1 # Highslide JS Theme for MJ's Photo Gallery
2 # (c) 2012 Martin Mares <mj@ucw.cz>; GPL'ed
4 package UCW::Gallery::Web::HighSlide;
10 use UCW::Gallery::Web;
12 our @ISA = qw(UCW::Gallery::Web);
14 sub theme_head_extras($) {
16 my $hsdir = $self->get('ThemeUrlPrefix') . "highslide";
17 return $self->showing_image ? <<AMEN_MINI : <<AMEN_FULL ;
18 <link rel="stylesheet" type="text/css" href="$hsdir/custom.css">
20 <script type="text/javascript" src="$hsdir/highslide-with-gallery.js"></script>
21 <script type="text/javascript" src="$hsdir/custom.js" charset="utf-8"></script>
22 <script type="text/javascript">
23 hs.graphicsDir = '$hsdir/graphics/';
25 <link rel="stylesheet" type="text/css" href="$hsdir/highslide.css">
26 <link rel="stylesheet" type="text/css" href="$hsdir/custom.css">
28 <link rel="stylesheet" type="text/css" href="$hsdir/highslide-ie6.css">
33 sub show_links($$$$) {
34 my ($self, $prev, $up, $next) = @_;
35 my $nav = $self->get('ThemeUrlPrefix') . "highslide/nav";
36 print "<p class=parent>";
37 print "<a href='$prev'><img class=back prev src='$nav/prev.png'></a>" if $prev ne "";
38 printf "<a href='$next'><img class=fwd src='$nav/next.png'></a>" if $next ne "";
39 printf "<a href='$up'><img class=up src='$nav/back.png'></a>" if $up ne "";
42 sub show_pre_thumbs($) {
44 print "\n<div class='highslide-gallery'><ul>\n";
45 $self->{hs_thumb_counter} = 0;
48 sub show_post_thumbs($) {
50 print "</ul></div>\n\n";
54 my ($self, $meta, $photo_id, $click_url) = @_;
55 my $m = $meta->{photo}->{$photo_id};
56 my $annot = UCW::CGI::html_escape($m->{title});
57 my $tf = $self->get('ThumbFormats')->[0];
58 my $tm = $meta->{thumb}->{$tf}->{$photo_id} or die "No thumbnails for format $tf found!\n";
61 my $thumb = $self->get('ThumbUrlPrefix') . "$tf/$photo_id.jpg";
62 # Highslide requires title either for all images, or for none
63 my $tit = " title=\"$annot\"";
64 my $aid = $self->{hs_thumb_counter}++ ? "" : " id=thumb1";
65 my $photo_url = $self->get('PhotoUrlPrefix') . $self->{gal}->photo_name($m, $photo_id);
66 print "<li><a$aid href='$click_url' class=highslide onclick='return hs.expand(this, { src: \"$photo_url\" })'>";
67 print "<img src='$thumb' width=$tw height=$th alt='Photo'$tit></a>\n";
71 my ($class, $gal) = @_;
72 my $self = $class->SUPER::attach($gal);