[ Index ] |
|
Code source de Dotclear 2.0-beta6 |
1 /* prevent execution of jQuery if included more then once */ 2 if(typeof window.jQuery == "undefined") { 3 /* 4 * jQuery 1.0.3 - New Wave Javascript 5 * 6 * Copyright (c) 2006 John Resig (jquery.com) 7 * Dual licensed under the MIT (MIT-LICENSE.txt) 8 * and GPL (GPL-LICENSE.txt) licenses. 9 * 10 * $Date: 2006-10-27 11:15:44 -0400 (Fri, 27 Oct 2006) $ 11 * $Rev: 501 $ 12 */ 13 14 // Global undefined variable 15 window.undefined = window.undefined; 16 var jQuery = function(a,c) { 17 18 // Shortcut for document ready (because $(document).each() is silly) 19 if ( a && typeof a == "function" && jQuery.fn.ready ) 20 return jQuery(document).ready(a); 21 22 // Make sure that a selection was provided 23 a = a || jQuery.context || document; 24 25 // Watch for when a jQuery object is passed as the selector 26 if ( a.jquery ) 27 return jQuery( jQuery.merge( a, [] ) ); 28 29 // Watch for when a jQuery object is passed at the context 30 if ( c && c.jquery ) 31 return jQuery( c ).find(a); 32 33 // If the context is global, return a new object 34 if ( window == this ) 35 return new jQuery(a,c); 36 37 // Handle HTML strings 38 if ( a.constructor == String ) { 39 var m = /^[^<]*(<.+>)[^>]*$/.exec(a); 40 if ( m ) a = jQuery.clean( [ m[1] ] ); 41 } 42 43 // Watch for when an array is passed in 44 this.get( a.constructor == Array || a.length && !a.nodeType && a[0] != undefined && a[0].nodeType ? 45 // Assume that it is an array of DOM Elements 46 jQuery.merge( a, [] ) : 47 48 // Find the matching elements and save them for later 49 jQuery.find( a, c ) ); 50 51 // See if an extra function was provided 52 var fn = arguments[ arguments.length - 1 ]; 53 54 // If so, execute it in context 55 if ( fn && typeof fn == "function" ) 56 this.each(fn); 57 58 return this; 59 }; 60 61 // Map over the $ in case of overwrite 62 if ( typeof $ != "undefined" ) 63 jQuery._$ = $; 64 65 // Map the jQuery namespace to the '$' one 66 var $ = jQuery; 67 68 jQuery.fn = jQuery.prototype = { 69 jquery: "1.0.3", 70 71 size: function() { 72 return this.length; 73 }, 74 75 get: function( num ) { 76 // Watch for when an array (of elements) is passed in 77 if ( num && num.constructor == Array ) { 78 79 // Use a tricky hack to make the jQuery object 80 // look and feel like an array 81 this.length = 0; 82 [].push.apply( this, num ); 83 84 return this; 85 } else 86 return num == undefined ? 87 88 // Return a 'clean' array 89 jQuery.merge( this, [] ) : 90 91 // Return just the object 92 this[num]; 93 }, 94 each: function( fn, args ) { 95 return jQuery.each( this, fn, args ); 96 }, 97 index: function( obj ) { 98 var pos = -1; 99 this.each(function(i){ 100 if ( this == obj ) pos = i; 101 }); 102 return pos; 103 }, 104 105 attr: function( key, value, type ) { 106 // Check to see if we're setting style values 107 return key.constructor != String || value != undefined ? 108 this.each(function(){ 109 // See if we're setting a hash of styles 110 if ( value == undefined ) 111 // Set all the styles 112 for ( var prop in key ) 113 jQuery.attr( 114 type ? this.style : this, 115 prop, key[prop] 116 ); 117 118 // See if we're setting a single key/value style 119 else 120 jQuery.attr( 121 type ? this.style : this, 122 key, value 123 ); 124 }) : 125 126 // Look for the case where we're accessing a style value 127 jQuery[ type || "attr" ]( this[0], key ); 128 }, 129 130 css: function( key, value ) { 131 return this.attr( key, value, "curCSS" ); 132 }, 133 text: function(e) { 134 e = e || this; 135 var t = ""; 136 for ( var j = 0; j < e.length; j++ ) { 137 var r = e[j].childNodes; 138 for ( var i = 0; i < r.length; i++ ) 139 if ( r[i].nodeType != 8 ) 140 t += r[i].nodeType != 1 ? 141 r[i].nodeValue : jQuery.fn.text([ r[i] ]); 142 } 143 return t; 144 }, 145 146 wrap: function() { 147 // The elements to wrap the target around 148 var a = jQuery.clean(arguments); 149 150 // Wrap each of the matched elements individually 151 return this.each(function(){ 152 // Clone the structure that we're using to wrap 153 var b = a[0].cloneNode(true); 154 155 // Insert it before the element to be wrapped 156 this.parentNode.insertBefore( b, this ); 157 158 // Find the deepest point in the wrap structure 159 while ( b.firstChild ) 160 b = b.firstChild; 161 162 // Move the matched element to within the wrap structure 163 b.appendChild( this ); 164 }); 165 }, 166 167 append: function() { 168 return this.domManip(arguments, true, 1, function(a){ 169 this.appendChild( a ); 170 }); 171 }, 172 173 prepend: function() { 174 return this.domManip(arguments, true, -1, function(a){ 175 this.insertBefore( a, this.firstChild ); 176 }); 177 }, 178 179 before: function() { 180 return this.domManip(arguments, false, 1, function(a){ 181 this.parentNode.insertBefore( a, this ); 182 }); 183 }, 184 185 after: function() { 186 return this.domManip(arguments, false, -1, function(a){ 187 this.parentNode.insertBefore( a, this.nextSibling ); 188 }); 189 }, 190 end: function() { 191 return this.get( this.stack.pop() ); 192 }, 193 find: function(t) { 194 return this.pushStack( jQuery.map( this, function(a){ 195 return jQuery.find(t,a); 196 }), arguments ); 197 }, 198 clone: function(deep) { 199 return this.pushStack( jQuery.map( this, function(a){ 200 return a.cloneNode( deep != undefined ? deep : true ); 201 }), arguments ); 202 }, 203 204 filter: function(t) { 205 return this.pushStack( 206 t.constructor == Array && 207 jQuery.map(this,function(a){ 208 for ( var i = 0; i < t.length; i++ ) 209 if ( jQuery.filter(t[i],[a]).r.length ) 210 return a; 211 return false; 212 }) || 213 214 t.constructor == Boolean && 215 ( t ? this.get() : [] ) || 216 217 typeof t == "function" && 218 jQuery.grep( this, t ) || 219 220 jQuery.filter(t,this).r, arguments ); 221 }, 222 223 not: function(t) { 224 return this.pushStack( t.constructor == String ? 225 jQuery.filter(t,this,false).r : 226 jQuery.grep(this,function(a){ return a != t; }), arguments ); 227 }, 228 229 add: function(t) { 230 return this.pushStack( jQuery.merge( this, t.constructor == String ? 231 jQuery.find(t) : t.constructor == Array ? t : [t] ), arguments ); 232 }, 233 is: function(expr) { 234 return expr ? jQuery.filter(expr,this).r.length > 0 : false; 235 }, 236 domManip: function(args, table, dir, fn){ 237 var clone = this.size() > 1; 238 var a = jQuery.clean(args); 239 240 return this.each(function(){ 241 var obj = this; 242 243 if ( table && this.nodeName.toUpperCase() == "TABLE" && a[0].nodeName.toUpperCase() != "THEAD" ) { 244 var tbody = this.getElementsByTagName("tbody"); 245 246 if ( !tbody.length ) { 247 obj = document.createElement("tbody"); 248 this.appendChild( obj ); 249 } else 250 obj = tbody[0]; 251 } 252 253 for ( var i = ( dir < 0 ? a.length - 1 : 0 ); 254 i != ( dir < 0 ? dir : a.length ); i += dir ) { 255 fn.apply( obj, [ clone ? a[i].cloneNode(true) : a[i] ] ); 256 } 257 }); 258 }, 259 pushStack: function(a,args) { 260 var fn = args && args[args.length-1]; 261 var fn2 = args && args[args.length-2]; 262 263 if ( fn && fn.constructor != Function ) fn = null; 264 if ( fn2 && fn2.constructor != Function ) fn2 = null; 265 266 if ( !fn ) { 267 if ( !this.stack ) this.stack = []; 268 this.stack.push( this.get() ); 269 this.get( a ); 270 } else { 271 var old = this.get(); 272 this.get( a ); 273 274 if ( fn2 && a.length || !fn2 ) 275 this.each( fn2 || fn ).get( old ); 276 else 277 this.get( old ).each( fn ); 278 } 279 280 return this; 281 } 282 }; 283 284 jQuery.extend = jQuery.fn.extend = function(obj,prop) { 285 // Watch for the case where null or undefined gets passed in by accident 286 if ( arguments.length > 1 && (prop === null || prop == undefined) ) 287 return obj; 288 289 // If no property object was provided, then we're extending jQuery 290 if ( !prop ) { prop = obj; obj = this; } 291 292 // Extend the base object 293 for ( var i in prop ) obj[i] = prop[i]; 294 295 // Return the modified object 296 return obj; 297 }; 298 299 jQuery.extend({ 300 init: function(){ 301 jQuery.initDone = true; 302 303 jQuery.each( jQuery.macros.axis, function(i,n){ 304 jQuery.fn[ i ] = function(a) { 305 var ret = jQuery.map(this,n); 306 if ( a && a.constructor == String ) 307 ret = jQuery.filter(a,ret).r; 308 return this.pushStack( ret, arguments ); 309 }; 310 }); 311 312 jQuery.each( jQuery.macros.to, function(i,n){ 313 jQuery.fn[ i ] = function(){ 314 var a = arguments; 315 return this.each(function(){ 316 for ( var j = 0; j < a.length; j++ ) 317 jQuery(a[j])[n]( this ); 318 }); 319 }; 320 }); 321 322 jQuery.each( jQuery.macros.each, function(i,n){ 323 jQuery.fn[ i ] = function() { 324 return this.each( n, arguments ); 325 }; 326 }); 327 328 jQuery.each( jQuery.macros.filter, function(i,n){ 329 jQuery.fn[ n ] = function(num,fn) { 330 return this.filter( ":" + n + "(" + num + ")", fn ); 331 }; 332 }); 333 334 jQuery.each( jQuery.macros.attr, function(i,n){ 335 n = n || i; 336 jQuery.fn[ i ] = function(h) { 337 return h == undefined ? 338 this.length ? this[0][n] : null : 339 this.attr( n, h ); 340 }; 341 }); 342 343 jQuery.each( jQuery.macros.css, function(i,n){ 344 jQuery.fn[ n ] = function(h) { 345 return h == undefined ? 346 ( this.length ? jQuery.css( this[0], n ) : null ) : 347 this.css( n, h ); 348 }; 349 }); 350 351 }, 352 each: function( obj, fn, args ) { 353 if ( obj.length == undefined ) 354 for ( var i in obj ) 355 fn.apply( obj[i], args || [i, obj[i]] ); 356 else 357 for ( var i = 0; i < obj.length; i++ ) 358 if ( fn.apply( obj[i], args || [i, obj[i]] ) === false ) break; 359 return obj; 360 }, 361 362 className: { 363 add: function(o,c){ 364 if (jQuery.className.has(o,c)) return; 365 o.className += ( o.className ? " " : "" ) + c; 366 }, 367 remove: function(o,c){ 368 if( !c ) { 369 o.className = ""; 370 } else { 371 var classes = o.className.split(" "); 372 for(var i=0; i<classes.length; i++) { 373 if(classes[i] == c) { 374 classes.splice(i, 1); 375 break; 376 } 377 } 378 o.className = classes.join(' '); 379 } 380 }, 381 has: function(e,a) { 382 if ( e.className != undefined ) 383 e = e.className; 384 return new RegExp("(^|\\s)" + a + "(\\s|$)").test(e); 385 } 386 }, 387 swap: function(e,o,f) { 388 for ( var i in o ) { 389 e.style["old"+i] = e.style[i]; 390 e.style[i] = o[i]; 391 } 392 f.apply( e, [] ); 393 for ( var i in o ) 394 e.style[i] = e.style["old"+i]; 395 }, 396 397 css: function(e,p) { 398 if ( p == "height" || p == "width" ) { 399 var old = {}, oHeight, oWidth, d = ["Top","Bottom","Right","Left"]; 400 401 for ( var i in d ) { 402 old["padding" + d[i]] = 0; 403 old["border" + d[i] + "Width"] = 0; 404 } 405 406 jQuery.swap( e, old, function() { 407 if (jQuery.css(e,"display") != "none") { 408 oHeight = e.offsetHeight; 409 oWidth = e.offsetWidth; 410 } else { 411 e = jQuery(e.cloneNode(true)) 412 .find(":radio").removeAttr("checked").end() 413 .css({ 414 visibility: "hidden", position: "absolute", display: "block", right: "0", left: "0" 415 }).appendTo(e.parentNode)[0]; 416 417 var parPos = jQuery.css(e.parentNode,"position"); 418 if ( parPos == "" || parPos == "static" ) 419 e.parentNode.style.position = "relative"; 420 421 oHeight = e.clientHeight; 422 oWidth = e.clientWidth; 423 424 if ( parPos == "" || parPos == "static" ) 425 e.parentNode.style.position = "static"; 426 427 e.parentNode.removeChild(e); 428 } 429 }); 430 431 return p == "height" ? oHeight : oWidth; 432 } 433 434 return jQuery.curCSS( e, p ); 435 }, 436 437 curCSS: function(elem, prop, force) { 438 var ret; 439 440 if (prop == 'opacity' && jQuery.browser.msie) 441 return jQuery.attr(elem.style, 'opacity'); 442 443 if (prop == "float" || prop == "cssFloat") 444 prop = jQuery.browser.msie ? "styleFloat" : "cssFloat"; 445 446 if (!force && elem.style[prop]) { 447 448 ret = elem.style[prop]; 449 450 } else if (elem.currentStyle) { 451 452 var newProp = prop.replace(/\-(\w)/g,function(m,c){return c.toUpperCase();}); 453 ret = elem.currentStyle[prop] || elem.currentStyle[newProp]; 454 455 } else if (document.defaultView && document.defaultView.getComputedStyle) { 456 457 if (prop == "cssFloat" || prop == "styleFloat") 458 prop = "float"; 459 460 prop = prop.replace(/([A-Z])/g,"-$1").toLowerCase(); 461 var cur = document.defaultView.getComputedStyle(elem, null); 462 463 if ( cur ) 464 ret = cur.getPropertyValue(prop); 465 else if ( prop == 'display' ) 466 ret = 'none'; 467 else 468 jQuery.swap(elem, { display: 'block' }, function() { 469 ret = document.defaultView.getComputedStyle(this,null).getPropertyValue(prop); 470 }); 471 472 } 473 474 return ret; 475 }, 476 477 clean: function(a) { 478 var r = []; 479 for ( var i = 0; i < a.length; i++ ) { 480 var arg = a[i]; 481 if ( arg.constructor == String ) { // Convert html string into DOM nodes 482 // Trim whitespace, otherwise indexOf won't work as expected 483 var s = jQuery.trim(arg), div = document.createElement("div"), wrap = [0,"",""]; 484 485 if ( !s.indexOf("<opt") ) // option or optgroup 486 wrap = [1, "<select>", "</select>"]; 487 else if ( !s.indexOf("<thead") || !s.indexOf("<tbody") ) 488 wrap = [1, "<table>", "</table>"]; 489 else if ( !s.indexOf("<tr") ) 490 wrap = [2, "<table>", "</table>"]; // tbody auto-inserted 491 else if ( !s.indexOf("<td") || !s.indexOf("<th") ) 492 wrap = [3, "<table><tbody><tr>", "</tr></tbody></table>"]; 493 494 // Go to html and back, then peel off extra wrappers 495 div.innerHTML = wrap[1] + s + wrap[2]; 496 while ( wrap[0]-- ) div = div.firstChild; 497 498 // Have to loop through the childNodes here to 499 // prevent a Safari crash with text nodes and /n characters 500 for ( var j = 0; j < div.childNodes.length; j++ ) 501 r.push( div.childNodes[j] ); 502 } 503 else if ( arg.length != undefined && !arg.nodeType ) // Handles Array, jQuery, DOM NodeList collections 504 for ( var n = 0; n < arg.length; n++ ) 505 r.push(arg[n]); 506 else 507 r.push( arg.nodeType ? arg : document.createTextNode(arg.toString()) ); 508 } 509 510 return r; 511 }, 512 513 expr: { 514 "": "m[2]== '*'||a.nodeName.toUpperCase()==m[2].toUpperCase()", 515 "#": "a.getAttribute('id')&&a.getAttribute('id')==m[2]", 516 ":": { 517 // Position Checks 518 lt: "i<m[3]-0", 519 gt: "i>m[3]-0", 520 nth: "m[3]-0==i", 521 eq: "m[3]-0==i", 522 first: "i==0", 523 last: "i==r.length-1", 524 even: "i%2==0", 525 odd: "i%2", 526 527 // Child Checks 528 "nth-child": "jQuery.sibling(a,m[3]).cur", 529 "first-child": "jQuery.sibling(a,0).cur", 530 "last-child": "jQuery.sibling(a,0).last", 531 "only-child": "jQuery.sibling(a).length==1", 532 533 // Parent Checks 534 parent: "a.childNodes.length", 535 empty: "!a.childNodes.length", 536 537 // Text Check 538 contains: "jQuery.fn.text.apply([a]).indexOf(m[3])>=0", 539 540 // Visibility 541 visible: "a.type!='hidden'&&jQuery.css(a,'display')!='none'&&jQuery.css(a,'visibility')!='hidden'", 542 hidden: "a.type=='hidden'||jQuery.css(a,'display')=='none'||jQuery.css(a,'visibility')=='hidden'", 543 544 // Form attributes 545 enabled: "!a.disabled", 546 disabled: "a.disabled", 547 checked: "a.checked", 548 selected: "a.selected || jQuery.attr(a, 'selected')", 549 550 // Form elements 551 text: "a.type=='text'", 552 radio: "a.type=='radio'", 553 checkbox: "a.type=='checkbox'", 554 file: "a.type=='file'", 555 password: "a.type=='password'", 556 submit: "a.type=='submit'", 557 image: "a.type=='image'", 558 reset: "a.type=='reset'", 559 button: "a.type=='button'", 560 input: "a.nodeName.toLowerCase().match(/input|select|textarea|button/)" 561 }, 562 ".": "jQuery.className.has(a,m[2])", 563 "@": { 564 "=": "z==m[4]", 565 "!=": "z!=m[4]", 566 "^=": "z && !z.indexOf(m[4])", 567 "$=": "z && z.substr(z.length - m[4].length,m[4].length)==m[4]", 568 "*=": "z && z.indexOf(m[4])>=0", 569 "": "z" 570 }, 571 "[": "jQuery.find(m[2],a).length" 572 }, 573 574 token: [ 575 "\\.\\.|/\\.\\.", "a.parentNode", 576 ">|/", "jQuery.sibling(a.firstChild)", 577 "\\+", "jQuery.sibling(a).next", 578 "~", function(a){ 579 var r = []; 580 var s = jQuery.sibling(a); 581 if ( s.n > 0 ) 582 for ( var i = s.n; i < s.length; i++ ) 583 r.push( s[i] ); 584 return r; 585 } 586 ], 587 find: function( t, context ) { 588 // Make sure that the context is a DOM Element 589 if ( context && context.nodeType == undefined ) 590 context = null; 591 592 // Set the correct context (if none is provided) 593 context = context || jQuery.context || document; 594 595 if ( t.constructor != String ) return [t]; 596 597 if ( !t.indexOf("//") ) { 598 context = context.documentElement; 599 t = t.substr(2,t.length); 600 } else if ( !t.indexOf("/") ) { 601 context = context.documentElement; 602 t = t.substr(1,t.length); 603 // FIX Assume the root element is right :( 604 if ( t.indexOf("/") >= 1 ) 605 t = t.substr(t.indexOf("/"),t.length); 606 } 607 608 var ret = [context]; 609 var done = []; 610 var last = null; 611 612 while ( t.length > 0 && last != t ) { 613 var r = []; 614 last = t; 615 616 t = jQuery.trim(t).replace( /^\/\//i, "" ); 617 618 var foundToken = false; 619 620 for ( var i = 0; i < jQuery.token.length; i += 2 ) { 621 if ( foundToken ) continue; 622 623 var re = new RegExp("^(" + jQuery.token[i] + ")"); 624 var m = re.exec(t); 625 626 if ( m ) { 627 r = ret = jQuery.map( ret, jQuery.token[i+1] ); 628 t = jQuery.trim( t.replace( re, "" ) ); 629 foundToken = true; 630 } 631 } 632 633 if ( !foundToken ) { 634 if ( !t.indexOf(",") || !t.indexOf("|") ) { 635 if ( ret[0] == context ) ret.shift(); 636 done = jQuery.merge( done, ret ); 637 r = ret = [context]; 638 t = " " + t.substr(1,t.length); 639 } else { 640 var re2 = /^([#.]?)([a-z0-9\\*_-]*)/i; 641 var m = re2.exec(t); 642 643 if ( m[1] == "#" ) { 644 // Ummm, should make this work in all XML docs 645 var oid = document.getElementById(m[2]); 646 r = ret = oid ? [oid] : []; 647 t = t.replace( re2, "" ); 648 } else { 649 if ( !m[2] || m[1] == "." ) m[2] = "*"; 650 651 for ( var i = 0; i < ret.length; i++ ) 652 r = jQuery.merge( r, 653 m[2] == "*" ? 654 jQuery.getAll(ret[i]) : 655 ret[i].getElementsByTagName(m[2]) 656 ); 657 } 658 } 659 660 } 661 662 if ( t ) { 663 var val = jQuery.filter(t,r); 664 ret = r = val.r; 665 t = jQuery.trim(val.t); 666 } 667 } 668 669 if ( ret && ret[0] == context ) ret.shift(); 670 done = jQuery.merge( done, ret ); 671 672 return done; 673 }, 674 675 getAll: function(o,r) { 676 r = r || []; 677 var s = o.childNodes; 678 for ( var i = 0; i < s.length; i++ ) 679 if ( s[i].nodeType == 1 ) { 680 r.push( s[i] ); 681 jQuery.getAll( s[i], r ); 682 } 683 return r; 684 }, 685 686 attr: function(elem, name, value){ 687 var fix = { 688 "for": "htmlFor", 689 "class": "className", 690 "float": jQuery.browser.msie ? "styleFloat" : "cssFloat", 691 cssFloat: jQuery.browser.msie ? "styleFloat" : "cssFloat", 692 innerHTML: "innerHTML", 693 className: "className", 694 value: "value", 695 disabled: "disabled", 696 checked: "checked", 697 readonly: "readOnly" 698 }; 699 700 // IE actually uses filters for opacity ... elem is actually elem.style 701 if (name == "opacity" && jQuery.browser.msie && value != undefined) { 702 // IE has trouble with opacity if it does not have layout 703 // Would prefer to check element.hasLayout first but don't have access to the element here 704 elem['zoom'] = 1; 705 if (value == 1) // Remove filter to avoid more IE weirdness 706 return elem["filter"] = elem["filter"].replace(/alpha\([^\)]*\)/gi,""); 707 else 708 return elem["filter"] = elem["filter"].replace(/alpha\([^\)]*\)/gi,"") + "alpha(opacity=" + value * 100 + ")"; 709 } else if (name == "opacity" && jQuery.browser.msie) { 710 return elem["filter"] ? parseFloat( elem["filter"].match(/alpha\(opacity=(.*)\)/)[1] )/100 : 1; 711 } 712 713 // Mozilla doesn't play well with opacity 1 714 if (name == "opacity" && jQuery.browser.mozilla && value == 1) value = 0.9999; 715 716 if ( fix[name] ) { 717 if ( value != undefined ) elem[fix[name]] = value; 718 return elem[fix[name]]; 719 } else if( value == undefined && jQuery.browser.msie && elem.nodeName && elem.nodeName.toUpperCase() == 'FORM' && (name == 'action' || name == 'method') ) { 720 return elem.getAttributeNode(name).nodeValue; 721 } else if ( elem.tagName ) { // IE elem.getAttribute passes even for style 722 if ( value != undefined ) elem.setAttribute( name, value ); 723 return elem.getAttribute( name ); 724 } else { 725 name = name.replace(/-([a-z])/ig,function(z,b){return b.toUpperCase();}); 726 if ( value != undefined ) elem[name] = value; 727 return elem[name]; 728 } 729 }, 730 731 // The regular expressions that power the parsing engine 732 parse: [ 733 // Match: [@value='test'], [@foo] 734 "\\[ *(@)S *([!*$^=]*) *('?\"?)(.*?)\\4 *\\]", 735 736 // Match: [div], [div p] 737 "(\\[)\s*(.*?)\s*\\]", 738 739 // Match: :contains('foo') 740 "(:)S\\(\"?'?([^\\)]*?)\"?'?\\)", 741 742 // Match: :even, :last-chlid 743 "([:.#]*)S" 744 ], 745 746 filter: function(t,r,not) { 747 // Figure out if we're doing regular, or inverse, filtering 748 var g = not !== false ? jQuery.grep : 749 function(a,f) {return jQuery.grep(a,f,true);}; 750 751 while ( t && /^[a-z[({<*:.#]/i.test(t) ) { 752 753 var p = jQuery.parse; 754 755 for ( var i = 0; i < p.length; i++ ) { 756 757 // Look for, and replace, string-like sequences 758 // and finally build a regexp out of it 759 var re = new RegExp( 760 "^" + p[i].replace("S", "([a-z*_-][a-z0-9_-]*)"), "i" ); 761 762 var m = re.exec( t ); 763 764 if ( m ) { 765 // Re-organize the first match 766 if ( !i ) 767 m = ["",m[1], m[3], m[2], m[5]]; 768 769 // Remove what we just matched 770 t = t.replace( re, "" ); 771 772 break; 773 } 774 } 775 776 // :not() is a special case that can be optimized by 777 // keeping it out of the expression list 778 if ( m[1] == ":" && m[2] == "not" ) 779 r = jQuery.filter(m[3],r,false).r; 780 781 // Otherwise, find the expression to execute 782 else { 783 var f = jQuery.expr[m[1]]; 784 if ( f.constructor != String ) 785 f = jQuery.expr[m[1]][m[2]]; 786 787 // Build a custom macro to enclose it 788 eval("f = function(a,i){" + 789 ( m[1] == "@" ? "z=jQuery.attr(a,m[3]);" : "" ) + 790 "return " + f + "}"); 791 792 // Execute it against the current filter 793 r = g( r, f ); 794 } 795 } 796 797 // Return an array of filtered elements (r) 798 // and the modified expression string (t) 799 return { r: r, t: t }; 800 }, 801 trim: function(t){ 802 return t.replace(/^\s+|\s+$/g, ""); 803 }, 804 parents: function( elem ){ 805 var matched = []; 806 var cur = elem.parentNode; 807 while ( cur && cur != document ) { 808 matched.push( cur ); 809 cur = cur.parentNode; 810 } 811 return matched; 812 }, 813 sibling: function(elem, pos, not) { 814 var elems = []; 815 816 if(elem) { 817 var siblings = elem.parentNode.childNodes; 818 for ( var i = 0; i < siblings.length; i++ ) { 819 if ( not === true && siblings[i] == elem ) continue; 820 821 if ( siblings[i].nodeType == 1 ) 822 elems.push( siblings[i] ); 823 if ( siblings[i] == elem ) 824 elems.n = elems.length - 1; 825 } 826 } 827 828 return jQuery.extend( elems, { 829 last: elems.n == elems.length - 1, 830 cur: pos == "even" && elems.n % 2 == 0 || pos == "odd" && elems.n % 2 || elems[pos] == elem, 831 prev: elems[elems.n - 1], 832 next: elems[elems.n + 1] 833 }); 834 }, 835 merge: function(first, second) { 836 var result = []; 837 838 // Move b over to the new array (this helps to avoid 839 // StaticNodeList instances) 840 for ( var k = 0; k < first.length; k++ ) 841 result[k] = first[k]; 842 843 // Now check for duplicates between a and b and only 844 // add the unique items 845 for ( var i = 0; i < second.length; i++ ) { 846 var noCollision = true; 847 848 // The collision-checking process 849 for ( var j = 0; j < first.length; j++ ) 850 if ( second[i] == first[j] ) 851 noCollision = false; 852 853 // If the item is unique, add it 854 if ( noCollision ) 855 result.push( second[i] ); 856 } 857 858 return result; 859 }, 860 grep: function(elems, fn, inv) { 861 // If a string is passed in for the function, make a function 862 // for it (a handy shortcut) 863 if ( fn.constructor == String ) 864 fn = new Function("a","i","return " + fn); 865 866 var result = []; 867 868 // Go through the array, only saving the items 869 // that pass the validator function 870 for ( var i = 0; i < elems.length; i++ ) 871 if ( !inv && fn(elems[i],i) || inv && !fn(elems[i],i) ) 872 result.push( elems[i] ); 873 874 return result; 875 }, 876 map: function(elems, fn) { 877 // If a string is passed in for the function, make a function 878 // for it (a handy shortcut) 879 if ( fn.constructor == String ) 880 fn = new Function("a","return " + fn); 881 882 var result = []; 883 884 // Go through the array, translating each of the items to their 885 // new value (or values). 886 for ( var i = 0; i < elems.length; i++ ) { 887 var val = fn(elems[i],i); 888 889 if ( val !== null && val != undefined ) { 890 if ( val.constructor != Array ) val = [val]; 891 result = jQuery.merge( result, val ); 892 } 893 } 894 895 return result; 896 }, 897 898 /* 899 * A number of helper functions used for managing events. 900 * Many of the ideas behind this code orignated from Dean Edwards' addEvent library. 901 */ 902 event: { 903 904 // Bind an event to an element 905 // Original by Dean Edwards 906 add: function(element, type, handler) { 907 // For whatever reason, IE has trouble passing the window object 908 // around, causing it to be cloned in the process 909 if ( jQuery.browser.msie && element.setInterval != undefined ) 910 element = window; 911 912 // Make sure that the function being executed has a unique ID 913 if ( !handler.guid ) 914 handler.guid = this.guid++; 915 916 // Init the element's event structure 917 if (!element.events) 918 element.events = {}; 919 920 // Get the current list of functions bound to this event 921 var handlers = element.events[type]; 922 923 // If it hasn't been initialized yet 924 if (!handlers) { 925 // Init the event handler queue 926 handlers = element.events[type] = {}; 927 928 // Remember an existing handler, if it's already there 929 if (element["on" + type]) 930 handlers[0] = element["on" + type]; 931 } 932 933 // Add the function to the element's handler list 934 handlers[handler.guid] = handler; 935 936 // And bind the global event handler to the element 937 element["on" + type] = this.handle; 938 939 // Remember the function in a global list (for triggering) 940 if (!this.global[type]) 941 this.global[type] = []; 942 this.global[type].push( element ); 943 }, 944 945 guid: 1, 946 global: {}, 947 948 // Detach an event or set of events from an element 949 remove: function(element, type, handler) { 950 if (element.events) 951 if (type && element.events[type]) 952 if ( handler ) 953 delete element.events[type][handler.guid]; 954 else 955 for ( var i in element.events[type] ) 956 delete element.events[type][i]; 957 else 958 for ( var j in element.events ) 959 this.remove( element, j ); 960 }, 961 962 trigger: function(type,data,element) { 963 // Touch up the incoming data 964 data = data || []; 965 966 // Handle a global trigger 967 if ( !element ) { 968 var g = this.global[type]; 969 if ( g ) 970 for ( var i = 0; i < g.length; i++ ) 971 this.trigger( type, data, g[i] ); 972 973 // Handle triggering a single element 974 } else if ( element["on" + type] ) { 975 // Pass along a fake event 976 data.unshift( this.fix({ type: type, target: element }) ); 977 978 // Trigger the event 979 element["on" + type].apply( element, data ); 980 } 981 }, 982 983 handle: function(event) { 984 if ( typeof jQuery == "undefined" ) return false; 985 986 event = event || jQuery.event.fix( window.event ); 987 988 // If no correct event was found, fail 989 if ( !event ) return false; 990 991 var returnValue = true; 992 993 var c = this.events[event.type]; 994 995 var args = [].slice.call( arguments, 1 ); 996 args.unshift( event ); 997 998 for ( var j in c ) { 999 if ( c[j].apply( this, args ) === false ) { 1000 event.preventDefault(); 1001 event.stopPropagation(); 1002 returnValue = false; 1003 } 1004 } 1005 1006 return returnValue; 1007 }, 1008 1009 fix: function(event) { 1010 // check IE 1011 if(jQuery.browser.msie) { 1012 // get real event from window.event 1013 event = window.event; 1014 // fix target property 1015 event.target = event.srcElement; 1016 // check safari and if target is a textnode 1017 } else if(jQuery.browser.safari && event.target.nodeType == 3) { 1018 // target is readonly, clone the event object 1019 event = jQuery.extend({}, event); 1020 // get parentnode from textnode 1021 event.target = event.target.parentNode; 1022 } 1023 // fix preventDefault and stopPropagation 1024 event.preventDefault = function() { 1025 this.returnValue = false; 1026 }; 1027 event.stopPropagation = function() { 1028 this.cancelBubble = true; 1029 }; 1030 return event; 1031 } 1032 1033 } 1034 }); 1035 new function() { 1036 var b = navigator.userAgent.toLowerCase(); 1037 1038 // Figure out what browser is being used 1039 jQuery.browser = { 1040 safari: /webkit/.test(b), 1041 opera: /opera/.test(b), 1042 msie: /msie/.test(b) && !/opera/.test(b), 1043 mozilla: /mozilla/.test(b) && !/(compatible|webkit)/.test(b) 1044 }; 1045 1046 // Check to see if the W3C box model is being used 1047 jQuery.boxModel = !jQuery.browser.msie || document.compatMode == "CSS1Compat"; 1048 }; 1049 1050 jQuery.macros = { 1051 to: { 1052 appendTo: "append", 1053 prependTo: "prepend", 1054 insertBefore: "before", 1055 insertAfter: "after" 1056 }, 1057 1058 css: "width,height,top,left,position,float,overflow,color,background".split(","), 1059 1060 filter: [ "eq", "lt", "gt", "contains" ], 1061 1062 attr: { 1063 1064 val: "value", 1065 1066 html: "innerHTML", 1067 1068 id: null, 1069 1070 title: null, 1071 1072 name: null, 1073 1074 href: null, 1075 1076 src: null, 1077 1078 rel: null 1079 }, 1080 1081 axis: { 1082 1083 parent: "a.parentNode", 1084 1085 ancestors: jQuery.parents, 1086 1087 parents: jQuery.parents, 1088 1089 next: "jQuery.sibling(a).next", 1090 1091 prev: "jQuery.sibling(a).prev", 1092 1093 siblings: "jQuery.sibling(a, null, true)", 1094 1095 children: "jQuery.sibling(a.firstChild)" 1096 }, 1097 1098 each: { 1099 removeAttr: function( key ) { 1100 this.removeAttribute( key ); 1101 }, 1102 show: function(){ 1103 this.style.display = this.oldblock ? this.oldblock : ""; 1104 if ( jQuery.css(this,"display") == "none" ) 1105 this.style.display = "block"; 1106 }, 1107 hide: function(){ 1108 this.oldblock = this.oldblock || jQuery.css(this,"display"); 1109 if ( this.oldblock == "none" ) 1110 this.oldblock = "block"; 1111 this.style.display = "none"; 1112 }, 1113 toggle: function(){ 1114 jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ].apply( jQuery(this), arguments ); 1115 }, 1116 addClass: function(c){ 1117 jQuery.className.add(this,c); 1118 }, 1119 removeClass: function(c){ 1120 jQuery.className.remove(this,c); 1121 }, 1122 toggleClass: function( c ){ 1123 jQuery.className[ jQuery.className.has(this,c) ? "remove" : "add" ](this,c); 1124 }, 1125 1126 remove: function(a){ 1127 if ( !a || jQuery.filter( a, [this] ).r ) 1128 this.parentNode.removeChild( this ); 1129 }, 1130 empty: function(){ 1131 while ( this.firstChild ) 1132 this.removeChild( this.firstChild ); 1133 }, 1134 bind: function( type, fn ) { 1135 if ( fn.constructor == String ) 1136 fn = new Function("e", ( !fn.indexOf(".") ? "jQuery(this)" : "return " ) + fn); 1137 jQuery.event.add( this, type, fn ); 1138 }, 1139 1140 unbind: function( type, fn ) { 1141 jQuery.event.remove( this, type, fn ); 1142 }, 1143 trigger: function( type, data ) { 1144 jQuery.event.trigger( type, data, this ); 1145 } 1146 } 1147 }; 1148 1149 jQuery.init(); 1150 jQuery.fn.extend({ 1151 1152 // We're overriding the old toggle function, so 1153 // remember it for later 1154 _toggle: jQuery.fn.toggle, 1155 toggle: function(a,b) { 1156 // If two functions are passed in, we're 1157 // toggling on a click 1158 return a && b && a.constructor == Function && b.constructor == Function ? this.click(function(e){ 1159 // Figure out which function to execute 1160 this.last = this.last == a ? b : a; 1161 1162 // Make sure that clicks stop 1163 e.preventDefault(); 1164 1165 // and execute the function 1166 return this.last.apply( this, [e] ) || false; 1167 }) : 1168 1169 // Otherwise, execute the old toggle function 1170 this._toggle.apply( this, arguments ); 1171 }, 1172 hover: function(f,g) { 1173 1174 // A private function for haandling mouse 'hovering' 1175 function handleHover(e) { 1176 // Check if mouse(over|out) are still within the same parent element 1177 var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget; 1178 1179 // Traverse up the tree 1180 while ( p && p != this ) try { p = p.parentNode } catch(e) { p = this; }; 1181 1182 // If we actually just moused on to a sub-element, ignore it 1183 if ( p == this ) return false; 1184 1185 // Execute the right function 1186 return (e.type == "mouseover" ? f : g).apply(this, [e]); 1187 } 1188 1189 // Bind the function to the two event listeners 1190 return this.mouseover(handleHover).mouseout(handleHover); 1191 }, 1192 ready: function(f) { 1193 // If the DOM is already ready 1194 if ( jQuery.isReady ) 1195 // Execute the function immediately 1196 f.apply( document ); 1197 1198 // Otherwise, remember the function for later 1199 else { 1200 // Add the function to the wait list 1201 jQuery.readyList.push( f ); 1202 } 1203 1204 return this; 1205 } 1206 }); 1207 1208 jQuery.extend({ 1209 /* 1210 * All the code that makes DOM Ready work nicely. 1211 */ 1212 isReady: false, 1213 readyList: [], 1214 1215 // Handle when the DOM is ready 1216 ready: function() { 1217 // Make sure that the DOM is not already loaded 1218 if ( !jQuery.isReady ) { 1219 // Remember that the DOM is ready 1220 jQuery.isReady = true; 1221 1222 // If there are functions bound, to execute 1223 if ( jQuery.readyList ) { 1224 // Execute all of them 1225 for ( var i = 0; i < jQuery.readyList.length; i++ ) 1226 jQuery.readyList[i].apply( document ); 1227 1228 // Reset the list of functions 1229 jQuery.readyList = null; 1230 } 1231 // Remove event lisenter to avoid memory leak 1232 if ( jQuery.browser.mozilla || jQuery.browser.opera ) 1233 document.removeEventListener( "DOMContentLoaded", jQuery.ready, false ); 1234 } 1235 } 1236 }); 1237 1238 new function(){ 1239 1240 var e = ("blur,focus,load,resize,scroll,unload,click,dblclick," + 1241 "mousedown,mouseup,mousemove,mouseover,mouseout,change,reset,select," + 1242 "submit,keydown,keypress,keyup,error").split(","); 1243 1244 // Go through all the event names, but make sure that 1245 // it is enclosed properly 1246 for ( var i = 0; i < e.length; i++ ) new function(){ 1247 1248 var o = e[i]; 1249 1250 // Handle event binding 1251 jQuery.fn[o] = function(f){ 1252 return f ? this.bind(o, f) : this.trigger(o); 1253 }; 1254 1255 // Handle event unbinding 1256 jQuery.fn["un"+o] = function(f){ return this.unbind(o, f); }; 1257 1258 // Finally, handle events that only fire once 1259 jQuery.fn["one"+o] = function(f){ 1260 // save cloned reference to this 1261 var element = jQuery(this); 1262 var handler = function() { 1263 // unbind itself when executed 1264 element.unbind(o, handler); 1265 element = null; 1266 // apply original handler with the same arguments 1267 f.apply(this, arguments); 1268 }; 1269 return this.bind(o, handler); 1270 }; 1271 1272 }; 1273 1274 // If Mozilla is used 1275 if ( jQuery.browser.mozilla || jQuery.browser.opera ) { 1276 // Use the handy event callback 1277 document.addEventListener( "DOMContentLoaded", jQuery.ready, false ); 1278 1279 // If IE is used, use the excellent hack by Matthias Miller 1280 // http://www.outofhanwell.com/blog/index.php?title=the_window_onload_problem_revisited 1281 } else if ( jQuery.browser.msie ) { 1282 1283 // Only works if you document.write() it 1284 document.write("<scr" + "ipt id=__ie_init defer=true " + 1285 "src=//:><\/script>"); 1286 1287 // Use the defer script hack 1288 var script = document.getElementById("__ie_init"); 1289 script.onreadystatechange = function() { 1290 if ( this.readyState != "complete" ) return; 1291 this.parentNode.removeChild( this ); 1292 jQuery.ready(); 1293 }; 1294 1295 // Clear from memory 1296 script = null; 1297 1298 // If Safari is used 1299 } else if ( jQuery.browser.safari ) { 1300 // Continually check to see if the document.readyState is valid 1301 jQuery.safariTimer = setInterval(function(){ 1302 // loaded and complete are both valid states 1303 if ( document.readyState == "loaded" || 1304 document.readyState == "complete" ) { 1305 1306 // If either one are found, remove the timer 1307 clearInterval( jQuery.safariTimer ); 1308 jQuery.safariTimer = null; 1309 1310 // and execute any waiting functions 1311 jQuery.ready(); 1312 } 1313 }, 10); 1314 } 1315 1316 // A fallback to window.onload, that will always work 1317 jQuery.event.add( window, "load", jQuery.ready ); 1318 1319 }; 1320 1321 // Clean up after IE to avoid memory leaks 1322 if (jQuery.browser.msie) jQuery(window).unload(function() { 1323 var event = jQuery.event, global = event.global; 1324 for (var type in global) { 1325 var els = global[type], i = els.length; 1326 if (i>0) do if (type != 'unload') event.remove(els[i-1], type); while (--i); 1327 } 1328 }); 1329 jQuery.fn.extend({ 1330 1331 // overwrite the old show method 1332 _show: jQuery.fn.show, 1333 1334 show: function(speed,callback){ 1335 return speed ? this.animate({ 1336 height: "show", width: "show", opacity: "show" 1337 }, speed, callback) : this._show(); 1338 }, 1339 1340 // Overwrite the old hide method 1341 _hide: jQuery.fn.hide, 1342 1343 hide: function(speed,callback){ 1344 return speed ? this.animate({ 1345 height: "hide", width: "hide", opacity: "hide" 1346 }, speed, callback) : this._hide(); 1347 }, 1348 1349 slideDown: function(speed,callback){ 1350 return this.animate({height: "show"}, speed, callback); 1351 }, 1352 1353 slideUp: function(speed,callback){ 1354 return this.animate({height: "hide"}, speed, callback); 1355 }, 1356 1357 slideToggle: function(speed,callback){ 1358 return this.each(function(){ 1359 var state = jQuery(this).is(":hidden") ? "show" : "hide"; 1360 jQuery(this).animate({height: state}, speed, callback); 1361 }); 1362 }, 1363 1364 fadeIn: function(speed,callback){ 1365 return this.animate({opacity: "show"}, speed, callback); 1366 }, 1367 1368 fadeOut: function(speed,callback){ 1369 return this.animate({opacity: "hide"}, speed, callback); 1370 }, 1371 1372 fadeTo: function(speed,to,callback){ 1373 return this.animate({opacity: to}, speed, callback); 1374 }, 1375 animate: function(prop,speed,callback) { 1376 return this.queue(function(){ 1377 1378 this.curAnim = jQuery.extend({}, prop); 1379 1380 for ( var p in prop ) { 1381 var e = new jQuery.fx( this, jQuery.speed(speed,callback), p ); 1382 if ( prop[p].constructor == Number ) 1383 e.custom( e.cur(), prop[p] ); 1384 else 1385 e[ prop[p] ]( prop ); 1386 } 1387 1388 }); 1389 }, 1390 queue: function(type,fn){ 1391 if ( !fn ) { 1392 fn = type; 1393 type = "fx"; 1394 } 1395 1396 return this.each(function(){ 1397 if ( !this.queue ) 1398 this.queue = {}; 1399 1400 if ( !this.queue[type] ) 1401 this.queue[type] = []; 1402 1403 this.queue[type].push( fn ); 1404 1405 if ( this.queue[type].length == 1 ) 1406 fn.apply(this); 1407 }); 1408 } 1409 1410 }); 1411 1412 jQuery.extend({ 1413 1414 setAuto: function(e,p) { 1415 if ( e.notAuto ) return; 1416 1417 if ( p == "height" && e.scrollHeight != parseInt(jQuery.curCSS(e,p)) ) return; 1418 if ( p == "width" && e.scrollWidth != parseInt(jQuery.curCSS(e,p)) ) return; 1419 1420 // Remember the original height 1421 var a = e.style[p]; 1422 1423 // Figure out the size of the height right now 1424 var o = jQuery.curCSS(e,p,1); 1425 1426 if ( p == "height" && e.scrollHeight != o || 1427 p == "width" && e.scrollWidth != o ) return; 1428 1429 // Set the height to auto 1430 e.style[p] = e.currentStyle ? "" : "auto"; 1431 1432 // See what the size of "auto" is 1433 var n = jQuery.curCSS(e,p,1); 1434 1435 // Revert back to the original size 1436 if ( o != n && n != "auto" ) { 1437 e.style[p] = a; 1438 e.notAuto = true; 1439 } 1440 }, 1441 1442 speed: function(s,o) { 1443 o = o || {}; 1444 1445 if ( o.constructor == Function ) 1446 o = { complete: o }; 1447 1448 var ss = { slow: 600, fast: 200 }; 1449 o.duration = (s && s.constructor == Number ? s : ss[s]) || 400; 1450 1451 // Queueing 1452 o.oldComplete = o.complete; 1453 o.complete = function(){ 1454 jQuery.dequeue(this, "fx"); 1455 if ( o.oldComplete && o.oldComplete.constructor == Function ) 1456 o.oldComplete.apply( this ); 1457 }; 1458 1459 return o; 1460 }, 1461 1462 queue: {}, 1463 1464 dequeue: function(elem,type){ 1465 type = type || "fx"; 1466 1467 if ( elem.queue && elem.queue[type] ) { 1468 // Remove self 1469 elem.queue[type].shift(); 1470 1471 // Get next function 1472 var f = elem.queue[type][0]; 1473 1474 if ( f ) f.apply( elem ); 1475 } 1476 }, 1477 1478 /* 1479 * I originally wrote fx() as a clone of moo.fx and in the process 1480 * of making it small in size the code became illegible to sane 1481 * people. You've been warned. 1482 */ 1483 1484 fx: function( elem, options, prop ){ 1485 1486 var z = this; 1487 1488 // The users options 1489 z.o = { 1490 duration: options.duration || 400, 1491 complete: options.complete, 1492 step: options.step 1493 }; 1494 1495 // The element 1496 z.el = elem; 1497 1498 // The styles 1499 var y = z.el.style; 1500 1501 // Simple function for setting a style value 1502 z.a = function(){ 1503 if ( options.step ) 1504 options.step.apply( elem, [ z.now ] ); 1505 1506 if ( prop == "opacity" ) 1507 jQuery.attr(y, "opacity", z.now); // Let attr handle opacity 1508 else if ( parseInt(z.now) ) // My hate for IE will never die 1509 y[prop] = parseInt(z.now) + "px"; 1510 1511 y.display = "block"; 1512 }; 1513 1514 // Figure out the maximum number to run to 1515 z.max = function(){ 1516 return parseFloat( jQuery.css(z.el,prop) ); 1517 }; 1518 1519 // Get the current size 1520 z.cur = function(){ 1521 var r = parseFloat( jQuery.curCSS(z.el, prop) ); 1522 return r && r > -10000 ? r : z.max(); 1523 }; 1524 1525 // Start an animation from one number to another 1526 z.custom = function(from,to){ 1527 z.startTime = (new Date()).getTime(); 1528 z.now = from; 1529 z.a(); 1530 1531 z.timer = setInterval(function(){ 1532 z.step(from, to); 1533 }, 13); 1534 }; 1535 1536 // Simple 'show' function 1537 z.show = function(){ 1538 if ( !z.el.orig ) z.el.orig = {}; 1539 1540 // Remember where we started, so that we can go back to it later 1541 z.el.orig[prop] = this.cur(); 1542 1543 // Begin the animation 1544 z.custom(0, z.el.orig[prop]); 1545 1546 // Stupid IE, look what you made me do 1547 if ( prop != "opacity" ) 1548 y[prop] = "1px"; 1549 }; 1550 1551 // Simple 'hide' function 1552 z.hide = function(){ 1553 if ( !z.el.orig ) z.el.orig = {}; 1554 1555 // Remember where we started, so that we can go back to it later 1556 z.el.orig[prop] = this.cur(); 1557 1558 z.o.hide = true; 1559 1560 // Begin the animation 1561 z.custom(z.el.orig[prop], 0); 1562 }; 1563 1564 // Remember the overflow of the element 1565 if ( !z.el.oldOverflow ) 1566 z.el.oldOverflow = jQuery.css( z.el, "overflow" ); 1567 1568 // Make sure that nothing sneaks out 1569 y.overflow = "hidden"; 1570 1571 // Each step of an animation 1572 z.step = function(firstNum, lastNum){ 1573 var t = (new Date()).getTime(); 1574 1575 if (t > z.o.duration + z.startTime) { 1576 // Stop the timer 1577 clearInterval(z.timer); 1578 z.timer = null; 1579 1580 z.now = lastNum; 1581 z.a(); 1582 1583 z.el.curAnim[ prop ] = true; 1584 1585 var done = true; 1586 for ( var i in z.el.curAnim ) 1587 if ( z.el.curAnim[i] !== true ) 1588 done = false; 1589 1590 if ( done ) { 1591 // Reset the overflow 1592 y.overflow = z.el.oldOverflow; 1593 1594 // Hide the element if the "hide" operation was done 1595 if ( z.o.hide ) 1596 y.display = 'none'; 1597 1598 // Reset the property, if the item has been hidden 1599 if ( z.o.hide ) { 1600 for ( var p in z.el.curAnim ) { 1601 if (p == "opacity") 1602 jQuery.attr(y, p, z.el.orig[p]); 1603 else 1604 y[ p ] = z.el.orig[p] + "px"; 1605 1606 // set its height and/or width to auto 1607 if ( p == 'height' || p == 'width' ) 1608 jQuery.setAuto( z.el, p ); 1609 } 1610 } 1611 } 1612 1613 // If a callback was provided, execute it 1614 if( done && z.o.complete && z.o.complete.constructor == Function ) 1615 // Execute the complete function 1616 z.o.complete.apply( z.el ); 1617 } else { 1618 // Figure out where in the animation we are and set the number 1619 var p = (t - this.startTime) / z.o.duration; 1620 z.now = ((-Math.cos(p*Math.PI)/2) + 0.5) * (lastNum-firstNum) + firstNum; 1621 1622 // Perform the next step of the animation 1623 z.a(); 1624 } 1625 }; 1626 1627 } 1628 1629 }); 1630 jQuery.fn.extend({ 1631 loadIfModified: function( url, params, callback ) { 1632 this.load( url, params, callback, 1 ); 1633 }, 1634 load: function( url, params, callback, ifModified ) { 1635 if ( url.constructor == Function ) 1636 return this.bind("load", url); 1637 1638 callback = callback || function(){}; 1639 1640 // Default to a GET request 1641 var type = "GET"; 1642 1643 // If the second parameter was provided 1644 if ( params ) { 1645 // If it's a function 1646 if ( params.constructor == Function ) { 1647 // We assume that it's the callback 1648 callback = params; 1649 params = null; 1650 1651 // Otherwise, build a param string 1652 } else { 1653 params = jQuery.param( params ); 1654 type = "POST"; 1655 } 1656 } 1657 1658 var self = this; 1659 1660 // Request the remote document 1661 jQuery.ajax( type, url, params,function(res, status){ 1662 1663 if ( status == "success" || !ifModified && status == "notmodified" ) { 1664 // Inject the HTML into all the matched elements 1665 self.html(res.responseText) 1666 // Execute all the scripts inside of the newly-injected HTML 1667 .evalScripts() 1668 // Execute callback 1669 .each( callback, [res.responseText, status] ); 1670 } else 1671 callback.apply( self, [res.responseText, status] ); 1672 1673 }, ifModified); 1674 1675 return this; 1676 }, 1677 serialize: function() { 1678 return jQuery.param( this ); 1679 }, 1680 1681 evalScripts: function() { 1682 return this.find('script').each(function(){ 1683 if ( this.src ) 1684 // for some weird reason, it doesn't work if the callback is ommited 1685 jQuery.getScript( this.src, function() {} ); 1686 else 1687 eval.call( window, this.text || this.textContent || this.innerHTML || "" ); 1688 }).end(); 1689 } 1690 1691 }); 1692 1693 // If IE is used, create a wrapper for the XMLHttpRequest object 1694 if ( jQuery.browser.msie && typeof XMLHttpRequest == "undefined" ) 1695 XMLHttpRequest = function(){ 1696 return new ActiveXObject( 1697 navigator.userAgent.indexOf("MSIE 5") >= 0 ? 1698 "Microsoft.XMLHTTP" : "Msxml2.XMLHTTP" 1699 ); 1700 }; 1701 1702 // Attach a bunch of functions for handling common AJAX events 1703 1704 1705 1706 new function(){ 1707 var e = "ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess".split(","); 1708 1709 for ( var i = 0; i < e.length; i++ ) new function(){ 1710 var o = e[i]; 1711 jQuery.fn[o] = function(f){ 1712 return this.bind(o, f); 1713 }; 1714 }; 1715 }; 1716 1717 jQuery.extend({ 1718 get: function( url, data, callback, type, ifModified ) { 1719 if ( data && data.constructor == Function ) { 1720 type = callback; 1721 callback = data; 1722 data = null; 1723 } 1724 1725 // append ? + data or & + data, in case there are already params 1726 if ( data ) url += ((url.indexOf("?") > -1) ? "&" : "?") + jQuery.param(data); 1727 1728 // Build and start the HTTP Request 1729 jQuery.ajax( "GET", url, null, function(r, status) { 1730 if ( callback ) callback( jQuery.httpData(r,type), status ); 1731 }, ifModified); 1732 }, 1733 getIfModified: function( url, data, callback, type ) { 1734 jQuery.get(url, data, callback, type, 1); 1735 }, 1736 getScript: function( url, callback ) { 1737 if(callback) 1738 jQuery.get(url, null, callback, "script"); 1739 else { 1740 jQuery.get(url, null, null, "script"); 1741 } 1742 }, 1743 getJSON: function( url, data, callback ) { 1744 if(callback) 1745 jQuery.get(url, data, callback, "json"); 1746 else { 1747 jQuery.get(url, data, "json"); 1748 } 1749 }, 1750 post: function( url, data, callback, type ) { 1751 // Build and start the HTTP Request 1752 jQuery.ajax( "POST", url, jQuery.param(data), function(r, status) { 1753 if ( callback ) callback( jQuery.httpData(r,type), status ); 1754 }); 1755 }, 1756 1757 // timeout (ms) 1758 timeout: 0, 1759 ajaxTimeout: function(timeout) { 1760 jQuery.timeout = timeout; 1761 }, 1762 1763 // Last-Modified header cache for next request 1764 lastModified: {}, 1765 ajax: function( type, url, data, ret, ifModified ) { 1766 // If only a single argument was passed in, 1767 // assume that it is a object of key/value pairs 1768 var global = true; 1769 var timeout = jQuery.timeout; 1770 if ( !url ) { 1771 ret = type.complete; 1772 var success = type.success; 1773 var error = type.error; 1774 var dataType = type.dataType; 1775 var global = typeof type.global == "boolean" ? type.global : true; 1776 var timeout = typeof type.timeout == "number" ? type.timeout : jQuery.timeout; 1777 ifModified = type.ifModified || false; 1778 data = type.data; 1779 url = type.url; 1780 type = type.type; 1781 } 1782 1783 // Watch for a new set of requests 1784 if ( global && ! jQuery.active++ ) 1785 jQuery.event.trigger( "ajaxStart" ); 1786 1787 var requestDone = false; 1788 1789 // Create the request object 1790 var xml = new XMLHttpRequest(); 1791 1792 // Open the socket 1793 xml.open(type || "GET", url, true); 1794 1795 // Set the correct header, if data is being sent 1796 if ( data ) 1797 xml.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 1798 1799 // Set the If-Modified-Since header, if ifModified mode. 1800 if ( ifModified ) 1801 xml.setRequestHeader("If-Modified-Since", 1802 jQuery.lastModified[url] || "Thu, 01 Jan 1970 00:00:00 GMT" ); 1803 1804 // Set header so the called script knows that it's an XMLHttpRequest 1805 xml.setRequestHeader("X-Requested-With", "XMLHttpRequest"); 1806 1807 // Make sure the browser sends the right content length 1808 if ( xml.overrideMimeType ) 1809 xml.setRequestHeader("Connection", "close"); 1810 1811 // Wait for a response to come back 1812 var onreadystatechange = function(istimeout){ 1813 // The transfer is complete and the data is available, or the request timed out 1814 if ( xml && (xml.readyState == 4 || istimeout == "timeout") ) { 1815 requestDone = true; 1816 1817 var status = jQuery.httpSuccess( xml ) && istimeout != "timeout" ? 1818 ifModified && jQuery.httpNotModified( xml, url ) ? "notmodified" : "success" : "error"; 1819 1820 // Make sure that the request was successful or notmodified 1821 if ( status != "error" ) { 1822 // Cache Last-Modified header, if ifModified mode. 1823 var modRes; 1824 try { 1825 modRes = xml.getResponseHeader("Last-Modified"); 1826 } catch(e) {} // swallow exception thrown by FF if header is not available 1827 1828 if ( ifModified && modRes ) 1829 jQuery.lastModified[url] = modRes; 1830 1831 // If a local callback was specified, fire it 1832 if ( success ) 1833 success( jQuery.httpData( xml, dataType ), status ); 1834 1835 // Fire the global callback 1836 if( global ) 1837 jQuery.event.trigger( "ajaxSuccess" ); 1838 1839 // Otherwise, the request was not successful 1840 } else { 1841 // If a local callback was specified, fire it 1842 if ( error ) error( xml, status ); 1843 1844 // Fire the global callback 1845 if( global ) 1846 jQuery.event.trigger( "ajaxError" ); 1847 } 1848 1849 // The request was completed 1850 if( global ) 1851 jQuery.event.trigger( "ajaxComplete" ); 1852 1853 // Handle the global AJAX counter 1854 if ( global && ! --jQuery.active ) 1855 jQuery.event.trigger( "ajaxStop" ); 1856 1857 // Process result 1858 if ( ret ) ret(xml, status); 1859 1860 // Stop memory leaks 1861 xml.onreadystatechange = function(){}; 1862 xml = null; 1863 1864 } 1865 }; 1866 xml.onreadystatechange = onreadystatechange; 1867 1868 // Timeout checker 1869 if(timeout > 0) 1870 setTimeout(function(){ 1871 // Check to see if the request is still happening 1872 if (xml) { 1873 // Cancel the request 1874 xml.abort(); 1875 1876 if ( !requestDone ) onreadystatechange( "timeout" ); 1877 1878 // Clear from memory 1879 xml = null; 1880 } 1881 }, timeout); 1882 1883 // Send the data 1884 xml.send(data); 1885 }, 1886 1887 // Counter for holding the number of active queries 1888 active: 0, 1889 1890 // Determines if an XMLHttpRequest was successful or not 1891 httpSuccess: function(r) { 1892 try { 1893 return !r.status && location.protocol == "file:" || 1894 ( r.status >= 200 && r.status < 300 ) || r.status == 304 || 1895 jQuery.browser.safari && r.status == undefined; 1896 } catch(e){} 1897 1898 return false; 1899 }, 1900 1901 // Determines if an XMLHttpRequest returns NotModified 1902 httpNotModified: function(xml, url) { 1903 try { 1904 var xmlRes = xml.getResponseHeader("Last-Modified"); 1905 1906 // Firefox always returns 200. check Last-Modified date 1907 return xml.status == 304 || xmlRes == jQuery.lastModified[url] || 1908 jQuery.browser.safari && xml.status == undefined; 1909 } catch(e){} 1910 1911 return false; 1912 }, 1913 1914 /* Get the data out of an XMLHttpRequest. 1915 * Return parsed XML if content-type header is "xml" and type is "xml" or omitted, 1916 * otherwise return plain text. 1917 * (String) data - The type of data that you're expecting back, 1918 * (e.g. "xml", "html", "script") 1919 */ 1920 httpData: function(r,type) { 1921 var ct = r.getResponseHeader("content-type"); 1922 var data = !type && ct && ct.indexOf("xml") >= 0; 1923 data = type == "xml" || data ? r.responseXML : r.responseText; 1924 1925 // If the type is "script", eval it 1926 if ( type == "script" ) eval.call( window, data ); 1927 1928 // Get the JavaScript object, if JSON is used. 1929 if ( type == "json" ) eval( "data = " + data ); 1930 1931 // evaluate scripts within html 1932 if ( type == "html" ) $("<div>").html(data).evalScripts(); 1933 1934 return data; 1935 }, 1936 1937 // Serialize an array of form elements or a set of 1938 // key/values into a query string 1939 param: function(a) { 1940 var s = []; 1941 1942 // If an array was passed in, assume that it is an array 1943 // of form elements 1944 if ( a.constructor == Array || a.jquery ) { 1945 // Serialize the form elements 1946 for ( var i = 0; i < a.length; i++ ) 1947 s.push( a[i].name + "=" + encodeURIComponent( a[i].value ) ); 1948 1949 // Otherwise, assume that it's an object of key/value pairs 1950 } else { 1951 // Serialize the key/values 1952 for ( var j in a ) 1953 s.push( j + "=" + encodeURIComponent( a[j] ) ); 1954 } 1955 1956 // Return the resulting serialization 1957 return s.join("&"); 1958 } 1959 1960 }); 1961 } // close: if(typeof window.jQuery == "undefined") {
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Feb 23 22:16:06 2007 | par Balluche grâce à PHPXref 0.7 |