mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-26 01:50:28 +00:00
Added ability for macros to register their own event handlers, and a rendering callback
This commit is contained in:
parent
2faa668717
commit
350f2f50d4
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user