From 462ef80604c5f016f8a70e3a87ecbc90f33cc5d9 Mon Sep 17 00:00:00 2001 From: Jason Skomorowski Date: Thu, 7 Aug 2014 14:24:43 -0400 Subject: [PATCH] Simple templates for Done, Search and Switch --- src/mkws-widget-main.js | 26 ++++++++++------------ src/mkws-widget-main.templates/Done.handlebars | 7 ++++++ src/mkws-widget-main.templates/Search.handlebars | 11 +++++++++ src/mkws-widget-main.templates/Switch.handlebars | 9 ++++++++ 4 files changed, 39 insertions(+), 14 deletions(-) create mode 100644 src/mkws-widget-main.templates/Done.handlebars create mode 100644 src/mkws-widget-main.templates/Search.handlebars create mode 100644 src/mkws-widget-main.templates/Switch.handlebars diff --git a/src/mkws-widget-main.js b/src/mkws-widget-main.js index 35cfb16..be2f588 100644 --- a/src/mkws-widget-main.js +++ b/src/mkws-widget-main.js @@ -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('\ -Records \ -| \ -Targets'); + 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('\ -
\ - \ - \ -
'); + 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 index 0000000..59a0b4f --- /dev/null +++ b/src/mkws-widget-main.templates/Done.handlebars @@ -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 index 0000000..5530013 --- /dev/null +++ b/src/mkws-widget-main.templates/Search.handlebars @@ -0,0 +1,11 @@ +{{! +Search form + +team - MKWS team +queryWidth - configured width for search box +}} +
+ + +
+ diff --git a/src/mkws-widget-main.templates/Switch.handlebars b/src/mkws-widget-main.templates/Switch.handlebars new file mode 100644 index 0000000..2b8e29c --- /dev/null +++ b/src/mkws-widget-main.templates/Switch.handlebars @@ -0,0 +1,9 @@ +{{! +Switch between record and target view + +recordClick - handler to switch to record view +targetClick - handler to switch to target view +}} +{{{mkws-translate "Records"}}} +| +{{{mkws-translate "Targets"}}} -- 1.7.10.4