[open-ils-commits] r16386 - in trunk: . Open-ILS/web/js/dojo/openils (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue May 4 14:06:51 EDT 2010
Author: miker
Date: 2010-05-04 14:06:47 -0400 (Tue, 04 May 2010)
New Revision: 16386
Modified:
trunk/
trunk/Open-ILS/web/js/dojo/openils/BibTemplate.js
Log:
custom "splice" method, spelled subsetNL -- supplied dojo version is not happy; debugging aids; js error protection
Property changes on: trunk
___________________________________________________________________
Name: bzr:revision-info
- timestamp: 2010-05-04 11:06:23.994999886 -0400
committer: Mike Rylander <miker at esilibrary.com>
properties:
branch-nick: trunk
+ timestamp: 2010-05-04 14:06:46.388999939 -0400
committer: Mike Rylander <miker at esilibrary.com>
properties:
branch-nick: trunk
Name: bzr:file-ids
- Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm 15833 at dcc99617-32d9-48b4-a31d-7c20da2025e4:trunk%2FOpen-ILS%2Fsrc%2Fperlmods%2FOpenILS%2FApplication%2FStorage%2FDriver%2FPg%2FQueryParser.pm
+ Open-ILS/web/js/dojo/openils/BibTemplate.js 13010 at dcc99617-32d9-48b4-a31d-7c20da2025e4:trunk%2FOpen-ILS%2Fweb%2Fjs%2Fdojo%2Fopenils%2FBibTemplate.js
Name: bzr:revision-id:v4
- 11741 phasefx at batrepo-20091014063041-ama3i5s87ziqohxo
11742 phasefx at batrepo-20091014063644-pn3a6urkw3uxgr6n
12108 phasefx at batrepo-20091120084700-lavt73oserscgalf
12166 jason at esilibrary.com-20091202233906-g8kh2kh3qmmz66r1
12184 jason at esilibrary.com-20091204161020-0dqezh01c05btffh
12198 jason at esilibrary.com-20091208140008-eofwdbn2u8dxk2kk
12199 jason at esilibrary.com-20091208155412-4qdzy8sgs51vm0yq
12215 jason at esilibrary.com-20091209133642-bp8mb3tc5vpoc1ij
12220 jason at esilibrary.com-20091209143447-i1st1to8ln4hhwyb
12231 jason at esilibrary.com-20091209221438-vv4crqppm8ajj3dr
12804 jason at esilibrary.com-20100324194046-jza2ic2dlpq8txhc
12946 miker at esilibrary.com-20100402183612-8xznj35wfohk7zyu
12955 miker at esilibrary.com-20100403141037-h8d57ryrmkkg9yhb
12971 miker at whirly-20100405202254-aztbsf3p3eey9e8e
12997 miker at esilibrary.com-20100408154146-zodwuxxizwf0y449
13010 miker at miker-msi-20100409021618-5f0ohbg5cgi5pai0
13014 miker at esilibrary.com-20100409135406-mitf09aw1srnps3g
13022 miker at esilibrary.com-20100412144909-fc4bx1n80ac0z8ox
13023 miker at esilibrary.com-20100412145629-92g9jts2k8yqsm38
13152 miker at esilibrary.com-20100503010126-67i6kclipxip27du
13153 miker at esilibrary.com-20100503010322-3ri56680p7bf4o26
13161 miker at esilibrary.com-20100504150623-34h9t5p64cd52swu
+ 11741 phasefx at batrepo-20091014063041-ama3i5s87ziqohxo
11742 phasefx at batrepo-20091014063644-pn3a6urkw3uxgr6n
12108 phasefx at batrepo-20091120084700-lavt73oserscgalf
12166 jason at esilibrary.com-20091202233906-g8kh2kh3qmmz66r1
12184 jason at esilibrary.com-20091204161020-0dqezh01c05btffh
12198 jason at esilibrary.com-20091208140008-eofwdbn2u8dxk2kk
12199 jason at esilibrary.com-20091208155412-4qdzy8sgs51vm0yq
12215 jason at esilibrary.com-20091209133642-bp8mb3tc5vpoc1ij
12220 jason at esilibrary.com-20091209143447-i1st1to8ln4hhwyb
12231 jason at esilibrary.com-20091209221438-vv4crqppm8ajj3dr
12804 jason at esilibrary.com-20100324194046-jza2ic2dlpq8txhc
12946 miker at esilibrary.com-20100402183612-8xznj35wfohk7zyu
12955 miker at esilibrary.com-20100403141037-h8d57ryrmkkg9yhb
12971 miker at whirly-20100405202254-aztbsf3p3eey9e8e
12997 miker at esilibrary.com-20100408154146-zodwuxxizwf0y449
13010 miker at miker-msi-20100409021618-5f0ohbg5cgi5pai0
13014 miker at esilibrary.com-20100409135406-mitf09aw1srnps3g
13022 miker at esilibrary.com-20100412144909-fc4bx1n80ac0z8ox
13023 miker at esilibrary.com-20100412145629-92g9jts2k8yqsm38
13152 miker at esilibrary.com-20100503010126-67i6kclipxip27du
13153 miker at esilibrary.com-20100503010322-3ri56680p7bf4o26
13161 miker at esilibrary.com-20100504150623-34h9t5p64cd52swu
13163 miker at esilibrary.com-20100504180646-77rxefvetqkiyo3s
Name: bzr:text-parents
- Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm svn-v4:dcc99617-32d9-48b4-a31d-7c20da2025e4:trunk:16028
+ Open-ILS/web/js/dojo/openils/BibTemplate.js miker at esilibrary.com-20100503010322-3ri56680p7bf4o26
Modified: trunk/Open-ILS/web/js/dojo/openils/BibTemplate.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/BibTemplate.js 2010-05-04 15:13:42 UTC (rev 16385)
+++ trunk/Open-ILS/web/js/dojo/openils/BibTemplate.js 2010-05-04 18:06:47 UTC (rev 16386)
@@ -43,6 +43,14 @@
}
},
+ subsetNL : function (old_nl, start, end) {
+ var new_nl = new dojo.NodeList();
+ for (var i = start; i < end && i < old_nl.length - 1; i++) {
+ new_nl.push(old_nl[i]);
+ }
+ return new_nl;
+ },
+
render : function() {
var all_slots = dojo.query('*[type^=opac/slot-data]', this.root);
@@ -93,48 +101,63 @@
load: function (bib) {
dojo.forEach(args.slot_list, function (slot) {
- var joiner = slot.getAttribute('join') || ' ';
- var item_limit = slot.getAttribute('limit');
- var item_offset = slot.getAttribute('offset') || 0;
+ var debug = slot.getAttribute('debug') == 'true';
- var item_list = dojo.query(
- slot.getAttribute('query'),
- bib
- );
+ try {
+ var joiner = slot.getAttribute('join') || ' ';
+ var item_limit = parseInt(slot.getAttribute('limit'));
+ var item_offset = parseInt(slot.getAttribute('offset')) || 0;
- if (parseInt(item_limit)) item_list = item_list.splice(parseInt(item_offset),parseInt(item_limit));
- if (!item_list.length) return;
+ var item_list = dojo.query(
+ slot.getAttribute('query'),
+ bib
+ );
- var templated = slot.getAttribute('templated') == 'true';
- if (templated) {
- var template_values = {};
+ 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;
+ }
- dojo.query(
- '*[type=opac/template-value]',
- slot
- ).orphan().forEach(function(x) {
- dojo.setObject(
- x.getAttribute('name'),
- (new Function( 'item_list', 'BT', 'slotXML', 'slot', unescape(x.innerHTML) ))(item_list,BT,bib,slot),
- template_values
- );
- });
+ var templated = slot.getAttribute('templated') == 'true';
+ if (debug) alert('BibTemplate debug -- slot ' + (templated ? 'is' : 'is not') + ' templated');
+ if (templated) {
+ var template_values = {};
- slot.innerHTML = dojo.string.substitute( unescape(slot.innerHTML), template_values );
- }
+ dojo.query(
+ '*[type=opac/template-value]',
+ slot
+ ).orphan().forEach(function(x) {
+ dojo.setObject(
+ x.getAttribute('name'),
+ (new Function( 'item_list', 'BT', 'slotXML', 'slot', unescape(x.innerHTML) ))(item_list,BT,bib,slot),
+ template_values
+ );
+ });
+
+ slot.innerHTML = dojo.string.substitute( unescape(slot.innerHTML), template_values );
+ }
- var handler_node = dojo.query( '*[type=opac/slot-format]', slot )[0];
- if (handler_node) slot_handler = new Function('item_list', 'BT', 'slotXML', 'slot', 'item', dojox.data.dom.textContent(handler_node) || handler_node.innerHTML);
- else slot_handler = new Function('item_list', 'BT', 'slotXML', 'slot', 'item','return dojox.data.dom.textContent(item) || item.innerHTML;');
-
- if (item_list.length) {
- var content = dojo.map(item_list, dojo.partial(slot_handler,item_list,BT,bib,slot)).join(joiner);
- if (templated) handler_node.parentNode.replaceChild( dojo.doc.createTextNode( content ), handler_node );
- else slot.innerHTML = content;
- }
+ var handler_node = dojo.query( '*[type=opac/slot-format]', slot )[0];
+ if (handler_node) slot_handler = new Function('item_list', 'BT', 'slotXML', 'slot', 'item', dojox.data.dom.textContent(handler_node) || handler_node.innerHTML);
+ else slot_handler = new Function('item_list', 'BT', 'slotXML', 'slot', 'item','return dojox.data.dom.textContent(item) || item.innerHTML;');
- delete(slot_handler);
+ if (item_list.length) {
+ var content = dojo.map(item_list, dojo.partial(slot_handler,item_list,BT,bib,slot)).join(joiner);
+ if (templated) {
+ if (handler_node) handler_node.parentNode.replaceChild( dojo.doc.createTextNode( content ), handler_node );
+ } else {
+ slot.innerHTML = content;
+ }
+ }
+ delete(slot_handler);
+ } catch (e) {
+ if (debug) {
+ alert('BibTemplate Error: ' + e + '\n' + dojo.toJson(e));
+ throw(e);
+ }
+ }
});
}
});
More information about the open-ils-commits
mailing list