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.

9205 lines
242 KiB

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