X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmkws-core.js;h=32e09f86ca89ee84d24659ea742de8e96d90c605;hb=40ad17b3ee7bd3df56853b9b58196d017fd1d631;hp=ab536f5cb1d1eb9db17b2834291f054e921ecbae;hpb=9f2178ead299b1804c59b32773e3a7902da673fa;p=mkws-moved-to-github.git diff --git a/src/mkws-core.js b/src/mkws-core.js index ab536f5..32e09f8 100644 --- a/src/mkws-core.js +++ b/src/mkws-core.js @@ -330,44 +330,34 @@ mkws.pagerNext = function(tname) { function resizePage() { - var list = ["mkwsSwitch", "mkwsLang"]; + var list = ["Switch", "Lang"]; var threshhold = 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 > threshhold && width <= threshhold) { - log("wide -> narrow"); - } else if (mkws.width <= threshhold && width > threshhold) { - log("narrow -> wide"); + 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 (mkws.width > threshhold && width <= threshhold) { - log("changing from wide to narrow: " + width); - $(".mkwsTermlist-Container-wide").hide(); - $(".mkwsTermlist-Container-narrow").show(); - for (var tname in mkws.teams) { - 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 (mkws.width <= threshhold && width > threshhold) { - log("changing from narrow to wide: " + width); - $(".mkwsTermlist-Container-wide").show(); - $(".mkwsTermlist-Container-narrow").hide(); + 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-wide").publish(); - $(".mkwsTermlists.mkwsTeam_" + tname).appendTo($(".mkwsTermlist-Container-wide.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](); } } } - - mkws.width = width; };