From 5e78daf7260096ebf13b9752ac5efdf4af3409ce Mon Sep 17 00:00:00 2001 From: Damien Churchill Date: Fri, 30 Apr 2010 22:06:32 +0100 Subject: [PATCH] fix the spinners on the various preference pages --- .../deluge-all/preferences/BandwidthPage.js | 108 ++++++----------- .../js/deluge-all/preferences/CachePage.js | 41 +++---- .../js/deluge-all/preferences/DaemonPage.js | 29 ++--- .../deluge-all/preferences/InterfacePage.js | 48 +++----- .../js/deluge-all/preferences/ProxyField.js | 20 +--- .../js/deluge-all/preferences/QueuePage.js | 109 +++++++----------- 6 files changed, 128 insertions(+), 227 deletions(-) diff --git a/deluge/ui/web/js/deluge-all/preferences/BandwidthPage.js b/deluge/ui/web/js/deluge-all/preferences/BandwidthPage.js index 9e3f823fd..5b5c1b0f9 100644 --- a/deluge/ui/web/js/deluge-all/preferences/BandwidthPage.js +++ b/deluge/ui/web/js/deluge-all/preferences/BandwidthPage.js @@ -49,87 +49,61 @@ Deluge.preferences.Bandwidth = Ext.extend(Ext.form.FormPanel, { initComponent: function() { Deluge.preferences.Bandwidth.superclass.initComponent.call(this); - var optMan = deluge.preferences.getOptionsManager(); + var om = deluge.preferences.getOptionsManager(); var fieldset = this.add({ xtype: 'fieldset', border: false, title: _('Global Bandwidth Usage'), labelWidth: 200, defaultType: 'spinnerfield', + defaults: { + minValue: -1, + maxValue: 99999 + }, style: 'margin-bottom: 0px; padding-bottom: 0px;', autoHeight: true }); - optMan.bind('max_connections_global', fieldset.add({ + om.bind('max_connections_global', fieldset.add({ name: 'max_connections_global', fieldLabel: _('Maximum Connections'), width: 80, value: -1, - strategy: { - xtype: 'number', - decimalPrecision: 0, - minValue: -1, - maxValue: 99999 - } + decimalPrecision: 0 })); - optMan.bind('max_upload_slots_global', fieldset.add({ + om.bind('max_upload_slots_global', fieldset.add({ name: 'max_upload_slots_global', fieldLabel: _('Maximum Upload Slots'), width: 80, value: -1, - strategy: { - xtype: 'number', - decimalPrecision: 0, - minValue: -1, - maxValue: 99999 - } + decimalPrecision: 0 })); - optMan.bind('max_download_speed', fieldset.add({ + om.bind('max_download_speed', fieldset.add({ name: 'max_download_speed', fieldLabel: _('Maximum Download Speed (KiB/s)'), width: 80, - value: -1, - strategy: { - xtype: 'number', - decimalPrecision: 1, - minValue: -1, - maxValue: 99999 - } + value: -1.0, + decimalPrecision: 1 })); - optMan.bind('max_upload_speed', fieldset.add({ + om.bind('max_upload_speed', fieldset.add({ name: 'max_upload_speed', fieldLabel: _('Maximum Upload Speed (KiB/s)'), width: 80, - value: -1, - strategy: { - xtype: 'number', - decimalPrecision: 1, - minValue: -1, - maxValue: 99999 - } + value: -1.0, + decimalPrecision: 1 })); - optMan.bind('max_half_open_connections', fieldset.add({ + om.bind('max_half_open_connections', fieldset.add({ name: 'max_half_open_connections', fieldLabel: _('Maximum Half-Open Connections'), width: 80, value: -1, - strategy: { - xtype: 'number', - decimalPrecision: 0, - minValue: -1, - maxValue: 99999 - } + decimalPrecision: 0 })); - optMan.bind('max_connections_per_second', fieldset.add({ + om.bind('max_connections_per_second', fieldset.add({ name: 'max_connections_per_second', fieldLabel: _('Maximum Connection Attempts per Second'), width: 80, value: -1, - strategy: { - xtype: 'number', - decimalPrecision: 0, - minValue: -1, - maxValue: 99999 - } + decimalPrecision: 0 })); fieldset = this.add({ @@ -140,14 +114,14 @@ Deluge.preferences.Bandwidth = Ext.extend(Ext.form.FormPanel, { style: 'padding-top: 0px; padding-bottom: 5px; margin-top: 0px; margin-bottom: 0px;', autoHeight: true }); - optMan.bind('ignore_limits_on_local_network', fieldset.add({ + om.bind('ignore_limits_on_local_network', fieldset.add({ name: 'ignore_limits_on_local_network', height: 22, fieldLabel: '', labelSeparator: '', boxLabel: _('Ignore limits on local network') })); - optMan.bind('rate_limit_ip_overhead', fieldset.add({ + om.bind('rate_limit_ip_overhead', fieldset.add({ name: 'rate_limit_ip_overhead', height: 22, fieldLabel: '', @@ -162,55 +136,39 @@ Deluge.preferences.Bandwidth = Ext.extend(Ext.form.FormPanel, { style: 'margin-bottom: 0px; padding-bottom: 0px;', defaultType: 'spinnerfield', labelWidth: 200, + defaults: { + minValue: -1, + maxValue: 99999 + }, autoHeight: true }); - optMan.bind('max_connections_per_torrent', fieldset.add({ + om.bind('max_connections_per_torrent', fieldset.add({ name: 'max_connections_per_torrent', fieldLabel: _('Maximum Connections'), width: 80, value: -1, - strategy: { - xtype: 'number', - decimalPrecision: 0, - minValue: -1, - maxValue: 99999 - } + decimalPrecision: 0 })); - optMan.bind('max_upload_slots_per_torrent', fieldset.add({ + om.bind('max_upload_slots_per_torrent', fieldset.add({ name: 'max_upload_slots_per_torrent', fieldLabel: _('Maximum Upload Slots'), width: 80, value: -1, - strategy: { - xtype: 'number', - decimalPrecision: 0, - minValue: -1, - maxValue: 99999 - } + decimalPrecision: 0 })); - optMan.bind('max_download_speed_per_torrent', fieldset.add({ + om.bind('max_download_speed_per_torrent', fieldset.add({ name: 'max_download_speed_per_torrent', fieldLabel: _('Maximum Download Speed (KiB/s)'), width: 80, value: -1, - strategy: { - xtype: 'number', - decimalPrecision: 1, - minValue: -1, - maxValue: 99999 - } + decimalPrecision: 0 })); - optMan.bind('max_upload_speed_per_torrent', fieldset.add({ + om.bind('max_upload_speed_per_torrent', fieldset.add({ name: 'max_upload_speed_per_torrent', fieldLabel: _('Maximum Upload Speed (KiB/s)'), width: 80, value: -1, - strategy: { - xtype: 'number', - decimalPrecision: 1, - minValue: -1, - maxValue: 99999 - } + decimalPrecision: 0 })); } }); diff --git a/deluge/ui/web/js/deluge-all/preferences/CachePage.js b/deluge/ui/web/js/deluge-all/preferences/CachePage.js index 16b3be30b..c673ed7ff 100644 --- a/deluge/ui/web/js/deluge-all/preferences/CachePage.js +++ b/deluge/ui/web/js/deluge-all/preferences/CachePage.js @@ -36,19 +36,15 @@ Ext.namespace('Deluge.preferences'); * @extends Ext.form.FormPanel */ Deluge.preferences.Cache = Ext.extend(Ext.form.FormPanel, { - constructor: function(config) { - config = Ext.apply({ - border: false, - title: _('Cache'), - layout: 'form' - }, config); - Deluge.preferences.Cache.superclass.constructor.call(this, config); - }, + + border: false, + title: _('Cache'), + layout: 'form', initComponent: function() { Deluge.preferences.Cache.superclass.initComponent.call(this); - var optMan = deluge.preferences.getOptionsManager(); + var om = deluge.preferences.getOptionsManager(); var fieldset = this.add({ xtype: 'fieldset', @@ -56,31 +52,24 @@ Deluge.preferences.Cache = Ext.extend(Ext.form.FormPanel, { title: _('Settings'), autoHeight: true, labelWidth: 180, - defaultType: 'spinnerfield' + defaultType: 'spinnerfield', + defaults: { + decimalPrecision: 0, + minValue: -1, + maxValue: 99999 + } }); - optMan.bind('cache_size', fieldset.add({ + om.bind('cache_size', fieldset.add({ fieldLabel: _('Cache Size (16 KiB Blocks)'), name: 'cache_size', width: 60, - value: 512, - strategy: { - xtype: 'number', - decimalPrecision: 0, - minValue: -1, - maxValue: 99999 - } + value: 512 })); - optMan.bind('cache_expiry', fieldset.add({ + om.bind('cache_expiry', fieldset.add({ fieldLabel: _('Cache Expiry (seconds)'), name: 'cache_expiry', width: 60, - value: 60, - strategy: { - xtype: 'number', - decimalPrecision: 0, - minValue: -1, - maxValue: 99999 - } + value: 60 })); } }); diff --git a/deluge/ui/web/js/deluge-all/preferences/DaemonPage.js b/deluge/ui/web/js/deluge-all/preferences/DaemonPage.js index 4e22c1a63..621c28a0f 100644 --- a/deluge/ui/web/js/deluge-all/preferences/DaemonPage.js +++ b/deluge/ui/web/js/deluge-all/preferences/DaemonPage.js @@ -36,19 +36,15 @@ Ext.namespace('Deluge.preferences'); * @extends Ext.form.FormPanel */ Deluge.preferences.Daemon = Ext.extend(Ext.form.FormPanel, { - constructor: function(config) { - config = Ext.apply({ - border: false, - title: _('Daemon'), - layout: 'form' - }, config); - Deluge.preferences.Daemon.superclass.constructor.call(this, config); - }, + + border: false, + title: _('Daemon'), + layout: 'form', initComponent: function() { Deluge.preferences.Daemon.superclass.initComponent.call(this); - var optMan = deluge.preferences.getOptionsManager(); + var om = deluge.preferences.getOptionsManager(); var fieldset = this.add({ xtype: 'fieldset', @@ -57,16 +53,13 @@ Deluge.preferences.Daemon = Ext.extend(Ext.form.FormPanel, { autoHeight: true, defaultType: 'spinnerfield' }); - optMan.bind('daemon_port', fieldset.add({ + om.bind('daemon_port', fieldset.add({ fieldLabel: _('Daemon port'), name: 'daemon_port', value: 58846, - strategy: { - xtype: 'number', - decimalPrecision: 0, - minValue: -1, - maxValue: 99999 - } + decimalPrecision: 0, + minValue: -1, + maxValue: 99999 })); fieldset = this.add({ @@ -77,7 +70,7 @@ Deluge.preferences.Daemon = Ext.extend(Ext.form.FormPanel, { labelWidth: 1, defaultType: 'checkbox' }); - optMan.bind('allow_remote', fieldset.add({ + om.bind('allow_remote', fieldset.add({ fieldLabel: '', height: 22, labelSeparator: '', @@ -93,7 +86,7 @@ Deluge.preferences.Daemon = Ext.extend(Ext.form.FormPanel, { labelWidth: 1, defaultType: 'checkbox' }); - optMan.bind('new_release_check', fieldset.add({ + om.bind('new_release_check', fieldset.add({ fieldLabel: '', labelSeparator: '', height: 40, diff --git a/deluge/ui/web/js/deluge-all/preferences/InterfacePage.js b/deluge/ui/web/js/deluge-all/preferences/InterfacePage.js index 5b8a5120c..bc8e87898 100644 --- a/deluge/ui/web/js/deluge-all/preferences/InterfacePage.js +++ b/deluge/ui/web/js/deluge-all/preferences/InterfacePage.js @@ -36,19 +36,15 @@ Ext.namespace('Deluge.preferences'); * @extends Ext.form.FormPanel */ Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, { - constructor: function(config) { - config = Ext.apply({ - border: false, - title: _('Interface'), - layout: 'form' - }, config); - Deluge.preferences.Interface.superclass.constructor.call(this, config); - }, + + border: false, + title: _('Interface'), + layout: 'form', initComponent: function() { Deluge.preferences.Interface.superclass.initComponent.call(this); - var optMan = this.optionsManager = new Deluge.OptionsManager(); + var om = this.optionsManager = new Deluge.OptionsManager(); this.on('show', this.onPageShow, this); var fieldset = this.add({ @@ -60,21 +56,21 @@ Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, { labelWidth: 1, defaultType: 'checkbox' }); - optMan.bind('show_session_speed', fieldset.add({ + om.bind('show_session_speed', fieldset.add({ name: 'show_session_speed', height: 22, fieldLabel: '', labelSeparator: '', boxLabel: _('Show session speed in titlebar') })); - optMan.bind('sidebar_show_zero', fieldset.add({ + om.bind('sidebar_show_zero', fieldset.add({ name: 'sidebar_show_zero', height: 22, fieldLabel: '', labelSeparator: '', boxLabel: _('Show filters with zero torrents') })); - optMan.bind('sidebar_multiple_filters', fieldset.add({ + om.bind('sidebar_multiple_filters', fieldset.add({ name: 'sidebar_multiple_filters', height: 22, fieldLabel: '', @@ -139,27 +135,21 @@ Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, { width: 80 } }); - optMan.bind('session_timeout', fieldset.add({ + om.bind('session_timeout', fieldset.add({ name: 'session_timeout', fieldLabel: _('Session Timeout'), - strategy: { - xtype: 'number', - decimalPrecision: 0, - minValue: -1, - maxValue: 99999 - } + decimalPrecision: 0, + minValue: -1, + maxValue: 99999 })); - optMan.bind('port', fieldset.add({ + om.bind('port', fieldset.add({ name: 'port', fieldLabel: _('Port'), - strategy: { - xtype: 'number', - decimalPrecision: 0, - minValue: -1, - maxValue: 99999 - } + decimalPrecision: 0, + minValue: -1, + maxValue: 99999 })); - this.httpsField = optMan.bind('https', fieldset.add({ + this.httpsField = om.bind('https', fieldset.add({ xtype: 'checkbox', name: 'https', hideLabel: true, @@ -168,14 +158,14 @@ Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, { boxLabel: _('Use SSL (paths relative to Deluge config folder)') })); this.httpsField.on('check', this.onSSLCheck, this); - this.pkeyField = optMan.bind('pkey', fieldset.add({ + this.pkeyField = om.bind('pkey', fieldset.add({ xtype: 'textfield', disabled: true, name: 'pkey', width: 180, fieldLabel: _('Private Key') })); - this.certField = optMan.bind('cert', fieldset.add({ + this.certField = om.bind('cert', fieldset.add({ xtype: 'textfield', disabled: true, name: 'cert', diff --git a/deluge/ui/web/js/deluge-all/preferences/ProxyField.js b/deluge/ui/web/js/deluge-all/preferences/ProxyField.js index 1c0d1ce70..228ae10d7 100644 --- a/deluge/ui/web/js/deluge-all/preferences/ProxyField.js +++ b/deluge/ui/web/js/deluge-all/preferences/ProxyField.js @@ -37,14 +37,9 @@ Ext.ns('Deluge.preferences'); */ Deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, { - constructor: function(config) { - config = Ext.apply({ - border: false, - autoHeight: true, - labelWidth: 70 - }, config); - Deluge.preferences.ProxyField.superclass.constructor.call(this, config); - }, + border: false, + autoHeight: true, + labelWidth: 70, initComponent: function() { Deluge.preferences.ProxyField.superclass.initComponent.call(this); @@ -82,12 +77,9 @@ Deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, { name: 'port', fieldLabel: _('Port'), width: 80, - strategy: { - xtype: 'number', - decimalPrecision: 0, - minValue: -1, - maxValue: 99999 - } + decimalPrecision: 0, + minValue: -1, + maxValue: 99999 }); this.username = this.add({ diff --git a/deluge/ui/web/js/deluge-all/preferences/QueuePage.js b/deluge/ui/web/js/deluge-all/preferences/QueuePage.js index b7b89ba2a..15ca0eb60 100644 --- a/deluge/ui/web/js/deluge-all/preferences/QueuePage.js +++ b/deluge/ui/web/js/deluge-all/preferences/QueuePage.js @@ -36,19 +36,15 @@ Ext.namespace('Deluge.preferences'); * @extends Ext.form.FormPanel */ Deluge.preferences.Queue = Ext.extend(Ext.form.FormPanel, { - constructor: function(config) { - config = Ext.apply({ - border: false, - title: _('Queue'), - layout: 'form' - }, config); - Deluge.preferences.Queue.superclass.constructor.call(this, config); - }, + + border: false, + title: _('Queue'), + layout: 'form', initComponent: function() { Deluge.preferences.Queue.superclass.initComponent.call(this); - var optMan = deluge.preferences.getOptionsManager(); + var om = deluge.preferences.getOptionsManager(); var fieldset = this.add({ xtype: 'fieldset', @@ -59,7 +55,7 @@ Deluge.preferences.Queue = Ext.extend(Ext.form.FormPanel, { labelWidth: 1, defaultType: 'checkbox' }); - optMan.bind('queue_new_to_top', fieldset.add({ + om.bind('queue_new_to_top', fieldset.add({ fieldLabel: '', labelSeparator: '', height: 22, @@ -76,43 +72,34 @@ Deluge.preferences.Queue = Ext.extend(Ext.form.FormPanel, { defaultType: 'spinnerfield', style: 'margin-bottom: 0px; padding-bottom: 0px;' }); - optMan.bind('max_active_limit', fieldset.add({ + om.bind('max_active_limit', fieldset.add({ fieldLabel: _('Total Active'), name: 'max_active_limit', value: 8, width: 80, - strategy: { - xtype: 'number', - decimalPrecision: 0, - minValue: -1, - maxValue: 99999 - } + decimalPrecision: 0, + minValue: -1, + maxValue: 99999 })); - optMan.bind('max_active_downloading', fieldset.add({ + om.bind('max_active_downloading', fieldset.add({ fieldLabel: _('Total Active Downloading'), name: 'max_active_downloading', value: 3, width: 80, - strategy: { - xtype: 'number', - decimalPrecision: 0, - minValue: -1, - maxValue: 99999 - } + decimalPrecision: 0, + minValue: -1, + maxValue: 99999 })); - optMan.bind('max_active_seeding', fieldset.add({ + om.bind('max_active_seeding', fieldset.add({ fieldLabel: _('Total Active Seeding'), name: 'max_active_seeding', value: 5, width: 80, - strategy: { - xtype: 'number', - decimalPrecision: 0, - minValue: -1, - maxValue: 99999 - } + decimalPrecision: 0, + minValue: -1, + maxValue: 99999 })); - optMan.bind('dont_count_slow_torrents', fieldset.add({ + om.bind('dont_count_slow_torrents', fieldset.add({ xtype: 'checkbox', name: 'dont_count_slow_torrents', height: 40, @@ -129,41 +116,36 @@ Deluge.preferences.Queue = Ext.extend(Ext.form.FormPanel, { defaultType: 'spinnerfield', style: 'margin-bottom: 0px; padding-bottom: 0px; margin-top: 0; padding-top: 0;' }); - optMan.bind('share_ratio_limit', fieldset.add({ + om.bind('share_ratio_limit', fieldset.add({ fieldLabel: _('Share Ratio Limit'), name: 'share_ratio_limit', value: 8, width: 80, - strategy: { - xtype: 'number', - decimalPrecision: 0, - minValue: -1, - maxValue: 99999 - } + incrementValue: 0.1, + minValue: -1, + maxValue: 99999, + alternateIncrementValue: 1, + decimalPrecision: 2 })); - optMan.bind('seed_time_ratio_limit', fieldset.add({ + om.bind('seed_time_ratio_limit', fieldset.add({ fieldLabel: _('Share Time Ratio'), name: 'seed_time_ratio_limit', value: 3, width: 80, - strategy: { - xtype: 'number', - decimalPrecision: 0, - minValue: -1, - maxValue: 99999 - } + incrementValue: 0.1, + minValue: -1, + maxValue: 99999, + alternateIncrementValue: 1, + decimalPrecision: 2 })); - optMan.bind('seed_time_limit', fieldset.add({ + om.bind('seed_time_limit', fieldset.add({ fieldLabel: _('Seed Time (m)'), name: 'seed_time_limit', value: 5, width: 80, - strategy: { - xtype: 'number', - decimalPrecision: 0, - minValue: -1, - maxValue: 99999 - } + decimalPrecision: 0, + minValue: -1, + maxValue: 99999 })); fieldset = this.add({ @@ -186,25 +168,22 @@ Deluge.preferences.Queue = Ext.extend(Ext.form.FormPanel, { boxLabel: _('Stop seeding when share ratio reaches:') }); this.stopAtRatio.on('check', this.onStopRatioCheck, this); - optMan.bind('stop_seed_at_ratio', this.stopAtRatio); + om.bind('stop_seed_at_ratio', this.stopAtRatio); this.stopRatio = fieldset.add({ xtype: 'spinnerfield', name: 'stop_seed_ratio', ctCls: 'x-deluge-indent-checkbox', disabled: true, - value: 2.0, + value: '2.0', width: 60, - strategy: { - xtype: 'number', - minValue: -1, - maxValue: 99999, - incrementValue: 0.1, - alternateIncrementValue: 1, - decimalPrecision: 1 - } + incrementValue: 0.1, + minValue: -1, + maxValue: 99999, + alternateIncrementValue: 1, + decimalPrecision: 2 }); - optMan.bind('stop_seed_ratio', this.stopRatio); + om.bind('stop_seed_ratio', this.stopRatio); this.removeAtRatio = fieldset.add({ name: 'remove_seed_at_ratio', @@ -213,7 +192,7 @@ Deluge.preferences.Queue = Ext.extend(Ext.form.FormPanel, { disabled: true, colspan: 2 }); - optMan.bind('remove_seed_at_ratio', this.removeAtRatio); + om.bind('remove_seed_at_ratio', this.removeAtRatio); }, onStopRatioCheck: function(e, checked) {