PageRenderTime 66ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 1ms

/EShopCms/WebRoot/jQuery/jquery-latest.js

http://jeshop.googlecode.com/
JavaScript | 2245 lines | 1501 code | 387 blank | 357 comment | 596 complexity | 45e03a05f9be02c75770c2ab566a5238 MD5 | raw file
Possible License(s): Apache-2.0, BSD-3-Clause, LGPL-2.1

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

  1. /* prevent execution of jQuery if included more than once */
  2. if(typeof window.jQuery == "undefined") {
  3. /*
  4. * jQuery 1.1.2 - New Wave Javascript
  5. *
  6. * Copyright (c) 2007 John Resig (jquery.com)
  7. * Dual licensed under the MIT (MIT-LICENSE.txt)
  8. * and GPL (GPL-LICENSE.txt) licenses.
  9. *
  10. * $Date: 2009/11/30 14:05:16 $
  11. * $Rev: 1465 $
  12. */
  13. // Global undefined variable
  14. window.undefined = window.undefined;
  15. var jQuery = function(a,c) {
  16. // If the context is global, return a new object
  17. if ( window == this )
  18. return new jQuery(a,c);
  19. // Make sure that a selection was provided
  20. a = a || document;
  21. // HANDLE: $(function)
  22. // Shortcut for document ready
  23. if ( jQuery.isFunction(a) )
  24. return new jQuery(document)[ jQuery.fn.ready ? "ready" : "load" ]( a );
  25. // Handle HTML strings
  26. if ( typeof a == "string" ) {
  27. // HANDLE: $(html) -> $(array)
  28. var m = /^[^<]*(<(.|\s)+>)[^>]*$/.exec(a);
  29. if ( m )
  30. a = jQuery.clean( [ m[1] ] );
  31. // HANDLE: $(expr)
  32. else
  33. return new jQuery( c ).find( a );
  34. }
  35. return this.setArray(
  36. // HANDLE: $(array)
  37. a.constructor == Array && a ||
  38. // HANDLE: $(arraylike)
  39. // Watch for when an array-like object is passed as the selector
  40. (a.jquery || a.length && a != window && !a.nodeType && a[0] != undefined && a[0].nodeType) && jQuery.makeArray( a ) ||
  41. // HANDLE: $(*)
  42. [ a ] );
  43. };
  44. // Map over the $ in case of overwrite
  45. if ( typeof $ != "undefined" )
  46. jQuery._$ = $;
  47. // Map the jQuery namespace to the '$' one
  48. var $ = jQuery;
  49. jQuery.fn = jQuery.prototype = {
  50. jquery: "1.1.2",
  51. size: function() {
  52. return this.length;
  53. },
  54. length: 0,
  55. get: function( num ) {
  56. return num == undefined ?
  57. // Return a 'clean' array
  58. jQuery.makeArray( this ) :
  59. // Return just the object
  60. this[num];
  61. },
  62. pushStack: function( a ) {
  63. var ret = jQuery(a);
  64. ret.prevObject = this;
  65. return ret;
  66. },
  67. setArray: function( a ) {
  68. this.length = 0;
  69. [].push.apply( this, a );
  70. return this;
  71. },
  72. each: function( fn, args ) {
  73. return jQuery.each( this, fn, args );
  74. },
  75. index: function( obj ) {
  76. var pos = -1;
  77. this.each(function(i){
  78. if ( this == obj ) pos = i;
  79. });
  80. return pos;
  81. },
  82. attr: function( key, value, type ) {
  83. var obj = key;
  84. // Look for the case where we're accessing a style value
  85. if ( key.constructor == String )
  86. if ( value == undefined )
  87. return this.length && jQuery[ type || "attr" ]( this[0], key ) || undefined;
  88. else {
  89. obj = {};
  90. obj[ key ] = value;
  91. }
  92. // Check to see if we're setting style values
  93. return this.each(function(index){
  94. // Set all the styles
  95. for ( var prop in obj )
  96. jQuery.attr(
  97. type ? this.style : this,
  98. prop, jQuery.prop(this, obj[prop], type, index, prop)
  99. );
  100. });
  101. },
  102. css: function( key, value ) {
  103. return this.attr( key, value, "curCSS" );
  104. },
  105. text: function(e) {
  106. if ( typeof e == "string" )
  107. return this.empty().append( document.createTextNode( e ) );
  108. var t = "";
  109. jQuery.each( e || this, function(){
  110. jQuery.each( this.childNodes, function(){
  111. if ( this.nodeType != 8 )
  112. t += this.nodeType != 1 ?
  113. this.nodeValue : jQuery.fn.text([ this ]);
  114. });
  115. });
  116. return t;
  117. },
  118. wrap: function() {
  119. // The elements to wrap the target around
  120. var a = jQuery.clean(arguments);
  121. // Wrap each of the matched elements individually
  122. return this.each(function(){
  123. // Clone the structure that we're using to wrap
  124. var b = a[0].cloneNode(true);
  125. // Insert it before the element to be wrapped
  126. this.parentNode.insertBefore( b, this );
  127. // Find the deepest point in the wrap structure
  128. while ( b.firstChild )
  129. b = b.firstChild;
  130. // Move the matched element to within the wrap structure
  131. b.appendChild( this );
  132. });
  133. },
  134. append: function() {
  135. return this.domManip(arguments, true, 1, function(a){
  136. this.appendChild( a );
  137. });
  138. },
  139. prepend: function() {
  140. return this.domManip(arguments, true, -1, function(a){
  141. this.insertBefore( a, this.firstChild );
  142. });
  143. },
  144. before: function() {
  145. return this.domManip(arguments, false, 1, function(a){
  146. this.parentNode.insertBefore( a, this );
  147. });
  148. },
  149. after: function() {
  150. return this.domManip(arguments, false, -1, function(a){
  151. this.parentNode.insertBefore( a, this.nextSibling );
  152. });
  153. },
  154. end: function() {
  155. return this.prevObject || jQuery([]);
  156. },
  157. find: function(t) {
  158. return this.pushStack( jQuery.map( this, function(a){
  159. return jQuery.find(t,a);
  160. }), t );
  161. },
  162. clone: function(deep) {
  163. return this.pushStack( jQuery.map( this, function(a){
  164. var a = a.cloneNode( deep != undefined ? deep : true );
  165. a.$events = null; // drop $events expando to avoid firing incorrect events
  166. return a;
  167. }) );
  168. },
  169. filter: function(t) {
  170. return this.pushStack(
  171. jQuery.isFunction( t ) &&
  172. jQuery.grep(this, function(el, index){
  173. return t.apply(el, [index])
  174. }) ||
  175. jQuery.multiFilter(t,this) );
  176. },
  177. not: function(t) {
  178. return this.pushStack(
  179. t.constructor == String &&
  180. jQuery.multiFilter(t, this, true) ||
  181. jQuery.grep(this, function(a) {
  182. return ( t.constructor == Array || t.jquery )
  183. ? jQuery.inArray( a, t ) < 0
  184. : a != t;
  185. })
  186. );
  187. },
  188. add: function(t) {
  189. return this.pushStack( jQuery.merge(
  190. this.get(),
  191. t.constructor == String ?
  192. jQuery(t).get() :
  193. t.length != undefined && (!t.nodeName || t.nodeName == "FORM") ?
  194. t : [t] )
  195. );
  196. },
  197. is: function(expr) {
  198. return expr ? jQuery.filter(expr,this).r.length > 0 : false;
  199. },
  200. val: function( val ) {
  201. return val == undefined ?
  202. ( this.length ? this[0].value : null ) :
  203. this.attr( "value", val );
  204. },
  205. html: function( val ) {
  206. return val == undefined ?
  207. ( this.length ? this[0].innerHTML : null ) :
  208. this.empty().append( val );
  209. },
  210. domManip: function(args, table, dir, fn){
  211. var clone = this.length > 1;
  212. var a = jQuery.clean(args);
  213. if ( dir < 0 )
  214. a.reverse();
  215. return this.each(function(){
  216. var obj = this;
  217. if ( table && jQuery.nodeName(this, "table") && jQuery.nodeName(a[0], "tr") )
  218. obj = this.getElementsByTagName("tbody")[0] || this.appendChild(document.createElement("tbody"));
  219. jQuery.each( a, function(){
  220. fn.apply( obj, [ clone ? this.cloneNode(true) : this ] );
  221. });
  222. });
  223. }
  224. };
  225. jQuery.extend = jQuery.fn.extend = function() {
  226. // copy reference to target object
  227. var target = arguments[0],
  228. a = 1;
  229. // extend jQuery itself if only one argument is passed
  230. if ( arguments.length == 1 ) {
  231. target = this;
  232. a = 0;
  233. }
  234. var prop;
  235. while (prop = arguments[a++])
  236. // Extend the base object
  237. for ( var i in prop ) target[i] = prop[i];
  238. // Return the modified object
  239. return target;
  240. };
  241. jQuery.extend({
  242. noConflict: function() {
  243. if ( jQuery._$ )
  244. $ = jQuery._$;
  245. return jQuery;
  246. },
  247. // This may seem like some crazy code, but trust me when I say that this
  248. // is the only cross-browser way to do this. --John
  249. isFunction: function( fn ) {
  250. return !!fn && typeof fn != "string" && !fn.nodeName &&
  251. typeof fn[0] == "undefined" && /function/i.test( fn + "" );
  252. },
  253. // check if an element is in a XML document
  254. isXMLDoc: function(elem) {
  255. return elem.tagName && elem.ownerDocument && !elem.ownerDocument.body;
  256. },
  257. nodeName: function( elem, name ) {
  258. return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase();
  259. },
  260. // args is for internal usage only
  261. each: function( obj, fn, args ) {
  262. if ( obj.length == undefined )
  263. for ( var i in obj )
  264. fn.apply( obj[i], args || [i, obj[i]] );
  265. else
  266. for ( var i = 0, ol = obj.length; i < ol; i++ )
  267. if ( fn.apply( obj[i], args || [i, obj[i]] ) === false ) break;
  268. return obj;
  269. },
  270. prop: function(elem, value, type, index, prop){
  271. // Handle executable functions
  272. if ( jQuery.isFunction( value ) )
  273. value = value.call( elem, [index] );
  274. // exclude the following css properties to add px
  275. var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i;
  276. // Handle passing in a number to a CSS property
  277. return value && value.constructor == Number && type == "curCSS" && !exclude.test(prop) ?
  278. value + "px" :
  279. value;
  280. },
  281. className: {
  282. // internal only, use addClass("class")
  283. add: function( elem, c ){
  284. jQuery.each( c.split(/\s+/), function(i, cur){
  285. if ( !jQuery.className.has( elem.className, cur ) )
  286. elem.className += ( elem.className ? " " : "" ) + cur;
  287. });
  288. },
  289. // internal only, use removeClass("class")
  290. remove: function( elem, c ){
  291. elem.className = c ?
  292. jQuery.grep( elem.className.split(/\s+/), function(cur){
  293. return !jQuery.className.has( c, cur );
  294. }).join(" ") : "";
  295. },
  296. // internal only, use is(".class")
  297. has: function( t, c ) {
  298. t = t.className || t;
  299. // escape regex characters
  300. c = c.replace(/([\.\\\+\*\?\[\^\]\$\(\)\{\}\=\!\<\>\|\:])/g, "\\$1");
  301. return t && new RegExp("(^|\\s)" + c + "(\\s|$)").test( t );
  302. }
  303. },
  304. swap: function(e,o,f) {
  305. for ( var i in o ) {
  306. e.style["old"+i] = e.style[i];
  307. e.style[i] = o[i];
  308. }
  309. f.apply( e, [] );
  310. for ( var i in o )
  311. e.style[i] = e.style["old"+i];
  312. },
  313. css: function(e,p) {
  314. if ( p == "height" || p == "width" ) {
  315. var old = {}, oHeight, oWidth, d = ["Top","Bottom","Right","Left"];
  316. jQuery.each( d, function(){
  317. old["padding" + this] = 0;
  318. old["border" + this + "Width"] = 0;
  319. });
  320. jQuery.swap( e, old, function() {
  321. if (jQuery.css(e,"display") != "none") {
  322. oHeight = e.offsetHeight;
  323. oWidth = e.offsetWidth;
  324. } else {
  325. e = jQuery(e.cloneNode(true))
  326. .find(":radio").removeAttr("checked").end()
  327. .css({
  328. visibility: "hidden", position: "absolute", display: "block", right: "0", left: "0"
  329. }).appendTo(e.parentNode)[0];
  330. var parPos = jQuery.css(e.parentNode,"position");
  331. if ( parPos == "" || parPos == "static" )
  332. e.parentNode.style.position = "relative";
  333. oHeight = e.clientHeight;
  334. oWidth = e.clientWidth;
  335. if ( parPos == "" || parPos == "static" )
  336. e.parentNode.style.position = "static";
  337. e.parentNode.removeChild(e);
  338. }
  339. });
  340. return p == "height" ? oHeight : oWidth;
  341. }
  342. return jQuery.curCSS( e, p );
  343. },
  344. curCSS: function(elem, prop, force) {
  345. var ret;
  346. if (prop == "opacity" && jQuery.browser.msie)
  347. return jQuery.attr(elem.style, "opacity");
  348. if (prop == "float" || prop == "cssFloat")
  349. prop = jQuery.browser.msie ? "styleFloat" : "cssFloat";
  350. if (!force && elem.style[prop])
  351. ret = elem.style[prop];
  352. else if (document.defaultView && document.defaultView.getComputedStyle) {
  353. if (prop == "cssFloat" || prop == "styleFloat")
  354. prop = "float";
  355. prop = prop.replace(/([A-Z])/g,"-$1").toLowerCase();
  356. var cur = document.defaultView.getComputedStyle(elem, null);
  357. if ( cur )
  358. ret = cur.getPropertyValue(prop);
  359. else if ( prop == "display" )
  360. ret = "none";
  361. else
  362. jQuery.swap(elem, { display: "block" }, function() {
  363. var c = document.defaultView.getComputedStyle(this, "");
  364. ret = c && c.getPropertyValue(prop) || "";
  365. });
  366. } else if (elem.currentStyle) {
  367. var newProp = prop.replace(/\-(\w)/g,function(m,c){return c.toUpperCase();});
  368. ret = elem.currentStyle[prop] || elem.currentStyle[newProp];
  369. }
  370. return ret;
  371. },
  372. clean: function(a) {
  373. var r = [];
  374. jQuery.each( a, function(i,arg){
  375. if ( !arg ) return;
  376. if ( arg.constructor == Number )
  377. arg = arg.toString();
  378. // Convert html string into DOM nodes
  379. if ( typeof arg == "string" ) {
  380. // Trim whitespace, otherwise indexOf won't work as expected
  381. var s = jQuery.trim(arg), div = document.createElement("div"), tb = [];
  382. var wrap =
  383. // option or optgroup
  384. !s.indexOf("<opt") &&
  385. [1, "<select>", "</select>"] ||
  386. (!s.indexOf("<thead") || !s.indexOf("<tbody") || !s.indexOf("<tfoot")) &&
  387. [1, "<table>", "</table>"] ||
  388. !s.indexOf("<tr") &&
  389. [2, "<table><tbody>", "</tbody></table>"] ||
  390. // <thead> matched above
  391. (!s.indexOf("<td") || !s.indexOf("<th")) &&
  392. [3, "<table><tbody><tr>", "</tr></tbody></table>"] ||
  393. [0,"",""];
  394. // Go to html and back, then peel off extra wrappers
  395. div.innerHTML = wrap[1] + s + wrap[2];
  396. // Move to the right depth
  397. while ( wrap[0]-- )
  398. div = div.firstChild;
  399. // Remove IE's autoinserted <tbody> from table fragments
  400. if ( jQuery.browser.msie ) {
  401. // String was a <table>, *may* have spurious <tbody>
  402. if ( !s.indexOf("<table") && s.indexOf("<tbody") < 0 )
  403. tb = div.firstChild && div.firstChild.childNodes;
  404. // String was a bare <thead> or <tfoot>
  405. else if ( wrap[1] == "<table>" && s.indexOf("<tbody") < 0 )
  406. tb = div.childNodes;
  407. for ( var n = tb.length-1; n >= 0 ; --n )
  408. if ( jQuery.nodeName(tb[n], "tbody") && !tb[n].childNodes.length )
  409. tb[n].parentNode.removeChild(tb[n]);
  410. }
  411. arg = [];
  412. for (var i=0, l=div.childNodes.length; i<l; i++)
  413. arg.push(div.childNodes[i]);
  414. }
  415. if ( arg.length === 0 && !jQuery.nodeName(arg, "form") )
  416. return;
  417. if ( arg[0] == undefined || jQuery.nodeName(arg, "form") )
  418. r.push( arg );
  419. else
  420. r = jQuery.merge( r, arg );
  421. });
  422. return r;
  423. },
  424. attr: function(elem, name, value){
  425. var fix = jQuery.isXMLDoc(elem) ? {} : {
  426. "for": "htmlFor",
  427. "class": "className",
  428. "float": jQuery.browser.msie ? "styleFloat" : "cssFloat",
  429. cssFloat: jQuery.browser.msie ? "styleFloat" : "cssFloat",
  430. innerHTML: "innerHTML",
  431. className: "className",
  432. value: "value",
  433. disabled: "disabled",
  434. checked: "checked",
  435. readonly: "readOnly",
  436. selected: "selected"
  437. };
  438. // IE actually uses filters for opacity ... elem is actually elem.style
  439. if ( name == "opacity" && jQuery.browser.msie && value != undefined ) {
  440. // IE has trouble with opacity if it does not have layout
  441. // Force it by setting the zoom level
  442. elem.zoom = 1;
  443. // Set the alpha filter to set the opacity
  444. return elem.filter = elem.filter.replace(/alpha\([^\)]*\)/gi,"") +
  445. ( value == 1 ? "" : "alpha(opacity=" + value * 100 + ")" );
  446. } else if ( name == "opacity" && jQuery.browser.msie )
  447. return elem.filter ?
  448. parseFloat( elem.filter.match(/alpha\(opacity=(.*)\)/)[1] ) / 100 : 1;
  449. // Mozilla doesn't play well with opacity 1
  450. if ( name == "opacity" && jQuery.browser.mozilla && value == 1 )
  451. value = 0.9999;
  452. // Certain attributes only work when accessed via the old DOM 0 way
  453. if ( fix[name] ) {
  454. if ( value != undefined ) elem[fix[name]] = value;
  455. return elem[fix[name]];
  456. } else if ( value == undefined && jQuery.browser.msie && jQuery.nodeName(elem, "form") && (name == "action" || name == "method") )
  457. return elem.getAttributeNode(name).nodeValue;
  458. // IE elem.getAttribute passes even for style
  459. else if ( elem.tagName ) {
  460. if ( value != undefined ) elem.setAttribute( name, value );
  461. if ( jQuery.browser.msie && /href|src/.test(name) && !jQuery.isXMLDoc(elem) )
  462. return elem.getAttribute( name, 2 );
  463. return elem.getAttribute( name );
  464. // elem is actually elem.style ... set the style
  465. } else {
  466. name = name.replace(/-([a-z])/ig,function(z,b){return b.toUpperCase();});
  467. if ( value != undefined ) elem[name] = value;
  468. return elem[name];
  469. }
  470. },
  471. trim: function(t){
  472. return t.replace(/^\s+|\s+$/g, "");
  473. },
  474. makeArray: function( a ) {
  475. var r = [];
  476. if ( a.constructor != Array )
  477. for ( var i = 0, al = a.length; i < al; i++ )
  478. r.push( a[i] );
  479. else
  480. r = a.slice( 0 );
  481. return r;
  482. },
  483. inArray: function( b, a ) {
  484. for ( var i = 0, al = a.length; i < al; i++ )
  485. if ( a[i] == b )
  486. return i;
  487. return -1;
  488. },
  489. merge: function(first, second) {
  490. var r = [].slice.call( first, 0 );
  491. // Now check for duplicates between the two arrays
  492. // and only add the unique items
  493. for ( var i = 0, sl = second.length; i < sl; i++ )
  494. // Check for duplicates
  495. if ( jQuery.inArray( second[i], r ) == -1 )
  496. // The item is unique, add it
  497. first.push( second[i] );
  498. return first;
  499. },
  500. grep: function(elems, fn, inv) {
  501. // If a string is passed in for the function, make a function
  502. // for it (a handy shortcut)
  503. if ( typeof fn == "string" )
  504. fn = new Function("a","i","return " + fn);
  505. var result = [];
  506. // Go through the array, only saving the items
  507. // that pass the validator function
  508. for ( var i = 0, el = elems.length; i < el; i++ )
  509. if ( !inv && fn(elems[i],i) || inv && !fn(elems[i],i) )
  510. result.push( elems[i] );
  511. return result;
  512. },
  513. map: function(elems, fn) {
  514. // If a string is passed in for the function, make a function
  515. // for it (a handy shortcut)
  516. if ( typeof fn == "string" )
  517. fn = new Function("a","return " + fn);
  518. var result = [], r = [];
  519. // Go through the array, translating each of the items to their
  520. // new value (or values).
  521. for ( var i = 0, el = elems.length; i < el; i++ ) {
  522. var val = fn(elems[i],i);
  523. if ( val !== null && val != undefined ) {
  524. if ( val.constructor != Array ) val = [val];
  525. result = result.concat( val );
  526. }
  527. }
  528. var r = result.length ? [ result[0] ] : [];
  529. check: for ( var i = 1, rl = result.length; i < rl; i++ ) {
  530. for ( var j = 0; j < i; j++ )
  531. if ( result[i] == r[j] )
  532. continue check;
  533. r.push( result[i] );
  534. }
  535. return r;
  536. }
  537. });
  538. /*
  539. * Whether the W3C compliant box model is being used.
  540. *
  541. * @property
  542. * @name $.boxModel
  543. * @type Boolean
  544. * @cat JavaScript
  545. */
  546. new function() {
  547. var b = navigator.userAgent.toLowerCase();
  548. // Figure out what browser is being used
  549. jQuery.browser = {
  550. safari: /webkit/.test(b),
  551. opera: /opera/.test(b),
  552. msie: /msie/.test(b) && !/opera/.test(b),
  553. mozilla: /mozilla/.test(b) && !/(compatible|webkit)/.test(b)
  554. };
  555. // Check to see if the W3C box model is being used
  556. jQuery.boxModel = !jQuery.browser.msie || document.compatMode == "CSS1Compat";
  557. };
  558. jQuery.each({
  559. parent: "a.parentNode",
  560. parents: "jQuery.parents(a)",
  561. next: "jQuery.nth(a,2,'nextSibling')",
  562. prev: "jQuery.nth(a,2,'previousSibling')",
  563. siblings: "jQuery.sibling(a.parentNode.firstChild,a)",
  564. children: "jQuery.sibling(a.firstChild)"
  565. }, function(i,n){
  566. jQuery.fn[ i ] = function(a) {
  567. var ret = jQuery.map(this,n);
  568. if ( a && typeof a == "string" )
  569. ret = jQuery.multiFilter(a,ret);
  570. return this.pushStack( ret );
  571. };
  572. });
  573. jQuery.each({
  574. appendTo: "append",
  575. prependTo: "prepend",
  576. insertBefore: "before",
  577. insertAfter: "after"
  578. }, function(i,n){
  579. jQuery.fn[ i ] = function(){
  580. var a = arguments;
  581. return this.each(function(){
  582. for ( var j = 0, al = a.length; j < al; j++ )
  583. jQuery(a[j])[n]( this );
  584. });
  585. };
  586. });
  587. jQuery.each( {
  588. removeAttr: function( key ) {
  589. jQuery.attr( this, key, "" );
  590. this.removeAttribute( key );
  591. },
  592. addClass: function(c){
  593. jQuery.className.add(this,c);
  594. },
  595. removeClass: function(c){
  596. jQuery.className.remove(this,c);
  597. },
  598. toggleClass: function( c ){
  599. jQuery.className[ jQuery.className.has(this,c) ? "remove" : "add" ](this, c);
  600. },
  601. remove: function(a){
  602. if ( !a || jQuery.filter( a, [this] ).r.length )
  603. this.parentNode.removeChild( this );
  604. },
  605. empty: function() {
  606. while ( this.firstChild )
  607. this.removeChild( this.firstChild );
  608. }
  609. }, function(i,n){
  610. jQuery.fn[ i ] = function() {
  611. return this.each( n, arguments );
  612. };
  613. });
  614. jQuery.each( [ "eq", "lt", "gt", "contains" ], function(i,n){
  615. jQuery.fn[ n ] = function(num,fn) {
  616. return this.filter( ":" + n + "(" + num + ")", fn );
  617. };
  618. });
  619. jQuery.each( [ "height", "width" ], function(i,n){
  620. jQuery.fn[ n ] = function(h) {
  621. return h == undefined ?
  622. ( this.length ? jQuery.css( this[0], n ) : null ) :
  623. this.css( n, h.constructor == String ? h : h + "px" );
  624. };
  625. });
  626. jQuery.extend({
  627. expr: {
  628. "": "m[2]=='*'||jQuery.nodeName(a,m[2])",
  629. "#": "a.getAttribute('id')==m[2]",
  630. ":": {
  631. // Position Checks
  632. lt: "i<m[3]-0",
  633. gt: "i>m[3]-0",
  634. nth: "m[3]-0==i",
  635. eq: "m[3]-0==i",
  636. first: "i==0",
  637. last: "i==r.length-1",
  638. even: "i%2==0",
  639. odd: "i%2",
  640. // Child Checks
  641. "nth-child": "jQuery.nth(a.parentNode.firstChild,m[3],'nextSibling',a)==a",
  642. "first-child": "jQuery.nth(a.parentNode.firstChild,1,'nextSibling')==a",
  643. "last-child": "jQuery.nth(a.parentNode.lastChild,1,'previousSibling')==a",
  644. "only-child": "jQuery.sibling(a.parentNode.firstChild).length==1",
  645. // Parent Checks
  646. parent: "a.firstChild",
  647. empty: "!a.firstChild",
  648. // Text Check
  649. contains: "jQuery.fn.text.apply([a]).indexOf(m[3])>=0",
  650. // Visibility
  651. visible: 'a.type!="hidden"&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden"',
  652. hidden: 'a.type=="hidden"||jQuery.css(a,"display")=="none"||jQuery.css(a,"visibility")=="hidden"',
  653. // Form attributes
  654. enabled: "!a.disabled",
  655. disabled: "a.disabled",
  656. checked: "a.checked",
  657. selected: "a.selected||jQuery.attr(a,'selected')",
  658. // Form elements
  659. text: "a.type=='text'",
  660. radio: "a.type=='radio'",
  661. checkbox: "a.type=='checkbox'",
  662. file: "a.type=='file'",
  663. password: "a.type=='password'",
  664. submit: "a.type=='submit'",
  665. image: "a.type=='image'",
  666. reset: "a.type=='reset'",
  667. button: 'a.type=="button"||jQuery.nodeName(a,"button")',
  668. input: "/input|select|textarea|button/i.test(a.nodeName)"
  669. },
  670. ".": "jQuery.className.has(a,m[2])",
  671. "@": {
  672. "=": "z==m[4]",
  673. "!=": "z!=m[4]",
  674. "^=": "z&&!z.indexOf(m[4])",
  675. "$=": "z&&z.substr(z.length - m[4].length,m[4].length)==m[4]",
  676. "*=": "z&&z.indexOf(m[4])>=0",
  677. "": "z",
  678. _resort: function(m){
  679. return ["", m[1], m[3], m[2], m[5]];
  680. },
  681. _prefix: "z=a[m[3]];if(!z||/href|src/.test(m[3]))z=jQuery.attr(a,m[3]);"
  682. },
  683. "[": "jQuery.find(m[2],a).length"
  684. },
  685. // The regular expressions that power the parsing engine
  686. parse: [
  687. // Match: [@value='test'], [@foo]
  688. /^\[ *(@)([a-z0-9_-]*) *([!*$^=]*) *('?"?)(.*?)\4 *\]/i,
  689. // Match: [div], [div p]
  690. /^(\[)\s*(.*?(\[.*?\])?[^[]*?)\s*\]/,
  691. // Match: :contains('foo')
  692. /^(:)([a-z0-9_-]*)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/i,
  693. // Match: :even, :last-chlid
  694. /^([:.#]*)([a-z0-9_*-]*)/i
  695. ],
  696. token: [
  697. /^(\/?\.\.)/, "a.parentNode",
  698. /^(>|\/)/, "jQuery.sibling(a.firstChild)",
  699. /^(\+)/, "jQuery.nth(a,2,'nextSibling')",
  700. /^(~)/, function(a){
  701. var s = jQuery.sibling(a.parentNode.firstChild);
  702. return s.slice(jQuery.inArray(a,s) + 1);
  703. }
  704. ],
  705. multiFilter: function( expr, elems, not ) {
  706. var old, cur = [];
  707. while ( expr && expr != old ) {
  708. old = expr;
  709. var f = jQuery.filter( expr, elems, not );
  710. expr = f.t.replace(/^\s*,\s*/, "" );
  711. cur = not ? elems = f.r : jQuery.merge( cur, f.r );
  712. }
  713. return cur;
  714. },
  715. find: function( t, context ) {
  716. // Quickly handle non-string expressions
  717. if ( typeof t != "string" )
  718. return [ t ];
  719. // Make sure that the context is a DOM Element
  720. if ( context && !context.nodeType )
  721. context = null;
  722. // Set the correct context (if none is provided)
  723. context = context || document;
  724. // Handle the common XPath // expression
  725. if ( !t.indexOf("//") ) {
  726. context = context.documentElement;
  727. t = t.substr(2,t.length);
  728. // And the / root expression
  729. } else if ( !t.indexOf("/") ) {
  730. context = context.documentElement;
  731. t = t.substr(1,t.length);
  732. if ( t.indexOf("/") >= 1 )
  733. t = t.substr(t.indexOf("/"),t.length);
  734. }
  735. // Initialize the search
  736. var ret = [context], done = [], last = null;
  737. // Continue while a selector expression exists, and while
  738. // we're no longer looping upon ourselves
  739. while ( t && last != t ) {
  740. var r = [];
  741. last = t;
  742. t = jQuery.trim(t).replace( /^\/\//i, "" );
  743. var foundToken = false;
  744. // An attempt at speeding up child selectors that
  745. // point to a specific element tag
  746. var re = /^[\/>]\s*([a-z0-9*-]+)/i;
  747. var m = re.exec(t);
  748. if ( m ) {
  749. // Perform our own iteration and filter
  750. jQuery.each( ret, function(){
  751. for ( var c = this.firstChild; c; c = c.nextSibling )
  752. if ( c.nodeType == 1 && ( jQuery.nodeName(c, m[1]) || m[1] == "*" ) )
  753. r.push( c );
  754. });
  755. ret = r;
  756. t = t.replace( re, "" );
  757. if ( t.indexOf(" ") == 0 ) continue;
  758. foundToken = true;
  759. } else {
  760. // Look for pre-defined expression tokens
  761. for ( var i = 0; i < jQuery.token.length; i += 2 ) {
  762. // Attempt to match each, individual, token in
  763. // the specified order
  764. var re = jQuery.token[i];
  765. var m = re.exec(t);
  766. // If the token match was found
  767. if ( m ) {
  768. // Map it against the token's handler
  769. r = ret = jQuery.map( ret, jQuery.isFunction( jQuery.token[i+1] ) ?
  770. jQuery.token[i+1] :
  771. function(a){ return eval(jQuery.token[i+1]); });
  772. // And remove the token
  773. t = jQuery.trim( t.replace( re, "" ) );
  774. foundToken = true;
  775. break;
  776. }
  777. }
  778. }
  779. // See if there's still an expression, and that we haven't already
  780. // matched a token
  781. if ( t && !foundToken ) {
  782. // Handle multiple expressions
  783. if ( !t.indexOf(",") ) {
  784. // Clean the result set
  785. if ( ret[0] == context ) ret.shift();
  786. // Merge the result sets
  787. jQuery.merge( done, ret );
  788. // Reset the context
  789. r = ret = [context];
  790. // Touch up the selector string
  791. t = " " + t.substr(1,t.length);
  792. } else {
  793. // Optomize for the case nodeName#idName
  794. var re2 = /^([a-z0-9_-]+)(#)([a-z0-9\\*_-]*)/i;
  795. var m = re2.exec(t);
  796. // Re-organize the results, so that they're consistent
  797. if ( m ) {
  798. m = [ 0, m[2], m[3], m[1] ];
  799. } else {
  800. // Otherwise, do a traditional filter check for
  801. // ID, class, and element selectors
  802. re2 = /^([#.]?)([a-z0-9\\*_-]*)/i;
  803. m = re2.exec(t);
  804. }
  805. // Try to do a global search by ID, where we can
  806. if ( m[1] == "#" && ret[ret.length-1].getElementById ) {
  807. // Optimization for HTML document case
  808. var oid = ret[ret.length-1].getElementById(m[2]);
  809. // Do a quick check for the existence of the actual ID attribute
  810. // to avoid selecting by the name attribute in IE
  811. if ( jQuery.browser.msie && oid && oid.id != m[2] )
  812. oid = jQuery('[@id="'+m[2]+'"]', ret[ret.length-1])[0];
  813. // Do a quick check for node name (where applicable) so
  814. // that div#foo searches will be really fast
  815. ret = r = oid && (!m[3] || jQuery.nodeName(oid, m[3])) ? [oid] : [];
  816. } else {
  817. // Pre-compile a regular expression to handle class searches
  818. if ( m[1] == "." )
  819. var rec = new RegExp("(^|\\s)" + m[2] + "(\\s|$)");
  820. // We need to find all descendant elements, it is more
  821. // efficient to use getAll() when we are already further down
  822. // the tree - we try to recognize that here
  823. jQuery.each( ret, function(){
  824. // Grab the tag name being searched for
  825. var tag = m[1] != "" || m[0] == "" ? "*" : m[2];
  826. // Handle IE7 being really dumb about <object>s
  827. if ( jQuery.nodeName(this, "object") && tag == "*" )
  828. tag = "param";
  829. jQuery.merge( r,
  830. m[1] != "" && ret.length != 1 ?
  831. jQuery.getAll( this, [], m[1], m[2], rec ) :
  832. this.getElementsByTagName( tag )
  833. );
  834. });
  835. // It's faster to filter by class and be done with it
  836. if ( m[1] == "." && ret.length == 1 )
  837. r = jQuery.grep( r, function(e) {
  838. return rec.test(e.className);
  839. });
  840. // Same with ID filtering
  841. if ( m[1] == "#" && ret.length == 1 ) {
  842. // Remember, then wipe out, the result set
  843. var tmp = r;
  844. r = [];
  845. // Then try to find the element with the ID
  846. jQuery.each( tmp, function(){
  847. if ( this.getAttribute("id") == m[2] ) {
  848. r = [ this ];
  849. return false;
  850. }
  851. });
  852. }
  853. ret = r;
  854. }
  855. t = t.replace( re2, "" );
  856. }
  857. }
  858. // If a selector string still exists
  859. if ( t ) {
  860. // Attempt to filter it
  861. var val = jQuery.filter(t,r);
  862. ret = r = val.r;
  863. t = jQuery.trim(val.t);
  864. }
  865. }
  866. // Remove the root context
  867. if ( ret && ret[0] == context ) ret.shift();
  868. // And combine the results
  869. jQuery.merge( done, ret );
  870. return done;
  871. },
  872. filter: function(t,r,not) {
  873. // Look for common filter expressions
  874. while ( t && /^[a-z[({<*:.#]/i.test(t) ) {
  875. var p = jQuery.parse, m;
  876. jQuery.each( p, function(i,re){
  877. // Look for, and replace, string-like sequences
  878. // and finally build a regexp out of it
  879. m = re.exec( t );
  880. if ( m ) {
  881. // Remove what we just matched
  882. t = t.substring( m[0].length );
  883. // Re-organize the first match
  884. if ( jQuery.expr[ m[1] ]._resort )
  885. m = jQuery.expr[ m[1] ]._resort( m );
  886. return false;
  887. }
  888. });
  889. // :not() is a special case that can be optimized by
  890. // keeping it out of the expression list
  891. if ( m[1] == ":" && m[2] == "not" )
  892. r = jQuery.filter(m[3], r, true).r;
  893. // Handle classes as a special case (this will help to
  894. // improve the speed, as the regexp will only be compiled once)
  895. else if ( m[1] == "." ) {
  896. var re = new RegExp("(^|\\s)" + m[2] + "(\\s|$)");
  897. r = jQuery.grep( r, function(e){
  898. return re.test(e.className || "");
  899. }, not);
  900. // Otherwise, find the expression to execute
  901. } else {
  902. var f = jQuery.expr[m[1]];
  903. if ( typeof f != "string" )
  904. f = jQuery.expr[m[1]][m[2]];
  905. // Build a custom macro to enclose it
  906. eval("f = function(a,i){" +
  907. ( jQuery.expr[ m[1] ]._prefix || "" ) +
  908. "return " + f + "}");
  909. // Execute it against the current filter
  910. r = jQuery.grep( r, f, not );
  911. }
  912. }
  913. // Return an array of filtered elements (r)
  914. // and the modified expression string (t)
  915. return { r: r, t: t };
  916. },
  917. getAll: function( o, r, token, name, re ) {
  918. for ( var s = o.firstChild; s; s = s.nextSibling )
  919. if ( s.nodeType == 1 ) {
  920. var add = true;
  921. if ( token == "." )
  922. add = s.className && re.test(s.className);
  923. else if ( token == "#" )
  924. add = s.getAttribute("id") == name;
  925. if ( add )
  926. r.push( s );
  927. if ( token == "#" && r.length ) break;
  928. if ( s.firstChild )
  929. jQuery.getAll( s, r, token, name, re );
  930. }
  931. return r;
  932. },
  933. parents: function( elem ){
  934. var matched = [];
  935. var cur = elem.parentNode;
  936. while ( cur && cur != document ) {
  937. matched.push( cur );
  938. cur = cur.parentNode;
  939. }
  940. return matched;
  941. },
  942. nth: function(cur,result,dir,elem){
  943. result = result || 1;
  944. var num = 0;
  945. for ( ; cur; cur = cur[dir] ) {
  946. if ( cur.nodeType == 1 ) num++;
  947. if ( num == result || result == "even" && num % 2 == 0 && num > 1 && cur == elem ||
  948. result == "odd" && num % 2 == 1 && cur == elem ) return cur;
  949. }
  950. },
  951. sibling: function( n, elem ) {
  952. var r = [];
  953. for ( ; n; n = n.nextSibling ) {
  954. if ( n.nodeType == 1 && (!elem || n != elem) )
  955. r.push( n );
  956. }
  957. return r;
  958. }
  959. });
  960. /*
  961. * A number of helper functions used for managing events.
  962. * Many of the ideas behind this code orignated from
  963. * Dean Edwards' addEvent library.
  964. */
  965. jQuery.event = {
  966. // Bind an event to an element
  967. // Original by Dean Edwards
  968. add: function(element, type, handler, data) {
  969. // For whatever reason, IE has trouble passing the window object
  970. // around, causing it to be cloned in the process
  971. if ( jQuery.browser.msie && element.setInterval != undefined )
  972. element = window;
  973. // if data is passed, bind to handler
  974. if( data )
  975. handler.data = data;
  976. // Make sure that the function being executed has a unique ID
  977. if ( !handler.guid )
  978. handler.guid = this.guid++;
  979. // Init the element's event structure
  980. if (!element.$events)
  981. element.$events = {};
  982. // Get the current list of functions bound to this event
  983. var handlers = element.$events[type];
  984. // If it hasn't been initialized yet
  985. if (!handlers) {
  986. // Init the event handler queue
  987. handlers = element.$events[type] = {};
  988. // Remember an existing handler, if it's already there
  989. if (element["on" + type])
  990. handlers[0] = element["on" + type];
  991. }
  992. // Add the function to the element's handler list
  993. handlers[handler.guid] = handler;
  994. // And bind the global event handler to the element
  995. element["on" + type] = this.handle;
  996. // Remember the function in a global list (for triggering)
  997. if (!this.global[type])
  998. this.global[type] = [];
  999. this.global[type].push( element );
  1000. },
  1001. guid: 1,
  1002. global: {},
  1003. // Detach an event or set of events from an element
  1004. remove: function(element, type, handler) {
  1005. if (element.$events) {
  1006. var i,j,k;
  1007. if ( type && type.type ) { // type is actually an event object here
  1008. handler = type.handler;
  1009. type = type.type;
  1010. }
  1011. if (type && element.$events[type])
  1012. // remove the given handler for the given type
  1013. if ( handler )
  1014. delete element.$events[type][handler.guid];
  1015. // remove all handlers for the given type
  1016. else
  1017. for ( i in element.$events[type] )
  1018. delete element.$events[type][i];
  1019. // remove all handlers
  1020. else
  1021. for ( j in element.$events )
  1022. this.remove( element, j );
  1023. // remove event handler if no more handlers exist
  1024. for ( k in element.$events[type] )
  1025. if (k) {
  1026. k = true;
  1027. break;
  1028. }
  1029. if (!k) element["on" + type] = null;
  1030. }
  1031. },
  1032. trigger: function(type, data, element) {
  1033. // Clone the incoming data, if any
  1034. data = jQuery.makeArray(data || []);
  1035. // Handle a global trigger
  1036. if ( !element )
  1037. jQuery.each( this.global[type] || [], function(){
  1038. jQuery.event.trigger( type, data, this );
  1039. });
  1040. // Handle triggering a single element
  1041. else {
  1042. var handler = element["on" + type ], val,
  1043. fn = jQuery.isFunction( element[ type ] );
  1044. if ( handler ) {
  1045. // Pass along a fake event
  1046. data.unshift( this.fix({ type: type, target: element }) );
  1047. // Trigger the event
  1048. if ( (val = handler.apply( element, data )) !== false )
  1049. this.triggered = true;
  1050. }
  1051. if ( fn && val !== false )
  1052. element[ type ]();
  1053. this.triggered = false;
  1054. }
  1055. },
  1056. handle: function(event) {
  1057. // Handle the second event of a trigger and when
  1058. // an event is called after a page has unloaded
  1059. if ( typeof jQuery == "undefined" || jQuery.event.triggered ) return;
  1060. // Empty object is for triggered events with no data
  1061. event = jQuery.event.fix( event || window.event || {} );
  1062. // returned undefined or false
  1063. var returnValue;
  1064. var c = this.$events[event.type];
  1065. var args = [].slice.call( arguments, 1 );
  1066. args.unshift( event );
  1067. for ( var j in c ) {
  1068. // Pass in a reference to the handler function itself
  1069. // So that we can later remove it
  1070. args[0].handler = c[j];
  1071. args[0].data = c[j].data;
  1072. if ( c[j].apply( this, args ) === false ) {
  1073. event.preventDefault();
  1074. event.stopPropagation();
  1075. returnValue = false;
  1076. }
  1077. }
  1078. // Clean up added properties in IE to prevent memory leak
  1079. if (jQuery.browser.msie) event.target = event.preventDefault = event.stopPropagation = event.handler = event.data = null;
  1080. return returnValue;
  1081. },
  1082. fix: function(event) {
  1083. // Fix target property, if necessary
  1084. if ( !event.target && event.srcElement )
  1085. event.target = event.srcElement;
  1086. // Calculate pageX/Y if missing and clientX/Y available
  1087. if ( event.pageX == undefined && event.clientX != undefined ) {
  1088. var e = document.documentElement, b = document.body;
  1089. event.pageX = event.clientX + (e.scrollLeft || b.scrollLeft);
  1090. event.pageY = event.clientY + (e.scrollTop || b.scrollTop);
  1091. }
  1092. // check if target is a textnode (safari)
  1093. if (jQuery.browser.safari && event.target.nodeType == 3) {
  1094. // store a copy of the original event object
  1095. // and clone because target is read only
  1096. var originalEvent = event;
  1097. event = jQuery.extend({}, originalEvent);
  1098. // get parentnode from textnode
  1099. event.target = originalEvent.target.parentNode;
  1100. // add preventDefault and stopPropagation since
  1101. // they will not work on the clone
  1102. event.preventDefault = function() {
  1103. return originalEvent.preventDefault();
  1104. };
  1105. event.stopPropagation = function() {
  1106. return originalEvent.stopPropagation();
  1107. };
  1108. }
  1109. // fix preventDefault and stopPropagation
  1110. if (!event.preventDefault)
  1111. event.preventDefault = function() {
  1112. this.returnValue = false;
  1113. };
  1114. if (!event.stopPropagation)
  1115. event.stopPropagation = function() {
  1116. this.cancelBubble = true;
  1117. };
  1118. return event;
  1119. }
  1120. };
  1121. jQuery.fn.extend({
  1122. bind: function( type, data, fn ) {
  1123. return this.each(function(){
  1124. jQuery.event.add( this, type, fn || data, data );
  1125. });
  1126. },
  1127. one: function( type, data, fn ) {
  1128. return this.each(function(){
  1129. jQuery.event.add( this, type, function(event) {
  1130. jQuery(this).unbind(event);
  1131. return (fn || data).apply( this, arguments);
  1132. }, data);
  1133. });
  1134. },
  1135. unbind: function( type, fn ) {
  1136. return this.each(function(){
  1137. jQuery.event.remove( this, type, fn );
  1138. });
  1139. },
  1140. trigger: function( type, data ) {
  1141. return this.each(function(){
  1142. jQuery.event.trigger( type, data, this );
  1143. });
  1144. },
  1145. toggle: function() {
  1146. // Save reference to arguments for access in closure
  1147. var a = arguments;
  1148. return this.click(function(e) {
  1149. // Figure out which function to execute
  1150. this.lastToggle = this.lastToggle == 0 ? 1 : 0;
  1151. // Make sure that clicks stop
  1152. e.preventDefault();
  1153. // and execute the function
  1154. return a[this.lastToggle].apply( this, [e] ) || false;
  1155. });
  1156. },
  1157. hover: function(f,g) {
  1158. // A private function for handling mouse 'hovering'
  1159. function handleHover(e) {
  1160. // Check if mouse(over|out) are still within the same parent element
  1161. var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget;
  1162. // Traverse up the tree
  1163. while ( p && p != this ) try { p = p.parentNode } catch(e) { p = this; };
  1164. // If we actually just moused on to a sub-element, ignore it
  1165. if ( p == this ) return false;
  1166. // Execute the right function
  1167. return (e.type == "mouseover" ? f : g).apply(this, [e]);
  1168. }
  1169. // Bind the function to the two event listeners
  1170. return this.mouseover(handleHover).mouseout(handleHover);
  1171. },
  1172. ready: function(f) {
  1173. // If the DOM is already ready
  1174. if ( jQuery.isReady )
  1175. // Execute the function immediately
  1176. f.apply( document, [jQuery] );
  1177. // Otherwise, remember the function for later
  1178. else {
  1179. // Add the function to the wait list
  1180. jQuery.readyList.push( function() { return f.apply(this, [jQuery]) } );
  1181. }
  1182. return this;
  1183. }
  1184. });
  1185. jQuery.extend({
  1186. /*
  1187. * All the code that makes DOM Ready work nicely.
  1188. */
  1189. isReady: false,
  1190. readyList: [],
  1191. // Handle when the DOM is ready
  1192. ready: function() {
  1193. // Make sure that the DOM is not already loaded
  1194. if ( !jQuery.isReady ) {
  1195. // Remember that the DOM is ready
  1196. jQuery.isReady = true;
  1197. // If there are functions bound, to execute
  1198. if ( jQuery.readyList ) {
  1199. // Execute all of them
  1200. jQuery.each( jQuery.readyList, function(){
  1201. this.apply( document );
  1202. });
  1203. // Reset the list of functions
  1204. jQuery.readyList = null;
  1205. }
  1206. // Remove event lisenter to avoid memory leak
  1207. if ( jQuery.browser.mozilla || jQuery.browser.opera )
  1208. document.removeEventListener( "DOMContentLoaded", jQuery.ready, false );
  1209. }
  1210. }
  1211. });
  1212. new function(){
  1213. jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," +
  1214. "mousedown,mouseup,mousemove,mouseover,mouseout,change,select," +
  1215. "submit,keydown,keypress,keyup,error").split(","), function(i,o){
  1216. // Handle event binding
  1217. jQuery.fn[o] = function(f){
  1218. return f ? this.bind(o, f) : this.trigger(o);
  1219. };
  1220. });
  1221. // If Mozilla is used
  1222. if ( jQuery.browser.mozilla || jQuery.browser.opera )
  1223. // Use the handy event callback
  1224. document.addEventListener( "DOMContentLoaded", jQuery.ready, false );
  1225. // If IE is used, use the excellent hack by Matthias Miller
  1226. // http://www.outofhanwell.com/blog/index.php?title=the_window_onload_problem_revisited
  1227. else if ( jQuery.browser.msie ) {
  1228. // Only works if you document.write() it
  1229. document.write("<scr" + "ipt id=__ie_init defer=true " +
  1230. "src=//:><\/script>");
  1231. // Use the defer script hack
  1232. var script = document.getElementById("__ie_init");
  1233. // script does not exist if jQuery is loaded dynamically
  1234. if ( script )
  1235. script.onreadystatechange = function() {
  1236. if ( this.readyState != "complete" ) return;
  1237. this.parentNode.removeChild( this );
  1238. jQuery.ready();
  1239. };
  1240. // Clear from memory
  1241. script = null;
  1242. // If Safari is used
  1243. } else if ( jQuery.browser.safari )
  1244. // Continually check to see if the document.readyState is valid
  1245. jQuery.safariTimer = setInterval(function(){
  1246. // loaded and complete are both valid states
  1247. if ( document.readyState == "loaded" ||
  1248. document.readyState == "complete" ) {
  1249. // If either one are found, remove the timer
  1250. clearInterval( jQuery.safariTimer );
  1251. jQuery.safariTimer = null;
  1252. // and execute any waiting functions
  1253. jQuery.ready();
  1254. }
  1255. }, 10);
  1256. // A fallback to window.onload, that will always work
  1257. jQuery.event.add( window, "load", jQuery.ready );
  1258. };
  1259. // Clean up after IE to avoid memory leaks
  1260. if (jQuery.browser.msie)
  1261. jQuery(window).one("unload", function() {
  1262. var global = jQuery.event.global;
  1263. for ( var type in global ) {
  1264. var els = global[type], i = els.length;
  1265. if ( i && type != 'unload' )
  1266. do
  1267. jQuery.event.remove(els[i-1], type);
  1268. while (--i);
  1269. }
  1270. });
  1271. jQuery.fn.extend({
  1272. loadIfModified: function( url, params, callback ) {
  1273. this.load( url, params, callback, 1 );
  1274. },
  1275. load: function( url, params, callback, ifModified ) {
  1276. if ( jQuery.isFunction( url ) )
  1277. return this.bind("load", url);
  1278. callback = callback || function(){};
  1279. // Default to a GET request
  1280. var type = "GET";
  1281. // If the second parameter was provided
  1282. if ( params )
  1283. // If it's a function
  1284. if ( jQuery.isFunction( params ) ) {
  1285. // We assume that it's the callback
  1286. callback = params;
  1287. params = null;
  1288. // Otherwise, build a param string
  1289. } else {
  1290. params = jQuery.param( params );
  1291. type = "POST";
  1292. }
  1293. var self = this;
  1294. // Request the remote document
  1295. jQuery.ajax({
  1296. url: url,
  1297. type: type,
  1298. data: params,
  1299. ifModified: ifModified,
  1300. complete: function(res, status){
  1301. if ( status == "success" || !ifModified && status == "notmodified" )
  1302. // Inject the HTML into all the matched elements
  1303. self.attr("innerHTML", res.responseText)
  1304. // Execute all the scripts inside of the newly-injected HTML
  1305. .evalScripts()
  1306. // Execute callback
  1307. .each( callback, [res.responseText, status, res] );
  1308. else
  1309. callback.apply( self, [res.responseText, status, res] );
  1310. }
  1311. });
  1312. return this;
  1313. },
  1314. serialize: function() {
  1315. return jQuery.param( this );
  1316. },
  1317. evalScripts: function() {
  1318. return this.find("script").each(function(){
  1319. if ( this.src )
  1320. jQuery.getScript( this.src );
  1321. else
  1322. jQuery.globalEval( this.text || this.textContent || this.innerHTML || "" );
  1323. }).end();
  1324. }
  1325. });
  1326. // If IE is used, create a wrapper for the XMLHttpRequest object
  1327. if ( !window.XMLHttpRequest )
  1328. XMLHttpRequest = function(){
  1329. return new ActiveXObject("Microsoft.XMLHTTP");
  1330. };
  1331. // Attach a bunch of functions for handling common AJAX events
  1332. jQuery.each( "ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","), function(i,o){
  1333. jQuery.fn[o] = function(f){
  1334. return this.bind(o, f);
  1335. };
  1336. });
  1337. jQuery.extend({
  1338. get: function( url, data, callback, type, ifModified ) {
  1339. // shift arguments if data argument was ommited
  1340. if ( jQuery.isFunction( data ) ) {
  1341. callback = data;
  1342. data = null;
  1343. }
  1344. return jQuery.ajax({
  1345. url: url,
  1346. data: data,
  1347. success: callback,
  1348. dataType: type,
  1349. ifModified: ifModified
  1350. });
  1351. },
  1352. getIfModified: function( url, data, callback, type ) {
  1353. return jQuery.get(url, data, callback, type, 1);
  1354. },
  1355. getScript: function( url, callback ) {
  1356. return jQuery.get(url, null, callback, "script");
  1357. },
  1358. getJSON: function( url, data, callback ) {
  1359. return jQuery.get(url, data, callback, "json");
  1360. },
  1361. post: function( url, data, callback, type ) {
  1362. if ( jQuery.isFunction( data ) ) {
  1363. callback = data;
  1364. data = {};
  1365. }
  1366. return jQuery.ajax({
  1367. type: "POST",
  1368. url: url,
  1369. data: data,
  1370. success: callback,
  1371. dataType: type
  1372. });
  1373. },
  1374. // timeout (ms)
  1375. //timeout: 0,
  1376. ajaxTimeout: function( timeout ) {
  1377. jQuery.ajaxSettings.timeout = timeout;
  1378. },
  1379. ajaxSetup: function( settings ) {
  1380. jQuery.extend( jQuery.ajaxSettings, settings );
  1381. },
  1382. ajaxSettings: {
  1383. global: true,
  1384. type: "GET",
  1385. timeout: 0,
  1386. contentType: "application/x-www-form-urlencoded",
  1387. processData: true,
  1388. async: true,
  1389. data: null
  1390. },
  1391. // Last-Modified header cache for next request
  1392. lastModified: {},
  1393. ajax: function( s ) {
  1394. // TODO introduce global settings, allowing the client to modify them for all requests, not only timeout
  1395. s = jQuery.extend({}, jQuery.ajaxSettings, s);
  1396. // if data available
  1397. if ( s.data ) {
  1398. // convert data if not already a string
  1399. if (s.processData && typeof s.data != "string")
  1400. s.data = jQuery.param(s.data);
  1401. // append data to url for get requests
  1402. if( s.type.toLowerCase() == "get" ) {
  1403. // "?" + data or "&" + data (in case there are already params)
  1404. s.url += ((s.url.indexOf("?") > -1) ? "&" : "?") + s.data;
  1405. // IE likes to send both get and post data, prevent this
  1406. s.data = null;
  1407. }
  1408. }
  1409. // Watch for a new set of requests
  1410. if ( s.global && ! jQuery.active++ )
  1411. jQuery.event.trigger( "ajaxStart" );
  1412. var requestDone = false;
  1413. // Create the request object
  1414. var xml = new XMLHttpRequest();
  1415. // Open the socket
  1416. xml.open(s.type, s.url, s.async);
  1417. // Set the correct header, if data is being sent
  1418. if ( s.data )
  1419. xml.setRequestHeader("Content-Type", s.contentType);
  1420. // Set the If-Modified-Since header, if ifModified mode.
  1421. if ( s.ifModified )
  1422. xml.setRequestHeader("If-Modified-Since",
  1423. jQuery.lastModified[s.url] || "Thu, 01 Jan 1970 00:00:00 GMT" );
  1424. // Set header so the called script knows that it's an XMLHttpRequest
  1425. xml.setRequestHeader("X-Requested-With", "XMLHttpRequest");
  1426. // Make sure the browser sends the right content length
  1427. if ( xml.overrideMimeType )
  1428. xml.setRequestHeader("Connection", "close");
  1429. // Allow custom headers/mimetypes
  1430. if( s.beforeSend )
  1431. s.beforeSend(xml);
  1432. if ( s.global )
  1433. jQuery.event.trigger("ajaxSend", [xml, s]);
  1434. // Wait for a response to come back
  1435. var onreadystatechange = function(isTimeout){
  1436. // The transfer is complete and the data is available, or the request timed out
  1437. if ( xml && (xml.readyState == 4 || isTimeout == "timeout") ) {
  1438. requestDone = true;
  1439. // clear poll interval
  1440. if (ival) {
  1441. clearInterval(ival);
  1442. ival = null;
  1443. }
  1444. var status;
  1445. try {
  1446. status = jQuery.httpSuccess( xml ) && isTimeout != "timeout" ?
  1447. s.ifModified && jQuery.httpNotModified( xml, s.url ) ? "notmodified" : "success" : "error";
  1448. // Make sure that the request was successful or notmodified
  1449. if ( status != "error" ) {
  1450. // Cache Last-Modified header, if ifModified mode.
  1451. var modRes;
  1452. try {
  1453. modRes = xml.getResponseHeader("Last-Modified");
  1454. } catch(e) {} // swallow exception thrown by FF if header is not available
  1455. if ( s.ifModified && modRes )
  1456. jQuery.lastModified[s.url] = modRes;
  1457. // process the data (runs the xml through httpData regardless of callback)
  1458. var data = jQuery.httpData( xml, s.dataType );
  1459. // If a local callback was specified, fire it and pass it the data
  1460. if ( s.success )
  1461. s.success( data, status );
  1462. // Fire the global callback
  1463. if( s.global )
  1464. jQuery.event.trigger( "ajaxSuccess", [xml, s] );
  1465. } else
  1466. jQuery.handleError(s, xml, status);
  1467. } catch(e) {
  1468. status = "error";
  1469. jQuery.handleError(s, xml, status, e);
  1470. }
  1471. // The request was completed
  1472. if( s.global )
  1473. jQuery.event.trigger( "ajaxComplete", [xml, s] );
  1474. // Handle the global AJAX counter
  1475. if ( s.global && ! --jQuery.active )
  1476. jQuery.event.trigger( "ajaxStop" );
  1477. // Process result
  1478. if ( s.complete )
  1479. s.complete(xml, status);
  1480. // Stop memory leaks
  1481. if(s.async)
  1482. xml = null;
  1483. }
  1484. };
  1485. // don't attach the handler to the request, just poll it instead
  1486. var ival = setInterval(onreadystatechange, 13);
  1487. // Timeout checker
  1488. if ( s.timeout > 0 )
  1489. setTimeout(function(){
  1490. // Check to see if the request is still happening
  1491. if ( xml ) {
  1492. // Cancel the request
  1493. xml.abort();
  1494. if( !requestDone )

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