@@ 9121-9158 (lines=38) @@ | ||
9118 | ||
9119 | ||
9120 | // Create scrollLeft and scrollTop methods |
|
9121 | jQuery.each( ["Left", "Top"], function( i, name ) { |
|
9122 | var method = "scroll" + name; |
|
9123 | ||
9124 | jQuery.fn[ method ] = function( val ) { |
|
9125 | var elem, win; |
|
9126 | ||
9127 | if ( val === undefined ) { |
|
9128 | elem = this[ 0 ]; |
|
9129 | ||
9130 | if ( !elem ) { |
|
9131 | return null; |
|
9132 | } |
|
9133 | ||
9134 | win = getWindow( elem ); |
|
9135 | ||
9136 | // Return the scroll offset |
|
9137 | return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] : |
|
9138 | jQuery.support.boxModel && win.document.documentElement[ method ] || |
|
9139 | win.document.body[ method ] : |
|
9140 | elem[ method ]; |
|
9141 | } |
|
9142 | ||
9143 | // Set the scroll offset |
|
9144 | return this.each(function() { |
|
9145 | win = getWindow( this ); |
|
9146 | ||
9147 | if ( win ) { |
|
9148 | win.scrollTo( |
|
9149 | !i ? val : jQuery( win ).scrollLeft(), |
|
9150 | i ? val : jQuery( win ).scrollTop() |
|
9151 | ); |
|
9152 | ||
9153 | } else { |
|
9154 | this[ method ] = val; |
|
9155 | } |
|
9156 | }); |
|
9157 | }; |
|
9158 | }); |
|
9159 | ||
9160 | function getWindow( elem ) { |
|
9161 | return jQuery.isWindow( elem ) ? |
@@ 8063-8098 (lines=36) @@ | ||
8060 | ||
8061 | ||
8062 | // Create scrollLeft and scrollTop methods |
|
8063 | jQuery.each( ["Left", "Top"], function( i, name ) { |
|
8064 | var method = "scroll" + name; |
|
8065 | ||
8066 | jQuery.fn[ method ] = function(val) { |
|
8067 | var elem = this[0], win; |
|
8068 | ||
8069 | if ( !elem ) { |
|
8070 | return null; |
|
8071 | } |
|
8072 | ||
8073 | if ( val !== undefined ) { |
|
8074 | // Set the scroll offset |
|
8075 | return this.each(function() { |
|
8076 | win = getWindow( this ); |
|
8077 | ||
8078 | if ( win ) { |
|
8079 | win.scrollTo( |
|
8080 | !i ? val : jQuery(win).scrollLeft(), |
|
8081 | i ? val : jQuery(win).scrollTop() |
|
8082 | ); |
|
8083 | ||
8084 | } else { |
|
8085 | this[ method ] = val; |
|
8086 | } |
|
8087 | }); |
|
8088 | } else { |
|
8089 | win = getWindow( elem ); |
|
8090 | ||
8091 | // Return the scroll offset |
|
8092 | return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] : |
|
8093 | jQuery.support.boxModel && win.document.documentElement[ method ] || |
|
8094 | win.document.body[ method ] : |
|
8095 | elem[ method ]; |
|
8096 | } |
|
8097 | }; |
|
8098 | }); |
|
8099 | ||
8100 | function getWindow( elem ) { |
|
8101 | return jQuery.isWindow( elem ) ? |