From 15c9f739698073ae375a4dc8822fa5b366351a33 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Tue, 29 Apr 2014 13:44:32 +0100 Subject: [PATCH] Move the defaultTemplate function, which was never team-specific, up into the MKWS global core --- src/mkws-core.js | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/mkws-team.js | 90 +----------------------------------------------------- 2 files changed, 90 insertions(+), 89 deletions(-) diff --git a/src/mkws-core.js b/src/mkws-core.js index e08958f..e0811ff 100644 --- a/src/mkws-core.js +++ b/src/mkws-core.js @@ -164,6 +164,95 @@ mkws.objectInheritingFrom = function(o) { } +mkws.defaultTemplate = function(name) { + if (name === 'Record') { + return '\ +\ + \ + \ + \ + \ + {{#if md-date}}\ + \ + \ + \ + \ + {{/if}}\ + {{#if md-author}}\ + \ + \ + \ + \ + {{/if}}\ + {{#if md-electronic-url}}\ + \ + \ + \ + \ + {{/if}}\ + {{#if-any location having="md-subject"}}\ + \ + \ + \ + \ + {{/if-any}}\ + \ + \ + \ + \ +
{{translate "Title"}}\ + {{md-title}}\ + {{#if md-title-remainder}}\ + ({{md-title-remainder}})\ + {{/if}}\ + {{#if md-title-responsibility}}\ + {{md-title-responsibility}}\ + {{/if}}\ +
{{translate "Date"}}{{md-date}}
{{translate "Author"}}{{md-author}}
{{translate "Links"}}\ + {{#each md-electronic-url}}\ + Link{{index1}}\ + {{/each}}\ +
{{translate "Subject"}}\ + {{#first location having="md-subject"}}\ + {{#if md-subject}}\ + {{#commaList md-subject}}\ + {{this}}{{/commaList}}\ + {{/if}}\ + {{/first}}\ +
{{translate "Locations"}}\ + {{#commaList location}}\ + {{attr "@name"}}{{/commaList}}\ +
\ +'; + } else if (name === "Summary") { + return '\ +\ + {{md-title}}\ +\ +{{#if md-title-remainder}}\ + {{md-title-remainder}}\ +{{/if}}\ +{{#if md-title-responsibility}}\ + {{md-title-responsibility}}\ +{{/if}}\ +'; + } else if (name === "Image") { + return '\ + \ + {{#first md-thumburl}}\ + {{../md-title}}\ + {{/first}}\ +
\ +
\ +'; + } + + var s = "There is no default '" + name +"' template!"; + alert(s); + return s; +}; + + // The following functions are dispatchers for team methods that // are called from the UI using a team-name rather than implicit // context. diff --git a/src/mkws-team.js b/src/mkws-team.js index 81877bc..759a1a7 100644 --- a/src/mkws-team.js +++ b/src/mkws-team.js @@ -447,7 +447,7 @@ function team($, teamName) { source = m_tempateText[name]; } if (!source) { - source = defaultTemplate(name); + source = mkws.defaultTemplate(name); } template = Handlebars.compile(source); @@ -460,94 +460,6 @@ function team($, teamName) { that.loadTemplate = loadTemplate; - function defaultTemplate(name) { - if (name === 'Record') { - return '\ -\ - \ - \ - \ - \ - {{#if md-date}}\ - \ - \ - \ - \ - {{/if}}\ - {{#if md-author}}\ - \ - \ - \ - \ - {{/if}}\ - {{#if md-electronic-url}}\ - \ - \ - \ - \ - {{/if}}\ - {{#if-any location having="md-subject"}}\ - \ - \ - \ - \ - {{/if-any}}\ - \ - \ - \ - \ -
{{translate "Title"}}\ - {{md-title}}\ - {{#if md-title-remainder}}\ - ({{md-title-remainder}})\ - {{/if}}\ - {{#if md-title-responsibility}}\ - {{md-title-responsibility}}\ - {{/if}}\ -
{{translate "Date"}}{{md-date}}
{{translate "Author"}}{{md-author}}
{{translate "Links"}}\ - {{#each md-electronic-url}}\ - Link{{index1}}\ - {{/each}}\ -
{{translate "Subject"}}\ - {{#first location having="md-subject"}}\ - {{#if md-subject}}\ - {{#commaList md-subject}}\ - {{this}}{{/commaList}}\ - {{/if}}\ - {{/first}}\ -
{{translate "Locations"}}\ - {{#commaList location}}\ - {{attr "@name"}}{{/commaList}}\ -
\ -'; - } else if (name === "Summary") { - return '\ -\ - {{md-title}}\ -\ -{{#if md-title-remainder}}\ - {{md-title-remainder}}\ -{{/if}}\ -{{#if md-title-responsibility}}\ - {{md-title-responsibility}}\ -{{/if}}\ -'; - } else if (name === "Image") { - return '\ - \ - {{#first md-thumburl}}\ - {{../md-title}}\ - {{/first}}\ -
\ -
\ -'; - } - - var s = "There is no default '" + name +"' template!"; - alert(s); - return s; - } - that.addWidget = function(w) { if (!m_widgets[w.type]) { m_widgets[w.type] = w; -- 1.7.10.4