From: Jason Skomorowski Date: Fri, 16 May 2014 05:00:11 +0000 (-0400) Subject: Merge branch 'master' of ssh://git.indexdata.com/home/git/private/mkws X-Git-Tag: 1.0.0~666 X-Git-Url: http://git.indexdata.com/?p=mkws-moved-to-github.git;a=commitdiff_plain;h=82b78674032447e08477c34258c999fea92cbadc;hp=3aa819ed8eaa4b37333a105c8e266c1e8e1ff2bb Merge branch 'master' of ssh://git.indexdata.com/home/git/private/mkws --- diff --git a/doc/README.markdown b/doc/README.markdown index 49d415d..667cf4f 100644 --- a/doc/README.markdown +++ b/doc/README.markdown @@ -75,6 +75,7 @@ possible options: show_lang: true, /* true, false: show/hide language menu */ show_sort: true, /* true, false: show/hide sort menu */ show_perpage: true, /* true, false: show/hide perpage menu */ + show_switch: true, /* true, false: show/hide switch menu */ lang_options: ["en", "de", "da"], /* display languages links for given languages, [] for all */ facets: ["xtargets", "subject", "author"], diff --git a/doc/whitepaper.markdown b/doc/whitepaper.markdown index 74a3234..55c56ec 100644 --- a/doc/whitepaper.markdown +++ b/doc/whitepaper.markdown @@ -394,6 +394,9 @@ show_perpage bool true Indicates whether or not to display show_sort bool true Indicates whether or not to display the sort menu. +show_switch bool true Indicates whether or not to display the switch menu, for switching between showing + retrieved records and target information. + sort_default string relevance The label of the default sort criterion to use. Must be one of those in the `sort` array. @@ -405,8 +408,8 @@ use_service_proxy bool true If true, then a Service Proxy is use Pazpar2. --- -Perhaps we should get rid of the `show_lang`, `show_perpage` and -`show_sort` configuration items, and simply display the relevant menus +Perhaps we should get rid of the `show_lang`, `show_perpage`, +`show_sort` and `show_switch` configuration items, and simply display the relevant menus only when their containers are provided -- e.g. an `mkwsLang` element for the language menu. But for now we retain these, as an easier route to lightly customise the display than my changing providing a full HTML diff --git a/examples/htdocs/jasmine-popup.html b/examples/htdocs/jasmine-popup.html index 44d981e..f00cd84 100644 --- a/examples/htdocs/jasmine-popup.html +++ b/examples/htdocs/jasmine-popup.html @@ -26,6 +26,7 @@ + diff --git a/examples/htdocs/mike.html b/examples/htdocs/mike.html index fdda334..477be88 100644 --- a/examples/htdocs/mike.html +++ b/examples/htdocs/mike.html @@ -28,6 +28,7 @@ + +
@@ -44,5 +46,15 @@
+
+

+ Welcome to the MasterKey Widget Set demo. +

+

+ Enter a search above to begin, or + Visit the MKWS home page to find out more. +

