You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

3559 lines
98 KiB

  1. (function(){
  2. /*
  3. * jQuery 1.2.6 - New Wave Javascript
  4. *
  5. * Copyright (c) 2008 John Resig (jquery.com)
  6. * Dual licensed under the MIT (MIT-LICENSE.txt)
  7. * and GPL (GPL-LICENSE.txt) licenses.
  8. *
  9. * $Date: 2008-05-27 21:17:26 +0200 (Di, 27 Mai 2008) $
  10. * $Rev: 5700 $
  11. */
  12. // Map over jQuery in case of overwrite
  13. var _jQuery = window.jQuery,
  14. // Map over the $ in case of overwrite
  15. _$ = window.$;
  16. var jQuery = window.jQuery = window.$ = function( selector, context ) {
  17. // The jQuery object is actually just the init constructor 'enhanced'
  18. return new jQuery.fn.init( selector, context );
  19. };
  20. // A simple way to check for HTML strings or ID strings
  21. // (both of which we optimize for)
  22. var quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/,
  23. // Is it a simple selector
  24. isSimple = /^.[^:#\[\.]*$/,
  25. // Will speed up references to undefined, and allows munging its name.
  26. undefined;
  27. jQuery.fn = jQuery.prototype = {
  28. init: function( selector, context ) {
  29. // Make sure that a selection was provided
  30. selector = selector || document;
  31. // Handle $(DOMElement)
  32. if ( selector.nodeType ) {
  33. this[0] = selector;
  34. this.length = 1;
  35. return this;
  36. }
  37. // Handle HTML strings
  38. if ( typeof selector == "string" ) {
  39. // Are we dealing with HTML string or an ID?
  40. var match = quickExpr.exec( selector );
  41. // Verify a match, and that no context was specified for #id
  42. if ( match && (match[1] || !context) ) {
  43. // HANDLE: $(html) -> $(array)
  44. if ( match[1] )
  45. selector = jQuery.clean( [ match[1] ], context );
  46. // HANDLE: $("#id")
  47. else {
  48. var elem = document.getElementById( match[3] );
  49. // Make sure an element was located
  50. if ( elem ){
  51. // Handle the case where IE and Opera return items
  52. // by name instead of ID
  53. if ( elem.id != match[3] )
  54. return jQuery().find( selector );
  55. // Otherwise, we inject the element directly into the jQuery object
  56. return jQuery( elem );
  57. }
  58. selector = [];
  59. }
  60. // HANDLE: $(expr, [context])
  61. // (which is just equivalent to: $(content).find(expr)
  62. } else
  63. return jQuery( context ).find( selector );
  64. // HANDLE: $(function)
  65. // Shortcut for document ready
  66. } else if ( jQuery.isFunction( selector ) )
  67. return jQuery( document )[ jQuery.fn.ready ? "ready" : "load" ]( selector );
  68. return this.setArray(jQuery.makeArray(selector));
  69. },
  70. // The current version of jQuery being used
  71. jquery: "1.2.6",
  72. // The number of elements contained in the matched element set
  73. size: function() {
  74. return this.length;
  75. },
  76. // The number of elements contained in the matched element set
  77. length: 0,
  78. // Get the Nth element in the matched element set OR
  79. // Get the whole matched element set as a clean array
  80. get: function( num ) {
  81. return num == undefined ?
  82. // Return a 'clean' array
  83. jQuery.makeArray( this ) :
  84. // Return just the object
  85. this[ num ];
  86. },
  87. // Take an array of elements and push it onto the stack
  88. // (returning the new matched element set)
  89. pushStack: function( elems ) {
  90. // Build a new jQuery matched element set
  91. var ret = jQuery( elems );
  92. // Add the old object onto the stack (as a reference)
  93. ret.prevObject = this;
  94. // Return the newly-formed element set
  95. return ret;
  96. },
  97. // Force the current matched set of elements to become
  98. // the specified array of elements (destroying the stack in the process)
  99. // You should use pushStack() in order to do this, but maintain the stack
  100. setArray: function( elems ) {
  101. // Resetting the length to 0, then using the native Array push
  102. // is a super-fast way to populate an object with array-like properties
  103. this.length = 0;
  104. Array.prototype.push.apply( this, elems );
  105. return this;
  106. },
  107. // Execute a callback for every element in the matched set.
  108. // (You can seed the arguments with an array of args, but this is
  109. // only used internally.)
  110. each: function( callback, args ) {
  111. return jQuery.each( this, callback, args );
  112. },
  113. // Determine the position of an element within
  114. // the matched set of elements
  115. index: function( elem ) {
  116. var ret = -1;
  117. // Locate the position of the desired element
  118. return jQuery.inArray(
  119. // If it receives a jQuery object, the first element is used
  120. elem && elem.jquery ? elem[0] : elem
  121. , this );
  122. },
  123. attr: function( name, value, type ) {
  124. var options = name;
  125. // Look for the case where we're accessing a style value
  126. if ( name.constructor == String )
  127. if ( value === undefined )
  128. return this[0] && jQuery[ type || "attr" ]( this[0], name );
  129. else {
  130. options = {};
  131. options[ name ] = value;
  132. }
  133. // Check to see if we're setting style values
  134. return this.each(function(i){
  135. // Set all the styles
  136. for ( name in options )
  137. jQuery.attr(
  138. type ?
  139. this.style :
  140. this,
  141. name, jQuery.prop( this, options[ name ], type, i, name )
  142. );
  143. });
  144. },
  145. css: function( key, value ) {
  146. // ignore negative width and height values
  147. if ( (key == 'width' || key == 'height') && parseFloat(value) < 0 )
  148. value = undefined;
  149. return this.attr( key, value, "curCSS" );
  150. },
  151. text: function( text ) {
  152. if ( typeof text != "object" && text != null )
  153. return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
  154. var ret = "";
  155. jQuery.each( text || this, function(){
  156. jQuery.each( this.childNodes, function(){
  157. if ( this.nodeType != 8 )
  158. ret += this.nodeType != 1 ?
  159. this.nodeValue :
  160. jQuery.fn.text( [ this ] );
  161. });
  162. });
  163. return ret;
  164. },
  165. wrapAll: function( html ) {
  166. if ( this[0] )
  167. // The elements to wrap the target around
  168. jQuery( html, this[0].ownerDocument )
  169. .clone()
  170. .insertBefore( this[0] )
  171. .map(function(){
  172. var elem = this;
  173. while ( elem.firstChild )
  174. elem = elem.firstChild;
  175. return elem;
  176. })
  177. .append(this);
  178. return this;
  179. },
  180. wrapInner: function( html ) {
  181. return this.each(function(){
  182. jQuery( this ).contents().wrapAll( html );
  183. });
  184. },
  185. wrap: function( html ) {
  186. return this.each(function(){
  187. jQuery( this ).wrapAll( html );
  188. });
  189. },
  190. append: function() {
  191. return this.domManip(arguments, true, false, function(elem){
  192. if (this.nodeType == 1)
  193. this.appendChild( elem );
  194. });
  195. },
  196. prepend: function() {
  197. return this.domManip(arguments, true, true, function(elem){
  198. if (this.nodeType == 1)
  199. this.insertBefore( elem, this.firstChild );
  200. });
  201. },
  202. before: function() {
  203. return this.domManip(arguments, false, false, function(elem){
  204. this.parentNode.insertBefore( elem, this );
  205. });
  206. },
  207. after: function() {
  208. return this.domManip(arguments, false, true, function(elem){
  209. this.parentNode.insertBefore( elem, this.nextSibling );
  210. });
  211. },
  212. end: function() {
  213. return this.prevObject || jQuery( [] );
  214. },
  215. find: function( selector ) {
  216. var elems = jQuery.map(this, function(elem){
  217. return jQuery.find( selector, elem );
  218. });
  219. return this.pushStack( /[^+>] [^+>]/.test( selector ) || selector.indexOf("..") > -1 ?
  220. jQuery.unique( elems ) :
  221. elems );
  222. },
  223. clone: function( events ) {
  224. // Do the clone
  225. var ret = this.map(function(){
  226. if ( jQuery.browser.msie && !jQuery.isXMLDoc(this) ) {
  227. // IE copies events bound via attachEvent when
  228. // using cloneNode. Calling detachEvent on the
  229. // clone will also remove the events from the orignal
  230. // In order to get around this, we use innerHTML.
  231. // Unfortunately, this means some modifications to
  232. // attributes in IE that are actually only stored
  233. // as properties will not be copied (such as the
  234. // the name attribute on an input).
  235. var clone = this.cloneNode(true),
  236. container = document.createElement("div");
  237. container.appendChild(clone);
  238. return jQuery.clean([container.innerHTML])[0];
  239. } else
  240. return this.cloneNode(true);
  241. });
  242. // Need to set the expando to null on the cloned set if it exists
  243. // removeData doesn't work here, IE removes it from the original as well
  244. // this is primarily for IE but the data expando shouldn't be copied over in any browser
  245. var clone = ret.find("*").andSelf().each(function(){
  246. if ( this[ expando ] != undefined )
  247. this[ expando ] = null;
  248. });
  249. // Copy the events from the original to the clone
  250. if ( events === true )
  251. this.find("*").andSelf().each(function(i){
  252. if (this.nodeType == 3)
  253. return;
  254. var events = jQuery.data( this, "events" );
  255. for ( var type in events )
  256. for ( var handler in events[ type ] )
  257. jQuery.event.add( clone[ i ], type, events[ type ][ handler ], events[ type ][ handler ].data );
  258. });
  259. // Return the cloned set
  260. return ret;
  261. },
  262. filter: function( selector ) {
  263. return this.pushStack(
  264. jQuery.isFunction( selector ) &&
  265. jQuery.grep(this, function(elem, i){
  266. return selector.call( elem, i );
  267. }) ||
  268. jQuery.multiFilter( selector, this ) );
  269. },
  270. not: function( selector ) {
  271. if ( selector.constructor == String )
  272. // test special case where just one selector is passed in
  273. if ( isSimple.test( selector ) )
  274. return this.pushStack( jQuery.multiFilter( selector, this, true ) );
  275. else
  276. selector = jQuery.multiFilter( selector, this );
  277. var isArrayLike = selector.length && selector[selector.length - 1] !== undefined && !selector.nodeType;
  278. return this.filter(function() {
  279. return isArrayLike ? jQuery.inArray( this, selector ) < 0 : this != selector;
  280. });
  281. },
  282. add: function( selector ) {
  283. return this.pushStack( jQuery.unique( jQuery.merge(
  284. this.get(),
  285. typeof selector == 'string' ?
  286. jQuery( selector ) :
  287. jQuery.makeArray( selector )
  288. )));
  289. },
  290. is: function( selector ) {
  291. return !!selector && jQuery.multiFilter( selector, this ).length > 0;
  292. },
  293. hasClass: function( selector ) {
  294. return this.is( "." + selector );
  295. },
  296. val: function( value ) {
  297. if ( value == undefined ) {
  298. if ( this.length ) {
  299. var elem = this[0];
  300. // We need to handle select boxes special
  301. if ( jQuery.nodeName( elem, "select" ) ) {
  302. var index = elem.selectedIndex,
  303. values = [],
  304. options = elem.options,
  305. one = elem.type == "select-one";
  306. // Nothing was selected
  307. if ( index < 0 )
  308. return null;
  309. // Loop through all the selected options
  310. for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
  311. var option = options[ i ];
  312. if ( option.selected ) {
  313. // Get the specifc value for the option
  314. value = jQuery.browser.msie && !option.attributes.value.specified ? option.text : option.value;
  315. // We don't need an array for one selects
  316. if ( one )
  317. return value;
  318. // Multi-Selects return an array
  319. values.push( value );
  320. }
  321. }
  322. return values;
  323. // Everything else, we just grab the value
  324. } else
  325. return (this[0].value || "").replace(/\r/g, "");
  326. }
  327. return undefined;
  328. }
  329. if( value.constructor == Number )
  330. value += '';
  331. return this.each(function(){
  332. if ( this.nodeType != 1 )
  333. return;
  334. if ( value.constructor == Array && /radio|checkbox/.test( this.type ) )
  335. this.checked = (jQuery.inArray(this.value, value) >= 0 ||
  336. jQuery.inArray(this.name, value) >= 0);
  337. else if ( jQuery.nodeName( this, "select" ) ) {
  338. var values = jQuery.makeArray(value);
  339. jQuery( "option", this ).each(function(){
  340. this.selected = (jQuery.inArray( this.value, values ) >= 0 ||
  341. jQuery.inArray( this.text, values ) >= 0);
  342. });
  343. if ( !values.length )
  344. this.selectedIndex = -1;
  345. } else
  346. this.value = value;
  347. });
  348. },
  349. html: function( value ) {
  350. return value == undefined ?
  351. (this[0] ?
  352. this[0].innerHTML :
  353. null) :
  354. this.empty().append( value );
  355. },
  356. replaceWith: function( value ) {
  357. return this.after( value ).remove();
  358. },
  359. eq: function( i ) {
  360. return this.slice( i, i + 1 );
  361. },
  362. slice: function() {
  363. return this.pushStack( Array.prototype.slice.apply( this, arguments ) );
  364. },
  365. map: function( callback ) {
  366. return this.pushStack( jQuery.map(this, function(elem, i){
  367. return callback.call( elem, i, elem );
  368. }));
  369. },
  370. andSelf: function() {
  371. return this.add( this.prevObject );
  372. },
  373. data: function( key, value ){
  374. var parts = key.split(".");
  375. parts[1] = parts[1] ? "." + parts[1] : "";
  376. if ( value === undefined ) {
  377. var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
  378. if ( data === undefined && this.length )
  379. data = jQuery.data( this[0], key );
  380. return data === undefined && parts[1] ?
  381. this.data( parts[0] ) :
  382. data;
  383. } else
  384. return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function(){
  385. jQuery.data( this, key, value );
  386. });
  387. },
  388. removeData: function( key ){
  389. return this.each(function(){
  390. jQuery.removeData( this, key );
  391. });
  392. },
  393. domManip: function( args, table, reverse, callback ) {
  394. var clone = this.length > 1, elems;
  395. return this.each(function(){
  396. if ( !elems ) {
  397. elems = jQuery.clean( args, this.ownerDocument );
  398. if ( reverse )
  399. elems.reverse();
  400. }
  401. var obj = this;
  402. if ( table && jQuery.nodeName( this, "table" ) && jQuery.nodeName( elems[0], "tr" ) )
  403. obj = this.getElementsByTagName("tbody")[0] || this.appendChild( this.ownerDocument.createElement("tbody") );
  404. var scripts = jQuery( [] );
  405. jQuery.each(elems, function(){
  406. var elem = clone ?
  407. jQuery( this ).clone( true )[0] :
  408. this;
  409. // execute all scripts after the elements have been injected
  410. if ( jQuery.nodeName( elem, "script" ) )
  411. scripts = scripts.add( elem );
  412. else {
  413. // Remove any inner scripts for later evaluation
  414. if ( elem.nodeType == 1 )
  415. scripts = scripts.add( jQuery( "script", elem ).remove() );
  416. // Inject the elements into the document
  417. callback.call( obj, elem );
  418. }
  419. });
  420. scripts.each( evalScript );
  421. });
  422. }
  423. };
  424. // Give the init function the jQuery prototype for later instantiation
  425. jQuery.fn.init.prototype = jQuery.fn;
  426. function evalScript( i, elem ) {
  427. if ( elem.src )
  428. jQuery.ajax({
  429. url: elem.src,
  430. async: false,
  431. dataType: "script"
  432. });
  433. else
  434. jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );
  435. if ( elem.parentNode )
  436. elem.parentNode.removeChild( elem );
  437. }
  438. function now(){
  439. return +new Date;
  440. }
  441. jQuery.extend = jQuery.fn.extend = function() {
  442. // copy reference to target object
  443. var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options;
  444. // Handle a deep copy situation
  445. if ( target.constructor == Boolean ) {
  446. deep = target;
  447. target = arguments[1] || {};
  448. // skip the boolean and the target
  449. i = 2;
  450. }
  451. // Handle case when target is a string or something (possible in deep copy)
  452. if ( typeof target != "object" && typeof target != "function" )
  453. target = {};
  454. // extend jQuery itself if only one argument is passed
  455. if ( length == i ) {
  456. target = this;
  457. --i;
  458. }
  459. for ( ; i < length; i++ )
  460. // Only deal with non-null/undefined values
  461. if ( (options = arguments[ i ]) != null )
  462. // Extend the base object
  463. for ( var name in options ) {
  464. var src = target[ name ], copy = options[ name ];
  465. // Prevent never-ending loop
  466. if ( target === copy )
  467. continue;
  468. // Recurse if we're merging object values
  469. if ( deep && copy && typeof copy == "object" && !copy.nodeType )
  470. target[ name ] = jQuery.extend( deep,
  471. // Never move original objects, clone them
  472. src || ( copy.length != null ? [ ] : { } )
  473. , copy );
  474. // Don't bring in undefined values
  475. else if ( copy !== undefined )
  476. target[ name ] = copy;
  477. }
  478. // Return the modified object
  479. return target;
  480. };
  481. var expando = "jQuery" + now(), uuid = 0, windowData = {},
  482. // exclude the following css properties to add px
  483. exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i,
  484. // cache defaultView
  485. defaultView = document.defaultView || {};
  486. jQuery.extend({
  487. noConflict: function( deep ) {
  488. window.$ = _$;
  489. if ( deep )
  490. window.jQuery = _jQuery;
  491. return jQuery;
  492. },
  493. // See test/unit/core.js for details concerning this function.
  494. isFunction: function( fn ) {
  495. return !!fn && typeof fn != "string" && !fn.nodeName &&
  496. fn.constructor != Array && /^[\s[]?function/.test( fn + "" );
  497. },
  498. // check if an element is in a (or is an) XML document
  499. isXMLDoc: function( elem ) {
  500. return elem.documentElement && !elem.body ||
  501. elem.tagName && elem.ownerDocument && !elem.ownerDocument.body;
  502. },
  503. // Evalulates a script in a global context
  504. globalEval: function( data ) {
  505. data = jQuery.trim( data );
  506. if ( data ) {
  507. // Inspired by code by Andrea Giammarchi
  508. // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
  509. var head = document.getElementsByTagName("head")[0] || document.documentElement,
  510. script = document.createElement("script");
  511. script.type = "text/javascript";
  512. if ( jQuery.browser.msie )
  513. script.text = data;
  514. else
  515. script.appendChild( document.createTextNode( data ) );
  516. // Use insertBefore instead of appendChild to circumvent an IE6 bug.
  517. // This arises when a base node is used (#2709).
  518. head.insertBefore( script, head.firstChild );
  519. head.removeChild( script );
  520. }
  521. },
  522. nodeName: function( elem, name ) {
  523. return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase();
  524. },
  525. cache: {},
  526. data: function( elem, name, data ) {
  527. elem = elem == window ?
  528. windowData :
  529. elem;
  530. var id = elem[ expando ];
  531. // Compute a unique ID for the element
  532. if ( !id )
  533. id = elem[ expando ] = ++uuid;
  534. // Only generate the data cache if we're
  535. // trying to access or manipulate it
  536. if ( name && !jQuery.cache[ id ] )
  537. jQuery.cache[ id ] = {};
  538. // Prevent overriding the named cache with undefined values
  539. if ( data !== undefined )
  540. jQuery.cache[ id ][ name ] = data;
  541. // Return the named cache data, or the ID for the element
  542. return name ?
  543. jQuery.cache[ id ][ name ] :
  544. id;
  545. },
  546. removeData: function( elem, name ) {
  547. elem = elem == window ?
  548. windowData :
  549. elem;
  550. var id = elem[ expando ];
  551. // If we want to remove a specific section of the element's data
  552. if ( name ) {
  553. if ( jQuery.cache[ id ] ) {
  554. // Remove the section of cache data
  555. delete jQuery.cache[ id ][ name ];
  556. // If we've removed all the data, remove the element's cache
  557. name = "";
  558. for ( name in jQuery.cache[ id ] )
  559. break;
  560. if ( !name )
  561. jQuery.removeData( elem );
  562. }
  563. // Otherwise, we want to remove all of the element's data
  564. } else {
  565. // Clean up the element expando
  566. try {
  567. delete elem[ expando ];
  568. } catch(e){
  569. // IE has trouble directly removing the expando
  570. // but it's ok with using removeAttribute
  571. if ( elem.removeAttribute )
  572. elem.removeAttribute( expando );
  573. }
  574. // Completely remove the data cache
  575. delete jQuery.cache[ id ];
  576. }
  577. },
  578. // args is for internal usage only
  579. each: function( object, callback, args ) {
  580. var name, i = 0, length = object.length;
  581. if ( args ) {
  582. if ( length == undefined ) {
  583. for ( name in object )
  584. if ( callback.apply( object[ name ], args ) === false )
  585. break;
  586. } else
  587. for ( ; i < length; )
  588. if ( callback.apply( object[ i++ ], args ) === false )
  589. break;
  590. // A special, fast, case for the most common use of each
  591. } else {
  592. if ( length == undefined ) {
  593. for ( name in object )
  594. if ( callback.call( object[ name ], name, object[ name ] ) === false )
  595. break;
  596. } else
  597. for ( var value = object[0];
  598. i < length && callback.call( value, i, value ) !== false; value = object[++i] ){}
  599. }
  600. return object;
  601. },
  602. prop: function( elem, value, type, i, name ) {
  603. // Handle executable functions
  604. if ( jQuery.isFunction( value ) )
  605. value = value.call( elem, i );
  606. // Handle passing in a number to a CSS property
  607. return value && value.constructor == Number && type == "curCSS" && !exclude.test( name ) ?
  608. value + "px" :
  609. value;
  610. },
  611. className: {
  612. // internal only, use addClass("class")
  613. add: function( elem, classNames ) {
  614. jQuery.each((classNames || "").split(/\s+/), function(i, className){
  615. if ( elem.nodeType == 1 && !jQuery.className.has( elem.className, className ) )
  616. elem.className += (elem.className ? " " : "") + className;
  617. });
  618. },
  619. // internal only, use removeClass("class")
  620. remove: function( elem, classNames ) {
  621. if (elem.nodeType == 1)
  622. elem.className = classNames != undefined ?
  623. jQuery.grep(elem.className.split(/\s+/), function(className){
  624. return !jQuery.className.has( classNames, className );
  625. }).join(" ") :
  626. "";
  627. },
  628. // internal only, use hasClass("class")
  629. has: function( elem, className ) {
  630. return jQuery.inArray( className, (elem.className || elem).toString().split(/\s+/) ) > -1;
  631. }
  632. },
  633. // A method for quickly swapping in/out CSS properties to get correct calculations
  634. swap: function( elem, options, callback ) {
  635. var old = {};
  636. // Remember the old values, and insert the new ones
  637. for ( var name in options ) {
  638. old[ name ] = elem.style[ name ];
  639. elem.style[ name ] = options[ name ];
  640. }
  641. callback.call( elem );
  642. // Revert the old values
  643. for ( var name in options )
  644. elem.style[ name ] = old[ name ];
  645. },
  646. css: function( elem, name, force ) {
  647. if ( name == "width" || name == "height" ) {
  648. var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name == "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ];
  649. function getWH() {
  650. val = name == "width" ? elem.offsetWidth : elem.offsetHeight;
  651. var padding = 0, border = 0;
  652. jQuery.each( which, function() {
  653. padding += parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0;
  654. border += parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0;
  655. });
  656. val -= Math.round(padding + border);
  657. }
  658. if ( jQuery(elem).is(":visible") )
  659. getWH();
  660. else
  661. jQuery.swap( elem, props, getWH );
  662. return Math.max(0, val);
  663. }
  664. return jQuery.curCSS( elem, name, force );
  665. },
  666. curCSS: function( elem, name, force ) {
  667. var ret, style = elem.style;
  668. // A helper method for determining if an element's values are broken
  669. function color( elem ) {
  670. if ( !jQuery.browser.safari )
  671. return false;
  672. // defaultView is cached
  673. var ret = defaultView.getComputedStyle( elem, null );
  674. return !ret || ret.getPropertyValue("color") == "";
  675. }
  676. // We need to handle opacity special in IE
  677. if ( name == "opacity" && jQuery.browser.msie ) {
  678. ret = jQuery.attr( style, "opacity" );
  679. return ret == "" ?
  680. "1" :
  681. ret;
  682. }
  683. // Opera sometimes will give the wrong display answer, this fixes it, see #2037
  684. if ( jQuery.browser.opera && name == "display" ) {
  685. var save = style.outline;
  686. style.outline = "0 solid black";
  687. style.outline = save;
  688. }
  689. // Make sure we're using the right name for getting the float value
  690. if ( name.match( /float/i ) )
  691. name = styleFloat;
  692. if ( !force && style && style[ name ] )
  693. ret = style[ name ];
  694. else if ( defaultView.getComputedStyle ) {
  695. // Only "float" is needed here
  696. if ( name.match( /float/i ) )
  697. name = "float";
  698. name = name.replace( /([A-Z])/g, "-$1" ).toLowerCase();
  699. var computedStyle = defaultView.getComputedStyle( elem, null );
  700. if ( computedStyle && !color( elem ) )
  701. ret = computedStyle.getPropertyValue( name );
  702. // If the element isn't reporting its values properly in Safari
  703. // then some display: none elements are involved
  704. else {
  705. var swap = [], stack = [], a = elem, i = 0;
  706. // Locate all of the parent display: none elements
  707. for ( ; a && color(a); a = a.parentNode )
  708. stack.unshift(a);
  709. // Go through and make them visible, but in reverse
  710. // (It would be better if we knew the exact display type that they had)
  711. for ( ; i < stack.length; i++ )
  712. if ( color( stack[ i ] ) ) {
  713. swap[ i ] = stack[ i ].style.display;
  714. stack[ i ].style.display = "block";
  715. }
  716. // Since we flip the display style, we have to handle that
  717. // one special, otherwise get the value
  718. ret = name == "display" && swap[ stack.length - 1 ] != null ?
  719. "none" :
  720. ( computedStyle && computedStyle.getPropertyValue( name ) ) || "";
  721. // Finally, revert the display styles back
  722. for ( i = 0; i < swap.length; i++ )
  723. if ( swap[ i ] != null )
  724. stack[ i ].style.display = swap[ i ];
  725. }
  726. // We should always get a number back from opacity
  727. if ( name == "opacity" && ret == "" )
  728. ret = "1";
  729. } else if ( elem.currentStyle ) {
  730. var camelCase = name.replace(/\-(\w)/g, function(all, letter){
  731. return letter.toUpperCase();
  732. });
  733. ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ];
  734. // From the awesome hack by Dean Edwards
  735. // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
  736. // If we're not dealing with a regular pixel number
  737. // but a number that has a weird ending, we need to convert it to pixels
  738. if ( !/^\d+(px)?$/i.test( ret ) && /^\d/.test( ret ) ) {
  739. // Remember the original values
  740. var left = style.left, rsLeft = elem.runtimeStyle.left;
  741. // Put in the new values to get a computed value out
  742. elem.runtimeStyle.left = elem.currentStyle.left;
  743. style.left = ret || 0;
  744. ret = style.pixelLeft + "px";
  745. // Revert the changed values
  746. style.left = left;
  747. elem.runtimeStyle.left = rsLeft;
  748. }
  749. }
  750. return ret;
  751. },
  752. clean: function( elems, context ) {
  753. var ret = [];
  754. context = context || document;
  755. // !context.createElement fails in IE with an error but returns typeof 'object'
  756. if (typeof context.createElement == 'undefined')
  757. context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
  758. jQuery.each(elems, function(i, elem){
  759. if ( !elem )
  760. return;
  761. if ( elem.constructor == Number )
  762. elem += '';
  763. // Convert html string into DOM nodes
  764. if ( typeof elem == "string" ) {
  765. // Fix "XHTML"-style tags in all browsers
  766. elem = elem.replace(/(<(\w+)[^>]*?)\/>/g, function(all, front, tag){
  767. return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i) ?
  768. all :
  769. front + "></" + tag + ">";
  770. });
  771. // Trim whitespace, otherwise indexOf won't work as expected
  772. var tags = jQuery.trim( elem ).toLowerCase(), div = context.createElement("div");
  773. var wrap =
  774. // option or optgroup
  775. !tags.indexOf("<opt") &&
  776. [ 1, "<select multiple='multiple'>", "</select>" ] ||
  777. !tags.indexOf("<leg") &&
  778. [ 1, "<fieldset>", "</fieldset>" ] ||
  779. tags.match(/^<(thead|tbody|tfoot|colg|cap)/) &&
  780. [ 1, "<table>", "</table>" ] ||
  781. !tags.indexOf("<tr") &&
  782. [ 2, "<table><tbody>", "</tbody></table>" ] ||
  783. // <thead> matched above
  784. (!tags.indexOf("<td") || !tags.indexOf("<th")) &&
  785. [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ] ||
  786. !tags.indexOf("<col") &&
  787. [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ] ||
  788. // IE can't serialize <link> and <script> tags normally
  789. jQuery.browser.msie &&
  790. [ 1, "div<div>", "</div>" ] ||
  791. [ 0, "", "" ];
  792. // Go to html and back, then peel off extra wrappers
  793. div.innerHTML = wrap[1] + elem + wrap[2];
  794. // Move to the right depth
  795. while ( wrap[0]-- )
  796. div = div.lastChild;
  797. // Remove IE's autoinserted <tbody> from table fragments
  798. if ( jQuery.browser.msie ) {
  799. // String was a <table>, *may* have spurious <tbody>
  800. var tbody = !tags.indexOf("<table") && tags.indexOf("<tbody") < 0 ?
  801. div.firstChild && div.firstChild.childNodes :
  802. // String was a bare <thead> or <tfoot>
  803. wrap[1] == "<table>" && tags.indexOf("<tbody") < 0 ?
  804. div.childNodes :
  805. [];
  806. for ( var j = tbody.length - 1; j >= 0 ; --j )
  807. if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length )
  808. tbody[ j ].parentNode.removeChild( tbody[ j ] );
  809. // IE completely kills leading whitespace when innerHTML is used
  810. if ( /^\s/.test( elem ) )
  811. div.insertBefore( context.createTextNode( elem.match(/^\s*/)[0] ), div.firstChild );
  812. }
  813. elem = jQuery.makeArray( div.childNodes );
  814. }
  815. if ( elem.length === 0 && (!jQuery.nodeName( elem, "form" ) && !jQuery.nodeName( elem, "select" )) )
  816. return;
  817. if ( elem[0] == undefined || jQuery.nodeName( elem, "form" ) || elem.options )
  818. ret.push( elem );
  819. else
  820. ret = jQuery.merge( ret, elem );
  821. });
  822. return ret;
  823. },
  824. attr: function( elem, name, value ) {
  825. // don't set attributes on text and comment nodes
  826. if (!elem || elem.nodeType == 3 || elem.nodeType == 8)
  827. return undefined;
  828. var notxml = !jQuery.isXMLDoc( elem ),
  829. // Whether we are setting (or getting)
  830. set = value !== undefined,
  831. msie = jQuery.browser.msie;
  832. // Try to normalize/fix the name
  833. name = notxml && jQuery.props[ name ] || name;
  834. // Only do all the following if this is a node (faster for style)
  835. // IE elem.getAttribute passes even for style
  836. if ( elem.tagName ) {
  837. // These attributes require special treatment
  838. var special = /href|src|style/.test( name );
  839. // Safari mis-reports the default selected property of a hidden option
  840. // Accessing the parent's selectedIndex property fixes it
  841. if ( name == "selected" && jQuery.browser.safari )
  842. elem.parentNode.selectedIndex;
  843. // If applicable, access the attribute via the DOM 0 way
  844. if ( name in elem && notxml && !special ) {
  845. if ( set ){
  846. // We can't allow the type property to be changed (since it causes problems in IE)
  847. if ( name == "type" && jQuery.nodeName( elem, "input" ) && elem.parentNode )
  848. throw "type property can't be changed";
  849. elem[ name ] = value;
  850. }
  851. // browsers index elements by id/name on forms, give priority to attributes.
  852. if( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) )
  853. return elem.getAttributeNode( name ).nodeValue;
  854. return elem[ name ];
  855. }
  856. if ( msie && notxml && name == "style" )
  857. return jQuery.attr( elem.style, "cssText", value );
  858. if ( set )
  859. // convert the value to a string (all browsers do this but IE) see #1070
  860. elem.setAttribute( name, "" + value );
  861. var attr = msie && notxml && special
  862. // Some attributes require a special call on IE
  863. ? elem.getAttribute( name, 2 )
  864. : elem.getAttribute( name );
  865. // Non-existent attributes return null, we normalize to undefined
  866. return attr === null ? undefined : attr;
  867. }
  868. // elem is actually elem.style ... set the style
  869. // IE uses filters for opacity
  870. if ( msie && name == "opacity" ) {
  871. if ( set ) {
  872. // IE has trouble with opacity if it does not have layout
  873. // Force it by setting the zoom level
  874. elem.zoom = 1;
  875. // Set the alpha filter to set the opacity
  876. elem.filter = (elem.filter || "").replace( /alpha\([^)]*\)/, "" ) +
  877. (parseInt( value ) + '' == "NaN" ? "" : "alpha(opacity=" + value * 100 + ")");
  878. }
  879. return elem.filter && elem.filter.indexOf("opacity=") >= 0 ?
  880. (parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100) + '':
  881. "";
  882. }
  883. name = name.replace(/-([a-z])/ig, function(all, letter){
  884. return letter.toUpperCase();
  885. });
  886. if ( set )
  887. elem[ name ] = value;
  888. return elem[ name ];
  889. },
  890. trim: function( text ) {
  891. return (text || "").replace( /^\s+|\s+$/g, "" );
  892. },
  893. makeArray: function( array ) {
  894. var ret = [];
  895. if( array != null ){
  896. var i = array.length;
  897. //the window, strings and functions also have 'length'
  898. if( i == null || array.split || array.setInterval || array.call )
  899. ret[0] = array;
  900. else
  901. while( i )
  902. ret[--i] = array[i];
  903. }
  904. return ret;
  905. },
  906. inArray: function( elem, array ) {
  907. for ( var i = 0, length = array.length; i < length; i++ )
  908. // Use === because on IE, window == document
  909. if ( array[ i ] === elem )
  910. return i;
  911. return -1;
  912. },
  913. merge: function( first, second ) {
  914. // We have to loop this way because IE & Opera overwrite the length
  915. // expando of getElementsByTagName
  916. var i = 0, elem, pos = first.length;
  917. // Also, we need to make sure that the correct elements are being returned
  918. // (IE returns comment nodes in a '*' query)
  919. if ( jQuery.browser.msie ) {
  920. while ( elem = second[ i++ ] )
  921. if ( elem.nodeType != 8 )
  922. first[ pos++ ] = elem;
  923. } else
  924. while ( elem = second[ i++ ] )
  925. first[ pos++ ] = elem;
  926. return first;
  927. },
  928. unique: function( array ) {
  929. var ret = [], done = {};
  930. try {
  931. for ( var i = 0, length = array.length; i < length; i++ ) {
  932. var id = jQuery.data( array[ i ] );
  933. if ( !done[ id ] ) {
  934. done[ id ] = true;
  935. ret.push( array[ i ] );
  936. }
  937. }
  938. } catch( e ) {
  939. ret = array;
  940. }
  941. return ret;
  942. },
  943. grep: function( elems, callback, inv ) {
  944. var ret = [];
  945. // Go through the array, only saving the items
  946. // that pass the validator function
  947. for ( var i = 0, length = elems.length; i < length; i++ )
  948. if ( !inv != !callback( elems[ i ], i ) )
  949. ret.push( elems[ i ] );
  950. return ret;
  951. },
  952. map: function( elems, callback ) {
  953. var ret = [];
  954. // Go through the array, translating each of the items to their
  955. // new value (or values).
  956. for ( var i = 0, length = elems.length; i < length; i++ ) {
  957. var value = callback( elems[ i ], i );
  958. if ( value != null )
  959. ret[ ret.length ] = value;
  960. }
  961. return ret.concat.apply( [], ret );
  962. }
  963. });
  964. var userAgent = navigator.userAgent.toLowerCase();
  965. // Figure out what browser is being used
  966. jQuery.browser = {
  967. version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1],
  968. safari: /webkit/.test( userAgent ),
  969. opera: /opera/.test( userAgent ),
  970. msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),
  971. mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent )
  972. };
  973. var styleFloat = jQuery.browser.msie ?
  974. "styleFloat" :
  975. "cssFloat";
  976. jQuery.extend({
  977. // Check to see if the W3C box model is being used
  978. boxModel: !jQuery.browser.msie || document.compatMode == "CSS1Compat",
  979. props: {
  980. "for": "htmlFor",
  981. "class": "className",
  982. "float": styleFloat,
  983. cssFloat: styleFloat,
  984. styleFloat: styleFloat,
  985. readonly: "readOnly",
  986. maxlength: "maxLength",
  987. cellspacing: "cellSpacing",
  988. rowspan: "rowSpan"
  989. }
  990. });
  991. jQuery.each({
  992. parent: function(elem){return elem.parentNode;},
  993. parents: function(elem){return jQuery.dir(elem,"parentNode");},
  994. next: function(elem){return jQuery.nth(elem,2,"nextSibling");},
  995. prev: function(elem){return jQuery.nth(elem,2,"previousSibling");},
  996. nextAll: function(elem){return jQuery.dir(elem,"nextSibling");},
  997. prevAll: function(elem){return jQuery.dir(elem,"previousSibling");},
  998. siblings: function(elem){return jQuery.sibling(elem.parentNode.firstChild,elem);},
  999. children: function(elem){return jQuery.sibling(elem.firstChild);},
  1000. contents: function(elem){return jQuery.nodeName(elem,"iframe")?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes);}
  1001. }, function(name, fn){
  1002. jQuery.fn[ name ] = function( selector ) {
  1003. var ret = jQuery.map( this, fn );
  1004. if ( selector && typeof selector == "string" )
  1005. ret = jQuery.multiFilter( selector, ret );
  1006. return this.pushStack( jQuery.unique( ret ) );
  1007. };
  1008. });
  1009. jQuery.each({
  1010. appendTo: "append",
  1011. prependTo: "prepend",
  1012. insertBefore: "before",
  1013. insertAfter: "after",
  1014. replaceAll: "replaceWith"
  1015. }, function(name, original){
  1016. jQuery.fn[ name ] = function() {
  1017. var args = arguments;
  1018. return this.each(function(){
  1019. for ( var i = 0, length = args.length; i < length; i++ )
  1020. jQuery( args[ i ] )[ original ]( this );
  1021. });
  1022. };
  1023. });
  1024. jQuery.each({
  1025. removeAttr: function( name ) {
  1026. jQuery.attr( this, name, "" );
  1027. if (this.nodeType == 1)
  1028. this.removeAttribute( name );
  1029. },
  1030. addClass: function( classNames ) {
  1031. jQuery.className.add( this, classNames );
  1032. },
  1033. removeClass: function( classNames ) {
  1034. jQuery.className.remove( this, classNames );
  1035. },
  1036. toggleClass: function( classNames ) {
  1037. jQuery.className[ jQuery.className.has( this, classNames ) ? "remove" : "add" ]( this, classNames );
  1038. },
  1039. remove: function( selector ) {
  1040. if ( !selector || jQuery.filter( selector, [ this ] ).r.length ) {
  1041. // Prevent memory leaks
  1042. jQuery( "*", this ).add(this).each(function(){
  1043. jQuery.event.remove(this);
  1044. jQuery.removeData(this);
  1045. });
  1046. if (this.parentNode)
  1047. this.parentNode.removeChild( this );
  1048. }
  1049. },
  1050. empty: function() {
  1051. // Remove element nodes and prevent memory leaks
  1052. jQuery( ">*", this ).remove();
  1053. // Remove any remaining nodes
  1054. while ( this.firstChild )
  1055. this.removeChild( this.firstChild );
  1056. }
  1057. }, function(name, fn){
  1058. jQuery.fn[ name ] = function(){
  1059. return this.each( fn, arguments );
  1060. };
  1061. });
  1062. jQuery.each([ "Height", "Width" ], function(i, name){
  1063. var type = name.toLowerCase();
  1064. jQuery.fn[ type ] = function( size ) {
  1065. // Get window width or height
  1066. return this[0] == window ?
  1067. // Opera reports document.body.client[Width/Height] properly in both quirks and standards
  1068. jQuery.browser.opera && document.body[ "client" + name ] ||
  1069. // Safari reports inner[Width/Height] just fine (Mozilla and Opera include scroll bar widths)
  1070. jQuery.browser.safari && window[ "inner" + name ] ||
  1071. // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
  1072. document.compatMode == "CSS1Compat" && document.documentElement[ "client" + name ] || document.body[ "client" + name ] :
  1073. // Get document width or height
  1074. this[0] == document ?
  1075. // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
  1076. Math.max(
  1077. Math.max(document.body["scroll" + name], document.documentElement["scroll" + name]),
  1078. Math.max(document.body["offset" + name], document.documentElement["offset" + name])
  1079. ) :
  1080. // Get or set width or height on the element
  1081. size == undefined ?
  1082. // Get width or height on the element
  1083. (this.length ? jQuery.css( this[0], type ) : null) :
  1084. // Set the width or height on the element (default to pixels if value is unitless)
  1085. this.css( type, size.constructor == String ? size : size + "px" );
  1086. };
  1087. });
  1088. // Helper function used by the dimensions and offset modules
  1089. function num(elem, prop) {
  1090. return elem[0] && parseInt( jQuery.curCSS(elem[0], prop, true), 10 ) || 0;
  1091. }var chars = jQuery.browser.safari && parseInt(jQuery.browser.version) < 417 ?
  1092. "(?:[\\w*_-]|\\\\.)" :
  1093. "(?:[\\w\u0128-\uFFFF*_-]|\\\\.)",
  1094. quickChild = new RegExp("^>\\s*(" + chars + "+)"),
  1095. quickID = new RegExp("^(" + chars + "+)(#)(" + chars + "+)"),
  1096. quickClass = new RegExp("^([#.]?)(" + chars + "*)");
  1097. jQuery.extend({
  1098. expr: {
  1099. "": function(a,i,m){return m[2]=="*"||jQuery.nodeName(a,m[2]);},
  1100. "#": function(a,i,m){return a.getAttribute("id")==m[2];},
  1101. ":": {
  1102. // Position Checks
  1103. lt: function(a,i,m){return i<m[3]-0;},
  1104. gt: function(a,i,m){return i>m[3]-0;},
  1105. nth: function(a,i,m){return m[3]-0==i;},
  1106. eq: function(a,i,m){return m[3]-0==i;},
  1107. first: function(a,i){return i==0;},
  1108. last: function(a,i,m,r){return i==r.length-1;},
  1109. even: function(a,i){return i%2==0;},
  1110. odd: function(a,i){return i%2;},
  1111. // Child Checks
  1112. "first-child": function(a){return a.parentNode.getElementsByTagName("*")[0]==a;},
  1113. "last-child": function(a){return jQuery.nth(a.parentNode.lastChild,1,"previousSibling")==a;},
  1114. "only-child": function(a){return !jQuery.nth(a.parentNode.lastChild,2,"previousSibling");},
  1115. // Parent Checks
  1116. parent: function(a){return a.firstChild;},
  1117. empty: function(a){return !a.firstChild;},
  1118. // Text Check
  1119. contains: function(a,i,m){return (a.textContent||a.innerText||jQuery(a).text()||"").indexOf(m[3])>=0;},
  1120. // Visibility
  1121. visible: function(a){return "hidden"!=a.type&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden";},
  1122. hidden: function(a){return "hidden"==a.type||jQuery.css(a,"display")=="none"||jQuery.css(a,"visibility")=="hidden";},
  1123. // Form attributes
  1124. enabled: function(a){return !a.disabled;},
  1125. disabled: function(a){return a.disabled;},
  1126. checked: function(a){return a.checked;},
  1127. selected: function(a){return a.selected||jQuery.attr(a,"selected");},
  1128. // Form elements
  1129. text: function(a){return "text"==a.type;},
  1130. radio: function(a){return "radio"==a.type;},
  1131. checkbox: function(a){return "checkbox"==a.type;},
  1132. file: function(a){return "file"==a.type;},
  1133. password: function(a){return "password"==a.type;},
  1134. submit: function(a){return "submit"==a.type;},
  1135. image: function(a){return "image"==a.type;},
  1136. reset: function(a){return "reset"==a.type;},
  1137. button: function(a){return "button"==a.type||jQuery.nodeName(a,"button");},
  1138. input: function(a){return /input|select|textarea|button/i.test(a.nodeName);},
  1139. // :has()
  1140. has: function(a,i,m){return jQuery.find(m[3],a).length;},
  1141. // :header
  1142. header: function(a){return /h\d/i.test(a.nodeName);},
  1143. // :animated
  1144. animated: function(a){return jQuery.grep(jQuery.timers,function(fn){return a==fn.elem;}).length;}
  1145. }
  1146. },
  1147. // The regular expressions that power the parsing engine
  1148. parse: [
  1149. // Match: [@value='test'], [@foo]
  1150. /^(\[) *@?([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/,
  1151. // Match: :contains('foo')
  1152. /^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/,
  1153. // Match: :even, :last-child, #id, .class
  1154. new RegExp("^([:.#]*)(" + chars + "+)")
  1155. ],
  1156. multiFilter: function( expr, elems, not ) {
  1157. var old, cur = [];
  1158. while ( expr && expr != old ) {
  1159. old = expr;
  1160. var f = jQuery.filter( expr, elems, not );
  1161. expr = f.t.replace(/^\s*,\s*/, "" );
  1162. cur = not ? elems = f.r : jQuery.merge( cur, f.r );
  1163. }
  1164. return cur;
  1165. },
  1166. find: function( t, context ) {
  1167. // Quickly handle non-string expressions
  1168. if ( typeof t != "string" )
  1169. return [ t ];
  1170. // check to make sure context is a DOM element or a document
  1171. if ( context && context.nodeType != 1 && context.nodeType != 9)
  1172. return [ ];
  1173. // Set the correct context (if none is provided)
  1174. context = context || document;
  1175. // Initialize the search
  1176. var ret = [context], done = [], last, nodeName;
  1177. // Continue while a selector expression exists, and while
  1178. // we're no longer looping upon ourselves
  1179. while ( t && last != t ) {
  1180. var r = [];
  1181. last = t;
  1182. t = jQuery.trim(t);
  1183. var foundToken = false,
  1184. // An attempt at speeding up child selectors that
  1185. // point to a specific element tag
  1186. re = quickChild,
  1187. m = re.exec(t);
  1188. if ( m ) {
  1189. nodeName = m[1].toUpperCase();
  1190. // Perform our own iteration and filter
  1191. for ( var i = 0; ret[i]; i++ )
  1192. for ( var c = ret[i].firstChild; c; c = c.nextSibling )
  1193. if ( c.nodeType == 1 && (nodeName == "*" || c.nodeName.toUpperCase() == nodeName) )
  1194. r.push( c );
  1195. ret = r;
  1196. t = t.replace( re, "" );
  1197. if ( t.indexOf(" ") == 0 ) continue;
  1198. foundToken = true;
  1199. } else {
  1200. re = /^([>+~])\s*(\w*)/i;
  1201. if ( (m = re.exec(t)) != null ) {
  1202. r = [];
  1203. var merge = {};
  1204. nodeName = m[2].toUpperCase();
  1205. m = m[1];
  1206. for ( var j = 0, rl = ret.length; j < rl; j++ ) {
  1207. var n = m == "~" || m == "+" ? ret[j].nextSibling : ret[j].firstChild;
  1208. for ( ; n; n = n.nextSibling )
  1209. if ( n.nodeType == 1 ) {
  1210. var id = jQuery.data(n);
  1211. if ( m == "~" && merge[id] ) break;
  1212. if (!nodeName || n.nodeName.toUpperCase() == nodeName ) {
  1213. if ( m == "~" ) merge[id] = true;
  1214. r.push( n );
  1215. }
  1216. if ( m == "+" ) break;
  1217. }
  1218. }
  1219. ret = r;
  1220. // And remove the token
  1221. t = jQuery.trim( t.replace( re, "" ) );
  1222. foundToken = true;
  1223. }
  1224. }
  1225. // See if there's still an expression, and that we haven't already
  1226. // matched a token
  1227. if ( t && !foundToken ) {
  1228. // Handle multiple expressions
  1229. if ( !t.indexOf(",") ) {
  1230. // Clean the result set
  1231. if ( context == ret[0] ) ret.shift();
  1232. // Merge the result sets
  1233. done = jQuery.merge( done, ret );
  1234. // Reset the context
  1235. r = ret = [context];
  1236. // Touch up the selector string
  1237. t = " " + t.substr(1,t.length);
  1238. } else {
  1239. // Optimize for the case nodeName#idName
  1240. var re2 = quickID;
  1241. var m = re2.exec(t);
  1242. // Re-organize the results, so that they're consistent
  1243. if ( m ) {
  1244. m = [ 0, m[2], m[3], m[1] ];
  1245. } else {
  1246. // Otherwise, do a traditional filter check for
  1247. // ID, class, and element selectors
  1248. re2 = quickClass;
  1249. m = re2.exec(t);
  1250. }
  1251. m[2] = m[2].replace(/\\/g, "");
  1252. var elem = ret[ret.length-1];
  1253. // Try to do a global search by ID, where we can
  1254. if ( m[1] == "#" && elem && elem.getElementById && !jQuery.isXMLDoc(elem) ) {
  1255. // Optimization for HTML document case
  1256. var oid = elem.getElementById(m[2]);
  1257. // Do a quick check for the existence of the actual ID attribute
  1258. // to avoid selecting by the name attribute in IE
  1259. // also check to insure id is a string to avoid selecting an element with the name of 'id' inside a form
  1260. if ( (jQuery.browser.msie||jQuery.browser.opera) && oid && typeof oid.id == "string" && oid.id != m[2] )
  1261. oid = jQuery('[@id="'+m[2]+'"]', elem)[0];
  1262. // Do a quick check for node name (where applicable) so
  1263. // that div#foo searches will be really fast
  1264. ret = r = oid && (!m[3] || jQuery.nodeName(oid, m[3])) ? [oid] : [];
  1265. } else {
  1266. // We need to find all descendant elements
  1267. for ( var i = 0; ret[i]; i++ ) {
  1268. // Grab the tag name being searched for
  1269. var tag = m[1] == "#" && m[3] ? m[3] : m[1] != "" || m[0] == "" ? "*" : m[2];
  1270. // Handle IE7 being really dumb about <object>s
  1271. if ( tag == "*" && ret[i].nodeName.toLowerCase() == "object" )
  1272. tag = "param";
  1273. r = jQuery.merge( r, ret[i].getElementsByTagName( tag ));
  1274. }
  1275. // It's faster to filter by class and be done with it
  1276. if ( m[1] == "." )
  1277. r = jQuery.classFilter( r, m[2] );
  1278. // Same with ID filtering
  1279. if ( m[1] == "#" ) {
  1280. var tmp = [];
  1281. // Try to find the element with the ID
  1282. for ( var i = 0; r[i]; i++ )
  1283. if ( r[i].getAttribute("id") == m[2] ) {
  1284. tmp = [ r[i] ];
  1285. break;
  1286. }
  1287. r = tmp;
  1288. }
  1289. ret = r;
  1290. }
  1291. t = t.replace( re2, "" );
  1292. }
  1293. }
  1294. // If a selector string still exists
  1295. if ( t ) {
  1296. // Attempt to filter it
  1297. var val = jQuery.filter(t,r);
  1298. ret = r = val.r;
  1299. t = jQuery.trim(val.t);
  1300. }
  1301. }
  1302. // An error occurred with the selector;
  1303. // just return an empty set instead
  1304. if ( t )
  1305. ret = [];
  1306. // Remove the root context
  1307. if ( ret && context == ret[0] )
  1308. ret.shift();
  1309. // And combine the results
  1310. done = jQuery.merge( done, ret );
  1311. return done;
  1312. },
  1313. classFilter: function(r,m,not){
  1314. m = " " + m + " ";
  1315. var tmp = [];
  1316. for ( var i = 0; r[i]; i++ ) {
  1317. var pass = (" " + r[i].className + " ").indexOf( m ) >= 0;
  1318. if ( !not && pass || not && !pass )
  1319. tmp.push( r[i] );
  1320. }
  1321. return tmp;
  1322. },
  1323. filter: function(t,r,not) {
  1324. var last;
  1325. // Look for common filter expressions
  1326. while ( t && t != last ) {
  1327. last = t;
  1328. var p = jQuery.parse, m;
  1329. for ( var i = 0; p[i]; i++ ) {
  1330. m = p[i].exec( t );
  1331. if ( m ) {
  1332. // Remove what we just matched
  1333. t = t.substring( m[0].length );
  1334. m[2] = m[2].replace(/\\/g, "");
  1335. break;
  1336. }
  1337. }
  1338. if ( !m )
  1339. break;
  1340. // :not() is a special case that can be optimized by
  1341. // keeping it out of the expression list
  1342. if ( m[1] == ":" && m[2] == "not" )
  1343. // optimize if only one selector found (most common case)
  1344. r = isSimple.test( m[3] ) ?
  1345. jQuery.filter(m[3], r, true).r :
  1346. jQuery( r ).not( m[3] );
  1347. // We can get a big speed boost by filtering by class here
  1348. else if ( m[1] == "." )
  1349. r = jQuery.classFilter(r, m[2], not);
  1350. else if ( m[1] == "[" ) {
  1351. var tmp = [], type = m[3];
  1352. for ( var i = 0, rl = r.length; i < rl; i++ ) {
  1353. var a = r[i], z = a[ jQuery.props[m[2]] || m[2] ];
  1354. if ( z == null || /href|src|selected/.test(m[2]) )
  1355. z = jQuery.attr(a,m[2]) || '';
  1356. if ( (type == "" && !!z ||
  1357. type == "=" && z == m[5] ||
  1358. type == "!=" && z != m[5] ||
  1359. type == "^=" && z && !z.indexOf(m[5]) ||
  1360. type == "$=" && z.substr(z.length - m[5].length) == m[5] ||
  1361. (type == "*=" || type == "~=") && z.indexOf(m[5]) >= 0) ^ not )
  1362. tmp.push( a );
  1363. }
  1364. r = tmp;
  1365. // We can get a speed boost by handling nth-child here
  1366. } else if ( m[1] == ":" && m[2] == "nth-child" ) {
  1367. var merge = {}, tmp = [],
  1368. // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
  1369. test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
  1370. m[3] == "even" && "2n" || m[3] == "odd" && "2n+1" ||
  1371. !/\D/.test(m[3]) && "0n+" + m[3] || m[3]),
  1372. // calculate the numbers (first)n+(last) including if they are negative
  1373. first = (test[1] + (test[2] || 1)) - 0, last = test[3] - 0;
  1374. // loop through all the elements left in the jQuery object
  1375. for ( var i = 0, rl = r.length; i < rl; i++ ) {
  1376. var node = r[i], parentNode = node.parentNode, id = jQuery.data(parentNode);
  1377. if ( !merge[id] ) {
  1378. var c = 1;
  1379. for ( var n = parentNode.firstChild; n; n = n.nextSibling )
  1380. if ( n.nodeType == 1 )
  1381. n.nodeIndex = c++;
  1382. merge[id] = true;
  1383. }
  1384. var add = false;
  1385. if ( first == 0 ) {
  1386. if ( node.nodeIndex == last )
  1387. add = true;
  1388. } else if ( (node.nodeIndex - last) % first == 0 && (node.nodeIndex - last) / first >= 0 )
  1389. add = true;
  1390. if ( add ^ not )
  1391. tmp.push( node );
  1392. }
  1393. r = tmp;
  1394. // Otherwise, find the expression to execute
  1395. } else {
  1396. var fn = jQuery.expr[ m[1] ];
  1397. if ( typeof fn == "object" )
  1398. fn = fn[ m[2] ];
  1399. if ( typeof fn == "string" )
  1400. fn = eval("false||function(a,i){return " + fn + ";}");
  1401. // Execute it against the current filter
  1402. r = jQuery.grep( r, function(elem, i){
  1403. return fn(elem, i, m, r);
  1404. }, not );
  1405. }
  1406. }
  1407. // Return an array of filtered elements (r)
  1408. // and the modified expression string (t)
  1409. return { r: r, t: t };
  1410. },
  1411. dir: function( elem, dir ){
  1412. var matched = [],
  1413. cur = elem[dir];
  1414. while ( cur && cur != document ) {
  1415. if ( cur.nodeType == 1 )
  1416. matched.push( cur );
  1417. cur = cur[dir];
  1418. }
  1419. return matched;
  1420. },
  1421. nth: function(cur,result,dir,elem){
  1422. result = result || 1;
  1423. var num = 0;
  1424. for ( ; cur; cur = cur[dir] )
  1425. if ( cur.nodeType == 1 && ++num == result )
  1426. break;
  1427. return cur;
  1428. },
  1429. sibling: function( n, elem ) {
  1430. var r = [];
  1431. for ( ; n; n = n.nextSibling ) {
  1432. if ( n.nodeType == 1 && n != elem )
  1433. r.push( n );
  1434. }
  1435. return r;
  1436. }
  1437. });
  1438. /*
  1439. * A number of helper functions used for managing events.
  1440. * Many of the ideas behind this code orignated from
  1441. * Dean Edwards' addEvent library.
  1442. */
  1443. jQuery.event = {
  1444. // Bind an event to an element
  1445. // Original by Dean Edwards
  1446. add: function(elem, types, handler, data) {
  1447. if ( elem.nodeType == 3 || elem.nodeType == 8 )
  1448. return;
  1449. // For whatever reason, IE has trouble passing the window object
  1450. // around, causing it to be cloned in the process
  1451. if ( jQuery.browser.msie && elem.setInterval )
  1452. elem = window;
  1453. // Make sure that the function being executed has a unique ID
  1454. if ( !handler.guid )
  1455. handler.guid = this.guid++;
  1456. // if data is passed, bind to handler
  1457. if( data != undefined ) {
  1458. // Create temporary function pointer to original handler
  1459. var fn = handler;
  1460. // Create unique handler function, wrapped around original handler
  1461. handler = this.proxy( fn, function() {
  1462. // Pass arguments and context to original handler
  1463. return fn.apply(this, arguments);
  1464. });
  1465. // Store data in unique handler
  1466. handler.data = data;
  1467. }
  1468. // Init the element's event structure
  1469. var events = jQuery.data(elem, "events") || jQuery.data(elem, "events", {}),
  1470. handle = jQuery.data(elem, "handle") || jQuery.data(elem, "handle", function(){
  1471. // Handle the second event of a trigger and when
  1472. // an event is called after a page has unloaded
  1473. if ( typeof jQuery != "undefined" && !jQuery.event.triggered )
  1474. return jQuery.event.handle.apply(arguments.callee.elem, arguments);
  1475. });
  1476. // Add elem as a property of the handle function
  1477. // This is to prevent a memory leak with non-native
  1478. // event in IE.
  1479. handle.elem = elem;
  1480. // Handle multiple events separated by a space
  1481. // jQuery(...).bind("mouseover mouseout", fn);
  1482. jQuery.each(types.split(/\s+/), function(index, type) {
  1483. // Namespaced event handlers
  1484. var parts = type.split(".");
  1485. type = parts[0];
  1486. handler.type = parts[1];
  1487. // Get the current list of functions bound to this event
  1488. var handlers = events[type];
  1489. // Init the event handler queue
  1490. if (!handlers) {
  1491. handlers = events[type] = {};
  1492. // Check for a special event handler
  1493. // Only use addEventListener/attachEvent if the special
  1494. // events handler returns false
  1495. if ( !jQuery.event.special[type] || jQuery.event.special[type].setup.call(elem) === false ) {
  1496. // Bind the global event handler to the element
  1497. if (elem.addEventListener)
  1498. elem.addEventListener(type, handle, false);
  1499. else if (elem.attachEvent)
  1500. elem.attachEvent("on" + type, handle);
  1501. }
  1502. }
  1503. // Add the function to the element's handler list
  1504. handlers[handler.guid] = handler;
  1505. // Keep track of which events have been used, for global triggering
  1506. jQuery.event.global[type] = true;
  1507. });
  1508. // Nullify elem to prevent memory leaks in IE
  1509. elem = null;
  1510. },
  1511. guid: 1,
  1512. global: {},
  1513. // Detach an event or set of events from an element
  1514. remove: function(elem, types, handler) {
  1515. // don't do events on text and comment nodes
  1516. if ( elem.nodeType == 3 || elem.nodeType == 8 )
  1517. return;
  1518. var events = jQuery.data(elem, "events"), ret, index;
  1519. if ( events ) {
  1520. // Unbind all events for the element
  1521. if ( types == undefined || (typeof types == "string" && types.charAt(0) == ".") )
  1522. for ( var type in events )
  1523. this.remove( elem, type + (types || "") );
  1524. else {
  1525. // types is actually an event object here
  1526. if ( types.type ) {
  1527. handler = types.handler;
  1528. types = types.type;
  1529. }
  1530. // Handle multiple events seperated by a space
  1531. // jQuery(...).unbind("mouseover mouseout", fn);
  1532. jQuery.each(types.split(/\s+/), function(index, type){
  1533. // Namespaced event handlers
  1534. var parts = type.split(".");
  1535. type = parts[0];
  1536. if ( events[type] ) {
  1537. // remove the given handler for the given type
  1538. if ( handler )
  1539. delete events[type][handler.guid];
  1540. // remove all handlers for the given type
  1541. else
  1542. for ( handler in events[type] )
  1543. // Handle the removal of namespaced events
  1544. if ( !parts[1] || events[type][handler].type == parts[1] )
  1545. delete events[type][handler];
  1546. // remove generic event handler if no more handlers exist
  1547. for ( ret in events[type] ) break;
  1548. if ( !ret ) {
  1549. if ( !jQuery.event.special[type] || jQuery.event.special[type].teardown.call(elem) === false ) {
  1550. if (elem.removeEventListener)
  1551. elem.removeEventListener(type, jQuery.data(elem, "handle"), false);
  1552. else if (elem.detachEvent)
  1553. elem.detachEvent("on" + type, jQuery.data(elem, "handle"));
  1554. }
  1555. ret = null;
  1556. delete events[type];
  1557. }
  1558. }
  1559. });
  1560. }
  1561. // Remove the expando if it's no longer used
  1562. for ( ret in events ) break;
  1563. if ( !ret ) {
  1564. var handle = jQuery.data( elem, "handle" );
  1565. if ( handle ) handle.elem = null;
  1566. jQuery.removeData( elem, "events" );
  1567. jQuery.removeData( elem, "handle" );
  1568. }
  1569. }
  1570. },
  1571. trigger: function(type, data, elem, donative, extra) {
  1572. // Clone the incoming data, if any
  1573. data = jQuery.makeArray(data);
  1574. if ( type.indexOf("!") >= 0 ) {
  1575. type = type.slice(0, -1);
  1576. var exclusive = true;
  1577. }
  1578. // Handle a global trigger
  1579. if ( !elem ) {
  1580. // Only trigger if we've ever bound an event for it
  1581. if ( this.global[type] )
  1582. jQuery("*").add([window, document]).trigger(type, data);
  1583. // Handle triggering a single element
  1584. } else {
  1585. // don't do events on text and comment nodes
  1586. if ( elem.nodeType == 3 || elem.nodeType == 8 )
  1587. return undefined;
  1588. var val, ret, fn = jQuery.isFunction( elem[ type ] || null ),
  1589. // Check to see if we need to provide a fake event, or not
  1590. event = !data[0] || !data[0].preventDefault;
  1591. // Pass along a fake event
  1592. if ( event ) {
  1593. data.unshift({
  1594. type: type,
  1595. target: elem,
  1596. preventDefault: function(){},
  1597. stopPropagation: function(){},
  1598. timeStamp: now()
  1599. });
  1600. data[0][expando] = true; // no need to fix fake event
  1601. }
  1602. // Enforce the right trigger type
  1603. data[0].type = type;
  1604. if ( exclusive )
  1605. data[0].exclusive = true;
  1606. // Trigger the event, it is assumed that "handle" is a function
  1607. var handle = jQuery.data(elem, "handle");
  1608. if ( handle )
  1609. val = handle.apply( elem, data );
  1610. // Handle triggering native .onfoo handlers (and on links since we don't call .click() for links)
  1611. if ( (!fn || (jQuery.nodeName(elem, 'a') && type == "click")) && elem["on"+type] && elem["on"+type].apply( elem, data ) === false )
  1612. val = false;
  1613. // Extra functions don't get the custom event object
  1614. if ( event )
  1615. data.shift();
  1616. // Handle triggering of extra function
  1617. if ( extra && jQuery.isFunction( extra ) ) {
  1618. // call the extra function and tack the current return value on the end for possible inspection
  1619. ret = extra.apply( elem, val == null ? data : data.concat( val ) );
  1620. // if anything is returned, give it precedence and have it overwrite the previous value
  1621. if (ret !== undefined)
  1622. val = ret;
  1623. }
  1624. // Trigger the native events (except for clicks on links)
  1625. if ( fn && donative !== false && val !== false && !(jQuery.nodeName(elem, 'a') && type == "click") ) {
  1626. this.triggered = true;
  1627. try {
  1628. elem[ type ]();
  1629. // prevent IE from throwing an error for some hidden elements
  1630. } catch (e) {}
  1631. }
  1632. this.triggered = false;
  1633. }
  1634. return val;
  1635. },
  1636. handle: function(event) {
  1637. // returned undefined or false
  1638. var val, ret, namespace, all, handlers;
  1639. event = arguments[0] = jQuery.event.fix( event || window.event );
  1640. // Namespaced event handlers
  1641. namespace = event.type.split(".");
  1642. event.type = namespace[0];
  1643. namespace = namespace[1];
  1644. // Cache this now, all = true means, any handler
  1645. all = !namespace && !event.exclusive;
  1646. handlers = ( jQuery.data(this, "events") || {} )[event.type];
  1647. for ( var j in handlers ) {
  1648. var handler = handlers[j];
  1649. // Filter the functions by class
  1650. if ( all || handler.type == namespace ) {
  1651. // Pass in a reference to the handler function itself
  1652. // So that we can later remove it
  1653. event.handler = handler;
  1654. event.data = handler.data;
  1655. ret = handler.apply( this, arguments );
  1656. if ( val !== false )
  1657. val = ret;
  1658. if ( ret === false ) {
  1659. event.preventDefault();
  1660. event.stopPropagation();
  1661. }
  1662. }
  1663. }
  1664. return val;
  1665. },
  1666. props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target timeStamp toElement type view wheelDelta which".split(" "),
  1667. fix: function(event) {
  1668. if ( event[expando] == true )
  1669. return event;
  1670. // store a copy of the original event object
  1671. // and "clone" to set read-only properties
  1672. var originalEvent = event;
  1673. event = { originalEvent: originalEvent };
  1674. for ( var i = this.props.length, prop; i; ){
  1675. prop = this.props[ --i ];
  1676. event[ prop ] = originalEvent[ prop ];
  1677. }
  1678. // Mark it as fixed
  1679. event[expando] = true;
  1680. // add preventDefault and stopPropagation since
  1681. // they will not work on the clone
  1682. event.preventDefault = function() {
  1683. // if preventDefault exists run it on the original event
  1684. if (originalEvent.preventDefault)
  1685. originalEvent.preventDefault();
  1686. // otherwise set the returnValue property of the original event to false (IE)
  1687. originalEvent.returnValue = false;
  1688. };
  1689. event.stopPropagation = function() {
  1690. // if stopPropagation exists run it on the original event
  1691. if (originalEvent.stopPropagation)
  1692. originalEvent.stopPropagation();
  1693. // otherwise set the cancelBubble property of the original event to true (IE)
  1694. originalEvent.cancelBubble = true;
  1695. };
  1696. // Fix timeStamp
  1697. event.timeStamp = event.timeStamp || now();
  1698. // Fix target property, if necessary
  1699. if ( !event.target )
  1700. event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either
  1701. // check if target is a textnode (safari)
  1702. if ( event.target.nodeType == 3 )
  1703. event.target = event.target.parentNode;
  1704. // Add relatedTarget, if necessary
  1705. if ( !event.relatedTarget && event.fromElement )
  1706. event.relatedTarget = event.fromElement == event.target ? event.toElement : event.fromElement;
  1707. // Calculate pageX/Y if missing and clientX/Y available
  1708. if ( event.pageX == null && event.clientX != null ) {
  1709. var doc = document.documentElement, body = document.body;
  1710. event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc.clientLeft || 0);
  1711. event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc.clientTop || 0);
  1712. }
  1713. // Add which for key events
  1714. if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) )
  1715. event.which = event.charCode || event.keyCode;
  1716. // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
  1717. if ( !event.metaKey && event.ctrlKey )
  1718. event.metaKey = event.ctrlKey;
  1719. // Add which for click: 1 == left; 2 == middle; 3 == right
  1720. // Note: button is not normalized, so don't use it
  1721. if ( !event.which && event.button )
  1722. event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
  1723. return event;
  1724. },
  1725. proxy: function( fn, proxy ){
  1726. // Set the guid of unique handler to the same of original handler, so it can be removed
  1727. proxy.guid = fn.guid = fn.guid || proxy.guid || this.guid++;
  1728. // So proxy can be declared as an argument
  1729. return proxy;
  1730. },
  1731. special: {
  1732. ready: {
  1733. setup: function() {
  1734. // Make sure the ready event is setup
  1735. bindReady();
  1736. return;
  1737. },
  1738. teardown: function() { return; }
  1739. },
  1740. mouseenter: {
  1741. setup: function() {
  1742. if ( jQuery.browser.msie ) return false;
  1743. jQuery(this).bind("mouseover", jQuery.event.special.mouseenter.handler);
  1744. return true;
  1745. },
  1746. teardown: function() {
  1747. if ( jQuery.browser.msie ) return false;
  1748. jQuery(this).unbind("mouseover", jQuery.event.special.mouseenter.handler);
  1749. return true;
  1750. },
  1751. handler: function(event) {
  1752. // If we actually just moused on to a sub-element, ignore it
  1753. if ( withinElement(event, this) ) return true;
  1754. // Execute the right handlers by setting the event type to mouseenter
  1755. event.type = "mouseenter";
  1756. return jQuery.event.handle.apply(this, arguments);
  1757. }
  1758. },
  1759. mouseleave: {
  1760. setup: function() {
  1761. if ( jQuery.browser.msie ) return false;
  1762. jQuery(this).bind("mouseout", jQuery.event.special.mouseleave.handler);
  1763. return true;
  1764. },
  1765. teardown: function() {
  1766. if ( jQuery.browser.msie ) return false;
  1767. jQuery(this).unbind("mouseout", jQuery.event.special.mouseleave.handler);
  1768. return true;
  1769. },
  1770. handler: function(event) {
  1771. // If we actually just moused on to a sub-element, ignore it
  1772. if ( withinElement(event, this) ) return true;
  1773. // Execute the right handlers by setting the event type to mouseleave
  1774. event.type = "mouseleave";
  1775. return jQuery.event.handle.apply(this, arguments);
  1776. }
  1777. }
  1778. }
  1779. };
  1780. jQuery.fn.extend({
  1781. bind: function( type, data, fn ) {
  1782. return type == "unload" ? this.one(type, data, fn) : this.each(function(){
  1783. jQuery.event.add( this, type, fn || data, fn && data );
  1784. });
  1785. },
  1786. one: function( type, data, fn ) {
  1787. var one = jQuery.event.proxy( fn || data, function(event) {
  1788. jQuery(this).unbind(event, one);
  1789. return (fn || data).apply( this, arguments );
  1790. });
  1791. return this.each(function(){
  1792. jQuery.event.add( this, type, one, fn && data);
  1793. });
  1794. },
  1795. unbind: function( type, fn ) {
  1796. return this.each(function(){
  1797. jQuery.event.remove( this, type, fn );
  1798. });
  1799. },
  1800. trigger: function( type, data, fn ) {
  1801. return this.each(function(){
  1802. jQuery.event.trigger( type, data, this, true, fn );
  1803. });
  1804. },
  1805. triggerHandler: function( type, data, fn ) {
  1806. return this[0] && jQuery.event.trigger( type, data, this[0], false, fn );
  1807. },
  1808. toggle: function( fn ) {
  1809. // Save reference to arguments for access in closure
  1810. var args = arguments, i = 1;
  1811. // link all the functions, so any of them can unbind this click handler
  1812. while( i < args.length )
  1813. jQuery.event.proxy( fn, args[i++] );
  1814. return this.click( jQuery.event.proxy( fn, function(event) {
  1815. // Figure out which function to execute
  1816. this.lastToggle = ( this.lastToggle || 0 ) % i;
  1817. // Make sure that clicks stop
  1818. event.preventDefault();
  1819. // and execute the function
  1820. return args[ this.lastToggle++ ].apply( this, arguments ) || false;
  1821. }));
  1822. },
  1823. hover: function(fnOver, fnOut) {
  1824. return this.bind('mouseenter', fnOver).bind('mouseleave', fnOut);
  1825. },
  1826. ready: function(fn) {
  1827. // Attach the listeners
  1828. bindReady();
  1829. // If the DOM is already ready
  1830. if ( jQuery.isReady )
  1831. // Execute the function immediately
  1832. fn.call( document, jQuery );
  1833. // Otherwise, remember the function for later
  1834. else
  1835. // Add the function to the wait list
  1836. jQuery.readyList.push( function() { return fn.call(this, jQuery); } );
  1837. return this;
  1838. }
  1839. });
  1840. jQuery.extend({
  1841. isReady: false,
  1842. readyList: [],
  1843. // Handle when the DOM is ready
  1844. ready: function() {
  1845. // Make sure that the DOM is not already loaded
  1846. if ( !jQuery.isReady ) {
  1847. // Remember that the DOM is ready
  1848. jQuery.isReady = true;
  1849. // If there are functions bound, to execute
  1850. if ( jQuery.readyList ) {
  1851. // Execute all of them
  1852. jQuery.each( jQuery.readyList, function(){
  1853. this.call( document );
  1854. });
  1855. // Reset the list of functions
  1856. jQuery.readyList = null;
  1857. }
  1858. // Trigger any bound ready events
  1859. jQuery(document).triggerHandler("ready");
  1860. }
  1861. }
  1862. });
  1863. var readyBound = false;
  1864. function bindReady(){
  1865. if ( readyBound ) return;
  1866. readyBound = true;
  1867. // Mozilla, Opera (see further below for it) and webkit nightlies currently support this event
  1868. if ( document.addEventListener && !jQuery.browser.opera)
  1869. // Use the handy event callback
  1870. document.addEventListener( "DOMContentLoaded", jQuery.ready, false );
  1871. // If IE is used and is not in a frame
  1872. // Continually check to see if the document is ready
  1873. if ( jQuery.browser.msie && window == top ) (function(){
  1874. if (jQuery.isReady) return;
  1875. try {
  1876. // If IE is used, use the trick by Diego Perini
  1877. // http://javascript.nwbox.com/IEContentLoaded/
  1878. document.documentElement.doScroll("left");
  1879. } catch( error ) {
  1880. setTimeout( arguments.callee, 0 );
  1881. return;
  1882. }
  1883. // and execute any waiting functions
  1884. jQuery.ready();
  1885. })();
  1886. if ( jQuery.browser.opera )
  1887. document.addEventListener( "DOMContentLoaded", function () {
  1888. if (jQuery.isReady) return;
  1889. for (var i = 0; i < document.styleSheets.length; i++)
  1890. if (document.styleSheets[i].disabled) {
  1891. setTimeout( arguments.callee, 0 );
  1892. return;
  1893. }
  1894. // and execute any waiting functions
  1895. jQuery.ready();
  1896. }, false);
  1897. if ( jQuery.browser.safari ) {
  1898. var numStyles;
  1899. (function(){
  1900. if (jQuery.isReady) return;
  1901. if ( document.readyState != "loaded" && document.readyState != "complete" ) {
  1902. setTimeout( arguments.callee, 0 );
  1903. return;
  1904. }
  1905. if ( numStyles === undefined )
  1906. numStyles = jQuery("style, link[rel=stylesheet]").length;
  1907. if ( document.styleSheets.length != numStyles ) {
  1908. setTimeout( arguments.callee, 0 );
  1909. return;
  1910. }
  1911. // and execute any waiting functions
  1912. jQuery.ready();
  1913. })();
  1914. }
  1915. // A fallback to window.onload, that will always work
  1916. jQuery.event.add( window, "load", jQuery.ready );
  1917. }
  1918. jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," +
  1919. "mousedown,mouseup,mousemove,mouseover,mouseout,change,select," +
  1920. "submit,keydown,keypress,keyup,error").split(","), function(i, name){
  1921. // Handle event binding
  1922. jQuery.fn[name] = function(fn){
  1923. return fn ? this.bind(name, fn) : this.trigger(name);
  1924. };
  1925. });
  1926. // Checks if an event happened on an element within another element
  1927. // Used in jQuery.event.special.mouseenter and mouseleave handlers
  1928. var withinElement = function(event, elem) {
  1929. // Check if mouse(over|out) are still within the same parent element
  1930. var parent = event.relatedTarget;
  1931. // Traverse up the tree
  1932. while ( parent && parent != elem ) try { parent = parent.parentNode; } catch(error) { parent = elem; }
  1933. // Return true if we actually just moused on to a sub-element
  1934. return parent == elem;
  1935. };
  1936. // Prevent memory leaks in IE
  1937. // And prevent errors on refresh with events like mouseover in other browsers
  1938. // Window isn't included so as not to unbind existing unload events
  1939. jQuery(window).bind("unload", function() {
  1940. jQuery("*").add(document).unbind();
  1941. });
  1942. jQuery.fn.extend({
  1943. // Keep a copy of the old load
  1944. _load: jQuery.fn.load,
  1945. load: function( url, params, callback ) {
  1946. if ( typeof url != 'string' )
  1947. return this._load( url );
  1948. var off = url.indexOf(" ");
  1949. if ( off >= 0 ) {
  1950. var selector = url.slice(off, url.length);
  1951. url = url.slice(0, off);
  1952. }
  1953. callback = callback || function(){};
  1954. // Default to a GET request
  1955. var type = "GET";
  1956. // If the second parameter was provided
  1957. if ( params )
  1958. // If it's a function
  1959. if ( jQuery.isFunction( params ) ) {
  1960. // We assume that it's the callback
  1961. callback = params;
  1962. params = null;
  1963. // Otherwise, build a param string
  1964. } else if( typeof params == 'object' ) {
  1965. params = jQuery.param( params );
  1966. type = "POST";
  1967. }
  1968. var self = this;
  1969. // Request the remote document
  1970. jQuery.ajax({
  1971. url: url,
  1972. type: type,
  1973. dataType: "html",
  1974. data: params,
  1975. complete: function(res, status){
  1976. // If successful, inject the HTML into all the matched elements
  1977. if ( status == "success" || status == "notmodified" )
  1978. // See if a selector was specified
  1979. self.html( selector ?
  1980. // Create a dummy div to hold the results
  1981. jQuery("<div/>")
  1982. // inject the contents of the document in, removing the scripts
  1983. // to avoid any 'Permission Denied' errors in IE
  1984. .append(res.responseText.replace(/<script(.|\s)*?\/script>/g, ""))
  1985. // Locate the specified elements
  1986. .find(selector) :
  1987. // If not, just inject the full result
  1988. res.responseText );
  1989. self.each( callback, [res.responseText, status, res] );
  1990. }
  1991. });
  1992. return this;
  1993. },
  1994. serialize: function() {
  1995. return jQuery.param(this.serializeArray());
  1996. },
  1997. serializeArray: function() {
  1998. return this.map(function(){
  1999. return jQuery.nodeName(this, "form") ?
  2000. jQuery.makeArray(this.elements) : this;
  2001. })
  2002. .filter(function(){
  2003. return this.name && !this.disabled &&
  2004. (this.checked || /select|textarea/i.test(this.nodeName) ||
  2005. /text|hidden|password/i.test(this.type));
  2006. })
  2007. .map(function(i, elem){
  2008. var val = jQuery(this).val();
  2009. return val == null ? null :
  2010. val.constructor == Array ?
  2011. jQuery.map( val, function(val, i){
  2012. return {name: elem.name, value: val};
  2013. }) :
  2014. {name: elem.name, value: val};
  2015. }).get();
  2016. }
  2017. });
  2018. // Attach a bunch of functions for handling common AJAX events
  2019. jQuery.each( "ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","), function(i,o){
  2020. jQuery.fn[o] = function(f){
  2021. return this.bind(o, f);
  2022. };
  2023. });
  2024. var jsc = now();
  2025. jQuery.extend({
  2026. get: function( url, data, callback, type ) {
  2027. // shift arguments if data argument was ommited
  2028. if ( jQuery.isFunction( data ) ) {
  2029. callback = data;
  2030. data = null;
  2031. }
  2032. return jQuery.ajax({
  2033. type: "GET",
  2034. url: url,
  2035. data: data,
  2036. success: callback,
  2037. dataType: type
  2038. });
  2039. },
  2040. getScript: function( url, callback ) {
  2041. return jQuery.get(url, null, callback, "script");
  2042. },
  2043. getJSON: function( url, data, callback ) {
  2044. return jQuery.get(url, data, callback, "json");
  2045. },
  2046. post: function( url, data, callback, type ) {
  2047. if ( jQuery.isFunction( data ) ) {
  2048. callback = data;
  2049. data = {};
  2050. }
  2051. return jQuery.ajax({
  2052. type: "POST",
  2053. url: url,
  2054. data: data,
  2055. success: callback,
  2056. dataType: type
  2057. });
  2058. },
  2059. ajaxSetup: function( settings ) {
  2060. jQuery.extend( jQuery.ajaxSettings, settings );
  2061. },
  2062. ajaxSettings: {
  2063. url: location.href,
  2064. global: true,
  2065. type: "GET",
  2066. timeout: 0,
  2067. contentType: "application/x-www-form-urlencoded",
  2068. processData: true,
  2069. async: true,
  2070. data: null,
  2071. username: null,
  2072. password: null,
  2073. accepts: {
  2074. xml: "application/xml, text/xml",
  2075. html: "text/html",
  2076. script: "text/javascript, application/javascript",
  2077. json: "application/json, text/javascript",
  2078. text: "text/plain",
  2079. _default: "*/*"
  2080. }
  2081. },
  2082. // Last-Modified header cache for next request
  2083. lastModified: {},
  2084. ajax: function( s ) {
  2085. // Extend the settings, but re-extend 's' so that it can be
  2086. // checked again later (in the test suite, specifically)
  2087. s = jQuery.extend(true, s, jQuery.extend(true, {}, jQuery.ajaxSettings, s));
  2088. var jsonp, jsre = /=\?(&|$)/g, status, data,
  2089. type = s.type.toUpperCase();
  2090. // convert data if not already a string
  2091. if ( s.data && s.processData && typeof s.data != "string" )
  2092. s.data = jQuery.param(s.data);
  2093. // Handle JSONP Parameter Callbacks
  2094. if ( s.dataType == "jsonp" ) {
  2095. if ( type == "GET" ) {
  2096. if ( !s.url.match(jsre) )
  2097. s.url += (s.url.match(/\?/) ? "&" : "?") + (s.jsonp || "callback") + "=?";
  2098. } else if ( !s.data || !s.data.match(jsre) )
  2099. s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?";
  2100. s.dataType = "json";
  2101. }
  2102. // Build temporary JSONP function
  2103. if ( s.dataType == "json" && (s.data && s.data.match(jsre) || s.url.match(jsre)) ) {
  2104. jsonp = "jsonp" + jsc++;
  2105. // Replace the =? sequence both in the query string and the data
  2106. if ( s.data )
  2107. s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1");
  2108. s.url = s.url.replace(jsre, "=" + jsonp + "$1");
  2109. // We need to make sure
  2110. // that a JSONP style response is executed properly
  2111. s.dataType = "script";
  2112. // Handle JSONP-style loading
  2113. window[ jsonp ] = function(tmp){
  2114. data = tmp;
  2115. success();
  2116. complete();
  2117. // Garbage collect
  2118. window[ jsonp ] = undefined;
  2119. try{ delete window[ jsonp ]; } catch(e){}
  2120. if ( head )
  2121. head.removeChild( script );
  2122. };
  2123. }
  2124. if ( s.dataType == "script" && s.cache == null )
  2125. s.cache = false;
  2126. if ( s.cache === false && type == "GET" ) {
  2127. var ts = now();
  2128. // try replacing _= if it is there
  2129. var ret = s.url.replace(/(\?|&)_=.*?(&|$)/, "$1_=" + ts + "$2");
  2130. // if nothing was replaced, add timestamp to the end
  2131. s.url = ret + ((ret == s.url) ? (s.url.match(/\?/) ? "&" : "?") + "_=" + ts : "");
  2132. }
  2133. // If data is available, append data to url for get requests
  2134. if ( s.data && type == "GET" ) {
  2135. s.url += (s.url.match(/\?/) ? "&" : "?") + s.data;
  2136. // IE likes to send both get and post data, prevent this
  2137. s.data = null;
  2138. }
  2139. // Watch for a new set of requests
  2140. if ( s.global && ! jQuery.active++ )
  2141. jQuery.event.trigger( "ajaxStart" );
  2142. // Matches an absolute URL, and saves the domain
  2143. var remote = /^(?:\w+:)?\/\/([^\/?#]+)/;
  2144. // If we're requesting a remote document
  2145. // and trying to load JSON or Script with a GET
  2146. if ( s.dataType == "script" && type == "GET"
  2147. && remote.test(s.url) && remote.exec(s.url)[1] != location.host ){
  2148. var head = document.getElementsByTagName("head")[0];
  2149. var script = document.createElement("script");
  2150. script.src = s.url;
  2151. if (s.scriptCharset)
  2152. script.charset = s.scriptCharset;
  2153. // Handle Script loading
  2154. if ( !jsonp ) {
  2155. var done = false;
  2156. // Attach handlers for all browsers
  2157. script.onload = script.onreadystatechange = function(){
  2158. if ( !done && (!this.readyState ||
  2159. this.readyState == "loaded" || this.readyState == "complete") ) {
  2160. done = true;
  2161. success();
  2162. complete();
  2163. head.removeChild( script );
  2164. }
  2165. };
  2166. }
  2167. head.appendChild(script);
  2168. // We handle everything using the script element injection
  2169. return undefined;
  2170. }
  2171. var requestDone = false;
  2172. // Create the request object; Microsoft failed to properly
  2173. // implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available
  2174. var xhr = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
  2175. // Open the socket
  2176. // Passing null username, generates a login popup on Opera (#2865)
  2177. if( s.username )
  2178. xhr.open(type, s.url, s.async, s.username, s.password);
  2179. else
  2180. xhr.open(type, s.url, s.async);
  2181. // Need an extra try/catch for cross domain requests in Firefox 3
  2182. try {
  2183. // Set the correct header, if data is being sent
  2184. if ( s.data )
  2185. xhr.setRequestHeader("Content-Type", s.contentType);
  2186. // Set the If-Modified-Since header, if ifModified mode.
  2187. if ( s.ifModified )
  2188. xhr.setRequestHeader("If-Modified-Since",
  2189. jQuery.lastModified[s.url] || "Thu, 01 Jan 1970 00:00:00 GMT" );
  2190. // Set header so the called script knows that it's an XMLHttpRequest
  2191. xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
  2192. // Set the Accepts header for the server, depending on the dataType
  2193. xhr.setRequestHeader("Accept", s.dataType && s.accepts[ s.dataType ] ?
  2194. s.accepts[ s.dataType ] + ", */*" :
  2195. s.accepts._default );
  2196. } catch(e){}
  2197. // Allow custom headers/mimetypes
  2198. if ( s.beforeSend && s.beforeSend(xhr, s) === false ) {
  2199. // cleanup active request counter
  2200. s.global && jQuery.active--;
  2201. // close opended socket
  2202. xhr.abort();
  2203. return false;
  2204. }
  2205. if ( s.global )
  2206. jQuery.event.trigger("ajaxSend", [xhr, s]);
  2207. // Wait for a response to come back
  2208. var onreadystatechange = function(isTimeout){
  2209. // The transfer is complete and the data is available, or the request timed out
  2210. if ( !requestDone && xhr && (xhr.readyState == 4 || isTimeout == "timeout") ) {
  2211. requestDone = true;
  2212. // clear poll interval
  2213. if (ival) {
  2214. clearInterval(ival);
  2215. ival = null;
  2216. }
  2217. status = isTimeout == "timeout" ? "timeout" :
  2218. !jQuery.httpSuccess( xhr ) ? "error" :
  2219. s.ifModified && jQuery.httpNotModified( xhr, s.url ) ? "notmodified" :
  2220. "success";
  2221. if ( status == "success" ) {
  2222. // Watch for, and catch, XML document parse errors
  2223. try {
  2224. // process the data (runs the xml through httpData regardless of callback)
  2225. data = jQuery.httpData( xhr, s.dataType, s.dataFilter );
  2226. } catch(e) {
  2227. status = "parsererror";
  2228. }
  2229. }
  2230. // Make sure that the request was successful or notmodified
  2231. if ( status == "success" ) {
  2232. // Cache Last-Modified header, if ifModified mode.
  2233. var modRes;
  2234. try {
  2235. modRes = xhr.getResponseHeader("Last-Modified");
  2236. } catch(e) {} // swallow exception thrown by FF if header is not available
  2237. if ( s.ifModified && modRes )
  2238. jQuery.lastModified[s.url] = modRes;
  2239. // JSONP handles its own success callback
  2240. if ( !jsonp )
  2241. success();
  2242. } else
  2243. jQuery.handleError(s, xhr, status);
  2244. // Fire the complete handlers
  2245. complete();
  2246. // Stop memory leaks
  2247. if ( s.async )
  2248. xhr = null;
  2249. }
  2250. };
  2251. if ( s.async ) {
  2252. // don't attach the handler to the request, just poll it instead
  2253. var ival = setInterval(onreadystatechange, 13);
  2254. // Timeout checker
  2255. if ( s.timeout > 0 )
  2256. setTimeout(function(){
  2257. // Check to see if the request is still happening
  2258. if ( xhr ) {
  2259. // Cancel the request
  2260. xhr.abort();
  2261. if( !requestDone )
  2262. onreadystatechange( "timeout" );
  2263. }
  2264. }, s.timeout);
  2265. }
  2266. // Send the data
  2267. try {
  2268. xhr.send(s.data);
  2269. } catch(e) {
  2270. jQuery.handleError(s, xhr, null, e);
  2271. }
  2272. // firefox 1.5 doesn't fire statechange for sync requests
  2273. if ( !s.async )
  2274. onreadystatechange();
  2275. function success(){
  2276. // If a local callback was specified, fire it and pass it the data
  2277. if ( s.success )
  2278. s.success( data, status );
  2279. // Fire the global callback
  2280. if ( s.global )
  2281. jQuery.event.trigger( "ajaxSuccess", [xhr, s] );
  2282. }
  2283. function complete(){
  2284. // Process result
  2285. if ( s.complete )
  2286. s.complete(xhr, status);
  2287. // The request was completed
  2288. if ( s.global )
  2289. jQuery.event.trigger( "ajaxComplete", [xhr, s] );
  2290. // Handle the global AJAX counter
  2291. if ( s.global && ! --jQuery.active )
  2292. jQuery.event.trigger( "ajaxStop" );
  2293. }
  2294. // return XMLHttpRequest to allow aborting the request etc.
  2295. return xhr;
  2296. },
  2297. handleError: function( s, xhr, status, e ) {
  2298. // If a local callback was specified, fire it
  2299. if ( s.error ) s.error( xhr, status, e );
  2300. // Fire the global callback
  2301. if ( s.global )
  2302. jQuery.event.trigger( "ajaxError", [xhr, s, e] );
  2303. },
  2304. // Counter for holding the number of active queries
  2305. active: 0,
  2306. // Determines if an XMLHttpRequest was successful or not
  2307. httpSuccess: function( xhr ) {
  2308. try {
  2309. // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
  2310. return !xhr.status && location.protocol == "file:" ||
  2311. ( xhr.status >= 200 && xhr.status < 300 ) || xhr.status == 304 || xhr.status == 1223 ||
  2312. jQuery.browser.safari && xhr.status == undefined;
  2313. } catch(e){}
  2314. return false;
  2315. },
  2316. // Determines if an XMLHttpRequest returns NotModified
  2317. httpNotModified: function( xhr, url ) {
  2318. try {
  2319. var xhrRes = xhr.getResponseHeader("Last-Modified");
  2320. // Firefox always returns 200. check Last-Modified date
  2321. return xhr.status == 304 || xhrRes == jQuery.lastModified[url] ||
  2322. jQuery.browser.safari && xhr.status == undefined;
  2323. } catch(e){}
  2324. return false;
  2325. },
  2326. httpData: function( xhr, type, filter ) {
  2327. var ct = xhr.getResponseHeader("content-type"),
  2328. xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0,
  2329. data = xml ? xhr.responseXML : xhr.responseText;
  2330. if ( xml && data.documentElement.tagName == "parsererror" )
  2331. throw "parsererror";
  2332. // Allow a pre-filtering function to sanitize the response
  2333. if( filter )
  2334. data = filter( data, type );
  2335. // If the type is "script", eval it in global context
  2336. if ( type == "script" )
  2337. jQuery.globalEval( data );
  2338. // Get the JavaScript object, if JSON is used.
  2339. if ( type == "json" )
  2340. data = eval("(" + data + ")");
  2341. return data;
  2342. },
  2343. // Serialize an array of form elements or a set of
  2344. // key/values into a query string
  2345. param: function( a ) {
  2346. var s = [ ];
  2347. function add( key, value ){
  2348. s[ s.length ] = encodeURIComponent(key) + '=' + encodeURIComponent(value);
  2349. };
  2350. // If an array was passed in, assume that it is an array
  2351. // of form elements
  2352. if ( a.constructor == Array || a.jquery )
  2353. // Serialize the form elements
  2354. jQuery.each( a, function(){
  2355. add( this.name, this.value );
  2356. });
  2357. // Otherwise, assume that it's an object of key/value pairs
  2358. else
  2359. // Serialize the key/values
  2360. for ( var j in a )
  2361. // If the value is an array then the key names need to be repeated
  2362. if ( a[j] && a[j].constructor == Array )
  2363. jQuery.each( a[j], function(){
  2364. add( j, this );
  2365. });
  2366. else
  2367. add( j, jQuery.isFunction(a[j]) ? a[j]() : a[j] );
  2368. // Return the resulting serialization
  2369. return s.join("&").replace(/%20/g, "+");
  2370. }
  2371. });
  2372. jQuery.fn.extend({
  2373. show: function(speed,callback){
  2374. return speed ?
  2375. this.animate({
  2376. height: "show", width: "show", opacity: "show"
  2377. }, speed, callback) :
  2378. this.filter(":hidden").each(function(){
  2379. this.style.display = this.oldblock || "";
  2380. if ( jQuery.css(this,"display") == "none" ) {
  2381. var elem = jQuery("<" + this.tagName + " />").appendTo("body");
  2382. this.style.display = elem.css("display");
  2383. // handle an edge condition where css is - div { display:none; } or similar
  2384. if (this.style.display == "none")
  2385. this.style.display = "block";
  2386. elem.remove();
  2387. }
  2388. }).end();
  2389. },
  2390. hide: function(speed,callback){
  2391. return speed ?
  2392. this.animate({
  2393. height: "hide", width: "hide", opacity: "hide"
  2394. }, speed, callback) :
  2395. this.filter(":visible").each(function(){
  2396. this.oldblock = this.oldblock || jQuery.css(this,"display");
  2397. this.style.display = "none";
  2398. }).end();
  2399. },
  2400. // Save the old toggle function
  2401. _toggle: jQuery.fn.toggle,
  2402. toggle: function( fn, fn2 ){
  2403. return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ?
  2404. this._toggle.apply( this, arguments ) :
  2405. fn ?
  2406. this.animate({
  2407. height: "toggle", width: "toggle", opacity: "toggle"
  2408. }, fn, fn2) :
  2409. this.each(function(){
  2410. jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ]();
  2411. });
  2412. },
  2413. slideDown: function(speed,callback){
  2414. return this.animate({height: "show"}, speed, callback);
  2415. },
  2416. slideUp: function(speed,callback){
  2417. return this.animate({height: "hide"}, speed, callback);
  2418. },
  2419. slideToggle: function(speed, callback){
  2420. return this.animate({height: "toggle"}, speed, callback);
  2421. },
  2422. fadeIn: function(speed, callback){
  2423. return this.animate({opacity: "show"}, speed, callback);
  2424. },
  2425. fadeOut: function(speed, callback){
  2426. return this.animate({opacity: "hide"}, speed, callback);
  2427. },
  2428. fadeTo: function(speed,to,callback){
  2429. return this.animate({opacity: to}, speed, callback);
  2430. },
  2431. animate: function( prop, speed, easing, callback ) {
  2432. var optall = jQuery.speed(speed, easing, callback);
  2433. return this[ optall.queue === false ? "each" : "queue" ](function(){
  2434. if ( this.nodeType != 1)
  2435. return false;
  2436. var opt = jQuery.extend({}, optall), p,
  2437. hidden = jQuery(this).is(":hidden"), self = this;
  2438. for ( p in prop ) {
  2439. if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden )
  2440. return opt.complete.call(this);
  2441. if ( p == "height" || p == "width" ) {
  2442. // Store display property
  2443. opt.display = jQuery.css(this, "display");
  2444. // Make sure that nothing sneaks out
  2445. opt.overflow = this.style.overflow;
  2446. }
  2447. }
  2448. if ( opt.overflow != null )
  2449. this.style.overflow = "hidden";
  2450. opt.curAnim = jQuery.extend({}, prop);
  2451. jQuery.each( prop, function(name, val){
  2452. var e = new jQuery.fx( self, opt, name );
  2453. if ( /toggle|show|hide/.test(val) )
  2454. e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop );
  2455. else {
  2456. var parts = val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),
  2457. start = e.cur(true) || 0;
  2458. if ( parts ) {
  2459. var end = parseFloat(parts[2]),
  2460. unit = parts[3] || "px";
  2461. // We need to compute starting value
  2462. if ( unit != "px" ) {
  2463. self.style[ name ] = (end || 1) + unit;
  2464. start = ((end || 1) / e.cur(true)) * start;
  2465. self.style[ name ] = start + unit;
  2466. }
  2467. // If a +=/-= token was provided, we're doing a relative animation
  2468. if ( parts[1] )
  2469. end = ((parts[1] == "-=" ? -1 : 1) * end) + start;
  2470. e.custom( start, end, unit );
  2471. } else
  2472. e.custom( start, val, "" );
  2473. }
  2474. });
  2475. // For JS strict compliance
  2476. return true;
  2477. });
  2478. },
  2479. queue: function(type, fn){
  2480. if ( jQuery.isFunction(type) || ( type && type.constructor == Array )) {
  2481. fn = type;
  2482. type = "fx";
  2483. }
  2484. if ( !type || (typeof type == "string" && !fn) )
  2485. return queue( this[0], type );
  2486. return this.each(function(){
  2487. if ( fn.constructor == Array )
  2488. queue(this, type, fn);
  2489. else {
  2490. queue(this, type).push( fn );
  2491. if ( queue(this, type).length == 1 )
  2492. fn.call(this);
  2493. }
  2494. });
  2495. },
  2496. stop: function(clearQueue, gotoEnd){
  2497. var timers = jQuery.timers;
  2498. if (clearQueue)
  2499. this.queue([]);
  2500. this.each(function(){
  2501. // go in reverse order so anything added to the queue during the loop is ignored
  2502. for ( var i = timers.length - 1; i >= 0; i-- )
  2503. if ( timers[i].elem == this ) {
  2504. if (gotoEnd)
  2505. // force the next step to be the last
  2506. timers[i](true);
  2507. timers.splice(i, 1);
  2508. }
  2509. });
  2510. // start the next in the queue if the last step wasn't forced
  2511. if (!gotoEnd)
  2512. this.dequeue();
  2513. return this;
  2514. }
  2515. });
  2516. var queue = function( elem, type, array ) {
  2517. if ( elem ){
  2518. type = type || "fx";
  2519. var q = jQuery.data( elem, type + "queue" );
  2520. if ( !q || array )
  2521. q = jQuery.data( elem, type + "queue", jQuery.makeArray(array) );
  2522. }
  2523. return q;
  2524. };
  2525. jQuery.fn.dequeue = function(type){
  2526. type = type || "fx";
  2527. return this.each(function(){
  2528. var q = queue(this, type);
  2529. q.shift();
  2530. if ( q.length )
  2531. q[0].call( this );
  2532. });
  2533. };
  2534. jQuery.extend({
  2535. speed: function(speed, easing, fn) {
  2536. var opt = speed && speed.constructor == Object ? speed : {
  2537. complete: fn || !fn && easing ||
  2538. jQuery.isFunction( speed ) && speed,
  2539. duration: speed,
  2540. easing: fn && easing || easing && easing.constructor != Function && easing
  2541. };
  2542. opt.duration = (opt.duration && opt.duration.constructor == Number ?
  2543. opt.duration :
  2544. jQuery.fx.speeds[opt.duration]) || jQuery.fx.speeds.def;
  2545. // Queueing
  2546. opt.old = opt.complete;
  2547. opt.complete = function(){
  2548. if ( opt.queue !== false )
  2549. jQuery(this).dequeue();
  2550. if ( jQuery.isFunction( opt.old ) )
  2551. opt.old.call( this );
  2552. };
  2553. return opt;
  2554. },
  2555. easing: {
  2556. linear: function( p, n, firstNum, diff ) {
  2557. return firstNum + diff * p;
  2558. },
  2559. swing: function( p, n, firstNum, diff ) {
  2560. return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
  2561. }
  2562. },
  2563. timers: [],
  2564. timerId: null,
  2565. fx: function( elem, options, prop ){
  2566. this.options = options;
  2567. this.elem = elem;
  2568. this.prop = prop;
  2569. if ( !options.orig )
  2570. options.orig = {};
  2571. }
  2572. });
  2573. jQuery.fx.prototype = {
  2574. // Simple function for setting a style value
  2575. update: function(){
  2576. if ( this.options.step )
  2577. this.options.step.call( this.elem, this.now, this );
  2578. (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
  2579. // Set display property to block for height/width animations
  2580. if ( this.prop == "height" || this.prop == "width" )
  2581. this.elem.style.display = "block";
  2582. },
  2583. // Get the current size
  2584. cur: function(force){
  2585. if ( this.elem[this.prop] != null && this.elem.style[this.prop] == null )
  2586. return this.elem[ this.prop ];
  2587. var r = parseFloat(jQuery.css(this.elem, this.prop, force));
  2588. return r && r > -10000 ? r : parseFloat(jQuery.curCSS(this.elem, this.prop)) || 0;
  2589. },
  2590. // Start an animation from one number to another
  2591. custom: function(from, to, unit){
  2592. this.startTime = now();
  2593. this.start = from;
  2594. this.end = to;
  2595. this.unit = unit || this.unit || "px";
  2596. this.now = this.start;
  2597. this.pos = this.state = 0;
  2598. this.update();
  2599. var self = this;
  2600. function t(gotoEnd){
  2601. return self.step(gotoEnd);
  2602. }
  2603. t.elem = this.elem;
  2604. jQuery.timers.push(t);
  2605. if ( jQuery.timerId == null ) {
  2606. jQuery.timerId = setInterval(function(){
  2607. var timers = jQuery.timers;
  2608. for ( var i = 0; i < timers.length; i++ )
  2609. if ( !timers[i]() )
  2610. timers.splice(i--, 1);
  2611. if ( !timers.length ) {
  2612. clearInterval( jQuery.timerId );
  2613. jQuery.timerId = null;
  2614. }
  2615. }, 13);
  2616. }
  2617. },
  2618. // Simple 'show' function
  2619. show: function(){
  2620. // Remember where we started, so that we can go back to it later
  2621. this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop );
  2622. this.options.show = true;
  2623. // Begin the animation
  2624. this.custom(0, this.cur());
  2625. // Make sure that we start at a small width/height to avoid any
  2626. // flash of content
  2627. if ( this.prop == "width" || this.prop == "height" )
  2628. this.elem.style[this.prop] = "1px";
  2629. // Start by showing the element
  2630. jQuery(this.elem).show();
  2631. },
  2632. // Simple 'hide' function
  2633. hide: function(){
  2634. // Remember where we started, so that we can go back to it later
  2635. this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop );
  2636. this.options.hide = true;
  2637. // Begin the animation
  2638. this.custom(this.cur(), 0);
  2639. },
  2640. // Each step of an animation
  2641. step: function(gotoEnd){
  2642. var t = now();
  2643. if ( gotoEnd || t > this.options.duration + this.startTime ) {
  2644. this.now = this.end;
  2645. this.pos = this.state = 1;
  2646. this.update();
  2647. this.options.curAnim[ this.prop ] = true;
  2648. var done = true;
  2649. for ( var i in this.options.curAnim )
  2650. if ( this.options.curAnim[i] !== true )
  2651. done = false;
  2652. if ( done ) {
  2653. if ( this.options.display != null ) {
  2654. // Reset the overflow
  2655. this.elem.style.overflow = this.options.overflow;
  2656. // Reset the display
  2657. this.elem.style.display = this.options.display;
  2658. if ( jQuery.css(this.elem, "display") == "none" )
  2659. this.elem.style.display = "block";
  2660. }
  2661. // Hide the element if the "hide" operation was done
  2662. if ( this.options.hide )
  2663. this.elem.style.display = "none";
  2664. // Reset the properties, if the item has been hidden or shown
  2665. if ( this.options.hide || this.options.show )
  2666. for ( var p in this.options.curAnim )
  2667. jQuery.attr(this.elem.style, p, this.options.orig[p]);
  2668. }
  2669. if ( done )
  2670. // Execute the complete function
  2671. this.options.complete.call( this.elem );
  2672. return false;
  2673. } else {
  2674. var n = t - this.startTime;
  2675. this.state = n / this.options.duration;
  2676. // Perform the easing function, defaults to swing
  2677. this.pos = jQuery.easing[this.options.easing || (jQuery.easing.swing ? "swing" : "linear")](this.state, n, 0, 1, this.options.duration);
  2678. this.now = this.start + ((this.end - this.start) * this.pos);
  2679. // Perform the next step of the animation
  2680. this.update();
  2681. }
  2682. return true;
  2683. }
  2684. };
  2685. jQuery.extend( jQuery.fx, {
  2686. speeds:{
  2687. slow: 600,
  2688. fast: 200,
  2689. // Default speed
  2690. def: 400
  2691. },
  2692. step: {
  2693. scrollLeft: function(fx){
  2694. fx.elem.scrollLeft = fx.now;
  2695. },
  2696. scrollTop: function(fx){
  2697. fx.elem.scrollTop = fx.now;
  2698. },
  2699. opacity: function(fx){
  2700. jQuery.attr(fx.elem.style, "opacity", fx.now);
  2701. },
  2702. _default: function(fx){
  2703. fx.elem.style[ fx.prop ] = fx.now + fx.unit;
  2704. }
  2705. }
  2706. });
  2707. // The Offset Method
  2708. // Originally By Brandon Aaron, part of the Dimension Plugin
  2709. // http://jquery.com/plugins/project/dimensions
  2710. jQuery.fn.offset = function() {
  2711. var left = 0, top = 0, elem = this[0], results;
  2712. if ( elem ) with ( jQuery.browser ) {
  2713. var parent = elem.parentNode,
  2714. offsetChild = elem,
  2715. offsetParent = elem.offsetParent,
  2716. doc = elem.ownerDocument,
  2717. safari2 = safari && parseInt(version) < 522 && !/adobeair/i.test(userAgent),
  2718. css = jQuery.curCSS,
  2719. fixed = css(elem, "position") == "fixed";
  2720. // Use getBoundingClientRect if available
  2721. if ( !(mozilla && elem == document.body) && elem.getBoundingClientRect ) {
  2722. var box = elem.getBoundingClientRect();
  2723. // Add the document scroll offsets
  2724. add(box.left + Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft),
  2725. box.top + Math.max(doc.documentElement.scrollTop, doc.body.scrollTop));
  2726. // IE adds the HTML element's border, by default it is medium which is 2px
  2727. // IE 6 and 7 quirks mode the border width is overwritable by the following css html { border: 0; }
  2728. // IE 7 standards mode, the border is always 2px
  2729. // This border/offset is typically represented by the clientLeft and clientTop properties
  2730. // However, in IE6 and 7 quirks mode the clientLeft and clientTop properties are not updated when overwriting it via CSS
  2731. // Therefore this method will be off by 2px in IE while in quirksmode
  2732. add( -doc.documentElement.clientLeft, -doc.documentElement.clientTop );
  2733. // Otherwise loop through the offsetParents and parentNodes
  2734. } else {
  2735. // Initial element offsets
  2736. add( elem.offsetLeft, elem.offsetTop );
  2737. // Get parent offsets
  2738. while ( offsetParent ) {
  2739. // Add offsetParent offsets
  2740. add( offsetParent.offsetLeft, offsetParent.offsetTop );
  2741. // Mozilla and Safari > 2 does not include the border on offset parents
  2742. // However Mozilla adds the border for table or table cells
  2743. if ( mozilla && !/^t(able|d|h)$/i.test(offsetParent.tagName) || safari && !safari2 )
  2744. border( offsetParent );
  2745. // Add the document scroll offsets if position is fixed on any offsetParent
  2746. if ( !fixed && css(offsetParent, "position") == "fixed" )
  2747. fixed = true;
  2748. // Set offsetChild to previous offsetParent unless it is the body element
  2749. offsetChild = /^body$/i.test(offsetParent.tagName) ? offsetChild : offsetParent;
  2750. // Get next offsetParent
  2751. offsetParent = offsetParent.offsetParent;
  2752. }
  2753. // Get parent scroll offsets
  2754. while ( parent && parent.tagName && !/^body|html$/i.test(parent.tagName) ) {
  2755. // Remove parent scroll UNLESS that parent is inline or a table to work around Opera inline/table scrollLeft/Top bug
  2756. if ( !/^inline|table.*$/i.test(css(parent, "display")) )
  2757. // Subtract parent scroll offsets
  2758. add( -parent.scrollLeft, -parent.scrollTop );
  2759. // Mozilla does not add the border for a parent that has overflow != visible
  2760. if ( mozilla && css(parent, "overflow") != "visible" )
  2761. border( parent );
  2762. // Get next parent
  2763. parent = parent.parentNode;
  2764. }
  2765. // Safari <= 2 doubles body offsets with a fixed position element/offsetParent or absolutely positioned offsetChild
  2766. // Mozilla doubles body offsets with a non-absolutely positioned offsetChild
  2767. if ( (safari2 && (fixed || css(offsetChild, "position") == "absolute")) ||
  2768. (mozilla && css(offsetChild, "position") != "absolute") )
  2769. add( -doc.body.offsetLeft, -doc.body.offsetTop );
  2770. // Add the document scroll offsets if position is fixed
  2771. if ( fixed )
  2772. add(Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft),
  2773. Math.max(doc.documentElement.scrollTop, doc.body.scrollTop));
  2774. }
  2775. // Return an object with top and left properties
  2776. results = { top: top, left: left };
  2777. }
  2778. function border(elem) {
  2779. add( jQuery.curCSS(elem, "borderLeftWidth", true), jQuery.curCSS(elem, "borderTopWidth", true) );
  2780. }
  2781. function add(l, t) {
  2782. left += parseInt(l, 10) || 0;
  2783. top += parseInt(t, 10) || 0;
  2784. }
  2785. return results;
  2786. };
  2787. jQuery.fn.extend({
  2788. position: function() {
  2789. var left = 0, top = 0, results;
  2790. if ( this[0] ) {
  2791. // Get *real* offsetParent
  2792. var offsetParent = this.offsetParent(),
  2793. // Get correct offsets
  2794. offset = this.offset(),
  2795. parentOffset = /^body|html$/i.test(offsetParent[0].tagName) ? { top: 0, left: 0 } : offsetParent.offset();
  2796. // Subtract element margins
  2797. // note: when an element has margin: auto the offsetLeft and marginLeft
  2798. // are the same in Safari causing offset.left to incorrectly be 0
  2799. offset.top -= num( this, 'marginTop' );
  2800. offset.left -= num( this, 'marginLeft' );
  2801. // Add offsetParent borders
  2802. parentOffset.top += num( offsetParent, 'borderTopWidth' );
  2803. parentOffset.left += num( offsetParent, 'borderLeftWidth' );
  2804. // Subtract the two offsets
  2805. results = {
  2806. top: offset.top - parentOffset.top,
  2807. left: offset.left - parentOffset.left
  2808. };
  2809. }
  2810. return results;
  2811. },
  2812. offsetParent: function() {
  2813. var offsetParent = this[0].offsetParent;
  2814. while ( offsetParent && (!/^body|html$/i.test(offsetParent.tagName) && jQuery.css(offsetParent, 'position') == 'static') )
  2815. offsetParent = offsetParent.offsetParent;
  2816. return jQuery(offsetParent);
  2817. }
  2818. });
  2819. // Create scrollLeft and scrollTop methods
  2820. jQuery.each( ['Left', 'Top'], function(i, name) {
  2821. var method = 'scroll' + name;
  2822. jQuery.fn[ method ] = function(val) {
  2823. if (!this[0]) return;
  2824. return val != undefined ?
  2825. // Set the scroll offset
  2826. this.each(function() {
  2827. this == window || this == document ?
  2828. window.scrollTo(
  2829. !i ? val : jQuery(window).scrollLeft(),
  2830. i ? val : jQuery(window).scrollTop()
  2831. ) :
  2832. this[ method ] = val;
  2833. }) :
  2834. // Return the scroll offset
  2835. this[0] == window || this[0] == document ?
  2836. self[ i ? 'pageYOffset' : 'pageXOffset' ] ||
  2837. jQuery.boxModel && document.documentElement[ method ] ||
  2838. document.body[ method ] :
  2839. this[0][ method ];
  2840. };
  2841. });
  2842. // Create innerHeight, innerWidth, outerHeight and outerWidth methods
  2843. jQuery.each([ "Height", "Width" ], function(i, name){
  2844. var tl = i ? "Left" : "Top", // top or left
  2845. br = i ? "Right" : "Bottom"; // bottom or right
  2846. // innerHeight and innerWidth
  2847. jQuery.fn["inner" + name] = function(){
  2848. return this[ name.toLowerCase() ]() +
  2849. num(this, "padding" + tl) +
  2850. num(this, "padding" + br);
  2851. };
  2852. // outerHeight and outerWidth
  2853. jQuery.fn["outer" + name] = function(margin) {
  2854. return this["inner" + name]() +
  2855. num(this, "border" + tl + "Width") +
  2856. num(this, "border" + br + "Width") +
  2857. (margin ?
  2858. num(this, "margin" + tl) + num(this, "margin" + br) : 0);
  2859. };
  2860. });})();