1 mkws.registerWidgetType('Termlists', function() {
4 // Initially hide the termlists; display when we get results
5 mkws.$(document).ready(function() {
8 this.team.queue("termlists").subscribe(function(data) {
13 var facets = this.config.facets;
14 acc.push('<div class="mkwsTermlistsTitle">' + mkws.M('Termlists') + '</div>');
15 for (var i = 0; i < facets.length; i++) {
16 acc.push('<div class="mkwsFacet mkwsTeam_', this.team.name(), '" data-mkws-facet="', facets[i], '">', '</div>');
18 this.node.html(acc.join(''));
20 widget.autosearch(this);
24 mkws.registerWidgetType('Facet', function() {
26 xtargets: [ "Sources", 16, false ],
27 subject: [ "Subjects", 10, true ],
28 author: [ "Authors", 10, true ]
32 var name = that.config.facet;
33 var ref = facetConfig[name] || [ "Unknown", 10, true ];
34 var caption = this.config['facet_caption_' + name] || ref[0];
35 var max = parseInt(this.config['facet_max_' + name] || ref[1]);
36 var pzIndex = ref[2] ? name : null;
38 that.toString = function() {
39 return '[Widget ' + that.team.name() + ':' + that.type + '(' + name + ')]';
42 that.team.queue("termlists").subscribe(function(data) {
45 var teamName = that.team.name();
47 acc.push('<div class="mkwsFacetTitle">' + mkws.M(caption) + '</div>');
48 for (var i = 0; i < data.length && i < max; i++) {
49 acc.push('<div class="mkwsTerm">');
50 acc.push('<a href="#" ');
53 // Special case: target selection
54 acc.push('target_id='+data[i].id+' ');
55 if (!that.team.targetFiltered(data[i].id)) {
56 action = 'mkws.limitTarget(\'' + teamName + '\', this.getAttribute(\'target_id\'),this.firstChild.nodeValue)';
59 action = 'mkws.limitQuery(\'' + teamName + '\', \'' + pzIndex + '\', this.firstChild.nodeValue)';
61 acc.push('onclick="' + action + ';return false;">' + data[i].name + '</a>'
62 + ' <span>' + data[i].freq + '</span>');
66 that.node.html(acc.join(''));