]> source.dussan.org Git - jquery-ui.git/commitdiff
Removed guard against duplicate loading. Use safe references to original functions...
authorScott González <scott.gonzalez@gmail.com>
Fri, 8 Mar 2013 15:23:25 +0000 (10:23 -0500)
committerScott González <scott.gonzalez@gmail.com>
Fri, 8 Mar 2013 15:23:25 +0000 (10:23 -0500)
ui/jquery.ui.core.js
ui/jquery.ui.effect.js

index d224f181a2127e3080d57265556291f4fd4eaa61..1a13da2512b067e226044a6391ece5d16a657bee 100644 (file)
 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;
index f3d9929b029e0f6ccd47887412ea52bca9407b94..3d65b40c7c54b0ddd2f8ccf077f4fd6872db061c 100644 (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 );
-       },
-
-       _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);