source: extensions/stripped/js/scripts-tpp.js @ 17407

Last change on this file since 17407 was 17407, checked in by Zaphod, 12 years ago

version 2.2.7

File size: 14.2 KB
Line 
1var showtabs;
2var selectedTab;
3var interfaceTimerDelay;
4var isScrollable;
5var zoomMode;
6
7jQuery("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) && (options.themeStyle == "original") ) {
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) {
95                                                        if (options.animatedTabs) {
96                                                                jQuery(this).slideUp(delay, function() {tab_title.removeClass("tabSelected");});
97                                                        } else {
98                                                                jQuery(this).hide();
99                                                                tab_title.removeClass("tabSelected");
100                                                        }
101                                                }
102                                        });
103                                        jQuery.cookie("tabactive",null);
104                                } else {
105                                        jQuery(this).addClass("tabSelected");
106                                        jQuery.cookie("tabactive",jQuery(this).attr("name"));
107                                        var old_selected_tab =-1;
108                                        tab_titles.each(function(index2) {
109                                                if ((index1 != index2) && (jQuery(this).hasClass("tabSelected"))) {
110                                                old_selected_tab=index2;
111                                                jQuery(this).removeClass("tabSelected");
112                                                }
113                                        });
114                                        tab_blocks.each(function(index2) {
115                                                if (index1 == index2) {
116                                                        if ((old_selected_tab == -1) && (options.animatedTabs)) {
117                                                                jQuery(this).slideDown(delay);
118                                                        } else {
119                                                                jQuery(this).show();
120                                                        }
121                                                }
122                                        });
123                                        tab_blocks.each(function(index2) {
124                                                if (index2 != index1) {
125                                                        jQuery(this).hide();
126                                                }
127                                        });
128                                }
129                        });
130                }); 
131               
132                if (options.themeStyle != "original") {
133                        jQuery("#content > .hideTabsZone").css("top",jQuery("#content").offset().top+"px");                     
134                        jQuery(".hideTabs").click(function() {
135                               
136                                tab_titles.each(function(index1) {
137                                        if (jQuery(this).hasClass("tabSelected")) {
138                                                var tab_title = jQuery(this);
139                                                tab_blocks.each(function(index2) {
140                                                        if (index1 == index2) {
141                                                                if (options.animatedTabs) {
142                                                                        jQuery(this).slideUp(delay, function() {tab_title.removeClass("tabSelected");});
143                                                                } else {
144                                                                        jQuery(this).hide();
145                                                                        tab_title.removeClass("tabSelected");
146                                                                }
147                                                        }
148                                                });
149                                                jQuery.cookie("tabactive",null);
150                                        } 
151                                });
152                       
153                        });
154                }
155        }
156
157       
158        // Image autosize function inspired from Autosize Plugin (from cljosse)
159
160        var img_ratio=image_w / image_h;
161
162        if (options.imageAutosize) {
163       
164                // Autosize image
165                jQuery(window).resize(function () {
166                       
167                        var Fenetre = jQuery(window);
168                        var ImageContainer = jQuery("#theImageAndTitle");
169                        var ImageCadre = jQuery("#theImg");
170                        var Image = jQuery("img","#theImg");
171                        var TitleBox=jQuery("#imageTitleContainer");
172                        var Content=jQuery("#content");
173                       
174                        var marge_cote;
175
176                        var marge_sup = 5 + Content.offset().top;
177                        var marge_inf;
178                        if (options.themeStyle == 'original') { marge_inf = options.imageAutosizeMargin+10;} else { marge_inf = 30;};
179                        var marge_spec = 0;
180
181                        if (ImageCadre.length == 0) {
182                                ImageContainer.css("opacity","1");
183                                jQuery("img","#theImageAndTitle").css("opacity","1");
184                                ImageContainer.css("top",marge_sup+"px");
185                                //maps & earth
186                                if (jQuery("#map").length == 1) {
187                                        ImageContainer.css("position","static");
188                                        ImageContainer.css("margin-top","10px");
189                                }
190                                return;
191                        }
192                       
193                        var slideshow=jQuery("#light_slideshow");
194                        if (slideshow.length!=0) {
195                                marge_inf = 5;
196                                marge_spec = 25;
197                        }
198                       
199                        var Hmin = options.imageAutosizeMinHeight;
200                       
201                        if (Image.length != 1) {
202                                if (TitleBox.length !=0) TitleBox.css("width","97%");
203                                return;
204                        }
205
206                        marge_inf = ImageContainer.height()-Image.height()+marge_inf;
207                        var win_height = Fenetre.height();
208                        var img_H = win_height - marge_sup - marge_inf;
209                        var max_H = img_H;
210
211                       
212                        if (img_H >= image_h) img_H = image_h;
213                        if (img_H <= Hmin) img_H = Hmin;
214
215                        var img_W = Math.round(parseFloat(img_H * img_ratio));
216                       
217
218                        var marge_image = ImageCadre.outerWidth() - Image.width();
219                        var ext_width;
220                       
221                        if (options.themeStyle == 'original') { ext_width = jQuery("#content").width();} else {ext_width = Fenetre.width();};
222                        var max_W = ext_width - marge_image - marge_cote * 2;
223                       
224                        if (img_W > max_W) {
225                                img_H = Math.round(parseFloat(max_W / img_ratio));
226                                img_W = max_W;
227                        }
228                       
229                        Image.css("width", img_W + "px");
230                        Image.css("height", img_H + "px");
231
232                        if (options.themeStyle != 'original') {
233                                var marge_tot = win_height - img_H - marge_inf - marge_sup - marge_spec;
234                                if (marge_tot < 0) marge_tot=0;
235                       
236                                var marge = marge_sup + Math.round(parseFloat(marge_tot / 2));
237
238                                ImageContainer.css("top",marge+"px");
239                        }
240
241                        // limit img title Container width
242
243                        if (TitleBox.length != 0) {
244                                TitleBox.css("min-width",jQuery("#theImg").outerWidth()+"px");
245                        }
246
247                        jQuery.cookie("stripped_max_width",max_W);
248                        jQuery.cookie("stripped_max_height",max_H);
249
250                        ImageContainer.css("opacity","1");
251                        ImageCadre.css("opacity","1");
252                        TitleBox.css("opacity","1");
253
254
255                        // limit img title Container width
256/*
257                        if (TitleBox.length != 0) {
258                                var TBminW = jQuery("#theImg").outerWidth();
259                                TitleBox.css("min-width",TBminW + "px");
260                                if (TitleBox.width() > TBminW) {
261                                        TitleBox.children().css("text-align","justify");
262                                } else {
263                                        TitleBox.children().css("text-align","center");
264                                }
265                        }
266*/
267                        // test
268                        if (options.themeStyle != 'original') {
269                                var max_footer_width = jQuery("#content").width() - jQuery("#tabTitles").width() - 5;
270                                jQuery("#copyright").css("max-width",max_footer_width);
271                        }
272                        return;
273
274                });
275               
276                jQuery(window).resize();
277                jQuery(window).resize();
278       
279        }       else {
280                jQuery("#theImageAndTitle").css("opacity","1");
281                jQuery("#theImg").css("opacity","1");
282                jQuery("#imageTitleContainer").css("opacity","1");
283                var TitleBox=jQuery("#imageTitleContainer");
284                if (TitleBox.length !=0) TitleBox.css("width","97%");
285               
286        }
287       
288               
289});
290
291
292
293// Scripts taken from Gally Theme
294
295function openDisplayHigh(url)
296{
297  jQuery('#theImageHigh').css(
298    {
299      width:jQuery("html").get(0).scrollWidth+"px",
300      height:jQuery("html").get(0).scrollHeight+"px",
301      display:"block"
302    }
303  );
304
305  if(jQuery("#theImgHigh").attr('src')=="")
306  {
307    p = new Object();
308    p.left = ((jQuery(window).width()-jQuery("#theImgHighContainer").prop("clientWidth")-options.paddingContainer*2)/2)+"px";
309    p.top = ((jQuery(window).height()-jQuery("#theImgHighContainer").prop("clientHeight")-options.paddingContainer*2)/2)+"px";
310
311
312    jQuery('#theImgHighContainer')
313      .css(
314        {
315          left:p.left,
316          top:p.top,
317          padding:options.paddingContainer+"px"
318        }
319      );
320
321
322    jQuery("#theImgHigh")
323      .load(
324        function ()
325        {
326          jQuery(document).data("highWidth", jQuery("#theImgHigh").width());
327          jQuery(document).data("highHeight", jQuery("#theImgHigh").height());
328
329          p=calcImgHighPositionAndSize(zoomMode);
330
331          jQuery('#theImgHighContainer').css("background-image", "none")
332          displayZoomHigh();
333          jQuery("#theImgHigh").css( {display:"block"} );
334        }
335      )
336      .attr('src', url);
337
338    if(options.highResClickMode=='close')
339    {
340      jQuery("#theImgHigh").bind('click', closeDisplayHigh);
341    }
342    else
343    {
344      // switch zoom
345      jQuery("#theImgHigh").bind('click', switchZoomHigh);
346    }
347  }
348  else
349  {
350    p=calcImgHighPositionAndSize(zoomMode);
351
352    jQuery('#theImgHighContainer')
353      .css(
354        {
355          left:p.left+"px",
356          top:p.top+"px",
357          width:p.width+"px",
358          height:p.height+"px"
359        }
360      );
361  }
362}
363
364function calcImgHighPositionAndSize(zoom)
365{
366  p = new Object();
367  imgH = jQuery(document).data("highHeight") 
368  imgW = jQuery(document).data("highWidth") 
369
370  if(zoom=='full')
371  {
372    p.width = (jQuery("html").get(0).clientWidth-(options.marginContainer+options.paddingContainer)*2);
373    p.height = (jQuery("html").get(0).clientHeight-(options.marginContainer+options.paddingContainer)*2);
374    p.left=options.marginContainer;
375    p.top=options.marginContainer;
376
377    if(p.width>imgW)
378    {
379      p.width = imgW;
380      p.left = (jQuery("html").get(0).clientWidth-p.width)/2;
381      jQuery("#theImgHighZoomButton").hide();
382    }
383
384    if(p.height>imgH)
385    {
386      p.height = imgH;
387      p.top = (jQuery("html").get(0).clientHeight-p.height)/2;
388      jQuery("#theImgHighZoomButton").hide();
389    }
390       
391        if ((p.width==imgW) && (p.height==imgH)) switchZoomHigh();
392  }
393  else
394  {
395    //zoom = 'fit'
396        ratioImg = imgW / imgH;
397    ratioPage = jQuery("html").get(0).clientWidth / jQuery("html").get(0).clientHeight;
398
399    if((ratioPage > 1 && (ratioPage > ratioImg)) ||
400       (ratioPage < 1 && (ratioPage < ratioImg)))
401    {
402      p.height = (jQuery("html").get(0).clientHeight-(options.marginContainer+options.paddingContainer)*2);
403      p.width = p.height*ratioImg;
404    }
405    else
406    {
407      p.width = (jQuery("html").get(0).clientWidth-(options.marginContainer+options.paddingContainer)*2);
408      p.height = p.width/ratioImg;
409    }
410       
411        if ((p.width > imgW) || (p.height > imgH)) {
412                p.height = imgH;
413                p.width = imgW;
414                jQuery("#theImgHighZoomButton").hide();
415        }
416    p.left = (jQuery("html").get(0).clientWidth-p.width)/2;
417    p.top = (jQuery("html").get(0).clientHeight-p.height)/2;
418  }
419
420  return(p);
421}
422
423function closeDisplayHigh()
424{
425  jQuery('#theImageHigh').css('display', 'none');
426}
427
428function switchZoomHigh()
429{
430  if(zoomMode=='full')
431  {
432    zoomMode="fit";
433  }
434  else
435  {
436    zoomMode="full";
437  }
438
439  jQuery("#theImgHighZoomButton").toggleClass('full').toggleClass('fit');
440
441  displayZoomHigh();
442}
443
444function displayZoomHigh()
445{
446  p=calcImgHighPositionAndSize(zoomMode);
447
448  jQuery('#theImgHighContainer').css(
449      {
450        left:p.left+"px",
451        top:p.top+"px",
452        width:p.width+"px",
453        height:p.height+"px"
454      }
455    );
456
457    if(zoomMode=="full")
458    {
459      jQuery("#theImgHigh")
460        .css(
461          {
462            width:jQuery(document).data("highWidth")+"px",
463            height:jQuery(document).data("highHeight")+"px"
464          }
465        );
466      jQuery('#theImgHighContainer').bind("mousemove",
467          function(event)
468          {
469            deadArea = options.marginContainer*2;
470            mouseX=Math.max(Math.min(event.clientX-this.offsetLeft, this.clientWidth - deadArea), deadArea);
471            mouseY=Math.max(Math.min(event.clientY-this.offsetTop, this.clientHeight - deadArea), deadArea);
472            jQuery("#theImgHigh")
473              .css("left",Math.round((jQuery("#theImgHigh").prop("scrollWidth")-this.clientWidth) * -(mouseX-deadArea)/(this.clientWidth-2*deadArea))+"px")
474              .css("top",Math.round((jQuery("#theImgHigh").prop("scrollHeight")-this.clientHeight) * -(mouseY-deadArea)/(this.clientHeight-2*deadArea))+"px");
475          }
476        );
477    }
478    else
479    {
480      jQuery("#theImgHigh")
481        .css(
482          {
483            width:p.width+"px",
484            height:p.height+"px",
485            left:"0px",
486            top:"0px"
487          }
488        );
489      jQuery('#theImgHighContainer').unbind("mousemove");
490    }
491}
492/**
493 * Cookie plugin
494 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
495 * Dual licensed under the MIT and GPL licenses:
496 */
497jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options=jQuery.extend({},options);options.expires=-1;}
498var 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;}
499expires='; expires='+date.toUTCString();}
500var 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;}}}
501return cookieValue;}};
502
503
504
505
Note: See TracBrowser for help on using the repository browser.