use OpenILS::Application::AppUtils;
my $U = 'OpenILS::Application::AppUtils';
+our $ac_types = ['toc', 'anotes', 'excerpt', 'summary', 'reviews'];
+
# context additions:
# record : bre object
sub load_record {
return Apache2::Const::OK;
}
+sub added_content_avail1 {
+ my $self = shift;
+ my $ctx = $self->ctx;
+ $ctx->{added_content} = {
+ map {$_ => {status => 3, content => ''}} @$ac_types;
+ };
+
+ # fire requests
+}
+
+sub added_content_avail2 {
+ my $self = shift;
+ my $ctx = $self->ctx;
+
+ # collect requests
+}
+
+sub added_content_get_type {
+ my $self = shift;
+ my $ctx = $self->ctx;
+}
+
1;
</script>
[% END; # use_autosuggest %]
+<script type="text/javascript">
+ [% acTypes = ['toc', 'anotes', 'excerpt', 'summary', 'reviews'] %]
+
+ /* Checks to see if a given type of added content has data to show.
+ * The first arg to callback() is boolean indicating the presence of data.
+ */
+ function acIsAvailable(ident, type, callback) {
+ var url = '/opac/extras/ac/' + type + '/html/' + ident;
+ dojo.xhr('HEAD', {
+ url : url,
+ failOk : true, // http://bugs.dojotoolkit.org/ticket/11568
+ error : function(err) { callback(false, ident, type); },
+ load : function(result) { callback(true, ident, type); }
+ });
+ }
+
+ [%
+ IF ctx.page == 'record';
+ # XXX revisit when ident=ctx.bre_id
+ ident = ctx.record_attrs.isbn_clean || ctx.record_attrs.upc;
+ IF ident;
+ FOR type IN acTypes;
+ IF ctx.added_content.$type.status == '3' # status unknown %]
+ dojo.addOnLoad(function() {
+ var ident = '[% ident %]';
+ var type = '[% type %]';
+ acIsAvailable(ident, type, function(avail, ident, type) {
+ // if the content is available, un-hide the tab
+ if (avail) dojo.removeClass(dojo.byId('ac:' + type), 'hidden');
+ });
+ });
+ [% END; # IF status unknown
+ END;
+ END; # IF ident
+ END;
+ %]
+</script>
+
[%- END; # want_dojo -%]
--- /dev/null
+<div class='rdetail_extras_div'>
+
+[%
+ ac_types = {
+ reviews => l('Reviews'),
+ anotes => l('Author Notes'),
+ toc => l('Table of Contents'),
+ excerpt => l('Excerpt'),
+ summary => l('Summary')
+ };
+
+ tab_class = 'ac_tab';
+
+ # For each type of added content, render the link if it's known to have
+ # content, do not render the link if it's known to not have content. If
+ # the content status is unknown, render the link, but hide the link via CSS
+ # if dojo is enabled. If dojo is not enabled, render and display the link.
+
+ %]
+
+ <div id='ac_tab_wrapper'>
+ [% FOR type IN ac_types.keys
+ IF ctx.added_content.$type.status != '2'; # no content
+ IF ctx.added_content.$type.status == '3' AND want_dojo; # status unknown
+ tab_class = tab_class _ 'hidden';
+ END %]
+ <div class="[% tab_class %]" id="ac:[% type %]">
+ <a href="[% mkurl('', {ac => type}) _ '#addedcontent' %]">[% ac_types.$type %]</a>
+ </div>
+ [% END %]
+ </div>
+
+ <div id='ac_content'>
+ <hr/>
+ [%
+ ac_type = CGI.param('ac');
+ IF ac_type;
+ content = ctx.added_content.$ac_type.content;
+ IF content;
+ content;
+ ELSE;
+ l('No Content Available');
+ END;
+ END;
+ %]
+ </div>
+</div>
+
+
PROCESS "opac/parts/misc_util.tt2";
PROCESS get_marc_attrs args=attrs;
stop_parms = ['expand','cnoffset'];
+ ctx.record_attrs = attrs; # capture for JS
%]
<div id='canvas_main' class='canvas' itemscope itemtype='[% args.schema.itemtype %]'>
{name => 'excerpt', label => l('Excerpt'), hide => 1},
{name => 'issues', label => l('Issues Held'), hide => !(ctx.have_holdings_to_show || ctx.have_mfhd_to_show)},
{name => 'preview', label => l('Preview'), hide => 1},
+ {name => 'addedcontent', label => l('Additional Content')}, # hide if all content is known to not exist
{name => 'cnbrowse', label => l('Shelf Browser')},
{name => 'marchtml', label => l('MARC Record')}
];
<div class="rdetail_extras_link">
[%
IF tab_is_active(name);
- href = mkurl('', {}, ['expand']);
+ href = mkurl('', {}, ['expand', 'ac']);
img_url = ctx.media_prefix _ '/images/rdetail_arrow_down.png';
ELSE;
href = mkurl('', {expand => name}) _ '#' _ name;
margin: 1em;
border: thick solid red;
}
+
+#ac_tab_wrapper { width : 100%; }
+.ac_tab { float: left; padding-right: 10px; font-size: 110%; }
+#ac_content { clear: both; width: 100%; margin-top: 10px; }