mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-27 03:57:21 +00:00
Update linkcatcher to optionally trigger a different event
This commit is contained in:
parent
0cbb89770f
commit
d4b6c05bc2
@ -24,6 +24,9 @@ var LinkCatcherWidget = function(renderer) {
|
|||||||
LinkCatcherWidget.prototype.generate = function() {
|
LinkCatcherWidget.prototype.generate = function() {
|
||||||
// Get our attributes
|
// Get our attributes
|
||||||
this.to = this.renderer.getAttribute("to");
|
this.to = this.renderer.getAttribute("to");
|
||||||
|
this.message = this.renderer.getAttribute("message");
|
||||||
|
this.set = this.renderer.getAttribute("set");
|
||||||
|
this.setTo = this.renderer.getAttribute("setTo");
|
||||||
// Set the element
|
// Set the element
|
||||||
this.tag = "div";
|
this.tag = "div";
|
||||||
this.attributes = {
|
this.attributes = {
|
||||||
@ -49,10 +52,20 @@ LinkCatcherWidget.prototype.handleNavigateEvent = function(event) {
|
|||||||
if(this.to) {
|
if(this.to) {
|
||||||
this.renderer.renderTree.wiki.setTextReference(this.to,event.navigateTo,this.renderer.tiddlerTitle);
|
this.renderer.renderTree.wiki.setTextReference(this.to,event.navigateTo,this.renderer.tiddlerTitle);
|
||||||
}
|
}
|
||||||
|
if(this.message) {
|
||||||
|
$tw.utils.dispatchCustomEvent(this.renderer.domNode,this.message,{
|
||||||
|
param: event.navigateTo,
|
||||||
|
tiddlerTitle: this.renderer.tiddlerTitle
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if(this.set) {
|
||||||
|
var tiddler = this.renderer.renderTree.wiki.getTiddler(this.set);
|
||||||
|
this.renderer.renderTree.wiki.addTiddler(new $tw.Tiddler(tiddler,{title: this.set, text: this.setTo}));
|
||||||
|
}
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.linkcatcher = LinkCatcherWidget;
|
exports.linkcatcher = LinkCatcherWidget;
|
||||||
|
|
||||||
})();
|
})();
|
Loading…
Reference in New Issue
Block a user