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.

7926 lines
302 KiB

4 years ago
  1. /*!
  2. * jQuery JavaScript Library v3.3.1 -ajax,-ajax/jsonp,-ajax/load,-ajax/parseXML,-ajax/script,-ajax/var/location,-ajax/var/nonce,-ajax/var/rquery,-ajax/xhr,-manipulation/_evalUrl,-event/ajax,-effects,-effects/Tween,-effects/animatedSelector
  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: 2018-01-20T17:24Z
  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 document = window.document;
  44. var getProto = Object.getPrototypeOf;
  45. var slice = arr.slice;
  46. var concat = arr.concat;
  47. var push = arr.push;
  48. var indexOf = arr.indexOf;
  49. var class2type = {};
  50. var toString = class2type.toString;
  51. var hasOwn = class2type.hasOwnProperty;
  52. var fnToString = hasOwn.toString;
  53. var ObjectFunctionString = fnToString.call(Object);
  54. var support = {};
  55. var isFunction = function isFunction(obj) {
  56. // Support: Chrome <=57, Firefox <=52
  57. // In some browsers, typeof returns "function" for HTML <object> elements
  58. // (i.e., `typeof document.createElement( "object" ) === "function"`).
  59. // We don't want to classify *any* DOM node as a function.
  60. return typeof obj === "function" && typeof obj.nodeType !== "number";
  61. };
  62. var isWindow = function isWindow(obj) {
  63. return obj != null && obj === obj.window;
  64. };
  65. var preservedScriptAttributes = {
  66. type: true,
  67. src: true,
  68. noModule: true
  69. };
  70. function DOMEval(code, doc, node) {
  71. doc = doc || document;
  72. var i,
  73. script = doc.createElement("script");
  74. script.text = code;
  75. if (node) {
  76. for (i in preservedScriptAttributes) {
  77. if (node[i]) {
  78. script[i] = node[i];
  79. }
  80. }
  81. }
  82. doc.head.appendChild(script).parentNode.removeChild(script);
  83. }
  84. function toType(obj) {
  85. if (obj == null) {
  86. return obj + "";
  87. }
  88. // Support: Android <=2.3 only (functionish RegExp)
  89. return typeof obj === "object" || typeof obj === "function" ?
  90. class2type[toString.call(obj)] || "object" :
  91. typeof obj;
  92. }
  93. /* global Symbol */
  94. // Defining this global in .eslintrc.json would create a danger of using the global
  95. // unguarded in another place, it seems safer to define global only for this module
  96. var
  97. version = "3.3.1 -ajax,-ajax/jsonp,-ajax/load,-ajax/parseXML,-ajax/script,-ajax/var/location,-ajax/var/nonce,-ajax/var/rquery,-ajax/xhr,-manipulation/_evalUrl,-event/ajax,-effects,-effects/Tween,-effects/animatedSelector",
  98. // Define a local copy of jQuery
  99. jQuery = function (selector, context) {
  100. // The jQuery object is actually just the init constructor 'enhanced'
  101. // Need init if jQuery is called (just allow error to be thrown if not included)
  102. return new jQuery.fn.init(selector, context);
  103. },
  104. // Support: Android <=4.0 only
  105. // Make sure we trim BOM and NBSP
  106. rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
  107. jQuery.fn = jQuery.prototype = {
  108. // The current version of jQuery being used
  109. jquery: version,
  110. constructor: jQuery,
  111. // The default length of a jQuery object is 0
  112. length: 0,
  113. toArray: function () {
  114. return slice.call(this);
  115. },
  116. // Get the Nth element in the matched element set OR
  117. // Get the whole matched element set as a clean array
  118. get: function (num) {
  119. // Return all the elements in a clean array
  120. if (num == null) {
  121. return slice.call(this);
  122. }
  123. // Return just the one element from the set
  124. return num < 0 ? this[num + this.length] : this[num];
  125. },
  126. // Take an array of elements and push it onto the stack
  127. // (returning the new matched element set)
  128. pushStack: function (elems) {
  129. // Build a new jQuery matched element set
  130. var ret = jQuery.merge(this.constructor(), elems);
  131. // Add the old object onto the stack (as a reference)
  132. ret.prevObject = this;
  133. // Return the newly-formed element set
  134. return ret;
  135. },
  136. // Execute a callback for every element in the matched set.
  137. each: function (callback) {
  138. return jQuery.each(this, callback);
  139. },
  140. map: function (callback) {
  141. return this.pushStack(jQuery.map(this, function (elem, i) {
  142. return callback.call(elem, i, elem);
  143. }));
  144. },
  145. slice: function () {
  146. return this.pushStack(slice.apply(this, arguments));
  147. },
  148. first: function () {
  149. return this.eq(0);
  150. },
  151. last: function () {
  152. return this.eq(-1);
  153. },
  154. eq: function (i) {
  155. var len = this.length,
  156. j = +i + (i < 0 ? len : 0);
  157. return this.pushStack(j >= 0 && j < len ? [this[j]] : []);
  158. },
  159. end: function () {
  160. return this.prevObject || this.constructor();
  161. },
  162. // For internal use only.
  163. // Behaves like an Array's method, not like a jQuery method.
  164. push: push,
  165. sort: arr.sort,
  166. splice: arr.splice
  167. };
  168. jQuery.extend = jQuery.fn.extend = function () {
  169. var options, name, src, copy, copyIsArray, clone,
  170. target = arguments[0] || {},
  171. i = 1,
  172. length = arguments.length,
  173. deep = false;
  174. // Handle a deep copy situation
  175. if (typeof target === "boolean") {
  176. deep = target;
  177. // Skip the boolean and the target
  178. target = arguments[i] || {};
  179. i++;
  180. }
  181. // Handle case when target is a string or something (possible in deep copy)
  182. if (typeof target !== "object" && !isFunction(target)) {
  183. target = {};
  184. }
  185. // Extend jQuery itself if only one argument is passed
  186. if (i === length) {
  187. target = this;
  188. i--;
  189. }
  190. for (; i < length; i++) {
  191. // Only deal with non-null/undefined values
  192. if ((options = arguments[i]) != null) {
  193. // Extend the base object
  194. for (name in options) {
  195. src = target[name];
  196. copy = options[name];
  197. // Prevent never-ending loop
  198. if (target === copy) {
  199. continue;
  200. }
  201. // Recurse if we're merging plain objects or arrays
  202. if (deep && copy && (jQuery.isPlainObject(copy) ||
  203. (copyIsArray = Array.isArray(copy)))) {
  204. if (copyIsArray) {
  205. copyIsArray = false;
  206. clone = src && Array.isArray(src) ? src : [];
  207. } else {
  208. clone = src && jQuery.isPlainObject(src) ? src : {};
  209. }
  210. // Never move original objects, clone them
  211. target[name] = jQuery.extend(deep, clone, copy);
  212. // Don't bring in undefined values
  213. } else if (copy !== undefined) {
  214. target[name] = copy;
  215. }
  216. }
  217. }
  218. }
  219. // Return the modified object
  220. return target;
  221. };
  222. jQuery.extend({
  223. // Unique for each copy of jQuery on the page
  224. expando: "jQuery" + (version + Math.random()).replace(/\D/g, ""),
  225. // Assume jQuery is ready without the ready module
  226. isReady: true,
  227. error: function (msg) {
  228. throw new Error(msg);
  229. },
  230. noop: function () { },
  231. isPlainObject: function (obj) {
  232. var proto, Ctor;
  233. // Detect obvious negatives
  234. // Use toString instead of jQuery.type to catch host objects
  235. if (!obj || toString.call(obj) !== "[object Object]") {
  236. return false;
  237. }
  238. proto = getProto(obj);
  239. // Objects with no prototype (e.g., `Object.create( null )`) are plain
  240. if (!proto) {
  241. return true;
  242. }
  243. // Objects with prototype are plain iff they were constructed by a global Object function
  244. Ctor = hasOwn.call(proto, "constructor") && proto.constructor;
  245. return typeof Ctor === "function" && fnToString.call(Ctor) === ObjectFunctionString;
  246. },
  247. isEmptyObject: function (obj) {
  248. /* eslint-disable no-unused-vars */
  249. // See https://github.com/eslint/eslint/issues/6125
  250. var name;
  251. for (name in obj) {
  252. return false;
  253. }
  254. return true;
  255. },
  256. // Evaluates a script in a global context
  257. globalEval: function (code) {
  258. DOMEval(code);
  259. },
  260. each: function (obj, callback) {
  261. var length, i = 0;
  262. if (isArrayLike(obj)) {
  263. length = obj.length;
  264. for (; i < length; i++) {
  265. if (callback.call(obj[i], i, obj[i]) === false) {
  266. break;
  267. }
  268. }
  269. } else {
  270. for (i in obj) {
  271. if (callback.call(obj[i], i, obj[i]) === false) {
  272. break;
  273. }
  274. }
  275. }
  276. return obj;
  277. },
  278. // Support: Android <=4.0 only
  279. trim: function (text) {
  280. return text == null ?
  281. "" :
  282. (text + "").replace(rtrim, "");
  283. },
  284. // results is for internal usage only
  285. makeArray: function (arr, results) {
  286. var ret = results || [];
  287. if (arr != null) {
  288. if (isArrayLike(Object(arr))) {
  289. jQuery.merge(ret,
  290. typeof arr === "string" ?
  291. [arr] : arr
  292. );
  293. } else {
  294. push.call(ret, arr);
  295. }
  296. }
  297. return ret;
  298. },
  299. inArray: function (elem, arr, i) {
  300. return arr == null ? -1 : indexOf.call(arr, elem, i);
  301. },
  302. // Support: Android <=4.0 only, PhantomJS 1 only
  303. // push.apply(_, arraylike) throws on ancient WebKit
  304. merge: function (first, second) {
  305. var len = +second.length,
  306. j = 0,
  307. i = first.length;
  308. for (; j < len; j++) {
  309. first[i++] = second[j];
  310. }
  311. first.length = i;
  312. return first;
  313. },
  314. grep: function (elems, callback, invert) {
  315. var callbackInverse,
  316. matches = [],
  317. i = 0,
  318. length = elems.length,
  319. callbackExpect = !invert;
  320. // Go through the array, only saving the items
  321. // that pass the validator function
  322. for (; i < length; i++) {
  323. callbackInverse = !callback(elems[i], i);
  324. if (callbackInverse !== callbackExpect) {
  325. matches.push(elems[i]);
  326. }
  327. }
  328. return matches;
  329. },
  330. // arg is for internal usage only
  331. map: function (elems, callback, arg) {
  332. var length, value,
  333. i = 0,
  334. ret = [];
  335. // Go through the array, translating each of the items to their new values
  336. if (isArrayLike(elems)) {
  337. length = elems.length;
  338. for (; i < length; i++) {
  339. value = callback(elems[i], i, arg);
  340. if (value != null) {
  341. ret.push(value);
  342. }
  343. }
  344. // Go through every key on the object,
  345. } else {
  346. for (i in elems) {
  347. value = callback(elems[i], i, arg);
  348. if (value != null) {
  349. ret.push(value);
  350. }
  351. }
  352. }
  353. // Flatten any nested arrays
  354. return concat.apply([], ret);
  355. },
  356. // A global GUID counter for objects
  357. guid: 1,
  358. // jQuery.support is not used in Core but other projects attach their
  359. // properties to it so it needs to exist.
  360. support: support
  361. });
  362. if (typeof Symbol === "function") {
  363. jQuery.fn[Symbol.iterator] = arr[Symbol.iterator];
  364. }
  365. // Populate the class2type map
  366. jQuery.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),
  367. function (i, name) {
  368. class2type["[object " + name + "]"] = name.toLowerCase();
  369. });
  370. function isArrayLike(obj) {
  371. // Support: real iOS 8.2 only (not reproducible in simulator)
  372. // `in` check used to prevent JIT error (gh-2145)
  373. // hasOwn isn't used here due to false negatives
  374. // regarding Nodelist length in IE
  375. var length = !!obj && "length" in obj && obj.length,
  376. type = toType(obj);
  377. if (isFunction(obj) || isWindow(obj)) {
  378. return false;
  379. }
  380. return type === "array" || length === 0 ||
  381. typeof length === "number" && length > 0 && (length - 1) in obj;
  382. }
  383. var Sizzle =
  384. /*!
  385. * Sizzle CSS Selector Engine v2.3.3
  386. * https://sizzlejs.com/
  387. *
  388. * Copyright jQuery Foundation and other contributors
  389. * Released under the MIT license
  390. * http://jquery.org/license
  391. *
  392. * Date: 2016-08-08
  393. */
  394. (function (window) {
  395. var i,
  396. support,
  397. Expr,
  398. getText,
  399. isXML,
  400. tokenize,
  401. compile,
  402. select,
  403. outermostContext,
  404. sortInput,
  405. hasDuplicate,
  406. // Local document vars
  407. setDocument,
  408. document,
  409. docElem,
  410. documentIsHTML,
  411. rbuggyQSA,
  412. rbuggyMatches,
  413. matches,
  414. contains,
  415. // Instance-specific data
  416. expando = "sizzle" + 1 * new Date(),
  417. preferredDoc = window.document,
  418. dirruns = 0,
  419. done = 0,
  420. classCache = createCache(),
  421. tokenCache = createCache(),
  422. compilerCache = createCache(),
  423. sortOrder = function (a, b) {
  424. if (a === b) {
  425. hasDuplicate = true;
  426. }
  427. return 0;
  428. },
  429. // Instance methods
  430. hasOwn = ({}).hasOwnProperty,
  431. arr = [],
  432. pop = arr.pop,
  433. push_native = arr.push,
  434. push = arr.push,
  435. slice = arr.slice,
  436. // Use a stripped-down indexOf as it's faster than native
  437. // https://jsperf.com/thor-indexof-vs-for/5
  438. indexOf = function (list, elem) {
  439. var i = 0,
  440. len = list.length;
  441. for (; i < len; i++) {
  442. if (list[i] === elem) {
  443. return i;
  444. }
  445. }
  446. return -1;
  447. },
  448. booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
  449. // Regular expressions
  450. // http://www.w3.org/TR/css3-selectors/#whitespace
  451. whitespace = "[\\x20\\t\\r\\n\\f]",
  452. // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
  453. identifier = "(?:\\\\.|[\\w-]|[^\0-\\xa0])+",
  454. // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
  455. attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
  456. // Operator (capture 2)
  457. "*([*^$|!~]?=)" + whitespace +
  458. // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
  459. "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
  460. "*\\]",
  461. pseudos = ":(" + identifier + ")(?:\\((" +
  462. // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
  463. // 1. quoted (capture 3; capture 4 or capture 5)
  464. "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
  465. // 2. simple (capture 6)
  466. "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
  467. // 3. anything else (capture 2)
  468. ".*" +
  469. ")\\)|)",
  470. // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
  471. rwhitespace = new RegExp(whitespace + "+", "g"),
  472. rtrim = new RegExp("^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g"),
  473. rcomma = new RegExp("^" + whitespace + "*," + whitespace + "*"),
  474. rcombinators = new RegExp("^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*"),
  475. rattributeQuotes = new RegExp("=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g"),
  476. rpseudo = new RegExp(pseudos),
  477. ridentifier = new RegExp("^" + identifier + "$"),
  478. matchExpr = {
  479. "ID": new RegExp("^#(" + identifier + ")"),
  480. "CLASS": new RegExp("^\\.(" + identifier + ")"),
  481. "TAG": new RegExp("^(" + identifier + "|[*])"),
  482. "ATTR": new RegExp("^" + attributes),
  483. "PSEUDO": new RegExp("^" + pseudos),
  484. "CHILD": new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
  485. "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
  486. "*(\\d+)|))" + whitespace + "*\\)|)", "i"),
  487. "bool": new RegExp("^(?:" + booleans + ")$", "i"),
  488. // For use in libraries implementing .is()
  489. // We use this for POS matching in `select`
  490. "needsContext": new RegExp("^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
  491. whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i")
  492. },
  493. rinputs = /^(?:input|select|textarea|button)$/i,
  494. rheader = /^h\d$/i,
  495. rnative = /^[^{]+\{\s*\[native \w/,
  496. // Easily-parseable/retrievable ID or TAG or CLASS selectors
  497. rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
  498. rsibling = /[+~]/,
  499. // CSS escapes
  500. // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
  501. runescape = new RegExp("\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig"),
  502. funescape = function (_, escaped, escapedWhitespace) {
  503. var high = "0x" + escaped - 0x10000;
  504. // NaN means non-codepoint
  505. // Support: Firefox<24
  506. // Workaround erroneous numeric interpretation of +"0x"
  507. return high !== high || escapedWhitespace ?
  508. escaped :
  509. high < 0 ?
  510. // BMP codepoint
  511. String.fromCharCode(high + 0x10000) :
  512. // Supplemental Plane codepoint (surrogate pair)
  513. String.fromCharCode(high >> 10 | 0xD800, high & 0x3FF | 0xDC00);
  514. },
  515. // CSS string/identifier serialization
  516. // https://drafts.csswg.org/cssom/#common-serializing-idioms
  517. rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
  518. fcssescape = function (ch, asCodePoint) {
  519. if (asCodePoint) {
  520. // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
  521. if (ch === "\0") {
  522. return "\uFFFD";
  523. }
  524. // Control characters and (dependent upon position) numbers get escaped as code points
  525. return ch.slice(0, -1) + "\\" + ch.charCodeAt(ch.length - 1).toString(16) + " ";
  526. }
  527. // Other potentially-special ASCII characters get backslash-escaped
  528. return "\\" + ch;
  529. },
  530. // Used for iframes
  531. // See setDocument()
  532. // Removing the function wrapper causes a "Permission Denied"
  533. // error in IE
  534. unloadHandler = function () {
  535. setDocument();
  536. },
  537. disabledAncestor = addCombinator(
  538. function (elem) {
  539. return elem.disabled === true && ("form" in elem || "label" in elem);
  540. },
  541. { dir: "parentNode", next: "legend" }
  542. );
  543. // Optimize for push.apply( _, NodeList )
  544. try {
  545. push.apply(
  546. (arr = slice.call(preferredDoc.childNodes)),
  547. preferredDoc.childNodes
  548. );
  549. // Support: Android<4.0
  550. // Detect silently failing push.apply
  551. arr[preferredDoc.childNodes.length].nodeType;
  552. } catch (e) {
  553. push = {
  554. apply: arr.length ?
  555. // Leverage slice if possible
  556. function (target, els) {
  557. push_native.apply(target, slice.call(els));
  558. } :
  559. // Support: IE<9
  560. // Otherwise append directly
  561. function (target, els) {
  562. var j = target.length,
  563. i = 0;
  564. // Can't trust NodeList.length
  565. while ((target[j++] = els[i++])) { }
  566. target.length = j - 1;
  567. }
  568. };
  569. }
  570. function Sizzle(selector, context, results, seed) {
  571. var m, i, elem, nid, match, groups, newSelector,
  572. newContext = context && context.ownerDocument,
  573. // nodeType defaults to 9, since context defaults to document
  574. nodeType = context ? context.nodeType : 9;
  575. results = results || [];
  576. // Return early from calls with invalid selector or context
  577. if (typeof selector !== "string" || !selector ||
  578. nodeType !== 1 && nodeType !== 9 && nodeType !== 11) {
  579. return results;
  580. }
  581. // Try to shortcut find operations (as opposed to filters) in HTML documents
  582. if (!seed) {
  583. if ((context ? context.ownerDocument || context : preferredDoc) !== document) {
  584. setDocument(context);
  585. }
  586. context = context || document;
  587. if (documentIsHTML) {
  588. // If the selector is sufficiently simple, try using a "get*By*" DOM method
  589. // (excepting DocumentFragment context, where the methods don't exist)
  590. if (nodeType !== 11 && (match = rquickExpr.exec(selector))) {
  591. // ID selector
  592. if ((m = match[1])) {
  593. // Document context
  594. if (nodeType === 9) {
  595. if ((elem = context.getElementById(m))) {
  596. // Support: IE, Opera, Webkit
  597. // TODO: identify versions
  598. // getElementById can match elements by name instead of ID
  599. if (elem.id === m) {
  600. results.push(elem);
  601. return results;
  602. }
  603. } else {
  604. return results;
  605. }
  606. // Element context
  607. } else {
  608. // Support: IE, Opera, Webkit
  609. // TODO: identify versions
  610. // getElementById can match elements by name instead of ID
  611. if (newContext && (elem = newContext.getElementById(m)) &&
  612. contains(context, elem) &&
  613. elem.id === m) {
  614. results.push(elem);
  615. return results;
  616. }
  617. }
  618. // Type selector
  619. } else if (match[2]) {
  620. push.apply(results, context.getElementsByTagName(selector));
  621. return results;
  622. // Class selector
  623. } else if ((m = match[3]) && support.getElementsByClassName &&
  624. context.getElementsByClassName) {
  625. push.apply(results, context.getElementsByClassName(m));
  626. return results;
  627. }
  628. }
  629. // Take advantage of querySelectorAll
  630. if (support.qsa &&
  631. !compilerCache[selector + " "] &&
  632. (!rbuggyQSA || !rbuggyQSA.test(selector))) {
  633. if (nodeType !== 1) {
  634. newContext = context;
  635. newSelector = selector;
  636. // qSA looks outside Element context, which is not what we want
  637. // Thanks to Andrew Dupont for this workaround technique
  638. // Support: IE <=8
  639. // Exclude object elements
  640. } else if (context.nodeName.toLowerCase() !== "object") {
  641. // Capture the context ID, setting it first if necessary
  642. if ((nid = context.getAttribute("id"))) {
  643. nid = nid.replace(rcssescape, fcssescape);
  644. } else {
  645. context.setAttribute("id", (nid = expando));
  646. }
  647. // Prefix every selector in the list
  648. groups = tokenize(selector);
  649. i = groups.length;
  650. while (i--) {
  651. groups[i] = "#" + nid + " " + toSelector(groups[i]);
  652. }
  653. newSelector = groups.join(",");
  654. // Expand context for sibling selectors
  655. newContext = rsibling.test(selector) && testContext(context.parentNode) ||
  656. context;
  657. }
  658. if (newSelector) {
  659. try {
  660. push.apply(results,
  661. newContext.querySelectorAll(newSelector)
  662. );
  663. return results;
  664. } catch (qsaError) {
  665. } finally {
  666. if (nid === expando) {
  667. context.removeAttribute("id");
  668. }
  669. }
  670. }
  671. }
  672. }
  673. }
  674. // All others
  675. return select(selector.replace(rtrim, "$1"), context, results, seed);
  676. }
  677. /**
  678. * Create key-value caches of limited size
  679. * @returns {function(string, object)} Returns the Object data after storing it on itself with
  680. * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
  681. * deleting the oldest entry
  682. */
  683. function createCache() {
  684. var keys = [];
  685. function cache(key, value) {
  686. // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
  687. if (keys.push(key + " ") > Expr.cacheLength) {
  688. // Only keep the most recent entries
  689. delete cache[keys.shift()];
  690. }
  691. return (cache[key + " "] = value);
  692. }
  693. return cache;
  694. }
  695. /**
  696. * Mark a function for special use by Sizzle
  697. * @param {Function} fn The function to mark
  698. */
  699. function markFunction(fn) {
  700. fn[expando] = true;
  701. return fn;
  702. }
  703. /**
  704. * Support testing using an element
  705. * @param {Function} fn Passed the created element and returns a boolean result
  706. */
  707. function assert(fn) {
  708. var el = document.createElement("fieldset");
  709. try {
  710. return !!fn(el);
  711. } catch (e) {
  712. return false;
  713. } finally {
  714. // Remove from its parent by default
  715. if (el.parentNode) {
  716. el.parentNode.removeChild(el);
  717. }
  718. // release memory in IE
  719. el = null;
  720. }
  721. }
  722. /**
  723. * Adds the same handler for all of the specified attrs
  724. * @param {String} attrs Pipe-separated list of attributes
  725. * @param {Function} handler The method that will be applied
  726. */
  727. function addHandle(attrs, handler) {
  728. var arr = attrs.split("|"),
  729. i = arr.length;
  730. while (i--) {
  731. Expr.attrHandle[arr[i]] = handler;
  732. }
  733. }
  734. /**
  735. * Checks document order of two siblings
  736. * @param {Element} a
  737. * @param {Element} b
  738. * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
  739. */
  740. function siblingCheck(a, b) {
  741. var cur = b && a,
  742. diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
  743. a.sourceIndex - b.sourceIndex;
  744. // Use IE sourceIndex if available on both nodes
  745. if (diff) {
  746. return diff;
  747. }
  748. // Check if b follows a
  749. if (cur) {
  750. while ((cur = cur.nextSibling)) {
  751. if (cur === b) {
  752. return -1;
  753. }
  754. }
  755. }
  756. return a ? 1 : -1;
  757. }
  758. /**
  759. * Returns a function to use in pseudos for input types
  760. * @param {String} type
  761. */
  762. function createInputPseudo(type) {
  763. return function (elem) {
  764. var name = elem.nodeName.toLowerCase();
  765. return name === "input" && elem.type === type;
  766. };
  767. }
  768. /**
  769. * Returns a function to use in pseudos for buttons
  770. * @param {String} type
  771. */
  772. function createButtonPseudo(type) {
  773. return function (elem) {
  774. var name = elem.nodeName.toLowerCase();
  775. return (name === "input" || name === "button") && elem.type === type;
  776. };
  777. }
  778. /**
  779. * Returns a function to use in pseudos for :enabled/:disabled
  780. * @param {Boolean} disabled true for :disabled; false for :enabled
  781. */
  782. function createDisabledPseudo(disabled) {
  783. // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
  784. return function (elem) {
  785. // Only certain elements can match :enabled or :disabled
  786. // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
  787. // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
  788. if ("form" in elem) {
  789. // Check for inherited disabledness on relevant non-disabled elements:
  790. // * listed form-associated elements in a disabled fieldset
  791. // https://html.spec.whatwg.org/multipage/forms.html#category-listed
  792. // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
  793. // * option elements in a disabled optgroup
  794. // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
  795. // All such elements have a "form" property.
  796. if (elem.parentNode && elem.disabled === false) {
  797. // Option elements defer to a parent optgroup if present
  798. if ("label" in elem) {
  799. if ("label" in elem.parentNode) {
  800. return elem.parentNode.disabled === disabled;
  801. } else {
  802. return elem.disabled === disabled;
  803. }
  804. }
  805. // Support: IE 6 - 11
  806. // Use the isDisabled shortcut property to check for disabled fieldset ancestors
  807. return elem.isDisabled === disabled ||
  808. // Where there is no isDisabled, check manually
  809. /* jshint -W018 */
  810. elem.isDisabled !== !disabled &&
  811. disabledAncestor(elem) === disabled;
  812. }
  813. return elem.disabled === disabled;
  814. // Try to winnow out elements that can't be disabled before trusting the disabled property.
  815. // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
  816. // even exist on them, let alone have a boolean value.
  817. } else if ("label" in elem) {
  818. return elem.disabled === disabled;
  819. }
  820. // Remaining elements are neither :enabled nor :disabled
  821. return false;
  822. };
  823. }
  824. /**
  825. * Returns a function to use in pseudos for positionals
  826. * @param {Function} fn
  827. */
  828. function createPositionalPseudo(fn) {
  829. return markFunction(function (argument) {
  830. argument = +argument;
  831. return markFunction(function (seed, matches) {
  832. var j,
  833. matchIndexes = fn([], seed.length, argument),
  834. i = matchIndexes.length;
  835. // Match elements found at the specified indexes
  836. while (i--) {
  837. if (seed[(j = matchIndexes[i])]) {
  838. seed[j] = !(matches[j] = seed[j]);
  839. }
  840. }
  841. });
  842. });
  843. }
  844. /**
  845. * Checks a node for validity as a Sizzle context
  846. * @param {Element|Object=} context
  847. * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
  848. */
  849. function testContext(context) {
  850. return context && typeof context.getElementsByTagName !== "undefined" && context;
  851. }
  852. // Expose support vars for convenience
  853. support = Sizzle.support = {};
  854. /**
  855. * Detects XML nodes
  856. * @param {Element|Object} elem An element or a document
  857. * @returns {Boolean} True iff elem is a non-HTML XML node
  858. */
  859. isXML = Sizzle.isXML = function (elem) {
  860. // documentElement is verified for cases where it doesn't yet exist
  861. // (such as loading iframes in IE - #4833)
  862. var documentElement = elem && (elem.ownerDocument || elem).documentElement;
  863. return documentElement ? documentElement.nodeName !== "HTML" : false;
  864. };
  865. /**
  866. * Sets document-related variables once based on the current document
  867. * @param {Element|Object} [doc] An element or document object to use to set the document
  868. * @returns {Object} Returns the current document
  869. */
  870. setDocument = Sizzle.setDocument = function (node) {
  871. var hasCompare, subWindow,
  872. doc = node ? node.ownerDocument || node : preferredDoc;
  873. // Return early if doc is invalid or already selected
  874. if (doc === document || doc.nodeType !== 9 || !doc.documentElement) {
  875. return document;
  876. }
  877. // Update global variables
  878. document = doc;
  879. docElem = document.documentElement;
  880. documentIsHTML = !isXML(document);
  881. // Support: IE 9-11, Edge
  882. // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
  883. if (preferredDoc !== document &&
  884. (subWindow = document.defaultView) && subWindow.top !== subWindow) {
  885. // Support: IE 11, Edge
  886. if (subWindow.addEventListener) {
  887. subWindow.addEventListener("unload", unloadHandler, false);
  888. // Support: IE 9 - 10 only
  889. } else if (subWindow.attachEvent) {
  890. subWindow.attachEvent("onunload", unloadHandler);
  891. }
  892. }
  893. /* Attributes
  894. ---------------------------------------------------------------------- */
  895. // Support: IE<8
  896. // Verify that getAttribute really returns attributes and not properties
  897. // (excepting IE8 booleans)
  898. support.attributes = assert(function (el) {
  899. el.className = "i";
  900. return !el.getAttribute("className");
  901. });
  902. /* getElement(s)By*
  903. ---------------------------------------------------------------------- */
  904. // Check if getElementsByTagName("*") returns only elements
  905. support.getElementsByTagName = assert(function (el) {
  906. el.appendChild(document.createComment(""));
  907. return !el.getElementsByTagName("*").length;
  908. });
  909. // Support: IE<9
  910. support.getElementsByClassName = rnative.test(document.getElementsByClassName);
  911. // Support: IE<10
  912. // Check if getElementById returns elements by name
  913. // The broken getElementById methods don't pick up programmatically-set names,
  914. // so use a roundabout getElementsByName test
  915. support.getById = assert(function (el) {
  916. docElem.appendChild(el).id = expando;
  917. return !document.getElementsByName || !document.getElementsByName(expando).length;
  918. });
  919. // ID filter and find
  920. if (support.getById) {
  921. Expr.filter["ID"] = function (id) {
  922. var attrId = id.replace(runescape, funescape);
  923. return function (elem) {
  924. return elem.getAttribute("id") === attrId;
  925. };
  926. };
  927. Expr.find["ID"] = function (id, context) {
  928. if (typeof context.getElementById !== "undefined" && documentIsHTML) {
  929. var elem = context.getElementById(id);
  930. return elem ? [elem] : [];
  931. }
  932. };
  933. } else {
  934. Expr.filter["ID"] = function (id) {
  935. var attrId = id.replace(runescape, funescape);
  936. return function (elem) {
  937. var node = typeof elem.getAttributeNode !== "undefined" &&
  938. elem.getAttributeNode("id");
  939. return node && node.value === attrId;
  940. };
  941. };
  942. // Support: IE 6 - 7 only
  943. // getElementById is not reliable as a find shortcut
  944. Expr.find["ID"] = function (id, context) {
  945. if (typeof context.getElementById !== "undefined" && documentIsHTML) {
  946. var node, i, elems,
  947. elem = context.getElementById(id);
  948. if (elem) {
  949. // Verify the id attribute
  950. node = elem.getAttributeNode("id");
  951. if (node && node.value === id) {
  952. return [elem];
  953. }
  954. // Fall back on getElementsByName
  955. elems = context.getElementsByName(id);
  956. i = 0;
  957. while ((elem = elems[i++])) {
  958. node = elem.getAttributeNode("id");
  959. if (node && node.value === id) {
  960. return [elem];
  961. }
  962. }
  963. }
  964. return [];
  965. }
  966. };
  967. }
  968. // Tag
  969. Expr.find["TAG"] = support.getElementsByTagName ?
  970. function (tag, context) {
  971. if (typeof context.getElementsByTagName !== "undefined") {
  972. return context.getElementsByTagName(tag);
  973. // DocumentFragment nodes don't have gEBTN
  974. } else if (support.qsa) {
  975. return context.querySelectorAll(tag);
  976. }
  977. } :
  978. function (tag, context) {
  979. var elem,
  980. tmp = [],
  981. i = 0,
  982. // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
  983. results = context.getElementsByTagName(tag);
  984. // Filter out possible comments
  985. if (tag === "*") {
  986. while ((elem = results[i++])) {
  987. if (elem.nodeType === 1) {
  988. tmp.push(elem);
  989. }
  990. }
  991. return tmp;
  992. }
  993. return results;
  994. };
  995. // Class
  996. Expr.find["CLASS"] = support.getElementsByClassName && function (className, context) {
  997. if (typeof context.getElementsByClassName !== "undefined" && documentIsHTML) {
  998. return context.getElementsByClassName(className);
  999. }
  1000. };
  1001. /* QSA/matchesSelector
  1002. ---------------------------------------------------------------------- */
  1003. // QSA and matchesSelector support
  1004. // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
  1005. rbuggyMatches = [];
  1006. // qSa(:focus) reports false when true (Chrome 21)
  1007. // We allow this because of a bug in IE8/9 that throws an error
  1008. // whenever `document.activeElement` is accessed on an iframe
  1009. // So, we allow :focus to pass through QSA all the time to avoid the IE error
  1010. // See https://bugs.jquery.com/ticket/13378
  1011. rbuggyQSA = [];
  1012. if ((support.qsa = rnative.test(document.querySelectorAll))) {
  1013. // Build QSA regex
  1014. // Regex strategy adopted from Diego Perini
  1015. assert(function (el) {
  1016. // Select is set to empty string on purpose
  1017. // This is to test IE's treatment of not explicitly
  1018. // setting a boolean content attribute,
  1019. // since its presence should be enough
  1020. // https://bugs.jquery.com/ticket/12359
  1021. docElem.appendChild(el).innerHTML = "<a id='" + expando + "'></a>" +
  1022. "<select id='" + expando + "-\r\\' msallowcapture=''>" +
  1023. "<option selected=''></option></select>";
  1024. // Support: IE8, Opera 11-12.16
  1025. // Nothing should be selected when empty strings follow ^= or $= or *=
  1026. // The test attribute must be unknown in Opera but "safe" for WinRT
  1027. // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
  1028. if (el.querySelectorAll("[msallowcapture^='']").length) {
  1029. rbuggyQSA.push("[*^$]=" + whitespace + "*(?:''|\"\")");
  1030. }
  1031. // Support: IE8
  1032. // Boolean attributes and "value" are not treated correctly
  1033. if (!el.querySelectorAll("[selected]").length) {
  1034. rbuggyQSA.push("\\[" + whitespace + "*(?:value|" + booleans + ")");
  1035. }
  1036. // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
  1037. if (!el.querySelectorAll("[id~=" + expando + "-]").length) {
  1038. rbuggyQSA.push("~=");
  1039. }
  1040. // Webkit/Opera - :checked should return selected option elements
  1041. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  1042. // IE8 throws error here and will not see later tests
  1043. if (!el.querySelectorAll(":checked").length) {
  1044. rbuggyQSA.push(":checked");
  1045. }
  1046. // Support: Safari 8+, iOS 8+
  1047. // https://bugs.webkit.org/show_bug.cgi?id=136851
  1048. // In-page `selector#id sibling-combinator selector` fails
  1049. if (!el.querySelectorAll("a#" + expando + "+*").length) {
  1050. rbuggyQSA.push(".#.+[+~]");
  1051. }
  1052. });
  1053. assert(function (el) {
  1054. el.innerHTML = "<a href='' disabled='disabled'></a>" +
  1055. "<select disabled='disabled'><option/></select>";
  1056. // Support: Windows 8 Native Apps
  1057. // The type and name attributes are restricted during .innerHTML assignment
  1058. var input = document.createElement("input");
  1059. input.setAttribute("type", "hidden");
  1060. el.appendChild(input).setAttribute("name", "D");
  1061. // Support: IE8
  1062. // Enforce case-sensitivity of name attribute
  1063. if (el.querySelectorAll("[name=d]").length) {
  1064. rbuggyQSA.push("name" + whitespace + "*[*^$|!~]?=");
  1065. }
  1066. // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
  1067. // IE8 throws error here and will not see later tests
  1068. if (el.querySelectorAll(":enabled").length !== 2) {
  1069. rbuggyQSA.push(":enabled", ":disabled");
  1070. }
  1071. // Support: IE9-11+
  1072. // IE's :disabled selector does not pick up the children of disabled fieldsets
  1073. docElem.appendChild(el).disabled = true;
  1074. if (el.querySelectorAll(":disabled").length !== 2) {
  1075. rbuggyQSA.push(":enabled", ":disabled");
  1076. }
  1077. // Opera 10-11 does not throw on post-comma invalid pseudos
  1078. el.querySelectorAll("*,:x");
  1079. rbuggyQSA.push(",.*:");
  1080. });
  1081. }
  1082. if ((support.matchesSelector = rnative.test((matches = docElem.matches ||
  1083. docElem.webkitMatchesSelector ||
  1084. docElem.mozMatchesSelector ||
  1085. docElem.oMatchesSelector ||
  1086. docElem.msMatchesSelector)))) {
  1087. assert(function (el) {
  1088. // Check to see if it's possible to do matchesSelector
  1089. // on a disconnected node (IE 9)
  1090. support.disconnectedMatch = matches.call(el, "*");
  1091. // This should fail with an exception
  1092. // Gecko does not error, returns false instead
  1093. matches.call(el, "[s!='']:x");
  1094. rbuggyMatches.push("!=", pseudos);
  1095. });
  1096. }
  1097. rbuggyQSA = rbuggyQSA.length && new RegExp(rbuggyQSA.join("|"));
  1098. rbuggyMatches = rbuggyMatches.length && new RegExp(rbuggyMatches.join("|"));
  1099. /* Contains
  1100. ---------------------------------------------------------------------- */
  1101. hasCompare = rnative.test(docElem.compareDocumentPosition);
  1102. // Element contains another
  1103. // Purposefully self-exclusive
  1104. // As in, an element does not contain itself
  1105. contains = hasCompare || rnative.test(docElem.contains) ?
  1106. function (a, b) {
  1107. var adown = a.nodeType === 9 ? a.documentElement : a,
  1108. bup = b && b.parentNode;
  1109. return a === bup || !!(bup && bup.nodeType === 1 && (
  1110. adown.contains ?
  1111. adown.contains(bup) :
  1112. a.compareDocumentPosition && a.compareDocumentPosition(bup) & 16
  1113. ));
  1114. } :
  1115. function (a, b) {
  1116. if (b) {
  1117. while ((b = b.parentNode)) {
  1118. if (b === a) {
  1119. return true;
  1120. }
  1121. }
  1122. }
  1123. return false;
  1124. };
  1125. /* Sorting
  1126. ---------------------------------------------------------------------- */
  1127. // Document order sorting
  1128. sortOrder = hasCompare ?
  1129. function (a, b) {
  1130. // Flag for duplicate removal
  1131. if (a === b) {
  1132. hasDuplicate = true;
  1133. return 0;
  1134. }
  1135. // Sort on method existence if only one input has compareDocumentPosition
  1136. var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
  1137. if (compare) {
  1138. return compare;
  1139. }
  1140. // Calculate position if both inputs belong to the same document
  1141. compare = (a.ownerDocument || a) === (b.ownerDocument || b) ?
  1142. a.compareDocumentPosition(b) :
  1143. // Otherwise we know they are disconnected
  1144. 1;
  1145. // Disconnected nodes
  1146. if (compare & 1 ||
  1147. (!support.sortDetached && b.compareDocumentPosition(a) === compare)) {
  1148. // Choose the first element that is related to our preferred document
  1149. if (a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a)) {
  1150. return -1;
  1151. }
  1152. if (b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b)) {
  1153. return 1;
  1154. }
  1155. // Maintain original order
  1156. return sortInput ?
  1157. (indexOf(sortInput, a) - indexOf(sortInput, b)) :
  1158. 0;
  1159. }
  1160. return compare & 4 ? -1 : 1;
  1161. } :
  1162. function (a, b) {
  1163. // Exit early if the nodes are identical
  1164. if (a === b) {
  1165. hasDuplicate = true;
  1166. return 0;
  1167. }
  1168. var cur,
  1169. i = 0,
  1170. aup = a.parentNode,
  1171. bup = b.parentNode,
  1172. ap = [a],
  1173. bp = [b];
  1174. // Parentless nodes are either documents or disconnected
  1175. if (!aup || !bup) {
  1176. return a === document ? -1 :
  1177. b === document ? 1 :
  1178. aup ? -1 :
  1179. bup ? 1 :
  1180. sortInput ?
  1181. (indexOf(sortInput, a) - indexOf(sortInput, b)) :
  1182. 0;
  1183. // If the nodes are siblings, we can do a quick check
  1184. } else if (aup === bup) {
  1185. return siblingCheck(a, b);
  1186. }
  1187. // Otherwise we need full lists of their ancestors for comparison
  1188. cur = a;
  1189. while ((cur = cur.parentNode)) {
  1190. ap.unshift(cur);
  1191. }
  1192. cur = b;
  1193. while ((cur = cur.parentNode)) {
  1194. bp.unshift(cur);
  1195. }
  1196. // Walk down the tree looking for a discrepancy
  1197. while (ap[i] === bp[i]) {
  1198. i++;
  1199. }
  1200. return i ?
  1201. // Do a sibling check if the nodes have a common ancestor
  1202. siblingCheck(ap[i], bp[i]) :
  1203. // Otherwise nodes in our document sort first
  1204. ap[i] === preferredDoc ? -1 :
  1205. bp[i] === preferredDoc ? 1 :
  1206. 0;
  1207. };
  1208. return document;
  1209. };
  1210. Sizzle.matches = function (expr, elements) {
  1211. return Sizzle(expr, null, null, elements);
  1212. };
  1213. Sizzle.matchesSelector = function (elem, expr) {
  1214. // Set document vars if needed
  1215. if ((elem.ownerDocument || elem) !== document) {
  1216. setDocument(elem);
  1217. }
  1218. // Make sure that attribute selectors are quoted
  1219. expr = expr.replace(rattributeQuotes, "='$1']");
  1220. if (support.matchesSelector && documentIsHTML &&
  1221. !compilerCache[expr + " "] &&
  1222. (!rbuggyMatches || !rbuggyMatches.test(expr)) &&
  1223. (!rbuggyQSA || !rbuggyQSA.test(expr))) {
  1224. try {
  1225. var ret = matches.call(elem, expr);
  1226. // IE 9's matchesSelector returns false on disconnected nodes
  1227. if (ret || support.disconnectedMatch ||
  1228. // As well, disconnected nodes are said to be in a document
  1229. // fragment in IE 9
  1230. elem.document && elem.document.nodeType !== 11) {
  1231. return ret;
  1232. }
  1233. } catch (e) { }
  1234. }
  1235. return Sizzle(expr, document, null, [elem]).length > 0;
  1236. };
  1237. Sizzle.contains = function (context, elem) {
  1238. // Set document vars if needed
  1239. if ((context.ownerDocument || context) !== document) {
  1240. setDocument(context);
  1241. }
  1242. return contains(context, elem);
  1243. };
  1244. Sizzle.attr = function (elem, name) {
  1245. // Set document vars if needed
  1246. if ((elem.ownerDocument || elem) !== document) {
  1247. setDocument(elem);
  1248. }
  1249. var fn = Expr.attrHandle[name.toLowerCase()],
  1250. // Don't get fooled by Object.prototype properties (jQuery #13807)
  1251. val = fn && hasOwn.call(Expr.attrHandle, name.toLowerCase()) ?
  1252. fn(elem, name, !documentIsHTML) :
  1253. undefined;
  1254. return val !== undefined ?
  1255. val :
  1256. support.attributes || !documentIsHTML ?
  1257. elem.getAttribute(name) :
  1258. (val = elem.getAttributeNode(name)) && val.specified ?
  1259. val.value :
  1260. null;
  1261. };
  1262. Sizzle.escape = function (sel) {
  1263. return (sel + "").replace(rcssescape, fcssescape);
  1264. };
  1265. Sizzle.error = function (msg) {
  1266. throw new Error("Syntax error, unrecognized expression: " + msg);
  1267. };
  1268. /**
  1269. * Document sorting and removing duplicates
  1270. * @param {ArrayLike} results
  1271. */
  1272. Sizzle.uniqueSort = function (results) {
  1273. var elem,
  1274. duplicates = [],
  1275. j = 0,
  1276. i = 0;
  1277. // Unless we *know* we can detect duplicates, assume their presence
  1278. hasDuplicate = !support.detectDuplicates;
  1279. sortInput = !support.sortStable && results.slice(0);
  1280. results.sort(sortOrder);
  1281. if (hasDuplicate) {
  1282. while ((elem = results[i++])) {
  1283. if (elem === results[i]) {
  1284. j = duplicates.push(i);
  1285. }
  1286. }
  1287. while (j--) {
  1288. results.splice(duplicates[j], 1);
  1289. }
  1290. }
  1291. // Clear input after sorting to release objects
  1292. // See https://github.com/jquery/sizzle/pull/225
  1293. sortInput = null;
  1294. return results;
  1295. };
  1296. /**
  1297. * Utility function for retrieving the text value of an array of DOM nodes
  1298. * @param {Array|Element} elem
  1299. */
  1300. getText = Sizzle.getText = function (elem) {
  1301. var node,
  1302. ret = "",
  1303. i = 0,
  1304. nodeType = elem.nodeType;
  1305. if (!nodeType) {
  1306. // If no nodeType, this is expected to be an array
  1307. while ((node = elem[i++])) {
  1308. // Do not traverse comment nodes
  1309. ret += getText(node);
  1310. }
  1311. } else if (nodeType === 1 || nodeType === 9 || nodeType === 11) {
  1312. // Use textContent for elements
  1313. // innerText usage removed for consistency of new lines (jQuery #11153)
  1314. if (typeof elem.textContent === "string") {
  1315. return elem.textContent;
  1316. } else {
  1317. // Traverse its children
  1318. for (elem = elem.firstChild; elem; elem = elem.nextSibling) {
  1319. ret += getText(elem);
  1320. }
  1321. }
  1322. } else if (nodeType === 3 || nodeType === 4) {
  1323. return elem.nodeValue;
  1324. }
  1325. // Do not include comment or processing instruction nodes
  1326. return ret;
  1327. };
  1328. Expr = Sizzle.selectors = {
  1329. // Can be adjusted by the user
  1330. cacheLength: 50,
  1331. createPseudo: markFunction,
  1332. match: matchExpr,
  1333. attrHandle: {},
  1334. find: {},
  1335. relative: {
  1336. ">": { dir: "parentNode", first: true },
  1337. " ": { dir: "parentNode" },
  1338. "+": { dir: "previousSibling", first: true },
  1339. "~": { dir: "previousSibling" }
  1340. },
  1341. preFilter: {
  1342. "ATTR": function (match) {
  1343. match[1] = match[1].replace(runescape, funescape);
  1344. // Move the given value to match[3] whether quoted or unquoted
  1345. match[3] = (match[3] || match[4] || match[5] || "").replace(runescape, funescape);
  1346. if (match[2] === "~=") {
  1347. match[3] = " " + match[3] + " ";
  1348. }
  1349. return match.slice(0, 4);
  1350. },
  1351. "CHILD": function (match) {
  1352. /* matches from matchExpr["CHILD"]
  1353. 1 type (only|nth|...)
  1354. 2 what (child|of-type)
  1355. 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
  1356. 4 xn-component of xn+y argument ([+-]?\d*n|)
  1357. 5 sign of xn-component
  1358. 6 x of xn-component
  1359. 7 sign of y-component
  1360. 8 y of y-component
  1361. */
  1362. match[1] = match[1].toLowerCase();
  1363. if (match[1].slice(0, 3) === "nth") {
  1364. // nth-* requires argument
  1365. if (!match[3]) {
  1366. Sizzle.error(match[0]);
  1367. }
  1368. // numeric x and y parameters for Expr.filter.CHILD
  1369. // remember that false/true cast respectively to 0/1
  1370. match[4] = +(match[4] ? match[5] + (match[6] || 1) : 2 * (match[3] === "even" || match[3] === "odd"));
  1371. match[5] = +((match[7] + match[8]) || match[3] === "odd");
  1372. // other types prohibit arguments
  1373. } else if (match[3]) {
  1374. Sizzle.error(match[0]);
  1375. }
  1376. return match;
  1377. },
  1378. "PSEUDO": function (match) {
  1379. var excess,
  1380. unquoted = !match[6] && match[2];
  1381. if (matchExpr["CHILD"].test(match[0])) {
  1382. return null;
  1383. }
  1384. // Accept quoted arguments as-is
  1385. if (match[3]) {
  1386. match[2] = match[4] || match[5] || "";
  1387. // Strip excess characters from unquoted arguments
  1388. } else if (unquoted && rpseudo.test(unquoted) &&
  1389. // Get excess from tokenize (recursively)
  1390. (excess = tokenize(unquoted, true)) &&
  1391. // advance to the next closing parenthesis
  1392. (excess = unquoted.indexOf(")", unquoted.length - excess) - unquoted.length)) {
  1393. // excess is a negative index
  1394. match[0] = match[0].slice(0, excess);
  1395. match[2] = unquoted.slice(0, excess);
  1396. }
  1397. // Return only captures needed by the pseudo filter method (type and argument)
  1398. return match.slice(0, 3);
  1399. }
  1400. },
  1401. filter: {
  1402. "TAG": function (nodeNameSelector) {
  1403. var nodeName = nodeNameSelector.replace(runescape, funescape).toLowerCase();
  1404. return nodeNameSelector === "*" ?
  1405. function () { return true; } :
  1406. function (elem) {
  1407. return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
  1408. };
  1409. },
  1410. "CLASS": function (className) {
  1411. var pattern = classCache[className + " "];
  1412. return pattern ||
  1413. (pattern = new RegExp("(^|" + whitespace + ")" + className + "(" + whitespace + "|$)")) &&
  1414. classCache(className, function (elem) {
  1415. return pattern.test(typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "");
  1416. });
  1417. },
  1418. "ATTR": function (name, operator, check) {
  1419. return function (elem) {
  1420. var result = Sizzle.attr(elem, name);
  1421. if (result == null) {
  1422. return operator === "!=";
  1423. }
  1424. if (!operator) {
  1425. return true;
  1426. }
  1427. result += "";
  1428. return operator === "=" ? result === check :
  1429. operator === "!=" ? result !== check :
  1430. operator === "^=" ? check && result.indexOf(check) === 0 :
  1431. operator === "*=" ? check && result.indexOf(check) > -1 :
  1432. operator === "$=" ? check && result.slice(-check.length) === check :
  1433. operator === "~=" ? (" " + result.replace(rwhitespace, " ") + " ").indexOf(check) > -1 :
  1434. operator === "|=" ? result === check || result.slice(0, check.length + 1) === check + "-" :
  1435. false;
  1436. };
  1437. },
  1438. "CHILD": function (type, what, argument, first, last) {
  1439. var simple = type.slice(0, 3) !== "nth",
  1440. forward = type.slice(-4) !== "last",
  1441. ofType = what === "of-type";
  1442. return first === 1 && last === 0 ?
  1443. // Shortcut for :nth-*(n)
  1444. function (elem) {
  1445. return !!elem.parentNode;
  1446. } :
  1447. function (elem, context, xml) {
  1448. var cache, uniqueCache, outerCache, node, nodeIndex, start,
  1449. dir = simple !== forward ? "nextSibling" : "previousSibling",
  1450. parent = elem.parentNode,
  1451. name = ofType && elem.nodeName.toLowerCase(),
  1452. useCache = !xml && !ofType,
  1453. diff = false;
  1454. if (parent) {
  1455. // :(first|last|only)-(child|of-type)
  1456. if (simple) {
  1457. while (dir) {
  1458. node = elem;
  1459. while ((node = node[dir])) {
  1460. if (ofType ?
  1461. node.nodeName.toLowerCase() === name :
  1462. node.nodeType === 1) {
  1463. return false;
  1464. }
  1465. }
  1466. // Reverse direction for :only-* (if we haven't yet done so)
  1467. start = dir = type === "only" && !start && "nextSibling";
  1468. }
  1469. return true;
  1470. }
  1471. start = [forward ? parent.firstChild : parent.lastChild];
  1472. // non-xml :nth-child(...) stores cache data on `parent`
  1473. if (forward && useCache) {
  1474. // Seek `elem` from a previously-cached index
  1475. // ...in a gzip-friendly way
  1476. node = parent;
  1477. outerCache = node[expando] || (node[expando] = {});
  1478. // Support: IE <9 only
  1479. // Defend against cloned attroperties (jQuery gh-1709)
  1480. uniqueCache = outerCache[node.uniqueID] ||
  1481. (outerCache[node.uniqueID] = {});
  1482. cache = uniqueCache[type] || [];
  1483. nodeIndex = cache[0] === dirruns && cache[1];
  1484. diff = nodeIndex && cache[2];
  1485. node = nodeIndex && parent.childNodes[nodeIndex];
  1486. while ((node = ++nodeIndex && node && node[dir] ||
  1487. // Fallback to seeking `elem` from the start
  1488. (diff = nodeIndex = 0) || start.pop())) {
  1489. // When found, cache indexes on `parent` and break
  1490. if (node.nodeType === 1 && ++diff && node === elem) {
  1491. uniqueCache[type] = [dirruns, nodeIndex, diff];
  1492. break;
  1493. }
  1494. }
  1495. } else {
  1496. // Use previously-cached element index if available
  1497. if (useCache) {
  1498. // ...in a gzip-friendly way
  1499. node = elem;
  1500. outerCache = node[expando] || (node[expando] = {});
  1501. // Support: IE <9 only
  1502. // Defend against cloned attroperties (jQuery gh-1709)
  1503. uniqueCache = outerCache[node.uniqueID] ||
  1504. (outerCache[node.uniqueID] = {});
  1505. cache = uniqueCache[type] || [];
  1506. nodeIndex = cache[0] === dirruns && cache[1];
  1507. diff = nodeIndex;
  1508. }
  1509. // xml :nth-child(...)
  1510. // or :nth-last-child(...) or :nth(-last)?-of-type(...)
  1511. if (diff === false) {
  1512. // Use the same loop as above to seek `elem` from the start
  1513. while ((node = ++nodeIndex && node && node[dir] ||
  1514. (diff = nodeIndex = 0) || start.pop())) {
  1515. if ((ofType ?
  1516. node.nodeName.toLowerCase() === name :
  1517. node.nodeType === 1) &&
  1518. ++diff) {
  1519. // Cache the index of each encountered element
  1520. if (useCache) {
  1521. outerCache = node[expando] || (node[expando] = {});
  1522. // Support: IE <9 only
  1523. // Defend against cloned attroperties (jQuery gh-1709)
  1524. uniqueCache = outerCache[node.uniqueID] ||
  1525. (outerCache[node.uniqueID] = {});
  1526. uniqueCache[type] = [dirruns, diff];
  1527. }
  1528. if (node === elem) {
  1529. break;
  1530. }
  1531. }
  1532. }
  1533. }
  1534. }
  1535. // Incorporate the offset, then check against cycle size
  1536. diff -= last;
  1537. return diff === first || (diff % first === 0 && diff / first >= 0);
  1538. }
  1539. };
  1540. },
  1541. "PSEUDO": function (pseudo, argument) {
  1542. // pseudo-class names are case-insensitive
  1543. // http://www.w3.org/TR/selectors/#pseudo-classes
  1544. // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
  1545. // Remember that setFilters inherits from pseudos
  1546. var args,
  1547. fn = Expr.pseudos[pseudo] || Expr.setFilters[pseudo.toLowerCase()] ||
  1548. Sizzle.error("unsupported pseudo: " + pseudo);
  1549. // The user may use createPseudo to indicate that
  1550. // arguments are needed to create the filter function
  1551. // just as Sizzle does
  1552. if (fn[expando]) {
  1553. return fn(argument);
  1554. }
  1555. // But maintain support for old signatures
  1556. if (fn.length > 1) {
  1557. args = [pseudo, pseudo, "", argument];
  1558. return Expr.setFilters.hasOwnProperty(pseudo.toLowerCase()) ?
  1559. markFunction(function (seed, matches) {
  1560. var idx,
  1561. matched = fn(seed, argument),
  1562. i = matched.length;
  1563. while (i--) {
  1564. idx = indexOf(seed, matched[i]);
  1565. seed[idx] = !(matches[idx] = matched[i]);
  1566. }
  1567. }) :
  1568. function (elem) {
  1569. return fn(elem, 0, args);
  1570. };
  1571. }
  1572. return fn;
  1573. }
  1574. },
  1575. pseudos: {
  1576. // Potentially complex pseudos
  1577. "not": markFunction(function (selector) {
  1578. // Trim the selector passed to compile
  1579. // to avoid treating leading and trailing
  1580. // spaces as combinators
  1581. var input = [],
  1582. results = [],
  1583. matcher = compile(selector.replace(rtrim, "$1"));
  1584. return matcher[expando] ?
  1585. markFunction(function (seed, matches, context, xml) {
  1586. var elem,
  1587. unmatched = matcher(seed, null, xml, []),
  1588. i = seed.length;
  1589. // Match elements unmatched by `matcher`
  1590. while (i--) {
  1591. if ((elem = unmatched[i])) {
  1592. seed[i] = !(matches[i] = elem);
  1593. }
  1594. }
  1595. }) :
  1596. function (elem, context, xml) {
  1597. input[0] = elem;
  1598. matcher(input, null, xml, results);
  1599. // Don't keep the element (issue #299)
  1600. input[0] = null;
  1601. return !results.pop();
  1602. };
  1603. }),
  1604. "has": markFunction(function (selector) {
  1605. return function (elem) {
  1606. return Sizzle(selector, elem).length > 0;
  1607. };
  1608. }),
  1609. "contains": markFunction(function (text) {
  1610. text = text.replace(runescape, funescape);
  1611. return function (elem) {
  1612. return (elem.textContent || elem.innerText || getText(elem)).indexOf(text) > -1;
  1613. };
  1614. }),
  1615. // "Whether an element is represented by a :lang() selector
  1616. // is based solely on the element's language value
  1617. // being equal to the identifier C,
  1618. // or beginning with the identifier C immediately followed by "-".
  1619. // The matching of C against the element's language value is performed case-insensitively.
  1620. // The identifier C does not have to be a valid language name."
  1621. // http://www.w3.org/TR/selectors/#lang-pseudo
  1622. "lang": markFunction(function (lang) {
  1623. // lang value must be a valid identifier
  1624. if (!ridentifier.test(lang || "")) {
  1625. Sizzle.error("unsupported lang: " + lang);
  1626. }
  1627. lang = lang.replace(runescape, funescape).toLowerCase();
  1628. return function (elem) {
  1629. var elemLang;
  1630. do {
  1631. if ((elemLang = documentIsHTML ?
  1632. elem.lang :
  1633. elem.getAttribute("xml:lang") || elem.getAttribute("lang"))) {
  1634. elemLang = elemLang.toLowerCase();
  1635. return elemLang === lang || elemLang.indexOf(lang + "-") === 0;
  1636. }
  1637. } while ((elem = elem.parentNode) && elem.nodeType === 1);
  1638. return false;
  1639. };
  1640. }),
  1641. // Miscellaneous
  1642. "target": function (elem) {
  1643. var hash = window.location && window.location.hash;
  1644. return hash && hash.slice(1) === elem.id;
  1645. },
  1646. "root": function (elem) {
  1647. return elem === docElem;
  1648. },
  1649. "focus": function (elem) {
  1650. return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
  1651. },
  1652. // Boolean properties
  1653. "enabled": createDisabledPseudo(false),
  1654. "disabled": createDisabledPseudo(true),
  1655. "checked": function (elem) {
  1656. // In CSS3, :checked should return both checked and selected elements
  1657. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  1658. var nodeName = elem.nodeName.toLowerCase();
  1659. return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
  1660. },
  1661. "selected": function (elem) {
  1662. // Accessing this property makes selected-by-default
  1663. // options in Safari work properly
  1664. if (elem.parentNode) {
  1665. elem.parentNode.selectedIndex;
  1666. }
  1667. return elem.selected === true;
  1668. },
  1669. // Contents
  1670. "empty": function (elem) {
  1671. // http://www.w3.org/TR/selectors/#empty-pseudo
  1672. // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
  1673. // but not by others (comment: 8; processing instruction: 7; etc.)
  1674. // nodeType < 6 works because attributes (2) do not appear as children
  1675. for (elem = elem.firstChild; elem; elem = elem.nextSibling) {
  1676. if (elem.nodeType < 6) {
  1677. return false;
  1678. }
  1679. }
  1680. return true;
  1681. },
  1682. "parent": function (elem) {
  1683. return !Expr.pseudos["empty"](elem);
  1684. },
  1685. // Element/input types
  1686. "header": function (elem) {
  1687. return rheader.test(elem.nodeName);
  1688. },
  1689. "input": function (elem) {
  1690. return rinputs.test(elem.nodeName);
  1691. },
  1692. "button": function (elem) {
  1693. var name = elem.nodeName.toLowerCase();
  1694. return name === "input" && elem.type === "button" || name === "button";
  1695. },
  1696. "text": function (elem) {
  1697. var attr;
  1698. return elem.nodeName.toLowerCase() === "input" &&
  1699. elem.type === "text" &&
  1700. // Support: IE<8
  1701. // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
  1702. ((attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text");
  1703. },
  1704. // Position-in-collection
  1705. "first": createPositionalPseudo(function () {
  1706. return [0];
  1707. }),
  1708. "last": createPositionalPseudo(function (matchIndexes, length) {
  1709. return [length - 1];
  1710. }),
  1711. "eq": createPositionalPseudo(function (matchIndexes, length, argument) {
  1712. return [argument < 0 ? argument + length : argument];
  1713. }),
  1714. "even": createPositionalPseudo(function (matchIndexes, length) {
  1715. var i = 0;
  1716. for (; i < length; i += 2) {
  1717. matchIndexes.push(i);
  1718. }
  1719. return matchIndexes;
  1720. }),
  1721. "odd": createPositionalPseudo(function (matchIndexes, length) {
  1722. var i = 1;
  1723. for (; i < length; i += 2) {
  1724. matchIndexes.push(i);
  1725. }
  1726. return matchIndexes;
  1727. }),
  1728. "lt": createPositionalPseudo(function (matchIndexes, length, argument) {
  1729. var i = argument < 0 ? argument + length : argument;
  1730. for (; --i >= 0;) {
  1731. matchIndexes.push(i);
  1732. }
  1733. return matchIndexes;
  1734. }),
  1735. "gt": createPositionalPseudo(function (matchIndexes, length, argument) {
  1736. var i = argument < 0 ? argument + length : argument;
  1737. for (; ++i < length;) {
  1738. matchIndexes.push(i);
  1739. }
  1740. return matchIndexes;
  1741. })
  1742. }
  1743. };
  1744. Expr.pseudos["nth"] = Expr.pseudos["eq"];
  1745. // Add button/input type pseudos
  1746. for (i in { radio: true, checkbox: true, file: true, password: true, image: true }) {
  1747. Expr.pseudos[i] = createInputPseudo(i);
  1748. }
  1749. for (i in { submit: true, reset: true }) {
  1750. Expr.pseudos[i] = createButtonPseudo(i);
  1751. }
  1752. // Easy API for creating new setFilters
  1753. function setFilters() { }
  1754. setFilters.prototype = Expr.filters = Expr.pseudos;
  1755. Expr.setFilters = new setFilters();
  1756. tokenize = Sizzle.tokenize = function (selector, parseOnly) {
  1757. var matched, match, tokens, type,
  1758. soFar, groups, preFilters,
  1759. cached = tokenCache[selector + " "];
  1760. if (cached) {
  1761. return parseOnly ? 0 : cached.slice(0);
  1762. }
  1763. soFar = selector;
  1764. groups = [];
  1765. preFilters = Expr.preFilter;
  1766. while (soFar) {
  1767. // Comma and first run
  1768. if (!matched || (match = rcomma.exec(soFar))) {
  1769. if (match) {
  1770. // Don't consume trailing commas as valid
  1771. soFar = soFar.slice(match[0].length) || soFar;
  1772. }
  1773. groups.push((tokens = []));
  1774. }
  1775. matched = false;
  1776. // Combinators
  1777. if ((match = rcombinators.exec(soFar))) {
  1778. matched = match.shift();
  1779. tokens.push({
  1780. value: matched,
  1781. // Cast descendant combinators to space
  1782. type: match[0].replace(rtrim, " ")
  1783. });
  1784. soFar = soFar.slice(matched.length);
  1785. }
  1786. // Filters
  1787. for (type in Expr.filter) {
  1788. if ((match = matchExpr[type].exec(soFar)) && (!preFilters[type] ||
  1789. (match = preFilters[type](match)))) {
  1790. matched = match.shift();
  1791. tokens.push({
  1792. value: matched,
  1793. type: type,
  1794. matches: match
  1795. });
  1796. soFar = soFar.slice(matched.length);
  1797. }
  1798. }
  1799. if (!matched) {
  1800. break;
  1801. }
  1802. }
  1803. // Return the length of the invalid excess
  1804. // if we're just parsing
  1805. // Otherwise, throw an error or return tokens
  1806. return parseOnly ?
  1807. soFar.length :
  1808. soFar ?
  1809. Sizzle.error(selector) :
  1810. // Cache the tokens
  1811. tokenCache(selector, groups).slice(0);
  1812. };
  1813. function toSelector(tokens) {
  1814. var i = 0,
  1815. len = tokens.length,
  1816. selector = "";
  1817. for (; i < len; i++) {
  1818. selector += tokens[i].value;
  1819. }
  1820. return selector;
  1821. }
  1822. function addCombinator(matcher, combinator, base) {
  1823. var dir = combinator.dir,
  1824. skip = combinator.next,
  1825. key = skip || dir,
  1826. checkNonElements = base && key === "parentNode",
  1827. doneName = done++;
  1828. return combinator.first ?
  1829. // Check against closest ancestor/preceding element
  1830. function (elem, context, xml) {
  1831. while ((elem = elem[dir])) {
  1832. if (elem.nodeType === 1 || checkNonElements) {
  1833. return matcher(elem, context, xml);
  1834. }
  1835. }
  1836. return false;
  1837. } :
  1838. // Check against all ancestor/preceding elements
  1839. function (elem, context, xml) {
  1840. var oldCache, uniqueCache, outerCache,
  1841. newCache = [dirruns, doneName];
  1842. // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
  1843. if (xml) {
  1844. while ((elem = elem[dir])) {
  1845. if (elem.nodeType === 1 || checkNonElements) {
  1846. if (matcher(elem, context, xml)) {
  1847. return true;
  1848. }
  1849. }
  1850. }
  1851. } else {
  1852. while ((elem = elem[dir])) {
  1853. if (elem.nodeType === 1 || checkNonElements) {
  1854. outerCache = elem[expando] || (elem[expando] = {});
  1855. // Support: IE <9 only
  1856. // Defend against cloned attroperties (jQuery gh-1709)
  1857. uniqueCache = outerCache[elem.uniqueID] || (outerCache[elem.uniqueID] = {});
  1858. if (skip && skip === elem.nodeName.toLowerCase()) {
  1859. elem = elem[dir] || elem;
  1860. } else if ((oldCache = uniqueCache[key]) &&
  1861. oldCache[0] === dirruns && oldCache[1] === doneName) {
  1862. // Assign to newCache so results back-propagate to previous elements
  1863. return (newCache[2] = oldCache[2]);
  1864. } else {
  1865. // Reuse newcache so results back-propagate to previous elements
  1866. uniqueCache[key] = newCache;
  1867. // A match means we're done; a fail means we have to keep checking
  1868. if ((newCache[2] = matcher(elem, context, xml))) {
  1869. return true;
  1870. }
  1871. }
  1872. }
  1873. }
  1874. }
  1875. return false;
  1876. };
  1877. }
  1878. function elementMatcher(matchers) {
  1879. return matchers.length > 1 ?
  1880. function (elem, context, xml) {
  1881. var i = matchers.length;
  1882. while (i--) {
  1883. if (!matchers[i](elem, context, xml)) {
  1884. return false;
  1885. }
  1886. }
  1887. return true;
  1888. } :
  1889. matchers[0];
  1890. }
  1891. function multipleContexts(selector, contexts, results) {
  1892. var i = 0,
  1893. len = contexts.length;
  1894. for (; i < len; i++) {
  1895. Sizzle(selector, contexts[i], results);
  1896. }
  1897. return results;
  1898. }
  1899. function condense(unmatched, map, filter, context, xml) {
  1900. var elem,
  1901. newUnmatched = [],
  1902. i = 0,
  1903. len = unmatched.length,
  1904. mapped = map != null;
  1905. for (; i < len; i++) {
  1906. if ((elem = unmatched[i])) {
  1907. if (!filter || filter(elem, context, xml)) {
  1908. newUnmatched.push(elem);
  1909. if (mapped) {
  1910. map.push(i);
  1911. }
  1912. }
  1913. }
  1914. }
  1915. return newUnmatched;
  1916. }
  1917. function setMatcher(preFilter, selector, matcher, postFilter, postFinder, postSelector) {
  1918. if (postFilter && !postFilter[expando]) {
  1919. postFilter = setMatcher(postFilter);
  1920. }
  1921. if (postFinder && !postFinder[expando]) {
  1922. postFinder = setMatcher(postFinder, postSelector);
  1923. }
  1924. return markFunction(function (seed, results, context, xml) {
  1925. var temp, i, elem,
  1926. preMap = [],
  1927. postMap = [],
  1928. preexisting = results.length,
  1929. // Get initial elements from seed or context
  1930. elems = seed || multipleContexts(selector || "*", context.nodeType ? [context] : context, []),
  1931. // Prefilter to get matcher input, preserving a map for seed-results synchronization
  1932. matcherIn = preFilter && (seed || !selector) ?
  1933. condense(elems, preMap, preFilter, context, xml) :
  1934. elems,
  1935. matcherOut = matcher ?
  1936. // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
  1937. postFinder || (seed ? preFilter : preexisting || postFilter) ?
  1938. // ...intermediate processing is necessary
  1939. [] :
  1940. // ...otherwise use results directly
  1941. results :
  1942. matcherIn;
  1943. // Find primary matches
  1944. if (matcher) {
  1945. matcher(matcherIn, matcherOut, context, xml);
  1946. }
  1947. // Apply postFilter
  1948. if (postFilter) {
  1949. temp = condense(matcherOut, postMap);
  1950. postFilter(temp, [], context, xml);
  1951. // Un-match failing elements by moving them back to matcherIn
  1952. i = temp.length;
  1953. while (i--) {
  1954. if ((elem = temp[i])) {
  1955. matcherOut[postMap[i]] = !(matcherIn[postMap[i]] = elem);
  1956. }
  1957. }
  1958. }
  1959. if (seed) {
  1960. if (postFinder || preFilter) {
  1961. if (postFinder) {
  1962. // Get the final matcherOut by condensing this intermediate into postFinder contexts
  1963. temp = [];
  1964. i = matcherOut.length;
  1965. while (i--) {
  1966. if ((elem = matcherOut[i])) {
  1967. // Restore matcherIn since elem is not yet a final match
  1968. temp.push((matcherIn[i] = elem));
  1969. }
  1970. }
  1971. postFinder(null, (matcherOut = []), temp, xml);
  1972. }
  1973. // Move matched elements from seed to results to keep them synchronized
  1974. i = matcherOut.length;
  1975. while (i--) {
  1976. if ((elem = matcherOut[i]) &&
  1977. (temp = postFinder ? indexOf(seed, elem) : preMap[i]) > -1) {
  1978. seed[temp] = !(results[temp] = elem);
  1979. }
  1980. }
  1981. }
  1982. // Add elements to results, through postFinder if defined
  1983. } else {
  1984. matcherOut = condense(
  1985. matcherOut === results ?
  1986. matcherOut.splice(preexisting, matcherOut.length) :
  1987. matcherOut
  1988. );
  1989. if (postFinder) {
  1990. postFinder(null, results, matcherOut, xml);
  1991. } else {
  1992. push.apply(results, matcherOut);
  1993. }
  1994. }
  1995. });
  1996. }
  1997. function matcherFromTokens(tokens) {
  1998. var checkContext, matcher, j,
  1999. len = tokens.length,
  2000. leadingRelative = Expr.relative[tokens[0].type],
  2001. implicitRelative = leadingRelative || Expr.relative[" "],
  2002. i = leadingRelative ? 1 : 0,
  2003. // The foundational matcher ensures that elements are reachable from top-level context(s)
  2004. matchContext = addCombinator(function (elem) {
  2005. return elem === checkContext;
  2006. }, implicitRelative, true),
  2007. matchAnyContext = addCombinator(function (elem) {
  2008. return indexOf(checkContext, elem) > -1;
  2009. }, implicitRelative, true),
  2010. matchers = [function (elem, context, xml) {
  2011. var ret = (!leadingRelative && (xml || context !== outermostContext)) || (
  2012. (checkContext = context).nodeType ?
  2013. matchContext(elem, context, xml) :
  2014. matchAnyContext(elem, context, xml));
  2015. // Avoid hanging onto element (issue #299)
  2016. checkContext = null;
  2017. return ret;
  2018. }];
  2019. for (; i < len; i++) {
  2020. if ((matcher = Expr.relative[tokens[i].type])) {
  2021. matchers = [addCombinator(elementMatcher(matchers), matcher)];
  2022. } else {
  2023. matcher = Expr.filter[tokens[i].type].apply(null, tokens[i].matches);
  2024. // Return special upon seeing a positional matcher
  2025. if (matcher[expando]) {
  2026. // Find the next relative operator (if any) for proper handling
  2027. j = ++i;
  2028. for (; j < len; j++) {
  2029. if (Expr.relative[tokens[j].type]) {
  2030. break;
  2031. }
  2032. }
  2033. return setMatcher(
  2034. i > 1 && elementMatcher(matchers),
  2035. i > 1 && toSelector(
  2036. // If the preceding token was a descendant combinator, insert an implicit any-element `*`
  2037. tokens.slice(0, i - 1).concat({ value: tokens[i - 2].type === " " ? "*" : "" })
  2038. ).replace(rtrim, "$1"),
  2039. matcher,
  2040. i < j && matcherFromTokens(tokens.slice(i, j)),
  2041. j < len && matcherFromTokens((tokens = tokens.slice(j))),
  2042. j < len && toSelector(tokens)
  2043. );
  2044. }
  2045. matchers.push(matcher);
  2046. }
  2047. }
  2048. return elementMatcher(matchers);
  2049. }
  2050. function matcherFromGroupMatchers(elementMatchers, setMatchers) {
  2051. var bySet = setMatchers.length > 0,
  2052. byElement = elementMatchers.length > 0,
  2053. superMatcher = function (seed, context, xml, results, outermost) {
  2054. var elem, j, matcher,
  2055. matchedCount = 0,
  2056. i = "0",
  2057. unmatched = seed && [],
  2058. setMatched = [],
  2059. contextBackup = outermostContext,
  2060. // We must always have either seed elements or outermost context
  2061. elems = seed || byElement && Expr.find["TAG"]("*", outermost),
  2062. // Use integer dirruns iff this is the outermost matcher
  2063. dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
  2064. len = elems.length;
  2065. if (outermost) {
  2066. outermostContext = context === document || context || outermost;
  2067. }
  2068. // Add elements passing elementMatchers directly to results
  2069. // Support: IE<9, Safari
  2070. // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
  2071. for (; i !== len && (elem = elems[i]) != null; i++) {
  2072. if (byElement && elem) {
  2073. j = 0;
  2074. if (!context && elem.ownerDocument !== document) {
  2075. setDocument(elem);
  2076. xml = !documentIsHTML;
  2077. }
  2078. while ((matcher = elementMatchers[j++])) {
  2079. if (matcher(elem, context || document, xml)) {
  2080. results.push(elem);
  2081. break;
  2082. }
  2083. }
  2084. if (outermost) {
  2085. dirruns = dirrunsUnique;
  2086. }
  2087. }
  2088. // Track unmatched elements for set filters
  2089. if (bySet) {
  2090. // They will have gone through all possible matchers
  2091. if ((elem = !matcher && elem)) {
  2092. matchedCount--;
  2093. }
  2094. // Lengthen the array for every element, matched or not
  2095. if (seed) {
  2096. unmatched.push(elem);
  2097. }
  2098. }
  2099. }
  2100. // `i` is now the count of elements visited above, and adding it to `matchedCount`
  2101. // makes the latter nonnegative.
  2102. matchedCount += i;
  2103. // Apply set filters to unmatched elements
  2104. // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
  2105. // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
  2106. // no element matchers and no seed.
  2107. // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
  2108. // case, which will result in a "00" `matchedCount` that differs from `i` but is also
  2109. // numerically zero.
  2110. if (bySet && i !== matchedCount) {
  2111. j = 0;
  2112. while ((matcher = setMatchers[j++])) {
  2113. matcher(unmatched, setMatched, context, xml);
  2114. }
  2115. if (seed) {
  2116. // Reintegrate element matches to eliminate the need for sorting
  2117. if (matchedCount > 0) {
  2118. while (i--) {
  2119. if (!(unmatched[i] || setMatched[i])) {
  2120. setMatched[i] = pop.call(results);
  2121. }
  2122. }
  2123. }
  2124. // Discard index placeholder values to get only actual matches
  2125. setMatched = condense(setMatched);
  2126. }
  2127. // Add matches to results
  2128. push.apply(results, setMatched);
  2129. // Seedless set matches succeeding multiple successful matchers stipulate sorting
  2130. if (outermost && !seed && setMatched.length > 0 &&
  2131. (matchedCount + setMatchers.length) > 1) {
  2132. Sizzle.uniqueSort(results);
  2133. }
  2134. }
  2135. // Override manipulation of globals by nested matchers
  2136. if (outermost) {
  2137. dirruns = dirrunsUnique;
  2138. outermostContext = contextBackup;
  2139. }
  2140. return unmatched;
  2141. };
  2142. return bySet ?
  2143. markFunction(superMatcher) :
  2144. superMatcher;
  2145. }
  2146. compile = Sizzle.compile = function (selector, match /* Internal Use Only */) {
  2147. var i,
  2148. setMatchers = [],
  2149. elementMatchers = [],
  2150. cached = compilerCache[selector + " "];
  2151. if (!cached) {
  2152. // Generate a function of recursive functions that can be used to check each element
  2153. if (!match) {
  2154. match = tokenize(selector);
  2155. }
  2156. i = match.length;
  2157. while (i--) {
  2158. cached = matcherFromTokens(match[i]);
  2159. if (cached[expando]) {
  2160. setMatchers.push(cached);
  2161. } else {
  2162. elementMatchers.push(cached);
  2163. }
  2164. }
  2165. // Cache the compiled function
  2166. cached = compilerCache(selector, matcherFromGroupMatchers(elementMatchers, setMatchers));
  2167. // Save selector and tokenization
  2168. cached.selector = selector;
  2169. }
  2170. return cached;
  2171. };
  2172. /**
  2173. * A low-level selection function that works with Sizzle's compiled
  2174. * selector functions
  2175. * @param {String|Function} selector A selector or a pre-compiled
  2176. * selector function built with Sizzle.compile
  2177. * @param {Element} context
  2178. * @param {Array} [results]
  2179. * @param {Array} [seed] A set of elements to match against
  2180. */
  2181. select = Sizzle.select = function (selector, context, results, seed) {
  2182. var i, tokens, token, type, find,
  2183. compiled = typeof selector === "function" && selector,
  2184. match = !seed && tokenize((selector = compiled.selector || selector));
  2185. results = results || [];
  2186. // Try to minimize operations if there is only one selector in the list and no seed
  2187. // (the latter of which guarantees us context)
  2188. if (match.length === 1) {
  2189. // Reduce context if the leading compound selector is an ID
  2190. tokens = match[0] = match[0].slice(0);
  2191. if (tokens.length > 2 && (token = tokens[0]).type === "ID" &&
  2192. context.nodeType === 9 && documentIsHTML && Expr.relative[tokens[1].type]) {
  2193. context = (Expr.find["ID"](token.matches[0].replace(runescape, funescape), context) || [])[0];
  2194. if (!context) {
  2195. return results;
  2196. // Precompiled matchers will still verify ancestry, so step up a level
  2197. } else if (compiled) {
  2198. context = context.parentNode;
  2199. }
  2200. selector = selector.slice(tokens.shift().value.length);
  2201. }
  2202. // Fetch a seed set for right-to-left matching
  2203. i = matchExpr["needsContext"].test(selector) ? 0 : tokens.length;
  2204. while (i--) {
  2205. token = tokens[i];
  2206. // Abort if we hit a combinator
  2207. if (Expr.relative[(type = token.type)]) {
  2208. break;
  2209. }
  2210. if ((find = Expr.find[type])) {
  2211. // Search, expanding context for leading sibling combinators
  2212. if ((seed = find(
  2213. token.matches[0].replace(runescape, funescape),
  2214. rsibling.test(tokens[0].type) && testContext(context.parentNode) || context
  2215. ))) {
  2216. // If seed is empty or no tokens remain, we can return early
  2217. tokens.splice(i, 1);
  2218. selector = seed.length && toSelector(tokens);
  2219. if (!selector) {
  2220. push.apply(results, seed);
  2221. return results;
  2222. }
  2223. break;
  2224. }
  2225. }
  2226. }
  2227. }
  2228. // Compile and execute a filtering function if one is not provided
  2229. // Provide `match` to avoid retokenization if we modified the selector above
  2230. (compiled || compile(selector, match))(
  2231. seed,
  2232. context,
  2233. !documentIsHTML,
  2234. results,
  2235. !context || rsibling.test(selector) && testContext(context.parentNode) || context
  2236. );
  2237. return results;
  2238. };
  2239. // One-time assignments
  2240. // Sort stability
  2241. support.sortStable = expando.split("").sort(sortOrder).join("") === expando;
  2242. // Support: Chrome 14-35+
  2243. // Always assume duplicates if they aren't passed to the comparison function
  2244. support.detectDuplicates = !!hasDuplicate;
  2245. // Initialize against the default document
  2246. setDocument();
  2247. // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
  2248. // Detached nodes confoundingly follow *each other*
  2249. support.sortDetached = assert(function (el) {
  2250. // Should return 1, but returns 4 (following)
  2251. return el.compareDocumentPosition(document.createElement("fieldset")) & 1;
  2252. });
  2253. // Support: IE<8
  2254. // Prevent attribute/property "interpolation"
  2255. // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  2256. if (!assert(function (el) {
  2257. el.innerHTML = "<a href='#'></a>";
  2258. return el.firstChild.getAttribute("href") === "#";
  2259. })) {
  2260. addHandle("type|href|height|width", function (elem, name, isXML) {
  2261. if (!isXML) {
  2262. return elem.getAttribute(name, name.toLowerCase() === "type" ? 1 : 2);
  2263. }
  2264. });
  2265. }
  2266. // Support: IE<9
  2267. // Use defaultValue in place of getAttribute("value")
  2268. if (!support.attributes || !assert(function (el) {
  2269. el.innerHTML = "<input/>";
  2270. el.firstChild.setAttribute("value", "");
  2271. return el.firstChild.getAttribute("value") === "";
  2272. })) {
  2273. addHandle("value", function (elem, name, isXML) {
  2274. if (!isXML && elem.nodeName.toLowerCase() === "input") {
  2275. return elem.defaultValue;
  2276. }
  2277. });
  2278. }
  2279. // Support: IE<9
  2280. // Use getAttributeNode to fetch booleans when getAttribute lies
  2281. if (!assert(function (el) {
  2282. return el.getAttribute("disabled") == null;
  2283. })) {
  2284. addHandle(booleans, function (elem, name, isXML) {
  2285. var val;
  2286. if (!isXML) {
  2287. return elem[name] === true ? name.toLowerCase() :
  2288. (val = elem.getAttributeNode(name)) && val.specified ?
  2289. val.value :
  2290. null;
  2291. }
  2292. });
  2293. }
  2294. return Sizzle;
  2295. })(window);
  2296. jQuery.find = Sizzle;
  2297. jQuery.expr = Sizzle.selectors;
  2298. // Deprecated
  2299. jQuery.expr[":"] = jQuery.expr.pseudos;
  2300. jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
  2301. jQuery.text = Sizzle.getText;
  2302. jQuery.isXMLDoc = Sizzle.isXML;
  2303. jQuery.contains = Sizzle.contains;
  2304. jQuery.escapeSelector = Sizzle.escape;
  2305. var dir = function (elem, dir, until) {
  2306. var matched = [],
  2307. truncate = until !== undefined;
  2308. while ((elem = elem[dir]) && elem.nodeType !== 9) {
  2309. if (elem.nodeType === 1) {
  2310. if (truncate && jQuery(elem).is(until)) {
  2311. break;
  2312. }
  2313. matched.push(elem);
  2314. }
  2315. }
  2316. return matched;
  2317. };
  2318. var siblings = function (n, elem) {
  2319. var matched = [];
  2320. for (; n; n = n.nextSibling) {
  2321. if (n.nodeType === 1 && n !== elem) {
  2322. matched.push(n);
  2323. }
  2324. }
  2325. return matched;
  2326. };
  2327. var rneedsContext = jQuery.expr.match.needsContext;
  2328. function nodeName(elem, name) {
  2329. return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
  2330. };
  2331. var rsingleTag = (/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i);
  2332. // Implement the identical functionality for filter and not
  2333. function winnow(elements, qualifier, not) {
  2334. if (isFunction(qualifier)) {
  2335. return jQuery.grep(elements, function (elem, i) {
  2336. return !!qualifier.call(elem, i, elem) !== not;
  2337. });
  2338. }
  2339. // Single element
  2340. if (qualifier.nodeType) {
  2341. return jQuery.grep(elements, function (elem) {
  2342. return (elem === qualifier) !== not;
  2343. });
  2344. }
  2345. // Arraylike of elements (jQuery, arguments, Array)
  2346. if (typeof qualifier !== "string") {
  2347. return jQuery.grep(elements, function (elem) {
  2348. return (indexOf.call(qualifier, elem) > -1) !== not;
  2349. });
  2350. }
  2351. // Filtered directly for both simple and complex selectors
  2352. return jQuery.filter(qualifier, elements, not);
  2353. }
  2354. jQuery.filter = function (expr, elems, not) {
  2355. var elem = elems[0];
  2356. if (not) {
  2357. expr = ":not(" + expr + ")";
  2358. }
  2359. if (elems.length === 1 && elem.nodeType === 1) {
  2360. return jQuery.find.matchesSelector(elem, expr) ? [elem] : [];
  2361. }
  2362. return jQuery.find.matches(expr, jQuery.grep(elems, function (elem) {
  2363. return elem.nodeType === 1;
  2364. }));
  2365. };
  2366. jQuery.fn.extend({
  2367. find: function (selector) {
  2368. var i, ret,
  2369. len = this.length,
  2370. self = this;
  2371. if (typeof selector !== "string") {
  2372. return this.pushStack(jQuery(selector).filter(function () {
  2373. for (i = 0; i < len; i++) {
  2374. if (jQuery.contains(self[i], this)) {
  2375. return true;
  2376. }
  2377. }
  2378. }));
  2379. }
  2380. ret = this.pushStack([]);
  2381. for (i = 0; i < len; i++) {
  2382. jQuery.find(selector, self[i], ret);
  2383. }
  2384. return len > 1 ? jQuery.uniqueSort(ret) : ret;
  2385. },
  2386. filter: function (selector) {
  2387. return this.pushStack(winnow(this, selector || [], false));
  2388. },
  2389. not: function (selector) {
  2390. return this.pushStack(winnow(this, selector || [], true));
  2391. },
  2392. is: function (selector) {
  2393. return !!winnow(
  2394. this,
  2395. // If this is a positional/relative selector, check membership in the returned set
  2396. // so $("p:first").is("p:last") won't return true for a doc with two "p".
  2397. typeof selector === "string" && rneedsContext.test(selector) ?
  2398. jQuery(selector) :
  2399. selector || [],
  2400. false
  2401. ).length;
  2402. }
  2403. });
  2404. // Initialize a jQuery object
  2405. // A central reference to the root jQuery(document)
  2406. var rootjQuery,
  2407. // A simple way to check for HTML strings
  2408. // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
  2409. // Strict HTML recognition (#11290: must start with <)
  2410. // Shortcut simple #id case for speed
  2411. rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
  2412. init = jQuery.fn.init = function (selector, context, root) {
  2413. var match, elem;
  2414. // HANDLE: $(""), $(null), $(undefined), $(false)
  2415. if (!selector) {
  2416. return this;
  2417. }
  2418. // Method init() accepts an alternate rootjQuery
  2419. // so migrate can support jQuery.sub (gh-2101)
  2420. root = root || rootjQuery;
  2421. // Handle HTML strings
  2422. if (typeof selector === "string") {
  2423. if (selector[0] === "<" &&
  2424. selector[selector.length - 1] === ">" &&
  2425. selector.length >= 3) {
  2426. // Assume that strings that start and end with <> are HTML and skip the regex check
  2427. match = [null, selector, null];
  2428. } else {
  2429. match = rquickExpr.exec(selector);
  2430. }
  2431. // Match html or make sure no context is specified for #id
  2432. if (match && (match[1] || !context)) {
  2433. // HANDLE: $(html) -> $(array)
  2434. if (match[1]) {
  2435. context = context instanceof jQuery ? context[0] : context;
  2436. // Option to run scripts is true for back-compat
  2437. // Intentionally let the error be thrown if parseHTML is not present
  2438. jQuery.merge(this, jQuery.parseHTML(
  2439. match[1],
  2440. context && context.nodeType ? context.ownerDocument || context : document,
  2441. true
  2442. ));
  2443. // HANDLE: $(html, props)
  2444. if (rsingleTag.test(match[1]) && jQuery.isPlainObject(context)) {
  2445. for (match in context) {
  2446. // Properties of context are called as methods if possible
  2447. if (isFunction(this[match])) {
  2448. this[match](context[match]);
  2449. // ...and otherwise set as attributes
  2450. } else {
  2451. this.attr(match, context[match]);
  2452. }
  2453. }
  2454. }
  2455. return this;
  2456. // HANDLE: $(#id)
  2457. } else {
  2458. elem = document.getElementById(match[2]);
  2459. if (elem) {
  2460. // Inject the element directly into the jQuery object
  2461. this[0] = elem;
  2462. this.length = 1;
  2463. }
  2464. return this;
  2465. }
  2466. // HANDLE: $(expr, $(...))
  2467. } else if (!context || context.jquery) {
  2468. return (context || root).find(selector);
  2469. // HANDLE: $(expr, context)
  2470. // (which is just equivalent to: $(context).find(expr)
  2471. } else {
  2472. return this.constructor(context).find(selector);
  2473. }
  2474. // HANDLE: $(DOMElement)
  2475. } else if (selector.nodeType) {
  2476. this[0] = selector;
  2477. this.length = 1;
  2478. return this;
  2479. // HANDLE: $(function)
  2480. // Shortcut for document ready
  2481. } else if (isFunction(selector)) {
  2482. return root.ready !== undefined ?
  2483. root.ready(selector) :
  2484. // Execute immediately if ready is not present
  2485. selector(jQuery);
  2486. }
  2487. return jQuery.makeArray(selector, this);
  2488. };
  2489. // Give the init function the jQuery prototype for later instantiation
  2490. init.prototype = jQuery.fn;
  2491. // Initialize central reference
  2492. rootjQuery = jQuery(document);
  2493. var rparentsprev = /^(?:parents|prev(?:Until|All))/,
  2494. // Methods guaranteed to produce a unique set when starting from a unique set
  2495. guaranteedUnique = {
  2496. children: true,
  2497. contents: true,
  2498. next: true,
  2499. prev: true
  2500. };
  2501. jQuery.fn.extend({
  2502. has: function (target) {
  2503. var targets = jQuery(target, this),
  2504. l = targets.length;
  2505. return this.filter(function () {
  2506. var i = 0;
  2507. for (; i < l; i++) {
  2508. if (jQuery.contains(this, targets[i])) {
  2509. return true;
  2510. }
  2511. }
  2512. });
  2513. },
  2514. closest: function (selectors, context) {
  2515. var cur,
  2516. i = 0,
  2517. l = this.length,
  2518. matched = [],
  2519. targets = typeof selectors !== "string" && jQuery(selectors);
  2520. // Positional selectors never match, since there's no _selection_ context
  2521. if (!rneedsContext.test(selectors)) {
  2522. for (; i < l; i++) {
  2523. for (cur = this[i]; cur && cur !== context; cur = cur.parentNode) {
  2524. // Always skip document fragments
  2525. if (cur.nodeType < 11 && (targets ?
  2526. targets.index(cur) > -1 :
  2527. // Don't pass non-elements to Sizzle
  2528. cur.nodeType === 1 &&
  2529. jQuery.find.matchesSelector(cur, selectors))) {
  2530. matched.push(cur);
  2531. break;
  2532. }
  2533. }
  2534. }
  2535. }
  2536. return this.pushStack(matched.length > 1 ? jQuery.uniqueSort(matched) : matched);
  2537. },
  2538. // Determine the position of an element within the set
  2539. index: function (elem) {
  2540. // No argument, return index in parent
  2541. if (!elem) {
  2542. return (this[0] && this[0].parentNode) ? this.first().prevAll().length : -1;
  2543. }
  2544. // Index in selector
  2545. if (typeof elem === "string") {
  2546. return indexOf.call(jQuery(elem), this[0]);
  2547. }
  2548. // Locate the position of the desired element
  2549. return indexOf.call(this,
  2550. // If it receives a jQuery object, the first element is used
  2551. elem.jquery ? elem[0] : elem
  2552. );
  2553. },
  2554. add: function (selector, context) {
  2555. return this.pushStack(
  2556. jQuery.uniqueSort(
  2557. jQuery.merge(this.get(), jQuery(selector, context))
  2558. )
  2559. );
  2560. },
  2561. addBack: function (selector) {
  2562. return this.add(selector == null ?
  2563. this.prevObject : this.prevObject.filter(selector)
  2564. );
  2565. }
  2566. });
  2567. function sibling(cur, dir) {
  2568. while ((cur = cur[dir]) && cur.nodeType !== 1) { }
  2569. return cur;
  2570. }
  2571. jQuery.each({
  2572. parent: function (elem) {
  2573. var parent = elem.parentNode;
  2574. return parent && parent.nodeType !== 11 ? parent : null;
  2575. },
  2576. parents: function (elem) {
  2577. return dir(elem, "parentNode");
  2578. },
  2579. parentsUntil: function (elem, i, until) {
  2580. return dir(elem, "parentNode", until);
  2581. },
  2582. next: function (elem) {
  2583. return sibling(elem, "nextSibling");
  2584. },
  2585. prev: function (elem) {
  2586. return sibling(elem, "previousSibling");
  2587. },
  2588. nextAll: function (elem) {
  2589. return dir(elem, "nextSibling");
  2590. },
  2591. prevAll: function (elem) {
  2592. return dir(elem, "previousSibling");
  2593. },
  2594. nextUntil: function (elem, i, until) {
  2595. return dir(elem, "nextSibling", until);
  2596. },
  2597. prevUntil: function (elem, i, until) {
  2598. return dir(elem, "previousSibling", until);
  2599. },
  2600. siblings: function (elem) {
  2601. return siblings((elem.parentNode || {}).firstChild, elem);
  2602. },
  2603. children: function (elem) {
  2604. return siblings(elem.firstChild);
  2605. },
  2606. contents: function (elem) {
  2607. if (nodeName(elem, "iframe")) {
  2608. return elem.contentDocument;
  2609. }
  2610. // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
  2611. // Treat the template element as a regular one in browsers that
  2612. // don't support it.
  2613. if (nodeName(elem, "template")) {
  2614. elem = elem.content || elem;
  2615. }
  2616. return jQuery.merge([], elem.childNodes);
  2617. }
  2618. }, function (name, fn) {
  2619. jQuery.fn[name] = function (until, selector) {
  2620. var matched = jQuery.map(this, fn, until);
  2621. if (name.slice(-5) !== "Until") {
  2622. selector = until;
  2623. }
  2624. if (selector && typeof selector === "string") {
  2625. matched = jQuery.filter(selector, matched);
  2626. }
  2627. if (this.length > 1) {
  2628. // Remove duplicates
  2629. if (!guaranteedUnique[name]) {
  2630. jQuery.uniqueSort(matched);
  2631. }
  2632. // Reverse order for parents* and prev-derivatives
  2633. if (rparentsprev.test(name)) {
  2634. matched.reverse();
  2635. }
  2636. }
  2637. return this.pushStack(matched);
  2638. };
  2639. });
  2640. var rnothtmlwhite = (/[^\x20\t\r\n\f]+/g);
  2641. // Convert String-formatted options into Object-formatted ones
  2642. function createOptions(options) {
  2643. var object = {};
  2644. jQuery.each(options.match(rnothtmlwhite) || [], function (_, flag) {
  2645. object[flag] = true;
  2646. });
  2647. return object;
  2648. }
  2649. /*
  2650. * Create a callback list using the following parameters:
  2651. *
  2652. * options: an optional list of space-separated options that will change how
  2653. * the callback list behaves or a more traditional option object
  2654. *
  2655. * By default a callback list will act like an event callback list and can be
  2656. * "fired" multiple times.
  2657. *
  2658. * Possible options:
  2659. *
  2660. * once: will ensure the callback list can only be fired once (like a Deferred)
  2661. *
  2662. * memory: will keep track of previous values and will call any callback added
  2663. * after the list has been fired right away with the latest "memorized"
  2664. * values (like a Deferred)
  2665. *
  2666. * unique: will ensure a callback can only be added once (no duplicate in the list)
  2667. *
  2668. * stopOnFalse: interrupt callings when a callback returns false
  2669. *
  2670. */
  2671. jQuery.Callbacks = function (options) {
  2672. // Convert options from String-formatted to Object-formatted if needed
  2673. // (we check in cache first)
  2674. options = typeof options === "string" ?
  2675. createOptions(options) :
  2676. jQuery.extend({}, options);
  2677. var // Flag to know if list is currently firing
  2678. firing,
  2679. // Last fire value for non-forgettable lists
  2680. memory,
  2681. // Flag to know if list was already fired
  2682. fired,
  2683. // Flag to prevent firing
  2684. locked,
  2685. // Actual callback list
  2686. list = [],
  2687. // Queue of execution data for repeatable lists
  2688. queue = [],
  2689. // Index of currently firing callback (modified by add/remove as needed)
  2690. firingIndex = -1,
  2691. // Fire callbacks
  2692. fire = function () {
  2693. // Enforce single-firing
  2694. locked = locked || options.once;
  2695. // Execute callbacks for all pending executions,
  2696. // respecting firingIndex overrides and runtime changes
  2697. fired = firing = true;
  2698. for (; queue.length; firingIndex = -1) {
  2699. memory = queue.shift();
  2700. while (++firingIndex < list.length) {
  2701. // Run callback and check for early termination
  2702. if (list[firingIndex].apply(memory[0], memory[1]) === false &&
  2703. options.stopOnFalse) {
  2704. // Jump to end and forget the data so .add doesn't re-fire
  2705. firingIndex = list.length;
  2706. memory = false;
  2707. }
  2708. }
  2709. }
  2710. // Forget the data if we're done with it
  2711. if (!options.memory) {
  2712. memory = false;
  2713. }
  2714. firing = false;
  2715. // Clean up if we're done firing for good
  2716. if (locked) {
  2717. // Keep an empty list if we have data for future add calls
  2718. if (memory) {
  2719. list = [];
  2720. // Otherwise, this object is spent
  2721. } else {
  2722. list = "";
  2723. }
  2724. }
  2725. },
  2726. // Actual Callbacks object
  2727. self = {
  2728. // Add a callback or a collection of callbacks to the list
  2729. add: function () {
  2730. if (list) {
  2731. // If we have memory from a past run, we should fire after adding
  2732. if (memory && !firing) {
  2733. firingIndex = list.length - 1;
  2734. queue.push(memory);
  2735. }
  2736. (function add(args) {
  2737. jQuery.each(args, function (_, arg) {
  2738. if (isFunction(arg)) {
  2739. if (!options.unique || !self.has(arg)) {
  2740. list.push(arg);
  2741. }
  2742. } else if (arg && arg.length && toType(arg) !== "string") {
  2743. // Inspect recursively
  2744. add(arg);
  2745. }
  2746. });
  2747. })(arguments);
  2748. if (memory && !firing) {
  2749. fire();
  2750. }
  2751. }
  2752. return this;
  2753. },
  2754. // Remove a callback from the list
  2755. remove: function () {
  2756. jQuery.each(arguments, function (_, arg) {
  2757. var index;
  2758. while ((index = jQuery.inArray(arg, list, index)) > -1) {
  2759. list.splice(index, 1);
  2760. // Handle firing indexes
  2761. if (index <= firingIndex) {
  2762. firingIndex--;
  2763. }
  2764. }
  2765. });
  2766. return this;
  2767. },
  2768. // Check if a given callback is in the list.
  2769. // If no argument is given, return whether or not list has callbacks attached.
  2770. has: function (fn) {
  2771. return fn ?
  2772. jQuery.inArray(fn, list) > -1 :
  2773. list.length > 0;
  2774. },
  2775. // Remove all callbacks from the list
  2776. empty: function () {
  2777. if (list) {
  2778. list = [];
  2779. }
  2780. return this;
  2781. },
  2782. // Disable .fire and .add
  2783. // Abort any current/pending executions
  2784. // Clear all callbacks and values
  2785. disable: function () {
  2786. locked = queue = [];
  2787. list = memory = "";
  2788. return this;
  2789. },
  2790. disabled: function () {
  2791. return !list;
  2792. },
  2793. // Disable .fire
  2794. // Also disable .add unless we have memory (since it would have no effect)
  2795. // Abort any pending executions
  2796. lock: function () {
  2797. locked = queue = [];
  2798. if (!memory && !firing) {
  2799. list = memory = "";
  2800. }
  2801. return this;
  2802. },
  2803. locked: function () {
  2804. return !!locked;
  2805. },
  2806. // Call all callbacks with the given context and arguments
  2807. fireWith: function (context, args) {
  2808. if (!locked) {
  2809. args = args || [];
  2810. args = [context, args.slice ? args.slice() : args];
  2811. queue.push(args);
  2812. if (!firing) {
  2813. fire();
  2814. }
  2815. }
  2816. return this;
  2817. },
  2818. // Call all the callbacks with the given arguments
  2819. fire: function () {
  2820. self.fireWith(this, arguments);
  2821. return this;
  2822. },
  2823. // To know if the callbacks have already been called at least once
  2824. fired: function () {
  2825. return !!fired;
  2826. }
  2827. };
  2828. return self;
  2829. };
  2830. function Identity(v) {
  2831. return v;
  2832. }
  2833. function Thrower(ex) {
  2834. throw ex;
  2835. }
  2836. function adoptValue(value, resolve, reject, noValue) {
  2837. var method;
  2838. try {
  2839. // Check for promise aspect first to privilege synchronous behavior
  2840. if (value && isFunction((method = value.promise))) {
  2841. method.call(value).done(resolve).fail(reject);
  2842. // Other thenables
  2843. } else if (value && isFunction((method = value.then))) {
  2844. method.call(value, resolve, reject);
  2845. // Other non-thenables
  2846. } else {
  2847. // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
  2848. // * false: [ value ].slice( 0 ) => resolve( value )
  2849. // * true: [ value ].slice( 1 ) => resolve()
  2850. resolve.apply(undefined, [value].slice(noValue));
  2851. }
  2852. // For Promises/A+, convert exceptions into rejections
  2853. // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
  2854. // Deferred#then to conditionally suppress rejection.
  2855. } catch (value) {
  2856. // Support: Android 4.0 only
  2857. // Strict mode functions invoked without .call/.apply get global-object context
  2858. reject.apply(undefined, [value]);
  2859. }
  2860. }
  2861. jQuery.extend({
  2862. Deferred: function (func) {
  2863. var tuples = [
  2864. // action, add listener, callbacks,
  2865. // ... .then handlers, argument index, [final state]
  2866. ["notify", "progress", jQuery.Callbacks("memory"),
  2867. jQuery.Callbacks("memory"), 2],
  2868. ["resolve", "done", jQuery.Callbacks("once memory"),
  2869. jQuery.Callbacks("once memory"), 0, "resolved"],
  2870. ["reject", "fail", jQuery.Callbacks("once memory"),
  2871. jQuery.Callbacks("once memory"), 1, "rejected"]
  2872. ],
  2873. state = "pending",
  2874. promise = {
  2875. state: function () {
  2876. return state;
  2877. },
  2878. always: function () {
  2879. deferred.done(arguments).fail(arguments);
  2880. return this;
  2881. },
  2882. "catch": function (fn) {
  2883. return promise.then(null, fn);
  2884. },
  2885. // Keep pipe for back-compat
  2886. pipe: function ( /* fnDone, fnFail, fnProgress */) {
  2887. var fns = arguments;
  2888. return jQuery.Deferred(function (newDefer) {
  2889. jQuery.each(tuples, function (i, tuple) {
  2890. // Map tuples (progress, done, fail) to arguments (done, fail, progress)
  2891. var fn = isFunction(fns[tuple[4]]) && fns[tuple[4]];
  2892. // deferred.progress(function() { bind to newDefer or newDefer.notify })
  2893. // deferred.done(function() { bind to newDefer or newDefer.resolve })
  2894. // deferred.fail(function() { bind to newDefer or newDefer.reject })
  2895. deferred[tuple[1]](function () {
  2896. var returned = fn && fn.apply(this, arguments);
  2897. if (returned && isFunction(returned.promise)) {
  2898. returned.promise()
  2899. .progress(newDefer.notify)
  2900. .done(newDefer.resolve)
  2901. .fail(newDefer.reject);
  2902. } else {
  2903. newDefer[tuple[0] + "With"](
  2904. this,
  2905. fn ? [returned] : arguments
  2906. );
  2907. }
  2908. });
  2909. });
  2910. fns = null;
  2911. }).promise();
  2912. },
  2913. then: function (onFulfilled, onRejected, onProgress) {
  2914. var maxDepth = 0;
  2915. function resolve(depth, deferred, handler, special) {
  2916. return function () {
  2917. var that = this,
  2918. args = arguments,
  2919. mightThrow = function () {
  2920. var returned, then;
  2921. // Support: Promises/A+ section 2.3.3.3.3
  2922. // https://promisesaplus.com/#point-59
  2923. // Ignore double-resolution attempts
  2924. if (depth < maxDepth) {
  2925. return;
  2926. }
  2927. returned = handler.apply(that, args);
  2928. // Support: Promises/A+ section 2.3.1
  2929. // https://promisesaplus.com/#point-48
  2930. if (returned === deferred.promise()) {
  2931. throw new TypeError("Thenable self-resolution");
  2932. }
  2933. // Support: Promises/A+ sections 2.3.3.1, 3.5
  2934. // https://promisesaplus.com/#point-54
  2935. // https://promisesaplus.com/#point-75
  2936. // Retrieve `then` only once
  2937. then = returned &&
  2938. // Support: Promises/A+ section 2.3.4
  2939. // https://promisesaplus.com/#point-64
  2940. // Only check objects and functions for thenability
  2941. (typeof returned === "object" ||
  2942. typeof returned === "function") &&
  2943. returned.then;
  2944. // Handle a returned thenable
  2945. if (isFunction(then)) {
  2946. // Special processors (notify) just wait for resolution
  2947. if (special) {
  2948. then.call(
  2949. returned,
  2950. resolve(maxDepth, deferred, Identity, special),
  2951. resolve(maxDepth, deferred, Thrower, special)
  2952. );
  2953. // Normal processors (resolve) also hook into progress
  2954. } else {
  2955. // ...and disregard older resolution values
  2956. maxDepth++;
  2957. then.call(
  2958. returned,
  2959. resolve(maxDepth, deferred, Identity, special),
  2960. resolve(maxDepth, deferred, Thrower, special),
  2961. resolve(maxDepth, deferred, Identity,
  2962. deferred.notifyWith)
  2963. );
  2964. }
  2965. // Handle all other returned values
  2966. } else {
  2967. // Only substitute handlers pass on context
  2968. // and multiple values (non-spec behavior)
  2969. if (handler !== Identity) {
  2970. that = undefined;
  2971. args = [returned];
  2972. }
  2973. // Process the value(s)
  2974. // Default process is resolve
  2975. (special || deferred.resolveWith)(that, args);
  2976. }
  2977. },
  2978. // Only normal processors (resolve) catch and reject exceptions
  2979. process = special ?
  2980. mightThrow :
  2981. function () {
  2982. try {
  2983. mightThrow();
  2984. } catch (e) {
  2985. if (jQuery.Deferred.exceptionHook) {
  2986. jQuery.Deferred.exceptionHook(e,
  2987. process.stackTrace);
  2988. }
  2989. // Support: Promises/A+ section 2.3.3.3.4.1
  2990. // https://promisesaplus.com/#point-61
  2991. // Ignore post-resolution exceptions
  2992. if (depth + 1 >= maxDepth) {
  2993. // Only substitute handlers pass on context
  2994. // and multiple values (non-spec behavior)
  2995. if (handler !== Thrower) {
  2996. that = undefined;
  2997. args = [e];
  2998. }
  2999. deferred.rejectWith(that, args);
  3000. }
  3001. }
  3002. };
  3003. // Support: Promises/A+ section 2.3.3.3.1
  3004. // https://promisesaplus.com/#point-57
  3005. // Re-resolve promises immediately to dodge false rejection from
  3006. // subsequent errors
  3007. if (depth) {
  3008. process();
  3009. } else {
  3010. // Call an optional hook to record the stack, in case of exception
  3011. // since it's otherwise lost when execution goes async
  3012. if (jQuery.Deferred.getStackHook) {
  3013. process.stackTrace = jQuery.Deferred.getStackHook();
  3014. }
  3015. window.setTimeout(process);
  3016. }
  3017. };
  3018. }
  3019. return jQuery.Deferred(function (newDefer) {
  3020. // progress_handlers.add( ... )
  3021. tuples[0][3].add(
  3022. resolve(
  3023. 0,
  3024. newDefer,
  3025. isFunction(onProgress) ?
  3026. onProgress :
  3027. Identity,
  3028. newDefer.notifyWith
  3029. )
  3030. );
  3031. // fulfilled_handlers.add( ... )
  3032. tuples[1][3].add(
  3033. resolve(
  3034. 0,
  3035. newDefer,
  3036. isFunction(onFulfilled) ?
  3037. onFulfilled :
  3038. Identity
  3039. )
  3040. );
  3041. // rejected_handlers.add( ... )
  3042. tuples[2][3].add(
  3043. resolve(
  3044. 0,
  3045. newDefer,
  3046. isFunction(onRejected) ?
  3047. onRejected :
  3048. Thrower
  3049. )
  3050. );
  3051. }).promise();
  3052. },
  3053. // Get a promise for this deferred
  3054. // If obj is provided, the promise aspect is added to the object
  3055. promise: function (obj) {
  3056. return obj != null ? jQuery.extend(obj, promise) : promise;
  3057. }
  3058. },
  3059. deferred = {};
  3060. // Add list-specific methods
  3061. jQuery.each(tuples, function (i, tuple) {
  3062. var list = tuple[2],
  3063. stateString = tuple[5];
  3064. // promise.progress = list.add
  3065. // promise.done = list.add
  3066. // promise.fail = list.add
  3067. promise[tuple[1]] = list.add;
  3068. // Handle state
  3069. if (stateString) {
  3070. list.add(
  3071. function () {
  3072. // state = "resolved" (i.e., fulfilled)
  3073. // state = "rejected"
  3074. state = stateString;
  3075. },
  3076. // rejected_callbacks.disable
  3077. // fulfilled_callbacks.disable
  3078. tuples[3 - i][2].disable,
  3079. // rejected_handlers.disable
  3080. // fulfilled_handlers.disable
  3081. tuples[3 - i][3].disable,
  3082. // progress_callbacks.lock
  3083. tuples[0][2].lock,
  3084. // progress_handlers.lock
  3085. tuples[0][3].lock
  3086. );
  3087. }
  3088. // progress_handlers.fire
  3089. // fulfilled_handlers.fire
  3090. // rejected_handlers.fire
  3091. list.add(tuple[3].fire);
  3092. // deferred.notify = function() { deferred.notifyWith(...) }
  3093. // deferred.resolve = function() { deferred.resolveWith(...) }
  3094. // deferred.reject = function() { deferred.rejectWith(...) }
  3095. deferred[tuple[0]] = function () {
  3096. deferred[tuple[0] + "With"](this === deferred ? undefined : this, arguments);
  3097. return this;
  3098. };
  3099. // deferred.notifyWith = list.fireWith
  3100. // deferred.resolveWith = list.fireWith
  3101. // deferred.rejectWith = list.fireWith
  3102. deferred[tuple[0] + "With"] = list.fireWith;
  3103. });
  3104. // Make the deferred a promise
  3105. promise.promise(deferred);
  3106. // Call given func if any
  3107. if (func) {
  3108. func.call(deferred, deferred);
  3109. }
  3110. // All done!
  3111. return deferred;
  3112. },
  3113. // Deferred helper
  3114. when: function (singleValue) {
  3115. var
  3116. // count of uncompleted subordinates
  3117. remaining = arguments.length,
  3118. // count of unprocessed arguments
  3119. i = remaining,
  3120. // subordinate fulfillment data
  3121. resolveContexts = Array(i),
  3122. resolveValues = slice.call(arguments),
  3123. // the master Deferred
  3124. master = jQuery.Deferred(),
  3125. // subordinate callback factory
  3126. updateFunc = function (i) {
  3127. return function (value) {
  3128. resolveContexts[i] = this;
  3129. resolveValues[i] = arguments.length > 1 ? slice.call(arguments) : value;
  3130. if (!(--remaining)) {
  3131. master.resolveWith(resolveContexts, resolveValues);
  3132. }
  3133. };
  3134. };
  3135. // Single- and empty arguments are adopted like Promise.resolve
  3136. if (remaining <= 1) {
  3137. adoptValue(singleValue, master.done(updateFunc(i)).resolve, master.reject,
  3138. !remaining);
  3139. // Use .then() to unwrap secondary thenables (cf. gh-3000)
  3140. if (master.state() === "pending" ||
  3141. isFunction(resolveValues[i] && resolveValues[i].then)) {
  3142. return master.then();
  3143. }
  3144. }
  3145. // Multiple arguments are aggregated like Promise.all array elements
  3146. while (i--) {
  3147. adoptValue(resolveValues[i], updateFunc(i), master.reject);
  3148. }
  3149. return master.promise();
  3150. }
  3151. });
  3152. // These usually indicate a programmer mistake during development,
  3153. // warn about them ASAP rather than swallowing them by default.
  3154. var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
  3155. jQuery.Deferred.exceptionHook = function (error, stack) {
  3156. // Support: IE 8 - 9 only
  3157. // Console exists when dev tools are open, which can happen at any time
  3158. if (window.console && window.console.warn && error && rerrorNames.test(error.name)) {
  3159. window.console.warn("jQuery.Deferred exception: " + error.message, error.stack, stack);
  3160. }
  3161. };
  3162. jQuery.readyException = function (error) {
  3163. window.setTimeout(function () {
  3164. throw error;
  3165. });
  3166. };
  3167. // The deferred used on DOM ready
  3168. var readyList = jQuery.Deferred();
  3169. jQuery.fn.ready = function (fn) {
  3170. readyList
  3171. .then(fn)
  3172. // Wrap jQuery.readyException in a function so that the lookup
  3173. // happens at the time of error handling instead of callback
  3174. // registration.
  3175. .catch(function (error) {
  3176. jQuery.readyException(error);
  3177. });
  3178. return this;
  3179. };
  3180. jQuery.extend({
  3181. // Is the DOM ready to be used? Set to true once it occurs.
  3182. isReady: false,
  3183. // A counter to track how many items to wait for before
  3184. // the ready event fires. See #6781
  3185. readyWait: 1,
  3186. // Handle when the DOM is ready
  3187. ready: function (wait) {
  3188. // Abort if there are pending holds or we're already ready
  3189. if (wait === true ? --jQuery.readyWait : jQuery.isReady) {
  3190. return;
  3191. }
  3192. // Remember that the DOM is ready
  3193. jQuery.isReady = true;
  3194. // If a normal DOM Ready event fired, decrement, and wait if need be
  3195. if (wait !== true && --jQuery.readyWait > 0) {
  3196. return;
  3197. }
  3198. // If there are functions bound, to execute
  3199. readyList.resolveWith(document, [jQuery]);
  3200. }
  3201. });
  3202. jQuery.ready.then = readyList.then;
  3203. // The ready event handler and self cleanup method
  3204. function completed() {
  3205. document.removeEventListener("DOMContentLoaded", completed);
  3206. window.removeEventListener("load", completed);
  3207. jQuery.ready();
  3208. }
  3209. // Catch cases where $(document).ready() is called
  3210. // after the browser event has already occurred.
  3211. // Support: IE <=9 - 10 only
  3212. // Older IE sometimes signals "interactive" too soon
  3213. if (document.readyState === "complete" ||
  3214. (document.readyState !== "loading" && !document.documentElement.doScroll)) {
  3215. // Handle it asynchronously to allow scripts the opportunity to delay ready
  3216. window.setTimeout(jQuery.ready);
  3217. } else {
  3218. // Use the handy event callback
  3219. document.addEventListener("DOMContentLoaded", completed);
  3220. // A fallback to window.onload, that will always work
  3221. window.addEventListener("load", completed);
  3222. }
  3223. // Multifunctional method to get and set values of a collection
  3224. // The value/s can optionally be executed if it's a function
  3225. var access = function (elems, fn, key, value, chainable, emptyGet, raw) {
  3226. var i = 0,
  3227. len = elems.length,
  3228. bulk = key == null;
  3229. // Sets many values
  3230. if (toType(key) === "object") {
  3231. chainable = true;
  3232. for (i in key) {
  3233. access(elems, fn, i, key[i], true, emptyGet, raw);
  3234. }
  3235. // Sets one value
  3236. } else if (value !== undefined) {
  3237. chainable = true;
  3238. if (!isFunction(value)) {
  3239. raw = true;
  3240. }
  3241. if (bulk) {
  3242. // Bulk operations run against the entire set
  3243. if (raw) {
  3244. fn.call(elems, value);
  3245. fn = null;
  3246. // ...except when executing function values
  3247. } else {
  3248. bulk = fn;
  3249. fn = function (elem, key, value) {
  3250. return bulk.call(jQuery(elem), value);
  3251. };
  3252. }
  3253. }
  3254. if (fn) {
  3255. for (; i < len; i++) {
  3256. fn(
  3257. elems[i], key, raw ?
  3258. value :
  3259. value.call(elems[i], i, fn(elems[i], key))
  3260. );
  3261. }
  3262. }
  3263. }
  3264. if (chainable) {
  3265. return elems;
  3266. }
  3267. // Gets
  3268. if (bulk) {
  3269. return fn.call(elems);
  3270. }
  3271. return len ? fn(elems[0], key) : emptyGet;
  3272. };
  3273. // Matches dashed string for camelizing
  3274. var rmsPrefix = /^-ms-/,
  3275. rdashAlpha = /-([a-z])/g;
  3276. // Used by camelCase as callback to replace()
  3277. function fcamelCase(all, letter) {
  3278. return letter.toUpperCase();
  3279. }
  3280. // Convert dashed to camelCase; used by the css and data modules
  3281. // Support: IE <=9 - 11, Edge 12 - 15
  3282. // Microsoft forgot to hump their vendor prefix (#9572)
  3283. function camelCase(string) {
  3284. return string.replace(rmsPrefix, "ms-").replace(rdashAlpha, fcamelCase);
  3285. }
  3286. var acceptData = function (owner) {
  3287. // Accepts only:
  3288. // - Node
  3289. // - Node.ELEMENT_NODE
  3290. // - Node.DOCUMENT_NODE
  3291. // - Object
  3292. // - Any
  3293. return owner.nodeType === 1 || owner.nodeType === 9 || !(+owner.nodeType);
  3294. };
  3295. function Data() {
  3296. this.expando = jQuery.expando + Data.uid++;
  3297. }
  3298. Data.uid = 1;
  3299. Data.prototype = {
  3300. cache: function (owner) {
  3301. // Check if the owner object already has a cache
  3302. var value = owner[this.expando];
  3303. // If not, create one
  3304. if (!value) {
  3305. value = {};
  3306. // We can accept data for non-element nodes in modern browsers,
  3307. // but we should not, see #8335.
  3308. // Always return an empty object.
  3309. if (acceptData(owner)) {
  3310. // If it is a node unlikely to be stringify-ed or looped over
  3311. // use plain assignment
  3312. if (owner.nodeType) {
  3313. owner[this.expando] = value;
  3314. // Otherwise secure it in a non-enumerable property
  3315. // configurable must be true to allow the property to be
  3316. // deleted when data is removed
  3317. } else {
  3318. Object.defineProperty(owner, this.expando, {
  3319. value: value,
  3320. configurable: true
  3321. });
  3322. }
  3323. }
  3324. }
  3325. return value;
  3326. },
  3327. set: function (owner, data, value) {
  3328. var prop,
  3329. cache = this.cache(owner);
  3330. // Handle: [ owner, key, value ] args
  3331. // Always use camelCase key (gh-2257)
  3332. if (typeof data === "string") {
  3333. cache[camelCase(data)] = value;
  3334. // Handle: [ owner, { properties } ] args
  3335. } else {
  3336. // Copy the properties one-by-one to the cache object
  3337. for (prop in data) {
  3338. cache[camelCase(prop)] = data[prop];
  3339. }
  3340. }
  3341. return cache;
  3342. },
  3343. get: function (owner, key) {
  3344. return key === undefined ?
  3345. this.cache(owner) :
  3346. // Always use camelCase key (gh-2257)
  3347. owner[this.expando] && owner[this.expando][camelCase(key)];
  3348. },
  3349. access: function (owner, key, value) {
  3350. // In cases where either:
  3351. //
  3352. // 1. No key was specified
  3353. // 2. A string key was specified, but no value provided
  3354. //
  3355. // Take the "read" path and allow the get method to determine
  3356. // which value to return, respectively either:
  3357. //
  3358. // 1. The entire cache object
  3359. // 2. The data stored at the key
  3360. //
  3361. if (key === undefined ||
  3362. ((key && typeof key === "string") && value === undefined)) {
  3363. return this.get(owner, key);
  3364. }
  3365. // When the key is not a string, or both a key and value
  3366. // are specified, set or extend (existing objects) with either:
  3367. //
  3368. // 1. An object of properties
  3369. // 2. A key and value
  3370. //
  3371. this.set(owner, key, value);
  3372. // Since the "set" path can have two possible entry points
  3373. // return the expected data based on which path was taken[*]
  3374. return value !== undefined ? value : key;
  3375. },
  3376. remove: function (owner, key) {
  3377. var i,
  3378. cache = owner[this.expando];
  3379. if (cache === undefined) {
  3380. return;
  3381. }
  3382. if (key !== undefined) {
  3383. // Support array or space separated string of keys
  3384. if (Array.isArray(key)) {
  3385. // If key is an array of keys...
  3386. // We always set camelCase keys, so remove that.
  3387. key = key.map(camelCase);
  3388. } else {
  3389. key = camelCase(key);
  3390. // If a key with the spaces exists, use it.
  3391. // Otherwise, create an array by matching non-whitespace
  3392. key = key in cache ?
  3393. [key] :
  3394. (key.match(rnothtmlwhite) || []);
  3395. }
  3396. i = key.length;
  3397. while (i--) {
  3398. delete cache[key[i]];
  3399. }
  3400. }
  3401. // Remove the expando if there's no more data
  3402. if (key === undefined || jQuery.isEmptyObject(cache)) {
  3403. // Support: Chrome <=35 - 45
  3404. // Webkit & Blink performance suffers when deleting properties
  3405. // from DOM nodes, so set to undefined instead
  3406. // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
  3407. if (owner.nodeType) {
  3408. owner[this.expando] = undefined;
  3409. } else {
  3410. delete owner[this.expando];
  3411. }
  3412. }
  3413. },
  3414. hasData: function (owner) {
  3415. var cache = owner[this.expando];
  3416. return cache !== undefined && !jQuery.isEmptyObject(cache);
  3417. }
  3418. };
  3419. var dataPriv = new Data();
  3420. var dataUser = new Data();
  3421. // Implementation Summary
  3422. //
  3423. // 1. Enforce API surface and semantic compatibility with 1.9.x branch
  3424. // 2. Improve the module's maintainability by reducing the storage
  3425. // paths to a single mechanism.
  3426. // 3. Use the same single mechanism to support "private" and "user" data.
  3427. // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
  3428. // 5. Avoid exposing implementation details on user objects (eg. expando properties)
  3429. // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
  3430. var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
  3431. rmultiDash = /[A-Z]/g;
  3432. function getData(data) {
  3433. if (data === "true") {
  3434. return true;
  3435. }
  3436. if (data === "false") {
  3437. return false;
  3438. }
  3439. if (data === "null") {
  3440. return null;
  3441. }
  3442. // Only convert to a number if it doesn't change the string
  3443. if (data === +data + "") {
  3444. return +data;
  3445. }
  3446. if (rbrace.test(data)) {
  3447. return JSON.parse(data);
  3448. }
  3449. return data;
  3450. }
  3451. function dataAttr(elem, key, data) {
  3452. var name;
  3453. // If nothing was found internally, try to fetch any
  3454. // data from the HTML5 data-* attribute
  3455. if (data === undefined && elem.nodeType === 1) {
  3456. name = "data-" + key.replace(rmultiDash, "-$&").toLowerCase();
  3457. data = elem.getAttribute(name);
  3458. if (typeof data === "string") {
  3459. try {
  3460. data = getData(data);
  3461. } catch (e) { }
  3462. // Make sure we set the data so it isn't changed later
  3463. dataUser.set(elem, key, data);
  3464. } else {
  3465. data = undefined;
  3466. }
  3467. }
  3468. return data;
  3469. }
  3470. jQuery.extend({
  3471. hasData: function (elem) {
  3472. return dataUser.hasData(elem) || dataPriv.hasData(elem);
  3473. },
  3474. data: function (elem, name, data) {
  3475. return dataUser.access(elem, name, data);
  3476. },
  3477. removeData: function (elem, name) {
  3478. dataUser.remove(elem, name);
  3479. },
  3480. // TODO: Now that all calls to _data and _removeData have been replaced
  3481. // with direct calls to dataPriv methods, these can be deprecated.
  3482. _data: function (elem, name, data) {
  3483. return dataPriv.access(elem, name, data);
  3484. },
  3485. _removeData: function (elem, name) {
  3486. dataPriv.remove(elem, name);
  3487. }
  3488. });
  3489. jQuery.fn.extend({
  3490. data: function (key, value) {
  3491. var i, name, data,
  3492. elem = this[0],
  3493. attrs = elem && elem.attributes;
  3494. // Gets all values
  3495. if (key === undefined) {
  3496. if (this.length) {
  3497. data = dataUser.get(elem);
  3498. if (elem.nodeType === 1 && !dataPriv.get(elem, "hasDataAttrs")) {
  3499. i = attrs.length;
  3500. while (i--) {
  3501. // Support: IE 11 only
  3502. // The attrs elements can be null (#14894)
  3503. if (attrs[i]) {
  3504. name = attrs[i].name;
  3505. if (name.indexOf("data-") === 0) {
  3506. name = camelCase(name.slice(5));
  3507. dataAttr(elem, name, data[name]);
  3508. }
  3509. }
  3510. }
  3511. dataPriv.set(elem, "hasDataAttrs", true);
  3512. }
  3513. }
  3514. return data;
  3515. }
  3516. // Sets multiple values
  3517. if (typeof key === "object") {
  3518. return this.each(function () {
  3519. dataUser.set(this, key);
  3520. });
  3521. }
  3522. return access(this, function (value) {
  3523. var data;
  3524. // The calling jQuery object (element matches) is not empty
  3525. // (and therefore has an element appears at this[ 0 ]) and the
  3526. // `value` parameter was not undefined. An empty jQuery object
  3527. // will result in `undefined` for elem = this[ 0 ] which will
  3528. // throw an exception if an attempt to read a data cache is made.
  3529. if (elem && value === undefined) {
  3530. // Attempt to get data from the cache
  3531. // The key will always be camelCased in Data
  3532. data = dataUser.get(elem, key);
  3533. if (data !== undefined) {
  3534. return data;
  3535. }
  3536. // Attempt to "discover" the data in
  3537. // HTML5 custom data-* attrs
  3538. data = dataAttr(elem, key);
  3539. if (data !== undefined) {
  3540. return data;
  3541. }
  3542. // We tried really hard, but the data doesn't exist.
  3543. return;
  3544. }
  3545. // Set the data...
  3546. this.each(function () {
  3547. // We always store the camelCased key
  3548. dataUser.set(this, key, value);
  3549. });
  3550. }, null, value, arguments.length > 1, null, true);
  3551. },
  3552. removeData: function (key) {
  3553. return this.each(function () {
  3554. dataUser.remove(this, key);
  3555. });
  3556. }
  3557. });
  3558. jQuery.extend({
  3559. queue: function (elem, type, data) {
  3560. var queue;
  3561. if (elem) {
  3562. type = (type || "fx") + "queue";
  3563. queue = dataPriv.get(elem, type);
  3564. // Speed up dequeue by getting out quickly if this is just a lookup
  3565. if (data) {
  3566. if (!queue || Array.isArray(data)) {
  3567. queue = dataPriv.access(elem, type, jQuery.makeArray(data));
  3568. } else {
  3569. queue.push(data);
  3570. }
  3571. }
  3572. return queue || [];
  3573. }
  3574. },
  3575. dequeue: function (elem, type) {
  3576. type = type || "fx";
  3577. var queue = jQuery.queue(elem, type),
  3578. startLength = queue.length,
  3579. fn = queue.shift(),
  3580. hooks = jQuery._queueHooks(elem, type),
  3581. next = function () {
  3582. jQuery.dequeue(elem, type);
  3583. };
  3584. // If the fx queue is dequeued, always remove the progress sentinel
  3585. if (fn === "inprogress") {
  3586. fn = queue.shift();
  3587. startLength--;
  3588. }
  3589. if (fn) {
  3590. // Add a progress sentinel to prevent the fx queue from being
  3591. // automatically dequeued
  3592. if (type === "fx") {
  3593. queue.unshift("inprogress");
  3594. }
  3595. // Clear up the last queue stop function
  3596. delete hooks.stop;
  3597. fn.call(elem, next, hooks);
  3598. }
  3599. if (!startLength && hooks) {
  3600. hooks.empty.fire();
  3601. }
  3602. },
  3603. // Not public - generate a queueHooks object, or return the current one
  3604. _queueHooks: function (elem, type) {
  3605. var key = type + "queueHooks";
  3606. return dataPriv.get(elem, key) || dataPriv.access(elem, key, {
  3607. empty: jQuery.Callbacks("once memory").add(function () {
  3608. dataPriv.remove(elem, [type + "queue", key]);
  3609. })
  3610. });
  3611. }
  3612. });
  3613. jQuery.fn.extend({
  3614. queue: function (type, data) {
  3615. var setter = 2;
  3616. if (typeof type !== "string") {
  3617. data = type;
  3618. type = "fx";
  3619. setter--;
  3620. }
  3621. if (arguments.length < setter) {
  3622. return jQuery.queue(this[0], type);
  3623. }
  3624. return data === undefined ?
  3625. this :
  3626. this.each(function () {
  3627. var queue = jQuery.queue(this, type, data);
  3628. // Ensure a hooks for this queue
  3629. jQuery._queueHooks(this, type);
  3630. if (type === "fx" && queue[0] !== "inprogress") {
  3631. jQuery.dequeue(this, type);
  3632. }
  3633. });
  3634. },
  3635. dequeue: function (type) {
  3636. return this.each(function () {
  3637. jQuery.dequeue(this, type);
  3638. });
  3639. },
  3640. clearQueue: function (type) {
  3641. return this.queue(type || "fx", []);
  3642. },
  3643. // Get a promise resolved when queues of a certain type
  3644. // are emptied (fx is the type by default)
  3645. promise: function (type, obj) {
  3646. var tmp,
  3647. count = 1,
  3648. defer = jQuery.Deferred(),
  3649. elements = this,
  3650. i = this.length,
  3651. resolve = function () {
  3652. if (!(--count)) {
  3653. defer.resolveWith(elements, [elements]);
  3654. }
  3655. };
  3656. if (typeof type !== "string") {
  3657. obj = type;
  3658. type = undefined;
  3659. }
  3660. type = type || "fx";
  3661. while (i--) {
  3662. tmp = dataPriv.get(elements[i], type + "queueHooks");
  3663. if (tmp && tmp.empty) {
  3664. count++;
  3665. tmp.empty.add(resolve);
  3666. }
  3667. }
  3668. resolve();
  3669. return defer.promise(obj);
  3670. }
  3671. });
  3672. var pnum = (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source;
  3673. var rcssNum = new RegExp("^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i");
  3674. var cssExpand = ["Top", "Right", "Bottom", "Left"];
  3675. var isHiddenWithinTree = function (elem, el) {
  3676. // isHiddenWithinTree might be called from jQuery#filter function;
  3677. // in that case, element will be second argument
  3678. elem = el || elem;
  3679. // Inline style trumps all
  3680. return elem.style.display === "none" ||
  3681. elem.style.display === "" &&
  3682. // Otherwise, check computed style
  3683. // Support: Firefox <=43 - 45
  3684. // Disconnected elements can have computed display: none, so first confirm that elem is
  3685. // in the document.
  3686. jQuery.contains(elem.ownerDocument, elem) &&
  3687. jQuery.css(elem, "display") === "none";
  3688. };
  3689. var swap = function (elem, options, callback, args) {
  3690. var ret, name,
  3691. old = {};
  3692. // Remember the old values, and insert the new ones
  3693. for (name in options) {
  3694. old[name] = elem.style[name];
  3695. elem.style[name] = options[name];
  3696. }
  3697. ret = callback.apply(elem, args || []);
  3698. // Revert the old values
  3699. for (name in options) {
  3700. elem.style[name] = old[name];
  3701. }
  3702. return ret;
  3703. };
  3704. function adjustCSS(elem, prop, valueParts, tween) {
  3705. var adjusted, scale,
  3706. maxIterations = 20,
  3707. currentValue = tween ?
  3708. function () {
  3709. return tween.cur();
  3710. } :
  3711. function () {
  3712. return jQuery.css(elem, prop, "");
  3713. },
  3714. initial = currentValue(),
  3715. unit = valueParts && valueParts[3] || (jQuery.cssNumber[prop] ? "" : "px"),
  3716. // Starting value computation is required for potential unit mismatches
  3717. initialInUnit = (jQuery.cssNumber[prop] || unit !== "px" && +initial) &&
  3718. rcssNum.exec(jQuery.css(elem, prop));
  3719. if (initialInUnit && initialInUnit[3] !== unit) {
  3720. // Support: Firefox <=54
  3721. // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
  3722. initial = initial / 2;
  3723. // Trust units reported by jQuery.css
  3724. unit = unit || initialInUnit[3];
  3725. // Iteratively approximate from a nonzero starting point
  3726. initialInUnit = +initial || 1;
  3727. while (maxIterations--) {
  3728. // Evaluate and update our best guess (doubling guesses that zero out).
  3729. // Finish if the scale equals or crosses 1 (making the old*new product non-positive).
  3730. jQuery.style(elem, prop, initialInUnit + unit);
  3731. if ((1 - scale) * (1 - (scale = currentValue() / initial || 0.5)) <= 0) {
  3732. maxIterations = 0;
  3733. }
  3734. initialInUnit = initialInUnit / scale;
  3735. }
  3736. initialInUnit = initialInUnit * 2;
  3737. jQuery.style(elem, prop, initialInUnit + unit);
  3738. // Make sure we update the tween properties later on
  3739. valueParts = valueParts || [];
  3740. }
  3741. if (valueParts) {
  3742. initialInUnit = +initialInUnit || +initial || 0;
  3743. // Apply relative offset (+=/-=) if specified
  3744. adjusted = valueParts[1] ?
  3745. initialInUnit + (valueParts[1] + 1) * valueParts[2] :
  3746. +valueParts[2];
  3747. if (tween) {
  3748. tween.unit = unit;
  3749. tween.start = initialInUnit;
  3750. tween.end = adjusted;
  3751. }
  3752. }
  3753. return adjusted;
  3754. }
  3755. var defaultDisplayMap = {};
  3756. function getDefaultDisplay(elem) {
  3757. var temp,
  3758. doc = elem.ownerDocument,
  3759. nodeName = elem.nodeName,
  3760. display = defaultDisplayMap[nodeName];
  3761. if (display) {
  3762. return display;
  3763. }
  3764. temp = doc.body.appendChild(doc.createElement(nodeName));
  3765. display = jQuery.css(temp, "display");
  3766. temp.parentNode.removeChild(temp);
  3767. if (display === "none") {
  3768. display = "block";
  3769. }
  3770. defaultDisplayMap[nodeName] = display;
  3771. return display;
  3772. }
  3773. function showHide(elements, show) {
  3774. var display, elem,
  3775. values = [],
  3776. index = 0,
  3777. length = elements.length;
  3778. // Determine new display value for elements that need to change
  3779. for (; index < length; index++) {
  3780. elem = elements[index];
  3781. if (!elem.style) {
  3782. continue;
  3783. }
  3784. display = elem.style.display;
  3785. if (show) {
  3786. // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
  3787. // check is required in this first loop unless we have a nonempty display value (either
  3788. // inline or about-to-be-restored)
  3789. if (display === "none") {
  3790. values[index] = dataPriv.get(elem, "display") || null;
  3791. if (!values[index]) {
  3792. elem.style.display = "";
  3793. }
  3794. }
  3795. if (elem.style.display === "" && isHiddenWithinTree(elem)) {
  3796. values[index] = getDefaultDisplay(elem);
  3797. }
  3798. } else {
  3799. if (display !== "none") {
  3800. values[index] = "none";
  3801. // Remember what we're overwriting
  3802. dataPriv.set(elem, "display", display);
  3803. }
  3804. }
  3805. }
  3806. // Set the display of the elements in a second loop to avoid constant reflow
  3807. for (index = 0; index < length; index++) {
  3808. if (values[index] != null) {
  3809. elements[index].style.display = values[index];
  3810. }
  3811. }
  3812. return elements;
  3813. }
  3814. jQuery.fn.extend({
  3815. show: function () {
  3816. return showHide(this, true);
  3817. },
  3818. hide: function () {
  3819. return showHide(this);
  3820. },
  3821. toggle: function (state) {
  3822. if (typeof state === "boolean") {
  3823. return state ? this.show() : this.hide();
  3824. }
  3825. return this.each(function () {
  3826. if (isHiddenWithinTree(this)) {
  3827. jQuery(this).show();
  3828. } else {
  3829. jQuery(this).hide();
  3830. }
  3831. });
  3832. }
  3833. });
  3834. var rcheckableType = (/^(?:checkbox|radio)$/i);
  3835. var rtagName = (/<([a-z][^\/\0>\x20\t\r\n\f]+)/i);
  3836. var rscriptType = (/^$|^module$|\/(?:java|ecma)script/i);
  3837. // We have to close these tags to support XHTML (#13200)
  3838. var wrapMap = {
  3839. // Support: IE <=9 only
  3840. option: [1, "<select multiple='multiple'>", "</select>"],
  3841. // XHTML parsers do not magically insert elements in the
  3842. // same way that tag soup parsers do. So we cannot shorten
  3843. // this by omitting <tbody> or other required elements.
  3844. thead: [1, "<table>", "</table>"],
  3845. col: [2, "<table><colgroup>", "</colgroup></table>"],
  3846. tr: [2, "<table><tbody>", "</tbody></table>"],
  3847. td: [3, "<table><tbody><tr>", "</tr></tbody></table>"],
  3848. _default: [0, "", ""]
  3849. };
  3850. // Support: IE <=9 only
  3851. wrapMap.optgroup = wrapMap.option;
  3852. wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  3853. wrapMap.th = wrapMap.td;
  3854. function getAll(context, tag) {
  3855. // Support: IE <=9 - 11 only
  3856. // Use typeof to avoid zero-argument method invocation on host objects (#15151)
  3857. var ret;
  3858. if (typeof context.getElementsByTagName !== "undefined") {
  3859. ret = context.getElementsByTagName(tag || "*");
  3860. } else if (typeof context.querySelectorAll !== "undefined") {
  3861. ret = context.querySelectorAll(tag || "*");
  3862. } else {
  3863. ret = [];
  3864. }
  3865. if (tag === undefined || tag && nodeName(context, tag)) {
  3866. return jQuery.merge([context], ret);
  3867. }
  3868. return ret;
  3869. }
  3870. // Mark scripts as having already been evaluated
  3871. function setGlobalEval(elems, refElements) {
  3872. var i = 0,
  3873. l = elems.length;
  3874. for (; i < l; i++) {
  3875. dataPriv.set(
  3876. elems[i],
  3877. "globalEval",
  3878. !refElements || dataPriv.get(refElements[i], "globalEval")
  3879. );
  3880. }
  3881. }
  3882. var rhtml = /<|&#?\w+;/;
  3883. function buildFragment(elems, context, scripts, selection, ignored) {
  3884. var elem, tmp, tag, wrap, contains, j,
  3885. fragment = context.createDocumentFragment(),
  3886. nodes = [],
  3887. i = 0,
  3888. l = elems.length;
  3889. for (; i < l; i++) {
  3890. elem = elems[i];
  3891. if (elem || elem === 0) {
  3892. // Add nodes directly
  3893. if (toType(elem) === "object") {
  3894. // Support: Android <=4.0 only, PhantomJS 1 only
  3895. // push.apply(_, arraylike) throws on ancient WebKit
  3896. jQuery.merge(nodes, elem.nodeType ? [elem] : elem);
  3897. // Convert non-html into a text node
  3898. } else if (!rhtml.test(elem)) {
  3899. nodes.push(context.createTextNode(elem));
  3900. // Convert html into DOM nodes
  3901. } else {
  3902. tmp = tmp || fragment.appendChild(context.createElement("div"));
  3903. // Deserialize a standard representation
  3904. tag = (rtagName.exec(elem) || ["", ""])[1].toLowerCase();
  3905. wrap = wrapMap[tag] || wrapMap._default;
  3906. tmp.innerHTML = wrap[1] + jQuery.htmlPrefilter(elem) + wrap[2];
  3907. // Descend through wrappers to the right content
  3908. j = wrap[0];
  3909. while (j--) {
  3910. tmp = tmp.lastChild;
  3911. }
  3912. // Support: Android <=4.0 only, PhantomJS 1 only
  3913. // push.apply(_, arraylike) throws on ancient WebKit
  3914. jQuery.merge(nodes, tmp.childNodes);
  3915. // Remember the top-level container
  3916. tmp = fragment.firstChild;
  3917. // Ensure the created nodes are orphaned (#12392)
  3918. tmp.textContent = "";
  3919. }
  3920. }
  3921. }
  3922. // Remove wrapper from fragment
  3923. fragment.textContent = "";
  3924. i = 0;
  3925. while ((elem = nodes[i++])) {
  3926. // Skip elements already in the context collection (trac-4087)
  3927. if (selection && jQuery.inArray(elem, selection) > -1) {
  3928. if (ignored) {
  3929. ignored.push(elem);
  3930. }
  3931. continue;
  3932. }
  3933. contains = jQuery.contains(elem.ownerDocument, elem);
  3934. // Append to fragment
  3935. tmp = getAll(fragment.appendChild(elem), "script");
  3936. // Preserve script evaluation history
  3937. if (contains) {
  3938. setGlobalEval(tmp);
  3939. }
  3940. // Capture executables
  3941. if (scripts) {
  3942. j = 0;
  3943. while ((elem = tmp[j++])) {
  3944. if (rscriptType.test(elem.type || "")) {
  3945. scripts.push(elem);
  3946. }
  3947. }
  3948. }
  3949. }
  3950. return fragment;
  3951. }
  3952. (function () {
  3953. var fragment = document.createDocumentFragment(),
  3954. div = fragment.appendChild(document.createElement("div")),
  3955. input = document.createElement("input");
  3956. // Support: Android 4.0 - 4.3 only
  3957. // Check state lost if the name is set (#11217)
  3958. // Support: Windows Web Apps (WWA)
  3959. // `name` and `type` must use .setAttribute for WWA (#14901)
  3960. input.setAttribute("type", "radio");
  3961. input.setAttribute("checked", "checked");
  3962. input.setAttribute("name", "t");
  3963. div.appendChild(input);
  3964. // Support: Android <=4.1 only
  3965. // Older WebKit doesn't clone checked state correctly in fragments
  3966. support.checkClone = div.cloneNode(true).cloneNode(true).lastChild.checked;
  3967. // Support: IE <=11 only
  3968. // Make sure textarea (and checkbox) defaultValue is properly cloned
  3969. div.innerHTML = "<textarea>x</textarea>";
  3970. support.noCloneChecked = !!div.cloneNode(true).lastChild.defaultValue;
  3971. })();
  3972. var documentElement = document.documentElement;
  3973. var
  3974. rkeyEvent = /^key/,
  3975. rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
  3976. rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
  3977. function returnTrue() {
  3978. return true;
  3979. }
  3980. function returnFalse() {
  3981. return false;
  3982. }
  3983. // Support: IE <=9 only
  3984. // See #13393 for more info
  3985. function safeActiveElement() {
  3986. try {
  3987. return document.activeElement;
  3988. } catch (err) { }
  3989. }
  3990. function on(elem, types, selector, data, fn, one) {
  3991. var origFn, type;
  3992. // Types can be a map of types/handlers
  3993. if (typeof types === "object") {
  3994. // ( types-Object, selector, data )
  3995. if (typeof selector !== "string") {
  3996. // ( types-Object, data )
  3997. data = data || selector;
  3998. selector = undefined;
  3999. }
  4000. for (type in types) {
  4001. on(elem, type, selector, data, types[type], one);
  4002. }
  4003. return elem;
  4004. }
  4005. if (data == null && fn == null) {
  4006. // ( types, fn )
  4007. fn = selector;
  4008. data = selector = undefined;
  4009. } else if (fn == null) {
  4010. if (typeof selector === "string") {
  4011. // ( types, selector, fn )
  4012. fn = data;
  4013. data = undefined;
  4014. } else {
  4015. // ( types, data, fn )
  4016. fn = data;
  4017. data = selector;
  4018. selector = undefined;
  4019. }
  4020. }
  4021. if (fn === false) {
  4022. fn = returnFalse;
  4023. } else if (!fn) {
  4024. return elem;
  4025. }
  4026. if (one === 1) {
  4027. origFn = fn;
  4028. fn = function (event) {
  4029. // Can use an empty set, since event contains the info
  4030. jQuery().off(event);
  4031. return origFn.apply(this, arguments);
  4032. };
  4033. // Use same guid so caller can remove using origFn
  4034. fn.guid = origFn.guid || (origFn.guid = jQuery.guid++);
  4035. }
  4036. return elem.each(function () {
  4037. jQuery.event.add(this, types, fn, data, selector);
  4038. });
  4039. }
  4040. /*
  4041. * Helper functions for managing events -- not part of the public interface.
  4042. * Props to Dean Edwards' addEvent library for many of the ideas.
  4043. */
  4044. jQuery.event = {
  4045. global: {},
  4046. add: function (elem, types, handler, data, selector) {
  4047. var handleObjIn, eventHandle, tmp,
  4048. events, t, handleObj,
  4049. special, handlers, type, namespaces, origType,
  4050. elemData = dataPriv.get(elem);
  4051. // Don't attach events to noData or text/comment nodes (but allow plain objects)
  4052. if (!elemData) {
  4053. return;
  4054. }
  4055. // Caller can pass in an object of custom data in lieu of the handler
  4056. if (handler.handler) {
  4057. handleObjIn = handler;
  4058. handler = handleObjIn.handler;
  4059. selector = handleObjIn.selector;
  4060. }
  4061. // Ensure that invalid selectors throw exceptions at attach time
  4062. // Evaluate against documentElement in case elem is a non-element node (e.g., document)
  4063. if (selector) {
  4064. jQuery.find.matchesSelector(documentElement, selector);
  4065. }
  4066. // Make sure that the handler has a unique ID, used to find/remove it later
  4067. if (!handler.guid) {
  4068. handler.guid = jQuery.guid++;
  4069. }
  4070. // Init the element's event structure and main handler, if this is the first
  4071. if (!(events = elemData.events)) {
  4072. events = elemData.events = {};
  4073. }
  4074. if (!(eventHandle = elemData.handle)) {
  4075. eventHandle = elemData.handle = function (e) {
  4076. // Discard the second event of a jQuery.event.trigger() and
  4077. // when an event is called after a page has unloaded
  4078. return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
  4079. jQuery.event.dispatch.apply(elem, arguments) : undefined;
  4080. };
  4081. }
  4082. // Handle multiple events separated by a space
  4083. types = (types || "").match(rnothtmlwhite) || [""];
  4084. t = types.length;
  4085. while (t--) {
  4086. tmp = rtypenamespace.exec(types[t]) || [];
  4087. type = origType = tmp[1];
  4088. namespaces = (tmp[2] || "").split(".").sort();
  4089. // There *must* be a type, no attaching namespace-only handlers
  4090. if (!type) {
  4091. continue;
  4092. }
  4093. // If event changes its type, use the special event handlers for the changed type
  4094. special = jQuery.event.special[type] || {};
  4095. // If selector defined, determine special event api type, otherwise given type
  4096. type = (selector ? special.delegateType : special.bindType) || type;
  4097. // Update special based on newly reset type
  4098. special = jQuery.event.special[type] || {};
  4099. // handleObj is passed to all event handlers
  4100. handleObj = jQuery.extend({
  4101. type: type,
  4102. origType: origType,
  4103. data: data,
  4104. handler: handler,
  4105. guid: handler.guid,
  4106. selector: selector,
  4107. needsContext: selector && jQuery.expr.match.needsContext.test(selector),
  4108. namespace: namespaces.join(".")
  4109. }, handleObjIn);
  4110. // Init the event handler queue if we're the first
  4111. if (!(handlers = events[type])) {
  4112. handlers = events[type] = [];
  4113. handlers.delegateCount = 0;
  4114. // Only use addEventListener if the special events handler returns false
  4115. if (!special.setup ||
  4116. special.setup.call(elem, data, namespaces, eventHandle) === false) {
  4117. if (elem.addEventListener) {
  4118. elem.addEventListener(type, eventHandle);
  4119. }
  4120. }
  4121. }
  4122. if (special.add) {
  4123. special.add.call(elem, handleObj);
  4124. if (!handleObj.handler.guid) {
  4125. handleObj.handler.guid = handler.guid;
  4126. }
  4127. }
  4128. // Add to the element's handler list, delegates in front
  4129. if (selector) {
  4130. handlers.splice(handlers.delegateCount++, 0, handleObj);
  4131. } else {
  4132. handlers.push(handleObj);
  4133. }
  4134. // Keep track of which events have ever been used, for event optimization
  4135. jQuery.event.global[type] = true;
  4136. }
  4137. },
  4138. // Detach an event or set of events from an element
  4139. remove: function (elem, types, handler, selector, mappedTypes) {
  4140. var j, origCount, tmp,
  4141. events, t, handleObj,
  4142. special, handlers, type, namespaces, origType,
  4143. elemData = dataPriv.hasData(elem) && dataPriv.get(elem);
  4144. if (!elemData || !(events = elemData.events)) {
  4145. return;
  4146. }
  4147. // Once for each type.namespace in types; type may be omitted
  4148. types = (types || "").match(rnothtmlwhite) || [""];
  4149. t = types.length;
  4150. while (t--) {
  4151. tmp = rtypenamespace.exec(types[t]) || [];
  4152. type = origType = tmp[1];
  4153. namespaces = (tmp[2] || "").split(".").sort();
  4154. // Unbind all events (on this namespace, if provided) for the element
  4155. if (!type) {
  4156. for (type in events) {
  4157. jQuery.event.remove(elem, type + types[t], handler, selector, true);
  4158. }
  4159. continue;
  4160. }
  4161. special = jQuery.event.special[type] || {};
  4162. type = (selector ? special.delegateType : special.bindType) || type;
  4163. handlers = events[type] || [];
  4164. tmp = tmp[2] &&
  4165. new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)");
  4166. // Remove matching events
  4167. origCount = j = handlers.length;
  4168. while (j--) {
  4169. handleObj = handlers[j];
  4170. if ((mappedTypes || origType === handleObj.origType) &&
  4171. (!handler || handler.guid === handleObj.guid) &&
  4172. (!tmp || tmp.test(handleObj.namespace)) &&
  4173. (!selector || selector === handleObj.selector ||
  4174. selector === "**" && handleObj.selector)) {
  4175. handlers.splice(j, 1);
  4176. if (handleObj.selector) {
  4177. handlers.delegateCount--;
  4178. }
  4179. if (special.remove) {
  4180. special.remove.call(elem, handleObj);
  4181. }
  4182. }
  4183. }
  4184. // Remove generic event handler if we removed something and no more handlers exist
  4185. // (avoids potential for endless recursion during removal of special event handlers)
  4186. if (origCount && !handlers.length) {
  4187. if (!special.teardown ||
  4188. special.teardown.call(elem, namespaces, elemData.handle) === false) {
  4189. jQuery.removeEvent(elem, type, elemData.handle);
  4190. }
  4191. delete events[type];
  4192. }
  4193. }
  4194. // Remove data and the expando if it's no longer used
  4195. if (jQuery.isEmptyObject(events)) {
  4196. dataPriv.remove(elem, "handle events");
  4197. }
  4198. },
  4199. dispatch: function (nativeEvent) {
  4200. // Make a writable jQuery.Event from the native event object
  4201. var event = jQuery.event.fix(nativeEvent);
  4202. var i, j, ret, matched, handleObj, handlerQueue,
  4203. args = new Array(arguments.length),
  4204. handlers = (dataPriv.get(this, "events") || {})[event.type] || [],
  4205. special = jQuery.event.special[event.type] || {};
  4206. // Use the fix-ed jQuery.Event rather than the (read-only) native event
  4207. args[0] = event;
  4208. for (i = 1; i < arguments.length; i++) {
  4209. args[i] = arguments[i];
  4210. }
  4211. event.delegateTarget = this;
  4212. // Call the preDispatch hook for the mapped type, and let it bail if desired
  4213. if (special.preDispatch && special.preDispatch.call(this, event) === false) {
  4214. return;
  4215. }
  4216. // Determine handlers
  4217. handlerQueue = jQuery.event.handlers.call(this, event, handlers);
  4218. // Run delegates first; they may want to stop propagation beneath us
  4219. i = 0;
  4220. while ((matched = handlerQueue[i++]) && !event.isPropagationStopped()) {
  4221. event.currentTarget = matched.elem;
  4222. j = 0;
  4223. while ((handleObj = matched.handlers[j++]) &&
  4224. !event.isImmediatePropagationStopped()) {
  4225. // Triggered event must either 1) have no namespace, or 2) have namespace(s)
  4226. // a subset or equal to those in the bound event (both can have no namespace).
  4227. if (!event.rnamespace || event.rnamespace.test(handleObj.namespace)) {
  4228. event.handleObj = handleObj;
  4229. event.data = handleObj.data;
  4230. ret = ((jQuery.event.special[handleObj.origType] || {}).handle ||
  4231. handleObj.handler).apply(matched.elem, args);
  4232. if (ret !== undefined) {
  4233. if ((event.result = ret) === false) {
  4234. event.preventDefault();
  4235. event.stopPropagation();
  4236. }
  4237. }
  4238. }
  4239. }
  4240. }
  4241. // Call the postDispatch hook for the mapped type
  4242. if (special.postDispatch) {
  4243. special.postDispatch.call(this, event);
  4244. }
  4245. return event.result;
  4246. },
  4247. handlers: function (event, handlers) {
  4248. var i, handleObj, sel, matchedHandlers, matchedSelectors,
  4249. handlerQueue = [],
  4250. delegateCount = handlers.delegateCount,
  4251. cur = event.target;
  4252. // Find delegate handlers
  4253. if (delegateCount &&
  4254. // Support: IE <=9
  4255. // Black-hole SVG <use> instance trees (trac-13180)
  4256. cur.nodeType &&
  4257. // Support: Firefox <=42
  4258. // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
  4259. // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
  4260. // Support: IE 11 only
  4261. // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
  4262. !(event.type === "click" && event.button >= 1)) {
  4263. for (; cur !== this; cur = cur.parentNode || this) {
  4264. // Don't check non-elements (#13208)
  4265. // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
  4266. if (cur.nodeType === 1 && !(event.type === "click" && cur.disabled === true)) {
  4267. matchedHandlers = [];
  4268. matchedSelectors = {};
  4269. for (i = 0; i < delegateCount; i++) {
  4270. handleObj = handlers[i];
  4271. // Don't conflict with Object.prototype properties (#13203)
  4272. sel = handleObj.selector + " ";
  4273. if (matchedSelectors[sel] === undefined) {
  4274. matchedSelectors[sel] = handleObj.needsContext ?
  4275. jQuery(sel, this).index(cur) > -1 :
  4276. jQuery.find(sel, this, null, [cur]).length;
  4277. }
  4278. if (matchedSelectors[sel]) {
  4279. matchedHandlers.push(handleObj);
  4280. }
  4281. }
  4282. if (matchedHandlers.length) {
  4283. handlerQueue.push({ elem: cur, handlers: matchedHandlers });
  4284. }
  4285. }
  4286. }
  4287. }
  4288. // Add the remaining (directly-bound) handlers
  4289. cur = this;
  4290. if (delegateCount < handlers.length) {
  4291. handlerQueue.push({ elem: cur, handlers: handlers.slice(delegateCount) });
  4292. }
  4293. return handlerQueue;
  4294. },
  4295. addProp: function (name, hook) {
  4296. Object.defineProperty(jQuery.Event.prototype, name, {
  4297. enumerable: true,
  4298. configurable: true,
  4299. get: isFunction(hook) ?
  4300. function () {
  4301. if (this.originalEvent) {
  4302. return hook(this.originalEvent);
  4303. }
  4304. } :
  4305. function () {
  4306. if (this.originalEvent) {
  4307. return this.originalEvent[name];
  4308. }
  4309. },
  4310. set: function (value) {
  4311. Object.defineProperty(this, name, {
  4312. enumerable: true,
  4313. configurable: true,
  4314. writable: true,
  4315. value: value
  4316. });
  4317. }
  4318. });
  4319. },
  4320. fix: function (originalEvent) {
  4321. return originalEvent[jQuery.expando] ?
  4322. originalEvent :
  4323. new jQuery.Event(originalEvent);
  4324. },
  4325. special: {
  4326. load: {
  4327. // Prevent triggered image.load events from bubbling to window.load
  4328. noBubble: true
  4329. },
  4330. focus: {
  4331. // Fire native event if possible so blur/focus sequence is correct
  4332. trigger: function () {
  4333. if (this !== safeActiveElement() && this.focus) {
  4334. this.focus();
  4335. return false;
  4336. }
  4337. },
  4338. delegateType: "focusin"
  4339. },
  4340. blur: {
  4341. trigger: function () {
  4342. if (this === safeActiveElement() && this.blur) {
  4343. this.blur();
  4344. return false;
  4345. }
  4346. },
  4347. delegateType: "focusout"
  4348. },
  4349. click: {
  4350. // For checkbox, fire native event so checked state will be right
  4351. trigger: function () {
  4352. if (this.type === "checkbox" && this.click && nodeName(this, "input")) {
  4353. this.click();
  4354. return false;
  4355. }
  4356. },
  4357. // For cross-browser consistency, don't fire native .click() on links
  4358. _default: function (event) {
  4359. return nodeName(event.target, "a");
  4360. }
  4361. },
  4362. beforeunload: {
  4363. postDispatch: function (event) {
  4364. // Support: Firefox 20+
  4365. // Firefox doesn't alert if the returnValue field is not set.
  4366. if (event.result !== undefined && event.originalEvent) {
  4367. event.originalEvent.returnValue = event.result;
  4368. }
  4369. }
  4370. }
  4371. }
  4372. };
  4373. jQuery.removeEvent = function (elem, type, handle) {
  4374. // This "if" is needed for plain objects
  4375. if (elem.removeEventListener) {
  4376. elem.removeEventListener(type, handle);
  4377. }
  4378. };
  4379. jQuery.Event = function (src, props) {
  4380. // Allow instantiation without the 'new' keyword
  4381. if (!(this instanceof jQuery.Event)) {
  4382. return new jQuery.Event(src, props);
  4383. }
  4384. // Event object
  4385. if (src && src.type) {
  4386. this.originalEvent = src;
  4387. this.type = src.type;
  4388. // Events bubbling up the document may have been marked as prevented
  4389. // by a handler lower down the tree; reflect the correct value.
  4390. this.isDefaultPrevented = src.defaultPrevented ||
  4391. src.defaultPrevented === undefined &&
  4392. // Support: Android <=2.3 only
  4393. src.returnValue === false ?
  4394. returnTrue :
  4395. returnFalse;
  4396. // Create target properties
  4397. // Support: Safari <=6 - 7 only
  4398. // Target should not be a text node (#504, #13143)
  4399. this.target = (src.target && src.target.nodeType === 3) ?
  4400. src.target.parentNode :
  4401. src.target;
  4402. this.currentTarget = src.currentTarget;
  4403. this.relatedTarget = src.relatedTarget;
  4404. // Event type
  4405. } else {
  4406. this.type = src;
  4407. }
  4408. // Put explicitly provided properties onto the event object
  4409. if (props) {
  4410. jQuery.extend(this, props);
  4411. }
  4412. // Create a timestamp if incoming event doesn't have one
  4413. this.timeStamp = src && src.timeStamp || Date.now();
  4414. // Mark it as fixed
  4415. this[jQuery.expando] = true;
  4416. };
  4417. // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
  4418. // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  4419. jQuery.Event.prototype = {
  4420. constructor: jQuery.Event,
  4421. isDefaultPrevented: returnFalse,
  4422. isPropagationStopped: returnFalse,
  4423. isImmediatePropagationStopped: returnFalse,
  4424. isSimulated: false,
  4425. preventDefault: function () {
  4426. var e = this.originalEvent;
  4427. this.isDefaultPrevented = returnTrue;
  4428. if (e && !this.isSimulated) {
  4429. e.preventDefault();
  4430. }
  4431. },
  4432. stopPropagation: function () {
  4433. var e = this.originalEvent;
  4434. this.isPropagationStopped = returnTrue;
  4435. if (e && !this.isSimulated) {
  4436. e.stopPropagation();
  4437. }
  4438. },
  4439. stopImmediatePropagation: function () {
  4440. var e = this.originalEvent;
  4441. this.isImmediatePropagationStopped = returnTrue;
  4442. if (e && !this.isSimulated) {
  4443. e.stopImmediatePropagation();
  4444. }
  4445. this.stopPropagation();
  4446. }
  4447. };
  4448. // Includes all common event props including KeyEvent and MouseEvent specific props
  4449. jQuery.each({
  4450. altKey: true,
  4451. bubbles: true,
  4452. cancelable: true,
  4453. changedTouches: true,
  4454. ctrlKey: true,
  4455. detail: true,
  4456. eventPhase: true,
  4457. metaKey: true,
  4458. pageX: true,
  4459. pageY: true,
  4460. shiftKey: true,
  4461. view: true,
  4462. "char": true,
  4463. charCode: true,
  4464. key: true,
  4465. keyCode: true,
  4466. button: true,
  4467. buttons: true,
  4468. clientX: true,
  4469. clientY: true,
  4470. offsetX: true,
  4471. offsetY: true,
  4472. pointerId: true,
  4473. pointerType: true,
  4474. screenX: true,
  4475. screenY: true,
  4476. targetTouches: true,
  4477. toElement: true,
  4478. touches: true,
  4479. which: function (event) {
  4480. var button = event.button;
  4481. // Add which for key events
  4482. if (event.which == null && rkeyEvent.test(event.type)) {
  4483. return event.charCode != null ? event.charCode : event.keyCode;
  4484. }
  4485. // Add which for click: 1 === left; 2 === middle; 3 === right
  4486. if (!event.which && button !== undefined && rmouseEvent.test(event.type)) {
  4487. if (button & 1) {
  4488. return 1;
  4489. }
  4490. if (button & 2) {
  4491. return 3;
  4492. }
  4493. if (button & 4) {
  4494. return 2;
  4495. }
  4496. return 0;
  4497. }
  4498. return event.which;
  4499. }
  4500. }, jQuery.event.addProp);
  4501. // Create mouseenter/leave events using mouseover/out and event-time checks
  4502. // so that event delegation works in jQuery.
  4503. // Do the same for pointerenter/pointerleave and pointerover/pointerout
  4504. //
  4505. // Support: Safari 7 only
  4506. // Safari sends mouseenter too often; see:
  4507. // https://bugs.chromium.org/p/chromium/issues/detail?id=470258
  4508. // for the description of the bug (it existed in older Chrome versions as well).
  4509. jQuery.each({
  4510. mouseenter: "mouseover",
  4511. mouseleave: "mouseout",
  4512. pointerenter: "pointerover",
  4513. pointerleave: "pointerout"
  4514. }, function (orig, fix) {
  4515. jQuery.event.special[orig] = {
  4516. delegateType: fix,
  4517. bindType: fix,
  4518. handle: function (event) {
  4519. var ret,
  4520. target = this,
  4521. related = event.relatedTarget,
  4522. handleObj = event.handleObj;
  4523. // For mouseenter/leave call the handler if related is outside the target.
  4524. // NB: No relatedTarget if the mouse left/entered the browser window
  4525. if (!related || (related !== target && !jQuery.contains(target, related))) {
  4526. event.type = handleObj.origType;
  4527. ret = handleObj.handler.apply(this, arguments);
  4528. event.type = fix;
  4529. }
  4530. return ret;
  4531. }
  4532. };
  4533. });
  4534. jQuery.fn.extend({
  4535. on: function (types, selector, data, fn) {
  4536. return on(this, types, selector, data, fn);
  4537. },
  4538. one: function (types, selector, data, fn) {
  4539. return on(this, types, selector, data, fn, 1);
  4540. },
  4541. off: function (types, selector, fn) {
  4542. var handleObj, type;
  4543. if (types && types.preventDefault && types.handleObj) {
  4544. // ( event ) dispatched jQuery.Event
  4545. handleObj = types.handleObj;
  4546. jQuery(types.delegateTarget).off(
  4547. handleObj.namespace ?
  4548. handleObj.origType + "." + handleObj.namespace :
  4549. handleObj.origType,
  4550. handleObj.selector,
  4551. handleObj.handler
  4552. );
  4553. return this;
  4554. }
  4555. if (typeof types === "object") {
  4556. // ( types-object [, selector] )
  4557. for (type in types) {
  4558. this.off(type, selector, types[type]);
  4559. }
  4560. return this;
  4561. }
  4562. if (selector === false || typeof selector === "function") {
  4563. // ( types [, fn] )
  4564. fn = selector;
  4565. selector = undefined;
  4566. }
  4567. if (fn === false) {
  4568. fn = returnFalse;
  4569. }
  4570. return this.each(function () {
  4571. jQuery.event.remove(this, types, fn, selector);
  4572. });
  4573. }
  4574. });
  4575. var
  4576. /* eslint-disable max-len */
  4577. // See https://github.com/eslint/eslint/issues/3229
  4578. rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
  4579. /* eslint-enable */
  4580. // Support: IE <=10 - 11, Edge 12 - 13 only
  4581. // In IE/Edge using regex groups here causes severe slowdowns.
  4582. // See https://connect.microsoft.com/IE/feedback/details/1736512/
  4583. rnoInnerhtml = /<script|<style|<link/i,
  4584. // checked="checked" or checked
  4585. rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
  4586. rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
  4587. // Prefer a tbody over its parent table for containing new rows
  4588. function manipulationTarget(elem, content) {
  4589. if (nodeName(elem, "table") &&
  4590. nodeName(content.nodeType !== 11 ? content : content.firstChild, "tr")) {
  4591. return jQuery(elem).children("tbody")[0] || elem;
  4592. }
  4593. return elem;
  4594. }
  4595. // Replace/restore the type attribute of script elements for safe DOM manipulation
  4596. function disableScript(elem) {
  4597. elem.type = (elem.getAttribute("type") !== null) + "/" + elem.type;
  4598. return elem;
  4599. }
  4600. function restoreScript(elem) {
  4601. if ((elem.type || "").slice(0, 5) === "true/") {
  4602. elem.type = elem.type.slice(5);
  4603. } else {
  4604. elem.removeAttribute("type");
  4605. }
  4606. return elem;
  4607. }
  4608. function cloneCopyEvent(src, dest) {
  4609. var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
  4610. if (dest.nodeType !== 1) {
  4611. return;
  4612. }
  4613. // 1. Copy private data: events, handlers, etc.
  4614. if (dataPriv.hasData(src)) {
  4615. pdataOld = dataPriv.access(src);
  4616. pdataCur = dataPriv.set(dest, pdataOld);
  4617. events = pdataOld.events;
  4618. if (events) {
  4619. delete pdataCur.handle;
  4620. pdataCur.events = {};
  4621. for (type in events) {
  4622. for (i = 0, l = events[type].length; i < l; i++) {
  4623. jQuery.event.add(dest, type, events[type][i]);
  4624. }
  4625. }
  4626. }
  4627. }
  4628. // 2. Copy user data
  4629. if (dataUser.hasData(src)) {
  4630. udataOld = dataUser.access(src);
  4631. udataCur = jQuery.extend({}, udataOld);
  4632. dataUser.set(dest, udataCur);
  4633. }
  4634. }
  4635. // Fix IE bugs, see support tests
  4636. function fixInput(src, dest) {
  4637. var nodeName = dest.nodeName.toLowerCase();
  4638. // Fails to persist the checked state of a cloned checkbox or radio button.
  4639. if (nodeName === "input" && rcheckableType.test(src.type)) {
  4640. dest.checked = src.checked;
  4641. // Fails to return the selected option to the default selected state when cloning options
  4642. } else if (nodeName === "input" || nodeName === "textarea") {
  4643. dest.defaultValue = src.defaultValue;
  4644. }
  4645. }
  4646. function domManip(collection, args, callback, ignored) {
  4647. // Flatten any nested arrays
  4648. args = concat.apply([], args);
  4649. var fragment, first, scripts, hasScripts, node, doc,
  4650. i = 0,
  4651. l = collection.length,
  4652. iNoClone = l - 1,
  4653. value = args[0],
  4654. valueIsFunction = isFunction(value);
  4655. // We can't cloneNode fragments that contain checked, in WebKit
  4656. if (valueIsFunction ||
  4657. (l > 1 && typeof value === "string" &&
  4658. !support.checkClone && rchecked.test(value))) {
  4659. return collection.each(function (index) {
  4660. var self = collection.eq(index);
  4661. if (valueIsFunction) {
  4662. args[0] = value.call(this, index, self.html());
  4663. }
  4664. domManip(self, args, callback, ignored);
  4665. });
  4666. }
  4667. if (l) {
  4668. fragment = buildFragment(args, collection[0].ownerDocument, false, collection, ignored);
  4669. first = fragment.firstChild;
  4670. if (fragment.childNodes.length === 1) {
  4671. fragment = first;
  4672. }
  4673. // Require either new content or an interest in ignored elements to invoke the callback
  4674. if (first || ignored) {
  4675. scripts = jQuery.map(getAll(fragment, "script"), disableScript);
  4676. hasScripts = scripts.length;
  4677. // Use the original fragment for the last item
  4678. // instead of the first because it can end up
  4679. // being emptied incorrectly in certain situations (#8070).
  4680. for (; i < l; i++) {
  4681. node = fragment;
  4682. if (i !== iNoClone) {
  4683. node = jQuery.clone(node, true, true);
  4684. // Keep references to cloned scripts for later restoration
  4685. if (hasScripts) {
  4686. // Support: Android <=4.0 only, PhantomJS 1 only
  4687. // push.apply(_, arraylike) throws on ancient WebKit
  4688. jQuery.merge(scripts, getAll(node, "script"));
  4689. }
  4690. }
  4691. callback.call(collection[i], node, i);
  4692. }
  4693. if (hasScripts) {
  4694. doc = scripts[scripts.length - 1].ownerDocument;
  4695. // Reenable scripts
  4696. jQuery.map(scripts, restoreScript);
  4697. // Evaluate executable scripts on first document insertion
  4698. for (i = 0; i < hasScripts; i++) {
  4699. node = scripts[i];
  4700. if (rscriptType.test(node.type || "") &&
  4701. !dataPriv.access(node, "globalEval") &&
  4702. jQuery.contains(doc, node)) {
  4703. if (node.src && (node.type || "").toLowerCase() !== "module") {
  4704. // Optional AJAX dependency, but won't run scripts if not present
  4705. if (jQuery._evalUrl) {
  4706. jQuery._evalUrl(node.src);
  4707. }
  4708. } else {
  4709. DOMEval(node.textContent.replace(rcleanScript, ""), doc, node);
  4710. }
  4711. }
  4712. }
  4713. }
  4714. }
  4715. }
  4716. return collection;
  4717. }
  4718. function remove(elem, selector, keepData) {
  4719. var node,
  4720. nodes = selector ? jQuery.filter(selector, elem) : elem,
  4721. i = 0;
  4722. for (; (node = nodes[i]) != null; i++) {
  4723. if (!keepData && node.nodeType === 1) {
  4724. jQuery.cleanData(getAll(node));
  4725. }
  4726. if (node.parentNode) {
  4727. if (keepData && jQuery.contains(node.ownerDocument, node)) {
  4728. setGlobalEval(getAll(node, "script"));
  4729. }
  4730. node.parentNode.removeChild(node);
  4731. }
  4732. }
  4733. return elem;
  4734. }
  4735. jQuery.extend({
  4736. htmlPrefilter: function (html) {
  4737. return html.replace(rxhtmlTag, "<$1></$2>");
  4738. },
  4739. clone: function (elem, dataAndEvents, deepDataAndEvents) {
  4740. var i, l, srcElements, destElements,
  4741. clone = elem.cloneNode(true),
  4742. inPage = jQuery.contains(elem.ownerDocument, elem);
  4743. // Fix IE cloning issues
  4744. if (!support.noCloneChecked && (elem.nodeType === 1 || elem.nodeType === 11) &&
  4745. !jQuery.isXMLDoc(elem)) {
  4746. // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
  4747. destElements = getAll(clone);
  4748. srcElements = getAll(elem);
  4749. for (i = 0, l = srcElements.length; i < l; i++) {
  4750. fixInput(srcElements[i], destElements[i]);
  4751. }
  4752. }
  4753. // Copy the events from the original to the clone
  4754. if (dataAndEvents) {
  4755. if (deepDataAndEvents) {
  4756. srcElements = srcElements || getAll(elem);
  4757. destElements = destElements || getAll(clone);
  4758. for (i = 0, l = srcElements.length; i < l; i++) {
  4759. cloneCopyEvent(srcElements[i], destElements[i]);
  4760. }
  4761. } else {
  4762. cloneCopyEvent(elem, clone);
  4763. }
  4764. }
  4765. // Preserve script evaluation history
  4766. destElements = getAll(clone, "script");
  4767. if (destElements.length > 0) {
  4768. setGlobalEval(destElements, !inPage && getAll(elem, "script"));
  4769. }
  4770. // Return the cloned set
  4771. return clone;
  4772. },
  4773. cleanData: function (elems) {
  4774. var data, elem, type,
  4775. special = jQuery.event.special,
  4776. i = 0;
  4777. for (; (elem = elems[i]) !== undefined; i++) {
  4778. if (acceptData(elem)) {
  4779. if ((data = elem[dataPriv.expando])) {
  4780. if (data.events) {
  4781. for (type in data.events) {
  4782. if (special[type]) {
  4783. jQuery.event.remove(elem, type);
  4784. // This is a shortcut to avoid jQuery.event.remove's overhead
  4785. } else {
  4786. jQuery.removeEvent(elem, type, data.handle);
  4787. }
  4788. }
  4789. }
  4790. // Support: Chrome <=35 - 45+
  4791. // Assign undefined instead of using delete, see Data#remove
  4792. elem[dataPriv.expando] = undefined;
  4793. }
  4794. if (elem[dataUser.expando]) {
  4795. // Support: Chrome <=35 - 45+
  4796. // Assign undefined instead of using delete, see Data#remove
  4797. elem[dataUser.expando] = undefined;
  4798. }
  4799. }
  4800. }
  4801. }
  4802. });
  4803. jQuery.fn.extend({
  4804. detach: function (selector) {
  4805. return remove(this, selector, true);
  4806. },
  4807. remove: function (selector) {
  4808. return remove(this, selector);
  4809. },
  4810. text: function (value) {
  4811. return access(this, function (value) {
  4812. return value === undefined ?
  4813. jQuery.text(this) :
  4814. this.empty().each(function () {
  4815. if (this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9) {
  4816. this.textContent = value;
  4817. }
  4818. });
  4819. }, null, value, arguments.length);
  4820. },
  4821. append: function () {
  4822. return domManip(this, arguments, function (elem) {
  4823. if (this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9) {
  4824. var target = manipulationTarget(this, elem);
  4825. target.appendChild(elem);
  4826. }
  4827. });
  4828. },
  4829. prepend: function () {
  4830. return domManip(this, arguments, function (elem) {
  4831. if (this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9) {
  4832. var target = manipulationTarget(this, elem);
  4833. target.insertBefore(elem, target.firstChild);
  4834. }
  4835. });
  4836. },
  4837. before: function () {
  4838. return domManip(this, arguments, function (elem) {
  4839. if (this.parentNode) {
  4840. this.parentNode.insertBefore(elem, this);
  4841. }
  4842. });
  4843. },
  4844. after: function () {
  4845. return domManip(this, arguments, function (elem) {
  4846. if (this.parentNode) {
  4847. this.parentNode.insertBefore(elem, this.nextSibling);
  4848. }
  4849. });
  4850. },
  4851. empty: function () {
  4852. var elem,
  4853. i = 0;
  4854. for (; (elem = this[i]) != null; i++) {
  4855. if (elem.nodeType === 1) {
  4856. // Prevent memory leaks
  4857. jQuery.cleanData(getAll(elem, false));
  4858. // Remove any remaining nodes
  4859. elem.textContent = "";
  4860. }
  4861. }
  4862. return this;
  4863. },
  4864. clone: function (dataAndEvents, deepDataAndEvents) {
  4865. dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
  4866. deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
  4867. return this.map(function () {
  4868. return jQuery.clone(this, dataAndEvents, deepDataAndEvents);
  4869. });
  4870. },
  4871. html: function (value) {
  4872. return access(this, function (value) {
  4873. var elem = this[0] || {},
  4874. i = 0,
  4875. l = this.length;
  4876. if (value === undefined && elem.nodeType === 1) {
  4877. return elem.innerHTML;
  4878. }
  4879. // See if we can take a shortcut and just use innerHTML
  4880. if (typeof value === "string" && !rnoInnerhtml.test(value) &&
  4881. !wrapMap[(rtagName.exec(value) || ["", ""])[1].toLowerCase()]) {
  4882. value = jQuery.htmlPrefilter(value);
  4883. try {
  4884. for (; i < l; i++) {
  4885. elem = this[i] || {};
  4886. // Remove element nodes and prevent memory leaks
  4887. if (elem.nodeType === 1) {
  4888. jQuery.cleanData(getAll(elem, false));
  4889. elem.innerHTML = value;
  4890. }
  4891. }
  4892. elem = 0;
  4893. // If using innerHTML throws an exception, use the fallback method
  4894. } catch (e) { }
  4895. }
  4896. if (elem) {
  4897. this.empty().append(value);
  4898. }
  4899. }, null, value, arguments.length);
  4900. },
  4901. replaceWith: function () {
  4902. var ignored = [];
  4903. // Make the changes, replacing each non-ignored context element with the new content
  4904. return domManip(this, arguments, function (elem) {
  4905. var parent = this.parentNode;
  4906. if (jQuery.inArray(this, ignored) < 0) {
  4907. jQuery.cleanData(getAll(this));
  4908. if (parent) {
  4909. parent.replaceChild(elem, this);
  4910. }
  4911. }
  4912. // Force callback invocation
  4913. }, ignored);
  4914. }
  4915. });
  4916. jQuery.each({
  4917. appendTo: "append",
  4918. prependTo: "prepend",
  4919. insertBefore: "before",
  4920. insertAfter: "after",
  4921. replaceAll: "replaceWith"
  4922. }, function (name, original) {
  4923. jQuery.fn[name] = function (selector) {
  4924. var elems,
  4925. ret = [],
  4926. insert = jQuery(selector),
  4927. last = insert.length - 1,
  4928. i = 0;
  4929. for (; i <= last; i++) {
  4930. elems = i === last ? this : this.clone(true);
  4931. jQuery(insert[i])[original](elems);
  4932. // Support: Android <=4.0 only, PhantomJS 1 only
  4933. // .get() because push.apply(_, arraylike) throws on ancient WebKit
  4934. push.apply(ret, elems.get());
  4935. }
  4936. return this.pushStack(ret);
  4937. };
  4938. });
  4939. var rnumnonpx = new RegExp("^(" + pnum + ")(?!px)[a-z%]+$", "i");
  4940. var getStyles = function (elem) {
  4941. // Support: IE <=11 only, Firefox <=30 (#15098, #14150)
  4942. // IE throws on elements created in popups
  4943. // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
  4944. var view = elem.ownerDocument.defaultView;
  4945. if (!view || !view.opener) {
  4946. view = window;
  4947. }
  4948. return view.getComputedStyle(elem);
  4949. };
  4950. var rboxStyle = new RegExp(cssExpand.join("|"), "i");
  4951. (function () {
  4952. // Executing both pixelPosition & boxSizingReliable tests require only one layout
  4953. // so they're executed at the same time to save the second computation.
  4954. function computeStyleTests() {
  4955. // This is a singleton, we need to execute it only once
  4956. if (!div) {
  4957. return;
  4958. }
  4959. container.style.cssText = "position:absolute;left:-11111px;width:60px;" +
  4960. "margin-top:1px;padding:0;border:0";
  4961. div.style.cssText =
  4962. "position:relative;display:block;box-sizing:border-box;overflow:scroll;" +
  4963. "margin:auto;border:1px;padding:1px;" +
  4964. "width:60%;top:1%";
  4965. documentElement.appendChild(container).appendChild(div);
  4966. var divStyle = window.getComputedStyle(div);
  4967. pixelPositionVal = divStyle.top !== "1%";
  4968. // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
  4969. reliableMarginLeftVal = roundPixelMeasures(divStyle.marginLeft) === 12;
  4970. // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
  4971. // Some styles come back with percentage values, even though they shouldn't
  4972. div.style.right = "60%";
  4973. pixelBoxStylesVal = roundPixelMeasures(divStyle.right) === 36;
  4974. // Support: IE 9 - 11 only
  4975. // Detect misreporting of content dimensions for box-sizing:border-box elements
  4976. boxSizingReliableVal = roundPixelMeasures(divStyle.width) === 36;
  4977. // Support: IE 9 only
  4978. // Detect overflow:scroll screwiness (gh-3699)
  4979. div.style.position = "absolute";
  4980. scrollboxSizeVal = div.offsetWidth === 36 || "absolute";
  4981. documentElement.removeChild(container);
  4982. // Nullify the div so it wouldn't be stored in the memory and
  4983. // it will also be a sign that checks already performed
  4984. div = null;
  4985. }
  4986. function roundPixelMeasures(measure) {
  4987. return Math.round(parseFloat(measure));
  4988. }
  4989. var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal,
  4990. reliableMarginLeftVal,
  4991. container = document.createElement("div"),
  4992. div = document.createElement("div");
  4993. // Finish early in limited (non-browser) environments
  4994. if (!div.style) {
  4995. return;
  4996. }
  4997. // Support: IE <=9 - 11 only
  4998. // Style of cloned element affects source element cloned (#8908)
  4999. div.style.backgroundClip = "content-box";
  5000. div.cloneNode(true).style.backgroundClip = "";
  5001. support.clearCloneStyle = div.style.backgroundClip === "content-box";
  5002. jQuery.extend(support, {
  5003. boxSizingReliable: function () {
  5004. computeStyleTests();
  5005. return boxSizingReliableVal;
  5006. },
  5007. pixelBoxStyles: function () {
  5008. computeStyleTests();
  5009. return pixelBoxStylesVal;
  5010. },
  5011. pixelPosition: function () {
  5012. computeStyleTests();
  5013. return pixelPositionVal;
  5014. },
  5015. reliableMarginLeft: function () {
  5016. computeStyleTests();
  5017. return reliableMarginLeftVal;
  5018. },
  5019. scrollboxSize: function () {
  5020. computeStyleTests();
  5021. return scrollboxSizeVal;
  5022. }
  5023. });
  5024. })();
  5025. function curCSS(elem, name, computed) {
  5026. var width, minWidth, maxWidth, ret,
  5027. // Support: Firefox 51+
  5028. // Retrieving style before computed somehow
  5029. // fixes an issue with getting wrong values
  5030. // on detached elements
  5031. style = elem.style;
  5032. computed = computed || getStyles(elem);
  5033. // getPropertyValue is needed for:
  5034. // .css('filter') (IE 9 only, #12537)
  5035. // .css('--customProperty) (#3144)
  5036. if (computed) {
  5037. ret = computed.getPropertyValue(name) || computed[name];
  5038. if (ret === "" && !jQuery.contains(elem.ownerDocument, elem)) {
  5039. ret = jQuery.style(elem, name);
  5040. }
  5041. // A tribute to the "awesome hack by Dean Edwards"
  5042. // Android Browser returns percentage for some values,
  5043. // but width seems to be reliably pixels.
  5044. // This is against the CSSOM draft spec:
  5045. // https://drafts.csswg.org/cssom/#resolved-values
  5046. if (!support.pixelBoxStyles() && rnumnonpx.test(ret) && rboxStyle.test(name)) {
  5047. // Remember the original values
  5048. width = style.width;
  5049. minWidth = style.minWidth;
  5050. maxWidth = style.maxWidth;
  5051. // Put in the new values to get a computed value out
  5052. style.minWidth = style.maxWidth = style.width = ret;
  5053. ret = computed.width;
  5054. // Revert the changed values
  5055. style.width = width;
  5056. style.minWidth = minWidth;
  5057. style.maxWidth = maxWidth;
  5058. }
  5059. }
  5060. return ret !== undefined ?
  5061. // Support: IE <=9 - 11 only
  5062. // IE returns zIndex value as an integer.
  5063. ret + "" :
  5064. ret;
  5065. }
  5066. function addGetHookIf(conditionFn, hookFn) {
  5067. // Define the hook, we'll check on the first run if it's really needed.
  5068. return {
  5069. get: function () {
  5070. if (conditionFn()) {
  5071. // Hook not needed (or it's not possible to use it due
  5072. // to missing dependency), remove it.
  5073. delete this.get;
  5074. return;
  5075. }
  5076. // Hook needed; redefine it so that the support test is not executed again.
  5077. return (this.get = hookFn).apply(this, arguments);
  5078. }
  5079. };
  5080. }
  5081. var
  5082. // Swappable if display is none or starts with table
  5083. // except "table", "table-cell", or "table-caption"
  5084. // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
  5085. rdisplayswap = /^(none|table(?!-c[ea]).+)/,
  5086. rcustomProp = /^--/,
  5087. cssShow = { position: "absolute", visibility: "hidden", display: "block" },
  5088. cssNormalTransform = {
  5089. letterSpacing: "0",
  5090. fontWeight: "400"
  5091. },
  5092. cssPrefixes = ["Webkit", "Moz", "ms"],
  5093. emptyStyle = document.createElement("div").style;
  5094. // Return a css property mapped to a potentially vendor prefixed property
  5095. function vendorPropName(name) {
  5096. // Shortcut for names that are not vendor prefixed
  5097. if (name in emptyStyle) {
  5098. return name;
  5099. }
  5100. // Check for vendor prefixed names
  5101. var capName = name[0].toUpperCase() + name.slice(1),
  5102. i = cssPrefixes.length;
  5103. while (i--) {
  5104. name = cssPrefixes[i] + capName;
  5105. if (name in emptyStyle) {
  5106. return name;
  5107. }
  5108. }
  5109. }
  5110. // Return a property mapped along what jQuery.cssProps suggests or to
  5111. // a vendor prefixed property.
  5112. function finalPropName(name) {
  5113. var ret = jQuery.cssProps[name];
  5114. if (!ret) {
  5115. ret = jQuery.cssProps[name] = vendorPropName(name) || name;
  5116. }
  5117. return ret;
  5118. }
  5119. function setPositiveNumber(elem, value, subtract) {
  5120. // Any relative (+/-) values have already been
  5121. // normalized at this point
  5122. var matches = rcssNum.exec(value);
  5123. return matches ?
  5124. // Guard against undefined "subtract", e.g., when used as in cssHooks
  5125. Math.max(0, matches[2] - (subtract || 0)) + (matches[3] || "px") :
  5126. value;
  5127. }
  5128. function boxModelAdjustment(elem, dimension, box, isBorderBox, styles, computedVal) {
  5129. var i = dimension === "width" ? 1 : 0,
  5130. extra = 0,
  5131. delta = 0;
  5132. // Adjustment may not be necessary
  5133. if (box === (isBorderBox ? "border" : "content")) {
  5134. return 0;
  5135. }
  5136. for (; i < 4; i += 2) {
  5137. // Both box models exclude margin
  5138. if (box === "margin") {
  5139. delta += jQuery.css(elem, box + cssExpand[i], true, styles);
  5140. }
  5141. // If we get here with a content-box, we're seeking "padding" or "border" or "margin"
  5142. if (!isBorderBox) {
  5143. // Add padding
  5144. delta += jQuery.css(elem, "padding" + cssExpand[i], true, styles);
  5145. // For "border" or "margin", add border
  5146. if (box !== "padding") {
  5147. delta += jQuery.css(elem, "border" + cssExpand[i] + "Width", true, styles);
  5148. // But still keep track of it otherwise
  5149. } else {
  5150. extra += jQuery.css(elem, "border" + cssExpand[i] + "Width", true, styles);
  5151. }
  5152. // If we get here with a border-box (content + padding + border), we're seeking "content" or
  5153. // "padding" or "margin"
  5154. } else {
  5155. // For "content", subtract padding
  5156. if (box === "content") {
  5157. delta -= jQuery.css(elem, "padding" + cssExpand[i], true, styles);
  5158. }
  5159. // For "content" or "padding", subtract border
  5160. if (box !== "margin") {
  5161. delta -= jQuery.css(elem, "border" + cssExpand[i] + "Width", true, styles);
  5162. }
  5163. }
  5164. }
  5165. // Account for positive content-box scroll gutter when requested by providing computedVal
  5166. if (!isBorderBox && computedVal >= 0) {
  5167. // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
  5168. // Assuming integer scroll gutter, subtract the rest and round down
  5169. delta += Math.max(0, Math.ceil(
  5170. elem["offset" + dimension[0].toUpperCase() + dimension.slice(1)] -
  5171. computedVal -
  5172. delta -
  5173. extra -
  5174. 0.5
  5175. ));
  5176. }
  5177. return delta;
  5178. }
  5179. function getWidthOrHeight(elem, dimension, extra) {
  5180. // Start with computed style
  5181. var styles = getStyles(elem),
  5182. val = curCSS(elem, dimension, styles),
  5183. isBorderBox = jQuery.css(elem, "boxSizing", false, styles) === "border-box",
  5184. valueIsBorderBox = isBorderBox;
  5185. // Support: Firefox <=54
  5186. // Return a confounding non-pixel value or feign ignorance, as appropriate.
  5187. if (rnumnonpx.test(val)) {
  5188. if (!extra) {
  5189. return val;
  5190. }
  5191. val = "auto";
  5192. }
  5193. // Check for style in case a browser which returns unreliable values
  5194. // for getComputedStyle silently falls back to the reliable elem.style
  5195. valueIsBorderBox = valueIsBorderBox &&
  5196. (support.boxSizingReliable() || val === elem.style[dimension]);
  5197. // Fall back to offsetWidth/offsetHeight when value is "auto"
  5198. // This happens for inline elements with no explicit setting (gh-3571)
  5199. // Support: Android <=4.1 - 4.3 only
  5200. // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602)
  5201. if (val === "auto" ||
  5202. !parseFloat(val) && jQuery.css(elem, "display", false, styles) === "inline") {
  5203. val = elem["offset" + dimension[0].toUpperCase() + dimension.slice(1)];
  5204. // offsetWidth/offsetHeight provide border-box values
  5205. valueIsBorderBox = true;
  5206. }
  5207. // Normalize "" and auto
  5208. val = parseFloat(val) || 0;
  5209. // Adjust for the element's box model
  5210. return (val +
  5211. boxModelAdjustment(
  5212. elem,
  5213. dimension,
  5214. extra || (isBorderBox ? "border" : "content"),
  5215. valueIsBorderBox,
  5216. styles,
  5217. // Provide the current computed size to request scroll gutter calculation (gh-3589)
  5218. val
  5219. )
  5220. ) + "px";
  5221. }
  5222. jQuery.extend({
  5223. // Add in style property hooks for overriding the default
  5224. // behavior of getting and setting a style property
  5225. cssHooks: {
  5226. opacity: {
  5227. get: function (elem, computed) {
  5228. if (computed) {
  5229. // We should always get a number back from opacity
  5230. var ret = curCSS(elem, "opacity");
  5231. return ret === "" ? "1" : ret;
  5232. }
  5233. }
  5234. }
  5235. },
  5236. // Don't automatically add "px" to these possibly-unitless properties
  5237. cssNumber: {
  5238. "animationIterationCount": true,
  5239. "columnCount": true,
  5240. "fillOpacity": true,
  5241. "flexGrow": true,
  5242. "flexShrink": true,
  5243. "fontWeight": true,
  5244. "lineHeight": true,
  5245. "opacity": true,
  5246. "order": true,
  5247. "orphans": true,
  5248. "widows": true,
  5249. "zIndex": true,
  5250. "zoom": true
  5251. },
  5252. // Add in properties whose names you wish to fix before
  5253. // setting or getting the value
  5254. cssProps: {},
  5255. // Get and set the style property on a DOM Node
  5256. style: function (elem, name, value, extra) {
  5257. // Don't set styles on text and comment nodes
  5258. if (!elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style) {
  5259. return;
  5260. }
  5261. // Make sure that we're working with the right name
  5262. var ret, type, hooks,
  5263. origName = camelCase(name),
  5264. isCustomProp = rcustomProp.test(name),
  5265. style = elem.style;
  5266. // Make sure that we're working with the right name. We don't
  5267. // want to query the value if it is a CSS custom property
  5268. // since they are user-defined.
  5269. if (!isCustomProp) {
  5270. name = finalPropName(origName);
  5271. }
  5272. // Gets hook for the prefixed version, then unprefixed version
  5273. hooks = jQuery.cssHooks[name] || jQuery.cssHooks[origName];
  5274. // Check if we're setting a value
  5275. if (value !== undefined) {
  5276. type = typeof value;
  5277. // Convert "+=" or "-=" to relative numbers (#7345)
  5278. if (type === "string" && (ret = rcssNum.exec(value)) && ret[1]) {
  5279. value = adjustCSS(elem, name, ret);
  5280. // Fixes bug #9237
  5281. type = "number";
  5282. }
  5283. // Make sure that null and NaN values aren't set (#7116)
  5284. if (value == null || value !== value) {
  5285. return;
  5286. }
  5287. // If a number was passed in, add the unit (except for certain CSS properties)
  5288. if (type === "number") {
  5289. value += ret && ret[3] || (jQuery.cssNumber[origName] ? "" : "px");
  5290. }
  5291. // background-* props affect original clone's values
  5292. if (!support.clearCloneStyle && value === "" && name.indexOf("background") === 0) {
  5293. style[name] = "inherit";
  5294. }
  5295. // If a hook was provided, use that value, otherwise just set the specified value
  5296. if (!hooks || !("set" in hooks) ||
  5297. (value = hooks.set(elem, value, extra)) !== undefined) {
  5298. if (isCustomProp) {
  5299. style.setProperty(name, value);
  5300. } else {
  5301. style[name] = value;
  5302. }
  5303. }
  5304. } else {
  5305. // If a hook was provided get the non-computed value from there
  5306. if (hooks && "get" in hooks &&
  5307. (ret = hooks.get(elem, false, extra)) !== undefined) {
  5308. return ret;
  5309. }
  5310. // Otherwise just get the value from the style object
  5311. return style[name];
  5312. }
  5313. },
  5314. css: function (elem, name, extra, styles) {
  5315. var val, num, hooks,
  5316. origName = camelCase(name),
  5317. isCustomProp = rcustomProp.test(name);
  5318. // Make sure that we're working with the right name. We don't
  5319. // want to modify the value if it is a CSS custom property
  5320. // since they are user-defined.
  5321. if (!isCustomProp) {
  5322. name = finalPropName(origName);
  5323. }
  5324. // Try prefixed name followed by the unprefixed name
  5325. hooks = jQuery.cssHooks[name] || jQuery.cssHooks[origName];
  5326. // If a hook was provided get the computed value from there
  5327. if (hooks && "get" in hooks) {
  5328. val = hooks.get(elem, true, extra);
  5329. }
  5330. // Otherwise, if a way to get the computed value exists, use that
  5331. if (val === undefined) {
  5332. val = curCSS(elem, name, styles);
  5333. }
  5334. // Convert "normal" to computed value
  5335. if (val === "normal" && name in cssNormalTransform) {
  5336. val = cssNormalTransform[name];
  5337. }
  5338. // Make numeric if forced or a qualifier was provided and val looks numeric
  5339. if (extra === "" || extra) {
  5340. num = parseFloat(val);
  5341. return extra === true || isFinite(num) ? num || 0 : val;
  5342. }
  5343. return val;
  5344. }
  5345. });
  5346. jQuery.each(["height", "width"], function (i, dimension) {
  5347. jQuery.cssHooks[dimension] = {
  5348. get: function (elem, computed, extra) {
  5349. if (computed) {
  5350. // Certain elements can have dimension info if we invisibly show them
  5351. // but it must have a current display style that would benefit
  5352. return rdisplayswap.test(jQuery.css(elem, "display")) &&
  5353. // Support: Safari 8+
  5354. // Table columns in Safari have non-zero offsetWidth & zero
  5355. // getBoundingClientRect().width unless display is changed.
  5356. // Support: IE <=11 only
  5357. // Running getBoundingClientRect on a disconnected node
  5358. // in IE throws an error.
  5359. (!elem.getClientRects().length || !elem.getBoundingClientRect().width) ?
  5360. swap(elem, cssShow, function () {
  5361. return getWidthOrHeight(elem, dimension, extra);
  5362. }) :
  5363. getWidthOrHeight(elem, dimension, extra);
  5364. }
  5365. },
  5366. set: function (elem, value, extra) {
  5367. var matches,
  5368. styles = getStyles(elem),
  5369. isBorderBox = jQuery.css(elem, "boxSizing", false, styles) === "border-box",
  5370. subtract = extra && boxModelAdjustment(
  5371. elem,
  5372. dimension,
  5373. extra,
  5374. isBorderBox,
  5375. styles
  5376. );
  5377. // Account for unreliable border-box dimensions by comparing offset* to computed and
  5378. // faking a content-box to get border and padding (gh-3699)
  5379. if (isBorderBox && support.scrollboxSize() === styles.position) {
  5380. subtract -= Math.ceil(
  5381. elem["offset" + dimension[0].toUpperCase() + dimension.slice(1)] -
  5382. parseFloat(styles[dimension]) -
  5383. boxModelAdjustment(elem, dimension, "border", false, styles) -
  5384. 0.5
  5385. );
  5386. }
  5387. // Convert to pixels if value adjustment is needed
  5388. if (subtract && (matches = rcssNum.exec(value)) &&
  5389. (matches[3] || "px") !== "px") {
  5390. elem.style[dimension] = value;
  5391. value = jQuery.css(elem, dimension);
  5392. }
  5393. return setPositiveNumber(elem, value, subtract);
  5394. }
  5395. };
  5396. });
  5397. jQuery.cssHooks.marginLeft = addGetHookIf(support.reliableMarginLeft,
  5398. function (elem, computed) {
  5399. if (computed) {
  5400. return (parseFloat(curCSS(elem, "marginLeft")) ||
  5401. elem.getBoundingClientRect().left -
  5402. swap(elem, { marginLeft: 0 }, function () {
  5403. return elem.getBoundingClientRect().left;
  5404. })
  5405. ) + "px";
  5406. }
  5407. }
  5408. );
  5409. // These hooks are used by animate to expand properties
  5410. jQuery.each({
  5411. margin: "",
  5412. padding: "",
  5413. border: "Width"
  5414. }, function (prefix, suffix) {
  5415. jQuery.cssHooks[prefix + suffix] = {
  5416. expand: function (value) {
  5417. var i = 0,
  5418. expanded = {},
  5419. // Assumes a single number if not a string
  5420. parts = typeof value === "string" ? value.split(" ") : [value];
  5421. for (; i < 4; i++) {
  5422. expanded[prefix + cssExpand[i] + suffix] =
  5423. parts[i] || parts[i - 2] || parts[0];
  5424. }
  5425. return expanded;
  5426. }
  5427. };
  5428. if (prefix !== "margin") {
  5429. jQuery.cssHooks[prefix + suffix].set = setPositiveNumber;
  5430. }
  5431. });
  5432. jQuery.fn.extend({
  5433. css: function (name, value) {
  5434. return access(this, function (elem, name, value) {
  5435. var styles, len,
  5436. map = {},
  5437. i = 0;
  5438. if (Array.isArray(name)) {
  5439. styles = getStyles(elem);
  5440. len = name.length;
  5441. for (; i < len; i++) {
  5442. map[name[i]] = jQuery.css(elem, name[i], false, styles);
  5443. }
  5444. return map;
  5445. }
  5446. return value !== undefined ?
  5447. jQuery.style(elem, name, value) :
  5448. jQuery.css(elem, name);
  5449. }, name, value, arguments.length > 1);
  5450. }
  5451. });
  5452. // Based off of the plugin by Clint Helfers, with permission.
  5453. // https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
  5454. jQuery.fn.delay = function (time, type) {
  5455. time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
  5456. type = type || "fx";
  5457. return this.queue(type, function (next, hooks) {
  5458. var timeout = window.setTimeout(next, time);
  5459. hooks.stop = function () {
  5460. window.clearTimeout(timeout);
  5461. };
  5462. });
  5463. };
  5464. (function () {
  5465. var input = document.createElement("input"),
  5466. select = document.createElement("select"),
  5467. opt = select.appendChild(document.createElement("option"));
  5468. input.type = "checkbox";
  5469. // Support: Android <=4.3 only
  5470. // Default value for a checkbox should be "on"
  5471. support.checkOn = input.value !== "";
  5472. // Support: IE <=11 only
  5473. // Must access selectedIndex to make default options select
  5474. support.optSelected = opt.selected;
  5475. // Support: IE <=11 only
  5476. // An input loses its value after becoming a radio
  5477. input = document.createElement("input");
  5478. input.value = "t";
  5479. input.type = "radio";
  5480. support.radioValue = input.value === "t";
  5481. })();
  5482. var boolHook,
  5483. attrHandle = jQuery.expr.attrHandle;
  5484. jQuery.fn.extend({
  5485. attr: function (name, value) {
  5486. return access(this, jQuery.attr, name, value, arguments.length > 1);
  5487. },
  5488. removeAttr: function (name) {
  5489. return this.each(function () {
  5490. jQuery.removeAttr(this, name);
  5491. });
  5492. }
  5493. });
  5494. jQuery.extend({
  5495. attr: function (elem, name, value) {
  5496. var ret, hooks,
  5497. nType = elem.nodeType;
  5498. // Don't get/set attributes on text, comment and attribute nodes
  5499. if (nType === 3 || nType === 8 || nType === 2) {
  5500. return;
  5501. }
  5502. // Fallback to prop when attributes are not supported
  5503. if (typeof elem.getAttribute === "undefined") {
  5504. return jQuery.prop(elem, name, value);
  5505. }
  5506. // Attribute hooks are determined by the lowercase version
  5507. // Grab necessary hook if one is defined
  5508. if (nType !== 1 || !jQuery.isXMLDoc(elem)) {
  5509. hooks = jQuery.attrHooks[name.toLowerCase()] ||
  5510. (jQuery.expr.match.bool.test(name) ? boolHook : undefined);
  5511. }
  5512. if (value !== undefined) {
  5513. if (value === null) {
  5514. jQuery.removeAttr(elem, name);
  5515. return;
  5516. }
  5517. if (hooks && "set" in hooks &&
  5518. (ret = hooks.set(elem, value, name)) !== undefined) {
  5519. return ret;
  5520. }
  5521. elem.setAttribute(name, value + "");
  5522. return value;
  5523. }
  5524. if (hooks && "get" in hooks && (ret = hooks.get(elem, name)) !== null) {
  5525. return ret;
  5526. }
  5527. ret = jQuery.find.attr(elem, name);
  5528. // Non-existent attributes return null, we normalize to undefined
  5529. return ret == null ? undefined : ret;
  5530. },
  5531. attrHooks: {
  5532. type: {
  5533. set: function (elem, value) {
  5534. if (!support.radioValue && value === "radio" &&
  5535. nodeName(elem, "input")) {
  5536. var val = elem.value;
  5537. elem.setAttribute("type", value);
  5538. if (val) {
  5539. elem.value = val;
  5540. }
  5541. return value;
  5542. }
  5543. }
  5544. }
  5545. },
  5546. removeAttr: function (elem, value) {
  5547. var name,
  5548. i = 0,
  5549. // Attribute names can contain non-HTML whitespace characters
  5550. // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
  5551. attrNames = value && value.match(rnothtmlwhite);
  5552. if (attrNames && elem.nodeType === 1) {
  5553. while ((name = attrNames[i++])) {
  5554. elem.removeAttribute(name);
  5555. }
  5556. }
  5557. }
  5558. });
  5559. // Hooks for boolean attributes
  5560. boolHook = {
  5561. set: function (elem, value, name) {
  5562. if (value === false) {
  5563. // Remove boolean attributes when set to false
  5564. jQuery.removeAttr(elem, name);
  5565. } else {
  5566. elem.setAttribute(name, name);
  5567. }
  5568. return name;
  5569. }
  5570. };
  5571. jQuery.each(jQuery.expr.match.bool.source.match(/\w+/g), function (i, name) {
  5572. var getter = attrHandle[name] || jQuery.find.attr;
  5573. attrHandle[name] = function (elem, name, isXML) {
  5574. var ret, handle,
  5575. lowercaseName = name.toLowerCase();
  5576. if (!isXML) {
  5577. // Avoid an infinite loop by temporarily removing this function from the getter
  5578. handle = attrHandle[lowercaseName];
  5579. attrHandle[lowercaseName] = ret;
  5580. ret = getter(elem, name, isXML) != null ?
  5581. lowercaseName :
  5582. null;
  5583. attrHandle[lowercaseName] = handle;
  5584. }
  5585. return ret;
  5586. };
  5587. });
  5588. var rfocusable = /^(?:input|select|textarea|button)$/i,
  5589. rclickable = /^(?:a|area)$/i;
  5590. jQuery.fn.extend({
  5591. prop: function (name, value) {
  5592. return access(this, jQuery.prop, name, value, arguments.length > 1);
  5593. },
  5594. removeProp: function (name) {
  5595. return this.each(function () {
  5596. delete this[jQuery.propFix[name] || name];
  5597. });
  5598. }
  5599. });
  5600. jQuery.extend({
  5601. prop: function (elem, name, value) {
  5602. var ret, hooks,
  5603. nType = elem.nodeType;
  5604. // Don't get/set properties on text, comment and attribute nodes
  5605. if (nType === 3 || nType === 8 || nType === 2) {
  5606. return;
  5607. }
  5608. if (nType !== 1 || !jQuery.isXMLDoc(elem)) {
  5609. // Fix name and attach hooks
  5610. name = jQuery.propFix[name] || name;
  5611. hooks = jQuery.propHooks[name];
  5612. }
  5613. if (value !== undefined) {
  5614. if (hooks && "set" in hooks &&
  5615. (ret = hooks.set(elem, value, name)) !== undefined) {
  5616. return ret;
  5617. }
  5618. return (elem[name] = value);
  5619. }
  5620. if (hooks && "get" in hooks && (ret = hooks.get(elem, name)) !== null) {
  5621. return ret;
  5622. }
  5623. return elem[name];
  5624. },
  5625. propHooks: {
  5626. tabIndex: {
  5627. get: function (elem) {
  5628. // Support: IE <=9 - 11 only
  5629. // elem.tabIndex doesn't always return the
  5630. // correct value when it hasn't been explicitly set
  5631. // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
  5632. // Use proper attribute retrieval(#12072)
  5633. var tabindex = jQuery.find.attr(elem, "tabindex");
  5634. if (tabindex) {
  5635. return parseInt(tabindex, 10);
  5636. }
  5637. if (
  5638. rfocusable.test(elem.nodeName) ||
  5639. rclickable.test(elem.nodeName) &&
  5640. elem.href
  5641. ) {
  5642. return 0;
  5643. }
  5644. return -1;
  5645. }
  5646. }
  5647. },
  5648. propFix: {
  5649. "for": "htmlFor",
  5650. "class": "className"
  5651. }
  5652. });
  5653. // Support: IE <=11 only
  5654. // Accessing the selectedIndex property
  5655. // forces the browser to respect setting selected
  5656. // on the option
  5657. // The getter ensures a default option is selected
  5658. // when in an optgroup
  5659. // eslint rule "no-unused-expressions" is disabled for this code
  5660. // since it considers such accessions noop
  5661. if (!support.optSelected) {
  5662. jQuery.propHooks.selected = {
  5663. get: function (elem) {
  5664. /* eslint no-unused-expressions: "off" */
  5665. var parent = elem.parentNode;
  5666. if (parent && parent.parentNode) {
  5667. parent.parentNode.selectedIndex;
  5668. }
  5669. return null;
  5670. },
  5671. set: function (elem) {
  5672. /* eslint no-unused-expressions: "off" */
  5673. var parent = elem.parentNode;
  5674. if (parent) {
  5675. parent.selectedIndex;
  5676. if (parent.parentNode) {
  5677. parent.parentNode.selectedIndex;
  5678. }
  5679. }
  5680. }
  5681. };
  5682. }
  5683. jQuery.each([
  5684. "tabIndex",
  5685. "readOnly",
  5686. "maxLength",
  5687. "cellSpacing",
  5688. "cellPadding",
  5689. "rowSpan",
  5690. "colSpan",
  5691. "useMap",
  5692. "frameBorder",
  5693. "contentEditable"
  5694. ], function () {
  5695. jQuery.propFix[this.toLowerCase()] = this;
  5696. });
  5697. // Strip and collapse whitespace according to HTML spec
  5698. // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace
  5699. function stripAndCollapse(value) {
  5700. var tokens = value.match(rnothtmlwhite) || [];
  5701. return tokens.join(" ");
  5702. }
  5703. function getClass(elem) {
  5704. return elem.getAttribute && elem.getAttribute("class") || "";
  5705. }
  5706. function classesToArray(value) {
  5707. if (Array.isArray(value)) {
  5708. return value;
  5709. }
  5710. if (typeof value === "string") {
  5711. return value.match(rnothtmlwhite) || [];
  5712. }
  5713. return [];
  5714. }
  5715. jQuery.fn.extend({
  5716. addClass: function (value) {
  5717. var classes, elem, cur, curValue, clazz, j, finalValue,
  5718. i = 0;
  5719. if (isFunction(value)) {
  5720. return this.each(function (j) {
  5721. jQuery(this).addClass(value.call(this, j, getClass(this)));
  5722. });
  5723. }
  5724. classes = classesToArray(value);
  5725. if (classes.length) {
  5726. while ((elem = this[i++])) {
  5727. curValue = getClass(elem);
  5728. cur = elem.nodeType === 1 && (" " + stripAndCollapse(curValue) + " ");
  5729. if (cur) {
  5730. j = 0;
  5731. while ((clazz = classes[j++])) {
  5732. if (cur.indexOf(" " + clazz + " ") < 0) {
  5733. cur += clazz + " ";
  5734. }
  5735. }
  5736. // Only assign if different to avoid unneeded rendering.
  5737. finalValue = stripAndCollapse(cur);
  5738. if (curValue !== finalValue) {
  5739. elem.setAttribute("class", finalValue);
  5740. }
  5741. }
  5742. }
  5743. }
  5744. return this;
  5745. },
  5746. removeClass: function (value) {
  5747. var classes, elem, cur, curValue, clazz, j, finalValue,
  5748. i = 0;
  5749. if (isFunction(value)) {
  5750. return this.each(function (j) {
  5751. jQuery(this).removeClass(value.call(this, j, getClass(this)));
  5752. });
  5753. }
  5754. if (!arguments.length) {
  5755. return this.attr("class", "");
  5756. }
  5757. classes = classesToArray(value);
  5758. if (classes.length) {
  5759. while ((elem = this[i++])) {
  5760. curValue = getClass(elem);
  5761. // This expression is here for better compressibility (see addClass)
  5762. cur = elem.nodeType === 1 && (" " + stripAndCollapse(curValue) + " ");
  5763. if (cur) {
  5764. j = 0;
  5765. while ((clazz = classes[j++])) {
  5766. // Remove *all* instances
  5767. while (cur.indexOf(" " + clazz + " ") > -1) {
  5768. cur = cur.replace(" " + clazz + " ", " ");
  5769. }
  5770. }
  5771. // Only assign if different to avoid unneeded rendering.
  5772. finalValue = stripAndCollapse(cur);
  5773. if (curValue !== finalValue) {
  5774. elem.setAttribute("class", finalValue);
  5775. }
  5776. }
  5777. }
  5778. }
  5779. return this;
  5780. },
  5781. toggleClass: function (value, stateVal) {
  5782. var type = typeof value,
  5783. isValidValue = type === "string" || Array.isArray(value);
  5784. if (typeof stateVal === "boolean" && isValidValue) {
  5785. return stateVal ? this.addClass(value) : this.removeClass(value);
  5786. }
  5787. if (isFunction(value)) {
  5788. return this.each(function (i) {
  5789. jQuery(this).toggleClass(
  5790. value.call(this, i, getClass(this), stateVal),
  5791. stateVal
  5792. );
  5793. });
  5794. }
  5795. return this.each(function () {
  5796. var className, i, self, classNames;
  5797. if (isValidValue) {
  5798. // Toggle individual class names
  5799. i = 0;
  5800. self = jQuery(this);
  5801. classNames = classesToArray(value);
  5802. while ((className = classNames[i++])) {
  5803. // Check each className given, space separated list
  5804. if (self.hasClass(className)) {
  5805. self.removeClass(className);
  5806. } else {
  5807. self.addClass(className);
  5808. }
  5809. }
  5810. // Toggle whole class name
  5811. } else if (value === undefined || type === "boolean") {
  5812. className = getClass(this);
  5813. if (className) {
  5814. // Store className if set
  5815. dataPriv.set(this, "__className__", className);
  5816. }
  5817. // If the element has a class name or if we're passed `false`,
  5818. // then remove the whole classname (if there was one, the above saved it).
  5819. // Otherwise bring back whatever was previously saved (if anything),
  5820. // falling back to the empty string if nothing was stored.
  5821. if (this.setAttribute) {
  5822. this.setAttribute("class",
  5823. className || value === false ?
  5824. "" :
  5825. dataPriv.get(this, "__className__") || ""
  5826. );
  5827. }
  5828. }
  5829. });
  5830. },
  5831. hasClass: function (selector) {
  5832. var className, elem,
  5833. i = 0;
  5834. className = " " + selector + " ";
  5835. while ((elem = this[i++])) {
  5836. if (elem.nodeType === 1 &&
  5837. (" " + stripAndCollapse(getClass(elem)) + " ").indexOf(className) > -1) {
  5838. return true;
  5839. }
  5840. }
  5841. return false;
  5842. }
  5843. });
  5844. var rreturn = /\r/g;
  5845. jQuery.fn.extend({
  5846. val: function (value) {
  5847. var hooks, ret, valueIsFunction,
  5848. elem = this[0];
  5849. if (!arguments.length) {
  5850. if (elem) {
  5851. hooks = jQuery.valHooks[elem.type] ||
  5852. jQuery.valHooks[elem.nodeName.toLowerCase()];
  5853. if (hooks &&
  5854. "get" in hooks &&
  5855. (ret = hooks.get(elem, "value")) !== undefined
  5856. ) {
  5857. return ret;
  5858. }
  5859. ret = elem.value;
  5860. // Handle most common string cases
  5861. if (typeof ret === "string") {
  5862. return ret.replace(rreturn, "");
  5863. }
  5864. // Handle cases where value is null/undef or number
  5865. return ret == null ? "" : ret;
  5866. }
  5867. return;
  5868. }
  5869. valueIsFunction = isFunction(value);
  5870. return this.each(function (i) {
  5871. var val;
  5872. if (this.nodeType !== 1) {
  5873. return;
  5874. }
  5875. if (valueIsFunction) {
  5876. val = value.call(this, i, jQuery(this).val());
  5877. } else {
  5878. val = value;
  5879. }
  5880. // Treat null/undefined as ""; convert numbers to string
  5881. if (val == null) {
  5882. val = "";
  5883. } else if (typeof val === "number") {
  5884. val += "";
  5885. } else if (Array.isArray(val)) {
  5886. val = jQuery.map(val, function (value) {
  5887. return value == null ? "" : value + "";
  5888. });
  5889. }
  5890. hooks = jQuery.valHooks[this.type] || jQuery.valHooks[this.nodeName.toLowerCase()];
  5891. // If set returns undefined, fall back to normal setting
  5892. if (!hooks || !("set" in hooks) || hooks.set(this, val, "value") === undefined) {
  5893. this.value = val;
  5894. }
  5895. });
  5896. }
  5897. });
  5898. jQuery.extend({
  5899. valHooks: {
  5900. option: {
  5901. get: function (elem) {
  5902. var val = jQuery.find.attr(elem, "value");
  5903. return val != null ?
  5904. val :
  5905. // Support: IE <=10 - 11 only
  5906. // option.text throws exceptions (#14686, #14858)
  5907. // Strip and collapse whitespace
  5908. // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
  5909. stripAndCollapse(jQuery.text(elem));
  5910. }
  5911. },
  5912. select: {
  5913. get: function (elem) {
  5914. var value, option, i,
  5915. options = elem.options,
  5916. index = elem.selectedIndex,
  5917. one = elem.type === "select-one",
  5918. values = one ? null : [],
  5919. max = one ? index + 1 : options.length;
  5920. if (index < 0) {
  5921. i = max;
  5922. } else {
  5923. i = one ? index : 0;
  5924. }
  5925. // Loop through all the selected options
  5926. for (; i < max; i++) {
  5927. option = options[i];
  5928. // Support: IE <=9 only
  5929. // IE8-9 doesn't update selected after form reset (#2551)
  5930. if ((option.selected || i === index) &&
  5931. // Don't return options that are disabled or in a disabled optgroup
  5932. !option.disabled &&
  5933. (!option.parentNode.disabled ||
  5934. !nodeName(option.parentNode, "optgroup"))) {
  5935. // Get the specific value for the option
  5936. value = jQuery(option).val();
  5937. // We don't need an array for one selects
  5938. if (one) {
  5939. return value;
  5940. }
  5941. // Multi-Selects return an array
  5942. values.push(value);
  5943. }
  5944. }
  5945. return values;
  5946. },
  5947. set: function (elem, value) {
  5948. var optionSet, option,
  5949. options = elem.options,
  5950. values = jQuery.makeArray(value),
  5951. i = options.length;
  5952. while (i--) {
  5953. option = options[i];
  5954. /* eslint-disable no-cond-assign */
  5955. if (option.selected =
  5956. jQuery.inArray(jQuery.valHooks.option.get(option), values) > -1
  5957. ) {
  5958. optionSet = true;
  5959. }
  5960. /* eslint-enable no-cond-assign */
  5961. }
  5962. // Force browsers to behave consistently when non-matching value is set
  5963. if (!optionSet) {
  5964. elem.selectedIndex = -1;
  5965. }
  5966. return values;
  5967. }
  5968. }
  5969. }
  5970. });
  5971. // Radios and checkboxes getter/setter
  5972. jQuery.each(["radio", "checkbox"], function () {
  5973. jQuery.valHooks[this] = {
  5974. set: function (elem, value) {
  5975. if (Array.isArray(value)) {
  5976. return (elem.checked = jQuery.inArray(jQuery(elem).val(), value) > -1);
  5977. }
  5978. }
  5979. };
  5980. if (!support.checkOn) {
  5981. jQuery.valHooks[this].get = function (elem) {
  5982. return elem.getAttribute("value") === null ? "on" : elem.value;
  5983. };
  5984. }
  5985. });
  5986. // Return jQuery for attributes-only inclusion
  5987. support.focusin = "onfocusin" in window;
  5988. var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
  5989. stopPropagationCallback = function (e) {
  5990. e.stopPropagation();
  5991. };
  5992. jQuery.extend(jQuery.event, {
  5993. trigger: function (event, data, elem, onlyHandlers) {
  5994. var i, cur, tmp, bubbleType, ontype, handle, special, lastElement,
  5995. eventPath = [elem || document],
  5996. type = hasOwn.call(event, "type") ? event.type : event,
  5997. namespaces = hasOwn.call(event, "namespace") ? event.namespace.split(".") : [];
  5998. cur = lastElement = tmp = elem = elem || document;
  5999. // Don't do events on text and comment nodes
  6000. if (elem.nodeType === 3 || elem.nodeType === 8) {
  6001. return;
  6002. }
  6003. // focus/blur morphs to focusin/out; ensure we're not firing them right now
  6004. if (rfocusMorph.test(type + jQuery.event.triggered)) {
  6005. return;
  6006. }
  6007. if (type.indexOf(".") > -1) {
  6008. // Namespaced trigger; create a regexp to match event type in handle()
  6009. namespaces = type.split(".");
  6010. type = namespaces.shift();
  6011. namespaces.sort();
  6012. }
  6013. ontype = type.indexOf(":") < 0 && "on" + type;
  6014. // Caller can pass in a jQuery.Event object, Object, or just an event type string
  6015. event = event[jQuery.expando] ?
  6016. event :
  6017. new jQuery.Event(type, typeof event === "object" && event);
  6018. // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
  6019. event.isTrigger = onlyHandlers ? 2 : 3;
  6020. event.namespace = namespaces.join(".");
  6021. event.rnamespace = event.namespace ?
  6022. new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)") :
  6023. null;
  6024. // Clean up the event in case it is being reused
  6025. event.result = undefined;
  6026. if (!event.target) {
  6027. event.target = elem;
  6028. }
  6029. // Clone any incoming data and prepend the event, creating the handler arg list
  6030. data = data == null ?
  6031. [event] :
  6032. jQuery.makeArray(data, [event]);
  6033. // Allow special events to draw outside the lines
  6034. special = jQuery.event.special[type] || {};
  6035. if (!onlyHandlers && special.trigger && special.trigger.apply(elem, data) === false) {
  6036. return;
  6037. }
  6038. // Determine event propagation path in advance, per W3C events spec (#9951)
  6039. // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
  6040. if (!onlyHandlers && !special.noBubble && !isWindow(elem)) {
  6041. bubbleType = special.delegateType || type;
  6042. if (!rfocusMorph.test(bubbleType + type)) {
  6043. cur = cur.parentNode;
  6044. }
  6045. for (; cur; cur = cur.parentNode) {
  6046. eventPath.push(cur);
  6047. tmp = cur;
  6048. }
  6049. // Only add window if we got to document (e.g., not plain obj or detached DOM)
  6050. if (tmp === (elem.ownerDocument || document)) {
  6051. eventPath.push(tmp.defaultView || tmp.parentWindow || window);
  6052. }
  6053. }
  6054. // Fire handlers on the event path
  6055. i = 0;
  6056. while ((cur = eventPath[i++]) && !event.isPropagationStopped()) {
  6057. lastElement = cur;
  6058. event.type = i > 1 ?
  6059. bubbleType :
  6060. special.bindType || type;
  6061. // jQuery handler
  6062. handle = (dataPriv.get(cur, "events") || {})[event.type] &&
  6063. dataPriv.get(cur, "handle");
  6064. if (handle) {
  6065. handle.apply(cur, data);
  6066. }
  6067. // Native handler
  6068. handle = ontype && cur[ontype];
  6069. if (handle && handle.apply && acceptData(cur)) {
  6070. event.result = handle.apply(cur, data);
  6071. if (event.result === false) {
  6072. event.preventDefault();
  6073. }
  6074. }
  6075. }
  6076. event.type = type;
  6077. // If nobody prevented the default action, do it now
  6078. if (!onlyHandlers && !event.isDefaultPrevented()) {
  6079. if ((!special._default ||
  6080. special._default.apply(eventPath.pop(), data) === false) &&
  6081. acceptData(elem)) {
  6082. // Call a native DOM method on the target with the same name as the event.
  6083. // Don't do default actions on window, that's where global variables be (#6170)
  6084. if (ontype && isFunction(elem[type]) && !isWindow(elem)) {
  6085. // Don't re-trigger an onFOO event when we call its FOO() method
  6086. tmp = elem[ontype];
  6087. if (tmp) {
  6088. elem[ontype] = null;
  6089. }
  6090. // Prevent re-triggering of the same event, since we already bubbled it above
  6091. jQuery.event.triggered = type;
  6092. if (event.isPropagationStopped()) {
  6093. lastElement.addEventListener(type, stopPropagationCallback);
  6094. }
  6095. elem[type]();
  6096. if (event.isPropagationStopped()) {
  6097. lastElement.removeEventListener(type, stopPropagationCallback);
  6098. }
  6099. jQuery.event.triggered = undefined;
  6100. if (tmp) {
  6101. elem[ontype] = tmp;
  6102. }
  6103. }
  6104. }
  6105. }
  6106. return event.result;
  6107. },
  6108. // Piggyback on a donor event to simulate a different one
  6109. // Used only for `focus(in | out)` events
  6110. simulate: function (type, elem, event) {
  6111. var e = jQuery.extend(
  6112. new jQuery.Event(),
  6113. event,
  6114. {
  6115. type: type,
  6116. isSimulated: true
  6117. }
  6118. );
  6119. jQuery.event.trigger(e, null, elem);
  6120. }
  6121. });
  6122. jQuery.fn.extend({
  6123. trigger: function (type, data) {
  6124. return this.each(function () {
  6125. jQuery.event.trigger(type, data, this);
  6126. });
  6127. },
  6128. triggerHandler: function (type, data) {
  6129. var elem = this[0];
  6130. if (elem) {
  6131. return jQuery.event.trigger(type, data, elem, true);
  6132. }
  6133. }
  6134. });
  6135. // Support: Firefox <=44
  6136. // Firefox doesn't have focus(in | out) events
  6137. // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
  6138. //
  6139. // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
  6140. // focus(in | out) events fire after focus & blur events,
  6141. // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
  6142. // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
  6143. if (!support.focusin) {
  6144. jQuery.each({ focus: "focusin", blur: "focusout" }, function (orig, fix) {
  6145. // Attach a single capturing handler on the document while someone wants focusin/focusout
  6146. var handler = function (event) {
  6147. jQuery.event.simulate(fix, event.target, jQuery.event.fix(event));
  6148. };
  6149. jQuery.event.special[fix] = {
  6150. setup: function () {
  6151. var doc = this.ownerDocument || this,
  6152. attaches = dataPriv.access(doc, fix);
  6153. if (!attaches) {
  6154. doc.addEventListener(orig, handler, true);
  6155. }
  6156. dataPriv.access(doc, fix, (attaches || 0) + 1);
  6157. },
  6158. teardown: function () {
  6159. var doc = this.ownerDocument || this,
  6160. attaches = dataPriv.access(doc, fix) - 1;
  6161. if (!attaches) {
  6162. doc.removeEventListener(orig, handler, true);
  6163. dataPriv.remove(doc, fix);
  6164. } else {
  6165. dataPriv.access(doc, fix, attaches);
  6166. }
  6167. }
  6168. };
  6169. });
  6170. }
  6171. var
  6172. rbracket = /\[\]$/,
  6173. rCRLF = /\r?\n/g,
  6174. rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
  6175. rsubmittable = /^(?:input|select|textarea|keygen)/i;
  6176. function buildParams(prefix, obj, traditional, add) {
  6177. var name;
  6178. if (Array.isArray(obj)) {
  6179. // Serialize array item.
  6180. jQuery.each(obj, function (i, v) {
  6181. if (traditional || rbracket.test(prefix)) {
  6182. // Treat each array item as a scalar.
  6183. add(prefix, v);
  6184. } else {
  6185. // Item is non-scalar (array or object), encode its numeric index.
  6186. buildParams(
  6187. prefix + "[" + (typeof v === "object" && v != null ? i : "") + "]",
  6188. v,
  6189. traditional,
  6190. add
  6191. );
  6192. }
  6193. });
  6194. } else if (!traditional && toType(obj) === "object") {
  6195. // Serialize object item.
  6196. for (name in obj) {
  6197. buildParams(prefix + "[" + name + "]", obj[name], traditional, add);
  6198. }
  6199. } else {
  6200. // Serialize scalar item.
  6201. add(prefix, obj);
  6202. }
  6203. }
  6204. // Serialize an array of form elements or a set of
  6205. // key/values into a query string
  6206. jQuery.param = function (a, traditional) {
  6207. var prefix,
  6208. s = [],
  6209. add = function (key, valueOrFunction) {
  6210. // If value is a function, invoke it and use its return value
  6211. var value = isFunction(valueOrFunction) ?
  6212. valueOrFunction() :
  6213. valueOrFunction;
  6214. s[s.length] = encodeURIComponent(key) + "=" +
  6215. encodeURIComponent(value == null ? "" : value);
  6216. };
  6217. // If an array was passed in, assume that it is an array of form elements.
  6218. if (Array.isArray(a) || (a.jquery && !jQuery.isPlainObject(a))) {
  6219. // Serialize the form elements
  6220. jQuery.each(a, function () {
  6221. add(this.name, this.value);
  6222. });
  6223. } else {
  6224. // If traditional, encode the "old" way (the way 1.3.2 or older
  6225. // did it), otherwise encode params recursively.
  6226. for (prefix in a) {
  6227. buildParams(prefix, a[prefix], traditional, add);
  6228. }
  6229. }
  6230. // Return the resulting serialization
  6231. return s.join("&");
  6232. };
  6233. jQuery.fn.extend({
  6234. serialize: function () {
  6235. return jQuery.param(this.serializeArray());
  6236. },
  6237. serializeArray: function () {
  6238. return this.map(function () {
  6239. // Can add propHook for "elements" to filter or add form elements
  6240. var elements = jQuery.prop(this, "elements");
  6241. return elements ? jQuery.makeArray(elements) : this;
  6242. })
  6243. .filter(function () {
  6244. var type = this.type;
  6245. // Use .is( ":disabled" ) so that fieldset[disabled] works
  6246. return this.name && !jQuery(this).is(":disabled") &&
  6247. rsubmittable.test(this.nodeName) && !rsubmitterTypes.test(type) &&
  6248. (this.checked || !rcheckableType.test(type));
  6249. })
  6250. .map(function (i, elem) {
  6251. var val = jQuery(this).val();
  6252. if (val == null) {
  6253. return null;
  6254. }
  6255. if (Array.isArray(val)) {
  6256. return jQuery.map(val, function (val) {
  6257. return { name: elem.name, value: val.replace(rCRLF, "\r\n") };
  6258. });
  6259. }
  6260. return { name: elem.name, value: val.replace(rCRLF, "\r\n") };
  6261. }).get();
  6262. }
  6263. });
  6264. jQuery.fn.extend({
  6265. wrapAll: function (html) {
  6266. var wrap;
  6267. if (this[0]) {
  6268. if (isFunction(html)) {
  6269. html = html.call(this[0]);
  6270. }
  6271. // The elements to wrap the target around
  6272. wrap = jQuery(html, this[0].ownerDocument).eq(0).clone(true);
  6273. if (this[0].parentNode) {
  6274. wrap.insertBefore(this[0]);
  6275. }
  6276. wrap.map(function () {
  6277. var elem = this;
  6278. while (elem.firstElementChild) {
  6279. elem = elem.firstElementChild;
  6280. }
  6281. return elem;
  6282. }).append(this);
  6283. }
  6284. return this;
  6285. },
  6286. wrapInner: function (html) {
  6287. if (isFunction(html)) {
  6288. return this.each(function (i) {
  6289. jQuery(this).wrapInner(html.call(this, i));
  6290. });
  6291. }
  6292. return this.each(function () {
  6293. var self = jQuery(this),
  6294. contents = self.contents();
  6295. if (contents.length) {
  6296. contents.wrapAll(html);
  6297. } else {
  6298. self.append(html);
  6299. }
  6300. });
  6301. },
  6302. wrap: function (html) {
  6303. var htmlIsFunction = isFunction(html);
  6304. return this.each(function (i) {
  6305. jQuery(this).wrapAll(htmlIsFunction ? html.call(this, i) : html);
  6306. });
  6307. },
  6308. unwrap: function (selector) {
  6309. this.parent(selector).not("body").each(function () {
  6310. jQuery(this).replaceWith(this.childNodes);
  6311. });
  6312. return this;
  6313. }
  6314. });
  6315. jQuery.expr.pseudos.hidden = function (elem) {
  6316. return !jQuery.expr.pseudos.visible(elem);
  6317. };
  6318. jQuery.expr.pseudos.visible = function (elem) {
  6319. return !!(elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length);
  6320. };
  6321. // Support: Safari 8 only
  6322. // In Safari 8 documents created via document.implementation.createHTMLDocument
  6323. // collapse sibling forms: the second one becomes a child of the first one.
  6324. // Because of that, this security measure has to be disabled in Safari 8.
  6325. // https://bugs.webkit.org/show_bug.cgi?id=137337
  6326. support.createHTMLDocument = (function () {
  6327. var body = document.implementation.createHTMLDocument("").body;
  6328. body.innerHTML = "<form></form><form></form>";
  6329. return body.childNodes.length === 2;
  6330. })();
  6331. // Argument "data" should be string of html
  6332. // context (optional): If specified, the fragment will be created in this context,
  6333. // defaults to document
  6334. // keepScripts (optional): If true, will include scripts passed in the html string
  6335. jQuery.parseHTML = function (data, context, keepScripts) {
  6336. if (typeof data !== "string") {
  6337. return [];
  6338. }
  6339. if (typeof context === "boolean") {
  6340. keepScripts = context;
  6341. context = false;
  6342. }
  6343. var base, parsed, scripts;
  6344. if (!context) {
  6345. // Stop scripts or inline event handlers from being executed immediately
  6346. // by using document.implementation
  6347. if (support.createHTMLDocument) {
  6348. context = document.implementation.createHTMLDocument("");
  6349. // Set the base href for the created document
  6350. // so any parsed elements with URLs
  6351. // are based on the document's URL (gh-2965)
  6352. base = context.createElement("base");
  6353. base.href = document.location.href;
  6354. context.head.appendChild(base);
  6355. } else {
  6356. context = document;
  6357. }
  6358. }
  6359. parsed = rsingleTag.exec(data);
  6360. scripts = !keepScripts && [];
  6361. // Single tag
  6362. if (parsed) {
  6363. return [context.createElement(parsed[1])];
  6364. }
  6365. parsed = buildFragment([data], context, scripts);
  6366. if (scripts && scripts.length) {
  6367. jQuery(scripts).remove();
  6368. }
  6369. return jQuery.merge([], parsed.childNodes);
  6370. };
  6371. jQuery.offset = {
  6372. setOffset: function (elem, options, i) {
  6373. var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
  6374. position = jQuery.css(elem, "position"),
  6375. curElem = jQuery(elem),
  6376. props = {};
  6377. // Set position first, in-case top/left are set even on static elem
  6378. if (position === "static") {
  6379. elem.style.position = "relative";
  6380. }
  6381. curOffset = curElem.offset();
  6382. curCSSTop = jQuery.css(elem, "top");
  6383. curCSSLeft = jQuery.css(elem, "left");
  6384. calculatePosition = (position === "absolute" || position === "fixed") &&
  6385. (curCSSTop + curCSSLeft).indexOf("auto") > -1;
  6386. // Need to be able to calculate position if either
  6387. // top or left is auto and position is either absolute or fixed
  6388. if (calculatePosition) {
  6389. curPosition = curElem.position();
  6390. curTop = curPosition.top;
  6391. curLeft = curPosition.left;
  6392. } else {
  6393. curTop = parseFloat(curCSSTop) || 0;
  6394. curLeft = parseFloat(curCSSLeft) || 0;
  6395. }
  6396. if (isFunction(options)) {
  6397. // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
  6398. options = options.call(elem, i, jQuery.extend({}, curOffset));
  6399. }
  6400. if (options.top != null) {
  6401. props.top = (options.top - curOffset.top) + curTop;
  6402. }
  6403. if (options.left != null) {
  6404. props.left = (options.left - curOffset.left) + curLeft;
  6405. }
  6406. if ("using" in options) {
  6407. options.using.call(elem, props);
  6408. } else {
  6409. curElem.css(props);
  6410. }
  6411. }
  6412. };
  6413. jQuery.fn.extend({
  6414. // offset() relates an element's border box to the document origin
  6415. offset: function (options) {
  6416. // Preserve chaining for setter
  6417. if (arguments.length) {
  6418. return options === undefined ?
  6419. this :
  6420. this.each(function (i) {
  6421. jQuery.offset.setOffset(this, options, i);
  6422. });
  6423. }
  6424. var rect, win,
  6425. elem = this[0];
  6426. if (!elem) {
  6427. return;
  6428. }
  6429. // Return zeros for disconnected and hidden (display: none) elements (gh-2310)
  6430. // Support: IE <=11 only
  6431. // Running getBoundingClientRect on a
  6432. // disconnected node in IE throws an error
  6433. if (!elem.getClientRects().length) {
  6434. return { top: 0, left: 0 };
  6435. }
  6436. // Get document-relative position by adding viewport scroll to viewport-relative gBCR
  6437. rect = elem.getBoundingClientRect();
  6438. win = elem.ownerDocument.defaultView;
  6439. return {
  6440. top: rect.top + win.pageYOffset,
  6441. left: rect.left + win.pageXOffset
  6442. };
  6443. },
  6444. // position() relates an element's margin box to its offset parent's padding box
  6445. // This corresponds to the behavior of CSS absolute positioning
  6446. position: function () {
  6447. if (!this[0]) {
  6448. return;
  6449. }
  6450. var offsetParent, offset, doc,
  6451. elem = this[0],
  6452. parentOffset = { top: 0, left: 0 };
  6453. // position:fixed elements are offset from the viewport, which itself always has zero offset
  6454. if (jQuery.css(elem, "position") === "fixed") {
  6455. // Assume position:fixed implies availability of getBoundingClientRect
  6456. offset = elem.getBoundingClientRect();
  6457. } else {
  6458. offset = this.offset();
  6459. // Account for the *real* offset parent, which can be the document or its root element
  6460. // when a statically positioned element is identified
  6461. doc = elem.ownerDocument;
  6462. offsetParent = elem.offsetParent || doc.documentElement;
  6463. while (offsetParent &&
  6464. (offsetParent === doc.body || offsetParent === doc.documentElement) &&
  6465. jQuery.css(offsetParent, "position") === "static") {
  6466. offsetParent = offsetParent.parentNode;
  6467. }
  6468. if (offsetParent && offsetParent !== elem && offsetParent.nodeType === 1) {
  6469. // Incorporate borders into its offset, since they are outside its content origin
  6470. parentOffset = jQuery(offsetParent).offset();
  6471. parentOffset.top += jQuery.css(offsetParent, "borderTopWidth", true);
  6472. parentOffset.left += jQuery.css(offsetParent, "borderLeftWidth", true);
  6473. }
  6474. }
  6475. // Subtract parent offsets and element margins
  6476. return {
  6477. top: offset.top - parentOffset.top - jQuery.css(elem, "marginTop", true),
  6478. left: offset.left - parentOffset.left - jQuery.css(elem, "marginLeft", true)
  6479. };
  6480. },
  6481. // This method will return documentElement in the following cases:
  6482. // 1) For the element inside the iframe without offsetParent, this method will return
  6483. // documentElement of the parent window
  6484. // 2) For the hidden or detached element
  6485. // 3) For body or html element, i.e. in case of the html node - it will return itself
  6486. //
  6487. // but those exceptions were never presented as a real life use-cases
  6488. // and might be considered as more preferable results.
  6489. //
  6490. // This logic, however, is not guaranteed and can change at any point in the future
  6491. offsetParent: function () {
  6492. return this.map(function () {
  6493. var offsetParent = this.offsetParent;
  6494. while (offsetParent && jQuery.css(offsetParent, "position") === "static") {
  6495. offsetParent = offsetParent.offsetParent;
  6496. }
  6497. return offsetParent || documentElement;
  6498. });
  6499. }
  6500. });
  6501. // Create scrollLeft and scrollTop methods
  6502. jQuery.each({ scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function (method, prop) {
  6503. var top = "pageYOffset" === prop;
  6504. jQuery.fn[method] = function (val) {
  6505. return access(this, function (elem, method, val) {
  6506. // Coalesce documents and windows
  6507. var win;
  6508. if (isWindow(elem)) {
  6509. win = elem;
  6510. } else if (elem.nodeType === 9) {
  6511. win = elem.defaultView;
  6512. }
  6513. if (val === undefined) {
  6514. return win ? win[prop] : elem[method];
  6515. }
  6516. if (win) {
  6517. win.scrollTo(
  6518. !top ? val : win.pageXOffset,
  6519. top ? val : win.pageYOffset
  6520. );
  6521. } else {
  6522. elem[method] = val;
  6523. }
  6524. }, method, val, arguments.length);
  6525. };
  6526. });
  6527. // Support: Safari <=7 - 9.1, Chrome <=37 - 49
  6528. // Add the top/left cssHooks using jQuery.fn.position
  6529. // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
  6530. // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
  6531. // getComputedStyle returns percent when specified for top/left/bottom/right;
  6532. // rather than make the css module depend on the offset module, just check for it here
  6533. jQuery.each(["top", "left"], function (i, prop) {
  6534. jQuery.cssHooks[prop] = addGetHookIf(support.pixelPosition,
  6535. function (elem, computed) {
  6536. if (computed) {
  6537. computed = curCSS(elem, prop);
  6538. // If curCSS returns percentage, fallback to offset
  6539. return rnumnonpx.test(computed) ?
  6540. jQuery(elem).position()[prop] + "px" :
  6541. computed;
  6542. }
  6543. }
  6544. );
  6545. });
  6546. // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
  6547. jQuery.each({ Height: "height", Width: "width" }, function (name, type) {
  6548. jQuery.each({ padding: "inner" + name, content: type, "": "outer" + name },
  6549. function (defaultExtra, funcName) {
  6550. // Margin is only for outerHeight, outerWidth
  6551. jQuery.fn[funcName] = function (margin, value) {
  6552. var chainable = arguments.length && (defaultExtra || typeof margin !== "boolean"),
  6553. extra = defaultExtra || (margin === true || value === true ? "margin" : "border");
  6554. return access(this, function (elem, type, value) {
  6555. var doc;
  6556. if (isWindow(elem)) {
  6557. // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
  6558. return funcName.indexOf("outer") === 0 ?
  6559. elem["inner" + name] :
  6560. elem.document.documentElement["client" + name];
  6561. }
  6562. // Get document width or height
  6563. if (elem.nodeType === 9) {
  6564. doc = elem.documentElement;
  6565. // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
  6566. // whichever is greatest
  6567. return Math.max(
  6568. elem.body["scroll" + name], doc["scroll" + name],
  6569. elem.body["offset" + name], doc["offset" + name],
  6570. doc["client" + name]
  6571. );
  6572. }
  6573. return value === undefined ?
  6574. // Get width or height on the element, requesting but not forcing parseFloat
  6575. jQuery.css(elem, type, extra) :
  6576. // Set width or height on the element
  6577. jQuery.style(elem, type, value, extra);
  6578. }, type, chainable ? margin : undefined, chainable);
  6579. };
  6580. });
  6581. });
  6582. jQuery.each(("blur focus focusin focusout resize scroll click dblclick " +
  6583. "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  6584. "change select submit keydown keypress keyup contextmenu").split(" "),
  6585. function (i, name) {
  6586. // Handle event binding
  6587. jQuery.fn[name] = function (data, fn) {
  6588. return arguments.length > 0 ?
  6589. this.on(name, null, data, fn) :
  6590. this.trigger(name);
  6591. };
  6592. });
  6593. jQuery.fn.extend({
  6594. hover: function (fnOver, fnOut) {
  6595. return this.mouseenter(fnOver).mouseleave(fnOut || fnOver);
  6596. }
  6597. });
  6598. jQuery.fn.extend({
  6599. bind: function (types, data, fn) {
  6600. return this.on(types, null, data, fn);
  6601. },
  6602. unbind: function (types, fn) {
  6603. return this.off(types, null, fn);
  6604. },
  6605. delegate: function (selector, types, data, fn) {
  6606. return this.on(types, selector, data, fn);
  6607. },
  6608. undelegate: function (selector, types, fn) {
  6609. // ( namespace ) or ( selector, types [, fn] )
  6610. return arguments.length === 1 ?
  6611. this.off(selector, "**") :
  6612. this.off(types, selector || "**", fn);
  6613. }
  6614. });
  6615. // Bind a function to a context, optionally partially applying any
  6616. // arguments.
  6617. // jQuery.proxy is deprecated to promote standards (specifically Function#bind)
  6618. // However, it is not slated for removal any time soon
  6619. jQuery.proxy = function (fn, context) {
  6620. var tmp, args, proxy;
  6621. if (typeof context === "string") {
  6622. tmp = fn[context];
  6623. context = fn;
  6624. fn = tmp;
  6625. }
  6626. // Quick check to determine if target is callable, in the spec
  6627. // this throws a TypeError, but we will just return undefined.
  6628. if (!isFunction(fn)) {
  6629. return undefined;
  6630. }
  6631. // Simulated bind
  6632. args = slice.call(arguments, 2);
  6633. proxy = function () {
  6634. return fn.apply(context || this, args.concat(slice.call(arguments)));
  6635. };
  6636. // Set the guid of unique handler to the same of original handler, so it can be removed
  6637. proxy.guid = fn.guid = fn.guid || jQuery.guid++;
  6638. return proxy;
  6639. };
  6640. jQuery.holdReady = function (hold) {
  6641. if (hold) {
  6642. jQuery.readyWait++;
  6643. } else {
  6644. jQuery.ready(true);
  6645. }
  6646. };
  6647. jQuery.isArray = Array.isArray;
  6648. jQuery.parseJSON = JSON.parse;
  6649. jQuery.nodeName = nodeName;
  6650. jQuery.isFunction = isFunction;
  6651. jQuery.isWindow = isWindow;
  6652. jQuery.camelCase = camelCase;
  6653. jQuery.type = toType;
  6654. jQuery.now = Date.now;
  6655. jQuery.isNumeric = function (obj) {
  6656. // As of jQuery 3.0, isNumeric is limited to
  6657. // strings and numbers (primitives or objects)
  6658. // that can be coerced to finite numbers (gh-2662)
  6659. var type = jQuery.type(obj);
  6660. return (type === "number" || type === "string") &&
  6661. // parseFloat NaNs numeric-cast false positives ("")
  6662. // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  6663. // subtraction forces infinities to NaN
  6664. !isNaN(obj - parseFloat(obj));
  6665. };
  6666. // Register as a named AMD module, since jQuery can be concatenated with other
  6667. // files that may use define, but not via a proper concatenation script that
  6668. // understands anonymous AMD modules. A named AMD is safest and most robust
  6669. // way to register. Lowercase jquery is used because AMD module names are
  6670. // derived from file names, and jQuery is normally delivered in a lowercase
  6671. // file name. Do this after creating the global so that if an AMD module wants
  6672. // to call noConflict to hide this version of jQuery, it will work.
  6673. // Note that for maximum portability, libraries that are not jQuery should
  6674. // declare themselves as anonymous modules, and avoid setting a global if an
  6675. // AMD loader is present. jQuery is a special case. For more information, see
  6676. // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
  6677. if (typeof define === "function" && define.amd) {
  6678. define("jquery", [], function () {
  6679. return jQuery;
  6680. });
  6681. }
  6682. var
  6683. // Map over jQuery in case of overwrite
  6684. _jQuery = window.jQuery,
  6685. // Map over the $ in case of overwrite
  6686. _$ = window.$;
  6687. jQuery.noConflict = function (deep) {
  6688. if (window.$ === jQuery) {
  6689. window.$ = _$;
  6690. }
  6691. if (deep && window.jQuery === jQuery) {
  6692. window.jQuery = _jQuery;
  6693. }
  6694. return jQuery;
  6695. };
  6696. // Expose jQuery and $ identifiers, even in AMD
  6697. // (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
  6698. // and CommonJS for browser emulators (#13566)
  6699. if (!noGlobal) {
  6700. window.jQuery = window.$ = jQuery;
  6701. }
  6702. return jQuery;
  6703. });