webui: first commit where the interface loads

At this point the interface loads, but it is misshapen and needs a lot more
work to get it fully extjs 4.0 compatible.
This commit is contained in:
Damien Churchill 2011-06-13 00:02:53 +01:00
commit 5b45670a85
46 changed files with 851 additions and 873 deletions

View file

@ -19,7 +19,7 @@
author: 'Damien Churchill <damoxc@gmail.com>', author: 'Damien Churchill <damoxc@gmail.com>',
version: '${version}', version: '${version}',
config: ${js_config} config: ${js_config}
} };
</script> </script>
<!-- Javascript --> <!-- Javascript -->
@ -31,7 +31,7 @@
</script> </script>
</head> </head>
<body> <body>
<div style="background-image: url('${base}themes/images/default/tree/loading.gif');"></div> <div style="background-image: url('${base}resources/themes/images/default/tree/loading.gif');"></div>
<!-- Preload icon classes --> <!-- Preload icon classes -->
<div class="ext-mb-error"></div> <div class="ext-mb-error"></div>

View file

@ -1,2 +1,3 @@
+ OptionsManager.js + OptionsManager.js
+ StatusbarMenu.js + StatusbarMenu.js
+ Formatters.js

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.AddConnectionWindow.js * Deluge.AddConnectionWindow.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -29,13 +29,13 @@
* 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.
*/ */
Ext.ns('Deluge');
/** /**
* @class Deluge.AddConnectionWindow * @class Deluge.AddConnectionWindow
* @extends Ext.Window * @extends Ext.Window
*/ */
Deluge.AddConnectionWindow = Ext.extend(Ext.Window, { Ext.define('Deluge.AddConnectionWindow', {
extend: 'Ext.Window',
title: _('Add Connection'), title: _('Add Connection'),
iconCls: 'x-deluge-add-window-icon', iconCls: 'x-deluge-add-window-icon',
@ -48,15 +48,15 @@ Deluge.AddConnectionWindow = Ext.extend(Ext.Window, {
closeAction: 'hide', closeAction: 'hide',
initComponent: function() { initComponent: function() {
Deluge.AddConnectionWindow.superclass.initComponent.call(this); this.callParent(arguments);
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',

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.AddTrackerWindow.js * Deluge.AddTrackerWindow.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -29,14 +29,14 @@
* 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.
*/ */
Ext.ns('Deluge');
/** /**
* @class Deluge.AddTrackerWindow * @class Deluge.AddTrackerWindow
* @extends Ext.Window * @extends Ext.Window
*/ */
Deluge.AddTrackerWindow = Ext.extend(Ext.Window, { Ext.define('Deluge.AddTrackerWindow', {
extend: 'Ext.Window',
title: _('Add Tracker'), title: _('Add Tracker'),
layout: 'fit', layout: 'fit',
width: 375, width: 375,
@ -51,12 +51,12 @@ Deluge.AddTrackerWindow = Ext.extend(Ext.Window, {
iconCls: 'x-deluge-edit-trackers', iconCls: 'x-deluge-edit-trackers',
initComponent: function() { initComponent: function() {
Deluge.AddTrackerWindow.superclass.initComponent.call(this); this.callParent(arguments);
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',
@ -73,7 +73,7 @@ Deluge.AddTrackerWindow = Ext.extend(Ext.Window, {
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)) {

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.Client.js * Deluge.Client.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -29,7 +29,6 @@
* 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.
*/ */
Ext.namespace('Ext.ux.util');
/** /**
* A class that connects to a json-rpc resource and adds the available * A class that connects to a json-rpc resource and adds the available
@ -37,23 +36,24 @@ Ext.namespace('Ext.ux.util');
* @class Ext.ux.util.RpcClient * @class Ext.ux.util.RpcClient
* @namespace Ext.ux.util * @namespace Ext.ux.util
*/ */
Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, { Ext.define('Ext.ux.util.RpcClient', {
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
/** /**
@ -62,12 +62,12 @@ Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, {
* @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];
@ -82,14 +82,14 @@ Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, {
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',
@ -100,7 +100,7 @@ Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, {
options: options options: options
}); });
}, },
_onFailure: function(response, requestOptions) { _onFailure: function(response, requestOptions) {
var options = requestOptions.options; var options = requestOptions.options;
errorObj = { errorObj = {
@ -111,23 +111,23 @@ Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, {
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);
@ -143,23 +143,23 @@ Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, {
} }
} }
}, },
_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.pop(-1)
} else { } else {
options = {} options = {}
} }
@ -172,11 +172,11 @@ Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, {
_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);
@ -184,11 +184,11 @@ Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, {
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);
} }

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.ConnectionManager.js * Deluge.ConnectionManager.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -30,7 +30,8 @@
* 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.ConnectionManager = Ext.extend(Ext.Window, { Ext.define('Deluge.ConnectionManager', {
extend: 'Ext.Window',
layout: 'fit', layout: 'fit',
width: 300, width: 300,
@ -44,15 +45,15 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, {
iconCls: 'x-deluge-connect-window-icon', iconCls: 'x-deluge-connect-window-icon',
initComponent: function() { initComponent: function() {
Deluge.ConnectionManager.superclass.initComponent.call(this); this.callParent(arguments);
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({
@ -121,7 +122,7 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, {
] ]
}) })
}); });
this.update = this.update.createDelegate(this); this.update = this.update.bind(this);
}, },
/** /**
@ -337,7 +338,7 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, {
// private // private
onShow: function() { onShow: function() {
if (!this.addHostButton) { if (!this.addHostButton) {
var bbar = this.panel.getBottomToolbar(); var bbar = this.panel.getDockedItems()[0];
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');

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.EditTrackerWindow.js * Deluge.EditTrackerWindow.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -29,13 +29,13 @@
* 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.
*/ */
Ext.ns('Deluge');
/** /**
* @class Deluge.EditTrackerWindow * @class Deluge.EditTrackerWindow
* @extends Ext.Window * @extends Ext.Window
*/ */
Deluge.EditTrackerWindow = Ext.extend(Ext.Window, { Ext.define('Deluge.EditTrackerWindow', {
extend: 'Ext.Window',
title: _('Edit Tracker'), title: _('Edit Tracker'),
layout: 'fit', layout: 'fit',
@ -49,14 +49,14 @@ Deluge.EditTrackerWindow = Ext.extend(Ext.Window, {
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); this.callParent(arguments);
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',
@ -69,22 +69,22 @@ Deluge.EditTrackerWindow = Ext.extend(Ext.Window, {
}] }]
}); });
}, },
show: function(record) { show: function(record) {
Deluge.EditTrackerWindow.superclass.show.call(this); this.callParent(arguments);
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);

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.EditTrackers.js * Deluge.EditTrackers.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -35,7 +35,8 @@ Ext.ns('Deluge');
* @class Deluge.EditTrackerWindow * @class Deluge.EditTrackerWindow
* @extends Ext.Window * @extends Ext.Window
*/ */
Deluge.EditTrackersWindow = Ext.extend(Ext.Window, { Ext.define('Deluge.EditTrackersWindow', {
extend: 'Ext.Window',
title: _('Edit Trackers'), title: _('Edit Trackers'),
layout: 'fit', layout: 'fit',
@ -51,18 +52,17 @@ Deluge.EditTrackersWindow = Ext.extend(Ext.Window, {
iconCls: 'x-deluge-edit-trackers', iconCls: 'x-deluge-edit-trackers',
initComponent: function() { initComponent: function() {
Deluge.EditTrackersWindow.superclass.initComponent.call(this); this.callParent(arguments);
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.addWindow = new Deluge.AddTrackerWindow(); this.addWindow = Ext.create('Deluge.AddTrackerWindow');
this.addWindow.on('add', this.onAddTrackers, this); this.addWindow.on('add', this.onAddTrackers, this);
this.editWindow = new Deluge.EditTrackerWindow(); this.editWindow = Ext.create('Deluge.EditTrackerWindow');
this.list = new Ext.list.ListView({ this.list = new Ext.list.ListView({
store: new Ext.data.JsonStore({ store: new Ext.data.JsonStore({
@ -194,6 +194,10 @@ Deluge.EditTrackersWindow = Ext.extend(Ext.Window, {
this.list.getStore().sort('tier', 'ASC'); this.list.getStore().sort('tier', 'ASC');
}, },
onSave: function() {
// What am I meant to do here?
},
onSaveFail: function() { onSaveFail: function() {
}, },

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.EventsManager.js * Deluge.EventsManager.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -37,12 +37,13 @@
* 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); this.callParent(arguments);
}, },
/** /**
* Append an event handler to this object. * Append an event handler to this object.
*/ */
@ -55,7 +56,7 @@ Deluge.EventsManager = Ext.extend(Ext.util.Observable, {
deluge.client.web.register_event_listener(eventName); deluge.client.web.register_event_listener(eventName);
} }
} }
Deluge.EventsManager.superclass.addListener.call(this, eventName, fn, scope, o); this.callParent(arguments);
}, },
getEvents: function() { getEvents: function() {
@ -114,14 +115,13 @@ Deluge.EventsManager = Ext.extend(Ext.util.Observable, {
/** /**
* Appends an event handler to this object (shorthand for {@link #addListener}) * Appends an event handler to this object (shorthand for {@link #addListener})
* @method * @method
*/ */
Deluge.EventsManager.prototype.on = Deluge.EventsManager.prototype.addListener Deluge.EventsManager.prototype.on = Deluge.EventsManager.prototype.addListener
/** /**
* Fires the specified event with the passed parameters (minus the * Fires the specified event with the passed parameters (minus the
* event name). * event name).
* @method * @method
*/ */
Deluge.EventsManager.prototype.fire = Deluge.EventsManager.prototype.fireEvent Deluge.EventsManager.prototype.fire = Deluge.EventsManager.prototype.fireEvent
deluge.events = new Deluge.EventsManager();

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.LoginWindow.js * Deluge.LoginWindow.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -30,8 +30,10 @@
* 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.LoginWindow = Ext.extend(Ext.Window, { Ext.define('Deluge.LoginWindow', {
extend: 'Ext.Window',
firstShow: true, firstShow: true,
bodyStyle: 'padding: 10px 5px;', bodyStyle: 'padding: 10px 5px;',
buttonAlign: 'center', buttonAlign: 'center',
@ -45,17 +47,17 @@ Deluge.LoginWindow = Ext.extend(Ext.Window, {
title: _('Login'), title: _('Login'),
width: 300, width: 300,
height: 120, height: 120,
initComponent: function() { initComponent: function() {
Deluge.LoginWindow.superclass.initComponent.call(this); this.callParent(arguments);
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',
@ -74,7 +76,7 @@ Deluge.LoginWindow = Ext.extend(Ext.Window, {
}); });
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({
@ -84,17 +86,17 @@ Deluge.LoginWindow = Ext.extend(Ext.Window, {
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 this.callParent(arguments);
} }
deluge.client.auth.check_session({ deluge.client.auth.check_session({
success: function(result) { success: function(result) {
if (result) { if (result) {
@ -109,11 +111,11 @@ Deluge.LoginWindow = Ext.extend(Ext.Window, {
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(), {
@ -139,14 +141,14 @@ Deluge.LoginWindow = Ext.extend(Ext.Window, {
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);
} }

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.MoveStorage.js * Deluge.MoveStorage.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -30,30 +30,26 @@
* 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.
*/ */
Ext.namespace('Deluge'); Ext.define('Deluge.MoveStorage', {
Deluge.MoveStorage = Ext.extend(Ext.Window, { extend: 'Ext.Window',
constructor: function(config) { title: _('Move Storage'),
config = Ext.apply({ width: 375,
title: _('Move Storage'), height: 110,
width: 375, layout: 'fit',
height: 110, buttonAlign: 'right',
layout: 'fit', closeAction: 'hide',
buttonAlign: 'right', closable: true,
closeAction: 'hide', iconCls: 'x-deluge-move-storage',
closable: true, plain: true,
iconCls: 'x-deluge-move-storage', resizable: false,
plain: true,
resizable: false
}, config);
Deluge.MoveStorage.superclass.constructor.call(this, config);
},
initComponent: function() { initComponent: function() {
Deluge.MoveStorage.superclass.initComponent.call(this); this.callParent(arguments);
this.addButton(_('Cancel'), this.onCancel, this); // FIXME: Replace the buttons
this.addButton(_('Move'), this.onMove, this); //this.addButton(_('Cancel'), this.onCancel, this);
//this.addButton(_('Move'), this.onMove, this);
this.form = this.add({ this.form = this.add({
xtype: 'form', xtype: 'form',
@ -82,12 +78,12 @@ Deluge.MoveStorage = Ext.extend(Ext.Window, {
}, },
hide: function() { hide: function() {
Deluge.MoveStorage.superclass.hide.call(this); this.callParent(arguments);
this.torrentIds = null; this.torrentIds = null;
}, },
show: function(torrentIds) { show: function(torrentIds) {
Deluge.MoveStorage.superclass.show.call(this); this.callParent(arguments);
this.torrentIds = torrentIds; this.torrentIds = torrentIds;
}, },

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.Plugin.js * Deluge.Plugin.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -29,13 +29,13 @@
* 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.
*/ */
Ext.ns('Deluge');
/** /**
* @class Deluge.Plugin * @class Deluge.Plugin
* @extends Ext.util.Observable * @extends Ext.util.Observable
*/ */
Deluge.Plugin = Ext.extend(Ext.util.Observable, { Ext.define('Deluge.Plugin', {
extend: 'Ext.util.Observable',
/** /**
* The plugins name * The plugins name
@ -59,9 +59,9 @@ Deluge.Plugin = Ext.extend(Ext.util.Observable, {
*/ */
"disabled": true "disabled": true
}); });
Deluge.Plugin.superclass.constructor.call(this, config); this.callParent(arguments);
}, },
/** /**
* 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.
@ -70,7 +70,7 @@ Deluge.Plugin = Ext.extend(Ext.util.Observable, {
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.

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.RemoveWindow.js * Deluge.RemoveWindow.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -34,29 +34,31 @@
* @class Deluge.RemoveWindow * @class Deluge.RemoveWindow
* @extends Ext.Window * @extends Ext.Window
*/ */
Deluge.RemoveWindow = Ext.extend(Ext.Window, { Ext.define('Deluge.RemoveWindow', {
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',
closable: true, closable: true,
iconCls: 'x-deluge-remove-window-icon', iconCls: 'x-deluge-remove-window-icon',
plain: true, plain: true,
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); this.callParent(arguments);
this.addButton(_('Cancel'), this.onCancel, this); // FIXME: Replace with docked toolbar
this.addButton(_('Remove With Data'), this.onRemoveData, this); //this.addButton(_('Cancel'), this.onCancel, this);
this.addButton(_('Remove Torrent'), this.onRemove, this); //this.addButton(_('Remove With Data'), this.onRemoveData, 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, {
@ -67,27 +69,27 @@ Deluge.RemoveWindow = Ext.extend(Ext.Window, {
torrentId: torrentId torrentId: torrentId
}); });
}, this); }, this);
}, },
show: function(ids) { show: function(ids) {
Deluge.RemoveWindow.superclass.show.call(this); this.callParent(arguments);
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();

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.Sidebar.js * Deluge.Sidebar.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -39,7 +39,8 @@
* @author Damien Churchill <damoxc@gmail.com> * @author Damien Churchill <damoxc@gmail.com>
* @version 1.3 * @version 1.3
*/ */
Deluge.Sidebar = Ext.extend(Ext.Panel, { Ext.define('Deluge.Sidebar', {
extend: 'Ext.Panel',
// private // private
panels: {}, panels: {},
@ -61,12 +62,12 @@ Deluge.Sidebar = Ext.extend(Ext.Panel, {
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); this.callParent(arguments);
}, },
// private // private
initComponent: function() { initComponent: function() {
Deluge.Sidebar.superclass.initComponent.call(this); this.callParent(arguments);
deluge.events.on("disconnect", this.onDisconnect, this); deluge.events.on("disconnect", this.onDisconnect, this);
}, },
@ -78,7 +79,7 @@ Deluge.Sidebar = Ext.extend(Ext.Panel, {
deluge.ui.update(); deluge.ui.update();
}); });
this.add(panel); this.add(panel);
this.doLayout(); this.doLayout();
this.panels[filter] = panel; this.panels[filter] = panel;
@ -87,7 +88,7 @@ Deluge.Sidebar = Ext.extend(Ext.Panel, {
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);

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.TorrentGrid.js * Deluge.TorrentGrid.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -30,230 +30,229 @@
* 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.
*/ */
(function() { /* Renderers for the Torrent Grid */
function queueRenderer(value) {
return (value == -1) ? '' : value + 1;
}
function torrentNameRenderer(value, p, r) {
return String.format('<div class="torrent-name x-deluge-{0}">{1}</div>', r.data['state'].toLowerCase(), value);
}
function torrentSpeedRenderer(value) {
if (!value) return;
return fspeed(value);
}
function torrentProgressRenderer(value, p, r) {
value = new Number(value);
var progress = value;
var text = r.data['state'] + ' ' + value.toFixed(2) + '%';
var width = new Number(this.style.match(/\w+:\s*(\d+)\w+/)[1]);
return Deluge.progressBar(value, width - 8, text);
}
function seedsRenderer(value, p, r) {
if (r.data['total_seeds'] > -1) {
return String.format('{0} ({1})', value, r.data['total_seeds']);
} else {
return value;
}
}
function peersRenderer(value, p, r) {
if (r.data['total_peers'] > -1) {
return String.format('{0} ({1})', value, r.data['total_peers']);
} else {
return value;
}
}
function availRenderer(value, p, r) {
return (value < 0) ? '&infin;' : new Number(value).toFixed(3);
}
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);
}
/* Renderers for the Torrent Grid */ function etaSorter(eta) {
function queueRenderer(value) { return eta * -1;
return (value == -1) ? '' : value + 1; }
}
function torrentNameRenderer(value, p, r) { function dateOrNever(date) {
return String.format('<div class="torrent-name x-deluge-{0}">{1}</div>', r.data['state'].toLowerCase(), value); return date > 0.0 ? fdate(date) : "Never"
} }
function torrentSpeedRenderer(value) {
if (!value) return; /**
return fspeed(value); * Deluge.TorrentGrid Class
} *
function torrentProgressRenderer(value, p, r) { * @author Damien Churchill <damoxc@gmail.com>
value = new Number(value); * @version 1.3
var progress = value; *
var text = r.data['state'] + ' ' + value.toFixed(2) + '%'; * @class Deluge.TorrentGrid
var width = new Number(this.style.match(/\w+:\s*(\d+)\w+/)[1]); * @extends Ext.grid.GridPanel
return Deluge.progressBar(value, width - 8, text); * @constructor
} * @param {Object} config Configuration options
function seedsRenderer(value, p, r) { */
if (r.data['total_seeds'] > -1) { Ext.define('Deluge.TorrentGrid', {
return String.format('{0} ({1})', value, r.data['total_seeds']); extend: 'Ext.grid.Panel',
} else {
return value; // object to store contained torrent ids
torrents: {},
columns: [{
id:'queue',
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: _('Last Seen Complete'),
width: 80,
sortable: true,
renderer: dateOrNever,
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'
}],
meta: {
root: 'torrents',
idProperty: 'id',
fields: [
{name: 'queue', sortType: Deluge.data.SortTypes.asQueuePosition},
{name: 'name'},
{name: 'total_size', type: 'int'},
{name: 'state'},
{name: 'progress', type: 'float'},
{name: 'num_seeds', type: 'int'},
{name: 'total_seeds', type: 'int'},
{name: 'num_peers', type: 'int'},
{name: 'total_peers', type: 'int'},
{name: 'download_payload_rate', type: 'int'},
{name: 'upload_payload_speed', type: 'int'},
{name: 'eta', type: 'int', sortType: etaSorter},
{name: 'ratio', type: 'float'},
{name: 'distributed_copies', type: 'float'},
{name: 'time_added', type: 'int'},
{name: 'tracker_host'},
{name: 'save_path'}
]
},
store: Ext.create('Ext.data.Store', {
model: 'Deluge.data.TorrentRecord',
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'torrents'
}
} }
} }),
function peersRenderer(value, p, r) {
if (r.data['total_peers'] > -1) {
return String.format('{0} ({1})', value, r.data['total_peers']);
} else {
return value;
}
}
function availRenderer(value, p, r) {
return (value < 0) ? '&infin;' : new Number(value).toFixed(3);
}
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);
}
function etaSorter(eta) { id: 'torrentGrid',
return eta * -1; region: 'center',
} cls: 'deluge-torrents',
stripeRows: true,
function dateOrNever(date) { autoExpandColumn: 'name',
return date > 0.0 ? fdate(date) : "Never" deferredRender:false,
} autoScroll:true,
margins: '5 5 0 0',
/** stateful: true,
* 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, {
// object to store contained torrent ids
torrents: {},
columns: [{
id:'queue',
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: _('Last Seen Complete'),
width: 80,
sortable: true,
renderer: dateOrNever,
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'
}],
meta: {
root: 'torrents',
idProperty: 'id',
fields: [
{name: 'queue', sortType: Deluge.data.SortTypes.asQueuePosition},
{name: 'name'},
{name: 'total_size', type: 'int'},
{name: 'state'},
{name: 'progress', type: 'float'},
{name: 'num_seeds', type: 'int'},
{name: 'total_seeds', type: 'int'},
{name: 'num_peers', type: 'int'},
{name: 'total_peers', type: 'int'},
{name: 'download_payload_rate', type: 'int'},
{name: 'upload_payload_speed', type: 'int'},
{name: 'eta', type: 'int', sortType: etaSorter},
{name: 'ratio', type: 'float'},
{name: 'distributed_copies', type: 'float'},
{name: 'time_added', type: 'int'},
{name: 'tracker_host'},
{name: 'save_path'}
]
},
constructor: function(config) {
config = Ext.apply({
id: 'torrentGrid',
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);
},
initComponent: function() { initComponent: function() {
Deluge.TorrentGrid.superclass.initComponent.call(this); this.callParent(arguments);
deluge.events.on('torrentRemoved', this.onTorrentRemoved, this); deluge.events.on('torrentRemoved', this.onTorrentRemoved, this);
deluge.events.on('disconnect', this.onDisconnect, this); deluge.events.on('disconnect', this.onDisconnect, this);
@ -378,5 +377,3 @@
}, this); }, this);
} }
}); });
deluge.torrents = new Deluge.TorrentGrid();
})();

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.UI.js * Deluge.UI.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -47,15 +47,18 @@ deluge.ui = {
* 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.details = new Deluge.details.DetailsPanel(); deluge.events = Ext.create('Deluge.EventsManager');
deluge.connectionManager = new Deluge.ConnectionManager(); deluge.add = Ext.create('Deluge.add.AddWindow');
deluge.editTrackers = new Deluge.EditTrackersWindow(); deluge.details = Ext.create('Deluge.details.DetailsPanel');
deluge.login = new Deluge.LoginWindow(); deluge.connectionManager = Ext.create('Deluge.ConnectionManager');
deluge.preferences = new Deluge.preferences.PreferencesWindow(); deluge.editTrackers = Ext.create('Deluge.EditTrackersWindow');
deluge.sidebar = new Deluge.Sidebar(); deluge.login = Ext.create('Deluge.LoginWindow');
deluge.statusbar = new Deluge.Statusbar(); deluge.preferences = Ext.create('Deluge.preferences.PreferencesWindow');
deluge.toolbar = new Deluge.Toolbar(); deluge.sidebar = Ext.create('Deluge.Sidebar');
deluge.statusbar = Ext.create('Deluge.Statusbar');
deluge.toolbar = Ext.create('Deluge.Toolbar');
deluge.torrents = Ext.create('Deluge.TorrentGrid');
this.MainPanel = new Ext.Panel({ this.MainPanel = new Ext.Panel({
id: 'mainPanel', id: 'mainPanel',
@ -98,8 +101,8 @@ deluge.ui = {
deluge.login.show(); deluge.login.show();
}, this, {single: true}); }, this, {single: true});
this.update = this.update.createDelegate(this); this.update = Ext.bind(this.update, this);
this.checkConnection = this.checkConnection.createDelegate(this); this.checkConnection = Ext.bind(this.checkConnection, this);
this.originalTitle = document.title; this.originalTitle = document.title;
}, },

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.add.AddWindow.js * Deluge.add.AddWindow.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -30,9 +30,8 @@
* 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.
*/ */
Ext.namespace('Deluge.add'); Ext.define('Deluge.add.AddWindow', {
extend: 'Deluge.add.Window',
Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
title: _('Add Torrents'), title: _('Add Torrents'),
layout: 'border', layout: 'border',
@ -46,11 +45,11 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
iconCls: 'x-deluge-add-window-icon', iconCls: 'x-deluge-add-window-icon',
initComponent: function() { initComponent: function() {
Deluge.add.AddWindow.superclass.initComponent.call(this); this.callParent(arguments);
// FIXME: replace with docked toolbar
//this.addButton(_('Cancel'), this.onCancelClick, this);
//this.addButton(_('Add'), this.onAddClick, this);
this.addButton(_('Cancel'), this.onCancelClick, 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);
@ -73,7 +72,7 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
sortable: true, sortable: true,
renderer: torrentRenderer, renderer: torrentRenderer,
dataIndex: 'text' dataIndex: 'text'
}], }],
stripeRows: true, stripeRows: true,
singleSelect: true, singleSelect: true,
listeners: { listeners: {
@ -114,7 +113,7 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
}] }]
}) })
}); });
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);
@ -165,12 +164,12 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
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);
@ -193,7 +192,7 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
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();
}, },

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.add.File.js * Deluge.add.File.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -29,13 +29,13 @@
* 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.
*/ */
Ext.ns('Deluge.add');
/** /**
* @class Deluge.add.FileWindow * @class Deluge.add.FileWindow
* @extends Deluge.add.Window * @extends Deluge.add.Window
*/ */
Deluge.add.FileWindow = Ext.extend(Deluge.add.Window, { Ext.define('Deluge.add.FileWindow', {
extend: 'Deluge.add.Window',
title: _('Add from File'), title: _('Add from File'),
layout: 'fit', layout: 'fit',
@ -49,9 +49,9 @@ Deluge.add.FileWindow = Ext.extend(Deluge.add.Window, {
iconCls: 'x-deluge-add-file', iconCls: 'x-deluge-add-file',
initComponent: function() { initComponent: function() {
Deluge.add.FileWindow.superclass.initComponent.call(this); this.callParent(arguments);
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',
@ -71,7 +71,7 @@ Deluge.add.FileWindow = Ext.extend(Deluge.add.Window, {
}] }]
}); });
}, },
// private // private
onAddClick: function(field, e) { onAddClick: function(field, e) {
if (this.form.getForm().isValid()) { if (this.form.getForm().isValid()) {
@ -88,7 +88,7 @@ Deluge.add.FileWindow = Ext.extend(Deluge.add.Window, {
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;
@ -99,7 +99,7 @@ Deluge.add.FileWindow = Ext.extend(Deluge.add.Window, {
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();

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.add.FilesTab.js * Deluge.add.FilesTab.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -29,13 +29,13 @@
* 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.
*/ */
Ext.ns('Deluge.add');
/** /**
* @class Deluge.add.FilesTab * @class Deluge.add.FilesTab
* @extends Ext.ux.tree.TreeGrid * @extends Ext.ux.tree.TreeGrid
*/ */
Deluge.add.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, { Ext.define('Deluge.add.FilesTab', {
extend: 'Ext.tree.Panel',
layout: 'fit', layout: 'fit',
title: _('Files'), title: _('Files'),
@ -71,7 +71,7 @@ Deluge.add.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
}], }],
initComponent: function() { initComponent: function() {
Deluge.add.FilesTab.superclass.initComponent.call(this); this.callParent(arguments);
this.on('click', this.onNodeClick, this); this.on('click', this.onNodeClick, this);
}, },

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.add.Infohash.js * Deluge.add.Infohash.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -29,4 +29,3 @@
* 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.
*/ */
Ext.namespace('Ext.deluge.add');

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.add.OptionsPanel.js * Deluge.add.OptionsPanel.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -29,9 +29,9 @@
* 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.
*/ */
Ext.ns('Deluge.add');
Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, { Ext.define('Deluge.add.OptionsPanel', {
extend: 'Ext.TabPanel',
torrents: {}, torrents: {},
@ -42,7 +42,7 @@ Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
height: 220, height: 220,
initComponent: function() { initComponent: function() {
Deluge.add.OptionsPanel.superclass.initComponent.call(this); this.callParent(arguments);
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());
@ -61,7 +61,7 @@ Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
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);
@ -91,7 +91,7 @@ Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
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');
@ -120,7 +120,7 @@ Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
} 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);
} }
}, },
@ -142,7 +142,7 @@ Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
}, 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

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.add.OptionsPanel.js * Deluge.add.OptionsPanel.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -29,13 +29,13 @@
* 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.
*/ */
Ext.ns('Deluge.add');
/** /**
* @class Deluge.add.OptionsTab * @class Deluge.add.OptionsTab
* @extends Ext.form.FormPanel * @extends Ext.form.FormPanel
*/ */
Deluge.add.OptionsTab = Ext.extend(Ext.form.FormPanel, { Ext.define('Deluge.add.OptionsTab', {
extend: 'Ext.form.Panel',
title: _('Options'), title: _('Options'),
height: 170, height: 170,
@ -46,7 +46,7 @@ Deluge.add.OptionsTab = Ext.extend(Ext.form.FormPanel, {
labelWidth: 1, labelWidth: 1,
initComponent: function() { initComponent: function() {
Deluge.add.OptionsTab.superclass.initComponent.call(this); this.callParent(arguments);
this.optionsManager = new Deluge.MultiOptionsManager(); this.optionsManager = new Deluge.MultiOptionsManager();
@ -67,7 +67,7 @@ Deluge.add.OptionsTab = Ext.extend(Ext.form.FormPanel, {
width: 400, width: 400,
labelSeparator: '' labelSeparator: ''
})); }));
var panel = this.add({ var panel = this.add({
border: false, border: false,
layout: 'column', layout: 'column',
@ -135,7 +135,7 @@ Deluge.add.OptionsTab = Ext.extend(Ext.form.FormPanel, {
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,

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.add.UrlWindow.js * Deluge.add.UrlWindow.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -30,8 +30,8 @@
* 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.
*/ */
Ext.namespace('Deluge.add'); Ext.define('Deluge.add.UrlWindow', {
Deluge.add.UrlWindow = Ext.extend(Deluge.add.Window, { extend: 'Deluge.add.Window',
title: _('Add from Url'), title: _('Add from Url'),
modal: true, modal: true,
@ -46,7 +46,7 @@ Deluge.add.UrlWindow = Ext.extend(Deluge.add.Window, {
iconCls: 'x-deluge-add-url-window-icon', iconCls: 'x-deluge-add-url-window-icon',
initComponent: function() { initComponent: function() {
Deluge.add.UrlWindow.superclass.initComponent.call(this); this.callParent(arguments);
this.addButton(_('Add'), this.onAddClick, this); this.addButton(_('Add'), this.onAddClick, this);
var form = this.add({ var form = this.add({

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.add.Window.js * Deluge.add.Window.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -29,16 +29,17 @@
* 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.
*/ */
Ext.ns('Deluge.add');
/** /**
* @class Deluge.add.Window * @class Deluge.add.Window
* @extends Ext.Window * @extends Ext.Window
* Base class for an add Window * Base class for an add Window
*/ */
Deluge.add.Window = Ext.extend(Ext.Window, { Ext.define('Deluge.add.Window', {
extend: 'Ext.Window',
initComponent: function() { initComponent: function() {
Deluge.add.Window.superclass.initComponent.call(this); this.callParent(arguments);
this.addEvents( this.addEvents(
'beforeadd', 'beforeadd',
'add' 'add'

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.data.PeerRecord.js * Deluge.data.PeerRecord.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -29,7 +29,6 @@
* 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.
*/ */
Ext.namespace('Deluge.data');
/** /**
* Deluge.data.Peer record * Deluge.data.Peer record
@ -38,32 +37,19 @@ Ext.namespace('Deluge.data');
* @version 1.3 * @version 1.3
* *
* @class Deluge.data.Peer * @class Deluge.data.Peer
* @extends Ext.data.Record * @extends Ext.data.Model
* @constructor * @constructor
* @param {Object} data The peer data * @param {Object} data The peer data
*/ */
Deluge.data.Peer = Ext.data.Record.create([ Ext.define('Deluge.data.Peer', {
{ extend: 'Ext.data.Model',
name: 'country', fields: [
type: 'string' {name: 'country', type: 'string'},
}, { {name: 'ip', type: 'string', sortType: Deluge.data.SortTypes.asIPAddress},
name: 'ip', {name: 'client', type: 'string'},
type: 'string', {name: 'progress', type: 'float'},
sortType: Deluge.data.SortTypes.asIPAddress {name: 'down_speed', type: 'int'},
}, { {name: 'up_speed', type: 'int'},
name: 'client', {name: 'seed', type: 'int'}
type: 'string' ]
}, { });
name: 'progress',
type: 'float'
}, {
name: 'down_speed',
type: 'int'
}, {
name: 'up_speed',
type: 'int'
}, {
name: 'seed',
type: 'int'
}
]);

View file

@ -0,0 +1,50 @@
/*!
* Deluge.data.PluginRecord.js
*
* Copyright (c) Damien Churchill 2011 <damoxc@gmail.com>
*
* 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
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, write to:
* The Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the OpenSSL
* library.
* 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
* 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
* this exception statement from your version. If you delete this exception
* statement from all source files in the program, then also delete it here.
*/
/**
* Deluge.data.Plugin record
*
* @author Damien Churchill <damoxc@gmail.com>
* @version 1.4
*
* @class Deluge.data.Plugin
* @extends Ext.data.Model
* @constructor
* @param {Object} data The plugin data
*/
Ext.define('Deluge.data.Plugin', {
extend: 'Ext.data.Model',
fields: [
{name: 'enabled', type: 'boolean'},
{name: 'plugin', type: 'string'}
]
});

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.data.SortTypes.js * Deluge.data.SortTypes.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -39,7 +39,7 @@ Ext.namespace('Deluge.data');
* *
* @class Deluge.data.SortTypes * @class Deluge.data.SortTypes
* @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+)/);

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.data.TorrentRecord.js * Deluge.data.TorrentRecord.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -29,7 +29,6 @@
* 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.
*/ */
Ext.namespace('Deluge.data');
/** /**
* Deluge.data.Torrent record * Deluge.data.Torrent record
@ -38,57 +37,28 @@ Ext.namespace('Deluge.data');
* @version 1.3 * @version 1.3
* *
* @class Deluge.data.Torrent * @class Deluge.data.Torrent
* @extends Ext.data.Record * @extends Ext.data.Model
* @constructor * @constructor
* @param {Object} data The torrents data * @param {Object} data The torrents data
*/ */
Deluge.data.Torrent = Ext.data.Record.create([{ Ext.define('Deluge.data.Torrent', {
name: 'queue', extend: 'Ext.data.Model',
type: 'int' fields: [
}, { {name: 'queue', type: 'int', sortType: Deluge.data.SortTypes.asQueuePosition},
name: 'name', {name: 'name', type: 'string'},
type: 'string' {name: 'total_size', type: 'int'},
}, { {name: 'state', type: 'string'},
name: 'total_size', {name: 'progress', type: 'int'},
type: 'int' {name: 'num_seeds', type: 'int'},
}, { {name: 'total_seeds', type: 'int'},
name: 'state', {name: 'num_peers', type: 'int'},
type: 'string' {name: 'total_peers', type: 'int'},
}, { {name: 'download_payload_rate', type: 'int'},
name: 'progress', {name: 'upload_payload_rate', type: 'int'},
type: 'int' {name: 'eta', type: 'int'},
}, { {name: 'ratio', type: 'float'},
name: 'num_seeds', {name: 'distributed_copies', type: 'float'},
type: 'int' {name: 'time_added', type: 'int'},
}, { {name: 'tracker_host', type: 'string'}
name: 'total_seeds', ]
type: 'int' });
}, {
name: 'num_peers',
type: 'int'
}, {
name: 'total_peers',
type: 'int'
}, {
name: 'download_payload_rate',
type: 'int'
}, {
name: 'upload_payload_rate',
type: 'int'
}, {
name: 'eta',
type: 'int'
}, {
name: 'ratio',
type: 'float'
}, {
name: 'distributed_copies',
type: 'float'
}, {
name: 'time_added',
type: 'int'
}, {
name: 'tracker_host',
type: 'string'
}
]);

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.details.DetailsPanel.js * Deluge.details.DetailsPanel.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -29,12 +29,12 @@
* 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.
*/ */
Ext.namespace('Deluge.details');
/** /**
* @class Deluge.details.DetailsPanel * @class Deluge.details.DetailsPanel
*/ */
Deluge.details.DetailsPanel = Ext.extend(Ext.TabPanel, { Ext.define('Deluge.details.DetailsPanel', {
extend: 'Ext.tab.Panel',
region: 'south', region: 'south',
id: 'torrentDetails', id: 'torrentDetails',
@ -44,16 +44,16 @@ Deluge.details.DetailsPanel = Ext.extend(Ext.TabPanel, {
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); this.callParent(arguments);
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) {
@ -62,42 +62,42 @@ Deluge.details.DetailsPanel = Ext.extend(Ext.TabPanel, {
} }
}); });
}, },
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); this.callParent(arguments);
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();
} }

View file

@ -32,17 +32,16 @@ Copyright:
*/ */
Deluge.details.DetailsTab = Ext.extend(Ext.Panel, { Ext.define('Deluge.details.DetailsTab', {
extend: 'Ext.Panel',
title: _('Details'), title: _('Details'),
fields: {}, fields: {},
queuedItems: {}, queuedItems: {},
oldData: {}, oldData: {},
initComponent: function() { initComponent: function() {
Deluge.details.DetailsTab.superclass.initComponent.call(this); this.callParent(arguments);
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'));
@ -54,7 +53,7 @@ Deluge.details.DetailsTab = Ext.extend(Ext.Panel, {
}, },
onRender: function(ct, position) { onRender: function(ct, position) {
Deluge.details.DetailsTab.superclass.onRender.call(this, ct, position); this.callParent(arguments);
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);

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.details.FilesTab.js * Deluge.details.FilesTab.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -29,8 +29,19 @@
* 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, { Ext.define('Deluge.data.File', {
extend: 'Ext.data.Model',
fields: [
{name: 'filename', type: 'string'},
{name: 'size', type: 'int'},
{name: 'progress', type: 'float'}
]
});
Ext.define('Deluge.details.FilesTab', {
extend: 'Ext.tree.Panel',
title: _('Files'), title: _('Files'),
@ -45,18 +56,19 @@ Deluge.details.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
header: _('Size'), header: _('Size'),
width: 150, width: 150,
dataIndex: 'size', dataIndex: 'size',
tpl: new Ext.XTemplate('{size:this.fsize}', { tpl: Ext.create('Ext.XTemplate', '{size:this.fsize}', {
fsize: function(v) { return fsize(v); } fsize: function(v) { return fsize(v); }
}) })
}, { }, {
xtype: 'tgrendercolumn',
header: _('Progress'), header: _('Progress'),
width: 150, width: 150,
dataIndex: 'progress', dataIndex: 'progress',
renderer: function(v) { tpl: Ext.create('Ext.XTemplate', '{progress:this.progress}', {
var progress = v * 100; progress: function(v) {
return Deluge.progressBar(progress, this.col.width, progress.toFixed(2) + '%', 0); var progress = v * 100;
} return Deluge.progressBar(progress, this.col.width, progress.toFixed(2) + '%', 0);
}
})
}, { }, {
header: _('Priority'), header: _('Priority'),
width: 150, width: 150,
@ -74,13 +86,8 @@ Deluge.details.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
} }
}) })
}], }],
selModel: new Ext.tree.MultiSelectionModel(),
initComponent: function() { multiSelect: true,
Deluge.details.FilesTab.superclass.initComponent.call(this);
this.setRootNode(new Ext.tree.TreeNode({text: 'Files'}));
},
clear: function() { clear: function() {
var root = this.getRootNode(); var root = this.getRootNode();
@ -130,7 +137,7 @@ Deluge.details.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
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,
@ -163,7 +170,7 @@ Deluge.details.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
folderSort: true folderSort: true
}); });
}, },
onContextMenu: function(node, e) { onContextMenu: function(node, e) {
e.stopEvent(); e.stopEvent();
var selModel = this.getSelectionModel(); var selModel = this.getSelectionModel();
@ -173,7 +180,7 @@ Deluge.details.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
} }
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':
@ -200,7 +207,7 @@ Deluge.details.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
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];
@ -217,7 +224,7 @@ Deluge.details.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
break; break;
} }
}, },
onRequestComplete: function(files, options) { onRequestComplete: function(files, options) {
if (!this.getRootNode().hasChildNodes()) { if (!this.getRootNode().hasChildNodes()) {
this.createFileTree(files); this.createFileTree(files);

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.details.OptionsTab.js * Deluge.details.OptionsTab.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -30,29 +30,24 @@
* 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.
*/ */
Ext.define('Deluge.details.OptionsTab', {
extend: 'Ext.form.Panel',
Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, { title: _('Options'),
autoScroll: true,
constructor: function(config) { bodyStyle: 'padding: 5px;',
config = Ext.apply({ border: false,
autoScroll: true, cls: 'x-deluge-options',
bodyStyle: 'padding: 5px;', defaults: {
border: false, autoHeight: true,
cls: 'x-deluge-options', labelWidth: 1,
defaults: { defaultType: 'checkbox'
autoHeight: true,
labelWidth: 1,
defaultType: 'checkbox'
},
deferredRender: false,
layout: 'column',
title: _('Options')
}, config);
Deluge.details.OptionsTab.superclass.constructor.call(this, config);
}, },
deferredRender: false,
layout: 'column',
initComponent: function() { initComponent: function() {
Deluge.details.OptionsTab.superclass.initComponent.call(this); this.callParent(arguments);
this.fieldsets = {}, this.fields = {}; this.fieldsets = {}, this.fields = {};
this.optionsManager = new Deluge.MultiOptionsManager({ this.optionsManager = new Deluge.MultiOptionsManager({
@ -291,7 +286,7 @@ Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
autoHeight: true, autoHeight: true,
defaultType: 'checkbox', defaultType: 'checkbox',
title: _('General'), title: _('General'),
layout: 'form' layout: 'anchor'
}); });
this.fields['private'] = this.fieldsets.general.add({ this.fields['private'] = this.fieldsets.general.add({
@ -354,7 +349,7 @@ Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
}, },
onRender: function(ct, position) { onRender: function(ct, position) {
Deluge.details.OptionsTab.superclass.onRender.call(this, ct, position); this.callParent(arguments);
// 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();

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.details.PeersTab.js * Deluge.details.PeersTab.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -51,65 +51,60 @@
return Deluge.progressBar(progress, this.width - 8, progress + '%'); return Deluge.progressBar(progress, this.width - 8, progress + '%');
} }
Deluge.details.PeersTab = Ext.extend(Ext.grid.GridPanel, { Ext.define('Deluge.details.PeersTab', {
extend: 'Ext.grid.Panel',
title: _('Peers'),
cls: 'x-deluge-peers',
store: Ext.create('Ext.data.Store', {
model: 'Deluge.data.Peer'
}),
columns: [{
header: '&nbsp;',
width: 30,
sortable: true,
renderer: flagRenderer,
dataIndex: 'country'
}, {
header: 'Address',
width: 125,
sortable: true,
renderer: peerAddressRenderer,
dataIndex: 'ip'
}, {
header: 'Client',
width: 125,
sortable: true,
renderer: function(v) { return fplain(v) },
dataIndex: 'client'
}, {
header: 'Progress',
width: 150,
sortable: true,
renderer: peerProgressRenderer,
dataIndex: 'progress'
}, {
header: 'Down Speed',
width: 100,
sortable: true,
renderer: function(v) { return fspeed(v) },
dataIndex: 'down_speed'
}, {
header: 'Up Speed',
width: 100,
sortable: true,
renderer: function(v) { return fspeed(v) },
dataIndex: 'up_speed'
}],
stripeRows: true,
deferredRender: false,
autoScroll: true,
// 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) {
config = Ext.apply({
title: _('Peers'),
cls: 'x-deluge-peers',
store: new Ext.data.Store({
reader: new Ext.data.JsonReader({
idProperty: 'ip',
root: 'peers'
}, Deluge.data.Peer)
}),
columns: [{
header: '&nbsp;',
width: 30,
sortable: true,
renderer: flagRenderer,
dataIndex: 'country'
}, {
header: 'Address',
width: 125,
sortable: true,
renderer: peerAddressRenderer,
dataIndex: 'ip'
}, {
header: 'Client',
width: 125,
sortable: true,
renderer: fplain,
dataIndex: 'client'
}, {
header: 'Progress',
width: 150,
sortable: true,
renderer: peerProgressRenderer,
dataIndex: 'progress'
}, {
header: 'Down Speed',
width: 100,
sortable: true,
renderer: fspeed,
dataIndex: 'down_speed'
}, {
header: 'Up Speed',
width: 100,
sortable: true,
renderer: fspeed,
dataIndex: 'up_speed'
}],
stripeRows: true,
deferredRender:false,
autoScroll:true
}, config);
Deluge.details.PeersTab.superclass.constructor.call(this, config);
},
clear: function() { clear: function() {
this.getStore().removeAll(); this.getStore().removeAll();
this.peers = {}; this.peers = {};

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.details.StatusTab.js * Deluge.details.StatusTab.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -29,52 +29,47 @@
* 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.
*/ */
Ext.ns('Deluge.details');
/** /**
* @class Deluge.details.StatusTab * @class Deluge.details.StatusTab
* @extends Ext.Panel * @extends Ext.Panel
*/ */
Deluge.details.StatusTab = Ext.extend(Ext.Panel, { Ext.define('Deluge.details.StatusTab', {
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); this.callParent(arguments);
this.progressBar = this.add({ this.progressBar = this.add({
xtype: 'progress', xtype: 'progressbar',
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: { loader: {
'render': { url: deluge.config.base + 'render/tab_status.html',
fn: function(panel) { loadMask: true,
panel.load({ success: this.onPanelUpdate,
url: deluge.config.base + 'render/tab_status.html', scope: this
text: _('Loading') + '...'
});
panel.getUpdater().on('update', this.onPanelUpdate, 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, {
@ -82,14 +77,14 @@ Deluge.details.StatusTab = Ext.extend(Ext.Panel, {
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;
@ -117,7 +112,7 @@ Deluge.details.StatusTab = Ext.extend(Ext.Panel, {
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];
} }

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.preferences.BandwidthPage.js * Deluge.preferences.BandwidthPage.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -29,26 +29,21 @@
* 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.
*/ */
Ext.namespace('Deluge.preferences');
/** /**
* @class Deluge.preferences.Bandwidth * @class Deluge.preferences.Bandwidth
* @extends Ext.form.FormPanel * @extends Ext.form.FormPanel
*/ */
Deluge.preferences.Bandwidth = Ext.extend(Ext.form.FormPanel, { Ext.define('Deluge.preferences.Bandwidth', {
constructor: function(config) { extend: 'Ext.form.Panel',
config = Ext.apply({
border: false, border: false,
title: _('Bandwidth'), title: _('Bandwidth'),
layout: 'form', labelWidth: 10,
labelWidth: 10
}, config);
Deluge.preferences.Bandwidth.superclass.constructor.call(this, config);
},
initComponent: function() { initComponent: function() {
Deluge.preferences.Bandwidth.superclass.initComponent.call(this); this.callParent(arguments);
var om = deluge.preferences.getOptionsManager(); var om = deluge.preferences.getOptionsManager();
var fieldset = this.add({ var fieldset = this.add({
xtype: 'fieldset', xtype: 'fieldset',
@ -105,7 +100,7 @@ Deluge.preferences.Bandwidth = Ext.extend(Ext.form.FormPanel, {
value: -1, value: -1,
decimalPrecision: 0 decimalPrecision: 0
})); }));
fieldset = this.add({ fieldset = this.add({
xtype: 'fieldset', xtype: 'fieldset',
border: false, border: false,
@ -128,7 +123,7 @@ Deluge.preferences.Bandwidth = Ext.extend(Ext.form.FormPanel, {
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,

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.preferences.CachePage.js * Deluge.preferences.CachePage.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -29,23 +29,22 @@
* 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.
*/ */
Ext.namespace('Deluge.preferences');
/** /**
* @class Deluge.preferences.Cache * @class Deluge.preferences.Cache
* @extends Ext.form.FormPanel * @extends Ext.form.FormPanel
*/ */
Deluge.preferences.Cache = Ext.extend(Ext.form.FormPanel, { Ext.define('Deluge.preferences.Cache', {
extend: 'Ext.form.Panel',
border: false, border: false,
title: _('Cache'), title: _('Cache'),
layout: 'form',
initComponent: function() { initComponent: function() {
Deluge.preferences.Cache.superclass.initComponent.call(this); this.callParent(arguments);
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,

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.preferences.DaemonPage.js * Deluge.preferences.DaemonPage.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -29,23 +29,22 @@
* 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.
*/ */
Ext.namespace('Deluge.preferences');
/** /**
* @class Deluge.preferences.Daemon * @class Deluge.preferences.Daemon
* @extends Ext.form.FormPanel * @extends Ext.form.FormPanel
*/ */
Deluge.preferences.Daemon = Ext.extend(Ext.form.FormPanel, { Ext.define('Deluge.preferences.Daemon', {
extend: 'Ext.form.Panel',
border: false, border: false,
title: _('Daemon'), title: _('Daemon'),
layout: 'form',
initComponent: function() { initComponent: function() {
Deluge.preferences.Daemon.superclass.initComponent.call(this); this.callParent(arguments);
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,
@ -61,7 +60,7 @@ Deluge.preferences.Daemon = Ext.extend(Ext.form.FormPanel, {
minValue: -1, minValue: -1,
maxValue: 99999 maxValue: 99999
})); }));
fieldset = this.add({ fieldset = this.add({
xtype: 'fieldset', xtype: 'fieldset',
border: false, border: false,
@ -77,7 +76,7 @@ Deluge.preferences.Daemon = Ext.extend(Ext.form.FormPanel, {
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,

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.preferences.DownloadsPage.js * Deluge.preferences.DownloadsPage.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -29,26 +29,21 @@
* 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.
*/ */
Ext.namespace('Deluge.preferences');
/** /**
* @class Deluge.preferences.Downloads * @class Deluge.preferences.Downloads
* @extends Ext.form.FormPanel * @extends Ext.form.FormPanel
*/ */
Deluge.preferences.Downloads = Ext.extend(Ext.FormPanel, { Ext.define('Deluge.preferences.Downloads', {
constructor: function(config) { extend: 'Ext.form.Panel',
config = Ext.apply({ border: false,
border: false, title: _('Downloads'),
title: _('Downloads'), layout: 'anchor',
layout: 'form', autoHeight: true,
autoHeight: true, width: 320,
width: 320
}, config);
Deluge.preferences.Downloads.superclass.constructor.call(this, config);
},
initComponent: function() { initComponent: function() {
Deluge.preferences.Downloads.superclass.initComponent.call(this); this.callParent(arguments);
var optMan = deluge.preferences.getOptionsManager(); var optMan = deluge.preferences.getOptionsManager();
var fieldset = this.add({ var fieldset = this.add({
@ -93,7 +88,7 @@ Deluge.preferences.Downloads = Ext.extend(Ext.FormPanel, {
}); });
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,
@ -122,7 +117,7 @@ Deluge.preferences.Downloads = Ext.extend(Ext.FormPanel, {
inputValue: true inputValue: true
}] }]
})); }));
fieldset = this.add({ fieldset = this.add({
xtype: 'fieldset', xtype: 'fieldset',
border: false, border: false,

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.preferences.InterfacePage.js * Deluge.preferences.InterfacePage.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -29,24 +29,23 @@
* 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.
*/ */
Ext.namespace('Deluge.preferences');
/** /**
* @class Deluge.preferences.Interface * @class Deluge.preferences.Interface
* @extends Ext.form.FormPanel * @extends Ext.form.FormPanel
*/ */
Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, { Ext.define('Deluge.preferences.Interface', {
extend: 'Ext.form.Panel',
border: false, border: false,
title: _('Interface'), title: _('Interface'),
layout: 'form',
initComponent: function() { initComponent: function() {
Deluge.preferences.Interface.superclass.initComponent.call(this); this.callParent(arguments);
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,
@ -77,7 +76,7 @@ Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, {
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,
@ -91,7 +90,7 @@ Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, {
inputType: 'password' inputType: 'password'
} }
}); });
this.oldPassword = fieldset.add({ this.oldPassword = fieldset.add({
name: 'old_password', name: 'old_password',
fieldLabel: _('Old Password') fieldLabel: _('Old Password')
@ -104,7 +103,7 @@ Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, {
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,
@ -122,7 +121,7 @@ Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, {
} }
} }
}); });
fieldset = this.add({ fieldset = this.add({
xtype: 'fieldset', xtype: 'fieldset',
border: false, border: false,
@ -173,7 +172,7 @@ Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, {
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)) {
@ -187,11 +186,11 @@ Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, {
} }
} }
}, },
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()) {
@ -205,7 +204,7 @@ Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, {
}); });
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) {
@ -236,18 +235,18 @@ Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, {
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);

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.preferences.NetworkPage.js * Deluge.preferences.NetworkPage.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -29,22 +29,21 @@
* 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.
*/ */
Ext.namespace('Deluge.preferences');
/** /**
* @class Deluge.preferences.Network * @class Deluge.preferences.Network
* @extends Ext.form.FormPanel * @extends Ext.form.FormPanel
*/ */
Deluge.preferences.Network = Ext.extend(Ext.form.FormPanel, { Ext.define('Deluge.preferences.Network', {
extend: 'Ext.form.Panel',
border: false, border: false,
layout: 'form',
title: _('Network'), title: _('Network'),
initComponent: function() { initComponent: function() {
Deluge.preferences.Network.superclass.initComponent.call(this); this.callParent(arguments);
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,
@ -97,7 +96,7 @@ Deluge.preferences.Network = Ext.extend(Ext.form.FormPanel, {
}] }]
}); });
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,
@ -150,7 +149,7 @@ Deluge.preferences.Network = Ext.extend(Ext.form.FormPanel, {
}] }]
}); });
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,
@ -166,7 +165,7 @@ Deluge.preferences.Network = Ext.extend(Ext.form.FormPanel, {
labelSeparator: '', labelSeparator: '',
width: 200 width: 200
})); }));
fieldset = this.add({ fieldset = this.add({
xtype: 'fieldset', xtype: 'fieldset',
border: false, border: false,
@ -181,7 +180,7 @@ Deluge.preferences.Network = Ext.extend(Ext.form.FormPanel, {
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,
@ -190,7 +189,7 @@ Deluge.preferences.Network = Ext.extend(Ext.form.FormPanel, {
layout: 'table', layout: 'table',
layoutConfig: { layoutConfig: {
columns: 3 columns: 3
}, },
defaultType: 'checkbox' defaultType: 'checkbox'
}); });
optMan.bind('upnp', fieldset.add({ optMan.bind('upnp', fieldset.add({

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.preferences.OtherPage.js * Deluge.preferences.OtherPage.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -29,27 +29,21 @@
* 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.
*/ */
Ext.namespace('Deluge.preferences');
/** /**
* @class Deluge.preferences.Other * @class Deluge.preferences.Other
* @extends Ext.form.FormPanel * @extends Ext.form.FormPanel
*/ */
Deluge.preferences.Other = Ext.extend(Ext.form.FormPanel, { Ext.define('Deluge.preferences.Other', {
constructor: function(config) { extend: 'Ext.form.Panel',
config = Ext.apply({ border: false,
border: false, title: _('Other'),
title: _('Other'),
layout: 'form'
}, config);
Deluge.preferences.Other.superclass.constructor.call(this, config);
},
initComponent: function() { initComponent: function() {
Deluge.preferences.Other.superclass.initComponent.call(this); this.callParent(arguments);
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,
@ -65,7 +59,7 @@ Deluge.preferences.Other = Ext.extend(Ext.form.FormPanel, {
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,
@ -90,7 +84,7 @@ Deluge.preferences.Other = Ext.extend(Ext.form.FormPanel, {
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,

View file

@ -54,7 +54,7 @@ Deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
), ),
initComponent: function() { initComponent: function() {
Deluge.preferences.Plugins.superclass.initComponent.call(this); this.callParent(arguments);
this.defaultValues = { this.defaultValues = {
'version': '', 'version': '',
'email': '', 'email': '',
@ -68,14 +68,12 @@ Deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
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.grid = this.add({
xtype: 'listview', xtype: 'grid',
store: new Ext.data.ArrayStore({ store: Ext.create('Ext.data.JsonStore', {
fields: [ model: 'Deluge.data.PluginRecord'
{name: 'enabled', mapping: 0},
{name: 'plugin', mapping: 1}
]
}), }),
singleSelect: true,
columns: [{ columns: [{
id: 'enabled', id: 'enabled',
header: _('Enabled'), header: _('Enabled'),
@ -94,8 +92,6 @@ Deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
sortable: true, sortable: true,
dataIndex: 'plugin' dataIndex: 'plugin'
}], }],
singleSelect: true,
autoExpandColumn: 'plugin',
listeners: { listeners: {
selectionchange: {fn: this.onPluginSelect, scope: this} selectionchange: {fn: this.onPluginSelect, scope: this}
} }
@ -105,7 +101,7 @@ Deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
region: 'center', region: 'center',
autoScroll: true, autoScroll: true,
margins: '5 5 5 5', margins: '5 5 5 5',
items: [this.list], items: [this.grid],
bbar: new Ext.Toolbar({ bbar: new Ext.Toolbar({
items: [{ items: [{
cls: 'x-btn-text-icon', cls: 'x-btn-text-icon',
@ -147,7 +143,7 @@ Deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
}); });
this.pluginInfo.on('render', this.onPluginInfoRender, this); this.pluginInfo.on('render', this.onPluginInfoRender, this);
this.list.on('click', this.onNodeClick, this); this.grid.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);

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.preferences.PreferencesWindow.js * Deluge.preferences.PreferencesWindow.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -29,15 +29,18 @@
* 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.
*/ */
Ext.namespace('Deluge.preferences');
PreferencesRecord = Ext.data.Record.create([{name:'name', type:'string'}]); Ext.define('PreferencesRecord', {
extend: 'Ext.data.Model',
fields: [{name: 'name', type: 'string'}]
});
/** /**
* @class Deluge.preferences.PreferencesWindow * @class Deluge.preferences.PreferencesWindow
* @extends Ext.Window * @extends Ext.Window
*/ */
Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, { Ext.define('Deluge.preferences.PreferencesWindow', {
extend: 'Ext.Window',
/** /**
* @property {String} currentPage The currently selected page. * @property {String} currentPage The currently selected page.
@ -59,10 +62,12 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
pages: {}, pages: {},
initComponent: function() { initComponent: function() {
Deluge.preferences.PreferencesWindow.superclass.initComponent.call(this); this.callParent(arguments);
this.list = new Ext.list.ListView({ this.list = new Ext.list.ListView({
store: new Ext.data.Store(), store: Ext.create('Ext.data.Store', {
model: 'PreferencesRecord'
}),
columns: [{ columns: [{
id: 'name', id: 'name',
renderer: fplain, renderer: fplain,
@ -103,10 +108,10 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
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);
@ -128,7 +133,7 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
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)) {
@ -137,13 +142,13 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
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
@ -151,7 +156,7 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
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
@ -166,7 +171,7 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
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
@ -179,12 +184,12 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
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);
@ -192,24 +197,24 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
// 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();
@ -222,7 +227,7 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
} }
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;

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.preferences.ProxyPage.js * Deluge.preferences.ProxyPage.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -29,51 +29,46 @@
* 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.
*/ */
Ext.namespace('Deluge.preferences');
/** /**
* @class Deluge.preferences.Proxy * @class Deluge.preferences.Proxy
* @extends Ext.form.FormPanel * @extends Ext.form.FormPanel
*/ */
Deluge.preferences.Proxy = Ext.extend(Ext.form.FormPanel, { Ext.define('Deluge.preferences.Proxy', {
constructor: function(config) { extend: 'Ext.form.Panel',
config = Ext.apply({
border: false, border: false,
title: _('Proxy'), title: _('Proxy'),
layout: 'form'
}, config);
Deluge.preferences.Proxy.superclass.constructor.call(this, config);
},
initComponent: function() { initComponent: function() {
Deluge.preferences.Proxy.superclass.initComponent.call(this); this.callParent(arguments);
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(),
@ -82,18 +77,18 @@ Deluge.preferences.Proxy = Ext.extend(Ext.form.FormPanel, {
'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);
} }
}); });

View file

@ -1,7 +1,7 @@
/*! /*!
* Deluge.preferences.QueuePage.js * Deluge.preferences.QueuePage.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2011 <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
@ -29,23 +29,22 @@
* 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.
*/ */
Ext.namespace('Deluge.preferences');
/** /**
* @class Deluge.preferences.Queue * @class Deluge.preferences.Queue
* @extends Ext.form.FormPanel * @extends Ext.form.FormPanel
*/ */
Deluge.preferences.Queue = Ext.extend(Ext.form.FormPanel, { Ext.define('Deluge.preferences.Queue', {
extend: 'Ext.form.Panel',
border: false, border: false,
title: _('Queue'), title: _('Queue'),
layout: 'form',
initComponent: function() { initComponent: function() {
Deluge.preferences.Queue.superclass.initComponent.call(this); this.callParent(arguments);
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,
@ -62,7 +61,7 @@ Deluge.preferences.Queue = Ext.extend(Ext.form.FormPanel, {
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,
@ -113,7 +112,7 @@ Deluge.preferences.Queue = Ext.extend(Ext.form.FormPanel, {
hideLabel: true, hideLabel: true,
boxLabel: _('Prefer Seeding over Downloading') boxLabel: _('Prefer Seeding over Downloading')
})); }));
fieldset = this.add({ fieldset = this.add({
xtype: 'fieldset', xtype: 'fieldset',
border: false, border: false,
@ -154,17 +153,17 @@ Deluge.preferences.Queue = Ext.extend(Ext.form.FormPanel, {
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: ''
@ -176,7 +175,7 @@ Deluge.preferences.Queue = Ext.extend(Ext.form.FormPanel, {
}); });
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',
@ -191,7 +190,7 @@ Deluge.preferences.Queue = Ext.extend(Ext.form.FormPanel, {
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',
@ -201,7 +200,7 @@ Deluge.preferences.Queue = Ext.extend(Ext.form.FormPanel, {
}); });
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);

View file

@ -427,7 +427,7 @@ class TopLevel(resource.Resource):
__stylesheets = [ __stylesheets = [
"resources/css/ext-all-gray.css", "resources/css/ext-all-gray.css",
# "css/ext-extensions.css", # "css/ext-extensions.css",
# "css/deluge.css" "css/deluge.css"
] ]
def __init__(self): def __init__(self):