Add mkws.objectWithParent function -- not yet used.
[mkws-moved-to-github.git] / src / mkws-core.js
index e0d4e2f..893951c 100644 (file)
@@ -102,6 +102,16 @@ mkws.log = function(string) {
 };
 
 
+mkws.objectWithParent = function(parent) {
+    function thing() {} // Must be function so `prototype' works
+
+    thing.prototype = parent;
+    var res = new thing();
+    thing.prototype = null;
+    return res;
+};
+
+
 mkws.registerWidgetType = function(name, fn) {
     mkws.widgetType2function[name] = fn;
     mkws.log("registered widget-type '" + name + "'");
@@ -310,11 +320,6 @@ mkws.pagerNext = function(tname) {
     $(document).ready(function() {
        mkws.defaultMkwsConfig();
 
-       if (mkws_config.query_width < 5 || mkws_config.query_width > 150) {
-           log("Reset query width: " + mkws_config.query_width);
-           mkws_config.query_width = 50;
-       }
-
        for (var key in mkws_config) {
            if (mkws_config.hasOwnProperty(key)) {
                if (key.match(/^language_/)) {
@@ -326,12 +331,9 @@ mkws.pagerNext = function(tname) {
            }
        }
 
-       if (mkws_config.responsive_design_width) {
-           // Responsive web design - change layout on the fly based on
-           // current screen width. Required for mobile devices.
-           $(window).resize(resizePage);
-           // initial check after page load
-           $(document).ready(resizePage);
+       if (mkws_config.query_width < 5 || mkws_config.query_width > 150) {
+           log("Reset query width: " + mkws_config.query_width);
+           mkws_config.query_width = 50;
        }
 
        // protocol independent link for pazpar2: "//mkws/sp" -> "https://mkws/sp"
@@ -340,6 +342,14 @@ mkws.pagerNext = function(tname) {
            log("adjust protocol independent links: " + mkws_config.pazpar2_url);
        }
 
+       if (mkws_config.responsive_design_width) {
+           // Responsive web design - change layout on the fly based on
+           // current screen width. Required for mobile devices.
+           $(window).resize(resizePage);
+           // initial check after page load
+           $(document).ready(resizePage);
+       }
+
        // Backwards compatibility: set new magic class names on any
        // elements that have the old magic IDs.
        var ids = [ "Switch", "Lang", "Search", "Pager", "Navi",