Skip to content
Permalink
Browse files

Removed guard against duplicate loading. Use safe references to origi…

…nal functions when proxying, don't rename originals.
  • Loading branch information...
scottgonzalez committed Mar 8, 2013
1 parent cdff72e commit e0b2644d91ffb8b59f9cf6d8ac8b45f94af7dacd
Showing with 51 additions and 52 deletions.
  1. +16 −20 ui/jquery.ui.core.js
  2. +35 −32 ui/jquery.ui.effect.js
@@ -13,13 +13,8 @@
var uuid = 0,
runiqueId = /^ui-id-\d+$/;

// prevent duplicate loading
// this is only a problem because we proxy existing functions
// and we don't want to double proxy them
// $.ui might exist from components with no dependencies, e.g., $.ui.position
$.ui = $.ui || {};
if ( $.ui.version ) {
return;
}

$.extend( $.ui, {
version: "@VERSION",
@@ -52,20 +47,21 @@ $.extend( $.ui, {

// plugins
$.fn.extend({
_focus: $.fn.focus,
focus: function( delay, fn ) {
return typeof delay === "number" ?
this.each(function() {
var elem = this;
setTimeout(function() {
$( elem ).focus();
if ( fn ) {
fn.call( elem );
}
}, delay );
}) :
this._focus.apply( this, arguments );
},
focus: (function( orig ) {
return function( delay, fn ) {
return typeof delay === "number" ?
this.each(function() {
var elem = this;
setTimeout(function() {
$( elem ).focus();
if ( fn ) {
fn.call( elem );
}
}, delay );
}) :
orig.apply( this, arguments );
};
})( $.fn.focus ),

scrollParent: function() {
var scrollParent;
@@ -8,7 +8,7 @@
*
* http://api.jqueryui.com/category/effects-core/
*/
;(jQuery.effects || (function($, undefined) {
(function($, undefined) {

var dataSpace = "ui-effects-";

@@ -839,39 +839,42 @@ $.effects.animateClass = function( value, duration, easing, callback ) {
};

$.fn.extend({
_addClass: $.fn.addClass,
addClass: function( classNames, speed, easing, callback ) {
return speed ?
$.effects.animateClass.call( this,
{ add: classNames }, speed, easing, callback ) :
this._addClass( classNames );
},

_removeClass: $.fn.removeClass,
removeClass: function( classNames, speed, easing, callback ) {
return arguments.length > 1 ?
$.effects.animateClass.call( this,
{ remove: classNames }, speed, easing, callback ) :
this._removeClass.apply( this, arguments );
},

_toggleClass: $.fn.toggleClass,
toggleClass: function( classNames, force, speed, easing, callback ) {
if ( typeof force === "boolean" || force === undefined ) {
if ( !speed ) {
// without speed parameter
return this._toggleClass( classNames, force );
addClass: (function( orig ) {
return function( classNames, speed, easing, callback ) {
return speed ?
$.effects.animateClass.call( this,
{ add: classNames }, speed, easing, callback ) :
orig.apply( this, arguments );
};
})( $.fn.addClass ),

removeClass: (function( orig ) {
return function( classNames, speed, easing, callback ) {
return arguments.length > 1 ?
$.effects.animateClass.call( this,
{ remove: classNames }, speed, easing, callback ) :
orig.apply( this, arguments );
};
})( $.fn.removeClass ),

toggleClass: (function( orig ) {
return function( classNames, force, speed, easing, callback ) {
if ( typeof force === "boolean" || force === undefined ) {
if ( !speed ) {
// without speed parameter
return orig.apply( this, arguments );
} else {
return $.effects.animateClass.call( this,
(force ? { add: classNames } : { remove: classNames }),
speed, easing, callback );
}
} else {
// without force parameter
return $.effects.animateClass.call( this,
(force ? { add: classNames } : { remove: classNames }),
speed, easing, callback );
{ toggle: classNames }, force, speed, easing );
}
} else {
// without force parameter
return $.effects.animateClass.call( this,
{ toggle: classNames }, force, speed, easing );
}
},
};
})( $.fn.toggleClass ),

switchClass: function( remove, add, speed, easing, callback) {
return $.effects.animateClass.call( this, {
@@ -1283,4 +1286,4 @@ $.each( baseEasings, function( name, easeIn ) {

})();

})(jQuery));
})(jQuery);

0 comments on commit e0b2644

Please sign in to comment.
You can’t perform that action at this time.