diff --git a/template/app/Application.js b/template/app/Application.js index bd5ca15c00adea78400efc5344150d71468d4456..12579613457797295eb9e7035a9e13e678aaaa27 100644 --- a/template/app/Application.js +++ b/template/app/Application.js @@ -9,7 +9,6 @@ Ext.define('Docs.Application', { name: 'Docs', requires: [ - 'Docs.Favorites', 'Docs.History', 'Docs.Settings' ], @@ -26,7 +25,6 @@ Ext.define('Docs.Application', { 'Search', 'InlineExamples', 'Examples', - 'Favorites', 'Guides', 'Videos', 'Tabs' @@ -34,7 +32,6 @@ Ext.define('Docs.Application', { launch: function() { Docs.App = this; - Docs.Favorites.init(); Docs.Settings.init(); Docs.contentState = {}; diff --git a/template/app/Favorites.js b/template/app/Favorites.js deleted file mode 100644 index 7f918bb7a6526cb11837d1987453ca9ab3125f1a..0000000000000000000000000000000000000000 --- a/template/app/Favorites.js +++ /dev/null @@ -1,99 +0,0 @@ -/** - * Favorites management. - */ -Ext.define("Docs.Favorites", { - extend: 'Docs.LocalStore', - storeName: 'Favorites', - singleton: true, - mixins: { - observable: 'Ext.util.Observable' - }, - - constructor: function() { - this.callParent(arguments); - - this.addEvents( - /** - * Fired when favorite added. - * @param {String} url The URL of the favorited page - */ - "add", - /** - * Fired when favorite removed. - * @param {String} url The URL of the favorited page - */ - "remove" - ); - }, - - init: function() { - this.callParent(arguments); - - // For backwards compatibility with old Favorites Model - // convert the old-style records to new schema. - if (this.store.first() && !this.store.first().get("url")) { - this.store.each(function(r) { - r.set("title", r.data.cls); - r.set("url", "/api/"+r.get("cls")); - r.set("cls", ""); - }); - this.syncStore(); - } - }, - - /** - * Adds page to favorites - * - * @param {String} url the page to add - * @param {String} title title for Favorites entry - */ - add: function(url, title) { - if (!this.has(url)) { - this.store.add({url: url, title: title}); - this.syncStore(); - this.fireEvent("add", url); - } - }, - - /** - * Removes page from favorites. - * - * @param {String} url the page URL to remove - */ - remove: function(url) { - if (this.has(url)) { - this.store.removeAt(this.store.findExact('url', url)); - this.syncStore(); - this.fireEvent("remove", url); - } - }, - - /** - * Checks if page exists in favorites - * - * @param {String} url the URL to check - * @return {Boolean} true when present - */ - has: function(url) { - return this.store.findExact('url', url) > -1; - }, - - /** - * Returns the number of favorites. - * @return {Number} - */ - getCount: function() { - return this.store.getCount(); - }, - - /** - * Save order of favorites in store. - * - * This needs to be called explicitly, because of a bug in - * localStorage which prevents the order of items being saved when - * they're changed. - */ - saveOrder: function() { - this.store.getProxy().setIds(Ext.Array.map(this.store.data.items, function(i) { return i.data.id; })); - } -}); diff --git a/template/app/LocalStore.js b/template/app/LocalStore.js index b259fc59ce23509c5d4c3ab1d99ccc97674160c1..1729305ce0c0467a87659f97f9e6bac652a219db 100644 --- a/template/app/LocalStore.js +++ b/template/app/LocalStore.js @@ -1,7 +1,7 @@ /** * Provides methods dealing with localStorage- and memory-store. * - * Base class for Favorites and Settings. + * Base class for Settings. */ Ext.define("Docs.LocalStore", { storeName: '', diff --git a/template/app/controller/Classes.js b/template/app/controller/Classes.js index 07cddbce826afbf7120bac66079f9b12ab34893e..fb83075c09a3293dc86b8161b829f47de70563df 100644 --- a/template/app/controller/Classes.js +++ b/template/app/controller/Classes.js @@ -10,12 +10,10 @@ Ext.define('Docs.controller.Classes', { ], stores: [ - 'Favorites', 'Settings' ], models: [ - 'Favorite', 'Setting' ], @@ -78,11 +76,6 @@ Ext.define('Docs.controller.Classes', { this.handleUrlClick(url, event, this.getTree()); } }, - 'classgrid': { - urlclick: function(url, event) { - this.handleUrlClick(url, event, this.getFavoritesGrid()); - } - }, 'toolbar': { toggleExpanded: function(expanded) { diff --git a/template/app/controller/Favorites.js b/template/app/controller/Favorites.js deleted file mode 100644 index c99296e7c7dcfc1c664bebebed052347a9181ff5..0000000000000000000000000000000000000000 --- a/template/app/controller/Favorites.js +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Controller for favorites. - * - * Syncronizes favorites store, grid and favorites markings in grid. - */ -Ext.define('Docs.controller.Favorites', { - extend: 'Ext.app.Controller', - - refs: [ - { - ref: 'panel', - selector: 'favoritespanel' - }, - { - ref: 'tree', - selector: 'classtree' - } - ], - - requires: [ - 'Docs.Favorites', - 'Docs.Settings' - ], - - init: function() { - this.control({ - 'favoritespanel': { - resize: function(cmp, w, h) { - Docs.Settings.set('favorites-height', h); - } - }, - 'favoritespanel > classgrid': { - closeclick: function(url) { - Docs.Favorites.remove(url); - }, - reorder: function() { - Docs.Favorites.saveOrder(); - } - }, - 'classtree': { - addfavorite: function(url, title) { - Docs.Favorites.add(url, title); - }, - removefavorite: function(url) { - Docs.Favorites.remove(url); - } - } - }); - - Docs.Favorites.on({ - add: function(url) { - // Show favorites when first favorite added - if (Docs.Favorites.getCount() > 0) { - // this.getPanel().show(); - } - // Add favorite marking to tree - this.getTree().setFavorite(url, true); - }, - remove: function(url) { - // Hide favorites when favorites list empty - if (Docs.Favorites.getCount() === 0) { - // this.getPanel().hide(); - } - // remove favorite marking from tree - this.getTree().setFavorite(url, false); - }, - scope: this - }); - } - -}); \ No newline at end of file diff --git a/template/app/model/Favorite.js b/template/app/model/Favorite.js deleted file mode 100644 index 6d9e3713824d76a899ecfefe51ae5dd16f327db4..0000000000000000000000000000000000000000 --- a/template/app/model/Favorite.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Favorite classes - */ -Ext.define('Docs.model.Favorite', { - fields: ['id', 'url', 'title', 'cls'], - extend: 'Ext.data.Model', - proxy: { - type: ('localStorage' in window && window['localStorage'] !== null) ? 'localstorage' : 'memory', - id: Docs.localStorageDb + '-favorites' - } -}); diff --git a/template/app/store/Favorites.js b/template/app/store/Favorites.js deleted file mode 100644 index f5d5b0f0f26807480fad767c69a2cd8fe6eb6e2e..0000000000000000000000000000000000000000 --- a/template/app/store/Favorites.js +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Favorites Store - */ -Ext.define('Docs.store.Favorites', { - extend: 'Ext.data.Store', - model: 'Docs.model.Favorite' -}); diff --git a/template/app/view/ClassGrid.js b/template/app/view/ClassGrid.js deleted file mode 100644 index 777eee528fc51ba5438898e5b05db247c840af0e..0000000000000000000000000000000000000000 --- a/template/app/view/ClassGrid.js +++ /dev/null @@ -1,145 +0,0 @@ -/** - * Gridpanel for showing list of classes. - */ -Ext.define('Docs.view.ClassGrid', { - extend: 'Ext.grid.Panel', - alias: 'widget.classgrid', - hideHeaders: true, - border: false, - bodyBorder: false, - - /** - * @cfg {Object} icons - * Mapping of class names to icon class names. - */ - icons: {}, - - /** - * @cfg {Boolean} enableClose - * Show or hide the close column - */ - enableClose: true, - - initComponent: function() { - this.addEvents( - /** - * @event - * Fired when class in grid clicked. - * @param {String} url URL of the page that was selected. For example "/api/Ext.Ajax". - * @param {Ext.EventObject} e - */ - "urlclick", - /** - * @event - * Fired when close button in grid clicked. - * @param {String} url URL of the page that was closed. For example "/api/Ext.Ajax". - */ - "closeclick", - /** - * @event - * Fired when items in grid reordered by drag-drop. - */ - "reorder" - ); - - this.viewConfig = { - plugins: [{ - pluginId: 'ddPlugin', - ptype: 'gridviewdragdrop', - animate: true, - dragText: 'Drag and drop to reorganize' - }], - listeners: { - drop: function() { - this.fireEvent("reorder"); - }, - scope: this - } - }; - - this.columns = [ - { - width: 18, - dataIndex: 'url', - renderer: function(url, data) { - data.tdCls = this.icons[url]; - }, - scope: this - }, - { - dataIndex: 'title', - flex: true, - renderer: function(title, data, r) { - return Ext.String.format('{1}', r.get("url"), title); - } - } - ]; - - if (this.enableClose) { - this.columns = this.columns.concat([ - { - xtype: 'actioncolumn', - width: 18, - icon: 'resources/images/x12.png', - tooltip: 'Delete', - handler: function(view, rowIndex) { - this.fireEvent("closeclick", this.getStore().getAt(rowIndex).get("url")); - }, - scope: this - } - ]); - } - - this.callParent(arguments); - - this.on("itemclick", function(view, record, item, index, event) { - // Only fire urlclick when the row background is clicked - // (that doesn't contain neither the link nor the close - // button). - if (!event.getTarget("img") && !event.getTarget("a")) { - this.fireEvent("urlclick", record.get("url"), event); - } - }, this); - - this.on("afterrender", function() { - // Initialize selection after rendering - this.selectUrl(this.selectedUrl); - - // Prevent row highlighting when doing drag-drop - var ddPlugin = this.getView().getPlugin('ddPlugin'); - var self = this; - ddPlugin.dragZone.onInitDrag = function() { - self.addCls('drag'); - Ext.view.DragZone.prototype.onInitDrag.apply(this, arguments); - }; - ddPlugin.dragZone.afterValidDrop = ddPlugin.dragZone.afterInvalidDrop = function() { - self.removeCls('drag'); - }; - }, this); - }, - - /** - * Selects page if grid contains such. - * Fires no events while selecting. - * @param {String} url page URL. - */ - selectUrl: function(url) { - this.selectedUrl = url; - // when grid hasn't been rendered yet, trying to select will give us error. - if (this.rendered) { - var index = this.getStore().findExact('url', url); - this.selectIndex(index); - } - }, - - selectIndex: function(index) { - if (index > -1) { - this.view.focusRow(index); - this.getSelectionModel().select(index, false, true); - } - else { - this.getSelectionModel().deselectAll(true); - } - } - -}); diff --git a/template/app/view/FavoritesPanel.js b/template/app/view/FavoritesPanel.js deleted file mode 100644 index 0b5d75bc68650c84800055a96164f2254bb7c99c..0000000000000000000000000000000000000000 --- a/template/app/view/FavoritesPanel.js +++ /dev/null @@ -1,49 +0,0 @@ -/** - * TabPanel with favorites grid - */ -Ext.define('Docs.view.FavoritesPanel', { - extend: 'Ext.tab.Panel', - requires: [ - 'Docs.view.ClassGrid', - 'Docs.Favorites' - ], - alias: 'widget.favoritespanel', - - padding: '2 4 0 0', - bodyPadding: '3 15 0 12', - border: false, - plain: true, - split: true, - - initComponent: function() { - this.addEvents( - /** - * @event - * Fired when favorites reordered in grid. - * @param {String} url The URL of the favorited page. - */ - "reorder" - ); - - this.items = [ - { - xtype: 'classgrid', - id: 'favorites-grid', - title: 'Favorites', - iconCls: 'icon-fav', - store: Ext.getStore('Favorites'), - icons: Docs.data.icons - } - ]; - - this.on({ - afterRender: function() { - // Add 7px padding at left side of tab-bar - this.tabBar.insert(0, {width: 7, xtype: 'container'}); - } - }); - - this.callParent(); - } - -}); diff --git a/template/app/view/cls/Tree.js b/template/app/view/cls/Tree.js index 2db6c9d04f1c3cb4a3c644da4325dd0bc807242e..6372840a1ab4e75db81c163564f68c31335dc883 100644 --- a/template/app/view/cls/Tree.js +++ b/template/app/view/cls/Tree.js @@ -4,9 +4,6 @@ Ext.define('Docs.view.cls.Tree', { extend: 'Ext.tree.Panel', alias : 'widget.classtree', - requires: [ - 'Docs.Favorites' - ], cls: 'class-tree iScroll', useArrows: true, @@ -23,25 +20,7 @@ Ext.define('Docs.view.cls.Tree', { * @param {String} url URL of the page to load * @param {Ext.EventObject} e */ - "urlclick", - /** - * @event - * Fired when item marked as favorite - * @param {String} url URL of the favorited tree node - * @param {String} title Title for the favorite - */ - "addfavorite", - /** - * @event - * Fired when favorite marking removed from tree node. - * @param {String} url URL of the favorite - */ - "removefavorite" - ); - - this.nodeTpl = new Ext.XTemplate( - '{text} ', - '' + "urlclick" ); // Expand the main tree @@ -52,23 +31,25 @@ Ext.define('Docs.view.cls.Tree', { this.callParent(); - // Add links for favoriting classes. + // Make all nodes into HTML links, so that middle-clicking on + // them will work cross-browser. // Do this after callParent, because the getRootNode() will // work after initComponent has run. - this.initFavIcons(); + this.nodeTpl = new Ext.XTemplate( + '{text}' + ); + this.initNodeLinks(); }, - initFavIcons: function() { - this.getRootNode().cascadeBy(this.addFavIcons, this); + initNodeLinks: function() { + this.getRootNode().cascadeBy(this.applyNodeTpl, this); }, - addFavIcons: function(node) { + applyNodeTpl: function(node) { if (node.get("leaf")) { - var url = node.raw.url; node.set("text", this.nodeTpl.apply({ text: node.get("text"), - url: url, - show: Docs.Favorites.has(url) ? "show" : "" + url: node.raw.url })); node.commit(); } @@ -78,20 +59,7 @@ Ext.define('Docs.view.cls.Tree', { var url = node.raw ? node.raw.url : node.data.url; if (url) { - if (e.getTarget(".fav")) { - var favEl = Ext.get(e.getTarget(".fav")); - if (favEl.hasCls('show')) { - this.fireEvent("removefavorite", url); - } - else { - this.fireEvent("addfavorite", url, this.getNodeTitle(node)); - } - } - // Only fire the event when not clicking on a link. - // Clicking on link is handled by the browser itself. - else if (!e.getTarget("a")) { - this.fireEvent("urlclick", url, e); - } + this.fireEvent("urlclick", url, e); } else if (!node.isLeaf()) { if (node.isExpanded()) { @@ -121,35 +89,10 @@ Ext.define('Docs.view.cls.Tree', { } }, - /** - * Sets favorite status of link on or off. - * - * @param {String} url URL of the link - * @param {Boolean} enable true to mark class as favorite. - */ - setFavorite: function(url, enable) { - var r = this.findRecordByUrl(url); - if (r) { - var show = enable ? "show" : ""; - r.set("text", r.get("text").replace(/class="fav *(show)?"/, 'class="fav '+show+'"')); - r.commit(); - } - }, - findRecordByUrl: function(url) { return this.getRootNode().findChildBy(function(n) { return url === n.raw.url; }, this, true); - }, - - getNodeTitle: function(node) { - var m = node.raw.url.match(/^\/api\/(.*)$/); - if (m) { - return m[1]; - } - else { - return node.raw.text; - } } }); diff --git a/template/resources/sass/viewport.scss b/template/resources/sass/viewport.scss index a9cc28b49fcbfec8c96d1c4d0fd5d29ad3428853..17349e0e75bedf0cf205bc4f92a3484b889efda3 100644 --- a/template/resources/sass/viewport.scss +++ b/template/resources/sass/viewport.scss @@ -71,8 +71,6 @@ $docs-monospace-font: "Menlo", "Courier New", Courier, monospace; background: url(../images/icons.png) no-repeat -3px -219px !important; } .icon-subclass { background: url(../images/icons.png) no-repeat -3px -299px !important; } - .icon-fav { - background: url(../images/icons.png) no-repeat -3px -328px !important; } .icon-example { background: url(../images/icons.png) no-repeat -3px -409px !important; } .icon-video { @@ -80,11 +78,6 @@ $docs-monospace-font: "Menlo", "Courier New", Courier, monospace; .icon-hist { background: url(../images/icons.png) no-repeat -3px -380px !important; } } -@mixin icon-fav { - background: url(../images/icons.png) no-repeat -4px -353px; } -@mixin icon-fav-over { - background: url(../images/icons.png) no-repeat -4px -326px; } - @mixin gray-h4 { h4 { font-family: $docs-font; @@ -255,8 +248,8 @@ a { background: #e9e9e9 url(../images/drag-bar-center.png) no-repeat center; border-width: 1px 0; } } -// Use normal color for class-links in tree and favorites grid -.class-tree, #favorites-grid { +// Use normal color for class-links in tree +.class-tree { .docClass, .docClass:hover { color: #000; } } @@ -413,23 +406,10 @@ a { position: relative; -webkit-transition: background-color 0.15s linear; @include icons; - a { color: #000; } - a.fav { - display: block; - width: 15px; - height: 15px; - position: absolute; - right: 7px; - top: 0; - &.show { - @include icon-fav-over; } } } + a { color: #000; } } .x-grid-row-over { .x-grid-cell-inner { - -webkit-transition: background-color 0.15s linear; - a.fav { - @include icon-fav; - &:hover { - @include icon-fav-over; } } } } + -webkit-transition: background-color 0.15s linear; } } .x-panel-body { border-color: #d4d4d4; background: $docs-bg-color; } }