Template Navi widget
authorJason Skomorowski <jason@indexdata.com>
Mon, 11 Aug 2014 14:21:33 +0000 (10:21 -0400)
committerJason Skomorowski <jason@indexdata.com>
Mon, 11 Aug 2014 14:44:49 +0000 (10:44 -0400)
src/mkws-widget-main.js
src/mkws-widget-main.templates/Navi.handlebars [new file with mode: 0644]

index ffe00d6..9930775 100644 (file)
@@ -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') + ': <a class="mkwsRemovable" href="#" onclick="mkws.delimitTarget(\'' + teamName +
-        "', '" + id + "'" + ');return false;">' + name + '</a>';
+      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) + ': <a class="mkwsRemovable" href="#" onclick="mkws.delimitQuery(\'' + teamName +
-        "', '" + field + "', '" + value + "'" +
-        ');return false;">' + value + '</a>';
+      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 (file)
index 0000000..c3f9839
--- /dev/null
@@ -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}}} : <a class="mkwsRemovable" href="#" onclick="{{{click}}}">{{value}}</a>
+  {{#unless @last}}|{{/unless}}
+{{/each}}
+