PageRenderTime 43ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/Plugins/Jquery rotate/js/jquery.js

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