/tags/1.1/src/main/webapp/js/jquery-1.4.1.js

http://jquery-stream.googlecode.com/ · JavaScript · 2489 lines · 1642 code · 476 blank · 371 comment · 527 complexity · 2eb478f7885959c6c627422f425c0cf8 MD5 · raw file

Large files are truncated click here to view the full file

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