1 mkws.registerWidgetType('Termlists', function() {
2 // Initially hide the termlists; display when we get results
5 mkws.$(document).ready(function() {
8 team.queue("termlists").subscribe(function(data) {
12 var template = team.loadTemplate(this.config.template || "Termlists");
13 this.node.html(template({
15 facets: this.config.facets
21 mkws.registerWidgetType('Facet', function() {
23 xtargets: [ "Sources", 16, false ],
24 subject: [ "Subjects", 10, true ],
25 author: [ "Authors", 10, true ]
29 var name = that.config.facet;
30 var ref = facetConfig[name] || [ "Unknown", 10, true ];
31 var caption = this.config['facet_caption_' + name] || ref[0];
32 var max = parseInt(this.config['facet_max_' + name] || ref[1]);
33 var pzIndex = ref[2] ? name : null;
35 that.toString = function() {
36 return '[Widget ' + team.name() + ':' + that.type + '(' + name + ')]';
39 team.queue("termlists").subscribe(function(data) {
42 var teamName = team.name();
43 for (var i = 0; i < data.length && i < max; i++) {
47 // Special case: target selection
48 linkdata += ('target_id='+data[i].id+' ');
49 if (!team.targetFiltered(data[i].id)) {
50 action = 'mkws.limitTarget(\'' + teamName + '\', this.getAttribute(\'target_id\'),this.firstChild.nodeValue)';
53 action = 'mkws.limitQuery(\'' + teamName + '\', \'' + pzIndex + '\', this.firstChild.nodeValue)';
55 linkdata += 'onclick="' + action + ';return false;"';
62 // configured template > facet specific template > default facet template
64 if (that.config.template) {
65 template = team.loadTemplate(that.config.template);
67 template = team.loadTemplate("Facet-" + caption);
69 that.log("Using Facet-" + caption + " template.")
71 that.log("No " + caption + " specific template, using default.")
72 template = team.loadTemplate("Facet");
75 that.node.html(template({