X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmkws-core.js;h=61cccdc213f89f9f7b7a306f038727753d71ad06;hb=767950c8211a1d7cef01c32775b099e26149633d;hp=09ae8aab47fd4acb0d3ba9e537cb119b0ed33804;hpb=3cde1d6b387b34e60fb00dc0e5a85d2152a85cda;p=mkws-moved-to-github.git diff --git a/src/mkws-core.js b/src/mkws-core.js index 09ae8aa..61cccdc 100644 --- a/src/mkws-core.js +++ b/src/mkws-core.js @@ -84,7 +84,7 @@ if (mkws_config == null || typeof mkws_config != 'object') { // wrapper to call team() after page load (function (j) { - mkws.log = function (string) { + function log(string) { if (!mkws.log_level) return; @@ -100,10 +100,10 @@ if (mkws_config == null || typeof mkws_config != 'object') { } console.log(string); } - var log = mkws.log; + mkws.log = log; - mkws.handleNodeWithTeam = function(node, callback) { + function handleNodeWithTeam(node, callback) { // First branch for DOM objects; second branch for jQuery objects var classes = node.className || node.attr('class'); if (!classes) { @@ -129,7 +129,7 @@ if (mkws_config == null || typeof mkws_config != 'object') { } - mkws.resizePage = function () { + function resizePage() { var list = ["mkwsSwitch", "mkwsLang"]; var width = mkws_config.responsive_design_width; @@ -161,6 +161,10 @@ if (mkws_config == null || typeof mkws_config != 'object') { }; + // The following functions are dispatchers for team methods that + // are called from the UI using a team-name rather than implicit + // context. Apart from mkws.log, they are the ONLY public UI to + // this module. mkws.switchView = function(tname, view) { mkws.teams[tname].switchView(view); } @@ -272,7 +276,7 @@ if (mkws_config == null || typeof mkws_config != 'object') { } var status = $(data).find("status"); if (status.text() != "OK") { - alert("service proxy auth repsonse status: " + status.text() + ", give up!"); + alert("service proxy auth response status: " + status.text() + ", give up!"); return; } @@ -293,7 +297,6 @@ if (mkws_config == null || typeof mkws_config != 'object') { $(document).ready(function() { - log("on load ready"); defaultMkwsConfig(); if (mkws_config.query_width < 5 || mkws_config.query_width > 150) { @@ -315,9 +318,9 @@ if (mkws_config == null || typeof mkws_config != 'object') { if (mkws_config.responsive_design_width) { // Responsive web design - change layout on the fly based on // current screen width. Required for mobile devices. - $(window).resize(function(e) { mkws.resizePage() }); + $(window).resize(resizePage); // initial check after page load - $(document).ready(function() { mkws.resizePage() }); + $(document).ready(resizePage); } // protocol independent link for pazpar2: "//mkws/sp" -> "https://mkws/sp" @@ -353,7 +356,7 @@ if (mkws_config == null || typeof mkws_config != 'object') { // the mkwsTeam_* class. Make all team objects. var then = $.now(); $('[class^="mkws"],[class*=" mkws"]').each(function () { - mkws.handleNodeWithTeam(this, function(tname, type) { + handleNodeWithTeam(this, function(tname, type) { if (!mkws.teams[tname]) { mkws.teams[tname] = team(j, tname); log("Made MKWS team '" + tname + "'"); @@ -365,7 +368,7 @@ if (mkws_config == null || typeof mkws_config != 'object') { // that sometimes makes new widget nodes (e.g. creating // mkwsTermlists inside mkwsResults. $('[class^="mkws"],[class*=" mkws"]').each(function () { - mkws.handleNodeWithTeam(this, function(tname, type) { + handleNodeWithTeam(this, function(tname, type) { var myTeam = mkws.teams[tname]; var myWidget = widget(j, myTeam, type, this); });