X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmkws-widget.js;h=25e68555170ee64f1767123c358aaa3236bfb486;hb=d1104229b6ce759a8f825f39d58bde19813a223c;hp=f050e77bc7033d6627f1736a48784d915adccb3f;hpb=2db7fbc13228be3ab6032f3299ddea116895ebbb;p=mkws-moved-to-github.git diff --git a/src/mkws-widget.js b/src/mkws-widget.js index f050e77..25e6855 100644 --- a/src/mkws-widget.js +++ b/src/mkws-widget.js @@ -26,6 +26,34 @@ function widget($, team, type, node) { return node.value; }; + // Returns the HTML of a subwidget of the specified type. It gets + // the same attributes at the parent widget that invokes this + // function, except where overrides are passed in. + that.subwidget = function(type, overrides) { + var attrs = {}; + + // Copy locally-set properties from the parent widget + for (var name in this.config) { + if (this.config.hasOwnProperty(name)) { + attrs[name] = this.config[name]; + log(this + " copied property " + name + "='" + attrs[name] + "' to " + type + " subwidget"); + } + } + + for (var name in overrides) { + attrs[name] = overrides[name]; + log(this + " overrode property " + name + "='" + attrs[name] + "' for " + type + " subwidget"); + } + + var s = []; + s.push('
'); + return s.join(''); + }; + for (var i = 0; i < node.attributes.length; i++) { var a = node.attributes[i]; if (a.name === 'data-mkws-config') {