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

Last change on this file since 17503 was 17503, checked in by cljosse, 12 years ago

[extensions] Autosize fix compatibility with 2.4, update

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