X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmkws-core.js;h=32e09f86ca89ee84d24659ea742de8e96d90c605;hb=40ad17b3ee7bd3df56853b9b58196d017fd1d631;hp=0bfc174472329b0f097dc8040f87ae9daca12bed;hpb=96ff13c77214b76cb54dbaa6b9fae081a856738f;p=mkws-moved-to-github.git diff --git a/src/mkws-core.js b/src/mkws-core.js index 0bfc174..32e09f8 100644 --- a/src/mkws-core.js +++ b/src/mkws-core.js @@ -88,7 +88,8 @@ mkws.log = function(string) { // you need to disable use strict at the top of the file!!! if (mkws.log_level >= 3) { - console.log(arguments.callee.caller); + // Works in Chrome; not sure about elsewhere + console.trace(); } else if (mkws.log_level >= 2) { console.log(">>> called from function " + arguments.callee.caller.name + ' <<<'); } @@ -163,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. @@ -240,31 +330,31 @@ mkws.pagerNext = function(tname) { function resizePage() { - var list = ["mkwsSwitch", "mkwsLang"]; - - var width = mkws.config.responsive_design_width; - var parent = $(".mkwsTermlists").parent(); - - if ($(window).width() <= width && - parent.hasClass("mkwsTermlistContainer1")) { - log("changing from wide to narrow: " + $(window).width()); - $(".mkwsTermlistContainer1").hide(); - $(".mkwsTermlistContainer2").show(); - for (var tname in mkws.teams) { - $(".mkwsTermlists.mkwsTeam_" + tname).appendTo($(".mkwsTermlistContainer2.mkwsTeam_" + tname)); - for(var i = 0; i < list.length; i++) { - $("." + list[i] + ".mkwsTeam_" + tname).hide(); - } - } - } else if ($(window).width() > width && - parent.hasClass("mkwsTermlistContainer2")) { - log("changing from narrow to wide: " + $(window).width()); - $(".mkwsTermlistContainer1").show(); - $(".mkwsTermlistContainer2").hide(); + var list = ["Switch", "Lang"]; + + var threshhold = mkws.config.responsive_design_width; + var width = $(window).width(); + var from, to, method; + + if ((mkws.width === undefined || mkws.width > threshhold) && + width <= threshhold) { + from = "wide"; to = "narrow"; method = "hide"; + } else if ((mkws.width === undefined || mkws.width <= threshhold) && + width > threshhold) { + from = "narrow"; to = "wide"; method = "show"; + } + mkws.width = width; + + if (from) { + log("changing from " + from + " to " + to + ": " + width); + $(".mkwsTermlist-Container-" + from).hide(); + $(".mkwsTermlist-Container-" + to).show(); for (var tname in mkws.teams) { - $(".mkwsTermlists.mkwsTeam_" + tname).appendTo($(".mkwsTermlistContainer1.mkwsTeam_" + tname)); + mkws.teams[tname].queue("resize" + to).publish(); + $(".mkwsTermlists.mkwsTeam_" + tname).appendTo($(".mkwsTermlist-Container-" + to + ".mkwsTeam_" + tname)); for(var i = 0; i < list.length; i++) { - $("." + list[i] + ".mkwsTeam_" + tname).show(); + var widget = mkws.teams[tname].widget(list[i]); + if (widget) $(widget.node)[method](); } } }