/jquery/jquery.source.js

https://code.google.com/p/jq-watermark/ · JavaScript · 7179 lines · 5563 code · 939 blank · 677 comment · 980 complexity · 42c61c851258b620bc817383d07a2f58 MD5 · raw file

Large files are truncated click here to view the full file

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