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

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

[extensions] Autosize fix compatibility with 2.4, add option: SelMax / Autosize (default setting)

File size: 3.6 KB
RevLine 
[11961]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;
[18716]20}
21
22
[11961]23jQuery(document).ready(function (jQuery) {
[18716]24 
25
26  jQuery(window).unload(function () {
27    return;
28
29  }); // unload
30
31
32
33
34
35
[11961]36  jQuery(window).load(function () {
[18716]37   
38
39
[11961]40    if (jQuery("#scrolltotop").length == 0)
41      jQuery('#scrolltobottom').before('<div id="scrolltotop" ><a title="Revenir en haut de la page" href="#"></a></div>');
[11912]42
[18716]43    stb = jQuery('#scrolltobottom');
44    stt = jQuery('#scrolltotop');
45    stt.css('opacity', 1)
[11961]46    stb.css('opacity', 1)
[11912]47
[11961]48    jQuery('#scrolltotop').height(100);
49    jQuery('#scrolltobottom').height(100);
50    jQuery('#scrolltotop').css({
[18716]51    });
52    jQuery('#scrolltobottom').css({
53    });
54    jQuery(window).resize(
[11961]55               function (event, ui) {
56                 jQuery(window).scroll();
57               });
[18716]58    jQuery('.auto_details').text(" ");
[11442]59
[18716]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 });
[11442]65
[18716]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);
[11442]72
73
[18716]74      jQuery(stt).css({ opacity: pourcent });
75      jQuery(stb).css({ opacity: 1 - pourcent });
[11961]76
77
[18716]78      jQuery("#scrollmiddle").css("bottom", maxi + "px");
79      // jQuery("#scrollmiddle").text(pourcent);
80      //====================================================
81      scrollBottom = jQuery(window).scrollTop();
[11961]82
[18716]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);
[11961]89
[18716]90      stb.stop().fadeTo(500, 1 - pourcent);
[11961]91
[18716]92    });
93    jQuery('#scrolltobottom a').mouseout(function () {
94      stb.stop().fadeTo(500, 0);
[11961]95
[18716]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);
[11442]102
[18716]103    });
104    jQuery('#scrolltotop a').mouseout(function () {
105      stt.stop().fadeTo(500, 0);
106    });
[11912]107
[18716]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      });
[11442]115    });
116
[18716]117    jQuery('#scrolltotop a').click(function () {
118      pos = 0;
119      jQuery('html, body').animate({
120        scrollTop: pos + 'px'
121      }, 0, function () {
[11961]122
123
[18716]124      });
[11442]125    });
[18716]126    //===================================================================         
[11442]127
128
129
[18716]130  });
[11442]131}); 
132//=========================================================
133
Note: See TracBrowser for help on using the repository browser.