diff options
author | Scott González <scott.gonzalez@gmail.com> | 2012-11-09 14:47:20 -0500 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2012-11-09 14:47:20 -0500 |
commit | dbaecf0ede6e8dcd6e80adfb2bd8826ddd648136 (patch) | |
tree | aa839c8f8ebf310c9fbf64f7f0fe9519d9229f9b /ui/jquery.ui.effect.js | |
parent | f5870712c1f73c474a6980bb16d12768f4150984 (diff) | |
download | jquery-ui-dbaecf0ede6e8dcd6e80adfb2bd8826ddd648136.tar.gz jquery-ui-dbaecf0ede6e8dcd6e80adfb2bd8826ddd648136.zip |
Effects: Cleaned up getElementStyles().
Diffstat (limited to 'ui/jquery.ui.effect.js')
-rw-r--r-- | ui/jquery.ui.effect.js | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/ui/jquery.ui.effect.js b/ui/jquery.ui.effect.js index 5cd33886f..fee3359bf 100644 --- a/ui/jquery.ui.effect.js +++ b/ui/jquery.ui.effect.js @@ -700,32 +700,31 @@ $.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopS }; }); -function getElementStyles() { - var style = this.ownerDocument.defaultView ? - this.ownerDocument.defaultView.getComputedStyle( this, null ) : - this.currentStyle, - newStyle = {}, - key, - len; - - // webkit enumerates style porperties +function getElementStyles( elem ) { + var key, len, + style = elem.ownerDocument.defaultView ? + elem.ownerDocument.defaultView.getComputedStyle( elem, null ) : + elem.currentStyle, + styles = {}; + if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) { len = style.length; while ( len-- ) { key = style[ len ]; if ( typeof style[ key ] === "string" ) { - newStyle[ $.camelCase( key ) ] = style[ key ]; + styles[ $.camelCase( key ) ] = style[ key ]; } } + // support: Opera, IE <9 } else { for ( key in style ) { if ( typeof style[ key ] === "string" ) { - newStyle[ key ] = style[ key ]; + styles[ key ] = style[ key ]; } } } - return newStyle; + return styles; } @@ -761,7 +760,7 @@ $.effects.animateClass = function( value, duration, easing, callback ) { var el = $( this ); return { el: el, - start: getElementStyles.call( this ) + start: getElementStyles( this ) }; }); @@ -777,7 +776,7 @@ $.effects.animateClass = function( value, duration, easing, callback ) { // map all animated objects again - calculate new styles and diff allAnimations = allAnimations.map(function() { - this.end = getElementStyles.call( this.el[ 0 ] ); + this.end = getElementStyles( this.el[ 0 ] ); this.diff = styleDifference( this.start, this.end ); return this; }); |