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

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

Changes for version 1.1.0 :

  • picture navbuttons moved into the title bar
  • increased size of prev/next thumbnail zone on picture page
  • picture icons and thumbnail arrows replaced by png stripes
File size: 13.8 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        }
54               
55        // Tabs
56
57        var tab_loaded=0;
58        var tab_height=[];
59        var delay;
60        if (options.animatedTabs) {delay = "slow";} else {delay = 0;}
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) {
82                                                        jQuery(this).hide("fold",{mode:"hide",size:'1'},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) {
99                                                                jQuery(this).show("fold",{horizFirst:hfirst,mode:"show",size:'1'},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 = parseInt(pos0.top);
149                        var win_height = jQuery(window).height();
150                        var img_H = win_height - img_top - marge_inf;
151
152                        if (img_W0==0){
153                                img_W0=Image.width();
154                                img_H0=Image.height();
155                                img_ratio=img_W0/img_H0;
156                        }
157
158                        if (img_W0 == 0) return;
159
160                        if (img_H >= img_H0) img_H=img_H0;
161                        if (img_H <= Hmin) img_H=Hmin;
162
163                        var img_W = parseInt(img_H * img_ratio);
164                       
165                        var max_W = jQuery("#content").width() - Image.outerWidth() + Image.width();
166                        if (img_W > max_W) {
167                                var img_H = parseInt(max_W / img_ratio);
168                                if (img_H <= Hmin) {
169                                        img_H = Hmin;
170                                        img_W = parseInt(img_H * img_ratio);
171                                } else {
172                                        img_W = max_W;
173                                }
174                        }
175
176                        Image.css("width", img_W + "px");
177                        Image.css("height", img_H+ "px");
178
179                        // limit img title Container width
180
181                        if (TitleBox.length != 0) {
182                                TitleBox.css("width",jQuery("#theImg").outerWidth()+"px");
183                        }
184
185                        Calc_nav_thumbs_pos();
186                       
187                        return;
188
189                });
190               
191                jQuery(window).resize();
192       
193        }       else {
194
195                var TitleBox=jQuery("#imageTitleContainer");
196                if (TitleBox.length !=0) TitleBox.css("width","97%");
197               
198                jQuery(window).resize(function () {
199                        Calc_nav_thumbs_pos();
200                        return;
201                });
202               
203        }
204               
205        Calc_nav_thumbs_pos()
206
207});
208
209function Init_nav_thumbs() {
210        var tfade=options.navThumbsFade;
211
212        var PrevBoxOut = jQuery("#linkPrevOut");
213        if (PrevBoxOut.length !=0)
214        {
215                var PrevBoxIn=jQuery("#linkPrevIn");
216                var PrevImgBox=jQuery("#linkPrevIn > .navThumb");
217                var PrevImg=jQuery("#linkPrevIn > .navThumb > img");
218
219                if ((jQuery("#mapPicture").length==0) && (jQuery("#Panorama").length==0) && (jQuery("#pamoorama").length==0)){
220                        PrevBoxIn.mouseenter(function(){PrevImg.animate({opacity:1},tfade);});
221                        PrevBoxOut.mouseleave(function(){PrevImg.animate({opacity:0},tfade);});
222                } else {
223                        PrevBoxOut.css("display","none");
224                }
225        }
226
227        var NextBoxOut = jQuery("#linkNextOut");
228        if (NextBoxOut.length !=0)
229        {
230                var NextBoxIn=jQuery("#linkNextIn");
231                var NextImgBox=jQuery("#linkNextIn > .navThumb");
232                var NextImg=jQuery("#linkNextIn > .navThumb > img");
233
234                if ((jQuery("#mapPicture").length==0) && (jQuery("#Panorama").length==0) && (jQuery("#pamoorama").length==0)){
235                        NextBoxIn.mouseenter(function(){NextImg.animate({opacity:1},tfade);});
236                        NextBoxOut.mouseleave(function(){NextImg.animate({opacity:0},tfade);});
237                } else {
238                        NextBoxOut.css("display","none");
239                }
240        }
241}
242
243function Calc_nav_thumbs_pos() {
244
245        var Window = jQuery(window);
246        var Content = jQuery("#content");
247        var ImageBox = jQuery("#theImg");
248        var PrevImg=jQuery("#linkPrevIn > .navThumb > img");
249
250        var window_width = Window.width();
251        var content_width = Content.width();
252        var image_width = ImageBox.width();
253
254        var PrevBoxOut = jQuery("#linkPrevOut");
255        if (PrevBoxOut.length !=0)
256        {       
257                if (PrevBoxOut.css("display") != "none") {
258                        var PrevBoxIn=jQuery("#linkPrevIn");
259                        var PrevImgBox=jQuery("#linkPrevIn > .navThumb");
260                        var PrevImg=jQuery("#linkPrevIn > .navThumb > img");
261
262                        // height
263
264                        var imgHeight = ImageBox.height()||0;
265                        PrevBoxOut.css("height",imgHeight+"px");
266
267                        var prevImgTopMargin =  parseInt( (imgHeight - PrevImgBox.outerHeight()) / 2 );
268                        PrevImgBox.css("margin-top",prevImgTopMargin+"px");
269
270                        // position
271                       
272                        var prevbox_pos1= parseInt( ( content_width - image_width + PrevImg.outerWidth()) / 2 ) + 120;
273                        var prevbox_pos0= prevbox_pos1 - PrevBoxOut.width();
274                        var left_margin = parseInt( ( window_width - content_width ) / 2 );
275                       
276                        if (prevbox_pos0 + left_margin < 0 ) {
277                                prevbox_pos0 = - left_margin
278                                prevbox_pos1 = prevbox_pos0 + PrevBoxOut.width();
279                        }
280                        var prevbox_width = prevbox_pos1 - prevbox_pos0;
281                       
282                        PrevBoxOut.css("left",prevbox_pos0+"px");
283                        PrevBoxOut.css("width",prevbox_width+"px");
284                }
285        }
286
287        var NextBoxOut = jQuery("#linkNextOut");
288        if (NextBoxOut.length !=0)
289        {
290                if (NextBoxOut.css("display") != "none") {
291                        var NextBoxIn=jQuery("#linkNextIn");
292                        var NextImgBox=jQuery("#linkNextIn > .navThumb");
293                        var NextImg=jQuery("#linkNextIn > .navThumb > img");
294
295                        // height
296
297                        var imgHeight = ImageBox.height()||0;
298                        NextBoxOut.css("height",imgHeight+"px");
299
300                        var nextImgTopMargin =  parseInt( (imgHeight - NextImg.outerHeight()) / 2 );
301                        NextImgBox.css("margin-top",nextImgTopMargin+"px");
302
303                        // position
304
305                        var nextbox_pos1= parseInt( ( content_width - image_width + NextImg.outerWidth()) / 2 ) + 120;
306                        var nextbox_pos0= nextbox_pos1 - NextBoxOut.width();
307                        var right_margin = parseInt( ( window_width - content_width ) / 2 );
308                       
309                        if (nextbox_pos0 + right_margin < 0 ) {
310                                nextbox_pos0 = - right_margin
311                                nextbox_pos1 = nextbox_pos0 + NextBoxOut.width();
312                        }
313               
314                        var nextbox_width = nextbox_pos1 - nextbox_pos0;
315                       
316                        NextBoxOut.css("right",nextbox_pos0+"px");
317                        NextBoxOut.css("width",nextbox_width+"px");
318                }
319        }
320}
321
322
323// Scripts taken from Gally Theme
324
325function openDisplayHigh(url)
326{
327  jQuery('#theImageHigh').css(
328    {
329      width:jQuery("html").get(0).scrollWidth+"px",
330      height:jQuery("html").get(0).scrollHeight+"px",
331      display:"block"
332    }
333  );
334
335  if(jQuery("#theImgHigh").attr('src')=="")
336  {
337    p = new Object();
338    p.left = ((jQuery(window).width()-jQuery("#theImgHighContainer").attr("clientWidth")-options.paddingContainer*2)/2)+"px";
339    p.top = ((jQuery(window).height()-jQuery("#theImgHighContainer").attr("clientHeight")-options.paddingContainer*2)/2)+"px";
340
341
342    jQuery('#theImgHighContainer')
343      .css(
344        {
345          left:p.left,
346          top:p.top,
347          padding:options.paddingContainer+"px"
348        }
349      );
350
351
352    jQuery("#theImgHigh")
353      .load(
354        function ()
355        {
356          jQuery(document).data("highWidth", jQuery("#theImgHigh").width());
357          jQuery(document).data("highHeight", jQuery("#theImgHigh").height());
358
359          p=calcImgHighPositionAndSize(zoomMode);
360
361          jQuery('#theImgHighContainer').css("background-image", "none")
362          displayZoomHigh();
363          jQuery("#theImgHigh").css( {display:"block"} );
364        }
365      )
366      .attr('src', url);
367
368    if(options.highResClickMode=='close')
369    {
370      jQuery("#theImgHigh").bind('click', closeDisplayHigh);
371    }
372    else
373    {
374      // switch zoom
375      jQuery("#theImgHigh").bind('click', switchZoomHigh);
376    }
377  }
378  else
379  {
380    p=calcImgHighPositionAndSize(zoomMode);
381
382    jQuery('#theImgHighContainer')
383      .css(
384        {
385          left:p.left+"px",
386          top:p.top+"px",
387          width:p.width+"px",
388          height:p.height+"px"
389        }
390      );
391  }
392}
393
394function calcImgHighPositionAndSize(zoom)
395{
396  p = new Object();
397
398  if(zoom=='full')
399  {
400    p.width = (jQuery("html").get(0).clientWidth-(options.marginContainer+options.paddingContainer)*2);
401    p.height = (jQuery("html").get(0).clientHeight-(options.marginContainer+options.paddingContainer)*2);
402    p.left=options.marginContainer;
403    p.top=options.marginContainer;
404
405    if(p.width>jQuery(document).data("highWidth"))
406    {
407      p.width = jQuery(document).data("highWidth")-options.paddingContainer*2;
408      p.left = (jQuery("html").get(0).clientWidth-p.width)/2;
409    }
410
411    if(p.height>jQuery(document).data("highHeight"))
412    {
413      p.height = jQuery(document).data("highHeight")-options.paddingContainer*2;
414      p.top = (jQuery("html").get(0).clientHeight-p.height)/2;
415    }
416  }
417  else
418  {
419    //zoom = 'fit'
420    ratioImg = jQuery(document).data("highWidth") / jQuery(document).data("highHeight");
421    ratioPage = jQuery("html").get(0).clientWidth / jQuery("html").get(0).clientHeight;
422
423    if((ratioPage > 1 && (ratioPage > ratioImg)) ||
424       (ratioPage < 1 && (ratioPage < ratioImg)))
425    {
426      p.height = (jQuery("html").get(0).clientHeight-(options.marginContainer+options.paddingContainer)*2);
427      p.width = p.height*ratioImg;
428    }
429    else
430    {
431      p.width = (jQuery("html").get(0).clientWidth-(options.marginContainer+options.paddingContainer)*2);
432      p.height = p.width/ratioImg;
433    }
434    p.left = (jQuery("html").get(0).clientWidth-p.width)/2;
435    p.top = (jQuery("html").get(0).clientHeight-p.height)/2;
436  }
437
438  return(p);
439}
440
441function closeDisplayHigh()
442{
443  jQuery('#theImageHigh').css('display', 'none');
444}
445
446function switchZoomHigh()
447{
448  if(zoomMode=='full')
449  {
450    zoomMode="fit";
451  }
452  else
453  {
454    zoomMode="full";
455  }
456
457  jQuery("#theImgHighZoomButton").toggleClass('full').toggleClass('fit');
458
459  displayZoomHigh();
460}
461
462function displayZoomHigh()
463{
464  p=calcImgHighPositionAndSize(zoomMode);
465
466  jQuery('#theImgHighContainer').css(
467      {
468        left:p.left+"px",
469        top:p.top+"px",
470        width:p.width+"px",
471        height:p.height+"px"
472      }
473    );
474
475    if(zoomMode=="full")
476    {
477      jQuery("#theImgHigh")
478        .css(
479          {
480            width:jQuery(document).data("highWidth")+"px",
481            height:jQuery(document).data("highHeight")+"px"
482          }
483        );
484      jQuery('#theImgHighContainer').bind("mousemove",
485          function(event)
486          {
487            deadArea = options.marginContainer*2;
488            mouseX=Math.max(Math.min(event.clientX-this.offsetLeft, this.clientWidth - deadArea), deadArea);
489            mouseY=Math.max(Math.min(event.clientY-this.offsetTop, this.clientHeight - deadArea), deadArea);
490            jQuery("#theImgHigh")
491              .css("left",Math.round((jQuery("#theImgHigh").attr("scrollWidth")-this.clientWidth) * -(mouseX-deadArea)/(this.clientWidth-2*deadArea))+"px")
492              .css("top",Math.round((jQuery("#theImgHigh").attr("scrollHeight")-this.clientHeight) * -(mouseY-deadArea)/(this.clientHeight-2*deadArea))+"px");
493          }
494        );
495    }
496    else
497    {
498      jQuery("#theImgHigh")
499        .css(
500          {
501            width:p.width+"px",
502            height:p.height+"px",
503            left:"0px",
504            top:"0px"
505          }
506        );
507      jQuery('#theImgHighContainer').unbind("mousemove");
508    }
509}
510
511
512
513
Note: See TracBrowser for help on using the repository browser.