Merge branch 'master' of ssh://git.indexdata.com/home/git/private/mkws
authorMike Taylor <mike@indexdata.com>
Tue, 10 Jun 2014 10:22:47 +0000 (11:22 +0100)
committerMike Taylor <mike@indexdata.com>
Tue, 10 Jun 2014 10:22:47 +0000 (11:22 +0100)
examples/htdocs/mike.html
src/mkws-team.js
src/mkws-widget-termlists.js

index b5afab9..27d7f1d 100644 (file)
     <div class="mkwsLang"></div>
     <div class="mkwsProgress"></div>
     <div class="mkwsSearch"></div>
-    <div class="mkwsResults" autosearch="!param!q" target="!param!t"></div>
+    <div class="mkwsResults" autosearch="!param!q"></div>
     <div class="mkwsTargets"></div>
     <div class="mkwsStat"></div>
     <div class="mkwsBuilder"></div>
   </body>
+  <script class="mkwsTemplate_facetTitle-Sources" type="text/x-handlebars-template">
+    <a href="?q={{query}}">Targets</a>
+  </script>
 </html>
index 25a24d6..02dc5ac 100644 (file)
@@ -386,7 +386,7 @@ function team($, teamName) {
   };
 
 
-  function loadTemplate(name) {
+  function loadTemplate(name, fallbackString) {
     var template = m_template[name];
 
     if (template === undefined) {
@@ -400,10 +400,16 @@ function team($, teamName) {
         source = node.html();
       }
 
+      // If the template is not defined in HTML, check the following
+      // in order: template registered in the team by a widget;
+      // fallback string provided on this invocation; global default.
       if (!source) {
         source = m_templateText[name];
       }
       if (!source) {
+        source = fallbackString;
+      }
+      if (!source) {
         source = mkws.defaultTemplate(name);
       }
 
index 1757b62..1f13820 100644 (file)
@@ -44,7 +44,9 @@ mkws.registerWidgetType('Facet', function() {
 
     var teamName = that.team.name();
     var acc = [];
-    acc.push('<div class="mkwsFacetTitle">' + mkws.M(caption) + '</div>');
+    var template = that.team.loadTemplate('facetTitle-' + caption, mkws.M(caption))
+    var title = template({ query: that.config.query });
+    acc.push('<div class="mkwsFacetTitle">' + title + '</div>');
     for (var i = 0; i < data.length && i < max; i++) {
       acc.push('<div class="mkwsTerm">');
       acc.push('<a href="#" ');