- function resizePage() {
- var list = ["mkwsSwitch", "mkwsLang"];
-
- var width = mkws_config.responsive_design_width;
- var parent = $(".mkwsTermlists").parent();
-
- if ($(window).width() <= width &&
- parent.hasClass("mkwsTermlistContainer1")) {
- log("changing from wide to narrow: " + $(window).width());
- $(".mkwsTermlistContainer1").hide();
- $(".mkwsTermlistContainer2").show();
- for (var tname in mkws.teams) {
- $(".mkwsTermlists.mkwsTeam_" + tname).appendTo($(".mkwsTermlistContainer2.mkwsTeam_" + tname));
- for(var i = 0; i < list.length; i++) {
- $("." + list[i] + ".mkwsTeam_" + tname).hide();
- }
- }
- } else if ($(window).width() > width &&
- parent.hasClass("mkwsTermlistContainer2")) {
- log("changing from narrow to wide: " + $(window).width());
- $(".mkwsTermlistContainer1").show();
- $(".mkwsTermlistContainer2").hide();
- for (var tname in mkws.teams) {
- $(".mkwsTermlists.mkwsTeam_" + tname).appendTo($(".mkwsTermlistContainer1.mkwsTeam_" + tname));
- for(var i = 0; i < list.length; i++) {
- $("." + list[i] + ".mkwsTeam_" + tname).show();
- }
- }
- }
- };
-
-
- // 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);
- };
-
- mkws.showDetails = function(tname, prefixRecId) {
- mkws.teams[tname].showDetails(prefixRecId);
- };
-
- mkws.limitTarget = function(tname, id, name) {
- mkws.teams[tname].limitTarget(id, name);
- };
-
- mkws.limitQuery = function(tname, field, value) {
- mkws.teams[tname].limitQuery(field, value);
- };
-
- mkws.delimitTarget = function(tname, id) {
- mkws.teams[tname].delimitTarget(id);
- };
-
- mkws.delimitQuery = function(tname, field, value) {
- mkws.teams[tname].delimitQuery(field, value);
- };
-
- mkws.showPage = function(tname, pageNum) {
- mkws.teams[tname].showPage(pageNum);
- };
-
- mkws.pagerPrev = function(tname) {
- mkws.teams[tname].pagerPrev();
- };
-
- mkws.pagerNext = function(tname) {
- mkws.teams[tname].pagerNext();
- };
-
-
- function defaultMkwsConfig() {
- /* default mkws config */
- var config_default = {
- use_service_proxy: true,
- pazpar2_url: "//mkws.indexdata.com/service-proxy/",
- service_proxy_auth: "//mkws.indexdata.com/service-proxy-auth",
- lang: "",
- sort_options: [["relevance"], ["title:1", "title"], ["date:0", "newest"], ["date:1", "oldest"]],
- perpage_options: [10, 20, 30, 50],
- sort_default: "relevance",
- perpage_default: 20,
- query_width: 50,
- show_lang: true, /* show/hide language menu */
- show_sort: true, /* show/hide sort menu */
- show_perpage: true, /* show/hide perpage menu */
- lang_options: [], /* display languages links for given languages, [] for all */
- facets: ["xtargets", "subject", "author"], /* display facets, in this order, [] for none */
- responsive_design_width: undefined, /* a page with less pixel width considered as narrow */
- log_level: 1, /* log level for development: 0..2 */
-
- dummy: "dummy"
- };
-
- // Set global log_level flag early so that log() works
- // Fall back to old "debug_level" setting for backwards compatibility
- var tmp = mkws_config.log_level;
- if (typeof(tmp) === 'undefined') tmp = mkws_config.debug_level;
-
- if (typeof(tmp) !== 'undefined') {
- mkws.log_level = tmp;
- } else if (typeof(config_default.log_level) !== 'undefined') {
- mkws.log_level = config_default.log_level;
- }
-
- // make sure the mkws_config is a valid hash
- if (!$.isPlainObject(mkws_config)) {
- log("ERROR: mkws_config is not an JS object, ignore it....");
- mkws_config = {};
- }
-
- /* override standard config values by function parameters */
- for (var k in config_default) {
- if (typeof mkws_config[k] === 'undefined')
- mkws_config[k] = config_default[k];
- //log("Set config: " + k + ' => ' + mkws_config[k]);
- }
+mkws.pagerPrev = function(tname) {
+ mkws.teams[tname].pagerPrev();
+};
+
+mkws.pagerNext = function(tname) {
+ mkws.teams[tname].pagerNext();
+};
+
+
+// wrapper to provide local copy of the jQuery object.
+(function($) {
+ var log = mkws.log;
+
+ function handleNodeWithTeam(node, callback) {
+ // First branch for DOM objects; second branch for jQuery objects
+ var classes = node.className || node.attr('class');
+ if (!classes) {
+ // For some reason, if we try to proceed when classes is
+ // undefined, we don't get an error message, but this
+ // function and its callers, up several stack level,
+ // silently return. What a crock.
+ log("handleNodeWithTeam() called on node with no classes");
+ return;
+ }
+ var list = classes.split(/\s+/)
+ var teamName, type;
+
+ for (var i = 0; i < list.length; i++) {
+ var cname = list[i];
+ if (cname.match(/^mkwsTeam_/)) {
+ teamName = cname.replace(/^mkwsTeam_/, '');
+ } else if (cname.match(/^mkws/)) {
+ type = cname.replace(/^mkws/, '');
+ }