Posted By

onefastsnail on 05/24/12


Tagged


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

mister
hurcy


JQUERY 1.7.1


 / Published in: JavaScript
 

  1. /*!
  2.  * jQuery JavaScript Library v1.7.1
  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: Mon Nov 21 21:11:03 2011 -0500
  15.  */
  16. (function( window, undefined ) {
  17.  
  18. // Use the correct document accordingly with window argument (sandbox)
  19. var document = window.document,
  20. navigator = window.navigator,
  21. location = window.location;
  22. var jQuery = (function() {
  23.  
  24. // Define a local copy of jQuery
  25. var jQuery = function( selector, context ) {
  26. // The jQuery object is actually just the init constructor 'enhanced'
  27. return new jQuery.fn.init( selector, context, rootjQuery );
  28. },
  29.  
  30. // Map over jQuery in case of overwrite
  31. _jQuery = window.jQuery,
  32.  
  33. // Map over the $ in case of overwrite
  34. _$ = window.$,
  35.  
  36. // A central reference to the root jQuery(document)
  37. rootjQuery,
  38.  
  39. // A simple way to check for HTML strings or ID strings
  40. // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
  41. quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
  42.  
  43. // Check if a string has a non-whitespace character in it
  44. rnotwhite = /\S/,
  45.  
  46. // Used for trimming whitespace
  47. trimLeft = /^\s+/,
  48. trimRight = /\s+$/,
  49.  
  50. // Match a standalone tag
  51. rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
  52.  
  53. // JSON RegExp
  54. rvalidchars = /^[\],:{}\s]*$/,
  55. rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
  56. rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
  57. rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
  58.  
  59. // Useragent RegExp
  60. rwebkit = /(webkit)[ \/]([\w.]+)/,
  61. ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
  62. rmsie = /(msie) ([\w.]+)/,
  63. rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
  64.  
  65. // Matches dashed string for camelizing
  66. rdashAlpha = /-([a-z]|[0-9])/ig,
  67. rmsPrefix = /^-ms-/,
  68.  
  69. // Used by jQuery.camelCase as callback to replace()
  70. fcamelCase = function( all, letter ) {
  71. return ( letter + "" ).toUpperCase();
  72. },
  73.  
  74. // Keep a UserAgent string for use with jQuery.browser
  75. userAgent = navigator.userAgent,
  76.  
  77. // For matching the engine and version of the browser
  78. browserMatch,
  79.  
  80. // The deferred used on DOM ready
  81. readyList,
  82.  
  83. // The ready event handler
  84. DOMContentLoaded,
  85.  
  86. // Save a reference to some core methods
  87. toString = Object.prototype.toString,
  88. hasOwn = Object.prototype.hasOwnProperty,
  89. push = Array.prototype.push,
  90. slice = Array.prototype.slice,
  91. trim = String.prototype.trim,
  92. indexOf = Array.prototype.indexOf,
  93.  
  94. // [[Class]] -> type pairs
  95. class2type = {};
  96.  
  97. jQuery.fn = jQuery.prototype = {
  98. constructor: jQuery,
  99. init: function( selector, context, rootjQuery ) {
  100. var match, elem, ret, doc;
  101.  
  102. // Handle $(""), $(null), or $(undefined)
  103. if ( !selector ) {
  104. return this;
  105. }
  106.  
  107. // Handle $(DOMElement)
  108. if ( selector.nodeType ) {
  109. this.context = this[0] = selector;
  110. this.length = 1;
  111. return this;
  112. }
  113.  
  114. // The body element only exists once, optimize finding it
  115. if ( selector === "body" && !context && document.body ) {
  116. this.context = document;
  117. this[0] = document.body;
  118. this.selector = selector;
  119. this.length = 1;
  120. return this;
  121. }
  122.  
  123. // Handle HTML strings
  124. if ( typeof selector === "string" ) {
  125. // Are we dealing with HTML string or an ID?
  126. if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
  127. // Assume that strings that start and end with <> are HTML and skip the regex check
  128. match = [ null, selector, null ];
  129.  
  130. } else {
  131. match = quickExpr.exec( selector );
  132. }
  133.  
  134. // Verify a match, and that no context was specified for #id
  135. if ( match && (match[1] || !context) ) {
  136.  
  137. // HANDLE: $(html) -> $(array)
  138. if ( match[1] ) {
  139. context = context instanceof jQuery ? context[0] : context;
  140. doc = ( context ? context.ownerDocument || context : document );
  141.  
  142. // If a single string is passed in and it's a single tag
  143. // just do a createElement and skip the rest
  144. ret = rsingleTag.exec( selector );
  145.  
  146. if ( ret ) {
  147. if ( jQuery.isPlainObject( context ) ) {
  148. selector = [ document.createElement( ret[1] ) ];
  149. jQuery.fn.attr.call( selector, context, true );
  150.  
  151. } else {
  152. selector = [ doc.createElement( ret[1] ) ];
  153. }
  154.  
  155. } else {
  156. ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
  157. selector = ( ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment ).childNodes;
  158. }
  159.  
  160. return jQuery.merge( this, selector );
  161.  
  162. // HANDLE: $("#id")
  163. } else {
  164. elem = document.getElementById( match[2] );
  165.  
  166. // Check parentNode to catch when Blackberry 4.6 returns
  167. // nodes that are no longer in the document #6963
  168. if ( elem && elem.parentNode ) {
  169. // Handle the case where IE and Opera return items
  170. // by name instead of ID
  171. if ( elem.id !== match[2] ) {
  172. return rootjQuery.find( selector );
  173. }
  174.  
  175. // Otherwise, we inject the element directly into the jQuery object
  176. this.length = 1;
  177. this[0] = elem;
  178. }
  179.  
  180. this.context = document;
  181. this.selector = selector;
  182. return this;
  183. }
  184.  
  185. // HANDLE: $(expr, $(...))
  186. } else if ( !context || context.jquery ) {
  187. return ( context || rootjQuery ).find( selector );
  188.  
  189. // HANDLE: $(expr, context)
  190. // (which is just equivalent to: $(context).find(expr)
  191. } else {
  192. return this.constructor( context ).find( selector );
  193. }
  194.  
  195. // HANDLE: $(function)
  196. // Shortcut for document ready
  197. } else if ( jQuery.isFunction( selector ) ) {
  198. return rootjQuery.ready( selector );
  199. }
  200.  
  201. if ( selector.selector !== undefined ) {
  202. this.selector = selector.selector;
  203. this.context = selector.context;
  204. }
  205.  
  206. return jQuery.makeArray( selector, this );
  207. },
  208.  
  209. // Start with an empty selector
  210. selector: "",
  211.  
  212. // The current version of jQuery being used
  213. jquery: "1.7.1",
  214.  
  215. // The default length of a jQuery object is 0
  216. length: 0,
  217.  
  218. // The number of elements contained in the matched element set
  219. size: function() {
  220. return this.length;
  221. },
  222.  
  223. toArray: function() {
  224. return slice.call( this, 0 );
  225. },
  226.  
  227. // Get the Nth element in the matched element set OR
  228. // Get the whole matched element set as a clean array
  229. get: function( num ) {
  230. return num == null ?
  231.  
  232. // Return a 'clean' array
  233. this.toArray() :
  234.  
  235. // Return just the object
  236. ( num < 0 ? this[ this.length + num ] : this[ num ] );
  237. },
  238.  
  239. // Take an array of elements and push it onto the stack
  240. // (returning the new matched element set)
  241. pushStack: function( elems, name, selector ) {
  242. // Build a new jQuery matched element set
  243. var ret = this.constructor();
  244.  
  245. if ( jQuery.isArray( elems ) ) {
  246. push.apply( ret, elems );
  247.  
  248. } else {
  249. jQuery.merge( ret, elems );
  250. }
  251.  
  252. // Add the old object onto the stack (as a reference)
  253. ret.prevObject = this;
  254.  
  255. ret.context = this.context;
  256.  
  257. if ( name === "find" ) {
  258. ret.selector = this.selector + ( this.selector ? " " : "" ) + selector;
  259. } else if ( name ) {
  260. ret.selector = this.selector + "." + name + "(" + selector + ")";
  261. }
  262.  
  263. // Return the newly-formed element set
  264. return ret;
  265. },
  266.  
  267. // Execute a callback for every element in the matched set.
  268. // (You can seed the arguments with an array of args, but this is
  269. // only used internally.)
  270. each: function( callback, args ) {
  271. return jQuery.each( this, callback, args );
  272. },
  273.  
  274. ready: function( fn ) {
  275. // Attach the listeners
  276. jQuery.bindReady();
  277.  
  278. // Add the callback
  279. readyList.add( fn );
  280.  
  281. return this;
  282. },
  283.  
  284. eq: function( i ) {
  285. i = +i;
  286. return i === -1 ?
  287. this.slice( i ) :
  288. this.slice( i, i + 1 );
  289. },
  290.  
  291. first: function() {
  292. return this.eq( 0 );
  293. },
  294.  
  295. last: function() {
  296. return this.eq( -1 );
  297. },
  298.  
  299. slice: function() {
  300. return this.pushStack( slice.apply( this, arguments ),
  301. "slice", slice.call(arguments).join(",") );
  302. },
  303.  
  304. map: function( callback ) {
  305. return this.pushStack( jQuery.map(this, function( elem, i ) {
  306. return callback.call( elem, i, elem );
  307. }));
  308. },
  309.  
  310. end: function() {
  311. return this.prevObject || this.constructor(null);
  312. },
  313.  
  314. // For internal use only.
  315. // Behaves like an Array's method, not like a jQuery method.
  316. push: push,
  317. sort: [].sort,
  318. splice: [].splice
  319. };
  320.  
  321. // Give the init function the jQuery prototype for later instantiation
  322. jQuery.fn.init.prototype = jQuery.fn;
  323.  
  324. jQuery.extend = jQuery.fn.extend = function() {
  325. var options, name, src, copy, copyIsArray, clone,
  326. target = arguments[0] || {},
  327. i = 1,
  328. length = arguments.length,
  329. deep = false;
  330.  
  331. // Handle a deep copy situation
  332. if ( typeof target === "boolean" ) {
  333. deep = target;
  334. target = arguments[1] || {};
  335. // skip the boolean and the target
  336. i = 2;
  337. }
  338.  
  339. // Handle case when target is a string or something (possible in deep copy)
  340. if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
  341. target = {};
  342. }
  343.  
  344. // extend jQuery itself if only one argument is passed
  345. if ( length === i ) {
  346. target = this;
  347. --i;
  348. }
  349.  
  350. for ( ; i < length; i++ ) {
  351. // Only deal with non-null/undefined values
  352. if ( (options = arguments[ i ]) != null ) {
  353. // Extend the base object
  354. for ( name in options ) {
  355. src = target[ name ];
  356. copy = options[ name ];
  357.  
  358. // Prevent never-ending loop
  359. if ( target === copy ) {
  360. continue;
  361. }
  362.  
  363. // Recurse if we're merging plain objects or arrays
  364. if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
  365. if ( copyIsArray ) {
  366. copyIsArray = false;
  367. clone = src && jQuery.isArray(src) ? src : [];
  368.  
  369. } else {
  370. clone = src && jQuery.isPlainObject(src) ? src : {};
  371. }
  372.  
  373. // Never move original objects, clone them
  374. target[ name ] = jQuery.extend( deep, clone, copy );
  375.  
  376. // Don't bring in undefined values
  377. } else if ( copy !== undefined ) {
  378. target[ name ] = copy;
  379. }
  380. }
  381. }
  382. }
  383.  
  384. // Return the modified object
  385. return target;
  386. };
  387.  
  388. jQuery.extend({
  389. noConflict: function( deep ) {
  390. if ( window.$ === jQuery ) {
  391. window.$ = _$;
  392. }
  393.  
  394. if ( deep && window.jQuery === jQuery ) {
  395. window.jQuery = _jQuery;
  396. }
  397.  
  398. return jQuery;
  399. },
  400.  
  401. // Is the DOM ready to be used? Set to true once it occurs.
  402. isReady: false,
  403.  
  404. // A counter to track how many items to wait for before
  405. // the ready event fires. See #6781
  406. readyWait: 1,
  407.  
  408. // Hold (or release) the ready event
  409. holdReady: function( hold ) {
  410. if ( hold ) {
  411. jQuery.readyWait++;
  412. } else {
  413. jQuery.ready( true );
  414. }
  415. },
  416.  
  417. // Handle when the DOM is ready
  418. ready: function( wait ) {
  419. // Either a released hold or an DOMready/load event and not yet ready
  420. if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) {
  421. // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
  422. if ( !document.body ) {
  423. return setTimeout( jQuery.ready, 1 );
  424. }
  425.  
  426. // Remember that the DOM is ready
  427. jQuery.isReady = true;
  428.  
  429. // If a normal DOM Ready event fired, decrement, and wait if need be
  430. if ( wait !== true && --jQuery.readyWait > 0 ) {
  431. return;
  432. }
  433.  
  434. // If there are functions bound, to execute
  435. readyList.fireWith( document, [ jQuery ] );
  436.  
  437. // Trigger any bound ready events
  438. if ( jQuery.fn.trigger ) {
  439. jQuery( document ).trigger( "ready" ).off( "ready" );
  440. }
  441. }
  442. },
  443.  
  444. bindReady: function() {
  445. if ( readyList ) {
  446. return;
  447. }
  448.  
  449. readyList = jQuery.Callbacks( "once memory" );
  450.  
  451. // Catch cases where $(document).ready() is called after the
  452. // browser event has already occurred.
  453. if ( document.readyState === "complete" ) {
  454. // Handle it asynchronously to allow scripts the opportunity to delay ready
  455. return setTimeout( jQuery.ready, 1 );
  456. }
  457.  
  458. // Mozilla, Opera and webkit nightlies currently support this event
  459. if ( document.addEventListener ) {
  460. // Use the handy event callback
  461. document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
  462.  
  463. // A fallback to window.onload, that will always work
  464. window.addEventListener( "load", jQuery.ready, false );
  465.  
  466. // If IE event model is used
  467. } else if ( document.attachEvent ) {
  468. // ensure firing before onload,
  469. // maybe late but safe also for iframes
  470. document.attachEvent( "onreadystatechange", DOMContentLoaded );
  471.  
  472. // A fallback to window.onload, that will always work
  473. window.attachEvent( "onload", jQuery.ready );
  474.  
  475. // If IE and not a frame
  476. // continually check to see if the document is ready
  477. var toplevel = false;
  478.  
  479. try {
  480. toplevel = window.frameElement == null;
  481. } catch(e) {}
  482.  
  483. if ( document.documentElement.doScroll && toplevel ) {
  484. doScrollCheck();
  485. }
  486. }
  487. },
  488.  
  489. // See test/unit/core.js for details concerning isFunction.
  490. // Since version 1.3, DOM methods and functions like alert
  491. // aren't supported. They return false on IE (#2968).
  492. isFunction: function( obj ) {
  493. return jQuery.type(obj) === "function";
  494. },
  495.  
  496. isArray: Array.isArray || function( obj ) {
  497. return jQuery.type(obj) === "array";
  498. },
  499.  
  500. // A crude way of determining if an object is a window
  501. isWindow: function( obj ) {
  502. return obj && typeof obj === "object" && "setInterval" in obj;
  503. },
  504.  
  505. isNumeric: function( obj ) {
  506. return !isNaN( parseFloat(obj) ) && isFinite( obj );
  507. },
  508.  
  509. type: function( obj ) {
  510. return obj == null ?
  511. String( obj ) :
  512. class2type[ toString.call(obj) ] || "object";
  513. },
  514.  
  515. isPlainObject: function( obj ) {
  516. // Must be an Object.
  517. // Because of IE, we also have to check the presence of the constructor property.
  518. // Make sure that DOM nodes and window objects don't pass through, as well
  519. if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
  520. return false;
  521. }
  522.  
  523. try {
  524. // Not own constructor property must be Object
  525. if ( obj.constructor &&
  526. !hasOwn.call(obj, "constructor") &&
  527. !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
  528. return false;
  529. }
  530. } catch ( e ) {
  531. // IE8,9 Will throw exceptions on certain host objects #9897
  532. return false;
  533. }
  534.  
  535. // Own properties are enumerated firstly, so to speed up,
  536. // if last one is own, then all properties are own.
  537.  
  538. var key;
  539. for ( key in obj ) {}
  540.  
  541. return key === undefined || hasOwn.call( obj, key );
  542. },
  543.  
  544. isEmptyObject: function( obj ) {
  545. for ( var name in obj ) {
  546. return false;
  547. }
  548. return true;
  549. },
  550.  
  551. error: function( msg ) {
  552. throw new Error( msg );
  553. },
  554.  
  555. parseJSON: function( data ) {
  556. if ( typeof data !== "string" || !data ) {
  557. return null;
  558. }
  559.  
  560. // Make sure leading/trailing whitespace is removed (IE can't handle it)
  561. data = jQuery.trim( data );
  562.  
  563. // Attempt to parse using the native JSON parser first
  564. if ( window.JSON && window.JSON.parse ) {
  565. return window.JSON.parse( data );
  566. }
  567.  
  568. // Make sure the incoming data is actual JSON
  569. // Logic borrowed from http://json.org/json2.js
  570. if ( rvalidchars.test( data.replace( rvalidescape, "@" )
  571. .replace( rvalidtokens, "]" )
  572. .replace( rvalidbraces, "")) ) {
  573.  
  574. return ( new Function( "return " + data ) )();
  575.  
  576. }
  577. jQuery.error( "Invalid JSON: " + data );
  578. },
  579.  
  580. // Cross-browser xml parsing
  581. parseXML: function( data ) {
  582. var xml, tmp;
  583. try {
  584. if ( window.DOMParser ) { // Standard
  585. tmp = new DOMParser();
  586. xml = tmp.parseFromString( data , "text/xml" );
  587. } else { // IE
  588. xml = new ActiveXObject( "Microsoft.XMLDOM" );
  589. xml.async = "false";
  590. xml.loadXML( data );
  591. }
  592. } catch( e ) {
  593. xml = undefined;
  594. }
  595. if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
  596. jQuery.error( "Invalid XML: " + data );
  597. }
  598. return xml;
  599. },
  600.  
  601. noop: function() {},
  602.  
  603. // Evaluates a script in a global context
  604. // Workarounds based on findings by Jim Driscoll
  605. // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
  606. globalEval: function( data ) {
  607. if ( data && rnotwhite.test( data ) ) {
  608. // We use execScript on Internet Explorer
  609. // We use an anonymous function so that context is window
  610. // rather than jQuery in Firefox
  611. ( window.execScript || function( data ) {
  612. window[ "eval" ].call( window, data );
  613. } )( data );
  614. }
  615. },
  616.  
  617. // Convert dashed to camelCase; used by the css and data modules
  618. // Microsoft forgot to hump their vendor prefix (#9572)
  619. camelCase: function( string ) {
  620. return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
  621. },
  622.  
  623. nodeName: function( elem, name ) {
  624. return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
  625. },
  626.  
  627. // args is for internal usage only
  628. each: function( object, callback, args ) {
  629. var name, i = 0,
  630. length = object.length,
  631. isObj = length === undefined || jQuery.isFunction( object );
  632.  
  633. if ( args ) {
  634. if ( isObj ) {
  635. for ( name in object ) {
  636. if ( callback.apply( object[ name ], args ) === false ) {
  637. break;
  638. }
  639. }
  640. } else {
  641. for ( ; i < length; ) {
  642. if ( callback.apply( object[ i++ ], args ) === false ) {
  643. break;
  644. }
  645. }
  646. }
  647.  
  648. // A special, fast, case for the most common use of each
  649. } else {
  650. if ( isObj ) {
  651. for ( name in object ) {
  652. if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
  653. break;
  654. }
  655. }
  656. } else {
  657. for ( ; i < length; ) {
  658. if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) {
  659. break;
  660. }
  661. }
  662. }
  663. }
  664.  
  665. return object;
  666. },
  667.  
  668. // Use native String.trim function wherever possible
  669. trim: trim ?
  670. function( text ) {
  671. return text == null ?
  672. "" :
  673. trim.call( text );
  674. } :
  675.  
  676. // Otherwise use our own trimming functionality
  677. function( text ) {
  678. return text == null ?
  679. "" :
  680. text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
  681. },
  682.  
  683. // results is for internal usage only
  684. makeArray: function( array, results ) {
  685. var ret = results || [];
  686.  
  687. if ( array != null ) {
  688. // The window, strings (and functions) also have 'length'
  689. // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
  690. var type = jQuery.type( array );
  691.  
  692. if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
  693. push.call( ret, array );
  694. } else {
  695. jQuery.merge( ret, array );
  696. }
  697. }
  698.  
  699. return ret;
  700. },
  701.  
  702. inArray: function( elem, array, i ) {
  703. var len;
  704.  
  705. if ( array ) {
  706. if ( indexOf ) {
  707. return indexOf.call( array, elem, i );
  708. }
  709.  
  710. len = array.length;
  711. i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
  712.  
  713. for ( ; i < len; i++ ) {
  714. // Skip accessing in sparse arrays
  715. if ( i in array && array[ i ] === elem ) {
  716. return i;
  717. }
  718. }
  719. }
  720.  
  721. return -1;
  722. },
  723.  
  724. merge: function( first, second ) {
  725. var i = first.length,
  726. j = 0;
  727.  
  728. if ( typeof second.length === "number" ) {
  729. for ( var l = second.length; j < l; j++ ) {
  730. first[ i++ ] = second[ j ];
  731. }
  732.  
  733. } else {
  734. while ( second[j] !== undefined ) {
  735. first[ i++ ] = second[ j++ ];
  736. }
  737. }
  738.  
  739. first.length = i;
  740.  
  741. return first;
  742. },
  743.  
  744. grep: function( elems, callback, inv ) {
  745. var ret = [], retVal;
  746. inv = !!inv;
  747.  
  748. // Go through the array, only saving the items
  749. // that pass the validator function
  750. for ( var i = 0, length = elems.length; i < length; i++ ) {
  751. retVal = !!callback( elems[ i ], i );
  752. if ( inv !== retVal ) {
  753. ret.push( elems[ i ] );
  754. }
  755. }
  756.  
  757. return ret;
  758. },
  759.  
  760. // arg is for internal usage only
  761. map: function( elems, callback, arg ) {
  762. var value, key, ret = [],
  763. i = 0,
  764. length = elems.length,
  765. // jquery objects are treated as arrays
  766. isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ;
  767.  
  768. // Go through the array, translating each of the items to their
  769. if ( isArray ) {
  770. for ( ; i < length; i++ ) {
  771. value = callback( elems[ i ], i, arg );
  772.  
  773. if ( value != null ) {
  774. ret[ ret.length ] = value;
  775. }
  776. }
  777.  
  778. // Go through every key on the object,
  779. } else {
  780. for ( key in elems ) {
  781. value = callback( elems[ key ], key, arg );
  782.  
  783. if ( value != null ) {
  784. ret[ ret.length ] = value;
  785. }
  786. }
  787. }
  788.  
  789. // Flatten any nested arrays
  790. return ret.concat.apply( [], ret );
  791. },
  792.  
  793. // A global GUID counter for objects
  794. guid: 1,
  795.  
  796. // Bind a function to a context, optionally partially applying any
  797. // arguments.
  798. proxy: function( fn, context ) {
  799. if ( typeof context === "string" ) {
  800. var tmp = fn[ context ];
  801. context = fn;
  802. fn = tmp;
  803. }
  804.  
  805. // Quick check to determine if target is callable, in the spec
  806. // this throws a TypeError, but we will just return undefined.
  807. if ( !jQuery.isFunction( fn ) ) {
  808. return undefined;
  809. }
  810.  
  811. // Simulated bind
  812. var args = slice.call( arguments, 2 ),
  813. proxy = function() {
  814. return fn.apply( context, args.concat( slice.call( arguments ) ) );
  815. };
  816.  
  817. // Set the guid of unique handler to the same of original handler, so it can be removed
  818. proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
  819.  
  820. return proxy;
  821. },
  822.  
  823. // Mutifunctional method to get and set values to a collection
  824. // The value/s can optionally be executed if it's a function
  825. access: function( elems, key, value, exec, fn, pass ) {
  826. var length = elems.length;
  827.  
  828. // Setting many attributes
  829. if ( typeof key === "object" ) {
  830. for ( var k in key ) {
  831. jQuery.access( elems, k, key[k], exec, fn, value );
  832. }
  833. return elems;
  834. }
  835.  
  836. // Setting one attribute
  837. if ( value !== undefined ) {
  838. // Optionally, function values get executed if exec is true
  839. exec = !pass && exec && jQuery.isFunction(value);
  840.  
  841. for ( var i = 0; i < length; i++ ) {
  842. fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
  843. }
  844.  
  845. return elems;
  846. }
  847.  
  848. // Getting an attribute
  849. return length ? fn( elems[0], key ) : undefined;
  850. },
  851.  
  852. now: function() {
  853. return ( new Date() ).getTime();
  854. },
  855.  
  856. // Use of jQuery.browser is frowned upon.
  857. // More details: http://docs.jquery.com/Utilities/jQuery.browser
  858. uaMatch: function( ua ) {
  859. ua = ua.toLowerCase();
  860.  
  861. var match = rwebkit.exec( ua ) ||
  862. ropera.exec( ua ) ||
  863. rmsie.exec( ua ) ||
  864. ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
  865. [];
  866.  
  867. return { browser: match[1] || "", version: match[2] || "0" };
  868. },
  869.  
  870. sub: function() {
  871. function jQuerySub( selector, context ) {
  872. return new jQuerySub.fn.init( selector, context );
  873. }
  874. jQuery.extend( true, jQuerySub, this );
  875. jQuerySub.superclass = this;
  876. jQuerySub.fn = jQuerySub.prototype = this();
  877. jQuerySub.fn.constructor = jQuerySub;
  878. jQuerySub.sub = this.sub;
  879. jQuerySub.fn.init = function init( selector, context ) {
  880. if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {
  881. context = jQuerySub( context );
  882. }
  883.  
  884. return jQuery.fn.init.call( this, selector, context, rootjQuerySub );
  885. };
  886. jQuerySub.fn.init.prototype = jQuerySub.fn;
  887. var rootjQuerySub = jQuerySub(document);
  888. return jQuerySub;
  889. },
  890.  
  891. browser: {}
  892. });
  893.  
  894. // Populate the class2type map
  895. jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
  896. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  897. });
  898.  
  899. browserMatch = jQuery.uaMatch( userAgent );
  900. if ( browserMatch.browser ) {
  901. jQuery.browser[ browserMatch.browser ] = true;
  902. jQuery.browser.version = browserMatch.version;
  903. }
  904.  
  905. // Deprecated, use jQuery.browser.webkit instead
  906. if ( jQuery.browser.webkit ) {
  907. jQuery.browser.safari = true;
  908. }
  909.  
  910. // IE doesn't match non-breaking spaces with \s
  911. if ( rnotwhite.test( "\xA0" ) ) {
  912. trimLeft = /^[\s\xA0]+/;
  913. trimRight = /[\s\xA0]+$/;
  914. }
  915.  
  916. // All jQuery objects should point back to these
  917. rootjQuery = jQuery(document);
  918.  
  919. // Cleanup functions for the document ready method
  920. if ( document.addEventListener ) {
  921. DOMContentLoaded = function() {
  922. document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
  923. jQuery.ready();
  924. };
  925.  
  926. } else if ( document.attachEvent ) {
  927. DOMContentLoaded = function() {
  928. // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
  929. if ( document.readyState === "complete" ) {
  930. document.detachEvent( "onreadystatechange", DOMContentLoaded );
  931. jQuery.ready();
  932. }
  933. };
  934. }
  935.  
  936. // The DOM ready check for Internet Explorer
  937. function doScrollCheck() {
  938. if ( jQuery.isReady ) {
  939. return;
  940. }
  941.  
  942. try {
  943. // If IE is used, use the trick by Diego Perini
  944. // http://javascript.nwbox.com/IEContentLoaded/
  945. document.documentElement.doScroll("left");
  946. } catch(e) {
  947. setTimeout( doScrollCheck, 1 );
  948. return;
  949. }
  950.  
  951. // and execute any waiting functions
  952. jQuery.ready();
  953. }
  954.  
  955. return jQuery;
  956.  
  957. })();
  958.  
  959.  
  960. // String to Object flags format cache
  961. var flagsCache = {};
  962.  
  963. // Convert String-formatted flags into Object-formatted ones and store in cache
  964. function createFlags( flags ) {
  965. var object = flagsCache[ flags ] = {},
  966. i, length;
  967. flags = flags.split( /\s+/ );
  968. for ( i = 0, length = flags.length; i < length; i++ ) {
  969. object[ flags[i] ] = true;
  970. }
  971. return object;
  972. }
  973.  
  974. /*
  975.  * Create a callback list using the following parameters:
  976.  *
  977.  * flags: an optional list of space-separated flags that will change how
  978.  * the callback list behaves
  979.  *
  980.  * By default a callback list will act like an event callback list and can be
  981.  * "fired" multiple times.
  982.  *
  983.  * Possible flags:
  984.  *
  985.  * once: will ensure the callback list can only be fired once (like a Deferred)
  986.  *
  987.  * memory: will keep track of previous values and will call any callback added
  988.  * after the list has been fired right away with the latest "memorized"
  989.  * values (like a Deferred)
  990.  *
  991.  * unique: will ensure a callback can only be added once (no duplicate in the list)
  992.  *
  993.  * stopOnFalse: interrupt callings when a callback returns false
  994.  *
  995.  */
  996. jQuery.Callbacks = function( flags ) {
  997.  
  998. // Convert flags from String-formatted to Object-formatted
  999. // (we check in cache first)
  1000. flags = flags ? ( flagsCache[ flags ] || createFlags( flags ) ) : {};
  1001.  
  1002. var // Actual callback list
  1003. list = [],
  1004. // Stack of fire calls for repeatable lists
  1005. stack = [],
  1006. // Last fire value (for non-forgettable lists)
  1007. memory,
  1008. // Flag to know if list is currently firing
  1009. firing,
  1010. // First callback to fire (used internally by add and fireWith)
  1011. firingStart,
  1012. // End of the loop when firing
  1013. firingLength,
  1014. // Index of currently firing callback (modified by remove if needed)
  1015. firingIndex,
  1016. // Add one or several callbacks to the list
  1017. add = function( args ) {
  1018. var i,
  1019. length,
  1020. elem,
  1021. type,
  1022. actual;
  1023. for ( i = 0, length = args.length; i < length; i++ ) {
  1024. elem = args[ i ];
  1025. type = jQuery.type( elem );
  1026. if ( type === "array" ) {
  1027. // Inspect recursively
  1028. add( elem );
  1029. } else if ( type === "function" ) {
  1030. // Add if not in unique mode and callback is not in
  1031. if ( !flags.unique || !self.has( elem ) ) {
  1032. list.push( elem );
  1033. }
  1034. }
  1035. }
  1036. },
  1037. // Fire callbacks
  1038. fire = function( context, args ) {
  1039. args = args || [];
  1040. memory = !flags.memory || [ context, args ];
  1041. firing = true;
  1042. firingIndex = firingStart || 0;
  1043. firingStart = 0;
  1044. firingLength = list.length;
  1045. for ( ; list && firingIndex < firingLength; firingIndex++ ) {
  1046. if ( list[ firingIndex ].apply( context, args ) === false && flags.stopOnFalse ) {
  1047. memory = true; // Mark as halted
  1048. break;
  1049. }
  1050. }
  1051. firing = false;
  1052. if ( list ) {
  1053. if ( !flags.once ) {
  1054. if ( stack && stack.length ) {
  1055. memory = stack.shift();
  1056. self.fireWith( memory[ 0 ], memory[ 1 ] );
  1057. }
  1058. } else if ( memory === true ) {
  1059. self.disable();
  1060. } else {
  1061. list = [];
  1062. }
  1063. }
  1064. },
  1065. // Actual Callbacks object
  1066. self = {
  1067. // Add a callback or a collection of callbacks to the list
  1068. add: function() {
  1069. if ( list ) {
  1070. var length = list.length;
  1071. add( arguments );
  1072. // Do we need to add the callbacks to the
  1073. // current firing batch?
  1074. if ( firing ) {
  1075. firingLength = list.length;
  1076. // With memory, if we're not firing then
  1077. // we should call right away, unless previous
  1078. // firing was halted (stopOnFalse)
  1079. } else if ( memory && memory !== true ) {
  1080. firingStart = length;
  1081. fire( memory[ 0 ], memory[ 1 ] );
  1082. }
  1083. }
  1084. return this;
  1085. },
  1086. // Remove a callback from the list
  1087. remove: function() {
  1088. if ( list ) {
  1089. var args = arguments,
  1090. argIndex = 0,
  1091. argLength = args.length;
  1092. for ( ; argIndex < argLength ; argIndex++ ) {
  1093. for ( var i = 0; i < list.length; i++ ) {
  1094. if ( args[ argIndex ] === list[ i ] ) {
  1095. // Handle firingIndex and firingLength
  1096. if ( firing ) {
  1097. if ( i <= firingLength ) {
  1098. firingLength--;
  1099. if ( i <= firingIndex ) {
  1100. firingIndex--;
  1101. }
  1102. }
  1103. }
  1104. // Remove the element
  1105. list.splice( i--, 1 );
  1106. // If we have some unicity property then
  1107. // we only need to do this once
  1108. if ( flags.unique ) {
  1109. break;
  1110. }
  1111. }
  1112. }
  1113. }
  1114. }
  1115. return this;
  1116. },
  1117. // Control if a given callback is in the list
  1118. has: function( fn ) {
  1119. if ( list ) {
  1120. var i = 0,
  1121. length = list.length;
  1122. for ( ; i < length; i++ ) {
  1123. if ( fn === list[ i ] ) {
  1124. return true;
  1125. }
  1126. }
  1127. }
  1128. return false;
  1129. },
  1130. // Remove all callbacks from the list
  1131. empty: function() {
  1132. list = [];
  1133. return this;
  1134. },
  1135. // Have the list do nothing anymore
  1136. disable: function() {
  1137. list = stack = memory = undefined;
  1138. return this;
  1139. },
  1140. // Is it disabled?
  1141. disabled: function() {
  1142. return !list;
  1143. },
  1144. // Lock the list in its current state
  1145. lock: function() {
  1146. stack = undefined;
  1147. if ( !memory || memory === true ) {
  1148. self.disable();
  1149. }
  1150. return this;
  1151. },
  1152. // Is it locked?
  1153. locked: function() {
  1154. return !stack;
  1155. },
  1156. // Call all callbacks with the given context and arguments
  1157. fireWith: function( context, args ) {
  1158. if ( stack ) {
  1159. if ( firing ) {
  1160. if ( !flags.once ) {
  1161. stack.push( [ context, args ] );
  1162. }
  1163. } else if ( !( flags.once && memory ) ) {
  1164. fire( context, args );
  1165. }
  1166. }
  1167. return this;
  1168. },
  1169. // Call all the callbacks with the given arguments
  1170. fire: function() {
  1171. self.fireWith( this, arguments );
  1172. return this;
  1173. },
  1174. // To know if the callbacks have already been called at least once
  1175. fired: function() {
  1176. return !!memory;
  1177. }
  1178. };
  1179.  
  1180. return self;
  1181. };
  1182.  
  1183.  
  1184.  
  1185.  
  1186. var // Static reference to slice
  1187. sliceDeferred = [].slice;
  1188.  
  1189. jQuery.extend({
  1190.  
  1191. Deferred: function( func ) {
  1192. var doneList = jQuery.Callbacks( "once memory" ),
  1193. failList = jQuery.Callbacks( "once memory" ),
  1194. progressList = jQuery.Callbacks( "memory" ),
  1195. state = "pending",
  1196. lists = {
  1197. resolve: doneList,
  1198. reject: failList,
  1199. notify: progressList
  1200. },
  1201. promise = {
  1202. done: doneList.add,
  1203. fail: failList.add,
  1204. progress: progressList.add,
  1205.  
  1206. state: function() {
  1207. return state;
  1208. },
  1209.  
  1210. // Deprecated
  1211. isResolved: doneList.fired,
  1212. isRejected: failList.fired,
  1213.  
  1214. then: function( doneCallbacks, failCallbacks, progressCallbacks ) {
  1215. deferred.done( doneCallbacks ).fail( failCallbacks ).progress( progressCallbacks );
  1216. return this;
  1217. },
  1218. always: function() {
  1219. deferred.done.apply( deferred, arguments ).fail.apply( deferred, arguments );
  1220. return this;
  1221. },
  1222. pipe: function( fnDone, fnFail, fnProgress ) {
  1223. return jQuery.Deferred(function( newDefer ) {
  1224. jQuery.each( {
  1225. done: [ fnDone, "resolve" ],
  1226. fail: [ fnFail, "reject" ],
  1227. progress: [ fnProgress, "notify" ]
  1228. }, function( handler, data ) {
  1229. var fn = data[ 0 ],
  1230. action = data[ 1 ],
  1231. returned;
  1232. if ( jQuery.isFunction( fn ) ) {
  1233. deferred[ handler ](function() {
  1234. returned = fn.apply( this, arguments );
  1235. if ( returned && jQuery.isFunction( returned.promise ) ) {
  1236. returned.promise().then( newDefer.resolve, newDefer.reject, newDefer.notify );
  1237. } else {
  1238. newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] );
  1239. }
  1240. });
  1241. } else {
  1242. deferred[ handler ]( newDefer[ action ] );
  1243. }
  1244. });
  1245. }).promise();
  1246. },
  1247. // Get a promise for this deferred
  1248. // If obj is provided, the promise aspect is added to the object
  1249. promise: function( obj ) {
  1250. if ( obj == null ) {
  1251. obj = promise;
  1252. } else {
  1253. for ( var key in promise ) {
  1254. obj[ key ] = promise[ key ];
  1255. }
  1256. }
  1257. return obj;
  1258. }
  1259. },
  1260. deferred = promise.promise({}),
  1261. key;
  1262.  
  1263. for ( key in lists ) {
  1264. deferred[ key ] = lists[ key ].fire;
  1265. deferred[ key + "With" ] = lists[ key ].fireWith;
  1266. }
  1267.  
  1268. // Handle state
  1269. deferred.done( function() {
  1270. state = "resolved";
  1271. }, failList.disable, progressList.lock ).fail( function() {
  1272. state = "rejected";
  1273. }, doneList.disable, progressList.lock );
  1274.  
  1275. // Call given func if any
  1276. if ( func ) {
  1277. func.call( deferred, deferred );
  1278. }
  1279.  
  1280. // All done!
  1281. return deferred;
  1282. },
  1283.  
  1284. // Deferred helper
  1285. when: function( firstParam ) {
  1286. var args = sliceDeferred.call( arguments, 0 ),
  1287. i = 0,
  1288. length = args.length,
  1289. pValues = new Array( length ),
  1290. count = length,
  1291. pCount = length,
  1292. deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ?
  1293. firstParam :
  1294. jQuery.Deferred(),
  1295. promise = deferred.promise();
  1296. function resolveFunc( i ) {
  1297. return function( value ) {
  1298. args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
  1299. if ( !( --count ) ) {
  1300. deferred.resolveWith( deferred, args );
  1301. }
  1302. };
  1303. }
  1304. function progressFunc( i ) {
  1305. return function( value ) {
  1306. pValues[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
  1307. deferred.notifyWith( promise, pValues );
  1308. };
  1309. }
  1310. if ( length > 1 ) {
  1311. for ( ; i < length; i++ ) {
  1312. if ( args[ i ] && args[ i ].promise && jQuery.isFunction( args[ i ].promise ) ) {
  1313. args[ i ].promise().then( resolveFunc(i), deferred.reject, progressFunc(i) );
  1314. } else {
  1315. --count;
  1316. }
  1317. }
  1318. if ( !count ) {
  1319. deferred.resolveWith( deferred, args );
  1320. }
  1321. } else if ( deferred !== firstParam ) {
  1322. deferred.resolveWith( deferred, length ? [ firstParam ] : [] );
  1323. }
  1324. return promise;
  1325. }
  1326. });
  1327.  
  1328.  
  1329.  
  1330.  
  1331. jQuery.support = (function() {
  1332.  
  1333. var support,
  1334. all,
  1335. a,
  1336. select,
  1337. opt,
  1338. input,
  1339. marginDiv,
  1340. fragment,
  1341. tds,
  1342. events,
  1343. eventName,
  1344. i,
  1345. isSupported,
  1346. div = document.createElement( "div" ),
  1347. documentElement = document.documentElement;
  1348.  
  1349. // Preliminary tests
  1350. div.setAttribute("className", "t");
  1351. div.innerHTML = " <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
  1352.  
  1353. all = div.getElementsByTagName( "*" );
  1354. a = div.getElementsByTagName( "a" )[ 0 ];
  1355.  
  1356. // Can't get basic test support
  1357. if ( !all || !all.length || !a ) {
  1358. return {};
  1359. }
  1360.  
  1361. // First batch of supports tests
  1362. select = document.createElement( "select" );
  1363. opt = select.appendChild( document.createElement("option") );
  1364. input = div.getElementsByTagName( "input" )[ 0 ];
  1365.  
  1366. support = {
  1367. // IE strips leading whitespace when .innerHTML is used
  1368. leadingWhitespace: ( div.firstChild.nodeType === 3 ),
  1369.  
  1370. // Make sure that tbody elements aren't automatically inserted
  1371. // IE will insert them into empty tables
  1372. tbody: !div.getElementsByTagName("tbody").length,
  1373.  
  1374. // Make sure that link elements get serialized correctly by innerHTML
  1375. // This requires a wrapper element in IE
  1376. htmlSerialize: !!div.getElementsByTagName("link").length,
  1377.  
  1378. // Get the style information from getAttribute
  1379. // (IE uses .cssText instead)
  1380. style: /top/.test( a.getAttribute("style") ),
  1381.  
  1382. // Make sure that URLs aren't manipulated
  1383. // (IE normalizes it by default)
  1384. hrefNormalized: ( a.getAttribute("href") === "/a" ),
  1385.  
  1386. // Make sure that element opacity exists
  1387. // (IE uses filter instead)
  1388. // Use a regex to work around a WebKit issue. See #5145
  1389. opacity: /^0.55/.test( a.style.opacity ),
  1390.  
  1391. // Verify style float existence
  1392. // (IE uses styleFloat instead of cssFloat)
  1393. cssFloat: !!a.style.cssFloat,
  1394.  
  1395. // Make sure that if no value is specified for a checkbox
  1396. // that it defaults to "on".
  1397. // (WebKit defaults to "" instead)
  1398. checkOn: ( input.value === "on" ),
  1399.  
  1400. // Make sure that a selected-by-default option has a working selected property.
  1401. // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
  1402. optSelected: opt.selected,
  1403.  
  1404. // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
  1405. getSetAttribute: div.className !== "t",
  1406.  
  1407. // Tests for enctype support on a form(#6743)
  1408. enctype: !!document.createElement("form").enctype,
  1409.  
  1410. // Makes sure cloning an html5 element does not cause problems
  1411. // Where outerHTML is undefined, this still works
  1412. html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav></:nav>",
  1413.  
  1414. // Will be defined later
  1415. submitBubbles: true,
  1416. changeBubbles: true,
  1417. focusinBubbles: false,
  1418. deleteExpando: true,
  1419. noCloneEvent: true,
  1420. inlineBlockNeedsLayout: false,
  1421. shrinkWrapBlocks: false,
  1422. reliableMarginRight: true
  1423. };
  1424.  
  1425. // Make sure checked status is properly cloned
  1426. input.checked = true;
  1427. support.noCloneChecked = input.cloneNode( true ).checked;
  1428.  
  1429. // Make sure that the options inside disabled selects aren't marked as disabled
  1430. // (WebKit marks them as disabled)
  1431. select.disabled = true;
  1432. support.optDisabled = !opt.disabled;
  1433.  
  1434. // Test to see if it's possible to delete an expando from an element
  1435. // Fails in Internet Explorer
  1436. try {
  1437. delete div.test;
  1438. } catch( e ) {
  1439. support.deleteExpando = false;
  1440. }
  1441.  
  1442. if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
  1443. div.attachEvent( "onclick", function() {
  1444. // Cloning a node shouldn't copy over any
  1445. // bound event handlers (IE does this)
  1446. support.noCloneEvent = false;
  1447. });
  1448. div.cloneNode( true ).fireEvent( "onclick" );
  1449. }
  1450.  
  1451. // Check if a radio maintains its value
  1452. // after being appended to the DOM
  1453. input = document.createElement("input");
  1454. input.value = "t";
  1455. input.setAttribute("type", "radio");
  1456. support.radioValue = input.value === "t";
  1457.  
  1458. input.setAttribute("checked", "checked");
  1459. div.appendChild( input );
  1460. fragment = document.createDocumentFragment();
  1461. fragment.appendChild( div.lastChild );
  1462.  
  1463. // WebKit doesn't clone checked state correctly in fragments
  1464. support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
  1465.  
  1466. // Check if a disconnected checkbox will retain its checked
  1467. // value of true after appended to the DOM (IE6/7)
  1468. support.appendChecked = input.checked;
  1469.  
  1470. fragment.removeChild( input );
  1471. fragment.appendChild( div );
  1472.  
  1473. div.innerHTML = "";
  1474.  
  1475. // Check if div with explicit width and no margin-right incorrectly
  1476. // gets computed margin-right based on width of container. For more
  1477. // info see bug #3333
  1478. // Fails in WebKit before Feb 2011 nightlies
  1479. // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
  1480. if ( window.getComputedStyle ) {
  1481. marginDiv = document.createElement( "div" );
  1482. marginDiv.style.width = "0";
  1483. marginDiv.style.marginRight = "0";
  1484. div.style.width = "2px";
  1485. div.appendChild( marginDiv );
  1486. support.reliableMarginRight =
  1487. ( parseInt( ( window.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0;
  1488. }
  1489.  
  1490. // Technique from Juriy Zaytsev
  1491. // http://perfectionkills.com/detecting-event-support-without-browser-sniffing/
  1492. // We only care about the case where non-standard event systems
  1493. // are used, namely in IE. Short-circuiting here helps us to
  1494. // avoid an eval call (in setAttribute) which can cause CSP
  1495. // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
  1496. if ( div.attachEvent ) {
  1497. for( i in {
  1498. submit: 1,
  1499. change: 1,
  1500. focusin: 1
  1501. }) {
  1502. eventName = "on" + i;
  1503. isSupported = ( eventName in div );
  1504. if ( !isSupported ) {
  1505. div.setAttribute( eventName, "return;" );
  1506. isSupported = ( typeof div[ eventName ] === "function" );
  1507. }
  1508. support[ i + "Bubbles" ] = isSupported;
  1509. }
  1510. }
  1511.  
  1512. fragment.removeChild( div );
  1513.  
  1514. // Null elements to avoid leaks in IE
  1515. fragment = select = opt = marginDiv = div = input = null;
  1516.  
  1517. // Run tests that need a body at doc ready
  1518. jQuery(function() {
  1519. var container, outer, inner, table, td, offsetSupport,
  1520. conMarginTop, ptlm, vb, style, html,
  1521. body = document.getElementsByTagName("body")[0];
  1522.  
  1523. if ( !body ) {
  1524. // Return for frameset docs that don't have a body
  1525. return;
  1526. }
  1527.  
  1528. conMarginTop = 1;
  1529. ptlm = "position:absolute;top:0;left:0;width:1px;height:1px;margin:0;";
  1530. vb = "visibility:hidden;border:0;";
  1531. style = "style='" + ptlm + "border:5px solid #000;padding:0;'";
  1532. html = "<div " + style + "><div></div></div>" +
  1533. "<table " + style + " cellpadding='0' cellspacing='0'>" +
  1534. "<tr><td></td></tr></table>";
  1535.  
  1536. container = document.createElement("div");
  1537. container.style.cssText = vb + "width:0;height:0;position:static;top:0;margin-top:" + conMarginTop + "px";
  1538. body.insertBefore( container, body.firstChild );
  1539.  
  1540. // Construct the test element
  1541. div = document.createElement("div");
  1542. container.appendChild( div );
  1543.  
  1544. // Check if table cells still have offsetWidth/Height when they are set
  1545. // to display:none and there are still other visible table cells in a
  1546. // table row; if so, offsetWidth/Height are not reliable for use when
  1547. // determining if an element has been hidden directly using
  1548. // display:none (it is still safe to use offsets if a parent element is
  1549. // hidden; don safety goggles and see bug #4512 for more information).
  1550. // (only IE 8 fails this test)
  1551. div.innerHTML = "<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>";
  1552. tds = div.getElementsByTagName( "td" );
  1553. isSupported = ( tds[ 0 ].offsetHeight === 0 );
  1554.  
  1555. tds[ 0 ].style.display = "";
  1556. tds[ 1 ].style.display = "none";
  1557.  
  1558. // Check if empty table cells still have offsetWidth/Height
  1559. // (IE <= 8 fail this test)
  1560. support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
  1561.  
  1562. // Figure out if the W3C box model works as expected
  1563. div.innerHTML = "";
  1564. div.style.width = div.style.paddingLeft = "1px";
  1565. jQuery.boxModel = support.boxModel = div.offsetWidth === 2;
  1566.  
  1567. if ( typeof div.style.zoom !== "undefined" ) {
  1568. // Check if natively block-level elements act like inline-block
  1569. // elements when setting their display to 'inline' and giving
  1570. // them layout
  1571. // (IE < 8 does this)
  1572. div.style.display = "inline";
  1573. div.style.zoom = 1;
  1574. support.inlineBlockNeedsLayout = ( div.offsetWidth === 2 );
  1575.  
  1576. // Check if elements with layout shrink-wrap their children
  1577. // (IE 6 does this)
  1578. div.style.display = "";
  1579. div.innerHTML = "<div style='width:4px;'></div>";
  1580. support.shrinkWrapBlocks = ( div.offsetWidth !== 2 );
  1581. }
  1582.  
  1583. div.style.cssText = ptlm + vb;
  1584. div.innerHTML = html;
  1585.  
  1586. outer = div.firstChild;
  1587. inner = outer.firstChild;
  1588. td = outer.nextSibling.firstChild.firstChild;
  1589.  
  1590. offsetSupport = {
  1591. doesNotAddBorder: ( inner.offsetTop !== 5 ),
  1592. doesAddBorderForTableAndCells: ( td.offsetTop === 5 )
  1593. };
  1594.  
  1595. inner.style.position = "fixed";
  1596. inner.style.top = "20px";
  1597.  
  1598. // safari subtracts parent border width here which is 5px
  1599. offsetSupport.fixedPosition = ( inner.offsetTop === 20 || inner.offsetTop === 15 );
  1600. inner.style.position = inner.style.top = "";
  1601.  
  1602. outer.style.overflow = "hidden";
  1603. outer.style.position = "relative";
  1604.  
  1605. offsetSupport.subtractsBorderForOverflowNotVisible = ( inner.offsetTop === -5 );
  1606. offsetSupport.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== conMarginTop );
  1607.  
  1608. body.removeChild( container );
  1609. div = container = null;
  1610.  
  1611. jQuery.extend( support, offsetSupport );
  1612. });
  1613.  
  1614. return support;
  1615. })();
  1616.  
  1617.  
  1618.  
  1619.  
  1620. var rbrace = /^(?:\{.*\}|\[.*\])$/,
  1621. rmultiDash = /([A-Z])/g;
  1622.  
  1623. jQuery.extend({
  1624. cache: {},
  1625.  
  1626. // Please use with caution
  1627. uuid: 0,
  1628.  
  1629. // Unique for each copy of jQuery on the page
  1630. // Non-digits removed to match rinlinejQuery
  1631. expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),
  1632.  
  1633. // The following elements throw uncatchable exceptions if you
  1634. // attempt to add expando properties to them.
  1635. noData: {
  1636. "embed": true,
  1637. // Ban all objects except for Flash (which handle expandos)
  1638. "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
  1639. "applet": true
  1640. },
  1641.  
  1642. hasData: function( elem ) {
  1643. elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
  1644. return !!elem && !isEmptyDataObject( elem );
  1645. },
  1646.  
  1647. data: function( elem, name, data, pvt /* Internal Use Only */ ) {
  1648. if ( !jQuery.acceptData( elem ) ) {
  1649. return;
  1650. }
  1651.  
  1652. var privateCache, thisCache, ret,
  1653. internalKey = jQuery.expando,
  1654. getByName = typeof name === "string",
  1655.  
  1656. // We have to handle DOM nodes and JS objects differently because IE6-7
  1657. // can't GC object references properly across the DOM-JS boundary
  1658. isNode = elem.nodeType,
  1659.  
  1660. // Only DOM nodes need the global jQuery cache; JS object data is
  1661. // attached directly to the object so GC can occur automatically
  1662. cache = isNode ? jQuery.cache : elem,
  1663.  
  1664. // Only defining an ID for JS objects if its cache already exists allows
  1665. // the code to shortcut on the same path as a DOM node with no cache
  1666. id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey,
  1667. isEvents = name === "events";
  1668.  
  1669. // Avoid doing any more work than we need to when trying to get data on an
  1670. // object that has no data at all
  1671. if ( (!id || !cache[id] || (!isEvents && !pvt && !cache[id].data)) && getByName && data === undefined ) {
  1672. return;
  1673. }
  1674.  
  1675. if ( !id ) {
  1676. // Only DOM nodes need a new unique ID for each element since their data
  1677. // ends up in the global cache
  1678. if ( isNode ) {
  1679. elem[ internalKey ] = id = ++jQuery.uuid;
  1680. } else {
  1681. id = internalKey;
  1682. }
  1683. }
  1684.  
  1685. if ( !cache[ id ] ) {
  1686. cache[ id ] = {};
  1687.  
  1688. // Avoids exposing jQuery metadata on plain JS objects when the object
  1689. // is serialized using JSON.stringify
  1690. if ( !isNode ) {
  1691. cache[ id ].toJSON = jQuery.noop;
  1692. }
  1693. }
  1694.  
  1695. // An object can be passed to jQuery.data instead of a key/value pair; this gets
  1696. // shallow copied over onto the existing cache
  1697. if ( typeof name === "object" || typeof name === "function" ) {
  1698. if ( pvt ) {
  1699. cache[ id ] = jQuery.extend( cache[ id ], name );
  1700. } else {
  1701. cache[ id ].data = jQuery.extend( cache[ id ].data, name );
  1702. }
  1703. }
  1704.  
  1705. privateCache = thisCache = cache[ id ];
  1706.  
  1707. // jQuery data() is stored in a separate object inside the object's internal data
  1708. // cache in order to avoid key collisions between internal data and user-defined
  1709. // data.
  1710. if ( !pvt ) {
  1711. if ( !thisCache.data ) {
  1712. thisCache.data = {};
  1713. }
  1714.  
  1715. thisCache = thisCache.data;
  1716. }
  1717.  
  1718. if ( data !== undefined ) {
  1719. thisCache[ jQuery.camelCase( name ) ] = data;
  1720. }
  1721.  
  1722. // Users should not attempt to inspect the internal events object using jQuery.data,
  1723. // it is undocumented and subject to change. But does anyone listen? No.
  1724. if ( isEvents && !thisCache[ name ] ) {
  1725. return privateCache.events;
  1726. }
  1727.  
  1728. // Check for both converted-to-camel and non-converted data property names
  1729. // If a data property was specified
  1730. if ( getByName ) {
  1731.  
  1732. // First Try to find as-is property data
  1733. ret = thisCache[ name ];
  1734.  
  1735. // Test for null|undefined property data
  1736. if ( ret == null ) {
  1737.  
  1738. // Try to find the camelCased property
  1739. ret = thisCache[ jQuery.camelCase( name ) ];
  1740. }
  1741. } else {
  1742. ret = thisCache;
  1743. }
  1744.  
  1745. return ret;
  1746. },
  1747.  
  1748. removeData: function( elem, name, pvt /* Internal Use Only */ ) {
  1749. if ( !jQuery.acceptData( elem ) ) {
  1750. return;
  1751. }
  1752.  
  1753. var thisCache, i, l,
  1754.  
  1755. // Reference to internal data cache key
  1756. internalKey = jQuery.expando,
  1757.  
  1758. isNode = elem.nodeType,
  1759.  
  1760. // See jQuery.data for more information
  1761. cache = isNode ? jQuery.cache : elem,
  1762.  
  1763. // See jQuery.data for more information
  1764. id = isNode ? elem[ internalKey ] : internalKey;
  1765.  
  1766. // If there is already no cache entry for this object, there is no
  1767. // purpose in continuing
  1768. if ( !cache[ id ] ) {
  1769. return;
  1770. }
  1771.  
  1772. if ( name ) {
  1773.  
  1774. thisCache = pvt ? cache[ id ] : cache[ id ].data;
  1775.  
  1776. if ( thisCache ) {
  1777.  
  1778. // Support array or space separated string names for data keys
  1779. if ( !jQuery.isArray( name ) ) {
  1780.  
  1781. // try the string as a key before any manipulation
  1782. if ( name in thisCache ) {
  1783. name = [ name ];
  1784. } else {
  1785.  
  1786. // split the camel cased version by spaces unless a key with the spaces exists
  1787. name = jQuery.camelCase( name );
  1788. if ( name in thisCache ) {
  1789. name = [ name ];
  1790. } else {
  1791. name = name.split( " " );
  1792. }
  1793. }
  1794. }
  1795.  
  1796. for ( i = 0, l = name.length; i < l; i++ ) {
  1797. delete thisCache[ name[i] ];
  1798. }
  1799.  
  1800. // If there is no data left in the cache, we want to continue
  1801. // and let the cache object itself get destroyed
  1802. if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) {
  1803. return;
  1804. }
  1805. }
  1806. }
  1807.  
  1808. // See jQuery.data for more information
  1809. if ( !pvt ) {
  1810. delete cache[ id ].data;
  1811.  
  1812. // Don't destroy the parent cache unless the internal data object
  1813. // had been the only thing left in it
  1814. if ( !isEmptyDataObject(cache[ id ]) ) {
  1815. return;
  1816. }
  1817. }
  1818.  
  1819. // Browsers that fail expando deletion also refuse to delete expandos on
  1820. // the window, but it will allow it on all other JS objects; other browsers
  1821. // don't care
  1822. // Ensure that `cache` is not a window object #10080
  1823. if ( jQuery.support.deleteExpando || !cache.setInterval ) {
  1824. delete cache[ id ];
  1825. } else {
  1826. cache[ id ] = null;
  1827. }
  1828.  
  1829. // We destroyed the cache and need to eliminate the expando on the node to avoid
  1830. // false lookups in the cache for entries that no longer exist
  1831. if ( isNode ) {
  1832. // IE does not allow us to delete expando properties from nodes,
  1833. // nor does it have a removeAttribute function on Document nodes;
  1834. // we must handle all of these cases
  1835. if ( jQuery.support.deleteExpando ) {
  1836. delete elem[ internalKey ];
  1837. } else if ( elem.removeAttribute ) {
  1838. elem.removeAttribute( internalKey );
  1839. } else {
  1840. elem[ internalKey ] = null;
  1841. }
  1842. }
  1843. },
  1844.  
  1845. // For internal use only.
  1846. _data: function( elem, name, data ) {
  1847. return jQuery.data( elem, name, data, true );
  1848. },
  1849.  
  1850. // A method for determining if a DOM node can handle the data expando
  1851. acceptData: function( elem ) {
  1852. if ( elem.nodeName ) {
  1853. var match = jQuery.noData[ elem.nodeName.toLowerCase() ];
  1854.  
  1855. if ( match ) {
  1856. return !(match === true || elem.getAttribute("classid") !== match);
  1857. }
  1858. }
  1859.  
  1860. return true;
  1861. }
  1862. });
  1863.  
  1864. jQuery.fn.extend({
  1865. data: function( key, value ) {
  1866. var parts, attr, name,
  1867. data = null;
  1868.  
  1869. if ( typeof key === "undefined" ) {
  1870. if ( this.length ) {
  1871. data = jQuery.data( this[0] );
  1872.  
  1873. if ( this[0].nodeType === 1 && !jQuery._data( this[0], "parsedAttrs" ) ) {
  1874. attr = this[0].attributes;
  1875. for ( var i = 0, l = attr.length; i < l; i++ ) {
  1876. name = attr[i].name;
  1877.  
  1878. if ( name.indexOf( "data-" ) === 0 ) {
  1879. name = jQuery.camelCase( name.substring(5) );
  1880.  
  1881. dataAttr( this[0], name, data[ name ] );
  1882. }
  1883. }
  1884. jQuery._data( this[0], "parsedAttrs", true );
  1885. }
  1886. }
  1887.  
  1888. return data;
  1889.  
  1890. } else if ( typeof key === "object" ) {
  1891. return this.each(function() {
  1892. jQuery.data( this, key );
  1893. });
  1894. }
  1895.  
  1896. parts = key.split(".");
  1897. parts[1] = parts[1] ? "." + parts[1] : "";
  1898.  
  1899. if ( value === undefined ) {
  1900. data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
  1901.  
  1902. // Try to fetch any internally stored data first
  1903. if ( data === undefined && this.length ) {
  1904. data = jQuery.data( this[0], key );
  1905. data = dataAttr( this[0], key, data );
  1906. }
  1907.  
  1908. return data === undefined && parts[1] ?
  1909. this.data( parts[0] ) :
  1910. data;
  1911.  
  1912. } else {
  1913. return this.each(function() {
  1914. var self = jQuery( this ),
  1915. args = [ parts[0], value ];
  1916.  
  1917. self.triggerHandler( "setData" + parts[1] + "!", args );
  1918. jQuery.data( this, key, value );
  1919. self.triggerHandler( "changeData" + parts[1] + "!", args );
  1920. });
  1921. }
  1922. },
  1923.  
  1924. removeData: function( key ) {
  1925. return this.each(function() {
  1926. jQuery.removeData( this, key );
  1927. });
  1928. }
  1929. });
  1930.  
  1931. function dataAttr( elem, key, data ) {
  1932. // If nothing was found internally, try to fetch any
  1933. // data from the HTML5 data-* attribute
  1934. if ( data === undefined && elem.nodeType === 1 ) {
  1935.  
  1936. var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
  1937.  
  1938. data = elem.getAttribute( name );
  1939.  
  1940. if ( typeof data === "string" ) {
  1941. try {
  1942. data = data === "true" ? true :
  1943. data === "false" ? false :
  1944. data === "null" ? null :
  1945. jQuery.isNumeric( data ) ? parseFloat( data ) :
  1946. rbrace.test( data ) ? jQuery.parseJSON( data ) :
  1947. data;
  1948. } catch( e ) {}
  1949.  
  1950. // Make sure we set the data so it isn't changed later
  1951. jQuery.data( elem, key, data );
  1952.  
  1953. } else {
  1954. data = undefined;
  1955. }
  1956. }
  1957.  
  1958. return data;
  1959. }
  1960.  
  1961. // checks a cache object for emptiness
  1962. function isEmptyDataObject( obj ) {
  1963. for ( var name in obj ) {
  1964.  
  1965. // if the public data object is empty, the private is still empty
  1966. if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
  1967. continue;
  1968. }
  1969. if ( name !== "toJSON" ) {
  1970. return false;
  1971. }
  1972. }
  1973.  
  1974. return true;
  1975. }
  1976.  
  1977.  
  1978.  
  1979.  
  1980. function handleQueueMarkDefer( elem, type, src ) {
  1981. var deferDataKey = type + "defer",
  1982. queueDataKey = type + "queue",
  1983. markDataKey = type + "mark",
  1984. defer = jQuery._data( elem, deferDataKey );
  1985. if ( defer &&
  1986. ( src === "queue" || !jQuery._data(elem, queueDataKey) ) &&
  1987. ( src === "mark" || !jQuery._data(elem, markDataKey) ) ) {
  1988. // Give room for hard-coded callbacks to fire first
  1989. // and eventually mark/queue something else on the element
  1990. setTimeout( function() {
  1991. if ( !jQuery._data( elem, queueDataKey ) &&
  1992. !jQuery._data( elem, markDataKey ) ) {
  1993. jQuery.removeData( elem, deferDataKey, true );
  1994. defer.fire();
  1995. }
  1996. }, 0 );
  1997. }
  1998. }
  1999.  
  2000. jQuery.extend({
  2001.  
  2002. _mark: function( elem, type ) {
  2003. if ( elem ) {
  2004. type = ( type || "fx" ) + "mark";
  2005. jQuery._data( elem, type, (jQuery._data( elem, type ) || 0) + 1 );
  2006. }
  2007. },
  2008.  
  2009. _unmark: function( force, elem, type ) {
  2010. if ( force !== true ) {
  2011. type = elem;
  2012. elem = force;
  2013. force = false;
  2014. }
  2015. if ( elem ) {
  2016. type = type || "fx";
  2017. var key = type + "mark",
  2018. count = force ? 0 : ( (jQuery._data( elem, key ) || 1) - 1 );
  2019. if ( count ) {
  2020. jQuery._data( elem, key, count );
  2021. } else {
  2022. jQuery.removeData( elem, key, true );
  2023. handleQueueMarkDefer( elem, type, "mark" );
  2024. }
  2025. }
  2026. },
  2027.  
  2028. queue: function( elem, type, data ) {
  2029. var q;
  2030. if ( elem ) {
  2031. type = ( type || "fx" ) + "queue";
  2032. q = jQuery._data( elem, type );
  2033.  
  2034. // Speed up dequeue by getting out quickly if this is just a lookup
  2035. if ( data ) {
  2036. if ( !q || jQuery.isArray(data) ) {
  2037. q = jQuery._data( elem, type, jQuery.makeArray(data) );
  2038. } else {
  2039. q.push( data );
  2040. }
  2041. }
  2042. return q || [];
  2043. }
  2044. },
  2045.  
  2046. dequeue: function( elem, type ) {
  2047. type = type || "fx";
  2048.  
  2049. var queue = jQuery.queue( elem, type ),
  2050. fn = queue.shift(),
  2051. hooks = {};
  2052.  
  2053. // If the fx queue is dequeued, always remove the progress sentinel
  2054. if ( fn === "inprogress" ) {
  2055. fn = queue.shift();
  2056. }
  2057.  
  2058. if ( fn ) {
  2059. // Add a progress sentinel to prevent the fx queue from being
  2060. // automatically dequeued
  2061. if ( type === "fx" ) {
  2062. queue.unshift( "inprogress" );
  2063. }
  2064.  
  2065. jQuery._data( elem, type + ".run", hooks );
  2066. fn.call( elem, function() {
  2067. jQuery.dequeue( elem, type );
  2068. }, hooks );
  2069. }
  2070.  
  2071. if ( !queue.length ) {
  2072. jQuery.removeData( elem, type + "queue " + type + ".run", true );
  2073. handleQueueMarkDefer( elem, type, "queue" );
  2074. }
  2075. }
  2076. });
  2077.  
  2078. jQuery.fn.extend({
  2079. queue: function( type, data ) {
  2080. if ( typeof type !== "string" ) {
  2081. data = type;
  2082. type = "fx";
  2083. }
  2084.  
  2085. if ( data === undefined ) {
  2086. return jQuery.queue( this[0], type );
  2087. }
  2088. return this.each(function() {
  2089. var queue = jQuery.queue( this, type, data );
  2090.  
  2091. if ( type === "fx" && queue[0] !== "inprogress" ) {
  2092. jQuery.dequeue( this, type );
  2093. }
  2094. });
  2095. },
  2096. dequeue: function( type ) {
  2097. return this.each(function() {
  2098. jQuery.dequeue( this, type );
  2099. });
  2100. },
  2101. // Based off of the plugin by Clint Helfers, with permission.
  2102. // http://blindsignals.com/index.php/2009/07/jquery-delay/
  2103. delay: function( time, type ) {
  2104. time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
  2105. type = type || "fx";
  2106.  
  2107. return this.queue( type, function( next, hooks ) {
  2108. var timeout = setTimeout( next, time );
  2109. hooks.stop = function() {
  2110. clearTimeout( timeout );
  2111. };
  2112. });
  2113. },
  2114. clearQueue: function( type ) {
  2115. return this.queue( type || "fx", [] );
  2116. },
  2117. // Get a promise resolved when queues of a certain type
  2118. // are emptied (fx is the type by default)
  2119. promise: function( type, object ) {
  2120. if ( typeof type !== "string" ) {
  2121. object = type;
  2122. type = undefined;
  2123. }
  2124. type = type || "fx";
  2125. var defer = jQuery.Deferred(),
  2126. elements = this,
  2127. i = elements.length,
  2128. count = 1,
  2129. deferDataKey = type + "defer",
  2130. queueDataKey = type + "queue",
  2131. markDataKey = type + "mark",
  2132. tmp;
  2133. function resolve() {
  2134. if ( !( --count ) ) {
  2135. defer.resolveWith( elements, [ elements ] );
  2136. }
  2137. }
  2138. while( i-- ) {
  2139. if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) ||
  2140. ( jQuery.data( elements[ i ], queueDataKey, undefined, true ) ||
  2141. jQuery.data( elements[ i ], markDataKey, undefined, true ) ) &&
  2142. jQuery.data( elements[ i ], deferDataKey, jQuery.Callbacks( "once memory" ), true ) )) {
  2143. count++;
  2144. tmp.add( resolve );
  2145. }
  2146. }
  2147. resolve();
  2148. return defer.promise();
  2149. }
  2150. });
  2151.  
  2152.  
  2153.  
  2154.  
  2155. var rclass = /[\n\t\r]/g,
  2156. rspace = /\s+/,
  2157. rreturn = /\r/g,
  2158. rtype = /^(?:button|input)$/i,
  2159. rfocusable = /^(?:button|input|object|select|textarea)$/i,
  2160. rclickable = /^a(?:rea)?$/i,
  2161. rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
  2162. getSetAttribute = jQuery.support.getSetAttribute,
  2163. nodeHook, boolHook, fixSpecified;
  2164.  
  2165. jQuery.fn.extend({
  2166. attr: function( name, value ) {
  2167. return jQuery.access( this, name, value, true, jQuery.attr );
  2168. },
  2169.  
  2170. removeAttr: function( name ) {
  2171. return this.each(function() {
  2172. jQuery.removeAttr( this, name );
  2173. });
  2174. },
  2175.  
  2176. prop: function( name, value ) {
  2177. return jQuery.access( this, name, value, true, jQuery.prop );
  2178. },
  2179.  
  2180. removeProp: function( name ) {
  2181. name = jQuery.propFix[ name ] || name;
  2182. return this.each(function() {
  2183. // try/catch handles cases where IE balks (such as removing a property on window)
  2184. try {
  2185. this[ name ] = undefined;
  2186. delete this[ name ];
  2187. } catch( e ) {}
  2188. });
  2189. },
  2190.  
  2191. addClass: function( value ) {
  2192. var classNames, i, l, elem,
  2193. setClass, c, cl;
  2194.  
  2195. if ( jQuery.isFunction( value ) ) {
  2196. return this.each(function( j ) {
  2197. jQuery( this ).addClass( value.call(this, j, this.className) );
  2198. });
  2199. }
  2200.  
  2201. if ( value && typeof value === "string" ) {
  2202. classNames = value.split( rspace );
  2203.  
  2204. for ( i = 0, l = this.length; i < l; i++ ) {
  2205. elem = this[ i ];
  2206.  
  2207. if ( elem.nodeType === 1 ) {
  2208. if ( !elem.className && classNames.length === 1 ) {
  2209. elem.className = value;
  2210.  
  2211. } else {
  2212. setClass = " " + elem.className + " ";
  2213.  
  2214. for ( c = 0, cl = classNames.length; c < cl; c++ ) {
  2215. if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) {
  2216. setClass += classNames[ c ] + " ";
  2217. }
  2218. }
  2219. elem.className = jQuery.trim( setClass );
  2220. }
  2221. }
  2222. }
  2223. }
  2224.  
  2225. return this;
  2226. },
  2227.  
  2228. removeClass: function( value ) {
  2229. var classNames, i, l, elem, className, c, cl;
  2230.  
  2231. if ( jQuery.isFunction( value ) ) {
  2232. return this.each(function( j ) {
  2233. jQuery( this ).removeClass( value.call(this, j, this.className) );
  2234. });
  2235. }
  2236.  
  2237. if ( (value && typeof value === "string") || value === undefined ) {
  2238. classNames = ( value || "" ).split( rspace );
  2239.  
  2240. for ( i = 0, l = this.length; i < l; i++ ) {
  2241. elem = this[ i ];
  2242.  
  2243. if ( elem.nodeType === 1 && elem.className ) {
  2244. if ( value ) {
  2245. className = (" " + elem.className + " ").replace( rclass, " " );
  2246. for ( c = 0, cl = classNames.length; c < cl; c++ ) {
  2247. className = className.replace(" " + classNames[ c ] + " ", " ");
  2248. }
  2249. elem.className = jQuery.trim( className );
  2250.  
  2251. } else {
  2252. elem.className = "";
  2253. }
  2254. }
  2255. }
  2256. }
  2257.  
  2258. return this;
  2259. },
  2260.  
  2261. toggleClass: function( value, stateVal ) {
  2262. var type = typeof value,
  2263. isBool = typeof stateVal === "boolean";
  2264.  
  2265. if ( jQuery.isFunction( value ) ) {
  2266. return this.each(function( i ) {
  2267. jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
  2268. });
  2269. }
  2270.  
  2271. return this.each(function() {
  2272. if ( type === "string" ) {
  2273. // toggle individual class names
  2274. var className,
  2275. i = 0,
  2276. self = jQuery( this ),
  2277. state = stateVal,
  2278. classNames = value.split( rspace );
  2279.  
  2280. while ( (className = classNames[ i++ ]) ) {
  2281. // check each className given, space seperated list
  2282. state = isBool ? state : !self.hasClass( className );
  2283. self[ state ? "addClass" : "removeClass" ]( className );
  2284. }
  2285.  
  2286. } else if ( type === "undefined" || type === "boolean" ) {
  2287. if ( this.className ) {
  2288. // store className if set
  2289. jQuery._data( this, "__className__", this.className );
  2290. }
  2291.  
  2292. // toggle whole className
  2293. this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
  2294. }
  2295. });
  2296. },
  2297.  
  2298. hasClass: function( selector ) {
  2299. var className = " " + selector + " ",
  2300. i = 0,
  2301. l = this.length;
  2302. for ( ; i < l; i++ ) {
  2303. if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
  2304. return true;
  2305. }
  2306. }
  2307.  
  2308. return false;
  2309. },
  2310.  
  2311. val: function( value ) {
  2312. var hooks, ret, isFunction,
  2313. elem = this[0];
  2314.  
  2315. if ( !arguments.length ) {
  2316. if ( elem ) {
  2317. hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ];
  2318.  
  2319. if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
  2320. return ret;
  2321. }
  2322.  
  2323. ret = elem.value;
  2324.  
  2325. return typeof ret === "string" ?
  2326. // handle most common string cases
  2327. ret.replace(rreturn, "") :
  2328. // handle cases where value is null/undef or number
  2329. ret == null ? "" : ret;
  2330. }
  2331.  
  2332. return;
  2333. }
  2334.  
  2335. isFunction = jQuery.isFunction( value );
  2336.  
  2337. return this.each(function( i ) {
  2338. var self = jQuery(this), val;
  2339.  
  2340. if ( this.nodeType !== 1 ) {
  2341. return;
  2342. }
  2343.  
  2344. if ( isFunction ) {
  2345. val = value.call( this, i, self.val() );
  2346. } else {
  2347. val = value;
  2348. }
  2349.  
  2350. // Treat null/undefined as ""; convert numbers to string
  2351. if ( val == null ) {
  2352. val = "";
  2353. } else if ( typeof val === "number" ) {
  2354. val += "";
  2355. } else if ( jQuery.isArray( val ) ) {
  2356. val = jQuery.map(val, function ( value ) {
  2357. return value == null ? "" : value + "";
  2358. });
  2359. }
  2360.  
  2361. hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ];
  2362.  
  2363. // If set returns undefined, fall back to normal setting
  2364. if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
  2365. this.value = val;
  2366. }
  2367. });
  2368. }
  2369. });
  2370.  
  2371. jQuery.extend({
  2372. valHooks: {
  2373. option: {
  2374. get: function( elem ) {
  2375. // attributes.value is undefined in Blackberry 4.7 but
  2376. // uses .value. See #6932
  2377. var val = elem.attributes.value;
  2378. return !val || val.specified ? elem.value : elem.text;
  2379. }
  2380. },
  2381. select: {
  2382. get: function( elem ) {
  2383. var value, i, max, option,
  2384. index = elem.selectedIndex,
  2385. values = [],
  2386. options = elem.options,
  2387. one = elem.type === "select-one";
  2388.  
  2389. // Nothing was selected
  2390. if ( index < 0 ) {
  2391. return null;
  2392. }
  2393.  
  2394. // Loop through all the selected options
  2395. i = one ? index : 0;
  2396. max = one ? index + 1 : options.length;
  2397. for ( ; i < max; i++ ) {
  2398. option = options[ i ];
  2399.  
  2400. // Don't return options that are disabled or in a disabled optgroup
  2401. if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
  2402. (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
  2403.  
  2404. // Get the specific value for the option
  2405. value = jQuery( option ).val();
  2406.  
  2407. // We don't need an array for one selects
  2408. if ( one ) {
  2409. return value;
  2410. }
  2411.  
  2412. // Multi-Selects return an array
  2413. values.push( value );
  2414. }
  2415. }
  2416.  
  2417. // Fixes Bug #2551 -- select.val() broken in IE after form.reset()
  2418. if ( one && !values.length && options.length ) {
  2419. return jQuery( options[ index ] ).val();
  2420. }
  2421.  
  2422. return values;
  2423. },
  2424.  
  2425. set: function( elem, value ) {
  2426. var values = jQuery.makeArray( value );
  2427.  
  2428. jQuery(elem).find("option").each(function() {
  2429. this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
  2430. });
  2431.  
  2432. if ( !values.length ) {
  2433. elem.selectedIndex = -1;
  2434. }
  2435. return values;
  2436. }
  2437. }
  2438. },
  2439.  
  2440. attrFn: {
  2441. val: true,
  2442. css: true,
  2443. html: true,
  2444. text: true,
  2445. data: true,
  2446. width: true,
  2447. height: true,
  2448. offset: true
  2449. },
  2450.  
  2451. attr: function( elem, name, value, pass ) {
  2452. var ret, hooks, notxml,
  2453. nType = elem.nodeType;
  2454.  
  2455. // don't get/set attributes on text, comment and attribute nodes
  2456. if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
  2457. return;
  2458. }
  2459.  
  2460. if ( pass && name in jQuery.attrFn ) {
  2461. return jQuery( elem )[ name ]( value );
  2462. }
  2463.  
  2464. // Fallback to prop when attributes are not supported
  2465. if ( typeof elem.getAttribute === "undefined" ) {
  2466. return jQuery.prop( elem, name, value );
  2467. }
  2468.  
  2469. notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
  2470.  
  2471. // All attributes are lowercase
  2472. // Grab necessary hook if one is defined
  2473. if ( notxml ) {
  2474. name = name.toLowerCase();
  2475. hooks = jQuery.attrHoo

Report this snippet  

You need to login to post a comment.