[Lint] Update pre-commit hook and isort versions

* Fixed black hook requiring Py3.6 to installed locally. Will now assume
Py3.6+ in installed.
 * Added isort traceback in pre-commit flake8 hook fails
 * Updated versions of Black, Prettier and isort
 * Keep Flake8 at 3.7.9 due to E402 issue: https://gitlab.com/pycqa/flake8/-/issues/638
 * New pyproject config for isort v5 with fixes for Python 2 imports.
 * Fixed travis config to run Python 3.6 for lint run. Replaced the
virtualenv with_system_site_packages config with Travis specific Python
config value so lint run doesn't attempt to append with_system_site_packages
to Python 3.6 command.
This commit is contained in:
Calum Lind 2021-01-17 15:48:35 +00:00
parent 23a48dd01c
commit 610a1bb313
114 changed files with 955 additions and 1034 deletions

View File

@ -6,28 +6,29 @@ exclude: >
)$ )$
repos: repos:
- repo: https://github.com/ambv/black - repo: https://github.com/ambv/black
rev: 19.10b0 rev: 20.8b1
hooks: hooks:
- id: black - id: black
name: Fmt Black name: Fmt Black
language_version: python3.6 - repo: https://github.com/pre-commit/mirrors-prettier
- repo: https://github.com/prettier/prettier rev: v2.2.1
rev: 1.19.1
hooks: hooks:
- id: prettier - id: prettier
name: Fmt Prettier name: Fmt Prettier
# Workaround to list modified files only. # Workaround to list modified files only.
args: [--list-different] args: [--list-different]
- repo: https://gitlab.com/pycqa/flake8 - repo: https://gitlab.com/pycqa/flake8
# v3.7.9 due to E402 issue: https://gitlab.com/pycqa/flake8/-/issues/638
rev: 3.7.9 rev: 3.7.9
hooks: hooks:
- id: flake8 - id: flake8
name: Chk Flake8 name: Chk Flake8
additional_dependencies: additional_dependencies:
- flake8-isort==2.7 - flake8-isort==4.0.0
- pep8-naming==0.8.2 - pep8-naming==0.11.1
args: [--isort-show-traceback]
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0 rev: v3.4.0
hooks: hooks:
- id: double-quote-string-fixer - id: double-quote-string-fixer
name: Fix Double-quotes name: Fix Double-quotes

View File

@ -4,10 +4,8 @@ dist: xenial
language: python language: python
python: python:
# Travis Xenial Python to support system_site_packages # Travis Xenial Python to support system_site_packages
- 3.5 - 3.5_with_system_site_packages
cache: pip cache: pip
virtualenv:
system_site_packages: true
env: env:
global: global:
@ -21,19 +19,20 @@ jobs:
include: include:
- name: Unit tests - name: Unit tests
env: TOX_ENV=py3 env: TOX_ENV=py3
- name: Unit tests - libtorrent 1.2 #~ - name: Unit tests - libtorrent 1.2
env: TOX_ENV=py3 #~ env: TOX_ENV=py3
addons: #~ addons:
apt: #~ apt:
sources: [sourceline: "ppa:libtorrent.org/1.2-daily"] #~ sources: [sourceline: "ppa:libtorrent.org/1.2-daily"]
packages: [python3-libtorrent, python3-venv] #~ packages: [python3-libtorrent, python3-venv]
- name: Unit tests - Python 2 - name: Unit tests - Python 2
env: TOX_ENV=py27 env: TOX_ENV=py27
python: 2.7 python: 2.7_with_system_site_packages
- if: commit_message =~ SECURITY_TEST - if: commit_message =~ SECURITY_TEST
env: TOX_ENV=security env: TOX_ENV=security
- name: Code linting - name: Code linting
env: TOX_ENV=lint env: TOX_ENV=lint
python: 3.6
- name: Docs build - name: Docs build
env: TOX_ENV=docs env: TOX_ENV=docs
- name: GTK unit tests - name: GTK unit tests
@ -73,7 +72,9 @@ install:
before_script: before_script:
- export PYTHONPATH=$PYTHONPATH:$PWD - export PYTHONPATH=$PYTHONPATH:$PWD
# Verify libtorrent installed and version # Verify libtorrent installed and version
- python -c "import libtorrent as lt; print(lt.__version__)" - "if [ $TOX_ENV != 'lint' ]; then
python -c 'import libtorrent as lt; print(lt.__version__)';
fi"
# Start xvfb for the GTKUI tests # Start xvfb for the GTKUI tests
- "if [ $TOX_ENV == 'gtkui' ]; then - "if [ $TOX_ENV == 'gtkui' ]; then
/sbin/start-stop-daemon --start --quiet --background \ /sbin/start-stop-daemon --start --quiet --background \

View File

@ -43,8 +43,8 @@ try:
from urllib.request import pathname2url from urllib.request import pathname2url
except ImportError: except ImportError:
# PY2 fallback # PY2 fallback
from urlparse import urljoin # pylint: disable=ungrouped-imports
from urllib import pathname2url, unquote_plus # pylint: disable=ungrouped-imports from urllib import pathname2url, unquote_plus # pylint: disable=ungrouped-imports
from urlparse import urljoin # pylint: disable=ungrouped-imports
# Windows workaround for HTTPS requests requiring certificate authority bundle. # Windows workaround for HTTPS requests requiring certificate authority bundle.
# see: https://twistedmatrix.com/trac/ticket/9209 # see: https://twistedmatrix.com/trac/ticket/9209
@ -1013,9 +1013,9 @@ def decode_bytes(byte_str, encoding='utf8'):
if encoding.lower() not in ['utf8', 'utf-8']: if encoding.lower() not in ['utf8', 'utf-8']:
encodings.insert(0, lambda: (encoding, 'strict')) encodings.insert(0, lambda: (encoding, 'strict'))
for l in encodings: for enc in encodings:
try: try:
return byte_str.decode(*l()) return byte_str.decode(*enc())
except UnicodeDecodeError: except UnicodeDecodeError:
pass pass
return '' return ''
@ -1144,6 +1144,7 @@ AUTH_LEVEL_DEFAULT = AUTH_LEVEL_NORMAL
def create_auth_file(): def create_auth_file():
import stat import stat
import deluge.configmanager import deluge.configmanager
auth_file = deluge.configmanager.get_config_dir('auth') auth_file = deluge.configmanager.get_config_dir('auth')
@ -1159,6 +1160,7 @@ def create_auth_file():
def create_localclient_account(append=False): def create_localclient_account(append=False):
import random import random
from hashlib import sha1 as sha from hashlib import sha1 as sha
import deluge.configmanager import deluge.configmanager
auth_file = deluge.configmanager.get_config_dir('auth') auth_file = deluge.configmanager.get_config_dir('auth')
@ -1244,8 +1246,7 @@ def set_env_variable(name, value):
os.environ[name] = value.encode('utf8') os.environ[name] = value.encode('utf8')
if windows_check(): if windows_check():
from ctypes import windll from ctypes import cdll, windll
from ctypes import cdll
# Update the copy maintained by Windows (so SysInternals Process Explorer sees it) # Update the copy maintained by Windows (so SysInternals Process Explorer sees it)
result = windll.kernel32.SetEnvironmentVariableW(name, value) result = windll.kernel32.SetEnvironmentVariableW(name, value)
@ -1274,7 +1275,7 @@ def unicode_argv():
# Versions 2.x of Python don't support Unicode in sys.argv on # Versions 2.x of Python don't support Unicode in sys.argv on
# Windows, with the underlying Windows API instead replacing multi-byte # Windows, with the underlying Windows API instead replacing multi-byte
# characters with '?'. # characters with '?'.
from ctypes import POINTER, byref, cdll, c_int, windll from ctypes import POINTER, byref, c_int, cdll, windll
from ctypes.wintypes import LPCWSTR, LPWSTR from ctypes.wintypes import LPCWSTR, LPWSTR
get_cmd_linew = cdll.kernel32.GetCommandLineW get_cmd_linew = cdll.kernel32.GetCommandLineW

View File

