From 1c1a3b1a361d90a73755fbd038b3cdfb0960c29f Mon Sep 17 00:00:00 2001 From: gnarf Date: Tue, 21 Jun 2011 00:23:52 -0500 Subject: Effects.*: Updating Effect Method API to avoid duplicating the queue call - Fixes #7318 - Add the queue functions to $.fn.effect() --- ui/jquery.effects.highlight.js | 62 ++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 32 deletions(-) (limited to 'ui/jquery.effects.highlight.js') diff --git a/ui/jquery.effects.highlight.js b/ui/jquery.effects.highlight.js index cd4f0705a..61826e696 100644 --- a/ui/jquery.effects.highlight.js +++ b/ui/jquery.effects.highlight.js @@ -12,40 +12,38 @@ */ (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); -- cgit v1.2.3 From 65a6c46e5568c43a9df9505e23da6a766814557e Mon Sep 17 00:00:00 2001 From: gnarf Date: Tue, 21 Jun 2011 01:15:42 -0500 Subject: Effects.*: Style Guidance --- ui/jquery.effects.blind.js | 16 ++++++++-------- ui/jquery.effects.bounce.js | 2 +- ui/jquery.effects.drop.js | 16 ++++++++++------ ui/jquery.effects.explode.js | 4 ++-- ui/jquery.effects.fold.js | 34 +++++++++++++++++++++------------- ui/jquery.effects.highlight.js | 11 +++++++---- ui/jquery.effects.scale.js | 5 +++-- ui/jquery.effects.shake.js | 12 +++++++----- ui/jquery.effects.slide.js | 21 ++++++++++++--------- ui/jquery.effects.transfer.js | 4 +++- 10 files changed, 74 insertions(+), 51 deletions(-) (limited to 'ui/jquery.effects.highlight.js') diff --git a/ui/jquery.effects.blind.js b/ui/jquery.effects.blind.js index 8c536be78..09d6a9e57 100644 --- a/ui/jquery.effects.blind.js +++ b/ui/jquery.effects.blind.js @@ -11,7 +11,7 @@ * jquery.effects.core.js */ (function( $, undefined ) { - + var rvertical = /up|down|vertical/, rpositivemotion = /up|left|vertical|horizontal/; @@ -35,24 +35,24 @@ $.effects.effect.blind = function( o, next ) { } else { $.effects.save( el, props ); } - el.show(); - wrapper = $.effects.createWrapper( el ).css({ + el.show(); + wrapper = $.effects.createWrapper( el ).css({ overflow: "hidden" }); distance = wrapper[ ref ](); - animation[ ref ] = ( mode === "show" ? distance : 0 ); + animation[ ref ] = 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[ ref2 ] = show ? 0 : distance; } // start at 0 if we are showing - if ( mode === "show" ) { + if ( show ) { wrapper.css( ref, 0 ); if ( ! motion ) { wrapper.css( ref2, distance ); @@ -65,10 +65,10 @@ $.effects.effect.blind = function( o, next ) { easing: o.easing, queue: false, complete: function() { - if ( mode == "hide" ) { + if ( mode === "hide" ) { el.hide(); } - $.effects.restore( el, props ); + $.effects.restore( el, props ); $.effects.removeWrapper( el ); if ( $.isFunction( o.complete ) ) { o.complete.apply( el[ 0 ], arguments ); diff --git a/ui/jquery.effects.bounce.js b/ui/jquery.effects.bounce.js index f6cf5bb02..38171c32e 100644 --- a/ui/jquery.effects.bounce.js +++ b/ui/jquery.effects.bounce.js @@ -61,7 +61,7 @@ $.effects.effect.bounce = function( o, next ) { // 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 ) + .css( ref, motion ? -distance * 2 : distance * 2 ) .animate( downAnim, speed, easing ); } diff --git a/ui/jquery.effects.drop.js b/ui/jquery.effects.drop.js index a0bdc7d4d..2fba49d92 100644 --- a/ui/jquery.effects.drop.js +++ b/ui/jquery.effects.drop.js @@ -17,11 +17,12 @@ $.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" ), + show = mode === "show", direction = o.direction || "left", - ref = ( direction == "up" || direction == "down" ) ? "top" : "left", - motion = ( direction == "up" || direction == "left" ) ? "pos" : "neg", + ref = ( direction === "up" || direction === "down" ) ? "top" : "left", + motion = ( direction === "up" || direction === "left" ) ? "pos" : "neg", animation = { - opacity: mode == "show" ? 1 : 0 + opacity: show ? 1 : 0 }, distance; @@ -32,14 +33,17 @@ $.effects.effect.drop = function( o, next ) { distance = o.distance || el[ ref == "top" ? "outerHeight": "outerWidth" ]({ margin: true }) / 2; - if ( mode == "show" ) { + if ( show ) { el .css( "opacity", 0 ) .css( ref, motion == "pos" ? -distance : distance ); } // Animation - animation[ ref ] = ((mode == "show") ? (motion == "pos" ? "+=" : "-=") : (motion == "pos" ? "-=" : "+=")) + distance; + animation[ ref ] = ( show ? + ( motion === "pos" ? "+=" : "-=" ) : + ( motion === "pos" ? "-=" : "+=" ) ) + + distance; // Animate el.animate( animation, { @@ -50,7 +54,7 @@ $.effects.effect.drop = function( o, next ) { mode == "hide" && el.hide(); $.effects.restore( el, props ); $.effects.removeWrapper( el ); - $.isFunction( o.complete ) && o.complete.apply(this, arguments); + $.isFunction( o.complete ) && o.complete.apply( this, arguments ); next(); } }); diff --git a/ui/jquery.effects.explode.js b/ui/jquery.effects.explode.js index 76711c6f2..0deb2be9f 100644 --- a/ui/jquery.effects.explode.js +++ b/ui/jquery.effects.explode.js @@ -14,11 +14,11 @@ $.effects.effect.explode = function( o, next ) { - var rows = o.pieces ? Math.round(Math.sqrt(o.pieces)) : 3, + 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 = mode === "show", // show and then visibility:hidden the element before calculating offset offset = el.show().css( "visibility", "hidden" ).offset(), diff --git a/ui/jquery.effects.fold.js b/ui/jquery.effects.fold.js index de7530bf0..b2a02ba78 100644 --- a/ui/jquery.effects.fold.js +++ b/ui/jquery.effects.fold.js @@ -16,15 +16,18 @@ $.effects.effect.fold = function( o, next ) { // Create element var el = $( this ), - props = ["position","top","bottom","left","right","height","width"], - mode = $.effects.setMode(el, o.mode || "hide"), + props = [ "position", "top", "bottom", "left", "right", "height", "width" ], + mode = $.effects.setMode( el, o.mode || "hide" ), + show = mode === "show", + hide = mode === "hide", size = o.size || 15, - percent = /([0-9]+)%/.exec(size), + percent = /([0-9]+)%/.exec( size ), horizFirst = !!o.horizFirst, - widthFirst = ((mode == "show") != horizFirst), - ref = widthFirst ? ["width", "height"] : ["height", "width"], + widthFirst = show != horizFirst, + ref = widthFirst ? [ "width", "height" ] : [ "height", "width" ], duration = o.duration / 2, - wrapper, distance; + wrapper, distance, + animation1 = {}, animation2 = {}; $.effects.save( el, props ); el.show(); @@ -38,29 +41,34 @@ $.effects.effect.fold = function( o, next ) { [ wrapper.height(), wrapper.width() ]; if ( percent ) { - size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ ( mode == "hide") ? 0 : 1 ]; + size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ]; } - mode == "show" && wrapper.css( horizFirst ? { + if ( show ) { + wrapper.css( horizFirst ? { height: 0, width: size } : { height: size, width: 0 }); + } // Animation - var animation1 = {}, animation2 = {}; - animation1[ ref[ 0 ] ] = mode == "show" ? distance[ 0 ] : size; - animation2[ ref[ 1 ] ] = mode == "show" ? distance[ 1 ] : 0; + animation1[ ref[ 0 ] ] = show ? distance[ 0 ] : size; + animation2[ ref[ 1 ] ] = show ? distance[ 1 ] : 0; // Animate wrapper .animate( animation1, duration, o.easing ) .animate( animation2, duration, o.easing, function() { - (mode == "hide") && el.hide(); + if ( hide ) { + el.hide(); + } $.effects.restore( el, props ); $.effects.removeWrapper( el ); - jQuery.isFunction(o.complete) && o.complete.apply( el[ 0 ], arguments ); + if ( $.isFunction( o.complete ) ) { + o.complete.apply( el[ 0 ], arguments ); + } next(); }); diff --git a/ui/jquery.effects.highlight.js b/ui/jquery.effects.highlight.js index 61826e696..709e93a3c 100644 --- a/ui/jquery.effects.highlight.js +++ b/ui/jquery.effects.highlight.js @@ -20,7 +20,7 @@ $.effects.effect.highlight = function( o, next ) { backgroundColor: elem.css( "backgroundColor" ) }; - if (mode == "hide") { + if (mode === "hide") { animation.opacity = 0; } @@ -37,10 +37,13 @@ $.effects.effect.highlight = function( o, next ) { duration: o.duration, easing: o.easing, complete: function() { - (mode == "hide" && elem.hide()); + if ( 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); + if ( $.isFunction( o.complete) ) { + o.complete.apply( this, arguments ); + } next(); } }); diff --git a/ui/jquery.effects.scale.js b/ui/jquery.effects.scale.js index 614943cfb..2642c6c1d 100644 --- a/ui/jquery.effects.scale.js +++ b/ui/jquery.effects.scale.js @@ -24,6 +24,7 @@ function compFunction( el, complete, next ) { $.effects.effect.puff = function( o, next ) { var elem = $( this ), mode = $.effects.setMode( elem, o.mode || "hide" ), + hide = mode === "hide", percent = parseInt( o.percent, 10 ) || 150, factor = percent / 100, original = { @@ -37,8 +38,8 @@ $.effects.effect.puff = function( o, next ) { fade: true, mode: mode, complete: compFunction( this, o.complete, next ), - percent: mode == "hide" ? percent : 100, - from: mode == "hide" + percent: hide ? percent : 100, + from: hide ? original : { height: original.height * factor, diff --git a/ui/jquery.effects.shake.js b/ui/jquery.effects.shake.js index 82d7ae97e..311edced0 100644 --- a/ui/jquery.effects.shake.js +++ b/ui/jquery.effects.shake.js @@ -23,7 +23,7 @@ $.effects.effect.shake = function( o, next ) { anims = times * 2 + 1, speed = o.duration, ref = (direction == "up" || direction == "down") ? "top" : "left", - motion = (direction == "up" || direction == "left") ? "pos" : "neg", + positiveMotion = (direction == "up" || direction == "left"), animation = {}, animation1 = {}, animation2 = {}, @@ -39,9 +39,9 @@ $.effects.effect.shake = function( o, next ) { $.effects.createWrapper( el ); // Animation - animation[ ref ] = ( motion == "pos" ? "-=" : "+=" ) + distance; - animation1[ ref ] = ( motion == "pos" ? "+=" : "-=" ) + distance * 2; - animation2[ ref ] = ( motion == "pos" ? "-=" : "+=" ) + distance * 2; + animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance; + animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2; + animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2; // Animate el.animate( animation, speed, o.easing ); @@ -59,7 +59,9 @@ $.effects.effect.shake = function( o, next ) { } $.effects.restore( el, props ); $.effects.removeWrapper( el ); - $.isFunction( o.complete ) && o.complete.apply( this, arguments ); + if ( $.isFunction( o.complete ) ) { + o.complete.apply( this, arguments ); + } next(); }); diff --git a/ui/jquery.effects.slide.js b/ui/jquery.effects.slide.js index 7ed744284..3be28d91b 100644 --- a/ui/jquery.effects.slide.js +++ b/ui/jquery.effects.slide.js @@ -18,9 +18,10 @@ $.effects.effect.slide = function( o, next ) { var el = $( this ), props = [ "position", "top", "bottom", "left", "right", "width", "height" ], mode = $.effects.setMode( el, o.mode || "show" ), + show = mode === "show", direction = o.direction || "left", ref = (direction == "up" || direction == "down") ? "top" : "left", - motion = (direction == "up" || direction == "left") ? "pos" : "neg", + positiveMotion = (direction == "up" || direction == "left"), distance, animation = {}, size; @@ -28,7 +29,7 @@ $.effects.effect.slide = function( o, next ) { // Adjust $.effects.save( el, props ); el.show(); - distance = o.distance || el[ ref == "top" ? "outerHeight" : "outerWidth" ]({ + distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]({ margin: true }); @@ -36,14 +37,14 @@ $.effects.effect.slide = function( o, next ) { overflow: "hidden" }); - if (mode == "show") { - el.css( ref, motion == "pos" ? (isNaN(distance) ? "-" + distance : -distance) : distance ); + if ( show ) { + el.css( ref, positiveMotion ? (isNaN(distance) ? "-" + distance : -distance) : distance ); } // Animation - animation[ ref ] = ( mode == "show" ? - (motion == "pos" ? "+=" : "-=") : - (motion == "pos" ? "-=" : "+=")) + animation[ ref ] = ( show ? + ( positiveMotion ? "+=" : "-=") : + ( positiveMotion ? "-=" : "+=")) + distance; // Animate @@ -52,12 +53,14 @@ $.effects.effect.slide = function( o, next ) { duration: o.duration, easing: o.easing, complete: function() { - if ( mode == "hide" ) { + if ( mode === "hide" ) { el.hide(); } $.effects.restore( el, props ); $.effects.removeWrapper( el ); - $.isFunction(o.complete) && o.complete.apply( this, arguments ); + if ( $.isFunction( o.complete ) ) { + o.complete.apply( this, arguments ); + } next(); } }); diff --git a/ui/jquery.effects.transfer.js b/ui/jquery.effects.transfer.js index 061882fec..0c840c35c 100644 --- a/ui/jquery.effects.transfer.js +++ b/ui/jquery.effects.transfer.js @@ -39,7 +39,9 @@ $.effects.effect.transfer = function( o, next ) { }) .animate( animation, o.duration, o.easing, function() { transfer.remove(); - $.isFunction( o.complete ) && o.complete.apply(elem[0], arguments); + if ( $.isFunction( o.complete ) ) { + o.complete.apply( elem[0], arguments ); + } next(); }); }; -- cgit v1.2.3 From ab627e03a6a37cbf3291e9600f5482bd50991360 Mon Sep 17 00:00:00 2001 From: gnarf Date: Tue, 21 Jun 2011 01:11:46 -0500 Subject: Effects.*: DRY the complete callback execution into the 'done' callback passed into an effect --- ui/jquery.effects.blind.js | 7 ++----- ui/jquery.effects.bounce.js | 11 ++++------- ui/jquery.effects.clip.js | 7 ++----- ui/jquery.effects.core.js | 14 +++++++++++++- ui/jquery.effects.drop.js | 5 ++--- ui/jquery.effects.explode.js | 7 ++----- ui/jquery.effects.fade.js | 7 ++----- ui/jquery.effects.fold.js | 7 ++----- ui/jquery.effects.highlight.js | 7 ++----- ui/jquery.effects.pulsate.js | 11 ++++------- ui/jquery.effects.scale.js | 24 ++++++------------------ ui/jquery.effects.shake.js | 11 ++++------- ui/jquery.effects.slide.js | 7 ++----- ui/jquery.effects.transfer.js | 7 ++----- 14 files changed, 49 insertions(+), 83 deletions(-) (limited to 'ui/jquery.effects.highlight.js') diff --git a/ui/jquery.effects.blind.js b/ui/jquery.effects.blind.js index 09d6a9e57..5f86bed7b 100644 --- a/ui/jquery.effects.blind.js +++ b/ui/jquery.effects.blind.js @@ -15,7 +15,7 @@ var rvertical = /up|down|vertical/, rpositivemotion = /up|left|vertical|horizontal/; -$.effects.effect.blind = function( o, next ) { +$.effects.effect.blind = function( o, done ) { // Create element var el = $( this ), props = [ "position", "top", "bottom", "left", "right", "height", "width" ], @@ -70,10 +70,7 @@ $.effects.effect.blind = function( o, next ) { } $.effects.restore( el, props ); $.effects.removeWrapper( el ); - if ( $.isFunction( o.complete ) ) { - o.complete.apply( el[ 0 ], arguments ); - } - next(); + done(); } }); diff --git a/ui/jquery.effects.bounce.js b/ui/jquery.effects.bounce.js index 38171c32e..41ee34f64 100644 --- a/ui/jquery.effects.bounce.js +++ b/ui/jquery.effects.bounce.js @@ -12,7 +12,7 @@ */ (function( $, undefined ) { -$.effects.effect.bounce = function( o, next ) { +$.effects.effect.bounce = function( o, done ) { var el = $( this ), props = [ "position", "top", "bottom", "left", "right", "height", "width" ], @@ -91,16 +91,13 @@ $.effects.effect.bounce = function( o, next ) { el.animate( upAnim, speed, easing ); } - el.queue( function( next ) { + el.queue(function() { if ( hide ) { el.hide(); } $.effects.restore( el, props ); $.effects.removeWrapper( el ); - if ( o.complete ) { - o.complete.apply( el[ 0 ] ); - } - next(); + done(); }); // inject all the animations we just queued to be first in line (after "inprogress") @@ -108,7 +105,7 @@ $.effects.effect.bounce = function( o, next ) { queue.splice.apply( queue, [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) ); } - next(); + el.dequeue(); }; diff --git a/ui/jquery.effects.clip.js b/ui/jquery.effects.clip.js index 8c5c76e8c..c6eecc671 100644 --- a/ui/jquery.effects.clip.js +++ b/ui/jquery.effects.clip.js @@ -12,7 +12,7 @@ */ (function( $, undefined ) { -$.effects.effect.clip = function( o, next ) { +$.effects.effect.clip = function( o, done ) { // Create element var el = $( this ), props = [ "position", "top", "bottom", "left", "right", "height", "width" ], @@ -57,10 +57,7 @@ $.effects.effect.clip = function( o, next ) { } $.effects.restore( el, props ); $.effects.removeWrapper( el ); - if ( $.isFunction( o.complete ) ) { - o.complete.apply( el[ 0 ], arguments ); - } - el.dequeue(); + done(); } }); diff --git a/ui/jquery.effects.core.js b/ui/jquery.effects.core.js index 87fc5a074..330ddd83c 100644 --- a/ui/jquery.effects.core.js +++ b/ui/jquery.effects.core.js @@ -556,7 +556,19 @@ $.fn.extend({ } function run( next ) { - effectMethod.call( this, args, $.isFunction( next ) ? next : $.noop ); + var elem = this, + complete = args.complete; + + function done() { + if ( $.isFunction( complete ) ) { + complete.call( elem ); + } + if ( $.isFunction( next ) ) { + next(); + } + } + + effectMethod.call( elem, args, done ); } // TODO: remove this check in 2.0, effectMethod will always be true diff --git a/ui/jquery.effects.drop.js b/ui/jquery.effects.drop.js index 2fba49d92..2e7a6ec0f 100644 --- a/ui/jquery.effects.drop.js +++ b/ui/jquery.effects.drop.js @@ -12,7 +12,7 @@ */ (function( $, undefined ) { -$.effects.effect.drop = function( o, next ) { +$.effects.effect.drop = function( o, done ) { var el = $( this ), props = [ "position", "top", "bottom", "left", "right", "opacity", "height", "width" ], @@ -54,8 +54,7 @@ $.effects.effect.drop = function( o, next ) { mode == "hide" && el.hide(); $.effects.restore( el, props ); $.effects.removeWrapper( el ); - $.isFunction( o.complete ) && o.complete.apply( this, arguments ); - next(); + done(); } }); diff --git a/ui/jquery.effects.explode.js b/ui/jquery.effects.explode.js index 0deb2be9f..22f506045 100644 --- a/ui/jquery.effects.explode.js +++ b/ui/jquery.effects.explode.js @@ -12,7 +12,7 @@ */ (function( $, undefined ) { -$.effects.effect.explode = function( o, next ) { +$.effects.effect.explode = function( o, done ) { var rows = o.pieces ? Math.round( Math.sqrt( o.pieces ) ) : 3, cells = rows, @@ -89,10 +89,7 @@ $.effects.effect.explode = function( o, next ) { if ( !show ) { el.hide(); } - if ( $.isFunction( o.complete ) ) { - o.complete.apply( el[ 0 ] ); - } - next(); + done(); } }; diff --git a/ui/jquery.effects.fade.js b/ui/jquery.effects.fade.js index 8f2d956dc..9b79ad3bc 100644 --- a/ui/jquery.effects.fade.js +++ b/ui/jquery.effects.fade.js @@ -12,7 +12,7 @@ */ (function( $, undefined ) { -$.effects.effect.fade = function( o, next ) { +$.effects.effect.fade = function( o, done ) { var el = $( this ), mode = $.effects.setMode( el, o.mode || "toggle" ), hide = mode === "hide"; @@ -28,10 +28,7 @@ $.effects.effect.fade = function( o, next ) { if ( hide ) { el.hide(); } - if ( o.complete ) { - o.complete.call( this ); - } - next(); + done(); } }); }; diff --git a/ui/jquery.effects.fold.js b/ui/jquery.effects.fold.js index b2a02ba78..7c4f583c1 100644 --- a/ui/jquery.effects.fold.js +++ b/ui/jquery.effects.fold.js @@ -12,7 +12,7 @@ */ (function( $, undefined ) { -$.effects.effect.fold = function( o, next ) { +$.effects.effect.fold = function( o, done ) { // Create element var el = $( this ), @@ -66,10 +66,7 @@ $.effects.effect.fold = function( o, next ) { } $.effects.restore( el, props ); $.effects.removeWrapper( el ); - if ( $.isFunction( o.complete ) ) { - o.complete.apply( el[ 0 ], arguments ); - } - next(); + done(); }); }; diff --git a/ui/jquery.effects.highlight.js b/ui/jquery.effects.highlight.js index 709e93a3c..edde845a3 100644 --- a/ui/jquery.effects.highlight.js +++ b/ui/jquery.effects.highlight.js @@ -12,7 +12,7 @@ */ (function( $, undefined ) { -$.effects.effect.highlight = function( o, next ) { +$.effects.effect.highlight = function( o, done ) { var elem = $( this ), props = [ "backgroundImage", "backgroundColor", "opacity" ], mode = $.effects.setMode( elem, o.mode || "show" ), @@ -41,10 +41,7 @@ $.effects.effect.highlight = function( o, next ) { elem.hide(); } $.effects.restore( elem, props ); - if ( $.isFunction( o.complete) ) { - o.complete.apply( this, arguments ); - } - next(); + done(); } }); }; diff --git a/ui/jquery.effects.pulsate.js b/ui/jquery.effects.pulsate.js index bc257f624..7d6e9328f 100644 --- a/ui/jquery.effects.pulsate.js +++ b/ui/jquery.effects.pulsate.js @@ -12,7 +12,7 @@ */ (function( $, undefined ) { -$.effects.effect.pulsate = function( o, next ) { +$.effects.effect.pulsate = function( o, done ) { var elem = $( this ), mode = $.effects.setMode( elem, o.mode || "show" ), show = mode === "show", @@ -44,14 +44,11 @@ $.effects.effect.pulsate = function( o, next ) { opacity: animateTo }, duration, o.easing); - elem.queue( function( next ) { + elem.queue(function() { if ( hide ) { elem.hide(); } - if ( o.complete ) { - o.complete.apply( this ); - } - next(); + done(); }); // We just queued up "anims" animations, we need to put them next in the queue @@ -59,7 +56,7 @@ $.effects.effect.pulsate = function( o, next ) { queue.splice.apply( queue, [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) ); } - next(); + elem.dequeue(); }; })(jQuery); diff --git a/ui/jquery.effects.scale.js b/ui/jquery.effects.scale.js index 2642c6c1d..000fdee28 100644 --- a/ui/jquery.effects.scale.js +++ b/ui/jquery.effects.scale.js @@ -12,16 +12,7 @@ */ (function( $, undefined ) { -function compFunction( el, complete, next ) { - return function() { - if ( $.isFunction( complete ) ) { - complete.apply( el ); - } - next(); - }; -}; - -$.effects.effect.puff = function( o, next ) { +$.effects.effect.puff = function( o, done ) { var elem = $( this ), mode = $.effects.setMode( elem, o.mode || "hide" ), hide = mode === "hide", @@ -37,7 +28,7 @@ $.effects.effect.puff = function( o, next ) { queue: false, fade: true, mode: mode, - complete: compFunction( this, o.complete, next ), + complete: done, percent: hide ? percent : 100, from: hide ? original @@ -50,7 +41,7 @@ $.effects.effect.puff = function( o, next ) { elem.effect( o ); }; -$.effects.effect.scale = function( o, next ) { +$.effects.effect.scale = function( o, done ) { // Create element var el = $( this ), @@ -73,7 +64,7 @@ $.effects.effect.scale = function( o, next ) { // We are going to pass this effect to the size effect: options.effect = "size"; options.queue = false; - options.complete = compFunction( this, options.complete, next ); + options.complete = done; // Set default origin and restore for show/hide if ( mode != "effect" ) { @@ -105,7 +96,7 @@ $.effects.effect.scale = function( o, next ) { }; -$.effects.effect.size = function( o, next ) { +$.effects.effect.size = function( o, done ) { // Create element var el = $( this ), @@ -302,10 +293,7 @@ $.effects.effect.size = function( o, next ) { } $.effects.removeWrapper( el ); - if ( $.isFunction( o.complete ) ) { - o.complete.apply( this, arguments ); - } - next(); + done(); } }); diff --git a/ui/jquery.effects.shake.js b/ui/jquery.effects.shake.js index 311edced0..7d83a9bb8 100644 --- a/ui/jquery.effects.shake.js +++ b/ui/jquery.effects.shake.js @@ -12,7 +12,7 @@ */ (function( $, undefined ) { -$.effects.effect.shake = function( o, next ) { +$.effects.effect.shake = function( o, done ) { var el = $( this ), props = [ "position", "top", "bottom", "left", "right", "height", "width" ], @@ -53,16 +53,13 @@ $.effects.effect.shake = function( o, next ) { el .animate( animation1, speed, o.easing ) .animate( animation, speed / 2, o.easing ) - .queue( function( next ) { + .queue(function() { if ( mode === "hide" ) { el.hide(); } $.effects.restore( el, props ); $.effects.removeWrapper( el ); - if ( $.isFunction( o.complete ) ) { - o.complete.apply( this, arguments ); - } - next(); + done(); }); // inject all the animations we just queued to be first in line (after "inprogress") @@ -70,7 +67,7 @@ $.effects.effect.shake = function( o, next ) { queue.splice.apply( queue, [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) ); } - next(); + el.dequeue(); }; diff --git a/ui/jquery.effects.slide.js b/ui/jquery.effects.slide.js index 3be28d91b..de393c779 100644 --- a/ui/jquery.effects.slide.js +++ b/ui/jquery.effects.slide.js @@ -12,7 +12,7 @@ */ (function( $, undefined ) { -$.effects.effect.slide = function( o, next ) { +$.effects.effect.slide = function( o, done ) { // Create element var el = $( this ), @@ -58,10 +58,7 @@ $.effects.effect.slide = function( o, next ) { } $.effects.restore( el, props ); $.effects.removeWrapper( el ); - if ( $.isFunction( o.complete ) ) { - o.complete.apply( this, arguments ); - } - next(); + done(); } }); diff --git a/ui/jquery.effects.transfer.js b/ui/jquery.effects.transfer.js index 0c840c35c..1fa291228 100644 --- a/ui/jquery.effects.transfer.js +++ b/ui/jquery.effects.transfer.js @@ -12,7 +12,7 @@ */ (function( $, undefined ) { -$.effects.effect.transfer = function( o, next ) { +$.effects.effect.transfer = function( o, done ) { var elem = $( this ), target = $( o.to ), targetFixed = target.css( "position" ) === "fixed", @@ -39,10 +39,7 @@ $.effects.effect.transfer = function( o, next ) { }) .animate( animation, o.duration, o.easing, function() { transfer.remove(); - if ( $.isFunction( o.complete ) ) { - o.complete.apply( elem[0], arguments ); - } - next(); + done(); }); }; -- cgit v1.2.3