PageRenderTime 77ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/django/contrib/admin/media/js/jquery.js

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