spaces FTW
This commit is contained in:
parent
a96aeed706
commit
bb981127db
@ -37,86 +37,86 @@ Ext.ns('Deluge');
|
|||||||
*/
|
*/
|
||||||
Deluge.AddConnectionWindow = Ext.extend(Ext.Window, {
|
Deluge.AddConnectionWindow = Ext.extend(Ext.Window, {
|
||||||
|
|
||||||
title: _('Add Connection'),
|
title: _('Add Connection'),
|
||||||
iconCls: 'x-deluge-add-window-icon',
|
iconCls: 'x-deluge-add-window-icon',
|
||||||
|
|
||||||
layout: 'fit',
|
layout: 'fit',
|
||||||
width: 300,
|
width: 300,
|
||||||
height: 195,
|
height: 195,
|
||||||
|
|
||||||
bodyStyle: 'padding: 10px 5px;',
|
bodyStyle: 'padding: 10px 5px;',
|
||||||
closeAction: 'hide',
|
closeAction: 'hide',
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.AddConnectionWindow.superclass.initComponent.call(this);
|
Deluge.AddConnectionWindow.superclass.initComponent.call(this);
|
||||||
|
|
||||||
this.addEvents('hostadded');
|
this.addEvents('hostadded');
|
||||||
|
|
||||||
this.addButton(_('Close'), this.hide, this);
|
this.addButton(_('Close'), this.hide, this);
|
||||||
this.addButton(_('Add'), this.onAddClick, this);
|
this.addButton(_('Add'), this.onAddClick, this);
|
||||||
|
|
||||||
this.on('hide', this.onHide, this);
|
this.on('hide', this.onHide, this);
|
||||||
|
|
||||||
this.form = this.add({
|
this.form = this.add({
|
||||||
xtype: 'form',
|
xtype: 'form',
|
||||||
defaultType: 'textfield',
|
defaultType: 'textfield',
|
||||||
baseCls: 'x-plain',
|
baseCls: 'x-plain',
|
||||||
labelWidth: 60,
|
labelWidth: 60,
|
||||||
items: [{
|
items: [{
|
||||||
fieldLabel: _('Host'),
|
fieldLabel: _('Host'),
|
||||||
name: 'host',
|
name: 'host',
|
||||||
anchor: '75%',
|
anchor: '75%',
|
||||||
value: ''
|
value: ''
|
||||||
}, {
|
}, {
|
||||||
xtype: 'spinnerfield',
|
xtype: 'spinnerfield',
|
||||||
fieldLabel: _('Port'),
|
fieldLabel: _('Port'),
|
||||||
name: 'port',
|
name: 'port',
|
||||||
strategy: {
|
strategy: {
|
||||||
xtype: 'number',
|
xtype: 'number',
|
||||||
decimalPrecision: 0,
|
decimalPrecision: 0,
|
||||||
minValue: -1,
|
minValue: -1,
|
||||||
maxValue: 65535
|
maxValue: 65535
|
||||||
},
|
},
|
||||||
value: '58846',
|
value: '58846',
|
||||||
anchor: '40%'
|
anchor: '40%'
|
||||||
}, {
|
}, {
|
||||||
fieldLabel: _('Username'),
|
fieldLabel: _('Username'),
|
||||||
name: 'username',
|
name: 'username',
|
||||||
anchor: '75%',
|
anchor: '75%',
|
||||||
value: ''
|
value: ''
|
||||||
}, {
|
}, {
|
||||||
fieldLabel: _('Password'),
|
fieldLabel: _('Password'),
|
||||||
anchor: '75%',
|
anchor: '75%',
|
||||||
name: 'password',
|
name: 'password',
|
||||||
inputType: 'password',
|
inputType: 'password',
|
||||||
value: ''
|
value: ''
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onAddClick: function() {
|
onAddClick: function() {
|
||||||
var values = this.form.getForm().getValues();
|
var values = this.form.getForm().getValues();
|
||||||
deluge.client.web.add_host(values.host, values.port, values.username, values.password, {
|
deluge.client.web.add_host(values.host, values.port, values.username, values.password, {
|
||||||
success: function(result) {
|
success: function(result) {
|
||||||
if (!result[0]) {
|
if (!result[0]) {
|
||||||
Ext.MessageBox.show({
|
Ext.MessageBox.show({
|
||||||
title: _('Error'),
|
title: _('Error'),
|
||||||
msg: "Unable to add host: " + result[1],
|
msg: "Unable to add host: " + result[1],
|
||||||
buttons: Ext.MessageBox.OK,
|
buttons: Ext.MessageBox.OK,
|
||||||
modal: false,
|
modal: false,
|
||||||
icon: Ext.MessageBox.ERROR,
|
icon: Ext.MessageBox.ERROR,
|
||||||
iconCls: 'x-deluge-icon-error'
|
iconCls: 'x-deluge-icon-error'
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.fireEvent('hostadded');
|
this.fireEvent('hostadded');
|
||||||
}
|
}
|
||||||
this.hide();
|
this.hide();
|
||||||
},
|
},
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onHide: function() {
|
onHide: function() {
|
||||||
this.form.getForm().reset();
|
this.form.getForm().reset();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -36,57 +36,57 @@ Ext.ns('Deluge');
|
|||||||
* @extends Ext.Window
|
* @extends Ext.Window
|
||||||
*/
|
*/
|
||||||
Deluge.AddTrackerWindow = Ext.extend(Ext.Window, {
|
Deluge.AddTrackerWindow = Ext.extend(Ext.Window, {
|
||||||
|
|
||||||
title: _('Add Tracker'),
|
title: _('Add Tracker'),
|
||||||
layout: 'fit',
|
layout: 'fit',
|
||||||
width: 375,
|
width: 375,
|
||||||
height: 150,
|
height: 150,
|
||||||
plain: true,
|
plain: true,
|
||||||
closable: true,
|
closable: true,
|
||||||
resizable: false,
|
resizable: false,
|
||||||
|
|
||||||
bodyStyle: 'padding: 5px',
|
bodyStyle: 'padding: 5px',
|
||||||
buttonAlign: 'right',
|
buttonAlign: 'right',
|
||||||
closeAction: 'hide',
|
closeAction: 'hide',
|
||||||
iconCls: 'x-deluge-edit-trackers',
|
iconCls: 'x-deluge-edit-trackers',
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.AddTrackerWindow.superclass.initComponent.call(this);
|
Deluge.AddTrackerWindow.superclass.initComponent.call(this);
|
||||||
|
|
||||||
this.addButton(_('Cancel'), this.onCancelClick, this);
|
this.addButton(_('Cancel'), this.onCancelClick, this);
|
||||||
this.addButton(_('Add'), this.onAddClick, this);
|
this.addButton(_('Add'), this.onAddClick, this);
|
||||||
this.addEvents('add');
|
this.addEvents('add');
|
||||||
|
|
||||||
this.form = this.add({
|
this.form = this.add({
|
||||||
xtype: 'form',
|
xtype: 'form',
|
||||||
defaultType: 'textarea',
|
defaultType: 'textarea',
|
||||||
baseCls: 'x-plain',
|
baseCls: 'x-plain',
|
||||||
labelWidth: 55,
|
labelWidth: 55,
|
||||||
items: [{
|
items: [{
|
||||||
fieldLabel: _('Trackers'),
|
fieldLabel: _('Trackers'),
|
||||||
name: 'trackers',
|
name: 'trackers',
|
||||||
anchor: '100%'
|
anchor: '100%'
|
||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
onAddClick: function() {
|
onAddClick: function() {
|
||||||
var trackers = this.form.getForm().findField('trackers').getValue();
|
var trackers = this.form.getForm().findField('trackers').getValue();
|
||||||
trackers = trackers.split('\n');
|
trackers = trackers.split('\n');
|
||||||
|
|
||||||
var cleaned = [];
|
var cleaned = [];
|
||||||
Ext.each(trackers, function(tracker) {
|
Ext.each(trackers, function(tracker) {
|
||||||
if (Ext.form.VTypes.url(tracker)) {
|
if (Ext.form.VTypes.url(tracker)) {
|
||||||
cleaned.push(tracker);
|
cleaned.push(tracker);
|
||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
this.fireEvent('add', cleaned);
|
this.fireEvent('add', cleaned);
|
||||||
this.hide();
|
this.hide();
|
||||||
this.form.getForm().findField('trackers').setValue('');
|
this.form.getForm().findField('trackers').setValue('');
|
||||||
},
|
},
|
||||||
|
|
||||||
onCancelClick: function() {
|
onCancelClick: function() {
|
||||||
this.form.getForm().findField('trackers').setValue('');
|
this.form.getForm().findField('trackers').setValue('');
|
||||||
this.hide();
|
this.hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -39,157 +39,157 @@ Ext.namespace('Ext.ux.util');
|
|||||||
*/
|
*/
|
||||||
Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, {
|
Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, {
|
||||||
|
|
||||||
_components: [],
|
_components: [],
|
||||||
|
|
||||||
_methods: [],
|
_methods: [],
|
||||||
|
|
||||||
_requests: {},
|
_requests: {},
|
||||||
|
|
||||||
_url: null,
|
_url: null,
|
||||||
|
|
||||||
_optionKeys: ['scope', 'success', 'failure'],
|
_optionKeys: ['scope', 'success', 'failure'],
|
||||||
|
|
||||||
constructor: function(config) {
|
constructor: function(config) {
|
||||||
Ext.ux.util.RpcClient.superclass.constructor.call(this, config);
|
Ext.ux.util.RpcClient.superclass.constructor.call(this, config);
|
||||||
this._url = config.url || null;
|
this._url = config.url || null;
|
||||||
this._id = 0;
|
this._id = 0;
|
||||||
|
|
||||||
this.addEvents(
|
this.addEvents(
|
||||||
// raw events
|
// raw events
|
||||||
/**
|
/**
|
||||||
* @event connected
|
* @event connected
|
||||||
* Fires when the client has retrieved the list of methods from the server.
|
* Fires when the client has retrieved the list of methods from the server.
|
||||||
* @param {Ext.ux.util.RpcClient} this
|
* @param {Ext.ux.util.RpcClient} this
|
||||||
*/
|
*/
|
||||||
'connected',
|
'connected',
|
||||||
|
|
||||||
'error'
|
'error'
|
||||||
);
|
);
|
||||||
this.reloadMethods();
|
this.reloadMethods();
|
||||||
},
|
},
|
||||||
|
|
||||||
reloadMethods: function() {
|
reloadMethods: function() {
|
||||||
Ext.each(this._components, function(component) {
|
Ext.each(this._components, function(component) {
|
||||||
delete this[component];
|
delete this[component];
|
||||||
}, this);
|
}, this);
|
||||||
this._execute('system.listMethods', {
|
this._execute('system.listMethods', {
|
||||||
success: this._setMethods,
|
success: this._setMethods,
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
_execute: function(method, options) {
|
_execute: function(method, options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
options.params = options.params || [];
|
options.params = options.params || [];
|
||||||
options.id = this._id;
|
options.id = this._id;
|
||||||
|
|
||||||
var request = Ext.encode({
|
var request = Ext.encode({
|
||||||
method: method,
|
method: method,
|
||||||
params: options.params,
|
params: options.params,
|
||||||
id: options.id
|
id: options.id
|
||||||
});
|
});
|
||||||
this._id++;
|
this._id++;
|
||||||
|
|
||||||
return Ext.Ajax.request({
|
return Ext.Ajax.request({
|
||||||
url: this._url,
|
url: this._url,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
success: this._onSuccess,
|
success: this._onSuccess,
|
||||||
failure: this._onFailure,
|
failure: this._onFailure,
|
||||||
scope: this,
|
scope: this,
|
||||||
jsonData: request,
|
jsonData: request,
|
||||||
options: options
|
options: options
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
_onFailure: function(response, requestOptions) {
|
_onFailure: function(response, requestOptions) {
|
||||||
var options = requestOptions.options;
|
var options = requestOptions.options;
|
||||||
errorObj = {
|
errorObj = {
|
||||||
id: options.id,
|
id: options.id,
|
||||||
result: null,
|
result: null,
|
||||||
error: {
|
error: {
|
||||||
msg: 'HTTP: ' + response.status + ' ' + response.statusText,
|
msg: 'HTTP: ' + response.status + ' ' + response.statusText,
|
||||||
code: 255
|
code: 255
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.fireEvent('error', errorObj, response, requestOptions)
|
this.fireEvent('error', errorObj, response, requestOptions)
|
||||||
|
|
||||||
if (Ext.type(options.failure) != 'function') return;
|
if (Ext.type(options.failure) != 'function') return;
|
||||||
if (options.scope) {
|
if (options.scope) {
|
||||||
options.failure.call(options.scope, errorObj, response, requestOptions);
|
options.failure.call(options.scope, errorObj, response, requestOptions);
|
||||||
} else {
|
} else {
|
||||||
options.failure(errorObj, response, requestOptions);
|
options.failure(errorObj, response, requestOptions);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_onSuccess: function(response, requestOptions) {
|
_onSuccess: function(response, requestOptions) {
|
||||||
var responseObj = Ext.decode(response.responseText);
|
var responseObj = Ext.decode(response.responseText);
|
||||||
var options = requestOptions.options;
|
var options = requestOptions.options;
|
||||||
if (responseObj.error) {
|
if (responseObj.error) {
|
||||||
this.fireEvent('error', responseObj, response, requestOptions);
|
this.fireEvent('error', responseObj, response, requestOptions);
|
||||||
|
|
||||||
if (Ext.type(options.failure) != 'function') return;
|
if (Ext.type(options.failure) != 'function') return;
|
||||||
if (options.scope) {
|
if (options.scope) {
|
||||||
options.failure.call(options.scope, responseObj, response, requestOptions);
|
options.failure.call(options.scope, responseObj, response, requestOptions);
|
||||||
} else {
|
} else {
|
||||||
options.failure(responseObj, response, requestOptions);
|
options.failure(responseObj, response, requestOptions);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Ext.type(options.success) != 'function') return;
|
if (Ext.type(options.success) != 'function') return;
|
||||||
if (options.scope) {
|
if (options.scope) {
|
||||||
options.success.call(options.scope, responseObj.result, responseObj, response, requestOptions);
|
options.success.call(options.scope, responseObj.result, responseObj, response, requestOptions);
|
||||||
} else {
|
} else {
|
||||||
options.success(responseObj.result, responseObj, response, requestOptions);
|
options.success(responseObj.result, responseObj, response, requestOptions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_parseArgs: function(args) {
|
_parseArgs: function(args) {
|
||||||
var params = [];
|
var params = [];
|
||||||
Ext.each(args, function(arg) {
|
Ext.each(args, function(arg) {
|
||||||
params.push(arg);
|
params.push(arg);
|
||||||
});
|
});
|
||||||
|
|
||||||
var options = params[params.length - 1];
|
var options = params[params.length - 1];
|
||||||
if (Ext.type(options) == 'object') {
|
if (Ext.type(options) == 'object') {
|
||||||
var keys = Ext.keys(options), isOption = false;
|
var keys = Ext.keys(options), isOption = false;
|
||||||
|
|
||||||
Ext.each(this._optionKeys, function(key) {
|
Ext.each(this._optionKeys, function(key) {
|
||||||
if (keys.indexOf(key) > -1) isOption = true;
|
if (keys.indexOf(key) > -1) isOption = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isOption) {
|
if (isOption) {
|
||||||
params.remove(options)
|
params.remove(options)
|
||||||
} else {
|
} else {
|
||||||
options = {}
|
options = {}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
options = {}
|
options = {}
|
||||||
}
|
}
|
||||||
options.params = params;
|
options.params = params;
|
||||||
return options;
|
return options;
|
||||||
},
|
},
|
||||||
|
|
||||||
_setMethods: function(methods) {
|
_setMethods: function(methods) {
|
||||||
var components = {}, self = this;
|
var components = {}, self = this;
|
||||||
|
|
||||||
Ext.each(methods, function(method) {
|
Ext.each(methods, function(method) {
|
||||||
var parts = method.split('.');
|
var parts = method.split('.');
|
||||||
var component = components[parts[0]] || {};
|
var component = components[parts[0]] || {};
|
||||||
|
|
||||||
var fn = function() {
|
var fn = function() {
|
||||||
var options = self._parseArgs(arguments);
|
var options = self._parseArgs(arguments);
|
||||||
return self._execute(method, options);
|
return self._execute(method, options);
|
||||||
}
|
}
|
||||||
component[parts[1]] = fn;
|
component[parts[1]] = fn;
|
||||||
components[parts[0]] = component;
|
components[parts[0]] = component;
|
||||||
});
|
});
|
||||||
|
|
||||||
for (var name in components) {
|
for (var name in components) {
|
||||||
self[name] = components[name];
|
self[name] = components[name];
|
||||||
}
|
}
|
||||||
|
|
||||||
this._components = Ext.keys(components);
|
this._components = Ext.keys(components);
|
||||||
this.fireEvent('connected', this);
|
this.fireEvent('connected', this);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -32,345 +32,345 @@
|
|||||||
|
|
||||||
Deluge.ConnectionManager = Ext.extend(Ext.Window, {
|
Deluge.ConnectionManager = Ext.extend(Ext.Window, {
|
||||||
|
|
||||||
layout: 'fit',
|
layout: 'fit',
|
||||||
width: 300,
|
width: 300,
|
||||||
height: 220,
|
height: 220,
|
||||||
bodyStyle: 'padding: 10px 5px;',
|
bodyStyle: 'padding: 10px 5px;',
|
||||||
buttonAlign: 'right',
|
buttonAlign: 'right',
|
||||||
closeAction: 'hide',
|
closeAction: 'hide',
|
||||||
closable: true,
|
closable: true,
|
||||||
plain: true,
|
plain: true,
|
||||||
title: _('Connection Manager'),
|
title: _('Connection Manager'),
|
||||||
iconCls: 'x-deluge-connect-window-icon',
|
iconCls: 'x-deluge-connect-window-icon',
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.ConnectionManager.superclass.initComponent.call(this);
|
Deluge.ConnectionManager.superclass.initComponent.call(this);
|
||||||
this.on('hide', this.onHide, this);
|
this.on('hide', this.onHide, this);
|
||||||
this.on('show', this.onShow, this);
|
this.on('show', this.onShow, this);
|
||||||
|
|
||||||
deluge.events.on('login', this.onLogin, this);
|
deluge.events.on('login', this.onLogin, this);
|
||||||
deluge.events.on('logout', this.onLogout, this);
|
deluge.events.on('logout', this.onLogout, this);
|
||||||
|
|
||||||
this.addButton(_('Close'), this.onClose, this);
|
this.addButton(_('Close'), this.onClose, this);
|
||||||
this.addButton(_('Connect'), this.onConnect, this);
|
this.addButton(_('Connect'), this.onConnect, this);
|
||||||
|
|
||||||
this.list = new Ext.list.ListView({
|
this.list = new Ext.list.ListView({
|
||||||
store: new Ext.data.ArrayStore({
|
store: new Ext.data.ArrayStore({
|
||||||
fields: [
|
fields: [
|
||||||
{name: 'status', mapping: 3},
|
{name: 'status', mapping: 3},
|
||||||
{name: 'host', mapping: 1},
|
{name: 'host', mapping: 1},
|
||||||
{name: 'port', mapping: 2},
|
{name: 'port', mapping: 2},
|
||||||
{name: 'version', mapping: 4}
|
{name: 'version', mapping: 4}
|
||||||
],
|
],
|
||||||
id: 0
|
id: 0
|
||||||
}),
|
}),
|
||||||
columns: [{
|
columns: [{
|
||||||
header: _('Status'),
|
header: _('Status'),
|
||||||
width: .24,
|
width: .24,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
dataIndex: 'status'
|
dataIndex: 'status'
|
||||||
}, {
|
}, {
|
||||||
id:'host',
|
id:'host',
|
||||||
header: _('Host'),
|
header: _('Host'),
|
||||||
width: .51,
|
width: .51,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
tpl: '{host}:{port}',
|
tpl: '{host}:{port}',
|
||||||
dataIndex: 'host'
|
dataIndex: 'host'
|
||||||
}, {
|
}, {
|
||||||
header: _('Version'),
|
header: _('Version'),
|
||||||
width: .25,
|
width: .25,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
tpl: '<tpl if="version">{version}</tpl>',
|
tpl: '<tpl if="version">{version}</tpl>',
|
||||||
dataIndex: 'version'
|
dataIndex: 'version'
|
||||||
}],
|
}],
|
||||||
singleSelect: true,
|
singleSelect: true,
|
||||||
listeners: {
|
listeners: {
|
||||||
'selectionchange': {fn: this.onSelectionChanged, scope: this}
|
'selectionchange': {fn: this.onSelectionChanged, scope: this}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.panel = this.add({
|
this.panel = this.add({
|
||||||
autoScroll: true,
|
autoScroll: true,
|
||||||
items: [this.list],
|
items: [this.list],
|
||||||
bbar: new Ext.Toolbar({
|
bbar: new Ext.Toolbar({
|
||||||
buttons: [
|
buttons: [
|
||||||
{
|
{
|
||||||
id: 'cm-add',
|
id: 'cm-add',
|
||||||
cls: 'x-btn-text-icon',
|
cls: 'x-btn-text-icon',
|
||||||
text: _('Add'),
|
text: _('Add'),
|
||||||
iconCls: 'icon-add',
|
iconCls: 'icon-add',
|
||||||
handler: this.onAddClick,
|
handler: this.onAddClick,
|
||||||
scope: this
|
scope: this
|
||||||
}, {
|
}, {
|
||||||
id: 'cm-remove',
|
id: 'cm-remove',
|
||||||
cls: 'x-btn-text-icon',
|
cls: 'x-btn-text-icon',
|
||||||
text: _('Remove'),
|
text: _('Remove'),
|
||||||
iconCls: 'icon-remove',
|
iconCls: 'icon-remove',
|
||||||
handler: this.onRemoveClick,
|
handler: this.onRemoveClick,
|
||||||
disabled: true,
|
disabled: true,
|
||||||
scope: this
|
scope: this
|
||||||
}, '->', {
|
}, '->', {
|
||||||
id: 'cm-stop',
|
id: 'cm-stop',
|
||||||
cls: 'x-btn-text-icon',
|
cls: 'x-btn-text-icon',
|
||||||
text: _('Stop Daemon'),
|
text: _('Stop Daemon'),
|
||||||
iconCls: 'icon-error',
|
iconCls: 'icon-error',
|
||||||
handler: this.onStopClick,
|
handler: this.onStopClick,
|
||||||
disabled: true,
|
disabled: true,
|
||||||
scope: this
|
scope: this
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
this.update = this.update.createDelegate(this);
|
this.update = this.update.createDelegate(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check to see if the the web interface is currently connected
|
* Check to see if the the web interface is currently connected
|
||||||
* to a Deluge Daemon and show the Connection Manager if not.
|
* to a Deluge Daemon and show the Connection Manager if not.
|
||||||
*/
|
*/
|
||||||
checkConnected: function() {
|
checkConnected: function() {
|
||||||
deluge.client.web.connected({
|
deluge.client.web.connected({
|
||||||
success: function(connected) {
|
success: function(connected) {
|
||||||
if (connected) {
|
if (connected) {
|
||||||
deluge.events.fire('connect');
|
deluge.events.fire('connect');
|
||||||
} else {
|
} else {
|
||||||
this.show();
|
this.show();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
disconnect: function(show) {
|
disconnect: function(show) {
|
||||||
deluge.events.fire('disconnect');
|
deluge.events.fire('disconnect');
|
||||||
if (show) {
|
if (show) {
|
||||||
if (this.isVisible()) return;
|
if (this.isVisible()) return;
|
||||||
this.show();
|
this.show();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
loadHosts: function() {
|
loadHosts: function() {
|
||||||
deluge.client.web.get_hosts({
|
deluge.client.web.get_hosts({
|
||||||
success: this.onGetHosts,
|
success: this.onGetHosts,
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
update: function() {
|
update: function() {
|
||||||
this.list.getStore().each(function(r) {
|
this.list.getStore().each(function(r) {
|
||||||
deluge.client.web.get_host_status(r.id, {
|
deluge.client.web.get_host_status(r.id, {
|
||||||
success: this.onGetHostStatus,
|
success: this.onGetHostStatus,
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
}, this);
|
}, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the buttons in the Connection Manager UI according to the
|
* Updates the buttons in the Connection Manager UI according to the
|
||||||
* passed in records host state.
|
* passed in records host state.
|
||||||
* @param {Ext.data.Record} record The hosts record to update the UI for
|
* @param {Ext.data.Record} record The hosts record to update the UI for
|
||||||
*/
|
*/
|
||||||
updateButtons: function(record) {
|
updateButtons: function(record) {
|
||||||
var button = this.buttons[1], status = record.get('status');
|
var button = this.buttons[1], status = record.get('status');
|
||||||
|
|
||||||
// Update the Connect/Disconnect button
|
// Update the Connect/Disconnect button
|
||||||
if (status == _('Connected')) {
|
if (status == _('Connected')) {
|
||||||
button.enable();
|
button.enable();
|
||||||
button.setText(_('Disconnect'));
|
button.setText(_('Disconnect'));
|
||||||
} else if (status == _('Offline')) {
|
} else if (status == _('Offline')) {
|
||||||
button.disable();
|
button.disable();
|
||||||
} else {
|
} else {
|
||||||
button.enable();
|
button.enable();
|
||||||
button.setText(_('Connect'));
|
button.setText(_('Connect'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the Stop/Start Daemon button
|
// Update the Stop/Start Daemon button
|
||||||
if (status == _('Offline')) {
|
if (status == _('Offline')) {
|
||||||
if (record.get('host') == '127.0.0.1' || record.get('host') == 'localhost') {
|
if (record.get('host') == '127.0.0.1' || record.get('host') == 'localhost') {
|
||||||
this.stopHostButton.enable();
|
this.stopHostButton.enable();
|
||||||
this.stopHostButton.setText(_('Start Daemon'));
|
this.stopHostButton.setText(_('Start Daemon'));
|
||||||
} else {
|
} else {
|
||||||
this.stopHostButton.disable();
|
this.stopHostButton.disable();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.stopHostButton.enable();
|
this.stopHostButton.enable();
|
||||||
this.stopHostButton.setText(_('Stop Daemon'));
|
this.stopHostButton.setText(_('Stop Daemon'));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onAddClick: function(button, e) {
|
onAddClick: function(button, e) {
|
||||||
if (!this.addWindow) {
|
if (!this.addWindow) {
|
||||||
this.addWindow = new Deluge.AddConnectionWindow();
|
this.addWindow = new Deluge.AddConnectionWindow();
|
||||||
this.addWindow.on('hostadded', this.onHostAdded, this);
|
this.addWindow.on('hostadded', this.onHostAdded, this);
|
||||||
}
|
}
|
||||||
this.addWindow.show();
|
this.addWindow.show();
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onHostAdded: function() {
|
onHostAdded: function() {
|
||||||
this.loadHosts();
|
this.loadHosts();
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onClose: function(e) {
|
onClose: function(e) {
|
||||||
this.hide();
|
this.hide();
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onConnect: function(e) {
|
onConnect: function(e) {
|
||||||
var selected = this.list.getSelectedRecords()[0];
|
var selected = this.list.getSelectedRecords()[0];
|
||||||
if (!selected) return;
|
if (!selected) return;
|
||||||
|
|
||||||
if (selected.get('status') == _('Connected')) {
|
if (selected.get('status') == _('Connected')) {
|
||||||
deluge.client.web.disconnect({
|
deluge.client.web.disconnect({
|
||||||
success: function(result) {
|
success: function(result) {
|
||||||
this.update(this);
|
this.update(this);
|
||||||
deluge.events.fire('disconnect');
|
deluge.events.fire('disconnect');
|
||||||
},
|
},
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var id = selected.id;
|
var id = selected.id;
|
||||||
deluge.client.web.connect(id, {
|
deluge.client.web.connect(id, {
|
||||||
success: function(methods) {
|
success: function(methods) {
|
||||||
deluge.client.reloadMethods();
|
deluge.client.reloadMethods();
|
||||||
deluge.client.on('connected', function(e) {
|
deluge.client.on('connected', function(e) {
|
||||||
deluge.events.fire('connect');
|
deluge.events.fire('connect');
|
||||||
}, this, {single: true});
|
}, this, {single: true});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.hide();
|
this.hide();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onGetHosts: function(hosts) {
|
onGetHosts: function(hosts) {
|
||||||
this.list.getStore().loadData(hosts);
|
this.list.getStore().loadData(hosts);
|
||||||
Ext.each(hosts, function(host) {
|
Ext.each(hosts, function(host) {
|
||||||
deluge.client.web.get_host_status(host[0], {
|
deluge.client.web.get_host_status(host[0], {
|
||||||
success: this.onGetHostStatus,
|
success: this.onGetHostStatus,
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
}, this);
|
}, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onGetHostStatus: function(host) {
|
onGetHostStatus: function(host) {
|
||||||
var record = this.list.getStore().getById(host[0]);
|
var record = this.list.getStore().getById(host[0]);
|
||||||
record.set('status', host[3])
|
record.set('status', host[3])
|
||||||
record.set('version', host[4])
|
record.set('version', host[4])
|
||||||
record.commit();
|
record.commit();
|
||||||
if (this.list.getSelectedRecords()[0] == record) this.updateButtons(record);
|
if (this.list.getSelectedRecords()[0] == record) this.updateButtons(record);
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onHide: function() {
|
onHide: function() {
|
||||||
if (this.running) window.clearInterval(this.running);
|
if (this.running) window.clearInterval(this.running);
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onLogin: function() {
|
onLogin: function() {
|
||||||
if (deluge.config.first_login) {
|
if (deluge.config.first_login) {
|
||||||
Ext.MessageBox.confirm('Change password',
|
Ext.MessageBox.confirm('Change password',
|
||||||
'As this is your first login, we recommend that you ' +
|
'As this is your first login, we recommend that you ' +
|
||||||
'change your password. Would you like to ' +
|
'change your password. Would you like to ' +
|
||||||
'do this now?', function(res) {
|
'do this now?', function(res) {
|
||||||
this.checkConnected();
|
this.checkConnected();
|
||||||
if (res == 'yes') {
|
if (res == 'yes') {
|
||||||
deluge.preferences.show();
|
deluge.preferences.show();
|
||||||
deluge.preferences.selectPage('Interface');
|
deluge.preferences.selectPage('Interface');
|
||||||
}
|
}
|
||||||
deluge.client.web.set_config({first_login: false});
|
deluge.client.web.set_config({first_login: false});
|
||||||
}, this);
|
}, this);
|
||||||
} else {
|
} else {
|
||||||
this.checkConnected();
|
this.checkConnected();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onLogout: function() {
|
onLogout: function() {
|
||||||
this.disconnect();
|
this.disconnect();
|
||||||
if (!this.hidden && this.rendered) {
|
if (!this.hidden && this.rendered) {
|
||||||
this.hide();
|
this.hide();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onRemoveClick: function(button) {
|
onRemoveClick: function(button) {
|
||||||
var connection = this.list.getSelectedRecords()[0];
|
var connection = this.list.getSelectedRecords()[0];
|
||||||
if (!connection) return;
|
if (!connection) return;
|
||||||
|
|
||||||
deluge.client.web.remove_host(connection.id, {
|
deluge.client.web.remove_host(connection.id, {
|
||||||
success: function(result) {
|
success: function(result) {
|
||||||
if (!result) {
|
if (!result) {
|
||||||
Ext.MessageBox.show({
|
Ext.MessageBox.show({
|
||||||
title: _('Error'),
|
title: _('Error'),
|
||||||
msg: result[1],
|
msg: result[1],
|
||||||
buttons: Ext.MessageBox.OK,
|
buttons: Ext.MessageBox.OK,
|
||||||
modal: false,
|
modal: false,
|
||||||
icon: Ext.MessageBox.ERROR,
|
icon: Ext.MessageBox.ERROR,
|
||||||
iconCls: 'x-deluge-icon-error'
|
iconCls: 'x-deluge-icon-error'
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.list.getStore().remove(connection);
|
this.list.getStore().remove(connection);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onSelectionChanged: function(list, selections) {
|
onSelectionChanged: function(list, selections) {
|
||||||
if (selections[0]) {
|
if (selections[0]) {
|
||||||
this.removeHostButton.enable();
|
this.removeHostButton.enable();
|
||||||
this.stopHostButton.enable();
|
this.stopHostButton.enable();
|
||||||
this.stopHostButton.setText(_('Stop Daemon'));
|
this.stopHostButton.setText(_('Stop Daemon'));
|
||||||
this.updateButtons(this.list.getRecord(selections[0]));
|
this.updateButtons(this.list.getRecord(selections[0]));
|
||||||
} else {
|
} else {
|
||||||
this.removeHostButton.disable();
|
this.removeHostButton.disable();
|
||||||
this.stopHostButton.disable();
|
this.stopHostButton.disable();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// FIXME: Find out why this is being fired twice
|
// FIXME: Find out why this is being fired twice
|
||||||
// private
|
// private
|
||||||
onShow: function() {
|
onShow: function() {
|
||||||
if (!this.addHostButton) {
|
if (!this.addHostButton) {
|
||||||
var bbar = this.panel.getBottomToolbar();
|
var bbar = this.panel.getBottomToolbar();
|
||||||
this.addHostButton = bbar.items.get('cm-add');
|
this.addHostButton = bbar.items.get('cm-add');
|
||||||
this.removeHostButton = bbar.items.get('cm-remove');
|
this.removeHostButton = bbar.items.get('cm-remove');
|
||||||
this.stopHostButton = bbar.items.get('cm-stop');
|
this.stopHostButton = bbar.items.get('cm-stop');
|
||||||
}
|
}
|
||||||
this.loadHosts();
|
this.loadHosts();
|
||||||
if (this.running) return;
|
if (this.running) return;
|
||||||
this.running = window.setInterval(this.update, 2000, this);
|
this.running = window.setInterval(this.update, 2000, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onStopClick: function(button, e) {
|
onStopClick: function(button, e) {
|
||||||
var connection = this.list.getSelectedRecords()[0];
|
var connection = this.list.getSelectedRecords()[0];
|
||||||
if (!connection) return;
|
if (!connection) return;
|
||||||
|
|
||||||
if (connection.get('status') == 'Offline') {
|
if (connection.get('status') == 'Offline') {
|
||||||
// This means we need to start the daemon
|
// This means we need to start the daemon
|
||||||
deluge.client.web.start_daemon(connection.get('port'));
|
deluge.client.web.start_daemon(connection.get('port'));
|
||||||
} else {
|
} else {
|
||||||
// This means we need to stop the daemon
|
// This means we need to stop the daemon
|
||||||
deluge.client.web.stop_daemon(connection.id, {
|
deluge.client.web.stop_daemon(connection.id, {
|
||||||
success: function(result) {
|
success: function(result) {
|
||||||
if (!result[0]) {
|
if (!result[0]) {
|
||||||
Ext.MessageBox.show({
|
Ext.MessageBox.show({
|
||||||
title: _('Error'),
|
title: _('Error'),
|
||||||
msg: result[1],
|
msg: result[1],
|
||||||
buttons: Ext.MessageBox.OK,
|
buttons: Ext.MessageBox.OK,
|
||||||
modal: false,
|
modal: false,
|
||||||
icon: Ext.MessageBox.ERROR,
|
icon: Ext.MessageBox.ERROR,
|
||||||
iconCls: 'x-deluge-icon-error'
|
iconCls: 'x-deluge-icon-error'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -36,50 +36,50 @@ Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
|
|||||||
// Add some additional functions to ext and setup some of the
|
// Add some additional functions to ext and setup some of the
|
||||||
// configurable parameters
|
// configurable parameters
|
||||||
Ext.apply(Ext, {
|
Ext.apply(Ext, {
|
||||||
escapeHTML: function(text) {
|
escapeHTML: function(text) {
|
||||||
text = String(text).replace('<', '<').replace('>', '>');
|
text = String(text).replace('<', '<').replace('>', '>');
|
||||||
return text.replace('&', '&');
|
return text.replace('&', '&');
|
||||||
},
|
},
|
||||||
|
|
||||||
isObjectEmpty: function(obj) {
|
isObjectEmpty: function(obj) {
|
||||||
for(var i in obj) { return false; }
|
for(var i in obj) { return false; }
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
areObjectsEqual: function(obj1, obj2) {
|
areObjectsEqual: function(obj1, obj2) {
|
||||||
var equal = true;
|
var equal = true;
|
||||||
if (!obj1 || !obj2) return false;
|
if (!obj1 || !obj2) return false;
|
||||||
for (var i in obj1) {
|
for (var i in obj1) {
|
||||||
if (obj1[i] != obj2[i]) {
|
if (obj1[i] != obj2[i]) {
|
||||||
equal = false;
|
equal = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return equal;
|
return equal;
|
||||||
},
|
},
|
||||||
|
|
||||||
keys: function(obj) {
|
keys: function(obj) {
|
||||||
var keys = [];
|
var keys = [];
|
||||||
for (var i in obj) if (obj.hasOwnProperty(i))
|
for (var i in obj) if (obj.hasOwnProperty(i))
|
||||||
{
|
{
|
||||||
keys.push(i);
|
keys.push(i);
|
||||||
}
|
}
|
||||||
return keys;
|
return keys;
|
||||||
},
|
},
|
||||||
|
|
||||||
values: function(obj) {
|
values: function(obj) {
|
||||||
var values = [];
|
var values = [];
|
||||||
for (var i in obj) {
|
for (var i in obj) {
|
||||||
if (obj.hasOwnProperty(i)) {
|
if (obj.hasOwnProperty(i)) {
|
||||||
values.push(obj[i]);
|
values.push(obj[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return values;
|
return values;
|
||||||
},
|
},
|
||||||
|
|
||||||
splat: function(obj) {
|
splat: function(obj) {
|
||||||
var type = Ext.type(obj);
|
var type = Ext.type(obj);
|
||||||
return (type) ? ((type != 'array') ? [obj] : obj) : [];
|
return (type) ? ((type != 'array') ? [obj] : obj) : [];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Ext.getKeys = Ext.keys;
|
Ext.getKeys = Ext.keys;
|
||||||
Ext.BLANK_IMAGE_URL = deluge.config.base + 'images/s.gif';
|
Ext.BLANK_IMAGE_URL = deluge.config.base + 'images/s.gif';
|
||||||
@ -88,65 +88,65 @@ Ext.USE_NATIVE_JSON = true;
|
|||||||
// Create the Deluge namespace
|
// Create the Deluge namespace
|
||||||
Ext.apply(Deluge, {
|
Ext.apply(Deluge, {
|
||||||
|
|
||||||
// private
|
// private
|
||||||
pluginStore: {},
|
pluginStore: {},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
progressTpl: '<div class="x-progress-wrap x-progress-renderered">' +
|
progressTpl: '<div class="x-progress-wrap x-progress-renderered">' +
|
||||||
'<div class="x-progress-inner">' +
|
'<div class="x-progress-inner">' +
|
||||||
'<div style="width: {2}px" class="x-progress-bar">' +
|
'<div style="width: {2}px" class="x-progress-bar">' +
|
||||||
'<div style="z-index: 99; width: {3}px" class="x-progress-text">' +
|
'<div style="z-index: 99; width: {3}px" class="x-progress-text">' +
|
||||||
'<div style="width: {1}px;">{0}</div>' +
|
'<div style="width: {1}px;">{0}</div>' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'<div class="x-progress-text x-progress-text-back">' +
|
'<div class="x-progress-text x-progress-text-back">' +
|
||||||
'<div style="width: {1}px;">{0}</div>' +
|
'<div style="width: {1}px;">{0}</div>' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'</div>',
|
'</div>',
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A method to create a progress bar that can be used by renderers
|
* A method to create a progress bar that can be used by renderers
|
||||||
* to display a bar within a grid or tree.
|
* to display a bar within a grid or tree.
|
||||||
* @param {Number} progress The bars progress
|
* @param {Number} progress The bars progress
|
||||||
* @param {Number} width The width of the bar
|
* @param {Number} width The width of the bar
|
||||||
* @param {String} text The text to display on the bar
|
* @param {String} text The text to display on the bar
|
||||||
* @param {Number} modified Amount to subtract from the width allowing for fixes
|
* @param {Number} modified Amount to subtract from the width allowing for fixes
|
||||||
*/
|
*/
|
||||||
progressBar: function(progress, width, text, modifier) {
|
progressBar: function(progress, width, text, modifier) {
|
||||||
modifier = Ext.value(modifier, 10);
|
modifier = Ext.value(modifier, 10);
|
||||||
var progressWidth = ((width / 100.0) * progress).toFixed(0);
|
var progressWidth = ((width / 100.0) * progress).toFixed(0);
|
||||||
var barWidth = progressWidth - 1;
|
var barWidth = progressWidth - 1;
|
||||||
var textWidth = ((progressWidth - modifier) > 0 ? progressWidth - modifier : 0);
|
var textWidth = ((progressWidth - modifier) > 0 ? progressWidth - modifier : 0);
|
||||||
return String.format(Deluge.progressTpl, text, width, barWidth, textWidth);
|
return String.format(Deluge.progressTpl, text, width, barWidth, textWidth);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new instance of the specified plugin.
|
* Constructs a new instance of the specified plugin.
|
||||||
* @param {String} name The plugin name to create
|
* @param {String} name The plugin name to create
|
||||||
*/
|
*/
|
||||||
createPlugin: function(name) {
|
createPlugin: function(name) {
|
||||||
return new Deluge.pluginStore[name]();
|
return new Deluge.pluginStore[name]();
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check to see if a plugin has been registered.
|
* Check to see if a plugin has been registered.
|
||||||
* @param {String} name The plugin name to check
|
* @param {String} name The plugin name to check
|
||||||
*/
|
*/
|
||||||
hasPlugin: function(name) {
|
hasPlugin: function(name) {
|
||||||
return (Deluge.pluginStore[name]) ? true : false;
|
return (Deluge.pluginStore[name]) ? true : false;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a plugin with the Deluge interface.
|
* Register a plugin with the Deluge interface.
|
||||||
* @param {String} name The plugin name to register
|
* @param {String} name The plugin name to register
|
||||||
* @param {Plugin} plugin The plugin to register
|
* @param {Plugin} plugin The plugin to register
|
||||||
*/
|
*/
|
||||||
registerPlugin: function(name, plugin) {
|
registerPlugin: function(name, plugin) {
|
||||||
Deluge.pluginStore[name] = plugin;
|
Deluge.pluginStore[name] = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Setup a space for plugins to insert themselves
|
// Setup a space for plugins to insert themselves
|
||||||
@ -158,12 +158,12 @@ deluge.plugins = {};
|
|||||||
// _('High Priority')
|
// _('High Priority')
|
||||||
// _('Highest Priority')
|
// _('Highest Priority')
|
||||||
FILE_PRIORITY = {
|
FILE_PRIORITY = {
|
||||||
9: 'Mixed',
|
9: 'Mixed',
|
||||||
0: 'Do Not Download',
|
0: 'Do Not Download',
|
||||||
1: 'Normal Priority',
|
1: 'Normal Priority',
|
||||||
2: 'High Priority',
|
2: 'High Priority',
|
||||||
5: 'Highest Priority',
|
5: 'Highest Priority',
|
||||||
'Mixed': 9,
|
'Mixed': 9,
|
||||||
'Do Not Download': 0,
|
'Do Not Download': 0,
|
||||||
'Normal Priority': 1,
|
'Normal Priority': 1,
|
||||||
'High Priority': 2,
|
'High Priority': 2,
|
||||||
@ -171,9 +171,9 @@ FILE_PRIORITY = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FILE_PRIORITY_CSS = {
|
FILE_PRIORITY_CSS = {
|
||||||
9: 'x-mixed-download',
|
9: 'x-mixed-download',
|
||||||
0: 'x-no-download',
|
0: 'x-no-download',
|
||||||
1: 'x-normal-download',
|
1: 'x-normal-download',
|
||||||
2: 'x-high-download',
|
2: 'x-high-download',
|
||||||
5: 'x-highest-download'
|
5: 'x-highest-download'
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,58 +37,58 @@ Ext.ns('Deluge');
|
|||||||
*/
|
*/
|
||||||
Deluge.EditTrackerWindow = Ext.extend(Ext.Window, {
|
Deluge.EditTrackerWindow = Ext.extend(Ext.Window, {
|
||||||
|
|
||||||
title: _('Edit Tracker'),
|
title: _('Edit Tracker'),
|
||||||
layout: 'fit',
|
layout: 'fit',
|
||||||
width: 375,
|
width: 375,
|
||||||
height: 110,
|
height: 110,
|
||||||
plain: true,
|
plain: true,
|
||||||
closable: true,
|
closable: true,
|
||||||
resizable: false,
|
resizable: false,
|
||||||
|
|
||||||
bodyStyle: 'padding: 5px',
|
bodyStyle: 'padding: 5px',
|
||||||
buttonAlign: 'right',
|
buttonAlign: 'right',
|
||||||
closeAction: 'hide',
|
closeAction: 'hide',
|
||||||
iconCls: 'x-deluge-edit-trackers',
|
iconCls: 'x-deluge-edit-trackers',
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.EditTrackerWindow.superclass.initComponent.call(this);
|
Deluge.EditTrackerWindow.superclass.initComponent.call(this);
|
||||||
|
|
||||||
this.addButton(_('Cancel'), this.onCancelClick, this);
|
this.addButton(_('Cancel'), this.onCancelClick, this);
|
||||||
this.addButton(_('Save'), this.onSaveClick, this);
|
this.addButton(_('Save'), this.onSaveClick, this);
|
||||||
this.on('hide', this.onHide, this);
|
this.on('hide', this.onHide, this);
|
||||||
|
|
||||||
this.form = this.add({
|
this.form = this.add({
|
||||||
xtype: 'form',
|
xtype: 'form',
|
||||||
defaultType: 'textfield',
|
defaultType: 'textfield',
|
||||||
baseCls: 'x-plain',
|
baseCls: 'x-plain',
|
||||||
labelWidth: 55,
|
labelWidth: 55,
|
||||||
items: [{
|
items: [{
|
||||||
fieldLabel: _('Tracker'),
|
fieldLabel: _('Tracker'),
|
||||||
name: 'tracker',
|
name: 'tracker',
|
||||||
anchor: '100%'
|
anchor: '100%'
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
show: function(record) {
|
show: function(record) {
|
||||||
Deluge.EditTrackerWindow.superclass.show.call(this);
|
Deluge.EditTrackerWindow.superclass.show.call(this);
|
||||||
|
|
||||||
this.record = record;
|
this.record = record;
|
||||||
this.form.getForm().findField('tracker').setValue(record.data['url']);
|
this.form.getForm().findField('tracker').setValue(record.data['url']);
|
||||||
},
|
},
|
||||||
|
|
||||||
onCancelClick: function() {
|
onCancelClick: function() {
|
||||||
this.hide();
|
this.hide();
|
||||||
},
|
},
|
||||||
|
|
||||||
onHide: function() {
|
onHide: function() {
|
||||||
this.form.getForm().findField('tracker').setValue('');
|
this.form.getForm().findField('tracker').setValue('');
|
||||||
},
|
},
|
||||||
|
|
||||||
onSaveClick: function() {
|
onSaveClick: function() {
|
||||||
var url = this.form.getForm().findField('tracker').getValue();
|
var url = this.form.getForm().findField('tracker').getValue();
|
||||||
this.record.set('url', url);
|
this.record.set('url', url);
|
||||||
this.record.commit();
|
this.record.commit();
|
||||||
this.hide();
|
this.hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -37,203 +37,203 @@ Ext.ns('Deluge');
|
|||||||
*/
|
*/
|
||||||
Deluge.EditTrackersWindow = Ext.extend(Ext.Window, {
|
Deluge.EditTrackersWindow = Ext.extend(Ext.Window, {
|
||||||
|
|
||||||
title: _('Edit Trackers'),
|
title: _('Edit Trackers'),
|
||||||
layout: 'fit',
|
layout: 'fit',
|
||||||
width: 350,
|
width: 350,
|
||||||
height: 220,
|
height: 220,
|
||||||
plain: true,
|
plain: true,
|
||||||
closable: true,
|
closable: true,
|
||||||
resizable: true,
|
resizable: true,
|
||||||
|
|
||||||
bodyStyle: 'padding: 5px',
|
bodyStyle: 'padding: 5px',
|
||||||
buttonAlign: 'right',
|
buttonAlign: 'right',
|
||||||
closeAction: 'hide',
|
closeAction: 'hide',
|
||||||
iconCls: 'x-deluge-edit-trackers',
|
iconCls: 'x-deluge-edit-trackers',
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.EditTrackersWindow.superclass.initComponent.call(this);
|
Deluge.EditTrackersWindow.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.addEvents('save');
|
this.addEvents('save');
|
||||||
|
|
||||||
this.on('show', this.onShow, this);
|
this.on('show', this.onShow, this);
|
||||||
this.on('save', this.onSave, this);
|
this.on('save', this.onSave, this);
|
||||||
|
|
||||||
this.addWindow = new Deluge.AddTrackerWindow();
|
this.addWindow = new Deluge.AddTrackerWindow();
|
||||||
this.addWindow.on('add', this.onAddTrackers, this);
|
this.addWindow.on('add', this.onAddTrackers, this);
|
||||||
this.editWindow = new Deluge.EditTrackerWindow();
|
this.editWindow = new Deluge.EditTrackerWindow();
|
||||||
|
|
||||||
this.list = new Ext.list.ListView({
|
this.list = new Ext.list.ListView({
|
||||||
store: new Ext.data.JsonStore({
|
store: new Ext.data.JsonStore({
|
||||||
root: 'trackers',
|
root: 'trackers',
|
||||||
fields: [
|
fields: [
|
||||||
'tier',
|
'tier',
|
||||||
'url'
|
'url'
|
||||||
]
|
]
|
||||||
}),
|
}),
|
||||||
columns: [{
|
columns: [{
|
||||||
header: _('Tier'),
|
header: _('Tier'),
|
||||||
width: .1,
|
width: .1,
|
||||||
dataIndex: 'tier'
|
dataIndex: 'tier'
|
||||||
}, {
|
}, {
|
||||||
header: _('Tracker'),
|
header: _('Tracker'),
|
||||||
width: .9,
|
width: .9,
|
||||||
dataIndex: 'url'
|
dataIndex: 'url'
|
||||||
}],
|
}],
|
||||||
columnSort: {
|
columnSort: {
|
||||||
sortClasses: ['', '']
|
sortClasses: ['', '']
|
||||||
},
|
},
|
||||||
stripeRows: true,
|
stripeRows: true,
|
||||||
singleSelect: true,
|
singleSelect: true,
|
||||||
listeners: {
|
listeners: {
|
||||||
'dblclick': {fn: this.onListNodeDblClicked, scope: this},
|
'dblclick': {fn: this.onListNodeDblClicked, scope: this},
|
||||||
'selectionchange': {fn: this.onSelect, scope: this}
|
'selectionchange': {fn: this.onSelect, scope: this}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.panel = this.add({
|
this.panel = this.add({
|
||||||
margins: '0 0 0 0',
|
margins: '0 0 0 0',
|
||||||
items: [this.list],
|
items: [this.list],
|
||||||
autoScroll: true,
|
autoScroll: true,
|
||||||
bbar: new Ext.Toolbar({
|
bbar: new Ext.Toolbar({
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
text: _('Up'),
|
text: _('Up'),
|
||||||
iconCls: 'icon-up',
|
iconCls: 'icon-up',
|
||||||
handler: this.onUpClick,
|
handler: this.onUpClick,
|
||||||
scope: this
|
scope: this
|
||||||
}, {
|
}, {
|
||||||
text: _('Down'),
|
text: _('Down'),
|
||||||
iconCls: 'icon-down',
|
iconCls: 'icon-down',
|
||||||
handler: this.onDownClick,
|
handler: this.onDownClick,
|
||||||
scope: this
|
scope: this
|
||||||
}, '->', {
|
}, '->', {
|
||||||
text: _('Add'),
|
text: _('Add'),
|
||||||
iconCls: 'icon-add',
|
iconCls: 'icon-add',
|
||||||
handler: this.onAddClick,
|
handler: this.onAddClick,
|
||||||
scope: this
|
scope: this
|
||||||
}, {
|
}, {
|
||||||
text: _('Edit'),
|
text: _('Edit'),
|
||||||
iconCls: 'icon-edit-trackers',
|
iconCls: 'icon-edit-trackers',
|
||||||
handler: this.onEditClick,
|
handler: this.onEditClick,
|
||||||
scope: this
|
scope: this
|
||||||
}, {
|
}, {
|
||||||
text: _('Remove'),
|
text: _('Remove'),
|
||||||
iconCls: 'icon-remove',
|
iconCls: 'icon-remove',
|
||||||
handler: this.onRemoveClick,
|
handler: this.onRemoveClick,
|
||||||
scope: this
|
scope: this
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onAddClick: function() {
|
onAddClick: function() {
|
||||||
this.addWindow.show();
|
this.addWindow.show();
|
||||||
},
|
},
|
||||||
|
|
||||||
onAddTrackers: function(trackers) {
|
onAddTrackers: function(trackers) {
|
||||||
var store = this.list.getStore();
|
var store = this.list.getStore();
|
||||||
Ext.each(trackers, function(tracker) {
|
Ext.each(trackers, function(tracker) {
|
||||||
var duplicate = false, heightestTier = -1;
|
var duplicate = false, heightestTier = -1;
|
||||||
store.each(function(record) {
|
store.each(function(record) {
|
||||||
if (record.get('tier') > heightestTier) {
|
if (record.get('tier') > heightestTier) {
|
||||||
heightestTier = record.get('tier');
|
heightestTier = record.get('tier');
|
||||||
}
|
}
|
||||||
if (tracker == record.get('tracker')) {
|
if (tracker == record.get('tracker')) {
|
||||||
duplicate = true;
|
duplicate = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
if (duplicate) return;
|
if (duplicate) return;
|
||||||
store.add(new store.recordType({'tier': heightestTier + 1, 'url': tracker}));
|
store.add(new store.recordType({'tier': heightestTier + 1, 'url': tracker}));
|
||||||
}, this);
|
}, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
onCancelClick: function() {
|
onCancelClick: function() {
|
||||||
this.hide();
|
this.hide();
|
||||||
},
|
},
|
||||||
|
|
||||||
onEditClick: function() {
|
onEditClick: function() {
|
||||||
this.editWindow.show(this.list.getSelectedRecords()[0]);
|
this.editWindow.show(this.list.getSelectedRecords()[0]);
|
||||||
},
|
},
|
||||||
|
|
||||||
onHide: function() {
|
onHide: function() {
|
||||||
this.list.getStore().removeAll();
|
this.list.getStore().removeAll();
|
||||||
},
|
},
|
||||||
|
|
||||||
onListNodeDblClicked: function(list, index, node, e) {
|
onListNodeDblClicked: function(list, index, node, e) {
|
||||||
this.editWindow.show(this.list.getRecord(node));
|
this.editWindow.show(this.list.getRecord(node));
|
||||||
},
|
},
|
||||||
|
|
||||||
onOkClick: function() {
|
onOkClick: function() {
|
||||||
var trackers = [];
|
var trackers = [];
|
||||||
this.list.getStore().each(function(record) {
|
this.list.getStore().each(function(record) {
|
||||||
trackers.push({
|
trackers.push({
|
||||||
'tier': record.get('tier'),
|
'tier': record.get('tier'),
|
||||||
'url': record.get('url')
|
'url': record.get('url')
|
||||||
})
|
})
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
deluge.client.core.set_torrent_trackers(this.torrentId, trackers, {
|
deluge.client.core.set_torrent_trackers(this.torrentId, trackers, {
|
||||||
failure: this.onSaveFail,
|
failure: this.onSaveFail,
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
|
|
||||||
this.hide();
|
this.hide();
|
||||||
},
|
},
|
||||||
|
|
||||||
onRemoveClick: function() {
|
onRemoveClick: function() {
|
||||||
// Remove from the grid
|
// Remove from the grid
|
||||||
this.list.getStore().remove(this.list.getSelectedRecords()[0]);
|
this.list.getStore().remove(this.list.getSelectedRecords()[0]);
|
||||||
},
|
},
|
||||||
|
|
||||||
onRequestComplete: function(status) {
|
onRequestComplete: function(status) {
|
||||||
this.list.getStore().loadData(status);
|
this.list.getStore().loadData(status);
|
||||||
this.list.getStore().sort('tier', 'ASC');
|
this.list.getStore().sort('tier', 'ASC');
|
||||||
},
|
},
|
||||||
|
|
||||||
onSaveFail: function() {
|
onSaveFail: function() {
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onSelect: function(list) {
|
onSelect: function(list) {
|
||||||
if (list.getSelectionCount()) {
|
if (list.getSelectionCount()) {
|
||||||
this.panel.getBottomToolbar().items.get(4).enable();
|
this.panel.getBottomToolbar().items.get(4).enable();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onShow: function() {
|
onShow: function() {
|
||||||
this.panel.getBottomToolbar().items.get(4).disable();
|
this.panel.getBottomToolbar().items.get(4).disable();
|
||||||
var r = deluge.torrents.getSelected();
|
var r = deluge.torrents.getSelected();
|
||||||
this.torrentId = r.id;
|
this.torrentId = r.id;
|
||||||
deluge.client.core.get_torrent_status(r.id, ['trackers'], {
|
deluge.client.core.get_torrent_status(r.id, ['trackers'], {
|
||||||
success: this.onRequestComplete,
|
success: this.onRequestComplete,
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onDownClick: function() {
|
onDownClick: function() {
|
||||||
var r = this.list.getSelectedRecords()[0];
|
var r = this.list.getSelectedRecords()[0];
|
||||||
if (!r) return;
|
if (!r) return;
|
||||||
|
|
||||||
r.set('tier', r.get('tier') + 1);
|
r.set('tier', r.get('tier') + 1);
|
||||||
r.store.sort('tier', 'ASC');
|
r.store.sort('tier', 'ASC');
|
||||||
r.store.commitChanges();
|
r.store.commitChanges();
|
||||||
|
|
||||||
this.list.select(r.store.indexOf(r));
|
this.list.select(r.store.indexOf(r));
|
||||||
},
|
},
|
||||||
|
|
||||||
onUpClick: function() {
|
onUpClick: function() {
|
||||||
var r = this.list.getSelectedRecords()[0];
|
var r = this.list.getSelectedRecords()[0];
|
||||||
if (!r) return;
|
if (!r) return;
|
||||||
|
|
||||||
if (r.get('tier') == 0) return;
|
if (r.get('tier') == 0) return;
|
||||||
r.set('tier', r.get('tier') - 1);
|
r.set('tier', r.get('tier') - 1);
|
||||||
r.store.sort('tier', 'ASC');
|
r.store.sort('tier', 'ASC');
|
||||||
r.store.commitChanges();
|
r.store.commitChanges();
|
||||||
|
|
||||||
this.list.select(r.store.indexOf(r));
|
this.list.select(r.store.indexOf(r));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -37,79 +37,79 @@
|
|||||||
* Class for holding global events that occur within the UI.
|
* Class for holding global events that occur within the UI.
|
||||||
*/
|
*/
|
||||||
Deluge.EventsManager = Ext.extend(Ext.util.Observable, {
|
Deluge.EventsManager = Ext.extend(Ext.util.Observable, {
|
||||||
constructor: function() {
|
constructor: function() {
|
||||||
this.toRegister = [];
|
this.toRegister = [];
|
||||||
this.on('login', this.onLogin, this);
|
this.on('login', this.onLogin, this);
|
||||||
Deluge.EventsManager.superclass.constructor.call(this);
|
Deluge.EventsManager.superclass.constructor.call(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Append an event handler to this object.
|
* Append an event handler to this object.
|
||||||
*/
|
*/
|
||||||
addListener: function(eventName, fn, scope, o) {
|
addListener: function(eventName, fn, scope, o) {
|
||||||
this.addEvents(eventName);
|
this.addEvents(eventName);
|
||||||
if (/[A-Z]/.test(eventName.substring(0, 1))) {
|
if (/[A-Z]/.test(eventName.substring(0, 1))) {
|
||||||
if (!deluge.client) {
|
if (!deluge.client) {
|
||||||
this.toRegister.push(eventName);
|
this.toRegister.push(eventName);
|
||||||
} else {
|
} else {
|
||||||
deluge.client.web.register_event_listener(eventName);
|
deluge.client.web.register_event_listener(eventName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Deluge.EventsManager.superclass.addListener.call(this, eventName, fn, scope, o);
|
Deluge.EventsManager.superclass.addListener.call(this, eventName, fn, scope, o);
|
||||||
},
|
},
|
||||||
|
|
||||||
getEvents: function() {
|
getEvents: function() {
|
||||||
deluge.client.web.get_events({
|
deluge.client.web.get_events({
|
||||||
success: this.onGetEventsSuccess,
|
success: this.onGetEventsSuccess,
|
||||||
failure: this.onGetEventsFailure,
|
failure: this.onGetEventsFailure,
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts the EventsManagerManager checking for events.
|
* Starts the EventsManagerManager checking for events.
|
||||||
*/
|
*/
|
||||||
start: function() {
|
start: function() {
|
||||||
Ext.each(this.toRegister, function(eventName) {
|
Ext.each(this.toRegister, function(eventName) {
|
||||||
deluge.client.web.register_event_listener(eventName);
|
deluge.client.web.register_event_listener(eventName);
|
||||||
});
|
});
|
||||||
this.running = true;
|
this.running = true;
|
||||||
this.errorCount = 0;
|
this.errorCount = 0;
|
||||||
this.getEvents();
|
this.getEvents();
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stops the EventsManagerManager checking for events.
|
* Stops the EventsManagerManager checking for events.
|
||||||
*/
|
*/
|
||||||
stop: function() {
|
stop: function() {
|
||||||
this.running = false;
|
this.running = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onLogin: function() {
|
onLogin: function() {
|
||||||
this.start();
|
this.start();
|
||||||
},
|
},
|
||||||
|
|
||||||
onGetEventsSuccess: function(events) {
|
onGetEventsSuccess: function(events) {
|
||||||
if (!events) return;
|
if (!events) return;
|
||||||
Ext.each(events, function(event) {
|
Ext.each(events, function(event) {
|
||||||
var name = event[0], args = event[1];
|
var name = event[0], args = event[1];
|
||||||
args.splice(0, 0, name);
|
args.splice(0, 0, name);
|
||||||
this.fireEvent.apply(this, args);
|
this.fireEvent.apply(this, args);
|
||||||
}, this);
|
}, this);
|
||||||
if (this.running) this.getEvents();
|
if (this.running) this.getEvents();
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onGetEventsFailure: function(result, error) {
|
onGetEventsFailure: function(result, error) {
|
||||||
// the request timed out or we had a communication failure
|
// the request timed out or we had a communication failure
|
||||||
if (!this.running) return;
|
if (!this.running) return;
|
||||||
if (!error.isTimeout && this.errorCount++ >= 3) {
|
if (!error.isTimeout && this.errorCount++ >= 3) {
|
||||||
this.stop();
|
this.stop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.getEvents();
|
this.getEvents();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -33,30 +33,30 @@
|
|||||||
Ext.namespace('Deluge');
|
Ext.namespace('Deluge');
|
||||||
Deluge.FileBrowser = Ext.extend(Ext.Window, {
|
Deluge.FileBrowser = Ext.extend(Ext.Window, {
|
||||||
|
|
||||||
title: _('File Browser'),
|
title: _('File Browser'),
|
||||||
|
|
||||||
width: 500,
|
width: 500,
|
||||||
height: 400,
|
height: 400,
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.FileBrowser.superclass.initComponent.call(this);
|
Deluge.FileBrowser.superclass.initComponent.call(this);
|
||||||
|
|
||||||
this.add({
|
this.add({
|
||||||
xtype: 'toolbar',
|
xtype: 'toolbar',
|
||||||
items: [{
|
items: [{
|
||||||
text: _('Back'),
|
text: _('Back'),
|
||||||
iconCls: 'icon-back'
|
iconCls: 'icon-back'
|
||||||
}, {
|
}, {
|
||||||
text: _('Forward'),
|
text: _('Forward'),
|
||||||
iconCls: 'icon-forward'
|
iconCls: 'icon-forward'
|
||||||
}, {
|
}, {
|
||||||
text: _('Up'),
|
text: _('Up'),
|
||||||
iconCls: 'icon-up'
|
iconCls: 'icon-up'
|
||||||
}, {
|
}, {
|
||||||
text: _('Home'),
|
text: _('Home'),
|
||||||
iconCls: 'icon-home'
|
iconCls: 'icon-home'
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@ -39,132 +39,132 @@ Deluge.FilterPanel = Ext.extend(Ext.Panel, {
|
|||||||
|
|
||||||
autoScroll: true,
|
autoScroll: true,
|
||||||
|
|
||||||
border: false,
|
border: false,
|
||||||
|
|
||||||
show_zero: null,
|
show_zero: null,
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.FilterPanel.superclass.initComponent.call(this);
|
Deluge.FilterPanel.superclass.initComponent.call(this);
|
||||||
this.filterType = this.initialConfig.filter;
|
this.filterType = this.initialConfig.filter;
|
||||||
|
|
||||||
var title = this.filterType.replace('_', ' '),
|
var title = this.filterType.replace('_', ' '),
|
||||||
parts = title.split(' '),
|
parts = title.split(' '),
|
||||||
title = '';
|
title = '';
|
||||||
Ext.each(parts, function(p) {
|
Ext.each(parts, function(p) {
|
||||||
fl = p.substring(0, 1).toUpperCase();
|
fl = p.substring(0, 1).toUpperCase();
|
||||||
title += fl + p.substring(1) + ' ';
|
title += fl + p.substring(1) + ' ';
|
||||||
});
|
});
|
||||||
this.setTitle(_(title));
|
this.setTitle(_(title));
|
||||||
|
|
||||||
if (Deluge.FilterPanel.templates[this.filterType]) {
|
if (Deluge.FilterPanel.templates[this.filterType]) {
|
||||||
var tpl = Deluge.FilterPanel.templates[this.filterType];
|
var tpl = Deluge.FilterPanel.templates[this.filterType];
|
||||||
} else {
|
} else {
|
||||||
var tpl = '<div class="x-deluge-filter x-deluge-{filter:lowercase}">{filter} ({count})</div>';
|
var tpl = '<div class="x-deluge-filter x-deluge-{filter:lowercase}">{filter} ({count})</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
this.list = this.add({
|
this.list = this.add({
|
||||||
xtype: 'listview',
|
xtype: 'listview',
|
||||||
singleSelect: true,
|
singleSelect: true,
|
||||||
hideHeaders: true,
|
hideHeaders: true,
|
||||||
reserveScrollOffset: true,
|
reserveScrollOffset: true,
|
||||||
store: new Ext.data.ArrayStore({
|
store: new Ext.data.ArrayStore({
|
||||||
idIndex: 0,
|
idIndex: 0,
|
||||||
fields: ['filter', 'count']
|
fields: ['filter', 'count']
|
||||||
}),
|
}),
|
||||||
columns: [{
|
columns: [{
|
||||||
id: 'filter',
|
id: 'filter',
|
||||||
sortable: false,
|
sortable: false,
|
||||||
tpl: tpl,
|
tpl: tpl,
|
||||||
dataIndex: 'filter'
|
dataIndex: 'filter'
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
this.relayEvents(this.list, ['selectionchange']);
|
this.relayEvents(this.list, ['selectionchange']);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the currently selected filter state
|
* Return the currently selected filter state
|
||||||
* @returns {String} the current filter state
|
* @returns {String} the current filter state
|
||||||
*/
|
*/
|
||||||
getState: function() {
|
getState: function() {
|
||||||
if (!this.list.getSelectionCount()) return;
|
if (!this.list.getSelectionCount()) return;
|
||||||
|
|
||||||
var state = this.list.getSelectedRecords()[0];
|
var state = this.list.getSelectedRecords()[0];
|
||||||
if (state.id == 'All') return;
|
if (state.id == 'All') return;
|
||||||
return state.id;
|
return state.id;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the current states in the filter
|
* Return the current states in the filter
|
||||||
*/
|
*/
|
||||||
getStates: function() {
|
getStates: function() {
|
||||||
return this.states;
|
return this.states;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the Store for the ListView of the FilterPanel
|
* Return the Store for the ListView of the FilterPanel
|
||||||
* @returns {Ext.data.Store} the ListView store
|
* @returns {Ext.data.Store} the ListView store
|
||||||
*/
|
*/
|
||||||
getStore: function() {
|
getStore: function() {
|
||||||
return this.list.getStore();
|
return this.list.getStore();
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the states in the FilterPanel
|
* Update the states in the FilterPanel
|
||||||
*/
|
*/
|
||||||
updateStates: function(states) {
|
updateStates: function(states) {
|
||||||
this.states = {};
|
this.states = {};
|
||||||
Ext.each(states, function(state) {
|
Ext.each(states, function(state) {
|
||||||
this.states[state[0]] = state[1];
|
this.states[state[0]] = state[1];
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
var show_zero = (this.show_zero == null) ? deluge.config.sidebar_show_zero : this.show_zero;
|
var show_zero = (this.show_zero == null) ? deluge.config.sidebar_show_zero : this.show_zero;
|
||||||
if (!show_zero) {
|
if (!show_zero) {
|
||||||
var newStates = [];
|
var newStates = [];
|
||||||
Ext.each(states, function(state) {
|
Ext.each(states, function(state) {
|
||||||
if (state[1] > 0 || state[0] == _('All')) {
|
if (state[1] > 0 || state[0] == _('All')) {
|
||||||
newStates.push(state);
|
newStates.push(state);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
states = newStates;
|
states = newStates;
|
||||||
}
|
}
|
||||||
|
|
||||||
var store = this.getStore();
|
var store = this.getStore();
|
||||||
var filters = {};
|
var filters = {};
|
||||||
Ext.each(states, function(s, i) {
|
Ext.each(states, function(s, i) {
|
||||||
var record = store.getById(s[0]);
|
var record = store.getById(s[0]);
|
||||||
if (!record) {
|
if (!record) {
|
||||||
record = new store.recordType({
|
record = new store.recordType({
|
||||||
filter: s[0],
|
filter: s[0],
|
||||||
count: s[1]
|
count: s[1]
|
||||||
});
|
});
|
||||||
record.id = s[0];
|
record.id = s[0];
|
||||||
store.insert(i, record);
|
store.insert(i, record);
|
||||||
}
|
}
|
||||||
record.beginEdit();
|
record.beginEdit();
|
||||||
record.set('filter', s[0]);
|
record.set('filter', s[0]);
|
||||||
record.set('count', s[1]);
|
record.set('count', s[1]);
|
||||||
record.endEdit();
|
record.endEdit();
|
||||||
filters[s[0]] = true;
|
filters[s[0]] = true;
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
store.each(function(record) {
|
store.each(function(record) {
|
||||||
if (filters[record.id]) return;
|
if (filters[record.id]) return;
|
||||||
var r = this.list.getSelectedRecords()[0];
|
var r = this.list.getSelectedRecords()[0];
|
||||||
store.remove(record);
|
store.remove(record);
|
||||||
if (r.id == record.id) {
|
if (r.id == record.id) {
|
||||||
this.list.select(0);
|
this.list.select(0);
|
||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
store.commitChanges();
|
store.commitChanges();
|
||||||
|
|
||||||
if (!this.list.getSelectionCount()) {
|
if (!this.list.getSelectionCount()) {
|
||||||
this.list.select(0);
|
this.list.select(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Deluge.FilterPanel.templates = {
|
Deluge.FilterPanel.templates = {
|
||||||
'tracker_host': '<div class="x-deluge-filter" style="background-image: url(' + deluge.config.base + 'tracker/{filter});">{filter} ({count})</div>'
|
'tracker_host': '<div class="x-deluge-filter" style="background-image: url(' + deluge.config.base + 'tracker/{filter});">{filter} ({count})</div>'
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,115 +38,115 @@
|
|||||||
* @singleton
|
* @singleton
|
||||||
*/
|
*/
|
||||||
Deluge.Formatters = {
|
Deluge.Formatters = {
|
||||||
/**
|
/**
|
||||||
* Formats a date string in the locale's date representation based on the
|
* Formats a date string in the locale's date representation based on the
|
||||||
* systems timezone.
|
* systems timezone.
|
||||||
*
|
*
|
||||||
* @param {Number} timestamp time in seconds since the Epoch
|
* @param {Number} timestamp time in seconds since the Epoch
|
||||||
* @return {String} a string in the locale's date representation or ""
|
* @return {String} a string in the locale's date representation or ""
|
||||||
* if seconds < 0
|
* if seconds < 0
|
||||||
*/
|
*/
|
||||||
date: function(timestamp) {
|
date: function(timestamp) {
|
||||||
function zeroPad(num, count) {
|
function zeroPad(num, count) {
|
||||||
var numZeropad = num + '';
|
var numZeropad = num + '';
|
||||||
while (numZeropad.length < count) {
|
while (numZeropad.length < count) {
|
||||||
numZeropad = '0' + numZeropad;
|
numZeropad = '0' + numZeropad;
|
||||||
}
|
}
|
||||||
return numZeropad;
|
return numZeropad;
|
||||||
}
|
}
|
||||||
timestamp = timestamp * 1000;
|
timestamp = timestamp * 1000;
|
||||||
var date = new Date(timestamp);
|
var date = new Date(timestamp);
|
||||||
return String.format('{0}/{1}/{2} {3}:{4}:{5}',
|
return String.format('{0}/{1}/{2} {3}:{4}:{5}',
|
||||||
zeroPad(date.getDate(), 2), zeroPad(date.getMonth() + 1, 2), date.getFullYear(),
|
zeroPad(date.getDate(), 2), zeroPad(date.getMonth() + 1, 2), date.getFullYear(),
|
||||||
zeroPad(date.getHours(), 2), zeroPad(date.getMinutes(), 2), zeroPad(date.getSeconds(), 2));
|
zeroPad(date.getHours(), 2), zeroPad(date.getMinutes(), 2), zeroPad(date.getSeconds(), 2));
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formats the bytes value into a string with KiB, MiB or GiB units.
|
* Formats the bytes value into a string with KiB, MiB or GiB units.
|
||||||
*
|
*
|
||||||
* @param {Number} bytes the filesize in bytes
|
* @param {Number} bytes the filesize in bytes
|
||||||
* @param {Boolean} showZero pass in true to displays 0 values
|
* @param {Boolean} showZero pass in true to displays 0 values
|
||||||
* @return {String} formatted string with KiB, MiB or GiB units.
|
* @return {String} formatted string with KiB, MiB or GiB units.
|
||||||
*/
|
*/
|
||||||
size: function(bytes, showZero) {
|
size: function(bytes, showZero) {
|
||||||
if (!bytes && !showZero) return '';
|
if (!bytes && !showZero) return '';
|
||||||
bytes = bytes / 1024.0;
|
bytes = bytes / 1024.0;
|
||||||
|
|
||||||
if (bytes < 1024) { return bytes.toFixed(1) + ' KiB'; }
|
if (bytes < 1024) { return bytes.toFixed(1) + ' KiB'; }
|
||||||
else { bytes = bytes / 1024; }
|
else { bytes = bytes / 1024; }
|
||||||
|
|
||||||
if (bytes < 1024) { return bytes.toFixed(1) + ' MiB'; }
|
if (bytes < 1024) { return bytes.toFixed(1) + ' MiB'; }
|
||||||
else { bytes = bytes / 1024; }
|
else { bytes = bytes / 1024; }
|
||||||
|
|
||||||
return bytes.toFixed(1) + ' GiB'
|
return bytes.toFixed(1) + ' GiB'
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formats a string to display a transfer speed utilizing {@link #size}
|
* Formats a string to display a transfer speed utilizing {@link #size}
|
||||||
*
|
*
|
||||||
* @param {Number} bytes the number of bytes per second
|
* @param {Number} bytes the number of bytes per second
|
||||||
* @param {Boolean} showZero pass in true to displays 0 values
|
* @param {Boolean} showZero pass in true to displays 0 values
|
||||||
* @return {String} formatted string with KiB, MiB or GiB units.
|
* @return {String} formatted string with KiB, MiB or GiB units.
|
||||||
*/
|
*/
|
||||||
speed: function(bytes, showZero) {
|
speed: function(bytes, showZero) {
|
||||||
return (!bytes && !showZero) ? '' : fsize(bytes, showZero) + '/s';
|
return (!bytes && !showZero) ? '' : fsize(bytes, showZero) + '/s';
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formats a string to show time in a human readable form.
|
* Formats a string to show time in a human readable form.
|
||||||
*
|
*
|
||||||
* @param {Number} time the number of seconds
|
* @param {Number} time the number of seconds
|
||||||
* @return {String} a formatted time string. will return '' if seconds == 0
|
* @return {String} a formatted time string. will return '' if seconds == 0
|
||||||
*/
|
*/
|
||||||
timeRemaining: function(time) {
|
timeRemaining: function(time) {
|
||||||
if (time == 0) { return '∞' }
|
if (time == 0) { return '∞' }
|
||||||
time = time.toFixed(0);
|
time = time.toFixed(0);
|
||||||
if (time < 60) { return time + 's'; }
|
if (time < 60) { return time + 's'; }
|
||||||
else { time = time / 60; }
|
else { time = time / 60; }
|
||||||
|
|
||||||
if (time < 60) {
|
if (time < 60) {
|
||||||
var minutes = Math.floor(time)
|
var minutes = Math.floor(time)
|
||||||
var seconds = Math.round(60 * (time - minutes))
|
var seconds = Math.round(60 * (time - minutes))
|
||||||
if (seconds > 0) {
|
if (seconds > 0) {
|
||||||
return minutes + 'm ' + seconds + 's';
|
return minutes + 'm ' + seconds + 's';
|
||||||
} else {
|
} else {
|
||||||
return minutes + 'm'; }
|
return minutes + 'm'; }
|
||||||
}
|
}
|
||||||
else { time = time / 60; }
|
else { time = time / 60; }
|
||||||
|
|
||||||
if (time < 24) {
|
if (time < 24) {
|
||||||
var hours = Math.floor(time)
|
var hours = Math.floor(time)
|
||||||
var minutes = Math.round(60 * (time - hours))
|
var minutes = Math.round(60 * (time - hours))
|
||||||
if (minutes > 0) {
|
if (minutes > 0) {
|
||||||
return hours + 'h ' + minutes + 'm';
|
return hours + 'h ' + minutes + 'm';
|
||||||
} else {
|
} else {
|
||||||
return hours + 'h';
|
return hours + 'h';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { time = time / 24; }
|
else { time = time / 24; }
|
||||||
|
|
||||||
var days = Math.floor(time)
|
var days = Math.floor(time)
|
||||||
var hours = Math.round(24 * (time - days))
|
var hours = Math.round(24 * (time - days))
|
||||||
if (hours > 0) {
|
if (hours > 0) {
|
||||||
return days + 'd ' + hours + 'h';
|
return days + 'd ' + hours + 'h';
|
||||||
} else {
|
} else {
|
||||||
return days + 'd';
|
return days + 'd';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simply returns the value untouched, for when no formatting is required.
|
* Simply returns the value untouched, for when no formatting is required.
|
||||||
*
|
*
|
||||||
* @param {Mixed} value the value to be displayed
|
* @param {Mixed} value the value to be displayed
|
||||||
* @return the untouched value.
|
* @return the untouched value.
|
||||||
*/
|
*/
|
||||||
plain: function(value) {
|
plain: function(value) {
|
||||||
return value;
|
return value;
|
||||||
},
|
},
|
||||||
|
|
||||||
cssClassEscape: function(value) {
|
cssClassEscape: function(value) {
|
||||||
return value.toLowerCase().replace('.', '_');
|
return value.toLowerCase().replace('.', '_');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var fsize = Deluge.Formatters.size;
|
var fsize = Deluge.Formatters.size;
|
||||||
var fspeed = Deluge.Formatters.speed;
|
var fspeed = Deluge.Formatters.speed;
|
||||||
|
|||||||
@ -37,13 +37,13 @@
|
|||||||
*/
|
*/
|
||||||
Deluge.Keys = {
|
Deluge.Keys = {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keys that are used within the torrent grid.
|
* Keys that are used within the torrent grid.
|
||||||
* <pre>['queue', 'name', 'total_size', 'state', 'progress', 'num_seeds',
|
* <pre>['queue', 'name', 'total_size', 'state', 'progress', 'num_seeds',
|
||||||
* 'total_seeds', 'num_peers', 'total_peers', 'download_payload_rate',
|
* 'total_seeds', 'num_peers', 'total_peers', 'download_payload_rate',
|
||||||
* 'upload_payload_rate', 'eta', 'ratio', 'distributed_copies',
|
* 'upload_payload_rate', 'eta', 'ratio', 'distributed_copies',
|
||||||
* 'is_auto_managed', 'time_added', 'tracker_host']</pre>
|
* 'is_auto_managed', 'time_added', 'tracker_host']</pre>
|
||||||
*/
|
*/
|
||||||
Grid: [
|
Grid: [
|
||||||
'queue', 'name', 'total_size', 'state', 'progress', 'num_seeds',
|
'queue', 'name', 'total_size', 'state', 'progress', 'num_seeds',
|
||||||
'total_seeds', 'num_peers', 'total_peers', 'download_payload_rate',
|
'total_seeds', 'num_peers', 'total_peers', 'download_payload_rate',
|
||||||
@ -54,22 +54,22 @@ Deluge.Keys = {
|
|||||||
/**
|
/**
|
||||||
* Keys used in the status tab of the statistics panel.
|
* Keys used in the status tab of the statistics panel.
|
||||||
* These get updated to include the keys in {@link #Grid}.
|
* These get updated to include the keys in {@link #Grid}.
|
||||||
* <pre>['total_done', 'total_payload_download', 'total_uploaded',
|
* <pre>['total_done', 'total_payload_download', 'total_uploaded',
|
||||||
* 'total_payload_upload', 'next_announce', 'tracker_status', 'num_pieces',
|
* 'total_payload_upload', 'next_announce', 'tracker_status', 'num_pieces',
|
||||||
* 'piece_length', 'is_auto_managed', 'active_time', 'seeding_time',
|
* 'piece_length', 'is_auto_managed', 'active_time', 'seeding_time',
|
||||||
* 'seed_rank']</pre>
|
* 'seed_rank']</pre>
|
||||||
*/
|
*/
|
||||||
Status: [
|
Status: [
|
||||||
'total_done', 'total_payload_download', 'total_uploaded',
|
'total_done', 'total_payload_download', 'total_uploaded',
|
||||||
'total_payload_upload', 'next_announce', 'tracker_status', 'num_pieces',
|
'total_payload_upload', 'next_announce', 'tracker_status', 'num_pieces',
|
||||||
'piece_length', 'is_auto_managed', 'active_time', 'seeding_time',
|
'piece_length', 'is_auto_managed', 'active_time', 'seeding_time',
|
||||||
'seed_rank'
|
'seed_rank', 'last_seen_complete', 'owner', 'public', 'shared'
|
||||||
],
|
],
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keys used in the files tab of the statistics panel.
|
* Keys used in the files tab of the statistics panel.
|
||||||
* <pre>['files', 'file_progress', 'file_priorities']</pre>
|
* <pre>['files', 'file_progress', 'file_priorities']</pre>
|
||||||
*/
|
*/
|
||||||
Files: [
|
Files: [
|
||||||
'files', 'file_progress', 'file_priorities'
|
'files', 'file_progress', 'file_priorities'
|
||||||
],
|
],
|
||||||
@ -77,25 +77,25 @@ Deluge.Keys = {
|
|||||||
/**
|
/**
|
||||||
* Keys used in the peers tab of the statistics panel.
|
* Keys used in the peers tab of the statistics panel.
|
||||||
* <pre>['peers']</pre>
|
* <pre>['peers']</pre>
|
||||||
*/
|
*/
|
||||||
Peers: [
|
Peers: [
|
||||||
'peers'
|
'peers'
|
||||||
],
|
],
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keys used in the details tab of the statistics panel.
|
* Keys used in the details tab of the statistics panel.
|
||||||
*/
|
*/
|
||||||
Details: [
|
Details: [
|
||||||
'name', 'save_path', 'total_size', 'num_files', 'message',
|
'name', 'save_path', 'total_size', 'num_files', 'message',
|
||||||
'tracker', 'comment'
|
'tracker', 'comment'
|
||||||
],
|
],
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keys used in the options tab of the statistics panel.
|
* Keys used in the options tab of the statistics panel.
|
||||||
* <pre>['max_download_speed', 'max_upload_speed', 'max_connections', 'max_upload_slots',
|
* <pre>['max_download_speed', 'max_upload_speed', 'max_connections', 'max_upload_slots',
|
||||||
* 'is_auto_managed', 'stop_at_ratio', 'stop_ratio', 'remove_at_ratio', 'private',
|
* 'is_auto_managed', 'stop_at_ratio', 'stop_ratio', 'remove_at_ratio', 'private',
|
||||||
* 'prioritize_first_last']</pre>
|
* 'prioritize_first_last']</pre>
|
||||||
*/
|
*/
|
||||||
Options: [
|
Options: [
|
||||||
'max_download_speed', 'max_upload_speed', 'max_connections',
|
'max_download_speed', 'max_upload_speed', 'max_connections',
|
||||||
'max_upload_slots','is_auto_managed', 'stop_at_ratio', 'stop_ratio',
|
'max_upload_slots','is_auto_managed', 'stop_at_ratio', 'stop_ratio',
|
||||||
|
|||||||
@ -31,123 +31,123 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
Deluge.LoginWindow = Ext.extend(Ext.Window, {
|
Deluge.LoginWindow = Ext.extend(Ext.Window, {
|
||||||
|
|
||||||
firstShow: true,
|
firstShow: true,
|
||||||
bodyStyle: 'padding: 10px 5px;',
|
bodyStyle: 'padding: 10px 5px;',
|
||||||
buttonAlign: 'center',
|
buttonAlign: 'center',
|
||||||
closable: false,
|
closable: false,
|
||||||
closeAction: 'hide',
|
closeAction: 'hide',
|
||||||
iconCls: 'x-deluge-login-window-icon',
|
iconCls: 'x-deluge-login-window-icon',
|
||||||
layout: 'fit',
|
layout: 'fit',
|
||||||
modal: true,
|
modal: true,
|
||||||
plain: true,
|
plain: true,
|
||||||
resizable: false,
|
resizable: false,
|
||||||
title: _('Login'),
|
title: _('Login'),
|
||||||
width: 300,
|
width: 300,
|
||||||
height: 120,
|
height: 120,
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.LoginWindow.superclass.initComponent.call(this);
|
Deluge.LoginWindow.superclass.initComponent.call(this);
|
||||||
this.on('show', this.onShow, this);
|
this.on('show', this.onShow, this);
|
||||||
|
|
||||||
this.addButton({
|
this.addButton({
|
||||||
text: _('Login'),
|
text: _('Login'),
|
||||||
handler: this.onLogin,
|
handler: this.onLogin,
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
|
|
||||||
this.form = this.add({
|
this.form = this.add({
|
||||||
xtype: 'form',
|
xtype: 'form',
|
||||||
baseCls: 'x-plain',
|
baseCls: 'x-plain',
|
||||||
labelWidth: 55,
|
labelWidth: 55,
|
||||||
width: 300,
|
width: 300,
|
||||||
defaults: {width: 200},
|
defaults: {width: 200},
|
||||||
defaultType: 'textfield'
|
defaultType: 'textfield'
|
||||||
});
|
});
|
||||||
|
|
||||||
this.passwordField = this.form.add({
|
this.passwordField = this.form.add({
|
||||||
xtype: 'textfield',
|
xtype: 'textfield',
|
||||||
fieldLabel: _('Password'),
|
fieldLabel: _('Password'),
|
||||||
id: '_password',
|
id: '_password',
|
||||||
name: 'password',
|
name: 'password',
|
||||||
inputType: 'password'
|
inputType: 'password'
|
||||||
});
|
});
|
||||||
this.passwordField.on('specialkey', this.onSpecialKey, this);
|
this.passwordField.on('specialkey', this.onSpecialKey, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
logout: function() {
|
logout: function() {
|
||||||
deluge.events.fire('logout');
|
deluge.events.fire('logout');
|
||||||
deluge.client.auth.delete_session({
|
deluge.client.auth.delete_session({
|
||||||
success: function(result) {
|
success: function(result) {
|
||||||
this.show(true);
|
this.show(true);
|
||||||
},
|
},
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
show: function(skipCheck) {
|
show: function(skipCheck) {
|
||||||
if (this.firstShow) {
|
if (this.firstShow) {
|
||||||
deluge.client.on('error', this.onClientError, this);
|
deluge.client.on('error', this.onClientError, this);
|
||||||
this.firstShow = false;
|
this.firstShow = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skipCheck) {
|
if (skipCheck) {
|
||||||
return Deluge.LoginWindow.superclass.show.call(this);
|
return Deluge.LoginWindow.superclass.show.call(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
deluge.client.auth.check_session({
|
deluge.client.auth.check_session({
|
||||||
success: function(result) {
|
success: function(result) {
|
||||||
if (result) {
|
if (result) {
|
||||||
deluge.events.fire('login');
|
deluge.events.fire('login');
|
||||||
} else {
|
} else {
|
||||||
this.show(true);
|
this.show(true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
failure: function(result) {
|
failure: function(result) {
|
||||||
this.show(true);
|
this.show(true);
|
||||||
},
|
},
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onSpecialKey: function(field, e) {
|
onSpecialKey: function(field, e) {
|
||||||
if (e.getKey() == 13) this.onLogin();
|
if (e.getKey() == 13) this.onLogin();
|
||||||
},
|
},
|
||||||
|
|
||||||
onLogin: function() {
|
onLogin: function() {
|
||||||
var passwordField = this.passwordField;
|
var passwordField = this.passwordField;
|
||||||
deluge.client.auth.login(passwordField.getValue(), {
|
deluge.client.auth.login(passwordField.getValue(), {
|
||||||
success: function(result) {
|
success: function(result) {
|
||||||
if (result) {
|
if (result) {
|
||||||
deluge.events.fire('login');
|
deluge.events.fire('login');
|
||||||
this.hide();
|
this.hide();
|
||||||
passwordField.setRawValue('');
|
passwordField.setRawValue('');
|
||||||
} else {
|
} else {
|
||||||
Ext.MessageBox.show({
|
Ext.MessageBox.show({
|
||||||
title: _('Login Failed'),
|
title: _('Login Failed'),
|
||||||
msg: _('You entered an incorrect password'),
|
msg: _('You entered an incorrect password'),
|
||||||
buttons: Ext.MessageBox.OK,
|
buttons: Ext.MessageBox.OK,
|
||||||
modal: false,
|
modal: false,
|
||||||
fn: function() {
|
fn: function() {
|
||||||
passwordField.focus(true, 10);
|
passwordField.focus(true, 10);
|
||||||
},
|
},
|
||||||
icon: Ext.MessageBox.WARNING,
|
icon: Ext.MessageBox.WARNING,
|
||||||
iconCls: 'x-deluge-icon-warning'
|
iconCls: 'x-deluge-icon-warning'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onClientError: function(errorObj, response, requestOptions) {
|
onClientError: function(errorObj, response, requestOptions) {
|
||||||
if (errorObj.error.code == 1) {
|
if (errorObj.error.code == 1) {
|
||||||
deluge.events.fire('logout');
|
deluge.events.fire('logout');
|
||||||
this.show(true);
|
this.show(true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onShow: function() {
|
onShow: function() {
|
||||||
this.passwordField.focus(true, true);
|
this.passwordField.focus(true, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -31,240 +31,240 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
deluge.menus = {
|
deluge.menus = {
|
||||||
onTorrentAction: function(item, e) {
|
onTorrentAction: function(item, e) {
|
||||||
var ids = deluge.torrents.getSelectedIds();
|
var ids = deluge.torrents.getSelectedIds();
|
||||||
var action = item.initialConfig.torrentAction;
|
var action = item.initialConfig.torrentAction;
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case 'pause':
|
case 'pause':
|
||||||
case 'resume':
|
case 'resume':
|
||||||
deluge.client.core[action + '_torrent'](ids, {
|
deluge.client.core[action + '_torrent'](ids, {
|
||||||
success: function() {
|
success: function() {
|
||||||
deluge.ui.update();
|
deluge.ui.update();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'top':
|
case 'top':
|
||||||
case 'up':
|
case 'up':
|
||||||
case 'down':
|
case 'down':
|
||||||
case 'bottom':
|
case 'bottom':
|
||||||
deluge.client.core['queue_' + action](ids, {
|
deluge.client.core['queue_' + action](ids, {
|
||||||
success: function() {
|
success: function() {
|
||||||
deluge.ui.update();
|
deluge.ui.update();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'edit_trackers':
|
case 'edit_trackers':
|
||||||
deluge.editTrackers.show();
|
deluge.editTrackers.show();
|
||||||
break;
|
break;
|
||||||
case 'update':
|
case 'update':
|
||||||
deluge.client.core.force_reannounce(ids, {
|
deluge.client.core.force_reannounce(ids, {
|
||||||
success: function() {
|
success: function() {
|
||||||
deluge.ui.update();
|
deluge.ui.update();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'remove':
|
case 'remove':
|
||||||
deluge.removeWindow.show(ids);
|
deluge.removeWindow.show(ids);
|
||||||
break;
|
break;
|
||||||
case 'recheck':
|
case 'recheck':
|
||||||
deluge.client.core.force_recheck(ids, {
|
deluge.client.core.force_recheck(ids, {
|
||||||
success: function() {
|
success: function() {
|
||||||
deluge.ui.update();
|
deluge.ui.update();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'move':
|
case 'move':
|
||||||
deluge.moveStorage.show(ids);
|
deluge.moveStorage.show(ids);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
deluge.menus.torrent = new Ext.menu.Menu({
|
deluge.menus.torrent = new Ext.menu.Menu({
|
||||||
id: 'torrentMenu',
|
id: 'torrentMenu',
|
||||||
items: [{
|
items: [{
|
||||||
torrentAction: 'pause',
|
torrentAction: 'pause',
|
||||||
text: _('Pause'),
|
text: _('Pause'),
|
||||||
iconCls: 'icon-pause',
|
iconCls: 'icon-pause',
|
||||||
handler: deluge.menus.onTorrentAction,
|
handler: deluge.menus.onTorrentAction,
|
||||||
scope: deluge.menus
|
scope: deluge.menus
|
||||||
}, {
|
}, {
|
||||||
torrentAction: 'resume',
|
torrentAction: 'resume',
|
||||||
text: _('Resume'),
|
text: _('Resume'),
|
||||||
iconCls: 'icon-resume',
|
iconCls: 'icon-resume',
|
||||||
handler: deluge.menus.onTorrentAction,
|
handler: deluge.menus.onTorrentAction,
|
||||||
scope: deluge.menus
|
scope: deluge.menus
|
||||||
}, '-', {
|
}, '-', {
|
||||||
text: _('Options'),
|
text: _('Options'),
|
||||||
iconCls: 'icon-options',
|
iconCls: 'icon-options',
|
||||||
menu: new Ext.menu.Menu({
|
menu: new Ext.menu.Menu({
|
||||||
items: [{
|
items: [{
|
||||||
text: _('D/L Speed Limit'),
|
text: _('D/L Speed Limit'),
|
||||||
iconCls: 'x-deluge-downloading',
|
iconCls: 'x-deluge-downloading',
|
||||||
menu: new Ext.menu.Menu({
|
menu: new Ext.menu.Menu({
|
||||||
items: [{
|
items: [{
|
||||||
text: _('5 KiB/s')
|
text: _('5 KiB/s')
|
||||||
}, {
|
}, {
|
||||||
text: _('10 KiB/s')
|
text: _('10 KiB/s')
|
||||||
}, {
|
}, {
|
||||||
text: _('30 KiB/s')
|
text: _('30 KiB/s')
|
||||||
}, {
|
}, {
|
||||||
text: _('80 KiB/s')
|
text: _('80 KiB/s')
|
||||||
}, {
|
}, {
|
||||||
text: _('300 KiB/s')
|
text: _('300 KiB/s')
|
||||||
},{
|
},{
|
||||||
text: _('Unlimited')
|
text: _('Unlimited')
|
||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
}, {
|
}, {
|
||||||
text: _('U/L Speed Limit'),
|
text: _('U/L Speed Limit'),
|
||||||
iconCls: 'x-deluge-seeding',
|
iconCls: 'x-deluge-seeding',
|
||||||
menu: new Ext.menu.Menu({
|
menu: new Ext.menu.Menu({
|
||||||
items: [{
|
items: [{
|
||||||
text: _('5 KiB/s')
|
text: _('5 KiB/s')
|
||||||
}, {
|
}, {
|
||||||
text: _('10 KiB/s')
|
text: _('10 KiB/s')
|
||||||
}, {
|
}, {
|
||||||
text: _('30 KiB/s')
|
text: _('30 KiB/s')
|
||||||
}, {
|
}, {
|
||||||
text: _('80 KiB/s')
|
text: _('80 KiB/s')
|
||||||
}, {
|
}, {
|
||||||
text: _('300 KiB/s')
|
text: _('300 KiB/s')
|
||||||
},{
|
},{
|
||||||
text: _('Unlimited')
|
text: _('Unlimited')
|
||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
}, {
|
}, {
|
||||||
text: _('Connection Limit'),
|
text: _('Connection Limit'),
|
||||||
iconCls: 'x-deluge-connections',
|
iconCls: 'x-deluge-connections',
|
||||||
menu: new Ext.menu.Menu({
|
menu: new Ext.menu.Menu({
|
||||||
items: [{
|
items: [{
|
||||||
text: _('50')
|
text: _('50')
|
||||||
}, {
|
}, {
|
||||||
text: _('100')
|
text: _('100')
|
||||||
}, {
|
}, {
|
||||||
text: _('200')
|
text: _('200')
|
||||||
}, {
|
}, {
|
||||||
text: _('300')
|
text: _('300')
|
||||||
}, {
|
}, {
|
||||||
text: _('500')
|
text: _('500')
|
||||||
},{
|
},{
|
||||||
text: _('Unlimited')
|
text: _('Unlimited')
|
||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
}, {
|
}, {
|
||||||
text: _('Upload Slot Limit'),
|
text: _('Upload Slot Limit'),
|
||||||
iconCls: 'icon-upload-slots',
|
iconCls: 'icon-upload-slots',
|
||||||
menu: new Ext.menu.Menu({
|
menu: new Ext.menu.Menu({
|
||||||
items: [{
|
items: [{
|
||||||
text: _('0')
|
text: _('0')
|
||||||
}, {
|
}, {
|
||||||
text: _('1')
|
text: _('1')
|
||||||
}, {
|
}, {
|
||||||
text: _('2')
|
text: _('2')
|
||||||
}, {
|
}, {
|
||||||
text: _('3')
|
text: _('3')
|
||||||
}, {
|
}, {
|
||||||
text: _('5')
|
text: _('5')
|
||||||
},{
|
},{
|
||||||
text: _('Unlimited')
|
text: _('Unlimited')
|
||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
}, {
|
}, {
|
||||||
id: 'auto_managed',
|
id: 'auto_managed',
|
||||||
text: _('Auto Managed'),
|
text: _('Auto Managed'),
|
||||||
checked: false
|
checked: false
|
||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
}, '-', {
|
}, '-', {
|
||||||
text: _('Queue'),
|
text: _('Queue'),
|
||||||
iconCls: 'icon-queue',
|
iconCls: 'icon-queue',
|
||||||
menu: new Ext.menu.Menu({
|
menu: new Ext.menu.Menu({
|
||||||
items: [{
|
items: [{
|
||||||
torrentAction: 'top',
|
torrentAction: 'top',
|
||||||
text: _('Top'),
|
text: _('Top'),
|
||||||
iconCls: 'icon-top',
|
iconCls: 'icon-top',
|
||||||
handler: deluge.menus.onTorrentAction,
|
handler: deluge.menus.onTorrentAction,
|
||||||
scope: deluge.menus
|
scope: deluge.menus
|
||||||
},{
|
},{
|
||||||
torrentAction: 'up',
|
torrentAction: 'up',
|
||||||
text: _('Up'),
|
text: _('Up'),
|
||||||
iconCls: 'icon-up',
|
iconCls: 'icon-up',
|
||||||
handler: deluge.menus.onTorrentAction,
|
handler: deluge.menus.onTorrentAction,
|
||||||
scope: deluge.menus
|
scope: deluge.menus
|
||||||
},{
|
},{
|
||||||
torrentAction: 'down',
|
torrentAction: 'down',
|
||||||
text: _('Down'),
|
text: _('Down'),
|
||||||
iconCls: 'icon-down',
|
iconCls: 'icon-down',
|
||||||
handler: deluge.menus.onTorrentAction,
|
handler: deluge.menus.onTorrentAction,
|
||||||
scope: deluge.menus
|
scope: deluge.menus
|
||||||
},{
|
},{
|
||||||
torrentAction: 'bottom',
|
torrentAction: 'bottom',
|
||||||
text: _('Bottom'),
|
text: _('Bottom'),
|
||||||
iconCls: 'icon-bottom',
|
iconCls: 'icon-bottom',
|
||||||
handler: deluge.menus.onTorrentAction,
|
handler: deluge.menus.onTorrentAction,
|
||||||
scope: deluge.menus
|
scope: deluge.menus
|
||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
}, '-', {
|
}, '-', {
|
||||||
torrentAction: 'update',
|
torrentAction: 'update',
|
||||||
text: _('Update Tracker'),
|
text: _('Update Tracker'),
|
||||||
iconCls: 'icon-update-tracker',
|
iconCls: 'icon-update-tracker',
|
||||||
handler: deluge.menus.onTorrentAction,
|
handler: deluge.menus.onTorrentAction,
|
||||||
scope: deluge.menus
|
scope: deluge.menus
|
||||||
}, {
|
}, {
|
||||||
torrentAction: 'edit_trackers',
|
torrentAction: 'edit_trackers',
|
||||||
text: _('Edit Trackers'),
|
text: _('Edit Trackers'),
|
||||||
iconCls: 'icon-edit-trackers',
|
iconCls: 'icon-edit-trackers',
|
||||||
handler: deluge.menus.onTorrentAction,
|
handler: deluge.menus.onTorrentAction,
|
||||||
scope: deluge.menus
|
scope: deluge.menus
|
||||||
}, '-', {
|
}, '-', {
|
||||||
torrentAction: 'remove',
|
torrentAction: 'remove',
|
||||||
text: _('Remove Torrent'),
|
text: _('Remove Torrent'),
|
||||||
iconCls: 'icon-remove',
|
iconCls: 'icon-remove',
|
||||||
handler: deluge.menus.onTorrentAction,
|
handler: deluge.menus.onTorrentAction,
|
||||||
scope: deluge.menus
|
scope: deluge.menus
|
||||||
}, '-', {
|
}, '-', {
|
||||||
torrentAction: 'recheck',
|
torrentAction: 'recheck',
|
||||||
text: _('Force Recheck'),
|
text: _('Force Recheck'),
|
||||||
iconCls: 'icon-recheck',
|
iconCls: 'icon-recheck',
|
||||||
handler: deluge.menus.onTorrentAction,
|
handler: deluge.menus.onTorrentAction,
|
||||||
scope: deluge.menus
|
scope: deluge.menus
|
||||||
}, {
|
}, {
|
||||||
torrentAction: 'move',
|
torrentAction: 'move',
|
||||||
text: _('Move Storage'),
|
text: _('Move Storage'),
|
||||||
iconCls: 'icon-move',
|
iconCls: 'icon-move',
|
||||||
handler: deluge.menus.onTorrentAction,
|
handler: deluge.menus.onTorrentAction,
|
||||||
scope: deluge.menus
|
scope: deluge.menus
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
|
|
||||||
deluge.menus.filePriorities = new Ext.menu.Menu({
|
deluge.menus.filePriorities = new Ext.menu.Menu({
|
||||||
id: 'filePrioritiesMenu',
|
id: 'filePrioritiesMenu',
|
||||||
items: [{
|
items: [{
|
||||||
id: 'expandAll',
|
id: 'expandAll',
|
||||||
text: _('Expand All'),
|
text: _('Expand All'),
|
||||||
iconCls: 'icon-expand-all'
|
iconCls: 'icon-expand-all'
|
||||||
}, '-', {
|
}, '-', {
|
||||||
id: 'no_download',
|
id: 'no_download',
|
||||||
text: _('Do Not Download'),
|
text: _('Do Not Download'),
|
||||||
iconCls: 'icon-do-not-download',
|
iconCls: 'icon-do-not-download',
|
||||||
filePriority: 0
|
filePriority: 0
|
||||||
}, {
|
}, {
|
||||||
id: 'normal',
|
id: 'normal',
|
||||||
text: _('Normal Priority'),
|
text: _('Normal Priority'),
|
||||||
iconCls: 'icon-normal',
|
iconCls: 'icon-normal',
|
||||||
filePriority: 1
|
filePriority: 1
|
||||||
}, {
|
}, {
|
||||||
id: 'high',
|
id: 'high',
|
||||||
text: _('High Priority'),
|
text: _('High Priority'),
|
||||||
iconCls: 'icon-high',
|
iconCls: 'icon-high',
|
||||||
filePriority: 2
|
filePriority: 2
|
||||||
}, {
|
}, {
|
||||||
id: 'highest',
|
id: 'highest',
|
||||||
text: _('Highest Priority'),
|
text: _('Highest Priority'),
|
||||||
iconCls: 'icon-highest',
|
iconCls: 'icon-highest',
|
||||||
filePriority: 5
|
filePriority: 5
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
|
|||||||
@ -32,73 +32,73 @@
|
|||||||
|
|
||||||
Ext.namespace('Deluge');
|
Ext.namespace('Deluge');
|
||||||
Deluge.MoveStorage = Ext.extend(Ext.Window, {
|
Deluge.MoveStorage = Ext.extend(Ext.Window, {
|
||||||
|
|
||||||
constructor: function(config) {
|
constructor: function(config) {
|
||||||
config = Ext.apply({
|
config = Ext.apply({
|
||||||
title: _('Move Storage'),
|
title: _('Move Storage'),
|
||||||
width: 375,
|
width: 375,
|
||||||
height: 110,
|
height: 110,
|
||||||
layout: 'fit',
|
layout: 'fit',
|
||||||
buttonAlign: 'right',
|
buttonAlign: 'right',
|
||||||
closeAction: 'hide',
|
closeAction: 'hide',
|
||||||
closable: true,
|
closable: true,
|
||||||
iconCls: 'x-deluge-move-storage',
|
iconCls: 'x-deluge-move-storage',
|
||||||
plain: true,
|
plain: true,
|
||||||
resizable: false
|
resizable: false
|
||||||
}, config);
|
}, config);
|
||||||
Deluge.MoveStorage.superclass.constructor.call(this, config);
|
Deluge.MoveStorage.superclass.constructor.call(this, config);
|
||||||
},
|
},
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.MoveStorage.superclass.initComponent.call(this);
|
Deluge.MoveStorage.superclass.initComponent.call(this);
|
||||||
|
|
||||||
this.addButton(_('Cancel'), this.onCancel, this);
|
this.addButton(_('Cancel'), this.onCancel, this);
|
||||||
this.addButton(_('Move'), this.onMove, this);
|
this.addButton(_('Move'), this.onMove, this);
|
||||||
|
|
||||||
this.form = this.add({
|
this.form = this.add({
|
||||||
xtype: 'form',
|
xtype: 'form',
|
||||||
border: false,
|
border: false,
|
||||||
defaultType: 'textfield',
|
defaultType: 'textfield',
|
||||||
width: 300,
|
width: 300,
|
||||||
bodyStyle: 'padding: 5px'
|
bodyStyle: 'padding: 5px'
|
||||||
});
|
});
|
||||||
|
|
||||||
this.moveLocation = this.form.add({
|
this.moveLocation = this.form.add({
|
||||||
fieldLabel: _('Location'),
|
fieldLabel: _('Location'),
|
||||||
name: 'location',
|
name: 'location',
|
||||||
width: 240
|
width: 240
|
||||||
});
|
});
|
||||||
//this.form.add({
|
//this.form.add({
|
||||||
// xtype: 'button',
|
// xtype: 'button',
|
||||||
// text: _('Browse'),
|
// text: _('Browse'),
|
||||||
// handler: function() {
|
// handler: function() {
|
||||||
// if (!this.fileBrowser) {
|
// if (!this.fileBrowser) {
|
||||||
// this.fileBrowser = new Deluge.FileBrowser();
|
// this.fileBrowser = new Deluge.FileBrowser();
|
||||||
// }
|
// }
|
||||||
// this.fileBrowser.show();
|
// this.fileBrowser.show();
|
||||||
// },
|
// },
|
||||||
// scope: this
|
// scope: this
|
||||||
//});
|
//});
|
||||||
},
|
},
|
||||||
|
|
||||||
hide: function() {
|
hide: function() {
|
||||||
Deluge.MoveStorage.superclass.hide.call(this);
|
Deluge.MoveStorage.superclass.hide.call(this);
|
||||||
this.torrentIds = null;
|
this.torrentIds = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
show: function(torrentIds) {
|
show: function(torrentIds) {
|
||||||
Deluge.MoveStorage.superclass.show.call(this);
|
Deluge.MoveStorage.superclass.show.call(this);
|
||||||
this.torrentIds = torrentIds;
|
this.torrentIds = torrentIds;
|
||||||
},
|
},
|
||||||
|
|
||||||
onCancel: function() {
|
onCancel: function() {
|
||||||
this.hide();
|
this.hide();
|
||||||
},
|
},
|
||||||
|
|
||||||
onMove: function() {
|
onMove: function() {
|
||||||
var dest = this.moveLocation.getValue();
|
var dest = this.moveLocation.getValue();
|
||||||
deluge.client.core.move_storage(this.torrentIds, dest);
|
deluge.client.core.move_storage(this.torrentIds, dest);
|
||||||
this.hide();
|
this.hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
deluge.moveStorage = new Deluge.MoveStorage();
|
deluge.moveStorage = new Deluge.MoveStorage();
|
||||||
|
|||||||
@ -38,177 +38,177 @@
|
|||||||
*/
|
*/
|
||||||
Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, {
|
Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, {
|
||||||
|
|
||||||
constructor: function(config) {
|
constructor: function(config) {
|
||||||
this.currentId = null;
|
this.currentId = null;
|
||||||
this.stored = {};
|
this.stored = {};
|
||||||
Deluge.MultiOptionsManager.superclass.constructor.call(this, config);
|
Deluge.MultiOptionsManager.superclass.constructor.call(this, config);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes bound fields to use the specified id.
|
* Changes bound fields to use the specified id.
|
||||||
* @param {String} id
|
* @param {String} id
|
||||||
*/
|
*/
|
||||||
changeId: function(id, dontUpdateBinds) {
|
changeId: function(id, dontUpdateBinds) {
|
||||||
var oldId = this.currentId;
|
var oldId = this.currentId;
|
||||||
this.currentId = id;
|
this.currentId = id;
|
||||||
if (!dontUpdateBinds) {
|
if (!dontUpdateBinds) {
|
||||||
for (var option in this.options) {
|
for (var option in this.options) {
|
||||||
if (!this.binds[option]) continue;
|
if (!this.binds[option]) continue;
|
||||||
Ext.each(this.binds[option], function(bind) {
|
Ext.each(this.binds[option], function(bind) {
|
||||||
bind.setValue(this.get(option));
|
bind.setValue(this.get(option));
|
||||||
}, this);
|
}, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return oldId;
|
return oldId;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes all the changed values to be the default values
|
* Changes all the changed values to be the default values
|
||||||
* @param {String} id
|
* @param {String} id
|
||||||
*/
|
*/
|
||||||
commit: function() {
|
commit: function() {
|
||||||
this.stored[this.currentId] = Ext.apply(this.stored[this.currentId], this.changed[this.currentId]);
|
this.stored[this.currentId] = Ext.apply(this.stored[this.currentId], this.changed[this.currentId]);
|
||||||
this.reset();
|
this.reset();
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the value for an option
|
* Get the value for an option
|
||||||
* @param {String/Array} option A single option or an array of options to return.
|
* @param {String/Array} option A single option or an array of options to return.
|
||||||
* @returns {Object} the options value.
|
* @returns {Object} the options value.
|
||||||
*/
|
*/
|
||||||
get: function() {
|
get: function() {
|
||||||
if (arguments.length == 1) {
|
if (arguments.length == 1) {
|
||||||
var option = arguments[0];
|
var option = arguments[0];
|
||||||
return (this.isDirty(option)) ? this.changed[this.currentId][option] : this.getDefault(option);
|
return (this.isDirty(option)) ? this.changed[this.currentId][option] : this.getDefault(option);
|
||||||
} else if (arguments.length == 0) {
|
} else if (arguments.length == 0) {
|
||||||
var options = {};
|
var options = {};
|
||||||
for (var option in this.options) {
|
for (var option in this.options) {
|
||||||
options[option] = (this.isDirty(option)) ? this.changed[this.currentId][option] : this.getDefault(option);
|
options[option] = (this.isDirty(option)) ? this.changed[this.currentId][option] : this.getDefault(option);
|
||||||
}
|
}
|
||||||
return options;
|
return options;
|
||||||
} else {
|
} else {
|
||||||
var options = {};
|
var options = {};
|
||||||
Ext.each(arguments, function(option) {
|
Ext.each(arguments, function(option) {
|
||||||
options[option] = (this.isDirty(option)) ? this.changed[this.currentId][option] : this.getDefault(option);
|
options[option] = (this.isDirty(option)) ? this.changed[this.currentId][option] : this.getDefault(option);
|
||||||
}, this);
|
}, this);
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the default value for an option.
|
* Get the default value for an option.
|
||||||
* @param {String} option A single option.
|
* @param {String} option A single option.
|
||||||
* @returns {Object} the value of the option
|
* @returns {Object} the value of the option
|
||||||
*/
|
*/
|
||||||
getDefault: function(option) {
|
getDefault: function(option) {
|
||||||
return (this.has(option)) ? this.stored[this.currentId][option] : this.options[option];
|
return (this.has(option)) ? this.stored[this.currentId][option] : this.options[option];
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the dirty (changed) values.
|
* Returns the dirty (changed) values.
|
||||||
* @returns {Object} the changed options
|
* @returns {Object} the changed options
|
||||||
*/
|
*/
|
||||||
getDirty: function() {
|
getDirty: function() {
|
||||||
return (this.changed[this.currentId]) ? this.changed[this.currentId] : {};
|
return (this.changed[this.currentId]) ? this.changed[this.currentId] : {};
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check to see if the option has been changed.
|
* Check to see if the option has been changed.
|
||||||
* @param {String} option
|
* @param {String} option
|
||||||
* @returns {Boolean} true if the option has been changed, else false.
|
* @returns {Boolean} true if the option has been changed, else false.
|
||||||
*/
|
*/
|
||||||
isDirty: function(option) {
|
isDirty: function(option) {
|
||||||
return (this.changed[this.currentId] && !Ext.isEmpty(this.changed[this.currentId][option]));
|
return (this.changed[this.currentId] && !Ext.isEmpty(this.changed[this.currentId][option]));
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check to see if an id has had an option set to something other than the
|
* Check to see if an id has had an option set to something other than the
|
||||||
* default value.
|
* default value.
|
||||||
* @param {String} option
|
* @param {String} option
|
||||||
* @returns {Boolean} true if the id has an option, else false.
|
* @returns {Boolean} true if the id has an option, else false.
|
||||||
*/
|
*/
|
||||||
has: function(option) {
|
has: function(option) {
|
||||||
return (this.stored[this.currentId] && !Ext.isEmpty(this.stored[this.currentId][option]));
|
return (this.stored[this.currentId] && !Ext.isEmpty(this.stored[this.currentId][option]));
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset the options back to the default values for the specified id.
|
* Reset the options back to the default values for the specified id.
|
||||||
*/
|
*/
|
||||||
reset: function() {
|
reset: function() {
|
||||||
if (this.changed[this.currentId]) delete this.changed[this.currentId];
|
if (this.changed[this.currentId]) delete this.changed[this.currentId];
|
||||||
if (this.stored[this.currentId]) delete this.stored[this.currentId];
|
if (this.stored[this.currentId]) delete this.stored[this.currentId];
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset the options back to their defaults for all ids.
|
* Reset the options back to their defaults for all ids.
|
||||||
*/
|
*/
|
||||||
resetAll: function() {
|
resetAll: function() {
|
||||||
this.changed = {};
|
this.changed = {};
|
||||||
this.stored = {};
|
this.stored = {};
|
||||||
this.changeId(null);
|
this.changeId(null);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the value of specified option for the passed in id.
|
* Sets the value of specified option for the passed in id.
|
||||||
* @param {String} id
|
* @param {String} id
|
||||||
* @param {String} option
|
* @param {String} option
|
||||||
* @param {Object} value The value for the option
|
* @param {Object} value The value for the option
|
||||||
*/
|
*/
|
||||||
setDefault: function(option, value) {
|
setDefault: function(option, value) {
|
||||||
if (option === undefined) {
|
if (option === undefined) {
|
||||||
return;
|
return;
|
||||||
} else if (value === undefined) {
|
} else if (value === undefined) {
|
||||||
for (var key in option) {
|
for (var key in option) {
|
||||||
this.setDefault(key, option[key]);
|
this.setDefault(key, option[key]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var oldValue = this.getDefault(option);
|
var oldValue = this.getDefault(option);
|
||||||
value = this.convertValueType(oldValue, value);
|
value = this.convertValueType(oldValue, value);
|
||||||
|
|
||||||
// If the value is the same as the old value there is
|
// If the value is the same as the old value there is
|
||||||
// no point in setting it again.
|
// no point in setting it again.
|
||||||
if (oldValue == value) return;
|
if (oldValue == value) return;
|
||||||
|
|
||||||
// Store the new default
|
// Store the new default
|
||||||
if (!this.stored[this.currentId]) this.stored[this.currentId] = {};
|
if (!this.stored[this.currentId]) this.stored[this.currentId] = {};
|
||||||
this.stored[this.currentId][option] = value;
|
this.stored[this.currentId][option] = value;
|
||||||
|
|
||||||
if (!this.isDirty(option)) {
|
if (!this.isDirty(option)) {
|
||||||
this.fireEvent('changed', option, value, oldValue);
|
this.fireEvent('changed', option, value, oldValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the value for the specified option and id.
|
* Update the value for the specified option and id.
|
||||||
* @param {String} id
|
* @param {String} id
|
||||||
* @param {String/Object} option or options to update
|
* @param {String/Object} option or options to update
|
||||||
* @param {Object} [value];
|
* @param {Object} [value];
|
||||||
*/
|
*/
|
||||||
update: function(option, value) {
|
update: function(option, value) {
|
||||||
if (option === undefined) {
|
if (option === undefined) {
|
||||||
return;
|
return;
|
||||||
} else if (value === undefined) {
|
} else if (value === undefined) {
|
||||||
for (var key in option) {
|
for (var key in option) {
|
||||||
this.update(key, option[key]);
|
this.update(key, option[key]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!this.changed[this.currentId]) this.changed[this.currentId] = {};
|
if (!this.changed[this.currentId]) this.changed[this.currentId] = {};
|
||||||
|
|
||||||
var defaultValue = this.getDefault(option);
|
var defaultValue = this.getDefault(option);
|
||||||
value = this.convertValueType(defaultValue, value);
|
value = this.convertValueType(defaultValue, value);
|
||||||
|
|
||||||
var oldValue = this.get(option);
|
var oldValue = this.get(option);
|
||||||
if (oldValue == value) return;
|
if (oldValue == value) return;
|
||||||
|
|
||||||
if (defaultValue == value) {
|
if (defaultValue == value) {
|
||||||
if (this.isDirty(option)) delete this.changed[this.currentId][option];
|
if (this.isDirty(option)) delete this.changed[this.currentId][option];
|
||||||
this.fireEvent('changed', option, value, oldValue);
|
this.fireEvent('changed', option, value, oldValue);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
this.changed[this.currentId][option] = value;
|
this.changed[this.currentId][option] = value;
|
||||||
this.fireEvent('changed', option, value, oldValue);
|
this.fireEvent('changed', option, value, oldValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -40,250 +40,250 @@ Ext.namespace('Deluge');
|
|||||||
* @param {Object} config Configuration options
|
* @param {Object} config Configuration options
|
||||||
*/
|
*/
|
||||||
Deluge.OptionsManager = Ext.extend(Ext.util.Observable, {
|
Deluge.OptionsManager = Ext.extend(Ext.util.Observable, {
|
||||||
|
|
||||||
constructor: function(config) {
|
constructor: function(config) {
|
||||||
config = config || {};
|
config = config || {};
|
||||||
this.binds = {};
|
this.binds = {};
|
||||||
this.changed = {};
|
this.changed = {};
|
||||||
this.options = (config && config['options']) || {};
|
this.options = (config && config['options']) || {};
|
||||||
this.focused = null;
|
this.focused = null;
|
||||||
|
|
||||||
this.addEvents({
|
this.addEvents({
|
||||||
/**
|
/**
|
||||||
* @event add
|
* @event add
|
||||||
* Fires when an option is added
|
* Fires when an option is added
|
||||||
*/
|
*/
|
||||||
'add': true,
|
'add': true,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @event changed
|
* @event changed
|
||||||
* Fires when an option is changed
|
* Fires when an option is changed
|
||||||
* @param {String} option The changed option
|
* @param {String} option The changed option
|
||||||
* @param {Mixed} value The options new value
|
* @param {Mixed} value The options new value
|
||||||
* @param {Mixed} oldValue The options old value
|
* @param {Mixed} oldValue The options old value
|
||||||
*/
|
*/
|
||||||
'changed': true,
|
'changed': true,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @event reset
|
* @event reset
|
||||||
* Fires when the options are reset
|
* Fires when the options are reset
|
||||||
*/
|
*/
|
||||||
'reset': true
|
'reset': true
|
||||||
});
|
});
|
||||||
this.on('changed', this.onChange, this);
|
this.on('changed', this.onChange, this);
|
||||||
|
|
||||||
Deluge.OptionsManager.superclass.constructor.call(this);
|
Deluge.OptionsManager.superclass.constructor.call(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a set of default options and values to the options manager
|
* Add a set of default options and values to the options manager
|
||||||
* @param {Object} options The default options.
|
* @param {Object} options The default options.
|
||||||
*/
|
*/
|
||||||
addOptions: function(options) {
|
addOptions: function(options) {
|
||||||
this.options = Ext.applyIf(this.options, options);
|
this.options = Ext.applyIf(this.options, options);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Binds a form field to the specified option.
|
* Binds a form field to the specified option.
|
||||||
* @param {String} option
|
* @param {String} option
|
||||||
* @param {Ext.form.Field} field
|
* @param {Ext.form.Field} field
|
||||||
*/
|
*/
|
||||||
bind: function(option, field) {
|
bind: function(option, field) {
|
||||||
this.binds[option] = this.binds[option] || [];
|
this.binds[option] = this.binds[option] || [];
|
||||||
this.binds[option].push(field);
|
this.binds[option].push(field);
|
||||||
field._doption = option;
|
field._doption = option;
|
||||||
|
|
||||||
field.on('focus', this.onFieldFocus, this);
|
field.on('focus', this.onFieldFocus, this);
|
||||||
field.on('blur', this.onFieldBlur, this);
|
field.on('blur', this.onFieldBlur, this);
|
||||||
field.on('change', this.onFieldChange, this);
|
field.on('change', this.onFieldChange, this);
|
||||||
field.on('check', this.onFieldChange, this);
|
field.on('check', this.onFieldChange, this);
|
||||||
field.on('spin', this.onFieldChange, this);
|
field.on('spin', this.onFieldChange, this);
|
||||||
return field;
|
return field;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes all the changed values to be the default values
|
* Changes all the changed values to be the default values
|
||||||
*/
|
*/
|
||||||
commit: function() {
|
commit: function() {
|
||||||
this.options = Ext.apply(this.options, this.changed);
|
this.options = Ext.apply(this.options, this.changed);
|
||||||
this.reset();
|
this.reset();
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts the value so it matches the originals type
|
* Converts the value so it matches the originals type
|
||||||
* @param {Mixed} oldValue The original value
|
* @param {Mixed} oldValue The original value
|
||||||
* @param {Mixed} value The new value to convert
|
* @param {Mixed} value The new value to convert
|
||||||
*/
|
*/
|
||||||
convertValueType: function(oldValue, value) {
|
convertValueType: function(oldValue, value) {
|
||||||
if (Ext.type(oldValue) != Ext.type(value)) {
|
if (Ext.type(oldValue) != Ext.type(value)) {
|
||||||
switch (Ext.type(oldValue)) {
|
switch (Ext.type(oldValue)) {
|
||||||
case 'string':
|
case 'string':
|
||||||
value = String(value);
|
value = String(value);
|
||||||
break;
|
break;
|
||||||
case 'number':
|
case 'number':
|
||||||
value = Number(value);
|
value = Number(value);
|
||||||
break;
|
break;
|
||||||
case 'boolean':
|
case 'boolean':
|
||||||
if (Ext.type(value) == 'string') {
|
if (Ext.type(value) == 'string') {
|
||||||
value = value.toLowerCase();
|
value = value.toLowerCase();
|
||||||
value = (value == 'true' || value == '1' || value == 'on') ? true : false;
|
value = (value == 'true' || value == '1' || value == 'on') ? true : false;
|
||||||
} else {
|
} else {
|
||||||
value = Boolean(value);
|
value = Boolean(value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the value for an option or options.
|
* Get the value for an option or options.
|
||||||
* @param {String} [option] A single option or an array of options to return.
|
* @param {String} [option] A single option or an array of options to return.
|
||||||
* @returns {Object} the options value.
|
* @returns {Object} the options value.
|
||||||
*/
|
*/
|
||||||
get: function() {
|
get: function() {
|
||||||
if (arguments.length == 1) {
|
if (arguments.length == 1) {
|
||||||
var option = arguments[0];
|
var option = arguments[0];
|
||||||
return (this.isDirty(option)) ? this.changed[option] : this.options[option];
|
return (this.isDirty(option)) ? this.changed[option] : this.options[option];
|
||||||
} else {
|
} else {
|
||||||
var options = {};
|
var options = {};
|
||||||
Ext.each(arguments, function(option) {
|
Ext.each(arguments, function(option) {
|
||||||
if (!this.has(option)) return;
|
if (!this.has(option)) return;
|
||||||
options[option] = (this.isDirty(option)) ? this.changed[option] : this.options[option];
|
options[option] = (this.isDirty(option)) ? this.changed[option] : this.options[option];
|
||||||
}, this);
|
}, this);
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the default value for an option or options.
|
* Get the default value for an option or options.
|
||||||
* @param {String|Array} [option] A single option or an array of options to return.
|
* @param {String|Array} [option] A single option or an array of options to return.
|
||||||
* @returns {Object} the value of the option
|
* @returns {Object} the value of the option
|
||||||
*/
|
*/
|
||||||
getDefault: function(option) {
|
getDefault: function(option) {
|
||||||
return this.options[option];
|
return this.options[option];
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the dirty (changed) values.
|
* Returns the dirty (changed) values.
|
||||||
* @returns {Object} the changed options
|
* @returns {Object} the changed options
|
||||||
*/
|
*/
|
||||||
getDirty: function() {
|
getDirty: function() {
|
||||||
return this.changed;
|
return this.changed;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {String} [option] The option to check
|
* @param {String} [option] The option to check
|
||||||
* @returns {Boolean} true if the option has been changed from the default.
|
* @returns {Boolean} true if the option has been changed from the default.
|
||||||
*/
|
*/
|
||||||
isDirty: function(option) {
|
isDirty: function(option) {
|
||||||
return !Ext.isEmpty(this.changed[option]);
|
return !Ext.isEmpty(this.changed[option]);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check to see if an option exists in the options manager
|
* Check to see if an option exists in the options manager
|
||||||
* @param {String} option
|
* @param {String} option
|
||||||
* @returns {Boolean} true if the option exists, else false.
|
* @returns {Boolean} true if the option exists, else false.
|
||||||
*/
|
*/
|
||||||
has: function(option) {
|
has: function(option) {
|
||||||
return (this.options[option]);
|
return (this.options[option]);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset the options back to the default values.
|
* Reset the options back to the default values.
|
||||||
*/
|
*/
|
||||||
reset: function() {
|
reset: function() {
|
||||||
this.changed = {};
|
this.changed = {};
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the value of specified option(s) for the passed in id.
|
* Sets the value of specified option(s) for the passed in id.
|
||||||
* @param {String} option
|
* @param {String} option
|
||||||
* @param {Object} value The value for the option
|
* @param {Object} value The value for the option
|
||||||
*/
|
*/
|
||||||
set: function(option, value) {
|
set: function(option, value) {
|
||||||
if (option === undefined) {
|
if (option === undefined) {
|
||||||
return;
|
return;
|
||||||
} else if (typeof option == 'object') {
|
} else if (typeof option == 'object') {
|
||||||
var options = option;
|
var options = option;
|
||||||
this.options = Ext.apply(this.options, options);
|
this.options = Ext.apply(this.options, options);
|
||||||
for (var option in options) {
|
for (var option in options) {
|
||||||
this.onChange(option, options[option]);
|
this.onChange(option, options[option]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.options[option] = value;
|
this.options[option] = value;
|
||||||
this.onChange(option, value)
|
this.onChange(option, value)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the value for the specified option and id.
|
* Update the value for the specified option and id.
|
||||||
* @param {String/Object} option or options to update
|
* @param {String/Object} option or options to update
|
||||||
* @param {Object} [value];
|
* @param {Object} [value];
|
||||||
*/
|
*/
|
||||||
update: function(option, value) {
|
update: function(option, value) {
|
||||||
if (option === undefined) {
|
if (option === undefined) {
|
||||||
return;
|
return;
|
||||||
} else if (value === undefined) {
|
} else if (value === undefined) {
|
||||||
for (var key in option) {
|
for (var key in option) {
|
||||||
this.update(key, option[key]);
|
this.update(key, option[key]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var defaultValue = this.getDefault(option);
|
var defaultValue = this.getDefault(option);
|
||||||
value = this.convertValueType(defaultValue, value);
|
value = this.convertValueType(defaultValue, value);
|
||||||
|
|
||||||
var oldValue = this.get(option);
|
var oldValue = this.get(option);
|
||||||
if (oldValue == value) return;
|
if (oldValue == value) return;
|
||||||
|
|
||||||
if (defaultValue == value) {
|
if (defaultValue == value) {
|
||||||
if (this.isDirty(option)) delete this.changed[option];
|
if (this.isDirty(option)) delete this.changed[option];
|
||||||
this.fireEvent('changed', option, value, oldValue);
|
this.fireEvent('changed', option, value, oldValue);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.changed[option] = value;
|
this.changed[option] = value;
|
||||||
this.fireEvent('changed', option, value, oldValue);
|
this.fireEvent('changed', option, value, oldValue);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lets the option manager know when a field is blurred so if a value
|
* Lets the option manager know when a field is blurred so if a value
|
||||||
* so value changing operations can continue on that field.
|
* so value changing operations can continue on that field.
|
||||||
*/
|
*/
|
||||||
onFieldBlur: function(field, event) {
|
onFieldBlur: function(field, event) {
|
||||||
if (this.focused == field) {
|
if (this.focused == field) {
|
||||||
this.focused = null;
|
this.focused = null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stops a form fields value from being blocked by the change functions
|
* Stops a form fields value from being blocked by the change functions
|
||||||
* @param {Ext.form.Field} field
|
* @param {Ext.form.Field} field
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
onFieldChange: function(field, event) {
|
onFieldChange: function(field, event) {
|
||||||
if (field.field) field = field.field // fix for spinners
|
if (field.field) field = field.field // fix for spinners
|
||||||
this.update(field._doption, field.getValue());
|
this.update(field._doption, field.getValue());
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lets the option manager know when a field is focused so if a value
|
* Lets the option manager know when a field is focused so if a value
|
||||||
* changing operation is performed it won't change the value of the
|
* changing operation is performed it won't change the value of the
|
||||||
* field.
|
* field.
|
||||||
*/
|
*/
|
||||||
onFieldFocus: function(field, event) {
|
onFieldFocus: function(field, event) {
|
||||||
this.focused = field;
|
this.focused = field;
|
||||||
},
|
},
|
||||||
|
|
||||||
onChange: function(option, newValue, oldValue) {
|
onChange: function(option, newValue, oldValue) {
|
||||||
// If we don't have a bind there's nothing to do.
|
// If we don't have a bind there's nothing to do.
|
||||||
if (Ext.isEmpty(this.binds[option])) return;
|
if (Ext.isEmpty(this.binds[option])) return;
|
||||||
Ext.each(this.binds[option], function(bind) {
|
Ext.each(this.binds[option], function(bind) {
|
||||||
// The field is currently focused so we don't want to
|
// The field is currently focused so we don't want to
|
||||||
// change it.
|
// change it.
|
||||||
if (bind == this.focused) return;
|
if (bind == this.focused) return;
|
||||||
// Set the form field to the new value.
|
// Set the form field to the new value.
|
||||||
bind.setValue(newValue);
|
bind.setValue(newValue);
|
||||||
}, this);
|
}, this);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -36,65 +36,65 @@ Ext.ns('Deluge');
|
|||||||
* @extends Ext.Window
|
* @extends Ext.Window
|
||||||
*/
|
*/
|
||||||
Deluge.OtherLimitWindow = Ext.extend(Ext.Window, {
|
Deluge.OtherLimitWindow = Ext.extend(Ext.Window, {
|
||||||
|
|
||||||
layout: 'fit',
|
layout: 'fit',
|
||||||
width: 210,
|
width: 210,
|
||||||
height: 100,
|
height: 100,
|
||||||
|
|
||||||
closeAction: 'hide',
|
closeAction: 'hide',
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.OtherLimitWindow.superclass.initComponent.call(this);
|
Deluge.OtherLimitWindow.superclass.initComponent.call(this);
|
||||||
this.form = this.add({
|
this.form = this.add({
|
||||||
xtype: 'form',
|
xtype: 'form',
|
||||||
baseCls: 'x-plain',
|
baseCls: 'x-plain',
|
||||||
bodyStyle: 'padding: 5px',
|
bodyStyle: 'padding: 5px',
|
||||||
layout: 'hbox',
|
layout: 'hbox',
|
||||||
layoutConfig: {
|
layoutConfig: {
|
||||||
pack: 'start'
|
pack: 'start'
|
||||||
},
|
},
|
||||||
items: [{
|
items: [{
|
||||||
xtype: 'spinnerfield',
|
xtype: 'spinnerfield',
|
||||||
name: 'limit'
|
name: 'limit'
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
if (this.initialConfig.unit) {
|
if (this.initialConfig.unit) {
|
||||||
this.form.add({
|
this.form.add({
|
||||||
border: false,
|
border: false,
|
||||||
baseCls: 'x-plain',
|
baseCls: 'x-plain',
|
||||||
bodyStyle: 'padding: 5px',
|
bodyStyle: 'padding: 5px',
|
||||||
html: this.initialConfig.unit
|
html: this.initialConfig.unit
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.setSize(180, 100);
|
this.setSize(180, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
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.afterMethod('show', this.doFocusField, this);
|
this.afterMethod('show', this.doFocusField, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
setValue: function(value) {
|
setValue: function(value) {
|
||||||
this.form.getForm().setValues({limit: value});
|
this.form.getForm().setValues({limit: value});
|
||||||
},
|
},
|
||||||
|
|
||||||
onCancelClick: function() {
|
onCancelClick: function() {
|
||||||
this.form.getForm().reset();
|
this.form.getForm().reset();
|
||||||
this.hide();
|
this.hide();
|
||||||
},
|
},
|
||||||
|
|
||||||
onOkClick: function() {
|
onOkClick: function() {
|
||||||
var config = {};
|
var config = {};
|
||||||
config[this.group] = this.form.getForm().getValues().limit;
|
config[this.group] = this.form.getForm().getValues().limit;
|
||||||
deluge.client.core.set_config(config, {
|
deluge.client.core.set_config(config, {
|
||||||
success: function() {
|
success: function() {
|
||||||
deluge.ui.update();
|
deluge.ui.update();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.hide();
|
this.hide();
|
||||||
},
|
},
|
||||||
|
|
||||||
doFocusField: function() {
|
doFocusField: function() {
|
||||||
this.form.getForm().findField('limit').focus(true, 10);
|
this.form.getForm().findField('limit').focus(true, 10);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -37,91 +37,91 @@ Ext.ns('Deluge');
|
|||||||
*/
|
*/
|
||||||
Deluge.Plugin = Ext.extend(Ext.util.Observable, {
|
Deluge.Plugin = Ext.extend(Ext.util.Observable, {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The plugins name
|
* The plugins name
|
||||||
* @property name
|
* @property name
|
||||||
* @type {String}
|
* @type {String}
|
||||||
*/
|
*/
|
||||||
name: null,
|
name: null,
|
||||||
|
|
||||||
constructor: function(config) {
|
constructor: function(config) {
|
||||||
this.isDelugePlugin = true;
|
this.isDelugePlugin = true;
|
||||||
this.addEvents({
|
this.addEvents({
|
||||||
/**
|
/**
|
||||||
* @event enabled
|
* @event enabled
|
||||||
* @param {Plugin} plugin the plugin instance
|
* @param {Plugin} plugin the plugin instance
|
||||||
*/
|
*/
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @event disabled
|
* @event disabled
|
||||||
* @param {Plugin} plugin the plugin instance
|
* @param {Plugin} plugin the plugin instance
|
||||||
*/
|
*/
|
||||||
"disabled": true
|
"disabled": true
|
||||||
});
|
});
|
||||||
Deluge.Plugin.superclass.constructor.call(this, config);
|
Deluge.Plugin.superclass.constructor.call(this, config);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disables the plugin, firing the "{@link #disabled}" event and
|
* Disables the plugin, firing the "{@link #disabled}" event and
|
||||||
* then executing the plugins clean up method onDisabled.
|
* then executing the plugins clean up method onDisabled.
|
||||||
*/
|
*/
|
||||||
disable: function() {
|
disable: function() {
|
||||||
this.fireEvent("disabled", this);
|
this.fireEvent("disabled", this);
|
||||||
if (this.onDisable) this.onDisable();
|
if (this.onDisable) this.onDisable();
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables the plugin, firing the "{@link #enabled}" event and
|
* Enables the plugin, firing the "{@link #enabled}" event and
|
||||||
* then executes the plugins setup method, onEnabled.
|
* then executes the plugins setup method, onEnabled.
|
||||||
*/
|
*/
|
||||||
enable: function() {
|
enable: function() {
|
||||||
this.fireEvent("enable", this);
|
this.fireEvent("enable", this);
|
||||||
if (this.onEnable) this.onEnable();
|
if (this.onEnable) this.onEnable();
|
||||||
},
|
},
|
||||||
|
|
||||||
registerTorrentStatus: function(key, header, options) {
|
registerTorrentStatus: function(key, header, options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
var cc = options.colCfg || {}, sc = options.storeCfg || {};
|
var cc = options.colCfg || {}, sc = options.storeCfg || {};
|
||||||
sc = Ext.apply(sc, {name: key});
|
sc = Ext.apply(sc, {name: key});
|
||||||
deluge.torrents.meta.fields.push(sc);
|
deluge.torrents.meta.fields.push(sc);
|
||||||
deluge.torrents.getStore().reader.onMetaChange(deluge.torrents.meta);
|
deluge.torrents.getStore().reader.onMetaChange(deluge.torrents.meta);
|
||||||
|
|
||||||
cc = Ext.apply(cc, {
|
cc = Ext.apply(cc, {
|
||||||
header: header,
|
header: header,
|
||||||
dataIndex: key
|
dataIndex: key
|
||||||
});
|
});
|
||||||
var cols = deluge.torrents.columns.slice(0);
|
var cols = deluge.torrents.columns.slice(0);
|
||||||
cols.push(cc);
|
cols.push(cc);
|
||||||
deluge.torrents.colModel.setConfig(cols);
|
deluge.torrents.colModel.setConfig(cols);
|
||||||
deluge.torrents.columns = cols;
|
deluge.torrents.columns = cols;
|
||||||
|
|
||||||
Deluge.Keys.Grid.push(key);
|
Deluge.Keys.Grid.push(key);
|
||||||
deluge.torrents.getView().refresh(true);
|
deluge.torrents.getView().refresh(true);
|
||||||
},
|
},
|
||||||
|
|
||||||
deregisterTorrentStatus: function(key) {
|
deregisterTorrentStatus: function(key) {
|
||||||
var fields = [];
|
var fields = [];
|
||||||
Ext.each(deluge.torrents.meta.fields, function(field) {
|
Ext.each(deluge.torrents.meta.fields, function(field) {
|
||||||
if (field.name != key) fields.push(field);
|
if (field.name != key) fields.push(field);
|
||||||
});
|
});
|
||||||
deluge.torrents.meta.fields = fields;
|
deluge.torrents.meta.fields = fields;
|
||||||
deluge.torrents.getStore().reader.onMetaChange(deluge.torrents.meta);
|
deluge.torrents.getStore().reader.onMetaChange(deluge.torrents.meta);
|
||||||
|
|
||||||
var cols = [];
|
var cols = [];
|
||||||
Ext.each(deluge.torrents.columns, function(col) {
|
Ext.each(deluge.torrents.columns, function(col) {
|
||||||
if (col.dataIndex != key) cols.push(col);
|
if (col.dataIndex != key) cols.push(col);
|
||||||
});
|
});
|
||||||
deluge.torrents.colModel.setConfig(cols);
|
deluge.torrents.colModel.setConfig(cols);
|
||||||
deluge.torrents.columns = cols;
|
deluge.torrents.columns = cols;
|
||||||
|
|
||||||
var keys = [];
|
var keys = [];
|
||||||
Ext.each(Deluge.Keys.Grid, function(k) {
|
Ext.each(Deluge.Keys.Grid, function(k) {
|
||||||
if (k == key) keys.push(k);
|
if (k == key) keys.push(k);
|
||||||
});
|
});
|
||||||
Deluge.Keys.Grid = keys;
|
Deluge.Keys.Grid = keys;
|
||||||
deluge.torrents.getView().refresh(true);
|
deluge.torrents.getView().refresh(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Ext.ns('Deluge.plugins');
|
Ext.ns('Deluge.plugins');
|
||||||
|
|||||||
@ -39,7 +39,7 @@ Deluge.RemoveWindow = Ext.extend(Ext.Window, {
|
|||||||
title: _('Remove Torrent'),
|
title: _('Remove Torrent'),
|
||||||
layout: 'fit',
|
layout: 'fit',
|
||||||
width: 350,
|
width: 350,
|
||||||
height: 100,
|
height: 100,
|
||||||
|
|
||||||
buttonAlign: 'right',
|
buttonAlign: 'right',
|
||||||
closeAction: 'hide',
|
closeAction: 'hide',
|
||||||
@ -49,50 +49,50 @@ Deluge.RemoveWindow = Ext.extend(Ext.Window, {
|
|||||||
|
|
||||||
bodyStyle: 'padding: 5px; padding-left: 10px;',
|
bodyStyle: 'padding: 5px; padding-left: 10px;',
|
||||||
html: 'Are you sure you wish to remove the torrent (s)?',
|
html: 'Are you sure you wish to remove the torrent (s)?',
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.RemoveWindow.superclass.initComponent.call(this);
|
Deluge.RemoveWindow.superclass.initComponent.call(this);
|
||||||
this.addButton(_('Cancel'), this.onCancel, this);
|
this.addButton(_('Cancel'), this.onCancel, this);
|
||||||
this.addButton(_('Remove With Data'), this.onRemoveData, this);
|
this.addButton(_('Remove With Data'), this.onRemoveData, this);
|
||||||
this.addButton(_('Remove Torrent'), this.onRemove, this);
|
this.addButton(_('Remove Torrent'), this.onRemove, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
remove: function(removeData) {
|
remove: function(removeData) {
|
||||||
Ext.each(this.torrentIds, function(torrentId) {
|
Ext.each(this.torrentIds, function(torrentId) {
|
||||||
deluge.client.core.remove_torrent(torrentId, removeData, {
|
deluge.client.core.remove_torrent(torrentId, removeData, {
|
||||||
success: function() {
|
success: function() {
|
||||||
this.onRemoved(torrentId);
|
this.onRemoved(torrentId);
|
||||||
},
|
},
|
||||||
scope: this,
|
scope: this,
|
||||||
torrentId: torrentId
|
torrentId: torrentId
|
||||||
});
|
});
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
show: function(ids) {
|
show: function(ids) {
|
||||||
Deluge.RemoveWindow.superclass.show.call(this);
|
Deluge.RemoveWindow.superclass.show.call(this);
|
||||||
this.torrentIds = ids;
|
this.torrentIds = ids;
|
||||||
},
|
},
|
||||||
|
|
||||||
onCancel: function() {
|
onCancel: function() {
|
||||||
this.hide();
|
this.hide();
|
||||||
this.torrentIds = null;
|
this.torrentIds = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
onRemove: function() {
|
onRemove: function() {
|
||||||
this.remove(false);
|
this.remove(false);
|
||||||
},
|
},
|
||||||
|
|
||||||
onRemoveData: function() {
|
onRemoveData: function() {
|
||||||
this.remove(true);
|
this.remove(true);
|
||||||
},
|
},
|
||||||
|
|
||||||
onRemoved: function(torrentId) {
|
onRemoved: function(torrentId) {
|
||||||
deluge.events.fire('torrentRemoved', torrentId);
|
deluge.events.fire('torrentRemoved', torrentId);
|
||||||
this.hide();
|
this.hide();
|
||||||
deluge.ui.update();
|
deluge.ui.update();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
deluge.removeWindow = new Deluge.RemoveWindow();
|
deluge.removeWindow = new Deluge.RemoveWindow();
|
||||||
|
|||||||
@ -41,122 +41,122 @@
|
|||||||
*/
|
*/
|
||||||
Deluge.Sidebar = Ext.extend(Ext.Panel, {
|
Deluge.Sidebar = Ext.extend(Ext.Panel, {
|
||||||
|
|
||||||
// private
|
// private
|
||||||
panels: {},
|
panels: {},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
selected: null,
|
selected: null,
|
||||||
|
|
||||||
constructor: function(config) {
|
constructor: function(config) {
|
||||||
config = Ext.apply({
|
config = Ext.apply({
|
||||||
id: 'sidebar',
|
id: 'sidebar',
|
||||||
region: 'west',
|
region: 'west',
|
||||||
cls: 'deluge-sidebar',
|
cls: 'deluge-sidebar',
|
||||||
title: _('Filters'),
|
title: _('Filters'),
|
||||||
layout: 'accordion',
|
layout: 'accordion',
|
||||||
split: true,
|
split: true,
|
||||||
width: 200,
|
width: 200,
|
||||||
minSize: 175,
|
minSize: 175,
|
||||||
collapsible: true,
|
collapsible: true,
|
||||||
margins: '5 0 0 5',
|
margins: '5 0 0 5',
|
||||||
cmargins: '5 0 0 5'
|
cmargins: '5 0 0 5'
|
||||||
}, config);
|
}, config);
|
||||||
Deluge.Sidebar.superclass.constructor.call(this, config);
|
Deluge.Sidebar.superclass.constructor.call(this, config);
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.Sidebar.superclass.initComponent.call(this);
|
Deluge.Sidebar.superclass.initComponent.call(this);
|
||||||
deluge.events.on("disconnect", this.onDisconnect, this);
|
deluge.events.on("disconnect", this.onDisconnect, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
createFilter: function(filter, states) {
|
createFilter: function(filter, states) {
|
||||||
var panel = new Deluge.FilterPanel({
|
var panel = new Deluge.FilterPanel({
|
||||||
filter: filter
|
filter: filter
|
||||||
});
|
});
|
||||||
panel.on('selectionchange', function(view, nodes) {
|
panel.on('selectionchange', function(view, nodes) {
|
||||||
deluge.ui.update();
|
deluge.ui.update();
|
||||||
});
|
});
|
||||||
this.add(panel);
|
this.add(panel);
|
||||||
|
|
||||||
this.doLayout();
|
this.doLayout();
|
||||||
this.panels[filter] = panel;
|
this.panels[filter] = panel;
|
||||||
|
|
||||||
panel.header.on('click', function(header) {
|
panel.header.on('click', function(header) {
|
||||||
if (!deluge.config.sidebar_multiple_filters) {
|
if (!deluge.config.sidebar_multiple_filters) {
|
||||||
deluge.ui.update();
|
deluge.ui.update();
|
||||||
}
|
}
|
||||||
if (!panel.list.getSelectionCount()) {
|
if (!panel.list.getSelectionCount()) {
|
||||||
panel.list.select(0);
|
panel.list.select(0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.fireEvent('filtercreate', this, panel);
|
this.fireEvent('filtercreate', this, panel);
|
||||||
|
|
||||||
panel.updateStates(states);
|
panel.updateStates(states);
|
||||||
this.fireEvent('afterfiltercreate', this, panel);
|
this.fireEvent('afterfiltercreate', this, panel);
|
||||||
},
|
},
|
||||||
|
|
||||||
getFilter: function(filter) {
|
getFilter: function(filter) {
|
||||||
return this.panels[filter];
|
return this.panels[filter];
|
||||||
},
|
},
|
||||||
|
|
||||||
getFilterStates: function() {
|
getFilterStates: function() {
|
||||||
var states = {}
|
var states = {}
|
||||||
|
|
||||||
if (deluge.config.sidebar_multiple_filters) {
|
if (deluge.config.sidebar_multiple_filters) {
|
||||||
// Grab the filters from each of the filter panels
|
// Grab the filters from each of the filter panels
|
||||||
this.items.each(function(panel) {
|
this.items.each(function(panel) {
|
||||||
var state = panel.getState();
|
var state = panel.getState();
|
||||||
if (state == null) return;
|
if (state == null) return;
|
||||||
states[panel.filterType] = state;
|
states[panel.filterType] = state;
|
||||||
}, this);
|
}, this);
|
||||||
} else {
|
} else {
|
||||||
var panel = this.getLayout().activeItem;
|
var panel = this.getLayout().activeItem;
|
||||||
if (panel) {
|
if (panel) {
|
||||||
var state = panel.getState();
|
var state = panel.getState();
|
||||||
if (!state == null) return;
|
if (!state == null) return;
|
||||||
states[panel.filterType] = state;
|
states[panel.filterType] = state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return states;
|
return states;
|
||||||
},
|
},
|
||||||
|
|
||||||
hasFilter: function(filter) {
|
hasFilter: function(filter) {
|
||||||
return (this.panels[filter]) ? true : false;
|
return (this.panels[filter]) ? true : false;
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onDisconnect: function() {
|
onDisconnect: function() {
|
||||||
for (var filter in this.panels) {
|
for (var filter in this.panels) {
|
||||||
this.remove(this.panels[filter]);
|
this.remove(this.panels[filter]);
|
||||||
}
|
}
|
||||||
this.panels = {};
|
this.panels = {};
|
||||||
this.selected = null;
|
this.selected = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
onFilterSelect: function(selModel, rowIndex, record) {
|
onFilterSelect: function(selModel, rowIndex, record) {
|
||||||
deluge.ui.update();
|
deluge.ui.update();
|
||||||
},
|
},
|
||||||
|
|
||||||
update: function(filters) {
|
update: function(filters) {
|
||||||
for (var filter in filters) {
|
for (var filter in filters) {
|
||||||
var states = filters[filter];
|
var states = filters[filter];
|
||||||
if (Ext.getKeys(this.panels).indexOf(filter) > -1) {
|
if (Ext.getKeys(this.panels).indexOf(filter) > -1) {
|
||||||
this.panels[filter].updateStates(states);
|
this.panels[filter].updateStates(states);
|
||||||
} else {
|
} else {
|
||||||
this.createFilter(filter, states);
|
this.createFilter(filter, states);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Perform a cleanup of fitlers that aren't enabled any more
|
// Perform a cleanup of fitlers that aren't enabled any more
|
||||||
Ext.each(Ext.keys(this.panels), function(filter) {
|
Ext.each(Ext.keys(this.panels), function(filter) {
|
||||||
if (Ext.keys(filters).indexOf(filter) == -1) {
|
if (Ext.keys(filters).indexOf(filter) == -1) {
|
||||||
// We need to remove the panel
|
// We need to remove the panel
|
||||||
this.remove(this.panels[filter]);
|
this.remove(this.panels[filter]);
|
||||||
this.doLayout();
|
this.doLayout();
|
||||||
delete this.panels[filter];
|
delete this.panels[filter];
|
||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -32,284 +32,284 @@
|
|||||||
Ext.namespace('Deluge');
|
Ext.namespace('Deluge');
|
||||||
|
|
||||||
Deluge.Statusbar = Ext.extend(Ext.ux.StatusBar, {
|
Deluge.Statusbar = Ext.extend(Ext.ux.StatusBar, {
|
||||||
constructor: function(config) {
|
constructor: function(config) {
|
||||||
config = Ext.apply({
|
config = Ext.apply({
|
||||||
id: 'deluge-statusbar',
|
id: 'deluge-statusbar',
|
||||||
defaultIconCls: 'x-deluge-statusbar x-not-connected',
|
defaultIconCls: 'x-deluge-statusbar x-not-connected',
|
||||||
defaultText: _('Not Connected')
|
defaultText: _('Not Connected')
|
||||||
}, config);
|
}, config);
|
||||||
Deluge.Statusbar.superclass.constructor.call(this, config);
|
Deluge.Statusbar.superclass.constructor.call(this, config);
|
||||||
},
|
},
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.Statusbar.superclass.initComponent.call(this);
|
Deluge.Statusbar.superclass.initComponent.call(this);
|
||||||
|
|
||||||
deluge.events.on('connect', this.onConnect, this);
|
deluge.events.on('connect', this.onConnect, this);
|
||||||
deluge.events.on('disconnect', this.onDisconnect, this);
|
deluge.events.on('disconnect', this.onDisconnect, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
createButtons: function() {
|
createButtons: function() {
|
||||||
this.buttons = this.add({
|
this.buttons = this.add({
|
||||||
id: 'statusbar-connections',
|
id: 'statusbar-connections',
|
||||||
text: ' ',
|
text: ' ',
|
||||||
cls: 'x-btn-text-icon',
|
cls: 'x-btn-text-icon',
|
||||||
iconCls: 'x-deluge-connections',
|
iconCls: 'x-deluge-connections',
|
||||||
tooltip: _('Connections'),
|
tooltip: _('Connections'),
|
||||||
menu: new Deluge.StatusbarMenu({
|
menu: new Deluge.StatusbarMenu({
|
||||||
items: [{
|
items: [{
|
||||||
text: '50',
|
text: '50',
|
||||||
value: '50',
|
value: '50',
|
||||||
group: 'max_connections_global',
|
group: 'max_connections_global',
|
||||||
checked: false
|
checked: false
|
||||||
},{
|
},{
|
||||||
text: '100',
|
text: '100',
|
||||||
value: '100',
|
value: '100',
|
||||||
group: 'max_connections_global',
|
group: 'max_connections_global',
|
||||||
checked: false
|
checked: false
|
||||||
},{
|
},{
|
||||||
text: '200',
|
text: '200',
|
||||||
value: '200',
|
value: '200',
|
||||||
group: 'max_connections_global',
|
group: 'max_connections_global',
|
||||||
checked: false
|
checked: false
|
||||||
},{
|
},{
|
||||||
text: '300',
|
text: '300',
|
||||||
value: '300',
|
value: '300',
|
||||||
group: 'max_connections_global',
|
group: 'max_connections_global',
|
||||||
checked: false
|
checked: false
|
||||||
},{
|
},{
|
||||||
text: '500',
|
text: '500',
|
||||||
value: '500',
|
value: '500',
|
||||||
group: 'max_connections_global',
|
group: 'max_connections_global',
|
||||||
checked: false
|
checked: false
|
||||||
},{
|
},{
|
||||||
text: _('Unlimited'),
|
text: _('Unlimited'),
|
||||||
value: '-1',
|
value: '-1',
|
||||||
group: 'max_connections_global',
|
group: 'max_connections_global',
|
||||||
checked: false
|
checked: false
|
||||||
},'-',{
|
},'-',{
|
||||||
text: _('Other'),
|
text: _('Other'),
|
||||||
value: 'other',
|
value: 'other',
|
||||||
group: 'max_connections_global',
|
group: 'max_connections_global',
|
||||||
checked: false
|
checked: false
|
||||||
}],
|
}],
|
||||||
otherWin: {
|
otherWin: {
|
||||||
title: _('Set Maximum Connections')
|
title: _('Set Maximum Connections')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}, '-', {
|
}, '-', {
|
||||||
id: 'statusbar-downspeed',
|
id: 'statusbar-downspeed',
|
||||||
text: ' ',
|
text: ' ',
|
||||||
cls: 'x-btn-text-icon',
|
cls: 'x-btn-text-icon',
|
||||||
iconCls: 'x-deluge-downloading',
|
iconCls: 'x-deluge-downloading',
|
||||||
tooltip: _('Download Speed'),
|
tooltip: _('Download Speed'),
|
||||||
menu: new Deluge.StatusbarMenu({
|
menu: new Deluge.StatusbarMenu({
|
||||||
items: [{
|
items: [{
|
||||||
value: '5',
|
value: '5',
|
||||||
text: '5 KiB/s',
|
text: '5 KiB/s',
|
||||||
group: 'max_download_speed',
|
group: 'max_download_speed',
|
||||||
checked: false
|
checked: false
|
||||||
},{
|
},{
|
||||||
value: '10',
|
value: '10',
|
||||||
text: '10 KiB/s',
|
text: '10 KiB/s',
|
||||||
group: 'max_download_speed',
|
group: 'max_download_speed',
|
||||||
checked: false
|
checked: false
|
||||||
},{
|
},{
|
||||||
value: '30',
|
value: '30',
|
||||||
text: '30 KiB/s',
|
text: '30 KiB/s',
|
||||||
group: 'max_download_speed',
|
group: 'max_download_speed',
|
||||||
checked: false
|
checked: false
|
||||||
},{
|
},{
|
||||||
value: '80',
|
value: '80',
|
||||||
text: '80 KiB/s',
|
text: '80 KiB/s',
|
||||||
group: 'max_download_speed',
|
group: 'max_download_speed',
|
||||||
checked: false
|
checked: false
|
||||||
},{
|
},{
|
||||||
value: '300',
|
value: '300',
|
||||||
text: '300 KiB/s',
|
text: '300 KiB/s',
|
||||||
group: 'max_download_speed',
|
group: 'max_download_speed',
|
||||||
checked: false
|
checked: false
|
||||||
},{
|
},{
|
||||||
value: '-1',
|
value: '-1',
|
||||||
text: _('Unlimited'),
|
text: _('Unlimited'),
|
||||||
group: 'max_download_speed',
|
group: 'max_download_speed',
|
||||||
checked: false
|
checked: false
|
||||||
},'-',{
|
},'-',{
|
||||||
value: 'other',
|
value: 'other',
|
||||||
text: _('Other'),
|
text: _('Other'),
|
||||||
group: 'max_download_speed',
|
group: 'max_download_speed',
|
||||||
checked: false
|
checked: false
|
||||||
}],
|
}],
|
||||||
otherWin: {
|
otherWin: {
|
||||||
title: _('Set Maximum Download Speed'),
|
title: _('Set Maximum Download Speed'),
|
||||||
unit: _('Kib/s')
|
unit: _('Kib/s')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}, '-', {
|
}, '-', {
|
||||||
id: 'statusbar-upspeed',
|
id: 'statusbar-upspeed',
|
||||||
text: ' ',
|
text: ' ',
|
||||||
cls: 'x-btn-text-icon',
|
cls: 'x-btn-text-icon',
|
||||||
iconCls: 'x-deluge-seeding',
|
iconCls: 'x-deluge-seeding',
|
||||||
tooltip: _('Upload Speed'),
|
tooltip: _('Upload Speed'),
|
||||||
menu: new Deluge.StatusbarMenu({
|
menu: new Deluge.StatusbarMenu({
|
||||||
items: [{
|
items: [{
|
||||||
value: '5',
|
value: '5',
|
||||||
text: '5 KiB/s',
|
text: '5 KiB/s',
|
||||||
group: 'max_upload_speed',
|
group: 'max_upload_speed',
|
||||||
checked: false
|
checked: false
|
||||||
},{
|
},{
|
||||||
value: '10',
|
value: '10',
|
||||||
text: '10 KiB/s',
|
text: '10 KiB/s',
|
||||||
group: 'max_upload_speed',
|
group: 'max_upload_speed',
|
||||||
checked: false
|
checked: false
|
||||||
},{
|
},{
|
||||||
value: '30',
|
value: '30',
|
||||||
text: '30 KiB/s',
|
text: '30 KiB/s',
|
||||||
group: 'max_upload_speed',
|
group: 'max_upload_speed',
|
||||||
checked: false
|
checked: false
|
||||||
},{
|
},{
|
||||||
value: '80',
|
value: '80',
|
||||||
text: '80 KiB/s',
|
text: '80 KiB/s',
|
||||||
group: 'max_upload_speed',
|
group: 'max_upload_speed',
|
||||||
checked: false
|
checked: false
|
||||||
},{
|
},{
|
||||||
value: '300',
|
value: '300',
|
||||||
text: '300 KiB/s',
|
text: '300 KiB/s',
|
||||||
group: 'max_upload_speed',
|
group: 'max_upload_speed',
|
||||||
checked: false
|
checked: false
|
||||||
},{
|
},{
|
||||||
value: '-1',
|
value: '-1',
|
||||||
text: _('Unlimited'),
|
text: _('Unlimited'),
|
||||||
group: 'max_upload_speed',
|
group: 'max_upload_speed',
|
||||||
checked: false
|
checked: false
|
||||||
},'-',{
|
},'-',{
|
||||||
value: 'other',
|
value: 'other',
|
||||||
text: _('Other'),
|
text: _('Other'),
|
||||||
group: 'max_upload_speed',
|
group: 'max_upload_speed',
|
||||||
checked: false
|
checked: false
|
||||||
}],
|
}],
|
||||||
otherWin: {
|
otherWin: {
|
||||||
title: _('Set Maximum Upload Speed'),
|
title: _('Set Maximum Upload Speed'),
|
||||||
unit: _('Kib/s')
|
unit: _('Kib/s')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}, '-', {
|
}, '-', {
|
||||||
id: 'statusbar-traffic',
|
id: 'statusbar-traffic',
|
||||||
text: ' ',
|
text: ' ',
|
||||||
cls: 'x-btn-text-icon',
|
cls: 'x-btn-text-icon',
|
||||||
iconCls: 'x-deluge-traffic',
|
iconCls: 'x-deluge-traffic',
|
||||||
tooltip: _('Protocol Traffic Download/Upload'),
|
tooltip: _('Protocol Traffic Download/Upload'),
|
||||||
handler: function() {
|
handler: function() {
|
||||||
deluge.preferences.show();
|
deluge.preferences.show();
|
||||||
deluge.preferences.selectPage('Network');
|
deluge.preferences.selectPage('Network');
|
||||||
}
|
}
|
||||||
}, '-', {
|
}, '-', {
|
||||||
id: 'statusbar-dht',
|
id: 'statusbar-dht',
|
||||||
text: ' ',
|
text: ' ',
|
||||||
cls: 'x-btn-text-icon',
|
cls: 'x-btn-text-icon',
|
||||||
iconCls: 'x-deluge-dht',
|
iconCls: 'x-deluge-dht',
|
||||||
tooltip: _('DHT Nodes')
|
tooltip: _('DHT Nodes')
|
||||||
}, '-', {
|
}, '-', {
|
||||||
id: 'statusbar-freespace',
|
id: 'statusbar-freespace',
|
||||||
text: ' ',
|
text: ' ',
|
||||||
cls: 'x-btn-text-icon',
|
cls: 'x-btn-text-icon',
|
||||||
iconCls: 'x-deluge-freespace',
|
iconCls: 'x-deluge-freespace',
|
||||||
tooltip: _('Freespace in download location'),
|
tooltip: _('Freespace in download location'),
|
||||||
handler: function() {
|
handler: function() {
|
||||||
deluge.preferences.show();
|
deluge.preferences.show();
|
||||||
deluge.preferences.selectPage('Downloads');
|
deluge.preferences.selectPage('Downloads');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.created = true;
|
this.created = true;
|
||||||
},
|
},
|
||||||
|
|
||||||
onConnect: function() {
|
onConnect: function() {
|
||||||
this.setStatus({
|
this.setStatus({
|
||||||
iconCls: 'x-connected',
|
iconCls: 'x-connected',
|
||||||
text: ''
|
text: ''
|
||||||
});
|
});
|
||||||
if (!this.created) {
|
if (!this.created) {
|
||||||
this.createButtons();
|
this.createButtons();
|
||||||
} else {
|
} else {
|
||||||
Ext.each(this.buttons, function(item) {
|
Ext.each(this.buttons, function(item) {
|
||||||
item.show();
|
item.show();
|
||||||
item.enable();
|
item.enable();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.doLayout();
|
this.doLayout();
|
||||||
},
|
},
|
||||||
|
|
||||||
onDisconnect: function() {
|
onDisconnect: function() {
|
||||||
this.clearStatus({useDefaults:true});
|
this.clearStatus({useDefaults:true});
|
||||||
Ext.each(this.buttons, function(item) {
|
Ext.each(this.buttons, function(item) {
|
||||||
item.hide();
|
item.hide();
|
||||||
item.disable();
|
item.disable();
|
||||||
});
|
});
|
||||||
this.doLayout();
|
this.doLayout();
|
||||||
},
|
},
|
||||||
|
|
||||||
update: function(stats) {
|
update: function(stats) {
|
||||||
if (!stats) return;
|
if (!stats) return;
|
||||||
|
|
||||||
function addSpeed(val) {return val + ' KiB/s'}
|
function addSpeed(val) {return val + ' KiB/s'}
|
||||||
|
|
||||||
var updateStat = function(name, config) {
|
var updateStat = function(name, config) {
|
||||||
var item = this.items.get('statusbar-' + name);
|
var item = this.items.get('statusbar-' + name);
|
||||||
if (config.limit.value > 0) {
|
if (config.limit.value > 0) {
|
||||||
var value = (config.value.formatter) ? config.value.formatter(config.value.value, true) : config.value.value;
|
var value = (config.value.formatter) ? config.value.formatter(config.value.value, true) : config.value.value;
|
||||||
var limit = (config.limit.formatter) ? config.limit.formatter(config.limit.value, true) : config.limit.value;
|
var limit = (config.limit.formatter) ? config.limit.formatter(config.limit.value, true) : config.limit.value;
|
||||||
var str = String.format(config.format, value, limit);
|
var str = String.format(config.format, value, limit);
|
||||||
} else {
|
} else {
|
||||||
var str = (config.value.formatter) ? config.value.formatter(config.value.value, true) : config.value.value;
|
var str = (config.value.formatter) ? config.value.formatter(config.value.value, true) : config.value.value;
|
||||||
}
|
}
|
||||||
item.setText(str);
|
item.setText(str);
|
||||||
|
|
||||||
if (!item.menu) return;
|
if (!item.menu) return;
|
||||||
item.menu.setValue(config.limit.value);
|
item.menu.setValue(config.limit.value);
|
||||||
}.createDelegate(this);
|
}.createDelegate(this);
|
||||||
|
|
||||||
updateStat('connections', {
|
updateStat('connections', {
|
||||||
value: {value: stats.num_connections},
|
value: {value: stats.num_connections},
|
||||||
limit: {value: stats.max_num_connections},
|
limit: {value: stats.max_num_connections},
|
||||||
format: '{0} ({1})'
|
format: '{0} ({1})'
|
||||||
});
|
});
|
||||||
|
|
||||||
updateStat('downspeed', {
|
updateStat('downspeed', {
|
||||||
value: {
|
value: {
|
||||||
value: stats.download_rate,
|
value: stats.download_rate,
|
||||||
formatter: Deluge.Formatters.speed
|
formatter: Deluge.Formatters.speed
|
||||||
},
|
},
|
||||||
limit: {
|
limit: {
|
||||||
value: stats.max_download,
|
value: stats.max_download,
|
||||||
formatter: addSpeed
|
formatter: addSpeed
|
||||||
},
|
},
|
||||||
format: '{0} ({1})'
|
format: '{0} ({1})'
|
||||||
});
|
});
|
||||||
|
|
||||||
updateStat('upspeed', {
|
updateStat('upspeed', {
|
||||||
value: {
|
value: {
|
||||||
value: stats.upload_rate,
|
value: stats.upload_rate,
|
||||||
formatter: Deluge.Formatters.speed
|
formatter: Deluge.Formatters.speed
|
||||||
},
|
},
|
||||||
limit: {
|
limit: {
|
||||||
value: stats.max_upload,
|
value: stats.max_upload,
|
||||||
formatter: addSpeed
|
formatter: addSpeed
|
||||||
},
|
},
|
||||||
format: '{0} ({1})'
|
format: '{0} ({1})'
|
||||||
});
|
});
|
||||||
|
|
||||||
updateStat('traffic', {
|
updateStat('traffic', {
|
||||||
value: {
|
value: {
|
||||||
value: stats.download_protocol_rate,
|
value: stats.download_protocol_rate,
|
||||||
formatter: Deluge.Formatters.speed
|
formatter: Deluge.Formatters.speed
|
||||||
},
|
},
|
||||||
limit: {
|
limit: {
|
||||||
value: stats.upload_protocol_rate,
|
value: stats.upload_protocol_rate,
|
||||||
formatter: Deluge.Formatters.speed
|
formatter: Deluge.Formatters.speed
|
||||||
},
|
},
|
||||||
format: '{0}/{1}'
|
format: '{0}/{1}'
|
||||||
});
|
});
|
||||||
|
|
||||||
this.items.get('statusbar-dht').setText(stats.dht_nodes);
|
this.items.get('statusbar-dht').setText(stats.dht_nodes);
|
||||||
this.items.get('statusbar-freespace').setText(fsize(stats.free_space));
|
this.items.get('statusbar-freespace').setText(fsize(stats.free_space));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -37,20 +37,20 @@ Ext.ns('Deluge');
|
|||||||
* @extends Ext.menu.Menu
|
* @extends Ext.menu.Menu
|
||||||
*/
|
*/
|
||||||
Deluge.StatusbarMenu = Ext.extend(Ext.menu.Menu, {
|
Deluge.StatusbarMenu = Ext.extend(Ext.menu.Menu, {
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.StatusbarMenu.superclass.initComponent.call(this);
|
Deluge.StatusbarMenu.superclass.initComponent.call(this);
|
||||||
this.otherWin = new Deluge.OtherLimitWindow(this.initialConfig.otherWin || {});
|
this.otherWin = new Deluge.OtherLimitWindow(this.initialConfig.otherWin || {});
|
||||||
|
|
||||||
this.items.each(function(item) {
|
this.items.each(function(item) {
|
||||||
if (item.getXType() != 'menucheckitem') return;
|
if (item.getXType() != 'menucheckitem') return;
|
||||||
if (item.value == 'other') {
|
if (item.value == 'other') {
|
||||||
item.on('click', this.onOtherClicked, this);
|
item.on('click', this.onOtherClicked, this);
|
||||||
} else {
|
} else {
|
||||||
item.on('checkchange', this.onLimitChanged, this);
|
item.on('checkchange', this.onLimitChanged, this);
|
||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
setValue: function(value) {
|
setValue: function(value) {
|
||||||
var beenSet = false;
|
var beenSet = false;
|
||||||
@ -81,20 +81,20 @@ Deluge.StatusbarMenu = Ext.extend(Ext.menu.Menu, {
|
|||||||
other.resumeEvents();
|
other.resumeEvents();
|
||||||
},
|
},
|
||||||
|
|
||||||
onLimitChanged: function(item, checked) {
|
onLimitChanged: function(item, checked) {
|
||||||
if (!checked || item.value == 'other') return; // we don't care about unchecks or other
|
if (!checked || item.value == 'other') return; // we don't care about unchecks or other
|
||||||
var config = {}
|
var config = {}
|
||||||
config[item.group] = item.value
|
config[item.group] = item.value
|
||||||
deluge.client.core.set_config(config, {
|
deluge.client.core.set_config(config, {
|
||||||
success: function() {
|
success: function() {
|
||||||
deluge.ui.update();
|
deluge.ui.update();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onOtherClicked: function(item, e) {
|
onOtherClicked: function(item, e) {
|
||||||
this.otherWin.group = item.group;
|
this.otherWin.group = item.group;
|
||||||
this.otherWin.setValue(this.value);
|
this.otherWin.setValue(this.value);
|
||||||
this.otherWin.show();
|
this.otherWin.show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -36,157 +36,157 @@
|
|||||||
* @extends Ext.Toolbar
|
* @extends Ext.Toolbar
|
||||||
*/
|
*/
|
||||||
Deluge.Toolbar = Ext.extend(Ext.Toolbar, {
|
Deluge.Toolbar = Ext.extend(Ext.Toolbar, {
|
||||||
constructor: function(config) {
|
constructor: function(config) {
|
||||||
config = Ext.apply({
|
config = Ext.apply({
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
id: 'create',
|
id: 'create',
|
||||||
disabled: true,
|
disabled: true,
|
||||||
text: _('Create'),
|
text: _('Create'),
|
||||||
iconCls: 'icon-create',
|
iconCls: 'icon-create',
|
||||||
handler: this.onTorrentAction
|
handler: this.onTorrentAction
|
||||||
},{
|
},{
|
||||||
id: 'add',
|
id: 'add',
|
||||||
disabled: true,
|
disabled: true,
|
||||||
text: _('Add'),
|
text: _('Add'),
|
||||||
iconCls: 'icon-add',
|
iconCls: 'icon-add',
|
||||||
handler: this.onTorrentAdd
|
handler: this.onTorrentAdd
|
||||||
},{
|
},{
|
||||||
id: 'remove',
|
id: 'remove',
|
||||||
disabled: true,
|
disabled: true,
|
||||||
text: _('Remove'),
|
text: _('Remove'),
|
||||||
iconCls: 'icon-remove',
|
iconCls: 'icon-remove',
|
||||||
handler: this.onTorrentAction
|
handler: this.onTorrentAction
|
||||||
},'|',{
|
},'|',{
|
||||||
id: 'pause',
|
id: 'pause',
|
||||||
disabled: true,
|
disabled: true,
|
||||||
text: _('Pause'),
|
text: _('Pause'),
|
||||||
iconCls: 'icon-pause',
|
iconCls: 'icon-pause',
|
||||||
handler: this.onTorrentAction
|
handler: this.onTorrentAction
|
||||||
},{
|
},{
|
||||||
id: 'resume',
|
id: 'resume',
|
||||||
disabled: true,
|
disabled: true,
|
||||||
text: _('Resume'),
|
text: _('Resume'),
|
||||||
iconCls: 'icon-resume',
|
iconCls: 'icon-resume',
|
||||||
handler: this.onTorrentAction
|
handler: this.onTorrentAction
|
||||||
},'|',{
|
},'|',{
|
||||||
id: 'up',
|
id: 'up',
|
||||||
cls: 'x-btn-text-icon',
|
cls: 'x-btn-text-icon',
|
||||||
disabled: true,
|
disabled: true,
|
||||||
text: _('Up'),
|
text: _('Up'),
|
||||||
iconCls: 'icon-up',
|
iconCls: 'icon-up',
|
||||||
handler: this.onTorrentAction
|
handler: this.onTorrentAction
|
||||||
},{
|
},{
|
||||||
id: 'down',
|
id: 'down',
|
||||||
disabled: true,
|
disabled: true,
|
||||||
text: _('Down'),
|
text: _('Down'),
|
||||||
iconCls: 'icon-down',
|
iconCls: 'icon-down',
|
||||||
handler: this.onTorrentAction
|
handler: this.onTorrentAction
|
||||||
},'|',{
|
},'|',{
|
||||||
id: 'preferences',
|
id: 'preferences',
|
||||||
text: _('Preferences'),
|
text: _('Preferences'),
|
||||||
iconCls: 'x-deluge-preferences',
|
iconCls: 'x-deluge-preferences',
|
||||||
handler: this.onPreferencesClick,
|
handler: this.onPreferencesClick,
|
||||||
scope: this
|
scope: this
|
||||||
},{
|
},{
|
||||||
id: 'connectionman',
|
id: 'connectionman',
|
||||||
text: _('Connection Manager'),
|
text: _('Connection Manager'),
|
||||||
iconCls: 'x-deluge-connection-manager',
|
iconCls: 'x-deluge-connection-manager',
|
||||||
handler: this.onConnectionManagerClick,
|
handler: this.onConnectionManagerClick,
|
||||||
scope: this
|
scope: this
|
||||||
},'->',{
|
},'->',{
|
||||||
id: 'help',
|
id: 'help',
|
||||||
iconCls: 'icon-help',
|
iconCls: 'icon-help',
|
||||||
text: _('Help'),
|
text: _('Help'),
|
||||||
handler: this.onHelpClick,
|
handler: this.onHelpClick,
|
||||||
scope: this
|
scope: this
|
||||||
},{
|
},{
|
||||||
id: 'logout',
|
id: 'logout',
|
||||||
iconCls: 'icon-logout',
|
iconCls: 'icon-logout',
|
||||||
disabled: true,
|
disabled: true,
|
||||||
text: _('Logout'),
|
text: _('Logout'),
|
||||||
handler: this.onLogout,
|
handler: this.onLogout,
|
||||||
scope: this
|
scope: this
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}, config);
|
}, config);
|
||||||
Deluge.Toolbar.superclass.constructor.call(this, config);
|
Deluge.Toolbar.superclass.constructor.call(this, config);
|
||||||
},
|
},
|
||||||
|
|
||||||
connectedButtons: [
|
connectedButtons: [
|
||||||
'add', 'remove', 'pause', 'resume', 'up', 'down'
|
'add', 'remove', 'pause', 'resume', 'up', 'down'
|
||||||
],
|
],
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.Toolbar.superclass.initComponent.call(this);
|
Deluge.Toolbar.superclass.initComponent.call(this);
|
||||||
deluge.events.on('connect', this.onConnect, this);
|
deluge.events.on('connect', this.onConnect, this);
|
||||||
deluge.events.on('login', this.onLogin, this);
|
deluge.events.on('login', this.onLogin, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
onConnect: function() {
|
onConnect: function() {
|
||||||
Ext.each(this.connectedButtons, function(buttonId) {
|
Ext.each(this.connectedButtons, function(buttonId) {
|
||||||
this.items.get(buttonId).enable();
|
this.items.get(buttonId).enable();
|
||||||
}, this);
|
}, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
onDisconnect: function() {
|
onDisconnect: function() {
|
||||||
Ext.each(this.connectedButtons, function(buttonId) {
|
Ext.each(this.connectedButtons, function(buttonId) {
|
||||||
this.items.get(buttonId).disable();
|
this.items.get(buttonId).disable();
|
||||||
}, this);
|
}, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
onLogin: function() {
|
onLogin: function() {
|
||||||
this.items.get('logout').enable();
|
this.items.get('logout').enable();
|
||||||
},
|
},
|
||||||
|
|
||||||
onLogout: function() {
|
onLogout: function() {
|
||||||
this.items.get('logout').disable();
|
this.items.get('logout').disable();
|
||||||
deluge.login.logout();
|
deluge.login.logout();
|
||||||
},
|
},
|
||||||
|
|
||||||
onConnectionManagerClick: function() {
|
onConnectionManagerClick: function() {
|
||||||
deluge.connectionManager.show();
|
deluge.connectionManager.show();
|
||||||
},
|
},
|
||||||
|
|
||||||
onHelpClick: function() {
|
onHelpClick: function() {
|
||||||
window.open('http://dev.deluge-torrent.org/wiki/UserGuide');
|
window.open('http://dev.deluge-torrent.org/wiki/UserGuide');
|
||||||
},
|
},
|
||||||
|
|
||||||
onPreferencesClick: function() {
|
onPreferencesClick: function() {
|
||||||
deluge.preferences.show();
|
deluge.preferences.show();
|
||||||
},
|
},
|
||||||
|
|
||||||
onTorrentAction: function(item) {
|
onTorrentAction: function(item) {
|
||||||
var selection = deluge.torrents.getSelections();
|
var selection = deluge.torrents.getSelections();
|
||||||
var ids = [];
|
var ids = [];
|
||||||
Ext.each(selection, function(record) {
|
Ext.each(selection, function(record) {
|
||||||
ids.push(record.id);
|
ids.push(record.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
switch (item.id) {
|
switch (item.id) {
|
||||||
case 'remove':
|
case 'remove':
|
||||||
deluge.removeWindow.show(ids);
|
deluge.removeWindow.show(ids);
|
||||||
break;
|
break;
|
||||||
case 'pause':
|
case 'pause':
|
||||||
case 'resume':
|
case 'resume':
|
||||||
deluge.client.core[item.id + '_torrent'](ids, {
|
deluge.client.core[item.id + '_torrent'](ids, {
|
||||||
success: function() {
|
success: function() {
|
||||||
deluge.ui.update();
|
deluge.ui.update();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'up':
|
case 'up':
|
||||||
case 'down':
|
case 'down':
|
||||||
deluge.client.core['queue_' + item.id](ids, {
|
deluge.client.core['queue_' + item.id](ids, {
|
||||||
success: function() {
|
success: function() {
|
||||||
deluge.ui.update();
|
deluge.ui.update();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onTorrentAdd: function() {
|
onTorrentAdd: function() {
|
||||||
deluge.add.show();
|
deluge.add.show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/*!
|
/*!
|
||||||
* Deluge.TorrentGrid.js
|
* Deluge.TorrentGrid.js
|
||||||
*
|
*
|
||||||
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com>
|
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -32,323 +32,347 @@
|
|||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
/* Renderers for the Torrent Grid */
|
/* Renderers for the Torrent Grid */
|
||||||
function queueRenderer(value) {
|
function queueRenderer(value) {
|
||||||
return (value == -1) ? '' : value + 1;
|
return (value == -1) ? '' : value + 1;
|
||||||
}
|
}
|
||||||
function torrentNameRenderer(value, p, r) {
|
function torrentNameRenderer(value, p, r) {
|
||||||
return String.format('<div class="torrent-name x-deluge-{0}">{1}</div>', r.data['state'].toLowerCase(), value);
|
return String.format('<div class="torrent-name x-deluge-{0}">{1}</div>', r.data['state'].toLowerCase(), value);
|
||||||
}
|
}
|
||||||
function torrentSpeedRenderer(value) {
|
function torrentSpeedRenderer(value) {
|
||||||
if (!value) return;
|
if (!value) return;
|
||||||
return fspeed(value);
|
return fspeed(value);
|
||||||
}
|
}
|
||||||
function torrentProgressRenderer(value, p, r) {
|
function torrentProgressRenderer(value, p, r) {
|
||||||
value = new Number(value);
|
value = new Number(value);
|
||||||
var progress = value;
|
var progress = value;
|
||||||
var text = r.data['state'] + ' ' + value.toFixed(2) + '%';
|
var text = r.data['state'] + ' ' + value.toFixed(2) + '%';
|
||||||
var width = new Number(this.style.match(/\w+:\s*(\d+)\w+/)[1]);
|
var width = new Number(this.style.match(/\w+:\s*(\d+)\w+/)[1]);
|
||||||
return Deluge.progressBar(value, width - 8, text);
|
return Deluge.progressBar(value, width - 8, text);
|
||||||
}
|
}
|
||||||
function seedsRenderer(value, p, r) {
|
function seedsRenderer(value, p, r) {
|
||||||
if (r.data['total_seeds'] > -1) {
|
if (r.data['total_seeds'] > -1) {
|
||||||
return String.format('{0} ({1})', value, r.data['total_seeds']);
|
return String.format('{0} ({1})', value, r.data['total_seeds']);
|
||||||
} else {
|
} else {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function peersRenderer(value, p, r) {
|
function peersRenderer(value, p, r) {
|
||||||
if (r.data['total_peers'] > -1) {
|
if (r.data['total_peers'] > -1) {
|
||||||
return String.format('{0} ({1})', value, r.data['total_peers']);
|
return String.format('{0} ({1})', value, r.data['total_peers']);
|
||||||
} else {
|
} else {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function availRenderer(value, p, r) {
|
function availRenderer(value, p, r) {
|
||||||
return (value < 0) ? '∞' : new Number(value).toFixed(3);
|
return (value < 0) ? '∞' : new Number(value).toFixed(3);
|
||||||
}
|
}
|
||||||
function trackerRenderer(value, p, r) {
|
function trackerRenderer(value, p, r) {
|
||||||
return String.format('<div style="background: url(' + deluge.config.base + 'tracker/{0}) no-repeat; padding-left: 20px;">{0}</div>', value);
|
return String.format('<div style="background: url(' + deluge.config.base + 'tracker/{0}) no-repeat; padding-left: 20px;">{0}</div>', value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function etaSorter(eta) {
|
|
||||||
return eta * -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
function etaSorter(eta) {
|
||||||
* Deluge.TorrentGrid Class
|
return eta * -1;
|
||||||
*
|
}
|
||||||
* @author Damien Churchill <damoxc@gmail.com>
|
|
||||||
* @version 1.3
|
|
||||||
*
|
|
||||||
* @class Deluge.TorrentGrid
|
|
||||||
* @extends Ext.grid.GridPanel
|
|
||||||
* @constructor
|
|
||||||
* @param {Object} config Configuration options
|
|
||||||
*/
|
|
||||||
Deluge.TorrentGrid = Ext.extend(Ext.grid.GridPanel, {
|
|
||||||
|
|
||||||
// object to store contained torrent ids
|
/**
|
||||||
torrents: {},
|
* Deluge.TorrentGrid Class
|
||||||
|
*
|
||||||
|
* @author Damien Churchill <damoxc@gmail.com>
|
||||||
|
* @version 1.3
|
||||||
|
*
|
||||||
|
* @class Deluge.TorrentGrid
|
||||||
|
* @extends Ext.grid.GridPanel
|
||||||
|
* @constructor
|
||||||
|
* @param {Object} config Configuration options
|
||||||
|
*/
|
||||||
|
Deluge.TorrentGrid = Ext.extend(Ext.grid.GridPanel, {
|
||||||
|
|
||||||
columns: [{
|
// object to store contained torrent ids
|
||||||
id:'queue',
|
torrents: {},
|
||||||
header: _('#'),
|
|
||||||
width: 30,
|
|
||||||
sortable: true,
|
|
||||||
renderer: queueRenderer,
|
|
||||||
dataIndex: 'queue'
|
|
||||||
}, {
|
|
||||||
id:'name',
|
|
||||||
header: _('Name'),
|
|
||||||
width: 150,
|
|
||||||
sortable: true,
|
|
||||||
renderer: torrentNameRenderer,
|
|
||||||
dataIndex: 'name'
|
|
||||||
}, {
|
|
||||||
header: _('Size'),
|
|
||||||
width: 75,
|
|
||||||
sortable: true,
|
|
||||||
renderer: fsize,
|
|
||||||
dataIndex: 'total_size'
|
|
||||||
}, {
|
|
||||||
header: _('Progress'),
|
|
||||||
width: 150,
|
|
||||||
sortable: true,
|
|
||||||
renderer: torrentProgressRenderer,
|
|
||||||
dataIndex: 'progress'
|
|
||||||
}, {
|
|
||||||
header: _('Seeders'),
|
|
||||||
width: 60,
|
|
||||||
sortable: true,
|
|
||||||
renderer: seedsRenderer,
|
|
||||||
dataIndex: 'num_seeds'
|
|
||||||
}, {
|
|
||||||
header: _('Peers'),
|
|
||||||
width: 60,
|
|
||||||
sortable: true,
|
|
||||||
renderer: peersRenderer,
|
|
||||||
dataIndex: 'num_peers'
|
|
||||||
}, {
|
|
||||||
header: _('Down Speed'),
|
|
||||||
width: 80,
|
|
||||||
sortable: true,
|
|
||||||
renderer: torrentSpeedRenderer,
|
|
||||||
dataIndex: 'download_payload_rate'
|
|
||||||
}, {
|
|
||||||
header: _('Up Speed'),
|
|
||||||
width: 80,
|
|
||||||
sortable: true,
|
|
||||||
renderer: torrentSpeedRenderer,
|
|
||||||
dataIndex: 'upload_payload_rate'
|
|
||||||
}, {
|
|
||||||
header: _('ETA'),
|
|
||||||
width: 60,
|
|
||||||
sortable: true,
|
|
||||||
renderer: ftime,
|
|
||||||
dataIndex: 'eta'
|
|
||||||
}, {
|
|
||||||
header: _('Ratio'),
|
|
||||||
width: 60,
|
|
||||||
sortable: true,
|
|
||||||
renderer: availRenderer,
|
|
||||||
dataIndex: 'ratio'
|
|
||||||
}, {
|
|
||||||
header: _('Avail'),
|
|
||||||
width: 60,
|
|
||||||
sortable: true,
|
|
||||||
renderer: availRenderer,
|
|
||||||
dataIndex: 'distributed_copies'
|
|
||||||
}, {
|
|
||||||
header: _('Added'),
|
|
||||||
width: 80,
|
|
||||||
sortable: true,
|
|
||||||
renderer: fdate,
|
|
||||||
dataIndex: 'time_added'
|
|
||||||
}, {
|
|
||||||
header: _('Tracker'),
|
|
||||||
width: 120,
|
|
||||||
sortable: true,
|
|
||||||
renderer: trackerRenderer,
|
|
||||||
dataIndex: 'tracker_host'
|
|
||||||
}, {
|
|
||||||
header: _('Save Path'),
|
|
||||||
width: 120,
|
|
||||||
sortable: true,
|
|
||||||
renderer: fplain,
|
|
||||||
dataIndex: 'save_path'
|
|
||||||
}],
|
|
||||||
|
|
||||||
meta: {
|
columns: [{
|
||||||
root: 'torrents',
|
id:'queue',
|
||||||
idProperty: 'id',
|
header: _('#'),
|
||||||
fields: [
|
width: 30,
|
||||||
{name: 'queue', sortType: Deluge.data.SortTypes.asQueuePosition},
|
sortable: true,
|
||||||
{name: 'name'},
|
renderer: queueRenderer,
|
||||||
{name: 'total_size', type: 'int'},
|
dataIndex: 'queue'
|
||||||
{name: 'state'},
|
}, {
|
||||||
{name: 'progress', type: 'float'},
|
id:'name',
|
||||||
{name: 'num_seeds', type: 'int'},
|
header: _('Name'),
|
||||||
{name: 'total_seeds', type: 'int'},
|
width: 150,
|
||||||
{name: 'num_peers', type: 'int'},
|
sortable: true,
|
||||||
{name: 'total_peers', type: 'int'},
|
renderer: torrentNameRenderer,
|
||||||
{name: 'download_payload_rate', type: 'int'},
|
dataIndex: 'name'
|
||||||
{name: 'upload_payload_speed', type: 'int'},
|
}, {
|
||||||
{name: 'eta', type: 'int', sortType: etaSorter},
|
header: _('Size'),
|
||||||
{name: 'ratio', type: 'float'},
|
width: 75,
|
||||||
{name: 'distributed_copies', type: 'float'},
|
sortable: true,
|
||||||
{name: 'time_added', type: 'int'},
|
renderer: fsize,
|
||||||
{name: 'tracker_host'},
|
dataIndex: 'total_size'
|
||||||
{name: 'save_path'}
|
}, {
|
||||||
]
|
header: _('Progress'),
|
||||||
},
|
width: 150,
|
||||||
|
sortable: true,
|
||||||
|
renderer: torrentProgressRenderer,
|
||||||
|
dataIndex: 'progress'
|
||||||
|
}, {
|
||||||
|
header: _('Seeders'),
|
||||||
|
width: 60,
|
||||||
|
sortable: true,
|
||||||
|
renderer: seedsRenderer,
|
||||||
|
dataIndex: 'num_seeds'
|
||||||
|
}, {
|
||||||
|
header: _('Peers'),
|
||||||
|
width: 60,
|
||||||
|
sortable: true,
|
||||||
|
renderer: peersRenderer,
|
||||||
|
dataIndex: 'num_peers'
|
||||||
|
}, {
|
||||||
|
header: _('Down Speed'),
|
||||||
|
width: 80,
|
||||||
|
sortable: true,
|
||||||
|
renderer: torrentSpeedRenderer,
|
||||||
|
dataIndex: 'download_payload_rate'
|
||||||
|
}, {
|
||||||
|
header: _('Up Speed'),
|
||||||
|
width: 80,
|
||||||
|
sortable: true,
|
||||||
|
renderer: torrentSpeedRenderer,
|
||||||
|
dataIndex: 'upload_payload_rate'
|
||||||
|
}, {
|
||||||
|
header: _('ETA'),
|
||||||
|
width: 60,
|
||||||
|
sortable: true,
|
||||||
|
renderer: ftime,
|
||||||
|
dataIndex: 'eta'
|
||||||
|
}, {
|
||||||
|
header: _('Ratio'),
|
||||||
|
width: 60,
|
||||||
|
sortable: true,
|
||||||
|
renderer: availRenderer,
|
||||||
|
dataIndex: 'ratio'
|
||||||
|
}, {
|
||||||
|
header: _('Avail'),
|
||||||
|
width: 60,
|
||||||
|
sortable: true,
|
||||||
|
renderer: availRenderer,
|
||||||
|
dataIndex: 'distributed_copies'
|
||||||
|
}, {
|
||||||
|
header: _('Added'),
|
||||||
|
width: 80,
|
||||||
|
sortable: true,
|
||||||
|
renderer: fdate,
|
||||||
|
dataIndex: 'time_added'
|
||||||
|
}, {
|
||||||
|
header: _('Last Seen Complete'),
|
||||||
|
width: 80,
|
||||||
|
sortable: true,
|
||||||
|
renderer: fdate,
|
||||||
|
dataIndex: 'last_seen_complete'
|
||||||
|
}, {
|
||||||
|
header: _('Tracker'),
|
||||||
|
width: 120,
|
||||||
|
sortable: true,
|
||||||
|
renderer: trackerRenderer,
|
||||||
|
dataIndex: 'tracker_host'
|
||||||
|
}, {
|
||||||
|
header: _('Save Path'),
|
||||||
|
width: 120,
|
||||||
|
sortable: true,
|
||||||
|
renderer: fplain,
|
||||||
|
dataIndex: 'save_path'
|
||||||
|
}, {
|
||||||
|
header: _('Owner'),
|
||||||
|
width: 80,
|
||||||
|
sortable: true,
|
||||||
|
renderer: fplain,
|
||||||
|
dataIndex: 'owner'
|
||||||
|
}, {
|
||||||
|
header: _('Public'),
|
||||||
|
width: 80,
|
||||||
|
sortable: true,
|
||||||
|
renderer: fplain,
|
||||||
|
dataIndex: 'public'
|
||||||
|
}, {
|
||||||
|
header: _('Shared'),
|
||||||
|
width: 80,
|
||||||
|
sortable: true,
|
||||||
|
renderer: fplain,
|
||||||
|
dataIndex: 'shared'
|
||||||
|
}],
|
||||||
|
|
||||||
constructor: function(config) {
|
meta: {
|
||||||
config = Ext.apply({
|
root: 'torrents',
|
||||||
id: 'torrentGrid',
|
idProperty: 'id',
|
||||||
store: new Ext.data.JsonStore(this.meta),
|
fields: [
|
||||||
columns: this.columns,
|
{name: 'queue', sortType: Deluge.data.SortTypes.asQueuePosition},
|
||||||
region: 'center',
|
{name: 'name'},
|
||||||
cls: 'deluge-torrents',
|
{name: 'total_size', type: 'int'},
|
||||||
stripeRows: true,
|
{name: 'state'},
|
||||||
autoExpandColumn: 'name',
|
{name: 'progress', type: 'float'},
|
||||||
deferredRender:false,
|
{name: 'num_seeds', type: 'int'},
|
||||||
autoScroll:true,
|
{name: 'total_seeds', type: 'int'},
|
||||||
margins: '5 5 0 0',
|
{name: 'num_peers', type: 'int'},
|
||||||
stateful: true,
|
{name: 'total_peers', type: 'int'},
|
||||||
view: new Ext.ux.grid.BufferView({
|
{name: 'download_payload_rate', type: 'int'},
|
||||||
rowHeight: 26,
|
{name: 'upload_payload_speed', type: 'int'},
|
||||||
scrollDelay: false
|
{name: 'eta', type: 'int', sortType: etaSorter},
|
||||||
})
|
{name: 'ratio', type: 'float'},
|
||||||
}, config);
|
{name: 'distributed_copies', type: 'float'},
|
||||||
Deluge.TorrentGrid.superclass.constructor.call(this, config);
|
{name: 'time_added', type: 'int'},
|
||||||
},
|
{name: 'tracker_host'},
|
||||||
|
{name: 'save_path'}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
initComponent: function() {
|
constructor: function(config) {
|
||||||
Deluge.TorrentGrid.superclass.initComponent.call(this);
|
config = Ext.apply({
|
||||||
deluge.events.on('torrentRemoved', this.onTorrentRemoved, this);
|
id: 'torrentGrid',
|
||||||
deluge.events.on('disconnect', this.onDisconnect, this);
|
store: new Ext.data.JsonStore(this.meta),
|
||||||
|
columns: this.columns,
|
||||||
|
region: 'center',
|
||||||
|
cls: 'deluge-torrents',
|
||||||
|
stripeRows: true,
|
||||||
|
autoExpandColumn: 'name',
|
||||||
|
deferredRender:false,
|
||||||
|
autoScroll:true,
|
||||||
|
margins: '5 5 0 0',
|
||||||
|
stateful: true,
|
||||||
|
view: new Ext.ux.grid.BufferView({
|
||||||
|
rowHeight: 26,
|
||||||
|
scrollDelay: false
|
||||||
|
})
|
||||||
|
}, config);
|
||||||
|
Deluge.TorrentGrid.superclass.constructor.call(this, config);
|
||||||
|
},
|
||||||
|
|
||||||
this.on('rowcontextmenu', function(grid, rowIndex, e) {
|
initComponent: function() {
|
||||||
e.stopEvent();
|
Deluge.TorrentGrid.superclass.initComponent.call(this);
|
||||||
var selection = grid.getSelectionModel();
|
deluge.events.on('torrentRemoved', this.onTorrentRemoved, this);
|
||||||
if (!selection.hasSelection()) {
|
deluge.events.on('disconnect', this.onDisconnect, this);
|
||||||
selection.selectRow(rowIndex);
|
|
||||||
}
|
|
||||||
deluge.menus.torrent.showAt(e.getPoint());
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
this.on('rowcontextmenu', function(grid, rowIndex, e) {
|
||||||
* Returns the record representing the torrent at the specified index.
|
e.stopEvent();
|
||||||
*
|
var selection = grid.getSelectionModel();
|
||||||
* @param index {int} The row index of the torrent you wish to retrieve.
|
if (!selection.hasSelection()) {
|
||||||
* @return {Ext.data.Record} The record representing the torrent.
|
selection.selectRow(rowIndex);
|
||||||
*/
|
}
|
||||||
getTorrent: function(index) {
|
deluge.menus.torrent.showAt(e.getPoint());
|
||||||
return this.getStore().getAt(index);
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the currently selected record.
|
* Returns the record representing the torrent at the specified index.
|
||||||
* @ return {Array/Ext.data.Record} The record(s) representing the rows
|
*
|
||||||
*/
|
* @param index {int} The row index of the torrent you wish to retrieve.
|
||||||
getSelected: function() {
|
* @return {Ext.data.Record} The record representing the torrent.
|
||||||
return this.getSelectionModel().getSelected();
|
*/
|
||||||
},
|
getTorrent: function(index) {
|
||||||
|
return this.getStore().getAt(index);
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the currently selected records.
|
* Returns the currently selected record.
|
||||||
*/
|
* @ return {Array/Ext.data.Record} The record(s) representing the rows
|
||||||
getSelections: function() {
|
*/
|
||||||
return this.getSelectionModel().getSelections();
|
getSelected: function() {
|
||||||
},
|
return this.getSelectionModel().getSelected();
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the currently selected torrent id.
|
* Returns the currently selected records.
|
||||||
* @return {String} The currently selected id.
|
*/
|
||||||
*/
|
getSelections: function() {
|
||||||
getSelectedId: function() {
|
return this.getSelectionModel().getSelections();
|
||||||
return this.getSelectionModel().getSelected().id
|
},
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the currently selected torrent ids.
|
* Return the currently selected torrent id.
|
||||||
* @return {Array} The currently selected ids.
|
* @return {String} The currently selected id.
|
||||||
*/
|
*/
|
||||||
getSelectedIds: function() {
|
getSelectedId: function() {
|
||||||
var ids = [];
|
return this.getSelectionModel().getSelected().id
|
||||||
Ext.each(this.getSelectionModel().getSelections(), function(r) {
|
},
|
||||||
ids.push(r.id);
|
|
||||||
});
|
|
||||||
return ids;
|
|
||||||
},
|
|
||||||
|
|
||||||
update: function(torrents, wipe) {
|
/**
|
||||||
var store = this.getStore();
|
* Return the currently selected torrent ids.
|
||||||
|
* @return {Array} The currently selected ids.
|
||||||
|
*/
|
||||||
|
getSelectedIds: function() {
|
||||||
|
var ids = [];
|
||||||
|
Ext.each(this.getSelectionModel().getSelections(), function(r) {
|
||||||
|
ids.push(r.id);
|
||||||
|
});
|
||||||
|
return ids;
|
||||||
|
},
|
||||||
|
|
||||||
// Need to perform a complete reload of the torrent grid.
|
update: function(torrents, wipe) {
|
||||||
if (wipe) {
|
var store = this.getStore();
|
||||||
store.removeAll();
|
|
||||||
this.torrents = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
var newTorrents = [];
|
// Need to perform a complete reload of the torrent grid.
|
||||||
|
if (wipe) {
|
||||||
|
store.removeAll();
|
||||||
|
this.torrents = {};
|
||||||
|
}
|
||||||
|
|
||||||
// Update and add any new torrents.
|
var newTorrents = [];
|
||||||
for (var t in torrents) {
|
|
||||||
var torrent = torrents[t];
|
|
||||||
|
|
||||||
if (this.torrents[t]) {
|
// Update and add any new torrents.
|
||||||
var record = store.getById(t);
|
for (var t in torrents) {
|
||||||
record.beginEdit();
|
var torrent = torrents[t];
|
||||||
for (var k in torrent) {
|
|
||||||
if (record.get(k) != torrent[k]) {
|
|
||||||
record.set(k, torrent[k]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
record.endEdit();
|
|
||||||
} else {
|
|
||||||
var record = new Deluge.data.Torrent(torrent);
|
|
||||||
record.id = t;
|
|
||||||
this.torrents[t] = 1;
|
|
||||||
newTorrents.push(record);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
store.add(newTorrents);
|
|
||||||
|
|
||||||
// Remove any torrents that should not be in the store.
|
if (this.torrents[t]) {
|
||||||
store.each(function(record) {
|
var record = store.getById(t);
|
||||||
if (!torrents[record.id]) {
|
record.beginEdit();
|
||||||
store.remove(record);
|
for (var k in torrent) {
|
||||||
delete this.torrents[record.id];
|
if (record.get(k) != torrent[k]) {
|
||||||
}
|
record.set(k, torrent[k]);
|
||||||
}, this);
|
}
|
||||||
store.commitChanges();
|
}
|
||||||
|
record.endEdit();
|
||||||
|
} else {
|
||||||
|
var record = new Deluge.data.Torrent(torrent);
|
||||||
|
record.id = t;
|
||||||
|
this.torrents[t] = 1;
|
||||||
|
newTorrents.push(record);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
store.add(newTorrents);
|
||||||
|
|
||||||
var sortState = store.getSortState()
|
// Remove any torrents that should not be in the store.
|
||||||
if (!sortState) return;
|
store.each(function(record) {
|
||||||
store.sort(sortState.field, sortState.direction);
|
if (!torrents[record.id]) {
|
||||||
},
|
store.remove(record);
|
||||||
|
delete this.torrents[record.id];
|
||||||
|
}
|
||||||
|
}, this);
|
||||||
|
store.commitChanges();
|
||||||
|
|
||||||
// private
|
var sortState = store.getSortState()
|
||||||
onDisconnect: function() {
|
if (!sortState) return;
|
||||||
this.getStore().removeAll();
|
store.sort(sortState.field, sortState.direction);
|
||||||
this.torrents = {};
|
},
|
||||||
},
|
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onTorrentRemoved: function(torrentIds) {
|
onDisconnect: function() {
|
||||||
var selModel = this.getSelectionModel();
|
this.getStore().removeAll();
|
||||||
Ext.each(torrentIds, function(torrentId) {
|
this.torrents = {};
|
||||||
var record = this.getStore().getById(torrentId);
|
},
|
||||||
if (selModel.isSelected(record)) {
|
|
||||||
selModel.deselectRow(this.getStore().indexOf(record));
|
// private
|
||||||
}
|
onTorrentRemoved: function(torrentIds) {
|
||||||
this.getStore().remove(record);
|
var selModel = this.getSelectionModel();
|
||||||
delete this.torrents[torrentId];
|
Ext.each(torrentIds, function(torrentId) {
|
||||||
}, this);
|
var record = this.getStore().getById(torrentId);
|
||||||
}
|
if (selModel.isSelected(record)) {
|
||||||
|
selModel.deselectRow(this.getStore().indexOf(record));
|
||||||
|
}
|
||||||
|
this.getStore().remove(record);
|
||||||
|
delete this.torrents[torrentId];
|
||||||
|
}, this);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
deluge.torrents = new Deluge.TorrentGrid();
|
deluge.torrents = new Deluge.TorrentGrid();
|
||||||
})();
|
})();
|
||||||
|
|||||||
@ -38,234 +38,234 @@
|
|||||||
*/
|
*/
|
||||||
deluge.ui = {
|
deluge.ui = {
|
||||||
|
|
||||||
errorCount: 0,
|
errorCount: 0,
|
||||||
|
|
||||||
filters: null,
|
filters: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Create all the interface components, the json-rpc client
|
* @description Create all the interface components, the json-rpc client
|
||||||
* and set up various events that the UI will utilise.
|
* and set up various events that the UI will utilise.
|
||||||
*/
|
*/
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
deluge.add = new Deluge.add.AddWindow();
|
deluge.add = new Deluge.add.AddWindow();
|
||||||
deluge.details = new Deluge.details.DetailsPanel();
|
deluge.details = new Deluge.details.DetailsPanel();
|
||||||
deluge.connectionManager = new Deluge.ConnectionManager();
|
deluge.connectionManager = new Deluge.ConnectionManager();
|
||||||
deluge.editTrackers = new Deluge.EditTrackersWindow();
|
deluge.editTrackers = new Deluge.EditTrackersWindow();
|
||||||
deluge.login = new Deluge.LoginWindow();
|
deluge.login = new Deluge.LoginWindow();
|
||||||
deluge.preferences = new Deluge.preferences.PreferencesWindow();
|
deluge.preferences = new Deluge.preferences.PreferencesWindow();
|
||||||
deluge.sidebar = new Deluge.Sidebar();
|
deluge.sidebar = new Deluge.Sidebar();
|
||||||
deluge.statusbar = new Deluge.Statusbar();
|
deluge.statusbar = new Deluge.Statusbar();
|
||||||
deluge.toolbar = new Deluge.Toolbar();
|
deluge.toolbar = new Deluge.Toolbar();
|
||||||
|
|
||||||
this.MainPanel = new Ext.Panel({
|
this.MainPanel = new Ext.Panel({
|
||||||
id: 'mainPanel',
|
id: 'mainPanel',
|
||||||
iconCls: 'x-deluge-main-panel',
|
iconCls: 'x-deluge-main-panel',
|
||||||
title: 'Deluge',
|
title: 'Deluge',
|
||||||
layout: 'border',
|
layout: 'border',
|
||||||
tbar: deluge.toolbar,
|
tbar: deluge.toolbar,
|
||||||
items: [
|
items: [
|
||||||
deluge.sidebar,
|
deluge.sidebar,
|
||||||
deluge.details,
|
deluge.details,
|
||||||
deluge.torrents
|
deluge.torrents
|
||||||
],
|
],
|
||||||
bbar: deluge.statusbar
|
bbar: deluge.statusbar
|
||||||
});
|
});
|
||||||
|
|
||||||
this.Viewport = new Ext.Viewport({
|
this.Viewport = new Ext.Viewport({
|
||||||
layout: 'fit',
|
layout: 'fit',
|
||||||
items: [this.MainPanel]
|
items: [this.MainPanel]
|
||||||
});
|
});
|
||||||
|
|
||||||
deluge.events.on("connect", this.onConnect, this);
|
deluge.events.on("connect", this.onConnect, this);
|
||||||
deluge.events.on("disconnect", this.onDisconnect, this);
|
deluge.events.on("disconnect", this.onDisconnect, this);
|
||||||
deluge.events.on('PluginDisabledEvent', this.onPluginDisabled, this);
|
deluge.events.on('PluginDisabledEvent', this.onPluginDisabled, this);
|
||||||
deluge.events.on('PluginEnabledEvent', this.onPluginEnabled, this);
|
deluge.events.on('PluginEnabledEvent', this.onPluginEnabled, this);
|
||||||
deluge.client = new Ext.ux.util.RpcClient({
|
deluge.client = new Ext.ux.util.RpcClient({
|
||||||
url: deluge.config.base + 'json'
|
url: deluge.config.base + 'json'
|
||||||
});
|
});
|
||||||
|
|
||||||
// enable all the already active plugins
|
// enable all the already active plugins
|
||||||
for (var plugin in Deluge.pluginStore) {
|
for (var plugin in Deluge.pluginStore) {
|
||||||
plugin = Deluge.createPlugin(plugin);
|
plugin = Deluge.createPlugin(plugin);
|
||||||
plugin.enable();
|
plugin.enable();
|
||||||
deluge.plugins[plugin.name] = plugin;
|
deluge.plugins[plugin.name] = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize quicktips so all the tooltip configs start working.
|
// Initialize quicktips so all the tooltip configs start working.
|
||||||
Ext.QuickTips.init();
|
Ext.QuickTips.init();
|
||||||
|
|
||||||
deluge.client.on('connected', function(e) {
|
deluge.client.on('connected', function(e) {
|
||||||
deluge.login.show();
|
deluge.login.show();
|
||||||
}, this, {single: true});
|
}, this, {single: true});
|
||||||
|
|
||||||
this.update = this.update.createDelegate(this);
|
this.update = this.update.createDelegate(this);
|
||||||
this.checkConnection = this.checkConnection.createDelegate(this);
|
this.checkConnection = this.checkConnection.createDelegate(this);
|
||||||
|
|
||||||
this.originalTitle = document.title;
|
this.originalTitle = document.title;
|
||||||
},
|
},
|
||||||
|
|
||||||
checkConnection: function() {
|
checkConnection: function() {
|
||||||
deluge.client.web.connected({
|
deluge.client.web.connected({
|
||||||
success: this.onConnectionSuccess,
|
success: this.onConnectionSuccess,
|
||||||
failure: this.onConnectionError,
|
failure: this.onConnectionError,
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
update: function() {
|
update: function() {
|
||||||
var filters = deluge.sidebar.getFilterStates();
|
var filters = deluge.sidebar.getFilterStates();
|
||||||
this.oldFilters = this.filters;
|
this.oldFilters = this.filters;
|
||||||
this.filters = filters;
|
this.filters = filters;
|
||||||
|
|
||||||
deluge.client.web.update_ui(Deluge.Keys.Grid, filters, {
|
deluge.client.web.update_ui(Deluge.Keys.Grid, filters, {
|
||||||
success: this.onUpdate,
|
success: this.onUpdate,
|
||||||
failure: this.onUpdateError,
|
failure: this.onUpdateError,
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
deluge.details.update();
|
deluge.details.update();
|
||||||
},
|
},
|
||||||
|
|
||||||
onConnectionError: function(error) {
|
onConnectionError: function(error) {
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onConnectionSuccess: function(result) {
|
onConnectionSuccess: function(result) {
|
||||||
deluge.statusbar.setStatus({
|
deluge.statusbar.setStatus({
|
||||||
iconCls: 'x-deluge-statusbar icon-ok',
|
iconCls: 'x-deluge-statusbar icon-ok',
|
||||||
text: _('Connection restored')
|
text: _('Connection restored')
|
||||||
});
|
});
|
||||||
clearInterval(this.checking);
|
clearInterval(this.checking);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
deluge.connectionManager.show();
|
deluge.connectionManager.show();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onUpdateError: function(error) {
|
onUpdateError: function(error) {
|
||||||
if (this.errorCount == 2) {
|
if (this.errorCount == 2) {
|
||||||
Ext.MessageBox.show({
|
Ext.MessageBox.show({
|
||||||
title: 'Lost Connection',
|
title: 'Lost Connection',
|
||||||
msg: 'The connection to the webserver has been lost!',
|
msg: 'The connection to the webserver has been lost!',
|
||||||
buttons: Ext.MessageBox.OK,
|
buttons: Ext.MessageBox.OK,
|
||||||
icon: Ext.MessageBox.ERROR
|
icon: Ext.MessageBox.ERROR
|
||||||
});
|
});
|
||||||
deluge.events.fire('disconnect');
|
deluge.events.fire('disconnect');
|
||||||
deluge.statusbar.setStatus({
|
deluge.statusbar.setStatus({
|
||||||
text: 'Lost connection to webserver'}
|
text: 'Lost connection to webserver'}
|
||||||
);
|
);
|
||||||
this.checking = setInterval(this.checkConnection, 2000);
|
this.checking = setInterval(this.checkConnection, 2000);
|
||||||
}
|
}
|
||||||
this.errorCount++;
|
this.errorCount++;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @static
|
* @static
|
||||||
* @private
|
* @private
|
||||||
* Updates the various components in the interface.
|
* Updates the various components in the interface.
|
||||||
*/
|
*/
|
||||||
onUpdate: function(data) {
|
onUpdate: function(data) {
|
||||||
if (!data['connected']) {
|
if (!data['connected']) {
|
||||||
deluge.connectionManager.disconnect(true);
|
deluge.connectionManager.disconnect(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deluge.config.show_session_speed) {
|
if (deluge.config.show_session_speed) {
|
||||||
document.title = this.originalTitle +
|
document.title = this.originalTitle +
|
||||||
' (Down: ' + fspeed(data['stats'].download_rate, true) +
|
' (Down: ' + fspeed(data['stats'].download_rate, true) +
|
||||||
' Up: ' + fspeed(data['stats'].upload_rate, true) + ')';
|
' Up: ' + fspeed(data['stats'].upload_rate, true) + ')';
|
||||||
}
|
}
|
||||||
if (Ext.areObjectsEqual(this.filters, this.oldFilters)) {
|
if (Ext.areObjectsEqual(this.filters, this.oldFilters)) {
|
||||||
deluge.torrents.update(data['torrents']);
|
deluge.torrents.update(data['torrents']);
|
||||||
} else {
|
} else {
|
||||||
deluge.torrents.update(data['torrents'], true);
|
deluge.torrents.update(data['torrents'], true);
|
||||||
}
|
}
|
||||||
deluge.statusbar.update(data['stats']);
|
deluge.statusbar.update(data['stats']);
|
||||||
deluge.sidebar.update(data['filters']);
|
deluge.sidebar.update(data['filters']);
|
||||||
this.errorCount = 0;
|
this.errorCount = 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @static
|
* @static
|
||||||
* @private
|
* @private
|
||||||
* Start the Deluge UI polling the server and update the interface.
|
* Start the Deluge UI polling the server and update the interface.
|
||||||
*/
|
*/
|
||||||
onConnect: function() {
|
onConnect: function() {
|
||||||
if (!this.running) {
|
if (!this.running) {
|
||||||
this.running = setInterval(this.update, 2000);
|
this.running = setInterval(this.update, 2000);
|
||||||
this.update();
|
this.update();
|
||||||
}
|
}
|
||||||
deluge.client.web.get_plugins({
|
deluge.client.web.get_plugins({
|
||||||
success: this.onGotPlugins,
|
success: this.onGotPlugins,
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @static
|
* @static
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
onDisconnect: function() {
|
onDisconnect: function() {
|
||||||
this.stop();
|
this.stop();
|
||||||
},
|
},
|
||||||
|
|
||||||
onGotPlugins: function(plugins) {
|
onGotPlugins: function(plugins) {
|
||||||
Ext.each(plugins.enabled_plugins, function(plugin) {
|
Ext.each(plugins.enabled_plugins, function(plugin) {
|
||||||
if (deluge.plugins[plugin]) return;
|
if (deluge.plugins[plugin]) return;
|
||||||
deluge.client.web.get_plugin_resources(plugin, {
|
deluge.client.web.get_plugin_resources(plugin, {
|
||||||
success: this.onGotPluginResources,
|
success: this.onGotPluginResources,
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
}, this);
|
}, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
onPluginEnabled: function(pluginName) {
|
onPluginEnabled: function(pluginName) {
|
||||||
if (deluge.plugins[pluginName]) {
|
if (deluge.plugins[pluginName]) {
|
||||||
deluge.plugins[pluginName].enable();
|
deluge.plugins[pluginName].enable();
|
||||||
} else {
|
} else {
|
||||||
deluge.client.web.get_plugin_resources(pluginName, {
|
deluge.client.web.get_plugin_resources(pluginName, {
|
||||||
success: this.onGotPluginResources,
|
success: this.onGotPluginResources,
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onGotPluginResources: function(resources) {
|
onGotPluginResources: function(resources) {
|
||||||
var scripts = (Deluge.debug) ? resources.debug_scripts : resources.scripts;
|
var scripts = (Deluge.debug) ? resources.debug_scripts : resources.scripts;
|
||||||
Ext.each(scripts, function(script) {
|
Ext.each(scripts, function(script) {
|
||||||
Ext.ux.JSLoader({
|
Ext.ux.JSLoader({
|
||||||
url: deluge.config.base + script,
|
url: deluge.config.base + script,
|
||||||
onLoad: this.onPluginLoaded,
|
onLoad: this.onPluginLoaded,
|
||||||
pluginName: resources.name
|
pluginName: resources.name
|
||||||
});
|
});
|
||||||
}, this);
|
}, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
onPluginDisabled: function(pluginName) {
|
onPluginDisabled: function(pluginName) {
|
||||||
deluge.plugins[pluginName].disable();
|
deluge.plugins[pluginName].disable();
|
||||||
},
|
},
|
||||||
|
|
||||||
onPluginLoaded: function(options) {
|
onPluginLoaded: function(options) {
|
||||||
// This could happen if the plugin has multiple scripts
|
// This could happen if the plugin has multiple scripts
|
||||||
if (!Deluge.hasPlugin(options.pluginName)) return;
|
if (!Deluge.hasPlugin(options.pluginName)) return;
|
||||||
|
|
||||||
// Enable the plugin
|
// Enable the plugin
|
||||||
plugin = Deluge.createPlugin(options.pluginName);
|
plugin = Deluge.createPlugin(options.pluginName);
|
||||||
plugin.enable();
|
plugin.enable();
|
||||||
deluge.plugins[plugin.name] = plugin;
|
deluge.plugins[plugin.name] = plugin;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @static
|
* @static
|
||||||
* Stop the Deluge UI polling the server and clear the interface.
|
* Stop the Deluge UI polling the server and clear the interface.
|
||||||
*/
|
*/
|
||||||
stop: function() {
|
stop: function() {
|
||||||
if (this.running) {
|
if (this.running) {
|
||||||
clearInterval(this.running);
|
clearInterval(this.running);
|
||||||
this.running = false;
|
this.running = false;
|
||||||
deluge.torrents.getStore().removeAll();
|
deluge.torrents.getStore().removeAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ext.onReady(function(e) {
|
Ext.onReady(function(e) {
|
||||||
deluge.ui.initialize();
|
deluge.ui.initialize();
|
||||||
});
|
});
|
||||||
|
|||||||
@ -34,195 +34,195 @@ Ext.namespace('Deluge.add');
|
|||||||
|
|
||||||
Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
|
Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
|
||||||
|
|
||||||
title: _('Add Torrents'),
|
title: _('Add Torrents'),
|
||||||
layout: 'border',
|
layout: 'border',
|
||||||
width: 470,
|
width: 470,
|
||||||
height: 450,
|
height: 450,
|
||||||
bodyStyle: 'padding: 10px 5px;',
|
bodyStyle: 'padding: 10px 5px;',
|
||||||
buttonAlign: 'right',
|
buttonAlign: 'right',
|
||||||
closeAction: 'hide',
|
closeAction: 'hide',
|
||||||
closable: true,
|
closable: true,
|
||||||
plain: true,
|
plain: true,
|
||||||
iconCls: 'x-deluge-add-window-icon',
|
iconCls: 'x-deluge-add-window-icon',
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.add.AddWindow.superclass.initComponent.call(this);
|
Deluge.add.AddWindow.superclass.initComponent.call(this);
|
||||||
|
|
||||||
this.addButton(_('Cancel'), this.onCancelClick, this);
|
this.addButton(_('Cancel'), this.onCancelClick, this);
|
||||||
this.addButton(_('Add'), this.onAddClick, this);
|
this.addButton(_('Add'), this.onAddClick, this);
|
||||||
|
|
||||||
function torrentRenderer(value, p, r) {
|
function torrentRenderer(value, p, r) {
|
||||||
if (r.data['info_hash']) {
|
if (r.data['info_hash']) {
|
||||||
return String.format('<div class="x-deluge-add-torrent-name">{0}</div>', value);
|
return String.format('<div class="x-deluge-add-torrent-name">{0}</div>', value);
|
||||||
} else {
|
} else {
|
||||||
return String.format('<div class="x-deluge-add-torrent-name-loading">{0}</div>', value);
|
return String.format('<div class="x-deluge-add-torrent-name-loading">{0}</div>', value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.list = new Ext.list.ListView({
|
this.list = new Ext.list.ListView({
|
||||||
store: new Ext.data.SimpleStore({
|
store: new Ext.data.SimpleStore({
|
||||||
fields: [
|
fields: [
|
||||||
{name: 'info_hash', mapping: 1},
|
{name: 'info_hash', mapping: 1},
|
||||||
{name: 'text', mapping: 2}
|
{name: 'text', mapping: 2}
|
||||||
],
|
],
|
||||||
id: 0
|
id: 0
|
||||||
}),
|
}),
|
||||||
columns: [{
|
columns: [{
|
||||||
id: 'torrent',
|
id: 'torrent',
|
||||||
width: 150,
|
width: 150,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
renderer: torrentRenderer,
|
renderer: torrentRenderer,
|
||||||
dataIndex: 'text'
|
dataIndex: 'text'
|
||||||
}],
|
}],
|
||||||
stripeRows: true,
|
stripeRows: true,
|
||||||
singleSelect: true,
|
singleSelect: true,
|
||||||
listeners: {
|
listeners: {
|
||||||
'selectionchange': {
|
'selectionchange': {
|
||||||
fn: this.onSelect,
|
fn: this.onSelect,
|
||||||
scope: this
|
scope: this
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
hideHeaders: true,
|
hideHeaders: true,
|
||||||
autoExpandColumn: 'torrent',
|
autoExpandColumn: 'torrent',
|
||||||
autoScroll: true
|
autoScroll: true
|
||||||
});
|
});
|
||||||
|
|
||||||
this.add({
|
this.add({
|
||||||
region: 'center',
|
region: 'center',
|
||||||
items: [this.list],
|
items: [this.list],
|
||||||
margins: '5 5 5 5',
|
margins: '5 5 5 5',
|
||||||
bbar: new Ext.Toolbar({
|
bbar: new Ext.Toolbar({
|
||||||
items: [{
|
items: [{
|
||||||
iconCls: 'x-deluge-add-file',
|
iconCls: 'x-deluge-add-file',
|
||||||
text: _('File'),
|
text: _('File'),
|
||||||
handler: this.onFile,
|
handler: this.onFile,
|
||||||
scope: this
|
scope: this
|
||||||
}, {
|
}, {
|
||||||
text: _('Url'),
|
text: _('Url'),
|
||||||
iconCls: 'icon-add-url',
|
iconCls: 'icon-add-url',
|
||||||
handler: this.onUrl,
|
handler: this.onUrl,
|
||||||
scope: this
|
scope: this
|
||||||
}, {
|
}, {
|
||||||
text: _('Infohash'),
|
text: _('Infohash'),
|
||||||
iconCls: 'icon-add-magnet',
|
iconCls: 'icon-add-magnet',
|
||||||
disabled: true
|
disabled: true
|
||||||
}, '->', {
|
}, '->', {
|
||||||
text: _('Remove'),
|
text: _('Remove'),
|
||||||
iconCls: 'icon-remove',
|
iconCls: 'icon-remove',
|
||||||
handler: this.onRemove,
|
handler: this.onRemove,
|
||||||
scope: this
|
scope: this
|
||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
this.optionsPanel = this.add(new Deluge.add.OptionsPanel());
|
this.optionsPanel = this.add(new Deluge.add.OptionsPanel());
|
||||||
this.on('hide', this.onHide, this);
|
this.on('hide', this.onHide, this);
|
||||||
this.on('show', this.onShow, this);
|
this.on('show', this.onShow, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
clear: function() {
|
clear: function() {
|
||||||
this.list.getStore().removeAll();
|
this.list.getStore().removeAll();
|
||||||
this.optionsPanel.clear();
|
this.optionsPanel.clear();
|
||||||
},
|
},
|
||||||
|
|
||||||
onAddClick: function() {
|
onAddClick: function() {
|
||||||
var torrents = [];
|
var torrents = [];
|
||||||
if (!this.list) return;
|
if (!this.list) return;
|
||||||
this.list.getStore().each(function(r) {
|
this.list.getStore().each(function(r) {
|
||||||
var id = r.get('info_hash');
|
var id = r.get('info_hash');
|
||||||
torrents.push({
|
torrents.push({
|
||||||
path: this.optionsPanel.getFilename(id),
|
path: this.optionsPanel.getFilename(id),
|
||||||
options: this.optionsPanel.getOptions(id)
|
options: this.optionsPanel.getOptions(id)
|
||||||
});
|
});
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
deluge.client.web.add_torrents(torrents, {
|
deluge.client.web.add_torrents(torrents, {
|
||||||
success: function(result) {
|
success: function(result) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
this.clear();
|
this.clear();
|
||||||
this.hide();
|
this.hide();
|
||||||
},
|
},
|
||||||
|
|
||||||
onCancelClick: function() {
|
onCancelClick: function() {
|
||||||
this.clear();
|
this.clear();
|
||||||
this.hide();
|
this.hide();
|
||||||
},
|
},
|
||||||
|
|
||||||
onFile: function() {
|
onFile: function() {
|
||||||
if (!this.file) this.file = new Deluge.add.FileWindow();
|
if (!this.file) this.file = new Deluge.add.FileWindow();
|
||||||
this.file.show();
|
this.file.show();
|
||||||
},
|
},
|
||||||
|
|
||||||
onHide: function() {
|
onHide: function() {
|
||||||
this.optionsPanel.setActiveTab(0);
|
this.optionsPanel.setActiveTab(0);
|
||||||
this.optionsPanel.files.setDisabled(true);
|
this.optionsPanel.files.setDisabled(true);
|
||||||
this.optionsPanel.form.setDisabled(true);
|
this.optionsPanel.form.setDisabled(true);
|
||||||
},
|
},
|
||||||
|
|
||||||
onRemove: function() {
|
onRemove: function() {
|
||||||
if (!this.list.getSelectionCount()) return;
|
if (!this.list.getSelectionCount()) return;
|
||||||
var torrent = this.list.getSelectedRecords()[0];
|
var torrent = this.list.getSelectedRecords()[0];
|
||||||
this.list.getStore().remove(torrent);
|
this.list.getStore().remove(torrent);
|
||||||
this.optionsPanel.clear();
|
this.optionsPanel.clear();
|
||||||
|
|
||||||
if (this.torrents && this.torrents[torrent.id]) delete this.torrents[torrent.id];
|
if (this.torrents && this.torrents[torrent.id]) delete this.torrents[torrent.id];
|
||||||
},
|
},
|
||||||
|
|
||||||
onSelect: function(list, selections) {
|
onSelect: function(list, selections) {
|
||||||
if (selections.length) {
|
if (selections.length) {
|
||||||
var record = this.list.getRecord(selections[0]);
|
var record = this.list.getRecord(selections[0]);
|
||||||
this.optionsPanel.setTorrent(record.get('info_hash'));
|
this.optionsPanel.setTorrent(record.get('info_hash'));
|
||||||
this.optionsPanel.files.setDisabled(false);
|
this.optionsPanel.files.setDisabled(false);
|
||||||
this.optionsPanel.form.setDisabled(false);
|
this.optionsPanel.form.setDisabled(false);
|
||||||
} else {
|
} else {
|
||||||
this.optionsPanel.files.setDisabled(true);
|
this.optionsPanel.files.setDisabled(true);
|
||||||
this.optionsPanel.form.setDisabled(true);
|
this.optionsPanel.form.setDisabled(true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onShow: function() {
|
onShow: function() {
|
||||||
if (!this.url) {
|
if (!this.url) {
|
||||||
this.url = new Deluge.add.UrlWindow();
|
this.url = new Deluge.add.UrlWindow();
|
||||||
this.url.on('beforeadd', this.onTorrentBeforeAdd, this);
|
this.url.on('beforeadd', this.onTorrentBeforeAdd, this);
|
||||||
this.url.on('add', this.onTorrentAdd, this);
|
this.url.on('add', this.onTorrentAdd, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.file) {
|
if (!this.file) {
|
||||||
this.file = new Deluge.add.FileWindow();
|
this.file = new Deluge.add.FileWindow();
|
||||||
this.file.on('beforeadd', this.onTorrentBeforeAdd, this);
|
this.file.on('beforeadd', this.onTorrentBeforeAdd, this);
|
||||||
this.file.on('add', this.onTorrentAdd, this);
|
this.file.on('add', this.onTorrentAdd, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.optionsPanel.form.getDefaults();
|
this.optionsPanel.form.getDefaults();
|
||||||
},
|
},
|
||||||
|
|
||||||
onTorrentBeforeAdd: function(torrentId, text) {
|
onTorrentBeforeAdd: function(torrentId, text) {
|
||||||
var store = this.list.getStore();
|
var store = this.list.getStore();
|
||||||
store.loadData([[torrentId, null, text]], true);
|
store.loadData([[torrentId, null, text]], true);
|
||||||
},
|
},
|
||||||
|
|
||||||
onTorrentAdd: function(torrentId, info) {
|
onTorrentAdd: function(torrentId, info) {
|
||||||
var r = this.list.getStore().getById(torrentId);
|
var r = this.list.getStore().getById(torrentId);
|
||||||
if (!info) {
|
if (!info) {
|
||||||
Ext.MessageBox.show({
|
Ext.MessageBox.show({
|
||||||
title: _('Error'),
|
title: _('Error'),
|
||||||
msg: _('Not a valid torrent'),
|
msg: _('Not a valid torrent'),
|
||||||
buttons: Ext.MessageBox.OK,
|
buttons: Ext.MessageBox.OK,
|
||||||
modal: false,
|
modal: false,
|
||||||
icon: Ext.MessageBox.ERROR,
|
icon: Ext.MessageBox.ERROR,
|
||||||
iconCls: 'x-deluge-icon-error'
|
iconCls: 'x-deluge-icon-error'
|
||||||
});
|
});
|
||||||
this.list.getStore().remove(r);
|
this.list.getStore().remove(r);
|
||||||
} else {
|
} else {
|
||||||
r.set('info_hash', info['info_hash']);
|
r.set('info_hash', info['info_hash']);
|
||||||
r.set('text', info['name']);
|
r.set('text', info['name']);
|
||||||
this.list.getStore().commitChanges();
|
this.list.getStore().commitChanges();
|
||||||
this.optionsPanel.addTorrent(info);
|
this.optionsPanel.addTorrent(info);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onUrl: function(button, event) {
|
onUrl: function(button, event) {
|
||||||
this.url.show();
|
this.url.show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -37,80 +37,80 @@ Ext.ns('Deluge.add');
|
|||||||
*/
|
*/
|
||||||
Deluge.add.FileWindow = Ext.extend(Deluge.add.Window, {
|
Deluge.add.FileWindow = Ext.extend(Deluge.add.Window, {
|
||||||
|
|
||||||
title: _('Add from File'),
|
title: _('Add from File'),
|
||||||
layout: 'fit',
|
layout: 'fit',
|
||||||
width: 350,
|
width: 350,
|
||||||
height: 115,
|
height: 115,
|
||||||
modal: true,
|
modal: true,
|
||||||
plain: true,
|
plain: true,
|
||||||
buttonAlign: 'center',
|
buttonAlign: 'center',
|
||||||
closeAction: 'hide',
|
closeAction: 'hide',
|
||||||
bodyStyle: 'padding: 10px 5px;',
|
bodyStyle: 'padding: 10px 5px;',
|
||||||
iconCls: 'x-deluge-add-file',
|
iconCls: 'x-deluge-add-file',
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.add.FileWindow.superclass.initComponent.call(this);
|
Deluge.add.FileWindow.superclass.initComponent.call(this);
|
||||||
this.addButton(_('Add'), this.onAddClick, this);
|
this.addButton(_('Add'), this.onAddClick, this);
|
||||||
|
|
||||||
this.form = this.add({
|
this.form = this.add({
|
||||||
xtype: 'form',
|
xtype: 'form',
|
||||||
baseCls: 'x-plain',
|
baseCls: 'x-plain',
|
||||||
labelWidth: 35,
|
labelWidth: 35,
|
||||||
autoHeight: true,
|
autoHeight: true,
|
||||||
fileUpload: true,
|
fileUpload: true,
|
||||||
items: [{
|
items: [{
|
||||||
xtype: 'fileuploadfield',
|
xtype: 'fileuploadfield',
|
||||||
id: 'torrentFile',
|
id: 'torrentFile',
|
||||||
width: 280,
|
width: 280,
|
||||||
emptyText: _('Select a torrent'),
|
emptyText: _('Select a torrent'),
|
||||||
fieldLabel: _('File'),
|
fieldLabel: _('File'),
|
||||||
name: 'file',
|
name: 'file',
|
||||||
buttonCfg: {
|
buttonCfg: {
|
||||||
text: _('Browse') + '...'
|
text: _('Browse') + '...'
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onAddClick: function(field, e) {
|
onAddClick: function(field, e) {
|
||||||
if (this.form.getForm().isValid()) {
|
if (this.form.getForm().isValid()) {
|
||||||
this.torrentId = this.createTorrentId();
|
this.torrentId = this.createTorrentId();
|
||||||
this.form.getForm().submit({
|
this.form.getForm().submit({
|
||||||
url: '/upload',
|
url: '/upload',
|
||||||
waitMsg: _('Uploading your torrent...'),
|
waitMsg: _('Uploading your torrent...'),
|
||||||
failure: this.onUploadFailure,
|
failure: this.onUploadFailure,
|
||||||
success: this.onUploadSuccess,
|
success: this.onUploadSuccess,
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
var name = this.form.getForm().findField('torrentFile').value;
|
var name = this.form.getForm().findField('torrentFile').value;
|
||||||
name = name.split('\\').slice(-1)[0];
|
name = name.split('\\').slice(-1)[0];
|
||||||
this.fireEvent('beforeadd', this.torrentId, name);
|
this.fireEvent('beforeadd', this.torrentId, name);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onGotInfo: function(info, obj, response, request) {
|
onGotInfo: function(info, obj, response, request) {
|
||||||
info['filename'] = request.options.filename;
|
info['filename'] = request.options.filename;
|
||||||
this.fireEvent('add', this.torrentId, info);
|
this.fireEvent('add', this.torrentId, info);
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onUploadFailure: function(form, action) {
|
onUploadFailure: function(form, action) {
|
||||||
this.hide();
|
this.hide();
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onUploadSuccess: function(fp, upload) {
|
onUploadSuccess: function(fp, upload) {
|
||||||
this.hide();
|
this.hide();
|
||||||
if (upload.result.success) {
|
if (upload.result.success) {
|
||||||
var filename = upload.result.files[0];
|
var filename = upload.result.files[0];
|
||||||
this.form.getForm().findField('torrentFile').setValue('');
|
this.form.getForm().findField('torrentFile').setValue('');
|
||||||
deluge.client.web.get_torrent_info(filename, {
|
deluge.client.web.get_torrent_info(filename, {
|
||||||
success: this.onGotInfo,
|
success: this.onGotInfo,
|
||||||
scope: this,
|
scope: this,
|
||||||
filename: filename
|
filename: filename
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -37,78 +37,78 @@ Ext.ns('Deluge.add');
|
|||||||
*/
|
*/
|
||||||
Deluge.add.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
|
Deluge.add.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
|
||||||
|
|
||||||
layout: 'fit',
|
layout: 'fit',
|
||||||
title: _('Files'),
|
title: _('Files'),
|
||||||
|
|
||||||
autoScroll: true,
|
autoScroll: true,
|
||||||
animate: false,
|
animate: false,
|
||||||
border: false,
|
border: false,
|
||||||
disabled: true,
|
disabled: true,
|
||||||
rootVisible: false,
|
rootVisible: false,
|
||||||
|
|
||||||
columns: [{
|
columns: [{
|
||||||
header: _('Filename'),
|
header: _('Filename'),
|
||||||
width: 295,
|
width: 295,
|
||||||
dataIndex: 'filename'
|
dataIndex: 'filename'
|
||||||
},{
|
},{
|
||||||
header: _('Size'),
|
header: _('Size'),
|
||||||
width: 60,
|
width: 60,
|
||||||
dataIndex: 'size',
|
dataIndex: 'size',
|
||||||
tpl: new Ext.XTemplate('{size:this.fsize}', {
|
tpl: new Ext.XTemplate('{size:this.fsize}', {
|
||||||
fsize: function(v) {
|
fsize: function(v) {
|
||||||
return fsize(v);
|
return fsize(v);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},{
|
},{
|
||||||
header: _('Download'),
|
header: _('Download'),
|
||||||
width: 65,
|
width: 65,
|
||||||
dataIndex: 'download',
|
dataIndex: 'download',
|
||||||
tpl: new Ext.XTemplate('{download:this.format}', {
|
tpl: new Ext.XTemplate('{download:this.format}', {
|
||||||
format: function(v) {
|
format: function(v) {
|
||||||
return '<div rel="chkbox" class="x-grid3-check-col'+(v?'-on':'')+'"> </div>';
|
return '<div rel="chkbox" class="x-grid3-check-col'+(v?'-on':'')+'"> </div>';
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}],
|
}],
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.add.FilesTab.superclass.initComponent.call(this);
|
Deluge.add.FilesTab.superclass.initComponent.call(this);
|
||||||
this.on('click', this.onNodeClick, this);
|
this.on('click', this.onNodeClick, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
clearFiles: function() {
|
clearFiles: function() {
|
||||||
var root = this.getRootNode();
|
var root = this.getRootNode();
|
||||||
if (!root.hasChildNodes()) return;
|
if (!root.hasChildNodes()) return;
|
||||||
root.cascade(function(node) {
|
root.cascade(function(node) {
|
||||||
if (!node.parentNode || !node.getOwnerTree()) return;
|
if (!node.parentNode || !node.getOwnerTree()) return;
|
||||||
node.remove();
|
node.remove();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
setDownload: function(node, value, suppress) {
|
setDownload: function(node, value, suppress) {
|
||||||
node.attributes.download = value;
|
node.attributes.download = value;
|
||||||
node.ui.updateColumns();
|
node.ui.updateColumns();
|
||||||
|
|
||||||
if (node.isLeaf()) {
|
if (node.isLeaf()) {
|
||||||
if (!suppress) {
|
if (!suppress) {
|
||||||
return this.fireEvent('fileschecked', [node], value, !value);
|
return this.fireEvent('fileschecked', [node], value, !value);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var nodes = [node];
|
var nodes = [node];
|
||||||
node.cascade(function(n) {
|
node.cascade(function(n) {
|
||||||
n.attributes.download = value;
|
n.attributes.download = value;
|
||||||
n.ui.updateColumns();
|
n.ui.updateColumns();
|
||||||
nodes.push(n);
|
nodes.push(n);
|
||||||
}, this);
|
}, this);
|
||||||
if (!suppress) {
|
if (!suppress) {
|
||||||
return this.fireEvent('fileschecked', nodes, value, !value);
|
return this.fireEvent('fileschecked', nodes, value, !value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onNodeClick: function(node, e) {
|
onNodeClick: function(node, e) {
|
||||||
var el = new Ext.Element(e.target);
|
var el = new Ext.Element(e.target);
|
||||||
if (el.getAttribute('rel') == 'chkbox') {
|
if (el.getAttribute('rel') == 'chkbox') {
|
||||||
this.setDownload(node, !node.attributes.download);
|
this.setDownload(node, !node.attributes.download);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -33,127 +33,127 @@ Ext.ns('Deluge.add');
|
|||||||
|
|
||||||
Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
|
Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
|
||||||
|
|
||||||
torrents: {},
|
torrents: {},
|
||||||
|
|
||||||
// layout options
|
// layout options
|
||||||
region: 'south',
|
region: 'south',
|
||||||
margins: '5 5 5 5',
|
margins: '5 5 5 5',
|
||||||
activeTab: 0,
|
activeTab: 0,
|
||||||
height: 220,
|
height: 220,
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.add.OptionsPanel.superclass.initComponent.call(this);
|
Deluge.add.OptionsPanel.superclass.initComponent.call(this);
|
||||||
this.files = this.add(new Deluge.add.FilesTab());
|
this.files = this.add(new Deluge.add.FilesTab());
|
||||||
this.form = this.add(new Deluge.add.OptionsTab());
|
this.form = this.add(new Deluge.add.OptionsTab());
|
||||||
|
|
||||||
this.files.on('fileschecked', this.onFilesChecked, this);
|
this.files.on('fileschecked', this.onFilesChecked, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
addTorrent: function(torrent) {
|
addTorrent: function(torrent) {
|
||||||
this.torrents[torrent['info_hash']] = torrent;
|
this.torrents[torrent['info_hash']] = torrent;
|
||||||
var fileIndexes = {};
|
var fileIndexes = {};
|
||||||
this.walkFileTree(torrent['files_tree'], function(filename, type, entry, parent) {
|
this.walkFileTree(torrent['files_tree'], function(filename, type, entry, parent) {
|
||||||
if (type != 'file') return;
|
if (type != 'file') return;
|
||||||
fileIndexes[entry.index] = entry.download;
|
fileIndexes[entry.index] = entry.download;
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
var priorities = [];
|
var priorities = [];
|
||||||
Ext.each(Ext.keys(fileIndexes), function(index) {
|
Ext.each(Ext.keys(fileIndexes), function(index) {
|
||||||
priorities[index] = fileIndexes[index];
|
priorities[index] = fileIndexes[index];
|
||||||
});
|
});
|
||||||
|
|
||||||
var oldId = this.form.optionsManager.changeId(torrent['info_hash'], true);
|
var oldId = this.form.optionsManager.changeId(torrent['info_hash'], true);
|
||||||
this.form.optionsManager.setDefault('file_priorities', priorities);
|
this.form.optionsManager.setDefault('file_priorities', priorities);
|
||||||
this.form.optionsManager.changeId(oldId, true);
|
this.form.optionsManager.changeId(oldId, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
clear: function() {
|
clear: function() {
|
||||||
this.files.clearFiles();
|
this.files.clearFiles();
|
||||||
this.form.optionsManager.resetAll();
|
this.form.optionsManager.resetAll();
|
||||||
},
|
},
|
||||||
|
|
||||||
getFilename: function(torrentId) {
|
getFilename: function(torrentId) {
|
||||||
return this.torrents[torrentId]['filename'];
|
return this.torrents[torrentId]['filename'];
|
||||||
},
|
},
|
||||||
|
|
||||||
getOptions: function(torrentId) {
|
getOptions: function(torrentId) {
|
||||||
var oldId = this.form.optionsManager.changeId(torrentId, true);
|
var oldId = this.form.optionsManager.changeId(torrentId, true);
|
||||||
var options = this.form.optionsManager.get();
|
var options = this.form.optionsManager.get();
|
||||||
this.form.optionsManager.changeId(oldId, true);
|
this.form.optionsManager.changeId(oldId, true);
|
||||||
Ext.each(options['file_priorities'], function(priority, index) {
|
Ext.each(options['file_priorities'], function(priority, index) {
|
||||||
options['file_priorities'][index] = (priority) ? 1 : 0;
|
options['file_priorities'][index] = (priority) ? 1 : 0;
|
||||||
});
|
});
|
||||||
return options;
|
return options;
|
||||||
},
|
},
|
||||||
|
|
||||||
setTorrent: function(torrentId) {
|
setTorrent: function(torrentId) {
|
||||||
if (!torrentId) return;
|
if (!torrentId) return;
|
||||||
|
|
||||||
this.torrentId = torrentId;
|
this.torrentId = torrentId;
|
||||||
this.form.optionsManager.changeId(torrentId);
|
this.form.optionsManager.changeId(torrentId);
|
||||||
|
|
||||||
this.files.clearFiles();
|
this.files.clearFiles();
|
||||||
var root = this.files.getRootNode();
|
var root = this.files.getRootNode();
|
||||||
var priorities = this.form.optionsManager.get('file_priorities');
|
var priorities = this.form.optionsManager.get('file_priorities');
|
||||||
|
|
||||||
this.walkFileTree(this.torrents[torrentId]['files_tree'], function(filename, type, entry, parentNode) {
|
this.walkFileTree(this.torrents[torrentId]['files_tree'], function(filename, type, entry, parentNode) {
|
||||||
var node = new Ext.tree.TreeNode({
|
var node = new Ext.tree.TreeNode({
|
||||||
download: (entry.index) ? priorities[entry.index] : true,
|
download: (entry.index) ? priorities[entry.index] : true,
|
||||||
filename: filename,
|
filename: filename,
|
||||||
fileindex: entry.index,
|
fileindex: entry.index,
|
||||||
leaf: type != 'dir',
|
leaf: type != 'dir',
|
||||||
size: entry.length
|
size: entry.length
|
||||||
});
|
});
|
||||||
parentNode.appendChild(node);
|
parentNode.appendChild(node);
|
||||||
if (type == 'dir') return node;
|
if (type == 'dir') return node;
|
||||||
}, this, root);
|
}, this, root);
|
||||||
root.firstChild.expand();
|
root.firstChild.expand();
|
||||||
},
|
},
|
||||||
|
|
||||||
walkFileTree: function(files, callback, scope, parentNode) {
|
walkFileTree: function(files, callback, scope, parentNode) {
|
||||||
for (var filename in files.contents) {
|
for (var filename in files.contents) {
|
||||||
var entry = files.contents[filename];
|
var entry = files.contents[filename];
|
||||||
var type = entry.type;
|
var type = entry.type;
|
||||||
|
|
||||||
if (scope) {
|
if (scope) {
|
||||||
var ret = callback.apply(scope, [filename, type, entry, parentNode]);
|
var ret = callback.apply(scope, [filename, type, entry, parentNode]);
|
||||||
} else {
|
} else {
|
||||||
var ret = callback(filename, type, entry, parentNode);
|
var ret = callback(filename, type, entry, parentNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == 'dir') this.walkFileTree(entry, callback, scope, ret);
|
if (type == 'dir') this.walkFileTree(entry, callback, scope, ret);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onFilesChecked: function(nodes, newValue, oldValue) {
|
onFilesChecked: function(nodes, newValue, oldValue) {
|
||||||
if (this.form.optionsManager.get('compact_allocation')) {
|
if (this.form.optionsManager.get('compact_allocation')) {
|
||||||
Ext.Msg.show({
|
Ext.Msg.show({
|
||||||
title: _('Unable to set file priority!'),
|
title: _('Unable to set file priority!'),
|
||||||
msg: _('File prioritization is unavailable when using Compact allocation. Would you like to switch to Full allocation?'),
|
msg: _('File prioritization is unavailable when using Compact allocation. Would you like to switch to Full allocation?'),
|
||||||
buttons: Ext.Msg.YESNO,
|
buttons: Ext.Msg.YESNO,
|
||||||
fn: function(result) {
|
fn: function(result) {
|
||||||
if (result == 'yes') {
|
if (result == 'yes') {
|
||||||
this.form.optionsManager.update('compact_allocation', false);
|
this.form.optionsManager.update('compact_allocation', false);
|
||||||
Ext.each(nodes, function(node) {
|
Ext.each(nodes, function(node) {
|
||||||
if (node.attributes.fileindex < 0) return;
|
if (node.attributes.fileindex < 0) return;
|
||||||
var priorities = this.form.optionsManager.get('file_priorities');
|
var priorities = this.form.optionsManager.get('file_priorities');
|
||||||
priorities[node.attributes.fileindex] = newValue;
|
priorities[node.attributes.fileindex] = newValue;
|
||||||
this.form.optionsManager.update('file_priorities', priorities);
|
this.form.optionsManager.update('file_priorities', priorities);
|
||||||
}, this);
|
}, this);
|
||||||
} else {
|
} else {
|
||||||
this.files.setDownload(nodes[0], oldValue, true);
|
this.files.setDownload(nodes[0], oldValue, true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
scope: this,
|
scope: this,
|
||||||
icon: Ext.MessageBox.QUESTION
|
icon: Ext.MessageBox.QUESTION
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
Ext.each(nodes, function(node) {
|
Ext.each(nodes, function(node) {
|
||||||
if (node.attributes.fileindex < 0) return;
|
if (node.attributes.fileindex < 0) return;
|
||||||
var priorities = this.form.optionsManager.get('file_priorities');
|
var priorities = this.form.optionsManager.get('file_priorities');
|
||||||
priorities[node.attributes.fileindex] = newValue;
|
priorities[node.attributes.fileindex] = newValue;
|
||||||
this.form.optionsManager.update('file_priorities', priorities);
|
this.form.optionsManager.update('file_priorities', priorities);
|
||||||
}, this);
|
}, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -37,148 +37,148 @@ Ext.ns('Deluge.add');
|
|||||||
*/
|
*/
|
||||||
Deluge.add.OptionsTab = Ext.extend(Ext.form.FormPanel, {
|
Deluge.add.OptionsTab = Ext.extend(Ext.form.FormPanel, {
|
||||||
|
|
||||||
title: _('Options'),
|
title: _('Options'),
|
||||||
height: 170,
|
height: 170,
|
||||||
|
|
||||||
border: false,
|
border: false,
|
||||||
bodyStyle: 'padding: 5px',
|
bodyStyle: 'padding: 5px',
|
||||||
disabled: true,
|
disabled: true,
|
||||||
labelWidth: 1,
|
labelWidth: 1,
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.add.OptionsTab.superclass.initComponent.call(this);
|
Deluge.add.OptionsTab.superclass.initComponent.call(this);
|
||||||
|
|
||||||
this.optionsManager = new Deluge.MultiOptionsManager();
|
this.optionsManager = new Deluge.MultiOptionsManager();
|
||||||
|
|
||||||
var fieldset = this.add({
|
var fieldset = this.add({
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
title: _('Download Location'),
|
title: _('Download Location'),
|
||||||
border: false,
|
border: false,
|
||||||
autoHeight: true,
|
autoHeight: true,
|
||||||
defaultType: 'textfield',
|
defaultType: 'textfield',
|
||||||
labelWidth: 1,
|
labelWidth: 1,
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
style: 'padding-bottom: 5px; margin-bottom: 0px;'
|
style: 'padding-bottom: 5px; margin-bottom: 0px;'
|
||||||
});
|
});
|
||||||
|
|
||||||
this.optionsManager.bind('download_location', fieldset.add({
|
this.optionsManager.bind('download_location', fieldset.add({
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
name: 'download_location',
|
name: 'download_location',
|
||||||
width: 400,
|
width: 400,
|
||||||
labelSeparator: ''
|
labelSeparator: ''
|
||||||
}));
|
}));
|
||||||
|
|
||||||
var panel = this.add({
|
var panel = this.add({
|
||||||
border: false,
|
border: false,
|
||||||
layout: 'column',
|
layout: 'column',
|
||||||
defaultType: 'fieldset'
|
defaultType: 'fieldset'
|
||||||
});
|
});
|
||||||
fieldset = panel.add({
|
fieldset = panel.add({
|
||||||
title: _('Allocation'),
|
title: _('Allocation'),
|
||||||
border: false,
|
border: false,
|
||||||
autoHeight: true,
|
autoHeight: true,
|
||||||
defaultType: 'radio',
|
defaultType: 'radio',
|
||||||
width: 100
|
width: 100
|
||||||
});
|
});
|
||||||
|
|
||||||
this.optionsManager.bind('compact_allocation', fieldset.add({
|
this.optionsManager.bind('compact_allocation', fieldset.add({
|
||||||
xtype: 'radiogroup',
|
xtype: 'radiogroup',
|
||||||
columns: 1,
|
columns: 1,
|
||||||
vertical: true,
|
vertical: true,
|
||||||
labelSeparator: '',
|
labelSeparator: '',
|
||||||
items: [{
|
items: [{
|
||||||
name: 'compact_allocation',
|
name: 'compact_allocation',
|
||||||
value: false,
|
value: false,
|
||||||
inputValue: false,
|
inputValue: false,
|
||||||
boxLabel: _('Full'),
|
boxLabel: _('Full'),
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
labelSeparator: ''
|
labelSeparator: ''
|
||||||
}, {
|
}, {
|
||||||
name: 'compact_allocation',
|
name: 'compact_allocation',
|
||||||
value: true,
|
value: true,
|
||||||
inputValue: true,
|
inputValue: true,
|
||||||
boxLabel: _('Compact'),
|
boxLabel: _('Compact'),
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
labelSeparator: ''
|
labelSeparator: ''
|
||||||
}]
|
}]
|
||||||
}));
|
}));
|
||||||
|
|
||||||
fieldset = panel.add({
|
fieldset = panel.add({
|
||||||
title: _('Bandwidth'),
|
title: _('Bandwidth'),
|
||||||
border: false,
|
border: false,
|
||||||
autoHeight: true,
|
autoHeight: true,
|
||||||
labelWidth: 100,
|
labelWidth: 100,
|
||||||
width: 200,
|
width: 200,
|
||||||
defaultType: 'spinnerfield'
|
defaultType: 'spinnerfield'
|
||||||
});
|
});
|
||||||
this.optionsManager.bind('max_download_speed', fieldset.add({
|
this.optionsManager.bind('max_download_speed', fieldset.add({
|
||||||
fieldLabel: _('Max Down Speed'),
|
fieldLabel: _('Max Down Speed'),
|
||||||
labelStyle: 'margin-left: 10px',
|
labelStyle: 'margin-left: 10px',
|
||||||
name: 'max_download_speed',
|
name: 'max_download_speed',
|
||||||
width: 60
|
width: 60
|
||||||
}));
|
}));
|
||||||
this.optionsManager.bind('max_upload_speed', fieldset.add({
|
this.optionsManager.bind('max_upload_speed', fieldset.add({
|
||||||
fieldLabel: _('Max Up Speed'),
|
fieldLabel: _('Max Up Speed'),
|
||||||
labelStyle: 'margin-left: 10px',
|
labelStyle: 'margin-left: 10px',
|
||||||
name: 'max_upload_speed',
|
name: 'max_upload_speed',
|
||||||
width: 60
|
width: 60
|
||||||
}));
|
}));
|
||||||
this.optionsManager.bind('max_connections', fieldset.add({
|
this.optionsManager.bind('max_connections', fieldset.add({
|
||||||
fieldLabel: _('Max Connections'),
|
fieldLabel: _('Max Connections'),
|
||||||
labelStyle: 'margin-left: 10px',
|
labelStyle: 'margin-left: 10px',
|
||||||
name: 'max_connections',
|
name: 'max_connections',
|
||||||
width: 60
|
width: 60
|
||||||
}));
|
}));
|
||||||
this.optionsManager.bind('max_upload_slots', fieldset.add({
|
this.optionsManager.bind('max_upload_slots', fieldset.add({
|
||||||
fieldLabel: _('Max Upload Slots'),
|
fieldLabel: _('Max Upload Slots'),
|
||||||
labelStyle: 'margin-left: 10px',
|
labelStyle: 'margin-left: 10px',
|
||||||
name: 'max_upload_slots',
|
name: 'max_upload_slots',
|
||||||
width: 60
|
width: 60
|
||||||
}));
|
}));
|
||||||
|
|
||||||
fieldset = panel.add({
|
fieldset = panel.add({
|
||||||
title: _('General'),
|
title: _('General'),
|
||||||
border: false,
|
border: false,
|
||||||
autoHeight: true,
|
autoHeight: true,
|
||||||
defaultType: 'checkbox'
|
defaultType: 'checkbox'
|
||||||
});
|
});
|
||||||
this.optionsManager.bind('add_paused', fieldset.add({
|
this.optionsManager.bind('add_paused', fieldset.add({
|
||||||
name: 'add_paused',
|
name: 'add_paused',
|
||||||
boxLabel: _('Add In Paused State'),
|
boxLabel: _('Add In Paused State'),
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
labelSeparator: ''
|
labelSeparator: ''
|
||||||
}));
|
}));
|
||||||
this.optionsManager.bind('prioritize_first_last_pieces', fieldset.add({
|
this.optionsManager.bind('prioritize_first_last_pieces', fieldset.add({
|
||||||
name: 'prioritize_first_last_pieces',
|
name: 'prioritize_first_last_pieces',
|
||||||
boxLabel: _('Prioritize First/Last Pieces'),
|
boxLabel: _('Prioritize First/Last Pieces'),
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
labelSeparator: ''
|
labelSeparator: ''
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
getDefaults: function() {
|
getDefaults: function() {
|
||||||
var keys = ['add_paused','compact_allocation','download_location',
|
var keys = ['add_paused','compact_allocation','download_location',
|
||||||
'max_connections_per_torrent','max_download_speed_per_torrent',
|
'max_connections_per_torrent','max_download_speed_per_torrent',
|
||||||
'max_upload_slots_per_torrent','max_upload_speed_per_torrent',
|
'max_upload_slots_per_torrent','max_upload_speed_per_torrent',
|
||||||
'prioritize_first_last_pieces'];
|
'prioritize_first_last_pieces'];
|
||||||
|
|
||||||
deluge.client.core.get_config_values(keys, {
|
deluge.client.core.get_config_values(keys, {
|
||||||
success: function(config) {
|
success: function(config) {
|
||||||
var options = {
|
var options = {
|
||||||
'file_priorities': [],
|
'file_priorities': [],
|
||||||
'add_paused': config.add_paused,
|
'add_paused': config.add_paused,
|
||||||
'compact_allocation': config.compact_allocation,
|
'compact_allocation': config.compact_allocation,
|
||||||
'download_location': config.download_location,
|
'download_location': config.download_location,
|
||||||
'max_connections': config.max_connections_per_torrent,
|
'max_connections': config.max_connections_per_torrent,
|
||||||
'max_download_speed': config.max_download_speed_per_torrent,
|
'max_download_speed': config.max_download_speed_per_torrent,
|
||||||
'max_upload_slots': config.max_upload_slots_per_torrent,
|
'max_upload_slots': config.max_upload_slots_per_torrent,
|
||||||
'max_upload_speed': config.max_upload_speed_per_torrent,
|
'max_upload_speed': config.max_upload_speed_per_torrent,
|
||||||
'prioritize_first_last_pieces': config.prioritize_first_last_pieces
|
'prioritize_first_last_pieces': config.prioritize_first_last_pieces
|
||||||
}
|
}
|
||||||
this.optionsManager.options = options;
|
this.optionsManager.options = options;
|
||||||
this.optionsManager.resetAll();
|
this.optionsManager.resetAll();
|
||||||
},
|
},
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -45,9 +45,9 @@ Deluge.add.Window = Ext.extend(Ext.Window, {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an id for the torrent before we have any info about it.
|
* Create an id for the torrent before we have any info about it.
|
||||||
*/
|
*/
|
||||||
createTorrentId: function() {
|
createTorrentId: function() {
|
||||||
return new Date().getTime();
|
return new Date().getTime();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,27 +43,27 @@ Ext.namespace('Deluge.data');
|
|||||||
* @param {Object} data The peer data
|
* @param {Object} data The peer data
|
||||||
*/
|
*/
|
||||||
Deluge.data.Peer = Ext.data.Record.create([
|
Deluge.data.Peer = Ext.data.Record.create([
|
||||||
{
|
{
|
||||||
name: 'country',
|
name: 'country',
|
||||||
type: 'string'
|
type: 'string'
|
||||||
}, {
|
}, {
|
||||||
name: 'ip',
|
name: 'ip',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
sortType: Deluge.data.SortTypes.asIPAddress
|
sortType: Deluge.data.SortTypes.asIPAddress
|
||||||
}, {
|
}, {
|
||||||
name: 'client',
|
name: 'client',
|
||||||
type: 'string'
|
type: 'string'
|
||||||
}, {
|
}, {
|
||||||
name: 'progress',
|
name: 'progress',
|
||||||
type: 'float'
|
type: 'float'
|
||||||
}, {
|
}, {
|
||||||
name: 'down_speed',
|
name: 'down_speed',
|
||||||
type: 'int'
|
type: 'int'
|
||||||
}, {
|
}, {
|
||||||
name: 'up_speed',
|
name: 'up_speed',
|
||||||
type: 'int'
|
type: 'int'
|
||||||
}, {
|
}, {
|
||||||
name: 'seed',
|
name: 'seed',
|
||||||
type: 'int'
|
type: 'int'
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|||||||
@ -41,12 +41,12 @@ Ext.namespace('Deluge.data');
|
|||||||
* @singleton
|
* @singleton
|
||||||
*/
|
*/
|
||||||
Deluge.data.SortTypes = {
|
Deluge.data.SortTypes = {
|
||||||
asIPAddress: function(value) {
|
asIPAddress: function(value) {
|
||||||
var d = value.match(/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\:(\d+)/);
|
var d = value.match(/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\:(\d+)/);
|
||||||
return ((((((+d[1])*256)+(+d[2]))*256)+(+d[3]))*256)+(+d[4]);
|
return ((((((+d[1])*256)+(+d[2]))*256)+(+d[3]))*256)+(+d[4]);
|
||||||
},
|
},
|
||||||
|
|
||||||
asQueuePosition: function(value) {
|
asQueuePosition: function(value) {
|
||||||
return (value > -1) ? value : Number.MAX_VALUE;
|
return (value > -1) ? value : Number.MAX_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,52 +43,52 @@ Ext.namespace('Deluge.data');
|
|||||||
* @param {Object} data The torrents data
|
* @param {Object} data The torrents data
|
||||||
*/
|
*/
|
||||||
Deluge.data.Torrent = Ext.data.Record.create([{
|
Deluge.data.Torrent = Ext.data.Record.create([{
|
||||||
name: 'queue',
|
name: 'queue',
|
||||||
type: 'int'
|
type: 'int'
|
||||||
}, {
|
}, {
|
||||||
name: 'name',
|
name: 'name',
|
||||||
type: 'string'
|
type: 'string'
|
||||||
}, {
|
}, {
|
||||||
name: 'total_size',
|
name: 'total_size',
|
||||||
type: 'int'
|
type: 'int'
|
||||||
}, {
|
}, {
|
||||||
name: 'state',
|
name: 'state',
|
||||||
type: 'string'
|
type: 'string'
|
||||||
}, {
|
}, {
|
||||||
name: 'progress',
|
name: 'progress',
|
||||||
type: 'int'
|
type: 'int'
|
||||||
}, {
|
}, {
|
||||||
name: 'num_seeds',
|
name: 'num_seeds',
|
||||||
type: 'int'
|
type: 'int'
|
||||||
}, {
|
}, {
|
||||||
name: 'total_seeds',
|
name: 'total_seeds',
|
||||||
type: 'int'
|
type: 'int'
|
||||||
}, {
|
}, {
|
||||||
name: 'num_peers',
|
name: 'num_peers',
|
||||||
type: 'int'
|
type: 'int'
|
||||||
}, {
|
}, {
|
||||||
name: 'total_peers',
|
name: 'total_peers',
|
||||||
type: 'int'
|
type: 'int'
|
||||||
}, {
|
}, {
|
||||||
name: 'download_payload_rate',
|
name: 'download_payload_rate',
|
||||||
type: 'int'
|
type: 'int'
|
||||||
}, {
|
}, {
|
||||||
name: 'upload_payload_rate',
|
name: 'upload_payload_rate',
|
||||||
type: 'int'
|
type: 'int'
|
||||||
}, {
|
}, {
|
||||||
name: 'eta',
|
name: 'eta',
|
||||||
type: 'int'
|
type: 'int'
|
||||||
}, {
|
}, {
|
||||||
name: 'ratio',
|
name: 'ratio',
|
||||||
type: 'float'
|
type: 'float'
|
||||||
}, {
|
}, {
|
||||||
name: 'distributed_copies',
|
name: 'distributed_copies',
|
||||||
type: 'float'
|
type: 'float'
|
||||||
}, {
|
}, {
|
||||||
name: 'time_added',
|
name: 'time_added',
|
||||||
type: 'int'
|
type: 'int'
|
||||||
}, {
|
}, {
|
||||||
name: 'tracker_host',
|
name: 'tracker_host',
|
||||||
type: 'string'
|
type: 'string'
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|||||||
@ -36,69 +36,69 @@ Ext.namespace('Deluge.details');
|
|||||||
*/
|
*/
|
||||||
Deluge.details.DetailsPanel = Ext.extend(Ext.TabPanel, {
|
Deluge.details.DetailsPanel = Ext.extend(Ext.TabPanel, {
|
||||||
|
|
||||||
region: 'south',
|
region: 'south',
|
||||||
id: 'torrentDetails',
|
id: 'torrentDetails',
|
||||||
split: true,
|
split: true,
|
||||||
height: 210,
|
height: 210,
|
||||||
minSize: 100,
|
minSize: 100,
|
||||||
collapsible: true,
|
collapsible: true,
|
||||||
margins: '0 5 5 5',
|
margins: '0 5 5 5',
|
||||||
activeTab: 0,
|
activeTab: 0,
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.details.DetailsPanel.superclass.initComponent.call(this);
|
Deluge.details.DetailsPanel.superclass.initComponent.call(this);
|
||||||
this.add(new Deluge.details.StatusTab());
|
this.add(new Deluge.details.StatusTab());
|
||||||
this.add(new Deluge.details.DetailsTab());
|
this.add(new Deluge.details.DetailsTab());
|
||||||
this.add(new Deluge.details.FilesTab());
|
this.add(new Deluge.details.FilesTab());
|
||||||
this.add(new Deluge.details.PeersTab());
|
this.add(new Deluge.details.PeersTab());
|
||||||
this.add(new Deluge.details.OptionsTab());
|
this.add(new Deluge.details.OptionsTab());
|
||||||
},
|
},
|
||||||
|
|
||||||
clear: function() {
|
clear: function() {
|
||||||
this.items.each(function(panel) {
|
this.items.each(function(panel) {
|
||||||
if (panel.clear) {
|
if (panel.clear) {
|
||||||
panel.clear.defer(100, panel);
|
panel.clear.defer(100, panel);
|
||||||
panel.disable();
|
panel.disable();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
update: function(tab) {
|
update: function(tab) {
|
||||||
var torrent = deluge.torrents.getSelected();
|
var torrent = deluge.torrents.getSelected();
|
||||||
if (!torrent) {
|
if (!torrent) {
|
||||||
this.clear();
|
this.clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.items.each(function(tab) {
|
this.items.each(function(tab) {
|
||||||
if (tab.disabled) tab.enable();
|
if (tab.disabled) tab.enable();
|
||||||
});
|
});
|
||||||
|
|
||||||
tab = tab || this.getActiveTab();
|
tab = tab || this.getActiveTab();
|
||||||
if (tab.update) tab.update(torrent.id);
|
if (tab.update) tab.update(torrent.id);
|
||||||
},
|
},
|
||||||
|
|
||||||
/* Event Handlers */
|
/* Event Handlers */
|
||||||
|
|
||||||
// We need to add the events in onRender since Deluge.Torrents hasn't
|
// We need to add the events in onRender since Deluge.Torrents hasn't
|
||||||
// been created yet.
|
// been created yet.
|
||||||
onRender: function(ct, position) {
|
onRender: function(ct, position) {
|
||||||
Deluge.details.DetailsPanel.superclass.onRender.call(this, ct, position);
|
Deluge.details.DetailsPanel.superclass.onRender.call(this, ct, position);
|
||||||
deluge.events.on('disconnect', this.clear, this);
|
deluge.events.on('disconnect', this.clear, this);
|
||||||
deluge.torrents.on('rowclick', this.onTorrentsClick, this);
|
deluge.torrents.on('rowclick', this.onTorrentsClick, this);
|
||||||
this.on('tabchange', this.onTabChange, this);
|
this.on('tabchange', this.onTabChange, this);
|
||||||
|
|
||||||
deluge.torrents.getSelectionModel().on('selectionchange', function(selModel) {
|
deluge.torrents.getSelectionModel().on('selectionchange', function(selModel) {
|
||||||
if (!selModel.hasSelection()) this.clear();
|
if (!selModel.hasSelection()) this.clear();
|
||||||
}, this);
|
}, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
onTabChange: function(panel, tab) {
|
onTabChange: function(panel, tab) {
|
||||||
this.update(tab);
|
this.update(tab);
|
||||||
},
|
},
|
||||||
|
|
||||||
onTorrentsClick: function(grid, rowIndex, e) {
|
onTorrentsClick: function(grid, rowIndex, e) {
|
||||||
this.update();
|
this.update();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,115 +1,115 @@
|
|||||||
/*
|
/*
|
||||||
Script: Deluge.Details.Details.js
|
Script: Deluge.Details.Details.js
|
||||||
The details tab displayed in the details panel.
|
The details tab displayed in the details panel.
|
||||||
|
|
||||||
Copyright:
|
Copyright:
|
||||||
(C) Damien Churchill 2009-2010 <damoxc@gmail.com>
|
(C) Damien Churchill 2009-2010 <damoxc@gmail.com>
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation; either version 3, or (at your option)
|
the Free Software Foundation; either version 3, or (at your option)
|
||||||
any later version.
|
any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, write to:
|
along with this program. If not, write to:
|
||||||
The Free Software Foundation, Inc.,
|
The Free Software Foundation, Inc.,
|
||||||
51 Franklin Street, Fifth Floor
|
51 Franklin Street, Fifth Floor
|
||||||
Boston, MA 02110-1301, USA.
|
Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
In addition, as a special exception, the copyright holders give
|
In addition, as a special exception, the copyright holders give
|
||||||
permission to link the code of portions of this program with the OpenSSL
|
permission to link the code of portions of this program with the OpenSSL
|
||||||
library.
|
library.
|
||||||
You must obey the GNU General Public License in all respects for all of
|
You must obey the GNU General Public License in all respects for all of
|
||||||
the code used other than OpenSSL. If you modify file(s) with this
|
the code used other than OpenSSL. If you modify file(s) with this
|
||||||
exception, you may extend this exception to your version of the file(s),
|
exception, you may extend this exception to your version of the file(s),
|
||||||
but you are not obligated to do so. If you do not wish to do so, delete
|
but you are not obligated to do so. If you do not wish to do so, delete
|
||||||
this exception statement from your version. If you delete this exception
|
this exception statement from your version. If you delete this exception
|
||||||
statement from all source files in the program, then also delete it here.
|
statement from all source files in the program, then also delete it here.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Deluge.details.DetailsTab = Ext.extend(Ext.Panel, {
|
Deluge.details.DetailsTab = Ext.extend(Ext.Panel, {
|
||||||
title: _('Details'),
|
title: _('Details'),
|
||||||
|
|
||||||
fields: {},
|
fields: {},
|
||||||
|
|
||||||
queuedItems: {},
|
queuedItems: {},
|
||||||
|
|
||||||
oldData: {},
|
oldData: {},
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.details.DetailsTab.superclass.initComponent.call(this);
|
Deluge.details.DetailsTab.superclass.initComponent.call(this);
|
||||||
this.addItem('torrent_name', _('Name'));
|
this.addItem('torrent_name', _('Name'));
|
||||||
this.addItem('hash', _('Hash'));
|
this.addItem('hash', _('Hash'));
|
||||||
this.addItem('path', _('Path'));
|
this.addItem('path', _('Path'));
|
||||||
this.addItem('size', _('Total Size'));
|
this.addItem('size', _('Total Size'));
|
||||||
this.addItem('files', _('# of files'));
|
this.addItem('files', _('# of files'));
|
||||||
this.addItem('comment', _('Comment'));
|
this.addItem('comment', _('Comment'));
|
||||||
this.addItem('status', _('Status'));
|
this.addItem('status', _('Status'));
|
||||||
this.addItem('tracker', _('Tracker'));
|
this.addItem('tracker', _('Tracker'));
|
||||||
},
|
},
|
||||||
|
|
||||||
onRender: function(ct, position) {
|
onRender: function(ct, position) {
|
||||||
Deluge.details.DetailsTab.superclass.onRender.call(this, ct, position);
|
Deluge.details.DetailsTab.superclass.onRender.call(this, ct, position);
|
||||||
this.body.setStyle('padding', '10px');
|
this.body.setStyle('padding', '10px');
|
||||||
this.dl = Ext.DomHelper.append(this.body, {tag: 'dl'}, true);
|
this.dl = Ext.DomHelper.append(this.body, {tag: 'dl'}, true);
|
||||||
|
|
||||||
for (var id in this.queuedItems) {
|
for (var id in this.queuedItems) {
|
||||||
this.doAddItem(id, this.queuedItems[id]);
|
this.doAddItem(id, this.queuedItems[id]);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
addItem: function(id, label) {
|
addItem: function(id, label) {
|
||||||
if (!this.rendered) {
|
if (!this.rendered) {
|
||||||
this.queuedItems[id] = label;
|
this.queuedItems[id] = label;
|
||||||
} else {
|
} else {
|
||||||
this.doAddItem(id, label);
|
this.doAddItem(id, label);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
doAddItem: function(id, label) {
|
doAddItem: function(id, label) {
|
||||||
Ext.DomHelper.append(this.dl, {tag: 'dt', cls: id, html: label + ':'});
|
Ext.DomHelper.append(this.dl, {tag: 'dt', cls: id, html: label + ':'});
|
||||||
this.fields[id] = Ext.DomHelper.append(this.dl, {tag: 'dd', cls: id, html: ''}, true);
|
this.fields[id] = Ext.DomHelper.append(this.dl, {tag: 'dd', cls: id, html: ''}, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
clear: function() {
|
clear: function() {
|
||||||
if (!this.fields) return;
|
if (!this.fields) return;
|
||||||
for (var k in this.fields) {
|
for (var k in this.fields) {
|
||||||
this.fields[k].dom.innerHTML = '';
|
this.fields[k].dom.innerHTML = '';
|
||||||
}
|
}
|
||||||
this.oldData = {}
|
this.oldData = {}
|
||||||
},
|
},
|
||||||
|
|
||||||
update: function(torrentId) {
|
update: function(torrentId) {
|
||||||
deluge.client.web.get_torrent_status(torrentId, Deluge.Keys.Details, {
|
deluge.client.web.get_torrent_status(torrentId, Deluge.Keys.Details, {
|
||||||
success: this.onRequestComplete,
|
success: this.onRequestComplete,
|
||||||
scope: this,
|
scope: this,
|
||||||
torrentId: torrentId
|
torrentId: torrentId
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onRequestComplete: function(torrent, request, response, options) {
|
onRequestComplete: function(torrent, request, response, options) {
|
||||||
var data = {
|
var data = {
|
||||||
torrent_name: torrent.name,
|
torrent_name: torrent.name,
|
||||||
hash: options.options.torrentId,
|
hash: options.options.torrentId,
|
||||||
path: torrent.save_path,
|
path: torrent.save_path,
|
||||||
size: fsize(torrent.total_size),
|
size: fsize(torrent.total_size),
|
||||||
files: torrent.num_files,
|
files: torrent.num_files,
|
||||||
status: torrent.message,
|
status: torrent.message,
|
||||||
tracker: torrent.tracker,
|
tracker: torrent.tracker,
|
||||||
comment: torrent.comment
|
comment: torrent.comment
|
||||||
};
|
};
|
||||||
|
|
||||||
for (var field in this.fields) {
|
for (var field in this.fields) {
|
||||||
if (!Ext.isDefined(data[field])) continue; // this is a field we aren't responsible for.
|
if (!Ext.isDefined(data[field])) continue; // this is a field we aren't responsible for.
|
||||||
if (data[field] == this.oldData[field]) continue;
|
if (data[field] == this.oldData[field]) continue;
|
||||||
this.fields[field].dom.innerHTML = Ext.escapeHTML(data[field]);
|
this.fields[field].dom.innerHTML = Ext.escapeHTML(data[field]);
|
||||||
}
|
}
|
||||||
this.oldData = data;
|
this.oldData = data;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -29,200 +29,200 @@
|
|||||||
* this exception statement from your version. If you delete this exception
|
* this exception statement from your version. If you delete this exception
|
||||||
* statement from all source files in the program, then also delete it here.
|
* statement from all source files in the program, then also delete it here.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Deluge.details.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
|
Deluge.details.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
|
||||||
|
|
||||||
title: _('Files'),
|
title: _('Files'),
|
||||||
|
|
||||||
autoScroll: true,
|
autoScroll: true,
|
||||||
rootVisible: false,
|
rootVisible: false,
|
||||||
|
|
||||||
columns: [{
|
columns: [{
|
||||||
header: _('Filename'),
|
header: _('Filename'),
|
||||||
width: 330,
|
width: 330,
|
||||||
dataIndex: 'filename'
|
dataIndex: 'filename'
|
||||||
}, {
|
}, {
|
||||||
header: _('Size'),
|
header: _('Size'),
|
||||||
width: 150,
|
width: 150,
|
||||||
dataIndex: 'size',
|
dataIndex: 'size',
|
||||||
tpl: new Ext.XTemplate('{size:this.fsize}', {
|
tpl: new Ext.XTemplate('{size:this.fsize}', {
|
||||||
fsize: function(v) { return fsize(v); }
|
fsize: function(v) { return fsize(v); }
|
||||||
})
|
})
|
||||||
}, {
|
}, {
|
||||||
xtype: 'tgrendercolumn',
|
xtype: 'tgrendercolumn',
|
||||||
header: _('Progress'),
|
header: _('Progress'),
|
||||||
width: 150,
|
width: 150,
|
||||||
dataIndex: 'progress',
|
dataIndex: 'progress',
|
||||||
renderer: function(v) {
|
renderer: function(v) {
|
||||||
var progress = v * 100;
|
var progress = v * 100;
|
||||||
return Deluge.progressBar(progress, this.col.width, progress.toFixed(2) + '%', 0);
|
return Deluge.progressBar(progress, this.col.width, progress.toFixed(2) + '%', 0);
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
header: _('Priority'),
|
header: _('Priority'),
|
||||||
width: 150,
|
width: 150,
|
||||||
dataIndex: 'priority',
|
dataIndex: 'priority',
|
||||||
tpl: new Ext.XTemplate('<tpl if="!isNaN(priority)">' +
|
tpl: new Ext.XTemplate('<tpl if="!isNaN(priority)">' +
|
||||||
'<div class="{priority:this.getClass}">' +
|
'<div class="{priority:this.getClass}">' +
|
||||||
'{priority:this.getName}' +
|
'{priority:this.getName}' +
|
||||||
'</div></tpl>', {
|
'</div></tpl>', {
|
||||||
getClass: function(v) {
|
getClass: function(v) {
|
||||||
return FILE_PRIORITY_CSS[v];
|
return FILE_PRIORITY_CSS[v];
|
||||||
},
|
},
|
||||||
|
|
||||||
getName: function(v) {
|
getName: function(v) {
|
||||||
return _(FILE_PRIORITY[v]);
|
return _(FILE_PRIORITY[v]);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}],
|
}],
|
||||||
|
|
||||||
selModel: new Ext.tree.MultiSelectionModel(),
|
selModel: new Ext.tree.MultiSelectionModel(),
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.details.FilesTab.superclass.initComponent.call(this);
|
Deluge.details.FilesTab.superclass.initComponent.call(this);
|
||||||
this.setRootNode(new Ext.tree.TreeNode({text: 'Files'}));
|
this.setRootNode(new Ext.tree.TreeNode({text: 'Files'}));
|
||||||
},
|
},
|
||||||
|
|
||||||
clear: function() {
|
clear: function() {
|
||||||
var root = this.getRootNode();
|
var root = this.getRootNode();
|
||||||
if (!root.hasChildNodes()) return;
|
if (!root.hasChildNodes()) return;
|
||||||
root.cascade(function(node) {
|
root.cascade(function(node) {
|
||||||
var parentNode = node.parentNode;
|
var parentNode = node.parentNode;
|
||||||
if (!parentNode) return;
|
if (!parentNode) return;
|
||||||
if (!parentNode.ownerTree) return;
|
if (!parentNode.ownerTree) return;
|
||||||
parentNode.removeChild(node);
|
parentNode.removeChild(node);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
createFileTree: function(files) {
|
createFileTree: function(files) {
|
||||||
function walk(files, parentNode) {
|
function walk(files, parentNode) {
|
||||||
for (var file in files.contents) {
|
for (var file in files.contents) {
|
||||||
var item = files.contents[file];
|
var item = files.contents[file];
|
||||||
if (item.type == 'dir') {
|
if (item.type == 'dir') {
|
||||||
walk(item, parentNode.appendChild(new Ext.tree.TreeNode({
|
walk(item, parentNode.appendChild(new Ext.tree.TreeNode({
|
||||||
text: file,
|
text: file,
|
||||||
filename: file,
|
filename: file,
|
||||||
size: item.size,
|
size: item.size,
|
||||||
progress: item.progress,
|
progress: item.progress,
|
||||||
priority: item.priority
|
priority: item.priority
|
||||||
})));
|
})));
|
||||||
} else {
|
} else {
|
||||||
parentNode.appendChild(new Ext.tree.TreeNode({
|
parentNode.appendChild(new Ext.tree.TreeNode({
|
||||||
text: file,
|
text: file,
|
||||||
filename: file,
|
filename: file,
|
||||||
fileIndex: item.index,
|
fileIndex: item.index,
|
||||||
size: item.size,
|
size: item.size,
|
||||||
progress: item.progress,
|
progress: item.progress,
|
||||||
priority: item.priority,
|
priority: item.priority,
|
||||||
leaf: true,
|
leaf: true,
|
||||||
iconCls: 'x-deluge-file',
|
iconCls: 'x-deluge-file',
|
||||||
uiProvider: Ext.ux.tree.TreeGridNodeUI
|
uiProvider: Ext.ux.tree.TreeGridNodeUI
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var root = this.getRootNode();
|
var root = this.getRootNode();
|
||||||
walk(files, root);
|
walk(files, root);
|
||||||
root.firstChild.expand();
|
root.firstChild.expand();
|
||||||
},
|
},
|
||||||
|
|
||||||
update: function(torrentId) {
|
update: function(torrentId) {
|
||||||
if (this.torrentId != torrentId) {
|
if (this.torrentId != torrentId) {
|
||||||
this.clear();
|
this.clear();
|
||||||
this.torrentId = torrentId;
|
this.torrentId = torrentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
deluge.client.web.get_torrent_files(torrentId, {
|
deluge.client.web.get_torrent_files(torrentId, {
|
||||||
success: this.onRequestComplete,
|
success: this.onRequestComplete,
|
||||||
scope: this,
|
scope: this,
|
||||||
torrentId: torrentId
|
torrentId: torrentId
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
updateFileTree: function(files) {
|
updateFileTree: function(files) {
|
||||||
function walk(files, parentNode) {
|
function walk(files, parentNode) {
|
||||||
for (var file in files.contents) {
|
for (var file in files.contents) {
|
||||||
var item = files.contents[file];
|
var item = files.contents[file];
|
||||||
var node = parentNode.findChild('filename', file);
|
var node = parentNode.findChild('filename', file);
|
||||||
node.attributes.size = item.size;
|
node.attributes.size = item.size;
|
||||||
node.attributes.progress = item.progress;
|
node.attributes.progress = item.progress;
|
||||||
node.attributes.priority = item.priority;
|
node.attributes.priority = item.priority;
|
||||||
node.ui.updateColumns();
|
node.ui.updateColumns();
|
||||||
if (item.type == 'dir') {
|
if (item.type == 'dir') {
|
||||||
walk(item, node);
|
walk(item, node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
walk(files, this.getRootNode());
|
walk(files, this.getRootNode());
|
||||||
},
|
},
|
||||||
|
|
||||||
onRender: function(ct, position) {
|
onRender: function(ct, position) {
|
||||||
Deluge.details.FilesTab.superclass.onRender.call(this, ct, position);
|
Deluge.details.FilesTab.superclass.onRender.call(this, ct, position);
|
||||||
deluge.menus.filePriorities.on('itemclick', this.onItemClick, this);
|
deluge.menus.filePriorities.on('itemclick', this.onItemClick, this);
|
||||||
this.on('contextmenu', this.onContextMenu, this);
|
this.on('contextmenu', this.onContextMenu, this);
|
||||||
this.sorter = new Ext.tree.TreeSorter(this, {
|
this.sorter = new Ext.tree.TreeSorter(this, {
|
||||||
folderSort: true
|
folderSort: true
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onContextMenu: function(node, e) {
|
onContextMenu: function(node, e) {
|
||||||
e.stopEvent();
|
e.stopEvent();
|
||||||
var selModel = this.getSelectionModel();
|
var selModel = this.getSelectionModel();
|
||||||
if (selModel.getSelectedNodes().length < 2) {
|
if (selModel.getSelectedNodes().length < 2) {
|
||||||
selModel.clearSelections();
|
selModel.clearSelections();
|
||||||
node.select();
|
node.select();
|
||||||
}
|
}
|
||||||
deluge.menus.filePriorities.showAt(e.getPoint());
|
deluge.menus.filePriorities.showAt(e.getPoint());
|
||||||
},
|
},
|
||||||
|
|
||||||
onItemClick: function(baseItem, e) {
|
onItemClick: function(baseItem, e) {
|
||||||
switch (baseItem.id) {
|
switch (baseItem.id) {
|
||||||
case 'expandAll':
|
case 'expandAll':
|
||||||
this.expandAll();
|
this.expandAll();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
var indexes = {};
|
var indexes = {};
|
||||||
function walk(node) {
|
function walk(node) {
|
||||||
if (Ext.isEmpty(node.attributes.fileIndex)) return;
|
if (Ext.isEmpty(node.attributes.fileIndex)) return;
|
||||||
indexes[node.attributes.fileIndex] = node.attributes.priority;
|
indexes[node.attributes.fileIndex] = node.attributes.priority;
|
||||||
}
|
}
|
||||||
this.getRootNode().cascade(walk);
|
this.getRootNode().cascade(walk);
|
||||||
|
|
||||||
var nodes = this.getSelectionModel().getSelectedNodes();
|
var nodes = this.getSelectionModel().getSelectedNodes();
|
||||||
Ext.each(nodes, function(node) {
|
Ext.each(nodes, function(node) {
|
||||||
if (!node.isLeaf()) {
|
if (!node.isLeaf()) {
|
||||||
function setPriorities(node) {
|
function setPriorities(node) {
|
||||||
if (Ext.isEmpty(node.attributes.fileIndex)) return;
|
if (Ext.isEmpty(node.attributes.fileIndex)) return;
|
||||||
indexes[node.attributes.fileIndex] = baseItem.filePriority;
|
indexes[node.attributes.fileIndex] = baseItem.filePriority;
|
||||||
}
|
}
|
||||||
node.cascade(setPriorities);
|
node.cascade(setPriorities);
|
||||||
} else if (!Ext.isEmpty(node.attributes.fileIndex)) {
|
} else if (!Ext.isEmpty(node.attributes.fileIndex)) {
|
||||||
indexes[node.attributes.fileIndex] = baseItem.filePriority;
|
indexes[node.attributes.fileIndex] = baseItem.filePriority;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var priorities = new Array(Ext.keys(indexes).length);
|
var priorities = new Array(Ext.keys(indexes).length);
|
||||||
for (var index in indexes) {
|
for (var index in indexes) {
|
||||||
priorities[index] = indexes[index];
|
priorities[index] = indexes[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
deluge.client.core.set_torrent_file_priorities(this.torrentId, priorities, {
|
deluge.client.core.set_torrent_file_priorities(this.torrentId, priorities, {
|
||||||
success: function() {
|
success: function() {
|
||||||
Ext.each(nodes, function(node) {
|
Ext.each(nodes, function(node) {
|
||||||
node.setColumnValue(3, baseItem.filePriority);
|
node.setColumnValue(3, baseItem.filePriority);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onRequestComplete: function(files, options) {
|
onRequestComplete: function(files, options) {
|
||||||
if (!this.getRootNode().hasChildNodes()) {
|
if (!this.getRootNode().hasChildNodes()) {
|
||||||
this.createFileTree(files);
|
this.createFileTree(files);
|
||||||
} else {
|
} else {
|
||||||
this.updateFileTree(files);
|
this.updateFileTree(files);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -33,382 +33,382 @@
|
|||||||
|
|
||||||
Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
|
Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
|
||||||
|
|
||||||
constructor: function(config) {
|
constructor: function(config) {
|
||||||
config = Ext.apply({
|
config = Ext.apply({
|
||||||
autoScroll: true,
|
autoScroll: true,
|
||||||
bodyStyle: 'padding: 5px;',
|
bodyStyle: 'padding: 5px;',
|
||||||
border: false,
|
border: false,
|
||||||
cls: 'x-deluge-options',
|
cls: 'x-deluge-options',
|
||||||
defaults: {
|
defaults: {
|
||||||
autoHeight: true,
|
autoHeight: true,
|
||||||
labelWidth: 1,
|
labelWidth: 1,
|
||||||
defaultType: 'checkbox'
|
defaultType: 'checkbox'
|
||||||
},
|
},
|
||||||
deferredRender: false,
|
deferredRender: false,
|
||||||
layout: 'column',
|
layout: 'column',
|
||||||
title: _('Options')
|
title: _('Options')
|
||||||
}, config);
|
}, config);
|
||||||
Deluge.details.OptionsTab.superclass.constructor.call(this, config);
|
Deluge.details.OptionsTab.superclass.constructor.call(this, config);
|
||||||
},
|
},
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.details.OptionsTab.superclass.initComponent.call(this);
|
Deluge.details.OptionsTab.superclass.initComponent.call(this);
|
||||||
|
|
||||||
this.fieldsets = {}, this.fields = {};
|
this.fieldsets = {}, this.fields = {};
|
||||||
this.optionsManager = new Deluge.MultiOptionsManager({
|
this.optionsManager = new Deluge.MultiOptionsManager({
|
||||||
options: {
|
options: {
|
||||||
'max_download_speed': -1,
|
'max_download_speed': -1,
|
||||||
'max_upload_speed': -1,
|
'max_upload_speed': -1,
|
||||||
'max_connections': -1,
|
'max_connections': -1,
|
||||||
'max_upload_slots': -1,
|
'max_upload_slots': -1,
|
||||||
'auto_managed': false,
|
'auto_managed': false,
|
||||||
'stop_at_ratio': false,
|
'stop_at_ratio': false,
|
||||||
'stop_ratio': 2.0,
|
'stop_ratio': 2.0,
|
||||||
'remove_at_ratio': false,
|
'remove_at_ratio': false,
|
||||||
'move_completed': false,
|
'move_completed': false,
|
||||||
'move_completed_path': '',
|
'move_completed_path': '',
|
||||||
'private': false,
|
'private': false,
|
||||||
'prioritize_first_last': false
|
'prioritize_first_last': false
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Bandwidth Options
|
* Bandwidth Options
|
||||||
*/
|
*/
|
||||||
this.fieldsets.bandwidth = this.add({
|
this.fieldsets.bandwidth = this.add({
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
defaultType: 'spinnerfield',
|
defaultType: 'spinnerfield',
|
||||||
bodyStyle: 'padding: 5px',
|
bodyStyle: 'padding: 5px',
|
||||||
|
|
||||||
layout: 'table',
|
layout: 'table',
|
||||||
layoutConfig: {columns: 3},
|
layoutConfig: {columns: 3},
|
||||||
labelWidth: 150,
|
labelWidth: 150,
|
||||||
|
|
||||||
style: 'margin-left: 10px; margin-right: 5px; padding: 5px',
|
style: 'margin-left: 10px; margin-right: 5px; padding: 5px',
|
||||||
title: _('Bandwidth'),
|
title: _('Bandwidth'),
|
||||||
width: 250
|
width: 250
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Max Download Speed
|
* Max Download Speed
|
||||||
*/
|
*/
|
||||||
this.fieldsets.bandwidth.add({
|
this.fieldsets.bandwidth.add({
|
||||||
xtype: 'label',
|
xtype: 'label',
|
||||||
text: _('Max Download Speed'),
|
text: _('Max Download Speed'),
|
||||||
forId: 'max_download_speed',
|
forId: 'max_download_speed',
|
||||||
cls: 'x-deluge-options-label'
|
cls: 'x-deluge-options-label'
|
||||||
});
|
});
|
||||||
this.fields.max_download_speed = this.fieldsets.bandwidth.add({
|
this.fields.max_download_speed = this.fieldsets.bandwidth.add({
|
||||||
id: 'max_download_speed',
|
id: 'max_download_speed',
|
||||||
name: 'max_download_speed',
|
name: 'max_download_speed',
|
||||||
width: 70,
|
width: 70,
|
||||||
strategy: {
|
strategy: {
|
||||||
xtype: 'number',
|
xtype: 'number',
|
||||||
decimalPrecision: 1,
|
decimalPrecision: 1,
|
||||||
minValue: -1,
|
minValue: -1,
|
||||||
maxValue: 99999
|
maxValue: 99999
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.fieldsets.bandwidth.add({
|
this.fieldsets.bandwidth.add({
|
||||||
xtype: 'label',
|
xtype: 'label',
|
||||||
text: _('KiB/s'),
|
text: _('KiB/s'),
|
||||||
style: 'margin-left: 10px'
|
style: 'margin-left: 10px'
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Max Upload Speed
|
* Max Upload Speed
|
||||||
*/
|
*/
|
||||||
this.fieldsets.bandwidth.add({
|
this.fieldsets.bandwidth.add({
|
||||||
xtype: 'label',
|
xtype: 'label',
|
||||||
text: _('Max Upload Speed'),
|
text: _('Max Upload Speed'),
|
||||||
forId: 'max_upload_speed',
|
forId: 'max_upload_speed',
|
||||||
cls: 'x-deluge-options-label'
|
cls: 'x-deluge-options-label'
|
||||||
});
|
});
|
||||||
this.fields.max_upload_speed = this.fieldsets.bandwidth.add({
|
this.fields.max_upload_speed = this.fieldsets.bandwidth.add({
|
||||||
id: 'max_upload_speed',
|
id: 'max_upload_speed',
|
||||||
name: 'max_upload_speed',
|
name: 'max_upload_speed',
|
||||||
width: 70,
|
width: 70,
|
||||||
value: -1,
|
value: -1,
|
||||||
strategy: {
|
strategy: {
|
||||||
xtype: 'number',
|
xtype: 'number',
|
||||||
decimalPrecision: 1,
|
decimalPrecision: 1,
|
||||||
minValue: -1,
|
minValue: -1,
|
||||||
maxValue: 99999
|
maxValue: 99999
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.fieldsets.bandwidth.add({
|
this.fieldsets.bandwidth.add({
|
||||||
xtype: 'label',
|
xtype: 'label',
|
||||||
text: _('KiB/s'),
|
text: _('KiB/s'),
|
||||||
style: 'margin-left: 10px'
|
style: 'margin-left: 10px'
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Max Connections
|
* Max Connections
|
||||||
*/
|
*/
|
||||||
this.fieldsets.bandwidth.add({
|
this.fieldsets.bandwidth.add({
|
||||||
xtype: 'label',
|
xtype: 'label',
|
||||||
text: _('Max Connections'),
|
text: _('Max Connections'),
|
||||||
forId: 'max_connections',
|
forId: 'max_connections',
|
||||||
cls: 'x-deluge-options-label'
|
cls: 'x-deluge-options-label'
|
||||||
});
|
});
|
||||||
this.fields.max_connections = this.fieldsets.bandwidth.add({
|
this.fields.max_connections = this.fieldsets.bandwidth.add({
|
||||||
id: 'max_connections',
|
id: 'max_connections',
|
||||||
name: 'max_connections',
|
name: 'max_connections',
|
||||||
width: 70,
|
width: 70,
|
||||||
value: -1,
|
value: -1,
|
||||||
strategy: {
|
strategy: {
|
||||||
xtype: 'number',
|
xtype: 'number',
|
||||||
decimalPrecision: 0,
|
decimalPrecision: 0,
|
||||||
minValue: -1,
|
minValue: -1,
|
||||||
maxValue: 99999
|
maxValue: 99999
|
||||||
},
|
},
|
||||||
colspan: 2
|
colspan: 2
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Max Upload Slots
|
* Max Upload Slots
|
||||||
*/
|
*/
|
||||||
this.fieldsets.bandwidth.add({
|
this.fieldsets.bandwidth.add({
|
||||||
xtype: 'label',
|
xtype: 'label',
|
||||||
text: _('Max Upload Slots'),
|
text: _('Max Upload Slots'),
|
||||||
forId: 'max_upload_slots',
|
forId: 'max_upload_slots',
|
||||||
cls: 'x-deluge-options-label'
|
cls: 'x-deluge-options-label'
|
||||||
});
|
});
|
||||||
this.fields.max_upload_slots = this.fieldsets.bandwidth.add({
|
this.fields.max_upload_slots = this.fieldsets.bandwidth.add({
|
||||||
id: 'max_upload_slots',
|
id: 'max_upload_slots',
|
||||||
name: 'max_upload_slots',
|
name: 'max_upload_slots',
|
||||||
width: 70,
|
width: 70,
|
||||||
value: -1,
|
value: -1,
|
||||||
strategy: {
|
strategy: {
|
||||||
xtype: 'number',
|
xtype: 'number',
|
||||||
decimalPrecision: 0,
|
decimalPrecision: 0,
|
||||||
minValue: -1,
|
minValue: -1,
|
||||||
maxValue: 99999
|
maxValue: 99999
|
||||||
},
|
},
|
||||||
colspan: 2
|
colspan: 2
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Queue Options
|
* Queue Options
|
||||||
*/
|
*/
|
||||||
this.fieldsets.queue = this.add({
|
this.fieldsets.queue = this.add({
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
title: _('Queue'),
|
title: _('Queue'),
|
||||||
style: 'margin-left: 5px; margin-right: 5px; padding: 5px',
|
style: 'margin-left: 5px; margin-right: 5px; padding: 5px',
|
||||||
width: 210,
|
width: 210,
|
||||||
|
|
||||||
layout: 'table',
|
layout: 'table',
|
||||||
layoutConfig: {columns: 2},
|
layoutConfig: {columns: 2},
|
||||||
labelWidth: 0,
|
labelWidth: 0,
|
||||||
|
|
||||||
defaults: {
|
defaults: {
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
labelSeparator: ''
|
labelSeparator: ''
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.fields.auto_managed = this.fieldsets.queue.add({
|
this.fields.auto_managed = this.fieldsets.queue.add({
|
||||||
xtype: 'checkbox',
|
xtype: 'checkbox',
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
labelSeparator: '',
|
labelSeparator: '',
|
||||||
name: 'is_auto_managed',
|
name: 'is_auto_managed',
|
||||||
boxLabel: _('Auto Managed'),
|
boxLabel: _('Auto Managed'),
|
||||||
width: 200,
|
width: 200,
|
||||||
colspan: 2
|
colspan: 2
|
||||||
});
|
});
|
||||||
|
|
||||||
this.fields.stop_at_ratio = this.fieldsets.queue.add({
|
this.fields.stop_at_ratio = this.fieldsets.queue.add({
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
labelSeparator: '',
|
labelSeparator: '',
|
||||||
id: 'stop_at_ratio',
|
id: 'stop_at_ratio',
|
||||||
width: 120,
|
width: 120,
|
||||||
boxLabel: _('Stop seed at ratio'),
|
boxLabel: _('Stop seed at ratio'),
|
||||||
handler: this.onStopRatioChecked,
|
handler: this.onStopRatioChecked,
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
|
|
||||||
this.fields.stop_ratio = this.fieldsets.queue.add({
|
this.fields.stop_ratio = this.fieldsets.queue.add({
|
||||||
xtype: 'spinnerfield',
|
xtype: 'spinnerfield',
|
||||||
id: 'stop_ratio',
|
id: 'stop_ratio',
|
||||||
name: 'stop_ratio',
|
name: 'stop_ratio',
|
||||||
disabled: true,
|
disabled: true,
|
||||||
width: 50,
|
width: 50,
|
||||||
value: 2.0,
|
value: 2.0,
|
||||||
strategy: {
|
strategy: {
|
||||||
xtype: 'number',
|
xtype: 'number',
|
||||||
minValue: -1,
|
minValue: -1,
|
||||||
maxValue: 99999,
|
maxValue: 99999,
|
||||||
incrementValue: 0.1,
|
incrementValue: 0.1,
|
||||||
alternateIncrementValue: 1,
|
alternateIncrementValue: 1,
|
||||||
decimalPrecision: 1
|
decimalPrecision: 1
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.fields.remove_at_ratio = this.fieldsets.queue.add({
|
this.fields.remove_at_ratio = this.fieldsets.queue.add({
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
labelSeparator: '',
|
labelSeparator: '',
|
||||||
id: 'remove_at_ratio',
|
id: 'remove_at_ratio',
|
||||||
ctCls: 'x-deluge-indent-checkbox',
|
ctCls: 'x-deluge-indent-checkbox',
|
||||||
bodyStyle: 'padding-left: 10px',
|
bodyStyle: 'padding-left: 10px',
|
||||||
boxLabel: _('Remove at ratio'),
|
boxLabel: _('Remove at ratio'),
|
||||||
disabled: true,
|
disabled: true,
|
||||||
colspan: 2
|
colspan: 2
|
||||||
});
|
});
|
||||||
|
|
||||||
this.fields.move_completed = this.fieldsets.queue.add({
|
this.fields.move_completed = this.fieldsets.queue.add({
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
labelSeparator: '',
|
labelSeparator: '',
|
||||||
id: 'move_completed',
|
id: 'move_completed',
|
||||||
boxLabel: _('Move Completed'),
|
boxLabel: _('Move Completed'),
|
||||||
colspan: 2,
|
colspan: 2,
|
||||||
handler: this.onMoveCompletedChecked,
|
handler: this.onMoveCompletedChecked,
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
|
|
||||||
this.fields.move_completed_path = this.fieldsets.queue.add({
|
this.fields.move_completed_path = this.fieldsets.queue.add({
|
||||||
xtype: 'textfield',
|
xtype: 'textfield',
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
id: 'move_completed_path',
|
id: 'move_completed_path',
|
||||||
colspan: 3,
|
colspan: 3,
|
||||||
bodyStyle: 'margin-left: 20px',
|
bodyStyle: 'margin-left: 20px',
|
||||||
width: 180,
|
width: 180,
|
||||||
disabled: true
|
disabled: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* General Options
|
* General Options
|
||||||
*/
|
*/
|
||||||
this.rightColumn = this.add({
|
this.rightColumn = this.add({
|
||||||
border: false,
|
border: false,
|
||||||
autoHeight: true,
|
autoHeight: true,
|
||||||
style: 'margin-left: 5px',
|
style: 'margin-left: 5px',
|
||||||
width: 210
|
width: 210
|
||||||
});
|
});
|
||||||
|
|
||||||
this.fieldsets.general = this.rightColumn.add({
|
this.fieldsets.general = this.rightColumn.add({
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
autoHeight: true,
|
autoHeight: true,
|
||||||
defaultType: 'checkbox',
|
defaultType: 'checkbox',
|
||||||
title: _('General'),
|
title: _('General'),
|
||||||
layout: 'form'
|
layout: 'form'
|
||||||
});
|
});
|
||||||
|
|
||||||
this.fields['private'] = this.fieldsets.general.add({
|
this.fields['private'] = this.fieldsets.general.add({
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
labelSeparator: '',
|
labelSeparator: '',
|
||||||
boxLabel: _('Private'),
|
boxLabel: _('Private'),
|
||||||
id: 'private',
|
id: 'private',
|
||||||
disabled: true
|
disabled: true
|
||||||
});
|
});
|
||||||
|
|
||||||
this.fields.prioritize_first_last = this.fieldsets.general.add({
|
this.fields.prioritize_first_last = this.fieldsets.general.add({
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
labelSeparator: '',
|
labelSeparator: '',
|
||||||
boxLabel: _('Prioritize First/Last'),
|
boxLabel: _('Prioritize First/Last'),
|
||||||
id: 'prioritize_first_last'
|
id: 'prioritize_first_last'
|
||||||
});
|
});
|
||||||
|
|
||||||
// Bind the fields so the options manager can manage them.
|
// Bind the fields so the options manager can manage them.
|
||||||
for (var id in this.fields) {
|
for (var id in this.fields) {
|
||||||
this.optionsManager.bind(id, this.fields[id]);
|
this.optionsManager.bind(id, this.fields[id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Buttons
|
* Buttons
|
||||||
*/
|
*/
|
||||||
this.buttonPanel = this.rightColumn.add({
|
this.buttonPanel = this.rightColumn.add({
|
||||||
layout: 'hbox',
|
layout: 'hbox',
|
||||||
xtype: 'panel',
|
xtype: 'panel',
|
||||||
border: false
|
border: false
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Edit Trackers button
|
* Edit Trackers button
|
||||||
*/
|
*/
|
||||||
this.buttonPanel.add({
|
this.buttonPanel.add({
|
||||||
id: 'edit_trackers',
|
id: 'edit_trackers',
|
||||||
xtype: 'button',
|
xtype: 'button',
|
||||||
text: _('Edit Trackers'),
|
text: _('Edit Trackers'),
|
||||||
cls: 'x-btn-text-icon',
|
cls: 'x-btn-text-icon',
|
||||||
iconCls: 'x-deluge-edit-trackers',
|
iconCls: 'x-deluge-edit-trackers',
|
||||||
border: false,
|
border: false,
|
||||||
width: 100,
|
width: 100,
|
||||||
handler: this.onEditTrackers,
|
handler: this.onEditTrackers,
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Apply button
|
* Apply button
|
||||||
*/
|
*/
|
||||||
this.buttonPanel.add({
|
this.buttonPanel.add({
|
||||||
id: 'apply',
|
id: 'apply',
|
||||||
xtype: 'button',
|
xtype: 'button',
|
||||||
text: _('Apply'),
|
text: _('Apply'),
|
||||||
style: 'margin-left: 10px;',
|
style: 'margin-left: 10px;',
|
||||||
border: false,
|
border: false,
|
||||||
width: 100,
|
width: 100,
|
||||||
handler: this.onApply,
|
handler: this.onApply,
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onRender: function(ct, position) {
|
onRender: function(ct, position) {
|
||||||
Deluge.details.OptionsTab.superclass.onRender.call(this, ct, position);
|
Deluge.details.OptionsTab.superclass.onRender.call(this, ct, position);
|
||||||
|
|
||||||
// This is another hack I think, so keep an eye out here when upgrading.
|
// This is another hack I think, so keep an eye out here when upgrading.
|
||||||
this.layout = new Ext.layout.ColumnLayout();
|
this.layout = new Ext.layout.ColumnLayout();
|
||||||
this.layout.setContainer(this);
|
this.layout.setContainer(this);
|
||||||
this.doLayout();
|
this.doLayout();
|
||||||
},
|
},
|
||||||
|
|
||||||
clear: function() {
|
clear: function() {
|
||||||
if (this.torrentId == null) return;
|
if (this.torrentId == null) return;
|
||||||
this.torrentId = null;
|
this.torrentId = null;
|
||||||
this.optionsManager.changeId(null);
|
this.optionsManager.changeId(null);
|
||||||
},
|
},
|
||||||
|
|
||||||
reset: function() {
|
reset: function() {
|
||||||
if (this.torrentId) this.optionsManager.reset();
|
if (this.torrentId) this.optionsManager.reset();
|
||||||
},
|
},
|
||||||
|
|
||||||
update: function(torrentId) {
|
update: function(torrentId) {
|
||||||
if (this.torrentId && !torrentId) this.clear(); // we want to clear the pane if we get a null torrent torrentIds
|
if (this.torrentId && !torrentId) this.clear(); // we want to clear the pane if we get a null torrent torrentIds
|
||||||
|
|
||||||
if (!torrentId) return; // we don't care about null torrentIds
|
if (!torrentId) return; // we don't care about null torrentIds
|
||||||
|
|
||||||
if (this.torrentId != torrentId) {
|
if (this.torrentId != torrentId) {
|
||||||
this.torrentId = torrentId;
|
this.torrentId = torrentId;
|
||||||
this.optionsManager.changeId(torrentId);
|
this.optionsManager.changeId(torrentId);
|
||||||
}
|
}
|
||||||
deluge.client.web.get_torrent_status(torrentId, Deluge.Keys.Options, {
|
deluge.client.web.get_torrent_status(torrentId, Deluge.Keys.Options, {
|
||||||
success: this.onRequestComplete,
|
success: this.onRequestComplete,
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onApply: function() {
|
onApply: function() {
|
||||||
var changed = this.optionsManager.getDirty();
|
var changed = this.optionsManager.getDirty();
|
||||||
if (!Ext.isEmpty(changed['prioritize_first_last'])) {
|
if (!Ext.isEmpty(changed['prioritize_first_last'])) {
|
||||||
var value = changed['prioritize_first_last'];
|
var value = changed['prioritize_first_last'];
|
||||||
deluge.client.core.set_torrent_prioritize_first_last(this.torrentId, value, {
|
deluge.client.core.set_torrent_prioritize_first_last(this.torrentId, value, {
|
||||||
success: function() {
|
success: function() {
|
||||||
this.optionsManager.set('prioritize_first_last', value);
|
this.optionsManager.set('prioritize_first_last', value);
|
||||||
},
|
},
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
deluge.client.core.set_torrent_options([this.torrentId], changed, {
|
deluge.client.core.set_torrent_options([this.torrentId], changed, {
|
||||||
success: function() {
|
success: function() {
|
||||||
this.optionsManager.commit();
|
this.optionsManager.commit();
|
||||||
},
|
},
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onEditTrackers: function() {
|
onEditTrackers: function() {
|
||||||
deluge.editTrackers.show();
|
deluge.editTrackers.show();
|
||||||
},
|
},
|
||||||
|
|
||||||
onMoveCompletedChecked: function(checkbox, checked) {
|
onMoveCompletedChecked: function(checkbox, checked) {
|
||||||
this.fields.move_completed_path.setDisabled(!checked);
|
this.fields.move_completed_path.setDisabled(!checked);
|
||||||
@ -417,20 +417,20 @@ Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
|
|||||||
this.fields.move_completed_path.focus();
|
this.fields.move_completed_path.focus();
|
||||||
},
|
},
|
||||||
|
|
||||||
onStopRatioChecked: function(checkbox, checked) {
|
onStopRatioChecked: function(checkbox, checked) {
|
||||||
this.fields.remove_at_ratio.setDisabled(!checked);
|
this.fields.remove_at_ratio.setDisabled(!checked);
|
||||||
this.fields.stop_ratio.setDisabled(!checked);
|
this.fields.stop_ratio.setDisabled(!checked);
|
||||||
},
|
},
|
||||||
|
|
||||||
onRequestComplete: function(torrent, options) {
|
onRequestComplete: function(torrent, options) {
|
||||||
this.fields['private'].setValue(torrent['private']);
|
this.fields['private'].setValue(torrent['private']);
|
||||||
this.fields['private'].setDisabled(true);
|
this.fields['private'].setDisabled(true);
|
||||||
delete torrent['private'];
|
delete torrent['private'];
|
||||||
torrent['auto_managed'] = torrent['is_auto_managed'];
|
torrent['auto_managed'] = torrent['is_auto_managed'];
|
||||||
this.optionsManager.setDefault(torrent);
|
this.optionsManager.setDefault(torrent);
|
||||||
var stop_at_ratio = this.optionsManager.get('stop_at_ratio');
|
var stop_at_ratio = this.optionsManager.get('stop_at_ratio');
|
||||||
this.fields.remove_at_ratio.setDisabled(!stop_at_ratio);
|
this.fields.remove_at_ratio.setDisabled(!stop_at_ratio);
|
||||||
this.fields.stop_ratio.setDisabled(!stop_at_ratio);
|
this.fields.stop_ratio.setDisabled(!stop_at_ratio);
|
||||||
this.fields.move_completed_path.setDisabled(!this.optionsManager.get('move_completed'));
|
this.fields.move_completed_path.setDisabled(!this.optionsManager.get('move_completed'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -31,102 +31,102 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
function flagRenderer(value) {
|
function flagRenderer(value) {
|
||||||
if (!value.replace(' ', '').replace(' ', '')){
|
if (!value.replace(' ', '').replace(' ', '')){
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
return String.format('<img src="flag/{0}" />', value);
|
return String.format('<img src="flag/{0}" />', value);
|
||||||
}
|
}
|
||||||
function peerAddressRenderer(value, p, record) {
|
function peerAddressRenderer(value, p, record) {
|
||||||
var seed = (record.data['seed'] == 1024) ? 'x-deluge-seed' : 'x-deluge-peer'
|
var seed = (record.data['seed'] == 1024) ? 'x-deluge-seed' : 'x-deluge-peer'
|
||||||
return String.format('<div class="{0}">{1}</div>', seed, value);
|
return String.format('<div class="{0}">{1}</div>', seed, value);
|
||||||
}
|
}
|
||||||
function peerProgressRenderer(value) {
|
function peerProgressRenderer(value) {
|
||||||
var progress = (value * 100).toFixed(0);
|
var progress = (value * 100).toFixed(0);
|
||||||
return Deluge.progressBar(progress, this.width - 8, progress + '%');
|
return Deluge.progressBar(progress, this.width - 8, progress + '%');
|
||||||
}
|
}
|
||||||
|
|
||||||
Deluge.details.PeersTab = Ext.extend(Ext.grid.GridPanel, {
|
Deluge.details.PeersTab = Ext.extend(Ext.grid.GridPanel, {
|
||||||
|
|
||||||
// fast way to figure out if we have a peer already.
|
// fast way to figure out if we have a peer already.
|
||||||
peers: {},
|
peers: {},
|
||||||
|
|
||||||
constructor: function(config) {
|
constructor: function(config) {
|
||||||
config = Ext.apply({
|
config = Ext.apply({
|
||||||
title: _('Peers'),
|
title: _('Peers'),
|
||||||
cls: 'x-deluge-peers',
|
cls: 'x-deluge-peers',
|
||||||
store: new Ext.data.Store({
|
store: new Ext.data.Store({
|
||||||
reader: new Ext.data.JsonReader({
|
reader: new Ext.data.JsonReader({
|
||||||
idProperty: 'ip',
|
idProperty: 'ip',
|
||||||
root: 'peers'
|
root: 'peers'
|
||||||
}, Deluge.data.Peer)
|
}, Deluge.data.Peer)
|
||||||
}),
|
}),
|
||||||
columns: [{
|
columns: [{
|
||||||
header: ' ',
|
header: ' ',
|
||||||
width: 30,
|
width: 30,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
renderer: flagRenderer,
|
renderer: flagRenderer,
|
||||||
dataIndex: 'country'
|
dataIndex: 'country'
|
||||||
}, {
|
}, {
|
||||||
header: 'Address',
|
header: 'Address',
|
||||||
width: 125,
|
width: 125,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
renderer: peerAddressRenderer,
|
renderer: peerAddressRenderer,
|
||||||
dataIndex: 'ip'
|
dataIndex: 'ip'
|
||||||
}, {
|
}, {
|
||||||
header: 'Client',
|
header: 'Client',
|
||||||
width: 125,
|
width: 125,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
renderer: fplain,
|
renderer: fplain,
|
||||||
dataIndex: 'client'
|
dataIndex: 'client'
|
||||||
}, {
|
}, {
|
||||||
header: 'Progress',
|
header: 'Progress',
|
||||||
width: 150,
|
width: 150,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
renderer: peerProgressRenderer,
|
renderer: peerProgressRenderer,
|
||||||
dataIndex: 'progress'
|
dataIndex: 'progress'
|
||||||
}, {
|
}, {
|
||||||
header: 'Down Speed',
|
header: 'Down Speed',
|
||||||
width: 100,
|
width: 100,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
renderer: fspeed,
|
renderer: fspeed,
|
||||||
dataIndex: 'down_speed'
|
dataIndex: 'down_speed'
|
||||||
}, {
|
}, {
|
||||||
header: 'Up Speed',
|
header: 'Up Speed',
|
||||||
width: 100,
|
width: 100,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
renderer: fspeed,
|
renderer: fspeed,
|
||||||
dataIndex: 'up_speed'
|
dataIndex: 'up_speed'
|
||||||
}],
|
}],
|
||||||
stripeRows: true,
|
stripeRows: true,
|
||||||
deferredRender:false,
|
deferredRender:false,
|
||||||
autoScroll:true
|
autoScroll:true
|
||||||
}, config);
|
}, config);
|
||||||
Deluge.details.PeersTab.superclass.constructor.call(this, config);
|
Deluge.details.PeersTab.superclass.constructor.call(this, config);
|
||||||
},
|
},
|
||||||
|
|
||||||
clear: function() {
|
clear: function() {
|
||||||
this.getStore().removeAll();
|
this.getStore().removeAll();
|
||||||
this.peers = {};
|
this.peers = {};
|
||||||
},
|
},
|
||||||
|
|
||||||
update: function(torrentId) {
|
update: function(torrentId) {
|
||||||
deluge.client.web.get_torrent_status(torrentId, Deluge.Keys.Peers, {
|
deluge.client.web.get_torrent_status(torrentId, Deluge.Keys.Peers, {
|
||||||
success: this.onRequestComplete,
|
success: this.onRequestComplete,
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onRequestComplete: function(torrent, options) {
|
onRequestComplete: function(torrent, options) {
|
||||||
if (!torrent) return;
|
if (!torrent) return;
|
||||||
|
|
||||||
var store = this.getStore();
|
var store = this.getStore();
|
||||||
var newPeers = [];
|
var newPeers = [];
|
||||||
var addresses = {};
|
var addresses = {};
|
||||||
|
|
||||||
// Go through the peers updating and creating peer records
|
// Go through the peers updating and creating peer records
|
||||||
Ext.each(torrent.peers, function(peer) {
|
Ext.each(torrent.peers, function(peer) {
|
||||||
if (this.peers[peer.ip]) {
|
if (this.peers[peer.ip]) {
|
||||||
var record = store.getById(peer.ip);
|
var record = store.getById(peer.ip);
|
||||||
record.beginEdit();
|
record.beginEdit();
|
||||||
for (var k in peer) {
|
for (var k in peer) {
|
||||||
@ -135,26 +135,26 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
record.endEdit();
|
record.endEdit();
|
||||||
} else {
|
} else {
|
||||||
this.peers[peer.ip] = 1;
|
this.peers[peer.ip] = 1;
|
||||||
newPeers.push(new Deluge.data.Peer(peer, peer.ip));
|
newPeers.push(new Deluge.data.Peer(peer, peer.ip));
|
||||||
}
|
}
|
||||||
addresses[peer.ip] = 1;
|
addresses[peer.ip] = 1;
|
||||||
}, this);
|
}, this);
|
||||||
store.add(newPeers);
|
store.add(newPeers);
|
||||||
|
|
||||||
// Remove any peers that shouldn't be left in the store
|
// Remove any peers that shouldn't be left in the store
|
||||||
store.each(function(record) {
|
store.each(function(record) {
|
||||||
if (!addresses[record.id]) {
|
if (!addresses[record.id]) {
|
||||||
store.remove(record);
|
store.remove(record);
|
||||||
delete this.peers[record.id];
|
delete this.peers[record.id];
|
||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
store.commitChanges();
|
store.commitChanges();
|
||||||
|
|
||||||
var sortState = store.getSortState();
|
var sortState = store.getSortState();
|
||||||
if (!sortState) return;
|
if (!sortState) return;
|
||||||
store.sort(sortState.field, sortState.direction);
|
store.sort(sortState.field, sortState.direction);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|||||||
@ -36,90 +36,90 @@ Ext.ns('Deluge.details');
|
|||||||
* @extends Ext.Panel
|
* @extends Ext.Panel
|
||||||
*/
|
*/
|
||||||
Deluge.details.StatusTab = Ext.extend(Ext.Panel, {
|
Deluge.details.StatusTab = Ext.extend(Ext.Panel, {
|
||||||
title: _('Status'),
|
title: _('Status'),
|
||||||
autoScroll: true,
|
autoScroll: true,
|
||||||
|
|
||||||
onRender: function(ct, position) {
|
onRender: function(ct, position) {
|
||||||
Deluge.details.StatusTab.superclass.onRender.call(this, ct, position);
|
Deluge.details.StatusTab.superclass.onRender.call(this, ct, position);
|
||||||
|
|
||||||
this.progressBar = this.add({
|
this.progressBar = this.add({
|
||||||
xtype: 'progress',
|
xtype: 'progress',
|
||||||
cls: 'x-deluge-status-progressbar'
|
cls: 'x-deluge-status-progressbar'
|
||||||
});
|
});
|
||||||
|
|
||||||
this.status = this.add({
|
this.status = this.add({
|
||||||
cls: 'x-deluge-status',
|
cls: 'x-deluge-status',
|
||||||
id: 'deluge-details-status',
|
id: 'deluge-details-status',
|
||||||
|
|
||||||
border: false,
|
border: false,
|
||||||
width: 1000,
|
width: 1000,
|
||||||
listeners: {
|
listeners: {
|
||||||
'render': {
|
'render': {
|
||||||
fn: function(panel) {
|
fn: function(panel) {
|
||||||
panel.load({
|
panel.load({
|
||||||
url: deluge.config.base + 'render/tab_status.html',
|
url: deluge.config.base + 'render/tab_status.html',
|
||||||
text: _('Loading') + '...'
|
text: _('Loading') + '...'
|
||||||
});
|
});
|
||||||
panel.getUpdater().on('update', this.onPanelUpdate, this);
|
panel.getUpdater().on('update', this.onPanelUpdate, this);
|
||||||
},
|
},
|
||||||
scope: this
|
scope: this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
clear: function() {
|
clear: function() {
|
||||||
this.progressBar.updateProgress(0, ' ');
|
this.progressBar.updateProgress(0, ' ');
|
||||||
for (var k in this.fields) {
|
for (var k in this.fields) {
|
||||||
this.fields[k].innerHTML = '';
|
this.fields[k].innerHTML = '';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
update: function(torrentId) {
|
update: function(torrentId) {
|
||||||
if (!this.fields) this.getFields();
|
if (!this.fields) this.getFields();
|
||||||
deluge.client.web.get_torrent_status(torrentId, Deluge.Keys.Status, {
|
deluge.client.web.get_torrent_status(torrentId, Deluge.Keys.Status, {
|
||||||
success: this.onRequestComplete,
|
success: this.onRequestComplete,
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onPanelUpdate: function(el, response) {
|
onPanelUpdate: function(el, response) {
|
||||||
this.fields = {};
|
this.fields = {};
|
||||||
Ext.each(Ext.query('dd', this.status.body.dom), function(field) {
|
Ext.each(Ext.query('dd', this.status.body.dom), function(field) {
|
||||||
this.fields[field.className] = field;
|
this.fields[field.className] = field;
|
||||||
}, this);
|
}, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
onRequestComplete: function(status) {
|
onRequestComplete: function(status) {
|
||||||
seeders = status.total_seeds > -1 ? status.num_seeds + ' (' + status.total_seeds + ')' : status.num_seeds
|
seeders = status.total_seeds > -1 ? status.num_seeds + ' (' + status.total_seeds + ')' : status.num_seeds
|
||||||
peers = status.total_peers > -1 ? status.num_peers + ' (' + status.total_peers + ')' : status.num_peers
|
peers = status.total_peers > -1 ? status.num_peers + ' (' + status.total_peers + ')' : status.num_peers
|
||||||
var data = {
|
var data = {
|
||||||
downloaded: fsize(status.total_done, true),
|
downloaded: fsize(status.total_done, true),
|
||||||
uploaded: fsize(status.total_uploaded, true),
|
uploaded: fsize(status.total_uploaded, true),
|
||||||
share: (status.ratio == -1) ? '∞' : status.ratio.toFixed(3),
|
share: (status.ratio == -1) ? '∞' : status.ratio.toFixed(3),
|
||||||
announce: ftime(status.next_announce),
|
announce: ftime(status.next_announce),
|
||||||
tracker_status: status.tracker_status,
|
tracker_status: status.tracker_status,
|
||||||
downspeed: (status.download_payload_rate) ? fspeed(status.download_payload_rate) : '0.0 KiB/s',
|
downspeed: (status.download_payload_rate) ? fspeed(status.download_payload_rate) : '0.0 KiB/s',
|
||||||
upspeed: (status.upload_payload_rate) ? fspeed(status.upload_payload_rate) : '0.0 KiB/s',
|
upspeed: (status.upload_payload_rate) ? fspeed(status.upload_payload_rate) : '0.0 KiB/s',
|
||||||
eta: ftime(status.eta),
|
eta: ftime(status.eta),
|
||||||
pieces: status.num_pieces + ' (' + fsize(status.piece_length) + ')',
|
pieces: status.num_pieces + ' (' + fsize(status.piece_length) + ')',
|
||||||
seeders: seeders,
|
seeders: seeders,
|
||||||
peers: peers,
|
peers: peers,
|
||||||
avail: status.distributed_copies.toFixed(3),
|
avail: status.distributed_copies.toFixed(3),
|
||||||
active_time: ftime(status.active_time),
|
active_time: ftime(status.active_time),
|
||||||
seeding_time: ftime(status.seeding_time),
|
seeding_time: ftime(status.seeding_time),
|
||||||
seed_rank: status.seed_rank,
|
seed_rank: status.seed_rank,
|
||||||
time_added: fdate(status.time_added)
|
time_added: fdate(status.time_added)
|
||||||
}
|
}
|
||||||
data.auto_managed = _((status.is_auto_managed) ? 'True' : 'False');
|
data.auto_managed = _((status.is_auto_managed) ? 'True' : 'False');
|
||||||
|
|
||||||
data.downloaded += ' (' + ((status.total_payload_download) ? fsize(status.total_payload_download) : '0.0 KiB') + ')';
|
data.downloaded += ' (' + ((status.total_payload_download) ? fsize(status.total_payload_download) : '0.0 KiB') + ')';
|
||||||
data.uploaded += ' (' + ((status.total_payload_download) ? fsize(status.total_payload_download): '0.0 KiB') + ')';
|
data.uploaded += ' (' + ((status.total_payload_download) ? fsize(status.total_payload_download): '0.0 KiB') + ')';
|
||||||
|
|
||||||
for (var field in this.fields) {
|
for (var field in this.fields) {
|
||||||
this.fields[field].innerHTML = data[field];
|
this.fields[field].innerHTML = data[field];
|
||||||
}
|
}
|
||||||
var text = status.state + ' ' + status.progress.toFixed(2) + '%';
|
var text = status.state + ' ' + status.progress.toFixed(2) + '%';
|
||||||
this.progressBar.updateProgress(status.progress / 100.0, text);
|
this.progressBar.updateProgress(status.progress / 100.0, text);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -36,139 +36,139 @@ Ext.namespace('Deluge.preferences');
|
|||||||
* @extends Ext.form.FormPanel
|
* @extends Ext.form.FormPanel
|
||||||
*/
|
*/
|
||||||
Deluge.preferences.Bandwidth = Ext.extend(Ext.form.FormPanel, {
|
Deluge.preferences.Bandwidth = Ext.extend(Ext.form.FormPanel, {
|
||||||
constructor: function(config) {
|
constructor: function(config) {
|
||||||
config = Ext.apply({
|
config = Ext.apply({
|
||||||
border: false,
|
border: false,
|
||||||
title: _('Bandwidth'),
|
title: _('Bandwidth'),
|
||||||
layout: 'form',
|
layout: 'form',
|
||||||
labelWidth: 10
|
labelWidth: 10
|
||||||
}, config);
|
}, config);
|
||||||
Deluge.preferences.Bandwidth.superclass.constructor.call(this, config);
|
Deluge.preferences.Bandwidth.superclass.constructor.call(this, config);
|
||||||
},
|
},
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.preferences.Bandwidth.superclass.initComponent.call(this);
|
Deluge.preferences.Bandwidth.superclass.initComponent.call(this);
|
||||||
|
|
||||||
var om = deluge.preferences.getOptionsManager();
|
var om = deluge.preferences.getOptionsManager();
|
||||||
var fieldset = this.add({
|
var fieldset = this.add({
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
border: false,
|
border: false,
|
||||||
title: _('Global Bandwidth Usage'),
|
title: _('Global Bandwidth Usage'),
|
||||||
labelWidth: 200,
|
labelWidth: 200,
|
||||||
defaultType: 'spinnerfield',
|
defaultType: 'spinnerfield',
|
||||||
defaults: {
|
defaults: {
|
||||||
minValue: -1,
|
minValue: -1,
|
||||||
maxValue: 99999
|
maxValue: 99999
|
||||||
},
|
},
|
||||||
style: 'margin-bottom: 0px; padding-bottom: 0px;',
|
style: 'margin-bottom: 0px; padding-bottom: 0px;',
|
||||||
autoHeight: true
|
autoHeight: true
|
||||||
});
|
});
|
||||||
om.bind('max_connections_global', fieldset.add({
|
om.bind('max_connections_global', fieldset.add({
|
||||||
name: 'max_connections_global',
|
name: 'max_connections_global',
|
||||||
fieldLabel: _('Maximum Connections'),
|
fieldLabel: _('Maximum Connections'),
|
||||||
width: 80,
|
width: 80,
|
||||||
value: -1,
|
value: -1,
|
||||||
decimalPrecision: 0
|
decimalPrecision: 0
|
||||||
}));
|
}));
|
||||||
om.bind('max_upload_slots_global', fieldset.add({
|
om.bind('max_upload_slots_global', fieldset.add({
|
||||||
name: 'max_upload_slots_global',
|
name: 'max_upload_slots_global',
|
||||||
fieldLabel: _('Maximum Upload Slots'),
|
fieldLabel: _('Maximum Upload Slots'),
|
||||||
width: 80,
|
width: 80,
|
||||||
value: -1,
|
value: -1,
|
||||||
decimalPrecision: 0
|
decimalPrecision: 0
|
||||||
}));
|
}));
|
||||||
om.bind('max_download_speed', fieldset.add({
|
om.bind('max_download_speed', fieldset.add({
|
||||||
name: 'max_download_speed',
|
name: 'max_download_speed',
|
||||||
fieldLabel: _('Maximum Download Speed (KiB/s)'),
|
fieldLabel: _('Maximum Download Speed (KiB/s)'),
|
||||||
width: 80,
|
width: 80,
|
||||||
value: -1.0,
|
value: -1.0,
|
||||||
decimalPrecision: 1
|
decimalPrecision: 1
|
||||||
}));
|
}));
|
||||||
om.bind('max_upload_speed', fieldset.add({
|
om.bind('max_upload_speed', fieldset.add({
|
||||||
name: 'max_upload_speed',
|
name: 'max_upload_speed',
|
||||||
fieldLabel: _('Maximum Upload Speed (KiB/s)'),
|
fieldLabel: _('Maximum Upload Speed (KiB/s)'),
|
||||||
width: 80,
|
width: 80,
|
||||||
value: -1.0,
|
value: -1.0,
|
||||||
decimalPrecision: 1
|
decimalPrecision: 1
|
||||||
}));
|
}));
|
||||||
om.bind('max_half_open_connections', fieldset.add({
|
om.bind('max_half_open_connections', fieldset.add({
|
||||||
name: 'max_half_open_connections',
|
name: 'max_half_open_connections',
|
||||||
fieldLabel: _('Maximum Half-Open Connections'),
|
fieldLabel: _('Maximum Half-Open Connections'),
|
||||||
width: 80,
|
width: 80,
|
||||||
value: -1,
|
value: -1,
|
||||||
decimalPrecision: 0
|
decimalPrecision: 0
|
||||||
}));
|
}));
|
||||||
om.bind('max_connections_per_second', fieldset.add({
|
om.bind('max_connections_per_second', fieldset.add({
|
||||||
name: 'max_connections_per_second',
|
name: 'max_connections_per_second',
|
||||||
fieldLabel: _('Maximum Connection Attempts per Second'),
|
fieldLabel: _('Maximum Connection Attempts per Second'),
|
||||||
width: 80,
|
width: 80,
|
||||||
value: -1,
|
value: -1,
|
||||||
decimalPrecision: 0
|
decimalPrecision: 0
|
||||||
}));
|
}));
|
||||||
|
|
||||||
fieldset = this.add({
|
fieldset = this.add({
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
border: false,
|
border: false,
|
||||||
title: '',
|
title: '',
|
||||||
defaultType: 'checkbox',
|
defaultType: 'checkbox',
|
||||||
style: 'padding-top: 0px; padding-bottom: 5px; margin-top: 0px; margin-bottom: 0px;',
|
style: 'padding-top: 0px; padding-bottom: 5px; margin-top: 0px; margin-bottom: 0px;',
|
||||||
autoHeight: true
|
autoHeight: true
|
||||||
});
|
});
|
||||||
om.bind('ignore_limits_on_local_network', fieldset.add({
|
om.bind('ignore_limits_on_local_network', fieldset.add({
|
||||||
name: 'ignore_limits_on_local_network',
|
name: 'ignore_limits_on_local_network',
|
||||||
height: 22,
|
height: 22,
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
labelSeparator: '',
|
labelSeparator: '',
|
||||||
boxLabel: _('Ignore limits on local network')
|
boxLabel: _('Ignore limits on local network')
|
||||||
}));
|
}));
|
||||||
om.bind('rate_limit_ip_overhead', fieldset.add({
|
om.bind('rate_limit_ip_overhead', fieldset.add({
|
||||||
name: 'rate_limit_ip_overhead',
|
name: 'rate_limit_ip_overhead',
|
||||||
height: 22,
|
height: 22,
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
labelSeparator: '',
|
labelSeparator: '',
|
||||||
boxLabel: _('Rate limit IP overhead')
|
boxLabel: _('Rate limit IP overhead')
|
||||||
}));
|
}));
|
||||||
|
|
||||||
fieldset = this.add({
|
fieldset = this.add({
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
border: false,
|
border: false,
|
||||||
title: _('Per Torrent Bandwidth Usage'),
|
title: _('Per Torrent Bandwidth Usage'),
|
||||||
style: 'margin-bottom: 0px; padding-bottom: 0px;',
|
style: 'margin-bottom: 0px; padding-bottom: 0px;',
|
||||||
defaultType: 'spinnerfield',
|
defaultType: 'spinnerfield',
|
||||||
labelWidth: 200,
|
labelWidth: 200,
|
||||||
defaults: {
|
defaults: {
|
||||||
minValue: -1,
|
minValue: -1,
|
||||||
maxValue: 99999
|
maxValue: 99999
|
||||||
},
|
},
|
||||||
autoHeight: true
|
autoHeight: true
|
||||||
});
|
});
|
||||||
om.bind('max_connections_per_torrent', fieldset.add({
|
om.bind('max_connections_per_torrent', fieldset.add({
|
||||||
name: 'max_connections_per_torrent',
|
name: 'max_connections_per_torrent',
|
||||||
fieldLabel: _('Maximum Connections'),
|
fieldLabel: _('Maximum Connections'),
|
||||||
width: 80,
|
width: 80,
|
||||||
value: -1,
|
value: -1,
|
||||||
decimalPrecision: 0
|
decimalPrecision: 0
|
||||||
}));
|
}));
|
||||||
om.bind('max_upload_slots_per_torrent', fieldset.add({
|
om.bind('max_upload_slots_per_torrent', fieldset.add({
|
||||||
name: 'max_upload_slots_per_torrent',
|
name: 'max_upload_slots_per_torrent',
|
||||||
fieldLabel: _('Maximum Upload Slots'),
|
fieldLabel: _('Maximum Upload Slots'),
|
||||||
width: 80,
|
width: 80,
|
||||||
value: -1,
|
value: -1,
|
||||||
decimalPrecision: 0
|
decimalPrecision: 0
|
||||||
}));
|
}));
|
||||||
om.bind('max_download_speed_per_torrent', fieldset.add({
|
om.bind('max_download_speed_per_torrent', fieldset.add({
|
||||||
name: 'max_download_speed_per_torrent',
|
name: 'max_download_speed_per_torrent',
|
||||||
fieldLabel: _('Maximum Download Speed (KiB/s)'),
|
fieldLabel: _('Maximum Download Speed (KiB/s)'),
|
||||||
width: 80,
|
width: 80,
|
||||||
value: -1,
|
value: -1,
|
||||||
decimalPrecision: 0
|
decimalPrecision: 0
|
||||||
}));
|
}));
|
||||||
om.bind('max_upload_speed_per_torrent', fieldset.add({
|
om.bind('max_upload_speed_per_torrent', fieldset.add({
|
||||||
name: 'max_upload_speed_per_torrent',
|
name: 'max_upload_speed_per_torrent',
|
||||||
fieldLabel: _('Maximum Upload Speed (KiB/s)'),
|
fieldLabel: _('Maximum Upload Speed (KiB/s)'),
|
||||||
width: 80,
|
width: 80,
|
||||||
value: -1,
|
value: -1,
|
||||||
decimalPrecision: 0
|
decimalPrecision: 0
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -37,39 +37,39 @@ Ext.namespace('Deluge.preferences');
|
|||||||
*/
|
*/
|
||||||
Deluge.preferences.Cache = Ext.extend(Ext.form.FormPanel, {
|
Deluge.preferences.Cache = Ext.extend(Ext.form.FormPanel, {
|
||||||
|
|
||||||
border: false,
|
border: false,
|
||||||
title: _('Cache'),
|
title: _('Cache'),
|
||||||
layout: 'form',
|
layout: 'form',
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.preferences.Cache.superclass.initComponent.call(this);
|
Deluge.preferences.Cache.superclass.initComponent.call(this);
|
||||||
|
|
||||||
var om = deluge.preferences.getOptionsManager();
|
var om = deluge.preferences.getOptionsManager();
|
||||||
|
|
||||||
var fieldset = this.add({
|
var fieldset = this.add({
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
border: false,
|
border: false,
|
||||||
title: _('Settings'),
|
title: _('Settings'),
|
||||||
autoHeight: true,
|
autoHeight: true,
|
||||||
labelWidth: 180,
|
labelWidth: 180,
|
||||||
defaultType: 'spinnerfield',
|
defaultType: 'spinnerfield',
|
||||||
defaults: {
|
defaults: {
|
||||||
decimalPrecision: 0,
|
decimalPrecision: 0,
|
||||||
minValue: -1,
|
minValue: -1,
|
||||||
maxValue: 99999
|
maxValue: 99999
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
om.bind('cache_size', fieldset.add({
|
om.bind('cache_size', fieldset.add({
|
||||||
fieldLabel: _('Cache Size (16 KiB Blocks)'),
|
fieldLabel: _('Cache Size (16 KiB Blocks)'),
|
||||||
name: 'cache_size',
|
name: 'cache_size',
|
||||||
width: 60,
|
width: 60,
|
||||||
value: 512
|
value: 512
|
||||||
}));
|
}));
|
||||||
om.bind('cache_expiry', fieldset.add({
|
om.bind('cache_expiry', fieldset.add({
|
||||||
fieldLabel: _('Cache Expiry (seconds)'),
|
fieldLabel: _('Cache Expiry (seconds)'),
|
||||||
name: 'cache_expiry',
|
name: 'cache_expiry',
|
||||||
width: 60,
|
width: 60,
|
||||||
value: 60
|
value: 60
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -37,61 +37,61 @@ Ext.namespace('Deluge.preferences');
|
|||||||
*/
|
*/
|
||||||
Deluge.preferences.Daemon = Ext.extend(Ext.form.FormPanel, {
|
Deluge.preferences.Daemon = Ext.extend(Ext.form.FormPanel, {
|
||||||
|
|
||||||
border: false,
|
border: false,
|
||||||
title: _('Daemon'),
|
title: _('Daemon'),
|
||||||
layout: 'form',
|
layout: 'form',
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.preferences.Daemon.superclass.initComponent.call(this);
|
Deluge.preferences.Daemon.superclass.initComponent.call(this);
|
||||||
|
|
||||||
var om = deluge.preferences.getOptionsManager();
|
var om = deluge.preferences.getOptionsManager();
|
||||||
|
|
||||||
var fieldset = this.add({
|
var fieldset = this.add({
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
border: false,
|
border: false,
|
||||||
title: _('Port'),
|
title: _('Port'),
|
||||||
autoHeight: true,
|
autoHeight: true,
|
||||||
defaultType: 'spinnerfield'
|
defaultType: 'spinnerfield'
|
||||||
});
|
});
|
||||||
om.bind('daemon_port', fieldset.add({
|
om.bind('daemon_port', fieldset.add({
|
||||||
fieldLabel: _('Daemon port'),
|
fieldLabel: _('Daemon port'),
|
||||||
name: 'daemon_port',
|
name: 'daemon_port',
|
||||||
value: 58846,
|
value: 58846,
|
||||||
decimalPrecision: 0,
|
decimalPrecision: 0,
|
||||||
minValue: -1,
|
minValue: -1,
|
||||||
maxValue: 99999
|
maxValue: 99999
|
||||||
}));
|
}));
|
||||||
|
|
||||||
fieldset = this.add({
|
fieldset = this.add({
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
border: false,
|
border: false,
|
||||||
title: _('Connections'),
|
title: _('Connections'),
|
||||||
autoHeight: true,
|
autoHeight: true,
|
||||||
labelWidth: 1,
|
labelWidth: 1,
|
||||||
defaultType: 'checkbox'
|
defaultType: 'checkbox'
|
||||||
});
|
});
|
||||||
om.bind('allow_remote', fieldset.add({
|
om.bind('allow_remote', fieldset.add({
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
height: 22,
|
height: 22,
|
||||||
labelSeparator: '',
|
labelSeparator: '',
|
||||||
boxLabel: _('Allow Remote Connections'),
|
boxLabel: _('Allow Remote Connections'),
|
||||||
name: 'allow_remote'
|
name: 'allow_remote'
|
||||||
}));
|
}));
|
||||||
|
|
||||||
fieldset = this.add({
|
fieldset = this.add({
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
border: false,
|
border: false,
|
||||||
title: _('Other'),
|
title: _('Other'),
|
||||||
autoHeight: true,
|
autoHeight: true,
|
||||||
labelWidth: 1,
|
labelWidth: 1,
|
||||||
defaultType: 'checkbox'
|
defaultType: 'checkbox'
|
||||||
});
|
});
|
||||||
om.bind('new_release_check', fieldset.add({
|
om.bind('new_release_check', fieldset.add({
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
labelSeparator: '',
|
labelSeparator: '',
|
||||||
height: 40,
|
height: 40,
|
||||||
boxLabel: _('Periodically check the website for new releases'),
|
boxLabel: _('Periodically check the website for new releases'),
|
||||||
id: 'new_release_check'
|
id: 'new_release_check'
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -36,114 +36,114 @@ Ext.namespace('Deluge.preferences');
|
|||||||
* @extends Ext.form.FormPanel
|
* @extends Ext.form.FormPanel
|
||||||
*/
|
*/
|
||||||
Deluge.preferences.Downloads = Ext.extend(Ext.FormPanel, {
|
Deluge.preferences.Downloads = Ext.extend(Ext.FormPanel, {
|
||||||
constructor: function(config) {
|
constructor: function(config) {
|
||||||
config = Ext.apply({
|
config = Ext.apply({
|
||||||
border: false,
|
border: false,
|
||||||
title: _('Downloads'),
|
title: _('Downloads'),
|
||||||
layout: 'form',
|
layout: 'form',
|
||||||
autoHeight: true,
|
autoHeight: true,
|
||||||
width: 320
|
width: 320
|
||||||
}, config);
|
}, config);
|
||||||
Deluge.preferences.Downloads.superclass.constructor.call(this, config);
|
Deluge.preferences.Downloads.superclass.constructor.call(this, config);
|
||||||
},
|
},
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.preferences.Downloads.superclass.initComponent.call(this);
|
Deluge.preferences.Downloads.superclass.initComponent.call(this);
|
||||||
|
|
||||||
var optMan = deluge.preferences.getOptionsManager();
|
var optMan = deluge.preferences.getOptionsManager();
|
||||||
var fieldset = this.add({
|
var fieldset = this.add({
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
border: false,
|
border: false,
|
||||||
title: _('Folders'),
|
title: _('Folders'),
|
||||||
labelWidth: 150,
|
labelWidth: 150,
|
||||||
defaultType: 'togglefield',
|
defaultType: 'togglefield',
|
||||||
autoHeight: true,
|
autoHeight: true,
|
||||||
labelAlign: 'top',
|
labelAlign: 'top',
|
||||||
width: 300,
|
width: 300,
|
||||||
style: 'margin-bottom: 5px; padding-bottom: 5px;'
|
style: 'margin-bottom: 5px; padding-bottom: 5px;'
|
||||||
});
|
});
|
||||||
|
|
||||||
optMan.bind('download_location', fieldset.add({
|
optMan.bind('download_location', fieldset.add({
|
||||||
xtype: 'textfield',
|
xtype: 'textfield',
|
||||||
name: 'download_location',
|
name: 'download_location',
|
||||||
fieldLabel: _('Download to'),
|
fieldLabel: _('Download to'),
|
||||||
width: 280
|
width: 280
|
||||||
}));
|
}));
|
||||||
|
|
||||||
var field = fieldset.add({
|
var field = fieldset.add({
|
||||||
name: 'move_completed_path',
|
name: 'move_completed_path',
|
||||||
fieldLabel: _('Move completed to'),
|
fieldLabel: _('Move completed to'),
|
||||||
width: 280
|
width: 280
|
||||||
});
|
});
|
||||||
optMan.bind('move_completed', field.toggle);
|
optMan.bind('move_completed', field.toggle);
|
||||||
optMan.bind('move_completed_path', field.input);
|
optMan.bind('move_completed_path', field.input);
|
||||||
|
|
||||||
field = fieldset.add({
|
field = fieldset.add({
|
||||||
name: 'torrentfiles_location',
|
name: 'torrentfiles_location',
|
||||||
fieldLabel: _('Copy of .torrent files to'),
|
fieldLabel: _('Copy of .torrent files to'),
|
||||||
width: 280
|
width: 280
|
||||||
});
|
});
|
||||||
optMan.bind('copy_torrent_file', field.toggle);
|
optMan.bind('copy_torrent_file', field.toggle);
|
||||||
optMan.bind('torrentfiles_location', field.input);
|
optMan.bind('torrentfiles_location', field.input);
|
||||||
|
|
||||||
field = fieldset.add({
|
field = fieldset.add({
|
||||||
name: 'autoadd_location',
|
name: 'autoadd_location',
|
||||||
fieldLabel: _('Autoadd .torrent files from'),
|
fieldLabel: _('Autoadd .torrent files from'),
|
||||||
width: 280
|
width: 280
|
||||||
});
|
});
|
||||||
optMan.bind('autoadd_enable', field.toggle);
|
optMan.bind('autoadd_enable', field.toggle);
|
||||||
optMan.bind('autoadd_location', field.input);
|
optMan.bind('autoadd_location', field.input);
|
||||||
|
|
||||||
fieldset = this.add({
|
fieldset = this.add({
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
border: false,
|
border: false,
|
||||||
title: _('Allocation'),
|
title: _('Allocation'),
|
||||||
autoHeight: true,
|
autoHeight: true,
|
||||||
labelWidth: 1,
|
labelWidth: 1,
|
||||||
defaultType: 'radiogroup',
|
defaultType: 'radiogroup',
|
||||||
style: 'margin-bottom: 5px; margin-top: 0; padding-bottom: 5px; padding-top: 0;',
|
style: 'margin-bottom: 5px; margin-top: 0; padding-bottom: 5px; padding-top: 0;',
|
||||||
width: 240
|
width: 240
|
||||||
});
|
});
|
||||||
optMan.bind('compact_allocation', fieldset.add({
|
optMan.bind('compact_allocation', fieldset.add({
|
||||||
name: 'compact_allocation',
|
name: 'compact_allocation',
|
||||||
width: 200,
|
width: 200,
|
||||||
labelSeparator: '',
|
labelSeparator: '',
|
||||||
//disabled: true,
|
//disabled: true,
|
||||||
defaults: {
|
defaults: {
|
||||||
width: 80,
|
width: 80,
|
||||||
height: 22,
|
height: 22,
|
||||||
name: 'compact_allocation'
|
name: 'compact_allocation'
|
||||||
},
|
},
|
||||||
items: [{
|
items: [{
|
||||||
boxLabel: _('Use Full'),
|
boxLabel: _('Use Full'),
|
||||||
inputValue: false
|
inputValue: false
|
||||||
}, {
|
}, {
|
||||||
boxLabel: _('Use Compact'),
|
boxLabel: _('Use Compact'),
|
||||||
inputValue: true
|
inputValue: true
|
||||||
}]
|
}]
|
||||||
}));
|
}));
|
||||||
|
|
||||||
fieldset = this.add({
|
fieldset = this.add({
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
border: false,
|
border: false,
|
||||||
title: _('Options'),
|
title: _('Options'),
|
||||||
autoHeight: true,
|
autoHeight: true,
|
||||||
labelWidth: 1,
|
labelWidth: 1,
|
||||||
defaultType: 'checkbox',
|
defaultType: 'checkbox',
|
||||||
style: 'margin-bottom: 0; padding-bottom: 0;',
|
style: 'margin-bottom: 0; padding-bottom: 0;',
|
||||||
width: 280
|
width: 280
|
||||||
});
|
});
|
||||||
optMan.bind('prioritize_first_last_pieces', fieldset.add({
|
optMan.bind('prioritize_first_last_pieces', fieldset.add({
|
||||||
name: 'prioritize_first_last_pieces',
|
name: 'prioritize_first_last_pieces',
|
||||||
labelSeparator: '',
|
labelSeparator: '',
|
||||||
height: 22,
|
height: 22,
|
||||||
boxLabel: _('Prioritize first and last pieces of torrent')
|
boxLabel: _('Prioritize first and last pieces of torrent')
|
||||||
}));
|
}));
|
||||||
optMan.bind('add_paused', fieldset.add({
|
optMan.bind('add_paused', fieldset.add({
|
||||||
name: 'add_paused',
|
name: 'add_paused',
|
||||||
labelSeparator: '',
|
labelSeparator: '',
|
||||||
height: 22,
|
height: 22,
|
||||||
boxLabel: _('Add torrents in Paused state')
|
boxLabel: _('Add torrents in Paused state')
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -37,79 +37,79 @@ Ext.namespace('Deluge.preferences');
|
|||||||
*/
|
*/
|
||||||
Deluge.preferences.Encryption = Ext.extend(Ext.form.FormPanel, {
|
Deluge.preferences.Encryption = Ext.extend(Ext.form.FormPanel, {
|
||||||
|
|
||||||
border: false,
|
border: false,
|
||||||
title: _('Encryption'),
|
title: _('Encryption'),
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.preferences.Encryption.superclass.initComponent.call(this);
|
Deluge.preferences.Encryption.superclass.initComponent.call(this);
|
||||||
|
|
||||||
var optMan = deluge.preferences.getOptionsManager();
|
var optMan = deluge.preferences.getOptionsManager();
|
||||||
|
|
||||||
var fieldset = this.add({
|
var fieldset = this.add({
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
border: false,
|
border: false,
|
||||||
title: _('Settings'),
|
title: _('Settings'),
|
||||||
autoHeight: true,
|
autoHeight: true,
|
||||||
defaultType: 'combo',
|
defaultType: 'combo',
|
||||||
width: 300
|
width: 300
|
||||||
});
|
});
|
||||||
optMan.bind('enc_in_policy', fieldset.add({
|
optMan.bind('enc_in_policy', fieldset.add({
|
||||||
fieldLabel: _('Inbound'),
|
fieldLabel: _('Inbound'),
|
||||||
mode: 'local',
|
mode: 'local',
|
||||||
width: 150,
|
width: 150,
|
||||||
store: new Ext.data.ArrayStore({
|
store: new Ext.data.ArrayStore({
|
||||||
fields: ['id', 'text'],
|
fields: ['id', 'text'],
|
||||||
data: [
|
data: [
|
||||||
[0, _('Forced')],
|
[0, _('Forced')],
|
||||||
[1, _('Enabled')],
|
[1, _('Enabled')],
|
||||||
[2, _('Disabled')]
|
[2, _('Disabled')]
|
||||||
]
|
]
|
||||||
}),
|
}),
|
||||||
editable: false,
|
editable: false,
|
||||||
triggerAction: 'all',
|
triggerAction: 'all',
|
||||||
valueField: 'id',
|
valueField: 'id',
|
||||||
displayField: 'text'
|
displayField: 'text'
|
||||||
}));
|
}));
|
||||||
optMan.bind('enc_out_policy', fieldset.add({
|
optMan.bind('enc_out_policy', fieldset.add({
|
||||||
fieldLabel: _('Outbound'),
|
fieldLabel: _('Outbound'),
|
||||||
mode: 'local',
|
mode: 'local',
|
||||||
width: 150,
|
width: 150,
|
||||||
store: new Ext.data.SimpleStore({
|
store: new Ext.data.SimpleStore({
|
||||||
fields: ['id', 'text'],
|
fields: ['id', 'text'],
|
||||||
data: [
|
data: [
|
||||||
[0, _('Forced')],
|
[0, _('Forced')],
|
||||||
[1, _('Enabled')],
|
[1, _('Enabled')],
|
||||||
[2, _('Disabled')]
|
[2, _('Disabled')]
|
||||||
]
|
]
|
||||||
}),
|
}),
|
||||||
editable: false,
|
editable: false,
|
||||||
triggerAction: 'all',
|
triggerAction: 'all',
|
||||||
valueField: 'id',
|
valueField: 'id',
|
||||||
displayField: 'text'
|
displayField: 'text'
|
||||||
}));
|
}));
|
||||||
optMan.bind('enc_level', fieldset.add({
|
optMan.bind('enc_level', fieldset.add({
|
||||||
fieldLabel: _('Level'),
|
fieldLabel: _('Level'),
|
||||||
mode: 'local',
|
mode: 'local',
|
||||||
width: 150,
|
width: 150,
|
||||||
store: new Ext.data.SimpleStore({
|
store: new Ext.data.SimpleStore({
|
||||||
fields: ['id', 'text'],
|
fields: ['id', 'text'],
|
||||||
data: [
|
data: [
|
||||||
[0, _('Handshake')],
|
[0, _('Handshake')],
|
||||||
[1, _('Full Stream')],
|
[1, _('Full Stream')],
|
||||||
[2, _('Either')]
|
[2, _('Either')]
|
||||||
]
|
]
|
||||||
}),
|
}),
|
||||||
editable: false,
|
editable: false,
|
||||||
triggerAction: 'all',
|
triggerAction: 'all',
|
||||||
valueField: 'id',
|
valueField: 'id',
|
||||||
displayField: 'text'
|
displayField: 'text'
|
||||||
}));
|
}));
|
||||||
optMan.bind('enc_prefer_rc4', fieldset.add({
|
optMan.bind('enc_prefer_rc4', fieldset.add({
|
||||||
xtype: 'checkbox',
|
xtype: 'checkbox',
|
||||||
name: 'enc_prefer_rc4',
|
name: 'enc_prefer_rc4',
|
||||||
height: 40,
|
height: 40,
|
||||||
hideLabel: true,
|
hideLabel: true,
|
||||||
boxLabel: _('Encrypt entire stream')
|
boxLabel: _('Encrypt entire stream')
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -37,66 +37,66 @@ Ext.namespace('Deluge.preferences');
|
|||||||
*/
|
*/
|
||||||
Deluge.preferences.InstallPluginWindow = Ext.extend(Ext.Window, {
|
Deluge.preferences.InstallPluginWindow = Ext.extend(Ext.Window, {
|
||||||
|
|
||||||
title: _('Install Plugin'),
|
title: _('Install Plugin'),
|
||||||
layout: 'fit',
|
layout: 'fit',
|
||||||
height: 115,
|
height: 115,
|
||||||
width: 350,
|
width: 350,
|
||||||
|
|
||||||
bodyStyle: 'padding: 10px 5px;',
|
bodyStyle: 'padding: 10px 5px;',
|
||||||
buttonAlign: 'center',
|
buttonAlign: 'center',
|
||||||
closeAction: 'hide',
|
closeAction: 'hide',
|
||||||
iconCls: 'x-deluge-install-plugin',
|
iconCls: 'x-deluge-install-plugin',
|
||||||
modal: true,
|
modal: true,
|
||||||
plain: true,
|
plain: true,
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.add.FileWindow.superclass.initComponent.call(this);
|
Deluge.add.FileWindow.superclass.initComponent.call(this);
|
||||||
this.addButton(_('Install'), this.onInstall, this);
|
this.addButton(_('Install'), this.onInstall, this);
|
||||||
|
|
||||||
this.form = this.add({
|
this.form = this.add({
|
||||||
xtype: 'form',
|
xtype: 'form',
|
||||||
baseCls: 'x-plain',
|
baseCls: 'x-plain',
|
||||||
labelWidth: 70,
|
labelWidth: 70,
|
||||||
autoHeight: true,
|
autoHeight: true,
|
||||||
fileUpload: true,
|
fileUpload: true,
|
||||||
items: [{
|
items: [{
|
||||||
xtype: 'fileuploadfield',
|
xtype: 'fileuploadfield',
|
||||||
width: 240,
|
width: 240,
|
||||||
emptyText: _('Select an egg'),
|
emptyText: _('Select an egg'),
|
||||||
fieldLabel: _('Plugin Egg'),
|
fieldLabel: _('Plugin Egg'),
|
||||||
name: 'file',
|
name: 'file',
|
||||||
buttonCfg: {
|
buttonCfg: {
|
||||||
text: _('Browse') + '...'
|
text: _('Browse') + '...'
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onInstall: function(field, e) {
|
onInstall: function(field, e) {
|
||||||
this.form.getForm().submit({
|
this.form.getForm().submit({
|
||||||
url: '/upload',
|
url: '/upload',
|
||||||
waitMsg: _('Uploading your plugin...'),
|
waitMsg: _('Uploading your plugin...'),
|
||||||
success: this.onUploadSuccess,
|
success: this.onUploadSuccess,
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onUploadPlugin: function(info, obj, response, request) {
|
onUploadPlugin: function(info, obj, response, request) {
|
||||||
this.fireEvent('pluginadded');
|
this.fireEvent('pluginadded');
|
||||||
},
|
},
|
||||||
|
|
||||||
onUploadSuccess: function(fp, upload) {
|
onUploadSuccess: function(fp, upload) {
|
||||||
this.hide();
|
this.hide();
|
||||||
if (upload.result.success) {
|
if (upload.result.success) {
|
||||||
var filename = this.form.getForm().getFieldValues().file;
|
var filename = this.form.getForm().getFieldValues().file;
|
||||||
filename = filename.split('\\').slice(-1)[0]
|
filename = filename.split('\\').slice(-1)[0]
|
||||||
var path = upload.result.files[0];
|
var path = upload.result.files[0];
|
||||||
this.form.getForm().setValues({file: ''});
|
this.form.getForm().setValues({file: ''});
|
||||||
deluge.client.web.upload_plugin(filename, path, {
|
deluge.client.web.upload_plugin(filename, path, {
|
||||||
success: this.onUploadPlugin,
|
success: this.onUploadPlugin,
|
||||||
scope: this,
|
scope: this,
|
||||||
filename: filename
|
filename: filename
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -37,219 +37,219 @@ Ext.namespace('Deluge.preferences');
|
|||||||
*/
|
*/
|
||||||
Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, {
|
Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, {
|
||||||
|
|
||||||
border: false,
|
border: false,
|
||||||
title: _('Interface'),
|
title: _('Interface'),
|
||||||
layout: 'form',
|
layout: 'form',
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.preferences.Interface.superclass.initComponent.call(this);
|
Deluge.preferences.Interface.superclass.initComponent.call(this);
|
||||||
|
|
||||||
var om = this.optionsManager = new Deluge.OptionsManager();
|
var om = this.optionsManager = new Deluge.OptionsManager();
|
||||||
this.on('show', this.onPageShow, this);
|
this.on('show', this.onPageShow, this);
|
||||||
|
|
||||||
var fieldset = this.add({
|
var fieldset = this.add({
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
border: false,
|
border: false,
|
||||||
title: _('Interface'),
|
title: _('Interface'),
|
||||||
style: 'margin-bottom: 0px; padding-bottom: 5px; padding-top: 5px',
|
style: 'margin-bottom: 0px; padding-bottom: 5px; padding-top: 5px',
|
||||||
autoHeight: true,
|
autoHeight: true,
|
||||||
labelWidth: 1,
|
labelWidth: 1,
|
||||||
defaultType: 'checkbox'
|
defaultType: 'checkbox'
|
||||||
});
|
});
|
||||||
om.bind('show_session_speed', fieldset.add({
|
om.bind('show_session_speed', fieldset.add({
|
||||||
name: 'show_session_speed',
|
name: 'show_session_speed',
|
||||||
height: 22,
|
height: 22,
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
labelSeparator: '',
|
labelSeparator: '',
|
||||||
boxLabel: _('Show session speed in titlebar')
|
boxLabel: _('Show session speed in titlebar')
|
||||||
}));
|
}));
|
||||||
om.bind('sidebar_show_zero', fieldset.add({
|
om.bind('sidebar_show_zero', fieldset.add({
|
||||||
name: 'sidebar_show_zero',
|
name: 'sidebar_show_zero',
|
||||||
height: 22,
|
height: 22,
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
labelSeparator: '',
|
labelSeparator: '',
|
||||||
boxLabel: _('Show filters with zero torrents')
|
boxLabel: _('Show filters with zero torrents')
|
||||||
}));
|
}));
|
||||||
om.bind('sidebar_multiple_filters', fieldset.add({
|
om.bind('sidebar_multiple_filters', fieldset.add({
|
||||||
name: 'sidebar_multiple_filters',
|
name: 'sidebar_multiple_filters',
|
||||||
height: 22,
|
height: 22,
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
labelSeparator: '',
|
labelSeparator: '',
|
||||||
boxLabel: _('Allow the use of multiple filters at once')
|
boxLabel: _('Allow the use of multiple filters at once')
|
||||||
}));
|
}));
|
||||||
|
|
||||||
fieldset = this.add({
|
fieldset = this.add({
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
border: false,
|
border: false,
|
||||||
title: _('Password'),
|
title: _('Password'),
|
||||||
style: 'margin-bottom: 0px; padding-bottom: 0px; padding-top: 5px',
|
style: 'margin-bottom: 0px; padding-bottom: 0px; padding-top: 5px',
|
||||||
autoHeight: true,
|
autoHeight: true,
|
||||||
labelWidth: 110,
|
labelWidth: 110,
|
||||||
defaultType: 'textfield',
|
defaultType: 'textfield',
|
||||||
defaults: {
|
defaults: {
|
||||||
width: 180,
|
width: 180,
|
||||||
inputType: 'password'
|
inputType: 'password'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.oldPassword = fieldset.add({
|
this.oldPassword = fieldset.add({
|
||||||
name: 'old_password',
|
name: 'old_password',
|
||||||
fieldLabel: _('Old Password')
|
fieldLabel: _('Old Password')
|
||||||
});
|
});
|
||||||
this.newPassword = fieldset.add({
|
this.newPassword = fieldset.add({
|
||||||
name: 'new_password',
|
name: 'new_password',
|
||||||
fieldLabel: _('New Password')
|
fieldLabel: _('New Password')
|
||||||
});
|
});
|
||||||
this.confirmPassword = fieldset.add({
|
this.confirmPassword = fieldset.add({
|
||||||
name: 'confirm_password',
|
name: 'confirm_password',
|
||||||
fieldLabel: _('Confirm Password')
|
fieldLabel: _('Confirm Password')
|
||||||
});
|
});
|
||||||
|
|
||||||
var panel = fieldset.add({
|
var panel = fieldset.add({
|
||||||
xtype: 'panel',
|
xtype: 'panel',
|
||||||
autoHeight: true,
|
autoHeight: true,
|
||||||
border: false,
|
border: false,
|
||||||
width: 320,
|
width: 320,
|
||||||
bodyStyle: 'padding-left: 230px'
|
bodyStyle: 'padding-left: 230px'
|
||||||
})
|
})
|
||||||
panel.add({
|
panel.add({
|
||||||
xtype: 'button',
|
xtype: 'button',
|
||||||
text: _('Change'),
|
text: _('Change'),
|
||||||
listeners: {
|
listeners: {
|
||||||
'click': {
|
'click': {
|
||||||
fn: this.onPasswordChange,
|
fn: this.onPasswordChange,
|
||||||
scope: this
|
scope: this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
fieldset = this.add({
|
fieldset = this.add({
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
border: false,
|
border: false,
|
||||||
title: _('Server'),
|
title: _('Server'),
|
||||||
style: 'margin-top: 0px; padding-top: 0px; margin-bottom: 0px; padding-bottom: 0px',
|
style: 'margin-top: 0px; padding-top: 0px; margin-bottom: 0px; padding-bottom: 0px',
|
||||||
autoHeight: true,
|
autoHeight: true,
|
||||||
labelWidth: 110,
|
labelWidth: 110,
|
||||||
defaultType: 'spinnerfield',
|
defaultType: 'spinnerfield',
|
||||||
defaults: {
|
defaults: {
|
||||||
width: 80
|
width: 80
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
om.bind('session_timeout', fieldset.add({
|
om.bind('session_timeout', fieldset.add({
|
||||||
name: 'session_timeout',
|
name: 'session_timeout',
|
||||||
fieldLabel: _('Session Timeout'),
|
fieldLabel: _('Session Timeout'),
|
||||||
decimalPrecision: 0,
|
decimalPrecision: 0,
|
||||||
minValue: -1,
|
minValue: -1,
|
||||||
maxValue: 99999
|
maxValue: 99999
|
||||||
}));
|
}));
|
||||||
om.bind('port', fieldset.add({
|
om.bind('port', fieldset.add({
|
||||||
name: 'port',
|
name: 'port',
|
||||||
fieldLabel: _('Port'),
|
fieldLabel: _('Port'),
|
||||||
decimalPrecision: 0,
|
decimalPrecision: 0,
|
||||||
minValue: -1,
|
minValue: -1,
|
||||||
maxValue: 99999
|
maxValue: 99999
|
||||||
}));
|
}));
|
||||||
this.httpsField = om.bind('https', fieldset.add({
|
this.httpsField = om.bind('https', fieldset.add({
|
||||||
xtype: 'checkbox',
|
xtype: 'checkbox',
|
||||||
name: 'https',
|
name: 'https',
|
||||||
hideLabel: true,
|
hideLabel: true,
|
||||||
width: 280,
|
width: 280,
|
||||||
height: 22,
|
height: 22,
|
||||||
boxLabel: _('Use SSL (paths relative to Deluge config folder)')
|
boxLabel: _('Use SSL (paths relative to Deluge config folder)')
|
||||||
}));
|
}));
|
||||||
this.httpsField.on('check', this.onSSLCheck, this);
|
this.httpsField.on('check', this.onSSLCheck, this);
|
||||||
this.pkeyField = om.bind('pkey', fieldset.add({
|
this.pkeyField = om.bind('pkey', fieldset.add({
|
||||||
xtype: 'textfield',
|
xtype: 'textfield',
|
||||||
disabled: true,
|
disabled: true,
|
||||||
name: 'pkey',
|
name: 'pkey',
|
||||||
width: 180,
|
width: 180,
|
||||||
fieldLabel: _('Private Key')
|
fieldLabel: _('Private Key')
|
||||||
}));
|
}));
|
||||||
this.certField = om.bind('cert', fieldset.add({
|
this.certField = om.bind('cert', fieldset.add({
|
||||||
xtype: 'textfield',
|
xtype: 'textfield',
|
||||||
disabled: true,
|
disabled: true,
|
||||||
name: 'cert',
|
name: 'cert',
|
||||||
width: 180,
|
width: 180,
|
||||||
fieldLabel: _('Certificate')
|
fieldLabel: _('Certificate')
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
onApply: function() {
|
onApply: function() {
|
||||||
var changed = this.optionsManager.getDirty();
|
var changed = this.optionsManager.getDirty();
|
||||||
if (!Ext.isObjectEmpty(changed)) {
|
if (!Ext.isObjectEmpty(changed)) {
|
||||||
deluge.client.web.set_config(changed, {
|
deluge.client.web.set_config(changed, {
|
||||||
success: this.onSetConfig,
|
success: this.onSetConfig,
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
|
|
||||||
for (var key in deluge.config) {
|
for (var key in deluge.config) {
|
||||||
deluge.config[key] = this.optionsManager.get(key);
|
deluge.config[key] = this.optionsManager.get(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onGotConfig: function(config) {
|
onGotConfig: function(config) {
|
||||||
this.optionsManager.set(config);
|
this.optionsManager.set(config);
|
||||||
},
|
},
|
||||||
|
|
||||||
onPasswordChange: function() {
|
onPasswordChange: function() {
|
||||||
var newPassword = this.newPassword.getValue();
|
var newPassword = this.newPassword.getValue();
|
||||||
if (newPassword != this.confirmPassword.getValue()) {
|
if (newPassword != this.confirmPassword.getValue()) {
|
||||||
Ext.MessageBox.show({
|
Ext.MessageBox.show({
|
||||||
title: _('Invalid Password'),
|
title: _('Invalid Password'),
|
||||||
msg: _('Your passwords don\'t match!'),
|
msg: _('Your passwords don\'t match!'),
|
||||||
buttons: Ext.MessageBox.OK,
|
buttons: Ext.MessageBox.OK,
|
||||||
modal: false,
|
modal: false,
|
||||||
icon: Ext.MessageBox.ERROR,
|
icon: Ext.MessageBox.ERROR,
|
||||||
iconCls: 'x-deluge-icon-error'
|
iconCls: 'x-deluge-icon-error'
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var oldPassword = this.oldPassword.getValue();
|
var oldPassword = this.oldPassword.getValue();
|
||||||
deluge.client.auth.change_password(oldPassword, newPassword, {
|
deluge.client.auth.change_password(oldPassword, newPassword, {
|
||||||
success: function(result) {
|
success: function(result) {
|
||||||
if (!result) {
|
if (!result) {
|
||||||
Ext.MessageBox.show({
|
Ext.MessageBox.show({
|
||||||
title: _('Password'),
|
title: _('Password'),
|
||||||
msg: _('Your old password was incorrect!'),
|
msg: _('Your old password was incorrect!'),
|
||||||
buttons: Ext.MessageBox.OK,
|
buttons: Ext.MessageBox.OK,
|
||||||
modal: false,
|
modal: false,
|
||||||
icon: Ext.MessageBox.ERROR,
|
icon: Ext.MessageBox.ERROR,
|
||||||
iconCls: 'x-deluge-icon-error'
|
iconCls: 'x-deluge-icon-error'
|
||||||
});
|
});
|
||||||
this.oldPassword.setValue('');
|
this.oldPassword.setValue('');
|
||||||
} else {
|
} else {
|
||||||
Ext.MessageBox.show({
|
Ext.MessageBox.show({
|
||||||
title: _('Change Successful'),
|
title: _('Change Successful'),
|
||||||
msg: _('Your password was successfully changed!'),
|
msg: _('Your password was successfully changed!'),
|
||||||
buttons: Ext.MessageBox.OK,
|
buttons: Ext.MessageBox.OK,
|
||||||
modal: false,
|
modal: false,
|
||||||
icon: Ext.MessageBox.INFO,
|
icon: Ext.MessageBox.INFO,
|
||||||
iconCls: 'x-deluge-icon-info'
|
iconCls: 'x-deluge-icon-info'
|
||||||
});
|
});
|
||||||
this.oldPassword.setValue('');
|
this.oldPassword.setValue('');
|
||||||
this.newPassword.setValue('');
|
this.newPassword.setValue('');
|
||||||
this.confirmPassword.setValue('');
|
this.confirmPassword.setValue('');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onSetConfig: function() {
|
onSetConfig: function() {
|
||||||
this.optionsManager.commit();
|
this.optionsManager.commit();
|
||||||
},
|
},
|
||||||
|
|
||||||
onPageShow: function() {
|
onPageShow: function() {
|
||||||
deluge.client.web.get_config({
|
deluge.client.web.get_config({
|
||||||
success: this.onGotConfig,
|
success: this.onGotConfig,
|
||||||
scope: this
|
scope: this
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
onSSLCheck: function(e, checked) {
|
onSSLCheck: function(e, checked) {
|
||||||
this.pkeyField.setDisabled(!checked);
|
this.pkeyField.setDisabled(!checked);
|
||||||
this.certField.setDisabled(!checked);
|
this.certField.setDisabled(!checked);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -36,195 +36,195 @@ Ext.namespace('Deluge.preferences');
|
|||||||
* @extends Ext.form.FormPanel
|
* @extends Ext.form.FormPanel
|
||||||
*/
|
*/
|
||||||
Deluge.preferences.Network = Ext.extend(Ext.form.FormPanel, {
|
Deluge.preferences.Network = Ext.extend(Ext.form.FormPanel, {
|
||||||
|
|
||||||
border: false,
|
border: false,
|
||||||
layout: 'form',
|
layout: 'form',
|
||||||
title: _('Network'),
|
title: _('Network'),
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.preferences.Network.superclass.initComponent.call(this);
|
Deluge.preferences.Network.superclass.initComponent.call(this);
|
||||||
var optMan = deluge.preferences.getOptionsManager();
|
var optMan = deluge.preferences.getOptionsManager();
|
||||||
|
|
||||||
var fieldset = this.add({
|
var fieldset = this.add({
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
border: false,
|
border: false,
|
||||||
title: _('Incoming Ports'),
|
title: _('Incoming Ports'),
|
||||||
style: 'margin-bottom: 5px; padding-bottom: 0px;',
|
style: 'margin-bottom: 5px; padding-bottom: 0px;',
|
||||||
autoHeight: true,
|
autoHeight: true,
|
||||||
labelWidth: 1,
|
labelWidth: 1,
|
||||||
defaultType: 'checkbox'
|
defaultType: 'checkbox'
|
||||||
});
|
});
|
||||||
optMan.bind('random_port', fieldset.add({
|
optMan.bind('random_port', fieldset.add({
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
labelSeparator: '',
|
labelSeparator: '',
|
||||||
boxLabel: _('Use Random Ports'),
|
boxLabel: _('Use Random Ports'),
|
||||||
name: 'random_port',
|
name: 'random_port',
|
||||||
height: 22,
|
height: 22,
|
||||||
listeners: {
|
listeners: {
|
||||||
'check': {
|
'check': {
|
||||||
fn: function(e, checked) {
|
fn: function(e, checked) {
|
||||||
this.listenPorts.setDisabled(checked);
|
this.listenPorts.setDisabled(checked);
|
||||||
},
|
},
|
||||||
scope: this
|
scope: this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
this.listenPorts = fieldset.add({
|
this.listenPorts = fieldset.add({
|
||||||
xtype: 'spinnergroup',
|
xtype: 'spinnergroup',
|
||||||
name: 'listen_ports',
|
name: 'listen_ports',
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
labelSeparator: '',
|
labelSeparator: '',
|
||||||
colCfg: {
|
colCfg: {
|
||||||
labelWidth: 40,
|
labelWidth: 40,
|
||||||
style: 'margin-right: 10px;'
|
style: 'margin-right: 10px;'
|
||||||
},
|
},
|
||||||
items: [{
|
items: [{
|
||||||
fieldLabel: 'From',
|
fieldLabel: 'From',
|
||||||
strategy: {
|
strategy: {
|
||||||
xtype: 'number',
|
xtype: 'number',
|
||||||
decimalPrecision: 0,
|
decimalPrecision: 0,
|
||||||
minValue: -1,
|
minValue: -1,
|
||||||
maxValue: 99999
|
maxValue: 99999
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
fieldLabel: 'To',
|
fieldLabel: 'To',
|
||||||
strategy: {
|
strategy: {
|
||||||
xtype: 'number',
|
xtype: 'number',
|
||||||
decimalPrecision: 0,
|
decimalPrecision: 0,
|
||||||
minValue: -1,
|
minValue: -1,
|
||||||
maxValue: 99999
|
maxValue: 99999
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
optMan.bind('listen_ports', this.listenPorts);
|
optMan.bind('listen_ports', this.listenPorts);
|
||||||
|
|
||||||
fieldset = this.add({
|
fieldset = this.add({
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
border: false,
|
border: false,
|
||||||
title: _('Outgoing Ports'),
|
title: _('Outgoing Ports'),
|
||||||
style: 'margin-bottom: 5px; padding-bottom: 0px;',
|
style: 'margin-bottom: 5px; padding-bottom: 0px;',
|
||||||
autoHeight: true,
|
autoHeight: true,
|
||||||
labelWidth: 1,
|
labelWidth: 1,
|
||||||
defaultType: 'checkbox'
|
defaultType: 'checkbox'
|
||||||
});
|
});
|
||||||
optMan.bind('random_outgoing_ports', fieldset.add({
|
optMan.bind('random_outgoing_ports', fieldset.add({
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
labelSeparator: '',
|
labelSeparator: '',
|
||||||
boxLabel: _('Use Random Ports'),
|
boxLabel: _('Use Random Ports'),
|
||||||
name: 'random_outgoing_ports',
|
name: 'random_outgoing_ports',
|
||||||
height: 22,
|
height: 22,
|
||||||
listeners: {
|
listeners: {
|
||||||
'check': {
|
'check': {
|
||||||
fn: function(e, checked) {
|
fn: function(e, checked) {
|
||||||
this.outgoingPorts.setDisabled(checked);
|
this.outgoingPorts.setDisabled(checked);
|
||||||
},
|
},
|
||||||
scope: this
|
scope: this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
this.outgoingPorts = fieldset.add({
|
this.outgoingPorts = fieldset.add({
|
||||||
xtype: 'spinnergroup',
|
xtype: 'spinnergroup',
|
||||||
name: 'outgoing_ports',
|
name: 'outgoing_ports',
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
labelSeparator: '',
|
labelSeparator: '',
|
||||||
colCfg: {
|
colCfg: {
|
||||||
labelWidth: 40,
|
labelWidth: 40,
|
||||||
style: 'margin-right: 10px;'
|
style: 'margin-right: 10px;'
|
||||||
},
|
},
|
||||||
items: [{
|
items: [{
|
||||||
fieldLabel: 'From',
|
fieldLabel: 'From',
|
||||||
strategy: {
|
strategy: {
|
||||||
xtype: 'number',
|
xtype: 'number',
|
||||||
decimalPrecision: 0,
|
decimalPrecision: 0,
|
||||||
minValue: -1,
|
minValue: -1,
|
||||||
maxValue: 99999
|
maxValue: 99999
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
fieldLabel: 'To',
|
fieldLabel: 'To',
|
||||||
strategy: {
|
strategy: {
|
||||||
xtype: 'number',
|
xtype: 'number',
|
||||||
decimalPrecision: 0,
|
decimalPrecision: 0,
|
||||||
minValue: -1,
|
minValue: -1,
|
||||||
maxValue: 99999
|
maxValue: 99999
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
optMan.bind('outgoing_ports', this.outgoingPorts);
|
optMan.bind('outgoing_ports', this.outgoingPorts);
|
||||||
|
|
||||||
fieldset = this.add({
|
fieldset = this.add({
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
border: false,
|
border: false,
|
||||||
title: _('Network Interface'),
|
title: _('Network Interface'),
|
||||||
style: 'margin-bottom: 5px; padding-bottom: 0px;',
|
style: 'margin-bottom: 5px; padding-bottom: 0px;',
|
||||||
autoHeight: true,
|
autoHeight: true,
|
||||||
labelWidth: 1,
|
labelWidth: 1,
|
||||||
defaultType: 'textfield'
|
defaultType: 'textfield'
|
||||||
});
|
});
|
||||||
optMan.bind('listen_interface', fieldset.add({
|
optMan.bind('listen_interface', fieldset.add({
|
||||||
name: 'listen_interface',
|
name: 'listen_interface',
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
labelSeparator: '',
|
labelSeparator: '',
|
||||||
width: 200
|
width: 200
|
||||||
}));
|
}));
|
||||||
|
|
||||||
fieldset = this.add({
|
fieldset = this.add({
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
border: false,
|
border: false,
|
||||||
title: _('TOS'),
|
title: _('TOS'),
|
||||||
style: 'margin-bottom: 5px; padding-bottom: 0px;',
|
style: 'margin-bottom: 5px; padding-bottom: 0px;',
|
||||||
bodyStyle: 'margin: 0px; padding: 0px',
|
bodyStyle: 'margin: 0px; padding: 0px',
|
||||||
autoHeight: true,
|
autoHeight: true,
|
||||||
defaultType: 'textfield'
|
defaultType: 'textfield'
|
||||||
});
|
});
|
||||||
optMan.bind('peer_tos', fieldset.add({
|
optMan.bind('peer_tos', fieldset.add({
|
||||||
name: 'peer_tos',
|
name: 'peer_tos',
|
||||||
fieldLabel: _('Peer TOS Byte'),
|
fieldLabel: _('Peer TOS Byte'),
|
||||||
width: 80
|
width: 80
|
||||||
}));
|
}));
|
||||||
|
|
||||||
fieldset = this.add({
|
fieldset = this.add({
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
border: false,
|
border: false,
|
||||||
title: _('Network Extras'),
|
title: _('Network Extras'),
|
||||||
autoHeight: true,
|
autoHeight: true,
|
||||||
layout: 'table',
|
layout: 'table',
|
||||||
layoutConfig: {
|
layoutConfig: {
|
||||||
columns: 3
|
columns: 3
|
||||||
},
|
},
|
||||||
defaultType: 'checkbox'
|
defaultType: 'checkbox'
|
||||||
});
|
});
|
||||||
optMan.bind('upnp', fieldset.add({
|
optMan.bind('upnp', fieldset.add({
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
labelSeparator: '',
|
labelSeparator: '',
|
||||||
boxLabel: _('UPnP'),
|
boxLabel: _('UPnP'),
|
||||||
name: 'upnp'
|
name: 'upnp'
|
||||||
}));
|
}));
|
||||||
optMan.bind('natpmp', fieldset.add({
|
optMan.bind('natpmp', fieldset.add({
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
labelSeparator: '',
|
labelSeparator: '',
|
||||||
boxLabel: _('NAT-PMP'),
|
boxLabel: _('NAT-PMP'),
|
||||||
ctCls: 'x-deluge-indent-checkbox',
|
ctCls: 'x-deluge-indent-checkbox',
|
||||||
name: 'natpmp'
|
name: 'natpmp'
|
||||||
}));
|
}));
|
||||||
optMan.bind('utpex', fieldset.add({
|
optMan.bind('utpex', fieldset.add({
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
labelSeparator: '',
|
labelSeparator: '',
|
||||||
boxLabel: _('Peer Exchange'),
|
boxLabel: _('Peer Exchange'),
|
||||||
ctCls: 'x-deluge-indent-checkbox',
|
ctCls: 'x-deluge-indent-checkbox',
|
||||||
name: 'utpex'
|
name: 'utpex'
|
||||||
}));
|
}));
|
||||||
optMan.bind('lsd', fieldset.add({
|
optMan.bind('lsd', fieldset.add({
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
labelSeparator: '',
|
labelSeparator: '',
|
||||||
boxLabel: _('LSD'),
|
boxLabel: _('LSD'),
|
||||||
name: 'lsd'
|
name: 'lsd'
|
||||||
}));
|
}));
|
||||||
optMan.bind('dht', fieldset.add({
|
optMan.bind('dht', fieldset.add({
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
labelSeparator: '',
|
labelSeparator: '',
|
||||||
boxLabel: _('DHT'),
|
boxLabel: _('DHT'),
|
||||||
ctCls: 'x-deluge-indent-checkbox',
|
ctCls: 'x-deluge-indent-checkbox',
|
||||||
name: 'dht'
|
name: 'dht'
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -36,73 +36,73 @@ Ext.namespace('Deluge.preferences');
|
|||||||
* @extends Ext.form.FormPanel
|
* @extends Ext.form.FormPanel
|
||||||
*/
|
*/
|
||||||
Deluge.preferences.Other = Ext.extend(Ext.form.FormPanel, {
|
Deluge.preferences.Other = Ext.extend(Ext.form.FormPanel, {
|
||||||
constructor: function(config) {
|
constructor: function(config) {
|
||||||
config = Ext.apply({
|
config = Ext.apply({
|
||||||
border: false,
|
border: false,
|
||||||
title: _('Other'),
|
title: _('Other'),
|
||||||
layout: 'form'
|
layout: 'form'
|
||||||
}, config);
|
}, config);
|
||||||
Deluge.preferences.Other.superclass.constructor.call(this, config);
|
Deluge.preferences.Other.superclass.constructor.call(this, config);
|
||||||
},
|
},
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.preferences.Other.superclass.initComponent.call(this);
|
Deluge.preferences.Other.superclass.initComponent.call(this);
|
||||||
|
|
||||||
var optMan = deluge.preferences.getOptionsManager();
|
var optMan = deluge.preferences.getOptionsManager();
|
||||||
|
|
||||||
var fieldset = this.add({
|
var fieldset = this.add({
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
border: false,
|
border: false,
|
||||||
title: _('Updates'),
|
title: _('Updates'),
|
||||||
autoHeight: true,
|
autoHeight: true,
|
||||||
labelWidth: 1,
|
labelWidth: 1,
|
||||||
defaultType: 'checkbox'
|
defaultType: 'checkbox'
|
||||||
});
|
});
|
||||||
optMan.bind('new_release_check', fieldset.add({
|
optMan.bind('new_release_check', fieldset.add({
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
labelSeparator: '',
|
labelSeparator: '',
|
||||||
height: 22,
|
height: 22,
|
||||||
name: 'new_release_check',
|
name: 'new_release_check',
|
||||||
boxLabel: _('Be alerted about new releases')
|
boxLabel: _('Be alerted about new releases')
|
||||||
}));
|
}));
|
||||||
|
|
||||||
fieldset = this.add({
|
fieldset = this.add({
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
border: false,
|
border: false,
|
||||||
title: _('System Information'),
|
title: _('System Information'),
|
||||||
autoHeight: true,
|
autoHeight: true,
|
||||||
labelWidth: 1,
|
labelWidth: 1,
|
||||||
defaultType: 'checkbox'
|
defaultType: 'checkbox'
|
||||||
});
|
});
|
||||||
fieldset.add({
|
fieldset.add({
|
||||||
xtype: 'panel',
|
xtype: 'panel',
|
||||||
border: false,
|
border: false,
|
||||||
bodyCfg: {
|
bodyCfg: {
|
||||||
html: _('Help us improve Deluge by sending us your '
|
html: _('Help us improve Deluge by sending us your '
|
||||||
+ 'Python version, PyGTK version, OS and processor '
|
+ 'Python version, PyGTK version, OS and processor '
|
||||||
+ 'types. Absolutely no other information is sent.')
|
+ 'types. Absolutely no other information is sent.')
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
optMan.bind('send_info', fieldset.add({
|
optMan.bind('send_info', fieldset.add({
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
labelSeparator: '',
|
labelSeparator: '',
|
||||||
height: 22,
|
height: 22,
|
||||||
boxLabel: _('Yes, please send anonymous statistics'),
|
boxLabel: _('Yes, please send anonymous statistics'),
|
||||||
name: 'send_info'
|
name: 'send_info'
|
||||||
}));
|
}));
|
||||||
|
|
||||||
fieldset = this.add({
|
fieldset = this.add({
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
border: false,
|
border: false,
|
||||||
title: _('GeoIP Database'),
|
title: _('GeoIP Database'),
|
||||||
autoHeight: true,
|
autoHeight: true,
|
||||||
labelWidth: 80,
|
labelWidth: 80,
|
||||||
defaultType: 'textfield'
|
defaultType: 'textfield'
|
||||||
});
|
});
|
||||||
optMan.bind('geoip_db_location', fieldset.add({
|
optMan.bind('geoip_db_location', fieldset.add({
|
||||||
name: 'geoip_db_location',
|
name: 'geoip_db_location',
|
||||||
fieldLabel: _('Location'),
|
fieldLabel: _('Location'),
|
||||||
width: 200
|
width: 200
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -37,234 +37,234 @@ Ext.namespace('Deluge.preferences');
|
|||||||
*/
|
*/
|
||||||
Deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
|
Deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
|
||||||
|
|
||||||
layout: 'border',
|
layout: 'border',
|
||||||
title: _('Plugins'),
|
title: _('Plugins'),
|
||||||
border: false,
|
border: false,
|
||||||
height: 400,
|
height: 400,
|
||||||
cls: 'x-deluge-plugins',
|
cls: 'x-deluge-plugins',
|
||||||
|
|
||||||
pluginTemplate: new Ext.Template(
|
pluginTemplate: new Ext.Template(
|
||||||
'<dl class="singleline">' +
|
'<dl class="singleline">' +
|
||||||
'<dt>Author:</dt><dd>{author}</dd>' +
|
'<dt>Author:</dt><dd>{author}</dd>' +
|
||||||
'<dt>Version:</dt><dd>{version}</dd>' +
|
'<dt>Version:</dt><dd>{version}</dd>' +
|
||||||
'<dt>Author Email:</dt><dd>{email}</dd>' +
|
'<dt>Author Email:</dt><dd>{email}</dd>' +
|
||||||
'<dt>Homepage:</dt><dd>{homepage}</dd>' +
|
'<dt>Homepage:</dt><dd>{homepage}</dd>' +
|
||||||
'<dt>Details:</dt><dd>{details}</dd>' +
|
'<dt>Details:</dt><dd>{details}</dd>' +
|
||||||
'</dl>'
|
'</dl>'
|
||||||
),
|
),
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.preferences.Plugins.superclass.initComponent.call(this);
|
Deluge.preferences.Plugins.superclass.initComponent.call(this);
|
||||||
this.defaultValues = {
|
this.defaultValues = {
|
||||||
'version': '',
|
'version': '',
|
||||||
'email': '',
|
'email': '',
|
||||||
'homepage': '',
|
'homepage': '',
|
||||||
'details': ''
|
'details': ''
|
||||||
};
|
};
|
||||||
this.pluginTemplate.compile();
|
this.pluginTemplate.compile();
|
||||||
|
|
||||||
var checkboxRenderer = function(v, p, record){
|
var checkboxRenderer = function(v, p, record){
|
||||||
p.css += ' x-grid3-check-col-td';
|
p.css += ' x-grid3-check-col-td';
|
||||||
return '<div class="x-grid3-check-col'+(v?'-on':'')+'"> </div>';
|
return '<div class="x-grid3-check-col'+(v?'-on':'')+'"> </div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
this.list = this.add({
|
this.list = this.add({
|
||||||
xtype: 'listview',
|
xtype: 'listview',
|
||||||
store: new Ext.data.ArrayStore({
|
store: new Ext.data.ArrayStore({
|
||||||
fields: [
|
fields: [
|
||||||
{name: 'enabled', mapping: 0},
|
{name: 'enabled', mapping: 0},
|
||||||
{name: 'plugin', mapping: 1}
|
{name: 'plugin', mapping: 1}
|
||||||
]
|
]
|
||||||
}),
|
}),
|
||||||
columns: [{
|
columns: [{
|
||||||
id: 'enabled',
|
id: 'enabled',
|
||||||
header: _('Enabled'),
|
header: _('Enabled'),
|
||||||
width: .2,
|
width: .2,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
tpl: new Ext.XTemplate('{enabled:this.getCheckbox}', {
|
tpl: new Ext.XTemplate('{enabled:this.getCheckbox}', {
|
||||||
getCheckbox: function(v) {
|
getCheckbox: function(v) {
|
||||||
return '<div class="x-grid3-check-col'+(v?'-on':'')+'" rel="chkbox"> </div>';
|
return '<div class="x-grid3-check-col'+(v?'-on':'')+'" rel="chkbox"> </div>';
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
dataIndex: 'enabled'
|
dataIndex: 'enabled'
|
||||||
}, {
|
}, {
|
||||||
id: 'plugin',
|
id: 'plugin',
|
||||||
header: _('Plugin'),
|
header: _('Plugin'),
|
||||||
width: .8,
|
width: .8,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
dataIndex: 'plugin'
|
dataIndex: 'plugin'
|
||||||
}],
|
}],
|
||||||
singleSelect: true,
|
singleSelect: true,
|
||||||
autoExpandColumn: 'plugin',
|
autoExpandColumn: 'plugin',
|
||||||
listeners: {
|
listeners: {
|
||||||
selectionchange: {fn: this.onPluginSelect, scope: this}
|
selectionchange: {fn: this.onPluginSelect, scope: this}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.panel = this.add({
|
this.panel = this.add({
|
||||||
region: 'center',
|
region: 'center',
|
||||||
autoScroll: true,
|
autoScroll: true,
|
||||||
margins: '5 5 5 5',
|
margins: '5 5 5 5',
|
||||||
items: [this.list],
|
items: [this.list],
|
||||||
bbar: new Ext.Toolbar({
|
bbar: new Ext.Toolbar({
|
||||||
items: [{
|
items: [{
|
||||||
cls: 'x-btn-text-icon',
|
cls: 'x-btn-text-icon',
|
||||||
iconCls: 'x-deluge-install-plugin',
|
iconCls: 'x-deluge-install-plugin',
|
||||||
text: _('Install'),
|
text: _('Install'),
|
||||||
handler: this.onInstallPluginWindow,
|
handler: this.onInstallPluginWindow,
|
||||||
scope: this
|
scope: this
|
||||||
}, '->', {
|
}, '->', {
|
||||||
cls: 'x-btn-text-icon',
|
cls: 'x-btn-text-icon',
|
||||||
text: _('Find More'),
|
text: _('Find More'),
|
||||||
iconCls: 'x-deluge-find-more',
|
iconCls: 'x-deluge-find-more',
|
||||||
handler: this.onFindMorePlugins,
|
handler: this.onFindMorePlugins,
|
||||||
scope: this
|
scope: this
|
||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
var pp = this.pluginInfo = this.add({
|
var pp = this.pluginInfo = this.add({
|
||||||
xtype: 'panel',
|
xtype: 'panel',
|
||||||
border: true,
|
border: true,
|
||||||
height: 160,
|
height: 160,
|
||||||
region: 'south',
|
region: 'south',
|
||||||
margins: '0 5 5 5'
|
margins: '0 5 5 5'
|
||||||
});
|
});
|
||||||
var fieldset = pp.add({
|
var fieldset = pp.add({
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
title: _('Info'),
|
title: _('Info'),
|
||||||
border: false,
|
border: false,
|
||||||
autoHeight: true,
|
autoHeight: true,
|
||||||
labelWidth: 1,
|
labelWidth: 1,
|
||||||
style: 'margin-top: 5px;'
|
style: 'margin-top: 5px;'
|
||||||
});
|
});
|
||||||
this.pluginInfo = fieldset.add({
|
this.pluginInfo = fieldset.add({
|
||||||
xtype: 'panel',
|
xtype: 'panel',
|
||||||
border: false,
|
border: false,
|
||||||
bodyCfg: {
|
bodyCfg: {
|
||||||
style: 'margin-left: 10px'
|
style: 'margin-left: 10px'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.pluginInfo.on('render', this.onPluginInfoRender, this);
|
this.pluginInfo.on('render', this.onPluginInfoRender, this);
|
||||||
this.list.on('click', this.onNodeClick, this);
|
this.list.on('click', this.onNodeClick, this);
|
||||||
deluge.preferences.on('show', this.onPreferencesShow, this);
|
deluge.preferences.on('show', this.onPreferencesShow, this);
|
||||||
deluge.events.on('PluginDisabledEvent', this.onPluginDisabled, this);
|
deluge.events.on('PluginDisabledEvent', this.onPluginDisabled, this);
|
||||||
deluge.events.on('PluginEnabledEvent', this.onPluginEnabled, this);
|
deluge.events.on('PluginEnabledEvent', this.onPluginEnabled, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
disablePlugin: function(plugin) {
|
disablePlugin: function(plugin) {
|
||||||
deluge.client.core.disable_plugin(plugin);
|
deluge.client.core.disable_plugin(plugin);
|
||||||
},
|
},
|
||||||
|
|
||||||
enablePlugin: function(plugin) {
|
enablePlugin: function(plugin) {
|
||||||
deluge.client.core.enable_plugin(plugin);
|
deluge.client.core.enable_plugin(plugin);
|
||||||
},
|
},
|
||||||
|
|
||||||
setInfo: function(plugin) {
|
setInfo: function(plugin) {
|
||||||
if (!this.pluginInfo.rendered) return;
|
if (!this.pluginInfo.rendered) return;
|
||||||
var values = plugin || this.defaultValues;
|
var values = plugin || this.defaultValues;
|
||||||
this.pluginInfo.body.dom.innerHTML = this.pluginTemplate.apply(values);
|
this.pluginInfo.body.dom.innerHTML = this.pluginTemplate.apply(values);
|
||||||
},
|
},
|
||||||
|
|
||||||
updatePlugins: function() {
|
updatePlugins: function() {
|
||||||
deluge.client.web.get_plugins({
|
deluge.client.web.get_plugins({
|
||||||
success: this.onGotPlugins,
|
success: this.onGotPlugins,
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
updatePluginsGrid: function() {
|
updatePluginsGrid: function() {
|
||||||
var plugins = [];
|
var plugins = [];
|
||||||
Ext.each(this.availablePlugins, function(plugin) {
|
Ext.each(this.availablePlugins, function(plugin) {
|
||||||
if (this.enabledPlugins.indexOf(plugin) > -1) {
|
if (this.enabledPlugins.indexOf(plugin) > -1) {
|
||||||
plugins.push([true, plugin]);
|
plugins.push([true, plugin]);
|
||||||
} else {
|
} else {
|
||||||
plugins.push([false, plugin]);
|
plugins.push([false, plugin]);
|
||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
this.list.getStore().loadData(plugins);
|
this.list.getStore().loadData(plugins);
|
||||||
},
|
},
|
||||||
|
|
||||||
onNodeClick: function(dv, index, node, e) {
|
onNodeClick: function(dv, index, node, e) {
|
||||||
var el = new Ext.Element(e.target);
|
var el = new Ext.Element(e.target);
|
||||||
if (el.getAttribute('rel') != 'chkbox') return;
|
if (el.getAttribute('rel') != 'chkbox') return;
|
||||||
|
|
||||||
var r = dv.getStore().getAt(index);
|
var r = dv.getStore().getAt(index);
|
||||||
r.set('enabled', !r.get('enabled'));
|
r.set('enabled', !r.get('enabled'));
|
||||||
r.commit();
|
r.commit();
|
||||||
if (r.get('enabled')) {
|
if (r.get('enabled')) {
|
||||||
this.enablePlugin(r.get('plugin'));
|
this.enablePlugin(r.get('plugin'));
|
||||||
} else {
|
} else {
|
||||||
this.disablePlugin(r.get('plugin'));
|
this.disablePlugin(r.get('plugin'));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onFindMorePlugins: function() {
|
onFindMorePlugins: function() {
|
||||||
window.open('http://dev.deluge-torrent.org/wiki/Plugins');
|
window.open('http://dev.deluge-torrent.org/wiki/Plugins');
|
||||||
},
|
},
|
||||||
|
|
||||||
onGotPlugins: function(plugins) {
|
onGotPlugins: function(plugins) {
|
||||||
this.enabledPlugins = plugins.enabled_plugins;
|
this.enabledPlugins = plugins.enabled_plugins;
|
||||||
this.availablePlugins = plugins.available_plugins;
|
this.availablePlugins = plugins.available_plugins;
|
||||||
this.setInfo();
|
this.setInfo();
|
||||||
this.updatePluginsGrid();
|
this.updatePluginsGrid();
|
||||||
},
|
},
|
||||||
|
|
||||||
onGotPluginInfo: function(info) {
|
onGotPluginInfo: function(info) {
|
||||||
var values = {
|
var values = {
|
||||||
author: info['Author'],
|
author: info['Author'],
|
||||||
version: info['Version'],
|
version: info['Version'],
|
||||||
email: info['Author-email'],
|
email: info['Author-email'],
|
||||||
homepage: info['Home-page'],
|
homepage: info['Home-page'],
|
||||||
details: info['Description']
|
details: info['Description']
|
||||||
}
|
}
|
||||||
this.setInfo(values);
|
this.setInfo(values);
|
||||||
delete info;
|
delete info;
|
||||||
},
|
},
|
||||||
|
|
||||||
onInstallPluginWindow: function() {
|
onInstallPluginWindow: function() {
|
||||||
if (!this.installWindow) {
|
if (!this.installWindow) {
|
||||||
this.installWindow = new Deluge.preferences.InstallPluginWindow();
|
this.installWindow = new Deluge.preferences.InstallPluginWindow();
|
||||||
this.installWindow.on('pluginadded', this.onPluginInstall, this);
|
this.installWindow.on('pluginadded', this.onPluginInstall, this);
|
||||||
}
|
}
|
||||||
this.installWindow.show();
|
this.installWindow.show();
|
||||||
},
|
},
|
||||||
|
|
||||||
onPluginEnabled: function(pluginName) {
|
onPluginEnabled: function(pluginName) {
|
||||||
var index = this.list.getStore().find('plugin', pluginName);
|
var index = this.list.getStore().find('plugin', pluginName);
|
||||||
if (index == -1) return;
|
if (index == -1) return;
|
||||||
var plugin = this.list.getStore().getAt(index);
|
var plugin = this.list.getStore().getAt(index);
|
||||||
plugin.set('enabled', true);
|
plugin.set('enabled', true);
|
||||||
plugin.commit();
|
plugin.commit();
|
||||||
},
|
},
|
||||||
|
|
||||||
onPluginDisabled: function(pluginName) {
|
onPluginDisabled: function(pluginName) {
|
||||||
var index = this.list.getStore().find('plugin', pluginName);
|
var index = this.list.getStore().find('plugin', pluginName);
|
||||||
if (index == -1) return;
|
if (index == -1) return;
|
||||||
var plugin = this.list.getStore().getAt(index);
|
var plugin = this.list.getStore().getAt(index);
|
||||||
plugin.set('enabled', false);
|
plugin.set('enabled', false);
|
||||||
plugin.commit();
|
plugin.commit();
|
||||||
},
|
},
|
||||||
|
|
||||||
onPluginInstall: function() {
|
onPluginInstall: function() {
|
||||||
this.updatePlugins();
|
this.updatePlugins();
|
||||||
},
|
},
|
||||||
|
|
||||||
onPluginSelect: function(dv, selections) {
|
onPluginSelect: function(dv, selections) {
|
||||||
if (selections.length == 0) return;
|
if (selections.length == 0) return;
|
||||||
var r = dv.getRecords(selections)[0];
|
var r = dv.getRecords(selections)[0];
|
||||||
deluge.client.web.get_plugin_info(r.get('plugin'), {
|
deluge.client.web.get_plugin_info(r.get('plugin'), {
|
||||||
success: this.onGotPluginInfo,
|
success: this.onGotPluginInfo,
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onPreferencesShow: function() {
|
onPreferencesShow: function() {
|
||||||
this.updatePlugins();
|
this.updatePlugins();
|
||||||
},
|
},
|
||||||
|
|
||||||
onPluginInfoRender: function(ct, position) {
|
onPluginInfoRender: function(ct, position) {
|
||||||
this.setInfo();
|
this.setInfo();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -39,207 +39,207 @@ PreferencesRecord = Ext.data.Record.create([{name:'name', type:'string'}]);
|
|||||||
*/
|
*/
|
||||||
Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
|
Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {String} currentPage The currently selected page.
|
* @property {String} currentPage The currently selected page.
|
||||||
*/
|
*/
|
||||||
currentPage: null,
|
currentPage: null,
|
||||||
|
|
||||||
title: _('Preferences'),
|
title: _('Preferences'),
|
||||||
layout: 'border',
|
layout: 'border',
|
||||||
width: 485,
|
width: 485,
|
||||||
height: 500,
|
height: 500,
|
||||||
|
|
||||||
buttonAlign: 'right',
|
buttonAlign: 'right',
|
||||||
closeAction: 'hide',
|
closeAction: 'hide',
|
||||||
closable: true,
|
closable: true,
|
||||||
iconCls: 'x-deluge-preferences',
|
iconCls: 'x-deluge-preferences',
|
||||||
plain: true,
|
plain: true,
|
||||||
resizable: false,
|
resizable: false,
|
||||||
|
|
||||||
pages: {},
|
pages: {},
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.preferences.PreferencesWindow.superclass.initComponent.call(this);
|
Deluge.preferences.PreferencesWindow.superclass.initComponent.call(this);
|
||||||
|
|
||||||
this.list = new Ext.list.ListView({
|
this.list = new Ext.list.ListView({
|
||||||
store: new Ext.data.Store(),
|
store: new Ext.data.Store(),
|
||||||
columns: [{
|
columns: [{
|
||||||
id: 'name',
|
id: 'name',
|
||||||
renderer: fplain,
|
renderer: fplain,
|
||||||
dataIndex: 'name'
|
dataIndex: 'name'
|
||||||
}],
|
}],
|
||||||
singleSelect: true,
|
singleSelect: true,
|
||||||
listeners: {
|
listeners: {
|
||||||
'selectionchange': {
|
'selectionchange': {
|
||||||
fn: this.onPageSelect, scope: this
|
fn: this.onPageSelect, scope: this
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
hideHeaders: true,
|
hideHeaders: true,
|
||||||
autoExpandColumn: 'name',
|
autoExpandColumn: 'name',
|
||||||
deferredRender: false,
|
deferredRender: false,
|
||||||
autoScroll: true,
|
autoScroll: true,
|
||||||
collapsible: true
|
collapsible: true
|
||||||
});
|
});
|
||||||
this.add({
|
this.add({
|
||||||
region: 'west',
|
region: 'west',
|
||||||
title: _('Categories'),
|
title: _('Categories'),
|
||||||
items: [this.list],
|
items: [this.list],
|
||||||
width: 120,
|
width: 120,
|
||||||
margins: '5 0 5 5',
|
margins: '5 0 5 5',
|
||||||
cmargins: '5 0 5 5'
|
cmargins: '5 0 5 5'
|
||||||
});
|
});
|
||||||
|
|
||||||
this.configPanel = this.add({
|
this.configPanel = this.add({
|
||||||
type: 'container',
|
type: 'container',
|
||||||
autoDestroy: false,
|
autoDestroy: false,
|
||||||
region: 'center',
|
region: 'center',
|
||||||
layout: 'card',
|
layout: 'card',
|
||||||
layoutConfig: {
|
layoutConfig: {
|
||||||
deferredRender: true
|
deferredRender: true
|
||||||
},
|
},
|
||||||
autoScroll: true,
|
autoScroll: true,
|
||||||
width: 300,
|
width: 300,
|
||||||
margins: '5 5 5 5',
|
margins: '5 5 5 5',
|
||||||
cmargins: '5 5 5 5'
|
cmargins: '5 5 5 5'
|
||||||
});
|
});
|
||||||
|
|
||||||
this.addButton(_('Close'), this.onClose, this);
|
this.addButton(_('Close'), this.onClose, this);
|
||||||
this.addButton(_('Apply'), this.onApply, this);
|
this.addButton(_('Apply'), this.onApply, this);
|
||||||
this.addButton(_('Ok'), this.onOk, this);
|
this.addButton(_('Ok'), this.onOk, this);
|
||||||
|
|
||||||
this.optionsManager = new Deluge.OptionsManager();
|
this.optionsManager = new Deluge.OptionsManager();
|
||||||
this.on('afterrender', this.onAfterRender, this);
|
this.on('afterrender', this.onAfterRender, this);
|
||||||
this.on('show', this.onShow, this);
|
this.on('show', this.onShow, this);
|
||||||
|
|
||||||
this.initPages();
|
this.initPages();
|
||||||
},
|
},
|
||||||
|
|
||||||
initPages: function() {
|
initPages: function() {
|
||||||
deluge.preferences = this;
|
deluge.preferences = this;
|
||||||
this.addPage(new Deluge.preferences.Downloads());
|
this.addPage(new Deluge.preferences.Downloads());
|
||||||
this.addPage(new Deluge.preferences.Network());
|
this.addPage(new Deluge.preferences.Network());
|
||||||
this.addPage(new Deluge.preferences.Encryption());
|
this.addPage(new Deluge.preferences.Encryption());
|
||||||
this.addPage(new Deluge.preferences.Bandwidth());
|
this.addPage(new Deluge.preferences.Bandwidth());
|
||||||
this.addPage(new Deluge.preferences.Interface());
|
this.addPage(new Deluge.preferences.Interface());
|
||||||
this.addPage(new Deluge.preferences.Other());
|
this.addPage(new Deluge.preferences.Other());
|
||||||
this.addPage(new Deluge.preferences.Daemon());
|
this.addPage(new Deluge.preferences.Daemon());
|
||||||
this.addPage(new Deluge.preferences.Queue());
|
this.addPage(new Deluge.preferences.Queue());
|
||||||
this.addPage(new Deluge.preferences.Proxy());
|
this.addPage(new Deluge.preferences.Proxy());
|
||||||
this.addPage(new Deluge.preferences.Cache());
|
this.addPage(new Deluge.preferences.Cache());
|
||||||
this.addPage(new Deluge.preferences.Plugins());
|
this.addPage(new Deluge.preferences.Plugins());
|
||||||
},
|
},
|
||||||
|
|
||||||
onApply: function(e) {
|
onApply: function(e) {
|
||||||
var changed = this.optionsManager.getDirty();
|
var changed = this.optionsManager.getDirty();
|
||||||
if (!Ext.isObjectEmpty(changed)) {
|
if (!Ext.isObjectEmpty(changed)) {
|
||||||
deluge.client.core.set_config(changed, {
|
deluge.client.core.set_config(changed, {
|
||||||
success: this.onSetConfig,
|
success: this.onSetConfig,
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var page in this.pages) {
|
for (var page in this.pages) {
|
||||||
if (this.pages[page].onApply) this.pages[page].onApply();
|
if (this.pages[page].onApply) this.pages[page].onApply();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the options manager for the preferences window.
|
* Return the options manager for the preferences window.
|
||||||
* @returns {Deluge.OptionsManager} the options manager
|
* @returns {Deluge.OptionsManager} the options manager
|
||||||
*/
|
*/
|
||||||
getOptionsManager: function() {
|
getOptionsManager: function() {
|
||||||
return this.optionsManager;
|
return this.optionsManager;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a page to the preferences window.
|
* Adds a page to the preferences window.
|
||||||
* @param {Mixed} page
|
* @param {Mixed} page
|
||||||
*/
|
*/
|
||||||
addPage: function(page) {
|
addPage: function(page) {
|
||||||
var store = this.list.getStore();
|
var store = this.list.getStore();
|
||||||
var name = page.title;
|
var name = page.title;
|
||||||
store.add([new PreferencesRecord({name: name})]);
|
store.add([new PreferencesRecord({name: name})]);
|
||||||
page['bodyStyle'] = 'padding: 5px';
|
page['bodyStyle'] = 'padding: 5px';
|
||||||
page.preferences = this;
|
page.preferences = this;
|
||||||
this.pages[name] = this.configPanel.add(page);
|
this.pages[name] = this.configPanel.add(page);
|
||||||
this.pages[name].index = -1;
|
this.pages[name].index = -1;
|
||||||
return this.pages[name];
|
return this.pages[name];
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a preferences page from the window.
|
* Removes a preferences page from the window.
|
||||||
* @param {mixed} name
|
* @param {mixed} name
|
||||||
*/
|
*/
|
||||||
removePage: function(page) {
|
removePage: function(page) {
|
||||||
var name = page.title;
|
var name = page.title;
|
||||||
var store = this.list.getStore();
|
var store = this.list.getStore();
|
||||||
store.removeAt(store.find('name', name));
|
store.removeAt(store.find('name', name));
|
||||||
this.configPanel.remove(page);
|
this.configPanel.remove(page);
|
||||||
delete this.pages[page.title];
|
delete this.pages[page.title];
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Select which preferences page is displayed.
|
* Select which preferences page is displayed.
|
||||||
* @param {String} page The page name to change to
|
* @param {String} page The page name to change to
|
||||||
*/
|
*/
|
||||||
selectPage: function(page) {
|
selectPage: function(page) {
|
||||||
if (this.pages[page].index < 0) {
|
if (this.pages[page].index < 0) {
|
||||||
this.pages[page].index = this.configPanel.items.indexOf(this.pages[page]);
|
this.pages[page].index = this.configPanel.items.indexOf(this.pages[page]);
|
||||||
}
|
}
|
||||||
this.list.select(this.pages[page].index);
|
this.list.select(this.pages[page].index);
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
doSelectPage: function(page) {
|
doSelectPage: function(page) {
|
||||||
if (this.pages[page].index < 0) {
|
if (this.pages[page].index < 0) {
|
||||||
this.pages[page].index = this.configPanel.items.indexOf(this.pages[page]);
|
this.pages[page].index = this.configPanel.items.indexOf(this.pages[page]);
|
||||||
}
|
}
|
||||||
this.configPanel.getLayout().setActiveItem(this.pages[page].index);
|
this.configPanel.getLayout().setActiveItem(this.pages[page].index);
|
||||||
this.currentPage = page;
|
this.currentPage = page;
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onGotConfig: function(config) {
|
onGotConfig: function(config) {
|
||||||
this.getOptionsManager().set(config);
|
this.getOptionsManager().set(config);
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onPageSelect: function(list, selections) {
|
onPageSelect: function(list, selections) {
|
||||||
var r = list.getRecord(selections[0]);
|
var r = list.getRecord(selections[0]);
|
||||||
this.doSelectPage(r.get('name'));
|
this.doSelectPage(r.get('name'));
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onSetConfig: function() {
|
onSetConfig: function() {
|
||||||
this.getOptionsManager().commit();
|
this.getOptionsManager().commit();
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onAfterRender: function() {
|
onAfterRender: function() {
|
||||||
if (!this.list.getSelectionCount()) {
|
if (!this.list.getSelectionCount()) {
|
||||||
this.list.select(0);
|
this.list.select(0);
|
||||||
}
|
}
|
||||||
this.configPanel.getLayout().setActiveItem(0);
|
this.configPanel.getLayout().setActiveItem(0);
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onShow: function() {
|
onShow: function() {
|
||||||
if (!deluge.client.core) return;
|
if (!deluge.client.core) return;
|
||||||
deluge.client.core.get_config({
|
deluge.client.core.get_config({
|
||||||
success: this.onGotConfig,
|
success: this.onGotConfig,
|
||||||
scope: this
|
scope: this
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onClose: function() {
|
onClose: function() {
|
||||||
this.hide();
|
this.hide();
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onOk: function() {
|
onOk: function() {
|
||||||
deluge.client.core.set_config(this.optionsManager.getDirty());
|
deluge.client.core.set_config(this.optionsManager.getDirty());
|
||||||
this.hide();
|
this.hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -15,9 +15,9 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, write to:
|
* along with this program. If not, write to:
|
||||||
* The Free Software Foundation, Inc.,
|
* The Free Software Foundation, Inc.,
|
||||||
* 51 Franklin Street, Fifth Floor
|
* 51 Franklin Street, Fifth Floor
|
||||||
* Boston, MA 02110-1301, USA.
|
* Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* In addition, as a special exception, the copyright holders give
|
* In addition, as a special exception, the copyright holders give
|
||||||
* permission to link the code of portions of this program with the OpenSSL
|
* permission to link the code of portions of this program with the OpenSSL
|
||||||
@ -37,125 +37,125 @@ Ext.ns('Deluge.preferences');
|
|||||||
*/
|
*/
|
||||||
Deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, {
|
Deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, {
|
||||||
|
|
||||||
border: false,
|
border: false,
|
||||||
autoHeight: true,
|
autoHeight: true,
|
||||||
labelWidth: 70,
|
labelWidth: 70,
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.preferences.ProxyField.superclass.initComponent.call(this);
|
Deluge.preferences.ProxyField.superclass.initComponent.call(this);
|
||||||
this.proxyType = this.add({
|
this.proxyType = this.add({
|
||||||
xtype: 'combo',
|
xtype: 'combo',
|
||||||
fieldLabel: _('Type'),
|
fieldLabel: _('Type'),
|
||||||
name: 'proxytype',
|
name: 'proxytype',
|
||||||
mode: 'local',
|
mode: 'local',
|
||||||
width: 150,
|
width: 150,
|
||||||
store: new Ext.data.ArrayStore({
|
store: new Ext.data.ArrayStore({
|
||||||
fields: ['id', 'text'],
|
fields: ['id', 'text'],
|
||||||
data: [
|
data: [
|
||||||
[0, _('None')],
|
[0, _('None')],
|
||||||
[1, _('Socksv4')],
|
[1, _('Socksv4')],
|
||||||
[2, _('Socksv5')],
|
[2, _('Socksv5')],
|
||||||
[3, _('Socksv5 with Auth')],
|
[3, _('Socksv5 with Auth')],
|
||||||
[4, _('HTTP')],
|
[4, _('HTTP')],
|
||||||
[5, _('HTTP with Auth')]
|
[5, _('HTTP with Auth')]
|
||||||
]
|
]
|
||||||
}),
|
}),
|
||||||
editable: false,
|
editable: false,
|
||||||
triggerAction: 'all',
|
triggerAction: 'all',
|
||||||
valueField: 'id',
|
valueField: 'id',
|
||||||
displayField: 'text'
|
displayField: 'text'
|
||||||
});
|
});
|
||||||
this.hostname = this.add({
|
this.hostname = this.add({
|
||||||
xtype: 'textfield',
|
xtype: 'textfield',
|
||||||
name: 'hostname',
|
name: 'hostname',
|
||||||
fieldLabel: _('Host'),
|
fieldLabel: _('Host'),
|
||||||
width: 220
|
width: 220
|
||||||
});
|
});
|
||||||
|
|
||||||
this.port = this.add({
|
this.port = this.add({
|
||||||
xtype: 'spinnerfield',
|
xtype: 'spinnerfield',
|
||||||
name: 'port',
|
name: 'port',
|
||||||
fieldLabel: _('Port'),
|
fieldLabel: _('Port'),
|
||||||
width: 80,
|
width: 80,
|
||||||
decimalPrecision: 0,
|
decimalPrecision: 0,
|
||||||
minValue: -1,
|
minValue: -1,
|
||||||
maxValue: 99999
|
maxValue: 99999
|
||||||
});
|
});
|
||||||
|
|
||||||
this.username = this.add({
|
this.username = this.add({
|
||||||
xtype: 'textfield',
|
xtype: 'textfield',
|
||||||
name: 'username',
|
name: 'username',
|
||||||
fieldLabel: _('Username'),
|
fieldLabel: _('Username'),
|
||||||
width: 220
|
width: 220
|
||||||
});
|
});
|
||||||
|
|
||||||
this.password = this.add({
|
this.password = this.add({
|
||||||
xtype: 'textfield',
|
xtype: 'textfield',
|
||||||
name: 'password',
|
name: 'password',
|
||||||
fieldLabel: _('Password'),
|
fieldLabel: _('Password'),
|
||||||
inputType: 'password',
|
inputType: 'password',
|
||||||
width: 220
|
width: 220
|
||||||
});
|
});
|
||||||
|
|
||||||
this.proxyType.on('change', this.onFieldChange, this);
|
this.proxyType.on('change', this.onFieldChange, this);
|
||||||
this.proxyType.on('select', this.onTypeSelect, this);
|
this.proxyType.on('select', this.onTypeSelect, this);
|
||||||
this.setting = false;
|
this.setting = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
getName: function() {
|
getName: function() {
|
||||||
return this.initialConfig.name;
|
return this.initialConfig.name;
|
||||||
},
|
},
|
||||||
|
|
||||||
getValue: function() {
|
getValue: function() {
|
||||||
return {
|
return {
|
||||||
'type': this.proxyType.getValue(),
|
'type': this.proxyType.getValue(),
|
||||||
'hostname': this.hostname.getValue(),
|
'hostname': this.hostname.getValue(),
|
||||||
'port': Number(this.port.getValue()),
|
'port': Number(this.port.getValue()),
|
||||||
'username': this.username.getValue(),
|
'username': this.username.getValue(),
|
||||||
'password': this.password.getValue()
|
'password': this.password.getValue()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// Set the values of the proxies
|
// Set the values of the proxies
|
||||||
setValue: function(value) {
|
setValue: function(value) {
|
||||||
this.setting = true;
|
this.setting = true;
|
||||||
this.proxyType.setValue(value['type']);
|
this.proxyType.setValue(value['type']);
|
||||||
var index = this.proxyType.getStore().find('id', value['type']);
|
var index = this.proxyType.getStore().find('id', value['type']);
|
||||||
var record = this.proxyType.getStore().getAt(index);
|
var record = this.proxyType.getStore().getAt(index);
|
||||||
|
|
||||||
this.hostname.setValue(value['hostname']);
|
this.hostname.setValue(value['hostname']);
|
||||||
this.port.setValue(value['port']);
|
this.port.setValue(value['port']);
|
||||||
this.username.setValue(value['username']);
|
this.username.setValue(value['username']);
|
||||||
this.password.setValue(value['password']);
|
this.password.setValue(value['password']);
|
||||||
this.onTypeSelect(this.type, record, index);
|
this.onTypeSelect(this.type, record, index);
|
||||||
this.setting = false;
|
this.setting = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
onFieldChange: function(field, newValue, oldValue) {
|
onFieldChange: function(field, newValue, oldValue) {
|
||||||
if (this.setting) return;
|
if (this.setting) return;
|
||||||
var newValues = this.getValue();
|
var newValues = this.getValue();
|
||||||
var oldValues = Ext.apply({}, newValues);
|
var oldValues = Ext.apply({}, newValues);
|
||||||
oldValues[field.getName()] = oldValue;
|
oldValues[field.getName()] = oldValue;
|
||||||
|
|
||||||
this.fireEvent('change', this, newValues, oldValues);
|
this.fireEvent('change', this, newValues, oldValues);
|
||||||
},
|
},
|
||||||
|
|
||||||
onTypeSelect: function(combo, record, index) {
|
onTypeSelect: function(combo, record, index) {
|
||||||
var typeId = record.get('id');
|
var typeId = record.get('id');
|
||||||
if (typeId > 0) {
|
if (typeId > 0) {
|
||||||
this.hostname.show();
|
this.hostname.show();
|
||||||
this.port.show();
|
this.port.show();
|
||||||
} else {
|
} else {
|
||||||
this.hostname.hide();
|
this.hostname.hide();
|
||||||
this.port.hide();
|
this.port.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeId == 3 || typeId == 5) {
|
if (typeId == 3 || typeId == 5) {
|
||||||
this.username.show();
|
this.username.show();
|
||||||
this.password.show();
|
this.password.show();
|
||||||
} else {
|
} else {
|
||||||
this.username.hide();
|
this.username.hide();
|
||||||
this.password.hide();
|
this.password.hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -36,64 +36,64 @@ Ext.namespace('Deluge.preferences');
|
|||||||
* @extends Ext.form.FormPanel
|
* @extends Ext.form.FormPanel
|
||||||
*/
|
*/
|
||||||
Deluge.preferences.Proxy = Ext.extend(Ext.form.FormPanel, {
|
Deluge.preferences.Proxy = Ext.extend(Ext.form.FormPanel, {
|
||||||
constructor: function(config) {
|
constructor: function(config) {
|
||||||
config = Ext.apply({
|
config = Ext.apply({
|
||||||
border: false,
|
border: false,
|
||||||
title: _('Proxy'),
|
title: _('Proxy'),
|
||||||
layout: 'form'
|
layout: 'form'
|
||||||
}, config);
|
}, config);
|
||||||
Deluge.preferences.Proxy.superclass.constructor.call(this, config);
|
Deluge.preferences.Proxy.superclass.constructor.call(this, config);
|
||||||
},
|
},
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.preferences.Proxy.superclass.initComponent.call(this);
|
Deluge.preferences.Proxy.superclass.initComponent.call(this);
|
||||||
this.peer = this.add(new Deluge.preferences.ProxyField({
|
this.peer = this.add(new Deluge.preferences.ProxyField({
|
||||||
title: _('Peer'),
|
title: _('Peer'),
|
||||||
name: 'peer'
|
name: 'peer'
|
||||||
}));
|
}));
|
||||||
this.peer.on('change', this.onProxyChange, this);
|
this.peer.on('change', this.onProxyChange, this);
|
||||||
|
|
||||||
this.web_seed = this.add(new Deluge.preferences.ProxyField({
|
this.web_seed = this.add(new Deluge.preferences.ProxyField({
|
||||||
title: _('Web Seed'),
|
title: _('Web Seed'),
|
||||||
name: 'web_seed'
|
name: 'web_seed'
|
||||||
}));
|
}));
|
||||||
this.web_seed.on('change', this.onProxyChange, this);
|
this.web_seed.on('change', this.onProxyChange, this);
|
||||||
|
|
||||||
this.tracker = this.add(new Deluge.preferences.ProxyField({
|
this.tracker = this.add(new Deluge.preferences.ProxyField({
|
||||||
title: _('Tracker'),
|
title: _('Tracker'),
|
||||||
name: 'tracker'
|
name: 'tracker'
|
||||||
}));
|
}));
|
||||||
this.tracker.on('change', this.onProxyChange, this);
|
this.tracker.on('change', this.onProxyChange, this);
|
||||||
|
|
||||||
this.dht = this.add(new Deluge.preferences.ProxyField({
|
this.dht = this.add(new Deluge.preferences.ProxyField({
|
||||||
title: _('DHT'),
|
title: _('DHT'),
|
||||||
name: 'dht'
|
name: 'dht'
|
||||||
}));
|
}));
|
||||||
this.dht.on('change', this.onProxyChange, this);
|
this.dht.on('change', this.onProxyChange, this);
|
||||||
|
|
||||||
deluge.preferences.getOptionsManager().bind('proxies', this);
|
deluge.preferences.getOptionsManager().bind('proxies', this);
|
||||||
},
|
},
|
||||||
|
|
||||||
getValue: function() {
|
getValue: function() {
|
||||||
return {
|
return {
|
||||||
'dht': this.dht.getValue(),
|
'dht': this.dht.getValue(),
|
||||||
'peer': this.peer.getValue(),
|
'peer': this.peer.getValue(),
|
||||||
'tracker': this.tracker.getValue(),
|
'tracker': this.tracker.getValue(),
|
||||||
'web_seed': this.web_seed.getValue()
|
'web_seed': this.web_seed.getValue()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
setValue: function(value) {
|
setValue: function(value) {
|
||||||
for (var proxy in value) {
|
for (var proxy in value) {
|
||||||
this[proxy].setValue(value[proxy]);
|
this[proxy].setValue(value[proxy]);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onProxyChange: function(field, newValue, oldValue) {
|
onProxyChange: function(field, newValue, oldValue) {
|
||||||
var newValues = this.getValue();
|
var newValues = this.getValue();
|
||||||
var oldValues = Ext.apply({}, newValues);
|
var oldValues = Ext.apply({}, newValues);
|
||||||
oldValues[field.getName()] = oldValue;
|
oldValues[field.getName()] = oldValue;
|
||||||
|
|
||||||
this.fireEvent('change', this, newValues, oldValues);
|
this.fireEvent('change', this, newValues, oldValues);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -37,166 +37,166 @@ Ext.namespace('Deluge.preferences');
|
|||||||
*/
|
*/
|
||||||
Deluge.preferences.Queue = Ext.extend(Ext.form.FormPanel, {
|
Deluge.preferences.Queue = Ext.extend(Ext.form.FormPanel, {
|
||||||
|
|
||||||
border: false,
|
border: false,
|
||||||
title: _('Queue'),
|
title: _('Queue'),
|
||||||
layout: 'form',
|
layout: 'form',
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.preferences.Queue.superclass.initComponent.call(this);
|
Deluge.preferences.Queue.superclass.initComponent.call(this);
|
||||||
|
|
||||||
var om = deluge.preferences.getOptionsManager();
|
var om = deluge.preferences.getOptionsManager();
|
||||||
|
|
||||||
var fieldset = this.add({
|
var fieldset = this.add({
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
border: false,
|
border: false,
|
||||||
title: _('General'),
|
title: _('General'),
|
||||||
style: 'padding-top: 5px;',
|
style: 'padding-top: 5px;',
|
||||||
autoHeight: true,
|
autoHeight: true,
|
||||||
labelWidth: 1,
|
labelWidth: 1,
|
||||||
defaultType: 'checkbox'
|
defaultType: 'checkbox'
|
||||||
});
|
});
|
||||||
om.bind('queue_new_to_top', fieldset.add({
|
om.bind('queue_new_to_top', fieldset.add({
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
labelSeparator: '',
|
labelSeparator: '',
|
||||||
height: 22,
|
height: 22,
|
||||||
boxLabel: _('Queue new torrents to top'),
|
boxLabel: _('Queue new torrents to top'),
|
||||||
name: 'queue_new_to_top'
|
name: 'queue_new_to_top'
|
||||||
}));
|
}));
|
||||||
|
|
||||||
fieldset = this.add({
|
fieldset = this.add({
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
border: false,
|
border: false,
|
||||||
title: _('Active Torrents'),
|
title: _('Active Torrents'),
|
||||||
autoHeight: true,
|
autoHeight: true,
|
||||||
labelWidth: 150,
|
labelWidth: 150,
|
||||||
defaultType: 'spinnerfield',
|
defaultType: 'spinnerfield',
|
||||||
style: 'margin-bottom: 0px; padding-bottom: 0px;'
|
style: 'margin-bottom: 0px; padding-bottom: 0px;'
|
||||||
});
|
});
|
||||||
om.bind('max_active_limit', fieldset.add({
|
om.bind('max_active_limit', fieldset.add({
|
||||||
fieldLabel: _('Total Active'),
|
fieldLabel: _('Total Active'),
|
||||||
name: 'max_active_limit',
|
name: 'max_active_limit',
|
||||||
value: 8,
|
value: 8,
|
||||||
width: 80,
|
width: 80,
|
||||||
decimalPrecision: 0,
|
decimalPrecision: 0,
|
||||||
minValue: -1,
|
minValue: -1,
|
||||||
maxValue: 99999
|
maxValue: 99999
|
||||||
}));
|
}));
|
||||||
om.bind('max_active_downloading', fieldset.add({
|
om.bind('max_active_downloading', fieldset.add({
|
||||||
fieldLabel: _('Total Active Downloading'),
|
fieldLabel: _('Total Active Downloading'),
|
||||||
name: 'max_active_downloading',
|
name: 'max_active_downloading',
|
||||||
value: 3,
|
value: 3,
|
||||||
width: 80,
|
width: 80,
|
||||||
decimalPrecision: 0,
|
decimalPrecision: 0,
|
||||||
minValue: -1,
|
minValue: -1,
|
||||||
maxValue: 99999
|
maxValue: 99999
|
||||||
}));
|
}));
|
||||||
om.bind('max_active_seeding', fieldset.add({
|
om.bind('max_active_seeding', fieldset.add({
|
||||||
fieldLabel: _('Total Active Seeding'),
|
fieldLabel: _('Total Active Seeding'),
|
||||||
name: 'max_active_seeding',
|
name: 'max_active_seeding',
|
||||||
value: 5,
|
value: 5,
|
||||||
width: 80,
|
width: 80,
|
||||||
decimalPrecision: 0,
|
decimalPrecision: 0,
|
||||||
minValue: -1,
|
minValue: -1,
|
||||||
maxValue: 99999
|
maxValue: 99999
|
||||||
}));
|
}));
|
||||||
om.bind('dont_count_slow_torrents', fieldset.add({
|
om.bind('dont_count_slow_torrents', fieldset.add({
|
||||||
xtype: 'checkbox',
|
xtype: 'checkbox',
|
||||||
name: 'dont_count_slow_torrents',
|
name: 'dont_count_slow_torrents',
|
||||||
height: 40,
|
height: 40,
|
||||||
hideLabel: true,
|
hideLabel: true,
|
||||||
boxLabel: _('Do not count slow torrents')
|
boxLabel: _('Do not count slow torrents')
|
||||||
}));
|
}));
|
||||||
|
|
||||||
fieldset = this.add({
|
fieldset = this.add({
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
border: false,
|
border: false,
|
||||||
title: _('Seeding'),
|
title: _('Seeding'),
|
||||||
autoHeight: true,
|
autoHeight: true,
|
||||||
labelWidth: 150,
|
labelWidth: 150,
|
||||||
defaultType: 'spinnerfield',
|
defaultType: 'spinnerfield',
|
||||||
style: 'margin-bottom: 0px; padding-bottom: 0px; margin-top: 0; padding-top: 0;'
|
style: 'margin-bottom: 0px; padding-bottom: 0px; margin-top: 0; padding-top: 0;'
|
||||||
});
|
});
|
||||||
om.bind('share_ratio_limit', fieldset.add({
|
om.bind('share_ratio_limit', fieldset.add({
|
||||||
fieldLabel: _('Share Ratio Limit'),
|
fieldLabel: _('Share Ratio Limit'),
|
||||||
name: 'share_ratio_limit',
|
name: 'share_ratio_limit',
|
||||||
value: 8,
|
value: 8,
|
||||||
width: 80,
|
width: 80,
|
||||||
incrementValue: 0.1,
|
incrementValue: 0.1,
|
||||||
minValue: -1,
|
minValue: -1,
|
||||||
maxValue: 99999,
|
maxValue: 99999,
|
||||||
alternateIncrementValue: 1,
|
alternateIncrementValue: 1,
|
||||||
decimalPrecision: 2
|
decimalPrecision: 2
|
||||||
}));
|
}));
|
||||||
om.bind('seed_time_ratio_limit', fieldset.add({
|
om.bind('seed_time_ratio_limit', fieldset.add({
|
||||||
fieldLabel: _('Share Time Ratio'),
|
fieldLabel: _('Share Time Ratio'),
|
||||||
name: 'seed_time_ratio_limit',
|
name: 'seed_time_ratio_limit',
|
||||||
value: 3,
|
value: 3,
|
||||||
width: 80,
|
width: 80,
|
||||||
incrementValue: 0.1,
|
incrementValue: 0.1,
|
||||||
minValue: -1,
|
minValue: -1,
|
||||||
maxValue: 99999,
|
maxValue: 99999,
|
||||||
alternateIncrementValue: 1,
|
alternateIncrementValue: 1,
|
||||||
decimalPrecision: 2
|
decimalPrecision: 2
|
||||||
}));
|
}));
|
||||||
om.bind('seed_time_limit', fieldset.add({
|
om.bind('seed_time_limit', fieldset.add({
|
||||||
fieldLabel: _('Seed Time (m)'),
|
fieldLabel: _('Seed Time (m)'),
|
||||||
name: 'seed_time_limit',
|
name: 'seed_time_limit',
|
||||||
value: 5,
|
value: 5,
|
||||||
width: 80,
|
width: 80,
|
||||||
decimalPrecision: 0,
|
decimalPrecision: 0,
|
||||||
minValue: -1,
|
minValue: -1,
|
||||||
maxValue: 99999
|
maxValue: 99999
|
||||||
}));
|
}));
|
||||||
|
|
||||||
fieldset = this.add({
|
fieldset = this.add({
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
border: false,
|
border: false,
|
||||||
autoHeight: true,
|
autoHeight: true,
|
||||||
|
|
||||||
layout: 'table',
|
layout: 'table',
|
||||||
layoutConfig: {columns: 2},
|
layoutConfig: {columns: 2},
|
||||||
labelWidth: 0,
|
labelWidth: 0,
|
||||||
defaultType: 'checkbox',
|
defaultType: 'checkbox',
|
||||||
|
|
||||||
defaults: {
|
defaults: {
|
||||||
fieldLabel: '',
|
fieldLabel: '',
|
||||||
labelSeparator: ''
|
labelSeparator: ''
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.stopAtRatio = fieldset.add({
|
this.stopAtRatio = fieldset.add({
|
||||||
name: 'stop_seed_at_ratio',
|
name: 'stop_seed_at_ratio',
|
||||||
boxLabel: _('Stop seeding when share ratio reaches:')
|
boxLabel: _('Stop seeding when share ratio reaches:')
|
||||||
});
|
});
|
||||||
this.stopAtRatio.on('check', this.onStopRatioCheck, this);
|
this.stopAtRatio.on('check', this.onStopRatioCheck, this);
|
||||||
om.bind('stop_seed_at_ratio', this.stopAtRatio);
|
om.bind('stop_seed_at_ratio', this.stopAtRatio);
|
||||||
|
|
||||||
this.stopRatio = fieldset.add({
|
this.stopRatio = fieldset.add({
|
||||||
xtype: 'spinnerfield',
|
xtype: 'spinnerfield',
|
||||||
name: 'stop_seed_ratio',
|
name: 'stop_seed_ratio',
|
||||||
ctCls: 'x-deluge-indent-checkbox',
|
ctCls: 'x-deluge-indent-checkbox',
|
||||||
disabled: true,
|
disabled: true,
|
||||||
value: '2.0',
|
value: '2.0',
|
||||||
width: 60,
|
width: 60,
|
||||||
incrementValue: 0.1,
|
incrementValue: 0.1,
|
||||||
minValue: -1,
|
minValue: -1,
|
||||||
maxValue: 99999,
|
maxValue: 99999,
|
||||||
alternateIncrementValue: 1,
|
alternateIncrementValue: 1,
|
||||||
decimalPrecision: 2
|
decimalPrecision: 2
|
||||||
});
|
});
|
||||||
om.bind('stop_seed_ratio', this.stopRatio);
|
om.bind('stop_seed_ratio', this.stopRatio);
|
||||||
|
|
||||||
this.removeAtRatio = fieldset.add({
|
this.removeAtRatio = fieldset.add({
|
||||||
name: 'remove_seed_at_ratio',
|
name: 'remove_seed_at_ratio',
|
||||||
ctCls: 'x-deluge-indent-checkbox',
|
ctCls: 'x-deluge-indent-checkbox',
|
||||||
boxLabel: _('Remove torrent when share ratio is reached'),
|
boxLabel: _('Remove torrent when share ratio is reached'),
|
||||||
disabled: true,
|
disabled: true,
|
||||||
colspan: 2
|
colspan: 2
|
||||||
});
|
});
|
||||||
om.bind('remove_seed_at_ratio', this.removeAtRatio);
|
om.bind('remove_seed_at_ratio', this.removeAtRatio);
|
||||||
},
|
},
|
||||||
|
|
||||||
onStopRatioCheck: function(e, checked) {
|
onStopRatioCheck: function(e, checked) {
|
||||||
this.stopRatio.setDisabled(!checked);
|
this.stopRatio.setDisabled(!checked);
|
||||||
this.removeAtRatio.setDisabled(!checked);
|
this.removeAtRatio.setDisabled(!checked);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,38 +1,38 @@
|
|||||||
Ext.ux.JSLoader = function(options) {
|
Ext.ux.JSLoader = function(options) {
|
||||||
Ext.ux.JSLoader.scripts[++Ext.ux.JSLoader.index] = {
|
Ext.ux.JSLoader.scripts[++Ext.ux.JSLoader.index] = {
|
||||||
url: options.url,
|
url: options.url,
|
||||||
success: true,
|
success: true,
|
||||||
jsLoadObj: null,
|
jsLoadObj: null,
|
||||||
options: options,
|
options: options,
|
||||||
onLoad: options.onLoad || Ext.emptyFn,
|
onLoad: options.onLoad || Ext.emptyFn,
|
||||||
onError: options.onError || Ext.ux.JSLoader.stdError,
|
onError: options.onError || Ext.ux.JSLoader.stdError,
|
||||||
scope: options.scope || this
|
scope: options.scope || this
|
||||||
};
|
};
|
||||||
|
|
||||||
Ext.Ajax.request({
|
Ext.Ajax.request({
|
||||||
url: options.url,
|
url: options.url,
|
||||||
scriptIndex: Ext.ux.JSLoader.index,
|
scriptIndex: Ext.ux.JSLoader.index,
|
||||||
success: function(response, options) {
|
success: function(response, options) {
|
||||||
var script = Ext.ux.JSLoader.scripts[options.scriptIndex];
|
var script = Ext.ux.JSLoader.scripts[options.scriptIndex];
|
||||||
try {
|
try {
|
||||||
eval(response.responseText);
|
eval(response.responseText);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
script.success = false;
|
script.success = false;
|
||||||
script.onError(script.options, e);
|
script.onError(script.options, e);
|
||||||
}
|
}
|
||||||
if (script.success) {
|
if (script.success) {
|
||||||
script.onLoad.call(script.scope, script.options);
|
script.onLoad.call(script.scope, script.options);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
failure: function(response, options) {
|
failure: function(response, options) {
|
||||||
var script = Ext.ux.JSLoader.scripts[options.scriptIndex];
|
var script = Ext.ux.JSLoader.scripts[options.scriptIndex];
|
||||||
script.success = false;
|
script.success = false;
|
||||||
script.onError(script.options, response.status);
|
script.onError(script.options, response.status);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Ext.ux.JSLoader.index = 0;
|
Ext.ux.JSLoader.index = 0;
|
||||||
Ext.ux.JSLoader.scripts = [];
|
Ext.ux.JSLoader.scripts = [];
|
||||||
Ext.ux.JSLoader.stdError = function(options, e) {
|
Ext.ux.JSLoader.stdError = function(options, e) {
|
||||||
window.alert('Error loading script:\n\n' + options.url + '\n\nstatus: ' + e);
|
window.alert('Error loading script:\n\n' + options.url + '\n\nstatus: ' + e);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,428 +10,428 @@
|
|||||||
* Creates a Spinner control utilized by Ext.ux.form.SpinnerField
|
* Creates a Spinner control utilized by Ext.ux.form.SpinnerField
|
||||||
*/
|
*/
|
||||||
Ext.ux.Spinner = Ext.extend(Ext.util.Observable, {
|
Ext.ux.Spinner = Ext.extend(Ext.util.Observable, {
|
||||||
incrementValue: 1,
|
incrementValue: 1,
|
||||||
alternateIncrementValue: 5,
|
alternateIncrementValue: 5,
|
||||||
triggerClass: 'x-form-spinner-trigger',
|
triggerClass: 'x-form-spinner-trigger',
|
||||||
splitterClass: 'x-form-spinner-splitter',
|
splitterClass: 'x-form-spinner-splitter',
|
||||||
alternateKey: Ext.EventObject.shiftKey,
|
alternateKey: Ext.EventObject.shiftKey,
|
||||||
defaultValue: 0,
|
defaultValue: 0,
|
||||||
accelerate: false,
|
accelerate: false,
|
||||||
|
|
||||||
constructor: function(config){
|
constructor: function(config){
|
||||||
Ext.ux.Spinner.superclass.constructor.call(this, config);
|
Ext.ux.Spinner.superclass.constructor.call(this, config);
|
||||||
Ext.apply(this, config);
|
Ext.apply(this, config);
|
||||||
this.mimicing = false;
|
this.mimicing = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
init: function(field){
|
init: function(field){
|
||||||
this.field = field;
|
this.field = field;
|
||||||
|
|
||||||
field.afterMethod('onRender', this.doRender, this);
|
field.afterMethod('onRender', this.doRender, this);
|
||||||
field.afterMethod('onEnable', this.doEnable, this);
|
field.afterMethod('onEnable', this.doEnable, this);
|
||||||
field.afterMethod('onDisable', this.doDisable, this);
|
field.afterMethod('onDisable', this.doDisable, this);
|
||||||
field.afterMethod('afterRender', this.doAfterRender, this);
|
field.afterMethod('afterRender', this.doAfterRender, this);
|
||||||
field.afterMethod('onResize', this.doResize, this);
|
field.afterMethod('onResize', this.doResize, this);
|
||||||
field.afterMethod('onFocus', this.doFocus, this);
|
field.afterMethod('onFocus', this.doFocus, this);
|
||||||
field.beforeMethod('onDestroy', this.doDestroy, this);
|
field.beforeMethod('onDestroy', this.doDestroy, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
doRender: function(ct, position){
|
doRender: function(ct, position){
|
||||||
var el = this.el = this.field.getEl();
|
var el = this.el = this.field.getEl();
|
||||||
var f = this.field;
|
var f = this.field;
|
||||||
|
|
||||||
if (!f.wrap) {
|
if (!f.wrap) {
|
||||||
f.wrap = this.wrap = el.wrap({
|
f.wrap = this.wrap = el.wrap({
|
||||||
cls: "x-form-field-wrap"
|
cls: "x-form-field-wrap"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.wrap = f.wrap.addClass('x-form-field-wrap');
|
this.wrap = f.wrap.addClass('x-form-field-wrap');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.trigger = this.wrap.createChild({
|
this.trigger = this.wrap.createChild({
|
||||||
tag: "img",
|
tag: "img",
|
||||||
src: Ext.BLANK_IMAGE_URL,
|
src: Ext.BLANK_IMAGE_URL,
|
||||||
cls: "x-form-trigger " + this.triggerClass
|
cls: "x-form-trigger " + this.triggerClass
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!f.width) {
|
if (!f.width) {
|
||||||
this.wrap.setWidth(el.getWidth() + this.trigger.getWidth());
|
this.wrap.setWidth(el.getWidth() + this.trigger.getWidth());
|
||||||
}
|
}
|
||||||
|
|
||||||
this.splitter = this.wrap.createChild({
|
this.splitter = this.wrap.createChild({
|
||||||
tag: 'div',
|
tag: 'div',
|
||||||
cls: this.splitterClass,
|
cls: this.splitterClass,
|
||||||
style: 'width:13px; height:2px;'
|
style: 'width:13px; height:2px;'
|
||||||
});
|
});
|
||||||
this.splitter.setRight((Ext.isIE) ? 1 : 2).setTop(10).show();
|
this.splitter.setRight((Ext.isIE) ? 1 : 2).setTop(10).show();
|
||||||
|
|
||||||
this.proxy = this.trigger.createProxy('', this.splitter, true);
|
this.proxy = this.trigger.createProxy('', this.splitter, true);
|
||||||
this.proxy.addClass("x-form-spinner-proxy");
|
this.proxy.addClass("x-form-spinner-proxy");
|
||||||
this.proxy.setStyle('left', '0px');
|
this.proxy.setStyle('left', '0px');
|
||||||
this.proxy.setSize(14, 1);
|
this.proxy.setSize(14, 1);
|
||||||
this.proxy.hide();
|
this.proxy.hide();
|
||||||
this.dd = new Ext.dd.DDProxy(this.splitter.dom.id, "SpinnerDrag", {
|
this.dd = new Ext.dd.DDProxy(this.splitter.dom.id, "SpinnerDrag", {
|
||||||
dragElId: this.proxy.id
|
dragElId: this.proxy.id
|
||||||
});
|
});
|
||||||
|
|
||||||
this.initTrigger();
|
this.initTrigger();
|
||||||
this.initSpinner();
|
this.initSpinner();
|
||||||
},
|
},
|
||||||
|
|
||||||
doAfterRender: function(){
|
doAfterRender: function(){
|
||||||
var y;
|
var y;
|
||||||
if (Ext.isIE && this.el.getY() != (y = this.trigger.getY())) {
|
if (Ext.isIE && this.el.getY() != (y = this.trigger.getY())) {
|
||||||
this.el.position();
|
this.el.position();
|
||||||
this.el.setY(y);
|
this.el.setY(y);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
doEnable: function(){
|
doEnable: function(){
|
||||||
if (this.wrap) {
|
if (this.wrap) {
|
||||||
this.wrap.removeClass(this.field.disabledClass);
|
this.wrap.removeClass(this.field.disabledClass);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
doDisable: function(){
|
doDisable: function(){
|
||||||
if (this.wrap) {
|
if (this.wrap) {
|
||||||
this.wrap.addClass(this.field.disabledClass);
|
this.wrap.addClass(this.field.disabledClass);
|
||||||
this.el.removeClass(this.field.disabledClass);
|
this.el.removeClass(this.field.disabledClass);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
doResize: function(w, h){
|
doResize: function(w, h){
|
||||||
if (typeof w == 'number') {
|
if (typeof w == 'number') {
|
||||||
this.el.setWidth(w - this.trigger.getWidth());
|
this.el.setWidth(w - this.trigger.getWidth());
|
||||||
}
|
}
|
||||||
this.wrap.setWidth(this.el.getWidth() + this.trigger.getWidth());
|
this.wrap.setWidth(this.el.getWidth() + this.trigger.getWidth());
|
||||||
},
|
},
|
||||||
|
|
||||||
doFocus: function(){
|
doFocus: function(){
|
||||||
if (!this.mimicing) {
|
if (!this.mimicing) {
|
||||||
this.wrap.addClass('x-trigger-wrap-focus');
|
this.wrap.addClass('x-trigger-wrap-focus');
|
||||||
this.mimicing = true;
|
this.mimicing = true;
|
||||||
Ext.get(Ext.isIE ? document.body : document).on("mousedown", this.mimicBlur, this, {
|
Ext.get(Ext.isIE ? document.body : document).on("mousedown", this.mimicBlur, this, {
|
||||||
delay: 10
|
delay: 10
|
||||||
});
|
});
|
||||||
this.el.on('keydown', this.checkTab, this);
|
this.el.on('keydown', this.checkTab, this);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
checkTab: function(e){
|
checkTab: function(e){
|
||||||
if (e.getKey() == e.TAB) {
|
if (e.getKey() == e.TAB) {
|
||||||
this.triggerBlur();
|
this.triggerBlur();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
mimicBlur: function(e){
|
mimicBlur: function(e){
|
||||||
if (!this.wrap.contains(e.target) && this.field.validateBlur(e)) {
|
if (!this.wrap.contains(e.target) && this.field.validateBlur(e)) {
|
||||||
this.triggerBlur();
|
this.triggerBlur();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
triggerBlur: function(){
|
triggerBlur: function(){
|
||||||
this.mimicing = false;
|
this.mimicing = false;
|
||||||
Ext.get(Ext.isIE ? document.body : document).un("mousedown", this.mimicBlur, this);
|
Ext.get(Ext.isIE ? document.body : document).un("mousedown", this.mimicBlur, this);
|
||||||
this.el.un("keydown", this.checkTab, this);
|
this.el.un("keydown", this.checkTab, this);
|
||||||
this.field.beforeBlur();
|
this.field.beforeBlur();
|
||||||
this.wrap.removeClass('x-trigger-wrap-focus');
|
this.wrap.removeClass('x-trigger-wrap-focus');
|
||||||
this.field.onBlur.call(this.field);
|
this.field.onBlur.call(this.field);
|
||||||
},
|
},
|
||||||
|
|
||||||
initTrigger: function(){
|
initTrigger: function(){
|
||||||
this.trigger.addClassOnOver('x-form-trigger-over');
|
this.trigger.addClassOnOver('x-form-trigger-over');
|
||||||
this.trigger.addClassOnClick('x-form-trigger-click');
|
this.trigger.addClassOnClick('x-form-trigger-click');
|
||||||
},
|
},
|
||||||
|
|
||||||
initSpinner: function(){
|
initSpinner: function(){
|
||||||
this.field.addEvents({
|
this.field.addEvents({
|
||||||
'spin': true,
|
'spin': true,
|
||||||
'spinup': true,
|
'spinup': true,
|
||||||
'spindown': true
|
'spindown': true
|
||||||
});
|
});
|
||||||
|
|
||||||
this.keyNav = new Ext.KeyNav(this.el, {
|
this.keyNav = new Ext.KeyNav(this.el, {
|
||||||
"up": function(e){
|
"up": function(e){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
this.onSpinUp();
|
this.onSpinUp();
|
||||||
},
|
},
|
||||||
|
|
||||||
"down": function(e){
|
"down": function(e){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
this.onSpinDown();
|
this.onSpinDown();
|
||||||
},
|
},
|
||||||
|
|
||||||
"pageUp": function(e){
|
"pageUp": function(e){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
this.onSpinUpAlternate();
|
this.onSpinUpAlternate();
|
||||||
},
|
},
|
||||||
|
|
||||||
"pageDown": function(e){
|
"pageDown": function(e){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
this.onSpinDownAlternate();
|
this.onSpinDownAlternate();
|
||||||
},
|
},
|
||||||
|
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
|
|
||||||
this.repeater = new Ext.util.ClickRepeater(this.trigger, {
|
this.repeater = new Ext.util.ClickRepeater(this.trigger, {
|
||||||
accelerate: this.accelerate
|
accelerate: this.accelerate
|
||||||
});
|
});
|
||||||
this.field.mon(this.repeater, "click", this.onTriggerClick, this, {
|
this.field.mon(this.repeater, "click", this.onTriggerClick, this, {
|
||||||
preventDefault: true
|
preventDefault: true
|
||||||
});
|
});
|
||||||
|
|
||||||
this.field.mon(this.trigger, {
|
this.field.mon(this.trigger, {
|
||||||
mouseover: this.onMouseOver,
|
mouseover: this.onMouseOver,
|
||||||
mouseout: this.onMouseOut,
|
mouseout: this.onMouseOut,
|
||||||
mousemove: this.onMouseMove,
|
mousemove: this.onMouseMove,
|
||||||
mousedown: this.onMouseDown,
|
mousedown: this.onMouseDown,
|
||||||
mouseup: this.onMouseUp,
|
mouseup: this.onMouseUp,
|
||||||
scope: this,
|
scope: this,
|
||||||
preventDefault: true
|
preventDefault: true
|
||||||
});
|
});
|
||||||
|
|
||||||
this.field.mon(this.wrap, "mousewheel", this.handleMouseWheel, this);
|
this.field.mon(this.wrap, "mousewheel", this.handleMouseWheel, this);
|
||||||
|
|
||||||
this.dd.setXConstraint(0, 0, 10)
|
this.dd.setXConstraint(0, 0, 10)
|
||||||
this.dd.setYConstraint(1500, 1500, 10);
|
this.dd.setYConstraint(1500, 1500, 10);
|
||||||
this.dd.endDrag = this.endDrag.createDelegate(this);
|
this.dd.endDrag = this.endDrag.createDelegate(this);
|
||||||
this.dd.startDrag = this.startDrag.createDelegate(this);
|
this.dd.startDrag = this.startDrag.createDelegate(this);
|
||||||
this.dd.onDrag = this.onDrag.createDelegate(this);
|
this.dd.onDrag = this.onDrag.createDelegate(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
onMouseOver: function(){
|
onMouseOver: function(){
|
||||||
if (this.disabled) {
|
if (this.disabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var middle = this.getMiddle();
|
var middle = this.getMiddle();
|
||||||
this.tmpHoverClass = (Ext.EventObject.getPageY() < middle) ? 'x-form-spinner-overup' : 'x-form-spinner-overdown';
|
this.tmpHoverClass = (Ext.EventObject.getPageY() < middle) ? 'x-form-spinner-overup' : 'x-form-spinner-overdown';
|
||||||
this.trigger.addClass(this.tmpHoverClass);
|
this.trigger.addClass(this.tmpHoverClass);
|
||||||
},
|
},
|
||||||
|
|
||||||
//private
|
//private
|
||||||
onMouseOut: function(){
|
onMouseOut: function(){
|
||||||
this.trigger.removeClass(this.tmpHoverClass);
|
this.trigger.removeClass(this.tmpHoverClass);
|
||||||
},
|
},
|
||||||
|
|
||||||
//private
|
//private
|
||||||
onMouseMove: function(){
|
onMouseMove: function(){
|
||||||
if (this.disabled) {
|
if (this.disabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var middle = this.getMiddle();
|
var middle = this.getMiddle();
|
||||||
if (((Ext.EventObject.getPageY() > middle) && this.tmpHoverClass == "x-form-spinner-overup") ||
|
if (((Ext.EventObject.getPageY() > middle) && this.tmpHoverClass == "x-form-spinner-overup") ||
|
||||||
((Ext.EventObject.getPageY() < middle) && this.tmpHoverClass == "x-form-spinner-overdown")) {
|
((Ext.EventObject.getPageY() < middle) && this.tmpHoverClass == "x-form-spinner-overdown")) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
//private
|
//private
|
||||||
onMouseDown: function(){
|
onMouseDown: function(){
|
||||||
if (this.disabled) {
|
if (this.disabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var middle = this.getMiddle();
|
var middle = this.getMiddle();
|
||||||
this.tmpClickClass = (Ext.EventObject.getPageY() < middle) ? 'x-form-spinner-clickup' : 'x-form-spinner-clickdown';
|
this.tmpClickClass = (Ext.EventObject.getPageY() < middle) ? 'x-form-spinner-clickup' : 'x-form-spinner-clickdown';
|
||||||
this.trigger.addClass(this.tmpClickClass);
|
this.trigger.addClass(this.tmpClickClass);
|
||||||
},
|
},
|
||||||
|
|
||||||
//private
|
//private
|
||||||
onMouseUp: function(){
|
onMouseUp: function(){
|
||||||
this.trigger.removeClass(this.tmpClickClass);
|
this.trigger.removeClass(this.tmpClickClass);
|
||||||
},
|
},
|
||||||
|
|
||||||
//private
|
//private
|
||||||
onTriggerClick: function(){
|
onTriggerClick: function(){
|
||||||
if (this.disabled || this.el.dom.readOnly) {
|
if (this.disabled || this.el.dom.readOnly) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var middle = this.getMiddle();
|
var middle = this.getMiddle();
|
||||||
var ud = (Ext.EventObject.getPageY() < middle) ? 'Up' : 'Down';
|
var ud = (Ext.EventObject.getPageY() < middle) ? 'Up' : 'Down';
|
||||||
this['onSpin' + ud]();
|
this['onSpin' + ud]();
|
||||||
},
|
},
|
||||||
|
|
||||||
//private
|
//private
|
||||||
getMiddle: function(){
|
getMiddle: function(){
|
||||||
var t = this.trigger.getTop();
|
var t = this.trigger.getTop();
|
||||||
var h = this.trigger.getHeight();
|
var h = this.trigger.getHeight();
|
||||||
var middle = t + (h / 2);
|
var middle = t + (h / 2);
|
||||||
return middle;
|
return middle;
|
||||||
},
|
},
|
||||||
|
|
||||||
//private
|
//private
|
||||||
//checks if control is allowed to spin
|
//checks if control is allowed to spin
|
||||||
isSpinnable: function(){
|
isSpinnable: function(){
|
||||||
if (this.disabled || this.el.dom.readOnly) {
|
if (this.disabled || this.el.dom.readOnly) {
|
||||||
Ext.EventObject.preventDefault(); //prevent scrolling when disabled/readonly
|
Ext.EventObject.preventDefault(); //prevent scrolling when disabled/readonly
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
handleMouseWheel: function(e){
|
handleMouseWheel: function(e){
|
||||||
//disable scrolling when not focused
|
//disable scrolling when not focused
|
||||||
if (this.wrap.hasClass('x-trigger-wrap-focus') == false) {
|
if (this.wrap.hasClass('x-trigger-wrap-focus') == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var delta = e.getWheelDelta();
|
var delta = e.getWheelDelta();
|
||||||
if (delta > 0) {
|
if (delta > 0) {
|
||||||
this.onSpinUp();
|
this.onSpinUp();
|
||||||
e.stopEvent();
|
e.stopEvent();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (delta < 0) {
|
if (delta < 0) {
|
||||||
this.onSpinDown();
|
this.onSpinDown();
|
||||||
e.stopEvent();
|
e.stopEvent();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
//private
|
//private
|
||||||
startDrag: function(){
|
startDrag: function(){
|
||||||
this.proxy.show();
|
this.proxy.show();
|
||||||
this._previousY = Ext.fly(this.dd.getDragEl()).getTop();
|
this._previousY = Ext.fly(this.dd.getDragEl()).getTop();
|
||||||
},
|
},
|
||||||
|
|
||||||
//private
|
//private
|
||||||
endDrag: function(){
|
endDrag: function(){
|
||||||
this.proxy.hide();
|
this.proxy.hide();
|
||||||
},
|
},
|
||||||
|
|
||||||
//private
|
//private
|
||||||
onDrag: function(){
|
onDrag: function(){
|
||||||
if (this.disabled) {
|
if (this.disabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var y = Ext.fly(this.dd.getDragEl()).getTop();
|
var y = Ext.fly(this.dd.getDragEl()).getTop();
|
||||||
var ud = '';
|
var ud = '';
|
||||||
|
|
||||||
if (this._previousY > y) {
|
if (this._previousY > y) {
|
||||||
ud = 'Up';
|
ud = 'Up';
|
||||||
} //up
|
} //up
|
||||||
if (this._previousY < y) {
|
if (this._previousY < y) {
|
||||||
ud = 'Down';
|
ud = 'Down';
|
||||||
} //down
|
} //down
|
||||||
if (ud != '') {
|
if (ud != '') {
|
||||||
this['onSpin' + ud]();
|
this['onSpin' + ud]();
|
||||||
}
|
}
|
||||||
|
|
||||||
this._previousY = y;
|
this._previousY = y;
|
||||||
},
|
},
|
||||||
|
|
||||||
//private
|
//private
|
||||||
onSpinUp: function(){
|
onSpinUp: function(){
|
||||||
if (this.isSpinnable() == false) {
|
if (this.isSpinnable() == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Ext.EventObject.shiftKey == true) {
|
if (Ext.EventObject.shiftKey == true) {
|
||||||
this.onSpinUpAlternate();
|
this.onSpinUpAlternate();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.spin(false, false);
|
this.spin(false, false);
|
||||||
}
|
}
|
||||||
this.field.fireEvent("spin", this);
|
this.field.fireEvent("spin", this);
|
||||||
this.field.fireEvent("spinup", this);
|
this.field.fireEvent("spinup", this);
|
||||||
},
|
},
|
||||||
|
|
||||||
//private
|
//private
|
||||||
onSpinDown: function(){
|
onSpinDown: function(){
|
||||||
if (this.isSpinnable() == false) {
|
if (this.isSpinnable() == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Ext.EventObject.shiftKey == true) {
|
if (Ext.EventObject.shiftKey == true) {
|
||||||
this.onSpinDownAlternate();
|
this.onSpinDownAlternate();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.spin(true, false);
|
this.spin(true, false);
|
||||||
}
|
}
|
||||||
this.field.fireEvent("spin", this);
|
this.field.fireEvent("spin", this);
|
||||||
this.field.fireEvent("spindown", this);
|
this.field.fireEvent("spindown", this);
|
||||||
},
|
},
|
||||||
|
|
||||||
//private
|
//private
|
||||||
onSpinUpAlternate: function(){
|
onSpinUpAlternate: function(){
|
||||||
if (this.isSpinnable() == false) {
|
if (this.isSpinnable() == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.spin(false, true);
|
this.spin(false, true);
|
||||||
this.field.fireEvent("spin", this);
|
this.field.fireEvent("spin", this);
|
||||||
this.field.fireEvent("spinup", this);
|
this.field.fireEvent("spinup", this);
|
||||||
},
|
},
|
||||||
|
|
||||||
//private
|
//private
|
||||||
onSpinDownAlternate: function(){
|
onSpinDownAlternate: function(){
|
||||||
if (this.isSpinnable() == false) {
|
if (this.isSpinnable() == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.spin(true, true);
|
this.spin(true, true);
|
||||||
this.field.fireEvent("spin", this);
|
this.field.fireEvent("spin", this);
|
||||||
this.field.fireEvent("spindown", this);
|
this.field.fireEvent("spindown", this);
|
||||||
},
|
},
|
||||||
|
|
||||||
spin: function(down, alternate){
|
spin: function(down, alternate){
|
||||||
var v = parseFloat(this.field.getValue());
|
var v = parseFloat(this.field.getValue());
|
||||||
var incr = (alternate == true) ? this.alternateIncrementValue : this.incrementValue;
|
var incr = (alternate == true) ? this.alternateIncrementValue : this.incrementValue;
|
||||||
(down == true) ? v -= incr : v += incr;
|
(down == true) ? v -= incr : v += incr;
|
||||||
|
|
||||||
v = (isNaN(v)) ? this.defaultValue : v;
|
v = (isNaN(v)) ? this.defaultValue : v;
|
||||||
v = this.fixBoundries(v);
|
v = this.fixBoundries(v);
|
||||||
this.field.setRawValue(v);
|
this.field.setRawValue(v);
|
||||||
},
|
},
|
||||||
|
|
||||||
fixBoundries: function(value){
|
fixBoundries: function(value){
|
||||||
var v = value;
|
var v = value;
|
||||||
|
|
||||||
if (this.field.minValue != undefined && v < this.field.minValue) {
|
if (this.field.minValue != undefined && v < this.field.minValue) {
|
||||||
v = this.field.minValue;
|
v = this.field.minValue;
|
||||||
}
|
}
|
||||||
if (this.field.maxValue != undefined && v > this.field.maxValue) {
|
if (this.field.maxValue != undefined && v > this.field.maxValue) {
|
||||||
v = this.field.maxValue;
|
v = this.field.maxValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.fixPrecision(v);
|
return this.fixPrecision(v);
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
fixPrecision: function(value){
|
fixPrecision: function(value){
|
||||||
var nan = isNaN(value);
|
var nan = isNaN(value);
|
||||||
if (!this.field.allowDecimals || this.field.decimalPrecision == -1 || nan || !value) {
|
if (!this.field.allowDecimals || this.field.decimalPrecision == -1 || nan || !value) {
|
||||||
return nan ? '' : value;
|
return nan ? '' : value;
|
||||||
}
|
}
|
||||||
return parseFloat(parseFloat(value).toFixed(this.field.decimalPrecision));
|
return parseFloat(parseFloat(value).toFixed(this.field.decimalPrecision));
|
||||||
},
|
},
|
||||||
|
|
||||||
doDestroy: function(){
|
doDestroy: function(){
|
||||||
if (this.trigger) {
|
if (this.trigger) {
|
||||||
this.trigger.remove();
|
this.trigger.remove();
|
||||||
}
|
}
|
||||||
if (this.wrap) {
|
if (this.wrap) {
|
||||||
this.wrap.remove();
|
this.wrap.remove();
|
||||||
delete this.field.wrap;
|
delete this.field.wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.splitter) {
|
if (this.splitter) {
|
||||||
this.splitter.remove();
|
this.splitter.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.dd) {
|
if (this.dd) {
|
||||||
this.dd.unreg();
|
this.dd.unreg();
|
||||||
this.dd = null;
|
this.dd = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.proxy) {
|
if (this.proxy) {
|
||||||
this.proxy.remove();
|
this.proxy.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.repeater) {
|
if (this.repeater) {
|
||||||
this.repeater.purgeListeners();
|
this.repeater.purgeListeners();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//backwards compat
|
//backwards compat
|
||||||
|
|||||||
@ -339,9 +339,9 @@ statusBar.setStatus({
|
|||||||
scope: this,
|
scope: this,
|
||||||
callback: function(){
|
callback: function(){
|
||||||
this.setStatus({
|
this.setStatus({
|
||||||
text: text,
|
text: text,
|
||||||
iconCls: iconCls
|
iconCls: iconCls
|
||||||
});
|
});
|
||||||
|
|
||||||
this.statusEl.el.show();
|
this.statusEl.el.show();
|
||||||
}
|
}
|
||||||
@ -349,10 +349,10 @@ statusBar.setStatus({
|
|||||||
}else{
|
}else{
|
||||||
// hide/show the el to avoid jumpy text or icon
|
// hide/show the el to avoid jumpy text or icon
|
||||||
this.statusEl.hide();
|
this.statusEl.hide();
|
||||||
this.setStatus({
|
this.setStatus({
|
||||||
text: text,
|
text: text,
|
||||||
iconCls: iconCls
|
iconCls: iconCls
|
||||||
});
|
});
|
||||||
this.statusEl.show();
|
this.statusEl.show();
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
@ -391,14 +391,14 @@ statusBar.setStatus({
|
|||||||
cls = cls || '';
|
cls = cls || '';
|
||||||
|
|
||||||
if(this.rendered){
|
if(this.rendered){
|
||||||
if(this.currIconCls){
|
if(this.currIconCls){
|
||||||
this.statusEl.removeClass(this.currIconCls);
|
this.statusEl.removeClass(this.currIconCls);
|
||||||
this.currIconCls = null;
|
this.currIconCls = null;
|
||||||
}
|
}
|
||||||
if(cls.length > 0){
|
if(cls.length > 0){
|
||||||
this.statusEl.addClass(cls);
|
this.statusEl.addClass(cls);
|
||||||
this.currIconCls = cls;
|
this.currIconCls = cls;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
this.currIconCls = cls;
|
this.currIconCls = cls;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,38 +34,38 @@
|
|||||||
Ext.override(Ext.form.RadioGroup, {
|
Ext.override(Ext.form.RadioGroup, {
|
||||||
|
|
||||||
afterRender: function() {
|
afterRender: function() {
|
||||||
this.items.each(function(i) {
|
this.items.each(function(i) {
|
||||||
this.relayEvents(i, ['check']);
|
this.relayEvents(i, ['check']);
|
||||||
}, this);
|
}, this);
|
||||||
if (this.lazyValue) {
|
if (this.lazyValue) {
|
||||||
this.setValue(this.value);
|
this.setValue(this.value);
|
||||||
delete this.value;
|
delete this.value;
|
||||||
delete this.lazyValue;
|
delete this.lazyValue;
|
||||||
}
|
}
|
||||||
Ext.form.RadioGroup.superclass.afterRender.call(this)
|
Ext.form.RadioGroup.superclass.afterRender.call(this)
|
||||||
},
|
},
|
||||||
|
|
||||||
getName: function() {
|
getName: function() {
|
||||||
return this.items.first().getName();
|
return this.items.first().getName();
|
||||||
},
|
},
|
||||||
|
|
||||||
getValue: function() {
|
getValue: function() {
|
||||||
return this.items.first().getGroupValue();
|
return this.items.first().getGroupValue();
|
||||||
},
|
},
|
||||||
|
|
||||||
setValue: function(v) {
|
setValue: function(v) {
|
||||||
if (!this.items.each) {
|
if (!this.items.each) {
|
||||||
this.value = v;
|
this.value = v;
|
||||||
this.lazyValue = true;
|
this.lazyValue = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.items.each(function(item) {
|
this.items.each(function(item) {
|
||||||
if (item.rendered) {
|
if (item.rendered) {
|
||||||
var checked = (item.el.getValue() == String(v));
|
var checked = (item.el.getValue() == String(v));
|
||||||
item.el.dom.checked = checked;
|
item.el.dom.checked = checked;
|
||||||
item.el.dom.defaultChecked = checked;
|
item.el.dom.defaultChecked = checked;
|
||||||
item.wrap[checked ? 'addClass' : 'removeClass'](item.checkedCls);
|
item.wrap[checked ? 'addClass' : 'removeClass'](item.checkedCls);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -13,46 +13,46 @@ Ext.ns('Ext.ux.form');
|
|||||||
* @xtype spinnerfield
|
* @xtype spinnerfield
|
||||||
*/
|
*/
|
||||||
Ext.ux.form.SpinnerField = Ext.extend(Ext.form.NumberField, {
|
Ext.ux.form.SpinnerField = Ext.extend(Ext.form.NumberField, {
|
||||||
actionMode: 'wrap',
|
actionMode: 'wrap',
|
||||||
deferHeight: true,
|
deferHeight: true,
|
||||||
autoSize: Ext.emptyFn,
|
autoSize: Ext.emptyFn,
|
||||||
onBlur: Ext.emptyFn,
|
onBlur: Ext.emptyFn,
|
||||||
adjustSize: Ext.BoxComponent.prototype.adjustSize,
|
adjustSize: Ext.BoxComponent.prototype.adjustSize,
|
||||||
|
|
||||||
constructor: function(config) {
|
constructor: function(config) {
|
||||||
var spinnerConfig = Ext.copyTo({}, config, 'incrementValue,alternateIncrementValue,accelerate,defaultValue,triggerClass,splitterClass');
|
var spinnerConfig = Ext.copyTo({}, config, 'incrementValue,alternateIncrementValue,accelerate,defaultValue,triggerClass,splitterClass');
|
||||||
|
|
||||||
var spl = this.spinner = new Ext.ux.Spinner(spinnerConfig);
|
var spl = this.spinner = new Ext.ux.Spinner(spinnerConfig);
|
||||||
|
|
||||||
var plugins = config.plugins
|
var plugins = config.plugins
|
||||||
? (Ext.isArray(config.plugins)
|
? (Ext.isArray(config.plugins)
|
||||||
? config.plugins.push(spl)
|
? config.plugins.push(spl)
|
||||||
: [config.plugins, spl])
|
: [config.plugins, spl])
|
||||||
: spl;
|
: spl;
|
||||||
|
|
||||||
Ext.ux.form.SpinnerField.superclass.constructor.call(this, Ext.apply(config, {plugins: plugins}));
|
Ext.ux.form.SpinnerField.superclass.constructor.call(this, Ext.apply(config, {plugins: plugins}));
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
getResizeEl: function(){
|
getResizeEl: function(){
|
||||||
return this.wrap;
|
return this.wrap;
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
getPositionEl: function(){
|
getPositionEl: function(){
|
||||||
return this.wrap;
|
return this.wrap;
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
alignErrorIcon: function(){
|
alignErrorIcon: function(){
|
||||||
if (this.wrap) {
|
if (this.wrap) {
|
||||||
this.errorIcon.alignTo(this.wrap, 'tl-tr', [2, 0]);
|
this.errorIcon.alignTo(this.wrap, 'tl-tr', [2, 0]);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
validateBlur: function(){
|
validateBlur: function(){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Ext.reg('spinnerfield', Ext.ux.form.SpinnerField);
|
Ext.reg('spinnerfield', Ext.ux.form.SpinnerField);
|
||||||
|
|||||||
@ -31,5 +31,5 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
Ext.override(Ext.ux.form.SpinnerField, {
|
Ext.override(Ext.ux.form.SpinnerField, {
|
||||||
onBlur: Ext.form.Field.prototype.onBlur
|
onBlur: Ext.form.Field.prototype.onBlur
|
||||||
});
|
});
|
||||||
|
|||||||
@ -99,7 +99,7 @@ Ext.ux.form.SpinnerGroup = Ext.extend(Ext.form.CheckboxGroup, {
|
|||||||
|
|
||||||
// Generate the column configs with the correct width setting
|
// Generate the column configs with the correct width setting
|
||||||
for(var i=0; i<numCols; i++){
|
for(var i=0; i<numCols; i++){
|
||||||
var cc = Ext.apply({items:[]}, colCfg);
|
var cc = Ext.apply({items:[]}, colCfg);
|
||||||
cc[this.columns[i] <= 1 ? 'columnWidth' : 'width'] = this.columns[i];
|
cc[this.columns[i] <= 1 ? 'columnWidth' : 'width'] = this.columns[i];
|
||||||
if(this.defaults){
|
if(this.defaults){
|
||||||
cc.defaults = Ext.apply(cc.defaults || {}, this.defaults)
|
cc.defaults = Ext.apply(cc.defaults || {}, this.defaults)
|
||||||
@ -156,17 +156,17 @@ Ext.ux.form.SpinnerGroup = Ext.extend(Ext.form.CheckboxGroup, {
|
|||||||
field.on('spin', this.onFieldChange, this);
|
field.on('spin', this.onFieldChange, this);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
if (this.lazyValueSet) {
|
if (this.lazyValueSet) {
|
||||||
this.setValue(this.value);
|
this.setValue(this.value);
|
||||||
delete this.value;
|
delete this.value;
|
||||||
delete this.lazyValueSet;
|
delete this.lazyValueSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.lazyRawValueSet) {
|
if (this.lazyRawValueSet) {
|
||||||
this.setRawValue(this.rawValue);
|
this.setRawValue(this.rawValue);
|
||||||
delete this.rawValue;
|
delete this.rawValue;
|
||||||
delete this.lazyRawValueSet;
|
delete this.lazyRawValueSet;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ext.ux.form.SpinnerGroup.superclass.onRender.call(this, ct, position);
|
Ext.ux.form.SpinnerGroup.superclass.onRender.call(this, ct, position);
|
||||||
@ -176,7 +176,7 @@ Ext.ux.form.SpinnerGroup = Ext.extend(Ext.form.CheckboxGroup, {
|
|||||||
this.fireEvent('change', this, this.getValue());
|
this.fireEvent('change', this, this.getValue());
|
||||||
},
|
},
|
||||||
|
|
||||||
initValue : Ext.emptyFn,
|
initValue : Ext.emptyFn,
|
||||||
|
|
||||||
getValue: function() {
|
getValue: function() {
|
||||||
var value = [this.items.getCount()];
|
var value = [this.items.getCount()];
|
||||||
@ -195,25 +195,25 @@ Ext.ux.form.SpinnerGroup = Ext.extend(Ext.form.CheckboxGroup, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
setValue: function(value) {
|
setValue: function(value) {
|
||||||
if (!this.rendered) {
|
if (!this.rendered) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.lazyValueSet = true;
|
this.lazyValueSet = true;
|
||||||
} else {
|
} else {
|
||||||
this.items.each(function(item, i) {
|
this.items.each(function(item, i) {
|
||||||
item.setValue(value[i]);
|
item.setValue(value[i]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
setRawValue: function(value) {
|
setRawValue: function(value) {
|
||||||
if (!this.rendered) {
|
if (!this.rendered) {
|
||||||
this.rawValue = value;
|
this.rawValue = value;
|
||||||
this.lazyRawValueSet = true;
|
this.lazyRawValueSet = true;
|
||||||
} else {
|
} else {
|
||||||
this.items.each(function(item, i) {
|
this.items.each(function(item, i) {
|
||||||
item.setRawValue(value[i]);
|
item.setRawValue(value[i]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Ext.reg('spinnergroup', Ext.ux.form.SpinnerGroup);
|
Ext.reg('spinnergroup', Ext.ux.form.SpinnerGroup);
|
||||||
|
|||||||
@ -42,54 +42,54 @@ Ext.namespace("Ext.ux.form");
|
|||||||
*/
|
*/
|
||||||
Ext.ux.form.ToggleField = Ext.extend(Ext.form.Field, {
|
Ext.ux.form.ToggleField = Ext.extend(Ext.form.Field, {
|
||||||
|
|
||||||
cls: 'x-toggle-field',
|
cls: 'x-toggle-field',
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Ext.ux.form.ToggleField.superclass.initComponent.call(this);
|
Ext.ux.form.ToggleField.superclass.initComponent.call(this);
|
||||||
|
|
||||||
this.toggle = new Ext.form.Checkbox();
|
this.toggle = new Ext.form.Checkbox();
|
||||||
this.toggle.on('check', this.onToggleCheck, this);
|
this.toggle.on('check', this.onToggleCheck, this);
|
||||||
|
|
||||||
this.input = new Ext.form.TextField({
|
this.input = new Ext.form.TextField({
|
||||||
disabled: true
|
disabled: true
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onRender: function(ct, position) {
|
onRender: function(ct, position) {
|
||||||
if (!this.el) {
|
if (!this.el) {
|
||||||
this.panel = new Ext.Panel({
|
this.panel = new Ext.Panel({
|
||||||
cls: this.groupCls,
|
cls: this.groupCls,
|
||||||
layout: 'table',
|
layout: 'table',
|
||||||
layoutConfig: {
|
layoutConfig: {
|
||||||
columns: 2
|
columns: 2
|
||||||
},
|
},
|
||||||
border: false,
|
border: false,
|
||||||
renderTo: ct
|
renderTo: ct
|
||||||
});
|
});
|
||||||
this.panel.ownerCt = this;
|
this.panel.ownerCt = this;
|
||||||
this.el = this.panel.getEl();
|
this.el = this.panel.getEl();
|
||||||
|
|
||||||
this.panel.add(this.toggle);
|
this.panel.add(this.toggle);
|
||||||
this.panel.add(this.input);
|
this.panel.add(this.input);
|
||||||
this.panel.doLayout();
|
this.panel.doLayout();
|
||||||
|
|
||||||
this.toggle.getEl().parent().setStyle('padding-right', '10px');
|
this.toggle.getEl().parent().setStyle('padding-right', '10px');
|
||||||
}
|
}
|
||||||
Ext.ux.form.ToggleField.superclass.onRender.call(this, ct, position);
|
Ext.ux.form.ToggleField.superclass.onRender.call(this, ct, position);
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onResize: function(w, h) {
|
onResize: function(w, h) {
|
||||||
this.panel.setSize(w, h);
|
this.panel.setSize(w, h);
|
||||||
this.panel.doLayout();
|
this.panel.doLayout();
|
||||||
|
|
||||||
// we substract 10 for the padding :-)
|
// we substract 10 for the padding :-)
|
||||||
var inputWidth = w - this.toggle.getSize().width - 25;
|
var inputWidth = w - this.toggle.getSize().width - 25;
|
||||||
this.input.setSize(inputWidth, h);
|
this.input.setSize(inputWidth, h);
|
||||||
},
|
},
|
||||||
|
|
||||||
onToggleCheck: function(toggle, checked) {
|
onToggleCheck: function(toggle, checked) {
|
||||||
this.input.setDisabled(!checked);
|
this.input.setDisabled(!checked);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Ext.reg('togglefield', Ext.ux.form.ToggleField);
|
Ext.reg('togglefield', Ext.ux.form.ToggleField);
|
||||||
|
|||||||
@ -12,208 +12,208 @@ Ext.ns('Ext.ux.grid');
|
|||||||
* A custom GridView which renders rows on an as-needed basis.
|
* A custom GridView which renders rows on an as-needed basis.
|
||||||
*/
|
*/
|
||||||
Ext.ux.grid.BufferView = Ext.extend(Ext.grid.GridView, {
|
Ext.ux.grid.BufferView = Ext.extend(Ext.grid.GridView, {
|
||||||
/**
|
/**
|
||||||
* @cfg {Number} rowHeight
|
* @cfg {Number} rowHeight
|
||||||
* The height of a row in the grid.
|
* The height of a row in the grid.
|
||||||
*/
|
*/
|
||||||
rowHeight: 19,
|
rowHeight: 19,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @cfg {Number} borderHeight
|
* @cfg {Number} borderHeight
|
||||||
* The combined height of border-top and border-bottom of a row.
|
* The combined height of border-top and border-bottom of a row.
|
||||||
*/
|
*/
|
||||||
borderHeight: 2,
|
borderHeight: 2,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @cfg {Boolean/Number} scrollDelay
|
* @cfg {Boolean/Number} scrollDelay
|
||||||
* The number of milliseconds before rendering rows out of the visible
|
* The number of milliseconds before rendering rows out of the visible
|
||||||
* viewing area. Defaults to 100. Rows will render immediately with a config
|
* viewing area. Defaults to 100. Rows will render immediately with a config
|
||||||
* of false.
|
* of false.
|
||||||
*/
|
*/
|
||||||
scrollDelay: 100,
|
scrollDelay: 100,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @cfg {Number} cacheSize
|
* @cfg {Number} cacheSize
|
||||||
* The number of rows to look forward and backwards from the currently viewable
|
* The number of rows to look forward and backwards from the currently viewable
|
||||||
* area. The cache applies only to rows that have been rendered already.
|
* area. The cache applies only to rows that have been rendered already.
|
||||||
*/
|
*/
|
||||||
cacheSize: 20,
|
cacheSize: 20,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @cfg {Number} cleanDelay
|
* @cfg {Number} cleanDelay
|
||||||
* The number of milliseconds to buffer cleaning of extra rows not in the
|
* The number of milliseconds to buffer cleaning of extra rows not in the
|
||||||
* cache.
|
* cache.
|
||||||
*/
|
*/
|
||||||
cleanDelay: 500,
|
cleanDelay: 500,
|
||||||
|
|
||||||
initTemplates : function(){
|
initTemplates : function(){
|
||||||
Ext.ux.grid.BufferView.superclass.initTemplates.call(this);
|
Ext.ux.grid.BufferView.superclass.initTemplates.call(this);
|
||||||
var ts = this.templates;
|
var ts = this.templates;
|
||||||
// empty div to act as a place holder for a row
|
// empty div to act as a place holder for a row
|
||||||
ts.rowHolder = new Ext.Template(
|
ts.rowHolder = new Ext.Template(
|
||||||
'<div class="x-grid3-row {alt}" style="{tstyle}"></div>'
|
'<div class="x-grid3-row {alt}" style="{tstyle}"></div>'
|
||||||
);
|
);
|
||||||
ts.rowHolder.disableFormats = true;
|
ts.rowHolder.disableFormats = true;
|
||||||
ts.rowHolder.compile();
|
ts.rowHolder.compile();
|
||||||
|
|
||||||
ts.rowBody = new Ext.Template(
|
ts.rowBody = new Ext.Template(
|
||||||
'<table class="x-grid3-row-table" border="0" cellspacing="0" cellpadding="0" style="{tstyle}">',
|
'<table class="x-grid3-row-table" border="0" cellspacing="0" cellpadding="0" style="{tstyle}">',
|
||||||
'<tbody><tr>{cells}</tr>',
|
'<tbody><tr>{cells}</tr>',
|
||||||
(this.enableRowBody ? '<tr class="x-grid3-row-body-tr" style="{bodyStyle}"><td colspan="{cols}" class="x-grid3-body-cell" tabIndex="0" hidefocus="on"><div class="x-grid3-row-body">{body}</div></td></tr>' : ''),
|
(this.enableRowBody ? '<tr class="x-grid3-row-body-tr" style="{bodyStyle}"><td colspan="{cols}" class="x-grid3-body-cell" tabIndex="0" hidefocus="on"><div class="x-grid3-row-body">{body}</div></td></tr>' : ''),
|
||||||
'</tbody></table>'
|
'</tbody></table>'
|
||||||
);
|
);
|
||||||
ts.rowBody.disableFormats = true;
|
ts.rowBody.disableFormats = true;
|
||||||
ts.rowBody.compile();
|
ts.rowBody.compile();
|
||||||
},
|
},
|
||||||
|
|
||||||
getStyleRowHeight : function(){
|
getStyleRowHeight : function(){
|
||||||
return Ext.isBorderBox ? (this.rowHeight + this.borderHeight) : this.rowHeight;
|
return Ext.isBorderBox ? (this.rowHeight + this.borderHeight) : this.rowHeight;
|
||||||
},
|
},
|
||||||
|
|
||||||
getCalculatedRowHeight : function(){
|
getCalculatedRowHeight : function(){
|
||||||
return this.rowHeight + this.borderHeight;
|
return this.rowHeight + this.borderHeight;
|
||||||
},
|
},
|
||||||
|
|
||||||
getVisibleRowCount : function(){
|
getVisibleRowCount : function(){
|
||||||
var rh = this.getCalculatedRowHeight();
|
var rh = this.getCalculatedRowHeight();
|
||||||
var visibleHeight = this.scroller.dom.clientHeight;
|
var visibleHeight = this.scroller.dom.clientHeight;
|
||||||
return (visibleHeight < 1) ? 0 : Math.ceil(visibleHeight / rh);
|
return (visibleHeight < 1) ? 0 : Math.ceil(visibleHeight / rh);
|
||||||
},
|
},
|
||||||
|
|
||||||
getVisibleRows: function(){
|
getVisibleRows: function(){
|
||||||
var count = this.getVisibleRowCount();
|
var count = this.getVisibleRowCount();
|
||||||
var sc = this.scroller.dom.scrollTop;
|
var sc = this.scroller.dom.scrollTop;
|
||||||
var start = (sc == 0 ? 0 : Math.floor(sc/this.getCalculatedRowHeight())-1);
|
var start = (sc == 0 ? 0 : Math.floor(sc/this.getCalculatedRowHeight())-1);
|
||||||
return {
|
return {
|
||||||
first: Math.max(start, 0),
|
first: Math.max(start, 0),
|
||||||
last: Math.min(start + count + 2, this.ds.getCount()-1)
|
last: Math.min(start + count + 2, this.ds.getCount()-1)
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
doRender : function(cs, rs, ds, startRow, colCount, stripe, onlyBody){
|
doRender : function(cs, rs, ds, startRow, colCount, stripe, onlyBody){
|
||||||
var ts = this.templates, ct = ts.cell, rt = ts.row, rb = ts.rowBody, last = colCount-1;
|
var ts = this.templates, ct = ts.cell, rt = ts.row, rb = ts.rowBody, last = colCount-1;
|
||||||
var rh = this.getStyleRowHeight();
|
var rh = this.getStyleRowHeight();
|
||||||
var vr = this.getVisibleRows();
|
var vr = this.getVisibleRows();
|
||||||
var tstyle = 'width:'+this.getTotalWidth()+';height:'+rh+'px;';
|
var tstyle = 'width:'+this.getTotalWidth()+';height:'+rh+'px;';
|
||||||
// buffers
|
// buffers
|
||||||
var buf = [], cb, c, p = {}, rp = {tstyle: tstyle}, r;
|
var buf = [], cb, c, p = {}, rp = {tstyle: tstyle}, r;
|
||||||
for (var j = 0, len = rs.length; j < len; j++) {
|
for (var j = 0, len = rs.length; j < len; j++) {
|
||||||
r = rs[j]; cb = [];
|
r = rs[j]; cb = [];
|
||||||
var rowIndex = (j+startRow);
|
var rowIndex = (j+startRow);
|
||||||
var visible = rowIndex >= vr.first && rowIndex <= vr.last;
|
var visible = rowIndex >= vr.first && rowIndex <= vr.last;
|
||||||
if (visible) {
|
if (visible) {
|
||||||
for (var i = 0; i < colCount; i++) {
|
for (var i = 0; i < colCount; i++) {
|
||||||
c = cs[i];
|
c = cs[i];
|
||||||
p.id = c.id;
|
p.id = c.id;
|
||||||
p.css = i == 0 ? 'x-grid3-cell-first ' : (i == last ? 'x-grid3-cell-last ' : '');
|
p.css = i == 0 ? 'x-grid3-cell-first ' : (i == last ? 'x-grid3-cell-last ' : '');
|
||||||
p.attr = p.cellAttr = "";
|
p.attr = p.cellAttr = "";
|
||||||
p.value = c.renderer(r.data[c.name], p, r, rowIndex, i, ds);
|
p.value = c.renderer(r.data[c.name], p, r, rowIndex, i, ds);
|
||||||
p.style = c.style;
|
p.style = c.style;
|
||||||
if (p.value == undefined || p.value === "") {
|
if (p.value == undefined || p.value === "") {
|
||||||
p.value = " ";
|
p.value = " ";
|
||||||
}
|
}
|
||||||
if (r.dirty && typeof r.modified[c.name] !== 'undefined') {
|
if (r.dirty && typeof r.modified[c.name] !== 'undefined') {
|
||||||
p.css += ' x-grid3-dirty-cell';
|
p.css += ' x-grid3-dirty-cell';
|
||||||
}
|
}
|
||||||
cb[cb.length] = ct.apply(p);
|
cb[cb.length] = ct.apply(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var alt = [];
|
var alt = [];
|
||||||
if(stripe && ((rowIndex+1) % 2 == 0)){
|
if(stripe && ((rowIndex+1) % 2 == 0)){
|
||||||
alt[0] = "x-grid3-row-alt";
|
alt[0] = "x-grid3-row-alt";
|
||||||
}
|
}
|
||||||
if(r.dirty){
|
if(r.dirty){
|
||||||
alt[1] = " x-grid3-dirty-row";
|
alt[1] = " x-grid3-dirty-row";
|
||||||
}
|
}
|
||||||
rp.cols = colCount;
|
rp.cols = colCount;
|
||||||
if(this.getRowClass){
|
if(this.getRowClass){
|
||||||
alt[2] = this.getRowClass(r, rowIndex, rp, ds);
|
alt[2] = this.getRowClass(r, rowIndex, rp, ds);
|
||||||
}
|
}
|
||||||
rp.alt = alt.join(" ");
|
rp.alt = alt.join(" ");
|
||||||
rp.cells = cb.join("");
|
rp.cells = cb.join("");
|
||||||
buf[buf.length] = !visible ? ts.rowHolder.apply(rp) : (onlyBody ? rb.apply(rp) : rt.apply(rp));
|
buf[buf.length] = !visible ? ts.rowHolder.apply(rp) : (onlyBody ? rb.apply(rp) : rt.apply(rp));
|
||||||
}
|
}
|
||||||
return buf.join("");
|
return buf.join("");
|
||||||
},
|
},
|
||||||
|
|
||||||
isRowRendered: function(index){
|
isRowRendered: function(index){
|
||||||
var row = this.getRow(index);
|
var row = this.getRow(index);
|
||||||
return row && row.childNodes.length > 0;
|
return row && row.childNodes.length > 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
syncScroll: function(){
|
syncScroll: function(){
|
||||||
Ext.ux.grid.BufferView.superclass.syncScroll.apply(this, arguments);
|
Ext.ux.grid.BufferView.superclass.syncScroll.apply(this, arguments);
|
||||||
this.update();
|
this.update();
|
||||||
},
|
},
|
||||||
|
|
||||||
// a (optionally) buffered method to update contents of gridview
|
// a (optionally) buffered method to update contents of gridview
|
||||||
update: function(){
|
update: function(){
|
||||||
if (this.scrollDelay) {
|
if (this.scrollDelay) {
|
||||||
if (!this.renderTask) {
|
if (!this.renderTask) {
|
||||||
this.renderTask = new Ext.util.DelayedTask(this.doUpdate, this);
|
this.renderTask = new Ext.util.DelayedTask(this.doUpdate, this);
|
||||||
}
|
}
|
||||||
this.renderTask.delay(this.scrollDelay);
|
this.renderTask.delay(this.scrollDelay);
|
||||||
}else{
|
}else{
|
||||||
this.doUpdate();
|
this.doUpdate();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onRemove : function(ds, record, index, isUpdate){
|
onRemove : function(ds, record, index, isUpdate){
|
||||||
Ext.ux.grid.BufferView.superclass.onRemove.apply(this, arguments);
|
Ext.ux.grid.BufferView.superclass.onRemove.apply(this, arguments);
|
||||||
if(isUpdate !== true){
|
if(isUpdate !== true){
|
||||||
this.update();
|
this.update();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
doUpdate: function(){
|
doUpdate: function(){
|
||||||
if (this.getVisibleRowCount() > 0) {
|
if (this.getVisibleRowCount() > 0) {
|
||||||
var g = this.grid, cm = g.colModel, ds = g.store;
|
var g = this.grid, cm = g.colModel, ds = g.store;
|
||||||
var cs = this.getColumnData();
|
var cs = this.getColumnData();
|
||||||
|
|
||||||
var vr = this.getVisibleRows();
|
var vr = this.getVisibleRows();
|
||||||
for (var i = vr.first; i <= vr.last; i++) {
|
for (var i = vr.first; i <= vr.last; i++) {
|
||||||
// if row is NOT rendered and is visible, render it
|
// if row is NOT rendered and is visible, render it
|
||||||
if(!this.isRowRendered(i)){
|
if(!this.isRowRendered(i)){
|
||||||
var html = this.doRender(cs, [ds.getAt(i)], ds, i, cm.getColumnCount(), g.stripeRows, true);
|
var html = this.doRender(cs, [ds.getAt(i)], ds, i, cm.getColumnCount(), g.stripeRows, true);
|
||||||
this.getRow(i).innerHTML = html;
|
this.getRow(i).innerHTML = html;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.clean();
|
this.clean();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// a buffered method to clean rows
|
// a buffered method to clean rows
|
||||||
clean : function(){
|
clean : function(){
|
||||||
if(!this.cleanTask){
|
if(!this.cleanTask){
|
||||||
this.cleanTask = new Ext.util.DelayedTask(this.doClean, this);
|
this.cleanTask = new Ext.util.DelayedTask(this.doClean, this);
|
||||||
}
|
}
|
||||||
this.cleanTask.delay(this.cleanDelay);
|
this.cleanTask.delay(this.cleanDelay);
|
||||||
},
|
},
|
||||||
|
|
||||||
doClean: function(){
|
doClean: function(){
|
||||||
if (this.getVisibleRowCount() > 0) {
|
if (this.getVisibleRowCount() > 0) {
|
||||||
var vr = this.getVisibleRows();
|
var vr = this.getVisibleRows();
|
||||||
vr.first -= this.cacheSize;
|
vr.first -= this.cacheSize;
|
||||||
vr.last += this.cacheSize;
|
vr.last += this.cacheSize;
|
||||||
|
|
||||||
var i = 0, rows = this.getRows();
|
var i = 0, rows = this.getRows();
|
||||||
// if first is less than 0, all rows have been rendered
|
// if first is less than 0, all rows have been rendered
|
||||||
// so lets clean the end...
|
// so lets clean the end...
|
||||||
if(vr.first <= 0){
|
if(vr.first <= 0){
|
||||||
i = vr.last + 1;
|
i = vr.last + 1;
|
||||||
}
|
}
|
||||||
for(var len = this.ds.getCount(); i < len; i++){
|
for(var len = this.ds.getCount(); i < len; i++){
|
||||||
// if current row is outside of first and last and
|
// if current row is outside of first and last and
|
||||||
// has content, update the innerHTML to nothing
|
// has content, update the innerHTML to nothing
|
||||||
if ((i < vr.first || i > vr.last) && rows[i].innerHTML) {
|
if ((i < vr.first || i > vr.last) && rows[i].innerHTML) {
|
||||||
rows[i].innerHTML = '';
|
rows[i].innerHTML = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
layout: function(){
|
layout: function(){
|
||||||
Ext.ux.grid.BufferView.superclass.layout.call(this);
|
Ext.ux.grid.BufferView.superclass.layout.call(this);
|
||||||
this.update();
|
this.update();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -34,23 +34,23 @@
|
|||||||
// remove spaces for hidden elements and make show(), hide(), enable() and disable() act on
|
// remove spaces for hidden elements and make show(), hide(), enable() and disable() act on
|
||||||
// the label. don't use hideLabel with this.
|
// the label. don't use hideLabel with this.
|
||||||
Ext.override(Ext.layout.FormLayout, {
|
Ext.override(Ext.layout.FormLayout, {
|
||||||
renderItem : function(c, position, target){
|
renderItem : function(c, position, target){
|
||||||
if(c && !c.rendered && (c.isFormField || c.fieldLabel) && c.inputType != 'hidden'){
|
if(c && !c.rendered && (c.isFormField || c.fieldLabel) && c.inputType != 'hidden'){
|
||||||
var args = this.getTemplateArgs(c);
|
var args = this.getTemplateArgs(c);
|
||||||
if(typeof position == 'number'){
|
if(typeof position == 'number'){
|
||||||
position = target.dom.childNodes[position] || null;
|
position = target.dom.childNodes[position] || null;
|
||||||
}
|
}
|
||||||
if(position){
|
if(position){
|
||||||
c.formItem = this.fieldTpl.insertBefore(position, args, true);
|
c.formItem = this.fieldTpl.insertBefore(position, args, true);
|
||||||
}else{
|
}else{
|
||||||
c.formItem = this.fieldTpl.append(target, args, true);
|
c.formItem = this.fieldTpl.append(target, args, true);
|
||||||
}
|
}
|
||||||
c.actionMode = 'formItem';
|
c.actionMode = 'formItem';
|
||||||
c.render('x-form-el-'+c.id);
|
c.render('x-form-el-'+c.id);
|
||||||
c.container = c.formItem;
|
c.container = c.formItem;
|
||||||
c.actionMode = 'container';
|
c.actionMode = 'container';
|
||||||
}else {
|
}else {
|
||||||
Ext.layout.FormLayout.superclass.renderItem.apply(this, arguments);
|
Ext.layout.FormLayout.superclass.renderItem.apply(this, arguments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -35,58 +35,58 @@
|
|||||||
* @author Damien Churchill <damoxc@gmail.com>
|
* @author Damien Churchill <damoxc@gmail.com>
|
||||||
*/
|
*/
|
||||||
Ext.override(Ext.tree.MultiSelectionModel, {
|
Ext.override(Ext.tree.MultiSelectionModel, {
|
||||||
|
|
||||||
onNodeClick: function (node, e) {
|
onNodeClick: function (node, e) {
|
||||||
if (e.ctrlKey && this.isSelected(node)) {
|
if (e.ctrlKey && this.isSelected(node)) {
|
||||||
this.unselect(node);
|
this.unselect(node);
|
||||||
} else if (e.shiftKey && !this.isSelected(node)) {
|
} else if (e.shiftKey && !this.isSelected(node)) {
|
||||||
var parentNode = node.parentNode;
|
var parentNode = node.parentNode;
|
||||||
// We can only shift select files in the same node
|
// We can only shift select files in the same node
|
||||||
if (this.lastSelNode.parentNode.id != parentNode.id) return;
|
if (this.lastSelNode.parentNode.id != parentNode.id) return;
|
||||||
|
|
||||||
// Get the node indexes
|
// Get the node indexes
|
||||||
var fi = parentNode.indexOf(node),
|
var fi = parentNode.indexOf(node),
|
||||||
li = parentNode.indexOf(this.lastSelNode);
|
li = parentNode.indexOf(this.lastSelNode);
|
||||||
|
|
||||||
// Select the last clicked node and wipe old selections
|
// Select the last clicked node and wipe old selections
|
||||||
this.select(this.lastSelNode, e, false, true);
|
this.select(this.lastSelNode, e, false, true);
|
||||||
|
|
||||||
// Swap the values if required
|
// Swap the values if required
|
||||||
if (fi > li) {
|
if (fi > li) {
|
||||||
fi = fi + li, li = fi - li, fi = fi - li;
|
fi = fi + li, li = fi - li, fi = fi - li;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Select all the nodes
|
// Select all the nodes
|
||||||
parentNode.eachChild(function(n) {
|
parentNode.eachChild(function(n) {
|
||||||
var i = parentNode.indexOf(n);
|
var i = parentNode.indexOf(n);
|
||||||
if (fi < i && i < li) {
|
if (fi < i && i < li) {
|
||||||
this.select(n, e, true, true);
|
this.select(n, e, true, true);
|
||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
// Select the clicked node
|
// Select the clicked node
|
||||||
this.select(node, e, true);
|
this.select(node, e, true);
|
||||||
} else {
|
} else {
|
||||||
this.select(node, e, e.ctrlKey);
|
this.select(node, e, e.ctrlKey);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
select: function(node, e, keepExisting, suppressEvent) {
|
select: function(node, e, keepExisting, suppressEvent) {
|
||||||
if(keepExisting !== true){
|
if(keepExisting !== true){
|
||||||
this.clearSelections(true);
|
this.clearSelections(true);
|
||||||
}
|
}
|
||||||
if(this.isSelected(node)){
|
if(this.isSelected(node)){
|
||||||
this.lastSelNode = node;
|
this.lastSelNode = node;
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
this.selNodes.push(node);
|
this.selNodes.push(node);
|
||||||
this.selMap[node.id] = node;
|
this.selMap[node.id] = node;
|
||||||
this.lastSelNode = node;
|
this.lastSelNode = node;
|
||||||
node.ui.onSelectedChange(true);
|
node.ui.onSelectedChange(true);
|
||||||
if (suppressEvent !== true) {
|
if (suppressEvent !== true) {
|
||||||
this.fireEvent('selectionchange', this, this.selNodes);
|
this.fireEvent('selectionchange', this, this.selNodes);
|
||||||
}
|
}
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
@ -56,7 +56,7 @@ Ext.tree.ColumnResizer = Ext.extend(Ext.util.Observable, {
|
|||||||
}
|
}
|
||||||
if(ps) {
|
if(ps) {
|
||||||
this.activeHd = Ext.get(ps);
|
this.activeHd = Ext.get(ps);
|
||||||
ss.cursor = Ext.isWebKit ? 'e-resize' : 'col-resize';
|
ss.cursor = Ext.isWebKit ? 'e-resize' : 'col-resize';
|
||||||
}
|
}
|
||||||
} else if(r.right - x <= hw) {
|
} else if(r.right - x <= hw) {
|
||||||
var ns = hd.dom;
|
var ns = hd.dom;
|
||||||
@ -65,7 +65,7 @@ Ext.tree.ColumnResizer = Ext.extend(Ext.util.Observable, {
|
|||||||
}
|
}
|
||||||
if(ns) {
|
if(ns) {
|
||||||
this.activeHd = Ext.get(ns);
|
this.activeHd = Ext.get(ns);
|
||||||
ss.cursor = Ext.isWebKit ? 'w-resize' : 'col-resize';
|
ss.cursor = Ext.isWebKit ? 'w-resize' : 'col-resize';
|
||||||
}
|
}
|
||||||
} else{
|
} else{
|
||||||
delete this.activeHd;
|
delete this.activeHd;
|
||||||
|
|||||||
@ -32,22 +32,22 @@
|
|||||||
|
|
||||||
Ext.override(Ext.ux.tree.TreeGridNodeUI, {
|
Ext.override(Ext.ux.tree.TreeGridNodeUI, {
|
||||||
|
|
||||||
updateColumns: function() {
|
updateColumns: function() {
|
||||||
if (!this.rendered) return;
|
if (!this.rendered) return;
|
||||||
|
|
||||||
var a = this.node.attributes,
|
var a = this.node.attributes,
|
||||||
t = this.node.getOwnerTree(),
|
t = this.node.getOwnerTree(),
|
||||||
cols = t.columns,
|
cols = t.columns,
|
||||||
c = cols[0];
|
c = cols[0];
|
||||||
|
|
||||||
// Update the first column
|
// Update the first column
|
||||||
this.anchor.firstChild.innerHTML = (c.tpl ? c.tpl.apply(a) : a[c.dataIndex] || c.text);
|
this.anchor.firstChild.innerHTML = (c.tpl ? c.tpl.apply(a) : a[c.dataIndex] || c.text);
|
||||||
|
|
||||||
// Update the remaining columns
|
// Update the remaining columns
|
||||||
for(i = 1, len = cols.length; i < len; i++) {
|
for(i = 1, len = cols.length; i < len; i++) {
|
||||||
c = cols[i];
|
c = cols[i];
|
||||||
this.elNode.childNodes[i].firstChild.innerHTML = (c.tpl ? c.tpl.apply(a) : a[c.dataIndex] || c.text);
|
this.elNode.childNodes[i].firstChild.innerHTML = (c.tpl ? c.tpl.apply(a) : a[c.dataIndex] || c.text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
Ext.tree.RenderColumn = Ext.extend(Ext.tree.Column, {
|
Ext.tree.RenderColumn = Ext.extend(Ext.tree.Column, {
|
||||||
|
|
||||||
constructor: function(c) {
|
constructor: function(c) {
|
||||||
c.tpl = c.tpl || new Ext.XTemplate('{' + c.dataIndex + ':this.format}');
|
c.tpl = c.tpl || new Ext.XTemplate('{' + c.dataIndex + ':this.format}');
|
||||||
c.tpl.format = c.renderer;
|
c.tpl.format = c.renderer;
|
||||||
c.tpl.col = this;
|
c.tpl.col = this;
|
||||||
Ext.tree.RenderColumn.superclass.constructor.call(this, c);
|
Ext.tree.RenderColumn.superclass.constructor.call(this, c);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Ext.reg('tgrendercolumn', Ext.tree.RenderColumn);
|
Ext.reg('tgrendercolumn', Ext.tree.RenderColumn);
|
||||||
|
|||||||
@ -56,14 +56,14 @@ Ext.ux.tree.TreeGridSorter = Ext.extend(Ext.tree.TreeSorter, {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var v1 = sortType ? sortType(n1.attributes[p]) : (cs ? n1.attributes[p] : n1.attributes[p].toUpperCase());
|
var v1 = sortType ? sortType(n1.attributes[p]) : (cs ? n1.attributes[p] : n1.attributes[p].toUpperCase());
|
||||||
var v2 = sortType ? sortType(n2.attributes[p]) : (cs ? n2.attributes[p] : n2.attributes[p].toUpperCase());
|
var v2 = sortType ? sortType(n2.attributes[p]) : (cs ? n2.attributes[p] : n2.attributes[p].toUpperCase());
|
||||||
if(v1 < v2){
|
if(v1 < v2){
|
||||||
return dsc ? +1 : -1;
|
return dsc ? +1 : -1;
|
||||||
}else if(v1 > v2){
|
}else if(v1 > v2){
|
||||||
return dsc ? -1 : +1;
|
return dsc ? -1 : +1;
|
||||||
}else{
|
}else{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user