Upgrade to ExtJS 4.0.2 - Released 06/09/2011
[extjs.git] / docs / app / Settings.js
diff --git a/docs/app/Settings.js b/docs/app/Settings.js
new file mode 100644 (file)
index 0000000..99593db
--- /dev/null
@@ -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;
+    }
+});