X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmkws-widget-termlists.js;h=3ea68f5cbbeca4fe0611a9be6791bb9a1a3ceb85;hb=8843c8a949a4c78ea141515cee85d269fa417fb5;hp=69d97a556d9818ecb154d085c8df3d4462d1bc49;hpb=a442ae54ee85ce806e8b9c33b6e4845f7c7fde92;p=mkws-moved-to-github.git
diff --git a/src/mkws-widget-termlists.js b/src/mkws-widget-termlists.js
index 69d97a5..3ea68f5 100644
--- a/src/mkws-widget-termlists.js
+++ b/src/mkws-widget-termlists.js
@@ -1,73 +1,68 @@
mkws.registerWidgetType('Termlists', function() {
var that = this;
- var M = mkws.M;
+ // Initially hide the termlists; display when we get results
+ $(document).ready(function() {
+ $(that.node).hide();
+ });
+ this.team.queue("termlists").subscribe(function(data) {
+ $(that.node).show();
+ });
+
+ var acc = [];
+ var facets = this.config.facets;
+ acc.push('
' + mkws.M('Termlists') + '
');
+ for (var i = 0; i < facets.length; i++) {
+ acc.push('', '
');
+ }
+ $(this.node).html(acc.join(''));
+
+ widget.autosearch(this);
+});
+
+
+mkws.registerWidgetType('Facet', function() {
var facetConfig = {
xtargets: [ "Sources", 16, false ],
subject: [ "Subjects", 10, true ],
author: [ "Authors", 10, true ]
}
- this.team.queue("termlists").subscribe(function(data) {
- // no facets: this should never happen
- var facets = that.config.facets;
-
- // display if we first got results
- $(that.node).show();
+ 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 pzIndex = ref[2] ? name : null;
- var acc = [];
- acc.push('' + M('Termlists') + '
');
- for (var i = 0; i < facets.length; i++) {
- var name = facets[i]
- var ref = facetConfig[name];
- if (!ref) {
- alert("bad facet configuration: '" + name + "'");
- } else {
- acc.push('');
- acc.push('
');
- }
- }
- $(that.node).html(acc.join(''));
+ that.toString = function() {
+ return '[Widget ' + that.team.name() + ':' + that.type + '(' + name + ')]';
+ };
+ that.team.queue("termlists").subscribe(function(data) {
+ data = data[name];
- for (var i = 0; i < facets.length; i++) {
- var name = facets[i]
- var ref = facetConfig[name];
- var caption = ref[0];
- if (!ref) {
- alert("bad facet configuration: '" + name + "'");
+ var teamName = that.team.name();
+ var acc = [];
+ acc.push('' + mkws.M(caption) + '
');
+ for (var i = 0; i < data.length && i < max; i++) {
+ acc.push('');
}
-
- function makeSingleFacet(caption, data, max, pzIndex) {
- var teamName = that.team.name();
-
- var acc = [];
- acc.push('' + M(caption) + '
');
- for (var i = 0; i < data.length && i < max; i++) {
- acc.push('');
- }
- return acc.join('');
- }
+ $(that.node).html(acc.join(''));
});
-
- widget.autosearch(that);
});