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

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

[extension] stripped - version 1.2.1

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