add pre- and post-render callback capabilities to BibTemplate
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sat, 18 Sep 2010 17:53:56 +0000 (17:53 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sat, 18 Sep 2010 17:53:56 +0000 (17:53 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@17809 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/js/dojo/openils/BibTemplate.js

index 5827a6e..6154e5c 100644 (file)
@@ -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));