[Lint] Format files with Prettier

Use Prettier to auto-format javascript, CSS and YAML files so that less
manual work is involved and style is consistent across project.
This commit is contained in:
Calum Lind
2018-10-03 11:22:22 +01:00
parent b1cdc32f73
commit 358ff74d0e
97 changed files with 8330 additions and 6334 deletions

6
.prettierignore Normal file
View File

@ -0,0 +1,6 @@
deluge/ui/web/css/ext-*.css
deluge/ui/web/js/extjs/ext-*.js
deluge/ui/web/docs/
deluge/ui/web/themes/images/
*.py*
*.html

13
.prettierrc.yaml Normal file
View File

@ -0,0 +1,13 @@
trailingComma: "es5"
tabWidth: 4
singleQuote: true
overrides:
- files:
- "*.yaml"
- ".*.yaml"
- "*.yml"
- ".*.yml"
- "*.md"
options:
tabWidth: 2
singleQuote: false

View File

@ -3,7 +3,7 @@ sudo: required
language: python language: python
python: python:
- "2.7" - "2.7"
cache: pip cache: pip
before_install: before_install:

View File

@ -22,46 +22,47 @@ install:
# purpose but it is problematic because it tends to cancel builds pushed # purpose but it is problematic because it tends to cancel builds pushed
# directly to master instead of just PR builds (or the converse). # directly to master instead of just PR builds (or the converse).
# credits: JuliaLang developers. # credits: JuliaLang developers.
- ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod ` - ps:
https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | ` if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod `
Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { ` https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | `
throw "There are newer queued builds for this pull request, failing early." } Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { `
throw "There are newer queued builds for this pull request, failing early." }
- "python -m pip install --upgrade pip" - "python -m pip install --upgrade pip"
- if defined TOXENV ( - if defined TOXENV (
pip install pip install
tox tox
pywin32 pywin32
certifi certifi
) )
- if not defined TOXENV ( - if not defined TOXENV (
pip install pip install
slimit slimit
twisted[tls] twisted[tls]
chardet chardet
mako mako
pyxdg pyxdg
pillow pillow
slimit slimit
setproctitle setproctitle
pywin32 pywin32
certifi certifi
pygame pygame
bbfreeze bbfreeze
pefile pefile
) )
- echo "Installing pygtk...." - echo "Installing pygtk...."
- if not exist pygtk-all-in-one-2.24.2.win32-py2.7.msi ( - if not exist pygtk-all-in-one-2.24.2.win32-py2.7.msi (
echo "Downloading pygtk...." echo "Downloading pygtk...."
& appveyor-retry appveyor DownloadFile "https://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.24/pygtk-all-in-one-2.24.2.win32-py2.7.msi" & appveyor-retry appveyor DownloadFile "https://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.24/pygtk-all-in-one-2.24.2.win32-py2.7.msi"
) )
- cmd: msiexec /i pygtk-all-in-one-2.24.2.win32-py2.7.msi /quiet /qn /norestart TARGETDIR=C:\Python27 INSTALLLEVEL=3 - cmd: msiexec /i pygtk-all-in-one-2.24.2.win32-py2.7.msi /quiet /qn /norestart TARGETDIR=C:\Python27 INSTALLLEVEL=3
- echo "Installing openssl...." - echo "Installing openssl...."
- if not exist openssl-1.1.0f-vs2008.7z ( - if not exist openssl-1.1.0f-vs2008.7z (
echo "Downloading openssl...." echo "Downloading openssl...."
& appveyor-retry appveyor DownloadFile "https://www.npcglib.org/~stathis/downloads/openssl-1.1.0f-vs2008.7z" & appveyor-retry appveyor DownloadFile "https://www.npcglib.org/~stathis/downloads/openssl-1.1.0f-vs2008.7z"
) )
- "7z x -oc:\\ -aoa openssl-1.1.0f-vs2008.7z" - "7z x -oc:\\ -aoa openssl-1.1.0f-vs2008.7z"
- "rename c:\\openssl-1.1.0f-vs2008 openssl-1.1" - "rename c:\\openssl-1.1.0f-vs2008 openssl-1.1"
@ -70,15 +71,15 @@ install:
- echo "Installing libtorrent...." - echo "Installing libtorrent...."
- if not exist libtorrent.pyd ( - if not exist libtorrent.pyd (
echo "Downloading libtorrent...." echo "Downloading libtorrent...."
& appveyor-retry appveyor DownloadFile "https://github.com/doadin/libtorrent/releases/download/1.1.7.test/libtorrent.pyd" & appveyor-retry appveyor DownloadFile "https://github.com/doadin/libtorrent/releases/download/1.1.7.test/libtorrent.pyd"
) )
- "copy /Y libtorrent.pyd c:\\Python27\\Lib\\site-packages\\libtorrent.pyd" - "copy /Y libtorrent.pyd c:\\Python27\\Lib\\site-packages\\libtorrent.pyd"
- "SET PATH=%TOXENV%;%PYTHON%;%PYTHON%\\Scripts;c:\\openssl-1.1\\bin;C:\\Program Files (x86)\\NSIS;%PATH%" - "SET PATH=%TOXENV%;%PYTHON%;%PYTHON%\\Scripts;c:\\openssl-1.1\\bin;C:\\Program Files (x86)\\NSIS;%PATH%"
- "python --version" - "python --version"
- "python -c \"import struct; print(struct.calcsize('P') * 8)\"" - 'python -c "import struct; print(struct.calcsize(\"P\") * 8)"'
- "python -c \"import libtorrent; print(libtorrent.__version__)\"" - 'python -c "import libtorrent; print(libtorrent.__version__)"'
- openssl version -v - openssl version -v
cache: cache:

View File

@ -19,7 +19,6 @@ Ext.ns('Deluge.ux.preferences');
* @extends Ext.Panel * @extends Ext.Panel
*/ */
Deluge.ux.preferences.AutoAddPage = Ext.extend(Ext.Panel, { Deluge.ux.preferences.AutoAddPage = Ext.extend(Ext.Panel, {
title: _('AutoAdd'), title: _('AutoAdd'),
header: false, header: false,
layout: 'fit', layout: 'fit',
@ -33,75 +32,91 @@ Deluge.ux.preferences.AutoAddPage = Ext.extend(Ext.Panel, {
this.list = new Ext.list.ListView({ this.list = new Ext.list.ListView({
store: new Ext.data.JsonStore({ store: new Ext.data.JsonStore({
fields: [ fields: ['id', 'enabled', 'owner', 'path'],
'id',
'enabled',
'owner',
'path'
]
}), }),
columns: [{ columns: [
id: 'enabled', {
header: _('Active'), id: 'enabled',
sortable: true, header: _('Active'),
dataIndex: 'enabled', sortable: true,
tpl: new Ext.XTemplate('{enabled:this.getCheckbox}', { dataIndex: 'enabled',
getCheckbox: function(checked, selected) { tpl: new Ext.XTemplate('{enabled:this.getCheckbox}', {
Deluge.ux.AutoAdd.onClickFunctions[selected.id] = function () { getCheckbox: function(checked, selected) {
if (selected.enabled) { Deluge.ux.AutoAdd.onClickFunctions[
deluge.client.autoadd.disable_watchdir(selected.id); selected.id
checked = false; ] = function() {
} if (selected.enabled) {
else { deluge.client.autoadd.disable_watchdir(
deluge.client.autoadd.enable_watchdir(selected.id); selected.id
checked = true; );
} checked = false;
autoAdd.updateWatchDirs(); } else {
}; deluge.client.autoadd.enable_watchdir(
return '<input id="enabled-' + selected.id + '" type="checkbox"' + (checked ? ' checked' : '') + selected.id
' onclick="Deluge.ux.AutoAdd.onClickFunctions[' + selected.id +']()" />' );
} checked = true;
}), }
width: .15 autoAdd.updateWatchDirs();
}, { };
id: 'owner', return (
header: _('Owner'), '<input id="enabled-' +
sortable: true, selected.id +
dataIndex: 'owner', '" type="checkbox"' +
width: .2 (checked ? ' checked' : '') +
}, { ' onclick="Deluge.ux.AutoAdd.onClickFunctions[' +
id: 'path', selected.id +
header: _('Path'), ']()" />'
sortable: true, );
dataIndex: 'path' },
}], }),
width: 0.15,
},
{
id: 'owner',
header: _('Owner'),
sortable: true,
dataIndex: 'owner',
width: 0.2,
},
{
id: 'path',
header: _('Path'),
sortable: true,
dataIndex: 'path',
},
],
singleSelect: true, singleSelect: true,
autoExpandColumn: 'path' autoExpandColumn: 'path',
}); });
this.list.on('selectionchange', this.onSelectionChange, this); this.list.on('selectionchange', this.onSelectionChange, this);
this.panel = this.add({ this.panel = this.add({
items: [this.list], items: [this.list],
bbar: { bbar: {
items: [{ items: [
{
text: _('Add'), text: _('Add'),
iconCls: 'icon-add', iconCls: 'icon-add',
handler: this.onAddClick, handler: this.onAddClick,
scope: this scope: this,
}, { },
{
text: _('Edit'), text: _('Edit'),
iconCls: 'icon-edit', iconCls: 'icon-edit',
handler: this.onEditClick, handler: this.onEditClick,
scope: this, scope: this,
disabled: true disabled: true,
}, '->', { },
'->',
{
text: _('Remove'), text: _('Remove'),
iconCls: 'icon-remove', iconCls: 'icon-remove',
handler: this.onRemoveClick, handler: this.onRemoveClick,
scope: this, scope: this,
disabled: true disabled: true,
}] },
} ],
},
}); });
this.on('show', this.onPreferencesShow, this); this.on('show', this.onPreferencesShow, this);
@ -117,7 +132,8 @@ Deluge.ux.preferences.AutoAddPage = Ext.extend(Ext.Panel, {
var watchdir = {}; var watchdir = {};
watchdir['id'] = id; watchdir['id'] = id;
watchdir['enabled'] = watchdirs[id].enabled; watchdir['enabled'] = watchdirs[id].enabled;
watchdir['owner'] = watchdirs[id].owner || 'localclient'; watchdir['owner'] =
watchdirs[id].owner || 'localclient';
watchdir['path'] = watchdirs[id].path; watchdir['path'] = watchdirs[id].path;
watchdirsArray.push(watchdir); watchdirsArray.push(watchdir);
@ -125,16 +141,20 @@ Deluge.ux.preferences.AutoAddPage = Ext.extend(Ext.Panel, {
} }
this.list.getStore().loadData(watchdirsArray); this.list.getStore().loadData(watchdirsArray);
}, },
scope: this scope: this,
}); });
}, },
onAddClick: function() { onAddClick: function() {
if (!this.addWin) { if (!this.addWin) {
this.addWin = new Deluge.ux.AutoAdd.AddAutoAddCommandWindow(); this.addWin = new Deluge.ux.AutoAdd.AddAutoAddCommandWindow();
this.addWin.on('watchdiradd', function() { this.addWin.on(
this.updateWatchDirs(); 'watchdiradd',
}, this); function() {
this.updateWatchDirs();
},
this
);
} }
this.addWin.show(); this.addWin.show();
}, },
@ -142,9 +162,13 @@ Deluge.ux.preferences.AutoAddPage = Ext.extend(Ext.Panel, {
onEditClick: function() { onEditClick: function() {
if (!this.editWin) { if (!this.editWin) {
this.editWin = new Deluge.ux.AutoAdd.EditAutoAddCommandWindow(); this.editWin = new Deluge.ux.AutoAdd.EditAutoAddCommandWindow();
this.editWin.on('watchdiredit', function() { this.editWin.on(
this.updateWatchDirs(); 'watchdiredit',
}, this); function() {
this.updateWatchDirs();
},
this
);
} }
var id = this.list.getSelectedRecords()[0].id; var id = this.list.getSelectedRecords()[0].id;
this.editWin.show(id, this.watchdirs[id]); this.editWin.show(id, this.watchdirs[id]);
@ -160,26 +184,38 @@ Deluge.ux.preferences.AutoAddPage = Ext.extend(Ext.Panel, {
success: function() { success: function() {
this.updateWatchDirs(); this.updateWatchDirs();
}, },
scope: this scope: this,
}); });
}, },
onSelectionChange: function(dv, selections) { onSelectionChange: function(dv, selections) {
if (selections.length) { if (selections.length) {
this.panel.getBottomToolbar().items.get(1).enable(); this.panel
this.panel.getBottomToolbar().items.get(3).enable(); .getBottomToolbar()
.items.get(1)
.enable();
this.panel
.getBottomToolbar()
.items.get(3)
.enable();
} else { } else {
this.panel.getBottomToolbar().items.get(1).disable(); this.panel
this.panel.getBottomToolbar().items.get(3).disable(); .getBottomToolbar()
.items.get(1)
.disable();
this.panel
.getBottomToolbar()
.items.get(3)
.disable();
} }
} },
}); });
Deluge.plugins.AutoAddPlugin = Ext.extend(Deluge.Plugin, { Deluge.plugins.AutoAddPlugin = Ext.extend(Deluge.Plugin, {
name: 'AutoAdd', name: 'AutoAdd',
static: { static: {
prefsPage: null prefsPage: null,
}, },
onDisable: function() { onDisable: function() {
@ -193,9 +229,11 @@ Deluge.plugins.AutoAddPlugin = Ext.extend(Deluge.Plugin, {
* This will prevent adding unnecessary tabs to the preferences window. * This will prevent adding unnecessary tabs to the preferences window.
*/ */
if (!Deluge.plugins.AutoAddPlugin.prefsPage) { if (!Deluge.plugins.AutoAddPlugin.prefsPage) {
Deluge.plugins.AutoAddPlugin.prefsPage = deluge.preferences.addPage(new Deluge.ux.preferences.AutoAddPage()); Deluge.plugins.AutoAddPlugin.prefsPage = deluge.preferences.addPage(
new Deluge.ux.preferences.AutoAddPage()
);
} }
} },
}); });
Deluge.registerPlugin('AutoAdd', Deluge.plugins.AutoAddPlugin); Deluge.registerPlugin('AutoAdd', Deluge.plugins.AutoAddPlugin);

View File

@ -16,34 +16,48 @@ Ext.ns('Deluge.ux.AutoAdd');
* @extends Ext.Window * @extends Ext.Window
*/ */
Deluge.ux.AutoAdd.AutoAddWindowBase = Ext.extend(Ext.Window, { Deluge.ux.AutoAdd.AutoAddWindowBase = Ext.extend(Ext.Window, {
width: 350, width: 350,
autoHeight: true, autoHeight: true,
closeAction: 'hide', closeAction: 'hide',
spin_ids: ['max_download_speed', 'max_upload_speed', 'stop_ratio'], spin_ids: ['max_download_speed', 'max_upload_speed', 'stop_ratio'],
spin_int_ids: ['max_upload_slots', 'max_connections'], spin_int_ids: ['max_upload_slots', 'max_connections'],
chk_ids: ['stop_at_ratio', 'remove_at_ratio', 'move_completed', chk_ids: [
'add_paused', 'auto_managed', 'queue_to_top'], 'stop_at_ratio',
toggle_ids: ['append_extension_toggle', 'download_location_toggle', 'remove_at_ratio',
'label_toggle', 'copy_torrent_toggle', 'move_completed',
'delete_copy_torrent_toggle', 'seed_mode'], 'add_paused',
'auto_managed',
'queue_to_top',
],
toggle_ids: [
'append_extension_toggle',
'download_location_toggle',
'label_toggle',
'copy_torrent_toggle',
'delete_copy_torrent_toggle',
'seed_mode',
],
accounts: new Ext.data.ArrayStore({ accounts: new Ext.data.ArrayStore({
storeId: 'accountStore', storeId: 'accountStore',
id: 0, id: 0,
fields: [{ fields: [
name: 'displayText', {
type: 'string' name: 'displayText',
}] type: 'string',
},
],
}), }),
labels: new Ext.data.ArrayStore({ labels: new Ext.data.ArrayStore({
storeId: 'labelStore', storeId: 'labelStore',
id: 0, id: 0,
fields: [{ fields: [
name: 'displayText', {
type: 'string' name: 'displayText',
}] type: 'string',
},
],
}), }),
initComponent: function() { initComponent: function() {
@ -57,14 +71,13 @@ Deluge.ux.AutoAdd.AutoAddWindowBase = Ext.extend(Ext.Window, {
xtype: 'form', xtype: 'form',
baseCls: 'x-plain', baseCls: 'x-plain',
bodyStyle: 'padding: 5px', bodyStyle: 'padding: 5px',
items: [{ items: [
xtype: 'tabpanel', {
activeTab: 0, xtype: 'tabpanel',
items: [ activeTab: 0,
this.MainTab, items: [this.MainTab, this.OptionsTab],
this.OptionsTab },
] ],
}]
}); });
}, },
@ -72,13 +85,17 @@ Deluge.ux.AutoAdd.AutoAddWindowBase = Ext.extend(Ext.Window, {
this.hide(); this.hide();
}, },
getOptions: function () { getOptions: function() {
var options = {}; var options = {};
options['enabled'] = Ext.getCmp('enabled').getValue(); options['enabled'] = Ext.getCmp('enabled').getValue();
options['path'] = Ext.getCmp('path').getValue(); options['path'] = Ext.getCmp('path').getValue();
options['download_location'] = Ext.getCmp('download_location').getValue(); options['download_location'] = Ext.getCmp(
options['move_completed_path'] = Ext.getCmp('move_completed_path').getValue(); 'download_location'
).getValue();
options['move_completed_path'] = Ext.getCmp(
'move_completed_path'
).getValue();
options['copy_torrent'] = Ext.getCmp('copy_torrent').getValue(); options['copy_torrent'] = Ext.getCmp('copy_torrent').getValue();
options['label'] = Ext.getCmp('label').getValue(); options['label'] = Ext.getCmp('label').getValue();
@ -89,27 +106,38 @@ Deluge.ux.AutoAdd.AutoAddWindowBase = Ext.extend(Ext.Window, {
options[toggle_id] = Ext.getCmp(toggle_id).getValue(); options[toggle_id] = Ext.getCmp(toggle_id).getValue();
}); });
this.spin_ids.forEach(function(spin_id) { this.spin_ids.forEach(function(spin_id) {
options[spin_id] = Ext.getCmp(spin_id).getValue(); options[spin_id] = Ext.getCmp(spin_id).getValue();
options[spin_id + '_toggle'] = Ext.getCmp(spin_id + '_toggle').getValue(); options[spin_id + '_toggle'] = Ext.getCmp(
spin_id + '_toggle'
).getValue();
}); });
this.spin_int_ids.forEach(function(spin_int_id) { this.spin_int_ids.forEach(function(spin_int_id) {
options[spin_int_id] = Ext.getCmp(spin_int_id).getValue(); options[spin_int_id] = Ext.getCmp(spin_int_id).getValue();
options[spin_int_id + '_toggle'] = Ext.getCmp(spin_int_id + '_toggle').getValue(); options[spin_int_id + '_toggle'] = Ext.getCmp(
spin_int_id + '_toggle'
).getValue();
}); });
this.chk_ids.forEach(function(chk_id) { this.chk_ids.forEach(function(chk_id) {
options[chk_id] = Ext.getCmp(chk_id).getValue(); options[chk_id] = Ext.getCmp(chk_id).getValue();
options[chk_id + '_toggle'] = Ext.getCmp(chk_id + '_toggle').getValue(); options[chk_id + '_toggle'] = Ext.getCmp(
chk_id + '_toggle'
).getValue();
}); });
if (options['copy_torrent_toggle'] && options['path'] === options['copy_torrent']) { if (
throw _('"Watch Folder" directory and "Copy of .torrent' + options['copy_torrent_toggle'] &&
' files to" directory cannot be the same!'); options['path'] === options['copy_torrent']
) {
throw _(
'"Watch Folder" directory and "Copy of .torrent' +
' files to" directory cannot be the same!'
);
} }
return options; return options;
}, },
loadOptions: function (options) { loadOptions: function(options) {
/* /*
* Populate all available options data to the UI * Populate all available options data to the UI
*/ */
@ -123,22 +151,33 @@ Deluge.ux.AutoAdd.AutoAddWindowBase = Ext.extend(Ext.Window, {
); );
Ext.getCmp('isnt_append_extension').setValue(true); Ext.getCmp('isnt_append_extension').setValue(true);
Ext.getCmp('append_extension_toggle').setValue( Ext.getCmp('append_extension_toggle').setValue(
options['append_extension_toggle'] !== undefined ? options['append_extension_toggle'] : false options['append_extension_toggle'] !== undefined
? options['append_extension_toggle']
: false
); );
Ext.getCmp('append_extension').setValue( Ext.getCmp('append_extension').setValue(
options['append_extension'] !== undefined ? options['append_extension'] : '.added' options['append_extension'] !== undefined
? options['append_extension']
: '.added'
); );
Ext.getCmp('download_location_toggle').setValue( Ext.getCmp('download_location_toggle').setValue(
options['download_location_toggle'] !== undefined ? options['download_location_toggle'] : false options['download_location_toggle'] !== undefined
? options['download_location_toggle']
: false
); );
Ext.getCmp('copy_torrent_toggle').setValue( Ext.getCmp('copy_torrent_toggle').setValue(
options['copy_torrent_toggle'] !== undefined ? options['copy_torrent_toggle'] : false options['copy_torrent_toggle'] !== undefined
? options['copy_torrent_toggle']
: false
); );
Ext.getCmp('delete_copy_torrent_toggle').setValue( Ext.getCmp('delete_copy_torrent_toggle').setValue(
options['delete_copy_torrent_toggle'] !== undefined ? options['delete_copy_torrent_toggle'] : false options['delete_copy_torrent_toggle'] !== undefined
? options['delete_copy_torrent_toggle']
: false
); );
value = options['seed_mode'] !== undefined ? options['seed_mode'] : false; value =
options['seed_mode'] !== undefined ? options['seed_mode'] : false;
Ext.getCmp('seed_mode').setValue(value); Ext.getCmp('seed_mode').setValue(value);
this.accounts.removeAll(true); this.accounts.removeAll(true);
@ -149,7 +188,9 @@ Deluge.ux.AutoAdd.AutoAddWindowBase = Ext.extend(Ext.Window, {
options['label'] !== undefined ? options['label'] : '' options['label'] !== undefined ? options['label'] : ''
); );
Ext.getCmp('label_toggle').setValue( Ext.getCmp('label_toggle').setValue(
options['label_toggle'] !== undefined ? options['label_toggle'] : false options['label_toggle'] !== undefined
? options['label_toggle']
: false
); );
this.spin_ids.forEach(function(spin_id) { this.spin_ids.forEach(function(spin_id) {
@ -157,7 +198,9 @@ Deluge.ux.AutoAdd.AutoAddWindowBase = Ext.extend(Ext.Window, {
options[spin_id] !== undefined ? options[spin_id] : 0 options[spin_id] !== undefined ? options[spin_id] : 0
); );
Ext.getCmp(spin_id + '_toggle').setValue( Ext.getCmp(spin_id + '_toggle').setValue(
options[spin_id + '_toggle'] !== undefined ? options[spin_id + '_toggle'] : false options[spin_id + '_toggle'] !== undefined
? options[spin_id + '_toggle']
: false
); );
}); });
this.chk_ids.forEach(function(chk_id) { this.chk_ids.forEach(function(chk_id) {
@ -165,23 +208,36 @@ Deluge.ux.AutoAdd.AutoAddWindowBase = Ext.extend(Ext.Window, {
options[chk_id] !== undefined ? options[chk_id] : true options[chk_id] !== undefined ? options[chk_id] : true
); );
Ext.getCmp(chk_id + '_toggle').setValue( Ext.getCmp(chk_id + '_toggle').setValue(
options[chk_id + '_toggle'] !== undefined ? options[chk_id + '_toggle'] : false options[chk_id + '_toggle'] !== undefined
? options[chk_id + '_toggle']
: false
); );
}); });
value = options['add_paused'] !== undefined ? options['add_paused'] : true; value =
options['add_paused'] !== undefined ? options['add_paused'] : true;
if (!value) { if (!value) {
Ext.getCmp('not_add_paused').setValue(true); Ext.getCmp('not_add_paused').setValue(true);
} }
value = options['queue_to_top'] !== undefined ? options['queue_to_top'] : true; value =
options['queue_to_top'] !== undefined
? options['queue_to_top']
: true;
if (!value) { if (!value) {
Ext.getCmp('not_queue_to_top').setValue(true); Ext.getCmp('not_queue_to_top').setValue(true);
} }
value = options['auto_managed'] !== undefined ? options['auto_managed'] : true; value =
options['auto_managed'] !== undefined
? options['auto_managed']
: true;
if (!value) { if (!value) {
Ext.getCmp('not_auto_managed').setValue(true) Ext.getCmp('not_auto_managed').setValue(true);
} }
['move_completed_path', 'path', 'download_location', [
'copy_torrent'].forEach(function(field) { 'move_completed_path',
'path',
'download_location',
'copy_torrent',
].forEach(function(field) {
value = options[field] !== undefined ? options[field] : ''; value = options[field] !== undefined ? options[field] : '';
Ext.getCmp(field).setValue(value); Ext.getCmp(field).setValue(value);
}); });
@ -191,53 +247,60 @@ Deluge.ux.AutoAdd.AutoAddWindowBase = Ext.extend(Ext.Window, {
success: function(config) { success: function(config) {
var value; var value;
Ext.getCmp('download_location').setValue( Ext.getCmp('download_location').setValue(
options['download_location'] !== undefined ? options['download_location'] !== undefined
options['download_location'] : ? options['download_location']
config['download_location'] : config['download_location']
); );
value = options['move_completed_toggle'] !== undefined ? value =
options['move_completed_toggle'] : options['move_completed_toggle'] !== undefined
config['move_completed']; ? options['move_completed_toggle']
: config['move_completed'];
if (value) { if (value) {
Ext.getCmp('move_completed_toggle').setValue( Ext.getCmp('move_completed_toggle').setValue(
options['move_completed_toggle'] !== undefined ? options['move_completed_toggle'] !== undefined
options['move_completed_toggle'] : ? options['move_completed_toggle']
false : false
); );
Ext.getCmp('move_completed_path').setValue( Ext.getCmp('move_completed_path').setValue(
options['move_completed_path'] !== undefined ? options['move_completed_path'] !== undefined
options['move_completed_path'] : ? options['move_completed_path']
config['move_completed_path'] : config['move_completed_path']
); );
} }
value = options['copy_torrent_toggle'] !== undefined ? value =
options['copy_torrent_toggle'] : options['copy_torrent_toggle'] !== undefined
config['copy_torrent_file']; ? options['copy_torrent_toggle']
: config['copy_torrent_file'];
if (value) { if (value) {
Ext.getCmp('copy_torrent_toggle').setValue(true); Ext.getCmp('copy_torrent_toggle').setValue(true);
Ext.getCmp('copy_torrent').setValue( Ext.getCmp('copy_torrent').setValue(
options['copy_torrent'] !== undefined ? options['copy_torrent'] !== undefined
options['copy_torrent'] : ? options['copy_torrent']
config['torrentfiles_location'] : config['torrentfiles_location']
); );
} }
value = options['delete_copy_torrent_toggle'] !== undefined ? value =
options['copy_torrent_toggle'] : options['delete_copy_torrent_toggle'] !== undefined
config['del_copy_torrent_file']; ? options['copy_torrent_toggle']
: config['del_copy_torrent_file'];
if (value) { if (value) {
Ext.getCmp('delete_copy_torrent_toggle').setValue(true) Ext.getCmp('delete_copy_torrent_toggle').setValue(true);
} }
} },
}) });
} }
deluge.client.core.get_enabled_plugins({ deluge.client.core.get_enabled_plugins({
success: function (plugins) { success: function(plugins) {
if (plugins !== undefined && plugins.indexOf('Label') > -1) { if (plugins !== undefined && plugins.indexOf('Label') > -1) {
this.MainTab.LabelFset.setVisible(true); this.MainTab.LabelFset.setVisible(true);
deluge.client.label.get_labels({ deluge.client.label.get_labels({
success: function(labels) { success: function(labels) {
for (var index = 0; index < labels.length; index++) { for (
var index = 0;
index < labels.length;
index++
) {
labels[index] = [labels[index]]; labels[index] = [labels[index]];
} }
this.labels.loadData(labels, false); this.labels.loadData(labels, false);
@ -245,14 +308,13 @@ Deluge.ux.AutoAdd.AutoAddWindowBase = Ext.extend(Ext.Window, {
failure: function(failure) { failure: function(failure) {
console.error(failure); console.error(failure);
}, },
scope: this scope: this,
}); });
} } else {
else {
this.MainTab.LabelFset.setVisible(false); this.MainTab.LabelFset.setVisible(false);
} }
}, },
scope: this scope: this,
}); });
var me = this; var me = this;
@ -262,137 +324,152 @@ Deluge.ux.AutoAdd.AutoAddWindowBase = Ext.extend(Ext.Window, {
accounts[index] = [accounts[index]['username']]; accounts[index] = [accounts[index]['username']];
} }
me.accounts.loadData(accounts, false); me.accounts.loadData(accounts, false);
Ext.getCmp('owner').setValue(owner).enable(); Ext.getCmp('owner')
.setValue(owner)
.enable();
} }
function on_accounts_failure(failure){ function on_accounts_failure(failure) {
deluge.client.autoadd.get_auth_user({ deluge.client.autoadd.get_auth_user({
success: function (user) { success: function(user) {
me.accounts.loadData([[user]], false); me.accounts.loadData([[user]], false);
Ext.getCmp('owner').setValue(user).disable(true); Ext.getCmp('owner')
.setValue(user)
.disable(true);
}, },
scope: this scope: this,
}); });
} }
deluge.client.autoadd.is_admin_level({ deluge.client.autoadd.is_admin_level({
success: function (is_admin) { success: function(is_admin) {
if (is_admin) { if (is_admin) {
deluge.client.core.get_known_accounts({ deluge.client.core.get_known_accounts({
success: function (accounts) { success: function(accounts) {
deluge.client.autoadd.get_auth_user({ deluge.client.autoadd.get_auth_user({
success: function(user) { success: function(user) {
on_accounts(accounts, on_accounts(
options['owner'] !== undefined ? options['owner'] : user accounts,
options['owner'] !== undefined
? options['owner']
: user
); );
}, },
scope: this scope: this,
}); });
}, },
failure: on_accounts_failure, failure: on_accounts_failure,
scope: this scope: this,
}) });
} } else {
else {
on_accounts_failure(null); on_accounts_failure(null);
} }
}, },
scope: this scope: this,
}); });
} },
}); });
/** /**
* @class Deluge.ux.AutoAdd.EditAutoAddCommandWindow * @class Deluge.ux.AutoAdd.EditAutoAddCommandWindow
* @extends Deluge.ux.AutoAdd.AutoAddWindowBase * @extends Deluge.ux.AutoAdd.AutoAddWindowBase
*/ */
Deluge.ux.AutoAdd.EditAutoAddCommandWindow = Ext.extend(Deluge.ux.AutoAdd.AutoAddWindowBase, { Deluge.ux.AutoAdd.EditAutoAddCommandWindow = Ext.extend(
Deluge.ux.AutoAdd.AutoAddWindowBase,
{
title: _('Edit Watch Folder'),
title: _('Edit Watch Folder'), initComponent: function() {
Deluge.ux.AutoAdd.EditAutoAddCommandWindow.superclass.initComponent.call(
initComponent: function() { this
Deluge.ux.AutoAdd.EditAutoAddCommandWindow.superclass.initComponent.call(this); );
this.addButton(_('Save'), this.onSaveClick, this); this.addButton(_('Save'), this.onSaveClick, this);
this.addEvents({ this.addEvents({
'watchdiredit': true watchdiredit: true,
});
},
show: function(watchdir_id, options) {
Deluge.ux.AutoAdd.EditAutoAddCommandWindow.superclass.show.call(this);
this.watchdir_id = watchdir_id;
this.loadOptions(options);
},
onSaveClick: function() {
try {
var options = this.getOptions();
deluge.client.autoadd.set_options(this.watchdir_id, options, {
success: function() {
this.fireEvent('watchdiredit', this, options);
},
scope: this
}); });
} },
catch(err) {
Ext.Msg.show({
title: _('Incompatible Option'),
msg: err,
buttons: Ext.Msg.OK,
scope: this
});
}
this.hide(); show: function(watchdir_id, options) {
Deluge.ux.AutoAdd.EditAutoAddCommandWindow.superclass.show.call(
this
);
this.watchdir_id = watchdir_id;
this.loadOptions(options);
},
onSaveClick: function() {
try {
var options = this.getOptions();
deluge.client.autoadd.set_options(this.watchdir_id, options, {
success: function() {
this.fireEvent('watchdiredit', this, options);
},
scope: this,
});
} catch (err) {
Ext.Msg.show({
title: _('Incompatible Option'),
msg: err,
buttons: Ext.Msg.OK,
scope: this,
});
}
this.hide();
},
} }
);
});
/** /**
* @class Deluge.ux.AutoAdd.AddAutoAddCommandWindow * @class Deluge.ux.AutoAdd.AddAutoAddCommandWindow
* @extends Deluge.ux.AutoAdd.AutoAddWindowBase * @extends Deluge.ux.AutoAdd.AutoAddWindowBase
*/ */
Deluge.ux.AutoAdd.AddAutoAddCommandWindow = Ext.extend(Deluge.ux.AutoAdd.AutoAddWindowBase, { Deluge.ux.AutoAdd.AddAutoAddCommandWindow = Ext.extend(
Deluge.ux.AutoAdd.AutoAddWindowBase,
{
title: _('Add Watch Folder'),
title: _('Add Watch Folder'), initComponent: function() {
Deluge.ux.AutoAdd.AddAutoAddCommandWindow.superclass.initComponent.call(
this
);
this.addButton(_('Add'), this.onAddClick, this);
this.addEvents({
watchdiradd: true,
});
},
initComponent: function() { show: function() {
Deluge.ux.AutoAdd.AddAutoAddCommandWindow.superclass.initComponent.call(this); Deluge.ux.AutoAdd.AddAutoAddCommandWindow.superclass.show.call(
this.addButton(_('Add'), this.onAddClick, this); this
this.addEvents({ );
'watchdiradd': true this.loadOptions();
}); },
},
show: function() { onAddClick: function() {
Deluge.ux.AutoAdd.AddAutoAddCommandWindow.superclass.show.call(this); var options = this.getOptions();
this.loadOptions(); deluge.client.autoadd.add(options, {
}, success: function() {
this.fireEvent('watchdiradd', this, options);
onAddClick: function() { this.hide();
var options = this.getOptions(); },
deluge.client.autoadd.add(options, { failure: function(err) {
success: function() { const regex = /: (.*\n)\n?\]/m;
this.fireEvent('watchdiradd', this, options); var error;
this.hide(); if ((error = regex.exec(err.error.message)) !== null) {
}, error = error[1];
failure: function(err) { } else {
const regex = /: (.*\n)\n?\]/m; error = err.error.message;
var error; }
if ((error = regex.exec(err.error.message)) !== null) { Ext.Msg.show({
error = error[1]; title: _('Incompatible Option'),
} msg: error,
else { buttons: Ext.Msg.OK,
error = err.error.message; scope: this,
} });
Ext.Msg.show({ },
title: _('Incompatible Option'), scope: this,
msg: error, });
buttons: Ext.Msg.OK, },
scope: this
});
},
scope: this
});
} }
}); );

View File

@ -29,18 +29,21 @@ Deluge.ux.AutoAdd.AutoAddMainPanel = Ext.extend(Ext.Panel, {
style: 'margin-top: 3px; margin-bottom: 0px; padding-bottom: 0px;', style: 'margin-top: 3px; margin-bottom: 0px; padding-bottom: 0px;',
width: '85%', width: '85%',
labelWidth: 1, labelWidth: 1,
items: [{ items: [
xtype: 'textfield', {
id: 'path', xtype: 'textfield',
hideLabel: true, id: 'path',
width: 304 hideLabel: true,
}, { width: 304,
hideLabel: true, },
id: 'enabled', {
xtype: 'checkbox', hideLabel: true,
boxLabel: _('Enable this watch folder'), id: 'enabled',
checked: true xtype: 'checkbox',
}] boxLabel: _('Enable this watch folder'),
checked: true,
},
],
}); });
this.torrentActionFset = new Ext.form.FieldSet({ this.torrentActionFset = new Ext.form.FieldSet({
@ -51,93 +54,136 @@ Deluge.ux.AutoAdd.AutoAddMainPanel = Ext.extend(Ext.Panel, {
width: '85%', width: '85%',
labelWidth: 1, labelWidth: 1,
defaults: { defaults: {
style: 'margin-bottom: 2px' style: 'margin-bottom: 2px',
}, },
items: [{ items: [
xtype: 'radiogroup', {
columns: 1, xtype: 'radiogroup',
items: [{ columns: 1,
xtype: 'radio', items: [
name: 'torrent_action', {
id: 'isnt_append_extension',
boxLabel: _('Delete .torrent after adding'),
checked: true,
hideLabel: true,
listeners: {
check: function (cb, newValue) {
if (newValue) {
Ext.getCmp('append_extension').setDisabled(newValue);
Ext.getCmp('copy_torrent').setDisabled(newValue);
Ext.getCmp('delete_copy_torrent_toggle').setDisabled(newValue);
}
}
}
}, {
xtype: 'container',
layout: 'hbox',
hideLabel: true,
items: [{
xtype: 'radio',
name: 'torrent_action',
id: 'append_extension_toggle',
boxLabel: _('Append extension after adding:'),
hideLabel: true,
listeners: {
check: function (cb, newValue) {
if (newValue) {
Ext.getCmp('append_extension').setDisabled(!newValue);
Ext.getCmp('copy_torrent').setDisabled(newValue);
Ext.getCmp('delete_copy_torrent_toggle').setDisabled(newValue);
}
}
}
}, {
xtype: 'textfield',
id: 'append_extension',
hideLabel: true,
disabled: true,
style: 'margin-left: 2px',
width: 112
}]
}, {
xtype: 'container',
hideLabel: true,
items: [{
xtype: 'container',
layout: 'hbox',
hideLabel: true,
items: [{
xtype: 'radio', xtype: 'radio',
name: 'torrent_action', name: 'torrent_action',
id: 'copy_torrent_toggle', id: 'isnt_append_extension',
boxLabel: _('Copy of .torrent files to:'), boxLabel: _('Delete .torrent after adding'),
checked: true,
hideLabel: true, hideLabel: true,
listeners: { listeners: {
check: function (cb, newValue) { check: function(cb, newValue) {
if (newValue) { if (newValue) {
Ext.getCmp('append_extension').setDisabled(newValue); Ext.getCmp(
Ext.getCmp('copy_torrent').setDisabled(!newValue); 'append_extension'
Ext.getCmp('delete_copy_torrent_toggle').setDisabled(!newValue); ).setDisabled(newValue);
Ext.getCmp('copy_torrent').setDisabled(
newValue
);
Ext.getCmp(
'delete_copy_torrent_toggle'
).setDisabled(newValue);
} }
} },
} },
}, { },
xtype: 'textfield', {
id: 'copy_torrent', xtype: 'container',
layout: 'hbox',
hideLabel: true, hideLabel: true,
disabled: true, items: [
style: 'margin-left: 2px', {
width: 152 xtype: 'radio',
}] name: 'torrent_action',
}, { id: 'append_extension_toggle',
xtype: 'checkbox', boxLabel: _(
id: 'delete_copy_torrent_toggle', 'Append extension after adding:'
boxLabel: _('Delete copy of torrent file on remove'), ),
style: 'margin-left: 10px', hideLabel: true,
disabled: true listeners: {
}] check: function(cb, newValue) {
}] if (newValue) {
}] Ext.getCmp(
'append_extension'
).setDisabled(!newValue);
Ext.getCmp(
'copy_torrent'
).setDisabled(newValue);
Ext.getCmp(
'delete_copy_torrent_toggle'
).setDisabled(newValue);
}
},
},
},
{
xtype: 'textfield',
id: 'append_extension',
hideLabel: true,
disabled: true,
style: 'margin-left: 2px',
width: 112,
},
],
},
{
xtype: 'container',
hideLabel: true,
items: [
{
xtype: 'container',
layout: 'hbox',
hideLabel: true,
items: [
{
xtype: 'radio',
name: 'torrent_action',
id: 'copy_torrent_toggle',
boxLabel: _(
'Copy of .torrent files to:'
),
hideLabel: true,
listeners: {
check: function(cb, newValue) {
if (newValue) {
Ext.getCmp(
'append_extension'
).setDisabled(newValue);
Ext.getCmp(
'copy_torrent'
).setDisabled(
!newValue
);
Ext.getCmp(
'delete_copy_torrent_toggle'
).setDisabled(
!newValue
);
}
},
},
},
{
xtype: 'textfield',
id: 'copy_torrent',
hideLabel: true,
disabled: true,
style: 'margin-left: 2px',
width: 152,
},
],
},
{
xtype: 'checkbox',
id: 'delete_copy_torrent_toggle',
boxLabel: _(
'Delete copy of torrent file on remove'
),
style: 'margin-left: 10px',
disabled: true,
},
],
},
],
},
],
}); });
this.downloadFolderFset = new Ext.form.FieldSet({ this.downloadFolderFset = new Ext.form.FieldSet({
@ -148,23 +194,28 @@ Deluge.ux.AutoAdd.AutoAddMainPanel = Ext.extend(Ext.Panel, {
style: 'margin-top: 3px; margin-bottom: 0px; padding-bottom: 0px;', style: 'margin-top: 3px; margin-bottom: 0px; padding-bottom: 0px;',
width: '85%', width: '85%',
labelWidth: 1, labelWidth: 1,
items: [{ items: [
hideLabel: true, {
id: 'download_location_toggle', hideLabel: true,
xtype: 'checkbox', id: 'download_location_toggle',
boxLabel: _('Set download folder'), xtype: 'checkbox',
listeners: { boxLabel: _('Set download folder'),
check: function (cb, checked) { listeners: {
Ext.getCmp('download_location').setDisabled(!checked); check: function(cb, checked) {
} Ext.getCmp('download_location').setDisabled(
} !checked
}, { );
xtype: 'textfield', },
id: 'download_location', },
hideLabel: true, },
width: 304, {
disabled: true xtype: 'textfield',
}] id: 'download_location',
hideLabel: true,
width: 304,
disabled: true,
},
],
}); });
this.moveCompletedFset = new Ext.form.FieldSet({ this.moveCompletedFset = new Ext.form.FieldSet({
@ -175,23 +226,28 @@ Deluge.ux.AutoAdd.AutoAddMainPanel = Ext.extend(Ext.Panel, {
style: 'margin-top: 3px; margin-bottom: 0px; padding-bottom: 0px;', style: 'margin-top: 3px; margin-bottom: 0px; padding-bottom: 0px;',
width: '85%', width: '85%',
labelWidth: 1, labelWidth: 1,
items: [{ items: [
hideLabel: true, {
id: 'move_completed_toggle', hideLabel: true,
xtype: 'checkbox', id: 'move_completed_toggle',
boxLabel: _('Set move completed folder'), xtype: 'checkbox',
listeners: { boxLabel: _('Set move completed folder'),
check: function (cb, checked) { listeners: {
Ext.getCmp('move_completed_path').setDisabled(!checked); check: function(cb, checked) {
} Ext.getCmp('move_completed_path').setDisabled(
} !checked
}, { );
xtype: 'textfield', },
id: 'move_completed_path', },
hideLabel: true, },
width: 304, {
disabled: true xtype: 'textfield',
}] id: 'move_completed_path',
hideLabel: true,
width: 304,
disabled: true,
},
],
}); });
this.LabelFset = new Ext.form.FieldSet({ this.LabelFset = new Ext.form.FieldSet({
@ -203,33 +259,38 @@ Deluge.ux.AutoAdd.AutoAddMainPanel = Ext.extend(Ext.Panel, {
//width: '85%', //width: '85%',
labelWidth: 1, labelWidth: 1,
//hidden: true, //hidden: true,
items: [{ items: [
xtype: 'container', {
layout: 'hbox', xtype: 'container',
hideLabel: true, layout: 'hbox',
items: [{
hashLabel: false,
id: 'label_toggle',
xtype: 'checkbox',
boxLabel: _('Label:'),
listeners: {
check: function (cb, checked) {
Ext.getCmp('label').setDisabled(!checked);
}
}
}, {
xtype: 'combo',
id: 'label',
hideLabel: true, hideLabel: true,
//width: 220, items: [
width: 254, {
disabled: true, hashLabel: false,
style: 'margin-left: 2px', id: 'label_toggle',
mode: 'local', xtype: 'checkbox',
valueField: 'displayText', boxLabel: _('Label:'),
displayField: 'displayText' listeners: {
}] check: function(cb, checked) {
}] Ext.getCmp('label').setDisabled(!checked);
},
},
},
{
xtype: 'combo',
id: 'label',
hideLabel: true,
//width: 220,
width: 254,
disabled: true,
style: 'margin-left: 2px',
mode: 'local',
valueField: 'displayText',
displayField: 'displayText',
},
],
},
],
}); });
this.add([ this.add([
@ -237,7 +298,7 @@ Deluge.ux.AutoAdd.AutoAddMainPanel = Ext.extend(Ext.Panel, {
this.torrentActionFset, this.torrentActionFset,
this.downloadFolderFset, this.downloadFolderFset,
this.moveCompletedFset, this.moveCompletedFset,
this.LabelFset this.LabelFset,
]) ]);
} },
}); });

View File

@ -20,30 +20,32 @@ Deluge.ux.AutoAdd.AutoAddOptionsPanel = Ext.extend(Ext.Panel, {
title: _('Options'), title: _('Options'),
initComponent: function() { initComponent: function() {
Deluge.ux.AutoAdd.AutoAddOptionsPanel.superclass.initComponent.call(this); Deluge.ux.AutoAdd.AutoAddOptionsPanel.superclass.initComponent.call(
this
);
var maxDownload = { var maxDownload = {
idCheckbox: 'max_download_speed_toggle', idCheckbox: 'max_download_speed_toggle',
labelCheckbox: 'Max Download Speed (KiB/s):', labelCheckbox: 'Max Download Speed (KiB/s):',
idSpinner: 'max_download_speed', idSpinner: 'max_download_speed',
decimalPrecision: 1 decimalPrecision: 1,
}; };
var maxUploadSpeed = { var maxUploadSpeed = {
idCheckbox: 'max_upload_speed_toggle', idCheckbox: 'max_upload_speed_toggle',
labelCheckbox: 'Max upload Speed (KiB/s):', labelCheckbox: 'Max upload Speed (KiB/s):',
idSpinner: 'max_upload_speed', idSpinner: 'max_upload_speed',
decimalPrecision: 1 decimalPrecision: 1,
}; };
var maxConnections = { var maxConnections = {
idCheckbox: 'max_connections_toggle', idCheckbox: 'max_connections_toggle',
labelCheckbox: 'Max Connections::', labelCheckbox: 'Max Connections::',
idSpinner: 'max_connections', idSpinner: 'max_connections',
decimalPrecision: 0 decimalPrecision: 0,
}; };
var maxUploadSlots = { var maxUploadSlots = {
idCheckbox: 'max_upload_slots_toggle', idCheckbox: 'max_upload_slots_toggle',
labelCheckbox: 'Max Upload Slots:', labelCheckbox: 'Max Upload Slots:',
idSpinner: 'max_upload_slots', idSpinner: 'max_upload_slots',
decimalPrecision: 0 decimalPrecision: 0,
}; };
// queue data // queue data
var addPause = { var addPause = {
@ -52,8 +54,8 @@ Deluge.ux.AutoAdd.AutoAddOptionsPanel = Ext.extend(Ext.Panel, {
nameRadio: 'add_paused', nameRadio: 'add_paused',
labelRadio: { labelRadio: {
yes: 'Yes', yes: 'Yes',
no: 'No' no: 'No',
} },
}; };
var queueTo = { var queueTo = {
idCheckbox: 'queue_to_top_toggle', idCheckbox: 'queue_to_top_toggle',
@ -61,8 +63,8 @@ Deluge.ux.AutoAdd.AutoAddOptionsPanel = Ext.extend(Ext.Panel, {
nameRadio: 'queue_to_top', nameRadio: 'queue_to_top',
labelRadio: { labelRadio: {
yes: 'Top', yes: 'Top',
no: 'Bottom' no: 'Bottom',
} },
}; };
var autoManaged = { var autoManaged = {
idCheckbox: 'auto_managed_toggle', idCheckbox: 'auto_managed_toggle',
@ -70,8 +72,8 @@ Deluge.ux.AutoAdd.AutoAddOptionsPanel = Ext.extend(Ext.Panel, {
nameRadio: 'auto_managed', nameRadio: 'auto_managed',
labelRadio: { labelRadio: {
yes: 'Yes', yes: 'Yes',
no: 'No' no: 'No',
} },
}; };
this.ownerFset = new Ext.form.FieldSet({ this.ownerFset = new Ext.form.FieldSet({
@ -81,15 +83,17 @@ Deluge.ux.AutoAdd.AutoAddOptionsPanel = Ext.extend(Ext.Panel, {
style: 'margin-top: 3px; margin-bottom: 0px; padding-bottom: 0px;', style: 'margin-top: 3px; margin-bottom: 0px; padding-bottom: 0px;',
//width: '85%', //width: '85%',
labelWidth: 1, labelWidth: 1,
items: [{ items: [
xtype: 'combo', {
id: 'owner', xtype: 'combo',
hideLabel: true, id: 'owner',
width: 312, hideLabel: true,
mode: 'local', width: 312,
valueField: 'displayText', mode: 'local',
displayField: 'displayText' valueField: 'displayText',
}] displayField: 'displayText',
},
],
}); });
this.bandwidthFset = new Ext.form.FieldSet({ this.bandwidthFset = new Ext.form.FieldSet({
@ -100,8 +104,8 @@ Deluge.ux.AutoAdd.AutoAddOptionsPanel = Ext.extend(Ext.Panel, {
//width: '85%', //width: '85%',
labelWidth: 1, labelWidth: 1,
defaults: { defaults: {
style: 'margin-bottom: 5px' style: 'margin-bottom: 5px',
} },
}); });
this.bandwidthFset.add(this._getBandwidthContainer(maxDownload)); this.bandwidthFset.add(this._getBandwidthContainer(maxDownload));
this.bandwidthFset.add(this._getBandwidthContainer(maxUploadSpeed)); this.bandwidthFset.add(this._getBandwidthContainer(maxUploadSpeed));
@ -116,13 +120,15 @@ Deluge.ux.AutoAdd.AutoAddOptionsPanel = Ext.extend(Ext.Panel, {
//width: '85%', //width: '85%',
labelWidth: 1, labelWidth: 1,
defaults: { defaults: {
style: 'margin-bottom: 5px' style: 'margin-bottom: 5px',
}, },
items: [{ items: [
xtype: 'container', {
layout: 'hbox', xtype: 'container',
hideLabel: true layout: 'hbox',
}] hideLabel: true,
},
],
}); });
this.queueFset.add(this._getQueueContainer(addPause)); this.queueFset.add(this._getQueueContainer(addPause));
this.queueFset.add(this._getQueueContainer(queueTo)); this.queueFset.add(this._getQueueContainer(queueTo));
@ -130,80 +136,91 @@ Deluge.ux.AutoAdd.AutoAddOptionsPanel = Ext.extend(Ext.Panel, {
this.queueFset.add({ this.queueFset.add({
xtype: 'container', xtype: 'container',
hideLabel: true, hideLabel: true,
items: [{ items: [
xtype: 'container', {
layout: 'hbox', xtype: 'container',
hideLabel: true, layout: 'hbox',
items: [{
xtype: 'checkbox',
id: 'stop_at_ratio_toggle',
boxLabel: _('Stop seed at ratio:'),
hideLabel: true, hideLabel: true,
width: 175, items: [
listeners: { {
check: function(cb, checked) { xtype: 'checkbox',
Ext.getCmp('stop_ratio').setDisabled(!checked); id: 'stop_at_ratio_toggle',
Ext.getCmp('remove_at_ratio').setDisabled(!checked); boxLabel: _('Stop seed at ratio:'),
} hideLabel: true,
} width: 175,
}, { listeners: {
xtype: 'spinnerfield', check: function(cb, checked) {
id: 'stop_ratio', Ext.getCmp('stop_ratio').setDisabled(
!checked
);
Ext.getCmp('remove_at_ratio').setDisabled(
!checked
);
},
},
},
{
xtype: 'spinnerfield',
id: 'stop_ratio',
hideLabel: true,
disabled: true,
value: 0.0,
minValue: 0.0,
maxValue: 100.0,
decimalPrecision: 1,
incrementValue: 0.1,
style: 'margin-left: 2px',
width: 100,
},
],
},
{
xtype: 'container',
layout: 'hbox',
hideLabel: true, hideLabel: true,
disabled: true, style: 'margin-left: 10px',
value: 0.0, items: [
minValue: 0.0, {
maxValue: 100.0, xtype: 'checkbox',
decimalPrecision: 1, id: 'remove_at_ratio',
incrementValue: 0.1, boxLabel: _('Remove at ratio'),
style: 'margin-left: 2px', disabled: true,
width: 100 checked: true,
}] },
}, { {
xtype: 'container', xtype: 'checkbox',
layout: 'hbox', id: 'remove_at_ratio_toggle',
hideLabel: true, disabled: true,
style: 'margin-left: 10px', checked: true,
items: [{ hidden: true,
xtype: 'checkbox', },
id: 'remove_at_ratio', {
boxLabel: _('Remove at ratio'), xtype: 'checkbox',
disabled: true, id: 'stop_ratio_toggle',
checked: true disabled: true,
}, { checked: true,
xtype: 'checkbox', hidden: true,
id: 'remove_at_ratio_toggle', },
disabled: true, {
checked: true, xtype: 'checkbox',
hidden: true id: 'stop_ratio_toggle',
}, { disabled: true,
xtype: 'checkbox', checked: true,
id: 'stop_ratio_toggle', hidden: true,
disabled: true, },
checked: true, ],
hidden: true },
}, { ],
xtype: 'checkbox',
id: 'stop_ratio_toggle',
disabled: true,
checked: true,
hidden: true
}]
}]
}); });
this.queueFset.add({ this.queueFset.add({
xtype: 'checkbox', xtype: 'checkbox',
id: 'seed_mode', id: 'seed_mode',
boxLabel: _('Skip File Hash Check'), boxLabel: _('Skip File Hash Check'),
hideLabel: true, hideLabel: true,
width: 175 width: 175,
}); });
this.add([ this.add([this.ownerFset, this.bandwidthFset, this.queueFset]);
this.ownerFset,
this.bandwidthFset,
this.queueFset
]);
}, },
_getBandwidthContainer: function(values) { _getBandwidthContainer: function(values) {
@ -211,66 +228,75 @@ Deluge.ux.AutoAdd.AutoAddOptionsPanel = Ext.extend(Ext.Panel, {
xtype: 'container', xtype: 'container',
layout: 'hbox', layout: 'hbox',
hideLabel: true, hideLabel: true,
items: [{ items: [
xtype: 'checkbox', {
hideLabel: true, xtype: 'checkbox',
id: values.idCheckbox, hideLabel: true,
boxLabel: _(values.labelCheckbox), id: values.idCheckbox,
width: 175, boxLabel: _(values.labelCheckbox),
listeners: { width: 175,
check: function(cb, checked) { listeners: {
Ext.getCmp(values.idSpinner).setDisabled(!checked); check: function(cb, checked) {
} Ext.getCmp(values.idSpinner).setDisabled(!checked);
} },
}, { },
xtype: 'spinnerfield', },
id: values.idSpinner, {
hideLabel: true, xtype: 'spinnerfield',
disabled: true, id: values.idSpinner,
minValue: -1, hideLabel: true,
maxValue: 10000, disabled: true,
value: 0.0, minValue: -1,
decimalPrecision: values.decimalPrecision, maxValue: 10000,
style: 'margin-left: 2px', value: 0.0,
width: 100 decimalPrecision: values.decimalPrecision,
}] style: 'margin-left: 2px',
width: 100,
},
],
}); });
}, },
_getQueueContainer: function (values) { _getQueueContainer: function(values) {
return new Ext.Container({ return new Ext.Container({
xtype: 'container', xtype: 'container',
layout: 'hbox', layout: 'hbox',
hideLabel: true, hideLabel: true,
items: [{ items: [
xtype: 'checkbox', {
hideLabel: true, xtype: 'checkbox',
id: values.idCheckbox, hideLabel: true,
boxLabel: _(values.labelCheckbox), id: values.idCheckbox,
width: 175, boxLabel: _(values.labelCheckbox),
listeners: { width: 175,
check: function(cb, checked) { listeners: {
Ext.getCmp(values.nameRadio).setDisabled(!checked); check: function(cb, checked) {
Ext.getCmp('not_' + values.nameRadio).setDisabled(!checked); Ext.getCmp(values.nameRadio).setDisabled(!checked);
} Ext.getCmp('not_' + values.nameRadio).setDisabled(
} !checked
}, { );
xtype: 'radio', },
name: values.nameRadio, },
id: values.nameRadio, },
boxLabel: _(values.labelRadio.yes), {
hideLabel: true, xtype: 'radio',
checked: true, name: values.nameRadio,
disabled: true, id: values.nameRadio,
width: 50 boxLabel: _(values.labelRadio.yes),
}, { hideLabel: true,
xtype: 'radio', checked: true,
name: values.nameRadio, disabled: true,
id: 'not_' + values.nameRadio, width: 50,
boxLabel: _(values.labelRadio.no), },
hideLabel: true, {
disabled: true xtype: 'radio',
}] name: values.nameRadio,
id: 'not_' + values.nameRadio,
boxLabel: _(values.labelRadio.no),
hideLabel: true,
disabled: true,
},
],
}); });
} },
}); });

View File

@ -16,7 +16,6 @@ Ext.ns('Deluge.ux.preferences');
* @extends Ext.Panel * @extends Ext.Panel
*/ */
Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, { Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, {
title: _('Blocklist'), title: _('Blocklist'),
header: false, header: false,
layout: 'fit', layout: 'fit',
@ -34,14 +33,14 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, {
defaultType: 'textfield', defaultType: 'textfield',
style: 'margin-top: 3px; margin-bottom: 0px; padding-bottom: 0px;', style: 'margin-top: 3px; margin-bottom: 0px; padding-bottom: 0px;',
autoWidth: true, autoWidth: true,
labelWidth: 40 labelWidth: 40,
}); });
this.URL = this.URLFset.add({ this.URL = this.URLFset.add({
fieldLabel: _('URL:'), fieldLabel: _('URL:'),
labelSeparator: '', labelSeparator: '',
name: 'url', name: 'url',
width: '80%' width: '80%',
}); });
this.SettingsFset = this.add({ this.SettingsFset = this.add({
@ -52,7 +51,7 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, {
defaultType: 'spinnerfield', defaultType: 'spinnerfield',
style: 'margin-top: 3px; margin-bottom: 0px; padding-bottom: 0px;', style: 'margin-top: 3px; margin-bottom: 0px; padding-bottom: 0px;',
autoWidth: true, autoWidth: true,
labelWidth: 160 labelWidth: 160,
}); });
this.checkListDays = this.SettingsFset.add({ this.checkListDays = this.SettingsFset.add({
@ -61,13 +60,13 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, {
name: 'check_list_days', name: 'check_list_days',
value: 4, value: 4,
decimalPrecision: 0, decimalPrecision: 0,
width: 80 width: 80,
}); });
this.chkImportOnStart = this.SettingsFset.add({ this.chkImportOnStart = this.SettingsFset.add({
xtype: 'checkbox', xtype: 'checkbox',
fieldLabel: _('Import blocklist on startup'), fieldLabel: _('Import blocklist on startup'),
name: 'check_import_startup' name: 'check_import_startup',
}); });
this.OptionsFset = this.add({ this.OptionsFset = this.add({
@ -79,7 +78,7 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, {
style: 'margin-top: 3px; margin-bottom: 0px; padding-bottom: 0px;', style: 'margin-top: 3px; margin-bottom: 0px; padding-bottom: 0px;',
autoWidth: false, autoWidth: false,
width: '80%', width: '80%',
labelWidth: 0 labelWidth: 0,
}); });
this.checkDownload = this.OptionsFset.add({ this.checkDownload = this.OptionsFset.add({
@ -88,18 +87,21 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, {
xtype: 'container', xtype: 'container',
layout: 'hbox', layout: 'hbox',
margins: '4 0 0 5', margins: '4 0 0 5',
items: [{ items: [
{
xtype: 'button', xtype: 'button',
text: ' Check Download and Import ', text: ' Check Download and Import ',
scale: 'medium' scale: 'medium',
}, { },
{
xtype: 'box', xtype: 'box',
autoEl: { autoEl: {
tag: 'img', tag: 'img',
src: '../icons/ok.png' src: '../icons/ok.png',
}, },
margins: '4 0 0 3' margins: '4 0 0 3',
}] },
],
}); });
this.forceDownload = this.OptionsFset.add({ this.forceDownload = this.OptionsFset.add({
@ -108,7 +110,7 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, {
text: ' Force Download and Import ', text: ' Force Download and Import ',
margins: '2 0 0 0', margins: '2 0 0 0',
//icon: '../icons/blocklist_import24.png', //icon: '../icons/blocklist_import24.png',
scale: 'medium' scale: 'medium',
}); });
this.ProgressFset = this.add({ this.ProgressFset = this.add({
@ -120,13 +122,13 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, {
style: 'margin-top: 1px; margin-bottom: 0px; padding-bottom: 0px;', style: 'margin-top: 1px; margin-bottom: 0px; padding-bottom: 0px;',
autoWidth: true, autoWidth: true,
labelWidth: 0, labelWidth: 0,
hidden: true hidden: true,
}); });
this.downProgBar = this.ProgressFset.add({ this.downProgBar = this.ProgressFset.add({
fieldLabel: _(''), fieldLabel: _(''),
name: 'progress_bar', name: 'progress_bar',
width: '90%' width: '90%',
}); });
this.InfoFset = this.add({ this.InfoFset = this.add({
@ -136,31 +138,31 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, {
autoHeight: true, autoHeight: true,
defaultType: 'label', defaultType: 'label',
style: 'margin-top: 0px; margin-bottom: 0px; padding-bottom: 0px;', style: 'margin-top: 0px; margin-bottom: 0px; padding-bottom: 0px;',
labelWidth: 60 labelWidth: 60,
}); });
this.lblFileSize = this.InfoFset.add({ this.lblFileSize = this.InfoFset.add({
fieldLabel: _('File Size:'), fieldLabel: _('File Size:'),
labelSeparator: '', labelSeparator: '',
name: 'file_size' name: 'file_size',
}); });
this.lblDate = this.InfoFset.add({ this.lblDate = this.InfoFset.add({
fieldLabel: _('Date:'), fieldLabel: _('Date:'),
labelSeparator: '', labelSeparator: '',
name: 'date' name: 'date',
}); });
this.lblType = this.InfoFset.add({ this.lblType = this.InfoFset.add({
fieldLabel: _('Type:'), fieldLabel: _('Type:'),
labelSeparator: '', labelSeparator: '',
name: 'type' name: 'type',
}); });
this.lblURL = this.InfoFset.add({ this.lblURL = this.InfoFset.add({
fieldLabel: _('URL:'), fieldLabel: _('URL:'),
labelSeparator: '', labelSeparator: '',
name: 'lbl_URL' name: 'lbl_URL',
}); });
this.WhitelistFset = this.add({ this.WhitelistFset = this.add({
@ -172,7 +174,8 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, {
style: 'margin-top: 3px; margin-bottom: 0px; padding-bottom: 0px;', style: 'margin-top: 3px; margin-bottom: 0px; padding-bottom: 0px;',
autoWidth: true, autoWidth: true,
labelWidth: 0, labelWidth: 0,
items: [{ items: [
{
fieldLabel: _(''), fieldLabel: _(''),
name: 'whitelist', name: 'whitelist',
margins: '2 0 5 5', margins: '2 0 5 5',
@ -181,10 +184,11 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, {
autoExpandColumn: 'ip', autoExpandColumn: 'ip',
viewConfig: { viewConfig: {
emptyText: _('Add an IP...'), emptyText: _('Add an IP...'),
deferEmptyText: false deferEmptyText: false,
}, },
colModel: new Ext.grid.ColumnModel({ colModel: new Ext.grid.ColumnModel({
columns: [{ columns: [
{
id: 'ip', id: 'ip',
header: _('IP'), header: _('IP'),
dataIndex: 'ip', dataIndex: 'ip',
@ -192,29 +196,30 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, {
hideable: false, hideable: false,
editable: true, editable: true,
editor: { editor: {
xtype: 'textfield' xtype: 'textfield',
} },
}] },
],
}), }),
selModel: new Ext.grid.RowSelectionModel({ selModel: new Ext.grid.RowSelectionModel({
singleSelect: false, singleSelect: false,
moveEditorOnEnter: false moveEditorOnEnter: false,
}), }),
store: new Ext.data.ArrayStore({ store: new Ext.data.ArrayStore({
autoDestroy: true, autoDestroy: true,
fields: [{name: 'ip'}] fields: [{ name: 'ip' }],
}), }),
listeners: { listeners: {
afteredit: function(e) { afteredit: function(e) {
e.record.commit(); e.record.commit();
} },
}, },
setEmptyText: function(text) { setEmptyText: function(text) {
if (this.viewReady) { if (this.viewReady) {
this.getView().emptyText = text; this.getView().emptyText = text;
this.getView().refresh(); this.getView().refresh();
} else { } else {
Ext.apply(this.viewConfig, {emptyText: text}); Ext.apply(this.viewConfig, { emptyText: text });
} }
}, },
loadData: function(data) { loadData: function(data) {
@ -222,28 +227,32 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, {
if (this.viewReady) { if (this.viewReady) {
this.getView().updateHeaders(); this.getView().updateHeaders();
} }
} },
}] },
],
}); });
this.ipButtonsContainer = this.WhitelistFset.add({ this.ipButtonsContainer = this.WhitelistFset.add({
xtype: 'container', xtype: 'container',
layout: 'hbox', layout: 'hbox',
margins: '4 0 0 5', margins: '4 0 0 5',
items: [{ items: [
{
xtype: 'button', xtype: 'button',
text: ' Add IP ', text: ' Add IP ',
margins: '0 5 0 0' margins: '0 5 0 0',
},{ },
{
xtype: 'button', xtype: 'button',
text: ' Delete IP ' text: ' Delete IP ',
}] },
],
}); });
this.updateTask = Ext.TaskMgr.start({ this.updateTask = Ext.TaskMgr.start({
interval: 2000, interval: 2000,
run: this.onUpdate, run: this.onUpdate,
scope: this scope: this,
}); });
this.on('show', this.updateConfig, this); this.on('show', this.updateConfig, this);
@ -290,8 +299,13 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, {
this.forceDownload.setDisabled(true); this.forceDownload.setDisabled(true);
this.ProgressFset.show(); this.ProgressFset.show();
this.downProgBar.updateProgress(status['file_progress'],'Downloading '.concat((status['file_progress'] * 100).toFixed(2)).concat('%'),true); this.downProgBar.updateProgress(
status['file_progress'],
'Downloading '
.concat((status['file_progress'] * 100).toFixed(2))
.concat('%'),
true
);
} else if (status['state'] == 'Importing') { } else if (status['state'] == 'Importing') {
this.InfoFset.hide(); this.InfoFset.hide();
this.checkDownload.getComponent(0).setDisabled(true); this.checkDownload.getComponent(0).setDisabled(true);
@ -299,8 +313,9 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, {
this.forceDownload.setDisabled(true); this.forceDownload.setDisabled(true);
this.ProgressFset.show(); this.ProgressFset.show();
this.downProgBar.updateText('Importing '.concat(status['num_blocked'])); this.downProgBar.updateText(
'Importing '.concat(status['num_blocked'])
);
} else if (status['state'] == 'Idle') { } else if (status['state'] == 'Idle') {
this.ProgressFset.hide(); this.ProgressFset.hide();
this.checkDownload.getComponent(0).setDisabled(false); this.checkDownload.getComponent(0).setDisabled(false);
@ -315,10 +330,12 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, {
this.lblFileSize.setText(fsize(status['file_size'])); this.lblFileSize.setText(fsize(status['file_size']));
this.lblDate.setText(fdate(status['file_date'])); this.lblDate.setText(fdate(status['file_date']));
this.lblType.setText(status['file_type']); this.lblType.setText(status['file_type']);
this.lblURL.setText(status['file_url'].substr(0,40).concat('...')); this.lblURL.setText(
status['file_url'].substr(0, 40).concat('...')
);
} }
}, },
scope: this scope: this,
}); });
}, },
@ -329,7 +346,7 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, {
forceDown: function() { forceDown: function() {
this.onApply(); this.onApply();
deluge.client.blocklist.check_import(force = true); deluge.client.blocklist.check_import((force = true));
}, },
updateConfig: function() { updateConfig: function() {
@ -348,7 +365,7 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, {
this.WhitelistFset.getComponent(0).loadData(data); this.WhitelistFset.getComponent(0).loadData(data);
}, },
scope: this scope: this,
}); });
deluge.client.blocklist.get_status({ deluge.client.blocklist.get_status({
@ -356,9 +373,11 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, {
this.lblFileSize.setText(fsize(status['file_size'])); this.lblFileSize.setText(fsize(status['file_size']));
this.lblDate.setText(fdate(status['file_date'])); this.lblDate.setText(fdate(status['file_date']));
this.lblType.setText(status['file_type']); this.lblType.setText(status['file_type']);
this.lblURL.setText(status['file_url'].substr(0,40).concat('...')); this.lblURL.setText(
status['file_url'].substr(0, 40).concat('...')
);
}, },
scope: this scope: this,
}); });
}, },
@ -366,7 +385,7 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, {
var store = this.WhitelistFset.getComponent(0).getStore(); var store = this.WhitelistFset.getComponent(0).getStore();
var IP = store.recordType; var IP = store.recordType;
var i = new IP({ var i = new IP({
ip: '' ip: '',
}); });
this.WhitelistFset.getComponent(0).stopEditing(); this.WhitelistFset.getComponent(0).stopEditing();
store.insert(0, i); store.insert(0, i);
@ -374,12 +393,13 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, {
}, },
deleteIP: function() { deleteIP: function() {
var selections = this.WhitelistFset.getComponent(0).getSelectionModel().getSelections(); var selections = this.WhitelistFset.getComponent(0)
.getSelectionModel()
.getSelections();
var store = this.WhitelistFset.getComponent(0).getStore(); var store = this.WhitelistFset.getComponent(0).getStore();
this.WhitelistFset.getComponent(0).stopEditing(); this.WhitelistFset.getComponent(0).stopEditing();
for (var i = 0; i < selections.length; i++) for (var i = 0; i < selections.length; i++) store.remove(selections[i]);
store.remove(selections[i]);
store.commitChanges(); store.commitChanges();
}, },
@ -389,11 +409,10 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, {
deluge.preferences.un('show', this.updateConfig, this); deluge.preferences.un('show', this.updateConfig, this);
Deluge.ux.preferences.BlocklistPage.superclass.onDestroy.call(this); Deluge.ux.preferences.BlocklistPage.superclass.onDestroy.call(this);
} },
}); });
Deluge.plugins.BlocklistPlugin = Ext.extend(Deluge.Plugin, { Deluge.plugins.BlocklistPlugin = Ext.extend(Deluge.Plugin, {
name: 'Blocklist', name: 'Blocklist',
onDisable: function() { onDisable: function() {
@ -401,8 +420,10 @@ Deluge.plugins.BlocklistPlugin = Ext.extend(Deluge.Plugin, {
}, },
onEnable: function() { onEnable: function() {
this.prefsPage = deluge.preferences.addPage(new Deluge.ux.preferences.BlocklistPage()); this.prefsPage = deluge.preferences.addPage(
} new Deluge.ux.preferences.BlocklistPage()
);
},
}); });
Deluge.registerPlugin('Blocklist', Deluge.plugins.BlocklistPlugin); Deluge.registerPlugin('Blocklist', Deluge.plugins.BlocklistPlugin);

View File

@ -13,7 +13,6 @@
Ext.ns('Deluge.ux'); Ext.ns('Deluge.ux');
Deluge.ux.ExecuteWindowBase = Ext.extend(Ext.Window, { Deluge.ux.ExecuteWindowBase = Ext.extend(Ext.Window, {
layout: 'fit', layout: 'fit',
width: 400, width: 400,
height: 130, height: 130,
@ -27,47 +26,49 @@ Deluge.ux.ExecuteWindowBase = Ext.extend(Ext.Window, {
xtype: 'form', xtype: 'form',
baseCls: 'x-plain', baseCls: 'x-plain',
bodyStyle: 'padding: 5px', bodyStyle: 'padding: 5px',
items: [{ items: [
{
xtype: 'combo', xtype: 'combo',
width: 270, width: 270,
fieldLabel: _('Event'), fieldLabel: _('Event'),
store: new Ext.data.ArrayStore({ store: new Ext.data.ArrayStore({
fields: ['id', 'text'], fields: ['id', 'text'],
data: [ data: [
['complete', _('Torrent Complete')], ['complete', _('Torrent Complete')],
['added', _('Torrent Added')], ['added', _('Torrent Added')],
['removed', _('Torrent Removed')] ['removed', _('Torrent Removed')],
] ],
}), }),
name: 'event', name: 'event',
mode: 'local', mode: 'local',
editable: false, editable: false,
triggerAction: 'all', triggerAction: 'all',
valueField: 'id', valueField: 'id',
displayField: 'text' displayField: 'text',
}, { },
{
xtype: 'textfield', xtype: 'textfield',
fieldLabel: _('Command'), fieldLabel: _('Command'),
name: 'command', name: 'command',
width: 270 width: 270,
}] },
],
}); });
}, },
onCancelClick: function() { onCancelClick: function() {
this.hide(); this.hide();
} },
}); });
Deluge.ux.EditExecuteCommandWindow = Ext.extend(Deluge.ux.ExecuteWindowBase, { Deluge.ux.EditExecuteCommandWindow = Ext.extend(Deluge.ux.ExecuteWindowBase, {
title: _('Edit Command'), title: _('Edit Command'),
initComponent: function() { initComponent: function() {
Deluge.ux.EditExecuteCommandWindow.superclass.initComponent.call(this); Deluge.ux.EditExecuteCommandWindow.superclass.initComponent.call(this);
this.addButton(_('Save'), this.onSaveClick, this); this.addButton(_('Save'), this.onSaveClick, this);
this.addEvents({ this.addEvents({
'commandedit': true commandedit: true,
}); });
}, },
@ -76,32 +77,40 @@ Deluge.ux.EditExecuteCommandWindow = Ext.extend(Deluge.ux.ExecuteWindowBase, {
this.command = command; this.command = command;
this.form.getForm().setValues({ this.form.getForm().setValues({
event: command.get('event'), event: command.get('event'),
command: command.get('name') command: command.get('name'),
}); });
}, },
onSaveClick: function() { onSaveClick: function() {
var values = this.form.getForm().getFieldValues(); var values = this.form.getForm().getFieldValues();
deluge.client.execute.save_command(this.command.id, values.event, values.command, { deluge.client.execute.save_command(
success: function() { this.command.id,
this.fireEvent('commandedit', this, values.event, values.command); values.event,
}, values.command,
scope: this {
}); success: function() {
this.fireEvent(
'commandedit',
this,
values.event,
values.command
);
},
scope: this,
}
);
this.hide(); this.hide();
} },
}); });
Deluge.ux.AddExecuteCommandWindow = Ext.extend(Deluge.ux.ExecuteWindowBase, { Deluge.ux.AddExecuteCommandWindow = Ext.extend(Deluge.ux.ExecuteWindowBase, {
title: _('Add Command'), title: _('Add Command'),
initComponent: function() { initComponent: function() {
Deluge.ux.AddExecuteCommandWindow.superclass.initComponent.call(this); Deluge.ux.AddExecuteCommandWindow.superclass.initComponent.call(this);
this.addButton(_('Add'), this.onAddClick, this); this.addButton(_('Add'), this.onAddClick, this);
this.addEvents({ this.addEvents({
'commandadd': true commandadd: true,
}); });
}, },
@ -109,13 +118,17 @@ Deluge.ux.AddExecuteCommandWindow = Ext.extend(Deluge.ux.ExecuteWindowBase, {
var values = this.form.getForm().getFieldValues(); var values = this.form.getForm().getFieldValues();
deluge.client.execute.add_command(values.event, values.command, { deluge.client.execute.add_command(values.event, values.command, {
success: function() { success: function() {
this.fireEvent('commandadd', this, values.event, values.command); this.fireEvent(
'commandadd',
this,
values.event,
values.command
);
}, },
scope: this scope: this,
}); });
this.hide(); this.hide();
} },
}); });
Ext.ns('Deluge.ux.preferences'); Ext.ns('Deluge.ux.preferences');
@ -125,7 +138,6 @@ Ext.ns('Deluge.ux.preferences');
* @extends Ext.Panel * @extends Ext.Panel
*/ */
Deluge.ux.preferences.ExecutePage = Ext.extend(Ext.Panel, { Deluge.ux.preferences.ExecutePage = Ext.extend(Ext.Panel, {
title: _('Execute'), title: _('Execute'),
header: false, header: false,
layout: 'fit', layout: 'fit',
@ -133,63 +145,71 @@ Deluge.ux.preferences.ExecutePage = Ext.extend(Ext.Panel, {
initComponent: function() { initComponent: function() {
Deluge.ux.preferences.ExecutePage.superclass.initComponent.call(this); Deluge.ux.preferences.ExecutePage.superclass.initComponent.call(this);
var event_map = this.event_map = { var event_map = (this.event_map = {
'complete': _('Torrent Complete'), complete: _('Torrent Complete'),
'added': _('Torrent Added'), added: _('Torrent Added'),
'removed': _('Torrent Removed') removed: _('Torrent Removed'),
}; });
this.list = new Ext.list.ListView({ this.list = new Ext.list.ListView({
store: new Ext.data.SimpleStore({ store: new Ext.data.SimpleStore({
fields: [ fields: [
{name: 'event', mapping: 1}, { name: 'event', mapping: 1 },
{name: 'name', mapping: 2} { name: 'name', mapping: 2 },
], ],
id: 0 id: 0,
}), }),
columns: [{ columns: [
width: .3, {
width: 0.3,
header: _('Event'), header: _('Event'),
sortable: true, sortable: true,
dataIndex: 'event', dataIndex: 'event',
tpl: new Ext.XTemplate('{[this.getEvent(values.event)]}', { tpl: new Ext.XTemplate('{[this.getEvent(values.event)]}', {
getEvent: function(e) { getEvent: function(e) {
return (event_map[e]) ? event_map[e] : e; return event_map[e] ? event_map[e] : e;
} },
}) }),
}, { },
{
id: 'name', id: 'name',
header: _('Command'), header: _('Command'),
sortable: true, sortable: true,
dataIndex: 'name' dataIndex: 'name',
}], },
],
singleSelect: true, singleSelect: true,
autoExpandColumn: 'name' autoExpandColumn: 'name',
}); });
this.list.on('selectionchange', this.onSelectionChange, this); this.list.on('selectionchange', this.onSelectionChange, this);
this.panel = this.add({ this.panel = this.add({
items: [this.list], items: [this.list],
bbar: { bbar: {
items: [{ items: [
{
text: _('Add'), text: _('Add'),
iconCls: 'icon-add', iconCls: 'icon-add',
handler: this.onAddClick, handler: this.onAddClick,
scope: this scope: this,
}, { },
{
text: _('Edit'), text: _('Edit'),
iconCls: 'icon-edit', iconCls: 'icon-edit',
handler: this.onEditClick, handler: this.onEditClick,
scope: this, scope: this,
disabled: true disabled: true,
}, '->', { },
'->',
{
text: _('Remove'), text: _('Remove'),
iconCls: 'icon-remove', iconCls: 'icon-remove',
handler: this.onRemoveClick, handler: this.onRemoveClick,
scope: this, scope: this,
disabled: true disabled: true,
}] },
} ],
},
}); });
this.on('show', this.onPreferencesShow, this); this.on('show', this.onPreferencesShow, this);
@ -200,16 +220,20 @@ Deluge.ux.preferences.ExecutePage = Ext.extend(Ext.Panel, {
success: function(commands) { success: function(commands) {
this.list.getStore().loadData(commands); this.list.getStore().loadData(commands);
}, },
scope: this scope: this,
}); });
}, },
onAddClick: function() { onAddClick: function() {
if (!this.addWin) { if (!this.addWin) {
this.addWin = new Deluge.ux.AddExecuteCommandWindow(); this.addWin = new Deluge.ux.AddExecuteCommandWindow();
this.addWin.on('commandadd', function() { this.addWin.on(
this.updateCommands(); 'commandadd',
}, this); function() {
this.updateCommands();
},
this
);
} }
this.addWin.show(); this.addWin.show();
}, },
@ -217,16 +241,20 @@ Deluge.ux.preferences.ExecutePage = Ext.extend(Ext.Panel, {
onCommandAdded: function(win, evt, cmd) { onCommandAdded: function(win, evt, cmd) {
var record = new this.list.getStore().recordType({ var record = new this.list.getStore().recordType({
event: evt, event: evt,
command: cmd command: cmd,
}); });
}, },
onEditClick: function() { onEditClick: function() {
if (!this.editWin) { if (!this.editWin) {
this.editWin = new Deluge.ux.EditExecuteCommandWindow(); this.editWin = new Deluge.ux.EditExecuteCommandWindow();
this.editWin.on('commandedit', function() { this.editWin.on(
this.updateCommands(); 'commandedit',
}, this); function() {
this.updateCommands();
},
this
);
} }
this.editWin.show(this.list.getSelectedRecords()[0]); this.editWin.show(this.list.getSelectedRecords()[0]);
}, },
@ -241,23 +269,34 @@ Deluge.ux.preferences.ExecutePage = Ext.extend(Ext.Panel, {
success: function() { success: function() {
this.updateCommands(); this.updateCommands();
}, },
scope: this scope: this,
}); });
}, },
onSelectionChange: function(dv, selections) { onSelectionChange: function(dv, selections) {
if (selections.length) { if (selections.length) {
this.panel.getBottomToolbar().items.get(1).enable(); this.panel
this.panel.getBottomToolbar().items.get(3).enable(); .getBottomToolbar()
.items.get(1)
.enable();
this.panel
.getBottomToolbar()
.items.get(3)
.enable();
} else { } else {
this.panel.getBottomToolbar().items.get(1).disable(); this.panel
this.panel.getBottomToolbar().items.get(3).disable(); .getBottomToolbar()
.items.get(1)
.disable();
this.panel
.getBottomToolbar()
.items.get(3)
.disable();
} }
} },
}); });
Deluge.plugins.ExecutePlugin = Ext.extend(Deluge.Plugin, { Deluge.plugins.ExecutePlugin = Ext.extend(Deluge.Plugin, {
name: 'Execute', name: 'Execute',
onDisable: function() { onDisable: function() {
@ -265,7 +304,9 @@ Deluge.plugins.ExecutePlugin = Ext.extend(Deluge.Plugin, {
}, },
onEnable: function() { onEnable: function() {
this.prefsPage = deluge.preferences.addPage(new Deluge.ux.preferences.ExecutePage()); this.prefsPage = deluge.preferences.addPage(
} new Deluge.ux.preferences.ExecutePage()
);
},
}); });
Deluge.registerPlugin('Execute', Deluge.plugins.ExecutePlugin); Deluge.registerPlugin('Execute', Deluge.plugins.ExecutePlugin);

View File

@ -16,7 +16,6 @@ Ext.ns('Deluge.ux.preferences');
* @extends Ext.Panel * @extends Ext.Panel
*/ */
Deluge.ux.preferences.ExtractorPage = Ext.extend(Ext.Panel, { Deluge.ux.preferences.ExtractorPage = Ext.extend(Ext.Panel, {
title: _('Extractor'), title: _('Extractor'),
header: false, header: false,
layout: 'fit', layout: 'fit',
@ -29,7 +28,7 @@ Deluge.ux.preferences.ExtractorPage = Ext.extend(Ext.Panel, {
xtype: 'form', xtype: 'form',
layout: 'form', layout: 'form',
border: false, border: false,
autoHeight: true autoHeight: true,
}); });
fieldset = this.form.add({ fieldset = this.form.add({
@ -39,23 +38,22 @@ Deluge.ux.preferences.ExtractorPage = Ext.extend(Ext.Panel, {
autoHeight: true, autoHeight: true,
labelAlign: 'top', labelAlign: 'top',
labelWidth: 80, labelWidth: 80,
defaultType: 'textfield' defaultType: 'textfield',
}); });
this.extract_path = fieldset.add({ this.extract_path = fieldset.add({
fieldLabel: _('Extract to:'), fieldLabel: _('Extract to:'),
labelSeparator: '', labelSeparator: '',
name: 'extract_path', name: 'extract_path',
width: '97%' width: '97%',
}); });
this.use_name_folder = fieldset.add({ this.use_name_folder = fieldset.add({
xtype: 'checkbox', xtype: 'checkbox',
name: 'use_name_folder', name: 'use_name_folder',
height: 22, height: 22,
hideLabel: true, hideLabel: true,
boxLabel: _('Create torrent name sub-folder') boxLabel: _('Create torrent name sub-folder'),
}); });
this.on('show', this.updateConfig, this); this.on('show', this.updateConfig, this);
@ -81,14 +79,12 @@ Deluge.ux.preferences.ExtractorPage = Ext.extend(Ext.Panel, {
this.extract_path.setValue(config['extract_path']); this.extract_path.setValue(config['extract_path']);
this.use_name_folder.setValue(config['use_name_folder']); this.use_name_folder.setValue(config['use_name_folder']);
}, },
scope: this scope: this,
}); });
} },
}); });
Deluge.plugins.ExtractorPlugin = Ext.extend(Deluge.Plugin, { Deluge.plugins.ExtractorPlugin = Ext.extend(Deluge.Plugin, {
name: 'Extractor', name: 'Extractor',
onDisable: function() { onDisable: function() {
@ -96,7 +92,9 @@ Deluge.plugins.ExtractorPlugin = Ext.extend(Deluge.Plugin, {
}, },
onEnable: function() { onEnable: function() {
this.prefsPage = deluge.preferences.addPage(new Deluge.ux.preferences.ExtractorPage()); this.prefsPage = deluge.preferences.addPage(
} new Deluge.ux.preferences.ExtractorPage()
);
},
}); });
Deluge.registerPlugin('Extractor', Deluge.plugins.ExtractorPlugin); Deluge.registerPlugin('Extractor', Deluge.plugins.ExtractorPlugin);

View File

@ -16,7 +16,6 @@ Ext.ns('Deluge.ux.preferences');
* @extends Ext.Panel * @extends Ext.Panel
*/ */
Deluge.ux.preferences.LabelPage = Ext.extend(Ext.Panel, { Deluge.ux.preferences.LabelPage = Ext.extend(Ext.Panel, {
title: _('Label'), title: _('Label'),
layout: 'fit', layout: 'fit',
border: false, border: false,
@ -29,20 +28,20 @@ Deluge.ux.preferences.LabelPage = Ext.extend(Ext.Panel, {
title: _('Label Preferences'), title: _('Label Preferences'),
autoHeight: true, autoHeight: true,
labelWidth: 1, labelWidth: 1,
defaultType: 'panel' defaultType: 'panel',
}); });
fieldset.add({ fieldset.add({
border: false, border: false,
bodyCfg: { bodyCfg: {
html: _('<p>The Label plugin is enabled.</p><br>' + html: _(
'<p>The Label plugin is enabled.</p><br>' +
'<p>To add, remove or edit labels right-click on the Label filter ' + '<p>To add, remove or edit labels right-click on the Label filter ' +
'entry in the sidebar.</p><br>' + 'entry in the sidebar.</p><br>' +
'<p>To apply a label right-click on torrent(s).<p>') '<p>To apply a label right-click on torrent(s).<p>'
} ),
},
}); });
}, },
}); });
Ext.ns('Deluge.ux'); Ext.ns('Deluge.ux');
@ -52,7 +51,6 @@ Ext.ns('Deluge.ux');
* @extends Ext.Window * @extends Ext.Window
*/ */
Deluge.ux.AddLabelWindow = Ext.extend(Ext.Window, { Deluge.ux.AddLabelWindow = Ext.extend(Ext.Window, {
title: _('Add Label'), title: _('Add Label'),
width: 300, width: 300,
height: 100, height: 100,
@ -66,23 +64,25 @@ Deluge.ux.AddLabelWindow = Ext.extend(Ext.Window, {
xtype: 'form', xtype: 'form',
height: 35, height: 35,
baseCls: 'x-plain', baseCls: 'x-plain',
bodyStyle:'padding:5px 5px 0', bodyStyle: 'padding:5px 5px 0',
defaultType: 'textfield', defaultType: 'textfield',
labelWidth: 50, labelWidth: 50,
items: [{ items: [
{
fieldLabel: _('Name'), fieldLabel: _('Name'),
name: 'name', name: 'name',
allowBlank: false, allowBlank: false,
width: 220, width: 220,
listeners: { listeners: {
'specialkey': { specialkey: {
fn: function(field, e) { fn: function(field, e) {
if (e.getKey() == 13) this.onOkClick(); if (e.getKey() == 13) this.onOkClick();
}, },
scope: this scope: this,
} },
} },
}] },
],
}); });
}, },
@ -97,7 +97,7 @@ Deluge.ux.AddLabelWindow = Ext.extend(Ext.Window, {
deluge.ui.update(); deluge.ui.update();
this.fireEvent('labeladded', label); this.fireEvent('labeladded', label);
}, },
scope: this scope: this,
}); });
this.hide(); this.hide();
}, },
@ -109,9 +109,11 @@ Deluge.ux.AddLabelWindow = Ext.extend(Ext.Window, {
onShow: function(comp) { onShow: function(comp) {
Deluge.ux.AddLabelWindow.superclass.onShow.call(this, comp); Deluge.ux.AddLabelWindow.superclass.onShow.call(this, comp);
this.form.getForm().findField('name').focus(false, 150); this.form
} .getForm()
.findField('name')
.focus(false, 150);
},
}); });
/** /**
@ -119,9 +121,8 @@ Deluge.ux.AddLabelWindow = Ext.extend(Ext.Window, {
* @extends Ext.Window * @extends Ext.Window
*/ */
Deluge.ux.LabelOptionsWindow = Ext.extend(Ext.Window, { Deluge.ux.LabelOptionsWindow = Ext.extend(Ext.Window, {
title: _('Label Options'), title: _('Label Options'),
width: 325, width: 325,
height: 240, height: 240,
initComponent: function() { initComponent: function() {
@ -130,136 +131,178 @@ Deluge.ux.LabelOptionsWindow = Ext.extend(Ext.Window, {
this.addButton(_('Ok'), this.onOkClick, this); this.addButton(_('Ok'), this.onOkClick, this);
this.form = this.add({ this.form = this.add({
xtype: 'form' xtype: 'form',
}); });
this.tabs = this.form.add({ this.tabs = this.form.add({
xtype: 'tabpanel', xtype: 'tabpanel',
height: 175, height: 175,
border: false, border: false,
items: [{ items: [
{
title: _('Maximum'), title: _('Maximum'),
items: [{ items: [
{
border: false, border: false,
items: [{ items: [
{
xtype: 'fieldset', xtype: 'fieldset',
border: false, border: false,
labelWidth: 1, labelWidth: 1,
style: 'margin-bottom: 0px; padding-bottom: 0px;', style:
items: [{ 'margin-bottom: 0px; padding-bottom: 0px;',
items: [
{
xtype: 'checkbox', xtype: 'checkbox',
name: 'apply_max', name: 'apply_max',
fieldLabel: '', fieldLabel: '',
boxLabel: _('Apply per torrent max settings:'), boxLabel: _(
'Apply per torrent max settings:'
),
listeners: { listeners: {
check: this.onFieldChecked check: this.onFieldChecked,
} },
}] },
}, { ],
},
{
xtype: 'fieldset', xtype: 'fieldset',
border: false, border: false,
defaultType: 'spinnerfield', defaultType: 'spinnerfield',
style: 'margin-top: 0px; padding-top: 0px;', style: 'margin-top: 0px; padding-top: 0px;',
items: [{ items: [
{
fieldLabel: _('Download Speed'), fieldLabel: _('Download Speed'),
name: 'max_download_speed', name: 'max_download_speed',
width: 80, width: 80,
disabled: true, disabled: true,
value: -1, value: -1,
minValue: -1 minValue: -1,
}, { },
{
fieldLabel: _('Upload Speed'), fieldLabel: _('Upload Speed'),
name: 'max_upload_speed', name: 'max_upload_speed',
width: 80, width: 80,
disabled: true, disabled: true,
value: -1, value: -1,
minValue: -1 minValue: -1,
}, { },
{
fieldLabel: _('Upload Slots'), fieldLabel: _('Upload Slots'),
name: 'max_upload_slots', name: 'max_upload_slots',
width: 80, width: 80,
disabled: true, disabled: true,
value: -1, value: -1,
minValue: -1 minValue: -1,
}, { },
{
fieldLabel: _('Connections'), fieldLabel: _('Connections'),
name: 'max_connections', name: 'max_connections',
width: 80, width: 80,
disabled: true, disabled: true,
value: -1, value: -1,
minValue: -1 minValue: -1,
}] },
}] ],
}] },
}, { ],
},
],
},
{
title: _('Queue'), title: _('Queue'),
items: [{ items: [
{
border: false, border: false,
items: [{ items: [
{
xtype: 'fieldset', xtype: 'fieldset',
border: false, border: false,
labelWidth: 1, labelWidth: 1,
style: 'margin-bottom: 0px; padding-bottom: 0px;', style:
items: [{ 'margin-bottom: 0px; padding-bottom: 0px;',
items: [
{
xtype: 'checkbox', xtype: 'checkbox',
name: 'apply_queue', name: 'apply_queue',
fieldLabel: '', fieldLabel: '',
boxLabel: _('Apply queue settings:'), boxLabel: _(
'Apply queue settings:'
),
listeners: { listeners: {
check: this.onFieldChecked check: this.onFieldChecked,
} },
}] },
}, { ],
},
{
xtype: 'fieldset', xtype: 'fieldset',
border: false, border: false,
labelWidth: 1, labelWidth: 1,
defaultType: 'checkbox', defaultType: 'checkbox',
style: 'margin-top: 0px; padding-top: 0px;', style: 'margin-top: 0px; padding-top: 0px;',
defaults: { defaults: {
style: 'margin-left: 20px' style: 'margin-left: 20px',
}, },
items: [{ items: [
{
boxLabel: _('Auto Managed'), boxLabel: _('Auto Managed'),
name: 'is_auto_managed', name: 'is_auto_managed',
disabled: true disabled: true,
}, { },
{
boxLabel: _('Stop seed at ratio:'), boxLabel: _('Stop seed at ratio:'),
name: 'stop_at_ratio', name: 'stop_at_ratio',
disabled: true disabled: true,
}, { },
{
xtype: 'spinnerfield', xtype: 'spinnerfield',
name: 'stop_ratio', name: 'stop_ratio',
width: 60, width: 60,
decimalPrecision: 2, decimalPrecision: 2,
incrementValue: 0.1, incrementValue: 0.1,
style: 'position: relative; left: 100px', style:
disabled: true 'position: relative; left: 100px',
}, { disabled: true,
},
{
boxLabel: _('Remove at ratio'), boxLabel: _('Remove at ratio'),
name: 'remove_at_ratio', name: 'remove_at_ratio',
disabled: true disabled: true,
}] },
}] ],
}] },
}, { ],
},
],
},
{
title: _('Folders'), title: _('Folders'),
items: [{ items: [
{
border: false, border: false,
items: [{ items: [
{
xtype: 'fieldset', xtype: 'fieldset',
border: false, border: false,
labelWidth: 1, labelWidth: 1,
style: 'margin-bottom: 0px; padding-bottom: 0px;', style:
items: [{ 'margin-bottom: 0px; padding-bottom: 0px;',
items: [
{
xtype: 'checkbox', xtype: 'checkbox',
name: 'apply_move_completed', name: 'apply_move_completed',
fieldLabel: '', fieldLabel: '',
boxLabel: _('Apply folder settings:'), boxLabel: _(
'Apply folder settings:'
),
listeners: { listeners: {
check: this.onFieldChecked check: this.onFieldChecked,
} },
}] },
}, { ],
},
{
xtype: 'fieldset', xtype: 'fieldset',
border: false, border: false,
labelWidth: 1, labelWidth: 1,
@ -267,64 +310,83 @@ Deluge.ux.LabelOptionsWindow = Ext.extend(Ext.Window, {
labelWidth: 1, labelWidth: 1,
style: 'margin-top: 0px; padding-top: 0px;', style: 'margin-top: 0px; padding-top: 0px;',
defaults: { defaults: {
style: 'margin-left: 20px' style: 'margin-left: 20px',
}, },
items: [{ items: [
{
boxLabel: _('Move completed to:'), boxLabel: _('Move completed to:'),
name: 'move_completed', name: 'move_completed',
disabled: true disabled: true,
}, { },
{
xtype: 'textfield', xtype: 'textfield',
name: 'move_completed_path', name: 'move_completed_path',
width: 250, width: 250,
disabled: true disabled: true,
}] },
}] ],
}] },
}, { ],
},
],
},
{
title: _('Trackers'), title: _('Trackers'),
items: [{ items: [
{
border: false, border: false,
items: [{ items: [
{
xtype: 'fieldset', xtype: 'fieldset',
border: false, border: false,
labelWidth: 1, labelWidth: 1,
style: 'margin-bottom: 0px; padding-bottom: 0px;', style:
items: [{ 'margin-bottom: 0px; padding-bottom: 0px;',
items: [
{
xtype: 'checkbox', xtype: 'checkbox',
name: 'auto_add', name: 'auto_add',
fieldLabel: '', fieldLabel: '',
boxLabel: _('Automatically apply label:'), boxLabel: _(
'Automatically apply label:'
),
listeners: { listeners: {
check: this.onFieldChecked check: this.onFieldChecked,
} },
}] },
}, { ],
},
{
xtype: 'fieldset', xtype: 'fieldset',
border: false, border: false,
labelWidth: 1, labelWidth: 1,
style: 'margin-top: 0px; padding-top: 0px;', style: 'margin-top: 0px; padding-top: 0px;',
defaults: { defaults: {
style: 'margin-left: 20px' style: 'margin-left: 20px',
}, },
defaultType: 'textarea', defaultType: 'textarea',
items: [{ items: [
{
boxLabel: _('Move completed to:'), boxLabel: _('Move completed to:'),
name: 'auto_add_trackers', name: 'auto_add_trackers',
width: 250, width: 250,
height: 100, height: 100,
disabled: true disabled: true,
}] },
}] ],
}] },
}] ],
},
],
},
],
}); });
}, },
getLabelOptions: function() { getLabelOptions: function() {
deluge.client.label.get_options(this.label, { deluge.client.label.get_options(this.label, {
success: this.gotOptions, success: this.gotOptions,
scope: this scope: this,
}); });
}, },
@ -347,7 +409,9 @@ Deluge.ux.LabelOptionsWindow = Ext.extend(Ext.Window, {
onOkClick: function() { onOkClick: function() {
var values = this.form.getForm().getFieldValues(); var values = this.form.getForm().getFieldValues();
if (values['auto_add_trackers']) { if (values['auto_add_trackers']) {
values['auto_add_trackers'] = values['auto_add_trackers'].split('\n'); values['auto_add_trackers'] = values['auto_add_trackers'].split(
'\n'
);
} }
deluge.client.label.set_options(this.label, values); deluge.client.label.set_options(this.label, values);
this.hide(); this.hide();
@ -358,11 +422,9 @@ Deluge.ux.LabelOptionsWindow = Ext.extend(Ext.Window, {
fs.items.each(function(field) { fs.items.each(function(field) {
field.setDisabled(!checked); field.setDisabled(!checked);
}); });
} },
}); });
Ext.ns('Deluge.plugins'); Ext.ns('Deluge.plugins');
/** /**
@ -370,28 +432,31 @@ Ext.ns('Deluge.plugins');
* @extends Deluge.Plugin * @extends Deluge.Plugin
*/ */
Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, { Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, {
name: 'Label', name: 'Label',
createMenu: function() { createMenu: function() {
this.labelMenu = new Ext.menu.Menu({ this.labelMenu = new Ext.menu.Menu({
items: [{ items: [
{
text: _('Add Label'), text: _('Add Label'),
iconCls: 'icon-add', iconCls: 'icon-add',
handler: this.onLabelAddClick, handler: this.onLabelAddClick,
scope: this scope: this,
}, { },
{
text: _('Remove Label'), text: _('Remove Label'),
disabled: true, disabled: true,
iconCls: 'icon-remove', iconCls: 'icon-remove',
handler: this.onLabelRemoveClick, handler: this.onLabelRemoveClick,
scope: this scope: this,
}, { },
{
text: _('Label Options'), text: _('Label Options'),
disabled: true, disabled: true,
handler: this.onLabelOptionsClick, handler: this.onLabelOptionsClick,
scope: this scope: this,
}] },
],
}); });
}, },
@ -409,7 +474,7 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, {
text: _('No Label'), text: _('No Label'),
label: '', label: '',
handler: this.onTorrentMenuClick, handler: this.onTorrentMenuClick,
scope: this scope: this,
}); });
for (var state in states) { for (var state in states) {
if (!state || state == 'All') continue; if (!state || state == 'All') continue;
@ -417,7 +482,7 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, {
text: state, text: state,
label: state, label: state,
handler: this.onTorrentMenuClick, handler: this.onTorrentMenuClick,
scope: this scope: this,
}); });
} }
}, },
@ -433,19 +498,22 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, {
}, },
onEnable: function() { onEnable: function() {
this.prefsPage = deluge.preferences.addPage(new Deluge.ux.preferences.LabelPage()); this.prefsPage = deluge.preferences.addPage(
new Deluge.ux.preferences.LabelPage()
);
this.torrentMenu = new Ext.menu.Menu(); this.torrentMenu = new Ext.menu.Menu();
this.tmSep = deluge.menus.torrent.add({ this.tmSep = deluge.menus.torrent.add({
xtype: 'menuseparator' xtype: 'menuseparator',
}); });
this.tm = deluge.menus.torrent.add({ this.tm = deluge.menus.torrent.add({
text: _('Label'), text: _('Label'),
menu: this.torrentMenu menu: this.torrentMenu,
}); });
var lbltpl = '<div class="x-deluge-filter">' + var lbltpl =
'<div class="x-deluge-filter">' +
'<tpl if="filter">{filter}</tpl>' + '<tpl if="filter">{filter}</tpl>' +
'<tpl if="!filter">No Label</tpl>' + '<tpl if="!filter">No Label</tpl>' +
' ({count})' + ' ({count})' +
@ -459,7 +527,11 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, {
filter.list.refresh(); filter.list.refresh();
} else { } else {
deluge.sidebar.on('filtercreate', this.onFilterCreate, this); deluge.sidebar.on('filtercreate', this.onFilterCreate, this);
deluge.sidebar.on('afterfiltercreate', this.onAfterFilterCreate, this); deluge.sidebar.on(
'afterfiltercreate',
this.onAfterFilterCreate,
this
);
Deluge.FilterPanel.templates.label = lbltpl; Deluge.FilterPanel.templates.label = lbltpl;
} }
this.registerTorrentStatus('label', _('Label')); this.registerTorrentStatus('label', _('Label'));
@ -499,7 +571,7 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, {
//console.log(states); //console.log(states);
//console.log(statesArray); //console.log(statesArray);
states = {} states = {};
for (i = 0; i < statesArray.length; ++i) { for (i = 0; i < statesArray.length; ++i) {
states[statesArray[i]] = 0; states[statesArray[i]] = 0;
@ -532,7 +604,8 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, {
}, },
onLabelOptionsClick: function() { onLabelOptionsClick: function() {
if (!this.labelOpts) this.labelOpts = new Deluge.ux.LabelOptionsWindow(); if (!this.labelOpts)
this.labelOpts = new Deluge.ux.LabelOptionsWindow();
this.labelOpts.show(this.filter.getState()); this.labelOpts.show(this.filter.getState());
}, },
@ -547,7 +620,7 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, {
var i = item; var i = item;
}, this); }, this);
}, },
scope: this scope: this,
}); });
}, },
@ -558,12 +631,12 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, {
deluge.client.label.set_torrent(id, item.label, { deluge.client.label.set_torrent(id, item.label, {
success: function() { success: function() {
deluge.ui.update(); deluge.ui.update();
} },
}); });
} else { } else {
deluge.client.label.set_torrent(id, item.label); deluge.client.label.set_torrent(id, item.label);
} }
}); });
} },
}); });
Deluge.registerPlugin('Label', Deluge.plugins.LabelPlugin); Deluge.registerPlugin('Label', Deluge.plugins.LabelPlugin);

View File

@ -16,14 +16,15 @@ Ext.ns('Deluge.ux.preferences');
* @extends Ext.Panel * @extends Ext.Panel
*/ */
Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, { Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, {
title: _('Notifications'), title: _('Notifications'),
header: false, header: false,
layout: 'fit', layout: 'fit',
border: false, border: false,
initComponent: function() { initComponent: function() {
Deluge.ux.preferences.NotificationsPage.superclass.initComponent.call(this); Deluge.ux.preferences.NotificationsPage.superclass.initComponent.call(
this
);
this.emailNotiFset = new Ext.form.FieldSet({ this.emailNotiFset = new Ext.form.FieldSet({
xtype: 'fieldset', xtype: 'fieldset',
@ -33,7 +34,7 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, {
defaultType: 'textfield', defaultType: 'textfield',
style: 'margin-top: 3px; margin-bottom: 0px; padding-bottom: 0px;', style: 'margin-top: 3px; margin-bottom: 0px; padding-bottom: 0px;',
width: '85%', width: '85%',
labelWidth: 1 labelWidth: 1,
}); });
this.chkEnableEmail = this.emailNotiFset.add({ this.chkEnableEmail = this.emailNotiFset.add({
@ -46,8 +47,8 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, {
check: function(object, checked) { check: function(object, checked) {
this.setSmtpDisabled(!checked); this.setSmtpDisabled(!checked);
}, },
scope: this scope: this,
} },
}); });
this.hBoxHost = this.emailNotiFset.add({ this.hBoxHost = this.emailNotiFset.add({
@ -57,14 +58,17 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, {
xtype: 'container', xtype: 'container',
layout: 'hbox', layout: 'hbox',
disabled: true, disabled: true,
items: [{ items: [
{
xtype: 'label', xtype: 'label',
text: _('Hostname:'), text: _('Hostname:'),
margins: '6 0 0 6' margins: '6 0 0 6',
},{ },
{
xtype: 'textfield', xtype: 'textfield',
margins: '2 0 0 4' margins: '2 0 0 4',
}] },
],
}); });
this.hBoxPort = this.emailNotiFset.add({ this.hBoxPort = this.emailNotiFset.add({
@ -74,18 +78,21 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, {
xtype: 'container', xtype: 'container',
layout: 'hbox', layout: 'hbox',
disabled: true, disabled: true,
items: [{ items: [
{
xtype: 'label', xtype: 'label',
text: _('Port:'), text: _('Port:'),
margins: '6 0 0 6' margins: '6 0 0 6',
},{ },
{
xtype: 'spinnerfield', xtype: 'spinnerfield',
margins: '2 0 0 34', margins: '2 0 0 34',
width: 64, width: 64,
decimalPrecision: 0, decimalPrecision: 0,
minValue: 0, minValue: 0,
maxValue: 65535 maxValue: 65535,
}] },
],
}); });
this.hBoxUser = this.emailNotiFset.add({ this.hBoxUser = this.emailNotiFset.add({
@ -95,14 +102,17 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, {
xtype: 'container', xtype: 'container',
layout: 'hbox', layout: 'hbox',
disabled: true, disabled: true,
items: [{ items: [
{
xtype: 'label', xtype: 'label',
text: _('Username:'), text: _('Username:'),
margins: '6 0 0 6' margins: '6 0 0 6',
},{ },
{
xtype: 'textfield', xtype: 'textfield',
margins: '2 0 0 3' margins: '2 0 0 3',
}] },
],
}); });
this.hBoxPassword = this.emailNotiFset.add({ this.hBoxPassword = this.emailNotiFset.add({
@ -112,15 +122,18 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, {
xtype: 'container', xtype: 'container',
layout: 'hbox', layout: 'hbox',
disabled: true, disabled: true,
items: [{ items: [
{
xtype: 'label', xtype: 'label',
text: _('Password:'), text: _('Password:'),
margins: '6 0 0 6' margins: '6 0 0 6',
},{ },
{
xtype: 'textfield', xtype: 'textfield',
inputType: 'password', inputType: 'password',
margins: '2 0 0 5' margins: '2 0 0 5',
}] },
],
}); });
this.hBoxFrom = this.emailNotiFset.add({ this.hBoxFrom = this.emailNotiFset.add({
@ -130,14 +143,17 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, {
xtype: 'container', xtype: 'container',
layout: 'hbox', layout: 'hbox',
disabled: true, disabled: true,
items: [{ items: [
{
xtype: 'label', xtype: 'label',
text: _('From:'), text: _('From:'),
margins: '6 0 0 6' margins: '6 0 0 6',
},{ },
{
xtype: 'textfield', xtype: 'textfield',
margins: '2 0 0 28' margins: '2 0 0 28',
}] },
],
}); });
this.chkTLS = this.emailNotiFset.add({ this.chkTLS = this.emailNotiFset.add({
@ -146,7 +162,7 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, {
name: 'enable_tls_ssl', name: 'enable_tls_ssl',
xtype: 'checkbox', xtype: 'checkbox',
disabled: true, disabled: true,
boxLabel: _('Server requires TLS/SSL') boxLabel: _('Server requires TLS/SSL'),
}); });
this.recipientsFset = new Ext.form.FieldSet({ this.recipientsFset = new Ext.form.FieldSet({
@ -157,7 +173,8 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, {
defaultType: 'editorgrid', defaultType: 'editorgrid',
style: 'margin-top: 3px; margin-bottom: 0px; padding-bottom: 0px;', style: 'margin-top: 3px; margin-bottom: 0px; padding-bottom: 0px;',
autoWidth: true, autoWidth: true,
items: [{ items: [
{
fieldLabel: '', fieldLabel: '',
name: 'recipients', name: 'recipients',
margins: '2 0 5 5', margins: '2 0 5 5',
@ -167,24 +184,28 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, {
disabled: true, disabled: true,
autoExpandColumn: 'recipient', autoExpandColumn: 'recipient',
bbar: { bbar: {
items: [{ items: [
{
text: _('Add'), text: _('Add'),
iconCls: 'icon-add', iconCls: 'icon-add',
handler: this.onAddClick, handler: this.onAddClick,
scope: this scope: this,
},{ },
{
text: _('Remove'), text: _('Remove'),
iconCls: 'icon-remove', iconCls: 'icon-remove',
handler: this.onRemoveClick, handler: this.onRemoveClick,
scope: this scope: this,
}] },
],
}, },
viewConfig: { viewConfig: {
emptyText: _('Add an recipient...'), emptyText: _('Add an recipient...'),
deferEmptyText: false deferEmptyText: false,
}, },
colModel: new Ext.grid.ColumnModel({ colModel: new Ext.grid.ColumnModel({
columns: [{ columns: [
{
id: 'recipient', id: 'recipient',
header: _('Recipient'), header: _('Recipient'),
dataIndex: 'recipient', dataIndex: 'recipient',
@ -192,29 +213,30 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, {
hideable: false, hideable: false,
editable: true, editable: true,
editor: { editor: {
xtype: 'textfield' xtype: 'textfield',
} },
}] },
],
}), }),
selModel: new Ext.grid.RowSelectionModel({ selModel: new Ext.grid.RowSelectionModel({
singleSelect: false, singleSelect: false,
moveEditorOnEnter: false moveEditorOnEnter: false,
}), }),
store: new Ext.data.ArrayStore({ store: new Ext.data.ArrayStore({
autoDestroy: true, autoDestroy: true,
fields: [{name: 'recipient'}] fields: [{ name: 'recipient' }],
}), }),
listeners: { listeners: {
afteredit: function(e) { afteredit: function(e) {
e.record.commit(); e.record.commit();
} },
}, },
setEmptyText: function(text) { setEmptyText: function(text) {
if (this.viewReady) { if (this.viewReady) {
this.getView().emptyText = text; this.getView().emptyText = text;
this.getView().refresh(); this.getView().refresh();
} else { } else {
Ext.apply(this.viewConfig, {emptyText: text}); Ext.apply(this.viewConfig, { emptyText: text });
} }
}, },
loadData: function(data) { loadData: function(data) {
@ -222,8 +244,9 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, {
if (this.viewReady) { if (this.viewReady) {
this.getView().updateHeaders(); this.getView().updateHeaders();
} }
} },
}] },
],
}); });
this.edGridSubs = new Ext.grid.EditorGridPanel({ this.edGridSubs = new Ext.grid.EditorGridPanel({
@ -232,43 +255,59 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, {
autoExpandColumn: 'event', autoExpandColumn: 'event',
viewConfig: { viewConfig: {
emptyText: _('Loading events...'), emptyText: _('Loading events...'),
deferEmptyText: false deferEmptyText: false,
}, },
colModel: new Ext.grid.ColumnModel({ colModel: new Ext.grid.ColumnModel({
defaults: { defaults: {
renderer: function(value, meta, record, rowIndex, colIndex, store) { renderer: function(
value,
meta,
record,
rowIndex,
colIndex,
store
) {
if (Ext.isNumber(value) && parseInt(value) !== value) { if (Ext.isNumber(value) && parseInt(value) !== value) {
return value.toFixed(6); return value.toFixed(6);
} else if (Ext.isBoolean(value)) { } else if (Ext.isBoolean(value)) {
return '<div class="x-grid3-check-col' + (value ? '-on' : '') + return (
'" style="width: 20px;">&#160;</div>'; '<div class="x-grid3-check-col' +
(value ? '-on' : '') +
'" style="width: 20px;">&#160;</div>'
);
} }
return value; return value;
} },
}, },
columns: [{ columns: [
{
id: 'event', id: 'event',
header: 'Event', header: 'Event',
dataIndex: 'event', dataIndex: 'event',
sortable: true, sortable: true,
hideable: false hideable: false,
},{ },
{
id: 'email', id: 'email',
header: _('Email'), header: _('Email'),
dataIndex: 'email', dataIndex: 'email',
sortable: true, sortable: true,
hideable: false, hideable: false,
menuDisabled: true, menuDisabled: true,
width: 40 width: 40,
}] },
],
}), }),
store: new Ext.data.ArrayStore({ store: new Ext.data.ArrayStore({
autoDestroy: true, autoDestroy: true,
fields: [{ fields: [
name: 'event' {
},{ name: 'event',
name: 'email' },
}] {
name: 'email',
},
],
}), }),
listeners: { listeners: {
cellclick: function(grid, rowIndex, colIndex, e) { cellclick: function(grid, rowIndex, colIndex, e) {
@ -292,20 +331,20 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, {
}, },
afteredit: function(e) { afteredit: function(e) {
e.record.commit(); e.record.commit();
} },
}, },
setEmptyText: function(text) { setEmptyText: function(text) {
if (this.viewReady) { if (this.viewReady) {
this.getView().emptyText = text; this.getView().emptyText = text;
this.getView().refresh(); this.getView().refresh();
} else { } else {
Ext.apply(this.viewConfig, {emptyText: text}); Ext.apply(this.viewConfig, { emptyText: text });
} }
}, },
setSub: function(eventName) { setSub: function(eventName) {
var store = this.getStore(); var store = this.getStore();
var index = store.find('event',eventName); var index = store.find('event', eventName);
store.getAt(index).set('email',true); store.getAt(index).set('email', true);
store.getAt(index).commit(); store.getAt(index).commit();
}, },
loadData: function(data) { loadData: function(data) {
@ -313,20 +352,23 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, {
if (this.viewReady) { if (this.viewReady) {
this.getView().updateHeaders(); this.getView().updateHeaders();
} }
} },
}); });
this.tabPanSettings = this.add({ this.tabPanSettings = this.add({
xtype: 'tabpanel', xtype: 'tabpanel',
activeTab: 0, activeTab: 0,
items: [{ items: [
{
title: _('Settings'), title: _('Settings'),
items: [this.emailNotiFset,this.recipientsFset], items: [this.emailNotiFset, this.recipientsFset],
autoScroll: true autoScroll: true,
},{ },
{
title: _('Subscriptions'), title: _('Subscriptions'),
items: this.edGridSubs items: this.edGridSubs,
}] },
],
}); });
this.on('show', this.updateConfig, this); this.on('show', this.updateConfig, this);
@ -343,7 +385,7 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, {
} }
this.edGridSubs.loadData(data); this.edGridSubs.loadData(data);
}, },
scope: this scope: this,
}); });
deluge.client.notifications.get_config({ deluge.client.notifications.get_config({
success: function(config) { success: function(config) {
@ -369,10 +411,12 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, {
keys = Ext.keys(config['subscriptions']['email']); keys = Ext.keys(config['subscriptions']['email']);
for (var i = 0; i < keys.length; i++) { for (var i = 0; i < keys.length; i++) {
var key = keys[i]; var key = keys[i];
this.edGridSubs.setSub(config['subscriptions']['email'][key]); this.edGridSubs.setSub(
config['subscriptions']['email'][key]
);
} }
}, },
scope: this scope: this,
}); });
}, },
@ -425,7 +469,7 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, {
var store = this.recipientsFset.getComponent(0).getStore(); var store = this.recipientsFset.getComponent(0).getStore();
var Recipient = store.recordType; var Recipient = store.recordType;
var i = new Recipient({ var i = new Recipient({
recipient: '' recipient: '',
}); });
this.recipientsFset.getComponent(0).stopEditing(); this.recipientsFset.getComponent(0).stopEditing();
store.insert(0, i); store.insert(0, i);
@ -433,12 +477,14 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, {
}, },
onRemoveClick: function() { onRemoveClick: function() {
var selections = this.recipientsFset.getComponent(0).getSelectionModel().getSelections(); var selections = this.recipientsFset
.getComponent(0)
.getSelectionModel()
.getSelections();
var store = this.recipientsFset.getComponent(0).getStore(); var store = this.recipientsFset.getComponent(0).getStore();
this.recipientsFset.getComponent(0).stopEditing(); this.recipientsFset.getComponent(0).stopEditing();
for (var i = 0; i < selections.length; i++) for (var i = 0; i < selections.length; i++) store.remove(selections[i]);
store.remove(selections[i]);
store.commitChanges(); store.commitChanges();
}, },
@ -456,8 +502,7 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, {
deluge.preferences.un('show', this.updateConfig, this); deluge.preferences.un('show', this.updateConfig, this);
Deluge.ux.preferences.NotificationsPage.superclass.onDestroy.call(this); Deluge.ux.preferences.NotificationsPage.superclass.onDestroy.call(this);
} },
}); });
Deluge.plugins.NotificationsPlugin = Ext.extend(Deluge.Plugin, { Deluge.plugins.NotificationsPlugin = Ext.extend(Deluge.Plugin, {
@ -468,8 +513,10 @@ Deluge.plugins.NotificationsPlugin = Ext.extend(Deluge.Plugin, {
}, },
onEnable: function() { onEnable: function() {
this.prefsPage = deluge.preferences.addPage(new Deluge.ux.preferences.NotificationsPage()); this.prefsPage = deluge.preferences.addPage(
} new Deluge.ux.preferences.NotificationsPage()
);
},
}); });
Deluge.registerPlugin('Notifications', Deluge.plugins.NotificationsPlugin); Deluge.registerPlugin('Notifications', Deluge.plugins.NotificationsPlugin);

View File

@ -13,7 +13,6 @@
Ext.ns('Deluge.ux'); Ext.ns('Deluge.ux');
Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, { Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, {
title: _('Schedule'), title: _('Schedule'),
autoHeight: true, autoHeight: true,
style: 'margin-bottom: 0px; padding-bottom: 0px;', style: 'margin-bottom: 0px; padding-bottom: 0px;',
@ -24,21 +23,21 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, {
name: 'Normal', name: 'Normal',
backgroundColor: 'LightGreen', backgroundColor: 'LightGreen',
borderColor: 'DarkGreen', borderColor: 'DarkGreen',
value: 0 value: 0,
}, },
{ {
name: 'Throttled', name: 'Throttled',
backgroundColor: 'Yellow', backgroundColor: 'Yellow',
borderColor: 'Gold', borderColor: 'Gold',
value: 1 value: 1,
}, },
{ {
name: 'Paused', name: 'Paused',
backgroundColor: 'OrangeRed', backgroundColor: 'OrangeRed',
borderColor: 'FireBrick', borderColor: 'FireBrick',
value: 2 value: 2,
} },
], ],
daysOfWeek: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], daysOfWeek: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
initComponent: function() { initComponent: function() {
@ -71,7 +70,8 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, {
// create state brushes // create state brushes
// tack a random number to the end to avoid clashes // tack a random number to the end to avoid clashes
this.stateBrushName = 'schedule-state-brush-' + Math.round(Math.random() * 10000); this.stateBrushName =
'schedule-state-brush-' + Math.round(Math.random() * 10000);
var el1 = createEl(dom, 'div'); var el1 = createEl(dom, 'div');
@ -124,47 +124,55 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, {
// cache access to cells for easier access later // cache access to cells for easier access later
this.scheduleCells = {}; this.scheduleCells = {};
Ext.each(this.daysOfWeek, function(day) { Ext.each(
var cells = []; this.daysOfWeek,
var row = createEl(table, 'tr'); function(day) {
var label = createEl(row, 'th'); var cells = [];
label.setAttribute('style', 'font-weight: bold; padding-right: 5px;'); var row = createEl(table, 'tr');
label.appendChild(document.createTextNode(day)); var label = createEl(row, 'th');
for (var hour = 0; hour < 24; hour++) { label.setAttribute(
var cell = createEl(row, 'td'); 'style',
'font-weight: bold; padding-right: 5px;'
);
label.appendChild(document.createTextNode(day));
for (var hour = 0; hour < 24; hour++) {
var cell = createEl(row, 'td');
// assume the first state is the default state // assume the first state is the default state
cell.currentValue = cell.oldValue = this.states[0].value; cell.currentValue = cell.oldValue = this.states[0].value;
cell.day = day; cell.day = day;
cell.hour = hour; cell.hour = hour;
cell.width = '16px'; cell.width = '16px';
cell.height = '20px'; cell.height = '20px';
cell.style.border = '1px solid #999999'; cell.style.border = '1px solid #999999';
// don't repeat borders in between cells // don't repeat borders in between cells
if (hour != 23) // not the last cell if (hour != 23)
cell.style.borderRight = 'none'; // not the last cell
cell.style.borderRight = 'none';
this.updateCell(cell); this.updateCell(cell);
cells.push(cell); cells.push(cell);
cell = Ext.get(cell); cell = Ext.get(cell);
cell.on('click', this.onCellClick, this); cell.on('click', this.onCellClick, this);
cell.on('mouseover', this.onCellMouseOver, this); cell.on('mouseover', this.onCellMouseOver, this);
cell.on('mouseout', this.onCellMouseOut, this); cell.on('mouseout', this.onCellMouseOut, this);
cell.on('mousedown', this.onCellMouseDown, this); cell.on('mousedown', this.onCellMouseDown, this);
cell.on('mouseup', this.onCellMouseUp, this); cell.on('mouseup', this.onCellMouseUp, this);
} }
// insert gap row to provide visual separation // insert gap row to provide visual separation
row = createEl(table, 'tr'); row = createEl(table, 'tr');
// blank cell to create gap // blank cell to create gap
createEl(row, 'td').height = '3px'; createEl(row, 'td').height = '3px';
this.scheduleCells[day] = cells; this.scheduleCells[day] = cells;
}, this); },
this
);
}, },
updateCell: function(cell) { updateCell: function(cell) {
@ -182,10 +190,11 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, {
getCurrentBrushValue: function() { getCurrentBrushValue: function() {
var v = null; var v = null;
var brushes = Ext.get(this.body.dom).findParent('form').elements[this.stateBrushName]; var brushes = Ext.get(this.body.dom).findParent('form').elements[
this.stateBrushName
];
Ext.each(brushes, function(b) { Ext.each(brushes, function(b) {
if (b.checked) if (b.checked) v = b.value;
v = b.value;
}); });
return v; return v;
@ -209,8 +218,7 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, {
this.confirmCells(cell.day, this.dragAnchor.hour, cell.hour); this.confirmCells(cell.day, this.dragAnchor.hour, cell.hour);
else if (cell.hour < this.dragAnchor.hour) else if (cell.hour < this.dragAnchor.hour)
this.confirmCells(cell.day, cell.hour, this.dragAnchor.hour); this.confirmCells(cell.day, cell.hour, this.dragAnchor.hour);
else else this.confirmCells(cell.day, cell.hour, cell.hour);
this.confirmCells(cell.day, cell.hour, cell.hour);
this.hideCellLeftTooltip(); this.hideCellLeftTooltip();
this.hideCellRightTooltip(); this.hideCellRightTooltip();
@ -224,10 +232,11 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, {
// otherwise if dragging, leave it alone unless we're dragging to the left. // otherwise if dragging, leave it alone unless we're dragging to the left.
// if we're not dragging, show it. // if we're not dragging, show it.
var leftTooltipCell = null; var leftTooltipCell = null;
if (!this.dragAnchor) if (!this.dragAnchor) leftTooltipCell = cell;
leftTooltipCell = cell; else if (
else if ((this.dragAnchor && this.isCellLeftTooltipHidden()) || (this.dragAnchor && this.isCellLeftTooltipHidden()) ||
(this.dragAnchor && this.dragAnchor.hour > cell.hour)) (this.dragAnchor && this.dragAnchor.hour > cell.hour)
)
leftTooltipCell = this.dragAnchor; leftTooltipCell = this.dragAnchor;
if (leftTooltipCell) { if (leftTooltipCell) {
@ -238,23 +247,27 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, {
if (hour >= 12) { if (hour >= 12) {
pm = true; pm = true;
if (hour > 12) hour -= 12; if (hour > 12) hour -= 12;
} } else if (hour == 0) {
else if (hour == 0) {
// change 0 hour to 12am // change 0 hour to 12am
hour = 12; hour = 12;
} }
this.showCellLeftTooltip(hour + ' ' + (pm ? 'pm' : 'am'), leftTooltipCell); this.showCellLeftTooltip(
hour + ' ' + (pm ? 'pm' : 'am'),
leftTooltipCell
);
} }
// RIGHT TOOL TIP // RIGHT TOOL TIP
var rightTooltipCell = null; var rightTooltipCell = null;
if (this.dragAnchor) { if (this.dragAnchor) {
if (this.dragAnchor.hour == cell.hour) if (this.dragAnchor.hour == cell.hour) this.hideCellRightTooltip();
this.hideCellRightTooltip(); else if (
else if (this.dragAnchor.hour > cell.hour && this.isCellRightTooltipHidden()) this.dragAnchor.hour > cell.hour &&
this.isCellRightTooltipHidden()
)
rightTooltipCell = this.dragAnchor; rightTooltipCell = this.dragAnchor;
else // cell.hour > this.dragAnchor.hour // cell.hour > this.dragAnchor.hour
rightTooltipCell = cell; else rightTooltipCell = cell;
} }
if (rightTooltipCell) { if (rightTooltipCell) {
@ -265,12 +278,14 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, {
if (hour >= 12) { if (hour >= 12) {
pm = true; pm = true;
if (hour > 12) hour -= 12; if (hour > 12) hour -= 12;
} } else if (hour == 0) {
else if (hour == 0) {
// change 0 hour to 12am // change 0 hour to 12am
hour = 12; hour = 12;
} }
this.showCellRightTooltip(hour + ' ' + (pm ? 'pm' : 'am'), rightTooltipCell); this.showCellRightTooltip(
hour + ' ' + (pm ? 'pm' : 'am'),
rightTooltipCell
);
} }
// preview colour change and // preview colour change and
@ -278,39 +293,38 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, {
if (this.dragAnchor) { if (this.dragAnchor) {
if (cell.day != this.dragAnchor.day) { if (cell.day != this.dragAnchor.day) {
// dragged into another day. Abort! Abort! // dragged into another day. Abort! Abort!
Ext.each(this.daysOfWeek, function(day) { Ext.each(
this.revertCells(day, 0, 23); this.daysOfWeek,
}, this); function(day) {
this.revertCells(day, 0, 23);
},
this
);
this.dragAnchor = null; this.dragAnchor = null;
this.hideCellLeftTooltip(); this.hideCellLeftTooltip();
this.hideCellRightTooltip(); this.hideCellRightTooltip();
} } else if (cell.hour > this.dragAnchor.hour) {
else if (cell.hour > this.dragAnchor.hour) {
// dragging right // dragging right
this.revertCells(cell.day, cell.hour + 1, 23); this.revertCells(cell.day, cell.hour + 1, 23);
this.previewCells(cell.day, this.dragAnchor.hour, cell.hour); this.previewCells(cell.day, this.dragAnchor.hour, cell.hour);
} } else if (cell.hour < this.dragAnchor.hour) {
else if (cell.hour < this.dragAnchor.hour) {
// dragging left // dragging left
this.revertCells(cell.day, 0, cell.hour - 1); this.revertCells(cell.day, 0, cell.hour - 1);
this.previewCells(cell.day, cell.hour, this.dragAnchor.hour); this.previewCells(cell.day, cell.hour, this.dragAnchor.hour);
} } else {
else {
// back to anchor cell // back to anchor cell
// don't know if it is from right or left, so revert all except this // don't know if it is from right or left, so revert all except this
this.revertCells(cell.day, cell.hour + 1, 23); this.revertCells(cell.day, cell.hour + 1, 23);
this.revertCells(cell.day, 0, cell.hour - 1); this.revertCells(cell.day, 0, cell.hour - 1);
} }
} } else {
else {
// not dragging, just preview this cell // not dragging, just preview this cell
this.previewCells(cell.day, cell.hour, cell.hour); this.previewCells(cell.day, cell.hour, cell.hour);
} }
}, },
onCellMouseOut: function(event, cell) { onCellMouseOut: function(event, cell) {
if (!this.dragAnchor) if (!this.dragAnchor) this.hideCellLeftTooltip();
this.hideCellLeftTooltip();
// revert state. If new state has been set, old and new will be equal. // revert state. If new state has been set, old and new will be equal.
// if dragging, this will be handled by the next mouse over // if dragging, this will be handled by the next mouse over
@ -395,8 +409,7 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, {
isCellLeftTooltipHidden: function() { isCellLeftTooltipHidden: function() {
if (this.cellLeftTooltip) if (this.cellLeftTooltip)
return this.cellLeftTooltip.style.visibility == 'hidden'; return this.cellLeftTooltip.style.visibility == 'hidden';
else else return true;
return true;
}, },
showCellRightTooltip: function(text, cell) { showCellRightTooltip: function(text, cell) {
@ -437,8 +450,7 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, {
isCellRightTooltipHidden: function() { isCellRightTooltipHidden: function() {
if (this.cellRightTooltip) if (this.cellRightTooltip)
return this.cellRightTooltip.style.visibility == 'hidden'; return this.cellRightTooltip.style.visibility == 'hidden';
else else return true;
return true;
}, },
getConfig: function() { getConfig: function() {
@ -448,7 +460,9 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, {
var hourConfig = [0, 0, 0, 0, 0, 0, 0]; var hourConfig = [0, 0, 0, 0, 0, 0, 0];
for (var j = 0; j < this.daysOfWeek.length; j++) { for (var j = 0; j < this.daysOfWeek.length; j++) {
hourConfig[j] = parseInt(this.scheduleCells[this.daysOfWeek[j]][i].currentValue); hourConfig[j] = parseInt(
this.scheduleCells[this.daysOfWeek[j]][i].currentValue
);
} }
config.push(hourConfig); config.push(hourConfig);
@ -471,13 +485,12 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, {
this.updateCell(cell); this.updateCell(cell);
} }
} }
} },
}); });
Ext.ns('Deluge.ux.preferences'); Ext.ns('Deluge.ux.preferences');
Deluge.ux.preferences.SchedulerPage = Ext.extend(Ext.Panel, { Deluge.ux.preferences.SchedulerPage = Ext.extend(Ext.Panel, {
border: false, border: false,
title: _('Scheduler'), title: _('Scheduler'),
header: false, header: false,
@ -490,7 +503,7 @@ Deluge.ux.preferences.SchedulerPage = Ext.extend(Ext.Panel, {
xtype: 'form', xtype: 'form',
layout: 'form', layout: 'form',
border: false, border: false,
autoHeight: true autoHeight: true,
}); });
this.schedule = this.form.add(new Deluge.ux.ScheduleSelector()); this.schedule = this.form.add(new Deluge.ux.ScheduleSelector());
@ -503,10 +516,10 @@ Deluge.ux.preferences.SchedulerPage = Ext.extend(Ext.Panel, {
defaultType: 'spinnerfield', defaultType: 'spinnerfield',
defaults: { defaults: {
minValue: -1, minValue: -1,
maxValue: 99999 maxValue: 99999,
}, },
style: 'margin-top: 5px; margin-bottom: 0px; padding-bottom: 0px;', style: 'margin-top: 5px; margin-bottom: 0px; padding-bottom: 0px;',
labelWidth: 200 labelWidth: 200,
}); });
this.downloadLimit = this.slowSettings.add({ this.downloadLimit = this.slowSettings.add({
@ -514,42 +527,46 @@ Deluge.ux.preferences.SchedulerPage = Ext.extend(Ext.Panel, {
name: 'download_limit', name: 'download_limit',
width: 80, width: 80,
value: -1, value: -1,
decimalPrecision: 0 decimalPrecision: 0,
}); });
this.uploadLimit = this.slowSettings.add({ this.uploadLimit = this.slowSettings.add({
fieldLabel: _('Maximum Upload Speed (KiB/s)'), fieldLabel: _('Maximum Upload Speed (KiB/s)'),
name: 'upload_limit', name: 'upload_limit',
width: 80, width: 80,
value: -1, value: -1,
decimalPrecision: 0 decimalPrecision: 0,
}); });
this.activeTorrents = this.slowSettings.add({ this.activeTorrents = this.slowSettings.add({
fieldLabel: _('Active Torrents'), fieldLabel: _('Active Torrents'),
name: 'active_torrents', name: 'active_torrents',
width: 80, width: 80,
value: -1, value: -1,
decimalPrecision: 0 decimalPrecision: 0,
}); });
this.activeDownloading = this.slowSettings.add({ this.activeDownloading = this.slowSettings.add({
fieldLabel: _('Active Downloading'), fieldLabel: _('Active Downloading'),
name: 'active_downloading', name: 'active_downloading',
width: 80, width: 80,
value: -1, value: -1,
decimalPrecision: 0 decimalPrecision: 0,
}); });
this.activeSeeding = this.slowSettings.add({ this.activeSeeding = this.slowSettings.add({
fieldLabel: _('Active Seeding'), fieldLabel: _('Active Seeding'),
name: 'active_seeding', name: 'active_seeding',
width: 80, width: 80,
value: -1, value: -1,
decimalPrecision: 0 decimalPrecision: 0,
}); });
this.on('show', this.updateConfig, this); this.on('show', this.updateConfig, this);
}, },
onRender: function(ct, position) { onRender: function(ct, position) {
Deluge.ux.preferences.SchedulerPage.superclass.onRender.call(this, ct, position); Deluge.ux.preferences.SchedulerPage.superclass.onRender.call(
this,
ct,
position
);
this.form.layout = new Ext.layout.FormLayout(); this.form.layout = new Ext.layout.FormLayout();
this.form.layout.setContainer(this); this.form.layout.setContainer(this);
this.form.doLayout(); this.form.doLayout();
@ -583,13 +600,12 @@ Deluge.ux.preferences.SchedulerPage = Ext.extend(Ext.Panel, {
this.activeDownloading.setValue(config['low_active_down']); this.activeDownloading.setValue(config['low_active_down']);
this.activeSeeding.setValue(config['low_active_up']); this.activeSeeding.setValue(config['low_active_up']);
}, },
scope: this scope: this,
}); });
} },
}); });
Deluge.plugins.SchedulerPlugin = Ext.extend(Deluge.Plugin, { Deluge.plugins.SchedulerPlugin = Ext.extend(Deluge.Plugin, {
name: 'Scheduler', name: 'Scheduler',
onDisable: function() { onDisable: function() {
@ -597,7 +613,9 @@ Deluge.plugins.SchedulerPlugin = Ext.extend(Deluge.Plugin, {
}, },
onEnable: function() { onEnable: function() {
this.prefsPage = deluge.preferences.addPage(new Deluge.ux.preferences.SchedulerPage()); this.prefsPage = deluge.preferences.addPage(
} new Deluge.ux.preferences.SchedulerPage()
);
},
}); });
Deluge.registerPlugin('Scheduler', Deluge.plugins.SchedulerPlugin); Deluge.registerPlugin('Scheduler', Deluge.plugins.SchedulerPlugin);

View File

@ -11,16 +11,17 @@
StatsPlugin = Ext.extend(Deluge.Plugin, { StatsPlugin = Ext.extend(Deluge.Plugin, {
constructor: function(config) { constructor: function(config) {
config = Ext.apply({ config = Ext.apply(
name: "Stats" {
}, config); name: 'Stats',
},
config
);
StatsPlugin.superclass.constructor.call(this, config); StatsPlugin.superclass.constructor.call(this, config);
}, },
onDisable: function() { onDisable: function() {},
},
onEnable: function() { onEnable: function() {},
}
}); });
new StatsPlugin(); new StatsPlugin();

View File

@ -11,18 +11,17 @@
TogglePlugin = Ext.extend(Deluge.Plugin, { TogglePlugin = Ext.extend(Deluge.Plugin, {
constructor: function(config) { constructor: function(config) {
config = Ext.apply({ config = Ext.apply(
name: "Toggle" {
}, config); name: 'Toggle',
},
config
);
TogglePlugin.superclass.constructor.call(this, config); TogglePlugin.superclass.constructor.call(this, config);
}, },
onDisable: function() { onDisable: function() {},
}, onEnable: function() {},
onEnable: function() {
}
}); });
new TogglePlugin(); new TogglePlugin();

View File

@ -1,10 +1,11 @@
html, body { html,
body {
font: normal 11px arial, tahoma, helvetica, sans-serif; font: normal 11px arial, tahoma, helvetica, sans-serif;
margin: 0; margin: 0;
padding: 0; padding: 0;
border: 0 none; border: 0 none;
overflow: hidden; overflow: hidden;
height:100%; height: 100%;
} }
input { input {
@ -21,7 +22,7 @@ button::-moz-focus-inner {
} }
#tbar-deluge-text.x-item-disabled * { #tbar-deluge-text.x-item-disabled * {
color:black !important; color: black !important;
font-weight: bold; font-weight: bold;
} }
@ -29,13 +30,15 @@ button::-moz-focus-inner {
opacity: 1 !important; opacity: 1 !important;
} }
.deluge-torrents td,
.deluge-torrents td, .x-deluge-peers td { .x-deluge-peers td {
height: 16px; height: 16px;
line-height: 16px; line-height: 16px;
} }
.deluge-torrents .torrent-name, .x-deluge-peer, .x-deluge-seed { .deluge-torrents .torrent-name,
.x-deluge-peer,
.x-deluge-seed {
padding-left: 20px; padding-left: 20px;
background-repeat: no-repeat; background-repeat: no-repeat;
} }
@ -45,40 +48,95 @@ button::-moz-focus-inner {
} }
/* Icon classes */ /* Icon classes */
.x-deluge-all { background-image: url('../icons/all.png'); } .x-deluge-all {
.x-deluge-active { background-image: url('../icons/active.png'); } background-image: url('../icons/all.png');
.x-deluge-downloading, .x-btn .x-deluge-downloading, .x-deluge-peer { background-image: url('../icons/downloading.png'); } }
.x-deluge-seeding, .x-btn .x-deluge-seeding, .deluge-torrents .seeding, .x-deluge-seed { background-image: url('../icons/seeding.png'); } .x-deluge-active {
.x-deluge-queued, .x-btn .x-deluge-queued, .deluge-torrents .queued { background-image: url('../icons/queued.png'); } background-image: url('../icons/active.png');
.x-deluge-paused, .x-btn .x-deluge-paused, .deluge-torrents .paused { background-image: url('../icons/inactive.png'); } }
.x-deluge-error, .deluge-torrents .error { background-image: url('../icons/alert.png'); } .x-deluge-downloading,
.x-deluge-checking, .deluge-torrents .checking { background-image: url('../icons/checking.png'); } .x-btn .x-deluge-downloading,
.x-deluge-dht, .x-btn .x-deluge-dht { background-image: url('../icons/dht.png'); } .x-deluge-peer {
.x-deluge-preferences, .x-btn .x-deluge-preferences { background-image: url('../icons/preferences.png') } background-image: url('../icons/downloading.png');
.x-deluge-connections, .x-btn .x-deluge-connections { background-image: url('../icons/connections.png') } }
.x-deluge-connection-manager, .x-btn .x-deluge-connection-manager { background-image: url('../icons/connection_manager.png') } .x-deluge-seeding,
.x-deluge-traffic, .x-btn .x-deluge-traffic { background-image: url('../icons/traffic.png') } .x-btn .x-deluge-seeding,
.x-deluge-edit-trackers, .x-btn .x-deluge-edit-trackers {background-image: url('../icons/edit_trackers.png'); } .deluge-torrents .seeding,
.x-deluge-freespace, .x-btn .x-deluge-freespace {background-image: url('../icons/drive.png'); } .x-deluge-seed {
background-image: url('../icons/seeding.png');
.x-deluge-install-plugin, .x-btn .x-deluge-install-plugin {background-image: url('../icons/install_plugin.png'); } }
.x-deluge-find-more, .x-btn .x-deluge-find-more {background-image: url('../icons/find_more.png'); } .x-deluge-queued,
.x-btn .x-deluge-queued,
.deluge-torrents .queued {
background-image: url('../icons/queued.png');
}
.x-deluge-paused,
.x-btn .x-deluge-paused,
.deluge-torrents .paused {
background-image: url('../icons/inactive.png');
}
.x-deluge-error,
.deluge-torrents .error {
background-image: url('../icons/alert.png');
}
.x-deluge-checking,
.deluge-torrents .checking {
background-image: url('../icons/checking.png');
}
.x-deluge-dht,
.x-btn .x-deluge-dht {
background-image: url('../icons/dht.png');
}
.x-deluge-preferences,
.x-btn .x-deluge-preferences {
background-image: url('../icons/preferences.png');
}
.x-deluge-connections,
.x-btn .x-deluge-connections {
background-image: url('../icons/connections.png');
}
.x-deluge-connection-manager,
.x-btn .x-deluge-connection-manager {
background-image: url('../icons/connection_manager.png');
}
.x-deluge-traffic,
.x-btn .x-deluge-traffic {
background-image: url('../icons/traffic.png');
}
.x-deluge-edit-trackers,
.x-btn .x-deluge-edit-trackers {
background-image: url('../icons/edit_trackers.png');
}
.x-deluge-freespace,
.x-btn .x-deluge-freespace {
background-image: url('../icons/drive.png');
}
.x-deluge-install-plugin,
.x-btn .x-deluge-install-plugin {
background-image: url('../icons/install_plugin.png');
}
.x-deluge-find-more,
.x-btn .x-deluge-find-more {
background-image: url('../icons/find_more.png');
}
/* Torrent Details */ /* Torrent Details */
#torrentDetails dl, #torrentDetails dl.singleline { #torrentDetails dl,
#torrentDetails dl.singleline {
float: left; float: left;
min-height: 120px; min-height: 120px;
} }
#torrentDetails dl dt, dl.singleline dt { #torrentDetails dl dt,
dl.singleline dt {
float: left; float: left;
font-weight: bold; font-weight: bold;
height: 19px; height: 19px;
} }
#torrentDetails dl dd, dl.singleline dd { #torrentDetails dl dd,
dl.singleline dd {
margin-left: 100px; margin-left: 100px;
width: 140px; width: 140px;
height: 19px; height: 19px;
@ -185,7 +243,8 @@ dl.singleline dd {
} }
/* Add Url Window */ /* Add Url Window */
.x-deluge-add-file, .x-btn .x-deluge-add-file { .x-deluge-add-file,
.x-btn .x-deluge-add-file {
background: url('../icons/add_file.png') no-repeat 2px; background: url('../icons/add_file.png') no-repeat 2px;
} }
@ -280,11 +339,11 @@ dl.singleline dd {
} }
.x-treegrid-resizer { .x-treegrid-resizer {
border-left:1px solid; border-left: 1px solid;
border-right:1px solid; border-right: 1px solid;
position:absolute; position: absolute;
left:0; left: 0;
top:0; top: 0;
} }
.x-treegrid-header-inner { .x-treegrid-header-inner {
@ -297,8 +356,8 @@ dl.singleline dd {
} }
.x-treegrid-resizer { .x-treegrid-resizer {
border-left-color:#555; border-left-color: #555;
border-right-color:#555; border-right-color: #555;
} }
/* Options Tab Styles */ /* Options Tab Styles */
@ -348,7 +407,11 @@ dl.singleline dd {
} }
/* Filepriority styles */ /* Filepriority styles */
.x-no-download, .x-low-download, .x-normal-download, .x-high-download, .x-mixed-download { .x-no-download,
.x-low-download,
.x-normal-download,
.x-high-download,
.x-mixed-download {
padding-left: 20px; padding-left: 20px;
background-repeat: no-repeat; background-repeat: no-repeat;
line-height: 16px; line-height: 16px;
@ -431,7 +494,8 @@ dl.singleline dd {
background-image: url('../icons/update.png') !important; background-image: url('../icons/update.png') !important;
} }
.icon-edit-trackers, .icon-edit { .icon-edit-trackers,
.icon-edit {
background-image: url('../icons/edit_trackers.png') !important; background-image: url('../icons/edit_trackers.png') !important;
} }

View File

@ -14,12 +14,11 @@ Ext.ns('Deluge');
* @extends Ext.Window * @extends Ext.Window
*/ */
Deluge.AddConnectionWindow = Ext.extend(Ext.Window, { Deluge.AddConnectionWindow = Ext.extend(Ext.Window, {
title: _('Add Connection'), title: _('Add Connection'),
iconCls: 'x-deluge-add-window-icon', iconCls: 'x-deluge-add-window-icon',
layout: 'fit', layout: 'fit',
width: 300, width: 300,
height: 195, height: 195,
constrainHeader: true, constrainHeader: true,
bodyStyle: 'padding: 10px 5px;', bodyStyle: 'padding: 10px 5px;',
@ -40,65 +39,79 @@ Deluge.AddConnectionWindow = Ext.extend(Ext.Window, {
defaultType: 'textfield', defaultType: 'textfield',
baseCls: 'x-plain', baseCls: 'x-plain',
labelWidth: 60, labelWidth: 60,
items: [{ items: [
fieldLabel: _('Host:'), {
labelSeparator : '', fieldLabel: _('Host:'),
name: 'host', labelSeparator: '',
anchor: '75%', name: 'host',
value: '' anchor: '75%',
}, { value: '',
xtype: 'spinnerfield',
fieldLabel: _('Port:'),
labelSeparator : '',
name: 'port',
strategy: {
xtype: 'number',
decimalPrecision: 0,
minValue: -1,
maxValue: 65535
}, },
value: '58846', {
anchor: '40%' xtype: 'spinnerfield',
}, { fieldLabel: _('Port:'),
fieldLabel: _('Username:'), labelSeparator: '',
labelSeparator : '', name: 'port',
name: 'username', strategy: {
anchor: '75%', xtype: 'number',
value: '' decimalPrecision: 0,
}, { minValue: -1,
fieldLabel: _('Password:'), maxValue: 65535,
labelSeparator : '', },
anchor: '75%', value: '58846',
name: 'password', anchor: '40%',
inputType: 'password', },
value: '' {
}] fieldLabel: _('Username:'),
labelSeparator: '',
name: 'username',
anchor: '75%',
value: '',
},
{
fieldLabel: _('Password:'),
labelSeparator: '',
anchor: '75%',
name: 'password',
inputType: 'password',
value: '',
},
],
}); });
}, },
onAddClick: function() { onAddClick: function() {
var values = this.form.getForm().getValues(); var values = this.form.getForm().getValues();
deluge.client.web.add_host(values.host, Number(values.port), values.username, values.password, { deluge.client.web.add_host(
success: function(result) { values.host,
if (!result[0]) { Number(values.port),
Ext.MessageBox.show({ values.username,
title: _('Error'), values.password,
msg: String.format(_('Unable to add host: {0}'), result[1]), {
buttons: Ext.MessageBox.OK, success: function(result) {
modal: false, if (!result[0]) {
icon: Ext.MessageBox.ERROR, Ext.MessageBox.show({
iconCls: 'x-deluge-icon-error' title: _('Error'),
}); msg: String.format(
} else { _('Unable to add host: {0}'),
this.fireEvent('hostadded'); result[1]
} ),
this.hide(); buttons: Ext.MessageBox.OK,
}, modal: false,
scope: this icon: Ext.MessageBox.ERROR,
}); iconCls: 'x-deluge-icon-error',
});
} else {
this.fireEvent('hostadded');
}
this.hide();
},
scope: this,
}
);
}, },
onHide: function() { onHide: function() {
this.form.getForm().reset(); this.form.getForm().reset();
} },
}); });

View File

@ -12,10 +12,10 @@ Ext.ns('Deluge');
// Custom VType validator for tracker urls // Custom VType validator for tracker urls
var trackerUrlTest = /(((^https?)|(^udp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i; var trackerUrlTest = /(((^https?)|(^udp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
Ext.apply(Ext.form.VTypes, { Ext.apply(Ext.form.VTypes, {
trackerUrl: function(val, field) { trackerUrl: function(val, field) {
return trackerUrlTest.test(val); return trackerUrlTest.test(val);
}, },
trackerUrlText: 'Not a valid tracker url' trackerUrlText: 'Not a valid tracker url',
}); });
/** /**
@ -23,7 +23,6 @@ Ext.apply(Ext.form.VTypes, {
* @extends Ext.Window * @extends Ext.Window
*/ */
Deluge.AddTrackerWindow = Ext.extend(Ext.Window, { Deluge.AddTrackerWindow = Ext.extend(Ext.Window, {
title: _('Add Tracker'), title: _('Add Tracker'),
layout: 'fit', layout: 'fit',
width: 375, width: 375,
@ -49,32 +48,47 @@ Deluge.AddTrackerWindow = Ext.extend(Ext.Window, {
defaultType: 'textarea', defaultType: 'textarea',
baseCls: 'x-plain', baseCls: 'x-plain',
labelWidth: 55, labelWidth: 55,
items: [{ items: [
fieldLabel: _('Trackers:'), {
labelSeparator: '', fieldLabel: _('Trackers:'),
name: 'trackers', labelSeparator: '',
anchor: '100%' name: 'trackers',
}] anchor: '100%',
}) },
],
});
}, },
onAddClick: function() { onAddClick: function() {
var trackers = this.form.getForm().findField('trackers').getValue(); var trackers = this.form
.getForm()
.findField('trackers')
.getValue();
trackers = trackers.split('\n'); trackers = trackers.split('\n');
var cleaned = []; var cleaned = [];
Ext.each(trackers, function(tracker) { Ext.each(
if (Ext.form.VTypes.trackerUrl(tracker)) { trackers,
cleaned.push(tracker); function(tracker) {
} if (Ext.form.VTypes.trackerUrl(tracker)) {
}, this); cleaned.push(tracker);
}
},
this
);
this.fireEvent('add', cleaned); this.fireEvent('add', cleaned);
this.hide(); this.hide();
this.form.getForm().findField('trackers').setValue(''); this.form
.getForm()
.findField('trackers')
.setValue('');
}, },
onCancelClick: function() { onCancelClick: function() {
this.form.getForm().findField('trackers').setValue(''); this.form
.getForm()
.findField('trackers')
.setValue('');
this.hide(); this.hide();
} },
}); });

View File

@ -16,7 +16,6 @@ Ext.namespace('Ext.ux.util');
* @namespace Ext.ux.util * @namespace Ext.ux.util
*/ */
Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, { Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, {
_components: [], _components: [],
_methods: [], _methods: [],
@ -33,15 +32,14 @@ Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, {
* @param {Ext.ux.util.RpcClient} this * @param {Ext.ux.util.RpcClient} this
*/ */
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
'connected', 'connected',
'error' 'error'
); );
this.reloadMethods(); this.reloadMethods();
}, },
@ -49,7 +47,7 @@ Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, {
reloadMethods: function() { reloadMethods: function() {
this._execute('system.listMethods', { this._execute('system.listMethods', {
success: this._setMethods, success: this._setMethods,
scope: this scope: this,
}); });
}, },
@ -61,7 +59,7 @@ Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, {
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++;
@ -72,7 +70,7 @@ Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, {
failure: this._onFailure, failure: this._onFailure,
scope: this, scope: this,
jsonData: request, jsonData: request,
options: options options: options,
}); });
}, },
@ -83,15 +81,20 @@ Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, {
result: null, result: null,
error: { error: {
msg: 'HTTP: ' + response.status + ' ' + response.statusText, msg: 'HTTP: ' + response.status + ' ' + response.statusText,
code: 255 code: 255,
} },
} };
this.fireEvent('error', errorObj, response, requestOptions) this.fireEvent('error', errorObj, response, requestOptions);
if (Ext.type(options.failure) != 'function') return; if (Ext.type(options.failure) != 'function') return;
if (options.scope) { if (options.scope) {
options.failure.call(options.scope, errorObj, response, requestOptions); options.failure.call(
options.scope,
errorObj,
response,
requestOptions
);
} else { } else {
options.failure(errorObj, response, requestOptions); options.failure(errorObj, response, requestOptions);
} }
@ -105,16 +108,32 @@ Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, {
if (Ext.type(options.failure) != 'function') return; if (Ext.type(options.failure) != 'function') return;
if (options.scope) { if (options.scope) {
options.failure.call(options.scope, responseObj, response, requestOptions); options.failure.call(
options.scope,
responseObj,
response,
requestOptions
);
} else { } else {
options.failure(responseObj, response, requestOptions); options.failure(responseObj, response, requestOptions);
} }
} else { } else {
if (Ext.type(options.success) != 'function') return; if (Ext.type(options.success) != 'function') return;
if (options.scope) { if (options.scope) {
options.success.call(options.scope, responseObj.result, responseObj, response, requestOptions); options.success.call(
options.scope,
responseObj.result,
responseObj,
response,
requestOptions
);
} else { } else {
options.success(responseObj.result, responseObj, response, requestOptions); options.success(
responseObj.result,
responseObj,
response,
requestOptions
);
} }
} }
}, },
@ -127,26 +146,28 @@ Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, {
var options = params[params.length - 1]; var options = params[params.length - 1];
if (Ext.type(options) == 'object') { if (Ext.type(options) == 'object') {
var keys = Ext.keys(options), isOption = false; var keys = Ext.keys(options),
isOption = false;
Ext.each(this._optionKeys, function(key) { Ext.each(this._optionKeys, function(key) {
if (keys.indexOf(key) > -1) isOption = true; if (keys.indexOf(key) > -1) isOption = true;
}); });
if (isOption) { if (isOption) {
params.remove(options) params.remove(options);
} else { } else {
options = {} options = {};
} }
} else { } else {
options = {} options = {};
} }
options.params = params; options.params = params;
return options; return options;
}, },
_setMethods: function(methods) { _setMethods: function(methods) {
var components = {}, self = this; var components = {},
self = this;
Ext.each(methods, function(method) { Ext.each(methods, function(method) {
var parts = method.split('.'); var parts = method.split('.');
@ -155,7 +176,7 @@ Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, {
var fn = function() { var fn = function() {
var options = self._parseArgs(arguments); var options = self._parseArgs(arguments);
return self._execute(method, options); return self._execute(method, options);
} };
component[parts[1]] = fn; component[parts[1]] = fn;
components[parts[0]] = component; components[parts[0]] = component;
}); });
@ -163,12 +184,16 @@ Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, {
for (var name in components) { for (var name in components) {
self[name] = components[name]; self[name] = components[name];
} }
Ext.each(this._components, function(component) { Ext.each(
if (!component in components) { this._components,
delete this[component]; function(component) {
} if (!component in components) {
}, this); delete this[component];
}
},
this
);
this._components = Ext.keys(components); this._components = Ext.keys(components);
this.fireEvent('connected', this); this.fireEvent('connected', this);
} },
}); });

View File

@ -9,7 +9,6 @@
*/ */
Deluge.ConnectionManager = Ext.extend(Ext.Window, { Deluge.ConnectionManager = Ext.extend(Ext.Window, {
layout: 'fit', layout: 'fit',
width: 300, width: 300,
height: 220, height: 220,
@ -24,7 +23,7 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, {
initComponent: function() { initComponent: function() {
Deluge.ConnectionManager.superclass.initComponent.call(this); Deluge.ConnectionManager.superclass.initComponent.call(this);
this.on('hide', this.onHide, this); this.on('hide', this.onHide, this);
this.on('show', this.onShow, this); this.on('show', this.onShow, this);
deluge.events.on('login', this.onLogin, this); deluge.events.on('login', this.onLogin, this);
@ -36,47 +35,52 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, {
this.list = new Ext.list.ListView({ this.list = new Ext.list.ListView({
store: new Ext.data.ArrayStore({ store: new Ext.data.ArrayStore({
fields: [ fields: [
{name: 'status', mapping: 4}, { name: 'status', mapping: 4 },
{name: 'host', mapping: 1}, { name: 'host', mapping: 1 },
{name: 'port', mapping: 2}, { name: 'port', mapping: 2 },
{name: 'user', mapping: 3}, { name: 'user', mapping: 3 },
{name: 'version', mapping: 5} { name: 'version', mapping: 5 },
], ],
id: 0 id: 0,
}), }),
columns: [{ columns: [
header: _('Status'), {
width: .24, header: _('Status'),
sortable: true, width: 0.24,
tpl: new Ext.XTemplate( sortable: true,
'<tpl if="status == \'Online\'">', tpl: new Ext.XTemplate(
'<tpl if="status == \'Online\'">',
_('Online'), _('Online'),
'</tpl>', '</tpl>',
'<tpl if="status == \'Offline\'">', '<tpl if="status == \'Offline\'">',
_('Offline'), _('Offline'),
'</tpl>', '</tpl>',
'<tpl if="status == \'Connected\'">', '<tpl if="status == \'Connected\'">',
_('Connected'), _('Connected'),
'</tpl>'), '</tpl>'
dataIndex: 'status' ),
}, { dataIndex: 'status',
id:'host', },
header: _('Host'), {
width: .51, id: 'host',
sortable: true, header: _('Host'),
tpl: '{user}@{host}:{port}', width: 0.51,
dataIndex: 'host' sortable: true,
}, { tpl: '{user}@{host}:{port}',
header: _('Version'), dataIndex: 'host',
width: .25, },
sortable: true, {
tpl: '<tpl if="version">{version}</tpl>', header: _('Version'),
dataIndex: 'version' width: 0.25,
}], sortable: true,
tpl: '<tpl if="version">{version}</tpl>',
dataIndex: 'version',
},
],
singleSelect: true, singleSelect: true,
listeners: { listeners: {
'selectionchange': {fn: this.onSelectionChanged, scope: this} selectionchange: { fn: this.onSelectionChanged, scope: this },
} },
}); });
this.panel = this.add({ this.panel = this.add({
@ -90,33 +94,37 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, {
text: _('Add'), text: _('Add'),
iconCls: 'icon-add', iconCls: 'icon-add',
handler: this.onAddClick, handler: this.onAddClick,
scope: this scope: this,
}, { },
{
id: 'cm-edit', id: 'cm-edit',
cls: 'x-btn-text-icon', cls: 'x-btn-text-icon',
text: _('Edit'), text: _('Edit'),
iconCls: 'icon-edit', iconCls: 'icon-edit',
handler: this.onEditClick, handler: this.onEditClick,
scope: this scope: this,
}, { },
{
id: 'cm-remove', id: 'cm-remove',
cls: 'x-btn-text-icon', cls: 'x-btn-text-icon',
text: _('Remove'), text: _('Remove'),
iconCls: 'icon-remove', iconCls: 'icon-remove',
handler: this.onRemoveClick, handler: this.onRemoveClick,
disabled: true, disabled: true,
scope: this scope: this,
}, '->', { },
'->',
{
id: 'cm-stop', id: 'cm-stop',
cls: 'x-btn-text-icon', cls: 'x-btn-text-icon',
text: _('Stop Daemon'), text: _('Stop Daemon'),
iconCls: 'icon-error', iconCls: 'icon-error',
handler: this.onStopClick, handler: this.onStopClick,
disabled: true, disabled: true,
scope: this scope: this,
} },
] ],
}) }),
}); });
this.update = this.update.createDelegate(this); this.update = this.update.createDelegate(this);
}, },
@ -134,7 +142,7 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, {
this.show(); this.show();
} }
}, },
scope: this scope: this,
}); });
}, },
@ -149,7 +157,7 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, {
loadHosts: function() { loadHosts: function() {
deluge.client.web.get_hosts({ deluge.client.web.get_hosts({
success: this.onGetHosts, success: this.onGetHosts,
scope: this scope: this,
}); });
}, },
@ -157,7 +165,7 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, {
this.list.getStore().each(function(r) { this.list.getStore().each(function(r) {
deluge.client.web.get_host_status(r.id, { deluge.client.web.get_host_status(r.id, {
success: this.onGetHostStatus, success: this.onGetHostStatus,
scope: this scope: this,
}); });
}, this); }, this);
}, },
@ -168,7 +176,8 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, {
* @param {Ext.data.Record} record The hosts record to update the UI for * @param {Ext.data.Record} record The hosts record to update the UI for
*/ */
updateButtons: function(record) { updateButtons: function(record) {
var button = this.buttons[1], status = record.get('status'); var button = this.buttons[1],
status = record.get('status');
// Update the Connect/Disconnect button // Update the Connect/Disconnect button
button.enable(); button.enable();
@ -180,11 +189,17 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, {
} }
// Update the Stop/Start Daemon button // Update the Stop/Start Daemon button
if (status.toLowerCase() == 'connected' || status.toLowerCase() == 'online') { if (
status.toLowerCase() == 'connected' ||
status.toLowerCase() == 'online'
) {
this.stopHostButton.enable(); this.stopHostButton.enable();
this.stopHostButton.setText(_('Stop Daemon')); this.stopHostButton.setText(_('Stop Daemon'));
} else { } else {
if (record.get('host') == '127.0.0.1' || record.get('host') == 'localhost') { if (
record.get('host') == '127.0.0.1' ||
record.get('host') == 'localhost'
) {
this.stopHostButton.enable(); this.stopHostButton.enable();
this.stopHostButton.setText(_('Start Daemon')); this.stopHostButton.setText(_('Start Daemon'));
} else { } else {
@ -236,26 +251,38 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, {
this.update(this); this.update(this);
deluge.events.fire('disconnect'); deluge.events.fire('disconnect');
}, },
scope: me scope: me,
}); });
}; };
if (selected.get('status').toLowerCase() == 'connected') { if (selected.get('status').toLowerCase() == 'connected') {
disconnect(); disconnect();
} else { } else {
if (this.list.getStore().find('status', 'Connected', 0, false, false) > -1) { if (
this.list
.getStore()
.find('status', 'Connected', 0, false, false) > -1
) {
disconnect(); disconnect();
} }
var id = selected.id; var id = selected.id;
deluge.client.web.connect(id, { deluge.client.web.connect(
success: function(methods) { id,
deluge.client.reloadMethods(); {
deluge.client.on('connected', function(e) { success: function(methods) {
deluge.events.fire('connect'); deluge.client.reloadMethods();
}, this, {single: true}); deluge.client.on(
'connected',
function(e) {
deluge.events.fire('connect');
},
this,
{ single: true }
);
},
} }
}); );
this.hide(); this.hide();
} }
}, },
@ -263,21 +290,25 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, {
// private // private
onGetHosts: function(hosts) { onGetHosts: function(hosts) {
this.list.getStore().loadData(hosts); this.list.getStore().loadData(hosts);
Ext.each(hosts, function(host) { Ext.each(
deluge.client.web.get_host_status(host[0], { hosts,
success: this.onGetHostStatus, function(host) {
scope: this deluge.client.web.get_host_status(host[0], {
}); success: this.onGetHostStatus,
}, this); scope: this,
});
},
this
);
}, },
// private // private
onGetHostStatus: function(host) { onGetHostStatus: function(host) {
var record = this.list.getStore().getById(host[0]); var record = this.list.getStore().getById(host[0]);
record.set('status', host[1]) record.set('status', host[1]);
record.set('version', host[2]) record.set('version', host[2]);
record.commit(); record.commit();
var selected = this.list.getSelectedRecords()[0] var selected = this.list.getSelectedRecords()[0];
if (!selected) return; if (!selected) return;
if (selected == record) this.updateButtons(record); if (selected == record) this.updateButtons(record);
}, },
@ -290,16 +321,21 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, {
// private // private
onLogin: function() { onLogin: function() {
if (deluge.config.first_login) { if (deluge.config.first_login) {
Ext.MessageBox.confirm(_('Change Default Password'), Ext.MessageBox.confirm(
_('We recommend changing the default password.<br><br>Would you like to change it now?'), _('Change Default Password'),
_(
'We recommend changing the default password.<br><br>Would you like to change it now?'
),
function(res) { function(res) {
this.checkConnected(); this.checkConnected();
if (res == 'yes') { if (res == 'yes') {
deluge.preferences.show(); deluge.preferences.show();
deluge.preferences.selectPage('Interface'); deluge.preferences.selectPage('Interface');
} }
deluge.client.web.set_config({first_login: false}); deluge.client.web.set_config({ first_login: false });
}, this); },
this
);
} else { } else {
this.checkConnected(); this.checkConnected();
} }
@ -327,13 +363,13 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, {
buttons: Ext.MessageBox.OK, buttons: Ext.MessageBox.OK,
modal: false, modal: false,
icon: Ext.MessageBox.ERROR, icon: Ext.MessageBox.ERROR,
iconCls: 'x-deluge-icon-error' iconCls: 'x-deluge-icon-error',
}); });
} else { } else {
this.list.getStore().remove(connection); this.list.getStore().remove(connection);
} }
}, },
scope: this scope: this,
}); });
}, },
@ -386,11 +422,11 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, {
buttons: Ext.MessageBox.OK, buttons: Ext.MessageBox.OK,
modal: false, modal: false,
icon: Ext.MessageBox.ERROR, icon: Ext.MessageBox.ERROR,
iconCls: 'x-deluge-icon-error' iconCls: 'x-deluge-icon-error',
}); });
} }
} },
}); });
} }
} },
}); });

View File

@ -9,25 +9,33 @@
*/ */
// Setup the state manager // Setup the state manager
Ext.state.Manager.setProvider(new Ext.state.CookieProvider({ Ext.state.Manager.setProvider(
/** new Ext.state.CookieProvider({
* By default, cookies will expire after 7 days. Provide /**
* an expiry date 10 years in the future to approximate * By default, cookies will expire after 7 days. Provide
* a cookie that does not expire. * an expiry date 10 years in the future to approximate
*/ * a cookie that does not expire.
expires: new Date(new Date().getTime() + (1000 * 60 * 60 * 24 * 365 * 10)) */
})); expires: new Date(
new Date().getTime() + 1000 * 60 * 60 * 24 * 365 * 10
),
})
);
// Add some additional functions to ext and setup some of the // Add some additional functions to ext and setup some of the
// configurable parameters // configurable parameters
Ext.apply(Ext, { Ext.apply(Ext, {
escapeHTML: function(text) { escapeHTML: function(text) {
text = String(text).replace('<', '&lt;').replace('>', '&gt;'); text = String(text)
.replace('<', '&lt;')
.replace('>', '&gt;');
return text.replace('&', '&amp;'); return text.replace('&', '&amp;');
}, },
isObjectEmpty: function(obj) { isObjectEmpty: function(obj) {
for(var i in obj) { return false; } for (var i in obj) {
return false;
}
return true; return true;
}, },
@ -44,10 +52,10 @@ Ext.apply(Ext, {
keys: function(obj) { keys: function(obj) {
var keys = []; var keys = [];
for (var i in obj) if (obj.hasOwnProperty(i)) for (var i in obj)
{ if (obj.hasOwnProperty(i)) {
keys.push(i); keys.push(i);
} }
return keys; return keys;
}, },
@ -63,8 +71,8 @@ Ext.apply(Ext, {
splat: function(obj) { splat: function(obj) {
var type = Ext.type(obj); var type = Ext.type(obj);
return (type) ? ((type != 'array') ? [obj] : obj) : []; return type ? (type != 'array' ? [obj] : obj) : [];
} },
}); });
Ext.getKeys = Ext.keys; Ext.getKeys = Ext.keys;
Ext.BLANK_IMAGE_URL = deluge.config.base + 'images/s.gif'; Ext.BLANK_IMAGE_URL = deluge.config.base + 'images/s.gif';
@ -72,24 +80,23 @@ Ext.USE_NATIVE_JSON = true;
// Create the Deluge namespace // Create the Deluge namespace
Ext.apply(Deluge, { Ext.apply(Deluge, {
// private // private
pluginStore: {}, pluginStore: {},
// private // private
progressTpl: '<div class="x-progress-wrap x-progress-renderered">' + progressTpl:
'<div class="x-progress-inner">' + '<div class="x-progress-wrap x-progress-renderered">' +
'<div style="width: {2}px" class="x-progress-bar">' + '<div class="x-progress-inner">' +
'<div style="z-index: 99; width: {3}px" class="x-progress-text">' + '<div style="width: {2}px" class="x-progress-bar">' +
'<div style="width: {1}px;">{0}</div>' + '<div style="z-index: 99; width: {3}px" class="x-progress-text">' +
'</div>' + '<div style="width: {1}px;">{0}</div>' +
'</div>' + '</div>' +
'<div class="x-progress-text x-progress-text-back">' + '</div>' +
'<div style="width: {1}px;">{0}</div>' + '<div class="x-progress-text x-progress-text-back">' +
'</div>' + '<div style="width: {1}px;">{0}</div>' +
'</div>' + '</div>' +
'</div>', '</div>' +
'</div>',
/** /**
* A method to create a progress bar that can be used by renderers * A method to create a progress bar that can be used by renderers
@ -103,8 +110,15 @@ Ext.apply(Deluge, {
modifier = Ext.value(modifier, 10); modifier = Ext.value(modifier, 10);
var progressWidth = ((width / 100.0) * progress).toFixed(0); var progressWidth = ((width / 100.0) * progress).toFixed(0);
var barWidth = progressWidth - 1; var barWidth = progressWidth - 1;
var textWidth = ((progressWidth - modifier) > 0 ? progressWidth - modifier : 0); var textWidth =
return String.format(Deluge.progressTpl, text, width, barWidth, textWidth); progressWidth - modifier > 0 ? progressWidth - modifier : 0;
return String.format(
Deluge.progressTpl,
text,
width,
barWidth,
textWidth
);
}, },
/** /**
@ -120,7 +134,7 @@ Ext.apply(Deluge, {
* @param {String} name The plugin name to check * @param {String} name The plugin name to check
*/ */
hasPlugin: function(name) { hasPlugin: function(name) {
return (Deluge.pluginStore[name]) ? true : false; return Deluge.pluginStore[name] ? true : false;
}, },
/** /**
@ -130,8 +144,7 @@ Ext.apply(Deluge, {
*/ */
registerPlugin: function(name, plugin) { registerPlugin: function(name, plugin) {
Deluge.pluginStore[name] = plugin; Deluge.pluginStore[name] = plugin;
} },
}); });
// Setup a space for plugins to insert themselves // Setup a space for plugins to insert themselves
@ -152,12 +165,12 @@ FILE_PRIORITY = {
6: 'High', 6: 'High',
7: 'High', 7: 'High',
9: 'Mixed', 9: 'Mixed',
'Ignore': 0, Ignore: 0,
'Low': 1, Low: 1,
'Normal': 4, Normal: 4,
'High': 7, High: 7,
'Mixed': 9 Mixed: 9,
} };
FILE_PRIORITY_CSS = { FILE_PRIORITY_CSS = {
0: 'x-no-download', 0: 'x-no-download',
@ -168,5 +181,5 @@ FILE_PRIORITY_CSS = {
5: 'x-high-download', 5: 'x-high-download',
6: 'x-high-download', 6: 'x-high-download',
7: 'x-high-download', 7: 'x-high-download',
9: 'x-mixed-download' 9: 'x-mixed-download',
} };

View File

@ -14,12 +14,11 @@ Ext.ns('Deluge');
* @extends Ext.Window * @extends Ext.Window
*/ */
Deluge.EditConnectionWindow = Ext.extend(Ext.Window, { Deluge.EditConnectionWindow = Ext.extend(Ext.Window, {
title: _('Edit Connection'), title: _('Edit Connection'),
iconCls: 'x-deluge-add-window-icon', iconCls: 'x-deluge-add-window-icon',
layout: 'fit', layout: 'fit',
width: 300, width: 300,
height: 195, height: 195,
constrainHeader: true, constrainHeader: true,
bodyStyle: 'padding: 10px 5px;', bodyStyle: 'padding: 10px 5px;',
@ -40,75 +39,96 @@ Deluge.EditConnectionWindow = Ext.extend(Ext.Window, {
defaultType: 'textfield', defaultType: 'textfield',
baseCls: 'x-plain', baseCls: 'x-plain',
labelWidth: 60, labelWidth: 60,
items: [{ items: [
fieldLabel: _('Host:'), {
labelSeparator : '', fieldLabel: _('Host:'),
name: 'host', labelSeparator: '',
anchor: '75%', name: 'host',
value: '' anchor: '75%',
}, { value: '',
xtype: 'spinnerfield',
fieldLabel: _('Port:'),
labelSeparator : '',
name: 'port',
strategy: {
xtype: 'number',
decimalPrecision: 0,
minValue: 0,
maxValue: 65535
}, },
anchor: '40%', {
value: 58846 xtype: 'spinnerfield',
}, { fieldLabel: _('Port:'),
fieldLabel: _('Username:'), labelSeparator: '',
labelSeparator : '', name: 'port',
name: 'username', strategy: {
anchor: '75%', xtype: 'number',
value: '' decimalPrecision: 0,
}, { minValue: 0,
fieldLabel: _('Password:'), maxValue: 65535,
labelSeparator : '', },
anchor: '75%', anchor: '40%',
name: 'password', value: 58846,
inputType: 'password', },
value: '' {
}] fieldLabel: _('Username:'),
labelSeparator: '',
name: 'username',
anchor: '75%',
value: '',
},
{
fieldLabel: _('Password:'),
labelSeparator: '',
anchor: '75%',
name: 'password',
inputType: 'password',
value: '',
},
],
}); });
}, },
show: function(connection) { show: function(connection) {
Deluge.EditConnectionWindow.superclass.show.call(this); Deluge.EditConnectionWindow.superclass.show.call(this);
this.form.getForm().findField('host').setValue(connection.get('host')); this.form
this.form.getForm().findField('port').setValue(connection.get('port')); .getForm()
this.form.getForm().findField('username').setValue(connection.get('user')); .findField('host')
this.host_id = connection.id .setValue(connection.get('host'));
this.form
.getForm()
.findField('port')
.setValue(connection.get('port'));
this.form
.getForm()
.findField('username')
.setValue(connection.get('user'));
this.host_id = connection.id;
}, },
onEditClick: function() { onEditClick: function() {
var values = this.form.getForm().getValues(); var values = this.form.getForm().getValues();
deluge.client.web.edit_host(this.host_id, values.host, Number(values.port), values.username, values.password, { deluge.client.web.edit_host(
success: function(result) { this.host_id,
if (!result) { values.host,
console.log(result) Number(values.port),
Ext.MessageBox.show({ values.username,
title: _('Error'), values.password,
msg: String.format(_('Unable to edit host')), {
buttons: Ext.MessageBox.OK, success: function(result) {
modal: false, if (!result) {
icon: Ext.MessageBox.ERROR, console.log(result);
iconCls: 'x-deluge-icon-error' Ext.MessageBox.show({
}); title: _('Error'),
} else { msg: String.format(_('Unable to edit host')),
this.fireEvent('hostedited'); buttons: Ext.MessageBox.OK,
} modal: false,
this.hide(); icon: Ext.MessageBox.ERROR,
}, iconCls: 'x-deluge-icon-error',
scope: this });
}); } else {
this.fireEvent('hostedited');
}
this.hide();
},
scope: this,
}
);
}, },
onHide: function() { onHide: function() {
this.form.getForm().reset(); this.form.getForm().reset();
} },
}); });

View File

@ -14,7 +14,6 @@ Ext.ns('Deluge');
* @extends Ext.Window * @extends Ext.Window
*/ */
Deluge.EditTrackerWindow = Ext.extend(Ext.Window, { Deluge.EditTrackerWindow = Ext.extend(Ext.Window, {
title: _('Edit Tracker'), title: _('Edit Tracker'),
layout: 'fit', layout: 'fit',
width: 375, width: 375,
@ -40,12 +39,14 @@ Deluge.EditTrackerWindow = Ext.extend(Ext.Window, {
defaultType: 'textfield', defaultType: 'textfield',
baseCls: 'x-plain', baseCls: 'x-plain',
labelWidth: 55, labelWidth: 55,
items: [{ items: [
fieldLabel: _('Tracker:'), {
labelSeparator: '', fieldLabel: _('Tracker:'),
name: 'tracker', labelSeparator: '',
anchor: '100%' name: 'tracker',
}] anchor: '100%',
},
],
}); });
}, },
@ -53,7 +54,10 @@ Deluge.EditTrackerWindow = Ext.extend(Ext.Window, {
Deluge.EditTrackerWindow.superclass.show.call(this); Deluge.EditTrackerWindow.superclass.show.call(this);
this.record = record; this.record = record;
this.form.getForm().findField('tracker').setValue(record.data['url']); this.form
.getForm()
.findField('tracker')
.setValue(record.data['url']);
}, },
onCancelClick: function() { onCancelClick: function() {
@ -61,13 +65,19 @@ Deluge.EditTrackerWindow = Ext.extend(Ext.Window, {
}, },
onHide: function() { onHide: function() {
this.form.getForm().findField('tracker').setValue(''); this.form
.getForm()
.findField('tracker')
.setValue('');
}, },
onSaveClick: function() { onSaveClick: function() {
var url = this.form.getForm().findField('tracker').getValue(); var url = this.form
.getForm()
.findField('tracker')
.getValue();
this.record.set('url', url); this.record.set('url', url);
this.record.commit(); this.record.commit();
this.hide(); this.hide();
} },
}); });

View File

@ -14,7 +14,6 @@ Ext.ns('Deluge');
* @extends Ext.Window * @extends Ext.Window
*/ */
Deluge.EditTrackersWindow = Ext.extend(Ext.Window, { Deluge.EditTrackersWindow = Ext.extend(Ext.Window, {
title: _('Edit Trackers'), title: _('Edit Trackers'),
layout: 'fit', layout: 'fit',
width: 350, width: 350,
@ -46,29 +45,29 @@ Deluge.EditTrackersWindow = Ext.extend(Ext.Window, {
this.list = new Ext.list.ListView({ this.list = new Ext.list.ListView({
store: new Ext.data.JsonStore({ store: new Ext.data.JsonStore({
root: 'trackers', root: 'trackers',
fields: [ fields: ['tier', 'url'],
'tier',
'url'
]
}), }),
columns: [{ columns: [
header: _('Tier'), {
width: .1, header: _('Tier'),
dataIndex: 'tier' width: 0.1,
}, { dataIndex: 'tier',
header: _('Tracker'), },
width: .9, {
dataIndex: 'url' header: _('Tracker'),
}], width: 0.9,
dataIndex: 'url',
},
],
columnSort: { columnSort: {
sortClasses: ['', ''] sortClasses: ['', ''],
}, },
stripeRows: true, stripeRows: true,
singleSelect: true, singleSelect: true,
listeners: { listeners: {
'dblclick': {fn: this.onListNodeDblClicked, scope: this}, dblclick: { fn: this.onListNodeDblClicked, scope: this },
'selectionchange': {fn: this.onSelect, scope: this} selectionchange: { fn: this.onSelect, scope: this },
} },
}); });
this.panel = this.add({ this.panel = this.add({
@ -80,30 +79,35 @@ Deluge.EditTrackersWindow = Ext.extend(Ext.Window, {
text: _('Up'), text: _('Up'),
iconCls: 'icon-up', iconCls: 'icon-up',
handler: this.onUpClick, handler: this.onUpClick,
scope: this scope: this,
}, { },
{
text: _('Down'), text: _('Down'),
iconCls: 'icon-down', iconCls: 'icon-down',
handler: this.onDownClick, handler: this.onDownClick,
scope: this scope: this,
}, '->', { },
'->',
{
text: _('Add'), text: _('Add'),
iconCls: 'icon-add', iconCls: 'icon-add',
handler: this.onAddClick, handler: this.onAddClick,
scope: this scope: this,
}, { },
{
text: _('Edit'), text: _('Edit'),
iconCls: 'icon-edit-trackers', iconCls: 'icon-edit-trackers',
handler: this.onEditClick, handler: this.onEditClick,
scope: this scope: this,
}, { },
{
text: _('Remove'), text: _('Remove'),
iconCls: 'icon-remove', iconCls: 'icon-remove',
handler: this.onRemoveClick, handler: this.onRemoveClick,
scope: this scope: this,
} },
] ],
}) }),
}); });
}, },
@ -113,20 +117,30 @@ Deluge.EditTrackersWindow = Ext.extend(Ext.Window, {
onAddTrackers: function(trackers) { onAddTrackers: function(trackers) {
var store = this.list.getStore(); var store = this.list.getStore();
Ext.each(trackers, function(tracker) { Ext.each(
var duplicate = false, heightestTier = -1; trackers,
store.each(function(record) { function(tracker) {
if (record.get('tier') > heightestTier) { var duplicate = false,
heightestTier = record.get('tier'); heightestTier = -1;
} store.each(function(record) {
if (tracker == record.get('tracker')) { if (record.get('tier') > heightestTier) {
duplicate = true; heightestTier = record.get('tier');
return false; }
} if (tracker == record.get('tracker')) {
}, this); duplicate = true;
if (duplicate) return; return false;
store.add(new store.recordType({'tier': heightestTier + 1, 'url': tracker})); }
}, this); }, this);
if (duplicate) return;
store.add(
new store.recordType({
tier: heightestTier + 1,
url: tracker,
})
);
},
this
);
}, },
onCancelClick: function() { onCancelClick: function() {
@ -151,14 +165,14 @@ Deluge.EditTrackersWindow = Ext.extend(Ext.Window, {
var trackers = []; var trackers = [];
this.list.getStore().each(function(record) { this.list.getStore().each(function(record) {
trackers.push({ trackers.push({
'tier': record.get('tier'), tier: record.get('tier'),
'url': record.get('url') url: record.get('url'),
}) });
}, this); }, this);
deluge.client.core.set_torrent_trackers(this.torrentId, trackers, { deluge.client.core.set_torrent_trackers(this.torrentId, trackers, {
failure: this.onSaveFail, failure: this.onSaveFail,
scope: this scope: this,
}); });
this.hide(); this.hide();
@ -176,23 +190,27 @@ Deluge.EditTrackersWindow = Ext.extend(Ext.Window, {
this.list.getStore().sort('tier', 'ASC'); this.list.getStore().sort('tier', 'ASC');
}, },
onSaveFail: function() { onSaveFail: function() {},
},
onSelect: function(list) { onSelect: function(list) {
if (list.getSelectionCount()) { if (list.getSelectionCount()) {
this.panel.getBottomToolbar().items.get(4).enable(); this.panel
.getBottomToolbar()
.items.get(4)
.enable();
} }
}, },
onShow: function() { onShow: function() {
this.panel.getBottomToolbar().items.get(4).disable(); this.panel
.getBottomToolbar()
.items.get(4)
.disable();
var r = deluge.torrents.getSelected(); var r = deluge.torrents.getSelected();
this.torrentId = r.id; this.torrentId = r.id;
deluge.client.core.get_torrent_status(r.id, ['trackers'], { deluge.client.core.get_torrent_status(r.id, ['trackers'], {
success: this.onRequestComplete, success: this.onRequestComplete,
scope: this scope: this,
}); });
}, },
@ -217,5 +235,5 @@ Deluge.EditTrackersWindow = Ext.extend(Ext.Window, {
r.store.commitChanges(); r.store.commitChanges();
this.list.select(r.store.indexOf(r)); this.list.select(r.store.indexOf(r));
} },
}); });

View File

@ -33,14 +33,20 @@ 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); Deluge.EventsManager.superclass.addListener.call(
this,
eventName,
fn,
scope,
o
);
}, },
getEvents: function() { getEvents: function() {
deluge.client.web.get_events({ deluge.client.web.get_events({
success: this.onGetEventsSuccess, success: this.onGetEventsSuccess,
failure: this.onGetEventsFailure, failure: this.onGetEventsFailure,
scope: this scope: this,
}); });
}, },
@ -71,11 +77,16 @@ Deluge.EventsManager = Ext.extend(Ext.util.Observable, {
onGetEventsSuccess: function(events) { onGetEventsSuccess: function(events) {
if (!this.running) return; if (!this.running) return;
if (events) { if (events) {
Ext.each(events, function(event) { Ext.each(
var name = event[0], args = event[1]; events,
args.splice(0, 0, name); function(event) {
this.fireEvent.apply(this, args); var name = event[0],
}, this); args = event[1];
args.splice(0, 0, name);
this.fireEvent.apply(this, args);
},
this
);
} }
this.getEvents(); this.getEvents();
}, },
@ -89,19 +100,19 @@ Deluge.EventsManager = Ext.extend(Ext.util.Observable, {
return; return;
} }
this.getEvents(); this.getEvents();
} },
}); });
/** /**
* 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(); deluge.events = new Deluge.EventsManager();

View File

@ -10,10 +10,9 @@
Ext.namespace('Deluge'); Ext.namespace('Deluge');
Deluge.FileBrowser = Ext.extend(Ext.Window, { Deluge.FileBrowser = Ext.extend(Ext.Window, {
title: _('File Browser'), title: _('File Browser'),
width: 500, width: 500,
height: 400, height: 400,
initComponent: function() { initComponent: function() {
@ -21,20 +20,24 @@ Deluge.FileBrowser = Ext.extend(Ext.Window, {
this.add({ this.add({
xtype: 'toolbar', xtype: 'toolbar',
items: [{ items: [
text: _('Back'), {
iconCls: 'icon-back' text: _('Back'),
}, { iconCls: 'icon-back',
text: _('Forward'), },
iconCls: 'icon-forward' {
}, { text: _('Forward'),
text: _('Up'), iconCls: 'icon-forward',
iconCls: 'icon-up' },
}, { {
text: _('Home'), text: _('Up'),
iconCls: 'icon-home' iconCls: 'icon-up',
}] },
{
text: _('Home'),
iconCls: 'icon-home',
},
],
}); });
} },
}); });

View File

@ -14,7 +14,6 @@ Ext.ns('Deluge');
* @extends Ext.list.ListView * @extends Ext.list.ListView
*/ */
Deluge.FilterPanel = Ext.extend(Ext.Panel, { Deluge.FilterPanel = Ext.extend(Ext.Panel, {
autoScroll: true, autoScroll: true,
border: false, border: false,
@ -34,9 +33,9 @@ Deluge.FilterPanel = Ext.extend(Ext.Panel, {
} else if (this.filterType == 'label') { } else if (this.filterType == 'label') {
title = _('Labels'); title = _('Labels');
} else { } else {
title = this.filterType.replace('_', ' '), (title = this.filterType.replace('_', ' ')),
parts = title.split(' '), (parts = title.split(' ')),
title = ''; (title = '');
Ext.each(parts, function(p) { Ext.each(parts, function(p) {
fl = p.substring(0, 1).toUpperCase(); fl = p.substring(0, 1).toUpperCase();
title += fl + p.substring(1) + ' '; title += fl + p.substring(1) + ' ';
@ -47,7 +46,8 @@ Deluge.FilterPanel = Ext.extend(Ext.Panel, {
if (Deluge.FilterPanel.templates[this.filterType]) { if (Deluge.FilterPanel.templates[this.filterType]) {
var tpl = Deluge.FilterPanel.templates[this.filterType]; var tpl = Deluge.FilterPanel.templates[this.filterType];
} else { } else {
var tpl = '<div class="x-deluge-filter x-deluge-{filter:lowercase}">{filter} ({count})</div>'; var tpl =
'<div class="x-deluge-filter x-deluge-{filter:lowercase}">{filter} ({count})</div>';
} }
this.list = this.add({ this.list = this.add({
@ -57,14 +57,16 @@ Deluge.FilterPanel = Ext.extend(Ext.Panel, {
reserveScrollOffset: true, reserveScrollOffset: true,
store: new Ext.data.ArrayStore({ store: new Ext.data.ArrayStore({
idIndex: 0, idIndex: 0,
fields: ['filter', 'count'] fields: ['filter', 'count'],
}), }),
columns: [{ columns: [
id: 'filter', {
sortable: false, id: 'filter',
tpl: tpl, sortable: false,
dataIndex: 'filter' tpl: tpl,
}] dataIndex: 'filter',
},
],
}); });
this.relayEvents(this.list, ['selectionchange']); this.relayEvents(this.list, ['selectionchange']);
}, },
@ -102,11 +104,18 @@ Deluge.FilterPanel = Ext.extend(Ext.Panel, {
*/ */
updateStates: function(states) { updateStates: function(states) {
this.states = {}; this.states = {};
Ext.each(states, function(state) { Ext.each(
this.states[state[0]] = state[1]; states,
}, this); function(state) {
this.states[state[0]] = state[1];
},
this
);
var show_zero = (this.show_zero == null) ? deluge.config.sidebar_show_zero : this.show_zero; var show_zero =
this.show_zero == null
? deluge.config.sidebar_show_zero
: this.show_zero;
if (!show_zero) { if (!show_zero) {
var newStates = []; var newStates = [];
Ext.each(states, function(state) { Ext.each(states, function(state) {
@ -119,22 +128,26 @@ Deluge.FilterPanel = Ext.extend(Ext.Panel, {
var store = this.getStore(); var store = this.getStore();
var filters = {}; var filters = {};
Ext.each(states, function(s, i) { Ext.each(
var record = store.getById(s[0]); states,
if (!record) { function(s, i) {
record = new store.recordType({ var record = store.getById(s[0]);
filter: s[0], if (!record) {
count: s[1] record = new store.recordType({
}); filter: s[0],
record.id = s[0]; count: s[1],
store.insert(i, record); });
} record.id = s[0];
record.beginEdit(); store.insert(i, record);
record.set('filter', _(s[0])); }
record.set('count', s[1]); record.beginEdit();
record.endEdit(); record.set('filter', _(s[0]));
filters[s[0]] = true; record.set('count', s[1]);
}, this); record.endEdit();
filters[s[0]] = true;
},
this
);
store.each(function(record) { store.each(function(record) {
if (filters[record.id]) return; if (filters[record.id]) return;
@ -151,10 +164,12 @@ Deluge.FilterPanel = Ext.extend(Ext.Panel, {
if (!this.list.getSelectionCount()) { if (!this.list.getSelectionCount()) {
this.list.select(0); this.list.select(0);
} }
} },
}); });
Deluge.FilterPanel.templates = { Deluge.FilterPanel.templates = {
'tracker_host': '<div class="x-deluge-filter" style="background-image: url(' + deluge.config.base + 'tracker/{filter});">{filter} ({count})</div>' tracker_host:
} '<div class="x-deluge-filter" style="background-image: url(' +
deluge.config.base +
'tracker/{filter});">{filter} ({count})</div>',
};

View File

@ -34,9 +34,15 @@ Deluge.Formatters = {
} }
timestamp = timestamp * 1000; timestamp = timestamp * 1000;
var date = new Date(timestamp); var date = new Date(timestamp);
return String.format('{0}/{1}/{2} {3}:{4}:{5}', return String.format(
zeroPad(date.getDate(), 2), zeroPad(date.getMonth() + 1, 2), date.getFullYear(), '{0}/{1}/{2} {3}:{4}:{5}',
zeroPad(date.getHours(), 2), zeroPad(date.getMinutes(), 2), zeroPad(date.getSeconds(), 2)); zeroPad(date.getDate(), 2),
zeroPad(date.getMonth() + 1, 2),
date.getFullYear(),
zeroPad(date.getHours(), 2),
zeroPad(date.getMinutes(), 2),
zeroPad(date.getSeconds(), 2)
);
}, },
/** /**
@ -50,13 +56,19 @@ Deluge.Formatters = {
if (!bytes && !showZero) return ''; if (!bytes && !showZero) return '';
bytes = bytes / 1024.0; bytes = bytes / 1024.0;
if (bytes < 1024) { return bytes.toFixed(1) + ' KiB'; } if (bytes < 1024) {
else { bytes = bytes / 1024; } return bytes.toFixed(1) + ' KiB';
} else {
bytes = bytes / 1024;
}
if (bytes < 1024) { return bytes.toFixed(1) + ' MiB'; } if (bytes < 1024) {
else { bytes = bytes / 1024; } return bytes.toFixed(1) + ' MiB';
} else {
bytes = bytes / 1024;
}
return bytes.toFixed(1) + ' GiB' return bytes.toFixed(1) + ' GiB';
}, },
/** /**
@ -70,13 +82,19 @@ Deluge.Formatters = {
if (!bytes && !showZero) return ''; if (!bytes && !showZero) return '';
bytes = bytes / 1024.0; bytes = bytes / 1024.0;
if (bytes < 1024) { return bytes.toFixed(1) + ' K'; } if (bytes < 1024) {
else { bytes = bytes / 1024; } return bytes.toFixed(1) + ' K';
} else {
bytes = bytes / 1024;
}
if (bytes < 1024) { return bytes.toFixed(1) + ' M'; } if (bytes < 1024) {
else { bytes = bytes / 1024; } return bytes.toFixed(1) + ' M';
} else {
bytes = bytes / 1024;
}
return bytes.toFixed(1) + ' G' return bytes.toFixed(1) + ' G';
}, },
/** /**
@ -87,7 +105,7 @@ Deluge.Formatters = {
* @return {String} formatted string with KiB, MiB or GiB units. * @return {String} formatted string with KiB, MiB or GiB units.
*/ */
speed: function(bytes, showZero) { speed: function(bytes, showZero) {
return (!bytes && !showZero) ? '' : fsize(bytes, showZero) + '/s'; return !bytes && !showZero ? '' : fsize(bytes, showZero) + '/s';
}, },
/** /**
@ -97,34 +115,42 @@ Deluge.Formatters = {
* @return {String} a formatted time string. will return '' if seconds == 0 * @return {String} a formatted time string. will return '' if seconds == 0
*/ */
timeRemaining: function(time) { timeRemaining: function(time) {
if (time <= 0) { return '&infin;' } if (time <= 0) {
return '&infin;';
}
time = time.toFixed(0); time = time.toFixed(0);
if (time < 60) { return time + 's'; } if (time < 60) {
else { time = time / 60; } return time + 's';
} else {
time = time / 60;
}
if (time < 60) { if (time < 60) {
var minutes = Math.floor(time) var minutes = Math.floor(time);
var seconds = Math.round(60 * (time - minutes)) var seconds = Math.round(60 * (time - minutes));
if (seconds > 0) { if (seconds > 0) {
return minutes + 'm ' + seconds + 's'; return minutes + 'm ' + seconds + 's';
} else { } else {
return minutes + 'm'; } return minutes + 'm';
} }
else { time = time / 60; } } else {
time = time / 60;
}
if (time < 24) { if (time < 24) {
var hours = Math.floor(time) var hours = Math.floor(time);
var minutes = Math.round(60 * (time - hours)) var minutes = Math.round(60 * (time - hours));
if (minutes > 0) { if (minutes > 0) {
return hours + 'h ' + minutes + 'm'; return hours + 'h ' + minutes + 'm';
} else { } else {
return hours + 'h'; return hours + 'h';
} }
} else {
time = time / 24;
} }
else { time = time / 24; }
var days = Math.floor(time) var days = Math.floor(time);
var hours = Math.round(24 * (time - days)) var hours = Math.round(24 * (time - days));
if (hours > 0) { if (hours > 0) {
return days + 'd ' + hours + 'h'; return days + 'd ' + hours + 'h';
} else { } else {
@ -144,8 +170,8 @@ Deluge.Formatters = {
cssClassEscape: function(value) { cssClassEscape: function(value) {
return value.toLowerCase().replace('.', '_'); return value.toLowerCase().replace('.', '_');
} },
} };
var fsize = Deluge.Formatters.size; var fsize = Deluge.Formatters.size;
var fsize_short = Deluge.Formatters.sizeShort; var fsize_short = Deluge.Formatters.sizeShort;
var fspeed = Deluge.Formatters.speed; var fspeed = Deluge.Formatters.speed;

View File

@ -14,7 +14,6 @@
* @singleton * @singleton
*/ */
Deluge.Keys = { Deluge.Keys = {
/** /**
* Keys that are used within the torrent grid. * Keys that are used within the torrent grid.
* <pre>['queue', 'name', 'total_wanted', 'state', 'progress', 'num_seeds', * <pre>['queue', 'name', 'total_wanted', 'state', 'progress', 'num_seeds',
@ -25,12 +24,33 @@ Deluge.Keys = {
* 'seeds_peers_ratio', 'total_remaining', 'completed_time', 'time_since_transfer']</pre> * 'seeds_peers_ratio', 'total_remaining', 'completed_time', 'time_since_transfer']</pre>
*/ */
Grid: [ Grid: [
'queue', 'name', 'total_wanted', 'state', 'progress', 'num_seeds', 'queue',
'total_seeds', 'num_peers', 'total_peers', 'download_payload_rate', 'name',
'upload_payload_rate', 'eta', 'ratio', 'distributed_copies', 'total_wanted',
'is_auto_managed', 'time_added', 'tracker_host', 'download_location', 'last_seen_complete', 'state',
'total_done', 'total_uploaded', 'max_download_speed', 'max_upload_speed', 'progress',
'seeds_peers_ratio', 'total_remaining', 'completed_time', 'time_since_transfer' 'num_seeds',
'total_seeds',
'num_peers',
'total_peers',
'download_payload_rate',
'upload_payload_rate',
'eta',
'ratio',
'distributed_copies',
'is_auto_managed',
'time_added',
'tracker_host',
'download_location',
'last_seen_complete',
'total_done',
'total_uploaded',
'max_download_speed',
'max_upload_speed',
'seeds_peers_ratio',
'total_remaining',
'completed_time',
'time_since_transfer',
], ],
/** /**
@ -42,34 +62,50 @@ Deluge.Keys = {
* 'seed_rank', 'last_seen_complete', 'completed_time', 'owner', 'public', 'shared']</pre> * 'seed_rank', 'last_seen_complete', 'completed_time', 'owner', 'public', 'shared']</pre>
*/ */
Status: [ Status: [
'total_done', 'total_payload_download', 'total_uploaded', 'total_done',
'total_payload_upload', 'next_announce', 'tracker_status', 'num_pieces', 'total_payload_download',
'piece_length', 'is_auto_managed', 'active_time', 'seeding_time', 'time_since_transfer', 'total_uploaded',
'seed_rank', 'last_seen_complete', 'completed_time', 'owner', 'public', 'shared' 'total_payload_upload',
'next_announce',
'tracker_status',
'num_pieces',
'piece_length',
'is_auto_managed',
'active_time',
'seeding_time',
'time_since_transfer',
'seed_rank',
'last_seen_complete',
'completed_time',
'owner',
'public',
'shared',
], ],
/** /**
* Keys used in the files tab of the statistics panel. * Keys used in the files tab of the statistics panel.
* <pre>['files', 'file_progress', 'file_priorities']</pre> * <pre>['files', 'file_progress', 'file_priorities']</pre>
*/ */
Files: [ Files: ['files', 'file_progress', 'file_priorities'],
'files', 'file_progress', 'file_priorities'
],
/** /**
* Keys used in the peers tab of the statistics panel. * Keys used in the peers tab of the statistics panel.
* <pre>['peers']</pre> * <pre>['peers']</pre>
*/ */
Peers: [ Peers: ['peers'],
'peers'
],
/** /**
* Keys used in the details tab of the statistics panel. * Keys used in the details tab of the statistics panel.
*/ */
Details: [ Details: [
'name', 'download_location', 'total_size', 'num_files', 'message', 'name',
'tracker_host', 'comment', 'creator' 'download_location',
'total_size',
'num_files',
'message',
'tracker_host',
'comment',
'creator',
], ],
/** /**
@ -79,11 +115,19 @@ Deluge.Keys = {
* 'prioritize_first_last']</pre> * 'prioritize_first_last']</pre>
*/ */
Options: [ Options: [
'max_download_speed', 'max_upload_speed', 'max_connections', 'max_download_speed',
'max_upload_slots','is_auto_managed', 'stop_at_ratio', 'stop_ratio', 'max_upload_speed',
'remove_at_ratio', 'private', 'prioritize_first_last', 'max_connections',
'move_completed', 'move_completed_path' 'max_upload_slots',
] 'is_auto_managed',
'stop_at_ratio',
'stop_ratio',
'remove_at_ratio',
'private',
'prioritize_first_last',
'move_completed',
'move_completed_path',
],
}; };
// Merge the grid and status keys together as the status keys contain all the // Merge the grid and status keys together as the status keys contain all the

View File

@ -9,20 +9,19 @@
*/ */
Deluge.LoginWindow = Ext.extend(Ext.Window, { Deluge.LoginWindow = Ext.extend(Ext.Window, {
firstShow: true,
firstShow: true, bodyStyle: 'padding: 10px 5px;',
bodyStyle: 'padding: 10px 5px;',
buttonAlign: 'center', buttonAlign: 'center',
closable: false, closable: false,
closeAction: 'hide', closeAction: 'hide',
iconCls: 'x-deluge-login-window-icon', iconCls: 'x-deluge-login-window-icon',
layout: 'fit', layout: 'fit',
modal: true, modal: true,
plain: true, plain: true,
resizable: false, resizable: false,
title: _('Login'), title: _('Login'),
width: 300, width: 300,
height: 120, height: 120,
initComponent: function() { initComponent: function() {
Deluge.LoginWindow.superclass.initComponent.call(this); Deluge.LoginWindow.superclass.initComponent.call(this);
@ -31,7 +30,7 @@ Deluge.LoginWindow = Ext.extend(Ext.Window, {
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({
@ -39,20 +38,20 @@ Deluge.LoginWindow = Ext.extend(Ext.Window, {
baseCls: 'x-plain', baseCls: 'x-plain',
labelWidth: 120, labelWidth: 120,
labelAlign: 'right', labelAlign: 'right',
defaults: {width: 110}, defaults: { width: 110 },
defaultType: 'textfield' defaultType: 'textfield',
}); });
this.passwordField = this.form.add({ this.passwordField = this.form.add({
xtype: 'textfield', xtype: 'textfield',
fieldLabel: _('Password:'), fieldLabel: _('Password:'),
labelSeparator : '', labelSeparator: '',
grow: true, grow: true,
growMin: '110', growMin: '110',
growMax: '145', growMax: '145',
id: '_password', id: '_password',
name: 'password', name: 'password',
inputType: 'password' inputType: 'password',
}); });
this.passwordField.on('specialkey', this.onSpecialKey, this); this.passwordField.on('specialkey', this.onSpecialKey, this);
}, },
@ -63,7 +62,7 @@ Deluge.LoginWindow = Ext.extend(Ext.Window, {
success: function(result) { success: function(result) {
this.show(true); this.show(true);
}, },
scope: this scope: this,
}); });
}, },
@ -88,7 +87,7 @@ Deluge.LoginWindow = Ext.extend(Ext.Window, {
failure: function(result) { failure: function(result) {
this.show(true); this.show(true);
}, },
scope: this scope: this,
}); });
}, },
@ -114,11 +113,11 @@ Deluge.LoginWindow = Ext.extend(Ext.Window, {
passwordField.focus(true, 10); passwordField.focus(true, 10);
}, },
icon: Ext.MessageBox.WARNING, icon: Ext.MessageBox.WARNING,
iconCls: 'x-deluge-icon-warning' iconCls: 'x-deluge-icon-warning',
}); });
} }
}, },
scope: this scope: this,
}); });
}, },
@ -131,5 +130,5 @@ Deluge.LoginWindow = Ext.extend(Ext.Window, {
onShow: function() { onShow: function() {
this.passwordField.focus(true, 300); this.passwordField.focus(true, 300);
} },
}); });

View File

@ -23,7 +23,7 @@ deluge.menus = {
deluge.client.core[action](ids, { deluge.client.core[action](ids, {
success: function() { success: function() {
deluge.ui.update(); deluge.ui.update();
} },
}); });
}, },
@ -41,284 +41,348 @@ deluge.menus = {
deluge.moveStorage.show(ids); deluge.moveStorage.show(ids);
break; break;
} }
} },
} };
deluge.menus.torrent = new Ext.menu.Menu({ deluge.menus.torrent = new Ext.menu.Menu({
id: 'torrentMenu', id: 'torrentMenu',
items: [{ items: [
torrentAction: 'pause_torrent', {
text: _('Pause'), torrentAction: 'pause_torrent',
iconCls: 'icon-pause', text: _('Pause'),
handler: deluge.menus.onTorrentActionMethod, iconCls: 'icon-pause',
scope: deluge.menus handler: deluge.menus.onTorrentActionMethod,
}, { scope: deluge.menus,
torrentAction: 'resume_torrent', },
text: _('Resume'), {
iconCls: 'icon-resume', torrentAction: 'resume_torrent',
handler: deluge.menus.onTorrentActionMethod, text: _('Resume'),
scope: deluge.menus iconCls: 'icon-resume',
}, '-', { handler: deluge.menus.onTorrentActionMethod,
text: _('Options'), scope: deluge.menus,
iconCls: 'icon-options', },
hideOnClick: false, '-',
menu: new Ext.menu.Menu({ {
items: [{ text: _('Options'),
text: _('D/L Speed Limit'), iconCls: 'icon-options',
iconCls: 'x-deluge-downloading', hideOnClick: false,
hideOnClick: false, menu: new Ext.menu.Menu({
menu: new Ext.menu.Menu({ items: [
items: [{ {
torrentAction: ['max_download_speed', 5], text: _('D/L Speed Limit'),
text: _('5 KiB/s'), iconCls: 'x-deluge-downloading',
handler: deluge.menus.onTorrentActionSetOpt, hideOnClick: false,
scope: deluge.menus menu: new Ext.menu.Menu({
}, { items: [
torrentAction: ['max_download_speed', 10], {
text: _('10 KiB/s'), torrentAction: ['max_download_speed', 5],
handler: deluge.menus.onTorrentActionSetOpt, text: _('5 KiB/s'),
scope: deluge.menus handler: deluge.menus.onTorrentActionSetOpt,
}, { scope: deluge.menus,
torrentAction: ['max_download_speed', 30], },
text: _('30 KiB/s'), {
handler: deluge.menus.onTorrentActionSetOpt, torrentAction: ['max_download_speed', 10],
scope: deluge.menus text: _('10 KiB/s'),
}, { handler: deluge.menus.onTorrentActionSetOpt,
torrentAction: ['max_download_speed', 80], scope: deluge.menus,
text: _('80 KiB/s'), },
handler: deluge.menus.onTorrentActionSetOpt, {
scope: deluge.menus torrentAction: ['max_download_speed', 30],
}, { text: _('30 KiB/s'),
torrentAction: ['max_download_speed', 300], handler: deluge.menus.onTorrentActionSetOpt,
text: _('300 KiB/s'), scope: deluge.menus,
handler: deluge.menus.onTorrentActionSetOpt, },
scope: deluge.menus {
},{ torrentAction: ['max_download_speed', 80],
torrentAction: ['max_download_speed', -1], text: _('80 KiB/s'),
text: _('Unlimited'), handler: deluge.menus.onTorrentActionSetOpt,
handler: deluge.menus.onTorrentActionSetOpt, scope: deluge.menus,
scope: deluge.menus },
}] {
}) torrentAction: ['max_download_speed', 300],
}, { text: _('300 KiB/s'),
text: _('U/L Speed Limit'), handler: deluge.menus.onTorrentActionSetOpt,
iconCls: 'x-deluge-seeding', scope: deluge.menus,
hideOnClick: false, },
menu: new Ext.menu.Menu({ {
items: [{ torrentAction: ['max_download_speed', -1],
torrentAction: ['max_upload_speed', 5], text: _('Unlimited'),
text: _('5 KiB/s'), handler: deluge.menus.onTorrentActionSetOpt,
handler: deluge.menus.onTorrentActionSetOpt, scope: deluge.menus,
scope: deluge.menus },
}, { ],
torrentAction: ['max_upload_speed', 10], }),
text: _('10 KiB/s'), },
handler: deluge.menus.onTorrentActionSetOpt, {
scope: deluge.menus text: _('U/L Speed Limit'),
}, { iconCls: 'x-deluge-seeding',
torrentAction: ['max_upload_speed', 30], hideOnClick: false,
text: _('30 KiB/s'), menu: new Ext.menu.Menu({
handler: deluge.menus.onTorrentActionSetOpt, items: [
scope: deluge.menus {
}, { torrentAction: ['max_upload_speed', 5],
torrentAction: ['max_upload_speed', 80], text: _('5 KiB/s'),
text: _('80 KiB/s'), handler: deluge.menus.onTorrentActionSetOpt,
handler: deluge.menus.onTorrentActionSetOpt, scope: deluge.menus,
scope: deluge.menus },
}, { {
torrentAction: ['max_upload_speed', 300], torrentAction: ['max_upload_speed', 10],
text: _('300 KiB/s'), text: _('10 KiB/s'),
handler: deluge.menus.onTorrentActionSetOpt, handler: deluge.menus.onTorrentActionSetOpt,
scope: deluge.menus scope: deluge.menus,
},{ },
torrentAction: ['max_upload_speed', -1], {
text: _('Unlimited'), torrentAction: ['max_upload_speed', 30],
handler: deluge.menus.onTorrentActionSetOpt, text: _('30 KiB/s'),
scope: deluge.menus handler: deluge.menus.onTorrentActionSetOpt,
}] scope: deluge.menus,
}) },
}, { {
text: _('Connection Limit'), torrentAction: ['max_upload_speed', 80],
iconCls: 'x-deluge-connections', text: _('80 KiB/s'),
hideOnClick: false, handler: deluge.menus.onTorrentActionSetOpt,
menu: new Ext.menu.Menu({ scope: deluge.menus,
items: [{ },
torrentAction: ['max_connections', 50], {
text: '50', torrentAction: ['max_upload_speed', 300],
handler: deluge.menus.onTorrentActionSetOpt, text: _('300 KiB/s'),
scope: deluge.menus handler: deluge.menus.onTorrentActionSetOpt,
}, { scope: deluge.menus,
torrentAction: ['max_connections', 100], },
text: '100', {
handler: deluge.menus.onTorrentActionSetOpt, torrentAction: ['max_upload_speed', -1],
scope: deluge.menus text: _('Unlimited'),
}, { handler: deluge.menus.onTorrentActionSetOpt,
torrentAction: ['max_connections', 200], scope: deluge.menus,
text: '200', },
handler: deluge.menus.onTorrentActionSetOpt, ],
scope: deluge.menus }),
}, { },
torrentAction: ['max_connections', 300], {
text: '300', text: _('Connection Limit'),
handler: deluge.menus.onTorrentActionSetOpt, iconCls: 'x-deluge-connections',
scope: deluge.menus hideOnClick: false,
}, { menu: new Ext.menu.Menu({
torrentAction: ['max_connections', 500], items: [
text: '500', {
handler: deluge.menus.onTorrentActionSetOpt, torrentAction: ['max_connections', 50],
scope: deluge.menus text: '50',
},{ handler: deluge.menus.onTorrentActionSetOpt,
torrentAction: ['max_connections', -1], scope: deluge.menus,
text: _('Unlimited'), },
handler: deluge.menus.onTorrentActionSetOpt, {
scope: deluge.menus torrentAction: ['max_connections', 100],
}] text: '100',
}) handler: deluge.menus.onTorrentActionSetOpt,
}, { scope: deluge.menus,
text: _('Upload Slot Limit'), },
iconCls: 'icon-upload-slots', {
hideOnClick: false, torrentAction: ['max_connections', 200],
menu: new Ext.menu.Menu({ text: '200',
items: [{ handler: deluge.menus.onTorrentActionSetOpt,
torrentAction: ['max_upload_slots', 0], scope: deluge.menus,
text: '0', },
handler: deluge.menus.onTorrentActionSetOpt, {
scope: deluge.menus torrentAction: ['max_connections', 300],
}, { text: '300',
torrentAction: ['max_upload_slots', 1], handler: deluge.menus.onTorrentActionSetOpt,
text: '1', scope: deluge.menus,
handler: deluge.menus.onTorrentActionSetOpt, },
scope: deluge.menus {
}, { torrentAction: ['max_connections', 500],
torrentAction: ['max_upload_slots', 2], text: '500',
text: '2', handler: deluge.menus.onTorrentActionSetOpt,
handler: deluge.menus.onTorrentActionSetOpt, scope: deluge.menus,
scope: deluge.menus },
}, { {
torrentAction: ['max_upload_slots', 3], torrentAction: ['max_connections', -1],
text: '3', text: _('Unlimited'),
handler: deluge.menus.onTorrentActionSetOpt, handler: deluge.menus.onTorrentActionSetOpt,
scope: deluge.menus scope: deluge.menus,
}, { },
torrentAction: ['max_upload_slots', 5], ],
text: '5', }),
handler: deluge.menus.onTorrentActionSetOpt, },
scope: deluge.menus {
},{ text: _('Upload Slot Limit'),
torrentAction: ['max_upload_slots', -1], iconCls: 'icon-upload-slots',
text: _('Unlimited'), hideOnClick: false,
handler: deluge.menus.onTorrentActionSetOpt, menu: new Ext.menu.Menu({
scope: deluge.menus items: [
}] {
}) torrentAction: ['max_upload_slots', 0],
}, { text: '0',
id: 'auto_managed', handler: deluge.menus.onTorrentActionSetOpt,
text: _('Auto Managed'), scope: deluge.menus,
hideOnClick: false, },
menu: new Ext.menu.Menu({ {
items: [{ torrentAction: ['max_upload_slots', 1],
torrentAction: ['auto_managed', true], text: '1',
text: _('On'), handler: deluge.menus.onTorrentActionSetOpt,
handler: deluge.menus.onTorrentActionSetOpt, scope: deluge.menus,
scope: deluge.menus },
}, { {
torrentAction: ['auto_managed', false], torrentAction: ['max_upload_slots', 2],
text: _('Off'), text: '2',
handler: deluge.menus.onTorrentActionSetOpt, handler: deluge.menus.onTorrentActionSetOpt,
scope: deluge.menus scope: deluge.menus,
}] },
}) {
}] torrentAction: ['max_upload_slots', 3],
}) text: '3',
}, '-', { handler: deluge.menus.onTorrentActionSetOpt,
text: _('Queue'), scope: deluge.menus,
iconCls: 'icon-queue', },
hideOnClick: false, {
menu: new Ext.menu.Menu({ torrentAction: ['max_upload_slots', 5],
items: [{ text: '5',
torrentAction: 'queue_top', handler: deluge.menus.onTorrentActionSetOpt,
text: _('Top'), scope: deluge.menus,
iconCls: 'icon-top', },
handler: deluge.menus.onTorrentActionMethod, {
scope: deluge.menus torrentAction: ['max_upload_slots', -1],
},{ text: _('Unlimited'),
torrentAction: 'queue_up', handler: deluge.menus.onTorrentActionSetOpt,
text: _('Up'), scope: deluge.menus,
iconCls: 'icon-up', },
handler: deluge.menus.onTorrentActionMethod, ],
scope: deluge.menus }),
},{ },
torrentAction: 'queue_down', {
text: _('Down'), id: 'auto_managed',
iconCls: 'icon-down', text: _('Auto Managed'),
handler: deluge.menus.onTorrentActionMethod, hideOnClick: false,
scope: deluge.menus menu: new Ext.menu.Menu({
},{ items: [
torrentAction: 'queue_bottom', {
text: _('Bottom'), torrentAction: ['auto_managed', true],
iconCls: 'icon-bottom', text: _('On'),
handler: deluge.menus.onTorrentActionMethod, handler: deluge.menus.onTorrentActionSetOpt,
scope: deluge.menus scope: deluge.menus,
}] },
}) {
}, '-', { torrentAction: ['auto_managed', false],
torrentAction: 'force_reannounce', text: _('Off'),
text: _('Update Tracker'), handler: deluge.menus.onTorrentActionSetOpt,
iconCls: 'icon-update-tracker', scope: deluge.menus,
handler: deluge.menus.onTorrentActionMethod, },
scope: deluge.menus ],
}, { }),
torrentAction: 'edit_trackers', },
text: _('Edit Trackers'), ],
iconCls: 'icon-edit-trackers', }),
handler: deluge.menus.onTorrentActionShow, },
scope: deluge.menus '-',
}, '-', { {
torrentAction: 'remove', text: _('Queue'),
text: _('Remove Torrent'), iconCls: 'icon-queue',
iconCls: 'icon-remove', hideOnClick: false,
handler: deluge.menus.onTorrentActionShow, menu: new Ext.menu.Menu({
scope: deluge.menus items: [
}, '-', { {
torrentAction: 'force_recheck', torrentAction: 'queue_top',
text: _('Force Recheck'), text: _('Top'),
iconCls: 'icon-recheck', iconCls: 'icon-top',
handler: deluge.menus.onTorrentActionMethod, handler: deluge.menus.onTorrentActionMethod,
scope: deluge.menus scope: deluge.menus,
}, { },
torrentAction: 'move', {
text: _('Move Download Folder'), torrentAction: 'queue_up',
iconCls: 'icon-move', text: _('Up'),
handler: deluge.menus.onTorrentActionShow, iconCls: 'icon-up',
scope: deluge.menus handler: deluge.menus.onTorrentActionMethod,
}] scope: deluge.menus,
},
{
torrentAction: 'queue_down',
text: _('Down'),
iconCls: 'icon-down',
handler: deluge.menus.onTorrentActionMethod,
scope: deluge.menus,
},
{
torrentAction: 'queue_bottom',
text: _('Bottom'),
iconCls: 'icon-bottom',
handler: deluge.menus.onTorrentActionMethod,
scope: deluge.menus,
},
],
}),
},
'-',
{
torrentAction: 'force_reannounce',
text: _('Update Tracker'),
iconCls: 'icon-update-tracker',
handler: deluge.menus.onTorrentActionMethod,
scope: deluge.menus,
},
{
torrentAction: 'edit_trackers',
text: _('Edit Trackers'),
iconCls: 'icon-edit-trackers',
handler: deluge.menus.onTorrentActionShow,
scope: deluge.menus,
},
'-',
{
torrentAction: 'remove',
text: _('Remove Torrent'),
iconCls: 'icon-remove',
handler: deluge.menus.onTorrentActionShow,
scope: deluge.menus,
},
'-',
{
torrentAction: 'force_recheck',
text: _('Force Recheck'),
iconCls: 'icon-recheck',
handler: deluge.menus.onTorrentActionMethod,
scope: deluge.menus,
},
{
torrentAction: 'move',
text: _('Move Download Folder'),
iconCls: 'icon-move',
handler: deluge.menus.onTorrentActionShow,
scope: deluge.menus,
},
],
}); });
deluge.menus.filePriorities = new Ext.menu.Menu({ deluge.menus.filePriorities = new Ext.menu.Menu({
id: 'filePrioritiesMenu', id: 'filePrioritiesMenu',
items: [{ items: [
id: 'expandAll', {
text: _('Expand All'), id: 'expandAll',
iconCls: 'icon-expand-all' text: _('Expand All'),
}, '-', { iconCls: 'icon-expand-all',
id: 'ignore', },
text: _('Ignore'), '-',
iconCls: 'icon-do-not-download', {
filePriority: FILE_PRIORITY['Ignore'] id: 'ignore',
}, { text: _('Ignore'),
id: 'low', iconCls: 'icon-do-not-download',
text: _('Low'), filePriority: FILE_PRIORITY['Ignore'],
iconCls: 'icon-low', },
filePriority: FILE_PRIORITY['Low'] {
}, { id: 'low',
id: 'normal', text: _('Low'),
text: _('Normal'), iconCls: 'icon-low',
iconCls: 'icon-normal', filePriority: FILE_PRIORITY['Low'],
filePriority: FILE_PRIORITY['Normal'] },
}, { {
id: 'high', id: 'normal',
text: _('High'), text: _('Normal'),
iconCls: 'icon-high', iconCls: 'icon-normal',
filePriority: FILE_PRIORITY['High'] filePriority: FILE_PRIORITY['Normal'],
}] },
{
id: 'high',
text: _('High'),
iconCls: 'icon-high',
filePriority: FILE_PRIORITY['High'],
},
],
}); });

View File

@ -10,21 +10,23 @@
Ext.namespace('Deluge'); Ext.namespace('Deluge');
Deluge.MoveStorage = Ext.extend(Ext.Window, { Deluge.MoveStorage = Ext.extend(Ext.Window, {
constructor: function(config) { constructor: function(config) {
config = Ext.apply({ config = Ext.apply(
title: _('Move Download Folder'), {
width: 375, title: _('Move Download Folder'),
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',
constrainHeader: true, plain: true,
resizable: false constrainHeader: true,
}, config); resizable: false,
},
config
);
Deluge.MoveStorage.superclass.constructor.call(this, config); Deluge.MoveStorage.superclass.constructor.call(this, config);
}, },
@ -39,13 +41,13 @@ Deluge.MoveStorage = Ext.extend(Ext.Window, {
border: false, border: false,
defaultType: 'textfield', defaultType: 'textfield',
width: 300, width: 300,
bodyStyle: 'padding: 5px' bodyStyle: 'padding: 5px',
}); });
this.moveLocation = this.form.add({ this.moveLocation = this.form.add({
fieldLabel: _('Download Folder'), fieldLabel: _('Download Folder'),
name: 'location', name: 'location',
width: 240 width: 240,
}); });
//this.form.add({ //this.form.add({
// xtype: 'button', // xtype: 'button',
@ -78,6 +80,6 @@ Deluge.MoveStorage = Ext.extend(Ext.Window, {
var dest = this.moveLocation.getValue(); var dest = this.moveLocation.getValue();
deluge.client.core.move_storage(this.torrentIds, dest); deluge.client.core.move_storage(this.torrentIds, dest);
this.hide(); this.hide();
} },
}); });
deluge.moveStorage = new Deluge.MoveStorage(); deluge.moveStorage = new Deluge.MoveStorage();

View File

@ -15,7 +15,6 @@
* @extends Deluge.OptionsManager * @extends Deluge.OptionsManager
*/ */
Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, { Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, {
constructor: function(config) { constructor: function(config) {
this.currentId = null; this.currentId = null;
this.stored = {}; this.stored = {};
@ -32,9 +31,13 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, {
if (!dontUpdateBinds) { if (!dontUpdateBinds) {
for (var option in this.options) { for (var option in this.options) {
if (!this.binds[option]) continue; if (!this.binds[option]) continue;
Ext.each(this.binds[option], function(bind) { Ext.each(
bind.setValue(this.get(option)); this.binds[option],
}, this); function(bind) {
bind.setValue(this.get(option));
},
this
);
} }
} }
return oldId; return oldId;
@ -45,7 +48,10 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, {
* @param {String} id * @param {String} id
*/ */
commit: function() { commit: function() {
this.stored[this.currentId] = Ext.apply(this.stored[this.currentId], this.changed[this.currentId]); this.stored[this.currentId] = Ext.apply(
this.stored[this.currentId],
this.changed[this.currentId]
);
this.reset(); this.reset();
}, },
@ -57,18 +63,28 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, {
get: function() { get: function() {
if (arguments.length == 1) { if (arguments.length == 1) {
var option = arguments[0]; var option = arguments[0];
return (this.isDirty(option)) ? this.changed[this.currentId][option] : this.getDefault(option); return this.isDirty(option)
? this.changed[this.currentId][option]
: this.getDefault(option);
} else if (arguments.length == 0) { } else if (arguments.length == 0) {
var options = {}; var options = {};
for (var option in this.options) { for (var option in this.options) {
options[option] = (this.isDirty(option)) ? this.changed[this.currentId][option] : this.getDefault(option); options[option] = this.isDirty(option)
? this.changed[this.currentId][option]
: this.getDefault(option);
} }
return options; return options;
} else { } else {
var options = {}; var options = {};
Ext.each(arguments, function(option) { Ext.each(
options[option] = (this.isDirty(option)) ? this.changed[this.currentId][option] : this.getDefault(option); arguments,
}, this); function(option) {
options[option] = this.isDirty(option)
? this.changed[this.currentId][option]
: this.getDefault(option);
},
this
);
return options; return options;
} }
}, },
@ -79,7 +95,9 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, {
* @returns {Object} the value of the option * @returns {Object} the value of the option
*/ */
getDefault: function(option) { getDefault: function(option) {
return (this.has(option)) ? this.stored[this.currentId][option] : this.options[option]; return this.has(option)
? this.stored[this.currentId][option]
: this.options[option];
}, },
/** /**
@ -87,7 +105,7 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, {
* @returns {Object} the changed options * @returns {Object} the changed options
*/ */
getDirty: function() { getDirty: function() {
return (this.changed[this.currentId]) ? this.changed[this.currentId] : {}; return this.changed[this.currentId] ? this.changed[this.currentId] : {};
}, },
/** /**
@ -96,7 +114,10 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, {
* @returns {Boolean} true if the option has been changed, else false. * @returns {Boolean} true if the option has been changed, else false.
*/ */
isDirty: function(option) { isDirty: function(option) {
return (this.changed[this.currentId] && !Ext.isEmpty(this.changed[this.currentId][option])); return (
this.changed[this.currentId] &&
!Ext.isEmpty(this.changed[this.currentId][option])
);
}, },
/** /**
@ -106,7 +127,10 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, {
* @returns {Boolean} true if the id has an option, else false. * @returns {Boolean} true if the id has an option, else false.
*/ */
has: function(option) { has: function(option) {
return (this.stored[this.currentId] && !Ext.isEmpty(this.stored[this.currentId][option])); return (
this.stored[this.currentId] &&
!Ext.isEmpty(this.stored[this.currentId][option])
);
}, },
/** /**
@ -171,7 +195,8 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, {
this.update(key, option[key]); this.update(key, option[key]);
} }
} else { } else {
if (!this.changed[this.currentId]) this.changed[this.currentId] = {}; if (!this.changed[this.currentId])
this.changed[this.currentId] = {};
var defaultValue = this.getDefault(option); var defaultValue = this.getDefault(option);
value = this.convertValueType(defaultValue, value); value = this.convertValueType(defaultValue, value);
@ -180,7 +205,8 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, {
if (oldValue == value) return; if (oldValue == value) return;
if (defaultValue == value) { if (defaultValue == value) {
if (this.isDirty(option)) delete this.changed[this.currentId][option]; if (this.isDirty(option))
delete this.changed[this.currentId][option];
this.fireEvent('changed', option, value, oldValue); this.fireEvent('changed', option, value, oldValue);
return; return;
} else { } else {
@ -188,5 +214,5 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, {
this.fireEvent('changed', option, value, oldValue); this.fireEvent('changed', option, value, oldValue);
} }
} }
} },
}); });

View File

@ -18,7 +18,6 @@ Ext.namespace('Deluge');
* @param {Object} config Configuration options * @param {Object} config Configuration options
*/ */
Deluge.OptionsManager = Ext.extend(Ext.util.Observable, { Deluge.OptionsManager = Ext.extend(Ext.util.Observable, {
constructor: function(config) { constructor: function(config) {
config = config || {}; config = config || {};
this.binds = {}; this.binds = {};
@ -31,7 +30,7 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, {
* @event add * @event add
* Fires when an option is added * Fires when an option is added
*/ */
'add': true, add: true,
/** /**
* @event changed * @event changed
@ -40,13 +39,13 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, {
* @param {Mixed} value The options new value * @param {Mixed} value The options new value
* @param {Mixed} oldValue The options old value * @param {Mixed} oldValue The options old value
*/ */
'changed': true, changed: true,
/** /**
* @event reset * @event reset
* Fires when the options are reset * Fires when the options are reset
*/ */
'reset': true reset: true,
}); });
this.on('changed', this.onChange, this); this.on('changed', this.onChange, this);
@ -104,7 +103,10 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, {
case 'boolean': case 'boolean':
if (Ext.type(value) == 'string') { if (Ext.type(value) == 'string') {
value = value.toLowerCase(); value = value.toLowerCase();
value = (value == 'true' || value == '1' || value == 'on') ? true : false; value =
value == 'true' || value == '1' || value == 'on'
? true
: false;
} else { } else {
value = Boolean(value); value = Boolean(value);
} }
@ -122,13 +124,21 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, {
get: function() { get: function() {
if (arguments.length == 1) { if (arguments.length == 1) {
var option = arguments[0]; var option = arguments[0];
return (this.isDirty(option)) ? this.changed[option] : this.options[option]; return this.isDirty(option)
? this.changed[option]
: this.options[option];
} else { } else {
var options = {}; var options = {};
Ext.each(arguments, function(option) { Ext.each(
if (!this.has(option)) return; arguments,
options[option] = (this.isDirty(option)) ? this.changed[option] : this.options[option]; function(option) {
}, this); if (!this.has(option)) return;
options[option] = this.isDirty(option)
? this.changed[option]
: this.options[option];
},
this
);
return options; return options;
} }
}, },
@ -164,7 +174,7 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, {
* @returns {Boolean} true if the option exists, else false. * @returns {Boolean} true if the option exists, else false.
*/ */
has: function(option) { has: function(option) {
return (this.options[option]); return this.options[option];
}, },
/** /**
@ -190,7 +200,7 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, {
} }
} else { } else {
this.options[option] = value; this.options[option] = value;
this.onChange(option, value) this.onChange(option, value);
} }
}, },
@ -255,11 +265,15 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, {
onChange: function(option, newValue, oldValue) { onChange: function(option, newValue, oldValue) {
// If we don't have a bind there's nothing to do. // If we don't have a bind there's nothing to do.
if (Ext.isEmpty(this.binds[option])) return; if (Ext.isEmpty(this.binds[option])) return;
Ext.each(this.binds[option], function(bind) { Ext.each(
// The field is currently focused so we do not want to change it. this.binds[option],
if (bind == this.focused) return; function(bind) {
// Set the form field to the new value. // The field is currently focused so we do not want to change it.
bind.setValue(newValue); if (bind == this.focused) return;
}, this); // Set the form field to the new value.
} bind.setValue(newValue);
},
this
);
},
}); });

View File

@ -14,7 +14,6 @@ Ext.ns('Deluge');
* @extends Ext.Window * @extends Ext.Window
*/ */
Deluge.OtherLimitWindow = Ext.extend(Ext.Window, { Deluge.OtherLimitWindow = Ext.extend(Ext.Window, {
layout: 'fit', layout: 'fit',
width: 210, width: 210,
height: 100, height: 100,
@ -29,19 +28,21 @@ Deluge.OtherLimitWindow = Ext.extend(Ext.Window, {
bodyStyle: 'padding: 5px', bodyStyle: 'padding: 5px',
layout: 'hbox', layout: 'hbox',
layoutConfig: { layoutConfig: {
pack: 'start' pack: 'start',
}, },
items: [{ items: [
xtype: 'spinnerfield', {
name: 'limit' xtype: 'spinnerfield',
}] name: 'limit',
},
],
}); });
if (this.initialConfig.unit) { if (this.initialConfig.unit) {
this.form.add({ this.form.add({
border: false, border: false,
baseCls: 'x-plain', baseCls: 'x-plain',
bodyStyle: 'padding: 5px', bodyStyle: 'padding: 5px',
html: this.initialConfig.unit html: this.initialConfig.unit,
}); });
} else { } else {
this.setSize(180, 100); this.setSize(180, 100);
@ -53,7 +54,7 @@ Deluge.OtherLimitWindow = Ext.extend(Ext.Window, {
}, },
setValue: function(value) { setValue: function(value) {
this.form.getForm().setValues({limit: value}); this.form.getForm().setValues({ limit: value });
}, },
onCancelClick: function() { onCancelClick: function() {
@ -67,12 +68,15 @@ Deluge.OtherLimitWindow = Ext.extend(Ext.Window, {
deluge.client.core.set_config(config, { deluge.client.core.set_config(config, {
success: function() { success: function() {
deluge.ui.update(); deluge.ui.update();
} },
}); });
this.hide(); this.hide();
}, },
doFocusField: function() { doFocusField: function() {
this.form.getForm().findField('limit').focus(true, 10); this.form
} .getForm()
.findField('limit')
.focus(true, 10);
},
}); });

View File

@ -14,7 +14,6 @@ Ext.ns('Deluge');
* @extends Ext.util.Observable * @extends Ext.util.Observable
*/ */
Deluge.Plugin = Ext.extend(Ext.util.Observable, { Deluge.Plugin = Ext.extend(Ext.util.Observable, {
/** /**
* The plugins name * The plugins name
* @property name * @property name
@ -29,13 +28,13 @@ Deluge.Plugin = Ext.extend(Ext.util.Observable, {
* @event enabled * @event enabled
* @param {Plugin} plugin the plugin instance * @param {Plugin} plugin the plugin instance
*/ */
'enabled': true, enabled: true,
/** /**
* @event disabled * @event disabled
* @param {Plugin} plugin the plugin instance * @param {Plugin} plugin the plugin instance
*/ */
'disabled': true disabled: true,
}); });
Deluge.Plugin.superclass.constructor.call(this, config); Deluge.Plugin.superclass.constructor.call(this, config);
}, },
@ -61,14 +60,15 @@ Deluge.Plugin = Ext.extend(Ext.util.Observable, {
registerTorrentStatus: function(key, header, options) { registerTorrentStatus: function(key, header, options) {
options = options || {}; options = options || {};
var cc = options.colCfg || {}, sc = options.storeCfg || {}; var cc = options.colCfg || {},
sc = Ext.apply(sc, {name: key}); sc = options.storeCfg || {};
sc = Ext.apply(sc, { name: key });
deluge.torrents.meta.fields.push(sc); deluge.torrents.meta.fields.push(sc);
deluge.torrents.getStore().reader.onMetaChange(deluge.torrents.meta); deluge.torrents.getStore().reader.onMetaChange(deluge.torrents.meta);
cc = Ext.apply(cc, { cc = Ext.apply(cc, {
header: header, header: header,
dataIndex: key dataIndex: key,
}); });
var cols = deluge.torrents.columns.slice(0); var cols = deluge.torrents.columns.slice(0);
cols.push(cc); cols.push(cc);
@ -100,7 +100,7 @@ Deluge.Plugin = Ext.extend(Ext.util.Observable, {
}); });
Deluge.Keys.Grid = keys; Deluge.Keys.Grid = keys;
deluge.torrents.getView().refresh(true); deluge.torrents.getView().refresh(true);
} },
}); });
Ext.ns('Deluge.plugins'); Ext.ns('Deluge.plugins');

View File

@ -13,17 +13,16 @@
* @extends Ext.Window * @extends Ext.Window
*/ */
Deluge.RemoveWindow = Ext.extend(Ext.Window, { Deluge.RemoveWindow = Ext.extend(Ext.Window, {
title: _('Remove Torrent'),
title: _('Remove Torrent'),
layout: 'fit', layout: 'fit',
width: 350, width: 350,
height: 100, height: 100,
constrainHeader: true, constrainHeader: true,
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)?',
@ -39,12 +38,14 @@ Deluge.RemoveWindow = Ext.extend(Ext.Window, {
deluge.client.core.remove_torrents(this.torrentIds, removeData, { deluge.client.core.remove_torrents(this.torrentIds, removeData, {
success: function(result) { success: function(result) {
if (result == true) { if (result == true) {
console.log('Error(s) occured when trying to delete torrent(s).'); console.log(
'Error(s) occured when trying to delete torrent(s).'
);
} }
this.onRemoved(this.torrentIds); this.onRemoved(this.torrentIds);
}, },
scope: this, scope: this,
torrentIds: this.torrentIds torrentIds: this.torrentIds,
}); });
}, },
@ -70,7 +71,7 @@ Deluge.RemoveWindow = Ext.extend(Ext.Window, {
deluge.events.fire('torrentsRemoved', torrentIds); deluge.events.fire('torrentsRemoved', torrentIds);
this.hide(); this.hide();
deluge.ui.update(); deluge.ui.update();
} },
}); });
deluge.removeWindow = new Deluge.RemoveWindow(); deluge.removeWindow = new Deluge.RemoveWindow();

View File

@ -18,7 +18,6 @@
* @version 1.3 * @version 1.3
*/ */
Deluge.Sidebar = Ext.extend(Ext.Panel, { Deluge.Sidebar = Ext.extend(Ext.Panel, {
// private // private
panels: {}, panels: {},
@ -26,17 +25,20 @@ Deluge.Sidebar = Ext.extend(Ext.Panel, {
selected: null, selected: null,
constructor: function(config) { constructor: function(config) {
config = Ext.apply({ config = Ext.apply(
id: 'sidebar', {
region: 'west', id: 'sidebar',
cls: 'deluge-sidebar', region: 'west',
title: _('Filters'), cls: 'deluge-sidebar',
layout: 'accordion', title: _('Filters'),
split: true, layout: 'accordion',
width: 200, split: true,
minSize: 100, width: 200,
collapsible: true minSize: 100,
}, config); collapsible: true,
},
config
);
Deluge.Sidebar.superclass.constructor.call(this, config); Deluge.Sidebar.superclass.constructor.call(this, config);
}, },
@ -48,7 +50,7 @@ Deluge.Sidebar = Ext.extend(Ext.Panel, {
createFilter: function(filter, states) { createFilter: function(filter, states) {
var panel = new Deluge.FilterPanel({ var panel = new Deluge.FilterPanel({
filter: filter filter: filter,
}); });
panel.on('selectionchange', function(view, nodes) { panel.on('selectionchange', function(view, nodes) {
deluge.ui.update(); deluge.ui.update();
@ -77,7 +79,7 @@ Deluge.Sidebar = Ext.extend(Ext.Panel, {
}, },
getFilterStates: function() { getFilterStates: function() {
var states = {} var states = {};
if (deluge.config.sidebar_multiple_filters) { if (deluge.config.sidebar_multiple_filters) {
// Grab the filters from each of the filter panels // Grab the filters from each of the filter panels
@ -99,7 +101,7 @@ Deluge.Sidebar = Ext.extend(Ext.Panel, {
}, },
hasFilter: function(filter) { hasFilter: function(filter) {
return (this.panels[filter]) ? true : false; return this.panels[filter] ? true : false;
}, },
// private // private
@ -126,13 +128,17 @@ Deluge.Sidebar = Ext.extend(Ext.Panel, {
} }
// Perform a cleanup of fitlers that are not enabled any more. // Perform a cleanup of fitlers that are not enabled any more.
Ext.each(Ext.keys(this.panels), function(filter) { Ext.each(
if (Ext.keys(filters).indexOf(filter) == -1) { Ext.keys(this.panels),
// We need to remove the panel function(filter) {
this.remove(this.panels[filter]); if (Ext.keys(filters).indexOf(filter) == -1) {
this.doLayout(); // We need to remove the panel
delete this.panels[filter]; this.remove(this.panels[filter]);
} this.doLayout();
}, this); delete this.panels[filter];
} }
},
this
);
},
}); });

View File

@ -11,11 +11,14 @@ Ext.namespace('Deluge');
Deluge.Statusbar = Ext.extend(Ext.ux.StatusBar, { Deluge.Statusbar = Ext.extend(Ext.ux.StatusBar, {
constructor: function(config) { constructor: function(config) {
config = Ext.apply({ config = Ext.apply(
id: 'deluge-statusbar', {
defaultIconCls: 'x-deluge-statusbar x-not-connected', id: 'deluge-statusbar',
defaultText: _('Not Connected') defaultIconCls: 'x-deluge-statusbar x-not-connected',
}, config); defaultText: _('Not Connected'),
},
config
);
Deluge.Statusbar.superclass.constructor.call(this, config); Deluge.Statusbar.superclass.constructor.call(this, config);
}, },
@ -27,188 +30,229 @@ Deluge.Statusbar = Ext.extend(Ext.ux.StatusBar, {
}, },
createButtons: function() { createButtons: function() {
this.buttons = this.add({ this.buttons = this.add(
id: 'statusbar-connections', {
text: ' ', id: 'statusbar-connections',
cls: 'x-btn-text-icon', text: ' ',
iconCls: 'x-deluge-connections', cls: 'x-btn-text-icon',
tooltip: _('Connections'), iconCls: 'x-deluge-connections',
menu: new Deluge.StatusbarMenu({ tooltip: _('Connections'),
items: [{ menu: new Deluge.StatusbarMenu({
text: '50', items: [
value: '50', {
group: 'max_connections_global', text: '50',
checked: false value: '50',
},{ group: 'max_connections_global',
text: '100', checked: false,
value: '100', },
group: 'max_connections_global', {
checked: false text: '100',
},{ value: '100',
text: '200', group: 'max_connections_global',
value: '200', checked: false,
group: 'max_connections_global', },
checked: false {
},{ text: '200',
text: '300', value: '200',
value: '300', group: 'max_connections_global',
group: 'max_connections_global', checked: false,
checked: false },
},{ {
text: '500', text: '300',
value: '500', value: '300',
group: 'max_connections_global', group: 'max_connections_global',
checked: false checked: false,
},{ },
text: _('Unlimited'), {
value: '-1', text: '500',
group: 'max_connections_global', value: '500',
checked: false group: 'max_connections_global',
},'-',{ checked: false,
text: _('Other'), },
value: 'other', {
group: 'max_connections_global', text: _('Unlimited'),
checked: false value: '-1',
}], group: 'max_connections_global',
otherWin: { checked: false,
title: _('Set Maximum Connections') },
} '-',
}) {
}, '-', { text: _('Other'),
id: 'statusbar-downspeed', value: 'other',
text: ' ', group: 'max_connections_global',
cls: 'x-btn-text-icon', checked: false,
iconCls: 'x-deluge-downloading', },
tooltip: _('Download Speed'), ],
menu: new Deluge.StatusbarMenu({ otherWin: {
items: [{ title: _('Set Maximum Connections'),
value: '5', },
text: _('5 KiB/s'), }),
group: 'max_download_speed', },
checked: false '-',
},{ {
value: '10', id: 'statusbar-downspeed',
text: _('10 KiB/s'), text: ' ',
group: 'max_download_speed', cls: 'x-btn-text-icon',
checked: false iconCls: 'x-deluge-downloading',
},{ tooltip: _('Download Speed'),
value: '30', menu: new Deluge.StatusbarMenu({
text: _('30 KiB/s'), items: [
group: 'max_download_speed', {
checked: false value: '5',
},{ text: _('5 KiB/s'),
value: '80', group: 'max_download_speed',
text: _('80 KiB/s'), checked: false,
group: 'max_download_speed', },
checked: false {
},{ value: '10',
value: '300', text: _('10 KiB/s'),
text: _('300 KiB/s'), group: 'max_download_speed',
group: 'max_download_speed', checked: false,
checked: false },
},{ {
value: '-1', value: '30',
text: _('Unlimited'), text: _('30 KiB/s'),
group: 'max_download_speed', group: 'max_download_speed',
checked: false checked: false,
},'-',{ },
value: 'other', {
text: _('Other'), value: '80',
group: 'max_download_speed', text: _('80 KiB/s'),
checked: false group: 'max_download_speed',
}], checked: false,
otherWin: { },
title: _('Set Maximum Download Speed'), {
unit: _('KiB/s') value: '300',
} text: _('300 KiB/s'),
}) group: 'max_download_speed',
}, '-', { checked: false,
id: 'statusbar-upspeed', },
text: ' ', {
cls: 'x-btn-text-icon', value: '-1',
iconCls: 'x-deluge-seeding', text: _('Unlimited'),
tooltip: _('Upload Speed'), group: 'max_download_speed',
menu: new Deluge.StatusbarMenu({ checked: false,
items: [{ },
value: '5', '-',
text: _('5 KiB/s'), {
group: 'max_upload_speed', value: 'other',
checked: false text: _('Other'),
},{ group: 'max_download_speed',
value: '10', checked: false,
text: _('10 KiB/s'), },
group: 'max_upload_speed', ],
checked: false otherWin: {
},{ title: _('Set Maximum Download Speed'),
value: '30', unit: _('KiB/s'),
text: _('30 KiB/s'), },
group: 'max_upload_speed', }),
checked: false },
},{ '-',
value: '80', {
text: _('80 KiB/s'), id: 'statusbar-upspeed',
group: 'max_upload_speed', text: ' ',
checked: false cls: 'x-btn-text-icon',
},{ iconCls: 'x-deluge-seeding',
value: '300', tooltip: _('Upload Speed'),
text: _('300 KiB/s'), menu: new Deluge.StatusbarMenu({
group: 'max_upload_speed', items: [
checked: false {
},{ value: '5',
value: '-1', text: _('5 KiB/s'),
text: _('Unlimited'), group: 'max_upload_speed',
group: 'max_upload_speed', checked: false,
checked: false },
},'-',{ {
value: 'other', value: '10',
text: _('Other'), text: _('10 KiB/s'),
group: 'max_upload_speed', group: 'max_upload_speed',
checked: false checked: false,
}], },
otherWin: { {
title: _('Set Maximum Upload Speed'), value: '30',
unit: _('KiB/s') text: _('30 KiB/s'),
} group: 'max_upload_speed',
}) checked: false,
}, '-', { },
id: 'statusbar-traffic', {
text: ' ', value: '80',
cls: 'x-btn-text-icon', text: _('80 KiB/s'),
iconCls: 'x-deluge-traffic', group: 'max_upload_speed',
tooltip: _('Protocol Traffic Download/Upload'), checked: false,
handler: function() { },
deluge.preferences.show(); {
deluge.preferences.selectPage('Network'); value: '300',
text: _('300 KiB/s'),
group: 'max_upload_speed',
checked: false,
},
{
value: '-1',
text: _('Unlimited'),
group: 'max_upload_speed',
checked: false,
},
'-',
{
value: 'other',
text: _('Other'),
group: 'max_upload_speed',
checked: false,
},
],
otherWin: {
title: _('Set Maximum Upload Speed'),
unit: _('KiB/s'),
},
}),
},
'-',
{
id: 'statusbar-traffic',
text: ' ',
cls: 'x-btn-text-icon',
iconCls: 'x-deluge-traffic',
tooltip: _('Protocol Traffic Download/Upload'),
handler: function() {
deluge.preferences.show();
deluge.preferences.selectPage('Network');
},
},
'-',
{
id: 'statusbar-externalip',
text: ' ',
cls: 'x-btn-text',
tooltip: _('External IP Address'),
},
'-',
{
id: 'statusbar-dht',
text: ' ',
cls: 'x-btn-text-icon',
iconCls: 'x-deluge-dht',
tooltip: _('DHT Nodes'),
},
'-',
{
id: 'statusbar-freespace',
text: ' ',
cls: 'x-btn-text-icon',
iconCls: 'x-deluge-freespace',
tooltip: _('Freespace in download folder'),
handler: function() {
deluge.preferences.show();
deluge.preferences.selectPage('Downloads');
},
} }
}, '-', { );
id: 'statusbar-externalip',
text: ' ',
cls: 'x-btn-text',
tooltip: _('External IP Address')
}, '-', {
id: 'statusbar-dht',
text: ' ',
cls: 'x-btn-text-icon',
iconCls: 'x-deluge-dht',
tooltip: _('DHT Nodes')
}, '-', {
id: 'statusbar-freespace',
text: ' ',
cls: 'x-btn-text-icon',
iconCls: 'x-deluge-freespace',
tooltip: _('Freespace in download folder'),
handler: function() {
deluge.preferences.show();
deluge.preferences.selectPage('Downloads');
}
});
this.created = true; this.created = true;
}, },
onConnect: function() { onConnect: function() {
this.setStatus({ this.setStatus({
iconCls: 'x-connected', iconCls: 'x-connected',
text: '' text: '',
}); });
if (!this.created) { if (!this.created) {
this.createButtons(); this.createButtons();
@ -222,7 +266,7 @@ Deluge.Statusbar = Ext.extend(Ext.ux.StatusBar, {
}, },
onDisconnect: function() { onDisconnect: function() {
this.clearStatus({useDefaults:true}); this.clearStatus({ useDefaults: true });
Ext.each(this.buttons, function(item) { Ext.each(this.buttons, function(item) {
item.hide(); item.hide();
item.disable(); item.disable();
@ -233,16 +277,24 @@ Deluge.Statusbar = Ext.extend(Ext.ux.StatusBar, {
update: function(stats) { update: function(stats) {
if (!stats) return; if (!stats) return;
function addSpeed(val) {return val + ' KiB/s'} function addSpeed(val) {
return val + ' KiB/s';
}
var updateStat = function(name, config) { var updateStat = function(name, config) {
var item = this.items.get('statusbar-' + name); var item = this.items.get('statusbar-' + name);
if (config.limit.value > 0) { if (config.limit.value > 0) {
var value = (config.value.formatter) ? config.value.formatter(config.value.value, true) : config.value.value; var value = config.value.formatter
var limit = (config.limit.formatter) ? config.limit.formatter(config.limit.value, true) : config.limit.value; ? config.value.formatter(config.value.value, true)
: config.value.value;
var limit = config.limit.formatter
? config.limit.formatter(config.limit.value, true)
: config.limit.value;
var str = String.format(config.format, value, limit); var str = String.format(config.format, value, limit);
} else { } else {
var str = (config.value.formatter) ? config.value.formatter(config.value.value, true) : config.value.value; var str = config.value.formatter
? config.value.formatter(config.value.value, true)
: config.value.value;
} }
item.setText(str); item.setText(str);
@ -251,50 +303,60 @@ Deluge.Statusbar = Ext.extend(Ext.ux.StatusBar, {
}.createDelegate(this); }.createDelegate(this);
updateStat('connections', { updateStat('connections', {
value: {value: stats.num_connections}, value: { value: stats.num_connections },
limit: {value: stats.max_num_connections}, limit: { value: stats.max_num_connections },
format: '{0} ({1})' format: '{0} ({1})',
}); });
updateStat('downspeed', { updateStat('downspeed', {
value: { value: {
value: stats.download_rate, value: stats.download_rate,
formatter: Deluge.Formatters.speed formatter: Deluge.Formatters.speed,
}, },
limit: { limit: {
value: stats.max_download, value: stats.max_download,
formatter: addSpeed formatter: addSpeed,
}, },
format: '{0} ({1})' format: '{0} ({1})',
}); });
updateStat('upspeed', { updateStat('upspeed', {
value: { value: {
value: stats.upload_rate, value: stats.upload_rate,
formatter: Deluge.Formatters.speed formatter: Deluge.Formatters.speed,
}, },
limit: { limit: {
value: stats.max_upload, value: stats.max_upload,
formatter: addSpeed formatter: addSpeed,
}, },
format: '{0} ({1})' format: '{0} ({1})',
}); });
updateStat('traffic', { updateStat('traffic', {
value: { value: {
value: stats.download_protocol_rate, value: stats.download_protocol_rate,
formatter: Deluge.Formatters.speed formatter: Deluge.Formatters.speed,
}, },
limit: { limit: {
value: stats.upload_protocol_rate, value: stats.upload_protocol_rate,
formatter: Deluge.Formatters.speed formatter: Deluge.Formatters.speed,
}, },
format: '{0}/{1}' format: '{0}/{1}',
}); });
this.items.get('statusbar-dht').setText(stats.dht_nodes); this.items.get('statusbar-dht').setText(stats.dht_nodes);
this.items.get('statusbar-freespace').setText(stats.free_space >= 0 ? fsize(stats.free_space): _('Error')); this.items
this.items.get('statusbar-externalip').setText( .get('statusbar-freespace')
String.format(_('<b>IP</b> {0}'), stats.external_ip ? stats.external_ip: _("n/a"))); .setText(
} stats.free_space >= 0 ? fsize(stats.free_space) : _('Error')
);
this.items
.get('statusbar-externalip')
.setText(
String.format(
_('<b>IP</b> {0}'),
stats.external_ip ? stats.external_ip : _('n/a')
)
);
},
}); });

View File

@ -15,10 +15,11 @@ Ext.ns('Deluge');
* @extends Ext.menu.Menu * @extends Ext.menu.Menu
*/ */
Deluge.StatusbarMenu = Ext.extend(Ext.menu.Menu, { Deluge.StatusbarMenu = Ext.extend(Ext.menu.Menu, {
initComponent: function() { initComponent: function() {
Deluge.StatusbarMenu.superclass.initComponent.call(this); Deluge.StatusbarMenu.superclass.initComponent.call(this);
this.otherWin = new Deluge.OtherLimitWindow(this.initialConfig.otherWin || {}); this.otherWin = new Deluge.OtherLimitWindow(
this.initialConfig.otherWin || {}
);
this.items.each(function(item) { this.items.each(function(item) {
if (item.getXType() != 'menucheckitem') return; if (item.getXType() != 'menucheckitem') return;
@ -33,7 +34,7 @@ Deluge.StatusbarMenu = Ext.extend(Ext.menu.Menu, {
setValue: function(value) { setValue: function(value) {
var beenSet = false; var beenSet = false;
// set the new value // set the new value
this.value = value = (value == 0) ? -1 : value; this.value = value = value == 0 ? -1 : value;
var other = null; var other = null;
// uncheck all items // uncheck all items
@ -61,12 +62,12 @@ Deluge.StatusbarMenu = Ext.extend(Ext.menu.Menu, {
onLimitChanged: function(item, checked) { onLimitChanged: function(item, checked) {
if (!checked || item.value == 'other') return; // We do not care about unchecked or other. if (!checked || item.value == 'other') return; // We do not care about unchecked or other.
var config = {} var config = {};
config[item.group] = item.value config[item.group] = item.value;
deluge.client.core.set_config(config, { deluge.client.core.set_config(config, {
success: function() { success: function() {
deluge.ui.update(); deluge.ui.update();
} },
}); });
}, },
@ -74,5 +75,5 @@ Deluge.StatusbarMenu = Ext.extend(Ext.menu.Menu, {
this.otherWin.group = item.group; this.otherWin.group = item.group;
this.otherWin.setValue(this.value); this.otherWin.setValue(this.value);
this.otherWin.show(); this.otherWin.show();
} },
}); });

View File

@ -15,92 +15,108 @@
*/ */
Deluge.Toolbar = Ext.extend(Ext.Toolbar, { Deluge.Toolbar = Ext.extend(Ext.Toolbar, {
constructor: function(config) { constructor: function(config) {
config = Ext.apply({ config = Ext.apply(
items: [ {
{ items: [
id: 'tbar-deluge-text', {
disabled: true, id: 'tbar-deluge-text',
text: _('Deluge'), disabled: true,
iconCls: 'x-deluge-main-panel' text: _('Deluge'),
}, new Ext.Toolbar.Separator(), iconCls: 'x-deluge-main-panel',
{ },
id: 'create', new Ext.Toolbar.Separator(),
disabled: true, {
hidden: true, id: 'create',
text: _('Create'), disabled: true,
iconCls: 'icon-create', hidden: true,
handler: this.onTorrentAction text: _('Create'),
},{ iconCls: 'icon-create',
id: 'add', handler: this.onTorrentAction,
disabled: true, },
text: _('Add'), {
iconCls: 'icon-add', id: 'add',
handler: this.onTorrentAdd disabled: true,
},{ text: _('Add'),
id: 'remove', iconCls: 'icon-add',
disabled: true, handler: this.onTorrentAdd,
text: _('Remove'), },
iconCls: 'icon-remove', {
handler: this.onTorrentAction id: 'remove',
}, new Ext.Toolbar.Separator(),{ disabled: true,
id: 'pause', text: _('Remove'),
disabled: true, iconCls: 'icon-remove',
text: _('Pause'), handler: this.onTorrentAction,
iconCls: 'icon-pause', },
handler: this.onTorrentAction new Ext.Toolbar.Separator(),
},{ {
id: 'resume', id: 'pause',
disabled: true, disabled: true,
text: _('Resume'), text: _('Pause'),
iconCls: 'icon-resume', iconCls: 'icon-pause',
handler: this.onTorrentAction handler: this.onTorrentAction,
}, new Ext.Toolbar.Separator(),{ },
id: 'up', {
cls: 'x-btn-text-icon', id: 'resume',
disabled: true, disabled: true,
text: _('Up'), text: _('Resume'),
iconCls: 'icon-up', iconCls: 'icon-resume',
handler: this.onTorrentAction handler: this.onTorrentAction,
},{ },
id: 'down', new Ext.Toolbar.Separator(),
disabled: true, {
text: _('Down'), id: 'up',
iconCls: 'icon-down', cls: 'x-btn-text-icon',
handler: this.onTorrentAction disabled: true,
}, new Ext.Toolbar.Separator(),{ text: _('Up'),
id: 'preferences', iconCls: 'icon-up',
text: _('Preferences'), handler: this.onTorrentAction,
iconCls: 'x-deluge-preferences', },
handler: this.onPreferencesClick, {
scope: this id: 'down',
},{ disabled: true,
id: 'connectionman', text: _('Down'),
text: _('Connection Manager'), iconCls: 'icon-down',
iconCls: 'x-deluge-connection-manager', handler: this.onTorrentAction,
handler: this.onConnectionManagerClick, },
scope: this new Ext.Toolbar.Separator(),
},'->',{ {
id: 'help', id: 'preferences',
iconCls: 'icon-help', text: _('Preferences'),
text: _('Help'), iconCls: 'x-deluge-preferences',
handler: this.onHelpClick, handler: this.onPreferencesClick,
scope: this scope: this,
},{ },
id: 'logout', {
iconCls: 'icon-logout', id: 'connectionman',
disabled: true, text: _('Connection Manager'),
text: _('Logout'), iconCls: 'x-deluge-connection-manager',
handler: this.onLogout, handler: this.onConnectionManagerClick,
scope: this scope: this,
} },
] '->',
}, config); {
id: 'help',
iconCls: 'icon-help',
text: _('Help'),
handler: this.onHelpClick,
scope: this,
},
{
id: 'logout',
iconCls: 'icon-logout',
disabled: true,
text: _('Logout'),
handler: this.onLogout,
scope: this,
},
],
},
config
);
Deluge.Toolbar.superclass.constructor.call(this, config); Deluge.Toolbar.superclass.constructor.call(this, config);
}, },
connectedButtons: [ connectedButtons: ['add', 'remove', 'pause', 'resume', 'up', 'down'],
'add', 'remove', 'pause', 'resume', 'up', 'down'
],
initComponent: function() { initComponent: function() {
Deluge.Toolbar.superclass.initComponent.call(this); Deluge.Toolbar.superclass.initComponent.call(this);
@ -109,15 +125,23 @@ Deluge.Toolbar = Ext.extend(Ext.Toolbar, {
}, },
onConnect: function() { onConnect: function() {
Ext.each(this.connectedButtons, function(buttonId) { Ext.each(
this.items.get(buttonId).enable(); this.connectedButtons,
}, this); function(buttonId) {
this.items.get(buttonId).enable();
},
this
);
}, },
onDisconnect: function() { onDisconnect: function() {
Ext.each(this.connectedButtons, function(buttonId) { Ext.each(
this.items.get(buttonId).disable(); this.connectedButtons,
}, this); function(buttonId) {
this.items.get(buttonId).disable();
},
this
);
}, },
onLogin: function() { onLogin: function() {
@ -157,7 +181,7 @@ Deluge.Toolbar = Ext.extend(Ext.Toolbar, {
deluge.client.core[item.id + '_torrent'](ids, { deluge.client.core[item.id + '_torrent'](ids, {
success: function() { success: function() {
deluge.ui.update(); deluge.ui.update();
} },
}); });
break; break;
case 'up': case 'up':
@ -165,7 +189,7 @@ Deluge.Toolbar = Ext.extend(Ext.Toolbar, {
deluge.client.core['queue_' + item.id](ids, { deluge.client.core['queue_' + item.id](ids, {
success: function() { success: function() {
deluge.ui.update(); deluge.ui.update();
} },
}); });
break; break;
} }
@ -173,5 +197,5 @@ Deluge.Toolbar = Ext.extend(Ext.Toolbar, {
onTorrentAdd: function() { onTorrentAdd: function() {
deluge.add.show(); deluge.add.show();
} },
}); });

View File

@ -9,13 +9,16 @@
*/ */
(function() { (function() {
/* Renderers for the Torrent Grid */ /* Renderers for the Torrent Grid */
function queueRenderer(value) { function queueRenderer(value) {
return (value == -1) ? '' : value + 1; return value == -1 ? '' : value + 1;
} }
function torrentNameRenderer(value, p, r) { function torrentNameRenderer(value, p, r) {
return String.format('<div class="torrent-name x-deluge-{0}">{1}</div>', r.data['state'].toLowerCase(), value); return String.format(
'<div class="torrent-name x-deluge-{0}">{1}</div>',
r.data['state'].toLowerCase(),
value
);
} }
function torrentSpeedRenderer(value) { function torrentSpeedRenderer(value) {
if (!value) return; if (!value) return;
@ -29,10 +32,10 @@
value = new Number(value); value = new Number(value);
var progress = value; var progress = value;
var text = _(r.data['state']) + ' ' + value.toFixed(2) + '%'; var text = _(r.data['state']) + ' ' + value.toFixed(2) + '%';
if ( this.style ) { if (this.style) {
var style = this.style var style = this.style;
} else { } else {
var style = p.style var style = p.style;
} }
var width = new Number(style.match(/\w+:\s*(\d+)\w+/)[1]); var width = new Number(style.match(/\w+:\s*(\d+)\w+/)[1]);
return Deluge.progressBar(value, width - 8, text); return Deluge.progressBar(value, width - 8, text);
@ -52,10 +55,15 @@
} }
} }
function availRenderer(value, p, r) { function availRenderer(value, p, r) {
return (value < 0) ? '&infin;' : parseFloat(new Number(value).toFixed(3)); return value < 0 ? '&infin;' : parseFloat(new Number(value).toFixed(3));
} }
function trackerRenderer(value, p, r) { function trackerRenderer(value, p, r) {
return String.format('<div style="background: url(' + deluge.config.base + 'tracker/{0}) no-repeat; padding-left: 20px;">{0}</div>', value); return String.format(
'<div style="background: url(' +
deluge.config.base +
'tracker/{0}) no-repeat; padding-left: 20px;">{0}</div>',
value
);
} }
function etaSorter(eta) { function etaSorter(eta) {
@ -63,7 +71,7 @@
} }
function dateOrNever(date) { function dateOrNever(date) {
return date > 0.0 ? fdate(date) : _('Never') return date > 0.0 ? fdate(date) : _('Never');
} }
/** /**
@ -78,383 +86,421 @@
* @param {Object} config Configuration options * @param {Object} config Configuration options
*/ */
Deluge.TorrentGrid = Ext.extend(Ext.grid.GridPanel, { Deluge.TorrentGrid = Ext.extend(Ext.grid.GridPanel, {
// object to store contained torrent ids // object to store contained torrent ids
torrents: {}, torrents: {},
columns: [{ columns: [
id:'queue', {
header: '#', id: 'queue',
width: 30, header: '#',
sortable: true, width: 30,
renderer: queueRenderer, sortable: true,
dataIndex: 'queue' renderer: queueRenderer,
}, { dataIndex: 'queue',
id:'name', },
header: _('Name'), {
width: 150, id: 'name',
sortable: true, header: _('Name'),
renderer: torrentNameRenderer, width: 150,
dataIndex: 'name' sortable: true,
}, { renderer: torrentNameRenderer,
header: _('Size'), dataIndex: 'name',
width: 75, },
sortable: true, {
renderer: fsize, header: _('Size'),
dataIndex: 'total_wanted' width: 75,
}, { sortable: true,
header: _('Progress'), renderer: fsize,
width: 150, dataIndex: 'total_wanted',
sortable: true, },
renderer: torrentProgressRenderer, {
dataIndex: 'progress' header: _('Progress'),
}, { width: 150,
header: _('Seeds'), sortable: true,
hidden: true, renderer: torrentProgressRenderer,
width: 60, dataIndex: 'progress',
sortable: true, },
renderer: seedsRenderer, {
dataIndex: 'num_seeds' header: _('Seeds'),
}, { hidden: true,
header: _('Peers'), width: 60,
hidden: true, sortable: true,
width: 60, renderer: seedsRenderer,
sortable: true, dataIndex: 'num_seeds',
renderer: peersRenderer, },
dataIndex: 'num_peers' {
}, { header: _('Peers'),
header: _('Down Speed'), hidden: true,
width: 80, width: 60,
sortable: true, sortable: true,
renderer: torrentSpeedRenderer, renderer: peersRenderer,
dataIndex: 'download_payload_rate' dataIndex: 'num_peers',
}, { },
header: _('Up Speed'), {
width: 80, header: _('Down Speed'),
sortable: true, width: 80,
renderer: torrentSpeedRenderer, sortable: true,
dataIndex: 'upload_payload_rate' renderer: torrentSpeedRenderer,
}, { dataIndex: 'download_payload_rate',
header: _('ETA'), },
width: 60, {
sortable: true, header: _('Up Speed'),
renderer: ftime, width: 80,
dataIndex: 'eta' sortable: true,
}, { renderer: torrentSpeedRenderer,
header: _('Ratio'), dataIndex: 'upload_payload_rate',
hidden: true, },
width: 60, {
sortable: true, header: _('ETA'),
renderer: availRenderer, width: 60,
dataIndex: 'ratio' sortable: true,
}, { renderer: ftime,
header: _('Avail'), dataIndex: 'eta',
hidden: true, },
width: 60, {
sortable: true, header: _('Ratio'),
renderer: availRenderer, hidden: true,
dataIndex: 'distributed_copies' width: 60,
}, { sortable: true,
header: _('Added'), renderer: availRenderer,
hidden: true, dataIndex: 'ratio',
width: 80, },
sortable: true, {
renderer: fdate, header: _('Avail'),
dataIndex: 'time_added' hidden: true,
}, { width: 60,
header: _('Complete Seen'), sortable: true,
hidden: true, renderer: availRenderer,
width: 80, dataIndex: 'distributed_copies',
sortable: true, },
renderer: dateOrNever, {
dataIndex: 'last_seen_complete' header: _('Added'),
}, { hidden: true,
header: _('Completed'), width: 80,
hidden: true, sortable: true,
width: 80, renderer: fdate,
sortable: true, dataIndex: 'time_added',
renderer: dateOrNever, },
dataIndex: 'completed_time' {
}, { header: _('Complete Seen'),
header: _('Tracker'), hidden: true,
hidden: true, width: 80,
width: 120, sortable: true,
sortable: true, renderer: dateOrNever,
renderer: trackerRenderer, dataIndex: 'last_seen_complete',
dataIndex: 'tracker_host' },
}, { {
header: _('Download Folder'), header: _('Completed'),
hidden: true, hidden: true,
width: 120, width: 80,
sortable: true, sortable: true,
renderer: fplain, renderer: dateOrNever,
dataIndex: 'download_location' dataIndex: 'completed_time',
}, { },
header: _('Owner'), {
width: 80, header: _('Tracker'),
sortable: true, hidden: true,
renderer: fplain, width: 120,
dataIndex: 'owner' sortable: true,
}, { renderer: trackerRenderer,
header: _('Public'), dataIndex: 'tracker_host',
hidden: true, },
width: 80, {
sortable: true, header: _('Download Folder'),
renderer: fplain, hidden: true,
dataIndex: 'public' width: 120,
}, { sortable: true,
header: _('Shared'), renderer: fplain,
hidden: true, dataIndex: 'download_location',
width: 80, },
sortable: true, {
renderer: fplain, header: _('Owner'),
dataIndex: 'shared' width: 80,
}, { sortable: true,
header: _('Downloaded'), renderer: fplain,
hidden: true, dataIndex: 'owner',
width: 75, },
sortable: true, {
renderer: fsize, header: _('Public'),
dataIndex: 'total_done' hidden: true,
}, { width: 80,
header: _('Uploaded'), sortable: true,
hidden: true, renderer: fplain,
width: 75, dataIndex: 'public',
sortable: true, },
renderer: fsize, {
dataIndex: 'total_uploaded' header: _('Shared'),
}, { hidden: true,
header: _('Remaining'), width: 80,
hidden: true, sortable: true,
width: 75, renderer: fplain,
sortable: true, dataIndex: 'shared',
renderer: fsize, },
dataIndex: 'total_remaining' {
}, { header: _('Downloaded'),
header: _('Down Limit'), hidden: true,
hidden: true, width: 75,
width: 75, sortable: true,
sortable: true, renderer: fsize,
renderer: torrentLimitRenderer, dataIndex: 'total_done',
dataIndex: 'max_download_speed' },
}, { {
header: _('Up Limit'), header: _('Uploaded'),
hidden: true, hidden: true,
width: 75, width: 75,
sortable: true, sortable: true,
renderer: torrentLimitRenderer, renderer: fsize,
dataIndex: 'max_upload_speed' dataIndex: 'total_uploaded',
}, { },
header: _('Seeds:Peers'), {
hidden: true, header: _('Remaining'),
width: 75, hidden: true,
sortable: true, width: 75,
renderer: availRenderer, sortable: true,
dataIndex: 'seeds_peers_ratio' renderer: fsize,
}, { dataIndex: 'total_remaining',
header: _('Last Transfer'), },
hidden: true, {
width: 75, header: _('Down Limit'),
sortable: true, hidden: true,
renderer: ftime, width: 75,
dataIndex: 'time_since_transfer' sortable: true,
}], renderer: torrentLimitRenderer,
dataIndex: 'max_download_speed',
},
{
header: _('Up Limit'),
hidden: true,
width: 75,
sortable: true,
renderer: torrentLimitRenderer,
dataIndex: 'max_upload_speed',
},
{
header: _('Seeds:Peers'),
hidden: true,
width: 75,
sortable: true,
renderer: availRenderer,
dataIndex: 'seeds_peers_ratio',
},
{
header: _('Last Transfer'),
hidden: true,
width: 75,
sortable: true,
renderer: ftime,
dataIndex: 'time_since_transfer',
},
],
meta: { meta: {
root: 'torrents', root: 'torrents',
idProperty: 'id', idProperty: 'id',
fields: [ fields: [
{name: 'queue', sortType: Deluge.data.SortTypes.asQueuePosition}, {
{name: 'name', sortType: Deluge.data.SortTypes.asName}, name: 'queue',
{name: 'total_wanted', type: 'int'}, sortType: Deluge.data.SortTypes.asQueuePosition,
{name: 'state'}, },
{name: 'progress', type: 'float'}, { name: 'name', sortType: Deluge.data.SortTypes.asName },
{name: 'num_seeds', type: 'int'}, { name: 'total_wanted', type: 'int' },
{name: 'total_seeds', type: 'int'}, { name: 'state' },
{name: 'num_peers', type: 'int'}, { name: 'progress', type: 'float' },
{name: 'total_peers', type: 'int'}, { name: 'num_seeds', type: 'int' },
{name: 'download_payload_rate', type: 'int'}, { name: 'total_seeds', type: 'int' },
{name: 'upload_payload_rate', type: 'int'}, { name: 'num_peers', type: 'int' },
{name: 'eta', type: 'int', sortType: etaSorter}, { name: 'total_peers', type: 'int' },
{name: 'ratio', type: 'float'}, { name: 'download_payload_rate', type: 'int' },
{name: 'distributed_copies', type: 'float'}, { name: 'upload_payload_rate', type: 'int' },
{name: 'time_added', type: 'int'}, { name: 'eta', type: 'int', sortType: etaSorter },
{name: 'tracker_host'}, { name: 'ratio', type: 'float' },
{name: 'download_location'}, { name: 'distributed_copies', type: 'float' },
{name: 'total_done', type: 'int'}, { name: 'time_added', type: 'int' },
{name: 'total_uploaded', type: 'int'}, { name: 'tracker_host' },
{name: 'total_remaining', type: 'int'}, { name: 'download_location' },
{name: 'max_download_speed', type: 'int'}, { name: 'total_done', type: 'int' },
{name: 'max_upload_speed', type: 'int'}, { name: 'total_uploaded', type: 'int' },
{name: 'seeds_peers_ratio', type: 'float'}, { name: 'total_remaining', type: 'int' },
{name: 'time_since_transfer', type: 'int'} { name: 'max_download_speed', type: 'int' },
] { name: 'max_upload_speed', type: 'int' },
{ name: 'seeds_peers_ratio', type: 'float' },
{ name: 'time_since_transfer', type: 'int' },
],
}, },
keys: [{ keys: [
key: 'a', {
ctrl: true, key: 'a',
stopEvent: true, ctrl: true,
handler: function() { stopEvent: true,
deluge.torrents.getSelectionModel().selectAll(); handler: function() {
} deluge.torrents.getSelectionModel().selectAll();
}, { },
key: [46], },
stopEvent: true, {
handler: function() { key: [46],
ids = deluge.torrents.getSelectedIds(); stopEvent: true,
deluge.removeWindow.show(ids); handler: function() {
} ids = deluge.torrents.getSelectedIds();
}], deluge.removeWindow.show(ids);
},
},
],
constructor: function(config) { constructor: function(config) {
config = Ext.apply({ config = Ext.apply(
id: 'torrentGrid', {
store: new Ext.data.JsonStore(this.meta), id: 'torrentGrid',
columns: this.columns, store: new Ext.data.JsonStore(this.meta),
keys: this.keys, columns: this.columns,
region: 'center', keys: this.keys,
cls: 'deluge-torrents', region: 'center',
stripeRows: true, cls: 'deluge-torrents',
autoExpandColumn: 'name', stripeRows: true,
autoExpandMin: 150, autoExpandColumn: 'name',
deferredRender:false, autoExpandMin: 150,
autoScroll:true, deferredRender: false,
stateful: true, autoScroll: true,
view: new Ext.ux.grid.BufferView({ stateful: true,
rowHeight: 26, view: new Ext.ux.grid.BufferView({
scrollDelay: false rowHeight: 26,
}) scrollDelay: false,
}, config); }),
},
config
);
Deluge.TorrentGrid.superclass.constructor.call(this, config); Deluge.TorrentGrid.superclass.constructor.call(this, config);
}, },
initComponent: function() { initComponent: function() {
Deluge.TorrentGrid.superclass.initComponent.call(this); Deluge.TorrentGrid.superclass.initComponent.call(this);
deluge.events.on('torrentsRemoved', this.onTorrentsRemoved, this); deluge.events.on('torrentsRemoved', this.onTorrentsRemoved, this);
deluge.events.on('disconnect', this.onDisconnect, this); deluge.events.on('disconnect', this.onDisconnect, this);
this.on('rowcontextmenu', function(grid, rowIndex, e) { this.on('rowcontextmenu', function(grid, rowIndex, e) {
e.stopEvent(); e.stopEvent();
var selection = grid.getSelectionModel(); var selection = grid.getSelectionModel();
if (!selection.isSelected(rowIndex)) { if (!selection.isSelected(rowIndex)) {
selection.selectRow(rowIndex); selection.selectRow(rowIndex);
}
deluge.menus.torrent.showAt(e.getPoint());
});
},
/**
* Returns the record representing the torrent at the specified index.
*
* @param index {int} The row index of the torrent you wish to retrieve.
* @return {Ext.data.Record} The record representing the torrent.
*/
getTorrent: function(index) {
return this.getStore().getAt(index);
},
/**
* Returns the currently selected record.
* @ return {Array/Ext.data.Record} The record(s) representing the rows
*/
getSelected: function() {
return this.getSelectionModel().getSelected();
},
/**
* Returns the currently selected records.
*/
getSelections: function() {
return this.getSelectionModel().getSelections();
},
/**
* Return the currently selected torrent id.
* @return {String} The currently selected id.
*/
getSelectedId: function() {
return this.getSelectionModel().getSelected().id
},
/**
* Return the currently selected torrent ids.
* @return {Array} The currently selected ids.
*/
getSelectedIds: function() {
var ids = [];
Ext.each(this.getSelectionModel().getSelections(), function(r) {
ids.push(r.id);
});
return ids;
},
update: function(torrents, wipe) {
var store = this.getStore();
// Need to perform a complete reload of the torrent grid.
if (wipe) {
store.removeAll();
this.torrents = {};
}
var newTorrents = [];
// Update and add any new torrents.
for (var t in torrents) {
var torrent = torrents[t];
if (this.torrents[t]) {
var record = store.getById(t);
record.beginEdit();
for (var k in torrent) {
if (record.get(k) != torrent[k]) {
record.set(k, torrent[k]);
}
} }
record.endEdit(); deluge.menus.torrent.showAt(e.getPoint());
} else { });
var record = new Deluge.data.Torrent(torrent); },
record.id = t;
this.torrents[t] = 1; /**
newTorrents.push(record); * Returns the record representing the torrent at the specified index.
*
* @param index {int} The row index of the torrent you wish to retrieve.
* @return {Ext.data.Record} The record representing the torrent.
*/
getTorrent: function(index) {
return this.getStore().getAt(index);
},
/**
* Returns the currently selected record.
* @ return {Array/Ext.data.Record} The record(s) representing the rows
*/
getSelected: function() {
return this.getSelectionModel().getSelected();
},
/**
* Returns the currently selected records.
*/
getSelections: function() {
return this.getSelectionModel().getSelections();
},
/**
* Return the currently selected torrent id.
* @return {String} The currently selected id.
*/
getSelectedId: function() {
return this.getSelectionModel().getSelected().id;
},
/**
* Return the currently selected torrent ids.
* @return {Array} The currently selected ids.
*/
getSelectedIds: function() {
var ids = [];
Ext.each(this.getSelectionModel().getSelections(), function(r) {
ids.push(r.id);
});
return ids;
},
update: function(torrents, wipe) {
var store = this.getStore();
// Need to perform a complete reload of the torrent grid.
if (wipe) {
store.removeAll();
this.torrents = {};
} }
}
store.add(newTorrents);
// Remove any torrents that should not be in the store. var newTorrents = [];
store.each(function(record) {
if (!torrents[record.id]) { // Update and add any new torrents.
store.remove(record); for (var t in torrents) {
delete this.torrents[record.id]; var torrent = torrents[t];
if (this.torrents[t]) {
var record = store.getById(t);
record.beginEdit();
for (var k in torrent) {
if (record.get(k) != torrent[k]) {
record.set(k, torrent[k]);
}
}
record.endEdit();
} else {
var record = new Deluge.data.Torrent(torrent);
record.id = t;
this.torrents[t] = 1;
newTorrents.push(record);
}
} }
}, this); store.add(newTorrents);
store.commitChanges();
var sortState = store.getSortState() // Remove any torrents that should not be in the store.
if (!sortState) return; store.each(function(record) {
store.sort(sortState.field, sortState.direction); if (!torrents[record.id]) {
}, store.remove(record);
delete this.torrents[record.id];
}
}, this);
store.commitChanges();
// private var sortState = store.getSortState();
onDisconnect: function() { if (!sortState) return;
this.getStore().removeAll(); store.sort(sortState.field, sortState.direction);
this.torrents = {}; },
},
// private // private
onTorrentsRemoved: function(torrentIds) { onDisconnect: function() {
var selModel = this.getSelectionModel(); this.getStore().removeAll();
Ext.each(torrentIds, function(torrentId) { this.torrents = {};
var record = this.getStore().getById(torrentId); },
if (selModel.isSelected(record)) {
selModel.deselectRow(this.getStore().indexOf(record)); // private
} onTorrentsRemoved: function(torrentIds) {
this.getStore().remove(record); var selModel = this.getSelectionModel();
delete this.torrents[torrentId]; Ext.each(
}, this); torrentIds,
} function(torrentId) {
}); var record = this.getStore().getById(torrentId);
deluge.torrents = new Deluge.TorrentGrid(); if (selModel.isSelected(record)) {
selModel.deselectRow(this.getStore().indexOf(record));
}
this.getStore().remove(record);
delete this.torrents[torrentId];
},
this
);
},
});
deluge.torrents = new Deluge.TorrentGrid();
})(); })();

View File

@ -9,11 +9,11 @@
*/ */
/** Dummy translation arrays so Torrent states are available for gettext.js and Translators. /** Dummy translation arrays so Torrent states are available for gettext.js and Translators.
* *
* All entries in deluge.common.TORRENT_STATE should be added here. * All entries in deluge.common.TORRENT_STATE should be added here.
* *
* No need to import these, just simply use the `_()` function around a status variable. * No need to import these, just simply use the `_()` function around a status variable.
*/ */
var TORRENT_STATE_TRANSLATION = [ var TORRENT_STATE_TRANSLATION = [
_('All'), _('All'),
_('Active'), _('Active'),
@ -24,7 +24,8 @@ var TORRENT_STATE_TRANSLATION = [
_('Paused'), _('Paused'),
_('Checking'), _('Checking'),
_('Queued'), _('Queued'),
_('Error')]; _('Error'),
];
/** /**
* @static * @static
@ -33,7 +34,6 @@ var TORRENT_STATE_TRANSLATION = [
* together and handles the 2 second poll. * together and handles the 2 second poll.
*/ */
deluge.ui = { deluge.ui = {
errorCount: 0, errorCount: 0,
filters: null, filters: null,
@ -62,9 +62,7 @@ deluge.ui = {
minSize: 100, minSize: 100,
collapsible: true, collapsible: true,
layout: 'fit', layout: 'fit',
items: [ items: [deluge.details],
deluge.details
]
}); });
this.MainPanel = new Ext.Panel({ this.MainPanel = new Ext.Panel({
@ -73,17 +71,13 @@ deluge.ui = {
layout: 'border', layout: 'border',
border: false, border: false,
tbar: deluge.toolbar, tbar: deluge.toolbar,
items: [ items: [deluge.sidebar, this.detailsPanel, deluge.torrents],
deluge.sidebar, bbar: deluge.statusbar,
this.detailsPanel,
deluge.torrents
],
bbar: deluge.statusbar
}); });
this.Viewport = new Ext.Viewport({ this.Viewport = new Ext.Viewport({
layout: 'fit', layout: 'fit',
items: [this.MainPanel] items: [this.MainPanel],
}); });
deluge.events.on('connect', this.onConnect, this); deluge.events.on('connect', this.onConnect, this);
@ -91,7 +85,7 @@ deluge.ui = {
deluge.events.on('PluginDisabledEvent', this.onPluginDisabled, this); deluge.events.on('PluginDisabledEvent', this.onPluginDisabled, this);
deluge.events.on('PluginEnabledEvent', this.onPluginEnabled, this); deluge.events.on('PluginEnabledEvent', this.onPluginEnabled, this);
deluge.client = new Ext.ux.util.RpcClient({ deluge.client = new Ext.ux.util.RpcClient({
url: deluge.config.base + 'json' url: deluge.config.base + 'json',
}); });
// enable all the already active plugins // enable all the already active plugins
@ -104,9 +98,14 @@ deluge.ui = {
// Initialize quicktips so all the tooltip configs start working. // Initialize quicktips so all the tooltip configs start working.
Ext.QuickTips.init(); Ext.QuickTips.init();
deluge.client.on('connected', function(e) { deluge.client.on(
deluge.login.show(); 'connected',
}, this, {single: true}); function(e) {
deluge.login.show();
},
this,
{ single: true }
);
this.update = this.update.createDelegate(this); this.update = this.update.createDelegate(this);
this.checkConnection = this.checkConnection.createDelegate(this); this.checkConnection = this.checkConnection.createDelegate(this);
@ -118,7 +117,7 @@ deluge.ui = {
deluge.client.web.connected({ deluge.client.web.connected({
success: this.onConnectionSuccess, success: this.onConnectionSuccess,
failure: this.onConnectionError, failure: this.onConnectionError,
scope: this scope: this,
}); });
}, },
@ -130,19 +129,17 @@ deluge.ui = {
deluge.client.web.update_ui(Deluge.Keys.Grid, filters, { deluge.client.web.update_ui(Deluge.Keys.Grid, filters, {
success: this.onUpdate, success: this.onUpdate,
failure: this.onUpdateError, failure: this.onUpdateError,
scope: this scope: this,
}); });
deluge.details.update(); deluge.details.update();
}, },
onConnectionError: function(error) { onConnectionError: function(error) {},
},
onConnectionSuccess: function(result) { onConnectionSuccess: function(result) {
deluge.statusbar.setStatus({ deluge.statusbar.setStatus({
iconCls: 'x-deluge-statusbar icon-ok', iconCls: 'x-deluge-statusbar icon-ok',
text: _('Connection restored') text: _('Connection restored'),
}); });
clearInterval(this.checking); clearInterval(this.checking);
if (!result) { if (!result) {
@ -156,12 +153,12 @@ deluge.ui = {
title: _('Lost Connection'), title: _('Lost Connection'),
msg: _('The connection to the webserver has been lost!'), msg: _('The connection to the webserver has been lost!'),
buttons: Ext.MessageBox.OK, buttons: Ext.MessageBox.OK,
icon: Ext.MessageBox.ERROR icon: Ext.MessageBox.ERROR,
}); });
deluge.events.fire('disconnect'); deluge.events.fire('disconnect');
deluge.statusbar.setStatus({ deluge.statusbar.setStatus({
text: _('Lost connection to webserver')} text: _('Lost connection to webserver'),
); });
this.checking = setInterval(this.checkConnection, 2000); this.checking = setInterval(this.checkConnection, 2000);
} }
this.errorCount++; this.errorCount++;
@ -179,8 +176,12 @@ deluge.ui = {
} }
if (deluge.config.show_session_speed) { if (deluge.config.show_session_speed) {
document.title = 'D: ' + fsize_short(data['stats'].download_rate, true) + document.title =
' U: ' + fsize_short(data['stats'].upload_rate, true) + ' - ' + 'D: ' +
fsize_short(data['stats'].download_rate, true) +
' U: ' +
fsize_short(data['stats'].upload_rate, true) +
' - ' +
this.originalTitle; this.originalTitle;
} }
if (Ext.areObjectsEqual(this.filters, this.oldFilters)) { if (Ext.areObjectsEqual(this.filters, this.oldFilters)) {
@ -205,7 +206,7 @@ deluge.ui = {
} }
deluge.client.web.get_plugins({ deluge.client.web.get_plugins({
success: this.onGotPlugins, success: this.onGotPlugins,
scope: this scope: this,
}); });
}, },
@ -218,13 +219,17 @@ deluge.ui = {
}, },
onGotPlugins: function(plugins) { onGotPlugins: function(plugins) {
Ext.each(plugins.enabled_plugins, function(plugin) { Ext.each(
if (deluge.plugins[plugin]) return; plugins.enabled_plugins,
deluge.client.web.get_plugin_resources(plugin, { function(plugin) {
success: this.onGotPluginResources, if (deluge.plugins[plugin]) return;
scope: this deluge.client.web.get_plugin_resources(plugin, {
}); success: this.onGotPluginResources,
}, this); scope: this,
});
},
this
);
}, },
onPluginEnabled: function(pluginName) { onPluginEnabled: function(pluginName) {
@ -233,20 +238,26 @@ deluge.ui = {
} else { } else {
deluge.client.web.get_plugin_resources(pluginName, { deluge.client.web.get_plugin_resources(pluginName, {
success: this.onGotPluginResources, success: this.onGotPluginResources,
scope: this scope: this,
}); });
} }
}, },
onGotPluginResources: function(resources) { onGotPluginResources: function(resources) {
var scripts = (Deluge.debug) ? resources.debug_scripts : resources.scripts; var scripts = Deluge.debug
Ext.each(scripts, function(script) { ? resources.debug_scripts
Ext.ux.JSLoader({ : resources.scripts;
url: deluge.config.base + script, Ext.each(
onLoad: this.onPluginLoaded, scripts,
pluginName: resources.name function(script) {
}); Ext.ux.JSLoader({
}, this); url: deluge.config.base + script,
onLoad: this.onPluginLoaded,
pluginName: resources.name,
});
},
this
);
}, },
onPluginDisabled: function(pluginName) { onPluginDisabled: function(pluginName) {
@ -273,8 +284,8 @@ deluge.ui = {
this.running = false; this.running = false;
deluge.torrents.getStore().removeAll(); deluge.torrents.getStore().removeAll();
} }
} },
} };
Ext.onReady(function(e) { Ext.onReady(function(e) {
deluge.ui.initialize(); deluge.ui.initialize();

View File

@ -12,30 +12,38 @@ Ext.namespace('Deluge.add');
// This override allows file upload buttons to contain icons // This override allows file upload buttons to contain icons
Ext.override(Ext.ux.form.FileUploadField, { Ext.override(Ext.ux.form.FileUploadField, {
onRender : function(ct, position){ onRender: function(ct, position) {
Ext.ux.form.FileUploadField.superclass.onRender.call(this, ct, position); Ext.ux.form.FileUploadField.superclass.onRender.call(
this,
ct,
position
);
this.wrap = this.el.wrap({cls:'x-form-field-wrap x-form-file-wrap'}); this.wrap = this.el.wrap({ cls: 'x-form-field-wrap x-form-file-wrap' });
this.el.addClass('x-form-file-text'); this.el.addClass('x-form-file-text');
this.el.dom.removeAttribute('name'); this.el.dom.removeAttribute('name');
this.createFileInput(); this.createFileInput();
var btnCfg = Ext.applyIf(this.buttonCfg || {}, { var btnCfg = Ext.applyIf(this.buttonCfg || {}, {
text: this.buttonText text: this.buttonText,
}); });
this.button = new Ext.Button(Ext.apply(btnCfg, { this.button = new Ext.Button(
renderTo: this.wrap, Ext.apply(btnCfg, {
cls: 'x-form-file-btn' + (btnCfg.iconCls ? ' x-btn-text-icon' : '') renderTo: this.wrap,
})); cls:
'x-form-file-btn' +
(btnCfg.iconCls ? ' x-btn-text-icon' : ''),
})
);
if(this.buttonOnly){ if (this.buttonOnly) {
this.el.hide(); this.el.hide();
this.wrap.setWidth(this.button.getEl().getWidth()); this.wrap.setWidth(this.button.getEl().getWidth());
} }
this.bindListeners(); this.bindListeners();
this.resizeEl = this.positionEl = this.wrap; this.resizeEl = this.positionEl = this.wrap;
} },
}); });
Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, { Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
@ -58,39 +66,47 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
function torrentRenderer(value, p, r) { function torrentRenderer(value, p, r) {
if (r.data['info_hash']) { if (r.data['info_hash']) {
return String.format('<div class="x-deluge-add-torrent-name">{0}</div>', value); return String.format(
'<div class="x-deluge-add-torrent-name">{0}</div>',
value
);
} else { } else {
return String.format('<div class="x-deluge-add-torrent-name-loading">{0}</div>', value); return String.format(
'<div class="x-deluge-add-torrent-name-loading">{0}</div>',
value
);
} }
} }
this.list = new Ext.list.ListView({ this.list = new Ext.list.ListView({
store: new Ext.data.SimpleStore({ store: new Ext.data.SimpleStore({
fields: [ fields: [
{name: 'info_hash', mapping: 1}, { name: 'info_hash', mapping: 1 },
{name: 'text', mapping: 2} { name: 'text', mapping: 2 },
], ],
id: 0 id: 0,
}), }),
columns: [{ columns: [
id: 'torrent', {
width: 150, id: 'torrent',
sortable: true, width: 150,
renderer: torrentRenderer, sortable: true,
dataIndex: 'text' renderer: torrentRenderer,
}], dataIndex: 'text',
},
],
stripeRows: true, stripeRows: true,
singleSelect: true, singleSelect: true,
listeners: { listeners: {
'selectionchange': { selectionchange: {
fn: this.onSelect, fn: this.onSelect,
scope: this scope: this,
} },
}, },
hideHeaders: true, hideHeaders: true,
autoExpandColumn: 'torrent', autoExpandColumn: 'torrent',
height: '100%', height: '100%',
autoScroll: true autoScroll: true,
}); });
this.add({ this.add({
@ -98,43 +114,51 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
items: [this.list], items: [this.list],
border: false, border: false,
bbar: new Ext.Toolbar({ bbar: new Ext.Toolbar({
items: [{ items: [
id: 'fileUploadForm', {
xtype: 'form', id: 'fileUploadForm',
layout: 'fit', xtype: 'form',
baseCls: 'x-plain', layout: 'fit',
fileUpload: true, baseCls: 'x-plain',
items: [{ fileUpload: true,
buttonOnly: true, items: [
xtype: 'fileuploadfield', {
id: 'torrentFile', buttonOnly: true,
name: 'file', xtype: 'fileuploadfield',
buttonCfg: { id: 'torrentFile',
iconCls: 'x-deluge-add-file', name: 'file',
text: _('File') buttonCfg: {
}, iconCls: 'x-deluge-add-file',
listeners: { text: _('File'),
scope: this, },
'fileselected': this.onFileSelected listeners: {
} scope: this,
}] fileselected: this.onFileSelected,
}, { },
text: _('Url'), },
iconCls: 'icon-add-url', ],
handler: this.onUrl, },
scope: this {
}, { text: _('Url'),
text: _('Infohash'), iconCls: 'icon-add-url',
iconCls: 'icon-add-magnet', handler: this.onUrl,
hidden: true, scope: this,
disabled: true },
}, '->', { {
text: _('Remove'), text: _('Infohash'),
iconCls: 'icon-remove', iconCls: 'icon-add-magnet',
handler: this.onRemove, hidden: true,
scope: this disabled: true,
}] },
}) '->',
{
text: _('Remove'),
iconCls: 'icon-remove',
handler: this.onRemove,
scope: this,
},
],
}),
}); });
this.fileUploadForm = Ext.getCmp('fileUploadForm').getForm(); this.fileUploadForm = Ext.getCmp('fileUploadForm').getForm();
@ -157,13 +181,12 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
var id = r.get('info_hash'); var id = r.get('info_hash');
torrents.push({ torrents.push({
path: this.optionsPanel.getFilename(id), path: this.optionsPanel.getFilename(id),
options: this.optionsPanel.getOptions(id) options: this.optionsPanel.getOptions(id),
}); });
}, this); }, this);
deluge.client.web.add_torrents(torrents, { deluge.client.web.add_torrents(torrents, {
success: function(result) { success: function(result) {},
}
}); });
this.clear(); this.clear();
this.hide(); this.hide();
@ -192,7 +215,8 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
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) {
@ -222,7 +246,7 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
url: deluge.config.base + 'upload', url: deluge.config.base + 'upload',
waitMsg: _('Uploading your torrent...'), waitMsg: _('Uploading your torrent...'),
success: this.onUploadSuccess, success: this.onUploadSuccess,
scope: this scope: this,
}); });
var name = this.fileUploadForm.findField('torrentFile').value; var name = this.fileUploadForm.findField('torrentFile').value;
name = name.split('\\').slice(-1)[0]; name = name.split('\\').slice(-1)[0];
@ -237,7 +261,7 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
deluge.client.web.get_torrent_info(filename, { deluge.client.web.get_torrent_info(filename, {
success: this.onGotInfo, success: this.onGotInfo,
scope: this, scope: this,
filename: filename filename: filename,
}); });
} }
}, },
@ -261,7 +285,7 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
buttons: Ext.MessageBox.OK, buttons: Ext.MessageBox.OK,
modal: false, modal: false,
icon: Ext.MessageBox.ERROR, icon: Ext.MessageBox.ERROR,
iconCls: 'x-deluge-icon-error' iconCls: 'x-deluge-icon-error',
}); });
this.list.getStore().remove(r); this.list.getStore().remove(r);
} else { } else {
@ -275,5 +299,5 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
onUrl: function(button, event) { onUrl: function(button, event) {
this.url.show(); this.url.show();
} },
}); });

View File

@ -14,39 +14,46 @@ Ext.ns('Deluge.add');
* @extends Ext.ux.tree.TreeGrid * @extends Ext.ux.tree.TreeGrid
*/ */
Deluge.add.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, { Deluge.add.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
layout: 'fit', layout: 'fit',
title: _('Files'), title: _('Files'),
autoScroll: false, autoScroll: false,
animate: false, animate: false,
border: false, border: false,
disabled: true, disabled: true,
rootVisible: false, rootVisible: false,
columns: [{ columns: [
header: _('Filename'), {
width: 295, header: _('Filename'),
dataIndex: 'filename' width: 295,
},{ dataIndex: 'filename',
header: _('Size'), },
width: 60, {
dataIndex: 'size', header: _('Size'),
tpl: new Ext.XTemplate('{size:this.fsize}', { width: 60,
fsize: function(v) { dataIndex: 'size',
return fsize(v); tpl: new Ext.XTemplate('{size:this.fsize}', {
} fsize: function(v) {
}) return fsize(v);
},{ },
header: _('Download'), }),
width: 65, },
dataIndex: 'download', {
tpl: new Ext.XTemplate('{download:this.format}', { header: _('Download'),
format: function(v) { width: 65,
return '<div rel="chkbox" class="x-grid3-check-col'+(v?'-on':'')+'"> </div>'; dataIndex: 'download',
} tpl: new Ext.XTemplate('{download:this.format}', {
}) format: function(v) {
}], return (
'<div rel="chkbox" class="x-grid3-check-col' +
(v ? '-on' : '') +
'"> </div>'
);
},
}),
},
],
initComponent: function() { initComponent: function() {
Deluge.add.FilesTab.superclass.initComponent.call(this); Deluge.add.FilesTab.superclass.initComponent.call(this);
@ -88,5 +95,5 @@ Deluge.add.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
if (el.getAttribute('rel') == 'chkbox') { if (el.getAttribute('rel') == 'chkbox') {
this.setDownload(node, !node.attributes.download); this.setDownload(node, !node.attributes.download);
} }
} },
}); });

View File

@ -10,7 +10,6 @@
Ext.ns('Deluge.add'); Ext.ns('Deluge.add');
Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, { Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
torrents: {}, torrents: {},
// layout options // layout options
@ -30,17 +29,24 @@ Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
addTorrent: function(torrent) { addTorrent: function(torrent) {
this.torrents[torrent['info_hash']] = torrent; this.torrents[torrent['info_hash']] = torrent;
var fileIndexes = {}; var fileIndexes = {};
this.walkFileTree(torrent['files_tree'], function(filename, type, entry, parent) { this.walkFileTree(
if (type != 'file') return; torrent['files_tree'],
fileIndexes[entry.index] = entry.download; function(filename, type, entry, parent) {
}, this); if (type != 'file') return;
fileIndexes[entry.index] = entry.download;
},
this
);
var priorities = []; var priorities = [];
Ext.each(Ext.keys(fileIndexes), function(index) { Ext.each(Ext.keys(fileIndexes), function(index) {
priorities[index] = fileIndexes[index]; priorities[index] = fileIndexes[index];
}); });
var oldId = this.form.optionsManager.changeId(torrent['info_hash'], true); var oldId = this.form.optionsManager.changeId(
torrent['info_hash'],
true
);
this.form.optionsManager.setDefault('file_priorities', priorities); this.form.optionsManager.setDefault('file_priorities', priorities);
this.form.optionsManager.changeId(oldId, true); this.form.optionsManager.changeId(oldId, true);
}, },
@ -59,7 +65,7 @@ Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
var options = this.form.optionsManager.get(); var options = this.form.optionsManager.get();
this.form.optionsManager.changeId(oldId, true); this.form.optionsManager.changeId(oldId, true);
Ext.each(options['file_priorities'], function(priority, index) { Ext.each(options['file_priorities'], function(priority, index) {
options['file_priorities'][index] = (priority) ? 1 : 0; options['file_priorities'][index] = priority ? 1 : 0;
}); });
return options; return options;
}, },
@ -77,17 +83,22 @@ Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
this.form.setDisabled(false); this.form.setDisabled(false);
if (this.torrents[torrentId]['files_tree']) { if (this.torrents[torrentId]['files_tree']) {
this.walkFileTree(this.torrents[torrentId]['files_tree'], function(filename, type, entry, parentNode) { this.walkFileTree(
var node = new Ext.tree.TreeNode({ this.torrents[torrentId]['files_tree'],
download: (entry.index) ? priorities[entry.index] : true, function(filename, type, entry, parentNode) {
filename: filename, var node = new Ext.tree.TreeNode({
fileindex: entry.index, download: entry.index ? priorities[entry.index] : true,
leaf: type != 'dir', filename: filename,
size: entry.length fileindex: entry.index,
}); leaf: type != 'dir',
parentNode.appendChild(node); size: entry.length,
if (type == 'dir') return node; });
}, this, root); parentNode.appendChild(node);
if (type == 'dir') return node;
},
this,
root
);
root.firstChild.expand(); root.firstChild.expand();
this.files.setDisabled(false); this.files.setDisabled(false);
this.files.show(); this.files.show();
@ -96,7 +107,6 @@ Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
this.form.show(); this.form.show();
this.files.setDisabled(true); this.files.setDisabled(true);
} }
}, },
walkFileTree: function(files, callback, scope, parentNode) { walkFileTree: function(files, callback, scope, parentNode) {
@ -105,7 +115,12 @@ Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
var type = entry.type; var type = entry.type;
if (scope) { if (scope) {
var ret = callback.apply(scope, [filename, type, entry, parentNode]); var ret = callback.apply(scope, [
filename,
type,
entry,
parentNode,
]);
} else { } else {
var ret = callback(filename, type, entry, parentNode); var ret = callback(filename, type, entry, parentNode);
} }
@ -115,12 +130,17 @@ Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
}, },
onFilesChecked: function(nodes, newValue, oldValue) { onFilesChecked: function(nodes, newValue, oldValue) {
Ext.each(nodes, function(node) { Ext.each(
if (node.attributes.fileindex < 0) return; nodes,
var priorities = this.form.optionsManager.get('file_priorities'); function(node) {
priorities[node.attributes.fileindex] = newValue; if (node.attributes.fileindex < 0) return;
this.form.optionsManager.update('file_priorities', priorities); var priorities = this.form.optionsManager.get(
}, this); 'file_priorities'
);
} priorities[node.attributes.fileindex] = newValue;
this.form.optionsManager.update('file_priorities', priorities);
},
this
);
},
}); });

View File

@ -14,7 +14,6 @@ Ext.ns('Deluge.add');
* @extends Ext.form.FormPanel * @extends Ext.form.FormPanel
*/ */
Deluge.add.OptionsTab = Ext.extend(Ext.form.FormPanel, { Deluge.add.OptionsTab = Ext.extend(Ext.form.FormPanel, {
title: _('Options'), title: _('Options'),
height: 170, height: 170,
border: false, border: false,
@ -35,14 +34,17 @@ Deluge.add.OptionsTab = Ext.extend(Ext.form.FormPanel, {
defaultType: 'textfield', defaultType: 'textfield',
labelWidth: 1, labelWidth: 1,
fieldLabel: '', fieldLabel: '',
style: 'padding: 5px 0; margin-bottom: 0;' style: 'padding: 5px 0; margin-bottom: 0;',
}); });
this.optionsManager.bind('download_location', fieldset.add({ this.optionsManager.bind(
fieldLabel: '', 'download_location',
name: 'download_location', fieldset.add({
anchor:'95%', fieldLabel: '',
labelSeparator: '' name: 'download_location',
})); anchor: '95%',
labelSeparator: '',
})
);
var fieldset = this.add({ var fieldset = this.add({
xtype: 'fieldset', xtype: 'fieldset',
title: _('Move Completed Folder'), title: _('Move Completed Folder'),
@ -51,20 +53,20 @@ Deluge.add.OptionsTab = Ext.extend(Ext.form.FormPanel, {
defaultType: 'togglefield', defaultType: 'togglefield',
labelWidth: 1, labelWidth: 1,
fieldLabel: '', fieldLabel: '',
style: 'padding: 5px 0; margin-bottom: 0;' style: 'padding: 5px 0; margin-bottom: 0;',
}); });
var field = fieldset.add({ var field = fieldset.add({
fieldLabel: '', fieldLabel: '',
name: 'move_completed_path', name: 'move_completed_path',
anchor:'98%' anchor: '98%',
}); });
this.optionsManager.bind('move_completed', field.toggle) this.optionsManager.bind('move_completed', field.toggle);
this.optionsManager.bind('move_completed_path', field.input) this.optionsManager.bind('move_completed_path', field.input);
var panel = this.add({ var panel = this.add({
border: false, border: false,
layout: 'column', layout: 'column',
defaultType: 'fieldset' defaultType: 'fieldset',
}); });
fieldset = panel.add({ fieldset = panel.add({
@ -75,95 +77,131 @@ Deluge.add.OptionsTab = Ext.extend(Ext.form.FormPanel, {
labelWidth: 105, labelWidth: 105,
width: 200, width: 200,
defaultType: 'spinnerfield', defaultType: 'spinnerfield',
style: 'padding-right: 10px;' style: 'padding-right: 10px;',
}); });
this.optionsManager.bind('max_download_speed', fieldset.add({ this.optionsManager.bind(
fieldLabel: _('Max Down Speed'), 'max_download_speed',
name: 'max_download_speed', fieldset.add({
width: 60 fieldLabel: _('Max Down Speed'),
})); name: 'max_download_speed',
this.optionsManager.bind('max_upload_speed', fieldset.add({ width: 60,
fieldLabel: _('Max Up Speed'), })
name: 'max_upload_speed', );
width: 60 this.optionsManager.bind(
})); 'max_upload_speed',
this.optionsManager.bind('max_connections', fieldset.add({ fieldset.add({
fieldLabel: _('Max Connections'), fieldLabel: _('Max Up Speed'),
name: 'max_connections', name: 'max_upload_speed',
width: 60 width: 60,
})); })
this.optionsManager.bind('max_upload_slots', fieldset.add({ );
fieldLabel: _('Max Upload Slots'), this.optionsManager.bind(
name: 'max_upload_slots', 'max_connections',
width: 60 fieldset.add({
})); fieldLabel: _('Max Connections'),
name: 'max_connections',
width: 60,
})
);
this.optionsManager.bind(
'max_upload_slots',
fieldset.add({
fieldLabel: _('Max Upload Slots'),
name: 'max_upload_slots',
width: 60,
})
);
fieldset = panel.add({ fieldset = panel.add({
title: _('General'), title: _('General'),
border: false, border: false,
autoHeight: true, autoHeight: true,
defaultType: 'checkbox' defaultType: 'checkbox',
}); });
this.optionsManager.bind('add_paused', fieldset.add({ this.optionsManager.bind(
name: 'add_paused', 'add_paused',
boxLabel: _('Add In Paused State'), fieldset.add({
fieldLabel: '', name: 'add_paused',
labelSeparator: '' boxLabel: _('Add In Paused State'),
})); fieldLabel: '',
this.optionsManager.bind('prioritize_first_last_pieces', fieldset.add({ labelSeparator: '',
name: 'prioritize_first_last_pieces', })
boxLabel: _('Prioritize First/Last Pieces'), );
fieldLabel: '', this.optionsManager.bind(
labelSeparator: '' 'prioritize_first_last_pieces',
})); fieldset.add({
this.optionsManager.bind('sequential_download', fieldset.add({ name: 'prioritize_first_last_pieces',
name: 'sequential_download', boxLabel: _('Prioritize First/Last Pieces'),
boxLabel: _('Sequential Download'), fieldLabel: '',
fieldLabel: '', labelSeparator: '',
labelSeparator: '' })
})); );
this.optionsManager.bind('seed_mode', fieldset.add({ this.optionsManager.bind(
name: 'seed_mode', 'sequential_download',
boxLabel: _('Skip File Hash Check'), fieldset.add({
fieldLabel: '', name: 'sequential_download',
labelSeparator: '' boxLabel: _('Sequential Download'),
})); fieldLabel: '',
this.optionsManager.bind('pre_allocate_storage', fieldset.add({ labelSeparator: '',
name: 'pre_allocate_storage', })
boxLabel: _('Preallocate Disk Space'), );
fieldLabel: '', this.optionsManager.bind(
labelSeparator: '' 'seed_mode',
})); fieldset.add({
name: 'seed_mode',
boxLabel: _('Skip File Hash Check'),
fieldLabel: '',
labelSeparator: '',
})
);
this.optionsManager.bind(
'pre_allocate_storage',
fieldset.add({
name: 'pre_allocate_storage',
boxLabel: _('Preallocate Disk Space'),
fieldLabel: '',
labelSeparator: '',
})
);
}, },
getDefaults: function() { getDefaults: function() {
var keys = ['add_paused','pre_allocate_storage','download_location', var keys = [
'max_connections_per_torrent','max_download_speed_per_torrent', 'add_paused',
'move_completed', 'move_completed_path', 'pre_allocate_storage',
'max_upload_slots_per_torrent','max_upload_speed_per_torrent', 'download_location',
'prioritize_first_last_pieces', 'sequential_download']; 'max_connections_per_torrent',
'max_download_speed_per_torrent',
'move_completed',
'move_completed_path',
'max_upload_slots_per_torrent',
'max_upload_speed_per_torrent',
'prioritize_first_last_pieces',
'sequential_download',
];
deluge.client.core.get_config_values(keys, { deluge.client.core.get_config_values(keys, {
success: function(config) { success: function(config) {
var options = { var options = {
'file_priorities': [], file_priorities: [],
'add_paused': config.add_paused, add_paused: config.add_paused,
'sequential_download': config.sequential_download, sequential_download: config.sequential_download,
'pre_allocate_storage': config.pre_allocate_storage, pre_allocate_storage: config.pre_allocate_storage,
'download_location': config.download_location, download_location: config.download_location,
'move_completed': config.move_completed, move_completed: config.move_completed,
'move_completed_path': config.move_completed_path, move_completed_path: config.move_completed_path,
'max_connections': config.max_connections_per_torrent, max_connections: config.max_connections_per_torrent,
'max_download_speed': config.max_download_speed_per_torrent, max_download_speed: config.max_download_speed_per_torrent,
'max_upload_slots': config.max_upload_slots_per_torrent, max_upload_slots: config.max_upload_slots_per_torrent,
'max_upload_speed': config.max_upload_speed_per_torrent, max_upload_speed: config.max_upload_speed_per_torrent,
'prioritize_first_last_pieces': config.prioritize_first_last_pieces, prioritize_first_last_pieces:
'seed_mode': false config.prioritize_first_last_pieces,
} seed_mode: false,
};
this.optionsManager.options = options; this.optionsManager.options = options;
this.optionsManager.resetAll(); this.optionsManager.resetAll();
}, },
scope: this scope: this,
}); });
} },
}); });

View File

@ -10,7 +10,6 @@
Ext.namespace('Deluge.add'); Ext.namespace('Deluge.add');
Deluge.add.UrlWindow = Ext.extend(Deluge.add.Window, { Deluge.add.UrlWindow = Ext.extend(Deluge.add.Window, {
title: _('Add from Url'), title: _('Add from Url'),
modal: true, modal: true,
plain: true, plain: true,
@ -31,14 +30,14 @@ Deluge.add.UrlWindow = Ext.extend(Deluge.add.Window, {
xtype: 'form', xtype: 'form',
defaultType: 'textfield', defaultType: 'textfield',
baseCls: 'x-plain', baseCls: 'x-plain',
labelWidth: 55 labelWidth: 55,
}); });
this.urlField = form.add({ this.urlField = form.add({
fieldLabel: _('Url'), fieldLabel: _('Url'),
id: 'url', id: 'url',
name: 'url', name: 'url',
width: '97%' width: '97%',
}); });
this.urlField.on('specialkey', this.onAdd, this); this.urlField.on('specialkey', this.onAdd, this);
@ -46,13 +45,17 @@ Deluge.add.UrlWindow = Ext.extend(Deluge.add.Window, {
fieldLabel: _('Cookies'), fieldLabel: _('Cookies'),
id: 'cookies', id: 'cookies',
name: 'cookies', name: 'cookies',
width: '97%' width: '97%',
}); });
this.cookieField.on('specialkey', this.onAdd, this); this.cookieField.on('specialkey', this.onAdd, this);
}, },
onAddClick: function(field, e) { onAddClick: function(field, e) {
if ((field.id == 'url' || field.id == 'cookies') && e.getKey() != e.ENTER) return; if (
(field.id == 'url' || field.id == 'cookies') &&
e.getKey() != e.ENTER
)
return;
var field = this.urlField; var field = this.urlField;
var url = field.getValue(); var url = field.getValue();
@ -64,13 +67,13 @@ Deluge.add.UrlWindow = Ext.extend(Deluge.add.Window, {
success: this.onGotInfo, success: this.onGotInfo,
scope: this, scope: this,
filename: url, filename: url,
torrentId: torrentId torrentId: torrentId,
}); });
} else { } else {
deluge.client.web.download_torrent_from_url(url, cookies, { deluge.client.web.download_torrent_from_url(url, cookies, {
success: this.onDownload, success: this.onDownload,
scope: this, scope: this,
torrentId: torrentId torrentId: torrentId,
}); });
} }
@ -84,12 +87,12 @@ Deluge.add.UrlWindow = Ext.extend(Deluge.add.Window, {
success: this.onGotInfo, success: this.onGotInfo,
scope: this, scope: this,
filename: filename, filename: filename,
torrentId: req.options.torrentId torrentId: req.options.torrentId,
}); });
}, },
onGotInfo: function(info, obj, response, request) { onGotInfo: function(info, obj, response, request) {
info['filename'] = request.options.filename; info['filename'] = request.options.filename;
this.fireEvent('add', request.options.torrentId, info); this.fireEvent('add', request.options.torrentId, info);
} },
}); });

View File

@ -17,10 +17,7 @@ Ext.ns('Deluge.add');
Deluge.add.Window = Ext.extend(Ext.Window, { Deluge.add.Window = Ext.extend(Ext.Window, {
initComponent: function() { initComponent: function() {
Deluge.add.Window.superclass.initComponent.call(this); Deluge.add.Window.superclass.initComponent.call(this);
this.addEvents( this.addEvents('beforeadd', 'add');
'beforeadd',
'add'
);
}, },
/** /**
@ -28,5 +25,5 @@ Deluge.add.Window = Ext.extend(Ext.Window, {
*/ */
createTorrentId: function() { createTorrentId: function() {
return new Date().getTime(); return new Date().getTime();
} },
}); });

View File

@ -23,25 +23,31 @@ Ext.namespace('Deluge.data');
Deluge.data.Peer = Ext.data.Record.create([ Deluge.data.Peer = Ext.data.Record.create([
{ {
name: 'country', name: 'country',
type: 'string' type: 'string',
}, { },
{
name: 'ip', name: 'ip',
type: 'string', type: 'string',
sortType: Deluge.data.SortTypes.asIPAddress sortType: Deluge.data.SortTypes.asIPAddress,
}, { },
{
name: 'client', name: 'client',
type: 'string' type: 'string',
}, { },
{
name: 'progress', name: 'progress',
type: 'float' type: 'float',
}, { },
{
name: 'down_speed', name: 'down_speed',
type: 'int' type: 'int',
}, { },
{
name: 'up_speed', name: 'up_speed',
type: 'int' type: 'int',
}, { },
{
name: 'seed', name: 'seed',
type: 'int' type: 'int',
} },
]); ]);

View File

@ -20,15 +20,17 @@ Ext.namespace('Deluge.data');
*/ */
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(
return ((((((+d[1])*256)+(+d[2]))*256)+(+d[3]))*256)+(+d[4]); /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\:(\d+)/
);
return ((+d[1] * 256 + +d[2]) * 256 + +d[3]) * 256 + +d[4];
}, },
asQueuePosition: function(value) { asQueuePosition: function(value) {
return (value > -1) ? value : Number.MAX_VALUE; return value > -1 ? value : Number.MAX_VALUE;
}, },
asName: function(value) { asName: function(value) {
return String(value).toLowerCase(); return String(value).toLowerCase();
} },
} };

View File

@ -20,78 +20,102 @@ Ext.namespace('Deluge.data');
* @constructor * @constructor
* @param {Object} data The torrents data * @param {Object} data The torrents data
*/ */
Deluge.data.Torrent = Ext.data.Record.create([{ Deluge.data.Torrent = Ext.data.Record.create([
{
name: 'queue', name: 'queue',
type: 'int' type: 'int',
}, { },
{
name: 'name', name: 'name',
type: 'string', type: 'string',
sortType: Deluge.data.SortTypes.asName sortType: Deluge.data.SortTypes.asName,
}, { },
{
name: 'total_wanted', name: 'total_wanted',
type: 'int' type: 'int',
}, { },
{
name: 'state', name: 'state',
type: 'string' type: 'string',
}, { },
{
name: 'progress', name: 'progress',
type: 'int' type: 'int',
}, { },
{
name: 'num_seeds', name: 'num_seeds',
type: 'int' type: 'int',
}, { },
{
name: 'total_seeds', name: 'total_seeds',
type: 'int' type: 'int',
}, { },
{
name: 'num_peers', name: 'num_peers',
type: 'int' type: 'int',
}, { },
{
name: 'total_peers', name: 'total_peers',
type: 'int' type: 'int',
}, { },
{
name: 'download_payload_rate', name: 'download_payload_rate',
type: 'int' type: 'int',
}, { },
{
name: 'upload_payload_rate', name: 'upload_payload_rate',
type: 'int' type: 'int',
}, { },
{
name: 'eta', name: 'eta',
type: 'int' type: 'int',
}, { },
{
name: 'ratio', name: 'ratio',
type: 'float' type: 'float',
}, { },
{
name: 'distributed_copies', name: 'distributed_copies',
type: 'float' type: 'float',
}, { },
{
name: 'time_added', name: 'time_added',
type: 'int' type: 'int',
}, { },
{
name: 'tracker_host', name: 'tracker_host',
type: 'string' type: 'string',
}, { },
{
name: 'save_path', name: 'save_path',
type: 'string' type: 'string',
}, { },
{
name: 'total_done', name: 'total_done',
type: 'int' type: 'int',
}, { },
{
name: 'total_uploaded', name: 'total_uploaded',
type: 'int' type: 'int',
}, { },
{
name: 'total_remaining', name: 'total_remaining',
type: 'int' type: 'int',
}, { },
{
name: 'max_download_speed', name: 'max_download_speed',
type: 'int' type: 'int',
}, { },
{
name: 'max_upload_speed', name: 'max_upload_speed',
type: 'int' type: 'int',
}, { },
{
name: 'seeds_peers_ratio', name: 'seeds_peers_ratio',
type: 'float' type: 'float',
}, { },
{
name: 'time_since_transfer', name: 'time_since_transfer',
type: 'int' type: 'int',
} },
]); ]);

View File

@ -13,7 +13,6 @@ Ext.namespace('Deluge.details');
* @class Deluge.details.DetailsPanel * @class Deluge.details.DetailsPanel
*/ */
Deluge.details.DetailsPanel = Ext.extend(Ext.TabPanel, { Deluge.details.DetailsPanel = Ext.extend(Ext.TabPanel, {
id: 'torrentDetails', id: 'torrentDetails',
activeTab: 0, activeTab: 0,
@ -35,7 +34,6 @@ 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) {
@ -55,14 +53,22 @@ Deluge.details.DetailsPanel = Ext.extend(Ext.TabPanel, {
// We need to add the events in onRender since Deluge.Torrents has not been created yet. // We need to add the events in onRender since Deluge.Torrents has not been created yet.
onRender: function(ct, position) { onRender: function(ct, position) {
Deluge.details.DetailsPanel.superclass.onRender.call(this, ct, position); Deluge.details.DetailsPanel.superclass.onRender.call(
this,
ct,
position
);
deluge.events.on('disconnect', this.clear, this); deluge.events.on('disconnect', this.clear, this);
deluge.torrents.on('rowclick', this.onTorrentsClick, this); deluge.torrents.on('rowclick', this.onTorrentsClick, this);
this.on('tabchange', this.onTabChange, this); this.on('tabchange', this.onTabChange, this);
deluge.torrents.getSelectionModel().on('selectionchange', function(selModel) { deluge.torrents.getSelectionModel().on(
if (!selModel.hasSelection()) this.clear(); 'selectionchange',
}, this); function(selModel) {
if (!selModel.hasSelection()) this.clear();
},
this
);
}, },
onTabChange: function(panel, tab) { onTabChange: function(panel, tab) {
@ -71,5 +77,5 @@ Deluge.details.DetailsPanel = Ext.extend(Ext.TabPanel, {
onTorrentsClick: function(grid, rowIndex, e) { onTorrentsClick: function(grid, rowIndex, e) {
this.update(); this.update();
} },
}); });

View File

@ -16,7 +16,6 @@ Deluge.details.DetailsTab = Ext.extend(Ext.Panel, {
autoScroll: true, autoScroll: true,
queuedItems: {}, queuedItems: {},
oldData: {}, oldData: {},
initComponent: function() { initComponent: function() {
@ -35,7 +34,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); Deluge.details.DetailsTab.superclass.onRender.call(this, ct, position);
this.body.setStyle('padding', '10px'); this.body.setStyle('padding', '10px');
this.dl = Ext.DomHelper.append(this.body, {tag: 'dl'}, true); this.dl = Ext.DomHelper.append(this.body, { tag: 'dl' }, true);
for (var id in this.queuedItems) { for (var id in this.queuedItems) {
this.doAddItem(id, this.queuedItems[id]); this.doAddItem(id, this.queuedItems[id]);
@ -52,8 +51,12 @@ Deluge.details.DetailsTab = Ext.extend(Ext.Panel, {
// private // private
doAddItem: function(id, label) { doAddItem: function(id, label) {
Ext.DomHelper.append(this.dl, {tag: 'dt', cls: id, html: label}); Ext.DomHelper.append(this.dl, { tag: 'dt', cls: id, html: label });
this.fields[id] = Ext.DomHelper.append(this.dl, {tag: 'dd', cls: id, html: ''}, true); this.fields[id] = Ext.DomHelper.append(
this.dl,
{ tag: 'dd', cls: id, html: '' },
true
);
}, },
clear: function() { clear: function() {
@ -61,14 +64,14 @@ Deluge.details.DetailsTab = Ext.extend(Ext.Panel, {
for (var k in this.fields) { for (var k in this.fields) {
this.fields[k].dom.innerHTML = ''; this.fields[k].dom.innerHTML = '';
} }
this.oldData = {} this.oldData = {};
}, },
update: function(torrentId) { update: function(torrentId) {
deluge.client.web.get_torrent_status(torrentId, Deluge.Keys.Details, { deluge.client.web.get_torrent_status(torrentId, Deluge.Keys.Details, {
success: this.onRequestComplete, success: this.onRequestComplete,
scope: this, scope: this,
torrentId: torrentId torrentId: torrentId,
}); });
}, },
@ -82,7 +85,7 @@ Deluge.details.DetailsTab = Ext.extend(Ext.Panel, {
status: torrent.message, status: torrent.message,
tracker: torrent.tracker_host, tracker: torrent.tracker_host,
comment: torrent.comment, comment: torrent.comment,
creator: torrent.creator creator: torrent.creator,
}; };
for (var field in this.fields) { for (var field in this.fields) {
@ -91,5 +94,5 @@ Deluge.details.DetailsTab = Ext.extend(Ext.Panel, {
this.fields[field].dom.innerHTML = Ext.escapeHTML(data[field]); this.fields[field].dom.innerHTML = Ext.escapeHTML(data[field]);
} }
this.oldData = data; this.oldData = data;
} },
}); });

View File

@ -9,54 +9,68 @@
*/ */
Deluge.details.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, { Deluge.details.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
title: _('Files'), title: _('Files'),
rootVisible: false, rootVisible: false,
columns: [{ columns: [
header: _('Filename'), {
width: 330, header: _('Filename'),
dataIndex: 'filename' width: 330,
}, { dataIndex: 'filename',
header: _('Size'), },
width: 150, {
dataIndex: 'size', header: _('Size'),
tpl: new Ext.XTemplate('{size:this.fsize}', { width: 150,
fsize: function(v) { return fsize(v); } dataIndex: 'size',
}) tpl: new Ext.XTemplate('{size:this.fsize}', {
}, { fsize: function(v) {
xtype: 'tgrendercolumn', return fsize(v);
header: _('Progress'), },
width: 150, }),
dataIndex: 'progress', },
renderer: function(v) { {
var progress = v * 100; xtype: 'tgrendercolumn',
return Deluge.progressBar(progress, this.col.width, progress.toFixed(2) + '%', 0); header: _('Progress'),
} width: 150,
}, { dataIndex: 'progress',
header: _('Priority'), renderer: function(v) {
width: 150, var progress = v * 100;
dataIndex: 'priority', return Deluge.progressBar(
tpl: new Ext.XTemplate('<tpl if="!isNaN(priority)">' + progress,
'<div class="{priority:this.getClass}">' + this.col.width,
'{priority:this.getName}' + progress.toFixed(2) + '%',
'</div></tpl>', { 0
getClass: function(v) { );
return FILE_PRIORITY_CSS[v];
}, },
},
{
header: _('Priority'),
width: 150,
dataIndex: 'priority',
tpl: new Ext.XTemplate(
'<tpl if="!isNaN(priority)">' +
'<div class="{priority:this.getClass}">' +
'{priority:this.getName}' +
'</div></tpl>',
{
getClass: function(v) {
return FILE_PRIORITY_CSS[v];
},
getName: function(v) { getName: function(v) {
return _(FILE_PRIORITY[v]); return _(FILE_PRIORITY[v]);
} },
}) }
}], ),
},
],
selModel: new Ext.tree.MultiSelectionModel(), selModel: new Ext.tree.MultiSelectionModel(),
initComponent: function() { initComponent: function() {
Deluge.details.FilesTab.superclass.initComponent.call(this); Deluge.details.FilesTab.superclass.initComponent.call(this);
this.setRootNode(new Ext.tree.TreeNode({text: _('Files')})); this.setRootNode(new Ext.tree.TreeNode({ text: _('Files') }));
}, },
clear: function() { clear: function() {
@ -75,25 +89,32 @@ Deluge.details.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
for (var file in files.contents) { for (var file in files.contents) {
var item = files.contents[file]; var item = files.contents[file];
if (item.type == 'dir') { if (item.type == 'dir') {
walk(item, parentNode.appendChild(new Ext.tree.TreeNode({ walk(
text: file, item,
filename: file, parentNode.appendChild(
size: item.size, new Ext.tree.TreeNode({
progress: item.progress, text: file,
priority: item.priority filename: file,
}))); size: item.size,
progress: item.progress,
priority: item.priority,
})
)
);
} else { } else {
parentNode.appendChild(new Ext.tree.TreeNode({ parentNode.appendChild(
text: file, new Ext.tree.TreeNode({
filename: file, text: file,
fileIndex: item.index, filename: file,
size: item.size, fileIndex: item.index,
progress: item.progress, size: item.size,
priority: item.priority, progress: item.progress,
leaf: true, priority: item.priority,
iconCls: 'x-deluge-file', leaf: true,
uiProvider: Ext.ux.tree.TreeGridNodeUI iconCls: 'x-deluge-file',
})); uiProvider: Ext.ux.tree.TreeGridNodeUI,
})
);
} }
} }
} }
@ -111,7 +132,7 @@ Deluge.details.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
deluge.client.web.get_torrent_files(torrentId, { deluge.client.web.get_torrent_files(torrentId, {
success: this.onRequestComplete, success: this.onRequestComplete,
scope: this, scope: this,
torrentId: torrentId torrentId: torrentId,
}); });
}, },
@ -120,7 +141,7 @@ Deluge.details.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
for (var file in files.contents) { for (var file in files.contents) {
var item = files.contents[file]; var item = files.contents[file];
var node = parentNode.findChild('filename', file); var node = parentNode.findChild('filename', file);
node.attributes.size = item.size; node.attributes.size = item.size;
node.attributes.progress = item.progress; node.attributes.progress = item.progress;
node.attributes.priority = item.priority; node.attributes.priority = item.priority;
node.ui.updateColumns(); node.ui.updateColumns();
@ -137,7 +158,7 @@ Deluge.details.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
deluge.menus.filePriorities.on('itemclick', this.onItemClick, this); deluge.menus.filePriorities.on('itemclick', this.onItemClick, this);
this.on('contextmenu', this.onContextMenu, this); this.on('contextmenu', this.onContextMenu, this);
this.sorter = new Ext.tree.TreeSorter(this, { this.sorter = new Ext.tree.TreeSorter(this, {
folderSort: true folderSort: true,
}); });
}, },
@ -160,7 +181,8 @@ Deluge.details.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
var indexes = {}; var indexes = {};
function walk(node) { function walk(node) {
if (Ext.isEmpty(node.attributes.fileIndex)) return; if (Ext.isEmpty(node.attributes.fileIndex)) return;
indexes[node.attributes.fileIndex] = node.attributes.priority; indexes[node.attributes.fileIndex] =
node.attributes.priority;
} }
this.getRootNode().cascade(walk); this.getRootNode().cascade(walk);
@ -169,11 +191,13 @@ Deluge.details.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
if (!node.isLeaf()) { if (!node.isLeaf()) {
function setPriorities(node) { function setPriorities(node) {
if (Ext.isEmpty(node.attributes.fileIndex)) return; if (Ext.isEmpty(node.attributes.fileIndex)) return;
indexes[node.attributes.fileIndex] = baseItem.filePriority; indexes[node.attributes.fileIndex] =
baseItem.filePriority;
} }
node.cascade(setPriorities); node.cascade(setPriorities);
} else if (!Ext.isEmpty(node.attributes.fileIndex)) { } else if (!Ext.isEmpty(node.attributes.fileIndex)) {
indexes[node.attributes.fileIndex] = baseItem.filePriority; indexes[node.attributes.fileIndex] =
baseItem.filePriority;
return; return;
} }
}); });
@ -183,14 +207,18 @@ Deluge.details.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
priorities[index] = indexes[index]; priorities[index] = indexes[index];
} }
deluge.client.core.set_torrent_options([this.torrentId], {'file_priorities': priorities}, { deluge.client.core.set_torrent_options(
success: function() { [this.torrentId],
Ext.each(nodes, function(node) { { file_priorities: priorities },
node.setColumnValue(3, baseItem.filePriority); {
}); success: function() {
}, Ext.each(nodes, function(node) {
scope: this node.setColumnValue(3, baseItem.filePriority);
}); });
},
scope: this,
}
);
break; break;
} }
}, },
@ -201,5 +229,5 @@ Deluge.details.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
} else { } else {
this.updateFileTree(files); this.updateFileTree(files);
} }
} },
}); });

View File

@ -8,46 +8,47 @@
* See LICENSE for more details. * See LICENSE for more details.
*/ */
Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, { Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
constructor: function(config) { constructor: function(config) {
config = Ext.apply({ config = Ext.apply(
autoScroll: true, {
bodyStyle: 'padding: 5px;', autoScroll: true,
border: false, bodyStyle: 'padding: 5px;',
cls: 'x-deluge-options', border: false,
defaults: { cls: 'x-deluge-options',
autoHeight: true, defaults: {
labelWidth: 1, autoHeight: true,
defaultType: 'checkbox' labelWidth: 1,
defaultType: 'checkbox',
},
deferredRender: false,
layout: 'column',
title: _('Options'),
}, },
deferredRender: false, config
layout: 'column', );
title: _('Options')
}, config);
Deluge.details.OptionsTab.superclass.constructor.call(this, config); Deluge.details.OptionsTab.superclass.constructor.call(this, config);
}, },
initComponent: function() { initComponent: function() {
Deluge.details.OptionsTab.superclass.initComponent.call(this); Deluge.details.OptionsTab.superclass.initComponent.call(this);
this.fieldsets = {}, this.fields = {}; (this.fieldsets = {}), (this.fields = {});
this.optionsManager = new Deluge.MultiOptionsManager({ this.optionsManager = new Deluge.MultiOptionsManager({
options: { options: {
'max_download_speed': -1, max_download_speed: -1,
'max_upload_speed': -1, max_upload_speed: -1,
'max_connections': -1, max_connections: -1,
'max_upload_slots': -1, max_upload_slots: -1,
'auto_managed': false, auto_managed: false,
'stop_at_ratio': false, stop_at_ratio: false,
'stop_ratio': 2.0, stop_ratio: 2.0,
'remove_at_ratio': false, remove_at_ratio: false,
'move_completed': false, move_completed: false,
'move_completed_path': '', move_completed_path: '',
'private': false, private: false,
'prioritize_first_last': false prioritize_first_last: false,
} },
}); });
/* /*
@ -59,12 +60,12 @@ Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
bodyStyle: 'padding: 5px', bodyStyle: 'padding: 5px',
layout: 'table', layout: 'table',
layoutConfig: {columns: 3}, layoutConfig: { columns: 3 },
labelWidth: 150, labelWidth: 150,
style: 'margin-left: 10px; margin-right: 5px; padding: 5px', style: 'margin-left: 10px; margin-right: 5px; padding: 5px',
title: _('Bandwidth'), title: _('Bandwidth'),
width: 250 width: 250,
}); });
/* /*
@ -74,7 +75,7 @@ Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
xtype: 'label', xtype: 'label',
text: _('Max Download Speed:'), text: _('Max Download Speed:'),
forId: 'max_download_speed', forId: 'max_download_speed',
cls: 'x-deluge-options-label' cls: 'x-deluge-options-label',
}); });
this.fields.max_download_speed = this.fieldsets.bandwidth.add({ this.fields.max_download_speed = this.fieldsets.bandwidth.add({
id: 'max_download_speed', id: 'max_download_speed',
@ -84,13 +85,13 @@ Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
xtype: 'number', xtype: 'number',
decimalPrecision: 1, decimalPrecision: 1,
minValue: -1, minValue: -1,
maxValue: 99999 maxValue: 99999,
} },
}); });
this.fieldsets.bandwidth.add({ this.fieldsets.bandwidth.add({
xtype: 'label', xtype: 'label',
text: _('KiB/s'), text: _('KiB/s'),
style: 'margin-left: 10px' style: 'margin-left: 10px',
}); });
/* /*
@ -100,7 +101,7 @@ Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
xtype: 'label', xtype: 'label',
text: _('Max Upload Speed:'), text: _('Max Upload Speed:'),
forId: 'max_upload_speed', forId: 'max_upload_speed',
cls: 'x-deluge-options-label' cls: 'x-deluge-options-label',
}); });
this.fields.max_upload_speed = this.fieldsets.bandwidth.add({ this.fields.max_upload_speed = this.fieldsets.bandwidth.add({
id: 'max_upload_speed', id: 'max_upload_speed',
@ -111,13 +112,13 @@ Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
xtype: 'number', xtype: 'number',
decimalPrecision: 1, decimalPrecision: 1,
minValue: -1, minValue: -1,
maxValue: 99999 maxValue: 99999,
} },
}); });
this.fieldsets.bandwidth.add({ this.fieldsets.bandwidth.add({
xtype: 'label', xtype: 'label',
text: _('KiB/s'), text: _('KiB/s'),
style: 'margin-left: 10px' style: 'margin-left: 10px',
}); });
/* /*
@ -127,7 +128,7 @@ Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
xtype: 'label', xtype: 'label',
text: _('Max Connections:'), text: _('Max Connections:'),
forId: 'max_connections', forId: 'max_connections',
cls: 'x-deluge-options-label' cls: 'x-deluge-options-label',
}); });
this.fields.max_connections = this.fieldsets.bandwidth.add({ this.fields.max_connections = this.fieldsets.bandwidth.add({
id: 'max_connections', id: 'max_connections',
@ -138,9 +139,9 @@ Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
xtype: 'number', xtype: 'number',
decimalPrecision: 0, decimalPrecision: 0,
minValue: -1, minValue: -1,
maxValue: 99999 maxValue: 99999,
}, },
colspan: 2 colspan: 2,
}); });
/* /*
@ -150,7 +151,7 @@ Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
xtype: 'label', xtype: 'label',
text: _('Max Upload Slots:'), text: _('Max Upload Slots:'),
forId: 'max_upload_slots', forId: 'max_upload_slots',
cls: 'x-deluge-options-label' cls: 'x-deluge-options-label',
}); });
this.fields.max_upload_slots = this.fieldsets.bandwidth.add({ this.fields.max_upload_slots = this.fieldsets.bandwidth.add({
id: 'max_upload_slots', id: 'max_upload_slots',
@ -161,9 +162,9 @@ Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
xtype: 'number', xtype: 'number',
decimalPrecision: 0, decimalPrecision: 0,
minValue: -1, minValue: -1,
maxValue: 99999 maxValue: 99999,
}, },
colspan: 2 colspan: 2,
}); });
/* /*
@ -176,13 +177,13 @@ Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
width: 210, width: 210,
layout: 'table', layout: 'table',
layoutConfig: {columns: 2}, layoutConfig: { columns: 2 },
labelWidth: 0, labelWidth: 0,
defaults: { defaults: {
fieldLabel: '', fieldLabel: '',
labelSeparator: '' labelSeparator: '',
} },
}); });
this.fields.auto_managed = this.fieldsets.queue.add({ this.fields.auto_managed = this.fieldsets.queue.add({
@ -192,7 +193,7 @@ Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
name: 'is_auto_managed', name: 'is_auto_managed',
boxLabel: _('Auto Managed'), boxLabel: _('Auto Managed'),
width: 200, width: 200,
colspan: 2 colspan: 2,
}); });
this.fields.stop_at_ratio = this.fieldsets.queue.add({ this.fields.stop_at_ratio = this.fieldsets.queue.add({
@ -202,7 +203,7 @@ Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
width: 120, width: 120,
boxLabel: _('Stop seed at ratio:'), boxLabel: _('Stop seed at ratio:'),
handler: this.onStopRatioChecked, handler: this.onStopRatioChecked,
scope: this scope: this,
}); });
this.fields.stop_ratio = this.fieldsets.queue.add({ this.fields.stop_ratio = this.fieldsets.queue.add({
@ -218,8 +219,8 @@ Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
maxValue: 99999, maxValue: 99999,
incrementValue: 0.1, incrementValue: 0.1,
alternateIncrementValue: 1, alternateIncrementValue: 1,
decimalPrecision: 1 decimalPrecision: 1,
} },
}); });
this.fields.remove_at_ratio = this.fieldsets.queue.add({ this.fields.remove_at_ratio = this.fieldsets.queue.add({
@ -230,7 +231,7 @@ Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
bodyStyle: 'padding-left: 10px', bodyStyle: 'padding-left: 10px',
boxLabel: _('Remove at ratio'), boxLabel: _('Remove at ratio'),
disabled: true, disabled: true,
colspan: 2 colspan: 2,
}); });
this.fields.move_completed = this.fieldsets.queue.add({ this.fields.move_completed = this.fieldsets.queue.add({
@ -240,7 +241,7 @@ Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
boxLabel: _('Move Completed:'), boxLabel: _('Move Completed:'),
colspan: 2, colspan: 2,
handler: this.onMoveCompletedChecked, handler: this.onMoveCompletedChecked,
scope: this scope: this,
}); });
this.fields.move_completed_path = this.fieldsets.queue.add({ this.fields.move_completed_path = this.fieldsets.queue.add({
@ -250,18 +251,17 @@ Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
colspan: 3, colspan: 3,
bodyStyle: 'margin-left: 20px', bodyStyle: 'margin-left: 20px',
width: 180, width: 180,
disabled: true disabled: true,
}); });
/* /*
* General Options * General Options
*/ */
this.rightColumn = this.add({ this.rightColumn = this.add({
border: false, border: false,
autoHeight: true, autoHeight: true,
style: 'margin-left: 5px', style: 'margin-left: 5px',
width: 210 width: 210,
}); });
this.fieldsets.general = this.rightColumn.add({ this.fieldsets.general = this.rightColumn.add({
@ -269,7 +269,7 @@ Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
autoHeight: true, autoHeight: true,
defaultType: 'checkbox', defaultType: 'checkbox',
title: _('General'), title: _('General'),
layout: 'form' layout: 'form',
}); });
this.fields['private'] = this.fieldsets.general.add({ this.fields['private'] = this.fieldsets.general.add({
@ -277,14 +277,14 @@ Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
labelSeparator: '', labelSeparator: '',
boxLabel: _('Private'), boxLabel: _('Private'),
id: 'private', id: 'private',
disabled: true disabled: true,
}); });
this.fields.prioritize_first_last = this.fieldsets.general.add({ this.fields.prioritize_first_last = this.fieldsets.general.add({
fieldLabel: '', fieldLabel: '',
labelSeparator: '', labelSeparator: '',
boxLabel: _('Prioritize First/Last'), boxLabel: _('Prioritize First/Last'),
id: 'prioritize_first_last' id: 'prioritize_first_last',
}); });
// Bind the fields so the options manager can manage them. // Bind the fields so the options manager can manage them.
@ -298,7 +298,7 @@ Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
this.buttonPanel = this.rightColumn.add({ this.buttonPanel = this.rightColumn.add({
layout: 'hbox', layout: 'hbox',
xtype: 'panel', xtype: 'panel',
border: false border: false,
}); });
/* /*
@ -313,7 +313,7 @@ Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
border: false, border: false,
width: 100, width: 100,
handler: this.onEditTrackers, handler: this.onEditTrackers,
scope: this scope: this,
}); });
/* /*
@ -327,7 +327,7 @@ Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
border: false, border: false,
width: 100, width: 100,
handler: this.onApply, handler: this.onApply,
scope: this scope: this,
}); });
}, },
@ -361,7 +361,7 @@ Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
} }
deluge.client.web.get_torrent_status(torrentId, Deluge.Keys.Options, { deluge.client.web.get_torrent_status(torrentId, Deluge.Keys.Options, {
success: this.onRequestComplete, success: this.onRequestComplete,
scope: this scope: this,
}); });
}, },
@ -371,7 +371,7 @@ Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
success: function() { success: function() {
this.optionsManager.commit(); this.optionsManager.commit();
}, },
scope: this scope: this,
}); });
}, },
@ -396,11 +396,14 @@ Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
this.fields['private'].setDisabled(true); this.fields['private'].setDisabled(true);
delete torrent['private']; delete torrent['private'];
torrent['auto_managed'] = torrent['is_auto_managed']; torrent['auto_managed'] = torrent['is_auto_managed'];
torrent['prioritize_first_last_pieces'] = torrent['prioritize_first_last']; torrent['prioritize_first_last_pieces'] =
torrent['prioritize_first_last'];
this.optionsManager.setDefault(torrent); this.optionsManager.setDefault(torrent);
var stop_at_ratio = this.optionsManager.get('stop_at_ratio'); var stop_at_ratio = this.optionsManager.get('stop_at_ratio');
this.fields.remove_at_ratio.setDisabled(!stop_at_ratio); this.fields.remove_at_ratio.setDisabled(!stop_at_ratio);
this.fields.stop_ratio.setDisabled(!stop_at_ratio); this.fields.stop_ratio.setDisabled(!stop_at_ratio);
this.fields.move_completed_path.setDisabled(!this.optionsManager.get('move_completed')); this.fields.move_completed_path.setDisabled(
} !this.optionsManager.get('move_completed')
);
},
}); });

View File

@ -10,13 +10,18 @@
(function() { (function() {
function flagRenderer(value) { function flagRenderer(value) {
if (!value.replace(' ', '').replace(' ', '')){ if (!value.replace(' ', '').replace(' ', '')) {
return ''; return '';
} }
return String.format('<img src="{0}flag/{1}" />', deluge.config.base, value); return String.format(
'<img src="{0}flag/{1}" />',
deluge.config.base,
value
);
} }
function peerAddressRenderer(value, p, record) { function peerAddressRenderer(value, p, record) {
var seed = (record.data['seed'] == 1024) ? 'x-deluge-seed' : 'x-deluge-peer'; var seed =
record.data['seed'] == 1024 ? 'x-deluge-seed' : 'x-deluge-peer';
// Modify display of IPv6 to include brackets // Modify display of IPv6 to include brackets
var peer_ip = value.split(':'); var peer_ip = value.split(':');
if (peer_ip.length > 2) { if (peer_ip.length > 2) {
@ -32,61 +37,73 @@
} }
Deluge.details.PeersTab = Ext.extend(Ext.grid.GridPanel, { Deluge.details.PeersTab = Ext.extend(Ext.grid.GridPanel, {
// fast way to figure out if we have a peer already. // fast way to figure out if we have a peer already.
peers: {}, peers: {},
constructor: function(config) { constructor: function(config) {
config = Ext.apply({ config = Ext.apply(
title: _('Peers'), {
cls: 'x-deluge-peers', title: _('Peers'),
store: new Ext.data.Store({ cls: 'x-deluge-peers',
reader: new Ext.data.JsonReader({ store: new Ext.data.Store({
idProperty: 'ip', reader: new Ext.data.JsonReader(
root: 'peers' {
}, Deluge.data.Peer) idProperty: 'ip',
}), root: 'peers',
columns: [{ },
header: '&nbsp;', Deluge.data.Peer
width: 30, ),
sortable: true, }),
renderer: flagRenderer, columns: [
dataIndex: 'country' {
}, { header: '&nbsp;',
header: _('Address'), width: 30,
width: 125, sortable: true,
sortable: true, renderer: flagRenderer,
renderer: peerAddressRenderer, dataIndex: 'country',
dataIndex: 'ip' },
}, { {
header: _('Client'), header: _('Address'),
width: 125, width: 125,
sortable: true, sortable: true,
renderer: fplain, renderer: peerAddressRenderer,
dataIndex: 'client' dataIndex: 'ip',
}, { },
header: _('Progress'), {
width: 150, header: _('Client'),
sortable: true, width: 125,
renderer: peerProgressRenderer, sortable: true,
dataIndex: 'progress' renderer: fplain,
}, { dataIndex: 'client',
header: _('Down Speed'), },
width: 100, {
sortable: true, header: _('Progress'),
renderer: fspeed, width: 150,
dataIndex: 'down_speed' sortable: true,
}, { renderer: peerProgressRenderer,
header: _('Up Speed'), dataIndex: 'progress',
width: 100, },
sortable: true, {
renderer: fspeed, header: _('Down Speed'),
dataIndex: 'up_speed' width: 100,
}], sortable: true,
stripeRows: true, renderer: fspeed,
deferredRender:false, dataIndex: 'down_speed',
autoScroll:true },
}, config); {
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); Deluge.details.PeersTab.superclass.constructor.call(this, config);
}, },
@ -98,7 +115,7 @@
update: function(torrentId) { update: function(torrentId) {
deluge.client.web.get_torrent_status(torrentId, Deluge.Keys.Peers, { deluge.client.web.get_torrent_status(torrentId, Deluge.Keys.Peers, {
success: this.onRequestComplete, success: this.onRequestComplete,
scope: this scope: this,
}); });
}, },
@ -110,22 +127,26 @@
var addresses = {}; var addresses = {};
// Go through the peers updating and creating peer records // Go through the peers updating and creating peer records
Ext.each(torrent.peers, function(peer) { Ext.each(
if (this.peers[peer.ip]) { torrent.peers,
var record = store.getById(peer.ip); function(peer) {
record.beginEdit(); if (this.peers[peer.ip]) {
for (var k in peer) { var record = store.getById(peer.ip);
if (record.get(k) != peer[k]) { record.beginEdit();
record.set(k, peer[k]); for (var k in peer) {
if (record.get(k) != peer[k]) {
record.set(k, peer[k]);
}
} }
record.endEdit();
} else {
this.peers[peer.ip] = 1;
newPeers.push(new Deluge.data.Peer(peer, peer.ip));
} }
record.endEdit(); addresses[peer.ip] = 1;
} else { },
this.peers[peer.ip] = 1; this
newPeers.push(new Deluge.data.Peer(peer, peer.ip)); );
}
addresses[peer.ip] = 1;
}, this);
store.add(newPeers); store.add(newPeers);
// Remove any peers that should not be left in the store. // Remove any peers that should not be left in the store.
@ -140,6 +161,6 @@
var sortState = store.getSortState(); var sortState = store.getSortState();
if (!sortState) return; if (!sortState) return;
store.sort(sortState.field, sortState.direction); store.sort(sortState.field, sortState.direction);
} },
}); });
})(); })();

View File

@ -22,7 +22,7 @@ Deluge.details.StatusTab = Ext.extend(Ext.Panel, {
this.progressBar = this.add({ this.progressBar = this.add({
xtype: 'progress', xtype: 'progress',
cls: 'x-deluge-status-progressbar' cls: 'x-deluge-status-progressbar',
}); });
this.status = this.add({ this.status = this.add({
@ -32,17 +32,19 @@ Deluge.details.StatusTab = Ext.extend(Ext.Panel, {
border: false, border: false,
width: 1000, width: 1000,
listeners: { listeners: {
'render': { render: {
fn: function(panel) { fn: function(panel) {
panel.load({ panel.load({
url: deluge.config.base + 'render/tab_status.html', url: deluge.config.base + 'render/tab_status.html',
text: _('Loading') + '...' text: _('Loading') + '...',
}); });
panel.getUpdater().on('update', this.onPanelUpdate, this); panel
.getUpdater()
.on('update', this.onPanelUpdate, this);
}, },
scope: this scope: this,
} },
} },
}); });
}, },
@ -57,31 +59,49 @@ Deluge.details.StatusTab = Ext.extend(Ext.Panel, {
if (!this.fields) this.getFields(); if (!this.fields) this.getFields();
deluge.client.web.get_torrent_status(torrentId, Deluge.Keys.Status, { deluge.client.web.get_torrent_status(torrentId, Deluge.Keys.Status, {
success: this.onRequestComplete, success: this.onRequestComplete,
scope: this scope: this,
}); });
}, },
onPanelUpdate: function(el, response) { onPanelUpdate: function(el, response) {
this.fields = {}; this.fields = {};
Ext.each(Ext.query('dd', this.status.body.dom), function(field) { Ext.each(
this.fields[field.className] = field; Ext.query('dd', this.status.body.dom),
}, this); function(field) {
this.fields[field.className] = field;
},
this
);
}, },
onRequestComplete: function(status) { onRequestComplete: function(status) {
seeds = status.total_seeds > -1 ? status.num_seeds + ' (' + status.total_seeds + ')' : status.num_seeds; seeds =
peers = status.total_peers > -1 ? status.num_peers + ' (' + status.total_peers + ')' : status.num_peers; status.total_seeds > -1
last_seen_complete = status.last_seen_complete > 0.0 ? fdate(status.last_seen_complete) : 'Never'; ? status.num_seeds + ' (' + status.total_seeds + ')'
completed_time = status.completed_time > 0.0 ? fdate(status.completed_time) : ''; : status.num_seeds;
peers =
status.total_peers > -1
? status.num_peers + ' (' + status.total_peers + ')'
: status.num_peers;
last_seen_complete =
status.last_seen_complete > 0.0
? fdate(status.last_seen_complete)
: 'Never';
completed_time =
status.completed_time > 0.0 ? fdate(status.completed_time) : '';
var data = { var data = {
downloaded: fsize(status.total_done, true), downloaded: fsize(status.total_done, true),
uploaded: fsize(status.total_uploaded, true), uploaded: fsize(status.total_uploaded, true),
share: (status.ratio == -1) ? '&infin;' : status.ratio.toFixed(3), share: status.ratio == -1 ? '&infin;' : status.ratio.toFixed(3),
announce: ftime(status.next_announce), announce: ftime(status.next_announce),
tracker_status: status.tracker_status, tracker_status: status.tracker_status,
downspeed: (status.download_payload_rate) ? fspeed(status.download_payload_rate) : '0.0 KiB/s', downspeed: status.download_payload_rate
upspeed: (status.upload_payload_rate) ? fspeed(status.upload_payload_rate) : '0.0 KiB/s', ? fspeed(status.download_payload_rate)
: '0.0 KiB/s',
upspeed: status.upload_payload_rate
? fspeed(status.upload_payload_rate)
: '0.0 KiB/s',
eta: ftime(status.eta), eta: ftime(status.eta),
pieces: status.num_pieces + ' (' + fsize(status.piece_length) + ')', pieces: status.num_pieces + ' (' + fsize(status.piece_length) + ')',
seeds: seeds, seeds: seeds,
@ -93,30 +113,43 @@ Deluge.details.StatusTab = Ext.extend(Ext.Panel, {
time_added: fdate(status.time_added), time_added: fdate(status.time_added),
last_seen_complete: last_seen_complete, last_seen_complete: last_seen_complete,
completed_time: completed_time, completed_time: completed_time,
time_since_transfer: ftime(status.time_since_transfer) time_since_transfer: ftime(status.time_since_transfer),
} };
data.auto_managed = _((status.is_auto_managed) ? 'True' : 'False'); data.auto_managed = _(status.is_auto_managed ? 'True' : 'False');
var translate_tracker_status = { var translate_tracker_status = {
'Error' : _('Error'), Error: _('Error'),
'Warning' : _('Warning'), Warning: _('Warning'),
'Announce OK' : _('Announce OK'), 'Announce OK': _('Announce OK'),
'Announce Sent' : _('Announce Sent') 'Announce Sent': _('Announce Sent'),
}; };
for (var key in translate_tracker_status) { for (var key in translate_tracker_status) {
if (data.tracker_status.indexOf(key) != -1) { if (data.tracker_status.indexOf(key) != -1) {
data.tracker_status = data.tracker_status.replace(key, translate_tracker_status[key]); data.tracker_status = data.tracker_status.replace(
key,
translate_tracker_status[key]
);
break; break;
} }
} }
data.downloaded += ' (' + ((status.total_payload_download) ? fsize(status.total_payload_download) : '0.0 KiB') + ')'; data.downloaded +=
data.uploaded += ' (' + ((status.total_payload_upload) ? fsize(status.total_payload_upload): '0.0 KiB') + ')'; ' (' +
(status.total_payload_download
? fsize(status.total_payload_download)
: '0.0 KiB') +
')';
data.uploaded +=
' (' +
(status.total_payload_upload
? fsize(status.total_payload_upload)
: '0.0 KiB') +
')';
for (var field in this.fields) { for (var field in this.fields) {
this.fields[field].innerHTML = data[field]; this.fields[field].innerHTML = data[field];
} }
var text = status.state + ' ' + status.progress.toFixed(2) + '%'; var text = status.state + ' ' + status.progress.toFixed(2) + '%';
this.progressBar.updateProgress(status.progress / 100.0, text); this.progressBar.updateProgress(status.progress / 100.0, text);
} },
}); });

View File

@ -15,13 +15,16 @@ Ext.namespace('Deluge.preferences');
*/ */
Deluge.preferences.Bandwidth = Ext.extend(Ext.form.FormPanel, { Deluge.preferences.Bandwidth = Ext.extend(Ext.form.FormPanel, {
constructor: function(config) { constructor: function(config) {
config = Ext.apply({ config = Ext.apply(
border: false, {
title: _('Bandwidth'), border: false,
header: false, title: _('Bandwidth'),
layout: 'form', header: false,
labelWidth: 10 layout: 'form',
}, config); labelWidth: 10,
},
config
);
Deluge.preferences.Bandwidth.superclass.constructor.call(this, config); Deluge.preferences.Bandwidth.superclass.constructor.call(this, config);
}, },
@ -37,82 +40,107 @@ Deluge.preferences.Bandwidth = Ext.extend(Ext.form.FormPanel, {
defaultType: 'spinnerfield', defaultType: 'spinnerfield',
defaults: { defaults: {
minValue: -1, minValue: -1,
maxValue: 99999 maxValue: 99999,
}, },
style: 'margin-bottom: 0px; padding-bottom: 0px;', style: 'margin-bottom: 0px; padding-bottom: 0px;',
autoHeight: true autoHeight: true,
}); });
om.bind('max_connections_global', fieldset.add({ om.bind(
name: 'max_connections_global', 'max_connections_global',
fieldLabel: _('Maximum Connections:'), fieldset.add({
labelSeparator: '', name: 'max_connections_global',
width: 80, fieldLabel: _('Maximum Connections:'),
value: -1, labelSeparator: '',
decimalPrecision: 0 width: 80,
})); value: -1,
om.bind('max_upload_slots_global', fieldset.add({ decimalPrecision: 0,
name: 'max_upload_slots_global', })
fieldLabel: _('Maximum Upload Slots'), );
labelSeparator: '', om.bind(
width: 80, 'max_upload_slots_global',
value: -1, fieldset.add({
decimalPrecision: 0 name: 'max_upload_slots_global',
})); fieldLabel: _('Maximum Upload Slots'),
om.bind('max_download_speed', fieldset.add({ labelSeparator: '',
name: 'max_download_speed', width: 80,
fieldLabel: _('Maximum Download Speed (KiB/s):'), value: -1,
labelSeparator: '', decimalPrecision: 0,
width: 80, })
value: -1.0, );
decimalPrecision: 1 om.bind(
})); 'max_download_speed',
om.bind('max_upload_speed', fieldset.add({ fieldset.add({
name: 'max_upload_speed', name: 'max_download_speed',
fieldLabel: _('Maximum Upload Speed (KiB/s):'), fieldLabel: _('Maximum Download Speed (KiB/s):'),
labelSeparator: '', labelSeparator: '',
width: 80, width: 80,
value: -1.0, value: -1.0,
decimalPrecision: 1 decimalPrecision: 1,
})); })
om.bind('max_half_open_connections', fieldset.add({ );
name: 'max_half_open_connections', om.bind(
fieldLabel: _('Maximum Half-Open Connections:'), 'max_upload_speed',
labelSeparator: '', fieldset.add({
width: 80, name: 'max_upload_speed',
value: -1, fieldLabel: _('Maximum Upload Speed (KiB/s):'),
decimalPrecision: 0 labelSeparator: '',
})); width: 80,
om.bind('max_connections_per_second', fieldset.add({ value: -1.0,
name: 'max_connections_per_second', decimalPrecision: 1,
fieldLabel: _('Maximum Connection Attempts per Second:'), })
labelSeparator: '', );
width: 80, om.bind(
value: -1, 'max_half_open_connections',
decimalPrecision: 0 fieldset.add({
})); name: 'max_half_open_connections',
fieldLabel: _('Maximum Half-Open Connections:'),
labelSeparator: '',
width: 80,
value: -1,
decimalPrecision: 0,
})
);
om.bind(
'max_connections_per_second',
fieldset.add({
name: 'max_connections_per_second',
fieldLabel: _('Maximum Connection Attempts per Second:'),
labelSeparator: '',
width: 80,
value: -1,
decimalPrecision: 0,
})
);
fieldset = this.add({ fieldset = this.add({
xtype: 'fieldset', xtype: 'fieldset',
border: false, border: false,
title: '', title: '',
defaultType: 'checkbox', defaultType: 'checkbox',
style: 'padding-top: 0px; padding-bottom: 5px; margin-top: 0px; margin-bottom: 0px;', style:
autoHeight: true 'padding-top: 0px; padding-bottom: 5px; margin-top: 0px; margin-bottom: 0px;',
autoHeight: true,
}); });
om.bind('ignore_limits_on_local_network', fieldset.add({ om.bind(
name: 'ignore_limits_on_local_network', 'ignore_limits_on_local_network',
height: 22, fieldset.add({
fieldLabel: '', name: 'ignore_limits_on_local_network',
labelSeparator: '', height: 22,
boxLabel: _('Ignore limits on local network') fieldLabel: '',
})); labelSeparator: '',
om.bind('rate_limit_ip_overhead', fieldset.add({ boxLabel: _('Ignore limits on local network'),
name: 'rate_limit_ip_overhead', })
height: 22, );
fieldLabel: '', om.bind(
labelSeparator: '', 'rate_limit_ip_overhead',
boxLabel: _('Rate limit IP overhead') fieldset.add({
})); name: 'rate_limit_ip_overhead',
height: 22,
fieldLabel: '',
labelSeparator: '',
boxLabel: _('Rate limit IP overhead'),
})
);
fieldset = this.add({ fieldset = this.add({
xtype: 'fieldset', xtype: 'fieldset',
@ -123,41 +151,53 @@ Deluge.preferences.Bandwidth = Ext.extend(Ext.form.FormPanel, {
labelWidth: 200, labelWidth: 200,
defaults: { defaults: {
minValue: -1, minValue: -1,
maxValue: 99999 maxValue: 99999,
}, },
autoHeight: true autoHeight: true,
}); });
om.bind('max_connections_per_torrent', fieldset.add({ om.bind(
name: 'max_connections_per_torrent', 'max_connections_per_torrent',
fieldLabel: _('Maximum Connections:'), fieldset.add({
labelSeparator: '', name: 'max_connections_per_torrent',
width: 80, fieldLabel: _('Maximum Connections:'),
value: -1, labelSeparator: '',
decimalPrecision: 0 width: 80,
})); value: -1,
om.bind('max_upload_slots_per_torrent', fieldset.add({ decimalPrecision: 0,
name: 'max_upload_slots_per_torrent', })
fieldLabel: _('Maximum Upload Slots:'), );
labelSeparator: '', om.bind(
width: 80, 'max_upload_slots_per_torrent',
value: -1, fieldset.add({
decimalPrecision: 0 name: 'max_upload_slots_per_torrent',
})); fieldLabel: _('Maximum Upload Slots:'),
om.bind('max_download_speed_per_torrent', fieldset.add({ labelSeparator: '',
name: 'max_download_speed_per_torrent', width: 80,
fieldLabel: _('Maximum Download Speed (KiB/s):'), value: -1,
labelSeparator: '', decimalPrecision: 0,
width: 80, })
value: -1, );
decimalPrecision: 0 om.bind(
})); 'max_download_speed_per_torrent',
om.bind('max_upload_speed_per_torrent', fieldset.add({ fieldset.add({
name: 'max_upload_speed_per_torrent', name: 'max_download_speed_per_torrent',
fieldLabel: _('Maximum Upload Speed (KiB/s):'), fieldLabel: _('Maximum Download Speed (KiB/s):'),
labelSeparator: '', labelSeparator: '',
width: 80, width: 80,
value: -1, value: -1,
decimalPrecision: 0 decimalPrecision: 0,
})); })
} );
om.bind(
'max_upload_speed_per_torrent',
fieldset.add({
name: 'max_upload_speed_per_torrent',
fieldLabel: _('Maximum Upload Speed (KiB/s):'),
labelSeparator: '',
width: 80,
value: -1,
decimalPrecision: 0,
})
);
},
}); });

View File

@ -14,13 +14,11 @@ Ext.namespace('Deluge.preferences');
* @extends Ext.form.FormPanel * @extends Ext.form.FormPanel
*/ */
Deluge.preferences.Cache = Ext.extend(Ext.form.FormPanel, { Deluge.preferences.Cache = Ext.extend(Ext.form.FormPanel, {
border: false, border: false,
title: _('Cache'), title: _('Cache'),
header: false, header: false,
layout: 'form', layout: 'form',
initComponent: function() { initComponent: function() {
Deluge.preferences.Cache.superclass.initComponent.call(this); Deluge.preferences.Cache.superclass.initComponent.call(this);
@ -36,22 +34,28 @@ Deluge.preferences.Cache = Ext.extend(Ext.form.FormPanel, {
defaults: { defaults: {
decimalPrecision: 0, decimalPrecision: 0,
minValue: -1, minValue: -1,
maxValue: 999999 maxValue: 999999,
} },
}); });
om.bind('cache_size', fieldset.add({ om.bind(
fieldLabel: _('Cache Size (16 KiB Blocks):'), 'cache_size',
labelSeparator: '', fieldset.add({
name: 'cache_size', fieldLabel: _('Cache Size (16 KiB Blocks):'),
width: 60, labelSeparator: '',
value: 512 name: 'cache_size',
})); width: 60,
om.bind('cache_expiry', fieldset.add({ value: 512,
fieldLabel: _('Cache Expiry (seconds):'), })
labelSeparator: '', );
name: 'cache_expiry', om.bind(
width: 60, 'cache_expiry',
value: 60 fieldset.add({
})); fieldLabel: _('Cache Expiry (seconds):'),
} labelSeparator: '',
name: 'cache_expiry',
width: 60,
value: 60,
})
);
},
}); });

View File

@ -14,7 +14,6 @@ Ext.namespace('Deluge.preferences');
* @extends Ext.form.FormPanel * @extends Ext.form.FormPanel
*/ */
Deluge.preferences.Daemon = Ext.extend(Ext.form.FormPanel, { Deluge.preferences.Daemon = Ext.extend(Ext.form.FormPanel, {
border: false, border: false,
title: _('Daemon'), title: _('Daemon'),
header: false, header: false,
@ -30,17 +29,20 @@ Deluge.preferences.Daemon = Ext.extend(Ext.form.FormPanel, {
border: false, border: false,
title: _('Port'), title: _('Port'),
autoHeight: true, autoHeight: true,
defaultType: 'spinnerfield' defaultType: 'spinnerfield',
}); });
om.bind('daemon_port', fieldset.add({ om.bind(
fieldLabel: _('Daemon port:'), 'daemon_port',
labelSeparator: '', fieldset.add({
name: 'daemon_port', fieldLabel: _('Daemon port:'),
value: 58846, labelSeparator: '',
decimalPrecision: 0, name: 'daemon_port',
minValue: -1, value: 58846,
maxValue: 99999 decimalPrecision: 0,
})); minValue: -1,
maxValue: 99999,
})
);
fieldset = this.add({ fieldset = this.add({
xtype: 'fieldset', xtype: 'fieldset',
@ -48,15 +50,18 @@ Deluge.preferences.Daemon = Ext.extend(Ext.form.FormPanel, {
title: _('Connections'), title: _('Connections'),
autoHeight: true, autoHeight: true,
labelWidth: 1, labelWidth: 1,
defaultType: 'checkbox' defaultType: 'checkbox',
}); });
om.bind('allow_remote', fieldset.add({ om.bind(
fieldLabel: '', 'allow_remote',
height: 22, fieldset.add({
labelSeparator: '', fieldLabel: '',
boxLabel: _('Allow Remote Connections'), height: 22,
name: 'allow_remote' labelSeparator: '',
})); boxLabel: _('Allow Remote Connections'),
name: 'allow_remote',
})
);
fieldset = this.add({ fieldset = this.add({
xtype: 'fieldset', xtype: 'fieldset',
@ -64,14 +69,17 @@ Deluge.preferences.Daemon = Ext.extend(Ext.form.FormPanel, {
title: _('Other'), title: _('Other'),
autoHeight: true, autoHeight: true,
labelWidth: 1, labelWidth: 1,
defaultType: 'checkbox' defaultType: 'checkbox',
}); });
om.bind('new_release_check', fieldset.add({ om.bind(
fieldLabel: '', 'new_release_check',
labelSeparator: '', fieldset.add({
height: 40, fieldLabel: '',
boxLabel: _('Periodically check the website for new releases'), labelSeparator: '',
id: 'new_release_check' height: 40,
})); boxLabel: _('Periodically check the website for new releases'),
} id: 'new_release_check',
})
);
},
}); });

View File

@ -15,14 +15,17 @@ Ext.namespace('Deluge.preferences');
*/ */
Deluge.preferences.Downloads = Ext.extend(Ext.FormPanel, { Deluge.preferences.Downloads = Ext.extend(Ext.FormPanel, {
constructor: function(config) { constructor: function(config) {
config = Ext.apply({ config = Ext.apply(
border: false, {
title: _('Downloads'), border: false,
header: false, title: _('Downloads'),
layout: 'form', header: false,
autoHeight: true, layout: 'form',
width: 320 autoHeight: true,
}, config); width: 320,
},
config
);
Deluge.preferences.Downloads.superclass.constructor.call(this, config); Deluge.preferences.Downloads.superclass.constructor.call(this, config);
}, },
@ -39,22 +42,25 @@ Deluge.preferences.Downloads = Ext.extend(Ext.FormPanel, {
autoHeight: true, autoHeight: true,
labelAlign: 'top', labelAlign: 'top',
width: 300, width: 300,
style: 'margin-bottom: 5px; padding-bottom: 5px;' style: 'margin-bottom: 5px; padding-bottom: 5px;',
}); });
optMan.bind('download_location', fieldset.add({ optMan.bind(
xtype: 'textfield', 'download_location',
name: 'download_location', fieldset.add({
fieldLabel: _('Download to:'), xtype: 'textfield',
labelSeparator: '', name: 'download_location',
width: 280 fieldLabel: _('Download to:'),
})); labelSeparator: '',
width: 280,
})
);
var field = fieldset.add({ var field = fieldset.add({
name: 'move_completed_path', name: 'move_completed_path',
fieldLabel: _('Move completed to:'), fieldLabel: _('Move completed to:'),
labelSeparator: '', labelSeparator: '',
width: 280 width: 280,
}); });
optMan.bind('move_completed', field.toggle); optMan.bind('move_completed', field.toggle);
optMan.bind('move_completed_path', field.input); optMan.bind('move_completed_path', field.input);
@ -63,7 +69,7 @@ Deluge.preferences.Downloads = Ext.extend(Ext.FormPanel, {
name: 'torrentfiles_location', name: 'torrentfiles_location',
fieldLabel: _('Copy of .torrent files to:'), fieldLabel: _('Copy of .torrent files to:'),
labelSeparator: '', labelSeparator: '',
width: 280 width: 280,
}); });
optMan.bind('copy_torrent_file', field.toggle); optMan.bind('copy_torrent_file', field.toggle);
optMan.bind('torrentfiles_location', field.input); optMan.bind('torrentfiles_location', field.input);
@ -76,32 +82,43 @@ Deluge.preferences.Downloads = Ext.extend(Ext.FormPanel, {
labelWidth: 1, labelWidth: 1,
defaultType: 'checkbox', defaultType: 'checkbox',
style: 'margin-bottom: 0; padding-bottom: 0;', style: 'margin-bottom: 0; padding-bottom: 0;',
width: 280 width: 280,
}); });
optMan.bind('prioritize_first_last_pieces', fieldset.add({ optMan.bind(
name: 'prioritize_first_last_pieces', 'prioritize_first_last_pieces',
labelSeparator: '', fieldset.add({
height: 22, name: 'prioritize_first_last_pieces',
boxLabel: _('Prioritize first and last pieces of torrent') labelSeparator: '',
})); height: 22,
optMan.bind('sequential_download', fieldset.add({ boxLabel: _('Prioritize first and last pieces of torrent'),
name: 'sequential_download', })
labelSeparator: '', );
height: 22, optMan.bind(
boxLabel: _('Sequential download') 'sequential_download',
})); fieldset.add({
optMan.bind('add_paused', fieldset.add({ name: 'sequential_download',
name: 'add_paused', labelSeparator: '',
labelSeparator: '', height: 22,
height: 22, boxLabel: _('Sequential download'),
boxLabel: _('Add torrents in Paused state') })
})); );
optMan.bind('pre_allocate_storage', fieldset.add({ optMan.bind(
name: 'pre_allocate_storage', 'add_paused',
labelSeparator: '', fieldset.add({
height: 22, name: 'add_paused',
boxLabel: _('Pre-allocate disk space') labelSeparator: '',
})); height: 22,
boxLabel: _('Add torrents in Paused state'),
} })
);
optMan.bind(
'pre_allocate_storage',
fieldset.add({
name: 'pre_allocate_storage',
labelSeparator: '',
height: 22,
boxLabel: _('Pre-allocate disk space'),
})
);
},
}); });

View File

@ -14,7 +14,6 @@ Ext.namespace('Deluge.preferences');
* @extends Ext.form.FormPanel * @extends Ext.form.FormPanel
*/ */
Deluge.preferences.Encryption = Ext.extend(Ext.form.FormPanel, { Deluge.preferences.Encryption = Ext.extend(Ext.form.FormPanel, {
border: false, border: false,
title: _('Encryption'), title: _('Encryption'),
header: false, header: false,
@ -31,61 +30,70 @@ Deluge.preferences.Encryption = Ext.extend(Ext.form.FormPanel, {
header: false, header: false,
autoHeight: true, autoHeight: true,
defaultType: 'combo', defaultType: 'combo',
width: 300 width: 300,
}); });
optMan.bind('enc_in_policy', fieldset.add({ optMan.bind(
fieldLabel: _('Incoming:'), 'enc_in_policy',
labelSeparator : '', fieldset.add({
mode: 'local', fieldLabel: _('Incoming:'),
width: 150, labelSeparator: '',
store: new Ext.data.ArrayStore({ mode: 'local',
fields: ['id', 'text'], width: 150,
data: [ store: new Ext.data.ArrayStore({
[0, _('Forced')], fields: ['id', 'text'],
[1, _('Enabled')], data: [
[2, _('Disabled')] [0, _('Forced')],
] [1, _('Enabled')],
}), [2, _('Disabled')],
editable: false, ],
triggerAction: 'all', }),
valueField: 'id', editable: false,
displayField: 'text' triggerAction: 'all',
})); valueField: 'id',
optMan.bind('enc_out_policy', fieldset.add({ displayField: 'text',
fieldLabel: _('Outgoing:'), })
labelSeparator : '', );
mode: 'local', optMan.bind(
width: 150, 'enc_out_policy',
store: new Ext.data.SimpleStore({ fieldset.add({
fields: ['id', 'text'], fieldLabel: _('Outgoing:'),
data: [ labelSeparator: '',
[0, _('Forced')], mode: 'local',
[1, _('Enabled')], width: 150,
[2, _('Disabled')] store: new Ext.data.SimpleStore({
] fields: ['id', 'text'],
}), data: [
editable: false, [0, _('Forced')],
triggerAction: 'all', [1, _('Enabled')],
valueField: 'id', [2, _('Disabled')],
displayField: 'text' ],
})); }),
optMan.bind('enc_level', fieldset.add({ editable: false,
fieldLabel: _('Level:'), triggerAction: 'all',
labelSeparator : '', valueField: 'id',
mode: 'local', displayField: 'text',
width: 150, })
store: new Ext.data.SimpleStore({ );
fields: ['id', 'text'], optMan.bind(
data: [ 'enc_level',
[0, _('Handshake')], fieldset.add({
[1, _('Full Stream')], fieldLabel: _('Level:'),
[2, _('Either')] labelSeparator: '',
] mode: 'local',
}), width: 150,
editable: false, store: new Ext.data.SimpleStore({
triggerAction: 'all', fields: ['id', 'text'],
valueField: 'id', data: [
displayField: 'text' [0, _('Handshake')],
})); [1, _('Full Stream')],
} [2, _('Either')],
],
}),
editable: false,
triggerAction: 'all',
valueField: 'id',
displayField: 'text',
})
);
},
}); });

View File

@ -14,7 +14,6 @@ Ext.namespace('Deluge.preferences');
* @extends Ext.Window * @extends Ext.Window
*/ */
Deluge.preferences.InstallPluginWindow = Ext.extend(Ext.Window, { Deluge.preferences.InstallPluginWindow = Ext.extend(Ext.Window, {
title: _('Install Plugin'), title: _('Install Plugin'),
layout: 'fit', layout: 'fit',
height: 115, height: 115,
@ -28,7 +27,9 @@ Deluge.preferences.InstallPluginWindow = Ext.extend(Ext.Window, {
plain: true, plain: true,
initComponent: function() { initComponent: function() {
Deluge.preferences.InstallPluginWindow.superclass.initComponent.call(this); Deluge.preferences.InstallPluginWindow.superclass.initComponent.call(
this
);
this.addButton(_('Install'), this.onInstall, this); this.addButton(_('Install'), this.onInstall, this);
this.form = this.add({ this.form = this.add({
@ -37,16 +38,18 @@ Deluge.preferences.InstallPluginWindow = Ext.extend(Ext.Window, {
labelWidth: 70, labelWidth: 70,
autoHeight: true, autoHeight: true,
fileUpload: true, fileUpload: true,
items: [{ items: [
xtype: 'fileuploadfield', {
width: 240, xtype: 'fileuploadfield',
emptyText: _('Select an egg'), width: 240,
fieldLabel: _('Plugin Egg'), emptyText: _('Select an egg'),
name: 'file', fieldLabel: _('Plugin Egg'),
buttonCfg: { name: 'file',
text: _('Browse...') buttonCfg: {
} text: _('Browse...'),
}] },
},
],
}); });
}, },
@ -55,7 +58,7 @@ Deluge.preferences.InstallPluginWindow = Ext.extend(Ext.Window, {
url: deluge.config.base + 'upload', url: deluge.config.base + 'upload',
waitMsg: _('Uploading your plugin...'), waitMsg: _('Uploading your plugin...'),
success: this.onUploadSuccess, success: this.onUploadSuccess,
scope: this scope: this,
}); });
}, },
@ -67,14 +70,14 @@ Deluge.preferences.InstallPluginWindow = Ext.extend(Ext.Window, {
this.hide(); this.hide();
if (upload.result.success) { if (upload.result.success) {
var filename = this.form.getForm().getFieldValues().file; var filename = this.form.getForm().getFieldValues().file;
filename = filename.split('\\').slice(-1)[0] filename = filename.split('\\').slice(-1)[0];
var path = upload.result.files[0]; var path = upload.result.files[0];
this.form.getForm().setValues({file: ''}); this.form.getForm().setValues({ file: '' });
deluge.client.web.upload_plugin(filename, path, { deluge.client.web.upload_plugin(filename, path, {
success: this.onUploadPlugin, success: this.onUploadPlugin,
scope: this, scope: this,
filename: filename filename: filename,
}); });
} }
} },
}); });

View File

@ -14,7 +14,6 @@ Ext.namespace('Deluge.preferences');
* @extends Ext.form.FormPanel * @extends Ext.form.FormPanel
*/ */
Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, { Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, {
border: false, border: false,
title: _('Interface'), title: _('Interface'),
header: false, header: false,
@ -23,7 +22,7 @@ Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, {
initComponent: function() { initComponent: function() {
Deluge.preferences.Interface.superclass.initComponent.call(this); Deluge.preferences.Interface.superclass.initComponent.call(this);
var om = this.optionsManager = new Deluge.OptionsManager(); var om = (this.optionsManager = new Deluge.OptionsManager());
this.on('show', this.onPageShow, this); this.on('show', this.onPageShow, this);
var fieldset = this.add({ var fieldset = this.add({
@ -37,21 +36,30 @@ Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, {
defaults: { defaults: {
height: 17, height: 17,
fieldLabel: '', fieldLabel: '',
labelSeparator: '' labelSeparator: '',
} },
}); });
om.bind('show_session_speed', fieldset.add({ om.bind(
name: 'show_session_speed', 'show_session_speed',
boxLabel: _('Show session speed in titlebar') fieldset.add({
})); name: 'show_session_speed',
om.bind('sidebar_show_zero', fieldset.add({ boxLabel: _('Show session speed in titlebar'),
name: 'sidebar_show_zero', })
boxLabel: _('Show filters with zero torrents') );
})); om.bind(
om.bind('sidebar_multiple_filters', fieldset.add({ 'sidebar_show_zero',
name: 'sidebar_multiple_filters', fieldset.add({
boxLabel: _('Allow the use of multiple filters at once') name: 'sidebar_show_zero',
})); boxLabel: _('Show filters with zero torrents'),
})
);
om.bind(
'sidebar_multiple_filters',
fieldset.add({
name: 'sidebar_multiple_filters',
boxLabel: _('Allow the use of multiple filters at once'),
})
);
var languagePanel = this.add({ var languagePanel = this.add({
xtype: 'fieldset', xtype: 'fieldset',
@ -60,22 +68,25 @@ Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, {
style: 'margin-bottom: 0px; padding-bottom: 5px; padding-top: 5px', style: 'margin-bottom: 0px; padding-bottom: 5px; padding-top: 5px',
autoHeight: true, autoHeight: true,
labelWidth: 1, labelWidth: 1,
defaultType: 'checkbox' defaultType: 'checkbox',
}); });
this.language = om.bind('language', languagePanel.add({ this.language = om.bind(
xtype: 'combo', 'language',
labelSeparator: '', languagePanel.add({
name: 'language', xtype: 'combo',
mode: 'local', labelSeparator: '',
width: 200, name: 'language',
store: new Ext.data.ArrayStore({ mode: 'local',
fields: ['id', 'text'] width: 200,
}), store: new Ext.data.ArrayStore({
editable: false, fields: ['id', 'text'],
triggerAction: 'all', }),
valueField: 'id', editable: false,
displayField: 'text' triggerAction: 'all',
})); valueField: 'id',
displayField: 'text',
})
);
fieldset = this.add({ fieldset = this.add({
xtype: 'fieldset', xtype: 'fieldset',
@ -90,21 +101,21 @@ Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, {
inputType: 'password', inputType: 'password',
labelStyle: 'padding-left: 5px', labelStyle: 'padding-left: 5px',
height: 20, height: 20,
labelSeparator: '' labelSeparator: '',
} },
}); });
this.oldPassword = fieldset.add({ this.oldPassword = fieldset.add({
name: 'old_password', name: 'old_password',
fieldLabel: _('Old:') fieldLabel: _('Old:'),
}); });
this.newPassword = fieldset.add({ this.newPassword = fieldset.add({
name: 'new_password', name: 'new_password',
fieldLabel: _('New:') fieldLabel: _('New:'),
}); });
this.confirmPassword = fieldset.add({ this.confirmPassword = fieldset.add({
name: 'confirm_password', name: 'confirm_password',
fieldLabel: _('Confirm:') fieldLabel: _('Confirm:'),
}); });
fieldset = this.add({ fieldset = this.add({
@ -119,46 +130,63 @@ Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, {
labelSeparator: '', labelSeparator: '',
labelStyle: 'padding-left: 5px', labelStyle: 'padding-left: 5px',
height: 20, height: 20,
width: 80 width: 80,
} },
}); });
om.bind('session_timeout', fieldset.add({ om.bind(
name: 'session_timeout', 'session_timeout',
fieldLabel: _('Session Timeout:'), fieldset.add({
decimalPrecision: 0, name: 'session_timeout',
minValue: -1, fieldLabel: _('Session Timeout:'),
maxValue: 99999 decimalPrecision: 0,
})); minValue: -1,
om.bind('port', fieldset.add({ maxValue: 99999,
name: 'port', })
fieldLabel: _('Port:'), );
decimalPrecision: 0, om.bind(
minValue: 1, 'port',
maxValue: 65535 fieldset.add({
})); name: 'port',
this.httpsField = om.bind('https', fieldset.add({ fieldLabel: _('Port:'),
xtype: 'checkbox', decimalPrecision: 0,
name: 'https', minValue: 1,
hideLabel: true, maxValue: 65535,
width: 300, })
style: 'margin-left: 5px', );
boxLabel: _('Enable SSL (paths relative to Deluge config folder)') this.httpsField = om.bind(
})); 'https',
fieldset.add({
xtype: 'checkbox',
name: 'https',
hideLabel: true,
width: 300,
style: 'margin-left: 5px',
boxLabel: _(
'Enable SSL (paths relative to Deluge config folder)'
),
})
);
this.httpsField.on('check', this.onSSLCheck, this); this.httpsField.on('check', this.onSSLCheck, this);
this.pkeyField = om.bind('pkey', fieldset.add({ this.pkeyField = om.bind(
xtype: 'textfield', 'pkey',
disabled: true, fieldset.add({
name: 'pkey', xtype: 'textfield',
width: 180, disabled: true,
fieldLabel: _('Private Key:') name: 'pkey',
})); width: 180,
this.certField = om.bind('cert', fieldset.add({ fieldLabel: _('Private Key:'),
xtype: 'textfield', })
disabled: true, );
name: 'cert', this.certField = om.bind(
width: 180, 'cert',
fieldLabel: _('Certificate:') fieldset.add({
})); xtype: 'textfield',
disabled: true,
name: 'cert',
width: 180,
fieldLabel: _('Certificate:'),
})
);
}, },
onApply: function() { onApply: function() {
@ -166,7 +194,7 @@ Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, {
if (!Ext.isObjectEmpty(changed)) { if (!Ext.isObjectEmpty(changed)) {
deluge.client.web.set_config(changed, { deluge.client.web.set_config(changed, {
success: this.onSetConfig, success: this.onSetConfig,
scope: this scope: this,
}); });
for (var key in deluge.config) { for (var key in deluge.config) {
@ -175,16 +203,18 @@ Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, {
if ('language' in changed) { if ('language' in changed) {
Ext.Msg.show({ Ext.Msg.show({
title: _('WebUI Language Changed'), title: _('WebUI Language Changed'),
msg: _('Do you want to refresh the page now to use the new language?'), msg: _(
'Do you want to refresh the page now to use the new language?'
),
buttons: { buttons: {
yes: _('Refresh'), yes: _('Refresh'),
no: _('Close') no: _('Close'),
}, },
multiline : false, multiline: false,
fn: function(btnText) { fn: function(btnText) {
if(btnText === 'yes') location.reload(); if (btnText === 'yes') location.reload();
}, },
icon: Ext.MessageBox.QUESTION icon: Ext.MessageBox.QUESTION,
}); });
} }
} }
@ -202,7 +232,7 @@ Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, {
}, },
onGotLanguages: function(info, obj, response, request) { onGotLanguages: function(info, obj, response, request) {
info.unshift(['', _('System Default')]) info.unshift(['', _('System Default')]);
this.language.store.loadData(info); this.language.store.loadData(info);
this.language.setValue(this.optionsManager.get('language')); this.language.setValue(this.optionsManager.get('language'));
}, },
@ -212,11 +242,11 @@ Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, {
if (newPassword != this.confirmPassword.getValue()) { if (newPassword != this.confirmPassword.getValue()) {
Ext.MessageBox.show({ Ext.MessageBox.show({
title: _('Invalid Password'), title: _('Invalid Password'),
msg: _('Your passwords don\'t match!'), msg: _("Your passwords don't match!"),
buttons: Ext.MessageBox.OK, buttons: Ext.MessageBox.OK,
modal: false, modal: false,
icon: Ext.MessageBox.ERROR, icon: Ext.MessageBox.ERROR,
iconCls: 'x-deluge-icon-error' iconCls: 'x-deluge-icon-error',
}); });
return; return;
} }
@ -231,7 +261,7 @@ Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, {
buttons: Ext.MessageBox.OK, buttons: Ext.MessageBox.OK,
modal: false, modal: false,
icon: Ext.MessageBox.ERROR, icon: Ext.MessageBox.ERROR,
iconCls: 'x-deluge-icon-error' iconCls: 'x-deluge-icon-error',
}); });
this.oldPassword.setValue(''); this.oldPassword.setValue('');
} else { } else {
@ -241,14 +271,14 @@ Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, {
buttons: Ext.MessageBox.OK, buttons: Ext.MessageBox.OK,
modal: false, modal: false,
icon: Ext.MessageBox.INFO, icon: Ext.MessageBox.INFO,
iconCls: 'x-deluge-icon-info' iconCls: 'x-deluge-icon-info',
}); });
this.oldPassword.setValue(''); this.oldPassword.setValue('');
this.newPassword.setValue(''); this.newPassword.setValue('');
this.confirmPassword.setValue(''); this.confirmPassword.setValue('');
} }
}, },
scope: this scope: this,
}); });
}, },
@ -259,16 +289,16 @@ Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, {
onPageShow: function() { onPageShow: function() {
deluge.client.web.get_config({ deluge.client.web.get_config({
success: this.onGotConfig, success: this.onGotConfig,
scope: this scope: this,
}); });
deluge.client.webutils.get_languages({ deluge.client.webutils.get_languages({
success: this.onGotLanguages, success: this.onGotLanguages,
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

@ -11,11 +11,11 @@ Ext.namespace('Deluge.preferences');
// custom Vtype for vtype:'IPAddress' // custom Vtype for vtype:'IPAddress'
Ext.apply(Ext.form.VTypes, { Ext.apply(Ext.form.VTypes, {
IPAddress: function(v) { IPAddress: function(v) {
return /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(v); return /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(v);
}, },
IPAddressText: 'Must be a numeric IP address', IPAddressText: 'Must be a numeric IP address',
IPAddressMask: /[\d\.]/i IPAddressMask: /[\d\.]/i,
}); });
/** /**
@ -23,10 +23,9 @@ Ext.apply(Ext.form.VTypes, {
* @extends Ext.form.FormPanel * @extends Ext.form.FormPanel
*/ */
Deluge.preferences.Network = Ext.extend(Ext.form.FormPanel, { Deluge.preferences.Network = Ext.extend(Ext.form.FormPanel, {
border: false, border: false,
layout: 'form', layout: 'form',
title: _('Network'), title: _('Network'),
header: false, header: false,
initComponent: function() { initComponent: function() {
@ -40,15 +39,18 @@ Deluge.preferences.Network = Ext.extend(Ext.form.FormPanel, {
style: 'margin-bottom: 5px; padding-bottom: 0px;', style: 'margin-bottom: 5px; padding-bottom: 0px;',
autoHeight: true, autoHeight: true,
labelWidth: 1, labelWidth: 1,
defaultType: 'textfield' defaultType: 'textfield',
}); });
optMan.bind('listen_interface', fieldset.add({ optMan.bind(
name: 'listen_interface', 'listen_interface',
fieldLabel: '', fieldset.add({
labelSeparator: '', name: 'listen_interface',
width: 200, fieldLabel: '',
vtype: 'IPAddress' labelSeparator: '',
})); width: 200,
vtype: 'IPAddress',
})
);
var fieldset = this.add({ var fieldset = this.add({
xtype: 'fieldset', xtype: 'fieldset',
@ -57,23 +59,26 @@ Deluge.preferences.Network = Ext.extend(Ext.form.FormPanel, {
style: 'margin-bottom: 5px; padding-bottom: 0px;', style: 'margin-bottom: 5px; padding-bottom: 0px;',
autoHeight: true, autoHeight: true,
labelWidth: 1, labelWidth: 1,
defaultType: 'checkbox' defaultType: 'checkbox',
}); });
optMan.bind('random_port', fieldset.add({ optMan.bind(
fieldLabel: '', 'random_port',
labelSeparator: '', fieldset.add({
boxLabel: _('Use Random Port'), fieldLabel: '',
name: 'random_port', labelSeparator: '',
height: 22, boxLabel: _('Use Random Port'),
listeners: { name: 'random_port',
'check': { height: 22,
fn: function(e, checked) { listeners: {
this.listenPort.setDisabled(checked); check: {
fn: function(e, checked) {
this.listenPort.setDisabled(checked);
},
scope: this,
}, },
scope: this },
} })
} );
}));
this.listenPort = fieldset.add({ this.listenPort = fieldset.add({
xtype: 'spinnerfield', xtype: 'spinnerfield',
@ -85,8 +90,8 @@ Deluge.preferences.Network = Ext.extend(Ext.form.FormPanel, {
xtype: 'number', xtype: 'number',
decimalPrecision: 0, decimalPrecision: 0,
minValue: 0, minValue: 0,
maxValue: 65535 maxValue: 65535,
} },
}); });
optMan.bind('listen_ports', this.listenPort); optMan.bind('listen_ports', this.listenPort);
@ -97,14 +102,17 @@ Deluge.preferences.Network = Ext.extend(Ext.form.FormPanel, {
style: 'margin-bottom: 5px; padding-bottom: 0px;', style: 'margin-bottom: 5px; padding-bottom: 0px;',
autoHeight: true, autoHeight: true,
labelWidth: 1, labelWidth: 1,
defaultType: 'textfield' defaultType: 'textfield',
}); });
optMan.bind('outgoing_interface', fieldset.add({ optMan.bind(
name: 'outgoing_interface', 'outgoing_interface',
fieldLabel: '', fieldset.add({
labelSeparator: '', name: 'outgoing_interface',
width: 40, fieldLabel: '',
})); labelSeparator: '',
width: 40,
})
);
fieldset = this.add({ fieldset = this.add({
xtype: 'fieldset', xtype: 'fieldset',
@ -113,23 +121,26 @@ Deluge.preferences.Network = Ext.extend(Ext.form.FormPanel, {
style: 'margin-bottom: 5px; padding-bottom: 0px;', style: 'margin-bottom: 5px; padding-bottom: 0px;',
autoHeight: true, autoHeight: true,
labelWidth: 1, labelWidth: 1,
defaultType: 'checkbox' defaultType: 'checkbox',
}); });
optMan.bind('random_outgoing_ports', fieldset.add({ optMan.bind(
fieldLabel: '', 'random_outgoing_ports',
labelSeparator: '', fieldset.add({
boxLabel: _('Use Random Ports'), fieldLabel: '',
name: 'random_outgoing_ports', labelSeparator: '',
height: 22, boxLabel: _('Use Random Ports'),
listeners: { name: 'random_outgoing_ports',
'check': { height: 22,
fn: function(e, checked) { listeners: {
this.outgoingPorts.setDisabled(checked); check: {
fn: function(e, checked) {
this.outgoingPorts.setDisabled(checked);
},
scope: this,
}, },
scope: this },
} })
} );
}));
this.outgoingPorts = fieldset.add({ this.outgoingPorts = fieldset.add({
xtype: 'spinnergroup', xtype: 'spinnergroup',
name: 'outgoing_ports', name: 'outgoing_ports',
@ -137,27 +148,30 @@ Deluge.preferences.Network = Ext.extend(Ext.form.FormPanel, {
labelSeparator: '', labelSeparator: '',
colCfg: { colCfg: {
labelWidth: 40, labelWidth: 40,
style: 'margin-right: 10px;' style: 'margin-right: 10px;',
}, },
items: [{ items: [
fieldLabel: _('From:'), {
labelSeparator: '', fieldLabel: _('From:'),
strategy: { labelSeparator: '',
xtype: 'number', strategy: {
decimalPrecision: 0, xtype: 'number',
minValue: 0, decimalPrecision: 0,
maxValue: 65535 minValue: 0,
} maxValue: 65535,
}, { },
fieldLabel: _('To:'), },
labelSeparator: '', {
strategy: { fieldLabel: _('To:'),
xtype: 'number', labelSeparator: '',
decimalPrecision: 0, strategy: {
minValue: 0, xtype: 'number',
maxValue: 65535 decimalPrecision: 0,
} minValue: 0,
}] maxValue: 65535,
},
},
],
}); });
optMan.bind('outgoing_ports', this.outgoingPorts); optMan.bind('outgoing_ports', this.outgoingPorts);
@ -168,43 +182,58 @@ Deluge.preferences.Network = Ext.extend(Ext.form.FormPanel, {
autoHeight: true, autoHeight: true,
layout: 'table', layout: 'table',
layoutConfig: { layoutConfig: {
columns: 3 columns: 3,
}, },
defaultType: 'checkbox' defaultType: 'checkbox',
}); });
optMan.bind('upnp', fieldset.add({ optMan.bind(
fieldLabel: '', 'upnp',
labelSeparator: '', fieldset.add({
boxLabel: _('UPnP'), fieldLabel: '',
name: 'upnp' labelSeparator: '',
})); boxLabel: _('UPnP'),
optMan.bind('natpmp', fieldset.add({ name: 'upnp',
fieldLabel: '', })
labelSeparator: '', );
boxLabel: _('NAT-PMP'), optMan.bind(
ctCls: 'x-deluge-indent-checkbox', 'natpmp',
name: 'natpmp' fieldset.add({
})); fieldLabel: '',
optMan.bind('utpex', fieldset.add({ labelSeparator: '',
fieldLabel: '', boxLabel: _('NAT-PMP'),
labelSeparator: '', ctCls: 'x-deluge-indent-checkbox',
boxLabel: _('Peer Exchange'), name: 'natpmp',
ctCls: 'x-deluge-indent-checkbox', })
name: 'utpex' );
})); optMan.bind(
optMan.bind('lsd', fieldset.add({ 'utpex',
fieldLabel: '', fieldset.add({
labelSeparator: '', fieldLabel: '',
boxLabel: _('LSD'), labelSeparator: '',
name: 'lsd' boxLabel: _('Peer Exchange'),
})); ctCls: 'x-deluge-indent-checkbox',
optMan.bind('dht', fieldset.add({ name: 'utpex',
fieldLabel: '', })
labelSeparator: '', );
boxLabel: _('DHT'), optMan.bind(
ctCls: 'x-deluge-indent-checkbox', 'lsd',
name: 'dht' fieldset.add({
})); fieldLabel: '',
labelSeparator: '',
boxLabel: _('LSD'),
name: 'lsd',
})
);
optMan.bind(
'dht',
fieldset.add({
fieldLabel: '',
labelSeparator: '',
boxLabel: _('DHT'),
ctCls: 'x-deluge-indent-checkbox',
name: 'dht',
})
);
fieldset = this.add({ fieldset = this.add({
xtype: 'fieldset', xtype: 'fieldset',
@ -213,13 +242,16 @@ Deluge.preferences.Network = Ext.extend(Ext.form.FormPanel, {
style: 'margin-bottom: 5px; padding-bottom: 0px;', style: 'margin-bottom: 5px; padding-bottom: 0px;',
bodyStyle: 'margin: 0px; padding: 0px', bodyStyle: 'margin: 0px; padding: 0px',
autoHeight: true, autoHeight: true,
defaultType: 'textfield' defaultType: 'textfield',
}); });
optMan.bind('peer_tos', fieldset.add({ optMan.bind(
name: 'peer_tos', 'peer_tos',
fieldLabel: _('Peer TOS Byte:'), fieldset.add({
labelSeparator: '', name: 'peer_tos',
width: 40 fieldLabel: _('Peer TOS Byte:'),
})); labelSeparator: '',
} width: 40,
})
);
},
}); });

View File

@ -15,12 +15,15 @@ Ext.namespace('Deluge.preferences');
*/ */
Deluge.preferences.Other = Ext.extend(Ext.form.FormPanel, { Deluge.preferences.Other = Ext.extend(Ext.form.FormPanel, {
constructor: function(config) { constructor: function(config) {
config = Ext.apply({ config = Ext.apply(
border: false, {
title: _('Other'), border: false,
header: false, title: _('Other'),
layout: 'form' header: false,
}, config); layout: 'form',
},
config
);
Deluge.preferences.Other.superclass.constructor.call(this, config); Deluge.preferences.Other.superclass.constructor.call(this, config);
}, },
@ -35,15 +38,18 @@ Deluge.preferences.Other = Ext.extend(Ext.form.FormPanel, {
title: _('Updates'), title: _('Updates'),
autoHeight: true, autoHeight: true,
labelWidth: 1, labelWidth: 1,
defaultType: 'checkbox' defaultType: 'checkbox',
}); });
optMan.bind('new_release_check', fieldset.add({ optMan.bind(
fieldLabel: '', 'new_release_check',
labelSeparator: '', fieldset.add({
height: 22, fieldLabel: '',
name: 'new_release_check', labelSeparator: '',
boxLabel: _('Be alerted about new releases') height: 22,
})); name: 'new_release_check',
boxLabel: _('Be alerted about new releases'),
})
);
fieldset = this.add({ fieldset = this.add({
xtype: 'fieldset', xtype: 'fieldset',
@ -51,22 +57,27 @@ Deluge.preferences.Other = Ext.extend(Ext.form.FormPanel, {
title: _('System Information'), title: _('System Information'),
autoHeight: true, autoHeight: true,
labelWidth: 1, labelWidth: 1,
defaultType: 'checkbox' defaultType: 'checkbox',
}); });
fieldset.add({ fieldset.add({
xtype: 'panel', xtype: 'panel',
border: false, border: false,
bodyCfg: { bodyCfg: {
html: _('Help us improve Deluge by sending us your Python version, PyGTK version, OS and processor types. Absolutely no other information is sent.') html: _(
} 'Help us improve Deluge by sending us your Python version, PyGTK version, OS and processor types. Absolutely no other information is sent.'
),
},
}); });
optMan.bind('send_info', fieldset.add({ optMan.bind(
fieldLabel: '', 'send_info',
labelSeparator: '', fieldset.add({
height: 22, fieldLabel: '',
boxLabel: _('Yes, please send anonymous statistics'), labelSeparator: '',
name: 'send_info' height: 22,
})); boxLabel: _('Yes, please send anonymous statistics'),
name: 'send_info',
})
);
fieldset = this.add({ fieldset = this.add({
xtype: 'fieldset', xtype: 'fieldset',
@ -74,13 +85,16 @@ Deluge.preferences.Other = Ext.extend(Ext.form.FormPanel, {
title: _('GeoIP Database'), title: _('GeoIP Database'),
autoHeight: true, autoHeight: true,
labelWidth: 80, labelWidth: 80,
defaultType: 'textfield' defaultType: 'textfield',
}); });
optMan.bind('geoip_db_location', fieldset.add({ optMan.bind(
name: 'geoip_db_location', 'geoip_db_location',
fieldLabel: _('Path:'), fieldset.add({
labelSeparator: '', name: 'geoip_db_location',
width: 200 fieldLabel: _('Path:'),
})); labelSeparator: '',
} width: 200,
})
);
},
}); });

View File

@ -14,7 +14,6 @@ Ext.namespace('Deluge.preferences');
* @extends Ext.Panel * @extends Ext.Panel
*/ */
Deluge.preferences.Plugins = Ext.extend(Ext.Panel, { Deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
layout: 'border', layout: 'border',
title: _('Plugins'), title: _('Plugins'),
header: false, header: false,
@ -23,60 +22,79 @@ Deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
pluginTemplate: new Ext.Template( pluginTemplate: new Ext.Template(
'<dl class="singleline">' + '<dl class="singleline">' +
'<dt>' + _('Author:') + '</dt><dd>{author}</dd>' + '<dt>' +
'<dt>' + _('Version:') + '</dt><dd>{version}</dd>' + _('Author:') +
'<dt>' + _('Author Email:') + '</dt><dd>{email}</dd>' + '</dt><dd>{author}</dd>' +
'<dt>' + _('Homepage:') + '</dt><dd>{homepage}</dd>' + '<dt>' +
'<dt>' + _('Details:') + '</dt><dd style="white-space:normal">{details}</dd>' + _('Version:') +
'</dl>' '</dt><dd>{version}</dd>' +
'<dt>' +
_('Author Email:') +
'</dt><dd>{email}</dd>' +
'<dt>' +
_('Homepage:') +
'</dt><dd>{homepage}</dd>' +
'<dt>' +
_('Details:') +
'</dt><dd style="white-space:normal">{details}</dd>' +
'</dl>'
), ),
initComponent: function() { initComponent: function() {
Deluge.preferences.Plugins.superclass.initComponent.call(this); Deluge.preferences.Plugins.superclass.initComponent.call(this);
this.defaultValues = { this.defaultValues = {
'version': '', version: '',
'email': '', email: '',
'homepage': '', homepage: '',
'details': '' details: '',
}; };
this.pluginTemplate.compile(); this.pluginTemplate.compile();
var checkboxRenderer = function(v, p, record){ var checkboxRenderer = function(v, p, record) {
p.css += ' x-grid3-check-col-td'; p.css += ' x-grid3-check-col-td';
return '<div class="x-grid3-check-col'+(v?'-on':'')+'"> </div>'; return (
} '<div class="x-grid3-check-col' + (v ? '-on' : '') + '"> </div>'
);
};
this.list = this.add({ this.list = this.add({
xtype: 'listview', xtype: 'listview',
store: new Ext.data.ArrayStore({ store: new Ext.data.ArrayStore({
fields: [ fields: [
{name: 'enabled', mapping: 0}, { name: 'enabled', mapping: 0 },
{name: 'plugin', mapping: 1, sortType: 'asUCString'} { name: 'plugin', mapping: 1, sortType: 'asUCString' },
] ],
}), }),
columns: [{ columns: [
id: 'enabled', {
header: _('Enabled'), id: 'enabled',
width: .2, header: _('Enabled'),
sortable: true, width: 0.2,
tpl: new Ext.XTemplate('{enabled:this.getCheckbox}', { sortable: true,
getCheckbox: function(v) { tpl: new Ext.XTemplate('{enabled:this.getCheckbox}', {
return '<div class="x-grid3-check-col'+(v?'-on':'')+'" rel="chkbox"> </div>'; getCheckbox: function(v) {
} return (
}), '<div class="x-grid3-check-col' +
dataIndex: 'enabled' (v ? '-on' : '') +
}, { '" rel="chkbox"> </div>'
id: 'plugin', );
header: _('Plugin'), },
width: .8, }),
sortable: true, dataIndex: 'enabled',
dataIndex: 'plugin' },
}], {
id: 'plugin',
header: _('Plugin'),
width: 0.8,
sortable: true,
dataIndex: 'plugin',
},
],
singleSelect: true, singleSelect: true,
autoExpandColumn: 'plugin', autoExpandColumn: 'plugin',
listeners: { listeners: {
selectionchange: {fn: this.onPluginSelect, scope: this} selectionchange: { fn: this.onPluginSelect, scope: this },
} },
}); });
this.panel = this.add({ this.panel = this.add({
@ -84,23 +102,27 @@ Deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
autoScroll: true, autoScroll: true,
items: [this.list], items: [this.list],
bbar: new Ext.Toolbar({ bbar: new Ext.Toolbar({
items: [{ items: [
cls: 'x-btn-text-icon', {
iconCls: 'x-deluge-install-plugin', cls: 'x-btn-text-icon',
text: _('Install'), iconCls: 'x-deluge-install-plugin',
handler: this.onInstallPluginWindow, text: _('Install'),
scope: this handler: this.onInstallPluginWindow,
}, '->', { scope: this,
cls: 'x-btn-text-icon', },
text: _('Find More'), '->',
iconCls: 'x-deluge-find-more', {
handler: this.onFindMorePlugins, cls: 'x-btn-text-icon',
scope: this text: _('Find More'),
}] iconCls: 'x-deluge-find-more',
}) handler: this.onFindMorePlugins,
scope: this,
},
],
}),
}); });
var pp = this.pluginInfo = this.add({ var pp = (this.pluginInfo = this.add({
xtype: 'panel', xtype: 'panel',
border: false, border: false,
height: 100, height: 100,
@ -108,9 +130,9 @@ Deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
padding: '5', padding: '5',
autoScroll: true, autoScroll: true,
bodyCfg: { bodyCfg: {
style: 'white-space: nowrap' style: 'white-space: nowrap',
} },
}); }));
this.pluginInfo.on('render', this.onPluginInfoRender, this); this.pluginInfo.on('render', this.onPluginInfoRender, this);
this.list.on('click', this.onNodeClick, this); this.list.on('click', this.onNodeClick, this);
@ -135,36 +157,40 @@ Deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
updatePlugins: function() { updatePlugins: function() {
var onGotAvailablePlugins = function(plugins) { var onGotAvailablePlugins = function(plugins) {
this.availablePlugins = plugins.sort(function (a, b) { this.availablePlugins = plugins.sort(function(a, b) {
return a.toLowerCase().localeCompare(b.toLowerCase()); return a.toLowerCase().localeCompare(b.toLowerCase());
}); });
deluge.client.core.get_enabled_plugins({ deluge.client.core.get_enabled_plugins({
success: onGotEnabledPlugins, success: onGotEnabledPlugins,
scope: this scope: this,
}); });
} };
var onGotEnabledPlugins = function(plugins) { var onGotEnabledPlugins = function(plugins) {
this.enabledPlugins = plugins; this.enabledPlugins = plugins;
this.onGotPlugins() this.onGotPlugins();
} };
deluge.client.core.get_available_plugins({ deluge.client.core.get_available_plugins({
success: onGotAvailablePlugins, success: onGotAvailablePlugins,
scope: this scope: this,
}); });
}, },
updatePluginsGrid: function() { updatePluginsGrid: function() {
var plugins = []; var plugins = [];
Ext.each(this.availablePlugins, function(plugin) { Ext.each(
if (this.enabledPlugins.indexOf(plugin) > -1) { this.availablePlugins,
plugins.push([true, plugin]); function(plugin) {
} else { if (this.enabledPlugins.indexOf(plugin) > -1) {
plugins.push([false, plugin]); plugins.push([true, plugin]);
} } else {
}, this); plugins.push([false, plugin]);
}
},
this
);
this.list.getStore().loadData(plugins); this.list.getStore().loadData(plugins);
}, },
@ -173,7 +199,7 @@ Deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
if (el.getAttribute('rel') != 'chkbox') return; if (el.getAttribute('rel') != 'chkbox') return;
var r = dv.getStore().getAt(index); var r = dv.getStore().getAt(index);
if (r.get('plugin') == "WebUi") return; if (r.get('plugin') == 'WebUi') return;
r.set('enabled', !r.get('enabled')); r.set('enabled', !r.get('enabled'));
r.commit(); r.commit();
if (r.get('enabled')) { if (r.get('enabled')) {
@ -198,8 +224,8 @@ Deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
version: info['Version'], version: info['Version'],
email: info['Author-email'], email: info['Author-email'],
homepage: info['Home-page'], homepage: info['Home-page'],
details: info['Description'] details: info['Description'],
} };
this.setInfo(values); this.setInfo(values);
delete info; delete info;
}, },
@ -237,7 +263,7 @@ Deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
var r = dv.getRecords(selections)[0]; var r = dv.getRecords(selections)[0];
deluge.client.web.get_plugin_info(r.get('plugin'), { deluge.client.web.get_plugin_info(r.get('plugin'), {
success: this.onGotPluginInfo, success: this.onGotPluginInfo,
scope: this scope: this,
}); });
}, },
@ -247,5 +273,5 @@ Deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
onPluginInfoRender: function(ct, position) { onPluginInfoRender: function(ct, position) {
this.setInfo(); this.setInfo();
} },
}); });

View File

@ -9,14 +9,13 @@
*/ */
Ext.namespace('Deluge.preferences'); Ext.namespace('Deluge.preferences');
PreferencesRecord = Ext.data.Record.create([{name:'name', type:'string'}]); PreferencesRecord = Ext.data.Record.create([{ 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, { Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
/** /**
* @property {String} currentPage The currently selected page. * @property {String} currentPage The currently selected page.
*/ */
@ -38,33 +37,38 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
pages: {}, pages: {},
initComponent: function() { initComponent: function() {
Deluge.preferences.PreferencesWindow.superclass.initComponent.call(this); Deluge.preferences.PreferencesWindow.superclass.initComponent.call(
this
);
this.list = new Ext.list.ListView({ this.list = new Ext.list.ListView({
store: new Ext.data.Store(), store: new Ext.data.Store(),
columns: [{ columns: [
id: 'name', {
renderer: fplain, id: 'name',
dataIndex: 'name' renderer: fplain,
}], dataIndex: 'name',
},
],
singleSelect: true, singleSelect: true,
listeners: { listeners: {
'selectionchange': { selectionchange: {
fn: this.onPageSelect, scope: this fn: this.onPageSelect,
} scope: this,
},
}, },
hideHeaders: true, hideHeaders: true,
autoExpandColumn: 'name', autoExpandColumn: 'name',
deferredRender: false, deferredRender: false,
autoScroll: true, autoScroll: true,
collapsible: true collapsible: true,
}); });
this.add({ this.add({
region: 'west', region: 'west',
items: [this.list], items: [this.list],
width: 120, width: 120,
margins: '0 5 0 0', margins: '0 5 0 0',
cmargins: '0 5 0 0' cmargins: '0 5 0 0',
}); });
this.configPanel = this.add({ this.configPanel = this.add({
@ -73,10 +77,10 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
region: 'center', region: 'center',
layout: 'card', layout: 'card',
layoutConfig: { layoutConfig: {
deferredRender: true deferredRender: true,
}, },
autoScroll: true, autoScroll: true,
width: 300 width: 300,
}); });
this.addButton(_('Close'), this.onClose, this); this.addButton(_('Close'), this.onClose, this);
@ -110,11 +114,14 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
if (!Ext.isObjectEmpty(changed)) { if (!Ext.isObjectEmpty(changed)) {
// Workaround for only displaying single listen port but still pass array to core. // Workaround for only displaying single listen port but still pass array to core.
if ('listen_ports' in changed) { if ('listen_ports' in changed) {
changed.listen_ports = [changed.listen_ports, changed.listen_ports] changed.listen_ports = [
changed.listen_ports,
changed.listen_ports,
];
} }
deluge.client.core.set_config(changed, { deluge.client.core.set_config(changed, {
success: this.onSetConfig, success: this.onSetConfig,
scope: this scope: this,
}); });
} }
@ -123,7 +130,6 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
} }
}, },
/** /**
* 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
@ -139,7 +145,7 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
addPage: function(page) { addPage: function(page) {
var store = this.list.getStore(); var store = this.list.getStore();
var name = page.title; var name = page.title;
store.add([new PreferencesRecord({name: name})]); store.add([new PreferencesRecord({ name: name })]);
page['bodyStyle'] = 'padding: 5px'; page['bodyStyle'] = 'padding: 5px';
page.preferences = this; page.preferences = this;
this.pages[name] = this.configPanel.add(page); this.pages[name] = this.configPanel.add(page);
@ -165,7 +171,9 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
*/ */
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);
}, },
@ -173,7 +181,9 @@ 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;
@ -208,8 +218,8 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
if (!deluge.client.core) return; if (!deluge.client.core) return;
deluge.client.core.get_config({ deluge.client.core.get_config({
success: this.onGotConfig, success: this.onGotConfig,
scope: this scope: this,
}) });
}, },
// private // private
@ -221,16 +231,16 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
onOk: function() { onOk: function() {
var changed = this.optionsManager.getDirty(); var changed = this.optionsManager.getDirty();
if (!Ext.isObjectEmpty(changed)) { if (!Ext.isObjectEmpty(changed)) {
deluge.client.core.set_config(changed, { deluge.client.core.set_config(changed, {
success: this.onSetConfig, success: this.onSetConfig,
scope: this scope: this,
}); });
} }
for (var page in this.pages) { for (var page in this.pages) {
if (this.pages[page].onOk) this.pages[page].onOk(); if (this.pages[page].onOk) this.pages[page].onOk();
} }
this.hide(); this.hide();
} },
}); });

View File

@ -14,7 +14,6 @@ Ext.ns('Deluge.preferences');
* @extends Ext.form.FieldSet * @extends Ext.form.FieldSet
*/ */
Deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, { Deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, {
border: false, border: false,
autoHeight: true, autoHeight: true,
labelWidth: 70, labelWidth: 70,
@ -37,13 +36,13 @@ Deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, {
[3, _('Socks5 Auth')], [3, _('Socks5 Auth')],
[4, _('HTTP')], [4, _('HTTP')],
[5, _('HTTP Auth')], [5, _('HTTP Auth')],
[6, _('I2P')] [6, _('I2P')],
] ],
}), }),
editable: false, editable: false,
triggerAction: 'all', triggerAction: 'all',
valueField: 'id', valueField: 'id',
displayField: 'text' displayField: 'text',
}); });
this.proxyType.on('change', this.onFieldChange, this); this.proxyType.on('change', this.onFieldChange, this);
this.proxyType.on('select', this.onTypeSelect, this); this.proxyType.on('select', this.onTypeSelect, this);
@ -53,7 +52,7 @@ Deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, {
name: 'hostname', name: 'hostname',
fieldLabel: _('Host:'), fieldLabel: _('Host:'),
labelSeparator: '', labelSeparator: '',
width: 220 width: 220,
}); });
this.hostname.on('change', this.onFieldChange, this); this.hostname.on('change', this.onFieldChange, this);
@ -65,16 +64,16 @@ Deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, {
width: 80, width: 80,
decimalPrecision: 0, decimalPrecision: 0,
minValue: 0, minValue: 0,
maxValue: 65535 maxValue: 65535,
}); });
this.port.on('change', this.onFieldChange, this); this.port.on('change', this.onFieldChange, this);
this.username = this.add({ this.username = this.add({
xtype: 'textfield', xtype: 'textfield',
name: 'username', name: 'username',
fieldLabel: _('Username:'), fieldLabel: _('Username:'),
labelSeparator: '', labelSeparator: '',
width: 220 width: 220,
}); });
this.username.on('change', this.onFieldChange, this); this.username.on('change', this.onFieldChange, this);
@ -84,7 +83,7 @@ Deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, {
fieldLabel: _('Password:'), fieldLabel: _('Password:'),
labelSeparator: '', labelSeparator: '',
inputType: 'password', inputType: 'password',
width: 220 width: 220,
}); });
this.password.on('change', this.onFieldChange, this); this.password.on('change', this.onFieldChange, this);
@ -93,7 +92,7 @@ Deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, {
name: 'proxy_host_resolve', name: 'proxy_host_resolve',
fieldLabel: '', fieldLabel: '',
boxLabel: _('Proxy Hostnames'), boxLabel: _('Proxy Hostnames'),
width: 220 width: 220,
}); });
this.proxy_host_resolve.on('change', this.onFieldChange, this); this.proxy_host_resolve.on('change', this.onFieldChange, this);
@ -102,7 +101,7 @@ Deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, {
name: 'proxy_peer_conn', name: 'proxy_peer_conn',
fieldLabel: '', fieldLabel: '',
boxLabel: _('Proxy Peers'), boxLabel: _('Proxy Peers'),
width: 220 width: 220,
}); });
this.proxy_peer_conn.on('change', this.onFieldChange, this); this.proxy_peer_conn.on('change', this.onFieldChange, this);
@ -111,7 +110,7 @@ Deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, {
name: 'proxy_tracker_conn', name: 'proxy_tracker_conn',
fieldLabel: '', fieldLabel: '',
boxLabel: _('Proxy Trackers'), boxLabel: _('Proxy Trackers'),
width: 220 width: 220,
}); });
this.proxy_tracker_conn.on('change', this.onFieldChange, this); this.proxy_tracker_conn.on('change', this.onFieldChange, this);
@ -122,7 +121,7 @@ Deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, {
autoHeight: true, autoHeight: true,
labelWidth: 1, labelWidth: 1,
defaultType: 'checkbox', defaultType: 'checkbox',
style: 'padding-left: 0px; margin-top: 10px' style: 'padding-left: 0px; margin-top: 10px',
}); });
this.force_proxy = fieldset.add({ this.force_proxy = fieldset.add({
@ -130,8 +129,7 @@ Deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, {
labelSeparator: '', labelSeparator: '',
height: 20, height: 20,
name: 'force_proxy', name: 'force_proxy',
boxLabel: _('Force Use of Proxy') boxLabel: _('Force Use of Proxy'),
}); });
this.force_proxy.on('change', this.onFieldChange, this); this.force_proxy.on('change', this.onFieldChange, this);
@ -140,7 +138,7 @@ Deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, {
labelSeparator: '', labelSeparator: '',
height: 20, height: 20,
name: 'anonymous_mode', name: 'anonymous_mode',
boxLabel: _('Hide Client Identity') boxLabel: _('Hide Client Identity'),
}); });
this.anonymous_mode.on('change', this.onFieldChange, this); this.anonymous_mode.on('change', this.onFieldChange, this);
@ -153,17 +151,17 @@ Deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, {
getValue: function() { getValue: function() {
return { return {
'type': this.proxyType.getValue(), type: this.proxyType.getValue(),
'hostname': this.hostname.getValue(), hostname: this.hostname.getValue(),
'port': Number(this.port.getValue()), port: Number(this.port.getValue()),
'username': this.username.getValue(), username: this.username.getValue(),
'password': this.password.getValue(), password: this.password.getValue(),
'proxy_hostnames': this.proxy_host_resolve.getValue(), proxy_hostnames: this.proxy_host_resolve.getValue(),
'proxy_peer_connections': this.proxy_peer_conn.getValue(), proxy_peer_connections: this.proxy_peer_conn.getValue(),
'proxy_tracker_connections': this.proxy_tracker_conn.getValue(), proxy_tracker_connections: this.proxy_tracker_conn.getValue(),
'force_proxy': this.force_proxy.getValue(), force_proxy: this.force_proxy.getValue(),
'anonymous_mode': this.anonymous_mode.getValue() anonymous_mode: this.anonymous_mode.getValue(),
} };
}, },
// Set the values of the proxies // Set the values of the proxies
@ -223,5 +221,5 @@ Deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, {
this.username.hide(); this.username.hide();
this.password.hide(); this.password.hide();
} }
} },
}); });

View File

@ -15,30 +15,35 @@ Ext.namespace('Deluge.preferences');
*/ */
Deluge.preferences.Proxy = Ext.extend(Ext.form.FormPanel, { Deluge.preferences.Proxy = Ext.extend(Ext.form.FormPanel, {
constructor: function(config) { constructor: function(config) {
config = Ext.apply({ config = Ext.apply(
border: false, {
title: _('Proxy'), border: false,
header: false, title: _('Proxy'),
layout: 'form', header: false,
autoScroll: true layout: 'form',
}, config); autoScroll: true,
},
config
);
Deluge.preferences.Proxy.superclass.constructor.call(this, config); Deluge.preferences.Proxy.superclass.constructor.call(this, config);
}, },
initComponent: function() { initComponent: function() {
Deluge.preferences.Proxy.superclass.initComponent.call(this); Deluge.preferences.Proxy.superclass.initComponent.call(this);
this.proxy = this.add(new Deluge.preferences.ProxyField({ this.proxy = this.add(
title: _('Proxy'), new Deluge.preferences.ProxyField({
name: 'proxy' title: _('Proxy'),
})); name: 'proxy',
})
);
this.proxy.on('change', this.onProxyChange, this); this.proxy.on('change', this.onProxyChange, this);
deluge.preferences.getOptionsManager().bind('proxy', this.proxy); deluge.preferences.getOptionsManager().bind('proxy', this.proxy);
}, },
getValue: function() { getValue: function() {
return { return {
'proxy': this.proxy.getValue() proxy: this.proxy.getValue(),
} };
}, },
setValue: function(value) { setValue: function(value) {
@ -53,5 +58,5 @@ Deluge.preferences.Proxy = Ext.extend(Ext.form.FormPanel, {
oldValues[field.getName()] = oldValue; oldValues[field.getName()] = oldValue;
this.fireEvent('change', this, newValues, oldValues); this.fireEvent('change', this, newValues, oldValues);
} },
}); });

View File

@ -14,7 +14,6 @@ Ext.namespace('Deluge.preferences');
* @extends Ext.form.FormPanel * @extends Ext.form.FormPanel
*/ */
Deluge.preferences.Queue = Ext.extend(Ext.form.FormPanel, { Deluge.preferences.Queue = Ext.extend(Ext.form.FormPanel, {
border: false, border: false,
title: _('Queue'), title: _('Queue'),
header: false, header: false,
@ -32,15 +31,18 @@ Deluge.preferences.Queue = Ext.extend(Ext.form.FormPanel, {
style: 'padding-top: 5px; margin-bottom: 0px;', style: 'padding-top: 5px; margin-bottom: 0px;',
autoHeight: true, autoHeight: true,
labelWidth: 1, labelWidth: 1,
defaultType: 'checkbox' defaultType: 'checkbox',
}); });
om.bind('queue_new_to_top', fieldset.add({ om.bind(
fieldLabel: '', 'queue_new_to_top',
labelSeparator: '', fieldset.add({
height: 22, fieldLabel: '',
boxLabel: _('Queue to top'), labelSeparator: '',
name: 'queue_new_to_top' height: 22,
})); boxLabel: _('Queue to top'),
name: 'queue_new_to_top',
})
);
fieldset = this.add({ fieldset = this.add({
xtype: 'fieldset', xtype: 'fieldset',
@ -49,51 +51,66 @@ Deluge.preferences.Queue = Ext.extend(Ext.form.FormPanel, {
autoHeight: true, autoHeight: true,
labelWidth: 150, labelWidth: 150,
defaultType: 'spinnerfield', defaultType: 'spinnerfield',
style: 'padding-top: 5px; margin-bottom: 0px' style: 'padding-top: 5px; margin-bottom: 0px',
}); });
om.bind('max_active_limit', fieldset.add({ om.bind(
fieldLabel: _('Total:'), 'max_active_limit',
labelSeparator: '', fieldset.add({
name: 'max_active_limit', fieldLabel: _('Total:'),
value: 8, labelSeparator: '',
width: 80, name: 'max_active_limit',
decimalPrecision: 0, value: 8,
minValue: -1, width: 80,
maxValue: 99999 decimalPrecision: 0,
})); minValue: -1,
om.bind('max_active_downloading', fieldset.add({ maxValue: 99999,
fieldLabel: _('Downloading:'), })
labelSeparator: '', );
name: 'max_active_downloading', om.bind(
value: 3, 'max_active_downloading',
width: 80, fieldset.add({
decimalPrecision: 0, fieldLabel: _('Downloading:'),
minValue: -1, labelSeparator: '',
maxValue: 99999 name: 'max_active_downloading',
})); value: 3,
om.bind('max_active_seeding', fieldset.add({ width: 80,
fieldLabel: _('Seeding:'), decimalPrecision: 0,
labelSeparator: '', minValue: -1,
name: 'max_active_seeding', maxValue: 99999,
value: 5, })
width: 80, );
decimalPrecision: 0, om.bind(
minValue: -1, 'max_active_seeding',
maxValue: 99999 fieldset.add({
})); fieldLabel: _('Seeding:'),
om.bind('dont_count_slow_torrents', fieldset.add({ labelSeparator: '',
xtype: 'checkbox', name: 'max_active_seeding',
name: 'dont_count_slow_torrents', value: 5,
height: 22, width: 80,
hideLabel: true, decimalPrecision: 0,
boxLabel: _('Ignore slow torrents') minValue: -1,
})); maxValue: 99999,
om.bind('auto_manage_prefer_seeds', fieldset.add({ })
xtype: 'checkbox', );
name: 'auto_manage_prefer_seeds', om.bind(
hideLabel: true, 'dont_count_slow_torrents',
boxLabel: _('Prefer seeding torrents') fieldset.add({
})); xtype: 'checkbox',
name: 'dont_count_slow_torrents',
height: 22,
hideLabel: true,
boxLabel: _('Ignore slow torrents'),
})
);
om.bind(
'auto_manage_prefer_seeds',
fieldset.add({
xtype: 'checkbox',
name: 'auto_manage_prefer_seeds',
hideLabel: true,
boxLabel: _('Prefer seeding torrents'),
})
);
fieldset = this.add({ fieldset = this.add({
xtype: 'fieldset', xtype: 'fieldset',
@ -102,42 +119,51 @@ Deluge.preferences.Queue = Ext.extend(Ext.form.FormPanel, {
autoHeight: true, autoHeight: true,
labelWidth: 150, labelWidth: 150,
defaultType: 'spinnerfield', defaultType: 'spinnerfield',
style: 'padding-top: 5px; margin-bottom: 0px' style: 'padding-top: 5px; margin-bottom: 0px',
}); });
om.bind('share_ratio_limit', fieldset.add({ om.bind(
fieldLabel: _('Share Ratio:'), 'share_ratio_limit',
labelSeparator: '', fieldset.add({
name: 'share_ratio_limit', fieldLabel: _('Share Ratio:'),
value: 8, labelSeparator: '',
width: 80, name: 'share_ratio_limit',
incrementValue: 0.1, value: 8,
minValue: -1, width: 80,
maxValue: 99999, incrementValue: 0.1,
alternateIncrementValue: 1, minValue: -1,
decimalPrecision: 2 maxValue: 99999,
})); alternateIncrementValue: 1,
om.bind('seed_time_ratio_limit', fieldset.add({ decimalPrecision: 2,
fieldLabel: _('Time Ratio:'), })
labelSeparator: '', );
name: 'seed_time_ratio_limit', om.bind(
value: 3, 'seed_time_ratio_limit',
width: 80, fieldset.add({
incrementValue: 0.1, fieldLabel: _('Time Ratio:'),
minValue: -1, labelSeparator: '',
maxValue: 99999, name: 'seed_time_ratio_limit',
alternateIncrementValue: 1, value: 3,
decimalPrecision: 2 width: 80,
})); incrementValue: 0.1,
om.bind('seed_time_limit', fieldset.add({ minValue: -1,
fieldLabel: _('Time (m):'), maxValue: 99999,
labelSeparator: '', alternateIncrementValue: 1,
name: 'seed_time_limit', decimalPrecision: 2,
value: 5, })
width: 80, );
decimalPrecision: 0, om.bind(
minValue: -1, 'seed_time_limit',
maxValue: 99999 fieldset.add({
})); fieldLabel: _('Time (m):'),
labelSeparator: '',
name: 'seed_time_limit',
value: 5,
width: 80,
decimalPrecision: 0,
minValue: -1,
maxValue: 99999,
})
);
fieldset = this.add({ fieldset = this.add({
xtype: 'fieldset', xtype: 'fieldset',
@ -147,18 +173,18 @@ Deluge.preferences.Queue = Ext.extend(Ext.form.FormPanel, {
title: _('Share Ratio Reached'), title: _('Share Ratio Reached'),
layout: 'table', layout: 'table',
layoutConfig: {columns: 2}, layoutConfig: { columns: 2 },
labelWidth: 0, labelWidth: 0,
defaultType: 'checkbox', defaultType: 'checkbox',
defaults: { defaults: {
fieldLabel: '', fieldLabel: '',
labelSeparator: '' labelSeparator: '',
} },
}); });
this.stopAtRatio = fieldset.add({ this.stopAtRatio = fieldset.add({
name: 'stop_seed_at_ratio', name: 'stop_seed_at_ratio',
boxLabel: _('Share Ratio:') boxLabel: _('Share Ratio:'),
}); });
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);
@ -174,7 +200,7 @@ Deluge.preferences.Queue = Ext.extend(Ext.form.FormPanel, {
minValue: -1, minValue: -1,
maxValue: 99999, maxValue: 99999,
alternateIncrementValue: 1, alternateIncrementValue: 1,
decimalPrecision: 2 decimalPrecision: 2,
}); });
om.bind('stop_seed_ratio', this.stopRatio); om.bind('stop_seed_ratio', this.stopRatio);
@ -183,17 +209,20 @@ Deluge.preferences.Queue = Ext.extend(Ext.form.FormPanel, {
columns: 1, columns: 1,
colspan: 2, colspan: 2,
disabled: true, disabled: true,
style: "margin-left: 10px", style: 'margin-left: 10px',
items: [{ items: [
boxLabel: _('Pause torrent'), {
name: 'at_ratio', boxLabel: _('Pause torrent'),
inputValue: false, name: 'at_ratio',
checked: true inputValue: false,
}, { checked: true,
boxLabel: _('Remove torrent'), },
name: 'at_ratio', {
inputValue: true boxLabel: _('Remove torrent'),
}] name: 'at_ratio',
inputValue: true,
},
],
}); });
om.bind('remove_seed_at_ratio', this.removeAtRatio); om.bind('remove_seed_at_ratio', this.removeAtRatio);
}, },
@ -201,5 +230,5 @@ Deluge.preferences.Queue = Ext.extend(Ext.form.FormPanel, {
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

@ -6,8 +6,8 @@ Ext.ux.JSLoader = function(options) {
options: options, options: options,
onLoad: options.onLoad || Ext.emptyFn, onLoad: options.onLoad || Ext.emptyFn,
onError: options.onError || Ext.ux.JSLoader.stdError, onError: options.onError || Ext.ux.JSLoader.stdError,
scope: options.scope || this scope: options.scope || this,
}; };
Ext.Ajax.request({ Ext.Ajax.request({
url: options.url, url: options.url,
@ -16,9 +16,9 @@ Ext.ux.JSLoader = function(options) {
var script = Ext.ux.JSLoader.scripts[options.scriptIndex]; var script = Ext.ux.JSLoader.scripts[options.scriptIndex];
try { try {
eval(response.responseText); eval(response.responseText);
} catch(e) { } catch (e) {
script.success = false; script.success = false;
script.onError(script.options, e); script.onError(script.options, e);
} }
if (script.success) { if (script.success) {
script.onLoad.call(script.scope, script.options); script.onLoad.call(script.scope, script.options);
@ -28,11 +28,13 @@ Ext.ux.JSLoader = function(options) {
var script = Ext.ux.JSLoader.scripts[options.scriptIndex]; var script = Ext.ux.JSLoader.scripts[options.scriptIndex];
script.success = false; script.success = false;
script.onError(script.options, response.status); script.onError(script.options, response.status);
} },
}); });
}; };
Ext.ux.JSLoader.index = 0; Ext.ux.JSLoader.index = 0;
Ext.ux.JSLoader.scripts = []; Ext.ux.JSLoader.scripts = [];
Ext.ux.JSLoader.stdError = function(options, e) { Ext.ux.JSLoader.stdError = function(options, e) {
window.alert('Error loading script:\n\n' + options.url + '\n\nstatus: ' + e); window.alert(
'Error loading script:\n\n' + options.url + '\n\nstatus: ' + e
);
}; };

View File

@ -18,13 +18,13 @@ Ext.ux.Spinner = Ext.extend(Ext.util.Observable, {
defaultValue: 0, defaultValue: 0,
accelerate: false, accelerate: false,
constructor: function(config){ constructor: function(config) {
Ext.ux.Spinner.superclass.constructor.call(this, config); Ext.ux.Spinner.superclass.constructor.call(this, config);
Ext.apply(this, config); Ext.apply(this, config);
this.mimicing = false; this.mimicing = false;
}, },
init: function(field){ init: function(field) {
this.field = field; this.field = field;
field.afterMethod('onRender', this.doRender, this); field.afterMethod('onRender', this.doRender, this);
@ -36,23 +36,22 @@ Ext.ux.Spinner = Ext.extend(Ext.util.Observable, {
field.beforeMethod('onDestroy', this.doDestroy, this); field.beforeMethod('onDestroy', this.doDestroy, this);
}, },
doRender: function(ct, position){ doRender: function(ct, position) {
var el = this.el = this.field.getEl(); var el = (this.el = this.field.getEl());
var f = this.field; var f = this.field;
if (!f.wrap) { if (!f.wrap) {
f.wrap = this.wrap = el.wrap({ f.wrap = this.wrap = el.wrap({
cls: "x-form-field-wrap" cls: 'x-form-field-wrap',
}); });
} } else {
else {
this.wrap = f.wrap.addClass('x-form-field-wrap'); this.wrap = f.wrap.addClass('x-form-field-wrap');
} }
this.trigger = this.wrap.createChild({ this.trigger = this.wrap.createChild({
tag: "img", tag: 'img',
src: Ext.BLANK_IMAGE_URL, src: Ext.BLANK_IMAGE_URL,
cls: "x-form-trigger " + this.triggerClass cls: 'x-form-trigger ' + this.triggerClass,
}); });
if (!f.width) { if (!f.width) {
@ -62,24 +61,27 @@ Ext.ux.Spinner = Ext.extend(Ext.util.Observable, {
this.splitter = this.wrap.createChild({ this.splitter = this.wrap.createChild({
tag: 'div', tag: 'div',
cls: this.splitterClass, cls: this.splitterClass,
style: 'width:13px; height:2px;' style: 'width:13px; height:2px;',
}); });
this.splitter.setRight((Ext.isIE) ? 1 : 2).setTop(10).show(); this.splitter
.setRight(Ext.isIE ? 1 : 2)
.setTop(10)
.show();
this.proxy = this.trigger.createProxy('', this.splitter, true); this.proxy = this.trigger.createProxy('', this.splitter, true);
this.proxy.addClass("x-form-spinner-proxy"); this.proxy.addClass('x-form-spinner-proxy');
this.proxy.setStyle('left', '0px'); this.proxy.setStyle('left', '0px');
this.proxy.setSize(14, 1); this.proxy.setSize(14, 1);
this.proxy.hide(); this.proxy.hide();
this.dd = new Ext.dd.DDProxy(this.splitter.dom.id, "SpinnerDrag", { this.dd = new Ext.dd.DDProxy(this.splitter.dom.id, 'SpinnerDrag', {
dragElId: this.proxy.id dragElId: this.proxy.id,
}); });
this.initTrigger(); this.initTrigger();
this.initSpinner(); this.initSpinner();
}, },
doAfterRender: function(){ doAfterRender: function() {
var y; var y;
if (Ext.isIE && this.el.getY() != (y = this.trigger.getY())) { if (Ext.isIE && this.el.getY() != (y = this.trigger.getY())) {
this.el.position(); this.el.position();
@ -87,104 +89,113 @@ Ext.ux.Spinner = Ext.extend(Ext.util.Observable, {
} }
}, },
doEnable: function(){ doEnable: function() {
if (this.wrap) { if (this.wrap) {
this.disabled = false; this.disabled = false;
this.wrap.removeClass(this.field.disabledClass); this.wrap.removeClass(this.field.disabledClass);
} }
}, },
doDisable: function(){ doDisable: function() {
if (this.wrap) { if (this.wrap) {
this.disabled = true; this.disabled = true;
this.wrap.addClass(this.field.disabledClass); this.wrap.addClass(this.field.disabledClass);
this.el.removeClass(this.field.disabledClass); this.el.removeClass(this.field.disabledClass);
} }
}, },
doResize: function(w, h){ doResize: function(w, h) {
if (typeof w == 'number') { if (typeof w == 'number') {
this.el.setWidth(w - this.trigger.getWidth()); this.el.setWidth(w - this.trigger.getWidth());
} }
this.wrap.setWidth(this.el.getWidth() + this.trigger.getWidth()); this.wrap.setWidth(this.el.getWidth() + this.trigger.getWidth());
}, },
doFocus: function(){ doFocus: function() {
if (!this.mimicing) { if (!this.mimicing) {
this.wrap.addClass('x-trigger-wrap-focus'); this.wrap.addClass('x-trigger-wrap-focus');
this.mimicing = true; this.mimicing = true;
Ext.get(Ext.isIE ? document.body : document).on("mousedown", this.mimicBlur, this, { Ext.get(Ext.isIE ? document.body : document).on(
delay: 10 'mousedown',
}); this.mimicBlur,
this,
{
delay: 10,
}
);
this.el.on('keydown', this.checkTab, this); this.el.on('keydown', this.checkTab, this);
} }
}, },
// private // private
checkTab: function(e){ checkTab: function(e) {
if (e.getKey() == e.TAB) { if (e.getKey() == e.TAB) {
this.triggerBlur(); this.triggerBlur();
} }
}, },
// private // private
mimicBlur: function(e){ mimicBlur: function(e) {
if (!this.wrap.contains(e.target) && this.field.validateBlur(e)) { if (!this.wrap.contains(e.target) && this.field.validateBlur(e)) {
this.triggerBlur(); this.triggerBlur();
} }
}, },
// private // private
triggerBlur: function(){ triggerBlur: function() {
this.mimicing = false; this.mimicing = false;
Ext.get(Ext.isIE ? document.body : document).un("mousedown", this.mimicBlur, this); Ext.get(Ext.isIE ? document.body : document).un(
this.el.un("keydown", this.checkTab, this); 'mousedown',
this.mimicBlur,
this
);
this.el.un('keydown', this.checkTab, this);
this.field.beforeBlur(); this.field.beforeBlur();
this.wrap.removeClass('x-trigger-wrap-focus'); this.wrap.removeClass('x-trigger-wrap-focus');
this.field.onBlur.call(this.field); this.field.onBlur.call(this.field);
}, },
initTrigger: function(){ initTrigger: function() {
this.trigger.addClassOnOver('x-form-trigger-over'); this.trigger.addClassOnOver('x-form-trigger-over');
this.trigger.addClassOnClick('x-form-trigger-click'); this.trigger.addClassOnClick('x-form-trigger-click');
}, },
initSpinner: function(){ initSpinner: function() {
this.field.addEvents({ this.field.addEvents({
'spin': true, spin: true,
'spinup': true, spinup: true,
'spindown': true spindown: true,
}); });
this.keyNav = new Ext.KeyNav(this.el, { this.keyNav = new Ext.KeyNav(this.el, {
"up": function(e){ up: function(e) {
e.preventDefault(); e.preventDefault();
this.onSpinUp(); this.onSpinUp();
}, },
"down": function(e){ down: function(e) {
e.preventDefault(); e.preventDefault();
this.onSpinDown(); this.onSpinDown();
}, },
"pageUp": function(e){ pageUp: function(e) {
e.preventDefault(); e.preventDefault();
this.onSpinUpAlternate(); this.onSpinUpAlternate();
}, },
"pageDown": function(e){ pageDown: function(e) {
e.preventDefault(); e.preventDefault();
this.onSpinDownAlternate(); this.onSpinDownAlternate();
}, },
scope: this scope: this,
}); });
this.repeater = new Ext.util.ClickRepeater(this.trigger, { this.repeater = new Ext.util.ClickRepeater(this.trigger, {
accelerate: this.accelerate accelerate: this.accelerate,
}); });
this.field.mon(this.repeater, "click", this.onTriggerClick, this, { this.field.mon(this.repeater, 'click', this.onTriggerClick, this, {
preventDefault: true preventDefault: true,
}); });
this.field.mon(this.trigger, { this.field.mon(this.trigger, {
@ -194,10 +205,10 @@ Ext.ux.Spinner = Ext.extend(Ext.util.Observable, {
mousedown: this.onMouseDown, mousedown: this.onMouseDown,
mouseup: this.onMouseUp, mouseup: this.onMouseUp,
scope: this, scope: this,
preventDefault: true preventDefault: true,
}); });
this.field.mon(this.wrap, "mousewheel", this.handleMouseWheel, this); this.field.mon(this.wrap, 'mousewheel', this.handleMouseWheel, this);
this.dd.setXConstraint(0, 0, 10); this.dd.setXConstraint(0, 0, 10);
this.dd.setYConstraint(1500, 1500, 10); this.dd.setYConstraint(1500, 1500, 10);
@ -206,67 +217,77 @@ Ext.ux.Spinner = Ext.extend(Ext.util.Observable, {
this.dd.onDrag = this.onDrag.createDelegate(this); this.dd.onDrag = this.onDrag.createDelegate(this);
}, },
onMouseOver: function(){ onMouseOver: function() {
if (this.disabled) { if (this.disabled) {
return; return;
} }
var middle = this.getMiddle(); var middle = this.getMiddle();
this.tmpHoverClass = (Ext.EventObject.getPageY() < middle) ? 'x-form-spinner-overup' : 'x-form-spinner-overdown'; this.tmpHoverClass =
Ext.EventObject.getPageY() < middle
? 'x-form-spinner-overup'
: 'x-form-spinner-overdown';
this.trigger.addClass(this.tmpHoverClass); this.trigger.addClass(this.tmpHoverClass);
}, },
//private //private
onMouseOut: function(){ onMouseOut: function() {
this.trigger.removeClass(this.tmpHoverClass); this.trigger.removeClass(this.tmpHoverClass);
}, },
//private //private
onMouseMove: function(){ onMouseMove: function() {
if (this.disabled) { if (this.disabled) {
return; return;
} }
var middle = this.getMiddle(); var middle = this.getMiddle();
if (((Ext.EventObject.getPageY() > middle) && this.tmpHoverClass == "x-form-spinner-overup") || if (
((Ext.EventObject.getPageY() < middle) && this.tmpHoverClass == "x-form-spinner-overdown")) { (Ext.EventObject.getPageY() > middle &&
this.tmpHoverClass == 'x-form-spinner-overup') ||
(Ext.EventObject.getPageY() < middle &&
this.tmpHoverClass == 'x-form-spinner-overdown')
) {
} }
}, },
//private //private
onMouseDown: function(){ onMouseDown: function() {
if (this.disabled) { if (this.disabled) {
return; return;
} }
var middle = this.getMiddle(); var middle = this.getMiddle();
this.tmpClickClass = (Ext.EventObject.getPageY() < middle) ? 'x-form-spinner-clickup' : 'x-form-spinner-clickdown'; this.tmpClickClass =
Ext.EventObject.getPageY() < middle
? 'x-form-spinner-clickup'
: 'x-form-spinner-clickdown';
this.trigger.addClass(this.tmpClickClass); this.trigger.addClass(this.tmpClickClass);
}, },
//private //private
onMouseUp: function(){ onMouseUp: function() {
this.trigger.removeClass(this.tmpClickClass); this.trigger.removeClass(this.tmpClickClass);
}, },
//private //private
onTriggerClick: function(){ onTriggerClick: function() {
if (this.disabled || this.el.dom.readOnly) { if (this.disabled || this.el.dom.readOnly) {
return; return;
} }
var middle = this.getMiddle(); var middle = this.getMiddle();
var ud = (Ext.EventObject.getPageY() < middle) ? 'Up' : 'Down'; var ud = Ext.EventObject.getPageY() < middle ? 'Up' : 'Down';
this['onSpin' + ud](); this['onSpin' + ud]();
}, },
//private //private
getMiddle: function(){ getMiddle: function() {
var t = this.trigger.getTop(); var t = this.trigger.getTop();
var h = this.trigger.getHeight(); var h = this.trigger.getHeight();
var middle = t + (h / 2); var middle = t + h / 2;
return middle; return middle;
}, },
//private //private
//checks if control is allowed to spin //checks if control is allowed to spin
isSpinnable: function(){ isSpinnable: function() {
if (this.disabled || this.el.dom.readOnly) { if (this.disabled || this.el.dom.readOnly) {
Ext.EventObject.preventDefault(); //prevent scrolling when disabled/readonly Ext.EventObject.preventDefault(); //prevent scrolling when disabled/readonly
return false; return false;
@ -274,7 +295,7 @@ Ext.ux.Spinner = Ext.extend(Ext.util.Observable, {
return true; return true;
}, },
handleMouseWheel: function(e){ handleMouseWheel: function(e) {
//disable scrolling when not focused //disable scrolling when not focused
if (this.wrap.hasClass('x-trigger-wrap-focus') == false) { if (this.wrap.hasClass('x-trigger-wrap-focus') == false) {
return; return;
@ -284,27 +305,25 @@ Ext.ux.Spinner = Ext.extend(Ext.util.Observable, {
if (delta > 0) { if (delta > 0) {
this.onSpinUp(); this.onSpinUp();
e.stopEvent(); e.stopEvent();
} else if (delta < 0) {
this.onSpinDown();
e.stopEvent();
} }
else
if (delta < 0) {
this.onSpinDown();
e.stopEvent();
}
}, },
//private //private
startDrag: function(){ startDrag: function() {
this.proxy.show(); this.proxy.show();
this._previousY = Ext.fly(this.dd.getDragEl()).getTop(); this._previousY = Ext.fly(this.dd.getDragEl()).getTop();
}, },
//private //private
endDrag: function(){ endDrag: function() {
this.proxy.hide(); this.proxy.hide();
}, },
//private //private
onDrag: function(){ onDrag: function() {
if (this.disabled) { if (this.disabled) {
return; return;
} }
@ -325,68 +344,69 @@ Ext.ux.Spinner = Ext.extend(Ext.util.Observable, {
}, },
//private //private
onSpinUp: function(){ onSpinUp: function() {
if (this.isSpinnable() == false) { if (this.isSpinnable() == false) {
return; return;
} }
if (Ext.EventObject.shiftKey == true) { if (Ext.EventObject.shiftKey == true) {
this.onSpinUpAlternate(); this.onSpinUpAlternate();
return; return;
} } else {
else {
this.spin(false, false); this.spin(false, false);
} }
this.field.fireEvent("spin", this); this.field.fireEvent('spin', this);
this.field.fireEvent("spinup", this); this.field.fireEvent('spinup', this);
}, },
//private //private
onSpinDown: function(){ onSpinDown: function() {
if (this.isSpinnable() == false) { if (this.isSpinnable() == false) {
return; return;
} }
if (Ext.EventObject.shiftKey == true) { if (Ext.EventObject.shiftKey == true) {
this.onSpinDownAlternate(); this.onSpinDownAlternate();
return; return;
} } else {
else {
this.spin(true, false); this.spin(true, false);
} }
this.field.fireEvent("spin", this); this.field.fireEvent('spin', this);
this.field.fireEvent("spindown", this); this.field.fireEvent('spindown', this);
}, },
//private //private
onSpinUpAlternate: function(){ onSpinUpAlternate: function() {
if (this.isSpinnable() == false) { if (this.isSpinnable() == false) {
return; return;
} }
this.spin(false, true); this.spin(false, true);
this.field.fireEvent("spin", this); this.field.fireEvent('spin', this);
this.field.fireEvent("spinup", this); this.field.fireEvent('spinup', this);
}, },
//private //private
onSpinDownAlternate: function(){ onSpinDownAlternate: function() {
if (this.isSpinnable() == false) { if (this.isSpinnable() == false) {
return; return;
} }
this.spin(true, true); this.spin(true, true);
this.field.fireEvent("spin", this); this.field.fireEvent('spin', this);
this.field.fireEvent("spindown", this); this.field.fireEvent('spindown', this);
}, },
spin: function(down, alternate){ spin: function(down, alternate) {
var v = parseFloat(this.field.getValue()); var v = parseFloat(this.field.getValue());
var incr = (alternate == true) ? this.alternateIncrementValue : this.incrementValue; var incr =
(down == true) ? v -= incr : v += incr; alternate == true
? this.alternateIncrementValue
: this.incrementValue;
down == true ? (v -= incr) : (v += incr);
v = (isNaN(v)) ? this.defaultValue : v; v = isNaN(v) ? this.defaultValue : v;
v = this.fixBoundries(v); v = this.fixBoundries(v);
this.field.setRawValue(v); this.field.setRawValue(v);
}, },
fixBoundries: function(value){ fixBoundries: function(value) {
var v = value; var v = value;
if (this.field.minValue != undefined && v < this.field.minValue) { if (this.field.minValue != undefined && v < this.field.minValue) {
@ -400,15 +420,22 @@ Ext.ux.Spinner = Ext.extend(Ext.util.Observable, {
}, },
// private // private
fixPrecision: function(value){ fixPrecision: function(value) {
var nan = isNaN(value); var nan = isNaN(value);
if (!this.field.allowDecimals || this.field.decimalPrecision == -1 || nan || !value) { if (
!this.field.allowDecimals ||
this.field.decimalPrecision == -1 ||
nan ||
!value
) {
return nan ? '' : value; return nan ? '' : value;
} }
return parseFloat(parseFloat(value).toFixed(this.field.decimalPrecision)); return parseFloat(
parseFloat(value).toFixed(this.field.decimalPrecision)
);
}, },
doDestroy: function(){ doDestroy: function() {
if (this.trigger) { if (this.trigger) {
this.trigger.remove(); this.trigger.remove();
} }
@ -433,10 +460,14 @@ Ext.ux.Spinner = Ext.extend(Ext.util.Observable, {
if (this.repeater) { if (this.repeater) {
this.repeater.purgeListeners(); this.repeater.purgeListeners();
} }
if (this.mimicing){ if (this.mimicing) {
Ext.get(Ext.isIE ? document.body : document).un("mousedown", this.mimicBlur, this); Ext.get(Ext.isIE ? document.body : document).un(
'mousedown',
this.mimicBlur,
this
);
} }
} },
}); });
//backwards compat //backwards compat

View File

@ -137,7 +137,7 @@ sb.setStatus({
* @cfg {String} cls * @cfg {String} cls
* The base class applied to the containing element for this component on render (defaults to 'x-statusbar') * The base class applied to the containing element for this component on render (defaults to 'x-statusbar')
*/ */
cls : 'x-statusbar', cls: 'x-statusbar',
/** /**
* @cfg {String} busyIconCls * @cfg {String} busyIconCls
* The default <code>{@link #iconCls}</code> applied when calling * The default <code>{@link #iconCls}</code> applied when calling
@ -145,7 +145,7 @@ sb.setStatus({
* It can be overridden at any time by passing the <code>iconCls</code> * It can be overridden at any time by passing the <code>iconCls</code>
* argument into <code>{@link #showBusy}</code>. * argument into <code>{@link #showBusy}</code>.
*/ */
busyIconCls : 'x-status-busy', busyIconCls: 'x-status-busy',
/** /**
* @cfg {String} busyText * @cfg {String} busyText
* The default <code>{@link #text}</code> applied when calling * The default <code>{@link #text}</code> applied when calling
@ -153,7 +153,7 @@ sb.setStatus({
* It can be overridden at any time by passing the <code>text</code> * It can be overridden at any time by passing the <code>text</code>
* argument into <code>{@link #showBusy}</code>. * argument into <code>{@link #showBusy}</code>.
*/ */
busyText : 'Loading...', busyText: 'Loading...',
/** /**
* @cfg {Number} autoClear * @cfg {Number} autoClear
* The number of milliseconds to wait after setting the status via * The number of milliseconds to wait after setting the status via
@ -165,7 +165,7 @@ sb.setStatus({
* <code>{@link #setStatus}</code>. Calls to <code>{@link #clearStatus}</code> * <code>{@link #setStatus}</code>. Calls to <code>{@link #clearStatus}</code>
* always clear the status bar immediately and ignore this value. * always clear the status bar immediately and ignore this value.
*/ */
autoClear : 5000, autoClear: 5000,
/** /**
* @cfg {String} emptyText * @cfg {String} emptyText
@ -177,34 +177,34 @@ sb.setStatus({
* vertically when no text is specified and there are no other items in * vertically when no text is specified and there are no other items in
* the toolbar. * the toolbar.
*/ */
emptyText : '&nbsp;', emptyText: '&nbsp;',
// private // private
activeThreadId : 0, activeThreadId: 0,
// private // private
initComponent : function(){ initComponent: function() {
if(this.statusAlign=='right'){ if (this.statusAlign == 'right') {
this.cls += ' x-status-right'; this.cls += ' x-status-right';
} }
Ext.ux.StatusBar.superclass.initComponent.call(this); Ext.ux.StatusBar.superclass.initComponent.call(this);
}, },
// private // private
afterRender : function(){ afterRender: function() {
Ext.ux.StatusBar.superclass.afterRender.call(this); Ext.ux.StatusBar.superclass.afterRender.call(this);
var right = this.statusAlign == 'right'; var right = this.statusAlign == 'right';
this.currIconCls = this.iconCls || this.defaultIconCls; this.currIconCls = this.iconCls || this.defaultIconCls;
this.statusEl = new Ext.Toolbar.TextItem({ this.statusEl = new Ext.Toolbar.TextItem({
cls: 'x-status-text ' + (this.currIconCls || ''), cls: 'x-status-text ' + (this.currIconCls || ''),
text: this.text || this.defaultText || '' text: this.text || this.defaultText || '',
}); });
if(right){ if (right) {
this.add('->'); this.add('->');
this.add(this.statusEl); this.add(this.statusEl);
}else{ } else {
this.insert(0, this.statusEl); this.insert(0, this.statusEl);
this.insert(1, '->'); this.insert(1, '->');
} }
@ -260,33 +260,33 @@ statusBar.setStatus({
</code></pre> </code></pre>
* @return {Ext.ux.StatusBar} this * @return {Ext.ux.StatusBar} this
*/ */
setStatus : function(o){ setStatus: function(o) {
o = o || {}; o = o || {};
if(typeof o == 'string'){ if (typeof o == 'string') {
o = {text:o}; o = { text: o };
} }
if(o.text !== undefined){ if (o.text !== undefined) {
this.setText(o.text); this.setText(o.text);
} }
if(o.iconCls !== undefined){ if (o.iconCls !== undefined) {
this.setIcon(o.iconCls); this.setIcon(o.iconCls);
} }
if(o.clear){ if (o.clear) {
var c = o.clear, var c = o.clear,
wait = this.autoClear, wait = this.autoClear,
defaults = {useDefaults: true, anim: true}; defaults = { useDefaults: true, anim: true };
if(typeof c == 'object'){ if (typeof c == 'object') {
c = Ext.applyIf(c, defaults); c = Ext.applyIf(c, defaults);
if(c.wait){ if (c.wait) {
wait = c.wait; wait = c.wait;
} }
}else if(typeof c == 'number'){ } else if (typeof c == 'number') {
wait = c; wait = c;
c = defaults; c = defaults;
}else if(typeof c == 'boolean'){ } else if (typeof c == 'boolean') {
c = defaults; c = defaults;
} }
@ -307,10 +307,10 @@ statusBar.setStatus({
* </ul> * </ul>
* @return {Ext.ux.StatusBar} this * @return {Ext.ux.StatusBar} this
*/ */
clearStatus : function(o){ clearStatus: function(o) {
o = o || {}; o = o || {};
if(o.threadId && o.threadId !== this.activeThreadId){ if (o.threadId && o.threadId !== this.activeThreadId) {
// this means the current call was made internally, but a newer // this means the current call was made internally, but a newer
// thread has set a message since this call was deferred. Since // thread has set a message since this call was deferred. Since
// we don't want to overwrite a newer message just ignore. // we don't want to overwrite a newer message just ignore.
@ -318,29 +318,33 @@ statusBar.setStatus({
} }
var text = o.useDefaults ? this.defaultText : this.emptyText, var text = o.useDefaults ? this.defaultText : this.emptyText,
iconCls = o.useDefaults ? (this.defaultIconCls ? this.defaultIconCls : '') : ''; iconCls = o.useDefaults
? this.defaultIconCls
? this.defaultIconCls
: ''
: '';
if(o.anim){ if (o.anim) {
// animate the statusEl Ext.Element // animate the statusEl Ext.Element
this.statusEl.el.fadeOut({ this.statusEl.el.fadeOut({
remove: false, remove: false,
useDisplay: true, useDisplay: true,
scope: this, scope: this,
callback: function(){ callback: function() {
this.setStatus({ this.setStatus({
text: text, text: text,
iconCls: iconCls iconCls: iconCls,
}); });
this.statusEl.el.show(); this.statusEl.el.show();
} },
}); });
}else{ } else {
// hide/show the el to avoid jumpy text or icon // hide/show the el to avoid jumpy text or icon
this.statusEl.hide(); this.statusEl.hide();
this.setStatus({ this.setStatus({
text: text, text: text,
iconCls: iconCls iconCls: iconCls,
}); });
this.statusEl.show(); this.statusEl.show();
} }
@ -352,10 +356,10 @@ statusBar.setStatus({
* @param {String} text (optional) The text to set (defaults to '') * @param {String} text (optional) The text to set (defaults to '')
* @return {Ext.ux.StatusBar} this * @return {Ext.ux.StatusBar} this
*/ */
setText : function(text){ setText: function(text) {
this.activeThreadId++; this.activeThreadId++;
this.text = text || ''; this.text = text || '';
if(this.rendered){ if (this.rendered) {
this.statusEl.setText(this.text); this.statusEl.setText(this.text);
} }
return this; return this;
@ -365,7 +369,7 @@ statusBar.setStatus({
* Returns the current status text. * Returns the current status text.
* @return {String} The status text * @return {String} The status text
*/ */
getText : function(){ getText: function() {
return this.text; return this.text;
}, },
@ -375,20 +379,20 @@ statusBar.setStatus({
* @param {String} iconCls (optional) The icon class to set (defaults to '', and any current icon class is removed) * @param {String} iconCls (optional) The icon class to set (defaults to '', and any current icon class is removed)
* @return {Ext.ux.StatusBar} this * @return {Ext.ux.StatusBar} this
*/ */
setIcon : function(cls){ setIcon: function(cls) {
this.activeThreadId++; this.activeThreadId++;
cls = cls || ''; cls = cls || '';
if(this.rendered){ if (this.rendered) {
if(this.currIconCls){ if (this.currIconCls) {
this.statusEl.removeClass(this.currIconCls); this.statusEl.removeClass(this.currIconCls);
this.currIconCls = null; this.currIconCls = null;
} }
if(cls.length > 0){ if (cls.length > 0) {
this.statusEl.addClass(cls); this.statusEl.addClass(cls);
this.currIconCls = cls; this.currIconCls = cls;
} }
}else{ } else {
this.currIconCls = cls; this.currIconCls = cls;
} }
return this; return this;
@ -404,15 +408,15 @@ statusBar.setStatus({
* {@link #busyIconCls} will be used in conjunction with all of the default options for {@link #setStatus}. * {@link #busyIconCls} will be used in conjunction with all of the default options for {@link #setStatus}.
* @return {Ext.ux.StatusBar} this * @return {Ext.ux.StatusBar} this
*/ */
showBusy : function(o){ showBusy: function(o) {
if(typeof o == 'string'){ if (typeof o == 'string') {
o = {text:o}; o = { text: o };
} }
o = Ext.applyIf(o || {}, { o = Ext.applyIf(o || {}, {
text: this.busyText, text: this.busyText,
iconCls: this.busyIconCls iconCls: this.busyIconCls,
}); });
return this.setStatus(o); return this.setStatus(o);
} },
}); });
Ext.reg('statusbar', Ext.ux.StatusBar); Ext.reg('statusbar', Ext.ux.StatusBar);

View File

@ -12,7 +12,7 @@ Ext.ns('Ext.ux.form');
* Creates a file upload field. * Creates a file upload field.
* @xtype fileuploadfield * @xtype fileuploadfield
*/ */
Ext.ux.form.FileUploadField = Ext.extend(Ext.form.TextField, { Ext.ux.form.FileUploadField = Ext.extend(Ext.form.TextField, {
/** /**
* @cfg {String} buttonText The button text to display on the upload button (defaults to * @cfg {String} buttonText The button text to display on the upload button (defaults to
* 'Browse...'). Note that if you supply a value for {@link #buttonCfg}, the buttonCfg.text * 'Browse...'). Note that if you supply a value for {@link #buttonCfg}, the buttonCfg.text
@ -43,7 +43,7 @@ Ext.ux.form.FileUploadField = Ext.extend(Ext.form.TextField, {
autoSize: Ext.emptyFn, autoSize: Ext.emptyFn,
// private // private
initComponent: function(){ initComponent: function() {
Ext.ux.form.FileUploadField.superclass.initComponent.call(this); Ext.ux.form.FileUploadField.superclass.initComponent.call(this);
this.addEvents( this.addEvents(
@ -59,23 +59,29 @@ Ext.ux.form.FileUploadField = Ext.extend(Ext.form.TextField, {
}, },
// private // private
onRender : function(ct, position){ onRender: function(ct, position) {
Ext.ux.form.FileUploadField.superclass.onRender.call(this, ct, position); Ext.ux.form.FileUploadField.superclass.onRender.call(
this,
ct,
position
);
this.wrap = this.el.wrap({cls:'x-form-field-wrap x-form-file-wrap'}); this.wrap = this.el.wrap({ cls: 'x-form-field-wrap x-form-file-wrap' });
this.el.addClass('x-form-file-text'); this.el.addClass('x-form-file-text');
this.el.dom.removeAttribute('name'); this.el.dom.removeAttribute('name');
this.createFileInput(); this.createFileInput();
var btnCfg = Ext.applyIf(this.buttonCfg || {}, { var btnCfg = Ext.applyIf(this.buttonCfg || {}, {
text: this.buttonText text: this.buttonText,
}); });
this.button = new Ext.Button(Ext.apply(btnCfg, { this.button = new Ext.Button(
renderTo: this.wrap, Ext.apply(btnCfg, {
cls: 'x-form-file-btn' + (btnCfg.iconCls ? ' x-btn-icon' : '') renderTo: this.wrap,
})); cls: 'x-form-file-btn' + (btnCfg.iconCls ? ' x-btn-icon' : ''),
})
);
if(this.buttonOnly){ if (this.buttonOnly) {
this.el.hide(); this.el.hide();
this.wrap.setWidth(this.button.getEl().getWidth()); this.wrap.setWidth(this.button.getEl().getWidth());
} }
@ -83,42 +89,50 @@ Ext.ux.form.FileUploadField = Ext.extend(Ext.form.TextField, {
this.bindListeners(); this.bindListeners();
this.resizeEl = this.positionEl = this.wrap; this.resizeEl = this.positionEl = this.wrap;
}, },
bindListeners: function(){ bindListeners: function() {
this.fileInput.on({ this.fileInput.on({
scope: this, scope: this,
mouseenter: function() { mouseenter: function() {
this.button.addClass(['x-btn-over','x-btn-focus']) this.button.addClass(['x-btn-over', 'x-btn-focus']);
}, },
mouseleave: function(){ mouseleave: function() {
this.button.removeClass(['x-btn-over','x-btn-focus','x-btn-click']) this.button.removeClass([
'x-btn-over',
'x-btn-focus',
'x-btn-click',
]);
}, },
mousedown: function(){ mousedown: function() {
this.button.addClass('x-btn-click') this.button.addClass('x-btn-click');
}, },
mouseup: function(){ mouseup: function() {
this.button.removeClass(['x-btn-over','x-btn-focus','x-btn-click']) this.button.removeClass([
'x-btn-over',
'x-btn-focus',
'x-btn-click',
]);
}, },
change: function(){ change: function() {
var v = this.fileInput.dom.value; var v = this.fileInput.dom.value;
this.setValue(v); this.setValue(v);
this.fireEvent('fileselected', this, v); this.fireEvent('fileselected', this, v);
} },
}); });
}, },
createFileInput : function() { createFileInput: function() {
this.fileInput = this.wrap.createChild({ this.fileInput = this.wrap.createChild({
id: this.getFileInputId(), id: this.getFileInputId(),
name: this.name||this.getId(), name: this.name || this.getId(),
cls: 'x-form-file', cls: 'x-form-file',
tag: 'input', tag: 'input',
type: 'file', type: 'file',
size: 1 size: 1,
}); });
}, },
reset : function(){ reset: function() {
if (this.rendered) { if (this.rendered) {
this.fileInput.remove(); this.fileInput.remove();
this.createFileInput(); this.createFileInput();
@ -128,54 +142,54 @@ Ext.ux.form.FileUploadField = Ext.extend(Ext.form.TextField, {
}, },
// private // private
getFileInputId: function(){ getFileInputId: function() {
return this.id + '-file'; return this.id + '-file';
}, },
// private // private
onResize : function(w, h){ onResize: function(w, h) {
Ext.ux.form.FileUploadField.superclass.onResize.call(this, w, h); Ext.ux.form.FileUploadField.superclass.onResize.call(this, w, h);
this.wrap.setWidth(w); this.wrap.setWidth(w);
if(!this.buttonOnly){ if (!this.buttonOnly) {
var w = this.wrap.getWidth() - this.button.getEl().getWidth() - this.buttonOffset; var w =
this.wrap.getWidth() -
this.button.getEl().getWidth() -
this.buttonOffset;
this.el.setWidth(w); this.el.setWidth(w);
} }
}, },
// private // private
onDestroy: function(){ onDestroy: function() {
Ext.ux.form.FileUploadField.superclass.onDestroy.call(this); Ext.ux.form.FileUploadField.superclass.onDestroy.call(this);
Ext.destroy(this.fileInput, this.button, this.wrap); Ext.destroy(this.fileInput, this.button, this.wrap);
}, },
onDisable: function(){ onDisable: function() {
Ext.ux.form.FileUploadField.superclass.onDisable.call(this); Ext.ux.form.FileUploadField.superclass.onDisable.call(this);
this.doDisable(true); this.doDisable(true);
}, },
onEnable: function(){ onEnable: function() {
Ext.ux.form.FileUploadField.superclass.onEnable.call(this); Ext.ux.form.FileUploadField.superclass.onEnable.call(this);
this.doDisable(false); this.doDisable(false);
}, },
// private // private
doDisable: function(disabled){ doDisable: function(disabled) {
this.fileInput.dom.disabled = disabled; this.fileInput.dom.disabled = disabled;
this.button.setDisabled(disabled); this.button.setDisabled(disabled);
}, },
// private
preFocus: Ext.emptyFn,
// private // private
preFocus : Ext.emptyFn, alignErrorIcon: function() {
// private
alignErrorIcon : function(){
this.errorIcon.alignTo(this.wrap, 'tl-tr', [2, 0]); this.errorIcon.alignTo(this.wrap, 'tl-tr', [2, 0]);
} },
}); });
Ext.reg('fileuploadfield', Ext.ux.form.FileUploadField); Ext.reg('fileuploadfield', Ext.ux.form.FileUploadField);

View File

@ -10,7 +10,6 @@
// Allow radiogroups to be treated as a single form element. // Allow radiogroups to be treated as a single form element.
Ext.override(Ext.form.RadioGroup, { Ext.override(Ext.form.RadioGroup, {
afterRender: function() { afterRender: function() {
this.items.each(function(i) { this.items.each(function(i) {
this.relayEvents(i, ['check']); this.relayEvents(i, ['check']);
@ -20,7 +19,7 @@ Ext.override(Ext.form.RadioGroup, {
delete this.value; delete this.value;
delete this.lazyValue; delete this.lazyValue;
} }
Ext.form.RadioGroup.superclass.afterRender.call(this) Ext.form.RadioGroup.superclass.afterRender.call(this);
}, },
getName: function() { getName: function() {
@ -39,11 +38,13 @@ Ext.override(Ext.form.RadioGroup, {
} }
this.items.each(function(item) { this.items.each(function(item) {
if (item.rendered) { if (item.rendered) {
var checked = (item.el.getValue() == String(v)); var checked = item.el.getValue() == String(v);
item.el.dom.checked = checked; item.el.dom.checked = checked;
item.el.dom.defaultChecked = checked; item.el.dom.defaultChecked = checked;
item.wrap[checked ? 'addClass' : 'removeClass'](item.checkedCls); item.wrap[checked ? 'addClass' : 'removeClass'](
item.checkedCls
);
} }
}); });
} },
}); });

View File

@ -20,39 +20,46 @@ Ext.ux.form.SpinnerField = Ext.extend(Ext.form.NumberField, {
adjustSize: Ext.BoxComponent.prototype.adjustSize, adjustSize: Ext.BoxComponent.prototype.adjustSize,
constructor: function(config) { constructor: function(config) {
var spinnerConfig = Ext.copyTo({}, config, 'incrementValue,alternateIncrementValue,accelerate,defaultValue,triggerClass,splitterClass'); var spinnerConfig = Ext.copyTo(
{},
config,
'incrementValue,alternateIncrementValue,accelerate,defaultValue,triggerClass,splitterClass'
);
var spl = this.spinner = new Ext.ux.Spinner(spinnerConfig); var spl = (this.spinner = new Ext.ux.Spinner(spinnerConfig));
var plugins = config.plugins var plugins = config.plugins
? (Ext.isArray(config.plugins) ? Ext.isArray(config.plugins)
? config.plugins.push(spl) ? config.plugins.push(spl)
: [config.plugins, spl]) : [config.plugins, spl]
: spl; : spl;
Ext.ux.form.SpinnerField.superclass.constructor.call(this, Ext.apply(config, {plugins: plugins})); Ext.ux.form.SpinnerField.superclass.constructor.call(
this,
Ext.apply(config, { plugins: plugins })
);
}, },
// private // private
getResizeEl: function(){ getResizeEl: function() {
return this.wrap; return this.wrap;
}, },
// private // private
getPositionEl: function(){ getPositionEl: function() {
return this.wrap; return this.wrap;
}, },
// private // private
alignErrorIcon: function(){ alignErrorIcon: function() {
if (this.wrap) { if (this.wrap) {
this.errorIcon.alignTo(this.wrap, 'tl-tr', [2, 0]); this.errorIcon.alignTo(this.wrap, 'tl-tr', [2, 0]);
} }
}, },
validateBlur: function(){ validateBlur: function() {
return true; return true;
} },
}); });
Ext.reg('spinnerfield', Ext.ux.form.SpinnerField); Ext.reg('spinnerfield', Ext.ux.form.SpinnerField);

View File

@ -9,5 +9,5 @@
*/ */
Ext.override(Ext.ux.form.SpinnerField, { Ext.override(Ext.ux.form.SpinnerField, {
onBlur: Ext.form.Field.prototype.onBlur onBlur: Ext.form.Field.prototype.onBlur,
}); });

View File

@ -13,7 +13,6 @@ Ext.ns('Ext.ux.form');
* *
*/ */
Ext.ux.form.SpinnerGroup = Ext.extend(Ext.form.CheckboxGroup, { Ext.ux.form.SpinnerGroup = Ext.extend(Ext.form.CheckboxGroup, {
// private // private
defaultType: 'spinnerfield', defaultType: 'spinnerfield',
anchor: '98%', anchor: '98%',
@ -24,52 +23,54 @@ Ext.ux.form.SpinnerGroup = Ext.extend(Ext.form.CheckboxGroup, {
colCfg: {}, colCfg: {},
// private // private
onRender : function(ct, position){ onRender: function(ct, position) {
if(!this.el){ if (!this.el) {
var panelCfg = { var panelCfg = {
cls: this.groupCls, cls: this.groupCls,
layout: 'column', layout: 'column',
border: false, border: false,
renderTo: ct renderTo: ct,
}; };
var colCfg = Ext.apply({ var colCfg = Ext.apply(
defaultType: this.defaultType, {
layout: 'form', defaultType: this.defaultType,
border: false, layout: 'form',
labelWidth: 60, border: false,
defaults: { labelWidth: 60,
hideLabel: true, defaults: {
anchor: '60%' hideLabel: true,
} anchor: '60%',
}, this.colCfg); },
},
if(this.items[0].items){ this.colCfg
);
if (this.items[0].items) {
// The container has standard ColumnLayout configs, so pass them in directly // The container has standard ColumnLayout configs, so pass them in directly
Ext.apply(panelCfg, { Ext.apply(panelCfg, {
layoutConfig: {columns: this.items.length}, layoutConfig: { columns: this.items.length },
defaults: this.defaults, defaults: this.defaults,
items: this.items items: this.items,
}); });
for(var i=0, len=this.items.length; i<len; i++){ for (var i = 0, len = this.items.length; i < len; i++) {
Ext.applyIf(this.items[i], colCfg); Ext.applyIf(this.items[i], colCfg);
}; }
} else {
}else{
// The container has field item configs, so we have to generate the column // The container has field item configs, so we have to generate the column
// panels first then move the items into the columns as needed. // panels first then move the items into the columns as needed.
var numCols, cols = []; var numCols,
cols = [];
if(typeof this.columns == 'string'){ // 'auto' so create a col per item if (typeof this.columns == 'string') {
// 'auto' so create a col per item
this.columns = this.items.length; this.columns = this.items.length;
} }
if(!Ext.isArray(this.columns)){ if (!Ext.isArray(this.columns)) {
var cs = []; var cs = [];
for(var i=0; i<this.columns; i++){ for (var i = 0; i < this.columns; i++) {
cs.push((100/this.columns)*.01); // distribute by even % cs.push((100 / this.columns) * 0.01); // distribute by even %
} }
this.columns = cs; this.columns = cs;
} }
@ -77,54 +78,60 @@ Ext.ux.form.SpinnerGroup = Ext.extend(Ext.form.CheckboxGroup, {
numCols = this.columns.length; numCols = this.columns.length;
// Generate the column configs with the correct width setting // Generate the column configs with the correct width setting
for(var i=0; i<numCols; i++){ for (var i = 0; i < numCols; i++) {
var cc = Ext.apply({items:[]}, colCfg); var cc = Ext.apply({ items: [] }, colCfg);
cc[this.columns[i] <= 1 ? 'columnWidth' : 'width'] = this.columns[i]; cc[
if(this.defaults){ this.columns[i] <= 1 ? 'columnWidth' : 'width'
cc.defaults = Ext.apply(cc.defaults || {}, this.defaults) ] = this.columns[i];
if (this.defaults) {
cc.defaults = Ext.apply(
cc.defaults || {},
this.defaults
);
} }
cols.push(cc); cols.push(cc);
}; }
// Distribute the original items into the columns // Distribute the original items into the columns
if(this.vertical){ if (this.vertical) {
var rows = Math.ceil(this.items.length / numCols), ri = 0; var rows = Math.ceil(this.items.length / numCols),
for(var i=0, len=this.items.length; i<len; i++){ ri = 0;
if(i>0 && i%rows==0){ for (var i = 0, len = this.items.length; i < len; i++) {
if (i > 0 && i % rows == 0) {
ri++; ri++;
} }
if(this.items[i].fieldLabel){ if (this.items[i].fieldLabel) {
this.items[i].hideLabel = false; this.items[i].hideLabel = false;
} }
cols[ri].items.push(this.items[i]); cols[ri].items.push(this.items[i]);
}; }
}else{ } else {
for(var i=0, len=this.items.length; i<len; i++){ for (var i = 0, len = this.items.length; i < len; i++) {
var ci = i % numCols; var ci = i % numCols;
if(this.items[i].fieldLabel){ if (this.items[i].fieldLabel) {
this.items[i].hideLabel = false; this.items[i].hideLabel = false;
} }
cols[ci].items.push(this.items[i]); cols[ci].items.push(this.items[i]);
}; }
} }
Ext.apply(panelCfg, { Ext.apply(panelCfg, {
layoutConfig: {columns: numCols}, layoutConfig: { columns: numCols },
items: cols items: cols,
}); });
} }
this.panel = new Ext.Panel(panelCfg); this.panel = new Ext.Panel(panelCfg);
this.el = this.panel.getEl(); this.el = this.panel.getEl();
if(this.forId && this.itemCls){ if (this.forId && this.itemCls) {
var l = this.el.up(this.itemCls).child('label', true); var l = this.el.up(this.itemCls).child('label', true);
if(l){ if (l) {
l.setAttribute('htmlFor', this.forId); l.setAttribute('htmlFor', this.forId);
} }
} }
var fields = this.panel.findBy(function(c){ var fields = this.panel.findBy(function(c) {
return c.isFormField; return c.isFormField;
}, this); }, this);
@ -156,7 +163,7 @@ Ext.ux.form.SpinnerGroup = Ext.extend(Ext.form.CheckboxGroup, {
this.fireEvent('change', this, this.getValue()); this.fireEvent('change', this, this.getValue());
}, },
initValue : Ext.emptyFn, initValue: Ext.emptyFn,
getValue: function() { getValue: function() {
var value = [this.items.getCount()]; var value = [this.items.getCount()];
@ -194,6 +201,6 @@ Ext.ux.form.SpinnerGroup = Ext.extend(Ext.form.CheckboxGroup, {
item.setRawValue(value[i]); item.setRawValue(value[i]);
}); });
} }
} },
}); });
Ext.reg('spinnergroup', Ext.ux.form.SpinnerGroup); Ext.reg('spinnergroup', Ext.ux.form.SpinnerGroup);

View File

@ -7,19 +7,18 @@
* the additional special exception to link portions of this program with the OpenSSL library. * the additional special exception to link portions of this program with the OpenSSL library.
* See LICENSE for more details. * See LICENSE for more details.
*/ */
Ext.namespace("Ext.ux.form"); Ext.namespace('Ext.ux.form');
/** /**
* Ext.ux.form.ToggleField class * Ext.ux.form.ToggleField class
* *
* @author Damien Churchill * @author Damien Churchill
* @version v0.1 * @version v0.1
* *
* @class Ext.ux.form.ToggleField * @class Ext.ux.form.ToggleField
* @extends Ext.form.TriggerField * @extends Ext.form.TriggerField
*/ */
Ext.ux.form.ToggleField = Ext.extend(Ext.form.Field, { Ext.ux.form.ToggleField = Ext.extend(Ext.form.Field, {
cls: 'x-toggle-field', cls: 'x-toggle-field',
initComponent: function() { initComponent: function() {
@ -29,7 +28,7 @@ Ext.ux.form.ToggleField = Ext.extend(Ext.form.Field, {
this.toggle.on('check', this.onToggleCheck, this); this.toggle.on('check', this.onToggleCheck, this);
this.input = new Ext.form.TextField({ this.input = new Ext.form.TextField({
disabled: true disabled: true,
}); });
}, },
@ -39,10 +38,10 @@ Ext.ux.form.ToggleField = Ext.extend(Ext.form.Field, {
cls: this.groupCls, cls: this.groupCls,
layout: 'table', layout: 'table',
layoutConfig: { layoutConfig: {
columns: 2 columns: 2,
}, },
border: false, border: false,
renderTo: ct renderTo: ct,
}); });
this.panel.ownerCt = this; this.panel.ownerCt = this;
this.el = this.panel.getEl(); this.el = this.panel.getEl();
@ -51,7 +50,10 @@ Ext.ux.form.ToggleField = Ext.extend(Ext.form.Field, {
this.panel.add(this.input); this.panel.add(this.input);
this.panel.doLayout(); this.panel.doLayout();
this.toggle.getEl().parent().setStyle('padding-right', '10px'); this.toggle
.getEl()
.parent()
.setStyle('padding-right', '10px');
} }
Ext.ux.form.ToggleField.superclass.onRender.call(this, ct, position); Ext.ux.form.ToggleField.superclass.onRender.call(this, ct, position);
}, },
@ -68,6 +70,6 @@ Ext.ux.form.ToggleField = Ext.extend(Ext.form.Field, {
onToggleCheck: function(toggle, checked) { onToggleCheck: function(toggle, checked) {
this.input.setDisabled(!checked); this.input.setDisabled(!checked);
} },
}); });
Ext.reg('togglefield', Ext.ux.form.ToggleField); Ext.reg('togglefield', Ext.ux.form.ToggleField);

View File

@ -46,7 +46,7 @@ Ext.ux.grid.BufferView = Ext.extend(Ext.grid.GridView, {
*/ */
cleanDelay: 500, cleanDelay: 500,
initTemplates : function(){ initTemplates: function() {
Ext.ux.grid.BufferView.superclass.initTemplates.call(this); Ext.ux.grid.BufferView.superclass.initTemplates.call(this);
var ts = this.templates; var ts = this.templates;
// empty div to act as a place holder for a row // empty div to act as a place holder for a row
@ -59,67 +59,80 @@ Ext.ux.grid.BufferView = Ext.extend(Ext.grid.GridView, {
ts.rowBody = new Ext.Template( ts.rowBody = new Ext.Template(
'<table class="x-grid3-row-table" border="0" cellspacing="0" cellpadding="0" style="{tstyle}">', '<table class="x-grid3-row-table" border="0" cellspacing="0" cellpadding="0" style="{tstyle}">',
'<tbody><tr>{cells}</tr>', '<tbody><tr>{cells}</tr>',
(this.enableRowBody ? '<tr class="x-grid3-row-body-tr" style="{bodyStyle}"><td colspan="{cols}" class="x-grid3-body-cell" tabIndex="0" hidefocus="on"><div class="x-grid3-row-body">{body}</div></td></tr>' : ''), this.enableRowBody
? '<tr class="x-grid3-row-body-tr" style="{bodyStyle}"><td colspan="{cols}" class="x-grid3-body-cell" tabIndex="0" hidefocus="on"><div class="x-grid3-row-body">{body}</div></td></tr>'
: '',
'</tbody></table>' '</tbody></table>'
); );
ts.rowBody.disableFormats = true; ts.rowBody.disableFormats = true;
ts.rowBody.compile(); ts.rowBody.compile();
}, },
getStyleRowHeight : function(){ getStyleRowHeight: function() {
return Ext.isBorderBox ? (this.rowHeight + this.borderHeight) : this.rowHeight; return Ext.isBorderBox
? this.rowHeight + this.borderHeight
: this.rowHeight;
}, },
getCalculatedRowHeight : function(){ getCalculatedRowHeight: function() {
return this.rowHeight + this.borderHeight; return this.rowHeight + this.borderHeight;
}, },
getVisibleRowCount : function(){ getVisibleRowCount: function() {
var rh = this.getCalculatedRowHeight(), var rh = this.getCalculatedRowHeight(),
visibleHeight = this.scroller.dom.clientHeight; visibleHeight = this.scroller.dom.clientHeight;
return (visibleHeight < 1) ? 0 : Math.ceil(visibleHeight / rh); return visibleHeight < 1 ? 0 : Math.ceil(visibleHeight / rh);
}, },
getVisibleRows: function(){ getVisibleRows: function() {
var count = this.getVisibleRowCount(), var count = this.getVisibleRowCount(),
sc = this.scroller.dom.scrollTop, sc = this.scroller.dom.scrollTop,
start = (sc === 0 ? 0 : Math.floor(sc/this.getCalculatedRowHeight())-1); start =
sc === 0
? 0
: Math.floor(sc / this.getCalculatedRowHeight()) - 1;
return { return {
first: Math.max(start, 0), first: Math.max(start, 0),
last: Math.min(start + count + 2, this.ds.getCount()-1) last: Math.min(start + count + 2, this.ds.getCount() - 1),
}; };
}, },
doRender : function(cs, rs, ds, startRow, colCount, stripe, onlyBody){ doRender: function(cs, rs, ds, startRow, colCount, stripe, onlyBody) {
var ts = this.templates, var ts = this.templates,
ct = ts.cell, ct = ts.cell,
rt = ts.row, rt = ts.row,
rb = ts.rowBody, rb = ts.rowBody,
last = colCount-1, last = colCount - 1,
rh = this.getStyleRowHeight(), rh = this.getStyleRowHeight(),
vr = this.getVisibleRows(), vr = this.getVisibleRows(),
tstyle = 'width:'+this.getTotalWidth()+';height:'+rh+'px;', tstyle = 'width:' + this.getTotalWidth() + ';height:' + rh + 'px;',
// buffers // buffers
buf = [], buf = [],
cb, cb,
c, c,
p = {}, p = {},
rp = {tstyle: tstyle}, rp = { tstyle: tstyle },
r; r;
for (var j = 0, len = rs.length; j < len; j++) { for (var j = 0, len = rs.length; j < len; j++) {
r = rs[j]; cb = []; r = rs[j];
var rowIndex = (j+startRow), cb = [];
var rowIndex = j + startRow,
visible = rowIndex >= vr.first && rowIndex <= vr.last; visible = rowIndex >= vr.first && rowIndex <= vr.last;
if (visible) { if (visible) {
for (var i = 0; i < colCount; i++) { for (var i = 0; i < colCount; i++) {
c = cs[i]; c = cs[i];
p.id = c.id; p.id = c.id;
p.css = i === 0 ? 'x-grid3-cell-first ' : (i == last ? 'x-grid3-cell-last ' : ''); p.css =
p.attr = p.cellAttr = ""; i === 0
? 'x-grid3-cell-first '
: i == last
? 'x-grid3-cell-last '
: '';
p.attr = p.cellAttr = '';
p.value = c.renderer(r.data[c.name], p, r, rowIndex, i, ds); p.value = c.renderer(r.data[c.name], p, r, rowIndex, i, ds);
p.style = c.style; p.style = c.style;
if (p.value === undefined || p.value === "") { if (p.value === undefined || p.value === '') {
p.value = "&#160;"; p.value = '&#160;';
} }
if (r.dirty && typeof r.modified[c.name] !== 'undefined') { if (r.dirty && typeof r.modified[c.name] !== 'undefined') {
p.css += ' x-grid3-dirty-cell'; p.css += ' x-grid3-dirty-cell';
@ -128,64 +141,76 @@ Ext.ux.grid.BufferView = Ext.extend(Ext.grid.GridView, {
} }
} }
var alt = []; var alt = [];
if(stripe && ((rowIndex+1) % 2 === 0)){ if (stripe && (rowIndex + 1) % 2 === 0) {
alt[0] = "x-grid3-row-alt"; alt[0] = 'x-grid3-row-alt';
} }
if(r.dirty){ if (r.dirty) {
alt[1] = " x-grid3-dirty-row"; alt[1] = ' x-grid3-dirty-row';
} }
rp.cols = colCount; rp.cols = colCount;
if(this.getRowClass){ if (this.getRowClass) {
alt[2] = this.getRowClass(r, rowIndex, rp, ds); alt[2] = this.getRowClass(r, rowIndex, rp, ds);
} }
rp.alt = alt.join(" "); rp.alt = alt.join(' ');
rp.cells = cb.join(""); rp.cells = cb.join('');
buf[buf.length] = !visible ? ts.rowHolder.apply(rp) : (onlyBody ? rb.apply(rp) : rt.apply(rp)); buf[buf.length] = !visible
? ts.rowHolder.apply(rp)
: onlyBody
? rb.apply(rp)
: rt.apply(rp);
} }
return buf.join(""); return buf.join('');
}, },
isRowRendered: function(index){ isRowRendered: function(index) {
var row = this.getRow(index); var row = this.getRow(index);
return row && row.childNodes.length > 0; return row && row.childNodes.length > 0;
}, },
syncScroll: function(){ syncScroll: function() {
Ext.ux.grid.BufferView.superclass.syncScroll.apply(this, arguments); Ext.ux.grid.BufferView.superclass.syncScroll.apply(this, arguments);
this.update(); this.update();
}, },
// a (optionally) buffered method to update contents of gridview // a (optionally) buffered method to update contents of gridview
update: function(){ update: function() {
if (this.scrollDelay) { if (this.scrollDelay) {
if (!this.renderTask) { if (!this.renderTask) {
this.renderTask = new Ext.util.DelayedTask(this.doUpdate, this); this.renderTask = new Ext.util.DelayedTask(this.doUpdate, this);
} }
this.renderTask.delay(this.scrollDelay); this.renderTask.delay(this.scrollDelay);
}else{ } else {
this.doUpdate(); this.doUpdate();
} }
}, },
onRemove : function(ds, record, index, isUpdate){ onRemove: function(ds, record, index, isUpdate) {
Ext.ux.grid.BufferView.superclass.onRemove.apply(this, arguments); Ext.ux.grid.BufferView.superclass.onRemove.apply(this, arguments);
if(isUpdate !== true){ if (isUpdate !== true) {
this.update(); this.update();
} }
}, },
doUpdate: function(){ doUpdate: function() {
if (this.getVisibleRowCount() > 0) { if (this.getVisibleRowCount() > 0) {
var g = this.grid, var g = this.grid,
cm = g.colModel, cm = g.colModel,
ds = g.store, ds = g.store,
cs = this.getColumnData(), cs = this.getColumnData(),
vr = this.getVisibleRows(), vr = this.getVisibleRows(),
row; row;
for (var i = vr.first; i <= vr.last; i++) { for (var i = vr.first; i <= vr.last; i++) {
// if row is NOT rendered and is visible, render it // if row is NOT rendered and is visible, render it
if(!this.isRowRendered(i) && (row = this.getRow(i))){ if (!this.isRowRendered(i) && (row = this.getRow(i))) {
var html = this.doRender(cs, [ds.getAt(i)], ds, i, cm.getColumnCount(), g.stripeRows, true); var html = this.doRender(
cs,
[ds.getAt(i)],
ds,
i,
cm.getColumnCount(),
g.stripeRows,
true
);
row.innerHTML = html; row.innerHTML = html;
} }
} }
@ -194,26 +219,27 @@ Ext.ux.grid.BufferView = Ext.extend(Ext.grid.GridView, {
}, },
// a buffered method to clean rows // a buffered method to clean rows
clean : function(){ clean: function() {
if(!this.cleanTask){ if (!this.cleanTask) {
this.cleanTask = new Ext.util.DelayedTask(this.doClean, this); this.cleanTask = new Ext.util.DelayedTask(this.doClean, this);
} }
this.cleanTask.delay(this.cleanDelay); this.cleanTask.delay(this.cleanDelay);
}, },
doClean: function(){ doClean: function() {
if (this.getVisibleRowCount() > 0) { if (this.getVisibleRowCount() > 0) {
var vr = this.getVisibleRows(); var vr = this.getVisibleRows();
vr.first -= this.cacheSize; vr.first -= this.cacheSize;
vr.last += this.cacheSize; vr.last += this.cacheSize;
var i = 0, rows = this.getRows(); var i = 0,
rows = this.getRows();
// if first is less than 0, all rows have been rendered // if first is less than 0, all rows have been rendered
// so lets clean the end... // so lets clean the end...
if(vr.first <= 0){ if (vr.first <= 0) {
i = vr.last + 1; i = vr.last + 1;
} }
for(var len = this.ds.getCount(); i < len; i++){ for (var len = this.ds.getCount(); i < len; i++) {
// if current row is outside of first and last and // if current row is outside of first and last and
// has content, update the innerHTML to nothing // has content, update the innerHTML to nothing
if ((i < vr.first || i > vr.last) && rows[i].innerHTML) { if ((i < vr.first || i > vr.last) && rows[i].innerHTML) {
@ -223,22 +249,22 @@ Ext.ux.grid.BufferView = Ext.extend(Ext.grid.GridView, {
} }
}, },
removeTask: function(name){ removeTask: function(name) {
var task = this[name]; var task = this[name];
if(task && task.cancel){ if (task && task.cancel) {
task.cancel(); task.cancel();
this[name] = null; this[name] = null;
} }
}, },
destroy : function(){ destroy: function() {
this.removeTask('cleanTask'); this.removeTask('cleanTask');
this.removeTask('renderTask'); this.removeTask('renderTask');
Ext.ux.grid.BufferView.superclass.destroy.call(this); Ext.ux.grid.BufferView.superclass.destroy.call(this);
}, },
layout: function(){ layout: function() {
Ext.ux.grid.BufferView.superclass.layout.call(this); Ext.ux.grid.BufferView.superclass.layout.call(this);
this.update(); this.update();
} },
}); });

View File

@ -12,23 +12,28 @@
// remove spaces for hidden elements and make show(), hide(), enable() and disable() act on // remove spaces for hidden elements and make show(), hide(), enable() and disable() act on
// the label. don't use hideLabel with this. // the label. don't use hideLabel with this.
Ext.override(Ext.layout.FormLayout, { Ext.override(Ext.layout.FormLayout, {
renderItem : function(c, position, target){ renderItem: function(c, position, target) {
if(c && !c.rendered && (c.isFormField || c.fieldLabel) && c.inputType != 'hidden'){ if (
c &&
!c.rendered &&
(c.isFormField || c.fieldLabel) &&
c.inputType != 'hidden'
) {
var args = this.getTemplateArgs(c); var args = this.getTemplateArgs(c);
if(typeof position == 'number'){ if (typeof position == 'number') {
position = target.dom.childNodes[position] || null; position = target.dom.childNodes[position] || null;
} }
if(position){ if (position) {
c.formItem = this.fieldTpl.insertBefore(position, args, true); c.formItem = this.fieldTpl.insertBefore(position, args, true);
}else{ } else {
c.formItem = this.fieldTpl.append(target, args, true); c.formItem = this.fieldTpl.append(target, args, true);
} }
c.actionMode = 'formItem'; c.actionMode = 'formItem';
c.render('x-form-el-'+c.id); c.render('x-form-el-' + c.id);
c.container = c.formItem; c.container = c.formItem;
c.actionMode = 'container'; c.actionMode = 'container';
}else { } else {
Ext.layout.FormLayout.superclass.renderItem.apply(this, arguments); Ext.layout.FormLayout.superclass.renderItem.apply(this, arguments);
} }
} },
}); });

View File

@ -13,8 +13,7 @@
* @author Damien Churchill <damoxc@gmail.com> * @author Damien Churchill <damoxc@gmail.com>
*/ */
Ext.override(Ext.tree.MultiSelectionModel, { Ext.override(Ext.tree.MultiSelectionModel, {
onNodeClick: function(node, e) {
onNodeClick: function (node, e) {
if (e.ctrlKey && this.isSelected(node)) { if (e.ctrlKey && this.isSelected(node)) {
this.unselect(node); this.unselect(node);
} else if (e.shiftKey && !this.isSelected(node)) { } else if (e.shiftKey && !this.isSelected(node)) {
@ -31,7 +30,7 @@ Ext.override(Ext.tree.MultiSelectionModel, {
// Swap the values if required // Swap the values if required
if (fi > li) { if (fi > li) {
fi = fi + li, li = fi - li, fi = fi - li; (fi = fi + li), (li = fi - li), (fi = fi - li);
} }
// Select all the nodes // Select all the nodes
@ -50,13 +49,13 @@ Ext.override(Ext.tree.MultiSelectionModel, {
}, },
select: function(node, e, keepExisting, suppressEvent) { select: function(node, e, keepExisting, suppressEvent) {
if(keepExisting !== true){ if (keepExisting !== true) {
this.clearSelections(true); this.clearSelections(true);
} }
if(this.isSelected(node)){ if (this.isSelected(node)) {
this.lastSelNode = node; this.lastSelNode = node;
return node; return node;
} }
this.selNodes.push(node); this.selNodes.push(node);
this.selMap[node.id] = node; this.selMap[node.id] = node;
this.lastSelNode = node; this.lastSelNode = node;
@ -65,6 +64,5 @@ Ext.override(Ext.tree.MultiSelectionModel, {
this.fireEvent('selectionchange', this, this.selNodes); this.fireEvent('selectionchange', this, this.selNodes);
} }
return node; return node;
} },
}); });

View File

@ -13,33 +13,33 @@ Ext.ns('Ext.ux.tree');
* @xtype treegrid * @xtype treegrid
*/ */
Ext.ux.tree.TreeGrid = Ext.extend(Ext.tree.TreePanel, { Ext.ux.tree.TreeGrid = Ext.extend(Ext.tree.TreePanel, {
rootVisible : false, rootVisible: false,
useArrows : true, useArrows: true,
lines : false, lines: false,
borderWidth : Ext.isBorderBox ? 0 : 2, // the combined left/right border for each cell borderWidth: Ext.isBorderBox ? 0 : 2, // the combined left/right border for each cell
cls : 'x-treegrid', cls: 'x-treegrid',
columnResize : true, columnResize: true,
enableSort : true, enableSort: true,
reserveScrollOffset : true, reserveScrollOffset: true,
enableHdMenu : true, enableHdMenu: true,
columnsText : 'Columns', columnsText: 'Columns',
initComponent : function() { initComponent: function() {
if(!this.root) { if (!this.root) {
this.root = new Ext.tree.AsyncTreeNode({text: 'Root'}); this.root = new Ext.tree.AsyncTreeNode({ text: 'Root' });
} }
// initialize the loader // initialize the loader
var l = this.loader; var l = this.loader;
if(!l){ if (!l) {
l = new Ext.ux.tree.TreeGridLoader({ l = new Ext.ux.tree.TreeGridLoader({
dataUrl: this.dataUrl, dataUrl: this.dataUrl,
requestMethod: this.requestMethod, requestMethod: this.requestMethod,
store: this.store store: this.store,
}); });
}else if(Ext.isObject(l) && !l.load){ } else if (Ext.isObject(l) && !l.load) {
l = new Ext.ux.tree.TreeGridLoader(l); l = new Ext.ux.tree.TreeGridLoader(l);
} }
this.loader = l; this.loader = l;
@ -48,63 +48,77 @@ Ext.ux.tree.TreeGrid = Ext.extend(Ext.tree.TreePanel, {
this.initColumns(); this.initColumns();
if(this.enableSort) { if (this.enableSort) {
this.treeGridSorter = new Ext.ux.tree.TreeGridSorter(this, this.enableSort); this.treeGridSorter = new Ext.ux.tree.TreeGridSorter(
this,
this.enableSort
);
} }
if(this.columnResize){ if (this.columnResize) {
this.colResizer = new Ext.tree.ColumnResizer(this.columnResize); this.colResizer = new Ext.tree.ColumnResizer(this.columnResize);
this.colResizer.init(this); this.colResizer.init(this);
} }
var c = this.columns; var c = this.columns;
if(!this.internalTpl){ if (!this.internalTpl) {
this.internalTpl = new Ext.XTemplate( this.internalTpl = new Ext.XTemplate(
'<div class="x-grid3-header">', '<div class="x-grid3-header">',
'<div class="x-treegrid-header-inner">', '<div class="x-treegrid-header-inner">',
'<div class="x-grid3-header-offset">', '<div class="x-grid3-header-offset">',
'<table style="table-layout: fixed;" cellspacing="0" cellpadding="0" border="0"><colgroup><tpl for="columns"><col /></tpl></colgroup>', '<table style="table-layout: fixed;" cellspacing="0" cellpadding="0" border="0"><colgroup><tpl for="columns"><col /></tpl></colgroup>',
'<thead><tr class="x-grid3-hd-row">', '<thead><tr class="x-grid3-hd-row">',
'<tpl for="columns">', '<tpl for="columns">',
'<td class="x-grid3-hd x-grid3-cell x-treegrid-hd" style="text-align: {align};" id="', this.id, '-xlhd-{#}">', '<td class="x-grid3-hd x-grid3-cell x-treegrid-hd" style="text-align: {align};" id="',
'<div class="x-grid3-hd-inner x-treegrid-hd-inner" unselectable="on">', this.id,
this.enableHdMenu ? '<a class="x-grid3-hd-btn" href="#"></a>' : '', '-xlhd-{#}">',
'{header}<img class="x-grid3-sort-icon" src="', Ext.BLANK_IMAGE_URL, '" />', '<div class="x-grid3-hd-inner x-treegrid-hd-inner" unselectable="on">',
'</div>', this.enableHdMenu
'</td></tpl>', ? '<a class="x-grid3-hd-btn" href="#"></a>'
'</tr></thead>', : '',
'</table>', '{header}<img class="x-grid3-sort-icon" src="',
'</div></div>', Ext.BLANK_IMAGE_URL,
'" />',
'</div>',
'</td></tpl>',
'</tr></thead>',
'</table>',
'</div></div>',
'</div>', '</div>',
'<div class="x-treegrid-root-node">', '<div class="x-treegrid-root-node">',
'<table class="x-treegrid-root-table" cellpadding="0" cellspacing="0" style="table-layout: fixed;"></table>', '<table class="x-treegrid-root-table" cellpadding="0" cellspacing="0" style="table-layout: fixed;"></table>',
'</div>' '</div>'
); );
} }
if(!this.colgroupTpl) { if (!this.colgroupTpl) {
this.colgroupTpl = new Ext.XTemplate( this.colgroupTpl = new Ext.XTemplate(
'<colgroup><tpl for="columns"><col style="width: {width}px"/></tpl></colgroup>' '<colgroup><tpl for="columns"><col style="width: {width}px"/></tpl></colgroup>'
); );
} }
}, },
initColumns : function() { initColumns: function() {
var cs = this.columns, var cs = this.columns,
len = cs.length, len = cs.length,
columns = [], columns = [],
i, c; i,
c;
for(i = 0; i < len; i++){ for (i = 0; i < len; i++) {
c = cs[i]; c = cs[i];
if(!c.isColumn) { if (!c.isColumn) {
c.xtype = c.xtype ? (/^tg/.test(c.xtype) ? c.xtype : 'tg' + c.xtype) : 'tgcolumn'; c.xtype = c.xtype
? /^tg/.test(c.xtype)
? c.xtype
: 'tg' + c.xtype
: 'tgcolumn';
c = Ext.create(c); c = Ext.create(c);
} }
c.init(this); c.init(this);
columns.push(c); columns.push(c);
if(this.enableSort !== false && c.sortable !== false) { if (this.enableSort !== false && c.sortable !== false) {
c.sortable = true; c.sortable = true;
this.enableSort = true; this.enableSort = true;
} }
@ -113,69 +127,78 @@ Ext.ux.tree.TreeGrid = Ext.extend(Ext.tree.TreePanel, {
this.columns = columns; this.columns = columns;
}, },
onRender : function(){ onRender: function() {
Ext.tree.TreePanel.superclass.onRender.apply(this, arguments); Ext.tree.TreePanel.superclass.onRender.apply(this, arguments);
this.el.addClass('x-treegrid'); this.el.addClass('x-treegrid');
this.outerCt = this.body.createChild({ this.outerCt = this.body.createChild({
cls:'x-tree-root-ct x-treegrid-ct ' + (this.useArrows ? 'x-tree-arrows' : this.lines ? 'x-tree-lines' : 'x-tree-no-lines') cls:
'x-tree-root-ct x-treegrid-ct ' +
(this.useArrows
? 'x-tree-arrows'
: this.lines
? 'x-tree-lines'
: 'x-tree-no-lines'),
}); });
this.internalTpl.overwrite(this.outerCt, {columns: this.columns}); this.internalTpl.overwrite(this.outerCt, { columns: this.columns });
this.mainHd = Ext.get(this.outerCt.dom.firstChild); this.mainHd = Ext.get(this.outerCt.dom.firstChild);
this.innerHd = Ext.get(this.mainHd.dom.firstChild); this.innerHd = Ext.get(this.mainHd.dom.firstChild);
this.innerBody = Ext.get(this.outerCt.dom.lastChild); this.innerBody = Ext.get(this.outerCt.dom.lastChild);
this.innerCt = Ext.get(this.innerBody.dom.firstChild); this.innerCt = Ext.get(this.innerBody.dom.firstChild);
this.colgroupTpl.insertFirst(this.innerCt, {columns: this.columns}); this.colgroupTpl.insertFirst(this.innerCt, { columns: this.columns });
if(this.hideHeaders){ if (this.hideHeaders) {
this.el.child('.x-grid3-header').setDisplayed('none'); this.el.child('.x-grid3-header').setDisplayed('none');
} } else if (this.enableHdMenu !== false) {
else if(this.enableHdMenu !== false){ this.hmenu = new Ext.menu.Menu({ id: this.id + '-hctx' });
this.hmenu = new Ext.menu.Menu({id: this.id + '-hctx'}); if (this.enableColumnHide !== false) {
if(this.enableColumnHide !== false){ this.colMenu = new Ext.menu.Menu({
this.colMenu = new Ext.menu.Menu({id: this.id + '-hcols-menu'}); id: this.id + '-hcols-menu',
});
this.colMenu.on({ this.colMenu.on({
scope: this, scope: this,
beforeshow: this.beforeColMenuShow, beforeshow: this.beforeColMenuShow,
itemclick: this.handleHdMenuClick itemclick: this.handleHdMenuClick,
}); });
this.hmenu.add({ this.hmenu.add({
itemId:'columns', itemId: 'columns',
hideOnClick: false, hideOnClick: false,
text: this.columnsText, text: this.columnsText,
menu: this.colMenu, menu: this.colMenu,
iconCls: 'x-cols-icon' iconCls: 'x-cols-icon',
}); });
} }
this.hmenu.on('itemclick', this.handleHdMenuClick, this); this.hmenu.on('itemclick', this.handleHdMenuClick, this);
} }
}, },
setRootNode : function(node){ setRootNode: function(node) {
node.attributes.uiProvider = Ext.ux.tree.TreeGridRootNodeUI; node.attributes.uiProvider = Ext.ux.tree.TreeGridRootNodeUI;
node = Ext.ux.tree.TreeGrid.superclass.setRootNode.call(this, node); node = Ext.ux.tree.TreeGrid.superclass.setRootNode.call(this, node);
if(this.innerCt) { if (this.innerCt) {
this.colgroupTpl.insertFirst(this.innerCt, {columns: this.columns}); this.colgroupTpl.insertFirst(this.innerCt, {
columns: this.columns,
});
} }
return node; return node;
}, },
clearInnerCt : function(){ clearInnerCt: function() {
if(Ext.isIE){ if (Ext.isIE) {
var dom = this.innerCt.dom; var dom = this.innerCt.dom;
while(dom.firstChild){ while (dom.firstChild) {
dom.removeChild(dom.firstChild); dom.removeChild(dom.firstChild);
} }
}else{ } else {
Ext.ux.tree.TreeGrid.superclass.clearInnerCt.call(this); Ext.ux.tree.TreeGrid.superclass.clearInnerCt.call(this);
} }
}, },
initEvents : function() { initEvents: function() {
Ext.ux.tree.TreeGrid.superclass.initEvents.apply(this, arguments); Ext.ux.tree.TreeGrid.superclass.initEvents.apply(this, arguments);
this.mon(this.innerBody, 'scroll', this.syncScroll, this); this.mon(this.innerBody, 'scroll', this.syncScroll, this);
@ -183,100 +206,118 @@ Ext.ux.tree.TreeGrid = Ext.extend(Ext.tree.TreePanel, {
this.mon(this.mainHd, { this.mon(this.mainHd, {
scope: this, scope: this,
mouseover: this.handleHdOver, mouseover: this.handleHdOver,
mouseout: this.handleHdOut mouseout: this.handleHdOut,
}); });
}, },
onResize : function(w, h) { onResize: function(w, h) {
Ext.ux.tree.TreeGrid.superclass.onResize.apply(this, arguments); Ext.ux.tree.TreeGrid.superclass.onResize.apply(this, arguments);
var bd = this.innerBody.dom; var bd = this.innerBody.dom;
var hd = this.innerHd.dom; var hd = this.innerHd.dom;
if(!bd){ if (!bd) {
return; return;
} }
if(Ext.isNumber(h)){ if (Ext.isNumber(h)) {
bd.style.height = this.body.getHeight(true) - hd.offsetHeight + 'px'; bd.style.height =
this.body.getHeight(true) - hd.offsetHeight + 'px';
} }
if(Ext.isNumber(w)){ if (Ext.isNumber(w)) {
var sw = Ext.num(this.scrollOffset, Ext.getScrollBarWidth()); var sw = Ext.num(this.scrollOffset, Ext.getScrollBarWidth());
if(this.reserveScrollOffset || ((bd.offsetWidth - bd.clientWidth) > 10)){ if (
this.reserveScrollOffset ||
bd.offsetWidth - bd.clientWidth > 10
) {
this.setScrollOffset(sw); this.setScrollOffset(sw);
}else{ } else {
var me = this; var me = this;
setTimeout(function(){ setTimeout(function() {
me.setScrollOffset(bd.offsetWidth - bd.clientWidth > 10 ? sw : 0); me.setScrollOffset(
bd.offsetWidth - bd.clientWidth > 10 ? sw : 0
);
}, 10); }, 10);
} }
} }
}, },
updateColumnWidths : function() { updateColumnWidths: function() {
var cols = this.columns, var cols = this.columns,
colCount = cols.length, colCount = cols.length,
groups = this.outerCt.query('colgroup'), groups = this.outerCt.query('colgroup'),
groupCount = groups.length, groupCount = groups.length,
c, g, i, j; c,
g,
i,
j;
for(i = 0; i<colCount; i++) { for (i = 0; i < colCount; i++) {
c = cols[i]; c = cols[i];
for(j = 0; j<groupCount; j++) { for (j = 0; j < groupCount; j++) {
g = groups[j]; g = groups[j];
g.childNodes[i].style.width = (c.hidden ? 0 : c.width) + 'px'; g.childNodes[i].style.width = (c.hidden ? 0 : c.width) + 'px';
} }
} }
for(i = 0, groups = this.innerHd.query('td'), len = groups.length; i<len; i++) { for (
i = 0, groups = this.innerHd.query('td'), len = groups.length;
i < len;
i++
) {
c = Ext.fly(groups[i]); c = Ext.fly(groups[i]);
if(cols[i] && cols[i].hidden) { if (cols[i] && cols[i].hidden) {
c.addClass('x-treegrid-hd-hidden'); c.addClass('x-treegrid-hd-hidden');
} } else {
else {
c.removeClass('x-treegrid-hd-hidden'); c.removeClass('x-treegrid-hd-hidden');
} }
} }
var tcw = this.getTotalColumnWidth(); var tcw = this.getTotalColumnWidth();
Ext.fly(this.innerHd.dom.firstChild).setWidth(tcw + (this.scrollOffset || 0)); Ext.fly(this.innerHd.dom.firstChild).setWidth(
tcw + (this.scrollOffset || 0)
);
this.outerCt.select('table').setWidth(tcw); this.outerCt.select('table').setWidth(tcw);
this.syncHeaderScroll(); this.syncHeaderScroll();
}, },
getVisibleColumns : function() { getVisibleColumns: function() {
var columns = [], var columns = [],
cs = this.columns, cs = this.columns,
len = cs.length, len = cs.length,
i; i;
for(i = 0; i<len; i++) { for (i = 0; i < len; i++) {
if(!cs[i].hidden) { if (!cs[i].hidden) {
columns.push(cs[i]); columns.push(cs[i]);
} }
} }
return columns; return columns;
}, },
getTotalColumnWidth : function() { getTotalColumnWidth: function() {
var total = 0; var total = 0;
for(var i = 0, cs = this.getVisibleColumns(), len = cs.length; i<len; i++) { for (
var i = 0, cs = this.getVisibleColumns(), len = cs.length;
i < len;
i++
) {
total += cs[i].width; total += cs[i].width;
} }
return total; return total;
}, },
setScrollOffset : function(scrollOffset) { setScrollOffset: function(scrollOffset) {
this.scrollOffset = scrollOffset; this.scrollOffset = scrollOffset;
this.updateColumnWidths(); this.updateColumnWidths();
}, },
// private // private
handleHdDown : function(e, t){ handleHdDown: function(e, t) {
var hd = e.getTarget('.x-treegrid-hd'); var hd = e.getTarget('.x-treegrid-hd');
if(hd && Ext.fly(t).hasClass('x-grid3-hd-btn')){ if (hd && Ext.fly(t).hasClass('x-grid3-hd-btn')) {
var ms = this.hmenu.items, var ms = this.hmenu.items,
cs = this.columns, cs = this.columns,
index = this.findHeaderIndex(hd), index = this.findHeaderIndex(hd),
@ -289,22 +330,26 @@ Ext.ux.tree.TreeGrid = Ext.extend(Ext.tree.TreePanel, {
this.fireEvent('headerbuttonclick', ms, c, hd, index); this.fireEvent('headerbuttonclick', ms, c, hd, index);
this.hmenu.on('hide', function(){ this.hmenu.on(
Ext.fly(hd).removeClass('x-grid3-hd-menu-open'); 'hide',
}, this, {single:true}); function() {
Ext.fly(hd).removeClass('x-grid3-hd-menu-open');
},
this,
{ single: true }
);
this.hmenu.show(t, 'tl-bl?'); this.hmenu.show(t, 'tl-bl?');
} } else if (hd) {
else if(hd) {
var index = this.findHeaderIndex(hd); var index = this.findHeaderIndex(hd);
this.fireEvent('headerclick', this.columns[index], hd, index); this.fireEvent('headerclick', this.columns[index], hd, index);
} }
}, },
// private // private
handleHdOver : function(e, t){ handleHdOver: function(e, t) {
var hd = e.getTarget('.x-treegrid-hd'); var hd = e.getTarget('.x-treegrid-hd');
if(hd && !this.headersDisabled){ if (hd && !this.headersDisabled) {
index = this.findHeaderIndex(hd); index = this.findHeaderIndex(hd);
this.activeHdRef = t; this.activeHdRef = t;
this.activeHdIndex = index; this.activeHdIndex = index;
@ -312,27 +357,28 @@ Ext.ux.tree.TreeGrid = Ext.extend(Ext.tree.TreePanel, {
this.activeHdRegion = el.getRegion(); this.activeHdRegion = el.getRegion();
el.addClass('x-grid3-hd-over'); el.addClass('x-grid3-hd-over');
this.activeHdBtn = el.child('.x-grid3-hd-btn'); this.activeHdBtn = el.child('.x-grid3-hd-btn');
if(this.activeHdBtn){ if (this.activeHdBtn) {
this.activeHdBtn.dom.style.height = (hd.firstChild.offsetHeight-1)+'px'; this.activeHdBtn.dom.style.height =
hd.firstChild.offsetHeight - 1 + 'px';
} }
} }
}, },
// private // private
handleHdOut : function(e, t){ handleHdOut: function(e, t) {
var hd = e.getTarget('.x-treegrid-hd'); var hd = e.getTarget('.x-treegrid-hd');
if(hd && (!Ext.isIE || !e.within(hd, true))){ if (hd && (!Ext.isIE || !e.within(hd, true))) {
this.activeHdRef = null; this.activeHdRef = null;
Ext.fly(hd).removeClass('x-grid3-hd-over'); Ext.fly(hd).removeClass('x-grid3-hd-over');
hd.style.cursor = ''; hd.style.cursor = '';
} }
}, },
findHeaderIndex : function(hd){ findHeaderIndex: function(hd) {
hd = hd.dom || hd; hd = hd.dom || hd;
var cs = hd.parentNode.childNodes; var cs = hd.parentNode.childNodes;
for(var i = 0, c; c = cs[i]; i++){ for (var i = 0, c; (c = cs[i]); i++) {
if(c == hd){ if (c == hd) {
return i; return i;
} }
} }
@ -340,33 +386,43 @@ Ext.ux.tree.TreeGrid = Ext.extend(Ext.tree.TreePanel, {
}, },
// private // private
beforeColMenuShow : function(){ beforeColMenuShow: function() {
var cols = this.columns, var cols = this.columns,
colCount = cols.length, colCount = cols.length,
i, c; i,
c;
this.colMenu.removeAll(); this.colMenu.removeAll();
for(i = 1; i < colCount; i++){ for (i = 1; i < colCount; i++) {
c = cols[i]; c = cols[i];
if(c.hideable !== false){ if (c.hideable !== false) {
this.colMenu.add(new Ext.menu.CheckItem({ this.colMenu.add(
itemId: 'col-' + i, new Ext.menu.CheckItem({
text: c.header, itemId: 'col-' + i,
checked: !c.hidden, text: c.header,
hideOnClick:false, checked: !c.hidden,
disabled: c.hideable === false hideOnClick: false,
})); disabled: c.hideable === false,
})
);
} }
} }
}, },
// private // private
handleHdMenuClick : function(item){ handleHdMenuClick: function(item) {
var index = this.hdCtxIndex, var index = this.hdCtxIndex,
id = item.getItemId(); id = item.getItemId();
if(this.fireEvent('headermenuclick', this.columns[index], id, index) !== false) { if (
this.fireEvent(
'headermenuclick',
this.columns[index],
id,
index
) !== false
) {
index = id.substr(4); index = id.substr(4);
if(index > 0 && this.columns[index]) { if (index > 0 && this.columns[index]) {
this.setColumnVisible(index, !item.checked); this.setColumnVisible(index, !item.checked);
} }
} }
@ -374,7 +430,7 @@ Ext.ux.tree.TreeGrid = Ext.extend(Ext.tree.TreePanel, {
return true; return true;
}, },
setColumnVisible : function(index, visible) { setColumnVisible: function(index, visible) {
this.columns[index].hidden = !visible; this.columns[index].hidden = !visible;
this.updateColumnWidths(); this.updateColumnWidths();
}, },
@ -382,31 +438,31 @@ Ext.ux.tree.TreeGrid = Ext.extend(Ext.tree.TreePanel, {
/** /**
* Scrolls the grid to the top * Scrolls the grid to the top
*/ */
scrollToTop : function(){ scrollToTop: function() {
this.innerBody.dom.scrollTop = 0; this.innerBody.dom.scrollTop = 0;
this.innerBody.dom.scrollLeft = 0; this.innerBody.dom.scrollLeft = 0;
}, },
// private // private
syncScroll : function(){ syncScroll: function() {
this.syncHeaderScroll(); this.syncHeaderScroll();
var mb = this.innerBody.dom; var mb = this.innerBody.dom;
this.fireEvent('bodyscroll', mb.scrollLeft, mb.scrollTop); this.fireEvent('bodyscroll', mb.scrollLeft, mb.scrollTop);
}, },
// private // private
syncHeaderScroll : function(){ syncHeaderScroll: function() {
var mb = this.innerBody.dom; var mb = this.innerBody.dom;
this.innerHd.dom.scrollLeft = mb.scrollLeft; this.innerHd.dom.scrollLeft = mb.scrollLeft;
this.innerHd.dom.scrollLeft = mb.scrollLeft; // second time for IE (1/2 time first fails, other browsers ignore) this.innerHd.dom.scrollLeft = mb.scrollLeft; // second time for IE (1/2 time first fails, other browsers ignore)
}, },
registerNode : function(n) { registerNode: function(n) {
Ext.ux.tree.TreeGrid.superclass.registerNode.call(this, n); Ext.ux.tree.TreeGrid.superclass.registerNode.call(this, n);
if(!n.uiProvider && !n.isRoot && !n.ui.isTreeGridNodeUI) { if (!n.uiProvider && !n.isRoot && !n.ui.isTreeGridNodeUI) {
n.ui = new Ext.ux.tree.TreeGridNodeUI(n); n.ui = new Ext.ux.tree.TreeGridNodeUI(n);
} }
} },
}); });
Ext.reg('treegrid', Ext.ux.tree.TreeGrid); Ext.reg('treegrid', Ext.ux.tree.TreeGrid);

View File

@ -15,17 +15,17 @@ Ext.tree.ColumnResizer = Ext.extend(Ext.util.Observable, {
*/ */
minWidth: 14, minWidth: 14,
constructor: function(config){ constructor: function(config) {
Ext.apply(this, config); Ext.apply(this, config);
Ext.tree.ColumnResizer.superclass.constructor.call(this); Ext.tree.ColumnResizer.superclass.constructor.call(this);
}, },
init : function(tree){ init: function(tree) {
this.tree = tree; this.tree = tree;
tree.on('render', this.initEvents, this); tree.on('render', this.initEvents, this);
}, },
initEvents : function(tree){ initEvents: function(tree) {
tree.mon(tree.innerHd, 'mousemove', this.handleHdMove, this); tree.mon(tree.innerHd, 'mousemove', this.handleHdMove, this);
this.tracker = new Ext.dd.DragTracker({ this.tracker = new Ext.dd.DragTracker({
onBeforeStart: this.onBeforeStart.createDelegate(this), onBeforeStart: this.onBeforeStart.createDelegate(this),
@ -33,56 +33,56 @@ Ext.tree.ColumnResizer = Ext.extend(Ext.util.Observable, {
onDrag: this.onDrag.createDelegate(this), onDrag: this.onDrag.createDelegate(this),
onEnd: this.onEnd.createDelegate(this), onEnd: this.onEnd.createDelegate(this),
tolerance: 3, tolerance: 3,
autoStart: 300 autoStart: 300,
}); });
this.tracker.initEl(tree.innerHd); this.tracker.initEl(tree.innerHd);
tree.on('beforedestroy', this.tracker.destroy, this.tracker); tree.on('beforedestroy', this.tracker.destroy, this.tracker);
}, },
handleHdMove : function(e, t){ handleHdMove: function(e, t) {
var hw = 5, var hw = 5,
x = e.getPageX(), x = e.getPageX(),
hd = e.getTarget('.x-treegrid-hd', 3, true); hd = e.getTarget('.x-treegrid-hd', 3, true);
if(hd){ if (hd) {
var r = hd.getRegion(), var r = hd.getRegion(),
ss = hd.dom.style, ss = hd.dom.style,
pn = hd.dom.parentNode; pn = hd.dom.parentNode;
if(x - r.left <= hw && hd.dom !== pn.firstChild) { if (x - r.left <= hw && hd.dom !== pn.firstChild) {
var ps = hd.dom.previousSibling; var ps = hd.dom.previousSibling;
while(ps && Ext.fly(ps).hasClass('x-treegrid-hd-hidden')) { while (ps && Ext.fly(ps).hasClass('x-treegrid-hd-hidden')) {
ps = ps.previousSibling; ps = ps.previousSibling;
} }
if(ps) { if (ps) {
this.activeHd = Ext.get(ps); this.activeHd = Ext.get(ps);
ss.cursor = Ext.isWebKit ? 'e-resize' : 'col-resize'; ss.cursor = Ext.isWebKit ? 'e-resize' : 'col-resize';
} }
} else if(r.right - x <= hw) { } else if (r.right - x <= hw) {
var ns = hd.dom; var ns = hd.dom;
while(ns && Ext.fly(ns).hasClass('x-treegrid-hd-hidden')) { while (ns && Ext.fly(ns).hasClass('x-treegrid-hd-hidden')) {
ns = ns.previousSibling; ns = ns.previousSibling;
} }
if(ns) { if (ns) {
this.activeHd = Ext.get(ns); this.activeHd = Ext.get(ns);
ss.cursor = Ext.isWebKit ? 'w-resize' : 'col-resize'; ss.cursor = Ext.isWebKit ? 'w-resize' : 'col-resize';
} }
} else{ } else {
delete this.activeHd; delete this.activeHd;
ss.cursor = ''; ss.cursor = '';
} }
} }
}, },
onBeforeStart : function(e){ onBeforeStart: function(e) {
this.dragHd = this.activeHd; this.dragHd = this.activeHd;
return !!this.dragHd; return !!this.dragHd;
}, },
onStart : function(e){ onStart: function(e) {
this.dragHeadersDisabled = this.tree.headersDisabled; this.dragHeadersDisabled = this.tree.headersDisabled;
this.tree.headersDisabled = true; this.tree.headersDisabled = true;
this.proxy = this.tree.body.createChild({cls:'x-treegrid-resizer'}); this.proxy = this.tree.body.createChild({ cls: 'x-treegrid-resizer' });
this.proxy.setHeight(this.tree.body.getHeight()); this.proxy.setHeight(this.tree.body.getHeight());
var x = this.tracker.getXY()[0]; var x = this.tracker.getXY()[0];
@ -91,29 +91,33 @@ Ext.tree.ColumnResizer = Ext.extend(Ext.util.Observable, {
this.hdIndex = this.tree.findHeaderIndex(this.dragHd); this.hdIndex = this.tree.findHeaderIndex(this.dragHd);
this.proxy.setX(this.hdX); this.proxy.setX(this.hdX);
this.proxy.setWidth(x-this.hdX); this.proxy.setWidth(x - this.hdX);
this.maxWidth = this.tree.outerCt.getWidth() - this.tree.innerBody.translatePoints(this.hdX).left; this.maxWidth =
this.tree.outerCt.getWidth() -
this.tree.innerBody.translatePoints(this.hdX).left;
}, },
onDrag : function(e){ onDrag: function(e) {
var cursorX = this.tracker.getXY()[0]; var cursorX = this.tracker.getXY()[0];
this.proxy.setWidth((cursorX-this.hdX).constrain(this.minWidth, this.maxWidth)); this.proxy.setWidth(
(cursorX - this.hdX).constrain(this.minWidth, this.maxWidth)
);
}, },
onEnd : function(e){ onEnd: function(e) {
var nw = this.proxy.getWidth(), var nw = this.proxy.getWidth(),
tree = this.tree, tree = this.tree,
disabled = this.dragHeadersDisabled; disabled = this.dragHeadersDisabled;
this.proxy.remove(); this.proxy.remove();
delete this.dragHd; delete this.dragHd;
tree.columns[this.hdIndex].width = nw; tree.columns[this.hdIndex].width = nw;
tree.updateColumnWidths(); tree.updateColumnWidths();
setTimeout(function(){ setTimeout(function() {
tree.headersDisabled = disabled; tree.headersDisabled = disabled;
}, 100); }, 100);
} },
}); });

View File

@ -6,25 +6,26 @@
*/ */
(function() { (function() {
Ext.override(Ext.list.Column, { Ext.override(Ext.list.Column, {
init : function() { init: function() {
var types = Ext.data.Types, var types = Ext.data.Types,
st = this.sortType; st = this.sortType;
if(this.type){ if (this.type) {
if(Ext.isString(this.type)){ if (Ext.isString(this.type)) {
this.type = Ext.data.Types[this.type.toUpperCase()] || types.AUTO; this.type =
Ext.data.Types[this.type.toUpperCase()] || types.AUTO;
} }
}else{ } else {
this.type = types.AUTO; this.type = types.AUTO;
} }
// named sortTypes are supported, here we look them up // named sortTypes are supported, here we look them up
if(Ext.isString(st)){ if (Ext.isString(st)) {
this.sortType = Ext.data.SortTypes[st]; this.sortType = Ext.data.SortTypes[st];
}else if(Ext.isEmpty(st)){ } else if (Ext.isEmpty(st)) {
this.sortType = this.type.sortType; this.sortType = this.type.sortType;
} }
} },
}); });
Ext.tree.Column = Ext.extend(Ext.list.Column, {}); Ext.tree.Column = Ext.extend(Ext.list.Column, {});

View File

@ -9,10 +9,10 @@
* @extends Ext.tree.TreeLoader * @extends Ext.tree.TreeLoader
*/ */
Ext.ux.tree.TreeGridLoader = Ext.extend(Ext.tree.TreeLoader, { Ext.ux.tree.TreeGridLoader = Ext.extend(Ext.tree.TreeLoader, {
createNode : function(attr) { createNode: function(attr) {
if (!attr.uiProvider) { if (!attr.uiProvider) {
attr.uiProvider = Ext.ux.tree.TreeGridNodeUI; attr.uiProvider = Ext.ux.tree.TreeGridNodeUI;
} }
return Ext.tree.TreeLoader.prototype.createNode.call(this, attr); return Ext.tree.TreeLoader.prototype.createNode.call(this, attr);
} },
}); });

View File

@ -11,51 +11,93 @@
Ext.ux.tree.TreeGridNodeUI = Ext.extend(Ext.tree.TreeNodeUI, { Ext.ux.tree.TreeGridNodeUI = Ext.extend(Ext.tree.TreeNodeUI, {
isTreeGridNodeUI: true, isTreeGridNodeUI: true,
renderElements : function(n, a, targetNode, bulkRender){ renderElements: function(n, a, targetNode, bulkRender) {
var t = n.getOwnerTree(), var t = n.getOwnerTree(),
cols = t.columns, cols = t.columns,
c = cols[0], c = cols[0],
i, buf, len; i,
buf,
len;
this.indentMarkup = n.parentNode ? n.parentNode.ui.getChildIndent() : ''; this.indentMarkup = n.parentNode
? n.parentNode.ui.getChildIndent()
: '';
buf = [ buf = [
'<tbody class="x-tree-node">', '<tbody class="x-tree-node">',
'<tr ext:tree-node-id="', n.id ,'" class="x-tree-node-el x-tree-node-leaf ', a.cls, '">', '<tr ext:tree-node-id="',
'<td class="x-treegrid-col">', n.id,
'<span class="x-tree-node-indent">', this.indentMarkup, "</span>", '" class="x-tree-node-el x-tree-node-leaf ',
'<img src="', this.emptyIcon, '" class="x-tree-ec-icon x-tree-elbow" />', a.cls,
'<img src="', a.icon || this.emptyIcon, '" class="x-tree-node-icon', (a.icon ? " x-tree-node-inline-icon" : ""), (a.iconCls ? " "+a.iconCls : ""), '" unselectable="on" />', '">',
'<a hidefocus="on" class="x-tree-node-anchor" href="', a.href ? a.href : '#', '" tabIndex="1" ', '<td class="x-treegrid-col">',
a.hrefTarget ? ' target="'+a.hrefTarget+'"' : '', '>', '<span class="x-tree-node-indent">',
'<span unselectable="on">', (c.tpl ? c.tpl.apply(a) : a[c.dataIndex] || c.text), '</span></a>', this.indentMarkup,
'</td>' '</span>',
'<img src="',
this.emptyIcon,
'" class="x-tree-ec-icon x-tree-elbow" />',
'<img src="',
a.icon || this.emptyIcon,
'" class="x-tree-node-icon',
a.icon ? ' x-tree-node-inline-icon' : '',
a.iconCls ? ' ' + a.iconCls : '',
'" unselectable="on" />',
'<a hidefocus="on" class="x-tree-node-anchor" href="',
a.href ? a.href : '#',
'" tabIndex="1" ',
a.hrefTarget ? ' target="' + a.hrefTarget + '"' : '',
'>',
'<span unselectable="on">',
c.tpl ? c.tpl.apply(a) : a[c.dataIndex] || c.text,
'</span></a>',
'</td>',
]; ];
for(i = 1, len = cols.length; i < len; i++){ for (i = 1, len = cols.length; i < len; i++) {
c = cols[i]; c = cols[i];
buf.push( buf.push(
'<td class="x-treegrid-col ', (c.cls ? c.cls : ''), '">', '<td class="x-treegrid-col ',
'<div unselectable="on" class="x-treegrid-text"', (c.align ? ' style="text-align: ' + c.align + ';"' : ''), '>', c.cls ? c.cls : '',
(c.tpl ? c.tpl.apply(a) : a[c.dataIndex]), '">',
'</div>', '<div unselectable="on" class="x-treegrid-text"',
'</td>' c.align ? ' style="text-align: ' + c.align + ';"' : '',
'>',
c.tpl ? c.tpl.apply(a) : a[c.dataIndex],
'</div>',
'</td>'
); );
} }
buf.push( buf.push(
'</tr><tr class="x-tree-node-ct"><td colspan="', cols.length, '">', '</tr><tr class="x-tree-node-ct"><td colspan="',
'<table class="x-treegrid-node-ct-table" cellpadding="0" cellspacing="0" style="table-layout: fixed; display: none; width: ', t.innerCt.getWidth() ,'px;"><colgroup>' cols.length,
'">',
'<table class="x-treegrid-node-ct-table" cellpadding="0" cellspacing="0" style="table-layout: fixed; display: none; width: ',
t.innerCt.getWidth(),
'px;"><colgroup>'
); );
for(i = 0, len = cols.length; i<len; i++) { for (i = 0, len = cols.length; i < len; i++) {
buf.push('<col style="width: ', (cols[i].hidden ? 0 : cols[i].width) ,'px;" />'); buf.push(
'<col style="width: ',
cols[i].hidden ? 0 : cols[i].width,
'px;" />'
);
} }
buf.push('</colgroup></table></td></tr></tbody>'); buf.push('</colgroup></table></td></tr></tbody>');
if(bulkRender !== true && n.nextSibling && n.nextSibling.ui.getEl()){ if (bulkRender !== true && n.nextSibling && n.nextSibling.ui.getEl()) {
this.wrap = Ext.DomHelper.insertHtml("beforeBegin", n.nextSibling.ui.getEl(), buf.join('')); this.wrap = Ext.DomHelper.insertHtml(
}else{ 'beforeBegin',
this.wrap = Ext.DomHelper.insertHtml("beforeEnd", targetNode, buf.join('')); n.nextSibling.ui.getEl(),
buf.join('')
);
} else {
this.wrap = Ext.DomHelper.insertHtml(
'beforeEnd',
targetNode,
buf.join('')
);
} }
this.elNode = this.wrap.childNodes[0]; this.elNode = this.wrap.childNodes[0];
@ -69,39 +111,39 @@ Ext.ux.tree.TreeGridNodeUI = Ext.extend(Ext.tree.TreeNodeUI, {
}, },
// private // private
animExpand : function(cb){ animExpand: function(cb) {
this.ctNode.style.display = ""; this.ctNode.style.display = '';
Ext.ux.tree.TreeGridNodeUI.superclass.animExpand.call(this, cb); Ext.ux.tree.TreeGridNodeUI.superclass.animExpand.call(this, cb);
} },
}); });
Ext.ux.tree.TreeGridRootNodeUI = Ext.extend(Ext.tree.TreeNodeUI, { Ext.ux.tree.TreeGridRootNodeUI = Ext.extend(Ext.tree.TreeNodeUI, {
isTreeGridNodeUI: true, isTreeGridNodeUI: true,
// private // private
render : function(){ render: function() {
if(!this.rendered){ if (!this.rendered) {
this.wrap = this.ctNode = this.node.ownerTree.innerCt.dom; this.wrap = this.ctNode = this.node.ownerTree.innerCt.dom;
this.node.expanded = true; this.node.expanded = true;
} }
if(Ext.isWebKit) { if (Ext.isWebKit) {
// weird table-layout: fixed issue in webkit // weird table-layout: fixed issue in webkit
var ct = this.ctNode; var ct = this.ctNode;
ct.style.tableLayout = null; ct.style.tableLayout = null;
(function() { (function() {
ct.style.tableLayout = 'fixed'; ct.style.tableLayout = 'fixed';
}).defer(1); }.defer(1));
} }
}, },
destroy : function(){ destroy: function() {
if(this.elNode){ if (this.elNode) {
Ext.dd.Registry.unregister(this.elNode.id); Ext.dd.Registry.unregister(this.elNode.id);
} }
delete this.node; delete this.node;
}, },
collapse : Ext.emptyFn, collapse: Ext.emptyFn,
expand : Ext.emptyFn expand: Ext.emptyFn,
}); });

View File

@ -9,23 +9,25 @@
*/ */
Ext.override(Ext.ux.tree.TreeGridNodeUI, { Ext.override(Ext.ux.tree.TreeGridNodeUI, {
updateColumns: function() { updateColumns: function() {
if (!this.rendered) return; if (!this.rendered) return;
var a = this.node.attributes, var a = this.node.attributes,
t = this.node.getOwnerTree(), t = this.node.getOwnerTree(),
cols = t.columns, cols = t.columns,
c = cols[0]; c = cols[0];
// Update the first column // Update the first column
this.anchor.firstChild.innerHTML = (c.tpl ? c.tpl.apply(a) : a[c.dataIndex] || c.text); this.anchor.firstChild.innerHTML = c.tpl
? c.tpl.apply(a)
: a[c.dataIndex] || c.text;
// Update the remaining columns // Update the remaining columns
for(i = 1, len = cols.length; i < len; i++) { for (i = 1, len = cols.length; i < len; i++) {
c = cols[i]; c = cols[i];
this.elNode.childNodes[i].firstChild.innerHTML = (c.tpl ? c.tpl.apply(a) : a[c.dataIndex] || c.text); this.elNode.childNodes[i].firstChild.innerHTML = c.tpl
? c.tpl.apply(a)
: a[c.dataIndex] || c.text;
} }
} },
}); });

View File

@ -1,10 +1,9 @@
Ext.tree.RenderColumn = Ext.extend(Ext.tree.Column, { Ext.tree.RenderColumn = Ext.extend(Ext.tree.Column, {
constructor: function(c) { constructor: function(c) {
c.tpl = c.tpl || new Ext.XTemplate('{' + c.dataIndex + ':this.format}'); c.tpl = c.tpl || new Ext.XTemplate('{' + c.dataIndex + ':this.format}');
c.tpl.format = c.renderer; c.tpl.format = c.renderer;
c.tpl.col = this; c.tpl.col = this;
Ext.tree.RenderColumn.superclass.constructor.call(this, c); Ext.tree.RenderColumn.superclass.constructor.call(this, c);
} },
}); });
Ext.reg('tgrendercolumn', Ext.tree.RenderColumn); Ext.reg('tgrendercolumn', Ext.tree.RenderColumn);

View File

@ -30,33 +30,35 @@ Ext.ux.tree.TreeGridSorter = Ext.extend(Ext.tree.TreeSorter, {
/** /**
* @cfg {Array} sortClasses The CSS classes applied to a header when it is sorted. (defaults to <tt>['sort-asc', 'sort-desc']</tt>) * @cfg {Array} sortClasses The CSS classes applied to a header when it is sorted. (defaults to <tt>['sort-asc', 'sort-desc']</tt>)
*/ */
sortClasses : ['sort-asc', 'sort-desc'], sortClasses: ['sort-asc', 'sort-desc'],
/** /**
* @cfg {String} sortAscText The text displayed in the 'Sort Ascending' menu item (defaults to <tt>'Sort Ascending'</tt>) * @cfg {String} sortAscText The text displayed in the 'Sort Ascending' menu item (defaults to <tt>'Sort Ascending'</tt>)
*/ */
sortAscText : 'Sort Ascending', sortAscText: 'Sort Ascending',
/** /**
* @cfg {String} sortDescText The text displayed in the 'Sort Descending' menu item (defaults to <tt>'Sort Descending'</tt>) * @cfg {String} sortDescText The text displayed in the 'Sort Descending' menu item (defaults to <tt>'Sort Descending'</tt>)
*/ */
sortDescText : 'Sort Descending', sortDescText: 'Sort Descending',
constructor : function(tree, config) { constructor: function(tree, config) {
if(!Ext.isObject(config)) { if (!Ext.isObject(config)) {
config = { config = {
property: tree.columns[0].dataIndex || 'text', property: tree.columns[0].dataIndex || 'text',
folderSort: true folderSort: true,
} };
} }
Ext.ux.tree.TreeGridSorter.superclass.constructor.apply(this, arguments); Ext.ux.tree.TreeGridSorter.superclass.constructor.apply(
this,
arguments
);
this.tree = tree; this.tree = tree;
tree.on('headerclick', this.onHeaderClick, this); tree.on('headerclick', this.onHeaderClick, this);
tree.ddAppendOnly = true; tree.ddAppendOnly = true;
var me = this; var me = this;
this.defaultSortFn = function(n1, n2){ this.defaultSortFn = function(n1, n2) {
var desc = me.dir && me.dir.toLowerCase() == 'desc', var desc = me.dir && me.dir.toLowerCase() == 'desc',
prop = me.property || 'text', prop = me.property || 'text',
sortType = me.sortType, sortType = me.sortType,
@ -65,61 +67,80 @@ Ext.ux.tree.TreeGridSorter = Ext.extend(Ext.tree.TreeSorter, {
attr1 = n1.attributes, attr1 = n1.attributes,
attr2 = n2.attributes; attr2 = n2.attributes;
if(me.folderSort){ if (me.folderSort) {
if(attr1[leafAttr] && !attr2[leafAttr]){ if (attr1[leafAttr] && !attr2[leafAttr]) {
return 1; return 1;
} }
if(!attr1[leafAttr] && attr2[leafAttr]){ if (!attr1[leafAttr] && attr2[leafAttr]) {
return -1; return -1;
} }
} }
var prop1 = attr1[prop], var prop1 = attr1[prop],
prop2 = attr2[prop], prop2 = attr2[prop],
v1 = sortType ? sortType(prop1) : (caseSensitive ? prop1 : prop1.toUpperCase()); v1 = sortType
v2 = sortType ? sortType(prop2) : (caseSensitive ? prop2 : prop2.toUpperCase()); ? sortType(prop1)
: caseSensitive
? prop1
: prop1.toUpperCase();
v2 = sortType
? sortType(prop2)
: caseSensitive
? prop2
: prop2.toUpperCase();
if(v1 < v2){ if (v1 < v2) {
return desc ? +1 : -1; return desc ? +1 : -1;
}else if(v1 > v2){ } else if (v1 > v2) {
return desc ? -1 : +1; return desc ? -1 : +1;
}else{ } else {
return 0; return 0;
} }
}; };
tree.on('afterrender', this.onAfterTreeRender, this, {single: true}); tree.on('afterrender', this.onAfterTreeRender, this, { single: true });
tree.on('headermenuclick', this.onHeaderMenuClick, this); tree.on('headermenuclick', this.onHeaderMenuClick, this);
}, },
onAfterTreeRender : function() { onAfterTreeRender: function() {
if(this.tree.hmenu){ if (this.tree.hmenu) {
this.tree.hmenu.insert(0, this.tree.hmenu.insert(
{itemId:'asc', text: this.sortAscText, cls: 'xg-hmenu-sort-asc'}, 0,
{itemId:'desc', text: this.sortDescText, cls: 'xg-hmenu-sort-desc'} {
itemId: 'asc',
text: this.sortAscText,
cls: 'xg-hmenu-sort-asc',
},
{
itemId: 'desc',
text: this.sortDescText,
cls: 'xg-hmenu-sort-desc',
}
); );
} }
this.updateSortIcon(0, 'asc'); this.updateSortIcon(0, 'asc');
}, },
onHeaderMenuClick : function(c, id, index) { onHeaderMenuClick: function(c, id, index) {
if(id === 'asc' || id === 'desc') { if (id === 'asc' || id === 'desc') {
this.onHeaderClick(c, null, index); this.onHeaderClick(c, null, index);
return false; return false;
} }
}, },
onHeaderClick : function(c, el, i) { onHeaderClick: function(c, el, i) {
if(c && !this.tree.headersDisabled){ if (c && !this.tree.headersDisabled) {
var me = this; var me = this;
me.property = c.dataIndex; me.property = c.dataIndex;
me.dir = c.dir = (c.dir === 'desc' ? 'asc' : 'desc'); me.dir = c.dir = c.dir === 'desc' ? 'asc' : 'desc';
me.sortType = c.sortType; me.sortType = c.sortType;
me.caseSensitive === Ext.isBoolean(c.caseSensitive) ? c.caseSensitive : this.caseSensitive; me.caseSensitive === Ext.isBoolean(c.caseSensitive)
? c.caseSensitive
: this.caseSensitive;
me.sortFn = c.sortFn || this.defaultSortFn; me.sortFn = c.sortFn || this.defaultSortFn;
this.tree.root.cascade(function(n) { this.tree.root.cascade(function(n) {
if(!n.isLeaf()) { if (!n.isLeaf()) {
me.updateSort(me.tree, n); me.updateSort(me.tree, n);
} }
}); });
@ -129,9 +150,9 @@ Ext.ux.tree.TreeGridSorter = Ext.extend(Ext.tree.TreeSorter, {
}, },
// private // private
updateSortIcon : function(col, dir){ updateSortIcon: function(col, dir) {
var sc = this.sortClasses, var sc = this.sortClasses,
hds = this.tree.innerHd.select('td').removeClass(sc); hds = this.tree.innerHd.select('td').removeClass(sc);
hds.item(col).addClass(sc[dir == 'desc' ? 1 : 0]); hds.item(col).addClass(sc[dir == 'desc' ? 1 : 0]);
} },
}); });

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -4,16 +4,18 @@ For a quick summary read: https://docs.pipenv.org/basics/
## Prerequisites ## Prerequisites
* python-libtorrent - python-libtorrent
* pip - pip
* pipenv - pipenv
## Install pipenv and packages ## Install pipenv and packages
Install Pipenv and upgrade pip: Install Pipenv and upgrade pip:
pip install -U pip pipenv pip install -U pip pipenv
On Ubuntu: On Ubuntu:
sudo -H pip install -U pip pipenv sudo -H pip install -U pip pipenv
In order to have access to system libtorrent we use `--site-packages` and In order to have access to system libtorrent we use `--site-packages` and