label plugin mooui-test1

This commit is contained in:
Martijn Voncken 2008-10-29 19:47:40 +00:00
commit 86ce5d104a
5 changed files with 84 additions and 13 deletions

View file

@ -1 +0,0 @@
4118

View file

@ -1,5 +1,72 @@
/*testing include_javascript*/
/* /*
yep it works. # Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
window.alert("test-plugin-javascript"); # License : GPL v3.
*/ */
popup_icon = "/static/images/tango/emblem-symbolic-link.png" /*the best i could find in 15 minutes, i still hate it.*/
Plugins = {}
function _(str) {
return str /*#todo : translations; see Deluge.Strings.get*/
}
Plugins.Label = {
/*onload:*/
initialize: function() {
$$('.filter_label').each(Plugins.Label.addPopup);
var menu = new Widgets.PopupMenu()
menu.add(this.menu);
menu.addEvent('action', function(e) {
Plugins.Label.labelAction(e.action, e.value)
}.bind(this));
},
/*add menu to html-ui*/
addPopup: function (el) {
var label_id = el.id.substring(13) /*crop of "filter_label_"*/
el.innerHTML = "<img src='" + popup_icon + "' onclick=alert('popup:" + label_id + "')>" + el.innerHTML;
},
/*callback handler*/
labelAction: function(action, label_id) {
func = Plugins.Label[action];
func(label_id);
},
/*menu callbacks:*/
add: function(label_id) {
alert("Add Label:" + label_id);
},
edit: function() {
alert("Edit Label:" + label_id);
},
remove: function() {
alert("Remove Label:" + label_id);
},
/*popup menu definition*/
menu:[
{
type:'text',
action:'add',
text: _('Add Label'),
icon:'/static/images/tango/pause.png'
},
{
type: 'text',
action: 'edit',
text: _('Label Options'),
icon: '/static/images/tango/start.png'
},
{
type: 'text',
action: 'remove',
text: _('Remove Label'),
icon: '/static/images/tango/start.png'
}
]
};
window.addEvent('domready', Plugins.Label.initialize);

View file

@ -8,6 +8,9 @@ $def with (title, active_tab="NONE")
<link rel="shortcut icon" href="$base/static/images/deluge-icon.png" type="image/png" /> <link rel="shortcut icon" href="$base/static/images/deluge-icon.png" type="image/png" />
<link rel="stylesheet" type="text/css" href="$base/template_style.css" /> <link rel="stylesheet" type="text/css" href="$base/template_style.css" />
<script language="javascript" src="$base/static/deluge.js"></script> <script language="javascript" src="$base/static/deluge.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/mooui.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>
</head> </head>

View file

@ -1,5 +1,4 @@
$def with (torrent_list, label_filters) $def with (torrent_list, label_filters)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
$:render.header(_("Deluge : Torrent List"), 'home') $:render.header(_("Deluge : Torrent List"), 'home')

View file

@ -21,27 +21,30 @@ $if get_config("show_keyword_search"):
> >
</form> </form>
<br /><br /> <br /><br />
<!-- <!--
$filter_items $filter_items
--> -->
$for cat in filter_items.keys(): $for cat in filter_items.keys():
<div class="title" id="label_cat_$cat">$id_to_label(cat)</div> <div class="title" id="filter_cat_$cat">$id_to_label(cat)</div>
<ul> <ul>
$for value, count in filter_items[cat]: $for value, count in filter_items[cat]:
<li id="label_$(cat)_$(value)" <li id="filter_$(cat)_$(value)"
$if cat == get('filter_cat'): $if cat == get('filter_cat'):
$if value == get('filter_value'): $if value == get('filter_value'):
class="selected label_$cat" class="selected filter_$cat"
$else: $else:
class="label_$cat" class="filter_$cat"
$# I hate this, special case for All $else:
$# templetor sucks with multiple conditions in 1 if-statement, i need to find a better way, class="filter_$cat"
/*BROKEN, todo: fix this!!
I hate this, special case for All
templetor sucks with multiple conditions in 1 if-statement, i need to find a better way,
*/
$if cat == "state": $if cat == "state":
$if value == "All": $if value == "All":
$if not get('filter_value'): $if not get('filter_value'):
$if not get('filter_cat'): $if not get('filter_cat'):
class="selected" class="selected filter_$cat"
> >
<a href="$self_url(filter_cat=cat, filter_value=value, sort=get('sort'), order=get('order')) "> <a href="$self_url(filter_cat=cat, filter_value=value, sort=get('sort'), order=get('order')) ">
$if cat == "state": $if cat == "state":