mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-24 02:27:19 +00:00
Catch navigation events that fall through to the document
And broadcast them back to the first story macro that accepts them
This commit is contained in:
parent
33420ac936
commit
581d165822
@ -120,6 +120,10 @@ var App = function() {
|
|||||||
text: "The time was recently " + (new Date()).toString()
|
text: "The time was recently " + (new Date()).toString()
|
||||||
}));
|
}));
|
||||||
},3000);
|
},3000);
|
||||||
|
// Listen for navigate events that weren't caught
|
||||||
|
document.addEventListener("tw-navigate",function (event) {
|
||||||
|
renderer.broadcastEvent(event);
|
||||||
|
},false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -34,6 +34,10 @@ Node.prototype.clone = function() {
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Node.prototype.broadcastEvent = function(event) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
Node.prototype.execute =
|
Node.prototype.execute =
|
||||||
Node.prototype.render =
|
Node.prototype.render =
|
||||||
Node.prototype.renderInDom =
|
Node.prototype.renderInDom =
|
||||||
@ -220,10 +224,6 @@ MacroNode.prototype.renderInDom = function(parentDomNode,insertBefore) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
MacroNode.prototype.handleEvent = function(event) {
|
|
||||||
return this.macro.events[event.type].call(this,event);
|
|
||||||
};
|
|
||||||
|
|
||||||
MacroNode.prototype.refresh = function(changes) {
|
MacroNode.prototype.refresh = function(changes) {
|
||||||
var t,
|
var t,
|
||||||
self = this;
|
self = this;
|
||||||
@ -267,6 +267,26 @@ MacroNode.prototype.refreshInDom = function(changes) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
MacroNode.prototype.handleEvent = function(event) {
|
||||||
|
return this.macro.events[event.type].call(this,event);
|
||||||
|
};
|
||||||
|
|
||||||
|
MacroNode.prototype.broadcastEvent = function(event) {
|
||||||
|
if(this.macro.events && this.macro.events.hasOwnProperty(event.type)) {
|
||||||
|
if(!this.handleEvent(event)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(this.content) {
|
||||||
|
for(var t=0; t<this.content.length; t++) {
|
||||||
|
if(!this.content[t].broadcastEvent(event)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
var ElementNode = function(type,attributes,children) {
|
var ElementNode = function(type,attributes,children) {
|
||||||
if(this instanceof ElementNode) {
|
if(this instanceof ElementNode) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
@ -381,6 +401,17 @@ ElementNode.prototype.refreshInDom = function(changes) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ElementNode.prototype.broadcastEvent = function(event) {
|
||||||
|
if(this.children) {
|
||||||
|
for(var t=0; t<this.children.length; t++) {
|
||||||
|
if(!this.children[t].broadcastEvent(event)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
var TextNode = function(text) {
|
var TextNode = function(text) {
|
||||||
if(this instanceof TextNode) {
|
if(this instanceof TextNode) {
|
||||||
this.text = text;
|
this.text = text;
|
||||||
|
Loading…
Reference in New Issue
Block a user