Each widget now has its own config object, inheriting from the team
[mkws-moved-to-github.git] / src / mkws-widgets.js
index a389646..2056c48 100644 (file)
@@ -3,7 +3,8 @@ function widget($, team, type, node) {
     var that = {
        team: team,
        type: type,
-       node: node
+       node: node,
+       config: Object.create(team.config())
     };
 
     function log(s) {
@@ -13,14 +14,14 @@ function widget($, team, type, node) {
 
     that.toString = function() {
        return '[Widget ' + team.name() + ':' + type + ']';
-    }
+    };
 
     var fn = mkws.promotionFunction(type);
     if (fn) {
        fn.call(that);
        log("made " + type + " widget(node=" + node + ")");
     } else {
-       log("made UNENCAPSULATED widget(type=" + type + ", node=" + node + ")");
+       log("made UNPROMOTED widget(type=" + type + ", node=" + node + ")");
     }
 
     return that;
@@ -87,7 +88,8 @@ mkws.registerWidgetType('Termlists', function() {
        }
 
        // no facets: this should never happen
-       if (!mkws_config.facets || mkws_config.facets.length == 0) {
+       var facets = that.config.facets;
+       if (!facets || facets.length == 0) {
            alert("onTerm called even though we have no facets: " + $.toJSON(data));
            $(that.node).hide();
            return;
@@ -98,7 +100,6 @@ mkws.registerWidgetType('Termlists', function() {
 
        var acc = [];
        acc.push('<div class="title">' + M('Termlists') + '</div>');
-       var facets = mkws_config.facets;
 
        for (var i = 0; i < facets.length; i++) {
            if (facets[i] == "xtargets") {