Move mkws.defaultTemplate() out of the team structure.
authorMike Taylor <mike@indexdata.com>
Wed, 5 Mar 2014 09:33:38 +0000 (09:33 +0000)
committerMike Taylor <mike@indexdata.com>
Wed, 5 Mar 2014 09:33:38 +0000 (09:33 +0000)
Fixes part of MKWS-126.

tools/htdocs/mkws.js

index 3a44f46..78f1e46 100644 (file)
@@ -1078,7 +1078,7 @@ function team($, teamName) {
 
            var source = node.html();
            if (!source) {
-               source = defaultTemplate(name);
+               source = mkws.defaultTemplate(name);
            }
 
            template = Handlebars.compile(source);
@@ -1090,87 +1090,6 @@ function team($, teamName) {
     }
 
 
-    function defaultTemplate(name)
-    {
-       if (name === 'Record') {
-           return '\
-<table>\
-  <tr>\
-    <th>{{translate "Title"}}</th>\
-    <td>\
-      {{md-title}}\
-      {{#if md-title-remainder}}\
-       ({{md-title-remainder}})\
-      {{/if}}\
-      {{#if md-title-responsibility}}\
-       <i>{{md-title-responsibility}}</i>\
-      {{/if}}\
-    </td>\
-  </tr>\
-  {{#if md-date}}\
-  <tr>\
-    <th>{{translate "Date"}}</th>\
-    <td>{{md-date}}</td>\
-  </tr>\
-  {{/if}}\
-  {{#if md-author}}\
-  <tr>\
-    <th>{{translate "Author"}}</th>\
-    <td>{{md-author}}</td>\
-  </tr>\
-  {{/if}}\
-  {{#if md-electronic-url}}\
-  <tr>\
-    <th>{{translate "Links"}}</th>\
-    <td>\
-      {{#each md-electronic-url}}\
-       <a href="{{this}}">Link{{index1}}</a>\
-      {{/each}}\
-    </td>\
-  </tr>\
-  {{/if}}\
-  {{#if-any location having="md-subject"}}\
-  <tr>\
-    <th>{{translate "Subject"}}</th>\
-    <td>\
-      {{#first location having="md-subject"}}\
-       {{#if md-subject}}\
-         {{#commaList md-subject}}\
-           {{this}}{{/commaList}}\
-       {{/if}}\
-      {{/first}}\
-    </td>\
-  </tr>\
-  {{/if-any}}\
-  <tr>\
-    <th>{{translate "Locations"}}</th>\
-    <td>\
-      {{#commaList location}}\
-       {{attr "@name"}}{{/commaList}}\
-    </td>\
-  </tr>\
-</table>\
-';
-       } else if (name === "Summary") {
-           return '\
-<a href="#" id="{{_id}}" onclick="{{_onclick}}">\
-  <b>{{md-title}}</b>\
-</a>\
-{{#if md-title-remainder}}\
-  <span>{{md-title-remainder}}</span>\
-{{/if}}\
-{{#if md-title-responsibility}}\
-  <span><i>{{md-title-responsibility}}</i></span>\
-{{/if}}\
-';
-       }
-
-       var s = "There is no default '" + name +"' template!";
-       alert(s);
-       return s;
-    }
-
-
     // The following PubSub code is modified from the jQuery manual:
     // https://api.jquery.com/jQuery.Callbacks/
     //
@@ -1328,6 +1247,87 @@ function team($, teamName) {
     }
 
 
+    mkws.defaultTemplate = function(name)
+    {
+       if (name === 'Record') {
+           return '\
+<table>\
+  <tr>\
+    <th>{{translate "Title"}}</th>\
+    <td>\
+      {{md-title}}\
+      {{#if md-title-remainder}}\
+       ({{md-title-remainder}})\
+      {{/if}}\
+      {{#if md-title-responsibility}}\
+       <i>{{md-title-responsibility}}</i>\
+      {{/if}}\
+    </td>\
+  </tr>\
+  {{#if md-date}}\
+  <tr>\
+    <th>{{translate "Date"}}</th>\
+    <td>{{md-date}}</td>\
+  </tr>\
+  {{/if}}\
+  {{#if md-author}}\
+  <tr>\
+    <th>{{translate "Author"}}</th>\
+    <td>{{md-author}}</td>\
+  </tr>\
+  {{/if}}\
+  {{#if md-electronic-url}}\
+  <tr>\
+    <th>{{translate "Links"}}</th>\
+    <td>\
+      {{#each md-electronic-url}}\
+       <a href="{{this}}">Link{{index1}}</a>\
+      {{/each}}\
+    </td>\
+  </tr>\
+  {{/if}}\
+  {{#if-any location having="md-subject"}}\
+  <tr>\
+    <th>{{translate "Subject"}}</th>\
+    <td>\
+      {{#first location having="md-subject"}}\
+       {{#if md-subject}}\
+         {{#commaList md-subject}}\
+           {{this}}{{/commaList}}\
+       {{/if}}\
+      {{/first}}\
+    </td>\
+  </tr>\
+  {{/if-any}}\
+  <tr>\
+    <th>{{translate "Locations"}}</th>\
+    <td>\
+      {{#commaList location}}\
+       {{attr "@name"}}{{/commaList}}\
+    </td>\
+  </tr>\
+</table>\
+';
+       } else if (name === "Summary") {
+           return '\
+<a href="#" id="{{_id}}" onclick="{{_onclick}}">\
+  <b>{{md-title}}</b>\
+</a>\
+{{#if md-title-remainder}}\
+  <span>{{md-title-remainder}}</span>\
+{{/if}}\
+{{#if md-title-responsibility}}\
+  <span><i>{{md-title-responsibility}}</i></span>\
+{{/if}}\
+';
+       }
+
+       var s = "There is no default '" + name +"' template!";
+       alert(s);
+       return s;
+    }
+
+
     function defaultMkwsConfig() {
        /* default mkws config */
        var config_default = {