From 29e7a2dd787f77a94ce9a3b1103a0a2863ca8f08 Mon Sep 17 00:00:00 2001 From: Johnny Voruz Date: Sat, 30 Sep 2023 21:37:32 -0500 Subject: [PATCH 1/2] added listener + logic to Save Layout button to disable save when name = default --- .../webclient/js/plugins/goldenlayout.js | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/evennia/web/static/webclient/js/plugins/goldenlayout.js b/evennia/web/static/webclient/js/plugins/goldenlayout.js index 7957cf3cbc..4e966de404 100644 --- a/evennia/web/static/webclient/js/plugins/goldenlayout.js +++ b/evennia/web/static/webclient/js/plugins/goldenlayout.js @@ -3,6 +3,9 @@ * Golden Layout plugin * */ + + + let goldenlayout = (function () { var myLayout; // The actively used GoldenLayout API object. @@ -584,12 +587,33 @@ let goldenlayout = (function () { } - // + // Listener for realtime changes to the layout name input field. + // If the layout name is "default", the save button is disabled + // to prevent the perception of overwriting the default layout. + $(document).on("input", "#layoutName", function () { + console.log("Input changed to:", $(this).val()); + if ($(this).val() === "default") { + $(".savelayout").prop("disabled", true); + } else { + $(".savelayout").prop("disabled", false); + } + }); + // var onSaveLayout = function () { // get the name from the select box var name = $("#layoutName").val(); var layouts = $("#goldenlayouts"); + var saveButton = $(".savelayout"); // Using the class to select the button + + // Enable the save button in case it was disabled before + saveButton.prop("disabled", false); + + // Check if name is "default" and disable saving + if (name === "default") { + saveButton.prop("disabled", true); // Disabling the save button + return; // Prevent further execution of the function + } // make sure we have a valid name if( name !== "" ) { @@ -618,6 +642,8 @@ let goldenlayout = (function () { } + + // // Public // From d686eab37494c13954a8950e22fce9d015b22773 Mon Sep 17 00:00:00 2001 From: Johnny Voruz Date: Tue, 3 Oct 2023 15:13:57 -0500 Subject: [PATCH 2/2] Removed console Log and added additional code comments --- .../webclient/js/plugins/goldenlayout.js | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/evennia/web/static/webclient/js/plugins/goldenlayout.js b/evennia/web/static/webclient/js/plugins/goldenlayout.js index 4e966de404..7fe25d8db4 100644 --- a/evennia/web/static/webclient/js/plugins/goldenlayout.js +++ b/evennia/web/static/webclient/js/plugins/goldenlayout.js @@ -4,8 +4,6 @@ * */ - - let goldenlayout = (function () { var myLayout; // The actively used GoldenLayout API object. @@ -586,20 +584,18 @@ let goldenlayout = (function () { layoutDiv.append(div); } - // Listener for realtime changes to the layout name input field. // If the layout name is "default", the save button is disabled // to prevent the perception of overwriting the default layout. + $(document).on("input", "#layoutName", function () { - console.log("Input changed to:", $(this).val()); - if ($(this).val() === "default") { - $(".savelayout").prop("disabled", true); - } else { - $(".savelayout").prop("disabled", false); + if ($(this).val() === "default") { // Disable the save button if the name is "default" + $(".savelayout").prop("disabled", true); // Disabling the save button + } else { // Enable the save button if the name is not "default" + $(".savelayout").prop("disabled", false); // Enabling the save button } }); - // var onSaveLayout = function () { // get the name from the select box var name = $("#layoutName").val(); @@ -640,10 +636,6 @@ let goldenlayout = (function () { resetUI( evenniaGoldenLayouts.get(name) ); } } - - - - // // Public //