mirror of
https://github.com/dataarts/dat.gui.git
synced 2024-12-12 04:08:27 +00:00
Added a delete button to the remember row and increased default width of gui when remeber is used
This commit is contained in:
parent
c2edd82e39
commit
f11aa04a2e
@ -766,7 +766,8 @@ common.extend(
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (this.autoPlace) {
|
if (this.autoPlace) {
|
||||||
// Set save row width
|
// Set save row width and increase to accomodate buttons
|
||||||
|
this.width += 40;
|
||||||
setWidth(this, this.width);
|
setWidth(this, this.width);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -858,6 +859,17 @@ common.extend(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
deleteSave: function() {
|
||||||
|
// Not allowed to remove Default preset
|
||||||
|
if (this.preset === DEFAULT_DEFAULT_PRESET_NAME || !confirm(`Delete preset "${this.preset}". Are you sure?`)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete this.load.remembered[this.preset];
|
||||||
|
this.preset = removeCurrentPresetOption(this);
|
||||||
|
this.saveToLocalStorageIfPossible();
|
||||||
|
},
|
||||||
|
|
||||||
listen: function(controller) {
|
listen: function(controller) {
|
||||||
const init = this.__listening.length === 0;
|
const init = this.__listening.length === 0;
|
||||||
this.__listening.push(controller);
|
this.__listening.push(controller);
|
||||||
@ -1191,6 +1203,11 @@ function addPresetOption(gui, name, setSelected) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function removeCurrentPresetOption(gui) {
|
||||||
|
gui.__preset_select.removeChild(gui.__preset_select.options[gui.__preset_select.selectedIndex]);
|
||||||
|
return gui.__preset_select.options[gui.__preset_select.selectedIndex].value;
|
||||||
|
}
|
||||||
|
|
||||||
function showHideExplain(gui, explain) {
|
function showHideExplain(gui, explain) {
|
||||||
explain.style.display = gui.useLocalStorage ? 'block' : 'none';
|
explain.style.display = gui.useLocalStorage ? 'block' : 'none';
|
||||||
}
|
}
|
||||||
@ -1224,6 +1241,11 @@ function addSaveMenu(gui) {
|
|||||||
dom.addClass(button3, 'button');
|
dom.addClass(button3, 'button');
|
||||||
dom.addClass(button3, 'revert');
|
dom.addClass(button3, 'revert');
|
||||||
|
|
||||||
|
const button4 = document.createElement('span');
|
||||||
|
button4.innerHTML = 'Delete';
|
||||||
|
dom.addClass(button4, 'button');
|
||||||
|
dom.addClass(button4, 'delete');
|
||||||
|
|
||||||
const select = gui.__preset_select = document.createElement('select');
|
const select = gui.__preset_select = document.createElement('select');
|
||||||
|
|
||||||
if (gui.load && gui.load.remembered) {
|
if (gui.load && gui.load.remembered) {
|
||||||
@ -1247,6 +1269,7 @@ function addSaveMenu(gui) {
|
|||||||
div.appendChild(button);
|
div.appendChild(button);
|
||||||
div.appendChild(button2);
|
div.appendChild(button2);
|
||||||
div.appendChild(button3);
|
div.appendChild(button3);
|
||||||
|
div.appendChild(button4);
|
||||||
|
|
||||||
if (SUPPORTS_LOCAL_STORAGE) {
|
if (SUPPORTS_LOCAL_STORAGE) {
|
||||||
const explain = document.getElementById('dg-local-explain');
|
const explain = document.getElementById('dg-local-explain');
|
||||||
@ -1298,6 +1321,10 @@ function addSaveMenu(gui) {
|
|||||||
gui.revert();
|
gui.revert();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
dom.bind(button4, 'click', function() {
|
||||||
|
gui.deleteSave();
|
||||||
|
});
|
||||||
|
|
||||||
// div.appendChild(button2);
|
// div.appendChild(button2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user