X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmkws-core.js;h=8d19f3a0d133a010e6c50f5fcfabe0d754ef5861;hb=383378d6a66b3b00bb540e2c1738d18d470b557e;hp=0bfc174472329b0f097dc8040f87ae9daca12bed;hpb=96ff13c77214b76cb54dbaa6b9fae081a856738f;p=mkws-moved-to-github.git diff --git a/src/mkws-core.js b/src/mkws-core.js index 0bfc174..8d19f3a 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. @@ -242,27 +332,43 @@ 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(); + var targetWidth = mkws.config.responsive_design_width; + var width = $(window).width(); + + if (mkws.width === undefined) { + // No state change, since we have no previous state + } else if (mkws.width <= targetWidth && width > targetWidth) { + log("narrow -> wide"); + } else if (mkws.width > targetWidth && width <= targetWidth) { + log("wide -> narrow"); + } else if (width > targetWidth) { + log("already wide"); + } else { + log("already narrow"); + } + mkws.width = width; + + if (width <= targetWidth && + parent.hasClass("mkwsTermlist-Container-wide")) { + log("changing from wide to narrow: " + width); + $(".mkwsTermlist-Container-wide").hide(); + $(".mkwsTermlist-Container-narrow").show(); for (var tname in mkws.teams) { - $(".mkwsTermlists.mkwsTeam_" + tname).appendTo($(".mkwsTermlistContainer2.mkwsTeam_" + tname)); + mkws.teams[tname].queue("resize-narrow").publish(); + $(".mkwsTermlists.mkwsTeam_" + tname).appendTo($(".mkwsTermlist-Container-narrow.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(); + } else if (width > targetWidth && + parent.hasClass("mkwsTermlist-Container-narrow")) { + log("changing from narrow to wide: " + width); + $(".mkwsTermlist-Container-wide").show(); + $(".mkwsTermlist-Container-narrow").hide(); for (var tname in mkws.teams) { - $(".mkwsTermlists.mkwsTeam_" + tname).appendTo($(".mkwsTermlistContainer1.mkwsTeam_" + tname)); + mkws.teams[tname].queue("resize-wide").publish(); + $(".mkwsTermlists.mkwsTeam_" + tname).appendTo($(".mkwsTermlist-Container-wide.mkwsTeam_" + tname)); for(var i = 0; i < list.length; i++) { $("." + list[i] + ".mkwsTeam_" + tname).show(); }