annotate node_modules/jQuery/tmp/jquery.js @ 101:52e44ee1c791 tip master

enabled all scores in autostart script
author Rob Canning <rc@kiben.net>
date Tue, 21 Apr 2015 16:20:57 +0100
parents cd921abc8887
children
rev   line source
rob@77 1 /*!
rob@77 2 * jQuery JavaScript Library v1.7.2
rob@77 3 * http://jquery.com/
rob@77 4 *
rob@77 5 * Copyright 2011, John Resig
rob@77 6 * Dual licensed under the MIT or GPL Version 2 licenses.
rob@77 7 * http://jquery.org/license
rob@77 8 *
rob@77 9 * Includes Sizzle.js
rob@77 10 * http://sizzlejs.com/
rob@77 11 * Copyright 2011, The Dojo Foundation
rob@77 12 * Released under the MIT, BSD, and GPL Licenses.
rob@77 13 *
rob@77 14 * Date: Wed Mar 21 12:46:34 2012 -0700
rob@77 15 */
rob@77 16 (function( window, undefined ) {
rob@77 17
rob@77 18 // Use the correct document accordingly with window argument (sandbox)
rob@77 19 var document = window.document,
rob@77 20 navigator = window.navigator,
rob@77 21 location = window.location;
rob@77 22 var jQuery = (function() {
rob@77 23
rob@77 24 // Define a local copy of jQuery
rob@77 25 var jQuery = function( selector, context ) {
rob@77 26 // The jQuery object is actually just the init constructor 'enhanced'
rob@77 27 return new jQuery.fn.init( selector, context, rootjQuery );
rob@77 28 },
rob@77 29
rob@77 30 // Map over jQuery in case of overwrite
rob@77 31 _jQuery = window.jQuery,
rob@77 32
rob@77 33 // Map over the $ in case of overwrite
rob@77 34 _$ = window.$,
rob@77 35
rob@77 36 // A central reference to the root jQuery(document)
rob@77 37 rootjQuery,
rob@77 38
rob@77 39 // A simple way to check for HTML strings or ID strings
rob@77 40 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
rob@77 41 quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
rob@77 42
rob@77 43 // Check if a string has a non-whitespace character in it
rob@77 44 rnotwhite = /\S/,
rob@77 45
rob@77 46 // Used for trimming whitespace
rob@77 47 trimLeft = /^\s+/,
rob@77 48 trimRight = /\s+$/,
rob@77 49
rob@77 50 // Match a standalone tag
rob@77 51 rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
rob@77 52
rob@77 53 // JSON RegExp
rob@77 54 rvalidchars = /^[\],:{}\s]*$/,
rob@77 55 rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
rob@77 56 rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
rob@77 57 rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
rob@77 58
rob@77 59 // Useragent RegExp
rob@77 60 rwebkit = /(webkit)[ \/]([\w.]+)/,
rob@77 61 ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
rob@77 62 rmsie = /(msie) ([\w.]+)/,
rob@77 63 rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
rob@77 64
rob@77 65 // Matches dashed string for camelizing
rob@77 66 rdashAlpha = /-([a-z]|[0-9])/ig,
rob@77 67 rmsPrefix = /^-ms-/,
rob@77 68
rob@77 69 // Used by jQuery.camelCase as callback to replace()
rob@77 70 fcamelCase = function( all, letter ) {
rob@77 71 return ( letter + "" ).toUpperCase();
rob@77 72 },
rob@77 73
rob@77 74 // Keep a UserAgent string for use with jQuery.browser
rob@77 75 userAgent = navigator.userAgent,
rob@77 76
rob@77 77 // For matching the engine and version of the browser
rob@77 78 browserMatch,
rob@77 79
rob@77 80 // The deferred used on DOM ready
rob@77 81 readyList,
rob@77 82
rob@77 83 // The ready event handler
rob@77 84 DOMContentLoaded,
rob@77 85
rob@77 86 // Save a reference to some core methods
rob@77 87 toString = Object.prototype.toString,
rob@77 88 hasOwn = Object.prototype.hasOwnProperty,
rob@77 89 push = Array.prototype.push,
rob@77 90 slice = Array.prototype.slice,
rob@77 91 trim = String.prototype.trim,
rob@77 92 indexOf = Array.prototype.indexOf,
rob@77 93
rob@77 94 // [[Class]] -> type pairs
rob@77 95 class2type = {};
rob@77 96
rob@77 97 jQuery.fn = jQuery.prototype = {
rob@77 98 constructor: jQuery,
rob@77 99 init: function( selector, context, rootjQuery ) {
rob@77 100 var match, elem, ret, doc;
rob@77 101
rob@77 102 // Handle $(""), $(null), or $(undefined)
rob@77 103 if ( !selector ) {
rob@77 104 return this;
rob@77 105 }
rob@77 106
rob@77 107 // Handle $(DOMElement)
rob@77 108 if ( selector.nodeType ) {
rob@77 109 this.context = this[0] = selector;
rob@77 110 this.length = 1;
rob@77 111 return this;
rob@77 112 }
rob@77 113
rob@77 114 // The body element only exists once, optimize finding it
rob@77 115 if ( selector === "body" && !context && document.body ) {
rob@77 116 this.context = document;
rob@77 117 this[0] = document.body;
rob@77 118 this.selector = selector;
rob@77 119 this.length = 1;
rob@77 120 return this;
rob@77 121 }
rob@77 122
rob@77 123 // Handle HTML strings
rob@77 124 if ( typeof selector === "string" ) {
rob@77 125 // Are we dealing with HTML string or an ID?
rob@77 126 if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
rob@77 127 // Assume that strings that start and end with <> are HTML and skip the regex check
rob@77 128 match = [ null, selector, null ];
rob@77 129
rob@77 130 } else {
rob@77 131 match = quickExpr.exec( selector );
rob@77 132 }
rob@77 133
rob@77 134 // Verify a match, and that no context was specified for #id
rob@77 135 if ( match && (match[1] || !context) ) {
rob@77 136
rob@77 137 // HANDLE: $(html) -> $(array)
rob@77 138 if ( match[1] ) {
rob@77 139 context = context instanceof jQuery ? context[0] : context;
rob@77 140 doc = ( context ? context.ownerDocument || context : document );
rob@77 141
rob@77 142 // If a single string is passed in and it's a single tag
rob@77 143 // just do a createElement and skip the rest
rob@77 144 ret = rsingleTag.exec( selector );
rob@77 145
rob@77 146 if ( ret ) {
rob@77 147 if ( jQuery.isPlainObject( context ) ) {
rob@77 148 selector = [ document.createElement( ret[1] ) ];
rob@77 149 jQuery.fn.attr.call( selector, context, true );
rob@77 150
rob@77 151 } else {
rob@77 152 selector = [ doc.createElement( ret[1] ) ];
rob@77 153 }
rob@77 154
rob@77 155 } else {
rob@77 156 ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
rob@77 157 selector = ( ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment ).childNodes;
rob@77 158 }
rob@77 159
rob@77 160 return jQuery.merge( this, selector );
rob@77 161
rob@77 162 // HANDLE: $("#id")
rob@77 163 } else {
rob@77 164 elem = document.getElementById( match[2] );
rob@77 165
rob@77 166 // Check parentNode to catch when Blackberry 4.6 returns
rob@77 167 // nodes that are no longer in the document #6963
rob@77 168 if ( elem && elem.parentNode ) {
rob@77 169 // Handle the case where IE and Opera return items
rob@77 170 // by name instead of ID
rob@77 171 if ( elem.id !== match[2] ) {
rob@77 172 return rootjQuery.find( selector );
rob@77 173 }
rob@77 174
rob@77 175 // Otherwise, we inject the element directly into the jQuery object
rob@77 176 this.length = 1;
rob@77 177 this[0] = elem;
rob@77 178 }
rob@77 179
rob@77 180 this.context = document;
rob@77 181 this.selector = selector;
rob@77 182 return this;
rob@77 183 }
rob@77 184
rob@77 185 // HANDLE: $(expr, $(...))
rob@77 186 } else if ( !context || context.jquery ) {
rob@77 187 return ( context || rootjQuery ).find( selector );
rob@77 188
rob@77 189 // HANDLE: $(expr, context)
rob@77 190 // (which is just equivalent to: $(context).find(expr)
rob@77 191 } else {
rob@77 192 return this.constructor( context ).find( selector );
rob@77 193 }
rob@77 194
rob@77 195 // HANDLE: $(function)
rob@77 196 // Shortcut for document ready
rob@77 197 } else if ( jQuery.isFunction( selector ) ) {
rob@77 198 return rootjQuery.ready( selector );
rob@77 199 }
rob@77 200
rob@77 201 if ( selector.selector !== undefined ) {
rob@77 202 this.selector = selector.selector;
rob@77 203 this.context = selector.context;
rob@77 204 }
rob@77 205
rob@77 206 return jQuery.makeArray( selector, this );
rob@77 207 },
rob@77 208
rob@77 209 // Start with an empty selector
rob@77 210 selector: "",
rob@77 211
rob@77 212 // The current version of jQuery being used
rob@77 213 jquery: "1.7.2",
rob@77 214
rob@77 215 // The default length of a jQuery object is 0
rob@77 216 length: 0,
rob@77 217
rob@77 218 // The number of elements contained in the matched element set
rob@77 219 size: function() {
rob@77 220 return this.length;
rob@77 221 },
rob@77 222
rob@77 223 toArray: function() {
rob@77 224 return slice.call( this, 0 );
rob@77 225 },
rob@77 226
rob@77 227 // Get the Nth element in the matched element set OR
rob@77 228 // Get the whole matched element set as a clean array
rob@77 229 get: function( num ) {
rob@77 230 return num == null ?
rob@77 231
rob@77 232 // Return a 'clean' array
rob@77 233 this.toArray() :
rob@77 234
rob@77 235 // Return just the object
rob@77 236 ( num < 0 ? this[ this.length + num ] : this[ num ] );
rob@77 237 },
rob@77 238
rob@77 239 // Take an array of elements and push it onto the stack
rob@77 240 // (returning the new matched element set)
rob@77 241 pushStack: function( elems, name, selector ) {
rob@77 242 // Build a new jQuery matched element set
rob@77 243 var ret = this.constructor();
rob@77 244
rob@77 245 if ( jQuery.isArray( elems ) ) {
rob@77 246 push.apply( ret, elems );
rob@77 247
rob@77 248 } else {
rob@77 249 jQuery.merge( ret, elems );
rob@77 250 }
rob@77 251
rob@77 252 // Add the old object onto the stack (as a reference)
rob@77 253 ret.prevObject = this;
rob@77 254
rob@77 255 ret.context = this.context;
rob@77 256
rob@77 257 if ( name === "find" ) {
rob@77 258 ret.selector = this.selector + ( this.selector ? " " : "" ) + selector;
rob@77 259 } else if ( name ) {
rob@77 260 ret.selector = this.selector + "." + name + "(" + selector + ")";
rob@77 261 }
rob@77 262
rob@77 263 // Return the newly-formed element set
rob@77 264 return ret;
rob@77 265 },
rob@77 266
rob@77 267 // Execute a callback for every element in the matched set.
rob@77 268 // (You can seed the arguments with an array of args, but this is
rob@77 269 // only used internally.)
rob@77 270 each: function( callback, args ) {
rob@77 271 return jQuery.each( this, callback, args );
rob@77 272 },
rob@77 273
rob@77 274 ready: function( fn ) {
rob@77 275 // Attach the listeners
rob@77 276 jQuery.bindReady();
rob@77 277
rob@77 278 // Add the callback
rob@77 279 readyList.add( fn );
rob@77 280
rob@77 281 return this;
rob@77 282 },
rob@77 283
rob@77 284 eq: function( i ) {
rob@77 285 i = +i;
rob@77 286 return i === -1 ?
rob@77 287 this.slice( i ) :
rob@77 288 this.slice( i, i + 1 );
rob@77 289 },
rob@77 290
rob@77 291 first: function() {
rob@77 292 return this.eq( 0 );
rob@77 293 },
rob@77 294
rob@77 295 last: function() {
rob@77 296 return this.eq( -1 );
rob@77 297 },
rob@77 298
rob@77 299 slice: function() {
rob@77 300 return this.pushStack( slice.apply( this, arguments ),
rob@77 301 "slice", slice.call(arguments).join(",") );
rob@77 302 },
rob@77 303
rob@77 304 map: function( callback ) {
rob@77 305 return this.pushStack( jQuery.map(this, function( elem, i ) {
rob@77 306 return callback.call( elem, i, elem );
rob@77 307 }));
rob@77 308 },
rob@77 309
rob@77 310 end: function() {
rob@77 311 return this.prevObject || this.constructor(null);
rob@77 312 },
rob@77 313
rob@77 314 // For internal use only.
rob@77 315 // Behaves like an Array's method, not like a jQuery method.
rob@77 316 push: push,
rob@77 317 sort: [].sort,
rob@77 318 splice: [].splice
rob@77 319 };
rob@77 320
rob@77 321 // Give the init function the jQuery prototype for later instantiation
rob@77 322 jQuery.fn.init.prototype = jQuery.fn;
rob@77 323
rob@77 324 jQuery.extend = jQuery.fn.extend = function() {
rob@77 325 var options, name, src, copy, copyIsArray, clone,
rob@77 326 target = arguments[0] || {},
rob@77 327 i = 1,
rob@77 328 length = arguments.length,
rob@77 329 deep = false;
rob@77 330
rob@77 331 // Handle a deep copy situation
rob@77 332 if ( typeof target === "boolean" ) {
rob@77 333 deep = target;
rob@77 334 target = arguments[1] || {};
rob@77 335 // skip the boolean and the target
rob@77 336 i = 2;
rob@77 337 }
rob@77 338
rob@77 339 // Handle case when target is a string or something (possible in deep copy)
rob@77 340 if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
rob@77 341 target = {};
rob@77 342 }
rob@77 343
rob@77 344 // extend jQuery itself if only one argument is passed
rob@77 345 if ( length === i ) {
rob@77 346 target = this;
rob@77 347 --i;
rob@77 348 }
rob@77 349
rob@77 350 for ( ; i < length; i++ ) {
rob@77 351 // Only deal with non-null/undefined values
rob@77 352 if ( (options = arguments[ i ]) != null ) {
rob@77 353 // Extend the base object
rob@77 354 for ( name in options ) {
rob@77 355 src = target[ name ];
rob@77 356 copy = options[ name ];
rob@77 357
rob@77 358 // Prevent never-ending loop
rob@77 359 if ( target === copy ) {
rob@77 360 continue;
rob@77 361 }
rob@77 362
rob@77 363 // Recurse if we're merging plain objects or arrays
rob@77 364 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
rob@77 365 if ( copyIsArray ) {
rob@77 366 copyIsArray = false;
rob@77 367 clone = src && jQuery.isArray(src) ? src : [];
rob@77 368
rob@77 369 } else {
rob@77 370 clone = src && jQuery.isPlainObject(src) ? src : {};
rob@77 371 }
rob@77 372
rob@77 373 // Never move original objects, clone them
rob@77 374 target[ name ] = jQuery.extend( deep, clone, copy );
rob@77 375
rob@77 376 // Don't bring in undefined values
rob@77 377 } else if ( copy !== undefined ) {
rob@77 378 target[ name ] = copy;
rob@77 379 }
rob@77 380 }
rob@77 381 }
rob@77 382 }
rob@77 383
rob@77 384 // Return the modified object
rob@77 385 return target;
rob@77 386 };
rob@77 387
rob@77 388 jQuery.extend({
rob@77 389 noConflict: function( deep ) {
rob@77 390 if ( window.$ === jQuery ) {
rob@77 391 window.$ = _$;
rob@77 392 }
rob@77 393
rob@77 394 if ( deep && window.jQuery === jQuery ) {
rob@77 395 window.jQuery = _jQuery;
rob@77 396 }
rob@77 397
rob@77 398 return jQuery;
rob@77 399 },
rob@77 400
rob@77 401 // Is the DOM ready to be used? Set to true once it occurs.
rob@77 402 isReady: false,
rob@77 403
rob@77 404 // A counter to track how many items to wait for before
rob@77 405 // the ready event fires. See #6781
rob@77 406 readyWait: 1,
rob@77 407
rob@77 408 // Hold (or release) the ready event
rob@77 409 holdReady: function( hold ) {
rob@77 410 if ( hold ) {
rob@77 411 jQuery.readyWait++;
rob@77 412 } else {
rob@77 413 jQuery.ready( true );
rob@77 414 }
rob@77 415 },
rob@77 416
rob@77 417 // Handle when the DOM is ready
rob@77 418 ready: function( wait ) {
rob@77 419 // Either a released hold or an DOMready/load event and not yet ready
rob@77 420 if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) {
rob@77 421 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
rob@77 422 if ( !document.body ) {
rob@77 423 return setTimeout( jQuery.ready, 1 );
rob@77 424 }
rob@77 425
rob@77 426 // Remember that the DOM is ready
rob@77 427 jQuery.isReady = true;
rob@77 428
rob@77 429 // If a normal DOM Ready event fired, decrement, and wait if need be
rob@77 430 if ( wait !== true && --jQuery.readyWait > 0 ) {
rob@77 431 return;
rob@77 432 }
rob@77 433
rob@77 434 // If there are functions bound, to execute
rob@77 435 readyList.fireWith( document, [ jQuery ] );
rob@77 436
rob@77 437 // Trigger any bound ready events
rob@77 438 if ( jQuery.fn.trigger ) {
rob@77 439 jQuery( document ).trigger( "ready" ).off( "ready" );
rob@77 440 }
rob@77 441 }
rob@77 442 },
rob@77 443
rob@77 444 bindReady: function() {
rob@77 445 if ( readyList ) {
rob@77 446 return;
rob@77 447 }
rob@77 448
rob@77 449 readyList = jQuery.Callbacks( "once memory" );
rob@77 450
rob@77 451 // Catch cases where $(document).ready() is called after the
rob@77 452 // browser event has already occurred.
rob@77 453 if ( document.readyState === "complete" ) {
rob@77 454 // Handle it asynchronously to allow scripts the opportunity to delay ready
rob@77 455 return setTimeout( jQuery.ready, 1 );
rob@77 456 }
rob@77 457
rob@77 458 // Mozilla, Opera and webkit nightlies currently support this event
rob@77 459 if ( document.addEventListener ) {
rob@77 460 // Use the handy event callback
rob@77 461 document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
rob@77 462
rob@77 463 // A fallback to window.onload, that will always work
rob@77 464 window.addEventListener( "load", jQuery.ready, false );
rob@77 465
rob@77 466 // If IE event model is used
rob@77 467 } else if ( document.attachEvent ) {
rob@77 468 // ensure firing before onload,
rob@77 469 // maybe late but safe also for iframes
rob@77 470 document.attachEvent( "onreadystatechange", DOMContentLoaded );
rob@77 471
rob@77 472 // A fallback to window.onload, that will always work
rob@77 473 window.attachEvent( "onload", jQuery.ready );
rob@77 474
rob@77 475 // If IE and not a frame
rob@77 476 // continually check to see if the document is ready
rob@77 477 var toplevel = false;
rob@77 478
rob@77 479 try {
rob@77 480 toplevel = window.frameElement == null;
rob@77 481 } catch(e) {}
rob@77 482
rob@77 483 if ( document.documentElement.doScroll && toplevel ) {
rob@77 484 doScrollCheck();
rob@77 485 }
rob@77 486 }
rob@77 487 },
rob@77 488
rob@77 489 // See test/unit/core.js for details concerning isFunction.
rob@77 490 // Since version 1.3, DOM methods and functions like alert
rob@77 491 // aren't supported. They return false on IE (#2968).
rob@77 492 isFunction: function( obj ) {
rob@77 493 return jQuery.type(obj) === "function";
rob@77 494 },
rob@77 495
rob@77 496 isArray: Array.isArray || function( obj ) {
rob@77 497 return jQuery.type(obj) === "array";
rob@77 498 },
rob@77 499
rob@77 500 isWindow: function( obj ) {
rob@77 501 return obj != null && obj == obj.window;
rob@77 502 },
rob@77 503
rob@77 504 isNumeric: function( obj ) {
rob@77 505 return !isNaN( parseFloat(obj) ) && isFinite( obj );
rob@77 506 },
rob@77 507
rob@77 508 type: function( obj ) {
rob@77 509 return obj == null ?
rob@77 510 String( obj ) :
rob@77 511 class2type[ toString.call(obj) ] || "object";
rob@77 512 },
rob@77 513
rob@77 514 isPlainObject: function( obj ) {
rob@77 515 // Must be an Object.
rob@77 516 // Because of IE, we also have to check the presence of the constructor property.
rob@77 517 // Make sure that DOM nodes and window objects don't pass through, as well
rob@77 518 if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
rob@77 519 return false;
rob@77 520 }
rob@77 521
rob@77 522 try {
rob@77 523 // Not own constructor property must be Object
rob@77 524 if ( obj.constructor &&
rob@77 525 !hasOwn.call(obj, "constructor") &&
rob@77 526 !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
rob@77 527 return false;
rob@77 528 }
rob@77 529 } catch ( e ) {
rob@77 530 // IE8,9 Will throw exceptions on certain host objects #9897
rob@77 531 return false;
rob@77 532 }
rob@77 533
rob@77 534 // Own properties are enumerated firstly, so to speed up,
rob@77 535 // if last one is own, then all properties are own.
rob@77 536
rob@77 537 var key;
rob@77 538 for ( key in obj ) {}
rob@77 539
rob@77 540 return key === undefined || hasOwn.call( obj, key );
rob@77 541 },
rob@77 542
rob@77 543 isEmptyObject: function( obj ) {
rob@77 544 for ( var name in obj ) {
rob@77 545 return false;
rob@77 546 }
rob@77 547 return true;
rob@77 548 },
rob@77 549
rob@77 550 error: function( msg ) {
rob@77 551 throw new Error( msg );
rob@77 552 },
rob@77 553
rob@77 554 parseJSON: function( data ) {
rob@77 555 if ( typeof data !== "string" || !data ) {
rob@77 556 return null;
rob@77 557 }
rob@77 558
rob@77 559 // Make sure leading/trailing whitespace is removed (IE can't handle it)
rob@77 560 data = jQuery.trim( data );
rob@77 561
rob@77 562 // Attempt to parse using the native JSON parser first
rob@77 563 if ( window.JSON && window.JSON.parse ) {
rob@77 564 return window.JSON.parse( data );
rob@77 565 }
rob@77 566
rob@77 567 // Make sure the incoming data is actual JSON
rob@77 568 // Logic borrowed from http://json.org/json2.js
rob@77 569 if ( rvalidchars.test( data.replace( rvalidescape, "@" )
rob@77 570 .replace( rvalidtokens, "]" )
rob@77 571 .replace( rvalidbraces, "")) ) {
rob@77 572
rob@77 573 return ( new Function( "return " + data ) )();
rob@77 574
rob@77 575 }
rob@77 576 jQuery.error( "Invalid JSON: " + data );
rob@77 577 },
rob@77 578
rob@77 579 // Cross-browser xml parsing
rob@77 580 parseXML: function( data ) {
rob@77 581 if ( typeof data !== "string" || !data ) {
rob@77 582 return null;
rob@77 583 }
rob@77 584 var xml, tmp;
rob@77 585 try {
rob@77 586 if ( window.DOMParser ) { // Standard
rob@77 587 tmp = new DOMParser();
rob@77 588 xml = tmp.parseFromString( data , "text/xml" );
rob@77 589 } else { // IE
rob@77 590 xml = new ActiveXObject( "Microsoft.XMLDOM" );
rob@77 591 xml.async = "false";
rob@77 592 xml.loadXML( data );
rob@77 593 }
rob@77 594 } catch( e ) {
rob@77 595 xml = undefined;
rob@77 596 }
rob@77 597 if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
rob@77 598 jQuery.error( "Invalid XML: " + data );
rob@77 599 }
rob@77 600 return xml;
rob@77 601 },
rob@77 602
rob@77 603 noop: function() {},
rob@77 604
rob@77 605 // Evaluates a script in a global context
rob@77 606 // Workarounds based on findings by Jim Driscoll
rob@77 607 // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
rob@77 608 globalEval: function( data ) {
rob@77 609 if ( data && rnotwhite.test( data ) ) {
rob@77 610 // We use execScript on Internet Explorer
rob@77 611 // We use an anonymous function so that context is window
rob@77 612 // rather than jQuery in Firefox
rob@77 613 ( window.execScript || function( data ) {
rob@77 614 window[ "eval" ].call( window, data );
rob@77 615 } )( data );
rob@77 616 }
rob@77 617 },
rob@77 618
rob@77 619 // Convert dashed to camelCase; used by the css and data modules
rob@77 620 // Microsoft forgot to hump their vendor prefix (#9572)
rob@77 621 camelCase: function( string ) {
rob@77 622 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
rob@77 623 },
rob@77 624
rob@77 625 nodeName: function( elem, name ) {
rob@77 626 return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
rob@77 627 },
rob@77 628
rob@77 629 // args is for internal usage only
rob@77 630 each: function( object, callback, args ) {
rob@77 631 var name, i = 0,
rob@77 632 length = object.length,
rob@77 633 isObj = length === undefined || jQuery.isFunction( object );
rob@77 634
rob@77 635 if ( args ) {
rob@77 636 if ( isObj ) {
rob@77 637 for ( name in object ) {
rob@77 638 if ( callback.apply( object[ name ], args ) === false ) {
rob@77 639 break;
rob@77 640 }
rob@77 641 }
rob@77 642 } else {
rob@77 643 for ( ; i < length; ) {
rob@77 644 if ( callback.apply( object[ i++ ], args ) === false ) {
rob@77 645 break;
rob@77 646 }
rob@77 647 }
rob@77 648 }
rob@77 649
rob@77 650 // A special, fast, case for the most common use of each
rob@77 651 } else {
rob@77 652 if ( isObj ) {
rob@77 653 for ( name in object ) {
rob@77 654 if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
rob@77 655 break;
rob@77 656 }
rob@77 657 }
rob@77 658 } else {
rob@77 659 for ( ; i < length; ) {
rob@77 660 if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) {
rob@77 661 break;
rob@77 662 }
rob@77 663 }
rob@77 664 }
rob@77 665 }
rob@77 666
rob@77 667 return object;
rob@77 668 },
rob@77 669
rob@77 670 // Use native String.trim function wherever possible
rob@77 671 trim: trim ?
rob@77 672 function( text ) {
rob@77 673 return text == null ?
rob@77 674 "" :
rob@77 675 trim.call( text );
rob@77 676 } :
rob@77 677
rob@77 678 // Otherwise use our own trimming functionality
rob@77 679 function( text ) {
rob@77 680 return text == null ?
rob@77 681 "" :
rob@77 682 text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
rob@77 683 },
rob@77 684
rob@77 685 // results is for internal usage only
rob@77 686 makeArray: function( array, results ) {
rob@77 687 var ret = results || [];
rob@77 688
rob@77 689 if ( array != null ) {
rob@77 690 // The window, strings (and functions) also have 'length'
rob@77 691 // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
rob@77 692 var type = jQuery.type( array );
rob@77 693
rob@77 694 if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
rob@77 695 push.call( ret, array );
rob@77 696 } else {
rob@77 697 jQuery.merge( ret, array );
rob@77 698 }
rob@77 699 }
rob@77 700
rob@77 701 return ret;
rob@77 702 },
rob@77 703
rob@77 704 inArray: function( elem, array, i ) {
rob@77 705 var len;
rob@77 706
rob@77 707 if ( array ) {
rob@77 708 if ( indexOf ) {
rob@77 709 return indexOf.call( array, elem, i );
rob@77 710 }
rob@77 711
rob@77 712 len = array.length;
rob@77 713 i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
rob@77 714
rob@77 715 for ( ; i < len; i++ ) {
rob@77 716 // Skip accessing in sparse arrays
rob@77 717 if ( i in array && array[ i ] === elem ) {
rob@77 718 return i;
rob@77 719 }
rob@77 720 }
rob@77 721 }
rob@77 722
rob@77 723 return -1;
rob@77 724 },
rob@77 725
rob@77 726 merge: function( first, second ) {
rob@77 727 var i = first.length,
rob@77 728 j = 0;
rob@77 729
rob@77 730 if ( typeof second.length === "number" ) {
rob@77 731 for ( var l = second.length; j < l; j++ ) {
rob@77 732 first[ i++ ] = second[ j ];
rob@77 733 }
rob@77 734
rob@77 735 } else {
rob@77 736 while ( second[j] !== undefined ) {
rob@77 737 first[ i++ ] = second[ j++ ];
rob@77 738 }
rob@77 739 }
rob@77 740
rob@77 741 first.length = i;
rob@77 742
rob@77 743 return first;
rob@77 744 },
rob@77 745
rob@77 746 grep: function( elems, callback, inv ) {
rob@77 747 var ret = [], retVal;
rob@77 748 inv = !!inv;
rob@77 749
rob@77 750 // Go through the array, only saving the items
rob@77 751 // that pass the validator function
rob@77 752 for ( var i = 0, length = elems.length; i < length; i++ ) {
rob@77 753 retVal = !!callback( elems[ i ], i );
rob@77 754 if ( inv !== retVal ) {
rob@77 755 ret.push( elems[ i ] );
rob@77 756 }
rob@77 757 }
rob@77 758
rob@77 759 return ret;
rob@77 760 },
rob@77 761
rob@77 762 // arg is for internal usage only
rob@77 763 map: function( elems, callback, arg ) {
rob@77 764 var value, key, ret = [],
rob@77 765 i = 0,
rob@77 766 length = elems.length,
rob@77 767 // jquery objects are treated as arrays
rob@77 768 isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ;
rob@77 769
rob@77 770 // Go through the array, translating each of the items to their
rob@77 771 if ( isArray ) {
rob@77 772 for ( ; i < length; i++ ) {
rob@77 773 value = callback( elems[ i ], i, arg );
rob@77 774
rob@77 775 if ( value != null ) {
rob@77 776 ret[ ret.length ] = value;
rob@77 777 }
rob@77 778 }
rob@77 779
rob@77 780 // Go through every key on the object,
rob@77 781 } else {
rob@77 782 for ( key in elems ) {
rob@77 783 value = callback( elems[ key ], key, arg );
rob@77 784
rob@77 785 if ( value != null ) {
rob@77 786 ret[ ret.length ] = value;
rob@77 787 }
rob@77 788 }
rob@77 789 }
rob@77 790
rob@77 791 // Flatten any nested arrays
rob@77 792 return ret.concat.apply( [], ret );
rob@77 793 },
rob@77 794
rob@77 795 // A global GUID counter for objects
rob@77 796 guid: 1,
rob@77 797
rob@77 798 // Bind a function to a context, optionally partially applying any
rob@77 799 // arguments.
rob@77 800 proxy: function( fn, context ) {
rob@77 801 if ( typeof context === "string" ) {
rob@77 802 var tmp = fn[ context ];
rob@77 803 context = fn;
rob@77 804 fn = tmp;
rob@77 805 }
rob@77 806
rob@77 807 // Quick check to determine if target is callable, in the spec
rob@77 808 // this throws a TypeError, but we will just return undefined.
rob@77 809 if ( !jQuery.isFunction( fn ) ) {
rob@77 810 return undefined;
rob@77 811 }
rob@77 812
rob@77 813 // Simulated bind
rob@77 814 var args = slice.call( arguments, 2 ),
rob@77 815 proxy = function() {
rob@77 816 return fn.apply( context, args.concat( slice.call( arguments ) ) );
rob@77 817 };
rob@77 818
rob@77 819 // Set the guid of unique handler to the same of original handler, so it can be removed
rob@77 820 proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
rob@77 821
rob@77 822 return proxy;
rob@77 823 },
rob@77 824
rob@77 825 // Mutifunctional method to get and set values to a collection
rob@77 826 // The value/s can optionally be executed if it's a function
rob@77 827 access: function( elems, fn, key, value, chainable, emptyGet, pass ) {
rob@77 828 var exec,
rob@77 829 bulk = key == null,
rob@77 830 i = 0,
rob@77 831 length = elems.length;
rob@77 832
rob@77 833 // Sets many values
rob@77 834 if ( key && typeof key === "object" ) {
rob@77 835 for ( i in key ) {
rob@77 836 jQuery.access( elems, fn, i, key[i], 1, emptyGet, value );
rob@77 837 }
rob@77 838 chainable = 1;
rob@77 839
rob@77 840 // Sets one value
rob@77 841 } else if ( value !== undefined ) {
rob@77 842 // Optionally, function values get executed if exec is true
rob@77 843 exec = pass === undefined && jQuery.isFunction( value );
rob@77 844
rob@77 845 if ( bulk ) {
rob@77 846 // Bulk operations only iterate when executing function values
rob@77 847 if ( exec ) {
rob@77 848 exec = fn;
rob@77 849 fn = function( elem, key, value ) {
rob@77 850 return exec.call( jQuery( elem ), value );
rob@77 851 };
rob@77 852
rob@77 853 // Otherwise they run against the entire set
rob@77 854 } else {
rob@77 855 fn.call( elems, value );
rob@77 856 fn = null;
rob@77 857 }
rob@77 858 }
rob@77 859
rob@77 860 if ( fn ) {
rob@77 861 for (; i < length; i++ ) {
rob@77 862 fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
rob@77 863 }
rob@77 864 }
rob@77 865
rob@77 866 chainable = 1;
rob@77 867 }
rob@77 868
rob@77 869 return chainable ?
rob@77 870 elems :
rob@77 871
rob@77 872 // Gets
rob@77 873 bulk ?
rob@77 874 fn.call( elems ) :
rob@77 875 length ? fn( elems[0], key ) : emptyGet;
rob@77 876 },
rob@77 877
rob@77 878 now: function() {
rob@77 879 return ( new Date() ).getTime();
rob@77 880 },
rob@77 881
rob@77 882 // Use of jQuery.browser is frowned upon.
rob@77 883 // More details: http://docs.jquery.com/Utilities/jQuery.browser
rob@77 884 uaMatch: function( ua ) {
rob@77 885 ua = ua.toLowerCase();
rob@77 886
rob@77 887 var match = rwebkit.exec( ua ) ||
rob@77 888 ropera.exec( ua ) ||
rob@77 889 rmsie.exec( ua ) ||
rob@77 890 ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
rob@77 891 [];
rob@77 892
rob@77 893 return { browser: match[1] || "", version: match[2] || "0" };
rob@77 894 },
rob@77 895
rob@77 896 sub: function() {
rob@77 897 function jQuerySub( selector, context ) {
rob@77 898 return new jQuerySub.fn.init( selector, context );
rob@77 899 }
rob@77 900 jQuery.extend( true, jQuerySub, this );
rob@77 901 jQuerySub.superclass = this;
rob@77 902 jQuerySub.fn = jQuerySub.prototype = this();
rob@77 903 jQuerySub.fn.constructor = jQuerySub;
rob@77 904 jQuerySub.sub = this.sub;
rob@77 905 jQuerySub.fn.init = function init( selector, context ) {
rob@77 906 if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {
rob@77 907 context = jQuerySub( context );
rob@77 908 }
rob@77 909
rob@77 910 return jQuery.fn.init.call( this, selector, context, rootjQuerySub );
rob@77 911 };
rob@77 912 jQuerySub.fn.init.prototype = jQuerySub.fn;
rob@77 913 var rootjQuerySub = jQuerySub(document);
rob@77 914 return jQuerySub;
rob@77 915 },
rob@77 916
rob@77 917 browser: {}
rob@77 918 });
rob@77 919
rob@77 920 // Populate the class2type map
rob@77 921 jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
rob@77 922 class2type[ "[object " + name + "]" ] = name.toLowerCase();
rob@77 923 });
rob@77 924
rob@77 925 browserMatch = jQuery.uaMatch( userAgent );
rob@77 926 if ( browserMatch.browser ) {
rob@77 927 jQuery.browser[ browserMatch.browser ] = true;
rob@77 928 jQuery.browser.version = browserMatch.version;
rob@77 929 }
rob@77 930
rob@77 931 // Deprecated, use jQuery.browser.webkit instead
rob@77 932 if ( jQuery.browser.webkit ) {
rob@77 933 jQuery.browser.safari = true;
rob@77 934 }
rob@77 935
rob@77 936 // IE doesn't match non-breaking spaces with \s
rob@77 937 if ( rnotwhite.test( "\xA0" ) ) {
rob@77 938 trimLeft = /^[\s\xA0]+/;
rob@77 939 trimRight = /[\s\xA0]+$/;
rob@77 940 }
rob@77 941
rob@77 942 // All jQuery objects should point back to these
rob@77 943 rootjQuery = jQuery(document);
rob@77 944
rob@77 945 // Cleanup functions for the document ready method
rob@77 946 if ( document.addEventListener ) {
rob@77 947 DOMContentLoaded = function() {
rob@77 948 document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
rob@77 949 jQuery.ready();
rob@77 950 };
rob@77 951
rob@77 952 } else if ( document.attachEvent ) {
rob@77 953 DOMContentLoaded = function() {
rob@77 954 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
rob@77 955 if ( document.readyState === "complete" ) {
rob@77 956 document.detachEvent( "onreadystatechange", DOMContentLoaded );
rob@77 957 jQuery.ready();
rob@77 958 }
rob@77 959 };
rob@77 960 }
rob@77 961
rob@77 962 // The DOM ready check for Internet Explorer
rob@77 963 function doScrollCheck() {
rob@77 964 if ( jQuery.isReady ) {
rob@77 965 return;
rob@77 966 }
rob@77 967
rob@77 968 try {
rob@77 969 // If IE is used, use the trick by Diego Perini
rob@77 970 // http://javascript.nwbox.com/IEContentLoaded/
rob@77 971 document.documentElement.doScroll("left");
rob@77 972 } catch(e) {
rob@77 973 setTimeout( doScrollCheck, 1 );
rob@77 974 return;
rob@77 975 }
rob@77 976
rob@77 977 // and execute any waiting functions
rob@77 978 jQuery.ready();
rob@77 979 }
rob@77 980
rob@77 981 return jQuery;
rob@77 982
rob@77 983 })();
rob@77 984
rob@77 985
rob@77 986 // String to Object flags format cache
rob@77 987 var flagsCache = {};
rob@77 988
rob@77 989 // Convert String-formatted flags into Object-formatted ones and store in cache
rob@77 990 function createFlags( flags ) {
rob@77 991 var object = flagsCache[ flags ] = {},
rob@77 992 i, length;
rob@77 993 flags = flags.split( /\s+/ );
rob@77 994 for ( i = 0, length = flags.length; i < length; i++ ) {
rob@77 995 object[ flags[i] ] = true;
rob@77 996 }
rob@77 997 return object;
rob@77 998 }
rob@77 999
rob@77 1000 /*
rob@77 1001 * Create a callback list using the following parameters:
rob@77 1002 *
rob@77 1003 * flags: an optional list of space-separated flags that will change how
rob@77 1004 * the callback list behaves
rob@77 1005 *
rob@77 1006 * By default a callback list will act like an event callback list and can be
rob@77 1007 * "fired" multiple times.
rob@77 1008 *
rob@77 1009 * Possible flags:
rob@77 1010 *
rob@77 1011 * once: will ensure the callback list can only be fired once (like a Deferred)
rob@77 1012 *
rob@77 1013 * memory: will keep track of previous values and will call any callback added
rob@77 1014 * after the list has been fired right away with the latest "memorized"
rob@77 1015 * values (like a Deferred)
rob@77 1016 *
rob@77 1017 * unique: will ensure a callback can only be added once (no duplicate in the list)
rob@77 1018 *
rob@77 1019 * stopOnFalse: interrupt callings when a callback returns false
rob@77 1020 *
rob@77 1021 */
rob@77 1022 jQuery.Callbacks = function( flags ) {
rob@77 1023
rob@77 1024 // Convert flags from String-formatted to Object-formatted
rob@77 1025 // (we check in cache first)
rob@77 1026 flags = flags ? ( flagsCache[ flags ] || createFlags( flags ) ) : {};
rob@77 1027
rob@77 1028 var // Actual callback list
rob@77 1029 list = [],
rob@77 1030 // Stack of fire calls for repeatable lists
rob@77 1031 stack = [],
rob@77 1032 // Last fire value (for non-forgettable lists)
rob@77 1033 memory,
rob@77 1034 // Flag to know if list was already fired
rob@77 1035 fired,
rob@77 1036 // Flag to know if list is currently firing
rob@77 1037 firing,
rob@77 1038 // First callback to fire (used internally by add and fireWith)
rob@77 1039 firingStart,
rob@77 1040 // End of the loop when firing
rob@77 1041 firingLength,
rob@77 1042 // Index of currently firing callback (modified by remove if needed)
rob@77 1043 firingIndex,
rob@77 1044 // Add one or several callbacks to the list
rob@77 1045 add = function( args ) {
rob@77 1046 var i,
rob@77 1047 length,
rob@77 1048 elem,
rob@77 1049 type,
rob@77 1050 actual;
rob@77 1051 for ( i = 0, length = args.length; i < length; i++ ) {
rob@77 1052 elem = args[ i ];
rob@77 1053 type = jQuery.type( elem );
rob@77 1054 if ( type === "array" ) {
rob@77 1055 // Inspect recursively
rob@77 1056 add( elem );
rob@77 1057 } else if ( type === "function" ) {
rob@77 1058 // Add if not in unique mode and callback is not in
rob@77 1059 if ( !flags.unique || !self.has( elem ) ) {
rob@77 1060 list.push( elem );
rob@77 1061 }
rob@77 1062 }
rob@77 1063 }
rob@77 1064 },
rob@77 1065 // Fire callbacks
rob@77 1066 fire = function( context, args ) {
rob@77 1067 args = args || [];
rob@77 1068 memory = !flags.memory || [ context, args ];
rob@77 1069 fired = true;
rob@77 1070 firing = true;
rob@77 1071 firingIndex = firingStart || 0;
rob@77 1072 firingStart = 0;
rob@77 1073 firingLength = list.length;
rob@77 1074 for ( ; list && firingIndex < firingLength; firingIndex++ ) {
rob@77 1075 if ( list[ firingIndex ].apply( context, args ) === false && flags.stopOnFalse ) {
rob@77 1076 memory = true; // Mark as halted
rob@77 1077 break;
rob@77 1078 }
rob@77 1079 }
rob@77 1080 firing = false;
rob@77 1081 if ( list ) {
rob@77 1082 if ( !flags.once ) {
rob@77 1083 if ( stack && stack.length ) {
rob@77 1084 memory = stack.shift();
rob@77 1085 self.fireWith( memory[ 0 ], memory[ 1 ] );
rob@77 1086 }
rob@77 1087 } else if ( memory === true ) {
rob@77 1088 self.disable();
rob@77 1089 } else {
rob@77 1090 list = [];
rob@77 1091 }
rob@77 1092 }
rob@77 1093 },
rob@77 1094 // Actual Callbacks object
rob@77 1095 self = {
rob@77 1096 // Add a callback or a collection of callbacks to the list
rob@77 1097 add: function() {
rob@77 1098 if ( list ) {
rob@77 1099 var length = list.length;
rob@77 1100 add( arguments );
rob@77 1101 // Do we need to add the callbacks to the
rob@77 1102 // current firing batch?
rob@77 1103 if ( firing ) {
rob@77 1104 firingLength = list.length;
rob@77 1105 // With memory, if we're not firing then
rob@77 1106 // we should call right away, unless previous
rob@77 1107 // firing was halted (stopOnFalse)
rob@77 1108 } else if ( memory && memory !== true ) {
rob@77 1109 firingStart = length;
rob@77 1110 fire( memory[ 0 ], memory[ 1 ] );
rob@77 1111 }
rob@77 1112 }
rob@77 1113 return this;
rob@77 1114 },
rob@77 1115 // Remove a callback from the list
rob@77 1116 remove: function() {
rob@77 1117 if ( list ) {
rob@77 1118 var args = arguments,
rob@77 1119 argIndex = 0,
rob@77 1120 argLength = args.length;
rob@77 1121 for ( ; argIndex < argLength ; argIndex++ ) {
rob@77 1122 for ( var i = 0; i < list.length; i++ ) {
rob@77 1123 if ( args[ argIndex ] === list[ i ] ) {
rob@77 1124 // Handle firingIndex and firingLength
rob@77 1125 if ( firing ) {
rob@77 1126 if ( i <= firingLength ) {
rob@77 1127 firingLength--;
rob@77 1128 if ( i <= firingIndex ) {
rob@77 1129 firingIndex--;
rob@77 1130 }
rob@77 1131 }
rob@77 1132 }
rob@77 1133 // Remove the element
rob@77 1134 list.splice( i--, 1 );
rob@77 1135 // If we have some unicity property then
rob@77 1136 // we only need to do this once
rob@77 1137 if ( flags.unique ) {
rob@77 1138 break;
rob@77 1139 }
rob@77 1140 }
rob@77 1141 }
rob@77 1142 }
rob@77 1143 }
rob@77 1144 return this;
rob@77 1145 },
rob@77 1146 // Control if a given callback is in the list
rob@77 1147 has: function( fn ) {
rob@77 1148 if ( list ) {
rob@77 1149 var i = 0,
rob@77 1150 length = list.length;
rob@77 1151 for ( ; i < length; i++ ) {
rob@77 1152 if ( fn === list[ i ] ) {
rob@77 1153 return true;
rob@77 1154 }
rob@77 1155 }
rob@77 1156 }
rob@77 1157 return false;
rob@77 1158 },
rob@77 1159 // Remove all callbacks from the list
rob@77 1160 empty: function() {
rob@77 1161 list = [];
rob@77 1162 return this;
rob@77 1163 },
rob@77 1164 // Have the list do nothing anymore
rob@77 1165 disable: function() {
rob@77 1166 list = stack = memory = undefined;
rob@77 1167 return this;
rob@77 1168 },
rob@77 1169 // Is it disabled?
rob@77 1170 disabled: function() {
rob@77 1171 return !list;
rob@77 1172 },
rob@77 1173 // Lock the list in its current state
rob@77 1174 lock: function() {
rob@77 1175 stack = undefined;
rob@77 1176 if ( !memory || memory === true ) {
rob@77 1177 self.disable();
rob@77 1178 }
rob@77 1179 return this;
rob@77 1180 },
rob@77 1181 // Is it locked?
rob@77 1182 locked: function() {
rob@77 1183 return !stack;
rob@77 1184 },
rob@77 1185 // Call all callbacks with the given context and arguments
rob@77 1186 fireWith: function( context, args ) {
rob@77 1187 if ( stack ) {
rob@77 1188 if ( firing ) {
rob@77 1189 if ( !flags.once ) {
rob@77 1190 stack.push( [ context, args ] );
rob@77 1191 }
rob@77 1192 } else if ( !( flags.once && memory ) ) {
rob@77 1193 fire( context, args );
rob@77 1194 }
rob@77 1195 }
rob@77 1196 return this;
rob@77 1197 },
rob@77 1198 // Call all the callbacks with the given arguments
rob@77 1199 fire: function() {
rob@77 1200 self.fireWith( this, arguments );
rob@77 1201 return this;
rob@77 1202 },
rob@77 1203 // To know if the callbacks have already been called at least once
rob@77 1204 fired: function() {
rob@77 1205 return !!fired;
rob@77 1206 }
rob@77 1207 };
rob@77 1208
rob@77 1209 return self;
rob@77 1210 };
rob@77 1211
rob@77 1212
rob@77 1213
rob@77 1214
rob@77 1215 var // Static reference to slice
rob@77 1216 sliceDeferred = [].slice;
rob@77 1217
rob@77 1218 jQuery.extend({
rob@77 1219
rob@77 1220 Deferred: function( func ) {
rob@77 1221 var doneList = jQuery.Callbacks( "once memory" ),
rob@77 1222 failList = jQuery.Callbacks( "once memory" ),
rob@77 1223 progressList = jQuery.Callbacks( "memory" ),
rob@77 1224 state = "pending",
rob@77 1225 lists = {
rob@77 1226 resolve: doneList,
rob@77 1227 reject: failList,
rob@77 1228 notify: progressList
rob@77 1229 },
rob@77 1230 promise = {
rob@77 1231 done: doneList.add,
rob@77 1232 fail: failList.add,
rob@77 1233 progress: progressList.add,
rob@77 1234
rob@77 1235 state: function() {
rob@77 1236 return state;
rob@77 1237 },
rob@77 1238
rob@77 1239 // Deprecated
rob@77 1240 isResolved: doneList.fired,
rob@77 1241 isRejected: failList.fired,
rob@77 1242
rob@77 1243 then: function( doneCallbacks, failCallbacks, progressCallbacks ) {
rob@77 1244 deferred.done( doneCallbacks ).fail( failCallbacks ).progress( progressCallbacks );
rob@77 1245 return this;
rob@77 1246 },
rob@77 1247 always: function() {
rob@77 1248 deferred.done.apply( deferred, arguments ).fail.apply( deferred, arguments );
rob@77 1249 return this;
rob@77 1250 },
rob@77 1251 pipe: function( fnDone, fnFail, fnProgress ) {
rob@77 1252 return jQuery.Deferred(function( newDefer ) {
rob@77 1253 jQuery.each( {
rob@77 1254 done: [ fnDone, "resolve" ],
rob@77 1255 fail: [ fnFail, "reject" ],
rob@77 1256 progress: [ fnProgress, "notify" ]
rob@77 1257 }, function( handler, data ) {
rob@77 1258 var fn = data[ 0 ],
rob@77 1259 action = data[ 1 ],
rob@77 1260 returned;
rob@77 1261 if ( jQuery.isFunction( fn ) ) {
rob@77 1262 deferred[ handler ](function() {
rob@77 1263 returned = fn.apply( this, arguments );
rob@77 1264 if ( returned && jQuery.isFunction( returned.promise ) ) {
rob@77 1265 returned.promise().then( newDefer.resolve, newDefer.reject, newDefer.notify );
rob@77 1266 } else {
rob@77 1267 newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] );
rob@77 1268 }
rob@77 1269 });
rob@77 1270 } else {
rob@77 1271 deferred[ handler ]( newDefer[ action ] );
rob@77 1272 }
rob@77 1273 });
rob@77 1274 }).promise();
rob@77 1275 },
rob@77 1276 // Get a promise for this deferred
rob@77 1277 // If obj is provided, the promise aspect is added to the object
rob@77 1278 promise: function( obj ) {
rob@77 1279 if ( obj == null ) {
rob@77 1280 obj = promise;
rob@77 1281 } else {
rob@77 1282 for ( var key in promise ) {
rob@77 1283 obj[ key ] = promise[ key ];
rob@77 1284 }
rob@77 1285 }
rob@77 1286 return obj;
rob@77 1287 }
rob@77 1288 },
rob@77 1289 deferred = promise.promise({}),
rob@77 1290 key;
rob@77 1291
rob@77 1292 for ( key in lists ) {
rob@77 1293 deferred[ key ] = lists[ key ].fire;
rob@77 1294 deferred[ key + "With" ] = lists[ key ].fireWith;
rob@77 1295 }
rob@77 1296
rob@77 1297 // Handle state
rob@77 1298 deferred.done( function() {
rob@77 1299 state = "resolved";
rob@77 1300 }, failList.disable, progressList.lock ).fail( function() {
rob@77 1301 state = "rejected";
rob@77 1302 }, doneList.disable, progressList.lock );
rob@77 1303
rob@77 1304 // Call given func if any
rob@77 1305 if ( func ) {
rob@77 1306 func.call( deferred, deferred );
rob@77 1307 }
rob@77 1308
rob@77 1309 // All done!
rob@77 1310 return deferred;
rob@77 1311 },
rob@77 1312
rob@77 1313 // Deferred helper
rob@77 1314 when: function( firstParam ) {
rob@77 1315 var args = sliceDeferred.call( arguments, 0 ),
rob@77 1316 i = 0,
rob@77 1317 length = args.length,
rob@77 1318 pValues = new Array( length ),
rob@77 1319 count = length,
rob@77 1320 pCount = length,
rob@77 1321 deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ?
rob@77 1322 firstParam :
rob@77 1323 jQuery.Deferred(),
rob@77 1324 promise = deferred.promise();
rob@77 1325 function resolveFunc( i ) {
rob@77 1326 return function( value ) {
rob@77 1327 args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
rob@77 1328 if ( !( --count ) ) {
rob@77 1329 deferred.resolveWith( deferred, args );
rob@77 1330 }
rob@77 1331 };
rob@77 1332 }
rob@77 1333 function progressFunc( i ) {
rob@77 1334 return function( value ) {
rob@77 1335 pValues[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
rob@77 1336 deferred.notifyWith( promise, pValues );
rob@77 1337 };
rob@77 1338 }
rob@77 1339 if ( length > 1 ) {
rob@77 1340 for ( ; i < length; i++ ) {
rob@77 1341 if ( args[ i ] && args[ i ].promise && jQuery.isFunction( args[ i ].promise ) ) {
rob@77 1342 args[ i ].promise().then( resolveFunc(i), deferred.reject, progressFunc(i) );
rob@77 1343 } else {
rob@77 1344 --count;
rob@77 1345 }
rob@77 1346 }
rob@77 1347 if ( !count ) {
rob@77 1348 deferred.resolveWith( deferred, args );
rob@77 1349 }
rob@77 1350 } else if ( deferred !== firstParam ) {
rob@77 1351 deferred.resolveWith( deferred, length ? [ firstParam ] : [] );
rob@77 1352 }
rob@77 1353 return promise;
rob@77 1354 }
rob@77 1355 });
rob@77 1356
rob@77 1357
rob@77 1358
rob@77 1359
rob@77 1360 jQuery.support = (function() {
rob@77 1361
rob@77 1362 var support,
rob@77 1363 all,
rob@77 1364 a,
rob@77 1365 select,
rob@77 1366 opt,
rob@77 1367 input,
rob@77 1368 fragment,
rob@77 1369 tds,
rob@77 1370 events,
rob@77 1371 eventName,
rob@77 1372 i,
rob@77 1373 isSupported,
rob@77 1374 div = document.createElement( "div" ),
rob@77 1375 documentElement = document.documentElement;
rob@77 1376
rob@77 1377 // Preliminary tests
rob@77 1378 div.setAttribute("className", "t");
rob@77 1379 div.innerHTML = " <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
rob@77 1380
rob@77 1381 all = div.getElementsByTagName( "*" );
rob@77 1382 a = div.getElementsByTagName( "a" )[ 0 ];
rob@77 1383
rob@77 1384 // Can't get basic test support
rob@77 1385 if ( !all || !all.length || !a ) {
rob@77 1386 return {};
rob@77 1387 }
rob@77 1388
rob@77 1389 // First batch of supports tests
rob@77 1390 select = document.createElement( "select" );
rob@77 1391 opt = select.appendChild( document.createElement("option") );
rob@77 1392 input = div.getElementsByTagName( "input" )[ 0 ];
rob@77 1393
rob@77 1394 support = {
rob@77 1395 // IE strips leading whitespace when .innerHTML is used
rob@77 1396 leadingWhitespace: ( div.firstChild.nodeType === 3 ),
rob@77 1397
rob@77 1398 // Make sure that tbody elements aren't automatically inserted
rob@77 1399 // IE will insert them into empty tables
rob@77 1400 tbody: !div.getElementsByTagName("tbody").length,
rob@77 1401
rob@77 1402 // Make sure that link elements get serialized correctly by innerHTML
rob@77 1403 // This requires a wrapper element in IE
rob@77 1404 htmlSerialize: !!div.getElementsByTagName("link").length,
rob@77 1405
rob@77 1406 // Get the style information from getAttribute
rob@77 1407 // (IE uses .cssText instead)
rob@77 1408 style: /top/.test( a.getAttribute("style") ),
rob@77 1409
rob@77 1410 // Make sure that URLs aren't manipulated
rob@77 1411 // (IE normalizes it by default)
rob@77 1412 hrefNormalized: ( a.getAttribute("href") === "/a" ),
rob@77 1413
rob@77 1414 // Make sure that element opacity exists
rob@77 1415 // (IE uses filter instead)
rob@77 1416 // Use a regex to work around a WebKit issue. See #5145
rob@77 1417 opacity: /^0.55/.test( a.style.opacity ),
rob@77 1418
rob@77 1419 // Verify style float existence
rob@77 1420 // (IE uses styleFloat instead of cssFloat)
rob@77 1421 cssFloat: !!a.style.cssFloat,
rob@77 1422
rob@77 1423 // Make sure that if no value is specified for a checkbox
rob@77 1424 // that it defaults to "on".
rob@77 1425 // (WebKit defaults to "" instead)
rob@77 1426 checkOn: ( input.value === "on" ),
rob@77 1427
rob@77 1428 // Make sure that a selected-by-default option has a working selected property.
rob@77 1429 // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
rob@77 1430 optSelected: opt.selected,
rob@77 1431
rob@77 1432 // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
rob@77 1433 getSetAttribute: div.className !== "t",
rob@77 1434
rob@77 1435 // Tests for enctype support on a form(#6743)
rob@77 1436 enctype: !!document.createElement("form").enctype,
rob@77 1437
rob@77 1438 // Makes sure cloning an html5 element does not cause problems
rob@77 1439 // Where outerHTML is undefined, this still works
rob@77 1440 html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav></:nav>",
rob@77 1441
rob@77 1442 // Will be defined later
rob@77 1443 submitBubbles: true,
rob@77 1444 changeBubbles: true,
rob@77 1445 focusinBubbles: false,
rob@77 1446 deleteExpando: true,
rob@77 1447 noCloneEvent: true,
rob@77 1448 inlineBlockNeedsLayout: false,
rob@77 1449 shrinkWrapBlocks: false,
rob@77 1450 reliableMarginRight: true,
rob@77 1451 pixelMargin: true
rob@77 1452 };
rob@77 1453
rob@77 1454 // jQuery.boxModel DEPRECATED in 1.3, use jQuery.support.boxModel instead
rob@77 1455 jQuery.boxModel = support.boxModel = (document.compatMode === "CSS1Compat");
rob@77 1456
rob@77 1457 // Make sure checked status is properly cloned
rob@77 1458 input.checked = true;
rob@77 1459 support.noCloneChecked = input.cloneNode( true ).checked;
rob@77 1460
rob@77 1461 // Make sure that the options inside disabled selects aren't marked as disabled
rob@77 1462 // (WebKit marks them as disabled)
rob@77 1463 select.disabled = true;
rob@77 1464 support.optDisabled = !opt.disabled;
rob@77 1465
rob@77 1466 // Test to see if it's possible to delete an expando from an element
rob@77 1467 // Fails in Internet Explorer
rob@77 1468 try {
rob@77 1469 delete div.test;
rob@77 1470 } catch( e ) {
rob@77 1471 support.deleteExpando = false;
rob@77 1472 }
rob@77 1473
rob@77 1474 if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
rob@77 1475 div.attachEvent( "onclick", function() {
rob@77 1476 // Cloning a node shouldn't copy over any
rob@77 1477 // bound event handlers (IE does this)
rob@77 1478 support.noCloneEvent = false;
rob@77 1479 });
rob@77 1480 div.cloneNode( true ).fireEvent( "onclick" );
rob@77 1481 }
rob@77 1482
rob@77 1483 // Check if a radio maintains its value
rob@77 1484 // after being appended to the DOM
rob@77 1485 input = document.createElement("input");
rob@77 1486 input.value = "t";
rob@77 1487 input.setAttribute("type", "radio");
rob@77 1488 support.radioValue = input.value === "t";
rob@77 1489
rob@77 1490 input.setAttribute("checked", "checked");
rob@77 1491
rob@77 1492 // #11217 - WebKit loses check when the name is after the checked attribute
rob@77 1493 input.setAttribute( "name", "t" );
rob@77 1494
rob@77 1495 div.appendChild( input );
rob@77 1496 fragment = document.createDocumentFragment();
rob@77 1497 fragment.appendChild( div.lastChild );
rob@77 1498
rob@77 1499 // WebKit doesn't clone checked state correctly in fragments
rob@77 1500 support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
rob@77 1501
rob@77 1502 // Check if a disconnected checkbox will retain its checked
rob@77 1503 // value of true after appended to the DOM (IE6/7)
rob@77 1504 support.appendChecked = input.checked;
rob@77 1505
rob@77 1506 fragment.removeChild( input );
rob@77 1507 fragment.appendChild( div );
rob@77 1508
rob@77 1509 // Technique from Juriy Zaytsev
rob@77 1510 // http://perfectionkills.com/detecting-event-support-without-browser-sniffing/
rob@77 1511 // We only care about the case where non-standard event systems
rob@77 1512 // are used, namely in IE. Short-circuiting here helps us to
rob@77 1513 // avoid an eval call (in setAttribute) which can cause CSP
rob@77 1514 // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
rob@77 1515 if ( div.attachEvent ) {
rob@77 1516 for ( i in {
rob@77 1517 submit: 1,
rob@77 1518 change: 1,
rob@77 1519 focusin: 1
rob@77 1520 }) {
rob@77 1521 eventName = "on" + i;
rob@77 1522 isSupported = ( eventName in div );
rob@77 1523 if ( !isSupported ) {
rob@77 1524 div.setAttribute( eventName, "return;" );
rob@77 1525 isSupported = ( typeof div[ eventName ] === "function" );
rob@77 1526 }
rob@77 1527 support[ i + "Bubbles" ] = isSupported;
rob@77 1528 }
rob@77 1529 }
rob@77 1530
rob@77 1531 fragment.removeChild( div );
rob@77 1532
rob@77 1533 // Null elements to avoid leaks in IE
rob@77 1534 fragment = select = opt = div = input = null;
rob@77 1535
rob@77 1536 // Run tests that need a body at doc ready
rob@77 1537 jQuery(function() {
rob@77 1538 var container, outer, inner, table, td, offsetSupport,
rob@77 1539 marginDiv, conMarginTop, style, html, positionTopLeftWidthHeight,
rob@77 1540 paddingMarginBorderVisibility, paddingMarginBorder,
rob@77 1541 body = document.getElementsByTagName("body")[0];
rob@77 1542
rob@77 1543 if ( !body ) {
rob@77 1544 // Return for frameset docs that don't have a body
rob@77 1545 return;
rob@77 1546 }
rob@77 1547
rob@77 1548 conMarginTop = 1;
rob@77 1549 paddingMarginBorder = "padding:0;margin:0;border:";
rob@77 1550 positionTopLeftWidthHeight = "position:absolute;top:0;left:0;width:1px;height:1px;";
rob@77 1551 paddingMarginBorderVisibility = paddingMarginBorder + "0;visibility:hidden;";
rob@77 1552 style = "style='" + positionTopLeftWidthHeight + paddingMarginBorder + "5px solid #000;";
rob@77 1553 html = "<div " + style + "display:block;'><div style='" + paddingMarginBorder + "0;display:block;overflow:hidden;'></div></div>" +
rob@77 1554 "<table " + style + "' cellpadding='0' cellspacing='0'>" +
rob@77 1555 "<tr><td></td></tr></table>";
rob@77 1556
rob@77 1557 container = document.createElement("div");
rob@77 1558 container.style.cssText = paddingMarginBorderVisibility + "width:0;height:0;position:static;top:0;margin-top:" + conMarginTop + "px";
rob@77 1559 body.insertBefore( container, body.firstChild );
rob@77 1560
rob@77 1561 // Construct the test element
rob@77 1562 div = document.createElement("div");
rob@77 1563 container.appendChild( div );
rob@77 1564
rob@77 1565 // Check if table cells still have offsetWidth/Height when they are set
rob@77 1566 // to display:none and there are still other visible table cells in a
rob@77 1567 // table row; if so, offsetWidth/Height are not reliable for use when
rob@77 1568 // determining if an element has been hidden directly using
rob@77 1569 // display:none (it is still safe to use offsets if a parent element is
rob@77 1570 // hidden; don safety goggles and see bug #4512 for more information).
rob@77 1571 // (only IE 8 fails this test)
rob@77 1572 div.innerHTML = "<table><tr><td style='" + paddingMarginBorder + "0;display:none'></td><td>t</td></tr></table>";
rob@77 1573 tds = div.getElementsByTagName( "td" );
rob@77 1574 isSupported = ( tds[ 0 ].offsetHeight === 0 );
rob@77 1575
rob@77 1576 tds[ 0 ].style.display = "";
rob@77 1577 tds[ 1 ].style.display = "none";
rob@77 1578
rob@77 1579 // Check if empty table cells still have offsetWidth/Height
rob@77 1580 // (IE <= 8 fail this test)
rob@77 1581 support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
rob@77 1582
rob@77 1583 // Check if div with explicit width and no margin-right incorrectly
rob@77 1584 // gets computed margin-right based on width of container. For more
rob@77 1585 // info see bug #3333
rob@77 1586 // Fails in WebKit before Feb 2011 nightlies
rob@77 1587 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
rob@77 1588 if ( window.getComputedStyle ) {
rob@77 1589 div.innerHTML = "";
rob@77 1590 marginDiv = document.createElement( "div" );
rob@77 1591 marginDiv.style.width = "0";
rob@77 1592 marginDiv.style.marginRight = "0";
rob@77 1593 div.style.width = "2px";
rob@77 1594 div.appendChild( marginDiv );
rob@77 1595 support.reliableMarginRight =
rob@77 1596 ( parseInt( ( window.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0;
rob@77 1597 }
rob@77 1598
rob@77 1599 if ( typeof div.style.zoom !== "undefined" ) {
rob@77 1600 // Check if natively block-level elements act like inline-block
rob@77 1601 // elements when setting their display to 'inline' and giving
rob@77 1602 // them layout
rob@77 1603 // (IE < 8 does this)
rob@77 1604 div.innerHTML = "";
rob@77 1605 div.style.width = div.style.padding = "1px";
rob@77 1606 div.style.border = 0;
rob@77 1607 div.style.overflow = "hidden";
rob@77 1608 div.style.display = "inline";
rob@77 1609 div.style.zoom = 1;
rob@77 1610 support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 );
rob@77 1611
rob@77 1612 // Check if elements with layout shrink-wrap their children
rob@77 1613 // (IE 6 does this)
rob@77 1614 div.style.display = "block";
rob@77 1615 div.style.overflow = "visible";
rob@77 1616 div.innerHTML = "<div style='width:5px;'></div>";
rob@77 1617 support.shrinkWrapBlocks = ( div.offsetWidth !== 3 );
rob@77 1618 }
rob@77 1619
rob@77 1620 div.style.cssText = positionTopLeftWidthHeight + paddingMarginBorderVisibility;
rob@77 1621 div.innerHTML = html;
rob@77 1622
rob@77 1623 outer = div.firstChild;
rob@77 1624 inner = outer.firstChild;
rob@77 1625 td = outer.nextSibling.firstChild.firstChild;
rob@77 1626
rob@77 1627 offsetSupport = {
rob@77 1628 doesNotAddBorder: ( inner.offsetTop !== 5 ),
rob@77 1629 doesAddBorderForTableAndCells: ( td.offsetTop === 5 )
rob@77 1630 };
rob@77 1631
rob@77 1632 inner.style.position = "fixed";
rob@77 1633 inner.style.top = "20px";
rob@77 1634
rob@77 1635 // safari subtracts parent border width here which is 5px
rob@77 1636 offsetSupport.fixedPosition = ( inner.offsetTop === 20 || inner.offsetTop === 15 );
rob@77 1637 inner.style.position = inner.style.top = "";
rob@77 1638
rob@77 1639 outer.style.overflow = "hidden";
rob@77 1640 outer.style.position = "relative";
rob@77 1641
rob@77 1642 offsetSupport.subtractsBorderForOverflowNotVisible = ( inner.offsetTop === -5 );
rob@77 1643 offsetSupport.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== conMarginTop );
rob@77 1644
rob@77 1645 if ( window.getComputedStyle ) {
rob@77 1646 div.style.marginTop = "1%";
rob@77 1647 support.pixelMargin = ( window.getComputedStyle( div, null ) || { marginTop: 0 } ).marginTop !== "1%";
rob@77 1648 }
rob@77 1649
rob@77 1650 if ( typeof container.style.zoom !== "undefined" ) {
rob@77 1651 container.style.zoom = 1;
rob@77 1652 }
rob@77 1653
rob@77 1654 body.removeChild( container );
rob@77 1655 marginDiv = div = container = null;
rob@77 1656
rob@77 1657 jQuery.extend( support, offsetSupport );
rob@77 1658 });
rob@77 1659
rob@77 1660 return support;
rob@77 1661 })();
rob@77 1662
rob@77 1663
rob@77 1664
rob@77 1665
rob@77 1666 var rbrace = /^(?:\{.*\}|\[.*\])$/,
rob@77 1667 rmultiDash = /([A-Z])/g;
rob@77 1668
rob@77 1669 jQuery.extend({
rob@77 1670 cache: {},
rob@77 1671
rob@77 1672 // Please use with caution
rob@77 1673 uuid: 0,
rob@77 1674
rob@77 1675 // Unique for each copy of jQuery on the page
rob@77 1676 // Non-digits removed to match rinlinejQuery
rob@77 1677 expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),
rob@77 1678
rob@77 1679 // The following elements throw uncatchable exceptions if you
rob@77 1680 // attempt to add expando properties to them.
rob@77 1681 noData: {
rob@77 1682 "embed": true,
rob@77 1683 // Ban all objects except for Flash (which handle expandos)
rob@77 1684 "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
rob@77 1685 "applet": true
rob@77 1686 },
rob@77 1687
rob@77 1688 hasData: function( elem ) {
rob@77 1689 elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
rob@77 1690 return !!elem && !isEmptyDataObject( elem );
rob@77 1691 },
rob@77 1692
rob@77 1693 data: function( elem, name, data, pvt /* Internal Use Only */ ) {
rob@77 1694 if ( !jQuery.acceptData( elem ) ) {
rob@77 1695 return;
rob@77 1696 }
rob@77 1697
rob@77 1698 var privateCache, thisCache, ret,
rob@77 1699 internalKey = jQuery.expando,
rob@77 1700 getByName = typeof name === "string",
rob@77 1701
rob@77 1702 // We have to handle DOM nodes and JS objects differently because IE6-7
rob@77 1703 // can't GC object references properly across the DOM-JS boundary
rob@77 1704 isNode = elem.nodeType,
rob@77 1705
rob@77 1706 // Only DOM nodes need the global jQuery cache; JS object data is
rob@77 1707 // attached directly to the object so GC can occur automatically
rob@77 1708 cache = isNode ? jQuery.cache : elem,
rob@77 1709
rob@77 1710 // Only defining an ID for JS objects if its cache already exists allows
rob@77 1711 // the code to shortcut on the same path as a DOM node with no cache
rob@77 1712 id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey,
rob@77 1713 isEvents = name === "events";
rob@77 1714
rob@77 1715 // Avoid doing any more work than we need to when trying to get data on an
rob@77 1716 // object that has no data at all
rob@77 1717 if ( (!id || !cache[id] || (!isEvents && !pvt && !cache[id].data)) && getByName && data === undefined ) {
rob@77 1718 return;
rob@77 1719 }
rob@77 1720
rob@77 1721 if ( !id ) {
rob@77 1722 // Only DOM nodes need a new unique ID for each element since their data
rob@77 1723 // ends up in the global cache
rob@77 1724 if ( isNode ) {
rob@77 1725 elem[ internalKey ] = id = ++jQuery.uuid;
rob@77 1726 } else {
rob@77 1727 id = internalKey;
rob@77 1728 }
rob@77 1729 }
rob@77 1730
rob@77 1731 if ( !cache[ id ] ) {
rob@77 1732 cache[ id ] = {};
rob@77 1733
rob@77 1734 // Avoids exposing jQuery metadata on plain JS objects when the object
rob@77 1735 // is serialized using JSON.stringify
rob@77 1736 if ( !isNode ) {
rob@77 1737 cache[ id ].toJSON = jQuery.noop;
rob@77 1738 }
rob@77 1739 }
rob@77 1740
rob@77 1741 // An object can be passed to jQuery.data instead of a key/value pair; this gets
rob@77 1742 // shallow copied over onto the existing cache
rob@77 1743 if ( typeof name === "object" || typeof name === "function" ) {
rob@77 1744 if ( pvt ) {
rob@77 1745 cache[ id ] = jQuery.extend( cache[ id ], name );
rob@77 1746 } else {
rob@77 1747 cache[ id ].data = jQuery.extend( cache[ id ].data, name );
rob@77 1748 }
rob@77 1749 }
rob@77 1750
rob@77 1751 privateCache = thisCache = cache[ id ];
rob@77 1752
rob@77 1753 // jQuery data() is stored in a separate object inside the object's internal data
rob@77 1754 // cache in order to avoid key collisions between internal data and user-defined
rob@77 1755 // data.
rob@77 1756 if ( !pvt ) {
rob@77 1757 if ( !thisCache.data ) {
rob@77 1758 thisCache.data = {};
rob@77 1759 }
rob@77 1760
rob@77 1761 thisCache = thisCache.data;
rob@77 1762 }
rob@77 1763
rob@77 1764 if ( data !== undefined ) {
rob@77 1765 thisCache[ jQuery.camelCase( name ) ] = data;
rob@77 1766 }
rob@77 1767
rob@77 1768 // Users should not attempt to inspect the internal events object using jQuery.data,
rob@77 1769 // it is undocumented and subject to change. But does anyone listen? No.
rob@77 1770 if ( isEvents && !thisCache[ name ] ) {
rob@77 1771 return privateCache.events;
rob@77 1772 }
rob@77 1773
rob@77 1774 // Check for both converted-to-camel and non-converted data property names
rob@77 1775 // If a data property was specified
rob@77 1776 if ( getByName ) {
rob@77 1777
rob@77 1778 // First Try to find as-is property data
rob@77 1779 ret = thisCache[ name ];
rob@77 1780
rob@77 1781 // Test for null|undefined property data
rob@77 1782 if ( ret == null ) {
rob@77 1783
rob@77 1784 // Try to find the camelCased property
rob@77 1785 ret = thisCache[ jQuery.camelCase( name ) ];
rob@77 1786 }
rob@77 1787 } else {
rob@77 1788 ret = thisCache;
rob@77 1789 }
rob@77 1790
rob@77 1791 return ret;
rob@77 1792 },
rob@77 1793
rob@77 1794 removeData: function( elem, name, pvt /* Internal Use Only */ ) {
rob@77 1795 if ( !jQuery.acceptData( elem ) ) {
rob@77 1796 return;
rob@77 1797 }
rob@77 1798
rob@77 1799 var thisCache, i, l,
rob@77 1800
rob@77 1801 // Reference to internal data cache key
rob@77 1802 internalKey = jQuery.expando,
rob@77 1803
rob@77 1804 isNode = elem.nodeType,
rob@77 1805
rob@77 1806 // See jQuery.data for more information
rob@77 1807 cache = isNode ? jQuery.cache : elem,
rob@77 1808
rob@77 1809 // See jQuery.data for more information
rob@77 1810 id = isNode ? elem[ internalKey ] : internalKey;
rob@77 1811
rob@77 1812 // If there is already no cache entry for this object, there is no
rob@77 1813 // purpose in continuing
rob@77 1814 if ( !cache[ id ] ) {
rob@77 1815 return;
rob@77 1816 }
rob@77 1817
rob@77 1818 if ( name ) {
rob@77 1819
rob@77 1820 thisCache = pvt ? cache[ id ] : cache[ id ].data;
rob@77 1821
rob@77 1822 if ( thisCache ) {
rob@77 1823
rob@77 1824 // Support array or space separated string names for data keys
rob@77 1825 if ( !jQuery.isArray( name ) ) {
rob@77 1826
rob@77 1827 // try the string as a key before any manipulation
rob@77 1828 if ( name in thisCache ) {
rob@77 1829 name = [ name ];
rob@77 1830 } else {
rob@77 1831
rob@77 1832 // split the camel cased version by spaces unless a key with the spaces exists
rob@77 1833 name = jQuery.camelCase( name );
rob@77 1834 if ( name in thisCache ) {
rob@77 1835 name = [ name ];
rob@77 1836 } else {
rob@77 1837 name = name.split( " " );
rob@77 1838 }
rob@77 1839 }
rob@77 1840 }
rob@77 1841
rob@77 1842 for ( i = 0, l = name.length; i < l; i++ ) {
rob@77 1843 delete thisCache[ name[i] ];
rob@77 1844 }
rob@77 1845
rob@77 1846 // If there is no data left in the cache, we want to continue
rob@77 1847 // and let the cache object itself get destroyed
rob@77 1848 if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) {
rob@77 1849 return;
rob@77 1850 }
rob@77 1851 }
rob@77 1852 }
rob@77 1853
rob@77 1854 // See jQuery.data for more information
rob@77 1855 if ( !pvt ) {
rob@77 1856 delete cache[ id ].data;
rob@77 1857
rob@77 1858 // Don't destroy the parent cache unless the internal data object
rob@77 1859 // had been the only thing left in it
rob@77 1860 if ( !isEmptyDataObject(cache[ id ]) ) {
rob@77 1861 return;
rob@77 1862 }
rob@77 1863 }
rob@77 1864
rob@77 1865 // Browsers that fail expando deletion also refuse to delete expandos on
rob@77 1866 // the window, but it will allow it on all other JS objects; other browsers
rob@77 1867 // don't care
rob@77 1868 // Ensure that `cache` is not a window object #10080
rob@77 1869 if ( jQuery.support.deleteExpando || !cache.setInterval ) {
rob@77 1870 delete cache[ id ];
rob@77 1871 } else {
rob@77 1872 cache[ id ] = null;
rob@77 1873 }
rob@77 1874
rob@77 1875 // We destroyed the cache and need to eliminate the expando on the node to avoid
rob@77 1876 // false lookups in the cache for entries that no longer exist
rob@77 1877 if ( isNode ) {
rob@77 1878 // IE does not allow us to delete expando properties from nodes,
rob@77 1879 // nor does it have a removeAttribute function on Document nodes;
rob@77 1880 // we must handle all of these cases
rob@77 1881 if ( jQuery.support.deleteExpando ) {
rob@77 1882 delete elem[ internalKey ];
rob@77 1883 } else if ( elem.removeAttribute ) {
rob@77 1884 elem.removeAttribute( internalKey );
rob@77 1885 } else {
rob@77 1886 elem[ internalKey ] = null;
rob@77 1887 }
rob@77 1888 }
rob@77 1889 },
rob@77 1890
rob@77 1891 // For internal use only.
rob@77 1892 _data: function( elem, name, data ) {
rob@77 1893 return jQuery.data( elem, name, data, true );
rob@77 1894 },
rob@77 1895
rob@77 1896 // A method for determining if a DOM node can handle the data expando
rob@77 1897 acceptData: function( elem ) {
rob@77 1898 if ( elem.nodeName ) {
rob@77 1899 var match = jQuery.noData[ elem.nodeName.toLowerCase() ];
rob@77 1900
rob@77 1901 if ( match ) {
rob@77 1902 return !(match === true || elem.getAttribute("classid") !== match);
rob@77 1903 }
rob@77 1904 }
rob@77 1905
rob@77 1906 return true;
rob@77 1907 }
rob@77 1908 });
rob@77 1909
rob@77 1910 jQuery.fn.extend({
rob@77 1911 data: function( key, value ) {
rob@77 1912 var parts, part, attr, name, l,
rob@77 1913 elem = this[0],
rob@77 1914 i = 0,
rob@77 1915 data = null;
rob@77 1916
rob@77 1917 // Gets all values
rob@77 1918 if ( key === undefined ) {
rob@77 1919 if ( this.length ) {
rob@77 1920 data = jQuery.data( elem );
rob@77 1921
rob@77 1922 if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
rob@77 1923 attr = elem.attributes;
rob@77 1924 for ( l = attr.length; i < l; i++ ) {
rob@77 1925 name = attr[i].name;
rob@77 1926
rob@77 1927 if ( name.indexOf( "data-" ) === 0 ) {
rob@77 1928 name = jQuery.camelCase( name.substring(5) );
rob@77 1929
rob@77 1930 dataAttr( elem, name, data[ name ] );
rob@77 1931 }
rob@77 1932 }
rob@77 1933 jQuery._data( elem, "parsedAttrs", true );
rob@77 1934 }
rob@77 1935 }
rob@77 1936
rob@77 1937 return data;
rob@77 1938 }
rob@77 1939
rob@77 1940 // Sets multiple values
rob@77 1941 if ( typeof key === "object" ) {
rob@77 1942 return this.each(function() {
rob@77 1943 jQuery.data( this, key );
rob@77 1944 });
rob@77 1945 }
rob@77 1946
rob@77 1947 parts = key.split( ".", 2 );
rob@77 1948 parts[1] = parts[1] ? "." + parts[1] : "";
rob@77 1949 part = parts[1] + "!";
rob@77 1950
rob@77 1951 return jQuery.access( this, function( value ) {
rob@77 1952
rob@77 1953 if ( value === undefined ) {
rob@77 1954 data = this.triggerHandler( "getData" + part, [ parts[0] ] );
rob@77 1955
rob@77 1956 // Try to fetch any internally stored data first
rob@77 1957 if ( data === undefined && elem ) {
rob@77 1958 data = jQuery.data( elem, key );
rob@77 1959 data = dataAttr( elem, key, data );
rob@77 1960 }
rob@77 1961
rob@77 1962 return data === undefined && parts[1] ?
rob@77 1963 this.data( parts[0] ) :
rob@77 1964 data;
rob@77 1965 }
rob@77 1966
rob@77 1967 parts[1] = value;
rob@77 1968 this.each(function() {
rob@77 1969 var self = jQuery( this );
rob@77 1970
rob@77 1971 self.triggerHandler( "setData" + part, parts );
rob@77 1972 jQuery.data( this, key, value );
rob@77 1973 self.triggerHandler( "changeData" + part, parts );
rob@77 1974 });
rob@77 1975 }, null, value, arguments.length > 1, null, false );
rob@77 1976 },
rob@77 1977
rob@77 1978 removeData: function( key ) {
rob@77 1979 return this.each(function() {
rob@77 1980 jQuery.removeData( this, key );
rob@77 1981 });
rob@77 1982 }
rob@77 1983 });
rob@77 1984
rob@77 1985 function dataAttr( elem, key, data ) {
rob@77 1986 // If nothing was found internally, try to fetch any
rob@77 1987 // data from the HTML5 data-* attribute
rob@77 1988 if ( data === undefined && elem.nodeType === 1 ) {
rob@77 1989
rob@77 1990 var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
rob@77 1991
rob@77 1992 data = elem.getAttribute( name );
rob@77 1993
rob@77 1994 if ( typeof data === "string" ) {
rob@77 1995 try {
rob@77 1996 data = data === "true" ? true :
rob@77 1997 data === "false" ? false :
rob@77 1998 data === "null" ? null :
rob@77 1999 jQuery.isNumeric( data ) ? +data :
rob@77 2000 rbrace.test( data ) ? jQuery.parseJSON( data ) :
rob@77 2001 data;
rob@77 2002 } catch( e ) {}
rob@77 2003
rob@77 2004 // Make sure we set the data so it isn't changed later
rob@77 2005 jQuery.data( elem, key, data );
rob@77 2006
rob@77 2007 } else {
rob@77 2008 data = undefined;
rob@77 2009 }
rob@77 2010 }
rob@77 2011
rob@77 2012 return data;
rob@77 2013 }
rob@77 2014
rob@77 2015 // checks a cache object for emptiness
rob@77 2016 function isEmptyDataObject( obj ) {
rob@77 2017 for ( var name in obj ) {
rob@77 2018
rob@77 2019 // if the public data object is empty, the private is still empty
rob@77 2020 if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
rob@77 2021 continue;
rob@77 2022 }
rob@77 2023 if ( name !== "toJSON" ) {
rob@77 2024 return false;
rob@77 2025 }
rob@77 2026 }
rob@77 2027
rob@77 2028 return true;
rob@77 2029 }
rob@77 2030
rob@77 2031
rob@77 2032
rob@77 2033
rob@77 2034 function handleQueueMarkDefer( elem, type, src ) {
rob@77 2035 var deferDataKey = type + "defer",
rob@77 2036 queueDataKey = type + "queue",
rob@77 2037 markDataKey = type + "mark",
rob@77 2038 defer = jQuery._data( elem, deferDataKey );
rob@77 2039 if ( defer &&
rob@77 2040 ( src === "queue" || !jQuery._data(elem, queueDataKey) ) &&
rob@77 2041 ( src === "mark" || !jQuery._data(elem, markDataKey) ) ) {
rob@77 2042 // Give room for hard-coded callbacks to fire first
rob@77 2043 // and eventually mark/queue something else on the element
rob@77 2044 setTimeout( function() {
rob@77 2045 if ( !jQuery._data( elem, queueDataKey ) &&
rob@77 2046 !jQuery._data( elem, markDataKey ) ) {
rob@77 2047 jQuery.removeData( elem, deferDataKey, true );
rob@77 2048 defer.fire();
rob@77 2049 }
rob@77 2050 }, 0 );
rob@77 2051 }
rob@77 2052 }
rob@77 2053
rob@77 2054 jQuery.extend({
rob@77 2055
rob@77 2056 _mark: function( elem, type ) {
rob@77 2057 if ( elem ) {
rob@77 2058 type = ( type || "fx" ) + "mark";
rob@77 2059 jQuery._data( elem, type, (jQuery._data( elem, type ) || 0) + 1 );
rob@77 2060 }
rob@77 2061 },
rob@77 2062
rob@77 2063 _unmark: function( force, elem, type ) {
rob@77 2064 if ( force !== true ) {
rob@77 2065 type = elem;
rob@77 2066 elem = force;
rob@77 2067 force = false;
rob@77 2068 }
rob@77 2069 if ( elem ) {
rob@77 2070 type = type || "fx";
rob@77 2071 var key = type + "mark",
rob@77 2072 count = force ? 0 : ( (jQuery._data( elem, key ) || 1) - 1 );
rob@77 2073 if ( count ) {
rob@77 2074 jQuery._data( elem, key, count );
rob@77 2075 } else {
rob@77 2076 jQuery.removeData( elem, key, true );
rob@77 2077 handleQueueMarkDefer( elem, type, "mark" );
rob@77 2078 }
rob@77 2079 }
rob@77 2080 },
rob@77 2081
rob@77 2082 queue: function( elem, type, data ) {
rob@77 2083 var q;
rob@77 2084 if ( elem ) {
rob@77 2085 type = ( type || "fx" ) + "queue";
rob@77 2086 q = jQuery._data( elem, type );
rob@77 2087
rob@77 2088 // Speed up dequeue by getting out quickly if this is just a lookup
rob@77 2089 if ( data ) {
rob@77 2090 if ( !q || jQuery.isArray(data) ) {
rob@77 2091 q = jQuery._data( elem, type, jQuery.makeArray(data) );
rob@77 2092 } else {
rob@77 2093 q.push( data );
rob@77 2094 }
rob@77 2095 }
rob@77 2096 return q || [];
rob@77 2097 }
rob@77 2098 },
rob@77 2099
rob@77 2100 dequeue: function( elem, type ) {
rob@77 2101 type = type || "fx";
rob@77 2102
rob@77 2103 var queue = jQuery.queue( elem, type ),
rob@77 2104 fn = queue.shift(),
rob@77 2105 hooks = {};
rob@77 2106
rob@77 2107 // If the fx queue is dequeued, always remove the progress sentinel
rob@77 2108 if ( fn === "inprogress" ) {
rob@77 2109 fn = queue.shift();
rob@77 2110 }
rob@77 2111
rob@77 2112 if ( fn ) {
rob@77 2113 // Add a progress sentinel to prevent the fx queue from being
rob@77 2114 // automatically dequeued
rob@77 2115 if ( type === "fx" ) {
rob@77 2116 queue.unshift( "inprogress" );
rob@77 2117 }
rob@77 2118
rob@77 2119 jQuery._data( elem, type + ".run", hooks );
rob@77 2120 fn.call( elem, function() {
rob@77 2121 jQuery.dequeue( elem, type );
rob@77 2122 }, hooks );
rob@77 2123 }
rob@77 2124
rob@77 2125 if ( !queue.length ) {
rob@77 2126 jQuery.removeData( elem, type + "queue " + type + ".run", true );
rob@77 2127 handleQueueMarkDefer( elem, type, "queue" );
rob@77 2128 }
rob@77 2129 }
rob@77 2130 });
rob@77 2131
rob@77 2132 jQuery.fn.extend({
rob@77 2133 queue: function( type, data ) {
rob@77 2134 var setter = 2;
rob@77 2135
rob@77 2136 if ( typeof type !== "string" ) {
rob@77 2137 data = type;
rob@77 2138 type = "fx";
rob@77 2139 setter--;
rob@77 2140 }
rob@77 2141
rob@77 2142 if ( arguments.length < setter ) {
rob@77 2143 return jQuery.queue( this[0], type );
rob@77 2144 }
rob@77 2145
rob@77 2146 return data === undefined ?
rob@77 2147 this :
rob@77 2148 this.each(function() {
rob@77 2149 var queue = jQuery.queue( this, type, data );
rob@77 2150
rob@77 2151 if ( type === "fx" && queue[0] !== "inprogress" ) {
rob@77 2152 jQuery.dequeue( this, type );
rob@77 2153 }
rob@77 2154 });
rob@77 2155 },
rob@77 2156 dequeue: function( type ) {
rob@77 2157 return this.each(function() {
rob@77 2158 jQuery.dequeue( this, type );
rob@77 2159 });
rob@77 2160 },
rob@77 2161 // Based off of the plugin by Clint Helfers, with permission.
rob@77 2162 // http://blindsignals.com/index.php/2009/07/jquery-delay/
rob@77 2163 delay: function( time, type ) {
rob@77 2164 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
rob@77 2165 type = type || "fx";
rob@77 2166
rob@77 2167 return this.queue( type, function( next, hooks ) {
rob@77 2168 var timeout = setTimeout( next, time );
rob@77 2169 hooks.stop = function() {
rob@77 2170 clearTimeout( timeout );
rob@77 2171 };
rob@77 2172 });
rob@77 2173 },
rob@77 2174 clearQueue: function( type ) {
rob@77 2175 return this.queue( type || "fx", [] );
rob@77 2176 },
rob@77 2177 // Get a promise resolved when queues of a certain type
rob@77 2178 // are emptied (fx is the type by default)
rob@77 2179 promise: function( type, object ) {
rob@77 2180 if ( typeof type !== "string" ) {
rob@77 2181 object = type;
rob@77 2182 type = undefined;
rob@77 2183 }
rob@77 2184 type = type || "fx";
rob@77 2185 var defer = jQuery.Deferred(),
rob@77 2186 elements = this,
rob@77 2187 i = elements.length,
rob@77 2188 count = 1,
rob@77 2189 deferDataKey = type + "defer",
rob@77 2190 queueDataKey = type + "queue",
rob@77 2191 markDataKey = type + "mark",
rob@77 2192 tmp;
rob@77 2193 function resolve() {
rob@77 2194 if ( !( --count ) ) {
rob@77 2195 defer.resolveWith( elements, [ elements ] );
rob@77 2196 }
rob@77 2197 }
rob@77 2198 while( i-- ) {
rob@77 2199 if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) ||
rob@77 2200 ( jQuery.data( elements[ i ], queueDataKey, undefined, true ) ||
rob@77 2201 jQuery.data( elements[ i ], markDataKey, undefined, true ) ) &&
rob@77 2202 jQuery.data( elements[ i ], deferDataKey, jQuery.Callbacks( "once memory" ), true ) )) {
rob@77 2203 count++;
rob@77 2204 tmp.add( resolve );
rob@77 2205 }
rob@77 2206 }
rob@77 2207 resolve();
rob@77 2208 return defer.promise( object );
rob@77 2209 }
rob@77 2210 });
rob@77 2211
rob@77 2212
rob@77 2213
rob@77 2214
rob@77 2215 var rclass = /[\n\t\r]/g,
rob@77 2216 rspace = /\s+/,
rob@77 2217 rreturn = /\r/g,
rob@77 2218 rtype = /^(?:button|input)$/i,
rob@77 2219 rfocusable = /^(?:button|input|object|select|textarea)$/i,
rob@77 2220 rclickable = /^a(?:rea)?$/i,
rob@77 2221 rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
rob@77 2222 getSetAttribute = jQuery.support.getSetAttribute,
rob@77 2223 nodeHook, boolHook, fixSpecified;
rob@77 2224
rob@77 2225 jQuery.fn.extend({
rob@77 2226 attr: function( name, value ) {
rob@77 2227 return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 );
rob@77 2228 },
rob@77 2229
rob@77 2230 removeAttr: function( name ) {
rob@77 2231 return this.each(function() {
rob@77 2232 jQuery.removeAttr( this, name );
rob@77 2233 });
rob@77 2234 },
rob@77 2235
rob@77 2236 prop: function( name, value ) {
rob@77 2237 return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 );
rob@77 2238 },
rob@77 2239
rob@77 2240 removeProp: function( name ) {
rob@77 2241 name = jQuery.propFix[ name ] || name;
rob@77 2242 return this.each(function() {
rob@77 2243 // try/catch handles cases where IE balks (such as removing a property on window)
rob@77 2244 try {
rob@77 2245 this[ name ] = undefined;
rob@77 2246 delete this[ name ];
rob@77 2247 } catch( e ) {}
rob@77 2248 });
rob@77 2249 },
rob@77 2250
rob@77 2251 addClass: function( value ) {
rob@77 2252 var classNames, i, l, elem,
rob@77 2253 setClass, c, cl;
rob@77 2254
rob@77 2255 if ( jQuery.isFunction( value ) ) {
rob@77 2256 return this.each(function( j ) {
rob@77 2257 jQuery( this ).addClass( value.call(this, j, this.className) );
rob@77 2258 });
rob@77 2259 }
rob@77 2260
rob@77 2261 if ( value && typeof value === "string" ) {
rob@77 2262 classNames = value.split( rspace );
rob@77 2263
rob@77 2264 for ( i = 0, l = this.length; i < l; i++ ) {
rob@77 2265 elem = this[ i ];
rob@77 2266
rob@77 2267 if ( elem.nodeType === 1 ) {
rob@77 2268 if ( !elem.className && classNames.length === 1 ) {
rob@77 2269 elem.className = value;
rob@77 2270
rob@77 2271 } else {
rob@77 2272 setClass = " " + elem.className + " ";
rob@77 2273
rob@77 2274 for ( c = 0, cl = classNames.length; c < cl; c++ ) {
rob@77 2275 if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) {
rob@77 2276 setClass += classNames[ c ] + " ";
rob@77 2277 }
rob@77 2278 }
rob@77 2279 elem.className = jQuery.trim( setClass );
rob@77 2280 }
rob@77 2281 }
rob@77 2282 }
rob@77 2283 }
rob@77 2284
rob@77 2285 return this;
rob@77 2286 },
rob@77 2287
rob@77 2288 removeClass: function( value ) {
rob@77 2289 var classNames, i, l, elem, className, c, cl;
rob@77 2290
rob@77 2291 if ( jQuery.isFunction( value ) ) {
rob@77 2292 return this.each(function( j ) {
rob@77 2293 jQuery( this ).removeClass( value.call(this, j, this.className) );
rob@77 2294 });
rob@77 2295 }
rob@77 2296
rob@77 2297 if ( (value && typeof value === "string") || value === undefined ) {
rob@77 2298 classNames = ( value || "" ).split( rspace );
rob@77 2299
rob@77 2300 for ( i = 0, l = this.length; i < l; i++ ) {
rob@77 2301 elem = this[ i ];
rob@77 2302
rob@77 2303 if ( elem.nodeType === 1 && elem.className ) {
rob@77 2304 if ( value ) {
rob@77 2305 className = (" " + elem.className + " ").replace( rclass, " " );
rob@77 2306 for ( c = 0, cl = classNames.length; c < cl; c++ ) {
rob@77 2307 className = className.replace(" " + classNames[ c ] + " ", " ");
rob@77 2308 }
rob@77 2309 elem.className = jQuery.trim( className );
rob@77 2310
rob@77 2311 } else {
rob@77 2312 elem.className = "";
rob@77 2313 }
rob@77 2314 }
rob@77 2315 }
rob@77 2316 }
rob@77 2317
rob@77 2318 return this;
rob@77 2319 },
rob@77 2320
rob@77 2321 toggleClass: function( value, stateVal ) {
rob@77 2322 var type = typeof value,
rob@77 2323 isBool = typeof stateVal === "boolean";
rob@77 2324
rob@77 2325 if ( jQuery.isFunction( value ) ) {
rob@77 2326 return this.each(function( i ) {
rob@77 2327 jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
rob@77 2328 });
rob@77 2329 }
rob@77 2330
rob@77 2331 return this.each(function() {
rob@77 2332 if ( type === "string" ) {
rob@77 2333 // toggle individual class names
rob@77 2334 var className,
rob@77 2335 i = 0,
rob@77 2336 self = jQuery( this ),
rob@77 2337 state = stateVal,
rob@77 2338 classNames = value.split( rspace );
rob@77 2339
rob@77 2340 while ( (className = classNames[ i++ ]) ) {
rob@77 2341 // check each className given, space seperated list
rob@77 2342 state = isBool ? state : !self.hasClass( className );
rob@77 2343 self[ state ? "addClass" : "removeClass" ]( className );
rob@77 2344 }
rob@77 2345
rob@77 2346 } else if ( type === "undefined" || type === "boolean" ) {
rob@77 2347 if ( this.className ) {
rob@77 2348 // store className if set
rob@77 2349 jQuery._data( this, "__className__", this.className );
rob@77 2350 }
rob@77 2351
rob@77 2352 // toggle whole className
rob@77 2353 this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
rob@77 2354 }
rob@77 2355 });
rob@77 2356 },
rob@77 2357
rob@77 2358 hasClass: function( selector ) {
rob@77 2359 var className = " " + selector + " ",
rob@77 2360 i = 0,
rob@77 2361 l = this.length;
rob@77 2362 for ( ; i < l; i++ ) {
rob@77 2363 if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
rob@77 2364 return true;
rob@77 2365 }
rob@77 2366 }
rob@77 2367
rob@77 2368 return false;
rob@77 2369 },
rob@77 2370
rob@77 2371 val: function( value ) {
rob@77 2372 var hooks, ret, isFunction,
rob@77 2373 elem = this[0];
rob@77 2374
rob@77 2375 if ( !arguments.length ) {
rob@77 2376 if ( elem ) {
rob@77 2377 hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
rob@77 2378
rob@77 2379 if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
rob@77 2380 return ret;
rob@77 2381 }
rob@77 2382
rob@77 2383 ret = elem.value;
rob@77 2384
rob@77 2385 return typeof ret === "string" ?
rob@77 2386 // handle most common string cases
rob@77 2387 ret.replace(rreturn, "") :
rob@77 2388 // handle cases where value is null/undef or number
rob@77 2389 ret == null ? "" : ret;
rob@77 2390 }
rob@77 2391
rob@77 2392 return;
rob@77 2393 }
rob@77 2394
rob@77 2395 isFunction = jQuery.isFunction( value );
rob@77 2396
rob@77 2397 return this.each(function( i ) {
rob@77 2398 var self = jQuery(this), val;
rob@77 2399
rob@77 2400 if ( this.nodeType !== 1 ) {
rob@77 2401 return;
rob@77 2402 }
rob@77 2403
rob@77 2404 if ( isFunction ) {
rob@77 2405 val = value.call( this, i, self.val() );
rob@77 2406 } else {
rob@77 2407 val = value;
rob@77 2408 }
rob@77 2409
rob@77 2410 // Treat null/undefined as ""; convert numbers to string
rob@77 2411 if ( val == null ) {
rob@77 2412 val = "";
rob@77 2413 } else if ( typeof val === "number" ) {
rob@77 2414 val += "";
rob@77 2415 } else if ( jQuery.isArray( val ) ) {
rob@77 2416 val = jQuery.map(val, function ( value ) {
rob@77 2417 return value == null ? "" : value + "";
rob@77 2418 });
rob@77 2419 }
rob@77 2420
rob@77 2421 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
rob@77 2422
rob@77 2423 // If set returns undefined, fall back to normal setting
rob@77 2424 if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
rob@77 2425 this.value = val;
rob@77 2426 }
rob@77 2427 });
rob@77 2428 }
rob@77 2429 });
rob@77 2430
rob@77 2431 jQuery.extend({
rob@77 2432 valHooks: {
rob@77 2433 option: {
rob@77 2434 get: function( elem ) {
rob@77 2435 // attributes.value is undefined in Blackberry 4.7 but
rob@77 2436 // uses .value. See #6932
rob@77 2437 var val = elem.attributes.value;
rob@77 2438 return !val || val.specified ? elem.value : elem.text;
rob@77 2439 }
rob@77 2440 },
rob@77 2441 select: {
rob@77 2442 get: function( elem ) {
rob@77 2443 var value, i, max, option,
rob@77 2444 index = elem.selectedIndex,
rob@77 2445 values = [],
rob@77 2446 options = elem.options,
rob@77 2447 one = elem.type === "select-one";
rob@77 2448
rob@77 2449 // Nothing was selected
rob@77 2450 if ( index < 0 ) {
rob@77 2451 return null;
rob@77 2452 }
rob@77 2453
rob@77 2454 // Loop through all the selected options
rob@77 2455 i = one ? index : 0;
rob@77 2456 max = one ? index + 1 : options.length;
rob@77 2457 for ( ; i < max; i++ ) {
rob@77 2458 option = options[ i ];
rob@77 2459
rob@77 2460 // Don't return options that are disabled or in a disabled optgroup
rob@77 2461 if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
rob@77 2462 (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
rob@77 2463
rob@77 2464 // Get the specific value for the option
rob@77 2465 value = jQuery( option ).val();
rob@77 2466
rob@77 2467 // We don't need an array for one selects
rob@77 2468 if ( one ) {
rob@77 2469 return value;
rob@77 2470 }
rob@77 2471
rob@77 2472 // Multi-Selects return an array
rob@77 2473 values.push( value );
rob@77 2474 }
rob@77 2475 }
rob@77 2476
rob@77 2477 // Fixes Bug #2551 -- select.val() broken in IE after form.reset()
rob@77 2478 if ( one && !values.length && options.length ) {
rob@77 2479 return jQuery( options[ index ] ).val();
rob@77 2480 }
rob@77 2481
rob@77 2482 return values;
rob@77 2483 },
rob@77 2484
rob@77 2485 set: function( elem, value ) {
rob@77 2486 var values = jQuery.makeArray( value );
rob@77 2487
rob@77 2488 jQuery(elem).find("option").each(function() {
rob@77 2489 this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
rob@77 2490 });
rob@77 2491
rob@77 2492 if ( !values.length ) {
rob@77 2493 elem.selectedIndex = -1;
rob@77 2494 }
rob@77 2495 return values;
rob@77 2496 }
rob@77 2497 }
rob@77 2498 },
rob@77 2499
rob@77 2500 attrFn: {
rob@77 2501 val: true,
rob@77 2502 css: true,
rob@77 2503 html: true,
rob@77 2504 text: true,
rob@77 2505 data: true,
rob@77 2506 width: true,
rob@77 2507 height: true,
rob@77 2508 offset: true
rob@77 2509 },
rob@77 2510
rob@77 2511 attr: function( elem, name, value, pass ) {
rob@77 2512 var ret, hooks, notxml,
rob@77 2513 nType = elem.nodeType;
rob@77 2514
rob@77 2515 // don't get/set attributes on text, comment and attribute nodes
rob@77 2516 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
rob@77 2517 return;
rob@77 2518 }
rob@77 2519
rob@77 2520 if ( pass && name in jQuery.attrFn ) {
rob@77 2521 return jQuery( elem )[ name ]( value );
rob@77 2522 }
rob@77 2523
rob@77 2524 // Fallback to prop when attributes are not supported
rob@77 2525 if ( typeof elem.getAttribute === "undefined" ) {
rob@77 2526 return jQuery.prop( elem, name, value );
rob@77 2527 }
rob@77 2528
rob@77 2529 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
rob@77 2530
rob@77 2531 // All attributes are lowercase
rob@77 2532 // Grab necessary hook if one is defined
rob@77 2533 if ( notxml ) {
rob@77 2534 name = name.toLowerCase();
rob@77 2535 hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook );
rob@77 2536 }
rob@77 2537
rob@77 2538 if ( value !== undefined ) {
rob@77 2539
rob@77 2540 if ( value === null ) {
rob@77 2541 jQuery.removeAttr( elem, name );
rob@77 2542 return;
rob@77 2543
rob@77 2544 } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) {
rob@77 2545 return ret;
rob@77 2546
rob@77 2547 } else {
rob@77 2548 elem.setAttribute( name, "" + value );
rob@77 2549 return value;
rob@77 2550 }
rob@77 2551
rob@77 2552 } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) {
rob@77 2553 return ret;
rob@77 2554
rob@77 2555 } else {
rob@77 2556
rob@77 2557 ret = elem.getAttribute( name );
rob@77 2558
rob@77 2559 // Non-existent attributes return null, we normalize to undefined
rob@77 2560 return ret === null ?
rob@77 2561 undefined :
rob@77 2562 ret;
rob@77 2563 }
rob@77 2564 },
rob@77 2565
rob@77 2566 removeAttr: function( elem, value ) {
rob@77 2567 var propName, attrNames, name, l, isBool,
rob@77 2568 i = 0;
rob@77 2569
rob@77 2570 if ( value && elem.nodeType === 1 ) {
rob@77 2571 attrNames = value.toLowerCase().split( rspace );
rob@77 2572 l = attrNames.length;
rob@77 2573
rob@77 2574 for ( ; i < l; i++ ) {
rob@77 2575 name = attrNames[ i ];
rob@77 2576
rob@77 2577 if ( name ) {
rob@77 2578 propName = jQuery.propFix[ name ] || name;
rob@77 2579 isBool = rboolean.test( name );
rob@77 2580
rob@77 2581 // See #9699 for explanation of this approach (setting first, then removal)
rob@77 2582 // Do not do this for boolean attributes (see #10870)
rob@77 2583 if ( !isBool ) {
rob@77 2584 jQuery.attr( elem, name, "" );
rob@77 2585 }
rob@77 2586 elem.removeAttribute( getSetAttribute ? name : propName );
rob@77 2587
rob@77 2588 // Set corresponding property to false for boolean attributes
rob@77 2589 if ( isBool && propName in elem ) {
rob@77 2590 elem[ propName ] = false;
rob@77 2591 }
rob@77 2592 }
rob@77 2593 }
rob@77 2594 }
rob@77 2595 },
rob@77 2596
rob@77 2597 attrHooks: {
rob@77 2598 type: {
rob@77 2599 set: function( elem, value ) {
rob@77 2600 // We can't allow the type property to be changed (since it causes problems in IE)
rob@77 2601 if ( rtype.test( elem.nodeName ) && elem.parentNode ) {
rob@77 2602 jQuery.error( "type property can't be changed" );
rob@77 2603 } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
rob@77 2604 // Setting the type on a radio button after the value resets the value in IE6-9
rob@77 2605 // Reset value to it's default in case type is set after value
rob@77 2606 // This is for element creation
rob@77 2607 var val = elem.value;
rob@77 2608 elem.setAttribute( "type", value );
rob@77 2609 if ( val ) {
rob@77 2610 elem.value = val;
rob@77 2611 }
rob@77 2612 return value;
rob@77 2613 }
rob@77 2614 }
rob@77 2615 },
rob@77 2616 // Use the value property for back compat
rob@77 2617 // Use the nodeHook for button elements in IE6/7 (#1954)
rob@77 2618 value: {
rob@77 2619 get: function( elem, name ) {
rob@77 2620 if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
rob@77 2621 return nodeHook.get( elem, name );
rob@77 2622 }
rob@77 2623 return name in elem ?
rob@77 2624 elem.value :
rob@77 2625 null;
rob@77 2626 },
rob@77 2627 set: function( elem, value, name ) {
rob@77 2628 if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
rob@77 2629 return nodeHook.set( elem, value, name );
rob@77 2630 }
rob@77 2631 // Does not return so that setAttribute is also used
rob@77 2632 elem.value = value;
rob@77 2633 }
rob@77 2634 }
rob@77 2635 },
rob@77 2636
rob@77 2637 propFix: {
rob@77 2638 tabindex: "tabIndex",
rob@77 2639 readonly: "readOnly",
rob@77 2640 "for": "htmlFor",
rob@77 2641 "class": "className",
rob@77 2642 maxlength: "maxLength",
rob@77 2643 cellspacing: "cellSpacing",
rob@77 2644 cellpadding: "cellPadding",
rob@77 2645 rowspan: "rowSpan",
rob@77 2646 colspan: "colSpan",
rob@77 2647 usemap: "useMap",
rob@77 2648 frameborder: "frameBorder",
rob@77 2649 contenteditable: "contentEditable"
rob@77 2650 },
rob@77 2651
rob@77 2652 prop: function( elem, name, value ) {
rob@77 2653 var ret, hooks, notxml,
rob@77 2654 nType = elem.nodeType;
rob@77 2655
rob@77 2656 // don't get/set properties on text, comment and attribute nodes
rob@77 2657 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
rob@77 2658 return;
rob@77 2659 }
rob@77 2660
rob@77 2661 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
rob@77 2662
rob@77 2663 if ( notxml ) {
rob@77 2664 // Fix name and attach hooks
rob@77 2665 name = jQuery.propFix[ name ] || name;
rob@77 2666 hooks = jQuery.propHooks[ name ];
rob@77 2667 }
rob@77 2668
rob@77 2669 if ( value !== undefined ) {
rob@77 2670 if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
rob@77 2671 return ret;
rob@77 2672
rob@77 2673 } else {
rob@77 2674 return ( elem[ name ] = value );
rob@77 2675 }
rob@77 2676
rob@77 2677 } else {
rob@77 2678 if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
rob@77 2679 return ret;
rob@77 2680
rob@77 2681 } else {
rob@77 2682 return elem[ name ];
rob@77 2683 }
rob@77 2684 }
rob@77 2685 },
rob@77 2686
rob@77 2687 propHooks: {
rob@77 2688 tabIndex: {
rob@77 2689 get: function( elem ) {
rob@77 2690 // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
rob@77 2691 // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
rob@77 2692 var attributeNode = elem.getAttributeNode("tabindex");
rob@77 2693
rob@77 2694 return attributeNode && attributeNode.specified ?
rob@77 2695 parseInt( attributeNode.value, 10 ) :
rob@77 2696 rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
rob@77 2697 0 :
rob@77 2698 undefined;
rob@77 2699 }
rob@77 2700 }
rob@77 2701 }
rob@77 2702 });
rob@77 2703
rob@77 2704 // Add the tabIndex propHook to attrHooks for back-compat (different case is intentional)
rob@77 2705 jQuery.attrHooks.tabindex = jQuery.propHooks.tabIndex;
rob@77 2706
rob@77 2707 // Hook for boolean attributes
rob@77 2708 boolHook = {
rob@77 2709 get: function( elem, name ) {
rob@77 2710 // Align boolean attributes with corresponding properties
rob@77 2711 // Fall back to attribute presence where some booleans are not supported
rob@77 2712 var attrNode,
rob@77 2713 property = jQuery.prop( elem, name );
rob@77 2714 return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ?
rob@77 2715 name.toLowerCase() :
rob@77 2716 undefined;
rob@77 2717 },
rob@77 2718 set: function( elem, value, name ) {
rob@77 2719 var propName;
rob@77 2720 if ( value === false ) {
rob@77 2721 // Remove boolean attributes when set to false
rob@77 2722 jQuery.removeAttr( elem, name );
rob@77 2723 } else {
rob@77 2724 // value is true since we know at this point it's type boolean and not false
rob@77 2725 // Set boolean attributes to the same name and set the DOM property
rob@77 2726 propName = jQuery.propFix[ name ] || name;
rob@77 2727 if ( propName in elem ) {
rob@77 2728 // Only set the IDL specifically if it already exists on the element
rob@77 2729 elem[ propName ] = true;
rob@77 2730 }
rob@77 2731
rob@77 2732 elem.setAttribute( name, name.toLowerCase() );
rob@77 2733 }
rob@77 2734 return name;
rob@77 2735 }
rob@77 2736 };
rob@77 2737
rob@77 2738 // IE6/7 do not support getting/setting some attributes with get/setAttribute
rob@77 2739 if ( !getSetAttribute ) {
rob@77 2740
rob@77 2741 fixSpecified = {
rob@77 2742 name: true,
rob@77 2743 id: true,
rob@77 2744 coords: true
rob@77 2745 };
rob@77 2746
rob@77 2747 // Use this for any attribute in IE6/7
rob@77 2748 // This fixes almost every IE6/7 issue
rob@77 2749 nodeHook = jQuery.valHooks.button = {
rob@77 2750 get: function( elem, name ) {
rob@77 2751 var ret;
rob@77 2752 ret = elem.getAttributeNode( name );
rob@77 2753 return ret && ( fixSpecified[ name ] ? ret.nodeValue !== "" : ret.specified ) ?
rob@77 2754 ret.nodeValue :
rob@77 2755 undefined;
rob@77 2756 },
rob@77 2757 set: function( elem, value, name ) {
rob@77 2758 // Set the existing or create a new attribute node
rob@77 2759 var ret = elem.getAttributeNode( name );
rob@77 2760 if ( !ret ) {
rob@77 2761 ret = document.createAttribute( name );
rob@77 2762 elem.setAttributeNode( ret );
rob@77 2763 }
rob@77 2764 return ( ret.nodeValue = value + "" );
rob@77 2765 }
rob@77 2766 };
rob@77 2767
rob@77 2768 // Apply the nodeHook to tabindex
rob@77 2769 jQuery.attrHooks.tabindex.set = nodeHook.set;
rob@77 2770
rob@77 2771 // Set width and height to auto instead of 0 on empty string( Bug #8150 )
rob@77 2772 // This is for removals
rob@77 2773 jQuery.each([ "width", "height" ], function( i, name ) {
rob@77 2774 jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
rob@77 2775 set: function( elem, value ) {
rob@77 2776 if ( value === "" ) {
rob@77 2777 elem.setAttribute( name, "auto" );
rob@77 2778 return value;
rob@77 2779 }
rob@77 2780 }
rob@77 2781 });
rob@77 2782 });
rob@77 2783
rob@77 2784 // Set contenteditable to false on removals(#10429)
rob@77 2785 // Setting to empty string throws an error as an invalid value
rob@77 2786 jQuery.attrHooks.contenteditable = {
rob@77 2787 get: nodeHook.get,
rob@77 2788 set: function( elem, value, name ) {
rob@77 2789 if ( value === "" ) {
rob@77 2790 value = "false";
rob@77 2791 }
rob@77 2792 nodeHook.set( elem, value, name );
rob@77 2793 }
rob@77 2794 };
rob@77 2795 }
rob@77 2796
rob@77 2797
rob@77 2798 // Some attributes require a special call on IE
rob@77 2799 if ( !jQuery.support.hrefNormalized ) {
rob@77 2800 jQuery.each([ "href", "src", "width", "height" ], function( i, name ) {
rob@77 2801 jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
rob@77 2802 get: function( elem ) {
rob@77 2803 var ret = elem.getAttribute( name, 2 );
rob@77 2804 return ret === null ? undefined : ret;
rob@77 2805 }
rob@77 2806 });
rob@77 2807 });
rob@77 2808 }
rob@77 2809
rob@77 2810 if ( !jQuery.support.style ) {
rob@77 2811 jQuery.attrHooks.style = {
rob@77 2812 get: function( elem ) {
rob@77 2813 // Return undefined in the case of empty string
rob@77 2814 // Normalize to lowercase since IE uppercases css property names
rob@77 2815 return elem.style.cssText.toLowerCase() || undefined;
rob@77 2816 },
rob@77 2817 set: function( elem, value ) {
rob@77 2818 return ( elem.style.cssText = "" + value );
rob@77 2819 }
rob@77 2820 };
rob@77 2821 }
rob@77 2822
rob@77 2823 // Safari mis-reports the default selected property of an option
rob@77 2824 // Accessing the parent's selectedIndex property fixes it
rob@77 2825 if ( !jQuery.support.optSelected ) {
rob@77 2826 jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, {
rob@77 2827 get: function( elem ) {
rob@77 2828 var parent = elem.parentNode;
rob@77 2829
rob@77 2830 if ( parent ) {
rob@77 2831 parent.selectedIndex;
rob@77 2832
rob@77 2833 // Make sure that it also works with optgroups, see #5701
rob@77 2834 if ( parent.parentNode ) {
rob@77 2835 parent.parentNode.selectedIndex;
rob@77 2836 }
rob@77 2837 }
rob@77 2838 return null;
rob@77 2839 }
rob@77 2840 });
rob@77 2841 }
rob@77 2842
rob@77 2843 // IE6/7 call enctype encoding
rob@77 2844 if ( !jQuery.support.enctype ) {
rob@77 2845 jQuery.propFix.enctype = "encoding";
rob@77 2846 }
rob@77 2847
rob@77 2848 // Radios and checkboxes getter/setter
rob@77 2849 if ( !jQuery.support.checkOn ) {
rob@77 2850 jQuery.each([ "radio", "checkbox" ], function() {
rob@77 2851 jQuery.valHooks[ this ] = {
rob@77 2852 get: function( elem ) {
rob@77 2853 // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
rob@77 2854 return elem.getAttribute("value") === null ? "on" : elem.value;
rob@77 2855 }
rob@77 2856 };
rob@77 2857 });
rob@77 2858 }
rob@77 2859 jQuery.each([ "radio", "checkbox" ], function() {
rob@77 2860 jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], {
rob@77 2861 set: function( elem, value ) {
rob@77 2862 if ( jQuery.isArray( value ) ) {
rob@77 2863 return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
rob@77 2864 }
rob@77 2865 }
rob@77 2866 });
rob@77 2867 });
rob@77 2868
rob@77 2869
rob@77 2870
rob@77 2871
rob@77 2872 var rformElems = /^(?:textarea|input|select)$/i,
rob@77 2873 rtypenamespace = /^([^\.]*)?(?:\.(.+))?$/,
rob@77 2874 rhoverHack = /(?:^|\s)hover(\.\S+)?\b/,
rob@77 2875 rkeyEvent = /^key/,
rob@77 2876 rmouseEvent = /^(?:mouse|contextmenu)|click/,
rob@77 2877 rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
rob@77 2878 rquickIs = /^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,
rob@77 2879 quickParse = function( selector ) {
rob@77 2880 var quick = rquickIs.exec( selector );
rob@77 2881 if ( quick ) {
rob@77 2882 // 0 1 2 3
rob@77 2883 // [ _, tag, id, class ]
rob@77 2884 quick[1] = ( quick[1] || "" ).toLowerCase();
rob@77 2885 quick[3] = quick[3] && new RegExp( "(?:^|\\s)" + quick[3] + "(?:\\s|$)" );
rob@77 2886 }
rob@77 2887 return quick;
rob@77 2888 },
rob@77 2889 quickIs = function( elem, m ) {
rob@77 2890 var attrs = elem.attributes || {};
rob@77 2891 return (
rob@77 2892 (!m[1] || elem.nodeName.toLowerCase() === m[1]) &&
rob@77 2893 (!m[2] || (attrs.id || {}).value === m[2]) &&
rob@77 2894 (!m[3] || m[3].test( (attrs[ "class" ] || {}).value ))
rob@77 2895 );
rob@77 2896 },
rob@77 2897 hoverHack = function( events ) {
rob@77 2898 return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" );
rob@77 2899 };
rob@77 2900
rob@77 2901 /*
rob@77 2902 * Helper functions for managing events -- not part of the public interface.
rob@77 2903 * Props to Dean Edwards' addEvent library for many of the ideas.
rob@77 2904 */
rob@77 2905 jQuery.event = {
rob@77 2906
rob@77 2907 add: function( elem, types, handler, data, selector ) {
rob@77 2908
rob@77 2909 var elemData, eventHandle, events,
rob@77 2910 t, tns, type, namespaces, handleObj,
rob@77 2911 handleObjIn, quick, handlers, special;
rob@77 2912
rob@77 2913 // Don't attach events to noData or text/comment nodes (allow plain objects tho)
rob@77 2914 if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) {
rob@77 2915 return;
rob@77 2916 }
rob@77 2917
rob@77 2918 // Caller can pass in an object of custom data in lieu of the handler
rob@77 2919 if ( handler.handler ) {
rob@77 2920 handleObjIn = handler;
rob@77 2921 handler = handleObjIn.handler;
rob@77 2922 selector = handleObjIn.selector;
rob@77 2923 }
rob@77 2924
rob@77 2925 // Make sure that the handler has a unique ID, used to find/remove it later
rob@77 2926 if ( !handler.guid ) {
rob@77 2927 handler.guid = jQuery.guid++;
rob@77 2928 }
rob@77 2929
rob@77 2930 // Init the element's event structure and main handler, if this is the first
rob@77 2931 events = elemData.events;
rob@77 2932 if ( !events ) {
rob@77 2933 elemData.events = events = {};
rob@77 2934 }
rob@77 2935 eventHandle = elemData.handle;
rob@77 2936 if ( !eventHandle ) {
rob@77 2937 elemData.handle = eventHandle = function( e ) {
rob@77 2938 // Discard the second event of a jQuery.event.trigger() and
rob@77 2939 // when an event is called after a page has unloaded
rob@77 2940 return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ?
rob@77 2941 jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
rob@77 2942 undefined;
rob@77 2943 };
rob@77 2944 // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
rob@77 2945 eventHandle.elem = elem;
rob@77 2946 }
rob@77 2947
rob@77 2948 // Handle multiple events separated by a space
rob@77 2949 // jQuery(...).bind("mouseover mouseout", fn);
rob@77 2950 types = jQuery.trim( hoverHack(types) ).split( " " );
rob@77 2951 for ( t = 0; t < types.length; t++ ) {
rob@77 2952
rob@77 2953 tns = rtypenamespace.exec( types[t] ) || [];
rob@77 2954 type = tns[1];
rob@77 2955 namespaces = ( tns[2] || "" ).split( "." ).sort();
rob@77 2956
rob@77 2957 // If event changes its type, use the special event handlers for the changed type
rob@77 2958 special = jQuery.event.special[ type ] || {};
rob@77 2959
rob@77 2960 // If selector defined, determine special event api type, otherwise given type
rob@77 2961 type = ( selector ? special.delegateType : special.bindType ) || type;
rob@77 2962
rob@77 2963 // Update special based on newly reset type
rob@77 2964 special = jQuery.event.special[ type ] || {};
rob@77 2965
rob@77 2966 // handleObj is passed to all event handlers
rob@77 2967 handleObj = jQuery.extend({
rob@77 2968 type: type,
rob@77 2969 origType: tns[1],
rob@77 2970 data: data,
rob@77 2971 handler: handler,
rob@77 2972 guid: handler.guid,
rob@77 2973 selector: selector,
rob@77 2974 quick: selector && quickParse( selector ),
rob@77 2975 namespace: namespaces.join(".")
rob@77 2976 }, handleObjIn );
rob@77 2977
rob@77 2978 // Init the event handler queue if we're the first
rob@77 2979 handlers = events[ type ];
rob@77 2980 if ( !handlers ) {
rob@77 2981 handlers = events[ type ] = [];
rob@77 2982 handlers.delegateCount = 0;
rob@77 2983
rob@77 2984 // Only use addEventListener/attachEvent if the special events handler returns false
rob@77 2985 if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
rob@77 2986 // Bind the global event handler to the element
rob@77 2987 if ( elem.addEventListener ) {
rob@77 2988 elem.addEventListener( type, eventHandle, false );
rob@77 2989
rob@77 2990 } else if ( elem.attachEvent ) {
rob@77 2991 elem.attachEvent( "on" + type, eventHandle );
rob@77 2992 }
rob@77 2993 }
rob@77 2994 }
rob@77 2995
rob@77 2996 if ( special.add ) {
rob@77 2997 special.add.call( elem, handleObj );
rob@77 2998
rob@77 2999 if ( !handleObj.handler.guid ) {
rob@77 3000 handleObj.handler.guid = handler.guid;
rob@77 3001 }
rob@77 3002 }
rob@77 3003
rob@77 3004 // Add to the element's handler list, delegates in front
rob@77 3005 if ( selector ) {
rob@77 3006 handlers.splice( handlers.delegateCount++, 0, handleObj );
rob@77 3007 } else {
rob@77 3008 handlers.push( handleObj );
rob@77 3009 }
rob@77 3010
rob@77 3011 // Keep track of which events have ever been used, for event optimization
rob@77 3012 jQuery.event.global[ type ] = true;
rob@77 3013 }
rob@77 3014
rob@77 3015 // Nullify elem to prevent memory leaks in IE
rob@77 3016 elem = null;
rob@77 3017 },
rob@77 3018
rob@77 3019 global: {},
rob@77 3020
rob@77 3021 // Detach an event or set of events from an element
rob@77 3022 remove: function( elem, types, handler, selector, mappedTypes ) {
rob@77 3023
rob@77 3024 var elemData = jQuery.hasData( elem ) && jQuery._data( elem ),
rob@77 3025 t, tns, type, origType, namespaces, origCount,
rob@77 3026 j, events, special, handle, eventType, handleObj;
rob@77 3027
rob@77 3028 if ( !elemData || !(events = elemData.events) ) {
rob@77 3029 return;
rob@77 3030 }
rob@77 3031
rob@77 3032 // Once for each type.namespace in types; type may be omitted
rob@77 3033 types = jQuery.trim( hoverHack( types || "" ) ).split(" ");
rob@77 3034 for ( t = 0; t < types.length; t++ ) {
rob@77 3035 tns = rtypenamespace.exec( types[t] ) || [];
rob@77 3036 type = origType = tns[1];
rob@77 3037 namespaces = tns[2];
rob@77 3038
rob@77 3039 // Unbind all events (on this namespace, if provided) for the element
rob@77 3040 if ( !type ) {
rob@77 3041 for ( type in events ) {
rob@77 3042 jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
rob@77 3043 }
rob@77 3044 continue;
rob@77 3045 }
rob@77 3046
rob@77 3047 special = jQuery.event.special[ type ] || {};
rob@77 3048 type = ( selector? special.delegateType : special.bindType ) || type;
rob@77 3049 eventType = events[ type ] || [];
rob@77 3050 origCount = eventType.length;
rob@77 3051 namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.)?") + "(\\.|$)") : null;
rob@77 3052
rob@77 3053 // Remove matching events
rob@77 3054 for ( j = 0; j < eventType.length; j++ ) {
rob@77 3055 handleObj = eventType[ j ];
rob@77 3056
rob@77 3057 if ( ( mappedTypes || origType === handleObj.origType ) &&
rob@77 3058 ( !handler || handler.guid === handleObj.guid ) &&
rob@77 3059 ( !namespaces || namespaces.test( handleObj.namespace ) ) &&
rob@77 3060 ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
rob@77 3061 eventType.splice( j--, 1 );
rob@77 3062
rob@77 3063 if ( handleObj.selector ) {
rob@77 3064 eventType.delegateCount--;
rob@77 3065 }
rob@77 3066 if ( special.remove ) {
rob@77 3067 special.remove.call( elem, handleObj );
rob@77 3068 }
rob@77 3069 }
rob@77 3070 }
rob@77 3071
rob@77 3072 // Remove generic event handler if we removed something and no more handlers exist
rob@77 3073 // (avoids potential for endless recursion during removal of special event handlers)
rob@77 3074 if ( eventType.length === 0 && origCount !== eventType.length ) {
rob@77 3075 if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
rob@77 3076 jQuery.removeEvent( elem, type, elemData.handle );
rob@77 3077 }
rob@77 3078
rob@77 3079 delete events[ type ];
rob@77 3080 }
rob@77 3081 }
rob@77 3082
rob@77 3083 // Remove the expando if it's no longer used
rob@77 3084 if ( jQuery.isEmptyObject( events ) ) {
rob@77 3085 handle = elemData.handle;
rob@77 3086 if ( handle ) {
rob@77 3087 handle.elem = null;
rob@77 3088 }
rob@77 3089
rob@77 3090 // removeData also checks for emptiness and clears the expando if empty
rob@77 3091 // so use it instead of delete
rob@77 3092 jQuery.removeData( elem, [ "events", "handle" ], true );
rob@77 3093 }
rob@77 3094 },
rob@77 3095
rob@77 3096 // Events that are safe to short-circuit if no handlers are attached.
rob@77 3097 // Native DOM events should not be added, they may have inline handlers.
rob@77 3098 customEvent: {
rob@77 3099 "getData": true,
rob@77 3100 "setData": true,
rob@77 3101 "changeData": true
rob@77 3102 },
rob@77 3103
rob@77 3104 trigger: function( event, data, elem, onlyHandlers ) {
rob@77 3105 // Don't do events on text and comment nodes
rob@77 3106 if ( elem && (elem.nodeType === 3 || elem.nodeType === 8) ) {
rob@77 3107 return;
rob@77 3108 }
rob@77 3109
rob@77 3110 // Event object or event type
rob@77 3111 var type = event.type || event,
rob@77 3112 namespaces = [],
rob@77 3113 cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType;
rob@77 3114
rob@77 3115 // focus/blur morphs to focusin/out; ensure we're not firing them right now
rob@77 3116 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
rob@77 3117 return;
rob@77 3118 }
rob@77 3119
rob@77 3120 if ( type.indexOf( "!" ) >= 0 ) {
rob@77 3121 // Exclusive events trigger only for the exact event (no namespaces)
rob@77 3122 type = type.slice(0, -1);
rob@77 3123 exclusive = true;
rob@77 3124 }
rob@77 3125
rob@77 3126 if ( type.indexOf( "." ) >= 0 ) {
rob@77 3127 // Namespaced trigger; create a regexp to match event type in handle()
rob@77 3128 namespaces = type.split(".");
rob@77 3129 type = namespaces.shift();
rob@77 3130 namespaces.sort();
rob@77 3131 }
rob@77 3132
rob@77 3133 if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) {
rob@77 3134 // No jQuery handlers for this event type, and it can't have inline handlers
rob@77 3135 return;
rob@77 3136 }
rob@77 3137
rob@77 3138 // Caller can pass in an Event, Object, or just an event type string
rob@77 3139 event = typeof event === "object" ?
rob@77 3140 // jQuery.Event object
rob@77 3141 event[ jQuery.expando ] ? event :
rob@77 3142 // Object literal
rob@77 3143 new jQuery.Event( type, event ) :
rob@77 3144 // Just the event type (string)
rob@77 3145 new jQuery.Event( type );
rob@77 3146
rob@77 3147 event.type = type;
rob@77 3148 event.isTrigger = true;
rob@77 3149 event.exclusive = exclusive;
rob@77 3150 event.namespace = namespaces.join( "." );
rob@77 3151 event.namespace_re = event.namespace? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)") : null;
rob@77 3152 ontype = type.indexOf( ":" ) < 0 ? "on" + type : "";
rob@77 3153
rob@77 3154 // Handle a global trigger
rob@77 3155 if ( !elem ) {
rob@77 3156
rob@77 3157 // TODO: Stop taunting the data cache; remove global events and always attach to document
rob@77 3158 cache = jQuery.cache;
rob@77 3159 for ( i in cache ) {
rob@77 3160 if ( cache[ i ].events && cache[ i ].events[ type ] ) {
rob@77 3161 jQuery.event.trigger( event, data, cache[ i ].handle.elem, true );
rob@77 3162 }
rob@77 3163 }
rob@77 3164 return;
rob@77 3165 }
rob@77 3166
rob@77 3167 // Clean up the event in case it is being reused
rob@77 3168 event.result = undefined;
rob@77 3169 if ( !event.target ) {
rob@77 3170 event.target = elem;
rob@77 3171 }
rob@77 3172
rob@77 3173 // Clone any incoming data and prepend the event, creating the handler arg list
rob@77 3174 data = data != null ? jQuery.makeArray( data ) : [];
rob@77 3175 data.unshift( event );
rob@77 3176
rob@77 3177 // Allow special events to draw outside the lines
rob@77 3178 special = jQuery.event.special[ type ] || {};
rob@77 3179 if ( special.trigger && special.trigger.apply( elem, data ) === false ) {
rob@77 3180 return;
rob@77 3181 }
rob@77 3182
rob@77 3183 // Determine event propagation path in advance, per W3C events spec (#9951)
rob@77 3184 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
rob@77 3185 eventPath = [[ elem, special.bindType || type ]];
rob@77 3186 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
rob@77 3187
rob@77 3188 bubbleType = special.delegateType || type;
rob@77 3189 cur = rfocusMorph.test( bubbleType + type ) ? elem : elem.parentNode;
rob@77 3190 old = null;
rob@77 3191 for ( ; cur; cur = cur.parentNode ) {
rob@77 3192 eventPath.push([ cur, bubbleType ]);
rob@77 3193 old = cur;
rob@77 3194 }
rob@77 3195
rob@77 3196 // Only add window if we got to document (e.g., not plain obj or detached DOM)
rob@77 3197 if ( old && old === elem.ownerDocument ) {
rob@77 3198 eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]);
rob@77 3199 }
rob@77 3200 }
rob@77 3201
rob@77 3202 // Fire handlers on the event path
rob@77 3203 for ( i = 0; i < eventPath.length && !event.isPropagationStopped(); i++ ) {
rob@77 3204
rob@77 3205 cur = eventPath[i][0];
rob@77 3206 event.type = eventPath[i][1];
rob@77 3207
rob@77 3208 handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" );
rob@77 3209 if ( handle ) {
rob@77 3210 handle.apply( cur, data );
rob@77 3211 }
rob@77 3212 // Note that this is a bare JS function and not a jQuery handler
rob@77 3213 handle = ontype && cur[ ontype ];
rob@77 3214 if ( handle && jQuery.acceptData( cur ) && handle.apply( cur, data ) === false ) {
rob@77 3215 event.preventDefault();
rob@77 3216 }
rob@77 3217 }
rob@77 3218 event.type = type;
rob@77 3219
rob@77 3220 // If nobody prevented the default action, do it now
rob@77 3221 if ( !onlyHandlers && !event.isDefaultPrevented() ) {
rob@77 3222
rob@77 3223 if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) &&
rob@77 3224 !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) {
rob@77 3225
rob@77 3226 // Call a native DOM method on the target with the same name name as the event.
rob@77 3227 // Can't use an .isFunction() check here because IE6/7 fails that test.
rob@77 3228 // Don't do default actions on window, that's where global variables be (#6170)
rob@77 3229 // IE<9 dies on focus/blur to hidden element (#1486)
rob@77 3230 if ( ontype && elem[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) && !jQuery.isWindow( elem ) ) {
rob@77 3231
rob@77 3232 // Don't re-trigger an onFOO event when we call its FOO() method
rob@77 3233 old = elem[ ontype ];
rob@77 3234
rob@77 3235 if ( old ) {
rob@77 3236 elem[ ontype ] = null;
rob@77 3237 }
rob@77 3238
rob@77 3239 // Prevent re-triggering of the same event, since we already bubbled it above
rob@77 3240 jQuery.event.triggered = type;
rob@77 3241 elem[ type ]();
rob@77 3242 jQuery.event.triggered = undefined;
rob@77 3243
rob@77 3244 if ( old ) {
rob@77 3245 elem[ ontype ] = old;
rob@77 3246 }
rob@77 3247 }
rob@77 3248 }
rob@77 3249 }
rob@77 3250
rob@77 3251 return event.result;
rob@77 3252 },
rob@77 3253
rob@77 3254 dispatch: function( event ) {
rob@77 3255
rob@77 3256 // Make a writable jQuery.Event from the native event object
rob@77 3257 event = jQuery.event.fix( event || window.event );
rob@77 3258
rob@77 3259 var handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []),
rob@77 3260 delegateCount = handlers.delegateCount,
rob@77 3261 args = [].slice.call( arguments, 0 ),
rob@77 3262 run_all = !event.exclusive && !event.namespace,
rob@77 3263 special = jQuery.event.special[ event.type ] || {},
rob@77 3264 handlerQueue = [],
rob@77 3265 i, j, cur, jqcur, ret, selMatch, matched, matches, handleObj, sel, related;
rob@77 3266
rob@77 3267 // Use the fix-ed jQuery.Event rather than the (read-only) native event
rob@77 3268 args[0] = event;
rob@77 3269 event.delegateTarget = this;
rob@77 3270
rob@77 3271 // Call the preDispatch hook for the mapped type, and let it bail if desired
rob@77 3272 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
rob@77 3273 return;
rob@77 3274 }
rob@77 3275
rob@77 3276 // Determine handlers that should run if there are delegated events
rob@77 3277 // Avoid non-left-click bubbling in Firefox (#3861)
rob@77 3278 if ( delegateCount && !(event.button && event.type === "click") ) {
rob@77 3279
rob@77 3280 // Pregenerate a single jQuery object for reuse with .is()
rob@77 3281 jqcur = jQuery(this);
rob@77 3282 jqcur.context = this.ownerDocument || this;
rob@77 3283
rob@77 3284 for ( cur = event.target; cur != this; cur = cur.parentNode || this ) {
rob@77 3285
rob@77 3286 // Don't process events on disabled elements (#6911, #8165)
rob@77 3287 if ( cur.disabled !== true ) {
rob@77 3288 selMatch = {};
rob@77 3289 matches = [];
rob@77 3290 jqcur[0] = cur;
rob@77 3291 for ( i = 0; i < delegateCount; i++ ) {
rob@77 3292 handleObj = handlers[ i ];
rob@77 3293 sel = handleObj.selector;
rob@77 3294
rob@77 3295 if ( selMatch[ sel ] === undefined ) {
rob@77 3296 selMatch[ sel ] = (
rob@77 3297 handleObj.quick ? quickIs( cur, handleObj.quick ) : jqcur.is( sel )
rob@77 3298 );
rob@77 3299 }
rob@77 3300 if ( selMatch[ sel ] ) {
rob@77 3301 matches.push( handleObj );
rob@77 3302 }
rob@77 3303 }
rob@77 3304 if ( matches.length ) {
rob@77 3305 handlerQueue.push({ elem: cur, matches: matches });
rob@77 3306 }
rob@77 3307 }
rob@77 3308 }
rob@77 3309 }
rob@77 3310
rob@77 3311 // Add the remaining (directly-bound) handlers
rob@77 3312 if ( handlers.length > delegateCount ) {
rob@77 3313 handlerQueue.push({ elem: this, matches: handlers.slice( delegateCount ) });
rob@77 3314 }
rob@77 3315
rob@77 3316 // Run delegates first; they may want to stop propagation beneath us
rob@77 3317 for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) {
rob@77 3318 matched = handlerQueue[ i ];
rob@77 3319 event.currentTarget = matched.elem;
rob@77 3320
rob@77 3321 for ( j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++ ) {
rob@77 3322 handleObj = matched.matches[ j ];
rob@77 3323
rob@77 3324 // Triggered event must either 1) be non-exclusive and have no namespace, or
rob@77 3325 // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
rob@77 3326 if ( run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) {
rob@77 3327
rob@77 3328 event.data = handleObj.data;
rob@77 3329 event.handleObj = handleObj;
rob@77 3330
rob@77 3331 ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
rob@77 3332 .apply( matched.elem, args );
rob@77 3333
rob@77 3334 if ( ret !== undefined ) {
rob@77 3335 event.result = ret;
rob@77 3336 if ( ret === false ) {
rob@77 3337 event.preventDefault();
rob@77 3338 event.stopPropagation();
rob@77 3339 }
rob@77 3340 }
rob@77 3341 }
rob@77 3342 }
rob@77 3343 }
rob@77 3344
rob@77 3345 // Call the postDispatch hook for the mapped type
rob@77 3346 if ( special.postDispatch ) {
rob@77 3347 special.postDispatch.call( this, event );
rob@77 3348 }
rob@77 3349
rob@77 3350 return event.result;
rob@77 3351 },
rob@77 3352
rob@77 3353 // Includes some event props shared by KeyEvent and MouseEvent
rob@77 3354 // *** attrChange attrName relatedNode srcElement are not normalized, non-W3C, deprecated, will be removed in 1.8 ***
rob@77 3355 props: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
rob@77 3356
rob@77 3357 fixHooks: {},
rob@77 3358
rob@77 3359 keyHooks: {
rob@77 3360 props: "char charCode key keyCode".split(" "),
rob@77 3361 filter: function( event, original ) {
rob@77 3362
rob@77 3363 // Add which for key events
rob@77 3364 if ( event.which == null ) {
rob@77 3365 event.which = original.charCode != null ? original.charCode : original.keyCode;
rob@77 3366 }
rob@77 3367
rob@77 3368 return event;
rob@77 3369 }
rob@77 3370 },
rob@77 3371
rob@77 3372 mouseHooks: {
rob@77 3373 props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
rob@77 3374 filter: function( event, original ) {
rob@77 3375 var eventDoc, doc, body,
rob@77 3376 button = original.button,
rob@77 3377 fromElement = original.fromElement;
rob@77 3378
rob@77 3379 // Calculate pageX/Y if missing and clientX/Y available
rob@77 3380 if ( event.pageX == null && original.clientX != null ) {
rob@77 3381 eventDoc = event.target.ownerDocument || document;
rob@77 3382 doc = eventDoc.documentElement;
rob@77 3383 body = eventDoc.body;
rob@77 3384
rob@77 3385 event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
rob@77 3386 event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
rob@77 3387 }
rob@77 3388
rob@77 3389 // Add relatedTarget, if necessary
rob@77 3390 if ( !event.relatedTarget && fromElement ) {
rob@77 3391 event.relatedTarget = fromElement === event.target ? original.toElement : fromElement;
rob@77 3392 }
rob@77 3393
rob@77 3394 // Add which for click: 1 === left; 2 === middle; 3 === right
rob@77 3395 // Note: button is not normalized, so don't use it
rob@77 3396 if ( !event.which && button !== undefined ) {
rob@77 3397 event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
rob@77 3398 }
rob@77 3399
rob@77 3400 return event;
rob@77 3401 }
rob@77 3402 },
rob@77 3403
rob@77 3404 fix: function( event ) {
rob@77 3405 if ( event[ jQuery.expando ] ) {
rob@77 3406 return event;
rob@77 3407 }
rob@77 3408
rob@77 3409 // Create a writable copy of the event object and normalize some properties
rob@77 3410 var i, prop,
rob@77 3411 originalEvent = event,
rob@77 3412 fixHook = jQuery.event.fixHooks[ event.type ] || {},
rob@77 3413 copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
rob@77 3414
rob@77 3415 event = jQuery.Event( originalEvent );
rob@77 3416
rob@77 3417 for ( i = copy.length; i; ) {
rob@77 3418 prop = copy[ --i ];
rob@77 3419 event[ prop ] = originalEvent[ prop ];
rob@77 3420 }
rob@77 3421
rob@77 3422 // Fix target property, if necessary (#1925, IE 6/7/8 & Safari2)
rob@77 3423 if ( !event.target ) {
rob@77 3424 event.target = originalEvent.srcElement || document;
rob@77 3425 }
rob@77 3426
rob@77 3427 // Target should not be a text node (#504, Safari)
rob@77 3428 if ( event.target.nodeType === 3 ) {
rob@77 3429 event.target = event.target.parentNode;
rob@77 3430 }
rob@77 3431
rob@77 3432 // For mouse/key events; add metaKey if it's not there (#3368, IE6/7/8)
rob@77 3433 if ( event.metaKey === undefined ) {
rob@77 3434 event.metaKey = event.ctrlKey;
rob@77 3435 }
rob@77 3436
rob@77 3437 return fixHook.filter? fixHook.filter( event, originalEvent ) : event;
rob@77 3438 },
rob@77 3439
rob@77 3440 special: {
rob@77 3441 ready: {
rob@77 3442 // Make sure the ready event is setup
rob@77 3443 setup: jQuery.bindReady
rob@77 3444 },
rob@77 3445
rob@77 3446 load: {
rob@77 3447 // Prevent triggered image.load events from bubbling to window.load
rob@77 3448 noBubble: true
rob@77 3449 },
rob@77 3450
rob@77 3451 focus: {
rob@77 3452 delegateType: "focusin"
rob@77 3453 },
rob@77 3454 blur: {
rob@77 3455 delegateType: "focusout"
rob@77 3456 },
rob@77 3457
rob@77 3458 beforeunload: {
rob@77 3459 setup: function( data, namespaces, eventHandle ) {
rob@77 3460 // We only want to do this special case on windows
rob@77 3461 if ( jQuery.isWindow( this ) ) {
rob@77 3462 this.onbeforeunload = eventHandle;
rob@77 3463 }
rob@77 3464 },
rob@77 3465
rob@77 3466 teardown: function( namespaces, eventHandle ) {
rob@77 3467 if ( this.onbeforeunload === eventHandle ) {
rob@77 3468 this.onbeforeunload = null;
rob@77 3469 }
rob@77 3470 }
rob@77 3471 }
rob@77 3472 },
rob@77 3473
rob@77 3474 simulate: function( type, elem, event, bubble ) {
rob@77 3475 // Piggyback on a donor event to simulate a different one.
rob@77 3476 // Fake originalEvent to avoid donor's stopPropagation, but if the
rob@77 3477 // simulated event prevents default then we do the same on the donor.
rob@77 3478 var e = jQuery.extend(
rob@77 3479 new jQuery.Event(),
rob@77 3480 event,
rob@77 3481 { type: type,
rob@77 3482 isSimulated: true,
rob@77 3483 originalEvent: {}
rob@77 3484 }
rob@77 3485 );
rob@77 3486 if ( bubble ) {
rob@77 3487 jQuery.event.trigger( e, null, elem );
rob@77 3488 } else {
rob@77 3489 jQuery.event.dispatch.call( elem, e );
rob@77 3490 }
rob@77 3491 if ( e.isDefaultPrevented() ) {
rob@77 3492 event.preventDefault();
rob@77 3493 }
rob@77 3494 }
rob@77 3495 };
rob@77 3496
rob@77 3497 // Some plugins are using, but it's undocumented/deprecated and will be removed.
rob@77 3498 // The 1.7 special event interface should provide all the hooks needed now.
rob@77 3499 jQuery.event.handle = jQuery.event.dispatch;
rob@77 3500
rob@77 3501 jQuery.removeEvent = document.removeEventListener ?
rob@77 3502 function( elem, type, handle ) {
rob@77 3503 if ( elem.removeEventListener ) {
rob@77 3504 elem.removeEventListener( type, handle, false );
rob@77 3505 }
rob@77 3506 } :
rob@77 3507 function( elem, type, handle ) {
rob@77 3508 if ( elem.detachEvent ) {
rob@77 3509 elem.detachEvent( "on" + type, handle );
rob@77 3510 }
rob@77 3511 };
rob@77 3512
rob@77 3513 jQuery.Event = function( src, props ) {
rob@77 3514 // Allow instantiation without the 'new' keyword
rob@77 3515 if ( !(this instanceof jQuery.Event) ) {
rob@77 3516 return new jQuery.Event( src, props );
rob@77 3517 }
rob@77 3518
rob@77 3519 // Event object
rob@77 3520 if ( src && src.type ) {
rob@77 3521 this.originalEvent = src;
rob@77 3522 this.type = src.type;
rob@77 3523
rob@77 3524 // Events bubbling up the document may have been marked as prevented
rob@77 3525 // by a handler lower down the tree; reflect the correct value.
rob@77 3526 this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false ||
rob@77 3527 src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse;
rob@77 3528
rob@77 3529 // Event type
rob@77 3530 } else {
rob@77 3531 this.type = src;
rob@77 3532 }
rob@77 3533
rob@77 3534 // Put explicitly provided properties onto the event object
rob@77 3535 if ( props ) {
rob@77 3536 jQuery.extend( this, props );
rob@77 3537 }
rob@77 3538
rob@77 3539 // Create a timestamp if incoming event doesn't have one
rob@77 3540 this.timeStamp = src && src.timeStamp || jQuery.now();
rob@77 3541
rob@77 3542 // Mark it as fixed
rob@77 3543 this[ jQuery.expando ] = true;
rob@77 3544 };
rob@77 3545
rob@77 3546 function returnFalse() {
rob@77 3547 return false;
rob@77 3548 }
rob@77 3549 function returnTrue() {
rob@77 3550 return true;
rob@77 3551 }
rob@77 3552
rob@77 3553 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
rob@77 3554 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
rob@77 3555 jQuery.Event.prototype = {
rob@77 3556 preventDefault: function() {
rob@77 3557 this.isDefaultPrevented = returnTrue;
rob@77 3558
rob@77 3559 var e = this.originalEvent;
rob@77 3560 if ( !e ) {
rob@77 3561 return;
rob@77 3562 }
rob@77 3563
rob@77 3564 // if preventDefault exists run it on the original event
rob@77 3565 if ( e.preventDefault ) {
rob@77 3566 e.preventDefault();
rob@77 3567
rob@77 3568 // otherwise set the returnValue property of the original event to false (IE)
rob@77 3569 } else {
rob@77 3570 e.returnValue = false;
rob@77 3571 }
rob@77 3572 },
rob@77 3573 stopPropagation: function() {
rob@77 3574 this.isPropagationStopped = returnTrue;
rob@77 3575
rob@77 3576 var e = this.originalEvent;
rob@77 3577 if ( !e ) {
rob@77 3578 return;
rob@77 3579 }
rob@77 3580 // if stopPropagation exists run it on the original event
rob@77 3581 if ( e.stopPropagation ) {
rob@77 3582 e.stopPropagation();
rob@77 3583 }
rob@77 3584 // otherwise set the cancelBubble property of the original event to true (IE)
rob@77 3585 e.cancelBubble = true;
rob@77 3586 },
rob@77 3587 stopImmediatePropagation: function() {
rob@77 3588 this.isImmediatePropagationStopped = returnTrue;
rob@77 3589 this.stopPropagation();
rob@77 3590 },
rob@77 3591 isDefaultPrevented: returnFalse,
rob@77 3592 isPropagationStopped: returnFalse,
rob@77 3593 isImmediatePropagationStopped: returnFalse
rob@77 3594 };
rob@77 3595
rob@77 3596 // Create mouseenter/leave events using mouseover/out and event-time checks
rob@77 3597 jQuery.each({
rob@77 3598 mouseenter: "mouseover",
rob@77 3599 mouseleave: "mouseout"
rob@77 3600 }, function( orig, fix ) {
rob@77 3601 jQuery.event.special[ orig ] = {
rob@77 3602 delegateType: fix,
rob@77 3603 bindType: fix,
rob@77 3604
rob@77 3605 handle: function( event ) {
rob@77 3606 var target = this,
rob@77 3607 related = event.relatedTarget,
rob@77 3608 handleObj = event.handleObj,
rob@77 3609 selector = handleObj.selector,
rob@77 3610 ret;
rob@77 3611
rob@77 3612 // For mousenter/leave call the handler if related is outside the target.
rob@77 3613 // NB: No relatedTarget if the mouse left/entered the browser window
rob@77 3614 if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
rob@77 3615 event.type = handleObj.origType;
rob@77 3616 ret = handleObj.handler.apply( this, arguments );
rob@77 3617 event.type = fix;
rob@77 3618 }
rob@77 3619 return ret;
rob@77 3620 }
rob@77 3621 };
rob@77 3622 });
rob@77 3623
rob@77 3624 // IE submit delegation
rob@77 3625 if ( !jQuery.support.submitBubbles ) {
rob@77 3626
rob@77 3627 jQuery.event.special.submit = {
rob@77 3628 setup: function() {
rob@77 3629 // Only need this for delegated form submit events
rob@77 3630 if ( jQuery.nodeName( this, "form" ) ) {
rob@77 3631 return false;
rob@77 3632 }
rob@77 3633
rob@77 3634 // Lazy-add a submit handler when a descendant form may potentially be submitted
rob@77 3635 jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
rob@77 3636 // Node name check avoids a VML-related crash in IE (#9807)
rob@77 3637 var elem = e.target,
rob@77 3638 form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined;
rob@77 3639 if ( form && !form._submit_attached ) {
rob@77 3640 jQuery.event.add( form, "submit._submit", function( event ) {
rob@77 3641 event._submit_bubble = true;
rob@77 3642 });
rob@77 3643 form._submit_attached = true;
rob@77 3644 }
rob@77 3645 });
rob@77 3646 // return undefined since we don't need an event listener
rob@77 3647 },
rob@77 3648
rob@77 3649 postDispatch: function( event ) {
rob@77 3650 // If form was submitted by the user, bubble the event up the tree
rob@77 3651 if ( event._submit_bubble ) {
rob@77 3652 delete event._submit_bubble;
rob@77 3653 if ( this.parentNode && !event.isTrigger ) {
rob@77 3654 jQuery.event.simulate( "submit", this.parentNode, event, true );
rob@77 3655 }
rob@77 3656 }
rob@77 3657 },
rob@77 3658
rob@77 3659 teardown: function() {
rob@77 3660 // Only need this for delegated form submit events
rob@77 3661 if ( jQuery.nodeName( this, "form" ) ) {
rob@77 3662 return false;
rob@77 3663 }
rob@77 3664
rob@77 3665 // Remove delegated handlers; cleanData eventually reaps submit handlers attached above
rob@77 3666 jQuery.event.remove( this, "._submit" );
rob@77 3667 }
rob@77 3668 };
rob@77 3669 }
rob@77 3670
rob@77 3671 // IE change delegation and checkbox/radio fix
rob@77 3672 if ( !jQuery.support.changeBubbles ) {
rob@77 3673
rob@77 3674 jQuery.event.special.change = {
rob@77 3675
rob@77 3676 setup: function() {
rob@77 3677
rob@77 3678 if ( rformElems.test( this.nodeName ) ) {
rob@77 3679 // IE doesn't fire change on a check/radio until blur; trigger it on click
rob@77 3680 // after a propertychange. Eat the blur-change in special.change.handle.
rob@77 3681 // This still fires onchange a second time for check/radio after blur.
rob@77 3682 if ( this.type === "checkbox" || this.type === "radio" ) {
rob@77 3683 jQuery.event.add( this, "propertychange._change", function( event ) {
rob@77 3684 if ( event.originalEvent.propertyName === "checked" ) {
rob@77 3685 this._just_changed = true;
rob@77 3686 }
rob@77 3687 });
rob@77 3688 jQuery.event.add( this, "click._change", function( event ) {
rob@77 3689 if ( this._just_changed && !event.isTrigger ) {
rob@77 3690 this._just_changed = false;
rob@77 3691 jQuery.event.simulate( "change", this, event, true );
rob@77 3692 }
rob@77 3693 });
rob@77 3694 }
rob@77 3695 return false;
rob@77 3696 }
rob@77 3697 // Delegated event; lazy-add a change handler on descendant inputs
rob@77 3698 jQuery.event.add( this, "beforeactivate._change", function( e ) {
rob@77 3699 var elem = e.target;
rob@77 3700
rob@77 3701 if ( rformElems.test( elem.nodeName ) && !elem._change_attached ) {
rob@77 3702 jQuery.event.add( elem, "change._change", function( event ) {
rob@77 3703 if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
rob@77 3704 jQuery.event.simulate( "change", this.parentNode, event, true );
rob@77 3705 }
rob@77 3706 });
rob@77 3707 elem._change_attached = true;
rob@77 3708 }
rob@77 3709 });
rob@77 3710 },
rob@77 3711
rob@77 3712 handle: function( event ) {
rob@77 3713 var elem = event.target;
rob@77 3714
rob@77 3715 // Swallow native change events from checkbox/radio, we already triggered them above
rob@77 3716 if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) {
rob@77 3717 return event.handleObj.handler.apply( this, arguments );
rob@77 3718 }
rob@77 3719 },
rob@77 3720
rob@77 3721 teardown: function() {
rob@77 3722 jQuery.event.remove( this, "._change" );
rob@77 3723
rob@77 3724 return rformElems.test( this.nodeName );
rob@77 3725 }
rob@77 3726 };
rob@77 3727 }
rob@77 3728
rob@77 3729 // Create "bubbling" focus and blur events
rob@77 3730 if ( !jQuery.support.focusinBubbles ) {
rob@77 3731 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
rob@77 3732
rob@77 3733 // Attach a single capturing handler while someone wants focusin/focusout
rob@77 3734 var attaches = 0,
rob@77 3735 handler = function( event ) {
rob@77 3736 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
rob@77 3737 };
rob@77 3738
rob@77 3739 jQuery.event.special[ fix ] = {
rob@77 3740 setup: function() {
rob@77 3741 if ( attaches++ === 0 ) {
rob@77 3742 document.addEventListener( orig, handler, true );
rob@77 3743 }
rob@77 3744 },
rob@77 3745 teardown: function() {
rob@77 3746 if ( --attaches === 0 ) {
rob@77 3747 document.removeEventListener( orig, handler, true );
rob@77 3748 }
rob@77 3749 }
rob@77 3750 };
rob@77 3751 });
rob@77 3752 }
rob@77 3753
rob@77 3754 jQuery.fn.extend({
rob@77 3755
rob@77 3756 on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
rob@77 3757 var origFn, type;
rob@77 3758
rob@77 3759 // Types can be a map of types/handlers
rob@77 3760 if ( typeof types === "object" ) {
rob@77 3761 // ( types-Object, selector, data )
rob@77 3762 if ( typeof selector !== "string" ) { // && selector != null
rob@77 3763 // ( types-Object, data )
rob@77 3764 data = data || selector;
rob@77 3765 selector = undefined;
rob@77 3766 }
rob@77 3767 for ( type in types ) {
rob@77 3768 this.on( type, selector, data, types[ type ], one );
rob@77 3769 }
rob@77 3770 return this;
rob@77 3771 }
rob@77 3772
rob@77 3773 if ( data == null && fn == null ) {
rob@77 3774 // ( types, fn )
rob@77 3775 fn = selector;
rob@77 3776 data = selector = undefined;
rob@77 3777 } else if ( fn == null ) {
rob@77 3778 if ( typeof selector === "string" ) {
rob@77 3779 // ( types, selector, fn )
rob@77 3780 fn = data;
rob@77 3781 data = undefined;
rob@77 3782 } else {
rob@77 3783 // ( types, data, fn )
rob@77 3784 fn = data;
rob@77 3785 data = selector;
rob@77 3786 selector = undefined;
rob@77 3787 }
rob@77 3788 }
rob@77 3789 if ( fn === false ) {
rob@77 3790 fn = returnFalse;
rob@77 3791 } else if ( !fn ) {
rob@77 3792 return this;
rob@77 3793 }
rob@77 3794
rob@77 3795 if ( one === 1 ) {
rob@77 3796 origFn = fn;
rob@77 3797 fn = function( event ) {
rob@77 3798 // Can use an empty set, since event contains the info
rob@77 3799 jQuery().off( event );
rob@77 3800 return origFn.apply( this, arguments );
rob@77 3801 };
rob@77 3802 // Use same guid so caller can remove using origFn
rob@77 3803 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
rob@77 3804 }
rob@77 3805 return this.each( function() {
rob@77 3806 jQuery.event.add( this, types, fn, data, selector );
rob@77 3807 });
rob@77 3808 },
rob@77 3809 one: function( types, selector, data, fn ) {
rob@77 3810 return this.on( types, selector, data, fn, 1 );
rob@77 3811 },
rob@77 3812 off: function( types, selector, fn ) {
rob@77 3813 if ( types && types.preventDefault && types.handleObj ) {
rob@77 3814 // ( event ) dispatched jQuery.Event
rob@77 3815 var handleObj = types.handleObj;
rob@77 3816 jQuery( types.delegateTarget ).off(
rob@77 3817 handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
rob@77 3818 handleObj.selector,
rob@77 3819 handleObj.handler
rob@77 3820 );
rob@77 3821 return this;
rob@77 3822 }
rob@77 3823 if ( typeof types === "object" ) {
rob@77 3824 // ( types-object [, selector] )
rob@77 3825 for ( var type in types ) {
rob@77 3826 this.off( type, selector, types[ type ] );
rob@77 3827 }
rob@77 3828 return this;
rob@77 3829 }
rob@77 3830 if ( selector === false || typeof selector === "function" ) {
rob@77 3831 // ( types [, fn] )
rob@77 3832 fn = selector;
rob@77 3833 selector = undefined;
rob@77 3834 }
rob@77 3835 if ( fn === false ) {
rob@77 3836 fn = returnFalse;
rob@77 3837 }
rob@77 3838 return this.each(function() {
rob@77 3839 jQuery.event.remove( this, types, fn, selector );
rob@77 3840 });
rob@77 3841 },
rob@77 3842
rob@77 3843 bind: function( types, data, fn ) {
rob@77 3844 return this.on( types, null, data, fn );
rob@77 3845 },
rob@77 3846 unbind: function( types, fn ) {
rob@77 3847 return this.off( types, null, fn );
rob@77 3848 },
rob@77 3849
rob@77 3850 live: function( types, data, fn ) {
rob@77 3851 jQuery( this.context ).on( types, this.selector, data, fn );
rob@77 3852 return this;
rob@77 3853 },
rob@77 3854 die: function( types, fn ) {
rob@77 3855 jQuery( this.context ).off( types, this.selector || "**", fn );
rob@77 3856 return this;
rob@77 3857 },
rob@77 3858
rob@77 3859 delegate: function( selector, types, data, fn ) {
rob@77 3860 return this.on( types, selector, data, fn );
rob@77 3861 },
rob@77 3862 undelegate: function( selector, types, fn ) {
rob@77 3863 // ( namespace ) or ( selector, types [, fn] )
rob@77 3864 return arguments.length == 1? this.off( selector, "**" ) : this.off( types, selector, fn );
rob@77 3865 },
rob@77 3866
rob@77 3867 trigger: function( type, data ) {
rob@77 3868 return this.each(function() {
rob@77 3869 jQuery.event.trigger( type, data, this );
rob@77 3870 });
rob@77 3871 },
rob@77 3872 triggerHandler: function( type, data ) {
rob@77 3873 if ( this[0] ) {
rob@77 3874 return jQuery.event.trigger( type, data, this[0], true );
rob@77 3875 }
rob@77 3876 },
rob@77 3877
rob@77 3878 toggle: function( fn ) {
rob@77 3879 // Save reference to arguments for access in closure
rob@77 3880 var args = arguments,
rob@77 3881 guid = fn.guid || jQuery.guid++,
rob@77 3882 i = 0,
rob@77 3883 toggler = function( event ) {
rob@77 3884 // Figure out which function to execute
rob@77 3885 var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
rob@77 3886 jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );
rob@77 3887
rob@77 3888 // Make sure that clicks stop
rob@77 3889 event.preventDefault();
rob@77 3890
rob@77 3891 // and execute the function
rob@77 3892 return args[ lastToggle ].apply( this, arguments ) || false;
rob@77 3893 };
rob@77 3894
rob@77 3895 // link all the functions, so any of them can unbind this click handler
rob@77 3896 toggler.guid = guid;
rob@77 3897 while ( i < args.length ) {
rob@77 3898 args[ i++ ].guid = guid;
rob@77 3899 }
rob@77 3900
rob@77 3901 return this.click( toggler );
rob@77 3902 },
rob@77 3903
rob@77 3904 hover: function( fnOver, fnOut ) {
rob@77 3905 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
rob@77 3906 }
rob@77 3907 });
rob@77 3908
rob@77 3909 jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
rob@77 3910 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
rob@77 3911 "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
rob@77 3912
rob@77 3913 // Handle event binding
rob@77 3914 jQuery.fn[ name ] = function( data, fn ) {
rob@77 3915 if ( fn == null ) {
rob@77 3916 fn = data;
rob@77 3917 data = null;
rob@77 3918 }
rob@77 3919
rob@77 3920 return arguments.length > 0 ?
rob@77 3921 this.on( name, null, data, fn ) :
rob@77 3922 this.trigger( name );
rob@77 3923 };
rob@77 3924
rob@77 3925 if ( jQuery.attrFn ) {
rob@77 3926 jQuery.attrFn[ name ] = true;
rob@77 3927 }
rob@77 3928
rob@77 3929 if ( rkeyEvent.test( name ) ) {
rob@77 3930 jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks;
rob@77 3931 }
rob@77 3932
rob@77 3933 if ( rmouseEvent.test( name ) ) {
rob@77 3934 jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks;
rob@77 3935 }
rob@77 3936 });
rob@77 3937
rob@77 3938
rob@77 3939
rob@77 3940 /*!
rob@77 3941 * Sizzle CSS Selector Engine
rob@77 3942 * Copyright 2011, The Dojo Foundation
rob@77 3943 * Released under the MIT, BSD, and GPL Licenses.
rob@77 3944 * More information: http://sizzlejs.com/
rob@77 3945 */
rob@77 3946 (function(){
rob@77 3947
rob@77 3948 var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
rob@77 3949 expando = "sizcache" + (Math.random() + '').replace('.', ''),
rob@77 3950 done = 0,
rob@77 3951 toString = Object.prototype.toString,
rob@77 3952 hasDuplicate = false,
rob@77 3953 baseHasDuplicate = true,
rob@77 3954 rBackslash = /\\/g,
rob@77 3955 rReturn = /\r\n/g,
rob@77 3956 rNonWord = /\W/;
rob@77 3957
rob@77 3958 // Here we check if the JavaScript engine is using some sort of
rob@77 3959 // optimization where it does not always call our comparision
rob@77 3960 // function. If that is the case, discard the hasDuplicate value.
rob@77 3961 // Thus far that includes Google Chrome.
rob@77 3962 [0, 0].sort(function() {
rob@77 3963 baseHasDuplicate = false;
rob@77 3964 return 0;
rob@77 3965 });
rob@77 3966
rob@77 3967 var Sizzle = function( selector, context, results, seed ) {
rob@77 3968 results = results || [];
rob@77 3969 context = context || document;
rob@77 3970
rob@77 3971 var origContext = context;
rob@77 3972
rob@77 3973 if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
rob@77 3974 return [];
rob@77 3975 }
rob@77 3976
rob@77 3977 if ( !selector || typeof selector !== "string" ) {
rob@77 3978 return results;
rob@77 3979 }
rob@77 3980
rob@77 3981 var m, set, checkSet, extra, ret, cur, pop, i,
rob@77 3982 prune = true,
rob@77 3983 contextXML = Sizzle.isXML( context ),
rob@77 3984 parts = [],
rob@77 3985 soFar = selector;
rob@77 3986
rob@77 3987 // Reset the position of the chunker regexp (start from head)
rob@77 3988 do {
rob@77 3989 chunker.exec( "" );
rob@77 3990 m = chunker.exec( soFar );
rob@77 3991
rob@77 3992 if ( m ) {
rob@77 3993 soFar = m[3];
rob@77 3994
rob@77 3995 parts.push( m[1] );
rob@77 3996
rob@77 3997 if ( m[2] ) {
rob@77 3998 extra = m[3];
rob@77 3999 break;
rob@77 4000 }
rob@77 4001 }
rob@77 4002 } while ( m );
rob@77 4003
rob@77 4004 if ( parts.length > 1 && origPOS.exec( selector ) ) {
rob@77 4005
rob@77 4006 if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
rob@77 4007 set = posProcess( parts[0] + parts[1], context, seed );
rob@77 4008
rob@77 4009 } else {
rob@77 4010 set = Expr.relative[ parts[0] ] ?
rob@77 4011 [ context ] :
rob@77 4012 Sizzle( parts.shift(), context );
rob@77 4013
rob@77 4014 while ( parts.length ) {
rob@77 4015 selector = parts.shift();
rob@77 4016
rob@77 4017 if ( Expr.relative[ selector ] ) {
rob@77 4018 selector += parts.shift();
rob@77 4019 }
rob@77 4020
rob@77 4021 set = posProcess( selector, set, seed );
rob@77 4022 }
rob@77 4023 }
rob@77 4024
rob@77 4025 } else {
rob@77 4026 // Take a shortcut and set the context if the root selector is an ID
rob@77 4027 // (but not if it'll be faster if the inner selector is an ID)
rob@77 4028 if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
rob@77 4029 Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
rob@77 4030
rob@77 4031 ret = Sizzle.find( parts.shift(), context, contextXML );
rob@77 4032 context = ret.expr ?
rob@77 4033 Sizzle.filter( ret.expr, ret.set )[0] :
rob@77 4034 ret.set[0];
rob@77 4035 }
rob@77 4036
rob@77 4037 if ( context ) {
rob@77 4038 ret = seed ?
rob@77 4039 { expr: parts.pop(), set: makeArray(seed) } :
rob@77 4040 Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
rob@77 4041
rob@77 4042 set = ret.expr ?
rob@77 4043 Sizzle.filter( ret.expr, ret.set ) :
rob@77 4044 ret.set;
rob@77 4045
rob@77 4046 if ( parts.length > 0 ) {
rob@77 4047 checkSet = makeArray( set );
rob@77 4048
rob@77 4049 } else {
rob@77 4050 prune = false;
rob@77 4051 }
rob@77 4052
rob@77 4053 while ( parts.length ) {
rob@77 4054 cur = parts.pop();
rob@77 4055 pop = cur;
rob@77 4056
rob@77 4057 if ( !Expr.relative[ cur ] ) {
rob@77 4058 cur = "";
rob@77 4059 } else {
rob@77 4060 pop = parts.pop();
rob@77 4061 }
rob@77 4062
rob@77 4063 if ( pop == null ) {
rob@77 4064 pop = context;
rob@77 4065 }
rob@77 4066
rob@77 4067 Expr.relative[ cur ]( checkSet, pop, contextXML );
rob@77 4068 }
rob@77 4069
rob@77 4070 } else {
rob@77 4071 checkSet = parts = [];
rob@77 4072 }
rob@77 4073 }
rob@77 4074
rob@77 4075 if ( !checkSet ) {
rob@77 4076 checkSet = set;
rob@77 4077 }
rob@77 4078
rob@77 4079 if ( !checkSet ) {
rob@77 4080 Sizzle.error( cur || selector );
rob@77 4081 }
rob@77 4082
rob@77 4083 if ( toString.call(checkSet) === "[object Array]" ) {
rob@77 4084 if ( !prune ) {
rob@77 4085 results.push.apply( results, checkSet );
rob@77 4086
rob@77 4087 } else if ( context && context.nodeType === 1 ) {
rob@77 4088 for ( i = 0; checkSet[i] != null; i++ ) {
rob@77 4089 if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) {
rob@77 4090 results.push( set[i] );
rob@77 4091 }
rob@77 4092 }
rob@77 4093
rob@77 4094 } else {
rob@77 4095 for ( i = 0; checkSet[i] != null; i++ ) {
rob@77 4096 if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
rob@77 4097 results.push( set[i] );
rob@77 4098 }
rob@77 4099 }
rob@77 4100 }
rob@77 4101
rob@77 4102 } else {
rob@77 4103 makeArray( checkSet, results );
rob@77 4104 }
rob@77 4105
rob@77 4106 if ( extra ) {
rob@77 4107 Sizzle( extra, origContext, results, seed );
rob@77 4108 Sizzle.uniqueSort( results );
rob@77 4109 }
rob@77 4110
rob@77 4111 return results;
rob@77 4112 };
rob@77 4113
rob@77 4114 Sizzle.uniqueSort = function( results ) {
rob@77 4115 if ( sortOrder ) {
rob@77 4116 hasDuplicate = baseHasDuplicate;
rob@77 4117 results.sort( sortOrder );
rob@77 4118
rob@77 4119 if ( hasDuplicate ) {
rob@77 4120 for ( var i = 1; i < results.length; i++ ) {
rob@77 4121 if ( results[i] === results[ i - 1 ] ) {
rob@77 4122 results.splice( i--, 1 );
rob@77 4123 }
rob@77 4124 }
rob@77 4125 }
rob@77 4126 }
rob@77 4127
rob@77 4128 return results;
rob@77 4129 };
rob@77 4130
rob@77 4131 Sizzle.matches = function( expr, set ) {
rob@77 4132 return Sizzle( expr, null, null, set );
rob@77 4133 };
rob@77 4134
rob@77 4135 Sizzle.matchesSelector = function( node, expr ) {
rob@77 4136 return Sizzle( expr, null, null, [node] ).length > 0;
rob@77 4137 };
rob@77 4138
rob@77 4139 Sizzle.find = function( expr, context, isXML ) {
rob@77 4140 var set, i, len, match, type, left;
rob@77 4141
rob@77 4142 if ( !expr ) {
rob@77 4143 return [];
rob@77 4144 }
rob@77 4145
rob@77 4146 for ( i = 0, len = Expr.order.length; i < len; i++ ) {
rob@77 4147 type = Expr.order[i];
rob@77 4148
rob@77 4149 if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
rob@77 4150 left = match[1];
rob@77 4151 match.splice( 1, 1 );
rob@77 4152
rob@77 4153 if ( left.substr( left.length - 1 ) !== "\\" ) {
rob@77 4154 match[1] = (match[1] || "").replace( rBackslash, "" );
rob@77 4155 set = Expr.find[ type ]( match, context, isXML );
rob@77 4156
rob@77 4157 if ( set != null ) {
rob@77 4158 expr = expr.replace( Expr.match[ type ], "" );
rob@77 4159 break;
rob@77 4160 }
rob@77 4161 }
rob@77 4162 }
rob@77 4163 }
rob@77 4164
rob@77 4165 if ( !set ) {
rob@77 4166 set = typeof context.getElementsByTagName !== "undefined" ?
rob@77 4167 context.getElementsByTagName( "*" ) :
rob@77 4168 [];
rob@77 4169 }
rob@77 4170
rob@77 4171 return { set: set, expr: expr };
rob@77 4172 };
rob@77 4173
rob@77 4174 Sizzle.filter = function( expr, set, inplace, not ) {
rob@77 4175 var match, anyFound,
rob@77 4176 type, found, item, filter, left,
rob@77 4177 i, pass,
rob@77 4178 old = expr,
rob@77 4179 result = [],
rob@77 4180 curLoop = set,
rob@77 4181 isXMLFilter = set && set[0] && Sizzle.isXML( set[0] );
rob@77 4182
rob@77 4183 while ( expr && set.length ) {
rob@77 4184 for ( type in Expr.filter ) {
rob@77 4185 if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
rob@77 4186 filter = Expr.filter[ type ];
rob@77 4187 left = match[1];
rob@77 4188
rob@77 4189 anyFound = false;
rob@77 4190
rob@77 4191 match.splice(1,1);
rob@77 4192
rob@77 4193 if ( left.substr( left.length - 1 ) === "\\" ) {
rob@77 4194 continue;
rob@77 4195 }
rob@77 4196
rob@77 4197 if ( curLoop === result ) {
rob@77 4198 result = [];
rob@77 4199 }
rob@77 4200
rob@77 4201 if ( Expr.preFilter[ type ] ) {
rob@77 4202 match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
rob@77 4203
rob@77 4204 if ( !match ) {
rob@77 4205 anyFound = found = true;
rob@77 4206
rob@77 4207 } else if ( match === true ) {
rob@77 4208 continue;
rob@77 4209 }
rob@77 4210 }
rob@77 4211
rob@77 4212 if ( match ) {
rob@77 4213 for ( i = 0; (item = curLoop[i]) != null; i++ ) {
rob@77 4214 if ( item ) {
rob@77 4215 found = filter( item, match, i, curLoop );
rob@77 4216 pass = not ^ found;
rob@77 4217
rob@77 4218 if ( inplace && found != null ) {
rob@77 4219 if ( pass ) {
rob@77 4220 anyFound = true;
rob@77 4221
rob@77 4222 } else {
rob@77 4223 curLoop[i] = false;
rob@77 4224 }
rob@77 4225
rob@77 4226 } else if ( pass ) {
rob@77 4227 result.push( item );
rob@77 4228 anyFound = true;
rob@77 4229 }
rob@77 4230 }
rob@77 4231 }
rob@77 4232 }
rob@77 4233
rob@77 4234 if ( found !== undefined ) {
rob@77 4235 if ( !inplace ) {
rob@77 4236 curLoop = result;
rob@77 4237 }
rob@77 4238
rob@77 4239 expr = expr.replace( Expr.match[ type ], "" );
rob@77 4240
rob@77 4241 if ( !anyFound ) {
rob@77 4242 return [];
rob@77 4243 }
rob@77 4244
rob@77 4245 break;
rob@77 4246 }
rob@77 4247 }
rob@77 4248 }
rob@77 4249
rob@77 4250 // Improper expression
rob@77 4251 if ( expr === old ) {
rob@77 4252 if ( anyFound == null ) {
rob@77 4253 Sizzle.error( expr );
rob@77 4254
rob@77 4255 } else {
rob@77 4256 break;
rob@77 4257 }
rob@77 4258 }
rob@77 4259
rob@77 4260 old = expr;
rob@77 4261 }
rob@77 4262
rob@77 4263 return curLoop;
rob@77 4264 };
rob@77 4265
rob@77 4266 Sizzle.error = function( msg ) {
rob@77 4267 throw new Error( "Syntax error, unrecognized expression: " + msg );
rob@77 4268 };
rob@77 4269
rob@77 4270 /**
rob@77 4271 * Utility function for retreiving the text value of an array of DOM nodes
rob@77 4272 * @param {Array|Element} elem
rob@77 4273 */
rob@77 4274 var getText = Sizzle.getText = function( elem ) {
rob@77 4275 var i, node,
rob@77 4276 nodeType = elem.nodeType,
rob@77 4277 ret = "";
rob@77 4278
rob@77 4279 if ( nodeType ) {
rob@77 4280 if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
rob@77 4281 // Use textContent || innerText for elements
rob@77 4282 if ( typeof elem.textContent === 'string' ) {
rob@77 4283 return elem.textContent;
rob@77 4284 } else if ( typeof elem.innerText === 'string' ) {
rob@77 4285 // Replace IE's carriage returns
rob@77 4286 return elem.innerText.replace( rReturn, '' );
rob@77 4287 } else {
rob@77 4288 // Traverse it's children
rob@77 4289 for ( elem = elem.firstChild; elem; elem = elem.nextSibling) {
rob@77 4290 ret += getText( elem );
rob@77 4291 }
rob@77 4292 }
rob@77 4293 } else if ( nodeType === 3 || nodeType === 4 ) {
rob@77 4294 return elem.nodeValue;
rob@77 4295 }
rob@77 4296 } else {
rob@77 4297
rob@77 4298 // If no nodeType, this is expected to be an array
rob@77 4299 for ( i = 0; (node = elem[i]); i++ ) {
rob@77 4300 // Do not traverse comment nodes
rob@77 4301 if ( node.nodeType !== 8 ) {
rob@77 4302 ret += getText( node );
rob@77 4303 }
rob@77 4304 }
rob@77 4305 }
rob@77 4306 return ret;
rob@77 4307 };
rob@77 4308
rob@77 4309 var Expr = Sizzle.selectors = {
rob@77 4310 order: [ "ID", "NAME", "TAG" ],
rob@77 4311
rob@77 4312 match: {
rob@77 4313 ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
rob@77 4314 CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
rob@77 4315 NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,
rob@77 4316 ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,
rob@77 4317 TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,
rob@77 4318 CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,
rob@77 4319 POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,
rob@77 4320 PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
rob@77 4321 },
rob@77 4322
rob@77 4323 leftMatch: {},
rob@77 4324
rob@77 4325 attrMap: {
rob@77 4326 "class": "className",
rob@77 4327 "for": "htmlFor"
rob@77 4328 },
rob@77 4329
rob@77 4330 attrHandle: {
rob@77 4331 href: function( elem ) {
rob@77 4332 return elem.getAttribute( "href" );
rob@77 4333 },
rob@77 4334 type: function( elem ) {
rob@77 4335 return elem.getAttribute( "type" );
rob@77 4336 }
rob@77 4337 },
rob@77 4338
rob@77 4339 relative: {
rob@77 4340 "+": function(checkSet, part){
rob@77 4341 var isPartStr = typeof part === "string",
rob@77 4342 isTag = isPartStr && !rNonWord.test( part ),
rob@77 4343 isPartStrNotTag = isPartStr && !isTag;
rob@77 4344
rob@77 4345 if ( isTag ) {
rob@77 4346 part = part.toLowerCase();
rob@77 4347 }
rob@77 4348
rob@77 4349 for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
rob@77 4350 if ( (elem = checkSet[i]) ) {
rob@77 4351 while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
rob@77 4352
rob@77 4353 checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
rob@77 4354 elem || false :
rob@77 4355 elem === part;
rob@77 4356 }
rob@77 4357 }
rob@77 4358
rob@77 4359 if ( isPartStrNotTag ) {
rob@77 4360 Sizzle.filter( part, checkSet, true );
rob@77 4361 }
rob@77 4362 },
rob@77 4363
rob@77 4364 ">": function( checkSet, part ) {
rob@77 4365 var elem,
rob@77 4366 isPartStr = typeof part === "string",
rob@77 4367 i = 0,
rob@77 4368 l = checkSet.length;
rob@77 4369
rob@77 4370 if ( isPartStr && !rNonWord.test( part ) ) {
rob@77 4371 part = part.toLowerCase();
rob@77 4372
rob@77 4373 for ( ; i < l; i++ ) {
rob@77 4374 elem = checkSet[i];
rob@77 4375
rob@77 4376 if ( elem ) {
rob@77 4377 var parent = elem.parentNode;
rob@77 4378 checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
rob@77 4379 }
rob@77 4380 }
rob@77 4381
rob@77 4382 } else {
rob@77 4383 for ( ; i < l; i++ ) {
rob@77 4384 elem = checkSet[i];
rob@77 4385
rob@77 4386 if ( elem ) {
rob@77 4387 checkSet[i] = isPartStr ?
rob@77 4388 elem.parentNode :
rob@77 4389 elem.parentNode === part;
rob@77 4390 }
rob@77 4391 }
rob@77 4392
rob@77 4393 if ( isPartStr ) {
rob@77 4394 Sizzle.filter( part, checkSet, true );
rob@77 4395 }
rob@77 4396 }
rob@77 4397 },
rob@77 4398
rob@77 4399 "": function(checkSet, part, isXML){
rob@77 4400 var nodeCheck,
rob@77 4401 doneName = done++,
rob@77 4402 checkFn = dirCheck;
rob@77 4403
rob@77 4404 if ( typeof part === "string" && !rNonWord.test( part ) ) {
rob@77 4405 part = part.toLowerCase();
rob@77 4406 nodeCheck = part;
rob@77 4407 checkFn = dirNodeCheck;
rob@77 4408 }
rob@77 4409
rob@77 4410 checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML );
rob@77 4411 },
rob@77 4412
rob@77 4413 "~": function( checkSet, part, isXML ) {
rob@77 4414 var nodeCheck,
rob@77 4415 doneName = done++,
rob@77 4416 checkFn = dirCheck;
rob@77 4417
rob@77 4418 if ( typeof part === "string" && !rNonWord.test( part ) ) {
rob@77 4419 part = part.toLowerCase();
rob@77 4420 nodeCheck = part;
rob@77 4421 checkFn = dirNodeCheck;
rob@77 4422 }
rob@77 4423
rob@77 4424 checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML );
rob@77 4425 }
rob@77 4426 },
rob@77 4427
rob@77 4428 find: {
rob@77 4429 ID: function( match, context, isXML ) {
rob@77 4430 if ( typeof context.getElementById !== "undefined" && !isXML ) {
rob@77 4431 var m = context.getElementById(match[1]);
rob@77 4432 // Check parentNode to catch when Blackberry 4.6 returns
rob@77 4433 // nodes that are no longer in the document #6963
rob@77 4434 return m && m.parentNode ? [m] : [];
rob@77 4435 }
rob@77 4436 },
rob@77 4437
rob@77 4438 NAME: function( match, context ) {
rob@77 4439 if ( typeof context.getElementsByName !== "undefined" ) {
rob@77 4440 var ret = [],
rob@77 4441 results = context.getElementsByName( match[1] );
rob@77 4442
rob@77 4443 for ( var i = 0, l = results.length; i < l; i++ ) {
rob@77 4444 if ( results[i].getAttribute("name") === match[1] ) {
rob@77 4445 ret.push( results[i] );
rob@77 4446 }
rob@77 4447 }
rob@77 4448
rob@77 4449 return ret.length === 0 ? null : ret;
rob@77 4450 }
rob@77 4451 },
rob@77 4452
rob@77 4453 TAG: function( match, context ) {
rob@77 4454 if ( typeof context.getElementsByTagName !== "undefined" ) {
rob@77 4455 return context.getElementsByTagName( match[1] );
rob@77 4456 }
rob@77 4457 }
rob@77 4458 },
rob@77 4459 preFilter: {
rob@77 4460 CLASS: function( match, curLoop, inplace, result, not, isXML ) {
rob@77 4461 match = " " + match[1].replace( rBackslash, "" ) + " ";
rob@77 4462
rob@77 4463 if ( isXML ) {
rob@77 4464 return match;
rob@77 4465 }
rob@77 4466
rob@77 4467 for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
rob@77 4468 if ( elem ) {
rob@77 4469 if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) {
rob@77 4470 if ( !inplace ) {
rob@77 4471 result.push( elem );
rob@77 4472 }
rob@77 4473
rob@77 4474 } else if ( inplace ) {
rob@77 4475 curLoop[i] = false;
rob@77 4476 }
rob@77 4477 }
rob@77 4478 }
rob@77 4479
rob@77 4480 return false;
rob@77 4481 },
rob@77 4482
rob@77 4483 ID: function( match ) {
rob@77 4484 return match[1].replace( rBackslash, "" );
rob@77 4485 },
rob@77 4486
rob@77 4487 TAG: function( match, curLoop ) {
rob@77 4488 return match[1].replace( rBackslash, "" ).toLowerCase();
rob@77 4489 },
rob@77 4490
rob@77 4491 CHILD: function( match ) {
rob@77 4492 if ( match[1] === "nth" ) {
rob@77 4493 if ( !match[2] ) {
rob@77 4494 Sizzle.error( match[0] );
rob@77 4495 }
rob@77 4496
rob@77 4497 match[2] = match[2].replace(/^\+|\s*/g, '');
rob@77 4498
rob@77 4499 // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
rob@77 4500 var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec(
rob@77 4501 match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
rob@77 4502 !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
rob@77 4503
rob@77 4504 // calculate the numbers (first)n+(last) including if they are negative
rob@77 4505 match[2] = (test[1] + (test[2] || 1)) - 0;
rob@77 4506 match[3] = test[3] - 0;
rob@77 4507 }
rob@77 4508 else if ( match[2] ) {
rob@77 4509 Sizzle.error( match[0] );
rob@77 4510 }
rob@77 4511
rob@77 4512 // TODO: Move to normal caching system
rob@77 4513 match[0] = done++;
rob@77 4514
rob@77 4515 return match;
rob@77 4516 },
rob@77 4517
rob@77 4518 ATTR: function( match, curLoop, inplace, result, not, isXML ) {
rob@77 4519 var name = match[1] = match[1].replace( rBackslash, "" );
rob@77 4520
rob@77 4521 if ( !isXML && Expr.attrMap[name] ) {
rob@77 4522 match[1] = Expr.attrMap[name];
rob@77 4523 }
rob@77 4524
rob@77 4525 // Handle if an un-quoted value was used
rob@77 4526 match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" );
rob@77 4527
rob@77 4528 if ( match[2] === "~=" ) {
rob@77 4529 match[4] = " " + match[4] + " ";
rob@77 4530 }
rob@77 4531
rob@77 4532 return match;
rob@77 4533 },
rob@77 4534
rob@77 4535 PSEUDO: function( match, curLoop, inplace, result, not ) {
rob@77 4536 if ( match[1] === "not" ) {
rob@77 4537 // If we're dealing with a complex expression, or a simple one
rob@77 4538 if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
rob@77 4539 match[3] = Sizzle(match[3], null, null, curLoop);
rob@77 4540
rob@77 4541 } else {
rob@77 4542 var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
rob@77 4543
rob@77 4544 if ( !inplace ) {
rob@77 4545 result.push.apply( result, ret );
rob@77 4546 }
rob@77 4547
rob@77 4548 return false;
rob@77 4549 }
rob@77 4550
rob@77 4551 } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
rob@77 4552 return true;
rob@77 4553 }
rob@77 4554
rob@77 4555 return match;
rob@77 4556 },
rob@77 4557
rob@77 4558 POS: function( match ) {
rob@77 4559 match.unshift( true );
rob@77 4560
rob@77 4561 return match;
rob@77 4562 }
rob@77 4563 },
rob@77 4564
rob@77 4565 filters: {
rob@77 4566 enabled: function( elem ) {
rob@77 4567 return elem.disabled === false && elem.type !== "hidden";
rob@77 4568 },
rob@77 4569
rob@77 4570 disabled: function( elem ) {
rob@77 4571 return elem.disabled === true;
rob@77 4572 },
rob@77 4573
rob@77 4574 checked: function( elem ) {
rob@77 4575 return elem.checked === true;
rob@77 4576 },
rob@77 4577
rob@77 4578 selected: function( elem ) {
rob@77 4579 // Accessing this property makes selected-by-default
rob@77 4580 // options in Safari work properly
rob@77 4581 if ( elem.parentNode ) {
rob@77 4582 elem.parentNode.selectedIndex;
rob@77 4583 }
rob@77 4584
rob@77 4585 return elem.selected === true;
rob@77 4586 },
rob@77 4587
rob@77 4588 parent: function( elem ) {
rob@77 4589 return !!elem.firstChild;
rob@77 4590 },
rob@77 4591
rob@77 4592 empty: function( elem ) {
rob@77 4593 return !elem.firstChild;
rob@77 4594 },
rob@77 4595
rob@77 4596 has: function( elem, i, match ) {
rob@77 4597 return !!Sizzle( match[3], elem ).length;
rob@77 4598 },
rob@77 4599
rob@77 4600 header: function( elem ) {
rob@77 4601 return (/h\d/i).test( elem.nodeName );
rob@77 4602 },
rob@77 4603
rob@77 4604 text: function( elem ) {
rob@77 4605 var attr = elem.getAttribute( "type" ), type = elem.type;
rob@77 4606 // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
rob@77 4607 // use getAttribute instead to test this case
rob@77 4608 return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null );
rob@77 4609 },
rob@77 4610
rob@77 4611 radio: function( elem ) {
rob@77 4612 return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type;
rob@77 4613 },
rob@77 4614
rob@77 4615 checkbox: function( elem ) {
rob@77 4616 return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type;
rob@77 4617 },
rob@77 4618
rob@77 4619 file: function( elem ) {
rob@77 4620 return elem.nodeName.toLowerCase() === "input" && "file" === elem.type;
rob@77 4621 },
rob@77 4622
rob@77 4623 password: function( elem ) {
rob@77 4624 return elem.nodeName.toLowerCase() === "input" && "password" === elem.type;
rob@77 4625 },
rob@77 4626
rob@77 4627 submit: function( elem ) {
rob@77 4628 var name = elem.nodeName.toLowerCase();
rob@77 4629 return (name === "input" || name === "button") && "submit" === elem.type;
rob@77 4630 },
rob@77 4631
rob@77 4632 image: function( elem ) {
rob@77 4633 return elem.nodeName.toLowerCase() === "input" && "image" === elem.type;
rob@77 4634 },
rob@77 4635
rob@77 4636 reset: function( elem ) {
rob@77 4637 var name = elem.nodeName.toLowerCase();
rob@77 4638 return (name === "input" || name === "button") && "reset" === elem.type;
rob@77 4639 },
rob@77 4640
rob@77 4641 button: function( elem ) {
rob@77 4642 var name = elem.nodeName.toLowerCase();
rob@77 4643 return name === "input" && "button" === elem.type || name === "button";
rob@77 4644 },
rob@77 4645
rob@77 4646 input: function( elem ) {
rob@77 4647 return (/input|select|textarea|button/i).test( elem.nodeName );
rob@77 4648 },
rob@77 4649
rob@77 4650 focus: function( elem ) {
rob@77 4651 return elem === elem.ownerDocument.activeElement;
rob@77 4652 }
rob@77 4653 },
rob@77 4654 setFilters: {
rob@77 4655 first: function( elem, i ) {
rob@77 4656 return i === 0;
rob@77 4657 },
rob@77 4658
rob@77 4659 last: function( elem, i, match, array ) {
rob@77 4660 return i === array.length - 1;
rob@77 4661 },
rob@77 4662
rob@77 4663 even: function( elem, i ) {
rob@77 4664 return i % 2 === 0;
rob@77 4665 },
rob@77 4666
rob@77 4667 odd: function( elem, i ) {
rob@77 4668 return i % 2 === 1;
rob@77 4669 },
rob@77 4670
rob@77 4671 lt: function( elem, i, match ) {
rob@77 4672 return i < match[3] - 0;
rob@77 4673 },
rob@77 4674
rob@77 4675 gt: function( elem, i, match ) {
rob@77 4676 return i > match[3] - 0;
rob@77 4677 },
rob@77 4678
rob@77 4679 nth: function( elem, i, match ) {
rob@77 4680 return match[3] - 0 === i;
rob@77 4681 },
rob@77 4682
rob@77 4683 eq: function( elem, i, match ) {
rob@77 4684 return match[3] - 0 === i;
rob@77 4685 }
rob@77 4686 },
rob@77 4687 filter: {
rob@77 4688 PSEUDO: function( elem, match, i, array ) {
rob@77 4689 var name = match[1],
rob@77 4690 filter = Expr.filters[ name ];
rob@77 4691
rob@77 4692 if ( filter ) {
rob@77 4693 return filter( elem, i, match, array );
rob@77 4694
rob@77 4695 } else if ( name === "contains" ) {
rob@77 4696 return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0;
rob@77 4697
rob@77 4698 } else if ( name === "not" ) {
rob@77 4699 var not = match[3];
rob@77 4700
rob@77 4701 for ( var j = 0, l = not.length; j < l; j++ ) {
rob@77 4702 if ( not[j] === elem ) {
rob@77 4703 return false;
rob@77 4704 }
rob@77 4705 }
rob@77 4706
rob@77 4707 return true;
rob@77 4708
rob@77 4709 } else {
rob@77 4710 Sizzle.error( name );
rob@77 4711 }
rob@77 4712 },
rob@77 4713
rob@77 4714 CHILD: function( elem, match ) {
rob@77 4715 var first, last,
rob@77 4716 doneName, parent, cache,
rob@77 4717 count, diff,
rob@77 4718 type = match[1],
rob@77 4719 node = elem;
rob@77 4720
rob@77 4721 switch ( type ) {
rob@77 4722 case "only":
rob@77 4723 case "first":
rob@77 4724 while ( (node = node.previousSibling) ) {
rob@77 4725 if ( node.nodeType === 1 ) {
rob@77 4726 return false;
rob@77 4727 }
rob@77 4728 }
rob@77 4729
rob@77 4730 if ( type === "first" ) {
rob@77 4731 return true;
rob@77 4732 }
rob@77 4733
rob@77 4734 node = elem;
rob@77 4735
rob@77 4736 /* falls through */
rob@77 4737 case "last":
rob@77 4738 while ( (node = node.nextSibling) ) {
rob@77 4739 if ( node.nodeType === 1 ) {
rob@77 4740 return false;
rob@77 4741 }
rob@77 4742 }
rob@77 4743
rob@77 4744 return true;
rob@77 4745
rob@77 4746 case "nth":
rob@77 4747 first = match[2];
rob@77 4748 last = match[3];
rob@77 4749
rob@77 4750 if ( first === 1 && last === 0 ) {
rob@77 4751 return true;
rob@77 4752 }
rob@77 4753
rob@77 4754 doneName = match[0];
rob@77 4755 parent = elem.parentNode;
rob@77 4756
rob@77 4757 if ( parent && (parent[ expando ] !== doneName || !elem.nodeIndex) ) {
rob@77 4758 count = 0;
rob@77 4759
rob@77 4760 for ( node = parent.firstChild; node; node = node.nextSibling ) {
rob@77 4761 if ( node.nodeType === 1 ) {
rob@77 4762 node.nodeIndex = ++count;
rob@77 4763 }
rob@77 4764 }
rob@77 4765
rob@77 4766 parent[ expando ] = doneName;
rob@77 4767 }
rob@77 4768
rob@77 4769 diff = elem.nodeIndex - last;
rob@77 4770
rob@77 4771 if ( first === 0 ) {
rob@77 4772 return diff === 0;
rob@77 4773
rob@77 4774 } else {
rob@77 4775 return ( diff % first === 0 && diff / first >= 0 );
rob@77 4776 }
rob@77 4777 }
rob@77 4778 },
rob@77 4779
rob@77 4780 ID: function( elem, match ) {
rob@77 4781 return elem.nodeType === 1 && elem.getAttribute("id") === match;
rob@77 4782 },
rob@77 4783
rob@77 4784 TAG: function( elem, match ) {
rob@77 4785 return (match === "*" && elem.nodeType === 1) || !!elem.nodeName && elem.nodeName.toLowerCase() === match;
rob@77 4786 },
rob@77 4787
rob@77 4788 CLASS: function( elem, match ) {
rob@77 4789 return (" " + (elem.className || elem.getAttribute("class")) + " ")
rob@77 4790 .indexOf( match ) > -1;
rob@77 4791 },
rob@77 4792
rob@77 4793 ATTR: function( elem, match ) {
rob@77 4794 var name = match[1],
rob@77 4795 result = Sizzle.attr ?
rob@77 4796 Sizzle.attr( elem, name ) :
rob@77 4797 Expr.attrHandle[ name ] ?
rob@77 4798 Expr.attrHandle[ name ]( elem ) :
rob@77 4799 elem[ name ] != null ?
rob@77 4800 elem[ name ] :
rob@77 4801 elem.getAttribute( name ),
rob@77 4802 value = result + "",
rob@77 4803 type = match[2],
rob@77 4804 check = match[4];
rob@77 4805
rob@77 4806 return result == null ?
rob@77 4807 type === "!=" :
rob@77 4808 !type && Sizzle.attr ?
rob@77 4809 result != null :
rob@77 4810 type === "=" ?
rob@77 4811 value === check :
rob@77 4812 type === "*=" ?
rob@77 4813 value.indexOf(check) >= 0 :
rob@77 4814 type === "~=" ?
rob@77 4815 (" " + value + " ").indexOf(check) >= 0 :
rob@77 4816 !check ?
rob@77 4817 value && result !== false :
rob@77 4818 type === "!=" ?
rob@77 4819 value !== check :
rob@77 4820 type === "^=" ?
rob@77 4821 value.indexOf(check) === 0 :
rob@77 4822 type === "$=" ?
rob@77 4823 value.substr(value.length - check.length) === check :
rob@77 4824 type === "|=" ?
rob@77 4825 value === check || value.substr(0, check.length + 1) === check + "-" :
rob@77 4826 false;
rob@77 4827 },
rob@77 4828
rob@77 4829 POS: function( elem, match, i, array ) {
rob@77 4830 var name = match[2],
rob@77 4831 filter = Expr.setFilters[ name ];
rob@77 4832
rob@77 4833 if ( filter ) {
rob@77 4834 return filter( elem, i, match, array );
rob@77 4835 }
rob@77 4836 }
rob@77 4837 }
rob@77 4838 };
rob@77 4839
rob@77 4840 var origPOS = Expr.match.POS,
rob@77 4841 fescape = function(all, num){
rob@77 4842 return "\\" + (num - 0 + 1);
rob@77 4843 };
rob@77 4844
rob@77 4845 for ( var type in Expr.match ) {
rob@77 4846 Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) );
rob@77 4847 Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) );
rob@77 4848 }
rob@77 4849 // Expose origPOS
rob@77 4850 // "global" as in regardless of relation to brackets/parens
rob@77 4851 Expr.match.globalPOS = origPOS;
rob@77 4852
rob@77 4853 var makeArray = function( array, results ) {
rob@77 4854 array = Array.prototype.slice.call( array, 0 );
rob@77 4855
rob@77 4856 if ( results ) {
rob@77 4857 results.push.apply( results, array );
rob@77 4858 return results;
rob@77 4859 }
rob@77 4860
rob@77 4861 return array;
rob@77 4862 };
rob@77 4863
rob@77 4864 // Perform a simple check to determine if the browser is capable of
rob@77 4865 // converting a NodeList to an array using builtin methods.
rob@77 4866 // Also verifies that the returned array holds DOM nodes
rob@77 4867 // (which is not the case in the Blackberry browser)
rob@77 4868 try {
rob@77 4869 Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType;
rob@77 4870
rob@77 4871 // Provide a fallback method if it does not work
rob@77 4872 } catch( e ) {
rob@77 4873 makeArray = function( array, results ) {
rob@77 4874 var i = 0,
rob@77 4875 ret = results || [];
rob@77 4876
rob@77 4877 if ( toString.call(array) === "[object Array]" ) {
rob@77 4878 Array.prototype.push.apply( ret, array );
rob@77 4879
rob@77 4880 } else {
rob@77 4881 if ( typeof array.length === "number" ) {
rob@77 4882 for ( var l = array.length; i < l; i++ ) {
rob@77 4883 ret.push( array[i] );
rob@77 4884 }
rob@77 4885
rob@77 4886 } else {
rob@77 4887 for ( ; array[i]; i++ ) {
rob@77 4888 ret.push( array[i] );
rob@77 4889 }
rob@77 4890 }
rob@77 4891 }
rob@77 4892
rob@77 4893 return ret;
rob@77 4894 };
rob@77 4895 }
rob@77 4896
rob@77 4897 var sortOrder, siblingCheck;
rob@77 4898
rob@77 4899 if ( document.documentElement.compareDocumentPosition ) {
rob@77 4900 sortOrder = function( a, b ) {
rob@77 4901 if ( a === b ) {
rob@77 4902 hasDuplicate = true;
rob@77 4903 return 0;
rob@77 4904 }
rob@77 4905
rob@77 4906 if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
rob@77 4907 return a.compareDocumentPosition ? -1 : 1;
rob@77 4908 }
rob@77 4909
rob@77 4910 return a.compareDocumentPosition(b) & 4 ? -1 : 1;
rob@77 4911 };
rob@77 4912
rob@77 4913 } else {
rob@77 4914 sortOrder = function( a, b ) {
rob@77 4915 // The nodes are identical, we can exit early
rob@77 4916 if ( a === b ) {
rob@77 4917 hasDuplicate = true;
rob@77 4918 return 0;
rob@77 4919
rob@77 4920 // Fallback to using sourceIndex (in IE) if it's available on both nodes
rob@77 4921 } else if ( a.sourceIndex && b.sourceIndex ) {
rob@77 4922 return a.sourceIndex - b.sourceIndex;
rob@77 4923 }
rob@77 4924
rob@77 4925 var al, bl,
rob@77 4926 ap = [],
rob@77 4927 bp = [],
rob@77 4928 aup = a.parentNode,
rob@77 4929 bup = b.parentNode,
rob@77 4930 cur = aup;
rob@77 4931
rob@77 4932 // If the nodes are siblings (or identical) we can do a quick check
rob@77 4933 if ( aup === bup ) {
rob@77 4934 return siblingCheck( a, b );
rob@77 4935
rob@77 4936 // If no parents were found then the nodes are disconnected
rob@77 4937 } else if ( !aup ) {
rob@77 4938 return -1;
rob@77 4939
rob@77 4940 } else if ( !bup ) {
rob@77 4941 return 1;
rob@77 4942 }
rob@77 4943
rob@77 4944 // Otherwise they're somewhere else in the tree so we need
rob@77 4945 // to build up a full list of the parentNodes for comparison
rob@77 4946 while ( cur ) {
rob@77 4947 ap.unshift( cur );
rob@77 4948 cur = cur.parentNode;
rob@77 4949 }
rob@77 4950
rob@77 4951 cur = bup;
rob@77 4952
rob@77 4953 while ( cur ) {
rob@77 4954 bp.unshift( cur );
rob@77 4955 cur = cur.parentNode;
rob@77 4956 }
rob@77 4957
rob@77 4958 al = ap.length;
rob@77 4959 bl = bp.length;
rob@77 4960
rob@77 4961 // Start walking down the tree looking for a discrepancy
rob@77 4962 for ( var i = 0; i < al && i < bl; i++ ) {
rob@77 4963 if ( ap[i] !== bp[i] ) {
rob@77 4964 return siblingCheck( ap[i], bp[i] );
rob@77 4965 }
rob@77 4966 }
rob@77 4967
rob@77 4968 // We ended someplace up the tree so do a sibling check
rob@77 4969 return i === al ?
rob@77 4970 siblingCheck( a, bp[i], -1 ) :
rob@77 4971 siblingCheck( ap[i], b, 1 );
rob@77 4972 };
rob@77 4973
rob@77 4974 siblingCheck = function( a, b, ret ) {
rob@77 4975 if ( a === b ) {
rob@77 4976 return ret;
rob@77 4977 }
rob@77 4978
rob@77 4979 var cur = a.nextSibling;
rob@77 4980
rob@77 4981 while ( cur ) {
rob@77 4982 if ( cur === b ) {
rob@77 4983 return -1;
rob@77 4984 }
rob@77 4985
rob@77 4986 cur = cur.nextSibling;
rob@77 4987 }
rob@77 4988
rob@77 4989 return 1;
rob@77 4990 };
rob@77 4991 }
rob@77 4992
rob@77 4993 // Check to see if the browser returns elements by name when
rob@77 4994 // querying by getElementById (and provide a workaround)
rob@77 4995 (function(){
rob@77 4996 // We're going to inject a fake input element with a specified name
rob@77 4997 var form = document.createElement("div"),
rob@77 4998 id = "script" + (new Date()).getTime(),
rob@77 4999 root = document.documentElement;
rob@77 5000
rob@77 5001 form.innerHTML = "<a name='" + id + "'/>";
rob@77 5002
rob@77 5003 // Inject it into the root element, check its status, and remove it quickly
rob@77 5004 root.insertBefore( form, root.firstChild );
rob@77 5005
rob@77 5006 // The workaround has to do additional checks after a getElementById
rob@77 5007 // Which slows things down for other browsers (hence the branching)
rob@77 5008 if ( document.getElementById( id ) ) {
rob@77 5009 Expr.find.ID = function( match, context, isXML ) {
rob@77 5010 if ( typeof context.getElementById !== "undefined" && !isXML ) {
rob@77 5011 var m = context.getElementById(match[1]);
rob@77 5012
rob@77 5013 return m ?
rob@77 5014 m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ?
rob@77 5015 [m] :
rob@77 5016 undefined :
rob@77 5017 [];
rob@77 5018 }
rob@77 5019 };
rob@77 5020
rob@77 5021 Expr.filter.ID = function( elem, match ) {
rob@77 5022 var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
rob@77 5023
rob@77 5024 return elem.nodeType === 1 && node && node.nodeValue === match;
rob@77 5025 };
rob@77 5026 }
rob@77 5027
rob@77 5028 root.removeChild( form );
rob@77 5029
rob@77 5030 // release memory in IE
rob@77 5031 root = form = null;
rob@77 5032 })();
rob@77 5033
rob@77 5034 (function(){
rob@77 5035 // Check to see if the browser returns only elements
rob@77 5036 // when doing getElementsByTagName("*")
rob@77 5037
rob@77 5038 // Create a fake element
rob@77 5039 var div = document.createElement("div");
rob@77 5040 div.appendChild( document.createComment("") );
rob@77 5041
rob@77 5042 // Make sure no comments are found
rob@77 5043 if ( div.getElementsByTagName("*").length > 0 ) {
rob@77 5044 Expr.find.TAG = function( match, context ) {
rob@77 5045 var results = context.getElementsByTagName( match[1] );
rob@77 5046
rob@77 5047 // Filter out possible comments
rob@77 5048 if ( match[1] === "*" ) {
rob@77 5049 var tmp = [];
rob@77 5050
rob@77 5051 for ( var i = 0; results[i]; i++ ) {
rob@77 5052 if ( results[i].nodeType === 1 ) {
rob@77 5053 tmp.push( results[i] );
rob@77 5054 }
rob@77 5055 }
rob@77 5056
rob@77 5057 results = tmp;
rob@77 5058 }
rob@77 5059
rob@77 5060 return results;
rob@77 5061 };
rob@77 5062 }
rob@77 5063
rob@77 5064 // Check to see if an attribute returns normalized href attributes
rob@77 5065 div.innerHTML = "<a href='#'></a>";
rob@77 5066
rob@77 5067 if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
rob@77 5068 div.firstChild.getAttribute("href") !== "#" ) {
rob@77 5069
rob@77 5070 Expr.attrHandle.href = function( elem ) {
rob@77 5071 return elem.getAttribute( "href", 2 );
rob@77 5072 };
rob@77 5073 }
rob@77 5074
rob@77 5075 // release memory in IE
rob@77 5076 div = null;
rob@77 5077 })();
rob@77 5078
rob@77 5079 if ( document.querySelectorAll ) {
rob@77 5080 (function(){
rob@77 5081 var oldSizzle = Sizzle,
rob@77 5082 div = document.createElement("div"),
rob@77 5083 id = "__sizzle__";
rob@77 5084
rob@77 5085 div.innerHTML = "<p class='TEST'></p>";
rob@77 5086
rob@77 5087 // Safari can't handle uppercase or unicode characters when
rob@77 5088 // in quirks mode.
rob@77 5089 if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
rob@77 5090 return;
rob@77 5091 }
rob@77 5092
rob@77 5093 Sizzle = function( query, context, extra, seed ) {
rob@77 5094 context = context || document;
rob@77 5095
rob@77 5096 // Only use querySelectorAll on non-XML documents
rob@77 5097 // (ID selectors don't work in non-HTML documents)
rob@77 5098 if ( !seed && !Sizzle.isXML(context) ) {
rob@77 5099 // See if we find a selector to speed up
rob@77 5100 var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query );
rob@77 5101
rob@77 5102 if ( match && (context.nodeType === 1 || context.nodeType === 9) ) {
rob@77 5103 // Speed-up: Sizzle("TAG")
rob@77 5104 if ( match[1] ) {
rob@77 5105 return makeArray( context.getElementsByTagName( query ), extra );
rob@77 5106
rob@77 5107 // Speed-up: Sizzle(".CLASS")
rob@77 5108 } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) {
rob@77 5109 return makeArray( context.getElementsByClassName( match[2] ), extra );
rob@77 5110 }
rob@77 5111 }
rob@77 5112
rob@77 5113 if ( context.nodeType === 9 ) {
rob@77 5114 // Speed-up: Sizzle("body")
rob@77 5115 // The body element only exists once, optimize finding it
rob@77 5116 if ( query === "body" && context.body ) {
rob@77 5117 return makeArray( [ context.body ], extra );
rob@77 5118
rob@77 5119 // Speed-up: Sizzle("#ID")
rob@77 5120 } else if ( match && match[3] ) {
rob@77 5121 var elem = context.getElementById( match[3] );
rob@77 5122
rob@77 5123 // Check parentNode to catch when Blackberry 4.6 returns
rob@77 5124 // nodes that are no longer in the document #6963
rob@77 5125 if ( elem && elem.parentNode ) {
rob@77 5126 // Handle the case where IE and Opera return items
rob@77 5127 // by name instead of ID
rob@77 5128 if ( elem.id === match[3] ) {
rob@77 5129 return makeArray( [ elem ], extra );
rob@77 5130 }
rob@77 5131
rob@77 5132 } else {
rob@77 5133 return makeArray( [], extra );
rob@77 5134 }
rob@77 5135 }
rob@77 5136
rob@77 5137 try {
rob@77 5138 return makeArray( context.querySelectorAll(query), extra );
rob@77 5139 } catch(qsaError) {}
rob@77 5140
rob@77 5141 // qSA works strangely on Element-rooted queries
rob@77 5142 // We can work around this by specifying an extra ID on the root
rob@77 5143 // and working up from there (Thanks to Andrew Dupont for the technique)
rob@77 5144 // IE 8 doesn't work on object elements
rob@77 5145 } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
rob@77 5146 var oldContext = context,
rob@77 5147 old = context.getAttribute( "id" ),
rob@77 5148 nid = old || id,
rob@77 5149 hasParent = context.parentNode,
rob@77 5150 relativeHierarchySelector = /^\s*[+~]/.test( query );
rob@77 5151
rob@77 5152 if ( !old ) {
rob@77 5153 context.setAttribute( "id", nid );
rob@77 5154 } else {
rob@77 5155 nid = nid.replace( /'/g, "\\$&" );
rob@77 5156 }
rob@77 5157 if ( relativeHierarchySelector && hasParent ) {
rob@77 5158 context = context.parentNode;
rob@77 5159 }
rob@77 5160
rob@77 5161 try {
rob@77 5162 if ( !relativeHierarchySelector || hasParent ) {
rob@77 5163 return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra );
rob@77 5164 }
rob@77 5165
rob@77 5166 } catch(pseudoError) {
rob@77 5167 } finally {
rob@77 5168 if ( !old ) {
rob@77 5169 oldContext.removeAttribute( "id" );
rob@77 5170 }
rob@77 5171 }
rob@77 5172 }
rob@77 5173 }
rob@77 5174
rob@77 5175 return oldSizzle(query, context, extra, seed);
rob@77 5176 };
rob@77 5177
rob@77 5178 for ( var prop in oldSizzle ) {
rob@77 5179 Sizzle[ prop ] = oldSizzle[ prop ];
rob@77 5180 }
rob@77 5181
rob@77 5182 // release memory in IE
rob@77 5183 div = null;
rob@77 5184 })();
rob@77 5185 }
rob@77 5186
rob@77 5187 (function(){
rob@77 5188 var html = document.documentElement,
rob@77 5189 matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector;
rob@77 5190
rob@77 5191 if ( matches ) {
rob@77 5192 // Check to see if it's possible to do matchesSelector
rob@77 5193 // on a disconnected node (IE 9 fails this)
rob@77 5194 var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ),
rob@77 5195 pseudoWorks = false;
rob@77 5196
rob@77 5197 try {
rob@77 5198 // This should fail with an exception
rob@77 5199 // Gecko does not error, returns false instead
rob@77 5200 matches.call( document.documentElement, "[test!='']:sizzle" );
rob@77 5201
rob@77 5202 } catch( pseudoError ) {
rob@77 5203 pseudoWorks = true;
rob@77 5204 }
rob@77 5205
rob@77 5206 Sizzle.matchesSelector = function( node, expr ) {
rob@77 5207 // Make sure that attribute selectors are quoted
rob@77 5208 expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
rob@77 5209
rob@77 5210 if ( !Sizzle.isXML( node ) ) {
rob@77 5211 try {
rob@77 5212 if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) {
rob@77 5213 var ret = matches.call( node, expr );
rob@77 5214
rob@77 5215 // IE 9's matchesSelector returns false on disconnected nodes
rob@77 5216 if ( ret || !disconnectedMatch ||
rob@77 5217 // As well, disconnected nodes are said to be in a document
rob@77 5218 // fragment in IE 9, so check for that
rob@77 5219 node.document && node.document.nodeType !== 11 ) {
rob@77 5220 return ret;
rob@77 5221 }
rob@77 5222 }
rob@77 5223 } catch(e) {}
rob@77 5224 }
rob@77 5225
rob@77 5226 return Sizzle(expr, null, null, [node]).length > 0;
rob@77 5227 };
rob@77 5228 }
rob@77 5229 })();
rob@77 5230
rob@77 5231 (function(){
rob@77 5232 var div = document.createElement("div");
rob@77 5233
rob@77 5234 div.innerHTML = "<div class='test e'></div><div class='test'></div>";
rob@77 5235
rob@77 5236 // Opera can't find a second classname (in 9.6)
rob@77 5237 // Also, make sure that getElementsByClassName actually exists
rob@77 5238 if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
rob@77 5239 return;
rob@77 5240 }
rob@77 5241
rob@77 5242 // Safari caches class attributes, doesn't catch changes (in 3.2)
rob@77 5243 div.lastChild.className = "e";
rob@77 5244
rob@77 5245 if ( div.getElementsByClassName("e").length === 1 ) {
rob@77 5246 return;
rob@77 5247 }
rob@77 5248
rob@77 5249 Expr.order.splice(1, 0, "CLASS");
rob@77 5250 Expr.find.CLASS = function( match, context, isXML ) {
rob@77 5251 if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
rob@77 5252 return context.getElementsByClassName(match[1]);
rob@77 5253 }
rob@77 5254 };
rob@77 5255
rob@77 5256 // release memory in IE
rob@77 5257 div = null;
rob@77 5258 })();
rob@77 5259
rob@77 5260 function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
rob@77 5261 for ( var i = 0, l = checkSet.length; i < l; i++ ) {
rob@77 5262 var elem = checkSet[i];
rob@77 5263
rob@77 5264 if ( elem ) {
rob@77 5265 var match = false;
rob@77 5266
rob@77 5267 elem = elem[dir];
rob@77 5268
rob@77 5269 while ( elem ) {
rob@77 5270 if ( elem[ expando ] === doneName ) {
rob@77 5271 match = checkSet[elem.sizset];
rob@77 5272 break;
rob@77 5273 }
rob@77 5274
rob@77 5275 if ( elem.nodeType === 1 && !isXML ){
rob@77 5276 elem[ expando ] = doneName;
rob@77 5277 elem.sizset = i;
rob@77 5278 }
rob@77 5279
rob@77 5280 if ( elem.nodeName.toLowerCase() === cur ) {
rob@77 5281 match = elem;
rob@77 5282 break;
rob@77 5283 }
rob@77 5284
rob@77 5285 elem = elem[dir];
rob@77 5286 }
rob@77 5287
rob@77 5288 checkSet[i] = match;
rob@77 5289 }
rob@77 5290 }
rob@77 5291 }
rob@77 5292
rob@77 5293 function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
rob@77 5294 for ( var i = 0, l = checkSet.length; i < l; i++ ) {
rob@77 5295 var elem = checkSet[i];
rob@77 5296
rob@77 5297 if ( elem ) {
rob@77 5298 var match = false;
rob@77 5299
rob@77 5300 elem = elem[dir];
rob@77 5301
rob@77 5302 while ( elem ) {
rob@77 5303 if ( elem[ expando ] === doneName ) {
rob@77 5304 match = checkSet[elem.sizset];
rob@77 5305 break;
rob@77 5306 }
rob@77 5307
rob@77 5308 if ( elem.nodeType === 1 ) {
rob@77 5309 if ( !isXML ) {
rob@77 5310 elem[ expando ] = doneName;
rob@77 5311 elem.sizset = i;
rob@77 5312 }
rob@77 5313
rob@77 5314 if ( typeof cur !== "string" ) {
rob@77 5315 if ( elem === cur ) {
rob@77 5316 match = true;
rob@77 5317 break;
rob@77 5318 }
rob@77 5319
rob@77 5320 } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
rob@77 5321 match = elem;
rob@77 5322 break;
rob@77 5323 }
rob@77 5324 }
rob@77 5325
rob@77 5326 elem = elem[dir];
rob@77 5327 }
rob@77 5328
rob@77 5329 checkSet[i] = match;
rob@77 5330 }
rob@77 5331 }
rob@77 5332 }
rob@77 5333
rob@77 5334 if ( document.documentElement.contains ) {
rob@77 5335 Sizzle.contains = function( a, b ) {
rob@77 5336 return a !== b && (a.contains ? a.contains(b) : true);
rob@77 5337 };
rob@77 5338
rob@77 5339 } else if ( document.documentElement.compareDocumentPosition ) {
rob@77 5340 Sizzle.contains = function( a, b ) {
rob@77 5341 return !!(a.compareDocumentPosition(b) & 16);
rob@77 5342 };
rob@77 5343
rob@77 5344 } else {
rob@77 5345 Sizzle.contains = function() {
rob@77 5346 return false;
rob@77 5347 };
rob@77 5348 }
rob@77 5349
rob@77 5350 Sizzle.isXML = function( elem ) {
rob@77 5351 // documentElement is verified for cases where it doesn't yet exist
rob@77 5352 // (such as loading iframes in IE - #4833)
rob@77 5353 var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
rob@77 5354
rob@77 5355 return documentElement ? documentElement.nodeName !== "HTML" : false;
rob@77 5356 };
rob@77 5357
rob@77 5358 var posProcess = function( selector, context, seed ) {
rob@77 5359 var match,
rob@77 5360 tmpSet = [],
rob@77 5361 later = "",
rob@77 5362 root = context.nodeType ? [context] : context;
rob@77 5363
rob@77 5364 // Position selectors must be done after the filter
rob@77 5365 // And so must :not(positional) so we move all PSEUDOs to the end
rob@77 5366 while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
rob@77 5367 later += match[0];
rob@77 5368 selector = selector.replace( Expr.match.PSEUDO, "" );
rob@77 5369 }
rob@77 5370
rob@77 5371 selector = Expr.relative[selector] ? selector + "*" : selector;
rob@77 5372
rob@77 5373 for ( var i = 0, l = root.length; i < l; i++ ) {
rob@77 5374 Sizzle( selector, root[i], tmpSet, seed );
rob@77 5375 }
rob@77 5376
rob@77 5377 return Sizzle.filter( later, tmpSet );
rob@77 5378 };
rob@77 5379
rob@77 5380 // EXPOSE
rob@77 5381 // Override sizzle attribute retrieval
rob@77 5382 Sizzle.attr = jQuery.attr;
rob@77 5383 Sizzle.selectors.attrMap = {};
rob@77 5384 jQuery.find = Sizzle;
rob@77 5385 jQuery.expr = Sizzle.selectors;
rob@77 5386 jQuery.expr[":"] = jQuery.expr.filters;
rob@77 5387 jQuery.unique = Sizzle.uniqueSort;
rob@77 5388 jQuery.text = Sizzle.getText;
rob@77 5389 jQuery.isXMLDoc = Sizzle.isXML;
rob@77 5390 jQuery.contains = Sizzle.contains;
rob@77 5391
rob@77 5392
rob@77 5393 })();
rob@77 5394
rob@77 5395
rob@77 5396 var runtil = /Until$/,
rob@77 5397 rparentsprev = /^(?:parents|prevUntil|prevAll)/,
rob@77 5398 // Note: This RegExp should be improved, or likely pulled from Sizzle
rob@77 5399 rmultiselector = /,/,
rob@77 5400 isSimple = /^.[^:#\[\.,]*$/,
rob@77 5401 slice = Array.prototype.slice,
rob@77 5402 POS = jQuery.expr.match.globalPOS,
rob@77 5403 // methods guaranteed to produce a unique set when starting from a unique set
rob@77 5404 guaranteedUnique = {
rob@77 5405 children: true,
rob@77 5406 contents: true,
rob@77 5407 next: true,
rob@77 5408 prev: true
rob@77 5409 };
rob@77 5410
rob@77 5411 jQuery.fn.extend({
rob@77 5412 find: function( selector ) {
rob@77 5413 var self = this,
rob@77 5414 i, l;
rob@77 5415
rob@77 5416 if ( typeof selector !== "string" ) {
rob@77 5417 return jQuery( selector ).filter(function() {
rob@77 5418 for ( i = 0, l = self.length; i < l; i++ ) {
rob@77 5419 if ( jQuery.contains( self[ i ], this ) ) {
rob@77 5420 return true;
rob@77 5421 }
rob@77 5422 }
rob@77 5423 });
rob@77 5424 }
rob@77 5425
rob@77 5426 var ret = this.pushStack( "", "find", selector ),
rob@77 5427 length, n, r;
rob@77 5428
rob@77 5429 for ( i = 0, l = this.length; i < l; i++ ) {
rob@77 5430 length = ret.length;
rob@77 5431 jQuery.find( selector, this[i], ret );
rob@77 5432
rob@77 5433 if ( i > 0 ) {
rob@77 5434 // Make sure that the results are unique
rob@77 5435 for ( n = length; n < ret.length; n++ ) {
rob@77 5436 for ( r = 0; r < length; r++ ) {
rob@77 5437 if ( ret[r] === ret[n] ) {
rob@77 5438 ret.splice(n--, 1);
rob@77 5439 break;
rob@77 5440 }
rob@77 5441 }
rob@77 5442 }
rob@77 5443 }
rob@77 5444 }
rob@77 5445
rob@77 5446 return ret;
rob@77 5447 },
rob@77 5448
rob@77 5449 has: function( target ) {
rob@77 5450 var targets = jQuery( target );
rob@77 5451 return this.filter(function() {
rob@77 5452 for ( var i = 0, l = targets.length; i < l; i++ ) {
rob@77 5453 if ( jQuery.contains( this, targets[i] ) ) {
rob@77 5454 return true;
rob@77 5455 }
rob@77 5456 }
rob@77 5457 });
rob@77 5458 },
rob@77 5459
rob@77 5460 not: function( selector ) {
rob@77 5461 return this.pushStack( winnow(this, selector, false), "not", selector);
rob@77 5462 },
rob@77 5463
rob@77 5464 filter: function( selector ) {
rob@77 5465 return this.pushStack( winnow(this, selector, true), "filter", selector );
rob@77 5466 },
rob@77 5467
rob@77 5468 is: function( selector ) {
rob@77 5469 return !!selector && (
rob@77 5470 typeof selector === "string" ?
rob@77 5471 // If this is a positional selector, check membership in the returned set
rob@77 5472 // so $("p:first").is("p:last") won't return true for a doc with two "p".
rob@77 5473 POS.test( selector ) ?
rob@77 5474 jQuery( selector, this.context ).index( this[0] ) >= 0 :
rob@77 5475 jQuery.filter( selector, this ).length > 0 :
rob@77 5476 this.filter( selector ).length > 0 );
rob@77 5477 },
rob@77 5478
rob@77 5479 closest: function( selectors, context ) {
rob@77 5480 var ret = [], i, l, cur = this[0];
rob@77 5481
rob@77 5482 // Array (deprecated as of jQuery 1.7)
rob@77 5483 if ( jQuery.isArray( selectors ) ) {
rob@77 5484 var level = 1;
rob@77 5485
rob@77 5486 while ( cur && cur.ownerDocument && cur !== context ) {
rob@77 5487 for ( i = 0; i < selectors.length; i++ ) {
rob@77 5488
rob@77 5489 if ( jQuery( cur ).is( selectors[ i ] ) ) {
rob@77 5490 ret.push({ selector: selectors[ i ], elem: cur, level: level });
rob@77 5491 }
rob@77 5492 }
rob@77 5493
rob@77 5494 cur = cur.parentNode;
rob@77 5495 level++;
rob@77 5496 }
rob@77 5497
rob@77 5498 return ret;
rob@77 5499 }
rob@77 5500
rob@77 5501 // String
rob@77 5502 var pos = POS.test( selectors ) || typeof selectors !== "string" ?
rob@77 5503 jQuery( selectors, context || this.context ) :
rob@77 5504 0;
rob@77 5505
rob@77 5506 for ( i = 0, l = this.length; i < l; i++ ) {
rob@77 5507 cur = this[i];
rob@77 5508
rob@77 5509 while ( cur ) {
rob@77 5510 if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
rob@77 5511 ret.push( cur );
rob@77 5512 break;
rob@77 5513
rob@77 5514 } else {
rob@77 5515 cur = cur.parentNode;
rob@77 5516 if ( !cur || !cur.ownerDocument || cur === context || cur.nodeType === 11 ) {
rob@77 5517 break;
rob@77 5518 }
rob@77 5519 }
rob@77 5520 }
rob@77 5521 }
rob@77 5522
rob@77 5523 ret = ret.length > 1 ? jQuery.unique( ret ) : ret;
rob@77 5524
rob@77 5525 return this.pushStack( ret, "closest", selectors );
rob@77 5526 },
rob@77 5527
rob@77 5528 // Determine the position of an element within
rob@77 5529 // the matched set of elements
rob@77 5530 index: function( elem ) {
rob@77 5531
rob@77 5532 // No argument, return index in parent
rob@77 5533 if ( !elem ) {
rob@77 5534 return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1;
rob@77 5535 }
rob@77 5536
rob@77 5537 // index in selector
rob@77 5538 if ( typeof elem === "string" ) {
rob@77 5539 return jQuery.inArray( this[0], jQuery( elem ) );
rob@77 5540 }
rob@77 5541
rob@77 5542 // Locate the position of the desired element
rob@77 5543 return jQuery.inArray(
rob@77 5544 // If it receives a jQuery object, the first element is used
rob@77 5545 elem.jquery ? elem[0] : elem, this );
rob@77 5546 },
rob@77 5547
rob@77 5548 add: function( selector, context ) {
rob@77 5549 var set = typeof selector === "string" ?
rob@77 5550 jQuery( selector, context ) :
rob@77 5551 jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
rob@77 5552 all = jQuery.merge( this.get(), set );
rob@77 5553
rob@77 5554 return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
rob@77 5555 all :
rob@77 5556 jQuery.unique( all ) );
rob@77 5557 },
rob@77 5558
rob@77 5559 andSelf: function() {
rob@77 5560 return this.add( this.prevObject );
rob@77 5561 }
rob@77 5562 });
rob@77 5563
rob@77 5564 // A painfully simple check to see if an element is disconnected
rob@77 5565 // from a document (should be improved, where feasible).
rob@77 5566 function isDisconnected( node ) {
rob@77 5567 return !node || !node.parentNode || node.parentNode.nodeType === 11;
rob@77 5568 }
rob@77 5569
rob@77 5570 jQuery.each({
rob@77 5571 parent: function( elem ) {
rob@77 5572 var parent = elem.parentNode;
rob@77 5573 return parent && parent.nodeType !== 11 ? parent : null;
rob@77 5574 },
rob@77 5575 parents: function( elem ) {
rob@77 5576 return jQuery.dir( elem, "parentNode" );
rob@77 5577 },
rob@77 5578 parentsUntil: function( elem, i, until ) {
rob@77 5579 return jQuery.dir( elem, "parentNode", until );
rob@77 5580 },
rob@77 5581 next: function( elem ) {
rob@77 5582 return jQuery.nth( elem, 2, "nextSibling" );
rob@77 5583 },
rob@77 5584 prev: function( elem ) {
rob@77 5585 return jQuery.nth( elem, 2, "previousSibling" );
rob@77 5586 },
rob@77 5587 nextAll: function( elem ) {
rob@77 5588 return jQuery.dir( elem, "nextSibling" );
rob@77 5589 },
rob@77 5590 prevAll: function( elem ) {
rob@77 5591 return jQuery.dir( elem, "previousSibling" );
rob@77 5592 },
rob@77 5593 nextUntil: function( elem, i, until ) {
rob@77 5594 return jQuery.dir( elem, "nextSibling", until );
rob@77 5595 },
rob@77 5596 prevUntil: function( elem, i, until ) {
rob@77 5597 return jQuery.dir( elem, "previousSibling", until );
rob@77 5598 },
rob@77 5599 siblings: function( elem ) {
rob@77 5600 return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
rob@77 5601 },
rob@77 5602 children: function( elem ) {
rob@77 5603 return jQuery.sibling( elem.firstChild );
rob@77 5604 },
rob@77 5605 contents: function( elem ) {
rob@77 5606 return jQuery.nodeName( elem, "iframe" ) ?
rob@77 5607 elem.contentDocument || elem.contentWindow.document :
rob@77 5608 jQuery.makeArray( elem.childNodes );
rob@77 5609 }
rob@77 5610 }, function( name, fn ) {
rob@77 5611 jQuery.fn[ name ] = function( until, selector ) {
rob@77 5612 var ret = jQuery.map( this, fn, until );
rob@77 5613
rob@77 5614 if ( !runtil.test( name ) ) {
rob@77 5615 selector = until;
rob@77 5616 }
rob@77 5617
rob@77 5618 if ( selector && typeof selector === "string" ) {
rob@77 5619 ret = jQuery.filter( selector, ret );
rob@77 5620 }
rob@77 5621
rob@77 5622 ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret;
rob@77 5623
rob@77 5624 if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
rob@77 5625 ret = ret.reverse();
rob@77 5626 }
rob@77 5627
rob@77 5628 return this.pushStack( ret, name, slice.call( arguments ).join(",") );
rob@77 5629 };
rob@77 5630 });
rob@77 5631
rob@77 5632 jQuery.extend({
rob@77 5633 filter: function( expr, elems, not ) {
rob@77 5634 if ( not ) {
rob@77 5635 expr = ":not(" + expr + ")";
rob@77 5636 }
rob@77 5637
rob@77 5638 return elems.length === 1 ?
rob@77 5639 jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
rob@77 5640 jQuery.find.matches(expr, elems);
rob@77 5641 },
rob@77 5642
rob@77 5643 dir: function( elem, dir, until ) {
rob@77 5644 var matched = [],
rob@77 5645 cur = elem[ dir ];
rob@77 5646
rob@77 5647 while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
rob@77 5648 if ( cur.nodeType === 1 ) {
rob@77 5649 matched.push( cur );
rob@77 5650 }
rob@77 5651 cur = cur[dir];
rob@77 5652 }
rob@77 5653 return matched;
rob@77 5654 },
rob@77 5655
rob@77 5656 nth: function( cur, result, dir, elem ) {
rob@77 5657 result = result || 1;
rob@77 5658 var num = 0;
rob@77 5659
rob@77 5660 for ( ; cur; cur = cur[dir] ) {
rob@77 5661 if ( cur.nodeType === 1 && ++num === result ) {
rob@77 5662 break;
rob@77 5663 }
rob@77 5664 }
rob@77 5665
rob@77 5666 return cur;
rob@77 5667 },
rob@77 5668
rob@77 5669 sibling: function( n, elem ) {
rob@77 5670 var r = [];
rob@77 5671
rob@77 5672 for ( ; n; n = n.nextSibling ) {
rob@77 5673 if ( n.nodeType === 1 && n !== elem ) {
rob@77 5674 r.push( n );
rob@77 5675 }
rob@77 5676 }
rob@77 5677
rob@77 5678 return r;
rob@77 5679 }
rob@77 5680 });
rob@77 5681
rob@77 5682 // Implement the identical functionality for filter and not
rob@77 5683 function winnow( elements, qualifier, keep ) {
rob@77 5684
rob@77 5685 // Can't pass null or undefined to indexOf in Firefox 4
rob@77 5686 // Set to 0 to skip string check
rob@77 5687 qualifier = qualifier || 0;
rob@77 5688
rob@77 5689 if ( jQuery.isFunction( qualifier ) ) {
rob@77 5690 return jQuery.grep(elements, function( elem, i ) {
rob@77 5691 var retVal = !!qualifier.call( elem, i, elem );
rob@77 5692 return retVal === keep;
rob@77 5693 });
rob@77 5694
rob@77 5695 } else if ( qualifier.nodeType ) {
rob@77 5696 return jQuery.grep(elements, function( elem, i ) {
rob@77 5697 return ( elem === qualifier ) === keep;
rob@77 5698 });
rob@77 5699
rob@77 5700 } else if ( typeof qualifier === "string" ) {
rob@77 5701 var filtered = jQuery.grep(elements, function( elem ) {
rob@77 5702 return elem.nodeType === 1;
rob@77 5703 });
rob@77 5704
rob@77 5705 if ( isSimple.test( qualifier ) ) {
rob@77 5706 return jQuery.filter(qualifier, filtered, !keep);
rob@77 5707 } else {
rob@77 5708 qualifier = jQuery.filter( qualifier, filtered );
rob@77 5709 }
rob@77 5710 }
rob@77 5711
rob@77 5712 return jQuery.grep(elements, function( elem, i ) {
rob@77 5713 return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep;
rob@77 5714 });
rob@77 5715 }
rob@77 5716
rob@77 5717
rob@77 5718
rob@77 5719
rob@77 5720 function createSafeFragment( document ) {
rob@77 5721 var list = nodeNames.split( "|" ),
rob@77 5722 safeFrag = document.createDocumentFragment();
rob@77 5723
rob@77 5724 if ( safeFrag.createElement ) {
rob@77 5725 while ( list.length ) {
rob@77 5726 safeFrag.createElement(
rob@77 5727 list.pop()
rob@77 5728 );
rob@77 5729 }
rob@77 5730 }
rob@77 5731 return safeFrag;
rob@77 5732 }
rob@77 5733
rob@77 5734 var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" +
rob@77 5735 "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
rob@77 5736 rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
rob@77 5737 rleadingWhitespace = /^\s+/,
rob@77 5738 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
rob@77 5739 rtagName = /<([\w:]+)/,
rob@77 5740 rtbody = /<tbody/i,
rob@77 5741 rhtml = /<|&#?\w+;/,
rob@77 5742 rnoInnerhtml = /<(?:script|style)/i,
rob@77 5743 rnocache = /<(?:script|object|embed|option|style)/i,
rob@77 5744 rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),
rob@77 5745 // checked="checked" or checked
rob@77 5746 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
rob@77 5747 rscriptType = /\/(java|ecma)script/i,
rob@77 5748 rcleanScript = /^\s*<!(?:\[CDATA\[|\-\-)/,
rob@77 5749 wrapMap = {
rob@77 5750 option: [ 1, "<select multiple='multiple'>", "</select>" ],
rob@77 5751 legend: [ 1, "<fieldset>", "</fieldset>" ],
rob@77 5752 thead: [ 1, "<table>", "</table>" ],
rob@77 5753 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
rob@77 5754 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
rob@77 5755 col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
rob@77 5756 area: [ 1, "<map>", "</map>" ],
rob@77 5757 _default: [ 0, "", "" ]
rob@77 5758 },
rob@77 5759 safeFragment = createSafeFragment( document );
rob@77 5760
rob@77 5761 wrapMap.optgroup = wrapMap.option;
rob@77 5762 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
rob@77 5763 wrapMap.th = wrapMap.td;
rob@77 5764
rob@77 5765 // IE can't serialize <link> and <script> tags normally
rob@77 5766 if ( !jQuery.support.htmlSerialize ) {
rob@77 5767 wrapMap._default = [ 1, "div<div>", "</div>" ];
rob@77 5768 }
rob@77 5769
rob@77 5770 jQuery.fn.extend({
rob@77 5771 text: function( value ) {
rob@77 5772 return jQuery.access( this, function( value ) {
rob@77 5773 return value === undefined ?
rob@77 5774 jQuery.text( this ) :
rob@77 5775 this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) );
rob@77 5776 }, null, value, arguments.length );
rob@77 5777 },
rob@77 5778
rob@77 5779 wrapAll: function( html ) {
rob@77 5780 if ( jQuery.isFunction( html ) ) {
rob@77 5781 return this.each(function(i) {
rob@77 5782 jQuery(this).wrapAll( html.call(this, i) );
rob@77 5783 });
rob@77 5784 }
rob@77 5785
rob@77 5786 if ( this[0] ) {
rob@77 5787 // The elements to wrap the target around
rob@77 5788 var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
rob@77 5789
rob@77 5790 if ( this[0].parentNode ) {
rob@77 5791 wrap.insertBefore( this[0] );
rob@77 5792 }
rob@77 5793
rob@77 5794 wrap.map(function() {
rob@77 5795 var elem = this;
rob@77 5796
rob@77 5797 while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
rob@77 5798 elem = elem.firstChild;
rob@77 5799 }
rob@77 5800
rob@77 5801 return elem;
rob@77 5802 }).append( this );
rob@77 5803 }
rob@77 5804
rob@77 5805 return this;
rob@77 5806 },
rob@77 5807
rob@77 5808 wrapInner: function( html ) {
rob@77 5809 if ( jQuery.isFunction( html ) ) {
rob@77 5810 return this.each(function(i) {
rob@77 5811 jQuery(this).wrapInner( html.call(this, i) );
rob@77 5812 });
rob@77 5813 }
rob@77 5814
rob@77 5815 return this.each(function() {
rob@77 5816 var self = jQuery( this ),
rob@77 5817 contents = self.contents();
rob@77 5818
rob@77 5819 if ( contents.length ) {
rob@77 5820 contents.wrapAll( html );
rob@77 5821
rob@77 5822 } else {
rob@77 5823 self.append( html );
rob@77 5824 }
rob@77 5825 });
rob@77 5826 },
rob@77 5827
rob@77 5828 wrap: function( html ) {
rob@77 5829 var isFunction = jQuery.isFunction( html );
rob@77 5830
rob@77 5831 return this.each(function(i) {
rob@77 5832 jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
rob@77 5833 });
rob@77 5834 },
rob@77 5835
rob@77 5836 unwrap: function() {
rob@77 5837 return this.parent().each(function() {
rob@77 5838 if ( !jQuery.nodeName( this, "body" ) ) {
rob@77 5839 jQuery( this ).replaceWith( this.childNodes );
rob@77 5840 }
rob@77 5841 }).end();
rob@77 5842 },
rob@77 5843
rob@77 5844 append: function() {
rob@77 5845 return this.domManip(arguments, true, function( elem ) {
rob@77 5846 if ( this.nodeType === 1 ) {
rob@77 5847 this.appendChild( elem );
rob@77 5848 }
rob@77 5849 });
rob@77 5850 },
rob@77 5851
rob@77 5852 prepend: function() {
rob@77 5853 return this.domManip(arguments, true, function( elem ) {
rob@77 5854 if ( this.nodeType === 1 ) {
rob@77 5855 this.insertBefore( elem, this.firstChild );
rob@77 5856 }
rob@77 5857 });
rob@77 5858 },
rob@77 5859
rob@77 5860 before: function() {
rob@77 5861 if ( this[0] && this[0].parentNode ) {
rob@77 5862 return this.domManip(arguments, false, function( elem ) {
rob@77 5863 this.parentNode.insertBefore( elem, this );
rob@77 5864 });
rob@77 5865 } else if ( arguments.length ) {
rob@77 5866 var set = jQuery.clean( arguments );
rob@77 5867 set.push.apply( set, this.toArray() );
rob@77 5868 return this.pushStack( set, "before", arguments );
rob@77 5869 }
rob@77 5870 },
rob@77 5871
rob@77 5872 after: function() {
rob@77 5873 if ( this[0] && this[0].parentNode ) {
rob@77 5874 return this.domManip(arguments, false, function( elem ) {
rob@77 5875 this.parentNode.insertBefore( elem, this.nextSibling );
rob@77 5876 });
rob@77 5877 } else if ( arguments.length ) {
rob@77 5878 var set = this.pushStack( this, "after", arguments );
rob@77 5879 set.push.apply( set, jQuery.clean(arguments) );
rob@77 5880 return set;
rob@77 5881 }
rob@77 5882 },
rob@77 5883
rob@77 5884 // keepData is for internal use only--do not document
rob@77 5885 remove: function( selector, keepData ) {
rob@77 5886 for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
rob@77 5887 if ( !selector || jQuery.filter( selector, [ elem ] ).length ) {
rob@77 5888 if ( !keepData && elem.nodeType === 1 ) {
rob@77 5889 jQuery.cleanData( elem.getElementsByTagName("*") );
rob@77 5890 jQuery.cleanData( [ elem ] );
rob@77 5891 }
rob@77 5892
rob@77 5893 if ( elem.parentNode ) {
rob@77 5894 elem.parentNode.removeChild( elem );
rob@77 5895 }
rob@77 5896 }
rob@77 5897 }
rob@77 5898
rob@77 5899 return this;
rob@77 5900 },
rob@77 5901
rob@77 5902 empty: function() {
rob@77 5903 for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
rob@77 5904 // Remove element nodes and prevent memory leaks
rob@77 5905 if ( elem.nodeType === 1 ) {
rob@77 5906 jQuery.cleanData( elem.getElementsByTagName("*") );
rob@77 5907 }
rob@77 5908
rob@77 5909 // Remove any remaining nodes
rob@77 5910 while ( elem.firstChild ) {
rob@77 5911 elem.removeChild( elem.firstChild );
rob@77 5912 }
rob@77 5913 }
rob@77 5914
rob@77 5915 return this;
rob@77 5916 },
rob@77 5917
rob@77 5918 clone: function( dataAndEvents, deepDataAndEvents ) {
rob@77 5919 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
rob@77 5920 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
rob@77 5921
rob@77 5922 return this.map( function () {
rob@77 5923 return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
rob@77 5924 });
rob@77 5925 },
rob@77 5926
rob@77 5927 html: function( value ) {
rob@77 5928 return jQuery.access( this, function( value ) {
rob@77 5929 var elem = this[0] || {},
rob@77 5930 i = 0,
rob@77 5931 l = this.length;
rob@77 5932
rob@77 5933 if ( value === undefined ) {
rob@77 5934 return elem.nodeType === 1 ?
rob@77 5935 elem.innerHTML.replace( rinlinejQuery, "" ) :
rob@77 5936 null;
rob@77 5937 }
rob@77 5938
rob@77 5939
rob@77 5940 if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
rob@77 5941 ( jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
rob@77 5942 !wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) {
rob@77 5943
rob@77 5944 value = value.replace( rxhtmlTag, "<$1></$2>" );
rob@77 5945
rob@77 5946 try {
rob@77 5947 for (; i < l; i++ ) {
rob@77 5948 // Remove element nodes and prevent memory leaks
rob@77 5949 elem = this[i] || {};
rob@77 5950 if ( elem.nodeType === 1 ) {
rob@77 5951 jQuery.cleanData( elem.getElementsByTagName( "*" ) );
rob@77 5952 elem.innerHTML = value;
rob@77 5953 }
rob@77 5954 }
rob@77 5955
rob@77 5956 elem = 0;
rob@77 5957
rob@77 5958 // If using innerHTML throws an exception, use the fallback method
rob@77 5959 } catch(e) {}
rob@77 5960 }
rob@77 5961
rob@77 5962 if ( elem ) {
rob@77 5963 this.empty().append( value );
rob@77 5964 }
rob@77 5965 }, null, value, arguments.length );
rob@77 5966 },
rob@77 5967
rob@77 5968 replaceWith: function( value ) {
rob@77 5969 if ( this[0] && this[0].parentNode ) {
rob@77 5970 // Make sure that the elements are removed from the DOM before they are inserted
rob@77 5971 // this can help fix replacing a parent with child elements
rob@77 5972 if ( jQuery.isFunction( value ) ) {
rob@77 5973 return this.each(function(i) {
rob@77 5974 var self = jQuery(this), old = self.html();
rob@77 5975 self.replaceWith( value.call( this, i, old ) );
rob@77 5976 });
rob@77 5977 }
rob@77 5978
rob@77 5979 if ( typeof value !== "string" ) {
rob@77 5980 value = jQuery( value ).detach();
rob@77 5981 }
rob@77 5982
rob@77 5983 return this.each(function() {
rob@77 5984 var next = this.nextSibling,
rob@77 5985 parent = this.parentNode;
rob@77 5986
rob@77 5987 jQuery( this ).remove();
rob@77 5988
rob@77 5989 if ( next ) {
rob@77 5990 jQuery(next).before( value );
rob@77 5991 } else {
rob@77 5992 jQuery(parent).append( value );
rob@77 5993 }
rob@77 5994 });
rob@77 5995 } else {
rob@77 5996 return this.length ?
rob@77 5997 this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) :
rob@77 5998 this;
rob@77 5999 }
rob@77 6000 },
rob@77 6001
rob@77 6002 detach: function( selector ) {
rob@77 6003 return this.remove( selector, true );
rob@77 6004 },
rob@77 6005
rob@77 6006 domManip: function( args, table, callback ) {
rob@77 6007 var results, first, fragment, parent,
rob@77 6008 value = args[0],
rob@77 6009 scripts = [];
rob@77 6010
rob@77 6011 // We can't cloneNode fragments that contain checked, in WebKit
rob@77 6012 if ( !jQuery.support.checkClone && arguments.length === 3 && typeof value === "string" && rchecked.test( value ) ) {
rob@77 6013 return this.each(function() {
rob@77 6014 jQuery(this).domManip( args, table, callback, true );
rob@77 6015 });
rob@77 6016 }
rob@77 6017
rob@77 6018 if ( jQuery.isFunction(value) ) {
rob@77 6019 return this.each(function(i) {
rob@77 6020 var self = jQuery(this);
rob@77 6021 args[0] = value.call(this, i, table ? self.html() : undefined);
rob@77 6022 self.domManip( args, table, callback );
rob@77 6023 });
rob@77 6024 }
rob@77 6025
rob@77 6026 if ( this[0] ) {
rob@77 6027 parent = value && value.parentNode;
rob@77 6028
rob@77 6029 // If we're in a fragment, just use that instead of building a new one
rob@77 6030 if ( jQuery.support.parentNode && parent && parent.nodeType === 11 && parent.childNodes.length === this.length ) {
rob@77 6031 results = { fragment: parent };
rob@77 6032
rob@77 6033 } else {
rob@77 6034 results = jQuery.buildFragment( args, this, scripts );
rob@77 6035 }
rob@77 6036
rob@77 6037 fragment = results.fragment;
rob@77 6038
rob@77 6039 if ( fragment.childNodes.length === 1 ) {
rob@77 6040 first = fragment = fragment.firstChild;
rob@77 6041 } else {
rob@77 6042 first = fragment.firstChild;
rob@77 6043 }
rob@77 6044
rob@77 6045 if ( first ) {
rob@77 6046 table = table && jQuery.nodeName( first, "tr" );
rob@77 6047
rob@77 6048 for ( var i = 0, l = this.length, lastIndex = l - 1; i < l; i++ ) {
rob@77 6049 callback.call(
rob@77 6050 table ?
rob@77 6051 root(this[i], first) :
rob@77 6052 this[i],
rob@77 6053 // Make sure that we do not leak memory by inadvertently discarding
rob@77 6054 // the original fragment (which might have attached data) instead of
rob@77 6055 // using it; in addition, use the original fragment object for the last
rob@77 6056 // item instead of first because it can end up being emptied incorrectly
rob@77 6057 // in certain situations (Bug #8070).
rob@77 6058 // Fragments from the fragment cache must always be cloned and never used
rob@77 6059 // in place.
rob@77 6060 results.cacheable || ( l > 1 && i < lastIndex ) ?
rob@77 6061 jQuery.clone( fragment, true, true ) :
rob@77 6062 fragment
rob@77 6063 );
rob@77 6064 }
rob@77 6065 }
rob@77 6066
rob@77 6067 if ( scripts.length ) {
rob@77 6068 jQuery.each( scripts, function( i, elem ) {
rob@77 6069 if ( elem.src ) {
rob@77 6070 jQuery.ajax({
rob@77 6071 type: "GET",
rob@77 6072 global: false,
rob@77 6073 url: elem.src,
rob@77 6074 async: false,
rob@77 6075 dataType: "script"
rob@77 6076 });
rob@77 6077 } else {
rob@77 6078 jQuery.globalEval( ( elem.text || elem.textContent || elem.innerHTML || "" ).replace( rcleanScript, "/*$0*/" ) );
rob@77 6079 }
rob@77 6080
rob@77 6081 if ( elem.parentNode ) {
rob@77 6082 elem.parentNode.removeChild( elem );
rob@77 6083 }
rob@77 6084 });
rob@77 6085 }
rob@77 6086 }
rob@77 6087
rob@77 6088 return this;
rob@77 6089 }
rob@77 6090 });
rob@77 6091
rob@77 6092 function root( elem, cur ) {
rob@77 6093 return jQuery.nodeName(elem, "table") ?
rob@77 6094 (elem.getElementsByTagName("tbody")[0] ||
rob@77 6095 elem.appendChild(elem.ownerDocument.createElement("tbody"))) :
rob@77 6096 elem;
rob@77 6097 }
rob@77 6098
rob@77 6099 function cloneCopyEvent( src, dest ) {
rob@77 6100
rob@77 6101 if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
rob@77 6102 return;
rob@77 6103 }
rob@77 6104
rob@77 6105 var type, i, l,
rob@77 6106 oldData = jQuery._data( src ),
rob@77 6107 curData = jQuery._data( dest, oldData ),
rob@77 6108 events = oldData.events;
rob@77 6109
rob@77 6110 if ( events ) {
rob@77 6111 delete curData.handle;
rob@77 6112 curData.events = {};
rob@77 6113
rob@77 6114 for ( type in events ) {
rob@77 6115 for ( i = 0, l = events[ type ].length; i < l; i++ ) {
rob@77 6116 jQuery.event.add( dest, type, events[ type ][ i ] );
rob@77 6117 }
rob@77 6118 }
rob@77 6119 }
rob@77 6120
rob@77 6121 // make the cloned public data object a copy from the original
rob@77 6122 if ( curData.data ) {
rob@77 6123 curData.data = jQuery.extend( {}, curData.data );
rob@77 6124 }
rob@77 6125 }
rob@77 6126
rob@77 6127 function cloneFixAttributes( src, dest ) {
rob@77 6128 var nodeName;
rob@77 6129
rob@77 6130 // We do not need to do anything for non-Elements
rob@77 6131 if ( dest.nodeType !== 1 ) {
rob@77 6132 return;
rob@77 6133 }
rob@77 6134
rob@77 6135 // clearAttributes removes the attributes, which we don't want,
rob@77 6136 // but also removes the attachEvent events, which we *do* want
rob@77 6137 if ( dest.clearAttributes ) {
rob@77 6138 dest.clearAttributes();
rob@77 6139 }
rob@77 6140
rob@77 6141 // mergeAttributes, in contrast, only merges back on the
rob@77 6142 // original attributes, not the events
rob@77 6143 if ( dest.mergeAttributes ) {
rob@77 6144 dest.mergeAttributes( src );
rob@77 6145 }
rob@77 6146
rob@77 6147 nodeName = dest.nodeName.toLowerCase();
rob@77 6148
rob@77 6149 // IE6-8 fail to clone children inside object elements that use
rob@77 6150 // the proprietary classid attribute value (rather than the type
rob@77 6151 // attribute) to identify the type of content to display
rob@77 6152 if ( nodeName === "object" ) {
rob@77 6153 dest.outerHTML = src.outerHTML;
rob@77 6154
rob@77 6155 } else if ( nodeName === "input" && (src.type === "checkbox" || src.type === "radio") ) {
rob@77 6156 // IE6-8 fails to persist the checked state of a cloned checkbox
rob@77 6157 // or radio button. Worse, IE6-7 fail to give the cloned element
rob@77 6158 // a checked appearance if the defaultChecked value isn't also set
rob@77 6159 if ( src.checked ) {
rob@77 6160 dest.defaultChecked = dest.checked = src.checked;
rob@77 6161 }
rob@77 6162
rob@77 6163 // IE6-7 get confused and end up setting the value of a cloned
rob@77 6164 // checkbox/radio button to an empty string instead of "on"
rob@77 6165 if ( dest.value !== src.value ) {
rob@77 6166 dest.value = src.value;
rob@77 6167 }
rob@77 6168
rob@77 6169 // IE6-8 fails to return the selected option to the default selected
rob@77 6170 // state when cloning options
rob@77 6171 } else if ( nodeName === "option" ) {
rob@77 6172 dest.selected = src.defaultSelected;
rob@77 6173
rob@77 6174 // IE6-8 fails to set the defaultValue to the correct value when
rob@77 6175 // cloning other types of input fields
rob@77 6176 } else if ( nodeName === "input" || nodeName === "textarea" ) {
rob@77 6177 dest.defaultValue = src.defaultValue;
rob@77 6178
rob@77 6179 // IE blanks contents when cloning scripts
rob@77 6180 } else if ( nodeName === "script" && dest.text !== src.text ) {
rob@77 6181 dest.text = src.text;
rob@77 6182 }
rob@77 6183
rob@77 6184 // Event data gets referenced instead of copied if the expando
rob@77 6185 // gets copied too
rob@77 6186 dest.removeAttribute( jQuery.expando );
rob@77 6187
rob@77 6188 // Clear flags for bubbling special change/submit events, they must
rob@77 6189 // be reattached when the newly cloned events are first activated
rob@77 6190 dest.removeAttribute( "_submit_attached" );
rob@77 6191 dest.removeAttribute( "_change_attached" );
rob@77 6192 }
rob@77 6193
rob@77 6194 jQuery.buildFragment = function( args, nodes, scripts ) {
rob@77 6195 var fragment, cacheable, cacheresults, doc,
rob@77 6196 first = args[ 0 ];
rob@77 6197
rob@77 6198 // nodes may contain either an explicit document object,
rob@77 6199 // a jQuery collection or context object.
rob@77 6200 // If nodes[0] contains a valid object to assign to doc
rob@77 6201 if ( nodes && nodes[0] ) {
rob@77 6202 doc = nodes[0].ownerDocument || nodes[0];
rob@77 6203 }
rob@77 6204
rob@77 6205 // Ensure that an attr object doesn't incorrectly stand in as a document object
rob@77 6206 // Chrome and Firefox seem to allow this to occur and will throw exception
rob@77 6207 // Fixes #8950
rob@77 6208 if ( !doc.createDocumentFragment ) {
rob@77 6209 doc = document;
rob@77 6210 }
rob@77 6211
rob@77 6212 // Only cache "small" (1/2 KB) HTML strings that are associated with the main document
rob@77 6213 // Cloning options loses the selected state, so don't cache them
rob@77 6214 // IE 6 doesn't like it when you put <object> or <embed> elements in a fragment
rob@77 6215 // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache
rob@77 6216 // Lastly, IE6,7,8 will not correctly reuse cached fragments that were created from unknown elems #10501
rob@77 6217 if ( args.length === 1 && typeof first === "string" && first.length < 512 && doc === document &&
rob@77 6218 first.charAt(0) === "<" && !rnocache.test( first ) &&
rob@77 6219 (jQuery.support.checkClone || !rchecked.test( first )) &&
rob@77 6220 (jQuery.support.html5Clone || !rnoshimcache.test( first )) ) {
rob@77 6221
rob@77 6222 cacheable = true;
rob@77 6223
rob@77 6224 cacheresults = jQuery.fragments[ first ];
rob@77 6225 if ( cacheresults && cacheresults !== 1 ) {
rob@77 6226 fragment = cacheresults;
rob@77 6227 }
rob@77 6228 }
rob@77 6229
rob@77 6230 if ( !fragment ) {
rob@77 6231 fragment = doc.createDocumentFragment();
rob@77 6232 jQuery.clean( args, doc, fragment, scripts );
rob@77 6233 }
rob@77 6234
rob@77 6235 if ( cacheable ) {
rob@77 6236 jQuery.fragments[ first ] = cacheresults ? fragment : 1;
rob@77 6237 }
rob@77 6238
rob@77 6239 return { fragment: fragment, cacheable: cacheable };
rob@77 6240 };
rob@77 6241
rob@77 6242 jQuery.fragments = {};
rob@77 6243
rob@77 6244 jQuery.each({
rob@77 6245 appendTo: "append",
rob@77 6246 prependTo: "prepend",
rob@77 6247 insertBefore: "before",
rob@77 6248 insertAfter: "after",
rob@77 6249 replaceAll: "replaceWith"
rob@77 6250 }, function( name, original ) {
rob@77 6251 jQuery.fn[ name ] = function( selector ) {
rob@77 6252 var ret = [],
rob@77 6253 insert = jQuery( selector ),
rob@77 6254 parent = this.length === 1 && this[0].parentNode;
rob@77 6255
rob@77 6256 if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) {
rob@77 6257 insert[ original ]( this[0] );
rob@77 6258 return this;
rob@77 6259
rob@77 6260 } else {
rob@77 6261 for ( var i = 0, l = insert.length; i < l; i++ ) {
rob@77 6262 var elems = ( i > 0 ? this.clone(true) : this ).get();
rob@77 6263 jQuery( insert[i] )[ original ]( elems );
rob@77 6264 ret = ret.concat( elems );
rob@77 6265 }
rob@77 6266
rob@77 6267 return this.pushStack( ret, name, insert.selector );
rob@77 6268 }
rob@77 6269 };
rob@77 6270 });
rob@77 6271
rob@77 6272 function getAll( elem ) {
rob@77 6273 if ( typeof elem.getElementsByTagName !== "undefined" ) {
rob@77 6274 return elem.getElementsByTagName( "*" );
rob@77 6275
rob@77 6276 } else if ( typeof elem.querySelectorAll !== "undefined" ) {
rob@77 6277 return elem.querySelectorAll( "*" );
rob@77 6278
rob@77 6279 } else {
rob@77 6280 return [];
rob@77 6281 }
rob@77 6282 }
rob@77 6283
rob@77 6284 // Used in clean, fixes the defaultChecked property
rob@77 6285 function fixDefaultChecked( elem ) {
rob@77 6286 if ( elem.type === "checkbox" || elem.type === "radio" ) {
rob@77 6287 elem.defaultChecked = elem.checked;
rob@77 6288 }
rob@77 6289 }
rob@77 6290 // Finds all inputs and passes them to fixDefaultChecked
rob@77 6291 function findInputs( elem ) {
rob@77 6292 var nodeName = ( elem.nodeName || "" ).toLowerCase();
rob@77 6293 if ( nodeName === "input" ) {
rob@77 6294 fixDefaultChecked( elem );
rob@77 6295 // Skip scripts, get other children
rob@77 6296 } else if ( nodeName !== "script" && typeof elem.getElementsByTagName !== "undefined" ) {
rob@77 6297 jQuery.grep( elem.getElementsByTagName("input"), fixDefaultChecked );
rob@77 6298 }
rob@77 6299 }
rob@77 6300
rob@77 6301 // Derived From: http://www.iecss.com/shimprove/javascript/shimprove.1-0-1.js
rob@77 6302 function shimCloneNode( elem ) {
rob@77 6303 var div = document.createElement( "div" );
rob@77 6304 safeFragment.appendChild( div );
rob@77 6305
rob@77 6306 div.innerHTML = elem.outerHTML;
rob@77 6307 return div.firstChild;
rob@77 6308 }
rob@77 6309
rob@77 6310 jQuery.extend({
rob@77 6311 clone: function( elem, dataAndEvents, deepDataAndEvents ) {
rob@77 6312 var srcElements,
rob@77 6313 destElements,
rob@77 6314 i,
rob@77 6315 // IE<=8 does not properly clone detached, unknown element nodes
rob@77 6316 clone = jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ?
rob@77 6317 elem.cloneNode( true ) :
rob@77 6318 shimCloneNode( elem );
rob@77 6319
rob@77 6320 if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
rob@77 6321 (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
rob@77 6322 // IE copies events bound via attachEvent when using cloneNode.
rob@77 6323 // Calling detachEvent on the clone will also remove the events
rob@77 6324 // from the original. In order to get around this, we use some
rob@77 6325 // proprietary methods to clear the events. Thanks to MooTools
rob@77 6326 // guys for this hotness.
rob@77 6327
rob@77 6328 cloneFixAttributes( elem, clone );
rob@77 6329
rob@77 6330 // Using Sizzle here is crazy slow, so we use getElementsByTagName instead
rob@77 6331 srcElements = getAll( elem );
rob@77 6332 destElements = getAll( clone );
rob@77 6333
rob@77 6334 // Weird iteration because IE will replace the length property
rob@77 6335 // with an element if you are cloning the body and one of the
rob@77 6336 // elements on the page has a name or id of "length"
rob@77 6337 for ( i = 0; srcElements[i]; ++i ) {
rob@77 6338 // Ensure that the destination node is not null; Fixes #9587
rob@77 6339 if ( destElements[i] ) {
rob@77 6340 cloneFixAttributes( srcElements[i], destElements[i] );
rob@77 6341 }
rob@77 6342 }
rob@77 6343 }
rob@77 6344
rob@77 6345 // Copy the events from the original to the clone
rob@77 6346 if ( dataAndEvents ) {
rob@77 6347 cloneCopyEvent( elem, clone );
rob@77 6348
rob@77 6349 if ( deepDataAndEvents ) {
rob@77 6350 srcElements = getAll( elem );
rob@77 6351 destElements = getAll( clone );
rob@77 6352
rob@77 6353 for ( i = 0; srcElements[i]; ++i ) {
rob@77 6354 cloneCopyEvent( srcElements[i], destElements[i] );
rob@77 6355 }
rob@77 6356 }
rob@77 6357 }
rob@77 6358
rob@77 6359 srcElements = destElements = null;
rob@77 6360
rob@77 6361 // Return the cloned set
rob@77 6362 return clone;
rob@77 6363 },
rob@77 6364
rob@77 6365 clean: function( elems, context, fragment, scripts ) {
rob@77 6366 var checkScriptType, script, j,
rob@77 6367 ret = [];
rob@77 6368
rob@77 6369 context = context || document;
rob@77 6370
rob@77 6371 // !context.createElement fails in IE with an error but returns typeof 'object'
rob@77 6372 if ( typeof context.createElement === "undefined" ) {
rob@77 6373 context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
rob@77 6374 }
rob@77 6375
rob@77 6376 for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
rob@77 6377 if ( typeof elem === "number" ) {
rob@77 6378 elem += "";
rob@77 6379 }
rob@77 6380
rob@77 6381 if ( !elem ) {
rob@77 6382 continue;
rob@77 6383 }
rob@77 6384
rob@77 6385 // Convert html string into DOM nodes
rob@77 6386 if ( typeof elem === "string" ) {
rob@77 6387 if ( !rhtml.test( elem ) ) {
rob@77 6388 elem = context.createTextNode( elem );
rob@77 6389 } else {
rob@77 6390 // Fix "XHTML"-style tags in all browsers
rob@77 6391 elem = elem.replace(rxhtmlTag, "<$1></$2>");
rob@77 6392
rob@77 6393 // Trim whitespace, otherwise indexOf won't work as expected
rob@77 6394 var tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase(),
rob@77 6395 wrap = wrapMap[ tag ] || wrapMap._default,
rob@77 6396 depth = wrap[0],
rob@77 6397 div = context.createElement("div"),
rob@77 6398 safeChildNodes = safeFragment.childNodes,
rob@77 6399 remove;
rob@77 6400
rob@77 6401 // Append wrapper element to unknown element safe doc fragment
rob@77 6402 if ( context === document ) {
rob@77 6403 // Use the fragment we've already created for this document
rob@77 6404 safeFragment.appendChild( div );
rob@77 6405 } else {
rob@77 6406 // Use a fragment created with the owner document
rob@77 6407 createSafeFragment( context ).appendChild( div );
rob@77 6408 }
rob@77 6409
rob@77 6410 // Go to html and back, then peel off extra wrappers
rob@77 6411 div.innerHTML = wrap[1] + elem + wrap[2];
rob@77 6412
rob@77 6413 // Move to the right depth
rob@77 6414 while ( depth-- ) {
rob@77 6415 div = div.lastChild;
rob@77 6416 }
rob@77 6417
rob@77 6418 // Remove IE's autoinserted <tbody> from table fragments
rob@77 6419 if ( !jQuery.support.tbody ) {
rob@77 6420
rob@77 6421 // String was a <table>, *may* have spurious <tbody>
rob@77 6422 var hasBody = rtbody.test(elem),
rob@77 6423 tbody = tag === "table" && !hasBody ?
rob@77 6424 div.firstChild && div.firstChild.childNodes :
rob@77 6425
rob@77 6426 // String was a bare <thead> or <tfoot>
rob@77 6427 wrap[1] === "<table>" && !hasBody ?
rob@77 6428 div.childNodes :
rob@77 6429 [];
rob@77 6430
rob@77 6431 for ( j = tbody.length - 1; j >= 0 ; --j ) {
rob@77 6432 if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
rob@77 6433 tbody[ j ].parentNode.removeChild( tbody[ j ] );
rob@77 6434 }
rob@77 6435 }
rob@77 6436 }
rob@77 6437
rob@77 6438 // IE completely kills leading whitespace when innerHTML is used
rob@77 6439 if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
rob@77 6440 div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
rob@77 6441 }
rob@77 6442
rob@77 6443 elem = div.childNodes;
rob@77 6444
rob@77 6445 // Clear elements from DocumentFragment (safeFragment or otherwise)
rob@77 6446 // to avoid hoarding elements. Fixes #11356
rob@77 6447 if ( div ) {
rob@77 6448 div.parentNode.removeChild( div );
rob@77 6449
rob@77 6450 // Guard against -1 index exceptions in FF3.6
rob@77 6451 if ( safeChildNodes.length > 0 ) {
rob@77 6452 remove = safeChildNodes[ safeChildNodes.length - 1 ];
rob@77 6453
rob@77 6454 if ( remove && remove.parentNode ) {
rob@77 6455 remove.parentNode.removeChild( remove );
rob@77 6456 }
rob@77 6457 }
rob@77 6458 }
rob@77 6459 }
rob@77 6460 }
rob@77 6461
rob@77 6462 // Resets defaultChecked for any radios and checkboxes
rob@77 6463 // about to be appended to the DOM in IE 6/7 (#8060)
rob@77 6464 var len;
rob@77 6465 if ( !jQuery.support.appendChecked ) {
rob@77 6466 if ( elem[0] && typeof (len = elem.length) === "number" ) {
rob@77 6467 for ( j = 0; j < len; j++ ) {
rob@77 6468 findInputs( elem[j] );
rob@77 6469 }
rob@77 6470 } else {
rob@77 6471 findInputs( elem );
rob@77 6472 }
rob@77 6473 }
rob@77 6474
rob@77 6475 if ( elem.nodeType ) {
rob@77 6476 ret.push( elem );
rob@77 6477 } else {
rob@77 6478 ret = jQuery.merge( ret, elem );
rob@77 6479 }
rob@77 6480 }
rob@77 6481
rob@77 6482 if ( fragment ) {
rob@77 6483 checkScriptType = function( elem ) {
rob@77 6484 return !elem.type || rscriptType.test( elem.type );
rob@77 6485 };
rob@77 6486 for ( i = 0; ret[i]; i++ ) {
rob@77 6487 script = ret[i];
rob@77 6488 if ( scripts && jQuery.nodeName( script, "script" ) && (!script.type || rscriptType.test( script.type )) ) {
rob@77 6489 scripts.push( script.parentNode ? script.parentNode.removeChild( script ) : script );
rob@77 6490
rob@77 6491 } else {
rob@77 6492 if ( script.nodeType === 1 ) {
rob@77 6493 var jsTags = jQuery.grep( script.getElementsByTagName( "script" ), checkScriptType );
rob@77 6494
rob@77 6495 ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
rob@77 6496 }
rob@77 6497 fragment.appendChild( script );
rob@77 6498 }
rob@77 6499 }
rob@77 6500 }
rob@77 6501
rob@77 6502 return ret;
rob@77 6503 },
rob@77 6504
rob@77 6505 cleanData: function( elems ) {
rob@77 6506 var data, id,
rob@77 6507 cache = jQuery.cache,
rob@77 6508 special = jQuery.event.special,
rob@77 6509 deleteExpando = jQuery.support.deleteExpando;
rob@77 6510
rob@77 6511 for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
rob@77 6512 if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
rob@77 6513 continue;
rob@77 6514 }
rob@77 6515
rob@77 6516 id = elem[ jQuery.expando ];
rob@77 6517
rob@77 6518 if ( id ) {
rob@77 6519 data = cache[ id ];
rob@77 6520
rob@77 6521 if ( data && data.events ) {
rob@77 6522 for ( var type in data.events ) {
rob@77 6523 if ( special[ type ] ) {
rob@77 6524 jQuery.event.remove( elem, type );
rob@77 6525
rob@77 6526 // This is a shortcut to avoid jQuery.event.remove's overhead
rob@77 6527 } else {
rob@77 6528 jQuery.removeEvent( elem, type, data.handle );
rob@77 6529 }
rob@77 6530 }
rob@77 6531
rob@77 6532 // Null the DOM reference to avoid IE6/7/8 leak (#7054)
rob@77 6533 if ( data.handle ) {
rob@77 6534 data.handle.elem = null;
rob@77 6535 }
rob@77 6536 }
rob@77 6537
rob@77 6538 if ( deleteExpando ) {
rob@77 6539 delete elem[ jQuery.expando ];
rob@77 6540
rob@77 6541 } else if ( elem.removeAttribute ) {
rob@77 6542 elem.removeAttribute( jQuery.expando );
rob@77 6543 }
rob@77 6544
rob@77 6545 delete cache[ id ];
rob@77 6546 }
rob@77 6547 }
rob@77 6548 }
rob@77 6549 });
rob@77 6550
rob@77 6551
rob@77 6552
rob@77 6553
rob@77 6554 var ralpha = /alpha\([^)]*\)/i,
rob@77 6555 ropacity = /opacity=([^)]*)/,
rob@77 6556 // fixed for IE9, see #8346
rob@77 6557 rupper = /([A-Z]|^ms)/g,
rob@77 6558 rnum = /^[\-+]?(?:\d*\.)?\d+$/i,
rob@77 6559 rnumnonpx = /^-?(?:\d*\.)?\d+(?!px)[^\d\s]+$/i,
rob@77 6560 rrelNum = /^([\-+])=([\-+.\de]+)/,
rob@77 6561 rmargin = /^margin/,
rob@77 6562
rob@77 6563 cssShow = { position: "absolute", visibility: "hidden", display: "block" },
rob@77 6564
rob@77 6565 // order is important!
rob@77 6566 cssExpand = [ "Top", "Right", "Bottom", "Left" ],
rob@77 6567
rob@77 6568 curCSS,
rob@77 6569
rob@77 6570 getComputedStyle,
rob@77 6571 currentStyle;
rob@77 6572
rob@77 6573 jQuery.fn.css = function( name, value ) {
rob@77 6574 return jQuery.access( this, function( elem, name, value ) {
rob@77 6575 return value !== undefined ?
rob@77 6576 jQuery.style( elem, name, value ) :
rob@77 6577 jQuery.css( elem, name );
rob@77 6578 }, name, value, arguments.length > 1 );
rob@77 6579 };
rob@77 6580
rob@77 6581 jQuery.extend({
rob@77 6582 // Add in style property hooks for overriding the default
rob@77 6583 // behavior of getting and setting a style property
rob@77 6584 cssHooks: {
rob@77 6585 opacity: {
rob@77 6586 get: function( elem, computed ) {
rob@77 6587 if ( computed ) {
rob@77 6588 // We should always get a number back from opacity
rob@77 6589 var ret = curCSS( elem, "opacity" );
rob@77 6590 return ret === "" ? "1" : ret;
rob@77 6591
rob@77 6592 } else {
rob@77 6593 return elem.style.opacity;
rob@77 6594 }
rob@77 6595 }
rob@77 6596 }
rob@77 6597 },
rob@77 6598
rob@77 6599 // Exclude the following css properties to add px
rob@77 6600 cssNumber: {
rob@77 6601 "fillOpacity": true,
rob@77 6602 "fontWeight": true,
rob@77 6603 "lineHeight": true,
rob@77 6604 "opacity": true,
rob@77 6605 "orphans": true,
rob@77 6606 "widows": true,
rob@77 6607 "zIndex": true,
rob@77 6608 "zoom": true
rob@77 6609 },
rob@77 6610
rob@77 6611 // Add in properties whose names you wish to fix before
rob@77 6612 // setting or getting the value
rob@77 6613 cssProps: {
rob@77 6614 // normalize float css property
rob@77 6615 "float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat"
rob@77 6616 },
rob@77 6617
rob@77 6618 // Get and set the style property on a DOM Node
rob@77 6619 style: function( elem, name, value, extra ) {
rob@77 6620 // Don't set styles on text and comment nodes
rob@77 6621 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
rob@77 6622 return;
rob@77 6623 }
rob@77 6624
rob@77 6625 // Make sure that we're working with the right name
rob@77 6626 var ret, type, origName = jQuery.camelCase( name ),
rob@77 6627 style = elem.style, hooks = jQuery.cssHooks[ origName ];
rob@77 6628
rob@77 6629 name = jQuery.cssProps[ origName ] || origName;
rob@77 6630
rob@77 6631 // Check if we're setting a value
rob@77 6632 if ( value !== undefined ) {
rob@77 6633 type = typeof value;
rob@77 6634
rob@77 6635 // convert relative number strings (+= or -=) to relative numbers. #7345
rob@77 6636 if ( type === "string" && (ret = rrelNum.exec( value )) ) {
rob@77 6637 value = ( +( ret[1] + 1) * +ret[2] ) + parseFloat( jQuery.css( elem, name ) );
rob@77 6638 // Fixes bug #9237
rob@77 6639 type = "number";
rob@77 6640 }
rob@77 6641
rob@77 6642 // Make sure that NaN and null values aren't set. See: #7116
rob@77 6643 if ( value == null || type === "number" && isNaN( value ) ) {
rob@77 6644 return;
rob@77 6645 }
rob@77 6646
rob@77 6647 // If a number was passed in, add 'px' to the (except for certain CSS properties)
rob@77 6648 if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
rob@77 6649 value += "px";
rob@77 6650 }
rob@77 6651
rob@77 6652 // If a hook was provided, use that value, otherwise just set the specified value
rob@77 6653 if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value )) !== undefined ) {
rob@77 6654 // Wrapped to prevent IE from throwing errors when 'invalid' values are provided
rob@77 6655 // Fixes bug #5509
rob@77 6656 try {
rob@77 6657 style[ name ] = value;
rob@77 6658 } catch(e) {}
rob@77 6659 }
rob@77 6660
rob@77 6661 } else {
rob@77 6662 // If a hook was provided get the non-computed value from there
rob@77 6663 if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
rob@77 6664 return ret;
rob@77 6665 }
rob@77 6666
rob@77 6667 // Otherwise just get the value from the style object
rob@77 6668 return style[ name ];
rob@77 6669 }
rob@77 6670 },
rob@77 6671
rob@77 6672 css: function( elem, name, extra ) {
rob@77 6673 var ret, hooks;
rob@77 6674
rob@77 6675 // Make sure that we're working with the right name
rob@77 6676 name = jQuery.camelCase( name );
rob@77 6677 hooks = jQuery.cssHooks[ name ];
rob@77 6678 name = jQuery.cssProps[ name ] || name;
rob@77 6679
rob@77 6680 // cssFloat needs a special treatment
rob@77 6681 if ( name === "cssFloat" ) {
rob@77 6682 name = "float";
rob@77 6683 }
rob@77 6684
rob@77 6685 // If a hook was provided get the computed value from there
rob@77 6686 if ( hooks && "get" in hooks && (ret = hooks.get( elem, true, extra )) !== undefined ) {
rob@77 6687 return ret;
rob@77 6688
rob@77 6689 // Otherwise, if a way to get the computed value exists, use that
rob@77 6690 } else if ( curCSS ) {
rob@77 6691 return curCSS( elem, name );
rob@77 6692 }
rob@77 6693 },
rob@77 6694
rob@77 6695 // A method for quickly swapping in/out CSS properties to get correct calculations
rob@77 6696 swap: function( elem, options, callback ) {
rob@77 6697 var old = {},
rob@77 6698 ret, name;
rob@77 6699
rob@77 6700 // Remember the old values, and insert the new ones
rob@77 6701 for ( name in options ) {
rob@77 6702 old[ name ] = elem.style[ name ];
rob@77 6703 elem.style[ name ] = options[ name ];
rob@77 6704 }
rob@77 6705
rob@77 6706 ret = callback.call( elem );
rob@77 6707
rob@77 6708 // Revert the old values
rob@77 6709 for ( name in options ) {
rob@77 6710 elem.style[ name ] = old[ name ];
rob@77 6711 }
rob@77 6712
rob@77 6713 return ret;
rob@77 6714 }
rob@77 6715 });
rob@77 6716
rob@77 6717 // DEPRECATED in 1.3, Use jQuery.css() instead
rob@77 6718 jQuery.curCSS = jQuery.css;
rob@77 6719
rob@77 6720 if ( document.defaultView && document.defaultView.getComputedStyle ) {
rob@77 6721 getComputedStyle = function( elem, name ) {
rob@77 6722 var ret, defaultView, computedStyle, width,
rob@77 6723 style = elem.style;
rob@77 6724
rob@77 6725 name = name.replace( rupper, "-$1" ).toLowerCase();
rob@77 6726
rob@77 6727 if ( (defaultView = elem.ownerDocument.defaultView) &&
rob@77 6728 (computedStyle = defaultView.getComputedStyle( elem, null )) ) {
rob@77 6729
rob@77 6730 ret = computedStyle.getPropertyValue( name );
rob@77 6731 if ( ret === "" && !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) {
rob@77 6732 ret = jQuery.style( elem, name );
rob@77 6733 }
rob@77 6734 }
rob@77 6735
rob@77 6736 // A tribute to the "awesome hack by Dean Edwards"
rob@77 6737 // WebKit uses "computed value (percentage if specified)" instead of "used value" for margins
rob@77 6738 // which is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
rob@77 6739 if ( !jQuery.support.pixelMargin && computedStyle && rmargin.test( name ) && rnumnonpx.test( ret ) ) {
rob@77 6740 width = style.width;
rob@77 6741 style.width = ret;
rob@77 6742 ret = computedStyle.width;
rob@77 6743 style.width = width;
rob@77 6744 }
rob@77 6745
rob@77 6746 return ret;
rob@77 6747 };
rob@77 6748 }
rob@77 6749
rob@77 6750 if ( document.documentElement.currentStyle ) {
rob@77 6751 currentStyle = function( elem, name ) {
rob@77 6752 var left, rsLeft, uncomputed,
rob@77 6753 ret = elem.currentStyle && elem.currentStyle[ name ],
rob@77 6754 style = elem.style;
rob@77 6755
rob@77 6756 // Avoid setting ret to empty string here
rob@77 6757 // so we don't default to auto
rob@77 6758 if ( ret == null && style && (uncomputed = style[ name ]) ) {
rob@77 6759 ret = uncomputed;
rob@77 6760 }
rob@77 6761
rob@77 6762 // From the awesome hack by Dean Edwards
rob@77 6763 // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
rob@77 6764
rob@77 6765 // If we're not dealing with a regular pixel number
rob@77 6766 // but a number that has a weird ending, we need to convert it to pixels
rob@77 6767 if ( rnumnonpx.test( ret ) ) {
rob@77 6768
rob@77 6769 // Remember the original values
rob@77 6770 left = style.left;
rob@77 6771 rsLeft = elem.runtimeStyle && elem.runtimeStyle.left;
rob@77 6772
rob@77 6773 // Put in the new values to get a computed value out
rob@77 6774 if ( rsLeft ) {
rob@77 6775 elem.runtimeStyle.left = elem.currentStyle.left;
rob@77 6776 }
rob@77 6777 style.left = name === "fontSize" ? "1em" : ret;
rob@77 6778 ret = style.pixelLeft + "px";
rob@77 6779
rob@77 6780 // Revert the changed values
rob@77 6781 style.left = left;
rob@77 6782 if ( rsLeft ) {
rob@77 6783 elem.runtimeStyle.left = rsLeft;
rob@77 6784 }
rob@77 6785 }
rob@77 6786
rob@77 6787 return ret === "" ? "auto" : ret;
rob@77 6788 };
rob@77 6789 }
rob@77 6790
rob@77 6791 curCSS = getComputedStyle || currentStyle;
rob@77 6792
rob@77 6793 function getWidthOrHeight( elem, name, extra ) {
rob@77 6794
rob@77 6795 // Start with offset property
rob@77 6796 var val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
rob@77 6797 i = name === "width" ? 1 : 0,
rob@77 6798 len = 4;
rob@77 6799
rob@77 6800 if ( val > 0 ) {
rob@77 6801 if ( extra !== "border" ) {
rob@77 6802 for ( ; i < len; i += 2 ) {
rob@77 6803 if ( !extra ) {
rob@77 6804 val -= parseFloat( jQuery.css( elem, "padding" + cssExpand[ i ] ) ) || 0;
rob@77 6805 }
rob@77 6806 if ( extra === "margin" ) {
rob@77 6807 val += parseFloat( jQuery.css( elem, extra + cssExpand[ i ] ) ) || 0;
rob@77 6808 } else {
rob@77 6809 val -= parseFloat( jQuery.css( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0;
rob@77 6810 }
rob@77 6811 }
rob@77 6812 }
rob@77 6813
rob@77 6814 return val + "px";
rob@77 6815 }
rob@77 6816
rob@77 6817 // Fall back to computed then uncomputed css if necessary
rob@77 6818 val = curCSS( elem, name );
rob@77 6819 if ( val < 0 || val == null ) {
rob@77 6820 val = elem.style[ name ];
rob@77 6821 }
rob@77 6822
rob@77 6823 // Computed unit is not pixels. Stop here and return.
rob@77 6824 if ( rnumnonpx.test(val) ) {
rob@77 6825 return val;
rob@77 6826 }
rob@77 6827
rob@77 6828 // Normalize "", auto, and prepare for extra
rob@77 6829 val = parseFloat( val ) || 0;
rob@77 6830
rob@77 6831 // Add padding, border, margin
rob@77 6832 if ( extra ) {
rob@77 6833 for ( ; i < len; i += 2 ) {
rob@77 6834 val += parseFloat( jQuery.css( elem, "padding" + cssExpand[ i ] ) ) || 0;
rob@77 6835 if ( extra !== "padding" ) {
rob@77 6836 val += parseFloat( jQuery.css( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0;
rob@77 6837 }
rob@77 6838 if ( extra === "margin" ) {
rob@77 6839 val += parseFloat( jQuery.css( elem, extra + cssExpand[ i ]) ) || 0;
rob@77 6840 }
rob@77 6841 }
rob@77 6842 }
rob@77 6843
rob@77 6844 return val + "px";
rob@77 6845 }
rob@77 6846
rob@77 6847 jQuery.each([ "height", "width" ], function( i, name ) {
rob@77 6848 jQuery.cssHooks[ name ] = {
rob@77 6849 get: function( elem, computed, extra ) {
rob@77 6850 if ( computed ) {
rob@77 6851 if ( elem.offsetWidth !== 0 ) {
rob@77 6852 return getWidthOrHeight( elem, name, extra );
rob@77 6853 } else {
rob@77 6854 return jQuery.swap( elem, cssShow, function() {
rob@77 6855 return getWidthOrHeight( elem, name, extra );
rob@77 6856 });
rob@77 6857 }
rob@77 6858 }
rob@77 6859 },
rob@77 6860
rob@77 6861 set: function( elem, value ) {
rob@77 6862 return rnum.test( value ) ?
rob@77 6863 value + "px" :
rob@77 6864 value;
rob@77 6865 }
rob@77 6866 };
rob@77 6867 });
rob@77 6868
rob@77 6869 if ( !jQuery.support.opacity ) {
rob@77 6870 jQuery.cssHooks.opacity = {
rob@77 6871 get: function( elem, computed ) {
rob@77 6872 // IE uses filters for opacity
rob@77 6873 return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
rob@77 6874 ( parseFloat( RegExp.$1 ) / 100 ) + "" :
rob@77 6875 computed ? "1" : "";
rob@77 6876 },
rob@77 6877
rob@77 6878 set: function( elem, value ) {
rob@77 6879 var style = elem.style,
rob@77 6880 currentStyle = elem.currentStyle,
rob@77 6881 opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
rob@77 6882 filter = currentStyle && currentStyle.filter || style.filter || "";
rob@77 6883
rob@77 6884 // IE has trouble with opacity if it does not have layout
rob@77 6885 // Force it by setting the zoom level
rob@77 6886 style.zoom = 1;
rob@77 6887
rob@77 6888 // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
rob@77 6889 if ( value >= 1 && jQuery.trim( filter.replace( ralpha, "" ) ) === "" ) {
rob@77 6890
rob@77 6891 // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
rob@77 6892 // if "filter:" is present at all, clearType is disabled, we want to avoid this
rob@77 6893 // style.removeAttribute is IE Only, but so apparently is this code path...
rob@77 6894 style.removeAttribute( "filter" );
rob@77 6895
rob@77 6896 // if there there is no filter style applied in a css rule, we are done
rob@77 6897 if ( currentStyle && !currentStyle.filter ) {
rob@77 6898 return;
rob@77 6899 }
rob@77 6900 }
rob@77 6901
rob@77 6902 // otherwise, set new filter values
rob@77 6903 style.filter = ralpha.test( filter ) ?
rob@77 6904 filter.replace( ralpha, opacity ) :
rob@77 6905 filter + " " + opacity;
rob@77 6906 }
rob@77 6907 };
rob@77 6908 }
rob@77 6909
rob@77 6910 jQuery(function() {
rob@77 6911 // This hook cannot be added until DOM ready because the support test
rob@77 6912 // for it is not run until after DOM ready
rob@77 6913 if ( !jQuery.support.reliableMarginRight ) {
rob@77 6914 jQuery.cssHooks.marginRight = {
rob@77 6915 get: function( elem, computed ) {
rob@77 6916 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
rob@77 6917 // Work around by temporarily setting element display to inline-block
rob@77 6918 return jQuery.swap( elem, { "display": "inline-block" }, function() {
rob@77 6919 if ( computed ) {
rob@77 6920 return curCSS( elem, "margin-right" );
rob@77 6921 } else {
rob@77 6922 return elem.style.marginRight;
rob@77 6923 }
rob@77 6924 });
rob@77 6925 }
rob@77 6926 };
rob@77 6927 }
rob@77 6928 });
rob@77 6929
rob@77 6930 if ( jQuery.expr && jQuery.expr.filters ) {
rob@77 6931 jQuery.expr.filters.hidden = function( elem ) {
rob@77 6932 var width = elem.offsetWidth,
rob@77 6933 height = elem.offsetHeight;
rob@77 6934
rob@77 6935 return ( width === 0 && height === 0 ) || (!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || jQuery.css( elem, "display" )) === "none");
rob@77 6936 };
rob@77 6937
rob@77 6938 jQuery.expr.filters.visible = function( elem ) {
rob@77 6939 return !jQuery.expr.filters.hidden( elem );
rob@77 6940 };
rob@77 6941 }
rob@77 6942
rob@77 6943 // These hooks are used by animate to expand properties
rob@77 6944 jQuery.each({
rob@77 6945 margin: "",
rob@77 6946 padding: "",
rob@77 6947 border: "Width"
rob@77 6948 }, function( prefix, suffix ) {
rob@77 6949
rob@77 6950 jQuery.cssHooks[ prefix + suffix ] = {
rob@77 6951 expand: function( value ) {
rob@77 6952 var i,
rob@77 6953
rob@77 6954 // assumes a single number if not a string
rob@77 6955 parts = typeof value === "string" ? value.split(" ") : [ value ],
rob@77 6956 expanded = {};
rob@77 6957
rob@77 6958 for ( i = 0; i < 4; i++ ) {
rob@77 6959 expanded[ prefix + cssExpand[ i ] + suffix ] =
rob@77 6960 parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
rob@77 6961 }
rob@77 6962
rob@77 6963 return expanded;
rob@77 6964 }
rob@77 6965 };
rob@77 6966 });
rob@77 6967
rob@77 6968
rob@77 6969
rob@77 6970
rob@77 6971 var r20 = /%20/g,
rob@77 6972 rbracket = /\[\]$/,
rob@77 6973 rCRLF = /\r?\n/g,
rob@77 6974 rhash = /#.*$/,
rob@77 6975 rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
rob@77 6976 rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
rob@77 6977 // #7653, #8125, #8152: local protocol detection
rob@77 6978 rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,
rob@77 6979 rnoContent = /^(?:GET|HEAD)$/,
rob@77 6980 rprotocol = /^\/\//,
rob@77 6981 rquery = /\?/,
rob@77 6982 rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
rob@77 6983 rselectTextarea = /^(?:select|textarea)/i,
rob@77 6984 rspacesAjax = /\s+/,
rob@77 6985 rts = /([?&])_=[^&]*/,
rob@77 6986 rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,
rob@77 6987
rob@77 6988 // Keep a copy of the old load method
rob@77 6989 _load = jQuery.fn.load,
rob@77 6990
rob@77 6991 /* Prefilters
rob@77 6992 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
rob@77 6993 * 2) These are called:
rob@77 6994 * - BEFORE asking for a transport
rob@77 6995 * - AFTER param serialization (s.data is a string if s.processData is true)
rob@77 6996 * 3) key is the dataType
rob@77 6997 * 4) the catchall symbol "*" can be used
rob@77 6998 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
rob@77 6999 */
rob@77 7000 prefilters = {},
rob@77 7001
rob@77 7002 /* Transports bindings
rob@77 7003 * 1) key is the dataType
rob@77 7004 * 2) the catchall symbol "*" can be used
rob@77 7005 * 3) selection will start with transport dataType and THEN go to "*" if needed
rob@77 7006 */
rob@77 7007 transports = {},
rob@77 7008
rob@77 7009 // Document location
rob@77 7010 ajaxLocation,
rob@77 7011
rob@77 7012 // Document location segments
rob@77 7013 ajaxLocParts,
rob@77 7014
rob@77 7015 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
rob@77 7016 allTypes = ["*/"] + ["*"];
rob@77 7017
rob@77 7018 // #8138, IE may throw an exception when accessing
rob@77 7019 // a field from window.location if document.domain has been set
rob@77 7020 try {
rob@77 7021 ajaxLocation = location.href;
rob@77 7022 } catch( e ) {
rob@77 7023 // Use the href attribute of an A element
rob@77 7024 // since IE will modify it given document.location
rob@77 7025 ajaxLocation = document.createElement( "a" );
rob@77 7026 ajaxLocation.href = "";
rob@77 7027 ajaxLocation = ajaxLocation.href;
rob@77 7028 }
rob@77 7029
rob@77 7030 // Segment location into parts
rob@77 7031 ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
rob@77 7032
rob@77 7033 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
rob@77 7034 function addToPrefiltersOrTransports( structure ) {
rob@77 7035
rob@77 7036 // dataTypeExpression is optional and defaults to "*"
rob@77 7037 return function( dataTypeExpression, func ) {
rob@77 7038
rob@77 7039 if ( typeof dataTypeExpression !== "string" ) {
rob@77 7040 func = dataTypeExpression;
rob@77 7041 dataTypeExpression = "*";
rob@77 7042 }
rob@77 7043
rob@77 7044 if ( jQuery.isFunction( func ) ) {
rob@77 7045 var dataTypes = dataTypeExpression.toLowerCase().split( rspacesAjax ),
rob@77 7046 i = 0,
rob@77 7047 length = dataTypes.length,
rob@77 7048 dataType,
rob@77 7049 list,
rob@77 7050 placeBefore;
rob@77 7051
rob@77 7052 // For each dataType in the dataTypeExpression
rob@77 7053 for ( ; i < length; i++ ) {
rob@77 7054 dataType = dataTypes[ i ];
rob@77 7055 // We control if we're asked to add before
rob@77 7056 // any existing element
rob@77 7057 placeBefore = /^\+/.test( dataType );
rob@77 7058 if ( placeBefore ) {
rob@77 7059 dataType = dataType.substr( 1 ) || "*";
rob@77 7060 }
rob@77 7061 list = structure[ dataType ] = structure[ dataType ] || [];
rob@77 7062 // then we add to the structure accordingly
rob@77 7063 list[ placeBefore ? "unshift" : "push" ]( func );
rob@77 7064 }
rob@77 7065 }
rob@77 7066 };
rob@77 7067 }
rob@77 7068
rob@77 7069 // Base inspection function for prefilters and transports
rob@77 7070 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR,
rob@77 7071 dataType /* internal */, inspected /* internal */ ) {
rob@77 7072
rob@77 7073 dataType = dataType || options.dataTypes[ 0 ];
rob@77 7074 inspected = inspected || {};
rob@77 7075
rob@77 7076 inspected[ dataType ] = true;
rob@77 7077
rob@77 7078 var list = structure[ dataType ],
rob@77 7079 i = 0,
rob@77 7080 length = list ? list.length : 0,
rob@77 7081 executeOnly = ( structure === prefilters ),
rob@77 7082 selection;
rob@77 7083
rob@77 7084 for ( ; i < length && ( executeOnly || !selection ); i++ ) {
rob@77 7085 selection = list[ i ]( options, originalOptions, jqXHR );
rob@77 7086 // If we got redirected to another dataType
rob@77 7087 // we try there if executing only and not done already
rob@77 7088 if ( typeof selection === "string" ) {
rob@77 7089 if ( !executeOnly || inspected[ selection ] ) {
rob@77 7090 selection = undefined;
rob@77 7091 } else {
rob@77 7092 options.dataTypes.unshift( selection );
rob@77 7093 selection = inspectPrefiltersOrTransports(
rob@77 7094 structure, options, originalOptions, jqXHR, selection, inspected );
rob@77 7095 }
rob@77 7096 }
rob@77 7097 }
rob@77 7098 // If we're only executing or nothing was selected
rob@77 7099 // we try the catchall dataType if not done already
rob@77 7100 if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) {
rob@77 7101 selection = inspectPrefiltersOrTransports(
rob@77 7102 structure, options, originalOptions, jqXHR, "*", inspected );
rob@77 7103 }
rob@77 7104 // unnecessary when only executing (prefilters)
rob@77 7105 // but it'll be ignored by the caller in that case
rob@77 7106 return selection;
rob@77 7107 }
rob@77 7108
rob@77 7109 // A special extend for ajax options
rob@77 7110 // that takes "flat" options (not to be deep extended)
rob@77 7111 // Fixes #9887
rob@77 7112 function ajaxExtend( target, src ) {
rob@77 7113 var key, deep,
rob@77 7114 flatOptions = jQuery.ajaxSettings.flatOptions || {};
rob@77 7115 for ( key in src ) {
rob@77 7116 if ( src[ key ] !== undefined ) {
rob@77 7117 ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
rob@77 7118 }
rob@77 7119 }
rob@77 7120 if ( deep ) {
rob@77 7121 jQuery.extend( true, target, deep );
rob@77 7122 }
rob@77 7123 }
rob@77 7124
rob@77 7125 jQuery.fn.extend({
rob@77 7126 load: function( url, params, callback ) {
rob@77 7127 if ( typeof url !== "string" && _load ) {
rob@77 7128 return _load.apply( this, arguments );
rob@77 7129
rob@77 7130 // Don't do a request if no elements are being requested
rob@77 7131 } else if ( !this.length ) {
rob@77 7132 return this;
rob@77 7133 }
rob@77 7134
rob@77 7135 var off = url.indexOf( " " );
rob@77 7136 if ( off >= 0 ) {
rob@77 7137 var selector = url.slice( off, url.length );
rob@77 7138 url = url.slice( 0, off );
rob@77 7139 }
rob@77 7140
rob@77 7141 // Default to a GET request
rob@77 7142 var type = "GET";
rob@77 7143
rob@77 7144 // If the second parameter was provided
rob@77 7145 if ( params ) {
rob@77 7146 // If it's a function
rob@77 7147 if ( jQuery.isFunction( params ) ) {
rob@77 7148 // We assume that it's the callback
rob@77 7149 callback = params;
rob@77 7150 params = undefined;
rob@77 7151
rob@77 7152 // Otherwise, build a param string
rob@77 7153 } else if ( typeof params === "object" ) {
rob@77 7154 params = jQuery.param( params, jQuery.ajaxSettings.traditional );
rob@77 7155 type = "POST";
rob@77 7156 }
rob@77 7157 }
rob@77 7158
rob@77 7159 var self = this;
rob@77 7160
rob@77 7161 // Request the remote document
rob@77 7162 jQuery.ajax({
rob@77 7163 url: url,
rob@77 7164 type: type,
rob@77 7165 dataType: "html",
rob@77 7166 data: params,
rob@77 7167 // Complete callback (responseText is used internally)
rob@77 7168 complete: function( jqXHR, status, responseText ) {
rob@77 7169 // Store the response as specified by the jqXHR object
rob@77 7170 responseText = jqXHR.responseText;
rob@77 7171 // If successful, inject the HTML into all the matched elements
rob@77 7172 if ( jqXHR.isResolved() ) {
rob@77 7173 // #4825: Get the actual response in case
rob@77 7174 // a dataFilter is present in ajaxSettings
rob@77 7175 jqXHR.done(function( r ) {
rob@77 7176 responseText = r;
rob@77 7177 });
rob@77 7178 // See if a selector was specified
rob@77 7179 self.html( selector ?
rob@77 7180 // Create a dummy div to hold the results
rob@77 7181 jQuery("<div>")
rob@77 7182 // inject the contents of the document in, removing the scripts
rob@77 7183 // to avoid any 'Permission Denied' errors in IE
rob@77 7184 .append(responseText.replace(rscript, ""))
rob@77 7185
rob@77 7186 // Locate the specified elements
rob@77 7187 .find(selector) :
rob@77 7188
rob@77 7189 // If not, just inject the full result
rob@77 7190 responseText );
rob@77 7191 }
rob@77 7192
rob@77 7193 if ( callback ) {
rob@77 7194 self.each( callback, [ responseText, status, jqXHR ] );
rob@77 7195 }
rob@77 7196 }
rob@77 7197 });
rob@77 7198
rob@77 7199 return this;
rob@77 7200 },
rob@77 7201
rob@77 7202 serialize: function() {
rob@77 7203 return jQuery.param( this.serializeArray() );
rob@77 7204 },
rob@77 7205
rob@77 7206 serializeArray: function() {
rob@77 7207 return this.map(function(){
rob@77 7208 return this.elements ? jQuery.makeArray( this.elements ) : this;
rob@77 7209 })
rob@77 7210 .filter(function(){
rob@77 7211 return this.name && !this.disabled &&
rob@77 7212 ( this.checked || rselectTextarea.test( this.nodeName ) ||
rob@77 7213 rinput.test( this.type ) );
rob@77 7214 })
rob@77 7215 .map(function( i, elem ){
rob@77 7216 var val = jQuery( this ).val();
rob@77 7217
rob@77 7218 return val == null ?
rob@77 7219 null :
rob@77 7220 jQuery.isArray( val ) ?
rob@77 7221 jQuery.map( val, function( val, i ){
rob@77 7222 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
rob@77 7223 }) :
rob@77 7224 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
rob@77 7225 }).get();
rob@77 7226 }
rob@77 7227 });
rob@77 7228
rob@77 7229 // Attach a bunch of functions for handling common AJAX events
rob@77 7230 jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i, o ){
rob@77 7231 jQuery.fn[ o ] = function( f ){
rob@77 7232 return this.on( o, f );
rob@77 7233 };
rob@77 7234 });
rob@77 7235
rob@77 7236 jQuery.each( [ "get", "post" ], function( i, method ) {
rob@77 7237 jQuery[ method ] = function( url, data, callback, type ) {
rob@77 7238 // shift arguments if data argument was omitted
rob@77 7239 if ( jQuery.isFunction( data ) ) {
rob@77 7240 type = type || callback;
rob@77 7241 callback = data;
rob@77 7242 data = undefined;
rob@77 7243 }
rob@77 7244
rob@77 7245 return jQuery.ajax({
rob@77 7246 type: method,
rob@77 7247 url: url,
rob@77 7248 data: data,
rob@77 7249 success: callback,
rob@77 7250 dataType: type
rob@77 7251 });
rob@77 7252 };
rob@77 7253 });
rob@77 7254
rob@77 7255 jQuery.extend({
rob@77 7256
rob@77 7257 getScript: function( url, callback ) {
rob@77 7258 return jQuery.get( url, undefined, callback, "script" );
rob@77 7259 },
rob@77 7260
rob@77 7261 getJSON: function( url, data, callback ) {
rob@77 7262 return jQuery.get( url, data, callback, "json" );
rob@77 7263 },
rob@77 7264
rob@77 7265 // Creates a full fledged settings object into target
rob@77 7266 // with both ajaxSettings and settings fields.
rob@77 7267 // If target is omitted, writes into ajaxSettings.
rob@77 7268 ajaxSetup: function( target, settings ) {
rob@77 7269 if ( settings ) {
rob@77 7270 // Building a settings object
rob@77 7271 ajaxExtend( target, jQuery.ajaxSettings );
rob@77 7272 } else {
rob@77 7273 // Extending ajaxSettings
rob@77 7274 settings = target;
rob@77 7275 target = jQuery.ajaxSettings;
rob@77 7276 }
rob@77 7277 ajaxExtend( target, settings );
rob@77 7278 return target;
rob@77 7279 },
rob@77 7280
rob@77 7281 ajaxSettings: {
rob@77 7282 url: ajaxLocation,
rob@77 7283 isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
rob@77 7284 global: true,
rob@77 7285 type: "GET",
rob@77 7286 contentType: "application/x-www-form-urlencoded; charset=UTF-8",
rob@77 7287 processData: true,
rob@77 7288 async: true,
rob@77 7289 /*
rob@77 7290 timeout: 0,
rob@77 7291 data: null,
rob@77 7292 dataType: null,
rob@77 7293 username: null,
rob@77 7294 password: null,
rob@77 7295 cache: null,
rob@77 7296 traditional: false,
rob@77 7297 headers: {},
rob@77 7298 */
rob@77 7299
rob@77 7300 accepts: {
rob@77 7301 xml: "application/xml, text/xml",
rob@77 7302 html: "text/html",
rob@77 7303 text: "text/plain",
rob@77 7304 json: "application/json, text/javascript",
rob@77 7305 "*": allTypes
rob@77 7306 },
rob@77 7307
rob@77 7308 contents: {
rob@77 7309 xml: /xml/,
rob@77 7310 html: /html/,
rob@77 7311 json: /json/
rob@77 7312 },
rob@77 7313
rob@77 7314 responseFields: {
rob@77 7315 xml: "responseXML",
rob@77 7316 text: "responseText"
rob@77 7317 },
rob@77 7318
rob@77 7319 // List of data converters
rob@77 7320 // 1) key format is "source_type destination_type" (a single space in-between)
rob@77 7321 // 2) the catchall symbol "*" can be used for source_type
rob@77 7322 converters: {
rob@77 7323
rob@77 7324 // Convert anything to text
rob@77 7325 "* text": window.String,
rob@77 7326
rob@77 7327 // Text to html (true = no transformation)
rob@77 7328 "text html": true,
rob@77 7329
rob@77 7330 // Evaluate text as a json expression
rob@77 7331 "text json": jQuery.parseJSON,
rob@77 7332
rob@77 7333 // Parse text as xml
rob@77 7334 "text xml": jQuery.parseXML
rob@77 7335 },
rob@77 7336
rob@77 7337 // For options that shouldn't be deep extended:
rob@77 7338 // you can add your own custom options here if
rob@77 7339 // and when you create one that shouldn't be
rob@77 7340 // deep extended (see ajaxExtend)
rob@77 7341 flatOptions: {
rob@77 7342 context: true,
rob@77 7343 url: true
rob@77 7344 }
rob@77 7345 },
rob@77 7346
rob@77 7347 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
rob@77 7348 ajaxTransport: addToPrefiltersOrTransports( transports ),
rob@77 7349
rob@77 7350 // Main method
rob@77 7351 ajax: function( url, options ) {
rob@77 7352
rob@77 7353 // If url is an object, simulate pre-1.5 signature
rob@77 7354 if ( typeof url === "object" ) {
rob@77 7355 options = url;
rob@77 7356 url = undefined;
rob@77 7357 }
rob@77 7358
rob@77 7359 // Force options to be an object
rob@77 7360 options = options || {};
rob@77 7361
rob@77 7362 var // Create the final options object
rob@77 7363 s = jQuery.ajaxSetup( {}, options ),
rob@77 7364 // Callbacks context
rob@77 7365 callbackContext = s.context || s,
rob@77 7366 // Context for global events
rob@77 7367 // It's the callbackContext if one was provided in the options
rob@77 7368 // and if it's a DOM node or a jQuery collection
rob@77 7369 globalEventContext = callbackContext !== s &&
rob@77 7370 ( callbackContext.nodeType || callbackContext instanceof jQuery ) ?
rob@77 7371 jQuery( callbackContext ) : jQuery.event,
rob@77 7372 // Deferreds
rob@77 7373 deferred = jQuery.Deferred(),
rob@77 7374 completeDeferred = jQuery.Callbacks( "once memory" ),
rob@77 7375 // Status-dependent callbacks
rob@77 7376 statusCode = s.statusCode || {},
rob@77 7377 // ifModified key
rob@77 7378 ifModifiedKey,
rob@77 7379 // Headers (they are sent all at once)
rob@77 7380 requestHeaders = {},
rob@77 7381 requestHeadersNames = {},
rob@77 7382 // Response headers
rob@77 7383 responseHeadersString,
rob@77 7384 responseHeaders,
rob@77 7385 // transport
rob@77 7386 transport,
rob@77 7387 // timeout handle
rob@77 7388 timeoutTimer,
rob@77 7389 // Cross-domain detection vars
rob@77 7390 parts,
rob@77 7391 // The jqXHR state
rob@77 7392 state = 0,
rob@77 7393 // To know if global events are to be dispatched
rob@77 7394 fireGlobals,
rob@77 7395 // Loop variable
rob@77 7396 i,
rob@77 7397 // Fake xhr
rob@77 7398 jqXHR = {
rob@77 7399
rob@77 7400 readyState: 0,
rob@77 7401
rob@77 7402 // Caches the header
rob@77 7403 setRequestHeader: function( name, value ) {
rob@77 7404 if ( !state ) {
rob@77 7405 var lname = name.toLowerCase();
rob@77 7406 name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
rob@77 7407 requestHeaders[ name ] = value;
rob@77 7408 }
rob@77 7409 return this;
rob@77 7410 },
rob@77 7411
rob@77 7412 // Raw string
rob@77 7413 getAllResponseHeaders: function() {
rob@77 7414 return state === 2 ? responseHeadersString : null;
rob@77 7415 },
rob@77 7416
rob@77 7417 // Builds headers hashtable if needed
rob@77 7418 getResponseHeader: function( key ) {
rob@77 7419 var match;
rob@77 7420 if ( state === 2 ) {
rob@77 7421 if ( !responseHeaders ) {
rob@77 7422 responseHeaders = {};
rob@77 7423 while( ( match = rheaders.exec( responseHeadersString ) ) ) {
rob@77 7424 responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
rob@77 7425 }
rob@77 7426 }
rob@77 7427 match = responseHeaders[ key.toLowerCase() ];
rob@77 7428 }
rob@77 7429 return match === undefined ? null : match;
rob@77 7430 },
rob@77 7431
rob@77 7432 // Overrides response content-type header
rob@77 7433 overrideMimeType: function( type ) {
rob@77 7434 if ( !state ) {
rob@77 7435 s.mimeType = type;
rob@77 7436 }
rob@77 7437 return this;
rob@77 7438 },
rob@77 7439
rob@77 7440 // Cancel the request
rob@77 7441 abort: function( statusText ) {
rob@77 7442 statusText = statusText || "abort";
rob@77 7443 if ( transport ) {
rob@77 7444 transport.abort( statusText );
rob@77 7445 }
rob@77 7446 done( 0, statusText );
rob@77 7447 return this;
rob@77 7448 }
rob@77 7449 };
rob@77 7450
rob@77 7451 // Callback for when everything is done
rob@77 7452 // It is defined here because jslint complains if it is declared
rob@77 7453 // at the end of the function (which would be more logical and readable)
rob@77 7454 function done( status, nativeStatusText, responses, headers ) {
rob@77 7455
rob@77 7456 // Called once
rob@77 7457 if ( state === 2 ) {
rob@77 7458 return;
rob@77 7459 }
rob@77 7460
rob@77 7461 // State is "done" now
rob@77 7462 state = 2;
rob@77 7463
rob@77 7464 // Clear timeout if it exists
rob@77 7465 if ( timeoutTimer ) {
rob@77 7466 clearTimeout( timeoutTimer );
rob@77 7467 }
rob@77 7468
rob@77 7469 // Dereference transport for early garbage collection
rob@77 7470 // (no matter how long the jqXHR object will be used)
rob@77 7471 transport = undefined;
rob@77 7472
rob@77 7473 // Cache response headers
rob@77 7474 responseHeadersString = headers || "";
rob@77 7475
rob@77 7476 // Set readyState
rob@77 7477 jqXHR.readyState = status > 0 ? 4 : 0;
rob@77 7478
rob@77 7479 var isSuccess,
rob@77 7480 success,
rob@77 7481 error,
rob@77 7482 statusText = nativeStatusText,
rob@77 7483 response = responses ? ajaxHandleResponses( s, jqXHR, responses ) : undefined,
rob@77 7484 lastModified,
rob@77 7485 etag;
rob@77 7486
rob@77 7487 // If successful, handle type chaining
rob@77 7488 if ( status >= 200 && status < 300 || status === 304 ) {
rob@77 7489
rob@77 7490 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
rob@77 7491 if ( s.ifModified ) {
rob@77 7492
rob@77 7493 if ( ( lastModified = jqXHR.getResponseHeader( "Last-Modified" ) ) ) {
rob@77 7494 jQuery.lastModified[ ifModifiedKey ] = lastModified;
rob@77 7495 }
rob@77 7496 if ( ( etag = jqXHR.getResponseHeader( "Etag" ) ) ) {
rob@77 7497 jQuery.etag[ ifModifiedKey ] = etag;
rob@77 7498 }
rob@77 7499 }
rob@77 7500
rob@77 7501 // If not modified
rob@77 7502 if ( status === 304 ) {
rob@77 7503
rob@77 7504 statusText = "notmodified";
rob@77 7505 isSuccess = true;
rob@77 7506
rob@77 7507 // If we have data
rob@77 7508 } else {
rob@77 7509
rob@77 7510 try {
rob@77 7511 success = ajaxConvert( s, response );
rob@77 7512 statusText = "success";
rob@77 7513 isSuccess = true;
rob@77 7514 } catch(e) {
rob@77 7515 // We have a parsererror
rob@77 7516 statusText = "parsererror";
rob@77 7517 error = e;
rob@77 7518 }
rob@77 7519 }
rob@77 7520 } else {
rob@77 7521 // We extract error from statusText
rob@77 7522 // then normalize statusText and status for non-aborts
rob@77 7523 error = statusText;
rob@77 7524 if ( !statusText || status ) {
rob@77 7525 statusText = "error";
rob@77 7526 if ( status < 0 ) {
rob@77 7527 status = 0;
rob@77 7528 }
rob@77 7529 }
rob@77 7530 }
rob@77 7531
rob@77 7532 // Set data for the fake xhr object
rob@77 7533 jqXHR.status = status;
rob@77 7534 jqXHR.statusText = "" + ( nativeStatusText || statusText );
rob@77 7535
rob@77 7536 // Success/Error
rob@77 7537 if ( isSuccess ) {
rob@77 7538 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
rob@77 7539 } else {
rob@77 7540 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
rob@77 7541 }
rob@77 7542
rob@77 7543 // Status-dependent callbacks
rob@77 7544 jqXHR.statusCode( statusCode );
rob@77 7545 statusCode = undefined;
rob@77 7546
rob@77 7547 if ( fireGlobals ) {
rob@77 7548 globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ),
rob@77 7549 [ jqXHR, s, isSuccess ? success : error ] );
rob@77 7550 }
rob@77 7551
rob@77 7552 // Complete
rob@77 7553 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
rob@77 7554
rob@77 7555 if ( fireGlobals ) {
rob@77 7556 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
rob@77 7557 // Handle the global AJAX counter
rob@77 7558 if ( !( --jQuery.active ) ) {
rob@77 7559 jQuery.event.trigger( "ajaxStop" );
rob@77 7560 }
rob@77 7561 }
rob@77 7562 }
rob@77 7563
rob@77 7564 // Attach deferreds
rob@77 7565 deferred.promise( jqXHR );
rob@77 7566 jqXHR.success = jqXHR.done;
rob@77 7567 jqXHR.error = jqXHR.fail;
rob@77 7568 jqXHR.complete = completeDeferred.add;
rob@77 7569
rob@77 7570 // Status-dependent callbacks
rob@77 7571 jqXHR.statusCode = function( map ) {
rob@77 7572 if ( map ) {
rob@77 7573 var tmp;
rob@77 7574 if ( state < 2 ) {
rob@77 7575 for ( tmp in map ) {
rob@77 7576 statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ];
rob@77 7577 }
rob@77 7578 } else {
rob@77 7579 tmp = map[ jqXHR.status ];
rob@77 7580 jqXHR.then( tmp, tmp );
rob@77 7581 }
rob@77 7582 }
rob@77 7583 return this;
rob@77 7584 };
rob@77 7585
rob@77 7586 // Remove hash character (#7531: and string promotion)
rob@77 7587 // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
rob@77 7588 // We also use the url parameter if available
rob@77 7589 s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
rob@77 7590
rob@77 7591 // Extract dataTypes list
rob@77 7592 s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( rspacesAjax );
rob@77 7593
rob@77 7594 // Determine if a cross-domain request is in order
rob@77 7595 if ( s.crossDomain == null ) {
rob@77 7596 parts = rurl.exec( s.url.toLowerCase() );
rob@77 7597 s.crossDomain = !!( parts &&
rob@77 7598 ( parts[ 1 ] != ajaxLocParts[ 1 ] || parts[ 2 ] != ajaxLocParts[ 2 ] ||
rob@77 7599 ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) !=
rob@77 7600 ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) )
rob@77 7601 );
rob@77 7602 }
rob@77 7603
rob@77 7604 // Convert data if not already a string
rob@77 7605 if ( s.data && s.processData && typeof s.data !== "string" ) {
rob@77 7606 s.data = jQuery.param( s.data, s.traditional );
rob@77 7607 }
rob@77 7608
rob@77 7609 // Apply prefilters
rob@77 7610 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
rob@77 7611
rob@77 7612 // If request was aborted inside a prefilter, stop there
rob@77 7613 if ( state === 2 ) {
rob@77 7614 return false;
rob@77 7615 }
rob@77 7616
rob@77 7617 // We can fire global events as of now if asked to
rob@77 7618 fireGlobals = s.global;
rob@77 7619
rob@77 7620 // Uppercase the type
rob@77 7621 s.type = s.type.toUpperCase();
rob@77 7622
rob@77 7623 // Determine if request has content
rob@77 7624 s.hasContent = !rnoContent.test( s.type );
rob@77 7625
rob@77 7626 // Watch for a new set of requests
rob@77 7627 if ( fireGlobals && jQuery.active++ === 0 ) {
rob@77 7628 jQuery.event.trigger( "ajaxStart" );
rob@77 7629 }
rob@77 7630
rob@77 7631 // More options handling for requests with no content
rob@77 7632 if ( !s.hasContent ) {
rob@77 7633
rob@77 7634 // If data is available, append data to url
rob@77 7635 if ( s.data ) {
rob@77 7636 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data;
rob@77 7637 // #9682: remove data so that it's not used in an eventual retry
rob@77 7638 delete s.data;
rob@77 7639 }
rob@77 7640
rob@77 7641 // Get ifModifiedKey before adding the anti-cache parameter
rob@77 7642 ifModifiedKey = s.url;
rob@77 7643
rob@77 7644 // Add anti-cache in url if needed
rob@77 7645 if ( s.cache === false ) {
rob@77 7646
rob@77 7647 var ts = jQuery.now(),
rob@77 7648 // try replacing _= if it is there
rob@77 7649 ret = s.url.replace( rts, "$1_=" + ts );
rob@77 7650
rob@77 7651 // if nothing was replaced, add timestamp to the end
rob@77 7652 s.url = ret + ( ( ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" );
rob@77 7653 }
rob@77 7654 }
rob@77 7655
rob@77 7656 // Set the correct header, if data is being sent
rob@77 7657 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
rob@77 7658 jqXHR.setRequestHeader( "Content-Type", s.contentType );
rob@77 7659 }
rob@77 7660
rob@77 7661 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
rob@77 7662 if ( s.ifModified ) {
rob@77 7663 ifModifiedKey = ifModifiedKey || s.url;
rob@77 7664 if ( jQuery.lastModified[ ifModifiedKey ] ) {
rob@77 7665 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ ifModifiedKey ] );
rob@77 7666 }
rob@77 7667 if ( jQuery.etag[ ifModifiedKey ] ) {
rob@77 7668 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ ifModifiedKey ] );
rob@77 7669 }
rob@77 7670 }
rob@77 7671
rob@77 7672 // Set the Accepts header for the server, depending on the dataType
rob@77 7673 jqXHR.setRequestHeader(
rob@77 7674 "Accept",
rob@77 7675 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
rob@77 7676 s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
rob@77 7677 s.accepts[ "*" ]
rob@77 7678 );
rob@77 7679
rob@77 7680 // Check for headers option
rob@77 7681 for ( i in s.headers ) {
rob@77 7682 jqXHR.setRequestHeader( i, s.headers[ i ] );
rob@77 7683 }
rob@77 7684
rob@77 7685 // Allow custom headers/mimetypes and early abort
rob@77 7686 if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
rob@77 7687 // Abort if not done already
rob@77 7688 jqXHR.abort();
rob@77 7689 return false;
rob@77 7690
rob@77 7691 }
rob@77 7692
rob@77 7693 // Install callbacks on deferreds
rob@77 7694 for ( i in { success: 1, error: 1, complete: 1 } ) {
rob@77 7695 jqXHR[ i ]( s[ i ] );
rob@77 7696 }
rob@77 7697
rob@77 7698 // Get transport
rob@77 7699 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
rob@77 7700
rob@77 7701 // If no transport, we auto-abort
rob@77 7702 if ( !transport ) {
rob@77 7703 done( -1, "No Transport" );
rob@77 7704 } else {
rob@77 7705 jqXHR.readyState = 1;
rob@77 7706 // Send global event
rob@77 7707 if ( fireGlobals ) {
rob@77 7708 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
rob@77 7709 }
rob@77 7710 // Timeout
rob@77 7711 if ( s.async && s.timeout > 0 ) {
rob@77 7712 timeoutTimer = setTimeout( function(){
rob@77 7713 jqXHR.abort( "timeout" );
rob@77 7714 }, s.timeout );
rob@77 7715 }
rob@77 7716
rob@77 7717 try {
rob@77 7718 state = 1;
rob@77 7719 transport.send( requestHeaders, done );
rob@77 7720 } catch (e) {
rob@77 7721 // Propagate exception as error if not done
rob@77 7722 if ( state < 2 ) {
rob@77 7723 done( -1, e );
rob@77 7724 // Simply rethrow otherwise
rob@77 7725 } else {
rob@77 7726 throw e;
rob@77 7727 }
rob@77 7728 }
rob@77 7729 }
rob@77 7730
rob@77 7731 return jqXHR;
rob@77 7732 },
rob@77 7733
rob@77 7734 // Serialize an array of form elements or a set of
rob@77 7735 // key/values into a query string
rob@77 7736 param: function( a, traditional ) {
rob@77 7737 var s = [],
rob@77 7738 add = function( key, value ) {
rob@77 7739 // If value is a function, invoke it and return its value
rob@77 7740 value = jQuery.isFunction( value ) ? value() : value;
rob@77 7741 s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
rob@77 7742 };
rob@77 7743
rob@77 7744 // Set traditional to true for jQuery <= 1.3.2 behavior.
rob@77 7745 if ( traditional === undefined ) {
rob@77 7746 traditional = jQuery.ajaxSettings.traditional;
rob@77 7747 }
rob@77 7748
rob@77 7749 // If an array was passed in, assume that it is an array of form elements.
rob@77 7750 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
rob@77 7751 // Serialize the form elements
rob@77 7752 jQuery.each( a, function() {
rob@77 7753 add( this.name, this.value );
rob@77 7754 });
rob@77 7755
rob@77 7756 } else {
rob@77 7757 // If traditional, encode the "old" way (the way 1.3.2 or older
rob@77 7758 // did it), otherwise encode params recursively.
rob@77 7759 for ( var prefix in a ) {
rob@77 7760 buildParams( prefix, a[ prefix ], traditional, add );
rob@77 7761 }
rob@77 7762 }
rob@77 7763
rob@77 7764 // Return the resulting serialization
rob@77 7765 return s.join( "&" ).replace( r20, "+" );
rob@77 7766 }
rob@77 7767 });
rob@77 7768
rob@77 7769 function buildParams( prefix, obj, traditional, add ) {
rob@77 7770 if ( jQuery.isArray( obj ) ) {
rob@77 7771 // Serialize array item.
rob@77 7772 jQuery.each( obj, function( i, v ) {
rob@77 7773 if ( traditional || rbracket.test( prefix ) ) {
rob@77 7774 // Treat each array item as a scalar.
rob@77 7775 add( prefix, v );
rob@77 7776
rob@77 7777 } else {
rob@77 7778 // If array item is non-scalar (array or object), encode its
rob@77 7779 // numeric index to resolve deserialization ambiguity issues.
rob@77 7780 // Note that rack (as of 1.0.0) can't currently deserialize
rob@77 7781 // nested arrays properly, and attempting to do so may cause
rob@77 7782 // a server error. Possible fixes are to modify rack's
rob@77 7783 // deserialization algorithm or to provide an option or flag
rob@77 7784 // to force array serialization to be shallow.
rob@77 7785 buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
rob@77 7786 }
rob@77 7787 });
rob@77 7788
rob@77 7789 } else if ( !traditional && jQuery.type( obj ) === "object" ) {
rob@77 7790 // Serialize object item.
rob@77 7791 for ( var name in obj ) {
rob@77 7792 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
rob@77 7793 }
rob@77 7794
rob@77 7795 } else {
rob@77 7796 // Serialize scalar item.
rob@77 7797 add( prefix, obj );
rob@77 7798 }
rob@77 7799 }
rob@77 7800
rob@77 7801 // This is still on the jQuery object... for now
rob@77 7802 // Want to move this to jQuery.ajax some day
rob@77 7803 jQuery.extend({
rob@77 7804
rob@77 7805 // Counter for holding the number of active queries
rob@77 7806 active: 0,
rob@77 7807
rob@77 7808 // Last-Modified header cache for next request
rob@77 7809 lastModified: {},
rob@77 7810 etag: {}
rob@77 7811
rob@77 7812 });
rob@77 7813
rob@77 7814 /* Handles responses to an ajax request:
rob@77 7815 * - sets all responseXXX fields accordingly
rob@77 7816 * - finds the right dataType (mediates between content-type and expected dataType)
rob@77 7817 * - returns the corresponding response
rob@77 7818 */
rob@77 7819 function ajaxHandleResponses( s, jqXHR, responses ) {
rob@77 7820
rob@77 7821 var contents = s.contents,
rob@77 7822 dataTypes = s.dataTypes,
rob@77 7823 responseFields = s.responseFields,
rob@77 7824 ct,
rob@77 7825 type,
rob@77 7826 finalDataType,
rob@77 7827 firstDataType;
rob@77 7828
rob@77 7829 // Fill responseXXX fields
rob@77 7830 for ( type in responseFields ) {
rob@77 7831 if ( type in responses ) {
rob@77 7832 jqXHR[ responseFields[type] ] = responses[ type ];
rob@77 7833 }
rob@77 7834 }
rob@77 7835
rob@77 7836 // Remove auto dataType and get content-type in the process
rob@77 7837 while( dataTypes[ 0 ] === "*" ) {
rob@77 7838 dataTypes.shift();
rob@77 7839 if ( ct === undefined ) {
rob@77 7840 ct = s.mimeType || jqXHR.getResponseHeader( "content-type" );
rob@77 7841 }
rob@77 7842 }
rob@77 7843
rob@77 7844 // Check if we're dealing with a known content-type
rob@77 7845 if ( ct ) {
rob@77 7846 for ( type in contents ) {
rob@77 7847 if ( contents[ type ] && contents[ type ].test( ct ) ) {
rob@77 7848 dataTypes.unshift( type );
rob@77 7849 break;
rob@77 7850 }
rob@77 7851 }
rob@77 7852 }
rob@77 7853
rob@77 7854 // Check to see if we have a response for the expected dataType
rob@77 7855 if ( dataTypes[ 0 ] in responses ) {
rob@77 7856 finalDataType = dataTypes[ 0 ];
rob@77 7857 } else {
rob@77 7858 // Try convertible dataTypes
rob@77 7859 for ( type in responses ) {
rob@77 7860 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
rob@77 7861 finalDataType = type;
rob@77 7862 break;
rob@77 7863 }
rob@77 7864 if ( !firstDataType ) {
rob@77 7865 firstDataType = type;
rob@77 7866 }
rob@77 7867 }
rob@77 7868 // Or just use first one
rob@77 7869 finalDataType = finalDataType || firstDataType;
rob@77 7870 }
rob@77 7871
rob@77 7872 // If we found a dataType
rob@77 7873 // We add the dataType to the list if needed
rob@77 7874 // and return the corresponding response
rob@77 7875 if ( finalDataType ) {
rob@77 7876 if ( finalDataType !== dataTypes[ 0 ] ) {
rob@77 7877 dataTypes.unshift( finalDataType );
rob@77 7878 }
rob@77 7879 return responses[ finalDataType ];
rob@77 7880 }
rob@77 7881 }
rob@77 7882
rob@77 7883 // Chain conversions given the request and the original response
rob@77 7884 function ajaxConvert( s, response ) {
rob@77 7885
rob@77 7886 // Apply the dataFilter if provided
rob@77 7887 if ( s.dataFilter ) {
rob@77 7888 response = s.dataFilter( response, s.dataType );
rob@77 7889 }
rob@77 7890
rob@77 7891 var dataTypes = s.dataTypes,
rob@77 7892 converters = {},
rob@77 7893 i,
rob@77 7894 key,
rob@77 7895 length = dataTypes.length,
rob@77 7896 tmp,
rob@77 7897 // Current and previous dataTypes
rob@77 7898 current = dataTypes[ 0 ],
rob@77 7899 prev,
rob@77 7900 // Conversion expression
rob@77 7901 conversion,
rob@77 7902 // Conversion function
rob@77 7903 conv,
rob@77 7904 // Conversion functions (transitive conversion)
rob@77 7905 conv1,
rob@77 7906 conv2;
rob@77 7907
rob@77 7908 // For each dataType in the chain
rob@77 7909 for ( i = 1; i < length; i++ ) {
rob@77 7910
rob@77 7911 // Create converters map
rob@77 7912 // with lowercased keys
rob@77 7913 if ( i === 1 ) {
rob@77 7914 for ( key in s.converters ) {
rob@77 7915 if ( typeof key === "string" ) {
rob@77 7916 converters[ key.toLowerCase() ] = s.converters[ key ];
rob@77 7917 }
rob@77 7918 }
rob@77 7919 }
rob@77 7920
rob@77 7921 // Get the dataTypes
rob@77 7922 prev = current;
rob@77 7923 current = dataTypes[ i ];
rob@77 7924
rob@77 7925 // If current is auto dataType, update it to prev
rob@77 7926 if ( current === "*" ) {
rob@77 7927 current = prev;
rob@77 7928 // If no auto and dataTypes are actually different
rob@77 7929 } else if ( prev !== "*" && prev !== current ) {
rob@77 7930
rob@77 7931 // Get the converter
rob@77 7932 conversion = prev + " " + current;
rob@77 7933 conv = converters[ conversion ] || converters[ "* " + current ];
rob@77 7934
rob@77 7935 // If there is no direct converter, search transitively
rob@77 7936 if ( !conv ) {
rob@77 7937 conv2 = undefined;
rob@77 7938 for ( conv1 in converters ) {
rob@77 7939 tmp = conv1.split( " " );
rob@77 7940 if ( tmp[ 0 ] === prev || tmp[ 0 ] === "*" ) {
rob@77 7941 conv2 = converters[ tmp[1] + " " + current ];
rob@77 7942 if ( conv2 ) {
rob@77 7943 conv1 = converters[ conv1 ];
rob@77 7944 if ( conv1 === true ) {
rob@77 7945 conv = conv2;
rob@77 7946 } else if ( conv2 === true ) {
rob@77 7947 conv = conv1;
rob@77 7948 }
rob@77 7949 break;
rob@77 7950 }
rob@77 7951 }
rob@77 7952 }
rob@77 7953 }
rob@77 7954 // If we found no converter, dispatch an error
rob@77 7955 if ( !( conv || conv2 ) ) {
rob@77 7956 jQuery.error( "No conversion from " + conversion.replace(" "," to ") );
rob@77 7957 }
rob@77 7958 // If found converter is not an equivalence
rob@77 7959 if ( conv !== true ) {
rob@77 7960 // Convert with 1 or 2 converters accordingly
rob@77 7961 response = conv ? conv( response ) : conv2( conv1(response) );
rob@77 7962 }
rob@77 7963 }
rob@77 7964 }
rob@77 7965 return response;
rob@77 7966 }
rob@77 7967
rob@77 7968
rob@77 7969
rob@77 7970
rob@77 7971 var jsc = jQuery.now(),
rob@77 7972 jsre = /(\=)\?(&|$)|\?\?/i;
rob@77 7973
rob@77 7974 // Default jsonp settings
rob@77 7975 jQuery.ajaxSetup({
rob@77 7976 jsonp: "callback",
rob@77 7977 jsonpCallback: function() {
rob@77 7978 return jQuery.expando + "_" + ( jsc++ );
rob@77 7979 }
rob@77 7980 });
rob@77 7981
rob@77 7982 // Detect, normalize options and install callbacks for jsonp requests
rob@77 7983 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
rob@77 7984
rob@77 7985 var inspectData = ( typeof s.data === "string" ) && /^application\/x\-www\-form\-urlencoded/.test( s.contentType );
rob@77 7986
rob@77 7987 if ( s.dataTypes[ 0 ] === "jsonp" ||
rob@77 7988 s.jsonp !== false && ( jsre.test( s.url ) ||
rob@77 7989 inspectData && jsre.test( s.data ) ) ) {
rob@77 7990
rob@77 7991 var responseContainer,
rob@77 7992 jsonpCallback = s.jsonpCallback =
rob@77 7993 jQuery.isFunction( s.jsonpCallback ) ? s.jsonpCallback() : s.jsonpCallback,
rob@77 7994 previous = window[ jsonpCallback ],
rob@77 7995 url = s.url,
rob@77 7996 data = s.data,
rob@77 7997 replace = "$1" + jsonpCallback + "$2";
rob@77 7998
rob@77 7999 if ( s.jsonp !== false ) {
rob@77 8000 url = url.replace( jsre, replace );
rob@77 8001 if ( s.url === url ) {
rob@77 8002 if ( inspectData ) {
rob@77 8003 data = data.replace( jsre, replace );
rob@77 8004 }
rob@77 8005 if ( s.data === data ) {
rob@77 8006 // Add callback manually
rob@77 8007 url += (/\?/.test( url ) ? "&" : "?") + s.jsonp + "=" + jsonpCallback;
rob@77 8008 }
rob@77 8009 }
rob@77 8010 }
rob@77 8011
rob@77 8012 s.url = url;
rob@77 8013 s.data = data;
rob@77 8014
rob@77 8015 // Install callback
rob@77 8016 window[ jsonpCallback ] = function( response ) {
rob@77 8017 responseContainer = [ response ];
rob@77 8018 };
rob@77 8019
rob@77 8020 // Clean-up function
rob@77 8021 jqXHR.always(function() {
rob@77 8022 // Set callback back to previous value
rob@77 8023 window[ jsonpCallback ] = previous;
rob@77 8024 // Call if it was a function and we have a response
rob@77 8025 if ( responseContainer && jQuery.isFunction( previous ) ) {
rob@77 8026 window[ jsonpCallback ]( responseContainer[ 0 ] );
rob@77 8027 }
rob@77 8028 });
rob@77 8029
rob@77 8030 // Use data converter to retrieve json after script execution
rob@77 8031 s.converters["script json"] = function() {
rob@77 8032 if ( !responseContainer ) {
rob@77 8033 jQuery.error( jsonpCallback + " was not called" );
rob@77 8034 }
rob@77 8035 return responseContainer[ 0 ];
rob@77 8036 };
rob@77 8037
rob@77 8038 // force json dataType
rob@77 8039 s.dataTypes[ 0 ] = "json";
rob@77 8040
rob@77 8041 // Delegate to script
rob@77 8042 return "script";
rob@77 8043 }
rob@77 8044 });
rob@77 8045
rob@77 8046
rob@77 8047
rob@77 8048
rob@77 8049 // Install script dataType
rob@77 8050 jQuery.ajaxSetup({
rob@77 8051 accepts: {
rob@77 8052 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
rob@77 8053 },
rob@77 8054 contents: {
rob@77 8055 script: /javascript|ecmascript/
rob@77 8056 },
rob@77 8057 converters: {
rob@77 8058 "text script": function( text ) {
rob@77 8059 jQuery.globalEval( text );
rob@77 8060 return text;
rob@77 8061 }
rob@77 8062 }
rob@77 8063 });
rob@77 8064
rob@77 8065 // Handle cache's special case and global
rob@77 8066 jQuery.ajaxPrefilter( "script", function( s ) {
rob@77 8067 if ( s.cache === undefined ) {
rob@77 8068 s.cache = false;
rob@77 8069 }
rob@77 8070 if ( s.crossDomain ) {
rob@77 8071 s.type = "GET";
rob@77 8072 s.global = false;
rob@77 8073 }
rob@77 8074 });
rob@77 8075
rob@77 8076 // Bind script tag hack transport
rob@77 8077 jQuery.ajaxTransport( "script", function(s) {
rob@77 8078
rob@77 8079 // This transport only deals with cross domain requests
rob@77 8080 if ( s.crossDomain ) {
rob@77 8081
rob@77 8082 var script,
rob@77 8083 head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement;
rob@77 8084
rob@77 8085 return {
rob@77 8086
rob@77 8087 send: function( _, callback ) {
rob@77 8088
rob@77 8089 script = document.createElement( "script" );
rob@77 8090
rob@77 8091 script.async = "async";
rob@77 8092
rob@77 8093 if ( s.scriptCharset ) {
rob@77 8094 script.charset = s.scriptCharset;
rob@77 8095 }
rob@77 8096
rob@77 8097 script.src = s.url;
rob@77 8098
rob@77 8099 // Attach handlers for all browsers
rob@77 8100 script.onload = script.onreadystatechange = function( _, isAbort ) {
rob@77 8101
rob@77 8102 if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
rob@77 8103
rob@77 8104 // Handle memory leak in IE
rob@77 8105 script.onload = script.onreadystatechange = null;
rob@77 8106
rob@77 8107 // Remove the script
rob@77 8108 if ( head && script.parentNode ) {
rob@77 8109 head.removeChild( script );
rob@77 8110 }
rob@77 8111
rob@77 8112 // Dereference the script
rob@77 8113 script = undefined;
rob@77 8114
rob@77 8115 // Callback if not abort
rob@77 8116 if ( !isAbort ) {
rob@77 8117 callback( 200, "success" );
rob@77 8118 }
rob@77 8119 }
rob@77 8120 };
rob@77 8121 // Use insertBefore instead of appendChild to circumvent an IE6 bug.
rob@77 8122 // This arises when a base node is used (#2709 and #4378).
rob@77 8123 head.insertBefore( script, head.firstChild );
rob@77 8124 },
rob@77 8125
rob@77 8126 abort: function() {
rob@77 8127 if ( script ) {
rob@77 8128 script.onload( 0, 1 );
rob@77 8129 }
rob@77 8130 }
rob@77 8131 };
rob@77 8132 }
rob@77 8133 });
rob@77 8134
rob@77 8135
rob@77 8136
rob@77 8137
rob@77 8138 var // #5280: Internet Explorer will keep connections alive if we don't abort on unload
rob@77 8139 xhrOnUnloadAbort = window.ActiveXObject ? function() {
rob@77 8140 // Abort all pending requests
rob@77 8141 for ( var key in xhrCallbacks ) {
rob@77 8142 xhrCallbacks[ key ]( 0, 1 );
rob@77 8143 }
rob@77 8144 } : false,
rob@77 8145 xhrId = 0,
rob@77 8146 xhrCallbacks;
rob@77 8147
rob@77 8148 // Functions to create xhrs
rob@77 8149 function createStandardXHR() {
rob@77 8150 try {
rob@77 8151 return new window.XMLHttpRequest();
rob@77 8152 } catch( e ) {}
rob@77 8153 }
rob@77 8154
rob@77 8155 function createActiveXHR() {
rob@77 8156 try {
rob@77 8157 return new window.ActiveXObject( "Microsoft.XMLHTTP" );
rob@77 8158 } catch( e ) {}
rob@77 8159 }
rob@77 8160
rob@77 8161 // Create the request object
rob@77 8162 // (This is still attached to ajaxSettings for backward compatibility)
rob@77 8163 jQuery.ajaxSettings.xhr = window.ActiveXObject ?
rob@77 8164 /* Microsoft failed to properly
rob@77 8165 * implement the XMLHttpRequest in IE7 (can't request local files),
rob@77 8166 * so we use the ActiveXObject when it is available
rob@77 8167 * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
rob@77 8168 * we need a fallback.
rob@77 8169 */
rob@77 8170 function() {
rob@77 8171 return !this.isLocal && createStandardXHR() || createActiveXHR();
rob@77 8172 } :
rob@77 8173 // For all other browsers, use the standard XMLHttpRequest object
rob@77 8174 createStandardXHR;
rob@77 8175
rob@77 8176 // Determine support properties
rob@77 8177 (function( xhr ) {
rob@77 8178 jQuery.extend( jQuery.support, {
rob@77 8179 ajax: !!xhr,
rob@77 8180 cors: !!xhr && ( "withCredentials" in xhr )
rob@77 8181 });
rob@77 8182 })( jQuery.ajaxSettings.xhr() );
rob@77 8183
rob@77 8184 // Create transport if the browser can provide an xhr
rob@77 8185 if ( jQuery.support.ajax ) {
rob@77 8186
rob@77 8187 jQuery.ajaxTransport(function( s ) {
rob@77 8188 // Cross domain only allowed if supported through XMLHttpRequest
rob@77 8189 if ( !s.crossDomain || jQuery.support.cors ) {
rob@77 8190
rob@77 8191 var callback;
rob@77 8192
rob@77 8193 return {
rob@77 8194 send: function( headers, complete ) {
rob@77 8195
rob@77 8196 // Get a new xhr
rob@77 8197 var xhr = s.xhr(),
rob@77 8198 handle,
rob@77 8199 i;
rob@77 8200
rob@77 8201 // Open the socket
rob@77 8202 // Passing null username, generates a login popup on Opera (#2865)
rob@77 8203 if ( s.username ) {
rob@77 8204 xhr.open( s.type, s.url, s.async, s.username, s.password );
rob@77 8205 } else {
rob@77 8206 xhr.open( s.type, s.url, s.async );
rob@77 8207 }
rob@77 8208
rob@77 8209 // Apply custom fields if provided
rob@77 8210 if ( s.xhrFields ) {
rob@77 8211 for ( i in s.xhrFields ) {
rob@77 8212 xhr[ i ] = s.xhrFields[ i ];
rob@77 8213 }
rob@77 8214 }
rob@77 8215
rob@77 8216 // Override mime type if needed
rob@77 8217 if ( s.mimeType && xhr.overrideMimeType ) {
rob@77 8218 xhr.overrideMimeType( s.mimeType );
rob@77 8219 }
rob@77 8220
rob@77 8221 // X-Requested-With header
rob@77 8222 // For cross-domain requests, seeing as conditions for a preflight are
rob@77 8223 // akin to a jigsaw puzzle, we simply never set it to be sure.
rob@77 8224 // (it can always be set on a per-request basis or even using ajaxSetup)
rob@77 8225 // For same-domain requests, won't change header if already provided.
rob@77 8226 if ( !s.crossDomain && !headers["X-Requested-With"] ) {
rob@77 8227 headers[ "X-Requested-With" ] = "XMLHttpRequest";
rob@77 8228 }
rob@77 8229
rob@77 8230 // Need an extra try/catch for cross domain requests in Firefox 3
rob@77 8231 try {
rob@77 8232 for ( i in headers ) {
rob@77 8233 xhr.setRequestHeader( i, headers[ i ] );
rob@77 8234 }
rob@77 8235 } catch( _ ) {}
rob@77 8236
rob@77 8237 // Do send the request
rob@77 8238 // This may raise an exception which is actually
rob@77 8239 // handled in jQuery.ajax (so no try/catch here)
rob@77 8240 xhr.send( ( s.hasContent && s.data ) || null );
rob@77 8241
rob@77 8242 // Listener
rob@77 8243 callback = function( _, isAbort ) {
rob@77 8244
rob@77 8245 var status,
rob@77 8246 statusText,
rob@77 8247 responseHeaders,
rob@77 8248 responses,
rob@77 8249 xml;
rob@77 8250
rob@77 8251 // Firefox throws exceptions when accessing properties
rob@77 8252 // of an xhr when a network error occured
rob@77 8253 // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
rob@77 8254 try {
rob@77 8255
rob@77 8256 // Was never called and is aborted or complete
rob@77 8257 if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
rob@77 8258
rob@77 8259 // Only called once
rob@77 8260 callback = undefined;
rob@77 8261
rob@77 8262 // Do not keep as active anymore
rob@77 8263 if ( handle ) {
rob@77 8264 xhr.onreadystatechange = jQuery.noop;
rob@77 8265 if ( xhrOnUnloadAbort ) {
rob@77 8266 delete xhrCallbacks[ handle ];
rob@77 8267 }
rob@77 8268 }
rob@77 8269
rob@77 8270 // If it's an abort
rob@77 8271 if ( isAbort ) {
rob@77 8272 // Abort it manually if needed
rob@77 8273 if ( xhr.readyState !== 4 ) {
rob@77 8274 xhr.abort();
rob@77 8275 }
rob@77 8276 } else {
rob@77 8277 status = xhr.status;
rob@77 8278 responseHeaders = xhr.getAllResponseHeaders();
rob@77 8279 responses = {};
rob@77 8280 xml = xhr.responseXML;
rob@77 8281
rob@77 8282 // Construct response list
rob@77 8283 if ( xml && xml.documentElement /* #4958 */ ) {
rob@77 8284 responses.xml = xml;
rob@77 8285 }
rob@77 8286
rob@77 8287 // When requesting binary data, IE6-9 will throw an exception
rob@77 8288 // on any attempt to access responseText (#11426)
rob@77 8289 try {
rob@77 8290 responses.text = xhr.responseText;
rob@77 8291 } catch( _ ) {
rob@77 8292 }
rob@77 8293
rob@77 8294 // Firefox throws an exception when accessing
rob@77 8295 // statusText for faulty cross-domain requests
rob@77 8296 try {
rob@77 8297 statusText = xhr.statusText;
rob@77 8298 } catch( e ) {
rob@77 8299 // We normalize with Webkit giving an empty statusText
rob@77 8300 statusText = "";
rob@77 8301 }
rob@77 8302
rob@77 8303 // Filter status for non standard behaviors
rob@77 8304
rob@77 8305 // If the request is local and we have data: assume a success
rob@77 8306 // (success with no data won't get notified, that's the best we
rob@77 8307 // can do given current implementations)
rob@77 8308 if ( !status && s.isLocal && !s.crossDomain ) {
rob@77 8309 status = responses.text ? 200 : 404;
rob@77 8310 // IE - #1450: sometimes returns 1223 when it should be 204
rob@77 8311 } else if ( status === 1223 ) {
rob@77 8312 status = 204;
rob@77 8313 }
rob@77 8314 }
rob@77 8315 }
rob@77 8316 } catch( firefoxAccessException ) {
rob@77 8317 if ( !isAbort ) {
rob@77 8318 complete( -1, firefoxAccessException );
rob@77 8319 }
rob@77 8320 }
rob@77 8321
rob@77 8322 // Call complete if needed
rob@77 8323 if ( responses ) {
rob@77 8324 complete( status, statusText, responses, responseHeaders );
rob@77 8325 }
rob@77 8326 };
rob@77 8327
rob@77 8328 // if we're in sync mode or it's in cache
rob@77 8329 // and has been retrieved directly (IE6 & IE7)
rob@77 8330 // we need to manually fire the callback
rob@77 8331 if ( !s.async || xhr.readyState === 4 ) {
rob@77 8332 callback();
rob@77 8333 } else {
rob@77 8334 handle = ++xhrId;
rob@77 8335 if ( xhrOnUnloadAbort ) {
rob@77 8336 // Create the active xhrs callbacks list if needed
rob@77 8337 // and attach the unload handler
rob@77 8338 if ( !xhrCallbacks ) {
rob@77 8339 xhrCallbacks = {};
rob@77 8340 jQuery( window ).unload( xhrOnUnloadAbort );
rob@77 8341 }
rob@77 8342 // Add to list of active xhrs callbacks
rob@77 8343 xhrCallbacks[ handle ] = callback;
rob@77 8344 }
rob@77 8345 xhr.onreadystatechange = callback;
rob@77 8346 }
rob@77 8347 },
rob@77 8348
rob@77 8349 abort: function() {
rob@77 8350 if ( callback ) {
rob@77 8351 callback(0,1);
rob@77 8352 }
rob@77 8353 }
rob@77 8354 };
rob@77 8355 }
rob@77 8356 });
rob@77 8357 }
rob@77 8358
rob@77 8359
rob@77 8360
rob@77 8361
rob@77 8362 var elemdisplay = {},
rob@77 8363 iframe, iframeDoc,
rob@77 8364 rfxtypes = /^(?:toggle|show|hide)$/,
rob@77 8365 rfxnum = /^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,
rob@77 8366 timerId,
rob@77 8367 fxAttrs = [
rob@77 8368 // height animations
rob@77 8369 [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
rob@77 8370 // width animations
rob@77 8371 [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
rob@77 8372 // opacity animations
rob@77 8373 [ "opacity" ]
rob@77 8374 ],
rob@77 8375 fxNow;
rob@77 8376
rob@77 8377 jQuery.fn.extend({
rob@77 8378 show: function( speed, easing, callback ) {
rob@77 8379 var elem, display;
rob@77 8380
rob@77 8381 if ( speed || speed === 0 ) {
rob@77 8382 return this.animate( genFx("show", 3), speed, easing, callback );
rob@77 8383
rob@77 8384 } else {
rob@77 8385 for ( var i = 0, j = this.length; i < j; i++ ) {
rob@77 8386 elem = this[ i ];
rob@77 8387
rob@77 8388 if ( elem.style ) {
rob@77 8389 display = elem.style.display;
rob@77 8390
rob@77 8391 // Reset the inline display of this element to learn if it is
rob@77 8392 // being hidden by cascaded rules or not
rob@77 8393 if ( !jQuery._data(elem, "olddisplay") && display === "none" ) {
rob@77 8394 display = elem.style.display = "";
rob@77 8395 }
rob@77 8396
rob@77 8397 // Set elements which have been overridden with display: none
rob@77 8398 // in a stylesheet to whatever the default browser style is
rob@77 8399 // for such an element
rob@77 8400 if ( (display === "" && jQuery.css(elem, "display") === "none") ||
rob@77 8401 !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) {
rob@77 8402 jQuery._data( elem, "olddisplay", defaultDisplay(elem.nodeName) );
rob@77 8403 }
rob@77 8404 }
rob@77 8405 }
rob@77 8406
rob@77 8407 // Set the display of most of the elements in a second loop
rob@77 8408 // to avoid the constant reflow
rob@77 8409 for ( i = 0; i < j; i++ ) {
rob@77 8410 elem = this[ i ];
rob@77 8411
rob@77 8412 if ( elem.style ) {
rob@77 8413 display = elem.style.display;
rob@77 8414
rob@77 8415 if ( display === "" || display === "none" ) {
rob@77 8416 elem.style.display = jQuery._data( elem, "olddisplay" ) || "";
rob@77 8417 }
rob@77 8418 }
rob@77 8419 }
rob@77 8420
rob@77 8421 return this;
rob@77 8422 }
rob@77 8423 },
rob@77 8424
rob@77 8425 hide: function( speed, easing, callback ) {
rob@77 8426 if ( speed || speed === 0 ) {
rob@77 8427 return this.animate( genFx("hide", 3), speed, easing, callback);
rob@77 8428
rob@77 8429 } else {
rob@77 8430 var elem, display,
rob@77 8431 i = 0,
rob@77 8432 j = this.length;
rob@77 8433
rob@77 8434 for ( ; i < j; i++ ) {
rob@77 8435 elem = this[i];
rob@77 8436 if ( elem.style ) {
rob@77 8437 display = jQuery.css( elem, "display" );
rob@77 8438
rob@77 8439 if ( display !== "none" && !jQuery._data( elem, "olddisplay" ) ) {
rob@77 8440 jQuery._data( elem, "olddisplay", display );
rob@77 8441 }
rob@77 8442 }
rob@77 8443 }
rob@77 8444
rob@77 8445 // Set the display of the elements in a second loop
rob@77 8446 // to avoid the constant reflow
rob@77 8447 for ( i = 0; i < j; i++ ) {
rob@77 8448 if ( this[i].style ) {
rob@77 8449 this[i].style.display = "none";
rob@77 8450 }
rob@77 8451 }
rob@77 8452
rob@77 8453 return this;
rob@77 8454 }
rob@77 8455 },
rob@77 8456
rob@77 8457 // Save the old toggle function
rob@77 8458 _toggle: jQuery.fn.toggle,
rob@77 8459
rob@77 8460 toggle: function( fn, fn2, callback ) {
rob@77 8461 var bool = typeof fn === "boolean";
rob@77 8462
rob@77 8463 if ( jQuery.isFunction(fn) && jQuery.isFunction(fn2) ) {
rob@77 8464 this._toggle.apply( this, arguments );
rob@77 8465
rob@77 8466 } else if ( fn == null || bool ) {
rob@77 8467 this.each(function() {
rob@77 8468 var state = bool ? fn : jQuery(this).is(":hidden");
rob@77 8469 jQuery(this)[ state ? "show" : "hide" ]();
rob@77 8470 });
rob@77 8471
rob@77 8472 } else {
rob@77 8473 this.animate(genFx("toggle", 3), fn, fn2, callback);
rob@77 8474 }
rob@77 8475
rob@77 8476 return this;
rob@77 8477 },
rob@77 8478
rob@77 8479 fadeTo: function( speed, to, easing, callback ) {
rob@77 8480 return this.filter(":hidden").css("opacity", 0).show().end()
rob@77 8481 .animate({opacity: to}, speed, easing, callback);
rob@77 8482 },
rob@77 8483
rob@77 8484 animate: function( prop, speed, easing, callback ) {
rob@77 8485 var optall = jQuery.speed( speed, easing, callback );
rob@77 8486
rob@77 8487 if ( jQuery.isEmptyObject( prop ) ) {
rob@77 8488 return this.each( optall.complete, [ false ] );
rob@77 8489 }
rob@77 8490
rob@77 8491 // Do not change referenced properties as per-property easing will be lost
rob@77 8492 prop = jQuery.extend( {}, prop );
rob@77 8493
rob@77 8494 function doAnimation() {
rob@77 8495 // XXX 'this' does not always have a nodeName when running the
rob@77 8496 // test suite
rob@77 8497
rob@77 8498 if ( optall.queue === false ) {
rob@77 8499 jQuery._mark( this );
rob@77 8500 }
rob@77 8501
rob@77 8502 var opt = jQuery.extend( {}, optall ),
rob@77 8503 isElement = this.nodeType === 1,
rob@77 8504 hidden = isElement && jQuery(this).is(":hidden"),
rob@77 8505 name, val, p, e, hooks, replace,
rob@77 8506 parts, start, end, unit,
rob@77 8507 method;
rob@77 8508
rob@77 8509 // will store per property easing and be used to determine when an animation is complete
rob@77 8510 opt.animatedProperties = {};
rob@77 8511
rob@77 8512 // first pass over propertys to expand / normalize
rob@77 8513 for ( p in prop ) {
rob@77 8514 name = jQuery.camelCase( p );
rob@77 8515 if ( p !== name ) {
rob@77 8516 prop[ name ] = prop[ p ];
rob@77 8517 delete prop[ p ];
rob@77 8518 }
rob@77 8519
rob@77 8520 if ( ( hooks = jQuery.cssHooks[ name ] ) && "expand" in hooks ) {
rob@77 8521 replace = hooks.expand( prop[ name ] );
rob@77 8522 delete prop[ name ];
rob@77 8523
rob@77 8524 // not quite $.extend, this wont overwrite keys already present.
rob@77 8525 // also - reusing 'p' from above because we have the correct "name"
rob@77 8526 for ( p in replace ) {
rob@77 8527 if ( ! ( p in prop ) ) {
rob@77 8528 prop[ p ] = replace[ p ];
rob@77 8529 }
rob@77 8530 }
rob@77 8531 }
rob@77 8532 }
rob@77 8533
rob@77 8534 for ( name in prop ) {
rob@77 8535 val = prop[ name ];
rob@77 8536 // easing resolution: per property > opt.specialEasing > opt.easing > 'swing' (default)
rob@77 8537 if ( jQuery.isArray( val ) ) {
rob@77 8538 opt.animatedProperties[ name ] = val[ 1 ];
rob@77 8539 val = prop[ name ] = val[ 0 ];
rob@77 8540 } else {
rob@77 8541 opt.animatedProperties[ name ] = opt.specialEasing && opt.specialEasing[ name ] || opt.easing || 'swing';
rob@77 8542 }
rob@77 8543
rob@77 8544 if ( val === "hide" && hidden || val === "show" && !hidden ) {
rob@77 8545 return opt.complete.call( this );
rob@77 8546 }
rob@77 8547
rob@77 8548 if ( isElement && ( name === "height" || name === "width" ) ) {
rob@77 8549 // Make sure that nothing sneaks out
rob@77 8550 // Record all 3 overflow attributes because IE does not
rob@77 8551 // change the overflow attribute when overflowX and
rob@77 8552 // overflowY are set to the same value
rob@77 8553 opt.overflow = [ this.style.overflow, this.style.overflowX, this.style.overflowY ];
rob@77 8554
rob@77 8555 // Set display property to inline-block for height/width
rob@77 8556 // animations on inline elements that are having width/height animated
rob@77 8557 if ( jQuery.css( this, "display" ) === "inline" &&
rob@77 8558 jQuery.css( this, "float" ) === "none" ) {
rob@77 8559
rob@77 8560 // inline-level elements accept inline-block;
rob@77 8561 // block-level elements need to be inline with layout
rob@77 8562 if ( !jQuery.support.inlineBlockNeedsLayout || defaultDisplay( this.nodeName ) === "inline" ) {
rob@77 8563 this.style.display = "inline-block";
rob@77 8564
rob@77 8565 } else {
rob@77 8566 this.style.zoom = 1;
rob@77 8567 }
rob@77 8568 }
rob@77 8569 }
rob@77 8570 }
rob@77 8571
rob@77 8572 if ( opt.overflow != null ) {
rob@77 8573 this.style.overflow = "hidden";
rob@77 8574 }
rob@77 8575
rob@77 8576 for ( p in prop ) {
rob@77 8577 e = new jQuery.fx( this, opt, p );
rob@77 8578 val = prop[ p ];
rob@77 8579
rob@77 8580 if ( rfxtypes.test( val ) ) {
rob@77 8581
rob@77 8582 // Tracks whether to show or hide based on private
rob@77 8583 // data attached to the element
rob@77 8584 method = jQuery._data( this, "toggle" + p ) || ( val === "toggle" ? hidden ? "show" : "hide" : 0 );
rob@77 8585 if ( method ) {
rob@77 8586 jQuery._data( this, "toggle" + p, method === "show" ? "hide" : "show" );
rob@77 8587 e[ method ]();
rob@77 8588 } else {
rob@77 8589 e[ val ]();
rob@77 8590 }
rob@77 8591
rob@77 8592 } else {
rob@77 8593 parts = rfxnum.exec( val );
rob@77 8594 start = e.cur();
rob@77 8595
rob@77 8596 if ( parts ) {
rob@77 8597 end = parseFloat( parts[2] );
rob@77 8598 unit = parts[3] || ( jQuery.cssNumber[ p ] ? "" : "px" );
rob@77 8599
rob@77 8600 // We need to compute starting value
rob@77 8601 if ( unit !== "px" ) {
rob@77 8602 jQuery.style( this, p, (end || 1) + unit);
rob@77 8603 start = ( (end || 1) / e.cur() ) * start;
rob@77 8604 jQuery.style( this, p, start + unit);
rob@77 8605 }
rob@77 8606
rob@77 8607 // If a +=/-= token was provided, we're doing a relative animation
rob@77 8608 if ( parts[1] ) {
rob@77 8609 end = ( (parts[ 1 ] === "-=" ? -1 : 1) * end ) + start;
rob@77 8610 }
rob@77 8611
rob@77 8612 e.custom( start, end, unit );
rob@77 8613
rob@77 8614 } else {
rob@77 8615 e.custom( start, val, "" );
rob@77 8616 }
rob@77 8617 }
rob@77 8618 }
rob@77 8619
rob@77 8620 // For JS strict compliance
rob@77 8621 return true;
rob@77 8622 }
rob@77 8623
rob@77 8624 return optall.queue === false ?
rob@77 8625 this.each( doAnimation ) :
rob@77 8626 this.queue( optall.queue, doAnimation );
rob@77 8627 },
rob@77 8628
rob@77 8629 stop: function( type, clearQueue, gotoEnd ) {
rob@77 8630 if ( typeof type !== "string" ) {
rob@77 8631 gotoEnd = clearQueue;
rob@77 8632 clearQueue = type;
rob@77 8633 type = undefined;
rob@77 8634 }
rob@77 8635 if ( clearQueue && type !== false ) {
rob@77 8636 this.queue( type || "fx", [] );
rob@77 8637 }
rob@77 8638
rob@77 8639 return this.each(function() {
rob@77 8640 var index,
rob@77 8641 hadTimers = false,
rob@77 8642 timers = jQuery.timers,
rob@77 8643 data = jQuery._data( this );
rob@77 8644
rob@77 8645 // clear marker counters if we know they won't be
rob@77 8646 if ( !gotoEnd ) {
rob@77 8647 jQuery._unmark( true, this );
rob@77 8648 }
rob@77 8649
rob@77 8650 function stopQueue( elem, data, index ) {
rob@77 8651 var hooks = data[ index ];
rob@77 8652 jQuery.removeData( elem, index, true );
rob@77 8653 hooks.stop( gotoEnd );
rob@77 8654 }
rob@77 8655
rob@77 8656 if ( type == null ) {
rob@77 8657 for ( index in data ) {
rob@77 8658 if ( data[ index ] && data[ index ].stop && index.indexOf(".run") === index.length - 4 ) {
rob@77 8659 stopQueue( this, data, index );
rob@77 8660 }
rob@77 8661 }
rob@77 8662 } else if ( data[ index = type + ".run" ] && data[ index ].stop ){
rob@77 8663 stopQueue( this, data, index );
rob@77 8664 }
rob@77 8665
rob@77 8666 for ( index = timers.length; index--; ) {
rob@77 8667 if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
rob@77 8668 if ( gotoEnd ) {
rob@77 8669
rob@77 8670 // force the next step to be the last
rob@77 8671 timers[ index ]( true );
rob@77 8672 } else {
rob@77 8673 timers[ index ].saveState();
rob@77 8674 }
rob@77 8675 hadTimers = true;
rob@77 8676 timers.splice( index, 1 );
rob@77 8677 }
rob@77 8678 }
rob@77 8679
rob@77 8680 // start the next in the queue if the last step wasn't forced
rob@77 8681 // timers currently will call their complete callbacks, which will dequeue
rob@77 8682 // but only if they were gotoEnd
rob@77 8683 if ( !( gotoEnd && hadTimers ) ) {
rob@77 8684 jQuery.dequeue( this, type );
rob@77 8685 }
rob@77 8686 });
rob@77 8687 }
rob@77 8688
rob@77 8689 });
rob@77 8690
rob@77 8691 // Animations created synchronously will run synchronously
rob@77 8692 function createFxNow() {
rob@77 8693 setTimeout( clearFxNow, 0 );
rob@77 8694 return ( fxNow = jQuery.now() );
rob@77 8695 }
rob@77 8696
rob@77 8697 function clearFxNow() {
rob@77 8698 fxNow = undefined;
rob@77 8699 }
rob@77 8700
rob@77 8701 // Generate parameters to create a standard animation
rob@77 8702 function genFx( type, num ) {
rob@77 8703 var obj = {};
rob@77 8704
rob@77 8705 jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice( 0, num )), function() {
rob@77 8706 obj[ this ] = type;
rob@77 8707 });
rob@77 8708
rob@77 8709 return obj;
rob@77 8710 }
rob@77 8711
rob@77 8712 // Generate shortcuts for custom animations
rob@77 8713 jQuery.each({
rob@77 8714 slideDown: genFx( "show", 1 ),
rob@77 8715 slideUp: genFx( "hide", 1 ),
rob@77 8716 slideToggle: genFx( "toggle", 1 ),
rob@77 8717 fadeIn: { opacity: "show" },
rob@77 8718 fadeOut: { opacity: "hide" },
rob@77 8719 fadeToggle: { opacity: "toggle" }
rob@77 8720 }, function( name, props ) {
rob@77 8721 jQuery.fn[ name ] = function( speed, easing, callback ) {
rob@77 8722 return this.animate( props, speed, easing, callback );
rob@77 8723 };
rob@77 8724 });
rob@77 8725
rob@77 8726 jQuery.extend({
rob@77 8727 speed: function( speed, easing, fn ) {
rob@77 8728 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
rob@77 8729 complete: fn || !fn && easing ||
rob@77 8730 jQuery.isFunction( speed ) && speed,
rob@77 8731 duration: speed,
rob@77 8732 easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
rob@77 8733 };
rob@77 8734
rob@77 8735 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
rob@77 8736 opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
rob@77 8737
rob@77 8738 // normalize opt.queue - true/undefined/null -> "fx"
rob@77 8739 if ( opt.queue == null || opt.queue === true ) {
rob@77 8740 opt.queue = "fx";
rob@77 8741 }
rob@77 8742
rob@77 8743 // Queueing
rob@77 8744 opt.old = opt.complete;
rob@77 8745
rob@77 8746 opt.complete = function( noUnmark ) {
rob@77 8747 if ( jQuery.isFunction( opt.old ) ) {
rob@77 8748 opt.old.call( this );
rob@77 8749 }
rob@77 8750
rob@77 8751 if ( opt.queue ) {
rob@77 8752 jQuery.dequeue( this, opt.queue );
rob@77 8753 } else if ( noUnmark !== false ) {
rob@77 8754 jQuery._unmark( this );
rob@77 8755 }
rob@77 8756 };
rob@77 8757
rob@77 8758 return opt;
rob@77 8759 },
rob@77 8760
rob@77 8761 easing: {
rob@77 8762 linear: function( p ) {
rob@77 8763 return p;
rob@77 8764 },
rob@77 8765 swing: function( p ) {
rob@77 8766 return ( -Math.cos( p*Math.PI ) / 2 ) + 0.5;
rob@77 8767 }
rob@77 8768 },
rob@77 8769
rob@77 8770 timers: [],
rob@77 8771
rob@77 8772 fx: function( elem, options, prop ) {
rob@77 8773 this.options = options;
rob@77 8774 this.elem = elem;
rob@77 8775 this.prop = prop;
rob@77 8776
rob@77 8777 options.orig = options.orig || {};
rob@77 8778 }
rob@77 8779
rob@77 8780 });
rob@77 8781
rob@77 8782 jQuery.fx.prototype = {
rob@77 8783 // Simple function for setting a style value
rob@77 8784 update: function() {
rob@77 8785 if ( this.options.step ) {
rob@77 8786 this.options.step.call( this.elem, this.now, this );
rob@77 8787 }
rob@77 8788
rob@77 8789 ( jQuery.fx.step[ this.prop ] || jQuery.fx.step._default )( this );
rob@77 8790 },
rob@77 8791
rob@77 8792 // Get the current size
rob@77 8793 cur: function() {
rob@77 8794 if ( this.elem[ this.prop ] != null && (!this.elem.style || this.elem.style[ this.prop ] == null) ) {
rob@77 8795 return this.elem[ this.prop ];
rob@77 8796 }
rob@77 8797
rob@77 8798 var parsed,
rob@77 8799 r = jQuery.css( this.elem, this.prop );
rob@77 8800 // Empty strings, null, undefined and "auto" are converted to 0,
rob@77 8801 // complex values such as "rotate(1rad)" are returned as is,
rob@77 8802 // simple values such as "10px" are parsed to Float.
rob@77 8803 return isNaN( parsed = parseFloat( r ) ) ? !r || r === "auto" ? 0 : r : parsed;
rob@77 8804 },
rob@77 8805
rob@77 8806 // Start an animation from one number to another
rob@77 8807 custom: function( from, to, unit ) {
rob@77 8808 var self = this,
rob@77 8809 fx = jQuery.fx;
rob@77 8810
rob@77 8811 this.startTime = fxNow || createFxNow();
rob@77 8812 this.end = to;
rob@77 8813 this.now = this.start = from;
rob@77 8814 this.pos = this.state = 0;
rob@77 8815 this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" );
rob@77 8816
rob@77 8817 function t( gotoEnd ) {
rob@77 8818 return self.step( gotoEnd );
rob@77 8819 }
rob@77 8820
rob@77 8821 t.queue = this.options.queue;
rob@77 8822 t.elem = this.elem;
rob@77 8823 t.saveState = function() {
rob@77 8824 if ( jQuery._data( self.elem, "fxshow" + self.prop ) === undefined ) {
rob@77 8825 if ( self.options.hide ) {
rob@77 8826 jQuery._data( self.elem, "fxshow" + self.prop, self.start );
rob@77 8827 } else if ( self.options.show ) {
rob@77 8828 jQuery._data( self.elem, "fxshow" + self.prop, self.end );
rob@77 8829 }
rob@77 8830 }
rob@77 8831 };
rob@77 8832
rob@77 8833 if ( t() && jQuery.timers.push(t) && !timerId ) {
rob@77 8834 timerId = setInterval( fx.tick, fx.interval );
rob@77 8835 }
rob@77 8836 },
rob@77 8837
rob@77 8838 // Simple 'show' function
rob@77 8839 show: function() {
rob@77 8840 var dataShow = jQuery._data( this.elem, "fxshow" + this.prop );
rob@77 8841
rob@77 8842 // Remember where we started, so that we can go back to it later
rob@77 8843 this.options.orig[ this.prop ] = dataShow || jQuery.style( this.elem, this.prop );
rob@77 8844 this.options.show = true;
rob@77 8845
rob@77 8846 // Begin the animation
rob@77 8847 // Make sure that we start at a small width/height to avoid any flash of content
rob@77 8848 if ( dataShow !== undefined ) {
rob@77 8849 // This show is picking up where a previous hide or show left off
rob@77 8850 this.custom( this.cur(), dataShow );
rob@77 8851 } else {
rob@77 8852 this.custom( this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur() );
rob@77 8853 }
rob@77 8854
rob@77 8855 // Start by showing the element
rob@77 8856 jQuery( this.elem ).show();
rob@77 8857 },
rob@77 8858
rob@77 8859 // Simple 'hide' function
rob@77 8860 hide: function() {
rob@77 8861 // Remember where we started, so that we can go back to it later
rob@77 8862 this.options.orig[ this.prop ] = jQuery._data( this.elem, "fxshow" + this.prop ) || jQuery.style( this.elem, this.prop );
rob@77 8863 this.options.hide = true;
rob@77 8864
rob@77 8865 // Begin the animation
rob@77 8866 this.custom( this.cur(), 0 );
rob@77 8867 },
rob@77 8868
rob@77 8869 // Each step of an animation
rob@77 8870 step: function( gotoEnd ) {
rob@77 8871 var p, n, complete,
rob@77 8872 t = fxNow || createFxNow(),
rob@77 8873 done = true,
rob@77 8874 elem = this.elem,
rob@77 8875 options = this.options;
rob@77 8876
rob@77 8877 if ( gotoEnd || t >= options.duration + this.startTime ) {
rob@77 8878 this.now = this.end;
rob@77 8879 this.pos = this.state = 1;
rob@77 8880 this.update();
rob@77 8881
rob@77 8882 options.animatedProperties[ this.prop ] = true;
rob@77 8883
rob@77 8884 for ( p in options.animatedProperties ) {
rob@77 8885 if ( options.animatedProperties[ p ] !== true ) {
rob@77 8886 done = false;
rob@77 8887 }
rob@77 8888 }
rob@77 8889
rob@77 8890 if ( done ) {
rob@77 8891 // Reset the overflow
rob@77 8892 if ( options.overflow != null && !jQuery.support.shrinkWrapBlocks ) {
rob@77 8893
rob@77 8894 jQuery.each( [ "", "X", "Y" ], function( index, value ) {
rob@77 8895 elem.style[ "overflow" + value ] = options.overflow[ index ];
rob@77 8896 });
rob@77 8897 }
rob@77 8898
rob@77 8899 // Hide the element if the "hide" operation was done
rob@77 8900 if ( options.hide ) {
rob@77 8901 jQuery( elem ).hide();
rob@77 8902 }
rob@77 8903
rob@77 8904 // Reset the properties, if the item has been hidden or shown
rob@77 8905 if ( options.hide || options.show ) {
rob@77 8906 for ( p in options.animatedProperties ) {
rob@77 8907 jQuery.style( elem, p, options.orig[ p ] );
rob@77 8908 jQuery.removeData( elem, "fxshow" + p, true );
rob@77 8909 // Toggle data is no longer needed
rob@77 8910 jQuery.removeData( elem, "toggle" + p, true );
rob@77 8911 }
rob@77 8912 }
rob@77 8913
rob@77 8914 // Execute the complete function
rob@77 8915 // in the event that the complete function throws an exception
rob@77 8916 // we must ensure it won't be called twice. #5684
rob@77 8917
rob@77 8918 complete = options.complete;
rob@77 8919 if ( complete ) {
rob@77 8920
rob@77 8921 options.complete = false;
rob@77 8922 complete.call( elem );
rob@77 8923 }
rob@77 8924 }
rob@77 8925
rob@77 8926 return false;
rob@77 8927
rob@77 8928 } else {
rob@77 8929 // classical easing cannot be used with an Infinity duration
rob@77 8930 if ( options.duration == Infinity ) {
rob@77 8931 this.now = t;
rob@77 8932 } else {
rob@77 8933 n = t - this.startTime;
rob@77 8934 this.state = n / options.duration;
rob@77 8935
rob@77 8936 // Perform the easing function, defaults to swing
rob@77 8937 this.pos = jQuery.easing[ options.animatedProperties[this.prop] ]( this.state, n, 0, 1, options.duration );
rob@77 8938 this.now = this.start + ( (this.end - this.start) * this.pos );
rob@77 8939 }
rob@77 8940 // Perform the next step of the animation
rob@77 8941 this.update();
rob@77 8942 }
rob@77 8943
rob@77 8944 return true;
rob@77 8945 }
rob@77 8946 };
rob@77 8947
rob@77 8948 jQuery.extend( jQuery.fx, {
rob@77 8949 tick: function() {
rob@77 8950 var timer,
rob@77 8951 timers = jQuery.timers,
rob@77 8952 i = 0;
rob@77 8953
rob@77 8954 for ( ; i < timers.length; i++ ) {
rob@77 8955 timer = timers[ i ];
rob@77 8956 // Checks the timer has not already been removed
rob@77 8957 if ( !timer() && timers[ i ] === timer ) {
rob@77 8958 timers.splice( i--, 1 );
rob@77 8959 }
rob@77 8960 }
rob@77 8961
rob@77 8962 if ( !timers.length ) {
rob@77 8963 jQuery.fx.stop();
rob@77 8964 }
rob@77 8965 },
rob@77 8966
rob@77 8967 interval: 13,
rob@77 8968
rob@77 8969 stop: function() {
rob@77 8970 clearInterval( timerId );
rob@77 8971 timerId = null;
rob@77 8972 },
rob@77 8973
rob@77 8974 speeds: {
rob@77 8975 slow: 600,
rob@77 8976 fast: 200,
rob@77 8977 // Default speed
rob@77 8978 _default: 400
rob@77 8979 },
rob@77 8980
rob@77 8981 step: {
rob@77 8982 opacity: function( fx ) {
rob@77 8983 jQuery.style( fx.elem, "opacity", fx.now );
rob@77 8984 },
rob@77 8985
rob@77 8986 _default: function( fx ) {
rob@77 8987 if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {
rob@77 8988 fx.elem.style[ fx.prop ] = fx.now + fx.unit;
rob@77 8989 } else {
rob@77 8990 fx.elem[ fx.prop ] = fx.now;
rob@77 8991 }
rob@77 8992 }
rob@77 8993 }
rob@77 8994 });
rob@77 8995
rob@77 8996 // Ensure props that can't be negative don't go there on undershoot easing
rob@77 8997 jQuery.each( fxAttrs.concat.apply( [], fxAttrs ), function( i, prop ) {
rob@77 8998 // exclude marginTop, marginLeft, marginBottom and marginRight from this list
rob@77 8999 if ( prop.indexOf( "margin" ) ) {
rob@77 9000 jQuery.fx.step[ prop ] = function( fx ) {
rob@77 9001 jQuery.style( fx.elem, prop, Math.max(0, fx.now) + fx.unit );
rob@77 9002 };
rob@77 9003 }
rob@77 9004 });
rob@77 9005
rob@77 9006 if ( jQuery.expr && jQuery.expr.filters ) {
rob@77 9007 jQuery.expr.filters.animated = function( elem ) {
rob@77 9008 return jQuery.grep(jQuery.timers, function( fn ) {
rob@77 9009 return elem === fn.elem;
rob@77 9010 }).length;
rob@77 9011 };
rob@77 9012 }
rob@77 9013
rob@77 9014 // Try to restore the default display value of an element
rob@77 9015 function defaultDisplay( nodeName ) {
rob@77 9016
rob@77 9017 if ( !elemdisplay[ nodeName ] ) {
rob@77 9018
rob@77 9019 var body = document.body,
rob@77 9020 elem = jQuery( "<" + nodeName + ">" ).appendTo( body ),
rob@77 9021 display = elem.css( "display" );
rob@77 9022 elem.remove();
rob@77 9023
rob@77 9024 // If the simple way fails,
rob@77 9025 // get element's real default display by attaching it to a temp iframe
rob@77 9026 if ( display === "none" || display === "" ) {
rob@77 9027 // No iframe to use yet, so create it
rob@77 9028 if ( !iframe ) {
rob@77 9029 iframe = document.createElement( "iframe" );
rob@77 9030 iframe.frameBorder = iframe.width = iframe.height = 0;
rob@77 9031 }
rob@77 9032
rob@77 9033 body.appendChild( iframe );
rob@77 9034
rob@77 9035 // Create a cacheable copy of the iframe document on first call.
rob@77 9036 // IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML
rob@77 9037 // document to it; WebKit & Firefox won't allow reusing the iframe document.
rob@77 9038 if ( !iframeDoc || !iframe.createElement ) {
rob@77 9039 iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;
rob@77 9040 iframeDoc.write( ( jQuery.support.boxModel ? "<!doctype html>" : "" ) + "<html><body>" );
rob@77 9041 iframeDoc.close();
rob@77 9042 }
rob@77 9043
rob@77 9044 elem = iframeDoc.createElement( nodeName );
rob@77 9045
rob@77 9046 iframeDoc.body.appendChild( elem );
rob@77 9047
rob@77 9048 display = jQuery.css( elem, "display" );
rob@77 9049 body.removeChild( iframe );
rob@77 9050 }
rob@77 9051
rob@77 9052 // Store the correct default display
rob@77 9053 elemdisplay[ nodeName ] = display;
rob@77 9054 }
rob@77 9055
rob@77 9056 return elemdisplay[ nodeName ];
rob@77 9057 }
rob@77 9058
rob@77 9059
rob@77 9060
rob@77 9061
rob@77 9062 var getOffset,
rob@77 9063 rtable = /^t(?:able|d|h)$/i,
rob@77 9064 rroot = /^(?:body|html)$/i;
rob@77 9065
rob@77 9066 if ( "getBoundingClientRect" in document.documentElement ) {
rob@77 9067 getOffset = function( elem, doc, docElem, box ) {
rob@77 9068 try {
rob@77 9069 box = elem.getBoundingClientRect();
rob@77 9070 } catch(e) {}
rob@77 9071
rob@77 9072 // Make sure we're not dealing with a disconnected DOM node
rob@77 9073 if ( !box || !jQuery.contains( docElem, elem ) ) {
rob@77 9074 return box ? { top: box.top, left: box.left } : { top: 0, left: 0 };
rob@77 9075 }
rob@77 9076
rob@77 9077 var body = doc.body,
rob@77 9078 win = getWindow( doc ),
rob@77 9079 clientTop = docElem.clientTop || body.clientTop || 0,
rob@77 9080 clientLeft = docElem.clientLeft || body.clientLeft || 0,
rob@77 9081 scrollTop = win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop,
rob@77 9082 scrollLeft = win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft,
rob@77 9083 top = box.top + scrollTop - clientTop,
rob@77 9084 left = box.left + scrollLeft - clientLeft;
rob@77 9085
rob@77 9086 return { top: top, left: left };
rob@77 9087 };
rob@77 9088
rob@77 9089 } else {
rob@77 9090 getOffset = function( elem, doc, docElem ) {
rob@77 9091 var computedStyle,
rob@77 9092 offsetParent = elem.offsetParent,
rob@77 9093 prevOffsetParent = elem,
rob@77 9094 body = doc.body,
rob@77 9095 defaultView = doc.defaultView,
rob@77 9096 prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle,
rob@77 9097 top = elem.offsetTop,
rob@77 9098 left = elem.offsetLeft;
rob@77 9099
rob@77 9100 while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {
rob@77 9101 if ( jQuery.support.fixedPosition && prevComputedStyle.position === "fixed" ) {
rob@77 9102 break;
rob@77 9103 }
rob@77 9104
rob@77 9105 computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle;
rob@77 9106 top -= elem.scrollTop;
rob@77 9107 left -= elem.scrollLeft;
rob@77 9108
rob@77 9109 if ( elem === offsetParent ) {
rob@77 9110 top += elem.offsetTop;
rob@77 9111 left += elem.offsetLeft;
rob@77 9112
rob@77 9113 if ( jQuery.support.doesNotAddBorder && !(jQuery.support.doesAddBorderForTableAndCells && rtable.test(elem.nodeName)) ) {
rob@77 9114 top += parseFloat( computedStyle.borderTopWidth ) || 0;
rob@77 9115 left += parseFloat( computedStyle.borderLeftWidth ) || 0;
rob@77 9116 }
rob@77 9117
rob@77 9118 prevOffsetParent = offsetParent;
rob@77 9119 offsetParent = elem.offsetParent;
rob@77 9120 }
rob@77 9121
rob@77 9122 if ( jQuery.support.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) {
rob@77 9123 top += parseFloat( computedStyle.borderTopWidth ) || 0;
rob@77 9124 left += parseFloat( computedStyle.borderLeftWidth ) || 0;
rob@77 9125 }
rob@77 9126
rob@77 9127 prevComputedStyle = computedStyle;
rob@77 9128 }
rob@77 9129
rob@77 9130 if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) {
rob@77 9131 top += body.offsetTop;
rob@77 9132 left += body.offsetLeft;
rob@77 9133 }
rob@77 9134
rob@77 9135 if ( jQuery.support.fixedPosition && prevComputedStyle.position === "fixed" ) {
rob@77 9136 top += Math.max( docElem.scrollTop, body.scrollTop );
rob@77 9137 left += Math.max( docElem.scrollLeft, body.scrollLeft );
rob@77 9138 }
rob@77 9139
rob@77 9140 return { top: top, left: left };
rob@77 9141 };
rob@77 9142 }
rob@77 9143
rob@77 9144 jQuery.fn.offset = function( options ) {
rob@77 9145 if ( arguments.length ) {
rob@77 9146 return options === undefined ?
rob@77 9147 this :
rob@77 9148 this.each(function( i ) {
rob@77 9149 jQuery.offset.setOffset( this, options, i );
rob@77 9150 });
rob@77 9151 }
rob@77 9152
rob@77 9153 var elem = this[0],
rob@77 9154 doc = elem && elem.ownerDocument;
rob@77 9155
rob@77 9156 if ( !doc ) {
rob@77 9157 return null;
rob@77 9158 }
rob@77 9159
rob@77 9160 if ( elem === doc.body ) {
rob@77 9161 return jQuery.offset.bodyOffset( elem );
rob@77 9162 }
rob@77 9163
rob@77 9164 return getOffset( elem, doc, doc.documentElement );
rob@77 9165 };
rob@77 9166
rob@77 9167 jQuery.offset = {
rob@77 9168
rob@77 9169 bodyOffset: function( body ) {
rob@77 9170 var top = body.offsetTop,
rob@77 9171 left = body.offsetLeft;
rob@77 9172
rob@77 9173 if ( jQuery.support.doesNotIncludeMarginInBodyOffset ) {
rob@77 9174 top += parseFloat( jQuery.css(body, "marginTop") ) || 0;
rob@77 9175 left += parseFloat( jQuery.css(body, "marginLeft") ) || 0;
rob@77 9176 }
rob@77 9177
rob@77 9178 return { top: top, left: left };
rob@77 9179 },
rob@77 9180
rob@77 9181 setOffset: function( elem, options, i ) {
rob@77 9182 var position = jQuery.css( elem, "position" );
rob@77 9183
rob@77 9184 // set position first, in-case top/left are set even on static elem
rob@77 9185 if ( position === "static" ) {
rob@77 9186 elem.style.position = "relative";
rob@77 9187 }
rob@77 9188
rob@77 9189 var curElem = jQuery( elem ),
rob@77 9190 curOffset = curElem.offset(),
rob@77 9191 curCSSTop = jQuery.css( elem, "top" ),
rob@77 9192 curCSSLeft = jQuery.css( elem, "left" ),
rob@77 9193 calculatePosition = ( position === "absolute" || position === "fixed" ) && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1,
rob@77 9194 props = {}, curPosition = {}, curTop, curLeft;
rob@77 9195
rob@77 9196 // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
rob@77 9197 if ( calculatePosition ) {
rob@77 9198 curPosition = curElem.position();
rob@77 9199 curTop = curPosition.top;
rob@77 9200 curLeft = curPosition.left;
rob@77 9201 } else {
rob@77 9202 curTop = parseFloat( curCSSTop ) || 0;
rob@77 9203 curLeft = parseFloat( curCSSLeft ) || 0;
rob@77 9204 }
rob@77 9205
rob@77 9206 if ( jQuery.isFunction( options ) ) {
rob@77 9207 options = options.call( elem, i, curOffset );
rob@77 9208 }
rob@77 9209
rob@77 9210 if ( options.top != null ) {
rob@77 9211 props.top = ( options.top - curOffset.top ) + curTop;
rob@77 9212 }
rob@77 9213 if ( options.left != null ) {
rob@77 9214 props.left = ( options.left - curOffset.left ) + curLeft;
rob@77 9215 }
rob@77 9216
rob@77 9217 if ( "using" in options ) {
rob@77 9218 options.using.call( elem, props );
rob@77 9219 } else {
rob@77 9220 curElem.css( props );
rob@77 9221 }
rob@77 9222 }
rob@77 9223 };
rob@77 9224
rob@77 9225
rob@77 9226 jQuery.fn.extend({
rob@77 9227
rob@77 9228 position: function() {
rob@77 9229 if ( !this[0] ) {
rob@77 9230 return null;
rob@77 9231 }
rob@77 9232
rob@77 9233 var elem = this[0],
rob@77 9234
rob@77 9235 // Get *real* offsetParent
rob@77 9236 offsetParent = this.offsetParent(),
rob@77 9237
rob@77 9238 // Get correct offsets
rob@77 9239 offset = this.offset(),
rob@77 9240 parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
rob@77 9241
rob@77 9242 // Subtract element margins
rob@77 9243 // note: when an element has margin: auto the offsetLeft and marginLeft
rob@77 9244 // are the same in Safari causing offset.left to incorrectly be 0
rob@77 9245 offset.top -= parseFloat( jQuery.css(elem, "marginTop") ) || 0;
rob@77 9246 offset.left -= parseFloat( jQuery.css(elem, "marginLeft") ) || 0;
rob@77 9247
rob@77 9248 // Add offsetParent borders
rob@77 9249 parentOffset.top += parseFloat( jQuery.css(offsetParent[0], "borderTopWidth") ) || 0;
rob@77 9250 parentOffset.left += parseFloat( jQuery.css(offsetParent[0], "borderLeftWidth") ) || 0;
rob@77 9251
rob@77 9252 // Subtract the two offsets
rob@77 9253 return {
rob@77 9254 top: offset.top - parentOffset.top,
rob@77 9255 left: offset.left - parentOffset.left
rob@77 9256 };
rob@77 9257 },
rob@77 9258
rob@77 9259 offsetParent: function() {
rob@77 9260 return this.map(function() {
rob@77 9261 var offsetParent = this.offsetParent || document.body;
rob@77 9262 while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
rob@77 9263 offsetParent = offsetParent.offsetParent;
rob@77 9264 }
rob@77 9265 return offsetParent;
rob@77 9266 });
rob@77 9267 }
rob@77 9268 });
rob@77 9269
rob@77 9270
rob@77 9271 // Create scrollLeft and scrollTop methods
rob@77 9272 jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( method, prop ) {
rob@77 9273 var top = /Y/.test( prop );
rob@77 9274
rob@77 9275 jQuery.fn[ method ] = function( val ) {
rob@77 9276 return jQuery.access( this, function( elem, method, val ) {
rob@77 9277 var win = getWindow( elem );
rob@77 9278
rob@77 9279 if ( val === undefined ) {
rob@77 9280 return win ? (prop in win) ? win[ prop ] :
rob@77 9281 jQuery.support.boxModel && win.document.documentElement[ method ] ||
rob@77 9282 win.document.body[ method ] :
rob@77 9283 elem[ method ];
rob@77 9284 }
rob@77 9285
rob@77 9286 if ( win ) {
rob@77 9287 win.scrollTo(
rob@77 9288 !top ? val : jQuery( win ).scrollLeft(),
rob@77 9289 top ? val : jQuery( win ).scrollTop()
rob@77 9290 );
rob@77 9291
rob@77 9292 } else {
rob@77 9293 elem[ method ] = val;
rob@77 9294 }
rob@77 9295 }, method, val, arguments.length, null );
rob@77 9296 };
rob@77 9297 });
rob@77 9298
rob@77 9299 function getWindow( elem ) {
rob@77 9300 return jQuery.isWindow( elem ) ?
rob@77 9301 elem :
rob@77 9302 elem.nodeType === 9 ?
rob@77 9303 elem.defaultView || elem.parentWindow :
rob@77 9304 false;
rob@77 9305 }
rob@77 9306
rob@77 9307
rob@77 9308
rob@77 9309
rob@77 9310 // Create width, height, innerHeight, innerWidth, outerHeight and outerWidth methods
rob@77 9311 jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
rob@77 9312 var clientProp = "client" + name,
rob@77 9313 scrollProp = "scroll" + name,
rob@77 9314 offsetProp = "offset" + name;
rob@77 9315
rob@77 9316 // innerHeight and innerWidth
rob@77 9317 jQuery.fn[ "inner" + name ] = function() {
rob@77 9318 var elem = this[0];
rob@77 9319 return elem ?
rob@77 9320 elem.style ?
rob@77 9321 parseFloat( jQuery.css( elem, type, "padding" ) ) :
rob@77 9322 this[ type ]() :
rob@77 9323 null;
rob@77 9324 };
rob@77 9325
rob@77 9326 // outerHeight and outerWidth
rob@77 9327 jQuery.fn[ "outer" + name ] = function( margin ) {
rob@77 9328 var elem = this[0];
rob@77 9329 return elem ?
rob@77 9330 elem.style ?
rob@77 9331 parseFloat( jQuery.css( elem, type, margin ? "margin" : "border" ) ) :
rob@77 9332 this[ type ]() :
rob@77 9333 null;
rob@77 9334 };
rob@77 9335
rob@77 9336 jQuery.fn[ type ] = function( value ) {
rob@77 9337 return jQuery.access( this, function( elem, type, value ) {
rob@77 9338 var doc, docElemProp, orig, ret;
rob@77 9339
rob@77 9340 if ( jQuery.isWindow( elem ) ) {
rob@77 9341 // 3rd condition allows Nokia support, as it supports the docElem prop but not CSS1Compat
rob@77 9342 doc = elem.document;
rob@77 9343 docElemProp = doc.documentElement[ clientProp ];
rob@77 9344 return jQuery.support.boxModel && docElemProp ||
rob@77 9345 doc.body && doc.body[ clientProp ] || docElemProp;
rob@77 9346 }
rob@77 9347
rob@77 9348 // Get document width or height
rob@77 9349 if ( elem.nodeType === 9 ) {
rob@77 9350 // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
rob@77 9351 doc = elem.documentElement;
rob@77 9352
rob@77 9353 // when a window > document, IE6 reports a offset[Width/Height] > client[Width/Height]
rob@77 9354 // so we can't use max, as it'll choose the incorrect offset[Width/Height]
rob@77 9355 // instead we use the correct client[Width/Height]
rob@77 9356 // support:IE6
rob@77 9357 if ( doc[ clientProp ] >= doc[ scrollProp ] ) {
rob@77 9358 return doc[ clientProp ];
rob@77 9359 }
rob@77 9360
rob@77 9361 return Math.max(
rob@77 9362 elem.body[ scrollProp ], doc[ scrollProp ],
rob@77 9363 elem.body[ offsetProp ], doc[ offsetProp ]
rob@77 9364 );
rob@77 9365 }
rob@77 9366
rob@77 9367 // Get width or height on the element
rob@77 9368 if ( value === undefined ) {
rob@77 9369 orig = jQuery.css( elem, type );
rob@77 9370 ret = parseFloat( orig );
rob@77 9371 return jQuery.isNumeric( ret ) ? ret : orig;
rob@77 9372 }
rob@77 9373
rob@77 9374 // Set the width or height on the element
rob@77 9375 jQuery( elem ).css( type, value );
rob@77 9376 }, type, value, arguments.length, null );
rob@77 9377 };
rob@77 9378 });
rob@77 9379
rob@77 9380
rob@77 9381
rob@77 9382
rob@77 9383 // Expose jQuery to the global object
rob@77 9384 window.jQuery = window.$ = jQuery;
rob@77 9385
rob@77 9386 // Expose jQuery as an AMD module, but only for AMD loaders that
rob@77 9387 // understand the issues with loading multiple versions of jQuery
rob@77 9388 // in a page that all might call define(). The loader will indicate
rob@77 9389 // they have special allowances for multiple jQuery versions by
rob@77 9390 // specifying define.amd.jQuery = true. Register as a named module,
rob@77 9391 // since jQuery can be concatenated with other files that may use define,
rob@77 9392 // but not use a proper concatenation script that understands anonymous
rob@77 9393 // AMD modules. A named AMD is safest and most robust way to register.
rob@77 9394 // Lowercase jquery is used because AMD module names are derived from
rob@77 9395 // file names, and jQuery is normally delivered in a lowercase file name.
rob@77 9396 // Do this after creating the global so that if an AMD module wants to call
rob@77 9397 // noConflict to hide this version of jQuery, it will work.
rob@77 9398 if ( typeof define === "function" && define.amd && define.amd.jQuery ) {
rob@77 9399 define( "jquery", [], function () { return jQuery; } );
rob@77 9400 }
rob@77 9401
rob@77 9402
rob@77 9403
rob@77 9404 })( window );