Upgrade to ExtJS 4.0.2 - Released 06/09/2011
[extjs.git] / docs / app / Settings.js
1 /**
2  * Provides access to Docs app settings.
3  */
4 Ext.define("Docs.Settings", {
5     extend: 'Docs.LocalStore',
6     storeName: 'Settings',
7     singleton: true,
8
9     /**
10      * Saves a setting
11      *
12      * @param {String} key  Name of the setting
13      * @param {Mixed} value  Value of the setting
14      */
15     set: function(key, value) {
16         var index = this.store.findExact("key", key);
17         if (index > -1) {
18             this.store.getAt(index).set({key: key, value: value});
19         }
20         else {
21             this.store.add({key: key, value: value});
22         }
23         this.syncStore();
24     },
25
26     /**
27      * Gets value of a setting.
28      *
29      * @param {String} key  Name of the setting
30      * @return {Mixed} value of the setting or undefined.
31      */
32     get: function(key) {
33         var index = this.store.findExact("key", key);
34         return index > -1 ? this.store.getAt(index).get("value") : undefined;
35     }
36 });