]> mj.ucw.cz Git - gallery.git/blob - highslide/custom.js
Highslide: Fix page jumps when closing thumbnails
[gallery.git] / highslide / custom.js
1 /*
2  *      Site-specific configuration settings for Highslide JS
3  */
4
5 hs.showCredits = true;
6 hs.creditsPosition = 'top right';
7 hs.outlineType = 'rounded-black';
8 hs.fadeInOut = false;
9 hs.align = 'center';
10 hs.useBox = true;
11 hs.width = 1080;
12 hs.height = 840;
13 // hs.allowMultipleInstances = false;
14 hs.captionEval = 'this.thumb.title';
15 hs.captionOverlay = { position: "top" };
16 hs.expandDuration = 100;
17 hs.restoreDuration = 100;
18 hs.dimmingDuration = 100;
19 hs.dimmingOpacity = 0.8;
20 hs.transitionDuration = 100;
21 hs.thumbnailId = 'thumb1';
22 hs.numberPosition = 'caption';
23 hs.transitions = ['expand', 'crossfade'];
24
25 hs.addSlideshow({
26         interval: 5000,
27         repeat: false,
28         useControls: true,
29         fixedControls: 'fit',
30         overlayOptions: {
31                 className: 'controls-in-heading',
32                 opacity: 0.6,
33                 position: 'top center',
34                 hideOnMouseOut: true
35         },
36         thumbstrip: {
37                 mode: 'horizontal',
38                 position: 'below',
39                 relativeTo: 'expander'
40         }
41 });
42
43
44 ////////////////////////////////////////////////
45 // Dynamic change of the hash part of the URL //
46 ////////////////////////////////////////////////
47 var hashTag = '';
48 // Use hashDelimiter to "hide" name of the anchor (and to not scroll the page)
49 var hashDelimiter = '_';
50
51 hs.extend (hs.Expander.prototype, {
52         onAfterExpand: function(sender) {
53                 hashTag = this.a.id;
54                 window.location.hash = hashDelimiter + hashTag;
55         },
56
57         onBeforeClose: function(sender) {
58                 window.location.hash = hashDelimiter;
59         }
60 });
61
62 function showDefaultImage() {
63         var hashParts = window.location.hash.split(hashDelimiter);
64         var myThumb = document.getElementById(hashParts[1])
65         if (hashParts[1] && myThumb) myThumb.click();
66 }
67 // If the new hash is not equal to the hash we store internally,
68 // then it must be the user hitting the "back/forward" button
69 function checkHashChange() {
70         var hashParts = window.location.hash.split(hashDelimiter);
71         if (hashParts[1] != hashTag) {
72                 hs.close();
73                 window.location.hash = hashDelimiter;
74         }
75 }
76
77 // Add onLoad and onHashChange functions
78 if(window.onload) {
79         var current = window.onload;
80         var newAction = function() {
81                 current();
82                 showDefaultImage();
83         };
84         window.onload = newAction;
85 } else window.onload = showDefaultImage;
86
87 if(window.onhashchange) {
88         var current = window.onHashChange;
89         var newAction = function() {
90                 current();
91                 checkHashChange();
92         };
93         window.onhashchange = newAction;
94 } else window.onhashchange = checkHashChange;