PageRenderTime 67ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/syntaxhighlighter_3.0.83/tests/js/jquery-1.4.2.js

#
JavaScript | 6240 lines | 5314 code | 455 blank | 471 comment | 498 complexity | 942d93b3f88aaca2b6f4718d983b92d4 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0, BSD-3-Clause

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

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

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