function resizePage() {
var list = ["mkwsSwitch", "mkwsLang"];
- var targetWidth = mkws.config.responsive_design_width;
- var parent = $(".mkwsTermlists").parent();
-
- if ($(window).width() <= targetWidth &&
- parent.hasClass("mkwsTermlist-Container-wide")) {
- log("changing from wide to narrow: " + $(window).width());
+ 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");
+ }
+
+ 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) {
$("." + list[i] + ".mkwsTeam_" + tname).hide();
}
}
- } else if ($(window).width() > targetWidth &&
- parent.hasClass("mkwsTermlist-Container-narrow")) {
- log("changing from narrow to wide: " + $(window).width());
+ } else if (mkws.width <= threshhold && width > threshhold) {
+ log("changing from narrow to wide: " + width);
$(".mkwsTermlist-Container-wide").show();
$(".mkwsTermlist-Container-narrow").hide();
for (var tname in mkws.teams) {
}
}
}
+
+ mkws.width = width;
};