From 28a313e74e5ca813d89096ba3fb6615b72a6708b Mon Sep 17 00:00:00 2001 From: Damien Churchill Date: Wed, 28 Apr 2010 15:43:06 +0100 Subject: [PATCH] fix up the label plugin making it more stable and work with the new filter panel api --- deluge/plugins/label/label/data/label.js | 38 ++++++++++++++---------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/deluge/plugins/label/label/data/label.js b/deluge/plugins/label/label/data/label.js index b897cbf20..827053a09 100644 --- a/deluge/plugins/label/label/data/label.js +++ b/deluge/plugins/label/label/data/label.js @@ -334,15 +334,15 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, { }, updateTorrentMenu: function(filter) { - Ext.each(filter.getStates(), function(state) { - if (!state) return; + for (var state in filter.getStates()) { + if (!state) continue; this.torrentMenu.addMenuItem({ text: state, label: state, handler: this.onTorrentMenuClick, scope: this }); - }, this); + } }, onDisable: function() { @@ -355,17 +355,6 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, { }, onEnable: function() { - if (deluge.sidebar.hasFilter('label')) { - var filter = deluge.sidebar.getFilter('label'); - this.setFilter(filter); - this.updateTorrentMenu(filter); - } else { - deluge.sidebar.on('filtercreate', this.onFilterCreate, this); - deluge.sidebar.on('afterfiltercreate', this.onAfterFilterCreate, this); - Deluge.FilterPanel.templates.label = '
{filter}no label ({count})
'; - } - this.registerTorrentStatus('label', _('Label')); - this.torrentMenu = new Ext.menu.Menu({ items: [{ text: _('No Label'), @@ -382,7 +371,26 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, { this.tm = deluge.menus.torrent.add({ text: _('Label'), menu: this.torrentMenu - }) + }); + + var lbltpl = '
' + + '{filter}' + + 'no label' + + ' ({count})' + + '
'; + + if (deluge.sidebar.hasFilter('label')) { + var filter = deluge.sidebar.getFilter('label'); + filter.list.columns[0].tpl = new Ext.XTemplate(lbltpl); + this.setFilter(filter); + this.updateTorrentMenu(filter); + filter.list.refresh(); + } else { + deluge.sidebar.on('filtercreate', this.onFilterCreate, this); + deluge.sidebar.on('afterfiltercreate', this.onAfterFilterCreate, this); + Deluge.FilterPanel.templates.label = lbltpl; + } + this.registerTorrentStatus('label', _('Label')); }, onAfterFilterCreate: function(sidebar, filter) {