X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmkws-team.js;h=935bcaa24c1c8d9695e5db9573a6f0eb15e84a97;hb=1e59ea3b6c29afeaf938fdb47729d2ec5f2cf7fc;hp=81877bca0a08c574f9eae09e89a797fc60bd49ad;hpb=349e19d948afcea4dd0b35c693a0f15a8d00d757;p=mkws-moved-to-github.git diff --git a/src/mkws-team.js b/src/mkws-team.js index 81877bc..935bcaa 100644 --- a/src/mkws-team.js +++ b/src/mkws-team.js @@ -29,7 +29,7 @@ function team($, teamName) { var m_tempateText = {}; // widgets can register tempates to be compiled var m_template = {}; // compiled templates, from any source var m_config = mkws.objectInheritingFrom(mkws.config); - var m_widgets = {}; // Maps widget-type to object + var m_widgets = {}; // Maps widget-type to array of widget objects that.toString = function() { return '[Team ' + teamName + ']'; }; @@ -314,13 +314,6 @@ function team($, teamName) { if (blanket) blanket.css('display', 'block'); if (motd) motd.css('display', 'none'); break; - case 'none': - alert("mkws.switchView(" + m_teamName + ", 'none') shouldn't happen"); - if (targets) targets.css('display', 'none'); - if (results) results.css('display', 'none'); - if (blanket) blanket.css('display', 'none'); - if (motd) motd.css('display', 'none'); - break; default: alert("Unknown view '" + view + "'"); } @@ -348,46 +341,21 @@ function team($, teamName) { }; - /* - * All the HTML stuff to render the search forms and - * result pages. - */ - function mkwsHtmlAll() { - var container = findnode(".mkwsMOTDContainer"); - if (container.length) { - // Move the MOTD from the provided element down into the container - findnode(".mkwsMOTD").appendTo(container); - } - } - - - function mkwsSetLang() { - var lang = mkws.getParameterByName("lang") || m_config.lang; - if (!lang || !mkws.locale_lang[lang]) { - m_config.lang = "" - } else { - m_config.lang = lang; - } - - log("Locale language: " + (m_config.lang ? m_config.lang : "none")); - return m_config.lang; - } - - // 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 // different languages. // - function M(word) { - var lang = m_config.lang; + mkws.M = function (word) { + var lang = mkws.config.lang; + log("in M('" + word + "'), lang=" + lang); if (!lang || !mkws.locale_lang[lang]) return word; return mkws.locale_lang[lang][word] || word; - } - mkws.M = M; // so the Handlebars helper can use it + }; + var M = mkws.M; // Finds the node of the specified class within the current team @@ -405,11 +373,8 @@ function team($, teamName) { //log('findnode(' + selector + ') found ' + node.length + ' nodes'); return node; } - that.findnode = findnode; - // This much simpler and more efficient function should be usable - // in place of most uses of findnode. function widgetNode(type) { var w = that.widget(type); return w ? $(w.node) : undefined; @@ -447,7 +412,7 @@ function team($, teamName) { source = m_tempateText[name]; } if (!source) { - source = defaultTemplate(name); + source = mkws.defaultTemplate(name); } template = Handlebars.compile(source); @@ -460,119 +425,49 @@ function team($, teamName) { that.loadTemplate = loadTemplate; - function defaultTemplate(name) { - if (name === 'Record') { - return '\ -
{{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}}\ - | \ -