PageRenderTime 96ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 1ms

/BlogEngine/BlogEngine.NET/Scripts/jQuery/jquery-1.5.2.js

#
JavaScript | 8374 lines | 5817 code | 1520 blank | 1037 comment | 1685 complexity | 45b0758e69da8012e629070d62b6fa7d MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0, BSD-3-Clause
  1. /*!
  2. * jQuery JavaScript Library v1.5.2
  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: Thu Mar 31 15:28:23 2011 -0400
  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. // The deferred used on DOM ready
  58. readyList,
  59. // The ready event handler
  60. DOMContentLoaded,
  61. // Save a reference to some core methods
  62. toString = Object.prototype.toString,
  63. hasOwn = Object.prototype.hasOwnProperty,
  64. push = Array.prototype.push,
  65. slice = Array.prototype.slice,
  66. trim = String.prototype.trim,
  67. indexOf = Array.prototype.indexOf,
  68. // [[Class]] -> type pairs
  69. class2type = {};
  70. jQuery.fn = jQuery.prototype = {
  71. constructor: jQuery,
  72. init: function( selector, context, rootjQuery ) {
  73. var match, elem, ret, doc;
  74. // Handle $(""), $(null), or $(undefined)
  75. if ( !selector ) {
  76. return this;
  77. }
  78. // Handle $(DOMElement)
  79. if ( selector.nodeType ) {
  80. this.context = this[0] = selector;
  81. this.length = 1;
  82. return this;
  83. }
  84. // The body element only exists once, optimize finding it
  85. if ( selector === "body" && !context && document.body ) {
  86. this.context = document;
  87. this[0] = document.body;
  88. this.selector = "body";
  89. this.length = 1;
  90. return this;
  91. }
  92. // Handle HTML strings
  93. if ( typeof selector === "string" ) {
  94. // Are we dealing with HTML string or an ID?
  95. match = quickExpr.exec( selector );
  96. // Verify a match, and that no context was specified for #id
  97. if ( match && (match[1] || !context) ) {
  98. // HANDLE: $(html) -> $(array)
  99. if ( match[1] ) {
  100. context = context instanceof jQuery ? context[0] : context;
  101. doc = (context ? context.ownerDocument || context : document);
  102. // If a single string is passed in and it's a single tag
  103. // just do a createElement and skip the rest
  104. ret = rsingleTag.exec( selector );
  105. if ( ret ) {
  106. if ( jQuery.isPlainObject( context ) ) {
  107. selector = [ document.createElement( ret[1] ) ];
  108. jQuery.fn.attr.call( selector, context, true );
  109. } else {
  110. selector = [ doc.createElement( ret[1] ) ];
  111. }
  112. } else {
  113. ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
  114. selector = (ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment).childNodes;
  115. }
  116. return jQuery.merge( this, selector );
  117. // HANDLE: $("#id")
  118. } else {
  119. elem = document.getElementById( match[2] );
  120. // Check parentNode to catch when Blackberry 4.6 returns
  121. // nodes that are no longer in the document #6963
  122. if ( elem && elem.parentNode ) {
  123. // Handle the case where IE and Opera return items
  124. // by name instead of ID
  125. if ( elem.id !== match[2] ) {
  126. return rootjQuery.find( selector );
  127. }
  128. // Otherwise, we inject the element directly into the jQuery object
  129. this.length = 1;
  130. this[0] = elem;
  131. }
  132. this.context = document;
  133. this.selector = selector;
  134. return this;
  135. }
  136. // HANDLE: $(expr, $(...))
  137. } else if ( !context || context.jquery ) {
  138. return (context || rootjQuery).find( selector );
  139. // HANDLE: $(expr, context)
  140. // (which is just equivalent to: $(context).find(expr)
  141. } else {
  142. return this.constructor( context ).find( selector );
  143. }
  144. // HANDLE: $(function)
  145. // Shortcut for document ready
  146. } else if ( jQuery.isFunction( selector ) ) {
  147. return rootjQuery.ready( selector );
  148. }
  149. if (selector.selector !== undefined) {
  150. this.selector = selector.selector;
  151. this.context = selector.context;
  152. }
  153. return jQuery.makeArray( selector, this );
  154. },
  155. // Start with an empty selector
  156. selector: "",
  157. // The current version of jQuery being used
  158. jquery: "1.5.2",
  159. // The default length of a jQuery object is 0
  160. length: 0,
  161. // The number of elements contained in the matched element set
  162. size: function() {
  163. return this.length;
  164. },
  165. toArray: function() {
  166. return slice.call( this, 0 );
  167. },
  168. // Get the Nth element in the matched element set OR
  169. // Get the whole matched element set as a clean array
  170. get: function( num ) {
  171. return num == null ?
  172. // Return a 'clean' array
  173. this.toArray() :
  174. // Return just the object
  175. ( num < 0 ? this[ this.length + num ] : this[ num ] );
  176. },
  177. // Take an array of elements and push it onto the stack
  178. // (returning the new matched element set)
  179. pushStack: function( elems, name, selector ) {
  180. // Build a new jQuery matched element set
  181. var ret = this.constructor();
  182. if ( jQuery.isArray( elems ) ) {
  183. push.apply( ret, elems );
  184. } else {
  185. jQuery.merge( ret, elems );
  186. }
  187. // Add the old object onto the stack (as a reference)
  188. ret.prevObject = this;
  189. ret.context = this.context;
  190. if ( name === "find" ) {
  191. ret.selector = this.selector + (this.selector ? " " : "") + selector;
  192. } else if ( name ) {
  193. ret.selector = this.selector + "." + name + "(" + selector + ")";
  194. }
  195. // Return the newly-formed element set
  196. return ret;
  197. },
  198. // Execute a callback for every element in the matched set.
  199. // (You can seed the arguments with an array of args, but this is
  200. // only used internally.)
  201. each: function( callback, args ) {
  202. return jQuery.each( this, callback, args );
  203. },
  204. ready: function( fn ) {
  205. // Attach the listeners
  206. jQuery.bindReady();
  207. // Add the callback
  208. readyList.done( fn );
  209. return this;
  210. },
  211. eq: function( i ) {
  212. return i === -1 ?
  213. this.slice( i ) :
  214. this.slice( i, +i + 1 );
  215. },
  216. first: function() {
  217. return this.eq( 0 );
  218. },
  219. last: function() {
  220. return this.eq( -1 );
  221. },
  222. slice: function() {
  223. return this.pushStack( slice.apply( this, arguments ),
  224. "slice", slice.call(arguments).join(",") );
  225. },
  226. map: function( callback ) {
  227. return this.pushStack( jQuery.map(this, function( elem, i ) {
  228. return callback.call( elem, i, elem );
  229. }));
  230. },
  231. end: function() {
  232. return this.prevObject || this.constructor(null);
  233. },
  234. // For internal use only.
  235. // Behaves like an Array's method, not like a jQuery method.
  236. push: push,
  237. sort: [].sort,
  238. splice: [].splice
  239. };
  240. // Give the init function the jQuery prototype for later instantiation
  241. jQuery.fn.init.prototype = jQuery.fn;
  242. jQuery.extend = jQuery.fn.extend = function() {
  243. var options, name, src, copy, copyIsArray, clone,
  244. target = arguments[0] || {},
  245. i = 1,
  246. length = arguments.length,
  247. deep = false;
  248. // Handle a deep copy situation
  249. if ( typeof target === "boolean" ) {
  250. deep = target;
  251. target = arguments[1] || {};
  252. // skip the boolean and the target
  253. i = 2;
  254. }
  255. // Handle case when target is a string or something (possible in deep copy)
  256. if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
  257. target = {};
  258. }
  259. // extend jQuery itself if only one argument is passed
  260. if ( length === i ) {
  261. target = this;
  262. --i;
  263. }
  264. for ( ; i < length; i++ ) {
  265. // Only deal with non-null/undefined values
  266. if ( (options = arguments[ i ]) != null ) {
  267. // Extend the base object
  268. for ( name in options ) {
  269. src = target[ name ];
  270. copy = options[ name ];
  271. // Prevent never-ending loop
  272. if ( target === copy ) {
  273. continue;
  274. }
  275. // Recurse if we're merging plain objects or arrays
  276. if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
  277. if ( copyIsArray ) {
  278. copyIsArray = false;
  279. clone = src && jQuery.isArray(src) ? src : [];
  280. } else {
  281. clone = src && jQuery.isPlainObject(src) ? src : {};
  282. }
  283. // Never move original objects, clone them
  284. target[ name ] = jQuery.extend( deep, clone, copy );
  285. // Don't bring in undefined values
  286. } else if ( copy !== undefined ) {
  287. target[ name ] = copy;
  288. }
  289. }
  290. }
  291. }
  292. // Return the modified object
  293. return target;
  294. };
  295. jQuery.extend({
  296. noConflict: function( deep ) {
  297. window.$ = _$;
  298. if ( deep ) {
  299. window.jQuery = _jQuery;
  300. }
  301. return jQuery;
  302. },
  303. // Is the DOM ready to be used? Set to true once it occurs.
  304. isReady: false,
  305. // A counter to track how many items to wait for before
  306. // the ready event fires. See #6781
  307. readyWait: 1,
  308. // Handle when the DOM is ready
  309. ready: function( wait ) {
  310. // A third-party is pushing the ready event forwards
  311. if ( wait === true ) {
  312. jQuery.readyWait--;
  313. }
  314. // Make sure that the DOM is not already loaded
  315. if ( !jQuery.readyWait || (wait !== true && !jQuery.isReady) ) {
  316. // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
  317. if ( !document.body ) {
  318. return setTimeout( jQuery.ready, 1 );
  319. }
  320. // Remember that the DOM is ready
  321. jQuery.isReady = true;
  322. // If a normal DOM Ready event fired, decrement, and wait if need be
  323. if ( wait !== true && --jQuery.readyWait > 0 ) {
  324. return;
  325. }
  326. // If there are functions bound, to execute
  327. readyList.resolveWith( document, [ jQuery ] );
  328. // Trigger any bound ready events
  329. if ( jQuery.fn.trigger ) {
  330. jQuery( document ).trigger( "ready" ).unbind( "ready" );
  331. }
  332. }
  333. },
  334. bindReady: function() {
  335. if ( readyList ) {
  336. return;
  337. }
  338. readyList = jQuery._Deferred();
  339. // Catch cases where $(document).ready() is called after the
  340. // browser event has already occurred.
  341. if ( document.readyState === "complete" ) {
  342. // Handle it asynchronously to allow scripts the opportunity to delay ready
  343. return setTimeout( jQuery.ready, 1 );
  344. }
  345. // Mozilla, Opera and webkit nightlies currently support this event
  346. if ( document.addEventListener ) {
  347. // Use the handy event callback
  348. document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
  349. // A fallback to window.onload, that will always work
  350. window.addEventListener( "load", jQuery.ready, false );
  351. // If IE event model is used
  352. } else if ( document.attachEvent ) {
  353. // ensure firing before onload,
  354. // maybe late but safe also for iframes
  355. document.attachEvent("onreadystatechange", DOMContentLoaded);
  356. // A fallback to window.onload, that will always work
  357. window.attachEvent( "onload", jQuery.ready );
  358. // If IE and not a frame
  359. // continually check to see if the document is ready
  360. var toplevel = false;
  361. try {
  362. toplevel = window.frameElement == null;
  363. } catch(e) {}
  364. if ( document.documentElement.doScroll && toplevel ) {
  365. doScrollCheck();
  366. }
  367. }
  368. },
  369. // See test/unit/core.js for details concerning isFunction.
  370. // Since version 1.3, DOM methods and functions like alert
  371. // aren't supported. They return false on IE (#2968).
  372. isFunction: function( obj ) {
  373. return jQuery.type(obj) === "function";
  374. },
  375. isArray: Array.isArray || function( obj ) {
  376. return jQuery.type(obj) === "array";
  377. },
  378. // A crude way of determining if an object is a window
  379. isWindow: function( obj ) {
  380. return obj && typeof obj === "object" && "setInterval" in obj;
  381. },
  382. isNaN: function( obj ) {
  383. return obj == null || !rdigit.test( obj ) || isNaN( obj );
  384. },
  385. type: function( obj ) {
  386. return obj == null ?
  387. String( obj ) :
  388. class2type[ toString.call(obj) ] || "object";
  389. },
  390. isPlainObject: function( obj ) {
  391. // Must be an Object.
  392. // Because of IE, we also have to check the presence of the constructor property.
  393. // Make sure that DOM nodes and window objects don't pass through, as well
  394. if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
  395. return false;
  396. }
  397. // Not own constructor property must be Object
  398. if ( obj.constructor &&
  399. !hasOwn.call(obj, "constructor") &&
  400. !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
  401. return false;
  402. }
  403. // Own properties are enumerated firstly, so to speed up,
  404. // if last one is own, then all properties are own.
  405. var key;
  406. for ( key in obj ) {}
  407. return key === undefined || hasOwn.call( obj, key );
  408. },
  409. isEmptyObject: function( obj ) {
  410. for ( var name in obj ) {
  411. return false;
  412. }
  413. return true;
  414. },
  415. error: function( msg ) {
  416. throw msg;
  417. },
  418. parseJSON: function( data ) {
  419. if ( typeof data !== "string" || !data ) {
  420. return null;
  421. }
  422. // Make sure leading/trailing whitespace is removed (IE can't handle it)
  423. data = jQuery.trim( data );
  424. // Make sure the incoming data is actual JSON
  425. // Logic borrowed from http://json.org/json2.js
  426. if ( rvalidchars.test(data.replace(rvalidescape, "@")
  427. .replace(rvalidtokens, "]")
  428. .replace(rvalidbraces, "")) ) {
  429. // Try to use the native JSON parser first
  430. return window.JSON && window.JSON.parse ?
  431. window.JSON.parse( data ) :
  432. (new Function("return " + data))();
  433. } else {
  434. jQuery.error( "Invalid JSON: " + data );
  435. }
  436. },
  437. // Cross-browser xml parsing
  438. // (xml & tmp used internally)
  439. parseXML: function( data , xml , tmp ) {
  440. if ( window.DOMParser ) { // Standard
  441. tmp = new DOMParser();
  442. xml = tmp.parseFromString( data , "text/xml" );
  443. } else { // IE
  444. xml = new ActiveXObject( "Microsoft.XMLDOM" );
  445. xml.async = "false";
  446. xml.loadXML( data );
  447. }
  448. tmp = xml.documentElement;
  449. if ( ! tmp || ! tmp.nodeName || tmp.nodeName === "parsererror" ) {
  450. jQuery.error( "Invalid XML: " + data );
  451. }
  452. return xml;
  453. },
  454. noop: function() {},
  455. // Evalulates a script in a global context
  456. globalEval: function( data ) {
  457. if ( data && rnotwhite.test(data) ) {
  458. // Inspired by code by Andrea Giammarchi
  459. // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
  460. var head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement,
  461. script = document.createElement( "script" );
  462. if ( jQuery.support.scriptEval() ) {
  463. script.appendChild( document.createTextNode( data ) );
  464. } else {
  465. script.text = data;
  466. }
  467. // Use insertBefore instead of appendChild to circumvent an IE6 bug.
  468. // This arises when a base node is used (#2709).
  469. head.insertBefore( script, head.firstChild );
  470. head.removeChild( script );
  471. }
  472. },
  473. nodeName: function( elem, name ) {
  474. return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
  475. },
  476. // args is for internal usage only
  477. each: function( object, callback, args ) {
  478. var name, i = 0,
  479. length = object.length,
  480. isObj = length === undefined || jQuery.isFunction(object);
  481. if ( args ) {
  482. if ( isObj ) {
  483. for ( name in object ) {
  484. if ( callback.apply( object[ name ], args ) === false ) {
  485. break;
  486. }
  487. }
  488. } else {
  489. for ( ; i < length; ) {
  490. if ( callback.apply( object[ i++ ], args ) === false ) {
  491. break;
  492. }
  493. }
  494. }
  495. // A special, fast, case for the most common use of each
  496. } else {
  497. if ( isObj ) {
  498. for ( name in object ) {
  499. if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
  500. break;
  501. }
  502. }
  503. } else {
  504. for ( var value = object[0];
  505. i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {}
  506. }
  507. }
  508. return object;
  509. },
  510. // Use native String.trim function wherever possible
  511. trim: trim ?
  512. function( text ) {
  513. return text == null ?
  514. "" :
  515. trim.call( text );
  516. } :
  517. // Otherwise use our own trimming functionality
  518. function( text ) {
  519. return text == null ?
  520. "" :
  521. text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
  522. },
  523. // results is for internal usage only
  524. makeArray: function( array, results ) {
  525. var ret = results || [];
  526. if ( array != null ) {
  527. // The window, strings (and functions) also have 'length'
  528. // The extra typeof function check is to prevent crashes
  529. // in Safari 2 (See: #3039)
  530. // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
  531. var type = jQuery.type(array);
  532. if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
  533. push.call( ret, array );
  534. } else {
  535. jQuery.merge( ret, array );
  536. }
  537. }
  538. return ret;
  539. },
  540. inArray: function( elem, array ) {
  541. if ( array.indexOf ) {
  542. return array.indexOf( elem );
  543. }
  544. for ( var i = 0, length = array.length; i < length; i++ ) {
  545. if ( array[ i ] === elem ) {
  546. return i;
  547. }
  548. }
  549. return -1;
  550. },
  551. merge: function( first, second ) {
  552. var i = first.length,
  553. j = 0;
  554. if ( typeof second.length === "number" ) {
  555. for ( var l = second.length; j < l; j++ ) {
  556. first[ i++ ] = second[ j ];
  557. }
  558. } else {
  559. while ( second[j] !== undefined ) {
  560. first[ i++ ] = second[ j++ ];
  561. }
  562. }
  563. first.length = i;
  564. return first;
  565. },
  566. grep: function( elems, callback, inv ) {
  567. var ret = [], retVal;
  568. inv = !!inv;
  569. // Go through the array, only saving the items
  570. // that pass the validator function
  571. for ( var i = 0, length = elems.length; i < length; i++ ) {
  572. retVal = !!callback( elems[ i ], i );
  573. if ( inv !== retVal ) {
  574. ret.push( elems[ i ] );
  575. }
  576. }
  577. return ret;
  578. },
  579. // arg is for internal usage only
  580. map: function( elems, callback, arg ) {
  581. var ret = [], value;
  582. // Go through the array, translating each of the items to their
  583. // new value (or values).
  584. for ( var i = 0, length = elems.length; i < length; i++ ) {
  585. value = callback( elems[ i ], i, arg );
  586. if ( value != null ) {
  587. ret[ ret.length ] = value;
  588. }
  589. }
  590. // Flatten any nested arrays
  591. return ret.concat.apply( [], ret );
  592. },
  593. // A global GUID counter for objects
  594. guid: 1,
  595. proxy: function( fn, proxy, thisObject ) {
  596. if ( arguments.length === 2 ) {
  597. if ( typeof proxy === "string" ) {
  598. thisObject = fn;
  599. fn = thisObject[ proxy ];
  600. proxy = undefined;
  601. } else if ( proxy && !jQuery.isFunction( proxy ) ) {
  602. thisObject = proxy;
  603. proxy = undefined;
  604. }
  605. }
  606. if ( !proxy && fn ) {
  607. proxy = function() {
  608. return fn.apply( thisObject || this, arguments );
  609. };
  610. }
  611. // Set the guid of unique handler to the same of original handler, so it can be removed
  612. if ( fn ) {
  613. proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
  614. }
  615. // So proxy can be declared as an argument
  616. return proxy;
  617. },
  618. // Mutifunctional method to get and set values to a collection
  619. // The value/s can be optionally by executed if its a function
  620. access: function( elems, key, value, exec, fn, pass ) {
  621. var length = elems.length;
  622. // Setting many attributes
  623. if ( typeof key === "object" ) {
  624. for ( var k in key ) {
  625. jQuery.access( elems, k, key[k], exec, fn, value );
  626. }
  627. return elems;
  628. }
  629. // Setting one attribute
  630. if ( value !== undefined ) {
  631. // Optionally, function values get executed if exec is true
  632. exec = !pass && exec && jQuery.isFunction(value);
  633. for ( var i = 0; i < length; i++ ) {
  634. fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
  635. }
  636. return elems;
  637. }
  638. // Getting an attribute
  639. return length ? fn( elems[0], key ) : undefined;
  640. },
  641. now: function() {
  642. return (new Date()).getTime();
  643. },
  644. // Use of jQuery.browser is frowned upon.
  645. // More details: http://docs.jquery.com/Utilities/jQuery.browser
  646. uaMatch: function( ua ) {
  647. ua = ua.toLowerCase();
  648. var match = rwebkit.exec( ua ) ||
  649. ropera.exec( ua ) ||
  650. rmsie.exec( ua ) ||
  651. ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
  652. [];
  653. return { browser: match[1] || "", version: match[2] || "0" };
  654. },
  655. sub: function() {
  656. function jQuerySubclass( selector, context ) {
  657. return new jQuerySubclass.fn.init( selector, context );
  658. }
  659. jQuery.extend( true, jQuerySubclass, this );
  660. jQuerySubclass.superclass = this;
  661. jQuerySubclass.fn = jQuerySubclass.prototype = this();
  662. jQuerySubclass.fn.constructor = jQuerySubclass;
  663. jQuerySubclass.subclass = this.subclass;
  664. jQuerySubclass.fn.init = function init( selector, context ) {
  665. if ( context && context instanceof jQuery && !(context instanceof jQuerySubclass) ) {
  666. context = jQuerySubclass(context);
  667. }
  668. return jQuery.fn.init.call( this, selector, context, rootjQuerySubclass );
  669. };
  670. jQuerySubclass.fn.init.prototype = jQuerySubclass.fn;
  671. var rootjQuerySubclass = jQuerySubclass(document);
  672. return jQuerySubclass;
  673. },
  674. browser: {}
  675. });
  676. // Populate the class2type map
  677. jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
  678. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  679. });
  680. browserMatch = jQuery.uaMatch( userAgent );
  681. if ( browserMatch.browser ) {
  682. jQuery.browser[ browserMatch.browser ] = true;
  683. jQuery.browser.version = browserMatch.version;
  684. }
  685. // Deprecated, use jQuery.browser.webkit instead
  686. if ( jQuery.browser.webkit ) {
  687. jQuery.browser.safari = true;
  688. }
  689. if ( indexOf ) {
  690. jQuery.inArray = function( elem, array ) {
  691. return indexOf.call( array, elem );
  692. };
  693. }
  694. // IE doesn't match non-breaking spaces with \s
  695. if ( rnotwhite.test( "\xA0" ) ) {
  696. trimLeft = /^[\s\xA0]+/;
  697. trimRight = /[\s\xA0]+$/;
  698. }
  699. // All jQuery objects should point back to these
  700. rootjQuery = jQuery(document);
  701. // Cleanup functions for the document ready method
  702. if ( document.addEventListener ) {
  703. DOMContentLoaded = function() {
  704. document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
  705. jQuery.ready();
  706. };
  707. } else if ( document.attachEvent ) {
  708. DOMContentLoaded = function() {
  709. // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
  710. if ( document.readyState === "complete" ) {
  711. document.detachEvent( "onreadystatechange", DOMContentLoaded );
  712. jQuery.ready();
  713. }
  714. };
  715. }
  716. // The DOM ready check for Internet Explorer
  717. function doScrollCheck() {
  718. if ( jQuery.isReady ) {
  719. return;
  720. }
  721. try {
  722. // If IE is used, use the trick by Diego Perini
  723. // http://javascript.nwbox.com/IEContentLoaded/
  724. document.documentElement.doScroll("left");
  725. } catch(e) {
  726. setTimeout( doScrollCheck, 1 );
  727. return;
  728. }
  729. // and execute any waiting functions
  730. jQuery.ready();
  731. }
  732. // Expose jQuery to the global object
  733. return jQuery;
  734. })();
  735. var // Promise methods
  736. promiseMethods = "then done fail isResolved isRejected promise".split( " " ),
  737. // Static reference to slice
  738. sliceDeferred = [].slice;
  739. jQuery.extend({
  740. // Create a simple deferred (one callbacks list)
  741. _Deferred: function() {
  742. var // callbacks list
  743. callbacks = [],
  744. // stored [ context , args ]
  745. fired,
  746. // to avoid firing when already doing so
  747. firing,
  748. // flag to know if the deferred has been cancelled
  749. cancelled,
  750. // the deferred itself
  751. deferred = {
  752. // done( f1, f2, ...)
  753. done: function() {
  754. if ( !cancelled ) {
  755. var args = arguments,
  756. i,
  757. length,
  758. elem,
  759. type,
  760. _fired;
  761. if ( fired ) {
  762. _fired = fired;
  763. fired = 0;
  764. }
  765. for ( i = 0, length = args.length; i < length; i++ ) {
  766. elem = args[ i ];
  767. type = jQuery.type( elem );
  768. if ( type === "array" ) {
  769. deferred.done.apply( deferred, elem );
  770. } else if ( type === "function" ) {
  771. callbacks.push( elem );
  772. }
  773. }
  774. if ( _fired ) {
  775. deferred.resolveWith( _fired[ 0 ], _fired[ 1 ] );
  776. }
  777. }
  778. return this;
  779. },
  780. // resolve with given context and args
  781. resolveWith: function( context, args ) {
  782. if ( !cancelled && !fired && !firing ) {
  783. // make sure args are available (#8421)
  784. args = args || [];
  785. firing = 1;
  786. try {
  787. while( callbacks[ 0 ] ) {
  788. callbacks.shift().apply( context, args );
  789. }
  790. }
  791. finally {
  792. fired = [ context, args ];
  793. firing = 0;
  794. }
  795. }
  796. return this;
  797. },
  798. // resolve with this as context and given arguments
  799. resolve: function() {
  800. deferred.resolveWith( this, arguments );
  801. return this;
  802. },
  803. // Has this deferred been resolved?
  804. isResolved: function() {
  805. return !!( firing || fired );
  806. },
  807. // Cancel
  808. cancel: function() {
  809. cancelled = 1;
  810. callbacks = [];
  811. return this;
  812. }
  813. };
  814. return deferred;
  815. },
  816. // Full fledged deferred (two callbacks list)
  817. Deferred: function( func ) {
  818. var deferred = jQuery._Deferred(),
  819. failDeferred = jQuery._Deferred(),
  820. promise;
  821. // Add errorDeferred methods, then and promise
  822. jQuery.extend( deferred, {
  823. then: function( doneCallbacks, failCallbacks ) {
  824. deferred.done( doneCallbacks ).fail( failCallbacks );
  825. return this;
  826. },
  827. fail: failDeferred.done,
  828. rejectWith: failDeferred.resolveWith,
  829. reject: failDeferred.resolve,
  830. isRejected: failDeferred.isResolved,
  831. // Get a promise for this deferred
  832. // If obj is provided, the promise aspect is added to the object
  833. promise: function( obj ) {
  834. if ( obj == null ) {
  835. if ( promise ) {
  836. return promise;
  837. }
  838. promise = obj = {};
  839. }
  840. var i = promiseMethods.length;
  841. while( i-- ) {
  842. obj[ promiseMethods[i] ] = deferred[ promiseMethods[i] ];
  843. }
  844. return obj;
  845. }
  846. } );
  847. // Make sure only one callback list will be used
  848. deferred.done( failDeferred.cancel ).fail( deferred.cancel );
  849. // Unexpose cancel
  850. delete deferred.cancel;
  851. // Call given func if any
  852. if ( func ) {
  853. func.call( deferred, deferred );
  854. }
  855. return deferred;
  856. },
  857. // Deferred helper
  858. when: function( firstParam ) {
  859. var args = arguments,
  860. i = 0,
  861. length = args.length,
  862. count = length,
  863. deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ?
  864. firstParam :
  865. jQuery.Deferred();
  866. function resolveFunc( i ) {
  867. return function( value ) {
  868. args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
  869. if ( !( --count ) ) {
  870. // Strange bug in FF4:
  871. // Values changed onto the arguments object sometimes end up as undefined values
  872. // outside the $.when method. Cloning the object into a fresh array solves the issue
  873. deferred.resolveWith( deferred, sliceDeferred.call( args, 0 ) );
  874. }
  875. };
  876. }
  877. if ( length > 1 ) {
  878. for( ; i < length; i++ ) {
  879. if ( args[ i ] && jQuery.isFunction( args[ i ].promise ) ) {
  880. args[ i ].promise().then( resolveFunc(i), deferred.reject );
  881. } else {
  882. --count;
  883. }
  884. }
  885. if ( !count ) {
  886. deferred.resolveWith( deferred, args );
  887. }
  888. } else if ( deferred !== firstParam ) {
  889. deferred.resolveWith( deferred, length ? [ firstParam ] : [] );
  890. }
  891. return deferred.promise();
  892. }
  893. });
  894. (function() {
  895. jQuery.support = {};
  896. var div = document.createElement("div");
  897. div.style.display = "none";
  898. div.innerHTML = " <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
  899. var all = div.getElementsByTagName("*"),
  900. a = div.getElementsByTagName("a")[0],
  901. select = document.createElement("select"),
  902. opt = select.appendChild( document.createElement("option") ),
  903. input = div.getElementsByTagName("input")[0];
  904. // Can't get basic test support
  905. if ( !all || !all.length || !a ) {
  906. return;
  907. }
  908. jQuery.support = {
  909. // IE strips leading whitespace when .innerHTML is used
  910. leadingWhitespace: div.firstChild.nodeType === 3,
  911. // Make sure that tbody elements aren't automatically inserted
  912. // IE will insert them into empty tables
  913. tbody: !div.getElementsByTagName("tbody").length,
  914. // Make sure that link elements get serialized correctly by innerHTML
  915. // This requires a wrapper element in IE
  916. htmlSerialize: !!div.getElementsByTagName("link").length,
  917. // Get the style information from getAttribute
  918. // (IE uses .cssText insted)
  919. style: /red/.test( a.getAttribute("style") ),
  920. // Make sure that URLs aren't manipulated
  921. // (IE normalizes it by default)
  922. hrefNormalized: a.getAttribute("href") === "/a",
  923. // Make sure that element opacity exists
  924. // (IE uses filter instead)
  925. // Use a regex to work around a WebKit issue. See #5145
  926. opacity: /^0.55$/.test( a.style.opacity ),
  927. // Verify style float existence
  928. // (IE uses styleFloat instead of cssFloat)
  929. cssFloat: !!a.style.cssFloat,
  930. // Make sure that if no value is specified for a checkbox
  931. // that it defaults to "on".
  932. // (WebKit defaults to "" instead)
  933. checkOn: input.value === "on",
  934. // Make sure that a selected-by-default option has a working selected property.
  935. // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
  936. optSelected: opt.selected,
  937. // Will be defined later
  938. deleteExpando: true,
  939. optDisabled: false,
  940. checkClone: false,
  941. noCloneEvent: true,
  942. noCloneChecked: true,
  943. boxModel: null,
  944. inlineBlockNeedsLayout: false,
  945. shrinkWrapBlocks: false,
  946. reliableHiddenOffsets: true,
  947. reliableMarginRight: true
  948. };
  949. input.checked = true;
  950. jQuery.support.noCloneChecked = input.cloneNode( true ).checked;
  951. // Make sure that the options inside disabled selects aren't marked as disabled
  952. // (WebKit marks them as diabled)
  953. select.disabled = true;
  954. jQuery.support.optDisabled = !opt.disabled;
  955. var _scriptEval = null;
  956. jQuery.support.scriptEval = function() {
  957. if ( _scriptEval === null ) {
  958. var root = document.documentElement,
  959. script = document.createElement("script"),
  960. id = "script" + jQuery.now();
  961. // Make sure that the execution of code works by injecting a script
  962. // tag with appendChild/createTextNode
  963. // (IE doesn't support this, fails, and uses .text instead)
  964. try {
  965. script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
  966. } catch(e) {}
  967. root.insertBefore( script, root.firstChild );
  968. if ( window[ id ] ) {
  969. _scriptEval = true;
  970. delete window[ id ];
  971. } else {
  972. _scriptEval = false;
  973. }
  974. root.removeChild( script );
  975. }
  976. return _scriptEval;
  977. };
  978. // Test to see if it's possible to delete an expando from an element
  979. // Fails in Internet Explorer
  980. try {
  981. delete div.test;
  982. } catch(e) {
  983. jQuery.support.deleteExpando = false;
  984. }
  985. if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
  986. div.attachEvent("onclick", function click() {
  987. // Cloning a node shouldn't copy over any
  988. // bound event handlers (IE does this)
  989. jQuery.support.noCloneEvent = false;
  990. div.detachEvent("onclick", click);
  991. });
  992. div.cloneNode(true).fireEvent("onclick");
  993. }
  994. div = document.createElement("div");
  995. div.innerHTML = "<input type='radio' name='radiotest' checked='checked'/>";
  996. var fragment = document.createDocumentFragment();
  997. fragment.appendChild( div.firstChild );
  998. // WebKit doesn't clone checked state correctly in fragments
  999. jQuery.support.checkClone = fragment.cloneNode(true).cloneNode(true).lastChild.checked;
  1000. // Figure out if the W3C box model works as expected
  1001. // document.body must exist before we can do this
  1002. jQuery(function() {
  1003. var div = document.createElement("div"),
  1004. body = document.getElementsByTagName("body")[0];
  1005. // Frameset documents with no body should not run this code
  1006. if ( !body ) {
  1007. return;
  1008. }
  1009. div.style.width = div.style.paddingLeft = "1px";
  1010. body.appendChild( div );
  1011. jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2;
  1012. if ( "zoom" in div.style ) {
  1013. // Check if natively block-level elements act like inline-block
  1014. // elements when setting their display to 'inline' and giving
  1015. // them layout
  1016. // (IE < 8 does this)
  1017. div.style.display = "inline";
  1018. div.style.zoom = 1;
  1019. jQuery.support.inlineBlockNeedsLayout = div.offsetWidth === 2;
  1020. // Check if elements with layout shrink-wrap their children
  1021. // (IE 6 does this)
  1022. div.style.display = "";
  1023. div.innerHTML = "<div style='width:4px;'></div>";
  1024. jQuery.support.shrinkWrapBlocks = div.offsetWidth !== 2;
  1025. }
  1026. div.innerHTML = "<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>";
  1027. var tds = div.getElementsByTagName("td");
  1028. // Check if table cells still have offsetWidth/Height when they are set
  1029. // to display:none and there are still other visible table cells in a
  1030. // table row; if so, offsetWidth/Height are not reliable for use when
  1031. // determining if an element has been hidden directly using
  1032. // display:none (it is still safe to use offsets if a parent element is
  1033. // hidden; don safety goggles and see bug #4512 for more information).
  1034. // (only IE 8 fails this test)
  1035. jQuery.support.reliableHiddenOffsets = tds[0].offsetHeight === 0;
  1036. tds[0].style.display = "";
  1037. tds[1].style.display = "none";
  1038. // Check if empty table cells still have offsetWidth/Height
  1039. // (IE < 8 fail this test)
  1040. jQuery.support.reliableHiddenOffsets = jQuery.support.reliableHiddenOffsets && tds[0].offsetHeight === 0;
  1041. div.innerHTML = "";
  1042. // Check if div with explicit width and no margin-right incorrectly
  1043. // gets computed margin-right based on width of container. For more
  1044. // info see bug #3333
  1045. // Fails in WebKit before Feb 2011 nightlies
  1046. // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
  1047. if ( document.defaultView && document.defaultView.getComputedStyle ) {
  1048. div.style.width = "1px";
  1049. div.style.marginRight = "0";
  1050. jQuery.support.reliableMarginRight = ( parseInt(document.defaultView.getComputedStyle(div, null).marginRight, 10) || 0 ) === 0;
  1051. }
  1052. body.removeChild( div ).style.display = "none";
  1053. div = tds = null;
  1054. });
  1055. // Technique from Juriy Zaytsev
  1056. // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
  1057. var eventSupported = function( eventName ) {
  1058. var el = document.createElement("div");
  1059. eventName = "on" + eventName;
  1060. // We only care about the case where non-standard event systems
  1061. // are used, namely in IE. Short-circuiting here helps us to
  1062. // avoid an eval call (in setAttribute) which can cause CSP
  1063. // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
  1064. if ( !el.attachEvent ) {
  1065. return true;
  1066. }
  1067. var isSupported = (eventName in el);
  1068. if ( !isSupported ) {
  1069. el.setAttribute(eventName, "return;");
  1070. isSupported = typeof el[eventName] === "function";
  1071. }
  1072. return isSupported;
  1073. };
  1074. jQuery.support.submitBubbles = eventSupported("submit");
  1075. jQuery.support.changeBubbles = eventSupported("change");
  1076. // release memory in IE
  1077. div = all = a = null;
  1078. })();
  1079. var rbrace = /^(?:\{.*\}|\[.*\])$/;
  1080. jQuery.extend({
  1081. cache: {},
  1082. // Please use with caution
  1083. uuid: 0,
  1084. // Unique for each copy of jQuery on the page
  1085. // Non-digits removed to match rinlinejQuery
  1086. expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),
  1087. // The following elements throw uncatchable exceptions if you
  1088. // attempt to add expando properties to them.
  1089. noData: {
  1090. "embed": true,
  1091. // Ban all objects except for Flash (which handle expandos)
  1092. "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
  1093. "applet": true
  1094. },
  1095. hasData: function( elem ) {
  1096. elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
  1097. return !!elem && !isEmptyDataObject( elem );
  1098. },
  1099. data: function( elem, name, data, pvt /* Internal Use Only */ ) {
  1100. if ( !jQuery.acceptData( elem ) ) {
  1101. return;
  1102. }
  1103. var internalKey = jQuery.expando, getByName = typeof name === "string", thisCache,
  1104. // We have to handle DOM nodes and JS objects differently because IE6-7
  1105. // can't GC object references properly across the DOM-JS boundary
  1106. isNode = elem.nodeType,
  1107. // Only DOM nodes need the global jQuery cache; JS object data is
  1108. // attached directly to the object so GC can occur automatically
  1109. cache = isNode ? jQuery.cache : elem,
  1110. // Only defining an ID for JS objects if its cache already exists allows
  1111. // the code to shortcut on the same path as a DOM node with no cache
  1112. id = isNode ? elem[ jQuery.expando ] : elem[ jQuery.expando ] && jQuery.expando;
  1113. // Avoid doing any more work than we need to when trying to get data on an
  1114. // object that has no data at all
  1115. if ( (!id || (pvt && id && !cache[ id ][ internalKey ])) && getByName && data === undefined ) {
  1116. return;
  1117. }
  1118. if ( !id ) {
  1119. // Only DOM nodes need a new unique ID for each element since their data
  1120. // ends up in the global cache
  1121. if ( isNode ) {
  1122. elem[ jQuery.expando ] = id = ++jQuery.uuid;
  1123. } else {
  1124. id = jQuery.expando;
  1125. }
  1126. }
  1127. if ( !cache[ id ] ) {
  1128. cache[ id ] = {};
  1129. // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
  1130. // metadata on plain JS objects when the object is serialized using
  1131. // JSON.stringify
  1132. if ( !isNode ) {
  1133. cache[ id ].toJSON = jQuery.noop;
  1134. }
  1135. }
  1136. // An object can be passed to jQuery.data instead of a key/value pair; this gets
  1137. // shallow copied over onto the existing cache
  1138. if ( typeof name === "object" || typeof name === "function" ) {
  1139. if ( pvt ) {
  1140. cache[ id ][ internalKey ] = jQuery.extend(cache[ id ][ internalKey ], name);
  1141. } else {
  1142. cache[ id ] = jQuery.extend(cache[ id ], name);
  1143. }
  1144. }
  1145. thisCache = cache[ id ];
  1146. // Internal jQuery data is stored in a separate object inside the object's data
  1147. // cache in order to avoid key collisions between internal data and user-defined
  1148. // data
  1149. if ( pvt ) {
  1150. if ( !thisCache[ internalKey ] ) {
  1151. thisCache[ internalKey ] = {};
  1152. }
  1153. thisCache = thisCache[ internalKey ];
  1154. }
  1155. if ( data !== undefined ) {
  1156. thisCache[ name ] = data;
  1157. }
  1158. // TODO: This is a hack for 1.5 ONLY. It will be removed in 1.6. Users should
  1159. // not attempt to inspect the internal events object using jQuery.data, as this
  1160. // internal data object is undocumented and subject to change.
  1161. if ( name === "events" && !thisCache[name] ) {
  1162. return thisCache[ internalKey ] && thisCache[ internalKey ].events;
  1163. }
  1164. return getByName ? thisCache[ name ] : thisCache;
  1165. },
  1166. removeData: function( elem, name, pvt /* Internal Use Only */ ) {
  1167. if ( !jQuery.acceptData( elem ) ) {
  1168. return;
  1169. }
  1170. var internalKey = jQuery.expando, isNode = elem.nodeType,
  1171. // See jQuery.data for more information
  1172. cache = isNode ? jQuery.cache : elem,
  1173. // See jQuery.data for more information
  1174. id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
  1175. // If there is already no cache entry for this object, there is no
  1176. // purpose in continuing
  1177. if ( !cache[ id ] ) {
  1178. return;
  1179. }
  1180. if ( name ) {
  1181. var thisCache = pvt ? cache[ id ][ internalKey ] : cache[ id ];
  1182. if ( thisCache ) {
  1183. delete thisCache[ name ];
  1184. // If there is no data left in the cache, we want to continue
  1185. // and let the cache object itself get destroyed
  1186. if ( !isEmptyDataObject(thisCache) ) {
  1187. return;
  1188. }
  1189. }
  1190. }
  1191. // See jQuery.data for more information
  1192. if ( pvt ) {
  1193. delete cache[ id ][ internalKey ];
  1194. // Don't destroy the parent cache unless the internal data object
  1195. // had been the only thing left in it
  1196. if ( !isEmptyDataObject(cache[ id ]) ) {
  1197. return;
  1198. }
  1199. }
  1200. var internalCache = cache[ id ][ internalKey ];
  1201. // Browsers that fail expando deletion also refuse to delete expandos on
  1202. // the window, but it will allow it on all other JS objects; other browsers
  1203. // don't care
  1204. if ( jQuery.support.deleteExpando || cache != window ) {
  1205. delete cache[ id ];
  1206. } else {
  1207. cache[ id ] = null;
  1208. }
  1209. // We destroyed the entire user cache at once because it's faster than
  1210. // iterating through each key, but we need to continue to persist internal
  1211. // data if it existed
  1212. if ( internalCache ) {
  1213. cache[ id ] = {};
  1214. // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
  1215. // metadata on plain JS objects when the object is serialized using
  1216. // JSON.stringify
  1217. if ( !isNode ) {
  1218. cache[ id ].toJSON = jQuery.noop;
  1219. }
  1220. cache[ id ][ internalKey ] = internalCache;
  1221. // Otherwise, we need to eliminate the expando on the node to avoid
  1222. // false lookups in the cache for entries that no longer exist
  1223. } else if ( isNode ) {
  1224. // IE does not allow us to delete expando properties from nodes,
  1225. // nor does it have a removeAttribute function on Document nodes;
  1226. // we must handle all of these cases
  1227. if ( jQuery.support.deleteExpando ) {
  1228. delete elem[ jQuery.expando ];
  1229. } else if ( elem.removeAttribute ) {
  1230. elem.removeAttribute( jQuery.expando );
  1231. } else {
  1232. elem[ jQuery.expando ] = null;
  1233. }
  1234. }
  1235. },
  1236. // For internal use only.
  1237. _data: function( elem, name, data ) {
  1238. return jQuery.data( elem, name, data, true );
  1239. },
  1240. // A method for determining if a DOM node can handle the data expando
  1241. acceptData: function( elem ) {
  1242. if ( elem.nodeName ) {
  1243. var match = jQuery.noData[ elem.nodeName.toLowerCase() ];
  1244. if ( match ) {
  1245. return !(match === true || elem.getAttribute("classid") !== match);
  1246. }
  1247. }
  1248. return true;
  1249. }
  1250. });
  1251. jQuery.fn.extend({
  1252. data: function( key, value ) {
  1253. var data = null;
  1254. if ( typeof key === "undefined" ) {
  1255. if ( this.length ) {
  1256. data = jQuery.data( this[0] );
  1257. if ( this[0].nodeType === 1 ) {
  1258. var attr = this[0].attributes, name;
  1259. for ( var i = 0, l = attr.length; i < l; i++ ) {
  1260. name = attr[i].name;
  1261. if ( name.indexOf( "data-" ) === 0 ) {
  1262. name = name.substr( 5 );
  1263. dataAttr( this[0], name, data[ name ] );
  1264. }
  1265. }
  1266. }
  1267. }
  1268. return data;
  1269. } else if ( typeof key === "object" ) {
  1270. return this.each(function() {
  1271. jQuery.data( this, key );
  1272. });
  1273. }
  1274. var parts = key.split(".");
  1275. parts[1] = parts[1] ? "." + parts[1] : "";
  1276. if ( value === undefined ) {
  1277. data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
  1278. // Try to fetch any internally stored data first
  1279. if ( data === undefined && this.length ) {
  1280. data = jQuery.data( this[0], key );
  1281. data = dataAttr( this[0], key, data );
  1282. }
  1283. return data === undefined && parts[1] ?
  1284. this.data( parts[0] ) :
  1285. data;
  1286. } else {
  1287. return this.each(function() {
  1288. var $this = jQuery( this ),
  1289. args = [ parts[0], value ];
  1290. $this.triggerHandler( "setData" + parts[1] + "!", args );
  1291. jQuery.data( this, key, value );
  1292. $this.triggerHandler( "changeData" + parts[1] + "!", args );
  1293. });
  1294. }
  1295. },
  1296. removeData: function( key ) {
  1297. return this.each(function() {
  1298. jQuery.removeData( this, key );
  1299. });
  1300. }
  1301. });
  1302. function dataAttr( elem, key, data ) {
  1303. // If nothing was found internally, try to fetch any
  1304. // data from the HTML5 data-* attribute
  1305. if ( data === undefined && elem.nodeType === 1 ) {
  1306. data = elem.getAttribute( "data-" + key );
  1307. if ( typeof data === "string" ) {
  1308. try {
  1309. data = data === "true" ? true :
  1310. data === "false" ? false :
  1311. data === "null" ? null :
  1312. !jQuery.isNaN( data ) ? parseFloat( data ) :
  1313. rbrace.test( data ) ? jQuery.parseJSON( data ) :
  1314. data;
  1315. } catch( e ) {}
  1316. // Make sure we set the data so it isn't changed later
  1317. jQuery.data( elem, key, data );
  1318. } else {
  1319. data = undefined;
  1320. }
  1321. }
  1322. return data;
  1323. }
  1324. // TODO: This is a hack for 1.5 ONLY to allow objects with a single toJSON
  1325. // property to be considered empty objects; this property always exists in
  1326. // order to make sure JSON.stringify does not expose internal metadata
  1327. function isEmptyDataObject( obj ) {
  1328. for ( var name in obj ) {
  1329. if ( name !== "toJSON" ) {
  1330. return false;
  1331. }
  1332. }
  1333. return true;
  1334. }
  1335. jQuery.extend({
  1336. queue: function( elem, type, data ) {
  1337. if ( !elem ) {
  1338. return;
  1339. }
  1340. type = (type || "fx") + "queue";
  1341. var q = jQuery._data( elem, type );
  1342. // Speed up dequeue by getting out quickly if this is just a lookup
  1343. if ( !data ) {
  1344. return q || [];
  1345. }
  1346. if ( !q || jQuery.isArray(data) ) {
  1347. q = jQuery._data( elem, type, jQuery.makeArray(data) );
  1348. } else {
  1349. q.push( data );
  1350. }
  1351. return q;
  1352. },
  1353. dequeue: function( elem, type ) {
  1354. type = type || "fx";
  1355. var queue = jQuery.queue( elem, type ),
  1356. fn = queue.shift();
  1357. // If the fx queue is dequeued, always remove the progress sentinel
  1358. if ( fn === "inprogress" ) {
  1359. fn = queue.shift();
  1360. }
  1361. if ( fn ) {
  1362. // Add a progress sentinel to prevent the fx queue from being
  1363. // automatically dequeued
  1364. if ( type === "fx" ) {
  1365. queue.unshift("inprogress");
  1366. }
  1367. fn.call(elem, function() {
  1368. jQuery.dequeue(elem, type);
  1369. });
  1370. }
  1371. if ( !queue.length ) {
  1372. jQuery.removeData( elem, type + "queue", true );
  1373. }
  1374. }
  1375. });
  1376. jQuery.fn.extend({
  1377. queue: function( type, data ) {
  1378. if ( typeof type !== "string" ) {
  1379. data = type;
  1380. type = "fx";
  1381. }
  1382. if ( data === undefined ) {
  1383. return jQuery.queue( this[0], type );
  1384. }
  1385. return this.each(function( i ) {
  1386. var queue = jQuery.queue( this, type, data );
  1387. if ( type === "fx" && queue[0] !== "inprogress" ) {
  1388. jQuery.dequeue( this, type );
  1389. }
  1390. });
  1391. },
  1392. dequeue: function( type ) {
  1393. return this.each(function() {
  1394. jQuery.dequeue( this, type );
  1395. });
  1396. },
  1397. // Based off of the plugin by Clint Helfers, with permission.
  1398. // http://blindsignals.com/index.php/2009/07/jquery-delay/
  1399. delay: function( time, type ) {
  1400. time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
  1401. type = type || "fx";
  1402. return this.queue( type, function() {
  1403. var elem = this;
  1404. setTimeout(function() {
  1405. jQuery.dequeue( elem, type );
  1406. }, time );
  1407. });
  1408. },
  1409. clearQueue: function( type ) {
  1410. return this.queue( type || "fx", [] );
  1411. }
  1412. });
  1413. var rclass = /[\n\t\r]/g,
  1414. rspaces = /\s+/,
  1415. rreturn = /\r/g,
  1416. rspecialurl = /^(?:href|src|style)$/,
  1417. rtype = /^(?:button|input)$/i,
  1418. rfocusable = /^(?:button|input|object|select|textarea)$/i,
  1419. rclickable = /^a(?:rea)?$/i,
  1420. rradiocheck = /^(?:radio|checkbox)$/i;
  1421. jQuery.props = {
  1422. "for": "htmlFor",
  1423. "class": "className",
  1424. readonly: "readOnly",
  1425. maxlength: "maxLength",
  1426. cellspacing: "cellSpacing",
  1427. rowspan: "rowSpan",
  1428. colspan: "colSpan",
  1429. tabindex: "tabIndex",
  1430. usemap: "useMap",
  1431. frameborder: "frameBorder"
  1432. };
  1433. jQuery.fn.extend({
  1434. attr: function( name, value ) {
  1435. return jQuery.access( this, name, value, true, jQuery.attr );
  1436. },
  1437. removeAttr: function( name, fn ) {
  1438. return this.each(function(){
  1439. jQuery.attr( this, name, "" );
  1440. if ( this.nodeType === 1 ) {
  1441. this.removeAttribute( name );
  1442. }
  1443. });
  1444. },
  1445. addClass: function( value ) {
  1446. if ( jQuery.isFunction(value) ) {
  1447. return this.each(function(i) {
  1448. var self = jQuery(this);
  1449. self.addClass( value.call(this, i, self.attr("class")) );
  1450. });
  1451. }
  1452. if ( value && typeof value === "string" ) {
  1453. var classNames = (value || "").split( rspaces );
  1454. for ( var i = 0, l = this.length; i < l; i++ ) {
  1455. var elem = this[i];
  1456. if ( elem.nodeType === 1 ) {
  1457. if ( !elem.className ) {
  1458. elem.className = value;
  1459. } else {
  1460. var className = " " + elem.className + " ",
  1461. setClass = elem.className;
  1462. for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
  1463. if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) {
  1464. setClass += " " + classNames[c];
  1465. }
  1466. }
  1467. elem.className = jQuery.trim( setClass );
  1468. }
  1469. }
  1470. }
  1471. }
  1472. return this;
  1473. },
  1474. removeClass: function( value ) {
  1475. if ( jQuery.isFunction(value) ) {
  1476. return this.each(function(i) {
  1477. var self = jQuery(this);
  1478. self.removeClass( value.call(this, i, self.attr("class")) );
  1479. });
  1480. }
  1481. if ( (value && typeof value === "string") || value === undefined ) {
  1482. var classNames = (value || "").split( rspaces );
  1483. for ( var i = 0, l = this.length; i < l; i++ ) {
  1484. var elem = this[i];
  1485. if ( elem.nodeType === 1 && elem.className ) {
  1486. if ( value ) {
  1487. var className = (" " + elem.className + " ").replace(rclass, " ");
  1488. for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
  1489. className = className.replace(" " + classNames[c] + " ", " ");
  1490. }
  1491. elem.className = jQuery.trim( className );
  1492. } else {
  1493. elem.className = "";
  1494. }
  1495. }
  1496. }
  1497. }
  1498. return this;
  1499. },
  1500. toggleClass: function( value, stateVal ) {
  1501. var type = typeof value,
  1502. isBool = typeof stateVal === "boolean";
  1503. if ( jQuery.isFunction( value ) ) {
  1504. return this.each(function(i) {
  1505. var self = jQuery(this);
  1506. self.toggleClass( value.call(this, i, self.attr("class"), stateVal), stateVal );
  1507. });
  1508. }
  1509. return this.each(function() {
  1510. if ( type === "string" ) {
  1511. // toggle individual class names
  1512. var className,
  1513. i = 0,
  1514. self = jQuery( this ),
  1515. state = stateVal,
  1516. classNames = value.split( rspaces );
  1517. while ( (className = classNames[ i++ ]) ) {
  1518. // check each className given, space seperated list
  1519. state = isBool ? state : !self.hasClass( className );
  1520. self[ state ? "addClass" : "removeClass" ]( className );
  1521. }
  1522. } else if ( type === "undefined" || type === "boolean" ) {
  1523. if ( this.className ) {
  1524. // store className if set
  1525. jQuery._data( this, "__className__", this.className );
  1526. }
  1527. // toggle whole className
  1528. this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
  1529. }
  1530. });
  1531. },
  1532. hasClass: function( selector ) {
  1533. var className = " " + selector + " ";
  1534. for ( var i = 0, l = this.length; i < l; i++ ) {
  1535. if ( (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
  1536. return true;
  1537. }
  1538. }
  1539. return false;
  1540. },
  1541. val: function( value ) {
  1542. if ( !arguments.length ) {
  1543. var elem = this[0];
  1544. if ( elem ) {
  1545. if ( jQuery.nodeName( elem, "option" ) ) {
  1546. // attributes.value is undefined in Blackberry 4.7 but
  1547. // uses .value. See #6932
  1548. var val = elem.attributes.value;
  1549. return !val || val.specified ? elem.value : elem.text;
  1550. }
  1551. // We need to handle select boxes special
  1552. if ( jQuery.nodeName( elem, "select" ) ) {
  1553. var index = elem.selectedIndex,
  1554. values = [],
  1555. options = elem.options,
  1556. one = elem.type === "select-one";
  1557. // Nothing was selected
  1558. if ( index < 0 ) {
  1559. return null;
  1560. }
  1561. // Loop through all the selected options
  1562. for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
  1563. var option = options[ i ];
  1564. // Don't return options that are disabled or in a disabled optgroup
  1565. if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
  1566. (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
  1567. // Get the specific value for the option
  1568. value = jQuery(option).val();
  1569. // We don't need an array for one selects
  1570. if ( one ) {
  1571. return value;
  1572. }
  1573. // Multi-Selects return an array
  1574. values.push( value );
  1575. }
  1576. }
  1577. // Fixes Bug #2551 -- select.val() broken in IE after form.reset()
  1578. if ( one && !values.length && options.length ) {
  1579. return jQuery( options[ index ] ).val();
  1580. }
  1581. return values;
  1582. }
  1583. // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
  1584. if ( rradiocheck.test( elem.type ) && !jQuery.support.checkOn ) {
  1585. return elem.getAttribute("value") === null ? "on" : elem.value;
  1586. }
  1587. // Everything else, we just grab the value
  1588. return (elem.value || "").replace(rreturn, "");
  1589. }
  1590. return undefined;
  1591. }
  1592. var isFunction = jQuery.isFunction(value);
  1593. return this.each(function(i) {
  1594. var self = jQuery(this), val = value;
  1595. if ( this.nodeType !== 1 ) {
  1596. return;
  1597. }
  1598. if ( isFunction ) {
  1599. val = value.call(this, i, self.val());
  1600. }
  1601. // Treat null/undefined as ""; convert numbers to string
  1602. if ( val == null ) {
  1603. val = "";
  1604. } else if ( typeof val === "number" ) {
  1605. val += "";
  1606. } else if ( jQuery.isArray(val) ) {
  1607. val = jQuery.map(val, function (value) {
  1608. return value == null ? "" : value + "";
  1609. });
  1610. }
  1611. if ( jQuery.isArray(val) && rradiocheck.test( this.type ) ) {
  1612. this.checked = jQuery.inArray( self.val(), val ) >= 0;
  1613. } else if ( jQuery.nodeName( this, "select" ) ) {
  1614. var values = jQuery.makeArray(val);
  1615. jQuery( "option", this ).each(function() {
  1616. this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
  1617. });
  1618. if ( !values.length ) {
  1619. this.selectedIndex = -1;
  1620. }
  1621. } else {
  1622. this.value = val;
  1623. }
  1624. });
  1625. }
  1626. });
  1627. jQuery.extend({
  1628. attrFn: {
  1629. val: true,
  1630. css: true,
  1631. html: true,
  1632. text: true,
  1633. data: true,
  1634. width: true,
  1635. height: true,
  1636. offset: true
  1637. },
  1638. attr: function( elem, name, value, pass ) {
  1639. // don't get/set attributes on text, comment and attribute nodes
  1640. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || elem.nodeType === 2 ) {
  1641. return undefined;
  1642. }
  1643. if ( pass && name in jQuery.attrFn ) {
  1644. return jQuery(elem)[name](value);
  1645. }
  1646. var notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ),
  1647. // Whether we are setting (or getting)
  1648. set = value !== undefined;
  1649. // Try to normalize/fix the name
  1650. name = notxml && jQuery.props[ name ] || name;
  1651. // Only do all the following if this is a node (faster for style)
  1652. if ( elem.nodeType === 1 ) {
  1653. // These attributes require special treatment
  1654. var special = rspecialurl.test( name );
  1655. // Safari mis-reports the default selected property of an option
  1656. // Accessing the parent's selectedIndex property fixes it
  1657. if ( name === "selected" && !jQuery.support.optSelected ) {
  1658. var parent = elem.parentNode;
  1659. if ( parent ) {
  1660. parent.selectedIndex;
  1661. // Make sure that it also works with optgroups, see #5701
  1662. if ( parent.parentNode ) {
  1663. parent.parentNode.selectedIndex;
  1664. }
  1665. }
  1666. }
  1667. // If applicable, access the attribute via the DOM 0 way
  1668. // 'in' checks fail in Blackberry 4.7 #6931
  1669. if ( (name in elem || elem[ name ] !== undefined) && notxml && !special ) {
  1670. if ( set ) {
  1671. // We can't allow the type property to be changed (since it causes problems in IE)
  1672. if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) {
  1673. jQuery.error( "type property can't be changed" );
  1674. }
  1675. if ( value === null ) {
  1676. if ( elem.nodeType === 1 ) {
  1677. elem.removeAttribute( name );
  1678. }
  1679. } else {
  1680. elem[ name ] = value;
  1681. }
  1682. }
  1683. // browsers index elements by id/name on forms, give priority to attributes.
  1684. if ( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) {
  1685. return elem.getAttributeNode( name ).nodeValue;
  1686. }
  1687. // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
  1688. // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
  1689. if ( name === "tabIndex" ) {
  1690. var attributeNode = elem.getAttributeNode( "tabIndex" );
  1691. return attributeNode && attributeNode.specified ?
  1692. attributeNode.value :
  1693. rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
  1694. 0 :
  1695. undefined;
  1696. }
  1697. return elem[ name ];
  1698. }
  1699. if ( !jQuery.support.style && notxml && name === "style" ) {
  1700. if ( set ) {
  1701. elem.style.cssText = "" + value;
  1702. }
  1703. return elem.style.cssText;
  1704. }
  1705. if ( set ) {
  1706. // convert the value to a string (all browsers do this but IE) see #1070
  1707. elem.setAttribute( name, "" + value );
  1708. }
  1709. // Ensure that missing attributes return undefined
  1710. // Blackberry 4.7 returns "" from getAttribute #6938
  1711. if ( !elem.attributes[ name ] && (elem.hasAttribute && !elem.hasAttribute( name )) ) {
  1712. return undefined;
  1713. }
  1714. var attr = !jQuery.support.hrefNormalized && notxml && special ?
  1715. // Some attributes require a special call on IE
  1716. elem.getAttribute( name, 2 ) :
  1717. elem.getAttribute( name );
  1718. // Non-existent attributes return null, we normalize to undefined
  1719. return attr === null ? undefined : attr;
  1720. }
  1721. // Handle everything which isn't a DOM element node
  1722. if ( set ) {
  1723. elem[ name ] = value;
  1724. }
  1725. return elem[ name ];
  1726. }
  1727. });
  1728. var rnamespaces = /\.(.*)$/,
  1729. rformElems = /^(?:textarea|input|select)$/i,
  1730. rperiod = /\./g,
  1731. rspace = / /g,
  1732. rescape = /[^\w\s.|`]/g,
  1733. fcleanup = function( nm ) {
  1734. return nm.replace(rescape, "\\$&");
  1735. };
  1736. /*
  1737. * A number of helper functions used for managing events.
  1738. * Many of the ideas behind this code originated from
  1739. * Dean Edwards' addEvent library.
  1740. */
  1741. jQuery.event = {
  1742. // Bind an event to an element
  1743. // Original by Dean Edwards
  1744. add: function( elem, types, handler, data ) {
  1745. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  1746. return;
  1747. }
  1748. // TODO :: Use a try/catch until it's safe to pull this out (likely 1.6)
  1749. // Minor release fix for bug #8018
  1750. try {
  1751. // For whatever reason, IE has trouble passing the window object
  1752. // around, causing it to be cloned in the process
  1753. if ( jQuery.isWindow( elem ) && ( elem !== window && !elem.frameElement ) ) {
  1754. elem = window;
  1755. }
  1756. }
  1757. catch ( e ) {}
  1758. if ( handler === false ) {
  1759. handler = returnFalse;
  1760. } else if ( !handler ) {
  1761. // Fixes bug #7229. Fix recommended by jdalton
  1762. return;
  1763. }
  1764. var handleObjIn, handleObj;
  1765. if ( handler.handler ) {
  1766. handleObjIn = handler;
  1767. handler = handleObjIn.handler;
  1768. }
  1769. // Make sure that the function being executed has a unique ID
  1770. if ( !handler.guid ) {
  1771. handler.guid = jQuery.guid++;
  1772. }
  1773. // Init the element's event structure
  1774. var elemData = jQuery._data( elem );
  1775. // If no elemData is found then we must be trying to bind to one of the
  1776. // banned noData elements
  1777. if ( !elemData ) {
  1778. return;
  1779. }
  1780. var events = elemData.events,
  1781. eventHandle = elemData.handle;
  1782. if ( !events ) {
  1783. elemData.events = events = {};
  1784. }
  1785. if ( !eventHandle ) {
  1786. elemData.handle = eventHandle = function( e ) {
  1787. // Handle the second event of a trigger and when
  1788. // an event is called after a page has unloaded
  1789. return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
  1790. jQuery.event.handle.apply( eventHandle.elem, arguments ) :
  1791. undefined;
  1792. };
  1793. }
  1794. // Add elem as a property of the handle function
  1795. // This is to prevent a memory leak with non-native events in IE.
  1796. eventHandle.elem = elem;
  1797. // Handle multiple events separated by a space
  1798. // jQuery(...).bind("mouseover mouseout", fn);
  1799. types = types.split(" ");
  1800. var type, i = 0, namespaces;
  1801. while ( (type = types[ i++ ]) ) {
  1802. handleObj = handleObjIn ?
  1803. jQuery.extend({}, handleObjIn) :
  1804. { handler: handler, data: data };
  1805. // Namespaced event handlers
  1806. if ( type.indexOf(".") > -1 ) {
  1807. namespaces = type.split(".");
  1808. type = namespaces.shift();
  1809. handleObj.namespace = namespaces.slice(0).sort().join(".");
  1810. } else {
  1811. namespaces = [];
  1812. handleObj.namespace = "";
  1813. }
  1814. handleObj.type = type;
  1815. if ( !handleObj.guid ) {
  1816. handleObj.guid = handler.guid;
  1817. }
  1818. // Get the current list of functions bound to this event
  1819. var handlers = events[ type ],
  1820. special = jQuery.event.special[ type ] || {};
  1821. // Init the event handler queue
  1822. if ( !handlers ) {
  1823. handlers = events[ type ] = [];
  1824. // Check for a special event handler
  1825. // Only use addEventListener/attachEvent if the special
  1826. // events handler returns false
  1827. if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
  1828. // Bind the global event handler to the element
  1829. if ( elem.addEventListener ) {
  1830. elem.addEventListener( type, eventHandle, false );
  1831. } else if ( elem.attachEvent ) {
  1832. elem.attachEvent( "on" + type, eventHandle );
  1833. }
  1834. }
  1835. }
  1836. if ( special.add ) {
  1837. special.add.call( elem, handleObj );
  1838. if ( !handleObj.handler.guid ) {
  1839. handleObj.handler.guid = handler.guid;
  1840. }
  1841. }
  1842. // Add the function to the element's handler list
  1843. handlers.push( handleObj );
  1844. // Keep track of which events have been used, for global triggering
  1845. jQuery.event.global[ type ] = true;
  1846. }
  1847. // Nullify elem to prevent memory leaks in IE
  1848. elem = null;
  1849. },
  1850. global: {},
  1851. // Detach an event or set of events from an element
  1852. remove: function( elem, types, handler, pos ) {
  1853. // don't do events on text and comment nodes
  1854. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  1855. return;
  1856. }
  1857. if ( handler === false ) {
  1858. handler = returnFalse;
  1859. }
  1860. var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType,
  1861. elemData = jQuery.hasData( elem ) && jQuery._data( elem ),
  1862. events = elemData && elemData.events;
  1863. if ( !elemData || !events ) {
  1864. return;
  1865. }
  1866. // types is actually an event object here
  1867. if ( types && types.type ) {
  1868. handler = types.handler;
  1869. types = types.type;
  1870. }
  1871. // Unbind all events for the element
  1872. if ( !types || typeof types === "string" && types.charAt(0) === "." ) {
  1873. types = types || "";
  1874. for ( type in events ) {
  1875. jQuery.event.remove( elem, type + types );
  1876. }
  1877. return;
  1878. }
  1879. // Handle multiple events separated by a space
  1880. // jQuery(...).unbind("mouseover mouseout", fn);
  1881. types = types.split(" ");
  1882. while ( (type = types[ i++ ]) ) {
  1883. origType = type;
  1884. handleObj = null;
  1885. all = type.indexOf(".") < 0;
  1886. namespaces = [];
  1887. if ( !all ) {
  1888. // Namespaced event handlers
  1889. namespaces = type.split(".");
  1890. type = namespaces.shift();
  1891. namespace = new RegExp("(^|\\.)" +
  1892. jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)");
  1893. }
  1894. eventType = events[ type ];
  1895. if ( !eventType ) {
  1896. continue;
  1897. }
  1898. if ( !handler ) {
  1899. for ( j = 0; j < eventType.length; j++ ) {
  1900. handleObj = eventType[ j ];
  1901. if ( all || namespace.test( handleObj.namespace ) ) {
  1902. jQuery.event.remove( elem, origType, handleObj.handler, j );
  1903. eventType.splice( j--, 1 );
  1904. }
  1905. }
  1906. continue;
  1907. }
  1908. special = jQuery.event.special[ type ] || {};
  1909. for ( j = pos || 0; j < eventType.length; j++ ) {
  1910. handleObj = eventType[ j ];
  1911. if ( handler.guid === handleObj.guid ) {
  1912. // remove the given handler for the given type
  1913. if ( all || namespace.test( handleObj.namespace ) ) {
  1914. if ( pos == null ) {
  1915. eventType.splice( j--, 1 );
  1916. }
  1917. if ( special.remove ) {
  1918. special.remove.call( elem, handleObj );
  1919. }
  1920. }
  1921. if ( pos != null ) {
  1922. break;
  1923. }
  1924. }
  1925. }
  1926. // remove generic event handler if no more handlers exist
  1927. if ( eventType.length === 0 || pos != null && eventType.length === 1 ) {
  1928. if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
  1929. jQuery.removeEvent( elem, type, elemData.handle );
  1930. }
  1931. ret = null;
  1932. delete events[ type ];
  1933. }
  1934. }
  1935. // Remove the expando if it's no longer used
  1936. if ( jQuery.isEmptyObject( events ) ) {
  1937. var handle = elemData.handle;
  1938. if ( handle ) {
  1939. handle.elem = null;
  1940. }
  1941. delete elemData.events;
  1942. delete elemData.handle;
  1943. if ( jQuery.isEmptyObject( elemData ) ) {
  1944. jQuery.removeData( elem, undefined, true );
  1945. }
  1946. }
  1947. },
  1948. // bubbling is internal
  1949. trigger: function( event, data, elem /*, bubbling */ ) {
  1950. // Event object or event type
  1951. var type = event.type || event,
  1952. bubbling = arguments[3];
  1953. if ( !bubbling ) {
  1954. event = typeof event === "object" ?
  1955. // jQuery.Event object
  1956. event[ jQuery.expando ] ? event :
  1957. // Object literal
  1958. jQuery.extend( jQuery.Event(type), event ) :
  1959. // Just the event type (string)
  1960. jQuery.Event(type);
  1961. if ( type.indexOf("!") >= 0 ) {
  1962. event.type = type = type.slice(0, -1);
  1963. event.exclusive = true;
  1964. }
  1965. // Handle a global trigger
  1966. if ( !elem ) {
  1967. // Don't bubble custom events when global (to avoid too much overhead)
  1968. event.stopPropagation();
  1969. // Only trigger if we've ever bound an event for it
  1970. if ( jQuery.event.global[ type ] ) {
  1971. // XXX This code smells terrible. event.js should not be directly
  1972. // inspecting the data cache
  1973. jQuery.each( jQuery.cache, function() {
  1974. // internalKey variable is just used to make it easier to find
  1975. // and potentially change this stuff later; currently it just
  1976. // points to jQuery.expando
  1977. var internalKey = jQuery.expando,
  1978. internalCache = this[ internalKey ];
  1979. if ( internalCache && internalCache.events && internalCache.events[ type ] ) {
  1980. jQuery.event.trigger( event, data, internalCache.handle.elem );
  1981. }
  1982. });
  1983. }
  1984. }
  1985. // Handle triggering a single element
  1986. // don't do events on text and comment nodes
  1987. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
  1988. return undefined;
  1989. }
  1990. // Clean up in case it is reused
  1991. event.result = undefined;
  1992. event.target = elem;
  1993. // Clone the incoming data, if any
  1994. data = jQuery.makeArray( data );
  1995. data.unshift( event );
  1996. }
  1997. event.currentTarget = elem;
  1998. // Trigger the event, it is assumed that "handle" is a function
  1999. var handle = jQuery._data( elem, "handle" );
  2000. if ( handle ) {
  2001. handle.apply( elem, data );
  2002. }
  2003. var parent = elem.parentNode || elem.ownerDocument;
  2004. // Trigger an inline bound script
  2005. try {
  2006. if ( !(elem && elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()]) ) {
  2007. if ( elem[ "on" + type ] && elem[ "on" + type ].apply( elem, data ) === false ) {
  2008. event.result = false;
  2009. event.preventDefault();
  2010. }
  2011. }
  2012. // prevent IE from throwing an error for some elements with some event types, see #3533
  2013. } catch (inlineError) {}
  2014. if ( !event.isPropagationStopped() && parent ) {
  2015. jQuery.event.trigger( event, data, parent, true );
  2016. } else if ( !event.isDefaultPrevented() ) {
  2017. var old,
  2018. target = event.target,
  2019. targetType = type.replace( rnamespaces, "" ),
  2020. isClick = jQuery.nodeName( target, "a" ) && targetType === "click",
  2021. special = jQuery.event.special[ targetType ] || {};
  2022. if ( (!special._default || special._default.call( elem, event ) === false) &&
  2023. !isClick && !(target && target.nodeName && jQuery.noData[target.nodeName.toLowerCase()]) ) {
  2024. try {
  2025. if ( target[ targetType ] ) {
  2026. // Make sure that we don't accidentally re-trigger the onFOO events
  2027. old = target[ "on" + targetType ];
  2028. if ( old ) {
  2029. target[ "on" + targetType ] = null;
  2030. }
  2031. jQuery.event.triggered = event.type;
  2032. target[ targetType ]();
  2033. }
  2034. // prevent IE from throwing an error for some elements with some event types, see #3533
  2035. } catch (triggerError) {}
  2036. if ( old ) {
  2037. target[ "on" + targetType ] = old;
  2038. }
  2039. jQuery.event.triggered = undefined;
  2040. }
  2041. }
  2042. },
  2043. handle: function( event ) {
  2044. var all, handlers, namespaces, namespace_re, events,
  2045. namespace_sort = [],
  2046. args = jQuery.makeArray( arguments );
  2047. event = args[0] = jQuery.event.fix( event || window.event );
  2048. event.currentTarget = this;
  2049. // Namespaced event handlers
  2050. all = event.type.indexOf(".") < 0 && !event.exclusive;
  2051. if ( !all ) {
  2052. namespaces = event.type.split(".");
  2053. event.type = namespaces.shift();
  2054. namespace_sort = namespaces.slice(0).sort();
  2055. namespace_re = new RegExp("(^|\\.)" + namespace_sort.join("\\.(?:.*\\.)?") + "(\\.|$)");
  2056. }
  2057. event.namespace = event.namespace || namespace_sort.join(".");
  2058. events = jQuery._data(this, "events");
  2059. handlers = (events || {})[ event.type ];
  2060. if ( events && handlers ) {
  2061. // Clone the handlers to prevent manipulation
  2062. handlers = handlers.slice(0);
  2063. for ( var j = 0, l = handlers.length; j < l; j++ ) {
  2064. var handleObj = handlers[ j ];
  2065. // Filter the functions by class
  2066. if ( all || namespace_re.test( handleObj.namespace ) ) {
  2067. // Pass in a reference to the handler function itself
  2068. // So that we can later remove it
  2069. event.handler = handleObj.handler;
  2070. event.data = handleObj.data;
  2071. event.handleObj = handleObj;
  2072. var ret = handleObj.handler.apply( this, args );
  2073. if ( ret !== undefined ) {
  2074. event.result = ret;
  2075. if ( ret === false ) {
  2076. event.preventDefault();
  2077. event.stopPropagation();
  2078. }
  2079. }
  2080. if ( event.isImmediatePropagationStopped() ) {
  2081. break;
  2082. }
  2083. }
  2084. }
  2085. }
  2086. return event.result;
  2087. },
  2088. 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(" "),
  2089. fix: function( event ) {
  2090. if ( event[ jQuery.expando ] ) {
  2091. return event;
  2092. }
  2093. // store a copy of the original event object
  2094. // and "clone" to set read-only properties
  2095. var originalEvent = event;
  2096. event = jQuery.Event( originalEvent );
  2097. for ( var i = this.props.length, prop; i; ) {
  2098. prop = this.props[ --i ];
  2099. event[ prop ] = originalEvent[ prop ];
  2100. }
  2101. // Fix target property, if necessary
  2102. if ( !event.target ) {
  2103. // Fixes #1925 where srcElement might not be defined either
  2104. event.target = event.srcElement || document;
  2105. }
  2106. // check if target is a textnode (safari)
  2107. if ( event.target.nodeType === 3 ) {
  2108. event.target = event.target.parentNode;
  2109. }
  2110. // Add relatedTarget, if necessary
  2111. if ( !event.relatedTarget && event.fromElement ) {
  2112. event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement;
  2113. }
  2114. // Calculate pageX/Y if missing and clientX/Y available
  2115. if ( event.pageX == null && event.clientX != null ) {
  2116. var doc = document.documentElement,
  2117. body = document.body;
  2118. event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
  2119. event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
  2120. }
  2121. // Add which for key events
  2122. if ( event.which == null && (event.charCode != null || event.keyCode != null) ) {
  2123. event.which = event.charCode != null ? event.charCode : event.keyCode;
  2124. }
  2125. // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
  2126. if ( !event.metaKey && event.ctrlKey ) {
  2127. event.metaKey = event.ctrlKey;
  2128. }
  2129. // Add which for click: 1 === left; 2 === middle; 3 === right
  2130. // Note: button is not normalized, so don't use it
  2131. if ( !event.which && event.button !== undefined ) {
  2132. event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
  2133. }
  2134. return event;
  2135. },
  2136. // Deprecated, use jQuery.guid instead
  2137. guid: 1E8,
  2138. // Deprecated, use jQuery.proxy instead
  2139. proxy: jQuery.proxy,
  2140. special: {
  2141. ready: {
  2142. // Make sure the ready event is setup
  2143. setup: jQuery.bindReady,
  2144. teardown: jQuery.noop
  2145. },
  2146. live: {
  2147. add: function( handleObj ) {
  2148. jQuery.event.add( this,
  2149. liveConvert( handleObj.origType, handleObj.selector ),
  2150. jQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) );
  2151. },
  2152. remove: function( handleObj ) {
  2153. jQuery.event.remove( this, liveConvert( handleObj.origType, handleObj.selector ), handleObj );
  2154. }
  2155. },
  2156. beforeunload: {
  2157. setup: function( data, namespaces, eventHandle ) {
  2158. // We only want to do this special case on windows
  2159. if ( jQuery.isWindow( this ) ) {
  2160. this.onbeforeunload = eventHandle;
  2161. }
  2162. },
  2163. teardown: function( namespaces, eventHandle ) {
  2164. if ( this.onbeforeunload === eventHandle ) {
  2165. this.onbeforeunload = null;
  2166. }
  2167. }
  2168. }
  2169. }
  2170. };
  2171. jQuery.removeEvent = document.removeEventListener ?
  2172. function( elem, type, handle ) {
  2173. if ( elem.removeEventListener ) {
  2174. elem.removeEventListener( type, handle, false );
  2175. }
  2176. } :
  2177. function( elem, type, handle ) {
  2178. if ( elem.detachEvent ) {
  2179. elem.detachEvent( "on" + type, handle );
  2180. }
  2181. };
  2182. jQuery.Event = function( src ) {
  2183. // Allow instantiation without the 'new' keyword
  2184. if ( !this.preventDefault ) {
  2185. return new jQuery.Event( src );
  2186. }
  2187. // Event object
  2188. if ( src && src.type ) {
  2189. this.originalEvent = src;
  2190. this.type = src.type;
  2191. // Events bubbling up the document may have been marked as prevented
  2192. // by a handler lower down the tree; reflect the correct value.
  2193. this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false ||
  2194. src.getPreventDefault && src.getPreventDefault()) ? returnTrue : returnFalse;
  2195. // Event type
  2196. } else {
  2197. this.type = src;
  2198. }
  2199. // timeStamp is buggy for some events on Firefox(#3843)
  2200. // So we won't rely on the native value
  2201. this.timeStamp = jQuery.now();
  2202. // Mark it as fixed
  2203. this[ jQuery.expando ] = true;
  2204. };
  2205. function returnFalse() {
  2206. return false;
  2207. }
  2208. function returnTrue() {
  2209. return true;
  2210. }
  2211. // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
  2212. // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  2213. jQuery.Event.prototype = {
  2214. preventDefault: function() {
  2215. this.isDefaultPrevented = returnTrue;
  2216. var e = this.originalEvent;
  2217. if ( !e ) {
  2218. return;
  2219. }
  2220. // if preventDefault exists run it on the original event
  2221. if ( e.preventDefault ) {
  2222. e.preventDefault();
  2223. // otherwise set the returnValue property of the original event to false (IE)
  2224. } else {
  2225. e.returnValue = false;
  2226. }
  2227. },
  2228. stopPropagation: function() {
  2229. this.isPropagationStopped = returnTrue;
  2230. var e = this.originalEvent;
  2231. if ( !e ) {
  2232. return;
  2233. }
  2234. // if stopPropagation exists run it on the original event
  2235. if ( e.stopPropagation ) {
  2236. e.stopPropagation();
  2237. }
  2238. // otherwise set the cancelBubble property of the original event to true (IE)
  2239. e.cancelBubble = true;
  2240. },
  2241. stopImmediatePropagation: function() {
  2242. this.isImmediatePropagationStopped = returnTrue;
  2243. this.stopPropagation();
  2244. },
  2245. isDefaultPrevented: returnFalse,
  2246. isPropagationStopped: returnFalse,
  2247. isImmediatePropagationStopped: returnFalse
  2248. };
  2249. // Checks if an event happened on an element within another element
  2250. // Used in jQuery.event.special.mouseenter and mouseleave handlers
  2251. var withinElement = function( event ) {
  2252. // Check if mouse(over|out) are still within the same parent element
  2253. var parent = event.relatedTarget;
  2254. // Firefox sometimes assigns relatedTarget a XUL element
  2255. // which we cannot access the parentNode property of
  2256. try {
  2257. // Chrome does something similar, the parentNode property
  2258. // can be accessed but is null.
  2259. if ( parent && parent !== document && !parent.parentNode ) {
  2260. return;
  2261. }
  2262. // Traverse up the tree
  2263. while ( parent && parent !== this ) {
  2264. parent = parent.parentNode;
  2265. }
  2266. if ( parent !== this ) {
  2267. // set the correct event type
  2268. event.type = event.data;
  2269. // handle event if we actually just moused on to a non sub-element
  2270. jQuery.event.handle.apply( this, arguments );
  2271. }
  2272. // assuming we've left the element since we most likely mousedover a xul element
  2273. } catch(e) { }
  2274. },
  2275. // In case of event delegation, we only need to rename the event.type,
  2276. // liveHandler will take care of the rest.
  2277. delegate = function( event ) {
  2278. event.type = event.data;
  2279. jQuery.event.handle.apply( this, arguments );
  2280. };
  2281. // Create mouseenter and mouseleave events
  2282. jQuery.each({
  2283. mouseenter: "mouseover",
  2284. mouseleave: "mouseout"
  2285. }, function( orig, fix ) {
  2286. jQuery.event.special[ orig ] = {
  2287. setup: function( data ) {
  2288. jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig );
  2289. },
  2290. teardown: function( data ) {
  2291. jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement );
  2292. }
  2293. };
  2294. });
  2295. // submit delegation
  2296. if ( !jQuery.support.submitBubbles ) {
  2297. jQuery.event.special.submit = {
  2298. setup: function( data, namespaces ) {
  2299. if ( this.nodeName && this.nodeName.toLowerCase() !== "form" ) {
  2300. jQuery.event.add(this, "click.specialSubmit", function( e ) {
  2301. var elem = e.target,
  2302. type = elem.type;
  2303. if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
  2304. trigger( "submit", this, arguments );
  2305. }
  2306. });
  2307. jQuery.event.add(this, "keypress.specialSubmit", function( e ) {
  2308. var elem = e.target,
  2309. type = elem.type;
  2310. if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
  2311. trigger( "submit", this, arguments );
  2312. }
  2313. });
  2314. } else {
  2315. return false;
  2316. }
  2317. },
  2318. teardown: function( namespaces ) {
  2319. jQuery.event.remove( this, ".specialSubmit" );
  2320. }
  2321. };
  2322. }
  2323. // change delegation, happens here so we have bind.
  2324. if ( !jQuery.support.changeBubbles ) {
  2325. var changeFilters,
  2326. getVal = function( elem ) {
  2327. var type = elem.type, val = elem.value;
  2328. if ( type === "radio" || type === "checkbox" ) {
  2329. val = elem.checked;
  2330. } else if ( type === "select-multiple" ) {
  2331. val = elem.selectedIndex > -1 ?
  2332. jQuery.map( elem.options, function( elem ) {
  2333. return elem.selected;
  2334. }).join("-") :
  2335. "";
  2336. } else if ( elem.nodeName.toLowerCase() === "select" ) {
  2337. val = elem.selectedIndex;
  2338. }
  2339. return val;
  2340. },
  2341. testChange = function testChange( e ) {
  2342. var elem = e.target, data, val;
  2343. if ( !rformElems.test( elem.nodeName ) || elem.readOnly ) {
  2344. return;
  2345. }
  2346. data = jQuery._data( elem, "_change_data" );
  2347. val = getVal(elem);
  2348. // the current data will be also retrieved by beforeactivate
  2349. if ( e.type !== "focusout" || elem.type !== "radio" ) {
  2350. jQuery._data( elem, "_change_data", val );
  2351. }
  2352. if ( data === undefined || val === data ) {
  2353. return;
  2354. }
  2355. if ( data != null || val ) {
  2356. e.type = "change";
  2357. e.liveFired = undefined;
  2358. jQuery.event.trigger( e, arguments[1], elem );
  2359. }
  2360. };
  2361. jQuery.event.special.change = {
  2362. filters: {
  2363. focusout: testChange,
  2364. beforedeactivate: testChange,
  2365. click: function( e ) {
  2366. var elem = e.target, type = elem.type;
  2367. if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) {
  2368. testChange.call( this, e );
  2369. }
  2370. },
  2371. // Change has to be called before submit
  2372. // Keydown will be called before keypress, which is used in submit-event delegation
  2373. keydown: function( e ) {
  2374. var elem = e.target, type = elem.type;
  2375. if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") ||
  2376. (e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
  2377. type === "select-multiple" ) {
  2378. testChange.call( this, e );
  2379. }
  2380. },
  2381. // Beforeactivate happens also before the previous element is blurred
  2382. // with this event you can't trigger a change event, but you can store
  2383. // information
  2384. beforeactivate: function( e ) {
  2385. var elem = e.target;
  2386. jQuery._data( elem, "_change_data", getVal(elem) );
  2387. }
  2388. },
  2389. setup: function( data, namespaces ) {
  2390. if ( this.type === "file" ) {
  2391. return false;
  2392. }
  2393. for ( var type in changeFilters ) {
  2394. jQuery.event.add( this, type + ".specialChange", changeFilters[type] );
  2395. }
  2396. return rformElems.test( this.nodeName );
  2397. },
  2398. teardown: function( namespaces ) {
  2399. jQuery.event.remove( this, ".specialChange" );
  2400. return rformElems.test( this.nodeName );
  2401. }
  2402. };
  2403. changeFilters = jQuery.event.special.change.filters;
  2404. // Handle when the input is .focus()'d
  2405. changeFilters.focus = changeFilters.beforeactivate;
  2406. }
  2407. function trigger( type, elem, args ) {
  2408. // Piggyback on a donor event to simulate a different one.
  2409. // Fake originalEvent to avoid donor's stopPropagation, but if the
  2410. // simulated event prevents default then we do the same on the donor.
  2411. // Don't pass args or remember liveFired; they apply to the donor event.
  2412. var event = jQuery.extend( {}, args[ 0 ] );
  2413. event.type = type;
  2414. event.originalEvent = {};
  2415. event.liveFired = undefined;
  2416. jQuery.event.handle.call( elem, event );
  2417. if ( event.isDefaultPrevented() ) {
  2418. args[ 0 ].preventDefault();
  2419. }
  2420. }
  2421. // Create "bubbling" focus and blur events
  2422. if ( document.addEventListener ) {
  2423. jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
  2424. // Attach a single capturing handler while someone wants focusin/focusout
  2425. var attaches = 0;
  2426. jQuery.event.special[ fix ] = {
  2427. setup: function() {
  2428. if ( attaches++ === 0 ) {
  2429. document.addEventListener( orig, handler, true );
  2430. }
  2431. },
  2432. teardown: function() {
  2433. if ( --attaches === 0 ) {
  2434. document.removeEventListener( orig, handler, true );
  2435. }
  2436. }
  2437. };
  2438. function handler( donor ) {
  2439. // Donor event is always a native one; fix it and switch its type.
  2440. // Let focusin/out handler cancel the donor focus/blur event.
  2441. var e = jQuery.event.fix( donor );
  2442. e.type = fix;
  2443. e.originalEvent = {};
  2444. jQuery.event.trigger( e, null, e.target );
  2445. if ( e.isDefaultPrevented() ) {
  2446. donor.preventDefault();
  2447. }
  2448. }
  2449. });
  2450. }
  2451. jQuery.each(["bind", "one"], function( i, name ) {
  2452. jQuery.fn[ name ] = function( type, data, fn ) {
  2453. // Handle object literals
  2454. if ( typeof type === "object" ) {
  2455. for ( var key in type ) {
  2456. this[ name ](key, data, type[key], fn);
  2457. }
  2458. return this;
  2459. }
  2460. if ( jQuery.isFunction( data ) || data === false ) {
  2461. fn = data;
  2462. data = undefined;
  2463. }
  2464. var handler = name === "one" ? jQuery.proxy( fn, function( event ) {
  2465. jQuery( this ).unbind( event, handler );
  2466. return fn.apply( this, arguments );
  2467. }) : fn;
  2468. if ( type === "unload" && name !== "one" ) {
  2469. this.one( type, data, fn );
  2470. } else {
  2471. for ( var i = 0, l = this.length; i < l; i++ ) {
  2472. jQuery.event.add( this[i], type, handler, data );
  2473. }
  2474. }
  2475. return this;
  2476. };
  2477. });
  2478. jQuery.fn.extend({
  2479. unbind: function( type, fn ) {
  2480. // Handle object literals
  2481. if ( typeof type === "object" && !type.preventDefault ) {
  2482. for ( var key in type ) {
  2483. this.unbind(key, type[key]);
  2484. }
  2485. } else {
  2486. for ( var i = 0, l = this.length; i < l; i++ ) {
  2487. jQuery.event.remove( this[i], type, fn );
  2488. }
  2489. }
  2490. return this;
  2491. },
  2492. delegate: function( selector, types, data, fn ) {
  2493. return this.live( types, data, fn, selector );
  2494. },
  2495. undelegate: function( selector, types, fn ) {
  2496. if ( arguments.length === 0 ) {
  2497. return this.unbind( "live" );
  2498. } else {
  2499. return this.die( types, null, fn, selector );
  2500. }
  2501. },
  2502. trigger: function( type, data ) {
  2503. return this.each(function() {
  2504. jQuery.event.trigger( type, data, this );
  2505. });
  2506. },
  2507. triggerHandler: function( type, data ) {
  2508. if ( this[0] ) {
  2509. var event = jQuery.Event( type );
  2510. event.preventDefault();
  2511. event.stopPropagation();
  2512. jQuery.event.trigger( event, data, this[0] );
  2513. return event.result;
  2514. }
  2515. },
  2516. toggle: function( fn ) {
  2517. // Save reference to arguments for access in closure
  2518. var args = arguments,
  2519. i = 1;
  2520. // link all the functions, so any of them can unbind this click handler
  2521. while ( i < args.length ) {
  2522. jQuery.proxy( fn, args[ i++ ] );
  2523. }
  2524. return this.click( jQuery.proxy( fn, function( event ) {
  2525. // Figure out which function to execute
  2526. var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
  2527. jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );
  2528. // Make sure that clicks stop
  2529. event.preventDefault();
  2530. // and execute the function
  2531. return args[ lastToggle ].apply( this, arguments ) || false;
  2532. }));
  2533. },
  2534. hover: function( fnOver, fnOut ) {
  2535. return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
  2536. }
  2537. });
  2538. var liveMap = {
  2539. focus: "focusin",
  2540. blur: "focusout",
  2541. mouseenter: "mouseover",
  2542. mouseleave: "mouseout"
  2543. };
  2544. jQuery.each(["live", "die"], function( i, name ) {
  2545. jQuery.fn[ name ] = function( types, data, fn, origSelector /* Internal Use Only */ ) {
  2546. var type, i = 0, match, namespaces, preType,
  2547. selector = origSelector || this.selector,
  2548. context = origSelector ? this : jQuery( this.context );
  2549. if ( typeof types === "object" && !types.preventDefault ) {
  2550. for ( var key in types ) {
  2551. context[ name ]( key, data, types[key], selector );
  2552. }
  2553. return this;
  2554. }
  2555. if ( jQuery.isFunction( data ) ) {
  2556. fn = data;
  2557. data = undefined;
  2558. }
  2559. types = (types || "").split(" ");
  2560. while ( (type = types[ i++ ]) != null ) {
  2561. match = rnamespaces.exec( type );
  2562. namespaces = "";
  2563. if ( match ) {
  2564. namespaces = match[0];
  2565. type = type.replace( rnamespaces, "" );
  2566. }
  2567. if ( type === "hover" ) {
  2568. types.push( "mouseenter" + namespaces, "mouseleave" + namespaces );
  2569. continue;
  2570. }
  2571. preType = type;
  2572. if ( type === "focus" || type === "blur" ) {
  2573. types.push( liveMap[ type ] + namespaces );
  2574. type = type + namespaces;
  2575. } else {
  2576. type = (liveMap[ type ] || type) + namespaces;
  2577. }
  2578. if ( name === "live" ) {
  2579. // bind live handler
  2580. for ( var j = 0, l = context.length; j < l; j++ ) {
  2581. jQuery.event.add( context[j], "live." + liveConvert( type, selector ),
  2582. { data: data, selector: selector, handler: fn, origType: type, origHandler: fn, preType: preType } );
  2583. }
  2584. } else {
  2585. // unbind live handler
  2586. context.unbind( "live." + liveConvert( type, selector ), fn );
  2587. }
  2588. }
  2589. return this;
  2590. };
  2591. });
  2592. function liveHandler( event ) {
  2593. var stop, maxLevel, related, match, handleObj, elem, j, i, l, data, close, namespace, ret,
  2594. elems = [],
  2595. selectors = [],
  2596. events = jQuery._data( this, "events" );
  2597. // Make sure we avoid non-left-click bubbling in Firefox (#3861) and disabled elements in IE (#6911)
  2598. if ( event.liveFired === this || !events || !events.live || event.target.disabled || event.button && event.type === "click" ) {
  2599. return;
  2600. }
  2601. if ( event.namespace ) {
  2602. namespace = new RegExp("(^|\\.)" + event.namespace.split(".").join("\\.(?:.*\\.)?") + "(\\.|$)");
  2603. }
  2604. event.liveFired = this;
  2605. var live = events.live.slice(0);
  2606. for ( j = 0; j < live.length; j++ ) {
  2607. handleObj = live[j];
  2608. if ( handleObj.origType.replace( rnamespaces, "" ) === event.type ) {
  2609. selectors.push( handleObj.selector );
  2610. } else {
  2611. live.splice( j--, 1 );
  2612. }
  2613. }
  2614. match = jQuery( event.target ).closest( selectors, event.currentTarget );
  2615. for ( i = 0, l = match.length; i < l; i++ ) {
  2616. close = match[i];
  2617. for ( j = 0; j < live.length; j++ ) {
  2618. handleObj = live[j];
  2619. if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) && !close.elem.disabled ) {
  2620. elem = close.elem;
  2621. related = null;
  2622. // Those two events require additional checking
  2623. if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) {
  2624. event.type = handleObj.preType;
  2625. related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0];
  2626. }
  2627. if ( !related || related !== elem ) {
  2628. elems.push({ elem: elem, handleObj: handleObj, level: close.level });
  2629. }
  2630. }
  2631. }
  2632. }
  2633. for ( i = 0, l = elems.length; i < l; i++ ) {
  2634. match = elems[i];
  2635. if ( maxLevel && match.level > maxLevel ) {
  2636. break;
  2637. }
  2638. event.currentTarget = match.elem;
  2639. event.data = match.handleObj.data;
  2640. event.handleObj = match.handleObj;
  2641. ret = match.handleObj.origHandler.apply( match.elem, arguments );
  2642. if ( ret === false || event.isPropagationStopped() ) {
  2643. maxLevel = match.level;
  2644. if ( ret === false ) {
  2645. stop = false;
  2646. }
  2647. if ( event.isImmediatePropagationStopped() ) {
  2648. break;
  2649. }
  2650. }
  2651. }
  2652. return stop;
  2653. }
  2654. function liveConvert( type, selector ) {
  2655. return (type && type !== "*" ? type + "." : "") + selector.replace(rperiod, "`").replace(rspace, "&");
  2656. }
  2657. jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
  2658. "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  2659. "change select submit keydown keypress keyup error").split(" "), function( i, name ) {
  2660. // Handle event binding
  2661. jQuery.fn[ name ] = function( data, fn ) {
  2662. if ( fn == null ) {
  2663. fn = data;
  2664. data = null;
  2665. }
  2666. return arguments.length > 0 ?
  2667. this.bind( name, data, fn ) :
  2668. this.trigger( name );
  2669. };
  2670. if ( jQuery.attrFn ) {
  2671. jQuery.attrFn[ name ] = true;
  2672. }
  2673. });
  2674. /*!
  2675. * Sizzle CSS Selector Engine
  2676. * Copyright 2011, The Dojo Foundation
  2677. * Released under the MIT, BSD, and GPL Licenses.
  2678. * More information: http://sizzlejs.com/
  2679. */
  2680. (function(){
  2681. var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
  2682. done = 0,
  2683. toString = Object.prototype.toString,
  2684. hasDuplicate = false,
  2685. baseHasDuplicate = true,
  2686. rBackslash = /\\/g,
  2687. rNonWord = /\W/;
  2688. // Here we check if the JavaScript engine is using some sort of
  2689. // optimization where it does not always call our comparision
  2690. // function. If that is the case, discard the hasDuplicate value.
  2691. // Thus far that includes Google Chrome.
  2692. [0, 0].sort(function() {
  2693. baseHasDuplicate = false;
  2694. return 0;
  2695. });
  2696. var Sizzle = function( selector, context, results, seed ) {
  2697. results = results || [];
  2698. context = context || document;
  2699. var origContext = context;
  2700. if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
  2701. return [];
  2702. }
  2703. if ( !selector || typeof selector !== "string" ) {
  2704. return results;
  2705. }
  2706. var m, set, checkSet, extra, ret, cur, pop, i,
  2707. prune = true,
  2708. contextXML = Sizzle.isXML( context ),
  2709. parts = [],
  2710. soFar = selector;
  2711. // Reset the position of the chunker regexp (start from head)
  2712. do {
  2713. chunker.exec( "" );
  2714. m = chunker.exec( soFar );
  2715. if ( m ) {
  2716. soFar = m[3];
  2717. parts.push( m[1] );
  2718. if ( m[2] ) {
  2719. extra = m[3];
  2720. break;
  2721. }
  2722. }
  2723. } while ( m );
  2724. if ( parts.length > 1 && origPOS.exec( selector ) ) {
  2725. if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
  2726. set = posProcess( parts[0] + parts[1], context );
  2727. } else {
  2728. set = Expr.relative[ parts[0] ] ?
  2729. [ context ] :
  2730. Sizzle( parts.shift(), context );
  2731. while ( parts.length ) {
  2732. selector = parts.shift();
  2733. if ( Expr.relative[ selector ] ) {
  2734. selector += parts.shift();
  2735. }
  2736. set = posProcess( selector, set );
  2737. }
  2738. }
  2739. } else {
  2740. // Take a shortcut and set the context if the root selector is an ID
  2741. // (but not if it'll be faster if the inner selector is an ID)
  2742. if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
  2743. Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
  2744. ret = Sizzle.find( parts.shift(), context, contextXML );
  2745. context = ret.expr ?
  2746. Sizzle.filter( ret.expr, ret.set )[0] :
  2747. ret.set[0];
  2748. }
  2749. if ( context ) {
  2750. ret = seed ?
  2751. { expr: parts.pop(), set: makeArray(seed) } :
  2752. Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
  2753. set = ret.expr ?
  2754. Sizzle.filter( ret.expr, ret.set ) :
  2755. ret.set;
  2756. if ( parts.length > 0 ) {
  2757. checkSet = makeArray( set );
  2758. } else {
  2759. prune = false;
  2760. }
  2761. while ( parts.length ) {
  2762. cur = parts.pop();
  2763. pop = cur;
  2764. if ( !Expr.relative[ cur ] ) {
  2765. cur = "";
  2766. } else {
  2767. pop = parts.pop();
  2768. }
  2769. if ( pop == null ) {
  2770. pop = context;
  2771. }
  2772. Expr.relative[ cur ]( checkSet, pop, contextXML );
  2773. }
  2774. } else {
  2775. checkSet = parts = [];
  2776. }
  2777. }
  2778. if ( !checkSet ) {
  2779. checkSet = set;
  2780. }
  2781. if ( !checkSet ) {
  2782. Sizzle.error( cur || selector );
  2783. }
  2784. if ( toString.call(checkSet) === "[object Array]" ) {
  2785. if ( !prune ) {
  2786. results.push.apply( results, checkSet );
  2787. } else if ( context && context.nodeType === 1 ) {
  2788. for ( i = 0; checkSet[i] != null; i++ ) {
  2789. if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) {
  2790. results.push( set[i] );
  2791. }
  2792. }
  2793. } else {
  2794. for ( i = 0; checkSet[i] != null; i++ ) {
  2795. if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
  2796. results.push( set[i] );
  2797. }
  2798. }
  2799. }
  2800. } else {
  2801. makeArray( checkSet, results );
  2802. }
  2803. if ( extra ) {
  2804. Sizzle( extra, origContext, results, seed );
  2805. Sizzle.uniqueSort( results );
  2806. }
  2807. return results;
  2808. };
  2809. Sizzle.uniqueSort = function( results ) {
  2810. if ( sortOrder ) {
  2811. hasDuplicate = baseHasDuplicate;
  2812. results.sort( sortOrder );
  2813. if ( hasDuplicate ) {
  2814. for ( var i = 1; i < results.length; i++ ) {
  2815. if ( results[i] === results[ i - 1 ] ) {
  2816. results.splice( i--, 1 );
  2817. }
  2818. }
  2819. }
  2820. }
  2821. return results;
  2822. };
  2823. Sizzle.matches = function( expr, set ) {
  2824. return Sizzle( expr, null, null, set );
  2825. };
  2826. Sizzle.matchesSelector = function( node, expr ) {
  2827. return Sizzle( expr, null, null, [node] ).length > 0;
  2828. };
  2829. Sizzle.find = function( expr, context, isXML ) {
  2830. var set;
  2831. if ( !expr ) {
  2832. return [];
  2833. }
  2834. for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
  2835. var match,
  2836. type = Expr.order[i];
  2837. if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
  2838. var left = match[1];
  2839. match.splice( 1, 1 );
  2840. if ( left.substr( left.length - 1 ) !== "\\" ) {
  2841. match[1] = (match[1] || "").replace( rBackslash, "" );
  2842. set = Expr.find[ type ]( match, context, isXML );
  2843. if ( set != null ) {
  2844. expr = expr.replace( Expr.match[ type ], "" );
  2845. break;
  2846. }
  2847. }
  2848. }
  2849. }
  2850. if ( !set ) {
  2851. set = typeof context.getElementsByTagName !== "undefined" ?
  2852. context.getElementsByTagName( "*" ) :
  2853. [];
  2854. }
  2855. return { set: set, expr: expr };
  2856. };
  2857. Sizzle.filter = function( expr, set, inplace, not ) {
  2858. var match, anyFound,
  2859. old = expr,
  2860. result = [],
  2861. curLoop = set,
  2862. isXMLFilter = set && set[0] && Sizzle.isXML( set[0] );
  2863. while ( expr && set.length ) {
  2864. for ( var type in Expr.filter ) {
  2865. if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
  2866. var found, item,
  2867. filter = Expr.filter[ type ],
  2868. left = match[1];
  2869. anyFound = false;
  2870. match.splice(1,1);
  2871. if ( left.substr( left.length - 1 ) === "\\" ) {
  2872. continue;
  2873. }
  2874. if ( curLoop === result ) {
  2875. result = [];
  2876. }
  2877. if ( Expr.preFilter[ type ] ) {
  2878. match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
  2879. if ( !match ) {
  2880. anyFound = found = true;
  2881. } else if ( match === true ) {
  2882. continue;
  2883. }
  2884. }
  2885. if ( match ) {
  2886. for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
  2887. if ( item ) {
  2888. found = filter( item, match, i, curLoop );
  2889. var pass = not ^ !!found;
  2890. if ( inplace && found != null ) {
  2891. if ( pass ) {
  2892. anyFound = true;
  2893. } else {
  2894. curLoop[i] = false;
  2895. }
  2896. } else if ( pass ) {
  2897. result.push( item );
  2898. anyFound = true;
  2899. }
  2900. }
  2901. }
  2902. }
  2903. if ( found !== undefined ) {
  2904. if ( !inplace ) {
  2905. curLoop = result;
  2906. }
  2907. expr = expr.replace( Expr.match[ type ], "" );
  2908. if ( !anyFound ) {
  2909. return [];
  2910. }
  2911. break;
  2912. }
  2913. }
  2914. }
  2915. // Improper expression
  2916. if ( expr === old ) {
  2917. if ( anyFound == null ) {
  2918. Sizzle.error( expr );
  2919. } else {
  2920. break;
  2921. }
  2922. }
  2923. old = expr;
  2924. }
  2925. return curLoop;
  2926. };
  2927. Sizzle.error = function( msg ) {
  2928. throw "Syntax error, unrecognized expression: " + msg;
  2929. };
  2930. var Expr = Sizzle.selectors = {
  2931. order: [ "ID", "NAME", "TAG" ],
  2932. match: {
  2933. ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
  2934. CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
  2935. NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,
  2936. ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,
  2937. TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,
  2938. CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,
  2939. POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,
  2940. PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
  2941. },
  2942. leftMatch: {},
  2943. attrMap: {
  2944. "class": "className",
  2945. "for": "htmlFor"
  2946. },
  2947. attrHandle: {
  2948. href: function( elem ) {
  2949. return elem.getAttribute( "href" );
  2950. },
  2951. type: function( elem ) {
  2952. return elem.getAttribute( "type" );
  2953. }
  2954. },
  2955. relative: {
  2956. "+": function(checkSet, part){
  2957. var isPartStr = typeof part === "string",
  2958. isTag = isPartStr && !rNonWord.test( part ),
  2959. isPartStrNotTag = isPartStr && !isTag;
  2960. if ( isTag ) {
  2961. part = part.toLowerCase();
  2962. }
  2963. for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
  2964. if ( (elem = checkSet[i]) ) {
  2965. while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
  2966. checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
  2967. elem || false :
  2968. elem === part;
  2969. }
  2970. }
  2971. if ( isPartStrNotTag ) {
  2972. Sizzle.filter( part, checkSet, true );
  2973. }
  2974. },
  2975. ">": function( checkSet, part ) {
  2976. var elem,
  2977. isPartStr = typeof part === "string",
  2978. i = 0,
  2979. l = checkSet.length;
  2980. if ( isPartStr && !rNonWord.test( part ) ) {
  2981. part = part.toLowerCase();
  2982. for ( ; i < l; i++ ) {
  2983. elem = checkSet[i];
  2984. if ( elem ) {
  2985. var parent = elem.parentNode;
  2986. checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
  2987. }
  2988. }
  2989. } else {
  2990. for ( ; i < l; i++ ) {
  2991. elem = checkSet[i];
  2992. if ( elem ) {
  2993. checkSet[i] = isPartStr ?
  2994. elem.parentNode :
  2995. elem.parentNode === part;
  2996. }
  2997. }
  2998. if ( isPartStr ) {
  2999. Sizzle.filter( part, checkSet, true );
  3000. }
  3001. }
  3002. },
  3003. "": function(checkSet, part, isXML){
  3004. var nodeCheck,
  3005. doneName = done++,
  3006. checkFn = dirCheck;
  3007. if ( typeof part === "string" && !rNonWord.test( part ) ) {
  3008. part = part.toLowerCase();
  3009. nodeCheck = part;
  3010. checkFn = dirNodeCheck;
  3011. }
  3012. checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML );
  3013. },
  3014. "~": function( checkSet, part, isXML ) {
  3015. var nodeCheck,
  3016. doneName = done++,
  3017. checkFn = dirCheck;
  3018. if ( typeof part === "string" && !rNonWord.test( part ) ) {
  3019. part = part.toLowerCase();
  3020. nodeCheck = part;
  3021. checkFn = dirNodeCheck;
  3022. }
  3023. checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML );
  3024. }
  3025. },
  3026. find: {
  3027. ID: function( match, context, isXML ) {
  3028. if ( typeof context.getElementById !== "undefined" && !isXML ) {
  3029. var m = context.getElementById(match[1]);
  3030. // Check parentNode to catch when Blackberry 4.6 returns
  3031. // nodes that are no longer in the document #6963
  3032. return m && m.parentNode ? [m] : [];
  3033. }
  3034. },
  3035. NAME: function( match, context ) {
  3036. if ( typeof context.getElementsByName !== "undefined" ) {
  3037. var ret = [],
  3038. results = context.getElementsByName( match[1] );
  3039. for ( var i = 0, l = results.length; i < l; i++ ) {
  3040. if ( results[i].getAttribute("name") === match[1] ) {
  3041. ret.push( results[i] );
  3042. }
  3043. }
  3044. return ret.length === 0 ? null : ret;
  3045. }
  3046. },
  3047. TAG: function( match, context ) {
  3048. if ( typeof context.getElementsByTagName !== "undefined" ) {
  3049. return context.getElementsByTagName( match[1] );
  3050. }
  3051. }
  3052. },
  3053. preFilter: {
  3054. CLASS: function( match, curLoop, inplace, result, not, isXML ) {
  3055. match = " " + match[1].replace( rBackslash, "" ) + " ";
  3056. if ( isXML ) {
  3057. return match;
  3058. }
  3059. for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
  3060. if ( elem ) {
  3061. if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) {
  3062. if ( !inplace ) {
  3063. result.push( elem );
  3064. }
  3065. } else if ( inplace ) {
  3066. curLoop[i] = false;
  3067. }
  3068. }
  3069. }
  3070. return false;
  3071. },
  3072. ID: function( match ) {
  3073. return match[1].replace( rBackslash, "" );
  3074. },
  3075. TAG: function( match, curLoop ) {
  3076. return match[1].replace( rBackslash, "" ).toLowerCase();
  3077. },
  3078. CHILD: function( match ) {
  3079. if ( match[1] === "nth" ) {
  3080. if ( !match[2] ) {
  3081. Sizzle.error( match[0] );
  3082. }
  3083. match[2] = match[2].replace(/^\+|\s*/g, '');
  3084. // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
  3085. var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec(
  3086. match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
  3087. !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
  3088. // calculate the numbers (first)n+(last) including if they are negative
  3089. match[2] = (test[1] + (test[2] || 1)) - 0;
  3090. match[3] = test[3] - 0;
  3091. }
  3092. else if ( match[2] ) {
  3093. Sizzle.error( match[0] );
  3094. }
  3095. // TODO: Move to normal caching system
  3096. match[0] = done++;
  3097. return match;
  3098. },
  3099. ATTR: function( match, curLoop, inplace, result, not, isXML ) {
  3100. var name = match[1] = match[1].replace( rBackslash, "" );
  3101. if ( !isXML && Expr.attrMap[name] ) {
  3102. match[1] = Expr.attrMap[name];
  3103. }
  3104. // Handle if an un-quoted value was used
  3105. match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" );
  3106. if ( match[2] === "~=" ) {
  3107. match[4] = " " + match[4] + " ";
  3108. }
  3109. return match;
  3110. },
  3111. PSEUDO: function( match, curLoop, inplace, result, not ) {
  3112. if ( match[1] === "not" ) {
  3113. // If we're dealing with a complex expression, or a simple one
  3114. if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
  3115. match[3] = Sizzle(match[3], null, null, curLoop);
  3116. } else {
  3117. var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
  3118. if ( !inplace ) {
  3119. result.push.apply( result, ret );
  3120. }
  3121. return false;
  3122. }
  3123. } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
  3124. return true;
  3125. }
  3126. return match;
  3127. },
  3128. POS: function( match ) {
  3129. match.unshift( true );
  3130. return match;
  3131. }
  3132. },
  3133. filters: {
  3134. enabled: function( elem ) {
  3135. return elem.disabled === false && elem.type !== "hidden";
  3136. },
  3137. disabled: function( elem ) {
  3138. return elem.disabled === true;
  3139. },
  3140. checked: function( elem ) {
  3141. return elem.checked === true;
  3142. },
  3143. selected: function( elem ) {
  3144. // Accessing this property makes selected-by-default
  3145. // options in Safari work properly
  3146. if ( elem.parentNode ) {
  3147. elem.parentNode.selectedIndex;
  3148. }
  3149. return elem.selected === true;
  3150. },
  3151. parent: function( elem ) {
  3152. return !!elem.firstChild;
  3153. },
  3154. empty: function( elem ) {
  3155. return !elem.firstChild;
  3156. },
  3157. has: function( elem, i, match ) {
  3158. return !!Sizzle( match[3], elem ).length;
  3159. },
  3160. header: function( elem ) {
  3161. return (/h\d/i).test( elem.nodeName );
  3162. },
  3163. text: function( elem ) {
  3164. var attr = elem.getAttribute( "type" ), type = elem.type;
  3165. // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
  3166. // use getAttribute instead to test this case
  3167. return "text" === type && ( attr === type || attr === null );
  3168. },
  3169. radio: function( elem ) {
  3170. return "radio" === elem.type;
  3171. },
  3172. checkbox: function( elem ) {
  3173. return "checkbox" === elem.type;
  3174. },
  3175. file: function( elem ) {
  3176. return "file" === elem.type;
  3177. },
  3178. password: function( elem ) {
  3179. return "password" === elem.type;
  3180. },
  3181. submit: function( elem ) {
  3182. return "submit" === elem.type;
  3183. },
  3184. image: function( elem ) {
  3185. return "image" === elem.type;
  3186. },
  3187. reset: function( elem ) {
  3188. return "reset" === elem.type;
  3189. },
  3190. button: function( elem ) {
  3191. return "button" === elem.type || elem.nodeName.toLowerCase() === "button";
  3192. },
  3193. input: function( elem ) {
  3194. return (/input|select|textarea|button/i).test( elem.nodeName );
  3195. }
  3196. },
  3197. setFilters: {
  3198. first: function( elem, i ) {
  3199. return i === 0;
  3200. },
  3201. last: function( elem, i, match, array ) {
  3202. return i === array.length - 1;
  3203. },
  3204. even: function( elem, i ) {
  3205. return i % 2 === 0;
  3206. },
  3207. odd: function( elem, i ) {
  3208. return i % 2 === 1;
  3209. },
  3210. lt: function( elem, i, match ) {
  3211. return i < match[3] - 0;
  3212. },
  3213. gt: function( elem, i, match ) {
  3214. return i > match[3] - 0;
  3215. },
  3216. nth: function( elem, i, match ) {
  3217. return match[3] - 0 === i;
  3218. },
  3219. eq: function( elem, i, match ) {
  3220. return match[3] - 0 === i;
  3221. }
  3222. },
  3223. filter: {
  3224. PSEUDO: function( elem, match, i, array ) {
  3225. var name = match[1],
  3226. filter = Expr.filters[ name ];
  3227. if ( filter ) {
  3228. return filter( elem, i, match, array );
  3229. } else if ( name === "contains" ) {
  3230. return (elem.textContent || elem.innerText || Sizzle.getText([ elem ]) || "").indexOf(match[3]) >= 0;
  3231. } else if ( name === "not" ) {
  3232. var not = match[3];
  3233. for ( var j = 0, l = not.length; j < l; j++ ) {
  3234. if ( not[j] === elem ) {
  3235. return false;
  3236. }
  3237. }
  3238. return true;
  3239. } else {
  3240. Sizzle.error( name );
  3241. }
  3242. },
  3243. CHILD: function( elem, match ) {
  3244. var type = match[1],
  3245. node = elem;
  3246. switch ( type ) {
  3247. case "only":
  3248. case "first":
  3249. while ( (node = node.previousSibling) ) {
  3250. if ( node.nodeType === 1 ) {
  3251. return false;
  3252. }
  3253. }
  3254. if ( type === "first" ) {
  3255. return true;
  3256. }
  3257. node = elem;
  3258. case "last":
  3259. while ( (node = node.nextSibling) ) {
  3260. if ( node.nodeType === 1 ) {
  3261. return false;
  3262. }
  3263. }
  3264. return true;
  3265. case "nth":
  3266. var first = match[2],
  3267. last = match[3];
  3268. if ( first === 1 && last === 0 ) {
  3269. return true;
  3270. }
  3271. var doneName = match[0],
  3272. parent = elem.parentNode;
  3273. if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
  3274. var count = 0;
  3275. for ( node = parent.firstChild; node; node = node.nextSibling ) {
  3276. if ( node.nodeType === 1 ) {
  3277. node.nodeIndex = ++count;
  3278. }
  3279. }
  3280. parent.sizcache = doneName;
  3281. }
  3282. var diff = elem.nodeIndex - last;
  3283. if ( first === 0 ) {
  3284. return diff === 0;
  3285. } else {
  3286. return ( diff % first === 0 && diff / first >= 0 );
  3287. }
  3288. }
  3289. },
  3290. ID: function( elem, match ) {
  3291. return elem.nodeType === 1 && elem.getAttribute("id") === match;
  3292. },
  3293. TAG: function( elem, match ) {
  3294. return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
  3295. },
  3296. CLASS: function( elem, match ) {
  3297. return (" " + (elem.className || elem.getAttribute("class")) + " ")
  3298. .indexOf( match ) > -1;
  3299. },
  3300. ATTR: function( elem, match ) {
  3301. var name = match[1],
  3302. result = Expr.attrHandle[ name ] ?
  3303. Expr.attrHandle[ name ]( elem ) :
  3304. elem[ name ] != null ?
  3305. elem[ name ] :
  3306. elem.getAttribute( name ),
  3307. value = result + "",
  3308. type = match[2],
  3309. check = match[4];
  3310. return result == null ?
  3311. type === "!=" :
  3312. type === "=" ?
  3313. value === check :
  3314. type === "*=" ?
  3315. value.indexOf(check) >= 0 :
  3316. type === "~=" ?
  3317. (" " + value + " ").indexOf(check) >= 0 :
  3318. !check ?
  3319. value && result !== false :
  3320. type === "!=" ?
  3321. value !== check :
  3322. type === "^=" ?
  3323. value.indexOf(check) === 0 :
  3324. type === "$=" ?
  3325. value.substr(value.length - check.length) === check :
  3326. type === "|=" ?
  3327. value === check || value.substr(0, check.length + 1) === check + "-" :
  3328. false;
  3329. },
  3330. POS: function( elem, match, i, array ) {
  3331. var name = match[2],
  3332. filter = Expr.setFilters[ name ];
  3333. if ( filter ) {
  3334. return filter( elem, i, match, array );
  3335. }
  3336. }
  3337. }
  3338. };
  3339. var origPOS = Expr.match.POS,
  3340. fescape = function(all, num){
  3341. return "\\" + (num - 0 + 1);
  3342. };
  3343. for ( var type in Expr.match ) {
  3344. Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) );
  3345. Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) );
  3346. }
  3347. var makeArray = function( array, results ) {
  3348. array = Array.prototype.slice.call( array, 0 );
  3349. if ( results ) {
  3350. results.push.apply( results, array );
  3351. return results;
  3352. }
  3353. return array;
  3354. };
  3355. // Perform a simple check to determine if the browser is capable of
  3356. // converting a NodeList to an array using builtin methods.
  3357. // Also verifies that the returned array holds DOM nodes
  3358. // (which is not the case in the Blackberry browser)
  3359. try {
  3360. Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType;
  3361. // Provide a fallback method if it does not work
  3362. } catch( e ) {
  3363. makeArray = function( array, results ) {
  3364. var i = 0,
  3365. ret = results || [];
  3366. if ( toString.call(array) === "[object Array]" ) {
  3367. Array.prototype.push.apply( ret, array );
  3368. } else {
  3369. if ( typeof array.length === "number" ) {
  3370. for ( var l = array.length; i < l; i++ ) {
  3371. ret.push( array[i] );
  3372. }
  3373. } else {
  3374. for ( ; array[i]; i++ ) {
  3375. ret.push( array[i] );
  3376. }
  3377. }
  3378. }
  3379. return ret;
  3380. };
  3381. }
  3382. var sortOrder, siblingCheck;
  3383. if ( document.documentElement.compareDocumentPosition ) {
  3384. sortOrder = function( a, b ) {
  3385. if ( a === b ) {
  3386. hasDuplicate = true;
  3387. return 0;
  3388. }
  3389. if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
  3390. return a.compareDocumentPosition ? -1 : 1;
  3391. }
  3392. return a.compareDocumentPosition(b) & 4 ? -1 : 1;
  3393. };
  3394. } else {
  3395. sortOrder = function( a, b ) {
  3396. var al, bl,
  3397. ap = [],
  3398. bp = [],
  3399. aup = a.parentNode,
  3400. bup = b.parentNode,
  3401. cur = aup;
  3402. // The nodes are identical, we can exit early
  3403. if ( a === b ) {
  3404. hasDuplicate = true;
  3405. return 0;
  3406. // If the nodes are siblings (or identical) we can do a quick check
  3407. } else if ( aup === bup ) {
  3408. return siblingCheck( a, b );
  3409. // If no parents were found then the nodes are disconnected
  3410. } else if ( !aup ) {
  3411. return -1;
  3412. } else if ( !bup ) {
  3413. return 1;
  3414. }
  3415. // Otherwise they're somewhere else in the tree so we need
  3416. // to build up a full list of the parentNodes for comparison
  3417. while ( cur ) {
  3418. ap.unshift( cur );
  3419. cur = cur.parentNode;
  3420. }
  3421. cur = bup;
  3422. while ( cur ) {
  3423. bp.unshift( cur );
  3424. cur = cur.parentNode;
  3425. }
  3426. al = ap.length;
  3427. bl = bp.length;
  3428. // Start walking down the tree looking for a discrepancy
  3429. for ( var i = 0; i < al && i < bl; i++ ) {
  3430. if ( ap[i] !== bp[i] ) {
  3431. return siblingCheck( ap[i], bp[i] );
  3432. }
  3433. }
  3434. // We ended someplace up the tree so do a sibling check
  3435. return i === al ?
  3436. siblingCheck( a, bp[i], -1 ) :
  3437. siblingCheck( ap[i], b, 1 );
  3438. };
  3439. siblingCheck = function( a, b, ret ) {
  3440. if ( a === b ) {
  3441. return ret;
  3442. }
  3443. var cur = a.nextSibling;
  3444. while ( cur ) {
  3445. if ( cur === b ) {
  3446. return -1;
  3447. }
  3448. cur = cur.nextSibling;
  3449. }
  3450. return 1;
  3451. };
  3452. }
  3453. // Utility function for retreiving the text value of an array of DOM nodes
  3454. Sizzle.getText = function( elems ) {
  3455. var ret = "", elem;
  3456. for ( var i = 0; elems[i]; i++ ) {
  3457. elem = elems[i];
  3458. // Get the text from text nodes and CDATA nodes
  3459. if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
  3460. ret += elem.nodeValue;
  3461. // Traverse everything else, except comment nodes
  3462. } else if ( elem.nodeType !== 8 ) {
  3463. ret += Sizzle.getText( elem.childNodes );
  3464. }
  3465. }
  3466. return ret;
  3467. };
  3468. // Check to see if the browser returns elements by name when
  3469. // querying by getElementById (and provide a workaround)
  3470. (function(){
  3471. // We're going to inject a fake input element with a specified name
  3472. var form = document.createElement("div"),
  3473. id = "script" + (new Date()).getTime(),
  3474. root = document.documentElement;
  3475. form.innerHTML = "<a name='" + id + "'/>";
  3476. // Inject it into the root element, check its status, and remove it quickly
  3477. root.insertBefore( form, root.firstChild );
  3478. // The workaround has to do additional checks after a getElementById
  3479. // Which slows things down for other browsers (hence the branching)
  3480. if ( document.getElementById( id ) ) {
  3481. Expr.find.ID = function( match, context, isXML ) {
  3482. if ( typeof context.getElementById !== "undefined" && !isXML ) {
  3483. var m = context.getElementById(match[1]);
  3484. return m ?
  3485. m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ?
  3486. [m] :
  3487. undefined :
  3488. [];
  3489. }
  3490. };
  3491. Expr.filter.ID = function( elem, match ) {
  3492. var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
  3493. return elem.nodeType === 1 && node && node.nodeValue === match;
  3494. };
  3495. }
  3496. root.removeChild( form );
  3497. // release memory in IE
  3498. root = form = null;
  3499. })();
  3500. (function(){
  3501. // Check to see if the browser returns only elements
  3502. // when doing getElementsByTagName("*")
  3503. // Create a fake element
  3504. var div = document.createElement("div");
  3505. div.appendChild( document.createComment("") );
  3506. // Make sure no comments are found
  3507. if ( div.getElementsByTagName("*").length > 0 ) {
  3508. Expr.find.TAG = function( match, context ) {
  3509. var results = context.getElementsByTagName( match[1] );
  3510. // Filter out possible comments
  3511. if ( match[1] === "*" ) {
  3512. var tmp = [];
  3513. for ( var i = 0; results[i]; i++ ) {
  3514. if ( results[i].nodeType === 1 ) {
  3515. tmp.push( results[i] );
  3516. }
  3517. }
  3518. results = tmp;
  3519. }
  3520. return results;
  3521. };
  3522. }
  3523. // Check to see if an attribute returns normalized href attributes
  3524. div.innerHTML = "<a href='#'></a>";
  3525. if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
  3526. div.firstChild.getAttribute("href") !== "#" ) {
  3527. Expr.attrHandle.href = function( elem ) {
  3528. return elem.getAttribute( "href", 2 );
  3529. };
  3530. }
  3531. // release memory in IE
  3532. div = null;
  3533. })();
  3534. if ( document.querySelectorAll ) {
  3535. (function(){
  3536. var oldSizzle = Sizzle,
  3537. div = document.createElement("div"),
  3538. id = "__sizzle__";
  3539. div.innerHTML = "<p class='TEST'></p>";
  3540. // Safari can't handle uppercase or unicode characters when
  3541. // in quirks mode.
  3542. if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
  3543. return;
  3544. }
  3545. Sizzle = function( query, context, extra, seed ) {
  3546. context = context || document;
  3547. // Only use querySelectorAll on non-XML documents
  3548. // (ID selectors don't work in non-HTML documents)
  3549. if ( !seed && !Sizzle.isXML(context) ) {
  3550. // See if we find a selector to speed up
  3551. var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query );
  3552. if ( match && (context.nodeType === 1 || context.nodeType === 9) ) {
  3553. // Speed-up: Sizzle("TAG")
  3554. if ( match[1] ) {
  3555. return makeArray( context.getElementsByTagName( query ), extra );
  3556. // Speed-up: Sizzle(".CLASS")
  3557. } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) {
  3558. return makeArray( context.getElementsByClassName( match[2] ), extra );
  3559. }
  3560. }
  3561. if ( context.nodeType === 9 ) {
  3562. // Speed-up: Sizzle("body")
  3563. // The body element only exists once, optimize finding it
  3564. if ( query === "body" && context.body ) {
  3565. return makeArray( [ context.body ], extra );
  3566. // Speed-up: Sizzle("#ID")
  3567. } else if ( match && match[3] ) {
  3568. var elem = context.getElementById( match[3] );
  3569. // Check parentNode to catch when Blackberry 4.6 returns
  3570. // nodes that are no longer in the document #6963
  3571. if ( elem && elem.parentNode ) {
  3572. // Handle the case where IE and Opera return items
  3573. // by name instead of ID
  3574. if ( elem.id === match[3] ) {
  3575. return makeArray( [ elem ], extra );
  3576. }
  3577. } else {
  3578. return makeArray( [], extra );
  3579. }
  3580. }
  3581. try {
  3582. return makeArray( context.querySelectorAll(query), extra );
  3583. } catch(qsaError) {}
  3584. // qSA works strangely on Element-rooted queries
  3585. // We can work around this by specifying an extra ID on the root
  3586. // and working up from there (Thanks to Andrew Dupont for the technique)
  3587. // IE 8 doesn't work on object elements
  3588. } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
  3589. var oldContext = context,
  3590. old = context.getAttribute( "id" ),
  3591. nid = old || id,
  3592. hasParent = context.parentNode,
  3593. relativeHierarchySelector = /^\s*[+~]/.test( query );
  3594. if ( !old ) {
  3595. context.setAttribute( "id", nid );
  3596. } else {
  3597. nid = nid.replace( /'/g, "\\$&" );
  3598. }
  3599. if ( relativeHierarchySelector && hasParent ) {
  3600. context = context.parentNode;
  3601. }
  3602. try {
  3603. if ( !relativeHierarchySelector || hasParent ) {
  3604. return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra );
  3605. }
  3606. } catch(pseudoError) {
  3607. } finally {
  3608. if ( !old ) {
  3609. oldContext.removeAttribute( "id" );
  3610. }
  3611. }
  3612. }
  3613. }
  3614. return oldSizzle(query, context, extra, seed);
  3615. };
  3616. for ( var prop in oldSizzle ) {
  3617. Sizzle[ prop ] = oldSizzle[ prop ];
  3618. }
  3619. // release memory in IE
  3620. div = null;
  3621. })();
  3622. }
  3623. (function(){
  3624. var html = document.documentElement,
  3625. matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector;
  3626. if ( matches ) {
  3627. // Check to see if it's possible to do matchesSelector
  3628. // on a disconnected node (IE 9 fails this)
  3629. var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ),
  3630. pseudoWorks = false;
  3631. try {
  3632. // This should fail with an exception
  3633. // Gecko does not error, returns false instead
  3634. matches.call( document.documentElement, "[test!='']:sizzle" );
  3635. } catch( pseudoError ) {
  3636. pseudoWorks = true;
  3637. }
  3638. Sizzle.matchesSelector = function( node, expr ) {
  3639. // Make sure that attribute selectors are quoted
  3640. expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
  3641. if ( !Sizzle.isXML( node ) ) {
  3642. try {
  3643. if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) {
  3644. var ret = matches.call( node, expr );
  3645. // IE 9's matchesSelector returns false on disconnected nodes
  3646. if ( ret || !disconnectedMatch ||
  3647. // As well, disconnected nodes are said to be in a document
  3648. // fragment in IE 9, so check for that
  3649. node.document && node.document.nodeType !== 11 ) {
  3650. return ret;
  3651. }
  3652. }
  3653. } catch(e) {}
  3654. }
  3655. return Sizzle(expr, null, null, [node]).length > 0;
  3656. };
  3657. }
  3658. })();
  3659. (function(){
  3660. var div = document.createElement("div");
  3661. div.innerHTML = "<div class='test e'></div><div class='test'></div>";
  3662. // Opera can't find a second classname (in 9.6)
  3663. // Also, make sure that getElementsByClassName actually exists
  3664. if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
  3665. return;
  3666. }
  3667. // Safari caches class attributes, doesn't catch changes (in 3.2)
  3668. div.lastChild.className = "e";
  3669. if ( div.getElementsByClassName("e").length === 1 ) {
  3670. return;
  3671. }
  3672. Expr.order.splice(1, 0, "CLASS");
  3673. Expr.find.CLASS = function( match, context, isXML ) {
  3674. if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
  3675. return context.getElementsByClassName(match[1]);
  3676. }
  3677. };
  3678. // release memory in IE
  3679. div = null;
  3680. })();
  3681. function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
  3682. for ( var i = 0, l = checkSet.length; i < l; i++ ) {
  3683. var elem = checkSet[i];
  3684. if ( elem ) {
  3685. var match = false;
  3686. elem = elem[dir];
  3687. while ( elem ) {
  3688. if ( elem.sizcache === doneName ) {
  3689. match = checkSet[elem.sizset];
  3690. break;
  3691. }
  3692. if ( elem.nodeType === 1 && !isXML ){
  3693. elem.sizcache = doneName;
  3694. elem.sizset = i;
  3695. }
  3696. if ( elem.nodeName.toLowerCase() === cur ) {
  3697. match = elem;
  3698. break;
  3699. }
  3700. elem = elem[dir];
  3701. }
  3702. checkSet[i] = match;
  3703. }
  3704. }
  3705. }
  3706. function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
  3707. for ( var i = 0, l = checkSet.length; i < l; i++ ) {
  3708. var elem = checkSet[i];
  3709. if ( elem ) {
  3710. var match = false;
  3711. elem = elem[dir];
  3712. while ( elem ) {
  3713. if ( elem.sizcache === doneName ) {
  3714. match = checkSet[elem.sizset];
  3715. break;
  3716. }
  3717. if ( elem.nodeType === 1 ) {
  3718. if ( !isXML ) {
  3719. elem.sizcache = doneName;
  3720. elem.sizset = i;
  3721. }
  3722. if ( typeof cur !== "string" ) {
  3723. if ( elem === cur ) {
  3724. match = true;
  3725. break;
  3726. }
  3727. } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
  3728. match = elem;
  3729. break;
  3730. }
  3731. }
  3732. elem = elem[dir];
  3733. }
  3734. checkSet[i] = match;
  3735. }
  3736. }
  3737. }
  3738. if ( document.documentElement.contains ) {
  3739. Sizzle.contains = function( a, b ) {
  3740. return a !== b && (a.contains ? a.contains(b) : true);
  3741. };
  3742. } else if ( document.documentElement.compareDocumentPosition ) {
  3743. Sizzle.contains = function( a, b ) {
  3744. return !!(a.compareDocumentPosition(b) & 16);
  3745. };
  3746. } else {
  3747. Sizzle.contains = function() {
  3748. return false;
  3749. };
  3750. }
  3751. Sizzle.isXML = function( elem ) {
  3752. // documentElement is verified for cases where it doesn't yet exist
  3753. // (such as loading iframes in IE - #4833)
  3754. var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
  3755. return documentElement ? documentElement.nodeName !== "HTML" : false;
  3756. };
  3757. var posProcess = function( selector, context ) {
  3758. var match,
  3759. tmpSet = [],
  3760. later = "",
  3761. root = context.nodeType ? [context] : context;
  3762. // Position selectors must be done after the filter
  3763. // And so must :not(positional) so we move all PSEUDOs to the end
  3764. while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
  3765. later += match[0];
  3766. selector = selector.replace( Expr.match.PSEUDO, "" );
  3767. }
  3768. selector = Expr.relative[selector] ? selector + "*" : selector;
  3769. for ( var i = 0, l = root.length; i < l; i++ ) {
  3770. Sizzle( selector, root[i], tmpSet );
  3771. }
  3772. return Sizzle.filter( later, tmpSet );
  3773. };
  3774. // EXPOSE
  3775. jQuery.find = Sizzle;
  3776. jQuery.expr = Sizzle.selectors;
  3777. jQuery.expr[":"] = jQuery.expr.filters;
  3778. jQuery.unique = Sizzle.uniqueSort;
  3779. jQuery.text = Sizzle.getText;
  3780. jQuery.isXMLDoc = Sizzle.isXML;
  3781. jQuery.contains = Sizzle.contains;
  3782. })();
  3783. var runtil = /Until$/,
  3784. rparentsprev = /^(?:parents|prevUntil|prevAll)/,
  3785. // Note: This RegExp should be improved, or likely pulled from Sizzle
  3786. rmultiselector = /,/,
  3787. isSimple = /^.[^:#\[\.,]*$/,
  3788. slice = Array.prototype.slice,
  3789. POS = jQuery.expr.match.POS,
  3790. // methods guaranteed to produce a unique set when starting from a unique set
  3791. guaranteedUnique = {
  3792. children: true,
  3793. contents: true,
  3794. next: true,
  3795. prev: true
  3796. };
  3797. jQuery.fn.extend({
  3798. find: function( selector ) {
  3799. var ret = this.pushStack( "", "find", selector ),
  3800. length = 0;
  3801. for ( var i = 0, l = this.length; i < l; i++ ) {
  3802. length = ret.length;
  3803. jQuery.find( selector, this[i], ret );
  3804. if ( i > 0 ) {
  3805. // Make sure that the results are unique
  3806. for ( var n = length; n < ret.length; n++ ) {
  3807. for ( var r = 0; r < length; r++ ) {
  3808. if ( ret[r] === ret[n] ) {
  3809. ret.splice(n--, 1);
  3810. break;
  3811. }
  3812. }
  3813. }
  3814. }
  3815. }
  3816. return ret;
  3817. },
  3818. has: function( target ) {
  3819. var targets = jQuery( target );
  3820. return this.filter(function() {
  3821. for ( var i = 0, l = targets.length; i < l; i++ ) {
  3822. if ( jQuery.contains( this, targets[i] ) ) {
  3823. return true;
  3824. }
  3825. }
  3826. });
  3827. },
  3828. not: function( selector ) {
  3829. return this.pushStack( winnow(this, selector, false), "not", selector);
  3830. },
  3831. filter: function( selector ) {
  3832. return this.pushStack( winnow(this, selector, true), "filter", selector );
  3833. },
  3834. is: function( selector ) {
  3835. return !!selector && jQuery.filter( selector, this ).length > 0;
  3836. },
  3837. closest: function( selectors, context ) {
  3838. var ret = [], i, l, cur = this[0];
  3839. if ( jQuery.isArray( selectors ) ) {
  3840. var match, selector,
  3841. matches = {},
  3842. level = 1;
  3843. if ( cur && selectors.length ) {
  3844. for ( i = 0, l = selectors.length; i < l; i++ ) {
  3845. selector = selectors[i];
  3846. if ( !matches[selector] ) {
  3847. matches[selector] = jQuery.expr.match.POS.test( selector ) ?
  3848. jQuery( selector, context || this.context ) :
  3849. selector;
  3850. }
  3851. }
  3852. while ( cur && cur.ownerDocument && cur !== context ) {
  3853. for ( selector in matches ) {
  3854. match = matches[selector];
  3855. if ( match.jquery ? match.index(cur) > -1 : jQuery(cur).is(match) ) {
  3856. ret.push({ selector: selector, elem: cur, level: level });
  3857. }
  3858. }
  3859. cur = cur.parentNode;
  3860. level++;
  3861. }
  3862. }
  3863. return ret;
  3864. }
  3865. var pos = POS.test( selectors ) ?
  3866. jQuery( selectors, context || this.context ) : null;
  3867. for ( i = 0, l = this.length; i < l; i++ ) {
  3868. cur = this[i];
  3869. while ( cur ) {
  3870. if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
  3871. ret.push( cur );
  3872. break;
  3873. } else {
  3874. cur = cur.parentNode;
  3875. if ( !cur || !cur.ownerDocument || cur === context ) {
  3876. break;
  3877. }
  3878. }
  3879. }
  3880. }
  3881. ret = ret.length > 1 ? jQuery.unique(ret) : ret;
  3882. return this.pushStack( ret, "closest", selectors );
  3883. },
  3884. // Determine the position of an element within
  3885. // the matched set of elements
  3886. index: function( elem ) {
  3887. if ( !elem || typeof elem === "string" ) {
  3888. return jQuery.inArray( this[0],
  3889. // If it receives a string, the selector is used
  3890. // If it receives nothing, the siblings are used
  3891. elem ? jQuery( elem ) : this.parent().children() );
  3892. }
  3893. // Locate the position of the desired element
  3894. return jQuery.inArray(
  3895. // If it receives a jQuery object, the first element is used
  3896. elem.jquery ? elem[0] : elem, this );
  3897. },
  3898. add: function( selector, context ) {
  3899. var set = typeof selector === "string" ?
  3900. jQuery( selector, context ) :
  3901. jQuery.makeArray( selector ),
  3902. all = jQuery.merge( this.get(), set );
  3903. return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
  3904. all :
  3905. jQuery.unique( all ) );
  3906. },
  3907. andSelf: function() {
  3908. return this.add( this.prevObject );
  3909. }
  3910. });
  3911. // A painfully simple check to see if an element is disconnected
  3912. // from a document (should be improved, where feasible).
  3913. function isDisconnected( node ) {
  3914. return !node || !node.parentNode || node.parentNode.nodeType === 11;
  3915. }
  3916. jQuery.each({
  3917. parent: function( elem ) {
  3918. var parent = elem.parentNode;
  3919. return parent && parent.nodeType !== 11 ? parent : null;
  3920. },
  3921. parents: function( elem ) {
  3922. return jQuery.dir( elem, "parentNode" );
  3923. },
  3924. parentsUntil: function( elem, i, until ) {
  3925. return jQuery.dir( elem, "parentNode", until );
  3926. },
  3927. next: function( elem ) {
  3928. return jQuery.nth( elem, 2, "nextSibling" );
  3929. },
  3930. prev: function( elem ) {
  3931. return jQuery.nth( elem, 2, "previousSibling" );
  3932. },
  3933. nextAll: function( elem ) {
  3934. return jQuery.dir( elem, "nextSibling" );
  3935. },
  3936. prevAll: function( elem ) {
  3937. return jQuery.dir( elem, "previousSibling" );
  3938. },
  3939. nextUntil: function( elem, i, until ) {
  3940. return jQuery.dir( elem, "nextSibling", until );
  3941. },
  3942. prevUntil: function( elem, i, until ) {
  3943. return jQuery.dir( elem, "previousSibling", until );
  3944. },
  3945. siblings: function( elem ) {
  3946. return jQuery.sibling( elem.parentNode.firstChild, elem );
  3947. },
  3948. children: function( elem ) {
  3949. return jQuery.sibling( elem.firstChild );
  3950. },
  3951. contents: function( elem ) {
  3952. return jQuery.nodeName( elem, "iframe" ) ?
  3953. elem.contentDocument || elem.contentWindow.document :
  3954. jQuery.makeArray( elem.childNodes );
  3955. }
  3956. }, function( name, fn ) {
  3957. jQuery.fn[ name ] = function( until, selector ) {
  3958. var ret = jQuery.map( this, fn, until ),
  3959. // The variable 'args' was introduced in
  3960. // https://github.com/jquery/jquery/commit/52a0238
  3961. // to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed.
  3962. // http://code.google.com/p/v8/issues/detail?id=1050
  3963. args = slice.call(arguments);
  3964. if ( !runtil.test( name ) ) {
  3965. selector = until;
  3966. }
  3967. if ( selector && typeof selector === "string" ) {
  3968. ret = jQuery.filter( selector, ret );
  3969. }
  3970. ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret;
  3971. if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
  3972. ret = ret.reverse();
  3973. }
  3974. return this.pushStack( ret, name, args.join(",") );
  3975. };
  3976. });
  3977. jQuery.extend({
  3978. filter: function( expr, elems, not ) {
  3979. if ( not ) {
  3980. expr = ":not(" + expr + ")";
  3981. }
  3982. return elems.length === 1 ?
  3983. jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
  3984. jQuery.find.matches(expr, elems);
  3985. },
  3986. dir: function( elem, dir, until ) {
  3987. var matched = [],
  3988. cur = elem[ dir ];
  3989. while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
  3990. if ( cur.nodeType === 1 ) {
  3991. matched.push( cur );
  3992. }
  3993. cur = cur[dir];
  3994. }
  3995. return matched;
  3996. },
  3997. nth: function( cur, result, dir, elem ) {
  3998. result = result || 1;
  3999. var num = 0;
  4000. for ( ; cur; cur = cur[dir] ) {
  4001. if ( cur.nodeType === 1 && ++num === result ) {
  4002. break;
  4003. }
  4004. }
  4005. return cur;
  4006. },
  4007. sibling: function( n, elem ) {
  4008. var r = [];
  4009. for ( ; n; n = n.nextSibling ) {
  4010. if ( n.nodeType === 1 && n !== elem ) {
  4011. r.push( n );
  4012. }
  4013. }
  4014. return r;
  4015. }
  4016. });
  4017. // Implement the identical functionality for filter and not
  4018. function winnow( elements, qualifier, keep ) {
  4019. if ( jQuery.isFunction( qualifier ) ) {
  4020. return jQuery.grep(elements, function( elem, i ) {
  4021. var retVal = !!qualifier.call( elem, i, elem );
  4022. return retVal === keep;
  4023. });
  4024. } else if ( qualifier.nodeType ) {
  4025. return jQuery.grep(elements, function( elem, i ) {
  4026. return (elem === qualifier) === keep;
  4027. });
  4028. } else if ( typeof qualifier === "string" ) {
  4029. var filtered = jQuery.grep(elements, function( elem ) {
  4030. return elem.nodeType === 1;
  4031. });
  4032. if ( isSimple.test( qualifier ) ) {
  4033. return jQuery.filter(qualifier, filtered, !keep);
  4034. } else {
  4035. qualifier = jQuery.filter( qualifier, filtered );
  4036. }
  4037. }
  4038. return jQuery.grep(elements, function( elem, i ) {
  4039. return (jQuery.inArray( elem, qualifier ) >= 0) === keep;
  4040. });
  4041. }
  4042. var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
  4043. rleadingWhitespace = /^\s+/,
  4044. rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
  4045. rtagName = /<([\w:]+)/,
  4046. rtbody = /<tbody/i,
  4047. rhtml = /<|&#?\w+;/,
  4048. rnocache = /<(?:script|object|embed|option|style)/i,
  4049. // checked="checked" or checked
  4050. rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
  4051. wrapMap = {
  4052. option: [ 1, "<select multiple='multiple'>", "</select>" ],
  4053. legend: [ 1, "<fieldset>", "</fieldset>" ],
  4054. thead: [ 1, "<table>", "</table>" ],
  4055. tr: [ 2, "<table><tbody>", "</tbody></table>" ],
  4056. td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
  4057. col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
  4058. area: [ 1, "<map>", "</map>" ],
  4059. _default: [ 0, "", "" ]
  4060. };
  4061. wrapMap.optgroup = wrapMap.option;
  4062. wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  4063. wrapMap.th = wrapMap.td;
  4064. // IE can't serialize <link> and <script> tags normally
  4065. if ( !jQuery.support.htmlSerialize ) {
  4066. wrapMap._default = [ 1, "div<div>", "</div>" ];
  4067. }
  4068. jQuery.fn.extend({
  4069. text: function( text ) {
  4070. if ( jQuery.isFunction(text) ) {
  4071. return this.each(function(i) {
  4072. var self = jQuery( this );
  4073. self.text( text.call(this, i, self.text()) );
  4074. });
  4075. }
  4076. if ( typeof text !== "object" && text !== undefined ) {
  4077. return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
  4078. }
  4079. return jQuery.text( this );
  4080. },
  4081. wrapAll: function( html ) {
  4082. if ( jQuery.isFunction( html ) ) {
  4083. return this.each(function(i) {
  4084. jQuery(this).wrapAll( html.call(this, i) );
  4085. });
  4086. }
  4087. if ( this[0] ) {
  4088. // The elements to wrap the target around
  4089. var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
  4090. if ( this[0].parentNode ) {
  4091. wrap.insertBefore( this[0] );
  4092. }
  4093. wrap.map(function() {
  4094. var elem = this;
  4095. while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
  4096. elem = elem.firstChild;
  4097. }
  4098. return elem;
  4099. }).append(this);
  4100. }
  4101. return this;
  4102. },
  4103. wrapInner: function( html ) {
  4104. if ( jQuery.isFunction( html ) ) {
  4105. return this.each(function(i) {
  4106. jQuery(this).wrapInner( html.call(this, i) );
  4107. });
  4108. }
  4109. return this.each(function() {
  4110. var self = jQuery( this ),
  4111. contents = self.contents();
  4112. if ( contents.length ) {
  4113. contents.wrapAll( html );
  4114. } else {
  4115. self.append( html );
  4116. }
  4117. });
  4118. },
  4119. wrap: function( html ) {
  4120. return this.each(function() {
  4121. jQuery( this ).wrapAll( html );
  4122. });
  4123. },
  4124. unwrap: function() {
  4125. return this.parent().each(function() {
  4126. if ( !jQuery.nodeName( this, "body" ) ) {
  4127. jQuery( this ).replaceWith( this.childNodes );
  4128. }
  4129. }).end();
  4130. },
  4131. append: function() {
  4132. return this.domManip(arguments, true, function( elem ) {
  4133. if ( this.nodeType === 1 ) {
  4134. this.appendChild( elem );
  4135. }
  4136. });
  4137. },
  4138. prepend: function() {
  4139. return this.domManip(arguments, true, function( elem ) {
  4140. if ( this.nodeType === 1 ) {
  4141. this.insertBefore( elem, this.firstChild );
  4142. }
  4143. });
  4144. },
  4145. before: function() {
  4146. if ( this[0] && this[0].parentNode ) {
  4147. return this.domManip(arguments, false, function( elem ) {
  4148. this.parentNode.insertBefore( elem, this );
  4149. });
  4150. } else if ( arguments.length ) {
  4151. var set = jQuery(arguments[0]);
  4152. set.push.apply( set, this.toArray() );
  4153. return this.pushStack( set, "before", arguments );
  4154. }
  4155. },
  4156. after: function() {
  4157. if ( this[0] && this[0].parentNode ) {
  4158. return this.domManip(arguments, false, function( elem ) {
  4159. this.parentNode.insertBefore( elem, this.nextSibling );
  4160. });
  4161. } else if ( arguments.length ) {
  4162. var set = this.pushStack( this, "after", arguments );
  4163. set.push.apply( set, jQuery(arguments[0]).toArray() );
  4164. return set;
  4165. }
  4166. },
  4167. // keepData is for internal use only--do not document
  4168. remove: function( selector, keepData ) {
  4169. for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
  4170. if ( !selector || jQuery.filter( selector, [ elem ] ).length ) {
  4171. if ( !keepData && elem.nodeType === 1 ) {
  4172. jQuery.cleanData( elem.getElementsByTagName("*") );
  4173. jQuery.cleanData( [ elem ] );
  4174. }
  4175. if ( elem.parentNode ) {
  4176. elem.parentNode.removeChild( elem );
  4177. }
  4178. }
  4179. }
  4180. return this;
  4181. },
  4182. empty: function() {
  4183. for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
  4184. // Remove element nodes and prevent memory leaks
  4185. if ( elem.nodeType === 1 ) {
  4186. jQuery.cleanData( elem.getElementsByTagName("*") );
  4187. }
  4188. // Remove any remaining nodes
  4189. while ( elem.firstChild ) {
  4190. elem.removeChild( elem.firstChild );
  4191. }
  4192. }
  4193. return this;
  4194. },
  4195. clone: function( dataAndEvents, deepDataAndEvents ) {
  4196. dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
  4197. deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
  4198. return this.map( function () {
  4199. return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
  4200. });
  4201. },
  4202. html: function( value ) {
  4203. if ( value === undefined ) {
  4204. return this[0] && this[0].nodeType === 1 ?
  4205. this[0].innerHTML.replace(rinlinejQuery, "") :
  4206. null;
  4207. // See if we can take a shortcut and just use innerHTML
  4208. } else if ( typeof value === "string" && !rnocache.test( value ) &&
  4209. (jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) &&
  4210. !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) {
  4211. value = value.replace(rxhtmlTag, "<$1></$2>");
  4212. try {
  4213. for ( var i = 0, l = this.length; i < l; i++ ) {
  4214. // Remove element nodes and prevent memory leaks
  4215. if ( this[i].nodeType === 1 ) {
  4216. jQuery.cleanData( this[i].getElementsByTagName("*") );
  4217. this[i].innerHTML = value;
  4218. }
  4219. }
  4220. // If using innerHTML throws an exception, use the fallback method
  4221. } catch(e) {
  4222. this.empty().append( value );
  4223. }
  4224. } else if ( jQuery.isFunction( value ) ) {
  4225. this.each(function(i){
  4226. var self = jQuery( this );
  4227. self.html( value.call(this, i, self.html()) );
  4228. });
  4229. } else {
  4230. this.empty().append( value );
  4231. }
  4232. return this;
  4233. },
  4234. replaceWith: function( value ) {
  4235. if ( this[0] && this[0].parentNode ) {
  4236. // Make sure that the elements are removed from the DOM before they are inserted
  4237. // this can help fix replacing a parent with child elements
  4238. if ( jQuery.isFunction( value ) ) {
  4239. return this.each(function(i) {
  4240. var self = jQuery(this), old = self.html();
  4241. self.replaceWith( value.call( this, i, old ) );
  4242. });
  4243. }
  4244. if ( typeof value !== "string" ) {
  4245. value = jQuery( value ).detach();
  4246. }
  4247. return this.each(function() {
  4248. var next = this.nextSibling,
  4249. parent = this.parentNode;
  4250. jQuery( this ).remove();
  4251. if ( next ) {
  4252. jQuery(next).before( value );
  4253. } else {
  4254. jQuery(parent).append( value );
  4255. }
  4256. });
  4257. } else {
  4258. return this.length ?
  4259. this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) :
  4260. this;
  4261. }
  4262. },
  4263. detach: function( selector ) {
  4264. return this.remove( selector, true );
  4265. },
  4266. domManip: function( args, table, callback ) {
  4267. var results, first, fragment, parent,
  4268. value = args[0],
  4269. scripts = [];
  4270. // We can't cloneNode fragments that contain checked, in WebKit
  4271. if ( !jQuery.support.checkClone && arguments.length === 3 && typeof value === "string" && rchecked.test( value ) ) {
  4272. return this.each(function() {
  4273. jQuery(this).domManip( args, table, callback, true );
  4274. });
  4275. }
  4276. if ( jQuery.isFunction(value) ) {
  4277. return this.each(function(i) {
  4278. var self = jQuery(this);
  4279. args[0] = value.call(this, i, table ? self.html() : undefined);
  4280. self.domManip( args, table, callback );
  4281. });
  4282. }
  4283. if ( this[0] ) {
  4284. parent = value && value.parentNode;
  4285. // If we're in a fragment, just use that instead of building a new one
  4286. if ( jQuery.support.parentNode && parent && parent.nodeType === 11 && parent.childNodes.length === this.length ) {
  4287. results = { fragment: parent };
  4288. } else {
  4289. results = jQuery.buildFragment( args, this, scripts );
  4290. }
  4291. fragment = results.fragment;
  4292. if ( fragment.childNodes.length === 1 ) {
  4293. first = fragment = fragment.firstChild;
  4294. } else {
  4295. first = fragment.firstChild;
  4296. }
  4297. if ( first ) {
  4298. table = table && jQuery.nodeName( first, "tr" );
  4299. for ( var i = 0, l = this.length, lastIndex = l - 1; i < l; i++ ) {
  4300. callback.call(
  4301. table ?
  4302. root(this[i], first) :
  4303. this[i],
  4304. // Make sure that we do not leak memory by inadvertently discarding
  4305. // the original fragment (which might have attached data) instead of
  4306. // using it; in addition, use the original fragment object for the last
  4307. // item instead of first because it can end up being emptied incorrectly
  4308. // in certain situations (Bug #8070).
  4309. // Fragments from the fragment cache must always be cloned and never used
  4310. // in place.
  4311. results.cacheable || (l > 1 && i < lastIndex) ?
  4312. jQuery.clone( fragment, true, true ) :
  4313. fragment
  4314. );
  4315. }
  4316. }
  4317. if ( scripts.length ) {
  4318. jQuery.each( scripts, evalScript );
  4319. }
  4320. }
  4321. return this;
  4322. }
  4323. });
  4324. function root( elem, cur ) {
  4325. return jQuery.nodeName(elem, "table") ?
  4326. (elem.getElementsByTagName("tbody")[0] ||
  4327. elem.appendChild(elem.ownerDocument.createElement("tbody"))) :
  4328. elem;
  4329. }
  4330. function cloneCopyEvent( src, dest ) {
  4331. if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
  4332. return;
  4333. }
  4334. var internalKey = jQuery.expando,
  4335. oldData = jQuery.data( src ),
  4336. curData = jQuery.data( dest, oldData );
  4337. // Switch to use the internal data object, if it exists, for the next
  4338. // stage of data copying
  4339. if ( (oldData = oldData[ internalKey ]) ) {
  4340. var events = oldData.events;
  4341. curData = curData[ internalKey ] = jQuery.extend({}, oldData);
  4342. if ( events ) {
  4343. delete curData.handle;
  4344. curData.events = {};
  4345. for ( var type in events ) {
  4346. for ( var i = 0, l = events[ type ].length; i < l; i++ ) {
  4347. jQuery.event.add( dest, type + ( events[ type ][ i ].namespace ? "." : "" ) + events[ type ][ i ].namespace, events[ type ][ i ], events[ type ][ i ].data );
  4348. }
  4349. }
  4350. }
  4351. }
  4352. }
  4353. function cloneFixAttributes(src, dest) {
  4354. // We do not need to do anything for non-Elements
  4355. if ( dest.nodeType !== 1 ) {
  4356. return;
  4357. }
  4358. var nodeName = dest.nodeName.toLowerCase();
  4359. // clearAttributes removes the attributes, which we don't want,
  4360. // but also removes the attachEvent events, which we *do* want
  4361. dest.clearAttributes();
  4362. // mergeAttributes, in contrast, only merges back on the
  4363. // original attributes, not the events
  4364. dest.mergeAttributes(src);
  4365. // IE6-8 fail to clone children inside object elements that use
  4366. // the proprietary classid attribute value (rather than the type
  4367. // attribute) to identify the type of content to display
  4368. if ( nodeName === "object" ) {
  4369. dest.outerHTML = src.outerHTML;
  4370. } else if ( nodeName === "input" && (src.type === "checkbox" || src.type === "radio") ) {
  4371. // IE6-8 fails to persist the checked state of a cloned checkbox
  4372. // or radio button. Worse, IE6-7 fail to give the cloned element
  4373. // a checked appearance if the defaultChecked value isn't also set
  4374. if ( src.checked ) {
  4375. dest.defaultChecked = dest.checked = src.checked;
  4376. }
  4377. // IE6-7 get confused and end up setting the value of a cloned
  4378. // checkbox/radio button to an empty string instead of "on"
  4379. if ( dest.value !== src.value ) {
  4380. dest.value = src.value;
  4381. }
  4382. // IE6-8 fails to return the selected option to the default selected
  4383. // state when cloning options
  4384. } else if ( nodeName === "option" ) {
  4385. dest.selected = src.defaultSelected;
  4386. // IE6-8 fails to set the defaultValue to the correct value when
  4387. // cloning other types of input fields
  4388. } else if ( nodeName === "input" || nodeName === "textarea" ) {
  4389. dest.defaultValue = src.defaultValue;
  4390. }
  4391. // Event data gets referenced instead of copied if the expando
  4392. // gets copied too
  4393. dest.removeAttribute( jQuery.expando );
  4394. }
  4395. jQuery.buildFragment = function( args, nodes, scripts ) {
  4396. var fragment, cacheable, cacheresults,
  4397. doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document);
  4398. // Only cache "small" (1/2 KB) HTML strings that are associated with the main document
  4399. // Cloning options loses the selected state, so don't cache them
  4400. // IE 6 doesn't like it when you put <object> or <embed> elements in a fragment
  4401. // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache
  4402. if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && doc === document &&
  4403. args[0].charAt(0) === "<" && !rnocache.test( args[0] ) && (jQuery.support.checkClone || !rchecked.test( args[0] )) ) {
  4404. cacheable = true;
  4405. cacheresults = jQuery.fragments[ args[0] ];
  4406. if ( cacheresults ) {
  4407. if ( cacheresults !== 1 ) {
  4408. fragment = cacheresults;
  4409. }
  4410. }
  4411. }
  4412. if ( !fragment ) {
  4413. fragment = doc.createDocumentFragment();
  4414. jQuery.clean( args, doc, fragment, scripts );
  4415. }
  4416. if ( cacheable ) {
  4417. jQuery.fragments[ args[0] ] = cacheresults ? fragment : 1;
  4418. }
  4419. return { fragment: fragment, cacheable: cacheable };
  4420. };
  4421. jQuery.fragments = {};
  4422. jQuery.each({
  4423. appendTo: "append",
  4424. prependTo: "prepend",
  4425. insertBefore: "before",
  4426. insertAfter: "after",
  4427. replaceAll: "replaceWith"
  4428. }, function( name, original ) {
  4429. jQuery.fn[ name ] = function( selector ) {
  4430. var ret = [],
  4431. insert = jQuery( selector ),
  4432. parent = this.length === 1 && this[0].parentNode;
  4433. if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) {
  4434. insert[ original ]( this[0] );
  4435. return this;
  4436. } else {
  4437. for ( var i = 0, l = insert.length; i < l; i++ ) {
  4438. var elems = (i > 0 ? this.clone(true) : this).get();
  4439. jQuery( insert[i] )[ original ]( elems );
  4440. ret = ret.concat( elems );
  4441. }
  4442. return this.pushStack( ret, name, insert.selector );
  4443. }
  4444. };
  4445. });
  4446. function getAll( elem ) {
  4447. if ( "getElementsByTagName" in elem ) {
  4448. return elem.getElementsByTagName( "*" );
  4449. } else if ( "querySelectorAll" in elem ) {
  4450. return elem.querySelectorAll( "*" );
  4451. } else {
  4452. return [];
  4453. }
  4454. }
  4455. jQuery.extend({
  4456. clone: function( elem, dataAndEvents, deepDataAndEvents ) {
  4457. var clone = elem.cloneNode(true),
  4458. srcElements,
  4459. destElements,
  4460. i;
  4461. if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
  4462. (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
  4463. // IE copies events bound via attachEvent when using cloneNode.
  4464. // Calling detachEvent on the clone will also remove the events
  4465. // from the original. In order to get around this, we use some
  4466. // proprietary methods to clear the events. Thanks to MooTools
  4467. // guys for this hotness.
  4468. cloneFixAttributes( elem, clone );
  4469. // Using Sizzle here is crazy slow, so we use getElementsByTagName
  4470. // instead
  4471. srcElements = getAll( elem );
  4472. destElements = getAll( clone );
  4473. // Weird iteration because IE will replace the length property
  4474. // with an element if you are cloning the body and one of the
  4475. // elements on the page has a name or id of "length"
  4476. for ( i = 0; srcElements[i]; ++i ) {
  4477. cloneFixAttributes( srcElements[i], destElements[i] );
  4478. }
  4479. }
  4480. // Copy the events from the original to the clone
  4481. if ( dataAndEvents ) {
  4482. cloneCopyEvent( elem, clone );
  4483. if ( deepDataAndEvents ) {
  4484. srcElements = getAll( elem );
  4485. destElements = getAll( clone );
  4486. for ( i = 0; srcElements[i]; ++i ) {
  4487. cloneCopyEvent( srcElements[i], destElements[i] );
  4488. }
  4489. }
  4490. }
  4491. // Return the cloned set
  4492. return clone;
  4493. },
  4494. clean: function( elems, context, fragment, scripts ) {
  4495. context = context || document;
  4496. // !context.createElement fails in IE with an error but returns typeof 'object'
  4497. if ( typeof context.createElement === "undefined" ) {
  4498. context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
  4499. }
  4500. var ret = [];
  4501. for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
  4502. if ( typeof elem === "number" ) {
  4503. elem += "";
  4504. }
  4505. if ( !elem ) {
  4506. continue;
  4507. }
  4508. // Convert html string into DOM nodes
  4509. if ( typeof elem === "string" && !rhtml.test( elem ) ) {
  4510. elem = context.createTextNode( elem );
  4511. } else if ( typeof elem === "string" ) {
  4512. // Fix "XHTML"-style tags in all browsers
  4513. elem = elem.replace(rxhtmlTag, "<$1></$2>");
  4514. // Trim whitespace, otherwise indexOf won't work as expected
  4515. var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(),
  4516. wrap = wrapMap[ tag ] || wrapMap._default,
  4517. depth = wrap[0],
  4518. div = context.createElement("div");
  4519. // Go to html and back, then peel off extra wrappers
  4520. div.innerHTML = wrap[1] + elem + wrap[2];
  4521. // Move to the right depth
  4522. while ( depth-- ) {
  4523. div = div.lastChild;
  4524. }
  4525. // Remove IE's autoinserted <tbody> from table fragments
  4526. if ( !jQuery.support.tbody ) {
  4527. // String was a <table>, *may* have spurious <tbody>
  4528. var hasBody = rtbody.test(elem),
  4529. tbody = tag === "table" && !hasBody ?
  4530. div.firstChild && div.firstChild.childNodes :
  4531. // String was a bare <thead> or <tfoot>
  4532. wrap[1] === "<table>" && !hasBody ?
  4533. div.childNodes :
  4534. [];
  4535. for ( var j = tbody.length - 1; j >= 0 ; --j ) {
  4536. if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
  4537. tbody[ j ].parentNode.removeChild( tbody[ j ] );
  4538. }
  4539. }
  4540. }
  4541. // IE completely kills leading whitespace when innerHTML is used
  4542. if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
  4543. div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
  4544. }
  4545. elem = div.childNodes;
  4546. }
  4547. if ( elem.nodeType ) {
  4548. ret.push( elem );
  4549. } else {
  4550. ret = jQuery.merge( ret, elem );
  4551. }
  4552. }
  4553. if ( fragment ) {
  4554. for ( i = 0; ret[i]; i++ ) {
  4555. if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
  4556. scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
  4557. } else {
  4558. if ( ret[i].nodeType === 1 ) {
  4559. ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) );
  4560. }
  4561. fragment.appendChild( ret[i] );
  4562. }
  4563. }
  4564. }
  4565. return ret;
  4566. },
  4567. cleanData: function( elems ) {
  4568. var data, id, cache = jQuery.cache, internalKey = jQuery.expando, special = jQuery.event.special,
  4569. deleteExpando = jQuery.support.deleteExpando;
  4570. for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
  4571. if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
  4572. continue;
  4573. }
  4574. id = elem[ jQuery.expando ];
  4575. if ( id ) {
  4576. data = cache[ id ] && cache[ id ][ internalKey ];
  4577. if ( data && data.events ) {
  4578. for ( var type in data.events ) {
  4579. if ( special[ type ] ) {
  4580. jQuery.event.remove( elem, type );
  4581. // This is a shortcut to avoid jQuery.event.remove's overhead
  4582. } else {
  4583. jQuery.removeEvent( elem, type, data.handle );
  4584. }
  4585. }
  4586. // Null the DOM reference to avoid IE6/7/8 leak (#7054)
  4587. if ( data.handle ) {
  4588. data.handle.elem = null;
  4589. }
  4590. }
  4591. if ( deleteExpando ) {
  4592. delete elem[ jQuery.expando ];
  4593. } else if ( elem.removeAttribute ) {
  4594. elem.removeAttribute( jQuery.expando );
  4595. }
  4596. delete cache[ id ];
  4597. }
  4598. }
  4599. }
  4600. });
  4601. function evalScript( i, elem ) {
  4602. if ( elem.src ) {
  4603. jQuery.ajax({
  4604. url: elem.src,
  4605. async: false,
  4606. dataType: "script"
  4607. });
  4608. } else {
  4609. jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );
  4610. }
  4611. if ( elem.parentNode ) {
  4612. elem.parentNode.removeChild( elem );
  4613. }
  4614. }
  4615. var ralpha = /alpha\([^)]*\)/i,
  4616. ropacity = /opacity=([^)]*)/,
  4617. rdashAlpha = /-([a-z])/ig,
  4618. // fixed for IE9, see #8346
  4619. rupper = /([A-Z]|^ms)/g,
  4620. rnumpx = /^-?\d+(?:px)?$/i,
  4621. rnum = /^-?\d/,
  4622. cssShow = { position: "absolute", visibility: "hidden", display: "block" },
  4623. cssWidth = [ "Left", "Right" ],
  4624. cssHeight = [ "Top", "Bottom" ],
  4625. curCSS,
  4626. getComputedStyle,
  4627. currentStyle,
  4628. fcamelCase = function( all, letter ) {
  4629. return letter.toUpperCase();
  4630. };
  4631. jQuery.fn.css = function( name, value ) {
  4632. // Setting 'undefined' is a no-op
  4633. if ( arguments.length === 2 && value === undefined ) {
  4634. return this;
  4635. }
  4636. return jQuery.access( this, name, value, true, function( elem, name, value ) {
  4637. return value !== undefined ?
  4638. jQuery.style( elem, name, value ) :
  4639. jQuery.css( elem, name );
  4640. });
  4641. };
  4642. jQuery.extend({
  4643. // Add in style property hooks for overriding the default
  4644. // behavior of getting and setting a style property
  4645. cssHooks: {
  4646. opacity: {
  4647. get: function( elem, computed ) {
  4648. if ( computed ) {
  4649. // We should always get a number back from opacity
  4650. var ret = curCSS( elem, "opacity", "opacity" );
  4651. return ret === "" ? "1" : ret;
  4652. } else {
  4653. return elem.style.opacity;
  4654. }
  4655. }
  4656. }
  4657. },
  4658. // Exclude the following css properties to add px
  4659. cssNumber: {
  4660. "zIndex": true,
  4661. "fontWeight": true,
  4662. "opacity": true,
  4663. "zoom": true,
  4664. "lineHeight": true
  4665. },
  4666. // Add in properties whose names you wish to fix before
  4667. // setting or getting the value
  4668. cssProps: {
  4669. // normalize float css property
  4670. "float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat"
  4671. },
  4672. // Get and set the style property on a DOM Node
  4673. style: function( elem, name, value, extra ) {
  4674. // Don't set styles on text and comment nodes
  4675. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
  4676. return;
  4677. }
  4678. // Make sure that we're working with the right name
  4679. var ret, origName = jQuery.camelCase( name ),
  4680. style = elem.style, hooks = jQuery.cssHooks[ origName ];
  4681. name = jQuery.cssProps[ origName ] || origName;
  4682. // Check if we're setting a value
  4683. if ( value !== undefined ) {
  4684. // Make sure that NaN and null values aren't set. See: #7116
  4685. if ( typeof value === "number" && isNaN( value ) || value == null ) {
  4686. return;
  4687. }
  4688. // If a number was passed in, add 'px' to the (except for certain CSS properties)
  4689. if ( typeof value === "number" && !jQuery.cssNumber[ origName ] ) {
  4690. value += "px";
  4691. }
  4692. // If a hook was provided, use that value, otherwise just set the specified value
  4693. if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value )) !== undefined ) {
  4694. // Wrapped to prevent IE from throwing errors when 'invalid' values are provided
  4695. // Fixes bug #5509
  4696. try {
  4697. style[ name ] = value;
  4698. } catch(e) {}
  4699. }
  4700. } else {
  4701. // If a hook was provided get the non-computed value from there
  4702. if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
  4703. return ret;
  4704. }
  4705. // Otherwise just get the value from the style object
  4706. return style[ name ];
  4707. }
  4708. },
  4709. css: function( elem, name, extra ) {
  4710. // Make sure that we're working with the right name
  4711. var ret, origName = jQuery.camelCase( name ),
  4712. hooks = jQuery.cssHooks[ origName ];
  4713. name = jQuery.cssProps[ origName ] || origName;
  4714. // If a hook was provided get the computed value from there
  4715. if ( hooks && "get" in hooks && (ret = hooks.get( elem, true, extra )) !== undefined ) {
  4716. return ret;
  4717. // Otherwise, if a way to get the computed value exists, use that
  4718. } else if ( curCSS ) {
  4719. return curCSS( elem, name, origName );
  4720. }
  4721. },
  4722. // A method for quickly swapping in/out CSS properties to get correct calculations
  4723. swap: function( elem, options, callback ) {
  4724. var old = {};
  4725. // Remember the old values, and insert the new ones
  4726. for ( var name in options ) {
  4727. old[ name ] = elem.style[ name ];
  4728. elem.style[ name ] = options[ name ];
  4729. }
  4730. callback.call( elem );
  4731. // Revert the old values
  4732. for ( name in options ) {
  4733. elem.style[ name ] = old[ name ];
  4734. }
  4735. },
  4736. camelCase: function( string ) {
  4737. return string.replace( rdashAlpha, fcamelCase );
  4738. }
  4739. });
  4740. // DEPRECATED, Use jQuery.css() instead
  4741. jQuery.curCSS = jQuery.css;
  4742. jQuery.each(["height", "width"], function( i, name ) {
  4743. jQuery.cssHooks[ name ] = {
  4744. get: function( elem, computed, extra ) {
  4745. var val;
  4746. if ( computed ) {
  4747. if ( elem.offsetWidth !== 0 ) {
  4748. val = getWH( elem, name, extra );
  4749. } else {
  4750. jQuery.swap( elem, cssShow, function() {
  4751. val = getWH( elem, name, extra );
  4752. });
  4753. }
  4754. if ( val <= 0 ) {
  4755. val = curCSS( elem, name, name );
  4756. if ( val === "0px" && currentStyle ) {
  4757. val = currentStyle( elem, name, name );
  4758. }
  4759. if ( val != null ) {
  4760. // Should return "auto" instead of 0, use 0 for
  4761. // temporary backwards-compat
  4762. return val === "" || val === "auto" ? "0px" : val;
  4763. }
  4764. }
  4765. if ( val < 0 || val == null ) {
  4766. val = elem.style[ name ];
  4767. // Should return "auto" instead of 0, use 0 for
  4768. // temporary backwards-compat
  4769. return val === "" || val === "auto" ? "0px" : val;
  4770. }
  4771. return typeof val === "string" ? val : val + "px";
  4772. }
  4773. },
  4774. set: function( elem, value ) {
  4775. if ( rnumpx.test( value ) ) {
  4776. // ignore negative width and height values #1599
  4777. value = parseFloat(value);
  4778. if ( value >= 0 ) {
  4779. return value + "px";
  4780. }
  4781. } else {
  4782. return value;
  4783. }
  4784. }
  4785. };
  4786. });
  4787. if ( !jQuery.support.opacity ) {
  4788. jQuery.cssHooks.opacity = {
  4789. get: function( elem, computed ) {
  4790. // IE uses filters for opacity
  4791. return ropacity.test((computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "") ?
  4792. (parseFloat(RegExp.$1) / 100) + "" :
  4793. computed ? "1" : "";
  4794. },
  4795. set: function( elem, value ) {
  4796. var style = elem.style;
  4797. // IE has trouble with opacity if it does not have layout
  4798. // Force it by setting the zoom level
  4799. style.zoom = 1;
  4800. // Set the alpha filter to set the opacity
  4801. var opacity = jQuery.isNaN(value) ?
  4802. "" :
  4803. "alpha(opacity=" + value * 100 + ")",
  4804. filter = style.filter || "";
  4805. style.filter = ralpha.test(filter) ?
  4806. filter.replace(ralpha, opacity) :
  4807. style.filter + ' ' + opacity;
  4808. }
  4809. };
  4810. }
  4811. jQuery(function() {
  4812. // This hook cannot be added until DOM ready because the support test
  4813. // for it is not run until after DOM ready
  4814. if ( !jQuery.support.reliableMarginRight ) {
  4815. jQuery.cssHooks.marginRight = {
  4816. get: function( elem, computed ) {
  4817. // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
  4818. // Work around by temporarily setting element display to inline-block
  4819. var ret;
  4820. jQuery.swap( elem, { "display": "inline-block" }, function() {
  4821. if ( computed ) {
  4822. ret = curCSS( elem, "margin-right", "marginRight" );
  4823. } else {
  4824. ret = elem.style.marginRight;
  4825. }
  4826. });
  4827. return ret;
  4828. }
  4829. };
  4830. }
  4831. });
  4832. if ( document.defaultView && document.defaultView.getComputedStyle ) {
  4833. getComputedStyle = function( elem, newName, name ) {
  4834. var ret, defaultView, computedStyle;
  4835. name = name.replace( rupper, "-$1" ).toLowerCase();
  4836. if ( !(defaultView = elem.ownerDocument.defaultView) ) {
  4837. return undefined;
  4838. }
  4839. if ( (computedStyle = defaultView.getComputedStyle( elem, null )) ) {
  4840. ret = computedStyle.getPropertyValue( name );
  4841. if ( ret === "" && !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) {
  4842. ret = jQuery.style( elem, name );
  4843. }
  4844. }
  4845. return ret;
  4846. };
  4847. }
  4848. if ( document.documentElement.currentStyle ) {
  4849. currentStyle = function( elem, name ) {
  4850. var left,
  4851. ret = elem.currentStyle && elem.currentStyle[ name ],
  4852. rsLeft = elem.runtimeStyle && elem.runtimeStyle[ name ],
  4853. style = elem.style;
  4854. // From the awesome hack by Dean Edwards
  4855. // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
  4856. // If we're not dealing with a regular pixel number
  4857. // but a number that has a weird ending, we need to convert it to pixels
  4858. if ( !rnumpx.test( ret ) && rnum.test( ret ) ) {
  4859. // Remember the original values
  4860. left = style.left;
  4861. // Put in the new values to get a computed value out
  4862. if ( rsLeft ) {
  4863. elem.runtimeStyle.left = elem.currentStyle.left;
  4864. }
  4865. style.left = name === "fontSize" ? "1em" : (ret || 0);
  4866. ret = style.pixelLeft + "px";
  4867. // Revert the changed values
  4868. style.left = left;
  4869. if ( rsLeft ) {
  4870. elem.runtimeStyle.left = rsLeft;
  4871. }
  4872. }
  4873. return ret === "" ? "auto" : ret;
  4874. };
  4875. }
  4876. curCSS = getComputedStyle || currentStyle;
  4877. function getWH( elem, name, extra ) {
  4878. var which = name === "width" ? cssWidth : cssHeight,
  4879. val = name === "width" ? elem.offsetWidth : elem.offsetHeight;
  4880. if ( extra === "border" ) {
  4881. return val;
  4882. }
  4883. jQuery.each( which, function() {
  4884. if ( !extra ) {
  4885. val -= parseFloat(jQuery.css( elem, "padding" + this )) || 0;
  4886. }
  4887. if ( extra === "margin" ) {
  4888. val += parseFloat(jQuery.css( elem, "margin" + this )) || 0;
  4889. } else {
  4890. val -= parseFloat(jQuery.css( elem, "border" + this + "Width" )) || 0;
  4891. }
  4892. });
  4893. return val;
  4894. }
  4895. if ( jQuery.expr && jQuery.expr.filters ) {
  4896. jQuery.expr.filters.hidden = function( elem ) {
  4897. var width = elem.offsetWidth,
  4898. height = elem.offsetHeight;
  4899. return (width === 0 && height === 0) || (!jQuery.support.reliableHiddenOffsets && (elem.style.display || jQuery.css( elem, "display" )) === "none");
  4900. };
  4901. jQuery.expr.filters.visible = function( elem ) {
  4902. return !jQuery.expr.filters.hidden( elem );
  4903. };
  4904. }
  4905. var r20 = /%20/g,
  4906. rbracket = /\[\]$/,
  4907. rCRLF = /\r?\n/g,
  4908. rhash = /#.*$/,
  4909. rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
  4910. rinput = /^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
  4911. // #7653, #8125, #8152: local protocol detection
  4912. rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|widget):$/,
  4913. rnoContent = /^(?:GET|HEAD)$/,
  4914. rprotocol = /^\/\//,
  4915. rquery = /\?/,
  4916. rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
  4917. rselectTextarea = /^(?:select|textarea)/i,
  4918. rspacesAjax = /\s+/,
  4919. rts = /([?&])_=[^&]*/,
  4920. rucHeaders = /(^|\-)([a-z])/g,
  4921. rucHeadersFunc = function( _, $1, $2 ) {
  4922. return $1 + $2.toUpperCase();
  4923. },
  4924. rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,
  4925. // Keep a copy of the old load method
  4926. _load = jQuery.fn.load,
  4927. /* Prefilters
  4928. * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
  4929. * 2) These are called:
  4930. * - BEFORE asking for a transport
  4931. * - AFTER param serialization (s.data is a string if s.processData is true)
  4932. * 3) key is the dataType
  4933. * 4) the catchall symbol "*" can be used
  4934. * 5) execution will start with transport dataType and THEN continue down to "*" if needed
  4935. */
  4936. prefilters = {},
  4937. /* Transports bindings
  4938. * 1) key is the dataType
  4939. * 2) the catchall symbol "*" can be used
  4940. * 3) selection will start with transport dataType and THEN go to "*" if needed
  4941. */
  4942. transports = {},
  4943. // Document location
  4944. ajaxLocation,
  4945. // Document location segments
  4946. ajaxLocParts;
  4947. // #8138, IE may throw an exception when accessing
  4948. // a field from document.location if document.domain has been set
  4949. try {
  4950. ajaxLocation = document.location.href;
  4951. } catch( e ) {
  4952. // Use the href attribute of an A element
  4953. // since IE will modify it given document.location
  4954. ajaxLocation = document.createElement( "a" );
  4955. ajaxLocation.href = "";
  4956. ajaxLocation = ajaxLocation.href;
  4957. }
  4958. // Segment location into parts
  4959. ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
  4960. // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
  4961. function addToPrefiltersOrTransports( structure ) {
  4962. // dataTypeExpression is optional and defaults to "*"
  4963. return function( dataTypeExpression, func ) {
  4964. if ( typeof dataTypeExpression !== "string" ) {
  4965. func = dataTypeExpression;
  4966. dataTypeExpression = "*";
  4967. }
  4968. if ( jQuery.isFunction( func ) ) {
  4969. var dataTypes = dataTypeExpression.toLowerCase().split( rspacesAjax ),
  4970. i = 0,
  4971. length = dataTypes.length,
  4972. dataType,
  4973. list,
  4974. placeBefore;
  4975. // For each dataType in the dataTypeExpression
  4976. for(; i < length; i++ ) {
  4977. dataType = dataTypes[ i ];
  4978. // We control if we're asked to add before
  4979. // any existing element
  4980. placeBefore = /^\+/.test( dataType );
  4981. if ( placeBefore ) {
  4982. dataType = dataType.substr( 1 ) || "*";
  4983. }
  4984. list = structure[ dataType ] = structure[ dataType ] || [];
  4985. // then we add to the structure accordingly
  4986. list[ placeBefore ? "unshift" : "push" ]( func );
  4987. }
  4988. }
  4989. };
  4990. }
  4991. //Base inspection function for prefilters and transports
  4992. function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR,
  4993. dataType /* internal */, inspected /* internal */ ) {
  4994. dataType = dataType || options.dataTypes[ 0 ];
  4995. inspected = inspected || {};
  4996. inspected[ dataType ] = true;
  4997. var list = structure[ dataType ],
  4998. i = 0,
  4999. length = list ? list.length : 0,
  5000. executeOnly = ( structure === prefilters ),
  5001. selection;
  5002. for(; i < length && ( executeOnly || !selection ); i++ ) {
  5003. selection = list[ i ]( options, originalOptions, jqXHR );
  5004. // If we got redirected to another dataType
  5005. // we try there if executing only and not done already
  5006. if ( typeof selection === "string" ) {
  5007. if ( !executeOnly || inspected[ selection ] ) {
  5008. selection = undefined;
  5009. } else {
  5010. options.dataTypes.unshift( selection );
  5011. selection = inspectPrefiltersOrTransports(
  5012. structure, options, originalOptions, jqXHR, selection, inspected );
  5013. }
  5014. }
  5015. }
  5016. // If we're only executing or nothing was selected
  5017. // we try the catchall dataType if not done already
  5018. if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) {
  5019. selection = inspectPrefiltersOrTransports(
  5020. structure, options, originalOptions, jqXHR, "*", inspected );
  5021. }
  5022. // unnecessary when only executing (prefilters)
  5023. // but it'll be ignored by the caller in that case
  5024. return selection;
  5025. }
  5026. jQuery.fn.extend({
  5027. load: function( url, params, callback ) {
  5028. if ( typeof url !== "string" && _load ) {
  5029. return _load.apply( this, arguments );
  5030. // Don't do a request if no elements are being requested
  5031. } else if ( !this.length ) {
  5032. return this;
  5033. }
  5034. var off = url.indexOf( " " );
  5035. if ( off >= 0 ) {
  5036. var selector = url.slice( off, url.length );
  5037. url = url.slice( 0, off );
  5038. }
  5039. // Default to a GET request
  5040. var type = "GET";
  5041. // If the second parameter was provided
  5042. if ( params ) {
  5043. // If it's a function
  5044. if ( jQuery.isFunction( params ) ) {
  5045. // We assume that it's the callback
  5046. callback = params;
  5047. params = undefined;
  5048. // Otherwise, build a param string
  5049. } else if ( typeof params === "object" ) {
  5050. params = jQuery.param( params, jQuery.ajaxSettings.traditional );
  5051. type = "POST";
  5052. }
  5053. }
  5054. var self = this;
  5055. // Request the remote document
  5056. jQuery.ajax({
  5057. url: url,
  5058. type: type,
  5059. dataType: "html",
  5060. data: params,
  5061. // Complete callback (responseText is used internally)
  5062. complete: function( jqXHR, status, responseText ) {
  5063. // Store the response as specified by the jqXHR object
  5064. responseText = jqXHR.responseText;
  5065. // If successful, inject the HTML into all the matched elements
  5066. if ( jqXHR.isResolved() ) {
  5067. // #4825: Get the actual response in case
  5068. // a dataFilter is present in ajaxSettings
  5069. jqXHR.done(function( r ) {
  5070. responseText = r;
  5071. });
  5072. // See if a selector was specified
  5073. self.html( selector ?
  5074. // Create a dummy div to hold the results
  5075. jQuery("<div>")
  5076. // inject the contents of the document in, removing the scripts
  5077. // to avoid any 'Permission Denied' errors in IE
  5078. .append(responseText.replace(rscript, ""))
  5079. // Locate the specified elements
  5080. .find(selector) :
  5081. // If not, just inject the full result
  5082. responseText );
  5083. }
  5084. if ( callback ) {
  5085. self.each( callback, [ responseText, status, jqXHR ] );
  5086. }
  5087. }
  5088. });
  5089. return this;
  5090. },
  5091. serialize: function() {
  5092. return jQuery.param( this.serializeArray() );
  5093. },
  5094. serializeArray: function() {
  5095. return this.map(function(){
  5096. return this.elements ? jQuery.makeArray( this.elements ) : this;
  5097. })
  5098. .filter(function(){
  5099. return this.name && !this.disabled &&
  5100. ( this.checked || rselectTextarea.test( this.nodeName ) ||
  5101. rinput.test( this.type ) );
  5102. })
  5103. .map(function( i, elem ){
  5104. var val = jQuery( this ).val();
  5105. return val == null ?
  5106. null :
  5107. jQuery.isArray( val ) ?
  5108. jQuery.map( val, function( val, i ){
  5109. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  5110. }) :
  5111. { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  5112. }).get();
  5113. }
  5114. });
  5115. // Attach a bunch of functions for handling common AJAX events
  5116. jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i, o ){
  5117. jQuery.fn[ o ] = function( f ){
  5118. return this.bind( o, f );
  5119. };
  5120. } );
  5121. jQuery.each( [ "get", "post" ], function( i, method ) {
  5122. jQuery[ method ] = function( url, data, callback, type ) {
  5123. // shift arguments if data argument was omitted
  5124. if ( jQuery.isFunction( data ) ) {
  5125. type = type || callback;
  5126. callback = data;
  5127. data = undefined;
  5128. }
  5129. return jQuery.ajax({
  5130. type: method,
  5131. url: url,
  5132. data: data,
  5133. success: callback,
  5134. dataType: type
  5135. });
  5136. };
  5137. } );
  5138. jQuery.extend({
  5139. getScript: function( url, callback ) {
  5140. return jQuery.get( url, undefined, callback, "script" );
  5141. },
  5142. getJSON: function( url, data, callback ) {
  5143. return jQuery.get( url, data, callback, "json" );
  5144. },
  5145. // Creates a full fledged settings object into target
  5146. // with both ajaxSettings and settings fields.
  5147. // If target is omitted, writes into ajaxSettings.
  5148. ajaxSetup: function ( target, settings ) {
  5149. if ( !settings ) {
  5150. // Only one parameter, we extend ajaxSettings
  5151. settings = target;
  5152. target = jQuery.extend( true, jQuery.ajaxSettings, settings );
  5153. } else {
  5154. // target was provided, we extend into it
  5155. jQuery.extend( true, target, jQuery.ajaxSettings, settings );
  5156. }
  5157. // Flatten fields we don't want deep extended
  5158. for( var field in { context: 1, url: 1 } ) {
  5159. if ( field in settings ) {
  5160. target[ field ] = settings[ field ];
  5161. } else if( field in jQuery.ajaxSettings ) {
  5162. target[ field ] = jQuery.ajaxSettings[ field ];
  5163. }
  5164. }
  5165. return target;
  5166. },
  5167. ajaxSettings: {
  5168. url: ajaxLocation,
  5169. isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
  5170. global: true,
  5171. type: "GET",
  5172. contentType: "application/x-www-form-urlencoded",
  5173. processData: true,
  5174. async: true,
  5175. /*
  5176. timeout: 0,
  5177. data: null,
  5178. dataType: null,
  5179. username: null,
  5180. password: null,
  5181. cache: null,
  5182. traditional: false,
  5183. headers: {},
  5184. */
  5185. accepts: {
  5186. xml: "application/xml, text/xml",
  5187. html: "text/html",
  5188. text: "text/plain",
  5189. json: "application/json, text/javascript",
  5190. "*": "*/*"
  5191. },
  5192. contents: {
  5193. xml: /xml/,
  5194. html: /html/,
  5195. json: /json/
  5196. },
  5197. responseFields: {
  5198. xml: "responseXML",
  5199. text: "responseText"
  5200. },
  5201. // List of data converters
  5202. // 1) key format is "source_type destination_type" (a single space in-between)
  5203. // 2) the catchall symbol "*" can be used for source_type
  5204. converters: {
  5205. // Convert anything to text
  5206. "* text": window.String,
  5207. // Text to html (true = no transformation)
  5208. "text html": true,
  5209. // Evaluate text as a json expression
  5210. "text json": jQuery.parseJSON,
  5211. // Parse text as xml
  5212. "text xml": jQuery.parseXML
  5213. }
  5214. },
  5215. ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
  5216. ajaxTransport: addToPrefiltersOrTransports( transports ),
  5217. // Main method
  5218. ajax: function( url, options ) {
  5219. // If url is an object, simulate pre-1.5 signature
  5220. if ( typeof url === "object" ) {
  5221. options = url;
  5222. url = undefined;
  5223. }
  5224. // Force options to be an object
  5225. options = options || {};
  5226. var // Create the final options object
  5227. s = jQuery.ajaxSetup( {}, options ),
  5228. // Callbacks context
  5229. callbackContext = s.context || s,
  5230. // Context for global events
  5231. // It's the callbackContext if one was provided in the options
  5232. // and if it's a DOM node or a jQuery collection
  5233. globalEventContext = callbackContext !== s &&
  5234. ( callbackContext.nodeType || callbackContext instanceof jQuery ) ?
  5235. jQuery( callbackContext ) : jQuery.event,
  5236. // Deferreds
  5237. deferred = jQuery.Deferred(),
  5238. completeDeferred = jQuery._Deferred(),
  5239. // Status-dependent callbacks
  5240. statusCode = s.statusCode || {},
  5241. // ifModified key
  5242. ifModifiedKey,
  5243. // Headers (they are sent all at once)
  5244. requestHeaders = {},
  5245. // Response headers
  5246. responseHeadersString,
  5247. responseHeaders,
  5248. // transport
  5249. transport,
  5250. // timeout handle
  5251. timeoutTimer,
  5252. // Cross-domain detection vars
  5253. parts,
  5254. // The jqXHR state
  5255. state = 0,
  5256. // To know if global events are to be dispatched
  5257. fireGlobals,
  5258. // Loop variable
  5259. i,
  5260. // Fake xhr
  5261. jqXHR = {
  5262. readyState: 0,
  5263. // Caches the header
  5264. setRequestHeader: function( name, value ) {
  5265. if ( !state ) {
  5266. requestHeaders[ name.toLowerCase().replace( rucHeaders, rucHeadersFunc ) ] = value;
  5267. }
  5268. return this;
  5269. },
  5270. // Raw string
  5271. getAllResponseHeaders: function() {
  5272. return state === 2 ? responseHeadersString : null;
  5273. },
  5274. // Builds headers hashtable if needed
  5275. getResponseHeader: function( key ) {
  5276. var match;
  5277. if ( state === 2 ) {
  5278. if ( !responseHeaders ) {
  5279. responseHeaders = {};
  5280. while( ( match = rheaders.exec( responseHeadersString ) ) ) {
  5281. responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
  5282. }
  5283. }
  5284. match = responseHeaders[ key.toLowerCase() ];
  5285. }
  5286. return match === undefined ? null : match;
  5287. },
  5288. // Overrides response content-type header
  5289. overrideMimeType: function( type ) {
  5290. if ( !state ) {
  5291. s.mimeType = type;
  5292. }
  5293. return this;
  5294. },
  5295. // Cancel the request
  5296. abort: function( statusText ) {
  5297. statusText = statusText || "abort";
  5298. if ( transport ) {
  5299. transport.abort( statusText );
  5300. }
  5301. done( 0, statusText );
  5302. return this;
  5303. }
  5304. };
  5305. // Callback for when everything is done
  5306. // It is defined here because jslint complains if it is declared
  5307. // at the end of the function (which would be more logical and readable)
  5308. function done( status, statusText, responses, headers ) {
  5309. // Called once
  5310. if ( state === 2 ) {
  5311. return;
  5312. }
  5313. // State is "done" now
  5314. state = 2;
  5315. // Clear timeout if it exists
  5316. if ( timeoutTimer ) {
  5317. clearTimeout( timeoutTimer );
  5318. }
  5319. // Dereference transport for early garbage collection
  5320. // (no matter how long the jqXHR object will be used)
  5321. transport = undefined;
  5322. // Cache response headers
  5323. responseHeadersString = headers || "";
  5324. // Set readyState
  5325. jqXHR.readyState = status ? 4 : 0;
  5326. var isSuccess,
  5327. success,
  5328. error,
  5329. response = responses ? ajaxHandleResponses( s, jqXHR, responses ) : undefined,
  5330. lastModified,
  5331. etag;
  5332. // If successful, handle type chaining
  5333. if ( status >= 200 && status < 300 || status === 304 ) {
  5334. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  5335. if ( s.ifModified ) {
  5336. if ( ( lastModified = jqXHR.getResponseHeader( "Last-Modified" ) ) ) {
  5337. jQuery.lastModified[ ifModifiedKey ] = lastModified;
  5338. }
  5339. if ( ( etag = jqXHR.getResponseHeader( "Etag" ) ) ) {
  5340. jQuery.etag[ ifModifiedKey ] = etag;
  5341. }
  5342. }
  5343. // If not modified
  5344. if ( status === 304 ) {
  5345. statusText = "notmodified";
  5346. isSuccess = true;
  5347. // If we have data
  5348. } else {
  5349. try {
  5350. success = ajaxConvert( s, response );
  5351. statusText = "success";
  5352. isSuccess = true;
  5353. } catch(e) {
  5354. // We have a parsererror
  5355. statusText = "parsererror";
  5356. error = e;
  5357. }
  5358. }
  5359. } else {
  5360. // We extract error from statusText
  5361. // then normalize statusText and status for non-aborts
  5362. error = statusText;
  5363. if( !statusText || status ) {
  5364. statusText = "error";
  5365. if ( status < 0 ) {
  5366. status = 0;
  5367. }
  5368. }
  5369. }
  5370. // Set data for the fake xhr object
  5371. jqXHR.status = status;
  5372. jqXHR.statusText = statusText;
  5373. // Success/Error
  5374. if ( isSuccess ) {
  5375. deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
  5376. } else {
  5377. deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
  5378. }
  5379. // Status-dependent callbacks
  5380. jqXHR.statusCode( statusCode );
  5381. statusCode = undefined;
  5382. if ( fireGlobals ) {
  5383. globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ),
  5384. [ jqXHR, s, isSuccess ? success : error ] );
  5385. }
  5386. // Complete
  5387. completeDeferred.resolveWith( callbackContext, [ jqXHR, statusText ] );
  5388. if ( fireGlobals ) {
  5389. globalEventContext.trigger( "ajaxComplete", [ jqXHR, s] );
  5390. // Handle the global AJAX counter
  5391. if ( !( --jQuery.active ) ) {
  5392. jQuery.event.trigger( "ajaxStop" );
  5393. }
  5394. }
  5395. }
  5396. // Attach deferreds
  5397. deferred.promise( jqXHR );
  5398. jqXHR.success = jqXHR.done;
  5399. jqXHR.error = jqXHR.fail;
  5400. jqXHR.complete = completeDeferred.done;
  5401. // Status-dependent callbacks
  5402. jqXHR.statusCode = function( map ) {
  5403. if ( map ) {
  5404. var tmp;
  5405. if ( state < 2 ) {
  5406. for( tmp in map ) {
  5407. statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ];
  5408. }
  5409. } else {
  5410. tmp = map[ jqXHR.status ];
  5411. jqXHR.then( tmp, tmp );
  5412. }
  5413. }
  5414. return this;
  5415. };
  5416. // Remove hash character (#7531: and string promotion)
  5417. // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
  5418. // We also use the url parameter if available
  5419. s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
  5420. // Extract dataTypes list
  5421. s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( rspacesAjax );
  5422. // Determine if a cross-domain request is in order
  5423. if ( s.crossDomain == null ) {
  5424. parts = rurl.exec( s.url.toLowerCase() );
  5425. s.crossDomain = !!( parts &&
  5426. ( parts[ 1 ] != ajaxLocParts[ 1 ] || parts[ 2 ] != ajaxLocParts[ 2 ] ||
  5427. ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) !=
  5428. ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) )
  5429. );
  5430. }
  5431. // Convert data if not already a string
  5432. if ( s.data && s.processData && typeof s.data !== "string" ) {
  5433. s.data = jQuery.param( s.data, s.traditional );
  5434. }
  5435. // Apply prefilters
  5436. inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
  5437. // If request was aborted inside a prefiler, stop there
  5438. if ( state === 2 ) {
  5439. return false;
  5440. }
  5441. // We can fire global events as of now if asked to
  5442. fireGlobals = s.global;
  5443. // Uppercase the type
  5444. s.type = s.type.toUpperCase();
  5445. // Determine if request has content
  5446. s.hasContent = !rnoContent.test( s.type );
  5447. // Watch for a new set of requests
  5448. if ( fireGlobals && jQuery.active++ === 0 ) {
  5449. jQuery.event.trigger( "ajaxStart" );
  5450. }
  5451. // More options handling for requests with no content
  5452. if ( !s.hasContent ) {
  5453. // If data is available, append data to url
  5454. if ( s.data ) {
  5455. s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data;
  5456. }
  5457. // Get ifModifiedKey before adding the anti-cache parameter
  5458. ifModifiedKey = s.url;
  5459. // Add anti-cache in url if needed
  5460. if ( s.cache === false ) {
  5461. var ts = jQuery.now(),
  5462. // try replacing _= if it is there
  5463. ret = s.url.replace( rts, "$1_=" + ts );
  5464. // if nothing was replaced, add timestamp to the end
  5465. s.url = ret + ( (ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" );
  5466. }
  5467. }
  5468. // Set the correct header, if data is being sent
  5469. if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
  5470. requestHeaders[ "Content-Type" ] = s.contentType;
  5471. }
  5472. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  5473. if ( s.ifModified ) {
  5474. ifModifiedKey = ifModifiedKey || s.url;
  5475. if ( jQuery.lastModified[ ifModifiedKey ] ) {
  5476. requestHeaders[ "If-Modified-Since" ] = jQuery.lastModified[ ifModifiedKey ];
  5477. }
  5478. if ( jQuery.etag[ ifModifiedKey ] ) {
  5479. requestHeaders[ "If-None-Match" ] = jQuery.etag[ ifModifiedKey ];
  5480. }
  5481. }
  5482. // Set the Accepts header for the server, depending on the dataType
  5483. requestHeaders.Accept = s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
  5484. s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", */*; q=0.01" : "" ) :
  5485. s.accepts[ "*" ];
  5486. // Check for headers option
  5487. for ( i in s.headers ) {
  5488. jqXHR.setRequestHeader( i, s.headers[ i ] );
  5489. }
  5490. // Allow custom headers/mimetypes and early abort
  5491. if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
  5492. // Abort if not done already
  5493. jqXHR.abort();
  5494. return false;
  5495. }
  5496. // Install callbacks on deferreds
  5497. for ( i in { success: 1, error: 1, complete: 1 } ) {
  5498. jqXHR[ i ]( s[ i ] );
  5499. }
  5500. // Get transport
  5501. transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
  5502. // If no transport, we auto-abort
  5503. if ( !transport ) {
  5504. done( -1, "No Transport" );
  5505. } else {
  5506. jqXHR.readyState = 1;
  5507. // Send global event
  5508. if ( fireGlobals ) {
  5509. globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
  5510. }
  5511. // Timeout
  5512. if ( s.async && s.timeout > 0 ) {
  5513. timeoutTimer = setTimeout( function(){
  5514. jqXHR.abort( "timeout" );
  5515. }, s.timeout );
  5516. }
  5517. try {
  5518. state = 1;
  5519. transport.send( requestHeaders, done );
  5520. } catch (e) {
  5521. // Propagate exception as error if not done
  5522. if ( status < 2 ) {
  5523. done( -1, e );
  5524. // Simply rethrow otherwise
  5525. } else {
  5526. jQuery.error( e );
  5527. }
  5528. }
  5529. }
  5530. return jqXHR;
  5531. },
  5532. // Serialize an array of form elements or a set of
  5533. // key/values into a query string
  5534. param: function( a, traditional ) {
  5535. var s = [],
  5536. add = function( key, value ) {
  5537. // If value is a function, invoke it and return its value
  5538. value = jQuery.isFunction( value ) ? value() : value;
  5539. s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
  5540. };
  5541. // Set traditional to true for jQuery <= 1.3.2 behavior.
  5542. if ( traditional === undefined ) {
  5543. traditional = jQuery.ajaxSettings.traditional;
  5544. }
  5545. // If an array was passed in, assume that it is an array of form elements.
  5546. if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
  5547. // Serialize the form elements
  5548. jQuery.each( a, function() {
  5549. add( this.name, this.value );
  5550. } );
  5551. } else {
  5552. // If traditional, encode the "old" way (the way 1.3.2 or older
  5553. // did it), otherwise encode params recursively.
  5554. for ( var prefix in a ) {
  5555. buildParams( prefix, a[ prefix ], traditional, add );
  5556. }
  5557. }
  5558. // Return the resulting serialization
  5559. return s.join( "&" ).replace( r20, "+" );
  5560. }
  5561. });
  5562. function buildParams( prefix, obj, traditional, add ) {
  5563. if ( jQuery.isArray( obj ) && obj.length ) {
  5564. // Serialize array item.
  5565. jQuery.each( obj, function( i, v ) {
  5566. if ( traditional || rbracket.test( prefix ) ) {
  5567. // Treat each array item as a scalar.
  5568. add( prefix, v );
  5569. } else {
  5570. // If array item is non-scalar (array or object), encode its
  5571. // numeric index to resolve deserialization ambiguity issues.
  5572. // Note that rack (as of 1.0.0) can't currently deserialize
  5573. // nested arrays properly, and attempting to do so may cause
  5574. // a server error. Possible fixes are to modify rack's
  5575. // deserialization algorithm or to provide an option or flag
  5576. // to force array serialization to be shallow.
  5577. buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v, traditional, add );
  5578. }
  5579. });
  5580. } else if ( !traditional && obj != null && typeof obj === "object" ) {
  5581. // If we see an array here, it is empty and should be treated as an empty
  5582. // object
  5583. if ( jQuery.isArray( obj ) || jQuery.isEmptyObject( obj ) ) {
  5584. add( prefix, "" );
  5585. // Serialize object item.
  5586. } else {
  5587. for ( var name in obj ) {
  5588. buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
  5589. }
  5590. }
  5591. } else {
  5592. // Serialize scalar item.
  5593. add( prefix, obj );
  5594. }
  5595. }
  5596. // This is still on the jQuery object... for now
  5597. // Want to move this to jQuery.ajax some day
  5598. jQuery.extend({
  5599. // Counter for holding the number of active queries
  5600. active: 0,
  5601. // Last-Modified header cache for next request
  5602. lastModified: {},
  5603. etag: {}
  5604. });
  5605. /* Handles responses to an ajax request:
  5606. * - sets all responseXXX fields accordingly
  5607. * - finds the right dataType (mediates between content-type and expected dataType)
  5608. * - returns the corresponding response
  5609. */
  5610. function ajaxHandleResponses( s, jqXHR, responses ) {
  5611. var contents = s.contents,
  5612. dataTypes = s.dataTypes,
  5613. responseFields = s.responseFields,
  5614. ct,
  5615. type,
  5616. finalDataType,
  5617. firstDataType;
  5618. // Fill responseXXX fields
  5619. for( type in responseFields ) {
  5620. if ( type in responses ) {
  5621. jqXHR[ responseFields[type] ] = responses[ type ];
  5622. }
  5623. }
  5624. // Remove auto dataType and get content-type in the process
  5625. while( dataTypes[ 0 ] === "*" ) {
  5626. dataTypes.shift();
  5627. if ( ct === undefined ) {
  5628. ct = s.mimeType || jqXHR.getResponseHeader( "content-type" );
  5629. }
  5630. }
  5631. // Check if we're dealing with a known content-type
  5632. if ( ct ) {
  5633. for ( type in contents ) {
  5634. if ( contents[ type ] && contents[ type ].test( ct ) ) {
  5635. dataTypes.unshift( type );
  5636. break;
  5637. }
  5638. }
  5639. }
  5640. // Check to see if we have a response for the expected dataType
  5641. if ( dataTypes[ 0 ] in responses ) {
  5642. finalDataType = dataTypes[ 0 ];
  5643. } else {
  5644. // Try convertible dataTypes
  5645. for ( type in responses ) {
  5646. if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
  5647. finalDataType = type;
  5648. break;
  5649. }
  5650. if ( !firstDataType ) {
  5651. firstDataType = type;
  5652. }
  5653. }
  5654. // Or just use first one
  5655. finalDataType = finalDataType || firstDataType;
  5656. }
  5657. // If we found a dataType
  5658. // We add the dataType to the list if needed
  5659. // and return the corresponding response
  5660. if ( finalDataType ) {
  5661. if ( finalDataType !== dataTypes[ 0 ] ) {
  5662. dataTypes.unshift( finalDataType );
  5663. }
  5664. return responses[ finalDataType ];
  5665. }
  5666. }
  5667. // Chain conversions given the request and the original response
  5668. function ajaxConvert( s, response ) {
  5669. // Apply the dataFilter if provided
  5670. if ( s.dataFilter ) {
  5671. response = s.dataFilter( response, s.dataType );
  5672. }
  5673. var dataTypes = s.dataTypes,
  5674. converters = {},
  5675. i,
  5676. key,
  5677. length = dataTypes.length,
  5678. tmp,
  5679. // Current and previous dataTypes
  5680. current = dataTypes[ 0 ],
  5681. prev,
  5682. // Conversion expression
  5683. conversion,
  5684. // Conversion function
  5685. conv,
  5686. // Conversion functions (transitive conversion)
  5687. conv1,
  5688. conv2;
  5689. // For each dataType in the chain
  5690. for( i = 1; i < length; i++ ) {
  5691. // Create converters map
  5692. // with lowercased keys
  5693. if ( i === 1 ) {
  5694. for( key in s.converters ) {
  5695. if( typeof key === "string" ) {
  5696. converters[ key.toLowerCase() ] = s.converters[ key ];
  5697. }
  5698. }
  5699. }
  5700. // Get the dataTypes
  5701. prev = current;
  5702. current = dataTypes[ i ];
  5703. // If current is auto dataType, update it to prev
  5704. if( current === "*" ) {
  5705. current = prev;
  5706. // If no auto and dataTypes are actually different
  5707. } else if ( prev !== "*" && prev !== current ) {
  5708. // Get the converter
  5709. conversion = prev + " " + current;
  5710. conv = converters[ conversion ] || converters[ "* " + current ];
  5711. // If there is no direct converter, search transitively
  5712. if ( !conv ) {
  5713. conv2 = undefined;
  5714. for( conv1 in converters ) {
  5715. tmp = conv1.split( " " );
  5716. if ( tmp[ 0 ] === prev || tmp[ 0 ] === "*" ) {
  5717. conv2 = converters[ tmp[1] + " " + current ];
  5718. if ( conv2 ) {
  5719. conv1 = converters[ conv1 ];
  5720. if ( conv1 === true ) {
  5721. conv = conv2;
  5722. } else if ( conv2 === true ) {
  5723. conv = conv1;
  5724. }
  5725. break;
  5726. }
  5727. }
  5728. }
  5729. }
  5730. // If we found no converter, dispatch an error
  5731. if ( !( conv || conv2 ) ) {
  5732. jQuery.error( "No conversion from " + conversion.replace(" "," to ") );
  5733. }
  5734. // If found converter is not an equivalence
  5735. if ( conv !== true ) {
  5736. // Convert with 1 or 2 converters accordingly
  5737. response = conv ? conv( response ) : conv2( conv1(response) );
  5738. }
  5739. }
  5740. }
  5741. return response;
  5742. }
  5743. var jsc = jQuery.now(),
  5744. jsre = /(\=)\?(&|$)|\?\?/i;
  5745. // Default jsonp settings
  5746. jQuery.ajaxSetup({
  5747. jsonp: "callback",
  5748. jsonpCallback: function() {
  5749. return jQuery.expando + "_" + ( jsc++ );
  5750. }
  5751. });
  5752. // Detect, normalize options and install callbacks for jsonp requests
  5753. jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
  5754. var dataIsString = ( typeof s.data === "string" );
  5755. if ( s.dataTypes[ 0 ] === "jsonp" ||
  5756. originalSettings.jsonpCallback ||
  5757. originalSettings.jsonp != null ||
  5758. s.jsonp !== false && ( jsre.test( s.url ) ||
  5759. dataIsString && jsre.test( s.data ) ) ) {
  5760. var responseContainer,
  5761. jsonpCallback = s.jsonpCallback =
  5762. jQuery.isFunction( s.jsonpCallback ) ? s.jsonpCallback() : s.jsonpCallback,
  5763. previous = window[ jsonpCallback ],
  5764. url = s.url,
  5765. data = s.data,
  5766. replace = "$1" + jsonpCallback + "$2",
  5767. cleanUp = function() {
  5768. // Set callback back to previous value
  5769. window[ jsonpCallback ] = previous;
  5770. // Call if it was a function and we have a response
  5771. if ( responseContainer && jQuery.isFunction( previous ) ) {
  5772. window[ jsonpCallback ]( responseContainer[ 0 ] );
  5773. }
  5774. };
  5775. if ( s.jsonp !== false ) {
  5776. url = url.replace( jsre, replace );
  5777. if ( s.url === url ) {
  5778. if ( dataIsString ) {
  5779. data = data.replace( jsre, replace );
  5780. }
  5781. if ( s.data === data ) {
  5782. // Add callback manually
  5783. url += (/\?/.test( url ) ? "&" : "?") + s.jsonp + "=" + jsonpCallback;
  5784. }
  5785. }
  5786. }
  5787. s.url = url;
  5788. s.data = data;
  5789. // Install callback
  5790. window[ jsonpCallback ] = function( response ) {
  5791. responseContainer = [ response ];
  5792. };
  5793. // Install cleanUp function
  5794. jqXHR.then( cleanUp, cleanUp );
  5795. // Use data converter to retrieve json after script execution
  5796. s.converters["script json"] = function() {
  5797. if ( !responseContainer ) {
  5798. jQuery.error( jsonpCallback + " was not called" );
  5799. }
  5800. return responseContainer[ 0 ];
  5801. };
  5802. // force json dataType
  5803. s.dataTypes[ 0 ] = "json";
  5804. // Delegate to script
  5805. return "script";
  5806. }
  5807. } );
  5808. // Install script dataType
  5809. jQuery.ajaxSetup({
  5810. accepts: {
  5811. script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
  5812. },
  5813. contents: {
  5814. script: /javascript|ecmascript/
  5815. },
  5816. converters: {
  5817. "text script": function( text ) {
  5818. jQuery.globalEval( text );
  5819. return text;
  5820. }
  5821. }
  5822. });
  5823. // Handle cache's special case and global
  5824. jQuery.ajaxPrefilter( "script", function( s ) {
  5825. if ( s.cache === undefined ) {
  5826. s.cache = false;
  5827. }
  5828. if ( s.crossDomain ) {
  5829. s.type = "GET";
  5830. s.global = false;
  5831. }
  5832. } );
  5833. // Bind script tag hack transport
  5834. jQuery.ajaxTransport( "script", function(s) {
  5835. // This transport only deals with cross domain requests
  5836. if ( s.crossDomain ) {
  5837. var script,
  5838. head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement;
  5839. return {
  5840. send: function( _, callback ) {
  5841. script = document.createElement( "script" );
  5842. script.async = "async";
  5843. if ( s.scriptCharset ) {
  5844. script.charset = s.scriptCharset;
  5845. }
  5846. script.src = s.url;
  5847. // Attach handlers for all browsers
  5848. script.onload = script.onreadystatechange = function( _, isAbort ) {
  5849. if ( !script.readyState || /loaded|complete/.test( script.readyState ) ) {
  5850. // Handle memory leak in IE
  5851. script.onload = script.onreadystatechange = null;
  5852. // Remove the script
  5853. if ( head && script.parentNode ) {
  5854. head.removeChild( script );
  5855. }
  5856. // Dereference the script
  5857. script = undefined;
  5858. // Callback if not abort
  5859. if ( !isAbort ) {
  5860. callback( 200, "success" );
  5861. }
  5862. }
  5863. };
  5864. // Use insertBefore instead of appendChild to circumvent an IE6 bug.
  5865. // This arises when a base node is used (#2709 and #4378).
  5866. head.insertBefore( script, head.firstChild );
  5867. },
  5868. abort: function() {
  5869. if ( script ) {
  5870. script.onload( 0, 1 );
  5871. }
  5872. }
  5873. };
  5874. }
  5875. } );
  5876. var // #5280: next active xhr id and list of active xhrs' callbacks
  5877. xhrId = jQuery.now(),
  5878. xhrCallbacks,
  5879. // XHR used to determine supports properties
  5880. testXHR;
  5881. // #5280: Internet Explorer will keep connections alive if we don't abort on unload
  5882. function xhrOnUnloadAbort() {
  5883. jQuery( window ).unload(function() {
  5884. // Abort all pending requests
  5885. for ( var key in xhrCallbacks ) {
  5886. xhrCallbacks[ key ]( 0, 1 );
  5887. }
  5888. });
  5889. }
  5890. // Functions to create xhrs
  5891. function createStandardXHR() {
  5892. try {
  5893. return new window.XMLHttpRequest();
  5894. } catch( e ) {}
  5895. }
  5896. function createActiveXHR() {
  5897. try {
  5898. return new window.ActiveXObject( "Microsoft.XMLHTTP" );
  5899. } catch( e ) {}
  5900. }
  5901. // Create the request object
  5902. // (This is still attached to ajaxSettings for backward compatibility)
  5903. jQuery.ajaxSettings.xhr = window.ActiveXObject ?
  5904. /* Microsoft failed to properly
  5905. * implement the XMLHttpRequest in IE7 (can't request local files),
  5906. * so we use the ActiveXObject when it is available
  5907. * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
  5908. * we need a fallback.
  5909. */
  5910. function() {
  5911. return !this.isLocal && createStandardXHR() || createActiveXHR();
  5912. } :
  5913. // For all other browsers, use the standard XMLHttpRequest object
  5914. createStandardXHR;
  5915. // Test if we can create an xhr object
  5916. testXHR = jQuery.ajaxSettings.xhr();
  5917. jQuery.support.ajax = !!testXHR;
  5918. // Does this browser support crossDomain XHR requests
  5919. jQuery.support.cors = testXHR && ( "withCredentials" in testXHR );
  5920. // No need for the temporary xhr anymore
  5921. testXHR = undefined;
  5922. // Create transport if the browser can provide an xhr
  5923. if ( jQuery.support.ajax ) {
  5924. jQuery.ajaxTransport(function( s ) {
  5925. // Cross domain only allowed if supported through XMLHttpRequest
  5926. if ( !s.crossDomain || jQuery.support.cors ) {
  5927. var callback;
  5928. return {
  5929. send: function( headers, complete ) {
  5930. // Get a new xhr
  5931. var xhr = s.xhr(),
  5932. handle,
  5933. i;
  5934. // Open the socket
  5935. // Passing null username, generates a login popup on Opera (#2865)
  5936. if ( s.username ) {
  5937. xhr.open( s.type, s.url, s.async, s.username, s.password );
  5938. } else {
  5939. xhr.open( s.type, s.url, s.async );
  5940. }
  5941. // Apply custom fields if provided
  5942. if ( s.xhrFields ) {
  5943. for ( i in s.xhrFields ) {
  5944. xhr[ i ] = s.xhrFields[ i ];
  5945. }
  5946. }
  5947. // Override mime type if needed
  5948. if ( s.mimeType && xhr.overrideMimeType ) {
  5949. xhr.overrideMimeType( s.mimeType );
  5950. }
  5951. // X-Requested-With header
  5952. // For cross-domain requests, seeing as conditions for a preflight are
  5953. // akin to a jigsaw puzzle, we simply never set it to be sure.
  5954. // (it can always be set on a per-request basis or even using ajaxSetup)
  5955. // For same-domain requests, won't change header if already provided.
  5956. if ( !s.crossDomain && !headers["X-Requested-With"] ) {
  5957. headers[ "X-Requested-With" ] = "XMLHttpRequest";
  5958. }
  5959. // Need an extra try/catch for cross domain requests in Firefox 3
  5960. try {
  5961. for ( i in headers ) {
  5962. xhr.setRequestHeader( i, headers[ i ] );
  5963. }
  5964. } catch( _ ) {}
  5965. // Do send the request
  5966. // This may raise an exception which is actually
  5967. // handled in jQuery.ajax (so no try/catch here)
  5968. xhr.send( ( s.hasContent && s.data ) || null );
  5969. // Listener
  5970. callback = function( _, isAbort ) {
  5971. var status,
  5972. statusText,
  5973. responseHeaders,
  5974. responses,
  5975. xml;
  5976. // Firefox throws exceptions when accessing properties
  5977. // of an xhr when a network error occured
  5978. // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
  5979. try {
  5980. // Was never called and is aborted or complete
  5981. if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
  5982. // Only called once
  5983. callback = undefined;
  5984. // Do not keep as active anymore
  5985. if ( handle ) {
  5986. xhr.onreadystatechange = jQuery.noop;
  5987. delete xhrCallbacks[ handle ];
  5988. }
  5989. // If it's an abort
  5990. if ( isAbort ) {
  5991. // Abort it manually if needed
  5992. if ( xhr.readyState !== 4 ) {
  5993. xhr.abort();
  5994. }
  5995. } else {
  5996. status = xhr.status;
  5997. responseHeaders = xhr.getAllResponseHeaders();
  5998. responses = {};
  5999. xml = xhr.responseXML;
  6000. // Construct response list
  6001. if ( xml && xml.documentElement /* #4958 */ ) {
  6002. responses.xml = xml;
  6003. }
  6004. responses.text = xhr.responseText;
  6005. // Firefox throws an exception when accessing
  6006. // statusText for faulty cross-domain requests
  6007. try {
  6008. statusText = xhr.statusText;
  6009. } catch( e ) {
  6010. // We normalize with Webkit giving an empty statusText
  6011. statusText = "";
  6012. }
  6013. // Filter status for non standard behaviors
  6014. // If the request is local and we have data: assume a success
  6015. // (success with no data won't get notified, that's the best we
  6016. // can do given current implementations)
  6017. if ( !status && s.isLocal && !s.crossDomain ) {
  6018. status = responses.text ? 200 : 404;
  6019. // IE - #1450: sometimes returns 1223 when it should be 204
  6020. } else if ( status === 1223 ) {
  6021. status = 204;
  6022. }
  6023. }
  6024. }
  6025. } catch( firefoxAccessException ) {
  6026. if ( !isAbort ) {
  6027. complete( -1, firefoxAccessException );
  6028. }
  6029. }
  6030. // Call complete if needed
  6031. if ( responses ) {
  6032. complete( status, statusText, responses, responseHeaders );
  6033. }
  6034. };
  6035. // if we're in sync mode or it's in cache
  6036. // and has been retrieved directly (IE6 & IE7)
  6037. // we need to manually fire the callback
  6038. if ( !s.async || xhr.readyState === 4 ) {
  6039. callback();
  6040. } else {
  6041. // Create the active xhrs callbacks list if needed
  6042. // and attach the unload handler
  6043. if ( !xhrCallbacks ) {
  6044. xhrCallbacks = {};
  6045. xhrOnUnloadAbort();
  6046. }
  6047. // Add to list of active xhrs callbacks
  6048. handle = xhrId++;
  6049. xhr.onreadystatechange = xhrCallbacks[ handle ] = callback;
  6050. }
  6051. },
  6052. abort: function() {
  6053. if ( callback ) {
  6054. callback(0,1);
  6055. }
  6056. }
  6057. };
  6058. }
  6059. });
  6060. }
  6061. var elemdisplay = {},
  6062. rfxtypes = /^(?:toggle|show|hide)$/,
  6063. rfxnum = /^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,
  6064. timerId,
  6065. fxAttrs = [
  6066. // height animations
  6067. [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
  6068. // width animations
  6069. [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
  6070. // opacity animations
  6071. [ "opacity" ]
  6072. ];
  6073. jQuery.fn.extend({
  6074. show: function( speed, easing, callback ) {
  6075. var elem, display;
  6076. if ( speed || speed === 0 ) {
  6077. return this.animate( genFx("show", 3), speed, easing, callback);
  6078. } else {
  6079. for ( var i = 0, j = this.length; i < j; i++ ) {
  6080. elem = this[i];
  6081. display = elem.style.display;
  6082. // Reset the inline display of this element to learn if it is
  6083. // being hidden by cascaded rules or not
  6084. if ( !jQuery._data(elem, "olddisplay") && display === "none" ) {
  6085. display = elem.style.display = "";
  6086. }
  6087. // Set elements which have been overridden with display: none
  6088. // in a stylesheet to whatever the default browser style is
  6089. // for such an element
  6090. if ( display === "" && jQuery.css( elem, "display" ) === "none" ) {
  6091. jQuery._data(elem, "olddisplay", defaultDisplay(elem.nodeName));
  6092. }
  6093. }
  6094. // Set the display of most of the elements in a second loop
  6095. // to avoid the constant reflow
  6096. for ( i = 0; i < j; i++ ) {
  6097. elem = this[i];
  6098. display = elem.style.display;
  6099. if ( display === "" || display === "none" ) {
  6100. elem.style.display = jQuery._data(elem, "olddisplay") || "";
  6101. }
  6102. }
  6103. return this;
  6104. }
  6105. },
  6106. hide: function( speed, easing, callback ) {
  6107. if ( speed || speed === 0 ) {
  6108. return this.animate( genFx("hide", 3), speed, easing, callback);
  6109. } else {
  6110. for ( var i = 0, j = this.length; i < j; i++ ) {
  6111. var display = jQuery.css( this[i], "display" );
  6112. if ( display !== "none" && !jQuery._data( this[i], "olddisplay" ) ) {
  6113. jQuery._data( this[i], "olddisplay", display );
  6114. }
  6115. }
  6116. // Set the display of the elements in a second loop
  6117. // to avoid the constant reflow
  6118. for ( i = 0; i < j; i++ ) {
  6119. this[i].style.display = "none";
  6120. }
  6121. return this;
  6122. }
  6123. },
  6124. // Save the old toggle function
  6125. _toggle: jQuery.fn.toggle,
  6126. toggle: function( fn, fn2, callback ) {
  6127. var bool = typeof fn === "boolean";
  6128. if ( jQuery.isFunction(fn) && jQuery.isFunction(fn2) ) {
  6129. this._toggle.apply( this, arguments );
  6130. } else if ( fn == null || bool ) {
  6131. this.each(function() {
  6132. var state = bool ? fn : jQuery(this).is(":hidden");
  6133. jQuery(this)[ state ? "show" : "hide" ]();
  6134. });
  6135. } else {
  6136. this.animate(genFx("toggle", 3), fn, fn2, callback);
  6137. }
  6138. return this;
  6139. },
  6140. fadeTo: function( speed, to, easing, callback ) {
  6141. return this.filter(":hidden").css("opacity", 0).show().end()
  6142. .animate({opacity: to}, speed, easing, callback);
  6143. },
  6144. animate: function( prop, speed, easing, callback ) {
  6145. var optall = jQuery.speed(speed, easing, callback);
  6146. if ( jQuery.isEmptyObject( prop ) ) {
  6147. return this.each( optall.complete );
  6148. }
  6149. return this[ optall.queue === false ? "each" : "queue" ](function() {
  6150. // XXX 'this' does not always have a nodeName when running the
  6151. // test suite
  6152. var opt = jQuery.extend({}, optall), p,
  6153. isElement = this.nodeType === 1,
  6154. hidden = isElement && jQuery(this).is(":hidden"),
  6155. self = this;
  6156. for ( p in prop ) {
  6157. var name = jQuery.camelCase( p );
  6158. if ( p !== name ) {
  6159. prop[ name ] = prop[ p ];
  6160. delete prop[ p ];
  6161. p = name;
  6162. }
  6163. if ( prop[p] === "hide" && hidden || prop[p] === "show" && !hidden ) {
  6164. return opt.complete.call(this);
  6165. }
  6166. if ( isElement && ( p === "height" || p === "width" ) ) {
  6167. // Make sure that nothing sneaks out
  6168. // Record all 3 overflow attributes because IE does not
  6169. // change the overflow attribute when overflowX and
  6170. // overflowY are set to the same value
  6171. opt.overflow = [ this.style.overflow, this.style.overflowX, this.style.overflowY ];
  6172. // Set display property to inline-block for height/width
  6173. // animations on inline elements that are having width/height
  6174. // animated
  6175. if ( jQuery.css( this, "display" ) === "inline" &&
  6176. jQuery.css( this, "float" ) === "none" ) {
  6177. if ( !jQuery.support.inlineBlockNeedsLayout ) {
  6178. this.style.display = "inline-block";
  6179. } else {
  6180. var display = defaultDisplay(this.nodeName);
  6181. // inline-level elements accept inline-block;
  6182. // block-level elements need to be inline with layout
  6183. if ( display === "inline" ) {
  6184. this.style.display = "inline-block";
  6185. } else {
  6186. this.style.display = "inline";
  6187. this.style.zoom = 1;
  6188. }
  6189. }
  6190. }
  6191. }
  6192. if ( jQuery.isArray( prop[p] ) ) {
  6193. // Create (if needed) and add to specialEasing
  6194. (opt.specialEasing = opt.specialEasing || {})[p] = prop[p][1];
  6195. prop[p] = prop[p][0];
  6196. }
  6197. }
  6198. if ( opt.overflow != null ) {
  6199. this.style.overflow = "hidden";
  6200. }
  6201. opt.curAnim = jQuery.extend({}, prop);
  6202. jQuery.each( prop, function( name, val ) {
  6203. var e = new jQuery.fx( self, opt, name );
  6204. if ( rfxtypes.test(val) ) {
  6205. e[ val === "toggle" ? hidden ? "show" : "hide" : val ]( prop );
  6206. } else {
  6207. var parts = rfxnum.exec(val),
  6208. start = e.cur();
  6209. if ( parts ) {
  6210. var end = parseFloat( parts[2] ),
  6211. unit = parts[3] || ( jQuery.cssNumber[ name ] ? "" : "px" );
  6212. // We need to compute starting value
  6213. if ( unit !== "px" ) {
  6214. jQuery.style( self, name, (end || 1) + unit);
  6215. start = ((end || 1) / e.cur()) * start;
  6216. jQuery.style( self, name, start + unit);
  6217. }
  6218. // If a +=/-= token was provided, we're doing a relative animation
  6219. if ( parts[1] ) {
  6220. end = ((parts[1] === "-=" ? -1 : 1) * end) + start;
  6221. }
  6222. e.custom( start, end, unit );
  6223. } else {
  6224. e.custom( start, val, "" );
  6225. }
  6226. }
  6227. });
  6228. // For JS strict compliance
  6229. return true;
  6230. });
  6231. },
  6232. stop: function( clearQueue, gotoEnd ) {
  6233. var timers = jQuery.timers;
  6234. if ( clearQueue ) {
  6235. this.queue([]);
  6236. }
  6237. this.each(function() {
  6238. // go in reverse order so anything added to the queue during the loop is ignored
  6239. for ( var i = timers.length - 1; i >= 0; i-- ) {
  6240. if ( timers[i].elem === this ) {
  6241. if (gotoEnd) {
  6242. // force the next step to be the last
  6243. timers[i](true);
  6244. }
  6245. timers.splice(i, 1);
  6246. }
  6247. }
  6248. });
  6249. // start the next in the queue if the last step wasn't forced
  6250. if ( !gotoEnd ) {
  6251. this.dequeue();
  6252. }
  6253. return this;
  6254. }
  6255. });
  6256. function genFx( type, num ) {
  6257. var obj = {};
  6258. jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function() {
  6259. obj[ this ] = type;
  6260. });
  6261. return obj;
  6262. }
  6263. // Generate shortcuts for custom animations
  6264. jQuery.each({
  6265. slideDown: genFx("show", 1),
  6266. slideUp: genFx("hide", 1),
  6267. slideToggle: genFx("toggle", 1),
  6268. fadeIn: { opacity: "show" },
  6269. fadeOut: { opacity: "hide" },
  6270. fadeToggle: { opacity: "toggle" }
  6271. }, function( name, props ) {
  6272. jQuery.fn[ name ] = function( speed, easing, callback ) {
  6273. return this.animate( props, speed, easing, callback );
  6274. };
  6275. });
  6276. jQuery.extend({
  6277. speed: function( speed, easing, fn ) {
  6278. var opt = speed && typeof speed === "object" ? jQuery.extend({}, speed) : {
  6279. complete: fn || !fn && easing ||
  6280. jQuery.isFunction( speed ) && speed,
  6281. duration: speed,
  6282. easing: fn && easing || easing && !jQuery.isFunction(easing) && easing
  6283. };
  6284. opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
  6285. opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[opt.duration] : jQuery.fx.speeds._default;
  6286. // Queueing
  6287. opt.old = opt.complete;
  6288. opt.complete = function() {
  6289. if ( opt.queue !== false ) {
  6290. jQuery(this).dequeue();
  6291. }
  6292. if ( jQuery.isFunction( opt.old ) ) {
  6293. opt.old.call( this );
  6294. }
  6295. };
  6296. return opt;
  6297. },
  6298. easing: {
  6299. linear: function( p, n, firstNum, diff ) {
  6300. return firstNum + diff * p;
  6301. },
  6302. swing: function( p, n, firstNum, diff ) {
  6303. return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
  6304. }
  6305. },
  6306. timers: [],
  6307. fx: function( elem, options, prop ) {
  6308. this.options = options;
  6309. this.elem = elem;
  6310. this.prop = prop;
  6311. if ( !options.orig ) {
  6312. options.orig = {};
  6313. }
  6314. }
  6315. });
  6316. jQuery.fx.prototype = {
  6317. // Simple function for setting a style value
  6318. update: function() {
  6319. if ( this.options.step ) {
  6320. this.options.step.call( this.elem, this.now, this );
  6321. }
  6322. (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
  6323. },
  6324. // Get the current size
  6325. cur: function() {
  6326. if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) {
  6327. return this.elem[ this.prop ];
  6328. }
  6329. var parsed,
  6330. r = jQuery.css( this.elem, this.prop );
  6331. // Empty strings, null, undefined and "auto" are converted to 0,
  6332. // complex values such as "rotate(1rad)" are returned as is,
  6333. // simple values such as "10px" are parsed to Float.
  6334. return isNaN( parsed = parseFloat( r ) ) ? !r || r === "auto" ? 0 : r : parsed;
  6335. },
  6336. // Start an animation from one number to another
  6337. custom: function( from, to, unit ) {
  6338. var self = this,
  6339. fx = jQuery.fx;
  6340. this.startTime = jQuery.now();
  6341. this.start = from;
  6342. this.end = to;
  6343. this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" );
  6344. this.now = this.start;
  6345. this.pos = this.state = 0;
  6346. function t( gotoEnd ) {
  6347. return self.step(gotoEnd);
  6348. }
  6349. t.elem = this.elem;
  6350. if ( t() && jQuery.timers.push(t) && !timerId ) {
  6351. timerId = setInterval(fx.tick, fx.interval);
  6352. }
  6353. },
  6354. // Simple 'show' function
  6355. show: function() {
  6356. // Remember where we started, so that we can go back to it later
  6357. this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
  6358. this.options.show = true;
  6359. // Begin the animation
  6360. // Make sure that we start at a small width/height to avoid any
  6361. // flash of content
  6362. this.custom(this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur());
  6363. // Start by showing the element
  6364. jQuery( this.elem ).show();
  6365. },
  6366. // Simple 'hide' function
  6367. hide: function() {
  6368. // Remember where we started, so that we can go back to it later
  6369. this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
  6370. this.options.hide = true;
  6371. // Begin the animation
  6372. this.custom(this.cur(), 0);
  6373. },
  6374. // Each step of an animation
  6375. step: function( gotoEnd ) {
  6376. var t = jQuery.now(), done = true;
  6377. if ( gotoEnd || t >= this.options.duration + this.startTime ) {
  6378. this.now = this.end;
  6379. this.pos = this.state = 1;
  6380. this.update();
  6381. this.options.curAnim[ this.prop ] = true;
  6382. for ( var i in this.options.curAnim ) {
  6383. if ( this.options.curAnim[i] !== true ) {
  6384. done = false;
  6385. }
  6386. }
  6387. if ( done ) {
  6388. // Reset the overflow
  6389. if ( this.options.overflow != null && !jQuery.support.shrinkWrapBlocks ) {
  6390. var elem = this.elem,
  6391. options = this.options;
  6392. jQuery.each( [ "", "X", "Y" ], function (index, value) {
  6393. elem.style[ "overflow" + value ] = options.overflow[index];
  6394. } );
  6395. }
  6396. // Hide the element if the "hide" operation was done
  6397. if ( this.options.hide ) {
  6398. jQuery(this.elem).hide();
  6399. }
  6400. // Reset the properties, if the item has been hidden or shown
  6401. if ( this.options.hide || this.options.show ) {
  6402. for ( var p in this.options.curAnim ) {
  6403. jQuery.style( this.elem, p, this.options.orig[p] );
  6404. }
  6405. }
  6406. // Execute the complete function
  6407. this.options.complete.call( this.elem );
  6408. }
  6409. return false;
  6410. } else {
  6411. var n = t - this.startTime;
  6412. this.state = n / this.options.duration;
  6413. // Perform the easing function, defaults to swing
  6414. var specialEasing = this.options.specialEasing && this.options.specialEasing[this.prop];
  6415. var defaultEasing = this.options.easing || (jQuery.easing.swing ? "swing" : "linear");
  6416. this.pos = jQuery.easing[specialEasing || defaultEasing](this.state, n, 0, 1, this.options.duration);
  6417. this.now = this.start + ((this.end - this.start) * this.pos);
  6418. // Perform the next step of the animation
  6419. this.update();
  6420. }
  6421. return true;
  6422. }
  6423. };
  6424. jQuery.extend( jQuery.fx, {
  6425. tick: function() {
  6426. var timers = jQuery.timers;
  6427. for ( var i = 0; i < timers.length; i++ ) {
  6428. if ( !timers[i]() ) {
  6429. timers.splice(i--, 1);
  6430. }
  6431. }
  6432. if ( !timers.length ) {
  6433. jQuery.fx.stop();
  6434. }
  6435. },
  6436. interval: 13,
  6437. stop: function() {
  6438. clearInterval( timerId );
  6439. timerId = null;
  6440. },
  6441. speeds: {
  6442. slow: 600,
  6443. fast: 200,
  6444. // Default speed
  6445. _default: 400
  6446. },
  6447. step: {
  6448. opacity: function( fx ) {
  6449. jQuery.style( fx.elem, "opacity", fx.now );
  6450. },
  6451. _default: function( fx ) {
  6452. if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {
  6453. fx.elem.style[ fx.prop ] = (fx.prop === "width" || fx.prop === "height" ? Math.max(0, fx.now) : fx.now) + fx.unit;
  6454. } else {
  6455. fx.elem[ fx.prop ] = fx.now;
  6456. }
  6457. }
  6458. }
  6459. });
  6460. if ( jQuery.expr && jQuery.expr.filters ) {
  6461. jQuery.expr.filters.animated = function( elem ) {
  6462. return jQuery.grep(jQuery.timers, function( fn ) {
  6463. return elem === fn.elem;
  6464. }).length;
  6465. };
  6466. }
  6467. function defaultDisplay( nodeName ) {
  6468. if ( !elemdisplay[ nodeName ] ) {
  6469. var elem = jQuery("<" + nodeName + ">").appendTo("body"),
  6470. display = elem.css("display");
  6471. elem.remove();
  6472. if ( display === "none" || display === "" ) {
  6473. display = "block";
  6474. }
  6475. elemdisplay[ nodeName ] = display;
  6476. }
  6477. return elemdisplay[ nodeName ];
  6478. }
  6479. var rtable = /^t(?:able|d|h)$/i,
  6480. rroot = /^(?:body|html)$/i;
  6481. if ( "getBoundingClientRect" in document.documentElement ) {
  6482. jQuery.fn.offset = function( options ) {
  6483. var elem = this[0], box;
  6484. if ( options ) {
  6485. return this.each(function( i ) {
  6486. jQuery.offset.setOffset( this, options, i );
  6487. });
  6488. }
  6489. if ( !elem || !elem.ownerDocument ) {
  6490. return null;
  6491. }
  6492. if ( elem === elem.ownerDocument.body ) {
  6493. return jQuery.offset.bodyOffset( elem );
  6494. }
  6495. try {
  6496. box = elem.getBoundingClientRect();
  6497. } catch(e) {}
  6498. var doc = elem.ownerDocument,
  6499. docElem = doc.documentElement;
  6500. // Make sure we're not dealing with a disconnected DOM node
  6501. if ( !box || !jQuery.contains( docElem, elem ) ) {
  6502. return box ? { top: box.top, left: box.left } : { top: 0, left: 0 };
  6503. }
  6504. var body = doc.body,
  6505. win = getWindow(doc),
  6506. clientTop = docElem.clientTop || body.clientTop || 0,
  6507. clientLeft = docElem.clientLeft || body.clientLeft || 0,
  6508. scrollTop = win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop,
  6509. scrollLeft = win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft,
  6510. top = box.top + scrollTop - clientTop,
  6511. left = box.left + scrollLeft - clientLeft;
  6512. return { top: top, left: left };
  6513. };
  6514. } else {
  6515. jQuery.fn.offset = function( options ) {
  6516. var elem = this[0];
  6517. if ( options ) {
  6518. return this.each(function( i ) {
  6519. jQuery.offset.setOffset( this, options, i );
  6520. });
  6521. }
  6522. if ( !elem || !elem.ownerDocument ) {
  6523. return null;
  6524. }
  6525. if ( elem === elem.ownerDocument.body ) {
  6526. return jQuery.offset.bodyOffset( elem );
  6527. }
  6528. jQuery.offset.initialize();
  6529. var computedStyle,
  6530. offsetParent = elem.offsetParent,
  6531. prevOffsetParent = elem,
  6532. doc = elem.ownerDocument,
  6533. docElem = doc.documentElement,
  6534. body = doc.body,
  6535. defaultView = doc.defaultView,
  6536. prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle,
  6537. top = elem.offsetTop,
  6538. left = elem.offsetLeft;
  6539. while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {
  6540. if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
  6541. break;
  6542. }
  6543. computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle;
  6544. top -= elem.scrollTop;
  6545. left -= elem.scrollLeft;
  6546. if ( elem === offsetParent ) {
  6547. top += elem.offsetTop;
  6548. left += elem.offsetLeft;
  6549. if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && rtable.test(elem.nodeName)) ) {
  6550. top += parseFloat( computedStyle.borderTopWidth ) || 0;
  6551. left += parseFloat( computedStyle.borderLeftWidth ) || 0;
  6552. }
  6553. prevOffsetParent = offsetParent;
  6554. offsetParent = elem.offsetParent;
  6555. }
  6556. if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) {
  6557. top += parseFloat( computedStyle.borderTopWidth ) || 0;
  6558. left += parseFloat( computedStyle.borderLeftWidth ) || 0;
  6559. }
  6560. prevComputedStyle = computedStyle;
  6561. }
  6562. if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) {
  6563. top += body.offsetTop;
  6564. left += body.offsetLeft;
  6565. }
  6566. if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
  6567. top += Math.max( docElem.scrollTop, body.scrollTop );
  6568. left += Math.max( docElem.scrollLeft, body.scrollLeft );
  6569. }
  6570. return { top: top, left: left };
  6571. };
  6572. }
  6573. jQuery.offset = {
  6574. initialize: function() {
  6575. var body = document.body, container = document.createElement("div"), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.css(body, "marginTop") ) || 0,
  6576. html = "<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";
  6577. jQuery.extend( container.style, { position: "absolute", top: 0, left: 0, margin: 0, border: 0, width: "1px", height: "1px", visibility: "hidden" } );
  6578. container.innerHTML = html;
  6579. body.insertBefore( container, body.firstChild );
  6580. innerDiv = container.firstChild;
  6581. checkDiv = innerDiv.firstChild;
  6582. td = innerDiv.nextSibling.firstChild.firstChild;
  6583. this.doesNotAddBorder = (checkDiv.offsetTop !== 5);
  6584. this.doesAddBorderForTableAndCells = (td.offsetTop === 5);
  6585. checkDiv.style.position = "fixed";
  6586. checkDiv.style.top = "20px";
  6587. // safari subtracts parent border width here which is 5px
  6588. this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15);
  6589. checkDiv.style.position = checkDiv.style.top = "";
  6590. innerDiv.style.overflow = "hidden";
  6591. innerDiv.style.position = "relative";
  6592. this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5);
  6593. this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop);
  6594. body.removeChild( container );
  6595. jQuery.offset.initialize = jQuery.noop;
  6596. },
  6597. bodyOffset: function( body ) {
  6598. var top = body.offsetTop,
  6599. left = body.offsetLeft;
  6600. jQuery.offset.initialize();
  6601. if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) {
  6602. top += parseFloat( jQuery.css(body, "marginTop") ) || 0;
  6603. left += parseFloat( jQuery.css(body, "marginLeft") ) || 0;
  6604. }
  6605. return { top: top, left: left };
  6606. },
  6607. setOffset: function( elem, options, i ) {
  6608. var position = jQuery.css( elem, "position" );
  6609. // set position first, in-case top/left are set even on static elem
  6610. if ( position === "static" ) {
  6611. elem.style.position = "relative";
  6612. }
  6613. var curElem = jQuery( elem ),
  6614. curOffset = curElem.offset(),
  6615. curCSSTop = jQuery.css( elem, "top" ),
  6616. curCSSLeft = jQuery.css( elem, "left" ),
  6617. calculatePosition = (position === "absolute" || position === "fixed") && jQuery.inArray('auto', [curCSSTop, curCSSLeft]) > -1,
  6618. props = {}, curPosition = {}, curTop, curLeft;
  6619. // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
  6620. if ( calculatePosition ) {
  6621. curPosition = curElem.position();
  6622. }
  6623. curTop = calculatePosition ? curPosition.top : parseInt( curCSSTop, 10 ) || 0;
  6624. curLeft = calculatePosition ? curPosition.left : parseInt( curCSSLeft, 10 ) || 0;
  6625. if ( jQuery.isFunction( options ) ) {
  6626. options = options.call( elem, i, curOffset );
  6627. }
  6628. if (options.top != null) {
  6629. props.top = (options.top - curOffset.top) + curTop;
  6630. }
  6631. if (options.left != null) {
  6632. props.left = (options.left - curOffset.left) + curLeft;
  6633. }
  6634. if ( "using" in options ) {
  6635. options.using.call( elem, props );
  6636. } else {
  6637. curElem.css( props );
  6638. }
  6639. }
  6640. };
  6641. jQuery.fn.extend({
  6642. position: function() {
  6643. if ( !this[0] ) {
  6644. return null;
  6645. }
  6646. var elem = this[0],
  6647. // Get *real* offsetParent
  6648. offsetParent = this.offsetParent(),
  6649. // Get correct offsets
  6650. offset = this.offset(),
  6651. parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
  6652. // Subtract element margins
  6653. // note: when an element has margin: auto the offsetLeft and marginLeft
  6654. // are the same in Safari causing offset.left to incorrectly be 0
  6655. offset.top -= parseFloat( jQuery.css(elem, "marginTop") ) || 0;
  6656. offset.left -= parseFloat( jQuery.css(elem, "marginLeft") ) || 0;
  6657. // Add offsetParent borders
  6658. parentOffset.top += parseFloat( jQuery.css(offsetParent[0], "borderTopWidth") ) || 0;
  6659. parentOffset.left += parseFloat( jQuery.css(offsetParent[0], "borderLeftWidth") ) || 0;
  6660. // Subtract the two offsets
  6661. return {
  6662. top: offset.top - parentOffset.top,
  6663. left: offset.left - parentOffset.left
  6664. };
  6665. },
  6666. offsetParent: function() {
  6667. return this.map(function() {
  6668. var offsetParent = this.offsetParent || document.body;
  6669. while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
  6670. offsetParent = offsetParent.offsetParent;
  6671. }
  6672. return offsetParent;
  6673. });
  6674. }
  6675. });
  6676. // Create scrollLeft and scrollTop methods
  6677. jQuery.each( ["Left", "Top"], function( i, name ) {
  6678. var method = "scroll" + name;
  6679. jQuery.fn[ method ] = function(val) {
  6680. var elem = this[0], win;
  6681. if ( !elem ) {
  6682. return null;
  6683. }
  6684. if ( val !== undefined ) {
  6685. // Set the scroll offset
  6686. return this.each(function() {
  6687. win = getWindow( this );
  6688. if ( win ) {
  6689. win.scrollTo(
  6690. !i ? val : jQuery(win).scrollLeft(),
  6691. i ? val : jQuery(win).scrollTop()
  6692. );
  6693. } else {
  6694. this[ method ] = val;
  6695. }
  6696. });
  6697. } else {
  6698. win = getWindow( elem );
  6699. // Return the scroll offset
  6700. return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] :
  6701. jQuery.support.boxModel && win.document.documentElement[ method ] ||
  6702. win.document.body[ method ] :
  6703. elem[ method ];
  6704. }
  6705. };
  6706. });
  6707. function getWindow( elem ) {
  6708. return jQuery.isWindow( elem ) ?
  6709. elem :
  6710. elem.nodeType === 9 ?
  6711. elem.defaultView || elem.parentWindow :
  6712. false;
  6713. }
  6714. // Create innerHeight, innerWidth, outerHeight and outerWidth methods
  6715. jQuery.each([ "Height", "Width" ], function( i, name ) {
  6716. var type = name.toLowerCase();
  6717. // innerHeight and innerWidth
  6718. jQuery.fn["inner" + name] = function() {
  6719. return this[0] ?
  6720. parseFloat( jQuery.css( this[0], type, "padding" ) ) :
  6721. null;
  6722. };
  6723. // outerHeight and outerWidth
  6724. jQuery.fn["outer" + name] = function( margin ) {
  6725. return this[0] ?
  6726. parseFloat( jQuery.css( this[0], type, margin ? "margin" : "border" ) ) :
  6727. null;
  6728. };
  6729. jQuery.fn[ type ] = function( size ) {
  6730. // Get window width or height
  6731. var elem = this[0];
  6732. if ( !elem ) {
  6733. return size == null ? null : this;
  6734. }
  6735. if ( jQuery.isFunction( size ) ) {
  6736. return this.each(function( i ) {
  6737. var self = jQuery( this );
  6738. self[ type ]( size.call( this, i, self[ type ]() ) );
  6739. });
  6740. }
  6741. if ( jQuery.isWindow( elem ) ) {
  6742. // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
  6743. // 3rd condition allows Nokia support, as it supports the docElem prop but not CSS1Compat
  6744. var docElemProp = elem.document.documentElement[ "client" + name ];
  6745. return elem.document.compatMode === "CSS1Compat" && docElemProp ||
  6746. elem.document.body[ "client" + name ] || docElemProp;
  6747. // Get document width or height
  6748. } else if ( elem.nodeType === 9 ) {
  6749. // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
  6750. return Math.max(
  6751. elem.documentElement["client" + name],
  6752. elem.body["scroll" + name], elem.documentElement["scroll" + name],
  6753. elem.body["offset" + name], elem.documentElement["offset" + name]
  6754. );
  6755. // Get or set width or height on the element
  6756. } else if ( size === undefined ) {
  6757. var orig = jQuery.css( elem, type ),
  6758. ret = parseFloat( orig );
  6759. return jQuery.isNaN( ret ) ? orig : ret;
  6760. // Set the width or height on the element (default to pixels if value is unitless)
  6761. } else {
  6762. return this.css( type, typeof size === "string" ? size : size + "px" );
  6763. }
  6764. };
  6765. });
  6766. window.jQuery = window.$ = jQuery;
  6767. })(window);