github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

jquery / jquery

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 2,006
    • 189
  • Source
  • Commits
  • Network (189)
  • Graphs
  • Tree: 48ec100

click here to add a description

click here to add a homepage

  • Switch Branches (3)
    • master
    • mobile
    • omgrequire
  • Switch Tags (41)
    • 1.4rc1
    • 1.4a2
    • 1.4a1
    • 1.4.2
    • 1.4.1
    • 1.4
    • 1.3rc1
    • 1.3b2
    • 1.3b1
    • 1.3.2
    • 1.3.1rc1
    • 1.3.1
    • 1.3
    • 1.2.6
    • 1.2.5
    • 1.2.4b
    • 1.2.4a
    • 1.2.4
    • 1.2.3b
    • 1.2.3a
    • 1.2.3
    • 1.2.2b2
    • 1.2.2b
    • 1.2.2
    • 1.2.1
    • 1.2
    • 1.1b
    • 1.1a
    • 1.1.4
    • 1.1.3a
    • 1.1.3.1
    • 1.1.3
    • 1.1.2
    • 1.1.1
    • 1.1
    • 1.0a
    • 1.0.4
    • 1.0.3
    • 1.0.2
    • 1.0.1
    • 1.0
  • Comments
Sending Request…

jQuery JavaScript Library — Read more

  Cancel

http://jquery.com/

  Cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Added in a bunch of fx fixes - and hide/show/toggle are decoupled from 
later methods.
jeresig (author)
Fri Aug 25 20:51:03 -0700 2006
commit  48ec10044f011ccfe9bd232d629682b59cccbd97
tree    5410cb2a50943749f943bdd688f5b99b125290d8
parent  a2af24b064bd1384c24b896fdd9c7d322954546b
M src/event/event.js 6 ••••
M src/fx/fx.js 62 ••••
M src/jquery/jquery.js 56 ••••
0
src/event/event.js
...
2
3
4
5
 
6
7
8
...
25
26
27
28
 
29
30
31
...
37
38
39
40
 
41
42
43
...
2
3
4
 
5
6
7
8
...
25
26
27
 
28
29
30
31
...
37
38
39
 
