PageRenderTime 91ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 1ms

/src/MM.Web/Scripts/jquery-1.4.1.js

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