From: Mike Taylor Date: Thu, 10 Jul 2014 16:45:49 +0000 (+0100) Subject: Merge branch 'master' of ssh://git.indexdata.com/home/git/private/mkws X-Git-Tag: 1.0.0~378^2 X-Git-Url: http://sru.miketaylor.org.uk/?a=commitdiff_plain;h=76fb961092cc65ba234105609bd2d30649b20bcf;hp=9720875f8d72063a5b845c1ee4a3ec83e2f2b1a8;p=mkws-moved-to-github.git Merge branch 'master' of ssh://git.indexdata.com/home/git/private/mkws --- diff --git a/Makefile b/Makefile index 9f1e405..e80e8e3 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ clean distclean: check-js: ${MAKE} -C./test check -phantomjs p jsb: +phantomjs p p-all phantomjs-all jsb: ${MAKE} -C./test $@ # must be called once after GIT checkout diff --git a/doc/README.markdown b/doc/README.markdown index 667cf4f..d82ffd6 100644 --- a/doc/README.markdown +++ b/doc/README.markdown @@ -1,6 +1,6 @@ % The MasterKey Widget Set % Mike Taylor; Wolfram Schneider -% 10 July 2013 +% 10 July 2014 Introduction @@ -100,4 +100,4 @@ For much more detail, see - - - -Copyright 2013 IndexData ApS. +Copyright 2014 IndexData ApS. diff --git a/doc/whitepaper.markdown b/doc/whitepaper.markdown index 55c56ec..c9b3fad 100644 --- a/doc/whitepaper.markdown +++ b/doc/whitepaper.markdown @@ -1,6 +1,5 @@ % Embedded metasearching with the MasterKey Widget Set % Mike Taylor -% July-September 2013 Introduction @@ -84,7 +83,7 @@ header, which are loaded from the tool site mkws.indexdata.com: contains all the JavaScript needed by the widget-set. * `mkws.css` - provides the default CSS styling + provides the default CSS styling Second, within the HTML body, `
` elements with special IDs that begin `mkws` can be provided. These are filled in by the MKWS code, @@ -273,9 +272,14 @@ generally visible on the page is a search box, and the results appear in a popup. The key part of such an application is this invocation of the MKWS jQuery plugin: - +
+
+
+
+
+
+
+
The necessary scaffolding can be seen in an example application, http://example.indexdata.com/index-popup.html @@ -350,7 +354,7 @@ Element Type Default Description debug_level int 1 Level of debugging output to emit. 0 = none, 1 = messages, 2 = messages with datestamps, 3 = messages with datestamps and stack-traces. -facets array *Note 1* Ordered list of names of facets to display. Supported facet names are +facets array *Note 1* Ordered list of names of facets to display. Supported facet names are `xtargets`, `subject` and `author`. lang string en Code of the default language to display the UI in. Supported language codes are `en` = @@ -480,48 +484,43 @@ and -### jQuery plugin invocation +### jQuery UI popup invocation -The MasterKey Widget Set can be invoked as a jQuery plugin rather than -by providing an HTML skeleton explicitly. When this approach is used, -the invocation is a single line of JavaScript: +The MasterKey Widget Set can be invoked in a popup window on top of the page. - +Note that when using the `popup` layout, facilities from the jQuery UI +toolkit are used, so it's necessary to include both CSS and JavaScript +from that toolkit. The relevant lines are: -This code should be inserted in the page at the position where the -metasearch should occur. + + -When invoking this plugin, a key-value lookup table of named options -may be passed in to modify the default behaviour, as in the exaple -above. The available options are as follows: +
+
+
+
+
+
+
+
- +--- ### The structure of the HTML generated by the MKWS widgets @@ -595,4 +594,4 @@ and .CLASS indicates an instance of a class. - - - -Copyright (C) 2013 by IndexData ApS, +Copyright (C) 2013-2014 by IndexData ApS, diff --git a/examples/htdocs/jasmine-cors-popup.html b/examples/htdocs/jasmine-cors-popup.html index ac49a3f..4263d0d 100644 --- a/examples/htdocs/jasmine-cors-popup.html +++ b/examples/htdocs/jasmine-cors-popup.html @@ -61,14 +61,16 @@

MKWS Jasmine regression tests

+
+
-
+
diff --git a/examples/htdocs/jasmine-local-popup.html b/examples/htdocs/jasmine-local-popup.html index 3a85e82..ed44aff 100644 --- a/examples/htdocs/jasmine-local-popup.html +++ b/examples/htdocs/jasmine-local-popup.html @@ -11,18 +11,21 @@ + + + - - + + @@ -60,15 +63,18 @@ show_record_url: true }; - jQuery.pazpar2({ - "layout": "popup", /* "table" [default], "div", "popup" */ - "width": 990, /* popup width, should be at least 800 */ - "height": 760 /* popup height, should be at least 600 */ - });

MKWS Jasmine regression tests

-

+ +

+
+
+
+
+
+
+
diff --git a/examples/htdocs/jasmine-popup.html b/examples/htdocs/jasmine-popup.html index c27e0f4..e95766d 100644 --- a/examples/htdocs/jasmine-popup.html +++ b/examples/htdocs/jasmine-popup.html @@ -11,18 +11,21 @@ + + + - - + + @@ -36,7 +39,7 @@ - @@ -62,16 +65,18 @@ check_motd: false, show_record_url: true }; - - jQuery.pazpar2({ - "layout": "popup", /* "table" [default], "div", "popup" */ - "width": 990, /* popup width, should be at least 800 */ - "height": 760 /* popup height, should be at least 600 */ - });

MKWS Jasmine regression tests

-

+

+
+
+
+
+
+
+
+ diff --git a/examples/htdocs/popup-dev.html b/examples/htdocs/popup-dev.html new file mode 100644 index 0000000..174fc37 --- /dev/null +++ b/examples/htdocs/popup-dev.html @@ -0,0 +1,61 @@ + + + + MKWS demo: Reference widget with popup window + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

MKWS widgets in a popup window

+ +
+
+
+
+
+
+
+
+ +
+
mkwsCredo result will appear here
+
+ +
+
mkwsReference result will appear here
+
+ + + diff --git a/examples/htdocs/popup.html b/examples/htdocs/popup.html index 60529bb..9a1a35e 100644 --- a/examples/htdocs/popup.html +++ b/examples/htdocs/popup.html @@ -1,81 +1,51 @@ - MKWS demo: popup search box - - + MKWS demo: Reference widget with popup window + + + + - - - - + + + - + + - - -
-      An embryonic MasterKey Widget Set
-=================================
-
-This directory contains an embryonic MasterKey Widget Set, based
-initially on "jsdemo" though now far removed from those beginnnings.
-
-
-How this works
---------------
-
-The goal is to make it that as much of the searching functionality as
-possible is hosted on
-        http://mkws.indexdata.com/
-so that very simple websites such as
-        http://example.indexdata.com/
-can have MasterKey searching with minimal effort.
-
-The following files must be hosted on mkws.indexdata.com:
-        mkws.js
-        mkws.css
-        /pazpar2/js/pz2.js (*)
-
-The following files make up the application:
-        index.html
-        favicon.ico [optional]
-        robots.txt [optional]
-
-(At present, the client application's configuruation also needs an
-Alias for /service-proxy/, to avoid cross-site scripting issues. We
-will fix this.)
+    

MKWS widgets in a popup window

-(*) if you don't have already installed pazpar2 on the machine, you can -do it by installing a debian package or check it out from GIT: -$ git clone ssh://git.indexdata.com:222/home/git/pub/pazpar2 +
+
+
+
+
+
+
+
-Configuring a client --------------------- +
+
mkwsCredo result will appear here
+
-The application's HTML must contains the following elements as well as -whatever makes up the application itself: +
+
mkwsReference result will appear here
+
-[...] -
- diff --git a/examples/htdocs/wolfram.html b/examples/htdocs/wolfram.html index a15f554..f2653aa 100644 --- a/examples/htdocs/wolfram.html +++ b/examples/htdocs/wolfram.html @@ -30,8 +30,11 @@ + + + \ - \ -\ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
'; - - var popup = '\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
' - - if (config && config.layout == 'div') { - debug("jquery plugin layout: div"); - document.write(div); - } else if (config && config.layout == 'popup') { - debug("jquery plugin layout: popup with id: " + id_popup); - document.write(popup); - $(document).ready(function() { init_popup(config); }); - } else { - debug("jquery plugin layout: table"); - document.write(table); - } - } - }); -}; - - -// XXX: enable before page load, so we could call it before mkws() runs -_mkws_jquery_plugin(mkws.$); - diff --git a/src/mkws-popup.js b/src/mkws-popup.js new file mode 100644 index 0000000..bc54f3c --- /dev/null +++ b/src/mkws-popup.js @@ -0,0 +1,60 @@ +/* generic function to open results in a popup window + * + */ + +//"use strict"; +// $(document).ready(function () { +mkws.registerWidgetType('Popup', function() { + var $ = mkws.$; + var debug = mkws.log; + debug("init popup window"); + + var popup_window = $(this.node); // mkws.registerWidgetType('Popup',....) + // var popup_window = $(".mkwsPopup"); // $(document).ready() + if (!popup_window) { + debug("no popup found, skip..."); + return; + } else { + debug("number of popup windows found: " + popup_window.length); + } + + if (!$.ui) { + alert("Error: jquery-ui.js is missing, did you include it after jQuery core in the HTML file?"); + return; + } + + // more than one widget on a page are possible + popup_window.each(function(i) { + var that = $(this); + + // all atributes are strings, convert them to integers here + var width = parseInt(that.attr("popup_width") || "800"); + var height = parseInt(that.attr("popup_height") || "600"); + var autoOpen = parseInt(that.attr("popup_autoOpen") || "0"); + var modal = parseInt(that.attr("popup_modal") || "0"); + + debug("Popup parameters: width: " + width + ", height: " + height + ", autoOpen: " + autoOpen); + that.dialog({ + closeOnEscape: true, + autoOpen: autoOpen, + height: height, + width: width, + modal: modal ? true : false, + resizable: true, + buttons: { + Cancel: function() { + that.dialog("close"); + } + }, + close: function() {} + }); + + // open at search query submit: "input.mkwsButton" + var id_botton = that.attr("popup_button"); + if (id_botton) { + $(id_botton).button().click(function() { + that.dialog("open"); + }); + } + }); +}); diff --git a/src/mkws-widget-main.js b/src/mkws-widget-main.js index 85c2ba4..d3a13cf 100644 --- a/src/mkws-widget-main.js +++ b/src/mkws-widget-main.js @@ -448,6 +448,5 @@ mkws.registerWidgetType('Progress', function() { mkws.registerWidgetType('Query', function() {}); mkws.registerWidgetType('MOTDContainer', function() {}); mkws.registerWidgetType('Button', function() {}); -mkws.registerWidgetType('Popup', function() {}); diff --git a/tools/htdocs/Makefile b/tools/htdocs/Makefile index 388a4b8..f0a7291 100644 --- a/tools/htdocs/Makefile +++ b/tools/htdocs/Makefile @@ -16,10 +16,19 @@ JQUERY_UI_URL = http://code.jquery.com/ui/1.10.3/jquery-ui.js VERSION = $(shell tr -d '\012' < ${SRC}/VERSION) COMPONENTS = ${SRC}/mkws-handlebars.js \ - ${SRC}/mkws-core.js ${SRC}/mkws-team.js ${SRC}/mkws-filter.js \ - ${SRC}/mkws-widget.js ${SRC}/mkws-widget-main.js ${SRC}/mkws-widget-termlists.js \ - ${SRC}/mkws-widget-authname.js ${SRC}/mkws-widget-categories.js ${SRC}/mkws-widget-log.js \ - ${SRC}/mkws-widget-record.js ${SRC}/mkws-widget-reference.js ${SRC}/mkws-widget-builder.js + ${SRC}/mkws-core.js \ + ${SRC}/mkws-team.js \ + ${SRC}/mkws-filter.js \ + ${SRC}/mkws-popup.js \ + ${SRC}/mkws-widget.js \ + ${SRC}/mkws-widget-main.js \ + ${SRC}/mkws-widget-termlists.js \ + ${SRC}/mkws-widget-authname.js \ + ${SRC}/mkws-widget-categories.js \ + ${SRC}/mkws-widget-log.js \ + ${SRC}/mkws-widget-record.js \ + ${SRC}/mkws-widget-reference.js \ + ${SRC}/mkws-widget-builder.js GENERATED = ${HANDLEBARS_FILE} ${JQUERY_FILE} ${JQUERY_JSON_FILE} ${PP2_FILE} \ mkws.js mkws.min.js mkws-complete.js mkws-complete.min.js @@ -28,7 +37,7 @@ GENERATED = ${HANDLEBARS_FILE} ${JQUERY_FILE} ${JQUERY_JSON_FILE} ${PP2_FILE} \ all: mkws.min.js mkws-complete.min.js -mkws-js mkws-complete.js: Makefile mkws.js ${SRC}/mkws-jquery.js ${HANDLEBARS_FILE} ${JQUERY_FILE} ${JQUERY_JSON_FILE} ${PP2_FILE} +mkws-js mkws-complete.js: Makefile mkws.js ${HANDLEBARS_FILE} ${JQUERY_FILE} ${JQUERY_JSON_FILE} ${PP2_FILE} ( set -e; \ echo "/*! Copyright (c) 2013-2014 IndexData ApS. http://indexdata.com"; \ echo " Licence: GPL, http://www.indexdata.com/licences/gpl"; \ @@ -42,7 +51,6 @@ mkws-js mkws-complete.js: Makefile mkws.js ${SRC}/mkws-jquery.js ${HANDLEBARS_FI cat ${HANDLEBARS_FILE}; \ cat ${PP2_FILE}; \ cat mkws.js; \ - cat ${SRC}/mkws-jquery.js; \ ) > mkws-complete.js.tmp mv -f mkws-complete.js.tmp mkws-complete.js @@ -87,6 +95,10 @@ mkws.js: $(COMPONENTS) Makefile mv -f $@.tmp $@ chmod 444 $@ +mkws-html-includes: + echo $(COMPONENTS) | perl -npe "s,${SRC},,g; s/\s+/\0/g" | \ + perl -n0e 'print qq{ \n}' + distclean: clean @echo "(No need for distclean, 'make clean' is fine)" diff --git a/tools/htdocs/index.html b/tools/htdocs/index.html index c1341be..e851ab4 100644 --- a/tools/htdocs/index.html +++ b/tools/htdocs/index.html @@ -282,7 +282,7 @@

- Copyright © 2013 IndexData ApS. + Copyright (©) 2013-2014 IndexData ApS. http://indexdata.com