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 list = ["Switch", "Lang"];
+
+ var threshhold = mkws.config.responsive_design_width;
+ var width = $(window).width();
+ 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 (from) {
+ log("changing from " + from + " to " + to + ": " + width);
for (var tname in mkws.teams) {
- $(".mkwsTermlists.mkwsTeam_" + tname).appendTo($(".mkwsTermlistContainer2.mkwsTeam_" + tname));
+ var team = mkws.teams[tname];
+ team.visitWidgets(function (t, w) {
+ var w1 = team.widget(t + "-Container-" + from);
+ var w2 = team.widget(t + "-Container-" + to);
+ if (w1) $(w1.node).hide();
+ if (w2) $(w2.node).show();
+ });
+ 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).hide();
- }
- }
- } else if ($(window).width() > width &&
- parent.hasClass("mkwsTermlistContainer2")) {
- log("changing from narrow to wide: " + $(window).width());
- $(".mkwsTermlistContainer1").show();
- $(".mkwsTermlistContainer2").hide();
- for (var tname in mkws.teams) {
- $(".mkwsTermlists.mkwsTeam_" + tname).appendTo($(".mkwsTermlistContainer1.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]();
}
}
}
myTeam.addWidget(myWidget);
var newHTML = this.innerHTML;
if (newHTML !== oldHTML) {
- log("widget " + tname + ":" + type + " HTML changed from '" + oldHTML + "' to '" + newHTML + "': reparse!");
+ log("widget " + tname + ":" + type + " HTML changed: reparsing");
makeWidgetsWithin(level+1, $(this));
}
});
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,