X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmkws-core.js;h=893951cbacc001adb4066f1dd9da5800a6015a6e;hb=86f25a52eba4a79b06c614fee9279ea583b1d549;hp=cc8c63f485737f220115a54ac93f8bf874c7ed90;hpb=28433f47f69eaf289b86d681c0ef72e38ba3042f;p=mkws-moved-to-github.git diff --git a/src/mkws-core.js b/src/mkws-core.js index cc8c63f..893951c 100644 --- a/src/mkws-core.js +++ b/src/mkws-core.js @@ -102,6 +102,16 @@ mkws.log = function(string) { }; +mkws.objectWithParent = function(parent) { + function thing() {} // Must be function so `prototype' works + + thing.prototype = parent; + var res = new thing(); + thing.prototype = null; + return res; +}; + + mkws.registerWidgetType = function(name, fn) { mkws.widgetType2function[name] = fn; mkws.log("registered widget-type '" + name + "'"); @@ -155,6 +165,46 @@ mkws.defaultMkwsConfig = function() { }; +// The following functions are dispatchers for team methods that +// are called from the UI using a team-name rather than implicit +// context. +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(); +}; + + // wrapper to call team() after page load (function(j) { var log = mkws.log; @@ -217,47 +267,6 @@ mkws.defaultMkwsConfig = function() { }; - // 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(); - }; - - /* * Run service-proxy authentication in background (after page load). * The username/password is configured in the apache config file @@ -311,11 +320,6 @@ mkws.defaultMkwsConfig = function() { $(document).ready(function() { mkws.defaultMkwsConfig(); - if (mkws_config.query_width < 5 || mkws_config.query_width > 150) { - log("Reset query width: " + mkws_config.query_width); - mkws_config.query_width = 50; - } - for (var key in mkws_config) { if (mkws_config.hasOwnProperty(key)) { if (key.match(/^language_/)) { @@ -327,12 +331,9 @@ mkws.defaultMkwsConfig = function() { } } - 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(resizePage); - // initial check after page load - $(document).ready(resizePage); + if (mkws_config.query_width < 5 || mkws_config.query_width > 150) { + log("Reset query width: " + mkws_config.query_width); + mkws_config.query_width = 50; } // protocol independent link for pazpar2: "//mkws/sp" -> "https://mkws/sp" @@ -341,6 +342,14 @@ mkws.defaultMkwsConfig = function() { log("adjust protocol independent links: " + mkws_config.pazpar2_url); } + 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(resizePage); + // initial check after page load + $(document).ready(resizePage); + } + // Backwards compatibility: set new magic class names on any // elements that have the old magic IDs. var ids = [ "Switch", "Lang", "Search", "Pager", "Navi",