From fc04ff3a08956adde55e2668c555d8c2bc6da747 Mon Sep 17 00:00:00 2001 From: Gnome Ann <> Date: Wed, 22 Dec 2021 13:12:35 -0500 Subject: [PATCH] World info folders can now be collapsed by clicking on the folder icon --- aiserver.py | 6 ++++++ static/application.js | 40 +++++++++++++++++++++++++++++++++++----- static/custom.css | 24 +++++++++++++++++++++++- templates/index.html | 4 ++-- 4 files changed, 66 insertions(+), 8 deletions(-) diff --git a/aiserver.py b/aiserver.py index f971cab3..bc9f67d4 100644 --- a/aiserver.py +++ b/aiserver.py @@ -1710,6 +1710,12 @@ def get_message(msg): elif(msg['cmd'] == 'wiexpandfolder'): assert 0 <= int(msg['data']) < len(vars.worldinfo) emit('from_server', {'cmd': 'wiexpandfolder', 'data': msg['data']}, broadcast=True) + elif(msg['cmd'] == 'wifoldercollapsecontent'): + vars.wifolders_d[msg['data']]['collapsed'] = True + emit('from_server', {'cmd': 'wifoldercollapsecontent', 'data': msg['data']}, broadcast=True) + elif(msg['cmd'] == 'wifolderexpandcontent'): + vars.wifolders_d[msg['data']]['collapsed'] = False + emit('from_server', {'cmd': 'wifolderexpandcontent', 'data': msg['data']}, broadcast=True) elif(msg['cmd'] == 'wiupdate'): num = int(msg['num']) fields = ("key", "keysecondary", "content", "comment") diff --git a/static/application.js b/static/application.js index ad747d48..5746f05e 100644 --- a/static/application.js +++ b/static/application.js @@ -419,7 +419,7 @@ function addWiLine(ob) { function addWiFolder(uid, ob) { if(uid !== null) { var uninitialized = $("#wilistfoldercontainer"+null); - var html = "
\ + var html = "
\
\
\ \ @@ -428,7 +428,7 @@ function addWiFolder(uid, ob) {
\
\
\ - \ + \
\
\
\ @@ -461,7 +461,7 @@ function addWiFolder(uid, ob) { var onfocusout = function () { socket.send({'cmd': 'wifolderupdate', 'uid': uid, 'data': { name: $("#wifoldername"+uid).val(), - collapsed: false, + collapsed: !$("#btn_wifolderexpand"+uid).hasClass("folder-expanded"), }}); }; $("#wifoldergutter"+uid).on("click", function () { @@ -488,9 +488,22 @@ function addWiFolder(uid, ob) { $(this).parent().parent().find(".wisortable-body").removeClass("hidden"); $(this).parent().css("max-height", "").find(".wifoldername").find(".form-control").css("max-height", ""); }); + $("#btn_wifolderexpand"+uid).on("click", function () { + if($(this).hasClass("folder-expanded")) { + socket.send({'cmd': 'wifoldercollapsecontent', 'data': uid}); + } else { + socket.send({'cmd': 'wifolderexpandcontent', 'data': uid}); + } + }) adjustWiFolderNameHeight($("#wifoldername"+uid)[0]); + if(ob.collapsed) { + setTimeout(function() { + var container = $("#wilistfoldercontainer"+uid); + hide([container.find(".wifoldergutter-container"), container.find(".wisortable-body")]); + }, 2); + } } else { - wi_menu.append("
\ + wi_menu.append("
\
\
\ \ @@ -499,7 +512,7 @@ function addWiFolder(uid, ob) {
\
\
\ - \ + \
\
\
\ @@ -564,6 +577,18 @@ function hideWiFolderDeleteConfirm(num) { hide([$("#btn_wifolderdel"+num), $("#btn_wifoldercan"+num)]); } +function collapseWiFolderContent(uid) { + hide([$("#wifoldergutter"+uid), $(".wisortable-body[folder-uid="+uid+"]")]); + $("#btn_wifolderexpand"+uid).removeClass("folder-expanded"); + $("#wilistfoldercontainer"+uid).removeClass("folder-expanded"); +} + +function expandWiFolderContent(uid) { + show([$("#wifoldergutter"+uid), $(".wisortable-body[folder-uid="+uid+"]")]); + $("#btn_wifolderexpand"+uid).addClass("folder-expanded"); + $("#wilistfoldercontainer"+uid).addClass("folder-expanded"); +} + function enableWiSelective(num) { hide([$("#wikey"+num)]); $("#wikeyprimary"+num).val($("#wikey"+num).val()); @@ -1922,6 +1947,10 @@ $(document).ready(function(){ expandWiLine(msg.data); } else if(msg.cmd == "wiexpandfolder") { expandWiFolderLine(msg.data); + } else if(msg.cmd == "wifoldercollapsecontent") { + collapseWiFolderContent(msg.data); + } else if(msg.cmd == "wifolderexpandcontent") { + expandWiFolderContent(msg.data); } else if(msg.cmd == "wiselon") { enableWiSelective(msg.data); } else if(msg.cmd == "wiseloff") { @@ -2062,6 +2091,7 @@ $(document).ready(function(){ // Make the userscripts menu sortable var us_sortable_settings = { + placeholder: "ussortable-placeholder", delay: 2, cursor: "move", tolerance: "pointer", diff --git a/static/custom.css b/static/custom.css index f4933258..5bc6139b 100644 --- a/static/custom.css +++ b/static/custom.css @@ -603,7 +603,12 @@ chunk.editing, chunk.editing * { background-color: #3bf723; } -.wisortable-container { +.ussortable-placeholder { + height: 4px; + background-color: #3bf723; +} + +.wisortable-container.folder-expanded { padding-bottom: 50px; } @@ -702,6 +707,23 @@ chunk.editing, chunk.editing * { position: relative; } +.folder-expand { + opacity: 20%; +} + +.folder-expand:hover { + opacity: 44%; + cursor: pointer; +} + +.folder-expand.folder-expanded { + opacity: 80% !important; +} + +.folder-expand.folder-expanded:hover { + opacity: 100% !important; +} + .selective-key-icon { position: absolute !important; top: 5px !important; diff --git a/templates/index.html b/templates/index.html index 5997720f..45fcb78e 100644 --- a/templates/index.html +++ b/templates/index.html @@ -10,12 +10,12 @@ - + - +