}
}
- if (!teamName) teamName = "AUTO";
+ // Widgets without a team are on team "AUTO"
+ if (!teamName) {
+ teamName = "AUTO";
+ // Autosearch widgets don't join team AUTO if there is already an
+ // autosearch on the team or the team has otherwise gotten a query
+ if (node.hasAttribute("autosearch")) {
+ if (mkws.autoHasAuto ||
+ mkws.teams["AUTO"] && mkws.teams["AUTO"].config["query"]) {
+ log("AUTO team already has a query, using unique team");
+ teamName = "UNIQUE";
+ }
+ mkws.autoHasAuto = true;
+ }
+ }
+
+ // Widgets on team "UNIQUE" get a random team
+ if (teamName === "UNIQUE") {
+ teamName = Math.floor(Math.random() * 100000000).toString();
+ }
+
callback.call(node, teamName, type);
}
function init(rootsel) {
+ mkws.autoHasAuto = false;
if (!rootsel) var rootsel = ':root';
var saved_config;
if (typeof mkws_config === 'undefined') {
}
*/
- if (mkws.config.use_service_proxy) {
+ if (mkws.config.use_service_proxy && !mkws.authenticated) {
authenticateSession(mkws.config.service_proxy_auth,
mkws.config.service_proxy_auth_domain,
mkws.config.pazpar2_url);
runAutoSearches();
}
};
- $(document).ready(function() {
+
+ // callback for calls after page load, e.g. requirejs
+ mkws.init_widgets = function (message) {
+ if (message) mkws.log(message);
+
var widgetSelector = selectorForAllWidgets();
- if (widgetSelector && $(widgetSelector).length !== 0) init();
+ if (widgetSelector && $(widgetSelector).length !== 0) {
+ init();
+ } else {
+ mkws.log("no widgets found");
+ }
+ };
+
+ $(document).ready(function() {
+ mkws.init_widgets();
});
+
})(mkws.$);