my $thumb = $self->get('ThumbUrlPrefix') . "$tf/$photo_id.jpg";
# Highslide requires title either for all images, or for none
my $tit = " title=\"$annot\"";
- my $aid = $self->{hs_thumb_counter}++ ? "" : " id=thumb1";
+ my $aid = 'i'.(++$self->{hs_thumb_counter});
my $photo_url = $self->get('PhotoUrlPrefix') . $self->{gal}->photo_file_name($m, $photo_id);
- print "<li><a$aid href='$click_url' class=highslide onclick='return hs.expand(this, { src: \"$photo_url\" })'>";
+ print "<li><a id='$aid' href='$click_url' class=highslide onclick='return hs.expand(this, { src: \"$photo_url\" })'>";
print "<img src='$thumb' width=$tw height=$th alt='Photo'$tit></a>\n";
}
relativeTo: 'expander'
}
+
+////////////////////////////////////////////////
+// Dynamic change of the hash part of the URL //
+////////////////////////////////////////////////
+var hashTag = '';
+// Use hashDelimiter to "hide" name of the anchor (and to not scroll the page)
+var hashDelimiter = '_';
+
+hs.extend (hs.Expander.prototype, {
+ onAfterExpand: function(sender) {
+ hashTag = this.a.id;
+ window.location.hash = hashDelimiter + hashTag;
+ },
+
+ onBeforeClose: function(sender) {
+ window.location.hash = '';
+ }
});
+
+function showDefaultImage() {
+ var hashParts = window.location.hash.split(hashDelimiter);
+ var myThumb = document.getElementById(hashParts[1])
+ if (hashParts[1] && myThumb) myThumb.click();
+ else window.location.hash = '';
+}
+// If the new hash is not equal to the hash we store internally,
+// then it must be the user hitting the "back/forward" button
+function checkHashChange() {
+ var hashParts = window.location.hash.split(hashDelimiter);
+ if (hashParts[1] != hashTag) {
+ hs.close();
+ window.location.hash = '';
+ }
+}
+
+// Add onLoad and onHashChange functions
+if(window.onload) {
+ var current = window.onload;
+ var newAction = function() {
+ current();
+ showDefaultImage();
+ };
+ window.onload = newAction;
+} else window.onload = showDefaultImage;
+
+if(window.onhashchange) {
+ var curronload = window.onHashChange;
+ var newAction = function() {
+ current();
+ checkHashChange();
+ };
+ window.onhashchange = newAction;
+} else window.onhashchange = checkHashChange;