Update linkcatcher to optionally trigger a different event

print-window-tiddler
Jeremy Ruston 2013-06-09 19:26:42 +01:00
rodzic 0cbb89770f
commit d4b6c05bc2
1 zmienionych plików z 14 dodań i 1 usunięć

Wyświetl plik

@ -24,6 +24,9 @@ var LinkCatcherWidget = function(renderer) {
LinkCatcherWidget.prototype.generate = function() {
// Get our attributes
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
this.tag = "div";
this.attributes = {
@ -49,10 +52,20 @@ LinkCatcherWidget.prototype.handleNavigateEvent = function(event) {
if(this.to) {
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();
return false;
};
exports.linkcatcher = LinkCatcherWidget;
})();
})();