summaryrefslogtreecommitdiff
path: root/common/modules/template.jsm
diff options
context:
space:
mode:
authorKris Maglione <maglione.k@gmail.com>2011-01-24 00:37:32 -0500
committerKris Maglione <maglione.k@gmail.com>2011-01-24 00:37:32 -0500
commit0a422502baaf59a99be649c7d8aeff2547cbc7c6 (patch)
tree1250636f39690ed8d68431595db11689e75a905c /common/modules/template.jsm
parentbeb9d69eaa96f7ba05be7a165555e20d786f9424 (diff)
downloadpentadactyl-0a422502baaf59a99be649c7d8aeff2547cbc7c6.tar.gz
Add Clear button to :downloads.
--HG-- branch : key-processing
Diffstat (limited to 'common/modules/template.jsm')
-rw-r--r--common/modules/template.jsm23
1 files changed, 20 insertions, 3 deletions
diff --git a/common/modules/template.jsm b/common/modules/template.jsm
index 178d0259..d9db8cb6 100644
--- a/common/modules/template.jsm
+++ b/common/modules/template.jsm
@@ -104,15 +104,32 @@ var Template = Module("Template", {
init.supercall(this, node);
this.target = params.commandTarget;
- if (callable(this.target))
- this.target = { command: this.target }
},
+ get command() this.getAttribute("command") || this.getAttribute("key"),
+
events: {
"click": function onClick(event) {
event.preventDefault();
- this.target.command(this.getAttribute("key"));
+ if (this.commandAllowed) {
+ if (set.has(this.target.commands || {}, this.command))
+ this.target.commands[this.command].call(this.target);
+ else
+ this.target.command(this.command);
+ }
}
+ },
+
+ get commandAllowed() {
+ if (set.has(this.target.allowedCommands || {}, this.command))
+ return this.target.allowedCommands[this.command];
+ if ("commandAllowed" in this.target)
+ return this.target.commandAllowed(this.command);
+ return true;
+ },
+
+ update: function update() {
+ this.collapsed = !this.commandAllowed;
}
})
},