X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/3789b528d8dd8aad4558e38e22d775bcab1cbd36..6746dc89c47ed01b165cc1152533605f97eb8e8d:/docs/app/Favorites.js diff --git a/docs/app/Favorites.js b/docs/app/Favorites.js new file mode 100644 index 00000000..3a9e1081 --- /dev/null +++ b/docs/app/Favorites.js @@ -0,0 +1,52 @@ +/** + * Favorites management. + */ +Ext.define("Docs.Favorites", { + extend: 'Docs.LocalStore', + storeName: 'Favorites', + singleton: true, + + /** + * Associates Favorites with Docs TreePanel component. + * @param {Docs.view.tree.Tree} tree + */ + setTree: function(tree) { + this.tree = tree; + }, + + /** + * Adds class to favorites + * + * @param {String} cls the class to add + */ + add: function(cls) { + if (!this.has(cls)) { + this.store.add({cls: cls}); + this.syncStore(); + this.tree.setFavorite(cls, true); + } + }, + + /** + * Removes class from favorites. + * + * @param {String} cls the class to remove + */ + remove: function(cls) { + if (this.has(cls)) { + this.store.removeAt(this.store.findExact('cls', cls)); + this.syncStore(); + this.tree.setFavorite(cls, false); + } + }, + + /** + * Checks if class is in favorites + * + * @param {String} cls the classname to check + * @return {Boolean} true when class exists in favorites. + */ + has: function(cls) { + return this.store.findExact('cls', cls) > -1; + } +});