PageRenderTime 76ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 2ms

/trunk/js/jQuery/jquery.js

#
JavaScript | 9301 lines | 7267 code | 1055 blank | 979 comment | 1354 complexity | 2cfa63d5c43e8478be2cfe7ff7e54638 MD5 | raw file
Possible License(s): GPL-2.0

Large files files are truncated, but you can click here to view the full file

  1. /*!
  2. * jQuery JavaScript Library v1.8.1
  3. * http://jquery.com/
  4. *
  5. * Includes Sizzle.js
  6. * http://sizzlejs.com/
  7. *
  8. * Copyright 2012 jQuery Foundation and other contributors
  9. * Released under the MIT license
  10. * http://jquery.org/license
  11. *
  12. * Date: Thu Aug 30 2012 17:17:22 GMT-0400 (Eastern Daylight Time)
  13. */
  14. (function( window, undefined ) {
  15. var
  16. // A central reference to the root jQuery(document)
  17. rootjQuery,
  18. // The deferred used on DOM ready
  19. readyList,
  20. // Use the correct document accordingly with window argument (sandbox)
  21. document = window.document,
  22. location = window.location,
  23. navigator = window.navigator,
  24. // Map over jQuery in case of overwrite
  25. _jQuery = window.jQuery,
  26. // Map over the $ in case of overwrite
  27. _$ = window.$,
  28. // Save a reference to some core methods
  29. core_push = Array.prototype.push,
  30. core_slice = Array.prototype.slice,
  31. core_indexOf = Array.prototype.indexOf,
  32. core_toString = Object.prototype.toString,
  33. core_hasOwn = Object.prototype.hasOwnProperty,
  34. core_trim = String.prototype.trim,
  35. // Define a local copy of jQuery
  36. jQuery = function( selector, context ) {
  37. // The jQuery object is actually just the init constructor 'enhanced'
  38. return new jQuery.fn.init( selector, context, rootjQuery );
  39. },
  40. // Used for matching numbers
  41. core_pnum = /[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source,
  42. // Used for detecting and trimming whitespace
  43. core_rnotwhite = /\S/,
  44. core_rspace = /\s+/,
  45. // Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE)
  46. rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
  47. // A simple way to check for HTML strings
  48. // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
  49. rquickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
  50. // Match a standalone tag
  51. rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/,
  52. // JSON RegExp
  53. rvalidchars = /^[\],:{}\s]*$/,
  54. rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
  55. rvalidescape = /\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,
  56. rvalidtokens = /"[^"\\\r\n]*"|true|false|null|-?(?:\d\d*\.|)\d+(?:[eE][\-+]?\d+|)/g,
  57. // Matches dashed string for camelizing
  58. rmsPrefix = /^-ms-/,
  59. rdashAlpha = /-([\da-z])/gi,
  60. // Used by jQuery.camelCase as callback to replace()
  61. fcamelCase = function( all, letter ) {
  62. return ( letter + "" ).toUpperCase();
  63. },
  64. // The ready event handler and self cleanup method
  65. DOMContentLoaded = function() {
  66. if ( document.addEventListener ) {
  67. document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
  68. jQuery.ready();
  69. } else if ( document.readyState === "complete" ) {
  70. // we're here because readyState === "complete" in oldIE
  71. // which is good enough for us to call the dom ready!
  72. document.detachEvent( "onreadystatechange", DOMContentLoaded );
  73. jQuery.ready();
  74. }
  75. },
  76. // [[Class]] -> type pairs
  77. class2type = {};
  78. jQuery.fn = jQuery.prototype = {
  79. constructor: jQuery,
  80. init: function( selector, context, rootjQuery ) {
  81. var match, elem, ret, doc;
  82. // Handle $(""), $(null), $(undefined), $(false)
  83. if ( !selector ) {
  84. return this;
  85. }
  86. // Handle $(DOMElement)
  87. if ( selector.nodeType ) {
  88. this.context = this[0] = selector;
  89. this.length = 1;
  90. return this;
  91. }
  92. // Handle HTML strings
  93. if ( typeof selector === "string" ) {
  94. if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
  95. // Assume that strings that start and end with <> are HTML and skip the regex check
  96. match = [ null, selector, null ];
  97. } else {
  98. match = rquickExpr.exec( selector );
  99. }
  100. // Match html or make sure no context is specified for #id
  101. if ( match && (match[1] || !context) ) {
  102. // HANDLE: $(html) -> $(array)
  103. if ( match[1] ) {
  104. context = context instanceof jQuery ? context[0] : context;
  105. doc = ( context && context.nodeType ? context.ownerDocument || context : document );
  106. // scripts is true for back-compat
  107. selector = jQuery.parseHTML( match[1], doc, true );
  108. if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
  109. this.attr.call( selector, context, true );
  110. }
  111. return jQuery.merge( this, selector );
  112. // HANDLE: $(#id)
  113. } else {
  114. elem = document.getElementById( match[2] );
  115. // Check parentNode to catch when Blackberry 4.6 returns
  116. // nodes that are no longer in the document #6963
  117. if ( elem && elem.parentNode ) {
  118. // Handle the case where IE and Opera return items
  119. // by name instead of ID
  120. if ( elem.id !== match[2] ) {
  121. return rootjQuery.find( selector );
  122. }
  123. // Otherwise, we inject the element directly into the jQuery object
  124. this.length = 1;
  125. this[0] = elem;
  126. }
  127. this.context = document;
  128. this.selector = selector;
  129. return this;
  130. }
  131. // HANDLE: $(expr, $(...))
  132. } else if ( !context || context.jquery ) {
  133. return ( context || rootjQuery ).find( selector );
  134. // HANDLE: $(expr, context)
  135. // (which is just equivalent to: $(context).find(expr)
  136. } else {
  137. return this.constructor( context ).find( selector );
  138. }
  139. // HANDLE: $(function)
  140. // Shortcut for document ready
  141. } else if ( jQuery.isFunction( selector ) ) {
  142. return rootjQuery.ready( selector );
  143. }
  144. if ( selector.selector !== undefined ) {
  145. this.selector = selector.selector;
  146. this.context = selector.context;
  147. }
  148. return jQuery.makeArray( selector, this );
  149. },
  150. // Start with an empty selector
  151. selector: "",
  152. // The current version of jQuery being used
  153. jquery: "1.8.1",
  154. // The default length of a jQuery object is 0
  155. length: 0,
  156. // The number of elements contained in the matched element set
  157. size: function() {
  158. return this.length;
  159. },
  160. toArray: function() {
  161. return core_slice.call( this );
  162. },
  163. // Get the Nth element in the matched element set OR
  164. // Get the whole matched element set as a clean array
  165. get: function( num ) {
  166. return num == null ?
  167. // Return a 'clean' array
  168. this.toArray() :
  169. // Return just the object
  170. ( num < 0 ? this[ this.length + num ] : this[ num ] );
  171. },
  172. // Take an array of elements and push it onto the stack
  173. // (returning the new matched element set)
  174. pushStack: function( elems, name, selector ) {
  175. // Build a new jQuery matched element set
  176. var ret = jQuery.merge( this.constructor(), elems );
  177. // Add the old object onto the stack (as a reference)
  178. ret.prevObject = this;
  179. ret.context = this.context;
  180. if ( name === "find" ) {
  181. ret.selector = this.selector + ( this.selector ? " " : "" ) + selector;
  182. } else if ( name ) {
  183. ret.selector = this.selector + "." + name + "(" + selector + ")";
  184. }
  185. // Return the newly-formed element set
  186. return ret;
  187. },
  188. // Execute a callback for every element in the matched set.
  189. // (You can seed the arguments with an array of args, but this is
  190. // only used internally.)
  191. each: function( callback, args ) {
  192. return jQuery.each( this, callback, args );
  193. },
  194. ready: function( fn ) {
  195. // Add the callback
  196. jQuery.ready.promise().done( fn );
  197. return this;
  198. },
  199. eq: function( i ) {
  200. i = +i;
  201. return i === -1 ?
  202. this.slice( i ) :
  203. this.slice( i, i + 1 );
  204. },
  205. first: function() {
  206. return this.eq( 0 );
  207. },
  208. last: function() {
  209. return this.eq( -1 );
  210. },
  211. slice: function() {
  212. return this.pushStack( core_slice.apply( this, arguments ),
  213. "slice", core_slice.call(arguments).join(",") );
  214. },
  215. map: function( callback ) {
  216. return this.pushStack( jQuery.map(this, function( elem, i ) {
  217. return callback.call( elem, i, elem );
  218. }));
  219. },
  220. end: function() {
  221. return this.prevObject || this.constructor(null);
  222. },
  223. // For internal use only.
  224. // Behaves like an Array's method, not like a jQuery method.
  225. push: core_push,
  226. sort: [].sort,
  227. splice: [].splice
  228. };
  229. // Give the init function the jQuery prototype for later instantiation
  230. jQuery.fn.init.prototype = jQuery.fn;
  231. jQuery.extend = jQuery.fn.extend = function() {
  232. var options, name, src, copy, copyIsArray, clone,
  233. target = arguments[0] || {},
  234. i = 1,
  235. length = arguments.length,
  236. deep = false;
  237. // Handle a deep copy situation
  238. if ( typeof target === "boolean" ) {
  239. deep = target;
  240. target = arguments[1] || {};
  241. // skip the boolean and the target
  242. i = 2;
  243. }
  244. // Handle case when target is a string or something (possible in deep copy)
  245. if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
  246. target = {};
  247. }
  248. // extend jQuery itself if only one argument is passed
  249. if ( length === i ) {
  250. target = this;
  251. --i;
  252. }
  253. for ( ; i < length; i++ ) {
  254. // Only deal with non-null/undefined values
  255. if ( (options = arguments[ i ]) != null ) {
  256. // Extend the base object
  257. for ( name in options ) {
  258. src = target[ name ];
  259. copy = options[ name ];
  260. // Prevent never-ending loop
  261. if ( target === copy ) {
  262. continue;
  263. }
  264. // Recurse if we're merging plain objects or arrays
  265. if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
  266. if ( copyIsArray ) {
  267. copyIsArray = false;
  268. clone = src && jQuery.isArray(src) ? src : [];
  269. } else {
  270. clone = src && jQuery.isPlainObject(src) ? src : {};
  271. }
  272. // Never move original objects, clone them
  273. target[ name ] = jQuery.extend( deep, clone, copy );
  274. // Don't bring in undefined values
  275. } else if ( copy !== undefined ) {
  276. target[ name ] = copy;
  277. }
  278. }
  279. }
  280. }
  281. // Return the modified object
  282. return target;
  283. };
  284. jQuery.extend({
  285. noConflict: function( deep ) {
  286. if ( window.$ === jQuery ) {
  287. window.$ = _$;
  288. }
  289. if ( deep && window.jQuery === jQuery ) {
  290. window.jQuery = _jQuery;
  291. }
  292. return jQuery;
  293. },
  294. // Is the DOM ready to be used? Set to true once it occurs.
  295. isReady: false,
  296. // A counter to track how many items to wait for before
  297. // the ready event fires. See #6781
  298. readyWait: 1,
  299. // Hold (or release) the ready event
  300. holdReady: function( hold ) {
  301. if ( hold ) {
  302. jQuery.readyWait++;
  303. } else {
  304. jQuery.ready( true );
  305. }
  306. },
  307. // Handle when the DOM is ready
  308. ready: function( wait ) {
  309. // Abort if there are pending holds or we're already ready
  310. if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
  311. return;
  312. }
  313. // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
  314. if ( !document.body ) {
  315. return setTimeout( jQuery.ready, 1 );
  316. }
  317. // Remember that the DOM is ready
  318. jQuery.isReady = true;
  319. // If a normal DOM Ready event fired, decrement, and wait if need be
  320. if ( wait !== true && --jQuery.readyWait > 0 ) {
  321. return;
  322. }
  323. // If there are functions bound, to execute
  324. readyList.resolveWith( document, [ jQuery ] );
  325. // Trigger any bound ready events
  326. if ( jQuery.fn.trigger ) {
  327. jQuery( document ).trigger("ready").off("ready");
  328. }
  329. },
  330. // See test/unit/core.js for details concerning isFunction.
  331. // Since version 1.3, DOM methods and functions like alert
  332. // aren't supported. They return false on IE (#2968).
  333. isFunction: function( obj ) {
  334. return jQuery.type(obj) === "function";
  335. },
  336. isArray: Array.isArray || function( obj ) {
  337. return jQuery.type(obj) === "array";
  338. },
  339. isWindow: function( obj ) {
  340. return obj != null && obj == obj.window;
  341. },
  342. isNumeric: function( obj ) {
  343. return !isNaN( parseFloat(obj) ) && isFinite( obj );
  344. },
  345. type: function( obj ) {
  346. return obj == null ?
  347. String( obj ) :
  348. class2type[ core_toString.call(obj) ] || "object";
  349. },
  350. isPlainObject: function( obj ) {
  351. // Must be an Object.
  352. // Because of IE, we also have to check the presence of the constructor property.
  353. // Make sure that DOM nodes and window objects don't pass through, as well
  354. if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
  355. return false;
  356. }
  357. try {
  358. // Not own constructor property must be Object
  359. if ( obj.constructor &&
  360. !core_hasOwn.call(obj, "constructor") &&
  361. !core_hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
  362. return false;
  363. }
  364. } catch ( e ) {
  365. // IE8,9 Will throw exceptions on certain host objects #9897
  366. return false;
  367. }
  368. // Own properties are enumerated firstly, so to speed up,
  369. // if last one is own, then all properties are own.
  370. var key;
  371. for ( key in obj ) {}
  372. return key === undefined || core_hasOwn.call( obj, key );
  373. },
  374. isEmptyObject: function( obj ) {
  375. var name;
  376. for ( name in obj ) {
  377. return false;
  378. }
  379. return true;
  380. },
  381. error: function( msg ) {
  382. throw new Error( msg );
  383. },
  384. // data: string of html
  385. // context (optional): If specified, the fragment will be created in this context, defaults to document
  386. // scripts (optional): If true, will include scripts passed in the html string
  387. parseHTML: function( data, context, scripts ) {
  388. var parsed;
  389. if ( !data || typeof data !== "string" ) {
  390. return null;
  391. }
  392. if ( typeof context === "boolean" ) {
  393. scripts = context;
  394. context = 0;
  395. }
  396. context = context || document;
  397. // Single tag
  398. if ( (parsed = rsingleTag.exec( data )) ) {
  399. return [ context.createElement( parsed[1] ) ];
  400. }
  401. parsed = jQuery.buildFragment( [ data ], context, scripts ? null : [] );
  402. return jQuery.merge( [],
  403. (parsed.cacheable ? jQuery.clone( parsed.fragment ) : parsed.fragment).childNodes );
  404. },
  405. parseJSON: function( data ) {
  406. if ( !data || typeof data !== "string") {
  407. return null;
  408. }
  409. // Make sure leading/trailing whitespace is removed (IE can't handle it)
  410. data = jQuery.trim( data );
  411. // Attempt to parse using the native JSON parser first
  412. if ( window.JSON && window.JSON.parse ) {
  413. return window.JSON.parse( data );
  414. }
  415. // Make sure the incoming data is actual JSON
  416. // Logic borrowed from http://json.org/json2.js
  417. if ( rvalidchars.test( data.replace( rvalidescape, "@" )
  418. .replace( rvalidtokens, "]" )
  419. .replace( rvalidbraces, "")) ) {
  420. return ( new Function( "return " + data ) )();
  421. }
  422. jQuery.error( "Invalid JSON: " + data );
  423. },
  424. // Cross-browser xml parsing
  425. parseXML: function( data ) {
  426. var xml, tmp;
  427. if ( !data || typeof data !== "string" ) {
  428. return null;
  429. }
  430. try {
  431. if ( window.DOMParser ) { // Standard
  432. tmp = new DOMParser();
  433. xml = tmp.parseFromString( data , "text/xml" );
  434. } else { // IE
  435. xml = new ActiveXObject( "Microsoft.XMLDOM" );
  436. xml.async = "false";
  437. xml.loadXML( data );
  438. }
  439. } catch( e ) {
  440. xml = undefined;
  441. }
  442. if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
  443. jQuery.error( "Invalid XML: " + data );
  444. }
  445. return xml;
  446. },
  447. noop: function() {},
  448. // Evaluates a script in a global context
  449. // Workarounds based on findings by Jim Driscoll
  450. // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
  451. globalEval: function( data ) {
  452. if ( data && core_rnotwhite.test( data ) ) {
  453. // We use execScript on Internet Explorer
  454. // We use an anonymous function so that context is window
  455. // rather than jQuery in Firefox
  456. ( window.execScript || function( data ) {
  457. window[ "eval" ].call( window, data );
  458. } )( data );
  459. }
  460. },
  461. // Convert dashed to camelCase; used by the css and data modules
  462. // Microsoft forgot to hump their vendor prefix (#9572)
  463. camelCase: function( string ) {
  464. return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
  465. },
  466. nodeName: function( elem, name ) {
  467. return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
  468. },
  469. // args is for internal usage only
  470. each: function( obj, callback, args ) {
  471. var name,
  472. i = 0,
  473. length = obj.length,
  474. isObj = length === undefined || jQuery.isFunction( obj );
  475. if ( args ) {
  476. if ( isObj ) {
  477. for ( name in obj ) {
  478. if ( callback.apply( obj[ name ], args ) === false ) {
  479. break;
  480. }
  481. }
  482. } else {
  483. for ( ; i < length; ) {
  484. if ( callback.apply( obj[ i++ ], args ) === false ) {
  485. break;
  486. }
  487. }
  488. }
  489. // A special, fast, case for the most common use of each
  490. } else {
  491. if ( isObj ) {
  492. for ( name in obj ) {
  493. if ( callback.call( obj[ name ], name, obj[ name ] ) === false ) {
  494. break;
  495. }
  496. }
  497. } else {
  498. for ( ; i < length; ) {
  499. if ( callback.call( obj[ i ], i, obj[ i++ ] ) === false ) {
  500. break;
  501. }
  502. }
  503. }
  504. }
  505. return obj;
  506. },
  507. // Use native String.trim function wherever possible
  508. trim: core_trim && !core_trim.call("\uFEFF\xA0") ?
  509. function( text ) {
  510. return text == null ?
  511. "" :
  512. core_trim.call( text );
  513. } :
  514. // Otherwise use our own trimming functionality
  515. function( text ) {
  516. return text == null ?
  517. "" :
  518. text.toString().replace( rtrim, "" );
  519. },
  520. // results is for internal usage only
  521. makeArray: function( arr, results ) {
  522. var type,
  523. ret = results || [];
  524. if ( arr != null ) {
  525. // The window, strings (and functions) also have 'length'
  526. // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
  527. type = jQuery.type( arr );
  528. if ( arr.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( arr ) ) {
  529. core_push.call( ret, arr );
  530. } else {
  531. jQuery.merge( ret, arr );
  532. }
  533. }
  534. return ret;
  535. },
  536. inArray: function( elem, arr, i ) {
  537. var len;
  538. if ( arr ) {
  539. if ( core_indexOf ) {
  540. return core_indexOf.call( arr, elem, i );
  541. }
  542. len = arr.length;
  543. i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
  544. for ( ; i < len; i++ ) {
  545. // Skip accessing in sparse arrays
  546. if ( i in arr && arr[ i ] === elem ) {
  547. return i;
  548. }
  549. }
  550. }
  551. return -1;
  552. },
  553. merge: function( first, second ) {
  554. var l = second.length,
  555. i = first.length,
  556. j = 0;
  557. if ( typeof l === "number" ) {
  558. for ( ; j < l; j++ ) {
  559. first[ i++ ] = second[ j ];
  560. }
  561. } else {
  562. while ( second[j] !== undefined ) {
  563. first[ i++ ] = second[ j++ ];
  564. }
  565. }
  566. first.length = i;
  567. return first;
  568. },
  569. grep: function( elems, callback, inv ) {
  570. var retVal,
  571. ret = [],
  572. i = 0,
  573. length = elems.length;
  574. inv = !!inv;
  575. // Go through the array, only saving the items
  576. // that pass the validator function
  577. for ( ; i < length; i++ ) {
  578. retVal = !!callback( elems[ i ], i );
  579. if ( inv !== retVal ) {
  580. ret.push( elems[ i ] );
  581. }
  582. }
  583. return ret;
  584. },
  585. // arg is for internal usage only
  586. map: function( elems, callback, arg ) {
  587. var value, key,
  588. ret = [],
  589. i = 0,
  590. length = elems.length,
  591. // jquery objects are treated as arrays
  592. isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ;
  593. // Go through the array, translating each of the items to their
  594. if ( isArray ) {
  595. for ( ; i < length; i++ ) {
  596. value = callback( elems[ i ], i, arg );
  597. if ( value != null ) {
  598. ret[ ret.length ] = value;
  599. }
  600. }
  601. // Go through every key on the object,
  602. } else {
  603. for ( key in elems ) {
  604. value = callback( elems[ key ], key, arg );
  605. if ( value != null ) {
  606. ret[ ret.length ] = value;
  607. }
  608. }
  609. }
  610. // Flatten any nested arrays
  611. return ret.concat.apply( [], ret );
  612. },
  613. // A global GUID counter for objects
  614. guid: 1,
  615. // Bind a function to a context, optionally partially applying any
  616. // arguments.
  617. proxy: function( fn, context ) {
  618. var tmp, args, proxy;
  619. if ( typeof context === "string" ) {
  620. tmp = fn[ context ];
  621. context = fn;
  622. fn = tmp;
  623. }
  624. // Quick check to determine if target is callable, in the spec
  625. // this throws a TypeError, but we will just return undefined.
  626. if ( !jQuery.isFunction( fn ) ) {
  627. return undefined;
  628. }
  629. // Simulated bind
  630. args = core_slice.call( arguments, 2 );
  631. proxy = function() {
  632. return fn.apply( context, args.concat( core_slice.call( arguments ) ) );
  633. };
  634. // Set the guid of unique handler to the same of original handler, so it can be removed
  635. proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
  636. return proxy;
  637. },
  638. // Multifunctional method to get and set values of a collection
  639. // The value/s can optionally be executed if it's a function
  640. access: function( elems, fn, key, value, chainable, emptyGet, pass ) {
  641. var exec,
  642. bulk = key == null,
  643. i = 0,
  644. length = elems.length;
  645. // Sets many values
  646. if ( key && typeof key === "object" ) {
  647. for ( i in key ) {
  648. jQuery.access( elems, fn, i, key[i], 1, emptyGet, value );
  649. }
  650. chainable = 1;
  651. // Sets one value
  652. } else if ( value !== undefined ) {
  653. // Optionally, function values get executed if exec is true
  654. exec = pass === undefined && jQuery.isFunction( value );
  655. if ( bulk ) {
  656. // Bulk operations only iterate when executing function values
  657. if ( exec ) {
  658. exec = fn;
  659. fn = function( elem, key, value ) {
  660. return exec.call( jQuery( elem ), value );
  661. };
  662. // Otherwise they run against the entire set
  663. } else {
  664. fn.call( elems, value );
  665. fn = null;
  666. }
  667. }
  668. if ( fn ) {
  669. for (; i < length; i++ ) {
  670. fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
  671. }
  672. }
  673. chainable = 1;
  674. }
  675. return chainable ?
  676. elems :
  677. // Gets
  678. bulk ?
  679. fn.call( elems ) :
  680. length ? fn( elems[0], key ) : emptyGet;
  681. },
  682. now: function() {
  683. return ( new Date() ).getTime();
  684. }
  685. });
  686. jQuery.ready.promise = function( obj ) {
  687. if ( !readyList ) {
  688. readyList = jQuery.Deferred();
  689. // Catch cases where $(document).ready() is called after the browser event has already occurred.
  690. // we once tried to use readyState "interactive" here, but it caused issues like the one
  691. // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
  692. if ( document.readyState === "complete" ) {
  693. // Handle it asynchronously to allow scripts the opportunity to delay ready
  694. setTimeout( jQuery.ready, 1 );
  695. // Standards-based browsers support DOMContentLoaded
  696. } else if ( document.addEventListener ) {
  697. // Use the handy event callback
  698. document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
  699. // A fallback to window.onload, that will always work
  700. window.addEventListener( "load", jQuery.ready, false );
  701. // If IE event model is used
  702. } else {
  703. // Ensure firing before onload, maybe late but safe also for iframes
  704. document.attachEvent( "onreadystatechange", DOMContentLoaded );
  705. // A fallback to window.onload, that will always work
  706. window.attachEvent( "onload", jQuery.ready );
  707. // If IE and not a frame
  708. // continually check to see if the document is ready
  709. var top = false;
  710. try {
  711. top = window.frameElement == null && document.documentElement;
  712. } catch(e) {}
  713. if ( top && top.doScroll ) {
  714. (function doScrollCheck() {
  715. if ( !jQuery.isReady ) {
  716. try {
  717. // Use the trick by Diego Perini
  718. // http://javascript.nwbox.com/IEContentLoaded/
  719. top.doScroll("left");
  720. } catch(e) {
  721. return setTimeout( doScrollCheck, 50 );
  722. }
  723. // and execute any waiting functions
  724. jQuery.ready();
  725. }
  726. })();
  727. }
  728. }
  729. }
  730. return readyList.promise( obj );
  731. };
  732. // Populate the class2type map
  733. jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
  734. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  735. });
  736. // All jQuery objects should point back to these
  737. rootjQuery = jQuery(document);
  738. // String to Object options format cache
  739. var optionsCache = {};
  740. // Convert String-formatted options into Object-formatted ones and store in cache
  741. function createOptions( options ) {
  742. var object = optionsCache[ options ] = {};
  743. jQuery.each( options.split( core_rspace ), function( _, flag ) {
  744. object[ flag ] = true;
  745. });
  746. return object;
  747. }
  748. /*
  749. * Create a callback list using the following parameters:
  750. *
  751. * options: an optional list of space-separated options that will change how
  752. * the callback list behaves or a more traditional option object
  753. *
  754. * By default a callback list will act like an event callback list and can be
  755. * "fired" multiple times.
  756. *
  757. * Possible options:
  758. *
  759. * once: will ensure the callback list can only be fired once (like a Deferred)
  760. *
  761. * memory: will keep track of previous values and will call any callback added
  762. * after the list has been fired right away with the latest "memorized"
  763. * values (like a Deferred)
  764. *
  765. * unique: will ensure a callback can only be added once (no duplicate in the list)
  766. *
  767. * stopOnFalse: interrupt callings when a callback returns false
  768. *
  769. */
  770. jQuery.Callbacks = function( options ) {
  771. // Convert options from String-formatted to Object-formatted if needed
  772. // (we check in cache first)
  773. options = typeof options === "string" ?
  774. ( optionsCache[ options ] || createOptions( options ) ) :
  775. jQuery.extend( {}, options );
  776. var // Last fire value (for non-forgettable lists)
  777. memory,
  778. // Flag to know if list was already fired
  779. fired,
  780. // Flag to know if list is currently firing
  781. firing,
  782. // First callback to fire (used internally by add and fireWith)
  783. firingStart,
  784. // End of the loop when firing
  785. firingLength,
  786. // Index of currently firing callback (modified by remove if needed)
  787. firingIndex,
  788. // Actual callback list
  789. list = [],
  790. // Stack of fire calls for repeatable lists
  791. stack = !options.once && [],
  792. // Fire callbacks
  793. fire = function( data ) {
  794. memory = options.memory && data;
  795. fired = true;
  796. firingIndex = firingStart || 0;
  797. firingStart = 0;
  798. firingLength = list.length;
  799. firing = true;
  800. for ( ; list && firingIndex < firingLength; firingIndex++ ) {
  801. if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
  802. memory = false; // To prevent further calls using add
  803. break;
  804. }
  805. }
  806. firing = false;
  807. if ( list ) {
  808. if ( stack ) {
  809. if ( stack.length ) {
  810. fire( stack.shift() );
  811. }
  812. } else if ( memory ) {
  813. list = [];
  814. } else {
  815. self.disable();
  816. }
  817. }
  818. },
  819. // Actual Callbacks object
  820. self = {
  821. // Add a callback or a collection of callbacks to the list
  822. add: function() {
  823. if ( list ) {
  824. // First, we save the current length
  825. var start = list.length;
  826. (function add( args ) {
  827. jQuery.each( args, function( _, arg ) {
  828. var type = jQuery.type( arg );
  829. if ( type === "function" && ( !options.unique || !self.has( arg ) ) ) {
  830. list.push( arg );
  831. } else if ( arg && arg.length && type !== "string" ) {
  832. // Inspect recursively
  833. add( arg );
  834. }
  835. });
  836. })( arguments );
  837. // Do we need to add the callbacks to the
  838. // current firing batch?
  839. if ( firing ) {
  840. firingLength = list.length;
  841. // With memory, if we're not firing then
  842. // we should call right away
  843. } else if ( memory ) {
  844. firingStart = start;
  845. fire( memory );
  846. }
  847. }
  848. return this;
  849. },
  850. // Remove a callback from the list
  851. remove: function() {
  852. if ( list ) {
  853. jQuery.each( arguments, function( _, arg ) {
  854. var index;
  855. while( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
  856. list.splice( index, 1 );
  857. // Handle firing indexes
  858. if ( firing ) {
  859. if ( index <= firingLength ) {
  860. firingLength--;
  861. }
  862. if ( index <= firingIndex ) {
  863. firingIndex--;
  864. }
  865. }
  866. }
  867. });
  868. }
  869. return this;
  870. },
  871. // Control if a given callback is in the list
  872. has: function( fn ) {
  873. return jQuery.inArray( fn, list ) > -1;
  874. },
  875. // Remove all callbacks from the list
  876. empty: function() {
  877. list = [];
  878. return this;
  879. },
  880. // Have the list do nothing anymore
  881. disable: function() {
  882. list = stack = memory = undefined;
  883. return this;
  884. },
  885. // Is it disabled?
  886. disabled: function() {
  887. return !list;
  888. },
  889. // Lock the list in its current state
  890. lock: function() {
  891. stack = undefined;
  892. if ( !memory ) {
  893. self.disable();
  894. }
  895. return this;
  896. },
  897. // Is it locked?
  898. locked: function() {
  899. return !stack;
  900. },
  901. // Call all callbacks with the given context and arguments
  902. fireWith: function( context, args ) {
  903. args = args || [];
  904. args = [ context, args.slice ? args.slice() : args ];
  905. if ( list && ( !fired || stack ) ) {
  906. if ( firing ) {
  907. stack.push( args );
  908. } else {
  909. fire( args );
  910. }
  911. }
  912. return this;
  913. },
  914. // Call all the callbacks with the given arguments
  915. fire: function() {
  916. self.fireWith( this, arguments );
  917. return this;
  918. },
  919. // To know if the callbacks have already been called at least once
  920. fired: function() {
  921. return !!fired;
  922. }
  923. };
  924. return self;
  925. };
  926. jQuery.extend({
  927. Deferred: function( func ) {
  928. var tuples = [
  929. // action, add listener, listener list, final state
  930. [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
  931. [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
  932. [ "notify", "progress", jQuery.Callbacks("memory") ]
  933. ],
  934. state = "pending",
  935. promise = {
  936. state: function() {
  937. return state;
  938. },
  939. always: function() {
  940. deferred.done( arguments ).fail( arguments );
  941. return this;
  942. },
  943. then: function( /* fnDone, fnFail, fnProgress */ ) {
  944. var fns = arguments;
  945. return jQuery.Deferred(function( newDefer ) {
  946. jQuery.each( tuples, function( i, tuple ) {
  947. var action = tuple[ 0 ],
  948. fn = fns[ i ];
  949. // deferred[ done | fail | progress ] for forwarding actions to newDefer
  950. deferred[ tuple[1] ]( jQuery.isFunction( fn ) ?
  951. function() {
  952. var returned = fn.apply( this, arguments );
  953. if ( returned && jQuery.isFunction( returned.promise ) ) {
  954. returned.promise()
  955. .done( newDefer.resolve )
  956. .fail( newDefer.reject )
  957. .progress( newDefer.notify );
  958. } else {
  959. newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] );
  960. }
  961. } :
  962. newDefer[ action ]
  963. );
  964. });
  965. fns = null;
  966. }).promise();
  967. },
  968. // Get a promise for this deferred
  969. // If obj is provided, the promise aspect is added to the object
  970. promise: function( obj ) {
  971. return typeof obj === "object" ? jQuery.extend( obj, promise ) : promise;
  972. }
  973. },
  974. deferred = {};
  975. // Keep pipe for back-compat
  976. promise.pipe = promise.then;
  977. // Add list-specific methods
  978. jQuery.each( tuples, function( i, tuple ) {
  979. var list = tuple[ 2 ],
  980. stateString = tuple[ 3 ];
  981. // promise[ done | fail | progress ] = list.add
  982. promise[ tuple[1] ] = list.add;
  983. // Handle state
  984. if ( stateString ) {
  985. list.add(function() {
  986. // state = [ resolved | rejected ]
  987. state = stateString;
  988. // [ reject_list | resolve_list ].disable; progress_list.lock
  989. }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
  990. }
  991. // deferred[ resolve | reject | notify ] = list.fire
  992. deferred[ tuple[0] ] = list.fire;
  993. deferred[ tuple[0] + "With" ] = list.fireWith;
  994. });
  995. // Make the deferred a promise
  996. promise.promise( deferred );
  997. // Call given func if any
  998. if ( func ) {
  999. func.call( deferred, deferred );
  1000. }
  1001. // All done!
  1002. return deferred;
  1003. },
  1004. // Deferred helper
  1005. when: function( subordinate /* , ..., subordinateN */ ) {
  1006. var i = 0,
  1007. resolveValues = core_slice.call( arguments ),
  1008. length = resolveValues.length,
  1009. // the count of uncompleted subordinates
  1010. remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
  1011. // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
  1012. deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
  1013. // Update function for both resolve and progress values
  1014. updateFunc = function( i, contexts, values ) {
  1015. return function( value ) {
  1016. contexts[ i ] = this;
  1017. values[ i ] = arguments.length > 1 ? core_slice.call( arguments ) : value;
  1018. if( values === progressValues ) {
  1019. deferred.notifyWith( contexts, values );
  1020. } else if ( !( --remaining ) ) {
  1021. deferred.resolveWith( contexts, values );
  1022. }
  1023. };
  1024. },
  1025. progressValues, progressContexts, resolveContexts;
  1026. // add listeners to Deferred subordinates; treat others as resolved
  1027. if ( length > 1 ) {
  1028. progressValues = new Array( length );
  1029. progressContexts = new Array( length );
  1030. resolveContexts = new Array( length );
  1031. for ( ; i < length; i++ ) {
  1032. if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
  1033. resolveValues[ i ].promise()
  1034. .done( updateFunc( i, resolveContexts, resolveValues ) )
  1035. .fail( deferred.reject )
  1036. .progress( updateFunc( i, progressContexts, progressValues ) );
  1037. } else {
  1038. --remaining;
  1039. }
  1040. }
  1041. }
  1042. // if we're not waiting on anything, resolve the master
  1043. if ( !remaining ) {
  1044. deferred.resolveWith( resolveContexts, resolveValues );
  1045. }
  1046. return deferred.promise();
  1047. }
  1048. });
  1049. jQuery.support = (function() {
  1050. var support,
  1051. all,
  1052. a,
  1053. select,
  1054. opt,
  1055. input,
  1056. fragment,
  1057. eventName,
  1058. i,
  1059. isSupported,
  1060. clickFn,
  1061. div = document.createElement("div");
  1062. // Preliminary tests
  1063. div.setAttribute( "className", "t" );
  1064. div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
  1065. all = div.getElementsByTagName("*");
  1066. a = div.getElementsByTagName("a")[ 0 ];
  1067. a.style.cssText = "top:1px;float:left;opacity:.5";
  1068. // Can't get basic test support
  1069. if ( !all || !all.length || !a ) {
  1070. return {};
  1071. }
  1072. // First batch of supports tests
  1073. select = document.createElement("select");
  1074. opt = select.appendChild( document.createElement("option") );
  1075. input = div.getElementsByTagName("input")[ 0 ];
  1076. support = {
  1077. // IE strips leading whitespace when .innerHTML is used
  1078. leadingWhitespace: ( div.firstChild.nodeType === 3 ),
  1079. // Make sure that tbody elements aren't automatically inserted
  1080. // IE will insert them into empty tables
  1081. tbody: !div.getElementsByTagName("tbody").length,
  1082. // Make sure that link elements get serialized correctly by innerHTML
  1083. // This requires a wrapper element in IE
  1084. htmlSerialize: !!div.getElementsByTagName("link").length,
  1085. // Get the style information from getAttribute
  1086. // (IE uses .cssText instead)
  1087. style: /top/.test( a.getAttribute("style") ),
  1088. // Make sure that URLs aren't manipulated
  1089. // (IE normalizes it by default)
  1090. hrefNormalized: ( a.getAttribute("href") === "/a" ),
  1091. // Make sure that element opacity exists
  1092. // (IE uses filter instead)
  1093. // Use a regex to work around a WebKit issue. See #5145
  1094. opacity: /^0.5/.test( a.style.opacity ),
  1095. // Verify style float existence
  1096. // (IE uses styleFloat instead of cssFloat)
  1097. cssFloat: !!a.style.cssFloat,
  1098. // Make sure that if no value is specified for a checkbox
  1099. // that it defaults to "on".
  1100. // (WebKit defaults to "" instead)
  1101. checkOn: ( input.value === "on" ),
  1102. // Make sure that a selected-by-default option has a working selected property.
  1103. // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
  1104. optSelected: opt.selected,
  1105. // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
  1106. getSetAttribute: div.className !== "t",
  1107. // Tests for enctype support on a form(#6743)
  1108. enctype: !!document.createElement("form").enctype,
  1109. // Makes sure cloning an html5 element does not cause problems
  1110. // Where outerHTML is undefined, this still works
  1111. html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav></:nav>",
  1112. // jQuery.support.boxModel DEPRECATED in 1.8 since we don't support Quirks Mode
  1113. boxModel: ( document.compatMode === "CSS1Compat" ),
  1114. // Will be defined later
  1115. submitBubbles: true,
  1116. changeBubbles: true,
  1117. focusinBubbles: false,
  1118. deleteExpando: true,
  1119. noCloneEvent: true,
  1120. inlineBlockNeedsLayout: false,
  1121. shrinkWrapBlocks: false,
  1122. reliableMarginRight: true,
  1123. boxSizingReliable: true,
  1124. pixelPosition: false
  1125. };
  1126. // Make sure checked status is properly cloned
  1127. input.checked = true;
  1128. support.noCloneChecked = input.cloneNode( true ).checked;
  1129. // Make sure that the options inside disabled selects aren't marked as disabled
  1130. // (WebKit marks them as disabled)
  1131. select.disabled = true;
  1132. support.optDisabled = !opt.disabled;
  1133. // Test to see if it's possible to delete an expando from an element
  1134. // Fails in Internet Explorer
  1135. try {
  1136. delete div.test;
  1137. } catch( e ) {
  1138. support.deleteExpando = false;
  1139. }
  1140. if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
  1141. div.attachEvent( "onclick", clickFn = function() {
  1142. // Cloning a node shouldn't copy over any
  1143. // bound event handlers (IE does this)
  1144. support.noCloneEvent = false;
  1145. });
  1146. div.cloneNode( true ).fireEvent("onclick");
  1147. div.detachEvent( "onclick", clickFn );
  1148. }
  1149. // Check if a radio maintains its value
  1150. // after being appended to the DOM
  1151. input = document.createElement("input");
  1152. input.value = "t";
  1153. input.setAttribute( "type", "radio" );
  1154. support.radioValue = input.value === "t";
  1155. input.setAttribute( "checked", "checked" );
  1156. // #11217 - WebKit loses check when the name is after the checked attribute
  1157. input.setAttribute( "name", "t" );
  1158. div.appendChild( input );
  1159. fragment = document.createDocumentFragment();
  1160. fragment.appendChild( div.lastChild );
  1161. // WebKit doesn't clone checked state correctly in fragments
  1162. support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
  1163. // Check if a disconnected checkbox will retain its checked
  1164. // value of true after appended to the DOM (IE6/7)
  1165. support.appendChecked = input.checked;
  1166. fragment.removeChild( input );
  1167. fragment.appendChild( div );
  1168. // Technique from Juriy Zaytsev
  1169. // http://perfectionkills.com/detecting-event-support-without-browser-sniffing/
  1170. // We only care about the case where non-standard event systems
  1171. // are used, namely in IE. Short-circuiting here helps us to
  1172. // avoid an eval call (in setAttribute) which can cause CSP
  1173. // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
  1174. if ( div.attachEvent ) {
  1175. for ( i in {
  1176. submit: true,
  1177. change: true,
  1178. focusin: true
  1179. }) {
  1180. eventName = "on" + i;
  1181. isSupported = ( eventName in div );
  1182. if ( !isSupported ) {
  1183. div.setAttribute( eventName, "return;" );
  1184. isSupported = ( typeof div[ eventName ] === "function" );
  1185. }
  1186. support[ i + "Bubbles" ] = isSupported;
  1187. }
  1188. }
  1189. // Run tests that need a body at doc ready
  1190. jQuery(function() {
  1191. var container, div, tds, marginDiv,
  1192. divReset = "padding:0;margin:0;border:0;display:block;overflow:hidden;",
  1193. body = document.getElementsByTagName("body")[0];
  1194. if ( !body ) {
  1195. // Return for frameset docs that don't have a body
  1196. return;
  1197. }
  1198. container = document.createElement("div");
  1199. container.style.cssText = "visibility:hidden;border:0;width:0;height:0;position:static;top:0;margin-top:1px";
  1200. body.insertBefore( container, body.firstChild );
  1201. // Construct the test element
  1202. div = document.createElement("div");
  1203. container.appendChild( div );
  1204. // Check if table cells still have offsetWidth/Height when they are set
  1205. // to display:none and there are still other visible table cells in a
  1206. // table row; if so, offsetWidth/Height are not reliable for use when
  1207. // determining if an element has been hidden directly using
  1208. // display:none (it is still safe to use offsets if a parent element is
  1209. // hidden; don safety goggles and see bug #4512 for more information).
  1210. // (only IE 8 fails this test)
  1211. div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";
  1212. tds = div.getElementsByTagName("td");
  1213. tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:none";
  1214. isSupported = ( tds[ 0 ].offsetHeight === 0 );
  1215. tds[ 0 ].style.display = "";
  1216. tds[ 1 ].style.display = "none";
  1217. // Check if empty table cells still have offsetWidth/Height
  1218. // (IE <= 8 fail this test)
  1219. support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
  1220. // Check box-sizing and margin behavior
  1221. div.innerHTML = "";
  1222. div.style.cssText = "box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;";
  1223. support.boxSizing = ( div.offsetWidth === 4 );
  1224. support.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== 1 );
  1225. // NOTE: To any future maintainer, we've window.getComputedStyle
  1226. // because jsdom on node.js will break without it.
  1227. if ( window.getComputedStyle ) {
  1228. support.pixelPosition = ( window.getComputedStyle( div, null ) || {} ).top !== "1%";
  1229. support.boxSizingReliable = ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px";
  1230. // Check if div with explicit width and no margin-right incorrectly
  1231. // gets computed margin-right based on width of container. For more
  1232. // info see bug #3333
  1233. // Fails in WebKit before Feb 2011 nightlies
  1234. // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
  1235. marginDiv = document.createElement("div");
  1236. marginDiv.style.cssText = div.style.cssText = divReset;
  1237. marginDiv.style.marginRight = marginDiv.style.width = "0";
  1238. div.style.width = "1px";
  1239. div.appendChild( marginDiv );
  1240. support.reliableMarginRight =
  1241. !parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight );
  1242. }
  1243. if ( typeof div.style.zoom !== "undefined" ) {
  1244. // Check if natively block-level elements act like inline-block
  1245. // elements when setting their display to 'inline' and giving
  1246. // them layout
  1247. // (IE < 8 does this)
  1248. div.innerHTML = "";
  1249. div.style.cssText = divReset + "width:1px;padding:1px;display:inline;zoom:1";
  1250. support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 );
  1251. // Check if elements with layout shrink-wrap their children
  1252. // (IE 6 does this)
  1253. div.style.display = "block";
  1254. div.style.overflow = "visible";
  1255. div.innerHTML = "<div></div>";
  1256. div.firstChild.style.width = "5px";
  1257. support.shrinkWrapBlocks = ( div.offsetWidth !== 3 );
  1258. container.style.zoom = 1;
  1259. }
  1260. // Null elements to avoid leaks in IE
  1261. body.removeChild( container );
  1262. container = div = tds = marginDiv = null;
  1263. });
  1264. // Null elements to avoid leaks in IE
  1265. fragment.removeChild( div );
  1266. all = a = select = opt = input = fragment = div = null;
  1267. return support;
  1268. })();
  1269. var rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/,
  1270. rmultiDash = /([A-Z])/g;
  1271. jQuery.extend({
  1272. cache: {},
  1273. deletedIds: [],
  1274. // Please use with caution
  1275. uuid: 0,
  1276. // Unique for each copy of jQuery on the page
  1277. // Non-digits removed to match rinlinejQuery
  1278. expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),
  1279. // The following elements throw uncatchable exceptions if you
  1280. // attempt to add expando properties to them.
  1281. noData: {
  1282. "embed": true,
  1283. // Ban all objects except for Flash (which handle expandos)
  1284. "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
  1285. "applet": true
  1286. },
  1287. hasData: function( elem ) {
  1288. elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
  1289. return !!elem && !isEmptyDataObject( elem );
  1290. },
  1291. data: function( elem, name, data, pvt /* Internal Use Only */ ) {
  1292. if ( !jQuery.acceptData( elem ) ) {
  1293. return;
  1294. }
  1295. var thisCache, ret,
  1296. internalKey = jQuery.expando,
  1297. getByName = typeof name === "string",
  1298. // We have to handle DOM nodes and JS objects differently because IE6-7
  1299. // can't GC object references properly across the DOM-JS boundary
  1300. isNode = elem.nodeType,
  1301. // Only DOM nodes need the global jQuery cache; JS object data is
  1302. // attached directly to the object so GC can occur automatically
  1303. cache = isNode ? jQuery.cache : elem,
  1304. // Only defining an ID for JS objects if its cache already exists allows
  1305. // the code to shortcut on the same path as a DOM node with no cache
  1306. id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey;
  1307. // Avoid doing any more work than we need to when trying to get data on an
  1308. // object that has no data at all
  1309. if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && getByName && data === undefined ) {
  1310. return;
  1311. }
  1312. if ( !id ) {
  1313. // Only DOM nodes need a new unique ID for each element since their data
  1314. // ends up in the global cache
  1315. if ( isNode ) {
  1316. elem[ internalKey ] = id = jQuery.deletedIds.pop() || ++jQuery.uuid;
  1317. } else {
  1318. id = internalKey;
  1319. }
  1320. }
  1321. if ( !cache[ id ] ) {
  1322. cache[ id ] = {};
  1323. // Avoids exposing jQuery metadata on plain JS objects when the object
  1324. // is serialized using JSON.stringify
  1325. if ( !isNode ) {
  1326. cache[ id ].toJSON = jQuery.noop;
  1327. }
  1328. }
  1329. // An object can be passed to jQuery.data instead of a key/value pair; this gets
  1330. // shallow copied over onto the existing cache
  1331. if ( typeof name === "object" || typeof name === "function" ) {
  1332. if ( pvt ) {
  1333. cache[ id ] = jQuery.extend( cache[ id ], name );
  1334. } else {
  1335. cache[ id ].data = jQuery.extend( cache[ id ].data, name );
  1336. }
  1337. }
  1338. thisCache = cache[ id ];
  1339. // jQuery data() is stored in a separate object inside the object's internal data
  1340. // cache in order to avoid key collisions between internal data and user-defined
  1341. // data.
  1342. if ( !pvt ) {
  1343. if ( !thisCache.data ) {
  1344. thisCache.data = {};
  1345. }
  1346. thisCache = thisCache.data;
  1347. }
  1348. if ( data !== undefined ) {
  1349. thisCache[ jQuery.camelCase( name ) ] = data;
  1350. }
  1351. // Check for both converted-to-camel and non-converted data property names
  1352. // If a data property was specified
  1353. if ( getByName ) {
  1354. // First Try to find as-is property data
  1355. ret = thisCache[ name ];
  1356. // Test for null|undefined property data
  1357. if ( ret == null ) {
  1358. // Try to find the camelCased property
  1359. ret = thisCache[ jQuery.camelCase( name ) ];
  1360. }
  1361. } else {
  1362. ret = thisCache;
  1363. }
  1364. return ret;
  1365. },
  1366. removeData: function( elem, name, pvt /* Internal Use Only */ ) {
  1367. if ( !jQuery.acceptData( elem ) ) {
  1368. return;
  1369. }
  1370. var thisCache, i, l,
  1371. isNode = elem.nodeType,
  1372. // See jQuery.data for more information
  1373. cache = isNode ? jQuery.cache : elem,
  1374. id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
  1375. // If there is already no cache entry for this object, there is no
  1376. // purpose in continuing
  1377. if ( !cache[ id ] ) {
  1378. return;
  1379. }
  1380. if ( name ) {
  1381. thisCache = pvt ? cache[ id ] : cache[ id ].data;
  1382. if ( thisCache ) {
  1383. // Support array or space separated string names for data keys
  1384. if ( !jQuery.isArray( name ) ) {
  1385. // try the string as a key before any manipulation
  1386. if ( name in thisCache ) {
  1387. name = [ name ];
  1388. } else {
  1389. // split the camel cased version by spaces unless a key with the spaces exists
  1390. name = jQuery.camelCase( name );
  1391. if ( name in thisCache ) {
  1392. name = [ name ];
  1393. } else {
  1394. name = name.split(" ");
  1395. }
  1396. }
  1397. }
  1398. for ( i = 0, l = name.length; i < l; i++ ) {
  1399. delete thisCache[ name[i] ];
  1400. }
  1401. // If there is no data left in the cache, we want to continue
  1402. // and let the cache object itself get destroyed
  1403. if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) {
  1404. return;
  1405. }
  1406. }
  1407. }
  1408. // See jQuery.data for more information
  1409. if ( !pvt ) {
  1410. delete cache[ id ].data;
  1411. // Don't destroy the parent cache unless the internal data object
  1412. // had been the only thing left in it
  1413. if ( !isEmptyDataObject( cache[ id ] ) ) {
  1414. return;
  1415. }
  1416. }
  1417. // Destroy the cache
  1418. if ( isNode ) {
  1419. jQuery.cleanData( [ elem ], true );
  1420. // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080)
  1421. } else if ( jQuery.support.deleteExpando || cache != cache.window ) {
  1422. delete cache[ id ];
  1423. // When all else fails, null
  1424. } else {
  1425. cache[ id ] = null;
  1426. }
  1427. },
  1428. // For internal use only.
  1429. _data: function( elem, name, data ) {
  1430. return jQuery.data( elem, name, data, true );
  1431. },
  1432. // A method for determining if a DOM node can handle the data expando
  1433. acceptData: function( elem ) {
  1434. var noData = elem.nodeName && jQuery.noData[ elem.nodeName.toLowerCase() ];
  1435. // nodes accept data unless otherwise specified; rejection can be conditional
  1436. return !noData || noData !== true && elem.getAttribute("classid") === noData;
  1437. }
  1438. });
  1439. jQuery.fn.extend({
  1440. data: function( key, value ) {
  1441. var parts, part, attr, name, l,
  1442. elem = this[0],
  1443. i = 0,
  1444. data = null;
  1445. // Gets all values
  1446. if ( key === undefined ) {
  1447. if ( this.length ) {
  1448. data = jQuery.data( elem );
  1449. if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
  1450. attr = elem.attributes;
  1451. for ( l = attr.length; i < l; i++ ) {
  1452. name = attr[i].name;
  1453. if ( name.indexOf( "data-" ) === 0 ) {
  1454. name = jQuery.camelCase( name.substring(5) );
  1455. dataAttr( elem, name, data[ name ] );
  1456. }
  1457. }
  1458. jQuery._data( elem, "parsedAttrs", true );
  1459. }
  1460. }
  1461. return data;
  1462. }
  1463. // Sets multiple values
  1464. if ( typeof key === "object" ) {
  1465. return this.each(function() {
  1466. jQuery.data( this, key );
  1467. });
  1468. }
  1469. parts = key.split( ".", 2 );
  1470. parts[1] = parts[1] ? "." + parts[1] : "";
  1471. part = parts[1] + "!";
  1472. return jQuery.access( this, function( value ) {
  1473. if ( value === undefined ) {
  1474. data = this.triggerHandler( "getData" + part, [ parts[0] ] );
  1475. // Try to fetch any internally stored data first
  1476. if ( data === undefined && elem ) {
  1477. data = jQuery.data( elem, key );
  1478. data = dataAttr( elem, key, data );
  1479. }
  1480. return data === undefined && parts[1] ?
  1481. this.data( parts[0] ) :
  1482. data;
  1483. }
  1484. parts[1] = value;
  1485. this.each(function() {
  1486. var self = jQuery( this );
  1487. self.triggerHandler( "setData" + part, parts );
  1488. jQuery.data( this, key, value );
  1489. self.triggerHandler( "changeData" + part, parts );
  1490. });
  1491. }, null, value, arguments.length > 1, null, false );
  1492. },
  1493. removeData: function( key ) {
  1494. return this.each(function() {
  1495. jQuery.removeData( this, key );
  1496. });
  1497. }
  1498. });
  1499. function dataAttr( elem, key, data ) {
  1500. // If nothing was found internally, try to fetch any
  1501. // data from the HTML5 data-* attribute
  1502. if ( data === undefined && elem.nodeType === 1 ) {
  1503. var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
  1504. data = elem.getAttribute( name );
  1505. if ( typeof data === "string" ) {
  1506. try {

Large files files are truncated, but you can click here to view the full file