mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-08 01:18:39 +00:00
label plugin:InputSensitivity
This commit is contained in:
parent
8a4da5b712
commit
81427006dd
6 changed files with 105 additions and 22 deletions
|
@ -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"]]
|
|
||||||
];
|
|
||||||
|
|
||||||
|
|
22
deluge/plugins/label/label/template/config_page.html
Normal file
22
deluge/plugins/label/label/template/config_page.html
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
$def with (labels)
|
||||||
|
$:render.basic_header(_("Label Config"))
|
||||||
|
<h2>$_("Label Config")</h2>
|
||||||
|
<table style="padding-left:20px;">
|
||||||
|
$for label in labels:
|
||||||
|
<tr>
|
||||||
|
<td><a href="$base/label/options/$label"
|
||||||
|
title="$_('Options')"
|
||||||
|
>$label</a></td>
|
||||||
|
</td>
|
||||||
|
<td><a href="$base/label/remove/$label"><img
|
||||||
|
src="$base/static/images/tango/list-remove.png"
|
||||||
|
title="$_('Remove')"
|
||||||
|
></a></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<h2>Options</h2>
|
||||||
|
<ul>
|
||||||
|
<li><a href="$base/label/add">$_("Add label")</a></li>
|
||||||
|
</ul>
|
||||||
|
$:render.footer()
|
|
@ -1,6 +1,5 @@
|
||||||
$def with (label_id, options_form)
|
$def with (label_id, options_form)
|
||||||
$:render.basic_header(_("Label Options"))
|
$:render.basic_header(_("Label Options"))
|
||||||
<script language="javascript" src="/label/data/apply_sensitivity.js"></script>
|
|
||||||
<h2>$label_id Options.</h2>
|
<h2>$label_id Options.</h2>
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
<form method="POST" action='$base/label/options/$label_id'>
|
<form method="POST" action='$base/label/options/$label_id'>
|
||||||
|
@ -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"]))
|
$:(options_form.as_table(["apply_queue", "is_auto_managed", "stop_at_ratio", "stop_ratio", "remove_at_ratio"]))
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
||||||
<h3>location</h3>
|
<h3>location</h3>
|
||||||
<table>
|
<table>
|
||||||
$:(options_form.as_table(["apply_move_completed", "move_completed", "move_completed_path"]))
|
$:(options_form.as_table(["apply_move_completed", "move_completed", "move_completed_path"]))
|
||||||
|
@ -30,5 +28,15 @@ $:render.basic_header(_("Label Options"))
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script language="javascript">
|
||||||
|
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"]]
|
||||||
|
]});
|
||||||
|
</script>
|
||||||
|
|
||||||
$:render.footer()
|
$:render.footer()
|
10
deluge/plugins/label/label/template/options_page.html
Normal file
10
deluge/plugins/label/label/template/options_page.html
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
$def with (label_id)
|
||||||
|
$:render.basic_header(_("Label Options"))
|
||||||
|
<h2>$label_id Options.</h2>
|
||||||
|
<div class="panel">
|
||||||
|
<form method="POST" action='$base/label/options/$label_id'>
|
||||||
|
label= $label_id
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
$:render.footer()
|
62
deluge/ui/webui/static/deluge-moo.js
Normal file
62
deluge/ui/webui/static/deluge-moo.js
Normal file
|
@ -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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ $def with (title)
|
||||||
<script language="javascript" src="$base/static/mootools-1.2-core.js"></script>
|
<script language="javascript" src="$base/static/mootools-1.2-core.js"></script>
|
||||||
<script language="javascript" src="$base/static/mootools-1.2-more.js"></script>
|
<script language="javascript" src="$base/static/mootools-1.2-more.js"></script>
|
||||||
<script language="javascript" src="$base/static/mooui.js"></script>
|
<script language="javascript" src="$base/static/mooui.js"></script>
|
||||||
|
<script language="javascript" src="$base/static/deluge-moo.js"></script>
|
||||||
<script language="javascript" src="$base/gettext.js"></script>
|
<script language="javascript" src="$base/gettext.js"></script>
|
||||||
$for js in include_javascript:
|
$for js in include_javascript:
|
||||||
<script language="javascript" src="$base$js"></script>
|
<script language="javascript" src="$base$js"></script>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue