hgbook

annotate web/javascript/jquery.js @ 659:8d130de70ebe

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