PageRenderTime 85ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/js/lib/jquery-1.5.1.js

http://github.com/onedayitwillmake/RealtimeMultiplayerNodeJs
JavaScript | 8316 lines | 5778 code | 1515 blank | 1023 comment | 1666 complexity | 416c4251d4835e7a5891977133e4173e MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, MPL-2.0-no-copyleft-exception, BSD-3-Clause
  1. /*!
  2. * jQuery JavaScript Library v1.5.1
  3. * http://jquery.com/
  4. *
  5. * Copyright 2011, 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 2011, The Dojo Foundation
  12. * Released under the MIT, BSD, and GPL Licenses.
  13. *
  14. * Date: Wed Feb 23 13:55:29 2011 -0500
  15. */
  16. (function( window, undefined ) {
  17. // Use the correct document accordingly with window argument (sandbox)
  18. var document = window.document;
  19. var jQuery = (function() {
  20. // Define a local copy of jQuery
  21. var jQuery = function( selector, context ) {
  22. // The jQuery object is actually just the init constructor 'enhanced'
  23. return new jQuery.fn.init( selector, context, rootjQuery );
  24. },
  25. // Map over jQuery in case of overwrite
  26. _jQuery = window.jQuery,
  27. // Map over the $ in case of overwrite
  28. _$ = window.$,
  29. // A central reference to the root jQuery(document)
  30. rootjQuery,
  31. // A simple way to check for HTML strings or ID strings
  32. // (both of which we optimize for)
  33. quickExpr = /^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/,
  34. // Check if a string has a non-whitespace character in it
  35. rnotwhite = /\S/,
  36. // Used for trimming whitespace
  37. trimLeft = /^\s+/,
  38. trimRight = /\s+$/,
  39. // Check for digits
  40. rdigit = /\d/,
  41. // Match a standalone tag
  42. rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
  43. // JSON RegExp
  44. rvalidchars = /^[\],:{}\s]*$/,
  45. rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
  46. rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
  47. rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
  48. // Useragent RegExp
  49. rwebkit = /(webkit)[ \/]([\w.]+)/,
  50. ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
  51. rmsie = /(msie) ([\w.]+)/,
  52. rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
  53. // Keep a UserAgent string for use with jQuery.browser
  54. userAgent = navigator.userAgent,
  55. // For matching the engine and version of the browser
  56. browserMatch,
  57. // Has the ready events already been bound?
  58. readyBound = false,
  59. // The deferred used on DOM ready
  60. readyList,
  61. // Promise methods
  62. promiseMethods = "then done fail isResolved isRejected promise".split( " " ),
  63. // The ready event handler
  64. DOMContentLoaded,
  65. // Save a reference to some core methods
  66. toString = Object.prototype.toString,
  67. hasOwn = Object.prototype.hasOwnProperty,
  68. push = Array.prototype.push,
  69. slice = Array.prototype.slice,
  70. trim = String.prototype.trim,
  71. indexOf = Array.prototype.indexOf,
  72. // [[Class]] -> type pairs
  73. class2type = {};
  74. jQuery.fn = jQuery.prototype = {
  75. constructor: jQuery,
  76. init: function( selector, context, rootjQuery ) {
  77. var match, elem, ret, doc;
  78. // Handle $(""), $(null), or $(undefined)
  79. if ( !selector ) {
  80. return this;
  81. }
  82. // Handle $(DOMElement)
  83. if ( selector.nodeType ) {
  84. this.context = this[0] = selector;
  85. this.length = 1;
  86. return this;
  87. }
  88. // The body element only exists once, optimize finding it
  89. if ( selector === "body" && !context && document.body ) {
  90. this.context = document;
  91. this[0] = document.body;
  92. this.selector = "body";
  93. this.length = 1;
  94. return this;
  95. }
  96. // Handle HTML strings
  97. if ( typeof selector === "string" ) {
  98. // Are we dealing with HTML string or an ID?
  99. match = quickExpr.exec( selector );
  100. // Verify a match, and that no context was specified for #id
  101. if ( match && (match[1] || !context) ) {
  102. // HANDLE: $(html) -> $(array)
  103. if ( match[1] ) {
  104. context = context instanceof jQuery ? context[0] : context;
  105. doc = (context ? context.ownerDocument || context : document);
  106. // If a single string is passed in and it's a single tag
  107. // just do a createElement and skip the rest
  108. ret = rsingleTag.exec( selector );
  109. if ( ret ) {
  110. if ( jQuery.isPlainObject( context ) ) {
  111. selector = [ document.createElement( ret[1] ) ];
  112. jQuery.fn.attr.call( selector, context, true );
  113. } else {
  114. selector = [ doc.createElement( ret[1] ) ];
  115. }
  116. } else {
  117. ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
  118. selector = (ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment).childNodes;
  119. }
  120. return jQuery.merge( this, selector );
  121. // HANDLE: $("#id")
  122. } else {
  123. elem = document.getElementById( match[2] );
  124. // Check parentNode to catch when Blackberry 4.6 returns
  125. // nodes that are no longer in the document #6963
  126. if ( elem && elem.parentNode ) {
  127. // Handle the case where IE and Opera return items
  128. // by name instead of ID
  129. if ( elem.id !== match[2] ) {
  130. return rootjQuery.find( selector );
  131. }
  132. // Otherwise, we inject the element directly into the jQuery object
  133. this.length = 1;
  134. this[0] = elem;
  135. }
  136. this.context = document;
  137. this.selector = selector;
  138. return this;
  139. }
  140. // HANDLE: $(expr, $(...))
  141. } else if ( !context || context.jquery ) {
  142. return (context || rootjQuery).find( selector );
  143. // HANDLE: $(expr, context)
  144. // (which is just equivalent to: $(context).find(expr)
  145. } else {
  146. return this.constructor( context ).find( selector );
  147. }
  148. // HANDLE: $(function)
  149. // Shortcut for document ready
  150. } else if ( jQuery.isFunction( selector ) ) {
  151. return rootjQuery.ready( selector );
  152. }
  153. if (selector.selector !== undefined) {
  154. this.selector = selector.selector;
  155. this.context = selector.context;
  156. }
  157. return jQuery.makeArray( selector, this );
  158. },
  159. // Start with an empty selector
  160. selector: "",
  161. // The current version of jQuery being used
  162. jquery: "1.5.1",
  163. // The default length of a jQuery object is 0
  164. length: 0,
  165. // The number of elements contained in the matched element set
  166. size: function() {
  167. return this.length;
  168. },
  169. toArray: function() {
  170. return slice.call( this, 0 );
  171. },
  172. // Get the Nth element in the matched element set OR
  173. // Get the whole matched element set as a clean array
  174. get: function( num ) {
  175. return num == null ?
  176. // Return a 'clean' array
  177. this.toArray() :
  178. // Return just the object
  179. ( num < 0 ? this[ this.length + num ] : this[ num ] );
  180. },
  181. // Take an array of elements and push it onto the stack
  182. // (returning the new matched element set)
  183. pushStack: function( elems, name, selector ) {
  184. // Build a new jQuery matched element set
  185. var ret = this.constructor();
  186. if ( jQuery.isArray( elems ) ) {
  187. push.apply( ret, elems );
  188. } else {
  189. jQuery.merge( ret, elems );
  190. }
  191. // Add the old object onto the stack (as a reference)
  192. ret.prevObject = this;
  193. ret.context = this.context;
  194. if ( name === "find" ) {
  195. ret.selector = this.selector + (this.selector ? " " : "") + selector;
  196. } else if ( name ) {
  197. ret.selector = this.selector + "." + name + "(" + selector + ")";
  198. }
  199. // Return the newly-formed element set
  200. return ret;
  201. },
  202. // Execute a callback for every element in the matched set.
  203. // (You can seed the arguments with an array of args, but this is
  204. // only used internally.)
  205. each: function( callback, args ) {
  206. return jQuery.each( this, callback, args );
  207. },
  208. ready: function( fn ) {
  209. // Attach the listeners
  210. jQuery.bindReady();
  211. // Add the callback
  212. readyList.done( fn );
  213. return this;
  214. },
  215. eq: function( i ) {
  216. return i === -1 ?
  217. this.slice( i ) :
  218. this.slice( i, +i + 1 );
  219. },
  220. first: function() {
  221. return this.eq( 0 );
  222. },
  223. last: function() {
  224. return this.eq( -1 );
  225. },
  226. slice: function() {
  227. return this.pushStack( slice.apply( this, arguments ),
  228. "slice", slice.call(arguments).join(",") );
  229. },
  230. map: function( callback ) {
  231. return this.pushStack( jQuery.map(this, function( elem, i ) {
  232. return callback.call( elem, i, elem );
  233. }));
  234. },
  235. end: function() {
  236. return this.prevObject || this.constructor(null);
  237. },
  238. // For internal use only.
  239. // Behaves like an Array's method, not like a jQuery method.
  240. push: push,
  241. sort: [].sort,
  242. splice: [].splice
  243. };
  244. // Give the init function the jQuery prototype for later instantiation
  245. jQuery.fn.init.prototype = jQuery.fn;
  246. jQuery.extend = jQuery.fn.extend = function() {
  247. var options, name, src, copy, copyIsArray, clone,
  248. target = arguments[0] || {},
  249. i = 1,
  250. length = arguments.length,
  251. deep = false;
  252. // Handle a deep copy situation
  253. if ( typeof target === "boolean" ) {
  254. deep = target;
  255. target = arguments[1] || {};
  256. // skip the boolean and the target
  257. i = 2;
  258. }
  259. // Handle case when target is a string or something (possible in deep copy)
  260. if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
  261. target = {};
  262. }
  263. // extend jQuery itself if only one argument is passed
  264. if ( length === i ) {
  265. target = this;
  266. --i;
  267. }
  268. for ( ; i < length; i++ ) {
  269. // Only deal with non-null/undefined values
  270. if ( (options = arguments[ i ]) != null ) {
  271. // Extend the base object
  272. for ( name in options ) {
  273. src = target[ name ];
  274. copy = options[ name ];
  275. // Prevent never-ending loop
  276. if ( target === copy ) {
  277. continue;
  278. }
  279. // Recurse if we're merging plain objects or arrays
  280. if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
  281. if ( copyIsArray ) {
  282. copyIsArray = false;
  283. clone = src && jQuery.isArray(src) ? src : [];
  284. } else {
  285. clone = src && jQuery.isPlainObject(src) ? src : {};
  286. }
  287. // Never move original objects, clone them
  288. target[ name ] = jQuery.extend( deep, clone, copy );
  289. // Don't bring in undefined values
  290. } else if ( copy !== undefined ) {
  291. target[ name ] = copy;
  292. }
  293. }
  294. }
  295. }
  296. // Return the modified object
  297. return target;
  298. };
  299. jQuery.extend({
  300. noConflict: function( deep ) {
  301. window.$ = _$;
  302. if ( deep ) {
  303. window.jQuery = _jQuery;
  304. }
  305. return jQuery;
  306. },
  307. // Is the DOM ready to be used? Set to true once it occurs.
  308. isReady: false,
  309. // A counter to track how many items to wait for before
  310. // the ready event fires. See #6781
  311. readyWait: 1,
  312. // Handle when the DOM is ready
  313. ready: function( wait ) {
  314. // A third-party is pushing the ready event forwards
  315. if ( wait === true ) {
  316. jQuery.readyWait--;
  317. }
  318. // Make sure that the DOM is not already loaded
  319. if ( !jQuery.readyWait || (wait !== true && !jQuery.isReady) ) {
  320. // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
  321. if ( !document.body ) {
  322. return setTimeout( jQuery.ready, 1 );
  323. }
  324. // Remember that the DOM is ready
  325. jQuery.isReady = true;
  326. // If a normal DOM Ready event fired, decrement, and wait if need be
  327. if ( wait !== true && --jQuery.readyWait > 0 ) {
  328. return;
  329. }
  330. // If there are functions bound, to execute
  331. readyList.resolveWith( document, [ jQuery ] );
  332. // Trigger any bound ready events
  333. if ( jQuery.fn.trigger ) {
  334. jQuery( document ).trigger( "ready" ).unbind( "ready" );
  335. }
  336. }
  337. },
  338. bindReady: function() {
  339. if ( readyBound ) {
  340. return;
  341. }
  342. readyBound = true;
  343. // Catch cases where $(document).ready() is called after the
  344. // browser event has already occurred.
  345. if ( document.readyState === "complete" ) {
  346. // Handle it asynchronously to allow scripts the opportunity to delay ready
  347. return setTimeout( jQuery.ready, 1 );
  348. }
  349. // Mozilla, Opera and webkit nightlies currently support this event
  350. if ( document.addEventListener ) {
  351. // Use the handy event callback
  352. document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
  353. // A fallback to window.onload, that will always work
  354. window.addEventListener( "load", jQuery.ready, false );
  355. // If IE event model is used
  356. } else if ( document.attachEvent ) {
  357. // ensure firing before onload,
  358. // maybe late but safe also for iframes
  359. document.attachEvent("onreadystatechange", DOMContentLoaded);
  360. // A fallback to window.onload, that will always work
  361. window.attachEvent( "onload", jQuery.ready );
  362. // If IE and not a frame
  363. // continually check to see if the document is ready
  364. var toplevel = false;
  365. try {
  366. toplevel = window.frameElement == null;
  367. } catch(e) {}
  368. if ( document.documentElement.doScroll && toplevel ) {
  369. doScrollCheck();
  370. }
  371. }
  372. },
  373. // See test/unit/core.js for details concerning isFunction.
  374. // Since version 1.3, DOM methods and functions like alert
  375. // aren't supported. They return false on IE (#2968).
  376. isFunction: function( obj ) {
  377. return jQuery.type(obj) === "function";
  378. },
  379. isArray: Array.isArray || function( obj ) {
  380. return jQuery.type(obj) === "array";
  381. },
  382. // A crude way of determining if an object is a window
  383. isWindow: function( obj ) {
  384. return obj && typeof obj === "object" && "setInterval" in obj;
  385. },
  386. isNaN: function( obj ) {
  387. return obj == null || !rdigit.test( obj ) || isNaN( obj );
  388. },
  389. type: function( obj ) {
  390. return obj == null ?
  391. String( obj ) :
  392. class2type[ toString.call(obj) ] || "object";
  393. },
  394. isPlainObject: function( obj ) {
  395. // Must be an Object.
  396. // Because of IE, we also have to check the presence of the constructor property.
  397. // Make sure that DOM nodes and window objects don't pass through, as well
  398. if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
  399. return false;
  400. }
  401. // Not own constructor property must be Object
  402. if ( obj.constructor &&
  403. !hasOwn.call(obj, "constructor") &&
  404. !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
  405. return false;
  406. }
  407. // Own properties are enumerated firstly, so to speed up,
  408. // if last one is own, then all properties are own.
  409. var key;
  410. for ( key in obj ) {}
  411. return key === undefined || hasOwn.call( obj, key );
  412. },
  413. isEmptyObject: function( obj ) {
  414. for ( var name in obj ) {
  415. return false;
  416. }
  417. return true;
  418. },
  419. error: function( msg ) {
  420. throw msg;
  421. },
  422. parseJSON: function( data ) {
  423. if ( typeof data !== "string" || !data ) {
  424. return null;
  425. }
  426. // Make sure leading/trailing whitespace is removed (IE can't handle it)
  427. data = jQuery.trim( data );
  428. // Make sure the incoming data is actual JSON
  429. // Logic borrowed from http://json.org/json2.js
  430. if ( rvalidchars.test(data.replace(rvalidescape, "@")
  431. .replace(rvalidtokens, "]")
  432. .replace(rvalidbraces, "")) ) {
  433. // Try to use the native JSON parser first
  434. return window.JSON && window.JSON.parse ?
  435. window.JSON.parse( data ) :
  436. (new Function("return " + data))();
  437. } else {
  438. jQuery.error( "Invalid JSON: " + data );
  439. }
  440. },
  441. // Cross-browser xml parsing
  442. // (xml & tmp used internally)
  443. parseXML: function( data , xml , tmp ) {
  444. if ( window.DOMParser ) { // Standard
  445. tmp = new DOMParser();
  446. xml = tmp.parseFromString( data , "text/xml" );
  447. } else { // IE
  448. xml = new ActiveXObject( "Microsoft.XMLDOM" );
  449. xml.async = "false";
  450. xml.loadXML( data );
  451. }
  452. tmp = xml.documentElement;
  453. if ( ! tmp || ! tmp.nodeName || tmp.nodeName === "parsererror" ) {
  454. jQuery.error( "Invalid XML: " + data );
  455. }
  456. return xml;
  457. },
  458. noop: function() {},
  459. // Evalulates a script in a global context
  460. globalEval: function( data ) {
  461. if ( data && rnotwhite.test(data) ) {
  462. // Inspired by code by Andrea Giammarchi
  463. // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
  464. var head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement,
  465. script = document.createElement( "script" );
  466. if ( jQuery.support.scriptEval() ) {
  467. script.appendChild( document.createTextNode( data ) );
  468. } else {
  469. script.text = data;
  470. }
  471. // Use insertBefore instead of appendChild to circumvent an IE6 bug.
  472. // This arises when a base node is used (#2709).
  473. head.insertBefore( script, head.firstChild );
  474. head.removeChild( script );
  475. }
  476. },
  477. nodeName: function( elem, name ) {
  478. return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
  479. },
  480. // args is for internal usage only
  481. each: function( object, callback, args ) {
  482. var name, i = 0,
  483. length = object.length,
  484. isObj = length === undefined || jQuery.isFunction(object);
  485. if ( args ) {
  486. if ( isObj ) {
  487. for ( name in object ) {
  488. if ( callback.apply( object[ name ], args ) === false ) {
  489. break;
  490. }
  491. }
  492. } else {
  493. for ( ; i < length; ) {
  494. if ( callback.apply( object[ i++ ], args ) === false ) {
  495. break;
  496. }
  497. }
  498. }
  499. // A special, fast, case for the most common use of each
  500. } else {
  501. if ( isObj ) {
  502. for ( name in object ) {
  503. if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
  504. break;
  505. }
  506. }
  507. } else {
  508. for ( var value = object[0];
  509. i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {}
  510. }
  511. }
  512. return object;
  513. },
  514. // Use native String.trim function wherever possible
  515. trim: trim ?
  516. function( text ) {
  517. return text == null ?
  518. "" :
  519. trim.call( text );
  520. } :
  521. // Otherwise use our own trimming functionality
  522. function( text ) {
  523. return text == null ?
  524. "" :
  525. text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
  526. },
  527. // results is for internal usage only
  528. makeArray: function( array, results ) {
  529. var ret = results || [];
  530. if ( array != null ) {
  531. // The window, strings (and functions) also have 'length'
  532. // The extra typeof function check is to prevent crashes
  533. // in Safari 2 (See: #3039)
  534. // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
  535. var type = jQuery.type(array);
  536. if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
  537. push.call( ret, array );
  538. } else {
  539. jQuery.merge( ret, array );
  540. }
  541. }
  542. return ret;
  543. },
  544. inArray: function( elem, array ) {
  545. if ( array.indexOf ) {
  546. return array.indexOf( elem );
  547. }
  548. for ( var i = 0, length = array.length; i < length; i++ ) {
  549. if ( array[ i ] === elem ) {
  550. return i;
  551. }
  552. }
  553. return -1;
  554. },
  555. merge: function( first, second ) {
  556. var i = first.length,
  557. j = 0;
  558. if ( typeof second.length === "number" ) {
  559. for ( var l = second.length; j < l; j++ ) {
  560. first[ i++ ] = second[ j ];
  561. }
  562. } else {
  563. while ( second[j] !== undefined ) {
  564. first[ i++ ] = second[ j++ ];
  565. }
  566. }
  567. first.length = i;
  568. return first;
  569. },
  570. grep: function( elems, callback, inv ) {
  571. var ret = [], retVal;
  572. inv = !!inv;
  573. // Go through the array, only saving the items
  574. // that pass the validator function
  575. for ( var i = 0, length = elems.length; i < length; i++ ) {
  576. retVal = !!callback( elems[ i ], i );
  577. if ( inv !== retVal ) {
  578. ret.push( elems[ i ] );
  579. }
  580. }
  581. return ret;
  582. },
  583. // arg is for internal usage only
  584. map: function( elems, callback, arg ) {
  585. var ret = [], value;
  586. // Go through the array, translating each of the items to their
  587. // new value (or values).
  588. for ( var i = 0, length = elems.length; i < length; i++ ) {
  589. value = callback( elems[ i ], i, arg );
  590. if ( value != null ) {
  591. ret[ ret.length ] = value;
  592. }
  593. }
  594. // Flatten any nested arrays
  595. return ret.concat.apply( [], ret );
  596. },
  597. // A global GUID counter for objects
  598. guid: 1,
  599. proxy: function( fn, proxy, thisObject ) {
  600. if ( arguments.length === 2 ) {
  601. if ( typeof proxy === "string" ) {
  602. thisObject = fn;
  603. fn = thisObject[ proxy ];
  604. proxy = undefined;
  605. } else if ( proxy && !jQuery.isFunction( proxy ) ) {
  606. thisObject = proxy;
  607. proxy = undefined;
  608. }
  609. }
  610. if ( !proxy && fn ) {
  611. proxy = function() {
  612. return fn.apply( thisObject || this, arguments );
  613. };
  614. }
  615. // Set the guid of unique handler to the same of original handler, so it can be removed
  616. if ( fn ) {
  617. proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
  618. }
  619. // So proxy can be declared as an argument
  620. return proxy;
  621. },
  622. // Mutifunctional method to get and set values to a collection
  623. // The value/s can be optionally by executed if its a function
  624. access: function( elems, key, value, exec, fn, pass ) {
  625. var length = elems.length;
  626. // Setting many attributes
  627. if ( typeof key === "object" ) {
  628. for ( var k in key ) {
  629. jQuery.access( elems, k, key[k], exec, fn, value );
  630. }
  631. return elems;
  632. }
  633. // Setting one attribute
  634. if ( value !== undefined ) {
  635. // Optionally, function values get executed if exec is true
  636. exec = !pass && exec && jQuery.isFunction(value);
  637. for ( var i = 0; i < length; i++ ) {
  638. fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
  639. }
  640. return elems;
  641. }
  642. // Getting an attribute
  643. return length ? fn( elems[0], key ) : undefined;
  644. },
  645. now: function() {
  646. return (new Date()).getTime();
  647. },
  648. // Create a simple deferred (one callbacks list)
  649. _Deferred: function() {
  650. var // callbacks list
  651. callbacks = [],
  652. // stored [ context , args ]
  653. fired,
  654. // to avoid firing when already doing so
  655. firing,
  656. // flag to know if the deferred has been cancelled
  657. cancelled,
  658. // the deferred itself
  659. deferred = {
  660. // done( f1, f2, ...)
  661. done: function() {
  662. if ( !cancelled ) {
  663. var args = arguments,
  664. i,
  665. length,
  666. elem,
  667. type,
  668. _fired;
  669. if ( fired ) {
  670. _fired = fired;
  671. fired = 0;
  672. }
  673. for ( i = 0, length = args.length; i < length; i++ ) {
  674. elem = args[ i ];
  675. type = jQuery.type( elem );
  676. if ( type === "array" ) {
  677. deferred.done.apply( deferred, elem );
  678. } else if ( type === "function" ) {
  679. callbacks.push( elem );
  680. }
  681. }
  682. if ( _fired ) {
  683. deferred.resolveWith( _fired[ 0 ], _fired[ 1 ] );
  684. }
  685. }
  686. return this;
  687. },
  688. // resolve with given context and args
  689. resolveWith: function( context, args ) {
  690. if ( !cancelled && !fired && !firing ) {
  691. firing = 1;
  692. try {
  693. while( callbacks[ 0 ] ) {
  694. callbacks.shift().apply( context, args );
  695. }
  696. }
  697. // We have to add a catch block for
  698. // IE prior to 8 or else the finally
  699. // block will never get executed
  700. catch (e) {
  701. throw e;
  702. }
  703. finally {
  704. fired = [ context, args ];
  705. firing = 0;
  706. }
  707. }
  708. return this;
  709. },
  710. // resolve with this as context and given arguments
  711. resolve: function() {
  712. deferred.resolveWith( jQuery.isFunction( this.promise ) ? this.promise() : this, arguments );
  713. return this;
  714. },
  715. // Has this deferred been resolved?
  716. isResolved: function() {
  717. return !!( firing || fired );
  718. },
  719. // Cancel
  720. cancel: function() {
  721. cancelled = 1;
  722. callbacks = [];
  723. return this;
  724. }
  725. };
  726. return deferred;
  727. },
  728. // Full fledged deferred (two callbacks list)
  729. Deferred: function( func ) {
  730. var deferred = jQuery._Deferred(),
  731. failDeferred = jQuery._Deferred(),
  732. promise;
  733. // Add errorDeferred methods, then and promise
  734. jQuery.extend( deferred, {
  735. then: function( doneCallbacks, failCallbacks ) {
  736. deferred.done( doneCallbacks ).fail( failCallbacks );
  737. return this;
  738. },
  739. fail: failDeferred.done,
  740. rejectWith: failDeferred.resolveWith,
  741. reject: failDeferred.resolve,
  742. isRejected: failDeferred.isResolved,
  743. // Get a promise for this deferred
  744. // If obj is provided, the promise aspect is added to the object
  745. promise: function( obj ) {
  746. if ( obj == null ) {
  747. if ( promise ) {
  748. return promise;
  749. }
  750. promise = obj = {};
  751. }
  752. var i = promiseMethods.length;
  753. while( i-- ) {
  754. obj[ promiseMethods[i] ] = deferred[ promiseMethods[i] ];
  755. }
  756. return obj;
  757. }
  758. } );
  759. // Make sure only one callback list will be used
  760. deferred.done( failDeferred.cancel ).fail( deferred.cancel );
  761. // Unexpose cancel
  762. delete deferred.cancel;
  763. // Call given func if any
  764. if ( func ) {
  765. func.call( deferred, deferred );
  766. }
  767. return deferred;
  768. },
  769. // Deferred helper
  770. when: function( object ) {
  771. var lastIndex = arguments.length,
  772. deferred = lastIndex <= 1 && object && jQuery.isFunction( object.promise ) ?
  773. object :
  774. jQuery.Deferred(),
  775. promise = deferred.promise();
  776. if ( lastIndex > 1 ) {
  777. var array = slice.call( arguments, 0 ),
  778. count = lastIndex,
  779. iCallback = function( index ) {
  780. return function( value ) {
  781. array[ index ] = arguments.length > 1 ? slice.call( arguments, 0 ) : value;
  782. if ( !( --count ) ) {
  783. deferred.resolveWith( promise, array );
  784. }
  785. };
  786. };
  787. while( ( lastIndex-- ) ) {
  788. object = array[ lastIndex ];
  789. if ( object && jQuery.isFunction( object.promise ) ) {
  790. object.promise().then( iCallback(lastIndex), deferred.reject );
  791. } else {
  792. --count;
  793. }
  794. }
  795. if ( !count ) {
  796. deferred.resolveWith( promise, array );
  797. }
  798. } else if ( deferred !== object ) {
  799. deferred.resolve( object );
  800. }
  801. return promise;
  802. },
  803. // Use of jQuery.browser is frowned upon.
  804. // More details: http://docs.jquery.com/Utilities/jQuery.browser
  805. uaMatch: function( ua ) {
  806. ua = ua.toLowerCase();
  807. var match = rwebkit.exec( ua ) ||
  808. ropera.exec( ua ) ||
  809. rmsie.exec( ua ) ||
  810. ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
  811. [];
  812. return { browser: match[1] || "", version: match[2] || "0" };
  813. },
  814. sub: function() {
  815. function jQuerySubclass( selector, context ) {
  816. return new jQuerySubclass.fn.init( selector, context );
  817. }
  818. jQuery.extend( true, jQuerySubclass, this );
  819. jQuerySubclass.superclass = this;
  820. jQuerySubclass.fn = jQuerySubclass.prototype = this();
  821. jQuerySubclass.fn.constructor = jQuerySubclass;
  822. jQuerySubclass.subclass = this.subclass;
  823. jQuerySubclass.fn.init = function init( selector, context ) {
  824. if ( context && context instanceof jQuery && !(context instanceof jQuerySubclass) ) {
  825. context = jQuerySubclass(context);
  826. }
  827. return jQuery.fn.init.call( this, selector, context, rootjQuerySubclass );
  828. };
  829. jQuerySubclass.fn.init.prototype = jQuerySubclass.fn;
  830. var rootjQuerySubclass = jQuerySubclass(document);
  831. return jQuerySubclass;
  832. },
  833. browser: {}
  834. });
  835. // Create readyList deferred
  836. readyList = jQuery._Deferred();
  837. // Populate the class2type map
  838. jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
  839. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  840. });
  841. browserMatch = jQuery.uaMatch( userAgent );
  842. if ( browserMatch.browser ) {
  843. jQuery.browser[ browserMatch.browser ] = true;
  844. jQuery.browser.version = browserMatch.version;
  845. }
  846. // Deprecated, use jQuery.browser.webkit instead
  847. if ( jQuery.browser.webkit ) {
  848. jQuery.browser.safari = true;
  849. }
  850. if ( indexOf ) {
  851. jQuery.inArray = function( elem, array ) {
  852. return indexOf.call( array, elem );
  853. };
  854. }
  855. // IE doesn't match non-breaking spaces with \s
  856. if ( rnotwhite.test( "\xA0" ) ) {
  857. trimLeft = /^[\s\xA0]+/;
  858. trimRight = /[\s\xA0]+$/;
  859. }
  860. // All jQuery objects should point back to these
  861. rootjQuery = jQuery(document);
  862. // Cleanup functions for the document ready method
  863. if ( document.addEventListener ) {
  864. DOMContentLoaded = function() {
  865. document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
  866. jQuery.ready();
  867. };
  868. } else if ( document.attachEvent ) {
  869. DOMContentLoaded = function() {
  870. // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
  871. if ( document.readyState === "complete" ) {
  872. document.detachEvent( "onreadystatechange", DOMContentLoaded );
  873. jQuery.ready();
  874. }
  875. };
  876. }
  877. // The DOM ready check for Internet Explorer
  878. function doScrollCheck() {
  879. if ( jQuery.isReady ) {
  880. return;
  881. }
  882. try {
  883. // If IE is used, use the trick by Diego Perini
  884. // http://javascript.nwbox.com/IEContentLoaded/
  885. document.documentElement.doScroll("left");
  886. } catch(e) {
  887. setTimeout( doScrollCheck, 1 );
  888. return;
  889. }
  890. // and execute any waiting functions
  891. jQuery.ready();
  892. }
  893. // Expose jQuery to the global object
  894. return jQuery;
  895. })();
  896. (function() {
  897. jQuery.support = {};
  898. var div = document.createElement("div");
  899. div.style.display = "none";
  900. div.innerHTML = " <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
  901. var all = div.getElementsByTagName("*"),
  902. a = div.getElementsByTagName("a")[0],
  903. select = document.createElement("select"),
  904. opt = select.appendChild( document.createElement("option") ),
  905. input = div.getElementsByTagName("input")[0];
  906. // Can't get basic test support
  907. if ( !all || !all.length || !a ) {
  908. return;
  909. }
  910. jQuery.support = {
  911. // IE strips leading whitespace when .innerHTML is used
  912. leadingWhitespace: div.firstChild.nodeType === 3,
  913. // Make sure that tbody elements aren't automatically inserted
  914. // IE will insert them into empty tables
  915. tbody: !div.getElementsByTagName("tbody").length,
  916. // Make sure that link elements get serialized correctly by innerHTML
  917. // This requires a wrapper element in IE
  918. htmlSerialize: !!div.getElementsByTagName("link").length,
  919. // Get the style information from getAttribute
  920. // (IE uses .cssText insted)
  921. style: /red/.test( a.getAttribute("style") ),
  922. // Make sure that URLs aren't manipulated
  923. // (IE normalizes it by default)
  924. hrefNormalized: a.getAttribute("href") === "/a",
  925. // Make sure that element opacity exists
  926. // (IE uses filter instead)
  927. // Use a regex to work around a WebKit issue. See #5145
  928. opacity: /^0.55$/.test( a.style.opacity ),
  929. // Verify style float existence
  930. // (IE uses styleFloat instead of cssFloat)
  931. cssFloat: !!a.style.cssFloat,
  932. // Make sure that if no value is specified for a checkbox
  933. // that it defaults to "on".
  934. // (WebKit defaults to "" instead)
  935. checkOn: input.value === "on",
  936. // Make sure that a selected-by-default option has a working selected property.
  937. // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
  938. optSelected: opt.selected,
  939. // Will be defined later
  940. deleteExpando: true,
  941. optDisabled: false,
  942. checkClone: false,
  943. noCloneEvent: true,
  944. noCloneChecked: true,
  945. boxModel: null,
  946. inlineBlockNeedsLayout: false,
  947. shrinkWrapBlocks: false,
  948. reliableHiddenOffsets: true
  949. };
  950. input.checked = true;
  951. jQuery.support.noCloneChecked = input.cloneNode( true ).checked;
  952. // Make sure that the options inside disabled selects aren't marked as disabled
  953. // (WebKit marks them as diabled)
  954. select.disabled = true;
  955. jQuery.support.optDisabled = !opt.disabled;
  956. var _scriptEval = null;
  957. jQuery.support.scriptEval = function() {
  958. if ( _scriptEval === null ) {
  959. var root = document.documentElement,
  960. script = document.createElement("script"),
  961. id = "script" + jQuery.now();
  962. try {
  963. script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
  964. } catch(e) {}
  965. root.insertBefore( script, root.firstChild );
  966. // Make sure that the execution of code works by injecting a script
  967. // tag with appendChild/createTextNode
  968. // (IE doesn't support this, fails, and uses .text instead)
  969. if ( window[ id ] ) {
  970. _scriptEval = true;
  971. delete window[ id ];
  972. } else {
  973. _scriptEval = false;
  974. }
  975. root.removeChild( script );
  976. // release memory in IE
  977. root = script = id = null;
  978. }
  979. return _scriptEval;
  980. };
  981. // Test to see if it's possible to delete an expando from an element
  982. // Fails in Internet Explorer
  983. try {
  984. delete div.test;
  985. } catch(e) {
  986. jQuery.support.deleteExpando = false;
  987. }
  988. if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
  989. div.attachEvent("onclick", function click() {
  990. // Cloning a node shouldn't copy over any
  991. // bound event handlers (IE does this)
  992. jQuery.support.noCloneEvent = false;
  993. div.detachEvent("onclick", click);
  994. });
  995. div.cloneNode(true).fireEvent("onclick");
  996. }
  997. div = document.createElement("div");
  998. div.innerHTML = "<input type='radio' name='radiotest' checked='checked'/>";
  999. var fragment = document.createDocumentFragment();
  1000. fragment.appendChild( div.firstChild );
  1001. // WebKit doesn't clone checked state correctly in fragments
  1002. jQuery.support.checkClone = fragment.cloneNode(true).cloneNode(true).lastChild.checked;
  1003. // Figure out if the W3C box model works as expected
  1004. // document.body must exist before we can do this
  1005. jQuery(function() {
  1006. var div = document.createElement("div"),
  1007. body = document.getElementsByTagName("body")[0];
  1008. // Frameset documents with no body should not run this code
  1009. if ( !body ) {
  1010. return;
  1011. }
  1012. div.style.width = div.style.paddingLeft = "1px";
  1013. body.appendChild( div );
  1014. jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2;
  1015. if ( "zoom" in div.style ) {
  1016. // Check if natively block-level elements act like inline-block
  1017. // elements when setting their display to 'inline' and giving
  1018. // them layout
  1019. // (IE < 8 does this)
  1020. div.style.display = "inline";
  1021. div.style.zoom = 1;
  1022. jQuery.support.inlineBlockNeedsLayout = div.offsetWidth === 2;
  1023. // Check if elements with layout shrink-wrap their children
  1024. // (IE 6 does this)
  1025. div.style.display = "";
  1026. div.innerHTML = "<div style='width:4px;'></div>";
  1027. jQuery.support.shrinkWrapBlocks = div.offsetWidth !== 2;
  1028. }
  1029. div.innerHTML = "<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>";
  1030. var tds = div.getElementsByTagName("td");
  1031. // Check if table cells still have offsetWidth/Height when they are set
  1032. // to display:none and there are still other visible table cells in a
  1033. // table row; if so, offsetWidth/Height are not reliable for use when
  1034. // determining if an element has been hidden directly using
  1035. // display:none (it is still safe to use offsets if a parent element is
  1036. // hidden; don safety goggles and see bug #4512 for more information).
  1037. // (only IE 8 fails this test)
  1038. jQuery.support.reliableHiddenOffsets = tds[0].offsetHeight === 0;
  1039. tds[0].style.display = "";
  1040. tds[1].style.display = "none";
  1041. // Check if empty table cells still have offsetWidth/Height
  1042. // (IE < 8 fail this test)
  1043. jQuery.support.reliableHiddenOffsets = jQuery.support.reliableHiddenOffsets && tds[0].offsetHeight === 0;
  1044. div.innerHTML = "";
  1045. body.removeChild( div ).style.display = "none";
  1046. div = tds = null;
  1047. });
  1048. // Technique from Juriy Zaytsev
  1049. // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
  1050. var eventSupported = function( eventName ) {
  1051. var el = document.createElement("div");
  1052. eventName = "on" + eventName;
  1053. // We only care about the case where non-standard event systems
  1054. // are used, namely in IE. Short-circuiting here helps us to
  1055. // avoid an eval call (in setAttribute) which can cause CSP
  1056. // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
  1057. if ( !el.attachEvent ) {
  1058. return true;
  1059. }
  1060. var isSupported = (eventName in el);
  1061. if ( !isSupported ) {
  1062. el.setAttribute(eventName, "return;");
  1063. isSupported = typeof el[eventName] === "function";
  1064. }
  1065. el = null;
  1066. return isSupported;
  1067. };
  1068. jQuery.support.submitBubbles = eventSupported("submit");
  1069. jQuery.support.changeBubbles = eventSupported("change");
  1070. // release memory in IE
  1071. div = all = a = null;
  1072. })();
  1073. var rbrace = /^(?:\{.*\}|\[.*\])$/;
  1074. jQuery.extend({
  1075. cache: {},
  1076. // Please use with caution
  1077. uuid: 0,
  1078. // Unique for each copy of jQuery on the page
  1079. // Non-digits removed to match rinlinejQuery
  1080. expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),
  1081. // The following elements throw uncatchable exceptions if you
  1082. // attempt to add expando properties to them.
  1083. noData: {
  1084. "embed": true,
  1085. // Ban all objects except for Flash (which handle expandos)
  1086. "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
  1087. "applet": true
  1088. },
  1089. hasData: function( elem ) {
  1090. elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
  1091. return !!elem && !isEmptyDataObject( elem );
  1092. },
  1093. data: function( elem, name, data, pvt /* Internal Use Only */ ) {
  1094. if ( !jQuery.acceptData( elem ) ) {
  1095. return;
  1096. }
  1097. var internalKey = jQuery.expando, getByName = typeof name === "string", thisCache,
  1098. // We have to handle DOM nodes and JS objects differently because IE6-7
  1099. // can't GC object references properly across the DOM-JS boundary
  1100. isNode = elem.nodeType,
  1101. // Only DOM nodes need the global jQuery cache; JS object data is
  1102. // attached directly to the object so GC can occur automatically
  1103. cache = isNode ? jQuery.cache : elem,
  1104. // Only defining an ID for JS objects if its cache already exists allows
  1105. // the code to shortcut on the same path as a DOM node with no cache
  1106. id = isNode ? elem[ jQuery.expando ] : elem[ jQuery.expando ] && jQuery.expando;
  1107. // Avoid doing any more work than we need to when trying to get data on an
  1108. // object that has no data at all
  1109. if ( (!id || (pvt && id && !cache[ id ][ internalKey ])) && getByName && data === undefined ) {
  1110. return;
  1111. }
  1112. if ( !id ) {
  1113. // Only DOM nodes need a new unique ID for each element since their data
  1114. // ends up in the global cache
  1115. if ( isNode ) {
  1116. elem[ jQuery.expando ] = id = ++jQuery.uuid;
  1117. } else {
  1118. id = jQuery.expando;
  1119. }
  1120. }
  1121. if ( !cache[ id ] ) {
  1122. cache[ id ] = {};
  1123. // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
  1124. // metadata on plain JS objects when the object is serialized using
  1125. // JSON.stringify
  1126. if ( !isNode ) {
  1127. cache[ id ].toJSON = jQuery.noop;
  1128. }
  1129. }
  1130. // An object can be passed to jQuery.data instead of a key/value pair; this gets
  1131. // shallow copied over onto the existing cache
  1132. if ( typeof name === "object" || typeof name === "function" ) {
  1133. if ( pvt ) {
  1134. cache[ id ][ internalKey ] = jQuery.extend(cache[ id ][ internalKey ], name);
  1135. } else {
  1136. cache[ id ] = jQuery.extend(cache[ id ], name);
  1137. }
  1138. }
  1139. thisCache = cache[ id ];
  1140. // Internal jQuery data is stored in a separate object inside the object's data
  1141. // cache in order to avoid key collisions between internal data and user-defined
  1142. // data
  1143. if ( pvt ) {
  1144. if ( !thisCache[ internalKey ] ) {
  1145. thisCache[ internalKey ] = {};
  1146. }
  1147. thisCache = thisCache[ internalKey ];
  1148. }
  1149. if ( data !== undefined ) {
  1150. thisCache[ name ] = data;
  1151. }
  1152. // TODO: This is a hack for 1.5 ONLY. It will be removed in 1.6. Users should
  1153. // not attempt to inspect the internal events object using jQuery.data, as this
  1154. // internal data object is undocumented and subject to change.
  1155. if ( name === "events" && !thisCache[name] ) {
  1156. return thisCache[ internalKey ] && thisCache[ internalKey ].events;
  1157. }
  1158. return getByName ? thisCache[ name ] : thisCache;
  1159. },
  1160. removeData: function( elem, name, pvt /* Internal Use Only */ ) {
  1161. if ( !jQuery.acceptData( elem ) ) {
  1162. return;
  1163. }
  1164. var internalKey = jQuery.expando, isNode = elem.nodeType,
  1165. // See jQuery.data for more information
  1166. cache = isNode ? jQuery.cache : elem,
  1167. // See jQuery.data for more information
  1168. id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
  1169. // If there is already no cache entry for this object, there is no
  1170. // purpose in continuing
  1171. if ( !cache[ id ] ) {
  1172. return;
  1173. }
  1174. if ( name ) {
  1175. var thisCache = pvt ? cache[ id ][ internalKey ] : cache[ id ];
  1176. if ( thisCache ) {
  1177. delete thisCache[ name ];
  1178. // If there is no data left in the cache, we want to continue
  1179. // and let the cache object itself get destroyed
  1180. if ( !isEmptyDataObject(thisCache) ) {
  1181. return;
  1182. }
  1183. }
  1184. }
  1185. // See jQuery.data for more information
  1186. if ( pvt ) {
  1187. delete cache[ id ][ internalKey ];
  1188. // Don't destroy the parent cache unless the internal data object
  1189. // had been the only thing left in it
  1190. if ( !isEmptyDataObject(cache[ id ]) ) {
  1191. return;
  1192. }
  1193. }
  1194. var internalCache = cache[ id ][ internalKey ];
  1195. // Browsers that fail expando deletion also refuse to delete expandos on
  1196. // the window, but it will allow it on all other JS objects; other browsers
  1197. // don't care
  1198. if ( jQuery.support.deleteExpando || cache != window ) {
  1199. delete cache[ id ];
  1200. } else {
  1201. cache[ id ] = null;
  1202. }
  1203. // We destroyed the entire user cache at once because it's faster than
  1204. // iterating through each key, but we need to continue to persist internal
  1205. // data if it existed
  1206. if ( internalCache ) {
  1207. cache[ id ] = {};
  1208. // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
  1209. // metadata on plain JS objects when the object is serialized using
  1210. // JSON.stringify
  1211. if ( !isNode ) {
  1212. cache[ id ].toJSON = jQuery.noop;
  1213. }
  1214. cache[ id ][ internalKey ] = internalCache;
  1215. // Otherwise, we need to eliminate the expando on the node to avoid
  1216. // false lookups in the cache for entries that no longer exist
  1217. } else if ( isNode ) {
  1218. // IE does not allow us to delete expando properties from nodes,
  1219. // nor does it have a removeAttribute function on Document nodes;
  1220. // we must handle all of these cases
  1221. if ( jQuery.support.deleteExpando ) {
  1222. delete elem[ jQuery.expando ];
  1223. } else if ( elem.removeAttribute ) {
  1224. elem.removeAttribute( jQuery.expando );
  1225. } else {
  1226. elem[ jQuery.expando ] = null;
  1227. }
  1228. }
  1229. },
  1230. // For internal use only.
  1231. _data: function( elem, name, data ) {
  1232. return jQuery.data( elem, name, data, true );
  1233. },
  1234. // A method for determining if a DOM node can handle the data expando
  1235. acceptData: function( elem ) {
  1236. if ( elem.nodeName ) {
  1237. var match = jQuery.noData[ elem.nodeName.toLowerCase() ];
  1238. if ( match ) {
  1239. return !(match === true || elem.getAttribute("classid") !== match);
  1240. }
  1241. }
  1242. return true;
  1243. }
  1244. });
  1245. jQuery.fn.extend({
  1246. data: function( key, value ) {
  1247. var data = null;
  1248. if ( typeof key === "undefined" ) {
  1249. if ( this.length ) {
  1250. data = jQuery.data( this[0] );
  1251. if ( this[0].nodeType === 1 ) {
  1252. var attr = this[0].attributes, name;
  1253. for ( var i = 0, l = attr.length; i < l; i++ ) {
  1254. name = attr[i].name;
  1255. if ( name.indexOf( "data-" ) === 0 ) {
  1256. name = name.substr( 5 );
  1257. dataAttr( this[0], name, data[ name ] );
  1258. }
  1259. }
  1260. }
  1261. }
  1262. return data;
  1263. } else if ( typeof key === "object" ) {
  1264. return this.each(function() {
  1265. jQuery.data( this, key );
  1266. });
  1267. }
  1268. var parts = key.split(".");
  1269. parts[1] = parts[1] ? "." + parts[1] : "";
  1270. if ( value === undefined ) {
  1271. data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
  1272. // Try to fetch any internally stored data first
  1273. if ( data === undefined && this.length ) {
  1274. data = jQuery.data( this[0], key );
  1275. data = dataAttr( this[0], key, data );
  1276. }
  1277. return data === undefined && parts[1] ?
  1278. this.data( parts[0] ) :
  1279. data;
  1280. } else {
  1281. return this.each(function() {
  1282. var $this = jQuery( this ),
  1283. args = [ parts[0], value ];
  1284. $this.triggerHandler( "setData" + parts[1] + "!", args );
  1285. jQuery.data( this, key, value );
  1286. $this.triggerHandler( "changeData" + parts[1] + "!", args );
  1287. });
  1288. }
  1289. },
  1290. removeData: function( key ) {
  1291. return this.each(function() {
  1292. jQuery.removeData( this, key );
  1293. });
  1294. }
  1295. });
  1296. function dataAttr( elem, key, data ) {
  1297. // If nothing was found internally, try to fetch any
  1298. // data from the HTML5 data-* attribute
  1299. if ( data === undefined && elem.nodeType === 1 ) {
  1300. data = elem.getAttribute( "data-" + key );
  1301. if ( typeof data === "string" ) {
  1302. try {
  1303. data = data === "true" ? true :
  1304. data === "false" ? false :
  1305. data === "null" ? null :
  1306. !jQuery.isNaN( data ) ? parseFloat( data ) :
  1307. rbrace.test( data ) ? jQuery.parseJSON( data ) :
  1308. data;
  1309. } catch( e ) {}
  1310. // Make sure we set the data so it isn't changed later
  1311. jQuery.data( elem, key, data );
  1312. } else {
  1313. data = undefined;
  1314. }
  1315. }
  1316. return data;
  1317. }
  1318. // TODO: This is a hack for 1.5 ONLY to allow objects with a single toJSON
  1319. // property to be considered empty objects; this property always exists in
  1320. // order to make sure JSON.stringify does not expose internal metadata
  1321. function isEmptyDataObject( obj ) {
  1322. for ( var name in obj ) {
  1323. if ( name !== "toJSON" ) {
  1324. return false;
  1325. }
  1326. }
  1327. return true;
  1328. }
  1329. jQuery.extend({
  1330. queue: function( elem, type, data ) {
  1331. if ( !elem ) {
  1332. return;
  1333. }
  1334. type = (type || "fx") + "queue";
  1335. var q = jQuery._data( elem, type );
  1336. // Speed up dequeue by getting out quickly if this is just a lookup
  1337. if ( !data ) {
  1338. return q || [];
  1339. }
  1340. if ( !q || jQuery.isArray(data) ) {
  1341. q = jQuery._data( elem, type, jQuery.makeArray(data) );
  1342. } else {
  1343. q.push( data );
  1344. }
  1345. return q;
  1346. },
  1347. dequeue: function( elem, type ) {
  1348. type = type || "fx";
  1349. var queue = jQuery.queue( elem, type ),
  1350. fn = queue.shift();
  1351. // If the fx queue is dequeued, always remove the progress sentinel
  1352. if ( fn === "inprogress" ) {
  1353. fn = queue.shift();
  1354. }
  1355. if ( fn ) {
  1356. // Add a progress sentinel to prevent the fx queue from being
  1357. // automatically dequeued
  1358. if ( type === "fx" ) {
  1359. queue.unshift("inprogress");
  1360. }
  1361. fn.call(elem, function() {
  1362. jQuery.dequeue(elem, type);
  1363. });
  1364. }
  1365. if ( !queue.length ) {
  1366. jQuery.removeData( elem, type + "queue", true );
  1367. }
  1368. }
  1369. });
  1370. jQuery.fn.extend({
  1371. queue: function( type, data ) {
  1372. if ( typeof type !== "string" ) {
  1373. data = type;
  1374. type = "fx";
  1375. }
  1376. if ( data === undefined ) {
  1377. return jQuery.queue( this[0], type );
  1378. }
  1379. return this.each(function( i ) {
  1380. var queue = jQuery.queue( this, type, data );
  1381. if ( type === "fx" && queue[0] !== "inprogress" ) {
  1382. jQuery.dequeue( this, type );
  1383. }
  1384. });
  1385. },
  1386. dequeue: function( type ) {
  1387. return this.each(function() {
  1388. jQuery.dequeue( this, type );
  1389. });
  1390. },
  1391. // Based off of the plugin by Clint Helfers, with permission.
  1392. // http://blindsignals.com/index.php/2009/07/jquery-delay/
  1393. delay: function( time, type ) {
  1394. time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
  1395. type = type || "fx";
  1396. return this.queue( type, function() {
  1397. var elem = this;
  1398. setTimeout(function() {
  1399. jQuery.dequeue( elem, type );
  1400. }, time );
  1401. });
  1402. },
  1403. clearQueue: function( type ) {
  1404. return this.queue( type || "fx", [] );
  1405. }
  1406. });
  1407. var rclass = /[\n\t\r]/g,
  1408. rspaces = /\s+/,
  1409. rreturn = /\r/g,
  1410. rspecialurl = /^(?:href|src|style)$/,
  1411. rtype = /^(?:button|input)$/i,
  1412. rfocusable = /^(?:button|input|object|select|textarea)$/i,
  1413. rclickable = /^a(?:rea)?$/i,
  1414. rradiocheck = /^(?:radio|checkbox)$/i;
  1415. jQuery.props = {
  1416. "for": "htmlFor",
  1417. "class": "className",
  1418. readonly: "readOnly",
  1419. maxlength: "maxLength",
  1420. cellspacing: "cellSpacing",
  1421. rowspan: "rowSpan",
  1422. colspan: "colSpan",
  1423. tabindex: "tabIndex",
  1424. usemap: "useMap",
  1425. frameborder: "frameBorder"
  1426. };
  1427. jQuery.fn.extend({
  1428. attr: function( name, value ) {
  1429. return jQuery.access( this, name, value, true, jQuery.attr );
  1430. },
  1431. removeAttr: function( name, fn ) {
  1432. return this.each(function(){
  1433. jQuery.attr( this, name, "" );
  1434. if ( this.nodeType === 1 ) {
  1435. this.removeAttribute( name );
  1436. }
  1437. });
  1438. },
  1439. addClass: function( value ) {
  1440. if ( jQuery.isFunction(value) ) {
  1441. return this.each(function(i) {
  1442. var self = jQuery(this);
  1443. self.addClass( value.call(this, i, self.attr("class")) );
  1444. });
  1445. }
  1446. if ( value && typeof value === "string" ) {
  1447. var classNames = (value || "").split( rspaces );
  1448. for ( var i = 0, l = this.length; i < l; i++ ) {
  1449. var elem = this[i];
  1450. if ( elem.nodeType === 1 ) {
  1451. if ( !elem.className ) {
  1452. elem.className = value;
  1453. } else {
  1454. var className = " " + elem.className + " ",
  1455. setClass = elem.className;
  1456. for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
  1457. if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) {
  1458. setClass += " " + classNames[c];
  1459. }
  1460. }
  1461. elem.className = jQuery.trim( setClass );
  1462. }
  1463. }
  1464. }
  1465. }
  1466. return this;
  1467. },
  1468. removeClass: function( value ) {
  1469. if ( jQuery.isFunction(value) ) {
  1470. return this.each(function(i) {
  1471. var self = jQuery(this);
  1472. self.removeClass( value.call(this, i, self.attr("class")) );
  1473. });
  1474. }
  1475. if ( (value && typeof value === "string") || value === undefined ) {
  1476. var classNames = (value || "").split( rspaces );
  1477. for ( var i = 0, l = this.length; i < l; i++ ) {
  1478. var elem = this[i];
  1479. if ( elem.nodeType === 1 && elem.className ) {
  1480. if ( value ) {
  1481. var className = (" " + elem.className + " ").replace(rclass, " ");
  1482. for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
  1483. className = className.replace(" " + classNames[c] + " ", " ");
  1484. }
  1485. elem.className = jQuery.trim( className );
  1486. } else {
  1487. elem.className = "";
  1488. }
  1489. }
  1490. }
  1491. }
  1492. return this;
  1493. },
  1494. toggleClass: function( value, stateVal ) {
  1495. var type = typeof value,
  1496. isBool = typeof stateVal === "boolean";
  1497. if ( jQuery.isFunction( value ) ) {
  1498. return this.each(function(i) {
  1499. var self = jQuery(this);
  1500. self.toggleClass( value.call(this, i, self.attr("class"), stateVal), stateVal );
  1501. });
  1502. }
  1503. return this.each(function() {
  1504. if ( type === "string" ) {
  1505. // toggle individual class names
  1506. var className,
  1507. i = 0,
  1508. self = jQuery( this ),
  1509. state = stateVal,
  1510. classNames = value.split( rspaces );
  1511. while ( (className = classNames[ i++ ]) ) {
  1512. // check each className given, space seperated list
  1513. state = isBool ? state : !self.hasClass( className );
  1514. self[ state ? "addClass" : "removeClass" ]( className );
  1515. }
  1516. } else if ( type === "undefined" || type === "boolean" ) {
  1517. if ( this.className ) {
  1518. // store className if set
  1519. jQuery._data( this, "__className__", this.className );
  1520. }
  1521. // toggle whole className
  1522. this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
  1523. }
  1524. });
  1525. },
  1526. hasClass: function( selector ) {
  1527. var className = " " + selector + " ";
  1528. for ( var i = 0, l = this.length; i < l; i++ ) {
  1529. if ( (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
  1530. return true;
  1531. }
  1532. }
  1533. return false;
  1534. },
  1535. val: function( value ) {
  1536. if ( !arguments.length ) {
  1537. var elem = this[0];
  1538. if ( elem ) {
  1539. if ( jQuery.nodeName( elem, "option" ) ) {
  1540. // attributes.value is undefined in Blackberry 4.7 but
  1541. // uses .value. See #6932
  1542. var val = elem.attributes.value;
  1543. return !val || val.specified ? elem.value : elem.text;
  1544. }
  1545. // We need to handle select boxes special
  1546. if ( jQuery.nodeName( elem, "select" ) ) {
  1547. var index = elem.selectedIndex,
  1548. values = [],
  1549. options = elem.options,
  1550. one = elem.type === "select-one";
  1551. // Nothing was selected
  1552. if ( index < 0 ) {
  1553. return null;
  1554. }
  1555. // Loop through all the selected options
  1556. for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
  1557. var option = options[ i ];
  1558. // Don't return options that are disabled or in a disabled optgroup
  1559. if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
  1560. (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
  1561. // Get the specific value for the option
  1562. value = jQuery(option).val();
  1563. // We don't need an array for one selects
  1564. if ( one ) {
  1565. return value;
  1566. }
  1567. // Multi-Selects return an array
  1568. values.push( value );
  1569. }
  1570. }
  1571. // Fixes Bug #2551 -- select.val() broken in IE after form.reset()
  1572. if ( one && !values.length && options.length ) {
  1573. return jQuery( options[ index ] ).val();
  1574. }
  1575. return values;
  1576. }
  1577. // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
  1578. if ( rradiocheck.test( elem.type ) && !jQuery.support.checkOn ) {
  1579. return elem.getAttribute("value") === null ? "on" : elem.value;
  1580. }
  1581. // Everything else, we just grab the value
  1582. return (elem.value || "").replace(rreturn, "");
  1583. }
  1584. return undefined;
  1585. }
  1586. var isFunction = jQuery.isFunction(value);
  1587. return this.each(function(i) {
  1588. var self = jQuery(this), val = value;
  1589. if ( this.nodeType !== 1 ) {
  1590. return;
  1591. }
  1592. if ( isFunction ) {
  1593. val = value.call(this, i, self.val());
  1594. }
  1595. // Treat null/undefined as ""; convert numbers to string
  1596. if ( val == null ) {
  1597. val = "";
  1598. } else if ( typeof val === "number" ) {
  1599. val += "";
  1600. } else if ( jQuery.isArray(val) ) {
  1601. val = jQuery.map(val, function (value) {
  1602. return value == null ? "" : value + "";
  1603. });
  1604. }
  1605. if ( jQuery.isArray(val) && rradiocheck.test( this.type ) ) {
  1606. this.checked = jQuery.inArray( self.val(), val ) >= 0;
  1607. } else if ( jQuery.nodeName( this, "select" ) ) {
  1608. var values = jQuery.makeArray(val);
  1609. jQuery( "option", this ).each(function() {
  1610. this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
  1611. });
  1612. if ( !values.length ) {
  1613. this.selectedIndex = -1;
  1614. }
  1615. } else {
  1616. this.value = val;
  1617. }
  1618. });
  1619. }
  1620. });
  1621. jQuery.extend({
  1622. attrFn: {
  1623. val: true,
  1624. css: true,
  1625. html: true,
  1626. text: true,
  1627. data: true,
  1628. width: true,
  1629. height: true,
  1630. offset: true
  1631. },
  1632. attr: function( elem, name, value, pass ) {
  1633. // don't get/set attributes on text, comment and attribute nodes
  1634. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || elem.nodeType === 2 ) {
  1635. return undefined;
  1636. }
  1637. if ( pass && name in jQuery.attrFn ) {
  1638. return jQuery(elem)[name](value);
  1639. }
  1640. var notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ),
  1641. // Whether we are setting (or getting)
  1642. set = value !== undefined;
  1643. // Try to normalize/fix the name
  1644. name = notxml && jQuery.props[ name ] || name;
  1645. // Only do all the following if this is a node (faster for style)
  1646. if ( elem.nodeType === 1 ) {
  1647. // These attributes require special treatment
  1648. var special = rspecialurl.test( name );
  1649. // Safari mis-reports the default selected property of an option
  1650. // Accessing the parent's selectedIndex property fixes it
  1651. if ( name === "selected" && !jQuery.support.optSelected ) {
  1652. var parent = elem.parentNode;
  1653. if ( parent ) {
  1654. parent.selectedIndex;
  1655. // Make sure that it also works with optgroups, see #5701
  1656. if ( parent.parentNode ) {
  1657. parent.parentNode.selectedIndex;
  1658. }
  1659. }
  1660. }
  1661. // If applicable, access the attribute via the DOM 0 way
  1662. // 'in' checks fail in Blackberry 4.7 #6931
  1663. if ( (name in elem || elem[ name ] !== undefined) && notxml && !special ) {
  1664. if ( set ) {
  1665. // We can't allow the type property to be changed (since it causes problems in IE)
  1666. if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) {
  1667. jQuery.error( "type property can't be changed" );
  1668. }
  1669. if ( value === null ) {
  1670. if ( elem.nodeType === 1 ) {
  1671. elem.removeAttribute( name );
  1672. }
  1673. } else {
  1674. elem[ name ] = value;
  1675. }
  1676. }
  1677. // browsers index elements by id/name on forms, give priority to attributes.
  1678. if ( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) {
  1679. return elem.getAttributeNode( name ).nodeValue;
  1680. }
  1681. // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
  1682. // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
  1683. if ( name === "tabIndex" ) {
  1684. var attributeNode = elem.getAttributeNode( "tabIndex" );
  1685. return attributeNode && attributeNode.specified ?
  1686. attributeNode.value :
  1687. rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
  1688. 0 :
  1689. undefined;
  1690. }
  1691. return elem[ name ];
  1692. }
  1693. if ( !jQuery.support.style && notxml && name === "style" ) {
  1694. if ( set ) {
  1695. elem.style.cssText = "" + value;
  1696. }
  1697. return elem.style.cssText;
  1698. }
  1699. if ( set ) {
  1700. // convert the value to a string (all browsers do this but IE) see #1070
  1701. elem.setAttribute( name, "" + value );
  1702. }
  1703. // Ensure that missing attributes return undefined
  1704. // Blackberry 4.7 returns "" from getAttribute #6938
  1705. if ( !elem.attributes[ name ] && (elem.hasAttribute && !elem.hasAttribute( name )) ) {
  1706. return undefined;
  1707. }
  1708. var attr = !jQuery.support.hrefNormalized && notxml && special ?
  1709. // Some attributes require a special call on IE
  1710. elem.getAttribute( name, 2 ) :
  1711. elem.getAttribute( name );
  1712. // Non-existent attributes return null, we normalize to undefined
  1713. return attr === null ? undefined : attr;
  1714. }
  1715. // Handle everything which isn't a DOM element node
  1716. if ( set ) {
  1717. elem[ name ] = value;
  1718. }
  1719. return elem[ name ];
  1720. }
  1721. });
  1722. var rnamespaces = /\.(.*)$/,
  1723. rformElems = /^(?:textarea|input|select)$/i,
  1724. rperiod = /\./g,
  1725. rspace = / /g,
  1726. rescape = /[^\w\s.|`]/g,
  1727. fcleanup = function( nm ) {
  1728. return nm.replace(rescape, "\\$&");
  1729. };
  1730. /*
  1731. * A number of helper functions used for managing events.
  1732. * Many of the ideas behind this code originated from
  1733. * Dean Edwards' addEvent library.
  1734. */
  1735. jQuery.event = {
  1736. // Bind an event to an element
  1737. // Original by Dean Edwards
  1738. add: function( elem, types, handler, data ) {
  1739. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  1740. return;
  1741. }
  1742. // TODO :: Use a try/catch until it's safe to pull this out (likely 1.6)
  1743. // Minor release fix for bug #8018
  1744. try {
  1745. // For whatever reason, IE has trouble passing the window object
  1746. // around, causing it to be cloned in the process
  1747. if ( jQuery.isWindow( elem ) && ( elem !== window && !elem.frameElement ) ) {
  1748. elem = window;
  1749. }
  1750. }
  1751. catch ( e ) {}
  1752. if ( handler === false ) {
  1753. handler = returnFalse;
  1754. } else if ( !handler ) {
  1755. // Fixes bug #7229. Fix recommended by jdalton
  1756. return;
  1757. }
  1758. var handleObjIn, handleObj;
  1759. if ( handler.handler ) {
  1760. handleObjIn = handler;
  1761. handler = handleObjIn.handler;
  1762. }
  1763. // Make sure that the function being executed has a unique ID
  1764. if ( !handler.guid ) {
  1765. handler.guid = jQuery.guid++;
  1766. }
  1767. // Init the element's event structure
  1768. var elemData = jQuery._data( elem );
  1769. // If no elemData is found then we must be trying to bind to one of the
  1770. // banned noData elements
  1771. if ( !elemData ) {
  1772. return;
  1773. }
  1774. var events = elemData.events,
  1775. eventHandle = elemData.handle;
  1776. if ( !events ) {
  1777. elemData.events = events = {};
  1778. }
  1779. if ( !eventHandle ) {
  1780. elemData.handle = eventHandle = function() {
  1781. // Handle the second event of a trigger and when
  1782. // an event is called after a page has unloaded
  1783. return typeof jQuery !== "undefined" && !jQuery.event.triggered ?
  1784. jQuery.event.handle.apply( eventHandle.elem, arguments ) :
  1785. undefined;
  1786. };
  1787. }
  1788. // Add elem as a property of the handle function
  1789. // This is to prevent a memory leak with non-native events in IE.
  1790. eventHandle.elem = elem;
  1791. // Handle multiple events separated by a space
  1792. // jQuery(...).bind("mouseover mouseout", fn);
  1793. types = types.split(" ");
  1794. var type, i = 0, namespaces;
  1795. while ( (type = types[ i++ ]) ) {
  1796. handleObj = handleObjIn ?
  1797. jQuery.extend({}, handleObjIn) :
  1798. { handler: handler, data: data };
  1799. // Namespaced event handlers
  1800. if ( type.indexOf(".") > -1 ) {
  1801. namespaces = type.split(".");
  1802. type = namespaces.shift();
  1803. handleObj.namespace = namespaces.slice(0).sort().join(".");
  1804. } else {
  1805. namespaces = [];
  1806. handleObj.namespace = "";
  1807. }
  1808. handleObj.type = type;
  1809. if ( !handleObj.guid ) {
  1810. handleObj.guid = handler.guid;
  1811. }
  1812. // Get the current list of functions bound to this event
  1813. var handlers = events[ type ],
  1814. special = jQuery.event.special[ type ] || {};
  1815. // Init the event handler queue
  1816. if ( !handlers ) {
  1817. handlers = events[ type ] = [];
  1818. // Check for a special event handler
  1819. // Only use addEventListener/attachEvent if the special
  1820. // events handler returns false
  1821. if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
  1822. // Bind the global event handler to the element
  1823. if ( elem.addEventListener ) {
  1824. elem.addEventListener( type, eventHandle, false );
  1825. } else if ( elem.attachEvent ) {
  1826. elem.attachEvent( "on" + type, eventHandle );
  1827. }
  1828. }
  1829. }
  1830. if ( special.add ) {
  1831. special.add.call( elem, handleObj );
  1832. if ( !handleObj.handler.guid ) {
  1833. handleObj.handler.guid = handler.guid;
  1834. }
  1835. }
  1836. // Add the function to the element's handler list
  1837. handlers.push( handleObj );
  1838. // Keep track of which events have been used, for global triggering
  1839. jQuery.event.global[ type ] = true;
  1840. }
  1841. // Nullify elem to prevent memory leaks in IE
  1842. elem = null;
  1843. },
  1844. global: {},
  1845. // Detach an event or set of events from an element
  1846. remove: function( elem, types, handler, pos ) {
  1847. // don't do events on text and comment nodes
  1848. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  1849. return;
  1850. }
  1851. if ( handler === false ) {
  1852. handler = returnFalse;
  1853. }
  1854. var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType,
  1855. elemData = jQuery.hasData( elem ) && jQuery._data( elem ),
  1856. events = elemData && elemData.events;
  1857. if ( !elemData || !events ) {
  1858. return;
  1859. }
  1860. // types is actually an event object here
  1861. if ( types && types.type ) {
  1862. handler = types.handler;
  1863. types = types.type;
  1864. }
  1865. // Unbind all events for the element
  1866. if ( !types || typeof types === "string" && types.charAt(0) === "." ) {
  1867. types = types || "";
  1868. for ( type in events ) {
  1869. jQuery.event.remove( elem, type + types );
  1870. }
  1871. return;
  1872. }
  1873. // Handle multiple events separated by a space
  1874. // jQuery(...).unbind("mouseover mouseout", fn);
  1875. types = types.split(" ");
  1876. while ( (type = types[ i++ ]) ) {
  1877. origType = type;
  1878. handleObj = null;
  1879. all = type.indexOf(".") < 0;
  1880. namespaces = [];
  1881. if ( !all ) {
  1882. // Namespaced event handlers
  1883. namespaces = type.split(".");
  1884. type = namespaces.shift();
  1885. namespace = new RegExp("(^|\\.)" +
  1886. jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)");
  1887. }
  1888. eventType = events[ type ];
  1889. if ( !eventType ) {
  1890. continue;
  1891. }
  1892. if ( !handler ) {
  1893. for ( j = 0; j < eventType.length; j++ ) {
  1894. handleObj = eventType[ j ];
  1895. if ( all || namespace.test( handleObj.namespace ) ) {
  1896. jQuery.event.remove( elem, origType, handleObj.handler, j );
  1897. eventType.splice( j--, 1 );
  1898. }
  1899. }
  1900. continue;
  1901. }
  1902. special = jQuery.event.special[ type ] || {};
  1903. for ( j = pos || 0; j < eventType.length; j++ ) {
  1904. handleObj = eventType[ j ];
  1905. if ( handler.guid === handleObj.guid ) {
  1906. // remove the given handler for the given type
  1907. if ( all || namespace.test( handleObj.namespace ) ) {
  1908. if ( pos == null ) {
  1909. eventType.splice( j--, 1 );
  1910. }
  1911. if ( special.remove ) {
  1912. special.remove.call( elem, handleObj );
  1913. }
  1914. }
  1915. if ( pos != null ) {
  1916. break;
  1917. }
  1918. }
  1919. }
  1920. // remove generic event handler if no more handlers exist
  1921. if ( eventType.length === 0 || pos != null && eventType.length === 1 ) {
  1922. if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
  1923. jQuery.removeEvent( elem, type, elemData.handle );
  1924. }
  1925. ret = null;
  1926. delete events[ type ];
  1927. }
  1928. }
  1929. // Remove the expando if it's no longer used
  1930. if ( jQuery.isEmptyObject( events ) ) {
  1931. var handle = elemData.handle;
  1932. if ( handle ) {
  1933. handle.elem = null;
  1934. }
  1935. delete elemData.events;
  1936. delete elemData.handle;
  1937. if ( jQuery.isEmptyObject( elemData ) ) {
  1938. jQuery.removeData( elem, undefined, true );
  1939. }
  1940. }
  1941. },
  1942. // bubbling is internal
  1943. trigger: function( event, data, elem /*, bubbling */ ) {
  1944. // Event object or event type
  1945. var type = event.type || event,
  1946. bubbling = arguments[3];
  1947. if ( !bubbling ) {
  1948. event = typeof event === "object" ?
  1949. // jQuery.Event object
  1950. event[ jQuery.expando ] ? event :
  1951. // Object literal
  1952. jQuery.extend( jQuery.Event(type), event ) :
  1953. // Just the event type (string)
  1954. jQuery.Event(type);
  1955. if ( type.indexOf("!") >= 0 ) {
  1956. event.type = type = type.slice(0, -1);
  1957. event.exclusive = true;
  1958. }
  1959. // Handle a global trigger
  1960. if ( !elem ) {
  1961. // Don't bubble custom events when global (to avoid too much overhead)
  1962. event.stopPropagation();
  1963. // Only trigger if we've ever bound an event for it
  1964. if ( jQuery.event.global[ type ] ) {
  1965. // XXX This code smells terrible. event.js should not be directly
  1966. // inspecting the data cache
  1967. jQuery.each( jQuery.cache, function() {
  1968. // internalKey variable is just used to make it easier to find
  1969. // and potentially change this stuff later; currently it just
  1970. // points to jQuery.expando
  1971. var internalKey = jQuery.expando,
  1972. internalCache = this[ internalKey ];
  1973. if ( internalCache && internalCache.events && internalCache.events[ type ] ) {
  1974. jQuery.event.trigger( event, data, internalCache.handle.elem );
  1975. }
  1976. });
  1977. }
  1978. }
  1979. // Handle triggering a single element
  1980. // don't do events on text and comment nodes
  1981. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
  1982. return undefined;
  1983. }
  1984. // Clean up in case it is reused
  1985. event.result = undefined;
  1986. event.target = elem;
  1987. // Clone the incoming data, if any
  1988. data = jQuery.makeArray( data );
  1989. data.unshift( event );
  1990. }
  1991. event.currentTarget = elem;
  1992. // Trigger the event, it is assumed that "handle" is a function
  1993. var handle = jQuery._data( elem, "handle" );
  1994. if ( handle ) {
  1995. handle.apply( elem, data );
  1996. }
  1997. var parent = elem.parentNode || elem.ownerDocument;
  1998. // Trigger an inline bound script
  1999. try {
  2000. if ( !(elem && elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()]) ) {
  2001. if ( elem[ "on" + type ] && elem[ "on" + type ].apply( elem, data ) === false ) {
  2002. event.result = false;
  2003. event.preventDefault();
  2004. }
  2005. }
  2006. // prevent IE from throwing an error for some elements with some event types, see #3533
  2007. } catch (inlineError) {}
  2008. if ( !event.isPropagationStopped() && parent ) {
  2009. jQuery.event.trigger( event, data, parent, true );
  2010. } else if ( !event.isDefaultPrevented() ) {
  2011. var old,
  2012. target = event.target,
  2013. targetType = type.replace( rnamespaces, "" ),
  2014. isClick = jQuery.nodeName( target, "a" ) && targetType === "click",
  2015. special = jQuery.event.special[ targetType ] || {};
  2016. if ( (!special._default || special._default.call( elem, event ) === false) &&
  2017. !isClick && !(target && target.nodeName && jQuery.noData[target.nodeName.toLowerCase()]) ) {
  2018. try {
  2019. if ( target[ targetType ] ) {
  2020. // Make sure that we don't accidentally re-trigger the onFOO events
  2021. old = target[ "on" + targetType ];
  2022. if ( old ) {
  2023. target[ "on" + targetType ] = null;
  2024. }
  2025. jQuery.event.triggered = true;
  2026. target[ targetType ]();
  2027. }
  2028. // prevent IE from throwing an error for some elements with some event types, see #3533
  2029. } catch (triggerError) {}
  2030. if ( old ) {
  2031. target[ "on" + targetType ] = old;
  2032. }
  2033. jQuery.event.triggered = false;
  2034. }
  2035. }
  2036. },
  2037. handle: function( event ) {
  2038. var all, handlers, namespaces, namespace_re, events,
  2039. namespace_sort = [],
  2040. args = jQuery.makeArray( arguments );
  2041. event = args[0] = jQuery.event.fix( event || window.event );
  2042. event.currentTarget = this;
  2043. // Namespaced event handlers
  2044. all = event.type.indexOf(".") < 0 && !event.exclusive;
  2045. if ( !all ) {
  2046. namespaces = event.type.split(".");
  2047. event.type = namespaces.shift();
  2048. namespace_sort = namespaces.slice(0).sort();
  2049. namespace_re = new RegExp("(^|\\.)" + namespace_sort.join("\\.(?:.*\\.)?") + "(\\.|$)");
  2050. }
  2051. event.namespace = event.namespace || namespace_sort.join(".");
  2052. events = jQuery._data(this, "events");
  2053. handlers = (events || {})[ event.type ];
  2054. if ( events && handlers ) {
  2055. // Clone the handlers to prevent manipulation
  2056. handlers = handlers.slice(0);
  2057. for ( var j = 0, l = handlers.length; j < l; j++ ) {
  2058. var handleObj = handlers[ j ];
  2059. // Filter the functions by class
  2060. if ( all || namespace_re.test( handleObj.namespace ) ) {
  2061. // Pass in a reference to the handler function itself
  2062. // So that we can later remove it
  2063. event.handler = handleObj.handler;
  2064. event.data = handleObj.data;
  2065. event.handleObj = handleObj;
  2066. var ret = handleObj.handler.apply( this, args );
  2067. if ( ret !== undefined ) {
  2068. event.result = ret;
  2069. if ( ret === false ) {
  2070. event.preventDefault();
  2071. event.stopPropagation();
  2072. }
  2073. }
  2074. if ( event.isImmediatePropagationStopped() ) {
  2075. break;
  2076. }
  2077. }
  2078. }
  2079. }
  2080. return event.result;
  2081. },
  2082. props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
  2083. fix: function( event ) {
  2084. if ( event[ jQuery.expando ] ) {
  2085. return event;
  2086. }
  2087. // store a copy of the original event object
  2088. // and "clone" to set read-only properties
  2089. var originalEvent = event;
  2090. event = jQuery.Event( originalEvent );
  2091. for ( var i = this.props.length, prop; i; ) {
  2092. prop = this.props[ --i ];
  2093. event[ prop ] = originalEvent[ prop ];
  2094. }
  2095. // Fix target property, if necessary
  2096. if ( !event.target ) {
  2097. // Fixes #1925 where srcElement might not be defined either
  2098. event.target = event.srcElement || document;
  2099. }
  2100. // check if target is a textnode (safari)
  2101. if ( event.target.nodeType === 3 ) {
  2102. event.target = event.target.parentNode;
  2103. }
  2104. // Add relatedTarget, if necessary
  2105. if ( !event.relatedTarget && event.fromElement ) {
  2106. event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement;
  2107. }
  2108. // Calculate pageX/Y if missing and clientX/Y available
  2109. if ( event.pageX == null && event.clientX != null ) {
  2110. var doc = document.documentElement,
  2111. body = document.body;
  2112. event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
  2113. event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
  2114. }
  2115. // Add which for key events
  2116. if ( event.which == null && (event.charCode != null || event.keyCode != null) ) {
  2117. event.which = event.charCode != null ? event.charCode : event.keyCode;
  2118. }
  2119. // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
  2120. if ( !event.metaKey && event.ctrlKey ) {
  2121. event.metaKey = event.ctrlKey;
  2122. }
  2123. // Add which for click: 1 === left; 2 === middle; 3 === right
  2124. // Note: button is not normalized, so don't use it
  2125. if ( !event.which && event.button !== undefined ) {
  2126. event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
  2127. }
  2128. return event;
  2129. },
  2130. // Deprecated, use jQuery.guid instead
  2131. guid: 1E8,
  2132. // Deprecated, use jQuery.proxy instead
  2133. proxy: jQuery.proxy,
  2134. special: {
  2135. ready: {
  2136. // Make sure the ready event is setup
  2137. setup: jQuery.bindReady,
  2138. teardown: jQuery.noop
  2139. },
  2140. live: {
  2141. add: function( handleObj ) {
  2142. jQuery.event.add( this,
  2143. liveConvert( handleObj.origType, handleObj.selector ),
  2144. jQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) );
  2145. },
  2146. remove: function( handleObj ) {
  2147. jQuery.event.remove( this, liveConvert( handleObj.origType, handleObj.selector ), handleObj );
  2148. }
  2149. },
  2150. beforeunload: {
  2151. setup: function( data, namespaces, eventHandle ) {
  2152. // We only want to do this special case on windows
  2153. if ( jQuery.isWindow( this ) ) {
  2154. this.onbeforeunload = eventHandle;
  2155. }
  2156. },
  2157. teardown: function( namespaces, eventHandle ) {
  2158. if ( this.onbeforeunload === eventHandle ) {
  2159. this.onbeforeunload = null;
  2160. }
  2161. }
  2162. }
  2163. }
  2164. };
  2165. jQuery.removeEvent = document.removeEventListener ?
  2166. function( elem, type, handle ) {
  2167. if ( elem.removeEventListener ) {
  2168. elem.removeEventListener( type, handle, false );
  2169. }
  2170. } :
  2171. function( elem, type, handle ) {
  2172. if ( elem.detachEvent ) {
  2173. elem.detachEvent( "on" + type, handle );
  2174. }
  2175. };
  2176. jQuery.Event = function( src ) {
  2177. // Allow instantiation without the 'new' keyword
  2178. if ( !this.preventDefault ) {
  2179. return new jQuery.Event( src );
  2180. }
  2181. // Event object
  2182. if ( src && src.type ) {
  2183. this.originalEvent = src;
  2184. this.type = src.type;
  2185. // Events bubbling up the document may have been marked as prevented
  2186. // by a handler lower down the tree; reflect the correct value.
  2187. this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false ||
  2188. src.getPreventDefault && src.getPreventDefault()) ? returnTrue : returnFalse;
  2189. // Event type
  2190. } else {
  2191. this.type = src;
  2192. }
  2193. // timeStamp is buggy for some events on Firefox(#3843)
  2194. // So we won't rely on the native value
  2195. this.timeStamp = jQuery.now();
  2196. // Mark it as fixed
  2197. this[ jQuery.expando ] = true;
  2198. };
  2199. function returnFalse() {
  2200. return false;
  2201. }
  2202. function returnTrue() {
  2203. return true;
  2204. }
  2205. // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
  2206. // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  2207. jQuery.Event.prototype = {
  2208. preventDefault: function() {
  2209. this.isDefaultPrevented = returnTrue;
  2210. var e = this.originalEvent;
  2211. if ( !e ) {
  2212. return;
  2213. }
  2214. // if preventDefault exists run it on the original event
  2215. if ( e.preventDefault ) {
  2216. e.preventDefault();
  2217. // otherwise set the returnValue property of the original event to false (IE)
  2218. } else {
  2219. e.returnValue = false;
  2220. }
  2221. },
  2222. stopPropagation: function() {
  2223. this.isPropagationStopped = returnTrue;
  2224. var e = this.originalEvent;
  2225. if ( !e ) {
  2226. return;
  2227. }
  2228. // if stopPropagation exists run it on the original event
  2229. if ( e.stopPropagation ) {
  2230. e.stopPropagation();
  2231. }
  2232. // otherwise set the cancelBubble property of the original event to true (IE)
  2233. e.cancelBubble = true;
  2234. },
  2235. stopImmediatePropagation: function() {
  2236. this.isImmediatePropagationStopped = returnTrue;
  2237. this.stopPropagation();
  2238. },
  2239. isDefaultPrevented: returnFalse,
  2240. isPropagationStopped: returnFalse,
  2241. isImmediatePropagationStopped: returnFalse
  2242. };
  2243. // Checks if an event happened on an element within another element
  2244. // Used in jQuery.event.special.mouseenter and mouseleave handlers
  2245. var withinElement = function( event ) {
  2246. // Check if mouse(over|out) are still within the same parent element
  2247. var parent = event.relatedTarget;
  2248. // Firefox sometimes assigns relatedTarget a XUL element
  2249. // which we cannot access the parentNode property of
  2250. try {
  2251. // Chrome does something similar, the parentNode property
  2252. // can be accessed but is null.
  2253. if ( parent !== document && !parent.parentNode ) {
  2254. return;
  2255. }
  2256. // Traverse up the tree
  2257. while ( parent && parent !== this ) {
  2258. parent = parent.parentNode;
  2259. }
  2260. if ( parent !== this ) {
  2261. // set the correct event type
  2262. event.type = event.data;
  2263. // handle event if we actually just moused on to a non sub-element
  2264. jQuery.event.handle.apply( this, arguments );
  2265. }
  2266. // assuming we've left the element since we most likely mousedover a xul element
  2267. } catch(e) { }
  2268. },
  2269. // In case of event delegation, we only need to rename the event.type,
  2270. // liveHandler will take care of the rest.
  2271. delegate = function( event ) {
  2272. event.type = event.data;
  2273. jQuery.event.handle.apply( this, arguments );
  2274. };
  2275. // Create mouseenter and mouseleave events
  2276. jQuery.each({
  2277. mouseenter: "mouseover",
  2278. mouseleave: "mouseout"
  2279. }, function( orig, fix ) {
  2280. jQuery.event.special[ orig ] = {
  2281. setup: function( data ) {
  2282. jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig );
  2283. },
  2284. teardown: function( data ) {
  2285. jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement );
  2286. }
  2287. };
  2288. });
  2289. // submit delegation
  2290. if ( !jQuery.support.submitBubbles ) {
  2291. jQuery.event.special.submit = {
  2292. setup: function( data, namespaces ) {
  2293. if ( this.nodeName && this.nodeName.toLowerCase() !== "form" ) {
  2294. jQuery.event.add(this, "click.specialSubmit", function( e ) {
  2295. var elem = e.target,
  2296. type = elem.type;
  2297. if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
  2298. trigger( "submit", this, arguments );
  2299. }
  2300. });
  2301. jQuery.event.add(this, "keypress.specialSubmit", function( e ) {
  2302. var elem = e.target,
  2303. type = elem.type;
  2304. if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
  2305. trigger( "submit", this, arguments );
  2306. }
  2307. });
  2308. } else {
  2309. return false;
  2310. }
  2311. },
  2312. teardown: function( namespaces ) {
  2313. jQuery.event.remove( this, ".specialSubmit" );
  2314. }
  2315. };
  2316. }
  2317. // change delegation, happens here so we have bind.
  2318. if ( !jQuery.support.changeBubbles ) {
  2319. var changeFilters,
  2320. getVal = function( elem ) {
  2321. var type = elem.type, val = elem.value;
  2322. if ( type === "radio" || type === "checkbox" ) {
  2323. val = elem.checked;
  2324. } else if ( type === "select-multiple" ) {
  2325. val = elem.selectedIndex > -1 ?
  2326. jQuery.map( elem.options, function( elem ) {
  2327. return elem.selected;
  2328. }).join("-") :
  2329. "";
  2330. } else if ( elem.nodeName.toLowerCase() === "select" ) {
  2331. val = elem.selectedIndex;
  2332. }
  2333. return val;
  2334. },
  2335. testChange = function testChange( e ) {
  2336. var elem = e.target, data, val;
  2337. if ( !rformElems.test( elem.nodeName ) || elem.readOnly ) {
  2338. return;
  2339. }
  2340. data = jQuery._data( elem, "_change_data" );
  2341. val = getVal(elem);
  2342. // the current data will be also retrieved by beforeactivate
  2343. if ( e.type !== "focusout" || elem.type !== "radio" ) {
  2344. jQuery._data( elem, "_change_data", val );
  2345. }
  2346. if ( data === undefined || val === data ) {
  2347. return;
  2348. }
  2349. if ( data != null || val ) {
  2350. e.type = "change";
  2351. e.liveFired = undefined;
  2352. jQuery.event.trigger( e, arguments[1], elem );
  2353. }
  2354. };
  2355. jQuery.event.special.change = {
  2356. filters: {
  2357. focusout: testChange,
  2358. beforedeactivate: testChange,
  2359. click: function( e ) {
  2360. var elem = e.target, type = elem.type;
  2361. if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) {
  2362. testChange.call( this, e );
  2363. }
  2364. },
  2365. // Change has to be called before submit
  2366. // Keydown will be called before keypress, which is used in submit-event delegation
  2367. keydown: function( e ) {
  2368. var elem = e.target, type = elem.type;
  2369. if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") ||
  2370. (e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
  2371. type === "select-multiple" ) {
  2372. testChange.call( this, e );
  2373. }
  2374. },
  2375. // Beforeactivate happens also before the previous element is blurred
  2376. // with this event you can't trigger a change event, but you can store
  2377. // information
  2378. beforeactivate: function( e ) {
  2379. var elem = e.target;
  2380. jQuery._data( elem, "_change_data", getVal(elem) );
  2381. }
  2382. },
  2383. setup: function( data, namespaces ) {
  2384. if ( this.type === "file" ) {
  2385. return false;
  2386. }
  2387. for ( var type in changeFilters ) {
  2388. jQuery.event.add( this, type + ".specialChange", changeFilters[type] );
  2389. }
  2390. return rformElems.test( this.nodeName );
  2391. },
  2392. teardown: function( namespaces ) {
  2393. jQuery.event.remove( this, ".specialChange" );
  2394. return rformElems.test( this.nodeName );
  2395. }
  2396. };
  2397. changeFilters = jQuery.event.special.change.filters;
  2398. // Handle when the input is .focus()'d
  2399. changeFilters.focus = changeFilters.beforeactivate;
  2400. }
  2401. function trigger( type, elem, args ) {
  2402. // Piggyback on a donor event to simulate a different one.
  2403. // Fake originalEvent to avoid donor's stopPropagation, but if the
  2404. // simulated event prevents default then we do the same on the donor.
  2405. // Don't pass args or remember liveFired; they apply to the donor event.
  2406. var event = jQuery.extend( {}, args[ 0 ] );
  2407. event.type = type;
  2408. event.originalEvent = {};
  2409. event.liveFired = undefined;
  2410. jQuery.event.handle.call( elem, event );
  2411. if ( event.isDefaultPrevented() ) {
  2412. args[ 0 ].preventDefault();
  2413. }
  2414. }
  2415. // Create "bubbling" focus and blur events
  2416. if ( document.addEventListener ) {
  2417. jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
  2418. jQuery.event.special[ fix ] = {
  2419. setup: function() {
  2420. this.addEventListener( orig, handler, true );
  2421. },
  2422. teardown: function() {
  2423. this.removeEventListener( orig, handler, true );
  2424. }
  2425. };
  2426. function handler( e ) {
  2427. e = jQuery.event.fix( e );
  2428. e.type = fix;
  2429. return jQuery.event.handle.call( this, e );
  2430. }
  2431. });
  2432. }
  2433. jQuery.each(["bind", "one"], function( i, name ) {
  2434. jQuery.fn[ name ] = function( type, data, fn ) {
  2435. // Handle object literals
  2436. if ( typeof type === "object" ) {
  2437. for ( var key in type ) {
  2438. this[ name ](key, data, type[key], fn);
  2439. }
  2440. return this;
  2441. }
  2442. if ( jQuery.isFunction( data ) || data === false ) {
  2443. fn = data;
  2444. data = undefined;
  2445. }
  2446. var handler = name === "one" ? jQuery.proxy( fn, function( event ) {
  2447. jQuery( this ).unbind( event, handler );
  2448. return fn.apply( this, arguments );
  2449. }) : fn;
  2450. if ( type === "unload" && name !== "one" ) {
  2451. this.one( type, data, fn );
  2452. } else {
  2453. for ( var i = 0, l = this.length; i < l; i++ ) {
  2454. jQuery.event.add( this[i], type, handler, data );
  2455. }
  2456. }
  2457. return this;
  2458. };
  2459. });
  2460. jQuery.fn.extend({
  2461. unbind: function( type, fn ) {
  2462. // Handle object literals
  2463. if ( typeof type === "object" && !type.preventDefault ) {
  2464. for ( var key in type ) {
  2465. this.unbind(key, type[key]);
  2466. }
  2467. } else {
  2468. for ( var i = 0, l = this.length; i < l; i++ ) {
  2469. jQuery.event.remove( this[i], type, fn );
  2470. }
  2471. }
  2472. return this;
  2473. },
  2474. delegate: function( selector, types, data, fn ) {
  2475. return this.live( types, data, fn, selector );
  2476. },
  2477. undelegate: function( selector, types, fn ) {
  2478. if ( arguments.length === 0 ) {
  2479. return this.unbind( "live" );
  2480. } else {
  2481. return this.die( types, null, fn, selector );
  2482. }
  2483. },
  2484. trigger: function( type, data ) {
  2485. return this.each(function() {
  2486. jQuery.event.trigger( type, data, this );
  2487. });
  2488. },
  2489. triggerHandler: function( type, data ) {
  2490. if ( this[0] ) {
  2491. var event = jQuery.Event( type );
  2492. event.preventDefault();
  2493. event.stopPropagation();
  2494. jQuery.event.trigger( event, data, this[0] );
  2495. return event.result;
  2496. }
  2497. },
  2498. toggle: function( fn ) {
  2499. // Save reference to arguments for access in closure
  2500. var args = arguments,
  2501. i = 1;
  2502. // link all the functions, so any of them can unbind this click handler
  2503. while ( i < args.length ) {
  2504. jQuery.proxy( fn, args[ i++ ] );
  2505. }
  2506. return this.click( jQuery.proxy( fn, function( event ) {
  2507. // Figure out which function to execute
  2508. var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
  2509. jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );
  2510. // Make sure that clicks stop
  2511. event.preventDefault();
  2512. // and execute the function
  2513. return args[ lastToggle ].apply( this, arguments ) || false;
  2514. }));
  2515. },
  2516. hover: function( fnOver, fnOut ) {
  2517. return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
  2518. }
  2519. });
  2520. var liveMap = {
  2521. focus: "focusin",
  2522. blur: "focusout",
  2523. mouseenter: "mouseover",
  2524. mouseleave: "mouseout"
  2525. };
  2526. jQuery.each(["live", "die"], function( i, name ) {
  2527. jQuery.fn[ name ] = function( types, data, fn, origSelector /* Internal Use Only */ ) {
  2528. var type, i = 0, match, namespaces, preType,
  2529. selector = origSelector || this.selector,
  2530. context = origSelector ? this : jQuery( this.context );
  2531. if ( typeof types === "object" && !types.preventDefault ) {
  2532. for ( var key in types ) {
  2533. context[ name ]( key, data, types[key], selector );
  2534. }
  2535. return this;
  2536. }
  2537. if ( jQuery.isFunction( data ) ) {
  2538. fn = data;
  2539. data = undefined;
  2540. }
  2541. types = (types || "").split(" ");
  2542. while ( (type = types[ i++ ]) != null ) {
  2543. match = rnamespaces.exec( type );
  2544. namespaces = "";
  2545. if ( match ) {
  2546. namespaces = match[0];
  2547. type = type.replace( rnamespaces, "" );
  2548. }
  2549. if ( type === "hover" ) {
  2550. types.push( "mouseenter" + namespaces, "mouseleave" + namespaces );
  2551. continue;
  2552. }
  2553. preType = type;
  2554. if ( type === "focus" || type === "blur" ) {
  2555. types.push( liveMap[ type ] + namespaces );
  2556. type = type + namespaces;
  2557. } else {
  2558. type = (liveMap[ type ] || type) + namespaces;
  2559. }
  2560. if ( name === "live" ) {
  2561. // bind live handler
  2562. for ( var j = 0, l = context.length; j < l; j++ ) {
  2563. jQuery.event.add( context[j], "live." + liveConvert( type, selector ),
  2564. { data: data, selector: selector, handler: fn, origType: type, origHandler: fn, preType: preType } );
  2565. }
  2566. } else {
  2567. // unbind live handler
  2568. context.unbind( "live." + liveConvert( type, selector ), fn );
  2569. }
  2570. }
  2571. return this;
  2572. };
  2573. });
  2574. function liveHandler( event ) {
  2575. var stop, maxLevel, related, match, handleObj, elem, j, i, l, data, close, namespace, ret,
  2576. elems = [],
  2577. selectors = [],
  2578. events = jQuery._data( this, "events" );
  2579. // Make sure we avoid non-left-click bubbling in Firefox (#3861) and disabled elements in IE (#6911)
  2580. if ( event.liveFired === this || !events || !events.live || event.target.disabled || event.button && event.type === "click" ) {
  2581. return;
  2582. }
  2583. if ( event.namespace ) {
  2584. namespace = new RegExp("(^|\\.)" + event.namespace.split(".").join("\\.(?:.*\\.)?") + "(\\.|$)");
  2585. }
  2586. event.liveFired = this;
  2587. var live = events.live.slice(0);
  2588. for ( j = 0; j < live.length; j++ ) {
  2589. handleObj = live[j];
  2590. if ( handleObj.origType.replace( rnamespaces, "" ) === event.type ) {
  2591. selectors.push( handleObj.selector );
  2592. } else {
  2593. live.splice( j--, 1 );
  2594. }
  2595. }
  2596. match = jQuery( event.target ).closest( selectors, event.currentTarget );
  2597. for ( i = 0, l = match.length; i < l; i++ ) {
  2598. close = match[i];
  2599. for ( j = 0; j < live.length; j++ ) {
  2600. handleObj = live[j];
  2601. if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) && !close.elem.disabled ) {
  2602. elem = close.elem;
  2603. related = null;
  2604. // Those two events require additional checking
  2605. if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) {
  2606. event.type = handleObj.preType;
  2607. related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0];
  2608. }
  2609. if ( !related || related !== elem ) {
  2610. elems.push({ elem: elem, handleObj: handleObj, level: close.level });
  2611. }
  2612. }
  2613. }
  2614. }
  2615. for ( i = 0, l = elems.length; i < l; i++ ) {
  2616. match = elems[i];
  2617. if ( maxLevel && match.level > maxLevel ) {
  2618. break;
  2619. }
  2620. event.currentTarget = match.elem;
  2621. event.data = match.handleObj.data;
  2622. event.handleObj = match.handleObj;
  2623. ret = match.handleObj.origHandler.apply( match.elem, arguments );
  2624. if ( ret === false || event.isPropagationStopped() ) {
  2625. maxLevel = match.level;
  2626. if ( ret === false ) {
  2627. stop = false;
  2628. }
  2629. if ( event.isImmediatePropagationStopped() ) {
  2630. break;
  2631. }
  2632. }
  2633. }
  2634. return stop;
  2635. }
  2636. function liveConvert( type, selector ) {
  2637. return (type && type !== "*" ? type + "." : "") + selector.replace(rperiod, "`").replace(rspace, "&");
  2638. }
  2639. jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
  2640. "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  2641. "change select submit keydown keypress keyup error").split(" "), function( i, name ) {
  2642. // Handle event binding
  2643. jQuery.fn[ name ] = function( data, fn ) {
  2644. if ( fn == null ) {
  2645. fn = data;
  2646. data = null;
  2647. }
  2648. return arguments.length > 0 ?
  2649. this.bind( name, data, fn ) :
  2650. this.trigger( name );
  2651. };
  2652. if ( jQuery.attrFn ) {
  2653. jQuery.attrFn[ name ] = true;
  2654. }
  2655. });
  2656. /*!
  2657. * Sizzle CSS Selector Engine
  2658. * Copyright 2011, The Dojo Foundation
  2659. * Released under the MIT, BSD, and GPL Licenses.
  2660. * More information: http://sizzlejs.com/
  2661. */
  2662. (function(){
  2663. var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
  2664. done = 0,
  2665. toString = Object.prototype.toString,
  2666. hasDuplicate = false,
  2667. baseHasDuplicate = true,
  2668. rBackslash = /\\/g,
  2669. rNonWord = /\W/;
  2670. // Here we check if the JavaScript engine is using some sort of
  2671. // optimization where it does not always call our comparision
  2672. // function. If that is the case, discard the hasDuplicate value.
  2673. // Thus far that includes Google Chrome.
  2674. [0, 0].sort(function() {
  2675. baseHasDuplicate = false;
  2676. return 0;
  2677. });
  2678. var Sizzle = function( selector, context, results, seed ) {
  2679. results = results || [];
  2680. context = context || document;
  2681. var origContext = context;
  2682. if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
  2683. return [];
  2684. }
  2685. if ( !selector || typeof selector !== "string" ) {
  2686. return results;
  2687. }
  2688. var m, set, checkSet, extra, ret, cur, pop, i,
  2689. prune = true,
  2690. contextXML = Sizzle.isXML( context ),
  2691. parts = [],
  2692. soFar = selector;
  2693. // Reset the position of the chunker regexp (start from head)
  2694. do {
  2695. chunker.exec( "" );
  2696. m = chunker.exec( soFar );
  2697. if ( m ) {
  2698. soFar = m[3];
  2699. parts.push( m[1] );
  2700. if ( m[2] ) {
  2701. extra = m[3];
  2702. break;
  2703. }
  2704. }
  2705. } while ( m );
  2706. if ( parts.length > 1 && origPOS.exec( selector ) ) {
  2707. if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
  2708. set = posProcess( parts[0] + parts[1], context );
  2709. } else {
  2710. set = Expr.relative[ parts[0] ] ?
  2711. [ context ] :
  2712. Sizzle( parts.shift(), context );
  2713. while ( parts.length ) {
  2714. selector = parts.shift();
  2715. if ( Expr.relative[ selector ] ) {
  2716. selector += parts.shift();
  2717. }
  2718. set = posProcess( selector, set );
  2719. }
  2720. }
  2721. } else {
  2722. // Take a shortcut and set the context if the root selector is an ID
  2723. // (but not if it'll be faster if the inner selector is an ID)
  2724. if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
  2725. Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
  2726. ret = Sizzle.find( parts.shift(), context, contextXML );
  2727. context = ret.expr ?
  2728. Sizzle.filter( ret.expr, ret.set )[0] :
  2729. ret.set[0];
  2730. }
  2731. if ( context ) {
  2732. ret = seed ?
  2733. { expr: parts.pop(), set: makeArray(seed) } :
  2734. Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
  2735. set = ret.expr ?
  2736. Sizzle.filter( ret.expr, ret.set ) :
  2737. ret.set;
  2738. if ( parts.length > 0 ) {
  2739. checkSet = makeArray( set );
  2740. } else {
  2741. prune = false;
  2742. }
  2743. while ( parts.length ) {
  2744. cur = parts.pop();
  2745. pop = cur;
  2746. if ( !Expr.relative[ cur ] ) {
  2747. cur = "";
  2748. } else {
  2749. pop = parts.pop();
  2750. }
  2751. if ( pop == null ) {
  2752. pop = context;
  2753. }
  2754. Expr.relative[ cur ]( checkSet, pop, contextXML );
  2755. }
  2756. } else {
  2757. checkSet = parts = [];
  2758. }
  2759. }
  2760. if ( !checkSet ) {
  2761. checkSet = set;
  2762. }
  2763. if ( !checkSet ) {
  2764. Sizzle.error( cur || selector );
  2765. }
  2766. if ( toString.call(checkSet) === "[object Array]" ) {
  2767. if ( !prune ) {
  2768. results.push.apply( results, checkSet );
  2769. } else if ( context && context.nodeType === 1 ) {
  2770. for ( i = 0; checkSet[i] != null; i++ ) {
  2771. if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) {
  2772. results.push( set[i] );
  2773. }
  2774. }
  2775. } else {
  2776. for ( i = 0; checkSet[i] != null; i++ ) {
  2777. if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
  2778. results.push( set[i] );
  2779. }
  2780. }
  2781. }
  2782. } else {
  2783. makeArray( checkSet, results );
  2784. }
  2785. if ( extra ) {
  2786. Sizzle( extra, origContext, results, seed );
  2787. Sizzle.uniqueSort( results );
  2788. }
  2789. return results;
  2790. };
  2791. Sizzle.uniqueSort = function( results ) {
  2792. if ( sortOrder ) {
  2793. hasDuplicate = baseHasDuplicate;
  2794. results.sort( sortOrder );
  2795. if ( hasDuplicate ) {
  2796. for ( var i = 1; i < results.length; i++ ) {
  2797. if ( results[i] === results[ i - 1 ] ) {
  2798. results.splice( i--, 1 );
  2799. }
  2800. }
  2801. }
  2802. }
  2803. return results;
  2804. };
  2805. Sizzle.matches = function( expr, set ) {
  2806. return Sizzle( expr, null, null, set );
  2807. };
  2808. Sizzle.matchesSelector = function( node, expr ) {
  2809. return Sizzle( expr, null, null, [node] ).length > 0;
  2810. };
  2811. Sizzle.find = function( expr, context, isXML ) {
  2812. var set;
  2813. if ( !expr ) {
  2814. return [];
  2815. }
  2816. for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
  2817. var match,
  2818. type = Expr.order[i];
  2819. if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
  2820. var left = match[1];
  2821. match.splice( 1, 1 );
  2822. if ( left.substr( left.length - 1 ) !== "\\" ) {
  2823. match[1] = (match[1] || "").replace( rBackslash, "" );
  2824. set = Expr.find[ type ]( match, context, isXML );
  2825. if ( set != null ) {
  2826. expr = expr.replace( Expr.match[ type ], "" );
  2827. break;
  2828. }
  2829. }
  2830. }
  2831. }
  2832. if ( !set ) {
  2833. set = typeof context.getElementsByTagName !== "undefined" ?
  2834. context.getElementsByTagName( "*" ) :
  2835. [];
  2836. }
  2837. return { set: set, expr: expr };
  2838. };
  2839. Sizzle.filter = function( expr, set, inplace, not ) {
  2840. var match, anyFound,
  2841. old = expr,
  2842. result = [],
  2843. curLoop = set,
  2844. isXMLFilter = set && set[0] && Sizzle.isXML( set[0] );
  2845. while ( expr && set.length ) {
  2846. for ( var type in Expr.filter ) {
  2847. if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
  2848. var found, item,
  2849. filter = Expr.filter[ type ],
  2850. left = match[1];
  2851. anyFound = false;
  2852. match.splice(1,1);
  2853. if ( left.substr( left.length - 1 ) === "\\" ) {
  2854. continue;
  2855. }
  2856. if ( curLoop === result ) {
  2857. result = [];
  2858. }
  2859. if ( Expr.preFilter[ type ] ) {
  2860. match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
  2861. if ( !match ) {
  2862. anyFound = found = true;
  2863. } else if ( match === true ) {
  2864. continue;
  2865. }
  2866. }
  2867. if ( match ) {
  2868. for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
  2869. if ( item ) {
  2870. found = filter( item, match, i, curLoop );
  2871. var pass = not ^ !!found;
  2872. if ( inplace && found != null ) {
  2873. if ( pass ) {
  2874. anyFound = true;
  2875. } else {
  2876. curLoop[i] = false;
  2877. }
  2878. } else if ( pass ) {
  2879. result.push( item );
  2880. anyFound = true;
  2881. }
  2882. }
  2883. }
  2884. }
  2885. if ( found !== undefined ) {
  2886. if ( !inplace ) {
  2887. curLoop = result;
  2888. }
  2889. expr = expr.replace( Expr.match[ type ], "" );
  2890. if ( !anyFound ) {
  2891. return [];
  2892. }
  2893. break;
  2894. }
  2895. }
  2896. }
  2897. // Improper expression
  2898. if ( expr === old ) {
  2899. if ( anyFound == null ) {
  2900. Sizzle.error( expr );
  2901. } else {
  2902. break;
  2903. }
  2904. }
  2905. old = expr;
  2906. }
  2907. return curLoop;
  2908. };
  2909. Sizzle.error = function( msg ) {
  2910. throw "Syntax error, unrecognized expression: " + msg;
  2911. };
  2912. var Expr = Sizzle.selectors = {
  2913. order: [ "ID", "NAME", "TAG" ],
  2914. match: {
  2915. ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
  2916. CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
  2917. NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,
  2918. ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,
  2919. TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,
  2920. CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,
  2921. POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,
  2922. PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
  2923. },
  2924. leftMatch: {},
  2925. attrMap: {
  2926. "class": "className",
  2927. "for": "htmlFor"
  2928. },
  2929. attrHandle: {
  2930. href: function( elem ) {
  2931. return elem.getAttribute( "href" );
  2932. },
  2933. type: function( elem ) {
  2934. return elem.getAttribute( "type" );
  2935. }
  2936. },
  2937. relative: {
  2938. "+": function(checkSet, part){
  2939. var isPartStr = typeof part === "string",
  2940. isTag = isPartStr && !rNonWord.test( part ),
  2941. isPartStrNotTag = isPartStr && !isTag;
  2942. if ( isTag ) {
  2943. part = part.toLowerCase();
  2944. }
  2945. for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
  2946. if ( (elem = checkSet[i]) ) {
  2947. while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
  2948. checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
  2949. elem || false :
  2950. elem === part;
  2951. }
  2952. }
  2953. if ( isPartStrNotTag ) {
  2954. Sizzle.filter( part, checkSet, true );
  2955. }
  2956. },
  2957. ">": function( checkSet, part ) {
  2958. var elem,
  2959. isPartStr = typeof part === "string",
  2960. i = 0,
  2961. l = checkSet.length;
  2962. if ( isPartStr && !rNonWord.test( part ) ) {
  2963. part = part.toLowerCase();
  2964. for ( ; i < l; i++ ) {
  2965. elem = checkSet[i];
  2966. if ( elem ) {
  2967. var parent = elem.parentNode;
  2968. checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
  2969. }
  2970. }
  2971. } else {
  2972. for ( ; i < l; i++ ) {
  2973. elem = checkSet[i];
  2974. if ( elem ) {
  2975. checkSet[i] = isPartStr ?
  2976. elem.parentNode :
  2977. elem.parentNode === part;
  2978. }
  2979. }
  2980. if ( isPartStr ) {
  2981. Sizzle.filter( part, checkSet, true );
  2982. }
  2983. }
  2984. },
  2985. "": function(checkSet, part, isXML){
  2986. var nodeCheck,
  2987. doneName = done++,
  2988. checkFn = dirCheck;
  2989. if ( typeof part === "string" && !rNonWord.test( part ) ) {
  2990. part = part.toLowerCase();
  2991. nodeCheck = part;
  2992. checkFn = dirNodeCheck;
  2993. }
  2994. checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML );
  2995. },
  2996. "~": function( checkSet, part, isXML ) {
  2997. var nodeCheck,
  2998. doneName = done++,
  2999. checkFn = dirCheck;
  3000. if ( typeof part === "string" && !rNonWord.test( part ) ) {
  3001. part = part.toLowerCase();
  3002. nodeCheck = part;
  3003. checkFn = dirNodeCheck;
  3004. }
  3005. checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML );
  3006. }
  3007. },
  3008. find: {
  3009. ID: function( match, context, isXML ) {
  3010. if ( typeof context.getElementById !== "undefined" && !isXML ) {
  3011. var m = context.getElementById(match[1]);
  3012. // Check parentNode to catch when Blackberry 4.6 returns
  3013. // nodes that are no longer in the document #6963
  3014. return m && m.parentNode ? [m] : [];
  3015. }
  3016. },
  3017. NAME: function( match, context ) {
  3018. if ( typeof context.getElementsByName !== "undefined" ) {
  3019. var ret = [],
  3020. results = context.getElementsByName( match[1] );
  3021. for ( var i = 0, l = results.length; i < l; i++ ) {
  3022. if ( results[i].getAttribute("name") === match[1] ) {
  3023. ret.push( results[i] );
  3024. }
  3025. }
  3026. return ret.length === 0 ? null : ret;
  3027. }
  3028. },
  3029. TAG: function( match, context ) {
  3030. if ( typeof context.getElementsByTagName !== "undefined" ) {
  3031. return context.getElementsByTagName( match[1] );
  3032. }
  3033. }
  3034. },
  3035. preFilter: {
  3036. CLASS: function( match, curLoop, inplace, result, not, isXML ) {
  3037. match = " " + match[1].replace( rBackslash, "" ) + " ";
  3038. if ( isXML ) {
  3039. return match;
  3040. }
  3041. for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
  3042. if ( elem ) {
  3043. if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) {
  3044. if ( !inplace ) {
  3045. result.push( elem );
  3046. }
  3047. } else if ( inplace ) {
  3048. curLoop[i] = false;
  3049. }
  3050. }
  3051. }
  3052. return false;
  3053. },
  3054. ID: function( match ) {
  3055. return match[1].replace( rBackslash, "" );
  3056. },
  3057. TAG: function( match, curLoop ) {
  3058. return match[1].replace( rBackslash, "" ).toLowerCase();
  3059. },
  3060. CHILD: function( match ) {
  3061. if ( match[1] === "nth" ) {
  3062. if ( !match[2] ) {
  3063. Sizzle.error( match[0] );
  3064. }
  3065. match[2] = match[2].replace(/^\+|\s*/g, '');
  3066. // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
  3067. var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec(
  3068. match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
  3069. !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
  3070. // calculate the numbers (first)n+(last) including if they are negative
  3071. match[2] = (test[1] + (test[2] || 1)) - 0;
  3072. match[3] = test[3] - 0;
  3073. }
  3074. else if ( match[2] ) {
  3075. Sizzle.error( match[0] );
  3076. }
  3077. // TODO: Move to normal caching system
  3078. match[0] = done++;
  3079. return match;
  3080. },
  3081. ATTR: function( match, curLoop, inplace, result, not, isXML ) {
  3082. var name = match[1] = match[1].replace( rBackslash, "" );
  3083. if ( !isXML && Expr.attrMap[name] ) {
  3084. match[1] = Expr.attrMap[name];
  3085. }
  3086. // Handle if an un-quoted value was used
  3087. match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" );
  3088. if ( match[2] === "~=" ) {
  3089. match[4] = " " + match[4] + " ";
  3090. }
  3091. return match;
  3092. },
  3093. PSEUDO: function( match, curLoop, inplace, result, not ) {
  3094. if ( match[1] === "not" ) {
  3095. // If we're dealing with a complex expression, or a simple one
  3096. if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
  3097. match[3] = Sizzle(match[3], null, null, curLoop);
  3098. } else {
  3099. var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
  3100. if ( !inplace ) {
  3101. result.push.apply( result, ret );
  3102. }
  3103. return false;
  3104. }
  3105. } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
  3106. return true;
  3107. }
  3108. return match;
  3109. },
  3110. POS: function( match ) {
  3111. match.unshift( true );
  3112. return match;
  3113. }
  3114. },
  3115. filters: {
  3116. enabled: function( elem ) {
  3117. return elem.disabled === false && elem.type !== "hidden";
  3118. },
  3119. disabled: function( elem ) {
  3120. return elem.disabled === true;
  3121. },
  3122. checked: function( elem ) {
  3123. return elem.checked === true;
  3124. },
  3125. selected: function( elem ) {
  3126. // Accessing this property makes selected-by-default
  3127. // options in Safari work properly
  3128. if ( elem.parentNode ) {
  3129. elem.parentNode.selectedIndex;
  3130. }
  3131. return elem.selected === true;
  3132. },
  3133. parent: function( elem ) {
  3134. return !!elem.firstChild;
  3135. },
  3136. empty: function( elem ) {
  3137. return !elem.firstChild;
  3138. },
  3139. has: function( elem, i, match ) {
  3140. return !!Sizzle( match[3], elem ).length;
  3141. },
  3142. header: function( elem ) {
  3143. return (/h\d/i).test( elem.nodeName );
  3144. },
  3145. text: function( elem ) {
  3146. // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
  3147. // use getAttribute instead to test this case
  3148. return "text" === elem.getAttribute( 'type' );
  3149. },
  3150. radio: function( elem ) {
  3151. return "radio" === elem.type;
  3152. },
  3153. checkbox: function( elem ) {
  3154. return "checkbox" === elem.type;
  3155. },
  3156. file: function( elem ) {
  3157. return "file" === elem.type;
  3158. },
  3159. password: function( elem ) {
  3160. return "password" === elem.type;
  3161. },
  3162. submit: function( elem ) {
  3163. return "submit" === elem.type;
  3164. },
  3165. image: function( elem ) {
  3166. return "image" === elem.type;
  3167. },
  3168. reset: function( elem ) {
  3169. return "reset" === elem.type;
  3170. },
  3171. button: function( elem ) {
  3172. return "button" === elem.type || elem.nodeName.toLowerCase() === "button";
  3173. },
  3174. input: function( elem ) {
  3175. return (/input|select|textarea|button/i).test( elem.nodeName );
  3176. }
  3177. },
  3178. setFilters: {
  3179. first: function( elem, i ) {
  3180. return i === 0;
  3181. },
  3182. last: function( elem, i, match, array ) {
  3183. return i === array.length - 1;
  3184. },
  3185. even: function( elem, i ) {
  3186. return i % 2 === 0;
  3187. },
  3188. odd: function( elem, i ) {
  3189. return i % 2 === 1;
  3190. },
  3191. lt: function( elem, i, match ) {
  3192. return i < match[3] - 0;
  3193. },
  3194. gt: function( elem, i, match ) {
  3195. return i > match[3] - 0;
  3196. },
  3197. nth: function( elem, i, match ) {
  3198. return match[3] - 0 === i;
  3199. },
  3200. eq: function( elem, i, match ) {
  3201. return match[3] - 0 === i;
  3202. }
  3203. },
  3204. filter: {
  3205. PSEUDO: function( elem, match, i, array ) {
  3206. var name = match[1],
  3207. filter = Expr.filters[ name ];
  3208. if ( filter ) {
  3209. return filter( elem, i, match, array );
  3210. } else if ( name === "contains" ) {
  3211. return (elem.textContent || elem.innerText || Sizzle.getText([ elem ]) || "").indexOf(match[3]) >= 0;
  3212. } else if ( name === "not" ) {
  3213. var not = match[3];
  3214. for ( var j = 0, l = not.length; j < l; j++ ) {
  3215. if ( not[j] === elem ) {
  3216. return false;
  3217. }
  3218. }
  3219. return true;
  3220. } else {
  3221. Sizzle.error( name );
  3222. }
  3223. },
  3224. CHILD: function( elem, match ) {
  3225. var type = match[1],
  3226. node = elem;
  3227. switch ( type ) {
  3228. case "only":
  3229. case "first":
  3230. while ( (node = node.previousSibling) ) {
  3231. if ( node.nodeType === 1 ) {
  3232. return false;
  3233. }
  3234. }
  3235. if ( type === "first" ) {
  3236. return true;
  3237. }
  3238. node = elem;
  3239. case "last":
  3240. while ( (node = node.nextSibling) ) {
  3241. if ( node.nodeType === 1 ) {
  3242. return false;
  3243. }
  3244. }
  3245. return true;
  3246. case "nth":
  3247. var first = match[2],
  3248. last = match[3];
  3249. if ( first === 1 && last === 0 ) {
  3250. return true;
  3251. }
  3252. var doneName = match[0],
  3253. parent = elem.parentNode;
  3254. if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
  3255. var count = 0;
  3256. for ( node = parent.firstChild; node; node = node.nextSibling ) {
  3257. if ( node.nodeType === 1 ) {
  3258. node.nodeIndex = ++count;
  3259. }
  3260. }
  3261. parent.sizcache = doneName;
  3262. }
  3263. var diff = elem.nodeIndex - last;
  3264. if ( first === 0 ) {
  3265. return diff === 0;
  3266. } else {
  3267. return ( diff % first === 0 && diff / first >= 0 );
  3268. }
  3269. }
  3270. },
  3271. ID: function( elem, match ) {
  3272. return elem.nodeType === 1 && elem.getAttribute("id") === match;
  3273. },
  3274. TAG: function( elem, match ) {
  3275. return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
  3276. },
  3277. CLASS: function( elem, match ) {
  3278. return (" " + (elem.className || elem.getAttribute("class")) + " ")
  3279. .indexOf( match ) > -1;
  3280. },
  3281. ATTR: function( elem, match ) {
  3282. var name = match[1],
  3283. result = Expr.attrHandle[ name ] ?
  3284. Expr.attrHandle[ name ]( elem ) :
  3285. elem[ name ] != null ?
  3286. elem[ name ] :
  3287. elem.getAttribute( name ),
  3288. value = result + "",
  3289. type = match[2],
  3290. check = match[4];
  3291. return result == null ?
  3292. type === "!=" :
  3293. type === "=" ?
  3294. value === check :
  3295. type === "*=" ?
  3296. value.indexOf(check) >= 0 :
  3297. type === "~=" ?
  3298. (" " + value + " ").indexOf(check) >= 0 :
  3299. !check ?
  3300. value && result !== false :
  3301. type === "!=" ?
  3302. value !== check :
  3303. type === "^=" ?
  3304. value.indexOf(check) === 0 :
  3305. type === "$=" ?
  3306. value.substr(value.length - check.length) === check :
  3307. type === "|=" ?
  3308. value === check || value.substr(0, check.length + 1) === check + "-" :
  3309. false;
  3310. },
  3311. POS: function( elem, match, i, array ) {
  3312. var name = match[2],
  3313. filter = Expr.setFilters[ name ];
  3314. if ( filter ) {
  3315. return filter( elem, i, match, array );
  3316. }
  3317. }
  3318. }
  3319. };
  3320. var origPOS = Expr.match.POS,
  3321. fescape = function(all, num){
  3322. return "\\" + (num - 0 + 1);
  3323. };
  3324. for ( var type in Expr.match ) {
  3325. Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) );
  3326. Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) );
  3327. }
  3328. var makeArray = function( array, results ) {
  3329. array = Array.prototype.slice.call( array, 0 );
  3330. if ( results ) {
  3331. results.push.apply( results, array );
  3332. return results;
  3333. }
  3334. return array;
  3335. };
  3336. // Perform a simple check to determine if the browser is capable of
  3337. // converting a NodeList to an array using builtin methods.
  3338. // Also verifies that the returned array holds DOM nodes
  3339. // (which is not the case in the Blackberry browser)
  3340. try {
  3341. Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType;
  3342. // Provide a fallback method if it does not work
  3343. } catch( e ) {
  3344. makeArray = function( array, results ) {
  3345. var i = 0,
  3346. ret = results || [];
  3347. if ( toString.call(array) === "[object Array]" ) {
  3348. Array.prototype.push.apply( ret, array );
  3349. } else {
  3350. if ( typeof array.length === "number" ) {
  3351. for ( var l = array.length; i < l; i++ ) {
  3352. ret.push( array[i] );
  3353. }
  3354. } else {
  3355. for ( ; array[i]; i++ ) {
  3356. ret.push( array[i] );
  3357. }
  3358. }
  3359. }
  3360. return ret;
  3361. };
  3362. }
  3363. var sortOrder, siblingCheck;
  3364. if ( document.documentElement.compareDocumentPosition ) {
  3365. sortOrder = function( a, b ) {
  3366. if ( a === b ) {
  3367. hasDuplicate = true;
  3368. return 0;
  3369. }
  3370. if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
  3371. return a.compareDocumentPosition ? -1 : 1;
  3372. }
  3373. return a.compareDocumentPosition(b) & 4 ? -1 : 1;
  3374. };
  3375. } else {
  3376. sortOrder = function( a, b ) {
  3377. var al, bl,
  3378. ap = [],
  3379. bp = [],
  3380. aup = a.parentNode,
  3381. bup = b.parentNode,
  3382. cur = aup;
  3383. // The nodes are identical, we can exit early
  3384. if ( a === b ) {
  3385. hasDuplicate = true;
  3386. return 0;
  3387. // If the nodes are siblings (or identical) we can do a quick check
  3388. } else if ( aup === bup ) {
  3389. return siblingCheck( a, b );
  3390. // If no parents were found then the nodes are disconnected
  3391. } else if ( !aup ) {
  3392. return -1;
  3393. } else if ( !bup ) {
  3394. return 1;
  3395. }
  3396. // Otherwise they're somewhere else in the tree so we need
  3397. // to build up a full list of the parentNodes for comparison
  3398. while ( cur ) {
  3399. ap.unshift( cur );
  3400. cur = cur.parentNode;
  3401. }
  3402. cur = bup;
  3403. while ( cur ) {
  3404. bp.unshift( cur );
  3405. cur = cur.parentNode;
  3406. }
  3407. al = ap.length;
  3408. bl = bp.length;
  3409. // Start walking down the tree looking for a discrepancy
  3410. for ( var i = 0; i < al && i < bl; i++ ) {
  3411. if ( ap[i] !== bp[i] ) {
  3412. return siblingCheck( ap[i], bp[i] );
  3413. }
  3414. }
  3415. // We ended someplace up the tree so do a sibling check
  3416. return i === al ?
  3417. siblingCheck( a, bp[i], -1 ) :
  3418. siblingCheck( ap[i], b, 1 );
  3419. };
  3420. siblingCheck = function( a, b, ret ) {
  3421. if ( a === b ) {
  3422. return ret;
  3423. }
  3424. var cur = a.nextSibling;
  3425. while ( cur ) {
  3426. if ( cur === b ) {
  3427. return -1;
  3428. }
  3429. cur = cur.nextSibling;
  3430. }
  3431. return 1;
  3432. };
  3433. }
  3434. // Utility function for retreiving the text value of an array of DOM nodes
  3435. Sizzle.getText = function( elems ) {
  3436. var ret = "", elem;
  3437. for ( var i = 0; elems[i]; i++ ) {
  3438. elem = elems[i];
  3439. // Get the text from text nodes and CDATA nodes
  3440. if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
  3441. ret += elem.nodeValue;
  3442. // Traverse everything else, except comment nodes
  3443. } else if ( elem.nodeType !== 8 ) {
  3444. ret += Sizzle.getText( elem.childNodes );
  3445. }
  3446. }
  3447. return ret;
  3448. };
  3449. // Check to see if the browser returns elements by name when
  3450. // querying by getElementById (and provide a workaround)
  3451. (function(){
  3452. // We're going to inject a fake input element with a specified name
  3453. var form = document.createElement("div"),
  3454. id = "script" + (new Date()).getTime(),
  3455. root = document.documentElement;
  3456. form.innerHTML = "<a name='" + id + "'/>";
  3457. // Inject it into the root element, check its status, and remove it quickly
  3458. root.insertBefore( form, root.firstChild );
  3459. // The workaround has to do additional checks after a getElementById
  3460. // Which slows things down for other browsers (hence the branching)
  3461. if ( document.getElementById( id ) ) {
  3462. Expr.find.ID = function( match, context, isXML ) {
  3463. if ( typeof context.getElementById !== "undefined" && !isXML ) {
  3464. var m = context.getElementById(match[1]);
  3465. return m ?
  3466. m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ?
  3467. [m] :
  3468. undefined :
  3469. [];
  3470. }
  3471. };
  3472. Expr.filter.ID = function( elem, match ) {
  3473. var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
  3474. return elem.nodeType === 1 && node && node.nodeValue === match;
  3475. };
  3476. }
  3477. root.removeChild( form );
  3478. // release memory in IE
  3479. root = form = null;
  3480. })();
  3481. (function(){
  3482. // Check to see if the browser returns only elements
  3483. // when doing getElementsByTagName("*")
  3484. // Create a fake element
  3485. var div = document.createElement("div");
  3486. div.appendChild( document.createComment("") );
  3487. // Make sure no comments are found
  3488. if ( div.getElementsByTagName("*").length > 0 ) {
  3489. Expr.find.TAG = function( match, context ) {
  3490. var results = context.getElementsByTagName( match[1] );
  3491. // Filter out possible comments
  3492. if ( match[1] === "*" ) {
  3493. var tmp = [];
  3494. for ( var i = 0; results[i]; i++ ) {
  3495. if ( results[i].nodeType === 1 ) {
  3496. tmp.push( results[i] );
  3497. }
  3498. }
  3499. results = tmp;
  3500. }
  3501. return results;
  3502. };
  3503. }
  3504. // Check to see if an attribute returns normalized href attributes
  3505. div.innerHTML = "<a href='#'></a>";
  3506. if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
  3507. div.firstChild.getAttribute("href") !== "#" ) {
  3508. Expr.attrHandle.href = function( elem ) {
  3509. return elem.getAttribute( "href", 2 );
  3510. };
  3511. }
  3512. // release memory in IE
  3513. div = null;
  3514. })();
  3515. if ( document.querySelectorAll ) {
  3516. (function(){
  3517. var oldSizzle = Sizzle,
  3518. div = document.createElement("div"),
  3519. id = "__sizzle__";
  3520. div.innerHTML = "<p class='TEST'></p>";
  3521. // Safari can't handle uppercase or unicode characters when
  3522. // in quirks mode.
  3523. if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
  3524. return;
  3525. }
  3526. Sizzle = function( query, context, extra, seed ) {
  3527. context = context || document;
  3528. // Only use querySelectorAll on non-XML documents
  3529. // (ID selectors don't work in non-HTML documents)
  3530. if ( !seed && !Sizzle.isXML(context) ) {
  3531. // See if we find a selector to speed up
  3532. var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query );
  3533. if ( match && (context.nodeType === 1 || context.nodeType === 9) ) {
  3534. // Speed-up: Sizzle("TAG")
  3535. if ( match[1] ) {
  3536. return makeArray( context.getElementsByTagName( query ), extra );
  3537. // Speed-up: Sizzle(".CLASS")
  3538. } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) {
  3539. return makeArray( context.getElementsByClassName( match[2] ), extra );
  3540. }
  3541. }
  3542. if ( context.nodeType === 9 ) {
  3543. // Speed-up: Sizzle("body")
  3544. // The body element only exists once, optimize finding it
  3545. if ( query === "body" && context.body ) {
  3546. return makeArray( [ context.body ], extra );
  3547. // Speed-up: Sizzle("#ID")
  3548. } else if ( match && match[3] ) {
  3549. var elem = context.getElementById( match[3] );
  3550. // Check parentNode to catch when Blackberry 4.6 returns
  3551. // nodes that are no longer in the document #6963
  3552. if ( elem && elem.parentNode ) {
  3553. // Handle the case where IE and Opera return items
  3554. // by name instead of ID
  3555. if ( elem.id === match[3] ) {
  3556. return makeArray( [ elem ], extra );
  3557. }
  3558. } else {
  3559. return makeArray( [], extra );
  3560. }
  3561. }
  3562. try {
  3563. return makeArray( context.querySelectorAll(query), extra );
  3564. } catch(qsaError) {}
  3565. // qSA works strangely on Element-rooted queries
  3566. // We can work around this by specifying an extra ID on the root
  3567. // and working up from there (Thanks to Andrew Dupont for the technique)
  3568. // IE 8 doesn't work on object elements
  3569. } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
  3570. var oldContext = context,
  3571. old = context.getAttribute( "id" ),
  3572. nid = old || id,
  3573. hasParent = context.parentNode,
  3574. relativeHierarchySelector = /^\s*[+~]/.test( query );
  3575. if ( !old ) {
  3576. context.setAttribute( "id", nid );
  3577. } else {
  3578. nid = nid.replace( /'/g, "\\$&" );
  3579. }
  3580. if ( relativeHierarchySelector && hasParent ) {
  3581. context = context.parentNode;
  3582. }
  3583. try {
  3584. if ( !relativeHierarchySelector || hasParent ) {
  3585. return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra );
  3586. }
  3587. } catch(pseudoError) {
  3588. } finally {
  3589. if ( !old ) {
  3590. oldContext.removeAttribute( "id" );
  3591. }
  3592. }
  3593. }
  3594. }
  3595. return oldSizzle(query, context, extra, seed);
  3596. };
  3597. for ( var prop in oldSizzle ) {
  3598. Sizzle[ prop ] = oldSizzle[ prop ];
  3599. }
  3600. // release memory in IE
  3601. div = null;
  3602. })();
  3603. }
  3604. (function(){
  3605. var html = document.documentElement,
  3606. matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector,
  3607. pseudoWorks = false;
  3608. try {
  3609. // This should fail with an exception
  3610. // Gecko does not error, returns false instead
  3611. matches.call( document.documentElement, "[test!='']:sizzle" );
  3612. } catch( pseudoError ) {
  3613. pseudoWorks = true;
  3614. }
  3615. if ( matches ) {
  3616. Sizzle.matchesSelector = function( node, expr ) {
  3617. // Make sure that attribute selectors are quoted
  3618. expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
  3619. if ( !Sizzle.isXML( node ) ) {
  3620. try {
  3621. if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) {
  3622. return matches.call( node, expr );
  3623. }
  3624. } catch(e) {}
  3625. }
  3626. return Sizzle(expr, null, null, [node]).length > 0;
  3627. };
  3628. }
  3629. })();
  3630. (function(){
  3631. var div = document.createElement("div");
  3632. div.innerHTML = "<div class='test e'></div><div class='test'></div>";
  3633. // Opera can't find a second classname (in 9.6)
  3634. // Also, make sure that getElementsByClassName actually exists
  3635. if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
  3636. return;
  3637. }
  3638. // Safari caches class attributes, doesn't catch changes (in 3.2)
  3639. div.lastChild.className = "e";
  3640. if ( div.getElementsByClassName("e").length === 1 ) {
  3641. return;
  3642. }
  3643. Expr.order.splice(1, 0, "CLASS");
  3644. Expr.find.CLASS = function( match, context, isXML ) {
  3645. if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
  3646. return context.getElementsByClassName(match[1]);
  3647. }
  3648. };
  3649. // release memory in IE
  3650. div = null;
  3651. })();
  3652. function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
  3653. for ( var i = 0, l = checkSet.length; i < l; i++ ) {
  3654. var elem = checkSet[i];
  3655. if ( elem ) {
  3656. var match = false;
  3657. elem = elem[dir];
  3658. while ( elem ) {
  3659. if ( elem.sizcache === doneName ) {
  3660. match = checkSet[elem.sizset];
  3661. break;
  3662. }
  3663. if ( elem.nodeType === 1 && !isXML ){
  3664. elem.sizcache = doneName;
  3665. elem.sizset = i;
  3666. }
  3667. if ( elem.nodeName.toLowerCase() === cur ) {
  3668. match = elem;
  3669. break;
  3670. }
  3671. elem = elem[dir];
  3672. }
  3673. checkSet[i] = match;
  3674. }
  3675. }
  3676. }
  3677. function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
  3678. for ( var i = 0, l = checkSet.length; i < l; i++ ) {
  3679. var elem = checkSet[i];
  3680. if ( elem ) {
  3681. var match = false;
  3682. elem = elem[dir];
  3683. while ( elem ) {
  3684. if ( elem.sizcache === doneName ) {
  3685. match = checkSet[elem.sizset];
  3686. break;
  3687. }
  3688. if ( elem.nodeType === 1 ) {
  3689. if ( !isXML ) {
  3690. elem.sizcache = doneName;
  3691. elem.sizset = i;
  3692. }
  3693. if ( typeof cur !== "string" ) {
  3694. if ( elem === cur ) {
  3695. match = true;
  3696. break;
  3697. }
  3698. } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
  3699. match = elem;
  3700. break;
  3701. }
  3702. }
  3703. elem = elem[dir];
  3704. }
  3705. checkSet[i] = match;
  3706. }
  3707. }
  3708. }
  3709. if ( document.documentElement.contains ) {
  3710. Sizzle.contains = function( a, b ) {
  3711. return a !== b && (a.contains ? a.contains(b) : true);
  3712. };
  3713. } else if ( document.documentElement.compareDocumentPosition ) {
  3714. Sizzle.contains = function( a, b ) {
  3715. return !!(a.compareDocumentPosition(b) & 16);
  3716. };
  3717. } else {
  3718. Sizzle.contains = function() {
  3719. return false;
  3720. };
  3721. }
  3722. Sizzle.isXML = function( elem ) {
  3723. // documentElement is verified for cases where it doesn't yet exist
  3724. // (such as loading iframes in IE - #4833)
  3725. var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
  3726. return documentElement ? documentElement.nodeName !== "HTML" : false;
  3727. };
  3728. var posProcess = function( selector, context ) {
  3729. var match,
  3730. tmpSet = [],
  3731. later = "",
  3732. root = context.nodeType ? [context] : context;
  3733. // Position selectors must be done after the filter
  3734. // And so must :not(positional) so we move all PSEUDOs to the end
  3735. while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
  3736. later += match[0];
  3737. selector = selector.replace( Expr.match.PSEUDO, "" );
  3738. }
  3739. selector = Expr.relative[selector] ? selector + "*" : selector;
  3740. for ( var i = 0, l = root.length; i < l; i++ ) {
  3741. Sizzle( selector, root[i], tmpSet );
  3742. }
  3743. return Sizzle.filter( later, tmpSet );
  3744. };
  3745. // EXPOSE
  3746. jQuery.find = Sizzle;
  3747. jQuery.expr = Sizzle.selectors;
  3748. jQuery.expr[":"] = jQuery.expr.filters;
  3749. jQuery.unique = Sizzle.uniqueSort;
  3750. jQuery.text = Sizzle.getText;
  3751. jQuery.isXMLDoc = Sizzle.isXML;
  3752. jQuery.contains = Sizzle.contains;
  3753. })();
  3754. var runtil = /Until$/,
  3755. rparentsprev = /^(?:parents|prevUntil|prevAll)/,
  3756. // Note: This RegExp should be improved, or likely pulled from Sizzle
  3757. rmultiselector = /,/,
  3758. isSimple = /^.[^:#\[\.,]*$/,
  3759. slice = Array.prototype.slice,
  3760. POS = jQuery.expr.match.POS,
  3761. // methods guaranteed to produce a unique set when starting from a unique set
  3762. guaranteedUnique = {
  3763. children: true,
  3764. contents: true,
  3765. next: true,
  3766. prev: true
  3767. };
  3768. jQuery.fn.extend({
  3769. find: function( selector ) {
  3770. var ret = this.pushStack( "", "find", selector ),
  3771. length = 0;
  3772. for ( var i = 0, l = this.length; i < l; i++ ) {
  3773. length = ret.length;
  3774. jQuery.find( selector, this[i], ret );
  3775. if ( i > 0 ) {
  3776. // Make sure that the results are unique
  3777. for ( var n = length; n < ret.length; n++ ) {
  3778. for ( var r = 0; r < length; r++ ) {
  3779. if ( ret[r] === ret[n] ) {
  3780. ret.splice(n--, 1);
  3781. break;
  3782. }
  3783. }
  3784. }
  3785. }
  3786. }
  3787. return ret;
  3788. },
  3789. has: function( target ) {
  3790. var targets = jQuery( target );
  3791. return this.filter(function() {
  3792. for ( var i = 0, l = targets.length; i < l; i++ ) {
  3793. if ( jQuery.contains( this, targets[i] ) ) {
  3794. return true;
  3795. }
  3796. }
  3797. });
  3798. },
  3799. not: function( selector ) {
  3800. return this.pushStack( winnow(this, selector, false), "not", selector);
  3801. },
  3802. filter: function( selector ) {
  3803. return this.pushStack( winnow(this, selector, true), "filter", selector );
  3804. },
  3805. is: function( selector ) {
  3806. return !!selector && jQuery.filter( selector, this ).length > 0;
  3807. },
  3808. closest: function( selectors, context ) {
  3809. var ret = [], i, l, cur = this[0];
  3810. if ( jQuery.isArray( selectors ) ) {
  3811. var match, selector,
  3812. matches = {},
  3813. level = 1;
  3814. if ( cur && selectors.length ) {
  3815. for ( i = 0, l = selectors.length; i < l; i++ ) {
  3816. selector = selectors[i];
  3817. if ( !matches[selector] ) {
  3818. matches[selector] = jQuery.expr.match.POS.test( selector ) ?
  3819. jQuery( selector, context || this.context ) :
  3820. selector;
  3821. }
  3822. }
  3823. while ( cur && cur.ownerDocument && cur !== context ) {
  3824. for ( selector in matches ) {
  3825. match = matches[selector];
  3826. if ( match.jquery ? match.index(cur) > -1 : jQuery(cur).is(match) ) {
  3827. ret.push({ selector: selector, elem: cur, level: level });
  3828. }
  3829. }
  3830. cur = cur.parentNode;
  3831. level++;
  3832. }
  3833. }
  3834. return ret;
  3835. }
  3836. var pos = POS.test( selectors ) ?
  3837. jQuery( selectors, context || this.context ) : null;
  3838. for ( i = 0, l = this.length; i < l; i++ ) {
  3839. cur = this[i];
  3840. while ( cur ) {
  3841. if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
  3842. ret.push( cur );
  3843. break;
  3844. } else {
  3845. cur = cur.parentNode;
  3846. if ( !cur || !cur.ownerDocument || cur === context ) {
  3847. break;
  3848. }
  3849. }
  3850. }
  3851. }
  3852. ret = ret.length > 1 ? jQuery.unique(ret) : ret;
  3853. return this.pushStack( ret, "closest", selectors );
  3854. },
  3855. // Determine the position of an element within
  3856. // the matched set of elements
  3857. index: function( elem ) {
  3858. if ( !elem || typeof elem === "string" ) {
  3859. return jQuery.inArray( this[0],
  3860. // If it receives a string, the selector is used
  3861. // If it receives nothing, the siblings are used
  3862. elem ? jQuery( elem ) : this.parent().children() );
  3863. }
  3864. // Locate the position of the desired element
  3865. return jQuery.inArray(
  3866. // If it receives a jQuery object, the first element is used
  3867. elem.jquery ? elem[0] : elem, this );
  3868. },
  3869. add: function( selector, context ) {
  3870. var set = typeof selector === "string" ?
  3871. jQuery( selector, context ) :
  3872. jQuery.makeArray( selector ),
  3873. all = jQuery.merge( this.get(), set );
  3874. return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
  3875. all :
  3876. jQuery.unique( all ) );
  3877. },
  3878. andSelf: function() {
  3879. return this.add( this.prevObject );
  3880. }
  3881. });
  3882. // A painfully simple check to see if an element is disconnected
  3883. // from a document (should be improved, where feasible).
  3884. function isDisconnected( node ) {
  3885. return !node || !node.parentNode || node.parentNode.nodeType === 11;
  3886. }
  3887. jQuery.each({
  3888. parent: function( elem ) {
  3889. var parent = elem.parentNode;
  3890. return parent && parent.nodeType !== 11 ? parent : null;
  3891. },
  3892. parents: function( elem ) {
  3893. return jQuery.dir( elem, "parentNode" );
  3894. },
  3895. parentsUntil: function( elem, i, until ) {
  3896. return jQuery.dir( elem, "parentNode", until );
  3897. },
  3898. next: function( elem ) {
  3899. return jQuery.nth( elem, 2, "nextSibling" );
  3900. },
  3901. prev: function( elem ) {
  3902. return jQuery.nth( elem, 2, "previousSibling" );
  3903. },
  3904. nextAll: function( elem ) {
  3905. return jQuery.dir( elem, "nextSibling" );
  3906. },
  3907. prevAll: function( elem ) {
  3908. return jQuery.dir( elem, "previousSibling" );
  3909. },
  3910. nextUntil: function( elem, i, until ) {
  3911. return jQuery.dir( elem, "nextSibling", until );
  3912. },
  3913. prevUntil: function( elem, i, until ) {
  3914. return jQuery.dir( elem, "previousSibling", until );
  3915. },
  3916. siblings: function( elem ) {
  3917. return jQuery.sibling( elem.parentNode.firstChild, elem );
  3918. },
  3919. children: function( elem ) {
  3920. return jQuery.sibling( elem.firstChild );
  3921. },
  3922. contents: function( elem ) {
  3923. return jQuery.nodeName( elem, "iframe" ) ?
  3924. elem.contentDocument || elem.contentWindow.document :
  3925. jQuery.makeArray( elem.childNodes );
  3926. }
  3927. }, function( name, fn ) {
  3928. jQuery.fn[ name ] = function( until, selector ) {
  3929. var ret = jQuery.map( this, fn, until ),
  3930. // The variable 'args' was introduced in
  3931. // https://github.com/jquery/jquery/commit/52a0238
  3932. // to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed.
  3933. // http://code.google.com/p/v8/issues/detail?id=1050
  3934. args = slice.call(arguments);
  3935. if ( !runtil.test( name ) ) {
  3936. selector = until;
  3937. }
  3938. if ( selector && typeof selector === "string" ) {
  3939. ret = jQuery.filter( selector, ret );
  3940. }
  3941. ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret;
  3942. if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
  3943. ret = ret.reverse();
  3944. }
  3945. return this.pushStack( ret, name, args.join(",") );
  3946. };
  3947. });
  3948. jQuery.extend({
  3949. filter: function( expr, elems, not ) {
  3950. if ( not ) {
  3951. expr = ":not(" + expr + ")";
  3952. }
  3953. return elems.length === 1 ?
  3954. jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
  3955. jQuery.find.matches(expr, elems);
  3956. },
  3957. dir: function( elem, dir, until ) {
  3958. var matched = [],
  3959. cur = elem[ dir ];
  3960. while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
  3961. if ( cur.nodeType === 1 ) {
  3962. matched.push( cur );
  3963. }
  3964. cur = cur[dir];
  3965. }
  3966. return matched;
  3967. },
  3968. nth: function( cur, result, dir, elem ) {
  3969. result = result || 1;
  3970. var num = 0;
  3971. for ( ; cur; cur = cur[dir] ) {
  3972. if ( cur.nodeType === 1 && ++num === result ) {
  3973. break;
  3974. }
  3975. }
  3976. return cur;
  3977. },
  3978. sibling: function( n, elem ) {
  3979. var r = [];
  3980. for ( ; n; n = n.nextSibling ) {
  3981. if ( n.nodeType === 1 && n !== elem ) {
  3982. r.push( n );
  3983. }
  3984. }
  3985. return r;
  3986. }
  3987. });
  3988. // Implement the identical functionality for filter and not
  3989. function winnow( elements, qualifier, keep ) {
  3990. if ( jQuery.isFunction( qualifier ) ) {
  3991. return jQuery.grep(elements, function( elem, i ) {
  3992. var retVal = !!qualifier.call( elem, i, elem );
  3993. return retVal === keep;
  3994. });
  3995. } else if ( qualifier.nodeType ) {
  3996. return jQuery.grep(elements, function( elem, i ) {
  3997. return (elem === qualifier) === keep;
  3998. });
  3999. } else if ( typeof qualifier === "string" ) {
  4000. var filtered = jQuery.grep(elements, function( elem ) {
  4001. return elem.nodeType === 1;
  4002. });
  4003. if ( isSimple.test( qualifier ) ) {
  4004. return jQuery.filter(qualifier, filtered, !keep);
  4005. } else {
  4006. qualifier = jQuery.filter( qualifier, filtered );
  4007. }
  4008. }
  4009. return jQuery.grep(elements, function( elem, i ) {
  4010. return (jQuery.inArray( elem, qualifier ) >= 0) === keep;
  4011. });
  4012. }
  4013. var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
  4014. rleadingWhitespace = /^\s+/,
  4015. rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
  4016. rtagName = /<([\w:]+)/,
  4017. rtbody = /<tbody/i,
  4018. rhtml = /<|&#?\w+;/,
  4019. rnocache = /<(?:script|object|embed|option|style)/i,
  4020. // checked="checked" or checked
  4021. rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
  4022. wrapMap = {
  4023. option: [ 1, "<select multiple='multiple'>", "</select>" ],
  4024. legend: [ 1, "<fieldset>", "</fieldset>" ],
  4025. thead: [ 1, "<table>", "</table>" ],
  4026. tr: [ 2, "<table><tbody>", "</tbody></table>" ],
  4027. td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
  4028. col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
  4029. area: [ 1, "<map>", "</map>" ],
  4030. _default: [ 0, "", "" ]
  4031. };
  4032. wrapMap.optgroup = wrapMap.option;
  4033. wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  4034. wrapMap.th = wrapMap.td;
  4035. // IE can't serialize <link> and <script> tags normally
  4036. if ( !jQuery.support.htmlSerialize ) {
  4037. wrapMap._default = [ 1, "div<div>", "</div>" ];
  4038. }
  4039. jQuery.fn.extend({
  4040. text: function( text ) {
  4041. if ( jQuery.isFunction(text) ) {
  4042. return this.each(function(i) {
  4043. var self = jQuery( this );
  4044. self.text( text.call(this, i, self.text()) );
  4045. });
  4046. }
  4047. if ( typeof text !== "object" && text !== undefined ) {
  4048. return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
  4049. }
  4050. return jQuery.text( this );
  4051. },
  4052. wrapAll: function( html ) {
  4053. if ( jQuery.isFunction( html ) ) {
  4054. return this.each(function(i) {
  4055. jQuery(this).wrapAll( html.call(this, i) );
  4056. });
  4057. }
  4058. if ( this[0] ) {
  4059. // The elements to wrap the target around
  4060. var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
  4061. if ( this[0].parentNode ) {
  4062. wrap.insertBefore( this[0] );
  4063. }
  4064. wrap.map(function() {
  4065. var elem = this;
  4066. while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
  4067. elem = elem.firstChild;
  4068. }
  4069. return elem;
  4070. }).append(this);
  4071. }
  4072. return this;
  4073. },
  4074. wrapInner: function( html ) {
  4075. if ( jQuery.isFunction( html ) ) {
  4076. return this.each(function(i) {
  4077. jQuery(this).wrapInner( html.call(this, i) );
  4078. });
  4079. }
  4080. return this.each(function() {
  4081. var self = jQuery( this ),
  4082. contents = self.contents();
  4083. if ( contents.length ) {
  4084. contents.wrapAll( html );
  4085. } else {
  4086. self.append( html );
  4087. }
  4088. });
  4089. },
  4090. wrap: function( html ) {
  4091. return this.each(function() {
  4092. jQuery( this ).wrapAll( html );
  4093. });
  4094. },
  4095. unwrap: function() {
  4096. return this.parent().each(function() {
  4097. if ( !jQuery.nodeName( this, "body" ) ) {
  4098. jQuery( this ).replaceWith( this.childNodes );
  4099. }
  4100. }).end();
  4101. },
  4102. append: function() {
  4103. return this.domManip(arguments, true, function( elem ) {
  4104. if ( this.nodeType === 1 ) {
  4105. this.appendChild( elem );
  4106. }
  4107. });
  4108. },
  4109. prepend: function() {
  4110. return this.domManip(arguments, true, function( elem ) {
  4111. if ( this.nodeType === 1 ) {
  4112. this.insertBefore( elem, this.firstChild );
  4113. }
  4114. });
  4115. },
  4116. before: function() {
  4117. if ( this[0] && this[0].parentNode ) {
  4118. return this.domManip(arguments, false, function( elem ) {
  4119. this.parentNode.insertBefore( elem, this );
  4120. });
  4121. } else if ( arguments.length ) {
  4122. var set = jQuery(arguments[0]);
  4123. set.push.apply( set, this.toArray() );
  4124. return this.pushStack( set, "before", arguments );
  4125. }
  4126. },
  4127. after: function() {
  4128. if ( this[0] && this[0].parentNode ) {
  4129. return this.domManip(arguments, false, function( elem ) {
  4130. this.parentNode.insertBefore( elem, this.nextSibling );
  4131. });
  4132. } else if ( arguments.length ) {
  4133. var set = this.pushStack( this, "after", arguments );
  4134. set.push.apply( set, jQuery(arguments[0]).toArray() );
  4135. return set;
  4136. }
  4137. },
  4138. // keepData is for internal use only--do not document
  4139. remove: function( selector, keepData ) {
  4140. for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
  4141. if ( !selector || jQuery.filter( selector, [ elem ] ).length ) {
  4142. if ( !keepData && elem.nodeType === 1 ) {
  4143. jQuery.cleanData( elem.getElementsByTagName("*") );
  4144. jQuery.cleanData( [ elem ] );
  4145. }
  4146. if ( elem.parentNode ) {
  4147. elem.parentNode.removeChild( elem );
  4148. }
  4149. }
  4150. }
  4151. return this;
  4152. },
  4153. empty: function() {
  4154. for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
  4155. // Remove element nodes and prevent memory leaks
  4156. if ( elem.nodeType === 1 ) {
  4157. jQuery.cleanData( elem.getElementsByTagName("*") );
  4158. }
  4159. // Remove any remaining nodes
  4160. while ( elem.firstChild ) {
  4161. elem.removeChild( elem.firstChild );
  4162. }
  4163. }
  4164. return this;
  4165. },
  4166. clone: function( dataAndEvents, deepDataAndEvents ) {
  4167. dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
  4168. deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
  4169. return this.map( function () {
  4170. return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
  4171. });
  4172. },
  4173. html: function( value ) {
  4174. if ( value === undefined ) {
  4175. return this[0] && this[0].nodeType === 1 ?
  4176. this[0].innerHTML.replace(rinlinejQuery, "") :
  4177. null;
  4178. // See if we can take a shortcut and just use innerHTML
  4179. } else if ( typeof value === "string" && !rnocache.test( value ) &&
  4180. (jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) &&
  4181. !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) {
  4182. value = value.replace(rxhtmlTag, "<$1></$2>");
  4183. try {
  4184. for ( var i = 0, l = this.length; i < l; i++ ) {
  4185. // Remove element nodes and prevent memory leaks
  4186. if ( this[i].nodeType === 1 ) {
  4187. jQuery.cleanData( this[i].getElementsByTagName("*") );
  4188. this[i].innerHTML = value;
  4189. }
  4190. }
  4191. // If using innerHTML throws an exception, use the fallback method
  4192. } catch(e) {
  4193. this.empty().append( value );
  4194. }
  4195. } else if ( jQuery.isFunction( value ) ) {
  4196. this.each(function(i){
  4197. var self = jQuery( this );
  4198. self.html( value.call(this, i, self.html()) );
  4199. });
  4200. } else {
  4201. this.empty().append( value );
  4202. }
  4203. return this;
  4204. },
  4205. replaceWith: function( value ) {
  4206. if ( this[0] && this[0].parentNode ) {
  4207. // Make sure that the elements are removed from the DOM before they are inserted
  4208. // this can help fix replacing a parent with child elements
  4209. if ( jQuery.isFunction( value ) ) {
  4210. return this.each(function(i) {
  4211. var self = jQuery(this), old = self.html();
  4212. self.replaceWith( value.call( this, i, old ) );
  4213. });
  4214. }
  4215. if ( typeof value !== "string" ) {
  4216. value = jQuery( value ).detach();
  4217. }
  4218. return this.each(function() {
  4219. var next = this.nextSibling,
  4220. parent = this.parentNode;
  4221. jQuery( this ).remove();
  4222. if ( next ) {
  4223. jQuery(next).before( value );
  4224. } else {
  4225. jQuery(parent).append( value );
  4226. }
  4227. });
  4228. } else {
  4229. return this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value );
  4230. }
  4231. },
  4232. detach: function( selector ) {
  4233. return this.remove( selector, true );
  4234. },
  4235. domManip: function( args, table, callback ) {
  4236. var results, first, fragment, parent,
  4237. value = args[0],
  4238. scripts = [];
  4239. // We can't cloneNode fragments that contain checked, in WebKit
  4240. if ( !jQuery.support.checkClone && arguments.length === 3 && typeof value === "string" && rchecked.test( value ) ) {
  4241. return this.each(function() {
  4242. jQuery(this).domManip( args, table, callback, true );
  4243. });
  4244. }
  4245. if ( jQuery.isFunction(value) ) {
  4246. return this.each(function(i) {
  4247. var self = jQuery(this);
  4248. args[0] = value.call(this, i, table ? self.html() : undefined);
  4249. self.domManip( args, table, callback );
  4250. });
  4251. }
  4252. if ( this[0] ) {
  4253. parent = value && value.parentNode;
  4254. // If we're in a fragment, just use that instead of building a new one
  4255. if ( jQuery.support.parentNode && parent && parent.nodeType === 11 && parent.childNodes.length === this.length ) {
  4256. results = { fragment: parent };
  4257. } else {
  4258. results = jQuery.buildFragment( args, this, scripts );
  4259. }
  4260. fragment = results.fragment;
  4261. if ( fragment.childNodes.length === 1 ) {
  4262. first = fragment = fragment.firstChild;
  4263. } else {
  4264. first = fragment.firstChild;
  4265. }
  4266. if ( first ) {
  4267. table = table && jQuery.nodeName( first, "tr" );
  4268. for ( var i = 0, l = this.length, lastIndex = l - 1; i < l; i++ ) {
  4269. callback.call(
  4270. table ?
  4271. root(this[i], first) :
  4272. this[i],
  4273. // Make sure that we do not leak memory by inadvertently discarding
  4274. // the original fragment (which might have attached data) instead of
  4275. // using it; in addition, use the original fragment object for the last
  4276. // item instead of first because it can end up being emptied incorrectly
  4277. // in certain situations (Bug #8070).
  4278. // Fragments from the fragment cache must always be cloned and never used
  4279. // in place.
  4280. results.cacheable || (l > 1 && i < lastIndex) ?
  4281. jQuery.clone( fragment, true, true ) :
  4282. fragment
  4283. );
  4284. }
  4285. }
  4286. if ( scripts.length ) {
  4287. jQuery.each( scripts, evalScript );
  4288. }
  4289. }
  4290. return this;
  4291. }
  4292. });
  4293. function root( elem, cur ) {
  4294. return jQuery.nodeName(elem, "table") ?
  4295. (elem.getElementsByTagName("tbody")[0] ||
  4296. elem.appendChild(elem.ownerDocument.createElement("tbody"))) :
  4297. elem;
  4298. }
  4299. function cloneCopyEvent( src, dest ) {
  4300. if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
  4301. return;
  4302. }
  4303. var internalKey = jQuery.expando,
  4304. oldData = jQuery.data( src ),
  4305. curData = jQuery.data( dest, oldData );
  4306. // Switch to use the internal data object, if it exists, for the next
  4307. // stage of data copying
  4308. if ( (oldData = oldData[ internalKey ]) ) {
  4309. var events = oldData.events;
  4310. curData = curData[ internalKey ] = jQuery.extend({}, oldData);
  4311. if ( events ) {
  4312. delete curData.handle;
  4313. curData.events = {};
  4314. for ( var type in events ) {
  4315. for ( var i = 0, l = events[ type ].length; i < l; i++ ) {
  4316. jQuery.event.add( dest, type + ( events[ type ][ i ].namespace ? "." : "" ) + events[ type ][ i ].namespace, events[ type ][ i ], events[ type ][ i ].data );
  4317. }
  4318. }
  4319. }
  4320. }
  4321. }
  4322. function cloneFixAttributes(src, dest) {
  4323. // We do not need to do anything for non-Elements
  4324. if ( dest.nodeType !== 1 ) {
  4325. return;
  4326. }
  4327. var nodeName = dest.nodeName.toLowerCase();
  4328. // clearAttributes removes the attributes, which we don't want,
  4329. // but also removes the attachEvent events, which we *do* want
  4330. dest.clearAttributes();
  4331. // mergeAttributes, in contrast, only merges back on the
  4332. // original attributes, not the events
  4333. dest.mergeAttributes(src);
  4334. // IE6-8 fail to clone children inside object elements that use
  4335. // the proprietary classid attribute value (rather than the type
  4336. // attribute) to identify the type of content to display
  4337. if ( nodeName === "object" ) {
  4338. dest.outerHTML = src.outerHTML;
  4339. } else if ( nodeName === "input" && (src.type === "checkbox" || src.type === "radio") ) {
  4340. // IE6-8 fails to persist the checked state of a cloned checkbox
  4341. // or radio button. Worse, IE6-7 fail to give the cloned element
  4342. // a checked appearance if the defaultChecked value isn't also set
  4343. if ( src.checked ) {
  4344. dest.defaultChecked = dest.checked = src.checked;
  4345. }
  4346. // IE6-7 get confused and end up setting the value of a cloned
  4347. // checkbox/radio button to an empty string instead of "on"
  4348. if ( dest.value !== src.value ) {
  4349. dest.value = src.value;
  4350. }
  4351. // IE6-8 fails to return the selected option to the default selected
  4352. // state when cloning options
  4353. } else if ( nodeName === "option" ) {
  4354. dest.selected = src.defaultSelected;
  4355. // IE6-8 fails to set the defaultValue to the correct value when
  4356. // cloning other types of input fields
  4357. } else if ( nodeName === "input" || nodeName === "textarea" ) {
  4358. dest.defaultValue = src.defaultValue;
  4359. }
  4360. // Event data gets referenced instead of copied if the expando
  4361. // gets copied too
  4362. dest.removeAttribute( jQuery.expando );
  4363. }
  4364. jQuery.buildFragment = function( args, nodes, scripts ) {
  4365. var fragment, cacheable, cacheresults,
  4366. doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document);
  4367. // Only cache "small" (1/2 KB) HTML strings that are associated with the main document
  4368. // Cloning options loses the selected state, so don't cache them
  4369. // IE 6 doesn't like it when you put <object> or <embed> elements in a fragment
  4370. // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache
  4371. if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && doc === document &&
  4372. args[0].charAt(0) === "<" && !rnocache.test( args[0] ) && (jQuery.support.checkClone || !rchecked.test( args[0] )) ) {
  4373. cacheable = true;
  4374. cacheresults = jQuery.fragments[ args[0] ];
  4375. if ( cacheresults ) {
  4376. if ( cacheresults !== 1 ) {
  4377. fragment = cacheresults;
  4378. }
  4379. }
  4380. }
  4381. if ( !fragment ) {
  4382. fragment = doc.createDocumentFragment();
  4383. jQuery.clean( args, doc, fragment, scripts );
  4384. }
  4385. if ( cacheable ) {
  4386. jQuery.fragments[ args[0] ] = cacheresults ? fragment : 1;
  4387. }
  4388. return { fragment: fragment, cacheable: cacheable };
  4389. };
  4390. jQuery.fragments = {};
  4391. jQuery.each({
  4392. appendTo: "append",
  4393. prependTo: "prepend",
  4394. insertBefore: "before",
  4395. insertAfter: "after",
  4396. replaceAll: "replaceWith"
  4397. }, function( name, original ) {
  4398. jQuery.fn[ name ] = function( selector ) {
  4399. var ret = [],
  4400. insert = jQuery( selector ),
  4401. parent = this.length === 1 && this[0].parentNode;
  4402. if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) {
  4403. insert[ original ]( this[0] );
  4404. return this;
  4405. } else {
  4406. for ( var i = 0, l = insert.length; i < l; i++ ) {
  4407. var elems = (i > 0 ? this.clone(true) : this).get();
  4408. jQuery( insert[i] )[ original ]( elems );
  4409. ret = ret.concat( elems );
  4410. }
  4411. return this.pushStack( ret, name, insert.selector );
  4412. }
  4413. };
  4414. });
  4415. function getAll( elem ) {
  4416. if ( "getElementsByTagName" in elem ) {
  4417. return elem.getElementsByTagName( "*" );
  4418. } else if ( "querySelectorAll" in elem ) {
  4419. return elem.querySelectorAll( "*" );
  4420. } else {
  4421. return [];
  4422. }
  4423. }
  4424. jQuery.extend({
  4425. clone: function( elem, dataAndEvents, deepDataAndEvents ) {
  4426. var clone = elem.cloneNode(true),
  4427. srcElements,
  4428. destElements,
  4429. i;
  4430. if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
  4431. (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
  4432. // IE copies events bound via attachEvent when using cloneNode.
  4433. // Calling detachEvent on the clone will also remove the events
  4434. // from the original. In order to get around this, we use some
  4435. // proprietary methods to clear the events. Thanks to MooTools
  4436. // guys for this hotness.
  4437. cloneFixAttributes( elem, clone );
  4438. // Using Sizzle here is crazy slow, so we use getElementsByTagName
  4439. // instead
  4440. srcElements = getAll( elem );
  4441. destElements = getAll( clone );
  4442. // Weird iteration because IE will replace the length property
  4443. // with an element if you are cloning the body and one of the
  4444. // elements on the page has a name or id of "length"
  4445. for ( i = 0; srcElements[i]; ++i ) {
  4446. cloneFixAttributes( srcElements[i], destElements[i] );
  4447. }
  4448. }
  4449. // Copy the events from the original to the clone
  4450. if ( dataAndEvents ) {
  4451. cloneCopyEvent( elem, clone );
  4452. if ( deepDataAndEvents ) {
  4453. srcElements = getAll( elem );
  4454. destElements = getAll( clone );
  4455. for ( i = 0; srcElements[i]; ++i ) {
  4456. cloneCopyEvent( srcElements[i], destElements[i] );
  4457. }
  4458. }
  4459. }
  4460. // Return the cloned set
  4461. return clone;
  4462. },
  4463. clean: function( elems, context, fragment, scripts ) {
  4464. context = context || document;
  4465. // !context.createElement fails in IE with an error but returns typeof 'object'
  4466. if ( typeof context.createElement === "undefined" ) {
  4467. context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
  4468. }
  4469. var ret = [];
  4470. for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
  4471. if ( typeof elem === "number" ) {
  4472. elem += "";
  4473. }
  4474. if ( !elem ) {
  4475. continue;
  4476. }
  4477. // Convert html string into DOM nodes
  4478. if ( typeof elem === "string" && !rhtml.test( elem ) ) {
  4479. elem = context.createTextNode( elem );
  4480. } else if ( typeof elem === "string" ) {
  4481. // Fix "XHTML"-style tags in all browsers
  4482. elem = elem.replace(rxhtmlTag, "<$1></$2>");
  4483. // Trim whitespace, otherwise indexOf won't work as expected
  4484. var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(),
  4485. wrap = wrapMap[ tag ] || wrapMap._default,
  4486. depth = wrap[0],
  4487. div = context.createElement("div");
  4488. // Go to html and back, then peel off extra wrappers
  4489. div.innerHTML = wrap[1] + elem + wrap[2];
  4490. // Move to the right depth
  4491. while ( depth-- ) {
  4492. div = div.lastChild;
  4493. }
  4494. // Remove IE's autoinserted <tbody> from table fragments
  4495. if ( !jQuery.support.tbody ) {
  4496. // String was a <table>, *may* have spurious <tbody>
  4497. var hasBody = rtbody.test(elem),
  4498. tbody = tag === "table" && !hasBody ?
  4499. div.firstChild && div.firstChild.childNodes :
  4500. // String was a bare <thead> or <tfoot>
  4501. wrap[1] === "<table>" && !hasBody ?
  4502. div.childNodes :
  4503. [];
  4504. for ( var j = tbody.length - 1; j >= 0 ; --j ) {
  4505. if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
  4506. tbody[ j ].parentNode.removeChild( tbody[ j ] );
  4507. }
  4508. }
  4509. }
  4510. // IE completely kills leading whitespace when innerHTML is used
  4511. if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
  4512. div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
  4513. }
  4514. elem = div.childNodes;
  4515. }
  4516. if ( elem.nodeType ) {
  4517. ret.push( elem );
  4518. } else {
  4519. ret = jQuery.merge( ret, elem );
  4520. }
  4521. }
  4522. if ( fragment ) {
  4523. for ( i = 0; ret[i]; i++ ) {
  4524. if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
  4525. scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
  4526. } else {
  4527. if ( ret[i].nodeType === 1 ) {
  4528. ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) );
  4529. }
  4530. fragment.appendChild( ret[i] );
  4531. }
  4532. }
  4533. }
  4534. return ret;
  4535. },
  4536. cleanData: function( elems ) {
  4537. var data, id, cache = jQuery.cache, internalKey = jQuery.expando, special = jQuery.event.special,
  4538. deleteExpando = jQuery.support.deleteExpando;
  4539. for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
  4540. if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
  4541. continue;
  4542. }
  4543. id = elem[ jQuery.expando ];
  4544. if ( id ) {
  4545. data = cache[ id ] && cache[ id ][ internalKey ];
  4546. if ( data && data.events ) {
  4547. for ( var type in data.events ) {
  4548. if ( special[ type ] ) {
  4549. jQuery.event.remove( elem, type );
  4550. // This is a shortcut to avoid jQuery.event.remove's overhead
  4551. } else {
  4552. jQuery.removeEvent( elem, type, data.handle );
  4553. }
  4554. }
  4555. // Null the DOM reference to avoid IE6/7/8 leak (#7054)
  4556. if ( data.handle ) {
  4557. data.handle.elem = null;
  4558. }
  4559. }
  4560. if ( deleteExpando ) {
  4561. delete elem[ jQuery.expando ];
  4562. } else if ( elem.removeAttribute ) {
  4563. elem.removeAttribute( jQuery.expando );
  4564. }
  4565. delete cache[ id ];
  4566. }
  4567. }
  4568. }
  4569. });
  4570. function evalScript( i, elem ) {
  4571. if ( elem.src ) {
  4572. jQuery.ajax({
  4573. url: elem.src,
  4574. async: false,
  4575. dataType: "script"
  4576. });
  4577. } else {
  4578. jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );
  4579. }
  4580. if ( elem.parentNode ) {
  4581. elem.parentNode.removeChild( elem );
  4582. }
  4583. }
  4584. var ralpha = /alpha\([^)]*\)/i,
  4585. ropacity = /opacity=([^)]*)/,
  4586. rdashAlpha = /-([a-z])/ig,
  4587. rupper = /([A-Z])/g,
  4588. rnumpx = /^-?\d+(?:px)?$/i,
  4589. rnum = /^-?\d/,
  4590. cssShow = { position: "absolute", visibility: "hidden", display: "block" },
  4591. cssWidth = [ "Left", "Right" ],
  4592. cssHeight = [ "Top", "Bottom" ],
  4593. curCSS,
  4594. getComputedStyle,
  4595. currentStyle,
  4596. fcamelCase = function( all, letter ) {
  4597. return letter.toUpperCase();
  4598. };
  4599. jQuery.fn.css = function( name, value ) {
  4600. // Setting 'undefined' is a no-op
  4601. if ( arguments.length === 2 && value === undefined ) {
  4602. return this;
  4603. }
  4604. return jQuery.access( this, name, value, true, function( elem, name, value ) {
  4605. return value !== undefined ?
  4606. jQuery.style( elem, name, value ) :
  4607. jQuery.css( elem, name );
  4608. });
  4609. };
  4610. jQuery.extend({
  4611. // Add in style property hooks for overriding the default
  4612. // behavior of getting and setting a style property
  4613. cssHooks: {
  4614. opacity: {
  4615. get: function( elem, computed ) {
  4616. if ( computed ) {
  4617. // We should always get a number back from opacity
  4618. var ret = curCSS( elem, "opacity", "opacity" );
  4619. return ret === "" ? "1" : ret;
  4620. } else {
  4621. return elem.style.opacity;
  4622. }
  4623. }
  4624. }
  4625. },
  4626. // Exclude the following css properties to add px
  4627. cssNumber: {
  4628. "zIndex": true,
  4629. "fontWeight": true,
  4630. "opacity": true,
  4631. "zoom": true,
  4632. "lineHeight": true
  4633. },
  4634. // Add in properties whose names you wish to fix before
  4635. // setting or getting the value
  4636. cssProps: {
  4637. // normalize float css property
  4638. "float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat"
  4639. },
  4640. // Get and set the style property on a DOM Node
  4641. style: function( elem, name, value, extra ) {
  4642. // Don't set styles on text and comment nodes
  4643. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
  4644. return;
  4645. }
  4646. // Make sure that we're working with the right name
  4647. var ret, origName = jQuery.camelCase( name ),
  4648. style = elem.style, hooks = jQuery.cssHooks[ origName ];
  4649. name = jQuery.cssProps[ origName ] || origName;
  4650. // Check if we're setting a value
  4651. if ( value !== undefined ) {
  4652. // Make sure that NaN and null values aren't set. See: #7116
  4653. if ( typeof value === "number" && isNaN( value ) || value == null ) {
  4654. return;
  4655. }
  4656. // If a number was passed in, add 'px' to the (except for certain CSS properties)
  4657. if ( typeof value === "number" && !jQuery.cssNumber[ origName ] ) {
  4658. value += "px";
  4659. }
  4660. // If a hook was provided, use that value, otherwise just set the specified value
  4661. if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value )) !== undefined ) {
  4662. // Wrapped to prevent IE from throwing errors when 'invalid' values are provided
  4663. // Fixes bug #5509
  4664. try {
  4665. style[ name ] = value;
  4666. } catch(e) {}
  4667. }
  4668. } else {
  4669. // If a hook was provided get the non-computed value from there
  4670. if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
  4671. return ret;
  4672. }
  4673. // Otherwise just get the value from the style object
  4674. return style[ name ];
  4675. }
  4676. },
  4677. css: function( elem, name, extra ) {
  4678. // Make sure that we're working with the right name
  4679. var ret, origName = jQuery.camelCase( name ),
  4680. hooks = jQuery.cssHooks[ origName ];
  4681. name = jQuery.cssProps[ origName ] || origName;
  4682. // If a hook was provided get the computed value from there
  4683. if ( hooks && "get" in hooks && (ret = hooks.get( elem, true, extra )) !== undefined ) {
  4684. return ret;
  4685. // Otherwise, if a way to get the computed value exists, use that
  4686. } else if ( curCSS ) {
  4687. return curCSS( elem, name, origName );
  4688. }
  4689. },
  4690. // A method for quickly swapping in/out CSS properties to get correct calculations
  4691. swap: function( elem, options, callback ) {
  4692. var old = {};
  4693. // Remember the old values, and insert the new ones
  4694. for ( var name in options ) {
  4695. old[ name ] = elem.style[ name ];
  4696. elem.style[ name ] = options[ name ];
  4697. }
  4698. callback.call( elem );
  4699. // Revert the old values
  4700. for ( name in options ) {
  4701. elem.style[ name ] = old[ name ];
  4702. }
  4703. },
  4704. camelCase: function( string ) {
  4705. return string.replace( rdashAlpha, fcamelCase );
  4706. }
  4707. });
  4708. // DEPRECATED, Use jQuery.css() instead
  4709. jQuery.curCSS = jQuery.css;
  4710. jQuery.each(["height", "width"], function( i, name ) {
  4711. jQuery.cssHooks[ name ] = {
  4712. get: function( elem, computed, extra ) {
  4713. var val;
  4714. if ( computed ) {
  4715. if ( elem.offsetWidth !== 0 ) {
  4716. val = getWH( elem, name, extra );
  4717. } else {
  4718. jQuery.swap( elem, cssShow, function() {
  4719. val = getWH( elem, name, extra );
  4720. });
  4721. }
  4722. if ( val <= 0 ) {
  4723. val = curCSS( elem, name, name );
  4724. if ( val === "0px" && currentStyle ) {
  4725. val = currentStyle( elem, name, name );
  4726. }
  4727. if ( val != null ) {
  4728. // Should return "auto" instead of 0, use 0 for
  4729. // temporary backwards-compat
  4730. return val === "" || val === "auto" ? "0px" : val;
  4731. }
  4732. }
  4733. if ( val < 0 || val == null ) {
  4734. val = elem.style[ name ];
  4735. // Should return "auto" instead of 0, use 0 for
  4736. // temporary backwards-compat
  4737. return val === "" || val === "auto" ? "0px" : val;
  4738. }
  4739. return typeof val === "string" ? val : val + "px";
  4740. }
  4741. },
  4742. set: function( elem, value ) {
  4743. if ( rnumpx.test( value ) ) {
  4744. // ignore negative width and height values #1599
  4745. value = parseFloat(value);
  4746. if ( value >= 0 ) {
  4747. return value + "px";
  4748. }
  4749. } else {
  4750. return value;
  4751. }
  4752. }
  4753. };
  4754. });
  4755. if ( !jQuery.support.opacity ) {
  4756. jQuery.cssHooks.opacity = {
  4757. get: function( elem, computed ) {
  4758. // IE uses filters for opacity
  4759. return ropacity.test((computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "") ?
  4760. (parseFloat(RegExp.$1) / 100) + "" :
  4761. computed ? "1" : "";
  4762. },
  4763. set: function( elem, value ) {
  4764. var style = elem.style;
  4765. // IE has trouble with opacity if it does not have layout
  4766. // Force it by setting the zoom level
  4767. style.zoom = 1;
  4768. // Set the alpha filter to set the opacity
  4769. var opacity = jQuery.isNaN(value) ?
  4770. "" :
  4771. "alpha(opacity=" + value * 100 + ")",
  4772. filter = style.filter || "";
  4773. style.filter = ralpha.test(filter) ?
  4774. filter.replace(ralpha, opacity) :
  4775. style.filter + ' ' + opacity;
  4776. }
  4777. };
  4778. }
  4779. if ( document.defaultView && document.defaultView.getComputedStyle ) {
  4780. getComputedStyle = function( elem, newName, name ) {
  4781. var ret, defaultView, computedStyle;
  4782. name = name.replace( rupper, "-$1" ).toLowerCase();
  4783. if ( !(defaultView = elem.ownerDocument.defaultView) ) {
  4784. return undefined;
  4785. }
  4786. if ( (computedStyle = defaultView.getComputedStyle( elem, null )) ) {
  4787. ret = computedStyle.getPropertyValue( name );
  4788. if ( ret === "" && !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) {
  4789. ret = jQuery.style( elem, name );
  4790. }
  4791. }
  4792. return ret;
  4793. };
  4794. }
  4795. if ( document.documentElement.currentStyle ) {
  4796. currentStyle = function( elem, name ) {
  4797. var left,
  4798. ret = elem.currentStyle && elem.currentStyle[ name ],
  4799. rsLeft = elem.runtimeStyle && elem.runtimeStyle[ name ],
  4800. style = elem.style;
  4801. // From the awesome hack by Dean Edwards
  4802. // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
  4803. // If we're not dealing with a regular pixel number
  4804. // but a number that has a weird ending, we need to convert it to pixels
  4805. if ( !rnumpx.test( ret ) && rnum.test( ret ) ) {
  4806. // Remember the original values
  4807. left = style.left;
  4808. // Put in the new values to get a computed value out
  4809. if ( rsLeft ) {
  4810. elem.runtimeStyle.left = elem.currentStyle.left;
  4811. }
  4812. style.left = name === "fontSize" ? "1em" : (ret || 0);
  4813. ret = style.pixelLeft + "px";
  4814. // Revert the changed values
  4815. style.left = left;
  4816. if ( rsLeft ) {
  4817. elem.runtimeStyle.left = rsLeft;
  4818. }
  4819. }
  4820. return ret === "" ? "auto" : ret;
  4821. };
  4822. }
  4823. curCSS = getComputedStyle || currentStyle;
  4824. function getWH( elem, name, extra ) {
  4825. var which = name === "width" ? cssWidth : cssHeight,
  4826. val = name === "width" ? elem.offsetWidth : elem.offsetHeight;
  4827. if ( extra === "border" ) {
  4828. return val;
  4829. }
  4830. jQuery.each( which, function() {
  4831. if ( !extra ) {
  4832. val -= parseFloat(jQuery.css( elem, "padding" + this )) || 0;
  4833. }
  4834. if ( extra === "margin" ) {
  4835. val += parseFloat(jQuery.css( elem, "margin" + this )) || 0;
  4836. } else {
  4837. val -= parseFloat(jQuery.css( elem, "border" + this + "Width" )) || 0;
  4838. }
  4839. });
  4840. return val;
  4841. }
  4842. if ( jQuery.expr && jQuery.expr.filters ) {
  4843. jQuery.expr.filters.hidden = function( elem ) {
  4844. var width = elem.offsetWidth,
  4845. height = elem.offsetHeight;
  4846. return (width === 0 && height === 0) || (!jQuery.support.reliableHiddenOffsets && (elem.style.display || jQuery.css( elem, "display" )) === "none");
  4847. };
  4848. jQuery.expr.filters.visible = function( elem ) {
  4849. return !jQuery.expr.filters.hidden( elem );
  4850. };
  4851. }
  4852. var r20 = /%20/g,
  4853. rbracket = /\[\]$/,
  4854. rCRLF = /\r?\n/g,
  4855. rhash = /#.*$/,
  4856. rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
  4857. rinput = /^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
  4858. // #7653, #8125, #8152: local protocol detection
  4859. rlocalProtocol = /(?:^file|^widget|\-extension):$/,
  4860. rnoContent = /^(?:GET|HEAD)$/,
  4861. rprotocol = /^\/\//,
  4862. rquery = /\?/,
  4863. rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
  4864. rselectTextarea = /^(?:select|textarea)/i,
  4865. rspacesAjax = /\s+/,
  4866. rts = /([?&])_=[^&]*/,
  4867. rucHeaders = /(^|\-)([a-z])/g,
  4868. rucHeadersFunc = function( _, $1, $2 ) {
  4869. return $1 + $2.toUpperCase();
  4870. },
  4871. rurl = /^([\w\+\.\-]+:)\/\/([^\/?#:]*)(?::(\d+))?/,
  4872. // Keep a copy of the old load method
  4873. _load = jQuery.fn.load,
  4874. /* Prefilters
  4875. * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
  4876. * 2) These are called:
  4877. * - BEFORE asking for a transport
  4878. * - AFTER param serialization (s.data is a string if s.processData is true)
  4879. * 3) key is the dataType
  4880. * 4) the catchall symbol "*" can be used
  4881. * 5) execution will start with transport dataType and THEN continue down to "*" if needed
  4882. */
  4883. prefilters = {},
  4884. /* Transports bindings
  4885. * 1) key is the dataType
  4886. * 2) the catchall symbol "*" can be used
  4887. * 3) selection will start with transport dataType and THEN go to "*" if needed
  4888. */
  4889. transports = {},
  4890. // Document location
  4891. ajaxLocation,
  4892. // Document location segments
  4893. ajaxLocParts;
  4894. // #8138, IE may throw an exception when accessing
  4895. // a field from document.location if document.domain has been set
  4896. try {
  4897. ajaxLocation = document.location.href;
  4898. } catch( e ) {
  4899. // Use the href attribute of an A element
  4900. // since IE will modify it given document.location
  4901. ajaxLocation = document.createElement( "a" );
  4902. ajaxLocation.href = "";
  4903. ajaxLocation = ajaxLocation.href;
  4904. }
  4905. // Segment location into parts
  4906. ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() );
  4907. // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
  4908. function addToPrefiltersOrTransports( structure ) {
  4909. // dataTypeExpression is optional and defaults to "*"
  4910. return function( dataTypeExpression, func ) {
  4911. if ( typeof dataTypeExpression !== "string" ) {
  4912. func = dataTypeExpression;
  4913. dataTypeExpression = "*";
  4914. }
  4915. if ( jQuery.isFunction( func ) ) {
  4916. var dataTypes = dataTypeExpression.toLowerCase().split( rspacesAjax ),
  4917. i = 0,
  4918. length = dataTypes.length,
  4919. dataType,
  4920. list,
  4921. placeBefore;
  4922. // For each dataType in the dataTypeExpression
  4923. for(; i < length; i++ ) {
  4924. dataType = dataTypes[ i ];
  4925. // We control if we're asked to add before
  4926. // any existing element
  4927. placeBefore = /^\+/.test( dataType );
  4928. if ( placeBefore ) {
  4929. dataType = dataType.substr( 1 ) || "*";
  4930. }
  4931. list = structure[ dataType ] = structure[ dataType ] || [];
  4932. // then we add to the structure accordingly
  4933. list[ placeBefore ? "unshift" : "push" ]( func );
  4934. }
  4935. }
  4936. };
  4937. }
  4938. //Base inspection function for prefilters and transports
  4939. function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR,
  4940. dataType /* internal */, inspected /* internal */ ) {
  4941. dataType = dataType || options.dataTypes[ 0 ];
  4942. inspected = inspected || {};
  4943. inspected[ dataType ] = true;
  4944. var list = structure[ dataType ],
  4945. i = 0,
  4946. length = list ? list.length : 0,
  4947. executeOnly = ( structure === prefilters ),
  4948. selection;
  4949. for(; i < length && ( executeOnly || !selection ); i++ ) {
  4950. selection = list[ i ]( options, originalOptions, jqXHR );
  4951. // If we got redirected to another dataType
  4952. // we try there if executing only and not done already
  4953. if ( typeof selection === "string" ) {
  4954. if ( !executeOnly || inspected[ selection ] ) {
  4955. selection = undefined;
  4956. } else {
  4957. options.dataTypes.unshift( selection );
  4958. selection = inspectPrefiltersOrTransports(
  4959. structure, options, originalOptions, jqXHR, selection, inspected );
  4960. }
  4961. }
  4962. }
  4963. // If we're only executing or nothing was selected
  4964. // we try the catchall dataType if not done already
  4965. if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) {
  4966. selection = inspectPrefiltersOrTransports(
  4967. structure, options, originalOptions, jqXHR, "*", inspected );
  4968. }
  4969. // unnecessary when only executing (prefilters)
  4970. // but it'll be ignored by the caller in that case
  4971. return selection;
  4972. }
  4973. jQuery.fn.extend({
  4974. load: function( url, params, callback ) {
  4975. if ( typeof url !== "string" && _load ) {
  4976. return _load.apply( this, arguments );
  4977. // Don't do a request if no elements are being requested
  4978. } else if ( !this.length ) {
  4979. return this;
  4980. }
  4981. var off = url.indexOf( " " );
  4982. if ( off >= 0 ) {
  4983. var selector = url.slice( off, url.length );
  4984. url = url.slice( 0, off );
  4985. }
  4986. // Default to a GET request
  4987. var type = "GET";
  4988. // If the second parameter was provided
  4989. if ( params ) {
  4990. // If it's a function
  4991. if ( jQuery.isFunction( params ) ) {
  4992. // We assume that it's the callback
  4993. callback = params;
  4994. params = undefined;
  4995. // Otherwise, build a param string
  4996. } else if ( typeof params === "object" ) {
  4997. params = jQuery.param( params, jQuery.ajaxSettings.traditional );
  4998. type = "POST";
  4999. }
  5000. }
  5001. var self = this;
  5002. // Request the remote document
  5003. jQuery.ajax({
  5004. url: url,
  5005. type: type,
  5006. dataType: "html",
  5007. data: params,
  5008. // Complete callback (responseText is used internally)
  5009. complete: function( jqXHR, status, responseText ) {
  5010. // Store the response as specified by the jqXHR object
  5011. responseText = jqXHR.responseText;
  5012. // If successful, inject the HTML into all the matched elements
  5013. if ( jqXHR.isResolved() ) {
  5014. // #4825: Get the actual response in case
  5015. // a dataFilter is present in ajaxSettings
  5016. jqXHR.done(function( r ) {
  5017. responseText = r;
  5018. });
  5019. // See if a selector was specified
  5020. self.html( selector ?
  5021. // Create a dummy div to hold the results
  5022. jQuery("<div>")
  5023. // inject the contents of the document in, removing the scripts
  5024. // to avoid any 'Permission Denied' errors in IE
  5025. .append(responseText.replace(rscript, ""))
  5026. // Locate the specified elements
  5027. .find(selector) :
  5028. // If not, just inject the full result
  5029. responseText );
  5030. }
  5031. if ( callback ) {
  5032. self.each( callback, [ responseText, status, jqXHR ] );
  5033. }
  5034. }
  5035. });
  5036. return this;
  5037. },
  5038. serialize: function() {
  5039. return jQuery.param( this.serializeArray() );
  5040. },
  5041. serializeArray: function() {
  5042. return this.map(function(){
  5043. return this.elements ? jQuery.makeArray( this.elements ) : this;
  5044. })
  5045. .filter(function(){
  5046. return this.name && !this.disabled &&
  5047. ( this.checked || rselectTextarea.test( this.nodeName ) ||
  5048. rinput.test( this.type ) );
  5049. })
  5050. .map(function( i, elem ){
  5051. var val = jQuery( this ).val();
  5052. return val == null ?
  5053. null :
  5054. jQuery.isArray( val ) ?
  5055. jQuery.map( val, function( val, i ){
  5056. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  5057. }) :
  5058. { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  5059. }).get();
  5060. }
  5061. });
  5062. // Attach a bunch of functions for handling common AJAX events
  5063. jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i, o ){
  5064. jQuery.fn[ o ] = function( f ){
  5065. return this.bind( o, f );
  5066. };
  5067. } );
  5068. jQuery.each( [ "get", "post" ], function( i, method ) {
  5069. jQuery[ method ] = function( url, data, callback, type ) {
  5070. // shift arguments if data argument was omitted
  5071. if ( jQuery.isFunction( data ) ) {
  5072. type = type || callback;
  5073. callback = data;
  5074. data = undefined;
  5075. }
  5076. return jQuery.ajax({
  5077. type: method,
  5078. url: url,
  5079. data: data,
  5080. success: callback,
  5081. dataType: type
  5082. });
  5083. };
  5084. } );
  5085. jQuery.extend({
  5086. getScript: function( url, callback ) {
  5087. return jQuery.get( url, undefined, callback, "script" );
  5088. },
  5089. getJSON: function( url, data, callback ) {
  5090. return jQuery.get( url, data, callback, "json" );
  5091. },
  5092. // Creates a full fledged settings object into target
  5093. // with both ajaxSettings and settings fields.
  5094. // If target is omitted, writes into ajaxSettings.
  5095. ajaxSetup: function ( target, settings ) {
  5096. if ( !settings ) {
  5097. // Only one parameter, we extend ajaxSettings
  5098. settings = target;
  5099. target = jQuery.extend( true, jQuery.ajaxSettings, settings );
  5100. } else {