X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/6746dc89c47ed01b165cc1152533605f97eb8e8d..HEAD:/docs/source/Stateful.html diff --git a/docs/source/Stateful.html b/docs/source/Stateful.html index 226f1baa..1049ac6a 100644 --- a/docs/source/Stateful.html +++ b/docs/source/Stateful.html @@ -3,8 +3,8 @@ The source code - - + + @@ -58,7 +58,7 @@ Ext.state.Manager.setProvider(new Ext.state.CookieProvider({ * object hash which represents the restorable state of the object.</p> * <p>The value yielded by getState is passed to {@link Ext.state.Manager#set} * which uses the configured {@link Ext.state.Provider} to save the object - * keyed by the <code>{@link #stateId}</code></p>. + * keyed by the <code>{@link #stateId}</code>.</p> * <p>During construction, a stateful object attempts to <i>restore</i> * its state by calling {@link Ext.state.Manager#get} passing the * <code>{@link #stateId}</code></p> @@ -79,18 +79,18 @@ Ext.state.Manager.setProvider(new Ext.state.CookieProvider({ */ /** - * @cfg {Array} stateEvents + * @cfg {String[]} stateEvents * <p>An array of events that, when fired, should trigger this object to - * save its state (defaults to none). <code>stateEvents</code> may be any type + * save its state. Defaults to none. <code>stateEvents</code> may be any type * of event supported by this object, including browser or custom events * (e.g., <tt>['click', 'customerchange']</tt>).</p> * <p>See <code>{@link #stateful}</code> for an explanation of saving and * restoring object state.</p> */ - /** - * @cfg {Number} saveBuffer A buffer to be applied if many state events are fired within - * a short period. Defaults to 100. + /** + * @cfg {Number} saveDelay + * A buffer to be applied if many state events are fired within a short period. */ saveDelay: 100, @@ -175,7 +175,7 @@ Ext.state.Manager.setProvider(new Ext.state.CookieProvider({ /** * Add events that will trigger the state to be saved. - * @param {String/Array} events The event name or an array of event names. + * @param {String/String[]} events The event name or an array of event names. */ addStateEvents: function(events){ if (!Ext.isArray(events)) { @@ -288,6 +288,41 @@ Ext.state.Manager.setProvider(new Ext.state.CookieProvider({ } }, + /** + * Conditionally saves a single property from this object to the given state object. + * The idea is to only save state which has changed from the initial state so that + * current software settings do not override future software settings. Only those + * values that are user-changed state should be saved. + * + * @param {String} propName The name of the property to save. + * @param {Object} state The state object in to which to save the property. + * @param {String} stateName (optional) The name to use for the property in state. + * @return {Boolean} True if the property was saved, false if not. + */ + savePropToState: function (propName, state, stateName) { + var me = this, + value = me[propName], + config = me.initialConfig; + + if (me.hasOwnProperty(propName)) { + if (!config || config[propName] !== value) { + if (state) { + state[stateName || propName] = value; + } + return true; + } + } + return false; + }, + + savePropsToState: function (propNames, state) { + var me = this; + Ext.each(propNames, function (propName) { + me.savePropToState(propName, state); + }); + return state; + }, + /** * Destroys this stateful object. */