1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-07-05 19:53:17 +00:00

Added ability for macros to register their own event handlers, and a rendering callback

This commit is contained in:
Jeremy Ruston 2012-03-31 18:10:16 +01:00
parent 2faa668717
commit 350f2f50d4

View File

@ -259,15 +259,23 @@ MacroNode.prototype.renderInDom = function(parentDomNode,insertBefore) {
}
// Add some debugging information to it
macroContainer.setAttribute("data-tw-macro",this.macroName);
// Add event handlers to the node
for(var e in this.macro.events) {
// Register this macro node to handle the event via the handleEvent() method
macroContainer.addEventListener(e,this,false);
// Ask the macro to add event handlers to the node
if(this.macro.addEventHandlers) {
this.macro.addEventHandlers.call(this);
} else {
for(var e in this.macro.events) {
// Register this macro node to handle the event via the handleEvent() method
macroContainer.addEventListener(e,this,false);
}
}
// Render the content of the macro
for(var t=0; t<this.content.length; t++) {
this.content[t].renderInDom(macroContainer);
}
// Call the macro renderInDom method if it has one
if(this.macro.renderInDom) {
this.macro.renderInDom.call(this);
}
};
MacroNode.prototype.refresh = function(changes) {