PageRenderTime 100ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 1ms

/libs/jquery/1.3.0/jquery.js

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