mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-19 22:58:30 +00:00
update label plugin javascript test case
alias _ to Deluge.Strings.get
This commit is contained in:
parent
86ce5d104a
commit
da6594d138
@ -15,26 +15,34 @@ function _(str) {
|
|||||||
Plugins.Label = {
|
Plugins.Label = {
|
||||||
/*onload:*/
|
/*onload:*/
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
$$('.filter_label').each(Plugins.Label.addPopup);
|
this.bound = {
|
||||||
|
addPopup: this.addPopup.bind(this),
|
||||||
|
labelAction: this.labelAction.bindWithEvent(this)
|
||||||
|
};
|
||||||
|
|
||||||
var menu = new Widgets.PopupMenu()
|
$$('.filter_label').each(this.bound.addPopup);
|
||||||
|
|
||||||
|
var menu = new Widgets.PopupMenu();
|
||||||
menu.add(this.menu);
|
menu.add(this.menu);
|
||||||
menu.addEvent('action', function(e) {
|
menu.addEvent('action', this.bound.labelAction);
|
||||||
Plugins.Label.labelAction(e.action, e.value)
|
|
||||||
}.bind(this));
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/*add menu to html-ui*/
|
/*add menu to html-ui*/
|
||||||
addPopup: function (el) {
|
addPopup: function (el) {
|
||||||
var label_id = el.id.substring(13) /*crop of "filter_label_"*/
|
var label_id = el.id.substring(13); /*crop of "filter_label_"*/
|
||||||
el.innerHTML = "<img src='" + popup_icon + "' onclick=alert('popup:" + label_id + "')>" + el.innerHTML;
|
el.addEvent('click', function(el) {
|
||||||
|
alert('popup:' + label_id);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
/*callback handler*/
|
/*callback handler*/
|
||||||
labelAction: function(action, label_id) {
|
labelAction: function(action, label_id) {
|
||||||
func = Plugins.Label[action];
|
// 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);
|
func(label_id);
|
||||||
},
|
},
|
||||||
|
|
||||||
/*menu callbacks:*/
|
/*menu callbacks:*/
|
||||||
add: function(label_id) {
|
add: function(label_id) {
|
||||||
alert("Add Label:" + label_id);
|
alert("Add Label:" + label_id);
|
||||||
|
@ -65,3 +65,4 @@ Deluge.Strings.add('Files', '$_('Files')');
|
|||||||
Deluge.Strings.add('Peers', '$_('Peers')');
|
Deluge.Strings.add('Peers', '$_('Peers')');
|
||||||
Deluge.Strings.add('Options', '$_('Options')');
|
Deluge.Strings.add('Options', '$_('Options')');
|
||||||
|
|
||||||
|
_ = Deluge.Strings.get;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user