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();
};
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);
};
// 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]) {
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();
+ }
};
};
mkdru.search = function () {
- $('.mkdru-detail').hide();
mkdru.pz2.search(mkdru.state.query, mkdru.state.perpage, mkdru.state.sort,
mkdru.state.filter);
};
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();
}
};
-Drupal.theme.prototype.mkdruResult = function(hit, num) {
+Drupal.theme.prototype.mkdruResult = function(hit, num, detailLink) {
var html = "";
html += '<li class="mkdru-result" id="rec_' + hit.recid + '" >'
+ '<span>' + num + '. </span>'
- + '<a href="#" class="mkdru-result-title">'
+ + '<a href="' + detailLink + '" class="mkdru-result-title">'
+ hit["md-title"] + '</a> ';
if (hit["md-title-remainder"] !== undefined) {
html += '<span class="mkdru-result-title-remainder">'
if (data["location"][0]["@name"] != undefined)
html += '<tr><td><b>Location</b></td><td><b>:</b> ' + data["location"][0]["@name"] + " (" +data["location"][0]["@id"] + ")" + '</td></tr>';
html += '</table></div>';
- html += '<a class="mkdru-result-back">Return to result list...</a>';
+ html += '<a class="mkdru-detail-back">Return to result list...</a>';
return html;
};