1 mkws.registerWidgetType('facets', function() {
2 // Initially hide the facets; display when we get results
5 team.queue("facets").subscribe(function(data) {
6 that.node.addClass("active");
9 var template = team.loadTemplate(this.config.template || "facets");
10 this.node.html(template({
12 facets: this.config.facets
18 mkws.registerWidgetType('facet', function() {
20 xtargets: [ "Sources", 16, false ],
21 subject: [ "Subjects", 10, true ],
22 author: [ "Authors", 10, true ]
26 var name = that.config.facet;
27 var ref = facetConfig[name] || [ "Unknown", 10, true ];
28 var caption = this.config['facet_caption_' + name] || ref[0];
29 var max = parseInt(this.config['facet_max_' + name] || ref[1]);
30 var pzIndex = ref[2] ? name : null;
32 that.toString = function() {
33 return '[Widget ' + team.name() + ':' + that.type + '(' + name + ')]';
36 team.queue("facets").subscribe(function(data) {
39 var teamName = team.name();
40 for (var i = 0; i < data.length && i < max; i++) {
44 // Special case: target selection
45 linkdata += ('target_id='+data[i].id+' ');
46 if (!team.targetFiltered(data[i].id)) {
47 action = 'mkws.limitTarget(\'' + teamName + '\', this.getAttribute(\'target_id\'),this.firstChild.nodeValue)';
50 action = 'mkws.limitQuery(\'' + teamName + '\', \'' + pzIndex + '\', this.firstChild.nodeValue)';
52 linkdata += 'onclick="' + action + ';return false;"';
60 // configured template > facet specific template > default facet template
62 if (that.config.template) {
63 template = team.loadTemplate(that.config.template);
65 template = team.loadTemplate("facet-" + name);
67 that.info("Using facet-" + name + " template.")
69 that.info("No " + name + " specific template, using default.")
70 template = team.loadTemplate("facet");
73 that.node.html(template({
76 query: that.config.query,