From a5db5420d793ca8550f326036e6fa30c95189719 Mon Sep 17 00:00:00 2001 From: Jason Skomorowski Date: Mon, 11 Aug 2014 10:21:33 -0400 Subject: [PATCH] Template Navi widget --- src/mkws-widget-main.js | 23 +++++++++++++---------- src/mkws-widget-main.templates/Navi.handlebars | 13 +++++++++++++ 2 files changed, 26 insertions(+), 10 deletions(-) create mode 100644 src/mkws-widget-main.templates/Navi.handlebars 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}} + -- 1.7.10.4