diff --git a/core/modules/widgetbase.js b/core/modules/widgetbase.js index ef659f712..6d30ad8c5 100644 --- a/core/modules/widgetbase.js +++ b/core/modules/widgetbase.js @@ -25,6 +25,32 @@ WidgetBase.prototype.init = function(renderer) { this.renderer = renderer; }; +/* +Default render() method just renders child nodes +*/ +WidgetBase.prototype.render = function(type) { + var output = []; + $tw.utils.each(this.children,function(node) { + if(node.render) { + output.push(node.render(type)); + } + }); + return output.join(""); +}; + +/* +Default renderInDom() method just renders child nodes +*/ +WidgetBase.prototype.renderInDom = function(parentElement) { + this.parentElement = parentElement; + // Render any child nodes + $tw.utils.each(this.children,function(node) { + if(node.renderInDom) { + parentElement.appendChild(node.renderInDom()); + } + }); +}; + exports.WidgetBase = WidgetBase; })(); diff --git a/core/modules/widgets/button.js b/core/modules/widgets/button.js index dcd2ab1bf..611645aa0 100644 --- a/core/modules/widgets/button.js +++ b/core/modules/widgets/button.js @@ -55,26 +55,6 @@ exports.generateChildNodes = function() { }]); }; -exports.render = function(type) { - var output = []; - $tw.utils.each(this.children,function(node) { - if(node.render) { - output.push(node.render(type)); - } - }); - return output.join(""); -}; - -exports.renderInDom = function(parentElement) { - this.parentElement = parentElement; - // Render any child nodes - $tw.utils.each(this.children,function(node) { - if(node.renderInDom) { - parentElement.appendChild(node.renderInDom()); - } - }); -}; - exports.dispatchMessage = function(event) { $tw.utils.dispatchCustomEvent(event.target,this.message,{ param: this.param, diff --git a/core/modules/widgets/link.js b/core/modules/widgets/link.js index 1ee43908b..ea5fa4bbe 100644 --- a/core/modules/widgets/link.js +++ b/core/modules/widgets/link.js @@ -68,26 +68,6 @@ exports.generateChildNodes = function() { }]); }; -exports.render = function(type) { - var output = []; - $tw.utils.each(this.children,function(node) { - if(node.render) { - output.push(node.render(type)); - } - }); - return output.join(""); -}; - -exports.renderInDom = function(parentElement) { - this.parentElement = parentElement; - // Render any child nodes - $tw.utils.each(this.children,function(node) { - if(node.renderInDom) { - parentElement.appendChild(node.renderInDom()); - } - }); -}; - exports.handleClickEvent = function(event) { if(isLinkExternal(this.to)) { event.target.setAttribute("target","_blank"); diff --git a/core/modules/widgets/list/list.js b/core/modules/widgets/list/list.js index b1c2bce4e..7545d2790 100644 --- a/core/modules/widgets/list/list.js +++ b/core/modules/widgets/list/list.js @@ -193,26 +193,6 @@ exports.findListElementByTitle = function(startIndex,title) { return undefined; }; -exports.render = function(type) { - var output = []; - $tw.utils.each(this.children,function(node) { - if(node.render) { - output.push(node.render(type)); - } - }); - return output.join(""); -}; - -exports.renderInDom = function(parentElement) { - this.parentElement = parentElement; - // Render any child nodes - $tw.utils.each(this.children,function(node) { - if(node.renderInDom) { - parentElement.appendChild(node.renderInDom()); - } - }); -}; - exports.refreshInDom = function(changedAttributes,changedTiddlers) { // Reexecute the widget if any of our attributes have changed if(changedAttributes.itemClass || changedAttributes.template || changedAttributes.editTemplate || changedAttributes.emptyMessage || changedAttributes.type || changedAttributes.filter || changedAttributes.template) { diff --git a/core/modules/widgets/navigator.js b/core/modules/widgets/navigator.js index 339809a65..3d60dcae0 100644 --- a/core/modules/widgets/navigator.js +++ b/core/modules/widgets/navigator.js @@ -31,16 +31,6 @@ exports.generateChildNodes = function() { this.children = this.renderer.renderTree.createRenderers(this.renderer.renderContext,this.renderer.parseTreeNode.children); }; -exports.render = function(type) { - var output = []; - $tw.utils.each(this.children,function(node) { - if(node.render) { - output.push(node.render(type)); - } - }); - return output.join(""); -}; - exports.renderInDom = function(parentElement) { this.parentElement = parentElement; // Render any child nodes diff --git a/core/modules/widgets/transclude.js b/core/modules/widgets/transclude.js index 7b6f22234..ac5001a48 100644 --- a/core/modules/widgets/transclude.js +++ b/core/modules/widgets/transclude.js @@ -100,26 +100,6 @@ exports.generateChildNodes = function() { }]); }; -exports.render = function(type) { - var output = []; - $tw.utils.each(this.children,function(node) { - if(node.render) { - output.push(node.render(type)); - } - }); - return output.join(""); -}; - -exports.renderInDom = function(parentElement) { - this.parentElement = parentElement; - // Render any child nodes - $tw.utils.each(this.children,function(node) { - if(node.renderInDom) { - parentElement.appendChild(node.renderInDom()); - } - }); -}; - exports.refreshInDom = function(changedAttributes,changedTiddlers) { // Set the class for missing tiddlers if(this.targetTitle) { diff --git a/core/modules/widgets/view/view.js b/core/modules/widgets/view/view.js index c1f834a6c..198ba794e 100644 --- a/core/modules/widgets/view/view.js +++ b/core/modules/widgets/view/view.js @@ -95,26 +95,6 @@ exports.generateChildNodes = function() { this.children = this.viewer.render(); }; -exports.render = function(type) { - var output = []; - $tw.utils.each(this.children,function(node) { - if(node.render) { - output.push(node.render(type)); - } - }); - return output.join(""); -}; - -exports.renderInDom = function(parentElement) { - this.parentElement = parentElement; - // Render any child nodes - $tw.utils.each(this.children,function(node) { - if(node.renderInDom) { - parentElement.appendChild(node.renderInDom()); - } - }); -}; - exports.refreshInDom = function(changedAttributes,changedTiddlers) { // Check if any of our attributes have changed, or if a tiddler we're interested in has changed if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.format || (this.tiddlerTitle && changedTiddlers[this.tiddlerTitle])) {