Oops, fixed a non-MKWS-specific HTML name (as opposed to id).
[mkws-moved-to-github.git] / experiments / spclient / mkws.js
index 0d94986..3abf9da 100644 (file)
@@ -185,6 +185,9 @@ function my_onterm(data) {
 
     var termlist = document.getElementById("mkwsTermlists");
     replaceHtml(termlist, acc.join(''));
+
+    if (mkws_config.responsive_design)
+        mkws_mobile_resize();
 }
 
 function add_single_facet(acc, caption, data, max, cclIndex) {
@@ -241,8 +244,8 @@ function my_onbytarget(data) {
 // wait until the DOM is ready
 function domReady ()
 {
-    document.search.onsubmit = onFormSubmitEventHandler;
-    document.search.mkwsQuery.value = '';
+    document.mkwsSearchForm.onsubmit = onFormSubmitEventHandler;
+    document.mkwsSearchForm.mkwsQuery.value = '';
     document.mkwsSelect.mkwsSort.onchange = onSelectDdChange;
     document.mkwsSelect.mkwsPerpage.onchange = onSelectDdChange;
 }
@@ -275,7 +278,7 @@ function resetPage()
 
 function triggerSearch ()
 {
-    my_paz.search(document.search.mkwsQuery.value, recPerPage, curSort, curFilter);
+    my_paz.search(document.mkwsSearchForm.mkwsQuery.value, recPerPage, curSort, curFilter);
 }
 
 function loadSelect ()
@@ -287,7 +290,7 @@ function loadSelect ()
 // limit the query after clicking the facet
 function limitQuery (field, value)
 {
-    document.search.query.value += ' and ' + field + '="' + value + '"';
+    document.mkwsSearchForm.query.value += ' and ' + field + '="' + value + '"';
     onFormSubmitEventHandler();
 }
 
@@ -331,9 +334,9 @@ function drawPager (pagerDiv)
         ? firstClkbl + 2*onsides
         : pages;
 
-    var prev = '<span id="prev">&#60;&#60; ' + M('Prev') + '</span><b> | </b>';
+    var prev = '<span id="mkwsPrev">&#60;&#60; ' + M('Prev') + '</span><b> | </b>';
     if (curPage > 1)
-        prev = '<a href="#" id="prev" onclick="pagerPrev();">'
+        prev = '<a href="#" id="mkwsPrev" onclick="pagerPrev();">'
         +'&#60;&#60; ' + M('Prev') + '</a><b> | </b>';
 
     var middle = '';
@@ -346,9 +349,9 @@ function drawPager (pagerDiv)
             + numLabel + ' </a>';
     }
 
-    var next = '<b> | </b><span id="next">' + M('Next') + ' &#62;&#62;</span>';
+    var next = '<b> | </b><span id="mkwsNext">' + M('Next') + ' &#62;&#62;</span>';
     if (pages - curPage > 0)
-        next = '<b> | </b><a href="#" id="next" onclick="pagerNext()">'
+        next = '<b> | </b><a href="#" id="mkwsNext" onclick="pagerNext()">'
         + M('Next') + ' &#62;&#62;</a>';
 
     var predots = '';
@@ -502,9 +505,11 @@ function mkws_html_all(config) {
        lang_menu: true,        /* show/hide language menu */
        lang_display: [],       /* display languages links for given languages, [] for all */
        facets: ["sources", "subjects", "authors"], /* display facets, in this order, [] for none */
+       responsive_design_width: 980, /* a page with less pixel width considered as mobile */   
 
        debug: 0,     /* debug level for development: 0..2 */
 
+
        dummy: "dummy"
     };
 
@@ -532,10 +537,10 @@ function mkws_html_all(config) {
        mkws_html_lang(mkws_config);
 
     // For some reason, doing this programmatically results in
-    // document.search.mkwsQuery being undefined, hence the raw HTML.
+    // document.mkwsSearchForm.mkwsQuery being undefined, hence the raw HTML.
     debug("HTML search form");
     $("#mkwsSearch").html('\
-    <form name="search" action="" >\
+    <form name="mkwsSearchForm" action="" >\
       <input id="mkwsQuery" type="text" size="' + mkws_config.query_width + '" />\
       <input id="mkwsButton" type="submit" value="' + M('Search') + '" />\
     </form>');
@@ -585,7 +590,7 @@ function mkws_responsive_design () {
     $(window).resize( function(e) {
        if (timeout)
            clearTimeout(timeout);
-       timeout = setTimeout(function () { mkws_mobile_resize() }, 100);
+       timeout = setTimeout(function () { mkws_mobile_resize() }, 50);
     });
 
     // initial check after page load
@@ -742,7 +747,9 @@ function mkws_mobile_resize () {
     var obj;
     // alert($(window).width());
 
-    if ($(window).width() <= 980) {
+    var width = mkws_config.responsive_design_width || 980;
+
+    if ($(window).width() <= width) {
        for(var i = 0; i < list.length; i++) {
            $("#" + list[i]).hide();
        }
@@ -789,7 +796,7 @@ jQuery.extend({
     <div id="mkwsTargets"></div>\
     <div id="mkwsFooter">\
       <div id="mkwsStat"></div>\
-      <span>Powered by MKWS &copy; 2013 <a href="http://www.indexdata.com">Index Data</a></span>\
+      <span>Powered by MKWS &copy; 2013 <a target="_new" href="http://www.indexdata.com">Index Data</a></span>\
     </div>');
 
     mkws_html_all(mkws_config);