1 | (function() { |
---|
2 | var session_storage = window.sessionStorage || {}; |
---|
3 | |
---|
4 | var menubar=jQuery("#menubar"), |
---|
5 | menuswitcher, |
---|
6 | content=jQuery("#the_page > .content"), |
---|
7 | pcontent=jQuery("#content"), |
---|
8 | imageInfos=jQuery("#imageInfos"), |
---|
9 | infoswitcher, |
---|
10 | theImage=jQuery("#theImage"), |
---|
11 | comments=jQuery("#thePicturePage #comments"), |
---|
12 | comments_button, |
---|
13 | commentsswitcher, |
---|
14 | comments_add, |
---|
15 | comments_top_offset = 0; |
---|
16 | |
---|
17 | if (session_storage['picture-menu'] == 'visible') { |
---|
18 | jQuery("head").append('<style>#content.contentWithMenu, #the_page > .content {margin-left:240px;}</style>'); |
---|
19 | } |
---|
20 | else { |
---|
21 | jQuery("head").append('<style>#the_page #menubar {display:none;} #content.contentWithMenu, #the_page > .content {margin-left:35px;}</style>'); |
---|
22 | } |
---|
23 | |
---|
24 | function hideMenu(delay) { |
---|
25 | menubar.hide(delay); |
---|
26 | menuswitcher.addClass("menuhidden").removeClass("menushown"); |
---|
27 | content.addClass("menuhidden").removeClass("menushown"); |
---|
28 | pcontent.addClass("menuhidden").removeClass("menushown"); |
---|
29 | session_storage['picture-menu'] = 'hidden'; |
---|
30 | } |
---|
31 | |
---|
32 | function showMenu(delay) { |
---|
33 | menubar.show(delay); |
---|
34 | menuswitcher.addClass("menushown").removeClass("menuhidden"); |
---|
35 | content.addClass("menushown").removeClass("menuhidden"); |
---|
36 | pcontent.addClass("menushown").removeClass("menuhidden"); |
---|
37 | session_storage['picture-menu'] = 'visible'; |
---|
38 | } |
---|
39 | |
---|
40 | function hideInfo(delay) { |
---|
41 | imageInfos.hide(delay); |
---|
42 | infoswitcher.addClass("infohidden").removeClass("infoshown"); |
---|
43 | theImage.addClass("infohidden").removeClass("infoshown"); |
---|
44 | session_storage['side-info'] = 'hidden'; |
---|
45 | } |
---|
46 | |
---|
47 | function showInfo(delay) { |
---|
48 | imageInfos.show(delay); |
---|
49 | infoswitcher.addClass("infoshown").removeClass("infohidden"); |
---|
50 | theImage.addClass("infoshown").removeClass("infohidden"); |
---|
51 | session_storage['side-info'] = 'visible'; |
---|
52 | } |
---|
53 | |
---|
54 | function commentsToggle() { |
---|
55 | if (comments.hasClass("commentshidden")) { |
---|
56 | comments.removeClass("commentshidden").addClass("commentsshown"); |
---|
57 | comments_button.addClass("comments_toggle_off").removeClass("comments_toggle_on");; |
---|
58 | session_storage['comments'] = 'visible'; |
---|
59 | comments_top_offset = comments_add.offset().top - parseFloat(comments_add.css('marginTop').replace(/auto/, 0)); |
---|
60 | } |
---|
61 | else { |
---|
62 | comments.addClass("commentshidden").removeClass("commentsshown"); |
---|
63 | comments_button.addClass("comments_toggle_on").removeClass("comments_toggle_off");; |
---|
64 | session_storage['comments'] = 'hidden'; |
---|
65 | comments_top_offset = 0; |
---|
66 | } |
---|
67 | } |
---|
68 | |
---|
69 | jQuery(function(){ |
---|
70 | // side-menu show/hide |
---|
71 | if (menubar.length == 1 && p_main_menu!="disabled") { |
---|
72 | menuswitcher=jQuery("#menuSwitcher"); |
---|
73 | |
---|
74 | menuswitcher.html('<div class="switchArrow"> </div>'); |
---|
75 | |
---|
76 | if (session_storage['picture-menu'] == undefined && p_main_menu == 'off') { |
---|
77 | session_storage['picture-menu'] = 'hidden'; |
---|
78 | } |
---|
79 | |
---|
80 | if (session_storage['picture-menu'] == 'hidden') { |
---|
81 | hideMenu(0); |
---|
82 | } |
---|
83 | else { |
---|
84 | showMenu(0); |
---|
85 | } |
---|
86 | |
---|
87 | menuswitcher.click(function(e){ |
---|
88 | if (menubar.is(":hidden")) { |
---|
89 | showMenu(0); |
---|
90 | } |
---|
91 | else { |
---|
92 | hideMenu(0); |
---|
93 | } |
---|
94 | e.preventDefault(); |
---|
95 | }); |
---|
96 | } |
---|
97 | |
---|
98 | // info show/hide |
---|
99 | if (imageInfos.length == 1 && p_pict_descr!="disabled") { |
---|
100 | infoswitcher=jQuery("#infoSwitcher"); |
---|
101 | |
---|
102 | infoswitcher.html('<div class="switchArrow"> </div>'); |
---|
103 | |
---|
104 | if (session_storage['side-info'] == undefined && p_pict_descr == 'off') { |
---|
105 | session_storage['side-info'] = 'hidden'; |
---|
106 | } |
---|
107 | |
---|
108 | if (session_storage['side-info'] == 'hidden') { |
---|
109 | hideInfo(0); |
---|
110 | } |
---|
111 | else { |
---|
112 | showInfo(0); |
---|
113 | } |
---|
114 | |
---|
115 | infoswitcher.click(function(e){ |
---|
116 | if (imageInfos.is(":hidden")) { |
---|
117 | showInfo(0); |
---|
118 | } |
---|
119 | else { |
---|
120 | hideInfo(0); |
---|
121 | } |
---|
122 | e.preventDefault(); |
---|
123 | }); |
---|
124 | } |
---|
125 | |
---|
126 | // comments show/hide |
---|
127 | if (comments.length == 1 && p_pict_comment!="disabled") { |
---|
128 | commentsswitcher=jQuery("#commentsSwitcher"); |
---|
129 | comments_button=jQuery("#comments h3"); |
---|
130 | comments_add=jQuery('#commentAdd'); |
---|
131 | |
---|
132 | commentsswitcher.html('<div class="switchArrow"> </div>'); |
---|
133 | |
---|
134 | if (comments_button.length == 0) { |
---|
135 | jQuery("#addComment").before("<h3>Comments</h3>"); |
---|
136 | comments_button=jQuery("#comments h3"); |
---|
137 | } |
---|
138 | |
---|
139 | if (session_storage['comments'] == undefined && p_pict_comment == 'off') { |
---|
140 | session_storage['comments'] = 'hidden'; |
---|
141 | } |
---|
142 | |
---|
143 | if (session_storage['comments'] == 'hidden') { |
---|
144 | comments.addClass("commentshidden"); |
---|
145 | comments_button.addClass("comments_toggle comments_toggle_on"); |
---|
146 | } |
---|
147 | else { |
---|
148 | comments.addClass("commentsshown"); |
---|
149 | comments_button.addClass("comments_toggle comments_toggle_off"); |
---|
150 | } |
---|
151 | |
---|
152 | comments_button.click(commentsToggle); |
---|
153 | commentsswitcher.click(commentsToggle); |
---|
154 | |
---|
155 | jQuery(window).scroll(function (event) { |
---|
156 | if (comments_top_offset==0) return; |
---|
157 | |
---|
158 | var y = jQuery(this).scrollTop(); |
---|
159 | |
---|
160 | if (y >= comments_top_offset) { |
---|
161 | comments_add.css({ |
---|
162 | 'position': 'absolute', |
---|
163 | 'top': y-comments.offset().top+10 |
---|
164 | }); |
---|
165 | } |
---|
166 | else { |
---|
167 | comments_add.css({ |
---|
168 | 'position': 'static', |
---|
169 | 'top': 0 |
---|
170 | }); |
---|
171 | } |
---|
172 | }); |
---|
173 | |
---|
174 | if (comments_add.is(":visible")) { |
---|
175 | comments_top_offset = comments_add.offset().top - parseFloat(comments_add.css('marginTop').replace(/auto/, 0)); |
---|
176 | } |
---|
177 | } |
---|
178 | }); |
---|
179 | }()); |
---|