1 mkws.registerWidgetType('facets', function() {
2 // Initially hide the facets; display when we get results
6 this.team.queue("searchtriggered").subscribe(function() {
7 var op = that.config.newsearch_opacity;
8 if (op !== undefined) { that.node.fadeTo(500, op); }
11 team.queue("facets").subscribe(function(data) {
13 that.node.css('opacity', 1);
14 that.node.addClass("active");
17 var template = team.loadTemplate(this.config.template || "facets");
18 this.node.html(template({
20 facets: this.config.facets
26 mkws.registerWidgetType('facet', function() {
28 xtargets: [ "Sources", 16, false ],
29 subject: [ "Subjects", 10, true ],
30 author: [ "Authors", 10, true ]
34 var name = that.config.facet;
35 var ref = facetConfig[name] || [ "Unknown", 10, true ];
36 var caption = this.config['facet_caption_' + name] || ref[0];
37 var max = parseInt(this.config['facet_max_' + name] || ref[1]);
38 var pzIndex = ref[2] ? name : null;
40 that.toString = function() {
41 return '[Widget ' + team.name() + ':' + that.type + '(' + name + ')]';
44 team.queue("facets").subscribe(function(data) {
47 var teamName = team.name();
48 var base = team.filters();
49 for (var i = 0; i < data.length && i < max; i++) {
50 var fs = $.extend(true, {}, base);
51 //team.warn("fs = " + mkws.$.toJSON(fs));
52 //team.warn("team.filters = " + mkws.$.toJSON(team.filters()));
54 // Special case: target selection
55 team.warn("before: team.filters = " + mkws.$.toJSON(team.filters()));
56 fs.add(targetFilter(data[i].id, data[i].name));
57 team.warn("after: team.filters = " + mkws.$.toJSON(team.filters()));
59 fs.add(fieldFilter(pzIndex, data[i].name));
64 href: '#' + team.urlFragment({ filters: fs })
67 // configured template > facet specific template > default facet template
69 if (that.config.template) {
70 template = team.loadTemplate(that.config.template);
72 template = team.loadTemplate("facet-" + name);
74 that.info("Using facet-" + name + " template.")
76 that.info("No " + name + " specific template, using default.")
77 template = team.loadTemplate("facet");
80 that.node.html(template({