From 19777b46905bc25b666eba4e37bacd76ffac91eb Mon Sep 17 00:00:00 2001 From: Jason Skomorowski Date: Tue, 19 Aug 2014 14:37:00 -0400 Subject: [PATCH] Fix root selector for init and better document that function. --- src/mkws-core.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/mkws-core.js b/src/mkws-core.js index 3031dd0..ddf34c9 100644 --- a/src/mkws-core.js +++ b/src/mkws-core.js @@ -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"); -- 1.7.10.4