X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmkws-widget-termlists.js;h=4052251142361921cb291163655ad2b5e92f38a9;hb=4a58da8ae4e60a8f786d460148a0ab1270473108;hp=e61ea645d2e41144164a6e1edba893ee7ab81bb9;hpb=2e5c86e69aebc7ac594db58ac0dbc63de7397527;p=mkws-moved-to-github.git diff --git a/src/mkws-widget-termlists.js b/src/mkws-widget-termlists.js index e61ea64..4052251 100644 --- a/src/mkws-widget-termlists.js +++ b/src/mkws-widget-termlists.js @@ -1,51 +1,81 @@ mkws.registerWidgetType('Termlists', function() { - var that = this; - var facets = that.config.facets; - var M = mkws.M; + // Initially hide the termlists; display when we get results + var that = this; + var team = this.team; + team.queue("termlists").subscribe(function(data) { + that.node.addClass("active"); + }); - this.team.queue("termlists").subscribe(function(data) { - // display if we first got results - $(that.node).show(); - }); - - this.team.queue("termlists").subscribe(function(data) { - for (var i = 0; i < facets.length; i++) { - var name = facets[i] - var ref = mkws.facetConfig[name]; - var caption = ref[0]; - if (!ref) { - alert("bad facet configuration: '" + name + "'"); - } else { - makeSingleFacet(ref[0], data[name], ref[1], ref[2] ? name : null); - } - } + var template = team.loadTemplate(this.config.template || "Termlists"); + this.node.html(template({ + team: team.name(), + facets: this.config.facets + })); + this.autosearch(); +}); - function makeSingleFacet(caption, data, max, pzIndex) { - var teamName = that.team.name(); +mkws.registerWidgetType('Facet', function() { + var facetConfig = { + xtargets: [ "Sources", 16, false ], + subject: [ "Subjects", 10, true ], + author: [ "Authors", 10, true ] + } + var that = this; + var team = this.team; + var name = that.config.facet; + var ref = facetConfig[name] || [ "Unknown", 10, true ]; + var caption = this.config['facet_caption_' + name] || ref[0]; + var max = parseInt(this.config['facet_max_' + name] || ref[1]); + var pzIndex = ref[2] ? name : null; - var acc = []; - acc.push('