X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmkws-widget.js;h=9a3a7f76c458694c50a6a7c31d71795284060d2f;hb=5b22f5dbb32564454ce63cd73b33237bc2103b18;hp=f702fb1b51634645f6b0bc1cf8eeb84650e08e2f;hpb=467a5f1e52a2fc97c28510659658a91f1dcabb98;p=mkws-moved-to-github.git diff --git a/src/mkws-widget.js b/src/mkws-widget.js index f702fb1..9a3a7f7 100644 --- a/src/mkws-widget.js +++ b/src/mkws-widget.js @@ -10,7 +10,7 @@ function widget($, team, type, node) { team: team, type: type, node: $(node), - config: mkws.objectInheritingFrom(team.config()) + config: mkws.objectInheritingFrom(team.config) }; function log(s) { @@ -43,8 +43,8 @@ function widget($, team, type, node) { } for (var name in overrides) { + log(this + " overrode property " + name + "='" + overrides[name] + "' (was '" + attrs[name] + "') for " + type + " subwidget"); attrs[name] = overrides[name]; - log(this + " overrode property " + name + "='" + attrs[name] + "' for " + type + " subwidget"); } if (defaults) { @@ -66,6 +66,7 @@ function widget($, team, type, node) { return s.join(''); }; + // ### why is this a member function? It's never called from outside this file. that.expandValue = function(val) { if (val.match(/^!param!/)) { var param = val.replace(/^!param!/, ''); @@ -98,11 +99,10 @@ function widget($, team, type, node) { var that = this; var query = this.config.autosearch; if (query) { - query = this.expandValue(query); - var old = this.team.config().query; + var old = this.team.config.query; if (!old) { // Stash this for subsequent inspection - this.team.config().query = query; + this.team.config.query = query; } else if (old === query) { this.log("duplicate autosearch: '" + query + "': ignoring"); return; @@ -153,26 +153,27 @@ function widget($, team, type, node) { for (var i = 0; i < node.attributes.length; i++) { var a = node.attributes[i]; + var val = that.expandValue(a.value); if (a.name === 'data-mkws-config') { // Treat as a JSON fragment configuring just this widget - log(node + ": parsing config fragment '" + a.value + "'"); + log(node + ": parsing config fragment '" + val + "'"); var data; try { - data = $.parseJSON(a.value); + data = $.parseJSON(val); for (var key in data) { log(node + ": adding config element " + key + "='" + data[key] + "'"); that.config[key] = data[key]; } } catch (err) { - alert("Can't parse " + node + " data-mkws-config as JSON: " + a.value); + alert("Can't parse " + node + " data-mkws-config as JSON: " + val); } } else if (a.name.match (/^data-mkws-/)) { var name = a.name.replace(/^data-mkws-/, '') - that.config[name] = a.value; - log(that + ": set data-mkws attribute " + name + "='" + a.value + "'"); + that.config[name] = val; + log(that + ": set data-mkws attribute " + name + "='" + val + "'"); } else if (!ignoreAttrs[a.name]) { - that.config[a.name] = a.value; - log(that + ": set regular attribute " + a.name + "='" + a.value + "'"); + that.config[a.name] = val; + log(that + ": set regular attribute " + a.name + "='" + val + "'"); } }