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
1 changed files with 9 additions and 0 deletions

View File

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