PageRenderTime 58ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 2ms

/js/lib/jquery-1.5.1.js

http://github.com/onedayitwillmake/RealtimeMultiplayerNodeJs
JavaScript | 8316 lines | 5778 code | 1515 blank | 1023 comment | 1666 complexity | 416c4251d4835e7a5891977133e4173e MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, MPL-2.0-no-copyleft-exception, BSD-3-Clause

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

  1. /*!
  2. * jQuery JavaScript Library v1.5.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: Wed Feb 23 13:55:29 2011 -0500
  15. */
  16. (function( window, undefined ) {
  17. // Use the correct document accordingly with window argument (sandbox)
  18. var document = window.document;
  19. var jQuery = (function() {
  20. // Define a local copy of jQuery
  21. var jQuery = function( selector, context ) {
  22. // The jQuery object is actually just the init constructor 'enhanced'
  23. return new jQuery.fn.init( selector, context, rootjQuery );
  24. },
  25. // Map over jQuery in case of overwrite
  26. _jQuery = window.jQuery,
  27. // Map over the $ in case of overwrite
  28. _$ = window.$,
  29. // A central reference to the root jQuery(document)
  30. rootjQuery,
  31. // A simple way to check for HTML strings or ID strings
  32. // (both of which we optimize for)
  33. quickExpr = /^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/,
  34. // Check if a string has a non-whitespace character in it
  35. rnotwhite = /\S/,
  36. // Used for trimming whitespace
  37. trimLeft = /^\s+/,
  38. trimRight = /\s+$/,
  39. // Check for digits
  40. rdigit = /\d/,
  41. // Match a standalone tag
  42. rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
  43. // JSON RegExp
  44. rvalidchars = /^[\],:{}\s]*$/,
  45. rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
  46. rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
  47. rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
  48. // Useragent RegExp
  49. rwebkit = /(webkit)[ \/]([\w.]+)/,
  50. ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
  51. rmsie = /(msie) ([\w.]+)/,
  52. rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
  53. // Keep a UserAgent string for use with jQuery.browser
  54. userAgent = navigator.userAgent,
  55. // For matching the engine and version of the browser
  56. browserMatch,
  57. // Has the ready events already been bound?
  58. readyBound = false,
  59. // The deferred used on DOM ready
  60. readyList,
  61. // Promise methods
  62. promiseMethods = "then done fail isResolved isRejected promise".split( " " ),
  63. // The ready event handler
  64. DOMContentLoaded,
  65. // Save a reference to some core methods
  66. toString = Object.prototype.toString,
  67. hasOwn = Object.prototype.hasOwnProperty,
  68. push = Array.prototype.push,
  69. slice = Array.prototype.slice,
  70. trim = String.prototype.trim,
  71. indexOf = Array.prototype.indexOf,
  72. // [[Class]] -> type pairs
  73. class2type = {};
  74. jQuery.fn = jQuery.prototype = {
  75. constructor: jQuery,
  76. init: function( selector, context, rootjQuery ) {
  77. var match, elem, ret, doc;
  78. // Handle $(""), $(null), or $(undefined)
  79. if ( !selector ) {
  80. return this;
  81. }
  82. // Handle $(DOMElement)
  83. if ( selector.nodeType ) {
  84. this.context = this[0] = selector;
  85. this.length = 1;
  86. return this;
  87. }
  88. // The body element only exists once, optimize finding it
  89. if ( selector === "body" && !context && document.body ) {
  90. this.context = document;
  91. this[0] = document.body;
  92. this.selector = "body";
  93. this.length = 1;
  94. return this;
  95. }
  96. // Handle HTML strings
  97. if ( typeof selector === "string" ) {
  98. // Are we dealing with HTML string or an ID?
  99. match = quickExpr.exec( selector );
  100. // Verify a match, and that no context was 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.ownerDocument || context : document);
  106. // If a single string is passed in and it's a single tag
  107. // just do a createElement and skip the rest
  108. ret = rsingleTag.exec( selector );
  109. if ( ret ) {
  110. if ( jQuery.isPlainObject( context ) ) {
  111. selector = [ document.createElement( ret[1] ) ];
  112. jQuery.fn.attr.call( selector, context, true );
  113. } else {
  114. selector = [ doc.createElement( ret[1] ) ];
  115. }
  116. } else {
  117. ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
  118. selector = (ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment).childNodes;
  119. }
  120. return jQuery.merge( this, selector );
  121. // HANDLE: $("#id")
  122. } else {
  123. elem = document.getElementById( match[2] );
  124. // Check parentNode to catch when Blackberry 4.6 returns
  125. // nodes that are no longer in the document #6963
  126. if ( elem && elem.parentNode ) {
  127. // Handle the case where IE and Opera return items
  128. // by name instead of ID
  129. if ( elem.id !== match[2] ) {
  130. return rootjQuery.find( selector );
  131. }
  132. // Otherwise, we inject the element directly into the jQuery object
  133. this.length = 1;
  134. this[0] = elem;
  135. }
  136. this.context = document;
  137. this.selector = selector;
  138. return this;
  139. }
  140. // HANDLE: $(expr, $(...))
  141. } else if ( !context || context.jquery ) {
  142. return (context || rootjQuery).find( selector );
  143. // HANDLE: $(expr, context)
  144. // (which is just equivalent to: $(context).find(expr)
  145. } else {
  146. return this.constructor( context ).find( selector );
  147. }
  148. // HANDLE: $(function)
  149. // Shortcut for document ready
  150. } else if ( jQuery.isFunction( selector ) ) {
  151. return rootjQuery.ready( selector );
  152. }
  153. if (selector.selector !== undefined) {
  154. this.selector = selector.selector;
  155. this.context = selector.context;
  156. }
  157. return jQuery.makeArray( selector, this );
  158. },
  159. // Start with an empty selector
  160. selector: "",
  161. // The current version of jQuery being used
  162. jquery: "1.5.1",
  163. // The default length of a jQuery object is 0
  164. length: 0,
  165. // The number of elements contained in the matched element set
  166. size: function() {
  167. return this.length;
  168. },
  169. toArray: function() {
  170. return slice.call( this, 0 );
  171. },
  172. // Get the Nth element in the matched element set OR
  173. // Get the whole matched element set as a clean array
  174. get: function( num ) {
  175. return num == null ?
  176. // Return a 'clean' array
  177. this.toArray() :
  178. // Return just the object
  179. ( num < 0 ? this[ this.length + num ] : this[ num ] );
  180. },
  181. // Take an array of elements and push it onto the stack
  182. // (returning the new matched element set)
  183. pushStack: function( elems, name, selector ) {
  184. // Build a new jQuery matched element set
  185. var ret = this.constructor();
  186. if ( jQuery.isArray( elems ) ) {
  187. push.apply( ret, elems );
  188. } else {
  189. jQuery.merge( ret, elems );
  190. }
  191. // Add the old object onto the stack (as a reference)
  192. ret.prevObject = this;
  193. ret.context = this.context;
  194. if ( name === "find" ) {
  195. ret.selector = this.selector + (this.selector ? " " : "") + selector;
  196. } else if ( name ) {
  197. ret.selector = this.selector + "." + name + "(" + selector + ")";
  198. }
  199. // Return the newly-formed element set
  200. return ret;
  201. },
  202. // Execute a callback for every element in the matched set.
  203. // (You can seed the arguments with an array of args, but this is
  204. // only used internally.)
  205. each: function( callback, args ) {
  206. return jQuery.each( this, callback, args );
  207. },
  208. ready: function( fn ) {
  209. // Attach the listeners
  210. jQuery.bindReady();
  211. // Add the callback
  212. readyList.done( fn );
  213. return this;
  214. },
  215. eq: function( i ) {
  216. return i === -1 ?
  217. this.slice( i ) :
  218. this.slice( i, +i + 1 );
  219. },
  220. first: function() {
  221. return this.eq( 0 );
  222. },
  223. last: function() {
  224. return this.eq( -1 );
  225. },
  226. slice: function() {
  227. return this.pushStack( slice.apply( this, arguments ),
  228. "slice", slice.call(arguments).join(",") );
  229. },
  230. map: function( callback ) {
  231. return this.pushStack( jQuery.map(this, function( elem, i ) {
  232. return callback.call( elem, i, elem );
  233. }));
  234. },
  235. end: function() {
  236. return this.prevObject || this.constructor(null);
  237. },
  238. // For internal use only.
  239. // Behaves like an Array's method, not like a jQuery method.
  240. push: push,
  241. sort: [].sort,
  242. splice: [].splice
  243. };
  244. // Give the init function the jQuery prototype for later instantiation
  245. jQuery.fn.init.prototype = jQuery.fn;
  246. jQuery.extend = jQuery.fn.extend = function() {
  247. var options, name, src, copy, copyIsArray, clone,
  248. target = arguments[0] || {},
  249. i = 1,
  250. length = arguments.length,
  251. deep = false;
  252. // Handle a deep copy situation
  253. if ( typeof target === "boolean" ) {
  254. deep = target;
  255. target = arguments[1] || {};
  256. // skip the boolean and the target
  257. i = 2;
  258. }
  259. // Handle case when target is a string or something (possible in deep copy)
  260. if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
  261. target = {};
  262. }
  263. // extend jQuery itself if only one argument is passed
  264. if ( length === i ) {
  265. target = this;
  266. --i;
  267. }
  268. for ( ; i < length; i++ ) {
  269. // Only deal with non-null/undefined values
  270. if ( (options = arguments[ i ]) != null ) {
  271. // Extend the base object
  272. for ( name in options ) {
  273. src = target[ name ];
  274. copy = options[ name ];
  275. // Prevent never-ending loop
  276. if ( target === copy ) {
  277. continue;
  278. }
  279. // Recurse if we're merging plain objects or arrays
  280. if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
  281. if ( copyIsArray ) {
  282. copyIsArray = false;
  283. clone = src && jQuery.isArray(src) ? src : [];
  284. } else {
  285. clone = src && jQuery.isPlainObject(src) ? src : {};
  286. }
  287. // Never move original objects, clone them
  288. target[ name ] = jQuery.extend( deep, clone, copy );
  289. // Don't bring in undefined values
  290. } else if ( copy !== undefined ) {
  291. target[ name ] = copy;
  292. }
  293. }
  294. }
  295. }
  296. // Return the modified object
  297. return target;
  298. };
  299. jQuery.extend({
  300. noConflict: function( deep ) {
  301. window.$ = _$;
  302. if ( deep ) {
  303. window.jQuery = _jQuery;
  304. }
  305. return jQuery;
  306. },
  307. // Is the DOM ready to be used? Set to true once it occurs.
  308. isReady: false,
  309. // A counter to track how many items to wait for before
  310. // the ready event fires. See #6781
  311. readyWait: 1,
  312. // Handle when the DOM is ready
  313. ready: function( wait ) {
  314. // A third-party is pushing the ready event forwards
  315. if ( wait === true ) {
  316. jQuery.readyWait--;
  317. }
  318. // Make sure that the DOM is not already loaded
  319. if ( !jQuery.readyWait || (wait !== true && !jQuery.isReady) ) {
  320. // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
  321. if ( !document.body ) {
  322. return setTimeout( jQuery.ready, 1 );
  323. }
  324. // Remember that the DOM is ready
  325. jQuery.isReady = true;
  326. // If a normal DOM Ready event fired, decrement, and wait if need be
  327. if ( wait !== true && --jQuery.readyWait > 0 ) {
  328. return;
  329. }
  330. // If there are functions bound, to execute
  331. readyList.resolveWith( document, [ jQuery ] );
  332. // Trigger any bound ready events
  333. if ( jQuery.fn.trigger ) {
  334. jQuery( document ).trigger( "ready" ).unbind( "ready" );
  335. }
  336. }
  337. },
  338. bindReady: function() {
  339. if ( readyBound ) {
  340. return;
  341. }
  342. readyBound = true;
  343. // Catch cases where $(document).ready() is called after the
  344. // browser event has already occurred.
  345. if ( document.readyState === "complete" ) {
  346. // Handle it asynchronously to allow scripts the opportunity to delay ready
  347. return setTimeout( jQuery.ready, 1 );
  348. }
  349. // Mozilla, Opera and webkit nightlies currently support this event
  350. if ( document.addEventListener ) {
  351. // Use the handy event callback
  352. document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
  353. // A fallback to window.onload, that will always work
  354. window.addEventListener( "load", jQuery.ready, false );
  355. // If IE event model is used
  356. } else if ( document.attachEvent ) {
  357. // ensure firing before onload,
  358. // maybe late but safe also for iframes
  359. document.attachEvent("onreadystatechange", DOMContentLoaded);
  360. // A fallback to window.onload, that will always work
  361. window.attachEvent( "onload", jQuery.ready );
  362. // If IE and not a frame
  363. // continually check to see if the document is ready
  364. var toplevel = false;
  365. try {
  366. toplevel = window.frameElement == null;
  367. } catch(e) {}
  368. if ( document.documentElement.doScroll && toplevel ) {
  369. doScrollCheck();
  370. }
  371. }
  372. },
  373. // See test/unit/core.js for details concerning isFunction.
  374. // Since version 1.3, DOM methods and functions like alert
  375. // aren't supported. They return false on IE (#2968).
  376. isFunction: function( obj ) {
  377. return jQuery.type(obj) === "function";
  378. },
  379. isArray: Array.isArray || function( obj ) {
  380. return jQuery.type(obj) === "array";
  381. },
  382. // A crude way of determining if an object is a window
  383. isWindow: function( obj ) {
  384. return obj && typeof obj === "object" && "setInterval" in obj;
  385. },
  386. isNaN: function( obj ) {
  387. return obj == null || !rdigit.test( obj ) || isNaN( obj );
  388. },
  389. type: function( obj ) {
  390. return obj == null ?
  391. String( obj ) :
  392. class2type[ toString.call(obj) ] || "object";
  393. },
  394. isPlainObject: function( obj ) {
  395. // Must be an Object.
  396. // Because of IE, we also have to check the presence of the constructor property.
  397. // Make sure that DOM nodes and window objects don't pass through, as well
  398. if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
  399. return false;
  400. }
  401. // Not own constructor property must be Object
  402. if ( obj.constructor &&
  403. !hasOwn.call(obj, "constructor") &&
  404. !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
  405. return false;
  406. }
  407. // Own properties are enumerated firstly, so to speed up,
  408. // if last one is own, then all properties are own.
  409. var key;
  410. for ( key in obj ) {}
  411. return key === undefined || hasOwn.call( obj, key );
  412. },
  413. isEmptyObject: function( obj ) {
  414. for ( var name in obj ) {
  415. return false;
  416. }
  417. return true;
  418. },
  419. error: function( msg ) {
  420. throw msg;
  421. },
  422. parseJSON: function( data ) {
  423. if ( typeof data !== "string" || !data ) {
  424. return null;
  425. }
  426. // Make sure leading/trailing whitespace is removed (IE can't handle it)
  427. data = jQuery.trim( data );
  428. // Make sure the incoming data is actual JSON
  429. // Logic borrowed from http://json.org/json2.js
  430. if ( rvalidchars.test(data.replace(rvalidescape, "@")
  431. .replace(rvalidtokens, "]")
  432. .replace(rvalidbraces, "")) ) {
  433. // Try to use the native JSON parser first
  434. return window.JSON && window.JSON.parse ?
  435. window.JSON.parse( data ) :
  436. (new Function("return " + data))();
  437. } else {
  438. jQuery.error( "Invalid JSON: " + data );
  439. }
  440. },
  441. // Cross-browser xml parsing
  442. // (xml & tmp used internally)
  443. parseXML: function( data , xml , tmp ) {
  444. if ( window.DOMParser ) { // Standard
  445. tmp = new DOMParser();
  446. xml = tmp.parseFromString( data , "text/xml" );
  447. } else { // IE
  448. xml = new ActiveXObject( "Microsoft.XMLDOM" );
  449. xml.async = "false";
  450. xml.loadXML( data );
  451. }
  452. tmp = xml.documentElement;
  453. if ( ! tmp || ! tmp.nodeName || tmp.nodeName === "parsererror" ) {
  454. jQuery.error( "Invalid XML: " + data );
  455. }
  456. return xml;
  457. },
  458. noop: function() {},
  459. // Evalulates a script in a global context
  460. globalEval: function( data ) {
  461. if ( data && rnotwhite.test(data) ) {
  462. // Inspired by code by Andrea Giammarchi
  463. // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
  464. var head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement,
  465. script = document.createElement( "script" );
  466. if ( jQuery.support.scriptEval() ) {
  467. script.appendChild( document.createTextNode( data ) );
  468. } else {
  469. script.text = data;
  470. }
  471. // Use insertBefore instead of appendChild to circumvent an IE6 bug.
  472. // This arises when a base node is used (#2709).
  473. head.insertBefore( script, head.firstChild );
  474. head.removeChild( script );
  475. }
  476. },
  477. nodeName: function( elem, name ) {
  478. return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
  479. },
  480. // args is for internal usage only
  481. each: function( object, callback, args ) {
  482. var name, i = 0,
  483. length = object.length,
  484. isObj = length === undefined || jQuery.isFunction(object);
  485. if ( args ) {
  486. if ( isObj ) {
  487. for ( name in object ) {
  488. if ( callback.apply( object[ name ], args ) === false ) {
  489. break;
  490. }
  491. }
  492. } else {
  493. for ( ; i < length; ) {
  494. if ( callback.apply( object[ i++ ], args ) === false ) {
  495. break;
  496. }
  497. }
  498. }
  499. // A special, fast, case for the most common use of each
  500. } else {
  501. if ( isObj ) {
  502. for ( name in object ) {
  503. if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
  504. break;
  505. }
  506. }
  507. } else {
  508. for ( var value = object[0];
  509. i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {}
  510. }
  511. }
  512. return object;
  513. },
  514. // Use native String.trim function wherever possible
  515. trim: trim ?
  516. function( text ) {
  517. return text == null ?
  518. "" :
  519. trim.call( text );
  520. } :
  521. // Otherwise use our own trimming functionality
  522. function( text ) {
  523. return text == null ?
  524. "" :
  525. text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
  526. },
  527. // results is for internal usage only
  528. makeArray: function( array, results ) {
  529. var ret = results || [];
  530. if ( array != null ) {
  531. // The window, strings (and functions) also have 'length'
  532. // The extra typeof function check is to prevent crashes
  533. // in Safari 2 (See: #3039)
  534. // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
  535. var type = jQuery.type(array);
  536. if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
  537. push.call( ret, array );
  538. } else {
  539. jQuery.merge( ret, array );
  540. }
  541. }
  542. return ret;
  543. },
  544. inArray: function( elem, array ) {
  545. if ( array.indexOf ) {
  546. return array.indexOf( elem );
  547. }
  548. for ( var i = 0, length = array.length; i < length; i++ ) {
  549. if ( array[ i ] === elem ) {
  550. return i;
  551. }
  552. }
  553. return -1;
  554. },
  555. merge: function( first, second ) {
  556. var i = first.length,
  557. j = 0;
  558. if ( typeof second.length === "number" ) {
  559. for ( var l = second.length; j < l; j++ ) {
  560. first[ i++ ] = second[ j ];
  561. }
  562. } else {
  563. while ( second[j] !== undefined ) {
  564. first[ i++ ] = second[ j++ ];
  565. }
  566. }
  567. first.length = i;
  568. return first;
  569. },
  570. grep: function( elems, callback, inv ) {
  571. var ret = [], retVal;
  572. inv = !!inv;
  573. // Go through the array, only saving the items
  574. // that pass the validator function
  575. for ( var i = 0, length = elems.length; i < length; i++ ) {
  576. retVal = !!callback( elems[ i ], i );
  577. if ( inv !== retVal ) {
  578. ret.push( elems[ i ] );
  579. }
  580. }
  581. return ret;
  582. },
  583. // arg is for internal usage only
  584. map: function( elems, callback, arg ) {
  585. var ret = [], value;
  586. // Go through the array, translating each of the items to their
  587. // new value (or values).
  588. for ( var i = 0, length = elems.length; i < length; i++ ) {
  589. value = callback( elems[ i ], i, arg );
  590. if ( value != null ) {
  591. ret[ ret.length ] = value;
  592. }
  593. }
  594. // Flatten any nested arrays
  595. return ret.concat.apply( [], ret );
  596. },
  597. // A global GUID counter for objects
  598. guid: 1,
  599. proxy: function( fn, proxy, thisObject ) {
  600. if ( arguments.length === 2 ) {
  601. if ( typeof proxy === "string" ) {
  602. thisObject = fn;
  603. fn = thisObject[ proxy ];
  604. proxy = undefined;
  605. } else if ( proxy && !jQuery.isFunction( proxy ) ) {
  606. thisObject = proxy;
  607. proxy = undefined;
  608. }
  609. }
  610. if ( !proxy && fn ) {
  611. proxy = function() {
  612. return fn.apply( thisObject || this, arguments );
  613. };
  614. }
  615. // Set the guid of unique handler to the same of original handler, so it can be removed
  616. if ( fn ) {
  617. proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
  618. }
  619. // So proxy can be declared as an argument
  620. return proxy;
  621. },
  622. // Mutifunctional method to get and set values to a collection
  623. // The value/s can be optionally by executed if its a function
  624. access: function( elems, key, value, exec, fn, pass ) {
  625. var length = elems.length;
  626. // Setting many attributes
  627. if ( typeof key === "object" ) {
  628. for ( var k in key ) {
  629. jQuery.access( elems, k, key[k], exec, fn, value );
  630. }
  631. return elems;
  632. }
  633. // Setting one attribute
  634. if ( value !== undefined ) {
  635. // Optionally, function values get executed if exec is true
  636. exec = !pass && exec && jQuery.isFunction(value);
  637. for ( var i = 0; i < length; i++ ) {
  638. fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
  639. }
  640. return elems;
  641. }
  642. // Getting an attribute
  643. return length ? fn( elems[0], key ) : undefined;
  644. },
  645. now: function() {
  646. return (new Date()).getTime();
  647. },
  648. // Create a simple deferred (one callbacks list)
  649. _Deferred: function() {
  650. var // callbacks list
  651. callbacks = [],
  652. // stored [ context , args ]
  653. fired,
  654. // to avoid firing when already doing so
  655. firing,
  656. // flag to know if the deferred has been cancelled
  657. cancelled,
  658. // the deferred itself
  659. deferred = {
  660. // done( f1, f2, ...)
  661. done: function() {
  662. if ( !cancelled ) {
  663. var args = arguments,
  664. i,
  665. length,
  666. elem,
  667. type,
  668. _fired;
  669. if ( fired ) {
  670. _fired = fired;
  671. fired = 0;
  672. }
  673. for ( i = 0, length = args.length; i < length; i++ ) {
  674. elem = args[ i ];
  675. type = jQuery.type( elem );
  676. if ( type === "array" ) {
  677. deferred.done.apply( deferred, elem );
  678. } else if ( type === "function" ) {
  679. callbacks.push( elem );
  680. }
  681. }
  682. if ( _fired ) {
  683. deferred.resolveWith( _fired[ 0 ], _fired[ 1 ] );
  684. }
  685. }
  686. return this;
  687. },
  688. // resolve with given context and args
  689. resolveWith: function( context, args ) {
  690. if ( !cancelled && !fired && !firing ) {
  691. firing = 1;
  692. try {
  693. while( callbacks[ 0 ] ) {
  694. callbacks.shift().apply( context, args );
  695. }
  696. }
  697. // We have to add a catch block for
  698. // IE prior to 8 or else the finally
  699. // block will never get executed
  700. catch (e) {
  701. throw e;
  702. }
  703. finally {
  704. fired = [ context, args ];
  705. firing = 0;
  706. }
  707. }
  708. return this;
  709. },
  710. // resolve with this as context and given arguments
  711. resolve: function() {
  712. deferred.resolveWith( jQuery.isFunction( this.promise ) ? this.promise() : this, arguments );
  713. return this;
  714. },
  715. // Has this deferred been resolved?
  716. isResolved: function() {
  717. return !!( firing || fired );
  718. },
  719. // Cancel
  720. cancel: function() {
  721. cancelled = 1;
  722. callbacks = [];
  723. return this;
  724. }
  725. };
  726. return deferred;
  727. },
  728. // Full fledged deferred (two callbacks list)
  729. Deferred: function( func ) {
  730. var deferred = jQuery._Deferred(),
  731. failDeferred = jQuery._Deferred(),
  732. promise;
  733. // Add errorDeferred methods, then and promise
  734. jQuery.extend( deferred, {
  735. then: function( doneCallbacks, failCallbacks ) {
  736. deferred.done( doneCallbacks ).fail( failCallbacks );
  737. return this;
  738. },
  739. fail: failDeferred.done,
  740. rejectWith: failDeferred.resolveWith,
  741. reject: failDeferred.resolve,
  742. isRejected: failDeferred.isResolved,
  743. // Get a promise for this deferred
  744. // If obj is provided, the promise aspect is added to the object
  745. promise: function( obj ) {
  746. if ( obj == null ) {
  747. if ( promise ) {
  748. return promise;
  749. }
  750. promise = obj = {};
  751. }
  752. var i = promiseMethods.length;
  753. while( i-- ) {
  754. obj[ promiseMethods[i] ] = deferred[ promiseMethods[i] ];
  755. }
  756. return obj;
  757. }
  758. } );
  759. // Make sure only one callback list will be used
  760. deferred.done( failDeferred.cancel ).fail( deferred.cancel );
  761. // Unexpose cancel
  762. delete deferred.cancel;
  763. // Call given func if any
  764. if ( func ) {
  765. func.call( deferred, deferred );
  766. }
  767. return deferred;
  768. },
  769. // Deferred helper
  770. when: function( object ) {
  771. var lastIndex = arguments.length,
  772. deferred = lastIndex <= 1 && object && jQuery.isFunction( object.promise ) ?
  773. object :
  774. jQuery.Deferred(),
  775. promise = deferred.promise();
  776. if ( lastIndex > 1 ) {
  777. var array = slice.call( arguments, 0 ),
  778. count = lastIndex,
  779. iCallback = function( index ) {
  780. return function( value ) {
  781. array[ index ] = arguments.length > 1 ? slice.call( arguments, 0 ) : value;
  782. if ( !( --count ) ) {
  783. deferred.resolveWith( promise, array );
  784. }
  785. };
  786. };
  787. while( ( lastIndex-- ) ) {
  788. object = array[ lastIndex ];
  789. if ( object && jQuery.isFunction( object.promise ) ) {
  790. object.promise().then( iCallback(lastIndex), deferred.reject );
  791. } else {
  792. --count;
  793. }
  794. }
  795. if ( !count ) {
  796. deferred.resolveWith( promise, array );
  797. }
  798. } else if ( deferred !== object ) {
  799. deferred.resolve( object );
  800. }
  801. return promise;
  802. },
  803. // Use of jQuery.browser is frowned upon.
  804. // More details: http://docs.jquery.com/Utilities/jQuery.browser
  805. uaMatch: function( ua ) {
  806. ua = ua.toLowerCase();
  807. var match = rwebkit.exec( ua ) ||
  808. ropera.exec( ua ) ||
  809. rmsie.exec( ua ) ||
  810. ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
  811. [];
  812. return { browser: match[1] || "", version: match[2] || "0" };
  813. },
  814. sub: function() {
  815. function jQuerySubclass( selector, context ) {
  816. return new jQuerySubclass.fn.init( selector, context );
  817. }
  818. jQuery.extend( true, jQuerySubclass, this );
  819. jQuerySubclass.superclass = this;
  820. jQuerySubclass.fn = jQuerySubclass.prototype = this();
  821. jQuerySubclass.fn.constructor = jQuerySubclass;
  822. jQuerySubclass.subclass = this.subclass;
  823. jQuerySubclass.fn.init = function init( selector, context ) {
  824. if ( context && context instanceof jQuery && !(context instanceof jQuerySubclass) ) {
  825. context = jQuerySubclass(context);
  826. }
  827. return jQuery.fn.init.call( this, selector, context, rootjQuerySubclass );
  828. };
  829. jQuerySubclass.fn.init.prototype = jQuerySubclass.fn;
  830. var rootjQuerySubclass = jQuerySubclass(document);
  831. return jQuerySubclass;
  832. },
  833. browser: {}
  834. });
  835. // Create readyList deferred
  836. readyList = jQuery._Deferred();
  837. // Populate the class2type map
  838. jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
  839. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  840. });
  841. browserMatch = jQuery.uaMatch( userAgent );
  842. if ( browserMatch.browser ) {
  843. jQuery.browser[ browserMatch.browser ] = true;
  844. jQuery.browser.version = browserMatch.version;
  845. }
  846. // Deprecated, use jQuery.browser.webkit instead
  847. if ( jQuery.browser.webkit ) {
  848. jQuery.browser.safari = true;
  849. }
  850. if ( indexOf ) {
  851. jQuery.inArray = function( elem, array ) {
  852. return indexOf.call( array, elem );
  853. };
  854. }
  855. // IE doesn't match non-breaking spaces with \s
  856. if ( rnotwhite.test( "\xA0" ) ) {
  857. trimLeft = /^[\s\xA0]+/;
  858. trimRight = /[\s\xA0]+$/;
  859. }
  860. // All jQuery objects should point back to these
  861. rootjQuery = jQuery(document);
  862. // Cleanup functions for the document ready method
  863. if ( document.addEventListener ) {
  864. DOMContentLoaded = function() {
  865. document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
  866. jQuery.ready();
  867. };
  868. } else if ( document.attachEvent ) {
  869. DOMContentLoaded = function() {
  870. // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
  871. if ( document.readyState === "complete" ) {
  872. document.detachEvent( "onreadystatechange", DOMContentLoaded );
  873. jQuery.ready();
  874. }
  875. };
  876. }
  877. // The DOM ready check for Internet Explorer
  878. function doScrollCheck() {
  879. if ( jQuery.isReady ) {
  880. return;
  881. }
  882. try {
  883. // If IE is used, use the trick by Diego Perini
  884. // http://javascript.nwbox.com/IEContentLoaded/
  885. document.documentElement.doScroll("left");
  886. } catch(e) {
  887. setTimeout( doScrollCheck, 1 );
  888. return;
  889. }
  890. // and execute any waiting functions
  891. jQuery.ready();
  892. }
  893. // Expose jQuery to the global object
  894. return jQuery;
  895. })();
  896. (function() {
  897. jQuery.support = {};
  898. var div = document.createElement("div");
  899. div.style.display = "none";
  900. div.innerHTML = " <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
  901. var all = div.getElementsByTagName("*"),
  902. a = div.getElementsByTagName("a")[0],
  903. select = document.createElement("select"),
  904. opt = select.appendChild( document.createElement("option") ),
  905. input = div.getElementsByTagName("input")[0];
  906. // Can't get basic test support
  907. if ( !all || !all.length || !a ) {
  908. return;
  909. }
  910. jQuery.support = {
  911. // IE strips leading whitespace when .innerHTML is used
  912. leadingWhitespace: div.firstChild.nodeType === 3,
  913. // Make sure that tbody elements aren't automatically inserted
  914. // IE will insert them into empty tables
  915. tbody: !div.getElementsByTagName("tbody").length,
  916. // Make sure that link elements get serialized correctly by innerHTML
  917. // This requires a wrapper element in IE
  918. htmlSerialize: !!div.getElementsByTagName("link").length,
  919. // Get the style information from getAttribute
  920. // (IE uses .cssText insted)
  921. style: /red/.test( a.getAttribute("style") ),
  922. // Make sure that URLs aren't manipulated
  923. // (IE normalizes it by default)
  924. hrefNormalized: a.getAttribute("href") === "/a",
  925. // Make sure that element opacity exists
  926. // (IE uses filter instead)
  927. // Use a regex to work around a WebKit issue. See #5145
  928. opacity: /^0.55$/.test( a.style.opacity ),
  929. // Verify style float existence
  930. // (IE uses styleFloat instead of cssFloat)
  931. cssFloat: !!a.style.cssFloat,
  932. // Make sure that if no value is specified for a checkbox
  933. // that it defaults to "on".
  934. // (WebKit defaults to "" instead)
  935. checkOn: input.value === "on",
  936. // Make sure that a selected-by-default option has a working selected property.
  937. // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
  938. optSelected: opt.selected,
  939. // Will be defined later
  940. deleteExpando: true,
  941. optDisabled: false,
  942. checkClone: false,
  943. noCloneEvent: true,
  944. noCloneChecked: true,
  945. boxModel: null,
  946. inlineBlockNeedsLayout: false,
  947. shrinkWrapBlocks: false,
  948. reliableHiddenOffsets: true
  949. };
  950. input.checked = true;
  951. jQuery.support.noCloneChecked = input.cloneNode( true ).checked;
  952. // Make sure that the options inside disabled selects aren't marked as disabled
  953. // (WebKit marks them as diabled)
  954. select.disabled = true;
  955. jQuery.support.optDisabled = !opt.disabled;
  956. var _scriptEval = null;
  957. jQuery.support.scriptEval = function() {
  958. if ( _scriptEval === null ) {
  959. var root = document.documentElement,
  960. script = document.createElement("script"),
  961. id = "script" + jQuery.now();
  962. try {
  963. script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
  964. } catch(e) {}
  965. root.insertBefore( script, root.firstChild );
  966. // Make sure that the execution of code works by injecting a script
  967. // tag with appendChild/createTextNode
  968. // (IE doesn't support this, fails, and uses .text instead)
  969. if ( window[ id ] ) {
  970. _scriptEval = true;
  971. delete window[ id ];
  972. } else {
  973. _scriptEval = false;
  974. }
  975. root.removeChild( script );
  976. // release memory in IE
  977. root = script = id = null;
  978. }
  979. return _scriptEval;
  980. };
  981. // Test to see if it's possible to delete an expando from an element
  982. // Fails in Internet Explorer
  983. try {
  984. delete div.test;
  985. } catch(e) {
  986. jQuery.support.deleteExpando = false;
  987. }
  988. if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
  989. div.attachEvent("onclick", function click() {
  990. // Cloning a node shouldn't copy over any
  991. // bound event handlers (IE does this)
  992. jQuery.support.noCloneEvent = false;
  993. div.detachEvent("onclick", click);
  994. });
  995. div.cloneNode(true).fireEvent("onclick");
  996. }
  997. div = document.createElement("div");
  998. div.innerHTML = "<input type='radio' name='radiotest' checked='checked'/>";
  999. var fragment = document.createDocumentFragment();
  1000. fragment.appendChild( div.firstChild );
  1001. // WebKit doesn't clone checked state correctly in fragments
  1002. jQuery.support.checkClone = fragment.cloneNode(true).cloneNode(true).lastChild.checked;
  1003. // Figure out if the W3C box model works as expected
  1004. // document.body must exist before we can do this
  1005. jQuery(function() {
  1006. var div = document.createElement("div"),
  1007. body = document.getElementsByTagName("body")[0];
  1008. // Frameset documents with no body should not run this code
  1009. if ( !body ) {
  1010. return;
  1011. }
  1012. div.style.width = div.style.paddingLeft = "1px";
  1013. body.appendChild( div );
  1014. jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2;
  1015. if ( "zoom" in div.style ) {
  1016. // Check if natively block-level elements act like inline-block
  1017. // elements when setting their display to 'inline' and giving
  1018. // them layout
  1019. // (IE < 8 does this)
  1020. div.style.display = "inline";
  1021. div.style.zoom = 1;
  1022. jQuery.support.inlineBlockNeedsLayout = div.offsetWidth === 2;
  1023. // Check if elements with layout shrink-wrap their children
  1024. // (IE 6 does this)
  1025. div.style.display = "";
  1026. div.innerHTML = "<div style='width:4px;'></div>";
  1027. jQuery.support.shrinkWrapBlocks = div.offsetWidth !== 2;
  1028. }
  1029. div.innerHTML = "<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>";
  1030. var tds = div.getElementsByTagName("td");
  1031. // Check if table cells still have offsetWidth/Height when they are set
  1032. // to display:none and there are still other visible table cells in a
  1033. // table row; if so, offsetWidth/Height are not reliable for use when
  1034. // determining if an element has been hidden directly using
  1035. // display:none (it is still safe to use offsets if a parent element is
  1036. // hidden; don safety goggles and see bug #4512 for more information).
  1037. // (only IE 8 fails this test)
  1038. jQuery.support.reliableHiddenOffsets = tds[0].offsetHeight === 0;
  1039. tds[0].style.display = "";
  1040. tds[1].style.display = "none";
  1041. // Check if empty table cells still have offsetWidth/Height
  1042. // (IE < 8 fail this test)
  1043. jQuery.support.reliableHiddenOffsets = jQuery.support.reliableHiddenOffsets && tds[0].offsetHeight === 0;
  1044. div.innerHTML = "";
  1045. body.removeChild( div ).style.display = "none";
  1046. div = tds = null;
  1047. });
  1048. // Technique from Juriy Zaytsev
  1049. // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
  1050. var eventSupported = function( eventName ) {
  1051. var el = document.createElement("div");
  1052. eventName = "on" + eventName;
  1053. // We only care about the case where non-standard event systems
  1054. // are used, namely in IE. Short-circuiting here helps us to
  1055. // avoid an eval call (in setAttribute) which can cause CSP
  1056. // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
  1057. if ( !el.attachEvent ) {
  1058. return true;
  1059. }
  1060. var isSupported = (eventName in el);
  1061. if ( !isSupported ) {
  1062. el.setAttribute(eventName, "return;");
  1063. isSupported = typeof el[eventName] === "function";
  1064. }
  1065. el = null;
  1066. return isSupported;
  1067. };
  1068. jQuery.support.submitBubbles = eventSupported("submit");
  1069. jQuery.support.changeBubbles = eventSupported("change");
  1070. // release memory in IE
  1071. div = all = a = null;
  1072. })();
  1073. var rbrace = /^(?:\{.*\}|\[.*\])$/;
  1074. jQuery.extend({
  1075. cache: {},
  1076. // Please use with caution
  1077. uuid: 0,
  1078. // Unique for each copy of jQuery on the page
  1079. // Non-digits removed to match rinlinejQuery
  1080. expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),
  1081. // The following elements throw uncatchable exceptions if you
  1082. // attempt to add expando properties to them.
  1083. noData: {
  1084. "embed": true,
  1085. // Ban all objects except for Flash (which handle expandos)
  1086. "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
  1087. "applet": true
  1088. },
  1089. hasData: function( elem ) {
  1090. elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
  1091. return !!elem && !isEmptyDataObject( elem );
  1092. },
  1093. data: function( elem, name, data, pvt /* Internal Use Only */ ) {
  1094. if ( !jQuery.acceptData( elem ) ) {
  1095. return;
  1096. }
  1097. var internalKey = jQuery.expando, getByName = typeof name === "string", thisCache,
  1098. // We have to handle DOM nodes and JS objects differently because IE6-7
  1099. // can't GC object references properly across the DOM-JS boundary
  1100. isNode = elem.nodeType,
  1101. // Only DOM nodes need the global jQuery cache; JS object data is
  1102. // attached directly to the object so GC can occur automatically
  1103. cache = isNode ? jQuery.cache : elem,
  1104. // Only defining an ID for JS objects if its cache already exists allows
  1105. // the code to shortcut on the same path as a DOM node with no cache
  1106. id = isNode ? elem[ jQuery.expando ] : elem[ jQuery.expando ] && jQuery.expando;
  1107. // Avoid doing any more work than we need to when trying to get data on an
  1108. // object that has no data at all
  1109. if ( (!id || (pvt && id && !cache[ id ][ internalKey ])) && getByName && data === undefined ) {
  1110. return;
  1111. }
  1112. if ( !id ) {
  1113. // Only DOM nodes need a new unique ID for each element since their data
  1114. // ends up in the global cache
  1115. if ( isNode ) {
  1116. elem[ jQuery.expando ] = id = ++jQuery.uuid;
  1117. } else {
  1118. id = jQuery.expando;
  1119. }
  1120. }
  1121. if ( !cache[ id ] ) {
  1122. cache[ id ] = {};
  1123. // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
  1124. // metadata on plain JS objects when the object is serialized using
  1125. // JSON.stringify
  1126. if ( !isNode ) {
  1127. cache[ id ].toJSON = jQuery.noop;
  1128. }
  1129. }
  1130. // An object can be passed to jQuery.data instead of a key/value pair; this gets
  1131. // shallow copied over onto the existing cache
  1132. if ( typeof name === "object" || typeof name === "function" ) {
  1133. if ( pvt ) {
  1134. cache[ id ][ internalKey ] = jQuery.extend(cache[ id ][ internalKey ], name);
  1135. } else {
  1136. cache[ id ] = jQuery.extend(cache[ id ], name);
  1137. }
  1138. }
  1139. thisCache = cache[ id ];
  1140. // Internal jQuery data is stored in a separate object inside the object's data
  1141. // cache in order to avoid key collisions between internal data and user-defined
  1142. // data
  1143. if ( pvt ) {
  1144. if ( !thisCache[ internalKey ] ) {
  1145. thisCache[ internalKey ] = {};
  1146. }
  1147. thisCache = thisCache[ internalKey ];
  1148. }
  1149. if ( data !== undefined ) {
  1150. thisCache[ name ] = data;
  1151. }
  1152. // TODO: This is a hack for 1.5 ONLY. It will be removed in 1.6. Users should
  1153. // not attempt to inspect the internal events object using jQuery.data, as this
  1154. // internal data object is undocumented and subject to change.
  1155. if ( name === "events" && !thisCache[name] ) {
  1156. return thisCache[ internalKey ] && thisCache[ internalKey ].events;
  1157. }
  1158. return getByName ? thisCache[ name ] : thisCache;
  1159. },
  1160. removeData: function( elem, name, pvt /* Internal Use Only */ ) {
  1161. if ( !jQuery.acceptData( elem ) ) {
  1162. return;
  1163. }
  1164. var internalKey = jQuery.expando, isNode = elem.nodeType,
  1165. // See jQuery.data for more information
  1166. cache = isNode ? jQuery.cache : elem,
  1167. // See jQuery.data for more information
  1168. id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
  1169. // If there is already no cache entry for this object, there is no
  1170. // purpose in continuing
  1171. if ( !cache[ id ] ) {
  1172. return;
  1173. }
  1174. if ( name ) {
  1175. var thisCache = pvt ? cache[ id ][ internalKey ] : cache[ id ];
  1176. if ( thisCache ) {
  1177. delete thisCache[ name ];
  1178. // If there is no data left in the cache, we want to continue
  1179. // and let the cache object itself get destroyed
  1180. if ( !isEmptyDataObject(thisCache) ) {
  1181. return;
  1182. }
  1183. }
  1184. }
  1185. // See jQuery.data for more information
  1186. if ( pvt ) {
  1187. delete cache[ id ][ internalKey ];
  1188. // Don't destroy the parent cache unless the internal data object
  1189. // had been the only thing left in it
  1190. if ( !isEmptyDataObject(cache[ id ]) ) {
  1191. return;
  1192. }
  1193. }
  1194. var internalCache = cache[ id ][ internalKey ];
  1195. // Browsers that fail expando deletion also refuse to delete expandos on
  1196. // the window, but it will allow it on all other JS objects; other browsers
  1197. // don't care
  1198. if ( jQuery.support.deleteExpando || cache != window ) {
  1199. delete cache[ id ];
  1200. } else {
  1201. cache[ id ] = null;
  1202. }
  1203. // We destroyed the entire user cache at once because it's faster than
  1204. // iterating through each key, but we need to continue to persist internal
  1205. // data if it existed
  1206. if ( internalCache ) {
  1207. cache[ id ] = {};
  1208. // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
  1209. // metadata on plain JS objects when the object is serialized using
  1210. // JSON.stringify
  1211. if ( !isNode ) {
  1212. cache[ id ].toJSON = jQuery.noop;
  1213. }
  1214. cache[ id ][ internalKey ] = internalCache;
  1215. // Otherwise, we need to eliminate the expando on the node to avoid
  1216. // false lookups in the cache for entries that no longer exist
  1217. } else if ( isNode ) {
  1218. // IE does not allow us to delete expando properties from nodes,
  1219. // nor does it have a removeAttribute function on Document nodes;
  1220. // we must handle all of these cases
  1221. if ( jQuery.support.deleteExpando ) {
  1222. delete elem[ jQuery.expando ];
  1223. } else if ( elem.removeAttribute ) {
  1224. elem.removeAttribute( jQuery.expando );
  1225. } else {
  1226. elem[ jQuery.expando ] = null;
  1227. }
  1228. }
  1229. },
  1230. // For internal use only.
  1231. _data: function( elem, name, data ) {
  1232. return jQuery.data( elem, name, data, true );
  1233. },
  1234. // A method for determining if a DOM node can handle the data expando
  1235. acceptData: function( elem ) {
  1236. if ( elem.nodeName ) {
  1237. var match = jQuery.noData[ elem.nodeName.toLowerCase() ];
  1238. if ( match ) {
  1239. return !(match === true || elem.getAttribute("classid") !== match);
  1240. }
  1241. }
  1242. return true;
  1243. }
  1244. });
  1245. jQuery.fn.extend({
  1246. data: function( key, value ) {
  1247. var data = null;
  1248. if ( typeof key === "undefined" ) {
  1249. if ( this.length ) {
  1250. data = jQuery.data( this[0] );
  1251. if ( this[0].nodeType === 1 ) {
  1252. var attr = this[0].attributes, name;
  1253. for ( var i = 0, l = attr.length; i < l; i++ ) {
  1254. name = attr[i].name;
  1255. if ( name.indexOf( "data-" ) === 0 ) {
  1256. name = name.substr( 5 );
  1257. dataAttr( this[0], name, data[ name ] );
  1258. }
  1259. }
  1260. }
  1261. }
  1262. return data;
  1263. } else if ( typeof key === "object" ) {
  1264. return this.each(function() {
  1265. jQuery.data( this, key );
  1266. });
  1267. }
  1268. var parts = key.split(".");
  1269. parts[1] = parts[1] ? "." + parts[1] : "";
  1270. if ( value === undefined ) {
  1271. data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
  1272. // Try to fetch any internally stored data first
  1273. if ( data === undefined && this.length ) {
  1274. data = jQuery.data( this[0], key );
  1275. data = dataAttr( this[0], key, data );
  1276. }
  1277. return data === undefined && parts[1] ?
  1278. this.data( parts[0] ) :
  1279. data;
  1280. } else {
  1281. return this.each(function() {
  1282. var $this = jQuery( this ),
  1283. args = [ parts[0], value ];
  1284. $this.triggerHandler( "setData" + parts[1] + "!", args );
  1285. jQuery.data( this, key, value );
  1286. $this.triggerHandler( "changeData" + parts[1] + "!", args );
  1287. });
  1288. }
  1289. },
  1290. removeData: function( key ) {
  1291. return this.each(function() {
  1292. jQuery.removeData( this, key );
  1293. });
  1294. }
  1295. });
  1296. function dataAttr( elem, key, data ) {
  1297. // If nothing was found internally, try to fetch any
  1298. // data from the HTML5 data-* attribute
  1299. if ( data === undefined && elem.nodeType === 1 ) {
  1300. data = elem.getAttribute( "data-" + key );
  1301. if ( typeof data === "string" ) {
  1302. try {
  1303. data = data === "true" ? true :
  1304. data === "false" ? false :
  1305. data === "null" ? null :
  1306. !jQuery.isNaN( data ) ? parseFloat( data ) :
  1307. rbrace.test( data ) ? jQuery.parseJSON( data ) :
  1308. data;
  1309. } catch( e ) {}
  1310. // Make sure we set the data so it isn't changed later
  1311. jQuery.data( elem, key, data );
  1312. } else {
  1313. data = undefined;
  1314. }
  1315. }
  1316. return data;
  1317. }
  1318. // TODO: This is a hack for 1.5 ONLY to allow objects with a single toJSON
  1319. // property to be considered empty objects; this property always exists in
  1320. // order to make sure JSON.stringify does not expose internal metadata
  1321. function isEmptyDataObject( obj ) {
  1322. for ( var name in obj ) {
  1323. if ( name !== "toJSON" ) {
  1324. return false;
  1325. }
  1326. }
  1327. return true;
  1328. }
  1329. jQuery.extend({
  1330. queue: function( elem, type, data ) {
  1331. if ( !elem ) {
  1332. return;
  1333. }
  1334. type = (type || "fx") + "queue";
  1335. var q = jQuery._data( elem, type );
  1336. // Speed up dequeue by getting out quickly if this is just a lookup
  1337. if ( !data ) {
  1338. return q || [];
  1339. }
  1340. if ( !q || jQuery.isArray(data) ) {
  1341. q = jQuery._data( elem, type, jQuery.makeArray(data) );
  1342. } else {
  1343. q.push( data );
  1344. }
  1345. return q;
  1346. },
  1347. dequeue: function( elem, type ) {
  1348. type = type || "fx";
  1349. var queue = jQuery.queue( elem, type ),
  1350. fn = queue.shift();
  1351. // If the fx queue is dequeued, always remove the progress sentinel
  1352. if ( fn === "inprogress" ) {
  1353. fn = queue.shift();
  1354. }
  1355. if ( fn ) {
  1356. // Add a progress sentinel to prevent the fx queue from being
  1357. // automatically dequeued
  1358. if ( type === "fx" ) {
  1359. queue.unshift("inprogress");
  1360. }
  1361. fn.call(elem, function() {
  1362. jQuery.dequeue(elem, type);
  1363. });
  1364. }
  1365. if ( !queue.length ) {
  1366. jQuery.removeData( elem, type + "queue", true );
  1367. }
  1368. }
  1369. });
  1370. jQuery.fn.extend({
  1371. queue: function( type, data ) {
  1372. if ( typeof type !== "string" ) {
  1373. data = type;
  1374. type = "fx";
  1375. }
  1376. if ( data === undefined ) {
  1377. return jQuery.queue( this[0], type );
  1378. }
  1379. return this.each(function( i ) {
  1380. var queue = jQuery.queue( this, type, data );
  1381. if ( type === "fx" && queue[0] !== "inprogress" ) {
  1382. jQuery.dequeue( this, type );
  1383. }
  1384. });
  1385. },
  1386. dequeue: function( type ) {
  1387. return this.each(function() {
  1388. jQuery.dequeue( this, type );
  1389. });
  1390. },
  1391. // Based off of the plugin by Clint Helfers, with permission.
  1392. // http://blindsignals.com/index.php/2009/07/jquery-delay/
  1393. delay: function( time, type ) {
  1394. time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
  1395. type = type || "fx";
  1396. return this.queue( type, function() {
  1397. var elem = this;
  1398. setTimeout(function() {
  1399. jQuery.dequeue( elem, type );
  1400. }, time );
  1401. });
  1402. },
  1403. clearQueue: function( type ) {
  1404. return this.queue( type || "fx", [] );
  1405. }
  1406. });
  1407. var rclass = /[\n\t\r]/g,
  1408. rspaces = /\s+/,
  1409. rreturn = /\r/g,
  1410. rspecialurl = /^(?:href|src|style)$/,
  1411. rtype = /^(?:button|input)$/i,
  1412. rfocusable = /^(?:button|input|object|select|textarea)$/i,
  1413. rclickable = /^a(?:rea)?$/i,
  1414. rradiocheck = /^(?:radio|checkbox)$/i;
  1415. jQuery.props = {
  1416. "for": "htmlFor",
  1417. "class": "className",
  1418. readonly: "readOnly",
  1419. maxlength: "maxLength",
  1420. cellspacing: "cellSpacing",
  1421. rowspan: "rowSpan",
  1422. colspan: "colSpan",
  1423. tabindex: "tabIndex",
  1424. usemap: "useMap",
  1425. frameborder: "frameBorder"
  1426. };
  1427. jQuery.fn.extend({
  1428. attr: function( name, value ) {
  1429. return jQuery.access( this, name, value, true, jQuery.attr );
  1430. },
  1431. removeAttr: function( name, fn ) {
  1432. return this.each(function(){
  1433. jQuery.attr( this, name, "" );
  1434. if ( this.nodeType === 1 ) {
  1435. this.removeAttribute( name );
  1436. }
  1437. });
  1438. },
  1439. addClass: function( value ) {
  1440. if ( jQuery.isFunction(value) ) {
  1441. return this.each(function(i) {
  1442. var self = jQuery(this);
  1443. self.addClass( value.call(this, i, self.attr("class")) );
  1444. });
  1445. }
  1446. if ( value && typeof value === "string" ) {
  1447. var classNames = (value || "").split( rspaces );
  1448. for ( var i = 0, l = this.length; i < l; i++ ) {
  1449. var elem = this[i];
  1450. if ( elem.nodeType === 1 ) {
  1451. if ( !elem.className ) {
  1452. elem.className = value;
  1453. } else {
  1454. var className = " " + elem.className + " ",
  1455. setClass = elem.className;
  1456. for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
  1457. if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) {
  1458. setClass += " " + classNames[c];
  1459. }
  1460. }
  1461. elem.className = jQuery.trim( setClass );
  1462. }
  1463. }
  1464. }
  1465. }
  1466. return this;
  1467. },
  1468. removeClass: function( value ) {
  1469. if ( jQuery.isFunction(value) ) {
  1470. return this.each(function(i) {
  1471. var self = jQuery(this);
  1472. self.removeClass( value.call(this, i, self.attr("class")) );
  1473. });
  1474. }
  1475. if ( (value && typeof value === "string") || value === undefined ) {
  1476. var classNames = (value || "").split( rspaces );
  1477. for ( var i = 0, l = this.length; i < l; i++ ) {
  1478. var elem = this[i];
  1479. if ( elem.nodeType === 1 && elem.className ) {
  1480. if ( value ) {
  1481. var className = (" " + elem.className + " ").replace(rclass, " ");
  1482. for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
  1483. className = className.replace(" " + classNames[c] + " ", " ");
  1484. }
  1485. elem.className = jQuery.trim( className );
  1486. } else {
  1487. elem.className = "";
  1488. }
  1489. }
  1490. }
  1491. }
  1492. return this;
  1493. },
  1494. toggleClass: function( value, stateVal ) {
  1495. var type = typeof value,
  1496. isBool = typeof stateVal === "boolean";
  1497. if ( jQuery.isFunction( value ) ) {
  1498. return this.each(function(i) {
  1499. var self = jQuery(this);
  1500. self.toggleClass( value.call(this, i, self.attr("class"), stateVal), stateVal );
  1501. });
  1502. }
  1503. return this.each(function() {
  1504. if ( type === "string" ) {
  1505. // toggle individual class names
  1506. var className,
  1507. i = 0,
  1508. self = jQuery( this ),
  1509. state = stateVal,
  1510. classNames = value.split( rspaces );
  1511. while ( (className = classNames[ i++ ]) ) {
  1512. // check each className given, space seperated list
  1513. state = isBool ? state : !self.hasClass( className );
  1514. self[ state ? "addClass" : "removeClass" ]( className );
  1515. }
  1516. } else if ( type === "undefined" || type === "boolean" ) {
  1517. if ( this.className ) {
  1518. // store className if set
  1519. jQuery._data( this, "__className__", this.className );
  1520. }
  1521. // toggle whole className
  1522. this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
  1523. }
  1524. });
  1525. },
  1526. hasClass: function( selector ) {
  1527. var className = " " + selector + " ";
  1528. for ( var i = 0, l = this.length; i < l; i++ ) {
  1529. if ( (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
  1530. return true;
  1531. }
  1532. }
  1533. return false;
  1534. },
  1535. val: function( value ) {
  1536. if ( !arguments.length ) {
  1537. var elem = this[0];
  1538. if ( elem ) {
  1539. if ( jQuery.nodeName( elem, "option" ) ) {
  1540. // attributes.value is undefined in Blackberry 4.7 but
  1541. // uses .value. See #6932
  1542. var val = elem.attributes.value;
  1543. return !val || val.specified ? elem.value : elem.text;
  1544. }
  1545. // We need to handle select boxes special
  1546. if ( jQuery.nodeName( elem, "select" ) ) {
  1547. var index = elem.selectedIndex,
  1548. values = [],
  1549. options = elem.options,
  1550. one = elem.type === "select-one";
  1551. // Nothing was sel…

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