1 | var showtabs; |
---|
2 | var selectedTab; |
---|
3 | var interfaceTimerDelay; |
---|
4 | var isScrollable; |
---|
5 | var zoomMode; |
---|
6 | |
---|
7 | jQuery("document").ready(function(jQuery) { |
---|
8 | |
---|
9 | zoomMode=options.defaultZoomSize; |
---|
10 | |
---|
11 | // display alt from PWG stuffs actions |
---|
12 | |
---|
13 | var stuffs_actions=jQuery(".categoryActions",".stuffs_block .stuffs"); |
---|
14 | |
---|
15 | if (stuffs_actions.length != 0) { |
---|
16 | stuffs_actions.each(function(index) { |
---|
17 | var images=jQuery(this).find("img"); |
---|
18 | if (images.length !=0) { |
---|
19 | images.each(function(index) { |
---|
20 | var alt_text = (jQuery(this).attr("alt")); |
---|
21 | jQuery(this).before(alt_text); |
---|
22 | jQuery(this).parents("li").css("width","auto"); |
---|
23 | jQuery(this).remove(); |
---|
24 | }); |
---|
25 | } |
---|
26 | }); |
---|
27 | } |
---|
28 | |
---|
29 | // gmaps icon |
---|
30 | |
---|
31 | var icon_gmaps=jQuery("#icon_gmaps"); |
---|
32 | var text_gmaps=jQuery("#text_gmaps"); |
---|
33 | if ((icon_gmaps.length == 1) && (text_gmaps.length ==1)) { |
---|
34 | icon_gmaps.text(text_gmaps.text()); |
---|
35 | icon_gmaps.css("text-align","right"); |
---|
36 | icon_gmaps.wrapAll('<li>'); |
---|
37 | } |
---|
38 | |
---|
39 | // Tabs |
---|
40 | |
---|
41 | var tab_loaded=0; |
---|
42 | var delay=400; |
---|
43 | var hfirst; |
---|
44 | if (jQuery.browser.msie) {hfirst=false;} else {hfirst=true;} |
---|
45 | |
---|
46 | var tab_titles=jQuery(".tabTitle"); |
---|
47 | var tab_blocks=jQuery(".tabBlock"); |
---|
48 | var tab_name; |
---|
49 | var tab_start = null; |
---|
50 | |
---|
51 | if (options.defaultTab) { |
---|
52 | if (options.defaultTab != "none") tab_start = options.defaultTab; |
---|
53 | if (options.defaultTab == "last") tab_start = jQuery.cookie("tabactive"); |
---|
54 | } |
---|
55 | |
---|
56 | if ((tab_titles.length != 0) && (tab_titles.length == tab_blocks.length)) { |
---|
57 | |
---|
58 | if (tab_start != null) { |
---|
59 | tab_blocks.each(function(index) { |
---|
60 | jQuery(this).css("display","none"); |
---|
61 | }); |
---|
62 | tab_loaded=1; |
---|
63 | jQuery("#tabs").css("height","auto"); |
---|
64 | |
---|
65 | tab_titles.each(function(index1) { |
---|
66 | tab_name = jQuery(this).attr("name"); |
---|
67 | if (tab_name == tab_start) { |
---|
68 | jQuery(this).addClass("tabSelected"); |
---|
69 | jQuery.cookie("tabactive",jQuery(this).attr("name")); |
---|
70 | var old_selected_tab =-1; |
---|
71 | tab_blocks.each(function(index2) { |
---|
72 | if (index1 == index2) { |
---|
73 | jQuery(this).show(); |
---|
74 | } |
---|
75 | }); |
---|
76 | } |
---|
77 | }); |
---|
78 | |
---|
79 | } |
---|
80 | |
---|
81 | tab_titles.each(function(index1) { |
---|
82 | var tab_title = jQuery(this); |
---|
83 | tab_title.click(function () { |
---|
84 | if (tab_loaded==0) { |
---|
85 | tab_blocks.each(function(index) { |
---|
86 | jQuery(this).css("display","none"); |
---|
87 | }); |
---|
88 | tab_loaded=1; |
---|
89 | jQuery("#tabs").css("height","auto"); |
---|
90 | } |
---|
91 | if (jQuery(this).hasClass("tabSelected")) { |
---|
92 | var tab_title = jQuery(this); |
---|
93 | tab_blocks.each(function(index2) { |
---|
94 | if ((index1 == index2) && (options.animatedTabs)) { |
---|
95 | jQuery(this).slideUp(delay, function() {tab_title.removeClass("tabSelected");}); |
---|
96 | } else { |
---|
97 | jQuery(this).hide(); |
---|
98 | } |
---|
99 | }); |
---|
100 | jQuery.cookie("tabactive",null); |
---|
101 | } else { |
---|
102 | jQuery(this).addClass("tabSelected"); |
---|
103 | jQuery.cookie("tabactive",jQuery(this).attr("name")); |
---|
104 | var old_selected_tab =-1; |
---|
105 | tab_titles.each(function(index2) { |
---|
106 | if ((index1 != index2) && (jQuery(this).hasClass("tabSelected"))) { |
---|
107 | old_selected_tab=index2; |
---|
108 | jQuery(this).removeClass("tabSelected"); |
---|
109 | } |
---|
110 | }); |
---|
111 | tab_blocks.each(function(index2) { |
---|
112 | if (index1 == index2) { |
---|
113 | if ((old_selected_tab == -1) && (options.animatedTabs)) { |
---|
114 | jQuery(this).slideDown(delay); |
---|
115 | } else { |
---|
116 | jQuery(this).show(); |
---|
117 | } |
---|
118 | } |
---|
119 | }); |
---|
120 | tab_blocks.each(function(index2) { |
---|
121 | if (index2 != index1) { |
---|
122 | jQuery(this).hide(); |
---|
123 | } |
---|
124 | }); |
---|
125 | } |
---|
126 | }); |
---|
127 | }); |
---|
128 | } |
---|
129 | |
---|
130 | |
---|
131 | // Image autosize function inspired from Autosize Plugin (from cljosse) |
---|
132 | |
---|
133 | var img_ratio=image_w / image_h; |
---|
134 | |
---|
135 | if (options.imageAutosize) { |
---|
136 | |
---|
137 | // Autosize image |
---|
138 | jQuery(window).resize(function () { |
---|
139 | |
---|
140 | var Fenetre = jQuery(window); |
---|
141 | var ImageContainer = jQuery("#theImageAndTitle"); |
---|
142 | var ImageCadre = jQuery("#theImg"); |
---|
143 | var Image = jQuery("img","#theImg"); |
---|
144 | var TitleBox=jQuery("#imageTitleContainer"); |
---|
145 | |
---|
146 | var marge_cote; |
---|
147 | |
---|
148 | if (options.navArrows) {marge_cote=30;} else {marge_cote=10;}; |
---|
149 | |
---|
150 | var marge_sup = 30; |
---|
151 | var marge_inf; |
---|
152 | if (options.themeStyle == 'original') { marge_inf = options.imageAutosizeMargin+10;} else { marge_inf = 30;}; |
---|
153 | var marge_spec = 0; |
---|
154 | |
---|
155 | var slideshow=jQuery("#light_slideshow"); |
---|
156 | if (slideshow.length!=0) { |
---|
157 | marge_inf = 5; |
---|
158 | marge_spec = 25; |
---|
159 | } |
---|
160 | |
---|
161 | var Hmin = options.imageAutosizeMinHeight; |
---|
162 | |
---|
163 | if (Image.length != 1) { |
---|
164 | if (TitleBox.length !=0) TitleBox.css("width","97%"); |
---|
165 | return; |
---|
166 | } |
---|
167 | |
---|
168 | marge_inf = ImageContainer.height()-Image.height()+marge_inf; |
---|
169 | var win_height = Fenetre.height(); |
---|
170 | var img_H = win_height - marge_sup - marge_inf; |
---|
171 | var max_H = img_H; |
---|
172 | |
---|
173 | |
---|
174 | if (img_H >= image_h) img_H = image_h; |
---|
175 | if (img_H <= Hmin) img_H = Hmin; |
---|
176 | |
---|
177 | var img_W = Math.round(parseFloat(img_H * img_ratio)); |
---|
178 | |
---|
179 | |
---|
180 | var marge_image = ImageCadre.outerWidth() - Image.width(); |
---|
181 | /* à modifier */ |
---|
182 | var ext_width; |
---|
183 | |
---|
184 | if (options.themeStyle == 'original') { ext_width = jQuery("#content").width();} else {ext_width = Fenetre.width();}; |
---|
185 | var max_W = ext_width - marge_image - marge_cote * 2; |
---|
186 | |
---|
187 | if (img_W > max_W) { |
---|
188 | img_H = Math.round(parseFloat(max_W / img_ratio)); |
---|
189 | img_W = max_W; |
---|
190 | } |
---|
191 | |
---|
192 | Image.css("width", img_W + "px"); |
---|
193 | Image.css("height", img_H + "px"); |
---|
194 | |
---|
195 | if (options.themeStyle != 'original') { |
---|
196 | var marge_tot = win_height - img_H - marge_inf - marge_sup - marge_spec; |
---|
197 | if (marge_tot < 0) marge_tot=0; |
---|
198 | |
---|
199 | var marge = marge_sup + Math.round(parseFloat(marge_tot / 2)); |
---|
200 | |
---|
201 | ImageContainer.css("top",marge+"px"); |
---|
202 | } |
---|
203 | |
---|
204 | // limit img title Container width |
---|
205 | |
---|
206 | if (TitleBox.length != 0) { |
---|
207 | TitleBox.css("min-width",jQuery("#theImg").outerWidth()+"px"); |
---|
208 | } |
---|
209 | |
---|
210 | jQuery.cookie("stripped_max_width",max_W); |
---|
211 | jQuery.cookie("stripped_max_height",max_H); |
---|
212 | |
---|
213 | ImageContainer.css("opacity","1"); |
---|
214 | ImageCadre.css("opacity","1"); |
---|
215 | TitleBox.css("opacity","1"); |
---|
216 | |
---|
217 | |
---|
218 | // limit img title Container width |
---|
219 | /* |
---|
220 | if (TitleBox.length != 0) { |
---|
221 | var TBminW = jQuery("#theImg").outerWidth(); |
---|
222 | TitleBox.css("min-width",TBminW + "px"); |
---|
223 | if (TitleBox.width() > TBminW) { |
---|
224 | TitleBox.children().css("text-align","justify"); |
---|
225 | } else { |
---|
226 | TitleBox.children().css("text-align","center"); |
---|
227 | } |
---|
228 | } |
---|
229 | */ |
---|
230 | // test |
---|
231 | if (options.themeStyle != 'original') { |
---|
232 | var max_footer_width = jQuery("#content").width() - jQuery("#tabTitles").width() - 5; |
---|
233 | jQuery("#copyright").css("max-width",max_footer_width); |
---|
234 | } |
---|
235 | return; |
---|
236 | |
---|
237 | }); |
---|
238 | |
---|
239 | jQuery(window).resize(); |
---|
240 | jQuery(window).resize(); |
---|
241 | |
---|
242 | } else { |
---|
243 | jQuery("#theImageAndTitle").css("opacity","1"); |
---|
244 | var TitleBox=jQuery("#imageTitleContainer"); |
---|
245 | if (TitleBox.length !=0) TitleBox.css("width","97%"); |
---|
246 | |
---|
247 | } |
---|
248 | |
---|
249 | |
---|
250 | }); |
---|
251 | |
---|
252 | |
---|
253 | |
---|
254 | // Scripts taken from Gally Theme |
---|
255 | |
---|
256 | function openDisplayHigh(url) |
---|
257 | { |
---|
258 | jQuery('#theImageHigh').css( |
---|
259 | { |
---|
260 | width:jQuery("html").get(0).scrollWidth+"px", |
---|
261 | height:jQuery("html").get(0).scrollHeight+"px", |
---|
262 | display:"block" |
---|
263 | } |
---|
264 | ); |
---|
265 | |
---|
266 | if(jQuery("#theImgHigh").attr('src')=="") |
---|
267 | { |
---|
268 | p = new Object(); |
---|
269 | p.left = ((jQuery(window).width()-jQuery("#theImgHighContainer").prop("clientWidth")-options.paddingContainer*2)/2)+"px"; |
---|
270 | p.top = ((jQuery(window).height()-jQuery("#theImgHighContainer").prop("clientHeight")-options.paddingContainer*2)/2)+"px"; |
---|
271 | |
---|
272 | |
---|
273 | jQuery('#theImgHighContainer') |
---|
274 | .css( |
---|
275 | { |
---|
276 | left:p.left, |
---|
277 | top:p.top, |
---|
278 | padding:options.paddingContainer+"px" |
---|
279 | } |
---|
280 | ); |
---|
281 | |
---|
282 | |
---|
283 | jQuery("#theImgHigh") |
---|
284 | .load( |
---|
285 | function () |
---|
286 | { |
---|
287 | jQuery(document).data("highWidth", jQuery("#theImgHigh").width()); |
---|
288 | jQuery(document).data("highHeight", jQuery("#theImgHigh").height()); |
---|
289 | |
---|
290 | p=calcImgHighPositionAndSize(zoomMode); |
---|
291 | |
---|
292 | jQuery('#theImgHighContainer').css("background-image", "none") |
---|
293 | displayZoomHigh(); |
---|
294 | jQuery("#theImgHigh").css( {display:"block"} ); |
---|
295 | } |
---|
296 | ) |
---|
297 | .attr('src', url); |
---|
298 | |
---|
299 | if(options.highResClickMode=='close') |
---|
300 | { |
---|
301 | jQuery("#theImgHigh").bind('click', closeDisplayHigh); |
---|
302 | } |
---|
303 | else |
---|
304 | { |
---|
305 | // switch zoom |
---|
306 | jQuery("#theImgHigh").bind('click', switchZoomHigh); |
---|
307 | } |
---|
308 | } |
---|
309 | else |
---|
310 | { |
---|
311 | p=calcImgHighPositionAndSize(zoomMode); |
---|
312 | |
---|
313 | jQuery('#theImgHighContainer') |
---|
314 | .css( |
---|
315 | { |
---|
316 | left:p.left+"px", |
---|
317 | top:p.top+"px", |
---|
318 | width:p.width+"px", |
---|
319 | height:p.height+"px" |
---|
320 | } |
---|
321 | ); |
---|
322 | } |
---|
323 | } |
---|
324 | |
---|
325 | function calcImgHighPositionAndSize(zoom) |
---|
326 | { |
---|
327 | p = new Object(); |
---|
328 | |
---|
329 | if(zoom=='full') |
---|
330 | { |
---|
331 | p.width = (jQuery("html").get(0).clientWidth-(options.marginContainer+options.paddingContainer)*2); |
---|
332 | p.height = (jQuery("html").get(0).clientHeight-(options.marginContainer+options.paddingContainer)*2); |
---|
333 | p.left=options.marginContainer; |
---|
334 | p.top=options.marginContainer; |
---|
335 | |
---|
336 | if(p.width>jQuery(document).data("highWidth")) |
---|
337 | { |
---|
338 | p.width = jQuery(document).data("highWidth")-options.paddingContainer*2; |
---|
339 | p.left = (jQuery("html").get(0).clientWidth-p.width)/2; |
---|
340 | } |
---|
341 | |
---|
342 | if(p.height>jQuery(document).data("highHeight")) |
---|
343 | { |
---|
344 | p.height = jQuery(document).data("highHeight")-options.paddingContainer*2; |
---|
345 | p.top = (jQuery("html").get(0).clientHeight-p.height)/2; |
---|
346 | } |
---|
347 | } |
---|
348 | else |
---|
349 | { |
---|
350 | //zoom = 'fit' |
---|
351 | ratioImg = jQuery(document).data("highWidth") / jQuery(document).data("highHeight"); |
---|
352 | ratioPage = jQuery("html").get(0).clientWidth / jQuery("html").get(0).clientHeight; |
---|
353 | |
---|
354 | if((ratioPage > 1 && (ratioPage > ratioImg)) || |
---|
355 | (ratioPage < 1 && (ratioPage < ratioImg))) |
---|
356 | { |
---|
357 | p.height = (jQuery("html").get(0).clientHeight-(options.marginContainer+options.paddingContainer)*2); |
---|
358 | p.width = p.height*ratioImg; |
---|
359 | } |
---|
360 | else |
---|
361 | { |
---|
362 | p.width = (jQuery("html").get(0).clientWidth-(options.marginContainer+options.paddingContainer)*2); |
---|
363 | p.height = p.width/ratioImg; |
---|
364 | } |
---|
365 | p.left = (jQuery("html").get(0).clientWidth-p.width)/2; |
---|
366 | p.top = (jQuery("html").get(0).clientHeight-p.height)/2; |
---|
367 | } |
---|
368 | |
---|
369 | return(p); |
---|
370 | } |
---|
371 | |
---|
372 | function closeDisplayHigh() |
---|
373 | { |
---|
374 | jQuery('#theImageHigh').css('display', 'none'); |
---|
375 | } |
---|
376 | |
---|
377 | function switchZoomHigh() |
---|
378 | { |
---|
379 | if(zoomMode=='full') |
---|
380 | { |
---|
381 | zoomMode="fit"; |
---|
382 | } |
---|
383 | else |
---|
384 | { |
---|
385 | zoomMode="full"; |
---|
386 | } |
---|
387 | |
---|
388 | jQuery("#theImgHighZoomButton").toggleClass('full').toggleClass('fit'); |
---|
389 | |
---|
390 | displayZoomHigh(); |
---|
391 | } |
---|
392 | |
---|
393 | function displayZoomHigh() |
---|
394 | { |
---|
395 | p=calcImgHighPositionAndSize(zoomMode); |
---|
396 | |
---|
397 | jQuery('#theImgHighContainer').css( |
---|
398 | { |
---|
399 | left:p.left+"px", |
---|
400 | top:p.top+"px", |
---|
401 | width:p.width+"px", |
---|
402 | height:p.height+"px" |
---|
403 | } |
---|
404 | ); |
---|
405 | |
---|
406 | if(zoomMode=="full") |
---|
407 | { |
---|
408 | jQuery("#theImgHigh") |
---|
409 | .css( |
---|
410 | { |
---|
411 | width:jQuery(document).data("highWidth")+"px", |
---|
412 | height:jQuery(document).data("highHeight")+"px" |
---|
413 | } |
---|
414 | ); |
---|
415 | jQuery('#theImgHighContainer').bind("mousemove", |
---|
416 | function(event) |
---|
417 | { |
---|
418 | deadArea = options.marginContainer*2; |
---|
419 | mouseX=Math.max(Math.min(event.clientX-this.offsetLeft, this.clientWidth - deadArea), deadArea); |
---|
420 | mouseY=Math.max(Math.min(event.clientY-this.offsetTop, this.clientHeight - deadArea), deadArea); |
---|
421 | jQuery("#theImgHigh") |
---|
422 | .css("left",Math.round((jQuery("#theImgHigh").prop("scrollWidth")-this.clientWidth) * -(mouseX-deadArea)/(this.clientWidth-2*deadArea))+"px") |
---|
423 | .css("top",Math.round((jQuery("#theImgHigh").prop("scrollHeight")-this.clientHeight) * -(mouseY-deadArea)/(this.clientHeight-2*deadArea))+"px"); |
---|
424 | } |
---|
425 | ); |
---|
426 | } |
---|
427 | else |
---|
428 | { |
---|
429 | jQuery("#theImgHigh") |
---|
430 | .css( |
---|
431 | { |
---|
432 | width:p.width+"px", |
---|
433 | height:p.height+"px", |
---|
434 | left:"0px", |
---|
435 | top:"0px" |
---|
436 | } |
---|
437 | ); |
---|
438 | jQuery('#theImgHighContainer').unbind("mousemove"); |
---|
439 | } |
---|
440 | } |
---|
441 | /** |
---|
442 | * Cookie plugin |
---|
443 | * Copyright (c) 2006 Klaus Hartl (stilbuero.de) |
---|
444 | * Dual licensed under the MIT and GPL licenses: |
---|
445 | */ |
---|
446 | jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options=jQuery.extend({},options);options.expires=-1;} |
---|
447 | var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;} |
---|
448 | expires='; expires='+date.toUTCString();} |
---|
449 | var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}} |
---|
450 | return cookieValue;}}; |
---|
451 | |
---|
452 | |
---|
453 | |
---|
454 | |
---|