@ -204,9 +204,9 @@ class Config(object):
global callLater global callLater
if callLater is None: if callLater is None:
# Must import here and not at the top or it will throw ReactorAlreadyInstalledError # Must import here and not at the top or it will throw ReactorAlreadyInstalledError
from twisted.internet.reactor import ( from twisted.internet.reactor import ( # pylint: disable=redefined-outer-name
callLater, callLater,
) # pylint: disable=redefined-outer-name )
# Run the set_function for this key if any # Run the set_function for this key if any
try: try:
for func in self.__set_functions[key]: for func in self.__set_functions[key]:
@ -304,9 +304,9 @@ class Config(object):
global callLater global callLater
if callLater is None: if callLater is None:
# Must import here and not at the top or it will throw ReactorAlreadyInstalledError # Must import here and not at the top or it will throw ReactorAlreadyInstalledError
from twisted.internet.reactor import ( from twisted.internet.reactor import ( # pylint: disable=redefined-outer-name
callLater, callLater,
) # pylint: disable=redefined-outer-name )
# We set the save_timer for 5 seconds if not already set # We set the save_timer for 5 seconds if not already set
if not self._save_timer or not self._save_timer.active(): if not self._save_timer or not self._save_timer.active():

View File

@ -57,10 +57,10 @@ from deluge.event import (
from deluge.httpdownloader import download_file from deluge.httpdownloader import download_file
try: try:
from urllib.request import urlopen, URLError from urllib.request import URLError, urlopen
except ImportError: except ImportError:
# PY2 fallback # PY2 fallback
from urllib2 import urlopen, URLError from urllib2 import URLError, urlopen
log = logging.getLogger(__name__) log = logging.getLogger(__name__)

View File

@ -200,6 +200,7 @@ class Daemon(object):
if rpc not in self.get_method_list(): if rpc not in self.get_method_list():
return False return False
return self.rpcserver.get_session_auth_level() >= self.rpcserver.get_rpc_auth_level( return (
rpc self.rpcserver.get_session_auth_level()
>= self.rpcserver.get_rpc_auth_level(rpc)
) )

View File

@ -100,9 +100,7 @@ def tracker_error_filter(torrent_ids, values):
class FilterManager(component.Component): class FilterManager(component.Component):
"""FilterManager """FilterManager"""
"""
def __init__(self, core): def __init__(self, core):
component.Component.__init__(self, 'FilterManager') component.Component.__init__(self, 'FilterManager')

View File

@ -1340,8 +1340,8 @@ class Torrent(object):
def scrape_tracker(self): def scrape_tracker(self):
"""Scrape the tracker """Scrape the tracker
A scrape request queries the tracker for statistics such as total A scrape request queries the tracker for statistics such as total
number of incomplete peers, complete peers, number of downloads etc. number of incomplete peers, complete peers, number of downloads etc.
""" """
try: try:
self.handle.scrape_tracker() self.handle.scrape_tracker()

View File

@ -25,7 +25,7 @@ Deluge.ux.preferences.AutoAddPage = Ext.extend(Ext.Panel, {
border: false, border: false,
watchdirs: {}, watchdirs: {},
initComponent: function() { initComponent: function () {
Deluge.ux.preferences.AutoAddPage.superclass.initComponent.call(this); Deluge.ux.preferences.AutoAddPage.superclass.initComponent.call(this);
var autoAdd = this; var autoAdd = this;
@ -41,10 +41,10 @@ Deluge.ux.preferences.AutoAddPage = Ext.extend(Ext.Panel, {
sortable: true, sortable: true,
dataIndex: 'enabled', dataIndex: 'enabled',
tpl: new Ext.XTemplate('{enabled:this.getCheckbox}', { tpl: new Ext.XTemplate('{enabled:this.getCheckbox}', {
getCheckbox: function(checked, selected) { getCheckbox: function (checked, selected) {
Deluge.ux.AutoAdd.onClickFunctions[ Deluge.ux.AutoAdd.onClickFunctions[
selected.id selected.id
] = function() { ] = function () {
if (selected.enabled) { if (selected.enabled) {
deluge.client.autoadd.disable_watchdir( deluge.client.autoadd.disable_watchdir(
selected.id selected.id
@ -122,9 +122,9 @@ Deluge.ux.preferences.AutoAddPage = Ext.extend(Ext.Panel, {
this.on('show', this.onPreferencesShow, this); this.on('show', this.onPreferencesShow, this);
}, },
updateWatchDirs: function() { updateWatchDirs: function () {
deluge.client.autoadd.get_watchdirs({ deluge.client.autoadd.get_watchdirs({
success: function(watchdirs) { success: function (watchdirs) {
this.watchdirs = watchdirs; this.watchdirs = watchdirs;
var watchdirsArray = []; var watchdirsArray = [];
for (var id in watchdirs) { for (var id in watchdirs) {
@ -145,12 +145,12 @@ Deluge.ux.preferences.AutoAddPage = Ext.extend(Ext.Panel, {
}); });
}, },
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( this.addWin.on(
'watchdiradd', 'watchdiradd',
function() { function () {
this.updateWatchDirs(); this.updateWatchDirs();
}, },
this this
@ -159,12 +159,12 @@ Deluge.ux.preferences.AutoAddPage = Ext.extend(Ext.Panel, {
this.addWin.show(); this.addWin.show();
}, },
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( this.editWin.on(
'watchdiredit', 'watchdiredit',
function() { function () {
this.updateWatchDirs(); this.updateWatchDirs();
}, },
this this
@ -174,39 +174,27 @@ Deluge.ux.preferences.AutoAddPage = Ext.extend(Ext.Panel, {
this.editWin.show(id, this.watchdirs[id]); this.editWin.show(id, this.watchdirs[id]);
}, },
onPreferencesShow: function() { onPreferencesShow: function () {
this.updateWatchDirs(); this.updateWatchDirs();
}, },
onRemoveClick: function() { onRemoveClick: function () {
var record = this.list.getSelectedRecords()[0]; var record = this.list.getSelectedRecords()[0];
deluge.client.autoadd.remove(record.id, { deluge.client.autoadd.remove(record.id, {
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 this.panel.getBottomToolbar().items.get(1).enable();
.getBottomToolbar() this.panel.getBottomToolbar().items.get(3).enable();
.items.get(1)
.enable();
this.panel
.getBottomToolbar()
.items.get(3)
.enable();
} else { } else {
this.panel this.panel.getBottomToolbar().items.get(1).disable();
.getBottomToolbar() this.panel.getBottomToolbar().items.get(3).disable();
.items.get(1)
.disable();
this.panel
.getBottomToolbar()
.items.get(3)
.disable();
} }
}, },
}); });
@ -218,12 +206,12 @@ Deluge.plugins.AutoAddPlugin = Ext.extend(Deluge.Plugin, {
prefsPage: null, prefsPage: null,
}, },
onDisable: function() { onDisable: function () {
deluge.preferences.removePage(Deluge.plugins.AutoAddPlugin.prefsPage); deluge.preferences.removePage(Deluge.plugins.AutoAddPlugin.prefsPage);
Deluge.plugins.AutoAddPlugin.prefsPage = null; Deluge.plugins.AutoAddPlugin.prefsPage = null;
}, },
onEnable: function() { onEnable: function () {
/* /*
* Called for each of the JavaScript files. * Called for each of the JavaScript files.
* This will prevent adding unnecessary tabs to the preferences window. * This will prevent adding unnecessary tabs to the preferences window.

View File

@ -60,7 +60,7 @@ Deluge.ux.AutoAdd.AutoAddWindowBase = Ext.extend(Ext.Window, {
], ],
}), }),
initComponent: function() { initComponent: function () {
Deluge.ux.AutoAdd.AutoAddWindowBase.superclass.initComponent.call(this); Deluge.ux.AutoAdd.AutoAddWindowBase.superclass.initComponent.call(this);
this.addButton(_('Cancel'), this.onCancelClick, this); this.addButton(_('Cancel'), this.onCancelClick, this);
@ -81,11 +81,11 @@ Deluge.ux.AutoAdd.AutoAddWindowBase = Ext.extend(Ext.Window, {
}); });
}, },
onCancelClick: function() { onCancelClick: function () {
this.hide(); this.hide();
}, },
getOptions: function() { getOptions: function () {
var options = {}; var options = {};
options['enabled'] = Ext.getCmp('enabled').getValue(); options['enabled'] = Ext.getCmp('enabled').getValue();
@ -102,22 +102,22 @@ Deluge.ux.AutoAdd.AutoAddWindowBase = Ext.extend(Ext.Window, {
options['append_extension'] = Ext.getCmp('append_extension').getValue(); options['append_extension'] = Ext.getCmp('append_extension').getValue();
options['owner'] = Ext.getCmp('owner').getValue(); options['owner'] = Ext.getCmp('owner').getValue();
this.toggle_ids.forEach(function(toggle_id) { this.toggle_ids.forEach(function (toggle_id) {
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( options[spin_id + '_toggle'] = Ext.getCmp(
spin_id + '_toggle' spin_id + '_toggle'
).getValue(); ).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( options[spin_int_id + '_toggle'] = Ext.getCmp(
spin_int_id + '_toggle' spin_int_id + '_toggle'
).getValue(); ).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( options[chk_id + '_toggle'] = Ext.getCmp(
chk_id + '_toggle' chk_id + '_toggle'
@ -137,7 +137,7 @@ Deluge.ux.AutoAdd.AutoAddWindowBase = Ext.extend(Ext.Window, {
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
*/ */
@ -193,7 +193,7 @@ Deluge.ux.AutoAdd.AutoAddWindowBase = Ext.extend(Ext.Window, {
: false : false
); );
this.spin_ids.forEach(function(spin_id) { this.spin_ids.forEach(function (spin_id) {
Ext.getCmp(spin_id).setValue( Ext.getCmp(spin_id).setValue(
options[spin_id] !== undefined ? options[spin_id] : 0 options[spin_id] !== undefined ? options[spin_id] : 0
); );
@ -203,7 +203,7 @@ Deluge.ux.AutoAdd.AutoAddWindowBase = Ext.extend(Ext.Window, {
: false : false
); );
}); });
this.chk_ids.forEach(function(chk_id) { this.chk_ids.forEach(function (chk_id) {
Ext.getCmp(chk_id).setValue( Ext.getCmp(chk_id).setValue(
options[chk_id] !== undefined ? options[chk_id] : true options[chk_id] !== undefined ? options[chk_id] : true
); );
@ -237,14 +237,14 @@ Deluge.ux.AutoAdd.AutoAddWindowBase = Ext.extend(Ext.Window, {
'path', 'path',
'download_location', 'download_location',
'copy_torrent', 'copy_torrent',
].forEach(function(field) { ].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);
}); });
if (Object.keys(options).length === 0) { if (Object.keys(options).length === 0) {
deluge.client.core.get_config({ deluge.client.core.get_config({
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
@ -291,11 +291,11 @@ Deluge.ux.AutoAdd.AutoAddWindowBase = Ext.extend(Ext.Window, {
} }
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 ( for (
var index = 0; var index = 0;
index < labels.length; index < labels.length;
@ -305,7 +305,7 @@ Deluge.ux.AutoAdd.AutoAddWindowBase = Ext.extend(Ext.Window, {
} }
this.labels.loadData(labels, false); this.labels.loadData(labels, false);
}, },
failure: function(failure) { failure: function (failure) {
console.error(failure); console.error(failure);
}, },
scope: this, scope: this,
@ -324,30 +324,26 @@ 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') Ext.getCmp('owner').setValue(owner).enable();
.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') Ext.getCmp('owner').setValue(user).disable(true);
.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( on_accounts(
accounts, accounts,
options['owner'] !== undefined options['owner'] !== undefined
@ -379,7 +375,7 @@ Deluge.ux.AutoAdd.EditAutoAddCommandWindow = Ext.extend(
{ {
title: _('Edit Watch Folder'), title: _('Edit Watch Folder'),
initComponent: function() { initComponent: function () {
Deluge.ux.AutoAdd.EditAutoAddCommandWindow.superclass.initComponent.call( Deluge.ux.AutoAdd.EditAutoAddCommandWindow.superclass.initComponent.call(
this this
); );
@ -389,7 +385,7 @@ Deluge.ux.AutoAdd.EditAutoAddCommandWindow = Ext.extend(
}); });
}, },
show: function(watchdir_id, options) { show: function (watchdir_id, options) {
Deluge.ux.AutoAdd.EditAutoAddCommandWindow.superclass.show.call( Deluge.ux.AutoAdd.EditAutoAddCommandWindow.superclass.show.call(
this this
); );
@ -397,11 +393,11 @@ Deluge.ux.AutoAdd.EditAutoAddCommandWindow = Ext.extend(
this.loadOptions(options); this.loadOptions(options);
}, },
onSaveClick: function() { onSaveClick: function () {
try { try {
var options = this.getOptions(); var options = this.getOptions();
deluge.client.autoadd.set_options(this.watchdir_id, options, { deluge.client.autoadd.set_options(this.watchdir_id, options, {
success: function() { success: function () {
this.fireEvent('watchdiredit', this, options); this.fireEvent('watchdiredit', this, options);
}, },
scope: this, scope: this,
@ -429,7 +425,7 @@ Deluge.ux.AutoAdd.AddAutoAddCommandWindow = Ext.extend(
{ {
title: _('Add Watch Folder'), title: _('Add Watch Folder'),
initComponent: function() { initComponent: function () {
Deluge.ux.AutoAdd.AddAutoAddCommandWindow.superclass.initComponent.call( Deluge.ux.AutoAdd.AddAutoAddCommandWindow.superclass.initComponent.call(
this this
); );
@ -439,21 +435,21 @@ Deluge.ux.AutoAdd.AddAutoAddCommandWindow = Ext.extend(
}); });
}, },
show: function() { show: function () {
Deluge.ux.AutoAdd.AddAutoAddCommandWindow.superclass.show.call( Deluge.ux.AutoAdd.AddAutoAddCommandWindow.superclass.show.call(
this this
); );
this.loadOptions(); this.loadOptions();
}, },
onAddClick: function() { onAddClick: function () {
var options = this.getOptions(); var options = this.getOptions();
deluge.client.autoadd.add(options, { deluge.client.autoadd.add(options, {
success: function() { success: function () {
this.fireEvent('watchdiradd', this, options); this.fireEvent('watchdiradd', this, options);
this.hide(); this.hide();
}, },
failure: function(err) { failure: function (err) {
const regex = /: (.*\n)\n?\]/m; const regex = /: (.*\n)\n?\]/m;
var error; var error;
if ((error = regex.exec(err.error.message)) !== null) { if ((error = regex.exec(err.error.message)) !== null) {

View File

@ -19,7 +19,7 @@ Deluge.ux.AutoAdd.AutoAddMainPanel = Ext.extend(Ext.Panel, {
id: 'main_tab_panel', id: 'main_tab_panel',
title: _('Main'), title: _('Main'),
initComponent: function() { initComponent: function () {
Deluge.ux.AutoAdd.AutoAddMainPanel.superclass.initComponent.call(this); Deluge.ux.AutoAdd.AutoAddMainPanel.superclass.initComponent.call(this);
this.watchFolderFset = new Ext.form.FieldSet({ this.watchFolderFset = new Ext.form.FieldSet({
xtype: 'fieldset', xtype: 'fieldset',
@ -69,7 +69,7 @@ Deluge.ux.AutoAdd.AutoAddMainPanel = Ext.extend(Ext.Panel, {
checked: true, checked: true,
hideLabel: true, hideLabel: true,
listeners: { listeners: {
check: function(cb, newValue) { check: function (cb, newValue) {
if (newValue) { if (newValue) {
Ext.getCmp( Ext.getCmp(
'append_extension' 'append_extension'
@ -98,7 +98,7 @@ Deluge.ux.AutoAdd.AutoAddMainPanel = Ext.extend(Ext.Panel, {
), ),
hideLabel: true, hideLabel: true,
listeners: { listeners: {
check: function(cb, newValue) { check: function (cb, newValue) {
if (newValue) { if (newValue) {
Ext.getCmp( Ext.getCmp(
'append_extension' 'append_extension'
@ -141,7 +141,7 @@ Deluge.ux.AutoAdd.AutoAddMainPanel = Ext.extend(Ext.Panel, {
), ),
hideLabel: true, hideLabel: true,
listeners: { listeners: {
check: function(cb, newValue) { check: function (cb, newValue) {
if (newValue) { if (newValue) {
Ext.getCmp( Ext.getCmp(
'append_extension' 'append_extension'
@ -201,7 +201,7 @@ Deluge.ux.AutoAdd.AutoAddMainPanel = Ext.extend(Ext.Panel, {
xtype: 'checkbox', xtype: 'checkbox',
boxLabel: _('Set download folder'), boxLabel: _('Set download folder'),
listeners: { listeners: {
check: function(cb, checked) { check: function (cb, checked) {
Ext.getCmp('download_location').setDisabled( Ext.getCmp('download_location').setDisabled(
!checked !checked
); );
@ -233,7 +233,7 @@ Deluge.ux.AutoAdd.AutoAddMainPanel = Ext.extend(Ext.Panel, {
xtype: 'checkbox', xtype: 'checkbox',
boxLabel: _('Set move completed folder'), boxLabel: _('Set move completed folder'),
listeners: { listeners: {
check: function(cb, checked) { check: function (cb, checked) {
Ext.getCmp('move_completed_path').setDisabled( Ext.getCmp('move_completed_path').setDisabled(
!checked !checked
); );
@ -271,7 +271,7 @@ Deluge.ux.AutoAdd.AutoAddMainPanel = Ext.extend(Ext.Panel, {
xtype: 'checkbox', xtype: 'checkbox',
boxLabel: _('Label:'), boxLabel: _('Label:'),
listeners: { listeners: {
check: function(cb, checked) { check: function (cb, checked) {
Ext.getCmp('label').setDisabled(!checked); Ext.getCmp('label').setDisabled(!checked);
}, },
}, },

View File

@ -19,7 +19,7 @@ Deluge.ux.AutoAdd.AutoAddOptionsPanel = Ext.extend(Ext.Panel, {
id: 'options_tab_panel', id: 'options_tab_panel',
title: _('Options'), title: _('Options'),
initComponent: function() { initComponent: function () {
Deluge.ux.AutoAdd.AutoAddOptionsPanel.superclass.initComponent.call( Deluge.ux.AutoAdd.AutoAddOptionsPanel.superclass.initComponent.call(
this this
); );
@ -149,7 +149,7 @@ Deluge.ux.AutoAdd.AutoAddOptionsPanel = Ext.extend(Ext.Panel, {
hideLabel: true, hideLabel: true,
width: 175, width: 175,
listeners: { listeners: {
check: function(cb, checked) { check: function (cb, checked) {
Ext.getCmp('stop_ratio').setDisabled( Ext.getCmp('stop_ratio').setDisabled(
!checked !checked
); );
@ -223,7 +223,7 @@ Deluge.ux.AutoAdd.AutoAddOptionsPanel = Ext.extend(Ext.Panel, {
this.add([this.ownerFset, this.bandwidthFset, this.queueFset]); this.add([this.ownerFset, this.bandwidthFset, this.queueFset]);
}, },
_getBandwidthContainer: function(values) { _getBandwidthContainer: function (values) {
return new Ext.Container({ return new Ext.Container({
xtype: 'container', xtype: 'container',
layout: 'hbox', layout: 'hbox',
@ -236,7 +236,7 @@ Deluge.ux.AutoAdd.AutoAddOptionsPanel = Ext.extend(Ext.Panel, {
boxLabel: _(values.labelCheckbox), boxLabel: _(values.labelCheckbox),
width: 175, width: 175,
listeners: { listeners: {
check: function(cb, checked) { check: function (cb, checked) {
Ext.getCmp(values.idSpinner).setDisabled(!checked); Ext.getCmp(values.idSpinner).setDisabled(!checked);
}, },
}, },
@ -257,7 +257,7 @@ Deluge.ux.AutoAdd.AutoAddOptionsPanel = Ext.extend(Ext.Panel, {
}); });
}, },
_getQueueContainer: function(values) { _getQueueContainer: function (values) {
return new Ext.Container({ return new Ext.Container({
xtype: 'container', xtype: 'container',
layout: 'hbox', layout: 'hbox',
@ -270,7 +270,7 @@ Deluge.ux.AutoAdd.AutoAddOptionsPanel = Ext.extend(Ext.Panel, {
boxLabel: _(values.labelCheckbox), boxLabel: _(values.labelCheckbox),
width: 175, width: 175,
listeners: { listeners: {
check: function(cb, checked) { check: function (cb, checked) {
Ext.getCmp(values.nameRadio).setDisabled(!checked); Ext.getCmp(values.nameRadio).setDisabled(!checked);
Ext.getCmp('not_' + values.nameRadio).setDisabled( Ext.getCmp('not_' + values.nameRadio).setDisabled(
!checked !checked

View File

@ -22,7 +22,7 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, {
border: false, border: false,
autoScroll: true, autoScroll: true,
initComponent: function() { initComponent: function () {
Deluge.ux.preferences.BlocklistPage.superclass.initComponent.call(this); Deluge.ux.preferences.BlocklistPage.superclass.initComponent.call(this);
this.URLFset = this.add({ this.URLFset = this.add({
@ -210,11 +210,11 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, {
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();
@ -222,7 +222,7 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, {
Ext.apply(this.viewConfig, { emptyText: text }); Ext.apply(this.viewConfig, { emptyText: text });
} }
}, },
loadData: function(data) { loadData: function (data) {
this.getStore().loadData(data); this.getStore().loadData(data);
if (this.viewReady) { if (this.viewReady) {
this.getView().updateHeaders(); this.getView().updateHeaders();
@ -264,7 +264,7 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, {
this.forceDownload.setHandler(this.forceDown, this); this.forceDownload.setHandler(this.forceDown, this);
}, },
onApply: function() { onApply: function () {
var config = {}; var config = {};
config['url'] = this.URL.getValue(); config['url'] = this.URL.getValue();
@ -285,13 +285,13 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, {
deluge.client.blocklist.set_config(config); deluge.client.blocklist.set_config(config);
}, },
onOk: function() { onOk: function () {
this.onApply(); this.onApply();
}, },
onUpdate: function() { onUpdate: function () {
deluge.client.blocklist.get_status({ deluge.client.blocklist.get_status({
success: function(status) { success: function (status) {
if (status['state'] == 'Downloading') { if (status['state'] == 'Downloading') {
this.InfoFset.hide(); this.InfoFset.hide();
this.checkDownload.getComponent(0).setDisabled(true); this.checkDownload.getComponent(0).setDisabled(true);
@ -339,19 +339,19 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, {
}); });
}, },
checkDown: function() { checkDown: function () {
this.onApply(); this.onApply();
deluge.client.blocklist.check_import(); deluge.client.blocklist.check_import();
}, },
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 () {
deluge.client.blocklist.get_config({ deluge.client.blocklist.get_config({
success: function(config) { success: function (config) {
this.URL.setValue(config['url']); this.URL.setValue(config['url']);
this.checkListDays.setValue(config['check_after_days']); this.checkListDays.setValue(config['check_after_days']);
this.chkImportOnStart.setValue(config['load_on_start']); this.chkImportOnStart.setValue(config['load_on_start']);
@ -369,7 +369,7 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, {
}); });
deluge.client.blocklist.get_status({ deluge.client.blocklist.get_status({
success: function(status) { success: function (status) {
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']);
@ -381,7 +381,7 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, {
}); });
}, },
addIP: function() { addIP: function () {
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({
@ -392,7 +392,7 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, {
this.WhitelistFset.getComponent(0).startEditing(0, 0); this.WhitelistFset.getComponent(0).startEditing(0, 0);
}, },
deleteIP: function() { deleteIP: function () {
var selections = this.WhitelistFset.getComponent(0) var selections = this.WhitelistFset.getComponent(0)
.getSelectionModel() .getSelectionModel()
.getSelections(); .getSelections();
@ -403,7 +403,7 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, {
store.commitChanges(); store.commitChanges();
}, },
onDestroy: function() { onDestroy: function () {
Ext.TaskMgr.stop(this.updateTask); Ext.TaskMgr.stop(this.updateTask);
deluge.preferences.un('show', this.updateConfig, this); deluge.preferences.un('show', this.updateConfig, this);
@ -415,11 +415,11 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, {
Deluge.plugins.BlocklistPlugin = Ext.extend(Deluge.Plugin, { Deluge.plugins.BlocklistPlugin = Ext.extend(Deluge.Plugin, {
name: 'Blocklist', name: 'Blocklist',
onDisable: function() { onDisable: function () {
deluge.preferences.removePage(this.prefsPage); deluge.preferences.removePage(this.prefsPage);
}, },
onEnable: function() { onEnable: function () {
this.prefsPage = deluge.preferences.addPage( this.prefsPage = deluge.preferences.addPage(
new Deluge.ux.preferences.BlocklistPage() new Deluge.ux.preferences.BlocklistPage()
); );

View File

@ -18,7 +18,7 @@ Deluge.ux.ExecuteWindowBase = Ext.extend(Ext.Window, {
height: 130, height: 130,
closeAction: 'hide', closeAction: 'hide',
initComponent: function() { initComponent: function () {
Deluge.ux.ExecuteWindowBase.superclass.initComponent.call(this); Deluge.ux.ExecuteWindowBase.superclass.initComponent.call(this);
this.addButton(_('Cancel'), this.onCancelClick, this); this.addButton(_('Cancel'), this.onCancelClick, this);
@ -56,7 +56,7 @@ Deluge.ux.ExecuteWindowBase = Ext.extend(Ext.Window, {
}); });
}, },
onCancelClick: function() { onCancelClick: function () {
this.hide(); this.hide();
}, },
}); });
@ -64,7 +64,7 @@ Deluge.ux.ExecuteWindowBase = Ext.extend(Ext.Window, {
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({
@ -72,7 +72,7 @@ Deluge.ux.EditExecuteCommandWindow = Ext.extend(Deluge.ux.ExecuteWindowBase, {
}); });
}, },
show: function(command) { show: function (command) {
Deluge.ux.EditExecuteCommandWindow.superclass.show.call(this); Deluge.ux.EditExecuteCommandWindow.superclass.show.call(this);
this.command = command; this.command = command;
this.form.getForm().setValues({ this.form.getForm().setValues({
@ -81,14 +81,14 @@ Deluge.ux.EditExecuteCommandWindow = Ext.extend(Deluge.ux.ExecuteWindowBase, {
}); });
}, },
onSaveClick: function() { onSaveClick: function () {
var values = this.form.getForm().getFieldValues(); var values = this.form.getForm().getFieldValues();
deluge.client.execute.save_command( deluge.client.execute.save_command(
this.command.id, this.command.id,
values.event, values.event,
values.command, values.command,
{ {
success: function() { success: function () {
this.fireEvent( this.fireEvent(
'commandedit', 'commandedit',
this, this,
@ -106,7 +106,7 @@ Deluge.ux.EditExecuteCommandWindow = Ext.extend(Deluge.ux.ExecuteWindowBase, {
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({
@ -114,10 +114,10 @@ Deluge.ux.AddExecuteCommandWindow = Ext.extend(Deluge.ux.ExecuteWindowBase, {
}); });
}, },
onAddClick: function() { onAddClick: function () {
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( this.fireEvent(
'commandadd', 'commandadd',
this, this,
@ -143,7 +143,7 @@ Deluge.ux.preferences.ExecutePage = Ext.extend(Ext.Panel, {
layout: 'fit', layout: 'fit',
border: false, border: false,
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'),
@ -166,7 +166,7 @@ Deluge.ux.preferences.ExecutePage = Ext.extend(Ext.Panel, {
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;
}, },
}), }),
@ -215,21 +215,21 @@ Deluge.ux.preferences.ExecutePage = Ext.extend(Ext.Panel, {
this.on('show', this.onPreferencesShow, this); this.on('show', this.onPreferencesShow, this);
}, },
updateCommands: function() { updateCommands: function () {
deluge.client.execute.get_commands({ deluge.client.execute.get_commands({
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( this.addWin.on(
'commandadd', 'commandadd',
function() { function () {
this.updateCommands(); this.updateCommands();
}, },
this this
@ -238,19 +238,19 @@ Deluge.ux.preferences.ExecutePage = Ext.extend(Ext.Panel, {
this.addWin.show(); this.addWin.show();
}, },
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( this.editWin.on(
'commandedit', 'commandedit',
function() { function () {
this.updateCommands(); this.updateCommands();
}, },
this this
@ -259,39 +259,27 @@ Deluge.ux.preferences.ExecutePage = Ext.extend(Ext.Panel, {
this.editWin.show(this.list.getSelectedRecords()[0]); this.editWin.show(this.list.getSelectedRecords()[0]);
}, },
onPreferencesShow: function() { onPreferencesShow: function () {
this.updateCommands(); this.updateCommands();
}, },
onRemoveClick: function() { onRemoveClick: function () {
var record = this.list.getSelectedRecords()[0]; var record = this.list.getSelectedRecords()[0];
deluge.client.execute.remove_command(record.id, { deluge.client.execute.remove_command(record.id, {
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 this.panel.getBottomToolbar().items.get(1).enable();
.getBottomToolbar() this.panel.getBottomToolbar().items.get(3).enable();
.items.get(1)
.enable();
this.panel
.getBottomToolbar()
.items.get(3)
.enable();
} else { } else {
this.panel this.panel.getBottomToolbar().items.get(1).disable();
.getBottomToolbar() this.panel.getBottomToolbar().items.get(3).disable();
.items.get(1)
.disable();
this.panel
.getBottomToolbar()
.items.get(3)
.disable();
} }
}, },
}); });
@ -299,11 +287,11 @@ Deluge.ux.preferences.ExecutePage = Ext.extend(Ext.Panel, {
Deluge.plugins.ExecutePlugin = Ext.extend(Deluge.Plugin, { Deluge.plugins.ExecutePlugin = Ext.extend(Deluge.Plugin, {
name: 'Execute', name: 'Execute',
onDisable: function() { onDisable: function () {
deluge.preferences.removePage(this.prefsPage); deluge.preferences.removePage(this.prefsPage);
}, },
onEnable: function() { onEnable: function () {
this.prefsPage = deluge.preferences.addPage( this.prefsPage = deluge.preferences.addPage(
new Deluge.ux.preferences.ExecutePage() new Deluge.ux.preferences.ExecutePage()
); );

View File

@ -21,7 +21,7 @@ Deluge.ux.preferences.ExtractorPage = Ext.extend(Ext.Panel, {
layout: 'fit', layout: 'fit',
border: false, border: false,
initComponent: function() { initComponent: function () {
Deluge.ux.preferences.ExtractorPage.superclass.initComponent.call(this); Deluge.ux.preferences.ExtractorPage.superclass.initComponent.call(this);
this.form = this.add({ this.form = this.add({
@ -59,7 +59,7 @@ Deluge.ux.preferences.ExtractorPage = Ext.extend(Ext.Panel, {
this.on('show', this.updateConfig, this); this.on('show', this.updateConfig, this);
}, },
onApply: function() { onApply: function () {
// build settings object // build settings object
var config = {}; var config = {};
@ -69,13 +69,13 @@ Deluge.ux.preferences.ExtractorPage = Ext.extend(Ext.Panel, {
deluge.client.extractor.set_config(config); deluge.client.extractor.set_config(config);
}, },
onOk: function() { onOk: function () {
this.onApply(); this.onApply();
}, },
updateConfig: function() { updateConfig: function () {
deluge.client.extractor.get_config({ deluge.client.extractor.get_config({
success: function(config) { success: function (config) {
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']);
}, },
@ -87,11 +87,11 @@ Deluge.ux.preferences.ExtractorPage = Ext.extend(Ext.Panel, {
Deluge.plugins.ExtractorPlugin = Ext.extend(Deluge.Plugin, { Deluge.plugins.ExtractorPlugin = Ext.extend(Deluge.Plugin, {
name: 'Extractor', name: 'Extractor',
onDisable: function() { onDisable: function () {
deluge.preferences.removePage(this.prefsPage); deluge.preferences.removePage(this.prefsPage);
}, },
onEnable: function() { onEnable: function () {
this.prefsPage = deluge.preferences.addPage( this.prefsPage = deluge.preferences.addPage(
new Deluge.ux.preferences.ExtractorPage() new Deluge.ux.preferences.ExtractorPage()
); );

View File

@ -20,7 +20,7 @@ Deluge.ux.preferences.LabelPage = Ext.extend(Ext.Panel, {
layout: 'fit', layout: 'fit',
border: false, border: false,
initComponent: function() { initComponent: function () {
Deluge.ux.preferences.LabelPage.superclass.initComponent.call(this); Deluge.ux.preferences.LabelPage.superclass.initComponent.call(this);
fieldset = this.add({ fieldset = this.add({
xtype: 'fieldset', xtype: 'fieldset',
@ -56,7 +56,7 @@ Deluge.ux.AddLabelWindow = Ext.extend(Ext.Window, {
height: 100, height: 100,
closeAction: 'hide', closeAction: 'hide',
initComponent: function() { initComponent: function () {
Deluge.ux.AddLabelWindow.superclass.initComponent.call(this); Deluge.ux.AddLabelWindow.superclass.initComponent.call(this);
this.addButton(_('Cancel'), this.onCancelClick, this); this.addButton(_('Cancel'), this.onCancelClick, this);
this.addButton(_('Ok'), this.onOkClick, this); this.addButton(_('Ok'), this.onOkClick, this);
@ -76,7 +76,7 @@ Deluge.ux.AddLabelWindow = Ext.extend(Ext.Window, {
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,
@ -87,14 +87,14 @@ Deluge.ux.AddLabelWindow = Ext.extend(Ext.Window, {
}); });
}, },
onCancelClick: function() { onCancelClick: function () {
this.hide(); this.hide();
}, },
onOkClick: function() { onOkClick: function () {
var label = this.form.getForm().getValues().name; var label = this.form.getForm().getValues().name;
deluge.client.label.add(label, { deluge.client.label.add(label, {
success: function() { success: function () {
deluge.ui.update(); deluge.ui.update();
this.fireEvent('labeladded', label); this.fireEvent('labeladded', label);
}, },
@ -103,17 +103,14 @@ Deluge.ux.AddLabelWindow = Ext.extend(Ext.Window, {
this.hide(); this.hide();
}, },
onHide: function(comp) { onHide: function (comp) {
Deluge.ux.AddLabelWindow.superclass.onHide.call(this, comp); Deluge.ux.AddLabelWindow.superclass.onHide.call(this, comp);
this.form.getForm().reset(); this.form.getForm().reset();
}, },
onShow: function(comp) { onShow: function (comp) {
Deluge.ux.AddLabelWindow.superclass.onShow.call(this, comp); Deluge.ux.AddLabelWindow.superclass.onShow.call(this, comp);
this.form this.form.getForm().findField('name').focus(false, 150);
.getForm()
.findField('name')
.focus(false, 150);
}, },
}); });
@ -127,7 +124,7 @@ Deluge.ux.LabelOptionsWindow = Ext.extend(Ext.Window, {
height: 240, height: 240,
closeAction: 'hide', closeAction: 'hide',
initComponent: function() { initComponent: function () {
Deluge.ux.LabelOptionsWindow.superclass.initComponent.call(this); Deluge.ux.LabelOptionsWindow.superclass.initComponent.call(this);
this.addButton(_('Cancel'), this.onCancelClick, this); this.addButton(_('Cancel'), this.onCancelClick, this);
this.addButton(_('Ok'), this.onOkClick, this); this.addButton(_('Ok'), this.onOkClick, this);
@ -385,18 +382,18 @@ Deluge.ux.LabelOptionsWindow = Ext.extend(Ext.Window, {
}); });
}, },
getLabelOptions: function() { getLabelOptions: function () {
deluge.client.label.get_options(this.label, { deluge.client.label.get_options(this.label, {
success: this.gotOptions, success: this.gotOptions,
scope: this, scope: this,
}); });
}, },
gotOptions: function(options) { gotOptions: function (options) {
this.form.getForm().setValues(options); this.form.getForm().setValues(options);
}, },
show: function(label) { show: function (label) {
Deluge.ux.LabelOptionsWindow.superclass.show.call(this); Deluge.ux.LabelOptionsWindow.superclass.show.call(this);
this.label = label; this.label = label;
this.setTitle(_('Label Options') + ': ' + this.label); this.setTitle(_('Label Options') + ': ' + this.label);
@ -404,11 +401,11 @@ Deluge.ux.LabelOptionsWindow = Ext.extend(Ext.Window, {
this.getLabelOptions(); this.getLabelOptions();
}, },
onCancelClick: function() { onCancelClick: function () {
this.hide(); this.hide();
}, },
onOkClick: function() { onOkClick: function () {
var values = this.form.getForm().getFieldValues(); var values = this.form.getForm().getFieldValues();
if (values['auto_add_trackers']) { if (values['auto_add_trackers']) {
values['auto_add_trackers'] = values['auto_add_trackers'].split( values['auto_add_trackers'] = values['auto_add_trackers'].split(
@ -419,9 +416,9 @@ Deluge.ux.LabelOptionsWindow = Ext.extend(Ext.Window, {
this.hide(); this.hide();
}, },
onFieldChecked: function(field, checked) { onFieldChecked: function (field, checked) {
var fs = field.ownerCt.nextSibling(); var fs = field.ownerCt.nextSibling();
fs.items.each(function(field) { fs.items.each(function (field) {
field.setDisabled(!checked); field.setDisabled(!checked);
}); });
}, },
@ -436,7 +433,7 @@ Ext.ns('Deluge.plugins');
Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, { Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, {
name: 'Label', name: 'Label',
createMenu: function() { createMenu: function () {
this.labelMenu = new Ext.menu.Menu({ this.labelMenu = new Ext.menu.Menu({
items: [ items: [
{ {
@ -462,7 +459,7 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, {
}); });
}, },
setFilter: function(filter) { setFilter: function (filter) {
filter.show_zero = true; filter.show_zero = true;
filter.list.on('contextmenu', this.onLabelContextMenu, this); filter.list.on('contextmenu', this.onLabelContextMenu, this);
@ -470,7 +467,7 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, {
this.filter = filter; this.filter = filter;
}, },
updateTorrentMenu: function(states) { updateTorrentMenu: function (states) {
this.torrentMenu.removeAll(true); this.torrentMenu.removeAll(true);
this.torrentMenu.addMenuItem({ this.torrentMenu.addMenuItem({
text: _('No Label'), text: _('No Label'),
@ -489,7 +486,7 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, {
} }
}, },
onDisable: function() { onDisable: function () {
deluge.sidebar.un('filtercreate', this.onFilterCreate); deluge.sidebar.un('filtercreate', this.onFilterCreate);
deluge.sidebar.un('afterfiltercreate', this.onAfterFilterCreate); deluge.sidebar.un('afterfiltercreate', this.onAfterFilterCreate);
delete Deluge.FilterPanel.templates.label; delete Deluge.FilterPanel.templates.label;
@ -499,7 +496,7 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, {
deluge.preferences.removePage(this.prefsPage); deluge.preferences.removePage(this.prefsPage);
}, },
onEnable: function() { onEnable: function () {
this.prefsPage = deluge.preferences.addPage( this.prefsPage = deluge.preferences.addPage(
new Deluge.ux.preferences.LabelPage() new Deluge.ux.preferences.LabelPage()
); );
@ -539,17 +536,17 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, {
this.registerTorrentStatus('label', _('Label')); this.registerTorrentStatus('label', _('Label'));
}, },
onAfterFilterCreate: function(sidebar, filter) { onAfterFilterCreate: function (sidebar, filter) {
if (filter.filter != 'label') return; if (filter.filter != 'label') return;
this.updateTorrentMenu(filter.getStates()); this.updateTorrentMenu(filter.getStates());
}, },
onFilterCreate: function(sidebar, filter) { onFilterCreate: function (sidebar, filter) {
if (filter.filter != 'label') return; if (filter.filter != 'label') return;
this.setFilter(filter); this.setFilter(filter);
}, },
onLabelAddClick: function() { onLabelAddClick: function () {
if (!this.addWindow) { if (!this.addWindow) {
this.addWindow = new Deluge.ux.AddLabelWindow(); this.addWindow = new Deluge.ux.AddLabelWindow();
this.addWindow.on('labeladded', this.onLabelAdded, this); this.addWindow.on('labeladded', this.onLabelAdded, this);
@ -557,7 +554,7 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, {
this.addWindow.show(); this.addWindow.show();
}, },
onLabelAdded: function(label) { onLabelAdded: function (label) {
var filter = deluge.sidebar.getFilter('label'); var filter = deluge.sidebar.getFilter('label');
var states = filter.getStates(); var states = filter.getStates();
var statesArray = []; var statesArray = [];
@ -582,7 +579,7 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, {
this.updateTorrentMenu(states); this.updateTorrentMenu(states);
}, },
onLabelContextMenu: function(dv, i, node, e) { onLabelContextMenu: function (dv, i, node, e) {
e.preventDefault(); e.preventDefault();
if (!this.labelMenu) this.createMenu(); if (!this.labelMenu) this.createMenu();
var r = dv.getRecord(node).get('filter'); var r = dv.getRecord(node).get('filter');
@ -597,7 +594,7 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, {
this.labelMenu.showAt(e.getXY()); this.labelMenu.showAt(e.getXY());
}, },
onLabelHeaderContextMenu: function(e, t) { onLabelHeaderContextMenu: function (e, t) {
e.preventDefault(); e.preventDefault();
if (!this.labelMenu) this.createMenu(); if (!this.labelMenu) this.createMenu();
this.labelMenu.items.get(1).setDisabled(true); this.labelMenu.items.get(1).setDisabled(true);
@ -605,18 +602,18 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, {
this.labelMenu.showAt(e.getXY()); this.labelMenu.showAt(e.getXY());
}, },
onLabelOptionsClick: function() { onLabelOptionsClick: function () {
if (!this.labelOpts) if (!this.labelOpts)
this.labelOpts = new Deluge.ux.LabelOptionsWindow(); this.labelOpts = new Deluge.ux.LabelOptionsWindow();
this.labelOpts.show(this.filter.getState()); this.labelOpts.show(this.filter.getState());
}, },
onLabelRemoveClick: function() { onLabelRemoveClick: function () {
var state = this.filter.getState(); var state = this.filter.getState();
deluge.client.label.remove(state, { deluge.client.label.remove(state, {
success: function() { success: function () {
deluge.ui.update(); deluge.ui.update();
this.torrentMenu.items.each(function(item) { this.torrentMenu.items.each(function (item) {
if (item.text != state) return; if (item.text != state) return;
this.torrentMenu.remove(item); this.torrentMenu.remove(item);
var i = item; var i = item;
@ -626,12 +623,12 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, {
}); });
}, },
onTorrentMenuClick: function(item, e) { onTorrentMenuClick: function (item, e) {
var ids = deluge.torrents.getSelectedIds(); var ids = deluge.torrents.getSelectedIds();
Ext.each(ids, function(id, i) { Ext.each(ids, function (id, i) {
if (ids.length == i + 1) { if (ids.length == i + 1) {
deluge.client.label.set_torrent(id, item.label, { deluge.client.label.set_torrent(id, item.label, {
success: function() { success: function () {
deluge.ui.update(); deluge.ui.update();
}, },
}); });

View File

@ -21,7 +21,7 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, {
layout: 'fit', layout: 'fit',
border: false, border: false,
initComponent: function() { initComponent: function () {
Deluge.ux.preferences.NotificationsPage.superclass.initComponent.call( Deluge.ux.preferences.NotificationsPage.superclass.initComponent.call(
this this
); );
@ -44,7 +44,7 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, {
xtype: 'checkbox', xtype: 'checkbox',
boxLabel: _('Enabled'), boxLabel: _('Enabled'),
listeners: { listeners: {
check: function(object, checked) { check: function (object, checked) {
this.setSmtpDisabled(!checked); this.setSmtpDisabled(!checked);
}, },
scope: this, scope: this,
@ -227,11 +227,11 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, {
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();
@ -239,7 +239,7 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, {
Ext.apply(this.viewConfig, { emptyText: text }); Ext.apply(this.viewConfig, { emptyText: text });
} }
}, },
loadData: function(data) { loadData: function (data) {
this.getStore().loadData(data); this.getStore().loadData(data);
if (this.viewReady) { if (this.viewReady) {
this.getView().updateHeaders(); this.getView().updateHeaders();
@ -259,7 +259,7 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, {
}, },
colModel: new Ext.grid.ColumnModel({ colModel: new Ext.grid.ColumnModel({
defaults: { defaults: {
renderer: function( renderer: function (
value, value,
meta, meta,
record, record,
@ -310,7 +310,7 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, {
], ],
}), }),
listeners: { listeners: {
cellclick: function(grid, rowIndex, colIndex, e) { cellclick: function (grid, rowIndex, colIndex, e) {
var record = grid.getStore().getAt(rowIndex); var record = grid.getStore().getAt(rowIndex);
var field = grid.getColumnModel().getDataIndex(colIndex); var field = grid.getColumnModel().getDataIndex(colIndex);
var value = record.get(field); var value = record.get(field);
@ -322,18 +322,18 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, {
} }
} }
}, },
beforeedit: function(e) { beforeedit: function (e) {
if (Ext.isBoolean(e.value)) { if (Ext.isBoolean(e.value)) {
return false; return false;
} }
return e.record.get('enabled'); return e.record.get('enabled');
}, },
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();
@ -341,13 +341,13 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, {
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) {
this.getStore().loadData(data); this.getStore().loadData(data);
if (this.viewReady) { if (this.viewReady) {
this.getView().updateHeaders(); this.getView().updateHeaders();
@ -374,9 +374,9 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, {
this.on('show', this.updateConfig, this); this.on('show', this.updateConfig, this);
}, },
updateConfig: function() { updateConfig: function () {
deluge.client.notifications.get_handled_events({ deluge.client.notifications.get_handled_events({
success: function(events) { success: function (events) {
var data = []; var data = [];
var keys = Ext.keys(events); var keys = Ext.keys(events);
for (var i = 0; i < keys.length; i++) { for (var i = 0; i < keys.length; i++) {
@ -388,7 +388,7 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, {
scope: this, scope: this,
}); });
deluge.client.notifications.get_config({ deluge.client.notifications.get_config({
success: function(config) { success: function (config) {
this.chkEnableEmail.setValue(config['smtp_enabled']); this.chkEnableEmail.setValue(config['smtp_enabled']);
this.setSmtpDisabled(!config['smtp_enabled']); this.setSmtpDisabled(!config['smtp_enabled']);
@ -420,7 +420,7 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, {
}); });
}, },
onApply: function() { onApply: function () {
var config = {}; var config = {};
config['smtp_enabled'] = this.chkEnableEmail.getValue(); config['smtp_enabled'] = this.chkEnableEmail.getValue();
@ -461,11 +461,11 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, {
deluge.client.notifications.set_config(config); deluge.client.notifications.set_config(config);
}, },
onOk: function() { onOk: function () {
this.onApply(); this.onApply();
}, },
onAddClick: function() { onAddClick: function () {
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({
@ -476,7 +476,7 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, {
this.recipientsFset.getComponent(0).startEditing(0, 0); this.recipientsFset.getComponent(0).startEditing(0, 0);
}, },
onRemoveClick: function() { onRemoveClick: function () {
var selections = this.recipientsFset var selections = this.recipientsFset
.getComponent(0) .getComponent(0)
.getSelectionModel() .getSelectionModel()
@ -488,7 +488,7 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, {
store.commitChanges(); store.commitChanges();
}, },
setSmtpDisabled: function(disable) { setSmtpDisabled: function (disable) {
this.hBoxHost.setDisabled(disable); this.hBoxHost.setDisabled(disable);
this.hBoxPort.setDisabled(disable); this.hBoxPort.setDisabled(disable);
this.hBoxUser.setDisabled(disable); this.hBoxUser.setDisabled(disable);
@ -498,7 +498,7 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, {
this.recipientsFset.getComponent(0).setDisabled(disable); this.recipientsFset.getComponent(0).setDisabled(disable);
}, },
onDestroy: function() { onDestroy: function () {
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);
@ -508,11 +508,11 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, {
Deluge.plugins.NotificationsPlugin = Ext.extend(Deluge.Plugin, { Deluge.plugins.NotificationsPlugin = Ext.extend(Deluge.Plugin, {
name: 'Notifications', name: 'Notifications',
onDisable: function() { onDisable: function () {
deluge.preferences.removePage(this.prefsPage); deluge.preferences.removePage(this.prefsPage);
}, },
onEnable: function() { onEnable: function () {
this.prefsPage = deluge.preferences.addPage( this.prefsPage = deluge.preferences.addPage(
new Deluge.ux.preferences.NotificationsPage() new Deluge.ux.preferences.NotificationsPage()
); );

View File

@ -42,7 +42,7 @@ except ImportError:
try: try:
require_version('Notify', '0.7') require_version('Notify', '0.7')
from gi.repository import Notify, GLib from gi.repository import GLib, Notify
except (ValueError, ImportError): except (ValueError, ImportError):
POPUP_AVAILABLE = False POPUP_AVAILABLE = False
else: else:

View File

@ -40,7 +40,7 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, {
], ],
daysOfWeek: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], daysOfWeek: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
initComponent: function() { initComponent: function () {
Deluge.ux.ScheduleSelector.superclass.initComponent.call(this); Deluge.ux.ScheduleSelector.superclass.initComponent.call(this);
// ExtJS' radiogroup implementation is very broken for styling. // ExtJS' radiogroup implementation is very broken for styling.
@ -57,7 +57,7 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, {
});*/ });*/
}, },
onRender: function(ct, position) { onRender: function (ct, position) {
Deluge.ux.ScheduleSelector.superclass.onRender.call(this, ct, position); Deluge.ux.ScheduleSelector.superclass.onRender.call(this, ct, position);
var dom = this.body.dom; var dom = this.body.dom;
@ -126,7 +126,7 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, {
Ext.each( Ext.each(
this.daysOfWeek, this.daysOfWeek,
function(day) { function (day) {
var cells = []; var cells = [];
var row = createEl(table, 'tr'); var row = createEl(table, 'tr');
var label = createEl(row, 'th'); var label = createEl(row, 'th');
@ -175,7 +175,7 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, {
); );
}, },
updateCell: function(cell) { updateCell: function (cell) {
// sanity check // sanity check
if (cell.currentValue == undefined) return; if (cell.currentValue == undefined) return;
@ -188,29 +188,29 @@ 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[ var brushes = Ext.get(this.body.dom).findParent('form').elements[
this.stateBrushName this.stateBrushName
]; ];
Ext.each(brushes, function(b) { Ext.each(brushes, function (b) {
if (b.checked) v = b.value; if (b.checked) v = b.value;
}); });
return v; return v;
}, },
onCellClick: function(event, cell) { onCellClick: function (event, cell) {
cell.oldValue = cell.currentValue; cell.oldValue = cell.currentValue;
this.dragAnchor = null; this.dragAnchor = null;
}, },
onCellMouseDown: function(event, cell) { onCellMouseDown: function (event, cell) {
this.dragAnchor = cell; this.dragAnchor = cell;
}, },
onCellMouseUp: function(event, cell) { onCellMouseUp: function (event, cell) {
// if we're dragging... // if we're dragging...
if (this.dragAnchor) { if (this.dragAnchor) {
// set all those between here and the anchor to the new values // set all those between here and the anchor to the new values
@ -226,7 +226,7 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, {
} }
}, },
onCellMouseOver: function(event, cell) { onCellMouseOver: function (event, cell) {
// LEFT TOOL TIP // LEFT TOOL TIP
// if it isn't showing and we're dragging, show it. // if it isn't showing and we're dragging, show it.
// 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.
@ -295,7 +295,7 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, {
// dragged into another day. Abort! Abort! // dragged into another day. Abort! Abort!
Ext.each( Ext.each(
this.daysOfWeek, this.daysOfWeek,
function(day) { function (day) {
this.revertCells(day, 0, 23); this.revertCells(day, 0, 23);
}, },
this this
@ -323,7 +323,7 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, {
} }
}, },
onCellMouseOut: function(event, cell) { onCellMouseOut: function (event, cell) {
if (!this.dragAnchor) this.hideCellLeftTooltip(); if (!this.dragAnchor) 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.
@ -333,7 +333,7 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, {
} }
}, },
previewCells: function(day, fromHour, toHour) { previewCells: function (day, fromHour, toHour) {
var cells = this.scheduleCells[day]; var cells = this.scheduleCells[day];
var curBrushValue = this.getCurrentBrushValue(); var curBrushValue = this.getCurrentBrushValue();
@ -348,7 +348,7 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, {
} }
}, },
revertCells: function(day, fromHour, toHour) { revertCells: function (day, fromHour, toHour) {
var cells = this.scheduleCells[day]; var cells = this.scheduleCells[day];
if (toHour > cells.length) toHour = cells.length; if (toHour > cells.length) toHour = cells.length;
@ -359,7 +359,7 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, {
} }
}, },
confirmCells: function(day, fromHour, toHour) { confirmCells: function (day, fromHour, toHour) {
var cells = this.scheduleCells[day]; var cells = this.scheduleCells[day];
if (toHour > cells.length) toHour = cells.length; if (toHour > cells.length) toHour = cells.length;
@ -371,7 +371,7 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, {
} }
}, },
showCellLeftTooltip: function(text, cell) { showCellLeftTooltip: function (text, cell) {
var tooltip = this.cellLeftTooltip; var tooltip = this.cellLeftTooltip;
if (!tooltip) { if (!tooltip) {
@ -400,19 +400,19 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, {
tooltip.style.visibility = 'visible'; tooltip.style.visibility = 'visible';
}, },
hideCellLeftTooltip: function() { hideCellLeftTooltip: function () {
if (this.cellLeftTooltip) { if (this.cellLeftTooltip) {
this.cellLeftTooltip.style.visibility = 'hidden'; this.cellLeftTooltip.style.visibility = 'hidden';
} }
}, },
isCellLeftTooltipHidden: function() { isCellLeftTooltipHidden: function () {
if (this.cellLeftTooltip) if (this.cellLeftTooltip)
return this.cellLeftTooltip.style.visibility == 'hidden'; return this.cellLeftTooltip.style.visibility == 'hidden';
else return true; else return true;
}, },
showCellRightTooltip: function(text, cell) { showCellRightTooltip: function (text, cell) {
var tooltip = this.cellRightTooltip; var tooltip = this.cellRightTooltip;
if (!tooltip) { if (!tooltip) {
@ -441,19 +441,19 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, {
tooltip.style.visibility = 'visible'; tooltip.style.visibility = 'visible';
}, },
hideCellRightTooltip: function() { hideCellRightTooltip: function () {
if (this.cellRightTooltip) { if (this.cellRightTooltip) {
this.cellRightTooltip.style.visibility = 'hidden'; this.cellRightTooltip.style.visibility = 'hidden';
} }
}, },
isCellRightTooltipHidden: function() { isCellRightTooltipHidden: function () {
if (this.cellRightTooltip) if (this.cellRightTooltip)
return this.cellRightTooltip.style.visibility == 'hidden'; return this.cellRightTooltip.style.visibility == 'hidden';
else return true; else return true;
}, },
getConfig: function() { getConfig: function () {
var config = []; var config = [];
for (var i = 0; i < 24; i++) { for (var i = 0; i < 24; i++) {
@ -471,7 +471,7 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, {
return config; return config;
}, },
setConfig: function(config) { setConfig: function (config) {
for (var i = 0; i < 24; i++) { for (var i = 0; i < 24; i++) {
var hourConfig = config[i]; var hourConfig = config[i];
@ -496,7 +496,7 @@ Deluge.ux.preferences.SchedulerPage = Ext.extend(Ext.Panel, {
header: false, header: false,
layout: 'fit', layout: 'fit',
initComponent: function() { initComponent: function () {
Deluge.ux.preferences.SchedulerPage.superclass.initComponent.call(this); Deluge.ux.preferences.SchedulerPage.superclass.initComponent.call(this);
this.form = this.add({ this.form = this.add({
@ -561,7 +561,7 @@ Deluge.ux.preferences.SchedulerPage = Ext.extend(Ext.Panel, {
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( Deluge.ux.preferences.SchedulerPage.superclass.onRender.call(
this, this,
ct, ct,
@ -572,7 +572,7 @@ Deluge.ux.preferences.SchedulerPage = Ext.extend(Ext.Panel, {
this.form.doLayout(); this.form.doLayout();
}, },
onApply: function() { onApply: function () {
// build settings object // build settings object
var config = {}; var config = {};
@ -586,13 +586,13 @@ Deluge.ux.preferences.SchedulerPage = Ext.extend(Ext.Panel, {
deluge.client.scheduler.set_config(config); deluge.client.scheduler.set_config(config);
}, },
onOk: function() { onOk: function () {
this.onApply(); this.onApply();
}, },
updateConfig: function() { updateConfig: function () {
deluge.client.scheduler.get_config({ deluge.client.scheduler.get_config({
success: function(config) { success: function (config) {
this.schedule.setConfig(config['button_state']); this.schedule.setConfig(config['button_state']);
this.downloadLimit.setValue(config['low_down']); this.downloadLimit.setValue(config['low_down']);
this.uploadLimit.setValue(config['low_up']); this.uploadLimit.setValue(config['low_up']);
@ -608,11 +608,11 @@ Deluge.ux.preferences.SchedulerPage = Ext.extend(Ext.Panel, {
Deluge.plugins.SchedulerPlugin = Ext.extend(Deluge.Plugin, { Deluge.plugins.SchedulerPlugin = Ext.extend(Deluge.Plugin, {
name: 'Scheduler', name: 'Scheduler',
onDisable: function() { onDisable: function () {
deluge.preferences.removePage(this.prefsPage); deluge.preferences.removePage(this.prefsPage);
}, },
onEnable: function() { onEnable: function () {
this.prefsPage = deluge.preferences.addPage( this.prefsPage = deluge.preferences.addPage(
new Deluge.ux.preferences.SchedulerPage() new Deluge.ux.preferences.SchedulerPage()
); );

View File

@ -10,7 +10,7 @@
*/ */
StatsPlugin = Ext.extend(Deluge.Plugin, { StatsPlugin = Ext.extend(Deluge.Plugin, {
constructor: function(config) { constructor: function (config) {
config = Ext.apply( config = Ext.apply(
{ {
name: 'Stats', name: 'Stats',
@ -20,8 +20,8 @@ StatsPlugin = Ext.extend(Deluge.Plugin, {
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

@ -72,14 +72,15 @@ class StatsTestCase(BaseTestCase):
Not strictly a unit test, but tests if calls do not fail... Not strictly a unit test, but tests if calls do not fail...
""" """
from deluge.ui.gtkui.gtkui import DEFAULT_PREFS from deluge_stats import graph, gtkui
from deluge.ui.gtkui.preferences import Preferences
from deluge.ui.gtkui.mainwindow import MainWindow
from deluge.configmanager import ConfigManager from deluge.configmanager import ConfigManager
from deluge.ui.gtkui.gtkui import DEFAULT_PREFS
from deluge.ui.gtkui.mainwindow import MainWindow
from deluge.ui.gtkui.pluginmanager import PluginManager from deluge.ui.gtkui.pluginmanager import PluginManager
from deluge.ui.gtkui.preferences import Preferences
from deluge.ui.gtkui.torrentdetails import TorrentDetails from deluge.ui.gtkui.torrentdetails import TorrentDetails
from deluge.ui.gtkui.torrentview import TorrentView from deluge.ui.gtkui.torrentview import TorrentView
from deluge_stats import graph, gtkui
ConfigManager('gtkui.conf', defaults=DEFAULT_PREFS) ConfigManager('gtkui.conf', defaults=DEFAULT_PREFS)

View File

@ -10,7 +10,7 @@
*/ */
TogglePlugin = Ext.extend(Deluge.Plugin, { TogglePlugin = Ext.extend(Deluge.Plugin, {
constructor: function(config) { constructor: function (config) {
config = Ext.apply( config = Ext.apply(
{ {
name: 'Toggle', name: 'Toggle',
@ -20,8 +20,8 @@ TogglePlugin = Ext.extend(Deluge.Plugin, {
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

@ -26,8 +26,8 @@ try:
from urllib.request import url2pathname from urllib.request import url2pathname
except ImportError: except ImportError:
# PY2 fallback # PY2 fallback
from urlparse import urlparse # pylint: disable=ungrouped-imports
from urllib import url2pathname # pylint: disable=ungrouped-imports from urllib import url2pathname # pylint: disable=ungrouped-imports
from urlparse import urlparse # pylint: disable=ungrouped-imports
class Command(BaseCommand): class Command(BaseCommand):

View File

@ -106,8 +106,8 @@ class Command(BaseCommand):
elif options.install: elif options.install:
import os.path import os.path
from base64 import b64encode
import shutil import shutil
from base64 import b64encode
filepath = options.install filepath = options.install

View File

@ -112,9 +112,9 @@ class Console(UI):
) )
# To properly print help message for the console commands ( e.g. deluge-console info -h), # To properly print help message for the console commands ( e.g. deluge-console info -h),
# we add a subparser for each command which will trigger the help/usage when given # we add a subparser for each command which will trigger the help/usage when given
from deluge.ui.console.parser import ( from deluge.ui.console.parser import ( # import here because (see top)
ConsoleCommandParser, ConsoleCommandParser,
) # import here because (see top) )
self.console_parser = ConsoleCommandParser( self.console_parser = ConsoleCommandParser(
parents=[self.parser], parents=[self.parser],

View File

@ -26,9 +26,9 @@ except ImportError:
try: try:
import signal import signal
from fcntl import ioctl
import termios
import struct import struct
import termios
from fcntl import ioctl
except ImportError: except ImportError:
pass pass

View File

@ -220,7 +220,7 @@ class TorrentDetail(BaseMode, PopupsHandler):
self.refresh() self.refresh()
def build_file_list(self, torrent_files, progress, priority): def build_file_list(self, torrent_files, progress, priority):
""" Split file list from torrent state into a directory tree. """Split file list from torrent state into a directory tree.
Returns: Returns:

View File

@ -60,14 +60,14 @@ class ConsoleCommandParser(ConsoleBaseParser):
def parse_args(self, args=None): def parse_args(self, args=None):
"""Parse known UI args and handle common and process group options. """Parse known UI args and handle common and process group options.
Notes: Notes:
If started by deluge entry script this has already been done. If started by deluge entry script this has already been done.
Args: Args:
args (list, optional): The arguments to parse. args (list, optional): The arguments to parse.
Returns: Returns:
argparse.Namespace: The parsed arguments. argparse.Namespace: The parsed arguments.
""" """
from deluge.ui.ui_entry import AMBIGUOUS_CMD_ARGS from deluge.ui.ui_entry import AMBIGUOUS_CMD_ARGS
@ -118,9 +118,9 @@ class OptionParser(ConsoleBaseParser):
def error(self, msg): def error(self, msg):
"""error(msg : string) """error(msg : string)
Print a usage message incorporating 'msg' to stderr and exit. Print a usage message incorporating 'msg' to stderr and exit.
If you override this in a subclass, it should not return -- it If you override this in a subclass, it should not return -- it
should either exit or raise an exception. should either exit or raise an exception.
""" """
raise OptionParserError(msg) raise OptionParserError(msg)

View File

@ -1061,9 +1061,9 @@ class ComboInput(InputField):
# No match, so start at beginning # No match, so start at beginning
select_in_range(0, selected) select_in_range(0, selected)
from deluge.ui.console.widgets.popup import ( from deluge.ui.console.widgets.popup import ( # Must import here
SelectablePopup, SelectablePopup,
) # Must import here )
select_popup = SelectablePopup( select_popup = SelectablePopup(
self.parent, self.parent,

View File

@ -40,9 +40,10 @@ class Gtk(UI):
def start(self): def start(self):
super(Gtk, self).start() super(Gtk, self).start()
from .gtkui import GtkUI
import deluge.common import deluge.common
from .gtkui import GtkUI
def run(options): def run(options):
try: try:
gtkui = GtkUI(options) gtkui = GtkUI(options)

View File

@ -159,8 +159,8 @@ class ErrorDialog(BaseDialog):
) )
if traceback: if traceback:
import traceback
import sys import sys
import traceback
tb = sys.exc_info() tb = sys.exc_info()
tb = traceback.format_exc(tb[2]) tb = traceback.format_exc(tb[2])

View File

@ -75,7 +75,7 @@ set_prgname('deluge')
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
try: try:
from setproctitle import setproctitle, getproctitle from setproctitle import getproctitle, setproctitle
except ImportError: except ImportError:
def setproctitle(title): def setproctitle(title):

View File

@ -31,8 +31,8 @@ try:
from urllib.request import url2pathname from urllib.request import url2pathname
except ImportError: except ImportError:
# PY2 fallback # PY2 fallback
from urlparse import urlparse # pylint: disable=ungrouped-imports
from urllib import url2pathname # pylint: disable=ungrouped-imports from urllib import url2pathname # pylint: disable=ungrouped-imports
from urlparse import urlparse # pylint: disable=ungrouped-imports
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -84,8 +84,8 @@ class IPCInterface(component.Component):
if windows_check(): if windows_check():
# If we're on windows we need to check the global mutex to see if deluge is # If we're on windows we need to check the global mutex to see if deluge is
# already running. # already running.
import win32event
import win32api import win32api
import win32event
import winerror import winerror
self.mutex = win32event.CreateMutex(None, False, 'deluge') self.mutex = win32event.CreateMutex(None, False, 'deluge')

View File

@ -68,10 +68,10 @@ class ListView(object):
class TreeviewColumn(Gtk.TreeViewColumn, object): class TreeviewColumn(Gtk.TreeViewColumn, object):
""" """
TreeViewColumn does not signal right-click events, and we need them TreeViewColumn does not signal right-click events, and we need them
This subclass is equivalent to TreeViewColumn, but it signals these events This subclass is equivalent to TreeViewColumn, but it signals these events
Most of the code of this class comes from Quod Libet (http://www.sacredchao.net/quodlibet) Most of the code of this class comes from Quod Libet (http://www.sacredchao.net/quodlibet)
""" """
__gsignals__ = { __gsignals__ = {
@ -281,7 +281,7 @@ class ListView(object):
def save_state(self, filename): def save_state(self, filename):
"""Saves the listview state (column positions and visibility) to """Saves the listview state (column positions and visibility) to
filename.""" filename."""
# A list of ListViewColumnStates # A list of ListViewColumnStates
state = [] state = []
@ -627,8 +627,7 @@ class ListView(object):
unique=False, unique=False,
default_sort=False, default_sort=False,
): ):
"""Add a text column to the listview. Only the header name is required. """Add a text column to the listview. Only the header name is required."""
"""
render = Gtk.CellRendererText() render = Gtk.CellRendererText()
self.add_column( self.add_column(
header, header,

View File

@ -305,8 +305,8 @@ class PeersTab(Tab):
peer_ip = peer['ip'] peer_ip = peer['ip']
else: else:
# This is an IPv6 address # This is an IPv6 address
import socket
import binascii import binascii
import socket
# Split out the :port # Split out the :port
ip = ':'.join(peer['ip'].split(':')[:-1]) ip = ':'.join(peer['ip'].split(':')[:-1])

View File

@ -1180,8 +1180,8 @@ class Preferences(component.Component):
chooser.destroy() chooser.destroy()
return return
from base64 import b64encode
import shutil import shutil
from base64 import b64encode
filename = os.path.split(filepath)[1] filename = os.path.split(filepath)[1]
shutil.copyfile(filepath, os.path.join(get_config_dir(), 'plugins', filename)) shutil.copyfile(filepath, os.path.join(get_config_dir(), 'plugins', filename))

View File

@ -112,11 +112,11 @@ class TorrentDetails(component.Component):
self.tabs = {} self.tabs = {}
# Add the default tabs # Add the default tabs
from .status_tab import StatusTab
from .details_tab import DetailsTab from .details_tab import DetailsTab
from .files_tab import FilesTab from .files_tab import FilesTab
from .peers_tab import PeersTab
from .options_tab import OptionsTab from .options_tab import OptionsTab
from .peers_tab import PeersTab
from .status_tab import StatusTab
from .trackers_tab import TrackersTab from .trackers_tab import TrackersTab
default_tabs = { default_tabs = {

View File

@ -28,16 +28,16 @@ Deluge.about.AboutWindow = Ext.extend(Ext.Window, {
}, },
buttonAlign: 'center', buttonAlign: 'center',
initComponent: function() { initComponent: function () {
Deluge.about.AboutWindow.superclass.initComponent.call(this); Deluge.about.AboutWindow.superclass.initComponent.call(this);
this.addEvents({ this.addEvents({
build_ready: true, build_ready: true,
}); });
var self = this; var self = this;
var libtorrent = function() { var libtorrent = function () {
deluge.client.core.get_libtorrent_version({ deluge.client.core.get_libtorrent_version({
success: function(lt_version) { success: function (lt_version) {
comment += '<br/>' + _('libtorrent:') + ' ' + lt_version; comment += '<br/>' + _('libtorrent:') + ' ' + lt_version;
Ext.getCmp('about_comment').setText(comment, false); Ext.getCmp('about_comment').setText(comment, false);
self.fireEvent('build_ready'); self.fireEvent('build_ready');
@ -57,10 +57,10 @@ Deluge.about.AboutWindow = Ext.extend(Ext.Window, {
client_version + client_version +
'<br/>'; '<br/>';
deluge.client.web.connected({ deluge.client.web.connected({
success: function(connected) { success: function (connected) {
if (connected) { if (connected) {
deluge.client.daemon.get_version({ deluge.client.daemon.get_version({
success: function(server_version) { success: function (server_version) {
comment += comment +=
_('Server:') + ' ' + server_version + '<br/>'; _('Server:') + ' ' + server_version + '<br/>';
libtorrent(); libtorrent();
@ -70,7 +70,7 @@ Deluge.about.AboutWindow = Ext.extend(Ext.Window, {
this.fireEvent('build_ready'); this.fireEvent('build_ready');
} }
}, },
failure: function() { failure: function () {
this.fireEvent('build_ready'); this.fireEvent('build_ready');
}, },
scope: this, scope: this,
@ -111,19 +111,19 @@ Deluge.about.AboutWindow = Ext.extend(Ext.Window, {
this.addButton(_('Close'), this.onCloseClick, this); this.addButton(_('Close'), this.onCloseClick, this);
}, },
show: function() { show: function () {
this.on('build_ready', function() { this.on('build_ready', function () {
Deluge.about.AboutWindow.superclass.show.call(this); Deluge.about.AboutWindow.superclass.show.call(this);
}); });
}, },
onCloseClick: function() { onCloseClick: function () {
this.close(); this.close();
}, },
}); });
Ext.namespace('Deluge'); Ext.namespace('Deluge');
Deluge.About = function() { Deluge.About = function () {
new Deluge.about.AboutWindow().show(); new Deluge.about.AboutWindow().show();
}; };

View File

@ -24,7 +24,7 @@ Deluge.AddConnectionWindow = Ext.extend(Ext.Window, {
bodyStyle: 'padding: 10px 5px;', bodyStyle: 'padding: 10px 5px;',
closeAction: 'hide', closeAction: 'hide',
initComponent: function() { initComponent: function () {
Deluge.AddConnectionWindow.superclass.initComponent.call(this); Deluge.AddConnectionWindow.superclass.initComponent.call(this);
this.addEvents('hostadded'); this.addEvents('hostadded');
@ -80,7 +80,7 @@ Deluge.AddConnectionWindow = Ext.extend(Ext.Window, {
}); });
}, },
onAddClick: function() { onAddClick: function () {
var values = this.form.getForm().getValues(); var values = this.form.getForm().getValues();
deluge.client.web.add_host( deluge.client.web.add_host(
values.host, values.host,
@ -88,7 +88,7 @@ Deluge.AddConnectionWindow = Ext.extend(Ext.Window, {
values.username, values.username,
values.password, values.password,
{ {
success: function(result) { success: function (result) {
if (!result[0]) { if (!result[0]) {
Ext.MessageBox.show({ Ext.MessageBox.show({
title: _('Error'), title: _('Error'),
@ -111,7 +111,7 @@ Deluge.AddConnectionWindow = Ext.extend(Ext.Window, {
); );
}, },
onHide: function() { onHide: function () {
this.form.getForm().reset(); this.form.getForm().reset();
}, },
}); });

View File

@ -12,7 +12,7 @@ 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',
@ -36,7 +36,7 @@ Deluge.AddTrackerWindow = Ext.extend(Ext.Window, {
closeAction: 'hide', closeAction: 'hide',
iconCls: 'x-deluge-edit-trackers', iconCls: 'x-deluge-edit-trackers',
initComponent: function() { initComponent: function () {
Deluge.AddTrackerWindow.superclass.initComponent.call(this); Deluge.AddTrackerWindow.superclass.initComponent.call(this);
this.addButton(_('Cancel'), this.onCancelClick, this); this.addButton(_('Cancel'), this.onCancelClick, this);
@ -59,17 +59,14 @@ Deluge.AddTrackerWindow = Ext.extend(Ext.Window, {
}); });
}, },
onAddClick: function() { onAddClick: function () {
var trackers = this.form var trackers = this.form.getForm().findField('trackers').getValue();
.getForm()
.findField('trackers')
.getValue();
trackers = trackers.split('\n'); trackers = trackers.split('\n');
var cleaned = []; var cleaned = [];
Ext.each( Ext.each(
trackers, trackers,
function(tracker) { function (tracker) {
if (Ext.form.VTypes.trackerUrl(tracker)) { if (Ext.form.VTypes.trackerUrl(tracker)) {
cleaned.push(tracker); cleaned.push(tracker);
} }
@ -78,17 +75,11 @@ Deluge.AddTrackerWindow = Ext.extend(Ext.Window, {
); );
this.fireEvent('add', cleaned); this.fireEvent('add', cleaned);
this.hide(); this.hide();
this.form this.form.getForm().findField('trackers').setValue('');
.getForm()
.findField('trackers')
.setValue('');
}, },
onCancelClick: function() { onCancelClick: function () {
this.form this.form.getForm().findField('trackers').setValue('');
.getForm()
.findField('trackers')
.setValue('');
this.hide(); this.hide();
}, },
}); });

View File

@ -31,7 +31,7 @@ Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, {
* Fires when the client has retrieved the list of methods from the server. * Fires when the client has retrieved the list of methods from the server.
* @param {Ext.ux.util.RpcClient} this * @param {Ext.ux.util.RpcClient} this
*/ */
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;
@ -44,14 +44,14 @@ Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, {
this.reloadMethods(); this.reloadMethods();
}, },
reloadMethods: function() { reloadMethods: function () {
this._execute('system.listMethods', { this._execute('system.listMethods', {
success: this._setMethods, success: this._setMethods,
scope: this, scope: this,
}); });
}, },
_execute: function(method, options) { _execute: function (method, options) {
options = options || {}; options = options || {};
options.params = options.params || []; options.params = options.params || [];
options.id = this._id; options.id = this._id;
@ -74,7 +74,7 @@ Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, {
}); });
}, },
_onFailure: function(response, requestOptions) { _onFailure: function (response, requestOptions) {
var options = requestOptions.options; var options = requestOptions.options;
errorObj = { errorObj = {
id: options.id, id: options.id,
@ -100,7 +100,7 @@ Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, {
} }
}, },
_onSuccess: function(response, requestOptions) { _onSuccess: function (response, requestOptions) {
var responseObj = Ext.decode(response.responseText); var responseObj = Ext.decode(response.responseText);
var options = requestOptions.options; var options = requestOptions.options;
if (responseObj.error) { if (responseObj.error) {
@ -138,9 +138,9 @@ Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, {
} }
}, },
_parseArgs: function(args) { _parseArgs: function (args) {
var params = []; var params = [];
Ext.each(args, function(arg) { Ext.each(args, function (arg) {
params.push(arg); params.push(arg);
}); });
@ -149,7 +149,7 @@ Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, {
var keys = Ext.keys(options), var keys = Ext.keys(options),
isOption = false; 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;
}); });
@ -165,15 +165,15 @@ Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, {
return options; return options;
}, },
_setMethods: function(methods) { _setMethods: function (methods) {
var components = {}, var components = {},
self = this; self = this;
Ext.each(methods, function(method) { Ext.each(methods, function (method) {
var parts = method.split('.'); var parts = method.split('.');
var component = components[parts[0]] || {}; var component = components[parts[0]] || {};
var fn = function() { var fn = function () {
var options = self._parseArgs(arguments); var options = self._parseArgs(arguments);
return self._execute(method, options); return self._execute(method, options);
}; };
@ -186,7 +186,7 @@ Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, {
} }
Ext.each( Ext.each(
this._components, this._components,
function(component) { function (component) {
if (!component in components) { if (!component in components) {
delete this[component]; delete this[component];
} }

View File

@ -21,7 +21,7 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, {
title: _('Connection Manager'), title: _('Connection Manager'),
iconCls: 'x-deluge-connect-window-icon', iconCls: 'x-deluge-connect-window-icon',
initComponent: function() { initComponent: function () {
Deluge.ConnectionManager.superclass.initComponent.call(this); Deluge.ConnectionManager.superclass.initComponent.call(this);
this.on('hide', this.onHide, this); this.on('hide', this.onHide, this);
this.on('show', this.onShow, this); this.on('show', this.onShow, this);
@ -133,9 +133,9 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, {
* Check to see if the the web interface is currently connected * Check to see if the the web interface is currently connected
* to a Deluge Daemon and show the Connection Manager if not. * to a Deluge Daemon and show the Connection Manager if not.
*/ */
checkConnected: function() { checkConnected: function () {
deluge.client.web.connected({ deluge.client.web.connected({
success: function(connected) { success: function (connected) {
if (connected) { if (connected) {
deluge.events.fire('connect'); deluge.events.fire('connect');
} else { } else {
@ -146,7 +146,7 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, {
}); });
}, },
disconnect: function(show) { disconnect: function (show) {
deluge.events.fire('disconnect'); deluge.events.fire('disconnect');
if (show) { if (show) {
if (this.isVisible()) return; if (this.isVisible()) return;
@ -154,15 +154,15 @@ 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,
}); });
}, },
update: function() { update: function () {
this.list.getStore().each(function(r) { this.list.getStore().each(function (r) {
deluge.client.web.get_host_status(r.id, { deluge.client.web.get_host_status(r.id, {
success: this.onGetHostStatus, success: this.onGetHostStatus,
scope: this, scope: this,
@ -175,7 +175,7 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, {
* passed in records host state. * passed in records host state.
* @param {Ext.data.Record} record The hosts record to update the UI for * @param {Ext.data.Record} record The hosts record to update the UI for
*/ */
updateButtons: function(record) { updateButtons: function (record) {
var button = this.buttons[1], var button = this.buttons[1],
status = record.get('status'); status = record.get('status');
@ -209,7 +209,7 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, {
}, },
// private // private
onAddClick: function(button, e) { onAddClick: function (button, e) {
if (!this.addWindow) { if (!this.addWindow) {
this.addWindow = new Deluge.AddConnectionWindow(); this.addWindow = new Deluge.AddConnectionWindow();
this.addWindow.on('hostadded', this.onHostChange, this); this.addWindow.on('hostadded', this.onHostChange, this);
@ -218,7 +218,7 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, {
}, },
// private // private
onEditClick: function(button, e) { onEditClick: function (button, e) {
var connection = this.list.getSelectedRecords()[0]; var connection = this.list.getSelectedRecords()[0];
if (!connection) return; if (!connection) return;
@ -230,24 +230,24 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, {
}, },
// private // private
onHostChange: function() { onHostChange: function () {
this.loadHosts(); this.loadHosts();
}, },
// private // private
onClose: function(e) { onClose: function (e) {
this.hide(); this.hide();
}, },
// private // private
onConnect: function(e) { onConnect: function (e) {
var selected = this.list.getSelectedRecords()[0]; var selected = this.list.getSelectedRecords()[0];
if (!selected) return; if (!selected) return;
var me = this; var me = this;
var disconnect = function() { var disconnect = function () {
deluge.client.web.disconnect({ deluge.client.web.disconnect({
success: function(result) { success: function (result) {
this.update(this); this.update(this);
deluge.events.fire('disconnect'); deluge.events.fire('disconnect');
}, },
@ -268,11 +268,11 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, {
var id = selected.id; var id = selected.id;
deluge.client.web.connect(id, { deluge.client.web.connect(id, {
success: function(methods) { success: function (methods) {
deluge.client.reloadMethods(); deluge.client.reloadMethods();
deluge.client.on( deluge.client.on(
'connected', 'connected',
function(e) { function (e) {
deluge.events.fire('connect'); deluge.events.fire('connect');
}, },
this, this,
@ -285,11 +285,11 @@ 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( Ext.each(
hosts, hosts,
function(host) { function (host) {
deluge.client.web.get_host_status(host[0], { deluge.client.web.get_host_status(host[0], {
success: this.onGetHostStatus, success: this.onGetHostStatus,
scope: this, scope: this,
@ -300,7 +300,7 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, {
}, },
// 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]);
@ -311,19 +311,19 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, {
}, },
// private // private
onHide: function() { onHide: function () {
if (this.running) window.clearInterval(this.running); if (this.running) window.clearInterval(this.running);
}, },
// private // private
onLogin: function() { onLogin: function () {
if (deluge.config.first_login) { if (deluge.config.first_login) {
Ext.MessageBox.confirm( Ext.MessageBox.confirm(
_('Change Default Password'), _('Change Default Password'),
_( _(
'We recommend changing the default password.<br><br>Would you like to change it now?' '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();
@ -339,7 +339,7 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, {
}, },
// private // private
onLogout: function() { onLogout: function () {
this.disconnect(); this.disconnect();
if (!this.hidden && this.rendered) { if (!this.hidden && this.rendered) {
this.hide(); this.hide();
@ -347,12 +347,12 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, {
}, },
// private // private
onRemoveClick: function(button) { onRemoveClick: function (button) {
var connection = this.list.getSelectedRecords()[0]; var connection = this.list.getSelectedRecords()[0];
if (!connection) return; if (!connection) return;
deluge.client.web.remove_host(connection.id, { deluge.client.web.remove_host(connection.id, {
success: function(result) { success: function (result) {
if (!result) { if (!result) {
Ext.MessageBox.show({ Ext.MessageBox.show({
title: _('Error'), title: _('Error'),
@ -371,7 +371,7 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, {
}, },
// private // private
onSelectionChanged: function(list, selections) { onSelectionChanged: function (list, selections) {
if (selections[0]) { if (selections[0]) {
this.editHostButton.enable(); this.editHostButton.enable();
this.removeHostButton.enable(); this.removeHostButton.enable();
@ -387,7 +387,7 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, {
// FIXME: Find out why this is being fired twice // FIXME: Find out why this is being fired twice
// private // private
onShow: function() { onShow: function () {
if (!this.addHostButton) { if (!this.addHostButton) {
var bbar = this.panel.getBottomToolbar(); var bbar = this.panel.getBottomToolbar();
this.addHostButton = bbar.items.get('cm-add'); this.addHostButton = bbar.items.get('cm-add');
@ -401,7 +401,7 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, {
}, },
// private // private
onStopClick: function(button, e) { onStopClick: function (button, e) {
var connection = this.list.getSelectedRecords()[0]; var connection = this.list.getSelectedRecords()[0];
if (!connection) return; if (!connection) return;
@ -411,7 +411,7 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, {
} else { } else {
// This means we need to stop the daemon // This means we need to stop the daemon
deluge.client.web.stop_daemon(connection.id, { deluge.client.web.stop_daemon(connection.id, {
success: function(result) { success: function (result) {
if (!result[0]) { if (!result[0]) {
Ext.MessageBox.show({ Ext.MessageBox.show({
title: _('Error'), title: _('Error'),

View File

@ -25,21 +25,19 @@ Ext.state.Manager.setProvider(
// 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) text = String(text).replace('<', '&lt;').replace('>', '&gt;');
.replace('<', '&lt;')
.replace('>', '&gt;');
return text.replace('&', '&amp;'); return text.replace('&', '&amp;');
}, },
isObjectEmpty: function(obj) { isObjectEmpty: function (obj) {
for (var i in obj) { for (var i in obj) {
return false; return false;
} }
return true; return true;
}, },
areObjectsEqual: function(obj1, obj2) { areObjectsEqual: function (obj1, obj2) {
var equal = true; var equal = true;
if (!obj1 || !obj2) return false; if (!obj1 || !obj2) return false;
for (var i in obj1) { for (var i in obj1) {
@ -50,7 +48,7 @@ Ext.apply(Ext, {
return equal; return equal;
}, },
keys: function(obj) { keys: function (obj) {
var keys = []; var keys = [];
for (var i in obj) for (var i in obj)
if (obj.hasOwnProperty(i)) { if (obj.hasOwnProperty(i)) {
@ -59,7 +57,7 @@ Ext.apply(Ext, {
return keys; return keys;
}, },
values: function(obj) { values: function (obj) {
var values = []; var values = [];
for (var i in obj) { for (var i in obj) {
if (obj.hasOwnProperty(i)) { if (obj.hasOwnProperty(i)) {
@ -69,7 +67,7 @@ Ext.apply(Ext, {
return values; return values;
}, },
splat: function(obj) { splat: function (obj) {
var type = Ext.type(obj); var type = Ext.type(obj);
return type ? (type != 'array' ? [obj] : obj) : []; return type ? (type != 'array' ? [obj] : obj) : [];
}, },
@ -106,7 +104,7 @@ Ext.apply(Deluge, {
* @param {String} text The text to display on the bar * @param {String} text The text to display on the bar
* @param {Number} modified Amount to subtract from the width allowing for fixes * @param {Number} modified Amount to subtract from the width allowing for fixes
*/ */
progressBar: function(progress, width, text, modifier) { progressBar: function (progress, width, text, modifier) {
modifier = Ext.value(modifier, 10); modifier = Ext.value(modifier, 10);
var progressWidth = ((width / 100.0) * progress).toFixed(0); var progressWidth = ((width / 100.0) * progress).toFixed(0);
var barWidth = progressWidth - 1; var barWidth = progressWidth - 1;
@ -125,7 +123,7 @@ Ext.apply(Deluge, {
* Constructs a new instance of the specified plugin. * Constructs a new instance of the specified plugin.
* @param {String} name The plugin name to create * @param {String} name The plugin name to create
*/ */
createPlugin: function(name) { createPlugin: function (name) {
return new Deluge.pluginStore[name](); return new Deluge.pluginStore[name]();
}, },
@ -133,7 +131,7 @@ Ext.apply(Deluge, {
* Check to see if a plugin has been registered. * Check to see if a plugin has been registered.
* @param {String} name The plugin name to check * @param {String} name The plugin name to check
*/ */
hasPlugin: function(name) { hasPlugin: function (name) {
return Deluge.pluginStore[name] ? true : false; return Deluge.pluginStore[name] ? true : false;
}, },
@ -142,7 +140,7 @@ Ext.apply(Deluge, {
* @param {String} name The plugin name to register * @param {String} name The plugin name to register
* @param {Plugin} plugin The plugin to register * @param {Plugin} plugin The plugin to register
*/ */
registerPlugin: function(name, plugin) { registerPlugin: function (name, plugin) {
Deluge.pluginStore[name] = plugin; Deluge.pluginStore[name] = plugin;
}, },
}); });

View File

@ -24,7 +24,7 @@ Deluge.EditConnectionWindow = Ext.extend(Ext.Window, {
bodyStyle: 'padding: 10px 5px;', bodyStyle: 'padding: 10px 5px;',
closeAction: 'hide', closeAction: 'hide',
initComponent: function() { initComponent: function () {
Deluge.EditConnectionWindow.superclass.initComponent.call(this); Deluge.EditConnectionWindow.superclass.initComponent.call(this);
this.addEvents('hostedited'); this.addEvents('hostedited');
@ -80,17 +80,11 @@ Deluge.EditConnectionWindow = Ext.extend(Ext.Window, {
}); });
}, },
show: function(connection) { show: function (connection) {
Deluge.EditConnectionWindow.superclass.show.call(this); Deluge.EditConnectionWindow.superclass.show.call(this);
this.form this.form.getForm().findField('host').setValue(connection.get('host'));
.getForm() this.form.getForm().findField('port').setValue(connection.get('port'));
.findField('host')
.setValue(connection.get('host'));
this.form
.getForm()
.findField('port')
.setValue(connection.get('port'));
this.form this.form
.getForm() .getForm()
.findField('username') .findField('username')
@ -98,7 +92,7 @@ Deluge.EditConnectionWindow = Ext.extend(Ext.Window, {
this.host_id = connection.id; 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( deluge.client.web.edit_host(
this.host_id, this.host_id,
@ -107,7 +101,7 @@ Deluge.EditConnectionWindow = Ext.extend(Ext.Window, {
values.username, values.username,
values.password, values.password,
{ {
success: function(result) { success: function (result) {
if (!result) { if (!result) {
console.log(result); console.log(result);
Ext.MessageBox.show({ Ext.MessageBox.show({
@ -128,7 +122,7 @@ Deluge.EditConnectionWindow = Ext.extend(Ext.Window, {
); );
}, },
onHide: function() { onHide: function () {
this.form.getForm().reset(); this.form.getForm().reset();
}, },
}); });

View File

@ -27,7 +27,7 @@ Deluge.EditTrackerWindow = Ext.extend(Ext.Window, {
closeAction: 'hide', closeAction: 'hide',
iconCls: 'x-deluge-edit-trackers', iconCls: 'x-deluge-edit-trackers',
initComponent: function() { initComponent: function () {
Deluge.EditTrackerWindow.superclass.initComponent.call(this); Deluge.EditTrackerWindow.superclass.initComponent.call(this);
this.addButton(_('Cancel'), this.onCancelClick, this); this.addButton(_('Cancel'), this.onCancelClick, this);
@ -50,32 +50,23 @@ Deluge.EditTrackerWindow = Ext.extend(Ext.Window, {
}); });
}, },
show: function(record) { show: function (record) {
Deluge.EditTrackerWindow.superclass.show.call(this); Deluge.EditTrackerWindow.superclass.show.call(this);
this.record = record; this.record = record;
this.form this.form.getForm().findField('tracker').setValue(record.data['url']);
.getForm()
.findField('tracker')
.setValue(record.data['url']);
}, },
onCancelClick: function() { onCancelClick: function () {
this.hide(); this.hide();
}, },
onHide: function() { onHide: function () {
this.form this.form.getForm().findField('tracker').setValue('');
.getForm()
.findField('tracker')
.setValue('');
}, },
onSaveClick: function() { onSaveClick: function () {
var url = this.form var url = this.form.getForm().findField('tracker').getValue();
.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

@ -28,7 +28,7 @@ Deluge.EditTrackersWindow = Ext.extend(Ext.Window, {
closeAction: 'hide', closeAction: 'hide',
iconCls: 'x-deluge-edit-trackers', iconCls: 'x-deluge-edit-trackers',
initComponent: function() { initComponent: function () {
Deluge.EditTrackersWindow.superclass.initComponent.call(this); Deluge.EditTrackersWindow.superclass.initComponent.call(this);
this.addButton(_('Cancel'), this.onCancelClick, this); this.addButton(_('Cancel'), this.onCancelClick, this);
@ -111,18 +111,18 @@ Deluge.EditTrackersWindow = Ext.extend(Ext.Window, {
}); });
}, },
onAddClick: function() { onAddClick: function () {
this.addWindow.show(); this.addWindow.show();
}, },
onAddTrackers: function(trackers) { onAddTrackers: function (trackers) {
var store = this.list.getStore(); var store = this.list.getStore();
Ext.each( Ext.each(
trackers, trackers,
function(tracker) { function (tracker) {
var duplicate = false, var duplicate = false,
heightestTier = -1; heightestTier = -1;
store.each(function(record) { store.each(function (record) {
if (record.get('tier') > heightestTier) { if (record.get('tier') > heightestTier) {
heightestTier = record.get('tier'); heightestTier = record.get('tier');
} }
@ -143,27 +143,27 @@ Deluge.EditTrackersWindow = Ext.extend(Ext.Window, {
); );
}, },
onCancelClick: function() { onCancelClick: function () {
this.hide(); this.hide();
}, },
onEditClick: function() { onEditClick: function () {
var selected = this.list.getSelectedRecords()[0]; var selected = this.list.getSelectedRecords()[0];
if (!selected) return; if (!selected) return;
this.editWindow.show(selected); this.editWindow.show(selected);
}, },
onHide: function() { onHide: function () {
this.list.getStore().removeAll(); this.list.getStore().removeAll();
}, },
onListNodeDblClicked: function(list, index, node, e) { onListNodeDblClicked: function (list, index, node, e) {
this.editWindow.show(this.list.getRecord(node)); this.editWindow.show(this.list.getRecord(node));
}, },
onOkClick: function() { onOkClick: function () {
var trackers = []; var trackers = [];
this.list.getStore().each(function(record) { this.list.getStore().each(function (record) {
trackers.push({ trackers.push({
tier: record.get('tier'), tier: record.get('tier'),
url: record.get('url'), url: record.get('url'),
@ -178,34 +178,28 @@ Deluge.EditTrackersWindow = Ext.extend(Ext.Window, {
this.hide(); this.hide();
}, },
onRemoveClick: function() { onRemoveClick: function () {
// Remove from the grid // Remove from the grid
var selected = this.list.getSelectedRecords()[0]; var selected = this.list.getSelectedRecords()[0];
if (!selected) return; if (!selected) return;
this.list.getStore().remove(selected); this.list.getStore().remove(selected);
}, },
onRequestComplete: function(status) { onRequestComplete: function (status) {
this.list.getStore().loadData(status); this.list.getStore().loadData(status);
this.list.getStore().sort('tier', 'ASC'); this.list.getStore().sort('tier', 'ASC');
}, },
onSaveFail: function() {}, onSaveFail: function () {},
onSelect: function(list) { onSelect: function (list) {
if (list.getSelectionCount()) { if (list.getSelectionCount()) {
this.panel this.panel.getBottomToolbar().items.get(4).enable();
.getBottomToolbar()
.items.get(4)
.enable();
} }
}, },
onShow: function() { onShow: function () {
this.panel this.panel.getBottomToolbar().items.get(4).disable();
.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'], {
@ -214,7 +208,7 @@ Deluge.EditTrackersWindow = Ext.extend(Ext.Window, {
}); });
}, },
onDownClick: function() { onDownClick: function () {
var r = this.list.getSelectedRecords()[0]; var r = this.list.getSelectedRecords()[0];
if (!r) return; if (!r) return;
@ -225,7 +219,7 @@ Deluge.EditTrackersWindow = Ext.extend(Ext.Window, {
this.list.select(r.store.indexOf(r)); this.list.select(r.store.indexOf(r));
}, },
onUpClick: function() { onUpClick: function () {
var r = this.list.getSelectedRecords()[0]; var r = this.list.getSelectedRecords()[0];
if (!r) return; if (!r) return;

View File

@ -15,7 +15,7 @@
* Class for holding global events that occur within the UI. * Class for holding global events that occur within the UI.
*/ */
Deluge.EventsManager = Ext.extend(Ext.util.Observable, { Deluge.EventsManager = Ext.extend(Ext.util.Observable, {
constructor: function() { constructor: function () {
this.toRegister = []; this.toRegister = [];
this.on('login', this.onLogin, this); this.on('login', this.onLogin, this);
Deluge.EventsManager.superclass.constructor.call(this); Deluge.EventsManager.superclass.constructor.call(this);
@ -24,7 +24,7 @@ Deluge.EventsManager = Ext.extend(Ext.util.Observable, {
/** /**
* Append an event handler to this object. * Append an event handler to this object.
*/ */
addListener: function(eventName, fn, scope, o) { addListener: function (eventName, fn, scope, o) {
this.addEvents(eventName); this.addEvents(eventName);
if (/[A-Z]/.test(eventName.substring(0, 1))) { if (/[A-Z]/.test(eventName.substring(0, 1))) {
if (!deluge.client) { if (!deluge.client) {
@ -42,7 +42,7 @@ Deluge.EventsManager = Ext.extend(Ext.util.Observable, {
); );
}, },
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,
@ -53,8 +53,8 @@ Deluge.EventsManager = Ext.extend(Ext.util.Observable, {
/** /**
* Starts the EventsManagerManager checking for events. * Starts the EventsManagerManager checking for events.
*/ */
start: function() { start: function () {
Ext.each(this.toRegister, function(eventName) { Ext.each(this.toRegister, function (eventName) {
deluge.client.web.register_event_listener(eventName); deluge.client.web.register_event_listener(eventName);
}); });
this.running = true; this.running = true;
@ -65,21 +65,21 @@ Deluge.EventsManager = Ext.extend(Ext.util.Observable, {
/** /**
* Stops the EventsManagerManager checking for events. * Stops the EventsManagerManager checking for events.
*/ */
stop: function() { stop: function () {
this.running = false; this.running = false;
}, },
// private // private
onLogin: function() { onLogin: function () {
this.start(); this.start();
}, },
onGetEventsSuccess: function(events) { onGetEventsSuccess: function (events) {
if (!this.running) return; if (!this.running) return;
if (events) { if (events) {
Ext.each( Ext.each(
events, events,
function(event) { function (event) {
var name = event[0], var name = event[0],
args = event[1]; args = event[1];
args.splice(0, 0, name); args.splice(0, 0, name);
@ -92,7 +92,7 @@ Deluge.EventsManager = Ext.extend(Ext.util.Observable, {
}, },
// private // private
onGetEventsFailure: function(result, error) { onGetEventsFailure: function (result, error) {
// the request timed out or we had a communication failure // the request timed out or we had a communication failure
if (!this.running) return; if (!this.running) return;
if (!error.isTimeout && this.errorCount++ >= 3) { if (!error.isTimeout && this.errorCount++ >= 3) {

View File

@ -15,7 +15,7 @@ Deluge.FileBrowser = Ext.extend(Ext.Window, {
width: 500, width: 500,
height: 400, height: 400,
initComponent: function() { initComponent: function () {
Deluge.FileBrowser.superclass.initComponent.call(this); Deluge.FileBrowser.superclass.initComponent.call(this);
this.add({ this.add({

View File

@ -20,7 +20,7 @@ Deluge.FilterPanel = Ext.extend(Ext.Panel, {
show_zero: null, show_zero: null,
initComponent: function() { initComponent: function () {
Deluge.FilterPanel.superclass.initComponent.call(this); Deluge.FilterPanel.superclass.initComponent.call(this);
this.filterType = this.initialConfig.filter; this.filterType = this.initialConfig.filter;
var title = ''; var title = '';
@ -36,7 +36,7 @@ Deluge.FilterPanel = Ext.extend(Ext.Panel, {
(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) + ' ';
}); });
@ -75,7 +75,7 @@ Deluge.FilterPanel = Ext.extend(Ext.Panel, {
* Return the currently selected filter state * Return the currently selected filter state
* @returns {String} the current filter state * @returns {String} the current filter state
*/ */
getState: function() { getState: function () {
if (!this.list.getSelectionCount()) return; if (!this.list.getSelectionCount()) return;
var state = this.list.getSelectedRecords()[0]; var state = this.list.getSelectedRecords()[0];
@ -87,7 +87,7 @@ Deluge.FilterPanel = Ext.extend(Ext.Panel, {
/** /**
* Return the current states in the filter * Return the current states in the filter
*/ */
getStates: function() { getStates: function () {
return this.states; return this.states;
}, },
@ -95,18 +95,18 @@ Deluge.FilterPanel = Ext.extend(Ext.Panel, {
* Return the Store for the ListView of the FilterPanel * Return the Store for the ListView of the FilterPanel
* @returns {Ext.data.Store} the ListView store * @returns {Ext.data.Store} the ListView store
*/ */
getStore: function() { getStore: function () {
return this.list.getStore(); return this.list.getStore();
}, },
/** /**
* Update the states in the FilterPanel * Update the states in the FilterPanel
*/ */
updateStates: function(states) { updateStates: function (states) {
this.states = {}; this.states = {};
Ext.each( Ext.each(
states, states,
function(state) { function (state) {
this.states[state[0]] = state[1]; this.states[state[0]] = state[1];
}, },
this this
@ -118,7 +118,7 @@ Deluge.FilterPanel = Ext.extend(Ext.Panel, {
: this.show_zero; : this.show_zero;
if (!show_zero) { if (!show_zero) {
var newStates = []; var newStates = [];
Ext.each(states, function(state) { Ext.each(states, function (state) {
if (state[1] > 0 || state[0] == 'All') { if (state[1] > 0 || state[0] == 'All') {
newStates.push(state); newStates.push(state);
} }
@ -130,7 +130,7 @@ Deluge.FilterPanel = Ext.extend(Ext.Panel, {
var filters = {}; var filters = {};
Ext.each( Ext.each(
states, states,
function(s, i) { function (s, i) {
var record = store.getById(s[0]); var record = store.getById(s[0]);
if (!record) { if (!record) {
record = new store.recordType({ record = new store.recordType({
@ -149,7 +149,7 @@ Deluge.FilterPanel = Ext.extend(Ext.Panel, {
this this
); );
store.each(function(record) { store.each(function (record) {
if (filters[record.id]) return; if (filters[record.id]) return;
store.remove(record); store.remove(record);
var selected = this.list.getSelectedRecords()[0]; var selected = this.list.getSelectedRecords()[0];

View File

@ -24,7 +24,7 @@ Deluge.Formatters = {
* @return {String} a string in the date representation of the current locale * @return {String} a string in the date representation of the current locale
* or "" if seconds < 0. * or "" if seconds < 0.
*/ */
date: function(timestamp) { date: function (timestamp) {
function zeroPad(num, count) { function zeroPad(num, count) {
var numZeropad = num + ''; var numZeropad = num + '';
while (numZeropad.length < count) { while (numZeropad.length < count) {
@ -52,7 +52,7 @@ Deluge.Formatters = {
* @param {Boolean} showZero pass in true to displays 0 values * @param {Boolean} showZero pass in true to displays 0 values
* @return {String} formatted string with KiB, MiB or GiB units. * @return {String} formatted string with KiB, MiB or GiB units.
*/ */
size: function(bytes, showZero) { size: function (bytes, showZero) {
if (!bytes && !showZero) return ''; if (!bytes && !showZero) return '';
bytes = bytes / 1024.0; bytes = bytes / 1024.0;
@ -78,7 +78,7 @@ Deluge.Formatters = {
* @param {Boolean} showZero pass in true to displays 0 values * @param {Boolean} showZero pass in true to displays 0 values
* @return {String} formatted string with K, M or G units. * @return {String} formatted string with K, M or G units.
*/ */
sizeShort: function(bytes, showZero) { sizeShort: function (bytes, showZero) {
if (!bytes && !showZero) return ''; if (!bytes && !showZero) return '';
bytes = bytes / 1024.0; bytes = bytes / 1024.0;
@ -104,7 +104,7 @@ Deluge.Formatters = {
* @param {Boolean} showZero pass in true to displays 0 values * @param {Boolean} showZero pass in true to displays 0 values
* @return {String} formatted string with KiB, MiB or GiB units. * @return {String} formatted string with KiB, MiB or GiB units.
*/ */
speed: function(bytes, showZero) { speed: function (bytes, showZero) {
return !bytes && !showZero ? '' : fsize(bytes, showZero) + '/s'; return !bytes && !showZero ? '' : fsize(bytes, showZero) + '/s';
}, },
@ -114,7 +114,7 @@ Deluge.Formatters = {
* @param {Number} time the number of seconds * @param {Number} time the number of seconds
* @return {String} a formatted time string. will return '' if seconds == 0 * @return {String} a formatted time string. will return '' if seconds == 0
*/ */
timeRemaining: function(time) { timeRemaining: function (time) {
if (time <= 0) { if (time <= 0) {
return '&infin;'; return '&infin;';
} }
@ -164,11 +164,11 @@ Deluge.Formatters = {
* @param {Mixed} value the value to be displayed * @param {Mixed} value the value to be displayed
* @return the untouched value. * @return the untouched value.
*/ */
plain: function(value) { plain: function (value) {
return value; return value;
}, },
cssClassEscape: function(value) { cssClassEscape: function (value) {
return value.toLowerCase().replace('.', '_'); return value.toLowerCase().replace('.', '_');
}, },
}; };

View File

@ -133,6 +133,6 @@ Deluge.Keys = {
// 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
// grid ones. // grid ones.
Ext.each(Deluge.Keys.Grid, function(key) { Ext.each(Deluge.Keys.Grid, function (key) {
Deluge.Keys.Status.push(key); Deluge.Keys.Status.push(key);
}); });

View File

@ -23,7 +23,7 @@ Deluge.LoginWindow = Ext.extend(Ext.Window, {
width: 300, width: 300,
height: 120, height: 120,
initComponent: function() { initComponent: function () {
Deluge.LoginWindow.superclass.initComponent.call(this); Deluge.LoginWindow.superclass.initComponent.call(this);
this.on('show', this.onShow, this); this.on('show', this.onShow, this);
@ -56,17 +56,17 @@ Deluge.LoginWindow = Ext.extend(Ext.Window, {
this.passwordField.on('specialkey', this.onSpecialKey, this); this.passwordField.on('specialkey', this.onSpecialKey, this);
}, },
logout: function() { logout: function () {
deluge.events.fire('logout'); deluge.events.fire('logout');
deluge.client.auth.delete_session({ deluge.client.auth.delete_session({
success: function(result) { success: function (result) {
this.show(true); this.show(true);
}, },
scope: this, scope: this,
}); });
}, },
show: function(skipCheck) { show: function (skipCheck) {
if (this.firstShow) { if (this.firstShow) {
deluge.client.on('error', this.onClientError, this); deluge.client.on('error', this.onClientError, this);
this.firstShow = false; this.firstShow = false;
@ -77,28 +77,28 @@ Deluge.LoginWindow = Ext.extend(Ext.Window, {
} }
deluge.client.auth.check_session({ deluge.client.auth.check_session({
success: function(result) { success: function (result) {
if (result) { if (result) {
deluge.events.fire('login'); deluge.events.fire('login');
} else { } else {
this.show(true); this.show(true);
} }
}, },
failure: function(result) { failure: function (result) {
this.show(true); this.show(true);
}, },
scope: this, scope: this,
}); });
}, },
onSpecialKey: function(field, e) { onSpecialKey: function (field, e) {
if (e.getKey() == 13) this.onLogin(); if (e.getKey() == 13) this.onLogin();
}, },
onLogin: function() { onLogin: function () {
var passwordField = this.passwordField; var passwordField = this.passwordField;
deluge.client.auth.login(passwordField.getValue(), { deluge.client.auth.login(passwordField.getValue(), {
success: function(result) { success: function (result) {
if (result) { if (result) {
deluge.events.fire('login'); deluge.events.fire('login');
this.hide(); this.hide();
@ -109,7 +109,7 @@ Deluge.LoginWindow = Ext.extend(Ext.Window, {
msg: _('You entered an incorrect password'), msg: _('You entered an incorrect password'),
buttons: Ext.MessageBox.OK, buttons: Ext.MessageBox.OK,
modal: false, modal: false,
fn: function() { fn: function () {
passwordField.focus(true, 10); passwordField.focus(true, 10);
}, },
icon: Ext.MessageBox.WARNING, icon: Ext.MessageBox.WARNING,
@ -121,14 +121,14 @@ Deluge.LoginWindow = Ext.extend(Ext.Window, {
}); });
}, },
onClientError: function(errorObj, response, requestOptions) { onClientError: function (errorObj, response, requestOptions) {
if (errorObj.error.code == 1) { if (errorObj.error.code == 1) {
deluge.events.fire('logout'); deluge.events.fire('logout');
this.show(true); this.show(true);
} }
}, },
onShow: function() { onShow: function () {
this.passwordField.focus(true, 300); this.passwordField.focus(true, 300);
}, },
}); });

View File

@ -9,7 +9,7 @@
*/ */
deluge.menus = { deluge.menus = {
onTorrentActionSetOpt: function(item, e) { onTorrentActionSetOpt: function (item, e) {
var ids = deluge.torrents.getSelectedIds(); var ids = deluge.torrents.getSelectedIds();
var action = item.initialConfig.torrentAction; var action = item.initialConfig.torrentAction;
var opts = {}; var opts = {};
@ -17,17 +17,17 @@ deluge.menus = {
deluge.client.core.set_torrent_options(ids, opts); deluge.client.core.set_torrent_options(ids, opts);
}, },
onTorrentActionMethod: function(item, e) { onTorrentActionMethod: function (item, e) {
var ids = deluge.torrents.getSelectedIds(); var ids = deluge.torrents.getSelectedIds();
var action = item.initialConfig.torrentAction; var action = item.initialConfig.torrentAction;
deluge.client.core[action](ids, { deluge.client.core[action](ids, {
success: function() { success: function () {
deluge.ui.update(); deluge.ui.update();
}, },
}); });
}, },
onTorrentActionShow: function(item, e) { onTorrentActionShow: function (item, e) {
var ids = deluge.torrents.getSelectedIds(); var ids = deluge.torrents.getSelectedIds();
var action = item.initialConfig.torrentAction; var action = item.initialConfig.torrentAction;
switch (action) { switch (action) {

View File

@ -10,7 +10,7 @@
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'), title: _('Move Download Folder'),
@ -30,7 +30,7 @@ Deluge.MoveStorage = Ext.extend(Ext.Window, {
Deluge.MoveStorage.superclass.constructor.call(this, config); Deluge.MoveStorage.superclass.constructor.call(this, config);
}, },
initComponent: function() { initComponent: function () {
Deluge.MoveStorage.superclass.initComponent.call(this); Deluge.MoveStorage.superclass.initComponent.call(this);
this.addButton(_('Cancel'), this.onCancel, this); this.addButton(_('Cancel'), this.onCancel, this);
@ -62,21 +62,21 @@ Deluge.MoveStorage = Ext.extend(Ext.Window, {
//}); //});
}, },
hide: function() { hide: function () {
Deluge.MoveStorage.superclass.hide.call(this); Deluge.MoveStorage.superclass.hide.call(this);
this.torrentIds = null; this.torrentIds = null;
}, },
show: function(torrentIds) { show: function (torrentIds) {
Deluge.MoveStorage.superclass.show.call(this); Deluge.MoveStorage.superclass.show.call(this);
this.torrentIds = torrentIds; this.torrentIds = torrentIds;
}, },
onCancel: function() { onCancel: function () {
this.hide(); this.hide();
}, },
onMove: function() { onMove: function () {
var dest = this.moveLocation.getValue(); var dest = this.moveLocation.getValue();
deluge.client.core.move_storage(this.torrentIds, dest); deluge.client.core.move_storage(this.torrentIds, dest);
this.hide(); this.hide();

View File

@ -15,7 +15,7 @@
* @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 = {};
Deluge.MultiOptionsManager.superclass.constructor.call(this, config); Deluge.MultiOptionsManager.superclass.constructor.call(this, config);
@ -25,7 +25,7 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, {
* Changes bound fields to use the specified id. * Changes bound fields to use the specified id.
* @param {String} id * @param {String} id
*/ */
changeId: function(id, dontUpdateBinds) { changeId: function (id, dontUpdateBinds) {
var oldId = this.currentId; var oldId = this.currentId;
this.currentId = id; this.currentId = id;
if (!dontUpdateBinds) { if (!dontUpdateBinds) {
@ -33,7 +33,7 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, {
if (!this.binds[option]) continue; if (!this.binds[option]) continue;
Ext.each( Ext.each(
this.binds[option], this.binds[option],
function(bind) { function (bind) {
bind.setValue(this.get(option)); bind.setValue(this.get(option));
}, },
this this
@ -47,7 +47,7 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, {
* Changes all the changed values to be the default values * Changes all the changed values to be the default values
* @param {String} id * @param {String} id
*/ */
commit: function() { commit: function () {
this.stored[this.currentId] = Ext.apply( this.stored[this.currentId] = Ext.apply(
this.stored[this.currentId], this.stored[this.currentId],
this.changed[this.currentId] this.changed[this.currentId]
@ -60,7 +60,7 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, {
* @param {String/Array} option A single option or an array of options to return. * @param {String/Array} option A single option or an array of options to return.
* @returns {Object} the options value. * @returns {Object} the options value.
*/ */
get: function() { get: function () {
if (arguments.length == 1) { if (arguments.length == 1) {
var option = arguments[0]; var option = arguments[0];
return this.isDirty(option) return this.isDirty(option)
@ -78,7 +78,7 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, {
var options = {}; var options = {};
Ext.each( Ext.each(
arguments, arguments,
function(option) { function (option) {
options[option] = this.isDirty(option) options[option] = this.isDirty(option)
? this.changed[this.currentId][option] ? this.changed[this.currentId][option]
: this.getDefault(option); : this.getDefault(option);
@ -94,7 +94,7 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, {
* @param {String} option A single option. * @param {String} option A single option.
* @returns {Object} the value of the option * @returns {Object} the value of the option
*/ */
getDefault: function(option) { getDefault: function (option) {
return this.has(option) return this.has(option)
? this.stored[this.currentId][option] ? this.stored[this.currentId][option]
: this.options[option]; : this.options[option];
@ -104,7 +104,7 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, {
* Returns the dirty (changed) values. * Returns the dirty (changed) values.
* @returns {Object} the changed options * @returns {Object} the changed options
*/ */
getDirty: function() { getDirty: function () {
return this.changed[this.currentId] ? this.changed[this.currentId] : {}; return this.changed[this.currentId] ? this.changed[this.currentId] : {};
}, },
@ -113,7 +113,7 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, {
* @param {String} option * @param {String} option
* @returns {Boolean} true if the option has been changed, else false. * @returns {Boolean} true if the option has been changed, else false.
*/ */
isDirty: function(option) { isDirty: function (option) {
return ( return (
this.changed[this.currentId] && this.changed[this.currentId] &&
!Ext.isEmpty(this.changed[this.currentId][option]) !Ext.isEmpty(this.changed[this.currentId][option])
@ -126,7 +126,7 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, {
* @param {String} option * @param {String} option
* @returns {Boolean} true if the id has an option, else false. * @returns {Boolean} true if the id has an option, else false.
*/ */
has: function(option) { has: function (option) {
return ( return (
this.stored[this.currentId] && this.stored[this.currentId] &&
!Ext.isEmpty(this.stored[this.currentId][option]) !Ext.isEmpty(this.stored[this.currentId][option])
@ -136,7 +136,7 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, {
/** /**
* Reset the options back to the default values for the specified id. * Reset the options back to the default values for the specified id.
*/ */
reset: function() { reset: function () {
if (this.changed[this.currentId]) delete this.changed[this.currentId]; if (this.changed[this.currentId]) delete this.changed[this.currentId];
if (this.stored[this.currentId]) delete this.stored[this.currentId]; if (this.stored[this.currentId]) delete this.stored[this.currentId];
}, },
@ -144,7 +144,7 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, {
/** /**
* Reset the options back to their defaults for all ids. * Reset the options back to their defaults for all ids.
*/ */
resetAll: function() { resetAll: function () {
this.changed = {}; this.changed = {};
this.stored = {}; this.stored = {};
this.changeId(null); this.changeId(null);
@ -156,7 +156,7 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, {
* @param {String} option * @param {String} option
* @param {Object} value The value for the option * @param {Object} value The value for the option
*/ */
setDefault: function(option, value) { setDefault: function (option, value) {
if (option === undefined) { if (option === undefined) {
return; return;
} else if (value === undefined) { } else if (value === undefined) {
@ -187,7 +187,7 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, {
* @param {String/Object} option or options to update * @param {String/Object} option or options to update
* @param {Object} [value]; * @param {Object} [value];
*/ */
update: function(option, value) { update: function (option, value) {
if (option === undefined) { if (option === undefined) {
return; return;
} else if (value === undefined) { } else if (value === undefined) {

View File

@ -18,7 +18,7 @@ Ext.namespace('Deluge');
* @param {Object} config Configuration options * @param {Object} config Configuration options
*/ */
Deluge.OptionsManager = Ext.extend(Ext.util.Observable, { Deluge.OptionsManager = Ext.extend(Ext.util.Observable, {
constructor: function(config) { constructor: function (config) {
config = config || {}; config = config || {};
this.binds = {}; this.binds = {};
this.changed = {}; this.changed = {};
@ -56,7 +56,7 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, {
* Add a set of default options and values to the options manager * Add a set of default options and values to the options manager
* @param {Object} options The default options. * @param {Object} options The default options.
*/ */
addOptions: function(options) { addOptions: function (options) {
this.options = Ext.applyIf(this.options, options); this.options = Ext.applyIf(this.options, options);
}, },
@ -65,7 +65,7 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, {
* @param {String} option * @param {String} option
* @param {Ext.form.Field} field * @param {Ext.form.Field} field
*/ */
bind: function(option, field) { bind: function (option, field) {
this.binds[option] = this.binds[option] || []; this.binds[option] = this.binds[option] || [];
this.binds[option].push(field); this.binds[option].push(field);
field._doption = option; field._doption = option;
@ -81,7 +81,7 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, {
/** /**
* Changes all the changed values to be the default values * Changes all the changed values to be the default values
*/ */
commit: function() { commit: function () {
this.options = Ext.apply(this.options, this.changed); this.options = Ext.apply(this.options, this.changed);
this.reset(); this.reset();
}, },
@ -91,7 +91,7 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, {
* @param {Mixed} oldValue The original value * @param {Mixed} oldValue The original value
* @param {Mixed} value The new value to convert * @param {Mixed} value The new value to convert
*/ */
convertValueType: function(oldValue, value) { convertValueType: function (oldValue, value) {
if (Ext.type(oldValue) != Ext.type(value)) { if (Ext.type(oldValue) != Ext.type(value)) {
switch (Ext.type(oldValue)) { switch (Ext.type(oldValue)) {
case 'string': case 'string':
@ -121,7 +121,7 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, {
* @param {String} [option] A single option or an array of options to return. * @param {String} [option] A single option or an array of options to return.
* @returns {Object} the options value. * @returns {Object} the options value.
*/ */
get: function() { get: function () {
if (arguments.length == 1) { if (arguments.length == 1) {
var option = arguments[0]; var option = arguments[0];
return this.isDirty(option) return this.isDirty(option)
@ -131,7 +131,7 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, {
var options = {}; var options = {};
Ext.each( Ext.each(
arguments, arguments,
function(option) { function (option) {
if (!this.has(option)) return; if (!this.has(option)) return;
options[option] = this.isDirty(option) options[option] = this.isDirty(option)
? this.changed[option] ? this.changed[option]
@ -148,7 +148,7 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, {
* @param {String|Array} [option] A single option or an array of options to return. * @param {String|Array} [option] A single option or an array of options to return.
* @returns {Object} the value of the option * @returns {Object} the value of the option
*/ */
getDefault: function(option) { getDefault: function (option) {
return this.options[option]; return this.options[option];
}, },
@ -156,7 +156,7 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, {
* Returns the dirty (changed) values. * Returns the dirty (changed) values.
* @returns {Object} the changed options * @returns {Object} the changed options
*/ */
getDirty: function() { getDirty: function () {
return this.changed; return this.changed;
}, },
@ -164,7 +164,7 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, {
* @param {String} [option] The option to check * @param {String} [option] The option to check
* @returns {Boolean} true if the option has been changed from the default. * @returns {Boolean} true if the option has been changed from the default.
*/ */
isDirty: function(option) { isDirty: function (option) {
return !Ext.isEmpty(this.changed[option]); return !Ext.isEmpty(this.changed[option]);
}, },
@ -173,14 +173,14 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, {
* @param {String} option * @param {String} option
* @returns {Boolean} true if the option exists, else false. * @returns {Boolean} true if the option exists, else false.
*/ */
has: function(option) { has: function (option) {
return this.options[option]; return this.options[option];
}, },
/** /**
* Reset the options back to the default values. * Reset the options back to the default values.
*/ */
reset: function() { reset: function () {
this.changed = {}; this.changed = {};
}, },
@ -189,7 +189,7 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, {
* @param {String} option * @param {String} option
* @param {Object} value The value for the option * @param {Object} value The value for the option
*/ */
set: function(option, value) { set: function (option, value) {
if (option === undefined) { if (option === undefined) {
return; return;
} else if (typeof option == 'object') { } else if (typeof option == 'object') {
@ -209,7 +209,7 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, {
* @param {String/Object} option or options to update * @param {String/Object} option or options to update
* @param {Object} [value]; * @param {Object} [value];
*/ */
update: function(option, value) { update: function (option, value) {
if (option === undefined) { if (option === undefined) {
return; return;
} else if (value === undefined) { } else if (value === undefined) {
@ -238,7 +238,7 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, {
* Lets the option manager know when a field is blurred so if a value * Lets the option manager know when a field is blurred so if a value
* so value changing operations can continue on that field. * so value changing operations can continue on that field.
*/ */
onFieldBlur: function(field, event) { onFieldBlur: function (field, event) {
if (this.focused == field) { if (this.focused == field) {
this.focused = null; this.focused = null;
} }
@ -249,7 +249,7 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, {
* @param {Ext.form.Field} field * @param {Ext.form.Field} field
* @private * @private
*/ */
onFieldChange: function(field, event) { onFieldChange: function (field, event) {
if (field.field) field = field.field; // fix for spinners if (field.field) field = field.field; // fix for spinners
this.update(field._doption, field.getValue()); this.update(field._doption, field.getValue());
}, },
@ -258,16 +258,16 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, {
* Lets the option manager know when a field is focused so if a value changing * Lets the option manager know when a field is focused so if a value changing
* operation is performed it will not change the value of the field. * operation is performed it will not change the value of the field.
*/ */
onFieldFocus: function(field, event) { onFieldFocus: function (field, event) {
this.focused = field; this.focused = field;
}, },
onChange: function(option, newValue, oldValue) { onChange: function (option, newValue, oldValue) {
// If we don't have a bind there's nothing to do. // If we don't have a bind there's nothing to do.
if (Ext.isEmpty(this.binds[option])) return; if (Ext.isEmpty(this.binds[option])) return;
Ext.each( Ext.each(
this.binds[option], this.binds[option],
function(bind) { function (bind) {
// The field is currently focused so we do not want to change it. // The field is currently focused so we do not want to change it.
if (bind == this.focused) return; if (bind == this.focused) return;
// Set the form field to the new value. // Set the form field to the new value.

View File

@ -20,7 +20,7 @@ Deluge.OtherLimitWindow = Ext.extend(Ext.Window, {
constrainHeader: true, constrainHeader: true,
closeAction: 'hide', closeAction: 'hide',
initComponent: function() { initComponent: function () {
Deluge.OtherLimitWindow.superclass.initComponent.call(this); Deluge.OtherLimitWindow.superclass.initComponent.call(this);
this.form = this.add({ this.form = this.add({
xtype: 'form', xtype: 'form',
@ -53,30 +53,27 @@ Deluge.OtherLimitWindow = Ext.extend(Ext.Window, {
this.afterMethod('show', this.doFocusField, this); this.afterMethod('show', this.doFocusField, this);
}, },
setValue: function(value) { setValue: function (value) {
this.form.getForm().setValues({ limit: value }); this.form.getForm().setValues({ limit: value });
}, },
onCancelClick: function() { onCancelClick: function () {
this.form.getForm().reset(); this.form.getForm().reset();
this.hide(); this.hide();
}, },
onOkClick: function() { onOkClick: function () {
var config = {}; var config = {};
config[this.group] = this.form.getForm().getValues().limit; config[this.group] = this.form.getForm().getValues().limit;
deluge.client.core.set_config(config, { deluge.client.core.set_config(config, {
success: function() { success: function () {
deluge.ui.update(); deluge.ui.update();
}, },
}); });
this.hide(); this.hide();
}, },
doFocusField: function() { doFocusField: function () {
this.form this.form.getForm().findField('limit').focus(true, 10);
.getForm()
.findField('limit')
.focus(true, 10);
}, },
}); });

View File

@ -21,7 +21,7 @@ Deluge.Plugin = Ext.extend(Ext.util.Observable, {
*/ */
name: null, name: null,
constructor: function(config) { constructor: function (config) {
this.isDelugePlugin = true; this.isDelugePlugin = true;
this.addEvents({ this.addEvents({
/** /**
@ -43,7 +43,7 @@ Deluge.Plugin = Ext.extend(Ext.util.Observable, {
* Disables the plugin, firing the "{@link #disabled}" event and * Disables the plugin, firing the "{@link #disabled}" event and
* then executing the plugins clean up method onDisabled. * then executing the plugins clean up method onDisabled.
*/ */
disable: function() { disable: function () {
this.fireEvent('disabled', this); this.fireEvent('disabled', this);
if (this.onDisable) this.onDisable(); if (this.onDisable) this.onDisable();
}, },
@ -52,13 +52,13 @@ Deluge.Plugin = Ext.extend(Ext.util.Observable, {
* Enables the plugin, firing the "{@link #enabled}" event and * Enables the plugin, firing the "{@link #enabled}" event and
* then executes the plugins setup method, onEnabled. * then executes the plugins setup method, onEnabled.
*/ */
enable: function() { enable: function () {
deluge.client.reloadMethods(); deluge.client.reloadMethods();
this.fireEvent('enable', this); this.fireEvent('enable', this);
if (this.onEnable) this.onEnable(); if (this.onEnable) this.onEnable();
}, },
registerTorrentStatus: function(key, header, options) { registerTorrentStatus: function (key, header, options) {
options = options || {}; options = options || {};
var cc = options.colCfg || {}, var cc = options.colCfg || {},
sc = options.storeCfg || {}; sc = options.storeCfg || {};
@ -79,23 +79,23 @@ Deluge.Plugin = Ext.extend(Ext.util.Observable, {
deluge.torrents.getView().refresh(true); deluge.torrents.getView().refresh(true);
}, },
deregisterTorrentStatus: function(key) { deregisterTorrentStatus: function (key) {
var fields = []; var fields = [];
Ext.each(deluge.torrents.meta.fields, function(field) { Ext.each(deluge.torrents.meta.fields, function (field) {
if (field.name != key) fields.push(field); if (field.name != key) fields.push(field);
}); });
deluge.torrents.meta.fields = fields; deluge.torrents.meta.fields = fields;
deluge.torrents.getStore().reader.onMetaChange(deluge.torrents.meta); deluge.torrents.getStore().reader.onMetaChange(deluge.torrents.meta);
var cols = []; var cols = [];
Ext.each(deluge.torrents.columns, function(col) { Ext.each(deluge.torrents.columns, function (col) {
if (col.dataIndex != key) cols.push(col); if (col.dataIndex != key) cols.push(col);
}); });
deluge.torrents.colModel.setConfig(cols); deluge.torrents.colModel.setConfig(cols);
deluge.torrents.columns = cols; deluge.torrents.columns = cols;
var keys = []; var keys = [];
Ext.each(Deluge.Keys.Grid, function(k) { Ext.each(Deluge.Keys.Grid, function (k) {
if (k == key) keys.push(k); if (k == key) keys.push(k);
}); });
Deluge.Keys.Grid = keys; Deluge.Keys.Grid = keys;

View File

@ -27,16 +27,16 @@ Deluge.RemoveWindow = Ext.extend(Ext.Window, {
bodyStyle: 'padding: 5px; padding-left: 10px;', bodyStyle: 'padding: 5px; padding-left: 10px;',
html: 'Are you sure you wish to remove the torrent (s)?', html: 'Are you sure you wish to remove the torrent (s)?',
initComponent: function() { initComponent: function () {
Deluge.RemoveWindow.superclass.initComponent.call(this); Deluge.RemoveWindow.superclass.initComponent.call(this);
this.addButton(_('Cancel'), this.onCancel, this); this.addButton(_('Cancel'), this.onCancel, this);
this.addButton(_('Remove With Data'), this.onRemoveData, this); this.addButton(_('Remove With Data'), this.onRemoveData, this);
this.addButton(_('Remove Torrent'), this.onRemove, this); this.addButton(_('Remove Torrent'), this.onRemove, this);
}, },
remove: function(removeData) { remove: function (removeData) {
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( console.log(
'Error(s) occured when trying to delete torrent(s).' 'Error(s) occured when trying to delete torrent(s).'
@ -49,25 +49,25 @@ Deluge.RemoveWindow = Ext.extend(Ext.Window, {
}); });
}, },
show: function(ids) { show: function (ids) {
Deluge.RemoveWindow.superclass.show.call(this); Deluge.RemoveWindow.superclass.show.call(this);
this.torrentIds = ids; this.torrentIds = ids;
}, },
onCancel: function() { onCancel: function () {
this.hide(); this.hide();
this.torrentIds = null; this.torrentIds = null;
}, },
onRemove: function() { onRemove: function () {
this.remove(false); this.remove(false);
}, },
onRemoveData: function() { onRemoveData: function () {
this.remove(true); this.remove(true);
}, },
onRemoved: function(torrentIds) { onRemoved: function (torrentIds) {
deluge.events.fire('torrentsRemoved', torrentIds); deluge.events.fire('torrentsRemoved', torrentIds);
this.hide(); this.hide();
deluge.ui.update(); deluge.ui.update();

View File

@ -24,7 +24,7 @@ Deluge.Sidebar = Ext.extend(Ext.Panel, {
// private // private
selected: null, selected: null,
constructor: function(config) { constructor: function (config) {
config = Ext.apply( config = Ext.apply(
{ {
id: 'sidebar', id: 'sidebar',
@ -43,16 +43,16 @@ Deluge.Sidebar = Ext.extend(Ext.Panel, {
}, },
// private // private
initComponent: function() { initComponent: function () {
Deluge.Sidebar.superclass.initComponent.call(this); Deluge.Sidebar.superclass.initComponent.call(this);
deluge.events.on('disconnect', this.onDisconnect, this); deluge.events.on('disconnect', this.onDisconnect, this);
}, },
createFilter: function(filter, states) { createFilter: function (filter, states) {
var panel = new Deluge.FilterPanel({ var panel = new Deluge.FilterPanel({
filter: filter, filter: filter,
}); });
panel.on('selectionchange', function(view, nodes) { panel.on('selectionchange', function (view, nodes) {
deluge.ui.update(); deluge.ui.update();
}); });
this.add(panel); this.add(panel);
@ -60,7 +60,7 @@ Deluge.Sidebar = Ext.extend(Ext.Panel, {
this.doLayout(); this.doLayout();
this.panels[filter] = panel; this.panels[filter] = panel;
panel.header.on('click', function(header) { panel.header.on('click', function (header) {
if (!deluge.config.sidebar_multiple_filters) { if (!deluge.config.sidebar_multiple_filters) {
deluge.ui.update(); deluge.ui.update();
} }
@ -74,16 +74,16 @@ Deluge.Sidebar = Ext.extend(Ext.Panel, {
this.fireEvent('afterfiltercreate', this, panel); this.fireEvent('afterfiltercreate', this, panel);
}, },
getFilter: function(filter) { getFilter: function (filter) {
return this.panels[filter]; return this.panels[filter];
}, },
getFilterStates: function() { getFilterStates: function () {
var states = {}; var states = {};
if (deluge.config.sidebar_multiple_filters) { if (deluge.config.sidebar_multiple_filters) {
// Grab the filters from each of the filter panels // Grab the filters from each of the filter panels
this.items.each(function(panel) { this.items.each(function (panel) {
var state = panel.getState(); var state = panel.getState();
if (state == null) return; if (state == null) return;
states[panel.filterType] = state; states[panel.filterType] = state;
@ -100,12 +100,12 @@ Deluge.Sidebar = Ext.extend(Ext.Panel, {
return states; return states;
}, },
hasFilter: function(filter) { hasFilter: function (filter) {
return this.panels[filter] ? true : false; return this.panels[filter] ? true : false;
}, },
// private // private
onDisconnect: function() { onDisconnect: function () {
for (var filter in this.panels) { for (var filter in this.panels) {
this.remove(this.panels[filter]); this.remove(this.panels[filter]);
} }
@ -113,11 +113,11 @@ Deluge.Sidebar = Ext.extend(Ext.Panel, {
this.selected = null; this.selected = null;
}, },
onFilterSelect: function(selModel, rowIndex, record) { onFilterSelect: function (selModel, rowIndex, record) {
deluge.ui.update(); deluge.ui.update();
}, },
update: function(filters) { update: function (filters) {
for (var filter in filters) { for (var filter in filters) {
var states = filters[filter]; var states = filters[filter];
if (Ext.getKeys(this.panels).indexOf(filter) > -1) { if (Ext.getKeys(this.panels).indexOf(filter) > -1) {
@ -130,7 +130,7 @@ 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.each(
Ext.keys(this.panels), Ext.keys(this.panels),
function(filter) { function (filter) {
if (Ext.keys(filters).indexOf(filter) == -1) { if (Ext.keys(filters).indexOf(filter) == -1) {
// We need to remove the panel // We need to remove the panel
this.remove(this.panels[filter]); this.remove(this.panels[filter]);

View File

@ -10,7 +10,7 @@
Ext.namespace('Deluge'); Ext.namespace('Deluge');
Deluge.Statusbar = Ext.extend(Ext.ux.StatusBar, { Deluge.Statusbar = Ext.extend(Ext.ux.StatusBar, {
constructor: function(config) { constructor: function (config) {
config = Ext.apply( config = Ext.apply(
{ {
id: 'deluge-statusbar', id: 'deluge-statusbar',
@ -22,14 +22,14 @@ Deluge.Statusbar = Ext.extend(Ext.ux.StatusBar, {
Deluge.Statusbar.superclass.constructor.call(this, config); Deluge.Statusbar.superclass.constructor.call(this, config);
}, },
initComponent: function() { initComponent: function () {
Deluge.Statusbar.superclass.initComponent.call(this); Deluge.Statusbar.superclass.initComponent.call(this);
deluge.events.on('connect', this.onConnect, this); deluge.events.on('connect', this.onConnect, this);
deluge.events.on('disconnect', this.onDisconnect, this); deluge.events.on('disconnect', this.onDisconnect, this);
}, },
createButtons: function() { createButtons: function () {
this.buttons = this.add( this.buttons = this.add(
{ {
id: 'statusbar-connections', id: 'statusbar-connections',
@ -213,7 +213,7 @@ Deluge.Statusbar = Ext.extend(Ext.ux.StatusBar, {
cls: 'x-btn-text-icon', cls: 'x-btn-text-icon',
iconCls: 'x-deluge-traffic', iconCls: 'x-deluge-traffic',
tooltip: _('Protocol Traffic Download/Upload'), tooltip: _('Protocol Traffic Download/Upload'),
handler: function() { handler: function () {
deluge.preferences.show(); deluge.preferences.show();
deluge.preferences.selectPage('Network'); deluge.preferences.selectPage('Network');
}, },
@ -240,7 +240,7 @@ Deluge.Statusbar = Ext.extend(Ext.ux.StatusBar, {
cls: 'x-btn-text-icon', cls: 'x-btn-text-icon',
iconCls: 'x-deluge-freespace', iconCls: 'x-deluge-freespace',
tooltip: _('Freespace in download folder'), tooltip: _('Freespace in download folder'),
handler: function() { handler: function () {
deluge.preferences.show(); deluge.preferences.show();
deluge.preferences.selectPage('Downloads'); deluge.preferences.selectPage('Downloads');
}, },
@ -249,7 +249,7 @@ Deluge.Statusbar = Ext.extend(Ext.ux.StatusBar, {
this.created = true; this.created = true;
}, },
onConnect: function() { onConnect: function () {
this.setStatus({ this.setStatus({
iconCls: 'x-connected', iconCls: 'x-connected',
text: '', text: '',
@ -257,7 +257,7 @@ Deluge.Statusbar = Ext.extend(Ext.ux.StatusBar, {
if (!this.created) { if (!this.created) {
this.createButtons(); this.createButtons();
} else { } else {
Ext.each(this.buttons, function(item) { Ext.each(this.buttons, function (item) {
item.show(); item.show();
item.enable(); item.enable();
}); });
@ -265,23 +265,23 @@ Deluge.Statusbar = Ext.extend(Ext.ux.StatusBar, {
this.doLayout(); this.doLayout();
}, },
onDisconnect: function() { onDisconnect: function () {
this.clearStatus({ useDefaults: true }); this.clearStatus({ useDefaults: true });
Ext.each(this.buttons, function(item) { Ext.each(this.buttons, function (item) {
item.hide(); item.hide();
item.disable(); item.disable();
}); });
this.doLayout(); this.doLayout();
}, },
update: function(stats) { update: function (stats) {
if (!stats) return; if (!stats) return;
function addSpeed(val) { function addSpeed(val) {
return val + ' KiB/s'; 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 var value = config.value.formatter

View File

@ -15,13 +15,13 @@ 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.otherWin = new Deluge.OtherLimitWindow(
this.initialConfig.otherWin || {} this.initialConfig.otherWin || {}
); );
this.items.each(function(item) { this.items.each(function (item) {
if (item.getXType() != 'menucheckitem') return; if (item.getXType() != 'menucheckitem') return;
if (item.value == 'other') { if (item.value == 'other') {
item.on('click', this.onOtherClicked, this); item.on('click', this.onOtherClicked, this);
@ -31,14 +31,14 @@ Deluge.StatusbarMenu = Ext.extend(Ext.menu.Menu, {
}, this); }, this);
}, },
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
this.items.each(function(item) { this.items.each(function (item) {
if (item.setChecked) { if (item.setChecked) {
item.suspendEvents(); item.suspendEvents();
if (item.value == value) { if (item.value == value) {
@ -60,18 +60,18 @@ Deluge.StatusbarMenu = Ext.extend(Ext.menu.Menu, {
other.resumeEvents(); other.resumeEvents();
}, },
onLimitChanged: function(item, checked) { onLimitChanged: function (item, checked) {
if (!checked || item.value == 'other') return; // We 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();
}, },
}); });
}, },
onOtherClicked: function(item, e) { onOtherClicked: function (item, e) {
this.otherWin.group = item.group; this.otherWin.group = item.group;
this.otherWin.setValue(this.value); this.otherWin.setValue(this.value);
this.otherWin.show(); this.otherWin.show();

View File

@ -14,7 +14,7 @@
* @extends Ext.Toolbar * @extends Ext.Toolbar
*/ */
Deluge.Toolbar = Ext.extend(Ext.Toolbar, { Deluge.Toolbar = Ext.extend(Ext.Toolbar, {
constructor: function(config) { constructor: function (config) {
config = Ext.apply( config = Ext.apply(
{ {
items: [ items: [
@ -118,62 +118,62 @@ Deluge.Toolbar = Ext.extend(Ext.Toolbar, {
connectedButtons: ['add', 'remove', 'pause', 'resume', 'up', 'down'], connectedButtons: ['add', 'remove', 'pause', 'resume', 'up', 'down'],
initComponent: function() { initComponent: function () {
Deluge.Toolbar.superclass.initComponent.call(this); Deluge.Toolbar.superclass.initComponent.call(this);
deluge.events.on('connect', this.onConnect, this); deluge.events.on('connect', this.onConnect, this);
deluge.events.on('login', this.onLogin, this); deluge.events.on('login', this.onLogin, this);
}, },
onConnect: function() { onConnect: function () {
Ext.each( Ext.each(
this.connectedButtons, this.connectedButtons,
function(buttonId) { function (buttonId) {
this.items.get(buttonId).enable(); this.items.get(buttonId).enable();
}, },
this this
); );
}, },
onDisconnect: function() { onDisconnect: function () {
Ext.each( Ext.each(
this.connectedButtons, this.connectedButtons,
function(buttonId) { function (buttonId) {
this.items.get(buttonId).disable(); this.items.get(buttonId).disable();
}, },
this this
); );
}, },
onLogin: function() { onLogin: function () {
this.items.get('logout').enable(); this.items.get('logout').enable();
}, },
onLogout: function() { onLogout: function () {
this.items.get('logout').disable(); this.items.get('logout').disable();
deluge.login.logout(); deluge.login.logout();
}, },
onConnectionManagerClick: function() { onConnectionManagerClick: function () {
deluge.connectionManager.show(); deluge.connectionManager.show();
}, },
onHelpClick: function() { onHelpClick: function () {
window.open('http://dev.deluge-torrent.org/wiki/UserGuide'); window.open('http://dev.deluge-torrent.org/wiki/UserGuide');
}, },
onAboutClick: function() { onAboutClick: function () {
var about = new Deluge.about.AboutWindow(); var about = new Deluge.about.AboutWindow();
about.show(); about.show();
}, },
onPreferencesClick: function() { onPreferencesClick: function () {
deluge.preferences.show(); deluge.preferences.show();
}, },
onTorrentAction: function(item) { onTorrentAction: function (item) {
var selection = deluge.torrents.getSelections(); var selection = deluge.torrents.getSelections();
var ids = []; var ids = [];
Ext.each(selection, function(record) { Ext.each(selection, function (record) {
ids.push(record.id); ids.push(record.id);
}); });
@ -184,7 +184,7 @@ Deluge.Toolbar = Ext.extend(Ext.Toolbar, {
case 'pause': case 'pause':
case 'resume': case 'resume':
deluge.client.core[item.id + '_torrent'](ids, { deluge.client.core[item.id + '_torrent'](ids, {
success: function() { success: function () {
deluge.ui.update(); deluge.ui.update();
}, },
}); });
@ -192,7 +192,7 @@ Deluge.Toolbar = Ext.extend(Ext.Toolbar, {
case 'up': case 'up':
case 'down': case 'down':
deluge.client.core['queue_' + item.id](ids, { deluge.client.core['queue_' + item.id](ids, {
success: function() { success: function () {
deluge.ui.update(); deluge.ui.update();
}, },
}); });
@ -200,7 +200,7 @@ Deluge.Toolbar = Ext.extend(Ext.Toolbar, {
} }
}, },
onTorrentAdd: function() { onTorrentAdd: function () {
deluge.add.show(); deluge.add.show();
}, },
}); });

View File

@ -8,7 +8,7 @@
* See LICENSE for more details. * See LICENSE for more details.
*/ */
(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;
@ -337,21 +337,21 @@
key: 'a', key: 'a',
ctrl: true, ctrl: true,
stopEvent: true, stopEvent: true,
handler: function() { handler: function () {
deluge.torrents.getSelectionModel().selectAll(); deluge.torrents.getSelectionModel().selectAll();
}, },
}, },
{ {
key: [46], key: [46],
stopEvent: true, stopEvent: true,
handler: function() { handler: function () {
ids = deluge.torrents.getSelectedIds(); ids = deluge.torrents.getSelectedIds();
deluge.removeWindow.show(ids); deluge.removeWindow.show(ids);
}, },
}, },
], ],
constructor: function(config) { constructor: function (config) {
config = Ext.apply( config = Ext.apply(
{ {
id: 'torrentGrid', id: 'torrentGrid',
@ -376,12 +376,12 @@
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)) {
@ -397,7 +397,7 @@
* @param index {int} The row index of the torrent you wish to retrieve. * @param index {int} The row index of the torrent you wish to retrieve.
* @return {Ext.data.Record} The record representing the torrent. * @return {Ext.data.Record} The record representing the torrent.
*/ */
getTorrent: function(index) { getTorrent: function (index) {
return this.getStore().getAt(index); return this.getStore().getAt(index);
}, },
@ -405,14 +405,14 @@
* Returns the currently selected record. * Returns the currently selected record.
* @ return {Array/Ext.data.Record} The record(s) representing the rows * @ return {Array/Ext.data.Record} The record(s) representing the rows
*/ */
getSelected: function() { getSelected: function () {
return this.getSelectionModel().getSelected(); return this.getSelectionModel().getSelected();
}, },
/** /**
* Returns the currently selected records. * Returns the currently selected records.
*/ */
getSelections: function() { getSelections: function () {
return this.getSelectionModel().getSelections(); return this.getSelectionModel().getSelections();
}, },
@ -420,7 +420,7 @@
* Return the currently selected torrent id. * Return the currently selected torrent id.
* @return {String} The currently selected id. * @return {String} The currently selected id.
*/ */
getSelectedId: function() { getSelectedId: function () {
return this.getSelectionModel().getSelected().id; return this.getSelectionModel().getSelected().id;
}, },
@ -428,15 +428,15 @@
* Return the currently selected torrent ids. * Return the currently selected torrent ids.
* @return {Array} The currently selected ids. * @return {Array} The currently selected ids.
*/ */
getSelectedIds: function() { getSelectedIds: function () {
var ids = []; var ids = [];
Ext.each(this.getSelectionModel().getSelections(), function(r) { Ext.each(this.getSelectionModel().getSelections(), function (r) {
ids.push(r.id); ids.push(r.id);
}); });
return ids; return ids;
}, },
update: function(torrents, wipe) { update: function (torrents, wipe) {
var store = this.getStore(); var store = this.getStore();
// Need to perform a complete reload of the torrent grid. // Need to perform a complete reload of the torrent grid.
@ -470,7 +470,7 @@
store.add(newTorrents); store.add(newTorrents);
// Remove any torrents that should not be in the store. // Remove any torrents that should not be in the store.
store.each(function(record) { store.each(function (record) {
if (!torrents[record.id]) { if (!torrents[record.id]) {
store.remove(record); store.remove(record);
delete this.torrents[record.id]; delete this.torrents[record.id];
@ -484,17 +484,17 @@
}, },
// private // private
onDisconnect: function() { onDisconnect: function () {
this.getStore().removeAll(); this.getStore().removeAll();
this.torrents = {}; this.torrents = {};
}, },
// private // private
onTorrentsRemoved: function(torrentIds) { onTorrentsRemoved: function (torrentIds) {
var selModel = this.getSelectionModel(); var selModel = this.getSelectionModel();
Ext.each( Ext.each(
torrentIds, torrentIds,
function(torrentId) { function (torrentId) {
var record = this.getStore().getById(torrentId); var record = this.getStore().getById(torrentId);
if (selModel.isSelected(record)) { if (selModel.isSelected(record)) {
selModel.deselectRow(this.getStore().indexOf(record)); selModel.deselectRow(this.getStore().indexOf(record));

View File

@ -42,7 +42,7 @@ deluge.ui = {
* @description Create all the interface components, the json-rpc client * @description Create all the interface components, the json-rpc client
* and set up various events that the UI will utilise. * and set up various events that the UI will utilise.
*/ */
initialize: function() { initialize: function () {
deluge.add = new Deluge.add.AddWindow(); deluge.add = new Deluge.add.AddWindow();
deluge.details = new Deluge.details.DetailsPanel(); deluge.details = new Deluge.details.DetailsPanel();
deluge.connectionManager = new Deluge.ConnectionManager(); deluge.connectionManager = new Deluge.ConnectionManager();
@ -100,7 +100,7 @@ deluge.ui = {
deluge.client.on( deluge.client.on(
'connected', 'connected',
function(e) { function (e) {
deluge.login.show(); deluge.login.show();
}, },
this, this,
@ -113,7 +113,7 @@ deluge.ui = {
this.originalTitle = document.title; this.originalTitle = document.title;
}, },
checkConnection: function() { checkConnection: function () {
deluge.client.web.connected({ deluge.client.web.connected({
success: this.onConnectionSuccess, success: this.onConnectionSuccess,
failure: this.onConnectionError, failure: this.onConnectionError,
@ -121,7 +121,7 @@ deluge.ui = {
}); });
}, },
update: function() { update: function () {
var filters = deluge.sidebar.getFilterStates(); var filters = deluge.sidebar.getFilterStates();
this.oldFilters = this.filters; this.oldFilters = this.filters;
this.filters = filters; this.filters = filters;
@ -134,9 +134,9 @@ deluge.ui = {
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'),
@ -147,7 +147,7 @@ deluge.ui = {
} }
}, },
onUpdateError: function(error) { onUpdateError: function (error) {
if (this.errorCount == 2) { if (this.errorCount == 2) {
Ext.MessageBox.show({ Ext.MessageBox.show({
title: _('Lost Connection'), title: _('Lost Connection'),
@ -169,7 +169,7 @@ deluge.ui = {
* @private * @private
* Updates the various components in the interface. * Updates the various components in the interface.
*/ */
onUpdate: function(data) { onUpdate: function (data) {
if (!data['connected']) { if (!data['connected']) {
deluge.connectionManager.disconnect(true); deluge.connectionManager.disconnect(true);
return; return;
@ -199,7 +199,7 @@ deluge.ui = {
* @private * @private
* Start the Deluge UI polling the server and update the interface. * Start the Deluge UI polling the server and update the interface.
*/ */
onConnect: function() { onConnect: function () {
if (!this.running) { if (!this.running) {
this.running = setInterval(this.update, 2000); this.running = setInterval(this.update, 2000);
this.update(); this.update();
@ -214,14 +214,14 @@ deluge.ui = {
* @static * @static
* @private * @private
*/ */
onDisconnect: function() { onDisconnect: function () {
this.stop(); this.stop();
}, },
onGotPlugins: function(plugins) { onGotPlugins: function (plugins) {
Ext.each( Ext.each(
plugins.enabled_plugins, plugins.enabled_plugins,
function(plugin) { function (plugin) {
if (deluge.plugins[plugin]) return; if (deluge.plugins[plugin]) return;
deluge.client.web.get_plugin_resources(plugin, { deluge.client.web.get_plugin_resources(plugin, {
success: this.onGotPluginResources, success: this.onGotPluginResources,
@ -232,7 +232,7 @@ deluge.ui = {
); );
}, },
onPluginEnabled: function(pluginName) { onPluginEnabled: function (pluginName) {
if (deluge.plugins[pluginName]) { if (deluge.plugins[pluginName]) {
deluge.plugins[pluginName].enable(); deluge.plugins[pluginName].enable();
} else { } else {
@ -243,13 +243,13 @@ deluge.ui = {
} }
}, },
onGotPluginResources: function(resources) { onGotPluginResources: function (resources) {
var scripts = Deluge.debug var scripts = Deluge.debug
? resources.debug_scripts ? resources.debug_scripts
: resources.scripts; : resources.scripts;
Ext.each( Ext.each(
scripts, scripts,
function(script) { function (script) {
Ext.ux.JSLoader({ Ext.ux.JSLoader({
url: deluge.config.base + script, url: deluge.config.base + script,
onLoad: this.onPluginLoaded, onLoad: this.onPluginLoaded,
@ -260,11 +260,11 @@ deluge.ui = {
); );
}, },
onPluginDisabled: function(pluginName) { onPluginDisabled: function (pluginName) {
if (deluge.plugins[pluginName]) deluge.plugins[pluginName].disable(); if (deluge.plugins[pluginName]) deluge.plugins[pluginName].disable();
}, },
onPluginLoaded: function(options) { onPluginLoaded: function (options) {
// This could happen if the plugin has multiple scripts // This could happen if the plugin has multiple scripts
if (!Deluge.hasPlugin(options.pluginName)) return; if (!Deluge.hasPlugin(options.pluginName)) return;
@ -278,7 +278,7 @@ deluge.ui = {
* @static * @static
* Stop the Deluge UI polling the server and clear the interface. * Stop the Deluge UI polling the server and clear the interface.
*/ */
stop: function() { stop: function () {
if (this.running) { if (this.running) {
clearInterval(this.running); clearInterval(this.running);
this.running = false; this.running = false;
@ -287,6 +287,6 @@ deluge.ui = {
}, },
}; };
Ext.onReady(function(e) { Ext.onReady(function (e) {
deluge.ui.initialize(); deluge.ui.initialize();
}); });

View File

@ -12,7 +12,7 @@ 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( Ext.ux.form.FileUploadField.superclass.onRender.call(
this, this,
ct, ct,
@ -58,7 +58,7 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
plain: true, plain: true,
iconCls: 'x-deluge-add-window-icon', iconCls: 'x-deluge-add-window-icon',
initComponent: function() { initComponent: function () {
Deluge.add.AddWindow.superclass.initComponent.call(this); Deluge.add.AddWindow.superclass.initComponent.call(this);
this.addButton(_('Cancel'), this.onCancelClick, this); this.addButton(_('Cancel'), this.onCancelClick, this);
@ -168,17 +168,17 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
this.on('show', this.onShow, this); this.on('show', this.onShow, this);
}, },
clear: function() { clear: function () {
this.list.getStore().removeAll(); this.list.getStore().removeAll();
this.optionsPanel.clear(); this.optionsPanel.clear();
// Reset upload form so handler fires when a canceled file is reselected // Reset upload form so handler fires when a canceled file is reselected
this.fileUploadForm.reset(); this.fileUploadForm.reset();
}, },
onAddClick: function() { onAddClick: function () {
var torrents = []; var torrents = [];
if (!this.list) return; if (!this.list) return;
this.list.getStore().each(function(r) { this.list.getStore().each(function (r) {
var id = r.get('info_hash'); var id = r.get('info_hash');
torrents.push({ torrents.push({
path: this.optionsPanel.getFilename(id), path: this.optionsPanel.getFilename(id),
@ -187,29 +187,29 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
}, this); }, this);
deluge.client.web.add_torrents(torrents, { deluge.client.web.add_torrents(torrents, {
success: function(result) {}, success: function (result) {},
}); });
this.clear(); this.clear();
this.hide(); this.hide();
}, },
onCancelClick: function() { onCancelClick: function () {
this.clear(); this.clear();
this.hide(); this.hide();
}, },
onFile: function() { onFile: function () {
if (!this.file) this.file = new Deluge.add.FileWindow(); if (!this.file) this.file = new Deluge.add.FileWindow();
this.file.show(); this.file.show();
}, },
onHide: function() { onHide: function () {
this.optionsPanel.setActiveTab(0); this.optionsPanel.setActiveTab(0);
this.optionsPanel.files.setDisabled(true); this.optionsPanel.files.setDisabled(true);
this.optionsPanel.form.setDisabled(true); this.optionsPanel.form.setDisabled(true);
}, },
onRemove: function() { onRemove: function () {
if (!this.list.getSelectionCount()) return; if (!this.list.getSelectionCount()) return;
var torrent = this.list.getSelectedRecords()[0]; var torrent = this.list.getSelectedRecords()[0];
if (!torrent) return; if (!torrent) return;
@ -220,7 +220,7 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
delete this.torrents[torrent.id]; delete this.torrents[torrent.id];
}, },
onSelect: function(list, selections) { onSelect: function (list, selections) {
if (selections.length) { if (selections.length) {
var record = this.list.getRecord(selections[0]); var record = this.list.getRecord(selections[0]);
this.optionsPanel.setTorrent(record.get('info_hash')); this.optionsPanel.setTorrent(record.get('info_hash'));
@ -230,7 +230,7 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
} }
}, },
onShow: function() { onShow: function () {
if (!this.url) { if (!this.url) {
this.url = new Deluge.add.UrlWindow(); this.url = new Deluge.add.UrlWindow();
this.url.on('beforeadd', this.onTorrentBeforeAdd, this); this.url.on('beforeadd', this.onTorrentBeforeAdd, this);
@ -241,14 +241,14 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
this.optionsPanel.form.getDefaults(); this.optionsPanel.form.getDefaults();
}, },
onFileSelected: function() { onFileSelected: function () {
if (this.fileUploadForm.isValid()) { if (this.fileUploadForm.isValid()) {
var torrentIds = []; var torrentIds = [];
var files = this.fileUploadForm.findField('torrentFile').value; var files = this.fileUploadForm.findField('torrentFile').value;
var randomId = this.createTorrentId(); var randomId = this.createTorrentId();
Array.prototype.forEach.call( Array.prototype.forEach.call(
files, files,
function(file, i) { function (file, i) {
// Append index for batch of unique torrentIds. // Append index for batch of unique torrentIds.
var torrentId = randomId + i.toString(); var torrentId = randomId + i.toString();
torrentIds.push(torrentId); torrentIds.push(torrentId);
@ -266,14 +266,14 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
} }
}, },
onUploadSuccess: function(fp, upload) { onUploadSuccess: function (fp, upload) {
if (!upload.result.success) { if (!upload.result.success) {
this.clear(); this.clear();
return; return;
} }
upload.result.files.forEach( upload.result.files.forEach(
function(filename, i) { function (filename, i) {
deluge.client.web.get_torrent_info(filename, { deluge.client.web.get_torrent_info(filename, {
success: this.onGotInfo, success: this.onGotInfo,
scope: this, scope: this,
@ -285,7 +285,7 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
this.fileUploadForm.reset(); this.fileUploadForm.reset();
}, },
onUploadFailure: function(form, action) { onUploadFailure: function (form, action) {
this.hide(); this.hide();
Ext.MessageBox.show({ Ext.MessageBox.show({
title: _('Error'), title: _('Error'),
@ -298,18 +298,18 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
this.fireEvent('addfailed', this.torrentId); this.fireEvent('addfailed', this.torrentId);
}, },
onGotInfo: function(info, obj, response, request) { onGotInfo: function (info, obj, response, request) {
info.filename = request.options.filename; info.filename = request.options.filename;
torrentId = request.options.torrentId; torrentId = request.options.torrentId;
this.onTorrentAdd(torrentId, info); this.onTorrentAdd(torrentId, info);
}, },
onTorrentBeforeAdd: function(torrentId, text) { onTorrentBeforeAdd: function (torrentId, text) {
var store = this.list.getStore(); var store = this.list.getStore();
store.loadData([[torrentId, null, text]], true); store.loadData([[torrentId, null, text]], true);
}, },
onTorrentAdd: function(torrentId, info) { onTorrentAdd: function (torrentId, info) {
var r = this.list.getStore().getById(torrentId); var r = this.list.getStore().getById(torrentId);
if (!info) { if (!info) {
Ext.MessageBox.show({ Ext.MessageBox.show({
@ -330,7 +330,7 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
} }
}, },
onTorrentAddFailed: function(torrentId) { onTorrentAddFailed: function (torrentId) {
var store = this.list.getStore(); var store = this.list.getStore();
var torrentRecord = store.getById(torrentId); var torrentRecord = store.getById(torrentId);
if (torrentRecord) { if (torrentRecord) {
@ -338,7 +338,7 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
} }
}, },
onUrl: function(button, event) { onUrl: function (button, event) {
this.url.show(); this.url.show();
}, },
}); });

View File

@ -34,7 +34,7 @@ Deluge.add.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
width: 60, width: 60,
dataIndex: 'size', dataIndex: 'size',
tpl: new Ext.XTemplate('{size:this.fsize}', { tpl: new Ext.XTemplate('{size:this.fsize}', {
fsize: function(v) { fsize: function (v) {
return fsize(v); return fsize(v);
}, },
}), }),
@ -44,7 +44,7 @@ Deluge.add.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
width: 65, width: 65,
dataIndex: 'download', dataIndex: 'download',
tpl: new Ext.XTemplate('{download:this.format}', { tpl: new Ext.XTemplate('{download:this.format}', {
format: function(v) { format: function (v) {
return ( return (
'<div rel="chkbox" class="x-grid3-check-col' + '<div rel="chkbox" class="x-grid3-check-col' +
(v ? '-on' : '') + (v ? '-on' : '') +
@ -55,21 +55,21 @@ Deluge.add.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
}, },
], ],
initComponent: function() { initComponent: function () {
Deluge.add.FilesTab.superclass.initComponent.call(this); Deluge.add.FilesTab.superclass.initComponent.call(this);
this.on('click', this.onNodeClick, this); this.on('click', this.onNodeClick, this);
}, },
clearFiles: function() { clearFiles: function () {
var root = this.getRootNode(); var root = this.getRootNode();
if (!root.hasChildNodes()) return; if (!root.hasChildNodes()) return;
root.cascade(function(node) { root.cascade(function (node) {
if (!node.parentNode || !node.getOwnerTree()) return; if (!node.parentNode || !node.getOwnerTree()) return;
node.remove(); node.remove();
}); });
}, },
setDownload: function(node, value, suppress) { setDownload: function (node, value, suppress) {
node.attributes.download = value; node.attributes.download = value;
node.ui.updateColumns(); node.ui.updateColumns();
@ -79,7 +79,7 @@ Deluge.add.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
} }
} else { } else {
var nodes = [node]; var nodes = [node];
node.cascade(function(n) { node.cascade(function (n) {
n.attributes.download = value; n.attributes.download = value;
n.ui.updateColumns(); n.ui.updateColumns();
nodes.push(n); nodes.push(n);
@ -90,7 +90,7 @@ Deluge.add.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
} }
}, },
onNodeClick: function(node, e) { onNodeClick: function (node, e) {
var el = new Ext.Element(e.target); var el = new Ext.Element(e.target);
if (el.getAttribute('rel') == 'chkbox') { if (el.getAttribute('rel') == 'chkbox') {
this.setDownload(node, !node.attributes.download); this.setDownload(node, !node.attributes.download);

View File

@ -18,7 +18,7 @@ Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
activeTab: 0, activeTab: 0,
height: 265, height: 265,
initComponent: function() { initComponent: function () {
Deluge.add.OptionsPanel.superclass.initComponent.call(this); Deluge.add.OptionsPanel.superclass.initComponent.call(this);
this.files = this.add(new Deluge.add.FilesTab()); this.files = this.add(new Deluge.add.FilesTab());
this.form = this.add(new Deluge.add.OptionsTab()); this.form = this.add(new Deluge.add.OptionsTab());
@ -26,12 +26,12 @@ Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
this.files.on('fileschecked', this.onFilesChecked, this); this.files.on('fileschecked', this.onFilesChecked, this);
}, },
addTorrent: function(torrent) { addTorrent: function (torrent) {
this.torrents[torrent['info_hash']] = torrent; this.torrents[torrent['info_hash']] = torrent;
var fileIndexes = {}; var fileIndexes = {};
this.walkFileTree( this.walkFileTree(
torrent['files_tree'], torrent['files_tree'],
function(filename, type, entry, parent) { function (filename, type, entry, parent) {
if (type != 'file') return; if (type != 'file') return;
fileIndexes[entry.index] = entry.download; fileIndexes[entry.index] = entry.download;
}, },
@ -39,7 +39,7 @@ Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
); );
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];
}); });
@ -51,26 +51,26 @@ Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
this.form.optionsManager.changeId(oldId, true); this.form.optionsManager.changeId(oldId, true);
}, },
clear: function() { clear: function () {
this.files.clearFiles(); this.files.clearFiles();
this.form.optionsManager.resetAll(); this.form.optionsManager.resetAll();
}, },
getFilename: function(torrentId) { getFilename: function (torrentId) {
return this.torrents[torrentId]['filename']; return this.torrents[torrentId]['filename'];
}, },
getOptions: function(torrentId) { getOptions: function (torrentId) {
var oldId = this.form.optionsManager.changeId(torrentId, true); var oldId = this.form.optionsManager.changeId(torrentId, true);
var options = this.form.optionsManager.get(); var options = this.form.optionsManager.get();
this.form.optionsManager.changeId(oldId, true); this.form.optionsManager.changeId(oldId, true);
Ext.each(options['file_priorities'], function(priority, index) { Ext.each(options['file_priorities'], function (priority, index) {
options['file_priorities'][index] = priority ? 1 : 0; options['file_priorities'][index] = priority ? 1 : 0;
}); });
return options; return options;
}, },
setTorrent: function(torrentId) { setTorrent: function (torrentId) {
if (!torrentId) return; if (!torrentId) return;
this.torrentId = torrentId; this.torrentId = torrentId;
@ -85,7 +85,7 @@ Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
if (this.torrents[torrentId]['files_tree']) { if (this.torrents[torrentId]['files_tree']) {
this.walkFileTree( this.walkFileTree(
this.torrents[torrentId]['files_tree'], this.torrents[torrentId]['files_tree'],
function(filename, type, entry, parentNode) { function (filename, type, entry, parentNode) {
var node = new Ext.tree.TreeNode({ var node = new Ext.tree.TreeNode({
download: entry.index ? priorities[entry.index] : true, download: entry.index ? priorities[entry.index] : true,
filename: filename, filename: filename,
@ -109,7 +109,7 @@ Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
} }
}, },
walkFileTree: function(files, callback, scope, parentNode) { walkFileTree: function (files, callback, scope, parentNode) {
for (var filename in files.contents) { for (var filename in files.contents) {
var entry = files.contents[filename]; var entry = files.contents[filename];
var type = entry.type; var type = entry.type;
@ -129,10 +129,10 @@ Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
} }
}, },
onFilesChecked: function(nodes, newValue, oldValue) { onFilesChecked: function (nodes, newValue, oldValue) {
Ext.each( Ext.each(
nodes, nodes,
function(node) { function (node) {
if (node.attributes.fileindex < 0) return; if (node.attributes.fileindex < 0) return;
var priorities = this.form.optionsManager.get( var priorities = this.form.optionsManager.get(
'file_priorities' 'file_priorities'

View File

@ -21,7 +21,7 @@ Deluge.add.OptionsTab = Ext.extend(Ext.form.FormPanel, {
disabled: true, disabled: true,
labelWidth: 1, labelWidth: 1,
initComponent: function() { initComponent: function () {
Deluge.add.OptionsTab.superclass.initComponent.call(this); Deluge.add.OptionsTab.superclass.initComponent.call(this);
this.optionsManager = new Deluge.MultiOptionsManager(); this.optionsManager = new Deluge.MultiOptionsManager();
@ -174,7 +174,7 @@ Deluge.add.OptionsTab = Ext.extend(Ext.form.FormPanel, {
); );
}, },
getDefaults: function() { getDefaults: function () {
var keys = [ var keys = [
'add_paused', 'add_paused',
'pre_allocate_storage', 'pre_allocate_storage',
@ -190,7 +190,7 @@ Deluge.add.OptionsTab = Ext.extend(Ext.form.FormPanel, {
]; ];
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,

View File

@ -22,7 +22,7 @@ Deluge.add.UrlWindow = Ext.extend(Deluge.add.Window, {
bodyStyle: 'padding: 10px 5px;', bodyStyle: 'padding: 10px 5px;',
iconCls: 'x-deluge-add-url-window-icon', iconCls: 'x-deluge-add-url-window-icon',
initComponent: function() { initComponent: function () {
Deluge.add.UrlWindow.superclass.initComponent.call(this); Deluge.add.UrlWindow.superclass.initComponent.call(this);
this.addButton(_('Add'), this.onAddClick, this); this.addButton(_('Add'), this.onAddClick, this);
@ -50,7 +50,7 @@ Deluge.add.UrlWindow = Ext.extend(Deluge.add.Window, {
this.cookieField.on('specialkey', this.onAdd, this); this.cookieField.on('specialkey', this.onAdd, this);
}, },
onAddClick: function(field, e) { onAddClick: function (field, e) {
if ( if (
(field.id == 'url' || field.id == 'cookies') && (field.id == 'url' || field.id == 'cookies') &&
e.getKey() != e.ENTER e.getKey() != e.ENTER
@ -83,7 +83,7 @@ Deluge.add.UrlWindow = Ext.extend(Deluge.add.Window, {
this.fireEvent('beforeadd', torrentId, url); this.fireEvent('beforeadd', torrentId, url);
}, },
onDownload: function(filename, obj, resp, req) { onDownload: function (filename, obj, resp, req) {
deluge.client.web.get_torrent_info(filename, { deluge.client.web.get_torrent_info(filename, {
success: this.onGotInfo, success: this.onGotInfo,
failure: this.onDownloadFailed, failure: this.onDownloadFailed,
@ -93,7 +93,7 @@ Deluge.add.UrlWindow = Ext.extend(Deluge.add.Window, {
}); });
}, },
onDownloadFailed: function(obj, resp, req) { onDownloadFailed: function (obj, resp, req) {
Ext.MessageBox.show({ Ext.MessageBox.show({
title: _('Error'), title: _('Error'),
msg: _('Failed to download torrent'), msg: _('Failed to download torrent'),
@ -105,7 +105,7 @@ Deluge.add.UrlWindow = Ext.extend(Deluge.add.Window, {
this.fireEvent('addfailed', req.options.torrentId); this.fireEvent('addfailed', 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

@ -15,7 +15,7 @@ Ext.ns('Deluge.add');
* Base class for an add Window * Base class for an add Window
*/ */
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('beforeadd', 'add', 'addfailed'); this.addEvents('beforeadd', 'add', 'addfailed');
}, },
@ -23,7 +23,7 @@ Deluge.add.Window = Ext.extend(Ext.Window, {
/** /**
* Create an id for the torrent before we have any info about it. * Create an id for the torrent before we have any info about it.
*/ */
createTorrentId: function() { createTorrentId: function () {
return new Date().getTime().toString(); return new Date().getTime().toString();
}, },
}); });

View File

@ -27,11 +27,11 @@ Deluge.data.SortTypes = {
return ((+d[1] * 256 + (+d[2])) * 256 + (+d[3])) * 256 + (+d[4]); return ((+d[1] * 256 + (+d[2])) * 256 + (+d[3])) * 256 + (+d[4]);
}, },
asQueuePosition: function(value) { asQueuePosition: function (value) {
return value > -1 ? value : Number.MAX_VALUE; return value > -1 ? value : Number.MAX_VALUE;
}, },
asName: function(value) { asName: function (value) {
return String(value).toLowerCase(); return String(value).toLowerCase();
}, },
}; };

View File

@ -16,7 +16,7 @@ Deluge.details.DetailsPanel = Ext.extend(Ext.TabPanel, {
id: 'torrentDetails', id: 'torrentDetails',
activeTab: 0, activeTab: 0,
initComponent: function() { initComponent: function () {
Deluge.details.DetailsPanel.superclass.initComponent.call(this); Deluge.details.DetailsPanel.superclass.initComponent.call(this);
this.add(new Deluge.details.StatusTab()); this.add(new Deluge.details.StatusTab());
this.add(new Deluge.details.DetailsTab()); this.add(new Deluge.details.DetailsTab());
@ -25,8 +25,8 @@ Deluge.details.DetailsPanel = Ext.extend(Ext.TabPanel, {
this.add(new Deluge.details.OptionsTab()); this.add(new Deluge.details.OptionsTab());
}, },
clear: function() { clear: function () {
this.items.each(function(panel) { this.items.each(function (panel) {
if (panel.clear) { if (panel.clear) {
panel.clear.defer(100, panel); panel.clear.defer(100, panel);
panel.disable(); panel.disable();
@ -34,14 +34,14 @@ Deluge.details.DetailsPanel = Ext.extend(Ext.TabPanel, {
}); });
}, },
update: function(tab) { update: function (tab) {
var torrent = deluge.torrents.getSelected(); var torrent = deluge.torrents.getSelected();
if (!torrent) { if (!torrent) {
this.clear(); this.clear();
return; return;
} }
this.items.each(function(tab) { this.items.each(function (tab) {
if (tab.disabled) tab.enable(); if (tab.disabled) tab.enable();
}); });
@ -52,7 +52,7 @@ Deluge.details.DetailsPanel = Ext.extend(Ext.TabPanel, {
/* Event Handlers */ /* Event Handlers */
// 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( Deluge.details.DetailsPanel.superclass.onRender.call(
this, this,
ct, ct,
@ -64,18 +64,18 @@ Deluge.details.DetailsPanel = Ext.extend(Ext.TabPanel, {
deluge.torrents.getSelectionModel().on( deluge.torrents.getSelectionModel().on(
'selectionchange', 'selectionchange',
function(selModel) { function (selModel) {
if (!selModel.hasSelection()) this.clear(); if (!selModel.hasSelection()) this.clear();
}, },
this this
); );
}, },
onTabChange: function(panel, tab) { onTabChange: function (panel, tab) {
this.update(tab); this.update(tab);
}, },
onTorrentsClick: function(grid, rowIndex, e) { onTorrentsClick: function (grid, rowIndex, e) {
this.update(); this.update();
}, },
}); });

View File

@ -18,7 +18,7 @@ Deluge.details.DetailsTab = Ext.extend(Ext.Panel, {
oldData: {}, oldData: {},
initComponent: function() { initComponent: function () {
Deluge.details.DetailsTab.superclass.initComponent.call(this); Deluge.details.DetailsTab.superclass.initComponent.call(this);
this.addItem('torrent_name', _('Name:')); this.addItem('torrent_name', _('Name:'));
this.addItem('hash', _('Hash:')); this.addItem('hash', _('Hash:'));
@ -31,7 +31,7 @@ Deluge.details.DetailsTab = Ext.extend(Ext.Panel, {
this.addItem('creator', _('Created By:')); this.addItem('creator', _('Created By:'));
}, },
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);
@ -41,7 +41,7 @@ Deluge.details.DetailsTab = Ext.extend(Ext.Panel, {
} }
}, },
addItem: function(id, label) { addItem: function (id, label) {
if (!this.rendered) { if (!this.rendered) {
this.queuedItems[id] = label; this.queuedItems[id] = label;
} else { } else {
@ -50,7 +50,7 @@ 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.fields[id] = Ext.DomHelper.append(
this.dl, this.dl,
@ -59,7 +59,7 @@ Deluge.details.DetailsTab = Ext.extend(Ext.Panel, {
); );
}, },
clear: function() { clear: function () {
if (!this.fields) return; if (!this.fields) return;
for (var k in this.fields) { for (var k in this.fields) {
this.fields[k].dom.innerHTML = ''; this.fields[k].dom.innerHTML = '';
@ -67,7 +67,7 @@ Deluge.details.DetailsTab = Ext.extend(Ext.Panel, {
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,
@ -75,7 +75,7 @@ Deluge.details.DetailsTab = Ext.extend(Ext.Panel, {
}); });
}, },
onRequestComplete: function(torrent, request, response, options) { onRequestComplete: function (torrent, request, response, options) {
var data = { var data = {
torrent_name: torrent.name, torrent_name: torrent.name,
hash: options.options.torrentId, hash: options.options.torrentId,

View File

@ -24,7 +24,7 @@ Deluge.details.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
width: 150, width: 150,
dataIndex: 'size', dataIndex: 'size',
tpl: new Ext.XTemplate('{size:this.fsize}', { tpl: new Ext.XTemplate('{size:this.fsize}', {
fsize: function(v) { fsize: function (v) {
return fsize(v); return fsize(v);
}, },
}), }),
@ -34,7 +34,7 @@ Deluge.details.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
header: _('Progress'), header: _('Progress'),
width: 150, width: 150,
dataIndex: 'progress', dataIndex: 'progress',
renderer: function(v) { renderer: function (v) {
var progress = v * 100; var progress = v * 100;
return Deluge.progressBar( return Deluge.progressBar(
progress, progress,
@ -54,11 +54,11 @@ Deluge.details.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
'{priority:this.getName}' + '{priority:this.getName}' +
'</div></tpl>', '</div></tpl>',
{ {
getClass: function(v) { getClass: function (v) {
return FILE_PRIORITY_CSS[v]; return FILE_PRIORITY_CSS[v];
}, },
getName: function(v) { getName: function (v) {
return _(FILE_PRIORITY[v]); return _(FILE_PRIORITY[v]);
}, },
} }
@ -68,15 +68,15 @@ Deluge.details.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
selModel: new Ext.tree.MultiSelectionModel(), selModel: new Ext.tree.MultiSelectionModel(),
initComponent: function() { initComponent: function () {
Deluge.details.FilesTab.superclass.initComponent.call(this); Deluge.details.FilesTab.superclass.initComponent.call(this);
this.setRootNode(new Ext.tree.TreeNode({ text: _('Files') })); this.setRootNode(new Ext.tree.TreeNode({ text: _('Files') }));
}, },
clear: function() { clear: function () {
var root = this.getRootNode(); var root = this.getRootNode();
if (!root.hasChildNodes()) return; if (!root.hasChildNodes()) return;
root.cascade(function(node) { root.cascade(function (node) {
var parentNode = node.parentNode; var parentNode = node.parentNode;
if (!parentNode) return; if (!parentNode) return;
if (!parentNode.ownerTree) return; if (!parentNode.ownerTree) return;
@ -84,7 +84,7 @@ Deluge.details.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
}); });
}, },
createFileTree: function(files) { createFileTree: function (files) {
function walk(files, parentNode) { function walk(files, parentNode) {
for (var file in files.contents) { for (var file in files.contents) {
var item = files.contents[file]; var item = files.contents[file];
@ -123,7 +123,7 @@ Deluge.details.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
root.firstChild.expand(); root.firstChild.expand();
}, },
update: function(torrentId) { update: function (torrentId) {
if (this.torrentId != torrentId) { if (this.torrentId != torrentId) {
this.clear(); this.clear();
this.torrentId = torrentId; this.torrentId = torrentId;
@ -136,7 +136,7 @@ Deluge.details.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
}); });
}, },
updateFileTree: function(files) { updateFileTree: function (files) {
function walk(files, parentNode) { function walk(files, parentNode) {
for (var file in files.contents) { for (var file in files.contents) {
var item = files.contents[file]; var item = files.contents[file];
@ -153,7 +153,7 @@ Deluge.details.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
walk(files, this.getRootNode()); walk(files, this.getRootNode());
}, },
onRender: function(ct, position) { onRender: function (ct, position) {
Deluge.details.FilesTab.superclass.onRender.call(this, ct, position); Deluge.details.FilesTab.superclass.onRender.call(this, ct, position);
deluge.menus.filePriorities.on('itemclick', this.onItemClick, this); deluge.menus.filePriorities.on('itemclick', this.onItemClick, this);
this.on('contextmenu', this.onContextMenu, this); this.on('contextmenu', this.onContextMenu, this);
@ -162,7 +162,7 @@ Deluge.details.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
}); });
}, },
onContextMenu: function(node, e) { onContextMenu: function (node, e) {
e.stopEvent(); e.stopEvent();
var selModel = this.getSelectionModel(); var selModel = this.getSelectionModel();
if (selModel.getSelectedNodes().length < 2) { if (selModel.getSelectedNodes().length < 2) {
@ -172,14 +172,14 @@ Deluge.details.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
deluge.menus.filePriorities.showAt(e.getPoint()); deluge.menus.filePriorities.showAt(e.getPoint());
}, },
onItemClick: function(baseItem, e) { onItemClick: function (baseItem, e) {
switch (baseItem.id) { switch (baseItem.id) {
case 'expandAll': case 'expandAll':
this.expandAll(); this.expandAll();
break; break;
default: default:
var indexes = {}; var indexes = {};
var walk = function(node) { var walk = function (node) {
if (Ext.isEmpty(node.attributes.fileIndex)) return; if (Ext.isEmpty(node.attributes.fileIndex)) return;
indexes[node.attributes.fileIndex] = indexes[node.attributes.fileIndex] =
node.attributes.priority; node.attributes.priority;
@ -187,9 +187,9 @@ Deluge.details.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
this.getRootNode().cascade(walk); this.getRootNode().cascade(walk);
var nodes = this.getSelectionModel().getSelectedNodes(); var nodes = this.getSelectionModel().getSelectedNodes();
Ext.each(nodes, function(node) { Ext.each(nodes, function (node) {
if (!node.isLeaf()) { if (!node.isLeaf()) {
var setPriorities = function(node) { var setPriorities = function (node) {
if (Ext.isEmpty(node.attributes.fileIndex)) return; if (Ext.isEmpty(node.attributes.fileIndex)) return;
indexes[node.attributes.fileIndex] = indexes[node.attributes.fileIndex] =
baseItem.filePriority; baseItem.filePriority;
@ -211,8 +211,8 @@ Deluge.details.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
[this.torrentId], [this.torrentId],
{ file_priorities: priorities }, { file_priorities: priorities },
{ {
success: function() { success: function () {
Ext.each(nodes, function(node) { Ext.each(nodes, function (node) {
node.setColumnValue(3, baseItem.filePriority); node.setColumnValue(3, baseItem.filePriority);
}); });
}, },
@ -223,7 +223,7 @@ Deluge.details.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
} }
}, },
onRequestComplete: function(files, options) { onRequestComplete: function (files, options) {
if (!this.getRootNode().hasChildNodes()) { if (!this.getRootNode().hasChildNodes()) {
this.createFileTree(files); this.createFileTree(files);
} else { } else {

View File

@ -9,7 +9,7 @@
*/ */
Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, { Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
constructor: function(config) { constructor: function (config) {
config = Ext.apply( config = Ext.apply(
{ {
autoScroll: true, autoScroll: true,
@ -30,7 +30,7 @@ Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
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 = {});
@ -339,7 +339,7 @@ Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
}); });
}, },
onRender: function(ct, position) { onRender: function (ct, position) {
Deluge.details.OptionsTab.superclass.onRender.call(this, ct, position); Deluge.details.OptionsTab.superclass.onRender.call(this, ct, position);
// This is another hack I think, so keep an eye out here when upgrading. // This is another hack I think, so keep an eye out here when upgrading.
@ -348,17 +348,17 @@ Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
this.doLayout(); this.doLayout();
}, },
clear: function() { clear: function () {
if (this.torrentId == null) return; if (this.torrentId == null) return;
this.torrentId = null; this.torrentId = null;
this.optionsManager.changeId(null); this.optionsManager.changeId(null);
}, },
reset: function() { reset: function () {
if (this.torrentId) this.optionsManager.reset(); if (this.torrentId) this.optionsManager.reset();
}, },
update: function(torrentId) { update: function (torrentId) {
if (this.torrentId && !torrentId) this.clear(); // we want to clear the pane if we get a null torrent torrentIds if (this.torrentId && !torrentId) this.clear(); // we want to clear the pane if we get a null torrent torrentIds
if (!torrentId) return; // We do not care about null torrentIds. if (!torrentId) return; // We do not care about null torrentIds.
@ -373,33 +373,33 @@ Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
}); });
}, },
onApply: function() { onApply: function () {
var changed = this.optionsManager.getDirty(); var changed = this.optionsManager.getDirty();
deluge.client.core.set_torrent_options([this.torrentId], changed, { deluge.client.core.set_torrent_options([this.torrentId], changed, {
success: function() { success: function () {
this.optionsManager.commit(); this.optionsManager.commit();
}, },
scope: this, scope: this,
}); });
}, },
onEditTrackers: function() { onEditTrackers: function () {
deluge.editTrackers.show(); deluge.editTrackers.show();
}, },
onMoveCompletedChecked: function(checkbox, checked) { onMoveCompletedChecked: function (checkbox, checked) {
this.fields.move_completed_path.setDisabled(!checked); this.fields.move_completed_path.setDisabled(!checked);
if (!checked) return; if (!checked) return;
this.fields.move_completed_path.focus(); this.fields.move_completed_path.focus();
}, },
onStopRatioChecked: function(checkbox, checked) { onStopRatioChecked: function (checkbox, checked) {
this.fields.remove_at_ratio.setDisabled(!checked); this.fields.remove_at_ratio.setDisabled(!checked);
this.fields.stop_ratio.setDisabled(!checked); this.fields.stop_ratio.setDisabled(!checked);
}, },
onRequestComplete: function(torrent, options) { onRequestComplete: function (torrent, options) {
this.fields['private'].setValue(torrent['private']); this.fields['private'].setValue(torrent['private']);
this.fields['private'].setDisabled(true); this.fields['private'].setDisabled(true);
delete torrent['private']; delete torrent['private'];

View File

@ -8,7 +8,7 @@
* See LICENSE for more details. * See LICENSE for more details.
*/ */
(function() { (function () {
function flagRenderer(value) { function flagRenderer(value) {
if (!value.replace(' ', '').replace(' ', '')) { if (!value.replace(' ', '').replace(' ', '')) {
return ''; return '';
@ -40,7 +40,7 @@
// fast way to figure out if we have a peer already. // fast way to figure out if we have a peer already.
peers: {}, peers: {},
constructor: function(config) { constructor: function (config) {
config = Ext.apply( config = Ext.apply(
{ {
title: _('Peers'), title: _('Peers'),
@ -107,19 +107,19 @@
Deluge.details.PeersTab.superclass.constructor.call(this, config); Deluge.details.PeersTab.superclass.constructor.call(this, config);
}, },
clear: function() { clear: function () {
this.getStore().removeAll(); this.getStore().removeAll();
this.peers = {}; this.peers = {};
}, },
update: function(torrentId) { update: function (torrentId) {
deluge.client.web.get_torrent_status(torrentId, Deluge.Keys.Peers, { deluge.client.web.get_torrent_status(torrentId, Deluge.Keys.Peers, {
success: this.onRequestComplete, success: this.onRequestComplete,
scope: this, scope: this,
}); });
}, },
onRequestComplete: function(torrent, options) { onRequestComplete: function (torrent, options) {
if (!torrent) return; if (!torrent) return;
var store = this.getStore(); var store = this.getStore();
@ -129,7 +129,7 @@
// Go through the peers updating and creating peer records // Go through the peers updating and creating peer records
Ext.each( Ext.each(
torrent.peers, torrent.peers,
function(peer) { function (peer) {
if (this.peers[peer.ip]) { if (this.peers[peer.ip]) {
var record = store.getById(peer.ip); var record = store.getById(peer.ip);
record.beginEdit(); record.beginEdit();
@ -150,7 +150,7 @@
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.
store.each(function(record) { store.each(function (record) {
if (!addresses[record.id]) { if (!addresses[record.id]) {
store.remove(record); store.remove(record);
delete this.peers[record.id]; delete this.peers[record.id];

View File

@ -17,7 +17,7 @@ Deluge.details.StatusTab = Ext.extend(Ext.Panel, {
title: _('Status'), title: _('Status'),
autoScroll: true, autoScroll: true,
onRender: function(ct, position) { onRender: function (ct, position) {
Deluge.details.StatusTab.superclass.onRender.call(this, ct, position); Deluge.details.StatusTab.superclass.onRender.call(this, ct, position);
this.progressBar = this.add({ this.progressBar = this.add({
@ -33,7 +33,7 @@ Deluge.details.StatusTab = Ext.extend(Ext.Panel, {
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') + '...',
@ -48,14 +48,14 @@ Deluge.details.StatusTab = Ext.extend(Ext.Panel, {
}); });
}, },
clear: function() { clear: function () {
this.progressBar.updateProgress(0, ' '); this.progressBar.updateProgress(0, ' ');
for (var k in this.fields) { for (var k in this.fields) {
this.fields[k].innerHTML = ''; this.fields[k].innerHTML = '';
} }
}, },
update: function(torrentId) { update: function (torrentId) {
if (!this.fields) this.getFields(); if (!this.fields) this.getFields();
deluge.client.web.get_torrent_status(torrentId, Deluge.Keys.Status, { deluge.client.web.get_torrent_status(torrentId, Deluge.Keys.Status, {
success: this.onRequestComplete, success: this.onRequestComplete,
@ -63,18 +63,18 @@ Deluge.details.StatusTab = Ext.extend(Ext.Panel, {
}); });
}, },
onPanelUpdate: function(el, response) { onPanelUpdate: function (el, response) {
this.fields = {}; this.fields = {};
Ext.each( Ext.each(
Ext.query('dd', this.status.body.dom), Ext.query('dd', this.status.body.dom),
function(field) { function (field) {
this.fields[field.className] = field; this.fields[field.className] = field;
}, },
this this
); );
}, },
onRequestComplete: function(status) { onRequestComplete: function (status) {
seeds = seeds =
status.total_seeds > -1 status.total_seeds > -1
? status.num_seeds + ' (' + status.total_seeds + ')' ? status.num_seeds + ' (' + status.total_seeds + ')'

View File

@ -14,7 +14,7 @@ Ext.namespace('Deluge.preferences');
* @extends Ext.form.FormPanel * @extends Ext.form.FormPanel
*/ */
Deluge.preferences.Bandwidth = Ext.extend(Ext.form.FormPanel, { Deluge.preferences.Bandwidth = Ext.extend(Ext.form.FormPanel, {
constructor: function(config) { constructor: function (config) {
config = Ext.apply( config = Ext.apply(
{ {
border: false, border: false,
@ -28,7 +28,7 @@ Deluge.preferences.Bandwidth = Ext.extend(Ext.form.FormPanel, {
Deluge.preferences.Bandwidth.superclass.constructor.call(this, config); Deluge.preferences.Bandwidth.superclass.constructor.call(this, config);
}, },
initComponent: function() { initComponent: function () {
Deluge.preferences.Bandwidth.superclass.initComponent.call(this); Deluge.preferences.Bandwidth.superclass.initComponent.call(this);
var om = deluge.preferences.getOptionsManager(); var om = deluge.preferences.getOptionsManager();

View File

@ -19,7 +19,7 @@ Deluge.preferences.Cache = Ext.extend(Ext.form.FormPanel, {
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);
var om = deluge.preferences.getOptionsManager(); var om = deluge.preferences.getOptionsManager();

View File

@ -19,7 +19,7 @@ Deluge.preferences.Daemon = Ext.extend(Ext.form.FormPanel, {
header: false, header: false,
layout: 'form', layout: 'form',
initComponent: function() { initComponent: function () {
Deluge.preferences.Daemon.superclass.initComponent.call(this); Deluge.preferences.Daemon.superclass.initComponent.call(this);
var om = deluge.preferences.getOptionsManager(); var om = deluge.preferences.getOptionsManager();

View File

@ -14,7 +14,7 @@ Ext.namespace('Deluge.preferences');
* @extends Ext.form.FormPanel * @extends Ext.form.FormPanel
*/ */
Deluge.preferences.Downloads = Ext.extend(Ext.FormPanel, { Deluge.preferences.Downloads = Ext.extend(Ext.FormPanel, {
constructor: function(config) { constructor: function (config) {
config = Ext.apply( config = Ext.apply(
{ {
border: false, border: false,
@ -29,7 +29,7 @@ Deluge.preferences.Downloads = Ext.extend(Ext.FormPanel, {
Deluge.preferences.Downloads.superclass.constructor.call(this, config); Deluge.preferences.Downloads.superclass.constructor.call(this, config);
}, },
initComponent: function() { initComponent: function () {
Deluge.preferences.Downloads.superclass.initComponent.call(this); Deluge.preferences.Downloads.superclass.initComponent.call(this);
var optMan = deluge.preferences.getOptionsManager(); var optMan = deluge.preferences.getOptionsManager();

View File

@ -18,7 +18,7 @@ Deluge.preferences.Encryption = Ext.extend(Ext.form.FormPanel, {
title: _('Encryption'), title: _('Encryption'),
header: false, header: false,
initComponent: function() { initComponent: function () {
Deluge.preferences.Encryption.superclass.initComponent.call(this); Deluge.preferences.Encryption.superclass.initComponent.call(this);
var optMan = deluge.preferences.getOptionsManager(); var optMan = deluge.preferences.getOptionsManager();

View File

@ -26,7 +26,7 @@ Deluge.preferences.InstallPluginWindow = Ext.extend(Ext.Window, {
modal: true, modal: true,
plain: true, plain: true,
initComponent: function() { initComponent: function () {
Deluge.preferences.InstallPluginWindow.superclass.initComponent.call( Deluge.preferences.InstallPluginWindow.superclass.initComponent.call(
this this
); );
@ -53,7 +53,7 @@ Deluge.preferences.InstallPluginWindow = Ext.extend(Ext.Window, {
}); });
}, },
onInstall: function(field, e) { onInstall: function (field, e) {
this.form.getForm().submit({ this.form.getForm().submit({
url: deluge.config.base + 'upload', url: deluge.config.base + 'upload',
waitMsg: _('Uploading your plugin...'), waitMsg: _('Uploading your plugin...'),
@ -62,11 +62,11 @@ Deluge.preferences.InstallPluginWindow = Ext.extend(Ext.Window, {
}); });
}, },
onUploadPlugin: function(info, obj, response, request) { onUploadPlugin: function (info, obj, response, request) {
this.fireEvent('pluginadded'); this.fireEvent('pluginadded');
}, },
onUploadSuccess: function(fp, upload) { onUploadSuccess: function (fp, upload) {
this.hide(); this.hide();
if (upload.result.success) { if (upload.result.success) {
var filename = this.form.getForm().getFieldValues().file; var filename = this.form.getForm().getFieldValues().file;

View File

@ -19,7 +19,7 @@ Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, {
header: false, header: false,
layout: 'form', layout: 'form',
initComponent: function() { initComponent: function () {
Deluge.preferences.Interface.superclass.initComponent.call(this); Deluge.preferences.Interface.superclass.initComponent.call(this);
var om = (this.optionsManager = new Deluge.OptionsManager()); var om = (this.optionsManager = new Deluge.OptionsManager());
@ -189,7 +189,7 @@ Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, {
); );
}, },
onApply: function() { onApply: function () {
var changed = this.optionsManager.getDirty(); var changed = this.optionsManager.getDirty();
if (!Ext.isObjectEmpty(changed)) { if (!Ext.isObjectEmpty(changed)) {
deluge.client.web.set_config(changed, { deluge.client.web.set_config(changed, {
@ -211,7 +211,7 @@ Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, {
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,
@ -223,21 +223,21 @@ Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, {
} }
}, },
onOk: function() { onOk: function () {
this.onApply(); this.onApply();
}, },
onGotConfig: function(config) { onGotConfig: function (config) {
this.optionsManager.set(config); this.optionsManager.set(config);
}, },
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'));
}, },
onPasswordChange: function() { onPasswordChange: function () {
var newPassword = this.newPassword.getValue(); var newPassword = this.newPassword.getValue();
if (newPassword != this.confirmPassword.getValue()) { if (newPassword != this.confirmPassword.getValue()) {
Ext.MessageBox.show({ Ext.MessageBox.show({
@ -253,7 +253,7 @@ Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, {
var oldPassword = this.oldPassword.getValue(); var oldPassword = this.oldPassword.getValue();
deluge.client.auth.change_password(oldPassword, newPassword, { deluge.client.auth.change_password(oldPassword, newPassword, {
success: function(result) { success: function (result) {
if (!result) { if (!result) {
Ext.MessageBox.show({ Ext.MessageBox.show({
title: _('Password'), title: _('Password'),
@ -282,11 +282,11 @@ Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, {
}); });
}, },
onSetConfig: function() { onSetConfig: function () {
this.optionsManager.commit(); this.optionsManager.commit();
}, },
onPageShow: function() { onPageShow: function () {
deluge.client.web.get_config({ deluge.client.web.get_config({
success: this.onGotConfig, success: this.onGotConfig,
scope: this, scope: this,
@ -297,7 +297,7 @@ Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, {
}); });
}, },
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,7 +11,7 @@ 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',
@ -28,7 +28,7 @@ Deluge.preferences.Network = Ext.extend(Ext.form.FormPanel, {
title: _('Network'), title: _('Network'),
header: false, header: false,
initComponent: function() { initComponent: function () {
Deluge.preferences.Network.superclass.initComponent.call(this); Deluge.preferences.Network.superclass.initComponent.call(this);
var optMan = deluge.preferences.getOptionsManager(); var optMan = deluge.preferences.getOptionsManager();
@ -71,7 +71,7 @@ Deluge.preferences.Network = Ext.extend(Ext.form.FormPanel, {
height: 22, height: 22,
listeners: { listeners: {
check: { check: {
fn: function(e, checked) { fn: function (e, checked) {
this.listenPort.setDisabled(checked); this.listenPort.setDisabled(checked);
}, },
scope: this, scope: this,
@ -133,7 +133,7 @@ Deluge.preferences.Network = Ext.extend(Ext.form.FormPanel, {
height: 22, height: 22,
listeners: { listeners: {
check: { check: {
fn: function(e, checked) { fn: function (e, checked) {
this.outgoingPorts.setDisabled(checked); this.outgoingPorts.setDisabled(checked);
}, },
scope: this, scope: this,

View File

@ -14,7 +14,7 @@ Ext.namespace('Deluge.preferences');
* @extends Ext.form.FormPanel * @extends Ext.form.FormPanel
*/ */
Deluge.preferences.Other = Ext.extend(Ext.form.FormPanel, { Deluge.preferences.Other = Ext.extend(Ext.form.FormPanel, {
constructor: function(config) { constructor: function (config) {
config = Ext.apply( config = Ext.apply(
{ {
border: false, border: false,
@ -27,7 +27,7 @@ Deluge.preferences.Other = Ext.extend(Ext.form.FormPanel, {
Deluge.preferences.Other.superclass.constructor.call(this, config); Deluge.preferences.Other.superclass.constructor.call(this, config);
}, },
initComponent: function() { initComponent: function () {
Deluge.preferences.Other.superclass.initComponent.call(this); Deluge.preferences.Other.superclass.initComponent.call(this);
var optMan = deluge.preferences.getOptionsManager(); var optMan = deluge.preferences.getOptionsManager();

View File

@ -40,7 +40,7 @@ Deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
'</dl>' '</dl>'
), ),
initComponent: function() { initComponent: function () {
Deluge.preferences.Plugins.superclass.initComponent.call(this); Deluge.preferences.Plugins.superclass.initComponent.call(this);
this.defaultValues = { this.defaultValues = {
version: '', version: '',
@ -50,7 +50,7 @@ Deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
}; };
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 ( return (
'<div class="x-grid3-check-col' + (v ? '-on' : '') + '"> </div>' '<div class="x-grid3-check-col' + (v ? '-on' : '') + '"> </div>'
@ -72,7 +72,7 @@ Deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
width: 0.2, width: 0.2,
sortable: true, sortable: true,
tpl: new Ext.XTemplate('{enabled:this.getCheckbox}', { tpl: new Ext.XTemplate('{enabled:this.getCheckbox}', {
getCheckbox: function(v) { getCheckbox: function (v) {
return ( return (
'<div class="x-grid3-check-col' + '<div class="x-grid3-check-col' +
(v ? '-on' : '') + (v ? '-on' : '') +
@ -141,23 +141,23 @@ Deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
deluge.events.on('PluginEnabledEvent', this.onPluginEnabled, this); deluge.events.on('PluginEnabledEvent', this.onPluginEnabled, this);
}, },
disablePlugin: function(plugin) { disablePlugin: function (plugin) {
deluge.client.core.disable_plugin(plugin); deluge.client.core.disable_plugin(plugin);
}, },
enablePlugin: function(plugin) { enablePlugin: function (plugin) {
deluge.client.core.enable_plugin(plugin); deluge.client.core.enable_plugin(plugin);
}, },
setInfo: function(plugin) { setInfo: function (plugin) {
if (!this.pluginInfo.rendered) return; if (!this.pluginInfo.rendered) return;
var values = plugin || this.defaultValues; var values = plugin || this.defaultValues;
this.pluginInfo.body.dom.innerHTML = this.pluginTemplate.apply(values); this.pluginInfo.body.dom.innerHTML = this.pluginTemplate.apply(values);
}, },
updatePlugins: function() { updatePlugins: function () {
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());
}); });
@ -167,7 +167,7 @@ Deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
}); });
}; };
var onGotEnabledPlugins = function(plugins) { var onGotEnabledPlugins = function (plugins) {
this.enabledPlugins = plugins; this.enabledPlugins = plugins;
this.onGotPlugins(); this.onGotPlugins();
}; };
@ -178,11 +178,11 @@ Deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
}); });
}, },
updatePluginsGrid: function() { updatePluginsGrid: function () {
var plugins = []; var plugins = [];
Ext.each( Ext.each(
this.availablePlugins, this.availablePlugins,
function(plugin) { function (plugin) {
if (this.enabledPlugins.indexOf(plugin) > -1) { if (this.enabledPlugins.indexOf(plugin) > -1) {
plugins.push([true, plugin]); plugins.push([true, plugin]);
} else { } else {
@ -194,7 +194,7 @@ Deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
this.list.getStore().loadData(plugins); this.list.getStore().loadData(plugins);
}, },
onNodeClick: function(dv, index, node, e) { onNodeClick: function (dv, index, node, e) {
var el = new Ext.Element(e.target); var el = new Ext.Element(e.target);
if (el.getAttribute('rel') != 'chkbox') return; if (el.getAttribute('rel') != 'chkbox') return;
@ -209,16 +209,16 @@ Deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
} }
}, },
onFindMorePlugins: function() { onFindMorePlugins: function () {
window.open('http://dev.deluge-torrent.org/wiki/Plugins'); window.open('http://dev.deluge-torrent.org/wiki/Plugins');
}, },
onGotPlugins: function() { onGotPlugins: function () {
this.setInfo(); this.setInfo();
this.updatePluginsGrid(); this.updatePluginsGrid();
}, },
onGotPluginInfo: function(info) { onGotPluginInfo: function (info) {
var values = { var values = {
author: info['Author'], author: info['Author'],
version: info['Version'], version: info['Version'],
@ -230,7 +230,7 @@ Deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
delete info; delete info;
}, },
onInstallPluginWindow: function() { onInstallPluginWindow: function () {
if (!this.installWindow) { if (!this.installWindow) {
this.installWindow = new Deluge.preferences.InstallPluginWindow(); this.installWindow = new Deluge.preferences.InstallPluginWindow();
this.installWindow.on('pluginadded', this.onPluginInstall, this); this.installWindow.on('pluginadded', this.onPluginInstall, this);
@ -238,7 +238,7 @@ Deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
this.installWindow.show(); this.installWindow.show();
}, },
onPluginEnabled: function(pluginName) { onPluginEnabled: function (pluginName) {
var index = this.list.getStore().find('plugin', pluginName); var index = this.list.getStore().find('plugin', pluginName);
if (index == -1) return; if (index == -1) return;
var plugin = this.list.getStore().getAt(index); var plugin = this.list.getStore().getAt(index);
@ -246,7 +246,7 @@ Deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
plugin.commit(); plugin.commit();
}, },
onPluginDisabled: function(pluginName) { onPluginDisabled: function (pluginName) {
var index = this.list.getStore().find('plugin', pluginName); var index = this.list.getStore().find('plugin', pluginName);
if (index == -1) return; if (index == -1) return;
var plugin = this.list.getStore().getAt(index); var plugin = this.list.getStore().getAt(index);
@ -254,11 +254,11 @@ Deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
plugin.commit(); plugin.commit();
}, },
onPluginInstall: function() { onPluginInstall: function () {
this.updatePlugins(); this.updatePlugins();
}, },
onPluginSelect: function(dv, selections) { onPluginSelect: function (dv, selections) {
if (selections.length == 0) return; if (selections.length == 0) return;
var r = dv.getRecords(selections)[0]; var r = dv.getRecords(selections)[0];
deluge.client.web.get_plugin_info(r.get('plugin'), { deluge.client.web.get_plugin_info(r.get('plugin'), {
@ -267,11 +267,11 @@ Deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
}); });
}, },
onPreferencesShow: function() { onPreferencesShow: function () {
this.updatePlugins(); this.updatePlugins();
}, },
onPluginInfoRender: function(ct, position) { onPluginInfoRender: function (ct, position) {
this.setInfo(); this.setInfo();
}, },
}); });

View File

@ -36,7 +36,7 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
pages: {}, pages: {},
initComponent: function() { initComponent: function () {
Deluge.preferences.PreferencesWindow.superclass.initComponent.call( Deluge.preferences.PreferencesWindow.superclass.initComponent.call(
this this
); );
@ -94,7 +94,7 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
this.initPages(); this.initPages();
}, },
initPages: function() { initPages: function () {
deluge.preferences = this; deluge.preferences = this;
this.addPage(new Deluge.preferences.Downloads()); this.addPage(new Deluge.preferences.Downloads());
this.addPage(new Deluge.preferences.Network()); this.addPage(new Deluge.preferences.Network());
@ -109,7 +109,7 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
this.addPage(new Deluge.preferences.Plugins()); this.addPage(new Deluge.preferences.Plugins());
}, },
onApply: function(e) { onApply: function (e) {
var changed = this.optionsManager.getDirty(); var changed = this.optionsManager.getDirty();
if (!Ext.isObjectEmpty(changed)) { if (!Ext.isObjectEmpty(changed)) {
// 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.
@ -134,7 +134,7 @@ 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
*/ */
getOptionsManager: function() { getOptionsManager: function () {
return this.optionsManager; return this.optionsManager;
}, },
@ -142,7 +142,7 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
* Adds a page to the preferences window. * Adds a page to the preferences window.
* @param {Mixed} page * @param {Mixed} page
*/ */
addPage: function(page) { addPage: function (page) {
var store = this.list.getStore(); var store = this.list.getStore();
var name = page.title; var name = page.title;
store.add([new PreferencesRecord({ name: name })]); store.add([new PreferencesRecord({ name: name })]);
@ -157,7 +157,7 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
* Removes a preferences page from the window. * Removes a preferences page from the window.
* @param {mixed} name * @param {mixed} name
*/ */
removePage: function(page) { removePage: function (page) {
var name = page.title; var name = page.title;
var store = this.list.getStore(); var store = this.list.getStore();
store.removeAt(store.find('name', name)); store.removeAt(store.find('name', name));
@ -169,7 +169,7 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
* Select which preferences page is displayed. * Select which preferences page is displayed.
* @param {String} page The page name to change to * @param {String} page The page name to change to
*/ */
selectPage: function(page) { selectPage: function (page) {
if (this.pages[page].index < 0) { if (this.pages[page].index < 0) {
this.pages[page].index = this.configPanel.items.indexOf( this.pages[page].index = this.configPanel.items.indexOf(
this.pages[page] this.pages[page]
@ -179,7 +179,7 @@ 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].index = this.configPanel.items.indexOf(
this.pages[page] this.pages[page]
@ -190,23 +190,23 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
}, },
// private // private
onGotConfig: function(config) { onGotConfig: function (config) {
this.getOptionsManager().set(config); this.getOptionsManager().set(config);
}, },
// private // private
onPageSelect: function(list, selections) { onPageSelect: function (list, selections) {
var r = list.getRecord(selections[0]); var r = list.getRecord(selections[0]);
this.doSelectPage(r.get('name')); this.doSelectPage(r.get('name'));
}, },
// private // private
onSetConfig: function() { onSetConfig: function () {
this.getOptionsManager().commit(); this.getOptionsManager().commit();
}, },
// private // private
onAfterRender: function() { onAfterRender: function () {
if (!this.list.getSelectionCount()) { if (!this.list.getSelectionCount()) {
this.list.select(0); this.list.select(0);
} }
@ -214,7 +214,7 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
}, },
// private // private
onShow: function() { onShow: function () {
if (!deluge.client.core) return; if (!deluge.client.core) return;
deluge.client.core.get_config({ deluge.client.core.get_config({
success: this.onGotConfig, success: this.onGotConfig,
@ -223,12 +223,12 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
}, },
// private // private
onClose: function() { onClose: function () {
this.hide(); this.hide();
}, },
// private // private
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, {

View File

@ -18,7 +18,7 @@ Deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, {
autoHeight: true, autoHeight: true,
labelWidth: 70, labelWidth: 70,
initComponent: function() { initComponent: function () {
Deluge.preferences.ProxyField.superclass.initComponent.call(this); Deluge.preferences.ProxyField.superclass.initComponent.call(this);
this.proxyType = this.add({ this.proxyType = this.add({
xtype: 'combo', xtype: 'combo',
@ -145,11 +145,11 @@ Deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, {
this.setting = false; this.setting = false;
}, },
getName: function() { getName: function () {
return this.initialConfig.name; return this.initialConfig.name;
}, },
getValue: function() { getValue: function () {
return { return {
type: this.proxyType.getValue(), type: this.proxyType.getValue(),
hostname: this.hostname.getValue(), hostname: this.hostname.getValue(),
@ -165,7 +165,7 @@ Deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, {
}, },
// Set the values of the proxies // Set the values of the proxies
setValue: function(value) { setValue: function (value) {
this.setting = true; this.setting = true;
this.proxyType.setValue(value['type']); this.proxyType.setValue(value['type']);
var index = this.proxyType.getStore().find('id', value['type']); var index = this.proxyType.getStore().find('id', value['type']);
@ -185,7 +185,7 @@ Deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, {
this.setting = false; this.setting = false;
}, },
onFieldChange: function(field, newValue, oldValue) { onFieldChange: function (field, newValue, oldValue) {
if (this.setting) return; if (this.setting) return;
var newValues = this.getValue(); var newValues = this.getValue();
var oldValues = Ext.apply({}, newValues); var oldValues = Ext.apply({}, newValues);
@ -194,7 +194,7 @@ Deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, {
this.fireEvent('change', this, newValues, oldValues); this.fireEvent('change', this, newValues, oldValues);
}, },
onTypeSelect: function(combo, record, index) { onTypeSelect: function (combo, record, index) {
var typeId = record.get('id'); var typeId = record.get('id');
if (typeId > 0) { if (typeId > 0) {
this.hostname.show(); this.hostname.show();

View File

@ -14,7 +14,7 @@ Ext.namespace('Deluge.preferences');
* @extends Ext.form.FormPanel * @extends Ext.form.FormPanel
*/ */
Deluge.preferences.Proxy = Ext.extend(Ext.form.FormPanel, { Deluge.preferences.Proxy = Ext.extend(Ext.form.FormPanel, {
constructor: function(config) { constructor: function (config) {
config = Ext.apply( config = Ext.apply(
{ {
border: false, border: false,
@ -28,7 +28,7 @@ Deluge.preferences.Proxy = Ext.extend(Ext.form.FormPanel, {
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( this.proxy = this.add(
new Deluge.preferences.ProxyField({ new Deluge.preferences.ProxyField({
@ -40,19 +40,19 @@ Deluge.preferences.Proxy = Ext.extend(Ext.form.FormPanel, {
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) {
for (var proxy in value) { for (var proxy in value) {
this[proxy].setValue(value[proxy]); this[proxy].setValue(value[proxy]);
} }
}, },
onProxyChange: function(field, newValue, oldValue) { onProxyChange: function (field, newValue, oldValue) {
var newValues = this.getValue(); var newValues = this.getValue();
var oldValues = Ext.apply({}, newValues); var oldValues = Ext.apply({}, newValues);
oldValues[field.getName()] = oldValue; oldValues[field.getName()] = oldValue;

View File

@ -19,7 +19,7 @@ Deluge.preferences.Queue = Ext.extend(Ext.form.FormPanel, {
header: false, header: false,
layout: 'form', layout: 'form',
initComponent: function() { initComponent: function () {
Deluge.preferences.Queue.superclass.initComponent.call(this); Deluge.preferences.Queue.superclass.initComponent.call(this);
var om = deluge.preferences.getOptionsManager(); var om = deluge.preferences.getOptionsManager();
@ -227,7 +227,7 @@ Deluge.preferences.Queue = Ext.extend(Ext.form.FormPanel, {
om.bind('remove_seed_at_ratio', this.removeAtRatio); om.bind('remove_seed_at_ratio', this.removeAtRatio);
}, },
onStopRatioCheck: function(e, checked) { onStopRatioCheck: function (e, checked) {
this.stopRatio.setDisabled(!checked); this.stopRatio.setDisabled(!checked);
this.removeAtRatio.setDisabled(!checked); this.removeAtRatio.setDisabled(!checked);
}, },

View File

@ -1,4 +1,4 @@
Ext.ux.JSLoader = function(options) { Ext.ux.JSLoader = function (options) {
Ext.ux.JSLoader.scripts[++Ext.ux.JSLoader.index] = { Ext.ux.JSLoader.scripts[++Ext.ux.JSLoader.index] = {
url: options.url, url: options.url,
success: true, success: true,
@ -12,7 +12,7 @@ Ext.ux.JSLoader = function(options) {
Ext.Ajax.request({ Ext.Ajax.request({
url: options.url, url: options.url,
scriptIndex: Ext.ux.JSLoader.index, scriptIndex: Ext.ux.JSLoader.index,
success: function(response, options) { success: function (response, options) {
var script = Ext.ux.JSLoader.scripts[options.scriptIndex]; var script = Ext.ux.JSLoader.scripts[options.scriptIndex];
try { try {
eval(response.responseText); eval(response.responseText);
@ -24,7 +24,7 @@ Ext.ux.JSLoader = function(options) {
script.onLoad.call(script.scope, script.options); script.onLoad.call(script.scope, script.options);
} }
}, },
failure: function(response, options) { failure: function (response, options) {
var script = Ext.ux.JSLoader.scripts[options.scriptIndex]; var script = Ext.ux.JSLoader.scripts[options.scriptIndex];
script.success = false; script.success = false;
script.onError(script.options, response.status); script.onError(script.options, response.status);
@ -33,7 +33,7 @@ Ext.ux.JSLoader = function(options) {
}; };
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( window.alert(
'Error loading script:\n\n' + options.url + '\n\nstatus: ' + e '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,7 +36,7 @@ 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;
@ -81,7 +81,7 @@ Ext.ux.Spinner = Ext.extend(Ext.util.Observable, {
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();
@ -89,14 +89,14 @@ 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);
@ -104,14 +104,14 @@ Ext.ux.Spinner = Ext.extend(Ext.util.Observable, {
} }
}, },
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;
@ -128,21 +128,21 @@ Ext.ux.Spinner = Ext.extend(Ext.util.Observable, {
}, },
// 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( Ext.get(Ext.isIE ? document.body : document).un(
'mousedown', 'mousedown',
@ -155,12 +155,12 @@ Ext.ux.Spinner = Ext.extend(Ext.util.Observable, {
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,
@ -168,22 +168,22 @@ Ext.ux.Spinner = Ext.extend(Ext.util.Observable, {
}); });
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();
}, },
@ -217,7 +217,7 @@ 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;
} }
@ -230,12 +230,12 @@ Ext.ux.Spinner = Ext.extend(Ext.util.Observable, {
}, },
//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;
} }
@ -250,7 +250,7 @@ Ext.ux.Spinner = Ext.extend(Ext.util.Observable, {
}, },
//private //private
onMouseDown: function() { onMouseDown: function () {
if (this.disabled) { if (this.disabled) {
return; return;
} }
@ -263,12 +263,12 @@ Ext.ux.Spinner = Ext.extend(Ext.util.Observable, {
}, },
//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;
} }
@ -278,7 +278,7 @@ Ext.ux.Spinner = Ext.extend(Ext.util.Observable, {
}, },
//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;
@ -287,7 +287,7 @@ Ext.ux.Spinner = Ext.extend(Ext.util.Observable, {
//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;
@ -295,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;
@ -312,18 +312,18 @@ Ext.ux.Spinner = Ext.extend(Ext.util.Observable, {
}, },
//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;
} }
@ -344,7 +344,7 @@ Ext.ux.Spinner = Ext.extend(Ext.util.Observable, {
}, },
//private //private
onSpinUp: function() { onSpinUp: function () {
if (this.isSpinnable() == false) { if (this.isSpinnable() == false) {
return; return;
} }
@ -359,7 +359,7 @@ Ext.ux.Spinner = Ext.extend(Ext.util.Observable, {
}, },
//private //private
onSpinDown: function() { onSpinDown: function () {
if (this.isSpinnable() == false) { if (this.isSpinnable() == false) {
return; return;
} }
@ -374,7 +374,7 @@ Ext.ux.Spinner = Ext.extend(Ext.util.Observable, {
}, },
//private //private
onSpinUpAlternate: function() { onSpinUpAlternate: function () {
if (this.isSpinnable() == false) { if (this.isSpinnable() == false) {
return; return;
} }
@ -384,7 +384,7 @@ Ext.ux.Spinner = Ext.extend(Ext.util.Observable, {
}, },
//private //private
onSpinDownAlternate: function() { onSpinDownAlternate: function () {
if (this.isSpinnable() == false) { if (this.isSpinnable() == false) {
return; return;
} }
@ -393,7 +393,7 @@ Ext.ux.Spinner = Ext.extend(Ext.util.Observable, {
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 = var incr =
alternate == true alternate == true
@ -406,7 +406,7 @@ Ext.ux.Spinner = Ext.extend(Ext.util.Observable, {
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) {
@ -420,7 +420,7 @@ 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 ( if (
!this.field.allowDecimals || !this.field.allowDecimals ||
@ -435,7 +435,7 @@ Ext.ux.Spinner = Ext.extend(Ext.util.Observable, {
); );
}, },
doDestroy: function() { doDestroy: function () {
if (this.trigger) { if (this.trigger) {
this.trigger.remove(); this.trigger.remove();
} }

View File

@ -183,7 +183,7 @@ sb.setStatus({
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';
} }
@ -191,7 +191,7 @@ sb.setStatus({
}, },
// 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';
@ -260,7 +260,7 @@ 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') {
@ -307,7 +307,7 @@ 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) {
@ -330,7 +330,7 @@ statusBar.setStatus({
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,
@ -356,7 +356,7 @@ 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) {
@ -369,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;
}, },
@ -379,7 +379,7 @@ 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 || '';
@ -408,7 +408,7 @@ 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 };
} }

View File

@ -50,7 +50,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(
@ -66,7 +66,7 @@ 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( Ext.ux.form.FileUploadField.superclass.onRender.call(
this, this,
ct, ct,
@ -97,30 +97,30 @@ Ext.ux.form.FileUploadField = Ext.extend(Ext.form.TextField, {
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([ this.button.removeClass([
'x-btn-over', 'x-btn-over',
'x-btn-focus', 'x-btn-focus',
'x-btn-click', '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([ this.button.removeClass([
'x-btn-over', 'x-btn-over',
'x-btn-focus', 'x-btn-focus',
'x-btn-click', 'x-btn-click',
]); ]);
}, },
change: function() { change: function () {
var value = this.fileInput.dom.files; var value = this.fileInput.dom.files;
// Fallback to value. // Fallback to value.
if (!value) value = this.fileInput.dom.value; if (!value) value = this.fileInput.dom.value;
@ -130,7 +130,7 @@ Ext.ux.form.FileUploadField = Ext.extend(Ext.form.TextField, {
}); });
}, },
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(),
@ -142,7 +142,7 @@ Ext.ux.form.FileUploadField = Ext.extend(Ext.form.TextField, {
this.fileInput.dom.multiple = this.multiple; this.fileInput.dom.multiple = this.multiple;
}, },
reset: function() { reset: function () {
if (this.rendered) { if (this.rendered) {
this.fileInput.remove(); this.fileInput.remove();
this.createFileInput(); this.createFileInput();
@ -152,12 +152,12 @@ 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);
@ -172,23 +172,23 @@ Ext.ux.form.FileUploadField = Ext.extend(Ext.form.TextField, {
}, },
// 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);
}, },
@ -197,7 +197,7 @@ Ext.ux.form.FileUploadField = Ext.extend(Ext.form.TextField, {
preFocus: Ext.emptyFn, preFocus: Ext.emptyFn,
// private // private
alignErrorIcon: function() { alignErrorIcon: function () {
this.errorIcon.alignTo(this.wrap, 'tl-tr', [2, 0]); this.errorIcon.alignTo(this.wrap, 'tl-tr', [2, 0]);
}, },
}); });

View File

@ -10,8 +10,8 @@
// 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']);
}, this); }, this);
if (this.lazyValue) { if (this.lazyValue) {
@ -22,21 +22,21 @@ Ext.override(Ext.form.RadioGroup, {
Ext.form.RadioGroup.superclass.afterRender.call(this); Ext.form.RadioGroup.superclass.afterRender.call(this);
}, },
getName: function() { getName: function () {
return this.items.first().getName(); return this.items.first().getName();
}, },
getValue: function() { getValue: function () {
return this.items.first().getGroupValue(); return this.items.first().getGroupValue();
}, },
setValue: function(v) { setValue: function (v) {
if (!this.items.each) { if (!this.items.each) {
this.value = v; this.value = v;
this.lazyValue = true; this.lazyValue = true;
return; return;
} }
this.items.each(function(item) { this.items.each(function (item) {
if (item.rendered) { if (item.rendered) {
var checked = item.el.getValue() == String(v); var checked = item.el.getValue() == String(v);
item.el.dom.checked = checked; item.el.dom.checked = checked;

View File

@ -19,7 +19,7 @@ Ext.ux.form.SpinnerField = Ext.extend(Ext.form.NumberField, {
onBlur: Ext.emptyFn, onBlur: Ext.emptyFn,
adjustSize: Ext.BoxComponent.prototype.adjustSize, adjustSize: Ext.BoxComponent.prototype.adjustSize,
constructor: function(config) { constructor: function (config) {
var spinnerConfig = Ext.copyTo( var spinnerConfig = Ext.copyTo(
{}, {},
config, config,
@ -41,23 +41,23 @@ Ext.ux.form.SpinnerField = Ext.extend(Ext.form.NumberField, {
}, },
// 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;
}, },
}); });

View File

@ -23,7 +23,7 @@ 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,
@ -131,14 +131,14 @@ Ext.ux.form.SpinnerGroup = Ext.extend(Ext.form.CheckboxGroup, {
} }
} }
var fields = this.panel.findBy(function(c) { var fields = this.panel.findBy(function (c) {
return c.isFormField; return c.isFormField;
}, this); }, this);
this.items = new Ext.util.MixedCollection(); this.items = new Ext.util.MixedCollection();
this.items.addAll(fields); this.items.addAll(fields);
this.items.each(function(field) { this.items.each(function (field) {
field.on('spin', this.onFieldChange, this); field.on('spin', this.onFieldChange, this);
field.on('change', this.onFieldChange, this); field.on('change', this.onFieldChange, this);
}, this); }, this);
@ -159,45 +159,45 @@ Ext.ux.form.SpinnerGroup = Ext.extend(Ext.form.CheckboxGroup, {
Ext.ux.form.SpinnerGroup.superclass.onRender.call(this, ct, position); Ext.ux.form.SpinnerGroup.superclass.onRender.call(this, ct, position);
}, },
onFieldChange: function(spinner) { onFieldChange: function (spinner) {
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()];
this.items.each(function(item, i) { this.items.each(function (item, i) {
value[i] = Number(item.getValue()); value[i] = Number(item.getValue());
}); });
return value; return value;
}, },
getRawValue: function() { getRawValue: function () {
var value = [this.items.getCount()]; var value = [this.items.getCount()];
this.items.each(function(item, i) { this.items.each(function (item, i) {
value[i] = Number(item.getRawValue()); value[i] = Number(item.getRawValue());
}); });
return value; return value;
}, },
setValue: function(value) { setValue: function (value) {
if (!this.rendered) { if (!this.rendered) {
this.value = value; this.value = value;
this.lazyValueSet = true; this.lazyValueSet = true;
} else { } else {
this.items.each(function(item, i) { this.items.each(function (item, i) {
item.setValue(value[i]); item.setValue(value[i]);
}); });
} }
}, },
setRawValue: function(value) { setRawValue: function (value) {
if (!this.rendered) { if (!this.rendered) {
this.rawValue = value; this.rawValue = value;
this.lazyRawValueSet = true; this.lazyRawValueSet = true;
} else { } else {
this.items.each(function(item, i) { this.items.each(function (item, i) {
item.setRawValue(value[i]); item.setRawValue(value[i]);
}); });
} }

View File

@ -21,7 +21,7 @@ Ext.namespace('Ext.ux.form');
Ext.ux.form.ToggleField = Ext.extend(Ext.form.Field, { Ext.ux.form.ToggleField = Ext.extend(Ext.form.Field, {
cls: 'x-toggle-field', cls: 'x-toggle-field',
initComponent: function() { initComponent: function () {
Ext.ux.form.ToggleField.superclass.initComponent.call(this); Ext.ux.form.ToggleField.superclass.initComponent.call(this);
this.toggle = new Ext.form.Checkbox(); this.toggle = new Ext.form.Checkbox();
@ -32,7 +32,7 @@ Ext.ux.form.ToggleField = Ext.extend(Ext.form.Field, {
}); });
}, },
onRender: function(ct, position) { onRender: function (ct, position) {
if (!this.el) { if (!this.el) {
this.panel = new Ext.Panel({ this.panel = new Ext.Panel({
cls: this.groupCls, cls: this.groupCls,
@ -50,16 +50,13 @@ 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 this.toggle.getEl().parent().setStyle('padding-right', '10px');
.getEl()
.parent()
.setStyle('padding-right', '10px');
} }
Ext.ux.form.ToggleField.superclass.onRender.call(this, ct, position); Ext.ux.form.ToggleField.superclass.onRender.call(this, ct, position);
}, },
// private // private
onResize: function(w, h) { onResize: function (w, h) {
this.panel.setSize(w, h); this.panel.setSize(w, h);
this.panel.doLayout(); this.panel.doLayout();
@ -68,7 +65,7 @@ Ext.ux.form.ToggleField = Ext.extend(Ext.form.Field, {
this.input.setSize(inputWidth, h); this.input.setSize(inputWidth, h);
}, },
onToggleCheck: function(toggle, checked) { onToggleCheck: function (toggle, checked) {
this.input.setDisabled(!checked); this.input.setDisabled(!checked);
}, },
}); });

Some files were not shown because too many files have changed in this diff Show More