Upgrade to ExtJS 4.0.2 - Released 06/09/2011
[extjs.git] / docs / app / LocalStore.js
diff --git a/docs/app/LocalStore.js b/docs/app/LocalStore.js
new file mode 100644 (file)
index 0000000..7bad266
--- /dev/null
@@ -0,0 +1,28 @@
+/**
+ * Provides methods dealing with localStorage- and memory-store.
+ *
+ * Base class for History and Favorites.
+ */
+Ext.define("Docs.LocalStore", {
+    storeName: '',
+
+    /**
+     * Initializes store management.
+     *
+     * Initializes this.store variable and loads the store if
+     * localStorage available.
+     */
+    init: function() {
+        this.localStorage = ('localStorage' in window && window['localStorage'] !== null);
+        this.store = Ext.getStore(this.storeName);
+        this.localStorage && this.store.load();
+    },
+
+    /**
+     * Syncs the store with localStorage if possible.
+     */
+    syncStore: function() {
+        this.localStorage && this.store.sync();
+    }
+
+});