diff options
Diffstat (limited to 'ui/jquery.effects.scale.js')
-rw-r--r-- | ui/jquery.effects.scale.js | 68 |
1 files changed, 37 insertions, 31 deletions
diff --git a/ui/jquery.effects.scale.js b/ui/jquery.effects.scale.js index 64e31ea96..83b41d3c2 100644 --- a/ui/jquery.effects.scale.js +++ b/ui/jquery.effects.scale.js @@ -1,4 +1,4 @@ -/* +/*! * jQuery UI Effects Scale @VERSION * * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) @@ -30,9 +30,9 @@ $.effects.effect.puff = function( o, done ) { mode: mode, complete: done, percent: hide ? percent : 100, - from: hide - ? original - : { + from: hide ? + original : + { height: original.height * factor, width: original.width * factor } @@ -47,7 +47,8 @@ $.effects.effect.scale = function( o, done ) { var el = $( this ), options = $.extend( true, {}, o ), mode = $.effects.setMode( el, o.mode || "effect" ), - percent = parseInt( o.percent, 10 ) || ( parseInt( o.percent, 10 ) == 0 ? 0 : ( mode == "hide" ? 0 : 100 ) ), + percent = parseInt( o.percent, 10 ) || + ( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode === "hide" ? 0 : 100 ) ), direction = o.direction || "both", origin = o.origin, original = { @@ -57,8 +58,8 @@ $.effects.effect.scale = function( o, done ) { outerWidth: el.outerWidth() }, factor = { - y: direction != "horizontal" ? (percent / 100) : 1, - x: direction != "vertical" ? (percent / 100) : 1 + y: direction !== "horizontal" ? (percent / 100) : 1, + x: direction !== "vertical" ? (percent / 100) : 1 }; // We are going to pass this effect to the size effect: @@ -67,12 +68,12 @@ $.effects.effect.scale = function( o, done ) { options.complete = done; // Set default origin and restore for show/hide - if ( mode != "effect" ) { + if ( mode !== "effect" ) { options.origin = origin || ["middle","center"]; options.restore = true; } - options.from = o.from || ( mode == "show" ? { height: 0, width: 0 } : original ); + options.from = o.from || ( mode === "show" ? { height: 0, width: 0 } : original ); options.to = { height: original.height * factor.y, width: original.width * factor.x, @@ -80,16 +81,17 @@ $.effects.effect.scale = function( o, done ) { outerWidth: original.outerWidth * factor.x }; - if ( options.fade ) { // Fade option to support puff - if ( mode == "show" ) { + // Fade option to support puff + if ( options.fade ) { + if ( mode === "show" ) { options.from.opacity = 0; options.to.opacity = 1; } - if ( mode == "hide" ) { + if ( mode === "hide" ) { options.from.opacity = 1; options.to.opacity = 0; } - }; + } // Animate el.effect( options ); @@ -145,34 +147,34 @@ $.effects.effect.size = function( o, done ) { }; // Scale the css box - if ( scale == "box" || scale == "both" ) { + if ( scale === "box" || scale === "both" ) { // Vertical props scaling if ( factor.from.y !== factor.to.y ) { props = props.concat( vProps ); el.from = $.effects.setTransition( el, vProps, factor.from.y, el.from ); el.to = $.effects.setTransition( el, vProps, factor.to.y, el.to ); - }; + } // Horizontal props scaling if ( factor.from.x !== factor.to.x ) { props = props.concat( hProps ); el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from ); el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to ); - }; - }; + } + } // Scale the content - if ( scale == "content" || scale == "both" ) { + if ( scale === "content" || scale === "both" ) { // Vertical props scaling if ( factor.from.y !== factor.to.y ) { props = props.concat( cProps ); el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from ); el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to ); - }; - }; - + } + } + $.effects.save( el, restore ? props : props1 ); el.show(); $.effects.createWrapper( el ); @@ -189,7 +191,7 @@ $.effects.effect.size = function( o, done ) { el.css( el.from ); // set top & left // Animate - if ( scale == "content" || scale == "both" ) { // Scale the children + if ( scale === "content" || scale === "both" ) { // Scale the children // Add margins/font-size vProps = vProps.concat([ "marginTop", "marginBottom" ]).concat(cProps); @@ -202,8 +204,10 @@ $.effects.effect.size = function( o, done ) { height: child.height(), width: child.width() }; - if (restore) $.effects.save(child, props2); - + if (restore) { + $.effects.save(child, props2); + } + child.from = { height: c_original.height * factor.from.y, width: c_original.width * factor.from.x @@ -214,26 +218,28 @@ $.effects.effect.size = function( o, done ) { }; // Vertical props scaling - if ( factor.from.y != factor.to.y ) { + if ( factor.from.y !== factor.to.y ) { child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from ); child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to ); - }; + } // Horizontal props scaling - if ( factor.from.x != factor.to.x ) { + if ( factor.from.x !== factor.to.x ) { child.from = $.effects.setTransition( child, hProps, factor.from.x, child.from ); child.to = $.effects.setTransition( child, hProps, factor.to.x, child.to ); - }; + } // Animate children child.css( child.from ); child.animate( child.to, o.duration, o.easing, function() { // Restore children - if (restore) $.effects.restore( child, props2 ); + if ( restore ) { + $.effects.restore( child, props2 ); + } }); }); - }; + } // Animate el.animate( el.to, { @@ -244,7 +250,7 @@ $.effects.effect.size = function( o, done ) { if ( el.to.opacity === 0 ) { el.css( "opacity", el.from.opacity ); } - if( mode == "hide" ) { + if( mode === "hide" ) { el.hide(); } $.effects.restore( el, restore ? props : props1 ); |