PageRenderTime 75ms CodeModel.GetById 33ms RepoModel.GetById 1ms app.codeStats 0ms

/packages/jQuery.1.5.1/Content/Scripts/jquery-1.5.1.js

#
JavaScript | 2485 lines | 1593 code | 476 blank | 416 comment | 491 complexity | 0a18474998577c7513955b91410979fc MD5 | raw file
  1. /*!
  2. * Note: While Microsoft is not the author of this file, Microsoft is
  3. * offering you a license subject to the terms of the Microsoft Software
  4. * License Terms for Microsoft ASP.NET Model View Controller 3.
  5. * Microsoft reserves all other rights. The notices below are provided
  6. * for informational purposes only and are not the license terms under
  7. * which Microsoft distributed this file.
  8. *
  9. * jQuery JavaScript Library v1.5.1
  10. * http://jquery.com/
  11. * Copyright 2011, John Resig
  12. *
  13. * Includes Sizzle.js
  14. * http://sizzlejs.com/
  15. * Copyright 2011, The Dojo Foundation
  16. *
  17. * Date: Thu Nov 11 19:04:53 2010 -0500
  18. */
  19. (function( window, undefined ) {
  20. // Use the correct document accordingly with window argument (sandbox)
  21. var document = window.document;
  22. var jQuery = (function() {
  23. // Define a local copy of jQuery
  24. var jQuery = function( selector, context ) {
  25. // The jQuery object is actually just the init constructor 'enhanced'
  26. return new jQuery.fn.init( selector, context, rootjQuery );
  27. },
  28. // Map over jQuery in case of overwrite
  29. _jQuery = window.jQuery,
  30. // Map over the $ in case of overwrite
  31. _$ = window.$,
  32. // A central reference to the root jQuery(document)
  33. rootjQuery,
  34. // A simple way to check for HTML strings or ID strings
  35. // (both of which we optimize for)
  36. quickExpr = /^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/,
  37. // Check if a string has a non-whitespace character in it
  38. rnotwhite = /\S/,
  39. // Used for trimming whitespace
  40. trimLeft = /^\s+/,
  41. trimRight = /\s+$/,
  42. // Check for digits
  43. rdigit = /\d/,
  44. // Match a standalone tag
  45. rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
  46. // JSON RegExp
  47. rvalidchars = /^[\],:{}\s]*$/,
  48. rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
  49. rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
  50. rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
  51. // Useragent RegExp
  52. rwebkit = /(webkit)[ \/]([\w.]+)/,
  53. ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
  54. rmsie = /(msie) ([\w.]+)/,
  55. rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
  56. // Keep a UserAgent string for use with jQuery.browser
  57. userAgent = navigator.userAgent,
  58. // For matching the engine and version of the browser
  59. browserMatch,
  60. // Has the ready events already been bound?
  61. readyBound = false,
  62. // The deferred used on DOM ready
  63. readyList,
  64. // Promise methods
  65. promiseMethods = "then done fail isResolved isRejected promise".split( " " ),
  66. // The ready event handler
  67. DOMContentLoaded,
  68. // Save a reference to some core methods
  69. toString = Object.prototype.toString,
  70. hasOwn = Object.prototype.hasOwnProperty,
  71. push = Array.prototype.push,
  72. slice = Array.prototype.slice,
  73. trim = String.prototype.trim,
  74. indexOf = Array.prototype.indexOf,
  75. // [[Class]] -> type pairs
  76. class2type = {};
  77. jQuery.fn = jQuery.prototype = {
  78. constructor: jQuery,
  79. init: function( selector, context, rootjQuery ) {
  80. var match, elem, ret, doc;
  81. // Handle $(""), $(null), or $(undefined)
  82. if ( !selector ) {
  83. return this;
  84. }
  85. // Handle $(DOMElement)
  86. if ( selector.nodeType ) {
  87. this.context = this[0] = selector;
  88. this.length = 1;
  89. return this;
  90. }
  91. // The body element only exists once, optimize finding it
  92. if ( selector === "body" && !context && document.body ) {
  93. this.context = document;
  94. this[0] = document.body;
  95. this.selector = "body";
  96. this.length = 1;
  97. return this;
  98. }
  99. // Handle HTML strings
  100. if ( typeof selector === "string" ) {
  101. // Are we dealing with HTML string or an ID?
  102. match = quickExpr.exec( selector );
  103. // Verify a match, and that no context was specified for #id
  104. if ( match && (match[1] || !context) ) {
  105. // HANDLE: $(html) -> $(array)
  106. if ( match[1] ) {
  107. context = context instanceof jQuery ? context[0] : context;
  108. doc = (context ? context.ownerDocument || context : document);
  109. // If a single string is passed in and it's a single tag
  110. // just do a createElement and skip the rest
  111. ret = rsingleTag.exec( selector );
  112. if ( ret ) {
  113. if ( jQuery.isPlainObject( context ) ) {
  114. selector = [ document.createElement( ret[1] ) ];
  115. jQuery.fn.attr.call( selector, context, true );
  116. } else {
  117. selector = [ doc.createElement( ret[1] ) ];
  118. }
  119. } else {
  120. ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
  121. selector = (ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment).childNodes;
  122. }
  123. return jQuery.merge( this, selector );
  124. // HANDLE: $("#id")
  125. } else {
  126. elem = document.getElementById( match[2] );
  127. // Check parentNode to catch when Blackberry 4.6 returns
  128. // nodes that are no longer in the document #6963
  129. if ( elem && elem.parentNode ) {
  130. // Handle the case where IE and Opera return items
  131. // by name instead of ID
  132. if ( elem.id !== match[2] ) {
  133. return rootjQuery.find( selector );
  134. }
  135. // Otherwise, we inject the element directly into the jQuery object
  136. this.length = 1;
  137. this[0] = elem;
  138. }
  139. this.context = document;
  140. this.selector = selector;
  141. return this;
  142. }
  143. // HANDLE: $(expr, $(...))
  144. } else if ( !context || context.jquery ) {
  145. return (context || rootjQuery).find( selector );
  146. // HANDLE: $(expr, context)
  147. // (which is just equivalent to: $(context).find(expr)
  148. } else {
  149. return this.constructor( context ).find( selector );
  150. }
  151. // HANDLE: $(function)
  152. // Shortcut for document ready
  153. } else if ( jQuery.isFunction( selector ) ) {
  154. return rootjQuery.ready( selector );
  155. }
  156. if (selector.selector !== undefined) {
  157. this.selector = selector.selector;
  158. this.context = selector.context;
  159. }
  160. return jQuery.makeArray( selector, this );
  161. },
  162. // Start with an empty selector
  163. selector: "",
  164. // The current version of jQuery being used
  165. jquery: "1.5.1",
  166. // The default length of a jQuery object is 0
  167. length: 0,
  168. // The number of elements contained in the matched element set
  169. size: function() {
  170. return this.length;
  171. },
  172. toArray: function() {
  173. return slice.call( this, 0 );
  174. },
  175. // Get the Nth element in the matched element set OR
  176. // Get the whole matched element set as a clean array
  177. get: function( num ) {
  178. return num == null ?
  179. // Return a 'clean' array
  180. this.toArray() :
  181. // Return just the object
  182. ( num < 0 ? this[ this.length + num ] : this[ num ] );
  183. },
  184. // Take an array of elements and push it onto the stack
  185. // (returning the new matched element set)
  186. pushStack: function( elems, name, selector ) {
  187. // Build a new jQuery matched element set
  188. var ret = this.constructor();
  189. if ( jQuery.isArray( elems ) ) {
  190. push.apply( ret, elems );
  191. } else {
  192. jQuery.merge( ret, elems );
  193. }
  194. // Add the old object onto the stack (as a reference)
  195. ret.prevObject = this;
  196. ret.context = this.context;
  197. if ( name === "find" ) {
  198. ret.selector = this.selector + (this.selector ? " " : "") + selector;
  199. } else if ( name ) {
  200. ret.selector = this.selector + "." + name + "(" + selector + ")";
  201. }
  202. // Return the newly-formed element set
  203. return ret;
  204. },
  205. // Execute a callback for every element in the matched set.
  206. // (You can seed the arguments with an array of args, but this is
  207. // only used internally.)
  208. each: function( callback, args ) {
  209. return jQuery.each( this, callback, args );
  210. },
  211. ready: function( fn ) {
  212. // Attach the listeners
  213. jQuery.bindReady();
  214. // Add the callback
  215. readyList.done( fn );
  216. return this;
  217. },
  218. eq: function( i ) {
  219. return i === -1 ?
  220. this.slice( i ) :
  221. this.slice( i, +i + 1 );
  222. },
  223. first: function() {
  224. return this.eq( 0 );
  225. },
  226. last: function() {
  227. return this.eq( -1 );
  228. },
  229. slice: function() {
  230. return this.pushStack( slice.apply( this, arguments ),
  231. "slice", slice.call(arguments).join(",") );
  232. },
  233. map: function( callback ) {
  234. return this.pushStack( jQuery.map(this, function( elem, i ) {
  235. return callback.call( elem, i, elem );
  236. }));
  237. },
  238. end: function() {
  239. return this.prevObject || this.constructor(null);
  240. },
  241. // For internal use only.
  242. // Behaves like an Array's method, not like a jQuery method.
  243. push: push,
  244. sort: [].sort,
  245. splice: [].splice
  246. };
  247. // Give the init function the jQuery prototype for later instantiation
  248. jQuery.fn.init.prototype = jQuery.fn;
  249. jQuery.extend = jQuery.fn.extend = function() {
  250. var options, name, src, copy, copyIsArray, clone,
  251. target = arguments[0] || {},
  252. i = 1,
  253. length = arguments.length,
  254. deep = false;
  255. // Handle a deep copy situation
  256. if ( typeof target === "boolean" ) {
  257. deep = target;
  258. target = arguments[1] || {};
  259. // skip the boolean and the target
  260. i = 2;
  261. }
  262. // Handle case when target is a string or something (possible in deep copy)
  263. if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
  264. target = {};
  265. }
  266. // extend jQuery itself if only one argument is passed
  267. if ( length === i ) {
  268. target = this;
  269. --i;
  270. }
  271. for ( ; i < length; i++ ) {
  272. // Only deal with non-null/undefined values
  273. if ( (options = arguments[ i ]) != null ) {
  274. // Extend the base object
  275. for ( name in options ) {
  276. src = target[ name ];
  277. copy = options[ name ];
  278. // Prevent never-ending loop
  279. if ( target === copy ) {
  280. continue;
  281. }
  282. // Recurse if we're merging plain objects or arrays
  283. if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
  284. if ( copyIsArray ) {
  285. copyIsArray = false;
  286. clone = src && jQuery.isArray(src) ? src : [];
  287. } else {
  288. clone = src && jQuery.isPlainObject(src) ? src : {};
  289. }
  290. // Never move original objects, clone them
  291. target[ name ] = jQuery.extend( deep, clone, copy );
  292. // Don't bring in undefined values
  293. } else if ( copy !== undefined ) {
  294. target[ name ] = copy;
  295. }
  296. }
  297. }
  298. }
  299. // Return the modified object
  300. return target;
  301. };
  302. jQuery.extend({
  303. noConflict: function( deep ) {
  304. window.$ = _$;
  305. if ( deep ) {
  306. window.jQuery = _jQuery;
  307. }
  308. return jQuery;
  309. },
  310. // Is the DOM ready to be used? Set to true once it occurs.
  311. isReady: false,
  312. // A counter to track how many items to wait for before
  313. // the ready event fires. See #6781
  314. readyWait: 1,
  315. // Handle when the DOM is ready
  316. ready: function( wait ) {
  317. // A third-party is pushing the ready event forwards
  318. if ( wait === true ) {
  319. jQuery.readyWait--;
  320. }
  321. // Make sure that the DOM is not already loaded
  322. if ( !jQuery.readyWait || (wait !== true && !jQuery.isReady) ) {
  323. // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
  324. if ( !document.body ) {
  325. return setTimeout( jQuery.ready, 1 );
  326. }
  327. // Remember that the DOM is ready
  328. jQuery.isReady = true;
  329. // If a normal DOM Ready event fired, decrement, and wait if need be
  330. if ( wait !== true && --jQuery.readyWait > 0 ) {
  331. return;
  332. }
  333. // If there are functions bound, to execute
  334. readyList.resolveWith( document, [ jQuery ] );
  335. // Trigger any bound ready events
  336. if ( jQuery.fn.trigger ) {
  337. jQuery( document ).trigger( "ready" ).unbind( "ready" );
  338. }
  339. }
  340. },
  341. bindReady: function() {
  342. if ( readyBound ) {
  343. return;
  344. }
  345. readyBound = true;
  346. // Catch cases where $(document).ready() is called after the
  347. // browser event has already occurred.
  348. if ( document.readyState === "complete" ) {
  349. // Handle it asynchronously to allow scripts the opportunity to delay ready
  350. return setTimeout( jQuery.ready, 1 );
  351. }
  352. // Mozilla, Opera and webkit nightlies currently support this event
  353. if ( document.addEventListener ) {
  354. // Use the handy event callback
  355. document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
  356. // A fallback to window.onload, that will always work
  357. window.addEventListener( "load", jQuery.ready, false );
  358. // If IE event model is used
  359. } else if ( document.attachEvent ) {
  360. // ensure firing before onload,
  361. // maybe late but safe also for iframes
  362. document.attachEvent("onreadystatechange", DOMContentLoaded);
  363. // A fallback to window.onload, that will always work
  364. window.attachEvent( "onload", jQuery.ready );
  365. // If IE and not a frame
  366. // continually check to see if the document is ready
  367. var toplevel = false;
  368. try {
  369. toplevel = window.frameElement == null;
  370. } catch(e) {}
  371. if ( document.documentElement.doScroll && toplevel ) {
  372. doScrollCheck();
  373. }
  374. }
  375. },
  376. // See test/unit/core.js for details concerning isFunction.
  377. // Since version 1.3, DOM methods and functions like alert
  378. // aren't supported. They return false on IE (#2968).
  379. isFunction: function( obj ) {
  380. return jQuery.type(obj) === "function";
  381. },
  382. isArray: Array.isArray || function( obj ) {
  383. return jQuery.type(obj) === "array";
  384. },
  385. // A crude way of determining if an object is a window
  386. isWindow: function( obj ) {
  387. return obj && typeof obj === "object" && "setInterval" in obj;
  388. },
  389. isNaN: function( obj ) {
  390. return obj == null || !rdigit.test( obj ) || isNaN( obj );
  391. },
  392. type: function( obj ) {
  393. return obj == null ?
  394. String( obj ) :
  395. class2type[ toString.call(obj) ] || "object";
  396. },
  397. isPlainObject: function( obj ) {
  398. // Must be an Object.
  399. // Because of IE, we also have to check the presence of the constructor property.
  400. // Make sure that DOM nodes and window objects don't pass through, as well
  401. if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
  402. return false;
  403. }
  404. // Not own constructor property must be Object
  405. if ( obj.constructor &&
  406. !hasOwn.call(obj, "constructor") &&
  407. !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
  408. return false;
  409. }
  410. // Own properties are enumerated firstly, so to speed up,
  411. // if last one is own, then all properties are own.
  412. var key;
  413. for ( key in obj ) {}
  414. return key === undefined || hasOwn.call( obj, key );
  415. },
  416. isEmptyObject: function( obj ) {
  417. for ( var name in obj ) {
  418. return false;
  419. }
  420. return true;
  421. },
  422. error: function( msg ) {
  423. throw msg;
  424. },
  425. parseJSON: function( data ) {
  426. if ( typeof data !== "string" || !data ) {
  427. return null;
  428. }
  429. // Make sure leading/trailing whitespace is removed (IE can't handle it)
  430. data = jQuery.trim( data );
  431. // Make sure the incoming data is actual JSON
  432. // Logic borrowed from http://json.org/json2.js
  433. if ( rvalidchars.test(data.replace(rvalidescape, "@")
  434. .replace(rvalidtokens, "]")
  435. .replace(rvalidbraces, "")) ) {
  436. // Try to use the native JSON parser first
  437. return window.JSON && window.JSON.parse ?
  438. window.JSON.parse( data ) :
  439. (new Function("return " + data))();
  440. } else {
  441. jQuery.error( "Invalid JSON: " + data );
  442. }
  443. },
  444. // Cross-browser xml parsing
  445. // (xml & tmp used internally)
  446. parseXML: function( data , xml , tmp ) {
  447. if ( window.DOMParser ) { // Standard
  448. tmp = new DOMParser();
  449. xml = tmp.parseFromString( data , "text/xml" );
  450. } else { // IE
  451. xml = new ActiveXObject( "Microsoft.XMLDOM" );
  452. xml.async = "false";
  453. xml.loadXML( data );
  454. }
  455. tmp = xml.documentElement;
  456. if ( ! tmp || ! tmp.nodeName || tmp.nodeName === "parsererror" ) {
  457. jQuery.error( "Invalid XML: " + data );
  458. }
  459. return xml;
  460. },
  461. noop: function() {},
  462. // Evalulates a script in a global context
  463. globalEval: function( data ) {
  464. if ( data && rnotwhite.test(data) ) {
  465. // Inspired by code by Andrea Giammarchi
  466. // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
  467. var head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement,
  468. script = document.createElement( "script" );
  469. if ( jQuery.support.scriptEval() ) {
  470. script.appendChild( document.createTextNode( data ) );
  471. } else {
  472. script.text = data;
  473. }
  474. // Use insertBefore instead of appendChild to circumvent an IE6 bug.
  475. // This arises when a base node is used (#2709).
  476. head.insertBefore( script, head.firstChild );
  477. head.removeChild( script );
  478. }
  479. },
  480. nodeName: function( elem, name ) {
  481. return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
  482. },
  483. // args is for internal usage only
  484. each: function( object, callback, args ) {
  485. var name, i = 0,
  486. length = object.length,
  487. isObj = length === undefined || jQuery.isFunction(object);
  488. if ( args ) {
  489. if ( isObj ) {
  490. for ( name in object ) {
  491. if ( callback.apply( object[ name ], args ) === false ) {
  492. break;
  493. }
  494. }
  495. } else {
  496. for ( ; i < length; ) {
  497. if ( callback.apply( object[ i++ ], args ) === false ) {
  498. break;
  499. }
  500. }
  501. }
  502. // A special, fast, case for the most common use of each
  503. } else {
  504. if ( isObj ) {
  505. for ( name in object ) {
  506. if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
  507. break;
  508. }
  509. }
  510. } else {
  511. for ( var value = object[0];
  512. i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {}
  513. }
  514. }
  515. return object;
  516. },
  517. // Use native String.trim function wherever possible
  518. trim: trim ?
  519. function( text ) {
  520. return text == null ?
  521. "" :
  522. trim.call( text );
  523. } :
  524. // Otherwise use our own trimming functionality
  525. function( text ) {
  526. return text == null ?
  527. "" :
  528. text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
  529. },
  530. // results is for internal usage only
  531. makeArray: function( array, results ) {
  532. var ret = results || [];
  533. if ( array != null ) {
  534. // The window, strings (and functions) also have 'length'
  535. // The extra typeof function check is to prevent crashes
  536. // in Safari 2 (See: #3039)
  537. // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
  538. var type = jQuery.type(array);
  539. if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
  540. push.call( ret, array );
  541. } else {
  542. jQuery.merge( ret, array );
  543. }
  544. }
  545. return ret;
  546. },
  547. inArray: function( elem, array ) {
  548. if ( array.indexOf ) {
  549. return array.indexOf( elem );
  550. }
  551. for ( var i = 0, length = array.length; i < length; i++ ) {
  552. if ( array[ i ] === elem ) {
  553. return i;
  554. }
  555. }
  556. return -1;
  557. },
  558. merge: function( first, second ) {
  559. var i = first.length,
  560. j = 0;
  561. if ( typeof second.length === "number" ) {
  562. for ( var l = second.length; j < l; j++ ) {
  563. first[ i++ ] = second[ j ];
  564. }
  565. } else {
  566. while ( second[j] !== undefined ) {
  567. first[ i++ ] = second[ j++ ];
  568. }
  569. }
  570. first.length = i;
  571. return first;
  572. },
  573. grep: function( elems, callback, inv ) {
  574. var ret = [], retVal;
  575. inv = !!inv;
  576. // Go through the array, only saving the items
  577. // that pass the validator function
  578. for ( var i = 0, length = elems.length; i < length; i++ ) {
  579. retVal = !!callback( elems[ i ], i );
  580. if ( inv !== retVal ) {
  581. ret.push( elems[ i ] );
  582. }
  583. }
  584. return ret;
  585. },
  586. // arg is for internal usage only
  587. map: function( elems, callback, arg ) {
  588. var ret = [], value;
  589. // Go through the array, translating each of the items to their
  590. // new value (or values).
  591. for ( var i = 0, length = elems.length; i < length; i++ ) {
  592. value = callback( elems[ i ], i, arg );
  593. if ( value != null ) {
  594. ret[ ret.length ] = value;
  595. }
  596. }
  597. // Flatten any nested arrays
  598. return ret.concat.apply( [], ret );
  599. },
  600. // A global GUID counter for objects
  601. guid: 1,
  602. proxy: function( fn, proxy, thisObject ) {
  603. if ( arguments.length === 2 ) {
  604. if ( typeof proxy === "string" ) {
  605. thisObject = fn;
  606. fn = thisObject[ proxy ];
  607. proxy = undefined;
  608. } else if ( proxy && !jQuery.isFunction( proxy ) ) {
  609. thisObject = proxy;
  610. proxy = undefined;
  611. }
  612. }
  613. if ( !proxy && fn ) {
  614. proxy = function() {
  615. return fn.apply( thisObject || this, arguments );
  616. };
  617. }
  618. // Set the guid of unique handler to the same of original handler, so it can be removed
  619. if ( fn ) {
  620. proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
  621. }
  622. // So proxy can be declared as an argument
  623. return proxy;
  624. },
  625. // Mutifunctional method to get and set values to a collection
  626. // The value/s can be optionally by executed if its a function
  627. access: function( elems, key, value, exec, fn, pass ) {
  628. var length = elems.length;
  629. // Setting many attributes
  630. if ( typeof key === "object" ) {
  631. for ( var k in key ) {
  632. jQuery.access( elems, k, key[k], exec, fn, value );
  633. }
  634. return elems;
  635. }
  636. // Setting one attribute
  637. if ( value !== undefined ) {
  638. // Optionally, function values get executed if exec is true
  639. exec = !pass && exec && jQuery.isFunction(value);
  640. for ( var i = 0; i < length; i++ ) {
  641. fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
  642. }
  643. return elems;
  644. }
  645. // Getting an attribute
  646. return length ? fn( elems[0], key ) : undefined;
  647. },
  648. now: function() {
  649. return (new Date()).getTime();
  650. },
  651. // Create a simple deferred (one callbacks list)
  652. _Deferred: function() {
  653. var // callbacks list
  654. callbacks = [],
  655. // stored [ context , args ]
  656. fired,
  657. // to avoid firing when already doing so
  658. firing,
  659. // flag to know if the deferred has been cancelled
  660. cancelled,
  661. // the deferred itself
  662. deferred = {
  663. // done( f1, f2, ...)
  664. done: function() {
  665. if ( !cancelled ) {
  666. var args = arguments,
  667. i,
  668. length,
  669. elem,
  670. type,
  671. _fired;
  672. if ( fired ) {
  673. _fired = fired;
  674. fired = 0;
  675. }
  676. for ( i = 0, length = args.length; i < length; i++ ) {
  677. elem = args[ i ];
  678. type = jQuery.type( elem );
  679. if ( type === "array" ) {
  680. deferred.done.apply( deferred, elem );
  681. } else if ( type === "function" ) {
  682. callbacks.push( elem );
  683. }
  684. }
  685. if ( _fired ) {
  686. deferred.resolveWith( _fired[ 0 ], _fired[ 1 ] );
  687. }
  688. }
  689. return this;
  690. },
  691. // resolve with given context and args
  692. resolveWith: function( context, args ) {
  693. if ( !cancelled && !fired && !firing ) {
  694. firing = 1;
  695. try {
  696. while( callbacks[ 0 ] ) {
  697. callbacks.shift().apply( context, args );
  698. }
  699. }
  700. // We have to add a catch block for
  701. // IE prior to 8 or else the finally
  702. // block will never get executed
  703. catch (e) {
  704. throw e;
  705. }
  706. finally {
  707. fired = [ context, args ];
  708. firing = 0;
  709. }
  710. }
  711. return this;
  712. },
  713. // resolve with this as context and given arguments
  714. resolve: function() {
  715. deferred.resolveWith( jQuery.isFunction( this.promise ) ? this.promise() : this, arguments );
  716. return this;
  717. },
  718. // Has this deferred been resolved?
  719. isResolved: function() {
  720. return !!( firing || fired );
  721. },
  722. // Cancel
  723. cancel: function() {
  724. cancelled = 1;
  725. callbacks = [];
  726. return this;
  727. }
  728. };
  729. return deferred;
  730. },
  731. // Full fledged deferred (two callbacks list)
  732. Deferred: function( func ) {
  733. var deferred = jQuery._Deferred(),
  734. failDeferred = jQuery._Deferred(),
  735. promise;
  736. // Add errorDeferred methods, then and promise
  737. jQuery.extend( deferred, {
  738. then: function( doneCallbacks, failCallbacks ) {
  739. deferred.done( doneCallbacks ).fail( failCallbacks );
  740. return this;
  741. },
  742. fail: failDeferred.done,
  743. rejectWith: failDeferred.resolveWith,
  744. reject: failDeferred.resolve,
  745. isRejected: failDeferred.isResolved,
  746. // Get a promise for this deferred
  747. // If obj is provided, the promise aspect is added to the object
  748. promise: function( obj ) {
  749. if ( obj == null ) {
  750. if ( promise ) {
  751. return promise;
  752. }
  753. promise = obj = {};
  754. }
  755. var i = promiseMethods.length;
  756. while( i-- ) {
  757. obj[ promiseMethods[i] ] = deferred[ promiseMethods[i] ];
  758. }
  759. return obj;
  760. }
  761. } );
  762. // Make sure only one callback list will be used
  763. deferred.done( failDeferred.cancel ).fail( deferred.cancel );
  764. // Unexpose cancel
  765. delete deferred.cancel;
  766. // Call given func if any
  767. if ( func ) {
  768. func.call( deferred, deferred );
  769. }
  770. return deferred;
  771. },
  772. // Deferred helper
  773. when: function( object ) {
  774. var lastIndex = arguments.length,
  775. deferred = lastIndex <= 1 && object && jQuery.isFunction( object.promise ) ?
  776. object :
  777. jQuery.Deferred(),
  778. promise = deferred.promise();
  779. if ( lastIndex > 1 ) {
  780. var array = slice.call( arguments, 0 ),
  781. count = lastIndex,
  782. iCallback = function( index ) {
  783. return function( value ) {
  784. array[ index ] = arguments.length > 1 ? slice.call( arguments, 0 ) : value;
  785. if ( !( --count ) ) {
  786. deferred.resolveWith( promise, array );
  787. }
  788. };
  789. };
  790. while( ( lastIndex-- ) ) {
  791. object = array[ lastIndex ];
  792. if ( object && jQuery.isFunction( object.promise ) ) {
  793. object.promise().then( iCallback(lastIndex), deferred.reject );
  794. } else {
  795. --count;
  796. }
  797. }
  798. if ( !count ) {
  799. deferred.resolveWith( promise, array );
  800. }
  801. } else if ( deferred !== object ) {
  802. deferred.resolve( object );
  803. }
  804. return promise;
  805. },
  806. // Use of jQuery.browser is frowned upon.
  807. // More details: http://docs.jquery.com/Utilities/jQuery.browser
  808. uaMatch: function( ua ) {
  809. ua = ua.toLowerCase();
  810. var match = rwebkit.exec( ua ) ||
  811. ropera.exec( ua ) ||
  812. rmsie.exec( ua ) ||
  813. ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
  814. [];
  815. return { browser: match[1] || "", version: match[2] || "0" };
  816. },
  817. sub: function() {
  818. function jQuerySubclass( selector, context ) {
  819. return new jQuerySubclass.fn.init( selector, context );
  820. }
  821. jQuery.extend( true, jQuerySubclass, this );
  822. jQuerySubclass.superclass = this;
  823. jQuerySubclass.fn = jQuerySubclass.prototype = this();
  824. jQuerySubclass.fn.constructor = jQuerySubclass;
  825. jQuerySubclass.subclass = this.subclass;
  826. jQuerySubclass.fn.init = function init( selector, context ) {
  827. if ( context && context instanceof jQuery && !(context instanceof jQuerySubclass) ) {
  828. context = jQuerySubclass(context);
  829. }
  830. return jQuery.fn.init.call( this, selector, context, rootjQuerySubclass );
  831. };
  832. jQuerySubclass.fn.init.prototype = jQuerySubclass.fn;
  833. var rootjQuerySubclass = jQuerySubclass(document);
  834. return jQuerySubclass;
  835. },
  836. browser: {}
  837. });
  838. // Create readyList deferred
  839. readyList = jQuery._Deferred();
  840. // Populate the class2type map
  841. jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
  842. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  843. });
  844. browserMatch = jQuery.uaMatch( userAgent );
  845. if ( browserMatch.browser ) {
  846. jQuery.browser[ browserMatch.browser ] = true;
  847. jQuery.browser.version = browserMatch.version;
  848. }
  849. // Deprecated, use jQuery.browser.webkit instead
  850. if ( jQuery.browser.webkit ) {
  851. jQuery.browser.safari = true;
  852. }
  853. if ( indexOf ) {
  854. jQuery.inArray = function( elem, array ) {
  855. return indexOf.call( array, elem );
  856. };
  857. }
  858. // IE doesn't match non-breaking spaces with \s
  859. if ( rnotwhite.test( "\xA0" ) ) {
  860. trimLeft = /^[\s\xA0]+/;
  861. trimRight = /[\s\xA0]+$/;
  862. }
  863. // All jQuery objects should point back to these
  864. rootjQuery = jQuery(document);
  865. // Cleanup functions for the document ready method
  866. if ( document.addEventListener ) {
  867. DOMContentLoaded = function() {
  868. document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
  869. jQuery.ready();
  870. };
  871. } else if ( document.attachEvent ) {
  872. DOMContentLoaded = function() {
  873. // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
  874. if ( document.readyState === "complete" ) {
  875. document.detachEvent( "onreadystatechange", DOMContentLoaded );
  876. jQuery.ready();
  877. }
  878. };
  879. }
  880. // The DOM ready check for Internet Explorer
  881. function doScrollCheck() {
  882. if ( jQuery.isReady ) {
  883. return;
  884. }
  885. try {
  886. // If IE is used, use the trick by Diego Perini
  887. // http://javascript.nwbox.com/IEContentLoaded/
  888. document.documentElement.doScroll("left");
  889. } catch(e) {
  890. setTimeout( doScrollCheck, 1 );
  891. return;
  892. }
  893. // and execute any waiting functions
  894. jQuery.ready();
  895. }
  896. // Expose jQuery to the global object
  897. return jQuery;
  898. })();
  899. (function() {
  900. jQuery.support = {};
  901. var div = document.createElement("div");
  902. div.style.display = "none";
  903. div.innerHTML = " <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
  904. var all = div.getElementsByTagName("*"),
  905. a = div.getElementsByTagName("a")[0],
  906. select = document.createElement("select"),
  907. opt = select.appendChild( document.createElement("option") ),
  908. input = div.getElementsByTagName("input")[0];
  909. // Can't get basic test support
  910. if ( !all || !all.length || !a ) {
  911. return;
  912. }
  913. jQuery.support = {
  914. // IE strips leading whitespace when .innerHTML is used
  915. leadingWhitespace: div.firstChild.nodeType === 3,
  916. // Make sure that tbody elements aren't automatically inserted
  917. // IE will insert them into empty tables
  918. tbody: !div.getElementsByTagName("tbody").length,
  919. // Make sure that link elements get serialized correctly by innerHTML
  920. // This requires a wrapper element in IE
  921. htmlSerialize: !!div.getElementsByTagName("link").length,
  922. // Get the style information from getAttribute
  923. // (IE uses .cssText insted)
  924. style: /red/.test( a.getAttribute("style") ),
  925. // Make sure that URLs aren't manipulated
  926. // (IE normalizes it by default)
  927. hrefNormalized: a.getAttribute("href") === "/a",
  928. // Make sure that element opacity exists
  929. // (IE uses filter instead)
  930. // Use a regex to work around a WebKit issue. See #5145
  931. opacity: /^0.55$/.test( a.style.opacity ),
  932. // Verify style float existence
  933. // (IE uses styleFloat instead of cssFloat)
  934. cssFloat: !!a.style.cssFloat,
  935. // Make sure that if no value is specified for a checkbox
  936. // that it defaults to "on".
  937. // (WebKit defaults to "" instead)
  938. checkOn: input.value === "on",
  939. // Make sure that a selected-by-default option has a working selected property.
  940. // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
  941. optSelected: opt.selected,
  942. // Will be defined later
  943. deleteExpando: true,
  944. optDisabled: false,
  945. checkClone: false,
  946. noCloneEvent: true,
  947. noCloneChecked: true,
  948. boxModel: null,
  949. inlineBlockNeedsLayout: false,
  950. shrinkWrapBlocks: false,
  951. reliableHiddenOffsets: true
  952. };
  953. input.checked = true;
  954. jQuery.support.noCloneChecked = input.cloneNode( true ).checked;
  955. // Make sure that the options inside disabled selects aren't marked as disabled
  956. // (WebKit marks them as diabled)
  957. select.disabled = true;
  958. jQuery.support.optDisabled = !opt.disabled;
  959. var _scriptEval = null;
  960. jQuery.support.scriptEval = function() {
  961. if ( _scriptEval === null ) {
  962. var root = document.documentElement,
  963. script = document.createElement("script"),
  964. id = "script" + jQuery.now();
  965. try {
  966. script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
  967. } catch(e) {}
  968. root.insertBefore( script, root.firstChild );
  969. // Make sure that the execution of code works by injecting a script
  970. // tag with appendChild/createTextNode
  971. // (IE doesn't support this, fails, and uses .text instead)
  972. if ( window[ id ] ) {
  973. _scriptEval = true;
  974. delete window[ id ];
  975. } else {
  976. _scriptEval = false;
  977. }
  978. root.removeChild( script );
  979. // release memory in IE
  980. root = script = id = null;
  981. }
  982. return _scriptEval;
  983. };
  984. // Test to see if it's possible to delete an expando from an element
  985. // Fails in Internet Explorer
  986. try {
  987. delete div.test;
  988. } catch(e) {
  989. jQuery.support.deleteExpando = false;
  990. }
  991. if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
  992. div.attachEvent("onclick", function click() {
  993. // Cloning a node shouldn't copy over any
  994. // bound event handlers (IE does this)
  995. jQuery.support.noCloneEvent = false;
  996. div.detachEvent("onclick", click);
  997. });
  998. div.cloneNode(true).fireEvent("onclick");
  999. }
  1000. div = document.createElement("div");
  1001. div.innerHTML = "<input type='radio' name='radiotest' checked='checked'/>";
  1002. var fragment = document.createDocumentFragment();
  1003. fragment.appendChild( div.firstChild );
  1004. // WebKit doesn't clone checked state correctly in fragments
  1005. jQuery.support.checkClone = fragment.cloneNode(true).cloneNode(true).lastChild.checked;
  1006. // Figure out if the W3C box model works as expected
  1007. // document.body must exist before we can do this
  1008. jQuery(function() {
  1009. var div = document.createElement("div"),
  1010. body = document.getElementsByTagName("body")[0];
  1011. // Frameset documents with no body should not run this code
  1012. if ( !body ) {
  1013. return;
  1014. }
  1015. div.style.width = div.style.paddingLeft = "1px";
  1016. body.appendChild( div );
  1017. jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2;
  1018. if ( "zoom" in div.style ) {
  1019. // Check if natively block-level elements act like inline-block
  1020. // elements when setting their display to 'inline' and giving
  1021. // them layout
  1022. // (IE < 8 does this)
  1023. div.style.display = "inline";
  1024. div.style.zoom = 1;
  1025. jQuery.support.inlineBlockNeedsLayout = div.offsetWidth === 2;
  1026. // Check if elements with layout shrink-wrap their children
  1027. // (IE 6 does this)
  1028. div.style.display = "";
  1029. div.innerHTML = "<div style='width:4px;'></div>";
  1030. jQuery.support.shrinkWrapBlocks = div.offsetWidth !== 2;
  1031. }
  1032. div.innerHTML = "<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>";
  1033. var tds = div.getElementsByTagName("td");
  1034. // Check if table cells still have offsetWidth/Height when they are set
  1035. // to display:none and there are still other visible table cells in a
  1036. // table row; if so, offsetWidth/Height are not reliable for use when
  1037. // determining if an element has been hidden directly using
  1038. // display:none (it is still safe to use offsets if a parent element is
  1039. // hidden; don safety goggles and see bug #4512 for more information).
  1040. // (only IE 8 fails this test)
  1041. jQuery.support.reliableHiddenOffsets = tds[0].offsetHeight === 0;
  1042. tds[0].style.display = "";
  1043. tds[1].style.display = "none";
  1044. // Check if empty table cells still have offsetWidth/Height
  1045. // (IE < 8 fail this test)
  1046. jQuery.support.reliableHiddenOffsets = jQuery.support.reliableHiddenOffsets && tds[0].offsetHeight === 0;
  1047. div.innerHTML = "";
  1048. body.removeChild( div ).style.display = "none";
  1049. div = tds = null;
  1050. });
  1051. // Technique from Juriy Zaytsev
  1052. // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
  1053. var eventSupported = function( eventName ) {
  1054. var el = document.createElement("div");
  1055. eventName = "on" + eventName;
  1056. // We only care about the case where non-standard event systems
  1057. // are used, namely in IE. Short-circuiting here helps us to
  1058. // avoid an eval call (in setAttribute) which can cause CSP
  1059. // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
  1060. if ( !el.attachEvent ) {
  1061. return true;
  1062. }
  1063. var isSupported = (eventName in el);
  1064. if ( !isSupported ) {
  1065. el.setAttribute(eventName, "return;");
  1066. isSupported = typeof el[eventName] === "function";
  1067. }
  1068. el = null;
  1069. return isSupported;
  1070. };
  1071. jQuery.support.submitBubbles = eventSupported("submit");
  1072. jQuery.support.changeBubbles = eventSupported("change");
  1073. // release memory in IE
  1074. div = all = a = null;
  1075. })();
  1076. var rbrace = /^(?:\{.*\}|\[.*\])$/;
  1077. jQuery.extend({
  1078. cache: {},
  1079. // Please use with caution
  1080. uuid: 0,
  1081. // Unique for each copy of jQuery on the page
  1082. // Non-digits removed to match rinlinejQuery
  1083. expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),
  1084. // The following elements throw uncatchable exceptions if you
  1085. // attempt to add expando properties to them.
  1086. noData: {
  1087. "embed": true,
  1088. // Ban all objects except for Flash (which handle expandos)
  1089. "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
  1090. "applet": true
  1091. },
  1092. hasData: function( elem ) {
  1093. elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
  1094. return !!elem && !isEmptyDataObject( elem );
  1095. },
  1096. data: function( elem, name, data, pvt /* Internal Use Only */ ) {
  1097. if ( !jQuery.acceptData( elem ) ) {
  1098. return;
  1099. }
  1100. var internalKey = jQuery.expando, getByName = typeof name === "string", thisCache,
  1101. // We have to handle DOM nodes and JS objects differently because IE6-7
  1102. // can't GC object references properly across the DOM-JS boundary
  1103. isNode = elem.nodeType,
  1104. // Only DOM nodes need the global jQuery cache; JS object data is
  1105. // attached directly to the object so GC can occur automatically
  1106. cache = isNode ? jQuery.cache : elem,
  1107. // Only defining an ID for JS objects if its cache already exists allows
  1108. // the code to shortcut on the same path as a DOM node with no cache
  1109. id = isNode ? elem[ jQuery.expando ] : elem[ jQuery.expando ] && jQuery.expando;
  1110. // Avoid doing any more work than we need to when trying to get data on an
  1111. // object that has no data at all
  1112. if ( (!id || (pvt && id && !cache[ id ][ internalKey ])) && getByName && data === undefined ) {
  1113. return;
  1114. }
  1115. if ( !id ) {
  1116. // Only DOM nodes need a new unique ID for each element since their data
  1117. // ends up in the global cache
  1118. if ( isNode ) {
  1119. elem[ jQuery.expando ] = id = ++jQuery.uuid;
  1120. } else {
  1121. id = jQuery.expando;
  1122. }
  1123. }
  1124. if ( !cache[ id ] ) {
  1125. cache[ id ] = {};
  1126. // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
  1127. // metadata on plain JS objects when the object is serialized using
  1128. // JSON.stringify
  1129. if ( !isNode ) {
  1130. cache[ id ].toJSON = jQuery.noop;
  1131. }
  1132. }
  1133. // An object can be passed to jQuery.data instead of a key/value pair; this gets
  1134. // shallow copied over onto the existing cache
  1135. if ( typeof name === "object" || typeof name === "function" ) {
  1136. if ( pvt ) {
  1137. cache[ id ][ internalKey ] = jQuery.extend(cache[ id ][ internalKey ], name);
  1138. } else {
  1139. cache[ id ] = jQuery.extend(cache[ id ], name);
  1140. }
  1141. }
  1142. thisCache = cache[ id ];
  1143. // Internal jQuery data is stored in a separate object inside the object's data
  1144. // cache in order to avoid key collisions between internal data and user-defined
  1145. // data
  1146. if ( pvt ) {
  1147. if ( !thisCache[ internalKey ] ) {
  1148. thisCache[ internalKey ] = {};
  1149. }
  1150. thisCache = thisCache[ internalKey ];
  1151. }
  1152. if ( data !== undefined ) {
  1153. thisCache[ name ] = data;
  1154. }
  1155. // TODO: This is a hack for 1.5 ONLY. It will be removed in 1.6. Users should
  1156. // not attempt to inspect the internal events object using jQuery.data, as this
  1157. // internal data object is undocumented and subject to change.
  1158. if ( name === "events" && !thisCache[name] ) {
  1159. return thisCache[ internalKey ] && thisCache[ internalKey ].events;
  1160. }
  1161. return getByName ? thisCache[ name ] : thisCache;
  1162. },
  1163. removeData: function( elem, name, pvt /* Internal Use Only */ ) {
  1164. if ( !jQuery.acceptData( elem ) ) {
  1165. return;
  1166. }
  1167. var internalKey = jQuery.expando, isNode = elem.nodeType,
  1168. // See jQuery.data for more information
  1169. cache = isNode ? jQuery.cache : elem,
  1170. // See jQuery.data for more information
  1171. id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
  1172. // If there is already no cache entry for this object, there is no
  1173. // purpose in continuing
  1174. if ( !cache[ id ] ) {
  1175. return;
  1176. }
  1177. if ( name ) {
  1178. var thisCache = pvt ? cache[ id ][ internalKey ] : cache[ id ];
  1179. if ( thisCache ) {
  1180. delete thisCache[ name ];
  1181. // If there is no data left in the cache, we want to continue
  1182. // and let the cache object itself get destroyed
  1183. if ( !isEmptyDataObject(thisCache) ) {
  1184. return;
  1185. }
  1186. }
  1187. }
  1188. // See jQuery.data for more information
  1189. if ( pvt ) {
  1190. delete cache[ id ][ internalKey ];
  1191. // Don't destroy the parent cache unless the internal data object
  1192. // had been the only thing left in it
  1193. if ( !isEmptyDataObject(cache[ id ]) ) {
  1194. return;
  1195. }
  1196. }
  1197. var internalCache = cache[ id ][ internalKey ];
  1198. // Browsers that fail expando deletion also refuse to delete expandos on
  1199. // the window, but it will allow it on all other JS objects; other browsers
  1200. // don't care
  1201. if ( jQuery.support.deleteExpando || cache != window ) {
  1202. delete cache[ id ];
  1203. } else {
  1204. cache[ id ] = null;
  1205. }
  1206. // We destroyed the entire user cache at once because it's faster than
  1207. // iterating through each key, but we need to continue to persist internal
  1208. // data if it existed
  1209. if ( internalCache ) {
  1210. cache[ id ] = {};
  1211. // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
  1212. // metadata on plain JS objects when the object is serialized using
  1213. // JSON.stringify
  1214. if ( !isNode ) {
  1215. cache[ id ].toJSON = jQuery.noop;
  1216. }
  1217. cache[ id ][ internalKey ] = internalCache;
  1218. // Otherwise, we need to eliminate the expando on the node to avoid
  1219. // false lookups in the cache for entries that no longer exist
  1220. } else if ( isNode ) {
  1221. // IE does not allow us to delete expando properties from nodes,
  1222. // nor does it have a removeAttribute function on Document nodes;
  1223. // we must handle all of these cases
  1224. if ( jQuery.support.deleteExpando ) {
  1225. delete elem[ jQuery.expando ];
  1226. } else if ( elem.removeAttribute ) {
  1227. elem.removeAttribute( jQuery.expando );
  1228. } else {
  1229. elem[ jQuery.expando ] = null;
  1230. }
  1231. }
  1232. },
  1233. // For internal use only.
  1234. _data: function( elem, name, data ) {
  1235. return jQuery.data( elem, name, data, true );
  1236. },
  1237. // A method for determining if a DOM node can handle the data expando
  1238. acceptData: function( elem ) {
  1239. if ( elem.nodeName ) {
  1240. var match = jQuery.noData[ elem.nodeName.toLowerCase() ];
  1241. if ( match ) {
  1242. return !(match === true || elem.getAttribute("classid") !== match);
  1243. }
  1244. }
  1245. return true;
  1246. }
  1247. });
  1248. jQuery.fn.extend({
  1249. data: function( key, value ) {
  1250. var data = null;
  1251. if ( typeof key === "undefined" ) {
  1252. if ( this.length ) {
  1253. data = jQuery.data( this[0] );
  1254. if ( this[0].nodeType === 1 ) {
  1255. var attr = this[0].attributes, name;
  1256. for ( var i = 0, l = attr.length; i < l; i++ ) {
  1257. name = attr[i].name;
  1258. if ( name.indexOf( "data-" ) === 0 ) {
  1259. name = name.substr( 5 );
  1260. dataAttr( this[0], name, data[ name ] );
  1261. }
  1262. }
  1263. }
  1264. }
  1265. return data;
  1266. } else if ( typeof key === "object" ) {
  1267. return this.each(function() {
  1268. jQuery.data( this, key );
  1269. });
  1270. }
  1271. var parts = key.split(".");
  1272. parts[1] = parts[1] ? "." + parts[1] : "";
  1273. if ( value === undefined ) {
  1274. data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
  1275. // Try to fetch any internally stored data first
  1276. if ( data === undefined && this.length ) {
  1277. data = jQuery.data( this[0], key );
  1278. data = dataAttr( this[0], key, data );
  1279. }
  1280. return data === undefined && parts[1] ?
  1281. this.data( parts[0] ) :
  1282. data;
  1283. } else {
  1284. return this.each(function() {
  1285. var $this = jQuery( this ),
  1286. args = [ parts[0], value ];
  1287. $this.triggerHandler( "setData" + parts[1] + "!", args );
  1288. jQuery.data( this, key, value );
  1289. $this.triggerHandler( "changeData" + parts[1] + "!", args );
  1290. });
  1291. }
  1292. },
  1293. removeData: function( key ) {
  1294. return this.each(function() {
  1295. jQuery.removeData( this, key );
  1296. });
  1297. }
  1298. });
  1299. function dataAttr( elem, key, data ) {
  1300. // If nothing was found internally, try to fetch any
  1301. // data from the HTML5 data-* attribute
  1302. if ( data === undefined && elem.nodeType === 1 ) {
  1303. data = elem.getAttribute( "data-" + key );
  1304. if ( typeof data === "string" ) {
  1305. try {
  1306. data = data === "true" ? true :
  1307. data === "false" ? false :
  1308. data === "null" ? null :
  1309. !jQuery.isNaN( data ) ? parseFloat( data ) :
  1310. rbrace.test( data ) ? jQuery.parseJSON( data ) :
  1311. data;
  1312. } catch( e ) {}
  1313. // Make sure we set the data so it isn't changed later
  1314. jQuery.data( elem, key, data );
  1315. } else {
  1316. data = undefined;
  1317. }
  1318. }
  1319. return data;
  1320. }
  1321. // TODO: This is a hack for 1.5 ONLY to allow objects with a single toJSON
  1322. // property to be considered empty objects; this property always exists in
  1323. // order to make sure JSON.stringify does not expose internal metadata
  1324. function isEmptyDataObject( obj ) {
  1325. for ( var name in obj ) {
  1326. if ( name !== "toJSON" ) {
  1327. return false;
  1328. }
  1329. }
  1330. return true;
  1331. }
  1332. jQuery.extend({
  1333. queue: function( elem, type, data ) {
  1334. if ( !elem ) {
  1335. return;
  1336. }
  1337. type = (type || "fx") + "queue";
  1338. var q = jQuery._data( elem, type );
  1339. // Speed up dequeue by getting out quickly if this is just a lookup
  1340. if ( !data ) {
  1341. return q || [];
  1342. }
  1343. if ( !q || jQuery.isArray(data) ) {
  1344. q = jQuery._data( elem, type, jQuery.makeArray(data) );
  1345. } else {
  1346. q.push( data );
  1347. }
  1348. return q;
  1349. },
  1350. dequeue: function( elem, type ) {
  1351. type = type || "fx";
  1352. var queue = jQuery.queue( elem, type ),
  1353. fn = queue.shift();
  1354. // If the fx queue is dequeued, always remove the progress sentinel
  1355. if ( fn === "inprogress" ) {
  1356. fn = queue.shift();
  1357. }
  1358. if ( fn ) {
  1359. // Add a progress sentinel to prevent the fx queue from being
  1360. // automatically dequeued
  1361. if ( type === "fx" ) {
  1362. queue.unshift("inprogress");
  1363. }
  1364. fn.call(elem, function() {
  1365. jQuery.dequeue(elem, type);
  1366. });
  1367. }
  1368. if ( !queue.length ) {
  1369. jQuery.removeData( elem, type + "queue", true );
  1370. }
  1371. }
  1372. });
  1373. jQuery.fn.extend({
  1374. queue: function( type, data ) {
  1375. if ( typeof type !== "string" ) {
  1376. data = type;
  1377. type = "fx";
  1378. }
  1379. if ( data === undefined ) {
  1380. return jQuery.queue( this[0], type );
  1381. }
  1382. return this.each(function( i ) {
  1383. var queue = jQuery.queue( this, type, data );
  1384. if ( type === "fx" && queue[0] !== "inprogress" ) {
  1385. jQuery.dequeue( this, type );
  1386. }
  1387. });
  1388. },
  1389. dequeue: function( type ) {
  1390. return this.each(function() {
  1391. jQuery.dequeue( this, type );
  1392. });
  1393. },
  1394. // Based off of the plugin by Clint Helfers, with permission.
  1395. // http://blindsignals.com/index.php/2009/07/jquery-delay/
  1396. delay: function( time, type ) {
  1397. time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
  1398. type = type || "fx";
  1399. return this.queue( type, function() {
  1400. var elem = this;
  1401. setTimeout(function() {
  1402. jQuery.dequeue( elem, type );
  1403. }, time );
  1404. });
  1405. },
  1406. clearQueue: function( type ) {
  1407. return this.queue( type || "fx", [] );
  1408. }
  1409. });
  1410. var rclass = /[\n\t\r]/g,
  1411. rspaces = /\s+/,
  1412. rreturn = /\r/g,
  1413. rspecialurl = /^(?:href|src|style)$/,
  1414. rtype = /^(?:button|input)$/i,
  1415. rfocusable = /^(?:button|input|object|select|textarea)$/i,
  1416. rclickable = /^a(?:rea)?$/i,
  1417. rradiocheck = /^(?:radio|checkbox)$/i;
  1418. jQuery.props = {
  1419. "for": "htmlFor",
  1420. "class": "className",
  1421. readonly: "readOnly",
  1422. maxlength: "maxLength",
  1423. cellspacing: "cellSpacing",
  1424. rowspan: "rowSpan",
  1425. colspan: "colSpan",
  1426. tabindex: "tabIndex",
  1427. usemap: "useMap",
  1428. frameborder: "frameBorder"
  1429. };
  1430. jQuery.fn.extend({
  1431. attr: function( name, value ) {
  1432. return jQuery.access( this, name, value, true, jQuery.attr );
  1433. },
  1434. removeAttr: function( name, fn ) {
  1435. return this.each(function(){
  1436. jQuery.attr( this, name, "" );
  1437. if ( this.nodeType === 1 ) {
  1438. this.removeAttribute( name );
  1439. }
  1440. });
  1441. },
  1442. addClass: function( value ) {
  1443. if ( jQuery.isFunction(value) ) {
  1444. return this.each(function(i) {
  1445. var self = jQuery(this);
  1446. self.addClass( value.call(this, i, self.attr("class")) );
  1447. });
  1448. }
  1449. if ( value && typeof value === "string" ) {
  1450. var classNames = (value || "").split( rspaces );
  1451. for ( var i = 0, l = this.length; i < l; i++ ) {
  1452. var elem = this[i];
  1453. if ( elem.nodeType === 1 ) {
  1454. if ( !elem.className ) {
  1455. elem.className = value;
  1456. } else {
  1457. var className = " " + elem.className + " ",
  1458. setClass = elem.className;
  1459. for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
  1460. if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) {
  1461. setClass += " " + classNames[c];
  1462. }
  1463. }
  1464. elem.className = jQuery.trim( setClass );
  1465. }
  1466. }
  1467. }
  1468. }
  1469. return this;
  1470. },
  1471. removeClass: function( value ) {
  1472. if ( jQuery.isFunction(value) ) {
  1473. return this.each(function(i) {
  1474. var self = jQuery(this);
  1475. self.removeClass( value.call(this, i, self.attr("class")) );
  1476. });
  1477. }
  1478. if ( (value && typeof value === "string") || value === undefined ) {
  1479. var classNames = (value || "").split( rspaces );
  1480. for ( var i = 0, l = this.length; i < l; i++ ) {
  1481. var elem = this[i];
  1482. if ( elem.nodeType === 1 && elem.className ) {
  1483. if ( value ) {
  1484. var className = (" " + elem.className + " ").replace(rclass, " ");
  1485. for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
  1486. className = className.replace(" " + classNames[c] + " ", " ");
  1487. }
  1488. elem.className = jQuery.trim( className );
  1489. } else {
  1490. elem.className = "";
  1491. }
  1492. }
  1493. }
  1494. }
  1495. return this;
  1496. },
  1497. toggleClass: function( value, stateVal ) {
  1498. var type = typeof value,
  1499. isBool = typeof stateVal === "boolean";
  1500. if ( jQuery.isFunction( value ) ) {
  1501. return this.each(function(i) {
  1502. var self = jQuery(this);
  1503. self.toggleClass( value.call(this, i, self.attr("class"), stateVal), stateVal );
  1504. });
  1505. }
  1506. return this.each(function() {
  1507. if ( type === "string" ) {
  1508. // toggle individual class names
  1509. var className,
  1510. i = 0,
  1511. self = jQuery( this ),
  1512. state = stateVal,
  1513. classNames = value.split( rspaces );
  1514. while ( (className = classNames[ i++ ]) ) {
  1515. // check each className given, space seperated list
  1516. state = isBool ? state : !self.hasClass( className );
  1517. self[ state ? "addClass" : "removeClass" ]( className );
  1518. }
  1519. } else if ( type === "undefined" || type === "boolean" ) {
  1520. if ( this.className ) {
  1521. // store className if set
  1522. jQuery._data( this, "__className__", this.className );
  1523. }
  1524. // toggle whole className
  1525. this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
  1526. }
  1527. });
  1528. },
  1529. hasClass: function( selector ) {
  1530. var className = " " + selector + " ";
  1531. for ( var i = 0, l = this.length; i < l; i++ ) {
  1532. if ( (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
  1533. return true;
  1534. }
  1535. }
  1536. return false;
  1537. },
  1538. val: function( value ) {
  1539. if ( !arguments.length ) {
  1540. var elem = this[0];
  1541. if ( elem ) {
  1542. if ( jQuery.nodeName( elem, "option" ) ) {
  1543. // attributes.value is undefined in Blackberry 4.7 but
  1544. // uses .value. See #6932
  1545. var val = elem.attributes.value;
  1546. return !val || val.specified ? elem.value : elem.text;
  1547. }
  1548. // We need to handle select boxes special
  1549. if ( jQuery.nodeName( elem, "select" ) ) {
  1550. var index = elem.selectedIndex,
  1551. values = [],
  1552. options = elem.options,
  1553. one = elem.type === "select-one";
  1554. // Nothing was selected
  1555. if ( index < 0 ) {
  1556. return null;
  1557. }
  1558. // Loop through all the selected options
  1559. for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
  1560. var option = options[ i ];
  1561. // Don't return options that are disabled or in a disabled optgroup
  1562. if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
  1563. (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
  1564. // Get the specific value for the option
  1565. value = jQuery(option).val();
  1566. // We don't need an array for one selects
  1567. if ( one ) {
  1568. return value;
  1569. }
  1570. // Multi-Selects return an array
  1571. values.push( value );
  1572. }
  1573. }
  1574. // Fixes Bug #2551 -- select.val() broken in IE after form.reset()
  1575. if ( one && !values.length && options.length ) {
  1576. return jQuery( options[ index ] ).val();
  1577. }
  1578. return values;
  1579. }
  1580. // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
  1581. if ( rradiocheck.test( elem.type ) && !jQuery.support.checkOn ) {
  1582. return elem.getAttribute("value") === null ? "on" : elem.value;
  1583. }
  1584. // Everything else, we just grab the value
  1585. return (elem.value || "").replace(rreturn, "");
  1586. }
  1587. return undefined;
  1588. }
  1589. var isFunction = jQuery.isFunction(value);
  1590. return this.each(function(i) {
  1591. var self = jQuery(this), val = value;
  1592. if ( this.nodeType !== 1 ) {
  1593. return;
  1594. }
  1595. if ( isFunction ) {
  1596. val = value.call(this, i, self.val());
  1597. }
  1598. // Treat null/undefined as ""; convert numbers to string
  1599. if ( val == null ) {
  1600. val = "";
  1601. } else if ( typeof val === "number" ) {
  1602. val += "";
  1603. } else if ( jQuery.isArray(val) ) {
  1604. val = jQuery.map(val, function (value) {
  1605. return value == null ? "" : value + "";
  1606. });
  1607. }
  1608. if ( jQuery.isArray(val) && rradiocheck.test( this.type ) ) {
  1609. this.checked = jQuery.inArray( self.val(), val ) >= 0;
  1610. } else if ( jQuery.nodeName( this, "select" ) ) {
  1611. var values = jQuery.makeArray(val);
  1612. jQuery( "option", this ).each(function() {
  1613. this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
  1614. });
  1615. if ( !values.length ) {
  1616. this.selectedIndex = -1;
  1617. }
  1618. } else {
  1619. this.value = val;
  1620. }
  1621. });
  1622. }
  1623. });
  1624. jQuery.extend({
  1625. attrFn: {
  1626. val: true,
  1627. css: true,
  1628. html: true,
  1629. text: true,
  1630. data: true,
  1631. width: true,
  1632. height: true,
  1633. offset: true
  1634. },
  1635. attr: function( elem, name, value, pass ) {
  1636. // don't get/set attributes on text, comment and attribute nodes
  1637. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || elem.nodeType === 2 ) {
  1638. return undefined;
  1639. }
  1640. if ( pass && name in jQuery.attrFn ) {
  1641. return jQuery(elem)[name](value);
  1642. }
  1643. var notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ),
  1644. // Whether we are setting (or getting)
  1645. set = value !== undefined;
  1646. // Try to normalize/fix the name
  1647. name = notxml && jQuery.props[ name ] || name;
  1648. // Only do all the following if this is a node (faster for style)
  1649. if ( elem.nodeType === 1 ) {
  1650. // These attributes require special treatment
  1651. var special = rspecialurl.test( name );
  1652. // Safari mis-reports the default selected property of an option
  1653. // Accessing the parent's selectedIndex property fixes it
  1654. if ( name === "selected" && !jQuery.support.optSelected ) {
  1655. var parent = elem.parentNode;
  1656. if ( parent ) {
  1657. parent.selectedIndex;
  1658. // Make sure that it also works with optgroups, see #5701
  1659. if ( parent.parentNode ) {
  1660. parent.parentNode.selectedIndex;
  1661. }
  1662. }
  1663. }
  1664. // If applicable, access the attribute via the DOM 0 way
  1665. // 'in' checks fail in Blackberry 4.7 #6931
  1666. if ( (name in elem || elem[ name ] !== undefined) && notxml && !special ) {
  1667. if ( set ) {
  1668. // We can't allow the type property to be changed (since it causes problems in IE)
  1669. if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) {
  1670. jQuery.error( "type property can't be changed" );
  1671. }
  1672. if ( value === null ) {
  1673. if ( elem.nodeType === 1 ) {
  1674. elem.removeAttribute( name );
  1675. }
  1676. } else {
  1677. elem[ name ] = value;
  1678. }
  1679. }
  1680. // browsers index elements by id/name on forms, give priority to attributes.
  1681. if ( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) {
  1682. return elem.getAttributeNode( name ).nodeValue;
  1683. }
  1684. // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
  1685. // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
  1686. if ( name === "tabIndex" ) {
  1687. var attributeNode = elem.getAttributeNode( "tabIndex" );
  1688. return attributeNode && attributeNode.specified ?
  1689. attributeNode.value :
  1690. rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
  1691. 0 :
  1692. undefined;
  1693. }
  1694. return elem[ name ];
  1695. }
  1696. if ( !jQuery.support.style && notxml && name === "style" ) {
  1697. if ( set ) {
  1698. elem.style.cssText = "" + value;
  1699. }
  1700. return elem.style.cssText;
  1701. }
  1702. if ( set ) {
  1703. // convert the value to a string (all browsers do this but IE) see #1070
  1704. elem.setAttribute( name, "" + value );
  1705. }
  1706. // Ensure that missing attributes return undefined
  1707. // Blackberry 4.7 returns "" from getAttribute #6938
  1708. if ( !elem.attributes[ name ] && (elem.hasAttribute && !elem.hasAttribute( name )) ) {
  1709. return undefined;
  1710. }
  1711. var attr = !jQuery.support.hrefNormalized && notxml && special ?
  1712. // Some attributes require a special call on IE
  1713. elem.getAttribute( name, 2 ) :
  1714. elem.getAttribute( name );
  1715. // Non-existent attributes return null, we normalize to undefined
  1716. return attr === null ? undefined : attr;
  1717. }
  1718. // Handle everything which isn't a DOM element node
  1719. if ( set ) {
  1720. elem[ name ] = value;
  1721. }
  1722. return elem[ name ];
  1723. }
  1724. });
  1725. var rnamespaces = /\.(.*)$/,
  1726. rformElems = /^(?:textarea|input|select)$/i,
  1727. rperiod = /\./g,
  1728. rspace = / /g,
  1729. rescape = /[^\w\s.|`]/g,
  1730. fcleanup = function( nm ) {
  1731. return nm.replace(rescape, "\\$&");
  1732. };
  1733. /*
  1734. * A number of helper functions used for managing events.
  1735. * Many of the ideas behind this code originated from
  1736. * Dean Edwards' addEvent library.
  1737. */
  1738. jQuery.event = {
  1739. // Bind an event to an element
  1740. // Original by Dean Edwards
  1741. add: function( elem, types, handler, data ) {
  1742. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  1743. return;
  1744. }
  1745. // TODO :: Use a try/catch until it's safe to pull this out (likely 1.6)
  1746. // Minor release fix for bug #8018
  1747. try {
  1748. // For whatever reason, IE has trouble passing the window object
  1749. // around, causing it to be cloned in the process
  1750. if ( jQuery.isWindow( elem ) && ( elem !== window && !elem.frameElement ) ) {
  1751. elem = window;
  1752. }
  1753. }
  1754. catch ( e ) {}
  1755. if ( handler === false ) {
  1756. handler = returnFalse;
  1757. } else if ( !handler ) {
  1758. // Fixes bug #7229. Fix recommended by jdalton
  1759. return;
  1760. }
  1761. var handleObjIn, handleObj;
  1762. if ( handler.handler ) {
  1763. handleObjIn = handler;
  1764. handler = handleObjIn.handler;
  1765. }
  1766. // Make sure that the function being executed has a unique ID
  1767. if ( !handler.guid ) {
  1768. handler.guid = jQuery.guid++;
  1769. }
  1770. // Init the element's event structure
  1771. var elemData = jQuery._data( elem );
  1772. // If no elemData is found then we must be trying to bind to one of the
  1773. // banned noData elements
  1774. if ( !elemData ) {
  1775. return;
  1776. }
  1777. var events = elemData.events,
  1778. eventHandle = elemData.handle;
  1779. if ( !events ) {
  1780. elemData.events = events = {};
  1781. }
  1782. if ( !eventHandle ) {
  1783. elemData.handle = eventHandle = function() {
  1784. // Handle the second event of a trigger and when
  1785. // an event is called after a page has unloaded
  1786. return typeof jQuery !== "undefined" && !jQuery.event.triggered ?
  1787. jQuery.event.handle.apply( eventHandle.elem, arguments ) :
  1788. undefined;
  1789. };
  1790. }
  1791. // Add elem as a property of the handle function
  1792. // This is to prevent a memory leak with non-native events in IE.
  1793. eventHandle.elem = elem;
  1794. // Handle multiple events separated by a space
  1795. // jQuery(...).bind("mouseover mouseout", fn);
  1796. types = types.split(" ");
  1797. var type, i = 0, namespaces;
  1798. while ( (type = types[ i++ ]) ) {
  1799. handleObj = handleObjIn ?
  1800. jQuery.extend({}, handleObjIn) :
  1801. { handler: handler, data: data };
  1802. // Namespaced event handlers
  1803. if ( type.indexOf(".") > -1 ) {
  1804. namespaces = type.split(".");
  1805. type = namespaces.shift();
  1806. handleObj.namespace = namespaces.slice(0).sort().join(".");
  1807. } else {
  1808. namespaces = [];
  1809. handleObj.namespace = "";
  1810. }
  1811. handleObj.type = type;
  1812. if ( !handleObj.guid ) {
  1813. handleObj.guid = handler.guid;
  1814. }
  1815. // Get the current list of functions bound to this event
  1816. var handlers = events[ type ],
  1817. special = jQuery.event.special[ type ] || {};
  1818. // Init the event handler queue
  1819. if ( !handlers ) {
  1820. handlers = events[ type ] = [];
  1821. // Check for a special event handler
  1822. // Only use addEventListener/attachEvent if the special
  1823. // events handler returns false
  1824. if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
  1825. // Bind the global event handler to the element
  1826. if ( elem.addEventListener ) {
  1827. elem.addEventListener( type, eventHandle, false );
  1828. } else if ( elem.attachEvent ) {
  1829. elem.attachEvent( "on" + type, eventHandle );
  1830. }
  1831. }
  1832. }
  1833. if ( special.add ) {
  1834. special.add.call( elem, handleObj );
  1835. if ( !handleObj.handler.guid ) {
  1836. handleObj.handler.guid = handler.guid;
  1837. }
  1838. }
  1839. // Add the function to the element's handler list
  1840. handlers.push( handleObj );
  1841. // Keep track of which events have been used, for global triggering
  1842. jQuery.event.global[ type ] = true;
  1843. }
  1844. // Nullify elem to prevent memory leaks in IE
  1845. elem = null;
  1846. },
  1847. global: {},
  1848. // Detach an event or set of events from an element
  1849. remove: function( elem, types, handler, pos ) {
  1850. // don't do events on text and comment nodes
  1851. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  1852. return;
  1853. }
  1854. if ( handler === false ) {
  1855. handler = returnFalse;
  1856. }
  1857. var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType,
  1858. elemData = jQuery.hasData( elem ) && jQuery._data( elem ),
  1859. events = elemData && elemData.events;
  1860. if ( !elemData || !events ) {
  1861. return;
  1862. }
  1863. // types is actually an event object here
  1864. if ( types && types.type ) {
  1865. handler = types.handler;
  1866. types = types.type;
  1867. }
  1868. // Unbind all events for the element
  1869. if ( !types || typeof types === "string" && types.charAt(0) === "." ) {
  1870. types = types || "";
  1871. for ( type in events ) {
  1872. jQuery.event.remove( elem, type + types );
  1873. }
  1874. return;
  1875. }
  1876. // Handle multiple events separated by a space
  1877. // jQuery(...).unbind("mouseover mouseout", fn);
  1878. types = types.split(" ");
  1879. while ( (type = types[ i++ ]) ) {
  1880. origType = type;
  1881. handleObj = null;
  1882. all = type.indexOf(".") < 0;
  1883. namespaces = [];
  1884. if ( !all ) {
  1885. // Namespaced event handlers
  1886. namespaces = type.split(".");
  1887. type = namespaces.shift();
  1888. namespace = new RegExp("(^|\\.)" +
  1889. jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)");
  1890. }
  1891. eventType = events[ type ];
  1892. if ( !eventType ) {
  1893. continue;
  1894. }
  1895. if ( !handler ) {
  1896. for ( j = 0; j < eventType.length; j++ ) {
  1897. handleObj = eventType[ j ];
  1898. if ( all || namespace.test( handleObj.namespace ) ) {
  1899. jQuery.event.remove( elem, origType, handleObj.handler, j );
  1900. eventType.splice( j--, 1 );
  1901. }
  1902. }
  1903. continue;
  1904. }
  1905. special = jQuery.event.special[ type ] || {};
  1906. for ( j = pos || 0; j < eventType.length; j++ ) {
  1907. handleObj = eventType[ j ];
  1908. if ( handler.guid === handleObj.guid ) {
  1909. // remove the given handler for the given type
  1910. if ( all || namespace.test( handleObj.namespace ) ) {
  1911. if ( pos == null ) {
  1912. eventType.splice( j--, 1 );
  1913. }
  1914. if ( special.remove ) {
  1915. special.remove.call( elem, handleObj );
  1916. }
  1917. }
  1918. if ( pos != null ) {
  1919. break;
  1920. }
  1921. }
  1922. }
  1923. // remove generic event handler if no more handlers exist
  1924. if ( eventType.length === 0 || pos != null && eventType.length === 1 ) {
  1925. if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
  1926. jQuery.removeEvent( elem, type, elemData.handle );
  1927. }
  1928. ret = null;
  1929. delete events[ type ];
  1930. }
  1931. }
  1932. // Remove the expando if it's no longer used
  1933. if ( jQuery.isEmptyObject( events ) ) {
  1934. var handle = elemData.handle;
  1935. if ( handle ) {
  1936. handle.elem = null;
  1937. }
  1938. delete elemData.events;
  1939. delete elemData.handle;
  1940. if ( jQuery.isEmptyObject( elemData ) ) {
  1941. jQuery.removeData( elem, undefined, true );
  1942. }
  1943. }
  1944. },
  1945. // bubbling is internal
  1946. trigger: function( event, data, elem /*, bubbling */ ) {
  1947. // Event object or event type
  1948. var type = event.type || event,
  1949. bubbling = arguments[3];
  1950. if ( !bubbling ) {
  1951. event = typeof event === "object" ?
  1952. // jQuery.Event object
  1953. event[ jQuery.expando ] ? event :
  1954. // Object literal
  1955. jQuery.extend( jQuery.Event(type), event ) :
  1956. // Just the event type (string)
  1957. jQuery.Event(type);
  1958. if ( type.indexOf("!") >= 0 ) {
  1959. event.type = type = type.slice(0, -1);
  1960. event.exclusive = true;
  1961. }
  1962. // Handle a global trigger
  1963. if ( !elem ) {
  1964. // Don't bubble custom events when global (to avoid too much overhead)
  1965. event.stopPropagation();
  1966. // Only trigger if we've ever bound an event for it
  1967. if ( jQuery.event.global[ type ] ) {
  1968. // XXX This code smells terrible. event.js should not be directly
  1969. // inspecting the data cache
  1970. jQuery.each( jQuery.cache, function() {
  1971. // internalKey variable is just used to make it easier to find
  1972. // and potentially change this stuff later; currently it just
  1973. // points to jQuery.expando
  1974. var internalKey = jQuery.expando,
  1975. internalCache = this[ internalKey ];
  1976. if ( internalCache && internalCache.events && internalCache.events[ type ] ) {
  1977. jQuery.event.trigger( event, data, internalCache.handle.elem );
  1978. }
  1979. });
  1980. }
  1981. }
  1982. // Handle triggering a single element
  1983. // don't do events on text and comment nodes
  1984. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
  1985. return undefined;
  1986. }
  1987. // Clean up in case it is reused
  1988. event.result = undefined;
  1989. event.target = elem;
  1990. // Clone the incoming data, if any
  1991. data = jQuery.makeArray( data );
  1992. data.unshift( event );
  1993. }
  1994. event.currentTarget = elem;
  1995. // Trigger the event, it is assumed that "handle" is a function
  1996. var handle = jQuery._data( elem, "handle" );
  1997. if ( handle ) {
  1998. handle.apply( elem, data );
  1999. }
  2000. var parent = elem.parentNode || elem.ownerDocument;
  2001. // Trigger an inline bound script
  2002. try {
  2003. if ( !(elem && elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()]) ) {
  2004. if ( elem[ "on" + type ] && elem[ "on" + type ].apply( elem, data ) === false ) {
  2005. event.result = false;
  2006. event.preventDefault();
  2007. }
  2008. }
  2009. // prevent IE from throwing an erro