Removed guard against duplicate loading. Use safe references to original functions when proxying, don't rename originals.

This commit is contained in:
Scott González 2013-03-08 10:23:25 -05:00
parent cdff72efed
commit e0b2644d91
2 changed files with 49 additions and 50 deletions

36
ui/jquery.ui.core.js vendored
View File

@ -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;

View File

@ -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 );
},
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: $.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 );
},
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: $.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 );
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);