Put safeguards on dragging and dropping into invalid positions

This commit is contained in:
Gnome Ann 2021-12-05 02:50:42 -05:00
parent 3e0b1a9e63
commit 85aa180a90

View File

@ -1029,6 +1029,10 @@ function sortableOnStop(event, ui) {
next_sibling = ui.item.next().next().attr("num");
}
next_sibling = parseInt(next_sibling);
if(Number.isNaN(next_sibling)) {
$(this).sortable("cancel");
return;
}
socket.send({'cmd': 'wimoveitem', 'destination': next_sibling, 'data': parseInt(ui.item.attr("num"))});
} else {
// Do the same thing for WI folders
@ -1038,6 +1042,10 @@ function sortableOnStop(event, ui) {
} else {
next_sibling = parseInt(next_sibling);
}
if(Number.isNaN(next_sibling)) {
$(this).sortable("cancel");
return;
}
socket.send({'cmd': 'wimovefolder', 'destination': next_sibling, 'data': parseInt(ui.item.attr("folder-uid"))});
}
}
@ -1873,6 +1881,7 @@ $(document).ready(function(){
start: sortableOnStart,
stop: sortableOnStop,
placeholder: "wisortable-placeholder",
delay: 2,
cursor: "move",
tolerance: "pointer",
opacity: 0.21,