X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmkws-widget-termlists.js;h=2e684f660564b32002c86b07ca7d8bd4983cfa02;hb=fb9e3fb3b09926f4be249b0263b9ad3174830481;hp=ce801ec20dd5ab143a68ee7d11a585f2e1293153;hpb=ee3953c2d2dcdec10648134bc75ae6fcf257e9b0;p=mkws-moved-to-github.git diff --git a/src/mkws-widget-termlists.js b/src/mkws-widget-termlists.js index ce801ec..2e684f6 100644 --- a/src/mkws-widget-termlists.js +++ b/src/mkws-widget-termlists.js @@ -1,50 +1,81 @@ -mkws.registerWidgetType('Termlists', function() { - var that = this; - var facets = that.config.facets; - var M = mkws.M; +mkws.registerWidgetType('termlists', function() { + // 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(); - - 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 { - var output = makeSingleFacet(ref[0], data[name], ref[1], ref[2] ? name : null); - that.team.findnode('.mkwsFacet' + caption).html(output); - } - } + 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('