Ignore:
Timestamp:
Aug 16, 2011, 3:27:53 PM (13 years ago)
Author:
cljosse
Message:

[extensions] Autosize fix compatibility with 'charlies video'

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');
     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)  ;
    555
    656
    7   stt.css('opacity', 1);
    8   var scrollBottom = 0;
     57  jQuery(stt).css({ opacity:pourcent });
     58  jQuery(stb).css({ opacity:  1-pourcent });
    959
    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;
    3060
    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();
    4265
    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//=====================================================
     68jQuery('#scrolltobottom a').mouseover(function () {
     69  wmax = jQuery("body").height() - jQuery(window).height();
     70  scrollTop = jQuery(window).scrollTop();
     71  pourcent = (scrollTop / wmax);
    5372
    54       }
    55     }
     73  stb.stop().fadeTo(500, 1-pourcent);
    5674
    5775  });
     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
    5886  });
     87jQuery('#scrolltotop a').mouseout(function () {
     88  stt.stop().fadeTo(500, 0);
     89});
    5990
    6091  jQuery('#scrolltobottom a').click(function () {
    61     pos = jQuery('#the_page').outerHeight();
     92  pos = jQuery("body").height() - jQuery(window).height(); ;
    6293    jQuery('html, body').animate({
    6394      scrollTop: pos + 'px'
    6495    }, 1000, function () {
    65 
    66       stt.stop().fadeTo(1000, 0);
    67       stb.stop().fadeTo(1000, 1);
    6896
    6997    });
     
    7199
    72100  jQuery('#scrolltotop a').click(function () {
    73 
    74101    pos = 0;
    75102    jQuery('html, body').animate({
    76103      scrollTop: pos + 'px'
    77     }, 1000, function () {
    78       stb.stop().fadeTo(1000, 0);
    79       stt.stop().fadeTo(1000, 1);
     104  }, 0, function () {
     105
     106
    80107    });
    81108  });
     109//===================================================================     
    82110
    83111
    84   function gotoPos(pos) {
    85     jQuery('html, body').animate({ scrollTop: jQuery('body').outerHeight() + 'px' },
    86      0, function () {
    87        scrollBottom = jQuery(window).scrollTop();
    88112
    89113     });
    90 
    91 
    92     return false;
    93   }
    94   //===================================================================   
    95   // jQuery(window).resize();
    96   jQuery(window).scroll();
    97 
    98 
    99114});
    100115//=========================================================
Note: See TracChangeset for help on using the changeset viewer.