}
- // 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
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");