X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmkws-team.js;h=f2db2de48aadeaac847a14b170eb29732f19055f;hb=b9ec634af85ea55b6241d4ffe1c23189a2840f26;hp=1b003e178434e6602af430a620e05971a9ce1326;hpb=c1e819f7760602c6638547dadcb371f512e3cd0c;p=mkws-moved-to-github.git diff --git a/src/mkws-team.js b/src/mkws-team.js index 1b003e1..f2db2de 100644 --- a/src/mkws-team.js +++ b/src/mkws-team.js @@ -393,13 +393,11 @@ function team($, teamName) { mkwsHtmlLang(); log("HTML search form"); - mkws.handleNodeWithTeam(findnode('.mkwsSearch'), function(tname) { - this.html('\ -
\ - \ - \ + findnode('.mkwsSearch').html('\ +\ + \ + \
'); - }); log("HTML records"); // If the team has a .mkwsResults, populate it in the usual @@ -456,7 +454,7 @@ function team($, teamName) { function mkwsSetLang() { - var lang = mkws.getParameterByName("lang") || mkws_config.lang; + var lang = getParameterByName("lang") || mkws_config.lang; if (!lang || !mkws.locale_lang[lang]) { mkws_config.lang = "" } else { @@ -577,7 +575,7 @@ function team($, teamName) { if (query.match(/^!param!/)) { var param = query.replace(/^!param!/, ''); - query = mkws.getParameterByName(param); + query = getParameterByName(param); log("obtained query '" + query + "' from param '" + param + "'"); if (!query) { alert("This page has a MasterKey widget that needs a query specified by the '" + param + "' parameter"); @@ -605,6 +603,16 @@ function team($, teamName) { } + // This function is taken from a StackOverflow answer + // http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript/901144#901144 + function getParameterByName(name) { + name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); + var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), + results = regex.exec(location.search); + return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); + } + + // Translation function. At present, this is properly a // global-level function (hence the assignment to mkws.M) but we // want to make it per-team so different teams can operate in @@ -658,7 +666,7 @@ function team($, teamName) { var source = node.html(); if (!source) { - source = mkws.defaultTemplate(name); + source = defaultTemplate(name); } template = Handlebars.compile(source); @@ -671,6 +679,87 @@ 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}}\ +'; + } + + 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/ //