From 46e0574cc3c5bb2d596ed4f1201395387683b23e Mon Sep 17 00:00:00 2001 From: gnarf Date: Fri, 11 Mar 2011 09:14:11 -0600 Subject: [PATCH 1/2] effects: Improving API Part 2 - BC Shim and $.effects.effect[] - Fixes #7103 --- ui/jquery.effects.blind.js | 2 +- ui/jquery.effects.bounce.js | 2 +- ui/jquery.effects.clip.js | 2 +- ui/jquery.effects.core.js | 32 ++++++++++++++++++++++++++------ ui/jquery.effects.drop.js | 2 +- ui/jquery.effects.explode.js | 2 +- ui/jquery.effects.fade.js | 2 +- ui/jquery.effects.fold.js | 2 +- ui/jquery.effects.highlight.js | 2 +- ui/jquery.effects.pulsate.js | 2 +- ui/jquery.effects.scale.js | 6 +++--- ui/jquery.effects.shake.js | 2 +- ui/jquery.effects.slide.js | 2 +- ui/jquery.effects.transfer.js | 2 +- 14 files changed, 41 insertions(+), 21 deletions(-) diff --git a/ui/jquery.effects.blind.js b/ui/jquery.effects.blind.js index 0c865d59f08..6b725078947 100644 --- a/ui/jquery.effects.blind.js +++ b/ui/jquery.effects.blind.js @@ -12,7 +12,7 @@ */ (function( $, undefined ) { -$.effects.blind = function( o ) { +$.effects.effect.blind = function( o ) { return this.queue( function() { diff --git a/ui/jquery.effects.bounce.js b/ui/jquery.effects.bounce.js index d5b43492e97..8da0feb7630 100644 --- a/ui/jquery.effects.bounce.js +++ b/ui/jquery.effects.bounce.js @@ -14,7 +14,7 @@ var rshowhide = /show|hide/; -$.effects.bounce = function(o) { +$.effects.effect.bounce = function(o) { return this.queue(function() { diff --git a/ui/jquery.effects.clip.js b/ui/jquery.effects.clip.js index 8cf91da57af..14b358dfae7 100644 --- a/ui/jquery.effects.clip.js +++ b/ui/jquery.effects.clip.js @@ -12,7 +12,7 @@ */ (function( $, undefined ) { -$.effects.clip = function( o ) { +$.effects.effect.clip = function( o ) { return this.queue( function() { diff --git a/ui/jquery.effects.core.js b/ui/jquery.effects.core.js index 0d326954ad1..201b3db9978 100644 --- a/ui/jquery.effects.core.js +++ b/ui/jquery.effects.core.js @@ -9,8 +9,12 @@ */ ;jQuery.effects || (function($, undefined) { -$.effects = {}; +var BC = $.uiBackCompat !== false; +$.effects = { + // contains effects 1.9+ API effect functions + effect: {} +}; /******************************************************************************/ /****************************** COLOR ANIMATIONS ******************************/ /******************************************************************************/ @@ -493,7 +497,7 @@ function standardSpeed( speed ) { } // invalid strings - treat as "normal" speed - if ( typeof speed === "string" && !$.effects[ speed ] ) { + if ( typeof speed === "string" && ! ( $.effects.effect[ speed ] || BC && $.effects[ speed ] ) ) { return true; } @@ -504,9 +508,12 @@ $.fn.extend({ effect: function( effect, options, speed, callback ) { var args = _normalizeArguments.apply( this, arguments ), mode = args.mode, - effectMethod = $.effects[ args.effect ]; - - if ( $.fx.off || !effectMethod ) { + effectMethod = $.effects.effect[ args.effect ], + + // DEPRECATED: Pre 1.9 API - effect functions existed in $.effects + oldEffectMethod = !effectMethod && BC && $.effects[ args.effect ]; + + if ( $.fx.off || ! ( effectMethod || oldEffectMethod ) ) { // delegate to the original method (e.g., .show()) if possible if ( mode ) { return this[ mode ]( args.duration, args.complete ); @@ -518,7 +525,20 @@ $.fn.extend({ }); } } - return effectMethod.call( this, args ); + + // DEPRECATED: effectMethod will always be true once BC is removed + if ( effectMethod ) { + return effectMethod.call( this, args ); + } else { + + // DEPRECATED: convert back to old format + return oldEffectMethod.call(this, { + options: args, + duration: args.duration, + callback: args.complete, + mode: args.mode + }); + } }, _show: $.fn.show, diff --git a/ui/jquery.effects.drop.js b/ui/jquery.effects.drop.js index b88a8c4287a..24fb89db0b9 100644 --- a/ui/jquery.effects.drop.js +++ b/ui/jquery.effects.drop.js @@ -12,7 +12,7 @@ */ (function( $, undefined ) { -$.effects.drop = function( o ) { +$.effects.effect.drop = function( o ) { return this.queue( function() { diff --git a/ui/jquery.effects.explode.js b/ui/jquery.effects.explode.js index 79cf1a9fbbf..b7708f021e2 100644 --- a/ui/jquery.effects.explode.js +++ b/ui/jquery.effects.explode.js @@ -12,7 +12,7 @@ */ (function( $, undefined ) { -$.effects.explode = function( o ) { +$.effects.effect.explode = function( o ) { return this.queue( function( next ) { diff --git a/ui/jquery.effects.fade.js b/ui/jquery.effects.fade.js index 825c84e780e..5fa0319c0d4 100644 --- a/ui/jquery.effects.fade.js +++ b/ui/jquery.effects.fade.js @@ -12,7 +12,7 @@ */ (function( $, undefined ) { -$.effects.fade = function( o ) { +$.effects.effect.fade = function( o ) { return this.queue( function() { var el = $( this ), mode = $.effects.setMode( el, o.mode || 'hide' ); diff --git a/ui/jquery.effects.fold.js b/ui/jquery.effects.fold.js index 19e97c40f20..29da090cb89 100644 --- a/ui/jquery.effects.fold.js +++ b/ui/jquery.effects.fold.js @@ -12,7 +12,7 @@ */ (function( $, undefined ) { -$.effects.fold = function( o ) { +$.effects.effect.fold = function( o ) { return this.queue( function() { diff --git a/ui/jquery.effects.highlight.js b/ui/jquery.effects.highlight.js index b2ffb15e8ea..cd4f0705a8d 100644 --- a/ui/jquery.effects.highlight.js +++ b/ui/jquery.effects.highlight.js @@ -12,7 +12,7 @@ */ (function( $, undefined ) { -$.effects.highlight = function( o ) { +$.effects.effect.highlight = function( o ) { return this.queue( function() { var elem = $( this ), props = [ 'backgroundImage', 'backgroundColor', 'opacity' ], diff --git a/ui/jquery.effects.pulsate.js b/ui/jquery.effects.pulsate.js index c5f67b12bff..b168b6ef518 100644 --- a/ui/jquery.effects.pulsate.js +++ b/ui/jquery.effects.pulsate.js @@ -12,7 +12,7 @@ */ (function( $, undefined ) { -$.effects.pulsate = function( o ) { +$.effects.effect.pulsate = function( o ) { return this.queue( function() { var elem = $( this ), mode = $.effects.setMode( elem, o.mode || 'show' ), diff --git a/ui/jquery.effects.scale.js b/ui/jquery.effects.scale.js index fcc0708b905..8f25ca9a8a7 100644 --- a/ui/jquery.effects.scale.js +++ b/ui/jquery.effects.scale.js @@ -12,7 +12,7 @@ */ (function( $, undefined ) { -$.effects.puff = function( o ) { +$.effects.effect.puff = function( o ) { return this.queue( function() { var elem = $( this ), mode = $.effects.setMode( elem, o.mode || 'hide' ), @@ -40,7 +40,7 @@ $.effects.puff = function( o ) { }); }; -$.effects.scale = function( o ) { +$.effects.effect.scale = function( o ) { return this.queue( function() { @@ -92,7 +92,7 @@ $.effects.scale = function( o ) { }; -$.effects.size = function( o ) { +$.effects.effect.size = function( o ) { return this.queue( function() { // Create element diff --git a/ui/jquery.effects.shake.js b/ui/jquery.effects.shake.js index 5e8875abeba..a1ba1577c31 100644 --- a/ui/jquery.effects.shake.js +++ b/ui/jquery.effects.shake.js @@ -12,7 +12,7 @@ */ (function( $, undefined ) { -$.effects.shake = function( o ) { +$.effects.effect.shake = function( o ) { return this.queue( function() { diff --git a/ui/jquery.effects.slide.js b/ui/jquery.effects.slide.js index eeba117cf85..6b029675414 100644 --- a/ui/jquery.effects.slide.js +++ b/ui/jquery.effects.slide.js @@ -12,7 +12,7 @@ */ (function( $, undefined ) { -$.effects.slide = function( o ) { +$.effects.effect.slide = function( o ) { return this.queue( function() { diff --git a/ui/jquery.effects.transfer.js b/ui/jquery.effects.transfer.js index 79b1577d95e..17d23c5fab2 100644 --- a/ui/jquery.effects.transfer.js +++ b/ui/jquery.effects.transfer.js @@ -12,7 +12,7 @@ */ (function( $, undefined ) { -$.effects.transfer = function( o ) { +$.effects.effect.transfer = function( o ) { return this.queue( function() { var elem = $( this ), From 79414226185f2dffd54559723f13514df58ec496 Mon Sep 17 00:00:00 2001 From: gnarf Date: Fri, 11 Mar 2011 09:26:08 -0600 Subject: [PATCH 2/2] ui.datepicker: Updated to check for new or old style effects --- ui/jquery.ui.datepicker.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js index 8dd9bf3dc75..670955f648e 100644 --- a/ui/jquery.ui.datepicker.js +++ b/ui/jquery.ui.datepicker.js @@ -656,7 +656,9 @@ $.extend(Datepicker.prototype, { } }; inst.dpDiv.zIndex($(input).zIndex()+1); - if ($.effects && $.effects[showAnim]) + + // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed + if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) inst.dpDiv.show(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess); else inst.dpDiv[showAnim || 'show']((showAnim ? duration : null), postProcess); @@ -781,7 +783,9 @@ $.extend(Datepicker.prototype, { $.datepicker._tidyDialog(inst); this._curInst = null; }; - if ($.effects && $.effects[showAnim]) + + // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed + if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) inst.dpDiv.hide(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess); else inst.dpDiv[(showAnim == 'slideDown' ? 'slideUp' :