From: Jason Skomorowski Date: Sat, 15 Jan 2011 04:32:35 +0000 (+0100) Subject: Back button works with details but some issues yet. X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=8c8f2a5d5896e6d5129ec249ef2d250170406dc6;p=mkdru-moved-to-drupal.org.git Back button works with details but some issues yet. --- diff --git a/mkdru.client.js b/mkdru.client.js index 86fcf50..b8e7f4c 100644 --- a/mkdru.client.js +++ b/mkdru.client.js @@ -54,11 +54,12 @@ mkdru.pz2Show = function (data) { var html = ""; for (var i = 0; i < data.hits.length; i++) { html += Drupal.theme('mkdruResult', data.hits[i], - i + 1 + mkdru.state.perpage * - (mkdru.state.page - 1)); + i + 1 + mkdru.state.perpage * (mkdru.state.page - 1), + "#" + $.param.fragment($.param.fragment( + window.location.href, {recid: data.hits[i].recid})) + "\n" + ); } $('.mkdru-result-list').html(html); - $('.mkdru-result-title').bind('click', mkdru.requestDetail); $('.mkdru-results').show(); }; @@ -111,7 +112,7 @@ mkdru.pz2Record = function (data) { clearTimeout(mkdru.pz2.showTimer); $('.mkdru-results').hide(); $('.mkdru-detail').html(Drupal.theme('mkdruDetail', data)); - $('.mkdru-detail').bind('click', function () {$('.mkdru-detail').hide()}); + $('.mkdru-detail-back').bind('click', function () {$.bbq.removeState('recid');}); $('.mkdru-detail').show(); clearTimeout(mkdru.pz2.recordTimer); }; @@ -140,6 +141,7 @@ mkdru.stateFromHash = function () { // set current window's hash string from state mkdru.hashFromState = function () { + // only include non-default settings in the URL var alteredState = {}; for (var key in mkdru.defaultState) { if (mkdru.state[key] != mkdru.defaultState[key]) { @@ -168,6 +170,14 @@ mkdru.uiFromState = function () { mkdru.hashChange = function () { dump("Submidded? " + mkdru.submitted + "\n"); + var hash = $.deparam.fragment(); + if (typeof(hash.recid) !== "undefined") { + mkdru.pz2.record(hash.recid); + } + else { + $('.mkdru-detail').hide(); + $('.mkdru-results').show(); + } }; @@ -189,7 +199,6 @@ mkdru.triggerSearch = function () { }; mkdru.search = function () { - $('.mkdru-detail').hide(); mkdru.pz2.search(mkdru.state.query, mkdru.state.perpage, mkdru.state.sort, mkdru.state.filter); }; @@ -233,20 +242,18 @@ 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.state.perpage * mkdru.state.page > 0) { mkdru.pz2.showNext(); mkdru.state.page++; + mkdru.hashFromState(); } }; mkdru.prevPage = function () { if (mkdru.pz2.showPrev() != false) { mkdru.state.page--; + mkdru.hashFromState(); } }; diff --git a/mkdru.theme.js b/mkdru.theme.js index a45ad75..da581ff 100644 --- a/mkdru.theme.js +++ b/mkdru.theme.js @@ -1,8 +1,8 @@ -Drupal.theme.prototype.mkdruResult = function(hit, num) { +Drupal.theme.prototype.mkdruResult = function(hit, num, detailLink) { var html = ""; html += '
  • ' + '' + num + '. ' - + '' + + '' + hit["md-title"] + ' '; if (hit["md-title-remainder"] !== undefined) { html += '' @@ -40,7 +40,7 @@ Drupal.theme.prototype.mkdruDetail = function(data) { if (data["location"][0]["@name"] != undefined) html += 'Location: ' + data["location"][0]["@name"] + " (" +data["location"][0]["@id"] + ")" + ''; html += ''; - html += 'Return to result list...'; + html += 'Return to result list...'; return html; };