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 my $theme_name = "plain";
24 return $self->get('ThemeUrlPrefix') . $theme_name;
27 sub theme_head_extras($) {
29 my $tdir = $self->theme_dir;
30 my $hsdir = $self->get('ThemeUrlPrefix') . "highslide";
32 <link rel=stylesheet href='$tdir/style.css' type='text/css' media=all>
33 <script type="text/javascript" src="$hsdir/highslide-with-gallery.js"></script>
34 <script type="text/javascript" src="$hsdir/highslide.config.js" charset="utf-8"></script>
35 <script type="text/javascript">
36 hs.graphicsDir = '$hsdir/graphics/';
38 <link rel="stylesheet" type="text/css" href="$hsdir/highslide.css">
40 <link rel="stylesheet" type="text/css" href="$hsdir/highslide-ie6.css">
45 sub show_links($$$$) {
46 my ($self, $prev, $up, $next) = @_;
47 my $theme = $self->theme_dir;
48 print "<p class=parent>";
49 print "<span class=back style='width: ${navw}px; height: ${navh}px'>";
50 print "<a href='$prev'><img src='$theme/prev.png' width=${navw} height=${navh} alt='Back'></a>" if $prev ne "";
52 printf "<span class=fwd style='width: ${navw}px; height: ${navh}px'>";
53 printf "<a href='$next'><img src='$theme/next.png' width=${navw} height=${navh} alt='Forward'></a>" if $next ne "";
55 printf "<a href='$up'><img src='$theme/back.png' width=${navw} height=${navh} alt='Up'></a>" if $up ne "";
58 sub show_pre_thumbs($) {
60 print "\n<div class='highslide-gallery'><ul>\n";
61 $self->{hs_thumb_counter} = 0;
64 sub show_post_thumbs($) {
66 print "</ul></div>\n\n";
70 my ($self, $meta, $photo_id, $click_url) = @_;
71 my $theme = $self->theme_dir;
72 my $m = $meta->{photo}->{$photo_id};
73 my $annot = UCW::CGI::html_escape($m->{title});
74 my $tf = $self->{thumb_fmt};
75 my $tm = $meta->{thumb}->{$tf}->{$photo_id} or die "No thumbnails for format $tf found!\n";
78 my $thumb = $self->get('ThumbUrlPrefix') . "$tf/$photo_id.jpg";
79 # HighSlide requires title either for all images, or for none
80 my $tit = " title=\"$annot\"";
81 my $aid = $self->{hs_thumb_counter}++ ? "" : " id=thumb1";
82 my $photo_url = $self->get('PhotoUrlPrefix') . "$photo_id.jpg";
83 print "<li><a$aid href='$click_url' class=highslide onclick='return hs.expand(this, { src: \"$photo_url\" })'>";
84 print "<img src='$thumb' width=$tw height=$th alt='Photo'$tit></a>\n";
88 my ($class, $gal) = @_;
89 my $self = $class->SUPER::attach($gal);
90 $self->{thumb_fmt} = $gal->require_thumbnails($thumb_w, $thumb_h);