PageRenderTime 66ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 1ms

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

http://jquery-stream.googlecode.com/
JavaScript | 2489 lines | 1946 code | 299 blank | 244 comment | 303 complexity | 2eb478f7885959c6c627422f425c0cf8 MD5 | raw 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 screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
  1535. fix: function( event ) {
  1536. if ( event[ expando ] ) {
  1537. return event;
  1538. }
  1539. // store a copy of the original event object
  1540. // and "clone" to set read-only properties
  1541. var originalEvent = event;
  1542. event = jQuery.Event( originalEvent );
  1543. for ( var i = this.props.length, prop; i; ) {
  1544. prop = this.props[ --i ];
  1545. event[ prop ] = originalEvent[ prop ];
  1546. }
  1547. // Fix target property, if necessary
  1548. if ( !event.target ) {
  1549. event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either
  1550. }
  1551. // check if target is a textnode (safari)
  1552. if ( event.target.nodeType === 3 ) {
  1553. event.target = event.target.parentNode;
  1554. }
  1555. // Add relatedTarget, if necessary
  1556. if ( !event.relatedTarget && event.fromElement ) {
  1557. event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement;
  1558. }
  1559. // Calculate pageX/Y if missing and clientX/Y available
  1560. if ( event.pageX == null && event.clientX != null ) {
  1561. var doc = document.documentElement, body = document.body;
  1562. event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
  1563. event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
  1564. }
  1565. // Add which for key events
  1566. if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) ) {
  1567. event.which = event.charCode || event.keyCode;
  1568. }
  1569. // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
  1570. if ( !event.metaKey && event.ctrlKey ) {
  1571. event.metaKey = event.ctrlKey;
  1572. }
  1573. // Add which for click: 1 === left; 2 === middle; 3 === right
  1574. // Note: button is not normalized, so don't use it
  1575. if ( !event.which && event.button !== undefined ) {
  1576. event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
  1577. }
  1578. return event;
  1579. },
  1580. // Deprecated, use jQuery.guid instead
  1581. guid: 1E8,
  1582. // Deprecated, use jQuery.proxy instead
  1583. proxy: jQuery.proxy,
  1584. special: {
  1585. ready: {
  1586. // Make sure the ready event is setup
  1587. setup: jQuery.bindReady,
  1588. teardown: jQuery.noop
  1589. },
  1590. live: {
  1591. add: function( proxy, data, namespaces, live ) {
  1592. jQuery.extend( proxy, data || {} );
  1593. proxy.guid += data.selector + data.live;
  1594. data.liveProxy = proxy;
  1595. jQuery.event.add( this, data.live, liveHandler, data );
  1596. },
  1597. remove: function( namespaces ) {
  1598. if ( namespaces.length ) {
  1599. var remove = 0, name = new RegExp("(^|\\.)" + namespaces[0] + "(\\.|$)");
  1600. jQuery.each( (jQuery.data(this, "events").live || {}), function() {
  1601. if ( name.test(this.type) ) {
  1602. remove++;
  1603. }
  1604. });
  1605. if ( remove < 1 ) {
  1606. jQuery.event.remove( this, namespaces[0], liveHandler );
  1607. }
  1608. }
  1609. },
  1610. special: {}
  1611. },
  1612. beforeunload: {
  1613. setup: function( data, namespaces, fn ) {
  1614. // We only want to do this special case on windows
  1615. if ( this.setInterval ) {
  1616. this.onbeforeunload = fn;
  1617. }
  1618. return false;
  1619. },
  1620. teardown: function( namespaces, fn ) {
  1621. if ( this.onbeforeunload === fn ) {
  1622. this.onbeforeunload = null;
  1623. }
  1624. }
  1625. }
  1626. }
  1627. };
  1628. jQuery.Event = function( src ) {
  1629. // Allow instantiation without the 'new' keyword
  1630. if ( !this.preventDefault ) {
  1631. return new jQuery.Event( src );
  1632. }
  1633. // Event object
  1634. if ( src && src.type ) {
  1635. this.originalEvent = src;
  1636. this.type = src.type;
  1637. // Event type
  1638. } else {
  1639. this.type = src;
  1640. }
  1641. // timeStamp is buggy for some events on Firefox(#3843)
  1642. // So we won't rely on the native value
  1643. this.timeStamp = now();
  1644. // Mark it as fixed
  1645. this[ expando ] = true;
  1646. };
  1647. function returnFalse() {
  1648. return false;
  1649. }
  1650. function returnTrue() {
  1651. return true;
  1652. }
  1653. // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
  1654. // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  1655. jQuery.Event.prototype = {
  1656. preventDefault: function() {
  1657. this.isDefaultPrevented = returnTrue;
  1658. var e = this.originalEvent;
  1659. if ( !e ) {
  1660. return;
  1661. }
  1662. // if preventDefault exists run it on the original event
  1663. if ( e.preventDefault ) {
  1664. e.preventDefault();
  1665. }
  1666. // otherwise set the returnValue property of the original event to false (IE)
  1667. e.returnValue = false;
  1668. },
  1669. stopPropagation: function() {
  1670. this.isPropagationStopped = returnTrue;
  1671. var e = this.originalEvent;
  1672. if ( !e ) {
  1673. return;
  1674. }
  1675. // if stopPropagation exists run it on the original event
  1676. if ( e.stopPropagation ) {
  1677. e.stopPropagation();
  1678. }
  1679. // otherwise set the cancelBubble property of the original event to true (IE)
  1680. e.cancelBubble = true;
  1681. },
  1682. stopImmediatePropagation: function() {
  1683. this.isImmediatePropagationStopped = returnTrue;
  1684. this.stopPropagation();
  1685. },
  1686. isDefaultPrevented: returnFalse,
  1687. isPropagationStopped: returnFalse,
  1688. isImmediatePropagationStopped: returnFalse
  1689. };
  1690. // Checks if an event happened on an element within another element
  1691. // Used in jQuery.event.special.mouseenter and mouseleave handlers
  1692. var withinElement = function( event ) {
  1693. // Check if mouse(over|out) are still within the same parent element
  1694. var parent = event.relatedTarget;
  1695. // Traverse up the tree
  1696. while ( parent && parent !== this ) {
  1697. // Firefox sometimes assigns relatedTarget a XUL element
  1698. // which we cannot access the parentNode property of
  1699. try {
  1700. parent = parent.parentNode;
  1701. // assuming we've left the element since we most likely mousedover a xul element
  1702. } catch(e) {
  1703. break;
  1704. }
  1705. }
  1706. if ( parent !== this ) {
  1707. // set the correct event type
  1708. event.type = event.data;
  1709. // handle event if we actually just moused on to a non sub-element
  1710. jQuery.event.handle.apply( this, arguments );
  1711. }
  1712. },
  1713. // In case of event delegation, we only need to rename the event.type,
  1714. // liveHandler will take care of the rest.
  1715. delegate = function( event ) {
  1716. event.type = event.data;
  1717. jQuery.event.handle.apply( this, arguments );
  1718. };
  1719. // Create mouseenter and mouseleave events
  1720. jQuery.each({
  1721. mouseenter: "mouseover",
  1722. mouseleave: "mouseout"
  1723. }, function( orig, fix ) {
  1724. jQuery.event.special[ orig ] = {
  1725. setup: function( data ) {
  1726. jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig );
  1727. },
  1728. teardown: function( data ) {
  1729. jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement );
  1730. }
  1731. };
  1732. });
  1733. // submit delegation
  1734. if ( !jQuery.support.submitBubbles ) {
  1735. jQuery.event.special.submit = {
  1736. setup: function( data, namespaces, fn ) {
  1737. if ( this.nodeName.toLowerCase() !== "form" ) {
  1738. jQuery.event.add(this, "click.specialSubmit." + fn.guid, function( e ) {
  1739. var elem = e.target, type = elem.type;
  1740. if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
  1741. return trigger( "submit", this, arguments );
  1742. }
  1743. });
  1744. jQuery.event.add(this, "keypress.specialSubmit." + fn.guid, function( e ) {
  1745. var elem = e.target, type = elem.type;
  1746. if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
  1747. return trigger( "submit", this, arguments );
  1748. }
  1749. });
  1750. } else {
  1751. return false;
  1752. }
  1753. },
  1754. remove: function( namespaces, fn ) {
  1755. jQuery.event.remove( this, "click.specialSubmit" + (fn ? "."+fn.guid : "") );
  1756. jQuery.event.remove( this, "keypress.specialSubmit" + (fn ? "."+fn.guid : "") );
  1757. }
  1758. };
  1759. }
  1760. // change delegation, happens here so we have bind.
  1761. if ( !jQuery.support.changeBubbles ) {
  1762. var formElems = /textarea|input|select/i;
  1763. function getVal( elem ) {
  1764. var type = elem.type, val = elem.value;
  1765. if ( type === "radio" || type === "checkbox" ) {
  1766. val = elem.checked;
  1767. } else if ( type === "select-multiple" ) {
  1768. val = elem.selectedIndex > -1 ?
  1769. jQuery.map( elem.options, function( elem ) {
  1770. return elem.selected;
  1771. }).join("-") :
  1772. "";
  1773. } else if ( elem.nodeName.toLowerCase() === "select" ) {
  1774. val = elem.selectedIndex;
  1775. }
  1776. return val;
  1777. }
  1778. function testChange( e ) {
  1779. var elem = e.target, data, val;
  1780. if ( !formElems.test( elem.nodeName ) || elem.readOnly ) {
  1781. return;
  1782. }
  1783. data = jQuery.data( elem, "_change_data" );
  1784. val = getVal(elem);
  1785. // the current data will be also retrieved by beforeactivate
  1786. if ( e.type !== "focusout" || elem.type !== "radio" ) {
  1787. jQuery.data( elem, "_change_data", val );
  1788. }
  1789. if ( data === undefined || val === data ) {
  1790. return;
  1791. }
  1792. if ( data != null || val ) {
  1793. e.type = "change";
  1794. return jQuery.event.trigger( e, arguments[1], elem );
  1795. }
  1796. }
  1797. jQuery.event.special.change = {
  1798. filters: {
  1799. focusout: testChange,
  1800. click: function( e ) {
  1801. var elem = e.target, type = elem.type;
  1802. if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) {
  1803. return testChange.call( this, e );
  1804. }
  1805. },
  1806. // Change has to be called before submit
  1807. // Keydown will be called before keypress, which is used in submit-event delegation
  1808. keydown: function( e ) {
  1809. var elem = e.target, type = elem.type;
  1810. if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") ||
  1811. (e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
  1812. type === "select-multiple" ) {
  1813. return testChange.call( this, e );
  1814. }
  1815. },
  1816. // Beforeactivate happens also before the previous element is blurred
  1817. // with this event you can't trigger a change event, but you can store
  1818. // information/focus[in] is not needed anymore
  1819. beforeactivate: function( e ) {
  1820. var elem = e.target;
  1821. if ( elem.nodeName.toLowerCase() === "input" && elem.type === "radio" ) {
  1822. jQuery.data( elem, "_change_data", getVal(elem) );
  1823. }
  1824. }
  1825. },
  1826. setup: function( data, namespaces, fn ) {
  1827. for ( var type in changeFilters ) {
  1828. jQuery.event.add( this, type + ".specialChange." + fn.guid, changeFilters[type] );
  1829. }
  1830. return formElems.test( this.nodeName );
  1831. },
  1832. remove: function( namespaces, fn ) {
  1833. for ( var type in changeFilters ) {
  1834. jQuery.event.remove( this, type + ".specialChange" + (fn ? "."+fn.guid : ""), changeFilters[type] );
  1835. }
  1836. return formElems.test( this.nodeName );
  1837. }
  1838. };
  1839. var changeFilters = jQuery.event.special.change.filters;
  1840. }
  1841. function trigger( type, elem, args ) {
  1842. args[0].type = type;
  1843. return jQuery.event.handle.apply( elem, args );
  1844. }
  1845. // Create "bubbling" focus and blur events
  1846. if ( document.addEventListener ) {
  1847. jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
  1848. jQuery.event.special[ fix ] = {
  1849. setup: function() {
  1850. this.addEventListener( orig, handler, true );
  1851. },
  1852. teardown: function() {
  1853. this.removeEventListener( orig, handler, true );
  1854. }
  1855. };
  1856. function handler( e ) {
  1857. e = jQuery.event.fix( e );
  1858. e.type = fix;
  1859. return jQuery.event.handle.call( this, e );
  1860. }
  1861. });
  1862. }
  1863. jQuery.each(["bind", "one"], function( i, name ) {
  1864. jQuery.fn[ name ] = function( type, data, fn ) {
  1865. // Handle object literals
  1866. if ( typeof type === "object" ) {
  1867. for ( var key in type ) {
  1868. this[ name ](key, data, type[key], fn);
  1869. }
  1870. return this;
  1871. }
  1872. if ( jQuery.isFunction( data ) ) {
  1873. fn = data;
  1874. data = undefined;
  1875. }
  1876. var handler = name === "one" ? jQuery.proxy( fn, function( event ) {
  1877. jQuery( this ).unbind( event, handler );
  1878. return fn.apply( this, arguments );
  1879. }) : fn;
  1880. return type === "unload" && name !== "one" ?
  1881. this.one( type, data, fn ) :
  1882. this.each(function() {
  1883. jQuery.event.add( this, type, handler, data );
  1884. });
  1885. };
  1886. });
  1887. jQuery.fn.extend({
  1888. unbind: function( type, fn ) {
  1889. // Handle object literals
  1890. if ( typeof type === "object" && !type.preventDefault ) {
  1891. for ( var key in type ) {
  1892. this.unbind(key, type[key]);
  1893. }
  1894. return this;
  1895. }
  1896. return this.each(function() {
  1897. jQuery.event.remove( this, type, fn );
  1898. });
  1899. },
  1900. trigger: function( type, data ) {
  1901. return this.each(function() {
  1902. jQuery.event.trigger( type, data, this );
  1903. });
  1904. },
  1905. triggerHandler: function( type, data ) {
  1906. if ( this[0] ) {
  1907. var event = jQuery.Event( type );
  1908. event.preventDefault();
  1909. event.stopPropagation();
  1910. jQuery.event.trigger( event, data, this[0] );
  1911. return event.result;
  1912. }
  1913. },
  1914. toggle: function( fn ) {
  1915. // Save reference to arguments for access in closure
  1916. var args = arguments, i = 1;
  1917. // link all the functions, so any of them can unbind this click handler
  1918. while ( i < args.length ) {
  1919. jQuery.proxy( fn, args[ i++ ] );
  1920. }
  1921. return this.click( jQuery.proxy( fn, function( event ) {
  1922. // Figure out which function to execute
  1923. var lastToggle = ( jQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i;
  1924. jQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 );
  1925. // Make sure that clicks stop
  1926. event.preventDefault();
  1927. // and execute the function
  1928. return args[ lastToggle ].apply( this, arguments ) || false;
  1929. }));
  1930. },
  1931. hover: function( fnOver, fnOut ) {
  1932. return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
  1933. }
  1934. });
  1935. jQuery.each(["live", "die"], function( i, name ) {
  1936. jQuery.fn[ name ] = function( types, data, fn ) {
  1937. var type, i = 0;
  1938. if ( jQuery.isFunction( data ) ) {
  1939. fn = data;
  1940. data = undefined;
  1941. }
  1942. types = (types || "").split( /\s+/ );
  1943. while ( (type = types[ i++ ]) != null ) {
  1944. type = type === "focus" ? "focusin" : // focus --> focusin
  1945. type === "blur" ? "focusout" : // blur --> focusout
  1946. type === "hover" ? types.push("mouseleave") && "mouseenter" : // hover support
  1947. type;
  1948. if ( name === "live" ) {
  1949. // bind live handler
  1950. jQuery( this.context ).bind( liveConvert( type, this.selector ), {
  1951. data: data, selector: this.selector, live: type
  1952. }, fn );
  1953. } else {
  1954. // unbind live handler
  1955. jQuery( this.context ).unbind( liveConvert( type, this.selector ), fn ? { guid: fn.guid + this.selector + type } : null );
  1956. }
  1957. }
  1958. return this;
  1959. }
  1960. });
  1961. function liveHandler( event ) {
  1962. var stop, elems = [], selectors = [], args = arguments,
  1963. related, match, fn, elem, j, i, l, data,
  1964. live = jQuery.extend({}, jQuery.data( this, "events" ).live);
  1965. // Make sure we avoid non-left-click bubbling in Firefox (#3861)
  1966. if ( event.button && event.type === "click" ) {
  1967. return;
  1968. }
  1969. for ( j in live ) {
  1970. fn = live[j];
  1971. if ( fn.live === event.type ||
  1972. fn.altLive && jQuery.inArray(event.type, fn.altLive) > -1 ) {
  1973. data = fn.data;
  1974. if ( !(data.beforeFilter && data.beforeFilter[event.type] &&
  1975. !data.beforeFilter[event.type](event)) ) {
  1976. selectors.push( fn.selector );
  1977. }
  1978. } else {
  1979. delete live[j];
  1980. }
  1981. }
  1982. match = jQuery( event.target ).closest( selectors, event.currentTarget );
  1983. for ( i = 0, l = match.length; i < l; i++ ) {
  1984. for ( j in live ) {
  1985. fn = live[j];
  1986. elem = match[i].elem;
  1987. related = null;
  1988. if ( match[i].selector === fn.selector ) {
  1989. // Those two events require additional checking
  1990. if ( fn.live === "mouseenter" || fn.live === "mouseleave" ) {
  1991. related = jQuery( event.relatedTarget ).closest( fn.selector )[0];
  1992. }
  1993. if ( !related || related !== elem ) {
  1994. elems.push({ elem: elem, fn: fn });
  1995. }
  1996. }
  1997. }
  1998. }
  1999. for ( i = 0, l = elems.length; i < l; i++ ) {
  2000. match = elems[i];
  2001. event.currentTarget = match.elem;
  2002. event.data = match.fn.data;
  2003. if ( match.fn.apply( match.elem, args ) === false ) {
  2004. stop = false;
  2005. break;
  2006. }
  2007. }
  2008. return stop;
  2009. }
  2010. function liveConvert( type, selector ) {
  2011. return "live." + (type ? type + "." : "") + selector.replace(/\./g, "`").replace(/ /g, "&");
  2012. }
  2013. jQuery.each( ("blur focus focusin focuso