From: Jason Skomorowski Date: Tue, 4 Jan 2011 03:32:42 +0000 (+0100) Subject: Simple detail view. X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=aa8e1fdaaa759602a95aa4cdd9186d209ae8abe6;p=mkdru-moved-to-drupal.org.git Simple detail view. --- diff --git a/mkdru-results.tpl.php b/mkdru-results.tpl.php index eb90d2b..077d565 100644 --- a/mkdru-results.tpl.php +++ b/mkdru-results.tpl.php @@ -1,6 +1,7 @@ +
-
+ \ No newline at end of file diff --git a/mkdru.client.js b/mkdru.client.js index 95c9bf5..69909e1 100644 --- a/mkdru.client.js +++ b/mkdru.client.js @@ -46,6 +46,7 @@ mkdru.pz2Show = function (data) { (mkdru.curPage - 1)); } $('.mkdru-result-list').html(html); + $('.mkdru-result-title').bind('click', mkdru.requestDetail); $('.mkdru-results').show(); }; @@ -53,48 +54,57 @@ mkdru.pz2Status = function (data) { }; mkdru.pz2Term = function (data) { - var html = ""; - for (var i = 0; i < data.xtargets.length && i < mkdru.sourceMax; i++ ) { - html += Drupal.theme('mkdruTerm', data.xtargets[i].name, data.xtargets[i].freq, - 'mkdru-facet-source', data.xtargets[i].id); - } - $('.mkdru-facet-sources').html(html); - - html = ""; - for (var i = 0; i < data.subject.length && i < mkdru.subjectMax; i++ ) { - html += Drupal.theme('mkdruTerm', data.subject[i].name, data.subject[i].freq, - 'mkdru-facet-subject', data.subject[i].id); - } - $('.mkdru-facet-subjects').html(html); - - html = ""; - for (var i = 0; i < data.author.length && i < mkdru.authorMax; i++ ) { - html += Drupal.theme('mkdruTerm', data.author[i].name, data.author[i].freq, - 'mkdru-facet-author', data.author[i].id); - } - $('.mkdru-facet-authors').html(html); - - $('.mkdru-facet-source').bind('click', function (e) { - mkdru.limitTarget(this.getAttribute('target_id'), this.firstChild.nodeValue); - return false; - }); - - $('.mkdru-facet-subject').bind('click', function (e) { - mkdru.limitQuery('su', this.firstChild.nodeValue); - return false; - }); - - $('.mkdru-facet-author').bind('click', function (e) { - mkdru.limitQuery('au', this.firstChild.nodeValue); - return false; - }); + var html = ""; + for (var i = 0; i < data.xtargets.length && i < mkdru.sourceMax; i++ ) { + html += Drupal.theme('mkdruTerm', data.xtargets[i].name, data.xtargets[i].freq, + 'mkdru-facet-source', data.xtargets[i].id); + } + $('.mkdru-facet-sources').html(html); + + html = ""; + for (var i = 0; i < data.subject.length && i < mkdru.subjectMax; i++ ) { + html += Drupal.theme('mkdruTerm', data.subject[i].name, data.subject[i].freq, + 'mkdru-facet-subject', data.subject[i].id); + } + $('.mkdru-facet-subjects').html(html); + + html = ""; + for (var i = 0; i < data.author.length && i < mkdru.authorMax; i++ ) { + html += Drupal.theme('mkdruTerm', data.author[i].name, data.author[i].freq, + 'mkdru-facet-author', data.author[i].id); + } + $('.mkdru-facet-authors').html(html); + + $('.mkdru-facet-source').bind('click', function (e) { + mkdru.limitTarget(this.getAttribute('target_id'), this.firstChild.nodeValue); + return false; + }); + + $('.mkdru-facet-subject').bind('click', function (e) { + mkdru.limitQuery('su', this.firstChild.nodeValue); + return false; + }); + + $('.mkdru-facet-author').bind('click', function (e) { + mkdru.limitQuery('au', this.firstChild.nodeValue); + return false; + }); }; mkdru.pz2ByTarget = function (data) { }; +mkdru.pz2Record = function (data) { + clearTimeout(mkdru.pz2.recordTimer); +// $('.mkdru-results').hide(); +// mkdru.pz2.stop(); +// clearTimeout(mkdru.pz2.showTimer); + $('.mkdru-detail').html(Drupal.theme('mkdruDetail', data)); + $('.mkdru-detail').bind('click', function () {$('.mkdru-detail').hide()}); + $('.mkdru-detail').show(); +}; // UI functions: mkdru.submitQuery = function () { @@ -132,7 +142,7 @@ mkdru.limitQuery = function (field, value) { mkdru.submitQuery(); }; -mkdru.limitTarget = function (id, name) { +mkdru.limitTarget = function (id, name) { var navi = document.getElementById('mkdru-navi'); navi.innerHTML = 'Source: ' @@ -155,6 +165,10 @@ mkdru.showPage = function (pageNum) { mkdru.pz2.showPage(pageNum-1); }; +mkdru.requestDetail = function (e) { + mkdru.pz2.record(e.target.parentNode.id.replace('rec_', '')); +}; + mkdru.nextPage = function () { if (mkdru.totalRec - mkdru.recPerPage * mkdru.curPage > 0) { mkdru.pz2.showNext(); diff --git a/mkdru.css b/mkdru.css index 8b1f398..75321b4 100644 --- a/mkdru.css +++ b/mkdru.css @@ -36,3 +36,7 @@ .mkdru-result a { font-weight: bold; } + +.mkdru-detail { + display: none; +} \ No newline at end of file diff --git a/mkdru.theme.js b/mkdru.theme.js index 782c935..800f2b3 100644 --- a/mkdru.theme.js +++ b/mkdru.theme.js @@ -1,19 +1,46 @@ Drupal.theme.prototype.mkdruResult = function(hit, num) { var html = ""; - html += '
  • ' + html += '
  • ' + '' + num + '. ' - + '' + + '' + hit["md-title"] + ' '; if (hit["md-title-remainder"] !== undefined) { - html += '' + hit["md-title-remainder"] + ' '; + html += '' + + hit["md-title-remainder"] + ' '; } if (hit["md-title-responsibility"] !== undefined) { - html += '' + html += '' + hit["md-title-responsibility"] + ''; } html += '
  • '; - return (html); + return html; +}; + +Drupal.theme.prototype.mkdruDetail = function(data) { + var html = '
    '; + if (data["md-title"] != undefined) { + html += ''; + } + if (data["md-date"] != undefined) + html += ''; + if (data["md-author"] != undefined) + html += ''; + if (data["md-electronic-url"] != undefined) + html += ''; + if (data["location"][0]["md-subject"] != undefined) + html += ''; + if (data["location"][0]["@name"] != undefined) + html += ''; + html += '
    Title: '+data["md-title"]; + if (data["md-title-remainder"] !== undefined) { + html += ' : ' + data["md-title-remainder"] + ' '; + } + if (data["md-title-responsibility"] !== undefined) { + html += ' '+ data["md-title-responsibility"] +''; + } + html += '
    Date: ' + data["md-date"] + '
    Author: ' + data["md-author"] + '
    URL: ' + data["md-electronic-url"] + '' + '
    Subject: ' + data["location"][0]["md-subject"] + '
    Location: ' + data["location"][0]["@name"] + " (" +data["location"][0]["@id"] + ")" + '
    '; + return html; }; Drupal.theme.prototype.mkdruPager = function (data, curPage, pages) {