Changeset 11961 for extensions/Autosize/js/JScript.js
- Timestamp:
- Aug 16, 2011, 3:27:53 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Autosize/js/JScript.js
r11912 r11961 1 jQuery(document).ready( 2 function (jQuery) { 3 var stt = jQuery('#scrolltobottom'); 4 var stb = jQuery('#scrolltotop'); 1 function 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 jQuery(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 }); 38 jQuery(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 //=================================================== 50 jQuery(window).scroll(function () { 51 maxi = getScrollMaxY(); 52 wmax = jQuery("body").height() - jQuery(window).height(); 53 scrollTop = jQuery(window).scrollTop(); 54 pourcent = (scrollTop / wmax) ; 5 55 6 56 7 stt.css('opacity', 1);8 var scrollBottom = 0;57 jQuery(stt).css({ opacity:pourcent }); 58 jQuery(stb).css({ opacity: 1-pourcent }); 9 59 10 //===================================================================11 jQuery(window).load(function (event, ui) {12 if (typeof (event) == 'undefined') return;13 scrollBottom = jQuery(window).scrollTop(0);14 var v_max = jQuery("#the_page").height();15 //===================================================================16 jQuery(window).scroll(function () {17 scrollBottom = jQuery(window).scrollTop();18 v_max = jQuery("#the_page").height() - jQuery(window).height();19 if (scrollBottom > 100) {20 if (stt.css('opacity') == 0) {21 stt.stop().fadeTo(1000, 1);22 }23 }24 if (scrollBottom > v_max - 100) {25 if (stb.css('opacity') == 0) {26 stb.stop().fadeTo(1000, 1);27 }28 }29 return;30 60 31 if (scrollBottom < v_max) { 32 if (stb.css('opacity') > 0) { 33 stb.stop().fadeTo(1000, 0); 34 stb.css("display", "none"); 35 } 36 } else { 37 if (stb.css('opacity') == 0) { 38 stb.stop().fadeTo(1000, 1); 39 stb.css("display", "block"); 40 } 41 } 61 jQuery("#scrollmiddle").css("bottom", maxi + "px"); 62 // jQuery("#scrollmiddle").text(pourcent); 63 //==================================================== 64 scrollBottom = jQuery(window).scrollTop(); 42 65 43 //========================================= 44 if (scrollBottom < v_max) { 45 if (stt.css('opacity') == 0) { 46 stt.stop().fadeTo(1000, 1); 47 stt.css("display", "block"); 48 } 49 } else { 50 if (stt.css('opacity') > 0) { 51 stt.stop().fadeTo(1000, 0); 52 stt.css("display", "none"); 66 }); 67 //===================================================== 68 jQuery('#scrolltobottom a').mouseover(function () { 69 wmax = jQuery("body").height() - jQuery(window).height(); 70 scrollTop = jQuery(window).scrollTop(); 71 pourcent = (scrollTop / wmax); 53 72 54 } 55 } 73 stb.stop().fadeTo(500, 1-pourcent); 56 74 57 75 }); 76 jQuery('#scrolltobottom a').mouseout(function () { 77 stb.stop().fadeTo(500, 0); 78 79 }); 80 jQuery('#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 58 86 }); 87 jQuery('#scrolltotop a').mouseout(function () { 88 stt.stop().fadeTo(500, 0); 89 }); 59 90 60 91 jQuery('#scrolltobottom a').click(function () { 61 pos = jQuery('#the_page').outerHeight();92 pos = jQuery("body").height() - jQuery(window).height(); ; 62 93 jQuery('html, body').animate({ 63 94 scrollTop: pos + 'px' 64 95 }, 1000, function () { 65 66 stt.stop().fadeTo(1000, 0);67 stb.stop().fadeTo(1000, 1);68 96 69 97 }); … … 71 99 72 100 jQuery('#scrolltotop a').click(function () { 73 74 101 pos = 0; 75 102 jQuery('html, body').animate({ 76 103 scrollTop: pos + 'px' 77 }, 1000, function () {78 stb.stop().fadeTo(1000, 0); 79 stt.stop().fadeTo(1000, 1); 104 }, 0, function () { 105 106 80 107 }); 81 108 }); 109 //=================================================================== 82 110 83 111 84 function gotoPos(pos) {85 jQuery('html, body').animate({ scrollTop: jQuery('body').outerHeight() + 'px' },86 0, function () {87 scrollBottom = jQuery(window).scrollTop();88 112 89 113 }); 90 91 92 return false;93 }94 //===================================================================95 // jQuery(window).resize();96 jQuery(window).scroll();97 98 99 114 }); 100 115 //=========================================================
Note: See TracChangeset
for help on using the changeset viewer.