function resizePage() {
- var list = ["mkwsSwitch", "mkwsLang"];
+ var list = ["Switch", "Lang"];
- var targetWidth = mkws.config.responsive_design_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 <= 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");
+ 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 > targetWidth && width <= targetWidth) {
- 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 <= targetWidth && width > targetWidth) {
- 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));
+ var team = mkws.teams[tname];
+ team.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 = team.widget(list[i]);
+ if (widget) $(widget.node)[method]();
}
}
}
-
- mkws.width = width;
};
var now = $.now();
log("Walking MKWS nodes took " + (now-then) + " ms");
-// for (var tName in mkws.teams) {
-// var myTeam = mkws.teams[tName]
-// var types = myTeam.widgetTypes();
-// log("TEAM '" + tName + "' = " + myTeam + " has widget types " + types);
-// for (var i = 0; i < types.length; i++) {
-// var type = types[i];
-// log(" has widget of type '" + type + "': " + myTeam.widget(type));
-// }
-// }
+ /*
+ for (var tName in mkws.teams) {
+ var myTeam = mkws.teams[tName]
+ log("TEAM '" + tName + "' = " + myTeam + " ...");
+ myTeam.visitWidgets(function(t, w) {
+ log(" has widget of type '" + t + "': " + w);
+ });
+ }
+ */
if (mkws.config.use_service_proxy) {
authenticateSession(mkws.config.service_proxy_auth,