X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmkws-widget-termlists.js;h=4823d2cb6b977cc6e5b11e2d92a5b1aa74e9a8da;hb=70318a73321ecf3b5fbfd159ff44bdc5f5d6a63d;hp=b28261479ea23fbada6fb7cb6410ac84b0c224a4;hpb=f122cb28acf4edfef651bc59472f1a88d03b6035;p=mkws-moved-to-github.git
diff --git a/src/mkws-widget-termlists.js b/src/mkws-widget-termlists.js
index b282614..4823d2c 100644
--- a/src/mkws-widget-termlists.js
+++ b/src/mkws-widget-termlists.js
@@ -2,11 +2,11 @@ mkws.registerWidgetType('Termlists', function() {
var that = this;
// Initially hide the termlists; display when we get results
- $(document).ready(function() {
- $(that.node).hide();
+ mkws.$(document).ready(function() {
+ that.node.hide();
});
this.team.queue("termlists").subscribe(function(data) {
- $(that.node).show();
+ that.node.show();
});
var acc = [];
@@ -15,9 +15,9 @@ mkws.registerWidgetType('Termlists', function() {
for (var i = 0; i < facets.length; i++) {
acc.push('
', '
');
}
- $(this.node).html(acc.join(''));
+ this.node.html(acc.join(''));
- widget.autosearch(this);
+ this.autosearch();
});
@@ -30,9 +30,9 @@ mkws.registerWidgetType('Facet', function() {
var that = this;
var name = that.config.facet;
- var ref = facetConfig[name] || alert("no facet definition for '" + name + "'");
- var caption = ref[0];
- var max = ref[1];
+ var ref = facetConfig[name] || [ "Unknown", 10, true ];
+ var caption = this.config['facet_caption_' + name] || ref[0];
+ var max = parseInt(this.config['facet_max_' + name] || ref[1]);
var pzIndex = ref[2] ? name : null;
that.toString = function() {
@@ -41,28 +41,35 @@ mkws.registerWidgetType('Facet', function() {
that.team.queue("termlists").subscribe(function(data) {
data = data[name];
+ var template = that.team.loadTemplate('facetTitle-' + caption, mkws.M(caption))
+ var title = template({ query: that.config.query });
+ var acc = [];
+ acc.push('', title, '
');
var teamName = that.team.name();
- var acc = [];
- acc.push('' + mkws.M(caption) + '
');
for (var i = 0; i < data.length && i < max; i++) {
- acc.push('');
+
+ var template = that.team.loadTemplate('Facet');
+ var s = template({
+ team: teamName,
+ fn: fn,
+ field: datum,
+ term: data[i].name,
+ count: data[i].freq,
+ query: that.config.query
+ });
+ acc.push('', s, '
');
}
- $(that.node).html(acc.join(''));
+ that.node.html(acc.join(''));
});
+
+ this.autosearch();
});