X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=mkdru.client.js;h=03f950715247c326c3adba90f5581486f718a14b;hb=e3b03d604b74604d2a67cb4d765f5d8d18a3d057;hp=73571020f11880bf61c795c153d85404b9d006db;hpb=89996d58c6ef47fdba1944a4d4c6fde026f07d63;p=mkdru-moved-to-drupal.org.git diff --git a/mkdru.client.js b/mkdru.client.js index 7357102..03f9507 100644 --- a/mkdru.client.js +++ b/mkdru.client.js @@ -30,7 +30,7 @@ var mkdru = { perpage: 20, sort: 'relevance', filter: null, - query:null, + query:'', recid:null }, state: {}, @@ -39,6 +39,9 @@ var mkdru = { +// Wrapper for jQuery +(function ($) { + // So we can use jQuery BBQ with Drupal 6 and its 1.2.6 jQuery if (!$.isArray) $.isArray = function(obj) { return Object.prototype.toString.call(obj) === "[object Array]"; @@ -131,8 +134,8 @@ mkdru.pz2ByTarget = function (data) { mkdru.pz2Record = function (data) { clearTimeout(mkdru.pz2.showTimer); $('.mkdru-results').hide(); - $('.mkdru-detail').html(Drupal.theme('mkdruDetail', data)); - $('.mkdru-detail-back').bind('click', function () {$.bbq.removeState('recid');}); + $('.mkdru-detail').html(Drupal.theme('mkdruDetail', data, + mkdru.hashAddDelOne(null, null, 'recid'))); $('.mkdru-detail').show(); clearTimeout(mkdru.pz2.recordTimer); }; @@ -191,9 +194,9 @@ mkdru.hashChange = function () { } // Other internal link else { - // need to run search again to limit targets + // may need to run search again to limit targets for (key in mkdru.state) { - if (key.substring(0,5) === 'limit') { + if (key.substring(0,5) === 'limit' && mkdru.state[key]) { mkdru.search(); break; } @@ -326,6 +329,7 @@ $(document).ready(function () { if (typeof(Drupal.settings.mkdru.query) !== "undefined") { mkdru.state.query = Drupal.settings.mkdru.query } + //not running against SP? init, otherwise authenticate if (mkdru.useSessions) { mkdru.pz2.init(); @@ -349,7 +353,7 @@ $(document).ready(function () { ); authReq.get(params, function (data) { - var s = data.getElementsByTagName('status'); + var s = data.getElementsByTagName('status'); if (s.length && Element_getTextContent(s[0]) == "OK") { mkdru.realm = data.getElementsByTagName('realm'); mkdru.pz2Init(); @@ -360,13 +364,5 @@ $(document).ready(function () { } ); } - - //I'm not sure how this can work, it assumes the search is in a proper state? - if (mkdru.state.recid) { - mkdru.pz2.record(mkdru.state.recid); - } - //mkdru.onInit deals with this in a more proper way - else if (mkdru.state.query) { - mkdru.search(); - } }); +})(jQuery); \ No newline at end of file