40
41
42
43
0
@@ -2,7 +2,7 @@ jQuery.fn.extend({
0
 
0
   // We're overriding the old toggle function, so
0
   // remember it for later
0
-  //_toggle: jQuery.fn.toggle,
0
+  _toggle: jQuery.fn.toggle,
0
   
0
   /**
0
    * Toggle between two function calls every other click.
0
@@ -25,7 +25,7 @@ jQuery.fn.extend({
0
   toggle: function(a,b) {
0
     // If two functions are passed in, we're
0
     // toggling on a click
0
-    return a && b ? this.click(function(e){
0
+    return a && b && a.constructor == Function && b.constructor == Function ? this.click(function(e){
0
       // Figure out which function to execute
0
       this.last = this.last == a ? b : a;
0
       
0
@@ -37,7 +37,7 @@ jQuery.fn.extend({
0
     }) :
0
     
0
     // Otherwise, execute the old toggle function
0
-    this._toggle();
0
+    this._toggle.apply( this, arguments );
0
   },
0
   
0
   /**
0
src/fx/fx.js
...
1
2
3
4
 
5
6
7
...
39
40
41
42
 
43
44
45
...
261
262
263
264
 
 
 
265
266
 
267
268
269
270
271
 
272
273
274
...
328
329
330
331
 
332
333
334
...
344
345
346
347
348
349
350
351
352
...
405
406
407
 
408
409
410
...
454
455
456
457
 
458
459
460
...
466
467
468
469
470
471
472
...
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
498
499
500
 
501
502
503
...
1
2
3
 
4
5
6
7
...
39
40
41
 
42
43
44
45
...
261
262
263
 
264
265
266
267
 
268
269
270
271
272
273
274
275
276
277
...
331
332
333
 
334
335
336
337
...
347
348
349
 
 
 
350
351
352
...
405
406
407
408
409
410
411
...
455
456
457
 
458
459
460
461
...
467
468
469
 
470
471
472
...
481
482
483
 
 
 
 
 
 
 
 
 
 
 
 
 
 
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
 
512
513
514
515
0
@@ -1,7 +1,7 @@
0
 jQuery.fn.extend({
0
 
0
   // overwrite the old show method
0
-  //_show: jQuery.fn.show,
0
+  _show: jQuery.fn.show,
0
   
0
   /**
0
    * Show all matched elements using a graceful animation.
0
@@ -39,7 +39,7 @@ jQuery.fn.extend({
0
   },
0
   
0
   // Overwrite the old hide method
0
-  //_hide: jQuery.fn.hide,
0
+  _hide: jQuery.fn.hide,
0
   
0
   /**
0
    * Hide all matched elements using a graceful animation.
0
@@ -261,14 +261,17 @@ jQuery.fn.extend({
0
    */
0
   animate: function(prop,speed,callback) {
0
     return this.queue(function(){
0
-      var i = 0;
0
+    
0
+      this.curAnim = prop;
0
+      
0
       for ( var p in prop ) {
0
-        var e = new jQuery.fx( this, jQuery.speed(speed,callback,i++), p );
0
+        var e = new jQuery.fx( this, jQuery.speed(speed,callback), p );
0
         if ( prop[p].constructor == Number )
0
           e.custom( e.cur(), prop[p] );
0
         else
0
           e[ prop[p] ]( prop );
0
       }
0
+      
0
     });
0
   },
0
   
0
@@ -328,7 +331,7 @@ jQuery.extend({
0
     }
0
   },
0
   
0
-  speed: function(s,o,i) {
0
+  speed: function(s,o) {
0
     o = o || {};
0
     
0
     if ( o.constructor == Function )
0
@@ -344,9 +347,6 @@ jQuery.extend({
0
       if ( o.oldComplete && o.oldComplete.constructor == Function )
0
         o.oldComplete.apply( this );
0
     };
0
-    
0
-    if ( i > 0 )
0
-      o.complete = null;
0
   
0
     return o;
0
   },
0
@@ -405,6 +405,7 @@ jQuery.extend({
0
       // My hate for IE will never die
0
       } else if ( parseInt(z.now) )
0
         y[prop] = parseInt(z.now) + "px";
0
+        
0
       y.display = "block";
0
     };
0
   
0
@@ -454,7 +455,7 @@ jQuery.extend({
0
       z.o.hide = true;
0
 
0
       // Begin the animation
0
-      z.custom(z.cur(),0);
0
+      z.custom(z.el.orig[prop], 0);
0
     };
0
   
0
     // IE has trouble with opacity if it does not have layout
0
@@ -466,7 +467,6 @@ jQuery.extend({
0
       z.el.oldOverflow = jQuery.css( z.el, "overflow" );
0
   
0
     // Make sure that nothing sneaks out
0
-    //if ( z.el.oldOverlay == "visible" )
0
     y.overflow = "hidden";
0
   
0
     // Each step of an animation
0
@@ -481,23 +481,35 @@ jQuery.extend({
0
         z.now = lastNum;
0
         z.a();
0
 
0
-        // Hide the element if the "hide" operation was done
0
-        if ( z.o.hide ) y.display = 'none';
0
-  
0
-        // Reset the overflow
0
-        y.overflow = z.el.oldOverflow;
0
-
0
-        // Reset the property, if the item has been hidden
0
-        if ( z.o.hide )
0
-          y[ prop ] = z.el.orig[ prop ].constructor == Number && prop != "opacity" ?
0
-            z.el.orig[prop] + "px" : z.el.orig[prop];
0
-
0
-        // set its height and/or width to auto
0
-        if ( prop == 'height' || prop == 'width' )
0
-          jQuery.setAuto( z.el, prop );
0
+        z.el.curAnim[ prop ] = true;
0
+        
0
+        var done = true;
0
+        for ( var i in z.el.curAnim )
0
+          if ( z.el.curAnim[i] !== true )
0
+            done = false;
0
+            
0
+        if ( done ) {
0
+          // Reset the overflow
0
+          y.overflow = z.el.oldOverflow;
0
+        
0
+          // Hide the element if the "hide" operation was done
0
+          if ( z.o.hide ) 
0
+            y.display = 'none';
0
+          
0
+          // Reset the property, if the item has been hidden
0
+          if ( z.o.hide ) {
0
+            for ( var p in z.el.curAnim ) {
0
+              y[ p ] = z.el.orig[p] + ( p == "opacity" ? "" : "px" );
0
+  
0
+              // set its height and/or width to auto
0
+              if ( p == 'height' || p == 'width' )
0
+                jQuery.setAuto( z.el, p );
0
+            }
0
+          }
0
+        }
0
 
0
         // If a callback was provided, execute it
0
-        if( z.o.complete && z.o.complete.constructor == Function )
0
+        if( done && z.o.complete && z.o.complete.constructor == Function )
0
           // Execute the complete function
0
           z.o.complete.apply( z.el );
0
       } else {
0
src/jquery/jquery.js
...
29
30
31
32
33
34
35
36
37
...
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
...
82
83
84
 
85
 
 
86
87
88
...
811
812
813
814
815
816
817
818
...
934
935
936
937
938
939
940
941
942
 
 
 
 
 
 
 
 
 
 
943
944
945
946
947
 
948
949
950
...
2417
2418
2419
2420
 
2421
2422
2423
...
2440
2441
2442
2443
 
2444
2445
2446
...
2460
2461
2462
2463
2464
2465
 
 
2466
2467
2468
...
2672
2673
2674
 
 
2675
...
29
30
31
 
 
 
32
33
34
...
36
37
38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
40
41
...
60
61
62
63
64
65
66
67
68
69
...
792
793
794
 
 
795
796
797
...
913
914
915
 
 
 
 
 
 
916
917
918
919
920
921
922
923
924
925
926
927
928
929
 
930
931
932
933
...
2400
2401
2402
 
2403
2404
2405
2406
...
2423
2424
2425
 
2426
2427
2428
2429
...
2443
2444
2445
 
 
 
2446
2447
2448
2449
2450
...
2654
2655
2656
2657
2658
2659
0
@@ -29,9 +29,6 @@ window.undefined = window.undefined;
0
  */
0
 function jQuery(a,c) {
0
 
0
-  // Initalize the extra macro functions
0
-  if ( !jQuery.initDone ) jQuery.init();
0
-
0
   // Shortcut for document ready (because $(document).each() is silly)
0
   if ( a && a.constructor == Function && jQuery.fn.ready )
0
     return jQuery(document).ready(a);
0
@@ -39,25 +36,6 @@ function jQuery(a,c) {
0
   // Make sure that a selection was provided
0
   a = a || jQuery.context || document;
0
 
0
-  /*
0
-    * Handle support for overriding other $() functions. Way too many libraries
0
-    * provide this function to simply ignore it and overwrite it.
0
-    */
0
-  /*
0
-  // Check to see if this is a possible collision case
0
-  if ( jQuery._$ && !c && a.constructor == String && 
0
-      
0
-    // Make sure that the expression is a colliding one
0
-    !/[^a-zA-Z0-9_-]/.test(a) &&
0
-        
0
-    // and that there are no elements that match it
0
-    // (this is the one truly ambiguous case)
0
-    !document.getElementsByTagName(a).length )
0
-
0
-      // Use the default method, in case it works some voodoo
0
-      return jQuery._$( a );
0
-  */
0
-
0
   // Watch for when a jQuery object is passed as the selector
0
   if ( a.jquery )
0
     return $( jQuery.merge( a, [] ) );
0
@@ -82,7 +60,10 @@ function jQuery(a,c) {
0
     // Find the matching elements and save them for later
0
     jQuery.find( a, c ) );
0
 
0
+  // See if an extra function was provided
0
   var fn = arguments[ arguments.length - 1 ];
0
+  
0
+  // If so, execute it in context
0
   if ( fn && fn.constructor == Function )
0
     this.each(fn);
0
 }
0
@@ -811,8 +792,6 @@ jQuery.extend = jQuery.fn.extend = function(obj,prop) {
0
 
0
 jQuery.extend({
0
   /**
0
-   * 
0
-   *
0
    * @private
0
    * @name init
0
    * @type undefined
0
@@ -934,17 +913,21 @@ jQuery.extend({
0
         if (jQuery.css(e,"display") != "none") {
0
           oHeight = e.offsetHeight;
0
           oWidth = e.offsetWidth;
0
-        } else
0
-          jQuery.swap( e, { visibility: "hidden", position: "absolute", display: "block" },
0
-            function(){
0
-              oHeight = e.clientHeight;
0
-              oWidth = e.clientWidth;
0
-            });
0
+        } else {
0
+          e = $(e.cloneNode(true)).css({
0
+            visibility: "hidden", position: "absolute", display: "block"
0
+          }).prependTo("body")[0];
0
+
0
+          oHeight = e.clientHeight;
0
+          oWidth = e.clientWidth;
0
+          
0
+          e.parentNode.removeChild(e);
0
+        }
0
       });
0
   
0
       return p == "height" ? oHeight : oWidth;
0
     } else if ( p == "opacity" && jQuery.browser.msie )
0
-      return parseFloat(  jQuery.curCSS(e,"filter").replace(/[^0-9.]/,"") ) || 1;
0
+      return parseFloat( jQuery.curCSS(e,"filter").replace(/[^0-9.]/,"") ) || 1;
0
 
0
     return jQuery.curCSS( e, p );
0
   },
0
@@ -2417,7 +2400,7 @@ jQuery.macros = {
0
      * @type jQuery
0
      * @cat Effects
0
      */
0
-    _show: function(){
0
+    show: function(){
0
       this.style.display = this.oldblock ? this.oldblock : "";
0
       if ( jQuery.css(this,"display") == "none" )
0
         this.style.display = "block";
0
@@ -2440,7 +2423,7 @@ jQuery.macros = {
0
      * @type jQuery
0
      * @cat Effects
0
      */
0
-    _hide: function(){
0
+    hide: function(){
0
       this.oldblock = this.oldblock || jQuery.css(this,"display");
0
       if ( this.oldblock == "none" )
0
         this.oldblock = "block";
0
@@ -2460,9 +2443,8 @@ jQuery.macros = {
0
      * @type jQuery
0
      * @cat Effects
0
      */
0
-    _toggle: function(){
0
-      var d = jQuery.css(this,"display");
0
-      $(this)[ !d || d == "none" ? "show" : "hide" ]();
0
+    toggle: function(){
0
+      $(this)[ $(this).is(":hidden") ? "show" : "hide" ].apply( $(this), arguments );
0
     },
0
     
0
     /**
0
@@ -2672,3 +2654,5 @@ jQuery.macros = {
0
     }
0
   }
0
 };
0
+
0
+jQuery.init();
0
\ No newline at end of file

Comments

Please log in to comment.
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server