Fix WI sortable handle events not being bound correctly

This fixes a problem where WI entries/folders are sometimes able to be
dragged into places they shouldn't be. Steps to reproduce:

1. Start a blank story
2. Refresh the browser
3. Open the W Info screen
4. Add a world info folder
5. Add a world info entry into that folder
6. Drag that world info entry
This commit is contained in:
Gnome Ann 2021-12-05 03:04:45 -05:00
parent 85aa180a90
commit d46ef8550b
1 changed files with 20 additions and 20 deletions

View File

@ -394,7 +394,15 @@ function addWiLine(ob) {
socket.send({'cmd': 'wiconstanton', 'data': ob.num});
}
});
$("#wihandle"+ob.num).off().on("mousedown", wientry_onfocusout);
$("#wihandle"+ob.num).off().on("mousedown", function () {
wientry_onfocusout()
$(".wisortable-container").addClass("wisortable-excluded");
// Prevent WI entries with extremely long comments from filling the screen and preventing scrolling
$(this).parent().css("max-height", "200px").find(".wicomment").find(".form-control").css("max-height", "110px");
}).on("mouseup", function () {
$(".wisortable-excluded-dynamic").removeClass("wisortable-excluded-dynamic");
$(this).parent().css("max-height", "").find(".wicomment").find(".form-control").css("max-height", "");
});
}
function addWiFolder(uid, ob) {
@ -452,7 +460,17 @@ function addWiFolder(uid, ob) {
hideWiFolderDeleteConfirm(uid);
})
$("#wifoldername"+uid).on("focusout", onfocusout);
$("#wifolderhandle"+uid).off().on("mousedown", onfocusout);
$("#wifolderhandle"+uid).off().on("mousedown", function () {
onfocusout();
$(".wilistitem, .wisortable-dummy").addClass("wisortable-excluded-dynamic");
// Prevent WI folders with extremely long names from filling the screen and preventing scrolling
$(this).parent().parent().find(".wisortable-body").addClass("hidden");
$(this).parent().css("max-height", "200px").find(".wifoldername").find(".form-control").css("max-height", "181px");
}).on("mouseup", function () {
$(".wisortable-excluded-dynamic").removeClass("wisortable-excluded-dynamic");
$(this).parent().parent().find(".wisortable-body").removeClass("hidden");
$(this).parent().css("max-height", "").find(".wifoldername").find(".form-control").css("max-height", "");
});
adjustWiFolderNameHeight($("#wifoldername"+uid)[0]);
} else {
wi_menu.append("<div class=\"wisortable-container\" id=\"wilistfoldercontainer"+uid+"\">\
@ -1855,24 +1873,6 @@ $(document).ready(function(){
wifolders_l = msg.wifolders_l;
} else if(msg.cmd == "wifinish") {
// Allow drag-and-drop rearranging of world info entries (via JQuery UI's "sortable widget")
$(".wifolderhandle").on("mousedown", function () {
$(".wilistitem, .wisortable-dummy").addClass("wisortable-excluded-dynamic");
// Prevent WI folders with extremely long names from filling the screen and preventing scrolling
$(this).parent().parent().find(".wisortable-body").addClass("hidden");
$(this).parent().css("max-height", "200px").find(".wifoldername").find(".form-control").css("max-height", "181px");
}).on("mouseup", function () {
$(".wisortable-excluded-dynamic").removeClass("wisortable-excluded-dynamic");
$(this).parent().parent().find(".wisortable-body").removeClass("hidden");
$(this).parent().css("max-height", "").find(".wifoldername").find(".form-control").css("max-height", "");
});
$(".wihandle:not(.wifolderhandle)").on("mousedown", function () {
$(".wisortable-container").addClass("wisortable-excluded");
// Prevent WI entries with extremely long comments from filling the screen and preventing scrolling
$(this).parent().css("max-height", "200px").find(".wicomment").find(".form-control").css("max-height", "110px");
}).on("mouseup", function () {
$(".wisortable-excluded-dynamic").removeClass("wisortable-excluded-dynamic");
$(this).parent().css("max-height", "").find(".wicomment").find(".form-control").css("max-height", "");
});
$("#gamescreen").sortable({
items: "#wimenu .wisortable-body > :not(.wisortable-excluded):not(.wisortable-excluded-dynamic), #wimenu .wisortable-container[folder-uid]:not(.wisortable-excluded):not(.wisortable-excluded-dynamic)",
containment: "#wimenu",