Extend button widget to allow navigating to a tiddler

Fixes #327
This commit is contained in:
Jermolene
2014-02-22 16:13:16 +00:00
parent ec606c89d2
commit 2ab0facf3a
4 changed files with 13 additions and 6 deletions
+6 -1
View File
@@ -53,6 +53,10 @@ ButtonWidget.prototype.render = function(parent,nextSibling) {
// Add a click event handler
domNode.addEventListener("click",function (event) {
var handled = false;
if(self.to) {
self.dispatchEvent({type: "tw-navigate", navigateTo: self.to, tiddlerTitle: self.getVariable("currentTiddler")});
handled = true;
}
if(self.message) {
self.dispatchMessage(event);
handled = true;
@@ -110,6 +114,7 @@ Compute the internal state of the widget
*/
ButtonWidget.prototype.execute = function() {
// Get attributes
this.to = this.getAttribute("to");
this.message = this.getAttribute("message");
this.param = this.getAttribute("param");
this.set = this.getAttribute("set");
@@ -129,7 +134,7 @@ Selectively refreshes the widget if needed. Returns true if the widget or any of
*/
ButtonWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes();
if(changedAttributes.message || changedAttributes.param || changedAttributes.set || changedAttributes.setTo || changedAttributes.popup || changedAttributes.hover || changedAttributes["class"] || changedAttributes.selectedClass || changedAttributes.style || (this.set && changedTiddlers[this.set]) || (this.popup && changedTiddlers[this.popup])) {
if(changedAttributes.to || changedAttributes.message || changedAttributes.param || changedAttributes.set || changedAttributes.setTo || changedAttributes.popup || changedAttributes.hover || changedAttributes["class"] || changedAttributes.selectedClass || changedAttributes.style || (this.set && changedTiddlers[this.set]) || (this.popup && changedTiddlers[this.popup])) {
this.refreshSelf();
return true;
}