From 6963889f73beda7aca6018de58728d28d0656db0 Mon Sep 17 00:00:00 2001 From: gnarf Date: Tue, 8 Mar 2011 01:02:32 -0600 Subject: [PATCH 1/5] effects: $.effects.$ and $.effects.effect[] --- ui/jquery.effects.blind.js | 22 +- ui/jquery.effects.bounce.js | 20 +- ui/jquery.effects.clip.js | 25 +- ui/jquery.effects.core.js | 608 +++++++++++++++++++-------------- ui/jquery.effects.drop.js | 17 +- ui/jquery.effects.explode.js | 8 +- ui/jquery.effects.fade.js | 6 +- ui/jquery.effects.fold.js | 27 +- ui/jquery.effects.highlight.js | 19 +- ui/jquery.effects.pulsate.js | 16 +- ui/jquery.effects.scale.js | 58 ++-- ui/jquery.effects.shake.js | 14 +- ui/jquery.effects.slide.js | 11 +- ui/jquery.effects.transfer.js | 2 +- 14 files changed, 457 insertions(+), 396 deletions(-) diff --git a/ui/jquery.effects.blind.js b/ui/jquery.effects.blind.js index 0c865d59f08..78a394140d9 100644 --- a/ui/jquery.effects.blind.js +++ b/ui/jquery.effects.blind.js @@ -12,35 +12,31 @@ */ (function( $, undefined ) { -$.effects.blind = function( o ) { +$.effects.effect.blind = function( o ) { return this.queue( function() { // Create element - var el = $( this ), + var el = $.effects.$( this ), props = [ 'position', 'top', 'bottom', 'left', 'right' ], mode = $.effects.setMode( el, o.mode || 'hide' ), direction = o.direction || 'vertical', ref = ( direction == 'vertical' ) ? 'height' : 'width', animation = {}, - wrapper, distance; - - $.effects.save( el, props ); - el.show(); - wrapper = $.effects.createWrapper( el ).css({ - overflow: 'hidden' - }); + wrapper = el.save( props ).show().createWrapper({ + overflow: 'hidden' + }), + distance; animation[ ref ] = ( mode == 'show' ? wrapper[ ref ]() : 0 ); - // start at 0 if we are showing + // reset to 0 if we are showing ( mode == 'show' && wrapper.css( ref, 0 ) ); // Animate wrapper.animate( animation, o.duration, o.easing, function() { - ( mode == 'hide' && el.hide() ); - $.effects.restore( el, props ); - $.effects.removeWrapper( el ); + ( mode == 'hide' && el.hide() ); + el.restore( props ).removeWrapper(); $.isFunction( o.complete ) && o.complete.apply( el[ 0 ], arguments ); el.dequeue(); }); diff --git a/ui/jquery.effects.bounce.js b/ui/jquery.effects.bounce.js index d5b43492e97..de1f8eef6cd 100644 --- a/ui/jquery.effects.bounce.js +++ b/ui/jquery.effects.bounce.js @@ -14,15 +14,15 @@ var rshowhide = /show|hide/; -$.effects.bounce = function(o) { +$.effects.effect.bounce = function(o) { return this.queue(function() { // Create element - var el = $( this ), + var el = $.effects.$( this ), props = [ 'position', 'top', 'bottom', 'left', 'right' ], // defaults: - mode = $.effects.setMode( el, o.mode || 'effect' ), + mode = el.setMode( o.mode || 'effect' ), direction = o.direction || 'up', distance = o.distance || 20, times = o.times || 5, @@ -37,9 +37,7 @@ $.effects.bounce = function(o) { props.push( 'opacity' ); } - $.effects.save( el, props ); - el.show(); - $.effects.createWrapper( el ); // Create Wrapper + el.save( props ).show().createWrapper(); if ( !distance ) { distance = el[ ref == 'top' ? 'outerHeight' : 'outerWidth' ]({ margin:true }) / 3; @@ -76,9 +74,9 @@ $.effects.bounce = function(o) { }; animation[ ref ] = ( motion ? '-=' : '+=' ) + distance; el.animate( animation, speed / 2, o.easing, function(){ - el.hide(); - $.effects.restore( el, props ); - $.effects.removeWrapper( el ); + el.hide() + .restore( props ) + .removeWrapper(); $.isFunction( o.complete ) && o.complete.apply( this, arguments ); }); } else { @@ -89,11 +87,11 @@ $.effects.bounce = function(o) { el .animate( animation1, speed / 2, o.easing ) .animate( animation2, speed / 2, o.easing, function() { - $.effects.restore( el, props ); - $.effects.removeWrapper( el ); + el.restore( props ).removeWrapper(); $.isFunction( o.complete ) && o.complete.apply( this, arguments ); }); } + el.dequeue(); }); diff --git a/ui/jquery.effects.clip.js b/ui/jquery.effects.clip.js index 8cf91da57af..cd6f1df3c69 100644 --- a/ui/jquery.effects.clip.js +++ b/ui/jquery.effects.clip.js @@ -12,31 +12,25 @@ */ (function( $, undefined ) { -$.effects.clip = function( o ) { +$.effects.effect.clip = function( o ) { return this.queue( function() { // Create element - var el = $( this ), + var el = $.effects.$( this ), props = ['position','top','bottom','left','right','height','width'], - mode = $.effects.setMode( el, o.mode || 'hide' ), + mode = el.setMode( o.mode || 'hide' ), direction = o.direction || 'vertical', ref = { size: (direction == 'vertical') ? 'height' : 'width', position: (direction == 'vertical') ? '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[ ref.size ](); + wrapper = el.save( props ).show().createWrapper({ + overflow: 'hidden' + }), + animate = ( el[0].tagName == 'IMG' ) ? wrapper : el, + distance = animate[ ref.size ](); // Shift if ( mode == 'show' ) { @@ -55,8 +49,7 @@ $.effects.clip = function( o ) { easing: o.easing, complete: function() { mode == 'hide' && el.hide(); - $.effects.restore( el, props ); - $.effects.removeWrapper( el ); + el.restore( props ).removeWrapper(); $.isFunction( o.complete ) && o.complete.apply( el[ 0 ], arguments ); el.dequeue(); } diff --git a/ui/jquery.effects.core.js b/ui/jquery.effects.core.js index cbfd4fbe196..a1bcc385f76 100644 --- a/ui/jquery.effects.core.js +++ b/ui/jquery.effects.core.js @@ -9,9 +9,14 @@ */ ;jQuery.effects || (function($, undefined) { -$.effects = {}; +var BC = $.uiBackCompat !== false; +$.effects = { + $: $.sub(), + // contains effects 1.9+ API effect functions + effect: {} +}; /******************************************************************************/ /****************************** COLOR ANIMATIONS ******************************/ @@ -144,7 +149,7 @@ var colors = { /****************************** CLASS ANIMATIONS ******************************/ /******************************************************************************/ -var classAnimationActions = ['add', 'remove', 'toggle'], +var classAnimationActions = [ 'add', 'remove', 'toggle' ], shorthandStyles = { border: 1, borderBottom: 1, @@ -163,24 +168,25 @@ function getElementStyles() { : this.currentStyle, newStyle = {}, key, - camelCase; + camelCase, + len; // webkit enumerates style porperties - if (style && style.length && style[0] && style[style[0]]) { - var len = style.length; - while (len--) { - key = style[len]; - if (typeof style[key] == 'string') { - camelCase = key.replace(/\-(\w)/g, function(all, letter){ + if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) { + len = style.length; + while ( len-- ) { + key = style[ len ]; + if ( typeof style[ key ] == 'string' ) { + camelCase = key.replace( /\-(\w)/g, function( all, letter ) { return letter.toUpperCase(); }); - newStyle[camelCase] = style[key]; + newStyle[ camelCase ] = style[ key ]; } } } else { - for (key in style) { - if (typeof style[key] === 'string') { - newStyle[key] = style[key]; + for ( key in style ) { + if ( typeof style[ key ] === 'string' ) { + newStyle[ key ] = style[ key ]; } } } @@ -188,115 +194,126 @@ function getElementStyles() { return newStyle; } -function filterStyles(styles) { +function filterStyles( styles ) { var name, value; - for (name in styles) { - value = styles[name]; + for ( name in styles ) { + value = styles[ name ]; if ( // ignore null and undefined values value == null || // ignore functions (when does this occur?) - $.isFunction(value) || + $.isFunction( value ) || // shorthand styles that need to be expanded name in shorthandStyles || // ignore scrollbars (break in IE) - (/scrollbar/).test(name) || + ( /scrollbar/ ).test( name ) || // only colors or values that can be converted to numbers - (!(/color/i).test(name) && isNaN(parseFloat(value))) + ( !( /color/i ).test( name ) && isNaN( parseFloat( value ) ) ) ) { - delete styles[name]; + delete styles[ name ]; } } return styles; } -function styleDifference(oldStyle, newStyle) { +function styleDifference( oldStyle, newStyle ) { var diff = { _: 0 }, // http://dev.jquery.com/ticket/5459 name; - for (name in newStyle) { - if (oldStyle[name] != newStyle[name]) { - diff[name] = newStyle[name]; + for ( name in newStyle ) { + if ( oldStyle[ name ] != newStyle[ name ] ) { + diff[ name ] = newStyle[ name ]; } } return diff; } -$.effects.animateClass = function(value, duration, easing, callback) { - if ($.isFunction(easing)) { +$.effects.animateClass = function( value, duration, easing, callback ) { + if ( $.isFunction( easing ) ) { callback = easing; easing = null; } - return this.queue('fx', function() { - var that = $(this), - originalStyleAttr = that.attr('style') || ' ', - originalStyle = filterStyles(getElementStyles.call(this)), + return this.queue( 'fx', function() { + var that = $( this ), + originalStyleAttr = that.attr( 'style' ) || ' ', + originalStyle = filterStyles( getElementStyles.call( this ) ), newStyle, - className = that.attr('className'); + className = that.attr( 'className' ); - $.each(classAnimationActions, function(i, action) { - if (value[action]) { - that[action + 'Class'](value[action]); + $.each( classAnimationActions, function(i, action) { + if ( value[ action ] ) { + that[ action + 'Class' ]( value[ action ] ); } }); - newStyle = filterStyles(getElementStyles.call(this)); - that.attr('className', className); + newStyle = filterStyles( getElementStyles.call( this ) ); + that.attr( 'className', className ); - that.animate(styleDifference(originalStyle, newStyle), duration, easing, function() { - $.each(classAnimationActions, function(i, action) { - if (value[action]) { that[action + 'Class'](value[action]); } + that.animate( styleDifference( originalStyle, newStyle ), duration, easing, function() { + $.each( classAnimationActions, function( i, action ) { + if ( value[ action ] ) { + that[ action + 'Class' ]( value[ action ] ); + } }); // work around bug in IE by clearing the cssText before setting it - if (typeof that.attr('style') == 'object') { - that.attr('style').cssText = ''; - that.attr('style').cssText = originalStyleAttr; + if ( typeof that.attr( 'style' ) == 'object' ) { + that.attr( 'style' ).cssText = ''; + that.attr( 'style' ).cssText = originalStyleAttr; } else { - that.attr('style', originalStyleAttr); + that.attr( 'style', originalStyleAttr ); + } + if ( callback ) { + callback.apply( this, arguments ); } - if (callback) { callback.apply(this, arguments); } }); // $.animate adds a function to the end of the queue // but we want it at the front - var queue = $.queue(this), - anim = queue.splice(queue.length - 1, 1)[0]; - queue.splice(1, 0, anim); - $.dequeue(this); + var queue = $.queue( this ), + anim = queue.splice( queue.length - 1, 1 )[ 0 ]; + queue.splice( 1, 0, anim ); + $.dequeue( this ); }); }; $.fn.extend({ _addClass: $.fn.addClass, - addClass: function(classNames, speed, easing, callback) { - return speed ? $.effects.animateClass.apply(this, [{ add: classNames },speed,easing,callback]) : this._addClass(classNames); + addClass: function( classNames, speed, easing, callback ) { + return speed ? + $.effects.animateClass.apply( this, [{ add: classNames }, speed, easing, callback ]) : + this._addClass(classNames); }, _removeClass: $.fn.removeClass, - removeClass: function(classNames,speed,easing,callback) { - return speed ? $.effects.animateClass.apply(this, [{ remove: classNames },speed,easing,callback]) : this._removeClass(classNames); + removeClass: function( classNames, speed, easing, callback ) { + return speed ? + $.effects.animateClass.apply( this, [{ remove: classNames }, speed, easing, callback ]) : + this._removeClass(classNames); }, _toggleClass: $.fn.toggleClass, - toggleClass: function(classNames, force, speed, easing, callback) { + toggleClass: function( classNames, force, speed, easing, callback ) { if ( typeof force == "boolean" || force === undefined ) { if ( !speed ) { // without speed parameter; - return this._toggleClass(classNames, force); + return this._toggleClass( classNames, force ); } else { - return $.effects.animateClass.apply(this, [(force?{add:classNames}:{remove:classNames}),speed,easing,callback]); + return $.effects.animateClass.apply( this, [( force ? { add:classNames } : { remove:classNames }), speed, easing, callback ]); } } else { // without switch parameter; - return $.effects.animateClass.apply(this, [{ toggle: classNames },force,speed,easing]); + return $.effects.animateClass.apply( this, [{ toggle: classNames }, force, speed, easing ]); } }, - switchClass: function(remove,add,speed,easing,callback) { - return $.effects.animateClass.apply(this, [{ add: add, remove: remove },speed,easing,callback]); + switchClass: function( remove, add, speed, easing, callback) { + return $.effects.animateClass.apply( this, [{ + add: add, + remove: remove + }, speed, easing, callback ]); } }); @@ -306,62 +323,70 @@ $.fn.extend({ /*********************************** EFFECTS **********************************/ /******************************************************************************/ -$.extend($.effects, { +$.extend( $.effects, { version: "@VERSION", - // Saves a set of properties in a data storage - save: function(element, set) { - for(var i=0; i < set.length; i++) { - if(set[i] !== null) element.data("ec.storage."+set[i], element[0].style[set[i]]); - } - }, - - // Restores a set of previously saved properties from a data storage - restore: function(element, set) { - for(var i=0; i < set.length; i++) { - if(set[i] !== null) element.css(set[i], element.data("ec.storage."+set[i])); - } - }, - - setMode: function(el, mode) { - if (mode == 'toggle') mode = el.is(':hidden') ? 'show' : 'hide'; // Set for toggle - return mode; - }, - - getBaseline: function(origin, original) { // Translates a [top,left] array into a baseline value - // this should be a little more flexible in the future to handle a string & hash + // Translates a [top,left] array into a baseline value + // this should be a little more flexible in the future to handle a string & hash + getBaseline: function( origin, original ) { var y, x; - switch (origin[0]) { + switch ( origin[ 0 ] ) { case 'top': y = 0; break; case 'middle': y = 0.5; break; case 'bottom': y = 1; break; - default: y = origin[0] / original.height; + default: y = origin[ 0 ] / original.height; }; - switch (origin[1]) { + switch ( origin[ 1 ] ) { case 'left': x = 0; break; case 'center': x = 0.5; break; case 'right': x = 1; break; - default: x = origin[1] / original.width; + default: x = origin[ 1 ] / original.width; }; - return {x: x, y: y}; + return { + x: x, + y: y + }; + } +}); + +// Effects 1.9 Helper jQuery.sub() +$.effects.$.fn.extend({ + + // Saves a set of properties in a data storage + save: function( set ) { + for( var i=0; i < set.length; i++ ) { + if ( set[ i ] !== null ) { + this.data( "ec.storage." + set[ i ], this[ 0 ].style[ set[ i ] ] ); + } + } + return this; }, - // Wraps the element around a wrapper that copies position properties - createWrapper: function(element) { + // Restores a set of previously saved properties from a data storage + restore: function( set ) { + for( var i=0; i < set.length; i++ ) { + if ( set[ i ] !== null ) { + this.css( set[ i ], this.data( "ec.storage." + set[ i ] ) ); + } + } + return this; + }, + createWrapper: function( css ) { // if the element is already wrapped, return it - if (element.parent().is('.ui-effects-wrapper')) { - return element.parent(); + if ( this.parent().is( '.ui-effects-wrapper' )) { + return this.parent(); } // wrap the element - var props = { + var element = this, + props = { width: element.outerWidth(true), height: element.outerHeight(true), - 'float': element.css('float') + 'float': element.css( 'float' ) }, - wrapper = $('
') - .addClass('ui-effects-wrapper') + wrapper = $( '
' ) + .addClass( 'ui-effects-wrapper' ) .css({ fontSize: '100%', background: 'transparent', @@ -370,46 +395,78 @@ $.extend($.effects, { padding: 0 }); - element.wrap(wrapper); + element.wrap( wrapper ); wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually loose the reference to the wrapped element // transfer positioning properties to the wrapper - if (element.css('position') == 'static') { + if ( element.css( 'position' ) == 'static' ) { wrapper.css({ position: 'relative' }); element.css({ position: 'relative' }); } else { - $.extend(props, { - position: element.css('position'), - zIndex: element.css('z-index') + $.extend( props, { + position: element.css( 'position' ), + zIndex: element.css( 'z-index' ) }); - $.each(['top', 'left', 'bottom', 'right'], function(i, pos) { - props[pos] = element.css(pos); - if (isNaN(parseInt(props[pos], 10))) { - props[pos] = 'auto'; + $.each([ 'top', 'left', 'bottom', 'right' ], function(i, pos) { + props[ pos ] = element.css( pos ); + if ( isNaN( parseInt( props[ pos ], 10 ) ) ) { + props[ pos ] = 'auto'; } }); - element.css({position: 'relative', top: 0, left: 0, right: 'auto', bottom: 'auto' }); + element.css({ + position: 'relative', + top: 0, + left: 0, + right: 'auto', + bottom: 'auto' + }); } - return wrapper.css(props).show(); + if ( $.type( css ) == 'object' ) { + props = $.extend( props, css ); + } + + return wrapper.css( props ).show(); + }, + setMode: function( mode ) { + if (mode == 'toggle') { + mode = this.is( ':hidden' ) ? 'show' : 'hide'; + } + return mode; }, - removeWrapper: function(element) { - if (element.parent().is('.ui-effects-wrapper')) - return element.parent().replaceWith(element); - return element; + removeWrapper: function() { + if ( this.parent().is( '.ui-effects-wrapper' ) ) + return this.parent().replaceWith( this ); + return this; }, - setTransition: function(element, list, factor, value) { + setTransition: function( list, factor, value ) { + var el = this; value = value || {}; - $.each(list, function(i, x){ - unit = element.cssUnit(x); - if (unit[0] > 0) value[x] = unit[0] * factor + unit[1]; + $.each( list, function(i, x){ + unit = el.cssUnit( x ); + if ( unit[ 0 ] > 0 ) value[ x ] = unit[ 0 ] * factor + unit[ 1 ]; }); return value; } + }); +// Effects 1.8 API -> 1.9 +if ( BC ) { + + $.each( [ "save", "restore", "createWrapper", "setMode", "removeWrapper", "setTransition" ], function( i, fnName ) { + $.effects[ fnName ] = function() { + var args = [].slice.call( arguments ), + el = args.shift(); + + return $.effects.$.fn[ fnName ].apply( el, args ); + }; + }); + +} + // return an effect options object for the given parameters: function _normalizeArguments( effect, options, speed, callback ) { @@ -462,7 +519,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; } @@ -470,66 +527,84 @@ function standardSpeed( speed ) { } $.fn.extend({ - effect: function(effect, options, speed, callback) { - var args = _normalizeArguments.apply(this, arguments), + 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.callback ); } else { - return this.each(function() { + return this.each( function() { if ( args.callback ) { args.callback.call( this ); } }); } } - 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, - show: function(speed) { + show: function( speed ) { if ( standardSpeed( speed ) ) { - return this._show.apply(this, arguments); + return this._show.apply( this, arguments ); } else { - var args = _normalizeArguments.apply(this, arguments); + var args = _normalizeArguments.apply( this, arguments ); args.mode = 'show'; - return this.effect.call(this, args); + return this.effect.call( this, args ); } }, _hide: $.fn.hide, - hide: function(speed) { + hide: function( speed ) { if ( standardSpeed( speed ) ) { - return this._hide.apply(this, arguments); + return this._hide.apply( this, arguments ); } else { - var args = _normalizeArguments.apply(this, arguments); + var args = _normalizeArguments.apply( this, arguments ); args.mode = 'hide'; - return this.effect.call(this, args); + return this.effect.call( this, args ); } }, // jQuery core overloads toggle and creates _toggle __toggle: $.fn.toggle, - toggle: function(speed) { + toggle: function( speed ) { if ( standardSpeed( speed ) || typeof speed === "boolean" || $.isFunction( speed ) ) { - return this.__toggle.apply(this, arguments); + return this.__toggle.apply( this, arguments ); } else { - var args = _normalizeArguments.apply(this, arguments); + var args = _normalizeArguments.apply( this, arguments ); args.mode = 'toggle'; - return this.effect.call(this, args); + return this.effect.call( this, args ); } }, // helper functions cssUnit: function(key) { - var style = this.css(key), val = []; - $.each( ['em','px','%','pt'], function(i, unit){ - if(style.indexOf(unit) > 0) - val = [parseFloat(style), unit]; + var style = this.css( key ), + val = []; + + $.each( [ 'em', 'px', '%', 'pt' ], function( i, unit ) { + if ( style.indexOf( unit ) > 0 ) + val = [ parseFloat( style ), unit ]; }); return val; } @@ -581,136 +656,155 @@ $.fn.extend({ // t: current time, b: begInnIng value, c: change In value, d: duration $.easing.jswing = $.easing.swing; -$.extend($.easing, -{ +$.extend( $.easing, { def: 'easeOutQuad', - swing: function (x, t, b, c, d) { - //alert($.easing.default); - return $.easing[$.easing.def](x, t, b, c, d); + swing: function ( x, t, b, c, d ) { + return $.easing[ $.easing.def ]( x, t, b, c, d ); + }, + easeInQuad: function ( x, t, b, c, d ) { + return c * ( t /= d ) * t + b; + }, + easeOutQuad: function ( x, t, b, c, d ) { + return -c * ( t /= d ) * ( t - 2 ) + b; + }, + easeInOutQuad: function ( x, t, b, c, d ) { + if ( ( t /= d / 2 ) < 1 ) return c / 2 * t * t + b; + return -c / 2 * ( ( --t ) * ( t-2 ) - 1) + b; + }, + easeInCubic: function ( x, t, b, c, d ) { + return c * ( t /= d ) * t * t + b; + }, + easeOutCubic: function ( x, t, b, c, d ) { + return c * ( ( t = t / d - 1 ) * t * t + 1 ) + b; }, - easeInQuad: function (x, t, b, c, d) { - return c*(t/=d)*t + b; + easeInOutCubic: function ( x, t, b, c, d ) { + if ( ( t /= d / 2 ) < 1 ) return c / 2 * t * t * t + b; + return c / 2 * ( ( t -= 2 ) * t * t + 2) + b; }, - easeOutQuad: function (x, t, b, c, d) { - return -c *(t/=d)*(t-2) + b; + easeInQuart: function ( x, t, b, c, d ) { + return c * ( t /= d ) * t * t * t + b; }, - easeInOutQuad: function (x, t, b, c, d) { - if ((t/=d/2) < 1) return c/2*t*t + b; - return -c/2 * ((--t)*(t-2) - 1) + b; + easeOutQuart: function ( x, t, b, c, d ) { + return -c * ( ( t = t / d - 1 ) * t * t * t - 1) + b; }, - easeInCubic: function (x, t, b, c, d) { - return c*(t/=d)*t*t + b; + easeInOutQuart: function ( x, t, b, c, d ) { + if ( (t /= d / 2 ) < 1 ) return c / 2 * t * t * t * t + b; + return -c / 2 * ( ( t -= 2 ) * t * t * t - 2) + b; }, - easeOutCubic: function (x, t, b, c, d) { - return c*((t=t/d-1)*t*t + 1) + b; - }, - easeInOutCubic: function (x, t, b, c, d) { - if ((t/=d/2) < 1) return c/2*t*t*t + b; - return c/2*((t-=2)*t*t + 2) + b; - }, - easeInQuart: function (x, t, b, c, d) { - return c*(t/=d)*t*t*t + b; - }, - easeOutQuart: function (x, t, b, c, d) { - return -c * ((t=t/d-1)*t*t*t - 1) + b; - }, - easeInOutQuart: function (x, t, b, c, d) { - if ((t/=d/2) < 1) return c/2*t*t*t*t + b; - return -c/2 * ((t-=2)*t*t*t - 2) + b; - }, - easeInQuint: function (x, t, b, c, d) { - return c*(t/=d)*t*t*t*t + b; - }, - easeOutQuint: function (x, t, b, c, d) { - return c*((t=t/d-1)*t*t*t*t + 1) + b; - }, - easeInOutQuint: function (x, t, b, c, d) { - if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b; - return c/2*((t-=2)*t*t*t*t + 2) + b; - }, - easeInSine: function (x, t, b, c, d) { - return -c * Math.cos(t/d * (Math.PI/2)) + c + b; - }, - easeOutSine: function (x, t, b, c, d) { - return c * Math.sin(t/d * (Math.PI/2)) + b; - }, - easeInOutSine: function (x, t, b, c, d) { - return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b; - }, - easeInExpo: function (x, t, b, c, d) { - return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b; - }, - easeOutExpo: function (x, t, b, c, d) { - return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b; - }, - easeInOutExpo: function (x, t, b, c, d) { - if (t==0) return b; - if (t==d) return b+c; - if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b; - return c/2 * (-Math.pow(2, -10 * --t) + 2) + b; - }, - easeInCirc: function (x, t, b, c, d) { - return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b; - }, - easeOutCirc: function (x, t, b, c, d) { - return c * Math.sqrt(1 - (t=t/d-1)*t) + b; - }, - easeInOutCirc: function (x, t, b, c, d) { - if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b; - return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b; - }, - easeInElastic: function (x, t, b, c, d) { - var s=1.70158;var p=0;var a=c; - if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; - if (a < Math.abs(c)) { a=c; var s=p/4; } - else var s = p/(2*Math.PI) * Math.asin (c/a); - return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; - }, - easeOutElastic: function (x, t, b, c, d) { - var s=1.70158;var p=0;var a=c; - if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; - if (a < Math.abs(c)) { a=c; var s=p/4; } - else var s = p/(2*Math.PI) * Math.asin (c/a); - return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b; - }, - easeInOutElastic: function (x, t, b, c, d) { - var s=1.70158;var p=0;var a=c; - if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5); - if (a < Math.abs(c)) { a=c; var s=p/4; } - else var s = p/(2*Math.PI) * Math.asin (c/a); - if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; - return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b; - }, - easeInBack: function (x, t, b, c, d, s) { - if (s == undefined) s = 1.70158; - return c*(t/=d)*t*((s+1)*t - s) + b; - }, - easeOutBack: function (x, t, b, c, d, s) { - if (s == undefined) s = 1.70158; - return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b; - }, - easeInOutBack: function (x, t, b, c, d, s) { - if (s == undefined) s = 1.70158; - if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b; - return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b; + easeInQuint: function ( x, t, b, c, d ) { + return c * ( t /= d ) * t * t * t * t + b; }, - easeInBounce: function (x, t, b, c, d) { - return c - $.easing.easeOutBounce (x, d-t, 0, c, d) + b; - }, - easeOutBounce: function (x, t, b, c, d) { - if ((t/=d) < (1/2.75)) { - return c*(7.5625*t*t) + b; - } else if (t < (2/2.75)) { - return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b; - } else if (t < (2.5/2.75)) { - return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b; + easeOutQuint: function ( x, t, b, c, d ) { + return c * ( ( t = t / d - 1 ) * t * t * t * t + 1) + b; + }, + easeInOutQuint: function ( x, t, b, c, d ) { + if ( ( t /= d / 2 ) < 1 ) return c / 2 * t * t * t * t * t + b; + return c / 2 * ( ( t -= 2 ) * t * t * t * t + 2) + b; + }, + easeInSine: function ( x, t, b, c, d ) { + return -c * Math.cos( t / d * ( Math.PI / 2 ) ) + c + b; + }, + easeOutSine: function ( x, t, b, c, d ) { + return c * Math.sin( t / d * ( Math.PI /2 ) ) + b; + }, + easeInOutSine: function ( x, t, b, c, d ) { + return -c / 2 * ( Math.cos( Math.PI * t / d ) - 1 ) + b; + }, + easeInExpo: function ( x, t, b, c, d ) { + return ( t==0 ) ? b : c * Math.pow( 2, 10 * ( t / d - 1) ) + b; + }, + easeOutExpo: function ( x, t, b, c, d ) { + return ( t==d ) ? b + c : c * ( -Math.pow( 2, -10 * t / d) + 1) + b; + }, + easeInOutExpo: function ( x, t, b, c, d ) { + if ( t==0 ) return b; + if ( t==d ) return b + c; + if ( ( t /= d / 2) < 1) return c / 2 * Math.pow( 2, 10 * (t - 1) ) + b; + return c / 2 * ( -Math.pow( 2, -10 * --t ) + 2 ) + b; + }, + easeInCirc: function ( x, t, b, c, d ) { + return -c * ( Math.sqrt( 1 - ( t /= d ) * t ) - 1 ) + b; + }, + easeOutCirc: function ( x, t, b, c, d ) { + return c * Math.sqrt( 1 - ( t = t / d - 1 ) * t ) + b; + }, + easeInOutCirc: function ( x, t, b, c, d ) { + if ( ( t /= d / 2) < 1 ) return -c / 2 * ( Math.sqrt( 1 - t * t ) - 1 ) + b; + return c / 2 * ( Math.sqrt( 1 - ( t -= 2 ) * t ) + 1 ) + b; + }, + easeInElastic: function ( x, t, b, c, d ) { + var s = 1.70158, + p = d * 0.3, + a = c; + if ( t == 0 ) return b; + if ( ( t /= d ) == 1 ) return b+c; + if ( a < Math.abs( c ) ) { + a = c; + s = p / 4; + } else { + s = p / ( 2 * Math.PI ) * Math.asin( c / a ); + } + return - ( a * Math.pow( 2, 10 * ( t -= 1 ) ) * Math.sin( ( t * d - s) * ( 2 * Math.PI ) / p ) ) + b; + }, + easeOutElastic: function ( x, t, b, c, d ) { + var s = 1.70158, + p = d * 0.3, + a = c; + if ( t == 0 ) return b; + if ( ( t /= d ) == 1 ) return b+c; + if ( a < Math.abs( c ) ) { + a = c; + s = p / 4; + } else { + s = p / ( 2 * Math.PI ) * Math.asin( c / a ); + } + return a * Math.pow( 2, -10 * t ) * Math.sin( ( t * d - s ) * ( 2 * Math.PI ) / p ) + c + b; + }, + easeInOutElastic: function ( x, t, b, c, d ) { + var s = 1.70158, + p = d * ( 0.3 * 1.5 ), + a = c; + if ( t == 0 ) return b; + if ( ( t /= d / 2 ) == 2 ) return b+c; + if ( a < Math.abs( c ) ) { + a = c; + s = p / 4; + } else { + s = p / ( 2 * Math.PI ) * Math.asin( c / a ); + } + if ( t < 1 ) return -.5 * ( a * Math.pow( 2, 10 * ( t -= 1 ) ) * Math.sin( ( t * d - s ) * ( 2 * Math.PI ) / p ) ) + b; + return a * Math.pow( 2, -10 * ( t -= 1 ) ) * Math.sin( ( t * d - s ) * ( 2 * Math.PI ) / p ) *.5 + c + b; + }, + easeInBack: function ( x, t, b, c, d, s ) { + if ( s == undefined ) s = 1.70158; + return c * ( t /= d ) * t * ( ( s+1 ) * t - s ) + b; + }, + easeOutBack: function ( x, t, b, c, d, s ) { + if ( s == undefined ) s = 1.70158; + return c * ( ( t = t / d - 1 ) * t * ( ( s + 1 ) * t + s) + 1) + b; + }, + easeInOutBack: function ( x, t, b, c, d, s ) { + if ( s == undefined ) s = 1.70158; + if ( ( t /= d / 2 ) < 1 ) return c / 2 * ( t * t * ( ( ( s *= 1.525 ) + 1 ) * t - s ) ) + b; + return c / 2 * ( ( t -= 2 ) * t * ( ( ( s *= 1.525 ) + 1 ) * t + s) + 2) + b; + }, + easeInBounce: function ( x, t, b, c, d ) { + return c - $.easing.easeOutBounce( x, d - t, 0, c, d ) + b; + }, + easeOutBounce: function ( x, t, b, c, d ) { + if ( ( t /= d ) < ( 1 / 2.75 ) ) { + return c * ( 7.5625 * t * t ) + b; + } else if ( t < ( 2 / 2.75 ) ) { + return c * ( 7.5625 * ( t -= ( 1.5 / 2.75 ) ) * t + .75 ) + b; + } else if ( t < ( 2.5 / 2.75 ) ) { + return c * ( 7.5625 * ( t -= ( 2.25/ 2.75 ) ) * t + .9375 ) + b; } else { - return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b; + return c * ( 7.5625 * ( t -= ( 2.625 / 2.75 ) ) * t + .984375 ) + b; } }, - easeInOutBounce: function (x, t, b, c, d) { - if (t < d/2) return $.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b; - return $.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b; + easeInOutBounce: function ( x, t, b, c, d ) { + if ( t < d / 2 ) return $.easing.easeInBounce( x, t * 2, 0, c, d ) * .5 + b; + return $.easing.easeOutBounce( x, t * 2 - d, 0, c, d ) * .5 + c * .5 + b; } }); @@ -747,4 +841,4 @@ $.extend($.easing, * */ -})(jQuery); +})(jQuery); \ No newline at end of file diff --git a/ui/jquery.effects.drop.js b/ui/jquery.effects.drop.js index 221a0bf17a0..70683d8ab40 100644 --- a/ui/jquery.effects.drop.js +++ b/ui/jquery.effects.drop.js @@ -12,13 +12,13 @@ */ (function( $, undefined ) { -$.effects.drop = function( o ) { +$.effects.effect.drop = function( o ) { return this.queue( function() { - var el = $( this ), + var el = $.effects.$( this ), props = [ 'position', 'top', 'bottom', 'left', 'right', 'opacity' ], - mode = $.effects.setMode( el, o.mode || 'hide' ), + mode = el.setMode( o.mode || 'hide' ), direction = o.direction || 'left', ref = (direction == 'up' || direction == 'down') ? 'top' : 'left', motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg', @@ -28,14 +28,12 @@ $.effects.drop = function( o ) { distance; // Adjust - $.effects.save(el, props); el.show(); - $.effects.createWrapper(el); - + el.save( props ).show().createWrapper(); + distance = o.distance || el[ ref == 'top' ? 'outerHeight': 'outerWidth' ]({ margin: true }) / 2; if ( mode == 'show' ) { - el - .css( 'opacity', 0 ) + el.css( 'opacity', 0 ) .css( ref, motion == 'pos' ? -distance : distance ); } @@ -49,8 +47,7 @@ $.effects.drop = function( o ) { easing: o.easing, complete: function() { mode == 'hide' && el.hide(); - $.effects.restore( el, props ); - $.effects.removeWrapper( el ); + el.restore( props ).removeWrapper(); $.isFunction( o.complete ) && o.complete.apply(this, arguments); el.dequeue(); } diff --git a/ui/jquery.effects.explode.js b/ui/jquery.effects.explode.js index 763092457fb..041f2e61312 100644 --- a/ui/jquery.effects.explode.js +++ b/ui/jquery.effects.explode.js @@ -12,14 +12,16 @@ */ (function( $, undefined ) { -$.effects.explode = function( o ) { +$.effects.effect.explode = function( o ) { return this.queue( function() { var rows = o.pieces ? Math.round(Math.sqrt(o.pieces)) : 3, cells = rows, - el = $( this ).show().css( 'visibility', 'hidden' ), - mode = $.effects.setMode( el, o.mode || 'hide' ), + el = $.effects.$( this ) + .show() + .css( 'visibility', 'hidden' ), + mode = el.setMode( o.mode || 'hide' ), offset = el.offset(), width = el.outerWidth( true ), height = el.outerHeight( true ); diff --git a/ui/jquery.effects.fade.js b/ui/jquery.effects.fade.js index c6cb85cc212..a4defb39d5f 100644 --- a/ui/jquery.effects.fade.js +++ b/ui/jquery.effects.fade.js @@ -12,10 +12,10 @@ */ (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' ); + var el = $.effects.$( this ), + mode = el.setMode( o.mode || 'hide' ); el.animate({ opacity: mode diff --git a/ui/jquery.effects.fold.js b/ui/jquery.effects.fold.js index 19e97c40f20..3280c94d73a 100644 --- a/ui/jquery.effects.fold.js +++ b/ui/jquery.effects.fold.js @@ -12,32 +12,26 @@ */ (function( $, undefined ) { -$.effects.fold = function( o ) { +$.effects.effect.fold = function( o ) { return this.queue( function() { // Create element - var el = $( this ), + var el = $.effects.$( this ), props = ['position','top','bottom','left','right'], - mode = $.effects.setMode(el, o.mode || 'hide'), + mode = el.setMode( 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(); - - // Create Wrapper - wrapper = $.effects.createWrapper( el ).css({ - overflow: 'hidden' - }); - distance = widthFirst ? - [ wrapper.width(), wrapper.height() ] : - [ wrapper.height(), wrapper.width() ]; + wrapper = el.save( props ).show().createWrapper({ + 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 ]; @@ -60,8 +54,7 @@ $.effects.fold = function( o ) { .animate( animation1, duration, o.easing ) .animate( animation2, duration, o.easing, function() { (mode == 'hide') && el.hide(); - $.effects.restore( el, props ); - $.effects.removeWrapper( el ); + el.restore( props ).removeWrapper(); jQuery.isFunction(o.complete) && o.complete.apply( el[ 0 ], arguments ); el.dequeue(); }); diff --git a/ui/jquery.effects.highlight.js b/ui/jquery.effects.highlight.js index b2ffb15e8ea..5a053f3e3c7 100644 --- a/ui/jquery.effects.highlight.js +++ b/ui/jquery.effects.highlight.js @@ -12,22 +12,21 @@ */ (function( $, undefined ) { -$.effects.highlight = function( o ) { +$.effects.effect.highlight = function( o ) { return this.queue( function() { - var elem = $( this ), + var el = $.effects.$( this ), props = [ 'backgroundImage', 'backgroundColor', 'opacity' ], - mode = $.effects.setMode( elem, o.mode || 'show' ), + mode = el.setMode( o.mode || 'show' ), animation = { - backgroundColor: elem.css( 'backgroundColor' ) + backgroundColor: el.css( 'backgroundColor' ) }; if (mode == 'hide') { animation.opacity = 0; } - $.effects.save( elem, props ); - - elem + el + .save( props ) .show() .css({ backgroundImage: 'none', @@ -38,11 +37,11 @@ $.effects.highlight = function( o ) { duration: o.duration, easing: o.easing, complete: function() { - (mode == 'hide' && elem.hide()); - $.effects.restore( elem, props ); + (mode == 'hide' && el.hide()); + el.restore( props ); (mode == 'show' && !$.support.opacity && this.style.removeAttribute( 'filter' )); jQuery.isFunction(o.complete) && o.complete.apply(this, arguments); - elem.dequeue(); + el.dequeue(); } }); }); diff --git a/ui/jquery.effects.pulsate.js b/ui/jquery.effects.pulsate.js index c5f67b12bff..7606a8d6900 100644 --- a/ui/jquery.effects.pulsate.js +++ b/ui/jquery.effects.pulsate.js @@ -12,18 +12,18 @@ */ (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' ), + var el = $.effects.$( this ), + mode = el.setMode( o.mode || 'show' ), times = ( ( o.times || 5 ) * 2 ) - 1, duration = o.duration / 2, - isVisible = elem.is( ':visible' ), + isVisible = el.is( ':visible' ), animateTo = 0, i; if ( !isVisible ) { - elem.css('opacity', 0).show(); + el.css('opacity', 0).show(); animateTo = 1; } @@ -32,17 +32,17 @@ $.effects.pulsate = function( o ) { } for ( i = 0; i < times; i++ ) { - elem.animate({ + el.animate({ opacity: animateTo }, duration, o.easing ); animateTo = ( animateTo + 1 ) % 2; } - elem.animate({ + el.animate({ opacity: animateTo }, duration, o.easing, function() { if (animateTo == 0) { - elem.hide(); + el.hide(); } (o.complete && o.complete.apply(this, arguments)); }).dequeue(); diff --git a/ui/jquery.effects.scale.js b/ui/jquery.effects.scale.js index ec707c2b596..77b3b09c5d0 100644 --- a/ui/jquery.effects.scale.js +++ b/ui/jquery.effects.scale.js @@ -12,16 +12,15 @@ */ (function( $, undefined ) { -$.effects.puff = function( o ) { - console.log(o); +$.effects.effect.puff = function( o ) { return this.queue( function() { - var elem = $( this ), - mode = $.effects.setMode( elem, o.mode || 'hide' ), + var el = $.effects.$( this ), + mode = el.setMode( o.mode || 'hide' ), percent = parseInt( o.percent, 10 ) || 150, factor = percent / 100, original = { - height: elem.height(), - width: elem.width() + height: el.height(), + width: el.width() }; $.extend(o, { @@ -37,18 +36,18 @@ $.effects.puff = function( o ) { } }); - elem.effect( o ).dequeue(); + el.effect( o ).dequeue(); }); }; -$.effects.scale = function( o ) { +$.effects.effect.scale = function( o ) { return this.queue( function() { // Create element - var el = $( this ), + var el = $.effects.$( this ), options = $.extend( true, {}, o ), - mode = $.effects.setMode( el, o.mode || 'effect' ), + mode = el.setMode( 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, @@ -93,11 +92,11 @@ $.effects.scale = function( o ) { }; -$.effects.size = function( o ) { +$.effects.effect.size = function( o ) { return this.queue( function() { // Create element - var el = $( this ), + var el = $.effects.$( this ), props = [ 'position', 'top', 'bottom', 'left', 'right', 'width', 'height', 'overflow', 'opacity' ], // Always restore @@ -110,7 +109,7 @@ $.effects.size = function( o ) { hProps = [ 'borderLeftWidth', 'borderRightWidth', 'paddingLeft', 'paddingRight' ], // Set options - mode = $.effects.setMode( el, o.mode || 'effect' ), + mode = el.setMode( o.mode || 'effect' ), restore = o.restore || false, scale = o.scale || 'both', origin = o.origin, @@ -150,15 +149,15 @@ $.effects.size = function( o ) { // 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 ); + el.from = el.setTransition( vProps, factor.from.y, el.from ); + el.to = el.setTransition( vProps, factor.to.y, el.to ); }; // Horizontal props scaling if ( factor.from.x != factor.to.x ) { props = props.concat( hProps ); - el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from ); - el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to ); + el.from = el.setTransition( hProps, factor.from.x, el.from ); + el.to = el.setTransition( hProps, factor.to.x, el.to ); }; }; @@ -168,14 +167,12 @@ $.effects.size = function( o ) { // 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 ); + el.from = el.setTransition( cProps, factor.from.y, el.from ); + el.to = el.setTransition( cProps, factor.to.y, el.to ); }; }; - $.effects.save( el, restore ? props : props1 ); - el.show(); - $.effects.createWrapper( el ); + el.save( restore ? props : props1 ).show().createWrapper(); el.css( 'overflow', 'hidden' ).css( el.from ); // Animate @@ -187,12 +184,12 @@ $.effects.size = function( o ) { props2 = props.concat(vProps).concat(hProps); el.find( "*[width]" ).each( function(){ - var child = $( this ), + var child = $.effects.$( this ), c_original = { height: child.height(), width: child.width() }; - if (restore) $.effects.save(child, props2); + if (restore) el.save(child, props2); child.from = { height: c_original.height * factor.from.y, @@ -205,14 +202,14 @@ $.effects.size = function( o ) { // 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 ); + child.from = child.setTransition( vProps, factor.from.y, child.from ); + child.to = child.setTransition( 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 ); + child.from = child.setTransition( hProps, factor.from.x, child.from ); + child.to = child.setTransition( hProps, factor.to.x, child.to ); }; // Animate children @@ -220,7 +217,7 @@ $.effects.size = function( o ) { child.animate( child.to, o.duration, o.easing, function() { // Restore children - if (restore) $.effects.restore( child, props2 ); + if (restore) child.restore( props2 ); }); }); }; @@ -237,8 +234,7 @@ $.effects.size = function( o ) { if( mode == 'hide' ) { el.hide(); } - $.effects.restore( el, restore ? props : props1 ); - $.effects.removeWrapper( el ); + el.restore( restore ? props : props1 ).removeWrapper(); $.isFunction( o.complete ) && o.complete.apply( this, arguments ); // Callback el.dequeue(); } diff --git a/ui/jquery.effects.shake.js b/ui/jquery.effects.shake.js index 5e8875abeba..ed100e43989 100644 --- a/ui/jquery.effects.shake.js +++ b/ui/jquery.effects.shake.js @@ -12,13 +12,13 @@ */ (function( $, undefined ) { -$.effects.shake = function( o ) { +$.effects.effect.shake = function( o ) { return this.queue( function() { - var el = $( this ), + var el = $.effect.$( this ), props = [ 'position', 'top', 'bottom', 'left', 'right' ], - mode = $.effects.setMode( el, o.mode || 'effect' ), + mode = el.setMode( o.mode || 'effect' ), direction = o.direction || 'left', distance = o.distance || 20, times = o.times || 3, @@ -30,10 +30,7 @@ $.effects.shake = function( o ) { animation2 = {}, i; - // Adjust - $.effects.save( el, props ); - el.show(); - $.effects.createWrapper( el ); // Create Wrapper + el.save( props ).show().createWrapper(); // Animation animation[ ref ] = ( motion == 'pos' ? '-=' : '+=' ) + distance; @@ -52,8 +49,7 @@ $.effects.shake = function( o ) { .animate( animation, speed / 2, o.easing, function() { // Last shake - $.effects.restore( el, props ); - $.effects.removeWrapper( el ); + el.restore( props ).removeWrapper(); $.isFunction( o.complete ) && o.complete.apply( this, arguments ); }) .dequeue(); diff --git a/ui/jquery.effects.slide.js b/ui/jquery.effects.slide.js index eeba117cf85..3fcf8729b7f 100644 --- a/ui/jquery.effects.slide.js +++ b/ui/jquery.effects.slide.js @@ -12,14 +12,14 @@ */ (function( $, undefined ) { -$.effects.slide = function( o ) { +$.effects.effect.slide = function( o ) { return this.queue( function() { // Create element var el = $( this ), props = ['position','top','bottom','left','right'], - mode = $.effects.setMode( el, o.mode || 'show' ), + mode = el.setMode( o.mode || 'show' ), direction = o.direction || 'left', ref = (direction == 'up' || direction == 'down') ? 'top' : 'left', motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg', @@ -27,9 +27,7 @@ $.effects.slide = function( o ) { animation = {}; // Adjust - $.effects.save( el, props ); - el.show(); - $.effects.createWrapper( el ).css({ + el.save( props ).show().createWrapper({ overflow: 'hidden' }); @@ -55,8 +53,7 @@ $.effects.slide = function( o ) { if ( mode == 'hide' ) { el.hide(); } - $.effects.restore( el, props ); - $.effects.removeWrapper( el ); + el.restore( props ).removeWrapper(); $.isFunction(o.complete) && o.complete.apply( this, arguments ); el.dequeue(); } 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 d0009afbcfd5ad0040015235ddcf5d88c0e98042 Mon Sep 17 00:00:00 2001 From: gnarf Date: Tue, 8 Mar 2011 01:18:37 -0600 Subject: [PATCH 2/5] effects.*: couple of quick changes lost in my cherrypicking --- ui/jquery.effects.shake.js | 2 +- ui/jquery.effects.slide.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/jquery.effects.shake.js b/ui/jquery.effects.shake.js index ed100e43989..f68807e7a14 100644 --- a/ui/jquery.effects.shake.js +++ b/ui/jquery.effects.shake.js @@ -16,7 +16,7 @@ $.effects.effect.shake = function( o ) { return this.queue( function() { - var el = $.effect.$( this ), + var el = $.effects.$( this ), props = [ 'position', 'top', 'bottom', 'left', 'right' ], mode = el.setMode( o.mode || 'effect' ), direction = o.direction || 'left', diff --git a/ui/jquery.effects.slide.js b/ui/jquery.effects.slide.js index 3fcf8729b7f..f565722e7ef 100644 --- a/ui/jquery.effects.slide.js +++ b/ui/jquery.effects.slide.js @@ -17,7 +17,7 @@ $.effects.effect.slide = function( o ) { return this.queue( function() { // Create element - var el = $( this ), + var el = $.effects.$( this ), props = ['position','top','bottom','left','right'], mode = el.setMode( o.mode || 'show' ), direction = o.direction || 'left', From 3c4aab826229a848792f1f0d4889ad4ccbf5671c Mon Sep 17 00:00:00 2001 From: gnarf Date: Fri, 11 Mar 2011 07:10:14 -0600 Subject: [PATCH 3/5] effects.core: Another place where args.callback was used that escaped my first pass --- ui/jquery.effects.core.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/jquery.effects.core.js b/ui/jquery.effects.core.js index 00ed0702122..1ace3ab660e 100644 --- a/ui/jquery.effects.core.js +++ b/ui/jquery.effects.core.js @@ -543,11 +543,11 @@ $.fn.extend({ if ( $.fx.off || ! ( effectMethod || oldEffectMethod ) ) { // delegate to the original method (e.g., .show()) if possible if ( mode ) { - return this[ mode ]( args.duration, args.callback ); + return this[ mode ]( args.duration, args.complete ); } else { return this.each( function() { - if ( args.callback ) { - args.callback.call( this ); + if ( args.complete ) { + args.complete.call( this ); } }); } From 46e0574cc3c5bb2d596ed4f1201395387683b23e Mon Sep 17 00:00:00 2001 From: gnarf Date: Fri, 11 Mar 2011 09:14:11 -0600 Subject: [PATCH 4/5] 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 5/5] 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' :