diff --git a/build/dat.gui.js b/build/dat.gui.js index 9e64a25..d119e6c 100644 --- a/build/dat.gui.js +++ b/build/dat.gui.js @@ -106,8 +106,9 @@ dat.utils.common = (function () { each: function(obj, itr, scope) { - - if (ARR_EACH && obj.forEach === ARR_EACH) { + if (!obj) return; + + if (ARR_EACH && obj.forEach && obj.forEach === ARR_EACH) { obj.forEach(itr, scope); @@ -779,6 +780,8 @@ dat.controllers.NumberController = (function (Controller, common) { */ step: function(v) { this.__step = v; + this.__impliedStep = v; + this.__precision = numDecimals(v); return this; } @@ -1671,6 +1674,8 @@ dat.GUI = dat.gui.GUI = (function (css, saveDialogueContents, styleSheet, contro SUPPORTS_LOCAL_STORAGE && localStorage.getItem(getLocalStorageHash(this, 'isLocal')) === 'true'; + var saveToLocalStorage; + Object.defineProperties(this, /** @lends dat.gui.GUI.prototype */ @@ -1926,10 +1931,15 @@ dat.GUI = dat.gui.GUI = (function (css, saveDialogueContents, styleSheet, contro addResizeHandle(this); } - function saveToLocalStorage() { - localStorage.setItem(getLocalStorageHash(_this, 'gui'), JSON.stringify(_this.getSaveObject())); + saveToLocalStorage = function () { + if (SUPPORTS_LOCAL_STORAGE && localStorage.getItem(getLocalStorageHash(_this, 'isLocal')) === 'true') { + localStorage.setItem(getLocalStorageHash(_this, 'gui'), JSON.stringify(_this.getSaveObject())); + } } + // expose this method publicly + this.saveToLocalStorageIfPossible = saveToLocalStorage; + var root = _this.getRoot(); function resetWidth() { var root = _this.getRoot(); @@ -2226,6 +2236,7 @@ dat.GUI = dat.gui.GUI = (function (css, saveDialogueContents, styleSheet, contro this.load.remembered[this.preset] = getCurrentPreset(this); markPresetModified(this, false); + this.saveToLocalStorageIfPossible(); }, @@ -2242,6 +2253,7 @@ dat.GUI = dat.gui.GUI = (function (css, saveDialogueContents, styleSheet, contro this.load.remembered[presetName] = getCurrentPreset(this); this.preset = presetName; addPresetOption(this, presetName, true); + this.saveToLocalStorageIfPossible(); }, diff --git a/src/dat/gui/GUI.js b/src/dat/gui/GUI.js index b25b8bf..0077f7d 100644 --- a/src/dat/gui/GUI.js +++ b/src/dat/gui/GUI.js @@ -179,6 +179,8 @@ define([ SUPPORTS_LOCAL_STORAGE && localStorage.getItem(getLocalStorageHash(this, 'isLocal')) === 'true'; + var saveToLocalStorage; + Object.defineProperties(this, /** @lends dat.gui.GUI.prototype */ @@ -434,10 +436,15 @@ define([ addResizeHandle(this); } - function saveToLocalStorage() { - localStorage.setItem(getLocalStorageHash(_this, 'gui'), JSON.stringify(_this.getSaveObject())); + saveToLocalStorage = function () { + if (SUPPORTS_LOCAL_STORAGE && localStorage.getItem(getLocalStorageHash(_this, 'isLocal')) === 'true') { + localStorage.setItem(getLocalStorageHash(_this, 'gui'), JSON.stringify(_this.getSaveObject())); + } } + // expose this method publicly + this.saveToLocalStorageIfPossible = saveToLocalStorage; + var root = _this.getRoot(); function resetWidth() { var root = _this.getRoot(); @@ -734,6 +741,7 @@ define([ this.load.remembered[this.preset] = getCurrentPreset(this); markPresetModified(this, false); + this.saveToLocalStorageIfPossible(); }, @@ -750,6 +758,7 @@ define([ this.load.remembered[presetName] = getCurrentPreset(this); this.preset = presetName; addPresetOption(this, presetName, true); + this.saveToLocalStorageIfPossible(); }, diff --git a/src/dat/utils/common.js b/src/dat/utils/common.js index 99c9e14..b5bcc34 100644 --- a/src/dat/utils/common.js +++ b/src/dat/utils/common.js @@ -68,8 +68,9 @@ define([ each: function(obj, itr, scope) { - - if (ARR_EACH && obj.forEach === ARR_EACH) { + if (!obj) return; + + if (ARR_EACH && obj.forEach && obj.forEach === ARR_EACH) { obj.forEach(itr, scope);