Loading template/app/Favorites.js +4 −15 Original line number Diff line number Diff line Loading @@ -2,20 +2,10 @@ * Favorites management. */ Ext.define("Docs.Favorites", { extend: 'Docs.LocalStore', storeName: 'Favorites', singleton: true, /** * Initializes favorites management. */ init: function() { // Load Favorites from localStorage this.localStorage = ('localStorage' in window && window['localStorage'] !== null); this.store = Ext.getStore("Favorites"); if (this.localStorage) this.store.load(); }, /** * Adds class to favorites * Loading @@ -24,7 +14,7 @@ Ext.define("Docs.Favorites", { add: function(cls) { if (!this.has(cls)) { this.store.add({cls: cls}); if (this.localStorage) this.store.sync(); this.syncStore(); } }, Loading @@ -36,7 +26,7 @@ Ext.define("Docs.Favorites", { remove: function(cls) { if (this.has(cls)) { this.store.removeAt(this.store.findExact('cls', cls)); if (this.localStorage) this.store.sync(); this.syncStore(); } }, Loading @@ -49,5 +39,4 @@ Ext.define("Docs.Favorites", { has: function(cls) { return this.store.findExact('cls', cls) > -1; } }); template/app/History.js +5 −7 Original line number Diff line number Diff line Loading @@ -2,6 +2,8 @@ * Browser history management using Ext.util.History. */ Ext.define("Docs.History", { extend: 'Docs.LocalStore', storeName: 'History', singleton: true, // Maximum number of items to keep in history store Loading @@ -15,11 +17,7 @@ Ext.define("Docs.History", { this.navigate(Ext.util.History.getToken()); }, this); Ext.util.History.on("change", this.navigate, this); // Load History from localStorage this.localStorage = ('localStorage' in window && window['localStorage'] !== null); this.store = Ext.getStore("History"); if (this.localStorage) this.store.load(); this.callParent(); }, // Parses current URL and navigates to the page Loading Loading @@ -85,7 +83,7 @@ Ext.define("Docs.History", { while (this.store.getAt(this.maxHistoryLength)) { this.store.removeAt(this.maxHistoryLength); } if (this.localStorage) this.store.sync(); this.syncStore(); } }, Loading @@ -97,6 +95,6 @@ Ext.define("Docs.History", { removeClass: function(cls) { var index = this.store.findExact('cls', cls); this.store.removeAt(index); if (this.localStorage) this.store.sync(); this.syncStore(); } }); template/app/LocalStore.js 0 → 100644 +28 −0 Original line number Diff line number Diff line /** * 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(); } }); template/index.html +1 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ <script type="text/javascript" src="prettify/prettify.js"></script> <script type="text/javascript" src="app.js"></script> <script type="text/javascript" src="app/LocalStore.js"></script> <script type="text/javascript" src="app/Favorites.js"></script> <script type="text/javascript" src="app/History.js"></script> Loading Loading
template/app/Favorites.js +4 −15 Original line number Diff line number Diff line Loading @@ -2,20 +2,10 @@ * Favorites management. */ Ext.define("Docs.Favorites", { extend: 'Docs.LocalStore', storeName: 'Favorites', singleton: true, /** * Initializes favorites management. */ init: function() { // Load Favorites from localStorage this.localStorage = ('localStorage' in window && window['localStorage'] !== null); this.store = Ext.getStore("Favorites"); if (this.localStorage) this.store.load(); }, /** * Adds class to favorites * Loading @@ -24,7 +14,7 @@ Ext.define("Docs.Favorites", { add: function(cls) { if (!this.has(cls)) { this.store.add({cls: cls}); if (this.localStorage) this.store.sync(); this.syncStore(); } }, Loading @@ -36,7 +26,7 @@ Ext.define("Docs.Favorites", { remove: function(cls) { if (this.has(cls)) { this.store.removeAt(this.store.findExact('cls', cls)); if (this.localStorage) this.store.sync(); this.syncStore(); } }, Loading @@ -49,5 +39,4 @@ Ext.define("Docs.Favorites", { has: function(cls) { return this.store.findExact('cls', cls) > -1; } });
template/app/History.js +5 −7 Original line number Diff line number Diff line Loading @@ -2,6 +2,8 @@ * Browser history management using Ext.util.History. */ Ext.define("Docs.History", { extend: 'Docs.LocalStore', storeName: 'History', singleton: true, // Maximum number of items to keep in history store Loading @@ -15,11 +17,7 @@ Ext.define("Docs.History", { this.navigate(Ext.util.History.getToken()); }, this); Ext.util.History.on("change", this.navigate, this); // Load History from localStorage this.localStorage = ('localStorage' in window && window['localStorage'] !== null); this.store = Ext.getStore("History"); if (this.localStorage) this.store.load(); this.callParent(); }, // Parses current URL and navigates to the page Loading Loading @@ -85,7 +83,7 @@ Ext.define("Docs.History", { while (this.store.getAt(this.maxHistoryLength)) { this.store.removeAt(this.maxHistoryLength); } if (this.localStorage) this.store.sync(); this.syncStore(); } }, Loading @@ -97,6 +95,6 @@ Ext.define("Docs.History", { removeClass: function(cls) { var index = this.store.findExact('cls', cls); this.store.removeAt(index); if (this.localStorage) this.store.sync(); this.syncStore(); } });
template/app/LocalStore.js 0 → 100644 +28 −0 Original line number Diff line number Diff line /** * 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(); } });
template/index.html +1 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ <script type="text/javascript" src="prettify/prettify.js"></script> <script type="text/javascript" src="app.js"></script> <script type="text/javascript" src="app/LocalStore.js"></script> <script type="text/javascript" src="app/Favorites.js"></script> <script type="text/javascript" src="app/History.js"></script> Loading