From: Jason Skomorowski Date: Tue, 16 Nov 2010 05:30:18 +0000 (+0100) Subject: Towards facets. X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=b14ccf027f714200870dcc3e8271cc19b27c9590;p=mkdru-moved-to-drupal.org.git Towards facets. --- diff --git a/mkdru-page.tpl.php b/mkdru-page.tpl.php index 0595341..23e0630 100644 --- a/mkdru-page.tpl.php +++ b/mkdru-page.tpl.php @@ -5,7 +5,7 @@ diff --git a/mkdru.client.js b/mkdru.client.js index 0ca107f..ae1ccca 100644 --- a/mkdru.client.js +++ b/mkdru.client.js @@ -65,6 +65,21 @@ mkdru.pz2Term = function (data) { 'mkdru-facet-link-author', data.author[i].id); } $('#mkdru-authors').html(html); + + $('.mkdru-facet-link-source').bind('click', function (e) { + mkdru.limitTarget(this.getAttribute('target_id'), this.firstChild.nodeValue); + return false; + }); + + $('.mkdru-facet-link-subject').bind('click', function (e) { + mkdru.limitQuery('su', this.firstChild.nodeValue); + return false; + }); + + $('.mkdru-facet-link-author').bind('click', function (e) { + mkdru.limitQuery('au', this.firstChild.nodeValue); + return false; + }); }; mkdru.pz2ByTarget = function (data) { @@ -79,6 +94,7 @@ mkdru.submitQuery = function () { // mkdru.resetPage(); // mkdru.pollDropDowns(); mkdru.search(); + return false; }; mkdru.search = function () { @@ -95,7 +111,23 @@ mkdru.pollDropDowns = function () { }; mkdru.limitQuery = function (field, value) { - + $('.mkdru-search input:text').attr('value', function () { + return this.value += ' and ' + field + '="' + value + '"'; + }); + mkdru.submitQuery(); +}; + +mkdru.limitTarget = function (id, name) { + var navi = document.getElementById('mkdru-navi'); + navi.innerHTML = + 'Source: ' + + name + ''; + navi.innerHTML += '
'; + mkdru.curFilter = 'pz:id=' + id; + mkdru.resetPage(); + mkdru.pollDropDowns(); + mkdru.search(); + return false; }; mkdru.resetPage = function () { @@ -125,7 +157,7 @@ mkdru.prevPage = function () { // wait until the DOM is ready, bind events // and instantiate pz2 library $(document).ready(function () { - $('.mkdru-search input:button').bind('click', mkdru.submitQuery); + $('.mkdru-search').bind('submit', mkdru.submitQuery); $('.mkdru-search input:text').attr('value', ''); $('#mkdru-perpage').bind('change', function () { mkdru.pollDropDowns() }); $('#mkdru-sort').bind('change', function () { mkdru.pollDropDowns() });