[open-ils-commits] r17846 - branches/rel_2_0/Open-ILS/web/js/dojo/openils (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Sep 20 15:14:32 EDT 2010
Author: miker
Date: 2010-09-20 15:14:28 -0400 (Mon, 20 Sep 2010)
New Revision: 17846
Modified:
branches/rel_2_0/Open-ILS/web/js/dojo/openils/BibTemplate.js
Log:
Backport BibTemplate callback support from trunk
Modified: branches/rel_2_0/Open-ILS/web/js/dojo/openils/BibTemplate.js
===================================================================
--- branches/rel_2_0/Open-ILS/web/js/dojo/openils/BibTemplate.js 2010-09-20 18:25:07 UTC (rev 17845)
+++ branches/rel_2_0/Open-ILS/web/js/dojo/openils/BibTemplate.js 2010-09-20 19:14:28 UTC (rev 17846)
@@ -99,6 +99,16 @@
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,9 +117,20 @@
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;
}
+ // 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) {
+ 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 +168,12 @@
}
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));
More information about the open-ils-commits
mailing list