1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
/*
# Copyright (C) Martijn Voncken 2008 <mvoncken@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, write to:
# The Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor
# Boston, MA 02110-1301, USA.
#
*/
popup_icon = "/static/images/tango/emblem-symbolic-link.png" /*the best i could find in 15 minutes, i still hate it.*/
Plugins = {}
Plugins.Label = {
initialize : function() {
this.bound = {
addPopup: this.addPopup.bind(this),
labelAction: this.labelAction.bindWithEvent(this),
};
$$('.filter_label').each(this.bound.addPopup);
var menu = new Widgets.PopupMenu();
menu.add(this.menu);
menu.addEvent('action', this.bound.labelAction);
},
/*add menu to html-ui*/
addPopup: function (el) {
var label_id = el.id.substring(13); /*crop of "filter_label_"*/
el.addEvent('contextmenu', function(el) {
alert('popup menu here : [label="' + label_id + '"] (using this.menu definitions)');
return false;
});
},
/*callback handler*/
labelAction: function(action, label_id) {
// We use $empty here to ensure that there is some form of a
// function to call
func = ($defined(this[action])) ? this[action] : $empty;
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', function(e) {
Plugins.Label.initialize();
});
|