1 mkws.registerWidgetType('Termlists', function() {
3 var facets = that.config.facets;
6 this.team.queue("termlists").subscribe(function(data) {
7 // display if we first got results
11 this.team.queue("termlists").subscribe(function(data) {
12 for (var i = 0; i < facets.length; i++) {
14 var ref = mkws.facetConfig[name];
17 alert("bad facet configuration: '" + name + "'");
19 makeSingleFacet(ref[0], data[name], ref[1], ref[2] ? name : null);
24 function makeSingleFacet(caption, data, max, pzIndex) {
25 var teamName = that.team.name();
28 acc.push('<div class="termtitle">' + M(caption) + '</div>');
29 for (var i = 0; i < data.length && i < max; i++) {
30 acc.push('<div class="term">');
31 acc.push('<a href="#" ');
34 // Special case: target selection
35 acc.push('target_id='+data[i].id+' ');
36 if (!that.team.targetFiltered(data[i].id)) {
37 action = 'mkws.limitTarget(\'' + teamName + '\', this.getAttribute(\'target_id\'),this.firstChild.nodeValue)';
40 action = 'mkws.limitQuery(\'' + teamName + '\', \'' + pzIndex + '\', this.firstChild.nodeValue)';
42 acc.push('onclick="' + action + ';return false;">' + data[i].name + '</a>'
43 + ' <span>' + data[i].freq + '</span>');
46 that.team.findnode('.mkwsFacet' + caption).html(acc.join(''));
50 widget.autosearch(that);