9598 lines
262KB

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