+
diff --git a/src/mkws-core.js b/src/mkws-core.js index c7c2863..0af84a9 100644 --- a/src/mkws-core.js +++ b/src/mkws-core.js @@ -10,6 +10,7 @@ // authentication, and a hash of team objects, indexed by team-name. // var mkws = { + $: $, // Our own local copy of the jQuery object authenticated: false, log_level: 1, // Will be overridden from mkws.config, but // initial value allows jQuery popup to use logging. @@ -147,7 +148,8 @@ mkws.setMkwsConfig = function(overrides) { query_width: 50, show_lang: true, /* show/hide language menu */ show_sort: true, /* show/hide sort menu */ - show_perpage: true, /* show/hide perpage menu */ + show_perpage: true, /* show/hide perpage menu */ + show_switch: true, /* show/hide switch 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 */ @@ -308,10 +310,9 @@ mkws.pagerNext = function(tname) { }; -// wrapper to call team() after page load -(function(j) { +// wrapper to provide local copy of the jQuery object. +(function($) { var log = mkws.log; - var $ = j; // XXX function handleNodeWithTeam(node, callback) { // First branch for DOM objects; second branch for jQuery objects @@ -363,11 +364,11 @@ mkws.pagerNext = function(tname) { var w1 = team.widget(t + "-Container-" + from); var w2 = team.widget(t + "-Container-" + to); if (w1) { - $(w1.node).hide(); + w1.node.hide(); } if (w2) { - $(w2.node).show(); - $(w.node).appendTo($(w2.node)); + w2.node.show(); + w.node.appendTo(w2.node); } }); team.queue("resize-" + to).publish(); @@ -382,7 +383,7 @@ mkws.pagerNext = function(tname) { * for the site. */ function authenticateSession(auth_url, auth_domain, pp2_url) { - log("Run service proxy auth URL: " + auth_url); + log("service proxy authentication on URL: " + auth_url); if (!auth_domain) { auth_domain = pp2_url.replace(/^(https?:)?\/\/(.*?)\/.*/, '$2'); @@ -405,7 +406,7 @@ mkws.pagerNext = function(tname) { return; } - log("Service proxy auth successfully done"); + log("service proxy authentication successful"); mkws.authenticated = true; var authName = $(data).find("displayName").text(); // You'd think there would be a better way to do this: @@ -440,14 +441,16 @@ mkws.pagerNext = function(tname) { return '[class^="mkws"],[class*=" mkws"]'; } else { // This is the new version, which works by looking up the - // specific classes of all registered widget types. Because all - // it requires jQuery to do is some hash lookups in pre-built - // tables, it should be very fast; but it silently ignores - // widgets of unregistered types. + // specific classes of all registered widget types and their + // resize containers. Because all it requires jQuery to do is + // some hash lookups in pre-built tables, it should be very + // fast; but it silently ignores widgets of unregistered types. var s = ""; for (var type in mkws.widgetType2function) { if (s) s += ','; s += '.mkws' + type; + s += ',.mkws' + type + "-Container-wide"; + s += ',.mkws' + type + "-Container-narrow"; } return s; } @@ -459,12 +462,12 @@ mkws.pagerNext = function(tname) { handleNodeWithTeam(this, function(tname, type) { var myTeam = mkws.teams[tname]; if (!myTeam) { - myTeam = mkws.teams[tname] = team(j, tname); - log("Made MKWS team '" + tname + "'"); + myTeam = mkws.teams[tname] = team($, tname); + log("made MKWS team '" + tname + "'"); } var oldHTML = this.innerHTML; - var myWidget = widget(j, myTeam, type, this); + var myWidget = widget($, myTeam, type, this); myTeam.addWidget(myWidget); var newHTML = this.innerHTML; if (newHTML !== oldHTML) { @@ -494,7 +497,7 @@ mkws.pagerNext = function(tname) { var lang = key.replace(/^language_/, ""); // Copy custom languages into list mkws.locale_lang[lang] = mkws.config[key]; - log("Added locally configured language '" + lang + "'"); + log("added locally configured language '" + lang + "'"); } } } @@ -506,17 +509,17 @@ mkws.pagerNext = function(tname) { mkws.config.lang = lang; } - log("Locale language: " + (mkws.config.lang ? mkws.config.lang : "none")); + log("using language: " + (mkws.config.lang ? mkws.config.lang : "none")); if (mkws.config.query_width < 5 || mkws.config.query_width > 150) { - log("Reset query width: " + mkws.config.query_width); + log("reset query width to " + mkws.config.query_width); mkws.config.query_width = 50; } // protocol independent link for pazpar2: "//mkws/sp" -> "https://mkws/sp" if (mkws.config.pazpar2_url.match(/^\/\//)) { mkws.config.pazpar2_url = document.location.protocol + mkws.config.pazpar2_url; - log("adjust protocol independent links: " + mkws.config.pazpar2_url); + log("adjusted protocol independent link to " + mkws.config.pazpar2_url); } if (mkws.config.responsive_design_width) { @@ -545,12 +548,12 @@ mkws.pagerNext = function(tname) { makeWidgetsWithin(1, $(rootsel)); var now = $.now(); - log("Walking MKWS nodes took " + (now-then) + " ms"); + log("walking MKWS nodes took " + (now-then) + " ms"); /* for (var tName in mkws.teams) { var myTeam = mkws.teams[tName] - log("TEAM '" + tName + "' = " + myTeam + " ..."); + log("team '" + tName + "' = " + myTeam + " ..."); myTeam.visitWidgets(function(t, w) { log(" has widget of type '" + t + "': " + w); }); diff --git a/src/mkws-filter.js b/src/mkws-filter.js index b8780da..22aeb20 100644 --- a/src/mkws-filter.js +++ b/src/mkws-filter.js @@ -6,7 +6,7 @@ function filterSet(team) { var that = {}; that.toJSON = function() { - return $.toJSON(m_list); + return mkws.$.toJSON(m_list); }; that.add = function(filter) { @@ -45,9 +45,9 @@ function filterSet(team) { for (var i in m_list) { var filter = m_list[i]; if (matchFn(filter)) { - m_team.log("removeMatching() removing filter " + $.toJSON(filter)); + m_team.log("removeMatching: removing filter " + mkws.$.toJSON(filter)); } else { - m_team.log("removeMatching() keeping filter " + $.toJSON(filter)); + m_team.log("removeMatching: keeping filter " + mkws.$.toJSON(filter)); newList.push(filter); } } diff --git a/src/mkws-jquery.js b/src/mkws-jquery.js index 90e43e4..73bd406 100644 --- a/src/mkws-jquery.js +++ b/src/mkws-jquery.js @@ -11,7 +11,7 @@ */ function _mkws_jquery_plugin($) { function debug(string) { - mkws.log("jquery.pazpar2: " + string); + mkws.log("jQuery.pazpar2: " + string); } function init_popup(obj) { diff --git a/src/mkws-team.js b/src/mkws-team.js index 9a012d3..8523ec7 100644 --- a/src/mkws-team.js +++ b/src/mkws-team.js @@ -83,12 +83,11 @@ function team($, teamName) { that.log = log; - log("start running MKWS"); + log("making new widget team"); m_sortOrder = m_config.sort_default; m_perpage = m_config.perpage_default; - log("Create main pz2 object"); // create a parameters array and pass it to the pz2's constructor // then register the form submit event with the pz2.search function // autoInit is set to true on default @@ -104,6 +103,7 @@ function team($, teamName) { "showtime": 500, //each timer (show, stat, term, bytarget) can be specified this way "termlist": m_config.facets.join(',') }); + log("created main pz2 object"); // pz2.js event handlers: function onInit() { @@ -113,7 +113,7 @@ function team($, teamName) { } function onBytarget(data) { - log("target"); + log("bytarget"); queue("targets").publish(data); } @@ -360,7 +360,7 @@ function team($, teamName) { function widgetNode(type) { var w = that.widget(type); - return w ? $(w.node) : undefined; + return w ? w.node : undefined; } function renderDetails(data, marker) { @@ -411,10 +411,8 @@ function team($, teamName) { that.addWidget = function(w) { if (m_widgets[w.type] === undefined) { m_widgets[w.type] = [ w ]; - log("Added '" + w.type + "' widget to team '" + m_teamName + "'"); } else { m_widgets[w.type].push(w); - log("Added '" + w.type + "' widget #" + m_widgets[w.type].length + "' to team '" + m_teamName + "'"); } } diff --git a/src/mkws-widget-authname.js b/src/mkws-widget-authname.js index 02cce99..b1e0b1f 100644 --- a/src/mkws-widget-authname.js +++ b/src/mkws-widget-authname.js @@ -2,6 +2,6 @@ mkws.registerWidgetType('Authname', function() { var that = this; this.team.queue("authenticated").subscribe(function(authName) { - $(that.node).html(authName); + that.node.html(authName); }); }); diff --git a/src/mkws-widget-builder.js b/src/mkws-widget-builder.js index 22f016d..60ee37b 100644 --- a/src/mkws-widget-builder.js +++ b/src/mkws-widget-builder.js @@ -2,11 +2,11 @@ mkws.registerWidgetType('Builder', function() { var that = this; var team = this.team; - this.button = $('