mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-06-24 22:33:16 +00:00
Fix linkcatcher recursion problem
Using action-navigate within the “actions” attribute of the linkcatcher widget would otherwise trigger the navigation handler recursively.
This commit is contained in:
parent
7bca39842f
commit
95ef1c4580
|
@ -48,6 +48,8 @@ LinkCatcherWidget.prototype.execute = function() {
|
||||||
this.catchActions = this.getAttribute("actions");
|
this.catchActions = this.getAttribute("actions");
|
||||||
// Construct the child widgets
|
// Construct the child widgets
|
||||||
this.makeChildWidgets();
|
this.makeChildWidgets();
|
||||||
|
// When executing actions we avoid trapping navigate events, so that we don't trigger ourselves recursively
|
||||||
|
this.executingActions = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -67,23 +69,35 @@ LinkCatcherWidget.prototype.refresh = function(changedTiddlers) {
|
||||||
Handle a tm-navigate event
|
Handle a tm-navigate event
|
||||||
*/
|
*/
|
||||||
LinkCatcherWidget.prototype.handleNavigateEvent = function(event) {
|
LinkCatcherWidget.prototype.handleNavigateEvent = function(event) {
|
||||||
if(this.catchTo) {
|
if(!this.executingActions) {
|
||||||
this.wiki.setTextReference(this.catchTo,event.navigateTo,this.getVariable("currentTiddler"));
|
// Execute the actions
|
||||||
}
|
if(this.catchTo) {
|
||||||
if(this.catchMessage && this.parentWidget) {
|
this.wiki.setTextReference(this.catchTo,event.navigateTo,this.getVariable("currentTiddler"));
|
||||||
|
}
|
||||||
|
if(this.catchMessage && this.parentWidget) {
|
||||||
|
this.parentWidget.dispatchEvent({
|
||||||
|
type: this.catchMessage,
|
||||||
|
param: event.navigateTo,
|
||||||
|
navigateTo: event.navigateTo
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if(this.catchSet) {
|
||||||
|
var tiddler = this.wiki.getTiddler(this.catchSet);
|
||||||
|
this.wiki.addTiddler(new $tw.Tiddler(tiddler,{title: this.catchSet, text: this.catchSetTo}));
|
||||||
|
}
|
||||||
|
if(this.catchActions) {
|
||||||
|
this.executingActions = true;
|
||||||
|
this.invokeActionString(this.catchActions,this,event,{navigateTo: event.navigateTo});
|
||||||
|
this.executingActions = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// This is a navigate event generated by the actions of this linkcatcher, so we don't trap it again, but just pass it to the parent
|
||||||
this.parentWidget.dispatchEvent({
|
this.parentWidget.dispatchEvent({
|
||||||
type: this.catchMessage,
|
type: "tm-navigate",
|
||||||
param: event.navigateTo,
|
param: event.navigateTo,
|
||||||
navigateTo: event.navigateTo
|
navigateTo: event.navigateTo
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if(this.catchSet) {
|
|
||||||
var tiddler = this.wiki.getTiddler(this.catchSet);
|
|
||||||
this.wiki.addTiddler(new $tw.Tiddler(tiddler,{title: this.catchSet, text: this.catchSetTo}));
|
|
||||||
}
|
|
||||||
if(this.catchActions) {
|
|
||||||
this.invokeActionString(this.catchActions,this,event,{navigateTo: event.navigateTo});
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user