You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

9790 line
267KB

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