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

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

[extension] stripped - first release

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