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.

9111 lines
239 KiB

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