tabs to spaces label.js
This commit is contained in:
parent
6e6f6313a8
commit
4bbf9e2ea6
|
@ -37,64 +37,64 @@ Ext.ns('Deluge.ux');
|
||||||
*/
|
*/
|
||||||
Deluge.ux.AddLabelWindow = Ext.extend(Ext.Window, {
|
Deluge.ux.AddLabelWindow = Ext.extend(Ext.Window, {
|
||||||
|
|
||||||
title: _('Add Label'),
|
title: _('Add Label'),
|
||||||
width: 300,
|
width: 300,
|
||||||
height: 100,
|
height: 100,
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.ux.AddLabelWindow.superclass.initComponent.call(this);
|
Deluge.ux.AddLabelWindow.superclass.initComponent.call(this);
|
||||||
this.addButton(_('Cancel'), this.onCancelClick, this);
|
this.addButton(_('Cancel'), this.onCancelClick, this);
|
||||||
this.addButton(_('Ok'), this.onOkClick, this);
|
this.addButton(_('Ok'), this.onOkClick, this);
|
||||||
|
|
||||||
this.form = this.add({
|
this.form = this.add({
|
||||||
xtype: 'form',
|
xtype: 'form',
|
||||||
height: 35,
|
height: 35,
|
||||||
baseCls: 'x-plain',
|
baseCls: 'x-plain',
|
||||||
bodyStyle:'padding:5px 5px 0',
|
bodyStyle:'padding:5px 5px 0',
|
||||||
defaultType: 'textfield',
|
defaultType: 'textfield',
|
||||||
labelWidth: 50,
|
labelWidth: 50,
|
||||||
items: [{
|
items: [{
|
||||||
fieldLabel: _('Name'),
|
fieldLabel: _('Name'),
|
||||||
name: 'name',
|
name: 'name',
|
||||||
allowBlank: false,
|
allowBlank: false,
|
||||||
width: 220,
|
width: 220,
|
||||||
listeners: {
|
listeners: {
|
||||||
'specialkey': {
|
'specialkey': {
|
||||||
fn: function(field, e) {
|
fn: function(field, e) {
|
||||||
if (e.getKey() == 13) this.onOkClick();
|
if (e.getKey() == 13) this.onOkClick();
|
||||||
},
|
},
|
||||||
scope: this
|
scope: this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onCancelClick: function() {
|
onCancelClick: function() {
|
||||||
this.hide();
|
this.hide();
|
||||||
},
|
},
|
||||||
|
|
||||||
onOkClick: function() {
|
onOkClick: function() {
|
||||||
var label = this.form.getForm().getValues().name;
|
var label = this.form.getForm().getValues().name;
|
||||||
deluge.client.label.add(label, {
|
deluge.client.label.add(label, {
|
||||||
success: function() {
|
success: function() {
|
||||||
deluge.ui.update();
|
deluge.ui.update();
|
||||||
this.fireEvent('labeladded', label);
|
this.fireEvent('labeladded', label);
|
||||||
},
|
},
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
this.hide();
|
this.hide();
|
||||||
},
|
},
|
||||||
|
|
||||||
onHide: function(comp) {
|
onHide: function(comp) {
|
||||||
Deluge.ux.AddLabelWindow.superclass.onHide.call(this, comp);
|
Deluge.ux.AddLabelWindow.superclass.onHide.call(this, comp);
|
||||||
this.form.getForm().reset();
|
this.form.getForm().reset();
|
||||||
},
|
},
|
||||||
|
|
||||||
onShow: function(comp) {
|
onShow: function(comp) {
|
||||||
Deluge.ux.AddLabelWindow.superclass.onShow.call(this, comp);
|
Deluge.ux.AddLabelWindow.superclass.onShow.call(this, comp);
|
||||||
this.form.getForm().findField('name').focus(false, 150);
|
this.form.getForm().findField('name').focus(false, 150);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -104,245 +104,245 @@ Deluge.ux.AddLabelWindow = Ext.extend(Ext.Window, {
|
||||||
*/
|
*/
|
||||||
Deluge.ux.LabelOptionsWindow = Ext.extend(Ext.Window, {
|
Deluge.ux.LabelOptionsWindow = Ext.extend(Ext.Window, {
|
||||||
|
|
||||||
title: _('Label Options'),
|
title: _('Label Options'),
|
||||||
width: 325,
|
width: 325,
|
||||||
height: 240,
|
height: 240,
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.ux.LabelOptionsWindow.superclass.initComponent.call(this);
|
Deluge.ux.LabelOptionsWindow.superclass.initComponent.call(this);
|
||||||
this.addButton(_('Cancel'), this.onCancelClick, this);
|
this.addButton(_('Cancel'), this.onCancelClick, this);
|
||||||
this.addButton(_('Ok'), this.onOkClick, this);
|
this.addButton(_('Ok'), this.onOkClick, this);
|
||||||
|
|
||||||
this.form = this.add({
|
this.form = this.add({
|
||||||
xtype: 'form'
|
xtype: 'form'
|
||||||
});
|
});
|
||||||
|
|
||||||
this.tabs = this.form.add({
|
this.tabs = this.form.add({
|
||||||
xtype: 'tabpanel',
|
xtype: 'tabpanel',
|
||||||
height: 175,
|
height: 175,
|
||||||
border: false,
|
border: false,
|
||||||
items: [{
|
items: [{
|
||||||
title: _('Maximum'),
|
title: _('Maximum'),
|
||||||
items: [{
|
items: [{
|
||||||
border: false,
|
border: false,
|
||||||
items: [{
|
items: [{
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
border: false,
|
border: false,
|
||||||
labelWidth: 1,
|
labelWidth: 1,
|
||||||
style: 'margin-bottom: 0px; padding-bottom: 0px;',
|
style: 'margin-bottom: 0px; padding-bottom: 0px;',
|
||||||
items: [{
|
items: [{
|
||||||
xtype: 'checkbox',
|
xtype: 'checkbox',
|
||||||
name: 'apply_max',
|
name: 'apply_max',
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
boxLabel: _('Apply per torrent max settings:'),
|
boxLabel: _('Apply per torrent max settings:'),
|
||||||
listeners: {
|
listeners: {
|
||||||
check: this.onFieldChecked
|
check: this.onFieldChecked
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
}, {
|
}, {
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
border: false,
|
border: false,
|
||||||
defaultType: 'spinnerfield',
|
defaultType: 'spinnerfield',
|
||||||
style: 'margin-top: 0px; padding-top: 0px;',
|
style: 'margin-top: 0px; padding-top: 0px;',
|
||||||
items: [{
|
items: [{
|
||||||
fieldLabel: _('Download Speed'),
|
fieldLabel: _('Download Speed'),
|
||||||
name: 'max_download_speed',
|
name: 'max_download_speed',
|
||||||
width: 80,
|
width: 80,
|
||||||
disabled: true,
|
disabled: true,
|
||||||
value: -1,
|
value: -1,
|
||||||
minValue: -1
|
minValue: -1
|
||||||
}, {
|
}, {
|
||||||
fieldLabel: _('Upload Speed'),
|
fieldLabel: _('Upload Speed'),
|
||||||
name: 'max_upload_speed',
|
name: 'max_upload_speed',
|
||||||
width: 80,
|
width: 80,
|
||||||
disabled: true,
|
disabled: true,
|
||||||
value: -1,
|
value: -1,
|
||||||
minValue: -1
|
minValue: -1
|
||||||
}, {
|
}, {
|
||||||
fieldLabel: _('Upload Slots'),
|
fieldLabel: _('Upload Slots'),
|
||||||
name: 'max_upload_slots',
|
name: 'max_upload_slots',
|
||||||
width: 80,
|
width: 80,
|
||||||
disabled: true,
|
disabled: true,
|
||||||
value: -1,
|
value: -1,
|
||||||
minValue: -1
|
minValue: -1
|
||||||
}, {
|
}, {
|
||||||
fieldLabel: _('Connections'),
|
fieldLabel: _('Connections'),
|
||||||
name: 'max_connections',
|
name: 'max_connections',
|
||||||
width: 80,
|
width: 80,
|
||||||
disabled: true,
|
disabled: true,
|
||||||
value: -1,
|
value: -1,
|
||||||
minValue: -1
|
minValue: -1
|
||||||
}]
|
}]
|
||||||
}]
|
}]
|
||||||
}]
|
}]
|
||||||
}, {
|
}, {
|
||||||
title: _('Queue'),
|
title: _('Queue'),
|
||||||
items: [{
|
items: [{
|
||||||
border: false,
|
border: false,
|
||||||
items: [{
|
items: [{
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
border: false,
|
border: false,
|
||||||
labelWidth: 1,
|
labelWidth: 1,
|
||||||
style: 'margin-bottom: 0px; padding-bottom: 0px;',
|
style: 'margin-bottom: 0px; padding-bottom: 0px;',
|
||||||
items: [{
|
items: [{
|
||||||
xtype: 'checkbox',
|
xtype: 'checkbox',
|
||||||
name: 'apply_queue',
|
name: 'apply_queue',
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
boxLabel: _('Apply queue settings:'),
|
boxLabel: _('Apply queue settings:'),
|
||||||
listeners: {
|
listeners: {
|
||||||
check: this.onFieldChecked
|
check: this.onFieldChecked
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
}, {
|
}, {
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
border: false,
|
border: false,
|
||||||
labelWidth: 1,
|
labelWidth: 1,
|
||||||
defaultType: 'checkbox',
|
defaultType: 'checkbox',
|
||||||
style: 'margin-top: 0px; padding-top: 0px;',
|
style: 'margin-top: 0px; padding-top: 0px;',
|
||||||
defaults: {
|
defaults: {
|
||||||
style: 'margin-left: 20px'
|
style: 'margin-left: 20px'
|
||||||
},
|
},
|
||||||
items: [{
|
items: [{
|
||||||
boxLabel: _('Auto Managed'),
|
boxLabel: _('Auto Managed'),
|
||||||
name: 'is_auto_managed',
|
name: 'is_auto_managed',
|
||||||
disabled: true
|
disabled: true
|
||||||
}, {
|
}, {
|
||||||
boxLabel: _('Stop seed at ratio:'),
|
boxLabel: _('Stop seed at ratio:'),
|
||||||
name: 'stop_at_ratio',
|
name: 'stop_at_ratio',
|
||||||
disabled: true
|
disabled: true
|
||||||
}, {
|
}, {
|
||||||
xtype: 'spinnerfield',
|
xtype: 'spinnerfield',
|
||||||
name: 'stop_ratio',
|
name: 'stop_ratio',
|
||||||
width: 60,
|
width: 60,
|
||||||
decimalPrecision: 2,
|
decimalPrecision: 2,
|
||||||
incrementValue: 0.1,
|
incrementValue: 0.1,
|
||||||
style: 'position: relative; left: 100px',
|
style: 'position: relative; left: 100px',
|
||||||
disabled: true
|
disabled: true
|
||||||
}, {
|
}, {
|
||||||
boxLabel: _('Remove at ratio'),
|
boxLabel: _('Remove at ratio'),
|
||||||
name: 'remove_at_ratio',
|
name: 'remove_at_ratio',
|
||||||
disabled: true
|
disabled: true
|
||||||
}]
|
}]
|
||||||
}]
|
}]
|
||||||
}]
|
}]
|
||||||
}, {
|
}, {
|
||||||
title: _('Location'),
|
title: _('Location'),
|
||||||
items: [{
|
items: [{
|
||||||
border: false,
|
border: false,
|
||||||
items: [{
|
items: [{
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
border: false,
|
border: false,
|
||||||
labelWidth: 1,
|
labelWidth: 1,
|
||||||
style: 'margin-bottom: 0px; padding-bottom: 0px;',
|
style: 'margin-bottom: 0px; padding-bottom: 0px;',
|
||||||
items: [{
|
items: [{
|
||||||
xtype: 'checkbox',
|
xtype: 'checkbox',
|
||||||
name: 'apply_move_completed',
|
name: 'apply_move_completed',
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
boxLabel: _('Apply location settings:'),
|
boxLabel: _('Apply location settings:'),
|
||||||
listeners: {
|
listeners: {
|
||||||
check: this.onFieldChecked
|
check: this.onFieldChecked
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
}, {
|
}, {
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
border: false,
|
border: false,
|
||||||
labelWidth: 1,
|
labelWidth: 1,
|
||||||
defaultType: 'checkbox',
|
defaultType: 'checkbox',
|
||||||
labelWidth: 1,
|
labelWidth: 1,
|
||||||
style: 'margin-top: 0px; padding-top: 0px;',
|
style: 'margin-top: 0px; padding-top: 0px;',
|
||||||
defaults: {
|
defaults: {
|
||||||
style: 'margin-left: 20px'
|
style: 'margin-left: 20px'
|
||||||
},
|
},
|
||||||
items: [{
|
items: [{
|
||||||
boxLabel: _('Move completed to:'),
|
boxLabel: _('Move completed to:'),
|
||||||
name: 'move_completed',
|
name: 'move_completed',
|
||||||
disabled: true
|
disabled: true
|
||||||
}, {
|
}, {
|
||||||
xtype: 'textfield',
|
xtype: 'textfield',
|
||||||
name: 'move_completed_path',
|
name: 'move_completed_path',
|
||||||
width: 250,
|
width: 250,
|
||||||
disabled: true
|
disabled: true
|
||||||
}]
|
}]
|
||||||
}]
|
}]
|
||||||
}]
|
}]
|
||||||
}, {
|
}, {
|
||||||
title: _('Trackers'),
|
title: _('Trackers'),
|
||||||
items: [{
|
items: [{
|
||||||
border: false,
|
border: false,
|
||||||
items: [{
|
items: [{
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
border: false,
|
border: false,
|
||||||
labelWidth: 1,
|
labelWidth: 1,
|
||||||
style: 'margin-bottom: 0px; padding-bottom: 0px;',
|
style: 'margin-bottom: 0px; padding-bottom: 0px;',
|
||||||
items: [{
|
items: [{
|
||||||
xtype: 'checkbox',
|
xtype: 'checkbox',
|
||||||
name: 'auto_add',
|
name: 'auto_add',
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
boxLabel: _('Automatically apply label:'),
|
boxLabel: _('Automatically apply label:'),
|
||||||
listeners: {
|
listeners: {
|
||||||
check: this.onFieldChecked
|
check: this.onFieldChecked
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
}, {
|
}, {
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
border: false,
|
border: false,
|
||||||
labelWidth: 1,
|
labelWidth: 1,
|
||||||
style: 'margin-top: 0px; padding-top: 0px;',
|
style: 'margin-top: 0px; padding-top: 0px;',
|
||||||
defaults: {
|
defaults: {
|
||||||
style: 'margin-left: 20px'
|
style: 'margin-left: 20px'
|
||||||
},
|
},
|
||||||
defaultType: 'textarea',
|
defaultType: 'textarea',
|
||||||
items: [{
|
items: [{
|
||||||
boxLabel: _('Move completed to:'),
|
boxLabel: _('Move completed to:'),
|
||||||
name: 'auto_add_trackers',
|
name: 'auto_add_trackers',
|
||||||
width: 250,
|
width: 250,
|
||||||
height: 100,
|
height: 100,
|
||||||
disabled: true
|
disabled: true
|
||||||
}]
|
}]
|
||||||
}]
|
}]
|
||||||
}]
|
}]
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
getLabelOptions: function() {
|
getLabelOptions: function() {
|
||||||
deluge.client.label.get_options(this.label, {
|
deluge.client.label.get_options(this.label, {
|
||||||
success: this.gotOptions,
|
success: this.gotOptions,
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
gotOptions: function(options) {
|
gotOptions: function(options) {
|
||||||
this.form.getForm().setValues(options);
|
this.form.getForm().setValues(options);
|
||||||
},
|
},
|
||||||
|
|
||||||
show: function(label) {
|
show: function(label) {
|
||||||
Deluge.ux.LabelOptionsWindow.superclass.show.call(this);
|
Deluge.ux.LabelOptionsWindow.superclass.show.call(this);
|
||||||
this.label = label;
|
this.label = label;
|
||||||
this.setTitle(_('Label Options') + ': ' + this.label);
|
this.setTitle(_('Label Options') + ': ' + this.label);
|
||||||
this.tabs.setActiveTab(0);
|
this.tabs.setActiveTab(0);
|
||||||
this.getLabelOptions();
|
this.getLabelOptions();
|
||||||
},
|
},
|
||||||
|
|
||||||
onCancelClick: function() {
|
onCancelClick: function() {
|
||||||
this.hide();
|
this.hide();
|
||||||
},
|
},
|
||||||
|
|
||||||
onOkClick: function() {
|
onOkClick: function() {
|
||||||
var values = this.form.getForm().getFieldValues();
|
var values = this.form.getForm().getFieldValues();
|
||||||
if (values['auto_add_trackers']) {
|
if (values['auto_add_trackers']) {
|
||||||
values['auto_add_trackers'] = values['auto_add_trackers'].split('\n');
|
values['auto_add_trackers'] = values['auto_add_trackers'].split('\n');
|
||||||
}
|
}
|
||||||
deluge.client.label.set_options(this.label, values);
|
deluge.client.label.set_options(this.label, values);
|
||||||
this.hide();
|
this.hide();
|
||||||
},
|
},
|
||||||
|
|
||||||
onFieldChecked: function(field, checked) {
|
onFieldChecked: function(field, checked) {
|
||||||
var fs = field.ownerCt.nextSibling();
|
var fs = field.ownerCt.nextSibling();
|
||||||
fs.items.each(function(field) {
|
fs.items.each(function(field) {
|
||||||
field.setDisabled(!checked);
|
field.setDisabled(!checked);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -355,178 +355,178 @@ Ext.ns('Deluge.plugins');
|
||||||
*/
|
*/
|
||||||
Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, {
|
Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, {
|
||||||
|
|
||||||
name: 'Label',
|
name: 'Label',
|
||||||
|
|
||||||
createMenu: function() {
|
createMenu: function() {
|
||||||
this.labelMenu = new Ext.menu.Menu({
|
this.labelMenu = new Ext.menu.Menu({
|
||||||
items: [{
|
items: [{
|
||||||
text: _('Add Label'),
|
text: _('Add Label'),
|
||||||
iconCls: 'icon-add',
|
iconCls: 'icon-add',
|
||||||
handler: this.onLabelAddClick,
|
handler: this.onLabelAddClick,
|
||||||
scope: this
|
scope: this
|
||||||
}, {
|
}, {
|
||||||
text: _('Remove Label'),
|
text: _('Remove Label'),
|
||||||
disabled: true,
|
disabled: true,
|
||||||
iconCls: 'icon-remove',
|
iconCls: 'icon-remove',
|
||||||
handler: this.onLabelRemoveClick,
|
handler: this.onLabelRemoveClick,
|
||||||
scope: this
|
scope: this
|
||||||
}, {
|
}, {
|
||||||
text: _('Label Options'),
|
text: _('Label Options'),
|
||||||
disabled: true,
|
disabled: true,
|
||||||
handler: this.onLabelOptionsClick,
|
handler: this.onLabelOptionsClick,
|
||||||
scope: this
|
scope: this
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
setFilter: function(filter) {
|
setFilter: function(filter) {
|
||||||
filter.show_zero = true;
|
filter.show_zero = true;
|
||||||
filter.list.on('contextmenu', this.onLabelContextMenu, this);
|
filter.list.on('contextmenu', this.onLabelContextMenu, this);
|
||||||
filter.header.on('contextmenu', this.onLabelHeaderContextMenu, this);
|
filter.header.on('contextmenu', this.onLabelHeaderContextMenu, this);
|
||||||
this.filter = filter;
|
this.filter = filter;
|
||||||
},
|
},
|
||||||
|
|
||||||
updateTorrentMenu: function(filter) {
|
updateTorrentMenu: function(filter) {
|
||||||
for (var state in filter.getStates()) {
|
for (var state in filter.getStates()) {
|
||||||
if (!state) continue;
|
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
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onDisable: function() {
|
onDisable: function() {
|
||||||
deluge.sidebar.un('filtercreate', this.onFilterCreate);
|
deluge.sidebar.un('filtercreate', this.onFilterCreate);
|
||||||
deluge.sidebar.un('afterfiltercreate', this.onAfterFilterCreate);
|
deluge.sidebar.un('afterfiltercreate', this.onAfterFilterCreate);
|
||||||
delete Deluge.FilterPanel.templates.label;
|
delete Deluge.FilterPanel.templates.label;
|
||||||
this.deregisterTorrentStatus('label');
|
this.deregisterTorrentStatus('label');
|
||||||
deluge.menus.torrent.remove(this.tmSep);
|
deluge.menus.torrent.remove(this.tmSep);
|
||||||
deluge.menus.torrent.remove(this.tm);
|
deluge.menus.torrent.remove(this.tm);
|
||||||
},
|
},
|
||||||
|
|
||||||
onEnable: function() {
|
onEnable: function() {
|
||||||
this.torrentMenu = new Ext.menu.Menu({
|
this.torrentMenu = new Ext.menu.Menu({
|
||||||
items: [{
|
items: [{
|
||||||
text: _('No Label'),
|
text: _('No Label'),
|
||||||
label: '',
|
label: '',
|
||||||
handler: this.onTorrentMenuClick,
|
handler: this.onTorrentMenuClick,
|
||||||
scope: this
|
scope: this
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
|
|
||||||
this.tmSep = deluge.menus.torrent.add({
|
this.tmSep = deluge.menus.torrent.add({
|
||||||
xtype: 'menuseparator'
|
xtype: 'menuseparator'
|
||||||
});
|
});
|
||||||
|
|
||||||
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">' +
|
var lbltpl = '<div class="x-deluge-filter">' +
|
||||||
'<tpl if="filter">{filter}</tpl>' +
|
'<tpl if="filter">{filter}</tpl>' +
|
||||||
'<tpl if="!filter">No Label</tpl>' +
|
'<tpl if="!filter">No Label</tpl>' +
|
||||||
' ({count})' +
|
' ({count})' +
|
||||||
'</div>';
|
'</div>';
|
||||||
|
|
||||||
if (deluge.sidebar.hasFilter('label')) {
|
if (deluge.sidebar.hasFilter('label')) {
|
||||||
var filter = deluge.sidebar.getFilter('label');
|
var filter = deluge.sidebar.getFilter('label');
|
||||||
filter.list.columns[0].tpl = new Ext.XTemplate(lbltpl);
|
filter.list.columns[0].tpl = new Ext.XTemplate(lbltpl);
|
||||||
this.setFilter(filter);
|
this.setFilter(filter);
|
||||||
this.updateTorrentMenu(filter);
|
this.updateTorrentMenu(filter);
|
||||||
filter.list.refresh();
|
filter.list.refresh();
|
||||||
} else {
|
} else {
|
||||||
deluge.sidebar.on('filtercreate', this.onFilterCreate, this);
|
deluge.sidebar.on('filtercreate', this.onFilterCreate, this);
|
||||||
deluge.sidebar.on('afterfiltercreate', this.onAfterFilterCreate, this);
|
deluge.sidebar.on('afterfiltercreate', this.onAfterFilterCreate, this);
|
||||||
Deluge.FilterPanel.templates.label = lbltpl;
|
Deluge.FilterPanel.templates.label = lbltpl;
|
||||||
}
|
}
|
||||||
this.registerTorrentStatus('label', _('Label'));
|
this.registerTorrentStatus('label', _('Label'));
|
||||||
},
|
},
|
||||||
|
|
||||||
onAfterFilterCreate: function(sidebar, filter) {
|
onAfterFilterCreate: function(sidebar, filter) {
|
||||||
if (filter.filter != 'label') return;
|
if (filter.filter != 'label') return;
|
||||||
this.updateTorrentMenu(filter);
|
this.updateTorrentMenu(filter);
|
||||||
},
|
},
|
||||||
|
|
||||||
onFilterCreate: function(sidebar, filter) {
|
onFilterCreate: function(sidebar, filter) {
|
||||||
if (filter.filter != 'label') return;
|
if (filter.filter != 'label') return;
|
||||||
this.setFilter(filter);
|
this.setFilter(filter);
|
||||||
},
|
},
|
||||||
|
|
||||||
onLabelAddClick: function() {
|
onLabelAddClick: function() {
|
||||||
if (!this.addWindow) {
|
if (!this.addWindow) {
|
||||||
this.addWindow = new Deluge.ux.AddLabelWindow();
|
this.addWindow = new Deluge.ux.AddLabelWindow();
|
||||||
this.addWindow.on('labeladded', this.onLabelAdded, this);
|
this.addWindow.on('labeladded', this.onLabelAdded, this);
|
||||||
}
|
}
|
||||||
this.addWindow.show();
|
this.addWindow.show();
|
||||||
},
|
},
|
||||||
|
|
||||||
onLabelAdded: function(label) {
|
onLabelAdded: function(label) {
|
||||||
this.torrentMenu.addMenuItem({
|
this.torrentMenu.addMenuItem({
|
||||||
text: label,
|
text: label,
|
||||||
label: label,
|
label: label,
|
||||||
handler: this.onTorrentMenuClick,
|
handler: this.onTorrentMenuClick,
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onLabelContextMenu: function(dv, i, node, e) {
|
onLabelContextMenu: function(dv, i, node, e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (!this.labelMenu) this.createMenu();
|
if (!this.labelMenu) this.createMenu();
|
||||||
var r = dv.getRecord(node);
|
var r = dv.getRecord(node);
|
||||||
if (dv.getRecord(node).get('filter')) {
|
if (dv.getRecord(node).get('filter')) {
|
||||||
this.labelMenu.items.get(1).setDisabled(false);
|
this.labelMenu.items.get(1).setDisabled(false);
|
||||||
this.labelMenu.items.get(2).setDisabled(false);
|
this.labelMenu.items.get(2).setDisabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
dv.select(i);
|
dv.select(i);
|
||||||
this.labelMenu.showAt(e.getXY());
|
this.labelMenu.showAt(e.getXY());
|
||||||
},
|
},
|
||||||
|
|
||||||
onLabelHeaderContextMenu: function(e, t) {
|
onLabelHeaderContextMenu: function(e, t) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (!this.labelMenu) this.createMenu();
|
if (!this.labelMenu) this.createMenu();
|
||||||
this.labelMenu.items.get(1).setDisabled(true);
|
this.labelMenu.items.get(1).setDisabled(true);
|
||||||
this.labelMenu.items.get(2).setDisabled(true);
|
this.labelMenu.items.get(2).setDisabled(true);
|
||||||
this.labelMenu.showAt(e.getXY());
|
this.labelMenu.showAt(e.getXY());
|
||||||
},
|
},
|
||||||
|
|
||||||
onLabelOptionsClick: function() {
|
onLabelOptionsClick: function() {
|
||||||
if (!this.labelOpts) this.labelOpts = new Deluge.ux.LabelOptionsWindow();
|
if (!this.labelOpts) this.labelOpts = new Deluge.ux.LabelOptionsWindow();
|
||||||
this.labelOpts.show(this.filter.getState());
|
this.labelOpts.show(this.filter.getState());
|
||||||
},
|
},
|
||||||
|
|
||||||
onLabelRemoveClick: function() {
|
onLabelRemoveClick: function() {
|
||||||
var state = this.filter.getState();
|
var state = this.filter.getState();
|
||||||
deluge.client.label.remove(state, {
|
deluge.client.label.remove(state, {
|
||||||
success: function() {
|
success: function() {
|
||||||
deluge.ui.update();
|
deluge.ui.update();
|
||||||
this.torrentMenu.items.each(function(item) {
|
this.torrentMenu.items.each(function(item) {
|
||||||
if (item.text != state) return;
|
if (item.text != state) return;
|
||||||
this.torrentMenu.remove(item);
|
this.torrentMenu.remove(item);
|
||||||
var i = item;
|
var i = item;
|
||||||
}, this);
|
}, this);
|
||||||
},
|
},
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onTorrentMenuClick: function(item, e) {
|
onTorrentMenuClick: function(item, e) {
|
||||||
var ids = deluge.torrents.getSelectedIds();
|
var ids = deluge.torrents.getSelectedIds();
|
||||||
Ext.each(ids, function(id, i) {
|
Ext.each(ids, function(id, i) {
|
||||||
if (ids.length == i +1 ) {
|
if (ids.length == i +1 ) {
|
||||||
deluge.client.label.set_torrent(id, item.label, {
|
deluge.client.label.set_torrent(id, item.label, {
|
||||||
success: function() {
|
success: function() {
|
||||||
deluge.ui.update();
|
deluge.ui.update();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
deluge.client.label.set_torrent(id, item.label);
|
deluge.client.label.set_torrent(id, item.label);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Deluge.registerPlugin('Label', Deluge.plugins.LabelPlugin);
|
Deluge.registerPlugin('Label', Deluge.plugins.LabelPlugin);
|
||||||
|
|
Loading…
Reference in New Issue