2 <script type="text/javascript">
4 /* Checks to see if a given type of added content has data to show.
5 * The first arg to callback() is boolean indicating the presence of data */
6 function acIsAvailable(ident, type, callback) {
7 var url = '/opac/extras/ac/' + type + '/html/' + ident;
10 failOk : true, // http://bugs.dojotoolkit.org/ticket/11568
11 error : function(err) { callback(false, ident, type); },
12 load : function(result) { callback(true, ident, type); }
16 [%- # XXX revisit when ident=ctx.bre_id
17 ident = ctx.record_attrs.isbn_clean || ctx.record_attrs.upc;
19 FOR type IN ctx.added_content.keys;
20 IF ctx.added_content.$type.status == '3' # status unknown %]
22 dojo.addOnLoad(function() {
23 var ident = '[% ident %]';
24 var type = '[% type %]';
26 acIsAvailable(ident, type, function(avail, ident, type) {
29 [% IF CGI.param('expand') == 'addedcontent' %]
31 // if the content is available, un-hide the tab
32 dojo.removeClass(dojo.byId('ac:' + type), 'hidden');
35 // if no default type is selected on the main tab link
36 // set one here, since we have available content
38 var link = dojo.query('[name=addedcontent]')[0];
39 var href = link.getAttribute('href');
40 if (!href.match('[\&;]ac=')) {
41 href = href.replace('#addedcontent', ';ac=' + type + '#addedcontent');
42 dojo.attr(link, 'href', href);
43 dojo.attr(dojo.query('[name=addedcontent_lbl]')[0], 'href', href);
50 [% END; # IF status unknown