1 mkws.registerWidgetType('Termlists', function() {
6 xtargets: [ "Sources", 16, false ],
7 subject: [ "Subjects", 10, true ],
8 author: [ "Authors", 10, true ]
11 this.team.queue("termlists").subscribe(function(data) {
12 // no facets: this should never happen
13 var facets = that.config.facets;
14 if (!facets || facets.length == 0) {
15 alert("onTerm called even though we have no facets: " + $.toJSON(data));
20 // display if we first got results
25 acc.push('<div class="title">' + M('Termlists') + '</div>');
26 for (var i = 0; i < facets.length; i++) {
28 var ref = facetConfig[name];
30 alert("bad facet configuration: '" + name + "'");
32 acc.push('<div class="mkwsFacet mkwsFacet' + ref[0] + ' mkwsTeam_' + that.team.name() + '">');
36 $(that.node).html(acc.join(''));
39 for (var i = 0; i < facets.length; i++) {
41 var ref = facetConfig[name];
44 alert("bad facet configuration: '" + name + "'");
46 var output = makeSingleFacet(ref[0], data[name], ref[1], ref[2] ? name : null);
47 that.team.findnode('.mkwsFacet' + caption).html(output);
52 function makeSingleFacet(caption, data, max, pzIndex) {
53 var teamName = that.team.name();
56 acc.push('<div class="termtitle">' + M(caption) + '</div>');
57 for (var i = 0; i < data.length && i < max; i++) {
58 acc.push('<div class="term">');
59 acc.push('<a href="#" ');
62 // Special case: target selection
63 acc.push('target_id='+data[i].id+' ');
64 if (!that.team.targetFiltered(data[i].id)) {
65 action = 'mkws.limitTarget(\'' + teamName + '\', this.getAttribute(\'target_id\'),this.firstChild.nodeValue)';
68 action = 'mkws.limitQuery(\'' + teamName + '\', \'' + pzIndex + '\', this.firstChild.nodeValue)';
70 acc.push('onclick="' + action + ';return false;">' + data[i].name + '</a>'
71 + ' <span>' + data[i].freq + '</span>');
78 widget.autosearch(that);