X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmkws-core.js;h=ff619bd2139f1d302cdd3b3fc12da912aeacee5b;hb=950eab978b2dea68dc7cf12947d3519c88373305;hp=0e65f27bdaca5b3c70a01d34c25829884a4766b0;hpb=ff74c45c811734751b090f858b35fae17d729ce6;p=mkws-moved-to-github.git diff --git a/src/mkws-core.js b/src/mkws-core.js index 0e65f27..ff619bd 100644 --- a/src/mkws-core.js +++ b/src/mkws-core.js @@ -332,42 +332,31 @@ mkws.pagerNext = function(tname) { function resizePage() { var list = ["mkwsSwitch", "mkwsLang"]; - var targetWidth = mkws.config.responsive_design_width; + var threshhold = mkws.config.responsive_design_width; var width = $(window).width(); + var from, to, method; if (mkws.width === undefined) { // No state change, since we have no previous state - } else if (mkws.width > targetWidth && width <= targetWidth) { - log("wide -> narrow"); - } else if (mkws.width <= targetWidth && width > targetWidth) { - log("narrow -> wide"); + } else if (mkws.width > threshhold && width <= threshhold) { + from = "wide"; to = "narrow"; method = "hide"; + } else if (mkws.width <= threshhold && width > threshhold) { + from = "narrow"; to = "wide"; method = "show"; } + mkws.width = width; - if (mkws.width > targetWidth && width <= targetWidth) { - log("changing from wide to narrow: " + width); - $(".mkwsTermlist-Container-wide").hide(); - $(".mkwsTermlist-Container-narrow").show(); + if (from) { + log("changing from " + from + " to " + to + ": " + width); + $(".mkwsTermlist-Container-" + from).hide(); + $(".mkwsTermlist-Container-" + to).show(); for (var tname in mkws.teams) { - mkws.teams[tname].queue("resize-narrow").publish(); - $(".mkwsTermlists.mkwsTeam_" + tname).appendTo($(".mkwsTermlist-Container-narrow.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).hide(); - } - } - } else if (mkws.width <= targetWidth && width > targetWidth) { - log("changing from narrow to wide: " + width); - $(".mkwsTermlist-Container-wide").show(); - $(".mkwsTermlist-Container-narrow").hide(); - for (var tname in mkws.teams) { - 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(); + $("." + list[i] + ".mkwsTeam_" + tname)[method](); } } } - - mkws.width = width; };