source: extensions/Autosize/js/JScript.js @ 22360

Last change on this file since 22360 was 22360, checked in by cljosse, 11 years ago

[extensions] Autosize update to piwigo 2.5 (fix bugs with pamooramics, charlies's )

File size: 3.5 KB
Line 
1function getScrollMaxY() {
2  var innerh;
3  if (window.innerHeight) {
4    innerh = window.innerHeight;
5  } else {
6    innerh = document.body.clientHeight;
7  }
8  if (window.innerHeight && window.scrollMaxY) {
9    // Firefox     
10    yWithScroll = window.innerHeight + window.scrollMaxY;
11  } else if (
12     document.body.scrollHeight > document.body.offsetHeight) {
13    // all but Explorer Mac   
14    yWithScroll = document.body.scrollHeight;
15  } else {
16    // works in Explorer 6 Strict, Mozilla (not FF) and Safari   
17    yWithScroll = document.body.offsetHeight;
18  }
19  return yWithScroll - innerh;
20}
21
22
23jQuery(document).ready(function (jQuery) {
24  jQuery(window).load(function () { 
25    if (jQuery("#scrolltotop").length == 0)
26      jQuery('#scrolltobottom').before('<div id="scrolltotop" ><a title="Revenir en haut de la page" href="#"></a></div>');
27
28    stb = jQuery('#scrolltobottom');
29    stt = jQuery('#scrolltotop');
30    stt.css('opacity', 1);
31    stb.css('opacity', 1);
32
33    jQuery('#scrolltotop').height(100);
34    jQuery('#scrolltobottom').height(100);
35    jQuery('#scrolltotop').css({
36    });
37    jQuery('#scrolltobottom').css({
38    });
39    jQuery(window).resize(
40               function (event, ui) {
41                 jQuery(window).scroll();
42               });
43    jQuery('.auto_details').text(" ");
44
45    wmax = jQuery("body").height() - jQuery(window).height();
46    scrollTop = jQuery(window).scrollTop();
47    pourcent = (scrollTop / wmax);
48    jQuery(stt).css({ opacity: pourcent });
49    jQuery(stb).css({ opacity: 1 - pourcent });
50
51    //===================================================               
52    jQuery(window).scroll(function () {
53      maxi = getScrollMaxY();
54      wmax = jQuery("body").height() - jQuery(window).height();
55      scrollTop = jQuery(window).scrollTop();
56      pourcent = (scrollTop / wmax);
57
58
59      jQuery(stt).css({ opacity: pourcent });
60      jQuery(stb).css({ opacity: 1 - pourcent });
61
62
63      jQuery("#scrollmiddle").css("bottom", maxi + "px");
64      // jQuery("#scrollmiddle").text(pourcent);
65      //====================================================
66      scrollBottom = jQuery(window).scrollTop();
67
68    });
69    //=====================================================
70    jQuery('#scrolltobottom a').mouseover(function () {
71      wmax = jQuery("body").height() - jQuery(window).height();
72      scrollTop = jQuery(window).scrollTop();
73      pourcent = (scrollTop / wmax);
74
75      stb.stop().fadeTo(500, 1 - pourcent);
76
77    });
78    jQuery('#scrolltobottom a').mouseout(function () {
79      stb.stop().fadeTo(500, 0);
80
81    });
82    jQuery('#scrolltotop a').mouseover(function () {
83      wmax = jQuery("body").height() - jQuery(window).height();
84      scrollTop = jQuery(window).scrollTop();
85      pourcent = (scrollTop / wmax);
86      stt.stop().fadeTo(500, pourcent);
87
88    });
89    jQuery('#scrolltotop a').mouseout(function () {
90      stt.stop().fadeTo(500, 0);
91    });
92
93    jQuery('#scrolltobottom a').click(function () {
94      pos = jQuery("body").height() - jQuery(window).height(); ;
95      jQuery('html, body').animate({
96        scrollTop: pos + 'px'
97      }, 1000, function () {
98
99      });
100    });
101
102    jQuery('#scrolltotop a').click(function () {
103      pos = 0;
104      jQuery('html, body').animate({
105        scrollTop: pos + 'px'
106      }, 0, function () {
107
108
109      });
110    });
111    //===================================================================         
112
113
114
115  });
116}); 
117//=========================================================
118
Note: See TracBrowser for help on using the repository browser.