fix up the label plugin making it more stable and work with the new filter panel api
This commit is contained in:
parent
5b6faa47b0
commit
28a313e74e
|
@ -334,15 +334,15 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, {
|
||||||
},
|
},
|
||||||
|
|
||||||
updateTorrentMenu: function(filter) {
|
updateTorrentMenu: function(filter) {
|
||||||
Ext.each(filter.getStates(), function(state) {
|
for (var state in filter.getStates()) {
|
||||||
if (!state) return;
|
if (!state) continue;
|
||||||
this.torrentMenu.addMenuItem({
|
this.torrentMenu.addMenuItem({
|
||||||
text: state,
|
text: state,
|
||||||
label: state,
|
label: state,
|
||||||
handler: this.onTorrentMenuClick,
|
handler: this.onTorrentMenuClick,
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
}, this);
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onDisable: function() {
|
onDisable: function() {
|
||||||
|
@ -355,17 +355,6 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, {
|
||||||
},
|
},
|
||||||
|
|
||||||
onEnable: function() {
|
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 = '<div class="x-deluge-filter x-deluge-{filter:lowercase}"><tpl if="filter">{filter}</tpl><tpl if="!filter">no label</tpl> ({count})</div>';
|
|
||||||
}
|
|
||||||
this.registerTorrentStatus('label', _('Label'));
|
|
||||||
|
|
||||||
this.torrentMenu = new Ext.menu.Menu({
|
this.torrentMenu = new Ext.menu.Menu({
|
||||||
items: [{
|
items: [{
|
||||||
text: _('No Label'),
|
text: _('No Label'),
|
||||||
|
@ -382,7 +371,26 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, {
|
||||||
this.tm = deluge.menus.torrent.add({
|
this.tm = deluge.menus.torrent.add({
|
||||||
text: _('Label'),
|
text: _('Label'),
|
||||||
menu: this.torrentMenu
|
menu: this.torrentMenu
|
||||||
})
|
});
|
||||||
|
|
||||||
|
var lbltpl = '<div class="x-deluge-filter">' +
|
||||||
|
'<tpl if="filter">{filter}</tpl>' +
|
||||||
|
'<tpl if="!filter">no label</tpl>' +
|
||||||
|
' ({count})' +
|
||||||
|
'</div>';
|
||||||
|
|
||||||
|
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) {
|
onAfterFilterCreate: function(sidebar, filter) {
|
||||||
|
|
Loading…
Reference in New Issue