Simple templates for Done, Search and Switch
authorJason Skomorowski <jason@indexdata.com>
Thu, 7 Aug 2014 18:24:43 +0000 (14:24 -0400)
committerJason Skomorowski <jason@indexdata.com>
Thu, 7 Aug 2014 18:24:43 +0000 (14:24 -0400)
src/mkws-widget-main.js
src/mkws-widget-main.templates/Done.handlebars [new file with mode: 0644]
src/mkws-widget-main.templates/Search.handlebars [new file with mode: 0644]
src/mkws-widget-main.templates/Switch.handlebars [new file with mode: 0644]

index 35cfb16..be2f588 100644 (file)
@@ -176,9 +176,9 @@ mkws.registerWidgetType('Perpage', function() {
 
 mkws.registerWidgetType('Done', function() {
   var that = this;
-
   this.team.queue("complete").subscribe(function(n) {
-    that.node.html("Search complete: found " + n + " records");
+    var template = that.team.loadTemplate(that.config.template || "Done");
+    that.node.html(template({count: n}));
   });
 });
 
@@ -186,23 +186,21 @@ mkws.registerWidgetType('Done', function() {
 mkws.registerWidgetType('Switch', function() {
   if (!this.config.show_switch) return;
   var tname = this.team.name();
-  this.node.html('\
-<a href="#" onclick="mkws.switchView(\'' + tname + '\', \'records\')">Records</a><span> \
-| \
-</span><a href="#" onclick="mkws.switchView(\'' + tname + '\', \'targets\')">Targets</a>');
+  var output = {};
+  output.recordClick = "mkws.switchView(\'" + tname + "\', \'records\')";
+  output.targetClick = "mkws.switchView(\'" + tname + "\', \'targets\')";
+  var template = this.team.loadTemplate(this.config.template || "Switch");
+  this.node.html(template(output));
   this.hideWhenNarrow();
 });
 
 
 mkws.registerWidgetType('Search', function() {
-  var tname = this.team.name();
-  var M = mkws.M;
-
-  this.node.html('\
-<form name="mkwsSearchForm" class="mkwsSearchForm mkwsTeam_' + tname + '" action="" >\
-  <input class="mkwsQuery mkwsTeam_' + tname + '" type="text" size="' + this.config.query_width + '" />\
-  <input class="mkwsButton mkwsTeam_' + tname + '" type="submit" value="' + M('Search') + '" />\
-</form>');
+  var output = {};
+  output.team = this.team.name();
+  output.queryWidth = this.config.query_width;
+  var template = this.team.loadTemplate(this.config.template || "Search");
+  this.node.html(template(output));
 });
 
 
diff --git a/src/mkws-widget-main.templates/Done.handlebars b/src/mkws-widget-main.templates/Done.handlebars
new file mode 100644 (file)
index 0000000..59a0b4f
--- /dev/null
@@ -0,0 +1,7 @@
+{{!
+Displayed on search completion
+
+count - number of results found
+}}
+{{{mkws-translate "Search complete: found"}}} {{count}} {{{mkws-translate "records"}}}
+
diff --git a/src/mkws-widget-main.templates/Search.handlebars b/src/mkws-widget-main.templates/Search.handlebars
new file mode 100644 (file)
index 0000000..5530013
--- /dev/null
@@ -0,0 +1,11 @@
+{{!
+Search form
+
+team - MKWS team
+queryWidth - configured width for search box
+}}
+<form name="mkwsSearchForm" class="mkwsSearchForm mkwsTeam_{{team}}" action="">
+  <input class="mkwsQuery mkwsTeam_{{team}}" type="text" size="{{queryWidth}}">
+  <input class="mkwsButton mkwsTeam_{{team}}" type="submit" value="{{{mkws-translate "Search"}}}">
+</form>
+
diff --git a/src/mkws-widget-main.templates/Switch.handlebars b/src/mkws-widget-main.templates/Switch.handlebars
new file mode 100644 (file)
index 0000000..2b8e29c
--- /dev/null
@@ -0,0 +1,9 @@
+{{!
+Switch between record and target view
+
+recordClick - handler to switch to record view
+targetClick - handler to switch to target view
+}}
+<a href="#" onclick="{{{recordClick}}}">{{{mkws-translate "Records"}}}</a>
+<span>|</span>
+<a href="#" onclick="{{{targetClick}}}">{{{mkws-translate "Targets"}}}</a>