7 /image/print_images.mas - a component for printing images associated with your favorite objects (locus, accession etc.)
12 Requires the following javascript classes:
13 <& /util/import_javascript.mas, classes => ["jquery", "thickbox", "CXGN.Page.FormattingHelpers"] &>
15 Parameters have to be either image_objects OR images and dbh
27 dstabase handle (for instantiating new SGN::Image objects)
31 arrayref of SGN::Image objects
38 Naama Menda <nm249@cornell.edu>
48 $image_objects => undef
54 use CXGN::Page::FormattingHelpers qw / html_optional_show /;
58 my $m_image_html = "";
62 if ($images && !$image_objects) {
63 my @image_object_list = map { SGN::Image->new( $dbh , $_->[0] ) } @$images ;
64 $image_objects = \@image_object_list;
67 ###print qq{ <script src="jquery.colorbox-min.js"></script> };
69 if ($image_objects) { # don't display anything for empty list of images
70 $image_html .= qq|<table class="table table-bordered"><thead><tr><th><button class="btn btn-sm btn-default" id="print_images_multi_image_view">View Selected</button></th><th>Image</th><th>Description</th><th>Type</th></tr></thead><tbody>|;
72 foreach my $image_ob (@$image_objects) {
74 my $image_id = $image_ob->get_image_id;
75 my $image_name = $image_ob->get_name();
76 my $image_description = $image_ob->get_description();
77 my $image_img = $image_ob->get_image_url("medium");
78 my $original_img = $image_ob->get_image_url("large");
79 my $small_image = $image_ob->get_image_url("thumbnail");
80 my $image_page = "/image/view/$image_id";
82 ##$image_html .= qq { $(".stock_image_group").colorbox({rel:'stock_image_group'}); };
85 qq|<a href="$image_img" title="<a href=$image_page>Go to image page ($image_name)</a>" class="stock_image_group" rel="gallery-figures"><img src="$small_image" alt="$image_description" /></a> |;
86 my $multi_open_colorbox = qq|<a href="$image_img" title="<a href=$image_page>Go to image page ($image_name)</a>" class="stock_image_group" rel="gallery-figures"><img src="$original_img" alt="$image_description" /></a> |;
88 qq|<tr><td><input type="checkbox" name="print_images_checkbox" data-html_text='$multi_open_colorbox'></td><td>|
96 if ( $count < 3 ) { $image_html .= $fhtml; }
98 push @more_is, $fhtml;
99 } #more than 3 figures- show these in a hidden div
102 $image_html .= "</tbody></table>"; #close the table tag or the first 3 figures
104 $image_html .= "<script>
105 jQuery(document).ready(function() {
106 jQuery('a.stock_image_group').colorbox();
107 jQuery(document).on('click', '#print_images_multi_image_view', function(){
108 var colorbox_html = '';
109 jQuery(\"input:checkbox[name='print_images_checkbox']:checked\").each(function(){
110 var html = jQuery(this).data('html_text');
111 colorbox_html = colorbox_html + html + '<br/>';
113 if (colorbox_html != ''){
114 jQuery.colorbox({html:colorbox_html});
121 "<table class='table table-bordered'><thead><tr><th><button class='btn btn-sm btn-default' id='print_images_multi_image_view'>View Selected</button></th><th>Image</th><th>Description</th><th>Type</th></tr></thead><tbody>"; #open table tag for the hidden figures #4 and on
122 my $more = scalar(@more_is);
123 foreach (@more_is) { $m_image_html .= $_; }
125 $m_image_html .= "</tbody></table>"; #close tabletag for the hidden figures
127 if (@more_is) { #html_optional_show if there are more than 3 figures
128 $image_html .= html_optional_show(
130 "<b>See $more more images...</b>",
132 0, #< do not show by default
133 #'abstract_optional_show', #< don't use the default button-like style