1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 18:17:20 +00:00

Get rid of the event handling in the tiddler widget

Much neater if each widget does as little as possible.
This commit is contained in:
Jeremy Ruston 2013-11-02 10:12:22 +00:00
parent 1c2c6ca63f
commit 51394e50e8
2 changed files with 2 additions and 12 deletions

View File

@ -91,6 +91,7 @@ LinkWidget.prototype.handleClickEvent = function (event) {
this.dispatchEvent({
type: "tw-navigate",
navigateTo: this.to,
navigateFromTitle: this.getVariable("currentTiddler"),
navigateFromNode: this,
navigateFromClientRect: { top: bounds.top, left: bounds.left, width: bounds.width, right: bounds.right, bottom: bounds.bottom, height: bounds.height
}

View File

@ -16,9 +16,6 @@ var Widget = require("$:/core/modules/new_widgets/widget.js").widget;
var TiddlerWidget = function(parseTreeNode,options) {
this.initialise(parseTreeNode,options);
this.addEventListeners([
{type: "tw-navigate", handler: "handleNavigateEvent"}
]);
};
/*
@ -41,7 +38,7 @@ Compute the internal state of the widget
*/
TiddlerWidget.prototype.execute = function() {
// Get our parameters
this.tiddlerTitle = this.getAttribute("tiddler","");
this.tiddlerTitle = this.getAttribute("tiddler",this.getVariable("currentTiddler"));
// Set context variables
this.setVariable("currentTiddler",this.tiddlerTitle);
this.setVariable("missingTiddlerClass",(this.wiki.tiddlerExists(this.tiddlerTitle) || this.wiki.isShadowTiddler(this.tiddlerTitle)) ? "tw-tiddler-exists" : "tw-tiddler-missing");
@ -64,14 +61,6 @@ TiddlerWidget.prototype.refresh = function(changedTiddlers) {
}
};
/*
Handle a tw-navigate event
*/
TiddlerWidget.prototype.handleNavigateEvent = function(event) {
event.navigateFromTitle = this.tiddlerTitle;
return true;
};
exports.tiddler = TiddlerWidget;
})();