jquery-source 1.2.6 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,34 +1,36 @@
1
- (function(){
2
- /*
3
- * jQuery 1.2.6 - New Wave Javascript
1
+ /*!
2
+ * jQuery JavaScript Library v1.3
3
+ * http://jquery.com/
4
4
  *
5
- * Copyright (c) 2008 John Resig (jquery.com)
6
- * Dual licensed under the MIT (MIT-LICENSE.txt)
7
- * and GPL (GPL-LICENSE.txt) licenses.
5
+ * Copyright (c) 2009 John Resig
6
+ * Dual licensed under the MIT and GPL licenses.
7
+ * http://docs.jquery.com/License
8
8
  *
9
- * $Date: 2008/05/26 $
10
- * $Rev: 5685 $
9
+ * Date: 2009-01-13 12:50:31 -0500 (Tue, 13 Jan 2009)
10
+ * Revision: 6104
11
11
  */
12
+ (function(){
12
13
 
13
- // Map over jQuery in case of overwrite
14
- var _jQuery = window.jQuery,
15
- // Map over the $ in case of overwrite
16
- _$ = window.$;
17
-
18
- var jQuery = window.jQuery = window.$ = function( selector, context ) {
19
- // The jQuery object is actually just the init constructor 'enhanced'
20
- return new jQuery.fn.init( selector, context );
21
- };
22
-
23
- // A simple way to check for HTML strings or ID strings
24
- // (both of which we optimize for)
25
- var quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/,
26
-
27
- // Is it a simple selector
28
- isSimple = /^.[^:#\[\.]*$/,
14
+ var
15
+ // Will speed up references to window, and allows munging its name.
16
+ window = this,
17
+ // Will speed up references to undefined, and allows munging its name.
18
+ undefined,
19
+ // Map over jQuery in case of overwrite
20
+ _jQuery = window.jQuery,
21
+ // Map over the $ in case of overwrite
22
+ _$ = window.$,
23
+
24
+ jQuery = window.jQuery = window.$ = function( selector, context ) {
25
+ // The jQuery object is actually just the init constructor 'enhanced'
26
+ return new jQuery.fn.init( selector, context );
27
+ },
29
28
 
30
- // Will speed up references to undefined, and allows munging its name.
31
- undefined;
29
+ // A simple way to check for HTML strings or ID strings
30
+ // (both of which we optimize for)
31
+ quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/,
32
+ // Is it a simple selector
33
+ isSimple = /^.[^:#\[\.,]*$/;
32
34
 
33
35
  jQuery.fn = jQuery.prototype = {
34
36
  init: function( selector, context ) {
@@ -39,10 +41,11 @@ jQuery.fn = jQuery.prototype = {
39
41
  if ( selector.nodeType ) {
40
42
  this[0] = selector;
41
43
  this.length = 1;
44
+ this.context = selector;
42
45
  return this;
43
46
  }
44
47
  // Handle HTML strings
45
- if ( typeof selector == "string" ) {
48
+ if ( typeof selector === "string" ) {
46
49
  // Are we dealing with HTML string or an ID?
47
50
  var match = quickExpr.exec( selector );
48
51
 
@@ -65,7 +68,10 @@ jQuery.fn = jQuery.prototype = {
65
68
  return jQuery().find( selector );
66
69
 
67
70
  // Otherwise, we inject the element directly into the jQuery object
68
- return jQuery( elem );
71
+ var ret = jQuery( elem );
72
+ ret.context = document;
73
+ ret.selector = selector;
74
+ return ret;
69
75
  }
70
76
  selector = [];
71
77
  }
@@ -78,26 +84,32 @@ jQuery.fn = jQuery.prototype = {
78
84
  // HANDLE: $(function)
79
85
  // Shortcut for document ready
80
86
  } else if ( jQuery.isFunction( selector ) )
81
- return jQuery( document )[ jQuery.fn.ready ? "ready" : "load" ]( selector );
87
+ return jQuery( document ).ready( selector );
88
+
89
+ // Make sure that old selector state is passed along
90
+ if ( selector.selector && selector.context ) {
91
+ this.selector = selector.selector;
92
+ this.context = selector.context;
93
+ }
82
94
 
83
95
  return this.setArray(jQuery.makeArray(selector));
84
96
  },
85
97
 
98
+ // Start with an empty selector
99
+ selector: "",
100
+
86
101
  // The current version of jQuery being used
87
- jquery: "1.2.6",
102
+ jquery: "1.3",
88
103
 
89
104
  // The number of elements contained in the matched element set
90
105
  size: function() {
91
106
  return this.length;
92
107
  },
93
108
 
94
- // The number of elements contained in the matched element set
95
- length: 0,
96
-
97
109
  // Get the Nth element in the matched element set OR
98
110
  // Get the whole matched element set as a clean array
99
111
  get: function( num ) {
100
- return num == undefined ?
112
+ return num === undefined ?
101
113
 
102
114
  // Return a 'clean' array
103
115
  jQuery.makeArray( this ) :
@@ -108,13 +120,20 @@ jQuery.fn = jQuery.prototype = {
108
120
 
109
121
  // Take an array of elements and push it onto the stack
110
122
  // (returning the new matched element set)
111
- pushStack: function( elems ) {
123
+ pushStack: function( elems, name, selector ) {
112
124
  // Build a new jQuery matched element set
113
125
  var ret = jQuery( elems );
114
126
 
115
127
  // Add the old object onto the stack (as a reference)
116
128
  ret.prevObject = this;
117
129
 
130
+ ret.context = this.context;
131
+
132
+ if ( name === "find" )
133
+ ret.selector = this.selector + (this.selector ? " " : "") + selector;
134
+ else if ( name )
135
+ ret.selector = this.selector + "." + name + "(" + selector + ")";
136
+
118
137
  // Return the newly-formed element set
119
138
  return ret;
120
139
  },
@@ -141,8 +160,6 @@ jQuery.fn = jQuery.prototype = {
141
160
  // Determine the position of an element within
142
161
  // the matched set of elements
143
162
  index: function( elem ) {
144
- var ret = -1;
145
-
146
163
  // Locate the position of the desired element
147
164
  return jQuery.inArray(
148
165
  // If it receives a jQuery object, the first element is used
@@ -154,7 +171,7 @@ jQuery.fn = jQuery.prototype = {
154
171
  var options = name;
155
172
 
156
173
  // Look for the case where we're accessing a style value
157
- if ( name.constructor == String )
174
+ if ( typeof name === "string" )
158
175
  if ( value === undefined )
159
176
  return this[0] && jQuery[ type || "attr" ]( this[0], name );
160
177
 
@@ -184,7 +201,7 @@ jQuery.fn = jQuery.prototype = {
184
201
  },
185
202
 
186
203
  text: function( text ) {
187
- if ( typeof text != "object" && text != null )
204
+ if ( typeof text !== "object" && text != null )
188
205
  return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
189
206
 
190
207
  var ret = "";
@@ -202,20 +219,22 @@ jQuery.fn = jQuery.prototype = {
202
219
  },
203
220
 
204
221
  wrapAll: function( html ) {
205
- if ( this[0] )
222
+ if ( this[0] ) {
206
223
  // The elements to wrap the target around
207
- jQuery( html, this[0].ownerDocument )
208
- .clone()
209
- .insertBefore( this[0] )
210
- .map(function(){
211
- var elem = this;
224
+ var wrap = jQuery( html, this[0].ownerDocument ).clone();
225
+
226
+ if ( this[0].parentNode )
227
+ wrap.insertBefore( this[0] );
212
228
 
213
- while ( elem.firstChild )
214
- elem = elem.firstChild;
229
+ wrap.map(function(){
230
+ var elem = this;
215
231
 
216
- return elem;
217
- })
218
- .append(this);
232
+ while ( elem.firstChild )
233
+ elem = elem.firstChild;
234
+
235
+ return elem;
236
+ }).append(this);
237
+ }
219
238
 
220
239
  return this;
221
240
  },
@@ -233,27 +252,27 @@ jQuery.fn = jQuery.prototype = {
233
252
  },
234
253
 
235
254
  append: function() {
236
- return this.domManip(arguments, true, false, function(elem){
255
+ return this.domManip(arguments, true, function(elem){
237
256
  if (this.nodeType == 1)
238
257
  this.appendChild( elem );
239
258
  });
240
259
  },
241
260
 
242
261
  prepend: function() {
243
- return this.domManip(arguments, true, true, function(elem){
262
+ return this.domManip(arguments, true, function(elem){
244
263
  if (this.nodeType == 1)
245
264
  this.insertBefore( elem, this.firstChild );
246
265
  });
247
266
  },
248
267
 
249
268
  before: function() {
250
- return this.domManip(arguments, false, false, function(elem){
269
+ return this.domManip(arguments, false, function(elem){
251
270
  this.parentNode.insertBefore( elem, this );
252
271
  });
253
272
  },
254
273
 
255
274
  after: function() {
256
- return this.domManip(arguments, false, true, function(elem){
275
+ return this.domManip(arguments, false, function(elem){
257
276
  this.parentNode.insertBefore( elem, this.nextSibling );
258
277
  });
259
278
  },
@@ -262,20 +281,31 @@ jQuery.fn = jQuery.prototype = {
262
281
  return this.prevObject || jQuery( [] );
263
282
  },
264
283
 
284
+ // For internal use only.
285
+ // Behaves like an Array's .push method, not like a jQuery method.
286
+ push: [].push,
287
+
265
288
  find: function( selector ) {
266
- var elems = jQuery.map(this, function(elem){
267
- return jQuery.find( selector, elem );
268
- });
289
+ if ( this.length === 1 && !/,/.test(selector) ) {
290
+ var ret = this.pushStack( [], "find", selector );
291
+ ret.length = 0;
292
+ jQuery.find( selector, this[0], ret );
293
+ return ret;
294
+ } else {
295
+ var elems = jQuery.map(this, function(elem){
296
+ return jQuery.find( selector, elem );
297
+ });
269
298
 
270
- return this.pushStack( /[^+>] [^+>]/.test( selector ) || selector.indexOf("..") > -1 ?
271
- jQuery.unique( elems ) :
272
- elems );
299
+ return this.pushStack( /[^+>] [^+>]/.test( selector ) ?
300
+ jQuery.unique( elems ) :
301
+ elems, "find", selector );
302
+ }
273
303
  },
274
304
 
275
305
  clone: function( events ) {
276
306
  // Do the clone
277
307
  var ret = this.map(function(){
278
- if ( jQuery.browser.msie && !jQuery.isXMLDoc(this) ) {
308
+ if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) {
279
309
  // IE copies events bound via attachEvent when
280
310
  // using cloneNode. Calling detachEvent on the
281
311
  // clone will also remove the events from the orignal
@@ -296,7 +326,7 @@ jQuery.fn = jQuery.prototype = {
296
326
  // removeData doesn't work here, IE removes it from the original as well
297
327
  // this is primarily for IE but the data expando shouldn't be copied over in any browser
298
328
  var clone = ret.find("*").andSelf().each(function(){
299
- if ( this[ expando ] != undefined )
329
+ if ( this[ expando ] !== undefined )
300
330
  this[ expando ] = null;
301
331
  });
302
332
 
@@ -323,14 +353,29 @@ jQuery.fn = jQuery.prototype = {
323
353
  return selector.call( elem, i );
324
354
  }) ||
325
355
 
326
- jQuery.multiFilter( selector, this ) );
356
+ jQuery.multiFilter( selector, jQuery.grep(this, function(elem){
357
+ return elem.nodeType === 1;
358
+ }) ), "filter", selector );
359
+ },
360
+
361
+ closest: function( selector ) {
362
+ var pos = jQuery.expr.match.POS.test( selector ) ? jQuery(selector) : null;
363
+
364
+ return this.map(function(){
365
+ var cur = this;
366
+ while ( cur && cur.ownerDocument ) {
367
+ if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selector) )
368
+ return cur;
369
+ cur = cur.parentNode;
370
+ }
371
+ });
327
372
  },
328
373
 
329
374
  not: function( selector ) {
330
- if ( selector.constructor == String )
375
+ if ( typeof selector === "string" )
331
376
  // test special case where just one selector is passed in
332
377
  if ( isSimple.test( selector ) )
333
- return this.pushStack( jQuery.multiFilter( selector, this, true ) );
378
+ return this.pushStack( jQuery.multiFilter( selector, this, true ), "not", selector );
334
379
  else
335
380
  selector = jQuery.multiFilter( selector, this );
336
381
 
@@ -343,7 +388,7 @@ jQuery.fn = jQuery.prototype = {
343
388
  add: function( selector ) {
344
389
  return this.pushStack( jQuery.unique( jQuery.merge(
345
390
  this.get(),
346
- typeof selector == 'string' ?
391
+ typeof selector === "string" ?
347
392
  jQuery( selector ) :
348
393
  jQuery.makeArray( selector )
349
394
  )));
@@ -354,15 +399,17 @@ jQuery.fn = jQuery.prototype = {
354
399
  },
355
400
 
356
401
  hasClass: function( selector ) {
357
- return this.is( "." + selector );
402
+ return !!selector && this.is( "." + selector );
358
403
  },
359
404
 
360
405
  val: function( value ) {
361
- if ( value == undefined ) {
362
-
363
- if ( this.length ) {
364
- var elem = this[0];
406
+ if ( value === undefined ) {
407
+ var elem = this[0];
365
408
 
409
+ if ( elem ) {
410
+ if( jQuery.nodeName( elem, 'option' ) )
411
+ return (elem.attributes.value || {}).specified ? elem.value : elem.text;
412
+
366
413
  // We need to handle select boxes special
367
414
  if ( jQuery.nodeName( elem, "select" ) ) {
368
415
  var index = elem.selectedIndex,
@@ -380,7 +427,7 @@ jQuery.fn = jQuery.prototype = {
380
427
 
381
428
  if ( option.selected ) {
382
429
  // Get the specifc value for the option
383
- value = jQuery.browser.msie && !option.attributes.value.specified ? option.text : option.value;
430
+ value = jQuery(option).val();
384
431
 
385
432
  // We don't need an array for one selects
386
433
  if ( one )
@@ -391,25 +438,25 @@ jQuery.fn = jQuery.prototype = {
391
438
  }
392
439
  }
393
440
 
394
- return values;
441
+ return values;
442
+ }
395
443
 
396
444
  // Everything else, we just grab the value
397
- } else
398
- return (this[0].value || "").replace(/\r/g, "");
445
+ return (elem.value || "").replace(/\r/g, "");
399
446
 
400
447
  }
401
448
 
402
449
  return undefined;
403
450
  }
404
451
 
405
- if( value.constructor == Number )
452
+ if ( typeof value === "number" )
406
453
  value += '';
407
454
 
408
455
  return this.each(function(){
409
456
  if ( this.nodeType != 1 )
410
457
  return;
411
458
 
412
- if ( value.constructor == Array && /radio|checkbox/.test( this.type ) )
459
+ if ( jQuery.isArray(value) && /radio|checkbox/.test( this.type ) )
413
460
  this.checked = (jQuery.inArray(this.value, value) >= 0 ||
414
461
  jQuery.inArray(this.name, value) >= 0);
415
462
 
@@ -430,7 +477,7 @@ jQuery.fn = jQuery.prototype = {
430
477
  },
431
478
 
432
479
  html: function( value ) {
433
- return value == undefined ?
480
+ return value === undefined ?
434
481
  (this[0] ?
435
482
  this[0].innerHTML :
436
483
  null) :
@@ -442,11 +489,12 @@ jQuery.fn = jQuery.prototype = {
442
489
  },
443
490
 
444
491
  eq: function( i ) {
445
- return this.slice( i, i + 1 );
492
+ return this.slice( i, +i + 1 );
446
493
  },
447
494
 
448
495
  slice: function() {
449
- return this.pushStack( Array.prototype.slice.apply( this, arguments ) );
496
+ return this.pushStack( Array.prototype.slice.apply( this, arguments ),
497
+ "slice", Array.prototype.slice.call(arguments).join(",") );
450
498
  },
451
499
 
452
500
  map: function( callback ) {
@@ -459,69 +507,29 @@ jQuery.fn = jQuery.prototype = {
459
507
  return this.add( this.prevObject );
460
508
  },
461
509
 
462
- data: function( key, value ){
463
- var parts = key.split(".");
464
- parts[1] = parts[1] ? "." + parts[1] : "";
465
-
466
- if ( value === undefined ) {
467
- var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
468
-
469
- if ( data === undefined && this.length )
470
- data = jQuery.data( this[0], key );
471
-
472
- return data === undefined && parts[1] ?
473
- this.data( parts[0] ) :
474
- data;
475
- } else
476
- return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function(){
477
- jQuery.data( this, key, value );
478
- });
479
- },
480
-
481
- removeData: function( key ){
482
- return this.each(function(){
483
- jQuery.removeData( this, key );
484
- });
485
- },
486
-
487
- domManip: function( args, table, reverse, callback ) {
488
- var clone = this.length > 1, elems;
489
-
490
- return this.each(function(){
491
- if ( !elems ) {
492
- elems = jQuery.clean( args, this.ownerDocument );
493
-
494
- if ( reverse )
495
- elems.reverse();
496
- }
497
-
498
- var obj = this;
499
-
500
- if ( table && jQuery.nodeName( this, "table" ) && jQuery.nodeName( elems[0], "tr" ) )
501
- obj = this.getElementsByTagName("tbody")[0] || this.appendChild( this.ownerDocument.createElement("tbody") );
502
-
503
- var scripts = jQuery( [] );
504
-
505
- jQuery.each(elems, function(){
506
- var elem = clone ?
507
- jQuery( this ).clone( true )[0] :
508
- this;
509
-
510
- // execute all scripts after the elements have been injected
511
- if ( jQuery.nodeName( elem, "script" ) )
512
- scripts = scripts.add( elem );
513
- else {
514
- // Remove any inner scripts for later evaluation
515
- if ( elem.nodeType == 1 )
516
- scripts = scripts.add( jQuery( "script", elem ).remove() );
517
-
518
- // Inject the elements into the document
519
- callback.call( obj, elem );
520
- }
521
- });
510
+ domManip: function( args, table, callback ) {
511
+ if ( this[0] ) {
512
+ var fragment = (this[0].ownerDocument || this[0]).createDocumentFragment(),
513
+ scripts = jQuery.clean( args, (this[0].ownerDocument || this[0]), fragment ),
514
+ first = fragment.firstChild,
515
+ extra = this.length > 1 ? fragment.cloneNode(true) : fragment;
516
+
517
+ if ( first )
518
+ for ( var i = 0, l = this.length; i < l; i++ )
519
+ callback.call( root(this[i], first), i > 0 ? extra.cloneNode(true) : fragment );
520
+
521
+ if ( scripts )
522
+ jQuery.each( scripts, evalScript );
523
+ }
522
524
 
523
- scripts.each( evalScript );
524
- });
525
+ return this;
526
+
527
+ function root( elem, cur ) {
528
+ return table && jQuery.nodeName(elem, "table") && jQuery.nodeName(cur, "tr") ?
529
+ (elem.getElementsByTagName("tbody")[0] ||
530
+ elem.appendChild(elem.ownerDocument.createElement("tbody"))) :
531
+ elem;
532
+ }
525
533
  }
526
534
  };
527
535
 
@@ -552,7 +560,7 @@ jQuery.extend = jQuery.fn.extend = function() {
552
560
  var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options;
553
561
 
554
562
  // Handle a deep copy situation
555
- if ( target.constructor == Boolean ) {
563
+ if ( typeof target === "boolean" ) {
556
564
  deep = target;
557
565
  target = arguments[1] || {};
558
566
  // skip the boolean and the target
@@ -560,7 +568,7 @@ jQuery.extend = jQuery.fn.extend = function() {
560
568
  }
561
569
 
562
570
  // Handle case when target is a string or something (possible in deep copy)
563
- if ( typeof target != "object" && typeof target != "function" )
571
+ if ( typeof target !== "object" && !jQuery.isFunction(target) )
564
572
  target = {};
565
573
 
566
574
  // extend jQuery itself if only one argument is passed
@@ -581,7 +589,7 @@ jQuery.extend = jQuery.fn.extend = function() {
581
589
  continue;
582
590
 
583
591
  // Recurse if we're merging object values
584
- if ( deep && copy && typeof copy == "object" && !copy.nodeType )
592
+ if ( deep && copy && typeof copy === "object" && !copy.nodeType )
585
593
  target[ name ] = jQuery.extend( deep,
586
594
  // Never move original objects, clone them
587
595
  src || ( copy.length != null ? [ ] : { } )
@@ -597,11 +605,11 @@ jQuery.extend = jQuery.fn.extend = function() {
597
605
  return target;
598
606
  };
599
607
 
600
- var expando = "jQuery" + now(), uuid = 0, windowData = {},
601
- // exclude the following css properties to add px
602
- exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i,
608
+ // exclude the following css properties to add px
609
+ var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i,
603
610
  // cache defaultView
604
- defaultView = document.defaultView || {};
611
+ defaultView = document.defaultView || {},
612
+ toString = Object.prototype.toString;
605
613
 
606
614
  jQuery.extend({
607
615
  noConflict: function( deep ) {
@@ -613,10 +621,15 @@ jQuery.extend({
613
621
  return jQuery;
614
622
  },
615
623
 
616
- // See test/unit/core.js for details concerning this function.
617
- isFunction: function( fn ) {
618
- return !!fn && typeof fn != "string" && !fn.nodeName &&
619
- fn.constructor != Array && /^[\s[]?function/.test( fn + "" );
624
+ // See test/unit/core.js for details concerning isFunction.
625
+ // Since version 1.3, DOM methods and functions like alert
626
+ // aren't supported. They return false on IE (#2968).
627
+ isFunction: function( obj ) {
628
+ return toString.call(obj) === "[object Function]";
629
+ },
630
+
631
+ isArray: function( obj ) {
632
+ return toString.call(obj) === "[object Array]";
620
633
  },
621
634
 
622
635
  // check if an element is in a (or is an) XML document
@@ -636,10 +649,10 @@ jQuery.extend({
636
649
  script = document.createElement("script");
637
650
 
638
651
  script.type = "text/javascript";
639
- if ( jQuery.browser.msie )
640
- script.text = data;
641
- else
652
+ if ( jQuery.support.scriptEval )
642
653
  script.appendChild( document.createTextNode( data ) );
654
+ else
655
+ script.text = data;
643
656
 
644
657
  // Use insertBefore instead of appendChild to circumvent an IE6 bug.
645
658
  // This arises when a base node is used (#2709).
@@ -652,80 +665,12 @@ jQuery.extend({
652
665
  return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase();
653
666
  },
654
667
 
655
- cache: {},
656
-
657
- data: function( elem, name, data ) {
658
- elem = elem == window ?
659
- windowData :
660
- elem;
661
-
662
- var id = elem[ expando ];
663
-
664
- // Compute a unique ID for the element
665
- if ( !id )
666
- id = elem[ expando ] = ++uuid;
667
-
668
- // Only generate the data cache if we're
669
- // trying to access or manipulate it
670
- if ( name && !jQuery.cache[ id ] )
671
- jQuery.cache[ id ] = {};
672
-
673
- // Prevent overriding the named cache with undefined values
674
- if ( data !== undefined )
675
- jQuery.cache[ id ][ name ] = data;
676
-
677
- // Return the named cache data, or the ID for the element
678
- return name ?
679
- jQuery.cache[ id ][ name ] :
680
- id;
681
- },
682
-
683
- removeData: function( elem, name ) {
684
- elem = elem == window ?
685
- windowData :
686
- elem;
687
-
688
- var id = elem[ expando ];
689
-
690
- // If we want to remove a specific section of the element's data
691
- if ( name ) {
692
- if ( jQuery.cache[ id ] ) {
693
- // Remove the section of cache data
694
- delete jQuery.cache[ id ][ name ];
695
-
696
- // If we've removed all the data, remove the element's cache
697
- name = "";
698
-
699
- for ( name in jQuery.cache[ id ] )
700
- break;
701
-
702
- if ( !name )
703
- jQuery.removeData( elem );
704
- }
705
-
706
- // Otherwise, we want to remove all of the element's data
707
- } else {
708
- // Clean up the element expando
709
- try {
710
- delete elem[ expando ];
711
- } catch(e){
712
- // IE has trouble directly removing the expando
713
- // but it's ok with using removeAttribute
714
- if ( elem.removeAttribute )
715
- elem.removeAttribute( expando );
716
- }
717
-
718
- // Completely remove the data cache
719
- delete jQuery.cache[ id ];
720
- }
721
- },
722
-
723
668
  // args is for internal usage only
724
669
  each: function( object, callback, args ) {
725
670
  var name, i = 0, length = object.length;
726
671
 
727
672
  if ( args ) {
728
- if ( length == undefined ) {
673
+ if ( length === undefined ) {
729
674
  for ( name in object )
730
675
  if ( callback.apply( object[ name ], args ) === false )
731
676
  break;
@@ -736,7 +681,7 @@ jQuery.extend({
736
681
 
737
682
  // A special, fast, case for the most common use of each
738
683
  } else {
739
- if ( length == undefined ) {
684
+ if ( length === undefined ) {
740
685
  for ( name in object )
741
686
  if ( callback.call( object[ name ], name, object[ name ] ) === false )
742
687
  break;
@@ -754,7 +699,7 @@ jQuery.extend({
754
699
  value = value.call( elem, i );
755
700
 
756
701
  // Handle passing in a number to a CSS property
757
- return value && value.constructor == Number && type == "curCSS" && !exclude.test( name ) ?
702
+ return typeof value === "number" && type == "curCSS" && !exclude.test( name ) ?
758
703
  value + "px" :
759
704
  value;
760
705
  },
@@ -771,7 +716,7 @@ jQuery.extend({
771
716
  // internal only, use removeClass("class")
772
717
  remove: function( elem, classNames ) {
773
718
  if (elem.nodeType == 1)
774
- elem.className = classNames != undefined ?
719
+ elem.className = classNames !== undefined ?
775
720
  jQuery.grep(elem.className.split(/\s+/), function(className){
776
721
  return !jQuery.className.has( classNames, className );
777
722
  }).join(" ") :
@@ -828,30 +773,14 @@ jQuery.extend({
828
773
  curCSS: function( elem, name, force ) {
829
774
  var ret, style = elem.style;
830
775
 
831
- // A helper method for determining if an element's values are broken
832
- function color( elem ) {
833
- if ( !jQuery.browser.safari )
834
- return false;
835
-
836
- // defaultView is cached
837
- var ret = defaultView.getComputedStyle( elem, null );
838
- return !ret || ret.getPropertyValue("color") == "";
839
- }
840
-
841
776
  // We need to handle opacity special in IE
842
- if ( name == "opacity" && jQuery.browser.msie ) {
777
+ if ( name == "opacity" && !jQuery.support.opacity ) {
843
778
  ret = jQuery.attr( style, "opacity" );
844
779
 
845
780
  return ret == "" ?
846
781
  "1" :
847
782
  ret;
848
783
  }
849
- // Opera sometimes will give the wrong display answer, this fixes it, see #2037
850
- if ( jQuery.browser.opera && name == "display" ) {
851
- var save = style.outline;
852
- style.outline = "0 solid black";
853
- style.outline = save;
854
- }
855
784
 
856
785
  // Make sure we're using the right name for getting the float value
857
786
  if ( name.match( /float/i ) )
@@ -870,38 +799,9 @@ jQuery.extend({
870
799
 
871
800
  var computedStyle = defaultView.getComputedStyle( elem, null );
872
801
 
873
- if ( computedStyle && !color( elem ) )
802
+ if ( computedStyle )
874
803
  ret = computedStyle.getPropertyValue( name );
875
804
 
876
- // If the element isn't reporting its values properly in Safari
877
- // then some display: none elements are involved
878
- else {
879
- var swap = [], stack = [], a = elem, i = 0;
880
-
881
- // Locate all of the parent display: none elements
882
- for ( ; a && color(a); a = a.parentNode )
883
- stack.unshift(a);
884
-
885
- // Go through and make them visible, but in reverse
886
- // (It would be better if we knew the exact display type that they had)
887
- for ( ; i < stack.length; i++ )
888
- if ( color( stack[ i ] ) ) {
889
- swap[ i ] = stack[ i ].style.display;
890
- stack[ i ].style.display = "block";
891
- }
892
-
893
- // Since we flip the display style, we have to handle that
894
- // one special, otherwise get the value
895
- ret = name == "display" && swap[ stack.length - 1 ] != null ?
896
- "none" :
897
- ( computedStyle && computedStyle.getPropertyValue( name ) ) || "";
898
-
899
- // Finally, revert the display styles back
900
- for ( i = 0; i < swap.length; i++ )
901
- if ( swap[ i ] != null )
902
- stack[ i ].style.display = swap[ i ];
903
- }
904
-
905
805
  // We should always get a number back from opacity
906
806
  if ( name == "opacity" && ret == "" )
907
807
  ret = "1";
@@ -936,22 +836,32 @@ jQuery.extend({
936
836
  return ret;
937
837
  },
938
838
 
939
- clean: function( elems, context ) {
940
- var ret = [];
839
+ clean: function( elems, context, fragment ) {
941
840
  context = context || document;
841
+
942
842
  // !context.createElement fails in IE with an error but returns typeof 'object'
943
- if (typeof context.createElement == 'undefined')
843
+ if ( typeof context.createElement === "undefined" )
944
844
  context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
945
845
 
846
+ // If a single string is passed in and it's a single tag
847
+ // just do a createElement and skip the rest
848
+ if ( !fragment && elems.length === 1 && typeof elems[0] === "string" ) {
849
+ var match = /^<(\w+)\s*\/?>$/.exec(elems[0]);
850
+ if ( match )
851
+ return [ context.createElement( match[1] ) ];
852
+ }
853
+
854
+ var ret = [], scripts = [], div = context.createElement("div");
855
+
946
856
  jQuery.each(elems, function(i, elem){
857
+ if ( typeof elem === "number" )
858
+ elem += '';
859
+
947
860
  if ( !elem )
948
861
  return;
949
862
 
950
- if ( elem.constructor == Number )
951
- elem += '';
952
-
953
863
  // Convert html string into DOM nodes
954
- if ( typeof elem == "string" ) {
864
+ if ( typeof elem === "string" ) {
955
865
  // Fix "XHTML"-style tags in all browsers
956
866
  elem = elem.replace(/(<(\w+)[^>]*?)\/>/g, function(all, front, tag){
957
867
  return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i) ?
@@ -960,7 +870,7 @@ jQuery.extend({
960
870
  });
961
871
 
962
872
  // Trim whitespace, otherwise indexOf won't work as expected
963
- var tags = jQuery.trim( elem ).toLowerCase(), div = context.createElement("div");
873
+ var tags = jQuery.trim( elem ).toLowerCase();
964
874
 
965
875
  var wrap =
966
876
  // option or optgroup
@@ -984,7 +894,7 @@ jQuery.extend({
984
894
  [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ] ||
985
895
 
986
896
  // IE can't serialize <link> and <script> tags normally
987
- jQuery.browser.msie &&
897
+ !jQuery.support.htmlSerialize &&
988
898
  [ 1, "div<div>", "</div>" ] ||
989
899
 
990
900
  [ 0, "", "" ];
@@ -997,7 +907,7 @@ jQuery.extend({
997
907
  div = div.lastChild;
998
908
 
999
909
  // Remove IE's autoinserted <tbody> from table fragments
1000
- if ( jQuery.browser.msie ) {
910
+ if ( !jQuery.support.tbody ) {
1001
911
 
1002
912
  // String was a <table>, *may* have spurious <tbody>
1003
913
  var tbody = !tags.indexOf("<table") && tags.indexOf("<tbody") < 0 ?
@@ -1012,26 +922,36 @@ jQuery.extend({
1012
922
  if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length )
1013
923
  tbody[ j ].parentNode.removeChild( tbody[ j ] );
1014
924
 
1015
- // IE completely kills leading whitespace when innerHTML is used
1016
- if ( /^\s/.test( elem ) )
1017
- div.insertBefore( context.createTextNode( elem.match(/^\s*/)[0] ), div.firstChild );
1018
-
1019
- }
925
+ }
1020
926
 
927
+ // IE completely kills leading whitespace when innerHTML is used
928
+ if ( !jQuery.support.leadingWhitespace && /^\s/.test( elem ) )
929
+ div.insertBefore( context.createTextNode( elem.match(/^\s*/)[0] ), div.firstChild );
930
+
1021
931
  elem = jQuery.makeArray( div.childNodes );
1022
932
  }
1023
933
 
1024
- if ( elem.length === 0 && (!jQuery.nodeName( elem, "form" ) && !jQuery.nodeName( elem, "select" )) )
1025
- return;
1026
-
1027
- if ( elem[0] == undefined || jQuery.nodeName( elem, "form" ) || elem.options )
934
+ if ( elem.nodeType )
1028
935
  ret.push( elem );
1029
-
1030
936
  else
1031
937
  ret = jQuery.merge( ret, elem );
1032
938
 
1033
939
  });
1034
940
 
941
+ if ( fragment ) {
942
+ for ( var i = 0; ret[i]; i++ ) {
943
+ if ( jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
944
+ scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
945
+ } else {
946
+ if ( ret[i].nodeType === 1 )
947
+ ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) );
948
+ fragment.appendChild( ret[i] );
949
+ }
950
+ }
951
+
952
+ return scripts;
953
+ }
954
+
1035
955
  return ret;
1036
956
  },
1037
957
 
@@ -1042,8 +962,7 @@ jQuery.extend({
1042
962
 
1043
963
  var notxml = !jQuery.isXMLDoc( elem ),
1044
964
  // Whether we are setting (or getting)
1045
- set = value !== undefined,
1046
- msie = jQuery.browser.msie;
965
+ set = value !== undefined;
1047
966
 
1048
967
  // Try to normalize/fix the name
1049
968
  name = notxml && jQuery.props[ name ] || name;
@@ -1057,7 +976,7 @@ jQuery.extend({
1057
976
 
1058
977
  // Safari mis-reports the default selected property of a hidden option
1059
978
  // Accessing the parent's selectedIndex property fixes it
1060
- if ( name == "selected" && jQuery.browser.safari )
979
+ if ( name == "selected" && elem.parentNode )
1061
980
  elem.parentNode.selectedIndex;
1062
981
 
1063
982
  // If applicable, access the attribute via the DOM 0 way
@@ -1074,17 +993,28 @@ jQuery.extend({
1074
993
  if( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) )
1075
994
  return elem.getAttributeNode( name ).nodeValue;
1076
995
 
996
+ // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
997
+ // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
998
+ if ( name == "tabIndex" ) {
999
+ var attributeNode = elem.getAttributeNode( "tabIndex" );
1000
+ return attributeNode && attributeNode.specified
1001
+ ? attributeNode.value
1002
+ : elem.nodeName.match(/^(a|area|button|input|object|select|textarea)$/i)
1003
+ ? 0
1004
+ : undefined;
1005
+ }
1006
+
1077
1007
  return elem[ name ];
1078
1008
  }
1079
1009
 
1080
- if ( msie && notxml && name == "style" )
1010
+ if ( !jQuery.support.style && notxml && name == "style" )
1081
1011
  return jQuery.attr( elem.style, "cssText", value );
1082
1012
 
1083
1013
  if ( set )
1084
1014
  // convert the value to a string (all browsers do this but IE) see #1070
1085
1015
  elem.setAttribute( name, "" + value );
1086
1016
 
1087
- var attr = msie && notxml && special
1017
+ var attr = !jQuery.support.hrefNormalized && notxml && special
1088
1018
  // Some attributes require a special call on IE
1089
1019
  ? elem.getAttribute( name, 2 )
1090
1020
  : elem.getAttribute( name );
@@ -1096,7 +1026,7 @@ jQuery.extend({
1096
1026
  // elem is actually elem.style ... set the style
1097
1027
 
1098
1028
  // IE uses filters for opacity
1099
- if ( msie && name == "opacity" ) {
1029
+ if ( !jQuery.support.opacity && name == "opacity" ) {
1100
1030
  if ( set ) {
1101
1031
  // IE has trouble with opacity if it does not have layout
1102
1032
  // Force it by setting the zoom level
@@ -1131,8 +1061,8 @@ jQuery.extend({
1131
1061
 
1132
1062
  if( array != null ){
1133
1063
  var i = array.length;
1134
- //the window, strings and functions also have 'length'
1135
- if( i == null || array.split || array.setInterval || array.call )
1064
+ // The window, strings (and functions) also have 'length'
1065
+ if( i == null || typeof array === "string" || jQuery.isFunction(array) || array.setInterval )
1136
1066
  ret[0] = array;
1137
1067
  else
1138
1068
  while( i )
@@ -1157,13 +1087,13 @@ jQuery.extend({
1157
1087
  var i = 0, elem, pos = first.length;
1158
1088
  // Also, we need to make sure that the correct elements are being returned
1159
1089
  // (IE returns comment nodes in a '*' query)
1160
- if ( jQuery.browser.msie ) {
1161
- while ( elem = second[ i++ ] )
1090
+ if ( !jQuery.support.getAll ) {
1091
+ while ( (elem = second[ i++ ]) != null )
1162
1092
  if ( elem.nodeType != 8 )
1163
1093
  first[ pos++ ] = elem;
1164
1094
 
1165
1095
  } else
1166
- while ( elem = second[ i++ ] )
1096
+ while ( (elem = second[ i++ ]) != null )
1167
1097
  first[ pos++ ] = elem;
1168
1098
 
1169
1099
  return first;
@@ -1218,37 +1148,21 @@ jQuery.extend({
1218
1148
  }
1219
1149
  });
1220
1150
 
1151
+ // Use of jQuery.browser is deprecated.
1152
+ // It's included for backwards compatibility and plugins,
1153
+ // although they should work to migrate away.
1154
+
1221
1155
  var userAgent = navigator.userAgent.toLowerCase();
1222
1156
 
1223
1157
  // Figure out what browser is being used
1224
1158
  jQuery.browser = {
1225
- version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1],
1159
+ version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[1],
1226
1160
  safari: /webkit/.test( userAgent ),
1227
1161
  opera: /opera/.test( userAgent ),
1228
1162
  msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),
1229
1163
  mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent )
1230
1164
  };
1231
1165
 
1232
- var styleFloat = jQuery.browser.msie ?
1233
- "styleFloat" :
1234
- "cssFloat";
1235
-
1236
- jQuery.extend({
1237
- // Check to see if the W3C box model is being used
1238
- boxModel: !jQuery.browser.msie || document.compatMode == "CSS1Compat",
1239
-
1240
- props: {
1241
- "for": "htmlFor",
1242
- "class": "className",
1243
- "float": styleFloat,
1244
- cssFloat: styleFloat,
1245
- styleFloat: styleFloat,
1246
- readonly: "readOnly",
1247
- maxlength: "maxLength",
1248
- cellspacing: "cellSpacing"
1249
- }
1250
- });
1251
-
1252
1166
  jQuery.each({
1253
1167
  parent: function(elem){return elem.parentNode;},
1254
1168
  parents: function(elem){return jQuery.dir(elem,"parentNode");},
@@ -1266,7 +1180,7 @@ jQuery.each({
1266
1180
  if ( selector && typeof selector == "string" )
1267
1181
  ret = jQuery.multiFilter( selector, ret );
1268
1182
 
1269
- return this.pushStack( jQuery.unique( ret ) );
1183
+ return this.pushStack( jQuery.unique( ret ), name, selector );
1270
1184
  };
1271
1185
  });
1272
1186
 
@@ -1302,14 +1216,16 @@ jQuery.each({
1302
1216
  jQuery.className.remove( this, classNames );
1303
1217
  },
1304
1218
 
1305
- toggleClass: function( classNames ) {
1306
- jQuery.className[ jQuery.className.has( this, classNames ) ? "remove" : "add" ]( this, classNames );
1219
+ toggleClass: function( classNames, state ) {
1220
+ if( typeof state !== "boolean" )
1221
+ state = !jQuery.className.has( this, classNames );
1222
+ jQuery.className[ state ? "add" : "remove" ]( this, classNames );
1307
1223
  },
1308
1224
 
1309
1225
  remove: function( selector ) {
1310
- if ( !selector || jQuery.filter( selector, [ this ] ).r.length ) {
1226
+ if ( !selector || jQuery.filter( selector, [ this ] ).length ) {
1311
1227
  // Prevent memory leaks
1312
- jQuery( "*", this ).add(this).each(function(){
1228
+ jQuery( "*", this ).add([this]).each(function(){
1313
1229
  jQuery.event.remove(this);
1314
1230
  jQuery.removeData(this);
1315
1231
  });
@@ -1332,489 +1248,1063 @@ jQuery.each({
1332
1248
  };
1333
1249
  });
1334
1250
 
1335
- jQuery.each([ "Height", "Width" ], function(i, name){
1336
- var type = name.toLowerCase();
1337
-
1338
- jQuery.fn[ type ] = function( size ) {
1339
- // Get window width or height
1340
- return this[0] == window ?
1341
- // Opera reports document.body.client[Width/Height] properly in both quirks and standards
1342
- jQuery.browser.opera && document.body[ "client" + name ] ||
1343
-
1344
- // Safari reports inner[Width/Height] just fine (Mozilla and Opera include scroll bar widths)
1345
- jQuery.browser.safari && window[ "inner" + name ] ||
1346
-
1347
- // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
1348
- document.compatMode == "CSS1Compat" && document.documentElement[ "client" + name ] || document.body[ "client" + name ] :
1349
-
1350
- // Get document width or height
1351
- this[0] == document ?
1352
- // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
1353
- Math.max(
1354
- Math.max(document.body["scroll" + name], document.documentElement["scroll" + name]),
1355
- Math.max(document.body["offset" + name], document.documentElement["offset" + name])
1356
- ) :
1357
-
1358
- // Get or set width or height on the element
1359
- size == undefined ?
1360
- // Get width or height on the element
1361
- (this.length ? jQuery.css( this[0], type ) : null) :
1362
-
1363
- // Set the width or height on the element (default to pixels if value is unitless)
1364
- this.css( type, size.constructor == String ? size : size + "px" );
1365
- };
1366
- });
1367
-
1368
1251
  // Helper function used by the dimensions and offset modules
1369
1252
  function num(elem, prop) {
1370
1253
  return elem[0] && parseInt( jQuery.curCSS(elem[0], prop, true), 10 ) || 0;
1371
- }var chars = jQuery.browser.safari && parseInt(jQuery.browser.version) < 417 ?
1372
- "(?:[\\w*_-]|\\\\.)" :
1373
- "(?:[\\w\u0128-\uFFFF*_-]|\\\\.)",
1374
- quickChild = new RegExp("^>\\s*(" + chars + "+)"),
1375
- quickID = new RegExp("^(" + chars + "+)(#)(" + chars + "+)"),
1376
- quickClass = new RegExp("^([#.]?)(" + chars + "*)");
1254
+ }
1255
+ var expando = "jQuery" + now(), uuid = 0, windowData = {};
1377
1256
 
1378
1257
  jQuery.extend({
1379
- expr: {
1380
- "": function(a,i,m){return m[2]=="*"||jQuery.nodeName(a,m[2]);},
1381
- "#": function(a,i,m){return a.getAttribute("id")==m[2];},
1382
- ":": {
1383
- // Position Checks
1384
- lt: function(a,i,m){return i<m[3]-0;},
1385
- gt: function(a,i,m){return i>m[3]-0;},
1386
- nth: function(a,i,m){return m[3]-0==i;},
1387
- eq: function(a,i,m){return m[3]-0==i;},
1388
- first: function(a,i){return i==0;},
1389
- last: function(a,i,m,r){return i==r.length-1;},
1390
- even: function(a,i){return i%2==0;},
1391
- odd: function(a,i){return i%2;},
1392
-
1393
- // Child Checks
1394
- "first-child": function(a){return a.parentNode.getElementsByTagName("*")[0]==a;},
1395
- "last-child": function(a){return jQuery.nth(a.parentNode.lastChild,1,"previousSibling")==a;},
1396
- "only-child": function(a){return !jQuery.nth(a.parentNode.lastChild,2,"previousSibling");},
1397
-
1398
- // Parent Checks
1399
- parent: function(a){return a.firstChild;},
1400
- empty: function(a){return !a.firstChild;},
1401
-
1402
- // Text Check
1403
- contains: function(a,i,m){return (a.textContent||a.innerText||jQuery(a).text()||"").indexOf(m[3])>=0;},
1404
-
1405
- // Visibility
1406
- visible: function(a){return "hidden"!=a.type&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden";},
1407
- hidden: function(a){return "hidden"==a.type||jQuery.css(a,"display")=="none"||jQuery.css(a,"visibility")=="hidden";},
1408
-
1409
- // Form attributes
1410
- enabled: function(a){return !a.disabled;},
1411
- disabled: function(a){return a.disabled;},
1412
- checked: function(a){return a.checked;},
1413
- selected: function(a){return a.selected||jQuery.attr(a,"selected");},
1414
-
1415
- // Form elements
1416
- text: function(a){return "text"==a.type;},
1417
- radio: function(a){return "radio"==a.type;},
1418
- checkbox: function(a){return "checkbox"==a.type;},
1419
- file: function(a){return "file"==a.type;},
1420
- password: function(a){return "password"==a.type;},
1421
- submit: function(a){return "submit"==a.type;},
1422
- image: function(a){return "image"==a.type;},
1423
- reset: function(a){return "reset"==a.type;},
1424
- button: function(a){return "button"==a.type||jQuery.nodeName(a,"button");},
1425
- input: function(a){return /input|select|textarea|button/i.test(a.nodeName);},
1426
-
1427
- // :has()
1428
- has: function(a,i,m){return jQuery.find(m[3],a).length;},
1429
-
1430
- // :header
1431
- header: function(a){return /h\d/i.test(a.nodeName);},
1432
-
1433
- // :animated
1434
- animated: function(a){return jQuery.grep(jQuery.timers,function(fn){return a==fn.elem;}).length;}
1435
- }
1436
- },
1437
-
1438
- // The regular expressions that power the parsing engine
1439
- parse: [
1440
- // Match: [@value='test'], [@foo]
1441
- /^(\[) *@?([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/,
1442
-
1443
- // Match: :contains('foo')
1444
- /^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/,
1445
-
1446
- // Match: :even, :last-child, #id, .class
1447
- new RegExp("^([:.#]*)(" + chars + "+)")
1448
- ],
1449
-
1450
- multiFilter: function( expr, elems, not ) {
1451
- var old, cur = [];
1452
-
1453
- while ( expr && expr != old ) {
1454
- old = expr;
1455
- var f = jQuery.filter( expr, elems, not );
1456
- expr = f.t.replace(/^\s*,\s*/, "" );
1457
- cur = not ? elems = f.r : jQuery.merge( cur, f.r );
1458
- }
1459
-
1460
- return cur;
1461
- },
1462
-
1463
- find: function( t, context ) {
1464
- // Quickly handle non-string expressions
1465
- if ( typeof t != "string" )
1466
- return [ t ];
1467
-
1468
- // check to make sure context is a DOM element or a document
1469
- if ( context && context.nodeType != 1 && context.nodeType != 9)
1470
- return [ ];
1471
-
1472
- // Set the correct context (if none is provided)
1473
- context = context || document;
1474
-
1475
- // Initialize the search
1476
- var ret = [context], done = [], last, nodeName;
1258
+ cache: {},
1477
1259
 
1478
- // Continue while a selector expression exists, and while
1479
- // we're no longer looping upon ourselves
1480
- while ( t && last != t ) {
1481
- var r = [];
1482
- last = t;
1260
+ data: function( elem, name, data ) {
1261
+ elem = elem == window ?
1262
+ windowData :
1263
+ elem;
1483
1264
 
1484
- t = jQuery.trim(t);
1265
+ var id = elem[ expando ];
1485
1266
 
1486
- var foundToken = false,
1267
+ // Compute a unique ID for the element
1268
+ if ( !id )
1269
+ id = elem[ expando ] = ++uuid;
1487
1270
 
1488
- // An attempt at speeding up child selectors that
1489
- // point to a specific element tag
1490
- re = quickChild,
1271
+ // Only generate the data cache if we're
1272
+ // trying to access or manipulate it
1273
+ if ( name && !jQuery.cache[ id ] )
1274
+ jQuery.cache[ id ] = {};
1491
1275
 
1492
- m = re.exec(t);
1276
+ // Prevent overriding the named cache with undefined values
1277
+ if ( data !== undefined )
1278
+ jQuery.cache[ id ][ name ] = data;
1493
1279
 
1494
- if ( m ) {
1495
- nodeName = m[1].toUpperCase();
1280
+ // Return the named cache data, or the ID for the element
1281
+ return name ?
1282
+ jQuery.cache[ id ][ name ] :
1283
+ id;
1284
+ },
1496
1285
 
1497
- // Perform our own iteration and filter
1498
- for ( var i = 0; ret[i]; i++ )
1499
- for ( var c = ret[i].firstChild; c; c = c.nextSibling )
1500
- if ( c.nodeType == 1 && (nodeName == "*" || c.nodeName.toUpperCase() == nodeName) )
1501
- r.push( c );
1286
+ removeData: function( elem, name ) {
1287
+ elem = elem == window ?
1288
+ windowData :
1289
+ elem;
1502
1290
 
1503
- ret = r;
1504
- t = t.replace( re, "" );
1505
- if ( t.indexOf(" ") == 0 ) continue;
1506
- foundToken = true;
1507
- } else {
1508
- re = /^([>+~])\s*(\w*)/i;
1291
+ var id = elem[ expando ];
1509
1292
 
1510
- if ( (m = re.exec(t)) != null ) {
1511
- r = [];
1293
+ // If we want to remove a specific section of the element's data
1294
+ if ( name ) {
1295
+ if ( jQuery.cache[ id ] ) {
1296
+ // Remove the section of cache data
1297
+ delete jQuery.cache[ id ][ name ];
1512
1298
 
1513
- var merge = {};
1514
- nodeName = m[2].toUpperCase();
1515
- m = m[1];
1299
+ // If we've removed all the data, remove the element's cache
1300
+ name = "";
1516
1301
 
1517
- for ( var j = 0, rl = ret.length; j < rl; j++ ) {
1518
- var n = m == "~" || m == "+" ? ret[j].nextSibling : ret[j].firstChild;
1519
- for ( ; n; n = n.nextSibling )
1520
- if ( n.nodeType == 1 ) {
1521
- var id = jQuery.data(n);
1302
+ for ( name in jQuery.cache[ id ] )
1303
+ break;
1522
1304
 
1523
- if ( m == "~" && merge[id] ) break;
1305
+ if ( !name )
1306
+ jQuery.removeData( elem );
1307
+ }
1524
1308
 
1525
- if (!nodeName || n.nodeName.toUpperCase() == nodeName ) {
1526
- if ( m == "~" ) merge[id] = true;
1527
- r.push( n );
1528
- }
1309
+ // Otherwise, we want to remove all of the element's data
1310
+ } else {
1311
+ // Clean up the element expando
1312
+ try {
1313
+ delete elem[ expando ];
1314
+ } catch(e){
1315
+ // IE has trouble directly removing the expando
1316
+ // but it's ok with using removeAttribute
1317
+ if ( elem.removeAttribute )
1318
+ elem.removeAttribute( expando );
1319
+ }
1529
1320
 
1530
- if ( m == "+" ) break;
1531
- }
1532
- }
1321
+ // Completely remove the data cache
1322
+ delete jQuery.cache[ id ];
1323
+ }
1324
+ },
1325
+ queue: function( elem, type, data ) {
1326
+ if ( elem ){
1327
+
1328
+ type = (type || "fx") + "queue";
1329
+
1330
+ var q = jQuery.data( elem, type );
1331
+
1332
+ if ( !q || jQuery.isArray(data) )
1333
+ q = jQuery.data( elem, type, jQuery.makeArray(data) );
1334
+ else if( data )
1335
+ q.push( data );
1336
+
1337
+ }
1338
+ return q;
1339
+ },
1340
+
1341
+ dequeue: function( elem, type ){
1342
+ var queue = jQuery.queue( elem, type ),
1343
+ fn = queue.shift();
1344
+
1345
+ if( !type || type === "fx" )
1346
+ fn = queue[0];
1347
+
1348
+ if( fn !== undefined )
1349
+ fn.call(elem);
1350
+ }
1351
+ });
1352
+
1353
+ jQuery.fn.extend({
1354
+ data: function( key, value ){
1355
+ var parts = key.split(".");
1356
+ parts[1] = parts[1] ? "." + parts[1] : "";
1533
1357
 
1534
- ret = r;
1358
+ if ( value === undefined ) {
1359
+ var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
1535
1360
 
1536
- // And remove the token
1537
- t = jQuery.trim( t.replace( re, "" ) );
1538
- foundToken = true;
1361
+ if ( data === undefined && this.length )
1362
+ data = jQuery.data( this[0], key );
1363
+
1364
+ return data === undefined && parts[1] ?
1365
+ this.data( parts[0] ) :
1366
+ data;
1367
+ } else
1368
+ return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function(){
1369
+ jQuery.data( this, key, value );
1370
+ });
1371
+ },
1372
+
1373
+ removeData: function( key ){
1374
+ return this.each(function(){
1375
+ jQuery.removeData( this, key );
1376
+ });
1377
+ },
1378
+ queue: function(type, data){
1379
+ if ( typeof type !== "string" ) {
1380
+ data = type;
1381
+ type = "fx";
1382
+ }
1383
+
1384
+ if ( data === undefined )
1385
+ return jQuery.queue( this[0], type );
1386
+
1387
+ return this.each(function(){
1388
+ var queue = jQuery.queue( this, type, data );
1389
+
1390
+ if( type == "fx" && queue.length == 1 )
1391
+ queue[0].call(this);
1392
+ });
1393
+ },
1394
+ dequeue: function(type){
1395
+ return this.each(function(){
1396
+ jQuery.dequeue( this, type );
1397
+ });
1398
+ }
1399
+ });/*!
1400
+ * Sizzle CSS Selector Engine - v0.9.1
1401
+ * Copyright 2009, The Dojo Foundation
1402
+ * Released under the MIT, BSD, and GPL Licenses.
1403
+ * More information: http://sizzlejs.com/
1404
+ */
1405
+ (function(){
1406
+
1407
+ var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|[^[\]]+)+\]|\\.|[^ >+~,(\[]+)+|[>+~])(\s*,\s*)?/g,
1408
+ done = 0,
1409
+ toString = Object.prototype.toString;
1410
+
1411
+ var Sizzle = function(selector, context, results, seed) {
1412
+ results = results || [];
1413
+ context = context || document;
1414
+
1415
+ if ( context.nodeType !== 1 && context.nodeType !== 9 )
1416
+ return [];
1417
+
1418
+ if ( !selector || typeof selector !== "string" ) {
1419
+ return results;
1420
+ }
1421
+
1422
+ var parts = [], m, set, checkSet, check, mode, extra, prune = true;
1423
+
1424
+ // Reset the position of the chunker regexp (start from head)
1425
+ chunker.lastIndex = 0;
1426
+
1427
+ while ( (m = chunker.exec(selector)) !== null ) {
1428
+ parts.push( m[1] );
1429
+
1430
+ if ( m[2] ) {
1431
+ extra = RegExp.rightContext;
1432
+ break;
1433
+ }
1434
+ }
1435
+
1436
+ if ( parts.length > 1 && Expr.match.POS.exec( selector ) ) {
1437
+ if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
1438
+ var later = "", match;
1439
+
1440
+ // Position selectors must be done after the filter
1441
+ while ( (match = Expr.match.POS.exec( selector )) ) {
1442
+ later += match[0];
1443
+ selector = selector.replace( Expr.match.POS, "" );
1444
+ }
1445
+
1446
+ set = Sizzle.filter( later, Sizzle( /\s$/.test(selector) ? selector + "*" : selector, context ) );
1447
+ } else {
1448
+ set = Expr.relative[ parts[0] ] ?
1449
+ [ context ] :
1450
+ Sizzle( parts.shift(), context );
1451
+
1452
+ while ( parts.length ) {
1453
+ var tmpSet = [];
1454
+
1455
+ selector = parts.shift();
1456
+ if ( Expr.relative[ selector ] )
1457
+ selector += parts.shift();
1458
+
1459
+ for ( var i = 0, l = set.length; i < l; i++ ) {
1460
+ Sizzle( selector, set[i], tmpSet );
1539
1461
  }
1462
+
1463
+ set = tmpSet;
1540
1464
  }
1465
+ }
1466
+ } else {
1467
+ var ret = seed ?
1468
+ { expr: parts.pop(), set: makeArray(seed) } :
1469
+ Sizzle.find( parts.pop(), parts.length === 1 && context.parentNode ? context.parentNode : context );
1470
+ set = Sizzle.filter( ret.expr, ret.set );
1471
+
1472
+ if ( parts.length > 0 ) {
1473
+ checkSet = makeArray(set);
1474
+ } else {
1475
+ prune = false;
1476
+ }
1541
1477
 
1542
- // See if there's still an expression, and that we haven't already
1543
- // matched a token
1544
- if ( t && !foundToken ) {
1545
- // Handle multiple expressions
1546
- if ( !t.indexOf(",") ) {
1547
- // Clean the result set
1548
- if ( context == ret[0] ) ret.shift();
1478
+ while ( parts.length ) {
1479
+ var cur = parts.pop(), pop = cur;
1549
1480
 
1550
- // Merge the result sets
1551
- done = jQuery.merge( done, ret );
1481
+ if ( !Expr.relative[ cur ] ) {
1482
+ cur = "";
1483
+ } else {
1484
+ pop = parts.pop();
1485
+ }
1552
1486
 
1553
- // Reset the context
1554
- r = ret = [context];
1487
+ if ( pop == null ) {
1488
+ pop = context;
1489
+ }
1555
1490
 
1556
- // Touch up the selector string
1557
- t = " " + t.substr(1,t.length);
1491
+ Expr.relative[ cur ]( checkSet, pop, isXML(context) );
1492
+ }
1493
+ }
1558
1494
 
1559
- } else {
1560
- // Optimize for the case nodeName#idName
1561
- var re2 = quickID;
1562
- var m = re2.exec(t);
1495
+ if ( !checkSet ) {
1496
+ checkSet = set;
1497
+ }
1563
1498
 
1564
- // Re-organize the results, so that they're consistent
1565
- if ( m ) {
1566
- m = [ 0, m[2], m[3], m[1] ];
1499
+ if ( !checkSet ) {
1500
+ throw "Syntax error, unrecognized expression: " + (cur || selector);
1501
+ }
1567
1502
 
1568
- } else {
1569
- // Otherwise, do a traditional filter check for
1570
- // ID, class, and element selectors
1571
- re2 = quickClass;
1572
- m = re2.exec(t);
1573
- }
1503
+ if ( toString.call(checkSet) === "[object Array]" ) {
1504
+ if ( !prune ) {
1505
+ results.push.apply( results, checkSet );
1506
+ } else if ( context.nodeType === 1 ) {
1507
+ for ( var i = 0; checkSet[i] != null; i++ ) {
1508
+ if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && contains(context, checkSet[i])) ) {
1509
+ results.push( set[i] );
1510
+ }
1511
+ }
1512
+ } else {
1513
+ for ( var i = 0; checkSet[i] != null; i++ ) {
1514
+ if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
1515
+ results.push( set[i] );
1516
+ }
1517
+ }
1518
+ }
1519
+ } else {
1520
+ makeArray( checkSet, results );
1521
+ }
1574
1522
 
1575
- m[2] = m[2].replace(/\\/g, "");
1523
+ if ( extra ) {
1524
+ Sizzle( extra, context, results, seed );
1525
+ }
1526
+
1527
+ return results;
1528
+ };
1576
1529
 
1577
- var elem = ret[ret.length-1];
1530
+ Sizzle.matches = function(expr, set){
1531
+ return Sizzle(expr, null, null, set);
1532
+ };
1578
1533
 
1579
- // Try to do a global search by ID, where we can
1580
- if ( m[1] == "#" && elem && elem.getElementById && !jQuery.isXMLDoc(elem) ) {
1581
- // Optimization for HTML document case
1582
- var oid = elem.getElementById(m[2]);
1534
+ Sizzle.find = function(expr, context){
1535
+ var set, match;
1583
1536
 
1584
- // Do a quick check for the existence of the actual ID attribute
1585
- // to avoid selecting by the name attribute in IE
1586
- // also check to insure id is a string to avoid selecting an element with the name of 'id' inside a form
1587
- if ( (jQuery.browser.msie||jQuery.browser.opera) && oid && typeof oid.id == "string" && oid.id != m[2] )
1588
- oid = jQuery('[@id="'+m[2]+'"]', elem)[0];
1537
+ if ( !expr ) {
1538
+ return [];
1539
+ }
1589
1540
 
1590
- // Do a quick check for node name (where applicable) so
1591
- // that div#foo searches will be really fast
1592
- ret = r = oid && (!m[3] || jQuery.nodeName(oid, m[3])) ? [oid] : [];
1593
- } else {
1594
- // We need to find all descendant elements
1595
- for ( var i = 0; ret[i]; i++ ) {
1596
- // Grab the tag name being searched for
1597
- var tag = m[1] == "#" && m[3] ? m[3] : m[1] != "" || m[0] == "" ? "*" : m[2];
1541
+ for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
1542
+ var type = Expr.order[i], match;
1543
+
1544
+ if ( (match = Expr.match[ type ].exec( expr )) ) {
1545
+ var left = RegExp.leftContext;
1546
+
1547
+ if ( left.substr( left.length - 1 ) !== "\\" ) {
1548
+ match[1] = (match[1] || "").replace(/\\/g, "");
1549
+ set = Expr.find[ type ]( match, context );
1550
+ if ( set != null ) {
1551
+ expr = expr.replace( Expr.match[ type ], "" );
1552
+ break;
1553
+ }
1554
+ }
1555
+ }
1556
+ }
1598
1557
 
1599
- // Handle IE7 being really dumb about <object>s
1600
- if ( tag == "*" && ret[i].nodeName.toLowerCase() == "object" )
1601
- tag = "param";
1558
+ if ( !set ) {
1559
+ set = context.getElementsByTagName("*");
1560
+ }
1602
1561
 
1603
- r = jQuery.merge( r, ret[i].getElementsByTagName( tag ));
1604
- }
1562
+ return {set: set, expr: expr};
1563
+ };
1605
1564
 
1606
- // It's faster to filter by class and be done with it
1607
- if ( m[1] == "." )
1608
- r = jQuery.classFilter( r, m[2] );
1565
+ Sizzle.filter = function(expr, set, inplace, not){
1566
+ var old = expr, result = [], curLoop = set, match, anyFound;
1609
1567
 
1610
- // Same with ID filtering
1611
- if ( m[1] == "#" ) {
1612
- var tmp = [];
1568
+ while ( expr && set.length ) {
1569
+ for ( var type in Expr.filter ) {
1570
+ if ( (match = Expr.match[ type ].exec( expr )) != null ) {
1571
+ var filter = Expr.filter[ type ], goodArray = null, goodPos = 0, found, item;
1572
+ anyFound = false;
1613
1573
 
1614
- // Try to find the element with the ID
1615
- for ( var i = 0; r[i]; i++ )
1616
- if ( r[i].getAttribute("id") == m[2] ) {
1617
- tmp = [ r[i] ];
1618
- break;
1619
- }
1574
+ if ( curLoop == result ) {
1575
+ result = [];
1576
+ }
1620
1577
 
1621
- r = tmp;
1578
+ if ( Expr.preFilter[ type ] ) {
1579
+ match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not );
1580
+
1581
+ if ( !match ) {
1582
+ anyFound = found = true;
1583
+ } else if ( match === true ) {
1584
+ continue;
1585
+ } else if ( match[0] === true ) {
1586
+ goodArray = [];
1587
+ var last = null, elem;
1588
+ for ( var i = 0; (elem = curLoop[i]) !== undefined; i++ ) {
1589
+ if ( elem && last !== elem ) {
1590
+ goodArray.push( elem );
1591
+ last = elem;
1592
+ }
1622
1593
  }
1623
-
1624
- ret = r;
1625
1594
  }
1595
+ }
1626
1596
 
1627
- t = t.replace( re2, "" );
1597
+ if ( match ) {
1598
+ for ( var i = 0; (item = curLoop[i]) !== undefined; i++ ) {
1599
+ if ( item ) {
1600
+ if ( goodArray && item != goodArray[goodPos] ) {
1601
+ goodPos++;
1602
+ }
1603
+
1604
+ found = filter( item, match, goodPos, goodArray );
1605
+ var pass = not ^ !!found;
1606
+
1607
+ if ( inplace && found != null ) {
1608
+ if ( pass ) {
1609
+ anyFound = true;
1610
+ } else {
1611
+ curLoop[i] = false;
1612
+ }
1613
+ } else if ( pass ) {
1614
+ result.push( item );
1615
+ anyFound = true;
1616
+ }
1617
+ }
1618
+ }
1628
1619
  }
1629
1620
 
1630
- }
1621
+ if ( found !== undefined ) {
1622
+ if ( !inplace ) {
1623
+ curLoop = result;
1624
+ }
1625
+
1626
+ expr = expr.replace( Expr.match[ type ], "" );
1627
+
1628
+ if ( !anyFound ) {
1629
+ return [];
1630
+ }
1631
1631
 
1632
- // If a selector string still exists
1633
- if ( t ) {
1634
- // Attempt to filter it
1635
- var val = jQuery.filter(t,r);
1636
- ret = r = val.r;
1637
- t = jQuery.trim(val.t);
1632
+ break;
1633
+ }
1638
1634
  }
1639
1635
  }
1640
1636
 
1641
- // An error occurred with the selector;
1642
- // just return an empty set instead
1643
- if ( t )
1644
- ret = [];
1637
+ expr = expr.replace(/\s*,\s*/, "");
1638
+
1639
+ // Improper expression
1640
+ if ( expr == old ) {
1641
+ if ( anyFound == null ) {
1642
+ throw "Syntax error, unrecognized expression: " + expr;
1643
+ } else {
1644
+ break;
1645
+ }
1646
+ }
1645
1647
 
1646
- // Remove the root context
1647
- if ( ret && context == ret[0] )
1648
- ret.shift();
1648
+ old = expr;
1649
+ }
1649
1650
 
1650
- // And combine the results
1651
- done = jQuery.merge( done, ret );
1651
+ return curLoop;
1652
+ };
1652
1653
 
1653
- return done;
1654
+ var Expr = Sizzle.selectors = {
1655
+ order: [ "ID", "NAME", "TAG" ],
1656
+ match: {
1657
+ ID: /#((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,
1658
+ CLASS: /\.((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,
1659
+ NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF_-]|\\.)+)['"]*\]/,
1660
+ ATTR: /\[\s*((?:[\w\u00c0-\uFFFF_-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,
1661
+ TAG: /^((?:[\w\u00c0-\uFFFF\*_-]|\\.)+)/,
1662
+ CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,
1663
+ POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,
1664
+ PSEUDO: /:((?:[\w\u00c0-\uFFFF_-]|\\.)+)(?:\((['"]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/
1654
1665
  },
1655
-
1656
- classFilter: function(r,m,not){
1657
- m = " " + m + " ";
1658
- var tmp = [];
1659
- for ( var i = 0; r[i]; i++ ) {
1660
- var pass = (" " + r[i].className + " ").indexOf( m ) >= 0;
1661
- if ( !not && pass || not && !pass )
1662
- tmp.push( r[i] );
1666
+ attrMap: {
1667
+ "class": "className",
1668
+ "for": "htmlFor"
1669
+ },
1670
+ attrHandle: {
1671
+ href: function(elem){
1672
+ return elem.getAttribute("href");
1663
1673
  }
1664
- return tmp;
1665
1674
  },
1675
+ relative: {
1676
+ "+": function(checkSet, part){
1677
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
1678
+ var elem = checkSet[i];
1679
+ if ( elem ) {
1680
+ var cur = elem.previousSibling;
1681
+ while ( cur && cur.nodeType !== 1 ) {
1682
+ cur = cur.previousSibling;
1683
+ }
1684
+ checkSet[i] = typeof part === "string" ?
1685
+ cur || false :
1686
+ cur === part;
1687
+ }
1688
+ }
1666
1689
 
1667
- filter: function(t,r,not) {
1668
- var last;
1690
+ if ( typeof part === "string" ) {
1691
+ Sizzle.filter( part, checkSet, true );
1692
+ }
1693
+ },
1694
+ ">": function(checkSet, part, isXML){
1695
+ if ( typeof part === "string" && !/\W/.test(part) ) {
1696
+ part = isXML ? part : part.toUpperCase();
1697
+
1698
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
1699
+ var elem = checkSet[i];
1700
+ if ( elem ) {
1701
+ var parent = elem.parentNode;
1702
+ checkSet[i] = parent.nodeName === part ? parent : false;
1703
+ }
1704
+ }
1705
+ } else {
1706
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
1707
+ var elem = checkSet[i];
1708
+ if ( elem ) {
1709
+ checkSet[i] = typeof part === "string" ?
1710
+ elem.parentNode :
1711
+ elem.parentNode === part;
1712
+ }
1713
+ }
1669
1714
 
1670
- // Look for common filter expressions
1671
- while ( t && t != last ) {
1672
- last = t;
1715
+ if ( typeof part === "string" ) {
1716
+ Sizzle.filter( part, checkSet, true );
1717
+ }
1718
+ }
1719
+ },
1720
+ "": function(checkSet, part, isXML){
1721
+ var doneName = "done" + (done++), checkFn = dirCheck;
1673
1722
 
1674
- var p = jQuery.parse, m;
1723
+ if ( !part.match(/\W/) ) {
1724
+ var nodeCheck = part = isXML ? part : part.toUpperCase();
1725
+ checkFn = dirNodeCheck;
1726
+ }
1675
1727
 
1676
- for ( var i = 0; p[i]; i++ ) {
1677
- m = p[i].exec( t );
1728
+ checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML);
1729
+ },
1730
+ "~": function(checkSet, part, isXML){
1731
+ var doneName = "done" + (done++), checkFn = dirCheck;
1678
1732
 
1679
- if ( m ) {
1680
- // Remove what we just matched
1681
- t = t.substring( m[0].length );
1733
+ if ( typeof part === "string" && !part.match(/\W/) ) {
1734
+ var nodeCheck = part = isXML ? part : part.toUpperCase();
1735
+ checkFn = dirNodeCheck;
1736
+ }
1682
1737
 
1683
- m[2] = m[2].replace(/\\/g, "");
1684
- break;
1738
+ checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML);
1739
+ }
1740
+ },
1741
+ find: {
1742
+ ID: function(match, context){
1743
+ if ( context.getElementById ) {
1744
+ var m = context.getElementById(match[1]);
1745
+ return m ? [m] : [];
1746
+ }
1747
+ },
1748
+ NAME: function(match, context){
1749
+ return context.getElementsByName ? context.getElementsByName(match[1]) : null;
1750
+ },
1751
+ TAG: function(match, context){
1752
+ return context.getElementsByTagName(match[1]);
1753
+ }
1754
+ },
1755
+ preFilter: {
1756
+ CLASS: function(match, curLoop, inplace, result, not){
1757
+ match = " " + match[1].replace(/\\/g, "") + " ";
1758
+
1759
+ for ( var i = 0; curLoop[i]; i++ ) {
1760
+ if ( not ^ (" " + curLoop[i].className + " ").indexOf(match) >= 0 ) {
1761
+ if ( !inplace )
1762
+ result.push( curLoop[i] );
1763
+ } else if ( inplace ) {
1764
+ curLoop[i] = false;
1685
1765
  }
1686
1766
  }
1687
1767
 
1688
- if ( !m )
1689
- break;
1690
-
1691
- // :not() is a special case that can be optimized by
1692
- // keeping it out of the expression list
1693
- if ( m[1] == ":" && m[2] == "not" )
1694
- // optimize if only one selector found (most common case)
1695
- r = isSimple.test( m[3] ) ?
1696
- jQuery.filter(m[3], r, true).r :
1697
- jQuery( r ).not( m[3] );
1698
-
1699
- // We can get a big speed boost by filtering by class here
1700
- else if ( m[1] == "." )
1701
- r = jQuery.classFilter(r, m[2], not);
1702
-
1703
- else if ( m[1] == "[" ) {
1704
- var tmp = [], type = m[3];
1705
-
1706
- for ( var i = 0, rl = r.length; i < rl; i++ ) {
1707
- var a = r[i], z = a[ jQuery.props[m[2]] || m[2] ];
1708
-
1709
- if ( z == null || /href|src|selected/.test(m[2]) )
1710
- z = jQuery.attr(a,m[2]) || '';
1711
-
1712
- if ( (type == "" && !!z ||
1713
- type == "=" && z == m[5] ||
1714
- type == "!=" && z != m[5] ||
1715
- type == "^=" && z && !z.indexOf(m[5]) ||
1716
- type == "$=" && z.substr(z.length - m[5].length) == m[5] ||
1717
- (type == "*=" || type == "~=") && z.indexOf(m[5]) >= 0) ^ not )
1718
- tmp.push( a );
1719
- }
1768
+ return false;
1769
+ },
1770
+ ID: function(match){
1771
+ return match[1].replace(/\\/g, "");
1772
+ },
1773
+ TAG: function(match, curLoop){
1774
+ for ( var i = 0; !curLoop[i]; i++ ){}
1775
+ return isXML(curLoop[i]) ? match[1] : match[1].toUpperCase();
1776
+ },
1777
+ CHILD: function(match){
1778
+ if ( match[1] == "nth" ) {
1779
+ // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
1780
+ var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
1781
+ match[2] == "even" && "2n" || match[2] == "odd" && "2n+1" ||
1782
+ !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
1783
+
1784
+ // calculate the numbers (first)n+(last) including if they are negative
1785
+ match[2] = (test[1] + (test[2] || 1)) - 0;
1786
+ match[3] = test[3] - 0;
1787
+ }
1720
1788
 
1721
- r = tmp;
1789
+ // TODO: Move to normal caching system
1790
+ match[0] = "done" + (done++);
1722
1791
 
1723
- // We can get a speed boost by handling nth-child here
1724
- } else if ( m[1] == ":" && m[2] == "nth-child" ) {
1725
- var merge = {}, tmp = [],
1726
- // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
1727
- test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
1728
- m[3] == "even" && "2n" || m[3] == "odd" && "2n+1" ||
1729
- !/\D/.test(m[3]) && "0n+" + m[3] || m[3]),
1730
- // calculate the numbers (first)n+(last) including if they are negative
1731
- first = (test[1] + (test[2] || 1)) - 0, last = test[3] - 0;
1792
+ return match;
1793
+ },
1794
+ ATTR: function(match){
1795
+ var name = match[1];
1796
+
1797
+ if ( Expr.attrMap[name] ) {
1798
+ match[1] = Expr.attrMap[name];
1799
+ }
1732
1800
 
1733
- // loop through all the elements left in the jQuery object
1734
- for ( var i = 0, rl = r.length; i < rl; i++ ) {
1735
- var node = r[i], parentNode = node.parentNode, id = jQuery.data(parentNode);
1801
+ if ( match[2] === "~=" ) {
1802
+ match[4] = " " + match[4] + " ";
1803
+ }
1736
1804
 
1737
- if ( !merge[id] ) {
1738
- var c = 1;
1805
+ return match;
1806
+ },
1807
+ PSEUDO: function(match, curLoop, inplace, result, not){
1808
+ if ( match[1] === "not" ) {
1809
+ // If we're dealing with a complex expression, or a simple one
1810
+ if ( match[3].match(chunker).length > 1 ) {
1811
+ match[3] = Sizzle(match[3], null, null, curLoop);
1812
+ } else {
1813
+ var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
1814
+ if ( !inplace ) {
1815
+ result.push.apply( result, ret );
1816
+ }
1817
+ return false;
1818
+ }
1819
+ } else if ( Expr.match.POS.test( match[0] ) ) {
1820
+ return true;
1821
+ }
1822
+
1823
+ return match;
1824
+ },
1825
+ POS: function(match){
1826
+ match.unshift( true );
1827
+ return match;
1828
+ }
1829
+ },
1830
+ filters: {
1831
+ enabled: function(elem){
1832
+ return elem.disabled === false && elem.type !== "hidden";
1833
+ },
1834
+ disabled: function(elem){
1835
+ return elem.disabled === true;
1836
+ },
1837
+ checked: function(elem){
1838
+ return elem.checked === true;
1839
+ },
1840
+ selected: function(elem){
1841
+ // Accessing this property makes selected-by-default
1842
+ // options in Safari work properly
1843
+ elem.parentNode.selectedIndex;
1844
+ return elem.selected === true;
1845
+ },
1846
+ parent: function(elem){
1847
+ return !!elem.firstChild;
1848
+ },
1849
+ empty: function(elem){
1850
+ return !elem.firstChild;
1851
+ },
1852
+ has: function(elem, i, match){
1853
+ return !!Sizzle( match[3], elem ).length;
1854
+ },
1855
+ header: function(elem){
1856
+ return /h\d/i.test( elem.nodeName );
1857
+ },
1858
+ text: function(elem){
1859
+ return "text" === elem.type;
1860
+ },
1861
+ radio: function(elem){
1862
+ return "radio" === elem.type;
1863
+ },
1864
+ checkbox: function(elem){
1865
+ return "checkbox" === elem.type;
1866
+ },
1867
+ file: function(elem){
1868
+ return "file" === elem.type;
1869
+ },
1870
+ password: function(elem){
1871
+ return "password" === elem.type;
1872
+ },
1873
+ submit: function(elem){
1874
+ return "submit" === elem.type;
1875
+ },
1876
+ image: function(elem){
1877
+ return "image" === elem.type;
1878
+ },
1879
+ reset: function(elem){
1880
+ return "reset" === elem.type;
1881
+ },
1882
+ button: function(elem){
1883
+ return "button" === elem.type || elem.nodeName.toUpperCase() === "BUTTON";
1884
+ },
1885
+ input: function(elem){
1886
+ return /input|select|textarea|button/i.test(elem.nodeName);
1887
+ }
1888
+ },
1889
+ setFilters: {
1890
+ first: function(elem, i){
1891
+ return i === 0;
1892
+ },
1893
+ last: function(elem, i, match, array){
1894
+ return i === array.length - 1;
1895
+ },
1896
+ even: function(elem, i){
1897
+ return i % 2 === 0;
1898
+ },
1899
+ odd: function(elem, i){
1900
+ return i % 2 === 1;
1901
+ },
1902
+ lt: function(elem, i, match){
1903
+ return i < match[3] - 0;
1904
+ },
1905
+ gt: function(elem, i, match){
1906
+ return i > match[3] - 0;
1907
+ },
1908
+ nth: function(elem, i, match){
1909
+ return match[3] - 0 == i;
1910
+ },
1911
+ eq: function(elem, i, match){
1912
+ return match[3] - 0 == i;
1913
+ }
1914
+ },
1915
+ filter: {
1916
+ CHILD: function(elem, match){
1917
+ var type = match[1], parent = elem.parentNode;
1739
1918
 
1740
- for ( var n = parentNode.firstChild; n; n = n.nextSibling )
1741
- if ( n.nodeType == 1 )
1742
- n.nodeIndex = c++;
1919
+ var doneName = "child" + parent.childNodes.length;
1920
+
1921
+ if ( parent && (!parent[ doneName ] || !elem.nodeIndex) ) {
1922
+ var count = 1;
1743
1923
 
1744
- merge[id] = true;
1924
+ for ( var node = parent.firstChild; node; node = node.nextSibling ) {
1925
+ if ( node.nodeType == 1 ) {
1926
+ node.nodeIndex = count++;
1745
1927
  }
1928
+ }
1746
1929
 
1747
- var add = false;
1930
+ parent[ doneName ] = count - 1;
1931
+ }
1932
+
1933
+ if ( type == "first" ) {
1934
+ return elem.nodeIndex == 1;
1935
+ } else if ( type == "last" ) {
1936
+ return elem.nodeIndex == parent[ doneName ];
1937
+ } else if ( type == "only" ) {
1938
+ return parent[ doneName ] == 1;
1939
+ } else if ( type == "nth" ) {
1940
+ var add = false, first = match[2], last = match[3];
1941
+
1942
+ if ( first == 1 && last == 0 ) {
1943
+ return true;
1944
+ }
1748
1945
 
1749
- if ( first == 0 ) {
1750
- if ( node.nodeIndex == last )
1751
- add = true;
1752
- } else if ( (node.nodeIndex - last) % first == 0 && (node.nodeIndex - last) / first >= 0 )
1946
+ if ( first == 0 ) {
1947
+ if ( elem.nodeIndex == last ) {
1753
1948
  add = true;
1949
+ }
1950
+ } else if ( (elem.nodeIndex - last) % first == 0 && (elem.nodeIndex - last) / first >= 0 ) {
1951
+ add = true;
1952
+ }
1754
1953
 
1755
- if ( add ^ not )
1756
- tmp.push( node );
1954
+ return add;
1955
+ }
1956
+ },
1957
+ PSEUDO: function(elem, match, i, array){
1958
+ var name = match[1], filter = Expr.filters[ name ];
1959
+
1960
+ if ( filter ) {
1961
+ return filter( elem, i, match, array );
1962
+ } else if ( name === "contains" ) {
1963
+ return (elem.textContent || elem.innerText || "").indexOf(match[3]) >= 0;
1964
+ } else if ( name === "not" ) {
1965
+ var not = match[3];
1966
+
1967
+ for ( var i = 0, l = not.length; i < l; i++ ) {
1968
+ if ( not[i] === elem ) {
1969
+ return false;
1970
+ }
1757
1971
  }
1758
1972
 
1759
- r = tmp;
1973
+ return true;
1974
+ }
1975
+ },
1976
+ ID: function(elem, match){
1977
+ return elem.nodeType === 1 && elem.getAttribute("id") === match;
1978
+ },
1979
+ TAG: function(elem, match){
1980
+ return (match === "*" && elem.nodeType === 1) || elem.nodeName === match;
1981
+ },
1982
+ CLASS: function(elem, match){
1983
+ return match.test( elem.className );
1984
+ },
1985
+ ATTR: function(elem, match){
1986
+ var result = Expr.attrHandle[ match[1] ] ? Expr.attrHandle[ match[1] ]( elem ) : elem[ match[1] ] || elem.getAttribute( match[1] ), value = result + "", type = match[2], check = match[4];
1987
+ return result == null ?
1988
+ false :
1989
+ type === "=" ?
1990
+ value === check :
1991
+ type === "*=" ?
1992
+ value.indexOf(check) >= 0 :
1993
+ type === "~=" ?
1994
+ (" " + value + " ").indexOf(check) >= 0 :
1995
+ !match[4] ?
1996
+ result :
1997
+ type === "!=" ?
1998
+ value != check :
1999
+ type === "^=" ?
2000
+ value.indexOf(check) === 0 :
2001
+ type === "$=" ?
2002
+ value.substr(value.length - check.length) === check :
2003
+ type === "|=" ?
2004
+ value === check || value.substr(0, check.length + 1) === check + "-" :
2005
+ false;
2006
+ },
2007
+ POS: function(elem, match, i, array){
2008
+ var name = match[2], filter = Expr.setFilters[ name ];
2009
+
2010
+ if ( filter ) {
2011
+ return filter( elem, i, match, array );
2012
+ }
2013
+ }
2014
+ }
2015
+ };
2016
+
2017
+ for ( var type in Expr.match ) {
2018
+ Expr.match[ type ] = RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source );
2019
+ }
2020
+
2021
+ var makeArray = function(array, results) {
2022
+ array = Array.prototype.slice.call( array );
2023
+
2024
+ if ( results ) {
2025
+ results.push.apply( results, array );
2026
+ return results;
2027
+ }
2028
+
2029
+ return array;
2030
+ };
2031
+
2032
+ // Perform a simple check to determine if the browser is capable of
2033
+ // converting a NodeList to an array using builtin methods.
2034
+ try {
2035
+ Array.prototype.slice.call( document.documentElement.childNodes );
2036
+
2037
+ // Provide a fallback method if it does not work
2038
+ } catch(e){
2039
+ makeArray = function(array, results) {
2040
+ var ret = results || [];
1760
2041
 
1761
- // Otherwise, find the expression to execute
2042
+ if ( toString.call(array) === "[object Array]" ) {
2043
+ Array.prototype.push.apply( ret, array );
2044
+ } else {
2045
+ if ( typeof array.length === "number" ) {
2046
+ for ( var i = 0, l = array.length; i < l; i++ ) {
2047
+ ret.push( array[i] );
2048
+ }
1762
2049
  } else {
1763
- var fn = jQuery.expr[ m[1] ];
1764
- if ( typeof fn == "object" )
1765
- fn = fn[ m[2] ];
2050
+ for ( var i = 0; array[i]; i++ ) {
2051
+ ret.push( array[i] );
2052
+ }
2053
+ }
2054
+ }
2055
+
2056
+ return ret;
2057
+ };
2058
+ }
2059
+
2060
+ // Check to see if the browser returns elements by name when
2061
+ // querying by getElementById (and provide a workaround)
2062
+ (function(){
2063
+ // We're going to inject a fake input element with a specified name
2064
+ var form = document.createElement("form"),
2065
+ id = "script" + (new Date).getTime();
2066
+ form.innerHTML = "<input name='" + id + "'/>";
2067
+
2068
+ // Inject it into the root element, check its status, and remove it quickly
2069
+ var root = document.documentElement;
2070
+ root.insertBefore( form, root.firstChild );
2071
+
2072
+ // The workaround has to do additional checks after a getElementById
2073
+ // Which slows things down for other browsers (hence the branching)
2074
+ if ( !!document.getElementById( id ) ) {
2075
+ Expr.find.ID = function(match, context){
2076
+ if ( context.getElementById ) {
2077
+ var m = context.getElementById(match[1]);
2078
+ return m ? m.id === match[1] || m.getAttributeNode && m.getAttributeNode("id").nodeValue === match[1] ? [m] : undefined : [];
2079
+ }
2080
+ };
2081
+
2082
+ Expr.filter.ID = function(elem, match){
2083
+ var node = elem.getAttributeNode && elem.getAttributeNode("id");
2084
+ return elem.nodeType === 1 && node && node.nodeValue === match;
2085
+ };
2086
+ }
2087
+
2088
+ root.removeChild( form );
2089
+ })();
2090
+
2091
+ (function(){
2092
+ // Check to see if the browser returns only elements
2093
+ // when doing getElementsByTagName("*")
1766
2094
 
1767
- if ( typeof fn == "string" )
1768
- fn = eval("false||function(a,i){return " + fn + ";}");
2095
+ // Create a fake element
2096
+ var div = document.createElement("div");
2097
+ div.appendChild( document.createComment("") );
1769
2098
 
1770
- // Execute it against the current filter
1771
- r = jQuery.grep( r, function(elem, i){
1772
- return fn(elem, i, m, r);
1773
- }, not );
2099
+ // Make sure no comments are found
2100
+ if ( div.getElementsByTagName("*").length > 0 ) {
2101
+ Expr.find.TAG = function(match, context){
2102
+ var results = context.getElementsByTagName(match[1]);
2103
+
2104
+ // Filter out possible comments
2105
+ if ( match[1] === "*" ) {
2106
+ var tmp = [];
2107
+
2108
+ for ( var i = 0; results[i]; i++ ) {
2109
+ if ( results[i].nodeType === 1 ) {
2110
+ tmp.push( results[i] );
2111
+ }
2112
+ }
2113
+
2114
+ results = tmp;
1774
2115
  }
2116
+
2117
+ return results;
2118
+ };
2119
+ }
2120
+
2121
+ // Check to see if an attribute returns normalized href attributes
2122
+ div.innerHTML = "<a href='#'></a>";
2123
+ if ( div.firstChild.getAttribute("href") !== "#" ) {
2124
+ Expr.attrHandle.href = function(elem){
2125
+ return elem.getAttribute("href", 2);
2126
+ };
2127
+ }
2128
+ })();
2129
+
2130
+ if ( document.querySelectorAll ) (function(){
2131
+ var oldSizzle = Sizzle;
2132
+
2133
+ Sizzle = function(query, context, extra, seed){
2134
+ context = context || document;
2135
+
2136
+ if ( !seed && context.nodeType === 9 ) {
2137
+ try {
2138
+ return makeArray( context.querySelectorAll(query), extra );
2139
+ } catch(e){}
1775
2140
  }
2141
+
2142
+ return oldSizzle(query, context, extra, seed);
2143
+ };
1776
2144
 
1777
- // Return an array of filtered elements (r)
1778
- // and the modified expression string (t)
1779
- return { r: r, t: t };
1780
- },
2145
+ Sizzle.find = oldSizzle.find;
2146
+ Sizzle.filter = oldSizzle.filter;
2147
+ Sizzle.selectors = oldSizzle.selectors;
2148
+ Sizzle.matches = oldSizzle.matches;
2149
+ })();
2150
+
2151
+ if ( document.documentElement.getElementsByClassName ) {
2152
+ Expr.order.splice(1, 0, "CLASS");
2153
+ Expr.find.CLASS = function(match, context) {
2154
+ return context.getElementsByClassName(match[1]);
2155
+ };
2156
+ }
2157
+
2158
+ function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
2159
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
2160
+ var elem = checkSet[i];
2161
+ if ( elem ) {
2162
+ elem = elem[dir];
2163
+ var match = false;
2164
+
2165
+ while ( elem && elem.nodeType ) {
2166
+ var done = elem[doneName];
2167
+ if ( done ) {
2168
+ match = checkSet[ done ];
2169
+ break;
2170
+ }
2171
+
2172
+ if ( elem.nodeType === 1 && !isXML )
2173
+ elem[doneName] = i;
2174
+
2175
+ if ( elem.nodeName === cur ) {
2176
+ match = elem;
2177
+ break;
2178
+ }
1781
2179
 
1782
- dir: function( elem, dir ){
1783
- var matched = [],
1784
- cur = elem[dir];
1785
- while ( cur && cur != document ) {
1786
- if ( cur.nodeType == 1 )
1787
- matched.push( cur );
1788
- cur = cur[dir];
2180
+ elem = elem[dir];
2181
+ }
2182
+
2183
+ checkSet[i] = match;
1789
2184
  }
1790
- return matched;
1791
- },
2185
+ }
2186
+ }
1792
2187
 
1793
- nth: function(cur,result,dir,elem){
1794
- result = result || 1;
1795
- var num = 0;
2188
+ function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
2189
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
2190
+ var elem = checkSet[i];
2191
+ if ( elem ) {
2192
+ elem = elem[dir];
2193
+ var match = false;
1796
2194
 
1797
- for ( ; cur; cur = cur[dir] )
1798
- if ( cur.nodeType == 1 && ++num == result )
1799
- break;
2195
+ while ( elem && elem.nodeType ) {
2196
+ if ( elem[doneName] ) {
2197
+ match = checkSet[ elem[doneName] ];
2198
+ break;
2199
+ }
1800
2200
 
1801
- return cur;
1802
- },
2201
+ if ( elem.nodeType === 1 ) {
2202
+ if ( !isXML )
2203
+ elem[doneName] = i;
2204
+
2205
+ if ( typeof cur !== "string" ) {
2206
+ if ( elem === cur ) {
2207
+ match = true;
2208
+ break;
2209
+ }
1803
2210
 
1804
- sibling: function( n, elem ) {
1805
- var r = [];
2211
+ } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
2212
+ match = elem;
2213
+ break;
2214
+ }
2215
+ }
2216
+
2217
+ elem = elem[dir];
2218
+ }
1806
2219
 
1807
- for ( ; n; n = n.nextSibling ) {
1808
- if ( n.nodeType == 1 && n != elem )
1809
- r.push( n );
2220
+ checkSet[i] = match;
1810
2221
  }
2222
+ }
2223
+ }
2224
+
2225
+ var contains = document.compareDocumentPosition ? function(a, b){
2226
+ return a.compareDocumentPosition(b) & 16;
2227
+ } : function(a, b){
2228
+ return a !== b && (a.contains ? a.contains(b) : true);
2229
+ };
2230
+
2231
+ var isXML = function(elem){
2232
+ return elem.documentElement && !elem.body ||
2233
+ elem.tagName && elem.ownerDocument && !elem.ownerDocument.body;
2234
+ };
2235
+
2236
+ // EXPOSE
2237
+ jQuery.find = Sizzle;
2238
+ jQuery.filter = Sizzle.filter;
2239
+ jQuery.expr = Sizzle.selectors;
2240
+ jQuery.expr[":"] = jQuery.expr.filters;
2241
+
2242
+ Sizzle.selectors.filters.hidden = function(elem){
2243
+ return "hidden" === elem.type ||
2244
+ jQuery.css(elem, "display") === "none" ||
2245
+ jQuery.css(elem, "visibility") === "hidden";
2246
+ };
2247
+
2248
+ Sizzle.selectors.filters.visible = function(elem){
2249
+ return "hidden" !== elem.type &&
2250
+ jQuery.css(elem, "display") !== "none" &&
2251
+ jQuery.css(elem, "visibility") !== "hidden";
2252
+ };
1811
2253
 
1812
- return r;
2254
+ Sizzle.selectors.filters.animated = function(elem){
2255
+ return jQuery.grep(jQuery.timers, function(fn){
2256
+ return elem === fn.elem;
2257
+ }).length;
2258
+ };
2259
+
2260
+ jQuery.multiFilter = function( expr, elems, not ) {
2261
+ if ( not ) {
2262
+ expr = ":not(" + expr + ")";
1813
2263
  }
1814
- });
2264
+
2265
+ return Sizzle.matches(expr, elems);
2266
+ };
2267
+
2268
+ jQuery.dir = function( elem, dir ){
2269
+ var matched = [], cur = elem[dir];
2270
+ while ( cur && cur != document ) {
2271
+ if ( cur.nodeType == 1 )
2272
+ matched.push( cur );
2273
+ cur = cur[dir];
2274
+ }
2275
+ return matched;
2276
+ };
2277
+
2278
+ jQuery.nth = function(cur, result, dir, elem){
2279
+ result = result || 1;
2280
+ var num = 0;
2281
+
2282
+ for ( ; cur; cur = cur[dir] )
2283
+ if ( cur.nodeType == 1 && ++num == result )
2284
+ break;
2285
+
2286
+ return cur;
2287
+ };
2288
+
2289
+ jQuery.sibling = function(n, elem){
2290
+ var r = [];
2291
+
2292
+ for ( ; n; n = n.nextSibling ) {
2293
+ if ( n.nodeType == 1 && n != elem )
2294
+ r.push( n );
2295
+ }
2296
+
2297
+ return r;
2298
+ };
2299
+
2300
+ return;
2301
+
2302
+ window.Sizzle = Sizzle;
2303
+
2304
+ })();
1815
2305
  /*
1816
2306
  * A number of helper functions used for managing events.
1817
- * Many of the ideas behind this code orignated from
2307
+ * Many of the ideas behind this code originated from
1818
2308
  * Dean Edwards' addEvent library.
1819
2309
  */
1820
2310
  jQuery.event = {
@@ -1827,7 +2317,7 @@ jQuery.event = {
1827
2317
 
1828
2318
  // For whatever reason, IE has trouble passing the window object
1829
2319
  // around, causing it to be cloned in the process
1830
- if ( jQuery.browser.msie && elem.setInterval )
2320
+ if ( elem.setInterval && elem != window )
1831
2321
  elem = window;
1832
2322
 
1833
2323
  // Make sure that the function being executed has a unique ID
@@ -1835,15 +2325,12 @@ jQuery.event = {
1835
2325
  handler.guid = this.guid++;
1836
2326
 
1837
2327
  // if data is passed, bind to handler
1838
- if( data != undefined ) {
2328
+ if ( data !== undefined ) {
1839
2329
  // Create temporary function pointer to original handler
1840
2330
  var fn = handler;
1841
2331
 
1842
2332
  // Create unique handler function, wrapped around original handler
1843
- handler = this.proxy( fn, function() {
1844
- // Pass arguments and context to original handler
1845
- return fn.apply(this, arguments);
1846
- });
2333
+ handler = this.proxy( fn );
1847
2334
 
1848
2335
  // Store data in unique handler
1849
2336
  handler.data = data;
@@ -1854,8 +2341,9 @@ jQuery.event = {
1854
2341
  handle = jQuery.data(elem, "handle") || jQuery.data(elem, "handle", function(){
1855
2342
  // Handle the second event of a trigger and when
1856
2343
  // an event is called after a page has unloaded
1857
- if ( typeof jQuery != "undefined" && !jQuery.event.triggered )
1858
- return jQuery.event.handle.apply(arguments.callee.elem, arguments);
2344
+ return typeof jQuery !== "undefined" && !jQuery.event.triggered ?
2345
+ jQuery.event.handle.apply(arguments.callee.elem, arguments) :
2346
+ undefined;
1859
2347
  });
1860
2348
  // Add elem as a property of the handle function
1861
2349
  // This is to prevent a memory leak with non-native
@@ -1866,12 +2354,15 @@ jQuery.event = {
1866
2354
  // jQuery(...).bind("mouseover mouseout", fn);
1867
2355
  jQuery.each(types.split(/\s+/), function(index, type) {
1868
2356
  // Namespaced event handlers
1869
- var parts = type.split(".");
1870
- type = parts[0];
1871
- handler.type = parts[1];
2357
+ var namespaces = type.split(".");
2358
+ type = namespaces.shift();
2359
+ handler.type = namespaces.slice().sort().join(".");
1872
2360
 
1873
2361
  // Get the current list of functions bound to this event
1874
2362
  var handlers = events[type];
2363
+
2364
+ if ( jQuery.event.specialAll[type] )
2365
+ jQuery.event.specialAll[type].setup.call(elem, data, namespaces);
1875
2366
 
1876
2367
  // Init the event handler queue
1877
2368
  if (!handlers) {
@@ -1880,7 +2371,7 @@ jQuery.event = {
1880
2371
  // Check for a special event handler
1881
2372
  // Only use addEventListener/attachEvent if the special
1882
2373
  // events handler returns false
1883
- if ( !jQuery.event.special[type] || jQuery.event.special[type].setup.call(elem) === false ) {
2374
+ if ( !jQuery.event.special[type] || jQuery.event.special[type].setup.call(elem, data, namespaces) === false ) {
1884
2375
  // Bind the global event handler to the element
1885
2376
  if (elem.addEventListener)
1886
2377
  elem.addEventListener(type, handle, false);
@@ -1913,7 +2404,7 @@ jQuery.event = {
1913
2404
 
1914
2405
  if ( events ) {
1915
2406
  // Unbind all events for the element
1916
- if ( types == undefined || (typeof types == "string" && types.charAt(0) == ".") )
2407
+ if ( types === undefined || (typeof types === "string" && types.charAt(0) == ".") )
1917
2408
  for ( var type in events )
1918
2409
  this.remove( elem, type + (types || "") );
1919
2410
  else {
@@ -1927,8 +2418,9 @@ jQuery.event = {
1927
2418
  // jQuery(...).unbind("mouseover mouseout", fn);
1928
2419
  jQuery.each(types.split(/\s+/), function(index, type){
1929
2420
  // Namespaced event handlers
1930
- var parts = type.split(".");
1931
- type = parts[0];
2421
+ var namespaces = type.split(".");
2422
+ type = namespaces.shift();
2423
+ var namespace = RegExp("(^|\\.)" + namespaces.slice().sort().join(".*\\.") + "(\\.|$)");
1932
2424
 
1933
2425
  if ( events[type] ) {
1934
2426
  // remove the given handler for the given type
@@ -1937,15 +2429,18 @@ jQuery.event = {
1937
2429
 
1938
2430
  // remove all handlers for the given type
1939
2431
  else
1940
- for ( handler in events[type] )
2432
+ for ( var handle in events[type] )
1941
2433
  // Handle the removal of namespaced events
1942
- if ( !parts[1] || events[type][handler].type == parts[1] )
1943
- delete events[type][handler];
2434
+ if ( namespace.test(events[type][handle].type) )
2435
+ delete events[type][handle];
2436
+
2437
+ if ( jQuery.event.specialAll[type] )
2438
+ jQuery.event.specialAll[type].teardown.call(elem, namespaces);
1944
2439
 
1945
2440
  // remove generic event handler if no more handlers exist
1946
2441
  for ( ret in events[type] ) break;
1947
2442
  if ( !ret ) {
1948
- if ( !jQuery.event.special[type] || jQuery.event.special[type].teardown.call(elem) === false ) {
2443
+ if ( !jQuery.event.special[type] || jQuery.event.special[type].teardown.call(elem, namespaces) === false ) {
1949
2444
  if (elem.removeEventListener)
1950
2445
  elem.removeEventListener(type, jQuery.data(elem, "handle"), false);
1951
2446
  else if (elem.detachEvent)
@@ -1969,97 +2464,95 @@ jQuery.event = {
1969
2464
  }
1970
2465
  },
1971
2466
 
1972
- trigger: function(type, data, elem, donative, extra) {
1973
- // Clone the incoming data, if any
1974
- data = jQuery.makeArray(data);
2467
+ // bubbling is internal
2468
+ trigger: function( event, data, elem, bubbling ) {
2469
+ // Event object or event type
2470
+ var type = event.type || event;
2471
+
2472
+ if( !bubbling ){
2473
+ event = typeof event === "object" ?
2474
+ // jQuery.Event object
2475
+ event[expando] ? event :
2476
+ // Object literal
2477
+ jQuery.extend( jQuery.Event(type), event ) :
2478
+ // Just the event type (string)
2479
+ jQuery.Event(type);
2480
+
2481
+ if ( type.indexOf("!") >= 0 ) {
2482
+ event.type = type = type.slice(0, -1);
2483
+ event.exclusive = true;
2484
+ }
1975
2485
 
1976
- if ( type.indexOf("!") >= 0 ) {
1977
- type = type.slice(0, -1);
1978
- var exclusive = true;
1979
- }
2486
+ // Handle a global trigger
2487
+ if ( !elem ) {
2488
+ // Don't bubble custom events when global (to avoid too much overhead)
2489
+ event.stopPropagation();
2490
+ // Only trigger if we've ever bound an event for it
2491
+ if ( this.global[type] )
2492
+ jQuery.each( jQuery.cache, function(){
2493
+ if ( this.events && this.events[type] )
2494
+ jQuery.event.trigger( event, data, this.handle.elem );
2495
+ });
2496
+ }
1980
2497
 
1981
- // Handle a global trigger
1982
- if ( !elem ) {
1983
- // Only trigger if we've ever bound an event for it
1984
- if ( this.global[type] )
1985
- jQuery("*").add([window, document]).trigger(type, data);
2498
+ // Handle triggering a single element
1986
2499
 
1987
- // Handle triggering a single element
1988
- } else {
1989
2500
  // don't do events on text and comment nodes
1990
- if ( elem.nodeType == 3 || elem.nodeType == 8 )
2501
+ if ( !elem || elem.nodeType == 3 || elem.nodeType == 8 )
1991
2502
  return undefined;
2503
+
2504
+ // Clean up in case it is reused
2505
+ event.result = undefined;
2506
+ event.target = elem;
2507
+
2508
+ // Clone the incoming data, if any
2509
+ data = jQuery.makeArray(data);
2510
+ data.unshift( event );
2511
+ }
1992
2512
 
1993
- var val, ret, fn = jQuery.isFunction( elem[ type ] || null ),
1994
- // Check to see if we need to provide a fake event, or not
1995
- event = !data[0] || !data[0].preventDefault;
1996
-
1997
- // Pass along a fake event
1998
- if ( event ) {
1999
- data.unshift({
2000
- type: type,
2001
- target: elem,
2002
- preventDefault: function(){},
2003
- stopPropagation: function(){},
2004
- timeStamp: now()
2005
- });
2006
- data[0][expando] = true; // no need to fix fake event
2007
- }
2513
+ event.currentTarget = elem;
2008
2514
 
2009
- // Enforce the right trigger type
2010
- data[0].type = type;
2011
- if ( exclusive )
2012
- data[0].exclusive = true;
2013
-
2014
- // Trigger the event, it is assumed that "handle" is a function
2015
- var handle = jQuery.data(elem, "handle");
2016
- if ( handle )
2017
- val = handle.apply( elem, data );
2018
-
2019
- // Handle triggering native .onfoo handlers (and on links since we don't call .click() for links)
2020
- if ( (!fn || (jQuery.nodeName(elem, 'a') && type == "click")) && elem["on"+type] && elem["on"+type].apply( elem, data ) === false )
2021
- val = false;
2022
-
2023
- // Extra functions don't get the custom event object
2024
- if ( event )
2025
- data.shift();
2026
-
2027
- // Handle triggering of extra function
2028
- if ( extra && jQuery.isFunction( extra ) ) {
2029
- // call the extra function and tack the current return value on the end for possible inspection
2030
- ret = extra.apply( elem, val == null ? data : data.concat( val ) );
2031
- // if anything is returned, give it precedence and have it overwrite the previous value
2032
- if (ret !== undefined)
2033
- val = ret;
2034
- }
2515
+ // Trigger the event, it is assumed that "handle" is a function
2516
+ var handle = jQuery.data(elem, "handle");
2517
+ if ( handle )
2518
+ handle.apply( elem, data );
2035
2519
 
2036
- // Trigger the native events (except for clicks on links)
2037
- if ( fn && donative !== false && val !== false && !(jQuery.nodeName(elem, 'a') && type == "click") ) {
2038
- this.triggered = true;
2039
- try {
2040
- elem[ type ]();
2041
- // prevent IE from throwing an error for some hidden elements
2042
- } catch (e) {}
2043
- }
2520
+ // Handle triggering native .onfoo handlers (and on links since we don't call .click() for links)
2521
+ if ( (!elem[type] || (jQuery.nodeName(elem, 'a') && type == "click")) && elem["on"+type] && elem["on"+type].apply( elem, data ) === false )
2522
+ event.result = false;
2044
2523
 
2045
- this.triggered = false;
2524
+ // Trigger the native events (except for clicks on links)
2525
+ if ( !bubbling && elem[type] && !event.isDefaultPrevented() && !(jQuery.nodeName(elem, 'a') && type == "click") ) {
2526
+ this.triggered = true;
2527
+ try {
2528
+ elem[ type ]();
2529
+ // prevent IE from throwing an error for some hidden elements
2530
+ } catch (e) {}
2046
2531
  }
2047
2532
 
2048
- return val;
2533
+ this.triggered = false;
2534
+
2535
+ if ( !event.isPropagationStopped() ) {
2536
+ var parent = elem.parentNode || elem.ownerDocument;
2537
+ if ( parent )
2538
+ jQuery.event.trigger(event, data, parent, true);
2539
+ }
2049
2540
  },
2050
2541
 
2051
2542
  handle: function(event) {
2052
2543
  // returned undefined or false
2053
- var val, ret, namespace, all, handlers;
2544
+ var all, handlers;
2054
2545
 
2055
2546
  event = arguments[0] = jQuery.event.fix( event || window.event );
2056
2547
 
2057
2548
  // Namespaced event handlers
2058
- namespace = event.type.split(".");
2059
- event.type = namespace[0];
2060
- namespace = namespace[1];
2549
+ var namespaces = event.type.split(".");
2550
+ event.type = namespaces.shift();
2551
+
2061
2552
  // Cache this now, all = true means, any handler
2062
- all = !namespace && !event.exclusive;
2553
+ all = !namespaces.length && !event.exclusive;
2554
+
2555
+ var namespace = RegExp("(^|\\.)" + namespaces.slice().sort().join(".*\\.") + "(\\.|$)");
2063
2556
 
2064
2557
  handlers = ( jQuery.data(this, "events") || {} )[event.type];
2065
2558
 
@@ -2067,61 +2560,44 @@ jQuery.event = {
2067
2560
  var handler = handlers[j];
2068
2561
 
2069
2562
  // Filter the functions by class
2070
- if ( all || handler.type == namespace ) {
2563
+ if ( all || namespace.test(handler.type) ) {
2071
2564
  // Pass in a reference to the handler function itself
2072
2565
  // So that we can later remove it
2073
2566
  event.handler = handler;
2074
2567
  event.data = handler.data;
2075
2568
 
2076
- ret = handler.apply( this, arguments );
2569
+ var ret = handler.apply(this, arguments);
2077
2570
 
2078
- if ( val !== false )
2079
- val = ret;
2080
-
2081
- if ( ret === false ) {
2082
- event.preventDefault();
2083
- event.stopPropagation();
2571
+ if( ret !== undefined ){
2572
+ event.result = ret;
2573
+ if ( ret === false ) {
2574
+ event.preventDefault();
2575
+ event.stopPropagation();
2576
+ }
2084
2577
  }
2578
+
2579
+ if( event.isImmediatePropagationStopped() )
2580
+ break;
2581
+
2085
2582
  }
2086
2583
  }
2087
-
2088
- return val;
2089
2584
  },
2090
2585
 
2586
+ props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
2587
+
2091
2588
  fix: function(event) {
2092
- if ( event[expando] == true )
2589
+ if ( event[expando] )
2093
2590
  return event;
2094
2591
 
2095
2592
  // store a copy of the original event object
2096
2593
  // and "clone" to set read-only properties
2097
2594
  var originalEvent = event;
2098
- event = { originalEvent: originalEvent };
2099
- var props = "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target timeStamp toElement type view wheelDelta which".split(" ");
2100
- for ( var i=props.length; i; i-- )
2101
- event[ props[i] ] = originalEvent[ props[i] ];
2102
-
2103
- // Mark it as fixed
2104
- event[expando] = true;
2105
-
2106
- // add preventDefault and stopPropagation since
2107
- // they will not work on the clone
2108
- event.preventDefault = function() {
2109
- // if preventDefault exists run it on the original event
2110
- if (originalEvent.preventDefault)
2111
- originalEvent.preventDefault();
2112
- // otherwise set the returnValue property of the original event to false (IE)
2113
- originalEvent.returnValue = false;
2114
- };
2115
- event.stopPropagation = function() {
2116
- // if stopPropagation exists run it on the original event
2117
- if (originalEvent.stopPropagation)
2118
- originalEvent.stopPropagation();
2119
- // otherwise set the cancelBubble property of the original event to true (IE)
2120
- originalEvent.cancelBubble = true;
2121
- };
2595
+ event = jQuery.Event( originalEvent );
2122
2596
 
2123
- // Fix timeStamp
2124
- event.timeStamp = event.timeStamp || now();
2597
+ for ( var i = this.props.length, prop; i; ){
2598
+ prop = this.props[ --i ];
2599
+ event[ prop ] = originalEvent[ prop ];
2600
+ }
2125
2601
 
2126
2602
  // Fix target property, if necessary
2127
2603
  if ( !event.target )
@@ -2159,6 +2635,7 @@ jQuery.event = {
2159
2635
  },
2160
2636
 
2161
2637
  proxy: function( fn, proxy ){
2638
+ proxy = proxy || function(){ return fn.apply(this, arguments); };
2162
2639
  // Set the guid of unique handler to the same of original handler, so it can be removed
2163
2640
  proxy.guid = fn.guid = fn.guid || proxy.guid || this.guid++;
2164
2641
  // So proxy can be declared as an argument
@@ -2167,60 +2644,128 @@ jQuery.event = {
2167
2644
 
2168
2645
  special: {
2169
2646
  ready: {
2170
- setup: function() {
2171
- // Make sure the ready event is setup
2172
- bindReady();
2173
- return;
2174
- },
2175
-
2176
- teardown: function() { return; }
2177
- },
2178
-
2179
- mouseenter: {
2180
- setup: function() {
2181
- if ( jQuery.browser.msie ) return false;
2182
- jQuery(this).bind("mouseover", jQuery.event.special.mouseenter.handler);
2183
- return true;
2647
+ // Make sure the ready event is setup
2648
+ setup: bindReady,
2649
+ teardown: function() {}
2650
+ }
2651
+ },
2652
+
2653
+ specialAll: {
2654
+ live: {
2655
+ setup: function( selector, namespaces ){
2656
+ jQuery.event.add( this, namespaces[0], liveHandler );
2184
2657
  },
2658
+ teardown: function( namespaces ){
2659
+ if ( namespaces.length ) {
2660
+ var remove = 0, name = RegExp("(^|\\.)" + namespaces[0] + "(\\.|$)");
2661
+
2662
+ jQuery.each( (jQuery.data(this, "events").live || {}), function(){
2663
+ if ( name.test(this.type) )
2664
+ remove++;
2665
+ });
2666
+
2667
+ if ( remove < 1 )
2668
+ jQuery.event.remove( this, namespaces[0], liveHandler );
2669
+ }
2670
+ }
2671
+ }
2672
+ }
2673
+ };
2185
2674
 
2186
- teardown: function() {
2187
- if ( jQuery.browser.msie ) return false;
2188
- jQuery(this).unbind("mouseover", jQuery.event.special.mouseenter.handler);
2189
- return true;
2190
- },
2675
+ jQuery.Event = function( src ){
2676
+ // Allow instantiation without the 'new' keyword
2677
+ if( !this.preventDefault )
2678
+ return new jQuery.Event(src);
2679
+
2680
+ // Event object
2681
+ if( src && src.type ){
2682
+ this.originalEvent = src;
2683
+ this.type = src.type;
2684
+ this.timeStamp = src.timeStamp;
2685
+ // Event type
2686
+ }else
2687
+ this.type = src;
2688
+
2689
+ if( !this.timeStamp )
2690
+ this.timeStamp = now();
2691
+
2692
+ // Mark it as fixed
2693
+ this[expando] = true;
2694
+ };
2191
2695
 
2192
- handler: function(event) {
2193
- // If we actually just moused on to a sub-element, ignore it
2194
- if ( withinElement(event, this) ) return true;
2195
- // Execute the right handlers by setting the event type to mouseenter
2196
- event.type = "mouseenter";
2197
- return jQuery.event.handle.apply(this, arguments);
2198
- }
2199
- },
2696
+ function returnFalse(){
2697
+ return false;
2698
+ }
2699
+ function returnTrue(){
2700
+ return true;
2701
+ }
2200
2702
 
2201
- mouseleave: {
2202
- setup: function() {
2203
- if ( jQuery.browser.msie ) return false;
2204
- jQuery(this).bind("mouseout", jQuery.event.special.mouseleave.handler);
2205
- return true;
2206
- },
2703
+ // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
2704
+ // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
2705
+ jQuery.Event.prototype = {
2706
+ preventDefault: function() {
2707
+ this.isDefaultPrevented = returnTrue;
2207
2708
 
2208
- teardown: function() {
2209
- if ( jQuery.browser.msie ) return false;
2210
- jQuery(this).unbind("mouseout", jQuery.event.special.mouseleave.handler);
2211
- return true;
2212
- },
2709
+ var e = this.originalEvent;
2710
+ if( !e )
2711
+ return;
2712
+ // if preventDefault exists run it on the original event
2713
+ if (e.preventDefault)
2714
+ e.preventDefault();
2715
+ // otherwise set the returnValue property of the original event to false (IE)
2716
+ e.returnValue = false;
2717
+ },
2718
+ stopPropagation: function() {
2719
+ this.isPropagationStopped = returnTrue;
2213
2720
 
2214
- handler: function(event) {
2215
- // If we actually just moused on to a sub-element, ignore it
2216
- if ( withinElement(event, this) ) return true;
2217
- // Execute the right handlers by setting the event type to mouseleave
2218
- event.type = "mouseleave";
2219
- return jQuery.event.handle.apply(this, arguments);
2220
- }
2221
- }
2721
+ var e = this.originalEvent;
2722
+ if( !e )
2723
+ return;
2724
+ // if stopPropagation exists run it on the original event
2725
+ if (e.stopPropagation)
2726
+ e.stopPropagation();
2727
+ // otherwise set the cancelBubble property of the original event to true (IE)
2728
+ e.cancelBubble = true;
2729
+ },
2730
+ stopImmediatePropagation:function(){
2731
+ this.isImmediatePropagationStopped = returnTrue;
2732
+ this.stopPropagation();
2733
+ },
2734
+ isDefaultPrevented: returnFalse,
2735
+ isPropagationStopped: returnFalse,
2736
+ isImmediatePropagationStopped: returnFalse
2737
+ };
2738
+ // Checks if an event happened on an element within another element
2739
+ // Used in jQuery.event.special.mouseenter and mouseleave handlers
2740
+ var withinElement = function(event) {
2741
+ // Check if mouse(over|out) are still within the same parent element
2742
+ var parent = event.relatedTarget;
2743
+ // Traverse up the tree
2744
+ while ( parent && parent != this )
2745
+ try { parent = parent.parentNode; }
2746
+ catch(e) { parent = this; }
2747
+
2748
+ if( parent != this ){
2749
+ // set the correct event type
2750
+ event.type = event.data;
2751
+ // handle event if we actually just moused on to a non sub-element
2752
+ jQuery.event.handle.apply( this, arguments );
2222
2753
  }
2223
2754
  };
2755
+
2756
+ jQuery.each({
2757
+ mouseover: 'mouseenter',
2758
+ mouseout: 'mouseleave'
2759
+ }, function( orig, fix ){
2760
+ jQuery.event.special[ fix ] = {
2761
+ setup: function(){
2762
+ jQuery.event.add( this, orig, withinElement, fix );
2763
+ },
2764
+ teardown: function(){
2765
+ jQuery.event.remove( this, orig, withinElement );
2766
+ }
2767
+ };
2768
+ });
2224
2769
 
2225
2770
  jQuery.fn.extend({
2226
2771
  bind: function( type, data, fn ) {
@@ -2245,14 +2790,20 @@ jQuery.fn.extend({
2245
2790
  });
2246
2791
  },
2247
2792
 
2248
- trigger: function( type, data, fn ) {
2793
+ trigger: function( type, data ) {
2249
2794
  return this.each(function(){
2250
- jQuery.event.trigger( type, data, this, true, fn );
2795
+ jQuery.event.trigger( type, data, this );
2251
2796
  });
2252
2797
  },
2253
2798
 
2254
- triggerHandler: function( type, data, fn ) {
2255
- return this[0] && jQuery.event.trigger( type, data, this[0], false, fn );
2799
+ triggerHandler: function( type, data ) {
2800
+ if( this[0] ){
2801
+ var event = jQuery.Event(type);
2802
+ event.preventDefault();
2803
+ event.stopPropagation();
2804
+ jQuery.event.trigger( event, data, this[0] );
2805
+ return event.result;
2806
+ }
2256
2807
  },
2257
2808
 
2258
2809
  toggle: function( fn ) {
@@ -2276,7 +2827,7 @@ jQuery.fn.extend({
2276
2827
  },
2277
2828
 
2278
2829
  hover: function(fnOver, fnOut) {
2279
- return this.bind('mouseenter', fnOver).bind('mouseleave', fnOut);
2830
+ return this.mouseenter(fnOver).mouseleave(fnOut);
2280
2831
  },
2281
2832
 
2282
2833
  ready: function(fn) {
@@ -2291,12 +2842,52 @@ jQuery.fn.extend({
2291
2842
  // Otherwise, remember the function for later
2292
2843
  else
2293
2844
  // Add the function to the wait list
2294
- jQuery.readyList.push( function() { return fn.call(this, jQuery); } );
2845
+ jQuery.readyList.push( fn );
2846
+
2847
+ return this;
2848
+ },
2849
+
2850
+ live: function( type, fn ){
2851
+ var proxy = jQuery.event.proxy( fn );
2852
+ proxy.guid += this.selector + type;
2853
+
2854
+ jQuery(document).bind( liveConvert(type, this.selector), this.selector, proxy );
2295
2855
 
2856
+ return this;
2857
+ },
2858
+
2859
+ die: function( type, fn ){
2860
+ jQuery(document).unbind( liveConvert(type, this.selector), fn ? { guid: fn.guid + this.selector + type } : null );
2296
2861
  return this;
2297
2862
  }
2298
2863
  });
2299
2864
 
2865
+ function liveHandler( event ){
2866
+ var check = RegExp("(^|\\.)" + event.type + "(\\.|$)"),
2867
+ stop = true,
2868
+ elems = [];
2869
+
2870
+ jQuery.each(jQuery.data(this, "events").live || [], function(i, fn){
2871
+ if ( check.test(fn.type) ) {
2872
+ var elem = jQuery(event.target).closest(fn.data)[0];
2873
+ if ( elem )
2874
+ elems.push({ elem: elem, fn: fn });
2875
+ }
2876
+ });
2877
+
2878
+ jQuery.each(elems, function(){
2879
+ if ( !event.isImmediatePropagationStopped() &&
2880
+ this.fn.call(this.elem, event, this.fn.data) === false )
2881
+ stop = false;
2882
+ });
2883
+
2884
+ return stop;
2885
+ }
2886
+
2887
+ function liveConvert(type, selector){
2888
+ return ["live", type, selector.replace(/\./g, "`").replace(/ /g, "|")].join(".");
2889
+ }
2890
+
2300
2891
  jQuery.extend({
2301
2892
  isReady: false,
2302
2893
  readyList: [],
@@ -2311,7 +2902,7 @@ jQuery.extend({
2311
2902
  if ( jQuery.readyList ) {
2312
2903
  // Execute all of them
2313
2904
  jQuery.each( jQuery.readyList, function(){
2314
- this.call( document );
2905
+ this.call( document, jQuery );
2315
2906
  });
2316
2907
 
2317
2908
  // Reset the list of functions
@@ -2330,53 +2921,39 @@ function bindReady(){
2330
2921
  if ( readyBound ) return;
2331
2922
  readyBound = true;
2332
2923
 
2333
- // Mozilla, Opera (see further below for it) and webkit nightlies currently support this event
2334
- if ( document.addEventListener && !jQuery.browser.opera)
2924
+ // Mozilla, Opera and webkit nightlies currently support this event
2925
+ if ( document.addEventListener ) {
2335
2926
  // Use the handy event callback
2336
- document.addEventListener( "DOMContentLoaded", jQuery.ready, false );
2337
-
2338
- // If IE is used and is not in a frame
2339
- // Continually check to see if the document is ready
2340
- if ( jQuery.browser.msie && window == top ) (function(){
2341
- if (jQuery.isReady) return;
2342
- try {
2343
- // If IE is used, use the trick by Diego Perini
2344
- // http://javascript.nwbox.com/IEContentLoaded/
2345
- document.documentElement.doScroll("left");
2346
- } catch( error ) {
2347
- setTimeout( arguments.callee, 0 );
2348
- return;
2349
- }
2350
- // and execute any waiting functions
2351
- jQuery.ready();
2352
- })();
2353
-
2354
- if ( jQuery.browser.opera )
2355
- document.addEventListener( "DOMContentLoaded", function () {
2356
- if (jQuery.isReady) return;
2357
- for (var i = 0; i < document.styleSheets.length; i++)
2358
- if (document.styleSheets[i].disabled) {
2359
- setTimeout( arguments.callee, 0 );
2360
- return;
2361
- }
2362
- // and execute any waiting functions
2927
+ document.addEventListener( "DOMContentLoaded", function(){
2928
+ document.removeEventListener( "DOMContentLoaded", arguments.callee, false );
2363
2929
  jQuery.ready();
2364
- }, false);
2365
-
2366
- if ( jQuery.browser.safari ) {
2367
- var numStyles;
2368
- (function(){
2369
- if (jQuery.isReady) return;
2370
- if ( document.readyState != "loaded" && document.readyState != "complete" ) {
2371
- setTimeout( arguments.callee, 0 );
2372
- return;
2930
+ }, false );
2931
+
2932
+ // If IE event model is used
2933
+ } else if ( document.attachEvent ) {
2934
+ // ensure firing before onload,
2935
+ // maybe late but safe also for iframes
2936
+ document.attachEvent("onreadystatechange", function(){
2937
+ if ( document.readyState === "complete" ) {
2938
+ document.detachEvent( "onreadystatechange", arguments.callee );
2939
+ jQuery.ready();
2373
2940
  }
2374
- if ( numStyles === undefined )
2375
- numStyles = jQuery("style, link[rel=stylesheet]").length;
2376
- if ( document.styleSheets.length != numStyles ) {
2941
+ });
2942
+
2943
+ // If IE and not an iframe
2944
+ // continually check to see if the document is ready
2945
+ if ( document.documentElement.doScroll && !window.frameElement ) (function(){
2946
+ if ( jQuery.isReady ) return;
2947
+
2948
+ try {
2949
+ // If IE is used, use the trick by Diego Perini
2950
+ // http://javascript.nwbox.com/IEContentLoaded/
2951
+ document.documentElement.doScroll("left");
2952
+ } catch( error ) {
2377
2953
  setTimeout( arguments.callee, 0 );
2378
2954
  return;
2379
2955
  }
2956
+
2380
2957
  // and execute any waiting functions
2381
2958
  jQuery.ready();
2382
2959
  })();
@@ -2387,8 +2964,8 @@ function bindReady(){
2387
2964
  }
2388
2965
 
2389
2966
  jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," +
2390
- "mousedown,mouseup,mousemove,mouseover,mouseout,change,select," +
2391
- "submit,keydown,keypress,keyup,error").split(","), function(i, name){
2967
+ "mousedown,mouseup,mousemove,mouseover,mouseout,mouseenter,mouseleave," +
2968
+ "change,select,submit,keydown,keypress,keyup,error").split(","), function(i, name){
2392
2969
 
2393
2970
  // Handle event binding
2394
2971
  jQuery.fn[name] = function(fn){
@@ -2396,29 +2973,134 @@ jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," +
2396
2973
  };
2397
2974
  });
2398
2975
 
2399
- // Checks if an event happened on an element within another element
2400
- // Used in jQuery.event.special.mouseenter and mouseleave handlers
2401
- var withinElement = function(event, elem) {
2402
- // Check if mouse(over|out) are still within the same parent element
2403
- var parent = event.relatedTarget;
2404
- // Traverse up the tree
2405
- while ( parent && parent != elem ) try { parent = parent.parentNode; } catch(error) { parent = elem; }
2406
- // Return true if we actually just moused on to a sub-element
2407
- return parent == elem;
2408
- };
2409
-
2410
2976
  // Prevent memory leaks in IE
2411
2977
  // And prevent errors on refresh with events like mouseover in other browsers
2412
2978
  // Window isn't included so as not to unbind existing unload events
2413
- jQuery(window).bind("unload", function() {
2414
- jQuery("*").add(document).unbind();
2415
- });
2979
+ jQuery( window ).bind( 'unload', function(){
2980
+ for ( var id in jQuery.cache )
2981
+ // Skip the window
2982
+ if ( id != 1 && jQuery.cache[ id ].handle )
2983
+ jQuery.event.remove( jQuery.cache[ id ].handle.elem );
2984
+ });
2985
+ (function(){
2986
+
2987
+ jQuery.support = {};
2988
+
2989
+ var root = document.documentElement,
2990
+ script = document.createElement("script"),
2991
+ div = document.createElement("div"),
2992
+ id = "script" + (new Date).getTime();
2993
+
2994
+ div.style.display = "none";
2995
+ div.innerHTML = ' <link/><table></table><a href="/a" style="color:red;float:left;opacity:.5;">a</a><select><option>text</option></select><object><param/></object>';
2996
+
2997
+ var all = div.getElementsByTagName("*"),
2998
+ a = div.getElementsByTagName("a")[0];
2999
+
3000
+ // Can't get basic test support
3001
+ if ( !all || !all.length || !a ) {
3002
+ return;
3003
+ }
3004
+
3005
+ jQuery.support = {
3006
+ // IE strips leading whitespace when .innerHTML is used
3007
+ leadingWhitespace: div.firstChild.nodeType == 3,
3008
+
3009
+ // Make sure that tbody elements aren't automatically inserted
3010
+ // IE will insert them into empty tables
3011
+ tbody: !div.getElementsByTagName("tbody").length,
3012
+
3013
+ // Make sure that you can get all elements in an <object> element
3014
+ // IE 7 always returns no results
3015
+ objectAll: !!div.getElementsByTagName("object")[0]
3016
+ .getElementsByTagName("*").length,
3017
+
3018
+ // Make sure that link elements get serialized correctly by innerHTML
3019
+ // This requires a wrapper element in IE
3020
+ htmlSerialize: !!div.getElementsByTagName("link").length,
3021
+
3022
+ // Get the style information from getAttribute
3023
+ // (IE uses .cssText insted)
3024
+ style: /red/.test( a.getAttribute("style") ),
3025
+
3026
+ // Make sure that URLs aren't manipulated
3027
+ // (IE normalizes it by default)
3028
+ hrefNormalized: a.getAttribute("href") === "/a",
3029
+
3030
+ // Make sure that element opacity exists
3031
+ // (IE uses filter instead)
3032
+ opacity: a.style.opacity === "0.5",
3033
+
3034
+ // Verify style float existence
3035
+ // (IE uses styleFloat instead of cssFloat)
3036
+ cssFloat: !!a.style.cssFloat,
3037
+
3038
+ // Will be defined later
3039
+ scriptEval: false,
3040
+ noCloneEvent: true,
3041
+ boxModel: null
3042
+ };
3043
+
3044
+ script.type = "text/javascript";
3045
+ try {
3046
+ script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
3047
+ } catch(e){}
3048
+
3049
+ root.insertBefore( script, root.firstChild );
3050
+
3051
+ // Make sure that the execution of code works by injecting a script
3052
+ // tag with appendChild/createTextNode
3053
+ // (IE doesn't support this, fails, and uses .text instead)
3054
+ if ( window[ id ] ) {
3055
+ jQuery.support.scriptEval = true;
3056
+ delete window[ id ];
3057
+ }
3058
+
3059
+ root.removeChild( script );
3060
+
3061
+ if ( div.attachEvent && div.fireEvent ) {
3062
+ div.attachEvent("onclick", function(){
3063
+ // Cloning a node shouldn't copy over any
3064
+ // bound event handlers (IE does this)
3065
+ jQuery.support.noCloneEvent = false;
3066
+ div.detachEvent("onclick", arguments.callee);
3067
+ });
3068
+ div.cloneNode(true).fireEvent("onclick");
3069
+ }
3070
+
3071
+ // Figure out if the W3C box model works as expected
3072
+ // document.body must exist before we can do this
3073
+ jQuery(function(){
3074
+ var div = document.createElement("div");
3075
+ div.style.width = "1px";
3076
+ div.style.paddingLeft = "1px";
3077
+
3078
+ document.body.appendChild( div );
3079
+ jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2;
3080
+ document.body.removeChild( div );
3081
+ });
3082
+ })();
3083
+
3084
+ var styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat";
3085
+
3086
+ jQuery.props = {
3087
+ "for": "htmlFor",
3088
+ "class": "className",
3089
+ "float": styleFloat,
3090
+ cssFloat: styleFloat,
3091
+ styleFloat: styleFloat,
3092
+ readonly: "readOnly",
3093
+ maxlength: "maxLength",
3094
+ cellspacing: "cellSpacing",
3095
+ rowspan: "rowSpan",
3096
+ tabindex: "tabIndex"
3097
+ };
2416
3098
  jQuery.fn.extend({
2417
3099
  // Keep a copy of the old load
2418
3100
  _load: jQuery.fn.load,
2419
3101
 
2420
3102
  load: function( url, params, callback ) {
2421
- if ( typeof url != 'string' )
3103
+ if ( typeof url !== "string" )
2422
3104
  return this._load( url );
2423
3105
 
2424
3106
  var off = url.indexOf(" ");
@@ -2427,8 +3109,6 @@ jQuery.fn.extend({
2427
3109
  url = url.slice(0, off);
2428
3110
  }
2429
3111
 
2430
- callback = callback || function(){};
2431
-
2432
3112
  // Default to a GET request
2433
3113
  var type = "GET";
2434
3114
 
@@ -2441,7 +3121,7 @@ jQuery.fn.extend({
2441
3121
  params = null;
2442
3122
 
2443
3123
  // Otherwise, build a param string
2444
- } else {
3124
+ } else if( typeof params === "object" ) {
2445
3125
  params = jQuery.param( params );
2446
3126
  type = "POST";
2447
3127
  }
@@ -2471,7 +3151,8 @@ jQuery.fn.extend({
2471
3151
  // If not, just inject the full result
2472
3152
  res.responseText );
2473
3153
 
2474
- self.each( callback, [res.responseText, status, res] );
3154
+ if( callback )
3155
+ self.each( callback, [res.responseText, status, res] );
2475
3156
  }
2476
3157
  });
2477
3158
  return this;
@@ -2482,8 +3163,7 @@ jQuery.fn.extend({
2482
3163
  },
2483
3164
  serializeArray: function() {
2484
3165
  return this.map(function(){
2485
- return jQuery.nodeName(this, "form") ?
2486
- jQuery.makeArray(this.elements) : this;
3166
+ return this.elements ? jQuery.makeArray(this.elements) : this;
2487
3167
  })
2488
3168
  .filter(function(){
2489
3169
  return this.name && !this.disabled &&
@@ -2493,7 +3173,7 @@ jQuery.fn.extend({
2493
3173
  .map(function(i, elem){
2494
3174
  var val = jQuery(this).val();
2495
3175
  return val == null ? null :
2496
- val.constructor == Array ?
3176
+ jQuery.isArray(val) ?
2497
3177
  jQuery.map( val, function(val, i){
2498
3178
  return {name: elem.name, value: val};
2499
3179
  }) :
@@ -2512,6 +3192,7 @@ jQuery.each( "ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".sp
2512
3192
  var jsc = now();
2513
3193
 
2514
3194
  jQuery.extend({
3195
+
2515
3196
  get: function( url, data, callback, type ) {
2516
3197
  // shift arguments if data argument was ommited
2517
3198
  if ( jQuery.isFunction( data ) ) {
@@ -2559,13 +3240,21 @@ jQuery.extend({
2559
3240
  url: location.href,
2560
3241
  global: true,
2561
3242
  type: "GET",
2562
- timeout: 0,
2563
3243
  contentType: "application/x-www-form-urlencoded",
2564
3244
  processData: true,
2565
3245
  async: true,
3246
+ /*
3247
+ timeout: 0,
2566
3248
  data: null,
2567
3249
  username: null,
2568
3250
  password: null,
3251
+ */
3252
+ // Create the request object; Microsoft failed to properly
3253
+ // implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available
3254
+ // This function can be overriden by calling jQuery.ajaxSetup
3255
+ xhr:function(){
3256
+ return window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
3257
+ },
2569
3258
  accepts: {
2570
3259
  xml: "application/xml, text/xml",
2571
3260
  html: "text/html",
@@ -2588,7 +3277,7 @@ jQuery.extend({
2588
3277
  type = s.type.toUpperCase();
2589
3278
 
2590
3279
  // convert data if not already a string
2591
- if ( s.data && s.processData && typeof s.data != "string" )
3280
+ if ( s.data && s.processData && typeof s.data !== "string" )
2592
3281
  s.data = jQuery.param(s.data);
2593
3282
 
2594
3283
  // Handle JSONP Parameter Callbacks
@@ -2651,12 +3340,13 @@ jQuery.extend({
2651
3340
  jQuery.event.trigger( "ajaxStart" );
2652
3341
 
2653
3342
  // Matches an absolute URL, and saves the domain
2654
- var remote = /^(?:\w+:)?\/\/([^\/?#]+)/;
3343
+ var parts = /^(\w+:)?\/\/([^\/?#]+)/.exec( s.url );
2655
3344
 
2656
3345
  // If we're requesting a remote document
2657
3346
  // and trying to load JSON or Script with a GET
2658
- if ( s.dataType == "script" && type == "GET"
2659
- && remote.test(s.url) && remote.exec(s.url)[1] != location.host ){
3347
+ if ( s.dataType == "script" && type == "GET" && parts
3348
+ && ( parts[1] && parts[1] != location.protocol || parts[2] != location.host )){
3349
+
2660
3350
  var head = document.getElementsByTagName("head")[0];
2661
3351
  var script = document.createElement("script");
2662
3352
  script.src = s.url;
@@ -2687,9 +3377,8 @@ jQuery.extend({
2687
3377
 
2688
3378
  var requestDone = false;
2689
3379
 
2690
- // Create the request object; Microsoft failed to properly
2691
- // implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available
2692
- var xhr = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
3380
+ // Create the request object
3381
+ var xhr = s.xhr();
2693
3382
 
2694
3383
  // Open the socket
2695
3384
  // Passing null username, generates a login popup on Opera (#2865)
@@ -2718,10 +3407,11 @@ jQuery.extend({
2718
3407
  s.accepts._default );
2719
3408
  } catch(e){}
2720
3409
 
2721
- // Allow custom headers/mimetypes
3410
+ // Allow custom headers/mimetypes and early abort
2722
3411
  if ( s.beforeSend && s.beforeSend(xhr, s) === false ) {
2723
- // cleanup active request counter
2724
- s.global && jQuery.active--;
3412
+ // Handle the global AJAX counter
3413
+ if ( s.global && ! --jQuery.active )
3414
+ jQuery.event.trigger( "ajaxStop" );
2725
3415
  // close opended socket
2726
3416
  xhr.abort();
2727
3417
  return false;
@@ -2732,8 +3422,18 @@ jQuery.extend({
2732
3422
 
2733
3423
  // Wait for a response to come back
2734
3424
  var onreadystatechange = function(isTimeout){
3425
+ // The request was aborted, clear the interval and decrement jQuery.active
3426
+ if (xhr.readyState == 0) {
3427
+ if (ival) {
3428
+ // clear poll interval
3429
+ clearInterval(ival);
3430
+ ival = null;
3431
+ // Handle the global AJAX counter
3432
+ if ( s.global && ! --jQuery.active )
3433
+ jQuery.event.trigger( "ajaxStop" );
3434
+ }
2735
3435
  // The transfer is complete and the data is available, or the request timed out
2736
- if ( !requestDone && xhr && (xhr.readyState == 4 || isTimeout == "timeout") ) {
3436
+ } else if ( !requestDone && xhr && (xhr.readyState == 4 || isTimeout == "timeout") ) {
2737
3437
  requestDone = true;
2738
3438
 
2739
3439
  // clear poll interval
@@ -2742,16 +3442,16 @@ jQuery.extend({
2742
3442
  ival = null;
2743
3443
  }
2744
3444
 
2745
- status = isTimeout == "timeout" && "timeout" ||
2746
- !jQuery.httpSuccess( xhr ) && "error" ||
2747
- s.ifModified && jQuery.httpNotModified( xhr, s.url ) && "notmodified" ||
3445
+ status = isTimeout == "timeout" ? "timeout" :
3446
+ !jQuery.httpSuccess( xhr ) ? "error" :
3447
+ s.ifModified && jQuery.httpNotModified( xhr, s.url ) ? "notmodified" :
2748
3448
  "success";
2749
3449
 
2750
3450
  if ( status == "success" ) {
2751
3451
  // Watch for, and catch, XML document parse errors
2752
3452
  try {
2753
3453
  // process the data (runs the xml through httpData regardless of callback)
2754
- data = jQuery.httpData( xhr, s.dataType, s.dataFilter );
3454
+ data = jQuery.httpData( xhr, s.dataType, s );
2755
3455
  } catch(e) {
2756
3456
  status = "parsererror";
2757
3457
  }
@@ -2792,11 +3492,12 @@ jQuery.extend({
2792
3492
  setTimeout(function(){
2793
3493
  // Check to see if the request is still happening
2794
3494
  if ( xhr ) {
2795
- // Cancel the request
2796
- xhr.abort();
2797
-
2798
3495
  if( !requestDone )
2799
3496
  onreadystatechange( "timeout" );
3497
+
3498
+ // Cancel the request
3499
+ if ( xhr )
3500
+ xhr.abort();
2800
3501
  }
2801
3502
  }, s.timeout);
2802
3503
  }
@@ -2857,8 +3558,7 @@ jQuery.extend({
2857
3558
  try {
2858
3559
  // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
2859
3560
  return !xhr.status && location.protocol == "file:" ||
2860
- ( xhr.status >= 200 && xhr.status < 300 ) || xhr.status == 304 || xhr.status == 1223 ||
2861
- jQuery.browser.safari && xhr.status == undefined;
3561
+ ( xhr.status >= 200 && xhr.status < 300 ) || xhr.status == 304 || xhr.status == 1223;
2862
3562
  } catch(e){}
2863
3563
  return false;
2864
3564
  },
@@ -2869,13 +3569,12 @@ jQuery.extend({
2869
3569
  var xhrRes = xhr.getResponseHeader("Last-Modified");
2870
3570
 
2871
3571
  // Firefox always returns 200. check Last-Modified date
2872
- return xhr.status == 304 || xhrRes == jQuery.lastModified[url] ||
2873
- jQuery.browser.safari && xhr.status == undefined;
3572
+ return xhr.status == 304 || xhrRes == jQuery.lastModified[url];
2874
3573
  } catch(e){}
2875
3574
  return false;
2876
3575
  },
2877
3576
 
2878
- httpData: function( xhr, type, filter ) {
3577
+ httpData: function( xhr, type, s ) {
2879
3578
  var ct = xhr.getResponseHeader("content-type"),
2880
3579
  xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0,
2881
3580
  data = xml ? xhr.responseXML : xhr.responseText;
@@ -2884,31 +3583,40 @@ jQuery.extend({
2884
3583
  throw "parsererror";
2885
3584
 
2886
3585
  // Allow a pre-filtering function to sanitize the response
2887
- if( filter )
2888
- data = filter( data, type );
3586
+ // s != null is checked to keep backwards compatibility
3587
+ if( s && s.dataFilter )
3588
+ data = s.dataFilter( data, type );
2889
3589
 
2890
- // If the type is "script", eval it in global context
2891
- if ( type == "script" )
2892
- jQuery.globalEval( data );
3590
+ // The filter can actually parse the response
3591
+ if( typeof data === "string" ){
2893
3592
 
2894
- // Get the JavaScript object, if JSON is used.
2895
- if ( type == "json" )
2896
- data = eval("(" + data + ")");
3593
+ // If the type is "script", eval it in global context
3594
+ if ( type == "script" )
3595
+ jQuery.globalEval( data );
2897
3596
 
3597
+ // Get the JavaScript object, if JSON is used.
3598
+ if ( type == "json" )
3599
+ data = window["eval"]("(" + data + ")");
3600
+ }
3601
+
2898
3602
  return data;
2899
3603
  },
2900
3604
 
2901
3605
  // Serialize an array of form elements or a set of
2902
3606
  // key/values into a query string
2903
3607
  param: function( a ) {
2904
- var s = [];
3608
+ var s = [ ];
3609
+
3610
+ function add( key, value ){
3611
+ s[ s.length ] = encodeURIComponent(key) + '=' + encodeURIComponent(value);
3612
+ };
2905
3613
 
2906
3614
  // If an array was passed in, assume that it is an array
2907
3615
  // of form elements
2908
- if ( a.constructor == Array || a.jquery )
3616
+ if ( jQuery.isArray(a) || a.jquery )
2909
3617
  // Serialize the form elements
2910
3618
  jQuery.each( a, function(){
2911
- s.push( encodeURIComponent(this.name) + "=" + encodeURIComponent( this.value ) );
3619
+ add( this.name, this.value );
2912
3620
  });
2913
3621
 
2914
3622
  // Otherwise, assume that it's an object of key/value pairs
@@ -2916,83 +3624,99 @@ jQuery.extend({
2916
3624
  // Serialize the key/values
2917
3625
  for ( var j in a )
2918
3626
  // If the value is an array then the key names need to be repeated
2919
- if ( a[j] && a[j].constructor == Array )
3627
+ if ( jQuery.isArray(a[j]) )
2920
3628
  jQuery.each( a[j], function(){
2921
- s.push( encodeURIComponent(j) + "=" + encodeURIComponent( this ) );
3629
+ add( j, this );
2922
3630
  });
2923
3631
  else
2924
- s.push( encodeURIComponent(j) + "=" + encodeURIComponent( jQuery.isFunction(a[j]) ? a[j]() : a[j] ) );
3632
+ add( j, jQuery.isFunction(a[j]) ? a[j]() : a[j] );
2925
3633
 
2926
3634
  // Return the resulting serialization
2927
3635
  return s.join("&").replace(/%20/g, "+");
2928
3636
  }
2929
3637
 
2930
3638
  });
3639
+ var elemdisplay = {},
3640
+ fxAttrs = [
3641
+ // height animations
3642
+ [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
3643
+ // width animations
3644
+ [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
3645
+ // opacity animations
3646
+ [ "opacity" ]
3647
+ ];
3648
+
3649
+ function genFx( type, num ){
3650
+ var obj = {};
3651
+ jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function(){
3652
+ obj[ this ] = type;
3653
+ });
3654
+ return obj;
3655
+ }
3656
+
2931
3657
  jQuery.fn.extend({
2932
3658
  show: function(speed,callback){
2933
- return speed ?
2934
- this.animate({
2935
- height: "show", width: "show", opacity: "show"
2936
- }, speed, callback) :
2937
-
2938
- this.filter(":hidden").each(function(){
2939
- this.style.display = this.oldblock || "";
2940
- if ( jQuery.css(this,"display") == "none" ) {
2941
- var elem = jQuery("<" + this.tagName + " />").appendTo("body");
2942
- this.style.display = elem.css("display");
2943
- // handle an edge condition where css is - div { display:none; } or similar
2944
- if (this.style.display == "none")
2945
- this.style.display = "block";
2946
- elem.remove();
3659
+ if ( speed ) {
3660
+ return this.animate( genFx("show", 3), speed, callback);
3661
+ } else {
3662
+ for ( var i = 0, l = this.length; i < l; i++ ){
3663
+ var old = jQuery.data(this[i], "olddisplay");
3664
+
3665
+ this[i].style.display = old || "";
3666
+
3667
+ if ( jQuery.css(this[i], "display") === "none" ) {
3668
+ var tagName = this[i].tagName, display;
3669
+
3670
+ if ( elemdisplay[ tagName ] ) {
3671
+ display = elemdisplay[ tagName ];
3672
+ } else {
3673
+ var elem = jQuery("<" + tagName + " />").appendTo("body");
3674
+
3675
+ display = elem.css("display");
3676
+ if ( display === "none" )
3677
+ display = "block";
3678
+
3679
+ elem.remove();
3680
+
3681
+ elemdisplay[ tagName ] = display;
3682
+ }
3683
+
3684
+ this[i].style.display = jQuery.data(this[i], "olddisplay", display);
2947
3685
  }
2948
- }).end();
3686
+ }
3687
+
3688
+ return this;
3689
+ }
2949
3690
  },
2950
3691
 
2951
3692
  hide: function(speed,callback){
2952
- return speed ?
2953
- this.animate({
2954
- height: "hide", width: "hide", opacity: "hide"
2955
- }, speed, callback) :
2956
-
2957
- this.filter(":visible").each(function(){
2958
- this.oldblock = this.oldblock || jQuery.css(this,"display");
2959
- this.style.display = "none";
2960
- }).end();
3693
+ if ( speed ) {
3694
+ return this.animate( genFx("hide", 3), speed, callback);
3695
+ } else {
3696
+ for ( var i = 0, l = this.length; i < l; i++ ){
3697
+ var old = jQuery.data(this[i], "olddisplay");
3698
+ if ( !old && old !== "none" )
3699
+ jQuery.data(this[i], "olddisplay", jQuery.css(this[i], "display"));
3700
+ this[i].style.display = "none";
3701
+ }
3702
+ return this;
3703
+ }
2961
3704
  },
2962
3705
 
2963
3706
  // Save the old toggle function
2964
3707
  _toggle: jQuery.fn.toggle,
2965
3708
 
2966
3709
  toggle: function( fn, fn2 ){
3710
+ var bool = typeof fn === "boolean";
3711
+
2967
3712
  return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ?
2968
3713
  this._toggle.apply( this, arguments ) :
2969
- fn ?
2970
- this.animate({
2971
- height: "toggle", width: "toggle", opacity: "toggle"
2972
- }, fn, fn2) :
3714
+ fn == null || bool ?
2973
3715
  this.each(function(){
2974
- jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ]();
2975
- });
2976
- },
2977
-
2978
- slideDown: function(speed,callback){
2979
- return this.animate({height: "show"}, speed, callback);
2980
- },
2981
-
2982
- slideUp: function(speed,callback){
2983
- return this.animate({height: "hide"}, speed, callback);
2984
- },
2985
-
2986
- slideToggle: function(speed, callback){
2987
- return this.animate({height: "toggle"}, speed, callback);
2988
- },
2989
-
2990
- fadeIn: function(speed, callback){
2991
- return this.animate({opacity: "show"}, speed, callback);
2992
- },
2993
-
2994
- fadeOut: function(speed, callback){
2995
- return this.animate({opacity: "hide"}, speed, callback);
3716
+ var state = bool ? fn : jQuery(this).is(":hidden");
3717
+ jQuery(this)[ state ? "show" : "hide" ]();
3718
+ }) :
3719
+ this.animate(genFx("toggle", 3), fn, fn2);
2996
3720
  },
2997
3721
 
2998
3722
  fadeTo: function(speed,to,callback){
@@ -3003,17 +3727,16 @@ jQuery.fn.extend({
3003
3727
  var optall = jQuery.speed(speed, easing, callback);
3004
3728
 
3005
3729
  return this[ optall.queue === false ? "each" : "queue" ](function(){
3006
- if ( this.nodeType != 1)
3007
- return false;
3008
-
3730
+
3009
3731
  var opt = jQuery.extend({}, optall), p,
3010
- hidden = jQuery(this).is(":hidden"), self = this;
3011
-
3732
+ hidden = this.nodeType == 1 && jQuery(this).is(":hidden"),
3733
+ self = this;
3734
+
3012
3735
  for ( p in prop ) {
3013
3736
  if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden )
3014
3737
  return opt.complete.call(this);
3015
3738
 
3016
- if ( p == "height" || p == "width" ) {
3739
+ if ( ( p == "height" || p == "width" ) && this.style ) {
3017
3740
  // Store display property
3018
3741
  opt.display = jQuery.css(this, "display");
3019
3742
 
@@ -3062,27 +3785,6 @@ jQuery.fn.extend({
3062
3785
  });
3063
3786
  },
3064
3787
 
3065
- queue: function(type, fn){
3066
- if ( jQuery.isFunction(type) || ( type && type.constructor == Array )) {
3067
- fn = type;
3068
- type = "fx";
3069
- }
3070
-
3071
- if ( !type || (typeof type == "string" && !fn) )
3072
- return queue( this[0], type );
3073
-
3074
- return this.each(function(){
3075
- if ( fn.constructor == Array )
3076
- queue(this, type, fn);
3077
- else {
3078
- queue(this, type).push( fn );
3079
-
3080
- if ( queue(this, type).length == 1 )
3081
- fn.call(this);
3082
- }
3083
- });
3084
- },
3085
-
3086
3788
  stop: function(clearQueue, gotoEnd){
3087
3789
  var timers = jQuery.timers;
3088
3790
 
@@ -3109,46 +3811,31 @@ jQuery.fn.extend({
3109
3811
 
3110
3812
  });
3111
3813
 
3112
- var queue = function( elem, type, array ) {
3113
- if ( elem ){
3114
-
3115
- type = type || "fx";
3116
-
3117
- var q = jQuery.data( elem, type + "queue" );
3118
-
3119
- if ( !q || array )
3120
- q = jQuery.data( elem, type + "queue", jQuery.makeArray(array) );
3121
-
3122
- }
3123
- return q;
3124
- };
3125
-
3126
- jQuery.fn.dequeue = function(type){
3127
- type = type || "fx";
3128
-
3129
- return this.each(function(){
3130
- var q = queue(this, type);
3131
-
3132
- q.shift();
3133
-
3134
- if ( q.length )
3135
- q[0].call( this );
3136
- });
3137
- };
3814
+ // Generate shortcuts for custom animations
3815
+ jQuery.each({
3816
+ slideDown: genFx("show", 1),
3817
+ slideUp: genFx("hide", 1),
3818
+ slideToggle: genFx("toggle", 1),
3819
+ fadeIn: { opacity: "show" },
3820
+ fadeOut: { opacity: "hide" }
3821
+ }, function( name, props ){
3822
+ jQuery.fn[ name ] = function( speed, callback ){
3823
+ return this.animate( props, speed, callback );
3824
+ };
3825
+ });
3138
3826
 
3139
3827
  jQuery.extend({
3140
3828
 
3141
3829
  speed: function(speed, easing, fn) {
3142
- var opt = speed && speed.constructor == Object ? speed : {
3830
+ var opt = typeof speed === "object" ? speed : {
3143
3831
  complete: fn || !fn && easing ||
3144
3832
  jQuery.isFunction( speed ) && speed,
3145
3833
  duration: speed,
3146
- easing: fn && easing || easing && easing.constructor != Function && easing
3834
+ easing: fn && easing || easing && !jQuery.isFunction(easing) && easing
3147
3835
  };
3148
3836
 
3149
- opt.duration = (opt.duration && opt.duration.constructor == Number ?
3150
- opt.duration :
3151
- jQuery.fx.speeds[opt.duration]) || jQuery.fx.speeds.def;
3837
+ opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
3838
+ jQuery.fx.speeds[opt.duration] || jQuery.fx.speeds._default;
3152
3839
 
3153
3840
  // Queueing
3154
3841
  opt.old = opt.complete;
@@ -3195,13 +3882,13 @@ jQuery.fx.prototype = {
3195
3882
  (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
3196
3883
 
3197
3884
  // Set display property to block for height/width animations
3198
- if ( this.prop == "height" || this.prop == "width" )
3885
+ if ( ( this.prop == "height" || this.prop == "width" ) && this.elem.style )
3199
3886
  this.elem.style.display = "block";
3200
3887
  },
3201
3888
 
3202
3889
  // Get the current size
3203
3890
  cur: function(force){
3204
- if ( this.elem[this.prop] != null && this.elem.style[this.prop] == null )
3891
+ if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) )
3205
3892
  return this.elem[ this.prop ];
3206
3893
 
3207
3894
  var r = parseFloat(jQuery.css(this.elem, this.prop, force));
@@ -3216,7 +3903,6 @@ jQuery.fx.prototype = {
3216
3903
  this.unit = unit || this.unit || "px";
3217
3904
  this.now = this.start;
3218
3905
  this.pos = this.state = 0;
3219
- this.update();
3220
3906
 
3221
3907
  var self = this;
3222
3908
  function t(gotoEnd){
@@ -3227,7 +3913,7 @@ jQuery.fx.prototype = {
3227
3913
 
3228
3914
  jQuery.timers.push(t);
3229
3915
 
3230
- if ( jQuery.timerId == null ) {
3916
+ if ( t() && jQuery.timerId == null ) {
3231
3917
  jQuery.timerId = setInterval(function(){
3232
3918
  var timers = jQuery.timers;
3233
3919
 
@@ -3250,12 +3936,9 @@ jQuery.fx.prototype = {
3250
3936
  this.options.show = true;
3251
3937
 
3252
3938
  // Begin the animation
3253
- this.custom(0, this.cur());
3254
-
3255
3939
  // Make sure that we start at a small width/height to avoid any
3256
3940
  // flash of content
3257
- if ( this.prop == "width" || this.prop == "height" )
3258
- this.elem.style[this.prop] = "1px";
3941
+ this.custom(this.prop == "width" || this.prop == "height" ? 1 : 0, this.cur());
3259
3942
 
3260
3943
  // Start by showing the element
3261
3944
  jQuery(this.elem).show();
@@ -3275,7 +3958,7 @@ jQuery.fx.prototype = {
3275
3958
  step: function(gotoEnd){
3276
3959
  var t = now();
3277
3960
 
3278
- if ( gotoEnd || t > this.options.duration + this.startTime ) {
3961
+ if ( gotoEnd || t >= this.options.duration + this.startTime ) {
3279
3962
  this.now = this.end;
3280
3963
  this.pos = this.state = 1;
3281
3964
  this.update();
@@ -3300,7 +3983,7 @@ jQuery.fx.prototype = {
3300
3983
 
3301
3984
  // Hide the element if the "hide" operation was done
3302
3985
  if ( this.options.hide )
3303
- this.elem.style.display = "none";
3986
+ jQuery(this.elem).hide();
3304
3987
 
3305
3988
  // Reset the properties, if the item has been hidden or shown
3306
3989
  if ( this.options.hide || this.options.show )
@@ -3335,124 +4018,106 @@ jQuery.extend( jQuery.fx, {
3335
4018
  slow: 600,
3336
4019
  fast: 200,
3337
4020
  // Default speed
3338
- def: 400
4021
+ _default: 400
3339
4022
  },
3340
4023
  step: {
3341
- scrollLeft: function(fx){
3342
- fx.elem.scrollLeft = fx.now;
3343
- },
3344
-
3345
- scrollTop: function(fx){
3346
- fx.elem.scrollTop = fx.now;
3347
- },
3348
4024
 
3349
4025
  opacity: function(fx){
3350
4026
  jQuery.attr(fx.elem.style, "opacity", fx.now);
3351
4027
  },
3352
4028
 
3353
4029
  _default: function(fx){
3354
- fx.elem.style[ fx.prop ] = fx.now + fx.unit;
4030
+ if ( fx.elem.style && fx.elem.style[ fx.prop ] != null )
4031
+ fx.elem.style[ fx.prop ] = fx.now + fx.unit;
4032
+ else
4033
+ fx.elem[ fx.prop ] = fx.now;
3355
4034
  }
3356
4035
  }
3357
4036
  });
3358
- // The Offset Method
3359
- // Originally By Brandon Aaron, part of the Dimension Plugin
3360
- // http://jquery.com/plugins/project/dimensions
3361
- jQuery.fn.offset = function() {
3362
- var left = 0, top = 0, elem = this[0], results;
3363
-
3364
- if ( elem ) with ( jQuery.browser ) {
3365
- var parent = elem.parentNode,
3366
- offsetChild = elem,
3367
- offsetParent = elem.offsetParent,
3368
- doc = elem.ownerDocument,
3369
- safari2 = safari && parseInt(version) < 522 && !/adobeair/i.test(userAgent),
3370
- css = jQuery.curCSS,
3371
- fixed = css(elem, "position") == "fixed";
3372
-
3373
- // Use getBoundingClientRect if available
3374
- if ( elem.getBoundingClientRect ) {
3375
- var box = elem.getBoundingClientRect();
3376
-
3377
- // Add the document scroll offsets
3378
- add(box.left + Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft),
3379
- box.top + Math.max(doc.documentElement.scrollTop, doc.body.scrollTop));
3380
-
3381
- // IE adds the HTML element's border, by default it is medium which is 2px
3382
- // IE 6 and 7 quirks mode the border width is overwritable by the following css html { border: 0; }
3383
- // IE 7 standards mode, the border is always 2px
3384
- // This border/offset is typically represented by the clientLeft and clientTop properties
3385
- // However, in IE6 and 7 quirks mode the clientLeft and clientTop properties are not updated when overwriting it via CSS
3386
- // Therefore this method will be off by 2px in IE while in quirksmode
3387
- add( -doc.documentElement.clientLeft, -doc.documentElement.clientTop );
3388
-
3389
- // Otherwise loop through the offsetParents and parentNodes
3390
- } else {
3391
-
3392
- // Initial element offsets
3393
- add( elem.offsetLeft, elem.offsetTop );
3394
-
3395
- // Get parent offsets
3396
- while ( offsetParent ) {
3397
- // Add offsetParent offsets
3398
- add( offsetParent.offsetLeft, offsetParent.offsetTop );
4037
+ if ( document.documentElement["getBoundingClientRect"] )
4038
+ jQuery.fn.offset = function() {
4039
+ if ( !this[0] ) return { top: 0, left: 0 };
4040
+ if ( this[0] === this[0].ownerDocument.body ) return jQuery.offset.bodyOffset( this[0] );
4041
+ var box = this[0].getBoundingClientRect(), doc = this[0].ownerDocument, body = doc.body, docElem = doc.documentElement,
4042
+ clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0,
4043
+ top = box.top + (self.pageYOffset || jQuery.boxModel && docElem.scrollTop || body.scrollTop ) - clientTop,
4044
+ left = box.left + (self.pageXOffset || jQuery.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft;
4045
+ return { top: top, left: left };
4046
+ };
4047
+ else
4048
+ jQuery.fn.offset = function() {
4049
+ if ( !this[0] ) return { top: 0, left: 0 };
4050
+ if ( this[0] === this[0].ownerDocument.body ) return jQuery.offset.bodyOffset( this[0] );
4051
+ jQuery.offset.initialized || jQuery.offset.initialize();
4052
+
4053
+ var elem = this[0], offsetParent = elem.offsetParent, prevOffsetParent = elem,
4054
+ doc = elem.ownerDocument, computedStyle, docElem = doc.documentElement,
4055
+ body = doc.body, defaultView = doc.defaultView,
4056
+ prevComputedStyle = defaultView.getComputedStyle(elem, null),
4057
+ top = elem.offsetTop, left = elem.offsetLeft;
4058
+
4059
+ while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {
4060
+ computedStyle = defaultView.getComputedStyle(elem, null);
4061
+ top -= elem.scrollTop, left -= elem.scrollLeft;
4062
+ if ( elem === offsetParent ) {
4063
+ top += elem.offsetTop, left += elem.offsetLeft;
4064
+ if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && /^t(able|d|h)$/i.test(elem.tagName)) )
4065
+ top += parseInt( computedStyle.borderTopWidth, 10) || 0,
4066
+ left += parseInt( computedStyle.borderLeftWidth, 10) || 0;
4067
+ prevOffsetParent = offsetParent, offsetParent = elem.offsetParent;
4068
+ }
4069
+ if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" )
4070
+ top += parseInt( computedStyle.borderTopWidth, 10) || 0,
4071
+ left += parseInt( computedStyle.borderLeftWidth, 10) || 0;
4072
+ prevComputedStyle = computedStyle;
4073
+ }
3399
4074
 
3400
- // Mozilla and Safari > 2 does not include the border on offset parents
3401
- // However Mozilla adds the border for table or table cells
3402
- if ( mozilla && !/^t(able|d|h)$/i.test(offsetParent.tagName) || safari && !safari2 )
3403
- border( offsetParent );
4075
+ if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" )
4076
+ top += body.offsetTop,
4077
+ left += body.offsetLeft;
3404
4078
 
3405
- // Add the document scroll offsets if position is fixed on any offsetParent
3406
- if ( !fixed && css(offsetParent, "position") == "fixed" )
3407
- fixed = true;
4079
+ if ( prevComputedStyle.position === "fixed" )
4080
+ top += Math.max(docElem.scrollTop, body.scrollTop),
4081
+ left += Math.max(docElem.scrollLeft, body.scrollLeft);
3408
4082
 
3409
- // Set offsetChild to previous offsetParent unless it is the body element
3410
- offsetChild = /^body$/i.test(offsetParent.tagName) ? offsetChild : offsetParent;
3411
- // Get next offsetParent
3412
- offsetParent = offsetParent.offsetParent;
3413
- }
4083
+ return { top: top, left: left };
4084
+ };
3414
4085
 
3415
- // Get parent scroll offsets
3416
- while ( parent && parent.tagName && !/^body|html$/i.test(parent.tagName) ) {
3417
- // Remove parent scroll UNLESS that parent is inline or a table to work around Opera inline/table scrollLeft/Top bug
3418
- if ( !/^inline|table.*$/i.test(css(parent, "display")) )
3419
- // Subtract parent scroll offsets
3420
- add( -parent.scrollLeft, -parent.scrollTop );
4086
+ jQuery.offset = {
4087
+ initialize: function() {
4088
+ if ( this.initialized ) return;
4089
+ var body = document.body, container = document.createElement('div'), innerDiv, checkDiv, table, td, rules, prop, bodyMarginTop = body.style.marginTop,
4090
+ 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>';
3421
4091
 
3422
- // Mozilla does not add the border for a parent that has overflow != visible
3423
- if ( mozilla && css(parent, "overflow") != "visible" )
3424
- border( parent );
4092
+ rules = { position: 'absolute', top: 0, left: 0, margin: 0, border: 0, width: '1px', height: '1px', visibility: 'hidden' };
4093
+ for ( prop in rules ) container.style[prop] = rules[prop];
3425
4094
 
3426
- // Get next parent
3427
- parent = parent.parentNode;
3428
- }
4095
+ container.innerHTML = html;
4096
+ body.insertBefore(container, body.firstChild);
4097
+ innerDiv = container.firstChild, checkDiv = innerDiv.firstChild, td = innerDiv.nextSibling.firstChild.firstChild;
3429
4098
 
3430
- // Safari <= 2 doubles body offsets with a fixed position element/offsetParent or absolutely positioned offsetChild
3431
- // Mozilla doubles body offsets with a non-absolutely positioned offsetChild
3432
- if ( (safari2 && (fixed || css(offsetChild, "position") == "absolute")) ||
3433
- (mozilla && css(offsetChild, "position") != "absolute") )
3434
- add( -doc.body.offsetLeft, -doc.body.offsetTop );
4099
+ this.doesNotAddBorder = (checkDiv.offsetTop !== 5);
4100
+ this.doesAddBorderForTableAndCells = (td.offsetTop === 5);
3435
4101
 
3436
- // Add the document scroll offsets if position is fixed
3437
- if ( fixed )
3438
- add(Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft),
3439
- Math.max(doc.documentElement.scrollTop, doc.body.scrollTop));
3440
- }
4102
+ innerDiv.style.overflow = 'hidden', innerDiv.style.position = 'relative';
4103
+ this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5);
3441
4104
 
3442
- // Return an object with top and left properties
3443
- results = { top: top, left: left };
3444
- }
4105
+ body.style.marginTop = '1px';
4106
+ this.doesNotIncludeMarginInBodyOffset = (body.offsetTop === 0);
4107
+ body.style.marginTop = bodyMarginTop;
3445
4108
 
3446
- function border(elem) {
3447
- add( jQuery.curCSS(elem, "borderLeftWidth", true), jQuery.curCSS(elem, "borderTopWidth", true) );
3448
- }
4109
+ body.removeChild(container);
4110
+ this.initialized = true;
4111
+ },
3449
4112
 
3450
- function add(l, t) {
3451
- left += parseInt(l, 10) || 0;
3452
- top += parseInt(t, 10) || 0;
4113
+ bodyOffset: function(body) {
4114
+ jQuery.offset.initialized || jQuery.offset.initialize();
4115
+ var top = body.offsetTop, left = body.offsetLeft;
4116
+ if ( jQuery.offset.doesNotIncludeMarginInBodyOffset )
4117
+ top += parseInt( jQuery.curCSS(body, 'marginTop', true), 10 ) || 0,
4118
+ left += parseInt( jQuery.curCSS(body, 'marginLeft', true), 10 ) || 0;
4119
+ return { top: top, left: left };
3453
4120
  }
3454
-
3455
- return results;
3456
4121
  };
3457
4122
 
3458
4123
 
@@ -3471,11 +4136,11 @@ jQuery.fn.extend({
3471
4136
  // Subtract element margins
3472
4137
  // note: when an element has margin: auto the offsetLeft and marginLeft
3473
4138
  // are the same in Safari causing offset.left to incorrectly be 0
3474
- offset.top -= num( this, 'marginTop' );
4139
+ offset.top -= num( this, 'marginTop' );
3475
4140
  offset.left -= num( this, 'marginLeft' );
3476
4141
 
3477
4142
  // Add offsetParent borders
3478
- parentOffset.top += num( offsetParent, 'borderTopWidth' );
4143
+ parentOffset.top += num( offsetParent, 'borderTopWidth' );
3479
4144
  parentOffset.left += num( offsetParent, 'borderLeftWidth' );
3480
4145
 
3481
4146
  // Subtract the two offsets
@@ -3489,7 +4154,7 @@ jQuery.fn.extend({
3489
4154
  },
3490
4155
 
3491
4156
  offsetParent: function() {
3492
- var offsetParent = this[0].offsetParent;
4157
+ var offsetParent = this[0].offsetParent || document.body;
3493
4158
  while ( offsetParent && (!/^body|html$/i.test(offsetParent.tagName) && jQuery.css(offsetParent, 'position') == 'static') )
3494
4159
  offsetParent = offsetParent.offsetParent;
3495
4160
  return jQuery(offsetParent);
@@ -3502,9 +4167,9 @@ jQuery.each( ['Left', 'Top'], function(i, name) {
3502
4167
  var method = 'scroll' + name;
3503
4168
 
3504
4169
  jQuery.fn[ method ] = function(val) {
3505
- if (!this[0]) return;
4170
+ if (!this[0]) return null;
3506
4171
 
3507
- return val != undefined ?
4172
+ return val !== undefined ?
3508
4173
 
3509
4174
  // Set the scroll offset
3510
4175
  this.each(function() {
@@ -3545,5 +4210,32 @@ jQuery.each([ "Height", "Width" ], function(i, name){
3545
4210
  (margin ?
3546
4211
  num(this, "margin" + tl) + num(this, "margin" + br) : 0);
3547
4212
  };
4213
+
4214
+ var type = name.toLowerCase();
4215
+
4216
+ jQuery.fn[ type ] = function( size ) {
4217
+ // Get window width or height
4218
+ return this[0] == window ?
4219
+ // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
4220
+ document.compatMode == "CSS1Compat" && document.documentElement[ "client" + name ] ||
4221
+ document.body[ "client" + name ] :
4222
+
4223
+ // Get document width or height
4224
+ this[0] == document ?
4225
+ // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
4226
+ Math.max(
4227
+ document.documentElement["client" + name],
4228
+ document.body["scroll" + name], document.documentElement["scroll" + name],
4229
+ document.body["offset" + name], document.documentElement["offset" + name]
4230
+ ) :
4231
+
4232
+ // Get or set width or height on the element
4233
+ size === undefined ?
4234
+ // Get width or height on the element
4235
+ (this.length ? jQuery.css( this[0], type ) : null) :
4236
+
4237
+ // Set the width or height on the element (default to pixels if value is unitless)
4238
+ this.css( type, typeof size === "string" ? size : size + "px" );
4239
+ };
3548
4240
 
3549
4241
  });})();