Module: deluge Branch: master Commit: 466b245fdf358804b4039ab48654721b9a792923
Author: Damien Churchill <[email protected]> Date: Mon Apr 26 00:50:23 2010 +0100 make it easier to manipulate filters --- deluge/ui/web/js/deluge-all/FilterPanel.js | 12 ++++++------ deluge/ui/web/js/deluge-all/Sidebar.js | 23 +++++++++++++++++------ deluge/ui/web/js/deluge-all/UI.js | 2 +- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/deluge/ui/web/js/deluge-all/FilterPanel.js b/deluge/ui/web/js/deluge-all/FilterPanel.js index 70e479a..a686170 100644 --- a/deluge/ui/web/js/deluge-all/FilterPanel.js +++ b/deluge/ui/web/js/deluge-all/FilterPanel.js @@ -86,15 +86,15 @@ Deluge.FilterPanel = Ext.extend(Ext.Panel, { }, /** - * Return the currently selected filter - * @returns {String} the current filter + * Return the currently selected filter state + * @returns {String} the current filter state */ - getFilter: function() { + getState: function() { if (!this.list.getSelectionCount()) return; - var filter = this.list.getSelectedRecords()[0]; - if (filter.id == 'All') return; - return filter.id; + var state = this.list.getSelectedRecords()[0]; + if (state.id == 'All') return; + return state.id; }, /** diff --git a/deluge/ui/web/js/deluge-all/Sidebar.js b/deluge/ui/web/js/deluge-all/Sidebar.js index 8751491..53b4cc9 100644 --- a/deluge/ui/web/js/deluge-all/Sidebar.js +++ b/deluge/ui/web/js/deluge-all/Sidebar.js @@ -87,17 +87,28 @@ Deluge.Sidebar = Ext.extend(Ext.Panel, { this.fireEvent('afterfiltercreate', this, panel); }, - getFilters: function() { - var filters = {} + getFilterStates: function() { + var states = {} // Grab the filters from each of the filter panels this.items.each(function(panel) { - var filter = panel.getFilter(); - if (!filter == null) return; - filters[panel.filterType] = filter; + var state = panel.getState(); + if (!state == null) return; + states[panel.filterType] = state; }, this); - return filters; + return states; + }, + + hasFilter: function(filter) { + var has = false; + this.items.each(function(panel) { + if (panel.filterType == filter) { + has = true; + return false; + } + }); + return has; }, // private diff --git a/deluge/ui/web/js/deluge-all/UI.js b/deluge/ui/web/js/deluge-all/UI.js index 9286cca..879ec5f 100644 --- a/deluge/ui/web/js/deluge-all/UI.js +++ b/deluge/ui/web/js/deluge-all/UI.js @@ -102,7 +102,7 @@ deluge.ui = { }, update: function() { - var filters = deluge.sidebar.getFilters(); + var filters = deluge.sidebar.getFilterStates(); deluge.client.web.update_ui(Deluge.Keys.Grid, filters, { success: this.onUpdate, failure: this.onUpdateError, -- You received this message because you are subscribed to the Google Groups "deluge-commit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/deluge-commit?hl=en.
