mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-08-05 21:33:52 +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:
parent
1c2c6ca63f
commit
51394e50e8
@ -91,6 +91,7 @@ LinkWidget.prototype.handleClickEvent = function (event) {
|
|||||||
this.dispatchEvent({
|
this.dispatchEvent({
|
||||||
type: "tw-navigate",
|
type: "tw-navigate",
|
||||||
navigateTo: this.to,
|
navigateTo: this.to,
|
||||||
|
navigateFromTitle: this.getVariable("currentTiddler"),
|
||||||
navigateFromNode: this,
|
navigateFromNode: this,
|
||||||
navigateFromClientRect: { top: bounds.top, left: bounds.left, width: bounds.width, right: bounds.right, bottom: bounds.bottom, height: bounds.height
|
navigateFromClientRect: { top: bounds.top, left: bounds.left, width: bounds.width, right: bounds.right, bottom: bounds.bottom, height: bounds.height
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,6 @@ var Widget = require("$:/core/modules/new_widgets/widget.js").widget;
|
|||||||
|
|
||||||
var TiddlerWidget = function(parseTreeNode,options) {
|
var TiddlerWidget = function(parseTreeNode,options) {
|
||||||
this.initialise(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() {
|
TiddlerWidget.prototype.execute = function() {
|
||||||
// Get our parameters
|
// Get our parameters
|
||||||
this.tiddlerTitle = this.getAttribute("tiddler","");
|
this.tiddlerTitle = this.getAttribute("tiddler",this.getVariable("currentTiddler"));
|
||||||
// Set context variables
|
// Set context variables
|
||||||
this.setVariable("currentTiddler",this.tiddlerTitle);
|
this.setVariable("currentTiddler",this.tiddlerTitle);
|
||||||
this.setVariable("missingTiddlerClass",(this.wiki.tiddlerExists(this.tiddlerTitle) || this.wiki.isShadowTiddler(this.tiddlerTitle)) ? "tw-tiddler-exists" : "tw-tiddler-missing");
|
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;
|
exports.tiddler = TiddlerWidget;
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user