PageRenderTime 110ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 1ms

/trunk/js/jQuery/jquery.js

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