From b14ccf027f714200870dcc3e8271cc19b27c9590 Mon Sep 17 00:00:00 2001 From: Jason Skomorowski Date: Tue, 16 Nov 2010 06:30:18 +0100 Subject: [PATCH] Towards facets. --- mkdru-page.tpl.php | 2 +- mkdru.client.js | 36 ++++++++++++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 3 deletions(-) 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() }); -- 1.7.10.4