Fix root selector for init and better document that function.
authorJason Skomorowski <jason@indexdata.com>
Tue, 19 Aug 2014 18:37:00 +0000 (14:37 -0400)
committerJason Skomorowski <jason@indexdata.com>
Tue, 19 Aug 2014 18:37:00 +0000 (14:37 -0400)
src/mkws-core.js

index 3031dd0..ddf34c9 100644 (file)
@@ -550,14 +550,23 @@ mkws.pagerNext = function(tname) {
   }
 
 
-  // This function should have no side effects if run again on an operating session, even if 
-  // the element/selector passed causes existing widgets to be reparsed: 
+  // The second "rootsel" parameter is passed to jQuery and is a DOM node
+  // or a selector string you would like to constrain the search for widgets to.
+  //
+  // This function has no side effects if run again on an operating session,
+  // even if the element/selector passed causes existing widgets to be reparsed: 
+  //
+  // (TODO: that last bit isn't true and we currently have to avoid reinitialising
+  // widgets, MKWS-261)
   //
   // * configuration is not regenerated
   // * authentication is not performed again
   // * autosearches are not re-run
   mkws.init = function(message, rootsel) {
-    if (message) mkws.log(message);
+    var greet = "MKWS initialised";
+    if (rootsel) greet += " (limited to " + rootsel + ")"
+    if (message) greet += " :: " + message; 
+    mkws.log(greet);
 
     // TODO: Let's remove this soon
     // Backwards compatibility: set new magic class names on any
@@ -638,7 +647,9 @@ mkws.pagerNext = function(tname) {
     var then = $.now();
     // If we've made no widgets, return without starting an SP session
     // or marking MKWS active.
-    if (makeWidgetsWithin(1, rootsel) === false) return false;
+    if (makeWidgetsWithin(1, rootsel ? $(rootsel) : undefined) === false) {
+      return false;
+    }
     var now = $.now();
 
     log("walking MKWS nodes took " + (now-then) + " ms");