]> source.dussan.org Git - jquery-ui.git/commitdiff
Effects.*: Updating Effect Method API to avoid duplicating the queue call - Fixes...
authorgnarf <gnarf@gnarf.net>
Tue, 21 Jun 2011 05:23:52 +0000 (00:23 -0500)
committergnarf <gnarf@gnarf.net>
Tue, 21 Jun 2011 06:18:01 +0000 (01:18 -0500)
14 files changed:
ui/jquery.effects.blind.js
ui/jquery.effects.bounce.js
ui/jquery.effects.clip.js
ui/jquery.effects.core.js
ui/jquery.effects.drop.js
ui/jquery.effects.explode.js
ui/jquery.effects.fade.js
ui/jquery.effects.fold.js
ui/jquery.effects.highlight.js
ui/jquery.effects.pulsate.js
ui/jquery.effects.scale.js
ui/jquery.effects.shake.js
ui/jquery.effects.slide.js
ui/jquery.effects.transfer.js

index b6485b6417105f0db7bfe9f1bc5b20fd7ec19fc9..8c536be7877548483432a44965a6f6dabb42300e 100644 (file)
  */
 (function( $, undefined ) {
        
-var rvertical = /up|down|vertical/;
-var rpositivemotion = /up|left|vertical|horizontal/;
+var rvertical = /up|down|vertical/,
+       rpositivemotion = /up|left|vertical|horizontal/;
 
-$.effects.effect.blind = function( o ) {
+$.effects.effect.blind = function( o, next ) {
+       // Create element
+       var el = $( this ),
+               props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
+               mode = $.effects.setMode( el, o.mode || "hide" ),
+               direction = o.direction || "up",
+               vertical = rvertical.test( direction ),
+               ref = vertical ? "height" : "width",
+               ref2 = vertical ? "top" : "left",
+               motion = rpositivemotion.test( direction ),
+               animation = {},
+               show = mode === "show",
+               wrapper, distance;
 
-       return this.queue( function() {
-
-               // Create element
-               var el = $( this ),
-                       props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
-                       mode = $.effects.setMode( el, o.mode || "hide" ),
-                       direction = o.direction || "up",
-                       vertical = rvertical.test( direction ),
-                       ref = vertical ? "height" : "width",
-                       ref2 = vertical ? "top" : "left",
-                       motion = rpositivemotion.test( direction ),
-                       animation = {},
-                       wrapper, distance;
+       // if already wrapped, the wrapper's properties are my property. #6245
+       if ( el.parent().is( ".ui-effects-wrapper" ) ) {
+               $.effects.save( el.parent(), props );
+       } else {
+               $.effects.save( el, props );
+       }
+       el.show(); 
+       wrapper = $.effects.createWrapper( el ).css({ 
+               overflow: "hidden"
+       });
 
-               // if already wrapped, the wrapper's properties are my property. #6245
-               if ( el.parent().is( ".ui-effects-wrapper" ) ) {
-                       $.effects.save( el.parent(), props );
-               } else {
-                       $.effects.save( el, props );
-               }
-               el.show(); 
-               wrapper = $.effects.createWrapper( el ).css({ 
-                       overflow: "hidden"
-               });
+       distance = wrapper[ ref ]();
 
-               distance = wrapper[ ref ]();
+       animation[ ref ] = ( mode === "show" ? distance : 0 );
+       if ( !motion ) {
+               el
+                       .css( vertical ? "bottom" : "right", 0 )
+                       .css( vertical ? "top" : "left", "" )
+                       .css({ position: "absolute" });
+               animation[ ref2 ] = ( mode === "show" ) ? 0 : distance;
+       }
 
-               animation[ ref ] = ( mode === "show" ? distance : 0 );
-               if ( !motion ) {
-                       el
-                               .css( vertical ? "bottom" : "right", 0 )
-                               .css( vertical ? "top" : "left", "" )
-                               .css({ position: "absolute" });
-                       animation[ ref2 ] = ( mode === "show" ) ? 0 : distance;
+       // start at 0 if we are showing
+       if ( mode === "show" ) {
+               wrapper.css( ref, 0 );
+               if ( ! motion ) {
+                       wrapper.css( ref2, distance );
                }
+       }
 
-               // start at 0 if we are showing
-               if ( mode == "show" ) {
-                       wrapper.css( ref, 0 );
-                       if ( ! motion ) {
-                               wrapper.css( ref2, distance );
+       // Animate
+       wrapper.animate( animation, {
+               duration: o.duration,
+               easing: o.easing,
+               queue: false,
+               complete: function() {
+                       if ( mode == "hide" ) {
+                               el.hide();
                        }
-               }
-
-               // Animate
-               wrapper.animate( animation, {
-                       duration: o.duration,
-                       easing: o.easing,
-                       queue: false,
-                       complete: function() {
-                               if ( mode == "hide" ) {
-                                       el.hide();
-                               }
-                               $.effects.restore( el, props ); 
-                               $.effects.removeWrapper( el );
-                               if ( $.isFunction( o.complete ) ) {
-                                       o.complete.apply( el[ 0 ], arguments );
-                               }
-                               el.dequeue();
+                       $.effects.restore( el, props ); 
+                       $.effects.removeWrapper( el );
+                       if ( $.isFunction( o.complete ) ) {
+                               o.complete.apply( el[ 0 ], arguments );
                        }
-               });
-
+                       next();
+               }
        });
 
 };
index 78fedb0ceb55b8b09513e9c412f18c557360777f..f6cf5bb025fb5321ef47d7762bf08e1138066228 100644 (file)
  */
 (function( $, undefined ) {
 
-$.effects.effect.bounce = function(o) {
-
-       return this.queue( function( next ) {
-               var el = $( this ), 
-                       props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
-
-                       // defaults:
-                       mode = $.effects.setMode( el, o.mode || "effect" ),
-                       hide = mode === "hide",
-                       show = mode === "show",
-                       direction = o.direction || "up", 
-                       distance = o.distance,
-                       times = o.times || 5,
-
-                       // number of internal animations
-                       anims = times * 2 + ( show || hide ? 1 : 0 ),
-                       speed = o.duration / anims,
-                       easing = o.easing,
-
-                       // utility:
-                       ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
-                       motion = ( direction === "up" || direction === "left" ), 
-                       i,
-                       upAnim,
-                       downAnim,
-
-                       // we will need to re-assemble the queue to stack our animations in place
-                       queue = el.queue(),
-                       queuelen = queue.length;
-
-               // Avoid touching opacity to prevent clearType and PNG issues in IE     
-               if ( show || hide ) {
-                       props.push( "opacity" );
-               } 
-
-               $.effects.save( el, props ); 
-               el.show(); 
-               $.effects.createWrapper( el ); // Create Wrapper
-
-               // default distance for the BIGGEST bounce is the outer Distance / 3
-               if ( !distance ) {
-                       distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
-               }
-
-               if ( show ) {
-                       downAnim = { opacity: 1 };
-                       downAnim[ ref ] = 0;
-
-                       // if we are showing, force opacity 0 and set the initial position
-                       // then do the "first" animation
-                       el.css( "opacity", 0 )
-                               .css( ref, motion ? -distance*2 : distance*2 )
-                               .animate( downAnim, speed, easing );
-               }
-
-               // start at the smallest distance if we are hiding
-               if ( hide ) {
-                       distance = distance / Math.pow( 2, times - 1 );
-               }
-
-               downAnim = {};
+$.effects.effect.bounce = function( o, next ) {
+       var el = $( this ), 
+               props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
+
+               // defaults:
+               mode = $.effects.setMode( el, o.mode || "effect" ),
+               hide = mode === "hide",
+               show = mode === "show",
+               direction = o.direction || "up", 
+               distance = o.distance,
+               times = o.times || 5,
+
+               // number of internal animations
+               anims = times * 2 + ( show || hide ? 1 : 0 ),
+               speed = o.duration / anims,
+               easing = o.easing,
+
+               // utility:
+               ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
+               motion = ( direction === "up" || direction === "left" ), 
+               i,
+               upAnim,
+               downAnim,
+
+               // we will need to re-assemble the queue to stack our animations in place
+               queue = el.queue(),
+               queuelen = queue.length;
+
+       // Avoid touching opacity to prevent clearType and PNG issues in IE     
+       if ( show || hide ) {
+               props.push( "opacity" );
+       } 
+
+       $.effects.save( el, props ); 
+       el.show(); 
+       $.effects.createWrapper( el ); // Create Wrapper
+
+       // default distance for the BIGGEST bounce is the outer Distance / 3
+       if ( !distance ) {
+               distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
+       }
+
+       if ( show ) {
+               downAnim = { opacity: 1 };
                downAnim[ ref ] = 0;
-               // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
-               for ( i = 0; i < times; i++ ) {
-                       upAnim = {};
-                       upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
-
-                       el.animate( upAnim, speed, easing )
-                               .animate( downAnim, speed, easing );
-
-                       distance = hide ? distance * 2 : distance / 2;
-               }
 
-               // Last Bounce when Hiding
+               // if we are showing, force opacity 0 and set the initial position
+               // then do the "first" animation
+               el.css( "opacity", 0 )
+                       .css( ref, motion ? -distance*2 : distance*2 )
+                       .animate( downAnim, speed, easing );
+       }
+
+       // start at the smallest distance if we are hiding
+       if ( hide ) {
+               distance = distance / Math.pow( 2, times - 1 );
+       }
+
+       downAnim = {};
+       downAnim[ ref ] = 0;
+       // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
+       for ( i = 0; i < times; i++ ) {
+               upAnim = {};
+               upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
+
+               el.animate( upAnim, speed, easing )
+                       .animate( downAnim, speed, easing );
+
+               distance = hide ? distance * 2 : distance / 2;
+       }
+
+       // Last Bounce when Hiding
+       if ( hide ) {
+               upAnim = { opacity: 0 };
+               upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
+
+               el.animate( upAnim, speed, easing );
+       }
+       
+       el.queue( function( next ) {
                if ( hide ) {
-                       upAnim = { opacity: 0 };
-                       upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
-
-                       el.animate( upAnim, speed, easing );
+                       el.hide();
                }
-               
-               el.queue( function( next ) {
-                       if ( hide ) {
-                               el.hide();
-                       }
-                       $.effects.restore( el, props );
-                       $.effects.removeWrapper( el );
-                       if ( o.complete ) {
-                               o.complete.apply( el[ 0 ] );
-                       }
-                       next();
-               });
-
-               // inject all the animations we just queued to be first in line (after "inprogress")
-               if ( queuelen > 1) {
-                       queue.splice.apply( queue,
-                               [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
+               $.effects.restore( el, props );
+               $.effects.removeWrapper( el );
+               if ( o.complete ) {
+                       o.complete.apply( el[ 0 ] );
                }
                next();
-
        });
 
+       // inject all the animations we just queued to be first in line (after "inprogress")
+       if ( queuelen > 1) {
+               queue.splice.apply( queue,
+                       [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
+       }
+       next();
+
 };
 
 })(jQuery);
index dbf0d36c9232e47f863994b9630d89eb1409dfb0..8c5c76e8c37eb775b543c30474d2f59fd6e9088b 100644 (file)
  */
 (function( $, undefined ) {
 
-$.effects.effect.clip = function( o ) {
+$.effects.effect.clip = function( o, next ) {
+       // Create element
+       var el = $( this ),
+               props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
+               mode = $.effects.setMode( el, o.mode || "hide" ),
+               show = mode === "show",
+               direction = o.direction || "vertical",
+               vert = direction === "vertical",
+               size = vert ? "height" : "width",
+               position = vert ? "top" : "left",
+               animation = {},
+               wrapper, animate, distance;
 
-       return this.queue( function() {
+       // Save & Show
+       $.effects.save( el, props );
+       el.show();
 
-               // Create element
-               var el = $( this ),
-                       props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
-                       mode = $.effects.setMode( el, o.mode || "hide" ),
-                       show = mode === "show",
-                       direction = o.direction || "vertical",
-                       vert = direction === "vertical",
-                       size = vert ? "height" : "width",
-                       position = vert ? "top" : "left",
-                       animation = {},
-                       wrapper, animate, distance;
-
-               // Save & Show
-               $.effects.save( el, props );
-               el.show();
-
-               // Create Wrapper
-               wrapper = $.effects.createWrapper( el ).css({
-                       overflow: "hidden"
-               });
-               animate = ( el[0].tagName === "IMG" ) ? wrapper : el;
-               distance = animate[ size ]();
+       // Create Wrapper
+       wrapper = $.effects.createWrapper( el ).css({
+               overflow: "hidden"
+       });
+       animate = ( el[0].tagName === "IMG" ) ? wrapper : el;
+       distance = animate[ size ]();
 
-               // Shift
-               if ( show ) {
-                       animate.css( size, 0 );
-                       animate.css( position, distance / 2 );
-               }
+       // Shift
+       if ( show ) {
+               animate.css( size, 0 );
+               animate.css( position, distance / 2 );
+       }
 
-               // Create Animation Object:
-               animation[ size ] = show ? distance : 0;
-               animation[ position ] = show ? 0 : distance / 2;
+       // Create Animation Object:
+       animation[ size ] = show ? distance : 0;
+       animation[ position ] = show ? 0 : distance / 2;
 
-               // Animate
-               animate.animate( animation, {
-                       queue: false,
-                       duration: o.duration,
-                       easing: o.easing,
-                       complete: function() {
-                               if ( !show ) {
-                                       el.hide();
-                               }
-                               $.effects.restore( el, props );
-                               $.effects.removeWrapper( el );
-                               if ( $.isFunction( o.complete ) ) {
-                                       o.complete.apply( el[ 0 ], arguments );
-                               }
-                               el.dequeue();
+       // Animate
+       animate.animate( animation, {
+               queue: false,
+               duration: o.duration,
+               easing: o.easing,
+               complete: function() {
+                       if ( !show ) {
+                               el.hide();
                        }
-               });
-
+                       $.effects.restore( el, props );
+                       $.effects.removeWrapper( el );
+                       if ( $.isFunction( o.complete ) ) {
+                               o.complete.apply( el[ 0 ], arguments );
+                       }
+                       el.dequeue();
+               }
        });
 
 };
index 00a803360b820545a110945c70bb6d0568e1e559..87fc5a074260ec334abb1bb73669c6f9d41722bb 100644 (file)
@@ -536,6 +536,7 @@ $.fn.extend({
        effect: function( effect, options, speed, callback ) {
                var args = _normalizeArguments.apply( this, arguments ),
                        mode = args.mode,
+                       queue = args.queue,
                        effectMethod = $.effects.effect[ args.effect ],
 
                        // DEPRECATED: remove in 2.0 (#7115)
@@ -554,9 +555,13 @@ $.fn.extend({
                        }
                }
 
+               function run( next ) {
+                       effectMethod.call( this, args, $.isFunction( next ) ? next : $.noop );
+               }
+
                // TODO: remove this check in 2.0, effectMethod will always be true
                if ( effectMethod ) {
-                       return effectMethod.call( this, args );
+                       return queue === false ? this.each( run ) : this.queue( queue || "fx", run );
                } else {
                        // DEPRECATED: remove in 2.0 (#7115)
                        return oldEffectMethod.call(this, {
index 4265b737b4e50bc381b9de3e6e5abf3582d13a9d..a0bdc7d4d33bbedeaa76dd38e131d7125372820a 100644 (file)
  */
 (function( $, undefined ) {
 
-$.effects.effect.drop = function( o ) {
-
-       return this.queue( function() {
-
-               var el = $( this ), 
-                       props = [ 'position', 'top', 'bottom', 'left', 'right', 'opacity', "height", "width" ],
-                       mode = $.effects.setMode( el, o.mode || 'hide' ),
-                       direction = o.direction || 'left',
-                       ref = ( direction == 'up' || direction == 'down' ) ? 'top' : 'left',
-                       motion = ( direction == 'up' || direction == 'left' ) ? 'pos' : 'neg',
-                       animation = {
-                               opacity: mode == 'show' ? 1 : 0
-                       },
-                       distance;
-
-               // Adjust
-               $.effects.save( el, props ); 
-               el.show(); 
-               $.effects.createWrapper( el ); 
-
-               distance = o.distance || el[ ref == 'top' ? 'outerHeight': 'outerWidth' ]({ margin: true }) / 2;
-
-               if ( mode == 'show' ) {
-                       el
-                               .css( 'opacity', 0 )
-                               .css( ref, motion == 'pos' ? -distance : distance );
+$.effects.effect.drop = function( o, next ) {
+
+       var el = $( this ), 
+               props = [ "position", "top", "bottom", "left", "right", "opacity", "height", "width" ],
+               mode = $.effects.setMode( el, o.mode || "hide" ),
+               direction = o.direction || "left",
+               ref = ( direction == "up" || direction == "down" ) ? "top" : "left",
+               motion = ( direction == "up" || direction == "left" ) ? "pos" : "neg",
+               animation = {
+                       opacity: mode == "show" ? 1 : 0
+               },
+               distance;
+
+       // Adjust
+       $.effects.save( el, props ); 
+       el.show(); 
+       $.effects.createWrapper( el ); 
+
+       distance = o.distance || el[ ref == "top" ? "outerHeight": "outerWidth" ]({ margin: true }) / 2;
+
+       if ( mode == "show" ) {
+               el
+                       .css( "opacity", 0 )
+                       .css( ref, motion == "pos" ? -distance : distance );
+       }
+
+       // Animation
+       animation[ ref ] = ((mode == "show") ? (motion == "pos" ? "+=" : "-=") : (motion == "pos" ? "-=" : "+=")) + distance;
+
+       // Animate
+       el.animate( animation, { 
+               queue: false, 
+               duration: o.duration, 
+               easing: o.easing, 
+               complete: function() {
+                       mode == "hide" && el.hide();
+                       $.effects.restore( el, props ); 
+                       $.effects.removeWrapper( el ); 
+                       $.isFunction( o.complete ) && o.complete.apply(this, arguments);
+                       next();
                }
-
-               // Animation
-               animation[ ref ] = ((mode == 'show') ? (motion == 'pos' ? '+=' : '-=') : (motion == 'pos' ? '-=' : '+=')) + distance;
-
-               // Animate
-               el.animate( animation, { 
-                       queue: false, 
-                       duration: o.duration, 
-                       easing: o.easing, 
-                       complete: function() {
-                               mode == 'hide' && el.hide();
-                               $.effects.restore( el, props ); 
-                               $.effects.removeWrapper( el ); 
-                               $.isFunction( o.complete ) && o.complete.apply(this, arguments);
-                               el.dequeue();
-                       }
-               });
-
        });
 
 };
index f5217ecb5f4671802c6f8e1eb71fed0188285a5e..76711c6f270dfb882a328d8eb16d55c47cf98b0d 100644 (file)
  */
 (function( $, undefined ) {
 
-$.effects.effect.explode = function( o ) {
+$.effects.effect.explode = function( o, next ) {
 
-       return this.queue( function( next ) {
+       var rows = o.pieces ? Math.round(Math.sqrt(o.pieces)) : 3,
+               cells = rows,
+               el = $( this ),
+               mode = $.effects.setMode( el, o.mode || "hide" ),
+               show = ( mode == "show" ),
 
-               var rows = o.pieces ? Math.round(Math.sqrt(o.pieces)) : 3,
-                       cells = rows,
-                       el = $( this ),
-                       mode = $.effects.setMode( el, o.mode || 'hide' ),
-                       show = ( mode == 'show' ),
+               // show and then visibility:hidden the element before calculating offset
+               offset = el.show().css( "visibility", "hidden" ).offset(),
 
-                       // show and then visibility:hidden the element before calculating offset
-                       offset = el.show().css( 'visibility', 'hidden' ).offset(),
+               // width and height of a piece
+               width = Math.ceil( el.outerWidth() / cells ),
+               height = Math.ceil( el.outerHeight() / rows ),
+               pieces = [],
 
-                       // width and height of a piece
-                       width = Math.ceil( el.outerWidth() / cells ),
-                       height = Math.ceil( el.outerHeight() / rows ),
-                       pieces = [],
+               // loop
+               i, j, left, top, mx, my;
 
-                       // loop
-                       i, j, left, top, mx, my;
+       // clone the element for each row and cell.
+       for( i = 0; i < rows ; i++ ) { // ===>
+               top = offset.top + i * height;
+               my = i - ( rows - 1 ) / 2 ;
 
-               // clone the element for each row and cell.
-               for( i = 0; i < rows ; i++ ) { // ===>
-                       top = offset.top + i * height;
-                       my = i - ( rows - 1 ) / 2 ;
+               for( j = 0; j < cells ; j++ ) { // |||
+                       left = offset.left + j * width;
+                       mx = j - ( cells - 1 ) / 2 ;
 
-                       for( j = 0; j < cells ; j++ ) { // |||
-                               left = offset.left + j * width;
-                               mx = j - ( cells - 1 ) / 2 ;
+                       // Create a clone of the now hidden main element that will be absolute positioned
+                       // within a wrapper div off the -left and -top equal to size of our pieces
+                       el
+                               .clone()
+                               .appendTo( "body" )
+                               .wrap( "<div></div>" )
+                               .css({
+                                       position: "absolute",
+                                       visibility: "visible",
+                                       left: -j * width,
+                                       top: -i * height
+                               })
 
-                               // Create a clone of the now hidden main element that will be absolute positioned
-                               // within a wrapper div off the -left and -top equal to size of our pieces
-                               el
-                                       .clone()
-                                       .appendTo( 'body' )
-                                       .wrap( '<div></div>' )
-                                       .css({
-                                               position: 'absolute',
-                                               visibility: 'visible',
-                                               left: -j * width,
-                                               top: -i * height
-                                       })
-
-                               // select the wrapper - make it overflow: hidden and absolute positioned based on
-                               // where the original was located +left and +top equal to the size of pieces
-                                       .parent()
-                                       .addClass( 'ui-effects-explode' )
-                                       .css({
-                                               position: 'absolute',
-                                               overflow: 'hidden',
-                                               width: width,
-                                               height: height,
-                                               left: left + ( show ? mx * width : 0 ),
-                                               top: top + ( show ? my * height : 0 ),
-                                               opacity: show ? 0 : 1
-                                       }).animate({
-                                               left: left + ( show ? 0 : mx * width ),
-                                               top: top + ( show ? 0 : my * height ),
-                                               opacity: show ? 1 : 0
-                                       }, o.duration || 500, o.easing, childComplete );
-                       }
+                       // select the wrapper - make it overflow: hidden and absolute positioned based on
+                       // where the original was located +left and +top equal to the size of pieces
+                               .parent()
+                               .addClass( "ui-effects-explode" )
+                               .css({
+                                       position: "absolute",
+                                       overflow: "hidden",
+                                       width: width,
+                                       height: height,
+                                       left: left + ( show ? mx * width : 0 ),
+                                       top: top + ( show ? my * height : 0 ),
+                                       opacity: show ? 0 : 1
+                               }).animate({
+                                       left: left + ( show ? 0 : mx * width ),
+                                       top: top + ( show ? 0 : my * height ),
+                                       opacity: show ? 1 : 0
+                               }, o.duration || 500, o.easing, childComplete );
                }
+       }
 
-               // children animate complete:
-               function childComplete() {
-                       pieces.push( this );
-                       if ( pieces.length == rows * cells ) {
-                               animComplete();
-                       }
+       // children animate complete:
+       function childComplete() {
+               pieces.push( this );
+               if ( pieces.length == rows * cells ) {
+                       animComplete();
                }
+       }
 
-               function animComplete() {
-                       el.css({
-                               visibility: 'visible'
-                       });
-                       $( pieces ).remove();
-                       if ( !show ) {
-                               el.hide();
-                       }
-                       if ( $.isFunction( o.complete ) ) {
-                               o.complete.apply( el[ 0 ] );
-                       }
-                       next();
+       function animComplete() {
+               el.css({
+                       visibility: "visible"
+               });
+               $( pieces ).remove();
+               if ( !show ) {
+                       el.hide();
                }
-       });
-
+               if ( $.isFunction( o.complete ) ) {
+                       o.complete.apply( el[ 0 ] );
+               }
+               next();
+       }
 };
 
 })(jQuery);
index ff1cba5f84a11c98ce63436a4fb04934bf360cf7..8f2d956dcec0f3475914afbbc2c79eb53dee87e0 100644 (file)
  */
 (function( $, undefined ) {
 
-$.effects.effect.fade = function( o ) {
-       return this.queue( function( next ) {
-               var el = $( this ),
-                       mode = $.effects.setMode( el, o.mode || 'toggle' ),
-                       hide = mode === "hide";
+$.effects.effect.fade = function( o, next ) {
+       var el = $( this ),
+               mode = $.effects.setMode( el, o.mode || "toggle" ),
+               hide = mode === "hide";
 
-               el.show();
-               el.animate({ 
-                       opacity: hide ? 0 : 1
-               }, {
-                       queue: false,
-                       duration: o.duration,
-                       easing: o.easing,
-                       complete: function() {
-                               if ( hide ) {
-                                       el.hide();
-                               }
-                               if ( o.complete ) {
-                                       o.complete.call( this );
-                               }
-                               next();
+       el.show();
+       el.animate({ 
+               opacity: hide ? 0 : 1
+       }, {
+               queue: false,
+               duration: o.duration,
+               easing: o.easing,
+               complete: function() {
+                       if ( hide ) {
+                               el.hide();
                        }
-               });
+                       if ( o.complete ) {
+                               o.complete.call( this );
+                       }
+                       next();
+               }
        });
 };
 
index 6100c33a163072f335f12f8952ad65789d5d0a0a..de7530bf035ce70631fd783f278fab631effc276 100644 (file)
  */
 (function( $, undefined ) {
 
-$.effects.effect.fold = function( o ) {
+$.effects.effect.fold = function( o, next ) {
 
-       return this.queue( function() {
+       // Create element
+       var el = $( this ),
+               props = ["position","top","bottom","left","right","height","width"],
+               mode = $.effects.setMode(el, o.mode || "hide"),
+               size = o.size || 15,
+               percent = /([0-9]+)%/.exec(size),
+               horizFirst = !!o.horizFirst,
+               widthFirst = ((mode == "show") != horizFirst),
+               ref = widthFirst ? ["width", "height"] : ["height", "width"],
+               duration = o.duration / 2,
+               wrapper, distance;
 
-               // Create element
-               var el = $( this ),
-                       props = ['position','top','bottom','left','right','height','width'],
-                       mode = $.effects.setMode(el, o.mode || 'hide'),
-                       size = o.size || 15,
-                       percent = /([0-9]+)%/.exec(size),
-                       horizFirst = !!o.horizFirst,
-                       widthFirst = ((mode == 'show') != horizFirst),
-                       ref = widthFirst ? ['width', 'height'] : ['height', 'width'],
-                       duration = o.duration / 2,
-                       wrapper, distance;
+       $.effects.save( el, props );
+       el.show();
 
-               $.effects.save( el, props ); 
-               el.show();
-
-               // Create Wrapper
-               wrapper = $.effects.createWrapper( el ).css({ 
-                       overflow: 'hidden' 
-               }); 
-               distance = widthFirst ? 
-                       [ wrapper.width(), wrapper.height() ] : 
-                       [ wrapper.height(), wrapper.width() ];
-
-               if ( percent ) { 
-                       size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ ( mode == 'hide') ? 0 : 1 ];
-               }
-               mode == 'show' && wrapper.css( horizFirst ? {
-                               height: 0, 
-                               width: size
-                       } : {
-                               height: size, 
-                               width: 0
-                       }); 
+       // Create Wrapper
+       wrapper = $.effects.createWrapper( el ).css({
+               overflow: "hidden"
+       });
+       distance = widthFirst ?
+               [ wrapper.width(), wrapper.height() ] :
+               [ wrapper.height(), wrapper.width() ];
 
-               // Animation
-               var animation1 = {}, animation2 = {};
-               animation1[ ref[ 0 ] ] = mode == 'show' ? distance[ 0 ] : size;
-               animation2[ ref[ 1 ] ] = mode == 'show' ? distance[ 1 ] : 0;
+       if ( percent ) {
+               size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ ( mode == "hide") ? 0 : 1 ];
+       }
+       mode == "show" && wrapper.css( horizFirst ? {
+                       height: 0,
+                       width: size
+               } : {
+                       height: size,
+                       width: 0
+               });
 
-               // Animate
-               wrapper
-                       .animate( animation1, duration, o.easing )
-                       .animate( animation2, duration, o.easing, function() {
-                               (mode == 'hide') && el.hide();
-                               $.effects.restore( el, props ); 
-                               $.effects.removeWrapper( el ); 
-                               jQuery.isFunction(o.complete) && o.complete.apply( el[ 0 ], arguments ); 
-                               el.dequeue();
-                       });
+       // Animation
+       var animation1 = {}, animation2 = {};
+       animation1[ ref[ 0 ] ] = mode == "show" ? distance[ 0 ] : size;
+       animation2[ ref[ 1 ] ] = mode == "show" ? distance[ 1 ] : 0;
 
-       });
+       // Animate
+       wrapper
+               .animate( animation1, duration, o.easing )
+               .animate( animation2, duration, o.easing, function() {
+                       (mode == "hide") && el.hide();
+                       $.effects.restore( el, props );
+                       $.effects.removeWrapper( el );
+                       jQuery.isFunction(o.complete) && o.complete.apply( el[ 0 ], arguments );
+                       next();
+               });
 
 };
 
index cd4f0705a8ddcedb8ac62e235f60a500f16453f7..61826e6963093c52ddca96463f15bc0d32a2e632 100644 (file)
  */
 (function( $, undefined ) {
 
-$.effects.effect.highlight = function( o ) {
-       return this.queue( function() {
-               var elem = $( this ),
-                       props = [ 'backgroundImage', 'backgroundColor', 'opacity' ],
-                       mode = $.effects.setMode( elem, o.mode || 'show' ),
-                       animation = {
-                               backgroundColor: elem.css( 'backgroundColor' )
-                       };
+$.effects.effect.highlight = function( o, next ) {
+       var elem = $( this ),
+               props = [ "backgroundImage", "backgroundColor", "opacity" ],
+               mode = $.effects.setMode( elem, o.mode || "show" ),
+               animation = {
+                       backgroundColor: elem.css( "backgroundColor" )
+               };
 
-               if (mode == 'hide') {
-                       animation.opacity = 0;
-               }
+       if (mode == "hide") {
+               animation.opacity = 0;
+       }
 
-               $.effects.save( elem, props );
-               
-               elem
-                       .show()
-                       .css({
-                               backgroundImage: 'none',
-                               backgroundColor: o.color || '#ffff99'
-                       })
-                       .animate( animation, {
-                               queue: false,
-                               duration: o.duration,
-                               easing: o.easing,
-                               complete: function() {
-                                       (mode == 'hide' && elem.hide());
-                                       $.effects.restore( elem, props );
-                                       (mode == 'show' && !$.support.opacity && this.style.removeAttribute( 'filter' ));
-                                       jQuery.isFunction(o.complete) && o.complete.apply(this, arguments);
-                                       elem.dequeue();
-                               }
-                       });
-       });
+       $.effects.save( elem, props );
+       
+       elem
+               .show()
+               .css({
+                       backgroundImage: "none",
+                       backgroundColor: o.color || "#ffff99"
+               })
+               .animate( animation, {
+                       queue: false,
+                       duration: o.duration,
+                       easing: o.easing,
+                       complete: function() {
+                               (mode == "hide" && elem.hide());
+                               $.effects.restore( elem, props );
+                               (mode == "show" && !$.support.opacity && this.style.removeAttribute( "filter" ));
+                               jQuery.isFunction(o.complete) && o.complete.apply(this, arguments);
+                               next();
+                       }
+               });
 };
 
 })(jQuery);
index a0ddf51fd93a57139760c8d6f4da09c26b573631..bc257f62433587fd0f5208f4ea7ad5fa8483b4d6 100644 (file)
  */
 (function( $, undefined ) {
 
-$.effects.effect.pulsate = function( o ) {
-       return this.queue( function( next ) {
-               var elem = $( this ),
-                       mode = $.effects.setMode( elem, o.mode || "show" ),
-                       show = mode === "show",
-                       hide = mode === "hide",
-                       showhide = ( show || mode === "hide" ),
+$.effects.effect.pulsate = function( o, next ) {
+       var elem = $( this ),
+               mode = $.effects.setMode( elem, o.mode || "show" ),
+               show = mode === "show",
+               hide = mode === "hide",
+               showhide = ( show || mode === "hide" ),
 
-                       // showing or hiding leaves of the "last" animation
-                       anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
-                       duration = o.duration / anims,
-                       animateTo = 0,
-                       queue = elem.queue(),
-                       queuelen = queue.length,
-                       i;
+               // showing or hiding leaves of the "last" animation
+               anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
+               duration = o.duration / anims,
+               animateTo = 0,
+               queue = elem.queue(),
+               queuelen = queue.length,
+               i;
 
-               if ( show || !elem.is(':visible')) {
-                       elem.css( "opacity", 0 ).show();
-                       animateTo = 1;
-               }
-
-               // anims - 1 opacity "toggles"
-               for ( i = 1; i < anims; i++ ) {
-                       elem.animate({
-                               opacity: animateTo
-                       }, duration, o.easing );
-                       animateTo = 1 - animateTo;
-               }
+       if ( show || !elem.is(":visible")) {
+               elem.css( "opacity", 0 ).show();
+               animateTo = 1;
+       }
 
+       // anims - 1 opacity "toggles"
+       for ( i = 1; i < anims; i++ ) {
                elem.animate({
                        opacity: animateTo
-               }, duration, o.easing);
+               }, duration, o.easing );
+               animateTo = 1 - animateTo;
+       }
 
-               elem.queue( function( next ) {
-                       if ( hide ) {
-                               elem.hide();
-                       }
-                       if ( o.complete ) {
-                               o.complete.apply( this );
-                       }
-                       next();
-               });
+       elem.animate({
+               opacity: animateTo
+       }, duration, o.easing);
 
-               // We just queued up "anims" animations, we need to put them next in the queue
-               if ( queuelen > 1) {
-                       queue.splice.apply( queue,
-                               [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
+       elem.queue( function( next ) {
+               if ( hide ) {
+                       elem.hide();
+               }
+               if ( o.complete ) {
+                       o.complete.apply( this );
                }
                next();
        });
+
+       // We just queued up "anims" animations, we need to put them next in the queue
+       if ( queuelen > 1 ) {
+               queue.splice.apply( queue,
+                       [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
+       }
+       next();
 };
 
 })(jQuery);
index e00d824977fac0b75852f6dc4d54284e87af3ff8..614943cfb7beaa024a66f414d098d26a32a9ae4e 100644 (file)
  */
 (function( $, undefined ) {
 
-$.effects.effect.puff = function( o ) {
-       return this.queue( function() {
-               var elem = $( this ),
-                       mode = $.effects.setMode( elem, o.mode || 'hide' ),
-                       percent = parseInt( o.percent, 10 ) || 150,
-                       factor = percent / 100,
-                       original = { 
-                               height: elem.height(), 
-                               width: elem.width() 
-                       };
-
-               $.extend(o, {
-                       effect: 'scale',
-                       queue: false,
-                       fade: true,
-                       mode: mode,
-                       percent: mode == 'hide' ? percent : 100,
-                       from: mode == 'hide'
-                               ? original
-                               : {
-                                       height: original.height * factor,
-                                       width: original.width * factor
-                               }
-               });
-
-               elem.effect( o );
-       });
-};
-
-$.effects.effect.scale = function( o ) {
-
-       return this[ o.queue === false ? "each" : "queue" ]( function() {
-
-               // Create element
-               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 ) ),
-                       direction = o.direction || 'both',
-                       origin = o.origin,
-                       original = { 
-                               height: el.height(), 
-                               width: el.width(),
-                               outerHeight: el.outerHeight(),
-                               outerWidth: el.outerWidth()
-                       },
-                       factor = {
-                               y: direction != 'horizontal' ? (percent / 100) : 1,
-                               x: direction != 'vertical' ? (percent / 100) : 1
-                       }; 
-
-               // We are going to pass this effect to the size effect:
-               options.effect = "size";
-               options.queue = false;
-
-               // Set default origin and restore for show/hide
-               if ( mode != 'effect' ) { 
-                       options.origin = origin || ['middle','center'];
-                       options.restore = true;
+function compFunction( el, complete, next ) {
+       return function() {
+               if ( $.isFunction( complete ) ) {
+                       complete.apply( el );
                }
+               next();
+       };
+};
 
-               options.from = o.from || ( mode == 'show' ? { height: 0, width: 0 } : original ); 
-               options.to = {
-                       height: original.height * factor.y, 
-                       width: original.width * factor.x,
-                       outerHeight: original.outerHeight * factor.y, 
-                       outerWidth: original.outerWidth * factor.x
-               }; 
-
-               if ( options.fade ) { // Fade option to support puff
-                       if ( mode == 'show' ) {
-                               options.from.opacity = 0; 
-                               options.to.opacity = 1;
-                       }
-                       if ( mode == 'hide' ) {
-                               options.from.opacity = 1; 
-                               options.to.opacity = 0;
-                       }
+$.effects.effect.puff = function( o, next ) {
+       var elem = $( this ),
+               mode = $.effects.setMode( elem, o.mode || "hide" ),
+               percent = parseInt( o.percent, 10 ) || 150,
+               factor = percent / 100,
+               original = { 
+                       height: elem.height(), 
+                       width: elem.width() 
                };
 
-               // Animate
-               el.effect(options);
+       $.extend( o, {
+               effect: "scale",
+               queue: false,
+               fade: true,
+               mode: mode,
+               complete: compFunction( this, o.complete, next ),
+               percent: mode == "hide" ? percent : 100,
+               from: mode == "hide"
+                       ? original
+                       : {
+                               height: original.height * factor,
+                               width: original.width * factor
+                       }
        });
 
+       elem.effect( o );
 };
 
-$.effects.effect.size = function( o ) {
-
-       return this[ o.queue === false ? "each" : "queue" ]( function() {
-               // Create element
-               var el = $( this ), 
-                       props = [ 'position', 'top', 'bottom', 'left', 'right', 'width', 'height', 'overflow', 'opacity' ],
-
-                       // Always restore
-                       props1 = [ 'position', 'top', 'bottom', 'left', 'right', 'overflow', 'opacity' ],
-
-                       // Copy for children
-                       props2 = [ 'width', 'height', 'overflow' ],
-                       cProps = [ 'fontSize' ],
-                       vProps = [ 'borderTopWidth', 'borderBottomWidth', 'paddingTop', 'paddingBottom' ],
-                       hProps = [ 'borderLeftWidth', 'borderRightWidth', 'paddingLeft', 'paddingRight' ],
-
-                       // Set options
-                       mode = $.effects.setMode( el, o.mode || 'effect' ),
-                       restore = o.restore || mode !== "effect",
-                       scale = o.scale || 'both',
-                       origin = o.origin || [ "middle", "center" ],
-                       original, baseline, factor,
-                       position = el.css( "position" ),
-                       originalVerticalPositioning = el.css( "bottom" ) !== "auto" ? "bottom" : "top";
-                       originalHorizontalPositioning = el.css( "right" ) !== "auto" ? "right" : "left";
-
-               if ( mode === "show" ) {
-                       el.show();
-               }
-               original = {
+$.effects.effect.scale = function( o, next ) {
+
+       // Create element
+       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 ) ),
+               direction = o.direction || "both",
+               origin = o.origin,
+               original = { 
                        height: el.height(), 
                        width: el.width(),
                        outerHeight: el.outerHeight(),
                        outerWidth: el.outerWidth()
-               };
+               },
+               factor = {
+                       y: direction != "horizontal" ? (percent / 100) : 1,
+                       x: direction != "vertical" ? (percent / 100) : 1
+               }; 
 
-               el.from = o.from || original;
-               el.to = o.to || original;
+       // We are going to pass this effect to the size effect:
+       options.effect = "size";
+       options.queue = false;
+       options.complete = compFunction( this, options.complete, next );
+
+       // Set default origin and restore for show/hide
+       if ( mode != "effect" ) { 
+               options.origin = origin || ["middle","center"];
+               options.restore = true;
+       }
+
+       options.from = o.from || ( mode == "show" ? { height: 0, width: 0 } : original ); 
+       options.to = {
+               height: original.height * factor.y, 
+               width: original.width * factor.x,
+               outerHeight: original.outerHeight * factor.y, 
+               outerWidth: original.outerWidth * factor.x
+       }; 
+
+       if ( options.fade ) { // Fade option to support puff
+               if ( mode == "show" ) {
+                       options.from.opacity = 0; 
+                       options.to.opacity = 1;
+               }
+               if ( mode == "hide" ) {
+                       options.from.opacity = 1; 
+                       options.to.opacity = 0;
+               }
+       };
 
-               // Set scaling factor
-               factor = {
-                       from: {
-                               y: el.from.height / original.height, 
-                               x: el.from.width / original.width
-                       },
-                       to: {
-                               y: el.to.height / original.height, 
-                               x: el.to.width / original.width
-                       }
-               };
+       // Animate
+       el.effect( options );
 
-               // Scale the css box
-               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 );
-                       };
+$.effects.effect.size = function( o, next ) {
+
+       // Create element
+       var el = $( this ), 
+               props = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ],
+
+               // Always restore
+               props1 = [ "position", "top", "bottom", "left", "right", "overflow", "opacity" ],
+
+               // Copy for children
+               props2 = [ "width", "height", "overflow" ],
+               cProps = [ "fontSize" ],
+               vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
+               hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
+
+               // Set options
+               mode = $.effects.setMode( el, o.mode || "effect" ),
+               restore = o.restore || mode !== "effect",
+               scale = o.scale || "both",
+               origin = o.origin || [ "middle", "center" ],
+               original, baseline, factor,
+               position = el.css( "position" ),
+               originalVerticalPositioning = el.css( "bottom" ) !== "auto" ? "bottom" : "top";
+               originalHorizontalPositioning = el.css( "right" ) !== "auto" ? "right" : "left";
+
+       if ( mode === "show" ) {
+               el.show();
+       }
+       original = {
+               height: el.height(), 
+               width: el.width(),
+               outerHeight: el.outerHeight(),
+               outerWidth: el.outerWidth()
+       };
+
+       el.from = o.from || original;
+       el.to = o.to || original;
+
+       // Set scaling factor
+       factor = {
+               from: {
+                       y: el.from.height / original.height, 
+                       x: el.from.width / original.width
+               },
+               to: {
+                       y: el.to.height / original.height, 
+                       x: el.to.width / original.width
+               }
+       };
 
-                       // 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 css box
+       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 );
                };
 
-               // Scale the content
-               if ( scale == 'content' || scale == 'both' ) { 
+               // 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 );
+               };
+       };
 
-                       // 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 );
-                       };
+       // Scale the content
+       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 );
-               el.css( 'overflow', 'hidden' ).css( el.from ); 
-
-               // Adjust
-               if (origin) { // Calculate baseline shifts
-                       baseline = $.effects.getBaseline( origin, original );
-                       el.from.top = ( original.outerHeight - el.outerHeight() ) * baseline.y;
-                       el.from.left = ( original.outerWidth - el.outerWidth() ) * baseline.x;
-                       el.to.top = ( original.outerHeight - el.to.outerHeight ) * baseline.y;
-                       el.to.left = ( original.outerWidth - el.to.outerWidth ) * baseline.x;
-               }
-               el.css( el.from ); // set top & left
-
-               // Animate
-               if ( scale == 'content' || scale == 'both' ) { // Scale the children
-
-                       // Add margins/font-size
-                       vProps = vProps.concat([ 'marginTop', 'marginBottom' ]).concat(cProps);
-                       hProps = hProps.concat([ 'marginLeft', 'marginRight' ]);
-                       props2 = props.concat(vProps).concat(hProps);
-
-                       el.find( "*[width]" ).each( function(){
-                               var child = $( this ),
-                                       c_original = { 
-                                               height: child.height(), 
-                                               width: child.width()
-                                       };
-                               if (restore) $.effects.save(child, props2);
-                               
-                               child.from = {
-                                       height: c_original.height * factor.from.y, 
-                                       width: c_original.width * factor.from.x
-                               };
-                               child.to = {
-                                       height: c_original.height * factor.to.y, 
-                                       width: c_original.width * factor.to.x
+       };
+       
+       $.effects.save( el, restore ? props : props1 ); 
+       el.show(); 
+       $.effects.createWrapper( el );
+       el.css( "overflow", "hidden" ).css( el.from ); 
+
+       // Adjust
+       if (origin) { // Calculate baseline shifts
+               baseline = $.effects.getBaseline( origin, original );
+               el.from.top = ( original.outerHeight - el.outerHeight() ) * baseline.y;
+               el.from.left = ( original.outerWidth - el.outerWidth() ) * baseline.x;
+               el.to.top = ( original.outerHeight - el.to.outerHeight ) * baseline.y;
+               el.to.left = ( original.outerWidth - el.to.outerWidth ) * baseline.x;
+       }
+       el.css( el.from ); // set top & left
+
+       // Animate
+       if ( scale == "content" || scale == "both" ) { // Scale the children
+
+               // Add margins/font-size
+               vProps = vProps.concat([ "marginTop", "marginBottom" ]).concat(cProps);
+               hProps = hProps.concat([ "marginLeft", "marginRight" ]);
+               props2 = props.concat(vProps).concat(hProps);
+
+               el.find( "*[width]" ).each( function(){
+                       var child = $( this ),
+                               c_original = { 
+                                       height: child.height(), 
+                                       width: child.width()
                                };
+                       if (restore) $.effects.save(child, props2);
+                       
+                       child.from = {
+                               height: c_original.height * factor.from.y, 
+                               width: c_original.width * factor.from.x
+                       };
+                       child.to = {
+                               height: c_original.height * factor.to.y, 
+                               width: c_original.width * factor.to.x
+                       };
 
-                               // Vertical props scaling
-                               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 );
-                               };
+                       // Vertical props scaling
+                       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 ) {
-                                       child.from = $.effects.setTransition( child, hProps, factor.from.x, child.from );
-                                       child.to = $.effects.setTransition( child, hProps, factor.to.x, child.to );
-                               };
+                       // Horizontal props scaling
+                       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() {
+                       // Animate children
+                       child.css( child.from );
+                       child.animate( child.to, o.duration, o.easing, function() {
 
-                                       // Restore children
-                                       if (restore) $.effects.restore( child, props2 ); 
-                               });
+                               // Restore children
+                               if (restore) $.effects.restore( child, props2 ); 
                        });
-               };
-
-               // Animate
-               el.animate( el.to, { 
-                       queue: false, 
-                       duration: o.duration, 
-                       easing: o.easing, 
-                       complete: function() {
-                               if ( el.to.opacity === 0 ) {
-                                       el.css( 'opacity', el.from.opacity );
-                               }
-                               if( mode == 'hide' ) {
-                                       el.hide();
-                               }
-                               $.effects.restore( el, restore ? props : props1 );
+               });
+       };
+
+       // Animate
+       el.animate( el.to, { 
+               queue: false, 
+               duration: o.duration, 
+               easing: o.easing, 
+               complete: function() {
+                       if ( el.to.opacity === 0 ) {
+                               el.css( "opacity", el.from.opacity );
+                       }
+                       if( mode == "hide" ) {
+                               el.hide();
+                       }
+                       $.effects.restore( el, restore ? props : props1 );
+                       if ( !restore ) {
 
-                               // we need to recalculate our positioning based on the new scaling
+                               // we need to calculate our new positioning based on the scaling
                                if ( position === "static" ) {
                                        el.css({
                                                position: "relative",
@@ -292,13 +298,14 @@ $.effects.effect.size = function( o ) {
                                                });
                                        });
                                }
-
-                               $.effects.removeWrapper( el ); 
-                               $.isFunction( o.complete ) && o.complete.apply( this, arguments ); // Callback
-                               el.dequeue();
                        }
-               });
 
+                       $.effects.removeWrapper( el );
+                       if ( $.isFunction( o.complete ) ) {
+                               o.complete.apply( this, arguments );
+                       }
+                       next();
+               }
        });
 
 };
index 52ab331e8b48f7553da5e2c64d16b148045a46f2..82d7ae97e5cece08ec8f35324bc357c2b9cb73eb 100644 (file)
  */
 (function( $, undefined ) {
 
-$.effects.effect.shake = function( o ) {
+$.effects.effect.shake = function( o, next ) {
 
-       return this.queue( function() {
+       var el = $( this ),
+               props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
+               mode = $.effects.setMode( el, o.mode || "effect" ),
+               direction = o.direction || "left",
+               distance = o.distance || 20,
+               times = o.times || 3,
+               anims = times * 2 + 1,
+               speed = o.duration,
+               ref = (direction == "up" || direction == "down") ? "top" : "left",
+               motion = (direction == "up" || direction == "left") ? "pos" : "neg",
+               animation = {},
+               animation1 = {},
+               animation2 = {},
+               i,
 
-               var el = $( this ),
-                       props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
-                       mode = $.effects.setMode( el, o.mode || "effect" ),
-                       direction = o.direction || "left",
-                       distance = o.distance || 20,
-                       times = o.times || 3,
-                       anims = times * 2 + 1,
-                       speed = o.duration,
-                       ref = (direction == "up" || direction == "down") ? "top" : "left",
-                       motion = (direction == "up" || direction == "left") ? "pos" : "neg",
-                       animation = {},
-                       animation1 = {},
-                       animation2 = {},
-                       i,
+               // we will need to re-assemble the queue to stack our animations in place
+               queue = el.queue(),
+               queuelen = queue.length;
+               
 
-                       // we will need to re-assemble the queue to stack our animations in place
-                       queue = el.queue(),
-                       queuelen = queue.length;
-                       
+       $.effects.save( el, props );
+       el.show();
+       $.effects.createWrapper( el );
 
-               $.effects.save( el, props );
-               el.show();
-               $.effects.createWrapper( el );
+       // Animation
+       animation[ ref ] = ( motion == "pos" ? "-=" : "+=" ) + distance;
+       animation1[ ref ] = ( motion == "pos" ? "+=" : "-=" ) + distance * 2;
+       animation2[ ref ] = ( motion == "pos" ? "-=" : "+=" ) + distance * 2;
 
-               // Animation
-               animation[ ref ] = ( motion == "pos" ? "-=" : "+=" ) + distance;
-               animation1[ ref ] = ( motion == "pos" ? "+=" : "-=" ) + distance * 2;
-               animation2[ ref ] = ( motion == "pos" ? "-=" : "+=" ) + distance * 2;
+       // Animate
+       el.animate( animation, speed, o.easing );
 
-               // Animate
-               el.animate( animation, speed, o.easing );
+       // Shakes
+       for ( i = 1; i < times; i++ ) {
+               el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing );
+       };
+       el
+               .animate( animation1, speed, o.easing )
+               .animate( animation, speed / 2, o.easing )
+               .queue( function( next ) {
+                       if ( mode === "hide" ) {
+                               el.hide();
+                       }
+                       $.effects.restore( el, props );
+                       $.effects.removeWrapper( el );
+                       $.isFunction( o.complete ) && o.complete.apply( this, arguments );
+                       next();
+               });
 
-               // Shakes
-               for ( i = 1; i < times; i++ ) {
-                       el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing );
-               };
-               el
-                       .animate( animation1, speed, o.easing )
-                       .animate( animation, speed / 2, o.easing )
-                       .queue( function( next ) {
-                               if ( mode === "hide" ) {
-                                       el.hide();
-                               }
-                               $.effects.restore( el, props );
-                               $.effects.removeWrapper( el );
-                               $.isFunction( o.complete ) && o.complete.apply( this, arguments );
-                               next();
-                       });
-
-               // inject all the animations we just queued to be first in line (after "inprogress")
-               if ( queuelen > 1) {
-                       queue.splice.apply( queue,
-                               [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
-               }
-               el.dequeue();
-       });
+       // inject all the animations we just queued to be first in line (after "inprogress")
+       if ( queuelen > 1) {
+               queue.splice.apply( queue,
+                       [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
+       }
+       next();
 
 };
 
index ccb13fa1bebd137088b9aebb995ff1eb087af4c1..7ed744284018156649cc24a6396aa1955e9ad5cf 100644 (file)
  */
 (function( $, undefined ) {
 
-$.effects.effect.slide = function( o ) {
+$.effects.effect.slide = function( o, next ) {
 
-       return this.queue( function() {
+       // Create element
+       var el = $( this ),
+               props = [ "position", "top", "bottom", "left", "right", "width", "height" ],
+               mode = $.effects.setMode( el, o.mode || "show" ),
+               direction = o.direction || "left",
+               ref = (direction == "up" || direction == "down") ? "top" : "left",
+               motion = (direction == "up" || direction == "left") ? "pos" : "neg",
+               distance,
+               animation = {},
+               size;
 
-               // Create element
-               var el = $( this ),
-                       props = [ "position", "top", "bottom", "left", "right", "width", "height" ],
-                       mode = $.effects.setMode( el, o.mode || 'show' ),
-                       direction = o.direction || 'left',
-                       ref = (direction == 'up' || direction == 'down') ? 'top' : 'left',
-                       motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg',
-                       distance,
-                       animation = {},
-                       size;
-
-               // Adjust
-               $.effects.save( el, props );
-               el.show();
-               distance = o.distance || el[ ref == 'top' ? "outerHeight" : "outerWidth" ]({ 
-                       margin: true
-               });
-               
-               $.effects.createWrapper( el ).css({
-                       overflow: 'hidden'
-               });
-               
-               if (mode == 'show') {
-                       el.css( ref, motion == 'pos' ? (isNaN(distance) ? "-" + distance : -distance) : distance );
-               }
+       // Adjust
+       $.effects.save( el, props );
+       el.show();
+       distance = o.distance || el[ ref == "top" ? "outerHeight" : "outerWidth" ]({ 
+               margin: true
+       });
+       
+       $.effects.createWrapper( el ).css({
+               overflow: "hidden"
+       });
+       
+       if (mode == "show") {
+               el.css( ref, motion == "pos" ? (isNaN(distance) ? "-" + distance : -distance) : distance );
+       }
 
-               // Animation
-               animation[ ref ] = ( mode == 'show' ? 
-                       (motion == 'pos' ? '+=' : '-=') : 
-                       (motion == 'pos' ? '-=' : '+=')) 
-                       + distance;
+       // Animation
+       animation[ ref ] = ( mode == "show" ? 
+               (motion == "pos" ? "+=" : "-=") : 
+               (motion == "pos" ? "-=" : "+=")) 
+               + distance;
 
-               // Animate
-               el.animate( animation, { 
-                       queue: false, 
-                       duration: o.duration, 
-                       easing: o.easing, 
-                       complete: function() {
-                               if ( mode == 'hide' ) {
-                                       el.hide(); 
-                               }
-                               $.effects.restore( el, props );
-                               $.effects.removeWrapper( el );
-                               $.isFunction(o.complete) && o.complete.apply( this, arguments ); 
-                               el.dequeue();
+       // Animate
+       el.animate( animation, { 
+               queue: false, 
+               duration: o.duration, 
+               easing: o.easing, 
+               complete: function() {
+                       if ( mode == "hide" ) {
+                               el.hide(); 
                        }
-               });
-
+                       $.effects.restore( el, props );
+                       $.effects.removeWrapper( el );
+                       $.isFunction(o.complete) && o.complete.apply( this, arguments ); 
+                       next();
+               }
        });
 
 };
index f0f9d9fd4bbabf30233a7e51e23de9ecd9579e27..061882fecb5836cda061f09dbe0b39c1e49dec67 100644 (file)
  */
 (function( $, undefined ) {
 
-$.effects.effect.transfer = function( o ) {
-       
-       return this.queue( function() {
-               var elem = $( this ),
-                       target = $( o.to ),
-                       targetFixed = target.css( "position" ) === "fixed",
-                       body = $("body"),
-                       fixTop = targetFixed ? body.scrollTop() : 0,
-                       fixLeft = targetFixed ? body.scrollLeft() : 0,
-                       endPosition = target.offset(),
-                       animation = {
-                               top: endPosition.top - fixTop ,
-                               left: endPosition.left - fixLeft ,
-                               height: target.innerHeight(),
-                               width: target.innerWidth()
-                       },
-                       startPosition = elem.offset(),
-                       transfer = $( '<div class="ui-effects-transfer"></div>' )
-                               .appendTo( document.body )
-                               .addClass( o.className )
-                               .css({
-                                       top: startPosition.top - fixTop ,
-                                       left: startPosition.left - fixLeft ,
-                                       height: elem.innerHeight(),
-                                       width: elem.innerWidth(),
-                                       position: targetFixed ? "fixed" : "absolute"
-                               })
-                               .animate( animation, o.duration, o.easing, function() {
-                                       transfer.remove();
-                                       $.isFunction( o.complete ) && o.complete.apply(elem[0], arguments);
-                                       elem.dequeue();
-                               });
-       });
+$.effects.effect.transfer = function( o, next ) {
+       var elem = $( this ),
+               target = $( o.to ),
+               targetFixed = target.css( "position" ) === "fixed",
+               body = $("body"),
+               fixTop = targetFixed ? body.scrollTop() : 0,
+               fixLeft = targetFixed ? body.scrollLeft() : 0,
+               endPosition = target.offset(),
+               animation = {
+                       top: endPosition.top - fixTop ,
+                       left: endPosition.left - fixLeft ,
+                       height: target.innerHeight(),
+                       width: target.innerWidth()
+               },
+               startPosition = elem.offset(),
+               transfer = $( '<div class="ui-effects-transfer"></div>' )
+                       .appendTo( document.body )
+                       .addClass( o.className )
+                       .css({
+                               top: startPosition.top - fixTop ,
+                               left: startPosition.left - fixLeft ,
+                               height: elem.innerHeight(),
+                               width: elem.innerWidth(),
+                               position: targetFixed ? "fixed" : "absolute"
+                       })
+                       .animate( animation, o.duration, o.easing, function() {
+                               transfer.remove();
+                               $.isFunction( o.complete ) && o.complete.apply(elem[0], arguments);
+                               next();
+                       });
 };
 
 })(jQuery);