X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/3789b528d8dd8aad4558e38e22d775bcab1cbd36..6746dc89c47ed01b165cc1152533605f97eb8e8d:/docs/app/Settings.js diff --git a/docs/app/Settings.js b/docs/app/Settings.js new file mode 100644 index 00000000..99593db6 --- /dev/null +++ b/docs/app/Settings.js @@ -0,0 +1,36 @@ +/** + * Provides access to Docs app settings. + */ +Ext.define("Docs.Settings", { + extend: 'Docs.LocalStore', + storeName: 'Settings', + singleton: true, + + /** + * Saves a setting + * + * @param {String} key Name of the setting + * @param {Mixed} value Value of the setting + */ + set: function(key, value) { + var index = this.store.findExact("key", key); + if (index > -1) { + this.store.getAt(index).set({key: key, value: value}); + } + else { + this.store.add({key: key, value: value}); + } + this.syncStore(); + }, + + /** + * Gets value of a setting. + * + * @param {String} key Name of the setting + * @return {Mixed} value of the setting or undefined. + */ + get: function(key) { + var index = this.store.findExact("key", key); + return index > -1 ? this.store.getAt(index).get("value") : undefined; + } +});