PageRenderTime 72ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/media/js/jquery.js

http://trespams.googlecode.com/
JavaScript | 3408 lines | 2771 code | 294 blank | 343 comment | 385 complexity | 032eb9d1100e96e9c9fbf3ad6a390bfd MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. (function(){
  2. /*
  3. * jQuery 1.2.3b - 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-02-03 19:43:04 +0100 (So, 03 Feb 2008) $
  10. * $Rev: 4611 $
  11. */
  12. // Map over jQuery in case of overwrite
  13. if ( window.jQuery )
  14. var _jQuery = window.jQuery;
  15. var jQuery = window.jQuery = function( selector, context ) {
  16. // The jQuery object is actually just the init constructor 'enhanced'
  17. return new jQuery.prototype.init( selector, context );
  18. };
  19. // Map over the $ in case of overwrite
  20. if ( window.$ )
  21. var _$ = window.$;
  22. // Map the jQuery namespace to the '$' one
  23. window.$ = jQuery;
  24. // A simple way to check for HTML strings or ID strings
  25. // (both of which we optimize for)
  26. var quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/;
  27. // Is it a simple selector
  28. var isSimple = /^.[^:#\[\.]*$/;
  29. jQuery.fn = jQuery.prototype = {
  30. init: function( selector, context ) {
  31. // Make sure that a selection was provided
  32. selector = selector || document;
  33. // Handle $(DOMElement)
  34. if ( selector.nodeType ) {
  35. this[0] = selector;
  36. this.length = 1;
  37. return this;
  38. // Handle HTML strings
  39. } else if ( typeof selector == "string" ) {
  40. // Are we dealing with HTML string or an ID?
  41. var match = quickExpr.exec( selector );
  42. // Verify a match, and that no context was specified for #id
  43. if ( match && (match[1] || !context) ) {
  44. // HANDLE: $(html) -> $(array)
  45. if ( match[1] )
  46. selector = jQuery.clean( [ match[1] ], context );
  47. // HANDLE: $("#id")
  48. else {
  49. var elem = document.getElementById( match[3] );
  50. // Make sure an element was located
  51. if ( elem )
  52. // Handle the case where IE and Opera return items
  53. // by name instead of ID
  54. if ( elem.id != match[3] )
  55. return jQuery().find( selector );
  56. // Otherwise, we inject the element directly into the jQuery object
  57. else {
  58. this[0] = elem;
  59. this.length = 1;
  60. return this;
  61. }
  62. else
  63. selector = [];
  64. }
  65. // HANDLE: $(expr, [context])
  66. // (which is just equivalent to: $(content).find(expr)
  67. } else
  68. return new jQuery( context ).find( selector );
  69. // HANDLE: $(function)
  70. // Shortcut for document ready
  71. } else if ( jQuery.isFunction( selector ) )
  72. return new jQuery( document )[ jQuery.fn.ready ? "ready" : "load" ]( selector );
  73. return this.setArray(
  74. // HANDLE: $(array)
  75. selector.constructor == Array && selector ||
  76. // HANDLE: $(arraylike)
  77. // Watch for when an array-like object, contains DOM nodes, is passed in as the selector
  78. (selector.jquery || selector.length && selector != window && !selector.nodeType && selector[0] != undefined && selector[0].nodeType) && jQuery.makeArray( selector ) ||
  79. // HANDLE: $(*)
  80. [ selector ] );
  81. },
  82. // The current version of jQuery being used
  83. jquery: "1.2.3b",
  84. // The number of elements contained in the matched element set
  85. size: function() {
  86. return this.length;
  87. },
  88. // The number of elements contained in the matched element set
  89. length: 0,
  90. // Get the Nth element in the matched element set OR
  91. // Get the whole matched element set as a clean array
  92. get: function( num ) {
  93. return num == undefined ?
  94. // Return a 'clean' array
  95. jQuery.makeArray( this ) :
  96. // Return just the object
  97. this[ num ];
  98. },
  99. // Take an array of elements and push it onto the stack
  100. // (returning the new matched element set)
  101. pushStack: function( elems ) {
  102. // Build a new jQuery matched element set
  103. var ret = jQuery( elems );
  104. // Add the old object onto the stack (as a reference)
  105. ret.prevObject = this;
  106. // Return the newly-formed element set
  107. return ret;
  108. },
  109. // Force the current matched set of elements to become
  110. // the specified array of elements (destroying the stack in the process)
  111. // You should use pushStack() in order to do this, but maintain the stack
  112. setArray: function( elems ) {
  113. // Resetting the length to 0, then using the native Array push
  114. // is a super-fast way to populate an object with array-like properties
  115. this.length = 0;
  116. Array.prototype.push.apply( this, elems );
  117. return this;
  118. },
  119. // Execute a callback for every element in the matched set.
  120. // (You can seed the arguments with an array of args, but this is
  121. // only used internally.)
  122. each: function( callback, args ) {
  123. return jQuery.each( this, callback, args );
  124. },
  125. // Determine the position of an element within
  126. // the matched set of elements
  127. index: function( elem ) {
  128. var ret = -1;
  129. // Locate the position of the desired element
  130. this.each(function(i){
  131. if ( this == elem )
  132. ret = i;
  133. });
  134. return ret;
  135. },
  136. attr: function( name, value, type ) {
  137. var options = name;
  138. // Look for the case where we're accessing a style value
  139. if ( name.constructor == String )
  140. if ( value == undefined )
  141. return this.length && jQuery[ type || "attr" ]( this[0], name ) || undefined;
  142. else {
  143. options = {};
  144. options[ name ] = value;
  145. }
  146. // Check to see if we're setting style values
  147. return this.each(function(i){
  148. // Set all the styles
  149. for ( name in options )
  150. jQuery.attr(
  151. type ?
  152. this.style :
  153. this,
  154. name, jQuery.prop( this, options[ name ], type, i, name )
  155. );
  156. });
  157. },
  158. css: function( key, value ) {
  159. // ignore negative width and height values
  160. if ( (key == 'width' || key == 'height') && parseFloat(value) < 0 )
  161. value = undefined;
  162. return this.attr( key, value, "curCSS" );
  163. },
  164. text: function( text ) {
  165. if ( typeof text != "object" && text != null )
  166. return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
  167. var ret = "";
  168. jQuery.each( text || this, function(){
  169. jQuery.each( this.childNodes, function(){
  170. if ( this.nodeType != 8 )
  171. ret += this.nodeType != 1 ?
  172. this.nodeValue :
  173. jQuery.fn.text( [ this ] );
  174. });
  175. });
  176. return ret;
  177. },
  178. wrapAll: function( html ) {
  179. if ( this[0] )
  180. // The elements to wrap the target around
  181. jQuery( html, this[0].ownerDocument )
  182. .clone()
  183. .insertBefore( this[0] )
  184. .map(function(){
  185. var elem = this;
  186. while ( elem.firstChild )
  187. elem = elem.firstChild;
  188. return elem;
  189. })
  190. .append(this);
  191. return this;
  192. },
  193. wrapInner: function( html ) {
  194. return this.each(function(){
  195. jQuery( this ).contents().wrapAll( html );
  196. });
  197. },
  198. wrap: function( html ) {
  199. return this.each(function(){
  200. jQuery( this ).wrapAll( html );
  201. });
  202. },
  203. append: function() {
  204. return this.domManip(arguments, true, false, function(elem){
  205. if (this.nodeType == 1)
  206. this.appendChild( elem );
  207. });
  208. },
  209. prepend: function() {
  210. return this.domManip(arguments, true, true, function(elem){
  211. if (this.nodeType == 1)
  212. this.insertBefore( elem, this.firstChild );
  213. });
  214. },
  215. before: function() {
  216. return this.domManip(arguments, false, false, function(elem){
  217. this.parentNode.insertBefore( elem, this );
  218. });
  219. },
  220. after: function() {
  221. return this.domManip(arguments, false, true, function(elem){
  222. this.parentNode.insertBefore( elem, this.nextSibling );
  223. });
  224. },
  225. end: function() {
  226. return this.prevObject || jQuery( [] );
  227. },
  228. find: function( selector ) {
  229. var elems = jQuery.map(this, function(elem){
  230. return jQuery.find( selector, elem );
  231. });
  232. return this.pushStack( /[^+>] [^+>]/.test( selector ) || selector.indexOf("..") > -1 ?
  233. jQuery.unique( elems ) :
  234. elems );
  235. },
  236. clone: function( events ) {
  237. // Do the clone
  238. var ret = this.map(function(){
  239. if ( jQuery.browser.msie && !jQuery.isXMLDoc(this) ) {
  240. // IE copies events bound via attachEvent when
  241. // using cloneNode. Calling detachEvent on the
  242. // clone will also remove the events from the orignal
  243. // In order to get around this, we use innerHTML.
  244. // Unfortunately, this means some modifications to
  245. // attributes in IE that are actually only stored
  246. // as properties will not be copied (such as the
  247. // the name attribute on an input).
  248. var clone = this.cloneNode(true),
  249. container = document.createElement("div");
  250. container.appendChild(clone);
  251. return jQuery.clean([container.innerHTML])[0];
  252. } else
  253. return this.cloneNode(true);
  254. });
  255. // Need to set the expando to null on the cloned set if it exists
  256. // removeData doesn't work here, IE removes it from the original as well
  257. // this is primarily for IE but the data expando shouldn't be copied over in any browser
  258. var clone = ret.find("*").andSelf().each(function(){
  259. if ( this[ expando ] != undefined )
  260. this[ expando ] = null;
  261. });
  262. // Copy the events from the original to the clone
  263. if ( events === true )
  264. this.find("*").andSelf().each(function(i){
  265. if (this.nodeType == 3)
  266. return;
  267. var events = jQuery.data( this, "events" );
  268. for ( var type in events )
  269. for ( var handler in events[ type ] )
  270. jQuery.event.add( clone[ i ], type, events[ type ][ handler ], events[ type ][ handler ].data );
  271. });
  272. // Return the cloned set
  273. return ret;
  274. },
  275. filter: function( selector ) {
  276. return this.pushStack(
  277. jQuery.isFunction( selector ) &&
  278. jQuery.grep(this, function(elem, i){
  279. return selector.call( elem, i );
  280. }) ||
  281. jQuery.multiFilter( selector, this ) );
  282. },
  283. not: function( selector ) {
  284. if ( selector.constructor == String )
  285. // test special case where just one selector is passed in
  286. if ( isSimple.test( selector ) )
  287. return this.pushStack( jQuery.multiFilter( selector, this, true ) );
  288. else
  289. selector = jQuery.multiFilter( selector, this );
  290. var isArrayLike = selector.length && selector[selector.length - 1] !== undefined && !selector.nodeType;
  291. return this.filter(function() {
  292. return isArrayLike ? jQuery.inArray( this, selector ) < 0 : this != selector;
  293. });
  294. },
  295. add: function( selector ) {
  296. return !selector ? this : this.pushStack( jQuery.merge(
  297. this.get(),
  298. selector.constructor == String ?
  299. jQuery( selector ).get() :
  300. selector.length != undefined && (!selector.nodeName || jQuery.nodeName(selector, "form")) ?
  301. selector : [selector] ) );
  302. },
  303. is: function( selector ) {
  304. return selector ?
  305. jQuery.multiFilter( selector, this ).length > 0 :
  306. false;
  307. },
  308. hasClass: function( selector ) {
  309. return this.is( "." + selector );
  310. },
  311. val: function( value ) {
  312. if ( value == undefined ) {
  313. if ( this.length ) {
  314. var elem = this[0];
  315. // We need to handle select boxes special
  316. if ( jQuery.nodeName( elem, "select" ) ) {
  317. var index = elem.selectedIndex,
  318. values = [],
  319. options = elem.options,
  320. one = elem.type == "select-one";
  321. // Nothing was selected
  322. if ( index < 0 )
  323. return null;
  324. // Loop through all the selected options
  325. for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
  326. var option = options[ i ];
  327. if ( option.selected ) {
  328. // Get the specifc value for the option
  329. value = jQuery.browser.msie && !option.attributes.value.specified ? option.text : option.value;
  330. // We don't need an array for one selects
  331. if ( one )
  332. return value;
  333. // Multi-Selects return an array
  334. values.push( value );
  335. }
  336. }
  337. return values;
  338. // Everything else, we just grab the value
  339. } else
  340. return (this[0].value || "").replace(/\r/g, "");
  341. }
  342. return undefined;
  343. }
  344. return this.each(function(){
  345. if ( this.nodeType != 1 )
  346. return;
  347. if ( value.constructor == Array && /radio|checkbox/.test( this.type ) )
  348. this.checked = (jQuery.inArray(this.value, value) >= 0 ||
  349. jQuery.inArray(this.name, value) >= 0);
  350. else if ( jQuery.nodeName( this, "select" ) ) {
  351. var values = value.constructor == Array ?
  352. value :
  353. [ value ];
  354. jQuery( "option", this ).each(function(){
  355. this.selected = (jQuery.inArray( this.value, values ) >= 0 ||
  356. jQuery.inArray( this.text, values ) >= 0);
  357. });
  358. if ( !values.length )
  359. this.selectedIndex = -1;
  360. } else
  361. this.value = value;
  362. });
  363. },
  364. html: function( value ) {
  365. return value == undefined ?
  366. (this.length ?
  367. this[0].innerHTML :
  368. null) :
  369. this.empty().append( value );
  370. },
  371. replaceWith: function( value ) {
  372. return this.after( value ).remove();
  373. },
  374. eq: function( i ) {
  375. return this.slice( i, i + 1 );
  376. },
  377. slice: function() {
  378. return this.pushStack( Array.prototype.slice.apply( this, arguments ) );
  379. },
  380. map: function( callback ) {
  381. return this.pushStack( jQuery.map(this, function(elem, i){
  382. return callback.call( elem, i, elem );
  383. }));
  384. },
  385. andSelf: function() {
  386. return this.add( this.prevObject );
  387. },
  388. data: function( key, value ){
  389. var parts = key.split(".");
  390. parts[1] = parts[1] ? "." + parts[1] : "";
  391. if ( value == null ) {
  392. var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
  393. if ( data == undefined && this.length )
  394. data = jQuery.data( this[0], key );
  395. return data == null && parts[1] ?
  396. this.data( parts[0] ) :
  397. data;
  398. } else
  399. return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function(){
  400. jQuery.data( this, key, value );
  401. });
  402. },
  403. removeData: function( key ){
  404. return this.each(function(){
  405. jQuery.removeData( this, key );
  406. });
  407. },
  408. domManip: function( args, table, reverse, callback ) {
  409. var clone = this.length > 1, elems;
  410. return this.each(function(){
  411. if ( !elems ) {
  412. elems = jQuery.clean( args, this.ownerDocument );
  413. if ( reverse )
  414. elems.reverse();
  415. }
  416. var obj = this;
  417. if ( table && jQuery.nodeName( this, "table" ) && jQuery.nodeName( elems[0], "tr" ) )
  418. obj = this.getElementsByTagName("tbody")[0] || this.appendChild( this.ownerDocument.createElement("tbody") );
  419. var scripts = jQuery( [] );
  420. jQuery.each(elems, function(){
  421. var elem = clone ?
  422. jQuery( this ).clone( true )[0] :
  423. this;
  424. // execute all scripts after the elements have been injected
  425. if ( jQuery.nodeName( elem, "script" ) ) {
  426. scripts = scripts.add( elem );
  427. } else {
  428. // Remove any inner scripts for later evaluation
  429. if ( elem.nodeType == 1 )
  430. scripts = scripts.add( jQuery( "script", elem ).remove() );
  431. // Inject the elements into the document
  432. callback.call( obj, elem );
  433. }
  434. });
  435. scripts.each( evalScript );
  436. });
  437. }
  438. };
  439. // Give the init function the jQuery prototype for later instantiation
  440. jQuery.prototype.init.prototype = jQuery.prototype;
  441. function evalScript( i, elem ) {
  442. if ( elem.src )
  443. jQuery.ajax({
  444. url: elem.src,
  445. async: false,
  446. dataType: "script"
  447. });
  448. else
  449. jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );
  450. if ( elem.parentNode )
  451. elem.parentNode.removeChild( elem );
  452. }
  453. jQuery.extend = jQuery.fn.extend = function() {
  454. // copy reference to target object
  455. var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options;
  456. // Handle a deep copy situation
  457. if ( target.constructor == Boolean ) {
  458. deep = target;
  459. target = arguments[1] || {};
  460. // skip the boolean and the target
  461. i = 2;
  462. }
  463. // Handle case when target is a string or something (possible in deep copy)
  464. if ( typeof target != "object" && typeof target != "function" )
  465. target = {};
  466. // extend jQuery itself if only one argument is passed
  467. if ( length == 1 ) {
  468. target = this;
  469. i = 0;
  470. }
  471. for ( ; i < length; i++ )
  472. // Only deal with non-null/undefined values
  473. if ( (options = arguments[ i ]) != null )
  474. // Extend the base object
  475. for ( var name in options ) {
  476. // Prevent never-ending loop
  477. if ( target === options[ name ] )
  478. continue;
  479. // Recurse if we're merging object values
  480. if ( deep && options[ name ] && typeof options[ name ] == "object" && target[ name ] && !options[ name ].nodeType )
  481. target[ name ] = jQuery.extend( target[ name ], options[ name ] );
  482. // Don't bring in undefined values
  483. else if ( options[ name ] != undefined )
  484. target[ name ] = options[ name ];
  485. }
  486. // Return the modified object
  487. return target;
  488. };
  489. var expando = "jQuery" + (new Date()).getTime(), uuid = 0, windowData = {};
  490. // exclude the following css properties to add px
  491. var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i;
  492. jQuery.extend({
  493. noConflict: function( deep ) {
  494. window.$ = _$;
  495. if ( deep )
  496. window.jQuery = _jQuery;
  497. return jQuery;
  498. },
  499. // See test/unit/core.js for details concerning this function.
  500. isFunction: function( fn ) {
  501. return !!fn && typeof fn != "string" && !fn.nodeName &&
  502. fn.constructor != Array && /function/i.test( fn + "" );
  503. },
  504. // check if an element is in a (or is an) XML document
  505. isXMLDoc: function( elem ) {
  506. return elem.documentElement && !elem.body ||
  507. elem.tagName && elem.ownerDocument && !elem.ownerDocument.body;
  508. },
  509. // Evalulates a script in a global context
  510. globalEval: function( data ) {
  511. data = jQuery.trim( data );
  512. if ( data ) {
  513. // Inspired by code by Andrea Giammarchi
  514. // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
  515. var head = document.getElementsByTagName("head")[0] || document.documentElement,
  516. script = document.createElement("script");
  517. script.type = "text/javascript";
  518. if ( jQuery.browser.msie )
  519. script.text = data;
  520. else
  521. script.appendChild( document.createTextNode( data ) );
  522. head.appendChild( script );
  523. head.removeChild( script );
  524. }
  525. },
  526. nodeName: function( elem, name ) {
  527. return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase();
  528. },
  529. cache: {},
  530. data: function( elem, name, data ) {
  531. elem = elem == window ?
  532. windowData :
  533. elem;
  534. var id = elem[ expando ];
  535. // Compute a unique ID for the element
  536. if ( !id )
  537. id = elem[ expando ] = ++uuid;
  538. // Only generate the data cache if we're
  539. // trying to access or manipulate it
  540. if ( name && !jQuery.cache[ id ] )
  541. jQuery.cache[ id ] = {};
  542. // Prevent overriding the named cache with undefined values
  543. if ( data != undefined )
  544. jQuery.cache[ id ][ name ] = data;
  545. // Return the named cache data, or the ID for the element
  546. return name ?
  547. jQuery.cache[ id ][ name ] :
  548. id;
  549. },
  550. removeData: function( elem, name ) {
  551. elem = elem == window ?
  552. windowData :
  553. elem;
  554. var id = elem[ expando ];
  555. // If we want to remove a specific section of the element's data
  556. if ( name ) {
  557. if ( jQuery.cache[ id ] ) {
  558. // Remove the section of cache data
  559. delete jQuery.cache[ id ][ name ];
  560. // If we've removed all the data, remove the element's cache
  561. name = "";
  562. for ( name in jQuery.cache[ id ] )
  563. break;
  564. if ( !name )
  565. jQuery.removeData( elem );
  566. }
  567. // Otherwise, we want to remove all of the element's data
  568. } else {
  569. // Clean up the element expando
  570. try {
  571. delete elem[ expando ];
  572. } catch(e){
  573. // IE has trouble directly removing the expando
  574. // but it's ok with using removeAttribute
  575. if ( elem.removeAttribute )
  576. elem.removeAttribute( expando );
  577. }
  578. // Completely remove the data cache
  579. delete jQuery.cache[ id ];
  580. }
  581. },
  582. // args is for internal usage only
  583. each: function( object, callback, args ) {
  584. if ( args ) {
  585. if ( object.length == undefined ) {
  586. for ( var name in object )
  587. if ( callback.apply( object[ name ], args ) === false )
  588. break;
  589. } else
  590. for ( var i = 0, length = object.length; i < length; i++ )
  591. if ( callback.apply( object[ i ], args ) === false )
  592. break;
  593. // A special, fast, case for the most common use of each
  594. } else {
  595. if ( object.length == undefined ) {
  596. for ( var name in object )
  597. if ( callback.call( object[ name ], name, object[ name ] ) === false )
  598. break;
  599. } else
  600. for ( var i = 0, length = object.length, value = object[0];
  601. i < length && callback.call( value, i, value ) !== false; value = object[++i] ){}
  602. }
  603. return object;
  604. },
  605. prop: function( elem, value, type, i, name ) {
  606. // Handle executable functions
  607. if ( jQuery.isFunction( value ) )
  608. value = value.call( elem, i );
  609. // Handle passing in a number to a CSS property
  610. return value && value.constructor == Number && type == "curCSS" && !exclude.test( name ) ?
  611. value + "px" :
  612. value;
  613. },
  614. className: {
  615. // internal only, use addClass("class")
  616. add: function( elem, classNames ) {
  617. jQuery.each((classNames || "").split(/\s+/), function(i, className){
  618. if ( elem.nodeType == 1 && !jQuery.className.has( elem.className, className ) )
  619. elem.className += (elem.className ? " " : "") + className;
  620. });
  621. },
  622. // internal only, use removeClass("class")
  623. remove: function( elem, classNames ) {
  624. if (elem.nodeType == 1)
  625. elem.className = classNames != undefined ?
  626. jQuery.grep(elem.className.split(/\s+/), function(className){
  627. return !jQuery.className.has( classNames, className );
  628. }).join(" ") :
  629. "";
  630. },
  631. // internal only, use is(".class")
  632. has: function( elem, className ) {
  633. return jQuery.inArray( className, (elem.className || elem).toString().split(/\s+/) ) > -1;
  634. }
  635. },
  636. // A method for quickly swapping in/out CSS properties to get correct calculations
  637. swap: function( elem, options, callback ) {
  638. var old = {};
  639. // Remember the old values, and insert the new ones
  640. for ( var name in options ) {
  641. old[ name ] = elem.style[ name ];
  642. elem.style[ name ] = options[ name ];
  643. }
  644. callback.call( elem );
  645. // Revert the old values
  646. for ( var name in options )
  647. elem.style[ name ] = old[ name ];
  648. },
  649. css: function( elem, name, force ) {
  650. if ( name == "width" || name == "height" ) {
  651. var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name == "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ];
  652. function getWH() {
  653. val = name == "width" ? elem.offsetWidth : elem.offsetHeight;
  654. var padding = 0, border = 0;
  655. jQuery.each( which, function() {
  656. padding += parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0;
  657. border += parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0;
  658. });
  659. val -= Math.round(padding + border);
  660. }
  661. if ( jQuery(elem).is(":visible") )
  662. getWH();
  663. else
  664. jQuery.swap( elem, props, getWH );
  665. return Math.max(0, val);
  666. }
  667. return jQuery.curCSS( elem, name, force );
  668. },
  669. curCSS: function( elem, name, force ) {
  670. var ret;
  671. // A helper method for determining if an element's values are broken
  672. function color( elem ) {
  673. if ( !jQuery.browser.safari )
  674. return false;
  675. var ret = document.defaultView.getComputedStyle( elem, null );
  676. return !ret || ret.getPropertyValue("color") == "";
  677. }
  678. // We need to handle opacity special in IE
  679. if ( name == "opacity" && jQuery.browser.msie ) {
  680. ret = jQuery.attr( elem.style, "opacity" );
  681. return ret == "" ?
  682. "1" :
  683. ret;
  684. }
  685. // Opera sometimes will give the wrong display answer, this fixes it, see #2037
  686. if ( jQuery.browser.opera && name == "display" ) {
  687. var save = elem.style.display;
  688. elem.style.display = "block";
  689. elem.style.display = save;
  690. }
  691. // Make sure we're using the right name for getting the float value
  692. if ( name.match( /float/i ) )
  693. name = styleFloat;
  694. if ( !force && elem.style && elem.style[ name ] )
  695. ret = elem.style[ name ];
  696. else if ( document.defaultView && document.defaultView.getComputedStyle ) {
  697. // Only "float" is needed here
  698. if ( name.match( /float/i ) )
  699. name = "float";
  700. name = name.replace( /([A-Z])/g, "-$1" ).toLowerCase();
  701. var getComputedStyle = document.defaultView.getComputedStyle( elem, null );
  702. if ( getComputedStyle && !color( elem ) )
  703. ret = getComputedStyle.getPropertyValue( name );
  704. // If the element isn't reporting its values properly in Safari
  705. // then some display: none elements are involved
  706. else {
  707. var swap = [], stack = [];
  708. // Locate all of the parent display: none elements
  709. for ( var a = elem; a && color(a); a = a.parentNode )
  710. stack.unshift(a);
  711. // Go through and make them visible, but in reverse
  712. // (It would be better if we knew the exact display type that they had)
  713. for ( var i = 0; i < stack.length; i++ )
  714. if ( color( stack[ i ] ) ) {
  715. swap[ i ] = stack[ i ].style.display;
  716. stack[ i ].style.display = "block";
  717. }
  718. // Since we flip the display style, we have to handle that
  719. // one special, otherwise get the value
  720. ret = name == "display" && swap[ stack.length - 1 ] != null ?
  721. "none" :
  722. ( getComputedStyle && getComputedStyle.getPropertyValue( name ) ) || "";
  723. // Finally, revert the display styles back
  724. for ( var i = 0; i < swap.length; i++ )
  725. if ( swap[ i ] != null )
  726. stack[ i ].style.display = swap[ i ];
  727. }
  728. // We should always get a number back from opacity
  729. if ( name == "opacity" && ret == "" )
  730. ret = "1";
  731. } else if ( elem.currentStyle ) {
  732. var camelCase = name.replace(/\-(\w)/g, function(all, letter){
  733. return letter.toUpperCase();
  734. });
  735. ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ];
  736. // From the awesome hack by Dean Edwards
  737. // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
  738. // If we're not dealing with a regular pixel number
  739. // but a number that has a weird ending, we need to convert it to pixels
  740. if ( !/^\d+(px)?$/i.test( ret ) && /^\d/.test( ret ) ) {
  741. // Remember the original values
  742. var style = elem.style.left, runtimeStyle = elem.runtimeStyle.left;
  743. // Put in the new values to get a computed value out
  744. elem.runtimeStyle.left = elem.currentStyle.left;
  745. elem.style.left = ret || 0;
  746. ret = elem.style.pixelLeft + "px";
  747. // Revert the changed values
  748. elem.style.left = style;
  749. elem.runtimeStyle.left = runtimeStyle;
  750. }
  751. }
  752. return ret;
  753. },
  754. clean: function( elems, context ) {
  755. var ret = [];
  756. context = context || document;
  757. // !context.createElement fails in IE with an error but returns typeof 'object'
  758. if (typeof context.createElement == 'undefined')
  759. context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
  760. jQuery.each(elems, function(i, elem){
  761. if ( !elem )
  762. return;
  763. if ( elem.constructor == Number )
  764. elem = elem.toString();
  765. // Convert html string into DOM nodes
  766. if ( typeof elem == "string" ) {
  767. // Fix "XHTML"-style tags in all browsers
  768. elem = elem.replace(/(<(\w+)[^>]*?)\/>/g, function(all, front, tag){
  769. return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i) ?
  770. all :
  771. front + "></" + tag + ">";
  772. });
  773. // Trim whitespace, otherwise indexOf won't work as expected
  774. var tags = jQuery.trim( elem ).toLowerCase(), div = context.createElement("div");
  775. var wrap =
  776. // option or optgroup
  777. !tags.indexOf("<opt") &&
  778. [ 1, "<select multiple='multiple'>", "</select>" ] ||
  779. !tags.indexOf("<leg") &&
  780. [ 1, "<fieldset>", "</fieldset>" ] ||
  781. tags.match(/^<(thead|tbody|tfoot|colg|cap)/) &&
  782. [ 1, "<table>", "</table>" ] ||
  783. !tags.indexOf("<tr") &&
  784. [ 2, "<table><tbody>", "</tbody></table>" ] ||
  785. // <thead> matched above
  786. (!tags.indexOf("<td") || !tags.indexOf("<th")) &&
  787. [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ] ||
  788. !tags.indexOf("<col") &&
  789. [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ] ||
  790. // IE can't serialize <link> and <script> tags normally
  791. jQuery.browser.msie &&
  792. [ 1, "div<div>", "</div>" ] ||
  793. [ 0, "", "" ];
  794. // Go to html and back, then peel off extra wrappers
  795. div.innerHTML = wrap[1] + elem + wrap[2];
  796. // Move to the right depth
  797. while ( wrap[0]-- )
  798. div = div.lastChild;
  799. // Remove IE's autoinserted <tbody> from table fragments
  800. if ( jQuery.browser.msie ) {
  801. // String was a <table>, *may* have spurious <tbody>
  802. var tbody = !tags.indexOf("<table") && tags.indexOf("<tbody") < 0 ?
  803. div.firstChild && div.firstChild.childNodes :
  804. // String was a bare <thead> or <tfoot>
  805. wrap[1] == "<table>" && tags.indexOf("<tbody") < 0 ?
  806. div.childNodes :
  807. [];
  808. for ( var j = tbody.length - 1; j >= 0 ; --j )
  809. if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length )
  810. tbody[ j ].parentNode.removeChild( tbody[ j ] );
  811. // IE completely kills leading whitespace when innerHTML is used
  812. if ( /^\s/.test( elem ) )
  813. div.insertBefore( context.createTextNode( elem.match(/^\s*/)[0] ), div.firstChild );
  814. }
  815. elem = jQuery.makeArray( div.childNodes );
  816. }
  817. if ( elem.length === 0 && (!jQuery.nodeName( elem, "form" ) && !jQuery.nodeName( elem, "select" )) )
  818. return;
  819. if ( elem[0] == undefined || jQuery.nodeName( elem, "form" ) || elem.options )
  820. ret.push( elem );
  821. else
  822. ret = jQuery.merge( ret, elem );
  823. });
  824. return ret;
  825. },
  826. attr: function( elem, name, value ) {
  827. // don't set attributes on text and comment nodes
  828. if (!elem || elem.nodeType == 3 || elem.nodeType == 8)
  829. return undefined;
  830. var fix = jQuery.isXMLDoc( elem ) ?
  831. {} :
  832. jQuery.props;
  833. // Safari mis-reports the default selected property of a hidden option
  834. // Accessing the parent's selectedIndex property fixes it
  835. if ( name == "selected" && jQuery.browser.safari )
  836. elem.parentNode.selectedIndex;
  837. // Certain attributes only work when accessed via the old DOM 0 way
  838. if ( fix[ name ] ) {
  839. if ( value != undefined )
  840. elem[ fix[ name ] ] = value;
  841. return elem[ fix[ name ] ];
  842. } else if ( jQuery.browser.msie && name == "style" )
  843. return jQuery.attr( elem.style, "cssText", value );
  844. else if ( value == undefined && jQuery.browser.msie && jQuery.nodeName( elem, "form" ) && (name == "action" || name == "method") )
  845. return elem.getAttributeNode( name ).nodeValue;
  846. // IE elem.getAttribute passes even for style
  847. else if ( elem.tagName ) {
  848. if ( value != undefined ) {
  849. // We can't allow the type property to be changed (since it causes problems in IE)
  850. if ( name == "type" && jQuery.nodeName( elem, "input" ) && elem.parentNode )
  851. throw "type property can't be changed";
  852. // convert the value to a string (all browsers do this but IE) see #1070
  853. elem.setAttribute( name, "" + value );
  854. }
  855. if ( jQuery.browser.msie && /href|src/.test( name ) && !jQuery.isXMLDoc( elem ) )
  856. return elem.getAttribute( name, 2 );
  857. return elem.getAttribute( name );
  858. // elem is actually elem.style ... set the style
  859. } else {
  860. // IE actually uses filters for opacity
  861. if ( name == "opacity" && jQuery.browser.msie ) {
  862. if ( value != undefined ) {
  863. // IE has trouble with opacity if it does not have layout
  864. // Force it by setting the zoom level
  865. elem.zoom = 1;
  866. // Set the alpha filter to set the opacity
  867. elem.filter = (elem.filter || "").replace( /alpha\([^)]*\)/, "" ) +
  868. (parseFloat( value ).toString() == "NaN" ? "" : "alpha(opacity=" + value * 100 + ")");
  869. }
  870. return elem.filter && elem.filter.indexOf("opacity=") >= 0 ?
  871. (parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100).toString() :
  872. "";
  873. }
  874. name = name.replace(/-([a-z])/ig, function(all, letter){
  875. return letter.toUpperCase();
  876. });
  877. if ( value != undefined )
  878. elem[ name ] = value;
  879. return elem[ name ];
  880. }
  881. },
  882. trim: function( text ) {
  883. return (text || "").replace( /^\s+|\s+$/g, "" );
  884. },
  885. makeArray: function( array ) {
  886. var ret = [];
  887. // Need to use typeof to fight Safari childNodes crashes
  888. if ( typeof array != "array" )
  889. for ( var i = 0, length = array.length; i < length; i++ )
  890. ret.push( array[ i ] );
  891. else
  892. ret = array.slice( 0 );
  893. return ret;
  894. },
  895. inArray: function( elem, array ) {
  896. for ( var i = 0, length = array.length; i < length; i++ )
  897. if ( array[ i ] == elem )
  898. return i;
  899. return -1;
  900. },
  901. merge: function( first, second ) {
  902. // We have to loop this way because IE & Opera overwrite the length
  903. // expando of getElementsByTagName
  904. // Also, we need to make sure that the correct elements are being returned
  905. // (IE returns comment nodes in a '*' query)
  906. if ( jQuery.browser.msie ) {
  907. for ( var i = 0; second[ i ]; i++ )
  908. if ( second[ i ].nodeType != 8 )
  909. first.push( second[ i ] );
  910. } else
  911. for ( var i = 0; second[ i ]; i++ )
  912. first.push( second[ i ] );
  913. return first;
  914. },
  915. unique: function( array ) {
  916. var ret = [], done = {};
  917. try {
  918. for ( var i = 0, length = array.length; i < length; i++ ) {
  919. var id = jQuery.data( array[ i ] );
  920. if ( !done[ id ] ) {
  921. done[ id ] = true;
  922. ret.push( array[ i ] );
  923. }
  924. }
  925. } catch( e ) {
  926. ret = array;
  927. }
  928. return ret;
  929. },
  930. grep: function( elems, callback, inv ) {
  931. var ret = [];
  932. // Go through the array, only saving the items
  933. // that pass the validator function
  934. for ( var i = 0, length = elems.length; i < length; i++ )
  935. if ( !inv && callback( elems[ i ], i ) || inv && !callback( elems[ i ], i ) )
  936. ret.push( elems[ i ] );
  937. return ret;
  938. },
  939. map: function( elems, callback ) {
  940. var ret = [];
  941. // Go through the array, translating each of the items to their
  942. // new value (or values).
  943. for ( var i = 0, length = elems.length; i < length; i++ ) {
  944. var value = callback( elems[ i ], i );
  945. if ( value !== null && value != undefined ) {
  946. if ( value.constructor != Array )
  947. value = [ value ];
  948. ret = ret.concat( value );
  949. }
  950. }
  951. return ret;
  952. }
  953. });
  954. var userAgent = navigator.userAgent.toLowerCase();
  955. // Figure out what browser is being used
  956. jQuery.browser = {
  957. version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1],
  958. safari: /webkit/.test( userAgent ),
  959. opera: /opera/.test( userAgent ),
  960. msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),
  961. mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent )
  962. };
  963. var styleFloat = jQuery.browser.msie ?
  964. "styleFloat" :
  965. "cssFloat";
  966. jQuery.extend({
  967. // Check to see if the W3C box model is being used
  968. boxModel: !jQuery.browser.msie || document.compatMode == "CSS1Compat",
  969. props: {
  970. "for": "htmlFor",
  971. "class": "className",
  972. "float": styleFloat,
  973. cssFloat: styleFloat,
  974. styleFloat: styleFloat,
  975. innerHTML: "innerHTML",
  976. className: "className",
  977. value: "value",
  978. disabled: "disabled",
  979. checked: "checked",
  980. readonly: "readOnly",
  981. selected: "selected",
  982. maxlength: "maxLength",
  983. selectedIndex: "selectedIndex",
  984. defaultValue: "defaultValue",
  985. tagName: "tagName",
  986. nodeName: "nodeName"
  987. }
  988. });
  989. jQuery.each({
  990. parent: function(elem){return elem.parentNode;},
  991. parents: function(elem){return jQuery.dir(elem,"parentNode");},
  992. next: function(elem){return jQuery.nth(elem,2,"nextSibling");},
  993. prev: function(elem){return jQuery.nth(elem,2,"previousSibling");},
  994. nextAll: function(elem){return jQuery.dir(elem,"nextSibling");},
  995. prevAll: function(elem){return jQuery.dir(elem,"previousSibling");},
  996. siblings: function(elem){return jQuery.sibling(elem.parentNode.firstChild,elem);},
  997. children: function(elem){return jQuery.sibling(elem.firstChild);},
  998. contents: function(elem){return jQuery.nodeName(elem,"iframe")?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes);}
  999. }, function(name, fn){
  1000. jQuery.fn[ name ] = function( selector ) {
  1001. var ret = jQuery.map( this, fn );
  1002. if ( selector && typeof selector == "string" )
  1003. ret = jQuery.multiFilter( selector, ret );
  1004. return this.pushStack( jQuery.unique( ret ) );
  1005. };
  1006. });
  1007. jQuery.each({
  1008. appendTo: "append",
  1009. prependTo: "prepend",
  1010. insertBefore: "before",
  1011. insertAfter: "after",
  1012. replaceAll: "replaceWith"
  1013. }, function(name, original){
  1014. jQuery.fn[ name ] = function() {
  1015. var args = arguments;
  1016. return this.each(function(){
  1017. for ( var i = 0, length = args.length; i < length; i++ )
  1018. jQuery( args[ i ] )[ original ]( this );
  1019. });
  1020. };
  1021. });
  1022. jQuery.each({
  1023. removeAttr: function( name ) {
  1024. jQuery.attr( this, name, "" );
  1025. if (this.nodeType == 1)
  1026. this.removeAttribute( name );
  1027. },
  1028. addClass: function( classNames ) {
  1029. jQuery.className.add( this, classNames );
  1030. },
  1031. removeClass: function( classNames ) {
  1032. jQuery.className.remove( this, classNames );
  1033. },
  1034. toggleClass: function( classNames ) {
  1035. jQuery.className[ jQuery.className.has( this, classNames ) ? "remove" : "add" ]( this, classNames );
  1036. },
  1037. remove: function( selector ) {
  1038. if ( !selector || jQuery.filter( selector, [ this ] ).r.length ) {
  1039. // Prevent memory leaks
  1040. jQuery( "*", this ).add(this).each(function(){
  1041. jQuery.event.remove(this);
  1042. jQuery.removeData(this);
  1043. });
  1044. if (this.parentNode)
  1045. this.parentNode.removeChild( this );
  1046. }
  1047. },
  1048. empty: function() {
  1049. // Remove element nodes and prevent memory leaks
  1050. jQuery( ">*", this ).remove();
  1051. // Remove any remaining nodes
  1052. while ( this.firstChild )
  1053. this.removeChild( this.firstChild );
  1054. }
  1055. }, function(name, fn){
  1056. jQuery.fn[ name ] = function(){
  1057. return this.each( fn, arguments );
  1058. };
  1059. });
  1060. jQuery.each([ "Height", "Width" ], function(i, name){
  1061. var type = name.toLowerCase();
  1062. jQuery.fn[ type ] = function( size ) {
  1063. // Get window width or height
  1064. return this[0] == window ?
  1065. // Opera reports document.body.client[Width/Height] properly in both quirks and standards
  1066. jQuery.browser.opera && document.body[ "client" + name ] ||
  1067. // Safari reports inner[Width/Height] just fine (Mozilla and Opera include scroll bar widths)
  1068. jQuery.browser.safari && window[ "inner" + name ] ||
  1069. // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
  1070. document.compatMode == "CSS1Compat" && document.documentElement[ "client" + name ] || document.body[ "client" + name ] :
  1071. // Get document width or height
  1072. this[0] == document ?
  1073. // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
  1074. Math.max(
  1075. Math.max(document.body["scroll" + name], document.documentElement["scroll" + name]),
  1076. Math.max(document.body["offset" + name], document.documentElement["offset" + name])
  1077. ) :
  1078. // Get or set width or height on the element
  1079. size == undefined ?
  1080. // Get width or height on the element
  1081. (this.length ? jQuery.css( this[0], type ) : null) :
  1082. // Set the width or height on the element (default to pixels if value is unitless)
  1083. this.css( type, size.constructor == String ? size : size + "px" );
  1084. };
  1085. });
  1086. var chars = jQuery.browser.safari && parseInt(jQuery.browser.version) < 417 ?
  1087. "(?:[\\w*_-]|\\\\.)" :
  1088. "(?:[\\w\u0128-\uFFFF*_-]|\\\\.)",
  1089. quickChild = new RegExp("^>\\s*(" + chars + "+)"),
  1090. quickID = new RegExp("^(" + chars + "+)(#)(" + chars + "+)"),
  1091. quickClass = new RegExp("^([#.]?)(" + chars + "*)");
  1092. jQuery.extend({
  1093. expr: {
  1094. "": function(a,i,m){return m[2]=="*"||jQuery.nodeName(a,m[2]);},
  1095. "#": function(a,i,m){return a.getAttribute("id")==m[2];},
  1096. ":": {
  1097. // Position Checks
  1098. lt: function(a,i,m){return i<m[3]-0;},
  1099. gt: function(a,i,m){return i>m[3]-0;},
  1100. nth: function(a,i,m){return m[3]-0==i;},
  1101. eq: function(a,i,m){return m[3]-0==i;},
  1102. first: function(a,i){return i==0;},
  1103. last: function(a,i,m,r){return i==r.length-1;},
  1104. even: function(a,i){return i%2==0;},
  1105. odd: function(a,i){return i%2;},
  1106. // Child Checks
  1107. "first-child": function(a){return a.parentNode.getElementsByTagName("*")[0]==a;},
  1108. "last-child": function(a){return jQuery.nth(a.parentNode.lastChild,1,"previousSibling")==a;},
  1109. "only-child": function(a){return !jQuery.nth(a.parentNode.lastChild,2,"previousSibling");},
  1110. // Parent Checks
  1111. parent: function(a){return a.firstChild;},
  1112. empty: function(a){return !a.firstChild;},
  1113. // Text Check
  1114. contains: function(a,i,m){return (a.textContent||a.innerText||jQuery(a).text()||"").indexOf(m[3])>=0;},
  1115. // Visibility
  1116. visible: function(a){return "hidden"!=a.type&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden";},
  1117. hidden: function(a){return "hidden"==a.type||jQuery.css(a,"display")=="none"||jQuery.css(a,"visibility")=="hidden";},
  1118. // Form attributes
  1119. enabled: function(a){return !a.disabled;},
  1120. disabled: function(a){return a.disabled;},
  1121. checked: function(a){return a.checked;},
  1122. selected: function(a){return a.selected||jQuery.attr(a,"selected");},
  1123. // Form elements
  1124. text: function(a){return "text"==a.type;},
  1125. radio: function(a){return "radio"==a.type;},
  1126. checkbox: function(a){return "checkbox"==a.type;},
  1127. file: function(a){return "file"==a.type;},
  1128. password: function(a){return "password"==a.type;},
  1129. submit: function(a){return "submit"==a.type;},
  1130. image: function(a){return "image"==a.type;},
  1131. reset: function(a){return "reset"==a.type;},
  1132. button: function(a){return "button"==a.type||jQuery.nodeName(a,"button");},
  1133. input: function(a){return /input|select|textarea|button/i.test(a.nodeName);},
  1134. // :has()
  1135. has: function(a,i,m){return jQuery.find(m[3],a).length;},
  1136. // :header
  1137. header: function(a){return /h\d/i.test(a.nodeName);},
  1138. // :animated
  1139. animated: function(a){return jQuery.grep(jQuery.timers,function(fn){return a==fn.elem;}).length;}
  1140. }
  1141. },
  1142. // The regular expressions that power the parsing engine
  1143. parse: [
  1144. // Match: [@value='test'], [@foo]
  1145. /^(\[) *@?([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/,
  1146. // Match: :contains('foo')
  1147. /^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/,
  1148. // Match: :even, :last-chlid, #id, .class
  1149. new RegExp("^([:.#]*)(" + chars + "+)")
  1150. ],
  1151. multiFilter: function( expr, elems, not ) {
  1152. var old, cur = [];
  1153. while ( expr && expr != old ) {
  1154. old = expr;
  1155. var f = jQuery.filter( expr, elems, not );
  1156. expr = f.t.replace(/^\s*,\s*/, "" );
  1157. cur = not ? elems = f.r : jQuery.merge( cur, f.r );
  1158. }
  1159. return cur;
  1160. },
  1161. find: function( t, context ) {
  1162. // Quickly handle non-string expressions
  1163. if ( typeof t != "string" )
  1164. return [ t ];
  1165. // check to make sure context is a DOM element or a document
  1166. if ( context && context.nodeType != 1 && context.nodeType != 9)
  1167. return [ ];
  1168. // Set the correct context (if none is provided)
  1169. context = context || document;
  1170. // Initialize the search
  1171. var ret = [context], done = [], last, nodeName;
  1172. // Continue while a selector expression exists, and while
  1173. // we're no longer looping upon ourselves
  1174. while ( t && last != t ) {
  1175. var r = [];
  1176. last = t;
  1177. t = jQuery.trim(t);
  1178. var foundToken = false;
  1179. // An attempt at speeding up child selectors that
  1180. // point to a specific element tag
  1181. var re = quickChild;
  1182. var m = re.exec(t);
  1183. if ( m ) {
  1184. nodeName = m[1].toUpperCase();
  1185. // Perform our own iteration and filter
  1186. for ( var i = 0; ret[i]; i++ )
  1187. for ( var c = ret[i].firstChild; c; c = c.nextSibling )
  1188. if ( c.nodeType == 1 && (nodeName == "*" || c.nodeName.toUpperCase() == nodeName) )
  1189. r.push( c );
  1190. ret = r;
  1191. t = t.replace( re, "" );
  1192. if ( t.indexOf(" ") == 0 ) continue;
  1193. foundToken = true;
  1194. } else {
  1195. re = /^([>+~])\s*(\w*)/i;
  1196. if ( (m = re.exec(t)) != null ) {
  1197. r = [];
  1198. var merge = {};
  1199. nodeName = m[2].toUpperCase();
  1200. m = m[1];
  1201. for ( var j = 0, rl = ret.length; j < rl; j++ ) {
  1202. var n = m == "~" || m == "+" ? ret[j].nextSibling : ret[j].firstChild;
  1203. for ( ; n; n = n.nextSibling )
  1204. if ( n.nodeType == 1 ) {
  1205. var id = jQuery.data(n);
  1206. if ( m == "~" && merge[id] ) break;
  1207. if (!nodeName || n.nodeName.toUpperCase() == nodeName ) {
  1208. if ( m == "~" ) merge[id] = true;
  1209. r.push( n );
  1210. }
  1211. if ( m == "+" ) break;
  1212. }
  1213. }
  1214. ret = r;
  1215. // And remove the token
  1216. t = jQuery.trim( t.replace( re, "" ) );
  1217. foundToken = true;
  1218. }
  1219. }
  1220. // See if there's still an expression, and that we haven't already
  1221. // matched a token
  1222. if ( t && !foundToken ) {
  1223. // Handle multiple expressions
  1224. if ( !t.indexOf(",") ) {
  1225. // Clean the result set
  1226. if ( context == ret[0] ) ret.shift();
  1227. // Merge the result sets
  1228. done = jQuery.merge( done, ret );
  1229. // Reset the context
  1230. r = ret = [context];
  1231. // Touch up the selector string
  1232. t = " " + t.substr(1,t.length);
  1233. } else {
  1234. // Optimize for the case nodeName#idName
  1235. var re2 = quickID;
  1236. var m = re2.exec(t);
  1237. // Re-organize the results, so that they're consistent
  1238. if ( m ) {
  1239. m = [ 0, m[2], m[3], m[1] ];
  1240. } else {
  1241. // Otherwise, do a traditional filter check for
  1242. // ID, class, and element selectors
  1243. re2 = quickClass;
  1244. m = re2.exec(t);
  1245. }
  1246. m[2] = m[2].replace(/\\/g, "");
  1247. var elem = ret[ret.length-1];
  1248. // Try to do a global search by ID, where we can
  1249. if ( m[1] == "#" && elem && elem.getElementById && !jQuery.isXMLDoc(elem) ) {
  1250. // Optimization for HTML document case
  1251. var oid = elem.getElementById(m[2]);
  1252. // Do a quick check for the existence of the actual ID attribute
  1253. // to avoid selecting by the name attribute in IE
  1254. // also check to insure id is a string to avoid selecting an element with the name of 'id' inside a form
  1255. if ( (jQuery.browser.msie||jQuery.browser.opera) && oid && typeof oid.id == "string" && oid.id != m[2] )
  1256. oid = jQuery('[@id="'+m[2]+'"]', elem)[0];
  1257. // Do a quick check for node name (where applicable) so
  1258. // that div#foo searches will be really fast
  1259. ret = r = oid && (!m[3] || jQuery.nodeName(oid, m[3])) ? [oid] : [];
  1260. } else {
  1261. // We need to find all descendant elements
  1262. for ( var i = 0; ret[i]; i++ ) {
  1263. // Grab the tag name being searched for
  1264. var tag = m[1] == "#" && m[3] ? m[3] : m[1] != "" || m[0] == "" ? "*" : m[2];
  1265. // Handle IE7 being really dumb about <object>s
  1266. if ( tag == "*" && ret[i].nodeName.toLowerCase() == "object" )
  1267. tag = "param";
  1268. r = jQuery.merge( r, ret[i].getElementsByTagName( tag ));
  1269. }
  1270. // It's faster to filter by class and be done with it
  1271. if ( m[1] == "." )
  1272. r = jQuery.classFilter( r, m[2] );
  1273. // Same with ID filtering
  1274. if ( m[1] == "#" ) {
  1275. var tmp = [];
  1276. // Try to find the element with the ID
  1277. for ( var i = 0; r[i]; i++ )
  1278. if ( r[i].getAttribute("id") == m[2] ) {
  1279. tmp = [ r[i] ];
  1280. break;
  1281. }
  1282. r = tmp;
  1283. }
  1284. ret = r;
  1285. }
  1286. t = t.replace( re2, "" );
  1287. }
  1288. }
  1289. // If a selector string still exists
  1290. if ( t ) {
  1291. // Attempt to filter it
  1292. var val = jQuery.filter(t,r);
  1293. ret = r = val.r;
  1294. t = jQuery.trim(val.t);
  1295. }
  1296. }
  1297. // An error occurred with the selector;
  1298. // just return an empty set instead
  1299. if ( t )
  1300. ret = [];
  1301. // Remove the root context
  1302. if ( ret && context == ret[0] )
  1303. ret.shift();
  1304. // And combine the results
  1305. done = jQuery.merge( done, ret );
  1306. return done;
  1307. },
  1308. classFilter: function(r,m,not){
  1309. m = " " + m + " ";
  1310. var tmp = [];
  1311. for ( var i = 0; r[i]; i++ ) {
  1312. var pass = (" " + r[i].className + " ").indexOf( m ) >= 0;
  1313. if ( !not && pass || not && !pass )
  1314. tmp.push( r[i] );
  1315. }
  1316. return tmp;
  1317. },
  1318. filter: function(t,r,not) {
  1319. var last;
  1320. // Look for common filter expressions
  1321. while ( t && t != last ) {
  1322. last = t;
  1323. var p = jQuery.parse, m;
  1324. for ( var i = 0; p[i]; i++ ) {
  1325. m = p[i].exec( t );
  1326. if ( m ) {
  1327. // Remove what we just matched
  1328. t = t.substring( m[0].length );
  1329. m[2] = m[2].replace(/\\/g, "");
  1330. break;
  1331. }
  1332. }
  1333. if ( !m )
  1334. break;
  1335. // :not() is a special case that can be optimized by
  1336. // keeping it out of the expression list
  1337. if ( m[1] == ":" && m[2] == "not" )
  1338. // optimize if only one selector found (most common case)
  1339. r = isSimple.test( m[3] ) ?
  1340. jQuery.filter(m[3], r, true).r :
  1341. jQuery( r ).not( m[3] );
  1342. // We can get a big speed boost by filtering by class here
  1343. else if ( m[1] == "." )
  1344. r = jQuery.classFilter(r, m[2], not);
  1345. else if ( m[1] == "[" ) {
  1346. var tmp = [], type = m[3];
  1347. for ( var i = 0, rl = r.length; i < rl; i++ ) {
  1348. var a = r[i], z = a[ jQuery.props[m[2]] || m[2] ];
  1349. if ( z == null || /href|src|selected/.test(m[2]) )
  1350. z = jQuery.attr(a,m[2]) || '';
  1351. if ( (type == "" && !!z ||
  1352. type == "=" && z == m[5] ||
  1353. type == "!=" && z != m[5] ||
  1354. type == "^=" && z && !z.indexOf(m[5]) ||
  1355. type == "$=" && z.substr(z.length - m[5].length) == m[5] ||
  1356. (type == "*=" || type == "~=") && z.indexOf(m[5]) >= 0) ^ not )
  1357. tmp.push( a );
  1358. }
  1359. r = tmp;
  1360. // We can get a speed boost by handling nth-child here
  1361. } else if ( m[1] == ":" && m[2] == "nth-child" ) {
  1362. var merge = {}, tmp = [],
  1363. // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
  1364. test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
  1365. m[3] == "even" && "2n" || m[3] == "odd" && "2n+1" ||
  1366. !/\D/.test(m[3]) && "0n+" + m[3] || m[3]),
  1367. // calculate the numbers (first)n+(last) including if they are negative
  1368. first = (test[1] + (test[2] || 1)) - 0, last = test[3] - 0;
  1369. // loop through all the elements left in the jQuery object
  1370. for ( var i = 0, rl = r.length; i < rl; i++ ) {
  1371. var node = r[i], parentNode = node.parentNode, id = jQuery.data(parentNode);
  1372. if ( !merge[id] ) {
  1373. var c = 1;
  1374. for ( var n = parentNode.firstChild; n; n = n.nextSibling )
  1375. if ( n.nodeType == 1 )
  1376. n.nodeIndex = c++;
  1377. merge[id] = true;
  1378. }
  1379. var add = false;
  1380. if ( first == 0 ) {
  1381. if ( node.nodeIndex == last )
  1382. add = true;
  1383. } else if ( (node.nodeIndex - last) % first == 0 && (node.nodeIndex - last) / first >= 0 )
  1384. add = true;
  1385. if ( add ^ not )
  1386. tmp.push( node );
  1387. }
  1388. r = tmp;
  1389. // Otherwise, find the expression to execute
  1390. } else {
  1391. var fn = jQuery.expr[ m[1] ];
  1392. if ( typeof fn == "object" )
  1393. fn = fn[ m[2] ];
  1394. if ( typeof fn == "string" )
  1395. fn = eval("false||function(a,i){return " + fn + ";}");
  1396. // Execute it against the current filter
  1397. r = jQuery.grep( r, function(elem, i){

Large files files are truncated, but you can click here to view the full file