From 08ecde1707ee12aa3e7fe0f7ee150627a03acab5 Mon Sep 17 00:00:00 2001 From: miker Date: Sat, 18 Sep 2010 17:53:56 +0000 Subject: [PATCH] add pre- and post-render callback capabilities to BibTemplate git-svn-id: svn://svn.open-ils.org/ILS/trunk@17809 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/js/dojo/openils/BibTemplate.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Open-ILS/web/js/dojo/openils/BibTemplate.js b/Open-ILS/web/js/dojo/openils/BibTemplate.js index 5827a6e03..6154e5c83 100644 --- a/Open-ILS/web/js/dojo/openils/BibTemplate.js +++ b/Open-ILS/web/js/dojo/openils/BibTemplate.js @@ -110,6 +110,14 @@ if(!dojo._hasResource["openils.BibTemplate"]) { 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 pre-render stuff + dojo.forEach(pre_render_callbacks, function (cb) { + try { (new Function( 'item_list', 'BT', 'slotXML', 'slot', unescape(cb.innerHTML) ))(item_list,BT,bib,slot) } catch (e) {/*meh*/} + }); + var templated = slot.getAttribute('templated') == 'true'; if (debug) alert('BibTemplate debug -- slot ' + (templated ? 'is' : 'is not') + ' templated'); if (templated) { @@ -147,6 +155,12 @@ if(!dojo._hasResource["openils.BibTemplate"]) { } delete(slot_handler); + + // Do post-render stuff + dojo.forEach(post_render_callbacks, function (cb) { + try { (new Function( 'item_list', 'BT', 'slotXML', 'slot', unescape(cb.innerHTML) ))(item_list,BT,bib,slot) } catch (e) {/*meh*/} + }); + } catch (e) { if (debug) { alert('BibTemplate Error: ' + e + '\n' + dojo.toJson(e)); -- 2.11.0