国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
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.

10873 lines
281KB

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