A book about the command line for humans.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

10308 lines
276 KiB

  1. /*!
  2. * jQuery JavaScript Library v1.11.1
  3. * http://jquery.com/
  4. *
  5. * Includes Sizzle.js
  6. * http://sizzlejs.com/
  7. *
  8. * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
  9. * Released under the MIT license
  10. * http://jquery.org/license
  11. *
  12. * Date: 2014-05-01T17:42Z
  13. */
  14. (function( global, factory ) {
  15. if ( typeof module === "object" && typeof module.exports === "object" ) {
  16. // For CommonJS and CommonJS-like environments where a proper window is present,
  17. // execute the factory and get jQuery
  18. // For environments that do not inherently posses a window with a document
  19. // (such as Node.js), expose a jQuery-making factory as module.exports
  20. // This accentuates the need for the creation of a real window
  21. // e.g. var jQuery = require("jquery")(window);
  22. // See ticket #14549 for more info
  23. module.exports = global.document ?
  24. factory( global, true ) :
  25. function( w ) {
  26. if ( !w.document ) {
  27. throw new Error( "jQuery requires a window with a document" );
  28. }
  29. return factory( w );
  30. };
  31. } else {
  32. factory( global );
  33. }
  34. // Pass this if window is not defined yet
  35. }(typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
  36. // Can't do this because several apps including ASP.NET trace
  37. // the stack via arguments.caller.callee and Firefox dies if
  38. // you try to trace through "use strict" call chains. (#13335)
  39. // Support: Firefox 18+
  40. //
  41. var deletedIds = [];
  42. var slice = deletedIds.slice;
  43. var concat = deletedIds.concat;
  44. var push = deletedIds.push;
  45. var indexOf = deletedIds.indexOf;
  46. var class2type = {};
  47. var toString = class2type.toString;
  48. var hasOwn = class2type.hasOwnProperty;
  49. var support = {};
  50. var
  51. version = "1.11.1",
  52. // Define a local copy of jQuery
  53. jQuery = function( selector, context ) {
  54. // The jQuery object is actually just the init constructor 'enhanced'
  55. // Need init if jQuery is called (just allow error to be thrown if not included)
  56. return new jQuery.fn.init( selector, context );
  57. },
  58. // Support: Android<4.1, IE<9
  59. // Make sure we trim BOM and NBSP
  60. rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
  61. // Matches dashed string for camelizing
  62. rmsPrefix = /^-ms-/,
  63. rdashAlpha = /-([\da-z])/gi,
  64. // Used by jQuery.camelCase as callback to replace()
  65. fcamelCase = function( all, letter ) {
  66. return letter.toUpperCase();
  67. };
  68. jQuery.fn = jQuery.prototype = {
  69. // The current version of jQuery being used
  70. jquery: version,
  71. constructor: jQuery,
  72. // Start with an empty selector
  73. selector: "",
  74. // The default length of a jQuery object is 0
  75. length: 0,
  76. toArray: function() {
  77. return slice.call( this );
  78. },
  79. // Get the Nth element in the matched element set OR
  80. // Get the whole matched element set as a clean array
  81. get: function( num ) {
  82. return num != null ?
  83. // Return just the one element from the set
  84. ( num < 0 ? this[ num + this.length ] : this[ num ] ) :
  85. // Return all the elements in a clean array
  86. slice.call( this );
  87. },
  88. // Take an array of elements and push it onto the stack
  89. // (returning the new matched element set)
  90. pushStack: function( elems ) {
  91. // Build a new jQuery matched element set
  92. var ret = jQuery.merge( this.constructor(), elems );
  93. // Add the old object onto the stack (as a reference)
  94. ret.prevObject = this;
  95. ret.context = this.context;
  96. // Return the newly-formed element set
  97. return ret;
  98. },
  99. // Execute a callback for every element in the matched set.
  100. // (You can seed the arguments with an array of args, but this is
  101. // only used internally.)
  102. each: function( callback, args ) {
  103. return jQuery.each( this, callback, args );
  104. },
  105. map: function( callback ) {
  106. return this.pushStack( jQuery.map(this, function( elem, i ) {
  107. return callback.call( elem, i, elem );
  108. }));
  109. },
  110. slice: function() {
  111. return this.pushStack( slice.apply( this, arguments ) );
  112. },
  113. first: function() {
  114. return this.eq( 0 );
  115. },
  116. last: function() {
  117. return this.eq( -1 );
  118. },
  119. eq: function( i ) {
  120. var len = this.length,
  121. j = +i + ( i < 0 ? len : 0 );
  122. return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
  123. },
  124. end: function() {
  125. return this.prevObject || this.constructor(null);
  126. },
  127. // For internal use only.
  128. // Behaves like an Array's method, not like a jQuery method.
  129. push: push,
  130. sort: deletedIds.sort,
  131. splice: deletedIds.splice
  132. };
  133. jQuery.extend = jQuery.fn.extend = function() {
  134. var src, copyIsArray, copy, name, options, clone,
  135. target = arguments[0] || {},
  136. i = 1,
  137. length = arguments.length,
  138. deep = false;
  139. // Handle a deep copy situation
  140. if ( typeof target === "boolean" ) {
  141. deep = target;
  142. // skip the boolean and the target
  143. target = arguments[ i ] || {};
  144. i++;
  145. }
  146. // Handle case when target is a string or something (possible in deep copy)
  147. if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
  148. target = {};
  149. }
  150. // extend jQuery itself if only one argument is passed
  151. if ( i === length ) {
  152. target = this;
  153. i--;
  154. }
  155. for ( ; i < length; i++ ) {
  156. // Only deal with non-null/undefined values
  157. if ( (options = arguments[ i ]) != null ) {
  158. // Extend the base object
  159. for ( name in options ) {
  160. src = target[ name ];
  161. copy = options[ name ];
  162. // Prevent never-ending loop
  163. if ( target === copy ) {
  164. continue;
  165. }
  166. // Recurse if we're merging plain objects or arrays
  167. if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
  168. if ( copyIsArray ) {
  169. copyIsArray = false;
  170. clone = src && jQuery.isArray(src) ? src : [];
  171. } else {
  172. clone = src && jQuery.isPlainObject(src) ? src : {};
  173. }
  174. // Never move original objects, clone them
  175. target[ name ] = jQuery.extend( deep, clone, copy );
  176. // Don't bring in undefined values
  177. } else if ( copy !== undefined ) {
  178. target[ name ] = copy;
  179. }
  180. }
  181. }
  182. }
  183. // Return the modified object
  184. return target;
  185. };
  186. jQuery.extend({
  187. // Unique for each copy of jQuery on the page
  188. expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
  189. // Assume jQuery is ready without the ready module
  190. isReady: true,
  191. error: function( msg ) {
  192. throw new Error( msg );
  193. },
  194. noop: function() {},
  195. // See test/unit/core.js for details concerning isFunction.
  196. // Since version 1.3, DOM methods and functions like alert
  197. // aren't supported. They return false on IE (#2968).
  198. isFunction: function( obj ) {
  199. return jQuery.type(obj) === "function";
  200. },
  201. isArray: Array.isArray || function( obj ) {
  202. return jQuery.type(obj) === "array";
  203. },
  204. isWindow: function( obj ) {
  205. /* jshint eqeqeq: false */
  206. return obj != null && obj == obj.window;
  207. },
  208. isNumeric: function( obj ) {
  209. // parseFloat NaNs numeric-cast false positives (null|true|false|"")
  210. // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  211. // subtraction forces infinities to NaN
  212. return !jQuery.isArray( obj ) && obj - parseFloat( obj ) >= 0;
  213. },
  214. isEmptyObject: function( obj ) {
  215. var name;
  216. for ( name in obj ) {
  217. return false;
  218. }
  219. return true;
  220. },
  221. isPlainObject: function( obj ) {
  222. var key;
  223. // Must be an Object.
  224. // Because of IE, we also have to check the presence of the constructor property.
  225. // Make sure that DOM nodes and window objects don't pass through, as well
  226. if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
  227. return false;
  228. }
  229. try {
  230. // Not own constructor property must be Object
  231. if ( obj.constructor &&
  232. !hasOwn.call(obj, "constructor") &&
  233. !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
  234. return false;
  235. }
  236. } catch ( e ) {
  237. // IE8,9 Will throw exceptions on certain host objects #9897
  238. return false;
  239. }
  240. // Support: IE<9
  241. // Handle iteration over inherited properties before own properties.
  242. if ( support.ownLast ) {
  243. for ( key in obj ) {
  244. return hasOwn.call( obj, key );
  245. }
  246. }
  247. // Own properties are enumerated firstly, so to speed up,
  248. // if last one is own, then all properties are own.
  249. for ( key in obj ) {}
  250. return key === undefined || hasOwn.call( obj, key );
  251. },
  252. type: function( obj ) {
  253. if ( obj == null ) {
  254. return obj + "";
  255. }
  256. return typeof obj === "object" || typeof obj === "function" ?
  257. class2type[ toString.call(obj) ] || "object" :
  258. typeof obj;
  259. },
  260. // Evaluates a script in a global context
  261. // Workarounds based on findings by Jim Driscoll
  262. // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
  263. globalEval: function( data ) {
  264. if ( data && jQuery.trim( data ) ) {
  265. // We use execScript on Internet Explorer
  266. // We use an anonymous function so that context is window
  267. // rather than jQuery in Firefox
  268. ( window.execScript || function( data ) {
  269. window[ "eval" ].call( window, data );
  270. } )( data );
  271. }
  272. },
  273. // Convert dashed to camelCase; used by the css and data modules
  274. // Microsoft forgot to hump their vendor prefix (#9572)
  275. camelCase: function( string ) {
  276. return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
  277. },
  278. nodeName: function( elem, name ) {
  279. return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
  280. },
  281. // args is for internal usage only
  282. each: function( obj, callback, args ) {
  283. var value,
  284. i = 0,
  285. length = obj.length,
  286. isArray = isArraylike( obj );
  287. if ( args ) {
  288. if ( isArray ) {
  289. for ( ; i < length; i++ ) {
  290. value = callback.apply( obj[ i ], args );
  291. if ( value === false ) {
  292. break;
  293. }
  294. }
  295. } else {
  296. for ( i in obj ) {
  297. value = callback.apply( obj[ i ], args );
  298. if ( value === false ) {
  299. break;
  300. }
  301. }
  302. }
  303. // A special, fast, case for the most common use of each
  304. } else {
  305. if ( isArray ) {
  306. for ( ; i < length; i++ ) {
  307. value = callback.call( obj[ i ], i, obj[ i ] );
  308. if ( value === false ) {
  309. break;
  310. }
  311. }
  312. } else {
  313. for ( i in obj ) {
  314. value = callback.call( obj[ i ], i, obj[ i ] );
  315. if ( value === false ) {
  316. break;
  317. }
  318. }
  319. }
  320. }
  321. return obj;
  322. },
  323. // Support: Android<4.1, IE<9
  324. trim: function( text ) {
  325. return text == null ?
  326. "" :
  327. ( text + "" ).replace( rtrim, "" );
  328. },
  329. // results is for internal usage only
  330. makeArray: function( arr, results ) {
  331. var ret = results || [];
  332. if ( arr != null ) {
  333. if ( isArraylike( Object(arr) ) ) {
  334. jQuery.merge( ret,
  335. typeof arr === "string" ?
  336. [ arr ] : arr
  337. );
  338. } else {
  339. push.call( ret, arr );
  340. }
  341. }
  342. return ret;
  343. },
  344. inArray: function( elem, arr, i ) {
  345. var len;
  346. if ( arr ) {
  347. if ( indexOf ) {
  348. return indexOf.call( arr, elem, i );
  349. }
  350. len = arr.length;
  351. i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
  352. for ( ; i < len; i++ ) {
  353. // Skip accessing in sparse arrays
  354. if ( i in arr && arr[ i ] === elem ) {
  355. return i;
  356. }
  357. }
  358. }
  359. return -1;
  360. },
  361. merge: function( first, second ) {
  362. var len = +second.length,
  363. j = 0,
  364. i = first.length;
  365. while ( j < len ) {
  366. first[ i++ ] = second[ j++ ];
  367. }
  368. // Support: IE<9
  369. // Workaround casting of .length to NaN on otherwise arraylike objects (e.g., NodeLists)
  370. if ( len !== len ) {
  371. while ( second[j] !== undefined ) {
  372. first[ i++ ] = second[ j++ ];
  373. }
  374. }
  375. first.length = i;
  376. return first;
  377. },
  378. grep: function( elems, callback, invert ) {
  379. var callbackInverse,
  380. matches = [],
  381. i = 0,
  382. length = elems.length,
  383. callbackExpect = !invert;
  384. // Go through the array, only saving the items
  385. // that pass the validator function
  386. for ( ; i < length; i++ ) {
  387. callbackInverse = !callback( elems[ i ], i );
  388. if ( callbackInverse !== callbackExpect ) {
  389. matches.push( elems[ i ] );
  390. }
  391. }
  392. return matches;
  393. },
  394. // arg is for internal usage only
  395. map: function( elems, callback, arg ) {
  396. var value,
  397. i = 0,
  398. length = elems.length,
  399. isArray = isArraylike( elems ),
  400. ret = [];
  401. // Go through the array, translating each of the items to their new values
  402. if ( isArray ) {
  403. for ( ; i < length; i++ ) {
  404. value = callback( elems[ i ], i, arg );
  405. if ( value != null ) {
  406. ret.push( value );
  407. }
  408. }
  409. // Go through every key on the object,
  410. } else {
  411. for ( i in elems ) {
  412. value = callback( elems[ i ], i, arg );
  413. if ( value != null ) {
  414. ret.push( value );
  415. }
  416. }
  417. }
  418. // Flatten any nested arrays
  419. return concat.apply( [], ret );
  420. },
  421. // A global GUID counter for objects
  422. guid: 1,
  423. // Bind a function to a context, optionally partially applying any
  424. // arguments.
  425. proxy: function( fn, context ) {
  426. var args, proxy, tmp;
  427. if ( typeof context === "string" ) {
  428. tmp = fn[ context ];
  429. context = fn;
  430. fn = tmp;
  431. }
  432. // Quick check to determine if target is callable, in the spec
  433. // this throws a TypeError, but we will just return undefined.
  434. if ( !jQuery.isFunction( fn ) ) {
  435. return undefined;
  436. }
  437. // Simulated bind
  438. args = slice.call( arguments, 2 );
  439. proxy = function() {
  440. return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
  441. };
  442. // Set the guid of unique handler to the same of original handler, so it can be removed
  443. proxy.guid = fn.guid = fn.guid || jQuery.guid++;
  444. return proxy;
  445. },
  446. now: function() {
  447. return +( new Date() );
  448. },
  449. // jQuery.support is not used in Core but other projects attach their
  450. // properties to it so it needs to exist.
  451. support: support
  452. });
  453. // Populate the class2type map
  454. jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
  455. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  456. });
  457. function isArraylike( obj ) {
  458. var length = obj.length,
  459. type = jQuery.type( obj );
  460. if ( type === "function" || jQuery.isWindow( obj ) ) {
  461. return false;
  462. }
  463. if ( obj.nodeType === 1 && length ) {
  464. return true;
  465. }
  466. return type === "array" || length === 0 ||
  467. typeof length === "number" && length > 0 && ( length - 1 ) in obj;
  468. }
  469. var Sizzle =
  470. /*!
  471. * Sizzle CSS Selector Engine v1.10.19
  472. * http://sizzlejs.com/
  473. *
  474. * Copyright 2013 jQuery Foundation, Inc. and other contributors
  475. * Released under the MIT license
  476. * http://jquery.org/license
  477. *
  478. * Date: 2014-04-18
  479. */
  480. (function( window ) {
  481. var i,
  482. support,
  483. Expr,
  484. getText,
  485. isXML,
  486. tokenize,
  487. compile,
  488. select,
  489. outermostContext,
  490. sortInput,
  491. hasDuplicate,
  492. // Local document vars
  493. setDocument,
  494. document,
  495. docElem,
  496. documentIsHTML,
  497. rbuggyQSA,
  498. rbuggyMatches,
  499. matches,
  500. contains,
  501. // Instance-specific data
  502. expando = "sizzle" + -(new Date()),
  503. preferredDoc = window.document,
  504. dirruns = 0,
  505. done = 0,
  506. classCache = createCache(),
  507. tokenCache = createCache(),
  508. compilerCache = createCache(),
  509. sortOrder = function( a, b ) {
  510. if ( a === b ) {
  511. hasDuplicate = true;
  512. }
  513. return 0;
  514. },
  515. // General-purpose constants
  516. strundefined = typeof undefined,
  517. MAX_NEGATIVE = 1 << 31,
  518. // Instance methods
  519. hasOwn = ({}).hasOwnProperty,
  520. arr = [],
  521. pop = arr.pop,
  522. push_native = arr.push,
  523. push = arr.push,
  524. slice = arr.slice,
  525. // Use a stripped-down indexOf if we can't use a native one
  526. indexOf = arr.indexOf || function( elem ) {
  527. var i = 0,
  528. len = this.length;
  529. for ( ; i < len; i++ ) {
  530. if ( this[i] === elem ) {
  531. return i;
  532. }
  533. }
  534. return -1;
  535. },
  536. booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
  537. // Regular expressions
  538. // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
  539. whitespace = "[\\x20\\t\\r\\n\\f]",
  540. // http://www.w3.org/TR/css3-syntax/#characters
  541. characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
  542. // Loosely modeled on CSS identifier characters
  543. // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
  544. // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
  545. identifier = characterEncoding.replace( "w", "w#" ),
  546. // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
  547. attributes = "\\[" + whitespace + "*(" + characterEncoding + ")(?:" + whitespace +
  548. // Operator (capture 2)
  549. "*([*^$|!~]?=)" + whitespace +
  550. // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
  551. "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
  552. "*\\]",
  553. pseudos = ":(" + characterEncoding + ")(?:\\((" +
  554. // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
  555. // 1. quoted (capture 3; capture 4 or capture 5)
  556. "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
  557. // 2. simple (capture 6)
  558. "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
  559. // 3. anything else (capture 2)
  560. ".*" +
  561. ")\\)|)",
  562. // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
  563. rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
  564. rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
  565. rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
  566. rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),
  567. rpseudo = new RegExp( pseudos ),
  568. ridentifier = new RegExp( "^" + identifier + "$" ),
  569. matchExpr = {
  570. "ID": new RegExp( "^#(" + characterEncoding + ")" ),
  571. "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
  572. "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
  573. "ATTR": new RegExp( "^" + attributes ),
  574. "PSEUDO": new RegExp( "^" + pseudos ),
  575. "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
  576. "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
  577. "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
  578. "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
  579. // For use in libraries implementing .is()
  580. // We use this for POS matching in `select`
  581. "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
  582. whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
  583. },
  584. rinputs = /^(?:input|select|textarea|button)$/i,
  585. rheader = /^h\d$/i,
  586. rnative = /^[^{]+\{\s*\[native \w/,
  587. // Easily-parseable/retrievable ID or TAG or CLASS selectors
  588. rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
  589. rsibling = /[+~]/,
  590. rescape = /'|\\/g,
  591. // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
  592. runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
  593. funescape = function( _, escaped, escapedWhitespace ) {
  594. var high = "0x" + escaped - 0x10000;
  595. // NaN means non-codepoint
  596. // Support: Firefox<24
  597. // Workaround erroneous numeric interpretation of +"0x"
  598. return high !== high || escapedWhitespace ?
  599. escaped :
  600. high < 0 ?
  601. // BMP codepoint
  602. String.fromCharCode( high + 0x10000 ) :
  603. // Supplemental Plane codepoint (surrogate pair)
  604. String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
  605. };
  606. // Optimize for push.apply( _, NodeList )
  607. try {
  608. push.apply(
  609. (arr = slice.call( preferredDoc.childNodes )),
  610. preferredDoc.childNodes
  611. );
  612. // Support: Android<4.0
  613. // Detect silently failing push.apply
  614. arr[ preferredDoc.childNodes.length ].nodeType;
  615. } catch ( e ) {
  616. push = { apply: arr.length ?
  617. // Leverage slice if possible
  618. function( target, els ) {
  619. push_native.apply( target, slice.call(els) );
  620. } :
  621. // Support: IE<9
  622. // Otherwise append directly
  623. function( target, els ) {
  624. var j = target.length,
  625. i = 0;
  626. // Can't trust NodeList.length
  627. while ( (target[j++] = els[i++]) ) {}
  628. target.length = j - 1;
  629. }
  630. };
  631. }
  632. function Sizzle( selector, context, results, seed ) {
  633. var match, elem, m, nodeType,
  634. // QSA vars
  635. i, groups, old, nid, newContext, newSelector;
  636. if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
  637. setDocument( context );
  638. }
  639. context = context || document;
  640. results = results || [];
  641. if ( !selector || typeof selector !== "string" ) {
  642. return results;
  643. }
  644. if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) {
  645. return [];
  646. }
  647. if ( documentIsHTML && !seed ) {
  648. // Shortcuts
  649. if ( (match = rquickExpr.exec( selector )) ) {
  650. // Speed-up: Sizzle("#ID")
  651. if ( (m = match[1]) ) {
  652. if ( nodeType === 9 ) {
  653. elem = context.getElementById( m );
  654. // Check parentNode to catch when Blackberry 4.6 returns
  655. // nodes that are no longer in the document (jQuery #6963)
  656. if ( elem && elem.parentNode ) {
  657. // Handle the case where IE, Opera, and Webkit return items
  658. // by name instead of ID
  659. if ( elem.id === m ) {
  660. results.push( elem );
  661. return results;
  662. }
  663. } else {
  664. return results;
  665. }
  666. } else {
  667. // Context is not a document
  668. if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
  669. contains( context, elem ) && elem.id === m ) {
  670. results.push( elem );
  671. return results;
  672. }
  673. }
  674. // Speed-up: Sizzle("TAG")
  675. } else if ( match[2] ) {
  676. push.apply( results, context.getElementsByTagName( selector ) );
  677. return results;
  678. // Speed-up: Sizzle(".CLASS")
  679. } else if ( (m = match[3]) && support.getElementsByClassName && context.getElementsByClassName ) {
  680. push.apply( results, context.getElementsByClassName( m ) );
  681. return results;
  682. }
  683. }
  684. // QSA path
  685. if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
  686. nid = old = expando;
  687. newContext = context;
  688. newSelector = nodeType === 9 && selector;
  689. // qSA works strangely on Element-rooted queries
  690. // We can work around this by specifying an extra ID on the root
  691. // and working up from there (Thanks to Andrew Dupont for the technique)
  692. // IE 8 doesn't work on object elements
  693. if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
  694. groups = tokenize( selector );
  695. if ( (old = context.getAttribute("id")) ) {
  696. nid = old.replace( rescape, "\\$&" );
  697. } else {
  698. context.setAttribute( "id", nid );
  699. }
  700. nid = "[id='" + nid + "'] ";
  701. i = groups.length;
  702. while ( i-- ) {
  703. groups[i] = nid + toSelector( groups[i] );
  704. }
  705. newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context;
  706. newSelector = groups.join(",");
  707. }
  708. if ( newSelector ) {
  709. try {
  710. push.apply( results,
  711. newContext.querySelectorAll( newSelector )
  712. );
  713. return results;
  714. } catch(qsaError) {
  715. } finally {
  716. if ( !old ) {
  717. context.removeAttribute("id");
  718. }
  719. }
  720. }
  721. }
  722. }
  723. // All others
  724. return select( selector.replace( rtrim, "$1" ), context, results, seed );
  725. }
  726. /**
  727. * Create key-value caches of limited size
  728. * @returns {Function(string, Object)} Returns the Object data after storing it on itself with
  729. * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
  730. * deleting the oldest entry
  731. */
  732. function createCache() {
  733. var keys = [];
  734. function cache( key, value ) {
  735. // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
  736. if ( keys.push( key + " " ) > Expr.cacheLength ) {
  737. // Only keep the most recent entries
  738. delete cache[ keys.shift() ];
  739. }
  740. return (cache[ key + " " ] = value);
  741. }
  742. return cache;
  743. }
  744. /**
  745. * Mark a function for special use by Sizzle
  746. * @param {Function} fn The function to mark
  747. */
  748. function markFunction( fn ) {
  749. fn[ expando ] = true;
  750. return fn;
  751. }
  752. /**
  753. * Support testing using an element
  754. * @param {Function} fn Passed the created div and expects a boolean result
  755. */
  756. function assert( fn ) {
  757. var div = document.createElement("div");
  758. try {
  759. return !!fn( div );
  760. } catch (e) {
  761. return false;
  762. } finally {
  763. // Remove from its parent by default
  764. if ( div.parentNode ) {
  765. div.parentNode.removeChild( div );
  766. }
  767. // release memory in IE
  768. div = null;
  769. }
  770. }
  771. /**
  772. * Adds the same handler for all of the specified attrs
  773. * @param {String} attrs Pipe-separated list of attributes
  774. * @param {Function} handler The method that will be applied
  775. */
  776. function addHandle( attrs, handler ) {
  777. var arr = attrs.split("|"),
  778. i = attrs.length;
  779. while ( i-- ) {
  780. Expr.attrHandle[ arr[i] ] = handler;
  781. }
  782. }
  783. /**
  784. * Checks document order of two siblings
  785. * @param {Element} a
  786. * @param {Element} b
  787. * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
  788. */
  789. function siblingCheck( a, b ) {
  790. var cur = b && a,
  791. diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
  792. ( ~b.sourceIndex || MAX_NEGATIVE ) -
  793. ( ~a.sourceIndex || MAX_NEGATIVE );
  794. // Use IE sourceIndex if available on both nodes
  795. if ( diff ) {
  796. return diff;
  797. }
  798. // Check if b follows a
  799. if ( cur ) {
  800. while ( (cur = cur.nextSibling) ) {
  801. if ( cur === b ) {
  802. return -1;
  803. }
  804. }
  805. }
  806. return a ? 1 : -1;
  807. }
  808. /**
  809. * Returns a function to use in pseudos for input types
  810. * @param {String} type
  811. */
  812. function createInputPseudo( type ) {
  813. return function( elem ) {
  814. var name = elem.nodeName.toLowerCase();
  815. return name === "input" && elem.type === type;
  816. };
  817. }
  818. /**
  819. * Returns a function to use in pseudos for buttons
  820. * @param {String} type
  821. */
  822. function createButtonPseudo( type ) {
  823. return function( elem ) {
  824. var name = elem.nodeName.toLowerCase();
  825. return (name === "input" || name === "button") && elem.type === type;
  826. };
  827. }
  828. /**
  829. * Returns a function to use in pseudos for positionals
  830. * @param {Function} fn
  831. */
  832. function createPositionalPseudo( fn ) {
  833. return markFunction(function( argument ) {
  834. argument = +argument;
  835. return markFunction(function( seed, matches ) {
  836. var j,
  837. matchIndexes = fn( [], seed.length, argument ),
  838. i = matchIndexes.length;
  839. // Match elements found at the specified indexes
  840. while ( i-- ) {
  841. if ( seed[ (j = matchIndexes[i]) ] ) {
  842. seed[j] = !(matches[j] = seed[j]);
  843. }
  844. }
  845. });
  846. });
  847. }
  848. /**
  849. * Checks a node for validity as a Sizzle context
  850. * @param {Element|Object=} context
  851. * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
  852. */
  853. function testContext( context ) {
  854. return context && typeof context.getElementsByTagName !== strundefined && context;
  855. }
  856. // Expose support vars for convenience
  857. support = Sizzle.support = {};
  858. /**
  859. * Detects XML nodes
  860. * @param {Element|Object} elem An element or a document
  861. * @returns {Boolean} True iff elem is a non-HTML XML node
  862. */
  863. isXML = Sizzle.isXML = function( elem ) {
  864. // documentElement is verified for cases where it doesn't yet exist
  865. // (such as loading iframes in IE - #4833)
  866. var documentElement = elem && (elem.ownerDocument || elem).documentElement;
  867. return documentElement ? documentElement.nodeName !== "HTML" : false;
  868. };
  869. /**
  870. * Sets document-related variables once based on the current document
  871. * @param {Element|Object} [doc] An element or document object to use to set the document
  872. * @returns {Object} Returns the current document
  873. */
  874. setDocument = Sizzle.setDocument = function( node ) {
  875. var hasCompare,
  876. doc = node ? node.ownerDocument || node : preferredDoc,
  877. parent = doc.defaultView;
  878. // If no document and documentElement is available, return
  879. if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
  880. return document;
  881. }
  882. // Set our document
  883. document = doc;
  884. docElem = doc.documentElement;
  885. // Support tests
  886. documentIsHTML = !isXML( doc );
  887. // Support: IE>8
  888. // If iframe document is assigned to "document" variable and if iframe has been reloaded,
  889. // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936
  890. // IE6-8 do not support the defaultView property so parent will be undefined
  891. if ( parent && parent !== parent.top ) {
  892. // IE11 does not have attachEvent, so all must suffer
  893. if ( parent.addEventListener ) {
  894. parent.addEventListener( "unload", function() {
  895. setDocument();
  896. }, false );
  897. } else if ( parent.attachEvent ) {
  898. parent.attachEvent( "onunload", function() {
  899. setDocument();
  900. });
  901. }
  902. }
  903. /* Attributes
  904. ---------------------------------------------------------------------- */
  905. // Support: IE<8
  906. // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans)
  907. support.attributes = assert(function( div ) {
  908. div.className = "i";
  909. return !div.getAttribute("className");
  910. });
  911. /* getElement(s)By*
  912. ---------------------------------------------------------------------- */
  913. // Check if getElementsByTagName("*") returns only elements
  914. support.getElementsByTagName = assert(function( div ) {
  915. div.appendChild( doc.createComment("") );
  916. return !div.getElementsByTagName("*").length;
  917. });
  918. // Check if getElementsByClassName can be trusted
  919. support.getElementsByClassName = rnative.test( doc.getElementsByClassName ) && assert(function( div ) {
  920. div.innerHTML = "<div class='a'></div><div class='a i'></div>";
  921. // Support: Safari<4
  922. // Catch class over-caching
  923. div.firstChild.className = "i";
  924. // Support: Opera<10
  925. // Catch gEBCN failure to find non-leading classes
  926. return div.getElementsByClassName("i").length === 2;
  927. });
  928. // Support: IE<10
  929. // Check if getElementById returns elements by name
  930. // The broken getElementById methods don't pick up programatically-set names,
  931. // so use a roundabout getElementsByName test
  932. support.getById = assert(function( div ) {
  933. docElem.appendChild( div ).id = expando;
  934. return !doc.getElementsByName || !doc.getElementsByName( expando ).length;
  935. });
  936. // ID find and filter
  937. if ( support.getById ) {
  938. Expr.find["ID"] = function( id, context ) {
  939. if ( typeof context.getElementById !== strundefined && documentIsHTML ) {
  940. var m = context.getElementById( id );
  941. // Check parentNode to catch when Blackberry 4.6 returns
  942. // nodes that are no longer in the document #6963
  943. return m && m.parentNode ? [ m ] : [];
  944. }
  945. };
  946. Expr.filter["ID"] = function( id ) {
  947. var attrId = id.replace( runescape, funescape );
  948. return function( elem ) {
  949. return elem.getAttribute("id") === attrId;
  950. };
  951. };
  952. } else {
  953. // Support: IE6/7
  954. // getElementById is not reliable as a find shortcut
  955. delete Expr.find["ID"];
  956. Expr.filter["ID"] = function( id ) {
  957. var attrId = id.replace( runescape, funescape );
  958. return function( elem ) {
  959. var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
  960. return node && node.value === attrId;
  961. };
  962. };
  963. }
  964. // Tag
  965. Expr.find["TAG"] = support.getElementsByTagName ?
  966. function( tag, context ) {
  967. if ( typeof context.getElementsByTagName !== strundefined ) {
  968. return context.getElementsByTagName( tag );
  969. }
  970. } :
  971. function( tag, context ) {
  972. var elem,
  973. tmp = [],
  974. i = 0,
  975. results = context.getElementsByTagName( tag );
  976. // Filter out possible comments
  977. if ( tag === "*" ) {
  978. while ( (elem = results[i++]) ) {
  979. if ( elem.nodeType === 1 ) {
  980. tmp.push( elem );
  981. }
  982. }
  983. return tmp;
  984. }
  985. return results;
  986. };
  987. // Class
  988. Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
  989. if ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) {
  990. return context.getElementsByClassName( className );
  991. }
  992. };
  993. /* QSA/matchesSelector
  994. ---------------------------------------------------------------------- */
  995. // QSA and matchesSelector support
  996. // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
  997. rbuggyMatches = [];
  998. // qSa(:focus) reports false when true (Chrome 21)
  999. // We allow this because of a bug in IE8/9 that throws an error
  1000. // whenever `document.activeElement` is accessed on an iframe
  1001. // So, we allow :focus to pass through QSA all the time to avoid the IE error
  1002. // See http://bugs.jquery.com/ticket/13378
  1003. rbuggyQSA = [];
  1004. if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) {
  1005. // Build QSA regex
  1006. // Regex strategy adopted from Diego Perini
  1007. assert(function( div ) {
  1008. // Select is set to empty string on purpose
  1009. // This is to test IE's treatment of not explicitly
  1010. // setting a boolean content attribute,
  1011. // since its presence should be enough
  1012. // http://bugs.jquery.com/ticket/12359
  1013. div.innerHTML = "<select msallowclip=''><option selected=''></option></select>";
  1014. // Support: IE8, Opera 11-12.16
  1015. // Nothing should be selected when empty strings follow ^= or $= or *=
  1016. // The test attribute must be unknown in Opera but "safe" for WinRT
  1017. // http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
  1018. if ( div.querySelectorAll("[msallowclip^='']").length ) {
  1019. rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
  1020. }
  1021. // Support: IE8
  1022. // Boolean attributes and "value" are not treated correctly
  1023. if ( !div.querySelectorAll("[selected]").length ) {
  1024. rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
  1025. }
  1026. // Webkit/Opera - :checked should return selected option elements
  1027. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  1028. // IE8 throws error here and will not see later tests
  1029. if ( !div.querySelectorAll(":checked").length ) {
  1030. rbuggyQSA.push(":checked");
  1031. }
  1032. });
  1033. assert(function( div ) {
  1034. // Support: Windows 8 Native Apps
  1035. // The type and name attributes are restricted during .innerHTML assignment
  1036. var input = doc.createElement("input");
  1037. input.setAttribute( "type", "hidden" );
  1038. div.appendChild( input ).setAttribute( "name", "D" );
  1039. // Support: IE8
  1040. // Enforce case-sensitivity of name attribute
  1041. if ( div.querySelectorAll("[name=d]").length ) {
  1042. rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
  1043. }
  1044. // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
  1045. // IE8 throws error here and will not see later tests
  1046. if ( !div.querySelectorAll(":enabled").length ) {
  1047. rbuggyQSA.push( ":enabled", ":disabled" );
  1048. }
  1049. // Opera 10-11 does not throw on post-comma invalid pseudos
  1050. div.querySelectorAll("*,:x");
  1051. rbuggyQSA.push(",.*:");
  1052. });
  1053. }
  1054. if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
  1055. docElem.webkitMatchesSelector ||
  1056. docElem.mozMatchesSelector ||
  1057. docElem.oMatchesSelector ||
  1058. docElem.msMatchesSelector) )) ) {
  1059. assert(function( div ) {
  1060. // Check to see if it's possible to do matchesSelector
  1061. // on a disconnected node (IE 9)
  1062. support.disconnectedMatch = matches.call( div, "div" );
  1063. // This should fail with an exception
  1064. // Gecko does not error, returns false instead
  1065. matches.call( div, "[s!='']:x" );
  1066. rbuggyMatches.push( "!=", pseudos );
  1067. });
  1068. }
  1069. rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
  1070. rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
  1071. /* Contains
  1072. ---------------------------------------------------------------------- */
  1073. hasCompare = rnative.test( docElem.compareDocumentPosition );
  1074. // Element contains another
  1075. // Purposefully does not implement inclusive descendent
  1076. // As in, an element does not contain itself
  1077. contains = hasCompare || rnative.test( docElem.contains ) ?
  1078. function( a, b ) {
  1079. var adown = a.nodeType === 9 ? a.documentElement : a,
  1080. bup = b && b.parentNode;
  1081. return a === bup || !!( bup && bup.nodeType === 1 && (
  1082. adown.contains ?
  1083. adown.contains( bup ) :
  1084. a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
  1085. ));
  1086. } :
  1087. function( a, b ) {
  1088. if ( b ) {
  1089. while ( (b = b.parentNode) ) {
  1090. if ( b === a ) {
  1091. return true;
  1092. }
  1093. }
  1094. }
  1095. return false;
  1096. };
  1097. /* Sorting
  1098. ---------------------------------------------------------------------- */
  1099. // Document order sorting
  1100. sortOrder = hasCompare ?
  1101. function( a, b ) {
  1102. // Flag for duplicate removal
  1103. if ( a === b ) {
  1104. hasDuplicate = true;
  1105. return 0;
  1106. }
  1107. // Sort on method existence if only one input has compareDocumentPosition
  1108. var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
  1109. if ( compare ) {
  1110. return compare;
  1111. }
  1112. // Calculate position if both inputs belong to the same document
  1113. compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
  1114. a.compareDocumentPosition( b ) :
  1115. // Otherwise we know they are disconnected
  1116. 1;
  1117. // Disconnected nodes
  1118. if ( compare & 1 ||
  1119. (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
  1120. // Choose the first element that is related to our preferred document
  1121. if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
  1122. return -1;
  1123. }
  1124. if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
  1125. return 1;
  1126. }
  1127. // Maintain original order
  1128. return sortInput ?
  1129. ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
  1130. 0;
  1131. }
  1132. return compare & 4 ? -1 : 1;
  1133. } :
  1134. function( a, b ) {
  1135. // Exit early if the nodes are identical
  1136. if ( a === b ) {
  1137. hasDuplicate = true;
  1138. return 0;
  1139. }
  1140. var cur,
  1141. i = 0,
  1142. aup = a.parentNode,
  1143. bup = b.parentNode,
  1144. ap = [ a ],
  1145. bp = [ b ];
  1146. // Parentless nodes are either documents or disconnected
  1147. if ( !aup || !bup ) {
  1148. return a === doc ? -1 :
  1149. b === doc ? 1 :
  1150. aup ? -1 :
  1151. bup ? 1 :
  1152. sortInput ?
  1153. ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
  1154. 0;
  1155. // If the nodes are siblings, we can do a quick check
  1156. } else if ( aup === bup ) {
  1157. return siblingCheck( a, b );
  1158. }
  1159. // Otherwise we need full lists of their ancestors for comparison
  1160. cur = a;
  1161. while ( (cur = cur.parentNode) ) {
  1162. ap.unshift( cur );
  1163. }
  1164. cur = b;
  1165. while ( (cur = cur.parentNode) ) {
  1166. bp.unshift( cur );
  1167. }
  1168. // Walk down the tree looking for a discrepancy
  1169. while ( ap[i] === bp[i] ) {
  1170. i++;
  1171. }
  1172. return i ?
  1173. // Do a sibling check if the nodes have a common ancestor
  1174. siblingCheck( ap[i], bp[i] ) :
  1175. // Otherwise nodes in our document sort first
  1176. ap[i] === preferredDoc ? -1 :
  1177. bp[i] === preferredDoc ? 1 :
  1178. 0;
  1179. };
  1180. return doc;
  1181. };
  1182. Sizzle.matches = function( expr, elements ) {
  1183. return Sizzle( expr, null, null, elements );
  1184. };
  1185. Sizzle.matchesSelector = function( elem, expr ) {
  1186. // Set document vars if needed
  1187. if ( ( elem.ownerDocument || elem ) !== document ) {
  1188. setDocument( elem );
  1189. }
  1190. // Make sure that attribute selectors are quoted
  1191. expr = expr.replace( rattributeQuotes, "='$1']" );
  1192. if ( support.matchesSelector && documentIsHTML &&
  1193. ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
  1194. ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
  1195. try {
  1196. var ret = matches.call( elem, expr );
  1197. // IE 9's matchesSelector returns false on disconnected nodes
  1198. if ( ret || support.disconnectedMatch ||
  1199. // As well, disconnected nodes are said to be in a document
  1200. // fragment in IE 9
  1201. elem.document && elem.document.nodeType !== 11 ) {
  1202. return ret;
  1203. }
  1204. } catch(e) {}
  1205. }
  1206. return Sizzle( expr, document, null, [ elem ] ).length > 0;
  1207. };
  1208. Sizzle.contains = function( context, elem ) {
  1209. // Set document vars if needed
  1210. if ( ( context.ownerDocument || context ) !== document ) {
  1211. setDocument( context );
  1212. }
  1213. return contains( context, elem );
  1214. };
  1215. Sizzle.attr = function( elem, name ) {
  1216. // Set document vars if needed
  1217. if ( ( elem.ownerDocument || elem ) !== document ) {
  1218. setDocument( elem );
  1219. }
  1220. var fn = Expr.attrHandle[ name.toLowerCase() ],
  1221. // Don't get fooled by Object.prototype properties (jQuery #13807)
  1222. val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
  1223. fn( elem, name, !documentIsHTML ) :
  1224. undefined;
  1225. return val !== undefined ?
  1226. val :
  1227. support.attributes || !documentIsHTML ?
  1228. elem.getAttribute( name ) :
  1229. (val = elem.getAttributeNode(name)) && val.specified ?
  1230. val.value :
  1231. null;
  1232. };
  1233. Sizzle.error = function( msg ) {
  1234. throw new Error( "Syntax error, unrecognized expression: " + msg );
  1235. };
  1236. /**
  1237. * Document sorting and removing duplicates
  1238. * @param {ArrayLike} results
  1239. */
  1240. Sizzle.uniqueSort = function( results ) {
  1241. var elem,
  1242. duplicates = [],
  1243. j = 0,
  1244. i = 0;
  1245. // Unless we *know* we can detect duplicates, assume their presence
  1246. hasDuplicate = !support.detectDuplicates;
  1247. sortInput = !support.sortStable && results.slice( 0 );
  1248. results.sort( sortOrder );
  1249. if ( hasDuplicate ) {
  1250. while ( (elem = results[i++]) ) {
  1251. if ( elem === results[ i ] ) {
  1252. j = duplicates.push( i );
  1253. }
  1254. }
  1255. while ( j-- ) {
  1256. results.splice( duplicates[ j ], 1 );
  1257. }
  1258. }
  1259. // Clear input after sorting to release objects
  1260. // See https://github.com/jquery/sizzle/pull/225
  1261. sortInput = null;
  1262. return results;
  1263. };
  1264. /**
  1265. * Utility function for retrieving the text value of an array of DOM nodes
  1266. * @param {Array|Element} elem
  1267. */
  1268. getText = Sizzle.getText = function( elem ) {
  1269. var node,
  1270. ret = "",
  1271. i = 0,
  1272. nodeType = elem.nodeType;
  1273. if ( !nodeType ) {
  1274. // If no nodeType, this is expected to be an array
  1275. while ( (node = elem[i++]) ) {
  1276. // Do not traverse comment nodes
  1277. ret += getText( node );
  1278. }
  1279. } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
  1280. // Use textContent for elements
  1281. // innerText usage removed for consistency of new lines (jQuery #11153)
  1282. if ( typeof elem.textContent === "string" ) {
  1283. return elem.textContent;
  1284. } else {
  1285. // Traverse its children
  1286. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  1287. ret += getText( elem );
  1288. }
  1289. }
  1290. } else if ( nodeType === 3 || nodeType === 4 ) {
  1291. return elem.nodeValue;
  1292. }
  1293. // Do not include comment or processing instruction nodes
  1294. return ret;
  1295. };
  1296. Expr = Sizzle.selectors = {
  1297. // Can be adjusted by the user
  1298. cacheLength: 50,
  1299. createPseudo: markFunction,
  1300. match: matchExpr,
  1301. attrHandle: {},
  1302. find: {},
  1303. relative: {
  1304. ">": { dir: "parentNode", first: true },
  1305. " ": { dir: "parentNode" },
  1306. "+": { dir: "previousSibling", first: true },
  1307. "~": { dir: "previousSibling" }
  1308. },
  1309. preFilter: {
  1310. "ATTR": function( match ) {
  1311. match[1] = match[1].replace( runescape, funescape );
  1312. // Move the given value to match[3] whether quoted or unquoted
  1313. match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
  1314. if ( match[2] === "~=" ) {
  1315. match[3] = " " + match[3] + " ";
  1316. }
  1317. return match.slice( 0, 4 );
  1318. },
  1319. "CHILD": function( match ) {
  1320. /* matches from matchExpr["CHILD"]
  1321. 1 type (only|nth|...)
  1322. 2 what (child|of-type)
  1323. 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
  1324. 4 xn-component of xn+y argument ([+-]?\d*n|)
  1325. 5 sign of xn-component
  1326. 6 x of xn-component
  1327. 7 sign of y-component
  1328. 8 y of y-component
  1329. */
  1330. match[1] = match[1].toLowerCase();
  1331. if ( match[1].slice( 0, 3 ) === "nth" ) {
  1332. // nth-* requires argument
  1333. if ( !match[3] ) {
  1334. Sizzle.error( match[0] );
  1335. }
  1336. // numeric x and y parameters for Expr.filter.CHILD
  1337. // remember that false/true cast respectively to 0/1
  1338. match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
  1339. match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
  1340. // other types prohibit arguments
  1341. } else if ( match[3] ) {
  1342. Sizzle.error( match[0] );
  1343. }
  1344. return match;
  1345. },
  1346. "PSEUDO": function( match ) {
  1347. var excess,
  1348. unquoted = !match[6] && match[2];
  1349. if ( matchExpr["CHILD"].test( match[0] ) ) {
  1350. return null;
  1351. }
  1352. // Accept quoted arguments as-is
  1353. if ( match[3] ) {
  1354. match[2] = match[4] || match[5] || "";
  1355. // Strip excess characters from unquoted arguments
  1356. } else if ( unquoted && rpseudo.test( unquoted ) &&
  1357. // Get excess from tokenize (recursively)
  1358. (excess = tokenize( unquoted, true )) &&
  1359. // advance to the next closing parenthesis
  1360. (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
  1361. // excess is a negative index
  1362. match[0] = match[0].slice( 0, excess );
  1363. match[2] = unquoted.slice( 0, excess );
  1364. }
  1365. // Return only captures needed by the pseudo filter method (type and argument)
  1366. return match.slice( 0, 3 );
  1367. }
  1368. },
  1369. filter: {
  1370. "TAG": function( nodeNameSelector ) {
  1371. var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
  1372. return nodeNameSelector === "*" ?
  1373. function() { return true; } :
  1374. function( elem ) {
  1375. return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
  1376. };
  1377. },
  1378. "CLASS": function( className ) {
  1379. var pattern = classCache[ className + " " ];
  1380. return pattern ||
  1381. (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
  1382. classCache( className, function( elem ) {
  1383. return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute("class") || "" );
  1384. });
  1385. },
  1386. "ATTR": function( name, operator, check ) {
  1387. return function( elem ) {
  1388. var result = Sizzle.attr( elem, name );
  1389. if ( result == null ) {
  1390. return operator === "!=";
  1391. }
  1392. if ( !operator ) {
  1393. return true;
  1394. }
  1395. result += "";
  1396. return operator === "=" ? result === check :
  1397. operator === "!=" ? result !== check :
  1398. operator === "^=" ? check && result.indexOf( check ) === 0 :
  1399. operator === "*=" ? check && result.indexOf( check ) > -1 :
  1400. operator === "$=" ? check && result.slice( -check.length ) === check :
  1401. operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
  1402. operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
  1403. false;
  1404. };
  1405. },
  1406. "CHILD": function( type, what, argument, first, last ) {
  1407. var simple = type.slice( 0, 3 ) !== "nth",
  1408. forward = type.slice( -4 ) !== "last",
  1409. ofType = what === "of-type";
  1410. return first === 1 && last === 0 ?
  1411. // Shortcut for :nth-*(n)
  1412. function( elem ) {
  1413. return !!elem.parentNode;
  1414. } :
  1415. function( elem, context, xml ) {
  1416. var cache, outerCache, node, diff, nodeIndex, start,
  1417. dir = simple !== forward ? "nextSibling" : "previousSibling",
  1418. parent = elem.parentNode,
  1419. name = ofType && elem.nodeName.toLowerCase(),
  1420. useCache = !xml && !ofType;
  1421. if ( parent ) {
  1422. // :(first|last|only)-(child|of-type)
  1423. if ( simple ) {
  1424. while ( dir ) {
  1425. node = elem;
  1426. while ( (node = node[ dir ]) ) {
  1427. if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) {
  1428. return false;
  1429. }
  1430. }
  1431. // Reverse direction for :only-* (if we haven't yet done so)
  1432. start = dir = type === "only" && !start && "nextSibling";
  1433. }
  1434. return true;
  1435. }
  1436. start = [ forward ? parent.firstChild : parent.lastChild ];
  1437. // non-xml :nth-child(...) stores cache data on `parent`
  1438. if ( forward && useCache ) {
  1439. // Seek `elem` from a previously-cached index
  1440. outerCache = parent[ expando ] || (parent[ expando ] = {});
  1441. cache = outerCache[ type ] || [];
  1442. nodeIndex = cache[0] === dirruns && cache[1];
  1443. diff = cache[0] === dirruns && cache[2];
  1444. node = nodeIndex && parent.childNodes[ nodeIndex ];
  1445. while ( (node = ++nodeIndex && node && node[ dir ] ||
  1446. // Fallback to seeking `elem` from the start
  1447. (diff = nodeIndex = 0) || start.pop()) ) {
  1448. // When found, cache indexes on `parent` and break
  1449. if ( node.nodeType === 1 && ++diff && node === elem ) {
  1450. outerCache[ type ] = [ dirruns, nodeIndex, diff ];
  1451. break;
  1452. }
  1453. }
  1454. // Use previously-cached element index if available
  1455. } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {
  1456. diff = cache[1];
  1457. // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
  1458. } else {
  1459. // Use the same loop as above to seek `elem` from the start
  1460. while ( (node = ++nodeIndex && node && node[ dir ] ||
  1461. (diff = nodeIndex = 0) || start.pop()) ) {
  1462. if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) {
  1463. // Cache the index of each encountered element
  1464. if ( useCache ) {
  1465. (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ];
  1466. }
  1467. if ( node === elem ) {
  1468. break;
  1469. }
  1470. }
  1471. }
  1472. }
  1473. // Incorporate the offset, then check against cycle size
  1474. diff -= last;
  1475. return diff === first || ( diff % first === 0 && diff / first >= 0 );
  1476. }
  1477. };
  1478. },
  1479. "PSEUDO": function( pseudo, argument ) {
  1480. // pseudo-class names are case-insensitive
  1481. // http://www.w3.org/TR/selectors/#pseudo-classes
  1482. // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
  1483. // Remember that setFilters inherits from pseudos
  1484. var args,
  1485. fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
  1486. Sizzle.error( "unsupported pseudo: " + pseudo );
  1487. // The user may use createPseudo to indicate that
  1488. // arguments are needed to create the filter function
  1489. // just as Sizzle does
  1490. if ( fn[ expando ] ) {
  1491. return fn( argument );
  1492. }
  1493. // But maintain support for old signatures
  1494. if ( fn.length > 1 ) {
  1495. args = [ pseudo, pseudo, "", argument ];
  1496. return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
  1497. markFunction(function( seed, matches ) {
  1498. var idx,
  1499. matched = fn( seed, argument ),
  1500. i = matched.length;
  1501. while ( i-- ) {
  1502. idx = indexOf.call( seed, matched[i] );
  1503. seed[ idx ] = !( matches[ idx ] = matched[i] );
  1504. }
  1505. }) :
  1506. function( elem ) {
  1507. return fn( elem, 0, args );
  1508. };
  1509. }
  1510. return fn;
  1511. }
  1512. },
  1513. pseudos: {
  1514. // Potentially complex pseudos
  1515. "not": markFunction(function( selector ) {
  1516. // Trim the selector passed to compile
  1517. // to avoid treating leading and trailing
  1518. // spaces as combinators
  1519. var input = [],
  1520. results = [],
  1521. matcher = compile( selector.replace( rtrim, "$1" ) );
  1522. return matcher[ expando ] ?
  1523. markFunction(function( seed, matches, context, xml ) {
  1524. var elem,
  1525. unmatched = matcher( seed, null, xml, [] ),
  1526. i = seed.length;
  1527. // Match elements unmatched by `matcher`
  1528. while ( i-- ) {
  1529. if ( (elem = unmatched[i]) ) {
  1530. seed[i] = !(matches[i] = elem);
  1531. }
  1532. }
  1533. }) :
  1534. function( elem, context, xml ) {
  1535. input[0] = elem;
  1536. matcher( input, null, xml, results );
  1537. return !results.pop();
  1538. };
  1539. }),
  1540. "has": markFunction(function( selector ) {
  1541. return function( elem ) {
  1542. return Sizzle( selector, elem ).length > 0;
  1543. };
  1544. }),
  1545. "contains": markFunction(function( text ) {
  1546. return function( elem ) {
  1547. return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
  1548. };
  1549. }),
  1550. // "Whether an element is represented by a :lang() selector
  1551. // is based solely on the element's language value
  1552. // being equal to the identifier C,
  1553. // or beginning with the identifier C immediately followed by "-".
  1554. // The matching of C against the element's language value is performed case-insensitively.
  1555. // The identifier C does not have to be a valid language name."
  1556. // http://www.w3.org/TR/selectors/#lang-pseudo
  1557. "lang": markFunction( function( lang ) {
  1558. // lang value must be a valid identifier
  1559. if ( !ridentifier.test(lang || "") ) {
  1560. Sizzle.error( "unsupported lang: " + lang );
  1561. }
  1562. lang = lang.replace( runescape, funescape ).toLowerCase();
  1563. return function( elem ) {
  1564. var elemLang;
  1565. do {
  1566. if ( (elemLang = documentIsHTML ?
  1567. elem.lang :
  1568. elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
  1569. elemLang = elemLang.toLowerCase();
  1570. return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
  1571. }
  1572. } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
  1573. return false;
  1574. };
  1575. }),
  1576. // Miscellaneous
  1577. "target": function( elem ) {
  1578. var hash = window.location && window.location.hash;
  1579. return hash && hash.slice( 1 ) === elem.id;
  1580. },
  1581. "root": function( elem ) {
  1582. return elem === docElem;
  1583. },
  1584. "focus": function( elem ) {
  1585. return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
  1586. },
  1587. // Boolean properties
  1588. "enabled": function( elem ) {
  1589. return elem.disabled === false;
  1590. },
  1591. "disabled": function( elem ) {
  1592. return elem.disabled === true;
  1593. },
  1594. "checked": function( elem ) {
  1595. // In CSS3, :checked should return both checked and selected elements
  1596. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  1597. var nodeName = elem.nodeName.toLowerCase();
  1598. return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
  1599. },
  1600. "selected": function( elem ) {
  1601. // Accessing this property makes selected-by-default
  1602. // options in Safari work properly
  1603. if ( elem.parentNode ) {
  1604. elem.parentNode.selectedIndex;
  1605. }
  1606. return elem.selected === true;
  1607. },
  1608. // Contents
  1609. "empty": function( elem ) {
  1610. // http://www.w3.org/TR/selectors/#empty-pseudo
  1611. // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
  1612. // but not by others (comment: 8; processing instruction: 7; etc.)
  1613. // nodeType < 6 works because attributes (2) do not appear as children
  1614. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  1615. if ( elem.nodeType < 6 ) {
  1616. return false;
  1617. }
  1618. }
  1619. return true;
  1620. },
  1621. "parent": function( elem ) {
  1622. return !Expr.pseudos["empty"]( elem );
  1623. },
  1624. // Element/input types
  1625. "header": function( elem ) {
  1626. return rheader.test( elem.nodeName );
  1627. },
  1628. "input": function( elem ) {
  1629. return rinputs.test( elem.nodeName );
  1630. },
  1631. "button": function( elem ) {
  1632. var name = elem.nodeName.toLowerCase();
  1633. return name === "input" && elem.type === "button" || name === "button";
  1634. },
  1635. "text": function( elem ) {
  1636. var attr;
  1637. return elem.nodeName.toLowerCase() === "input" &&
  1638. elem.type === "text" &&
  1639. // Support: IE<8
  1640. // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
  1641. ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
  1642. },
  1643. // Position-in-collection
  1644. "first": createPositionalPseudo(function() {
  1645. return [ 0 ];
  1646. }),
  1647. "last": createPositionalPseudo(function( matchIndexes, length ) {
  1648. return [ length - 1 ];
  1649. }),
  1650. "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
  1651. return [ argument < 0 ? argument + length : argument ];
  1652. }),
  1653. "even": createPositionalPseudo(function( matchIndexes, length ) {
  1654. var i = 0;
  1655. for ( ; i < length; i += 2 ) {
  1656. matchIndexes.push( i );
  1657. }
  1658. return matchIndexes;
  1659. }),
  1660. "odd": createPositionalPseudo(function( matchIndexes, length ) {
  1661. var i = 1;
  1662. for ( ; i < length; i += 2 ) {
  1663. matchIndexes.push( i );
  1664. }
  1665. return matchIndexes;
  1666. }),
  1667. "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  1668. var i = argument < 0 ? argument + length : argument;
  1669. for ( ; --i >= 0; ) {
  1670. matchIndexes.push( i );
  1671. }
  1672. return matchIndexes;
  1673. }),
  1674. "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  1675. var i = argument < 0 ? argument + length : argument;
  1676. for ( ; ++i < length; ) {
  1677. matchIndexes.push( i );
  1678. }
  1679. return matchIndexes;
  1680. })
  1681. }
  1682. };
  1683. Expr.pseudos["nth"] = Expr.pseudos["eq"];
  1684. // Add button/input type pseudos
  1685. for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
  1686. Expr.pseudos[ i ] = createInputPseudo( i );
  1687. }
  1688. for ( i in { submit: true, reset: true } ) {
  1689. Expr.pseudos[ i ] = createButtonPseudo( i );
  1690. }
  1691. // Easy API for creating new setFilters
  1692. function setFilters() {}
  1693. setFilters.prototype = Expr.filters = Expr.pseudos;
  1694. Expr.setFilters = new setFilters();
  1695. tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
  1696. var matched, match, tokens, type,
  1697. soFar, groups, preFilters,
  1698. cached = tokenCache[ selector + " " ];
  1699. if ( cached ) {
  1700. return parseOnly ? 0 : cached.slice( 0 );
  1701. }
  1702. soFar = selector;
  1703. groups = [];
  1704. preFilters = Expr.preFilter;
  1705. while ( soFar ) {
  1706. // Comma and first run
  1707. if ( !matched || (match = rcomma.exec( soFar )) ) {
  1708. if ( match ) {
  1709. // Don't consume trailing commas as valid
  1710. soFar = soFar.slice( match[0].length ) || soFar;
  1711. }
  1712. groups.push( (tokens = []) );
  1713. }
  1714. matched = false;
  1715. // Combinators
  1716. if ( (match = rcombinators.exec( soFar )) ) {
  1717. matched = match.shift();
  1718. tokens.push({
  1719. value: matched,
  1720. // Cast descendant combinators to space
  1721. type: match[0].replace( rtrim, " " )
  1722. });
  1723. soFar = soFar.slice( matched.length );
  1724. }
  1725. // Filters
  1726. for ( type in Expr.filter ) {
  1727. if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
  1728. (match = preFilters[ type ]( match ))) ) {
  1729. matched = match.shift();
  1730. tokens.push({
  1731. value: matched,
  1732. type: type,
  1733. matches: match
  1734. });
  1735. soFar = soFar.slice( matched.length );
  1736. }
  1737. }
  1738. if ( !matched ) {
  1739. break;
  1740. }
  1741. }
  1742. // Return the length of the invalid excess
  1743. // if we're just parsing
  1744. // Otherwise, throw an error or return tokens
  1745. return parseOnly ?
  1746. soFar.length :
  1747. soFar ?
  1748. Sizzle.error( selector ) :
  1749. // Cache the tokens
  1750. tokenCache( selector, groups ).slice( 0 );
  1751. };
  1752. function toSelector( tokens ) {
  1753. var i = 0,
  1754. len = tokens.length,
  1755. selector = "";
  1756. for ( ; i < len; i++ ) {
  1757. selector += tokens[i].value;
  1758. }
  1759. return selector;
  1760. }
  1761. function addCombinator( matcher, combinator, base ) {
  1762. var dir = combinator.dir,
  1763. checkNonElements = base && dir === "parentNode",
  1764. doneName = done++;
  1765. return combinator.first ?
  1766. // Check against closest ancestor/preceding element
  1767. function( elem, context, xml ) {
  1768. while ( (elem = elem[ dir ]) ) {
  1769. if ( elem.nodeType === 1 || checkNonElements ) {
  1770. return matcher( elem, context, xml );
  1771. }
  1772. }
  1773. } :
  1774. // Check against all ancestor/preceding elements
  1775. function( elem, context, xml ) {
  1776. var oldCache, outerCache,
  1777. newCache = [ dirruns, doneName ];
  1778. // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
  1779. if ( xml ) {
  1780. while ( (elem = elem[ dir ]) ) {
  1781. if ( elem.nodeType === 1 || checkNonElements ) {
  1782. if ( matcher( elem, context, xml ) ) {
  1783. return true;
  1784. }
  1785. }
  1786. }
  1787. } else {
  1788. while ( (elem = elem[ dir ]) ) {
  1789. if ( elem.nodeType === 1 || checkNonElements ) {
  1790. outerCache = elem[ expando ] || (elem[ expando ] = {});
  1791. if ( (oldCache = outerCache[ dir ]) &&
  1792. oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
  1793. // Assign to newCache so results back-propagate to previous elements
  1794. return (newCache[ 2 ] = oldCache[ 2 ]);
  1795. } else {
  1796. // Reuse newcache so results back-propagate to previous elements
  1797. outerCache[ dir ] = newCache;
  1798. // A match means we're done; a fail means we have to keep checking
  1799. if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
  1800. return true;
  1801. }
  1802. }
  1803. }
  1804. }
  1805. }
  1806. };
  1807. }
  1808. function elementMatcher( matchers ) {
  1809. return matchers.length > 1 ?
  1810. function( elem, context, xml ) {
  1811. var i = matchers.length;
  1812. while ( i-- ) {
  1813. if ( !matchers[i]( elem, context, xml ) ) {
  1814. return false;
  1815. }
  1816. }
  1817. return true;
  1818. } :
  1819. matchers[0];
  1820. }
  1821. function multipleContexts( selector, contexts, results ) {
  1822. var i = 0,
  1823. len = contexts.length;
  1824. for ( ; i < len; i++ ) {
  1825. Sizzle( selector, contexts[i], results );
  1826. }
  1827. return results;
  1828. }
  1829. function condense( unmatched, map, filter, context, xml ) {
  1830. var elem,
  1831. newUnmatched = [],
  1832. i = 0,
  1833. len = unmatched.length,
  1834. mapped = map != null;
  1835. for ( ; i < len; i++ ) {
  1836. if ( (elem = unmatched[i]) ) {
  1837. if ( !filter || filter( elem, context, xml ) ) {
  1838. newUnmatched.push( elem );
  1839. if ( mapped ) {
  1840. map.push( i );
  1841. }
  1842. }
  1843. }
  1844. }
  1845. return newUnmatched;
  1846. }
  1847. function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
  1848. if ( postFilter && !postFilter[ expando ] ) {
  1849. postFilter = setMatcher( postFilter );
  1850. }
  1851. if ( postFinder && !postFinder[ expando ] ) {
  1852. postFinder = setMatcher( postFinder, postSelector );
  1853. }
  1854. return markFunction(function( seed, results, context, xml ) {
  1855. var temp, i, elem,
  1856. preMap = [],
  1857. postMap = [],
  1858. preexisting = results.length,
  1859. // Get initial elements from seed or context
  1860. elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
  1861. // Prefilter to get matcher input, preserving a map for seed-results synchronization
  1862. matcherIn = preFilter && ( seed || !selector ) ?
  1863. condense( elems, preMap, preFilter, context, xml ) :
  1864. elems,
  1865. matcherOut = matcher ?
  1866. // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
  1867. postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
  1868. // ...intermediate processing is necessary
  1869. [] :
  1870. // ...otherwise use results directly
  1871. results :
  1872. matcherIn;
  1873. // Find primary matches
  1874. if ( matcher ) {
  1875. matcher( matcherIn, matcherOut, context, xml );
  1876. }
  1877. // Apply postFilter
  1878. if ( postFilter ) {
  1879. temp = condense( matcherOut, postMap );
  1880. postFilter( temp, [], context, xml );
  1881. // Un-match failing elements by moving them back to matcherIn
  1882. i = temp.length;
  1883. while ( i-- ) {
  1884. if ( (elem = temp[i]) ) {
  1885. matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
  1886. }
  1887. }
  1888. }
  1889. if ( seed ) {
  1890. if ( postFinder || preFilter ) {
  1891. if ( postFinder ) {
  1892. // Get the final matcherOut by condensing this intermediate into postFinder contexts
  1893. temp = [];
  1894. i = matcherOut.length;
  1895. while ( i-- ) {
  1896. if ( (elem = matcherOut[i]) ) {
  1897. // Restore matcherIn since elem is not yet a final match
  1898. temp.push( (matcherIn[i] = elem) );
  1899. }
  1900. }
  1901. postFinder( null, (matcherOut = []), temp, xml );
  1902. }
  1903. // Move matched elements from seed to results to keep them synchronized
  1904. i = matcherOut.length;
  1905. while ( i-- ) {
  1906. if ( (elem = matcherOut[i]) &&
  1907. (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) {
  1908. seed[temp] = !(results[temp] = elem);
  1909. }
  1910. }
  1911. }
  1912. // Add elements to results, through postFinder if defined
  1913. } else {
  1914. matcherOut = condense(
  1915. matcherOut === results ?
  1916. matcherOut.splice( preexisting, matcherOut.length ) :
  1917. matcherOut
  1918. );
  1919. if ( postFinder ) {
  1920. postFinder( null, results, matcherOut, xml );
  1921. } else {
  1922. push.apply( results, matcherOut );
  1923. }
  1924. }
  1925. });
  1926. }
  1927. function matcherFromTokens( tokens ) {
  1928. var checkContext, matcher, j,
  1929. len = tokens.length,
  1930. leadingRelative = Expr.relative[ tokens[0].type ],
  1931. implicitRelative = leadingRelative || Expr.relative[" "],
  1932. i = leadingRelative ? 1 : 0,
  1933. // The foundational matcher ensures that elements are reachable from top-level context(s)
  1934. matchContext = addCombinator( function( elem ) {
  1935. return elem === checkContext;
  1936. }, implicitRelative, true ),
  1937. matchAnyContext = addCombinator( function( elem ) {
  1938. return indexOf.call( checkContext, elem ) > -1;
  1939. }, implicitRelative, true ),
  1940. matchers = [ function( elem, context, xml ) {
  1941. return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
  1942. (checkContext = context).nodeType ?
  1943. matchContext( elem, context, xml ) :
  1944. matchAnyContext( elem, context, xml ) );
  1945. } ];
  1946. for ( ; i < len; i++ ) {
  1947. if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
  1948. matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
  1949. } else {
  1950. matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
  1951. // Return special upon seeing a positional matcher
  1952. if ( matcher[ expando ] ) {
  1953. // Find the next relative operator (if any) for proper handling
  1954. j = ++i;
  1955. for ( ; j < len; j++ ) {
  1956. if ( Expr.relative[ tokens[j].type ] ) {
  1957. break;
  1958. }
  1959. }
  1960. return setMatcher(
  1961. i > 1 && elementMatcher( matchers ),
  1962. i > 1 && toSelector(
  1963. // If the preceding token was a descendant combinator, insert an implicit any-element `*`
  1964. tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
  1965. ).replace( rtrim, "$1" ),
  1966. matcher,
  1967. i < j && matcherFromTokens( tokens.slice( i, j ) ),
  1968. j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
  1969. j < len && toSelector( tokens )
  1970. );
  1971. }
  1972. matchers.push( matcher );
  1973. }
  1974. }
  1975. return elementMatcher( matchers );
  1976. }
  1977. function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
  1978. var bySet = setMatchers.length > 0,
  1979. byElement = elementMatchers.length > 0,
  1980. superMatcher = function( seed, context, xml, results, outermost ) {
  1981. var elem, j, matcher,
  1982. matchedCount = 0,
  1983. i = "0",
  1984. unmatched = seed && [],
  1985. setMatched = [],
  1986. contextBackup = outermostContext,
  1987. // We must always have either seed elements or outermost context
  1988. elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
  1989. // Use integer dirruns iff this is the outermost matcher
  1990. dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
  1991. len = elems.length;
  1992. if ( outermost ) {
  1993. outermostContext = context !== document && context;
  1994. }
  1995. // Add elements passing elementMatchers directly to results
  1996. // Keep `i` a string if there are no elements so `matchedCount` will be "00" below
  1997. // Support: IE<9, Safari
  1998. // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
  1999. for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
  2000. if ( byElement && elem ) {
  2001. j = 0;
  2002. while ( (matcher = elementMatchers[j++]) ) {
  2003. if ( matcher( elem, context, xml ) ) {
  2004. results.push( elem );
  2005. break;
  2006. }
  2007. }
  2008. if ( outermost ) {
  2009. dirruns = dirrunsUnique;
  2010. }
  2011. }
  2012. // Track unmatched elements for set filters
  2013. if ( bySet ) {
  2014. // They will have gone through all possible matchers
  2015. if ( (elem = !matcher && elem) ) {
  2016. matchedCount--;
  2017. }
  2018. // Lengthen the array for every element, matched or not
  2019. if ( seed ) {
  2020. unmatched.push( elem );
  2021. }
  2022. }
  2023. }
  2024. // Apply set filters to unmatched elements
  2025. matchedCount += i;
  2026. if ( bySet && i !== matchedCount ) {
  2027. j = 0;
  2028. while ( (matcher = setMatchers[j++]) ) {
  2029. matcher( unmatched, setMatched, context, xml );
  2030. }
  2031. if ( seed ) {
  2032. // Reintegrate element matches to eliminate the need for sorting
  2033. if ( matchedCount > 0 ) {
  2034. while ( i-- ) {
  2035. if ( !(unmatched[i] || setMatched[i]) ) {
  2036. setMatched[i] = pop.call( results );
  2037. }
  2038. }
  2039. }
  2040. // Discard index placeholder values to get only actual matches
  2041. setMatched = condense( setMatched );
  2042. }
  2043. // Add matches to results
  2044. push.apply( results, setMatched );
  2045. // Seedless set matches succeeding multiple successful matchers stipulate sorting
  2046. if ( outermost && !seed && setMatched.length > 0 &&
  2047. ( matchedCount + setMatchers.length ) > 1 ) {
  2048. Sizzle.uniqueSort( results );
  2049. }
  2050. }
  2051. // Override manipulation of globals by nested matchers
  2052. if ( outermost ) {
  2053. dirruns = dirrunsUnique;
  2054. outermostContext = contextBackup;
  2055. }
  2056. return unmatched;
  2057. };
  2058. return bySet ?
  2059. markFunction( superMatcher ) :
  2060. superMatcher;
  2061. }
  2062. compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
  2063. var i,
  2064. setMatchers = [],
  2065. elementMatchers = [],
  2066. cached = compilerCache[ selector + " " ];
  2067. if ( !cached ) {
  2068. // Generate a function of recursive functions that can be used to check each element
  2069. if ( !match ) {
  2070. match = tokenize( selector );
  2071. }
  2072. i = match.length;
  2073. while ( i-- ) {
  2074. cached = matcherFromTokens( match[i] );
  2075. if ( cached[ expando ] ) {
  2076. setMatchers.push( cached );
  2077. } else {
  2078. elementMatchers.push( cached );
  2079. }
  2080. }
  2081. // Cache the compiled function
  2082. cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
  2083. // Save selector and tokenization
  2084. cached.selector = selector;
  2085. }
  2086. return cached;
  2087. };
  2088. /**
  2089. * A low-level selection function that works with Sizzle's compiled
  2090. * selector functions
  2091. * @param {String|Function} selector A selector or a pre-compiled
  2092. * selector function built with Sizzle.compile
  2093. * @param {Element} context
  2094. * @param {Array} [results]
  2095. * @param {Array} [seed] A set of elements to match against
  2096. */
  2097. select = Sizzle.select = function( selector, context, results, seed ) {
  2098. var i, tokens, token, type, find,
  2099. compiled = typeof selector === "function" && selector,
  2100. match = !seed && tokenize( (selector = compiled.selector || selector) );
  2101. results = results || [];
  2102. // Try to minimize operations if there is no seed and only one group
  2103. if ( match.length === 1 ) {
  2104. // Take a shortcut and set the context if the root selector is an ID
  2105. tokens = match[0] = match[0].slice( 0 );
  2106. if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
  2107. support.getById && context.nodeType === 9 && documentIsHTML &&
  2108. Expr.relative[ tokens[1].type ] ) {
  2109. context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
  2110. if ( !context ) {
  2111. return results;
  2112. // Precompiled matchers will still verify ancestry, so step up a level
  2113. } else if ( compiled ) {
  2114. context = context.parentNode;
  2115. }
  2116. selector = selector.slice( tokens.shift().value.length );
  2117. }
  2118. // Fetch a seed set for right-to-left matching
  2119. i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
  2120. while ( i-- ) {
  2121. token = tokens[i];
  2122. // Abort if we hit a combinator
  2123. if ( Expr.relative[ (type = token.type) ] ) {
  2124. break;
  2125. }
  2126. if ( (find = Expr.find[ type ]) ) {
  2127. // Search, expanding context for leading sibling combinators
  2128. if ( (seed = find(
  2129. token.matches[0].replace( runescape, funescape ),
  2130. rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
  2131. )) ) {
  2132. // If seed is empty or no tokens remain, we can return early
  2133. tokens.splice( i, 1 );
  2134. selector = seed.length && toSelector( tokens );
  2135. if ( !selector ) {
  2136. push.apply( results, seed );
  2137. return results;
  2138. }
  2139. break;
  2140. }
  2141. }
  2142. }
  2143. }
  2144. // Compile and execute a filtering function if one is not provided
  2145. // Provide `match` to avoid retokenization if we modified the selector above
  2146. ( compiled || compile( selector, match ) )(
  2147. seed,
  2148. context,
  2149. !documentIsHTML,
  2150. results,
  2151. rsibling.test( selector ) && testContext( context.parentNode ) || context
  2152. );
  2153. return results;
  2154. };
  2155. // One-time assignments
  2156. // Sort stability
  2157. support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
  2158. // Support: Chrome<14
  2159. // Always assume duplicates if they aren't passed to the comparison function
  2160. support.detectDuplicates = !!hasDuplicate;
  2161. // Initialize against the default document
  2162. setDocument();
  2163. // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
  2164. // Detached nodes confoundingly follow *each other*
  2165. support.sortDetached = assert(function( div1 ) {
  2166. // Should return 1, but returns 4 (following)
  2167. return div1.compareDocumentPosition( document.createElement("div") ) & 1;
  2168. });
  2169. // Support: IE<8
  2170. // Prevent attribute/property "interpolation"
  2171. // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  2172. if ( !assert(function( div ) {
  2173. div.innerHTML = "<a href='#'></a>";
  2174. return div.firstChild.getAttribute("href") === "#" ;
  2175. }) ) {
  2176. addHandle( "type|href|height|width", function( elem, name, isXML ) {
  2177. if ( !isXML ) {
  2178. return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
  2179. }
  2180. });
  2181. }
  2182. // Support: IE<9
  2183. // Use defaultValue in place of getAttribute("value")
  2184. if ( !support.attributes || !assert(function( div ) {
  2185. div.innerHTML = "<input/>";
  2186. div.firstChild.setAttribute( "value", "" );
  2187. return div.firstChild.getAttribute( "value" ) === "";
  2188. }) ) {
  2189. addHandle( "value", function( elem, name, isXML ) {
  2190. if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
  2191. return elem.defaultValue;
  2192. }
  2193. });
  2194. }
  2195. // Support: IE<9
  2196. // Use getAttributeNode to fetch booleans when getAttribute lies
  2197. if ( !assert(function( div ) {
  2198. return div.getAttribute("disabled") == null;
  2199. }) ) {
  2200. addHandle( booleans, function( elem, name, isXML ) {
  2201. var val;
  2202. if ( !isXML ) {
  2203. return elem[ name ] === true ? name.toLowerCase() :
  2204. (val = elem.getAttributeNode( name )) && val.specified ?
  2205. val.value :
  2206. null;
  2207. }
  2208. });
  2209. }
  2210. return Sizzle;
  2211. })( window );
  2212. jQuery.find = Sizzle;
  2213. jQuery.expr = Sizzle.selectors;
  2214. jQuery.expr[":"] = jQuery.expr.pseudos;
  2215. jQuery.unique = Sizzle.uniqueSort;
  2216. jQuery.text = Sizzle.getText;
  2217. jQuery.isXMLDoc = Sizzle.isXML;
  2218. jQuery.contains = Sizzle.contains;
  2219. var rneedsContext = jQuery.expr.match.needsContext;
  2220. var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/);
  2221. var risSimple = /^.[^:#\[\.,]*$/;
  2222. // Implement the identical functionality for filter and not
  2223. function winnow( elements, qualifier, not ) {
  2224. if ( jQuery.isFunction( qualifier ) ) {
  2225. return jQuery.grep( elements, function( elem, i ) {
  2226. /* jshint -W018 */
  2227. return !!qualifier.call( elem, i, elem ) !== not;
  2228. });
  2229. }
  2230. if ( qualifier.nodeType ) {
  2231. return jQuery.grep( elements, function( elem ) {
  2232. return ( elem === qualifier ) !== not;
  2233. });
  2234. }
  2235. if ( typeof qualifier === "string" ) {
  2236. if ( risSimple.test( qualifier ) ) {
  2237. return jQuery.filter( qualifier, elements, not );
  2238. }
  2239. qualifier = jQuery.filter( qualifier, elements );
  2240. }
  2241. return jQuery.grep( elements, function( elem ) {
  2242. return ( jQuery.inArray( elem, qualifier ) >= 0 ) !== not;
  2243. });
  2244. }
  2245. jQuery.filter = function( expr, elems, not ) {
  2246. var elem = elems[ 0 ];
  2247. if ( not ) {
  2248. expr = ":not(" + expr + ")";
  2249. }
  2250. return elems.length === 1 && elem.nodeType === 1 ?
  2251. jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
  2252. jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
  2253. return elem.nodeType === 1;
  2254. }));
  2255. };
  2256. jQuery.fn.extend({
  2257. find: function( selector ) {
  2258. var i,
  2259. ret = [],
  2260. self = this,
  2261. len = self.length;
  2262. if ( typeof selector !== "string" ) {
  2263. return this.pushStack( jQuery( selector ).filter(function() {
  2264. for ( i = 0; i < len; i++ ) {
  2265. if ( jQuery.contains( self[ i ], this ) ) {
  2266. return true;
  2267. }
  2268. }
  2269. }) );
  2270. }
  2271. for ( i = 0; i < len; i++ ) {
  2272. jQuery.find( selector, self[ i ], ret );
  2273. }
  2274. // Needed because $( selector, context ) becomes $( context ).find( selector )
  2275. ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
  2276. ret.selector = this.selector ? this.selector + " " + selector : selector;
  2277. return ret;
  2278. },
  2279. filter: function( selector ) {
  2280. return this.pushStack( winnow(this, selector || [], false) );
  2281. },
  2282. not: function( selector ) {
  2283. return this.pushStack( winnow(this, selector || [], true) );
  2284. },
  2285. is: function( selector ) {
  2286. return !!winnow(
  2287. this,
  2288. // If this is a positional/relative selector, check membership in the returned set
  2289. // so $("p:first").is("p:last") won't return true for a doc with two "p".
  2290. typeof selector === "string" && rneedsContext.test( selector ) ?
  2291. jQuery( selector ) :
  2292. selector || [],
  2293. false
  2294. ).length;
  2295. }
  2296. });
  2297. // Initialize a jQuery object
  2298. // A central reference to the root jQuery(document)
  2299. var rootjQuery,
  2300. // Use the correct document accordingly with window argument (sandbox)
  2301. document = window.document,
  2302. // A simple way to check for HTML strings
  2303. // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
  2304. // Strict HTML recognition (#11290: must start with <)
  2305. rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
  2306. init = jQuery.fn.init = function( selector, context ) {
  2307. var match, elem;
  2308. // HANDLE: $(""), $(null), $(undefined), $(false)
  2309. if ( !selector ) {
  2310. return this;
  2311. }
  2312. // Handle HTML strings
  2313. if ( typeof selector === "string" ) {
  2314. if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
  2315. // Assume that strings that start and end with <> are HTML and skip the regex check
  2316. match = [ null, selector, null ];
  2317. } else {
  2318. match = rquickExpr.exec( selector );
  2319. }
  2320. // Match html or make sure no context is specified for #id
  2321. if ( match && (match[1] || !context) ) {
  2322. // HANDLE: $(html) -> $(array)
  2323. if ( match[1] ) {
  2324. context = context instanceof jQuery ? context[0] : context;
  2325. // scripts is true for back-compat
  2326. // Intentionally let the error be thrown if parseHTML is not present
  2327. jQuery.merge( this, jQuery.parseHTML(
  2328. match[1],
  2329. context && context.nodeType ? context.ownerDocument || context : document,
  2330. true
  2331. ) );
  2332. // HANDLE: $(html, props)
  2333. if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
  2334. for ( match in context ) {
  2335. // Properties of context are called as methods if possible
  2336. if ( jQuery.isFunction( this[ match ] ) ) {
  2337. this[ match ]( context[ match ] );
  2338. // ...and otherwise set as attributes
  2339. } else {
  2340. this.attr( match, context[ match ] );
  2341. }
  2342. }
  2343. }
  2344. return this;
  2345. // HANDLE: $(#id)
  2346. } else {
  2347. elem = document.getElementById( match[2] );
  2348. // Check parentNode to catch when Blackberry 4.6 returns
  2349. // nodes that are no longer in the document #6963
  2350. if ( elem && elem.parentNode ) {
  2351. // Handle the case where IE and Opera return items
  2352. // by name instead of ID
  2353. if ( elem.id !== match[2] ) {
  2354. return rootjQuery.find( selector );
  2355. }
  2356. // Otherwise, we inject the element directly into the jQuery object
  2357. this.length = 1;
  2358. this[0] = elem;
  2359. }
  2360. this.context = document;
  2361. this.selector = selector;
  2362. return this;
  2363. }
  2364. // HANDLE: $(expr, $(...))
  2365. } else if ( !context || context.jquery ) {
  2366. return ( context || rootjQuery ).find( selector );
  2367. // HANDLE: $(expr, context)
  2368. // (which is just equivalent to: $(context).find(expr)
  2369. } else {
  2370. return this.constructor( context ).find( selector );
  2371. }
  2372. // HANDLE: $(DOMElement)
  2373. } else if ( selector.nodeType ) {
  2374. this.context = this[0] = selector;
  2375. this.length = 1;
  2376. return this;
  2377. // HANDLE: $(function)
  2378. // Shortcut for document ready
  2379. } else if ( jQuery.isFunction( selector ) ) {
  2380. return typeof rootjQuery.ready !== "undefined" ?
  2381. rootjQuery.ready( selector ) :
  2382. // Execute immediately if ready is not present
  2383. selector( jQuery );
  2384. }
  2385. if ( selector.selector !== undefined ) {
  2386. this.selector = selector.selector;
  2387. this.context = selector.context;
  2388. }
  2389. return jQuery.makeArray( selector, this );
  2390. };
  2391. // Give the init function the jQuery prototype for later instantiation
  2392. init.prototype = jQuery.fn;
  2393. // Initialize central reference
  2394. rootjQuery = jQuery( document );
  2395. var rparentsprev = /^(?:parents|prev(?:Until|All))/,
  2396. // methods guaranteed to produce a unique set when starting from a unique set
  2397. guaranteedUnique = {
  2398. children: true,
  2399. contents: true,
  2400. next: true,
  2401. prev: true
  2402. };
  2403. jQuery.extend({
  2404. dir: function( elem, dir, until ) {
  2405. var matched = [],
  2406. cur = elem[ dir ];
  2407. while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
  2408. if ( cur.nodeType === 1 ) {
  2409. matched.push( cur );
  2410. }
  2411. cur = cur[dir];
  2412. }
  2413. return matched;
  2414. },
  2415. sibling: function( n, elem ) {
  2416. var r = [];
  2417. for ( ; n; n = n.nextSibling ) {
  2418. if ( n.nodeType === 1 && n !== elem ) {
  2419. r.push( n );
  2420. }
  2421. }
  2422. return r;
  2423. }
  2424. });
  2425. jQuery.fn.extend({
  2426. has: function( target ) {
  2427. var i,
  2428. targets = jQuery( target, this ),
  2429. len = targets.length;
  2430. return this.filter(function() {
  2431. for ( i = 0; i < len; i++ ) {
  2432. if ( jQuery.contains( this, targets[i] ) ) {
  2433. return true;
  2434. }
  2435. }
  2436. });
  2437. },
  2438. closest: function( selectors, context ) {
  2439. var cur,
  2440. i = 0,
  2441. l = this.length,
  2442. matched = [],
  2443. pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
  2444. jQuery( selectors, context || this.context ) :
  2445. 0;
  2446. for ( ; i < l; i++ ) {
  2447. for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) {
  2448. // Always skip document fragments
  2449. if ( cur.nodeType < 11 && (pos ?
  2450. pos.index(cur) > -1 :
  2451. // Don't pass non-elements to Sizzle
  2452. cur.nodeType === 1 &&
  2453. jQuery.find.matchesSelector(cur, selectors)) ) {
  2454. matched.push( cur );
  2455. break;
  2456. }
  2457. }
  2458. }
  2459. return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched );
  2460. },
  2461. // Determine the position of an element within
  2462. // the matched set of elements
  2463. index: function( elem ) {
  2464. // No argument, return index in parent
  2465. if ( !elem ) {
  2466. return ( this[0] && this[0].parentNode ) ? this.first().prevAll().length : -1;
  2467. }
  2468. // index in selector
  2469. if ( typeof elem === "string" ) {
  2470. return jQuery.inArray( this[0], jQuery( elem ) );
  2471. }
  2472. // Locate the position of the desired element
  2473. return jQuery.inArray(
  2474. // If it receives a jQuery object, the first element is used
  2475. elem.jquery ? elem[0] : elem, this );
  2476. },
  2477. add: function( selector, context ) {
  2478. return this.pushStack(
  2479. jQuery.unique(
  2480. jQuery.merge( this.get(), jQuery( selector, context ) )
  2481. )
  2482. );
  2483. },
  2484. addBack: function( selector ) {
  2485. return this.add( selector == null ?
  2486. this.prevObject : this.prevObject.filter(selector)
  2487. );
  2488. }
  2489. });
  2490. function sibling( cur, dir ) {
  2491. do {
  2492. cur = cur[ dir ];
  2493. } while ( cur && cur.nodeType !== 1 );
  2494. return cur;
  2495. }
  2496. jQuery.each({
  2497. parent: function( elem ) {
  2498. var parent = elem.parentNode;
  2499. return parent && parent.nodeType !== 11 ? parent : null;
  2500. },
  2501. parents: function( elem ) {
  2502. return jQuery.dir( elem, "parentNode" );
  2503. },
  2504. parentsUntil: function( elem, i, until ) {
  2505. return jQuery.dir( elem, "parentNode", until );
  2506. },
  2507. next: function( elem ) {
  2508. return sibling( elem, "nextSibling" );
  2509. },
  2510. prev: function( elem ) {
  2511. return sibling( elem, "previousSibling" );
  2512. },
  2513. nextAll: function( elem ) {
  2514. return jQuery.dir( elem, "nextSibling" );
  2515. },
  2516. prevAll: function( elem ) {
  2517. return jQuery.dir( elem, "previousSibling" );
  2518. },
  2519. nextUntil: function( elem, i, until ) {
  2520. return jQuery.dir( elem, "nextSibling", until );
  2521. },
  2522. prevUntil: function( elem, i, until ) {
  2523. return jQuery.dir( elem, "previousSibling", until );
  2524. },
  2525. siblings: function( elem ) {
  2526. return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
  2527. },
  2528. children: function( elem ) {
  2529. return jQuery.sibling( elem.firstChild );
  2530. },
  2531. contents: function( elem ) {
  2532. return jQuery.nodeName( elem, "iframe" ) ?
  2533. elem.contentDocument || elem.contentWindow.document :
  2534. jQuery.merge( [], elem.childNodes );
  2535. }
  2536. }, function( name, fn ) {
  2537. jQuery.fn[ name ] = function( until, selector ) {
  2538. var ret = jQuery.map( this, fn, until );
  2539. if ( name.slice( -5 ) !== "Until" ) {
  2540. selector = until;
  2541. }
  2542. if ( selector && typeof selector === "string" ) {
  2543. ret = jQuery.filter( selector, ret );
  2544. }
  2545. if ( this.length > 1 ) {
  2546. // Remove duplicates
  2547. if ( !guaranteedUnique[ name ] ) {
  2548. ret = jQuery.unique( ret );
  2549. }
  2550. // Reverse order for parents* and prev-derivatives
  2551. if ( rparentsprev.test( name ) ) {
  2552. ret = ret.reverse();
  2553. }
  2554. }
  2555. return this.pushStack( ret );
  2556. };
  2557. });
  2558. var rnotwhite = (/\S+/g);
  2559. // String to Object options format cache
  2560. var optionsCache = {};
  2561. // Convert String-formatted options into Object-formatted ones and store in cache
  2562. function createOptions( options ) {
  2563. var object = optionsCache[ options ] = {};
  2564. jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {
  2565. object[ flag ] = true;
  2566. });
  2567. return object;
  2568. }
  2569. /*
  2570. * Create a callback list using the following parameters:
  2571. *
  2572. * options: an optional list of space-separated options that will change how
  2573. * the callback list behaves or a more traditional option object
  2574. *
  2575. * By default a callback list will act like an event callback list and can be
  2576. * "fired" multiple times.
  2577. *
  2578. * Possible options:
  2579. *
  2580. * once: will ensure the callback list can only be fired once (like a Deferred)
  2581. *
  2582. * memory: will keep track of previous values and will call any callback added
  2583. * after the list has been fired right away with the latest "memorized"
  2584. * values (like a Deferred)
  2585. *
  2586. * unique: will ensure a callback can only be added once (no duplicate in the list)
  2587. *
  2588. * stopOnFalse: interrupt callings when a callback returns false
  2589. *
  2590. */
  2591. jQuery.Callbacks = function( options ) {
  2592. // Convert options from String-formatted to Object-formatted if needed
  2593. // (we check in cache first)
  2594. options = typeof options === "string" ?
  2595. ( optionsCache[ options ] || createOptions( options ) ) :
  2596. jQuery.extend( {}, options );
  2597. var // Flag to know if list is currently firing
  2598. firing,
  2599. // Last fire value (for non-forgettable lists)
  2600. memory,
  2601. // Flag to know if list was already fired
  2602. fired,
  2603. // End of the loop when firing
  2604. firingLength,
  2605. // Index of currently firing callback (modified by remove if needed)
  2606. firingIndex,
  2607. // First callback to fire (used internally by add and fireWith)
  2608. firingStart,
  2609. // Actual callback list
  2610. list = [],
  2611. // Stack of fire calls for repeatable lists
  2612. stack = !options.once && [],
  2613. // Fire callbacks
  2614. fire = function( data ) {
  2615. memory = options.memory && data;
  2616. fired = true;
  2617. firingIndex = firingStart || 0;
  2618. firingStart = 0;
  2619. firingLength = list.length;
  2620. firing = true;
  2621. for ( ; list && firingIndex < firingLength; firingIndex++ ) {
  2622. if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
  2623. memory = false; // To prevent further calls using add
  2624. break;
  2625. }
  2626. }
  2627. firing = false;
  2628. if ( list ) {
  2629. if ( stack ) {
  2630. if ( stack.length ) {
  2631. fire( stack.shift() );
  2632. }
  2633. } else if ( memory ) {
  2634. list = [];
  2635. } else {
  2636. self.disable();
  2637. }
  2638. }
  2639. },
  2640. // Actual Callbacks object
  2641. self = {
  2642. // Add a callback or a collection of callbacks to the list
  2643. add: function() {
  2644. if ( list ) {
  2645. // First, we save the current length
  2646. var start = list.length;
  2647. (function add( args ) {
  2648. jQuery.each( args, function( _, arg ) {
  2649. var type = jQuery.type( arg );
  2650. if ( type === "function" ) {
  2651. if ( !options.unique || !self.has( arg ) ) {
  2652. list.push( arg );
  2653. }
  2654. } else if ( arg && arg.length && type !== "string" ) {
  2655. // Inspect recursively
  2656. add( arg );
  2657. }
  2658. });
  2659. })( arguments );
  2660. // Do we need to add the callbacks to the
  2661. // current firing batch?
  2662. if ( firing ) {
  2663. firingLength = list.length;
  2664. // With memory, if we're not firing then
  2665. // we should call right away
  2666. } else if ( memory ) {
  2667. firingStart = start;
  2668. fire( memory );
  2669. }
  2670. }
  2671. return this;
  2672. },
  2673. // Remove a callback from the list
  2674. remove: function() {
  2675. if ( list ) {
  2676. jQuery.each( arguments, function( _, arg ) {
  2677. var index;
  2678. while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
  2679. list.splice( index, 1 );
  2680. // Handle firing indexes
  2681. if ( firing ) {
  2682. if ( index <= firingLength ) {
  2683. firingLength--;
  2684. }
  2685. if ( index <= firingIndex ) {
  2686. firingIndex--;
  2687. }
  2688. }
  2689. }
  2690. });
  2691. }
  2692. return this;
  2693. },
  2694. // Check if a given callback is in the list.
  2695. // If no argument is given, return whether or not list has callbacks attached.
  2696. has: function( fn ) {
  2697. return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length );
  2698. },
  2699. // Remove all callbacks from the list
  2700. empty: function() {
  2701. list = [];
  2702. firingLength = 0;
  2703. return this;
  2704. },
  2705. // Have the list do nothing anymore
  2706. disable: function() {
  2707. list = stack = memory = undefined;
  2708. return this;
  2709. },
  2710. // Is it disabled?
  2711. disabled: function() {
  2712. return !list;
  2713. },
  2714. // Lock the list in its current state
  2715. lock: function() {
  2716. stack = undefined;
  2717. if ( !memory ) {
  2718. self.disable();
  2719. }
  2720. return this;
  2721. },
  2722. // Is it locked?
  2723. locked: function() {
  2724. return !stack;
  2725. },
  2726. // Call all callbacks with the given context and arguments
  2727. fireWith: function( context, args ) {
  2728. if ( list && ( !fired || stack ) ) {
  2729. args = args || [];
  2730. args = [ context, args.slice ? args.slice() : args ];
  2731. if ( firing ) {
  2732. stack.push( args );
  2733. } else {
  2734. fire( args );
  2735. }
  2736. }
  2737. return this;
  2738. },
  2739. // Call all the callbacks with the given arguments
  2740. fire: function() {
  2741. self.fireWith( this, arguments );
  2742. return this;
  2743. },
  2744. // To know if the callbacks have already been called at least once
  2745. fired: function() {
  2746. return !!fired;
  2747. }
  2748. };
  2749. return self;
  2750. };
  2751. jQuery.extend({
  2752. Deferred: function( func ) {
  2753. var tuples = [
  2754. // action, add listener, listener list, final state
  2755. [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
  2756. [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
  2757. [ "notify", "progress", jQuery.Callbacks("memory") ]
  2758. ],
  2759. state = "pending",
  2760. promise = {
  2761. state: function() {
  2762. return state;
  2763. },
  2764. always: function() {
  2765. deferred.done( arguments ).fail( arguments );
  2766. return this;
  2767. },
  2768. then: function( /* fnDone, fnFail, fnProgress */ ) {
  2769. var fns = arguments;
  2770. return jQuery.Deferred(function( newDefer ) {
  2771. jQuery.each( tuples, function( i, tuple ) {
  2772. var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
  2773. // deferred[ done | fail | progress ] for forwarding actions to newDefer
  2774. deferred[ tuple[1] ](function() {
  2775. var returned = fn && fn.apply( this, arguments );
  2776. if ( returned && jQuery.isFunction( returned.promise ) ) {
  2777. returned.promise()
  2778. .done( newDefer.resolve )
  2779. .fail( newDefer.reject )
  2780. .progress( newDefer.notify );
  2781. } else {
  2782. newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
  2783. }
  2784. });
  2785. });
  2786. fns = null;
  2787. }).promise();
  2788. },
  2789. // Get a promise for this deferred
  2790. // If obj is provided, the promise aspect is added to the object
  2791. promise: function( obj ) {
  2792. return obj != null ? jQuery.extend( obj, promise ) : promise;
  2793. }
  2794. },
  2795. deferred = {};
  2796. // Keep pipe for back-compat
  2797. promise.pipe = promise.then;
  2798. // Add list-specific methods
  2799. jQuery.each( tuples, function( i, tuple ) {
  2800. var list = tuple[ 2 ],
  2801. stateString = tuple[ 3 ];
  2802. // promise[ done | fail | progress ] = list.add
  2803. promise[ tuple[1] ] = list.add;
  2804. // Handle state
  2805. if ( stateString ) {
  2806. list.add(function() {
  2807. // state = [ resolved | rejected ]
  2808. state = stateString;
  2809. // [ reject_list | resolve_list ].disable; progress_list.lock
  2810. }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
  2811. }
  2812. // deferred[ resolve | reject | notify ]
  2813. deferred[ tuple[0] ] = function() {
  2814. deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments );
  2815. return this;
  2816. };
  2817. deferred[ tuple[0] + "With" ] = list.fireWith;
  2818. });
  2819. // Make the deferred a promise
  2820. promise.promise( deferred );
  2821. // Call given func if any
  2822. if ( func ) {
  2823. func.call( deferred, deferred );
  2824. }
  2825. // All done!
  2826. return deferred;
  2827. },
  2828. // Deferred helper
  2829. when: function( subordinate /* , ..., subordinateN */ ) {
  2830. var i = 0,
  2831. resolveValues = slice.call( arguments ),
  2832. length = resolveValues.length,
  2833. // the count of uncompleted subordinates
  2834. remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
  2835. // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
  2836. deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
  2837. // Update function for both resolve and progress values
  2838. updateFunc = function( i, contexts, values ) {
  2839. return function( value ) {
  2840. contexts[ i ] = this;
  2841. values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
  2842. if ( values === progressValues ) {
  2843. deferred.notifyWith( contexts, values );
  2844. } else if ( !(--remaining) ) {
  2845. deferred.resolveWith( contexts, values );
  2846. }
  2847. };
  2848. },
  2849. progressValues, progressContexts, resolveContexts;
  2850. // add listeners to Deferred subordinates; treat others as resolved
  2851. if ( length > 1 ) {
  2852. progressValues = new Array( length );
  2853. progressContexts = new Array( length );
  2854. resolveContexts = new Array( length );
  2855. for ( ; i < length; i++ ) {
  2856. if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
  2857. resolveValues[ i ].promise()
  2858. .done( updateFunc( i, resolveContexts, resolveValues ) )
  2859. .fail( deferred.reject )
  2860. .progress( updateFunc( i, progressContexts, progressValues ) );
  2861. } else {
  2862. --remaining;
  2863. }
  2864. }
  2865. }
  2866. // if we're not waiting on anything, resolve the master
  2867. if ( !remaining ) {
  2868. deferred.resolveWith( resolveContexts, resolveValues );
  2869. }
  2870. return deferred.promise();
  2871. }
  2872. });
  2873. // The deferred used on DOM ready
  2874. var readyList;
  2875. jQuery.fn.ready = function( fn ) {
  2876. // Add the callback
  2877. jQuery.ready.promise().done( fn );
  2878. return this;
  2879. };
  2880. jQuery.extend({
  2881. // Is the DOM ready to be used? Set to true once it occurs.
  2882. isReady: false,
  2883. // A counter to track how many items to wait for before
  2884. // the ready event fires. See #6781
  2885. readyWait: 1,
  2886. // Hold (or release) the ready event
  2887. holdReady: function( hold ) {
  2888. if ( hold ) {
  2889. jQuery.readyWait++;
  2890. } else {
  2891. jQuery.ready( true );
  2892. }
  2893. },
  2894. // Handle when the DOM is ready
  2895. ready: function( wait ) {
  2896. // Abort if there are pending holds or we're already ready
  2897. if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
  2898. return;
  2899. }
  2900. // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
  2901. if ( !document.body ) {
  2902. return setTimeout( jQuery.ready );
  2903. }
  2904. // Remember that the DOM is ready
  2905. jQuery.isReady = true;
  2906. // If a normal DOM Ready event fired, decrement, and wait if need be
  2907. if ( wait !== true && --jQuery.readyWait > 0 ) {
  2908. return;
  2909. }
  2910. // If there are functions bound, to execute
  2911. readyList.resolveWith( document, [ jQuery ] );
  2912. // Trigger any bound ready events
  2913. if ( jQuery.fn.triggerHandler ) {
  2914. jQuery( document ).triggerHandler( "ready" );
  2915. jQuery( document ).off( "ready" );
  2916. }
  2917. }
  2918. });
  2919. /**
  2920. * Clean-up method for dom ready events
  2921. */
  2922. function detach() {
  2923. if ( document.addEventListener ) {
  2924. document.removeEventListener( "DOMContentLoaded", completed, false );
  2925. window.removeEventListener( "load", completed, false );
  2926. } else {
  2927. document.detachEvent( "onreadystatechange", completed );
  2928. window.detachEvent( "onload", completed );
  2929. }
  2930. }
  2931. /**
  2932. * The ready event handler and self cleanup method
  2933. */
  2934. function completed() {
  2935. // readyState === "complete" is good enough for us to call the dom ready in oldIE
  2936. if ( document.addEventListener || event.type === "load" || document.readyState === "complete" ) {
  2937. detach();
  2938. jQuery.ready();
  2939. }
  2940. }
  2941. jQuery.ready.promise = function( obj ) {
  2942. if ( !readyList ) {
  2943. readyList = jQuery.Deferred();
  2944. // Catch cases where $(document).ready() is called after the browser event has already occurred.
  2945. // we once tried to use readyState "interactive" here, but it caused issues like the one
  2946. // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
  2947. if ( document.readyState === "complete" ) {
  2948. // Handle it asynchronously to allow scripts the opportunity to delay ready
  2949. setTimeout( jQuery.ready );
  2950. // Standards-based browsers support DOMContentLoaded
  2951. } else if ( document.addEventListener ) {
  2952. // Use the handy event callback
  2953. document.addEventListener( "DOMContentLoaded", completed, false );
  2954. // A fallback to window.onload, that will always work
  2955. window.addEventListener( "load", completed, false );
  2956. // If IE event model is used
  2957. } else {
  2958. // Ensure firing before onload, maybe late but safe also for iframes
  2959. document.attachEvent( "onreadystatechange", completed );
  2960. // A fallback to window.onload, that will always work
  2961. window.attachEvent( "onload", completed );
  2962. // If IE and not a frame
  2963. // continually check to see if the document is ready
  2964. var top = false;
  2965. try {
  2966. top = window.frameElement == null && document.documentElement;
  2967. } catch(e) {}
  2968. if ( top && top.doScroll ) {
  2969. (function doScrollCheck() {
  2970. if ( !jQuery.isReady ) {
  2971. try {
  2972. // Use the trick by Diego Perini
  2973. // http://javascript.nwbox.com/IEContentLoaded/
  2974. top.doScroll("left");
  2975. } catch(e) {
  2976. return setTimeout( doScrollCheck, 50 );
  2977. }
  2978. // detach all dom ready events
  2979. detach();
  2980. // and execute any waiting functions
  2981. jQuery.ready();
  2982. }
  2983. })();
  2984. }
  2985. }
  2986. }
  2987. return readyList.promise( obj );
  2988. };
  2989. var strundefined = typeof undefined;
  2990. // Support: IE<9
  2991. // Iteration over object's inherited properties before its own
  2992. var i;
  2993. for ( i in jQuery( support ) ) {
  2994. break;
  2995. }
  2996. support.ownLast = i !== "0";
  2997. // Note: most support tests are defined in their respective modules.
  2998. // false until the test is run
  2999. support.inlineBlockNeedsLayout = false;
  3000. // Execute ASAP in case we need to set body.style.zoom
  3001. jQuery(function() {
  3002. // Minified: var a,b,c,d
  3003. var val, div, body, container;
  3004. body = document.getElementsByTagName( "body" )[ 0 ];
  3005. if ( !body || !body.style ) {
  3006. // Return for frameset docs that don't have a body
  3007. return;
  3008. }
  3009. // Setup
  3010. div = document.createElement( "div" );
  3011. container = document.createElement( "div" );
  3012. container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
  3013. body.appendChild( container ).appendChild( div );
  3014. if ( typeof div.style.zoom !== strundefined ) {
  3015. // Support: IE<8
  3016. // Check if natively block-level elements act like inline-block
  3017. // elements when setting their display to 'inline' and giving
  3018. // them layout
  3019. div.style.cssText = "display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1";
  3020. support.inlineBlockNeedsLayout = val = div.offsetWidth === 3;
  3021. if ( val ) {
  3022. // Prevent IE 6 from affecting layout for positioned elements #11048
  3023. // Prevent IE from shrinking the body in IE 7 mode #12869
  3024. // Support: IE<8
  3025. body.style.zoom = 1;
  3026. }
  3027. }
  3028. body.removeChild( container );
  3029. });
  3030. (function() {
  3031. var div = document.createElement( "div" );
  3032. // Execute the test only if not already executed in another module.
  3033. if (support.deleteExpando == null) {
  3034. // Support: IE<9
  3035. support.deleteExpando = true;
  3036. try {
  3037. delete div.test;
  3038. } catch( e ) {
  3039. support.deleteExpando = false;
  3040. }
  3041. }
  3042. // Null elements to avoid leaks in IE.
  3043. div = null;
  3044. })();
  3045. /**
  3046. * Determines whether an object can have data
  3047. */
  3048. jQuery.acceptData = function( elem ) {
  3049. var noData = jQuery.noData[ (elem.nodeName + " ").toLowerCase() ],
  3050. nodeType = +elem.nodeType || 1;
  3051. // Do not set data on non-element DOM nodes because it will not be cleared (#8335).
  3052. return nodeType !== 1 && nodeType !== 9 ?
  3053. false :
  3054. // Nodes accept data unless otherwise specified; rejection can be conditional
  3055. !noData || noData !== true && elem.getAttribute("classid") === noData;
  3056. };
  3057. var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
  3058. rmultiDash = /([A-Z])/g;
  3059. function dataAttr( elem, key, data ) {
  3060. // If nothing was found internally, try to fetch any
  3061. // data from the HTML5 data-* attribute
  3062. if ( data === undefined && elem.nodeType === 1 ) {
  3063. var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
  3064. data = elem.getAttribute( name );
  3065. if ( typeof data === "string" ) {
  3066. try {
  3067. data = data === "true" ? true :
  3068. data === "false" ? false :
  3069. data === "null" ? null :
  3070. // Only convert to a number if it doesn't change the string
  3071. +data + "" === data ? +data :
  3072. rbrace.test( data ) ? jQuery.parseJSON( data ) :
  3073. data;
  3074. } catch( e ) {}
  3075. // Make sure we set the data so it isn't changed later
  3076. jQuery.data( elem, key, data );
  3077. } else {
  3078. data = undefined;
  3079. }
  3080. }
  3081. return data;
  3082. }
  3083. // checks a cache object for emptiness
  3084. function isEmptyDataObject( obj ) {
  3085. var name;
  3086. for ( name in obj ) {
  3087. // if the public data object is empty, the private is still empty
  3088. if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
  3089. continue;
  3090. }
  3091. if ( name !== "toJSON" ) {
  3092. return false;
  3093. }
  3094. }
  3095. return true;
  3096. }
  3097. function internalData( elem, name, data, pvt /* Internal Use Only */ ) {
  3098. if ( !jQuery.acceptData( elem ) ) {
  3099. return;
  3100. }
  3101. var ret, thisCache,
  3102. internalKey = jQuery.expando,
  3103. // We have to handle DOM nodes and JS objects differently because IE6-7
  3104. // can't GC object references properly across the DOM-JS boundary
  3105. isNode = elem.nodeType,
  3106. // Only DOM nodes need the global jQuery cache; JS object data is
  3107. // attached directly to the object so GC can occur automatically
  3108. cache = isNode ? jQuery.cache : elem,
  3109. // Only defining an ID for JS objects if its cache already exists allows
  3110. // the code to shortcut on the same path as a DOM node with no cache
  3111. id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey;
  3112. // Avoid doing any more work than we need to when trying to get data on an
  3113. // object that has no data at all
  3114. if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && data === undefined && typeof name === "string" ) {
  3115. return;
  3116. }
  3117. if ( !id ) {
  3118. // Only DOM nodes need a new unique ID for each element since their data
  3119. // ends up in the global cache
  3120. if ( isNode ) {
  3121. id = elem[ internalKey ] = deletedIds.pop() || jQuery.guid++;
  3122. } else {
  3123. id = internalKey;
  3124. }
  3125. }
  3126. if ( !cache[ id ] ) {
  3127. // Avoid exposing jQuery metadata on plain JS objects when the object
  3128. // is serialized using JSON.stringify
  3129. cache[ id ] = isNode ? {} : { toJSON: jQuery.noop };
  3130. }
  3131. // An object can be passed to jQuery.data instead of a key/value pair; this gets
  3132. // shallow copied over onto the existing cache
  3133. if ( typeof name === "object" || typeof name === "function" ) {
  3134. if ( pvt ) {
  3135. cache[ id ] = jQuery.extend( cache[ id ], name );
  3136. } else {
  3137. cache[ id ].data = jQuery.extend( cache[ id ].data, name );
  3138. }
  3139. }
  3140. thisCache = cache[ id ];
  3141. // jQuery data() is stored in a separate object inside the object's internal data
  3142. // cache in order to avoid key collisions between internal data and user-defined
  3143. // data.
  3144. if ( !pvt ) {
  3145. if ( !thisCache.data ) {
  3146. thisCache.data = {};
  3147. }
  3148. thisCache = thisCache.data;
  3149. }
  3150. if ( data !== undefined ) {
  3151. thisCache[ jQuery.camelCase( name ) ] = data;
  3152. }
  3153. // Check for both converted-to-camel and non-converted data property names
  3154. // If a data property was specified
  3155. if ( typeof name === "string" ) {
  3156. // First Try to find as-is property data
  3157. ret = thisCache[ name ];
  3158. // Test for null|undefined property data
  3159. if ( ret == null ) {
  3160. // Try to find the camelCased property
  3161. ret = thisCache[ jQuery.camelCase( name ) ];
  3162. }
  3163. } else {
  3164. ret = thisCache;
  3165. }
  3166. return ret;
  3167. }
  3168. function internalRemoveData( elem, name, pvt ) {
  3169. if ( !jQuery.acceptData( elem ) ) {
  3170. return;
  3171. }
  3172. var thisCache, i,
  3173. isNode = elem.nodeType,
  3174. // See jQuery.data for more information
  3175. cache = isNode ? jQuery.cache : elem,
  3176. id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
  3177. // If there is already no cache entry for this object, there is no
  3178. // purpose in continuing
  3179. if ( !cache[ id ] ) {
  3180. return;
  3181. }
  3182. if ( name ) {
  3183. thisCache = pvt ? cache[ id ] : cache[ id ].data;
  3184. if ( thisCache ) {
  3185. // Support array or space separated string names for data keys
  3186. if ( !jQuery.isArray( name ) ) {
  3187. // try the string as a key before any manipulation
  3188. if ( name in thisCache ) {
  3189. name = [ name ];
  3190. } else {
  3191. // split the camel cased version by spaces unless a key with the spaces exists
  3192. name = jQuery.camelCase( name );
  3193. if ( name in thisCache ) {
  3194. name = [ name ];
  3195. } else {
  3196. name = name.split(" ");
  3197. }
  3198. }
  3199. } else {
  3200. // If "name" is an array of keys...
  3201. // When data is initially created, via ("key", "val") signature,
  3202. // keys will be converted to camelCase.
  3203. // Since there is no way to tell _how_ a key was added, remove
  3204. // both plain key and camelCase key. #12786
  3205. // This will only penalize the array argument path.
  3206. name = name.concat( jQuery.map( name, jQuery.camelCase ) );
  3207. }
  3208. i = name.length;
  3209. while ( i-- ) {
  3210. delete thisCache[ name[i] ];
  3211. }
  3212. // If there is no data left in the cache, we want to continue
  3213. // and let the cache object itself get destroyed
  3214. if ( pvt ? !isEmptyDataObject(thisCache) : !jQuery.isEmptyObject(thisCache) ) {
  3215. return;
  3216. }
  3217. }
  3218. }
  3219. // See jQuery.data for more information
  3220. if ( !pvt ) {
  3221. delete cache[ id ].data;
  3222. // Don't destroy the parent cache unless the internal data object
  3223. // had been the only thing left in it
  3224. if ( !isEmptyDataObject( cache[ id ] ) ) {
  3225. return;
  3226. }
  3227. }
  3228. // Destroy the cache
  3229. if ( isNode ) {
  3230. jQuery.cleanData( [ elem ], true );
  3231. // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080)
  3232. /* jshint eqeqeq: false */
  3233. } else if ( support.deleteExpando || cache != cache.window ) {
  3234. /* jshint eqeqeq: true */
  3235. delete cache[ id ];
  3236. // When all else fails, null
  3237. } else {
  3238. cache[ id ] = null;
  3239. }
  3240. }
  3241. jQuery.extend({
  3242. cache: {},
  3243. // The following elements (space-suffixed to avoid Object.prototype collisions)
  3244. // throw uncatchable exceptions if you attempt to set expando properties
  3245. noData: {
  3246. "applet ": true,
  3247. "embed ": true,
  3248. // ...but Flash objects (which have this classid) *can* handle expandos
  3249. "object ": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
  3250. },
  3251. hasData: function( elem ) {
  3252. elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
  3253. return !!elem && !isEmptyDataObject( elem );
  3254. },
  3255. data: function( elem, name, data ) {
  3256. return internalData( elem, name, data );
  3257. },
  3258. removeData: function( elem, name ) {
  3259. return internalRemoveData( elem, name );
  3260. },
  3261. // For internal use only.
  3262. _data: function( elem, name, data ) {
  3263. return internalData( elem, name, data, true );
  3264. },
  3265. _removeData: function( elem, name ) {
  3266. return internalRemoveData( elem, name, true );
  3267. }
  3268. });
  3269. jQuery.fn.extend({
  3270. data: function( key, value ) {
  3271. var i, name, data,
  3272. elem = this[0],
  3273. attrs = elem && elem.attributes;
  3274. // Special expections of .data basically thwart jQuery.access,
  3275. // so implement the relevant behavior ourselves
  3276. // Gets all values
  3277. if ( key === undefined ) {
  3278. if ( this.length ) {
  3279. data = jQuery.data( elem );
  3280. if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
  3281. i = attrs.length;
  3282. while ( i-- ) {
  3283. // Support: IE11+
  3284. // The attrs elements can be null (#14894)
  3285. if ( attrs[ i ] ) {
  3286. name = attrs[ i ].name;
  3287. if ( name.indexOf( "data-" ) === 0 ) {
  3288. name = jQuery.camelCase( name.slice(5) );
  3289. dataAttr( elem, name, data[ name ] );
  3290. }
  3291. }
  3292. }
  3293. jQuery._data( elem, "parsedAttrs", true );
  3294. }
  3295. }
  3296. return data;
  3297. }
  3298. // Sets multiple values
  3299. if ( typeof key === "object" ) {
  3300. return this.each(function() {
  3301. jQuery.data( this, key );
  3302. });
  3303. }
  3304. return arguments.length > 1 ?
  3305. // Sets one value
  3306. this.each(function() {
  3307. jQuery.data( this, key, value );
  3308. }) :
  3309. // Gets one value
  3310. // Try to fetch any internally stored data first
  3311. elem ? dataAttr( elem, key, jQuery.data( elem, key ) ) : undefined;
  3312. },
  3313. removeData: function( key ) {
  3314. return this.each(function() {
  3315. jQuery.removeData( this, key );
  3316. });
  3317. }
  3318. });
  3319. jQuery.extend({
  3320. queue: function( elem, type, data ) {
  3321. var queue;
  3322. if ( elem ) {
  3323. type = ( type || "fx" ) + "queue";
  3324. queue = jQuery._data( elem, type );
  3325. // Speed up dequeue by getting out quickly if this is just a lookup
  3326. if ( data ) {
  3327. if ( !queue || jQuery.isArray(data) ) {
  3328. queue = jQuery._data( elem, type, jQuery.makeArray(data) );
  3329. } else {
  3330. queue.push( data );
  3331. }
  3332. }
  3333. return queue || [];
  3334. }
  3335. },
  3336. dequeue: function( elem, type ) {
  3337. type = type || "fx";
  3338. var queue = jQuery.queue( elem, type ),
  3339. startLength = queue.length,
  3340. fn = queue.shift(),
  3341. hooks = jQuery._queueHooks( elem, type ),
  3342. next = function() {
  3343. jQuery.dequeue( elem, type );
  3344. };
  3345. // If the fx queue is dequeued, always remove the progress sentinel
  3346. if ( fn === "inprogress" ) {
  3347. fn = queue.shift();
  3348. startLength--;
  3349. }
  3350. if ( fn ) {
  3351. // Add a progress sentinel to prevent the fx queue from being
  3352. // automatically dequeued
  3353. if ( type === "fx" ) {
  3354. queue.unshift( "inprogress" );
  3355. }
  3356. // clear up the last queue stop function
  3357. delete hooks.stop;
  3358. fn.call( elem, next, hooks );
  3359. }
  3360. if ( !startLength && hooks ) {
  3361. hooks.empty.fire();
  3362. }
  3363. },
  3364. // not intended for public consumption - generates a queueHooks object, or returns the current one
  3365. _queueHooks: function( elem, type ) {
  3366. var key = type + "queueHooks";
  3367. return jQuery._data( elem, key ) || jQuery._data( elem, key, {
  3368. empty: jQuery.Callbacks("once memory").add(function() {
  3369. jQuery._removeData( elem, type + "queue" );
  3370. jQuery._removeData( elem, key );
  3371. })
  3372. });
  3373. }
  3374. });
  3375. jQuery.fn.extend({
  3376. queue: function( type, data ) {
  3377. var setter = 2;
  3378. if ( typeof type !== "string" ) {
  3379. data = type;
  3380. type = "fx";
  3381. setter--;
  3382. }
  3383. if ( arguments.length < setter ) {
  3384. return jQuery.queue( this[0], type );
  3385. }
  3386. return data === undefined ?
  3387. this :
  3388. this.each(function() {
  3389. var queue = jQuery.queue( this, type, data );
  3390. // ensure a hooks for this queue
  3391. jQuery._queueHooks( this, type );
  3392. if ( type === "fx" && queue[0] !== "inprogress" ) {
  3393. jQuery.dequeue( this, type );
  3394. }
  3395. });
  3396. },
  3397. dequeue: function( type ) {
  3398. return this.each(function() {
  3399. jQuery.dequeue( this, type );
  3400. });
  3401. },
  3402. clearQueue: function( type ) {
  3403. return this.queue( type || "fx", [] );
  3404. },
  3405. // Get a promise resolved when queues of a certain type
  3406. // are emptied (fx is the type by default)
  3407. promise: function( type, obj ) {
  3408. var tmp,
  3409. count = 1,
  3410. defer = jQuery.Deferred(),
  3411. elements = this,
  3412. i = this.length,
  3413. resolve = function() {
  3414. if ( !( --count ) ) {
  3415. defer.resolveWith( elements, [ elements ] );
  3416. }
  3417. };
  3418. if ( typeof type !== "string" ) {
  3419. obj = type;
  3420. type = undefined;
  3421. }
  3422. type = type || "fx";
  3423. while ( i-- ) {
  3424. tmp = jQuery._data( elements[ i ], type + "queueHooks" );
  3425. if ( tmp && tmp.empty ) {
  3426. count++;
  3427. tmp.empty.add( resolve );
  3428. }
  3429. }
  3430. resolve();
  3431. return defer.promise( obj );
  3432. }
  3433. });
  3434. var pnum = (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source;
  3435. var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
  3436. var isHidden = function( elem, el ) {
  3437. // isHidden might be called from jQuery#filter function;
  3438. // in that case, element will be second argument
  3439. elem = el || elem;
  3440. return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
  3441. };
  3442. // Multifunctional method to get and set values of a collection
  3443. // The value/s can optionally be executed if it's a function
  3444. var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
  3445. var i = 0,
  3446. length = elems.length,
  3447. bulk = key == null;
  3448. // Sets many values
  3449. if ( jQuery.type( key ) === "object" ) {
  3450. chainable = true;
  3451. for ( i in key ) {
  3452. jQuery.access( elems, fn, i, key[i], true, emptyGet, raw );
  3453. }
  3454. // Sets one value
  3455. } else if ( value !== undefined ) {
  3456. chainable = true;
  3457. if ( !jQuery.isFunction( value ) ) {
  3458. raw = true;
  3459. }
  3460. if ( bulk ) {
  3461. // Bulk operations run against the entire set
  3462. if ( raw ) {
  3463. fn.call( elems, value );
  3464. fn = null;
  3465. // ...except when executing function values
  3466. } else {
  3467. bulk = fn;
  3468. fn = function( elem, key, value ) {
  3469. return bulk.call( jQuery( elem ), value );
  3470. };
  3471. }
  3472. }
  3473. if ( fn ) {
  3474. for ( ; i < length; i++ ) {
  3475. fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) );
  3476. }
  3477. }
  3478. }
  3479. return chainable ?
  3480. elems :
  3481. // Gets
  3482. bulk ?
  3483. fn.call( elems ) :
  3484. length ? fn( elems[0], key ) : emptyGet;
  3485. };
  3486. var rcheckableType = (/^(?:checkbox|radio)$/i);
  3487. (function() {
  3488. // Minified: var a,b,c
  3489. var input = document.createElement( "input" ),
  3490. div = document.createElement( "div" ),
  3491. fragment = document.createDocumentFragment();
  3492. // Setup
  3493. div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
  3494. // IE strips leading whitespace when .innerHTML is used
  3495. support.leadingWhitespace = div.firstChild.nodeType === 3;
  3496. // Make sure that tbody elements aren't automatically inserted
  3497. // IE will insert them into empty tables
  3498. support.tbody = !div.getElementsByTagName( "tbody" ).length;
  3499. // Make sure that link elements get serialized correctly by innerHTML
  3500. // This requires a wrapper element in IE
  3501. support.htmlSerialize = !!div.getElementsByTagName( "link" ).length;
  3502. // Makes sure cloning an html5 element does not cause problems
  3503. // Where outerHTML is undefined, this still works
  3504. support.html5Clone =
  3505. document.createElement( "nav" ).cloneNode( true ).outerHTML !== "<:nav></:nav>";
  3506. // Check if a disconnected checkbox will retain its checked
  3507. // value of true after appended to the DOM (IE6/7)
  3508. input.type = "checkbox";
  3509. input.checked = true;
  3510. fragment.appendChild( input );
  3511. support.appendChecked = input.checked;
  3512. // Make sure textarea (and checkbox) defaultValue is properly cloned
  3513. // Support: IE6-IE11+
  3514. div.innerHTML = "<textarea>x</textarea>";
  3515. support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
  3516. // #11217 - WebKit loses check when the name is after the checked attribute
  3517. fragment.appendChild( div );
  3518. div.innerHTML = "<input type='radio' checked='checked' name='t'/>";
  3519. // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3
  3520. // old WebKit doesn't clone checked state correctly in fragments
  3521. support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
  3522. // Support: IE<9
  3523. // Opera does not clone events (and typeof div.attachEvent === undefined).
  3524. // IE9-10 clones events bound via attachEvent, but they don't trigger with .click()
  3525. support.noCloneEvent = true;
  3526. if ( div.attachEvent ) {
  3527. div.attachEvent( "onclick", function() {
  3528. support.noCloneEvent = false;
  3529. });
  3530. div.cloneNode( true ).click();
  3531. }
  3532. // Execute the test only if not already executed in another module.
  3533. if (support.deleteExpando == null) {
  3534. // Support: IE<9
  3535. support.deleteExpando = true;
  3536. try {
  3537. delete div.test;
  3538. } catch( e ) {
  3539. support.deleteExpando = false;
  3540. }
  3541. }
  3542. })();
  3543. (function() {
  3544. var i, eventName,
  3545. div = document.createElement( "div" );
  3546. // Support: IE<9 (lack submit/change bubble), Firefox 23+ (lack focusin event)
  3547. for ( i in { submit: true, change: true, focusin: true }) {
  3548. eventName = "on" + i;
  3549. if ( !(support[ i + "Bubbles" ] = eventName in window) ) {
  3550. // Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP)
  3551. div.setAttribute( eventName, "t" );
  3552. support[ i + "Bubbles" ] = div.attributes[ eventName ].expando === false;
  3553. }
  3554. }
  3555. // Null elements to avoid leaks in IE.
  3556. div = null;
  3557. })();
  3558. var rformElems = /^(?:input|select|textarea)$/i,
  3559. rkeyEvent = /^key/,
  3560. rmouseEvent = /^(?:mouse|pointer|contextmenu)|click/,
  3561. rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
  3562. rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
  3563. function returnTrue() {
  3564. return true;
  3565. }
  3566. function returnFalse() {
  3567. return false;
  3568. }
  3569. function safeActiveElement() {
  3570. try {
  3571. return document.activeElement;
  3572. } catch ( err ) { }
  3573. }
  3574. /*
  3575. * Helper functions for managing events -- not part of the public interface.
  3576. * Props to Dean Edwards' addEvent library for many of the ideas.
  3577. */
  3578. jQuery.event = {
  3579. global: {},
  3580. add: function( elem, types, handler, data, selector ) {
  3581. var tmp, events, t, handleObjIn,
  3582. special, eventHandle, handleObj,
  3583. handlers, type, namespaces, origType,
  3584. elemData = jQuery._data( elem );
  3585. // Don't attach events to noData or text/comment nodes (but allow plain objects)
  3586. if ( !elemData ) {
  3587. return;
  3588. }
  3589. // Caller can pass in an object of custom data in lieu of the handler
  3590. if ( handler.handler ) {
  3591. handleObjIn = handler;
  3592. handler = handleObjIn.handler;
  3593. selector = handleObjIn.selector;
  3594. }
  3595. // Make sure that the handler has a unique ID, used to find/remove it later
  3596. if ( !handler.guid ) {
  3597. handler.guid = jQuery.guid++;
  3598. }
  3599. // Init the element's event structure and main handler, if this is the first
  3600. if ( !(events = elemData.events) ) {
  3601. events = elemData.events = {};
  3602. }
  3603. if ( !(eventHandle = elemData.handle) ) {
  3604. eventHandle = elemData.handle = function( e ) {
  3605. // Discard the second event of a jQuery.event.trigger() and
  3606. // when an event is called after a page has unloaded
  3607. return typeof jQuery !== strundefined && (!e || jQuery.event.triggered !== e.type) ?
  3608. jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
  3609. undefined;
  3610. };
  3611. // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
  3612. eventHandle.elem = elem;
  3613. }
  3614. // Handle multiple events separated by a space
  3615. types = ( types || "" ).match( rnotwhite ) || [ "" ];
  3616. t = types.length;
  3617. while ( t-- ) {
  3618. tmp = rtypenamespace.exec( types[t] ) || [];
  3619. type = origType = tmp[1];
  3620. namespaces = ( tmp[2] || "" ).split( "." ).sort();
  3621. // There *must* be a type, no attaching namespace-only handlers
  3622. if ( !type ) {
  3623. continue;
  3624. }
  3625. // If event changes its type, use the special event handlers for the changed type
  3626. special = jQuery.event.special[ type ] || {};
  3627. // If selector defined, determine special event api type, otherwise given type
  3628. type = ( selector ? special.delegateType : special.bindType ) || type;
  3629. // Update special based on newly reset type
  3630. special = jQuery.event.special[ type ] || {};
  3631. // handleObj is passed to all event handlers
  3632. handleObj = jQuery.extend({
  3633. type: type,
  3634. origType: origType,
  3635. data: data,
  3636. handler: handler,
  3637. guid: handler.guid,
  3638. selector: selector,
  3639. needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
  3640. namespace: namespaces.join(".")
  3641. }, handleObjIn );
  3642. // Init the event handler queue if we're the first
  3643. if ( !(handlers = events[ type ]) ) {
  3644. handlers = events[ type ] = [];
  3645. handlers.delegateCount = 0;
  3646. // Only use addEventListener/attachEvent if the special events handler returns false
  3647. if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
  3648. // Bind the global event handler to the element
  3649. if ( elem.addEventListener ) {
  3650. elem.addEventListener( type, eventHandle, false );
  3651. } else if ( elem.attachEvent ) {
  3652. elem.attachEvent( "on" + type, eventHandle );
  3653. }
  3654. }
  3655. }
  3656. if ( special.add ) {
  3657. special.add.call( elem, handleObj );
  3658. if ( !handleObj.handler.guid ) {
  3659. handleObj.handler.guid = handler.guid;
  3660. }
  3661. }
  3662. // Add to the element's handler list, delegates in front
  3663. if ( selector ) {
  3664. handlers.splice( handlers.delegateCount++, 0, handleObj );
  3665. } else {
  3666. handlers.push( handleObj );
  3667. }
  3668. // Keep track of which events have ever been used, for event optimization
  3669. jQuery.event.global[ type ] = true;
  3670. }
  3671. // Nullify elem to prevent memory leaks in IE
  3672. elem = null;
  3673. },
  3674. // Detach an event or set of events from an element
  3675. remove: function( elem, types, handler, selector, mappedTypes ) {
  3676. var j, handleObj, tmp,
  3677. origCount, t, events,
  3678. special, handlers, type,
  3679. namespaces, origType,
  3680. elemData = jQuery.hasData( elem ) && jQuery._data( elem );
  3681. if ( !elemData || !(events = elemData.events) ) {
  3682. return;
  3683. }
  3684. // Once for each type.namespace in types; type may be omitted
  3685. types = ( types || "" ).match( rnotwhite ) || [ "" ];
  3686. t = types.length;
  3687. while ( t-- ) {
  3688. tmp = rtypenamespace.exec( types[t] ) || [];
  3689. type = origType = tmp[1];
  3690. namespaces = ( tmp[2] || "" ).split( "." ).sort();
  3691. // Unbind all events (on this namespace, if provided) for the element
  3692. if ( !type ) {
  3693. for ( type in events ) {
  3694. jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
  3695. }
  3696. continue;
  3697. }
  3698. special = jQuery.event.special[ type ] || {};
  3699. type = ( selector ? special.delegateType : special.bindType ) || type;
  3700. handlers = events[ type ] || [];
  3701. tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" );
  3702. // Remove matching events
  3703. origCount = j = handlers.length;
  3704. while ( j-- ) {
  3705. handleObj = handlers[ j ];
  3706. if ( ( mappedTypes || origType === handleObj.origType ) &&
  3707. ( !handler || handler.guid === handleObj.guid ) &&
  3708. ( !tmp || tmp.test( handleObj.namespace ) ) &&
  3709. ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
  3710. handlers.splice( j, 1 );
  3711. if ( handleObj.selector ) {
  3712. handlers.delegateCount--;
  3713. }
  3714. if ( special.remove ) {
  3715. special.remove.call( elem, handleObj );
  3716. }
  3717. }
  3718. }
  3719. // Remove generic event handler if we removed something and no more handlers exist
  3720. // (avoids potential for endless recursion during removal of special event handlers)
  3721. if ( origCount && !handlers.length ) {
  3722. if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
  3723. jQuery.removeEvent( elem, type, elemData.handle );
  3724. }
  3725. delete events[ type ];
  3726. }
  3727. }
  3728. // Remove the expando if it's no longer used
  3729. if ( jQuery.isEmptyObject( events ) ) {
  3730. delete elemData.handle;
  3731. // removeData also checks for emptiness and clears the expando if empty
  3732. // so use it instead of delete
  3733. jQuery._removeData( elem, "events" );
  3734. }
  3735. },
  3736. trigger: function( event, data, elem, onlyHandlers ) {
  3737. var handle, ontype, cur,
  3738. bubbleType, special, tmp, i,
  3739. eventPath = [ elem || document ],
  3740. type = hasOwn.call( event, "type" ) ? event.type : event,
  3741. namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : [];
  3742. cur = tmp = elem = elem || document;
  3743. // Don't do events on text and comment nodes
  3744. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  3745. return;
  3746. }
  3747. // focus/blur morphs to focusin/out; ensure we're not firing them right now
  3748. if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
  3749. return;
  3750. }
  3751. if ( type.indexOf(".") >= 0 ) {
  3752. // Namespaced trigger; create a regexp to match event type in handle()
  3753. namespaces = type.split(".");
  3754. type = namespaces.shift();
  3755. namespaces.sort();
  3756. }
  3757. ontype = type.indexOf(":") < 0 && "on" + type;
  3758. // Caller can pass in a jQuery.Event object, Object, or just an event type string
  3759. event = event[ jQuery.expando ] ?
  3760. event :
  3761. new jQuery.Event( type, typeof event === "object" && event );
  3762. // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
  3763. event.isTrigger = onlyHandlers ? 2 : 3;
  3764. event.namespace = namespaces.join(".");
  3765. event.namespace_re = event.namespace ?
  3766. new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
  3767. null;
  3768. // Clean up the event in case it is being reused
  3769. event.result = undefined;
  3770. if ( !event.target ) {
  3771. event.target = elem;
  3772. }
  3773. // Clone any incoming data and prepend the event, creating the handler arg list
  3774. data = data == null ?
  3775. [ event ] :
  3776. jQuery.makeArray( data, [ event ] );
  3777. // Allow special events to draw outside the lines
  3778. special = jQuery.event.special[ type ] || {};
  3779. if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
  3780. return;
  3781. }
  3782. // Determine event propagation path in advance, per W3C events spec (#9951)
  3783. // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
  3784. if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
  3785. bubbleType = special.delegateType || type;
  3786. if ( !rfocusMorph.test( bubbleType + type ) ) {
  3787. cur = cur.parentNode;
  3788. }
  3789. for ( ; cur; cur = cur.parentNode ) {
  3790. eventPath.push( cur );
  3791. tmp = cur;
  3792. }
  3793. // Only add window if we got to document (e.g., not plain obj or detached DOM)
  3794. if ( tmp === (elem.ownerDocument || document) ) {
  3795. eventPath.push( tmp.defaultView || tmp.parentWindow || window );
  3796. }
  3797. }
  3798. // Fire handlers on the event path
  3799. i = 0;
  3800. while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) {
  3801. event.type = i > 1 ?
  3802. bubbleType :
  3803. special.bindType || type;
  3804. // jQuery handler
  3805. handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" );
  3806. if ( handle ) {
  3807. handle.apply( cur, data );
  3808. }
  3809. // Native handler
  3810. handle = ontype && cur[ ontype ];
  3811. if ( handle && handle.apply && jQuery.acceptData( cur ) ) {
  3812. event.result = handle.apply( cur, data );
  3813. if ( event.result === false ) {
  3814. event.preventDefault();
  3815. }
  3816. }
  3817. }
  3818. event.type = type;
  3819. // If nobody prevented the default action, do it now
  3820. if ( !onlyHandlers && !event.isDefaultPrevented() ) {
  3821. if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) &&
  3822. jQuery.acceptData( elem ) ) {
  3823. // Call a native DOM method on the target with the same name name as the event.
  3824. // Can't use an .isFunction() check here because IE6/7 fails that test.
  3825. // Don't do default actions on window, that's where global variables be (#6170)
  3826. if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) {
  3827. // Don't re-trigger an onFOO event when we call its FOO() method
  3828. tmp = elem[ ontype ];
  3829. if ( tmp ) {
  3830. elem[ ontype ] = null;
  3831. }
  3832. // Prevent re-triggering of the same event, since we already bubbled it above
  3833. jQuery.event.triggered = type;
  3834. try {
  3835. elem[ type ]();
  3836. } catch ( e ) {
  3837. // IE<9 dies on focus/blur to hidden element (#1486,#12518)
  3838. // only reproducible on winXP IE8 native, not IE9 in IE8 mode
  3839. }
  3840. jQuery.event.triggered = undefined;
  3841. if ( tmp ) {
  3842. elem[ ontype ] = tmp;
  3843. }
  3844. }
  3845. }
  3846. }
  3847. return event.result;
  3848. },
  3849. dispatch: function( event ) {
  3850. // Make a writable jQuery.Event from the native event object
  3851. event = jQuery.event.fix( event );
  3852. var i, ret, handleObj, matched, j,
  3853. handlerQueue = [],
  3854. args = slice.call( arguments ),
  3855. handlers = ( jQuery._data( this, "events" ) || {} )[ event.type ] || [],
  3856. special = jQuery.event.special[ event.type ] || {};
  3857. // Use the fix-ed jQuery.Event rather than the (read-only) native event
  3858. args[0] = event;
  3859. event.delegateTarget = this;
  3860. // Call the preDispatch hook for the mapped type, and let it bail if desired
  3861. if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
  3862. return;
  3863. }
  3864. // Determine handlers
  3865. handlerQueue = jQuery.event.handlers.call( this, event, handlers );
  3866. // Run delegates first; they may want to stop propagation beneath us
  3867. i = 0;
  3868. while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) {
  3869. event.currentTarget = matched.elem;
  3870. j = 0;
  3871. while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) {
  3872. // Triggered event must either 1) have no namespace, or
  3873. // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
  3874. if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) {
  3875. event.handleObj = handleObj;
  3876. event.data = handleObj.data;
  3877. ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
  3878. .apply( matched.elem, args );
  3879. if ( ret !== undefined ) {
  3880. if ( (event.result = ret) === false ) {
  3881. event.preventDefault();
  3882. event.stopPropagation();
  3883. }
  3884. }
  3885. }
  3886. }
  3887. }
  3888. // Call the postDispatch hook for the mapped type
  3889. if ( special.postDispatch ) {
  3890. special.postDispatch.call( this, event );
  3891. }
  3892. return event.result;
  3893. },
  3894. handlers: function( event, handlers ) {
  3895. var sel, handleObj, matches, i,
  3896. handlerQueue = [],
  3897. delegateCount = handlers.delegateCount,
  3898. cur = event.target;
  3899. // Find delegate handlers
  3900. // Black-hole SVG <use> instance trees (#13180)
  3901. // Avoid non-left-click bubbling in Firefox (#3861)
  3902. if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) {
  3903. /* jshint eqeqeq: false */
  3904. for ( ; cur != this; cur = cur.parentNode || this ) {
  3905. /* jshint eqeqeq: true */
  3906. // Don't check non-elements (#13208)
  3907. // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
  3908. if ( cur.nodeType === 1 && (cur.disabled !== true || event.type !== "click") ) {
  3909. matches = [];
  3910. for ( i = 0; i < delegateCount; i++ ) {
  3911. handleObj = handlers[ i ];
  3912. // Don't conflict with Object.prototype properties (#13203)
  3913. sel = handleObj.selector + " ";
  3914. if ( matches[ sel ] === undefined ) {
  3915. matches[ sel ] = handleObj.needsContext ?
  3916. jQuery( sel, this ).index( cur ) >= 0 :
  3917. jQuery.find( sel, this, null, [ cur ] ).length;
  3918. }
  3919. if ( matches[ sel ] ) {
  3920. matches.push( handleObj );
  3921. }
  3922. }
  3923. if ( matches.length ) {
  3924. handlerQueue.push({ elem: cur, handlers: matches });
  3925. }
  3926. }
  3927. }
  3928. }
  3929. // Add the remaining (directly-bound) handlers
  3930. if ( delegateCount < handlers.length ) {
  3931. handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) });
  3932. }
  3933. return handlerQueue;
  3934. },
  3935. fix: function( event ) {
  3936. if ( event[ jQuery.expando ] ) {
  3937. return event;
  3938. }
  3939. // Create a writable copy of the event object and normalize some properties
  3940. var i, prop, copy,
  3941. type = event.type,
  3942. originalEvent = event,
  3943. fixHook = this.fixHooks[ type ];
  3944. if ( !fixHook ) {
  3945. this.fixHooks[ type ] = fixHook =
  3946. rmouseEvent.test( type ) ? this.mouseHooks :
  3947. rkeyEvent.test( type ) ? this.keyHooks :
  3948. {};
  3949. }
  3950. copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
  3951. event = new jQuery.Event( originalEvent );
  3952. i = copy.length;
  3953. while ( i-- ) {
  3954. prop = copy[ i ];
  3955. event[ prop ] = originalEvent[ prop ];
  3956. }
  3957. // Support: IE<9
  3958. // Fix target property (#1925)
  3959. if ( !event.target ) {
  3960. event.target = originalEvent.srcElement || document;
  3961. }
  3962. // Support: Chrome 23+, Safari?
  3963. // Target should not be a text node (#504, #13143)
  3964. if ( event.target.nodeType === 3 ) {
  3965. event.target = event.target.parentNode;
  3966. }
  3967. // Support: IE<9
  3968. // For mouse/key events, metaKey==false if it's undefined (#3368, #11328)
  3969. event.metaKey = !!event.metaKey;
  3970. return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
  3971. },
  3972. // Includes some event props shared by KeyEvent and MouseEvent
  3973. props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
  3974. fixHooks: {},
  3975. keyHooks: {
  3976. props: "char charCode key keyCode".split(" "),
  3977. filter: function( event, original ) {
  3978. // Add which for key events
  3979. if ( event.which == null ) {
  3980. event.which = original.charCode != null ? original.charCode : original.keyCode;
  3981. }
  3982. return event;
  3983. }
  3984. },
  3985. mouseHooks: {
  3986. props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
  3987. filter: function( event, original ) {
  3988. var body, eventDoc, doc,
  3989. button = original.button,
  3990. fromElement = original.fromElement;
  3991. // Calculate pageX/Y if missing and clientX/Y available
  3992. if ( event.pageX == null && original.clientX != null ) {
  3993. eventDoc = event.target.ownerDocument || document;
  3994. doc = eventDoc.documentElement;
  3995. body = eventDoc.body;
  3996. event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
  3997. event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
  3998. }
  3999. // Add relatedTarget, if necessary
  4000. if ( !event.relatedTarget && fromElement ) {
  4001. event.relatedTarget = fromElement === event.target ? original.toElement : fromElement;
  4002. }
  4003. // Add which for click: 1 === left; 2 === middle; 3 === right
  4004. // Note: button is not normalized, so don't use it
  4005. if ( !event.which && button !== undefined ) {
  4006. event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
  4007. }
  4008. return event;
  4009. }
  4010. },
  4011. special: {
  4012. load: {
  4013. // Prevent triggered image.load events from bubbling to window.load
  4014. noBubble: true
  4015. },
  4016. focus: {
  4017. // Fire native event if possible so blur/focus sequence is correct
  4018. trigger: function() {
  4019. if ( this !== safeActiveElement() && this.focus ) {
  4020. try {
  4021. this.focus();
  4022. return false;
  4023. } catch ( e ) {
  4024. // Support: IE<9
  4025. // If we error on focus to hidden element (#1486, #12518),
  4026. // let .trigger() run the handlers
  4027. }
  4028. }
  4029. },
  4030. delegateType: "focusin"
  4031. },
  4032. blur: {
  4033. trigger: function() {
  4034. if ( this === safeActiveElement() && this.blur ) {
  4035. this.blur();
  4036. return false;
  4037. }
  4038. },
  4039. delegateType: "focusout"
  4040. },
  4041. click: {
  4042. // For checkbox, fire native event so checked state will be right
  4043. trigger: function() {
  4044. if ( jQuery.nodeName( this, "input" ) && this.type === "checkbox" && this.click ) {
  4045. this.click();
  4046. return false;
  4047. }
  4048. },
  4049. // For cross-browser consistency, don't fire native .click() on links
  4050. _default: function( event ) {
  4051. return jQuery.nodeName( event.target, "a" );
  4052. }
  4053. },
  4054. beforeunload: {
  4055. postDispatch: function( event ) {
  4056. // Support: Firefox 20+
  4057. // Firefox doesn't alert if the returnValue field is not set.
  4058. if ( event.result !== undefined && event.originalEvent ) {
  4059. event.originalEvent.returnValue = event.result;
  4060. }
  4061. }
  4062. }
  4063. },
  4064. simulate: function( type, elem, event, bubble ) {
  4065. // Piggyback on a donor event to simulate a different one.
  4066. // Fake originalEvent to avoid donor's stopPropagation, but if the
  4067. // simulated event prevents default then we do the same on the donor.
  4068. var e = jQuery.extend(
  4069. new jQuery.Event(),
  4070. event,
  4071. {
  4072. type: type,
  4073. isSimulated: true,
  4074. originalEvent: {}
  4075. }
  4076. );
  4077. if ( bubble ) {
  4078. jQuery.event.trigger( e, null, elem );
  4079. } else {
  4080. jQuery.event.dispatch.call( elem, e );
  4081. }
  4082. if ( e.isDefaultPrevented() ) {
  4083. event.preventDefault();
  4084. }
  4085. }
  4086. };
  4087. jQuery.removeEvent = document.removeEventListener ?
  4088. function( elem, type, handle ) {
  4089. if ( elem.removeEventListener ) {
  4090. elem.removeEventListener( type, handle, false );
  4091. }
  4092. } :
  4093. function( elem, type, handle ) {
  4094. var name = "on" + type;
  4095. if ( elem.detachEvent ) {
  4096. // #8545, #7054, preventing memory leaks for custom events in IE6-8
  4097. // detachEvent needed property on element, by name of that event, to properly expose it to GC
  4098. if ( typeof elem[ name ] === strundefined ) {
  4099. elem[ name ] = null;
  4100. }
  4101. elem.detachEvent( name, handle );
  4102. }
  4103. };
  4104. jQuery.Event = function( src, props ) {
  4105. // Allow instantiation without the 'new' keyword
  4106. if ( !(this instanceof jQuery.Event) ) {
  4107. return new jQuery.Event( src, props );
  4108. }
  4109. // Event object
  4110. if ( src && src.type ) {
  4111. this.originalEvent = src;
  4112. this.type = src.type;
  4113. // Events bubbling up the document may have been marked as prevented
  4114. // by a handler lower down the tree; reflect the correct value.
  4115. this.isDefaultPrevented = src.defaultPrevented ||
  4116. src.defaultPrevented === undefined &&
  4117. // Support: IE < 9, Android < 4.0
  4118. src.returnValue === false ?
  4119. returnTrue :
  4120. returnFalse;
  4121. // Event type
  4122. } else {
  4123. this.type = src;
  4124. }
  4125. // Put explicitly provided properties onto the event object
  4126. if ( props ) {
  4127. jQuery.extend( this, props );
  4128. }
  4129. // Create a timestamp if incoming event doesn't have one
  4130. this.timeStamp = src && src.timeStamp || jQuery.now();
  4131. // Mark it as fixed
  4132. this[ jQuery.expando ] = true;
  4133. };
  4134. // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
  4135. // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  4136. jQuery.Event.prototype = {
  4137. isDefaultPrevented: returnFalse,
  4138. isPropagationStopped: returnFalse,
  4139. isImmediatePropagationStopped: returnFalse,
  4140. preventDefault: function() {
  4141. var e = this.originalEvent;
  4142. this.isDefaultPrevented = returnTrue;
  4143. if ( !e ) {
  4144. return;
  4145. }
  4146. // If preventDefault exists, run it on the original event
  4147. if ( e.preventDefault ) {
  4148. e.preventDefault();
  4149. // Support: IE
  4150. // Otherwise set the returnValue property of the original event to false
  4151. } else {
  4152. e.returnValue = false;
  4153. }
  4154. },
  4155. stopPropagation: function() {
  4156. var e = this.originalEvent;
  4157. this.isPropagationStopped = returnTrue;
  4158. if ( !e ) {
  4159. return;
  4160. }
  4161. // If stopPropagation exists, run it on the original event
  4162. if ( e.stopPropagation ) {
  4163. e.stopPropagation();
  4164. }
  4165. // Support: IE
  4166. // Set the cancelBubble property of the original event to true
  4167. e.cancelBubble = true;
  4168. },
  4169. stopImmediatePropagation: function() {
  4170. var e = this.originalEvent;
  4171. this.isImmediatePropagationStopped = returnTrue;
  4172. if ( e && e.stopImmediatePropagation ) {
  4173. e.stopImmediatePropagation();
  4174. }
  4175. this.stopPropagation();
  4176. }
  4177. };
  4178. // Create mouseenter/leave events using mouseover/out and event-time checks
  4179. jQuery.each({
  4180. mouseenter: "mouseover",
  4181. mouseleave: "mouseout",
  4182. pointerenter: "pointerover",
  4183. pointerleave: "pointerout"
  4184. }, function( orig, fix ) {
  4185. jQuery.event.special[ orig ] = {
  4186. delegateType: fix,
  4187. bindType: fix,
  4188. handle: function( event ) {
  4189. var ret,
  4190. target = this,
  4191. related = event.relatedTarget,
  4192. handleObj = event.handleObj;
  4193. // For mousenter/leave call the handler if related is outside the target.
  4194. // NB: No relatedTarget if the mouse left/entered the browser window
  4195. if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
  4196. event.type = handleObj.origType;
  4197. ret = handleObj.handler.apply( this, arguments );
  4198. event.type = fix;
  4199. }
  4200. return ret;
  4201. }
  4202. };
  4203. });
  4204. // IE submit delegation
  4205. if ( !support.submitBubbles ) {
  4206. jQuery.event.special.submit = {
  4207. setup: function() {
  4208. // Only need this for delegated form submit events
  4209. if ( jQuery.nodeName( this, "form" ) ) {
  4210. return false;
  4211. }
  4212. // Lazy-add a submit handler when a descendant form may potentially be submitted
  4213. jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
  4214. // Node name check avoids a VML-related crash in IE (#9807)
  4215. var elem = e.target,
  4216. form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined;
  4217. if ( form && !jQuery._data( form, "submitBubbles" ) ) {
  4218. jQuery.event.add( form, "submit._submit", function( event ) {
  4219. event._submit_bubble = true;
  4220. });
  4221. jQuery._data( form, "submitBubbles", true );
  4222. }
  4223. });
  4224. // return undefined since we don't need an event listener
  4225. },
  4226. postDispatch: function( event ) {
  4227. // If form was submitted by the user, bubble the event up the tree
  4228. if ( event._submit_bubble ) {
  4229. delete event._submit_bubble;
  4230. if ( this.parentNode && !event.isTrigger ) {
  4231. jQuery.event.simulate( "submit", this.parentNode, event, true );
  4232. }
  4233. }
  4234. },
  4235. teardown: function() {
  4236. // Only need this for delegated form submit events
  4237. if ( jQuery.nodeName( this, "form" ) ) {
  4238. return false;
  4239. }
  4240. // Remove delegated handlers; cleanData eventually reaps submit handlers attached above
  4241. jQuery.event.remove( this, "._submit" );
  4242. }
  4243. };
  4244. }
  4245. // IE change delegation and checkbox/radio fix
  4246. if ( !support.changeBubbles ) {
  4247. jQuery.event.special.change = {
  4248. setup: function() {
  4249. if ( rformElems.test( this.nodeName ) ) {
  4250. // IE doesn't fire change on a check/radio until blur; trigger it on click
  4251. // after a propertychange. Eat the blur-change in special.change.handle.
  4252. // This still fires onchange a second time for check/radio after blur.
  4253. if ( this.type === "checkbox" || this.type === "radio" ) {
  4254. jQuery.event.add( this, "propertychange._change", function( event ) {
  4255. if ( event.originalEvent.propertyName === "checked" ) {
  4256. this._just_changed = true;
  4257. }
  4258. });
  4259. jQuery.event.add( this, "click._change", function( event ) {
  4260. if ( this._just_changed && !event.isTrigger ) {
  4261. this._just_changed = false;
  4262. }
  4263. // Allow triggered, simulated change events (#11500)
  4264. jQuery.event.simulate( "change", this, event, true );
  4265. });
  4266. }
  4267. return false;
  4268. }
  4269. // Delegated event; lazy-add a change handler on descendant inputs
  4270. jQuery.event.add( this, "beforeactivate._change", function( e ) {
  4271. var elem = e.target;
  4272. if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "changeBubbles" ) ) {
  4273. jQuery.event.add( elem, "change._change", function( event ) {
  4274. if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
  4275. jQuery.event.simulate( "change", this.parentNode, event, true );
  4276. }
  4277. });
  4278. jQuery._data( elem, "changeBubbles", true );
  4279. }
  4280. });
  4281. },
  4282. handle: function( event ) {
  4283. var elem = event.target;
  4284. // Swallow native change events from checkbox/radio, we already triggered them above
  4285. if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) {
  4286. return event.handleObj.handler.apply( this, arguments );
  4287. }
  4288. },
  4289. teardown: function() {
  4290. jQuery.event.remove( this, "._change" );
  4291. return !rformElems.test( this.nodeName );
  4292. }
  4293. };
  4294. }
  4295. // Create "bubbling" focus and blur events
  4296. if ( !support.focusinBubbles ) {
  4297. jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
  4298. // Attach a single capturing handler on the document while someone wants focusin/focusout
  4299. var handler = function( event ) {
  4300. jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
  4301. };
  4302. jQuery.event.special[ fix ] = {
  4303. setup: function() {
  4304. var doc = this.ownerDocument || this,
  4305. attaches = jQuery._data( doc, fix );
  4306. if ( !attaches ) {
  4307. doc.addEventListener( orig, handler, true );
  4308. }
  4309. jQuery._data( doc, fix, ( attaches || 0 ) + 1 );
  4310. },
  4311. teardown: function() {
  4312. var doc = this.ownerDocument || this,
  4313. attaches = jQuery._data( doc, fix ) - 1;
  4314. if ( !attaches ) {
  4315. doc.removeEventListener( orig, handler, true );
  4316. jQuery._removeData( doc, fix );
  4317. } else {
  4318. jQuery._data( doc, fix, attaches );
  4319. }
  4320. }
  4321. };
  4322. });
  4323. }
  4324. jQuery.fn.extend({
  4325. on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
  4326. var type, origFn;
  4327. // Types can be a map of types/handlers
  4328. if ( typeof types === "object" ) {
  4329. // ( types-Object, selector, data )
  4330. if ( typeof selector !== "string" ) {
  4331. // ( types-Object, data )
  4332. data = data || selector;
  4333. selector = undefined;
  4334. }
  4335. for ( type in types ) {
  4336. this.on( type, selector, data, types[ type ], one );
  4337. }
  4338. return this;
  4339. }
  4340. if ( data == null && fn == null ) {
  4341. // ( types, fn )
  4342. fn = selector;
  4343. data = selector = undefined;
  4344. } else if ( fn == null ) {
  4345. if ( typeof selector === "string" ) {
  4346. // ( types, selector, fn )
  4347. fn = data;
  4348. data = undefined;
  4349. } else {
  4350. // ( types, data, fn )
  4351. fn = data;
  4352. data = selector;
  4353. selector = undefined;
  4354. }
  4355. }
  4356. if ( fn === false ) {
  4357. fn = returnFalse;
  4358. } else if ( !fn ) {
  4359. return this;
  4360. }
  4361. if ( one === 1 ) {
  4362. origFn = fn;
  4363. fn = function( event ) {
  4364. // Can use an empty set, since event contains the info
  4365. jQuery().off( event );
  4366. return origFn.apply( this, arguments );
  4367. };
  4368. // Use same guid so caller can remove using origFn
  4369. fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
  4370. }
  4371. return this.each( function() {
  4372. jQuery.event.add( this, types, fn, data, selector );
  4373. });
  4374. },
  4375. one: function( types, selector, data, fn ) {
  4376. return this.on( types, selector, data, fn, 1 );
  4377. },
  4378. off: function( types, selector, fn ) {
  4379. var handleObj, type;
  4380. if ( types && types.preventDefault && types.handleObj ) {
  4381. // ( event ) dispatched jQuery.Event
  4382. handleObj = types.handleObj;
  4383. jQuery( types.delegateTarget ).off(
  4384. handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
  4385. handleObj.selector,
  4386. handleObj.handler
  4387. );
  4388. return this;
  4389. }
  4390. if ( typeof types === "object" ) {
  4391. // ( types-object [, selector] )
  4392. for ( type in types ) {
  4393. this.off( type, selector, types[ type ] );
  4394. }
  4395. return this;
  4396. }
  4397. if ( selector === false || typeof selector === "function" ) {
  4398. // ( types [, fn] )
  4399. fn = selector;
  4400. selector = undefined;
  4401. }
  4402. if ( fn === false ) {
  4403. fn = returnFalse;
  4404. }
  4405. return this.each(function() {
  4406. jQuery.event.remove( this, types, fn, selector );
  4407. });
  4408. },
  4409. trigger: function( type, data ) {
  4410. return this.each(function() {
  4411. jQuery.event.trigger( type, data, this );
  4412. });
  4413. },
  4414. triggerHandler: function( type, data ) {
  4415. var elem = this[0];
  4416. if ( elem ) {
  4417. return jQuery.event.trigger( type, data, elem, true );
  4418. }
  4419. }
  4420. });
  4421. function createSafeFragment( document ) {
  4422. var list = nodeNames.split( "|" ),
  4423. safeFrag = document.createDocumentFragment();
  4424. if ( safeFrag.createElement ) {
  4425. while ( list.length ) {
  4426. safeFrag.createElement(
  4427. list.pop()
  4428. );
  4429. }
  4430. }
  4431. return safeFrag;
  4432. }
  4433. var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" +
  4434. "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
  4435. rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
  4436. rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),
  4437. rleadingWhitespace = /^\s+/,
  4438. rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
  4439. rtagName = /<([\w:]+)/,
  4440. rtbody = /<tbody/i,
  4441. rhtml = /<|&#?\w+;/,
  4442. rnoInnerhtml = /<(?:script|style|link)/i,
  4443. // checked="checked" or checked
  4444. rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
  4445. rscriptType = /^$|\/(?:java|ecma)script/i,
  4446. rscriptTypeMasked = /^true\/(.*)/,
  4447. rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
  4448. // We have to close these tags to support XHTML (#13200)
  4449. wrapMap = {
  4450. option: [ 1, "<select multiple='multiple'>", "</select>" ],
  4451. legend: [ 1, "<fieldset>", "</fieldset>" ],
  4452. area: [ 1, "<map>", "</map>" ],
  4453. param: [ 1, "<object>", "</object>" ],
  4454. thead: [ 1, "<table>", "</table>" ],
  4455. tr: [ 2, "<table><tbody>", "</tbody></table>" ],
  4456. col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
  4457. td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
  4458. // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
  4459. // unless wrapped in a div with non-breaking characters in front of it.
  4460. _default: support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X<div>", "</div>" ]
  4461. },
  4462. safeFragment = createSafeFragment( document ),
  4463. fragmentDiv = safeFragment.appendChild( document.createElement("div") );
  4464. wrapMap.optgroup = wrapMap.option;
  4465. wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  4466. wrapMap.th = wrapMap.td;
  4467. function getAll( context, tag ) {
  4468. var elems, elem,
  4469. i = 0,
  4470. found = typeof context.getElementsByTagName !== strundefined ? context.getElementsByTagName( tag || "*" ) :
  4471. typeof context.querySelectorAll !== strundefined ? context.querySelectorAll( tag || "*" ) :
  4472. undefined;
  4473. if ( !found ) {
  4474. for ( found = [], elems = context.childNodes || context; (elem = elems[i]) != null; i++ ) {
  4475. if ( !tag || jQuery.nodeName( elem, tag ) ) {
  4476. found.push( elem );
  4477. } else {
  4478. jQuery.merge( found, getAll( elem, tag ) );
  4479. }
  4480. }
  4481. }
  4482. return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
  4483. jQuery.merge( [ context ], found ) :
  4484. found;
  4485. }
  4486. // Used in buildFragment, fixes the defaultChecked property
  4487. function fixDefaultChecked( elem ) {
  4488. if ( rcheckableType.test( elem.type ) ) {
  4489. elem.defaultChecked = elem.checked;
  4490. }
  4491. }
  4492. // Support: IE<8
  4493. // Manipulating tables requires a tbody
  4494. function manipulationTarget( elem, content ) {
  4495. return jQuery.nodeName( elem, "table" ) &&
  4496. jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ?
  4497. elem.getElementsByTagName("tbody")[0] ||
  4498. elem.appendChild( elem.ownerDocument.createElement("tbody") ) :
  4499. elem;
  4500. }
  4501. // Replace/restore the type attribute of script elements for safe DOM manipulation
  4502. function disableScript( elem ) {
  4503. elem.type = (jQuery.find.attr( elem, "type" ) !== null) + "/" + elem.type;
  4504. return elem;
  4505. }
  4506. function restoreScript( elem ) {
  4507. var match = rscriptTypeMasked.exec( elem.type );
  4508. if ( match ) {
  4509. elem.type = match[1];
  4510. } else {
  4511. elem.removeAttribute("type");
  4512. }
  4513. return elem;
  4514. }
  4515. // Mark scripts as having already been evaluated
  4516. function setGlobalEval( elems, refElements ) {
  4517. var elem,
  4518. i = 0;
  4519. for ( ; (elem = elems[i]) != null; i++ ) {
  4520. jQuery._data( elem, "globalEval", !refElements || jQuery._data( refElements[i], "globalEval" ) );
  4521. }
  4522. }
  4523. function cloneCopyEvent( src, dest ) {
  4524. if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
  4525. return;
  4526. }
  4527. var type, i, l,
  4528. oldData = jQuery._data( src ),
  4529. curData = jQuery._data( dest, oldData ),
  4530. events = oldData.events;
  4531. if ( events ) {
  4532. delete curData.handle;
  4533. curData.events = {};
  4534. for ( type in events ) {
  4535. for ( i = 0, l = events[ type ].length; i < l; i++ ) {
  4536. jQuery.event.add( dest, type, events[ type ][ i ] );
  4537. }
  4538. }
  4539. }
  4540. // make the cloned public data object a copy from the original
  4541. if ( curData.data ) {
  4542. curData.data = jQuery.extend( {}, curData.data );
  4543. }
  4544. }
  4545. function fixCloneNodeIssues( src, dest ) {
  4546. var nodeName, e, data;
  4547. // We do not need to do anything for non-Elements
  4548. if ( dest.nodeType !== 1 ) {
  4549. return;
  4550. }
  4551. nodeName = dest.nodeName.toLowerCase();
  4552. // IE6-8 copies events bound via attachEvent when using cloneNode.
  4553. if ( !support.noCloneEvent && dest[ jQuery.expando ] ) {
  4554. data = jQuery._data( dest );
  4555. for ( e in data.events ) {
  4556. jQuery.removeEvent( dest, e, data.handle );
  4557. }
  4558. // Event data gets referenced instead of copied if the expando gets copied too
  4559. dest.removeAttribute( jQuery.expando );
  4560. }
  4561. // IE blanks contents when cloning scripts, and tries to evaluate newly-set text
  4562. if ( nodeName === "script" && dest.text !== src.text ) {
  4563. disableScript( dest ).text = src.text;
  4564. restoreScript( dest );
  4565. // IE6-10 improperly clones children of object elements using classid.
  4566. // IE10 throws NoModificationAllowedError if parent is null, #12132.
  4567. } else if ( nodeName === "object" ) {
  4568. if ( dest.parentNode ) {
  4569. dest.outerHTML = src.outerHTML;
  4570. }
  4571. // This path appears unavoidable for IE9. When cloning an object
  4572. // element in IE9, the outerHTML strategy above is not sufficient.
  4573. // If the src has innerHTML and the destination does not,
  4574. // copy the src.innerHTML into the dest.innerHTML. #10324
  4575. if ( support.html5Clone && ( src.innerHTML && !jQuery.trim(dest.innerHTML) ) ) {
  4576. dest.innerHTML = src.innerHTML;
  4577. }
  4578. } else if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
  4579. // IE6-8 fails to persist the checked state of a cloned checkbox
  4580. // or radio button. Worse, IE6-7 fail to give the cloned element
  4581. // a checked appearance if the defaultChecked value isn't also set
  4582. dest.defaultChecked = dest.checked = src.checked;
  4583. // IE6-7 get confused and end up setting the value of a cloned
  4584. // checkbox/radio button to an empty string instead of "on"
  4585. if ( dest.value !== src.value ) {
  4586. dest.value = src.value;
  4587. }
  4588. // IE6-8 fails to return the selected option to the default selected
  4589. // state when cloning options
  4590. } else if ( nodeName === "option" ) {
  4591. dest.defaultSelected = dest.selected = src.defaultSelected;
  4592. // IE6-8 fails to set the defaultValue to the correct value when
  4593. // cloning other types of input fields
  4594. } else if ( nodeName === "input" || nodeName === "textarea" ) {
  4595. dest.defaultValue = src.defaultValue;
  4596. }
  4597. }
  4598. jQuery.extend({
  4599. clone: function( elem, dataAndEvents, deepDataAndEvents ) {
  4600. var destElements, node, clone, i, srcElements,
  4601. inPage = jQuery.contains( elem.ownerDocument, elem );
  4602. if ( support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
  4603. clone = elem.cloneNode( true );
  4604. // IE<=8 does not properly clone detached, unknown element nodes
  4605. } else {
  4606. fragmentDiv.innerHTML = elem.outerHTML;
  4607. fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
  4608. }
  4609. if ( (!support.noCloneEvent || !support.noCloneChecked) &&
  4610. (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
  4611. // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
  4612. destElements = getAll( clone );
  4613. srcElements = getAll( elem );
  4614. // Fix all IE cloning issues
  4615. for ( i = 0; (node = srcElements[i]) != null; ++i ) {
  4616. // Ensure that the destination node is not null; Fixes #9587
  4617. if ( destElements[i] ) {
  4618. fixCloneNodeIssues( node, destElements[i] );
  4619. }
  4620. }
  4621. }
  4622. // Copy the events from the original to the clone
  4623. if ( dataAndEvents ) {
  4624. if ( deepDataAndEvents ) {
  4625. srcElements = srcElements || getAll( elem );
  4626. destElements = destElements || getAll( clone );
  4627. for ( i = 0; (node = srcElements[i]) != null; i++ ) {
  4628. cloneCopyEvent( node, destElements[i] );
  4629. }
  4630. } else {
  4631. cloneCopyEvent( elem, clone );
  4632. }
  4633. }
  4634. // Preserve script evaluation history
  4635. destElements = getAll( clone, "script" );
  4636. if ( destElements.length > 0 ) {
  4637. setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
  4638. }
  4639. destElements = srcElements = node = null;
  4640. // Return the cloned set
  4641. return clone;
  4642. },
  4643. buildFragment: function( elems, context, scripts, selection ) {
  4644. var j, elem, contains,
  4645. tmp, tag, tbody, wrap,
  4646. l = elems.length,
  4647. // Ensure a safe fragment
  4648. safe = createSafeFragment( context ),
  4649. nodes = [],
  4650. i = 0;
  4651. for ( ; i < l; i++ ) {
  4652. elem = elems[ i ];
  4653. if ( elem || elem === 0 ) {
  4654. // Add nodes directly
  4655. if ( jQuery.type( elem ) === "object" ) {
  4656. jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
  4657. // Convert non-html into a text node
  4658. } else if ( !rhtml.test( elem ) ) {
  4659. nodes.push( context.createTextNode( elem ) );
  4660. // Convert html into DOM nodes
  4661. } else {
  4662. tmp = tmp || safe.appendChild( context.createElement("div") );
  4663. // Deserialize a standard representation
  4664. tag = (rtagName.exec( elem ) || [ "", "" ])[ 1 ].toLowerCase();
  4665. wrap = wrapMap[ tag ] || wrapMap._default;
  4666. tmp.innerHTML = wrap[1] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[2];
  4667. // Descend through wrappers to the right content
  4668. j = wrap[0];
  4669. while ( j-- ) {
  4670. tmp = tmp.lastChild;
  4671. }
  4672. // Manually add leading whitespace removed by IE
  4673. if ( !support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
  4674. nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[0] ) );
  4675. }
  4676. // Remove IE's autoinserted <tbody> from table fragments
  4677. if ( !support.tbody ) {
  4678. // String was a <table>, *may* have spurious <tbody>
  4679. elem = tag === "table" && !rtbody.test( elem ) ?
  4680. tmp.firstChild :
  4681. // String was a bare <thead> or <tfoot>
  4682. wrap[1] === "<table>" && !rtbody.test( elem ) ?
  4683. tmp :
  4684. 0;
  4685. j = elem && elem.childNodes.length;
  4686. while ( j-- ) {
  4687. if ( jQuery.nodeName( (tbody = elem.childNodes[j]), "tbody" ) && !tbody.childNodes.length ) {
  4688. elem.removeChild( tbody );
  4689. }
  4690. }
  4691. }
  4692. jQuery.merge( nodes, tmp.childNodes );
  4693. // Fix #12392 for WebKit and IE > 9
  4694. tmp.textContent = "";
  4695. // Fix #12392 for oldIE
  4696. while ( tmp.firstChild ) {
  4697. tmp.removeChild( tmp.firstChild );
  4698. }
  4699. // Remember the top-level container for proper cleanup
  4700. tmp = safe.lastChild;
  4701. }
  4702. }
  4703. }
  4704. // Fix #11356: Clear elements from fragment
  4705. if ( tmp ) {
  4706. safe.removeChild( tmp );
  4707. }
  4708. // Reset defaultChecked for any radios and checkboxes
  4709. // about to be appended to the DOM in IE 6/7 (#8060)
  4710. if ( !support.appendChecked ) {
  4711. jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked );
  4712. }
  4713. i = 0;
  4714. while ( (elem = nodes[ i++ ]) ) {
  4715. // #4087 - If origin and destination elements are the same, and this is
  4716. // that element, do not do anything
  4717. if ( selection && jQuery.inArray( elem, selection ) !== -1 ) {
  4718. continue;
  4719. }
  4720. contains = jQuery.contains( elem.ownerDocument, elem );
  4721. // Append to fragment
  4722. tmp = getAll( safe.appendChild( elem ), "script" );
  4723. // Preserve script evaluation history
  4724. if ( contains ) {
  4725. setGlobalEval( tmp );
  4726. }
  4727. // Capture executables
  4728. if ( scripts ) {
  4729. j = 0;
  4730. while ( (elem = tmp[ j++ ]) ) {
  4731. if ( rscriptType.test( elem.type || "" ) ) {
  4732. scripts.push( elem );
  4733. }
  4734. }
  4735. }
  4736. }
  4737. tmp = null;
  4738. return safe;
  4739. },
  4740. cleanData: function( elems, /* internal */ acceptData ) {
  4741. var elem, type, id, data,
  4742. i = 0,
  4743. internalKey = jQuery.expando,
  4744. cache = jQuery.cache,
  4745. deleteExpando = support.deleteExpando,
  4746. special = jQuery.event.special;
  4747. for ( ; (elem = elems[i]) != null; i++ ) {
  4748. if ( acceptData || jQuery.acceptData( elem ) ) {
  4749. id = elem[ internalKey ];
  4750. data = id && cache[ id ];
  4751. if ( data ) {
  4752. if ( data.events ) {
  4753. for ( type in data.events ) {
  4754. if ( special[ type ] ) {
  4755. jQuery.event.remove( elem, type );
  4756. // This is a shortcut to avoid jQuery.event.remove's overhead
  4757. } else {
  4758. jQuery.removeEvent( elem, type, data.handle );
  4759. }
  4760. }
  4761. }
  4762. // Remove cache only if it was not already removed by jQuery.event.remove
  4763. if ( cache[ id ] ) {
  4764. delete cache[ id ];
  4765. // IE does not allow us to delete expando properties from nodes,
  4766. // nor does it have a removeAttribute function on Document nodes;
  4767. // we must handle all of these cases
  4768. if ( deleteExpando ) {
  4769. delete elem[ internalKey ];
  4770. } else if ( typeof elem.removeAttribute !== strundefined ) {
  4771. elem.removeAttribute( internalKey );
  4772. } else {
  4773. elem[ internalKey ] = null;
  4774. }
  4775. deletedIds.push( id );
  4776. }
  4777. }
  4778. }
  4779. }
  4780. }
  4781. });
  4782. jQuery.fn.extend({
  4783. text: function( value ) {
  4784. return access( this, function( value ) {
  4785. return value === undefined ?
  4786. jQuery.text( this ) :
  4787. this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) );
  4788. }, null, value, arguments.length );
  4789. },
  4790. append: function() {
  4791. return this.domManip( arguments, function( elem ) {
  4792. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  4793. var target = manipulationTarget( this, elem );
  4794. target.appendChild( elem );
  4795. }
  4796. });
  4797. },
  4798. prepend: function() {
  4799. return this.domManip( arguments, function( elem ) {
  4800. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  4801. var target = manipulationTarget( this, elem );
  4802. target.insertBefore( elem, target.firstChild );
  4803. }
  4804. });
  4805. },
  4806. before: function() {
  4807. return this.domManip( arguments, function( elem ) {
  4808. if ( this.parentNode ) {
  4809. this.parentNode.insertBefore( elem, this );
  4810. }
  4811. });
  4812. },
  4813. after: function() {
  4814. return this.domManip( arguments, function( elem ) {
  4815. if ( this.parentNode ) {
  4816. this.parentNode.insertBefore( elem, this.nextSibling );
  4817. }
  4818. });
  4819. },
  4820. remove: function( selector, keepData /* Internal Use Only */ ) {
  4821. var elem,
  4822. elems = selector ? jQuery.filter( selector, this ) : this,
  4823. i = 0;
  4824. for ( ; (elem = elems[i]) != null; i++ ) {
  4825. if ( !keepData && elem.nodeType === 1 ) {
  4826. jQuery.cleanData( getAll( elem ) );
  4827. }
  4828. if ( elem.parentNode ) {
  4829. if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
  4830. setGlobalEval( getAll( elem, "script" ) );
  4831. }
  4832. elem.parentNode.removeChild( elem );
  4833. }
  4834. }
  4835. return this;
  4836. },
  4837. empty: function() {
  4838. var elem,
  4839. i = 0;
  4840. for ( ; (elem = this[i]) != null; i++ ) {
  4841. // Remove element nodes and prevent memory leaks
  4842. if ( elem.nodeType === 1 ) {
  4843. jQuery.cleanData( getAll( elem, false ) );
  4844. }
  4845. // Remove any remaining nodes
  4846. while ( elem.firstChild ) {
  4847. elem.removeChild( elem.firstChild );
  4848. }
  4849. // If this is a select, ensure that it displays empty (#12336)
  4850. // Support: IE<9
  4851. if ( elem.options && jQuery.nodeName( elem, "select" ) ) {
  4852. elem.options.length = 0;
  4853. }
  4854. }
  4855. return this;
  4856. },
  4857. clone: function( dataAndEvents, deepDataAndEvents ) {
  4858. dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
  4859. deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
  4860. return this.map(function() {
  4861. return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
  4862. });
  4863. },
  4864. html: function( value ) {
  4865. return access( this, function( value ) {
  4866. var elem = this[ 0 ] || {},
  4867. i = 0,
  4868. l = this.length;
  4869. if ( value === undefined ) {
  4870. return elem.nodeType === 1 ?
  4871. elem.innerHTML.replace( rinlinejQuery, "" ) :
  4872. undefined;
  4873. }
  4874. // See if we can take a shortcut and just use innerHTML
  4875. if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
  4876. ( support.htmlSerialize || !rnoshimcache.test( value ) ) &&
  4877. ( support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
  4878. !wrapMap[ (rtagName.exec( value ) || [ "", "" ])[ 1 ].toLowerCase() ] ) {
  4879. value = value.replace( rxhtmlTag, "<$1></$2>" );
  4880. try {
  4881. for (; i < l; i++ ) {
  4882. // Remove element nodes and prevent memory leaks
  4883. elem = this[i] || {};
  4884. if ( elem.nodeType === 1 ) {
  4885. jQuery.cleanData( getAll( elem, false ) );
  4886. elem.innerHTML = value;
  4887. }
  4888. }
  4889. elem = 0;
  4890. // If using innerHTML throws an exception, use the fallback method
  4891. } catch(e) {}
  4892. }
  4893. if ( elem ) {
  4894. this.empty().append( value );
  4895. }
  4896. }, null, value, arguments.length );
  4897. },
  4898. replaceWith: function() {
  4899. var arg = arguments[ 0 ];
  4900. // Make the changes, replacing each context element with the new content
  4901. this.domManip( arguments, function( elem ) {
  4902. arg = this.parentNode;
  4903. jQuery.cleanData( getAll( this ) );
  4904. if ( arg ) {
  4905. arg.replaceChild( elem, this );
  4906. }
  4907. });
  4908. // Force removal if there was no new content (e.g., from empty arguments)
  4909. return arg && (arg.length || arg.nodeType) ? this : this.remove();
  4910. },
  4911. detach: function( selector ) {
  4912. return this.remove( selector, true );
  4913. },
  4914. domManip: function( args, callback ) {
  4915. // Flatten any nested arrays
  4916. args = concat.apply( [], args );
  4917. var first, node, hasScripts,
  4918. scripts, doc, fragment,
  4919. i = 0,
  4920. l = this.length,
  4921. set = this,
  4922. iNoClone = l - 1,
  4923. value = args[0],
  4924. isFunction = jQuery.isFunction( value );
  4925. // We can't cloneNode fragments that contain checked, in WebKit
  4926. if ( isFunction ||
  4927. ( l > 1 && typeof value === "string" &&
  4928. !support.checkClone && rchecked.test( value ) ) ) {
  4929. return this.each(function( index ) {
  4930. var self = set.eq( index );
  4931. if ( isFunction ) {
  4932. args[0] = value.call( this, index, self.html() );
  4933. }
  4934. self.domManip( args, callback );
  4935. });
  4936. }
  4937. if ( l ) {
  4938. fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this );
  4939. first = fragment.firstChild;
  4940. if ( fragment.childNodes.length === 1 ) {
  4941. fragment = first;
  4942. }
  4943. if ( first ) {
  4944. scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
  4945. hasScripts = scripts.length;
  4946. // Use the original fragment for the last item instead of the first because it can end up
  4947. // being emptied incorrectly in certain situations (#8070).
  4948. for ( ; i < l; i++ ) {
  4949. node = fragment;
  4950. if ( i !== iNoClone ) {
  4951. node = jQuery.clone( node, true, true );
  4952. // Keep references to cloned scripts for later restoration
  4953. if ( hasScripts ) {
  4954. jQuery.merge( scripts, getAll( node, "script" ) );
  4955. }
  4956. }
  4957. callback.call( this[i], node, i );
  4958. }
  4959. if ( hasScripts ) {
  4960. doc = scripts[ scripts.length - 1 ].ownerDocument;
  4961. // Reenable scripts
  4962. jQuery.map( scripts, restoreScript );
  4963. // Evaluate executable scripts on first document insertion
  4964. for ( i = 0; i < hasScripts; i++ ) {
  4965. node = scripts[ i ];
  4966. if ( rscriptType.test( node.type || "" ) &&
  4967. !jQuery._data( node, "globalEval" ) && jQuery.contains( doc, node ) ) {
  4968. if ( node.src ) {
  4969. // Optional AJAX dependency, but won't run scripts if not present
  4970. if ( jQuery._evalUrl ) {
  4971. jQuery._evalUrl( node.src );
  4972. }
  4973. } else {
  4974. jQuery.globalEval( ( node.text || node.textContent || node.innerHTML || "" ).replace( rcleanScript, "" ) );
  4975. }
  4976. }
  4977. }
  4978. }
  4979. // Fix #11809: Avoid leaking memory
  4980. fragment = first = null;
  4981. }
  4982. }
  4983. return this;
  4984. }
  4985. });
  4986. jQuery.each({
  4987. appendTo: "append",
  4988. prependTo: "prepend",
  4989. insertBefore: "before",
  4990. insertAfter: "after",
  4991. replaceAll: "replaceWith"
  4992. }, function( name, original ) {
  4993. jQuery.fn[ name ] = function( selector ) {
  4994. var elems,
  4995. i = 0,
  4996. ret = [],
  4997. insert = jQuery( selector ),
  4998. last = insert.length - 1;
  4999. for ( ; i <= last; i++ ) {
  5000. elems = i === last ? this : this.clone(true);
  5001. jQuery( insert[i] )[ original ]( elems );
  5002. // Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get()
  5003. push.apply( ret, elems.get() );
  5004. }
  5005. return this.pushStack( ret );
  5006. };
  5007. });
  5008. var iframe,
  5009. elemdisplay = {};
  5010. /**
  5011. * Retrieve the actual display of a element
  5012. * @param {String} name nodeName of the element
  5013. * @param {Object} doc Document object
  5014. */
  5015. // Called only from within defaultDisplay
  5016. function actualDisplay( name, doc ) {
  5017. var style,
  5018. elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
  5019. // getDefaultComputedStyle might be reliably used only on attached element
  5020. display = window.getDefaultComputedStyle && ( style = window.getDefaultComputedStyle( elem[ 0 ] ) ) ?
  5021. // Use of this method is a temporary fix (more like optmization) until something better comes along,
  5022. // since it was removed from specification and supported only in FF
  5023. style.display : jQuery.css( elem[ 0 ], "display" );
  5024. // We don't have any data stored on the element,
  5025. // so use "detach" method as fast way to get rid of the element
  5026. elem.detach();
  5027. return display;
  5028. }
  5029. /**
  5030. * Try to determine the default display value of an element
  5031. * @param {String} nodeName
  5032. */
  5033. function defaultDisplay( nodeName ) {
  5034. var doc = document,
  5035. display = elemdisplay[ nodeName ];
  5036. if ( !display ) {
  5037. display = actualDisplay( nodeName, doc );
  5038. // If the simple way fails, read from inside an iframe
  5039. if ( display === "none" || !display ) {
  5040. // Use the already-created iframe if possible
  5041. iframe = (iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" )).appendTo( doc.documentElement );
  5042. // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
  5043. doc = ( iframe[ 0 ].contentWindow || iframe[ 0 ].contentDocument ).document;
  5044. // Support: IE
  5045. doc.write();
  5046. doc.close();
  5047. display = actualDisplay( nodeName, doc );
  5048. iframe.detach();
  5049. }
  5050. // Store the correct default display
  5051. elemdisplay[ nodeName ] = display;
  5052. }
  5053. return display;
  5054. }
  5055. (function() {
  5056. var shrinkWrapBlocksVal;
  5057. support.shrinkWrapBlocks = function() {
  5058. if ( shrinkWrapBlocksVal != null ) {
  5059. return shrinkWrapBlocksVal;
  5060. }
  5061. // Will be changed later if needed.
  5062. shrinkWrapBlocksVal = false;
  5063. // Minified: var b,c,d
  5064. var div, body, container;
  5065. body = document.getElementsByTagName( "body" )[ 0 ];
  5066. if ( !body || !body.style ) {
  5067. // Test fired too early or in an unsupported environment, exit.
  5068. return;
  5069. }
  5070. // Setup
  5071. div = document.createElement( "div" );
  5072. container = document.createElement( "div" );
  5073. container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
  5074. body.appendChild( container ).appendChild( div );
  5075. // Support: IE6
  5076. // Check if elements with layout shrink-wrap their children
  5077. if ( typeof div.style.zoom !== strundefined ) {
  5078. // Reset CSS: box-sizing; display; margin; border
  5079. div.style.cssText =
  5080. // Support: Firefox<29, Android 2.3
  5081. // Vendor-prefix box-sizing
  5082. "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
  5083. "box-sizing:content-box;display:block;margin:0;border:0;" +
  5084. "padding:1px;width:1px;zoom:1";
  5085. div.appendChild( document.createElement( "div" ) ).style.width = "5px";
  5086. shrinkWrapBlocksVal = div.offsetWidth !== 3;
  5087. }
  5088. body.removeChild( container );
  5089. return shrinkWrapBlocksVal;
  5090. };
  5091. })();
  5092. var rmargin = (/^margin/);
  5093. var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
  5094. var getStyles, curCSS,
  5095. rposition = /^(top|right|bottom|left)$/;
  5096. if ( window.getComputedStyle ) {
  5097. getStyles = function( elem ) {
  5098. return elem.ownerDocument.defaultView.getComputedStyle( elem, null );
  5099. };
  5100. curCSS = function( elem, name, computed ) {
  5101. var width, minWidth, maxWidth, ret,
  5102. style = elem.style;
  5103. computed = computed || getStyles( elem );
  5104. // getPropertyValue is only needed for .css('filter') in IE9, see #12537
  5105. ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined;
  5106. if ( computed ) {
  5107. if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
  5108. ret = jQuery.style( elem, name );
  5109. }
  5110. // A tribute to the "awesome hack by Dean Edwards"
  5111. // Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right
  5112. // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
  5113. // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
  5114. if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
  5115. // Remember the original values
  5116. width = style.width;
  5117. minWidth = style.minWidth;
  5118. maxWidth = style.maxWidth;
  5119. // Put in the new values to get a computed value out
  5120. style.minWidth = style.maxWidth = style.width = ret;
  5121. ret = computed.width;
  5122. // Revert the changed values
  5123. style.width = width;
  5124. style.minWidth = minWidth;
  5125. style.maxWidth = maxWidth;
  5126. }
  5127. }
  5128. // Support: IE
  5129. // IE returns zIndex value as an integer.
  5130. return ret === undefined ?
  5131. ret :
  5132. ret + "";
  5133. };
  5134. } else if ( document.documentElement.currentStyle ) {
  5135. getStyles = function( elem ) {
  5136. return elem.currentStyle;
  5137. };
  5138. curCSS = function( elem, name, computed ) {
  5139. var left, rs, rsLeft, ret,
  5140. style = elem.style;
  5141. computed = computed || getStyles( elem );
  5142. ret = computed ? computed[ name ] : undefined;
  5143. // Avoid setting ret to empty string here
  5144. // so we don't default to auto
  5145. if ( ret == null && style && style[ name ] ) {
  5146. ret = style[ name ];
  5147. }
  5148. // From the awesome hack by Dean Edwards
  5149. // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
  5150. // If we're not dealing with a regular pixel number
  5151. // but a number that has a weird ending, we need to convert it to pixels
  5152. // but not position css attributes, as those are proportional to the parent element instead
  5153. // and we can't measure the parent instead because it might trigger a "stacking dolls" problem
  5154. if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) {
  5155. // Remember the original values
  5156. left = style.left;
  5157. rs = elem.runtimeStyle;
  5158. rsLeft = rs && rs.left;
  5159. // Put in the new values to get a computed value out
  5160. if ( rsLeft ) {
  5161. rs.left = elem.currentStyle.left;
  5162. }
  5163. style.left = name === "fontSize" ? "1em" : ret;
  5164. ret = style.pixelLeft + "px";
  5165. // Revert the changed values
  5166. style.left = left;
  5167. if ( rsLeft ) {
  5168. rs.left = rsLeft;
  5169. }
  5170. }
  5171. // Support: IE
  5172. // IE returns zIndex value as an integer.
  5173. return ret === undefined ?
  5174. ret :
  5175. ret + "" || "auto";
  5176. };
  5177. }
  5178. function addGetHookIf( conditionFn, hookFn ) {
  5179. // Define the hook, we'll check on the first run if it's really needed.
  5180. return {
  5181. get: function() {
  5182. var condition = conditionFn();
  5183. if ( condition == null ) {
  5184. // The test was not ready at this point; screw the hook this time
  5185. // but check again when needed next time.
  5186. return;
  5187. }
  5188. if ( condition ) {
  5189. // Hook not needed (or it's not possible to use it due to missing dependency),
  5190. // remove it.
  5191. // Since there are no other hooks for marginRight, remove the whole object.
  5192. delete this.get;
  5193. return;
  5194. }
  5195. // Hook needed; redefine it so that the support test is not executed again.
  5196. return (this.get = hookFn).apply( this, arguments );
  5197. }
  5198. };
  5199. }
  5200. (function() {
  5201. // Minified: var b,c,d,e,f,g, h,i
  5202. var div, style, a, pixelPositionVal, boxSizingReliableVal,
  5203. reliableHiddenOffsetsVal, reliableMarginRightVal;
  5204. // Setup
  5205. div = document.createElement( "div" );
  5206. div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
  5207. a = div.getElementsByTagName( "a" )[ 0 ];
  5208. style = a && a.style;
  5209. // Finish early in limited (non-browser) environments
  5210. if ( !style ) {
  5211. return;
  5212. }
  5213. style.cssText = "float:left;opacity:.5";
  5214. // Support: IE<9
  5215. // Make sure that element opacity exists (as opposed to filter)
  5216. support.opacity = style.opacity === "0.5";
  5217. // Verify style float existence
  5218. // (IE uses styleFloat instead of cssFloat)
  5219. support.cssFloat = !!style.cssFloat;
  5220. div.style.backgroundClip = "content-box";
  5221. div.cloneNode( true ).style.backgroundClip = "";
  5222. support.clearCloneStyle = div.style.backgroundClip === "content-box";
  5223. // Support: Firefox<29, Android 2.3
  5224. // Vendor-prefix box-sizing
  5225. support.boxSizing = style.boxSizing === "" || style.MozBoxSizing === "" ||
  5226. style.WebkitBoxSizing === "";
  5227. jQuery.extend(support, {
  5228. reliableHiddenOffsets: function() {
  5229. if ( reliableHiddenOffsetsVal == null ) {
  5230. computeStyleTests();
  5231. }
  5232. return reliableHiddenOffsetsVal;
  5233. },
  5234. boxSizingReliable: function() {
  5235. if ( boxSizingReliableVal == null ) {
  5236. computeStyleTests();
  5237. }
  5238. return boxSizingReliableVal;
  5239. },
  5240. pixelPosition: function() {
  5241. if ( pixelPositionVal == null ) {
  5242. computeStyleTests();
  5243. }
  5244. return pixelPositionVal;
  5245. },
  5246. // Support: Android 2.3
  5247. reliableMarginRight: function() {
  5248. if ( reliableMarginRightVal == null ) {
  5249. computeStyleTests();
  5250. }
  5251. return reliableMarginRightVal;
  5252. }
  5253. });
  5254. function computeStyleTests() {
  5255. // Minified: var b,c,d,j
  5256. var div, body, container, contents;
  5257. body = document.getElementsByTagName( "body" )[ 0 ];
  5258. if ( !body || !body.style ) {
  5259. // Test fired too early or in an unsupported environment, exit.
  5260. return;
  5261. }
  5262. // Setup
  5263. div = document.createElement( "div" );
  5264. container = document.createElement( "div" );
  5265. container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
  5266. body.appendChild( container ).appendChild( div );
  5267. div.style.cssText =
  5268. // Support: Firefox<29, Android 2.3
  5269. // Vendor-prefix box-sizing
  5270. "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;" +
  5271. "box-sizing:border-box;display:block;margin-top:1%;top:1%;" +
  5272. "border:1px;padding:1px;width:4px;position:absolute";
  5273. // Support: IE<9
  5274. // Assume reasonable values in the absence of getComputedStyle
  5275. pixelPositionVal = boxSizingReliableVal = false;
  5276. reliableMarginRightVal = true;
  5277. // Check for getComputedStyle so that this code is not run in IE<9.
  5278. if ( window.getComputedStyle ) {
  5279. pixelPositionVal = ( window.getComputedStyle( div, null ) || {} ).top !== "1%";
  5280. boxSizingReliableVal =
  5281. ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px";
  5282. // Support: Android 2.3
  5283. // Div with explicit width and no margin-right incorrectly
  5284. // gets computed margin-right based on width of container (#3333)
  5285. // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
  5286. contents = div.appendChild( document.createElement( "div" ) );
  5287. // Reset CSS: box-sizing; display; margin; border; padding
  5288. contents.style.cssText = div.style.cssText =
  5289. // Support: Firefox<29, Android 2.3
  5290. // Vendor-prefix box-sizing
  5291. "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
  5292. "box-sizing:content-box;display:block;margin:0;border:0;padding:0";
  5293. contents.style.marginRight = contents.style.width = "0";
  5294. div.style.width = "1px";
  5295. reliableMarginRightVal =
  5296. !parseFloat( ( window.getComputedStyle( contents, null ) || {} ).marginRight );
  5297. }
  5298. // Support: IE8
  5299. // Check if table cells still have offsetWidth/Height when they are set
  5300. // to display:none and there are still other visible table cells in a
  5301. // table row; if so, offsetWidth/Height are not reliable for use when
  5302. // determining if an element has been hidden directly using
  5303. // display:none (it is still safe to use offsets if a parent element is
  5304. // hidden; don safety goggles and see bug #4512 for more information).
  5305. div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";
  5306. contents = div.getElementsByTagName( "td" );
  5307. contents[ 0 ].style.cssText = "margin:0;border:0;padding:0;display:none";
  5308. reliableHiddenOffsetsVal = contents[ 0 ].offsetHeight === 0;
  5309. if ( reliableHiddenOffsetsVal ) {
  5310. contents[ 0 ].style.display = "";
  5311. contents[ 1 ].style.display = "none";
  5312. reliableHiddenOffsetsVal = contents[ 0 ].offsetHeight === 0;
  5313. }
  5314. body.removeChild( container );
  5315. }
  5316. })();
  5317. // A method for quickly swapping in/out CSS properties to get correct calculations.
  5318. jQuery.swap = function( elem, options, callback, args ) {
  5319. var ret, name,
  5320. old = {};
  5321. // Remember the old values, and insert the new ones
  5322. for ( name in options ) {
  5323. old[ name ] = elem.style[ name ];
  5324. elem.style[ name ] = options[ name ];
  5325. }
  5326. ret = callback.apply( elem, args || [] );
  5327. // Revert the old values
  5328. for ( name in options ) {
  5329. elem.style[ name ] = old[ name ];
  5330. }
  5331. return ret;
  5332. };
  5333. var
  5334. ralpha = /alpha\([^)]*\)/i,
  5335. ropacity = /opacity\s*=\s*([^)]*)/,
  5336. // swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
  5337. // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
  5338. rdisplayswap = /^(none|table(?!-c[ea]).+)/,
  5339. rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ),
  5340. rrelNum = new RegExp( "^([+-])=(" + pnum + ")", "i" ),
  5341. cssShow = { position: "absolute", visibility: "hidden", display: "block" },
  5342. cssNormalTransform = {
  5343. letterSpacing: "0",
  5344. fontWeight: "400"
  5345. },
  5346. cssPrefixes = [ "Webkit", "O", "Moz", "ms" ];
  5347. // return a css property mapped to a potentially vendor prefixed property
  5348. function vendorPropName( style, name ) {
  5349. // shortcut for names that are not vendor prefixed
  5350. if ( name in style ) {
  5351. return name;
  5352. }
  5353. // check for vendor prefixed names
  5354. var capName = name.charAt(0).toUpperCase() + name.slice(1),
  5355. origName = name,
  5356. i = cssPrefixes.length;
  5357. while ( i-- ) {
  5358. name = cssPrefixes[ i ] + capName;
  5359. if ( name in style ) {
  5360. return name;
  5361. }
  5362. }
  5363. return origName;
  5364. }
  5365. function showHide( elements, show ) {
  5366. var display, elem, hidden,
  5367. values = [],
  5368. index = 0,
  5369. length = elements.length;
  5370. for ( ; index < length; index++ ) {
  5371. elem = elements[ index ];
  5372. if ( !elem.style ) {
  5373. continue;
  5374. }
  5375. values[ index ] = jQuery._data( elem, "olddisplay" );
  5376. display = elem.style.display;
  5377. if ( show ) {
  5378. // Reset the inline display of this element to learn if it is
  5379. // being hidden by cascaded rules or not
  5380. if ( !values[ index ] && display === "none" ) {
  5381. elem.style.display = "";
  5382. }
  5383. // Set elements which have been overridden with display: none
  5384. // in a stylesheet to whatever the default browser style is
  5385. // for such an element
  5386. if ( elem.style.display === "" && isHidden( elem ) ) {
  5387. values[ index ] = jQuery._data( elem, "olddisplay", defaultDisplay(elem.nodeName) );
  5388. }
  5389. } else {
  5390. hidden = isHidden( elem );
  5391. if ( display && display !== "none" || !hidden ) {
  5392. jQuery._data( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) );
  5393. }
  5394. }
  5395. }
  5396. // Set the display of most of the elements in a second loop
  5397. // to avoid the constant reflow
  5398. for ( index = 0; index < length; index++ ) {
  5399. elem = elements[ index ];
  5400. if ( !elem.style ) {
  5401. continue;
  5402. }
  5403. if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
  5404. elem.style.display = show ? values[ index ] || "" : "none";
  5405. }
  5406. }
  5407. return elements;
  5408. }
  5409. function setPositiveNumber( elem, value, subtract ) {
  5410. var matches = rnumsplit.exec( value );
  5411. return matches ?
  5412. // Guard against undefined "subtract", e.g., when used as in cssHooks
  5413. Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
  5414. value;
  5415. }
  5416. function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
  5417. var i = extra === ( isBorderBox ? "border" : "content" ) ?
  5418. // If we already have the right measurement, avoid augmentation
  5419. 4 :
  5420. // Otherwise initialize for horizontal or vertical properties
  5421. name === "width" ? 1 : 0,
  5422. val = 0;
  5423. for ( ; i < 4; i += 2 ) {
  5424. // both box models exclude margin, so add it if we want it
  5425. if ( extra === "margin" ) {
  5426. val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
  5427. }
  5428. if ( isBorderBox ) {
  5429. // border-box includes padding, so remove it if we want content
  5430. if ( extra === "content" ) {
  5431. val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  5432. }
  5433. // at this point, extra isn't border nor margin, so remove border
  5434. if ( extra !== "margin" ) {
  5435. val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  5436. }
  5437. } else {
  5438. // at this point, extra isn't content, so add padding
  5439. val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  5440. // at this point, extra isn't content nor padding, so add border
  5441. if ( extra !== "padding" ) {
  5442. val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  5443. }
  5444. }
  5445. }
  5446. return val;
  5447. }
  5448. function getWidthOrHeight( elem, name, extra ) {
  5449. // Start with offset property, which is equivalent to the border-box value
  5450. var valueIsBorderBox = true,
  5451. val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
  5452. styles = getStyles( elem ),
  5453. isBorderBox = support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
  5454. // some non-html elements return undefined for offsetWidth, so check for null/undefined
  5455. // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
  5456. // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
  5457. if ( val <= 0 || val == null ) {
  5458. // Fall back to computed then uncomputed css if necessary
  5459. val = curCSS( elem, name, styles );
  5460. if ( val < 0 || val == null ) {
  5461. val = elem.style[ name ];
  5462. }
  5463. // Computed unit is not pixels. Stop here and return.
  5464. if ( rnumnonpx.test(val) ) {
  5465. return val;
  5466. }
  5467. // we need the check for style in case a browser which returns unreliable values
  5468. // for getComputedStyle silently falls back to the reliable elem.style
  5469. valueIsBorderBox = isBorderBox && ( support.boxSizingReliable() || val === elem.style[ name ] );
  5470. // Normalize "", auto, and prepare for extra
  5471. val = parseFloat( val ) || 0;
  5472. }
  5473. // use the active box-sizing model to add/subtract irrelevant styles
  5474. return ( val +
  5475. augmentWidthOrHeight(
  5476. elem,
  5477. name,
  5478. extra || ( isBorderBox ? "border" : "content" ),
  5479. valueIsBorderBox,
  5480. styles
  5481. )
  5482. ) + "px";
  5483. }
  5484. jQuery.extend({
  5485. // Add in style property hooks for overriding the default
  5486. // behavior of getting and setting a style property
  5487. cssHooks: {
  5488. opacity: {
  5489. get: function( elem, computed ) {
  5490. if ( computed ) {
  5491. // We should always get a number back from opacity
  5492. var ret = curCSS( elem, "opacity" );
  5493. return ret === "" ? "1" : ret;
  5494. }
  5495. }
  5496. }
  5497. },
  5498. // Don't automatically add "px" to these possibly-unitless properties
  5499. cssNumber: {
  5500. "columnCount": true,
  5501. "fillOpacity": true,
  5502. "flexGrow": true,
  5503. "flexShrink": true,
  5504. "fontWeight": true,
  5505. "lineHeight": true,
  5506. "opacity": true,
  5507. "order": true,
  5508. "orphans": true,
  5509. "widows": true,
  5510. "zIndex": true,
  5511. "zoom": true
  5512. },
  5513. // Add in properties whose names you wish to fix before
  5514. // setting or getting the value
  5515. cssProps: {
  5516. // normalize float css property
  5517. "float": support.cssFloat ? "cssFloat" : "styleFloat"
  5518. },
  5519. // Get and set the style property on a DOM Node
  5520. style: function( elem, name, value, extra ) {
  5521. // Don't set styles on text and comment nodes
  5522. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
  5523. return;
  5524. }
  5525. // Make sure that we're working with the right name
  5526. var ret, type, hooks,
  5527. origName = jQuery.camelCase( name ),
  5528. style = elem.style;
  5529. name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
  5530. // gets hook for the prefixed version
  5531. // followed by the unprefixed version
  5532. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  5533. // Check if we're setting a value
  5534. if ( value !== undefined ) {
  5535. type = typeof value;
  5536. // convert relative number strings (+= or -=) to relative numbers. #7345
  5537. if ( type === "string" && (ret = rrelNum.exec( value )) ) {
  5538. value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
  5539. // Fixes bug #9237
  5540. type = "number";
  5541. }
  5542. // Make sure that null and NaN values aren't set. See: #7116
  5543. if ( value == null || value !== value ) {
  5544. return;
  5545. }
  5546. // If a number was passed in, add 'px' to the (except for certain CSS properties)
  5547. if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
  5548. value += "px";
  5549. }
  5550. // Fixes #8908, it can be done more correctly by specifing setters in cssHooks,
  5551. // but it would mean to define eight (for every problematic property) identical functions
  5552. if ( !support.clearCloneStyle && value === "" && name.indexOf("background") === 0 ) {
  5553. style[ name ] = "inherit";
  5554. }
  5555. // If a hook was provided, use that value, otherwise just set the specified value
  5556. if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
  5557. // Support: IE
  5558. // Swallow errors from 'invalid' CSS values (#5509)
  5559. try {
  5560. style[ name ] = value;
  5561. } catch(e) {}
  5562. }
  5563. } else {
  5564. // If a hook was provided get the non-computed value from there
  5565. if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
  5566. return ret;
  5567. }
  5568. // Otherwise just get the value from the style object
  5569. return style[ name ];
  5570. }
  5571. },
  5572. css: function( elem, name, extra, styles ) {
  5573. var num, val, hooks,
  5574. origName = jQuery.camelCase( name );
  5575. // Make sure that we're working with the right name
  5576. name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
  5577. // gets hook for the prefixed version
  5578. // followed by the unprefixed version
  5579. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  5580. // If a hook was provided get the computed value from there
  5581. if ( hooks && "get" in hooks ) {
  5582. val = hooks.get( elem, true, extra );
  5583. }
  5584. // Otherwise, if a way to get the computed value exists, use that
  5585. if ( val === undefined ) {
  5586. val = curCSS( elem, name, styles );
  5587. }
  5588. //convert "normal" to computed value
  5589. if ( val === "normal" && name in cssNormalTransform ) {
  5590. val = cssNormalTransform[ name ];
  5591. }
  5592. // Return, converting to number if forced or a qualifier was provided and val looks numeric
  5593. if ( extra === "" || extra ) {
  5594. num = parseFloat( val );
  5595. return extra === true || jQuery.isNumeric( num ) ? num || 0 : val;
  5596. }
  5597. return val;
  5598. }
  5599. });
  5600. jQuery.each([ "height", "width" ], function( i, name ) {
  5601. jQuery.cssHooks[ name ] = {
  5602. get: function( elem, computed, extra ) {
  5603. if ( computed ) {
  5604. // certain elements can have dimension info if we invisibly show them
  5605. // however, it must have a current display style that would benefit from this
  5606. return rdisplayswap.test( jQuery.css( elem, "display" ) ) && elem.offsetWidth === 0 ?
  5607. jQuery.swap( elem, cssShow, function() {
  5608. return getWidthOrHeight( elem, name, extra );
  5609. }) :
  5610. getWidthOrHeight( elem, name, extra );
  5611. }
  5612. },
  5613. set: function( elem, value, extra ) {
  5614. var styles = extra && getStyles( elem );
  5615. return setPositiveNumber( elem, value, extra ?
  5616. augmentWidthOrHeight(
  5617. elem,
  5618. name,
  5619. extra,
  5620. support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  5621. styles
  5622. ) : 0
  5623. );
  5624. }
  5625. };
  5626. });
  5627. if ( !support.opacity ) {
  5628. jQuery.cssHooks.opacity = {
  5629. get: function( elem, computed ) {
  5630. // IE uses filters for opacity
  5631. return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
  5632. ( 0.01 * parseFloat( RegExp.$1 ) ) + "" :
  5633. computed ? "1" : "";
  5634. },
  5635. set: function( elem, value ) {
  5636. var style = elem.style,
  5637. currentStyle = elem.currentStyle,
  5638. opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
  5639. filter = currentStyle && currentStyle.filter || style.filter || "";
  5640. // IE has trouble with opacity if it does not have layout
  5641. // Force it by setting the zoom level
  5642. style.zoom = 1;
  5643. // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
  5644. // if value === "", then remove inline opacity #12685
  5645. if ( ( value >= 1 || value === "" ) &&
  5646. jQuery.trim( filter.replace( ralpha, "" ) ) === "" &&
  5647. style.removeAttribute ) {
  5648. // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
  5649. // if "filter:" is present at all, clearType is disabled, we want to avoid this
  5650. // style.removeAttribute is IE Only, but so apparently is this code path...
  5651. style.removeAttribute( "filter" );
  5652. // if there is no filter style applied in a css rule or unset inline opacity, we are done
  5653. if ( value === "" || currentStyle && !currentStyle.filter ) {
  5654. return;
  5655. }
  5656. }
  5657. // otherwise, set new filter values
  5658. style.filter = ralpha.test( filter ) ?
  5659. filter.replace( ralpha, opacity ) :
  5660. filter + " " + opacity;
  5661. }
  5662. };
  5663. }
  5664. jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
  5665. function( elem, computed ) {
  5666. if ( computed ) {
  5667. // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
  5668. // Work around by temporarily setting element display to inline-block
  5669. return jQuery.swap( elem, { "display": "inline-block" },
  5670. curCSS, [ elem, "marginRight" ] );
  5671. }
  5672. }
  5673. );
  5674. // These hooks are used by animate to expand properties
  5675. jQuery.each({
  5676. margin: "",
  5677. padding: "",
  5678. border: "Width"
  5679. }, function( prefix, suffix ) {
  5680. jQuery.cssHooks[ prefix + suffix ] = {
  5681. expand: function( value ) {
  5682. var i = 0,
  5683. expanded = {},
  5684. // assumes a single number if not a string
  5685. parts = typeof value === "string" ? value.split(" ") : [ value ];
  5686. for ( ; i < 4; i++ ) {
  5687. expanded[ prefix + cssExpand[ i ] + suffix ] =
  5688. parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
  5689. }
  5690. return expanded;
  5691. }
  5692. };
  5693. if ( !rmargin.test( prefix ) ) {
  5694. jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
  5695. }
  5696. });
  5697. jQuery.fn.extend({
  5698. css: function( name, value ) {
  5699. return access( this, function( elem, name, value ) {
  5700. var styles, len,
  5701. map = {},
  5702. i = 0;
  5703. if ( jQuery.isArray( name ) ) {
  5704. styles = getStyles( elem );
  5705. len = name.length;
  5706. for ( ; i < len; i++ ) {
  5707. map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
  5708. }
  5709. return map;
  5710. }
  5711. return value !== undefined ?
  5712. jQuery.style( elem, name, value ) :
  5713. jQuery.css( elem, name );
  5714. }, name, value, arguments.length > 1 );
  5715. },
  5716. show: function() {
  5717. return showHide( this, true );
  5718. },
  5719. hide: function() {
  5720. return showHide( this );
  5721. },
  5722. toggle: function( state ) {
  5723. if ( typeof state === "boolean" ) {
  5724. return state ? this.show() : this.hide();
  5725. }
  5726. return this.each(function() {
  5727. if ( isHidden( this ) ) {
  5728. jQuery( this ).show();
  5729. } else {
  5730. jQuery( this ).hide();
  5731. }
  5732. });
  5733. }
  5734. });
  5735. function Tween( elem, options, prop, end, easing ) {
  5736. return new Tween.prototype.init( elem, options, prop, end, easing );
  5737. }
  5738. jQuery.Tween = Tween;
  5739. Tween.prototype = {
  5740. constructor: Tween,
  5741. init: function( elem, options, prop, end, easing, unit ) {
  5742. this.elem = elem;
  5743. this.prop = prop;
  5744. this.easing = easing || "swing";
  5745. this.options = options;
  5746. this.start = this.now = this.cur();
  5747. this.end = end;
  5748. this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
  5749. },
  5750. cur: function() {
  5751. var hooks = Tween.propHooks[ this.prop ];
  5752. return hooks && hooks.get ?
  5753. hooks.get( this ) :
  5754. Tween.propHooks._default.get( this );
  5755. },
  5756. run: function( percent ) {
  5757. var eased,
  5758. hooks = Tween.propHooks[ this.prop ];
  5759. if ( this.options.duration ) {
  5760. this.pos = eased = jQuery.easing[ this.easing ](
  5761. percent, this.options.duration * percent, 0, 1, this.options.duration
  5762. );
  5763. } else {
  5764. this.pos = eased = percent;
  5765. }
  5766. this.now = ( this.end - this.start ) * eased + this.start;
  5767. if ( this.options.step ) {
  5768. this.options.step.call( this.elem, this.now, this );
  5769. }
  5770. if ( hooks && hooks.set ) {
  5771. hooks.set( this );
  5772. } else {
  5773. Tween.propHooks._default.set( this );
  5774. }
  5775. return this;
  5776. }
  5777. };
  5778. Tween.prototype.init.prototype = Tween.prototype;
  5779. Tween.propHooks = {
  5780. _default: {
  5781. get: function( tween ) {
  5782. var result;
  5783. if ( tween.elem[ tween.prop ] != null &&
  5784. (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
  5785. return tween.elem[ tween.prop ];
  5786. }
  5787. // passing an empty string as a 3rd parameter to .css will automatically
  5788. // attempt a parseFloat and fallback to a string if the parse fails
  5789. // so, simple values such as "10px" are parsed to Float.
  5790. // complex values such as "rotate(1rad)" are returned as is.
  5791. result = jQuery.css( tween.elem, tween.prop, "" );
  5792. // Empty strings, null, undefined and "auto" are converted to 0.
  5793. return !result || result === "auto" ? 0 : result;
  5794. },
  5795. set: function( tween ) {
  5796. // use step hook for back compat - use cssHook if its there - use .style if its
  5797. // available and use plain properties where available
  5798. if ( jQuery.fx.step[ tween.prop ] ) {
  5799. jQuery.fx.step[ tween.prop ]( tween );
  5800. } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
  5801. jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
  5802. } else {
  5803. tween.elem[ tween.prop ] = tween.now;
  5804. }
  5805. }
  5806. }
  5807. };
  5808. // Support: IE <=9
  5809. // Panic based approach to setting things on disconnected nodes
  5810. Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
  5811. set: function( tween ) {
  5812. if ( tween.elem.nodeType && tween.elem.parentNode ) {
  5813. tween.elem[ tween.prop ] = tween.now;
  5814. }
  5815. }
  5816. };
  5817. jQuery.easing = {
  5818. linear: function( p ) {
  5819. return p;
  5820. },
  5821. swing: function( p ) {
  5822. return 0.5 - Math.cos( p * Math.PI ) / 2;
  5823. }
  5824. };
  5825. jQuery.fx = Tween.prototype.init;
  5826. // Back Compat <1.8 extension point
  5827. jQuery.fx.step = {};
  5828. var
  5829. fxNow, timerId,
  5830. rfxtypes = /^(?:toggle|show|hide)$/,
  5831. rfxnum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ),
  5832. rrun = /queueHooks$/,
  5833. animationPrefilters = [ defaultPrefilter ],
  5834. tweeners = {
  5835. "*": [ function( prop, value ) {
  5836. var tween = this.createTween( prop, value ),
  5837. target = tween.cur(),
  5838. parts = rfxnum.exec( value ),
  5839. unit = parts && parts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
  5840. // Starting value computation is required for potential unit mismatches
  5841. start = ( jQuery.cssNumber[ prop ] || unit !== "px" && +target ) &&
  5842. rfxnum.exec( jQuery.css( tween.elem, prop ) ),
  5843. scale = 1,
  5844. maxIterations = 20;
  5845. if ( start && start[ 3 ] !== unit ) {
  5846. // Trust units reported by jQuery.css
  5847. unit = unit || start[ 3 ];
  5848. // Make sure we update the tween properties later on
  5849. parts = parts || [];
  5850. // Iteratively approximate from a nonzero starting point
  5851. start = +target || 1;
  5852. do {
  5853. // If previous iteration zeroed out, double until we get *something*
  5854. // Use a string for doubling factor so we don't accidentally see scale as unchanged below
  5855. scale = scale || ".5";
  5856. // Adjust and apply
  5857. start = start / scale;
  5858. jQuery.style( tween.elem, prop, start + unit );
  5859. // Update scale, tolerating zero or NaN from tween.cur()
  5860. // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
  5861. } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
  5862. }
  5863. // Update tween properties
  5864. if ( parts ) {
  5865. start = tween.start = +start || +target || 0;
  5866. tween.unit = unit;
  5867. // If a +=/-= token was provided, we're doing a relative animation
  5868. tween.end = parts[ 1 ] ?
  5869. start + ( parts[ 1 ] + 1 ) * parts[ 2 ] :
  5870. +parts[ 2 ];
  5871. }
  5872. return tween;
  5873. } ]
  5874. };
  5875. // Animations created synchronously will run synchronously
  5876. function createFxNow() {
  5877. setTimeout(function() {
  5878. fxNow = undefined;
  5879. });
  5880. return ( fxNow = jQuery.now() );
  5881. }
  5882. // Generate parameters to create a standard animation
  5883. function genFx( type, includeWidth ) {
  5884. var which,
  5885. attrs = { height: type },
  5886. i = 0;
  5887. // if we include width, step value is 1 to do all cssExpand values,
  5888. // if we don't include width, step value is 2 to skip over Left and Right
  5889. includeWidth = includeWidth ? 1 : 0;
  5890. for ( ; i < 4 ; i += 2 - includeWidth ) {
  5891. which = cssExpand[ i ];
  5892. attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
  5893. }
  5894. if ( includeWidth ) {
  5895. attrs.opacity = attrs.width = type;
  5896. }
  5897. return attrs;
  5898. }
  5899. function createTween( value, prop, animation ) {
  5900. var tween,
  5901. collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
  5902. index = 0,
  5903. length = collection.length;
  5904. for ( ; index < length; index++ ) {
  5905. if ( (tween = collection[ index ].call( animation, prop, value )) ) {
  5906. // we're done with this property
  5907. return tween;
  5908. }
  5909. }
  5910. }
  5911. function defaultPrefilter( elem, props, opts ) {
  5912. /* jshint validthis: true */
  5913. var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay,
  5914. anim = this,
  5915. orig = {},
  5916. style = elem.style,
  5917. hidden = elem.nodeType && isHidden( elem ),
  5918. dataShow = jQuery._data( elem, "fxshow" );
  5919. // handle queue: false promises
  5920. if ( !opts.queue ) {
  5921. hooks = jQuery._queueHooks( elem, "fx" );
  5922. if ( hooks.unqueued == null ) {
  5923. hooks.unqueued = 0;
  5924. oldfire = hooks.empty.fire;
  5925. hooks.empty.fire = function() {
  5926. if ( !hooks.unqueued ) {
  5927. oldfire();
  5928. }
  5929. };
  5930. }
  5931. hooks.unqueued++;
  5932. anim.always(function() {
  5933. // doing this makes sure that the complete handler will be called
  5934. // before this completes
  5935. anim.always(function() {
  5936. hooks.unqueued--;
  5937. if ( !jQuery.queue( elem, "fx" ).length ) {
  5938. hooks.empty.fire();
  5939. }
  5940. });
  5941. });
  5942. }
  5943. // height/width overflow pass
  5944. if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
  5945. // Make sure that nothing sneaks out
  5946. // Record all 3 overflow attributes because IE does not
  5947. // change the overflow attribute when overflowX and
  5948. // overflowY are set to the same value
  5949. opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
  5950. // Set display property to inline-block for height/width
  5951. // animations on inline elements that are having width/height animated
  5952. display = jQuery.css( elem, "display" );
  5953. // Test default display if display is currently "none"
  5954. checkDisplay = display === "none" ?
  5955. jQuery._data( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display;
  5956. if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) {
  5957. // inline-level elements accept inline-block;
  5958. // block-level elements need to be inline with layout
  5959. if ( !support.inlineBlockNeedsLayout || defaultDisplay( elem.nodeName ) === "inline" ) {
  5960. style.display = "inline-block";
  5961. } else {
  5962. style.zoom = 1;
  5963. }
  5964. }
  5965. }
  5966. if ( opts.overflow ) {
  5967. style.overflow = "hidden";
  5968. if ( !support.shrinkWrapBlocks() ) {
  5969. anim.always(function() {
  5970. style.overflow = opts.overflow[ 0 ];
  5971. style.overflowX = opts.overflow[ 1 ];
  5972. style.overflowY = opts.overflow[ 2 ];
  5973. });
  5974. }
  5975. }
  5976. // show/hide pass
  5977. for ( prop in props ) {
  5978. value = props[ prop ];
  5979. if ( rfxtypes.exec( value ) ) {
  5980. delete props[ prop ];
  5981. toggle = toggle || value === "toggle";
  5982. if ( value === ( hidden ? "hide" : "show" ) ) {
  5983. // If there is dataShow left over from a stopped hide or show and we are going to proceed with show, we should pretend to be hidden
  5984. if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
  5985. hidden = true;
  5986. } else {
  5987. continue;
  5988. }
  5989. }
  5990. orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
  5991. // Any non-fx value stops us from restoring the original display value
  5992. } else {
  5993. display = undefined;
  5994. }
  5995. }
  5996. if ( !jQuery.isEmptyObject( orig ) ) {
  5997. if ( dataShow ) {
  5998. if ( "hidden" in dataShow ) {
  5999. hidden = dataShow.hidden;
  6000. }
  6001. } else {
  6002. dataShow = jQuery._data( elem, "fxshow", {} );
  6003. }
  6004. // store state if its toggle - enables .stop().toggle() to "reverse"
  6005. if ( toggle ) {
  6006. dataShow.hidden = !hidden;
  6007. }
  6008. if ( hidden ) {
  6009. jQuery( elem ).show();
  6010. } else {
  6011. anim.done(function() {
  6012. jQuery( elem ).hide();
  6013. });
  6014. }
  6015. anim.done(function() {
  6016. var prop;
  6017. jQuery._removeData( elem, "fxshow" );
  6018. for ( prop in orig ) {
  6019. jQuery.style( elem, prop, orig[ prop ] );
  6020. }
  6021. });
  6022. for ( prop in orig ) {
  6023. tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
  6024. if ( !( prop in dataShow ) ) {
  6025. dataShow[ prop ] = tween.start;
  6026. if ( hidden ) {
  6027. tween.end = tween.start;
  6028. tween.start = prop === "width" || prop === "height" ? 1 : 0;
  6029. }
  6030. }
  6031. }
  6032. // If this is a noop like .hide().hide(), restore an overwritten display value
  6033. } else if ( (display === "none" ? defaultDisplay( elem.nodeName ) : display) === "inline" ) {
  6034. style.display = display;
  6035. }
  6036. }
  6037. function propFilter( props, specialEasing ) {
  6038. var index, name, easing, value, hooks;
  6039. // camelCase, specialEasing and expand cssHook pass
  6040. for ( index in props ) {
  6041. name = jQuery.camelCase( index );
  6042. easing = specialEasing[ name ];
  6043. value = props[ index ];
  6044. if ( jQuery.isArray( value ) ) {
  6045. easing = value[ 1 ];
  6046. value = props[ index ] = value[ 0 ];
  6047. }
  6048. if ( index !== name ) {
  6049. props[ name ] = value;
  6050. delete props[ index ];
  6051. }
  6052. hooks = jQuery.cssHooks[ name ];
  6053. if ( hooks && "expand" in hooks ) {
  6054. value = hooks.expand( value );
  6055. delete props[ name ];
  6056. // not quite $.extend, this wont overwrite keys already present.
  6057. // also - reusing 'index' from above because we have the correct "name"
  6058. for ( index in value ) {
  6059. if ( !( index in props ) ) {
  6060. props[ index ] = value[ index ];
  6061. specialEasing[ index ] = easing;
  6062. }
  6063. }
  6064. } else {
  6065. specialEasing[ name ] = easing;
  6066. }
  6067. }
  6068. }
  6069. function Animation( elem, properties, options ) {
  6070. var result,
  6071. stopped,
  6072. index = 0,
  6073. length = animationPrefilters.length,
  6074. deferred = jQuery.Deferred().always( function() {
  6075. // don't match elem in the :animated selector
  6076. delete tick.elem;
  6077. }),
  6078. tick = function() {
  6079. if ( stopped ) {
  6080. return false;
  6081. }
  6082. var currentTime = fxNow || createFxNow(),
  6083. remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
  6084. // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
  6085. temp = remaining / animation.duration || 0,
  6086. percent = 1 - temp,
  6087. index = 0,
  6088. length = animation.tweens.length;
  6089. for ( ; index < length ; index++ ) {
  6090. animation.tweens[ index ].run( percent );
  6091. }
  6092. deferred.notifyWith( elem, [ animation, percent, remaining ]);
  6093. if ( percent < 1 && length ) {
  6094. return remaining;
  6095. } else {
  6096. deferred.resolveWith( elem, [ animation ] );
  6097. return false;
  6098. }
  6099. },
  6100. animation = deferred.promise({
  6101. elem: elem,
  6102. props: jQuery.extend( {}, properties ),
  6103. opts: jQuery.extend( true, { specialEasing: {} }, options ),
  6104. originalProperties: properties,
  6105. originalOptions: options,
  6106. startTime: fxNow || createFxNow(),
  6107. duration: options.duration,
  6108. tweens: [],
  6109. createTween: function( prop, end ) {
  6110. var tween = jQuery.Tween( elem, animation.opts, prop, end,
  6111. animation.opts.specialEasing[ prop ] || animation.opts.easing );
  6112. animation.tweens.push( tween );
  6113. return tween;
  6114. },
  6115. stop: function( gotoEnd ) {
  6116. var index = 0,
  6117. // if we are going to the end, we want to run all the tweens
  6118. // otherwise we skip this part
  6119. length = gotoEnd ? animation.tweens.length : 0;
  6120. if ( stopped ) {
  6121. return this;
  6122. }
  6123. stopped = true;
  6124. for ( ; index < length ; index++ ) {
  6125. animation.tweens[ index ].run( 1 );
  6126. }
  6127. // resolve when we played the last frame
  6128. // otherwise, reject
  6129. if ( gotoEnd ) {
  6130. deferred.resolveWith( elem, [ animation, gotoEnd ] );
  6131. } else {
  6132. deferred.rejectWith( elem, [ animation, gotoEnd ] );
  6133. }
  6134. return this;
  6135. }
  6136. }),
  6137. props = animation.props;
  6138. propFilter( props, animation.opts.specialEasing );
  6139. for ( ; index < length ; index++ ) {
  6140. result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
  6141. if ( result ) {
  6142. return result;
  6143. }
  6144. }
  6145. jQuery.map( props, createTween, animation );
  6146. if ( jQuery.isFunction( animation.opts.start ) ) {
  6147. animation.opts.start.call( elem, animation );
  6148. }
  6149. jQuery.fx.timer(
  6150. jQuery.extend( tick, {
  6151. elem: elem,
  6152. anim: animation,
  6153. queue: animation.opts.queue
  6154. })
  6155. );
  6156. // attach callbacks from options
  6157. return animation.progress( animation.opts.progress )
  6158. .done( animation.opts.done, animation.opts.complete )
  6159. .fail( animation.opts.fail )
  6160. .always( animation.opts.always );
  6161. }
  6162. jQuery.Animation = jQuery.extend( Animation, {
  6163. tweener: function( props, callback ) {
  6164. if ( jQuery.isFunction( props ) ) {
  6165. callback = props;
  6166. props = [ "*" ];
  6167. } else {
  6168. props = props.split(" ");
  6169. }
  6170. var prop,
  6171. index = 0,
  6172. length = props.length;
  6173. for ( ; index < length ; index++ ) {
  6174. prop = props[ index ];
  6175. tweeners[ prop ] = tweeners[ prop ] || [];
  6176. tweeners[ prop ].unshift( callback );
  6177. }
  6178. },
  6179. prefilter: function( callback, prepend ) {
  6180. if ( prepend ) {
  6181. animationPrefilters.unshift( callback );
  6182. } else {
  6183. animationPrefilters.push( callback );
  6184. }
  6185. }
  6186. });
  6187. jQuery.speed = function( speed, easing, fn ) {
  6188. var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
  6189. complete: fn || !fn && easing ||
  6190. jQuery.isFunction( speed ) && speed,
  6191. duration: speed,
  6192. easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
  6193. };
  6194. opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
  6195. opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
  6196. // normalize opt.queue - true/undefined/null -> "fx"
  6197. if ( opt.queue == null || opt.queue === true ) {
  6198. opt.queue = "fx";
  6199. }
  6200. // Queueing
  6201. opt.old = opt.complete;
  6202. opt.complete = function() {
  6203. if ( jQuery.isFunction( opt.old ) ) {
  6204. opt.old.call( this );
  6205. }
  6206. if ( opt.queue ) {
  6207. jQuery.dequeue( this, opt.queue );
  6208. }
  6209. };
  6210. return opt;
  6211. };
  6212. jQuery.fn.extend({
  6213. fadeTo: function( speed, to, easing, callback ) {
  6214. // show any hidden elements after setting opacity to 0
  6215. return this.filter( isHidden ).css( "opacity", 0 ).show()
  6216. // animate to the value specified
  6217. .end().animate({ opacity: to }, speed, easing, callback );
  6218. },
  6219. animate: function( prop, speed, easing, callback ) {
  6220. var empty = jQuery.isEmptyObject( prop ),
  6221. optall = jQuery.speed( speed, easing, callback ),
  6222. doAnimation = function() {
  6223. // Operate on a copy of prop so per-property easing won't be lost
  6224. var anim = Animation( this, jQuery.extend( {}, prop ), optall );
  6225. // Empty animations, or finishing resolves immediately
  6226. if ( empty || jQuery._data( this, "finish" ) ) {
  6227. anim.stop( true );
  6228. }
  6229. };
  6230. doAnimation.finish = doAnimation;
  6231. return empty || optall.queue === false ?
  6232. this.each( doAnimation ) :
  6233. this.queue( optall.queue, doAnimation );
  6234. },
  6235. stop: function( type, clearQueue, gotoEnd ) {
  6236. var stopQueue = function( hooks ) {
  6237. var stop = hooks.stop;
  6238. delete hooks.stop;
  6239. stop( gotoEnd );
  6240. };
  6241. if ( typeof type !== "string" ) {
  6242. gotoEnd = clearQueue;
  6243. clearQueue = type;
  6244. type = undefined;
  6245. }
  6246. if ( clearQueue && type !== false ) {
  6247. this.queue( type || "fx", [] );
  6248. }
  6249. return this.each(function() {
  6250. var dequeue = true,
  6251. index = type != null && type + "queueHooks",
  6252. timers = jQuery.timers,
  6253. data = jQuery._data( this );
  6254. if ( index ) {
  6255. if ( data[ index ] && data[ index ].stop ) {
  6256. stopQueue( data[ index ] );
  6257. }
  6258. } else {
  6259. for ( index in data ) {
  6260. if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
  6261. stopQueue( data[ index ] );
  6262. }
  6263. }
  6264. }
  6265. for ( index = timers.length; index--; ) {
  6266. if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
  6267. timers[ index ].anim.stop( gotoEnd );
  6268. dequeue = false;
  6269. timers.splice( index, 1 );
  6270. }
  6271. }
  6272. // start the next in the queue if the last step wasn't forced
  6273. // timers currently will call their complete callbacks, which will dequeue
  6274. // but only if they were gotoEnd
  6275. if ( dequeue || !gotoEnd ) {
  6276. jQuery.dequeue( this, type );
  6277. }
  6278. });
  6279. },
  6280. finish: function( type ) {
  6281. if ( type !== false ) {
  6282. type = type || "fx";
  6283. }
  6284. return this.each(function() {
  6285. var index,
  6286. data = jQuery._data( this ),
  6287. queue = data[ type + "queue" ],
  6288. hooks = data[ type + "queueHooks" ],
  6289. timers = jQuery.timers,
  6290. length = queue ? queue.length : 0;
  6291. // enable finishing flag on private data
  6292. data.finish = true;
  6293. // empty the queue first
  6294. jQuery.queue( this, type, [] );
  6295. if ( hooks && hooks.stop ) {
  6296. hooks.stop.call( this, true );
  6297. }
  6298. // look for any active animations, and finish them
  6299. for ( index = timers.length; index--; ) {
  6300. if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
  6301. timers[ index ].anim.stop( true );
  6302. timers.splice( index, 1 );
  6303. }
  6304. }
  6305. // look for any animations in the old queue and finish them
  6306. for ( index = 0; index < length; index++ ) {
  6307. if ( queue[ index ] && queue[ index ].finish ) {
  6308. queue[ index ].finish.call( this );
  6309. }
  6310. }
  6311. // turn off finishing flag
  6312. delete data.finish;
  6313. });
  6314. }
  6315. });
  6316. jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
  6317. var cssFn = jQuery.fn[ name ];
  6318. jQuery.fn[ name ] = function( speed, easing, callback ) {
  6319. return speed == null || typeof speed === "boolean" ?
  6320. cssFn.apply( this, arguments ) :
  6321. this.animate( genFx( name, true ), speed, easing, callback );
  6322. };
  6323. });
  6324. // Generate shortcuts for custom animations
  6325. jQuery.each({
  6326. slideDown: genFx("show"),
  6327. slideUp: genFx("hide"),
  6328. slideToggle: genFx("toggle"),
  6329. fadeIn: { opacity: "show" },
  6330. fadeOut: { opacity: "hide" },
  6331. fadeToggle: { opacity: "toggle" }
  6332. }, function( name, props ) {
  6333. jQuery.fn[ name ] = function( speed, easing, callback ) {
  6334. return this.animate( props, speed, easing, callback );
  6335. };
  6336. });
  6337. jQuery.timers = [];
  6338. jQuery.fx.tick = function() {
  6339. var timer,
  6340. timers = jQuery.timers,
  6341. i = 0;
  6342. fxNow = jQuery.now();
  6343. for ( ; i < timers.length; i++ ) {
  6344. timer = timers[ i ];
  6345. // Checks the timer has not already been removed
  6346. if ( !timer() && timers[ i ] === timer ) {
  6347. timers.splice( i--, 1 );
  6348. }
  6349. }
  6350. if ( !timers.length ) {
  6351. jQuery.fx.stop();
  6352. }
  6353. fxNow = undefined;
  6354. };
  6355. jQuery.fx.timer = function( timer ) {
  6356. jQuery.timers.push( timer );
  6357. if ( timer() ) {
  6358. jQuery.fx.start();
  6359. } else {
  6360. jQuery.timers.pop();
  6361. }
  6362. };
  6363. jQuery.fx.interval = 13;
  6364. jQuery.fx.start = function() {
  6365. if ( !timerId ) {
  6366. timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
  6367. }
  6368. };
  6369. jQuery.fx.stop = function() {
  6370. clearInterval( timerId );
  6371. timerId = null;
  6372. };
  6373. jQuery.fx.speeds = {
  6374. slow: 600,
  6375. fast: 200,
  6376. // Default speed
  6377. _default: 400
  6378. };
  6379. // Based off of the plugin by Clint Helfers, with permission.
  6380. // http://blindsignals.com/index.php/2009/07/jquery-delay/
  6381. jQuery.fn.delay = function( time, type ) {
  6382. time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
  6383. type = type || "fx";
  6384. return this.queue( type, function( next, hooks ) {
  6385. var timeout = setTimeout( next, time );
  6386. hooks.stop = function() {
  6387. clearTimeout( timeout );
  6388. };
  6389. });
  6390. };
  6391. (function() {
  6392. // Minified: var a,b,c,d,e
  6393. var input, div, select, a, opt;
  6394. // Setup
  6395. div = document.createElement( "div" );
  6396. div.setAttribute( "className", "t" );
  6397. div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
  6398. a = div.getElementsByTagName("a")[ 0 ];
  6399. // First batch of tests.
  6400. select = document.createElement("select");
  6401. opt = select.appendChild( document.createElement("option") );
  6402. input = div.getElementsByTagName("input")[ 0 ];
  6403. a.style.cssText = "top:1px";
  6404. // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
  6405. support.getSetAttribute = div.className !== "t";
  6406. // Get the style information from getAttribute
  6407. // (IE uses .cssText instead)
  6408. support.style = /top/.test( a.getAttribute("style") );
  6409. // Make sure that URLs aren't manipulated
  6410. // (IE normalizes it by default)
  6411. support.hrefNormalized = a.getAttribute("href") === "/a";
  6412. // Check the default checkbox/radio value ("" on WebKit; "on" elsewhere)
  6413. support.checkOn = !!input.value;
  6414. // Make sure that a selected-by-default option has a working selected property.
  6415. // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
  6416. support.optSelected = opt.selected;
  6417. // Tests for enctype support on a form (#6743)
  6418. support.enctype = !!document.createElement("form").enctype;
  6419. // Make sure that the options inside disabled selects aren't marked as disabled
  6420. // (WebKit marks them as disabled)
  6421. select.disabled = true;
  6422. support.optDisabled = !opt.disabled;
  6423. // Support: IE8 only
  6424. // Check if we can trust getAttribute("value")
  6425. input = document.createElement( "input" );
  6426. input.setAttribute( "value", "" );
  6427. support.input = input.getAttribute( "value" ) === "";
  6428. // Check if an input maintains its value after becoming a radio
  6429. input.value = "t";
  6430. input.setAttribute( "type", "radio" );
  6431. support.radioValue = input.value === "t";
  6432. })();
  6433. var rreturn = /\r/g;
  6434. jQuery.fn.extend({
  6435. val: function( value ) {
  6436. var hooks, ret, isFunction,
  6437. elem = this[0];
  6438. if ( !arguments.length ) {
  6439. if ( elem ) {
  6440. hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
  6441. if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
  6442. return ret;
  6443. }
  6444. ret = elem.value;
  6445. return typeof ret === "string" ?
  6446. // handle most common string cases
  6447. ret.replace(rreturn, "") :
  6448. // handle cases where value is null/undef or number
  6449. ret == null ? "" : ret;
  6450. }
  6451. return;
  6452. }
  6453. isFunction = jQuery.isFunction( value );
  6454. return this.each(function( i ) {
  6455. var val;
  6456. if ( this.nodeType !== 1 ) {
  6457. return;
  6458. }
  6459. if ( isFunction ) {
  6460. val = value.call( this, i, jQuery( this ).val() );
  6461. } else {
  6462. val = value;
  6463. }
  6464. // Treat null/undefined as ""; convert numbers to string
  6465. if ( val == null ) {
  6466. val = "";
  6467. } else if ( typeof val === "number" ) {
  6468. val += "";
  6469. } else if ( jQuery.isArray( val ) ) {
  6470. val = jQuery.map( val, function( value ) {
  6471. return value == null ? "" : value + "";
  6472. });
  6473. }
  6474. hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
  6475. // If set returns undefined, fall back to normal setting
  6476. if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
  6477. this.value = val;
  6478. }
  6479. });
  6480. }
  6481. });
  6482. jQuery.extend({
  6483. valHooks: {
  6484. option: {
  6485. get: function( elem ) {
  6486. var val = jQuery.find.attr( elem, "value" );
  6487. return val != null ?
  6488. val :
  6489. // Support: IE10-11+
  6490. // option.text throws exceptions (#14686, #14858)
  6491. jQuery.trim( jQuery.text( elem ) );
  6492. }
  6493. },
  6494. select: {
  6495. get: function( elem ) {
  6496. var value, option,
  6497. options = elem.options,
  6498. index = elem.selectedIndex,
  6499. one = elem.type === "select-one" || index < 0,
  6500. values = one ? null : [],
  6501. max = one ? index + 1 : options.length,
  6502. i = index < 0 ?
  6503. max :
  6504. one ? index : 0;
  6505. // Loop through all the selected options
  6506. for ( ; i < max; i++ ) {
  6507. option = options[ i ];
  6508. // oldIE doesn't update selected after form reset (#2551)
  6509. if ( ( option.selected || i === index ) &&
  6510. // Don't return options that are disabled or in a disabled optgroup
  6511. ( support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) &&
  6512. ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
  6513. // Get the specific value for the option
  6514. value = jQuery( option ).val();
  6515. // We don't need an array for one selects
  6516. if ( one ) {
  6517. return value;
  6518. }
  6519. // Multi-Selects return an array
  6520. values.push( value );
  6521. }
  6522. }
  6523. return values;
  6524. },
  6525. set: function( elem, value ) {
  6526. var optionSet, option,
  6527. options = elem.options,
  6528. values = jQuery.makeArray( value ),
  6529. i = options.length;
  6530. while ( i-- ) {
  6531. option = options[ i ];
  6532. if ( jQuery.inArray( jQuery.valHooks.option.get( option ), values ) >= 0 ) {
  6533. // Support: IE6
  6534. // When new option element is added to select box we need to
  6535. // force reflow of newly added node in order to workaround delay
  6536. // of initialization properties
  6537. try {
  6538. option.selected = optionSet = true;
  6539. } catch ( _ ) {
  6540. // Will be executed only in IE6
  6541. option.scrollHeight;
  6542. }
  6543. } else {
  6544. option.selected = false;
  6545. }
  6546. }
  6547. // Force browsers to behave consistently when non-matching value is set
  6548. if ( !optionSet ) {
  6549. elem.selectedIndex = -1;
  6550. }
  6551. return options;
  6552. }
  6553. }
  6554. }
  6555. });
  6556. // Radios and checkboxes getter/setter
  6557. jQuery.each([ "radio", "checkbox" ], function() {
  6558. jQuery.valHooks[ this ] = {
  6559. set: function( elem, value ) {
  6560. if ( jQuery.isArray( value ) ) {
  6561. return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
  6562. }
  6563. }
  6564. };
  6565. if ( !support.checkOn ) {
  6566. jQuery.valHooks[ this ].get = function( elem ) {
  6567. // Support: Webkit
  6568. // "" is returned instead of "on" if a value isn't specified
  6569. return elem.getAttribute("value") === null ? "on" : elem.value;
  6570. };
  6571. }
  6572. });
  6573. var nodeHook, boolHook,
  6574. attrHandle = jQuery.expr.attrHandle,
  6575. ruseDefault = /^(?:checked|selected)$/i,
  6576. getSetAttribute = support.getSetAttribute,
  6577. getSetInput = support.input;
  6578. jQuery.fn.extend({
  6579. attr: function( name, value ) {
  6580. return access( this, jQuery.attr, name, value, arguments.length > 1 );
  6581. },
  6582. removeAttr: function( name ) {
  6583. return this.each(function() {
  6584. jQuery.removeAttr( this, name );
  6585. });
  6586. }
  6587. });
  6588. jQuery.extend({
  6589. attr: function( elem, name, value ) {
  6590. var hooks, ret,
  6591. nType = elem.nodeType;
  6592. // don't get/set attributes on text, comment and attribute nodes
  6593. if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
  6594. return;
  6595. }
  6596. // Fallback to prop when attributes are not supported
  6597. if ( typeof elem.getAttribute === strundefined ) {
  6598. return jQuery.prop( elem, name, value );
  6599. }
  6600. // All attributes are lowercase
  6601. // Grab necessary hook if one is defined
  6602. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  6603. name = name.toLowerCase();
  6604. hooks = jQuery.attrHooks[ name ] ||
  6605. ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook );
  6606. }
  6607. if ( value !== undefined ) {
  6608. if ( value === null ) {
  6609. jQuery.removeAttr( elem, name );
  6610. } else if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
  6611. return ret;
  6612. } else {
  6613. elem.setAttribute( name, value + "" );
  6614. return value;
  6615. }
  6616. } else if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
  6617. return ret;
  6618. } else {
  6619. ret = jQuery.find.attr( elem, name );
  6620. // Non-existent attributes return null, we normalize to undefined
  6621. return ret == null ?
  6622. undefined :
  6623. ret;
  6624. }
  6625. },
  6626. removeAttr: function( elem, value ) {
  6627. var name, propName,
  6628. i = 0,
  6629. attrNames = value && value.match( rnotwhite );
  6630. if ( attrNames && elem.nodeType === 1 ) {
  6631. while ( (name = attrNames[i++]) ) {
  6632. propName = jQuery.propFix[ name ] || name;
  6633. // Boolean attributes get special treatment (#10870)
  6634. if ( jQuery.expr.match.bool.test( name ) ) {
  6635. // Set corresponding property to false
  6636. if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
  6637. elem[ propName ] = false;
  6638. // Support: IE<9
  6639. // Also clear defaultChecked/defaultSelected (if appropriate)
  6640. } else {
  6641. elem[ jQuery.camelCase( "default-" + name ) ] =
  6642. elem[ propName ] = false;
  6643. }
  6644. // See #9699 for explanation of this approach (setting first, then removal)
  6645. } else {
  6646. jQuery.attr( elem, name, "" );
  6647. }
  6648. elem.removeAttribute( getSetAttribute ? name : propName );
  6649. }
  6650. }
  6651. },
  6652. attrHooks: {
  6653. type: {
  6654. set: function( elem, value ) {
  6655. if ( !support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
  6656. // Setting the type on a radio button after the value resets the value in IE6-9
  6657. // Reset value to default in case type is set after value during creation
  6658. var val = elem.value;
  6659. elem.setAttribute( "type", value );
  6660. if ( val ) {
  6661. elem.value = val;
  6662. }
  6663. return value;
  6664. }
  6665. }
  6666. }
  6667. }
  6668. });
  6669. // Hook for boolean attributes
  6670. boolHook = {
  6671. set: function( elem, value, name ) {
  6672. if ( value === false ) {
  6673. // Remove boolean attributes when set to false
  6674. jQuery.removeAttr( elem, name );
  6675. } else if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
  6676. // IE<8 needs the *property* name
  6677. elem.setAttribute( !getSetAttribute && jQuery.propFix[ name ] || name, name );
  6678. // Use defaultChecked and defaultSelected for oldIE
  6679. } else {
  6680. elem[ jQuery.camelCase( "default-" + name ) ] = elem[ name ] = true;
  6681. }
  6682. return name;
  6683. }
  6684. };
  6685. // Retrieve booleans specially
  6686. jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
  6687. var getter = attrHandle[ name ] || jQuery.find.attr;
  6688. attrHandle[ name ] = getSetInput && getSetAttribute || !ruseDefault.test( name ) ?
  6689. function( elem, name, isXML ) {
  6690. var ret, handle;
  6691. if ( !isXML ) {
  6692. // Avoid an infinite loop by temporarily removing this function from the getter
  6693. handle = attrHandle[ name ];
  6694. attrHandle[ name ] = ret;
  6695. ret = getter( elem, name, isXML ) != null ?
  6696. name.toLowerCase() :
  6697. null;
  6698. attrHandle[ name ] = handle;
  6699. }
  6700. return ret;
  6701. } :
  6702. function( elem, name, isXML ) {
  6703. if ( !isXML ) {
  6704. return elem[ jQuery.camelCase( "default-" + name ) ] ?
  6705. name.toLowerCase() :
  6706. null;
  6707. }
  6708. };
  6709. });
  6710. // fix oldIE attroperties
  6711. if ( !getSetInput || !getSetAttribute ) {
  6712. jQuery.attrHooks.value = {
  6713. set: function( elem, value, name ) {
  6714. if ( jQuery.nodeName( elem, "input" ) ) {
  6715. // Does not return so that setAttribute is also used
  6716. elem.defaultValue = value;
  6717. } else {
  6718. // Use nodeHook if defined (#1954); otherwise setAttribute is fine
  6719. return nodeHook && nodeHook.set( elem, value, name );
  6720. }
  6721. }
  6722. };
  6723. }
  6724. // IE6/7 do not support getting/setting some attributes with get/setAttribute
  6725. if ( !getSetAttribute ) {
  6726. // Use this for any attribute in IE6/7
  6727. // This fixes almost every IE6/7 issue
  6728. nodeHook = {
  6729. set: function( elem, value, name ) {
  6730. // Set the existing or create a new attribute node
  6731. var ret = elem.getAttributeNode( name );
  6732. if ( !ret ) {
  6733. elem.setAttributeNode(
  6734. (ret = elem.ownerDocument.createAttribute( name ))
  6735. );
  6736. }
  6737. ret.value = value += "";
  6738. // Break association with cloned elements by also using setAttribute (#9646)
  6739. if ( name === "value" || value === elem.getAttribute( name ) ) {
  6740. return value;
  6741. }
  6742. }
  6743. };
  6744. // Some attributes are constructed with empty-string values when not defined
  6745. attrHandle.id = attrHandle.name = attrHandle.coords =
  6746. function( elem, name, isXML ) {
  6747. var ret;
  6748. if ( !isXML ) {
  6749. return (ret = elem.getAttributeNode( name )) && ret.value !== "" ?
  6750. ret.value :
  6751. null;
  6752. }
  6753. };
  6754. // Fixing value retrieval on a button requires this module
  6755. jQuery.valHooks.button = {
  6756. get: function( elem, name ) {
  6757. var ret = elem.getAttributeNode( name );
  6758. if ( ret && ret.specified ) {
  6759. return ret.value;
  6760. }
  6761. },
  6762. set: nodeHook.set
  6763. };
  6764. // Set contenteditable to false on removals(#10429)
  6765. // Setting to empty string throws an error as an invalid value
  6766. jQuery.attrHooks.contenteditable = {
  6767. set: function( elem, value, name ) {
  6768. nodeHook.set( elem, value === "" ? false : value, name );
  6769. }
  6770. };
  6771. // Set width and height to auto instead of 0 on empty string( Bug #8150 )
  6772. // This is for removals
  6773. jQuery.each([ "width", "height" ], function( i, name ) {
  6774. jQuery.attrHooks[ name ] = {
  6775. set: function( elem, value ) {
  6776. if ( value === "" ) {
  6777. elem.setAttribute( name, "auto" );
  6778. return value;
  6779. }
  6780. }
  6781. };
  6782. });
  6783. }
  6784. if ( !support.style ) {
  6785. jQuery.attrHooks.style = {
  6786. get: function( elem ) {
  6787. // Return undefined in the case of empty string
  6788. // Note: IE uppercases css property names, but if we were to .toLowerCase()
  6789. // .cssText, that would destroy case senstitivity in URL's, like in "background"
  6790. return elem.style.cssText || undefined;
  6791. },
  6792. set: function( elem, value ) {
  6793. return ( elem.style.cssText = value + "" );
  6794. }
  6795. };
  6796. }
  6797. var rfocusable = /^(?:input|select|textarea|button|object)$/i,
  6798. rclickable = /^(?:a|area)$/i;
  6799. jQuery.fn.extend({
  6800. prop: function( name, value ) {
  6801. return access( this, jQuery.prop, name, value, arguments.length > 1 );
  6802. },
  6803. removeProp: function( name ) {
  6804. name = jQuery.propFix[ name ] || name;
  6805. return this.each(function() {
  6806. // try/catch handles cases where IE balks (such as removing a property on window)
  6807. try {
  6808. this[ name ] = undefined;
  6809. delete this[ name ];
  6810. } catch( e ) {}
  6811. });
  6812. }
  6813. });
  6814. jQuery.extend({
  6815. propFix: {
  6816. "for": "htmlFor",
  6817. "class": "className"
  6818. },
  6819. prop: function( elem, name, value ) {
  6820. var ret, hooks, notxml,
  6821. nType = elem.nodeType;
  6822. // don't get/set properties on text, comment and attribute nodes
  6823. if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
  6824. return;
  6825. }
  6826. notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
  6827. if ( notxml ) {
  6828. // Fix name and attach hooks
  6829. name = jQuery.propFix[ name ] || name;
  6830. hooks = jQuery.propHooks[ name ];
  6831. }
  6832. if ( value !== undefined ) {
  6833. return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ?
  6834. ret :
  6835. ( elem[ name ] = value );
  6836. } else {
  6837. return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ?
  6838. ret :
  6839. elem[ name ];
  6840. }
  6841. },
  6842. propHooks: {
  6843. tabIndex: {
  6844. get: function( elem ) {
  6845. // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
  6846. // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
  6847. // Use proper attribute retrieval(#12072)
  6848. var tabindex = jQuery.find.attr( elem, "tabindex" );
  6849. return tabindex ?
  6850. parseInt( tabindex, 10 ) :
  6851. rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
  6852. 0 :
  6853. -1;
  6854. }
  6855. }
  6856. }
  6857. });
  6858. // Some attributes require a special call on IE
  6859. // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  6860. if ( !support.hrefNormalized ) {
  6861. // href/src property should get the full normalized URL (#10299/#12915)
  6862. jQuery.each([ "href", "src" ], function( i, name ) {
  6863. jQuery.propHooks[ name ] = {
  6864. get: function( elem ) {
  6865. return elem.getAttribute( name, 4 );
  6866. }
  6867. };
  6868. });
  6869. }
  6870. // Support: Safari, IE9+
  6871. // mis-reports the default selected property of an option
  6872. // Accessing the parent's selectedIndex property fixes it
  6873. if ( !support.optSelected ) {
  6874. jQuery.propHooks.selected = {
  6875. get: function( elem ) {
  6876. var parent = elem.parentNode;
  6877. if ( parent ) {
  6878. parent.selectedIndex;
  6879. // Make sure that it also works with optgroups, see #5701
  6880. if ( parent.parentNode ) {
  6881. parent.parentNode.selectedIndex;
  6882. }
  6883. }
  6884. return null;
  6885. }
  6886. };
  6887. }
  6888. jQuery.each([
  6889. "tabIndex",
  6890. "readOnly",
  6891. "maxLength",
  6892. "cellSpacing",
  6893. "cellPadding",
  6894. "rowSpan",
  6895. "colSpan",
  6896. "useMap",
  6897. "frameBorder",
  6898. "contentEditable"
  6899. ], function() {
  6900. jQuery.propFix[ this.toLowerCase() ] = this;
  6901. });
  6902. // IE6/7 call enctype encoding
  6903. if ( !support.enctype ) {
  6904. jQuery.propFix.enctype = "encoding";
  6905. }
  6906. var rclass = /[\t\r\n\f]/g;
  6907. jQuery.fn.extend({
  6908. addClass: function( value ) {
  6909. var classes, elem, cur, clazz, j, finalValue,
  6910. i = 0,
  6911. len = this.length,
  6912. proceed = typeof value === "string" && value;
  6913. if ( jQuery.isFunction( value ) ) {
  6914. return this.each(function( j ) {
  6915. jQuery( this ).addClass( value.call( this, j, this.className ) );
  6916. });
  6917. }
  6918. if ( proceed ) {
  6919. // The disjunction here is for better compressibility (see removeClass)
  6920. classes = ( value || "" ).match( rnotwhite ) || [];
  6921. for ( ; i < len; i++ ) {
  6922. elem = this[ i ];
  6923. cur = elem.nodeType === 1 && ( elem.className ?
  6924. ( " " + elem.className + " " ).replace( rclass, " " ) :
  6925. " "
  6926. );
  6927. if ( cur ) {
  6928. j = 0;
  6929. while ( (clazz = classes[j++]) ) {
  6930. if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
  6931. cur += clazz + " ";
  6932. }
  6933. }
  6934. // only assign if different to avoid unneeded rendering.
  6935. finalValue = jQuery.trim( cur );
  6936. if ( elem.className !== finalValue ) {
  6937. elem.className = finalValue;
  6938. }
  6939. }
  6940. }
  6941. }
  6942. return this;
  6943. },
  6944. removeClass: function( value ) {
  6945. var classes, elem, cur, clazz, j, finalValue,
  6946. i = 0,
  6947. len = this.length,
  6948. proceed = arguments.length === 0 || typeof value === "string" && value;
  6949. if ( jQuery.isFunction( value ) ) {
  6950. return this.each(function( j ) {
  6951. jQuery( this ).removeClass( value.call( this, j, this.className ) );
  6952. });
  6953. }
  6954. if ( proceed ) {
  6955. classes = ( value || "" ).match( rnotwhite ) || [];
  6956. for ( ; i < len; i++ ) {
  6957. elem = this[ i ];
  6958. // This expression is here for better compressibility (see addClass)
  6959. cur = elem.nodeType === 1 && ( elem.className ?
  6960. ( " " + elem.className + " " ).replace( rclass, " " ) :
  6961. ""
  6962. );
  6963. if ( cur ) {
  6964. j = 0;
  6965. while ( (clazz = classes[j++]) ) {
  6966. // Remove *all* instances
  6967. while ( cur.indexOf( " " + clazz + " " ) >= 0 ) {
  6968. cur = cur.replace( " " + clazz + " ", " " );
  6969. }
  6970. }
  6971. // only assign if different to avoid unneeded rendering.
  6972. finalValue = value ? jQuery.trim( cur ) : "";
  6973. if ( elem.className !== finalValue ) {
  6974. elem.className = finalValue;
  6975. }
  6976. }
  6977. }
  6978. }
  6979. return this;
  6980. },
  6981. toggleClass: function( value, stateVal ) {
  6982. var type = typeof value;
  6983. if ( typeof stateVal === "boolean" && type === "string" ) {
  6984. return stateVal ? this.addClass( value ) : this.removeClass( value );
  6985. }
  6986. if ( jQuery.isFunction( value ) ) {
  6987. return this.each(function( i ) {
  6988. jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
  6989. });
  6990. }
  6991. return this.each(function() {
  6992. if ( type === "string" ) {
  6993. // toggle individual class names
  6994. var className,
  6995. i = 0,
  6996. self = jQuery( this ),
  6997. classNames = value.match( rnotwhite ) || [];
  6998. while ( (className = classNames[ i++ ]) ) {
  6999. // check each className given, space separated list
  7000. if ( self.hasClass( className ) ) {
  7001. self.removeClass( className );
  7002. } else {
  7003. self.addClass( className );
  7004. }
  7005. }
  7006. // Toggle whole class name
  7007. } else if ( type === strundefined || type === "boolean" ) {
  7008. if ( this.className ) {
  7009. // store className if set
  7010. jQuery._data( this, "__className__", this.className );
  7011. }
  7012. // If the element has a class name or if we're passed "false",
  7013. // then remove the whole classname (if there was one, the above saved it).
  7014. // Otherwise bring back whatever was previously saved (if anything),
  7015. // falling back to the empty string if nothing was stored.
  7016. this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
  7017. }
  7018. });
  7019. },
  7020. hasClass: function( selector ) {
  7021. var className = " " + selector + " ",
  7022. i = 0,
  7023. l = this.length;
  7024. for ( ; i < l; i++ ) {
  7025. if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
  7026. return true;
  7027. }
  7028. }
  7029. return false;
  7030. }
  7031. });
  7032. // Return jQuery for attributes-only inclusion
  7033. jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
  7034. "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  7035. "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
  7036. // Handle event binding
  7037. jQuery.fn[ name ] = function( data, fn ) {
  7038. return arguments.length > 0 ?
  7039. this.on( name, null, data, fn ) :
  7040. this.trigger( name );
  7041. };
  7042. });
  7043. jQuery.fn.extend({
  7044. hover: function( fnOver, fnOut ) {
  7045. return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
  7046. },
  7047. bind: function( types, data, fn ) {
  7048. return this.on( types, null, data, fn );
  7049. },
  7050. unbind: function( types, fn ) {
  7051. return this.off( types, null, fn );
  7052. },
  7053. delegate: function( selector, types, data, fn ) {
  7054. return this.on( types, selector, data, fn );
  7055. },
  7056. undelegate: function( selector, types, fn ) {
  7057. // ( namespace ) or ( selector, types [, fn] )
  7058. return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
  7059. }
  7060. });
  7061. var nonce = jQuery.now();
  7062. var rquery = (/\?/);
  7063. var rvalidtokens = /(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;
  7064. jQuery.parseJSON = function( data ) {
  7065. // Attempt to parse using the native JSON parser first
  7066. if ( window.JSON && window.JSON.parse ) {
  7067. // Support: Android 2.3
  7068. // Workaround failure to string-cast null input
  7069. return window.JSON.parse( data + "" );
  7070. }
  7071. var requireNonComma,
  7072. depth = null,
  7073. str = jQuery.trim( data + "" );
  7074. // Guard against invalid (and possibly dangerous) input by ensuring that nothing remains
  7075. // after removing valid tokens
  7076. return str && !jQuery.trim( str.replace( rvalidtokens, function( token, comma, open, close ) {
  7077. // Force termination if we see a misplaced comma
  7078. if ( requireNonComma && comma ) {
  7079. depth = 0;
  7080. }
  7081. // Perform no more replacements after returning to outermost depth
  7082. if ( depth === 0 ) {
  7083. return token;
  7084. }
  7085. // Commas must not follow "[", "{", or ","
  7086. requireNonComma = open || comma;
  7087. // Determine new depth
  7088. // array/object open ("[" or "{"): depth += true - false (increment)
  7089. // array/object close ("]" or "}"): depth += false - true (decrement)
  7090. // other cases ("," or primitive): depth += true - true (numeric cast)
  7091. depth += !close - !open;
  7092. // Remove this token
  7093. return "";
  7094. }) ) ?
  7095. ( Function( "return " + str ) )() :
  7096. jQuery.error( "Invalid JSON: " + data );
  7097. };
  7098. // Cross-browser xml parsing
  7099. jQuery.parseXML = function( data ) {
  7100. var xml, tmp;
  7101. if ( !data || typeof data !== "string" ) {
  7102. return null;
  7103. }
  7104. try {
  7105. if ( window.DOMParser ) { // Standard
  7106. tmp = new DOMParser();
  7107. xml = tmp.parseFromString( data, "text/xml" );
  7108. } else { // IE
  7109. xml = new ActiveXObject( "Microsoft.XMLDOM" );
  7110. xml.async = "false";
  7111. xml.loadXML( data );
  7112. }
  7113. } catch( e ) {
  7114. xml = undefined;
  7115. }
  7116. if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
  7117. jQuery.error( "Invalid XML: " + data );
  7118. }
  7119. return xml;
  7120. };
  7121. var
  7122. // Document location
  7123. ajaxLocParts,
  7124. ajaxLocation,
  7125. rhash = /#.*$/,
  7126. rts = /([?&])_=[^&]*/,
  7127. rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
  7128. // #7653, #8125, #8152: local protocol detection
  7129. rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
  7130. rnoContent = /^(?:GET|HEAD)$/,
  7131. rprotocol = /^\/\//,
  7132. rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,
  7133. /* Prefilters
  7134. * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
  7135. * 2) These are called:
  7136. * - BEFORE asking for a transport
  7137. * - AFTER param serialization (s.data is a string if s.processData is true)
  7138. * 3) key is the dataType
  7139. * 4) the catchall symbol "*" can be used
  7140. * 5) execution will start with transport dataType and THEN continue down to "*" if needed
  7141. */
  7142. prefilters = {},
  7143. /* Transports bindings
  7144. * 1) key is the dataType
  7145. * 2) the catchall symbol "*" can be used
  7146. * 3) selection will start with transport dataType and THEN go to "*" if needed
  7147. */
  7148. transports = {},
  7149. // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
  7150. allTypes = "*/".concat("*");
  7151. // #8138, IE may throw an exception when accessing
  7152. // a field from window.location if document.domain has been set
  7153. try {
  7154. ajaxLocation = location.href;
  7155. } catch( e ) {
  7156. // Use the href attribute of an A element
  7157. // since IE will modify it given document.location
  7158. ajaxLocation = document.createElement( "a" );
  7159. ajaxLocation.href = "";
  7160. ajaxLocation = ajaxLocation.href;
  7161. }
  7162. // Segment location into parts
  7163. ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
  7164. // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
  7165. function addToPrefiltersOrTransports( structure ) {
  7166. // dataTypeExpression is optional and defaults to "*"
  7167. return function( dataTypeExpression, func ) {
  7168. if ( typeof dataTypeExpression !== "string" ) {
  7169. func = dataTypeExpression;
  7170. dataTypeExpression = "*";
  7171. }
  7172. var dataType,
  7173. i = 0,
  7174. dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || [];
  7175. if ( jQuery.isFunction( func ) ) {
  7176. // For each dataType in the dataTypeExpression
  7177. while ( (dataType = dataTypes[i++]) ) {
  7178. // Prepend if requested
  7179. if ( dataType.charAt( 0 ) === "+" ) {
  7180. dataType = dataType.slice( 1 ) || "*";
  7181. (structure[ dataType ] = structure[ dataType ] || []).unshift( func );
  7182. // Otherwise append
  7183. } else {
  7184. (structure[ dataType ] = structure[ dataType ] || []).push( func );
  7185. }
  7186. }
  7187. }
  7188. };
  7189. }
  7190. // Base inspection function for prefilters and transports
  7191. function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
  7192. var inspected = {},
  7193. seekingTransport = ( structure === transports );
  7194. function inspect( dataType ) {
  7195. var selected;
  7196. inspected[ dataType ] = true;
  7197. jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
  7198. var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
  7199. if ( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
  7200. options.dataTypes.unshift( dataTypeOrTransport );
  7201. inspect( dataTypeOrTransport );
  7202. return false;
  7203. } else if ( seekingTransport ) {
  7204. return !( selected = dataTypeOrTransport );
  7205. }
  7206. });
  7207. return selected;
  7208. }
  7209. return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
  7210. }
  7211. // A special extend for ajax options
  7212. // that takes "flat" options (not to be deep extended)
  7213. // Fixes #9887
  7214. function ajaxExtend( target, src ) {
  7215. var deep, key,
  7216. flatOptions = jQuery.ajaxSettings.flatOptions || {};
  7217. for ( key in src ) {
  7218. if ( src[ key ] !== undefined ) {
  7219. ( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ];
  7220. }
  7221. }
  7222. if ( deep ) {
  7223. jQuery.extend( true, target, deep );
  7224. }
  7225. return target;
  7226. }
  7227. /* Handles responses to an ajax request:
  7228. * - finds the right dataType (mediates between content-type and expected dataType)
  7229. * - returns the corresponding response
  7230. */
  7231. function ajaxHandleResponses( s, jqXHR, responses ) {
  7232. var firstDataType, ct, finalDataType, type,
  7233. contents = s.contents,
  7234. dataTypes = s.dataTypes;
  7235. // Remove auto dataType and get content-type in the process
  7236. while ( dataTypes[ 0 ] === "*" ) {
  7237. dataTypes.shift();
  7238. if ( ct === undefined ) {
  7239. ct = s.mimeType || jqXHR.getResponseHeader("Content-Type");
  7240. }
  7241. }
  7242. // Check if we're dealing with a known content-type
  7243. if ( ct ) {
  7244. for ( type in contents ) {
  7245. if ( contents[ type ] && contents[ type ].test( ct ) ) {
  7246. dataTypes.unshift( type );
  7247. break;
  7248. }
  7249. }
  7250. }
  7251. // Check to see if we have a response for the expected dataType
  7252. if ( dataTypes[ 0 ] in responses ) {
  7253. finalDataType = dataTypes[ 0 ];
  7254. } else {
  7255. // Try convertible dataTypes
  7256. for ( type in responses ) {
  7257. if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
  7258. finalDataType = type;
  7259. break;
  7260. }
  7261. if ( !firstDataType ) {
  7262. firstDataType = type;
  7263. }
  7264. }
  7265. // Or just use first one
  7266. finalDataType = finalDataType || firstDataType;
  7267. }
  7268. // If we found a dataType
  7269. // We add the dataType to the list if needed
  7270. // and return the corresponding response
  7271. if ( finalDataType ) {
  7272. if ( finalDataType !== dataTypes[ 0 ] ) {
  7273. dataTypes.unshift( finalDataType );
  7274. }
  7275. return responses[ finalDataType ];
  7276. }
  7277. }
  7278. /* Chain conversions given the request and the original response
  7279. * Also sets the responseXXX fields on the jqXHR instance
  7280. */
  7281. function ajaxConvert( s, response, jqXHR, isSuccess ) {
  7282. var conv2, current, conv, tmp, prev,
  7283. converters = {},
  7284. // Work with a copy of dataTypes in case we need to modify it for conversion
  7285. dataTypes = s.dataTypes.slice();
  7286. // Create converters map with lowercased keys
  7287. if ( dataTypes[ 1 ] ) {
  7288. for ( conv in s.converters ) {
  7289. converters[ conv.toLowerCase() ] = s.converters[ conv ];
  7290. }
  7291. }
  7292. current = dataTypes.shift();
  7293. // Convert to each sequential dataType
  7294. while ( current ) {
  7295. if ( s.responseFields[ current ] ) {
  7296. jqXHR[ s.responseFields[ current ] ] = response;
  7297. }
  7298. // Apply the dataFilter if provided
  7299. if ( !prev && isSuccess && s.dataFilter ) {
  7300. response = s.dataFilter( response, s.dataType );
  7301. }
  7302. prev = current;
  7303. current = dataTypes.shift();
  7304. if ( current ) {
  7305. // There's only work to do if current dataType is non-auto
  7306. if ( current === "*" ) {
  7307. current = prev;
  7308. // Convert response if prev dataType is non-auto and differs from current
  7309. } else if ( prev !== "*" && prev !== current ) {
  7310. // Seek a direct converter
  7311. conv = converters[ prev + " " + current ] || converters[ "* " + current ];
  7312. // If none found, seek a pair
  7313. if ( !conv ) {
  7314. for ( conv2 in converters ) {
  7315. // If conv2 outputs current
  7316. tmp = conv2.split( " " );
  7317. if ( tmp[ 1 ] === current ) {
  7318. // If prev can be converted to accepted input
  7319. conv = converters[ prev + " " + tmp[ 0 ] ] ||
  7320. converters[ "* " + tmp[ 0 ] ];
  7321. if ( conv ) {
  7322. // Condense equivalence converters
  7323. if ( conv === true ) {
  7324. conv = converters[ conv2 ];
  7325. // Otherwise, insert the intermediate dataType
  7326. } else if ( converters[ conv2 ] !== true ) {
  7327. current = tmp[ 0 ];
  7328. dataTypes.unshift( tmp[ 1 ] );
  7329. }
  7330. break;
  7331. }
  7332. }
  7333. }
  7334. }
  7335. // Apply converter (if not an equivalence)
  7336. if ( conv !== true ) {
  7337. // Unless errors are allowed to bubble, catch and return them
  7338. if ( conv && s[ "throws" ] ) {
  7339. response = conv( response );
  7340. } else {
  7341. try {
  7342. response = conv( response );
  7343. } catch ( e ) {
  7344. return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
  7345. }
  7346. }
  7347. }
  7348. }
  7349. }
  7350. }
  7351. return { state: "success", data: response };
  7352. }
  7353. jQuery.extend({
  7354. // Counter for holding the number of active queries
  7355. active: 0,
  7356. // Last-Modified header cache for next request
  7357. lastModified: {},
  7358. etag: {},
  7359. ajaxSettings: {
  7360. url: ajaxLocation,
  7361. type: "GET",
  7362. isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
  7363. global: true,
  7364. processData: true,
  7365. async: true,
  7366. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  7367. /*
  7368. timeout: 0,
  7369. data: null,
  7370. dataType: null,
  7371. username: null,
  7372. password: null,
  7373. cache: null,
  7374. throws: false,
  7375. traditional: false,
  7376. headers: {},
  7377. */
  7378. accepts: {
  7379. "*": allTypes,
  7380. text: "text/plain",
  7381. html: "text/html",
  7382. xml: "application/xml, text/xml",
  7383. json: "application/json, text/javascript"
  7384. },
  7385. contents: {
  7386. xml: /xml/,
  7387. html: /html/,
  7388. json: /json/
  7389. },
  7390. responseFields: {
  7391. xml: "responseXML",
  7392. text: "responseText",
  7393. json: "responseJSON"
  7394. },
  7395. // Data converters
  7396. // Keys separate source (or catchall "*") and destination types with a single space
  7397. converters: {
  7398. // Convert anything to text
  7399. "* text": String,
  7400. // Text to html (true = no transformation)
  7401. "text html": true,
  7402. // Evaluate text as a json expression
  7403. "text json": jQuery.parseJSON,
  7404. // Parse text as xml
  7405. "text xml": jQuery.parseXML
  7406. },
  7407. // For options that shouldn't be deep extended:
  7408. // you can add your own custom options here if
  7409. // and when you create one that shouldn't be
  7410. // deep extended (see ajaxExtend)
  7411. flatOptions: {
  7412. url: true,
  7413. context: true
  7414. }
  7415. },
  7416. // Creates a full fledged settings object into target
  7417. // with both ajaxSettings and settings fields.
  7418. // If target is omitted, writes into ajaxSettings.
  7419. ajaxSetup: function( target, settings ) {
  7420. return settings ?
  7421. // Building a settings object
  7422. ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
  7423. // Extending ajaxSettings
  7424. ajaxExtend( jQuery.ajaxSettings, target );
  7425. },
  7426. ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
  7427. ajaxTransport: addToPrefiltersOrTransports( transports ),
  7428. // Main method
  7429. ajax: function( url, options ) {
  7430. // If url is an object, simulate pre-1.5 signature
  7431. if ( typeof url === "object" ) {
  7432. options = url;
  7433. url = undefined;
  7434. }
  7435. // Force options to be an object
  7436. options = options || {};
  7437. var // Cross-domain detection vars
  7438. parts,
  7439. // Loop variable
  7440. i,
  7441. // URL without anti-cache param
  7442. cacheURL,
  7443. // Response headers as string
  7444. responseHeadersString,
  7445. // timeout handle
  7446. timeoutTimer,
  7447. // To know if global events are to be dispatched
  7448. fireGlobals,
  7449. transport,
  7450. // Response headers
  7451. responseHeaders,
  7452. // Create the final options object
  7453. s = jQuery.ajaxSetup( {}, options ),
  7454. // Callbacks context
  7455. callbackContext = s.context || s,
  7456. // Context for global events is callbackContext if it is a DOM node or jQuery collection
  7457. globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ?
  7458. jQuery( callbackContext ) :
  7459. jQuery.event,
  7460. // Deferreds
  7461. deferred = jQuery.Deferred(),
  7462. completeDeferred = jQuery.Callbacks("once memory"),
  7463. // Status-dependent callbacks
  7464. statusCode = s.statusCode || {},
  7465. // Headers (they are sent all at once)
  7466. requestHeaders = {},
  7467. requestHeadersNames = {},
  7468. // The jqXHR state
  7469. state = 0,
  7470. // Default abort message
  7471. strAbort = "canceled",
  7472. // Fake xhr
  7473. jqXHR = {
  7474. readyState: 0,
  7475. // Builds headers hashtable if needed
  7476. getResponseHeader: function( key ) {
  7477. var match;
  7478. if ( state === 2 ) {
  7479. if ( !responseHeaders ) {
  7480. responseHeaders = {};
  7481. while ( (match = rheaders.exec( responseHeadersString )) ) {
  7482. responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
  7483. }
  7484. }
  7485. match = responseHeaders[ key.toLowerCase() ];
  7486. }
  7487. return match == null ? null : match;
  7488. },
  7489. // Raw string
  7490. getAllResponseHeaders: function() {
  7491. return state === 2 ? responseHeadersString : null;
  7492. },
  7493. // Caches the header
  7494. setRequestHeader: function( name, value ) {
  7495. var lname = name.toLowerCase();
  7496. if ( !state ) {
  7497. name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
  7498. requestHeaders[ name ] = value;
  7499. }
  7500. return this;
  7501. },
  7502. // Overrides response content-type header
  7503. overrideMimeType: function( type ) {
  7504. if ( !state ) {
  7505. s.mimeType = type;
  7506. }
  7507. return this;
  7508. },
  7509. // Status-dependent callbacks
  7510. statusCode: function( map ) {
  7511. var code;
  7512. if ( map ) {
  7513. if ( state < 2 ) {
  7514. for ( code in map ) {
  7515. // Lazy-add the new callback in a way that preserves old ones
  7516. statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
  7517. }
  7518. } else {
  7519. // Execute the appropriate callbacks
  7520. jqXHR.always( map[ jqXHR.status ] );
  7521. }
  7522. }
  7523. return this;
  7524. },
  7525. // Cancel the request
  7526. abort: function( statusText ) {
  7527. var finalText = statusText || strAbort;
  7528. if ( transport ) {
  7529. transport.abort( finalText );
  7530. }
  7531. done( 0, finalText );
  7532. return this;
  7533. }
  7534. };
  7535. // Attach deferreds
  7536. deferred.promise( jqXHR ).complete = completeDeferred.add;
  7537. jqXHR.success = jqXHR.done;
  7538. jqXHR.error = jqXHR.fail;
  7539. // Remove hash character (#7531: and string promotion)
  7540. // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
  7541. // Handle falsy url in the settings object (#10093: consistency with old signature)
  7542. // We also use the url parameter if available
  7543. s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
  7544. // Alias method option to type as per ticket #12004
  7545. s.type = options.method || options.type || s.method || s.type;
  7546. // Extract dataTypes list
  7547. s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ];
  7548. // A cross-domain request is in order when we have a protocol:host:port mismatch
  7549. if ( s.crossDomain == null ) {
  7550. parts = rurl.exec( s.url.toLowerCase() );
  7551. s.crossDomain = !!( parts &&
  7552. ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
  7553. ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !==
  7554. ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) )
  7555. );
  7556. }
  7557. // Convert data if not already a string
  7558. if ( s.data && s.processData && typeof s.data !== "string" ) {
  7559. s.data = jQuery.param( s.data, s.traditional );
  7560. }
  7561. // Apply prefilters
  7562. inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
  7563. // If request was aborted inside a prefilter, stop there
  7564. if ( state === 2 ) {
  7565. return jqXHR;
  7566. }
  7567. // We can fire global events as of now if asked to
  7568. fireGlobals = s.global;
  7569. // Watch for a new set of requests
  7570. if ( fireGlobals && jQuery.active++ === 0 ) {
  7571. jQuery.event.trigger("ajaxStart");
  7572. }
  7573. // Uppercase the type
  7574. s.type = s.type.toUpperCase();
  7575. // Determine if request has content
  7576. s.hasContent = !rnoContent.test( s.type );
  7577. // Save the URL in case we're toying with the If-Modified-Since
  7578. // and/or If-None-Match header later on
  7579. cacheURL = s.url;
  7580. // More options handling for requests with no content
  7581. if ( !s.hasContent ) {
  7582. // If data is available, append data to url
  7583. if ( s.data ) {
  7584. cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
  7585. // #9682: remove data so that it's not used in an eventual retry
  7586. delete s.data;
  7587. }
  7588. // Add anti-cache in url if needed
  7589. if ( s.cache === false ) {
  7590. s.url = rts.test( cacheURL ) ?
  7591. // If there is already a '_' parameter, set its value
  7592. cacheURL.replace( rts, "$1_=" + nonce++ ) :
  7593. // Otherwise add one to the end
  7594. cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++;
  7595. }
  7596. }
  7597. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  7598. if ( s.ifModified ) {
  7599. if ( jQuery.lastModified[ cacheURL ] ) {
  7600. jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
  7601. }
  7602. if ( jQuery.etag[ cacheURL ] ) {
  7603. jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
  7604. }
  7605. }
  7606. // Set the correct header, if data is being sent
  7607. if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
  7608. jqXHR.setRequestHeader( "Content-Type", s.contentType );
  7609. }
  7610. // Set the Accepts header for the server, depending on the dataType
  7611. jqXHR.setRequestHeader(
  7612. "Accept",
  7613. s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
  7614. s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
  7615. s.accepts[ "*" ]
  7616. );
  7617. // Check for headers option
  7618. for ( i in s.headers ) {
  7619. jqXHR.setRequestHeader( i, s.headers[ i ] );
  7620. }
  7621. // Allow custom headers/mimetypes and early abort
  7622. if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
  7623. // Abort if not done already and return
  7624. return jqXHR.abort();
  7625. }
  7626. // aborting is no longer a cancellation
  7627. strAbort = "abort";
  7628. // Install callbacks on deferreds
  7629. for ( i in { success: 1, error: 1, complete: 1 } ) {
  7630. jqXHR[ i ]( s[ i ] );
  7631. }
  7632. // Get transport
  7633. transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
  7634. // If no transport, we auto-abort
  7635. if ( !transport ) {
  7636. done( -1, "No Transport" );
  7637. } else {
  7638. jqXHR.readyState = 1;
  7639. // Send global event
  7640. if ( fireGlobals ) {
  7641. globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
  7642. }
  7643. // Timeout
  7644. if ( s.async && s.timeout > 0 ) {
  7645. timeoutTimer = setTimeout(function() {
  7646. jqXHR.abort("timeout");
  7647. }, s.timeout );
  7648. }
  7649. try {
  7650. state = 1;
  7651. transport.send( requestHeaders, done );
  7652. } catch ( e ) {
  7653. // Propagate exception as error if not done
  7654. if ( state < 2 ) {
  7655. done( -1, e );
  7656. // Simply rethrow otherwise
  7657. } else {
  7658. throw e;
  7659. }
  7660. }
  7661. }
  7662. // Callback for when everything is done
  7663. function done( status, nativeStatusText, responses, headers ) {
  7664. var isSuccess, success, error, response, modified,
  7665. statusText = nativeStatusText;
  7666. // Called once
  7667. if ( state === 2 ) {
  7668. return;
  7669. }
  7670. // State is "done" now
  7671. state = 2;
  7672. // Clear timeout if it exists
  7673. if ( timeoutTimer ) {
  7674. clearTimeout( timeoutTimer );
  7675. }
  7676. // Dereference transport for early garbage collection
  7677. // (no matter how long the jqXHR object will be used)
  7678. transport = undefined;
  7679. // Cache response headers
  7680. responseHeadersString = headers || "";
  7681. // Set readyState
  7682. jqXHR.readyState = status > 0 ? 4 : 0;
  7683. // Determine if successful
  7684. isSuccess = status >= 200 && status < 300 || status === 304;
  7685. // Get response data
  7686. if ( responses ) {
  7687. response = ajaxHandleResponses( s, jqXHR, responses );
  7688. }
  7689. // Convert no matter what (that way responseXXX fields are always set)
  7690. response = ajaxConvert( s, response, jqXHR, isSuccess );
  7691. // If successful, handle type chaining
  7692. if ( isSuccess ) {
  7693. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  7694. if ( s.ifModified ) {
  7695. modified = jqXHR.getResponseHeader("Last-Modified");
  7696. if ( modified ) {
  7697. jQuery.lastModified[ cacheURL ] = modified;
  7698. }
  7699. modified = jqXHR.getResponseHeader("etag");
  7700. if ( modified ) {
  7701. jQuery.etag[ cacheURL ] = modified;
  7702. }
  7703. }
  7704. // if no content
  7705. if ( status === 204 || s.type === "HEAD" ) {
  7706. statusText = "nocontent";
  7707. // if not modified
  7708. } else if ( status === 304 ) {
  7709. statusText = "notmodified";
  7710. // If we have data, let's convert it
  7711. } else {
  7712. statusText = response.state;
  7713. success = response.data;
  7714. error = response.error;
  7715. isSuccess = !error;
  7716. }
  7717. } else {
  7718. // We extract error from statusText
  7719. // then normalize statusText and status for non-aborts
  7720. error = statusText;
  7721. if ( status || !statusText ) {
  7722. statusText = "error";
  7723. if ( status < 0 ) {
  7724. status = 0;
  7725. }
  7726. }
  7727. }
  7728. // Set data for the fake xhr object
  7729. jqXHR.status = status;
  7730. jqXHR.statusText = ( nativeStatusText || statusText ) + "";
  7731. // Success/Error
  7732. if ( isSuccess ) {
  7733. deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
  7734. } else {
  7735. deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
  7736. }
  7737. // Status-dependent callbacks
  7738. jqXHR.statusCode( statusCode );
  7739. statusCode = undefined;
  7740. if ( fireGlobals ) {
  7741. globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
  7742. [ jqXHR, s, isSuccess ? success : error ] );
  7743. }
  7744. // Complete
  7745. completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
  7746. if ( fireGlobals ) {
  7747. globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
  7748. // Handle the global AJAX counter
  7749. if ( !( --jQuery.active ) ) {
  7750. jQuery.event.trigger("ajaxStop");
  7751. }
  7752. }
  7753. }
  7754. return jqXHR;
  7755. },
  7756. getJSON: function( url, data, callback ) {
  7757. return jQuery.get( url, data, callback, "json" );
  7758. },
  7759. getScript: function( url, callback ) {
  7760. return jQuery.get( url, undefined, callback, "script" );
  7761. }
  7762. });
  7763. jQuery.each( [ "get", "post" ], function( i, method ) {
  7764. jQuery[ method ] = function( url, data, callback, type ) {
  7765. // shift arguments if data argument was omitted
  7766. if ( jQuery.isFunction( data ) ) {
  7767. type = type || callback;
  7768. callback = data;
  7769. data = undefined;
  7770. }
  7771. return jQuery.ajax({
  7772. url: url,
  7773. type: method,
  7774. dataType: type,
  7775. data: data,
  7776. success: callback
  7777. });
  7778. };
  7779. });
  7780. // Attach a bunch of functions for handling common AJAX events
  7781. jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ) {
  7782. jQuery.fn[ type ] = function( fn ) {
  7783. return this.on( type, fn );
  7784. };
  7785. });
  7786. jQuery._evalUrl = function( url ) {
  7787. return jQuery.ajax({
  7788. url: url,
  7789. type: "GET",
  7790. dataType: "script",
  7791. async: false,
  7792. global: false,
  7793. "throws": true
  7794. });
  7795. };
  7796. jQuery.fn.extend({
  7797. wrapAll: function( html ) {
  7798. if ( jQuery.isFunction( html ) ) {
  7799. return this.each(function(i) {
  7800. jQuery(this).wrapAll( html.call(this, i) );
  7801. });
  7802. }
  7803. if ( this[0] ) {
  7804. // The elements to wrap the target around
  7805. var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
  7806. if ( this[0].parentNode ) {
  7807. wrap.insertBefore( this[0] );
  7808. }
  7809. wrap.map(function() {
  7810. var elem = this;
  7811. while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
  7812. elem = elem.firstChild;
  7813. }
  7814. return elem;
  7815. }).append( this );
  7816. }
  7817. return this;
  7818. },
  7819. wrapInner: function( html ) {
  7820. if ( jQuery.isFunction( html ) ) {
  7821. return this.each(function(i) {
  7822. jQuery(this).wrapInner( html.call(this, i) );
  7823. });
  7824. }
  7825. return this.each(function() {
  7826. var self = jQuery( this ),
  7827. contents = self.contents();
  7828. if ( contents.length ) {
  7829. contents.wrapAll( html );
  7830. } else {
  7831. self.append( html );
  7832. }
  7833. });
  7834. },
  7835. wrap: function( html ) {
  7836. var isFunction = jQuery.isFunction( html );
  7837. return this.each(function(i) {
  7838. jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
  7839. });
  7840. },
  7841. unwrap: function() {
  7842. return this.parent().each(function() {
  7843. if ( !jQuery.nodeName( this, "body" ) ) {
  7844. jQuery( this ).replaceWith( this.childNodes );
  7845. }
  7846. }).end();
  7847. }
  7848. });
  7849. jQuery.expr.filters.hidden = function( elem ) {
  7850. // Support: Opera <= 12.12
  7851. // Opera reports offsetWidths and offsetHeights less than zero on some elements
  7852. return elem.offsetWidth <= 0 && elem.offsetHeight <= 0 ||
  7853. (!support.reliableHiddenOffsets() &&
  7854. ((elem.style && elem.style.display) || jQuery.css( elem, "display" )) === "none");
  7855. };
  7856. jQuery.expr.filters.visible = function( elem ) {
  7857. return !jQuery.expr.filters.hidden( elem );
  7858. };
  7859. var r20 = /%20/g,
  7860. rbracket = /\[\]$/,
  7861. rCRLF = /\r?\n/g,
  7862. rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
  7863. rsubmittable = /^(?:input|select|textarea|keygen)/i;
  7864. function buildParams( prefix, obj, traditional, add ) {
  7865. var name;
  7866. if ( jQuery.isArray( obj ) ) {
  7867. // Serialize array item.
  7868. jQuery.each( obj, function( i, v ) {
  7869. if ( traditional || rbracket.test( prefix ) ) {
  7870. // Treat each array item as a scalar.
  7871. add( prefix, v );
  7872. } else {
  7873. // Item is non-scalar (array or object), encode its numeric index.
  7874. buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
  7875. }
  7876. });
  7877. } else if ( !traditional && jQuery.type( obj ) === "object" ) {
  7878. // Serialize object item.
  7879. for ( name in obj ) {
  7880. buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
  7881. }
  7882. } else {
  7883. // Serialize scalar item.
  7884. add( prefix, obj );
  7885. }
  7886. }
  7887. // Serialize an array of form elements or a set of
  7888. // key/values into a query string
  7889. jQuery.param = function( a, traditional ) {
  7890. var prefix,
  7891. s = [],
  7892. add = function( key, value ) {
  7893. // If value is a function, invoke it and return its value
  7894. value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
  7895. s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
  7896. };
  7897. // Set traditional to true for jQuery <= 1.3.2 behavior.
  7898. if ( traditional === undefined ) {
  7899. traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
  7900. }
  7901. // If an array was passed in, assume that it is an array of form elements.
  7902. if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
  7903. // Serialize the form elements
  7904. jQuery.each( a, function() {
  7905. add( this.name, this.value );
  7906. });
  7907. } else {
  7908. // If traditional, encode the "old" way (the way 1.3.2 or older
  7909. // did it), otherwise encode params recursively.
  7910. for ( prefix in a ) {
  7911. buildParams( prefix, a[ prefix ], traditional, add );
  7912. }
  7913. }
  7914. // Return the resulting serialization
  7915. return s.join( "&" ).replace( r20, "+" );
  7916. };
  7917. jQuery.fn.extend({
  7918. serialize: function() {
  7919. return jQuery.param( this.serializeArray() );
  7920. },
  7921. serializeArray: function() {
  7922. return this.map(function() {
  7923. // Can add propHook for "elements" to filter or add form elements
  7924. var elements = jQuery.prop( this, "elements" );
  7925. return elements ? jQuery.makeArray( elements ) : this;
  7926. })
  7927. .filter(function() {
  7928. var type = this.type;
  7929. // Use .is(":disabled") so that fieldset[disabled] works
  7930. return this.name && !jQuery( this ).is( ":disabled" ) &&
  7931. rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
  7932. ( this.checked || !rcheckableType.test( type ) );
  7933. })
  7934. .map(function( i, elem ) {
  7935. var val = jQuery( this ).val();
  7936. return val == null ?
  7937. null :
  7938. jQuery.isArray( val ) ?
  7939. jQuery.map( val, function( val ) {
  7940. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  7941. }) :
  7942. { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  7943. }).get();
  7944. }
  7945. });
  7946. // Create the request object
  7947. // (This is still attached to ajaxSettings for backward compatibility)
  7948. jQuery.ajaxSettings.xhr = window.ActiveXObject !== undefined ?
  7949. // Support: IE6+
  7950. function() {
  7951. // XHR cannot access local files, always use ActiveX for that case
  7952. return !this.isLocal &&
  7953. // Support: IE7-8
  7954. // oldIE XHR does not support non-RFC2616 methods (#13240)
  7955. // See http://msdn.microsoft.com/en-us/library/ie/ms536648(v=vs.85).aspx
  7956. // and http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9
  7957. // Although this check for six methods instead of eight
  7958. // since IE also does not support "trace" and "connect"
  7959. /^(get|post|head|put|delete|options)$/i.test( this.type ) &&
  7960. createStandardXHR() || createActiveXHR();
  7961. } :
  7962. // For all other browsers, use the standard XMLHttpRequest object
  7963. createStandardXHR;
  7964. var xhrId = 0,
  7965. xhrCallbacks = {},
  7966. xhrSupported = jQuery.ajaxSettings.xhr();
  7967. // Support: IE<10
  7968. // Open requests must be manually aborted on unload (#5280)
  7969. if ( window.ActiveXObject ) {
  7970. jQuery( window ).on( "unload", function() {
  7971. for ( var key in xhrCallbacks ) {
  7972. xhrCallbacks[ key ]( undefined, true );
  7973. }
  7974. });
  7975. }
  7976. // Determine support properties
  7977. support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
  7978. xhrSupported = support.ajax = !!xhrSupported;
  7979. // Create transport if the browser can provide an xhr
  7980. if ( xhrSupported ) {
  7981. jQuery.ajaxTransport(function( options ) {
  7982. // Cross domain only allowed if supported through XMLHttpRequest
  7983. if ( !options.crossDomain || support.cors ) {
  7984. var callback;
  7985. return {
  7986. send: function( headers, complete ) {
  7987. var i,
  7988. xhr = options.xhr(),
  7989. id = ++xhrId;
  7990. // Open the socket
  7991. xhr.open( options.type, options.url, options.async, options.username, options.password );
  7992. // Apply custom fields if provided
  7993. if ( options.xhrFields ) {
  7994. for ( i in options.xhrFields ) {
  7995. xhr[ i ] = options.xhrFields[ i ];
  7996. }
  7997. }
  7998. // Override mime type if needed
  7999. if ( options.mimeType && xhr.overrideMimeType ) {
  8000. xhr.overrideMimeType( options.mimeType );
  8001. }
  8002. // X-Requested-With header
  8003. // For cross-domain requests, seeing as conditions for a preflight are
  8004. // akin to a jigsaw puzzle, we simply never set it to be sure.
  8005. // (it can always be set on a per-request basis or even using ajaxSetup)
  8006. // For same-domain requests, won't change header if already provided.
  8007. if ( !options.crossDomain && !headers["X-Requested-With"] ) {
  8008. headers["X-Requested-With"] = "XMLHttpRequest";
  8009. }
  8010. // Set headers
  8011. for ( i in headers ) {
  8012. // Support: IE<9
  8013. // IE's ActiveXObject throws a 'Type Mismatch' exception when setting
  8014. // request header to a null-value.
  8015. //
  8016. // To keep consistent with other XHR implementations, cast the value
  8017. // to string and ignore `undefined`.
  8018. if ( headers[ i ] !== undefined ) {
  8019. xhr.setRequestHeader( i, headers[ i ] + "" );
  8020. }
  8021. }
  8022. // Do send the request
  8023. // This may raise an exception which is actually
  8024. // handled in jQuery.ajax (so no try/catch here)
  8025. xhr.send( ( options.hasContent && options.data ) || null );
  8026. // Listener
  8027. callback = function( _, isAbort ) {
  8028. var status, statusText, responses;
  8029. // Was never called and is aborted or complete
  8030. if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
  8031. // Clean up
  8032. delete xhrCallbacks[ id ];
  8033. callback = undefined;
  8034. xhr.onreadystatechange = jQuery.noop;
  8035. // Abort manually if needed
  8036. if ( isAbort ) {
  8037. if ( xhr.readyState !== 4 ) {
  8038. xhr.abort();
  8039. }
  8040. } else {
  8041. responses = {};
  8042. status = xhr.status;
  8043. // Support: IE<10
  8044. // Accessing binary-data responseText throws an exception
  8045. // (#11426)
  8046. if ( typeof xhr.responseText === "string" ) {
  8047. responses.text = xhr.responseText;
  8048. }
  8049. // Firefox throws an exception when accessing
  8050. // statusText for faulty cross-domain requests
  8051. try {
  8052. statusText = xhr.statusText;
  8053. } catch( e ) {
  8054. // We normalize with Webkit giving an empty statusText
  8055. statusText = "";
  8056. }
  8057. // Filter status for non standard behaviors
  8058. // If the request is local and we have data: assume a success
  8059. // (success with no data won't get notified, that's the best we
  8060. // can do given current implementations)
  8061. if ( !status && options.isLocal && !options.crossDomain ) {
  8062. status = responses.text ? 200 : 404;
  8063. // IE - #1450: sometimes returns 1223 when it should be 204
  8064. } else if ( status === 1223 ) {
  8065. status = 204;
  8066. }
  8067. }
  8068. }
  8069. // Call complete if needed
  8070. if ( responses ) {
  8071. complete( status, statusText, responses, xhr.getAllResponseHeaders() );
  8072. }
  8073. };
  8074. if ( !options.async ) {
  8075. // if we're in sync mode we fire the callback
  8076. callback();
  8077. } else if ( xhr.readyState === 4 ) {
  8078. // (IE6 & IE7) if it's in cache and has been
  8079. // retrieved directly we need to fire the callback
  8080. setTimeout( callback );
  8081. } else {
  8082. // Add to the list of active xhr callbacks
  8083. xhr.onreadystatechange = xhrCallbacks[ id ] = callback;
  8084. }
  8085. },
  8086. abort: function() {
  8087. if ( callback ) {
  8088. callback( undefined, true );
  8089. }
  8090. }
  8091. };
  8092. }
  8093. });
  8094. }
  8095. // Functions to create xhrs
  8096. function createStandardXHR() {
  8097. try {
  8098. return new window.XMLHttpRequest();
  8099. } catch( e ) {}
  8100. }
  8101. function createActiveXHR() {
  8102. try {
  8103. return new window.ActiveXObject( "Microsoft.XMLHTTP" );
  8104. } catch( e ) {}
  8105. }
  8106. // Install script dataType
  8107. jQuery.ajaxSetup({
  8108. accepts: {
  8109. script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
  8110. },
  8111. contents: {
  8112. script: /(?:java|ecma)script/
  8113. },
  8114. converters: {
  8115. "text script": function( text ) {
  8116. jQuery.globalEval( text );
  8117. return text;
  8118. }
  8119. }
  8120. });
  8121. // Handle cache's special case and global
  8122. jQuery.ajaxPrefilter( "script", function( s ) {
  8123. if ( s.cache === undefined ) {
  8124. s.cache = false;
  8125. }
  8126. if ( s.crossDomain ) {
  8127. s.type = "GET";
  8128. s.global = false;
  8129. }
  8130. });
  8131. // Bind script tag hack transport
  8132. jQuery.ajaxTransport( "script", function(s) {
  8133. // This transport only deals with cross domain requests
  8134. if ( s.crossDomain ) {
  8135. var script,
  8136. head = document.head || jQuery("head")[0] || document.documentElement;
  8137. return {
  8138. send: function( _, callback ) {
  8139. script = document.createElement("script");
  8140. script.async = true;
  8141. if ( s.scriptCharset ) {
  8142. script.charset = s.scriptCharset;
  8143. }
  8144. script.src = s.url;
  8145. // Attach handlers for all browsers
  8146. script.onload = script.onreadystatechange = function( _, isAbort ) {
  8147. if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
  8148. // Handle memory leak in IE
  8149. script.onload = script.onreadystatechange = null;
  8150. // Remove the script
  8151. if ( script.parentNode ) {
  8152. script.parentNode.removeChild( script );
  8153. }
  8154. // Dereference the script
  8155. script = null;
  8156. // Callback if not abort
  8157. if ( !isAbort ) {
  8158. callback( 200, "success" );
  8159. }
  8160. }
  8161. };
  8162. // Circumvent IE6 bugs with base elements (#2709 and #4378) by prepending
  8163. // Use native DOM manipulation to avoid our domManip AJAX trickery
  8164. head.insertBefore( script, head.firstChild );
  8165. },
  8166. abort: function() {
  8167. if ( script ) {
  8168. script.onload( undefined, true );
  8169. }
  8170. }
  8171. };
  8172. }
  8173. });
  8174. var oldCallbacks = [],
  8175. rjsonp = /(=)\?(?=&|$)|\?\?/;
  8176. // Default jsonp settings
  8177. jQuery.ajaxSetup({
  8178. jsonp: "callback",
  8179. jsonpCallback: function() {
  8180. var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
  8181. this[ callback ] = true;
  8182. return callback;
  8183. }
  8184. });
  8185. // Detect, normalize options and install callbacks for jsonp requests
  8186. jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
  8187. var callbackName, overwritten, responseContainer,
  8188. jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
  8189. "url" :
  8190. typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data"
  8191. );
  8192. // Handle iff the expected data type is "jsonp" or we have a parameter to set
  8193. if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
  8194. // Get callback name, remembering preexisting value associated with it
  8195. callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
  8196. s.jsonpCallback() :
  8197. s.jsonpCallback;
  8198. // Insert callback into url or form data
  8199. if ( jsonProp ) {
  8200. s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
  8201. } else if ( s.jsonp !== false ) {
  8202. s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
  8203. }
  8204. // Use data converter to retrieve json after script execution
  8205. s.converters["script json"] = function() {
  8206. if ( !responseContainer ) {
  8207. jQuery.error( callbackName + " was not called" );
  8208. }
  8209. return responseContainer[ 0 ];
  8210. };
  8211. // force json dataType
  8212. s.dataTypes[ 0 ] = "json";
  8213. // Install callback
  8214. overwritten = window[ callbackName ];
  8215. window[ callbackName ] = function() {
  8216. responseContainer = arguments;
  8217. };
  8218. // Clean-up function (fires after converters)
  8219. jqXHR.always(function() {
  8220. // Restore preexisting value
  8221. window[ callbackName ] = overwritten;
  8222. // Save back as free
  8223. if ( s[ callbackName ] ) {
  8224. // make sure that re-using the options doesn't screw things around
  8225. s.jsonpCallback = originalSettings.jsonpCallback;
  8226. // save the callback name for future use
  8227. oldCallbacks.push( callbackName );
  8228. }
  8229. // Call if it was a function and we have a response
  8230. if ( responseContainer && jQuery.isFunction( overwritten ) ) {
  8231. overwritten( responseContainer[ 0 ] );
  8232. }
  8233. responseContainer = overwritten = undefined;
  8234. });
  8235. // Delegate to script
  8236. return "script";
  8237. }
  8238. });
  8239. // data: string of html
  8240. // context (optional): If specified, the fragment will be created in this context, defaults to document
  8241. // keepScripts (optional): If true, will include scripts passed in the html string
  8242. jQuery.parseHTML = function( data, context, keepScripts ) {
  8243. if ( !data || typeof data !== "string" ) {
  8244. return null;
  8245. }
  8246. if ( typeof context === "boolean" ) {
  8247. keepScripts = context;
  8248. context = false;
  8249. }
  8250. context = context || document;
  8251. var parsed = rsingleTag.exec( data ),
  8252. scripts = !keepScripts && [];
  8253. // Single tag
  8254. if ( parsed ) {
  8255. return [ context.createElement( parsed[1] ) ];
  8256. }
  8257. parsed = jQuery.buildFragment( [ data ], context, scripts );
  8258. if ( scripts && scripts.length ) {
  8259. jQuery( scripts ).remove();
  8260. }
  8261. return jQuery.merge( [], parsed.childNodes );
  8262. };
  8263. // Keep a copy of the old load method
  8264. var _load = jQuery.fn.load;
  8265. /**
  8266. * Load a url into a page
  8267. */
  8268. jQuery.fn.load = function( url, params, callback ) {
  8269. if ( typeof url !== "string" && _load ) {
  8270. return _load.apply( this, arguments );
  8271. }
  8272. var selector, response, type,
  8273. self = this,
  8274. off = url.indexOf(" ");
  8275. if ( off >= 0 ) {
  8276. selector = jQuery.trim( url.slice( off, url.length ) );
  8277. url = url.slice( 0, off );
  8278. }
  8279. // If it's a function
  8280. if ( jQuery.isFunction( params ) ) {
  8281. // We assume that it's the callback
  8282. callback = params;
  8283. params = undefined;
  8284. // Otherwise, build a param string
  8285. } else if ( params && typeof params === "object" ) {
  8286. type = "POST";
  8287. }
  8288. // If we have elements to modify, make the request
  8289. if ( self.length > 0 ) {
  8290. jQuery.ajax({
  8291. url: url,
  8292. // if "type" variable is undefined, then "GET" method will be used
  8293. type: type,
  8294. dataType: "html",
  8295. data: params
  8296. }).done(function( responseText ) {
  8297. // Save response for use in complete callback
  8298. response = arguments;
  8299. self.html( selector ?
  8300. // If a selector was specified, locate the right elements in a dummy div
  8301. // Exclude scripts to avoid IE 'Permission Denied' errors
  8302. jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) :
  8303. // Otherwise use the full result
  8304. responseText );
  8305. }).complete( callback && function( jqXHR, status ) {
  8306. self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
  8307. });
  8308. }
  8309. return this;
  8310. };
  8311. jQuery.expr.filters.animated = function( elem ) {
  8312. return jQuery.grep(jQuery.timers, function( fn ) {
  8313. return elem === fn.elem;
  8314. }).length;
  8315. };
  8316. var docElem = window.document.documentElement;
  8317. /**
  8318. * Gets a window from an element
  8319. */
  8320. function getWindow( elem ) {
  8321. return jQuery.isWindow( elem ) ?
  8322. elem :
  8323. elem.nodeType === 9 ?
  8324. elem.defaultView || elem.parentWindow :
  8325. false;
  8326. }
  8327. jQuery.offset = {
  8328. setOffset: function( elem, options, i ) {
  8329. var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
  8330. position = jQuery.css( elem, "position" ),
  8331. curElem = jQuery( elem ),
  8332. props = {};
  8333. // set position first, in-case top/left are set even on static elem
  8334. if ( position === "static" ) {
  8335. elem.style.position = "relative";
  8336. }
  8337. curOffset = curElem.offset();
  8338. curCSSTop = jQuery.css( elem, "top" );
  8339. curCSSLeft = jQuery.css( elem, "left" );
  8340. calculatePosition = ( position === "absolute" || position === "fixed" ) &&
  8341. jQuery.inArray("auto", [ curCSSTop, curCSSLeft ] ) > -1;
  8342. // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
  8343. if ( calculatePosition ) {
  8344. curPosition = curElem.position();
  8345. curTop = curPosition.top;
  8346. curLeft = curPosition.left;
  8347. } else {
  8348. curTop = parseFloat( curCSSTop ) || 0;
  8349. curLeft = parseFloat( curCSSLeft ) || 0;
  8350. }
  8351. if ( jQuery.isFunction( options ) ) {
  8352. options = options.call( elem, i, curOffset );
  8353. }
  8354. if ( options.top != null ) {
  8355. props.top = ( options.top - curOffset.top ) + curTop;
  8356. }
  8357. if ( options.left != null ) {
  8358. props.left = ( options.left - curOffset.left ) + curLeft;
  8359. }
  8360. if ( "using" in options ) {
  8361. options.using.call( elem, props );
  8362. } else {
  8363. curElem.css( props );
  8364. }
  8365. }
  8366. };
  8367. jQuery.fn.extend({
  8368. offset: function( options ) {
  8369. if ( arguments.length ) {
  8370. return options === undefined ?
  8371. this :
  8372. this.each(function( i ) {
  8373. jQuery.offset.setOffset( this, options, i );
  8374. });
  8375. }
  8376. var docElem, win,
  8377. box = { top: 0, left: 0 },
  8378. elem = this[ 0 ],
  8379. doc = elem && elem.ownerDocument;
  8380. if ( !doc ) {
  8381. return;
  8382. }
  8383. docElem = doc.documentElement;
  8384. // Make sure it's not a disconnected DOM node
  8385. if ( !jQuery.contains( docElem, elem ) ) {
  8386. return box;
  8387. }
  8388. // If we don't have gBCR, just use 0,0 rather than error
  8389. // BlackBerry 5, iOS 3 (original iPhone)
  8390. if ( typeof elem.getBoundingClientRect !== strundefined ) {
  8391. box = elem.getBoundingClientRect();
  8392. }
  8393. win = getWindow( doc );
  8394. return {
  8395. top: box.top + ( win.pageYOffset || docElem.scrollTop ) - ( docElem.clientTop || 0 ),
  8396. left: box.left + ( win.pageXOffset || docElem.scrollLeft ) - ( docElem.clientLeft || 0 )
  8397. };
  8398. },
  8399. position: function() {
  8400. if ( !this[ 0 ] ) {
  8401. return;
  8402. }
  8403. var offsetParent, offset,
  8404. parentOffset = { top: 0, left: 0 },
  8405. elem = this[ 0 ];
  8406. // fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is its only offset parent
  8407. if ( jQuery.css( elem, "position" ) === "fixed" ) {
  8408. // we assume that getBoundingClientRect is available when computed position is fixed
  8409. offset = elem.getBoundingClientRect();
  8410. } else {
  8411. // Get *real* offsetParent
  8412. offsetParent = this.offsetParent();
  8413. // Get correct offsets
  8414. offset = this.offset();
  8415. if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) {
  8416. parentOffset = offsetParent.offset();
  8417. }
  8418. // Add offsetParent borders
  8419. parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
  8420. parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
  8421. }
  8422. // Subtract parent offsets and element margins
  8423. // note: when an element has margin: auto the offsetLeft and marginLeft
  8424. // are the same in Safari causing offset.left to incorrectly be 0
  8425. return {
  8426. top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
  8427. left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true)
  8428. };
  8429. },
  8430. offsetParent: function() {
  8431. return this.map(function() {
  8432. var offsetParent = this.offsetParent || docElem;
  8433. while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && jQuery.css( offsetParent, "position" ) === "static" ) ) {
  8434. offsetParent = offsetParent.offsetParent;
  8435. }
  8436. return offsetParent || docElem;
  8437. });
  8438. }
  8439. });
  8440. // Create scrollLeft and scrollTop methods
  8441. jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
  8442. var top = /Y/.test( prop );
  8443. jQuery.fn[ method ] = function( val ) {
  8444. return access( this, function( elem, method, val ) {
  8445. var win = getWindow( elem );
  8446. if ( val === undefined ) {
  8447. return win ? (prop in win) ? win[ prop ] :
  8448. win.document.documentElement[ method ] :
  8449. elem[ method ];
  8450. }
  8451. if ( win ) {
  8452. win.scrollTo(
  8453. !top ? val : jQuery( win ).scrollLeft(),
  8454. top ? val : jQuery( win ).scrollTop()
  8455. );
  8456. } else {
  8457. elem[ method ] = val;
  8458. }
  8459. }, method, val, arguments.length, null );
  8460. };
  8461. });
  8462. // Add the top/left cssHooks using jQuery.fn.position
  8463. // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
  8464. // getComputedStyle returns percent when specified for top/left/bottom/right
  8465. // rather than make the css module depend on the offset module, we just check for it here
  8466. jQuery.each( [ "top", "left" ], function( i, prop ) {
  8467. jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
  8468. function( elem, computed ) {
  8469. if ( computed ) {
  8470. computed = curCSS( elem, prop );
  8471. // if curCSS returns percentage, fallback to offset
  8472. return rnumnonpx.test( computed ) ?
  8473. jQuery( elem ).position()[ prop ] + "px" :
  8474. computed;
  8475. }
  8476. }
  8477. );
  8478. });
  8479. // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
  8480. jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
  8481. jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
  8482. // margin is only for outerHeight, outerWidth
  8483. jQuery.fn[ funcName ] = function( margin, value ) {
  8484. var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
  8485. extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
  8486. return access( this, function( elem, type, value ) {
  8487. var doc;
  8488. if ( jQuery.isWindow( elem ) ) {
  8489. // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
  8490. // isn't a whole lot we can do. See pull request at this URL for discussion:
  8491. // https://github.com/jquery/jquery/pull/764
  8492. return elem.document.documentElement[ "client" + name ];
  8493. }
  8494. // Get document width or height
  8495. if ( elem.nodeType === 9 ) {
  8496. doc = elem.documentElement;
  8497. // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest
  8498. // unfortunately, this causes bug #3838 in IE6/8 only, but there is currently no good, small way to fix it.
  8499. return Math.max(
  8500. elem.body[ "scroll" + name ], doc[ "scroll" + name ],
  8501. elem.body[ "offset" + name ], doc[ "offset" + name ],
  8502. doc[ "client" + name ]
  8503. );
  8504. }
  8505. return value === undefined ?
  8506. // Get width or height on the element, requesting but not forcing parseFloat
  8507. jQuery.css( elem, type, extra ) :
  8508. // Set width or height on the element
  8509. jQuery.style( elem, type, value, extra );
  8510. }, type, chainable ? margin : undefined, chainable, null );
  8511. };
  8512. });
  8513. });
  8514. // The number of elements contained in the matched element set
  8515. jQuery.fn.size = function() {
  8516. return this.length;
  8517. };
  8518. jQuery.fn.andSelf = jQuery.fn.addBack;
  8519. // Register as a named AMD module, since jQuery can be concatenated with other
  8520. // files that may use define, but not via a proper concatenation script that
  8521. // understands anonymous AMD modules. A named AMD is safest and most robust
  8522. // way to register. Lowercase jquery is used because AMD module names are
  8523. // derived from file names, and jQuery is normally delivered in a lowercase
  8524. // file name. Do this after creating the global so that if an AMD module wants
  8525. // to call noConflict to hide this version of jQuery, it will work.
  8526. // Note that for maximum portability, libraries that are not jQuery should
  8527. // declare themselves as anonymous modules, and avoid setting a global if an
  8528. // AMD loader is present. jQuery is a special case. For more information, see
  8529. // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
  8530. if ( typeof define === "function" && define.amd ) {
  8531. define( "jquery", [], function() {
  8532. return jQuery;
  8533. });
  8534. }
  8535. var
  8536. // Map over jQuery in case of overwrite
  8537. _jQuery = window.jQuery,
  8538. // Map over the $ in case of overwrite
  8539. _$ = window.$;
  8540. jQuery.noConflict = function( deep ) {
  8541. if ( window.$ === jQuery ) {
  8542. window.$ = _$;
  8543. }
  8544. if ( deep && window.jQuery === jQuery ) {
  8545. window.jQuery = _jQuery;
  8546. }
  8547. return jQuery;
  8548. };
  8549. // Expose jQuery and $ identifiers, even in
  8550. // AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
  8551. // and CommonJS for browser emulators (#13566)
  8552. if ( typeof noGlobal === strundefined ) {
  8553. window.jQuery = window.$ = jQuery;
  8554. }
  8555. return jQuery;
  8556. }));