From: Jason Skomorowski Date: Mon, 11 Aug 2014 14:21:33 +0000 (-0400) Subject: Template Navi widget X-Git-Tag: 1.0.0~324^2~36 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=a5db5420d793ca8550f326036e6fa30c95189719;p=mkws-moved-to-github.git Template Navi widget --- diff --git a/src/mkws-widget-main.js b/src/mkws-widget-main.js index ffe00d6..9930775 100644 --- a/src/mkws-widget-main.js +++ b/src/mkws-widget-main.js @@ -121,26 +121,29 @@ mkws.registerWidgetType('Records', function() { mkws.registerWidgetType('Navi', function() { var that = this; var teamName = this.team.name(); - var M = mkws.M; this.team.queue("navi").subscribe(function() { var filters = that.team.filters(); - var text = ""; + var output = {filters:[]}; filters.visitTargets(function(id, name) { - if (text) text += " | "; - text += M('source') + ': ' + name + ''; + var cur = {}; + cur.facet = 'source'; + cur.value = name; + cur.click = "mkws.delimitTarget('" + teamName + "', '" + id + "'); return false;"; + output.filters.push(cur); }); filters.visitFields(function(field, value) { - if (text) text += " | "; - text += M(field) + ': ' + value + ''; + var cur = {}; + cur.facet = field; + cur.value = value; + cur.click = "mkws.delimitQuery('" + teamName + "', '" + field + "', '" + value + "'" + ");return false;"; + output.filters.push(cur); }); - that.node.html(text); + var template = that.team.loadTemplate(that.config.template || "Navi"); + that.node.html(template(output)); }); }); diff --git a/src/mkws-widget-main.templates/Navi.handlebars b/src/mkws-widget-main.templates/Navi.handlebars new file mode 100644 index 0000000..c3f9839 --- /dev/null +++ b/src/mkws-widget-main.templates/Navi.handlebars @@ -0,0 +1,13 @@ +{{! +Facet breadcrumbs -- filters on the current search + +filters + facet - name of facet being limited + value - limit to this value + click - handler script to remove limit +}} +{{#each filters}} + {{{mkws-translate facet}}} : {{value}} + {{#unless @last}}|{{/unless}} +{{/each}} +