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

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

[extensions] Autosize update to piwigo 2.5 (fix bugs)

File size: 3.6 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 
25
26  jQuery(window).unload(function () {
27    return;
28
29  }); // unload
30
31
32
33
34
35
36  jQuery(window).load(function () {
37   
38
39
40    if (jQuery("#scrolltotop").length == 0)
41      jQuery('#scrolltobottom').before('<div id="scrolltotop" ><a title="Revenir en haut de la page" href="#"></a></div>');
42
43    stb = jQuery('#scrolltobottom');
44    stt = jQuery('#scrolltotop');
45    stt.css('opacity', 1);
46    stb.css('opacity', 1);
47
48    jQuery('#scrolltotop').height(100);
49    jQuery('#scrolltobottom').height(100);
50    jQuery('#scrolltotop').css({
51    });
52    jQuery('#scrolltobottom').css({
53    });
54    jQuery(window).resize(
55               function (event, ui) {
56                 jQuery(window).scroll();
57               });
58    jQuery('.auto_details').text(" ");
59
60    wmax = jQuery("body").height() - jQuery(window).height();
61    scrollTop = jQuery(window).scrollTop();
62    pourcent = (scrollTop / wmax);
63    jQuery(stt).css({ opacity: pourcent });
64    jQuery(stb).css({ opacity: 1 - pourcent });
65
66    //===================================================               
67    jQuery(window).scroll(function () {
68      maxi = getScrollMaxY();
69      wmax = jQuery("body").height() - jQuery(window).height();
70      scrollTop = jQuery(window).scrollTop();
71      pourcent = (scrollTop / wmax);
72
73
74      jQuery(stt).css({ opacity: pourcent });
75      jQuery(stb).css({ opacity: 1 - pourcent });
76
77
78      jQuery("#scrollmiddle").css("bottom", maxi + "px");
79      // jQuery("#scrollmiddle").text(pourcent);
80      //====================================================
81      scrollBottom = jQuery(window).scrollTop();
82
83    });
84    //=====================================================
85    jQuery('#scrolltobottom a').mouseover(function () {
86      wmax = jQuery("body").height() - jQuery(window).height();
87      scrollTop = jQuery(window).scrollTop();
88      pourcent = (scrollTop / wmax);
89
90      stb.stop().fadeTo(500, 1 - pourcent);
91
92    });
93    jQuery('#scrolltobottom a').mouseout(function () {
94      stb.stop().fadeTo(500, 0);
95
96    });
97    jQuery('#scrolltotop a').mouseover(function () {
98      wmax = jQuery("body").height() - jQuery(window).height();
99      scrollTop = jQuery(window).scrollTop();
100      pourcent = (scrollTop / wmax);
101      stt.stop().fadeTo(500, pourcent);
102
103    });
104    jQuery('#scrolltotop a').mouseout(function () {
105      stt.stop().fadeTo(500, 0);
106    });
107
108    jQuery('#scrolltobottom a').click(function () {
109      pos = jQuery("body").height() - jQuery(window).height(); ;
110      jQuery('html, body').animate({
111        scrollTop: pos + 'px'
112      }, 1000, function () {
113
114      });
115    });
116
117    jQuery('#scrolltotop a').click(function () {
118      pos = 0;
119      jQuery('html, body').animate({
120        scrollTop: pos + 'px'
121      }, 0, function () {
122
123
124      });
125    });
126    //===================================================================         
127
128
129
130  });
131}); 
132//=========================================================
133
Note: See TracBrowser for help on using the repository browser.