X-Git-Url: http://git.indexdata.com/?p=mkws-moved-to-github.git;a=blobdiff_plain;f=experiments%2Fspclient%2Fmkws.js;h=f182558d38aa50916da8a98d536474d7764cc1f5;hp=d168a3444c2e26334e1a945881d919deb9bc02e5;hb=928700876d4761de482f57e0b78c8c6038039201;hpb=4c6f9a1f806b78e332cd5712d37f72f20ac79567 diff --git a/experiments/spclient/mkws.js b/experiments/spclient/mkws.js index d168a34..f182558 100644 --- a/experiments/spclient/mkws.js +++ b/experiments/spclient/mkws.js @@ -113,7 +113,7 @@ function my_oninit() { function my_onshow(data) { totalRec = data.merged; // move it out - var pager = document.getElementById("pager"); + var pager = document.getElementById("mkwsPager"); pager.innerHTML = ""; pager.innerHTML +='
' + M('Displaying') + ': ' + (data.start + 1) + ' ' + M('to') + ' ' + (data.start + data.num) + @@ -121,7 +121,7 @@ function my_onshow(data) { + data.total + ')
'; drawPager(pager); // navi - var results = document.getElementById("results"); + var results = document.getElementById("mkwsResults"); var html = []; for (var i = 0; i < data.hits.length; i++) { @@ -160,28 +160,31 @@ function my_onstat(data) { function my_onterm(data) { // no facets if (!mkws_config.facets || mkws_config.facets.length == 0) { - $("#termlist").parent().hide(); + $("#mkwsTermlists").parent().hide(); return; } // display if we first got results - $("#termlist").parent().show(); + $("#mkwsTermlists").parent().show(); - var termlists = []; - termlists.push('
' + M('Termlists') + '
'); + var acc = []; + acc.push('
' + M('Termlists') + '
'); var facets = mkws_config.facets; for(var i = 0; i < facets.length; i++) { - if (facets[i] == "sources") - add_single_facet(termlists, "Sources", data.xtargets, SourceMax, null); - if (facets[i] == "subjects") - add_single_facet(termlists, "Subjects", data.subject, SubjectMax, "su"); - if (facets[i] == "authors") - add_single_facet(termlists, "Authors", data.author, AuthorMax, "au"); + if (facets[i] == "sources") { + add_single_facet(acc, "Sources", data.xtargets, SourceMax, null); + } else if (facets[i] == "subjects") { + add_single_facet(acc, "Subjects", data.subject, SubjectMax, "su"); + } else if (facets[i] == "authors") { + add_single_facet(acc, "Authors", data.author, AuthorMax, "au"); + } else { + alert("bad facet configuration: '" + facets[i] + "'"); + } } - var termlist = document.getElementById("termlist"); - replaceHtml(termlist, termlists.join('')); + var termlist = document.getElementById("mkwsTermlists"); + replaceHtml(termlist, acc.join('')); } function add_single_facet(acc, caption, data, max, cclIndex) { @@ -207,7 +210,7 @@ function my_onrecord(data) { // FIXME: record is async!! clearTimeout(my_paz.recordTimer); // in case on_show was faster to redraw element - var detRecordDiv = document.getElementById('det_'+data.recid); + var detRecordDiv = document.getElementById('mkwsDet_'+data.recid); if (detRecordDiv) return; curDetRecData = data; var recordDiv = document.getElementById('recdiv_'+curDetRecData.recid); @@ -216,7 +219,7 @@ function my_onrecord(data) { } function my_onbytarget(data) { - var targetDiv = document.getElementById("bytarget"); + var targetDiv = document.getElementById("mkwsBytarget"); var table ='' +''; @@ -291,7 +294,7 @@ function limitQuery (field, value) // limit by target functions function limitTarget (id, name) { - var navi = document.getElementById('navi'); + var navi = document.getElementById('mkwsNavi'); navi.innerHTML = 'Source: ' + name + ''; @@ -305,7 +308,7 @@ function limitTarget (id, name) function delimitTarget () { - var navi = document.getElementById('navi'); + var navi = document.getElementById('mkwsNavi'); navi.innerHTML = ''; curFilter = null; resetPage(); @@ -416,7 +419,7 @@ function showDetails (prefixRecId) { curDetRecId = recId; // remove current detailed view if any - var detRecordDiv = document.getElementById('det_'+oldRecId); + var detRecordDiv = document.getElementById('mkwsDet_'+oldRecId); // lovin DOM! if (detRecordDiv) detRecordDiv.parentNode.removeChild(detRecordDiv); @@ -447,7 +450,7 @@ function replaceHtml(el, html) { function renderDetails(data, marker) { - var details = '
Target IDHitsDiagsRecordsState
'; + var details = '
'; if (marker) details += ''; details += renderField("Title", data["md-title"], data["md-title-remainder"], data["md-title-responsibility"]); @@ -542,7 +545,7 @@ function mkws_html_all(config) {
'+ marker + '
\ \ \ \ \
\ -
\ +
\
\
\ @@ -552,21 +555,41 @@ function mkws_html_all(config) { ' + M('per page') + '.\ \
\ -
\ - \ -
\ +
\ +
\ +
\
'); mkws_html_switch(config); + if (mkws_config.use_service_proxy) mkws_service_proxy_auth(config.service_proxy_auth); + if (mkws_config.responsive_design) + mkws_responsive_design(); + domReady(); // on first page, hide the termlist - $(document).ready(function() { $("#termlist").parent().hide(); } ); + $(document).ready(function() { $("#mkwsTermlists").parent().hide(); } ); +} + +/* Responsive web design - change layout on the fly depending on + * the current screen size width/height. Required for mobile devices. + */ +function mkws_responsive_design () { + var timeout = null; + + $(window).resize( function(e) { + if (timeout) + clearTimeout(timeout); + timeout = setTimeout(function () { mkws_mobile_resize() }, 100); + }); + + // initial check after page load + $(document).ready(function() { mkws_mobile_resize() }); } function mkws_set_lang(mkws_config) { @@ -598,7 +621,7 @@ function mkws_html_switch(config) { debug("HTML targets"); $("#mkwsTargets").html('\ -
\ +
\ No information available yet.\
'); $("#mkwsTargets").css("display", "none"); @@ -713,6 +736,29 @@ function mkws_html_lang(mkws_config) { $("#mkwsLang").html(data); } +function mkws_mobile_resize () { + debug("resize width: " + $(window).height() + ", width: " + $(window).width()); + var list = ["mkwsSwitch"]; + var obj; + // alert($(window).width()); + + if ($(window).width() <= 980) { + for(var i = 0; i < list.length; i++) { + $("#" + list[i]).hide(); + } + + $("#mkwsTermlists").parent().hide(); + obj = $("#mkwsTermlists").parent().html(); + $("#mkwsShiftedTermlists").html("
" + obj); + } else { + for(var i = 0; i < list.length; i++) { + $("#" + list[i]).show(); + } + $("#mkwsTermlists").parent().show(); + $("#mkwsShiftedTermlists").html(""); + } +}; + /* locale */ function M(word) { var lang = mkws_config.lang;