From 139d7f620e0fb02a7cb1136d3d9e7250bf4a30a5 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Tue, 10 Jun 2014 13:37:17 +0100 Subject: [PATCH] Radically simplify and generalise generation of facet HTML. Preparation for moving the (much simpler) HTML-generation into a template. --- src/mkws-widget-termlists.js | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/mkws-widget-termlists.js b/src/mkws-widget-termlists.js index c0dd474..715eff2 100644 --- a/src/mkws-widget-termlists.js +++ b/src/mkws-widget-termlists.js @@ -41,27 +41,30 @@ mkws.registerWidgetType('Facet', function() { that.team.queue("termlists").subscribe(function(data) { data = data[name]; - - var teamName = that.team.name(); - var acc = []; var template = that.team.loadTemplate('facetTitle-' + caption, mkws.M(caption)) var title = template({ query: that.config.query }); - acc.push('
' + title + '
'); + var acc = []; + acc.push('
', title, '
'); + + var teamName = that.team.name(); for (var i = 0; i < data.length && i < max; i++) { - acc.push('
'); - acc.push('' + data[i].name + '' - + ' ' + data[i].freq + ''); - acc.push('
'); + + var action = ''; + if (fn) { + action = 'mkws.' + fn + '(\'' + teamName + '\', \'' + datum + '\', this.firstChild.nodeValue)'; + } + + acc.push('
', + '', data[i].name, '', + '', data[i].freq, '', + '
'); } that.node.html(acc.join('')); -- 1.7.10.4