From bceef3c33269bf49847672af0482f85cb14cecdb Mon Sep 17 00:00:00 2001 From: Jason Skomorowski Date: Thu, 15 May 2014 23:46:33 -0400 Subject: [PATCH] Only init if there are widgets MKWS-166 --- src/mkws-core.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/mkws-core.js b/src/mkws-core.js index 6eb53bd..c7c2863 100644 --- a/src/mkws-core.js +++ b/src/mkws-core.js @@ -429,7 +429,7 @@ mkws.pagerNext = function(tname) { function selectorForAllWidgets() { - if (mkws.config.scan_all_nodes) { + if (mkws.config && mkws.config.scan_all_nodes) { // This is the old version, which works by telling jQuery to // find every node that has a class beginning with "mkws". In // theory it should be slower than the class-based selector; but @@ -476,7 +476,8 @@ mkws.pagerNext = function(tname) { } - $(document).ready(function() { + function init(rootsel) { + if (!rootsel) var rootsel = ':root'; var saved_config; if (typeof mkws_config === 'undefined') { log("setting empty config"); @@ -541,7 +542,7 @@ mkws.pagerNext = function(tname) { } var then = $.now(); - makeWidgetsWithin(1, $(':root')); + makeWidgetsWithin(1, $(rootsel)); var now = $.now(); log("Walking MKWS nodes took " + (now-then) + " ms"); @@ -564,5 +565,9 @@ mkws.pagerNext = function(tname) { // raw pp2 runAutoSearches(); } + }; + $(document).ready(function() { + var widgetSelector = selectorForAllWidgets(); + if (widgetSelector && $(widgetSelector).length !== 0) init(); }); })(jQuery); -- 1.7.10.4