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

Last change on this file since 12153 was 11961, checked in by cljosse, 13 years ago

[extensions] Autosize fix compatibility with 'charlies video'

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