From 81427006dd14125184caa38957b777befe43f1ab Mon Sep 17 00:00:00 2001 From: Martijn Voncken Date: Tue, 11 Nov 2008 19:35:03 +0000 Subject: [PATCH] label plugin:InputSensitivity --- .../label/label/data/apply_sensitivity.js | 20 ------ .../label/label/template/config_page.html | 22 +++++++ .../plugins/label/label/template/options.html | 12 +++- .../label/label/template/options_page.html | 10 +++ deluge/ui/webui/static/deluge-moo.js | 62 +++++++++++++++++++ .../webui/templates/white/basic_header.html | 1 + 6 files changed, 105 insertions(+), 22 deletions(-) delete mode 100644 deluge/plugins/label/label/data/apply_sensitivity.js create mode 100644 deluge/plugins/label/label/template/config_page.html create mode 100644 deluge/plugins/label/label/template/options_page.html create mode 100644 deluge/ui/webui/static/deluge-moo.js diff --git a/deluge/plugins/label/label/data/apply_sensitivity.js b/deluge/plugins/label/label/data/apply_sensitivity.js deleted file mode 100644 index 9026d50f3..000000000 --- a/deluge/plugins/label/label/data/apply_sensitivity.js +++ /dev/null @@ -1,20 +0,0 @@ -/* -see : gtkui/sidebar_menu.py: - def apply_sensitivity(self, event=None): - for chk_id , sensitive_list in self.sensitive_groups: - chk = self.glade.get_widget(chk_id) - sens = chk.get_active() and chk.get_property("sensitive") - for widget_id in sensitive_list: - self.glade.get_widget(widget_id).set_sensitive(sens) -*/ - -var sensitive_groups = [ - ["apply_max", ["max_download_speed", "max_upload_speed", "max_upload_slots", "max_connections"]], - ["apply_queue", ["is_auto_managed", "stop_at_ratio"]], - ["stop_at_ratio", ["remove_at_ratio", "stop_ratio"]], /*#nested*/ - ["apply_move_completed", ["move_completed"]], - ["move_completed", ["move_completed_path"]], /*#nested*/ - ["auto_add", ["auto_add_trackers"]] -]; - - diff --git a/deluge/plugins/label/label/template/config_page.html b/deluge/plugins/label/label/template/config_page.html new file mode 100644 index 000000000..382d5e3b1 --- /dev/null +++ b/deluge/plugins/label/label/template/config_page.html @@ -0,0 +1,22 @@ +$def with (labels) +$:render.basic_header(_("Label Config")) +

$_("Label Config")

+ +$for label in labels: + + + + + +
$label
+ +

Options

+ +$:render.footer() \ No newline at end of file diff --git a/deluge/plugins/label/label/template/options.html b/deluge/plugins/label/label/template/options.html index 8f53dd463..8ea17325a 100644 --- a/deluge/plugins/label/label/template/options.html +++ b/deluge/plugins/label/label/template/options.html @@ -1,6 +1,5 @@ $def with (label_id, options_form) $:render.basic_header(_("Label Options")) -

$label_id Options.

@@ -15,7 +14,6 @@ $:render.basic_header(_("Label Options")) $:(options_form.as_table(["apply_queue", "is_auto_managed", "stop_at_ratio", "stop_ratio", "remove_at_ratio"])) -

location

$:(options_form.as_table(["apply_move_completed", "move_completed", "move_completed_path"])) @@ -30,5 +28,15 @@ $:render.basic_header(_("Label Options")) + $:render.footer() \ No newline at end of file diff --git a/deluge/plugins/label/label/template/options_page.html b/deluge/plugins/label/label/template/options_page.html new file mode 100644 index 000000000..b1f83e99b --- /dev/null +++ b/deluge/plugins/label/label/template/options_page.html @@ -0,0 +1,10 @@ +$def with (label_id) +$:render.basic_header(_("Label Options")) +

$label_id Options.

+
+
+ label= $label_id + +
+ +$:render.footer() \ No newline at end of file diff --git a/deluge/ui/webui/static/deluge-moo.js b/deluge/ui/webui/static/deluge-moo.js new file mode 100644 index 000000000..d0fca53e8 --- /dev/null +++ b/deluge/ui/webui/static/deluge-moo.js @@ -0,0 +1,62 @@ +/* +(c) Martijn Voncken mvoncken@gmail.com +License: GPL v3 +*/ + + + +/* += InputSensitivitySetter = +see : gtkui/sidebar_menu.py: + def apply_sensitivity(self, event=None): + for chk_id , sensitive_list in self.sensitive_groups: + chk = self.glade.get_widget(chk_id) + sens = chk.get_active() and chk.get_property("sensitive") + for widget_id in sensitive_list: + self.glade.get_widget(widget_id).set_sensitive(sens) + + +Sets disabled property of input fields according to value of checkboxes. +Example (see label plugin) + +new InputSensitivitySetter({prefix:"id_",groups:[ + ["apply_max", ["max_download_speed", "max_upload_speed", "max_upload_slots", "max_connections"]], + ["apply_queue", ["is_auto_managed", "stop_at_ratio"]], + ["stop_at_ratio", ["remove_at_ratio", "stop_ratio"]], #nested + ["apply_move_completed", ["move_completed"]], + ["move_completed", ["move_completed_path"]], #nested + ["auto_add", ["auto_add_trackers"]] +]}); + +*/ +var InputSensitivitySetter = new Class({ + Implements: [Options, Events], + options: { + groups : [], + prefix : "" /*django forms prefixes input elements with id_*/ + }, + initialize :function(options){ + this.setOptions(options); + this.attachWidgets(); + this.appySensitivity(); + } + ,attachWidgets: function() { + this.options.groups.each(function(group, i) { + el = $(this.options.prefix + group[0]); + el.addEvent('click', this.appySensitivity.bind(this)); + }, this); + } + ,appySensitivity: function () { + this.options.groups.each(function(group, i) { + var el = $(this.options.prefix + group[0]); + var widgets = group[1]; + var sensitive = (el.checked && !el.get('disabled')); + widgets.each(function(widget, i) { + $(this.options.prefix + widget).set('disabled', !sensitive); + },this); + },this); + } +}); + + + diff --git a/deluge/ui/webui/templates/white/basic_header.html b/deluge/ui/webui/templates/white/basic_header.html index 91ff5991f..ef8b575c2 100644 --- a/deluge/ui/webui/templates/white/basic_header.html +++ b/deluge/ui/webui/templates/white/basic_header.html @@ -11,6 +11,7 @@ $def with (title) + $for js in include_javascript: