jquery-rails 1.0.16 → 1.0.17

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of jquery-rails might be problematic. Click here for more details.

@@ -1,3 +1,10 @@
1
+ ## 1.0.17 (9 November 2011)
2
+
3
+ - Updated to jQuery 1.7
4
+ - Updated to latest jquery-ujs
5
+ - Moved file comment above function so it won't be included in
6
+ compressed version
7
+
1
8
  ## 1.0.16 (12 October 2011)
2
9
 
3
10
  - Updated to jQuery 1.6.4
@@ -4,55 +4,6 @@ GIT
4
4
  specs:
5
5
  rack (1.2.1)
6
6
 
7
- GIT
8
- remote: git://github.com/rails/rails.git
9
- revision: 2fbbd08616c25dc2931eca914349dd2161766f69
10
- specs:
11
- actionmailer (3.1.0.beta)
12
- actionpack (= 3.1.0.beta)
13
- mail (~> 2.3.0)
14
- actionpack (3.1.0.beta)
15
- activemodel (= 3.1.0.beta)
16
- activesupport (= 3.1.0.beta)
17
- builder (~> 3.0.0)
18
- erubis (~> 2.7.0)
19
- i18n (~> 0.6.0beta1)
20
- rack (~> 1.2.1)
21
- rack-cache (~> 1.0.0)
22
- rack-mount (~> 0.7.2)
23
- rack-test (~> 0.5.7)
24
- sprockets (~> 2.0.0.beta.2)
25
- tzinfo (~> 0.3.23)
26
- activemodel (3.1.0.beta)
27
- activesupport (= 3.1.0.beta)
28
- bcrypt-ruby (~> 2.1.4)
29
- builder (~> 3.0.0)
30
- i18n (~> 0.6.0beta1)
31
- activerecord (3.1.0.beta)
32
- activemodel (= 3.1.0.beta)
33
- activesupport (= 3.1.0.beta)
34
- arel (~> 2.1.0)
35
- tzinfo (~> 0.3.23)
36
- activeresource (3.1.0.beta)
37
- activemodel (= 3.1.0.beta)
38
- activesupport (= 3.1.0.beta)
39
- activesupport (3.1.0.beta)
40
- multi_json (~> 1.0.0)
41
- rails (3.1.0.beta)
42
- actionmailer (= 3.1.0.beta)
43
- actionpack (= 3.1.0.beta)
44
- activerecord (= 3.1.0.beta)
45
- activeresource (= 3.1.0.beta)
46
- activesupport (= 3.1.0.beta)
47
- bundler (~> 1.0)
48
- railties (= 3.1.0.beta)
49
- railties (3.1.0.beta)
50
- actionpack (= 3.1.0.beta)
51
- activesupport (= 3.1.0.beta)
52
- rack-ssl (~> 1.3.2)
53
- rake (>= 0.8.7)
54
- thor (~> 0.14.4)
55
-
56
7
  GIT
57
8
  remote: git://github.com/sstephenson/sprockets.git
58
9
  revision: c4800417792744c11eb1fb888bbe9a3a82859952
@@ -65,46 +16,77 @@ GIT
65
16
  PATH
66
17
  remote: .
67
18
  specs:
68
- jquery-rails (0.3)
69
- rails (~> 3.1)
70
- thor (~> 0.14.4)
19
+ jquery-rails (1.0.17)
20
+ railties (~> 3.0)
21
+ thor (~> 0.14)
71
22
 
72
23
  GEM
73
24
  remote: http://rubygems.org/
74
25
  specs:
75
- addressable (2.2.4)
76
- arel (2.1.0)
77
- bcrypt-ruby (2.1.4)
78
- builder (3.0.0)
79
- crack (0.1.8)
80
- erubis (2.7.0)
26
+ abstract (1.0.0)
27
+ actionmailer (3.0.5)
28
+ actionpack (= 3.0.5)
29
+ mail (~> 2.2.15)
30
+ actionpack (3.0.5)
31
+ activemodel (= 3.0.5)
32
+ activesupport (= 3.0.5)
33
+ builder (~> 2.1.2)
34
+ erubis (~> 2.6.6)
35
+ i18n (~> 0.4)
36
+ rack (~> 1.2.1)
37
+ rack-mount (~> 0.6.13)
38
+ rack-test (~> 0.5.7)
39
+ tzinfo (~> 0.3.23)
40
+ activemodel (3.0.5)
41
+ activesupport (= 3.0.5)
42
+ builder (~> 2.1.2)
43
+ i18n (~> 0.4)
44
+ activerecord (3.0.5)
45
+ activemodel (= 3.0.5)
46
+ activesupport (= 3.0.5)
47
+ arel (~> 2.0.2)
48
+ tzinfo (~> 0.3.23)
49
+ activeresource (3.0.5)
50
+ activemodel (= 3.0.5)
51
+ activesupport (= 3.0.5)
52
+ activesupport (3.0.5)
53
+ arel (2.0.10)
54
+ builder (2.1.2)
55
+ erubis (2.6.6)
56
+ abstract (>= 1.0.0)
81
57
  hike (1.0.0)
82
58
  i18n (0.6.0beta1)
83
- mail (2.3.0)
59
+ mail (2.2.19)
60
+ activesupport (>= 2.3.6)
84
61
  i18n (>= 0.4.0)
85
62
  mime-types (~> 1.16)
86
63
  treetop (~> 1.4.8)
87
- mime-types (1.16)
88
- multi_json (1.0.0)
89
- polyglot (0.3.1)
90
- rack-cache (1.0.1)
91
- rack (>= 0.4)
92
- rack-mount (0.7.2)
64
+ mime-types (1.17.2)
65
+ polyglot (0.3.3)
66
+ rack-mount (0.6.14)
93
67
  rack (>= 1.0.0)
94
- rack-ssl (1.3.2)
95
- rack
96
68
  rack-test (0.5.7)
97
69
  rack (>= 1.0)
98
- rake (0.8.7)
99
- rspec (1.3.1)
70
+ rails (3.0.5)
71
+ actionmailer (= 3.0.5)
72
+ actionpack (= 3.0.5)
73
+ activerecord (= 3.0.5)
74
+ activeresource (= 3.0.5)
75
+ activesupport (= 3.0.5)
76
+ bundler (~> 1.0)
77
+ railties (= 3.0.5)
78
+ railties (3.0.5)
79
+ actionpack (= 3.0.5)
80
+ activesupport (= 3.0.5)
81
+ rake (>= 0.8.7)
82
+ thor (~> 0.14.4)
83
+ rake (0.9.2.2)
100
84
  thor (0.14.6)
101
85
  tilt (1.3)
102
- treetop (1.4.9)
86
+ treetop (1.4.10)
87
+ polyglot
103
88
  polyglot (>= 0.3.1)
104
- tzinfo (0.3.27)
105
- webmock (1.6.2)
106
- addressable (>= 2.2.2)
107
- crack (>= 0.1.7)
89
+ tzinfo (0.3.31)
108
90
 
109
91
  PLATFORMS
110
92
  ruby
@@ -114,7 +96,5 @@ DEPENDENCIES
114
96
  i18n (= 0.6.0beta1)
115
97
  jquery-rails!
116
98
  rack!
117
- rails!
118
- rspec (~> 1.3)
99
+ rails (~> 3.0)
119
100
  sprockets!
120
- webmock (~> 1.6.2)
@@ -1,8 +1,8 @@
1
1
  module Jquery
2
2
  module Rails
3
- VERSION = "1.0.16"
4
- JQUERY_VERSION = "1.6.4"
3
+ VERSION = "1.0.17"
4
+ JQUERY_VERSION = "1.7.0"
5
5
  JQUERY_UI_VERSION = "1.8.16"
6
- JQUERY_UJS_VERSION = "acd1a149fb715710c22e56ee4c50a9c6ab840709"
6
+ JQUERY_UJS_VERSION = "17f4004310b6ece3cb240914932b4d6d46032c24"
7
7
  end
8
8
  end
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * jQuery JavaScript Library v1.6.4
2
+ * jQuery JavaScript Library v1.7
3
3
  * http://jquery.com/
4
4
  *
5
5
  * Copyright 2011, John Resig
@@ -11,7 +11,7 @@
11
11
  * Copyright 2011, The Dojo Foundation
12
12
  * Released under the MIT, BSD, and GPL Licenses.
13
13
  *
14
- * Date: Mon Sep 12 18:54:48 2011 -0400
14
+ * Date: Thu Nov 3 16:18:21 2011 -0400
15
15
  */
16
16
  (function( window, undefined ) {
17
17
 
@@ -140,7 +140,7 @@ jQuery.fn = jQuery.prototype = {
140
140
  // HANDLE: $(html) -> $(array)
141
141
  if ( match[1] ) {
142
142
  context = context instanceof jQuery ? context[0] : context;
143
- doc = (context ? context.ownerDocument || context : document);
143
+ doc = ( context ? context.ownerDocument || context : document );
144
144
 
145
145
  // If a single string is passed in and it's a single tag
146
146
  // just do a createElement and skip the rest
@@ -157,7 +157,7 @@ jQuery.fn = jQuery.prototype = {
157
157
 
158
158
  } else {
159
159
  ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
160
- selector = (ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment).childNodes;
160
+ selector = ( ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment ).childNodes;
161
161
  }
162
162
 
163
163
  return jQuery.merge( this, selector );
@@ -187,7 +187,7 @@ jQuery.fn = jQuery.prototype = {
187
187
 
188
188
  // HANDLE: $(expr, $(...))
189
189
  } else if ( !context || context.jquery ) {
190
- return (context || rootjQuery).find( selector );
190
+ return ( context || rootjQuery ).find( selector );
191
191
 
192
192
  // HANDLE: $(expr, context)
193
193
  // (which is just equivalent to: $(context).find(expr)
@@ -201,7 +201,7 @@ jQuery.fn = jQuery.prototype = {
201
201
  return rootjQuery.ready( selector );
202
202
  }
203
203
 
204
- if (selector.selector !== undefined) {
204
+ if ( selector.selector !== undefined ) {
205
205
  this.selector = selector.selector;
206
206
  this.context = selector.context;
207
207
  }
@@ -213,7 +213,7 @@ jQuery.fn = jQuery.prototype = {
213
213
  selector: "",
214
214
 
215
215
  // The current version of jQuery being used
216
- jquery: "1.6.4",
216
+ jquery: "1.7",
217
217
 
218
218
  // The default length of a jQuery object is 0
219
219
  length: 0,
@@ -258,7 +258,7 @@ jQuery.fn = jQuery.prototype = {
258
258
  ret.context = this.context;
259
259
 
260
260
  if ( name === "find" ) {
261
- ret.selector = this.selector + (this.selector ? " " : "") + selector;
261
+ ret.selector = this.selector + ( this.selector ? " " : "" ) + selector;
262
262
  } else if ( name ) {
263
263
  ret.selector = this.selector + "." + name + "(" + selector + ")";
264
264
  }
@@ -279,7 +279,7 @@ jQuery.fn = jQuery.prototype = {
279
279
  jQuery.bindReady();
280
280
 
281
281
  // Add the callback
282
- readyList.done( fn );
282
+ readyList.add( fn );
283
283
 
284
284
  return this;
285
285
  },
@@ -434,7 +434,7 @@ jQuery.extend({
434
434
  }
435
435
 
436
436
  // If there are functions bound, to execute
437
- readyList.resolveWith( document, [ jQuery ] );
437
+ readyList.fireWith( document, [ jQuery ] );
438
438
 
439
439
  // Trigger any bound ready events
440
440
  if ( jQuery.fn.trigger ) {
@@ -448,7 +448,7 @@ jQuery.extend({
448
448
  return;
449
449
  }
450
450
 
451
- readyList = jQuery._Deferred();
451
+ readyList = jQuery.Callbacks( "once memory" );
452
452
 
453
453
  // Catch cases where $(document).ready() is called after the
454
454
  // browser event has already occurred.
@@ -504,8 +504,8 @@ jQuery.extend({
504
504
  return obj && typeof obj === "object" && "setInterval" in obj;
505
505
  },
506
506
 
507
- isNaN: function( obj ) {
508
- return obj == null || !rdigit.test( obj ) || isNaN( obj );
507
+ isNumeric: function( obj ) {
508
+ return obj != null && rdigit.test( obj ) && !isNaN( obj );
509
509
  },
510
510
 
511
511
  type: function( obj ) {
@@ -573,7 +573,7 @@ jQuery.extend({
573
573
  .replace( rvalidtokens, "]" )
574
574
  .replace( rvalidbraces, "")) ) {
575
575
 
576
- return (new Function( "return " + data ))();
576
+ return ( new Function( "return " + data ) )();
577
577
 
578
578
  }
579
579
  jQuery.error( "Invalid JSON: " + data );
@@ -703,18 +703,22 @@ jQuery.extend({
703
703
  return ret;
704
704
  },
705
705
 
706
- inArray: function( elem, array ) {
707
- if ( !array ) {
708
- return -1;
709
- }
706
+ inArray: function( elem, array, i ) {
707
+ var len;
710
708
 
711
- if ( indexOf ) {
712
- return indexOf.call( array, elem );
713
- }
709
+ if ( array ) {
710
+ if ( indexOf ) {
711
+ return indexOf.call( array, elem, i );
712
+ }
714
713
 
715
- for ( var i = 0, length = array.length; i < length; i++ ) {
716
- if ( array[ i ] === elem ) {
717
- return i;
714
+ len = array.length;
715
+ i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
716
+
717
+ for ( ; i < len; i++ ) {
718
+ // Skip accessing in sparse arrays
719
+ if ( i in array && array[ i ] === elem ) {
720
+ return i;
721
+ }
718
722
  }
719
723
  }
720
724
 
@@ -850,7 +854,7 @@ jQuery.extend({
850
854
  },
851
855
 
852
856
  now: function() {
853
- return (new Date()).getTime();
857
+ return ( new Date() ).getTime();
854
858
  },
855
859
 
856
860
  // Use of jQuery.browser is frowned upon.
@@ -952,193 +956,378 @@ function doScrollCheck() {
952
956
  jQuery.ready();
953
957
  }
954
958
 
959
+ // Expose jQuery as an AMD module, but only for AMD loaders that
960
+ // understand the issues with loading multiple versions of jQuery
961
+ // in a page that all might call define(). The loader will indicate
962
+ // they have special allowances for multiple jQuery versions by
963
+ // specifying define.amd.jQuery = true. Register as a named module,
964
+ // since jQuery can be concatenated with other files that may use define,
965
+ // but not use a proper concatenation script that understands anonymous
966
+ // AMD modules. A named AMD is safest and most robust way to register.
967
+ // Lowercase jquery is used because AMD module names are derived from
968
+ // file names, and jQuery is normally delivered in a lowercase file name.
969
+ if ( typeof define === "function" && define.amd && define.amd.jQuery ) {
970
+ define( "jquery", [], function () { return jQuery; } );
971
+ }
972
+
955
973
  return jQuery;
956
974
 
957
975
  })();
958
976
 
959
977
 
960
- var // Promise methods
961
- promiseMethods = "done fail isResolved isRejected promise then always pipe".split( " " ),
962
- // Static reference to slice
963
- sliceDeferred = [].slice;
978
+ // String to Object flags format cache
979
+ var flagsCache = {};
964
980
 
965
- jQuery.extend({
966
- // Create a simple deferred (one callbacks list)
967
- _Deferred: function() {
968
- var // callbacks list
969
- callbacks = [],
970
- // stored [ context , args ]
971
- fired,
972
- // to avoid firing when already doing so
973
- firing,
974
- // flag to know if the deferred has been cancelled
975
- cancelled,
976
- // the deferred itself
977
- deferred = {
978
-
979
- // done( f1, f2, ...)
980
- done: function() {
981
- if ( !cancelled ) {
982
- var args = arguments,
983
- i,
984
- length,
985
- elem,
986
- type,
987
- _fired;
988
- if ( fired ) {
989
- _fired = fired;
990
- fired = 0;
991
- }
992
- for ( i = 0, length = args.length; i < length; i++ ) {
993
- elem = args[ i ];
994
- type = jQuery.type( elem );
995
- if ( type === "array" ) {
996
- deferred.done.apply( deferred, elem );
997
- } else if ( type === "function" ) {
998
- callbacks.push( elem );
981
+ // Convert String-formatted flags into Object-formatted ones and store in cache
982
+ function createFlags( flags ) {
983
+ var object = flagsCache[ flags ] = {},
984
+ i, length;
985
+ flags = flags.split( /\s+/ );
986
+ for ( i = 0, length = flags.length; i < length; i++ ) {
987
+ object[ flags[i] ] = true;
988
+ }
989
+ return object;
990
+ }
991
+
992
+ /*
993
+ * Create a callback list using the following parameters:
994
+ *
995
+ * flags: an optional list of space-separated flags that will change how
996
+ * the callback list behaves
997
+ *
998
+ * By default a callback list will act like an event callback list and can be
999
+ * "fired" multiple times.
1000
+ *
1001
+ * Possible flags:
1002
+ *
1003
+ * once: will ensure the callback list can only be fired once (like a Deferred)
1004
+ *
1005
+ * memory: will keep track of previous values and will call any callback added
1006
+ * after the list has been fired right away with the latest "memorized"
1007
+ * values (like a Deferred)
1008
+ *
1009
+ * unique: will ensure a callback can only be added once (no duplicate in the list)
1010
+ *
1011
+ * stopOnFalse: interrupt callings when a callback returns false
1012
+ *
1013
+ */
1014
+ jQuery.Callbacks = function( flags ) {
1015
+
1016
+ // Convert flags from String-formatted to Object-formatted
1017
+ // (we check in cache first)
1018
+ flags = flags ? ( flagsCache[ flags ] || createFlags( flags ) ) : {};
1019
+
1020
+ var // Actual callback list
1021
+ list = [],
1022
+ // Stack of fire calls for repeatable lists
1023
+ stack = [],
1024
+ // Last fire value (for non-forgettable lists)
1025
+ memory,
1026
+ // Flag to know if list is currently firing
1027
+ firing,
1028
+ // First callback to fire (used internally by add and fireWith)
1029
+ firingStart,
1030
+ // End of the loop when firing
1031
+ firingLength,
1032
+ // Index of currently firing callback (modified by remove if needed)
1033
+ firingIndex,
1034
+ // Add one or several callbacks to the list
1035
+ add = function( args ) {
1036
+ var i,
1037
+ length,
1038
+ elem,
1039
+ type,
1040
+ actual;
1041
+ for ( i = 0, length = args.length; i < length; i++ ) {
1042
+ elem = args[ i ];
1043
+ type = jQuery.type( elem );
1044
+ if ( type === "array" ) {
1045
+ // Inspect recursively
1046
+ add( elem );
1047
+ } else if ( type === "function" ) {
1048
+ // Add if not in unique mode and callback is not in
1049
+ if ( !flags.unique || !self.has( elem ) ) {
1050
+ list.push( elem );
1051
+ }
1052
+ }
1053
+ }
1054
+ },
1055
+ // Fire callbacks
1056
+ fire = function( context, args ) {
1057
+ args = args || [];
1058
+ memory = !flags.memory || [ context, args ];
1059
+ firing = true;
1060
+ firingIndex = firingStart || 0;
1061
+ firingStart = 0;
1062
+ firingLength = list.length;
1063
+ for ( ; list && firingIndex < firingLength; firingIndex++ ) {
1064
+ if ( list[ firingIndex ].apply( context, args ) === false && flags.stopOnFalse ) {
1065
+ memory = true; // Mark as halted
1066
+ break;
1067
+ }
1068
+ }
1069
+ firing = false;
1070
+ if ( list ) {
1071
+ if ( !flags.once ) {
1072
+ if ( stack && stack.length ) {
1073
+ memory = stack.shift();
1074
+ self.fireWith( memory[ 0 ], memory[ 1 ] );
1075
+ }
1076
+ } else if ( memory === true ) {
1077
+ self.disable();
1078
+ } else {
1079
+ list = [];
1080
+ }
1081
+ }
1082
+ },
1083
+ // Actual Callbacks object
1084
+ self = {
1085
+ // Add a callback or a collection of callbacks to the list
1086
+ add: function() {
1087
+ if ( list ) {
1088
+ var length = list.length;
1089
+ add( arguments );
1090
+ // Do we need to add the callbacks to the
1091
+ // current firing batch?
1092
+ if ( firing ) {
1093
+ firingLength = list.length;
1094
+ // With memory, if we're not firing then
1095
+ // we should call right away, unless previous
1096
+ // firing was halted (stopOnFalse)
1097
+ } else if ( memory && memory !== true ) {
1098
+ firingStart = length;
1099
+ fire( memory[ 0 ], memory[ 1 ] );
1100
+ }
1101
+ }
1102
+ return this;
1103
+ },
1104
+ // Remove a callback from the list
1105
+ remove: function() {
1106
+ if ( list ) {
1107
+ var args = arguments,
1108
+ argIndex = 0,
1109
+ argLength = args.length;
1110
+ for ( ; argIndex < argLength ; argIndex++ ) {
1111
+ for ( var i = 0; i < list.length; i++ ) {
1112
+ if ( args[ argIndex ] === list[ i ] ) {
1113
+ // Handle firingIndex and firingLength
1114
+ if ( firing ) {
1115
+ if ( i <= firingLength ) {
1116
+ firingLength--;
1117
+ if ( i <= firingIndex ) {
1118
+ firingIndex--;
1119
+ }
1120
+ }
1121
+ }
1122
+ // Remove the element
1123
+ list.splice( i--, 1 );
1124
+ // If we have some unicity property then
1125
+ // we only need to do this once
1126
+ if ( flags.unique ) {
1127
+ break;
1128
+ }
999
1129
  }
1000
1130
  }
1001
- if ( _fired ) {
1002
- deferred.resolveWith( _fired[ 0 ], _fired[ 1 ] );
1003
- }
1004
1131
  }
1005
- return this;
1006
- },
1007
-
1008
- // resolve with given context and args
1009
- resolveWith: function( context, args ) {
1010
- if ( !cancelled && !fired && !firing ) {
1011
- // make sure args are available (#8421)
1012
- args = args || [];
1013
- firing = 1;
1014
- try {
1015
- while( callbacks[ 0 ] ) {
1016
- callbacks.shift().apply( context, args );
1017
- }
1132
+ }
1133
+ return this;
1134
+ },
1135
+ // Control if a given callback is in the list
1136
+ has: function( fn ) {
1137
+ if ( list ) {
1138
+ var i = 0,
1139
+ length = list.length;
1140
+ for ( ; i < length; i++ ) {
1141
+ if ( fn === list[ i ] ) {
1142
+ return true;
1018
1143
  }
1019
- finally {
1020
- fired = [ context, args ];
1021
- firing = 0;
1144
+ }
1145
+ }
1146
+ return false;
1147
+ },
1148
+ // Remove all callbacks from the list
1149
+ empty: function() {
1150
+ list = [];
1151
+ return this;
1152
+ },
1153
+ // Have the list do nothing anymore
1154
+ disable: function() {
1155
+ list = stack = memory = undefined;
1156
+ return this;
1157
+ },
1158
+ // Is it disabled?
1159
+ disabled: function() {
1160
+ return !list;
1161
+ },
1162
+ // Lock the list in its current state
1163
+ lock: function() {
1164
+ stack = undefined;
1165
+ if ( !memory || memory === true ) {
1166
+ self.disable();
1167
+ }
1168
+ return this;
1169
+ },
1170
+ // Is it locked?
1171
+ locked: function() {
1172
+ return !stack;
1173
+ },
1174
+ // Call all callbacks with the given context and arguments
1175
+ fireWith: function( context, args ) {
1176
+ if ( stack ) {
1177
+ if ( firing ) {
1178
+ if ( !flags.once ) {
1179
+ stack.push( [ context, args ] );
1022
1180
  }
1181
+ } else if ( !( flags.once && memory ) ) {
1182
+ fire( context, args );
1023
1183
  }
1024
- return this;
1025
- },
1184
+ }
1185
+ return this;
1186
+ },
1187
+ // Call all the callbacks with the given arguments
1188
+ fire: function() {
1189
+ self.fireWith( this, arguments );
1190
+ return this;
1191
+ },
1192
+ // To know if the callbacks have already been called at least once
1193
+ fired: function() {
1194
+ return !!memory;
1195
+ }
1196
+ };
1026
1197
 
1027
- // resolve with this as context and given arguments
1028
- resolve: function() {
1029
- deferred.resolveWith( this, arguments );
1030
- return this;
1031
- },
1198
+ return self;
1199
+ };
1032
1200
 
1033
- // Has this deferred been resolved?
1034
- isResolved: function() {
1035
- return !!( firing || fired );
1036
- },
1037
1201
 
1038
- // Cancel
1039
- cancel: function() {
1040
- cancelled = 1;
1041
- callbacks = [];
1042
- return this;
1043
- }
1044
- };
1045
1202
 
1046
- return deferred;
1047
- },
1048
1203
 
1049
- // Full fledged deferred (two callbacks list)
1204
+ var // Static reference to slice
1205
+ sliceDeferred = [].slice;
1206
+
1207
+ jQuery.extend({
1208
+
1050
1209
  Deferred: function( func ) {
1051
- var deferred = jQuery._Deferred(),
1052
- failDeferred = jQuery._Deferred(),
1053
- promise;
1054
- // Add errorDeferred methods, then and promise
1055
- jQuery.extend( deferred, {
1056
- then: function( doneCallbacks, failCallbacks ) {
1057
- deferred.done( doneCallbacks ).fail( failCallbacks );
1058
- return this;
1059
- },
1060
- always: function() {
1061
- return deferred.done.apply( deferred, arguments ).fail.apply( this, arguments );
1210
+ var doneList = jQuery.Callbacks( "once memory" ),
1211
+ failList = jQuery.Callbacks( "once memory" ),
1212
+ progressList = jQuery.Callbacks( "memory" ),
1213
+ state = "pending",
1214
+ lists = {
1215
+ resolve: doneList,
1216
+ reject: failList,
1217
+ notify: progressList
1062
1218
  },
1063
- fail: failDeferred.done,
1064
- rejectWith: failDeferred.resolveWith,
1065
- reject: failDeferred.resolve,
1066
- isRejected: failDeferred.isResolved,
1067
- pipe: function( fnDone, fnFail ) {
1068
- return jQuery.Deferred(function( newDefer ) {
1069
- jQuery.each( {
1070
- done: [ fnDone, "resolve" ],
1071
- fail: [ fnFail, "reject" ]
1072
- }, function( handler, data ) {
1073
- var fn = data[ 0 ],
1074
- action = data[ 1 ],
1075
- returned;
1076
- if ( jQuery.isFunction( fn ) ) {
1077
- deferred[ handler ](function() {
1078
- returned = fn.apply( this, arguments );
1079
- if ( returned && jQuery.isFunction( returned.promise ) ) {
1080
- returned.promise().then( newDefer.resolve, newDefer.reject );
1081
- } else {
1082
- newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] );
1083
- }
1084
- });
1085
- } else {
1086
- deferred[ handler ]( newDefer[ action ] );
1219
+ promise = {
1220
+ done: doneList.add,
1221
+ fail: failList.add,
1222
+ progress: progressList.add,
1223
+
1224
+ state: function() {
1225
+ return state;
1226
+ },
1227
+
1228
+ // Deprecated
1229
+ isResolved: doneList.fired,
1230
+ isRejected: failList.fired,
1231
+
1232
+ then: function( doneCallbacks, failCallbacks, progressCallbacks ) {
1233
+ deferred.done( doneCallbacks ).fail( failCallbacks ).progress( progressCallbacks );
1234
+ return this;
1235
+ },
1236
+ always: function() {
1237
+ return deferred.done.apply( deferred, arguments ).fail.apply( deferred, arguments );
1238
+ },
1239
+ pipe: function( fnDone, fnFail, fnProgress ) {
1240
+ return jQuery.Deferred(function( newDefer ) {
1241
+ jQuery.each( {
1242
+ done: [ fnDone, "resolve" ],
1243
+ fail: [ fnFail, "reject" ],
1244
+ progress: [ fnProgress, "notify" ]
1245
+ }, function( handler, data ) {
1246
+ var fn = data[ 0 ],
1247
+ action = data[ 1 ],
1248
+ returned;
1249
+ if ( jQuery.isFunction( fn ) ) {
1250
+ deferred[ handler ](function() {
1251
+ returned = fn.apply( this, arguments );
1252
+ if ( returned && jQuery.isFunction( returned.promise ) ) {
1253
+ returned.promise().then( newDefer.resolve, newDefer.reject, newDefer.notify );
1254
+ } else {
1255
+ newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] );
1256
+ }
1257
+ });
1258
+ } else {
1259
+ deferred[ handler ]( newDefer[ action ] );
1260
+ }
1261
+ });
1262
+ }).promise();
1263
+ },
1264
+ // Get a promise for this deferred
1265
+ // If obj is provided, the promise aspect is added to the object
1266
+ promise: function( obj ) {
1267
+ if ( obj == null ) {
1268
+ obj = promise;
1269
+ } else {
1270
+ for ( var key in promise ) {
1271
+ obj[ key ] = promise[ key ];
1087
1272
  }
1088
- });
1089
- }).promise();
1090
- },
1091
- // Get a promise for this deferred
1092
- // If obj is provided, the promise aspect is added to the object
1093
- promise: function( obj ) {
1094
- if ( obj == null ) {
1095
- if ( promise ) {
1096
- return promise;
1097
1273
  }
1098
- promise = obj = {};
1274
+ return obj;
1099
1275
  }
1100
- var i = promiseMethods.length;
1101
- while( i-- ) {
1102
- obj[ promiseMethods[i] ] = deferred[ promiseMethods[i] ];
1103
- }
1104
- return obj;
1105
- }
1106
- });
1107
- // Make sure only one callback list will be used
1108
- deferred.done( failDeferred.cancel ).fail( deferred.cancel );
1109
- // Unexpose cancel
1110
- delete deferred.cancel;
1276
+ },
1277
+ deferred = promise.promise({}),
1278
+ key;
1279
+
1280
+ for ( key in lists ) {
1281
+ deferred[ key ] = lists[ key ].fire;
1282
+ deferred[ key + "With" ] = lists[ key ].fireWith;
1283
+ }
1284
+
1285
+ // Handle state
1286
+ deferred.done( function() {
1287
+ state = "resolved";
1288
+ }, failList.disable, progressList.lock ).fail( function() {
1289
+ state = "rejected";
1290
+ }, doneList.disable, progressList.lock );
1291
+
1111
1292
  // Call given func if any
1112
1293
  if ( func ) {
1113
1294
  func.call( deferred, deferred );
1114
1295
  }
1296
+
1297
+ // All done!
1115
1298
  return deferred;
1116
1299
  },
1117
1300
 
1118
1301
  // Deferred helper
1119
1302
  when: function( firstParam ) {
1120
- var args = arguments,
1303
+ var args = sliceDeferred.call( arguments, 0 ),
1121
1304
  i = 0,
1122
1305
  length = args.length,
1306
+ pValues = new Array( length ),
1123
1307
  count = length,
1308
+ pCount = length,
1124
1309
  deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ?
1125
1310
  firstParam :
1126
- jQuery.Deferred();
1311
+ jQuery.Deferred(),
1312
+ promise = deferred.promise();
1127
1313
  function resolveFunc( i ) {
1128
1314
  return function( value ) {
1129
1315
  args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
1130
1316
  if ( !( --count ) ) {
1131
- // Strange bug in FF4:
1132
- // Values changed onto the arguments object sometimes end up as undefined values
1133
- // outside the $.when method. Cloning the object into a fresh array solves the issue
1134
- deferred.resolveWith( deferred, sliceDeferred.call( args, 0 ) );
1317
+ deferred.resolveWith( deferred, args );
1135
1318
  }
1136
1319
  };
1137
1320
  }
1321
+ function progressFunc( i ) {
1322
+ return function( value ) {
1323
+ pValues[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
1324
+ deferred.notifyWith( promise, pValues );
1325
+ };
1326
+ }
1138
1327
  if ( length > 1 ) {
1139
- for( ; i < length; i++ ) {
1140
- if ( args[ i ] && jQuery.isFunction( args[ i ].promise ) ) {
1141
- args[ i ].promise().then( resolveFunc(i), deferred.reject );
1328
+ for ( ; i < length; i++ ) {
1329
+ if ( args[ i ] && args[ i ].promise && jQuery.isFunction( args[ i ].promise ) ) {
1330
+ args[ i ].promise().then( resolveFunc(i), deferred.reject, progressFunc(i) );
1142
1331
  } else {
1143
1332
  --count;
1144
1333
  }
@@ -1149,12 +1338,13 @@ jQuery.extend({
1149
1338
  } else if ( deferred !== firstParam ) {
1150
1339
  deferred.resolveWith( deferred, length ? [ firstParam ] : [] );
1151
1340
  }
1152
- return deferred.promise();
1341
+ return promise;
1153
1342
  }
1154
1343
  });
1155
1344
 
1156
1345
 
1157
1346
 
1347
+
1158
1348
  jQuery.support = (function() {
1159
1349
 
1160
1350
  var div = document.createElement( "div" ),
@@ -1179,7 +1369,7 @@ jQuery.support = (function() {
1179
1369
 
1180
1370
  // Preliminary tests
1181
1371
  div.setAttribute("className", "t");
1182
- div.innerHTML = " <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
1372
+ div.innerHTML = " <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/><nav></nav>";
1183
1373
 
1184
1374
 
1185
1375
  all = div.getElementsByTagName( "*" );
@@ -1218,12 +1408,15 @@ jQuery.support = (function() {
1218
1408
  // Make sure that element opacity exists
1219
1409
  // (IE uses filter instead)
1220
1410
  // Use a regex to work around a WebKit issue. See #5145
1221
- opacity: /^0.55$/.test( a.style.opacity ),
1411
+ opacity: /^0.55/.test( a.style.opacity ),
1222
1412
 
1223
1413
  // Verify style float existence
1224
1414
  // (IE uses styleFloat instead of cssFloat)
1225
1415
  cssFloat: !!a.style.cssFloat,
1226
1416
 
1417
+ // Make sure unknown elements (like HTML5 elems) are handled appropriately
1418
+ unknownElems: !!div.getElementsByTagName( "nav" ).length,
1419
+
1227
1420
  // Make sure that if no value is specified for a checkbox
1228
1421
  // that it defaults to "on".
1229
1422
  // (WebKit defaults to "" instead)
@@ -1236,6 +1429,9 @@ jQuery.support = (function() {
1236
1429
  // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
1237
1430
  getSetAttribute: div.className !== "t",
1238
1431
 
1432
+ // Tests for enctype support on a form(#6743)
1433
+ enctype: !!document.createElement("form").enctype,
1434
+
1239
1435
  // Will be defined later
1240
1436
  submitBubbles: true,
1241
1437
  changeBubbles: true,
@@ -1273,7 +1469,7 @@ jQuery.support = (function() {
1273
1469
  div.cloneNode( true ).fireEvent( "onclick" );
1274
1470
  }
1275
1471
 
1276
- // Check if a radio maintains it's value
1472
+ // Check if a radio maintains its value
1277
1473
  // after being appended to the DOM
1278
1474
  input = document.createElement("input");
1279
1475
  input.value = "t";
@@ -1283,7 +1479,7 @@ jQuery.support = (function() {
1283
1479
  input.setAttribute("checked", "checked");
1284
1480
  div.appendChild( input );
1285
1481
  fragment = document.createDocumentFragment();
1286
- fragment.appendChild( div.firstChild );
1482
+ fragment.appendChild( div.lastChild );
1287
1483
 
1288
1484
  // WebKit doesn't clone checked state correctly in fragments
1289
1485
  support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
@@ -1293,7 +1489,11 @@ jQuery.support = (function() {
1293
1489
  // Figure out if the W3C box model works as expected
1294
1490
  div.style.width = div.style.paddingLeft = "1px";
1295
1491
 
1296
- body = document.getElementsByTagName( "body" )[ 0 ];
1492
+ // We don't want to do body-related feature tests on frameset
1493
+ // documents, which lack a body. So we use
1494
+ // document.getElementsByTagName("body")[0], which is undefined in
1495
+ // frameset documents, while document.body isn’t. (7398)
1496
+ body = document.getElementsByTagName("body")[ 0 ];
1297
1497
  // We use our own, invisible, body unless the body is already present
1298
1498
  // in which case we use a div (#9239)
1299
1499
  testElement = document.createElement( body ? "div" : "body" );
@@ -1308,8 +1508,8 @@ jQuery.support = (function() {
1308
1508
  if ( body ) {
1309
1509
  jQuery.extend( testElementStyle, {
1310
1510
  position: "absolute",
1311
- left: "-1000px",
1312
- top: "-1000px"
1511
+ left: "-999px",
1512
+ top: "-999px"
1313
1513
  });
1314
1514
  }
1315
1515
  for ( i in testElementStyle ) {
@@ -1375,12 +1575,8 @@ jQuery.support = (function() {
1375
1575
  ( parseInt( ( document.defaultView.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0;
1376
1576
  }
1377
1577
 
1378
- // Remove the body element we added
1379
- testElement.innerHTML = "";
1380
- testElementParent.removeChild( testElement );
1381
-
1382
1578
  // Technique from Juriy Zaytsev
1383
- // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
1579
+ // http://perfectionkills.com/detecting-event-support-without-browser-sniffing/
1384
1580
  // We only care about the case where non-standard event systems
1385
1581
  // are used, namely in IE. Short-circuiting here helps us to
1386
1582
  // avoid an eval call (in setAttribute) which can cause CSP
@@ -1401,6 +1597,67 @@ jQuery.support = (function() {
1401
1597
  }
1402
1598
  }
1403
1599
 
1600
+ // Run fixed position tests at doc ready to avoid a crash
1601
+ // related to the invisible body in IE8
1602
+ jQuery(function() {
1603
+ var container, outer, inner, table, td, offsetSupport,
1604
+ conMarginTop = 1,
1605
+ ptlm = "position:absolute;top:0;left:0;width:1px;height:1px;margin:0;",
1606
+ vb = "visibility:hidden;border:0;",
1607
+ style = "style='" + ptlm + "border:5px solid #000;padding:0;'",
1608
+ html = "<div " + style + "><div></div></div>" +
1609
+ "<table " + style + " cellpadding='0' cellspacing='0'>" +
1610
+ "<tr><td></td></tr></table>";
1611
+
1612
+ // Reconstruct a container
1613
+ body = document.getElementsByTagName("body")[0];
1614
+ if ( !body ) {
1615
+ // Return for frameset docs that don't have a body
1616
+ // These tests cannot be done
1617
+ return;
1618
+ }
1619
+
1620
+ container = document.createElement("div");
1621
+ container.style.cssText = vb + "width:0;height:0;position:static;top:0;margin-top:" + conMarginTop + "px";
1622
+ body.insertBefore( container, body.firstChild );
1623
+
1624
+ // Construct a test element
1625
+ testElement = document.createElement("div");
1626
+ testElement.style.cssText = ptlm + vb;
1627
+
1628
+ testElement.innerHTML = html;
1629
+ container.appendChild( testElement );
1630
+ outer = testElement.firstChild;
1631
+ inner = outer.firstChild;
1632
+ td = outer.nextSibling.firstChild.firstChild;
1633
+
1634
+ offsetSupport = {
1635
+ doesNotAddBorder: ( inner.offsetTop !== 5 ),
1636
+ doesAddBorderForTableAndCells: ( td.offsetTop === 5 )
1637
+ };
1638
+
1639
+ inner.style.position = "fixed";
1640
+ inner.style.top = "20px";
1641
+
1642
+ // safari subtracts parent border width here which is 5px
1643
+ offsetSupport.fixedPosition = ( inner.offsetTop === 20 || inner.offsetTop === 15 );
1644
+ inner.style.position = inner.style.top = "";
1645
+
1646
+ outer.style.overflow = "hidden";
1647
+ outer.style.position = "relative";
1648
+
1649
+ offsetSupport.subtractsBorderForOverflowNotVisible = ( inner.offsetTop === -5 );
1650
+ offsetSupport.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== conMarginTop );
1651
+
1652
+ body.removeChild( container );
1653
+ testElement = container = null;
1654
+
1655
+ jQuery.extend( support, offsetSupport );
1656
+ });
1657
+
1658
+ testElement.innerHTML = "";
1659
+ testElementParent.removeChild( testElement );
1660
+
1404
1661
  // Null connected elements to avoid leaks in IE
1405
1662
  testElement = fragment = select = opt = body = marginDiv = div = input = null;
1406
1663
 
@@ -1437,7 +1694,6 @@ jQuery.extend({
1437
1694
 
1438
1695
  hasData: function( elem ) {
1439
1696
  elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
1440
-
1441
1697
  return !!elem && !isEmptyDataObject( elem );
1442
1698
  },
1443
1699
 
@@ -1446,7 +1702,7 @@ jQuery.extend({
1446
1702
  return;
1447
1703
  }
1448
1704
 
1449
- var thisCache, ret,
1705
+ var privateCache, thisCache, ret,
1450
1706
  internalKey = jQuery.expando,
1451
1707
  getByName = typeof name === "string",
1452
1708
 
@@ -1460,11 +1716,12 @@ jQuery.extend({
1460
1716
 
1461
1717
  // Only defining an ID for JS objects if its cache already exists allows
1462
1718
  // the code to shortcut on the same path as a DOM node with no cache
1463
- id = isNode ? elem[ jQuery.expando ] : elem[ jQuery.expando ] && jQuery.expando;
1719
+ id = isNode ? elem[ jQuery.expando ] : elem[ jQuery.expando ] && jQuery.expando,
1720
+ isEvents = name === "events";
1464
1721
 
1465
1722
  // Avoid doing any more work than we need to when trying to get data on an
1466
1723
  // object that has no data at all
1467
- if ( (!id || (pvt && id && (cache[ id ] && !cache[ id ][ internalKey ]))) && getByName && data === undefined ) {
1724
+ if ( (!id || !cache[id] || (!isEvents && !pvt && !cache[id].data)) && getByName && data === undefined ) {
1468
1725
  return;
1469
1726
  }
1470
1727
 
@@ -1481,9 +1738,8 @@ jQuery.extend({
1481
1738
  if ( !cache[ id ] ) {
1482
1739
  cache[ id ] = {};
1483
1740
 
1484
- // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
1485
- // metadata on plain JS objects when the object is serialized using
1486
- // JSON.stringify
1741
+ // Avoids exposing jQuery metadata on plain JS objects when the object
1742
+ // is serialized using JSON.stringify
1487
1743
  if ( !isNode ) {
1488
1744
  cache[ id ].toJSON = jQuery.noop;
1489
1745
  }
@@ -1493,34 +1749,33 @@ jQuery.extend({
1493
1749
  // shallow copied over onto the existing cache
1494
1750
  if ( typeof name === "object" || typeof name === "function" ) {
1495
1751
  if ( pvt ) {
1496
- cache[ id ][ internalKey ] = jQuery.extend(cache[ id ][ internalKey ], name);
1752
+ cache[ id ] = jQuery.extend( cache[ id ], name );
1497
1753
  } else {
1498
- cache[ id ] = jQuery.extend(cache[ id ], name);
1754
+ cache[ id ].data = jQuery.extend( cache[ id ].data, name );
1499
1755
  }
1500
1756
  }
1501
1757
 
1502
- thisCache = cache[ id ];
1758
+ privateCache = thisCache = cache[ id ];
1503
1759
 
1504
- // Internal jQuery data is stored in a separate object inside the object's data
1760
+ // jQuery data() is stored in a separate object inside the object's internal data
1505
1761
  // cache in order to avoid key collisions between internal data and user-defined
1506
- // data
1507
- if ( pvt ) {
1508
- if ( !thisCache[ internalKey ] ) {
1509
- thisCache[ internalKey ] = {};
1762
+ // data.
1763
+ if ( !pvt ) {
1764
+ if ( !thisCache.data ) {
1765
+ thisCache.data = {};
1510
1766
  }
1511
1767
 
1512
- thisCache = thisCache[ internalKey ];
1768
+ thisCache = thisCache.data;
1513
1769
  }
1514
1770
 
1515
1771
  if ( data !== undefined ) {
1516
1772
  thisCache[ jQuery.camelCase( name ) ] = data;
1517
1773
  }
1518
1774
 
1519
- // TODO: This is a hack for 1.5 ONLY. It will be removed in 1.6. Users should
1520
- // not attempt to inspect the internal events object using jQuery.data, as this
1521
- // internal data object is undocumented and subject to change.
1522
- if ( name === "events" && !thisCache[name] ) {
1523
- return thisCache[ internalKey ] && thisCache[ internalKey ].events;
1775
+ // Users should not attempt to inspect the internal events object using jQuery.data,
1776
+ // it is undocumented and subject to change. But does anyone listen? No.
1777
+ if ( isEvents && !thisCache[ name ] ) {
1778
+ return privateCache.events;
1524
1779
  }
1525
1780
 
1526
1781
  // Check for both converted-to-camel and non-converted data property names
@@ -1548,7 +1803,7 @@ jQuery.extend({
1548
1803
  return;
1549
1804
  }
1550
1805
 
1551
- var thisCache,
1806
+ var thisCache, i, l,
1552
1807
 
1553
1808
  // Reference to internal data cache key
1554
1809
  internalKey = jQuery.expando,
@@ -1569,28 +1824,41 @@ jQuery.extend({
1569
1824
 
1570
1825
  if ( name ) {
1571
1826
 
1572
- thisCache = pvt ? cache[ id ][ internalKey ] : cache[ id ];
1827
+ thisCache = pvt ? cache[ id ] : cache[ id ].data;
1573
1828
 
1574
1829
  if ( thisCache ) {
1575
1830
 
1576
- // Support interoperable removal of hyphenated or camelcased keys
1577
- if ( !thisCache[ name ] ) {
1831
+ // Support space separated names
1832
+ if ( jQuery.isArray( name ) ) {
1833
+ name = name;
1834
+ } else if ( name in thisCache ) {
1835
+ name = [ name ];
1836
+ } else {
1837
+
1838
+ // split the camel cased version by spaces
1578
1839
  name = jQuery.camelCase( name );
1840
+ if ( name in thisCache ) {
1841
+ name = [ name ];
1842
+ } else {
1843
+ name = name.split( " " );
1844
+ }
1579
1845
  }
1580
1846
 
1581
- delete thisCache[ name ];
1847
+ for ( i = 0, l = name.length; i < l; i++ ) {
1848
+ delete thisCache[ name[i] ];
1849
+ }
1582
1850
 
1583
1851
  // If there is no data left in the cache, we want to continue
1584
1852
  // and let the cache object itself get destroyed
1585
- if ( !isEmptyDataObject(thisCache) ) {
1853
+ if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) {
1586
1854
  return;
1587
1855
  }
1588
1856
  }
1589
1857
  }
1590
1858
 
1591
1859
  // See jQuery.data for more information
1592
- if ( pvt ) {
1593
- delete cache[ id ][ internalKey ];
1860
+ if ( !pvt ) {
1861
+ delete cache[ id ].data;
1594
1862
 
1595
1863
  // Don't destroy the parent cache unless the internal data object
1596
1864
  // had been the only thing left in it
@@ -1599,8 +1867,6 @@ jQuery.extend({
1599
1867
  }
1600
1868
  }
1601
1869
 
1602
- var internalCache = cache[ id ][ internalKey ];
1603
-
1604
1870
  // Browsers that fail expando deletion also refuse to delete expandos on
1605
1871
  // the window, but it will allow it on all other JS objects; other browsers
1606
1872
  // don't care
@@ -1611,23 +1877,9 @@ jQuery.extend({
1611
1877
  cache[ id ] = null;
1612
1878
  }
1613
1879
 
1614
- // We destroyed the entire user cache at once because it's faster than
1615
- // iterating through each key, but we need to continue to persist internal
1616
- // data if it existed
1617
- if ( internalCache ) {
1618
- cache[ id ] = {};
1619
- // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
1620
- // metadata on plain JS objects when the object is serialized using
1621
- // JSON.stringify
1622
- if ( !isNode ) {
1623
- cache[ id ].toJSON = jQuery.noop;
1624
- }
1625
-
1626
- cache[ id ][ internalKey ] = internalCache;
1627
-
1628
- // Otherwise, we need to eliminate the expando on the node to avoid
1880
+ // We destroyed the cache and need to eliminate the expando on the node to avoid
1629
1881
  // false lookups in the cache for entries that no longer exist
1630
- } else if ( isNode ) {
1882
+ if ( isNode ) {
1631
1883
  // IE does not allow us to delete expando properties from nodes,
1632
1884
  // nor does it have a removeAttribute function on Document nodes;
1633
1885
  // we must handle all of these cases
@@ -1662,14 +1914,15 @@ jQuery.extend({
1662
1914
 
1663
1915
  jQuery.fn.extend({
1664
1916
  data: function( key, value ) {
1665
- var data = null;
1917
+ var parts, attr, name,
1918
+ data = null;
1666
1919
 
1667
1920
  if ( typeof key === "undefined" ) {
1668
1921
  if ( this.length ) {
1669
1922
  data = jQuery.data( this[0] );
1670
1923
 
1671
- if ( this[0].nodeType === 1 ) {
1672
- var attr = this[0].attributes, name;
1924
+ if ( this[0].nodeType === 1 && !jQuery._data( this[0], "parsedAttrs" ) ) {
1925
+ attr = this[0].attributes;
1673
1926
  for ( var i = 0, l = attr.length; i < l; i++ ) {
1674
1927
  name = attr[i].name;
1675
1928
 
@@ -1679,6 +1932,7 @@ jQuery.fn.extend({
1679
1932
  dataAttr( this[0], name, data[ name ] );
1680
1933
  }
1681
1934
  }
1935
+ jQuery._data( this[0], "parsedAttrs", true );
1682
1936
  }
1683
1937
  }
1684
1938
 
@@ -1690,7 +1944,7 @@ jQuery.fn.extend({
1690
1944
  });
1691
1945
  }
1692
1946
 
1693
- var parts = key.split(".");
1947
+ parts = key.split(".");
1694
1948
  parts[1] = parts[1] ? "." + parts[1] : "";
1695
1949
 
1696
1950
  if ( value === undefined ) {
@@ -1739,7 +1993,7 @@ function dataAttr( elem, key, data ) {
1739
1993
  data = data === "true" ? true :
1740
1994
  data === "false" ? false :
1741
1995
  data === "null" ? null :
1742
- !jQuery.isNaN( data ) ? parseFloat( data ) :
1996
+ jQuery.isNumeric( data ) ? parseFloat( data ) :
1743
1997
  rbrace.test( data ) ? jQuery.parseJSON( data ) :
1744
1998
  data;
1745
1999
  } catch( e ) {}
@@ -1755,11 +2009,14 @@ function dataAttr( elem, key, data ) {
1755
2009
  return data;
1756
2010
  }
1757
2011
 
1758
- // TODO: This is a hack for 1.5 ONLY to allow objects with a single toJSON
1759
- // property to be considered empty objects; this property always exists in
1760
- // order to make sure JSON.stringify does not expose internal metadata
2012
+ // checks a cache object for emptiness
1761
2013
  function isEmptyDataObject( obj ) {
1762
2014
  for ( var name in obj ) {
2015
+
2016
+ // if the public data object is empty, the private is still empty
2017
+ if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
2018
+ continue;
2019
+ }
1763
2020
  if ( name !== "toJSON" ) {
1764
2021
  return false;
1765
2022
  }
@@ -1775,17 +2032,17 @@ function handleQueueMarkDefer( elem, type, src ) {
1775
2032
  var deferDataKey = type + "defer",
1776
2033
  queueDataKey = type + "queue",
1777
2034
  markDataKey = type + "mark",
1778
- defer = jQuery.data( elem, deferDataKey, undefined, true );
2035
+ defer = jQuery._data( elem, deferDataKey );
1779
2036
  if ( defer &&
1780
- ( src === "queue" || !jQuery.data( elem, queueDataKey, undefined, true ) ) &&
1781
- ( src === "mark" || !jQuery.data( elem, markDataKey, undefined, true ) ) ) {
2037
+ ( src === "queue" || !jQuery._data(elem, queueDataKey) ) &&
2038
+ ( src === "mark" || !jQuery._data(elem, markDataKey) ) ) {
1782
2039
  // Give room for hard-coded callbacks to fire first
1783
2040
  // and eventually mark/queue something else on the element
1784
2041
  setTimeout( function() {
1785
- if ( !jQuery.data( elem, queueDataKey, undefined, true ) &&
1786
- !jQuery.data( elem, markDataKey, undefined, true ) ) {
2042
+ if ( !jQuery._data( elem, queueDataKey ) &&
2043
+ !jQuery._data( elem, markDataKey ) ) {
1787
2044
  jQuery.removeData( elem, deferDataKey, true );
1788
- defer.resolve();
2045
+ defer.fire();
1789
2046
  }
1790
2047
  }, 0 );
1791
2048
  }
@@ -1795,8 +2052,8 @@ jQuery.extend({
1795
2052
 
1796
2053
  _mark: function( elem, type ) {
1797
2054
  if ( elem ) {
1798
- type = (type || "fx") + "mark";
1799
- jQuery.data( elem, type, (jQuery.data(elem,type,undefined,true) || 0) + 1, true );
2055
+ type = ( type || "fx" ) + "mark";
2056
+ jQuery._data( elem, type, (jQuery._data( elem, type ) || 0) + 1 );
1800
2057
  }
1801
2058
  },
1802
2059
 
@@ -1809,9 +2066,9 @@ jQuery.extend({
1809
2066
  if ( elem ) {
1810
2067
  type = type || "fx";
1811
2068
  var key = type + "mark",
1812
- count = force ? 0 : ( (jQuery.data( elem, key, undefined, true) || 1 ) - 1 );
2069
+ count = force ? 0 : ( (jQuery._data( elem, key ) || 1) - 1 );
1813
2070
  if ( count ) {
1814
- jQuery.data( elem, key, count, true );
2071
+ jQuery._data( elem, key, count );
1815
2072
  } else {
1816
2073
  jQuery.removeData( elem, key, true );
1817
2074
  handleQueueMarkDefer( elem, type, "mark" );
@@ -1820,13 +2077,15 @@ jQuery.extend({
1820
2077
  },
1821
2078
 
1822
2079
  queue: function( elem, type, data ) {
2080
+ var q;
1823
2081
  if ( elem ) {
1824
- type = (type || "fx") + "queue";
1825
- var q = jQuery.data( elem, type, undefined, true );
2082
+ type = ( type || "fx" ) + "queue";
2083
+ q = jQuery._data( elem, type );
2084
+
1826
2085
  // Speed up dequeue by getting out quickly if this is just a lookup
1827
2086
  if ( data ) {
1828
2087
  if ( !q || jQuery.isArray(data) ) {
1829
- q = jQuery.data( elem, type, jQuery.makeArray(data), true );
2088
+ q = jQuery._data( elem, type, jQuery.makeArray(data) );
1830
2089
  } else {
1831
2090
  q.push( data );
1832
2091
  }
@@ -1840,7 +2099,7 @@ jQuery.extend({
1840
2099
 
1841
2100
  var queue = jQuery.queue( elem, type ),
1842
2101
  fn = queue.shift(),
1843
- defer;
2102
+ hooks = {};
1844
2103
 
1845
2104
  // If the fx queue is dequeued, always remove the progress sentinel
1846
2105
  if ( fn === "inprogress" ) {
@@ -1851,16 +2110,17 @@ jQuery.extend({
1851
2110
  // Add a progress sentinel to prevent the fx queue from being
1852
2111
  // automatically dequeued
1853
2112
  if ( type === "fx" ) {
1854
- queue.unshift("inprogress");
2113
+ queue.unshift( "inprogress" );
1855
2114
  }
1856
2115
 
1857
- fn.call(elem, function() {
1858
- jQuery.dequeue(elem, type);
1859
- });
2116
+ jQuery._data( elem, type + ".run", hooks );
2117
+ fn.call( elem, function() {
2118
+ jQuery.dequeue( elem, type );
2119
+ }, hooks );
1860
2120
  }
1861
2121
 
1862
2122
  if ( !queue.length ) {
1863
- jQuery.removeData( elem, type + "queue", true );
2123
+ jQuery.removeData( elem, type + "queue " + type + ".run", true );
1864
2124
  handleQueueMarkDefer( elem, type, "queue" );
1865
2125
  }
1866
2126
  }
@@ -1892,14 +2152,14 @@ jQuery.fn.extend({
1892
2152
  // Based off of the plugin by Clint Helfers, with permission.
1893
2153
  // http://blindsignals.com/index.php/2009/07/jquery-delay/
1894
2154
  delay: function( time, type ) {
1895
- time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
2155
+ time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
1896
2156
  type = type || "fx";
1897
2157
 
1898
- return this.queue( type, function() {
1899
- var elem = this;
1900
- setTimeout(function() {
1901
- jQuery.dequeue( elem, type );
1902
- }, time );
2158
+ return this.queue( type, function( next, hooks ) {
2159
+ var timeout = setTimeout( next, time );
2160
+ hooks.stop = function() {
2161
+ clearTimeout( timeout );
2162
+ };
1903
2163
  });
1904
2164
  },
1905
2165
  clearQueue: function( type ) {
@@ -1930,9 +2190,9 @@ jQuery.fn.extend({
1930
2190
  if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) ||
1931
2191
  ( jQuery.data( elements[ i ], queueDataKey, undefined, true ) ||
1932
2192
  jQuery.data( elements[ i ], markDataKey, undefined, true ) ) &&
1933
- jQuery.data( elements[ i ], deferDataKey, jQuery._Deferred(), true ) )) {
2193
+ jQuery.data( elements[ i ], deferDataKey, jQuery.Callbacks( "once memory" ), true ) )) {
1934
2194
  count++;
1935
- tmp.done( resolve );
2195
+ tmp.add( resolve );
1936
2196
  }
1937
2197
  }
1938
2198
  resolve();
@@ -1950,7 +2210,8 @@ var rclass = /[\n\t\r]/g,
1950
2210
  rfocusable = /^(?:button|input|object|select|textarea)$/i,
1951
2211
  rclickable = /^a(?:rea)?$/i,
1952
2212
  rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
1953
- nodeHook, boolHook;
2213
+ getSetAttribute = jQuery.support.getSetAttribute,
2214
+ nodeHook, boolHook, fixSpecified;
1954
2215
 
1955
2216
  jQuery.fn.extend({
1956
2217
  attr: function( name, value ) {
@@ -1962,11 +2223,11 @@ jQuery.fn.extend({
1962
2223
  jQuery.removeAttr( this, name );
1963
2224
  });
1964
2225
  },
1965
-
2226
+
1966
2227
  prop: function( name, value ) {
1967
2228
  return jQuery.access( this, name, value, true, jQuery.prop );
1968
2229
  },
1969
-
2230
+
1970
2231
  removeProp: function( name ) {
1971
2232
  name = jQuery.propFix[ name ] || name;
1972
2233
  return this.each(function() {
@@ -2025,7 +2286,7 @@ jQuery.fn.extend({
2025
2286
  }
2026
2287
 
2027
2288
  if ( (value && typeof value === "string") || value === undefined ) {
2028
- classNames = (value || "").split( rspace );
2289
+ classNames = ( value || "" ).split( rspace );
2029
2290
 
2030
2291
  for ( i = 0, l = this.length; i < l; i++ ) {
2031
2292
  elem = this[ i ];
@@ -2086,8 +2347,10 @@ jQuery.fn.extend({
2086
2347
  },
2087
2348
 
2088
2349
  hasClass: function( selector ) {
2089
- var className = " " + selector + " ";
2090
- for ( var i = 0, l = this.length; i < l; i++ ) {
2350
+ var className = " " + selector + " ",
2351
+ i = 0,
2352
+ l = this.length;
2353
+ for ( ; i < l; i++ ) {
2091
2354
  if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
2092
2355
  return true;
2093
2356
  }
@@ -2097,9 +2360,9 @@ jQuery.fn.extend({
2097
2360
  },
2098
2361
 
2099
2362
  val: function( value ) {
2100
- var hooks, ret,
2363
+ var hooks, ret, isFunction,
2101
2364
  elem = this[0];
2102
-
2365
+
2103
2366
  if ( !arguments.length ) {
2104
2367
  if ( elem ) {
2105
2368
  hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ];
@@ -2110,9 +2373,9 @@ jQuery.fn.extend({
2110
2373
 
2111
2374
  ret = elem.value;
2112
2375
 
2113
- return typeof ret === "string" ?
2376
+ return typeof ret === "string" ?
2114
2377
  // handle most common string cases
2115
- ret.replace(rreturn, "") :
2378
+ ret.replace(rreturn, "") :
2116
2379
  // handle cases where value is null/undef or number
2117
2380
  ret == null ? "" : ret;
2118
2381
  }
@@ -2120,7 +2383,7 @@ jQuery.fn.extend({
2120
2383
  return undefined;
2121
2384
  }
2122
2385
 
2123
- var isFunction = jQuery.isFunction( value );
2386
+ isFunction = jQuery.isFunction( value );
2124
2387
 
2125
2388
  return this.each(function( i ) {
2126
2389
  var self = jQuery(this), val;
@@ -2168,7 +2431,7 @@ jQuery.extend({
2168
2431
  },
2169
2432
  select: {
2170
2433
  get: function( elem ) {
2171
- var value,
2434
+ var value, i, max, option,
2172
2435
  index = elem.selectedIndex,
2173
2436
  values = [],
2174
2437
  options = elem.options,
@@ -2180,8 +2443,10 @@ jQuery.extend({
2180
2443
  }
2181
2444
 
2182
2445
  // Loop through all the selected options
2183
- for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
2184
- var option = options[ i ];
2446
+ i = one ? index : 0;
2447
+ max = one ? index + 1 : options.length;
2448
+ for ( ; i < max; i++ ) {
2449
+ option = options[ i ];
2185
2450
 
2186
2451
  // Don't return options that are disabled or in a disabled optgroup
2187
2452
  if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
@@ -2233,15 +2498,11 @@ jQuery.extend({
2233
2498
  height: true,
2234
2499
  offset: true
2235
2500
  },
2236
-
2237
- attrFix: {
2238
- // Always normalize to ensure hook usage
2239
- tabindex: "tabIndex"
2240
- },
2241
-
2501
+
2242
2502
  attr: function( elem, name, value, pass ) {
2243
- var nType = elem.nodeType;
2244
-
2503
+ var ret, hooks, notxml,
2504
+ nType = elem.nodeType;
2505
+
2245
2506
  // don't get/set attributes on text, comment and attribute nodes
2246
2507
  if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
2247
2508
  return undefined;
@@ -2256,25 +2517,13 @@ jQuery.extend({
2256
2517
  return jQuery.prop( elem, name, value );
2257
2518
  }
2258
2519
 
2259
- var ret, hooks,
2260
- notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
2520
+ notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
2261
2521
 
2262
- // Normalize the name if needed
2522
+ // All attributes are lowercase
2523
+ // Grab necessary hook if one is defined
2263
2524
  if ( notxml ) {
2264
- name = jQuery.attrFix[ name ] || name;
2265
-
2266
- hooks = jQuery.attrHooks[ name ];
2267
-
2268
- if ( !hooks ) {
2269
- // Use boolHook for boolean attributes
2270
- if ( rboolean.test( name ) ) {
2271
- hooks = boolHook;
2272
-
2273
- // Use nodeHook if available( IE6/7 )
2274
- } else if ( nodeHook ) {
2275
- hooks = nodeHook;
2276
- }
2277
- }
2525
+ name = name.toLowerCase();
2526
+ hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook );
2278
2527
  }
2279
2528
 
2280
2529
  if ( value !== undefined ) {
@@ -2305,17 +2554,26 @@ jQuery.extend({
2305
2554
  }
2306
2555
  },
2307
2556
 
2308
- removeAttr: function( elem, name ) {
2309
- var propName;
2557
+ removeAttr: function( elem, value ) {
2558
+ var propName, attrNames, name, l,
2559
+ i = 0;
2560
+
2310
2561
  if ( elem.nodeType === 1 ) {
2311
- name = jQuery.attrFix[ name ] || name;
2562
+ attrNames = ( value || "" ).split( rspace );
2563
+ l = attrNames.length;
2564
+
2565
+ for ( ; i < l; i++ ) {
2566
+ name = attrNames[ i ].toLowerCase();
2567
+ propName = jQuery.propFix[ name ] || name;
2312
2568
 
2313
- jQuery.attr( elem, name, "" );
2314
- elem.removeAttribute( name );
2569
+ // See #9699 for explanation of this approach (setting first, then removal)
2570
+ jQuery.attr( elem, name, "" );
2571
+ elem.removeAttribute( getSetAttribute ? name : propName );
2315
2572
 
2316
- // Set corresponding property to false for boolean attributes
2317
- if ( rboolean.test( name ) && (propName = jQuery.propFix[ name ] || name) in elem ) {
2318
- elem[ propName ] = false;
2573
+ // Set corresponding property to false for boolean attributes
2574
+ if ( rboolean.test( name ) && propName in elem ) {
2575
+ elem[ propName ] = false;
2576
+ }
2319
2577
  }
2320
2578
  }
2321
2579
  },
@@ -2374,17 +2632,17 @@ jQuery.extend({
2374
2632
  frameborder: "frameBorder",
2375
2633
  contenteditable: "contentEditable"
2376
2634
  },
2377
-
2635
+
2378
2636
  prop: function( elem, name, value ) {
2379
- var nType = elem.nodeType;
2637
+ var ret, hooks, notxml,
2638
+ nType = elem.nodeType;
2380
2639
 
2381
2640
  // don't get/set properties on text, comment and attribute nodes
2382
2641
  if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
2383
2642
  return undefined;
2384
2643
  }
2385
2644
 
2386
- var ret, hooks,
2387
- notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
2645
+ notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
2388
2646
 
2389
2647
  if ( notxml ) {
2390
2648
  // Fix name and attach hooks
@@ -2397,7 +2655,7 @@ jQuery.extend({
2397
2655
  return ret;
2398
2656
 
2399
2657
  } else {
2400
- return (elem[ name ] = value);
2658
+ return ( elem[ name ] = value );
2401
2659
  }
2402
2660
 
2403
2661
  } else {
@@ -2409,7 +2667,7 @@ jQuery.extend({
2409
2667
  }
2410
2668
  }
2411
2669
  },
2412
-
2670
+
2413
2671
  propHooks: {
2414
2672
  tabIndex: {
2415
2673
  get: function( elem ) {
@@ -2427,16 +2685,17 @@ jQuery.extend({
2427
2685
  }
2428
2686
  });
2429
2687
 
2430
- // Add the tabindex propHook to attrHooks for back-compat
2431
- jQuery.attrHooks.tabIndex = jQuery.propHooks.tabIndex;
2688
+ // Add the tabIndex propHook to attrHooks for back-compat (different case is intentional)
2689
+ jQuery.attrHooks.tabindex = jQuery.propHooks.tabIndex;
2432
2690
 
2433
2691
  // Hook for boolean attributes
2434
2692
  boolHook = {
2435
2693
  get: function( elem, name ) {
2436
2694
  // Align boolean attributes with corresponding properties
2437
2695
  // Fall back to attribute presence where some booleans are not supported
2438
- var attrNode;
2439
- return jQuery.prop( elem, name ) === true || ( attrNode = elem.getAttributeNode( name ) ) && attrNode.nodeValue !== false ?
2696
+ var attrNode,
2697
+ property = jQuery.prop( elem, name );
2698
+ return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ?
2440
2699
  name.toLowerCase() :
2441
2700
  undefined;
2442
2701
  },
@@ -2461,16 +2720,20 @@ boolHook = {
2461
2720
  };
2462
2721
 
2463
2722
  // IE6/7 do not support getting/setting some attributes with get/setAttribute
2464
- if ( !jQuery.support.getSetAttribute ) {
2465
-
2723
+ if ( !getSetAttribute ) {
2724
+
2725
+ fixSpecified = {
2726
+ name: true,
2727
+ id: true
2728
+ };
2729
+
2466
2730
  // Use this for any attribute in IE6/7
2467
2731
  // This fixes almost every IE6/7 issue
2468
2732
  nodeHook = jQuery.valHooks.button = {
2469
2733
  get: function( elem, name ) {
2470
2734
  var ret;
2471
2735
  ret = elem.getAttributeNode( name );
2472
- // Return undefined if nodeValue is empty string
2473
- return ret && ret.nodeValue !== "" ?
2736
+ return ret && ( fixSpecified[ name ] ? ret.nodeValue !== "" : ret.specified ) ?
2474
2737
  ret.nodeValue :
2475
2738
  undefined;
2476
2739
  },
@@ -2481,10 +2744,13 @@ if ( !jQuery.support.getSetAttribute ) {
2481
2744
  ret = document.createAttribute( name );
2482
2745
  elem.setAttributeNode( ret );
2483
2746
  }
2484
- return (ret.nodeValue = value + "");
2747
+ return ( ret.nodeValue = value + "" );
2485
2748
  }
2486
2749
  };
2487
2750
 
2751
+ // Apply the nodeHook to tabindex
2752
+ jQuery.attrHooks.tabindex.set = nodeHook.set;
2753
+
2488
2754
  // Set width and height to auto instead of 0 on empty string( Bug #8150 )
2489
2755
  // This is for removals
2490
2756
  jQuery.each([ "width", "height" ], function( i, name ) {
@@ -2497,6 +2763,18 @@ if ( !jQuery.support.getSetAttribute ) {
2497
2763
  }
2498
2764
  });
2499
2765
  });
2766
+
2767
+ // Set contenteditable to false on removals(#10429)
2768
+ // Setting to empty string throws an error as an invalid value
2769
+ jQuery.attrHooks.contenteditable = {
2770
+ get: nodeHook.get,
2771
+ set: function( elem, value, name ) {
2772
+ if ( value === "" ) {
2773
+ value = "false";
2774
+ }
2775
+ nodeHook.set( elem, value, name );
2776
+ }
2777
+ };
2500
2778
  }
2501
2779
 
2502
2780
 
@@ -2520,7 +2798,7 @@ if ( !jQuery.support.style ) {
2520
2798
  return elem.style.cssText.toLowerCase() || undefined;
2521
2799
  },
2522
2800
  set: function( elem, value ) {
2523
- return (elem.style.cssText = "" + value);
2801
+ return ( elem.style.cssText = "" + value );
2524
2802
  }
2525
2803
  };
2526
2804
  }
@@ -2545,6 +2823,11 @@ if ( !jQuery.support.optSelected ) {
2545
2823
  });
2546
2824
  }
2547
2825
 
2826
+ // IE6/7 call enctype encoding
2827
+ if ( !jQuery.support.enctype ) {
2828
+ jQuery.propFix.enctype = "encoding";
2829
+ }
2830
+
2548
2831
  // Radios and checkboxes getter/setter
2549
2832
  if ( !jQuery.support.checkOn ) {
2550
2833
  jQuery.each([ "radio", "checkbox" ], function() {
@@ -2560,7 +2843,7 @@ jQuery.each([ "radio", "checkbox" ], function() {
2560
2843
  jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], {
2561
2844
  set: function( elem, value ) {
2562
2845
  if ( jQuery.isArray( value ) ) {
2563
- return (elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0);
2846
+ return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
2564
2847
  }
2565
2848
  }
2566
2849
  });
@@ -2574,111 +2857,122 @@ var rnamespaces = /\.(.*)$/,
2574
2857
  rperiod = /\./g,
2575
2858
  rspaces = / /g,
2576
2859
  rescape = /[^\w\s.|`]/g,
2577
- fcleanup = function( nm ) {
2578
- return nm.replace(rescape, "\\$&");
2860
+ rtypenamespace = /^([^\.]*)?(?:\.(.+))?$/,
2861
+ rhoverHack = /\bhover(\.\S+)?/,
2862
+ rkeyEvent = /^key/,
2863
+ rmouseEvent = /^(?:mouse|contextmenu)|click/,
2864
+ rquickIs = /^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,
2865
+ quickParse = function( selector ) {
2866
+ var quick = rquickIs.exec( selector );
2867
+ if ( quick ) {
2868
+ // 0 1 2 3
2869
+ // [ _, tag, id, class ]
2870
+ quick[1] = ( quick[1] || "" ).toLowerCase();
2871
+ quick[3] = quick[3] && new RegExp( "(?:^|\\s)" + quick[3] + "(?:\\s|$)" );
2872
+ }
2873
+ return quick;
2874
+ },
2875
+ quickIs = function( elem, m ) {
2876
+ return (
2877
+ (!m[1] || elem.nodeName.toLowerCase() === m[1]) &&
2878
+ (!m[2] || elem.id === m[2]) &&
2879
+ (!m[3] || m[3].test( elem.className ))
2880
+ );
2881
+ },
2882
+ hoverHack = function( events ) {
2883
+ return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" );
2579
2884
  };
2580
2885
 
2581
2886
  /*
2582
- * A number of helper functions used for managing events.
2583
- * Many of the ideas behind this code originated from
2584
- * Dean Edwards' addEvent library.
2887
+ * Helper functions for managing events -- not part of the public interface.
2888
+ * Props to Dean Edwards' addEvent library for many of the ideas.
2585
2889
  */
2586
2890
  jQuery.event = {
2587
2891
 
2588
- // Bind an event to an element
2589
- // Original by Dean Edwards
2590
- add: function( elem, types, handler, data ) {
2591
- if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
2592
- return;
2593
- }
2892
+ add: function( elem, types, handler, data, selector ) {
2594
2893
 
2595
- if ( handler === false ) {
2596
- handler = returnFalse;
2597
- } else if ( !handler ) {
2598
- // Fixes bug #7229. Fix recommended by jdalton
2894
+ var elemData, eventHandle, events,
2895
+ t, tns, type, namespaces, handleObj,
2896
+ handleObjIn, quick, handlers, special;
2897
+
2898
+ // Don't attach events to noData or text/comment nodes (allow plain objects tho)
2899
+ if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) {
2599
2900
  return;
2600
2901
  }
2601
2902
 
2602
- var handleObjIn, handleObj;
2603
-
2903
+ // Caller can pass in an object of custom data in lieu of the handler
2604
2904
  if ( handler.handler ) {
2605
2905
  handleObjIn = handler;
2606
2906
  handler = handleObjIn.handler;
2607
2907
  }
2608
2908
 
2609
- // Make sure that the function being executed has a unique ID
2909
+ // Make sure that the handler has a unique ID, used to find/remove it later
2610
2910
  if ( !handler.guid ) {
2611
2911
  handler.guid = jQuery.guid++;
2612
2912
  }
2613
2913
 
2614
- // Init the element's event structure
2615
- var elemData = jQuery._data( elem );
2616
-
2617
- // If no elemData is found then we must be trying to bind to one of the
2618
- // banned noData elements
2619
- if ( !elemData ) {
2620
- return;
2621
- }
2622
-
2623
- var events = elemData.events,
2624
- eventHandle = elemData.handle;
2625
-
2914
+ // Init the element's event structure and main handler, if this is the first
2915
+ events = elemData.events;
2626
2916
  if ( !events ) {
2627
2917
  elemData.events = events = {};
2628
2918
  }
2629
-
2919
+ eventHandle = elemData.handle;
2630
2920
  if ( !eventHandle ) {
2631
2921
  elemData.handle = eventHandle = function( e ) {
2632
2922
  // Discard the second event of a jQuery.event.trigger() and
2633
2923
  // when an event is called after a page has unloaded
2634
2924
  return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ?
2635
- jQuery.event.handle.apply( eventHandle.elem, arguments ) :
2925
+ jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
2636
2926
  undefined;
2637
2927
  };
2928
+ // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
2929
+ eventHandle.elem = elem;
2638
2930
  }
2639
2931
 
2640
- // Add elem as a property of the handle function
2641
- // This is to prevent a memory leak with non-native events in IE.
2642
- eventHandle.elem = elem;
2643
-
2644
2932
  // Handle multiple events separated by a space
2645
2933
  // jQuery(...).bind("mouseover mouseout", fn);
2646
- types = types.split(" ");
2934
+ types = hoverHack(types).split( " " );
2935
+ for ( t = 0; t < types.length; t++ ) {
2647
2936
 
2648
- var type, i = 0, namespaces;
2937
+ tns = rtypenamespace.exec( types[t] ) || [];
2938
+ type = tns[1];
2939
+ namespaces = ( tns[2] || "" ).split( "." ).sort();
2649
2940
 
2650
- while ( (type = types[ i++ ]) ) {
2651
- handleObj = handleObjIn ?
2652
- jQuery.extend({}, handleObjIn) :
2653
- { handler: handler, data: data };
2941
+ // If event changes its type, use the special event handlers for the changed type
2942
+ special = jQuery.event.special[ type ] || {};
2654
2943
 
2655
- // Namespaced event handlers
2656
- if ( type.indexOf(".") > -1 ) {
2657
- namespaces = type.split(".");
2658
- type = namespaces.shift();
2659
- handleObj.namespace = namespaces.slice(0).sort().join(".");
2944
+ // If selector defined, determine special event api type, otherwise given type
2945
+ type = ( selector ? special.delegateType : special.bindType ) || type;
2660
2946
 
2661
- } else {
2662
- namespaces = [];
2663
- handleObj.namespace = "";
2664
- }
2947
+ // Update special based on newly reset type
2948
+ special = jQuery.event.special[ type ] || {};
2665
2949
 
2666
- handleObj.type = type;
2667
- if ( !handleObj.guid ) {
2668
- handleObj.guid = handler.guid;
2669
- }
2950
+ // handleObj is passed to all event handlers
2951
+ handleObj = jQuery.extend({
2952
+ type: type,
2953
+ origType: tns[1],
2954
+ data: data,
2955
+ handler: handler,
2956
+ guid: handler.guid,
2957
+ selector: selector,
2958
+ namespace: namespaces.join(".")
2959
+ }, handleObjIn );
2670
2960
 
2671
- // Get the current list of functions bound to this event
2672
- var handlers = events[ type ],
2673
- special = jQuery.event.special[ type ] || {};
2961
+ // Delegated event; pre-analyze selector so it's processed quickly on event dispatch
2962
+ if ( selector ) {
2963
+ handleObj.quick = quickParse( selector );
2964
+ if ( !handleObj.quick && jQuery.expr.match.POS.test( selector ) ) {
2965
+ handleObj.isPositional = true;
2966
+ }
2967
+ }
2674
2968
 
2675
- // Init the event handler queue
2969
+ // Init the event handler queue if we're the first
2970
+ handlers = events[ type ];
2676
2971
  if ( !handlers ) {
2677
2972
  handlers = events[ type ] = [];
2973
+ handlers.delegateCount = 0;
2678
2974
 
2679
- // Check for a special event handler
2680
- // Only use addEventListener/attachEvent if the special
2681
- // events handler returns false
2975
+ // Only use addEventListener/attachEvent if the special events handler returns false
2682
2976
  if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
2683
2977
  // Bind the global event handler to the element
2684
2978
  if ( elem.addEventListener ) {
@@ -2698,10 +2992,14 @@ jQuery.event = {
2698
2992
  }
2699
2993
  }
2700
2994
 
2701
- // Add the function to the element's handler list
2702
- handlers.push( handleObj );
2995
+ // Add to the element's handler list, delegates in front
2996
+ if ( selector ) {
2997
+ handlers.splice( handlers.delegateCount++, 0, handleObj );
2998
+ } else {
2999
+ handlers.push( handleObj );
3000
+ }
2703
3001
 
2704
- // Keep track of which events have been used, for event optimization
3002
+ // Keep track of which events have ever been used, for event optimization
2705
3003
  jQuery.event.global[ type ] = true;
2706
3004
  }
2707
3005
 
@@ -2712,129 +3010,87 @@ jQuery.event = {
2712
3010
  global: {},
2713
3011
 
2714
3012
  // Detach an event or set of events from an element
2715
- remove: function( elem, types, handler, pos ) {
2716
- // don't do events on text and comment nodes
2717
- if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
2718
- return;
2719
- }
2720
-
2721
- if ( handler === false ) {
2722
- handler = returnFalse;
2723
- }
3013
+ remove: function( elem, types, handler, selector ) {
2724
3014
 
2725
- var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType,
2726
- elemData = jQuery.hasData( elem ) && jQuery._data( elem ),
2727
- events = elemData && elemData.events;
3015
+ var elemData = jQuery.hasData( elem ) && jQuery._data( elem ),
3016
+ t, tns, type, namespaces, origCount,
3017
+ j, events, special, handle, eventType, handleObj;
2728
3018
 
2729
- if ( !elemData || !events ) {
3019
+ if ( !elemData || !(events = elemData.events) ) {
2730
3020
  return;
2731
3021
  }
2732
3022
 
2733
- // types is actually an event object here
2734
- if ( types && types.type ) {
2735
- handler = types.handler;
2736
- types = types.type;
2737
- }
2738
-
2739
- // Unbind all events for the element
2740
- if ( !types || typeof types === "string" && types.charAt(0) === "." ) {
2741
- types = types || "";
3023
+ // Once for each type.namespace in types; type may be omitted
3024
+ types = hoverHack( types || "" ).split(" ");
3025
+ for ( t = 0; t < types.length; t++ ) {
3026
+ tns = rtypenamespace.exec( types[t] ) || [];
3027
+ type = tns[1];
3028
+ namespaces = tns[2];
2742
3029
 
2743
- for ( type in events ) {
2744
- jQuery.event.remove( elem, type + types );
2745
- }
2746
-
2747
- return;
2748
- }
2749
-
2750
- // Handle multiple events separated by a space
2751
- // jQuery(...).unbind("mouseover mouseout", fn);
2752
- types = types.split(" ");
2753
-
2754
- while ( (type = types[ i++ ]) ) {
2755
- origType = type;
2756
- handleObj = null;
2757
- all = type.indexOf(".") < 0;
2758
- namespaces = [];
2759
-
2760
- if ( !all ) {
2761
- // Namespaced event handlers
2762
- namespaces = type.split(".");
2763
- type = namespaces.shift();
2764
-
2765
- namespace = new RegExp("(^|\\.)" +
2766
- jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)");
2767
- }
2768
-
2769
- eventType = events[ type ];
2770
-
2771
- if ( !eventType ) {
2772
- continue;
2773
- }
2774
-
2775
- if ( !handler ) {
2776
- for ( j = 0; j < eventType.length; j++ ) {
2777
- handleObj = eventType[ j ];
2778
-
2779
- if ( all || namespace.test( handleObj.namespace ) ) {
2780
- jQuery.event.remove( elem, origType, handleObj.handler, j );
2781
- eventType.splice( j--, 1 );
2782
- }
3030
+ // Unbind all events (on this namespace, if provided) for the element
3031
+ if ( !type ) {
3032
+ namespaces = namespaces? "." + namespaces : "";
3033
+ for ( j in events ) {
3034
+ jQuery.event.remove( elem, j + namespaces, handler, selector );
2783
3035
  }
2784
-
2785
- continue;
3036
+ return;
2786
3037
  }
2787
3038
 
2788
3039
  special = jQuery.event.special[ type ] || {};
3040
+ type = ( selector? special.delegateType : special.bindType ) || type;
3041
+ eventType = events[ type ] || [];
3042
+ origCount = eventType.length;
3043
+ namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.)?") + "(\\.|$)") : null;
2789
3044
 
2790
- for ( j = pos || 0; j < eventType.length; j++ ) {
2791
- handleObj = eventType[ j ];
3045
+ // Only need to loop for special events or selective removal
3046
+ if ( handler || namespaces || selector || special.remove ) {
3047
+ for ( j = 0; j < eventType.length; j++ ) {
3048
+ handleObj = eventType[ j ];
2792
3049
 
2793
- if ( handler.guid === handleObj.guid ) {
2794
- // remove the given handler for the given type
2795
- if ( all || namespace.test( handleObj.namespace ) ) {
2796
- if ( pos == null ) {
2797
- eventType.splice( j--, 1 );
2798
- }
3050
+ if ( !handler || handler.guid === handleObj.guid ) {
3051
+ if ( !namespaces || namespaces.test( handleObj.namespace ) ) {
3052
+ if ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) {
3053
+ eventType.splice( j--, 1 );
2799
3054
 
2800
- if ( special.remove ) {
2801
- special.remove.call( elem, handleObj );
3055
+ if ( handleObj.selector ) {
3056
+ eventType.delegateCount--;
3057
+ }
3058
+ if ( special.remove ) {
3059
+ special.remove.call( elem, handleObj );
3060
+ }
3061
+ }
2802
3062
  }
2803
3063
  }
2804
-
2805
- if ( pos != null ) {
2806
- break;
2807
- }
2808
3064
  }
3065
+ } else {
3066
+ // Removing all events
3067
+ eventType.length = 0;
2809
3068
  }
2810
3069
 
2811
- // remove generic event handler if no more handlers exist
2812
- if ( eventType.length === 0 || pos != null && eventType.length === 1 ) {
3070
+ // Remove generic event handler if we removed something and no more handlers exist
3071
+ // (avoids potential for endless recursion during removal of special event handlers)
3072
+ if ( eventType.length === 0 && origCount !== eventType.length ) {
2813
3073
  if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
2814
3074
  jQuery.removeEvent( elem, type, elemData.handle );
2815
3075
  }
2816
3076
 
2817
- ret = null;
2818
3077
  delete events[ type ];
2819
3078
  }
2820
3079
  }
2821
3080
 
2822
3081
  // Remove the expando if it's no longer used
2823
3082
  if ( jQuery.isEmptyObject( events ) ) {
2824
- var handle = elemData.handle;
3083
+ handle = elemData.handle;
2825
3084
  if ( handle ) {
2826
3085
  handle.elem = null;
2827
3086
  }
2828
3087
 
2829
- delete elemData.events;
2830
- delete elemData.handle;
2831
-
2832
- if ( jQuery.isEmptyObject( elemData ) ) {
2833
- jQuery.removeData( elem, undefined, true );
2834
- }
3088
+ // removeData also checks for emptiness and clears the expando if empty
3089
+ // so use it instead of delete
3090
+ jQuery.removeData( elem, [ "events", "handle" ], true );
2835
3091
  }
2836
3092
  },
2837
-
3093
+
2838
3094
  // Events that are safe to short-circuit if no handlers are attached.
2839
3095
  // Native DOM events should not be added, they may have inline handlers.
2840
3096
  customEvent: {
@@ -2844,18 +3100,23 @@ jQuery.event = {
2844
3100
  },
2845
3101
 
2846
3102
  trigger: function( event, data, elem, onlyHandlers ) {
3103
+ // Don't do events on text and comment nodes
3104
+ if ( elem && (elem.nodeType === 3 || elem.nodeType === 8) ) {
3105
+ return;
3106
+ }
3107
+
2847
3108
  // Event object or event type
2848
3109
  var type = event.type || event,
2849
3110
  namespaces = [],
2850
- exclusive;
3111
+ cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType;
2851
3112
 
2852
- if ( type.indexOf("!") >= 0 ) {
3113
+ if ( type.indexOf( "!" ) >= 0 ) {
2853
3114
  // Exclusive events trigger only for the exact event (no namespaces)
2854
3115
  type = type.slice(0, -1);
2855
3116
  exclusive = true;
2856
3117
  }
2857
3118
 
2858
- if ( type.indexOf(".") >= 0 ) {
3119
+ if ( type.indexOf( "." ) >= 0 ) {
2859
3120
  // Namespaced trigger; create a regexp to match event type in handle()
2860
3121
  namespaces = type.split(".");
2861
3122
  type = namespaces.shift();
@@ -2877,230 +3138,300 @@ jQuery.event = {
2877
3138
  new jQuery.Event( type );
2878
3139
 
2879
3140
  event.type = type;
3141
+ event.isTrigger = true;
2880
3142
  event.exclusive = exclusive;
2881
- event.namespace = namespaces.join(".");
2882
- event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)");
2883
-
3143
+ event.namespace = namespaces.join( "." );
3144
+ event.namespace_re = event.namespace? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)") : null;
3145
+ ontype = type.indexOf( ":" ) < 0 ? "on" + type : "";
3146
+
2884
3147
  // triggerHandler() and global events don't bubble or run the default action
2885
3148
  if ( onlyHandlers || !elem ) {
2886
3149
  event.preventDefault();
2887
- event.stopPropagation();
2888
3150
  }
2889
3151
 
2890
3152
  // Handle a global trigger
2891
3153
  if ( !elem ) {
3154
+
2892
3155
  // TODO: Stop taunting the data cache; remove global events and always attach to document
2893
- jQuery.each( jQuery.cache, function() {
2894
- // internalKey variable is just used to make it easier to find
2895
- // and potentially change this stuff later; currently it just
2896
- // points to jQuery.expando
2897
- var internalKey = jQuery.expando,
2898
- internalCache = this[ internalKey ];
2899
- if ( internalCache && internalCache.events && internalCache.events[ type ] ) {
2900
- jQuery.event.trigger( event, data, internalCache.handle.elem );
3156
+ cache = jQuery.cache;
3157
+ for ( i in cache ) {
3158
+ if ( cache[ i ].events && cache[ i ].events[ type ] ) {
3159
+ jQuery.event.trigger( event, data, cache[ i ].handle.elem, true );
2901
3160
  }
2902
- });
2903
- return;
2904
- }
2905
-
2906
- // Don't do events on text and comment nodes
2907
- if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
3161
+ }
2908
3162
  return;
2909
3163
  }
2910
3164
 
2911
3165
  // Clean up the event in case it is being reused
2912
3166
  event.result = undefined;
2913
- event.target = elem;
3167
+ if ( !event.target ) {
3168
+ event.target = elem;
3169
+ }
2914
3170
 
2915
3171
  // Clone any incoming data and prepend the event, creating the handler arg list
2916
3172
  data = data != null ? jQuery.makeArray( data ) : [];
2917
3173
  data.unshift( event );
2918
3174
 
2919
- var cur = elem,
2920
- // IE doesn't like method names with a colon (#3533, #8272)
2921
- ontype = type.indexOf(":") < 0 ? "on" + type : "";
3175
+ // Allow special events to draw outside the lines
3176
+ special = jQuery.event.special[ type ] || {};
3177
+ if ( special.trigger && special.trigger.apply( elem, data ) === false ) {
3178
+ return;
3179
+ }
3180
+
3181
+ // Determine event propagation path in advance, per W3C events spec (#9951)
3182
+ // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
3183
+ eventPath = [[ elem, special.bindType || type ]];
3184
+ if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
3185
+
3186
+ bubbleType = special.delegateType || type;
3187
+ old = null;
3188
+ for ( cur = elem.parentNode; cur; cur = cur.parentNode ) {
3189
+ eventPath.push([ cur, bubbleType ]);
3190
+ old = cur;
3191
+ }
3192
+
3193
+ // Only add window if we got to document (e.g., not plain obj or detached DOM)
3194
+ if ( old && old === elem.ownerDocument ) {
3195
+ eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]);
3196
+ }
3197
+ }
3198
+
3199
+ // Fire handlers on the event path
3200
+ for ( i = 0; i < eventPath.length; i++ ) {
2922
3201
 
2923
- // Fire event on the current element, then bubble up the DOM tree
2924
- do {
2925
- var handle = jQuery._data( cur, "handle" );
3202
+ cur = eventPath[i][0];
3203
+ event.type = eventPath[i][1];
2926
3204
 
2927
- event.currentTarget = cur;
3205
+ handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" );
2928
3206
  if ( handle ) {
2929
3207
  handle.apply( cur, data );
2930
3208
  }
2931
-
2932
- // Trigger an inline bound script
2933
- if ( ontype && jQuery.acceptData( cur ) && cur[ ontype ] && cur[ ontype ].apply( cur, data ) === false ) {
2934
- event.result = false;
2935
- event.preventDefault();
3209
+ handle = ontype && cur[ ontype ];
3210
+ if ( handle && jQuery.acceptData( cur ) ) {
3211
+ handle.apply( cur, data );
2936
3212
  }
2937
3213
 
2938
- // Bubble up to document, then to window
2939
- cur = cur.parentNode || cur.ownerDocument || cur === event.target.ownerDocument && window;
2940
- } while ( cur && !event.isPropagationStopped() );
3214
+ if ( event.isPropagationStopped() ) {
3215
+ break;
3216
+ }
3217
+ }
3218
+ event.type = type;
2941
3219
 
2942
3220
  // If nobody prevented the default action, do it now
2943
3221
  if ( !event.isDefaultPrevented() ) {
2944
- var old,
2945
- special = jQuery.event.special[ type ] || {};
2946
3222
 
2947
- if ( (!special._default || special._default.call( elem.ownerDocument, event ) === false) &&
3223
+ if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) &&
2948
3224
  !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) {
2949
3225
 
2950
3226
  // Call a native DOM method on the target with the same name name as the event.
2951
- // Can't use an .isFunction)() check here because IE6/7 fails that test.
2952
- // IE<9 dies on focus to hidden element (#1486), may want to revisit a try/catch.
2953
- try {
2954
- if ( ontype && elem[ type ] ) {
2955
- // Don't re-trigger an onFOO event when we call its FOO() method
2956
- old = elem[ ontype ];
3227
+ // Can't use an .isFunction() check here because IE6/7 fails that test.
3228
+ // Don't do default actions on window, that's where global variables be (#6170)
3229
+ // IE<9 dies on focus/blur to hidden element (#1486)
3230
+ if ( ontype && elem[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) && !jQuery.isWindow( elem ) ) {
2957
3231
 
2958
- if ( old ) {
2959
- elem[ ontype ] = null;
2960
- }
3232
+ // Don't re-trigger an onFOO event when we call its FOO() method
3233
+ old = elem[ ontype ];
2961
3234
 
2962
- jQuery.event.triggered = type;
2963
- elem[ type ]();
3235
+ if ( old ) {
3236
+ elem[ ontype ] = null;
2964
3237
  }
2965
- } catch ( ieError ) {}
2966
3238
 
2967
- if ( old ) {
2968
- elem[ ontype ] = old;
2969
- }
3239
+ // Prevent re-triggering of the same event, since we already bubbled it above
3240
+ jQuery.event.triggered = type;
3241
+ elem[ type ]();
3242
+ jQuery.event.triggered = undefined;
2970
3243
 
2971
- jQuery.event.triggered = undefined;
3244
+ if ( old ) {
3245
+ elem[ ontype ] = old;
3246
+ }
3247
+ }
2972
3248
  }
2973
3249
  }
2974
-
3250
+
2975
3251
  return event.result;
2976
3252
  },
2977
3253
 
2978
- handle: function( event ) {
3254
+ dispatch: function( event ) {
3255
+
3256
+ // Make a writable jQuery.Event from the native event object
2979
3257
  event = jQuery.event.fix( event || window.event );
2980
- // Snapshot the handlers list since a called handler may add/remove events.
2981
- var handlers = ((jQuery._data( this, "events" ) || {})[ event.type ] || []).slice(0),
3258
+
3259
+ var handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []),
3260
+ delegateCount = handlers.delegateCount,
3261
+ args = [].slice.call( arguments, 0 ),
2982
3262
  run_all = !event.exclusive && !event.namespace,
2983
- args = Array.prototype.slice.call( arguments, 0 );
3263
+ specialHandle = ( jQuery.event.special[ event.type ] || {} ).handle,
3264
+ handlerQueue = [],
3265
+ i, j, cur, ret, selMatch, matched, matches, handleObj, sel, hit, related;
2984
3266
 
2985
- // Use the fix-ed Event rather than the (read-only) native event
3267
+ // Use the fix-ed jQuery.Event rather than the (read-only) native event
2986
3268
  args[0] = event;
2987
- event.currentTarget = this;
2988
-
2989
- for ( var j = 0, l = handlers.length; j < l; j++ ) {
2990
- var handleObj = handlers[ j ];
2991
-
2992
- // Triggered event must 1) be non-exclusive and have no namespace, or
2993
- // 2) have namespace(s) a subset or equal to those in the bound event.
2994
- if ( run_all || event.namespace_re.test( handleObj.namespace ) ) {
2995
- // Pass in a reference to the handler function itself
2996
- // So that we can later remove it
2997
- event.handler = handleObj.handler;
2998
- event.data = handleObj.data;
2999
- event.handleObj = handleObj;
3000
-
3001
- var ret = handleObj.handler.apply( this, args );
3002
-
3003
- if ( ret !== undefined ) {
3004
- event.result = ret;
3005
- if ( ret === false ) {
3006
- event.preventDefault();
3007
- event.stopPropagation();
3269
+ event.delegateTarget = this;
3270
+
3271
+ // Determine handlers that should run if there are delegated events
3272
+ // Avoid disabled elements in IE (#6911) and non-left-click bubbling in Firefox (#3861)
3273
+ if ( delegateCount && !event.target.disabled && !(event.button && event.type === "click") ) {
3274
+
3275
+ for ( cur = event.target; cur != this; cur = cur.parentNode || this ) {
3276
+ selMatch = {};
3277
+ matches = [];
3278
+ for ( i = 0; i < delegateCount; i++ ) {
3279
+ handleObj = handlers[ i ];
3280
+ sel = handleObj.selector;
3281
+ hit = selMatch[ sel ];
3282
+
3283
+ if ( handleObj.isPositional ) {
3284
+ // Since .is() does not work for positionals; see http://jsfiddle.net/eJ4yd/3/
3285
+ hit = ( hit || (selMatch[ sel ] = jQuery( sel )) ).index( cur ) >= 0;
3286
+ } else if ( hit === undefined ) {
3287
+ hit = selMatch[ sel ] = ( handleObj.quick ? quickIs( cur, handleObj.quick ) : jQuery( cur ).is( sel ) );
3288
+ }
3289
+ if ( hit ) {
3290
+ matches.push( handleObj );
3008
3291
  }
3009
3292
  }
3293
+ if ( matches.length ) {
3294
+ handlerQueue.push({ elem: cur, matches: matches });
3295
+ }
3296
+ }
3297
+ }
3010
3298
 
3011
- if ( event.isImmediatePropagationStopped() ) {
3012
- break;
3299
+ // Add the remaining (directly-bound) handlers
3300
+ if ( handlers.length > delegateCount ) {
3301
+ handlerQueue.push({ elem: this, matches: handlers.slice( delegateCount ) });
3302
+ }
3303
+
3304
+ // Run delegates first; they may want to stop propagation beneath us
3305
+ for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) {
3306
+ matched = handlerQueue[ i ];
3307
+ event.currentTarget = matched.elem;
3308
+
3309
+ for ( j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++ ) {
3310
+ handleObj = matched.matches[ j ];
3311
+
3312
+ // Triggered event must either 1) be non-exclusive and have no namespace, or
3313
+ // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
3314
+ if ( run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) {
3315
+
3316
+ event.data = handleObj.data;
3317
+ event.handleObj = handleObj;
3318
+
3319
+ ret = ( specialHandle || handleObj.handler ).apply( matched.elem, args );
3320
+
3321
+ if ( ret !== undefined ) {
3322
+ event.result = ret;
3323
+ if ( ret === false ) {
3324
+ event.preventDefault();
3325
+ event.stopPropagation();
3326
+ }
3327
+ }
3013
3328
  }
3014
3329
  }
3015
3330
  }
3331
+
3016
3332
  return event.result;
3017
3333
  },
3018
3334
 
3019
- props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
3335
+ // Includes some event props shared by KeyEvent and MouseEvent
3336
+ // *** attrChange attrName relatedNode srcElement are not normalized, non-W3C, deprecated, will be removed in 1.8 ***
3337
+ props: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
3338
+
3339
+ fixHooks: {},
3340
+
3341
+ keyHooks: {
3342
+ props: "char charCode key keyCode".split(" "),
3343
+ filter: function( event, original ) {
3344
+
3345
+ // Add which for key events
3346
+ if ( event.which == null ) {
3347
+ event.which = original.charCode != null ? original.charCode : original.keyCode;
3348
+ }
3349
+
3350
+ return event;
3351
+ }
3352
+ },
3353
+
3354
+ mouseHooks: {
3355
+ props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement wheelDelta".split(" "),
3356
+ filter: function( event, original ) {
3357
+ var eventDoc, doc, body,
3358
+ button = original.button,
3359
+ fromElement = original.fromElement;
3360
+
3361
+ // Calculate pageX/Y if missing and clientX/Y available
3362
+ if ( event.pageX == null && original.clientX != null ) {
3363
+ eventDoc = event.target.ownerDocument || document;
3364
+ doc = eventDoc.documentElement;
3365
+ body = eventDoc.body;
3366
+
3367
+ event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
3368
+ event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
3369
+ }
3370
+
3371
+ // Add relatedTarget, if necessary
3372
+ if ( !event.relatedTarget && fromElement ) {
3373
+ event.relatedTarget = fromElement === event.target ? original.toElement : fromElement;
3374
+ }
3375
+
3376
+ // Add which for click: 1 === left; 2 === middle; 3 === right
3377
+ // Note: button is not normalized, so don't use it
3378
+ if ( !event.which && button !== undefined ) {
3379
+ event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
3380
+ }
3381
+
3382
+ return event;
3383
+ }
3384
+ },
3020
3385
 
3021
3386
  fix: function( event ) {
3022
3387
  if ( event[ jQuery.expando ] ) {
3023
3388
  return event;
3024
3389
  }
3025
3390
 
3026
- // store a copy of the original event object
3027
- // and "clone" to set read-only properties
3028
- var originalEvent = event;
3391
+ // Create a writable copy of the event object and normalize some properties
3392
+ var i, prop,
3393
+ originalEvent = event,
3394
+ fixHook = jQuery.event.fixHooks[ event.type ] || {},
3395
+ copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
3396
+
3029
3397
  event = jQuery.Event( originalEvent );
3030
3398
 
3031
- for ( var i = this.props.length, prop; i; ) {
3032
- prop = this.props[ --i ];
3399
+ for ( i = copy.length; i; ) {
3400
+ prop = copy[ --i ];
3033
3401
  event[ prop ] = originalEvent[ prop ];
3034
3402
  }
3035
3403
 
3036
- // Fix target property, if necessary
3404
+ // Fix target property, if necessary (#1925, IE 6/7/8 & Safari2)
3037
3405
  if ( !event.target ) {
3038
- // Fixes #1925 where srcElement might not be defined either
3039
- event.target = event.srcElement || document;
3406
+ event.target = originalEvent.srcElement || document;
3040
3407
  }
3041
3408
 
3042
- // check if target is a textnode (safari)
3409
+ // Target should not be a text node (#504, Safari)
3043
3410
  if ( event.target.nodeType === 3 ) {
3044
3411
  event.target = event.target.parentNode;
3045
3412
  }
3046
3413
 
3047
- // Add relatedTarget, if necessary
3048
- if ( !event.relatedTarget && event.fromElement ) {
3049
- event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement;
3050
- }
3051
-
3052
- // Calculate pageX/Y if missing and clientX/Y available
3053
- if ( event.pageX == null && event.clientX != null ) {
3054
- var eventDocument = event.target.ownerDocument || document,
3055
- doc = eventDocument.documentElement,
3056
- body = eventDocument.body;
3057
-
3058
- event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
3059
- event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
3060
- }
3061
-
3062
- // Add which for key events
3063
- if ( event.which == null && (event.charCode != null || event.keyCode != null) ) {
3064
- event.which = event.charCode != null ? event.charCode : event.keyCode;
3065
- }
3066
-
3067
- // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
3068
- if ( !event.metaKey && event.ctrlKey ) {
3414
+ // For mouse/key events; add metaKey if it's not there (#3368, IE6/7/8)
3415
+ if ( event.metaKey === undefined ) {
3069
3416
  event.metaKey = event.ctrlKey;
3070
3417
  }
3071
3418
 
3072
- // Add which for click: 1 === left; 2 === middle; 3 === right
3073
- // Note: button is not normalized, so don't use it
3074
- if ( !event.which && event.button !== undefined ) {
3075
- event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
3076
- }
3077
-
3078
- return event;
3419
+ return fixHook.filter? fixHook.filter( event, originalEvent ) : event;
3079
3420
  },
3080
3421
 
3081
- // Deprecated, use jQuery.guid instead
3082
- guid: 1E8,
3083
-
3084
- // Deprecated, use jQuery.proxy instead
3085
- proxy: jQuery.proxy,
3086
-
3087
3422
  special: {
3088
3423
  ready: {
3089
3424
  // Make sure the ready event is setup
3090
- setup: jQuery.bindReady,
3091
- teardown: jQuery.noop
3425
+ setup: jQuery.bindReady
3092
3426
  },
3093
3427
 
3094
- live: {
3095
- add: function( handleObj ) {
3096
- jQuery.event.add( this,
3097
- liveConvert( handleObj.origType, handleObj.selector ),
3098
- jQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) );
3099
- },
3100
-
3101
- remove: function( handleObj ) {
3102
- jQuery.event.remove( this, liveConvert( handleObj.origType, handleObj.selector ), handleObj );
3103
- }
3428
+ focus: {
3429
+ delegateType: "focusin",
3430
+ noBubble: true
3431
+ },
3432
+ blur: {
3433
+ delegateType: "focusout",
3434
+ noBubble: true
3104
3435
  },
3105
3436
 
3106
3437
  beforeunload: {
@@ -3117,9 +3448,35 @@ jQuery.event = {
3117
3448
  }
3118
3449
  }
3119
3450
  }
3451
+ },
3452
+
3453
+ simulate: function( type, elem, event, bubble ) {
3454
+ // Piggyback on a donor event to simulate a different one.
3455
+ // Fake originalEvent to avoid donor's stopPropagation, but if the
3456
+ // simulated event prevents default then we do the same on the donor.
3457
+ var e = jQuery.extend(
3458
+ new jQuery.Event(),
3459
+ event,
3460
+ { type: type,
3461
+ isSimulated: true,
3462
+ originalEvent: {}
3463
+ }
3464
+ );
3465
+ if ( bubble ) {
3466
+ jQuery.event.trigger( e, null, elem );
3467
+ } else {
3468
+ jQuery.event.dispatch.call( elem, e );
3469
+ }
3470
+ if ( e.isDefaultPrevented() ) {
3471
+ event.preventDefault();
3472
+ }
3120
3473
  }
3121
3474
  };
3122
3475
 
3476
+ // Some plugins are using, but it's undocumented/deprecated and will be removed.
3477
+ // The 1.7 special event interface should provide all the hooks needed now.
3478
+ jQuery.event.handle = jQuery.event.dispatch;
3479
+
3123
3480
  jQuery.removeEvent = document.removeEventListener ?
3124
3481
  function( elem, type, handle ) {
3125
3482
  if ( elem.removeEventListener ) {
@@ -3134,7 +3491,7 @@ jQuery.removeEvent = document.removeEventListener ?
3134
3491
 
3135
3492
  jQuery.Event = function( src, props ) {
3136
3493
  // Allow instantiation without the 'new' keyword
3137
- if ( !this.preventDefault ) {
3494
+ if ( !(this instanceof jQuery.Event) ) {
3138
3495
  return new jQuery.Event( src, props );
3139
3496
  }
3140
3497
 
@@ -3145,8 +3502,8 @@ jQuery.Event = function( src, props ) {
3145
3502
 
3146
3503
  // Events bubbling up the document may have been marked as prevented
3147
3504
  // by a handler lower down the tree; reflect the correct value.
3148
- this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false ||
3149
- src.getPreventDefault && src.getPreventDefault()) ? returnTrue : returnFalse;
3505
+ this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false ||
3506
+ src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse;
3150
3507
 
3151
3508
  // Event type
3152
3509
  } else {
@@ -3158,9 +3515,8 @@ jQuery.Event = function( src, props ) {
3158
3515
  jQuery.extend( this, props );
3159
3516
  }
3160
3517
 
3161
- // timeStamp is buggy for some events on Firefox(#3843)
3162
- // So we won't rely on the native value
3163
- this.timeStamp = jQuery.now();
3518
+ // Create a timestamp if incoming event doesn't have one
3519
+ this.timeStamp = src && src.timeStamp || jQuery.now();
3164
3520
 
3165
3521
  // Mark it as fixed
3166
3522
  this[ jQuery.expando ] = true;
@@ -3216,216 +3572,132 @@ jQuery.Event.prototype = {
3216
3572
  isImmediatePropagationStopped: returnFalse
3217
3573
  };
3218
3574
 
3219
- // Checks if an event happened on an element within another element
3220
- // Used in jQuery.event.special.mouseenter and mouseleave handlers
3221
- var withinElement = function( event ) {
3222
-
3223
- // Check if mouse(over|out) are still within the same parent element
3224
- var related = event.relatedTarget,
3225
- inside = false,
3226
- eventType = event.type;
3227
-
3228
- event.type = event.data;
3229
-
3230
- if ( related !== this ) {
3231
-
3232
- if ( related ) {
3233
- inside = jQuery.contains( this, related );
3234
- }
3235
-
3236
- if ( !inside ) {
3237
-
3238
- jQuery.event.handle.apply( this, arguments );
3239
-
3240
- event.type = eventType;
3241
- }
3242
- }
3243
- },
3244
-
3245
- // In case of event delegation, we only need to rename the event.type,
3246
- // liveHandler will take care of the rest.
3247
- delegate = function( event ) {
3248
- event.type = event.data;
3249
- jQuery.event.handle.apply( this, arguments );
3250
- };
3251
-
3252
- // Create mouseenter and mouseleave events
3575
+ // Create mouseenter/leave events using mouseover/out and event-time checks
3253
3576
  jQuery.each({
3254
3577
  mouseenter: "mouseover",
3255
3578
  mouseleave: "mouseout"
3256
3579
  }, function( orig, fix ) {
3257
- jQuery.event.special[ orig ] = {
3258
- setup: function( data ) {
3259
- jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig );
3260
- },
3261
- teardown: function( data ) {
3262
- jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement );
3580
+ jQuery.event.special[ orig ] = jQuery.event.special[ fix ] = {
3581
+ delegateType: fix,
3582
+ bindType: fix,
3583
+
3584
+ handle: function( event ) {
3585
+ var target = this,
3586
+ related = event.relatedTarget,
3587
+ handleObj = event.handleObj,
3588
+ selector = handleObj.selector,
3589
+ oldType, ret;
3590
+
3591
+ // For a real mouseover/out, always call the handler; for
3592
+ // mousenter/leave call the handler if related is outside the target.
3593
+ // NB: No relatedTarget if the mouse left/entered the browser window
3594
+ if ( !related || handleObj.origType === event.type || (related !== target && !jQuery.contains( target, related )) ) {
3595
+ oldType = event.type;
3596
+ event.type = handleObj.origType;
3597
+ ret = handleObj.handler.apply( this, arguments );
3598
+ event.type = oldType;
3599
+ }
3600
+ return ret;
3263
3601
  }
3264
3602
  };
3265
3603
  });
3266
3604
 
3267
- // submit delegation
3605
+ // IE submit delegation
3268
3606
  if ( !jQuery.support.submitBubbles ) {
3269
3607
 
3270
3608
  jQuery.event.special.submit = {
3271
- setup: function( data, namespaces ) {
3272
- if ( !jQuery.nodeName( this, "form" ) ) {
3273
- jQuery.event.add(this, "click.specialSubmit", function( e ) {
3274
- // Avoid triggering error on non-existent type attribute in IE VML (#7071)
3275
- var elem = e.target,
3276
- type = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.type : "";
3277
-
3278
- if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
3279
- trigger( "submit", this, arguments );
3280
- }
3281
- });
3282
-
3283
- jQuery.event.add(this, "keypress.specialSubmit", function( e ) {
3284
- var elem = e.target,
3285
- type = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.type : "";
3609
+ setup: function() {
3610
+ // Only need this for delegated form submit events
3611
+ if ( jQuery.nodeName( this, "form" ) ) {
3612
+ return false;
3613
+ }
3286
3614
 
3287
- if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
3288
- trigger( "submit", this, arguments );
3289
- }
3290
- });
3615
+ // Lazy-add a submit handler when a descendant form may potentially be submitted
3616
+ jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
3617
+ // Node name check avoids a VML-related crash in IE (#9807)
3618
+ var elem = e.target,
3619
+ form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined;
3620
+ if ( form && !form._submit_attached ) {
3621
+ jQuery.event.add( form, "submit._submit", function( event ) {
3622
+ // Form was submitted, bubble the event up the tree
3623
+ if ( this.parentNode ) {
3624
+ jQuery.event.simulate( "submit", this.parentNode, event, true );
3625
+ }
3626
+ });
3627
+ form._submit_attached = true;
3628
+ }
3629
+ });
3630
+ // return undefined since we don't need an event listener
3631
+ },
3291
3632
 
3292
- } else {
3633
+ teardown: function() {
3634
+ // Only need this for delegated form submit events
3635
+ if ( jQuery.nodeName( this, "form" ) ) {
3293
3636
  return false;
3294
3637
  }
3295
- },
3296
3638
 
3297
- teardown: function( namespaces ) {
3298
- jQuery.event.remove( this, ".specialSubmit" );
3639
+ // Remove delegated handlers; cleanData eventually reaps submit handlers attached above
3640
+ jQuery.event.remove( this, "._submit" );
3299
3641
  }
3300
3642
  };
3301
-
3302
3643
  }
3303
3644
 
3304
- // change delegation, happens here so we have bind.
3645
+ // IE change delegation and checkbox/radio fix
3305
3646
  if ( !jQuery.support.changeBubbles ) {
3306
3647
 
3307
- var changeFilters,
3308
-
3309
- getVal = function( elem ) {
3310
- var type = jQuery.nodeName( elem, "input" ) ? elem.type : "",
3311
- val = elem.value;
3312
-
3313
- if ( type === "radio" || type === "checkbox" ) {
3314
- val = elem.checked;
3315
-
3316
- } else if ( type === "select-multiple" ) {
3317
- val = elem.selectedIndex > -1 ?
3318
- jQuery.map( elem.options, function( elem ) {
3319
- return elem.selected;
3320
- }).join("-") :
3321
- "";
3322
-
3323
- } else if ( jQuery.nodeName( elem, "select" ) ) {
3324
- val = elem.selectedIndex;
3325
- }
3326
-
3327
- return val;
3328
- },
3329
-
3330
- testChange = function testChange( e ) {
3331
- var elem = e.target, data, val;
3332
-
3333
- if ( !rformElems.test( elem.nodeName ) || elem.readOnly ) {
3334
- return;
3335
- }
3336
-
3337
- data = jQuery._data( elem, "_change_data" );
3338
- val = getVal(elem);
3339
-
3340
- // the current data will be also retrieved by beforeactivate
3341
- if ( e.type !== "focusout" || elem.type !== "radio" ) {
3342
- jQuery._data( elem, "_change_data", val );
3343
- }
3344
-
3345
- if ( data === undefined || val === data ) {
3346
- return;
3347
- }
3348
-
3349
- if ( data != null || val ) {
3350
- e.type = "change";
3351
- e.liveFired = undefined;
3352
- jQuery.event.trigger( e, arguments[1], elem );
3353
- }
3354
- };
3355
-
3356
3648
  jQuery.event.special.change = {
3357
- filters: {
3358
- focusout: testChange,
3359
-
3360
- beforedeactivate: testChange,
3361
3649
 
3362
- click: function( e ) {
3363
- var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : "";
3650
+ setup: function() {
3364
3651
 
3365
- if ( type === "radio" || type === "checkbox" || jQuery.nodeName( elem, "select" ) ) {
3366
- testChange.call( this, e );
3652
+ if ( rformElems.test( this.nodeName ) ) {
3653
+ // IE doesn't fire change on a check/radio until blur; trigger it on click
3654
+ // after a propertychange. Eat the blur-change in special.change.handle.
3655
+ // This still fires onchange a second time for check/radio after blur.
3656
+ if ( this.type === "checkbox" || this.type === "radio" ) {
3657
+ jQuery.event.add( this, "propertychange._change", function( event ) {
3658
+ if ( event.originalEvent.propertyName === "checked" ) {
3659
+ this._just_changed = true;
3660
+ }
3661
+ });
3662
+ jQuery.event.add( this, "click._change", function( event ) {
3663
+ if ( this._just_changed ) {
3664
+ this._just_changed = false;
3665
+ jQuery.event.simulate( "change", this, event, true );
3666
+ }
3667
+ });
3367
3668
  }
3368
- },
3369
-
3370
- // Change has to be called before submit
3371
- // Keydown will be called before keypress, which is used in submit-event delegation
3372
- keydown: function( e ) {
3373
- var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : "";
3669
+ return false;
3670
+ }
3671
+ // Delegated event; lazy-add a change handler on descendant inputs
3672
+ jQuery.event.add( this, "beforeactivate._change", function( e ) {
3673
+ var elem = e.target;
3374
3674
 
3375
- if ( (e.keyCode === 13 && !jQuery.nodeName( elem, "textarea" ) ) ||
3376
- (e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
3377
- type === "select-multiple" ) {
3378
- testChange.call( this, e );
3675
+ if ( rformElems.test( elem.nodeName ) && !elem._change_attached ) {
3676
+ jQuery.event.add( elem, "change._change", function( event ) {
3677
+ if ( this.parentNode && !event.isSimulated ) {
3678
+ jQuery.event.simulate( "change", this.parentNode, event, true );
3679
+ }
3680
+ });
3681
+ elem._change_attached = true;
3379
3682
  }
3380
- },
3381
-
3382
- // Beforeactivate happens also before the previous element is blurred
3383
- // with this event you can't trigger a change event, but you can store
3384
- // information
3385
- beforeactivate: function( e ) {
3386
- var elem = e.target;
3387
- jQuery._data( elem, "_change_data", getVal(elem) );
3388
- }
3683
+ });
3389
3684
  },
3390
3685
 
3391
- setup: function( data, namespaces ) {
3392
- if ( this.type === "file" ) {
3393
- return false;
3394
- }
3686
+ handle: function( event ) {
3687
+ var elem = event.target;
3395
3688
 
3396
- for ( var type in changeFilters ) {
3397
- jQuery.event.add( this, type + ".specialChange", changeFilters[type] );
3689
+ // Swallow native change events from checkbox/radio, we already triggered them above
3690
+ if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) {
3691
+ return event.handleObj.handler.apply( this, arguments );
3398
3692
  }
3399
-
3400
- return rformElems.test( this.nodeName );
3401
3693
  },
3402
3694
 
3403
- teardown: function( namespaces ) {
3404
- jQuery.event.remove( this, ".specialChange" );
3695
+ teardown: function() {
3696
+ jQuery.event.remove( this, "._change" );
3405
3697
 
3406
3698
  return rformElems.test( this.nodeName );
3407
3699
  }
3408
3700
  };
3409
-
3410
- changeFilters = jQuery.event.special.change.filters;
3411
-
3412
- // Handle when the input is .focus()'d
3413
- changeFilters.focus = changeFilters.beforeactivate;
3414
- }
3415
-
3416
- function trigger( type, elem, args ) {
3417
- // Piggyback on a donor event to simulate a different one.
3418
- // Fake originalEvent to avoid donor's stopPropagation, but if the
3419
- // simulated event prevents default then we do the same on the donor.
3420
- // Don't pass args or remember liveFired; they apply to the donor event.
3421
- var event = jQuery.extend( {}, args[ 0 ] );
3422
- event.type = type;
3423
- event.originalEvent = {};
3424
- event.liveFired = undefined;
3425
- jQuery.event.handle.call( elem, event );
3426
- if ( event.isDefaultPrevented() ) {
3427
- args[ 0 ].preventDefault();
3428
- }
3429
3701
  }
3430
3702
 
3431
3703
  // Create "bubbling" focus and blur events
@@ -3433,7 +3705,10 @@ if ( !jQuery.support.focusinBubbles ) {
3433
3705
  jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
3434
3706
 
3435
3707
  // Attach a single capturing handler while someone wants focusin/focusout
3436
- var attaches = 0;
3708
+ var attaches = 0,
3709
+ handler = function( event ) {
3710
+ jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
3711
+ };
3437
3712
 
3438
3713
  jQuery.event.special[ fix ] = {
3439
3714
  setup: function() {
@@ -3447,89 +3722,120 @@ if ( !jQuery.support.focusinBubbles ) {
3447
3722
  }
3448
3723
  }
3449
3724
  };
3725
+ });
3726
+ }
3450
3727
 
3451
- function handler( donor ) {
3452
- // Donor event is always a native one; fix it and switch its type.
3453
- // Let focusin/out handler cancel the donor focus/blur event.
3454
- var e = jQuery.event.fix( donor );
3455
- e.type = fix;
3456
- e.originalEvent = {};
3457
- jQuery.event.trigger( e, null, e.target );
3458
- if ( e.isDefaultPrevented() ) {
3459
- donor.preventDefault();
3460
- }
3461
- }
3462
- });
3463
- }
3464
-
3465
- jQuery.each(["bind", "one"], function( i, name ) {
3466
- jQuery.fn[ name ] = function( type, data, fn ) {
3467
- var handler;
3468
-
3469
- // Handle object literals
3470
- if ( typeof type === "object" ) {
3471
- for ( var key in type ) {
3472
- this[ name ](key, data, type[key], fn);
3473
- }
3474
- return this;
3475
- }
3476
-
3477
- if ( arguments.length === 2 || data === false ) {
3478
- fn = data;
3479
- data = undefined;
3480
- }
3481
-
3482
- if ( name === "one" ) {
3483
- handler = function( event ) {
3484
- jQuery( this ).unbind( event, handler );
3485
- return fn.apply( this, arguments );
3486
- };
3487
- handler.guid = fn.guid || jQuery.guid++;
3488
- } else {
3489
- handler = fn;
3490
- }
3491
-
3492
- if ( type === "unload" && name !== "one" ) {
3493
- this.one( type, data, fn );
3728
+ jQuery.fn.extend({
3494
3729
 
3495
- } else {
3496
- for ( var i = 0, l = this.length; i < l; i++ ) {
3497
- jQuery.event.add( this[i], type, handler, data );
3730
+ on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
3731
+ var origFn, type;
3732
+
3733
+ // Types can be a map of types/handlers
3734
+ if ( typeof types === "object" ) {
3735
+ // ( types-Object, selector, data )
3736
+ if ( typeof selector !== "string" ) {
3737
+ // ( types-Object, data )
3738
+ data = selector;
3739
+ selector = undefined;
3740
+ }
3741
+ for ( type in types ) {
3742
+ this.on( type, selector, data, types[ type ], one );
3498
3743
  }
3744
+ return this;
3499
3745
  }
3500
3746
 
3501
- return this;
3502
- };
3503
- });
3504
-
3505
- jQuery.fn.extend({
3506
- unbind: function( type, fn ) {
3507
- // Handle object literals
3508
- if ( typeof type === "object" && !type.preventDefault ) {
3509
- for ( var key in type ) {
3510
- this.unbind(key, type[key]);
3747
+ if ( data == null && fn == null ) {
3748
+ // ( types, fn )
3749
+ fn = selector;
3750
+ data = selector = undefined;
3751
+ } else if ( fn == null ) {
3752
+ if ( typeof selector === "string" ) {
3753
+ // ( types, selector, fn )
3754
+ fn = data;
3755
+ data = undefined;
3756
+ } else {
3757
+ // ( types, data, fn )
3758
+ fn = data;
3759
+ data = selector;
3760
+ selector = undefined;
3511
3761
  }
3762
+ }
3763
+ if ( fn === false ) {
3764
+ fn = returnFalse;
3765
+ } else if ( !fn ) {
3766
+ return this;
3767
+ }
3512
3768
 
3513
- } else {
3514
- for ( var i = 0, l = this.length; i < l; i++ ) {
3515
- jQuery.event.remove( this[i], type, fn );
3769
+ if ( one === 1 ) {
3770
+ origFn = fn;
3771
+ fn = function( event ) {
3772
+ // Can use an empty set, since event contains the info
3773
+ jQuery().off( event );
3774
+ return origFn.apply( this, arguments );
3775
+ };
3776
+ // Use same guid so caller can remove using origFn
3777
+ fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
3778
+ }
3779
+ return this.each( function() {
3780
+ jQuery.event.add( this, types, fn, data, selector );
3781
+ });
3782
+ },
3783
+ one: function( types, selector, data, fn ) {
3784
+ return this.on.call( this, types, selector, data, fn, 1 );
3785
+ },
3786
+ off: function( types, selector, fn ) {
3787
+ if ( types && types.preventDefault && types.handleObj ) {
3788
+ // ( event ) dispatched jQuery.Event
3789
+ var handleObj = types.handleObj;
3790
+ jQuery( types.delegateTarget ).off(
3791
+ handleObj.namespace? handleObj.type + "." + handleObj.namespace : handleObj.type,
3792
+ handleObj.selector,
3793
+ handleObj.handler
3794
+ );
3795
+ return this;
3796
+ }
3797
+ if ( typeof types === "object" ) {
3798
+ // ( types-object [, selector] )
3799
+ for ( var type in types ) {
3800
+ this.off( type, selector, types[ type ] );
3516
3801
  }
3802
+ return this;
3803
+ }
3804
+ if ( selector === false || typeof selector === "function" ) {
3805
+ // ( types [, fn] )
3806
+ fn = selector;
3807
+ selector = undefined;
3517
3808
  }
3809
+ if ( fn === false ) {
3810
+ fn = returnFalse;
3811
+ }
3812
+ return this.each(function() {
3813
+ jQuery.event.remove( this, types, fn, selector );
3814
+ });
3815
+ },
3816
+
3817
+ bind: function( types, data, fn ) {
3818
+ return this.on( types, null, data, fn );
3819
+ },
3820
+ unbind: function( types, fn ) {
3821
+ return this.off( types, null, fn );
3822
+ },
3518
3823
 
3824
+ live: function( types, data, fn ) {
3825
+ jQuery( this.context ).on( types, this.selector, data, fn );
3826
+ return this;
3827
+ },
3828
+ die: function( types, fn ) {
3829
+ jQuery( this.context ).off( types, this.selector || "**", fn );
3519
3830
  return this;
3520
3831
  },
3521
3832
 
3522
3833
  delegate: function( selector, types, data, fn ) {
3523
- return this.live( types, data, fn, selector );
3834
+ return this.on( types, selector, data, fn );
3524
3835
  },
3525
-
3526
3836
  undelegate: function( selector, types, fn ) {
3527
- if ( arguments.length === 0 ) {
3528
- return this.unbind( "live" );
3529
-
3530
- } else {
3531
- return this.die( types, null, fn, selector );
3532
- }
3837
+ // ( namespace ) or ( selector, types [, fn] )
3838
+ return arguments.length == 1? this.off( selector, "**" ) : this.off( types, selector, fn );
3533
3839
  },
3534
3840
 
3535
3841
  trigger: function( type, data ) {
@@ -3537,7 +3843,6 @@ jQuery.fn.extend({
3537
3843
  jQuery.event.trigger( type, data, this );
3538
3844
  });
3539
3845
  },
3540
-
3541
3846
  triggerHandler: function( type, data ) {
3542
3847
  if ( this[0] ) {
3543
3848
  return jQuery.event.trigger( type, data, this[0], true );
@@ -3551,8 +3856,8 @@ jQuery.fn.extend({
3551
3856
  i = 0,
3552
3857
  toggler = function( event ) {
3553
3858
  // Figure out which function to execute
3554
- var lastToggle = ( jQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i;
3555
- jQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 );
3859
+ var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
3860
+ jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );
3556
3861
 
3557
3862
  // Make sure that clicks stop
3558
3863
  event.preventDefault();
@@ -3575,178 +3880,9 @@ jQuery.fn.extend({
3575
3880
  }
3576
3881
  });
3577
3882
 
3578
- var liveMap = {
3579
- focus: "focusin",
3580
- blur: "focusout",
3581
- mouseenter: "mouseover",
3582
- mouseleave: "mouseout"
3583
- };
3584
-
3585
- jQuery.each(["live", "die"], function( i, name ) {
3586
- jQuery.fn[ name ] = function( types, data, fn, origSelector /* Internal Use Only */ ) {
3587
- var type, i = 0, match, namespaces, preType,
3588
- selector = origSelector || this.selector,
3589
- context = origSelector ? this : jQuery( this.context );
3590
-
3591
- if ( typeof types === "object" && !types.preventDefault ) {
3592
- for ( var key in types ) {
3593
- context[ name ]( key, data, types[key], selector );
3594
- }
3595
-
3596
- return this;
3597
- }
3598
-
3599
- if ( name === "die" && !types &&
3600
- origSelector && origSelector.charAt(0) === "." ) {
3601
-
3602
- context.unbind( origSelector );
3603
-
3604
- return this;
3605
- }
3606
-
3607
- if ( data === false || jQuery.isFunction( data ) ) {
3608
- fn = data || returnFalse;
3609
- data = undefined;
3610
- }
3611
-
3612
- types = (types || "").split(" ");
3613
-
3614
- while ( (type = types[ i++ ]) != null ) {
3615
- match = rnamespaces.exec( type );
3616
- namespaces = "";
3617
-
3618
- if ( match ) {
3619
- namespaces = match[0];
3620
- type = type.replace( rnamespaces, "" );
3621
- }
3622
-
3623
- if ( type === "hover" ) {
3624
- types.push( "mouseenter" + namespaces, "mouseleave" + namespaces );
3625
- continue;
3626
- }
3627
-
3628
- preType = type;
3629
-
3630
- if ( liveMap[ type ] ) {
3631
- types.push( liveMap[ type ] + namespaces );
3632
- type = type + namespaces;
3633
-
3634
- } else {
3635
- type = (liveMap[ type ] || type) + namespaces;
3636
- }
3637
-
3638
- if ( name === "live" ) {
3639
- // bind live handler
3640
- for ( var j = 0, l = context.length; j < l; j++ ) {
3641
- jQuery.event.add( context[j], "live." + liveConvert( type, selector ),
3642
- { data: data, selector: selector, handler: fn, origType: type, origHandler: fn, preType: preType } );
3643
- }
3644
-
3645
- } else {
3646
- // unbind live handler
3647
- context.unbind( "live." + liveConvert( type, selector ), fn );
3648
- }
3649
- }
3650
-
3651
- return this;
3652
- };
3653
- });
3654
-
3655
- function liveHandler( event ) {
3656
- var stop, maxLevel, related, match, handleObj, elem, j, i, l, data, close, namespace, ret,
3657
- elems = [],
3658
- selectors = [],
3659
- events = jQuery._data( this, "events" );
3660
-
3661
- // Make sure we avoid non-left-click bubbling in Firefox (#3861) and disabled elements in IE (#6911)
3662
- if ( event.liveFired === this || !events || !events.live || event.target.disabled || event.button && event.type === "click" ) {
3663
- return;
3664
- }
3665
-
3666
- if ( event.namespace ) {
3667
- namespace = new RegExp("(^|\\.)" + event.namespace.split(".").join("\\.(?:.*\\.)?") + "(\\.|$)");
3668
- }
3669
-
3670
- event.liveFired = this;
3671
-
3672
- var live = events.live.slice(0);
3673
-
3674
- for ( j = 0; j < live.length; j++ ) {
3675
- handleObj = live[j];
3676
-
3677
- if ( handleObj.origType.replace( rnamespaces, "" ) === event.type ) {
3678
- selectors.push( handleObj.selector );
3679
-
3680
- } else {
3681
- live.splice( j--, 1 );
3682
- }
3683
- }
3684
-
3685
- match = jQuery( event.target ).closest( selectors, event.currentTarget );
3686
-
3687
- for ( i = 0, l = match.length; i < l; i++ ) {
3688
- close = match[i];
3689
-
3690
- for ( j = 0; j < live.length; j++ ) {
3691
- handleObj = live[j];
3692
-
3693
- if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) && !close.elem.disabled ) {
3694
- elem = close.elem;
3695
- related = null;
3696
-
3697
- // Those two events require additional checking
3698
- if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) {
3699
- event.type = handleObj.preType;
3700
- related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0];
3701
-
3702
- // Make sure not to accidentally match a child element with the same selector
3703
- if ( related && jQuery.contains( elem, related ) ) {
3704
- related = elem;
3705
- }
3706
- }
3707
-
3708
- if ( !related || related !== elem ) {
3709
- elems.push({ elem: elem, handleObj: handleObj, level: close.level });
3710
- }
3711
- }
3712
- }
3713
- }
3714
-
3715
- for ( i = 0, l = elems.length; i < l; i++ ) {
3716
- match = elems[i];
3717
-
3718
- if ( maxLevel && match.level > maxLevel ) {
3719
- break;
3720
- }
3721
-
3722
- event.currentTarget = match.elem;
3723
- event.data = match.handleObj.data;
3724
- event.handleObj = match.handleObj;
3725
-
3726
- ret = match.handleObj.origHandler.apply( match.elem, arguments );
3727
-
3728
- if ( ret === false || event.isPropagationStopped() ) {
3729
- maxLevel = match.level;
3730
-
3731
- if ( ret === false ) {
3732
- stop = false;
3733
- }
3734
- if ( event.isImmediatePropagationStopped() ) {
3735
- break;
3736
- }
3737
- }
3738
- }
3739
-
3740
- return stop;
3741
- }
3742
-
3743
- function liveConvert( type, selector ) {
3744
- return (type && type !== "*" ? type + "." : "") + selector.replace(rperiod, "`").replace(rspaces, "&");
3745
- }
3746
-
3747
3883
  jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
3748
3884
  "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
3749
- "change select submit keydown keypress keyup error").split(" "), function( i, name ) {
3885
+ "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
3750
3886
 
3751
3887
  // Handle event binding
3752
3888
  jQuery.fn[ name ] = function( data, fn ) {
@@ -3763,6 +3899,14 @@ jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblcl
3763
3899
  if ( jQuery.attrFn ) {
3764
3900
  jQuery.attrFn[ name ] = true;
3765
3901
  }
3902
+
3903
+ if ( rkeyEvent.test( name ) ) {
3904
+ jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks;
3905
+ }
3906
+
3907
+ if ( rmouseEvent.test( name ) ) {
3908
+ jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks;
3909
+ }
3766
3910
  });
3767
3911
 
3768
3912
 
@@ -3776,11 +3920,13 @@ jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblcl
3776
3920
  (function(){
3777
3921
 
3778
3922
  var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
3923
+ expando = "sizcache" + (Math.random() + '').replace('.', ''),
3779
3924
  done = 0,
3780
3925
  toString = Object.prototype.toString,
3781
3926
  hasDuplicate = false,
3782
3927
  baseHasDuplicate = true,
3783
3928
  rBackslash = /\\/g,
3929
+ rReturn = /\r\n/g,
3784
3930
  rNonWord = /\W/;
3785
3931
 
3786
3932
  // Here we check if the JavaScript engine is using some sort of
@@ -3832,7 +3978,7 @@ var Sizzle = function( selector, context, results, seed ) {
3832
3978
  if ( parts.length > 1 && origPOS.exec( selector ) ) {
3833
3979
 
3834
3980
  if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
3835
- set = posProcess( parts[0] + parts[1], context );
3981
+ set = posProcess( parts[0] + parts[1], context, seed );
3836
3982
 
3837
3983
  } else {
3838
3984
  set = Expr.relative[ parts[0] ] ?
@@ -3846,7 +3992,7 @@ var Sizzle = function( selector, context, results, seed ) {
3846
3992
  selector += parts.shift();
3847
3993
  }
3848
3994
 
3849
- set = posProcess( selector, set );
3995
+ set = posProcess( selector, set, seed );
3850
3996
  }
3851
3997
  }
3852
3998
 
@@ -3965,18 +4111,17 @@ Sizzle.matchesSelector = function( node, expr ) {
3965
4111
  };
3966
4112
 
3967
4113
  Sizzle.find = function( expr, context, isXML ) {
3968
- var set;
4114
+ var set, i, len, match, type, left;
3969
4115
 
3970
4116
  if ( !expr ) {
3971
4117
  return [];
3972
4118
  }
3973
4119
 
3974
- for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
3975
- var match,
3976
- type = Expr.order[i];
4120
+ for ( i = 0, len = Expr.order.length; i < len; i++ ) {
4121
+ type = Expr.order[i];
3977
4122
 
3978
4123
  if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
3979
- var left = match[1];
4124
+ left = match[1];
3980
4125
  match.splice( 1, 1 );
3981
4126
 
3982
4127
  if ( left.substr( left.length - 1 ) !== "\\" ) {
@@ -4002,17 +4147,18 @@ Sizzle.find = function( expr, context, isXML ) {
4002
4147
 
4003
4148
  Sizzle.filter = function( expr, set, inplace, not ) {
4004
4149
  var match, anyFound,
4150
+ type, found, item, filter, left,
4151
+ i, pass,
4005
4152
  old = expr,
4006
4153
  result = [],
4007
4154
  curLoop = set,
4008
4155
  isXMLFilter = set && set[0] && Sizzle.isXML( set[0] );
4009
4156
 
4010
4157
  while ( expr && set.length ) {
4011
- for ( var type in Expr.filter ) {
4158
+ for ( type in Expr.filter ) {
4012
4159
  if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
4013
- var found, item,
4014
- filter = Expr.filter[ type ],
4015
- left = match[1];
4160
+ filter = Expr.filter[ type ];
4161
+ left = match[1];
4016
4162
 
4017
4163
  anyFound = false;
4018
4164
 
@@ -4038,10 +4184,10 @@ Sizzle.filter = function( expr, set, inplace, not ) {
4038
4184
  }
4039
4185
 
4040
4186
  if ( match ) {
4041
- for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
4187
+ for ( i = 0; (item = curLoop[i]) != null; i++ ) {
4042
4188
  if ( item ) {
4043
4189
  found = filter( item, match, i, curLoop );
4044
- var pass = not ^ !!found;
4190
+ pass = not ^ found;
4045
4191
 
4046
4192
  if ( inplace && found != null ) {
4047
4193
  if ( pass ) {
@@ -4095,6 +4241,45 @@ Sizzle.error = function( msg ) {
4095
4241
  throw "Syntax error, unrecognized expression: " + msg;
4096
4242
  };
4097
4243
 
4244
+ /**
4245
+ * Utility function for retreiving the text value of an array of DOM nodes
4246
+ * @param {Array|Element} elem
4247
+ */
4248
+ var getText = Sizzle.getText = function( elem ) {
4249
+ var i, node,
4250
+ nodeType = elem.nodeType,
4251
+ ret = "";
4252
+
4253
+ if ( nodeType ) {
4254
+ if ( nodeType === 1 ) {
4255
+ // Use textContent || innerText for elements
4256
+ if ( typeof elem.textContent === 'string' ) {
4257
+ return elem.textContent;
4258
+ } else if ( typeof elem.innerText === 'string' ) {
4259
+ // Replace IE's carriage returns
4260
+ return elem.innerText.replace( rReturn, '' );
4261
+ } else {
4262
+ // Traverse it's children
4263
+ for ( elem = elem.firstChild; elem; elem = elem.nextSibling) {
4264
+ ret += getText( elem );
4265
+ }
4266
+ }
4267
+ } else if ( nodeType === 3 || nodeType === 4 ) {
4268
+ return elem.nodeValue;
4269
+ }
4270
+ } else {
4271
+
4272
+ // If no nodeType, this is expected to be an array
4273
+ for ( i = 0; (node = elem[i]); i++ ) {
4274
+ // Do not traverse comment nodes
4275
+ if ( node.nodeType !== 8 ) {
4276
+ ret += getText( node );
4277
+ }
4278
+ }
4279
+ }
4280
+ return ret;
4281
+ };
4282
+
4098
4283
  var Expr = Sizzle.selectors = {
4099
4284
  order: [ "ID", "NAME", "TAG" ],
4100
4285
 
@@ -4482,7 +4667,7 @@ var Expr = Sizzle.selectors = {
4482
4667
  return filter( elem, i, match, array );
4483
4668
 
4484
4669
  } else if ( name === "contains" ) {
4485
- return (elem.textContent || elem.innerText || Sizzle.getText([ elem ]) || "").indexOf(match[3]) >= 0;
4670
+ return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0;
4486
4671
 
4487
4672
  } else if ( name === "not" ) {
4488
4673
  var not = match[3];
@@ -4501,7 +4686,10 @@ var Expr = Sizzle.selectors = {
4501
4686
  },
4502
4687
 
4503
4688
  CHILD: function( elem, match ) {
4504
- var type = match[1],
4689
+ var first, last,
4690
+ doneName, parent, cache,
4691
+ count, diff,
4692
+ type = match[1],
4505
4693
  node = elem;
4506
4694
 
4507
4695
  switch ( type ) {
@@ -4529,18 +4717,18 @@ var Expr = Sizzle.selectors = {
4529
4717
  return true;
4530
4718
 
4531
4719
  case "nth":
4532
- var first = match[2],
4533
- last = match[3];
4720
+ first = match[2];
4721
+ last = match[3];
4534
4722
 
4535
4723
  if ( first === 1 && last === 0 ) {
4536
4724
  return true;
4537
4725
  }
4538
4726
 
4539
- var doneName = match[0],
4540
- parent = elem.parentNode;
4727
+ doneName = match[0];
4728
+ parent = elem.parentNode;
4541
4729
 
4542
- if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
4543
- var count = 0;
4730
+ if ( parent && (parent[ expando ] !== doneName || !elem.nodeIndex) ) {
4731
+ count = 0;
4544
4732
 
4545
4733
  for ( node = parent.firstChild; node; node = node.nextSibling ) {
4546
4734
  if ( node.nodeType === 1 ) {
@@ -4548,10 +4736,10 @@ var Expr = Sizzle.selectors = {
4548
4736
  }
4549
4737
  }
4550
4738
 
4551
- parent.sizcache = doneName;
4739
+ parent[ expando ] = doneName;
4552
4740
  }
4553
4741
 
4554
- var diff = elem.nodeIndex - last;
4742
+ diff = elem.nodeIndex - last;
4555
4743
 
4556
4744
  if ( first === 0 ) {
4557
4745
  return diff === 0;
@@ -4567,7 +4755,7 @@ var Expr = Sizzle.selectors = {
4567
4755
  },
4568
4756
 
4569
4757
  TAG: function( elem, match ) {
4570
- return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
4758
+ return (match === "*" && elem.nodeType === 1) || !!elem.nodeName && elem.nodeName.toLowerCase() === match;
4571
4759
  },
4572
4760
 
4573
4761
  CLASS: function( elem, match ) {
@@ -4577,7 +4765,9 @@ var Expr = Sizzle.selectors = {
4577
4765
 
4578
4766
  ATTR: function( elem, match ) {
4579
4767
  var name = match[1],
4580
- result = Expr.attrHandle[ name ] ?
4768
+ result = Sizzle.attr ?
4769
+ Sizzle.attr( elem, name ) :
4770
+ Expr.attrHandle[ name ] ?
4581
4771
  Expr.attrHandle[ name ]( elem ) :
4582
4772
  elem[ name ] != null ?
4583
4773
  elem[ name ] :
@@ -4588,6 +4778,8 @@ var Expr = Sizzle.selectors = {
4588
4778
 
4589
4779
  return result == null ?
4590
4780
  type === "!=" :
4781
+ !type && Sizzle.attr ?
4782
+ result != null :
4591
4783
  type === "=" ?
4592
4784
  value === check :
4593
4785
  type === "*=" ?
@@ -4768,26 +4960,6 @@ if ( document.documentElement.compareDocumentPosition ) {
4768
4960
  };
4769
4961
  }
4770
4962
 
4771
- // Utility function for retreiving the text value of an array of DOM nodes
4772
- Sizzle.getText = function( elems ) {
4773
- var ret = "", elem;
4774
-
4775
- for ( var i = 0; elems[i]; i++ ) {
4776
- elem = elems[i];
4777
-
4778
- // Get the text from text nodes and CDATA nodes
4779
- if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
4780
- ret += elem.nodeValue;
4781
-
4782
- // Traverse everything else, except comment nodes
4783
- } else if ( elem.nodeType !== 8 ) {
4784
- ret += Sizzle.getText( elem.childNodes );
4785
- }
4786
- }
4787
-
4788
- return ret;
4789
- };
4790
-
4791
4963
  // Check to see if the browser returns elements by name when
4792
4964
  // querying by getElementById (and provide a workaround)
4793
4965
  (function(){
@@ -5065,13 +5237,13 @@ function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
5065
5237
  elem = elem[dir];
5066
5238
 
5067
5239
  while ( elem ) {
5068
- if ( elem.sizcache === doneName ) {
5240
+ if ( elem[ expando ] === doneName ) {
5069
5241
  match = checkSet[elem.sizset];
5070
5242
  break;
5071
5243
  }
5072
5244
 
5073
5245
  if ( elem.nodeType === 1 && !isXML ){
5074
- elem.sizcache = doneName;
5246
+ elem[ expando ] = doneName;
5075
5247
  elem.sizset = i;
5076
5248
  }
5077
5249
 
@@ -5098,14 +5270,14 @@ function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
5098
5270
  elem = elem[dir];
5099
5271
 
5100
5272
  while ( elem ) {
5101
- if ( elem.sizcache === doneName ) {
5273
+ if ( elem[ expando ] === doneName ) {
5102
5274
  match = checkSet[elem.sizset];
5103
5275
  break;
5104
5276
  }
5105
5277
 
5106
5278
  if ( elem.nodeType === 1 ) {
5107
5279
  if ( !isXML ) {
5108
- elem.sizcache = doneName;
5280
+ elem[ expando ] = doneName;
5109
5281
  elem.sizset = i;
5110
5282
  }
5111
5283
 
@@ -5153,7 +5325,7 @@ Sizzle.isXML = function( elem ) {
5153
5325
  return documentElement ? documentElement.nodeName !== "HTML" : false;
5154
5326
  };
5155
5327
 
5156
- var posProcess = function( selector, context ) {
5328
+ var posProcess = function( selector, context, seed ) {
5157
5329
  var match,
5158
5330
  tmpSet = [],
5159
5331
  later = "",
@@ -5169,13 +5341,16 @@ var posProcess = function( selector, context ) {
5169
5341
  selector = Expr.relative[selector] ? selector + "*" : selector;
5170
5342
 
5171
5343
  for ( var i = 0, l = root.length; i < l; i++ ) {
5172
- Sizzle( selector, root[i], tmpSet );
5344
+ Sizzle( selector, root[i], tmpSet, seed );
5173
5345
  }
5174
5346
 
5175
5347
  return Sizzle.filter( later, tmpSet );
5176
5348
  };
5177
5349
 
5178
5350
  // EXPOSE
5351
+ // Override sizzle attribute retrieval
5352
+ Sizzle.attr = jQuery.attr;
5353
+ Sizzle.selectors.attrMap = {};
5179
5354
  jQuery.find = Sizzle;
5180
5355
  jQuery.expr = Sizzle.selectors;
5181
5356
  jQuery.expr[":"] = jQuery.expr.filters;
@@ -5261,43 +5436,33 @@ jQuery.fn.extend({
5261
5436
  },
5262
5437
 
5263
5438
  is: function( selector ) {
5264
- return !!selector && ( typeof selector === "string" ?
5265
- jQuery.filter( selector, this ).length > 0 :
5266
- this.filter( selector ).length > 0 );
5439
+ return !!selector && (
5440
+ typeof selector === "string" ?
5441
+ // If this is a positional selector, check membership in the returned set
5442
+ // so $("p:first").is("p:last") won't return true for a doc with two "p".
5443
+ POS.test( selector ) ?
5444
+ jQuery( selector, this.context ).index( this[0] ) >= 0 :
5445
+ jQuery.filter( selector, this ).length > 0 :
5446
+ this.filter( selector ).length > 0 );
5267
5447
  },
5268
5448
 
5269
5449
  closest: function( selectors, context ) {
5270
5450
  var ret = [], i, l, cur = this[0];
5271
5451
 
5272
- // Array
5452
+ // Array (deprecated as of jQuery 1.7)
5273
5453
  if ( jQuery.isArray( selectors ) ) {
5274
- var match, selector,
5275
- matches = {},
5276
- level = 1;
5277
-
5278
- if ( cur && selectors.length ) {
5279
- for ( i = 0, l = selectors.length; i < l; i++ ) {
5280
- selector = selectors[i];
5281
-
5282
- if ( !matches[ selector ] ) {
5283
- matches[ selector ] = POS.test( selector ) ?
5284
- jQuery( selector, context || this.context ) :
5285
- selector;
5286
- }
5287
- }
5454
+ var level = 1;
5288
5455
 
5289
- while ( cur && cur.ownerDocument && cur !== context ) {
5290
- for ( selector in matches ) {
5291
- match = matches[ selector ];
5456
+ while ( cur && cur.ownerDocument && cur !== context ) {
5457
+ for ( i = 0; i < selectors.length; i++ ) {
5292
5458
 
5293
- if ( match.jquery ? match.index( cur ) > -1 : jQuery( cur ).is( match ) ) {
5294
- ret.push({ selector: selector, elem: cur, level: level });
5295
- }
5459
+ if ( jQuery( cur ).is( selectors[ i ] ) ) {
5460
+ ret.push({ selector: selectors[ i ], elem: cur, level: level });
5296
5461
  }
5297
-
5298
- cur = cur.parentNode;
5299
- level++;
5300
5462
  }
5463
+
5464
+ cur = cur.parentNode;
5465
+ level++;
5301
5466
  }
5302
5467
 
5303
5468
  return ret;
@@ -5504,7 +5669,7 @@ function winnow( elements, qualifier, keep ) {
5504
5669
 
5505
5670
  } else if ( qualifier.nodeType ) {
5506
5671
  return jQuery.grep(elements, function( elem, i ) {
5507
- return (elem === qualifier) === keep;
5672
+ return ( elem === qualifier ) === keep;
5508
5673
  });
5509
5674
 
5510
5675
  } else if ( typeof qualifier === "string" ) {
@@ -5520,20 +5685,38 @@ function winnow( elements, qualifier, keep ) {
5520
5685
  }
5521
5686
 
5522
5687
  return jQuery.grep(elements, function( elem, i ) {
5523
- return (jQuery.inArray( elem, qualifier ) >= 0) === keep;
5688
+ return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep;
5524
5689
  });
5525
5690
  }
5526
5691
 
5527
5692
 
5528
5693
 
5529
5694
 
5530
- var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
5695
+ function createSafeFragment( document ) {
5696
+ var list = nodeNames.split( " " ),
5697
+ safeFrag = document.createDocumentFragment();
5698
+
5699
+ if ( safeFrag.createElement ) {
5700
+ while ( list.length ) {
5701
+ safeFrag.createElement(
5702
+ list.pop()
5703
+ );
5704
+ }
5705
+ }
5706
+ return safeFrag;
5707
+ }
5708
+
5709
+ var nodeNames = "abbr article aside audio canvas datalist details figcaption figure footer " +
5710
+ "header hgroup mark meter nav output progress section summary time video",
5711
+ rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
5531
5712
  rleadingWhitespace = /^\s+/,
5532
5713
  rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
5533
5714
  rtagName = /<([\w:]+)/,
5534
5715
  rtbody = /<tbody/i,
5535
5716
  rhtml = /<|&#?\w+;/,
5717
+ rnoInnerhtml = /<(?:script|style)/i,
5536
5718
  rnocache = /<(?:script|object|embed|option|style)/i,
5719
+ rnoshimcache = new RegExp("<(?:" + nodeNames.replace(" ", "|") + ")", "i"),
5537
5720
  // checked="checked" or checked
5538
5721
  rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
5539
5722
  rscriptType = /\/(java|ecma)script/i,
@@ -5547,7 +5730,8 @@ var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
5547
5730
  col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
5548
5731
  area: [ 1, "<map>", "</map>" ],
5549
5732
  _default: [ 0, "", "" ]
5550
- };
5733
+ },
5734
+ safeFragment = createSafeFragment( document );
5551
5735
 
5552
5736
  wrapMap.optgroup = wrapMap.option;
5553
5737
  wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
@@ -5728,7 +5912,7 @@ jQuery.fn.extend({
5728
5912
  null;
5729
5913
 
5730
5914
  // See if we can take a shortcut and just use innerHTML
5731
- } else if ( typeof value === "string" && !rnocache.test( value ) &&
5915
+ } else if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
5732
5916
  (jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) &&
5733
5917
  !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) {
5734
5918
 
@@ -5854,7 +6038,7 @@ jQuery.fn.extend({
5854
6038
  // in certain situations (Bug #8070).
5855
6039
  // Fragments from the fragment cache must always be cloned and never used
5856
6040
  // in place.
5857
- results.cacheable || (l > 1 && i < lastIndex) ?
6041
+ results.cacheable || ( l > 1 && i < lastIndex ) ?
5858
6042
  jQuery.clone( fragment, true, true ) :
5859
6043
  fragment
5860
6044
  );
@@ -5883,27 +6067,26 @@ function cloneCopyEvent( src, dest ) {
5883
6067
  return;
5884
6068
  }
5885
6069
 
5886
- var internalKey = jQuery.expando,
5887
- oldData = jQuery.data( src ),
5888
- curData = jQuery.data( dest, oldData );
5889
-
5890
- // Switch to use the internal data object, if it exists, for the next
5891
- // stage of data copying
5892
- if ( (oldData = oldData[ internalKey ]) ) {
5893
- var events = oldData.events;
5894
- curData = curData[ internalKey ] = jQuery.extend({}, oldData);
6070
+ var type, i, l,
6071
+ oldData = jQuery._data( src ),
6072
+ curData = jQuery._data( dest, oldData ),
6073
+ events = oldData.events;
5895
6074
 
5896
- if ( events ) {
5897
- delete curData.handle;
5898
- curData.events = {};
6075
+ if ( events ) {
6076
+ delete curData.handle;
6077
+ curData.events = {};
5899
6078
 
5900
- for ( var type in events ) {
5901
- for ( var i = 0, l = events[ type ].length; i < l; i++ ) {
5902
- jQuery.event.add( dest, type + ( events[ type ][ i ].namespace ? "." : "" ) + events[ type ][ i ].namespace, events[ type ][ i ], events[ type ][ i ].data );
5903
- }
6079
+ for ( type in events ) {
6080
+ for ( i = 0, l = events[ type ].length; i < l; i++ ) {
6081
+ jQuery.event.add( dest, type + ( events[ type ][ i ].namespace ? "." : "" ) + events[ type ][ i ].namespace, events[ type ][ i ], events[ type ][ i ].data );
5904
6082
  }
5905
6083
  }
5906
6084
  }
6085
+
6086
+ // make the cloned public data object a copy from the original
6087
+ if ( curData.data ) {
6088
+ curData.data = jQuery.extend( {}, curData.data );
6089
+ }
5907
6090
  }
5908
6091
 
5909
6092
  function cloneFixAttributes( src, dest ) {
@@ -5965,14 +6148,15 @@ function cloneFixAttributes( src, dest ) {
5965
6148
  }
5966
6149
 
5967
6150
  jQuery.buildFragment = function( args, nodes, scripts ) {
5968
- var fragment, cacheable, cacheresults, doc;
5969
-
5970
- // nodes may contain either an explicit document object,
5971
- // a jQuery collection or context object.
5972
- // If nodes[0] contains a valid object to assign to doc
5973
- if ( nodes && nodes[0] ) {
5974
- doc = nodes[0].ownerDocument || nodes[0];
5975
- }
6151
+ var fragment, cacheable, cacheresults, doc,
6152
+ first = args[ 0 ];
6153
+
6154
+ // nodes may contain either an explicit document object,
6155
+ // a jQuery collection or context object.
6156
+ // If nodes[0] contains a valid object to assign to doc
6157
+ if ( nodes && nodes[0] ) {
6158
+ doc = nodes[0].ownerDocument || nodes[0];
6159
+ }
5976
6160
 
5977
6161
  // Ensure that an attr object doesn't incorrectly stand in as a document object
5978
6162
  // Chrome and Firefox seem to allow this to occur and will throw exception
@@ -5985,12 +6169,15 @@ jQuery.buildFragment = function( args, nodes, scripts ) {
5985
6169
  // Cloning options loses the selected state, so don't cache them
5986
6170
  // IE 6 doesn't like it when you put <object> or <embed> elements in a fragment
5987
6171
  // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache
5988
- if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && doc === document &&
5989
- args[0].charAt(0) === "<" && !rnocache.test( args[0] ) && (jQuery.support.checkClone || !rchecked.test( args[0] )) ) {
6172
+ // Lastly, IE6,7,8 will not correctly reuse cached fragments that were created from unknown elems #10501
6173
+ if ( args.length === 1 && typeof first === "string" && first.length < 512 && doc === document &&
6174
+ first.charAt(0) === "<" && !rnocache.test( first ) &&
6175
+ (jQuery.support.checkClone || !rchecked.test( first )) &&
6176
+ (!jQuery.support.unknownElems && rnoshimcache.test( first )) ) {
5990
6177
 
5991
6178
  cacheable = true;
5992
6179
 
5993
- cacheresults = jQuery.fragments[ args[0] ];
6180
+ cacheresults = jQuery.fragments[ first ];
5994
6181
  if ( cacheresults && cacheresults !== 1 ) {
5995
6182
  fragment = cacheresults;
5996
6183
  }
@@ -6002,7 +6189,7 @@ jQuery.buildFragment = function( args, nodes, scripts ) {
6002
6189
  }
6003
6190
 
6004
6191
  if ( cacheable ) {
6005
- jQuery.fragments[ args[0] ] = cacheresults ? fragment : 1;
6192
+ jQuery.fragments[ first ] = cacheresults ? fragment : 1;
6006
6193
  }
6007
6194
 
6008
6195
  return { fragment: fragment, cacheable: cacheable };
@@ -6028,7 +6215,7 @@ jQuery.each({
6028
6215
 
6029
6216
  } else {
6030
6217
  for ( var i = 0, l = insert.length; i < l; i++ ) {
6031
- var elems = (i > 0 ? this.clone(true) : this).get();
6218
+ var elems = ( i > 0 ? this.clone(true) : this ).get();
6032
6219
  jQuery( insert[i] )[ original ]( elems );
6033
6220
  ret = ret.concat( elems );
6034
6221
  }
@@ -6039,10 +6226,10 @@ jQuery.each({
6039
6226
  });
6040
6227
 
6041
6228
  function getAll( elem ) {
6042
- if ( "getElementsByTagName" in elem ) {
6229
+ if ( typeof elem.getElementsByTagName !== "undefined" ) {
6043
6230
  return elem.getElementsByTagName( "*" );
6044
6231
 
6045
- } else if ( "querySelectorAll" in elem ) {
6232
+ } else if ( typeof elem.querySelectorAll !== "undefined" ) {
6046
6233
  return elem.querySelectorAll( "*" );
6047
6234
 
6048
6235
  } else {
@@ -6058,9 +6245,11 @@ function fixDefaultChecked( elem ) {
6058
6245
  }
6059
6246
  // Finds all inputs and passes them to fixDefaultChecked
6060
6247
  function findInputs( elem ) {
6061
- if ( jQuery.nodeName( elem, "input" ) ) {
6248
+ var nodeName = ( elem.nodeName || "" ).toLowerCase();
6249
+ if ( nodeName === "input" ) {
6062
6250
  fixDefaultChecked( elem );
6063
- } else if ( "getElementsByTagName" in elem ) {
6251
+ // Skip scripts, get other children
6252
+ } else if ( nodeName !== "script" && typeof elem.getElementsByTagName !== "undefined" ) {
6064
6253
  jQuery.grep( elem.getElementsByTagName("input"), fixDefaultChecked );
6065
6254
  }
6066
6255
  }
@@ -6148,11 +6337,20 @@ jQuery.extend({
6148
6337
  elem = elem.replace(rxhtmlTag, "<$1></$2>");
6149
6338
 
6150
6339
  // Trim whitespace, otherwise indexOf won't work as expected
6151
- var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(),
6340
+ var tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase(),
6152
6341
  wrap = wrapMap[ tag ] || wrapMap._default,
6153
6342
  depth = wrap[0],
6154
6343
  div = context.createElement("div");
6155
6344
 
6345
+ // Append wrapper element to unknown element safe doc fragment
6346
+ if ( context === document ) {
6347
+ // Use the fragment we've already created for this document
6348
+ safeFragment.appendChild( div );
6349
+ } else {
6350
+ // Use a fragment created with the owner document
6351
+ createSafeFragment( context ).appendChild( div );
6352
+ }
6353
+
6156
6354
  // Go to html and back, then peel off extra wrappers
6157
6355
  div.innerHTML = wrap[1] + elem + wrap[2];
6158
6356
 
@@ -6233,7 +6431,9 @@ jQuery.extend({
6233
6431
  },
6234
6432
 
6235
6433
  cleanData: function( elems ) {
6236
- var data, id, cache = jQuery.cache, internalKey = jQuery.expando, special = jQuery.event.special,
6434
+ var data, id,
6435
+ cache = jQuery.cache,
6436
+ special = jQuery.event.special,
6237
6437
  deleteExpando = jQuery.support.deleteExpando;
6238
6438
 
6239
6439
  for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
@@ -6244,7 +6444,7 @@ jQuery.extend({
6244
6444
  id = elem[ jQuery.expando ];
6245
6445
 
6246
6446
  if ( id ) {
6247
- data = cache[ id ] && cache[ id ][ internalKey ];
6447
+ data = cache[ id ];
6248
6448
 
6249
6449
  if ( data && data.events ) {
6250
6450
  for ( var type in data.events ) {
@@ -6506,7 +6706,7 @@ if ( !jQuery.support.opacity ) {
6506
6706
  set: function( elem, value ) {
6507
6707
  var style = elem.style,
6508
6708
  currentStyle = elem.currentStyle,
6509
- opacity = jQuery.isNaN( value ) ? "" : "alpha(opacity=" + value * 100 + ")",
6709
+ opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
6510
6710
  filter = currentStyle && currentStyle.filter || style.filter || "";
6511
6711
 
6512
6712
  // IE has trouble with opacity if it does not have layout
@@ -6580,25 +6780,32 @@ if ( document.defaultView && document.defaultView.getComputedStyle ) {
6580
6780
 
6581
6781
  if ( document.documentElement.currentStyle ) {
6582
6782
  currentStyle = function( elem, name ) {
6583
- var left,
6783
+ var left, rsLeft, uncomputed,
6584
6784
  ret = elem.currentStyle && elem.currentStyle[ name ],
6585
- rsLeft = elem.runtimeStyle && elem.runtimeStyle[ name ],
6586
6785
  style = elem.style;
6587
6786
 
6787
+ // Avoid setting ret to empty string here
6788
+ // so we don't default to auto
6789
+ if ( ret === null && style && (uncomputed = style[ name ]) ) {
6790
+ ret = uncomputed;
6791
+ }
6792
+
6588
6793
  // From the awesome hack by Dean Edwards
6589
6794
  // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
6590
6795
 
6591
6796
  // If we're not dealing with a regular pixel number
6592
6797
  // but a number that has a weird ending, we need to convert it to pixels
6593
6798
  if ( !rnumpx.test( ret ) && rnum.test( ret ) ) {
6799
+
6594
6800
  // Remember the original values
6595
6801
  left = style.left;
6802
+ rsLeft = elem.runtimeStyle && elem.runtimeStyle.left;
6596
6803
 
6597
6804
  // Put in the new values to get a computed value out
6598
6805
  if ( rsLeft ) {
6599
6806
  elem.runtimeStyle.left = elem.currentStyle.left;
6600
6807
  }
6601
- style.left = name === "fontSize" ? "1em" : (ret || 0);
6808
+ style.left = name === "fontSize" ? "1em" : ( ret || 0 );
6602
6809
  ret = style.pixelLeft + "px";
6603
6810
 
6604
6811
  // Revert the changed values
@@ -6666,7 +6873,7 @@ if ( jQuery.expr && jQuery.expr.filters ) {
6666
6873
  var width = elem.offsetWidth,
6667
6874
  height = elem.offsetHeight;
6668
6875
 
6669
- return (width === 0 && height === 0) || (!jQuery.support.reliableHiddenOffsets && (elem.style.display || jQuery.css( elem, "display" )) === "none");
6876
+ return ( width === 0 && height === 0 ) || (!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || jQuery.css( elem, "display" )) === "none");
6670
6877
  };
6671
6878
 
6672
6879
  jQuery.expr.filters.visible = function( elem ) {
@@ -6720,7 +6927,7 @@ var r20 = /%20/g,
6720
6927
 
6721
6928
  // Document location segments
6722
6929
  ajaxLocParts,
6723
-
6930
+
6724
6931
  // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
6725
6932
  allTypes = ["*/"] + ["*"];
6726
6933
 
@@ -6759,7 +6966,7 @@ function addToPrefiltersOrTransports( structure ) {
6759
6966
  placeBefore;
6760
6967
 
6761
6968
  // For each dataType in the dataTypeExpression
6762
- for(; i < length; i++ ) {
6969
+ for ( ; i < length; i++ ) {
6763
6970
  dataType = dataTypes[ i ];
6764
6971
  // We control if we're asked to add before
6765
6972
  // any existing element
@@ -6790,7 +6997,7 @@ function inspectPrefiltersOrTransports( structure, options, originalOptions, jqX
6790
6997
  executeOnly = ( structure === prefilters ),
6791
6998
  selection;
6792
6999
 
6793
- for(; i < length && ( executeOnly || !selection ); i++ ) {
7000
+ for ( ; i < length && ( executeOnly || !selection ); i++ ) {
6794
7001
  selection = list[ i ]( options, originalOptions, jqXHR );
6795
7002
  // If we got redirected to another dataType
6796
7003
  // we try there if executing only and not done already
@@ -6821,7 +7028,7 @@ function inspectPrefiltersOrTransports( structure, options, originalOptions, jqX
6821
7028
  function ajaxExtend( target, src ) {
6822
7029
  var key, deep,
6823
7030
  flatOptions = jQuery.ajaxSettings.flatOptions || {};
6824
- for( key in src ) {
7031
+ for ( key in src ) {
6825
7032
  if ( src[ key ] !== undefined ) {
6826
7033
  ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
6827
7034
  }
@@ -7080,7 +7287,7 @@ jQuery.extend({
7080
7287
  jQuery( callbackContext ) : jQuery.event,
7081
7288
  // Deferreds
7082
7289
  deferred = jQuery.Deferred(),
7083
- completeDeferred = jQuery._Deferred(),
7290
+ completeDeferred = jQuery.Callbacks( "once memory" ),
7084
7291
  // Status-dependent callbacks
7085
7292
  statusCode = s.statusCode || {},
7086
7293
  // ifModified key
@@ -7230,7 +7437,7 @@ jQuery.extend({
7230
7437
  // We extract error from statusText
7231
7438
  // then normalize statusText and status for non-aborts
7232
7439
  error = statusText;
7233
- if( !statusText || status ) {
7440
+ if ( !statusText || status ) {
7234
7441
  statusText = "error";
7235
7442
  if ( status < 0 ) {
7236
7443
  status = 0;
@@ -7259,7 +7466,7 @@ jQuery.extend({
7259
7466
  }
7260
7467
 
7261
7468
  // Complete
7262
- completeDeferred.resolveWith( callbackContext, [ jqXHR, statusText ] );
7469
+ completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
7263
7470
 
7264
7471
  if ( fireGlobals ) {
7265
7472
  globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
@@ -7274,14 +7481,14 @@ jQuery.extend({
7274
7481
  deferred.promise( jqXHR );
7275
7482
  jqXHR.success = jqXHR.done;
7276
7483
  jqXHR.error = jqXHR.fail;
7277
- jqXHR.complete = completeDeferred.done;
7484
+ jqXHR.complete = completeDeferred.add;
7278
7485
 
7279
7486
  // Status-dependent callbacks
7280
7487
  jqXHR.statusCode = function( map ) {
7281
7488
  if ( map ) {
7282
7489
  var tmp;
7283
7490
  if ( state < 2 ) {
7284
- for( tmp in map ) {
7491
+ for ( tmp in map ) {
7285
7492
  statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ];
7286
7493
  }
7287
7494
  } else {
@@ -7358,7 +7565,7 @@ jQuery.extend({
7358
7565
  ret = s.url.replace( rts, "$1_=" + ts );
7359
7566
 
7360
7567
  // if nothing was replaced, add timestamp to the end
7361
- s.url = ret + ( (ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" );
7568
+ s.url = ret + ( ( ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" );
7362
7569
  }
7363
7570
  }
7364
7571
 
@@ -7536,7 +7743,7 @@ function ajaxHandleResponses( s, jqXHR, responses ) {
7536
7743
  firstDataType;
7537
7744
 
7538
7745
  // Fill responseXXX fields
7539
- for( type in responseFields ) {
7746
+ for ( type in responseFields ) {
7540
7747
  if ( type in responses ) {
7541
7748
  jqXHR[ responseFields[type] ] = responses[ type ];
7542
7749
  }
@@ -7615,13 +7822,13 @@ function ajaxConvert( s, response ) {
7615
7822
  conv2;
7616
7823
 
7617
7824
  // For each dataType in the chain
7618
- for( i = 1; i < length; i++ ) {
7825
+ for ( i = 1; i < length; i++ ) {
7619
7826
 
7620
7827
  // Create converters map
7621
7828
  // with lowercased keys
7622
7829
  if ( i === 1 ) {
7623
- for( key in s.converters ) {
7624
- if( typeof key === "string" ) {
7830
+ for ( key in s.converters ) {
7831
+ if ( typeof key === "string" ) {
7625
7832
  converters[ key.toLowerCase() ] = s.converters[ key ];
7626
7833
  }
7627
7834
  }
@@ -7632,7 +7839,7 @@ function ajaxConvert( s, response ) {
7632
7839
  current = dataTypes[ i ];
7633
7840
 
7634
7841
  // If current is auto dataType, update it to prev
7635
- if( current === "*" ) {
7842
+ if ( current === "*" ) {
7636
7843
  current = prev;
7637
7844
  // If no auto and dataTypes are actually different
7638
7845
  } else if ( prev !== "*" && prev !== current ) {
@@ -7644,7 +7851,7 @@ function ajaxConvert( s, response ) {
7644
7851
  // If there is no direct converter, search transitively
7645
7852
  if ( !conv ) {
7646
7853
  conv2 = undefined;
7647
- for( conv1 in converters ) {
7854
+ for ( conv1 in converters ) {
7648
7855
  tmp = conv1.split( " " );
7649
7856
  if ( tmp[ 0 ] === prev || tmp[ 0 ] === "*" ) {
7650
7857
  conv2 = converters[ tmp[1] + " " + current ];
@@ -8083,11 +8290,11 @@ jQuery.fn.extend({
8083
8290
  var elem, display;
8084
8291
 
8085
8292
  if ( speed || speed === 0 ) {
8086
- return this.animate( genFx("show", 3), speed, easing, callback);
8293
+ return this.animate( genFx("show", 3), speed, easing, callback );
8087
8294
 
8088
8295
  } else {
8089
8296
  for ( var i = 0, j = this.length; i < j; i++ ) {
8090
- elem = this[i];
8297
+ elem = this[ i ];
8091
8298
 
8092
8299
  if ( elem.style ) {
8093
8300
  display = elem.style.display;
@@ -8101,8 +8308,8 @@ jQuery.fn.extend({
8101
8308
  // Set elements which have been overridden with display: none
8102
8309
  // in a stylesheet to whatever the default browser style is
8103
8310
  // for such an element
8104
- if ( display === "" && jQuery.css( elem, "display" ) === "none" ) {
8105
- jQuery._data(elem, "olddisplay", defaultDisplay(elem.nodeName));
8311
+ if ( display === "" && jQuery.css(elem, "display") === "none" ) {
8312
+ jQuery._data( elem, "olddisplay", defaultDisplay(elem.nodeName) );
8106
8313
  }
8107
8314
  }
8108
8315
  }
@@ -8110,13 +8317,13 @@ jQuery.fn.extend({
8110
8317
  // Set the display of most of the elements in a second loop
8111
8318
  // to avoid the constant reflow
8112
8319
  for ( i = 0; i < j; i++ ) {
8113
- elem = this[i];
8320
+ elem = this[ i ];
8114
8321
 
8115
8322
  if ( elem.style ) {
8116
8323
  display = elem.style.display;
8117
8324
 
8118
8325
  if ( display === "" || display === "none" ) {
8119
- elem.style.display = jQuery._data(elem, "olddisplay") || "";
8326
+ elem.style.display = jQuery._data( elem, "olddisplay" ) || "";
8120
8327
  }
8121
8328
  }
8122
8329
  }
@@ -8130,12 +8337,17 @@ jQuery.fn.extend({
8130
8337
  return this.animate( genFx("hide", 3), speed, easing, callback);
8131
8338
 
8132
8339
  } else {
8133
- for ( var i = 0, j = this.length; i < j; i++ ) {
8134
- if ( this[i].style ) {
8135
- var display = jQuery.css( this[i], "display" );
8340
+ var elem, display,
8341
+ i = 0,
8342
+ j = this.length;
8343
+
8344
+ for ( ; i < j; i++ ) {
8345
+ elem = this[i];
8346
+ if ( elem.style ) {
8347
+ display = jQuery.css( elem, "display" );
8136
8348
 
8137
- if ( display !== "none" && !jQuery._data( this[i], "olddisplay" ) ) {
8138
- jQuery._data( this[i], "olddisplay", display );
8349
+ if ( display !== "none" && !jQuery._data( elem, "olddisplay" ) ) {
8350
+ jQuery._data( elem, "olddisplay", display );
8139
8351
  }
8140
8352
  }
8141
8353
  }
@@ -8180,7 +8392,7 @@ jQuery.fn.extend({
8180
8392
  },
8181
8393
 
8182
8394
  animate: function( prop, speed, easing, callback ) {
8183
- var optall = jQuery.speed(speed, easing, callback);
8395
+ var optall = jQuery.speed( speed, easing, callback );
8184
8396
 
8185
8397
  if ( jQuery.isEmptyObject( prop ) ) {
8186
8398
  return this.each( optall.complete, [ false ] );
@@ -8189,7 +8401,7 @@ jQuery.fn.extend({
8189
8401
  // Do not change referenced properties as per-property easing will be lost
8190
8402
  prop = jQuery.extend( {}, prop );
8191
8403
 
8192
- return this[ optall.queue === false ? "each" : "queue" ](function() {
8404
+ function doAnimation() {
8193
8405
  // XXX 'this' does not always have a nodeName when running the
8194
8406
  // test suite
8195
8407
 
@@ -8200,9 +8412,9 @@ jQuery.fn.extend({
8200
8412
  var opt = jQuery.extend( {}, optall ),
8201
8413
  isElement = this.nodeType === 1,
8202
8414
  hidden = isElement && jQuery(this).is(":hidden"),
8203
- name, val, p,
8204
- display, e,
8205
- parts, start, end, unit;
8415
+ name, val, p, e,
8416
+ parts, start, end, unit,
8417
+ method;
8206
8418
 
8207
8419
  // will store per property easing and be used to determine when an animation is complete
8208
8420
  opt.animatedProperties = {};
@@ -8238,25 +8450,17 @@ jQuery.fn.extend({
8238
8450
  opt.overflow = [ this.style.overflow, this.style.overflowX, this.style.overflowY ];
8239
8451
 
8240
8452
  // Set display property to inline-block for height/width
8241
- // animations on inline elements that are having width/height
8242
- // animated
8453
+ // animations on inline elements that are having width/height animated
8243
8454
  if ( jQuery.css( this, "display" ) === "inline" &&
8244
8455
  jQuery.css( this, "float" ) === "none" ) {
8245
- if ( !jQuery.support.inlineBlockNeedsLayout ) {
8456
+
8457
+ // inline-level elements accept inline-block;
8458
+ // block-level elements need to be inline with layout
8459
+ if ( !jQuery.support.inlineBlockNeedsLayout || defaultDisplay( this.nodeName ) === "inline" ) {
8246
8460
  this.style.display = "inline-block";
8247
8461
 
8248
8462
  } else {
8249
- display = defaultDisplay( this.nodeName );
8250
-
8251
- // inline-level elements accept inline-block;
8252
- // block-level elements need to be inline with layout
8253
- if ( display === "inline" ) {
8254
- this.style.display = "inline-block";
8255
-
8256
- } else {
8257
- this.style.display = "inline";
8258
- this.style.zoom = 1;
8259
- }
8463
+ this.style.zoom = 1;
8260
8464
  }
8261
8465
  }
8262
8466
  }
@@ -8270,8 +8474,17 @@ jQuery.fn.extend({
8270
8474
  e = new jQuery.fx( this, opt, p );
8271
8475
  val = prop[ p ];
8272
8476
 
8273
- if ( rfxtypes.test(val) ) {
8274
- e[ val === "toggle" ? hidden ? "show" : "hide" : val ]();
8477
+ if ( rfxtypes.test( val ) ) {
8478
+
8479
+ // Tracks whether to show or hide based on private
8480
+ // data attached to the element
8481
+ method = jQuery._data( this, "toggle" + p ) || ( val === "toggle" ? hidden ? "show" : "hide" : 0 );
8482
+ if ( method ) {
8483
+ jQuery._data( this, "toggle" + p, method === "show" ? "hide" : "show" );
8484
+ e[ method ]();
8485
+ } else {
8486
+ e[ val ]();
8487
+ }
8275
8488
 
8276
8489
  } else {
8277
8490
  parts = rfxnum.exec( val );
@@ -8284,7 +8497,7 @@ jQuery.fn.extend({
8284
8497
  // We need to compute starting value
8285
8498
  if ( unit !== "px" ) {
8286
8499
  jQuery.style( this, p, (end || 1) + unit);
8287
- start = ((end || 1) / e.cur()) * start;
8500
+ start = ( (end || 1) / e.cur() ) * start;
8288
8501
  jQuery.style( this, p, start + unit);
8289
8502
  }
8290
8503
 
@@ -8303,39 +8516,71 @@ jQuery.fn.extend({
8303
8516
 
8304
8517
  // For JS strict compliance
8305
8518
  return true;
8306
- });
8519
+ }
8520
+
8521
+ return optall.queue === false ?
8522
+ this.each( doAnimation ) :
8523
+ this.queue( optall.queue, doAnimation );
8307
8524
  },
8308
8525
 
8309
- stop: function( clearQueue, gotoEnd ) {
8310
- if ( clearQueue ) {
8311
- this.queue([]);
8526
+ stop: function( type, clearQueue, gotoEnd ) {
8527
+ if ( typeof type !== "string" ) {
8528
+ gotoEnd = clearQueue;
8529
+ clearQueue = type;
8530
+ type = undefined;
8531
+ }
8532
+ if ( clearQueue && type !== false ) {
8533
+ this.queue( type || "fx", [] );
8312
8534
  }
8313
8535
 
8314
- this.each(function() {
8315
- var timers = jQuery.timers,
8316
- i = timers.length;
8536
+ return this.each(function() {
8537
+ var i,
8538
+ hadTimers = false,
8539
+ timers = jQuery.timers,
8540
+ data = jQuery._data( this );
8541
+
8317
8542
  // clear marker counters if we know they won't be
8318
8543
  if ( !gotoEnd ) {
8319
8544
  jQuery._unmark( true, this );
8320
8545
  }
8321
- while ( i-- ) {
8322
- if ( timers[i].elem === this ) {
8323
- if (gotoEnd) {
8324
- // force the next step to be the last
8325
- timers[i](true);
8326
- }
8327
8546
 
8328
- timers.splice(i, 1);
8547
+ function stopQueue( elem, data, i ) {
8548
+ var hooks = data[ i ];
8549
+ jQuery.removeData( elem, i, true );
8550
+ hooks.stop( gotoEnd );
8551
+ }
8552
+
8553
+ if ( type == null ) {
8554
+ for ( i in data ) {
8555
+ if ( data[ i ].stop && i.indexOf(".run") === i.length - 4 ) {
8556
+ stopQueue( this, data, i );
8557
+ }
8329
8558
  }
8559
+ } else if ( data[ i = type + ".run" ] && data[ i ].stop ){
8560
+ stopQueue( this, data, i );
8330
8561
  }
8331
- });
8332
8562
 
8333
- // start the next in the queue if the last step wasn't forced
8334
- if ( !gotoEnd ) {
8335
- this.dequeue();
8336
- }
8563
+ for ( i = timers.length; i--; ) {
8564
+ if ( timers[ i ].elem === this && (type == null || timers[ i ].queue === type) ) {
8565
+ if ( gotoEnd ) {
8337
8566
 
8338
- return this;
8567
+ // force the next step to be the last
8568
+ timers[ i ]( true );
8569
+ } else {
8570
+ timers[ i ].saveState();
8571
+ }
8572
+ hadTimers = true;
8573
+ timers.splice( i, 1 );
8574
+ }
8575
+ }
8576
+
8577
+ // start the next in the queue if the last step wasn't forced
8578
+ // timers currently will call their complete callbacks, which will dequeue
8579
+ // but only if they were gotoEnd
8580
+ if ( !( gotoEnd && hadTimers ) ) {
8581
+ jQuery.dequeue( this, type );
8582
+ }
8583
+ });
8339
8584
  }
8340
8585
 
8341
8586
  });
@@ -8354,7 +8599,7 @@ function clearFxNow() {
8354
8599
  function genFx( type, num ) {
8355
8600
  var obj = {};
8356
8601
 
8357
- jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function() {
8602
+ jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice( 0, num )), function() {
8358
8603
  obj[ this ] = type;
8359
8604
  });
8360
8605
 
@@ -8363,9 +8608,9 @@ function genFx( type, num ) {
8363
8608
 
8364
8609
  // Generate shortcuts for custom animations
8365
8610
  jQuery.each({
8366
- slideDown: genFx("show", 1),
8367
- slideUp: genFx("hide", 1),
8368
- slideToggle: genFx("toggle", 1),
8611
+ slideDown: genFx( "show", 1 ),
8612
+ slideUp: genFx( "hide", 1 ),
8613
+ slideToggle: genFx( "toggle", 1 ),
8369
8614
  fadeIn: { opacity: "show" },
8370
8615
  fadeOut: { opacity: "hide" },
8371
8616
  fadeToggle: { opacity: "toggle" }
@@ -8377,25 +8622,31 @@ jQuery.each({
8377
8622
 
8378
8623
  jQuery.extend({
8379
8624
  speed: function( speed, easing, fn ) {
8380
- var opt = speed && typeof speed === "object" ? jQuery.extend({}, speed) : {
8625
+ var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
8381
8626
  complete: fn || !fn && easing ||
8382
8627
  jQuery.isFunction( speed ) && speed,
8383
8628
  duration: speed,
8384
- easing: fn && easing || easing && !jQuery.isFunction(easing) && easing
8629
+ easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
8385
8630
  };
8386
8631
 
8387
8632
  opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
8388
- opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[opt.duration] : jQuery.fx.speeds._default;
8633
+ opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
8634
+
8635
+ // normalize opt.queue - true/undefined/null -> "fx"
8636
+ if ( opt.queue == null || opt.queue === true ) {
8637
+ opt.queue = "fx";
8638
+ }
8389
8639
 
8390
8640
  // Queueing
8391
8641
  opt.old = opt.complete;
8642
+
8392
8643
  opt.complete = function( noUnmark ) {
8393
8644
  if ( jQuery.isFunction( opt.old ) ) {
8394
8645
  opt.old.call( this );
8395
8646
  }
8396
8647
 
8397
- if ( opt.queue !== false ) {
8398
- jQuery.dequeue( this );
8648
+ if ( opt.queue ) {
8649
+ jQuery.dequeue( this, opt.queue );
8399
8650
  } else if ( noUnmark !== false ) {
8400
8651
  jQuery._unmark( this );
8401
8652
  }
@@ -8409,7 +8660,7 @@ jQuery.extend({
8409
8660
  return firstNum + diff * p;
8410
8661
  },
8411
8662
  swing: function( p, n, firstNum, diff ) {
8412
- return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
8663
+ return ( ( -Math.cos( p*Math.PI ) / 2 ) + 0.5 ) * diff + firstNum;
8413
8664
  }
8414
8665
  },
8415
8666
 
@@ -8432,12 +8683,12 @@ jQuery.fx.prototype = {
8432
8683
  this.options.step.call( this.elem, this.now, this );
8433
8684
  }
8434
8685
 
8435
- (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
8686
+ ( jQuery.fx.step[ this.prop ] || jQuery.fx.step._default )( this );
8436
8687
  },
8437
8688
 
8438
8689
  // Get the current size
8439
8690
  cur: function() {
8440
- if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) {
8691
+ if ( this.elem[ this.prop ] != null && (!this.elem.style || this.elem.style[ this.prop ] == null) ) {
8441
8692
  return this.elem[ this.prop ];
8442
8693
  }
8443
8694
 
@@ -8455,17 +8706,22 @@ jQuery.fx.prototype = {
8455
8706
  fx = jQuery.fx;
8456
8707
 
8457
8708
  this.startTime = fxNow || createFxNow();
8458
- this.start = from;
8459
8709
  this.end = to;
8460
- this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" );
8461
- this.now = this.start;
8710
+ this.now = this.start = from;
8462
8711
  this.pos = this.state = 0;
8712
+ this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" );
8463
8713
 
8464
8714
  function t( gotoEnd ) {
8465
- return self.step(gotoEnd);
8715
+ return self.step( gotoEnd );
8466
8716
  }
8467
8717
 
8718
+ t.queue = this.options.queue;
8468
8719
  t.elem = this.elem;
8720
+ t.saveState = function() {
8721
+ if ( self.options.hide && jQuery._data( self.elem, "fxshow" + self.prop ) === undefined ) {
8722
+ jQuery._data( self.elem, "fxshow" + self.prop, self.start );
8723
+ }
8724
+ };
8469
8725
 
8470
8726
  if ( t() && jQuery.timers.push(t) && !timerId ) {
8471
8727
  timerId = setInterval( fx.tick, fx.interval );
@@ -8474,14 +8730,20 @@ jQuery.fx.prototype = {
8474
8730
 
8475
8731
  // Simple 'show' function
8476
8732
  show: function() {
8733
+ var dataShow = jQuery._data( this.elem, "fxshow" + this.prop );
8734
+
8477
8735
  // Remember where we started, so that we can go back to it later
8478
- this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
8736
+ this.options.orig[ this.prop ] = dataShow || jQuery.style( this.elem, this.prop );
8479
8737
  this.options.show = true;
8480
8738
 
8481
8739
  // Begin the animation
8482
- // Make sure that we start at a small width/height to avoid any
8483
- // flash of content
8484
- this.custom(this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur());
8740
+ // Make sure that we start at a small width/height to avoid any flash of content
8741
+ if ( dataShow !== undefined ) {
8742
+ // This show is picking up where a previous hide or show left off
8743
+ this.custom( this.cur(), dataShow );
8744
+ } else {
8745
+ this.custom( this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur() );
8746
+ }
8485
8747
 
8486
8748
  // Start by showing the element
8487
8749
  jQuery( this.elem ).show();
@@ -8490,20 +8752,20 @@ jQuery.fx.prototype = {
8490
8752
  // Simple 'hide' function
8491
8753
  hide: function() {
8492
8754
  // Remember where we started, so that we can go back to it later
8493
- this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
8755
+ this.options.orig[ this.prop ] = jQuery._data( this.elem, "fxshow" + this.prop ) || jQuery.style( this.elem, this.prop );
8494
8756
  this.options.hide = true;
8495
8757
 
8496
8758
  // Begin the animation
8497
- this.custom(this.cur(), 0);
8759
+ this.custom( this.cur(), 0 );
8498
8760
  },
8499
8761
 
8500
8762
  // Each step of an animation
8501
8763
  step: function( gotoEnd ) {
8502
- var t = fxNow || createFxNow(),
8764
+ var p, n, complete,
8765
+ t = fxNow || createFxNow(),
8503
8766
  done = true,
8504
8767
  elem = this.elem,
8505
- options = this.options,
8506
- i, n;
8768
+ options = this.options;
8507
8769
 
8508
8770
  if ( gotoEnd || t >= options.duration + this.startTime ) {
8509
8771
  this.now = this.end;
@@ -8512,8 +8774,8 @@ jQuery.fx.prototype = {
8512
8774
 
8513
8775
  options.animatedProperties[ this.prop ] = true;
8514
8776
 
8515
- for ( i in options.animatedProperties ) {
8516
- if ( options.animatedProperties[i] !== true ) {
8777
+ for ( p in options.animatedProperties ) {
8778
+ if ( options.animatedProperties[ p ] !== true ) {
8517
8779
  done = false;
8518
8780
  }
8519
8781
  }
@@ -8522,25 +8784,36 @@ jQuery.fx.prototype = {
8522
8784
  // Reset the overflow
8523
8785
  if ( options.overflow != null && !jQuery.support.shrinkWrapBlocks ) {
8524
8786
 
8525
- jQuery.each( [ "", "X", "Y" ], function (index, value) {
8526
- elem.style[ "overflow" + value ] = options.overflow[index];
8787
+ jQuery.each( [ "", "X", "Y" ], function( index, value ) {
8788
+ elem.style[ "overflow" + value ] = options.overflow[ index ];
8527
8789
  });
8528
8790
  }
8529
8791
 
8530
8792
  // Hide the element if the "hide" operation was done
8531
8793
  if ( options.hide ) {
8532
- jQuery(elem).hide();
8794
+ jQuery( elem ).hide();
8533
8795
  }
8534
8796
 
8535
8797
  // Reset the properties, if the item has been hidden or shown
8536
8798
  if ( options.hide || options.show ) {
8537
- for ( var p in options.animatedProperties ) {
8538
- jQuery.style( elem, p, options.orig[p] );
8799
+ for ( p in options.animatedProperties ) {
8800
+ jQuery.style( elem, p, options.orig[ p ] );
8801
+ jQuery.removeData( elem, "fxshow" + p, true );
8802
+ // Toggle data is no longer needed
8803
+ jQuery.removeData( elem, "toggle" + p, true );
8539
8804
  }
8540
8805
  }
8541
8806
 
8542
8807
  // Execute the complete function
8543
- options.complete.call( elem );
8808
+ // in the event that the complete function throws an exception
8809
+ // we must ensure it won't be called twice. #5684
8810
+
8811
+ complete = options.complete;
8812
+ if ( complete ) {
8813
+
8814
+ options.complete = false;
8815
+ complete.call( elem );
8816
+ }
8544
8817
  }
8545
8818
 
8546
8819
  return false;
@@ -8554,8 +8827,8 @@ jQuery.fx.prototype = {
8554
8827
  this.state = n / options.duration;
8555
8828
 
8556
8829
  // Perform the easing function, defaults to swing
8557
- this.pos = jQuery.easing[ options.animatedProperties[ this.prop ] ]( this.state, n, 0, 1, options.duration );
8558
- this.now = this.start + ((this.end - this.start) * this.pos);
8830
+ this.pos = jQuery.easing[ options.animatedProperties[this.prop] ]( this.state, n, 0, 1, options.duration );
8831
+ this.now = this.start + ( (this.end - this.start) * this.pos );
8559
8832
  }
8560
8833
  // Perform the next step of the animation
8561
8834
  this.update();
@@ -8567,9 +8840,15 @@ jQuery.fx.prototype = {
8567
8840
 
8568
8841
  jQuery.extend( jQuery.fx, {
8569
8842
  tick: function() {
8570
- for ( var timers = jQuery.timers, i = 0 ; i < timers.length ; ++i ) {
8571
- if ( !timers[i]() ) {
8572
- timers.splice(i--, 1);
8843
+ var timer,
8844
+ timers = jQuery.timers,
8845
+ i = 0;
8846
+
8847
+ for ( ; i < timers.length; i++ ) {
8848
+ timer = timers[ i ];
8849
+ // Checks the timer has not already been removed
8850
+ if ( !timer() && timers[ i ] === timer ) {
8851
+ timers.splice( i--, 1 );
8573
8852
  }
8574
8853
  }
8575
8854
 
@@ -8599,7 +8878,7 @@ jQuery.extend( jQuery.fx, {
8599
8878
 
8600
8879
  _default: function( fx ) {
8601
8880
  if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {
8602
- fx.elem.style[ fx.prop ] = (fx.prop === "width" || fx.prop === "height" ? Math.max(0, fx.now) : fx.now) + fx.unit;
8881
+ fx.elem.style[ fx.prop ] = fx.now + fx.unit;
8603
8882
  } else {
8604
8883
  fx.elem[ fx.prop ] = fx.now;
8605
8884
  }
@@ -8607,6 +8886,14 @@ jQuery.extend( jQuery.fx, {
8607
8886
  }
8608
8887
  });
8609
8888
 
8889
+ // Adds width/height step functions
8890
+ // Do not set anything below 0
8891
+ jQuery.each([ "width", "height" ], function( i, prop ) {
8892
+ jQuery.fx.step[ prop ] = function( fx ) {
8893
+ jQuery.style( fx.elem, prop, Math.max(0, fx.now) );
8894
+ };
8895
+ });
8896
+
8610
8897
  if ( jQuery.expr && jQuery.expr.filters ) {
8611
8898
  jQuery.expr.filters.animated = function( elem ) {
8612
8899
  return jQuery.grep(jQuery.timers, function( fn ) {
@@ -8623,7 +8910,6 @@ function defaultDisplay( nodeName ) {
8623
8910
  var body = document.body,
8624
8911
  elem = jQuery( "<" + nodeName + ">" ).appendTo( body ),
8625
8912
  display = elem.css( "display" );
8626
-
8627
8913
  elem.remove();
8628
8914
 
8629
8915
  // If the simple way fails,
@@ -8651,7 +8937,6 @@ function defaultDisplay( nodeName ) {
8651
8937
  iframeDoc.body.appendChild( elem );
8652
8938
 
8653
8939
  display = jQuery.css( elem, "display" );
8654
-
8655
8940
  body.removeChild( iframe );
8656
8941
  }
8657
8942
 
@@ -8728,8 +9013,6 @@ if ( "getBoundingClientRect" in document.documentElement ) {
8728
9013
  return jQuery.offset.bodyOffset( elem );
8729
9014
  }
8730
9015
 
8731
- jQuery.offset.initialize();
8732
-
8733
9016
  var computedStyle,
8734
9017
  offsetParent = elem.offsetParent,
8735
9018
  prevOffsetParent = elem,
@@ -8742,7 +9025,7 @@ if ( "getBoundingClientRect" in document.documentElement ) {
8742
9025
  left = elem.offsetLeft;
8743
9026
 
8744
9027
  while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {
8745
- if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
9028
+ if ( jQuery.support.fixedPosition && prevComputedStyle.position === "fixed" ) {
8746
9029
  break;
8747
9030
  }
8748
9031
 
@@ -8754,7 +9037,7 @@ if ( "getBoundingClientRect" in document.documentElement ) {
8754
9037
  top += elem.offsetTop;
8755
9038
  left += elem.offsetLeft;
8756
9039
 
8757
- if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && rtable.test(elem.nodeName)) ) {
9040
+ if ( jQuery.support.doesNotAddBorder && !(jQuery.support.doesAddBorderForTableAndCells && rtable.test(elem.nodeName)) ) {
8758
9041
  top += parseFloat( computedStyle.borderTopWidth ) || 0;
8759
9042
  left += parseFloat( computedStyle.borderLeftWidth ) || 0;
8760
9043
  }
@@ -8763,7 +9046,7 @@ if ( "getBoundingClientRect" in document.documentElement ) {
8763
9046
  offsetParent = elem.offsetParent;
8764
9047
  }
8765
9048
 
8766
- if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) {
9049
+ if ( jQuery.support.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) {
8767
9050
  top += parseFloat( computedStyle.borderTopWidth ) || 0;
8768
9051
  left += parseFloat( computedStyle.borderLeftWidth ) || 0;
8769
9052
  }
@@ -8776,7 +9059,7 @@ if ( "getBoundingClientRect" in document.documentElement ) {
8776
9059
  left += body.offsetLeft;
8777
9060
  }
8778
9061
 
8779
- if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
9062
+ if ( jQuery.support.fixedPosition && prevComputedStyle.position === "fixed" ) {
8780
9063
  top += Math.max( docElem.scrollTop, body.scrollTop );
8781
9064
  left += Math.max( docElem.scrollLeft, body.scrollLeft );
8782
9065
  }
@@ -8786,46 +9069,12 @@ if ( "getBoundingClientRect" in document.documentElement ) {
8786
9069
  }
8787
9070
 
8788
9071
  jQuery.offset = {
8789
- initialize: function() {
8790
- var body = document.body, container = document.createElement("div"), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.css(body, "marginTop") ) || 0,
8791
- html = "<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";
8792
-
8793
- jQuery.extend( container.style, { position: "absolute", top: 0, left: 0, margin: 0, border: 0, width: "1px", height: "1px", visibility: "hidden" } );
8794
-
8795
- container.innerHTML = html;
8796
- body.insertBefore( container, body.firstChild );
8797
- innerDiv = container.firstChild;
8798
- checkDiv = innerDiv.firstChild;
8799
- td = innerDiv.nextSibling.firstChild.firstChild;
8800
-
8801
- this.doesNotAddBorder = (checkDiv.offsetTop !== 5);
8802
- this.doesAddBorderForTableAndCells = (td.offsetTop === 5);
8803
-
8804
- checkDiv.style.position = "fixed";
8805
- checkDiv.style.top = "20px";
8806
-
8807
- // safari subtracts parent border width here which is 5px
8808
- this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15);
8809
- checkDiv.style.position = checkDiv.style.top = "";
8810
-
8811
- innerDiv.style.overflow = "hidden";
8812
- innerDiv.style.position = "relative";
8813
-
8814
- this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5);
8815
-
8816
- this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop);
8817
-
8818
- body.removeChild( container );
8819
- jQuery.offset.initialize = jQuery.noop;
8820
- },
8821
9072
 
8822
9073
  bodyOffset: function( body ) {
8823
9074
  var top = body.offsetTop,
8824
9075
  left = body.offsetLeft;
8825
9076
 
8826
- jQuery.offset.initialize();
8827
-
8828
- if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) {
9077
+ if ( jQuery.support.doesNotIncludeMarginInBodyOffset ) {
8829
9078
  top += parseFloat( jQuery.css(body, "marginTop") ) || 0;
8830
9079
  left += parseFloat( jQuery.css(body, "marginLeft") ) || 0;
8831
9080
  }
@@ -8845,7 +9094,7 @@ jQuery.offset = {
8845
9094
  curOffset = curElem.offset(),
8846
9095
  curCSSTop = jQuery.css( elem, "top" ),
8847
9096
  curCSSLeft = jQuery.css( elem, "left" ),
8848
- calculatePosition = (position === "absolute" || position === "fixed") && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1,
9097
+ calculatePosition = ( position === "absolute" || position === "fixed" ) && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1,
8849
9098
  props = {}, curPosition = {}, curTop, curLeft;
8850
9099
 
8851
9100
  // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
@@ -8862,11 +9111,11 @@ jQuery.offset = {
8862
9111
  options = options.call( elem, i, curOffset );
8863
9112
  }
8864
9113
 
8865
- if (options.top != null) {
8866
- props.top = (options.top - curOffset.top) + curTop;
9114
+ if ( options.top != null ) {
9115
+ props.top = ( options.top - curOffset.top ) + curTop;
8867
9116
  }
8868
- if (options.left != null) {
8869
- props.left = (options.left - curOffset.left) + curLeft;
9117
+ if ( options.left != null ) {
9118
+ props.left = ( options.left - curOffset.left ) + curLeft;
8870
9119
  }
8871
9120
 
8872
9121
  if ( "using" in options ) {
@@ -8879,6 +9128,7 @@ jQuery.offset = {
8879
9128
 
8880
9129
 
8881
9130
  jQuery.fn.extend({
9131
+
8882
9132
  position: function() {
8883
9133
  if ( !this[0] ) {
8884
9134
  return null;
@@ -8981,16 +9231,20 @@ jQuery.each([ "Height", "Width" ], function( i, name ) {
8981
9231
  // innerHeight and innerWidth
8982
9232
  jQuery.fn[ "inner" + name ] = function() {
8983
9233
  var elem = this[0];
8984
- return elem && elem.style ?
9234
+ return elem ?
9235
+ elem.style ?
8985
9236
  parseFloat( jQuery.css( elem, type, "padding" ) ) :
9237
+ this[ type ]() :
8986
9238
  null;
8987
9239
  };
8988
9240
 
8989
9241
  // outerHeight and outerWidth
8990
9242
  jQuery.fn[ "outer" + name ] = function( margin ) {
8991
9243
  var elem = this[0];
8992
- return elem && elem.style ?
9244
+ return elem ?
9245
+ elem.style ?
8993
9246
  parseFloat( jQuery.css( elem, type, margin ? "margin" : "border" ) ) :
9247
+ this[ type ]() :
8994
9248
  null;
8995
9249
  };
8996
9250
 
@@ -9030,7 +9284,7 @@ jQuery.each([ "Height", "Width" ], function( i, name ) {
9030
9284
  var orig = jQuery.css( elem, type ),
9031
9285
  ret = parseFloat( orig );
9032
9286
 
9033
- return jQuery.isNaN( ret ) ? orig : ret;
9287
+ return jQuery.isNumeric( ret ) ? ret : orig;
9034
9288
 
9035
9289
  // Set the width or height on the element (default to pixels if value is unitless)
9036
9290
  } else {
@@ -9043,4 +9297,4 @@ jQuery.each([ "Height", "Width" ], function( i, name ) {
9043
9297
 
9044
9298
  // Expose jQuery to the global object
9045
9299
  window.jQuery = window.$ = jQuery;
9046
- })(window);
9300
+ })( window );