annotate js/bt/other_libs/jquery-1.2.6.js @ 54:d6f510f35e72 tip

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