From 2e752203adf926313aeddd4efcbc5f329699b3ca Mon Sep 17 00:00:00 2001 From: miker Date: Sat, 18 Sep 2010 19:06:34 +0000 Subject: [PATCH] more callbacks, this time pre- and post-query git-svn-id: svn://svn.open-ils.org/ILS/trunk@17812 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/js/dojo/openils/BibTemplate.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Open-ILS/web/js/dojo/openils/BibTemplate.js b/Open-ILS/web/js/dojo/openils/BibTemplate.js index 6154e5c83c..790d16a60e 100644 --- a/Open-ILS/web/js/dojo/openils/BibTemplate.js +++ b/Open-ILS/web/js/dojo/openils/BibTemplate.js @@ -99,6 +99,16 @@ if(!dojo._hasResource["openils.BibTemplate"]) { var item_limit = parseInt(slot.getAttribute('limit')); var item_offset = parseInt(slot.getAttribute('offset')) || 0; + var pre_render_callbacks = dojo.query( '*[type=opac/call-back+pre-render]', slot ); + var post_render_callbacks = dojo.query( '*[type=opac/call-back+post-render]', slot ); + var pre_query_callbacks = dojo.query( '*[type=opac/call-back+pre-query]', slot ); + var post_query_callbacks = dojo.query( '*[type=opac/call-back+post-query]', slot ); + + // Do pre-query stuff + dojo.forEach(pre_query_callbacks, function (cb) { + try { (new Function( 'BT', 'slotXML', 'slot', unescape(cb.innerHTML) ))(BT,bib,slot) } catch (e) {/*meh*/} + }); + var item_list = dojo.query( slot.getAttribute('query'), bib @@ -107,11 +117,14 @@ if(!dojo._hasResource["openils.BibTemplate"]) { if (item_limit) { if (debug) alert('BibTemplate debug -- item list limit/offset requested: ' + item_limit + '/' + item_offset); if (item_list.length) item_list = BT.subsetNL(item_list, item_offset, item_offset + item_limit); - if (!item_list.length) return; } - var pre_render_callbacks = dojo.query( '*[type=opac/call-back+pre-render]', slot ); - var post_render_callbacks = dojo.query( '*[type=opac/call-back+post-render]', slot ); + // Do post-query stuff, only if there's an item list! + dojo.forEach(post_query_callbacks, function (cb) { + try { (new Function( 'item_list', 'BT', 'slotXML', 'slot', unescape(cb.innerHTML) ))(item_list,BT,bib,slot) } catch (e) {/*meh*/} + }); + + if (!item_list.length) return; // Do pre-render stuff dojo.forEach(pre_render_callbacks, function (cb) { -- 2.11.0