jquery-source 1.4.1 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module Jquery
2
2
  module Source
3
- VERSION = "1.4.1"
3
+ VERSION = "1.4.2"
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * jQuery JavaScript Library v1.4.1
2
+ * jQuery JavaScript Library v1.4.2
3
3
  * http://jquery.com/
4
4
  *
5
5
  * Copyright 2010, John Resig
@@ -11,7 +11,7 @@
11
11
  * Copyright 2010, The Dojo Foundation
12
12
  * Released under the MIT, BSD, and GPL Licenses.
13
13
  *
14
- * Date: Mon Jan 25 19:43:33 2010 -0500
14
+ * Date: Sat Feb 13 22:33:48 2010 -0500
15
15
  */
16
16
  (function( window, undefined ) {
17
17
 
@@ -86,6 +86,15 @@ jQuery.fn = jQuery.prototype = {
86
86
  this.length = 1;
87
87
  return this;
88
88
  }
89
+
90
+ // The body element only exists once, optimize finding it
91
+ if ( selector === "body" && !context ) {
92
+ this.context = document;
93
+ this[0] = document.body;
94
+ this.selector = "body";
95
+ this.length = 1;
96
+ return this;
97
+ }
89
98
 
90
99
  // Handle HTML strings
91
100
  if ( typeof selector === "string" ) {
@@ -116,7 +125,9 @@ jQuery.fn = jQuery.prototype = {
116
125
  ret = buildFragment( [ match[1] ], [ doc ] );
117
126
  selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes;
118
127
  }
119
-
128
+
129
+ return jQuery.merge( this, selector );
130
+
120
131
  // HANDLE: $("#id")
121
132
  } else {
122
133
  elem = document.getElementById( match[2] );
@@ -143,6 +154,7 @@ jQuery.fn = jQuery.prototype = {
143
154
  this.selector = selector;
144
155
  this.context = document;
145
156
  selector = document.getElementsByTagName( selector );
157
+ return jQuery.merge( this, selector );
146
158
 
147
159
  // HANDLE: $(expr, $(...))
148
160
  } else if ( !context || context.jquery ) {
@@ -165,16 +177,14 @@ jQuery.fn = jQuery.prototype = {
165
177
  this.context = selector.context;
166
178
  }
167
179
 
168
- return jQuery.isArray( selector ) ?
169
- this.setArray( selector ) :
170
- jQuery.makeArray( selector, this );
180
+ return jQuery.makeArray( selector, this );
171
181
  },
172
182
 
173
183
  // Start with an empty selector
174
184
  selector: "",
175
185
 
176
186
  // The current version of jQuery being used
177
- jquery: "1.4.1",
187
+ jquery: "1.4.2",
178
188
 
179
189
  // The default length of a jQuery object is 0
180
190
  length: 0,
@@ -204,7 +214,14 @@ jQuery.fn = jQuery.prototype = {
204
214
  // (returning the new matched element set)
205
215
  pushStack: function( elems, name, selector ) {
206
216
  // Build a new jQuery matched element set
207
- var ret = jQuery( elems || null );
217
+ var ret = jQuery();
218
+
219
+ if ( jQuery.isArray( elems ) ) {
220
+ push.apply( ret, elems );
221
+
222
+ } else {
223
+ jQuery.merge( ret, elems );
224
+ }
208
225
 
209
226
  // Add the old object onto the stack (as a reference)
210
227
  ret.prevObject = this;
@@ -221,18 +238,6 @@ jQuery.fn = jQuery.prototype = {
221
238
  return ret;
222
239
  },
223
240
 
224
- // Force the current matched set of elements to become
225
- // the specified array of elements (destroying the stack in the process)
226
- // You should use pushStack() in order to do this, but maintain the stack
227
- setArray: function( elems ) {
228
- // Resetting the length to 0, then using the native Array push
229
- // is a super-fast way to populate an object with array-like properties
230
- this.length = 0;
231
- push.apply( this, elems );
232
-
233
- return this;
234
- },
235
-
236
241
  // Execute a callback for every element in the matched set.
237
242
  // (You can seed the arguments with an array of args, but this is
238
243
  // only used internally.)
@@ -492,6 +497,9 @@ jQuery.extend({
492
497
  if ( typeof data !== "string" || !data ) {
493
498
  return null;
494
499
  }
500
+
501
+ // Make sure leading/trailing whitespace is removed (IE can't handle it)
502
+ data = jQuery.trim( data );
495
503
 
496
504
  // Make sure the incoming data is actual JSON
497
505
  // Logic borrowed from http://json.org/json2.js
@@ -619,6 +627,7 @@ jQuery.extend({
619
627
  for ( var l = second.length; j < l; j++ ) {
620
628
  first[ i++ ] = second[ j ];
621
629
  }
630
+
622
631
  } else {
623
632
  while ( second[j] !== undefined ) {
624
633
  first[ i++ ] = second[ j++ ];
@@ -807,7 +816,7 @@ function access( elems, key, value, exec, fn, pass ) {
807
816
  }
808
817
 
809
818
  // Getting an attribute
810
- return length ? fn( elems[0], key ) : null;
819
+ return length ? fn( elems[0], key ) : undefined;
811
820
  }
812
821
 
813
822
  function now() {
@@ -871,7 +880,10 @@ function now() {
871
880
  // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
872
881
  optSelected: document.createElement("select").appendChild( document.createElement("option") ).selected,
873
882
 
883
+ parentNode: div.removeChild( div.appendChild( document.createElement("div") ) ).parentNode === null,
884
+
874
885
  // Will be defined later
886
+ deleteExpando: true,
875
887
  checkClone: false,
876
888
  scriptEval: false,
877
889
  noCloneEvent: true,
@@ -893,6 +905,15 @@ function now() {
893
905
  delete window[ id ];
894
906
  }
895
907
 
908
+ // Test to see if it's possible to delete an expando from an element
909
+ // Fails in Internet Explorer
910
+ try {
911
+ delete script.test;
912
+
913
+ } catch(e) {
914
+ jQuery.support.deleteExpando = false;
915
+ }
916
+
896
917
  root.removeChild( script );
897
918
 
898
919
  if ( div.attachEvent && div.fireEvent ) {
@@ -923,6 +944,7 @@ function now() {
923
944
  document.body.appendChild( div );
924
945
  jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2;
925
946
  document.body.removeChild( div ).style.display = 'none';
947
+
926
948
  div = null;
927
949
  });
928
950
 
@@ -962,7 +984,6 @@ jQuery.props = {
962
984
  frameborder: "frameBorder"
963
985
  };
964
986
  var expando = "jQuery" + now(), uuid = 0, windowData = {};
965
- var emptyObject = {};
966
987
 
967
988
  jQuery.extend({
968
989
  cache: {},
@@ -988,8 +1009,7 @@ jQuery.extend({
988
1009
 
989
1010
  var id = elem[ expando ], cache = jQuery.cache, thisCache;
990
1011
 
991
- // Handle the case where there's no name immediately
992
- if ( !name && !id ) {
1012
+ if ( !id && typeof name === "string" && data === undefined ) {
993
1013
  return null;
994
1014
  }
995
1015
 
@@ -1003,17 +1023,16 @@ jQuery.extend({
1003
1023
  if ( typeof name === "object" ) {
1004
1024
  elem[ expando ] = id;
1005
1025
  thisCache = cache[ id ] = jQuery.extend(true, {}, name);
1006
- } else if ( cache[ id ] ) {
1007
- thisCache = cache[ id ];
1008
- } else if ( typeof data === "undefined" ) {
1009
- thisCache = emptyObject;
1010
- } else {
1011
- thisCache = cache[ id ] = {};
1026
+
1027
+ } else if ( !cache[ id ] ) {
1028
+ elem[ expando ] = id;
1029
+ cache[ id ] = {};
1012
1030
  }
1013
1031
 
1032
+ thisCache = cache[ id ];
1033
+
1014
1034
  // Prevent overriding the named cache with undefined values
1015
1035
  if ( data !== undefined ) {
1016
- elem[ expando ] = id;
1017
1036
  thisCache[ name ] = data;
1018
1037
  }
1019
1038
 
@@ -1045,15 +1064,11 @@ jQuery.extend({
1045
1064
 
1046
1065
  // Otherwise, we want to remove all of the element's data
1047
1066
  } else {
1048
- // Clean up the element expando
1049
- try {
1050
- delete elem[ expando ];
1051
- } catch( e ) {
1052
- // IE has trouble directly removing the expando
1053
- // but it's ok with using removeAttribute
1054
- if ( elem.removeAttribute ) {
1055
- elem.removeAttribute( expando );
1056
- }
1067
+ if ( jQuery.support.deleteExpando ) {
1068
+ delete elem[ jQuery.expando ];
1069
+
1070
+ } else if ( elem.removeAttribute ) {
1071
+ elem.removeAttribute( jQuery.expando );
1057
1072
  }
1058
1073
 
1059
1074
  // Completely remove the data cache
@@ -1230,12 +1245,13 @@ jQuery.fn.extend({
1230
1245
  elem.className = value;
1231
1246
 
1232
1247
  } else {
1233
- var className = " " + elem.className + " ";
1248
+ var className = " " + elem.className + " ", setClass = elem.className;
1234
1249
  for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
1235
1250
  if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) {
1236
- elem.className += " " + classNames[c];
1251
+ setClass += " " + classNames[c];
1237
1252
  }
1238
1253
  }
1254
+ elem.className = jQuery.trim( setClass );
1239
1255
  }
1240
1256
  }
1241
1257
  }
@@ -1264,7 +1280,7 @@ jQuery.fn.extend({
1264
1280
  for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
1265
1281
  className = className.replace(" " + classNames[c] + " ", " ");
1266
1282
  }
1267
- elem.className = className.substring(1, className.length - 1);
1283
+ elem.className = jQuery.trim( className );
1268
1284
 
1269
1285
  } else {
1270
1286
  elem.className = "";
@@ -1520,15 +1536,16 @@ jQuery.extend({
1520
1536
  }
1521
1537
 
1522
1538
  // elem is actually elem.style ... set the style
1523
- // Using attr for specific style information is now deprecated. Use style insead.
1539
+ // Using attr for specific style information is now deprecated. Use style instead.
1524
1540
  return jQuery.style( elem, name, value );
1525
1541
  }
1526
1542
  });
1527
- var fcleanup = function( nm ) {
1528
- return nm.replace(/[^\w\s\.\|`]/g, function( ch ) {
1529
- return "\\" + ch;
1530
- });
1531
- };
1543
+ var rnamespaces = /\.(.*)$/,
1544
+ fcleanup = function( nm ) {
1545
+ return nm.replace(/[^\w\s\.\|`]/g, function( ch ) {
1546
+ return "\\" + ch;
1547
+ });
1548
+ };
1532
1549
 
1533
1550
  /*
1534
1551
  * A number of helper functions used for managing events.
@@ -1550,107 +1567,104 @@ jQuery.event = {
1550
1567
  elem = window;
1551
1568
  }
1552
1569
 
1570
+ var handleObjIn, handleObj;
1571
+
1572
+ if ( handler.handler ) {
1573
+ handleObjIn = handler;
1574
+ handler = handleObjIn.handler;
1575
+ }
1576
+
1553
1577
  // Make sure that the function being executed has a unique ID
1554
1578
  if ( !handler.guid ) {
1555
1579
  handler.guid = jQuery.guid++;
1556
1580
  }
1557
1581
 
1558
- // if data is passed, bind to handler
1559
- if ( data !== undefined ) {
1560
- // Create temporary function pointer to original handler
1561
- var fn = handler;
1562
-
1563
- // Create unique handler function, wrapped around original handler
1564
- handler = jQuery.proxy( fn );
1582
+ // Init the element's event structure
1583
+ var elemData = jQuery.data( elem );
1565
1584
 
1566
- // Store data in unique handler
1567
- handler.data = data;
1585
+ // If no elemData is found then we must be trying to bind to one of the
1586
+ // banned noData elements
1587
+ if ( !elemData ) {
1588
+ return;
1568
1589
  }
1569
1590
 
1570
- // Init the element's event structure
1571
- var events = jQuery.data( elem, "events" ) || jQuery.data( elem, "events", {} ),
1572
- handle = jQuery.data( elem, "handle" ), eventHandle;
1591
+ var events = elemData.events = elemData.events || {},
1592
+ eventHandle = elemData.handle, eventHandle;
1573
1593
 
1574
- if ( !handle ) {
1575
- eventHandle = function() {
1594
+ if ( !eventHandle ) {
1595
+ elemData.handle = eventHandle = function() {
1576
1596
  // Handle the second event of a trigger and when
1577
1597
  // an event is called after a page has unloaded
1578
1598
  return typeof jQuery !== "undefined" && !jQuery.event.triggered ?
1579
1599
  jQuery.event.handle.apply( eventHandle.elem, arguments ) :
1580
1600
  undefined;
1581
1601
  };
1582
-
1583
- handle = jQuery.data( elem, "handle", eventHandle );
1584
- }
1585
-
1586
- // If no handle is found then we must be trying to bind to one of the
1587
- // banned noData elements
1588
- if ( !handle ) {
1589
- return;
1590
1602
  }
1591
1603
 
1592
1604
  // Add elem as a property of the handle function
1593
- // This is to prevent a memory leak with non-native
1594
- // event in IE.
1595
- handle.elem = elem;
1605
+ // This is to prevent a memory leak with non-native events in IE.
1606
+ eventHandle.elem = elem;
1596
1607
 
1597
1608
  // Handle multiple events separated by a space
1598
1609
  // jQuery(...).bind("mouseover mouseout", fn);
1599
- types = types.split( /\s+/ );
1610
+ types = types.split(" ");
1600
1611
 
1601
- var type, i = 0;
1612
+ var type, i = 0, namespaces;
1602
1613
 
1603
1614
  while ( (type = types[ i++ ]) ) {
1604
- // Namespaced event handlers
1605
- var namespaces = type.split(".");
1606
- type = namespaces.shift();
1615
+ handleObj = handleObjIn ?
1616
+ jQuery.extend({}, handleObjIn) :
1617
+ { handler: handler, data: data };
1607
1618
 
1608
- if ( i > 1 ) {
1609
- handler = jQuery.proxy( handler );
1619
+ // Namespaced event handlers
1620
+ if ( type.indexOf(".") > -1 ) {
1621
+ namespaces = type.split(".");
1622
+ type = namespaces.shift();
1623
+ handleObj.namespace = namespaces.slice(0).sort().join(".");
1610
1624
 
1611
- if ( data !== undefined ) {
1612
- handler.data = data;
1613
- }
1625
+ } else {
1626
+ namespaces = [];
1627
+ handleObj.namespace = "";
1614
1628
  }
1615
1629
 
1616
- handler.type = namespaces.slice(0).sort().join(".");
1630
+ handleObj.type = type;
1631
+ handleObj.guid = handler.guid;
1617
1632
 
1618
1633
  // Get the current list of functions bound to this event
1619
1634
  var handlers = events[ type ],
1620
- special = this.special[ type ] || {};
1635
+ special = jQuery.event.special[ type ] || {};
1621
1636
 
1622
1637
  // Init the event handler queue
1623
1638
  if ( !handlers ) {
1624
- handlers = events[ type ] = {};
1639
+ handlers = events[ type ] = [];
1625
1640
 
1626
1641
  // Check for a special event handler
1627
1642
  // Only use addEventListener/attachEvent if the special
1628
1643
  // events handler returns false
1629
- if ( !special.setup || special.setup.call( elem, data, namespaces, handler) === false ) {
1644
+ if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
1630
1645
  // Bind the global event handler to the element
1631
1646
  if ( elem.addEventListener ) {
1632
- elem.addEventListener( type, handle, false );
1647
+ elem.addEventListener( type, eventHandle, false );
1648
+
1633
1649
  } else if ( elem.attachEvent ) {
1634
- elem.attachEvent( "on" + type, handle );
1650
+ elem.attachEvent( "on" + type, eventHandle );
1635
1651
  }
1636
1652
  }
1637
1653
  }
1638
1654
 
1639
1655
  if ( special.add ) {
1640
- var modifiedHandler = special.add.call( elem, handler, data, namespaces, handlers );
1641
- if ( modifiedHandler && jQuery.isFunction( modifiedHandler ) ) {
1642
- modifiedHandler.guid = modifiedHandler.guid || handler.guid;
1643
- modifiedHandler.data = modifiedHandler.data || handler.data;
1644
- modifiedHandler.type = modifiedHandler.type || handler.type;
1645
- handler = modifiedHandler;
1646
- }
1647
- }
1648
-
1656
+ special.add.call( elem, handleObj );
1657
+
1658
+ if ( !handleObj.handler.guid ) {
1659
+ handleObj.handler.guid = handler.guid;
1660
+ }
1661
+ }
1662
+
1649
1663
  // Add the function to the element's handler list
1650
- handlers[ handler.guid ] = handler;
1664
+ handlers.push( handleObj );
1651
1665
 
1652
1666
  // Keep track of which events have been used, for global triggering
1653
- this.global[ type ] = true;
1667
+ jQuery.event.global[ type ] = true;
1654
1668
  }
1655
1669
 
1656
1670
  // Nullify elem to prevent memory leaks in IE
@@ -1660,90 +1674,121 @@ jQuery.event = {
1660
1674
  global: {},
1661
1675
 
1662
1676
  // Detach an event or set of events from an element
1663
- remove: function( elem, types, handler ) {
1677
+ remove: function( elem, types, handler, pos ) {
1664
1678
  // don't do events on text and comment nodes
1665
1679
  if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
1666
1680
  return;
1667
1681
  }
1668
1682
 
1669
- var events = jQuery.data( elem, "events" ), ret, type, fn;
1683
+ var ret, type, fn, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType,
1684
+ elemData = jQuery.data( elem ),
1685
+ events = elemData && elemData.events;
1670
1686
 
1671
- if ( events ) {
1672
- // Unbind all events for the element
1673
- if ( types === undefined || (typeof types === "string" && types.charAt(0) === ".") ) {
1674
- for ( type in events ) {
1675
- this.remove( elem, type + (types || "") );
1676
- }
1677
- } else {
1678
- // types is actually an event object here
1679
- if ( types.type ) {
1680
- handler = types.handler;
1681
- types = types.type;
1687
+ if ( !elemData || !events ) {
1688
+ return;
1689
+ }
1690
+
1691
+ // types is actually an event object here
1692
+ if ( types && types.type ) {
1693
+ handler = types.handler;
1694
+ types = types.type;
1695
+ }
1696
+
1697
+ // Unbind all events for the element
1698
+ if ( !types || typeof types === "string" && types.charAt(0) === "." ) {
1699
+ types = types || "";
1700
+
1701
+ for ( type in events ) {
1702
+ jQuery.event.remove( elem, type + types );
1703
+ }
1704
+
1705
+ return;
1706
+ }
1707
+
1708
+ // Handle multiple events separated by a space
1709
+ // jQuery(...).unbind("mouseover mouseout", fn);
1710
+ types = types.split(" ");
1711
+
1712
+ while ( (type = types[ i++ ]) ) {
1713
+ origType = type;
1714
+ handleObj = null;
1715
+ all = type.indexOf(".") < 0;
1716
+ namespaces = [];
1717
+
1718
+ if ( !all ) {
1719
+ // Namespaced event handlers
1720
+ namespaces = type.split(".");
1721
+ type = namespaces.shift();
1722
+
1723
+ namespace = new RegExp("(^|\\.)" +
1724
+ jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)")
1725
+ }
1726
+
1727
+ eventType = events[ type ];
1728
+
1729
+ if ( !eventType ) {
1730
+ continue;
1731
+ }
1732
+
1733
+ if ( !handler ) {
1734
+ for ( var j = 0; j < eventType.length; j++ ) {
1735
+ handleObj = eventType[ j ];
1736
+
1737
+ if ( all || namespace.test( handleObj.namespace ) ) {
1738
+ jQuery.event.remove( elem, origType, handleObj.handler, j );
1739
+ eventType.splice( j--, 1 );
1740
+ }
1682
1741
  }
1683
1742
 
1684
- // Handle multiple events separated by a space
1685
- // jQuery(...).unbind("mouseover mouseout", fn);
1686
- types = types.split(/\s+/);
1687
- var i = 0;
1688
- while ( (type = types[ i++ ]) ) {
1689
- // Namespaced event handlers
1690
- var namespaces = type.split(".");
1691
- type = namespaces.shift();
1692
- var all = !namespaces.length,
1693
- cleaned = jQuery.map( namespaces.slice(0).sort(), fcleanup ),
1694
- namespace = new RegExp("(^|\\.)" + cleaned.join("\\.(?:.*\\.)?") + "(\\.|$)"),
1695
- special = this.special[ type ] || {};
1696
-
1697
- if ( events[ type ] ) {
1698
- // remove the given handler for the given type
1699
- if ( handler ) {
1700
- fn = events[ type ][ handler.guid ];
1701
- delete events[ type ][ handler.guid ];
1702
-
1703
- // remove all handlers for the given type
1704
- } else {
1705
- for ( var handle in events[ type ] ) {
1706
- // Handle the removal of namespaced events
1707
- if ( all || namespace.test( events[ type ][ handle ].type ) ) {
1708
- delete events[ type ][ handle ];
1709
- }
1710
- }
1743
+ continue;
1744
+ }
1745
+
1746
+ special = jQuery.event.special[ type ] || {};
1747
+
1748
+ for ( var j = pos || 0; j < eventType.length; j++ ) {
1749
+ handleObj = eventType[ j ];
1750
+
1751
+ if ( handler.guid === handleObj.guid ) {
1752
+ // remove the given handler for the given type
1753
+ if ( all || namespace.test( handleObj.namespace ) ) {
1754
+ if ( pos == null ) {
1755
+ eventType.splice( j--, 1 );
1711
1756
  }
1712
1757
 
1713
1758
  if ( special.remove ) {
1714
- special.remove.call( elem, namespaces, fn);
1759
+ special.remove.call( elem, handleObj );
1715
1760
  }
1761
+ }
1716
1762
 
1717
- // remove generic event handler if no more handlers exist
1718
- for ( ret in events[ type ] ) {
1719
- break;
1720
- }
1721
- if ( !ret ) {
1722
- if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
1723
- if ( elem.removeEventListener ) {
1724
- elem.removeEventListener( type, jQuery.data( elem, "handle" ), false );
1725
- } else if ( elem.detachEvent ) {
1726
- elem.detachEvent( "on" + type, jQuery.data( elem, "handle" ) );
1727
- }
1728
- }
1729
- ret = null;
1730
- delete events[ type ];
1731
- }
1763
+ if ( pos != null ) {
1764
+ break;
1732
1765
  }
1733
1766
  }
1734
1767
  }
1735
1768
 
1736
- // Remove the expando if it's no longer used
1737
- for ( ret in events ) {
1738
- break;
1739
- }
1740
- if ( !ret ) {
1741
- var handle = jQuery.data( elem, "handle" );
1742
- if ( handle ) {
1743
- handle.elem = null;
1769
+ // remove generic event handler if no more handlers exist
1770
+ if ( eventType.length === 0 || pos != null && eventType.length === 1 ) {
1771
+ if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
1772
+ removeEvent( elem, type, elemData.handle );
1744
1773
  }
1745
- jQuery.removeData( elem, "events" );
1746
- jQuery.removeData( elem, "handle" );
1774
+
1775
+ ret = null;
1776
+ delete events[ type ];
1777
+ }
1778
+ }
1779
+
1780
+ // Remove the expando if it's no longer used
1781
+ if ( jQuery.isEmptyObject( events ) ) {
1782
+ var handle = elemData.handle;
1783
+ if ( handle ) {
1784
+ handle.elem = null;
1785
+ }
1786
+
1787
+ delete elemData.events;
1788
+ delete elemData.handle;
1789
+
1790
+ if ( jQuery.isEmptyObject( elemData ) ) {
1791
+ jQuery.removeData( elem );
1747
1792
  }
1748
1793
  }
1749
1794
  },
@@ -1774,7 +1819,7 @@ jQuery.event = {
1774
1819
  event.stopPropagation();
1775
1820
 
1776
1821
  // Only trigger if we've ever bound an event for it
1777
- if ( this.global[ type ] ) {
1822
+ if ( jQuery.event.global[ type ] ) {
1778
1823
  jQuery.each( jQuery.cache, function() {
1779
1824
  if ( this.events && this.events[type] ) {
1780
1825
  jQuery.event.trigger( event, data, this.handle.elem );
@@ -1825,9 +1870,12 @@ jQuery.event = {
1825
1870
 
1826
1871
  } else if ( !event.isDefaultPrevented() ) {
1827
1872
  var target = event.target, old,
1828
- isClick = jQuery.nodeName(target, "a") && type === "click";
1873
+ isClick = jQuery.nodeName(target, "a") && type === "click",
1874
+ special = jQuery.event.special[ type ] || {};
1875
+
1876
+ if ( (!special._default || special._default.call( elem, event ) === false) &&
1877
+ !isClick && !(target && target.nodeName && jQuery.noData[target.nodeName.toLowerCase()]) ) {
1829
1878
 
1830
- if ( !isClick && !(target && target.nodeName && jQuery.noData[target.nodeName.toLowerCase()]) ) {
1831
1879
  try {
1832
1880
  if ( target[ type ] ) {
1833
1881
  // Make sure that we don't accidentally re-trigger the onFOO events
@@ -1837,7 +1885,7 @@ jQuery.event = {
1837
1885
  target[ "on" + type ] = null;
1838
1886
  }
1839
1887
 
1840
- this.triggered = true;
1888
+ jQuery.event.triggered = true;
1841
1889
  target[ type ]();
1842
1890
  }
1843
1891
 
@@ -1848,53 +1896,57 @@ jQuery.event = {
1848
1896
  target[ "on" + type ] = old;
1849
1897
  }
1850
1898
 
1851
- this.triggered = false;
1899
+ jQuery.event.triggered = false;
1852
1900
  }
1853
1901
  }
1854
1902
  },
1855
1903
 
1856
1904
  handle: function( event ) {
1857
- // returned undefined or false
1858
- var all, handlers;
1905
+ var all, handlers, namespaces, namespace, events;
1859
1906
 
1860
1907
  event = arguments[0] = jQuery.event.fix( event || window.event );
1861
1908
  event.currentTarget = this;
1862
1909
 
1863
1910
  // Namespaced event handlers
1864
- var namespaces = event.type.split(".");
1865
- event.type = namespaces.shift();
1911
+ all = event.type.indexOf(".") < 0 && !event.exclusive;
1866
1912
 
1867
- // Cache this now, all = true means, any handler
1868
- all = !namespaces.length && !event.exclusive;
1869
-
1870
- var namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join("\\.(?:.*\\.)?") + "(\\.|$)");
1913
+ if ( !all ) {
1914
+ namespaces = event.type.split(".");
1915
+ event.type = namespaces.shift();
1916
+ namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join("\\.(?:.*\\.)?") + "(\\.|$)");
1917
+ }
1871
1918
 
1872
- handlers = ( jQuery.data(this, "events") || {} )[ event.type ];
1919
+ var events = jQuery.data(this, "events"), handlers = events[ event.type ];
1873
1920
 
1874
- for ( var j in handlers ) {
1875
- var handler = handlers[ j ];
1921
+ if ( events && handlers ) {
1922
+ // Clone the handlers to prevent manipulation
1923
+ handlers = handlers.slice(0);
1876
1924
 
1877
- // Filter the functions by class
1878
- if ( all || namespace.test(handler.type) ) {
1879
- // Pass in a reference to the handler function itself
1880
- // So that we can later remove it
1881
- event.handler = handler;
1882
- event.data = handler.data;
1925
+ for ( var j = 0, l = handlers.length; j < l; j++ ) {
1926
+ var handleObj = handlers[ j ];
1883
1927
 
1884
- var ret = handler.apply( this, arguments );
1928
+ // Filter the functions by class
1929
+ if ( all || namespace.test( handleObj.namespace ) ) {
1930
+ // Pass in a reference to the handler function itself
1931
+ // So that we can later remove it
1932
+ event.handler = handleObj.handler;
1933
+ event.data = handleObj.data;
1934
+ event.handleObj = handleObj;
1935
+
1936
+ var ret = handleObj.handler.apply( this, arguments );
1885
1937
 
1886
- if ( ret !== undefined ) {
1887
- event.result = ret;
1888
- if ( ret === false ) {
1889
- event.preventDefault();
1890
- event.stopPropagation();
1938
+ if ( ret !== undefined ) {
1939
+ event.result = ret;
1940
+ if ( ret === false ) {
1941
+ event.preventDefault();
1942
+ event.stopPropagation();
1943
+ }
1891
1944
  }
1892
- }
1893
1945
 
1894
- if ( event.isImmediatePropagationStopped() ) {
1895
- break;
1946
+ if ( event.isImmediatePropagationStopped() ) {
1947
+ break;
1948
+ }
1896
1949
  }
1897
-
1898
1950
  }
1899
1951
  }
1900
1952
 
@@ -1973,44 +2025,39 @@ jQuery.event = {
1973
2025
  },
1974
2026
 
1975
2027
  live: {
1976
- add: function( proxy, data, namespaces, live ) {
1977
- jQuery.extend( proxy, data || {} );
1978
-
1979
- proxy.guid += data.selector + data.live;
1980
- data.liveProxy = proxy;
1981
-
1982
- jQuery.event.add( this, data.live, liveHandler, data );
1983
-
2028
+ add: function( handleObj ) {
2029
+ jQuery.event.add( this, handleObj.origType, jQuery.extend({}, handleObj, {handler: liveHandler}) );
1984
2030
  },
1985
2031
 
1986
- remove: function( namespaces ) {
1987
- if ( namespaces.length ) {
1988
- var remove = 0, name = new RegExp("(^|\\.)" + namespaces[0] + "(\\.|$)");
1989
-
1990
- jQuery.each( (jQuery.data(this, "events").live || {}), function() {
1991
- if ( name.test(this.type) ) {
1992
- remove++;
1993
- }
1994
- });
1995
-
1996
- if ( remove < 1 ) {
1997
- jQuery.event.remove( this, namespaces[0], liveHandler );
2032
+ remove: function( handleObj ) {
2033
+ var remove = true,
2034
+ type = handleObj.origType.replace(rnamespaces, "");
2035
+
2036
+ jQuery.each( jQuery.data(this, "events").live || [], function() {
2037
+ if ( type === this.origType.replace(rnamespaces, "") ) {
2038
+ remove = false;
2039
+ return false;
1998
2040
  }
2041
+ });
2042
+
2043
+ if ( remove ) {
2044
+ jQuery.event.remove( this, handleObj.origType, liveHandler );
1999
2045
  }
2000
- },
2001
- special: {}
2046
+ }
2047
+
2002
2048
  },
2049
+
2003
2050
  beforeunload: {
2004
- setup: function( data, namespaces, fn ) {
2051
+ setup: function( data, namespaces, eventHandle ) {
2005
2052
  // We only want to do this special case on windows
2006
2053
  if ( this.setInterval ) {
2007
- this.onbeforeunload = fn;
2054
+ this.onbeforeunload = eventHandle;
2008
2055
  }
2009
2056
 
2010
2057
  return false;
2011
2058
  },
2012
- teardown: function( namespaces, fn ) {
2013
- if ( this.onbeforeunload === fn ) {
2059
+ teardown: function( namespaces, eventHandle ) {
2060
+ if ( this.onbeforeunload === eventHandle ) {
2014
2061
  this.onbeforeunload = null;
2015
2062
  }
2016
2063
  }
@@ -2018,6 +2065,14 @@ jQuery.event = {
2018
2065
  }
2019
2066
  };
2020
2067
 
2068
+ var removeEvent = document.removeEventListener ?
2069
+ function( elem, type, handle ) {
2070
+ elem.removeEventListener( type, handle, false );
2071
+ } :
2072
+ function( elem, type, handle ) {
2073
+ elem.detachEvent( "on" + type, handle );
2074
+ };
2075
+
2021
2076
  jQuery.Event = function( src ) {
2022
2077
  // Allow instantiation without the 'new' keyword
2023
2078
  if ( !this.preventDefault ) {
@@ -2095,27 +2150,24 @@ var withinElement = function( event ) {
2095
2150
  // Check if mouse(over|out) are still within the same parent element
2096
2151
  var parent = event.relatedTarget;
2097
2152
 
2098
- // Traverse up the tree
2099
- while ( parent && parent !== this ) {
2100
- // Firefox sometimes assigns relatedTarget a XUL element
2101
- // which we cannot access the parentNode property of
2102
- try {
2153
+ // Firefox sometimes assigns relatedTarget a XUL element
2154
+ // which we cannot access the parentNode property of
2155
+ try {
2156
+ // Traverse up the tree
2157
+ while ( parent && parent !== this ) {
2103
2158
  parent = parent.parentNode;
2104
-
2105
- // assuming we've left the element since we most likely mousedover a xul element
2106
- } catch(e) {
2107
- break;
2108
2159
  }
2109
- }
2110
2160
 
2111
- if ( parent !== this ) {
2112
- // set the correct event type
2113
- event.type = event.data;
2161
+ if ( parent !== this ) {
2162
+ // set the correct event type
2163
+ event.type = event.data;
2114
2164
 
2115
- // handle event if we actually just moused on to a non sub-element
2116
- jQuery.event.handle.apply( this, arguments );
2117
- }
2165
+ // handle event if we actually just moused on to a non sub-element
2166
+ jQuery.event.handle.apply( this, arguments );
2167
+ }
2118
2168
 
2169
+ // assuming we've left the element since we most likely mousedover a xul element
2170
+ } catch(e) { }
2119
2171
  },
2120
2172
 
2121
2173
  // In case of event delegation, we only need to rename the event.type,
@@ -2143,64 +2195,65 @@ jQuery.each({
2143
2195
  // submit delegation
2144
2196
  if ( !jQuery.support.submitBubbles ) {
2145
2197
 
2146
- jQuery.event.special.submit = {
2147
- setup: function( data, namespaces, fn ) {
2148
- if ( this.nodeName.toLowerCase() !== "form" ) {
2149
- jQuery.event.add(this, "click.specialSubmit." + fn.guid, function( e ) {
2150
- var elem = e.target, type = elem.type;
2198
+ jQuery.event.special.submit = {
2199
+ setup: function( data, namespaces ) {
2200
+ if ( this.nodeName.toLowerCase() !== "form" ) {
2201
+ jQuery.event.add(this, "click.specialSubmit", function( e ) {
2202
+ var elem = e.target, type = elem.type;
2151
2203
 
2152
- if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
2153
- return trigger( "submit", this, arguments );
2154
- }
2155
- });
2204
+ if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
2205
+ return trigger( "submit", this, arguments );
2206
+ }
2207
+ });
2156
2208
 
2157
- jQuery.event.add(this, "keypress.specialSubmit." + fn.guid, function( e ) {
2158
- var elem = e.target, type = elem.type;
2209
+ jQuery.event.add(this, "keypress.specialSubmit", function( e ) {
2210
+ var elem = e.target, type = elem.type;
2159
2211
 
2160
- if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
2161
- return trigger( "submit", this, arguments );
2162
- }
2163
- });
2212
+ if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
2213
+ return trigger( "submit", this, arguments );
2214
+ }
2215
+ });
2164
2216
 
2165
- } else {
2166
- return false;
2167
- }
2168
- },
2217
+ } else {
2218
+ return false;
2219
+ }
2220
+ },
2169
2221
 
2170
- remove: function( namespaces, fn ) {
2171
- jQuery.event.remove( this, "click.specialSubmit" + (fn ? "."+fn.guid : "") );
2172
- jQuery.event.remove( this, "keypress.specialSubmit" + (fn ? "."+fn.guid : "") );
2173
- }
2174
- };
2222
+ teardown: function( namespaces ) {
2223
+ jQuery.event.remove( this, ".specialSubmit" );
2224
+ }
2225
+ };
2175
2226
 
2176
2227
  }
2177
2228
 
2178
2229
  // change delegation, happens here so we have bind.
2179
2230
  if ( !jQuery.support.changeBubbles ) {
2180
2231
 
2181
- var formElems = /textarea|input|select/i;
2232
+ var formElems = /textarea|input|select/i,
2182
2233
 
2183
- function getVal( elem ) {
2184
- var type = elem.type, val = elem.value;
2234
+ changeFilters,
2185
2235
 
2186
- if ( type === "radio" || type === "checkbox" ) {
2187
- val = elem.checked;
2236
+ getVal = function( elem ) {
2237
+ var type = elem.type, val = elem.value;
2188
2238
 
2189
- } else if ( type === "select-multiple" ) {
2190
- val = elem.selectedIndex > -1 ?
2191
- jQuery.map( elem.options, function( elem ) {
2192
- return elem.selected;
2193
- }).join("-") :
2194
- "";
2239
+ if ( type === "radio" || type === "checkbox" ) {
2240
+ val = elem.checked;
2195
2241
 
2196
- } else if ( elem.nodeName.toLowerCase() === "select" ) {
2197
- val = elem.selectedIndex;
2198
- }
2242
+ } else if ( type === "select-multiple" ) {
2243
+ val = elem.selectedIndex > -1 ?
2244
+ jQuery.map( elem.options, function( elem ) {
2245
+ return elem.selected;
2246
+ }).join("-") :
2247
+ "";
2199
2248
 
2200
- return val;
2201
- }
2249
+ } else if ( elem.nodeName.toLowerCase() === "select" ) {
2250
+ val = elem.selectedIndex;
2251
+ }
2252
+
2253
+ return val;
2254
+ },
2202
2255
 
2203
- function testChange( e ) {
2256
+ testChange = function testChange( e ) {
2204
2257
  var elem = e.target, data, val;
2205
2258
 
2206
2259
  if ( !formElems.test( elem.nodeName ) || elem.readOnly ) {
@@ -2223,61 +2276,61 @@ function testChange( e ) {
2223
2276
  e.type = "change";
2224
2277
  return jQuery.event.trigger( e, arguments[1], elem );
2225
2278
  }
2226
- }
2279
+ };
2227
2280
 
2228
- jQuery.event.special.change = {
2229
- filters: {
2230
- focusout: testChange,
2281
+ jQuery.event.special.change = {
2282
+ filters: {
2283
+ focusout: testChange,
2231
2284
 
2232
- click: function( e ) {
2233
- var elem = e.target, type = elem.type;
2285
+ click: function( e ) {
2286
+ var elem = e.target, type = elem.type;
2234
2287
 
2235
- if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) {
2236
- return testChange.call( this, e );
2237
- }
2238
- },
2288
+ if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) {
2289
+ return testChange.call( this, e );
2290
+ }
2291
+ },
2292
+
2293
+ // Change has to be called before submit
2294
+ // Keydown will be called before keypress, which is used in submit-event delegation
2295
+ keydown: function( e ) {
2296
+ var elem = e.target, type = elem.type;
2239
2297
 
2240
- // Change has to be called before submit
2241
- // Keydown will be called before keypress, which is used in submit-event delegation
2242
- keydown: function( e ) {
2243
- var elem = e.target, type = elem.type;
2298
+ if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") ||
2299
+ (e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
2300
+ type === "select-multiple" ) {
2301
+ return testChange.call( this, e );
2302
+ }
2303
+ },
2244
2304
 
2245
- if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") ||
2246
- (e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
2247
- type === "select-multiple" ) {
2248
- return testChange.call( this, e );
2305
+ // Beforeactivate happens also before the previous element is blurred
2306
+ // with this event you can't trigger a change event, but you can store
2307
+ // information/focus[in] is not needed anymore
2308
+ beforeactivate: function( e ) {
2309
+ var elem = e.target;
2310
+ jQuery.data( elem, "_change_data", getVal(elem) );
2249
2311
  }
2250
2312
  },
2251
2313
 
2252
- // Beforeactivate happens also before the previous element is blurred
2253
- // with this event you can't trigger a change event, but you can store
2254
- // information/focus[in] is not needed anymore
2255
- beforeactivate: function( e ) {
2256
- var elem = e.target;
2314
+ setup: function( data, namespaces ) {
2315
+ if ( this.type === "file" ) {
2316
+ return false;
2317
+ }
2257
2318
 
2258
- if ( elem.nodeName.toLowerCase() === "input" && elem.type === "radio" ) {
2259
- jQuery.data( elem, "_change_data", getVal(elem) );
2319
+ for ( var type in changeFilters ) {
2320
+ jQuery.event.add( this, type + ".specialChange", changeFilters[type] );
2260
2321
  }
2261
- }
2262
- },
2263
- setup: function( data, namespaces, fn ) {
2264
- for ( var type in changeFilters ) {
2265
- jQuery.event.add( this, type + ".specialChange." + fn.guid, changeFilters[type] );
2266
- }
2267
2322
 
2268
- return formElems.test( this.nodeName );
2269
- },
2270
- remove: function( namespaces, fn ) {
2271
- for ( var type in changeFilters ) {
2272
- jQuery.event.remove( this, type + ".specialChange" + (fn ? "."+fn.guid : ""), changeFilters[type] );
2273
- }
2323
+ return formElems.test( this.nodeName );
2324
+ },
2274
2325
 
2275
- return formElems.test( this.nodeName );
2276
- }
2277
- };
2326
+ teardown: function( namespaces ) {
2327
+ jQuery.event.remove( this, ".specialChange" );
2278
2328
 
2279
- var changeFilters = jQuery.event.special.change.filters;
2329
+ return formElems.test( this.nodeName );
2330
+ }
2331
+ };
2280
2332
 
2333
+ changeFilters = jQuery.event.special.change.filters;
2281
2334
  }
2282
2335
 
2283
2336
  function trigger( type, elem, args ) {
@@ -2325,11 +2378,16 @@ jQuery.each(["bind", "one"], function( i, name ) {
2325
2378
  return fn.apply( this, arguments );
2326
2379
  }) : fn;
2327
2380
 
2328
- return type === "unload" && name !== "one" ?
2329
- this.one( type, data, fn ) :
2330
- this.each(function() {
2331
- jQuery.event.add( this, type, handler, data );
2332
- });
2381
+ if ( type === "unload" && name !== "one" ) {
2382
+ this.one( type, data, fn );
2383
+
2384
+ } else {
2385
+ for ( var i = 0, l = this.length; i < l; i++ ) {
2386
+ jQuery.event.add( this[i], type, handler, data );
2387
+ }
2388
+ }
2389
+
2390
+ return this;
2333
2391
  };
2334
2392
  });
2335
2393
 
@@ -2340,13 +2398,29 @@ jQuery.fn.extend({
2340
2398
  for ( var key in type ) {
2341
2399
  this.unbind(key, type[key]);
2342
2400
  }
2343
- return this;
2401
+
2402
+ } else {
2403
+ for ( var i = 0, l = this.length; i < l; i++ ) {
2404
+ jQuery.event.remove( this[i], type, fn );
2405
+ }
2344
2406
  }
2345
2407
 
2346
- return this.each(function() {
2347
- jQuery.event.remove( this, type, fn );
2348
- });
2408
+ return this;
2409
+ },
2410
+
2411
+ delegate: function( selector, types, data, fn ) {
2412
+ return this.live( types, data, fn, selector );
2413
+ },
2414
+
2415
+ undelegate: function( selector, types, fn ) {
2416
+ if ( arguments.length === 0 ) {
2417
+ return this.unbind( "live" );
2418
+
2419
+ } else {
2420
+ return this.die( types, null, fn, selector );
2421
+ }
2349
2422
  },
2423
+
2350
2424
  trigger: function( type, data ) {
2351
2425
  return this.each(function() {
2352
2426
  jQuery.event.trigger( type, data, this );
@@ -2390,32 +2464,60 @@ jQuery.fn.extend({
2390
2464
  }
2391
2465
  });
2392
2466
 
2467
+ var liveMap = {
2468
+ focus: "focusin",
2469
+ blur: "focusout",
2470
+ mouseenter: "mouseover",
2471
+ mouseleave: "mouseout"
2472
+ };
2473
+
2393
2474
  jQuery.each(["live", "die"], function( i, name ) {
2394
- jQuery.fn[ name ] = function( types, data, fn ) {
2395
- var type, i = 0;
2475
+ jQuery.fn[ name ] = function( types, data, fn, origSelector /* Internal Use Only */ ) {
2476
+ var type, i = 0, match, namespaces, preType,
2477
+ selector = origSelector || this.selector,
2478
+ context = origSelector ? this : jQuery( this.context );
2396
2479
 
2397
2480
  if ( jQuery.isFunction( data ) ) {
2398
2481
  fn = data;
2399
2482
  data = undefined;
2400
2483
  }
2401
2484
 
2402
- types = (types || "").split( /\s+/ );
2485
+ types = (types || "").split(" ");
2403
2486
 
2404
2487
  while ( (type = types[ i++ ]) != null ) {
2405
- type = type === "focus" ? "focusin" : // focus --> focusin
2406
- type === "blur" ? "focusout" : // blur --> focusout
2407
- type === "hover" ? types.push("mouseleave") && "mouseenter" : // hover support
2408
- type;
2409
-
2488
+ match = rnamespaces.exec( type );
2489
+ namespaces = "";
2490
+
2491
+ if ( match ) {
2492
+ namespaces = match[0];
2493
+ type = type.replace( rnamespaces, "" );
2494
+ }
2495
+
2496
+ if ( type === "hover" ) {
2497
+ types.push( "mouseenter" + namespaces, "mouseleave" + namespaces );
2498
+ continue;
2499
+ }
2500
+
2501
+ preType = type;
2502
+
2503
+ if ( type === "focus" || type === "blur" ) {
2504
+ types.push( liveMap[ type ] + namespaces );
2505
+ type = type + namespaces;
2506
+
2507
+ } else {
2508
+ type = (liveMap[ type ] || type) + namespaces;
2509
+ }
2510
+
2410
2511
  if ( name === "live" ) {
2411
2512
  // bind live handler
2412
- jQuery( this.context ).bind( liveConvert( type, this.selector ), {
2413
- data: data, selector: this.selector, live: type
2414
- }, fn );
2513
+ context.each(function(){
2514
+ jQuery.event.add( this, liveConvert( type, selector ),
2515
+ { data: data, selector: selector, handler: fn, origType: type, origHandler: fn, preType: preType } );
2516
+ });
2415
2517
 
2416
2518
  } else {
2417
2519
  // unbind live handler
2418
- jQuery( this.context ).unbind( liveConvert( type, this.selector ), fn ? { guid: fn.guid + this.selector + type } : null );
2520
+ context.unbind( liveConvert( type, selector ), fn );
2419
2521
  }
2420
2522
  }
2421
2523
 
@@ -2425,45 +2527,46 @@ jQuery.each(["live", "die"], function( i, name ) {
2425
2527
 
2426
2528
  function liveHandler( event ) {
2427
2529
  var stop, elems = [], selectors = [], args = arguments,
2428
- related, match, fn, elem, j, i, l, data,
2429
- live = jQuery.extend({}, jQuery.data( this, "events" ).live);
2530
+ related, match, handleObj, elem, j, i, l, data,
2531
+ events = jQuery.data( this, "events" );
2430
2532
 
2431
2533
  // Make sure we avoid non-left-click bubbling in Firefox (#3861)
2432
- if ( event.button && event.type === "click" ) {
2534
+ if ( event.liveFired === this || !events || !events.live || event.button && event.type === "click" ) {
2433
2535
  return;
2434
2536
  }
2435
2537
 
2436
- for ( j in live ) {
2437
- fn = live[j];
2438
- if ( fn.live === event.type ||
2439
- fn.altLive && jQuery.inArray(event.type, fn.altLive) > -1 ) {
2538
+ event.liveFired = this;
2539
+
2540
+ var live = events.live.slice(0);
2541
+
2542
+ for ( j = 0; j < live.length; j++ ) {
2543
+ handleObj = live[j];
2544
+
2545
+ if ( handleObj.origType.replace( rnamespaces, "" ) === event.type ) {
2546
+ selectors.push( handleObj.selector );
2440
2547
 
2441
- data = fn.data;
2442
- if ( !(data.beforeFilter && data.beforeFilter[event.type] &&
2443
- !data.beforeFilter[event.type](event)) ) {
2444
- selectors.push( fn.selector );
2445
- }
2446
2548
  } else {
2447
- delete live[j];
2549
+ live.splice( j--, 1 );
2448
2550
  }
2449
2551
  }
2450
2552
 
2451
2553
  match = jQuery( event.target ).closest( selectors, event.currentTarget );
2452
2554
 
2453
2555
  for ( i = 0, l = match.length; i < l; i++ ) {
2454
- for ( j in live ) {
2455
- fn = live[j];
2456
- elem = match[i].elem;
2457
- related = null;
2556
+ for ( j = 0; j < live.length; j++ ) {
2557
+ handleObj = live[j];
2558
+
2559
+ if ( match[i].selector === handleObj.selector ) {
2560
+ elem = match[i].elem;
2561
+ related = null;
2458
2562
 
2459
- if ( match[i].selector === fn.selector ) {
2460
2563
  // Those two events require additional checking
2461
- if ( fn.live === "mouseenter" || fn.live === "mouseleave" ) {
2462
- related = jQuery( event.relatedTarget ).closest( fn.selector )[0];
2564
+ if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) {
2565
+ related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0];
2463
2566
  }
2464
2567
 
2465
2568
  if ( !related || related !== elem ) {
2466
- elems.push({ elem: elem, fn: fn });
2569
+ elems.push({ elem: elem, handleObj: handleObj });
2467
2570
  }
2468
2571
  }
2469
2572
  }
@@ -2472,8 +2575,10 @@ function liveHandler( event ) {
2472
2575
  for ( i = 0, l = elems.length; i < l; i++ ) {
2473
2576
  match = elems[i];
2474
2577
  event.currentTarget = match.elem;
2475
- event.data = match.fn.data;
2476
- if ( match.fn.apply( match.elem, args ) === false ) {
2578
+ event.data = match.handleObj.data;
2579
+ event.handleObj = match.handleObj;
2580
+
2581
+ if ( match.handleObj.origHandler.apply( match.elem, args ) === false ) {
2477
2582
  stop = false;
2478
2583
  break;
2479
2584
  }
@@ -2483,7 +2588,7 @@ function liveHandler( event ) {
2483
2588
  }
2484
2589
 
2485
2590
  function liveConvert( type, selector ) {
2486
- return "live." + (type ? type + "." : "") + selector.replace(/\./g, "`").replace(/ /g, "&");
2591
+ return "live." + (type && type !== "*" ? type + "." : "") + selector.replace(/\./g, "`").replace(/ /g, "&");
2487
2592
  }
2488
2593
 
2489
2594
  jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
@@ -3228,8 +3333,10 @@ var makeArray = function(array, results) {
3228
3333
 
3229
3334
  // Perform a simple check to determine if the browser is capable of
3230
3335
  // converting a NodeList to an array using builtin methods.
3336
+ // Also verifies that the returned array holds DOM nodes
3337
+ // (which is not the case in the Blackberry browser)
3231
3338
  try {
3232
- Array.prototype.slice.call( document.documentElement.childNodes, 0 );
3339
+ Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType;
3233
3340
 
3234
3341
  // Provide a fallback method if it does not work
3235
3342
  } catch(e){
@@ -3533,7 +3640,7 @@ function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
3533
3640
  }
3534
3641
 
3535
3642
  var contains = document.compareDocumentPosition ? function(a, b){
3536
- return a.compareDocumentPosition(b) & 16;
3643
+ return !!(a.compareDocumentPosition(b) & 16);
3537
3644
  } : function(a, b){
3538
3645
  return a !== b && (a.contains ? a.contains(b) : true);
3539
3646
  };
@@ -3570,7 +3677,7 @@ jQuery.find = Sizzle;
3570
3677
  jQuery.expr = Sizzle.selectors;
3571
3678
  jQuery.expr[":"] = jQuery.expr.filters;
3572
3679
  jQuery.unique = Sizzle.uniqueSort;
3573
- jQuery.getText = getText;
3680
+ jQuery.text = getText;
3574
3681
  jQuery.isXMLDoc = isXML;
3575
3682
  jQuery.contains = contains;
3576
3683
 
@@ -3856,7 +3963,8 @@ var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
3856
3963
  rselfClosing = /^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,
3857
3964
  rtagName = /<([\w:]+)/,
3858
3965
  rtbody = /<tbody/i,
3859
- rhtml = /<|&\w+;/,
3966
+ rhtml = /<|&#?\w+;/,
3967
+ rnocache = /<script|<object|<embed|<option|<style/i,
3860
3968
  rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, // checked="checked" or checked (html5)
3861
3969
  fcloseTag = function( all, front, tag ) {
3862
3970
  return rselfClosing.test( tag ) ?
@@ -3896,7 +4004,7 @@ jQuery.fn.extend({
3896
4004
  return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
3897
4005
  }
3898
4006
 
3899
- return jQuery.getText( this );
4007
+ return jQuery.text( this );
3900
4008
  },
3901
4009
 
3902
4010
  wrapAll: function( html ) {
@@ -4000,6 +4108,40 @@ jQuery.fn.extend({
4000
4108
  return set;
4001
4109
  }
4002
4110
  },
4111
+
4112
+ // keepData is for internal use only--do not document
4113
+ remove: function( selector, keepData ) {
4114
+ for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
4115
+ if ( !selector || jQuery.filter( selector, [ elem ] ).length ) {
4116
+ if ( !keepData && elem.nodeType === 1 ) {
4117
+ jQuery.cleanData( elem.getElementsByTagName("*") );
4118
+ jQuery.cleanData( [ elem ] );
4119
+ }
4120
+
4121
+ if ( elem.parentNode ) {
4122
+ elem.parentNode.removeChild( elem );
4123
+ }
4124
+ }
4125
+ }
4126
+
4127
+ return this;
4128
+ },
4129
+
4130
+ empty: function() {
4131
+ for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
4132
+ // Remove element nodes and prevent memory leaks
4133
+ if ( elem.nodeType === 1 ) {
4134
+ jQuery.cleanData( elem.getElementsByTagName("*") );
4135
+ }
4136
+
4137
+ // Remove any remaining nodes
4138
+ while ( elem.firstChild ) {
4139
+ elem.removeChild( elem.firstChild );
4140
+ }
4141
+ }
4142
+
4143
+ return this;
4144
+ },
4003
4145
 
4004
4146
  clone: function( events ) {
4005
4147
  // Do the clone
@@ -4021,6 +4163,8 @@ jQuery.fn.extend({
4021
4163
  }
4022
4164
 
4023
4165
  return jQuery.clean([html.replace(rinlinejQuery, "")
4166
+ // Handle the case in IE 8 where action=/test/> self-closes a tag
4167
+ .replace(/=([^="'>\s]+\/)>/g, '="$1">')
4024
4168
  .replace(rleadingWhitespace, "")], ownerDocument)[0];
4025
4169
  } else {
4026
4170
  return this.cloneNode(true);
@@ -4044,7 +4188,7 @@ jQuery.fn.extend({
4044
4188
  null;
4045
4189
 
4046
4190
  // See if we can take a shortcut and just use innerHTML
4047
- } else if ( typeof value === "string" && !/<script/i.test( value ) &&
4191
+ } else if ( typeof value === "string" && !rnocache.test( value ) &&
4048
4192
  (jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) &&
4049
4193
  !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) {
4050
4194
 
@@ -4083,16 +4227,17 @@ jQuery.fn.extend({
4083
4227
  if ( this[0] && this[0].parentNode ) {
4084
4228
  // Make sure that the elements are removed from the DOM before they are inserted
4085
4229
  // this can help fix replacing a parent with child elements
4086
- if ( !jQuery.isFunction( value ) ) {
4087
- value = jQuery( value ).detach();
4088
-
4089
- } else {
4230
+ if ( jQuery.isFunction( value ) ) {
4090
4231
  return this.each(function(i) {
4091
4232
  var self = jQuery(this), old = self.html();
4092
4233
  self.replaceWith( value.call( this, i, old ) );
4093
4234
  });
4094
4235
  }
4095
4236
 
4237
+ if ( typeof value !== "string" ) {
4238
+ value = jQuery(value).detach();
4239
+ }
4240
+
4096
4241
  return this.each(function() {
4097
4242
  var next = this.nextSibling, parent = this.parentNode;
4098
4243
 
@@ -4114,7 +4259,7 @@ jQuery.fn.extend({
4114
4259
  },
4115
4260
 
4116
4261
  domManip: function( args, table, callback ) {
4117
- var results, first, value = args[0], scripts = [];
4262
+ var results, first, value = args[0], scripts = [], fragment, parent;
4118
4263
 
4119
4264
  // We can't cloneNode fragments that contain checked, in WebKit
4120
4265
  if ( !jQuery.support.checkClone && arguments.length === 3 && typeof value === "string" && rchecked.test( value ) ) {
@@ -4132,14 +4277,23 @@ jQuery.fn.extend({
4132
4277
  }
4133
4278
 
4134
4279
  if ( this[0] ) {
4280
+ parent = value && value.parentNode;
4281
+
4135
4282
  // If we're in a fragment, just use that instead of building a new one
4136
- if ( args[0] && args[0].parentNode && args[0].parentNode.nodeType === 11 ) {
4137
- results = { fragment: args[0].parentNode };
4283
+ if ( jQuery.support.parentNode && parent && parent.nodeType === 11 && parent.childNodes.length === this.length ) {
4284
+ results = { fragment: parent };
4285
+
4138
4286
  } else {
4139
4287
  results = buildFragment( args, this, scripts );
4140
4288
  }
4141
-
4142
- first = results.fragment.firstChild;
4289
+
4290
+ fragment = results.fragment;
4291
+
4292
+ if ( fragment.childNodes.length === 1 ) {
4293
+ first = fragment = fragment.firstChild;
4294
+ } else {
4295
+ first = fragment.firstChild;
4296
+ }
4143
4297
 
4144
4298
  if ( first ) {
4145
4299
  table = table && jQuery.nodeName( first, "tr" );
@@ -4149,14 +4303,14 @@ jQuery.fn.extend({
4149
4303
  table ?
4150
4304
  root(this[i], first) :
4151
4305
  this[i],
4152
- results.cacheable || this.length > 1 || i > 0 ?
4153
- results.fragment.cloneNode(true) :
4154
- results.fragment
4306
+ i > 0 || results.cacheable || this.length > 1 ?
4307
+ fragment.cloneNode(true) :
4308
+ fragment
4155
4309
  );
4156
4310
  }
4157
4311
  }
4158
4312
 
4159
- if ( scripts ) {
4313
+ if ( scripts.length ) {
4160
4314
  jQuery.each( scripts, evalScript );
4161
4315
  }
4162
4316
  }
@@ -4196,10 +4350,16 @@ function cloneCopyEvent(orig, ret) {
4196
4350
  }
4197
4351
 
4198
4352
  function buildFragment( args, nodes, scripts ) {
4199
- var fragment, cacheable, cacheresults, doc;
4353
+ var fragment, cacheable, cacheresults,
4354
+ doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document);
4355
+
4356
+ // Only cache "small" (1/2 KB) strings that are associated with the main document
4357
+ // Cloning options loses the selected state, so don't cache them
4358
+ // IE 6 doesn't like it when you put <object> or <embed> elements in a fragment
4359
+ // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache
4360
+ if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && doc === document &&
4361
+ !rnocache.test( args[0] ) && (jQuery.support.checkClone || !rchecked.test( args[0] )) ) {
4200
4362
 
4201
- // webkit does not clone 'checked' attribute of radio inputs on cloneNode, so don't cache if string has a checked
4202
- if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && args[0].indexOf("<option") < 0 && (jQuery.support.checkClone || !rchecked.test( args[0] )) ) {
4203
4363
  cacheable = true;
4204
4364
  cacheresults = jQuery.fragments[ args[0] ];
4205
4365
  if ( cacheresults ) {
@@ -4210,7 +4370,6 @@ function buildFragment( args, nodes, scripts ) {
4210
4370
  }
4211
4371
 
4212
4372
  if ( !fragment ) {
4213
- doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document);
4214
4373
  fragment = doc.createDocumentFragment();
4215
4374
  jQuery.clean( args, doc, fragment, scripts );
4216
4375
  }
@@ -4232,46 +4391,22 @@ jQuery.each({
4232
4391
  replaceAll: "replaceWith"
4233
4392
  }, function( name, original ) {
4234
4393
  jQuery.fn[ name ] = function( selector ) {
4235
- var ret = [], insert = jQuery( selector );
4236
-
4237
- for ( var i = 0, l = insert.length; i < l; i++ ) {
4238
- var elems = (i > 0 ? this.clone(true) : this).get();
4239
- jQuery.fn[ original ].apply( jQuery(insert[i]), elems );
4240
- ret = ret.concat( elems );
4241
- }
4242
- return this.pushStack( ret, name, insert.selector );
4243
- };
4244
- });
4245
-
4246
- jQuery.each({
4247
- // keepData is for internal use only--do not document
4248
- remove: function( selector, keepData ) {
4249
- if ( !selector || jQuery.filter( selector, [ this ] ).length ) {
4250
- if ( !keepData && this.nodeType === 1 ) {
4251
- jQuery.cleanData( this.getElementsByTagName("*") );
4252
- jQuery.cleanData( [ this ] );
4253
- }
4254
-
4255
- if ( this.parentNode ) {
4256
- this.parentNode.removeChild( this );
4394
+ var ret = [], insert = jQuery( selector ),
4395
+ parent = this.length === 1 && this[0].parentNode;
4396
+
4397
+ if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) {
4398
+ insert[ original ]( this[0] );
4399
+ return this;
4400
+
4401
+ } else {
4402
+ for ( var i = 0, l = insert.length; i < l; i++ ) {
4403
+ var elems = (i > 0 ? this.clone(true) : this).get();
4404
+ jQuery.fn[ original ].apply( jQuery(insert[i]), elems );
4405
+ ret = ret.concat( elems );
4257
4406
  }
4407
+
4408
+ return this.pushStack( ret, name, insert.selector );
4258
4409
  }
4259
- },
4260
-
4261
- empty: function() {
4262
- // Remove element nodes and prevent memory leaks
4263
- if ( this.nodeType === 1 ) {
4264
- jQuery.cleanData( this.getElementsByTagName("*") );
4265
- }
4266
-
4267
- // Remove any remaining nodes
4268
- while ( this.firstChild ) {
4269
- this.removeChild( this.firstChild );
4270
- }
4271
- }
4272
- }, function( name, fn ) {
4273
- jQuery.fn[ name ] = function() {
4274
- return this.each( fn, arguments );
4275
4410
  };
4276
4411
  });
4277
4412
 
@@ -4286,13 +4421,13 @@ jQuery.extend({
4286
4421
 
4287
4422
  var ret = [];
4288
4423
 
4289
- jQuery.each(elems, function( i, elem ) {
4424
+ for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
4290
4425
  if ( typeof elem === "number" ) {
4291
4426
  elem += "";
4292
4427
  }
4293
4428
 
4294
4429
  if ( !elem ) {
4295
- return;
4430
+ continue;
4296
4431
  }
4297
4432
 
4298
4433
  // Convert html string into DOM nodes
@@ -4343,7 +4478,7 @@ jQuery.extend({
4343
4478
  div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
4344
4479
  }
4345
4480
 
4346
- elem = jQuery.makeArray( div.childNodes );
4481
+ elem = div.childNodes;
4347
4482
  }
4348
4483
 
4349
4484
  if ( elem.nodeType ) {
@@ -4351,13 +4486,13 @@ jQuery.extend({
4351
4486
  } else {
4352
4487
  ret = jQuery.merge( ret, elem );
4353
4488
  }
4354
-
4355
- });
4489
+ }
4356
4490
 
4357
4491
  if ( fragment ) {
4358
4492
  for ( var i = 0; ret[i]; i++ ) {
4359
4493
  if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
4360
4494
  scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
4495
+
4361
4496
  } else {
4362
4497
  if ( ret[i].nodeType === 1 ) {
4363
4498
  ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) );
@@ -4371,9 +4506,36 @@ jQuery.extend({
4371
4506
  },
4372
4507
 
4373
4508
  cleanData: function( elems ) {
4374
- for ( var i = 0, elem, id; (elem = elems[i]) != null; i++ ) {
4375
- jQuery.event.remove( elem );
4376
- jQuery.removeData( elem );
4509
+ var data, id, cache = jQuery.cache,
4510
+ special = jQuery.event.special,
4511
+ deleteExpando = jQuery.support.deleteExpando;
4512
+
4513
+ for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
4514
+ id = elem[ jQuery.expando ];
4515
+
4516
+ if ( id ) {
4517
+ data = cache[ id ];
4518
+
4519
+ if ( data.events ) {
4520
+ for ( var type in data.events ) {
4521
+ if ( special[ type ] ) {
4522
+ jQuery.event.remove( elem, type );
4523
+
4524
+ } else {
4525
+ removeEvent( elem, type, data.handle );
4526
+ }
4527
+ }
4528
+ }
4529
+
4530
+ if ( deleteExpando ) {
4531
+ delete elem[ jQuery.expando ];
4532
+
4533
+ } else if ( elem.removeAttribute ) {
4534
+ elem.removeAttribute( jQuery.expando );
4535
+ }
4536
+
4537
+ delete cache[ id ];
4538
+ }
4377
4539
  }
4378
4540
  }
4379
4541
  });
@@ -4614,15 +4776,15 @@ var jsc = now(),
4614
4776
  rquery = /\?/,
4615
4777
  rts = /(\?|&)_=.*?(&|$)/,
4616
4778
  rurl = /^(\w+:)?\/\/([^\/?#]+)/,
4617
- r20 = /%20/g;
4779
+ r20 = /%20/g,
4618
4780
 
4619
- jQuery.fn.extend({
4620
- // Keep a copy of the old load
4621
- _load: jQuery.fn.load,
4781
+ // Keep a copy of the old load method
4782
+ _load = jQuery.fn.load;
4622
4783
 
4784
+ jQuery.fn.extend({
4623
4785
  load: function( url, params, callback ) {
4624
4786
  if ( typeof url !== "string" ) {
4625
- return this._load( url );
4787
+ return _load.call( this, url );
4626
4788
 
4627
4789
  // Don't do a request if no elements are being requested
4628
4790
  } else if ( !this.length ) {
@@ -5243,7 +5405,7 @@ jQuery.extend({
5243
5405
  if ( jQuery.isArray(obj) ) {
5244
5406
  // Serialize array item.
5245
5407
  jQuery.each( obj, function( i, v ) {
5246
- if ( traditional ) {
5408
+ if ( traditional || /\[\]$/.test( prefix ) ) {
5247
5409
  // Treat each array item as a scalar.
5248
5410
  add( prefix, v );
5249
5411
  } else {