added listener + logic to Save Layout button to disable save when name = default
This commit is contained in:
parent
67b1e4ca9c
commit
29e7a2dd78
1 changed files with 27 additions and 1 deletions
|
|
@ -3,6 +3,9 @@
|
||||||
* Golden Layout plugin
|
* Golden Layout plugin
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let goldenlayout = (function () {
|
let goldenlayout = (function () {
|
||||||
|
|
||||||
var myLayout; // The actively used GoldenLayout API object.
|
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 () {
|
var onSaveLayout = function () {
|
||||||
// get the name from the select box
|
// get the name from the select box
|
||||||
var name = $("#layoutName").val();
|
var name = $("#layoutName").val();
|
||||||
var layouts = $("#goldenlayouts");
|
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
|
// make sure we have a valid name
|
||||||
if( name !== "" ) {
|
if( name !== "" ) {
|
||||||
|
|
@ -618,6 +642,8 @@ let goldenlayout = (function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Public
|
// Public
|
||||||
//
|
//
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue