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

Last change on this file since 9960 was 9960, checked in by Zaphod, 13 years ago

[extension] stripped - version 1.3.0

File size: 15.1 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        // display alt from ALL actions.
30        if (options.replaceActionIcons) {
31                var actionBlock=jQuery(".randomButtons");
32               
33                if (actionBlock.length != 0) {
34                        var actionIcons=actionBlock.find("img.button");
35                        if (actionIcons.length !=0) {
36                                actionIcons.each(function(index) {
37                                        var alt_text = (jQuery(this).attr("alt"));
38                                        jQuery(this).before(alt_text);
39                                        jQuery(this).parents("li").css("width","auto");
40                                        jQuery(this).remove();
41                                });
42                        }
43                }
44        }
45
46        // gmaps icon
47       
48        var icon_gmaps=jQuery("#icon_gmaps");
49        var text_gmaps=jQuery("#text_gmaps");
50        if ((icon_gmaps.length == 1) && (text_gmaps.length ==1)) {
51                icon_gmaps.text(text_gmaps.text());
52                icon_gmaps.css("text-align","right");
53                icon_gmaps.wrapAll('<li>');
54        }
55               
56        // Tabs
57
58        var tab_loaded=0;
59        var tab_height=[];
60        var delay=400;
61        var hfirst;
62        if (jQuery.browser.msie) {hfirst=false;} else {hfirst=true;}
63       
64        var tab_titles=jQuery(".tabTitle");
65        var tab_blocks=jQuery(".tabBlock");
66
67        if ((tab_titles.length != 0) && (tab_titles.length == tab_blocks.length)) {
68                tab_titles.each(function(index1) {
69                        var tab_title = jQuery(this);
70                        tab_title.click(function () {
71                                if (tab_loaded==0) {
72                                        tab_blocks.each(function(index) {
73                                                jQuery(this).css("display","none");
74                                        });
75                                        tab_loaded=1;
76                                        jQuery("#tabs").css("height","auto");
77                                }
78                                if (jQuery(this).hasClass("tabSelected")) {
79                                        var tab_title = jQuery(this);
80                                        tab_blocks.each(function(index2) {
81                                                if ((index1 == index2) && (options.animatedTabs)) {
82                                                        jQuery(this).slideUp(delay, function() {tab_title.removeClass("tabSelected");});
83                                                } else {
84                                                        jQuery(this).hide();
85                                                }
86                                        });
87                                } else {
88                                        jQuery(this).addClass("tabSelected");
89                                        var old_selected_tab =-1;
90                                        tab_titles.each(function(index2) {
91                                                if ((index1 != index2) && (jQuery(this).hasClass("tabSelected"))) {
92                                                old_selected_tab=index2;
93                                                jQuery(this).removeClass("tabSelected");
94                                                }
95                                        });
96                                        tab_blocks.each(function(index2) {
97                                                if (index1 == index2) {
98                                                        if ((old_selected_tab == -1) && (options.animatedTabs)) {
99                                                                jQuery(this).slideDown(delay);
100                                                        } else {
101                                                                jQuery(this).show();
102                                                        }
103                                                }
104                                        });
105                                        tab_blocks.each(function(index2) {
106                                                if (index2 != index1) {
107                                                        jQuery(this).hide();
108                                                }
109                                        });
110                                }
111                        });
112                }); 
113        }
114
115        Init_nav_thumbs();
116
117       
118        // Image autosize function inspired from Autosize Plugin (from cljosse)
119        var img_W0=0;
120        var img_H0=0;
121        var img_ratio=0;
122
123        if (options.imageAutosize) {
124                // Autosize image
125                jQuery(window).resize(function () {
126               
127                        var marge_inf_sup = options.imageAutosizeMargin;
128                        var Hmin = options.imageAutosizeMinHeight;
129                       
130                        var ImageContainer;
131                       
132                        if (options.imageAutosizeTitle) {
133                                ImageContainer = jQuery("#theImageAndTitle");
134                        } else {
135                                ImageContainer = jQuery("#theImage");
136                        }
137                        var Image = jQuery("img","#theImg");
138                        var TitleBox=jQuery("#imageTitleContainer");
139
140                        if (Image.length != 1) {
141                                if (TitleBox.length !=0) TitleBox.css("width","97%");
142                                return;
143                        }
144                       
145                        var marge_inf = ImageContainer.height()-Image.height()+marge_inf_sup;
146                        var pos0 = jQuery(Image).offset();
147                        if (!pos0) return;
148                        var img_top = Math.round(parseFloat(pos0.top));
149                        var win_height = jQuery(window).height();
150                        var img_H = win_height - img_top - marge_inf;
151                        var max_H = img_H;
152                       
153                        if (img_W0==0){
154                                img_W0=Image.width();
155                                img_H0=Image.height();
156                                img_ratio=img_W0/img_H0;
157                        }
158
159                        if (img_W0 == 0) return;
160
161                        if (img_H >= img_H0) img_H=img_H0;
162                        if (img_H <= Hmin) img_H=Hmin;
163
164                        var img_W = Math.round(parseFloat(img_H * img_ratio));
165                       
166                        var max_W = jQuery("#content").width() - Image.outerWidth() + Image.width();
167                        if (img_W > max_W) {
168                                var img_H = Math.round(parseFloat(max_W / img_ratio));
169                                if (img_H <= Hmin) {
170                                        img_H = Hmin;
171                                        img_W = Math.round(parseFloat(img_H * img_ratio));
172                                } else {
173                                        img_W = max_W;
174                                }
175                        }
176
177                        Image.css("width", img_W + "px");
178                        Image.css("height", img_H+ "px");
179                       
180                        jQuery.cookie("stripped_max_width",max_W);
181                        jQuery.cookie("stripped_max_height",max_H);
182
183                        // limit img title Container width
184
185                        if (TitleBox.length != 0) {
186                                TitleBox.css("width",jQuery("#theImg").outerWidth()+"px");
187                        }
188
189                        Calc_nav_thumbs_pos();
190                       
191                        return;
192
193                });
194               
195                jQuery(window).resize();
196       
197        }       else {
198
199                var TitleBox=jQuery("#imageTitleContainer");
200                if (TitleBox.length !=0) TitleBox.css("width","97%");
201               
202                jQuery(window).resize(function () {
203                        Calc_nav_thumbs_pos();
204                        return;
205                });
206               
207        }
208               
209        Calc_nav_thumbs_pos()
210
211});
212
213function Init_nav_thumbs() {
214        var tfade=options.navThumbsFade;
215
216        var PrevBoxOut = jQuery("#linkPrevOut");
217        if (PrevBoxOut.length !=0)
218        {
219                var PrevBoxIn=jQuery("#linkPrevIn");
220                var PrevImgBox=jQuery("#linkPrevIn > .navThumb");
221                var PrevImg=jQuery("#linkPrevIn > .navThumb > img");
222
223                if ((jQuery("#mapPicture").length==0) && (jQuery("#Panorama").length==0) && (jQuery("#pamoorama").length==0)){
224                        PrevBoxIn.mouseenter(function(){PrevImg.animate({opacity:1},tfade);});
225                        PrevBoxOut.mouseleave(function(){PrevImg.animate({opacity:0},tfade);});
226                } else {
227                        PrevBoxOut.css("display","none");
228                }
229        }
230
231        var NextBoxOut = jQuery("#linkNextOut");
232        if (NextBoxOut.length !=0)
233        {
234                var NextBoxIn=jQuery("#linkNextIn");
235                var NextImgBox=jQuery("#linkNextIn > .navThumb");
236                var NextImg=jQuery("#linkNextIn > .navThumb > img");
237
238                if ((jQuery("#mapPicture").length==0) && (jQuery("#Panorama").length==0) && (jQuery("#pamoorama").length==0)){
239                        NextBoxIn.mouseenter(function(){NextImg.animate({opacity:1},tfade);});
240                        NextBoxOut.mouseleave(function(){NextImg.animate({opacity:0},tfade);});
241                } else {
242                        NextBoxOut.css("display","none");
243                }
244        }
245}
246
247function Calc_nav_thumbs_pos() {
248
249        var Window = jQuery(window);
250        var Content = jQuery("#content");
251        var ImageBox = jQuery("#theImg");
252        var PrevImg=jQuery("#linkPrevIn > .navThumb > img");
253
254        var window_width = Window.width();
255        var content_width = Content.width();
256        var image_width = ImageBox.width();
257
258        var PrevBoxOut = jQuery("#linkPrevOut");
259        if (PrevBoxOut.length !=0)
260        {       
261                if (PrevBoxOut.css("display") != "none") {
262                        var PrevBoxIn=jQuery("#linkPrevIn");
263                        var PrevImgBox=jQuery("#linkPrevIn > .navThumb");
264                        var PrevImg=jQuery("#linkPrevIn > .navThumb > img");
265
266                        // height
267
268                        var imgHeight = ImageBox.height()||0;
269                        PrevBoxOut.css("height",imgHeight+"px");
270
271                        var prevImgTopMargin =  parseInt( (imgHeight - PrevImgBox.outerHeight()) / 2 );
272                        PrevImgBox.css("margin-top",prevImgTopMargin+"px");
273
274                        // position
275                       
276                        var prevbox_pos1= parseInt( ( content_width - image_width + PrevImg.outerWidth()) / 2 ) + 120;
277                        var prevbox_pos0= prevbox_pos1 - PrevBoxOut.width();
278                        var left_margin = parseInt( ( window_width - content_width ) / 2 );
279                       
280                        if (prevbox_pos0 + left_margin < 0 ) {
281                                prevbox_pos0 = - left_margin
282                                prevbox_pos1 = prevbox_pos0 + PrevBoxOut.width();
283                        }
284                        var prevbox_width = prevbox_pos1 - prevbox_pos0;
285                       
286                        PrevBoxOut.css("left",prevbox_pos0+"px");
287                        PrevBoxOut.css("width",prevbox_width+"px");
288                }
289        }
290
291        var NextBoxOut = jQuery("#linkNextOut");
292        if (NextBoxOut.length !=0)
293        {
294                if (NextBoxOut.css("display") != "none") {
295                        var NextBoxIn=jQuery("#linkNextIn");
296                        var NextImgBox=jQuery("#linkNextIn > .navThumb");
297                        var NextImg=jQuery("#linkNextIn > .navThumb > img");
298
299                        // height
300
301                        var imgHeight = ImageBox.height()||0;
302                        NextBoxOut.css("height",imgHeight+"px");
303
304                        var nextImgTopMargin =  parseInt( (imgHeight - NextImg.outerHeight()) / 2 );
305                        NextImgBox.css("margin-top",nextImgTopMargin+"px");
306
307                        // position
308
309                        var nextbox_pos1= parseInt( ( content_width - image_width + NextImg.outerWidth()) / 2 ) + 120;
310                        var nextbox_pos0= nextbox_pos1 - NextBoxOut.width();
311                        var right_margin = parseInt( ( window_width - content_width ) / 2 );
312                       
313                        if (nextbox_pos0 + right_margin < 0 ) {
314                                nextbox_pos0 = - right_margin
315                                nextbox_pos1 = nextbox_pos0 + NextBoxOut.width();
316                        }
317               
318                        var nextbox_width = nextbox_pos1 - nextbox_pos0;
319                       
320                        NextBoxOut.css("right",nextbox_pos0+"px");
321                        NextBoxOut.css("width",nextbox_width+"px");
322                }
323        }
324}
325
326
327// Scripts taken from Gally Theme
328
329function openDisplayHigh(url)
330{
331  jQuery('#theImageHigh').css(
332    {
333      width:jQuery("html").get(0).scrollWidth+"px",
334      height:jQuery("html").get(0).scrollHeight+"px",
335      display:"block"
336    }
337  );
338
339  if(jQuery("#theImgHigh").attr('src')=="")
340  {
341    p = new Object();
342    p.left = ((jQuery(window).width()-jQuery("#theImgHighContainer").attr("clientWidth")-options.paddingContainer*2)/2)+"px";
343    p.top = ((jQuery(window).height()-jQuery("#theImgHighContainer").attr("clientHeight")-options.paddingContainer*2)/2)+"px";
344
345
346    jQuery('#theImgHighContainer')
347      .css(
348        {
349          left:p.left,
350          top:p.top,
351          padding:options.paddingContainer+"px"
352        }
353      );
354
355
356    jQuery("#theImgHigh")
357      .load(
358        function ()
359        {
360          jQuery(document).data("highWidth", jQuery("#theImgHigh").width());
361          jQuery(document).data("highHeight", jQuery("#theImgHigh").height());
362
363          p=calcImgHighPositionAndSize(zoomMode);
364
365          jQuery('#theImgHighContainer').css("background-image", "none")
366          displayZoomHigh();
367          jQuery("#theImgHigh").css( {display:"block"} );
368        }
369      )
370      .attr('src', url);
371
372    if(options.highResClickMode=='close')
373    {
374      jQuery("#theImgHigh").bind('click', closeDisplayHigh);
375    }
376    else
377    {
378      // switch zoom
379      jQuery("#theImgHigh").bind('click', switchZoomHigh);
380    }
381  }
382  else
383  {
384    p=calcImgHighPositionAndSize(zoomMode);
385
386    jQuery('#theImgHighContainer')
387      .css(
388        {
389          left:p.left+"px",
390          top:p.top+"px",
391          width:p.width+"px",
392          height:p.height+"px"
393        }
394      );
395  }
396}
397
398function calcImgHighPositionAndSize(zoom)
399{
400  p = new Object();
401
402  if(zoom=='full')
403  {
404    p.width = (jQuery("html").get(0).clientWidth-(options.marginContainer+options.paddingContainer)*2);
405    p.height = (jQuery("html").get(0).clientHeight-(options.marginContainer+options.paddingContainer)*2);
406    p.left=options.marginContainer;
407    p.top=options.marginContainer;
408
409    if(p.width>jQuery(document).data("highWidth"))
410    {
411      p.width = jQuery(document).data("highWidth")-options.paddingContainer*2;
412      p.left = (jQuery("html").get(0).clientWidth-p.width)/2;
413    }
414
415    if(p.height>jQuery(document).data("highHeight"))
416    {
417      p.height = jQuery(document).data("highHeight")-options.paddingContainer*2;
418      p.top = (jQuery("html").get(0).clientHeight-p.height)/2;
419    }
420  }
421  else
422  {
423    //zoom = 'fit'
424    ratioImg = jQuery(document).data("highWidth") / jQuery(document).data("highHeight");
425    ratioPage = jQuery("html").get(0).clientWidth / jQuery("html").get(0).clientHeight;
426
427    if((ratioPage > 1 && (ratioPage > ratioImg)) ||
428       (ratioPage < 1 && (ratioPage < ratioImg)))
429    {
430      p.height = (jQuery("html").get(0).clientHeight-(options.marginContainer+options.paddingContainer)*2);
431      p.width = p.height*ratioImg;
432    }
433    else
434    {
435      p.width = (jQuery("html").get(0).clientWidth-(options.marginContainer+options.paddingContainer)*2);
436      p.height = p.width/ratioImg;
437    }
438    p.left = (jQuery("html").get(0).clientWidth-p.width)/2;
439    p.top = (jQuery("html").get(0).clientHeight-p.height)/2;
440  }
441
442  return(p);
443}
444
445function closeDisplayHigh()
446{
447  jQuery('#theImageHigh').css('display', 'none');
448}
449
450function switchZoomHigh()
451{
452  if(zoomMode=='full')
453  {
454    zoomMode="fit";
455  }
456  else
457  {
458    zoomMode="full";
459  }
460
461  jQuery("#theImgHighZoomButton").toggleClass('full').toggleClass('fit');
462
463  displayZoomHigh();
464}
465
466function displayZoomHigh()
467{
468  p=calcImgHighPositionAndSize(zoomMode);
469
470  jQuery('#theImgHighContainer').css(
471      {
472        left:p.left+"px",
473        top:p.top+"px",
474        width:p.width+"px",
475        height:p.height+"px"
476      }
477    );
478
479    if(zoomMode=="full")
480    {
481      jQuery("#theImgHigh")
482        .css(
483          {
484            width:jQuery(document).data("highWidth")+"px",
485            height:jQuery(document).data("highHeight")+"px"
486          }
487        );
488      jQuery('#theImgHighContainer').bind("mousemove",
489          function(event)
490          {
491            deadArea = options.marginContainer*2;
492            mouseX=Math.max(Math.min(event.clientX-this.offsetLeft, this.clientWidth - deadArea), deadArea);
493            mouseY=Math.max(Math.min(event.clientY-this.offsetTop, this.clientHeight - deadArea), deadArea);
494            jQuery("#theImgHigh")
495              .css("left",Math.round((jQuery("#theImgHigh").attr("scrollWidth")-this.clientWidth) * -(mouseX-deadArea)/(this.clientWidth-2*deadArea))+"px")
496              .css("top",Math.round((jQuery("#theImgHigh").attr("scrollHeight")-this.clientHeight) * -(mouseY-deadArea)/(this.clientHeight-2*deadArea))+"px");
497          }
498        );
499    }
500    else
501    {
502      jQuery("#theImgHigh")
503        .css(
504          {
505            width:p.width+"px",
506            height:p.height+"px",
507            left:"0px",
508            top:"0px"
509          }
510        );
511      jQuery('#theImgHighContainer').unbind("mousemove");
512    }
513}
514/**
515 * Cookie plugin
516 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
517 * Dual licensed under the MIT and GPL licenses:
518 */
519jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options=jQuery.extend({},options);options.expires=-1;}
520var 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;}
521expires='; expires='+date.toUTCString();}
522var 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;}}}
523return cookieValue;}};
524
525
526
527
Note: See TracBrowser for help on using the repository browser.