From d46ef8550b923934ed8e1e154a74415b133423b2 Mon Sep 17 00:00:00 2001 From: Gnome Ann <> Date: Sun, 5 Dec 2021 03:04:45 -0500 Subject: [PATCH] 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 --- static/application.js | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/static/application.js b/static/application.js index d7e0792c..7778b990 100644 --- a/static/application.js +++ b/static/application.js @@ -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("
\ @@ -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",