PageRenderTime 45ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 2ms

/packages/jQuery.1.7/Content/Scripts/jquery-1.7.js

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