Index: trunk/extensions/VisualEditor/modules/jquery.js |
— | — | @@ -0,0 +1,9300 @@ |
| 2 | +/*! |
| 3 | + * jQuery JavaScript Library v1.7rc2 |
| 4 | + * http://jquery.com/ |
| 5 | + * |
| 6 | + * Copyright 2011, John Resig |
| 7 | + * Dual licensed under the MIT or GPL Version 2 licenses. |
| 8 | + * http://jquery.org/license |
| 9 | + * |
| 10 | + * Includes Sizzle.js |
| 11 | + * http://sizzlejs.com/ |
| 12 | + * Copyright 2011, The Dojo Foundation |
| 13 | + * Released under the MIT, BSD, and GPL Licenses. |
| 14 | + * |
| 15 | + * Date: Tue Nov 1 12:07:23 2011 -0400 |
| 16 | + */ |
| 17 | +(function( window, undefined ) { |
| 18 | + |
| 19 | +// Use the correct document accordingly with window argument (sandbox) |
| 20 | +var document = window.document, |
| 21 | + navigator = window.navigator, |
| 22 | + location = window.location; |
| 23 | +var jQuery = (function() { |
| 24 | + |
| 25 | +// Define a local copy of jQuery |
| 26 | +var jQuery = function( selector, context ) { |
| 27 | + // The jQuery object is actually just the init constructor 'enhanced' |
| 28 | + return new jQuery.fn.init( selector, context, rootjQuery ); |
| 29 | + }, |
| 30 | + |
| 31 | + // Map over jQuery in case of overwrite |
| 32 | + _jQuery = window.jQuery, |
| 33 | + |
| 34 | + // Map over the $ in case of overwrite |
| 35 | + _$ = window.$, |
| 36 | + |
| 37 | + // A central reference to the root jQuery(document) |
| 38 | + rootjQuery, |
| 39 | + |
| 40 | + // A simple way to check for HTML strings or ID strings |
| 41 | + // Prioritize #id over <tag> to avoid XSS via location.hash (#9521) |
| 42 | + quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/, |
| 43 | + |
| 44 | + // Check if a string has a non-whitespace character in it |
| 45 | + rnotwhite = /\S/, |
| 46 | + |
| 47 | + // Used for trimming whitespace |
| 48 | + trimLeft = /^\s+/, |
| 49 | + trimRight = /\s+$/, |
| 50 | + |
| 51 | + // Check for digits |
| 52 | + rdigit = /\d/, |
| 53 | + |
| 54 | + // Match a standalone tag |
| 55 | + rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/, |
| 56 | + |
| 57 | + // JSON RegExp |
| 58 | + rvalidchars = /^[\],:{}\s]*$/, |
| 59 | + rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, |
| 60 | + rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, |
| 61 | + rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g, |
| 62 | + |
| 63 | + // Useragent RegExp |
| 64 | + rwebkit = /(webkit)[ \/]([\w.]+)/, |
| 65 | + ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/, |
| 66 | + rmsie = /(msie) ([\w.]+)/, |
| 67 | + rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/, |
| 68 | + |
| 69 | + // Matches dashed string for camelizing |
| 70 | + rdashAlpha = /-([a-z]|[0-9])/ig, |
| 71 | + rmsPrefix = /^-ms-/, |
| 72 | + |
| 73 | + // Used by jQuery.camelCase as callback to replace() |
| 74 | + fcamelCase = function( all, letter ) { |
| 75 | + return ( letter + "" ).toUpperCase(); |
| 76 | + }, |
| 77 | + |
| 78 | + // Keep a UserAgent string for use with jQuery.browser |
| 79 | + userAgent = navigator.userAgent, |
| 80 | + |
| 81 | + // For matching the engine and version of the browser |
| 82 | + browserMatch, |
| 83 | + |
| 84 | + // The deferred used on DOM ready |
| 85 | + readyList, |
| 86 | + |
| 87 | + // The ready event handler |
| 88 | + DOMContentLoaded, |
| 89 | + |
| 90 | + // Save a reference to some core methods |
| 91 | + toString = Object.prototype.toString, |
| 92 | + hasOwn = Object.prototype.hasOwnProperty, |
| 93 | + push = Array.prototype.push, |
| 94 | + slice = Array.prototype.slice, |
| 95 | + trim = String.prototype.trim, |
| 96 | + indexOf = Array.prototype.indexOf, |
| 97 | + |
| 98 | + // [[Class]] -> type pairs |
| 99 | + class2type = {}; |
| 100 | + |
| 101 | +jQuery.fn = jQuery.prototype = { |
| 102 | + constructor: jQuery, |
| 103 | + init: function( selector, context, rootjQuery ) { |
| 104 | + var match, elem, ret, doc; |
| 105 | + |
| 106 | + // Handle $(""), $(null), or $(undefined) |
| 107 | + if ( !selector ) { |
| 108 | + return this; |
| 109 | + } |
| 110 | + |
| 111 | + // Handle $(DOMElement) |
| 112 | + if ( selector.nodeType ) { |
| 113 | + this.context = this[0] = selector; |
| 114 | + this.length = 1; |
| 115 | + return this; |
| 116 | + } |
| 117 | + |
| 118 | + // The body element only exists once, optimize finding it |
| 119 | + if ( selector === "body" && !context && document.body ) { |
| 120 | + this.context = document; |
| 121 | + this[0] = document.body; |
| 122 | + this.selector = selector; |
| 123 | + this.length = 1; |
| 124 | + return this; |
| 125 | + } |
| 126 | + |
| 127 | + // Handle HTML strings |
| 128 | + if ( typeof selector === "string" ) { |
| 129 | + // Are we dealing with HTML string or an ID? |
| 130 | + if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) { |
| 131 | + // Assume that strings that start and end with <> are HTML and skip the regex check |
| 132 | + match = [ null, selector, null ]; |
| 133 | + |
| 134 | + } else { |
| 135 | + match = quickExpr.exec( selector ); |
| 136 | + } |
| 137 | + |
| 138 | + // Verify a match, and that no context was specified for #id |
| 139 | + if ( match && (match[1] || !context) ) { |
| 140 | + |
| 141 | + // HANDLE: $(html) -> $(array) |
| 142 | + if ( match[1] ) { |
| 143 | + context = context instanceof jQuery ? context[0] : context; |
| 144 | + doc = ( context ? context.ownerDocument || context : document ); |
| 145 | + |
| 146 | + // If a single string is passed in and it's a single tag |
| 147 | + // just do a createElement and skip the rest |
| 148 | + ret = rsingleTag.exec( selector ); |
| 149 | + |
| 150 | + if ( ret ) { |
| 151 | + if ( jQuery.isPlainObject( context ) ) { |
| 152 | + selector = [ document.createElement( ret[1] ) ]; |
| 153 | + jQuery.fn.attr.call( selector, context, true ); |
| 154 | + |
| 155 | + } else { |
| 156 | + selector = [ doc.createElement( ret[1] ) ]; |
| 157 | + } |
| 158 | + |
| 159 | + } else { |
| 160 | + ret = jQuery.buildFragment( [ match[1] ], [ doc ] ); |
| 161 | + selector = ( ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment ).childNodes; |
| 162 | + } |
| 163 | + |
| 164 | + return jQuery.merge( this, selector ); |
| 165 | + |
| 166 | + // HANDLE: $("#id") |
| 167 | + } else { |
| 168 | + elem = document.getElementById( match[2] ); |
| 169 | + |
| 170 | + // Check parentNode to catch when Blackberry 4.6 returns |
| 171 | + // nodes that are no longer in the document #6963 |
| 172 | + if ( elem && elem.parentNode ) { |
| 173 | + // Handle the case where IE and Opera return items |
| 174 | + // by name instead of ID |
| 175 | + if ( elem.id !== match[2] ) { |
| 176 | + return rootjQuery.find( selector ); |
| 177 | + } |
| 178 | + |
| 179 | + // Otherwise, we inject the element directly into the jQuery object |
| 180 | + this.length = 1; |
| 181 | + this[0] = elem; |
| 182 | + } |
| 183 | + |
| 184 | + this.context = document; |
| 185 | + this.selector = selector; |
| 186 | + return this; |
| 187 | + } |
| 188 | + |
| 189 | + // HANDLE: $(expr, $(...)) |
| 190 | + } else if ( !context || context.jquery ) { |
| 191 | + return ( context || rootjQuery ).find( selector ); |
| 192 | + |
| 193 | + // HANDLE: $(expr, context) |
| 194 | + // (which is just equivalent to: $(context).find(expr) |
| 195 | + } else { |
| 196 | + return this.constructor( context ).find( selector ); |
| 197 | + } |
| 198 | + |
| 199 | + // HANDLE: $(function) |
| 200 | + // Shortcut for document ready |
| 201 | + } else if ( jQuery.isFunction( selector ) ) { |
| 202 | + return rootjQuery.ready( selector ); |
| 203 | + } |
| 204 | + |
| 205 | + if ( selector.selector !== undefined ) { |
| 206 | + this.selector = selector.selector; |
| 207 | + this.context = selector.context; |
| 208 | + } |
| 209 | + |
| 210 | + return jQuery.makeArray( selector, this ); |
| 211 | + }, |
| 212 | + |
| 213 | + // Start with an empty selector |
| 214 | + selector: "", |
| 215 | + |
| 216 | + // The current version of jQuery being used |
| 217 | + jquery: "1.7rc2", |
| 218 | + |
| 219 | + // The default length of a jQuery object is 0 |
| 220 | + length: 0, |
| 221 | + |
| 222 | + // The number of elements contained in the matched element set |
| 223 | + size: function() { |
| 224 | + return this.length; |
| 225 | + }, |
| 226 | + |
| 227 | + toArray: function() { |
| 228 | + return slice.call( this, 0 ); |
| 229 | + }, |
| 230 | + |
| 231 | + // Get the Nth element in the matched element set OR |
| 232 | + // Get the whole matched element set as a clean array |
| 233 | + get: function( num ) { |
| 234 | + return num == null ? |
| 235 | + |
| 236 | + // Return a 'clean' array |
| 237 | + this.toArray() : |
| 238 | + |
| 239 | + // Return just the object |
| 240 | + ( num < 0 ? this[ this.length + num ] : this[ num ] ); |
| 241 | + }, |
| 242 | + |
| 243 | + // Take an array of elements and push it onto the stack |
| 244 | + // (returning the new matched element set) |
| 245 | + pushStack: function( elems, name, selector ) { |
| 246 | + // Build a new jQuery matched element set |
| 247 | + var ret = this.constructor(); |
| 248 | + |
| 249 | + if ( jQuery.isArray( elems ) ) { |
| 250 | + push.apply( ret, elems ); |
| 251 | + |
| 252 | + } else { |
| 253 | + jQuery.merge( ret, elems ); |
| 254 | + } |
| 255 | + |
| 256 | + // Add the old object onto the stack (as a reference) |
| 257 | + ret.prevObject = this; |
| 258 | + |
| 259 | + ret.context = this.context; |
| 260 | + |
| 261 | + if ( name === "find" ) { |
| 262 | + ret.selector = this.selector + ( this.selector ? " " : "" ) + selector; |
| 263 | + } else if ( name ) { |
| 264 | + ret.selector = this.selector + "." + name + "(" + selector + ")"; |
| 265 | + } |
| 266 | + |
| 267 | + // Return the newly-formed element set |
| 268 | + return ret; |
| 269 | + }, |
| 270 | + |
| 271 | + // Execute a callback for every element in the matched set. |
| 272 | + // (You can seed the arguments with an array of args, but this is |
| 273 | + // only used internally.) |
| 274 | + each: function( callback, args ) { |
| 275 | + return jQuery.each( this, callback, args ); |
| 276 | + }, |
| 277 | + |
| 278 | + ready: function( fn ) { |
| 279 | + // Attach the listeners |
| 280 | + jQuery.bindReady(); |
| 281 | + |
| 282 | + // Add the callback |
| 283 | + readyList.add( fn ); |
| 284 | + |
| 285 | + return this; |
| 286 | + }, |
| 287 | + |
| 288 | + eq: function( i ) { |
| 289 | + return i === -1 ? |
| 290 | + this.slice( i ) : |
| 291 | + this.slice( i, +i + 1 ); |
| 292 | + }, |
| 293 | + |
| 294 | + first: function() { |
| 295 | + return this.eq( 0 ); |
| 296 | + }, |
| 297 | + |
| 298 | + last: function() { |
| 299 | + return this.eq( -1 ); |
| 300 | + }, |
| 301 | + |
| 302 | + slice: function() { |
| 303 | + return this.pushStack( slice.apply( this, arguments ), |
| 304 | + "slice", slice.call(arguments).join(",") ); |
| 305 | + }, |
| 306 | + |
| 307 | + map: function( callback ) { |
| 308 | + return this.pushStack( jQuery.map(this, function( elem, i ) { |
| 309 | + return callback.call( elem, i, elem ); |
| 310 | + })); |
| 311 | + }, |
| 312 | + |
| 313 | + end: function() { |
| 314 | + return this.prevObject || this.constructor(null); |
| 315 | + }, |
| 316 | + |
| 317 | + // For internal use only. |
| 318 | + // Behaves like an Array's method, not like a jQuery method. |
| 319 | + push: push, |
| 320 | + sort: [].sort, |
| 321 | + splice: [].splice |
| 322 | +}; |
| 323 | + |
| 324 | +// Give the init function the jQuery prototype for later instantiation |
| 325 | +jQuery.fn.init.prototype = jQuery.fn; |
| 326 | + |
| 327 | +jQuery.extend = jQuery.fn.extend = function() { |
| 328 | + var options, name, src, copy, copyIsArray, clone, |
| 329 | + target = arguments[0] || {}, |
| 330 | + i = 1, |
| 331 | + length = arguments.length, |
| 332 | + deep = false; |
| 333 | + |
| 334 | + // Handle a deep copy situation |
| 335 | + if ( typeof target === "boolean" ) { |
| 336 | + deep = target; |
| 337 | + target = arguments[1] || {}; |
| 338 | + // skip the boolean and the target |
| 339 | + i = 2; |
| 340 | + } |
| 341 | + |
| 342 | + // Handle case when target is a string or something (possible in deep copy) |
| 343 | + if ( typeof target !== "object" && !jQuery.isFunction(target) ) { |
| 344 | + target = {}; |
| 345 | + } |
| 346 | + |
| 347 | + // extend jQuery itself if only one argument is passed |
| 348 | + if ( length === i ) { |
| 349 | + target = this; |
| 350 | + --i; |
| 351 | + } |
| 352 | + |
| 353 | + for ( ; i < length; i++ ) { |
| 354 | + // Only deal with non-null/undefined values |
| 355 | + if ( (options = arguments[ i ]) != null ) { |
| 356 | + // Extend the base object |
| 357 | + for ( name in options ) { |
| 358 | + src = target[ name ]; |
| 359 | + copy = options[ name ]; |
| 360 | + |
| 361 | + // Prevent never-ending loop |
| 362 | + if ( target === copy ) { |
| 363 | + continue; |
| 364 | + } |
| 365 | + |
| 366 | + // Recurse if we're merging plain objects or arrays |
| 367 | + if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) { |
| 368 | + if ( copyIsArray ) { |
| 369 | + copyIsArray = false; |
| 370 | + clone = src && jQuery.isArray(src) ? src : []; |
| 371 | + |
| 372 | + } else { |
| 373 | + clone = src && jQuery.isPlainObject(src) ? src : {}; |
| 374 | + } |
| 375 | + |
| 376 | + // Never move original objects, clone them |
| 377 | + target[ name ] = jQuery.extend( deep, clone, copy ); |
| 378 | + |
| 379 | + // Don't bring in undefined values |
| 380 | + } else if ( copy !== undefined ) { |
| 381 | + target[ name ] = copy; |
| 382 | + } |
| 383 | + } |
| 384 | + } |
| 385 | + } |
| 386 | + |
| 387 | + // Return the modified object |
| 388 | + return target; |
| 389 | +}; |
| 390 | + |
| 391 | +jQuery.extend({ |
| 392 | + noConflict: function( deep ) { |
| 393 | + if ( window.$ === jQuery ) { |
| 394 | + window.$ = _$; |
| 395 | + } |
| 396 | + |
| 397 | + if ( deep && window.jQuery === jQuery ) { |
| 398 | + window.jQuery = _jQuery; |
| 399 | + } |
| 400 | + |
| 401 | + return jQuery; |
| 402 | + }, |
| 403 | + |
| 404 | + // Is the DOM ready to be used? Set to true once it occurs. |
| 405 | + isReady: false, |
| 406 | + |
| 407 | + // A counter to track how many items to wait for before |
| 408 | + // the ready event fires. See #6781 |
| 409 | + readyWait: 1, |
| 410 | + |
| 411 | + // Hold (or release) the ready event |
| 412 | + holdReady: function( hold ) { |
| 413 | + if ( hold ) { |
| 414 | + jQuery.readyWait++; |
| 415 | + } else { |
| 416 | + jQuery.ready( true ); |
| 417 | + } |
| 418 | + }, |
| 419 | + |
| 420 | + // Handle when the DOM is ready |
| 421 | + ready: function( wait ) { |
| 422 | + // Either a released hold or an DOMready/load event and not yet ready |
| 423 | + if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) { |
| 424 | + // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). |
| 425 | + if ( !document.body ) { |
| 426 | + return setTimeout( jQuery.ready, 1 ); |
| 427 | + } |
| 428 | + |
| 429 | + // Remember that the DOM is ready |
| 430 | + jQuery.isReady = true; |
| 431 | + |
| 432 | + // If a normal DOM Ready event fired, decrement, and wait if need be |
| 433 | + if ( wait !== true && --jQuery.readyWait > 0 ) { |
| 434 | + return; |
| 435 | + } |
| 436 | + |
| 437 | + // If there are functions bound, to execute |
| 438 | + readyList.fireWith( document, [ jQuery ] ); |
| 439 | + |
| 440 | + // Trigger any bound ready events |
| 441 | + if ( jQuery.fn.trigger ) { |
| 442 | + jQuery( document ).trigger( "ready" ).unbind( "ready" ); |
| 443 | + } |
| 444 | + } |
| 445 | + }, |
| 446 | + |
| 447 | + bindReady: function() { |
| 448 | + if ( readyList ) { |
| 449 | + return; |
| 450 | + } |
| 451 | + |
| 452 | + readyList = jQuery.Callbacks( "once memory" ); |
| 453 | + |
| 454 | + // Catch cases where $(document).ready() is called after the |
| 455 | + // browser event has already occurred. |
| 456 | + if ( document.readyState === "complete" ) { |
| 457 | + // Handle it asynchronously to allow scripts the opportunity to delay ready |
| 458 | + return setTimeout( jQuery.ready, 1 ); |
| 459 | + } |
| 460 | + |
| 461 | + // Mozilla, Opera and webkit nightlies currently support this event |
| 462 | + if ( document.addEventListener ) { |
| 463 | + // Use the handy event callback |
| 464 | + document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false ); |
| 465 | + |
| 466 | + // A fallback to window.onload, that will always work |
| 467 | + window.addEventListener( "load", jQuery.ready, false ); |
| 468 | + |
| 469 | + // If IE event model is used |
| 470 | + } else if ( document.attachEvent ) { |
| 471 | + // ensure firing before onload, |
| 472 | + // maybe late but safe also for iframes |
| 473 | + document.attachEvent( "onreadystatechange", DOMContentLoaded ); |
| 474 | + |
| 475 | + // A fallback to window.onload, that will always work |
| 476 | + window.attachEvent( "onload", jQuery.ready ); |
| 477 | + |
| 478 | + // If IE and not a frame |
| 479 | + // continually check to see if the document is ready |
| 480 | + var toplevel = false; |
| 481 | + |
| 482 | + try { |
| 483 | + toplevel = window.frameElement == null; |
| 484 | + } catch(e) {} |
| 485 | + |
| 486 | + if ( document.documentElement.doScroll && toplevel ) { |
| 487 | + doScrollCheck(); |
| 488 | + } |
| 489 | + } |
| 490 | + }, |
| 491 | + |
| 492 | + // See test/unit/core.js for details concerning isFunction. |
| 493 | + // Since version 1.3, DOM methods and functions like alert |
| 494 | + // aren't supported. They return false on IE (#2968). |
| 495 | + isFunction: function( obj ) { |
| 496 | + return jQuery.type(obj) === "function"; |
| 497 | + }, |
| 498 | + |
| 499 | + isArray: Array.isArray || function( obj ) { |
| 500 | + return jQuery.type(obj) === "array"; |
| 501 | + }, |
| 502 | + |
| 503 | + // A crude way of determining if an object is a window |
| 504 | + isWindow: function( obj ) { |
| 505 | + return obj && typeof obj === "object" && "setInterval" in obj; |
| 506 | + }, |
| 507 | + |
| 508 | + isNumeric: function( obj ) { |
| 509 | + return obj != null && rdigit.test( obj ) && !isNaN( obj ); |
| 510 | + }, |
| 511 | + |
| 512 | + type: function( obj ) { |
| 513 | + return obj == null ? |
| 514 | + String( obj ) : |
| 515 | + class2type[ toString.call(obj) ] || "object"; |
| 516 | + }, |
| 517 | + |
| 518 | + isPlainObject: function( obj ) { |
| 519 | + // Must be an Object. |
| 520 | + // Because of IE, we also have to check the presence of the constructor property. |
| 521 | + // Make sure that DOM nodes and window objects don't pass through, as well |
| 522 | + if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { |
| 523 | + return false; |
| 524 | + } |
| 525 | + |
| 526 | + try { |
| 527 | + // Not own constructor property must be Object |
| 528 | + if ( obj.constructor && |
| 529 | + !hasOwn.call(obj, "constructor") && |
| 530 | + !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { |
| 531 | + return false; |
| 532 | + } |
| 533 | + } catch ( e ) { |
| 534 | + // IE8,9 Will throw exceptions on certain host objects #9897 |
| 535 | + return false; |
| 536 | + } |
| 537 | + |
| 538 | + // Own properties are enumerated firstly, so to speed up, |
| 539 | + // if last one is own, then all properties are own. |
| 540 | + |
| 541 | + var key; |
| 542 | + for ( key in obj ) {} |
| 543 | + |
| 544 | + return key === undefined || hasOwn.call( obj, key ); |
| 545 | + }, |
| 546 | + |
| 547 | + isEmptyObject: function( obj ) { |
| 548 | + for ( var name in obj ) { |
| 549 | + return false; |
| 550 | + } |
| 551 | + return true; |
| 552 | + }, |
| 553 | + |
| 554 | + error: function( msg ) { |
| 555 | + throw msg; |
| 556 | + }, |
| 557 | + |
| 558 | + parseJSON: function( data ) { |
| 559 | + if ( typeof data !== "string" || !data ) { |
| 560 | + return null; |
| 561 | + } |
| 562 | + |
| 563 | + // Make sure leading/trailing whitespace is removed (IE can't handle it) |
| 564 | + data = jQuery.trim( data ); |
| 565 | + |
| 566 | + // Attempt to parse using the native JSON parser first |
| 567 | + if ( window.JSON && window.JSON.parse ) { |
| 568 | + return window.JSON.parse( data ); |
| 569 | + } |
| 570 | + |
| 571 | + // Make sure the incoming data is actual JSON |
| 572 | + // Logic borrowed from http://json.org/json2.js |
| 573 | + if ( rvalidchars.test( data.replace( rvalidescape, "@" ) |
| 574 | + .replace( rvalidtokens, "]" ) |
| 575 | + .replace( rvalidbraces, "")) ) { |
| 576 | + |
| 577 | + return ( new Function( "return " + data ) )(); |
| 578 | + |
| 579 | + } |
| 580 | + jQuery.error( "Invalid JSON: " + data ); |
| 581 | + }, |
| 582 | + |
| 583 | + // Cross-browser xml parsing |
| 584 | + parseXML: function( data ) { |
| 585 | + var xml, tmp; |
| 586 | + try { |
| 587 | + if ( window.DOMParser ) { // Standard |
| 588 | + tmp = new DOMParser(); |
| 589 | + xml = tmp.parseFromString( data , "text/xml" ); |
| 590 | + } else { // IE |
| 591 | + xml = new ActiveXObject( "Microsoft.XMLDOM" ); |
| 592 | + xml.async = "false"; |
| 593 | + xml.loadXML( data ); |
| 594 | + } |
| 595 | + } catch( e ) { |
| 596 | + xml = undefined; |
| 597 | + } |
| 598 | + if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) { |
| 599 | + jQuery.error( "Invalid XML: " + data ); |
| 600 | + } |
| 601 | + return xml; |
| 602 | + }, |
| 603 | + |
| 604 | + noop: function() {}, |
| 605 | + |
| 606 | + // Evaluates a script in a global context |
| 607 | + // Workarounds based on findings by Jim Driscoll |
| 608 | + // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context |
| 609 | + globalEval: function( data ) { |
| 610 | + if ( data && rnotwhite.test( data ) ) { |
| 611 | + // We use execScript on Internet Explorer |
| 612 | + // We use an anonymous function so that context is window |
| 613 | + // rather than jQuery in Firefox |
| 614 | + ( window.execScript || function( data ) { |
| 615 | + window[ "eval" ].call( window, data ); |
| 616 | + } )( data ); |
| 617 | + } |
| 618 | + }, |
| 619 | + |
| 620 | + // Convert dashed to camelCase; used by the css and data modules |
| 621 | + // Microsoft forgot to hump their vendor prefix (#9572) |
| 622 | + camelCase: function( string ) { |
| 623 | + return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); |
| 624 | + }, |
| 625 | + |
| 626 | + nodeName: function( elem, name ) { |
| 627 | + return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase(); |
| 628 | + }, |
| 629 | + |
| 630 | + // args is for internal usage only |
| 631 | + each: function( object, callback, args ) { |
| 632 | + var name, i = 0, |
| 633 | + length = object.length, |
| 634 | + isObj = length === undefined || jQuery.isFunction( object ); |
| 635 | + |
| 636 | + if ( args ) { |
| 637 | + if ( isObj ) { |
| 638 | + for ( name in object ) { |
| 639 | + if ( callback.apply( object[ name ], args ) === false ) { |
| 640 | + break; |
| 641 | + } |
| 642 | + } |
| 643 | + } else { |
| 644 | + for ( ; i < length; ) { |
| 645 | + if ( callback.apply( object[ i++ ], args ) === false ) { |
| 646 | + break; |
| 647 | + } |
| 648 | + } |
| 649 | + } |
| 650 | + |
| 651 | + // A special, fast, case for the most common use of each |
| 652 | + } else { |
| 653 | + if ( isObj ) { |
| 654 | + for ( name in object ) { |
| 655 | + if ( callback.call( object[ name ], name, object[ name ] ) === false ) { |
| 656 | + break; |
| 657 | + } |
| 658 | + } |
| 659 | + } else { |
| 660 | + for ( ; i < length; ) { |
| 661 | + if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) { |
| 662 | + break; |
| 663 | + } |
| 664 | + } |
| 665 | + } |
| 666 | + } |
| 667 | + |
| 668 | + return object; |
| 669 | + }, |
| 670 | + |
| 671 | + // Use native String.trim function wherever possible |
| 672 | + trim: trim ? |
| 673 | + function( text ) { |
| 674 | + return text == null ? |
| 675 | + "" : |
| 676 | + trim.call( text ); |
| 677 | + } : |
| 678 | + |
| 679 | + // Otherwise use our own trimming functionality |
| 680 | + function( text ) { |
| 681 | + return text == null ? |
| 682 | + "" : |
| 683 | + text.toString().replace( trimLeft, "" ).replace( trimRight, "" ); |
| 684 | + }, |
| 685 | + |
| 686 | + // results is for internal usage only |
| 687 | + makeArray: function( array, results ) { |
| 688 | + var ret = results || []; |
| 689 | + |
| 690 | + if ( array != null ) { |
| 691 | + // The window, strings (and functions) also have 'length' |
| 692 | + // The extra typeof function check is to prevent crashes |
| 693 | + // in Safari 2 (See: #3039) |
| 694 | + // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930 |
| 695 | + var type = jQuery.type( array ); |
| 696 | + |
| 697 | + if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) { |
| 698 | + push.call( ret, array ); |
| 699 | + } else { |
| 700 | + jQuery.merge( ret, array ); |
| 701 | + } |
| 702 | + } |
| 703 | + |
| 704 | + return ret; |
| 705 | + }, |
| 706 | + |
| 707 | + inArray: function( elem, array, i ) { |
| 708 | + var len; |
| 709 | + |
| 710 | + if ( array ) { |
| 711 | + if ( indexOf ) { |
| 712 | + return indexOf.call( array, elem, i ); |
| 713 | + } |
| 714 | + |
| 715 | + len = array.length; |
| 716 | + i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0; |
| 717 | + |
| 718 | + for ( ; i < len; i++ ) { |
| 719 | + // Skip accessing in sparse arrays |
| 720 | + if ( i in array && array[ i ] === elem ) { |
| 721 | + return i; |
| 722 | + } |
| 723 | + } |
| 724 | + } |
| 725 | + |
| 726 | + return -1; |
| 727 | + }, |
| 728 | + |
| 729 | + merge: function( first, second ) { |
| 730 | + var i = first.length, |
| 731 | + j = 0; |
| 732 | + |
| 733 | + if ( typeof second.length === "number" ) { |
| 734 | + for ( var l = second.length; j < l; j++ ) { |
| 735 | + first[ i++ ] = second[ j ]; |
| 736 | + } |
| 737 | + |
| 738 | + } else { |
| 739 | + while ( second[j] !== undefined ) { |
| 740 | + first[ i++ ] = second[ j++ ]; |
| 741 | + } |
| 742 | + } |
| 743 | + |
| 744 | + first.length = i; |
| 745 | + |
| 746 | + return first; |
| 747 | + }, |
| 748 | + |
| 749 | + grep: function( elems, callback, inv ) { |
| 750 | + var ret = [], retVal; |
| 751 | + inv = !!inv; |
| 752 | + |
| 753 | + // Go through the array, only saving the items |
| 754 | + // that pass the validator function |
| 755 | + for ( var i = 0, length = elems.length; i < length; i++ ) { |
| 756 | + retVal = !!callback( elems[ i ], i ); |
| 757 | + if ( inv !== retVal ) { |
| 758 | + ret.push( elems[ i ] ); |
| 759 | + } |
| 760 | + } |
| 761 | + |
| 762 | + return ret; |
| 763 | + }, |
| 764 | + |
| 765 | + // arg is for internal usage only |
| 766 | + map: function( elems, callback, arg ) { |
| 767 | + var value, key, ret = [], |
| 768 | + i = 0, |
| 769 | + length = elems.length, |
| 770 | + // jquery objects are treated as arrays |
| 771 | + isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ; |
| 772 | + |
| 773 | + // Go through the array, translating each of the items to their |
| 774 | + if ( isArray ) { |
| 775 | + for ( ; i < length; i++ ) { |
| 776 | + value = callback( elems[ i ], i, arg ); |
| 777 | + |
| 778 | + if ( value != null ) { |
| 779 | + ret[ ret.length ] = value; |
| 780 | + } |
| 781 | + } |
| 782 | + |
| 783 | + // Go through every key on the object, |
| 784 | + } else { |
| 785 | + for ( key in elems ) { |
| 786 | + value = callback( elems[ key ], key, arg ); |
| 787 | + |
| 788 | + if ( value != null ) { |
| 789 | + ret[ ret.length ] = value; |
| 790 | + } |
| 791 | + } |
| 792 | + } |
| 793 | + |
| 794 | + // Flatten any nested arrays |
| 795 | + return ret.concat.apply( [], ret ); |
| 796 | + }, |
| 797 | + |
| 798 | + // A global GUID counter for objects |
| 799 | + guid: 1, |
| 800 | + |
| 801 | + // Bind a function to a context, optionally partially applying any |
| 802 | + // arguments. |
| 803 | + proxy: function( fn, context ) { |
| 804 | + if ( typeof context === "string" ) { |
| 805 | + var tmp = fn[ context ]; |
| 806 | + context = fn; |
| 807 | + fn = tmp; |
| 808 | + } |
| 809 | + |
| 810 | + // Quick check to determine if target is callable, in the spec |
| 811 | + // this throws a TypeError, but we will just return undefined. |
| 812 | + if ( !jQuery.isFunction( fn ) ) { |
| 813 | + return undefined; |
| 814 | + } |
| 815 | + |
| 816 | + // Simulated bind |
| 817 | + var args = slice.call( arguments, 2 ), |
| 818 | + proxy = function() { |
| 819 | + return fn.apply( context, args.concat( slice.call( arguments ) ) ); |
| 820 | + }; |
| 821 | + |
| 822 | + // Set the guid of unique handler to the same of original handler, so it can be removed |
| 823 | + proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++; |
| 824 | + |
| 825 | + return proxy; |
| 826 | + }, |
| 827 | + |
| 828 | + // Mutifunctional method to get and set values to a collection |
| 829 | + // The value/s can optionally be executed if it's a function |
| 830 | + access: function( elems, key, value, exec, fn, pass ) { |
| 831 | + var length = elems.length; |
| 832 | + |
| 833 | + // Setting many attributes |
| 834 | + if ( typeof key === "object" ) { |
| 835 | + for ( var k in key ) { |
| 836 | + jQuery.access( elems, k, key[k], exec, fn, value ); |
| 837 | + } |
| 838 | + return elems; |
| 839 | + } |
| 840 | + |
| 841 | + // Setting one attribute |
| 842 | + if ( value !== undefined ) { |
| 843 | + // Optionally, function values get executed if exec is true |
| 844 | + exec = !pass && exec && jQuery.isFunction(value); |
| 845 | + |
| 846 | + for ( var i = 0; i < length; i++ ) { |
| 847 | + fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass ); |
| 848 | + } |
| 849 | + |
| 850 | + return elems; |
| 851 | + } |
| 852 | + |
| 853 | + // Getting an attribute |
| 854 | + return length ? fn( elems[0], key ) : undefined; |
| 855 | + }, |
| 856 | + |
| 857 | + now: function() { |
| 858 | + return ( new Date() ).getTime(); |
| 859 | + }, |
| 860 | + |
| 861 | + // Use of jQuery.browser is frowned upon. |
| 862 | + // More details: http://docs.jquery.com/Utilities/jQuery.browser |
| 863 | + uaMatch: function( ua ) { |
| 864 | + ua = ua.toLowerCase(); |
| 865 | + |
| 866 | + var match = rwebkit.exec( ua ) || |
| 867 | + ropera.exec( ua ) || |
| 868 | + rmsie.exec( ua ) || |
| 869 | + ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) || |
| 870 | + []; |
| 871 | + |
| 872 | + return { browser: match[1] || "", version: match[2] || "0" }; |
| 873 | + }, |
| 874 | + |
| 875 | + sub: function() { |
| 876 | + function jQuerySub( selector, context ) { |
| 877 | + return new jQuerySub.fn.init( selector, context ); |
| 878 | + } |
| 879 | + jQuery.extend( true, jQuerySub, this ); |
| 880 | + jQuerySub.superclass = this; |
| 881 | + jQuerySub.fn = jQuerySub.prototype = this(); |
| 882 | + jQuerySub.fn.constructor = jQuerySub; |
| 883 | + jQuerySub.sub = this.sub; |
| 884 | + jQuerySub.fn.init = function init( selector, context ) { |
| 885 | + if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) { |
| 886 | + context = jQuerySub( context ); |
| 887 | + } |
| 888 | + |
| 889 | + return jQuery.fn.init.call( this, selector, context, rootjQuerySub ); |
| 890 | + }; |
| 891 | + jQuerySub.fn.init.prototype = jQuerySub.fn; |
| 892 | + var rootjQuerySub = jQuerySub(document); |
| 893 | + return jQuerySub; |
| 894 | + }, |
| 895 | + |
| 896 | + browser: {} |
| 897 | +}); |
| 898 | + |
| 899 | +// Populate the class2type map |
| 900 | +jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) { |
| 901 | + class2type[ "[object " + name + "]" ] = name.toLowerCase(); |
| 902 | +}); |
| 903 | + |
| 904 | +browserMatch = jQuery.uaMatch( userAgent ); |
| 905 | +if ( browserMatch.browser ) { |
| 906 | + jQuery.browser[ browserMatch.browser ] = true; |
| 907 | + jQuery.browser.version = browserMatch.version; |
| 908 | +} |
| 909 | + |
| 910 | +// Deprecated, use jQuery.browser.webkit instead |
| 911 | +if ( jQuery.browser.webkit ) { |
| 912 | + jQuery.browser.safari = true; |
| 913 | +} |
| 914 | + |
| 915 | +// IE doesn't match non-breaking spaces with \s |
| 916 | +if ( rnotwhite.test( "\xA0" ) ) { |
| 917 | + trimLeft = /^[\s\xA0]+/; |
| 918 | + trimRight = /[\s\xA0]+$/; |
| 919 | +} |
| 920 | + |
| 921 | +// All jQuery objects should point back to these |
| 922 | +rootjQuery = jQuery(document); |
| 923 | + |
| 924 | +// Cleanup functions for the document ready method |
| 925 | +if ( document.addEventListener ) { |
| 926 | + DOMContentLoaded = function() { |
| 927 | + document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false ); |
| 928 | + jQuery.ready(); |
| 929 | + }; |
| 930 | + |
| 931 | +} else if ( document.attachEvent ) { |
| 932 | + DOMContentLoaded = function() { |
| 933 | + // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). |
| 934 | + if ( document.readyState === "complete" ) { |
| 935 | + document.detachEvent( "onreadystatechange", DOMContentLoaded ); |
| 936 | + jQuery.ready(); |
| 937 | + } |
| 938 | + }; |
| 939 | +} |
| 940 | + |
| 941 | +// The DOM ready check for Internet Explorer |
| 942 | +function doScrollCheck() { |
| 943 | + if ( jQuery.isReady ) { |
| 944 | + return; |
| 945 | + } |
| 946 | + |
| 947 | + try { |
| 948 | + // If IE is used, use the trick by Diego Perini |
| 949 | + // http://javascript.nwbox.com/IEContentLoaded/ |
| 950 | + document.documentElement.doScroll("left"); |
| 951 | + } catch(e) { |
| 952 | + setTimeout( doScrollCheck, 1 ); |
| 953 | + return; |
| 954 | + } |
| 955 | + |
| 956 | + // and execute any waiting functions |
| 957 | + jQuery.ready(); |
| 958 | +} |
| 959 | + |
| 960 | +// Expose jQuery as an AMD module, but only for AMD loaders that |
| 961 | +// understand the issues with loading multiple versions of jQuery |
| 962 | +// in a page that all might call define(). The loader will indicate |
| 963 | +// they have special allowances for multiple jQuery versions by |
| 964 | +// specifying define.amd.jQuery = true. Register as a named module, |
| 965 | +// since jQuery can be concatenated with other files that may use define, |
| 966 | +// but not use a proper concatenation script that understands anonymous |
| 967 | +// AMD modules. A named AMD is safest and most robust way to register. |
| 968 | +// Lowercase jquery is used because AMD module names are derived from |
| 969 | +// file names, and jQuery is normally delivered in a lowercase file name. |
| 970 | +if ( typeof define === "function" && define.amd && define.amd.jQuery ) { |
| 971 | + define( "jquery", [], function () { return jQuery; } ); |
| 972 | +} |
| 973 | + |
| 974 | +return jQuery; |
| 975 | + |
| 976 | +})(); |
| 977 | + |
| 978 | + |
| 979 | +// String to Object flags format cache |
| 980 | +var flagsCache = {}; |
| 981 | + |
| 982 | +// Convert String-formatted flags into Object-formatted ones and store in cache |
| 983 | +function createFlags( flags ) { |
| 984 | + var object = flagsCache[ flags ] = {}, |
| 985 | + i, length; |
| 986 | + flags = flags.split( /\s+/ ); |
| 987 | + for ( i = 0, length = flags.length; i < length; i++ ) { |
| 988 | + object[ flags[i] ] = true; |
| 989 | + } |
| 990 | + return object; |
| 991 | +} |
| 992 | + |
| 993 | +/* |
| 994 | + * Create a callback list using the following parameters: |
| 995 | + * |
| 996 | + * flags: an optional list of space-separated flags that will change how |
| 997 | + * the callback list behaves |
| 998 | + * |
| 999 | + * By default a callback list will act like an event callback list and can be |
| 1000 | + * "fired" multiple times. |
| 1001 | + * |
| 1002 | + * Possible flags: |
| 1003 | + * |
| 1004 | + * once: will ensure the callback list can only be fired once (like a Deferred) |
| 1005 | + * |
| 1006 | + * memory: will keep track of previous values and will call any callback added |
| 1007 | + * after the list has been fired right away with the latest "memorized" |
| 1008 | + * values (like a Deferred) |
| 1009 | + * |
| 1010 | + * unique: will ensure a callback can only be added once (no duplicate in the list) |
| 1011 | + * |
| 1012 | + * stopOnFalse: interrupt callings when a callback returns false |
| 1013 | + * |
| 1014 | + */ |
| 1015 | +jQuery.Callbacks = function( flags ) { |
| 1016 | + |
| 1017 | + // Convert flags from String-formatted to Object-formatted |
| 1018 | + // (we check in cache first) |
| 1019 | + flags = flags ? ( flagsCache[ flags ] || createFlags( flags ) ) : {}; |
| 1020 | + |
| 1021 | + var // Actual callback list |
| 1022 | + list = [], |
| 1023 | + // Stack of fire calls for repeatable lists |
| 1024 | + stack = [], |
| 1025 | + // Last fire value (for non-forgettable lists) |
| 1026 | + memory, |
| 1027 | + // Flag to know if list is currently firing |
| 1028 | + firing, |
| 1029 | + // First callback to fire (used internally by add and fireWith) |
| 1030 | + firingStart, |
| 1031 | + // End of the loop when firing |
| 1032 | + firingLength, |
| 1033 | + // Index of currently firing callback (modified by remove if needed) |
| 1034 | + firingIndex, |
| 1035 | + // Add one or several callbacks to the list |
| 1036 | + add = function( args ) { |
| 1037 | + var i, |
| 1038 | + length, |
| 1039 | + elem, |
| 1040 | + type, |
| 1041 | + actual; |
| 1042 | + for ( i = 0, length = args.length; i < length; i++ ) { |
| 1043 | + elem = args[ i ]; |
| 1044 | + type = jQuery.type( elem ); |
| 1045 | + if ( type === "array" ) { |
| 1046 | + // Inspect recursively |
| 1047 | + add( elem ); |
| 1048 | + } else if ( type === "function" ) { |
| 1049 | + // Add if not in unique mode and callback is not in |
| 1050 | + if ( !flags.unique || !self.has( elem ) ) { |
| 1051 | + list.push( elem ); |
| 1052 | + } |
| 1053 | + } |
| 1054 | + } |
| 1055 | + }, |
| 1056 | + // Fire callbacks |
| 1057 | + fire = function( context, args ) { |
| 1058 | + args = args || []; |
| 1059 | + memory = !flags.memory || [ context, args ]; |
| 1060 | + firing = true; |
| 1061 | + firingIndex = firingStart || 0; |
| 1062 | + firingStart = 0; |
| 1063 | + firingLength = list.length; |
| 1064 | + for ( ; list && firingIndex < firingLength; firingIndex++ ) { |
| 1065 | + if ( list[ firingIndex ].apply( context, args ) === false && flags.stopOnFalse ) { |
| 1066 | + memory = true; // Mark as halted |
| 1067 | + break; |
| 1068 | + } |
| 1069 | + } |
| 1070 | + firing = false; |
| 1071 | + if ( list ) { |
| 1072 | + if ( !flags.once ) { |
| 1073 | + if ( stack && stack.length ) { |
| 1074 | + memory = stack.shift(); |
| 1075 | + self.fireWith( memory[ 0 ], memory[ 1 ] ); |
| 1076 | + } |
| 1077 | + } else if ( memory === true ) { |
| 1078 | + self.disable(); |
| 1079 | + } else { |
| 1080 | + list = []; |
| 1081 | + } |
| 1082 | + } |
| 1083 | + }, |
| 1084 | + // Actual Callbacks object |
| 1085 | + self = { |
| 1086 | + // Add a callback or a collection of callbacks to the list |
| 1087 | + add: function() { |
| 1088 | + if ( list ) { |
| 1089 | + var length = list.length; |
| 1090 | + add( arguments ); |
| 1091 | + // Do we need to add the callbacks to the |
| 1092 | + // current firing batch? |
| 1093 | + if ( firing ) { |
| 1094 | + firingLength = list.length; |
| 1095 | + // With memory, if we're not firing then |
| 1096 | + // we should call right away, unless previous |
| 1097 | + // firing was halted (stopOnFalse) |
| 1098 | + } else if ( memory && memory !== true ) { |
| 1099 | + firingStart = length; |
| 1100 | + fire( memory[ 0 ], memory[ 1 ] ); |
| 1101 | + } |
| 1102 | + } |
| 1103 | + return this; |
| 1104 | + }, |
| 1105 | + // Remove a callback from the list |
| 1106 | + remove: function() { |
| 1107 | + if ( list ) { |
| 1108 | + var args = arguments, |
| 1109 | + argIndex = 0, |
| 1110 | + argLength = args.length; |
| 1111 | + for ( ; argIndex < argLength ; argIndex++ ) { |
| 1112 | + for ( var i = 0; i < list.length; i++ ) { |
| 1113 | + if ( args[ argIndex ] === list[ i ] ) { |
| 1114 | + // Handle firingIndex and firingLength |
| 1115 | + if ( firing ) { |
| 1116 | + if ( i <= firingLength ) { |
| 1117 | + firingLength--; |
| 1118 | + if ( i <= firingIndex ) { |
| 1119 | + firingIndex--; |
| 1120 | + } |
| 1121 | + } |
| 1122 | + } |
| 1123 | + // Remove the element |
| 1124 | + list.splice( i--, 1 ); |
| 1125 | + // If we have some unicity property then |
| 1126 | + // we only need to do this once |
| 1127 | + if ( flags.unique ) { |
| 1128 | + break; |
| 1129 | + } |
| 1130 | + } |
| 1131 | + } |
| 1132 | + } |
| 1133 | + } |
| 1134 | + return this; |
| 1135 | + }, |
| 1136 | + // Control if a given callback is in the list |
| 1137 | + has: function( fn ) { |
| 1138 | + if ( list ) { |
| 1139 | + var i = 0, |
| 1140 | + length = list.length; |
| 1141 | + for ( ; i < length; i++ ) { |
| 1142 | + if ( fn === list[ i ] ) { |
| 1143 | + return true; |
| 1144 | + } |
| 1145 | + } |
| 1146 | + } |
| 1147 | + return false; |
| 1148 | + }, |
| 1149 | + // Remove all callbacks from the list |
| 1150 | + empty: function() { |
| 1151 | + list = []; |
| 1152 | + return this; |
| 1153 | + }, |
| 1154 | + // Have the list do nothing anymore |
| 1155 | + disable: function() { |
| 1156 | + list = stack = memory = undefined; |
| 1157 | + return this; |
| 1158 | + }, |
| 1159 | + // Is it disabled? |
| 1160 | + disabled: function() { |
| 1161 | + return !list; |
| 1162 | + }, |
| 1163 | + // Lock the list in its current state |
| 1164 | + lock: function() { |
| 1165 | + stack = undefined; |
| 1166 | + if ( !memory || memory === true ) { |
| 1167 | + self.disable(); |
| 1168 | + } |
| 1169 | + return this; |
| 1170 | + }, |
| 1171 | + // Is it locked? |
| 1172 | + locked: function() { |
| 1173 | + return !stack; |
| 1174 | + }, |
| 1175 | + // Call all callbacks with the given context and arguments |
| 1176 | + fireWith: function( context, args ) { |
| 1177 | + if ( stack ) { |
| 1178 | + if ( firing ) { |
| 1179 | + if ( !flags.once ) { |
| 1180 | + stack.push( [ context, args ] ); |
| 1181 | + } |
| 1182 | + } else if ( !( flags.once && memory ) ) { |
| 1183 | + fire( context, args ); |
| 1184 | + } |
| 1185 | + } |
| 1186 | + return this; |
| 1187 | + }, |
| 1188 | + // Call all the callbacks with the given arguments |
| 1189 | + fire: function() { |
| 1190 | + self.fireWith( this, arguments ); |
| 1191 | + return this; |
| 1192 | + }, |
| 1193 | + // To know if the callbacks have already been called at least once |
| 1194 | + fired: function() { |
| 1195 | + return !!memory; |
| 1196 | + } |
| 1197 | + }; |
| 1198 | + |
| 1199 | + return self; |
| 1200 | +}; |
| 1201 | + |
| 1202 | + |
| 1203 | + |
| 1204 | + |
| 1205 | +var // Static reference to slice |
| 1206 | + sliceDeferred = [].slice; |
| 1207 | + |
| 1208 | +jQuery.extend({ |
| 1209 | + |
| 1210 | + Deferred: function( func ) { |
| 1211 | + var doneList = jQuery.Callbacks( "once memory" ), |
| 1212 | + failList = jQuery.Callbacks( "once memory" ), |
| 1213 | + progressList = jQuery.Callbacks( "memory" ), |
| 1214 | + state = "pending", |
| 1215 | + lists = { |
| 1216 | + resolve: doneList, |
| 1217 | + reject: failList, |
| 1218 | + notify: progressList |
| 1219 | + }, |
| 1220 | + promise = { |
| 1221 | + done: doneList.add, |
| 1222 | + fail: failList.add, |
| 1223 | + progress: progressList.add, |
| 1224 | + |
| 1225 | + state: function() { |
| 1226 | + return state; |
| 1227 | + }, |
| 1228 | + |
| 1229 | + // Deprecated |
| 1230 | + isResolved: doneList.fired, |
| 1231 | + isRejected: failList.fired, |
| 1232 | + |
| 1233 | + then: function( doneCallbacks, failCallbacks, progressCallbacks ) { |
| 1234 | + deferred.done( doneCallbacks ).fail( failCallbacks ).progress( progressCallbacks ); |
| 1235 | + return this; |
| 1236 | + }, |
| 1237 | + always: function() { |
| 1238 | + return deferred.done.apply( deferred, arguments ).fail.apply( deferred, arguments ); |
| 1239 | + }, |
| 1240 | + pipe: function( fnDone, fnFail, fnProgress ) { |
| 1241 | + return jQuery.Deferred(function( newDefer ) { |
| 1242 | + jQuery.each( { |
| 1243 | + done: [ fnDone, "resolve" ], |
| 1244 | + fail: [ fnFail, "reject" ], |
| 1245 | + progress: [ fnProgress, "notify" ] |
| 1246 | + }, function( handler, data ) { |
| 1247 | + var fn = data[ 0 ], |
| 1248 | + action = data[ 1 ], |
| 1249 | + returned; |
| 1250 | + if ( jQuery.isFunction( fn ) ) { |
| 1251 | + deferred[ handler ](function() { |
| 1252 | + returned = fn.apply( this, arguments ); |
| 1253 | + if ( returned && jQuery.isFunction( returned.promise ) ) { |
| 1254 | + returned.promise().then( newDefer.resolve, newDefer.reject, newDefer.notify ); |
| 1255 | + } else { |
| 1256 | + newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] ); |
| 1257 | + } |
| 1258 | + }); |
| 1259 | + } else { |
| 1260 | + deferred[ handler ]( newDefer[ action ] ); |
| 1261 | + } |
| 1262 | + }); |
| 1263 | + }).promise(); |
| 1264 | + }, |
| 1265 | + // Get a promise for this deferred |
| 1266 | + // If obj is provided, the promise aspect is added to the object |
| 1267 | + promise: function( obj ) { |
| 1268 | + if ( obj == null ) { |
| 1269 | + obj = promise; |
| 1270 | + } else { |
| 1271 | + for ( var key in promise ) { |
| 1272 | + obj[ key ] = promise[ key ]; |
| 1273 | + } |
| 1274 | + } |
| 1275 | + return obj; |
| 1276 | + } |
| 1277 | + }, |
| 1278 | + deferred = promise.promise({}), |
| 1279 | + key; |
| 1280 | + |
| 1281 | + for ( key in lists ) { |
| 1282 | + deferred[ key ] = lists[ key ].fire; |
| 1283 | + deferred[ key + "With" ] = lists[ key ].fireWith; |
| 1284 | + } |
| 1285 | + |
| 1286 | + // Handle state |
| 1287 | + deferred.done( function() { |
| 1288 | + state = "resolved"; |
| 1289 | + }, failList.disable, progressList.lock ).fail( function() { |
| 1290 | + state = "rejected"; |
| 1291 | + }, doneList.disable, progressList.lock ); |
| 1292 | + |
| 1293 | + // Call given func if any |
| 1294 | + if ( func ) { |
| 1295 | + func.call( deferred, deferred ); |
| 1296 | + } |
| 1297 | + |
| 1298 | + // All done! |
| 1299 | + return deferred; |
| 1300 | + }, |
| 1301 | + |
| 1302 | + // Deferred helper |
| 1303 | + when: function( firstParam ) { |
| 1304 | + var args = sliceDeferred.call( arguments, 0 ), |
| 1305 | + i = 0, |
| 1306 | + length = args.length, |
| 1307 | + pValues = new Array( length ), |
| 1308 | + count = length, |
| 1309 | + pCount = length, |
| 1310 | + deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ? |
| 1311 | + firstParam : |
| 1312 | + jQuery.Deferred(), |
| 1313 | + promise = deferred.promise(); |
| 1314 | + function resolveFunc( i ) { |
| 1315 | + return function( value ) { |
| 1316 | + args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value; |
| 1317 | + if ( !( --count ) ) { |
| 1318 | + deferred.resolveWith( deferred, args ); |
| 1319 | + } |
| 1320 | + }; |
| 1321 | + } |
| 1322 | + function progressFunc( i ) { |
| 1323 | + return function( value ) { |
| 1324 | + pValues[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value; |
| 1325 | + deferred.notifyWith( promise, pValues ); |
| 1326 | + }; |
| 1327 | + } |
| 1328 | + if ( length > 1 ) { |
| 1329 | + for ( ; i < length; i++ ) { |
| 1330 | + if ( args[ i ] && args[ i ].promise && jQuery.isFunction( args[ i ].promise ) ) { |
| 1331 | + args[ i ].promise().then( resolveFunc(i), deferred.reject, progressFunc(i) ); |
| 1332 | + } else { |
| 1333 | + --count; |
| 1334 | + } |
| 1335 | + } |
| 1336 | + if ( !count ) { |
| 1337 | + deferred.resolveWith( deferred, args ); |
| 1338 | + } |
| 1339 | + } else if ( deferred !== firstParam ) { |
| 1340 | + deferred.resolveWith( deferred, length ? [ firstParam ] : [] ); |
| 1341 | + } |
| 1342 | + return promise; |
| 1343 | + } |
| 1344 | +}); |
| 1345 | + |
| 1346 | + |
| 1347 | + |
| 1348 | + |
| 1349 | +jQuery.support = (function() { |
| 1350 | + |
| 1351 | + var div = document.createElement( "div" ), |
| 1352 | + documentElement = document.documentElement, |
| 1353 | + all, |
| 1354 | + a, |
| 1355 | + select, |
| 1356 | + opt, |
| 1357 | + input, |
| 1358 | + marginDiv, |
| 1359 | + support, |
| 1360 | + fragment, |
| 1361 | + body, |
| 1362 | + testElementParent, |
| 1363 | + testElement, |
| 1364 | + testElementStyle, |
| 1365 | + tds, |
| 1366 | + events, |
| 1367 | + eventName, |
| 1368 | + i, |
| 1369 | + isSupported; |
| 1370 | + |
| 1371 | + // Preliminary tests |
| 1372 | + div.setAttribute("className", "t"); |
| 1373 | + div.innerHTML = " <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/><nav></nav>"; |
| 1374 | + |
| 1375 | + |
| 1376 | + all = div.getElementsByTagName( "*" ); |
| 1377 | + a = div.getElementsByTagName( "a" )[ 0 ]; |
| 1378 | + |
| 1379 | + // Can't get basic test support |
| 1380 | + if ( !all || !all.length || !a ) { |
| 1381 | + return {}; |
| 1382 | + } |
| 1383 | + |
| 1384 | + // First batch of supports tests |
| 1385 | + select = document.createElement( "select" ); |
| 1386 | + opt = select.appendChild( document.createElement("option") ); |
| 1387 | + input = div.getElementsByTagName( "input" )[ 0 ]; |
| 1388 | + |
| 1389 | + support = { |
| 1390 | + // IE strips leading whitespace when .innerHTML is used |
| 1391 | + leadingWhitespace: ( div.firstChild.nodeType === 3 ), |
| 1392 | + |
| 1393 | + // Make sure that tbody elements aren't automatically inserted |
| 1394 | + // IE will insert them into empty tables |
| 1395 | + tbody: !div.getElementsByTagName( "tbody" ).length, |
| 1396 | + |
| 1397 | + // Make sure that link elements get serialized correctly by innerHTML |
| 1398 | + // This requires a wrapper element in IE |
| 1399 | + htmlSerialize: !!div.getElementsByTagName( "link" ).length, |
| 1400 | + |
| 1401 | + // Get the style information from getAttribute |
| 1402 | + // (IE uses .cssText instead) |
| 1403 | + style: /top/.test( a.getAttribute("style") ), |
| 1404 | + |
| 1405 | + // Make sure that URLs aren't manipulated |
| 1406 | + // (IE normalizes it by default) |
| 1407 | + hrefNormalized: ( a.getAttribute( "href" ) === "/a" ), |
| 1408 | + |
| 1409 | + // Make sure that element opacity exists |
| 1410 | + // (IE uses filter instead) |
| 1411 | + // Use a regex to work around a WebKit issue. See #5145 |
| 1412 | + opacity: /^0.55/.test( a.style.opacity ), |
| 1413 | + |
| 1414 | + // Verify style float existence |
| 1415 | + // (IE uses styleFloat instead of cssFloat) |
| 1416 | + cssFloat: !!a.style.cssFloat, |
| 1417 | + |
| 1418 | + // Make sure unknown elements (like HTML5 elems) are handled appropriately |
| 1419 | + unknownElems: !!div.getElementsByTagName( "nav" ).length, |
| 1420 | + |
| 1421 | + // Make sure that if no value is specified for a checkbox |
| 1422 | + // that it defaults to "on". |
| 1423 | + // (WebKit defaults to "" instead) |
| 1424 | + checkOn: ( input.value === "on" ), |
| 1425 | + |
| 1426 | + // Make sure that a selected-by-default option has a working selected property. |
| 1427 | + // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) |
| 1428 | + optSelected: opt.selected, |
| 1429 | + |
| 1430 | + // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7) |
| 1431 | + getSetAttribute: div.className !== "t", |
| 1432 | + |
| 1433 | + // Tests for enctype support on a form(#6743) |
| 1434 | + enctype: !!document.createElement("form").enctype, |
| 1435 | + |
| 1436 | + // Will be defined later |
| 1437 | + submitBubbles: true, |
| 1438 | + changeBubbles: true, |
| 1439 | + focusinBubbles: false, |
| 1440 | + deleteExpando: true, |
| 1441 | + noCloneEvent: true, |
| 1442 | + inlineBlockNeedsLayout: false, |
| 1443 | + shrinkWrapBlocks: false, |
| 1444 | + reliableMarginRight: true |
| 1445 | + }; |
| 1446 | + |
| 1447 | + // Make sure checked status is properly cloned |
| 1448 | + input.checked = true; |
| 1449 | + support.noCloneChecked = input.cloneNode( true ).checked; |
| 1450 | + |
| 1451 | + // Make sure that the options inside disabled selects aren't marked as disabled |
| 1452 | + // (WebKit marks them as disabled) |
| 1453 | + select.disabled = true; |
| 1454 | + support.optDisabled = !opt.disabled; |
| 1455 | + |
| 1456 | + // Test to see if it's possible to delete an expando from an element |
| 1457 | + // Fails in Internet Explorer |
| 1458 | + try { |
| 1459 | + delete div.test; |
| 1460 | + } catch( e ) { |
| 1461 | + support.deleteExpando = false; |
| 1462 | + } |
| 1463 | + |
| 1464 | + if ( !div.addEventListener && div.attachEvent && div.fireEvent ) { |
| 1465 | + div.attachEvent( "onclick", function() { |
| 1466 | + // Cloning a node shouldn't copy over any |
| 1467 | + // bound event handlers (IE does this) |
| 1468 | + support.noCloneEvent = false; |
| 1469 | + }); |
| 1470 | + div.cloneNode( true ).fireEvent( "onclick" ); |
| 1471 | + } |
| 1472 | + |
| 1473 | + // Check if a radio maintains its value |
| 1474 | + // after being appended to the DOM |
| 1475 | + input = document.createElement("input"); |
| 1476 | + input.value = "t"; |
| 1477 | + input.setAttribute("type", "radio"); |
| 1478 | + support.radioValue = input.value === "t"; |
| 1479 | + |
| 1480 | + input.setAttribute("checked", "checked"); |
| 1481 | + div.appendChild( input ); |
| 1482 | + fragment = document.createDocumentFragment(); |
| 1483 | + fragment.appendChild( div.lastChild ); |
| 1484 | + |
| 1485 | + // WebKit doesn't clone checked state correctly in fragments |
| 1486 | + support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked; |
| 1487 | + |
| 1488 | + div.innerHTML = ""; |
| 1489 | + |
| 1490 | + // Figure out if the W3C box model works as expected |
| 1491 | + div.style.width = div.style.paddingLeft = "1px"; |
| 1492 | + |
| 1493 | + // We don't want to do body-related feature tests on frameset |
| 1494 | + // documents, which lack a body. So we use |
| 1495 | + // document.getElementsByTagName("body")[0], which is undefined in |
| 1496 | + // frameset documents, while document.body isn’t. (7398) |
| 1497 | + body = document.getElementsByTagName("body")[ 0 ]; |
| 1498 | + // We use our own, invisible, body unless the body is already present |
| 1499 | + // in which case we use a div (#9239) |
| 1500 | + testElement = document.createElement( body ? "div" : "body" ); |
| 1501 | + testElementStyle = { |
| 1502 | + visibility: "hidden", |
| 1503 | + width: 0, |
| 1504 | + height: 0, |
| 1505 | + border: 0, |
| 1506 | + margin: 0, |
| 1507 | + background: "none" |
| 1508 | + }; |
| 1509 | + if ( body ) { |
| 1510 | + jQuery.extend( testElementStyle, { |
| 1511 | + position: "absolute", |
| 1512 | + left: "-999px", |
| 1513 | + top: "-999px" |
| 1514 | + }); |
| 1515 | + } |
| 1516 | + for ( i in testElementStyle ) { |
| 1517 | + testElement.style[ i ] = testElementStyle[ i ]; |
| 1518 | + } |
| 1519 | + testElement.appendChild( div ); |
| 1520 | + testElementParent = body || documentElement; |
| 1521 | + testElementParent.insertBefore( testElement, testElementParent.firstChild ); |
| 1522 | + |
| 1523 | + // Check if a disconnected checkbox will retain its checked |
| 1524 | + // value of true after appended to the DOM (IE6/7) |
| 1525 | + support.appendChecked = input.checked; |
| 1526 | + |
| 1527 | + support.boxModel = div.offsetWidth === 2; |
| 1528 | + |
| 1529 | + if ( "zoom" in div.style ) { |
| 1530 | + // Check if natively block-level elements act like inline-block |
| 1531 | + // elements when setting their display to 'inline' and giving |
| 1532 | + // them layout |
| 1533 | + // (IE < 8 does this) |
| 1534 | + div.style.display = "inline"; |
| 1535 | + div.style.zoom = 1; |
| 1536 | + support.inlineBlockNeedsLayout = ( div.offsetWidth === 2 ); |
| 1537 | + |
| 1538 | + // Check if elements with layout shrink-wrap their children |
| 1539 | + // (IE 6 does this) |
| 1540 | + div.style.display = ""; |
| 1541 | + div.innerHTML = "<div style='width:4px;'></div>"; |
| 1542 | + support.shrinkWrapBlocks = ( div.offsetWidth !== 2 ); |
| 1543 | + } |
| 1544 | + |
| 1545 | + div.innerHTML = "<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>"; |
| 1546 | + tds = div.getElementsByTagName( "td" ); |
| 1547 | + |
| 1548 | + // Check if table cells still have offsetWidth/Height when they are set |
| 1549 | + // to display:none and there are still other visible table cells in a |
| 1550 | + // table row; if so, offsetWidth/Height are not reliable for use when |
| 1551 | + // determining if an element has been hidden directly using |
| 1552 | + // display:none (it is still safe to use offsets if a parent element is |
| 1553 | + // hidden; don safety goggles and see bug #4512 for more information). |
| 1554 | + // (only IE 8 fails this test) |
| 1555 | + isSupported = ( tds[ 0 ].offsetHeight === 0 ); |
| 1556 | + |
| 1557 | + tds[ 0 ].style.display = ""; |
| 1558 | + tds[ 1 ].style.display = "none"; |
| 1559 | + |
| 1560 | + // Check if empty table cells still have offsetWidth/Height |
| 1561 | + // (IE < 8 fail this test) |
| 1562 | + support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 ); |
| 1563 | + div.innerHTML = ""; |
| 1564 | + |
| 1565 | + // Check if div with explicit width and no margin-right incorrectly |
| 1566 | + // gets computed margin-right based on width of container. For more |
| 1567 | + // info see bug #3333 |
| 1568 | + // Fails in WebKit before Feb 2011 nightlies |
| 1569 | + // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right |
| 1570 | + if ( document.defaultView && document.defaultView.getComputedStyle ) { |
| 1571 | + marginDiv = document.createElement( "div" ); |
| 1572 | + marginDiv.style.width = "0"; |
| 1573 | + marginDiv.style.marginRight = "0"; |
| 1574 | + div.appendChild( marginDiv ); |
| 1575 | + support.reliableMarginRight = |
| 1576 | + ( parseInt( ( document.defaultView.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0; |
| 1577 | + } |
| 1578 | + |
| 1579 | + // Technique from Juriy Zaytsev |
| 1580 | + // http://perfectionkills.com/detecting-event-support-without-browser-sniffing/ |
| 1581 | + // We only care about the case where non-standard event systems |
| 1582 | + // are used, namely in IE. Short-circuiting here helps us to |
| 1583 | + // avoid an eval call (in setAttribute) which can cause CSP |
| 1584 | + // to go haywire. See: https://developer.mozilla.org/en/Security/CSP |
| 1585 | + if ( div.attachEvent ) { |
| 1586 | + for( i in { |
| 1587 | + submit: 1, |
| 1588 | + change: 1, |
| 1589 | + focusin: 1 |
| 1590 | + } ) { |
| 1591 | + eventName = "on" + i; |
| 1592 | + isSupported = ( eventName in div ); |
| 1593 | + if ( !isSupported ) { |
| 1594 | + div.setAttribute( eventName, "return;" ); |
| 1595 | + isSupported = ( typeof div[ eventName ] === "function" ); |
| 1596 | + } |
| 1597 | + support[ i + "Bubbles" ] = isSupported; |
| 1598 | + } |
| 1599 | + } |
| 1600 | + |
| 1601 | + // Run fixed position tests at doc ready to avoid a crash |
| 1602 | + // related to the invisible body in IE8 |
| 1603 | + jQuery(function() { |
| 1604 | + var container, outer, inner, table, td, offsetSupport, |
| 1605 | + conMarginTop = 1, |
| 1606 | + ptlm = "position:absolute;top:0;left:0;width:1px;height:1px;margin:0;", |
| 1607 | + vb = "visibility:hidden;border:0;", |
| 1608 | + style = "style='" + ptlm + "border:5px solid #000;padding:0;'", |
| 1609 | + html = "<div " + style + "><div></div></div>" + |
| 1610 | + "<table " + style + " cellpadding='0' cellspacing='0'>" + |
| 1611 | + "<tr><td></td></tr></table>"; |
| 1612 | + |
| 1613 | + // Reconstruct a container |
| 1614 | + body = document.getElementsByTagName("body")[0]; |
| 1615 | + if ( !body ) { |
| 1616 | + // Return for frameset docs that don't have a body |
| 1617 | + // These tests cannot be done |
| 1618 | + return; |
| 1619 | + } |
| 1620 | + |
| 1621 | + container = document.createElement("div"); |
| 1622 | + container.style.cssText = vb + "width:0;height:0;position:static;top:0;marginTop:" + conMarginTop + "px"; |
| 1623 | + body.insertBefore( container, body.firstChild ); |
| 1624 | + |
| 1625 | + // Construct a test element |
| 1626 | + testElement = document.createElement("div"); |
| 1627 | + testElement.style.cssText = ptlm + vb; |
| 1628 | + |
| 1629 | + testElement.innerHTML = html; |
| 1630 | + container.appendChild( testElement ); |
| 1631 | + outer = testElement.firstChild; |
| 1632 | + inner = outer.firstChild; |
| 1633 | + td = outer.nextSibling.firstChild.firstChild; |
| 1634 | + |
| 1635 | + offsetSupport = { |
| 1636 | + doesNotAddBorder: ( inner.offsetTop !== 5 ), |
| 1637 | + doesAddBorderForTableAndCells: ( td.offsetTop === 5 ) |
| 1638 | + }; |
| 1639 | + |
| 1640 | + inner.style.position = "fixed"; |
| 1641 | + inner.style.top = "20px"; |
| 1642 | + |
| 1643 | + // safari subtracts parent border width here which is 5px |
| 1644 | + offsetSupport.fixedPosition = ( inner.offsetTop === 20 || inner.offsetTop === 15 ); |
| 1645 | + inner.style.position = inner.style.top = ""; |
| 1646 | + |
| 1647 | + outer.style.overflow = "hidden"; |
| 1648 | + outer.style.position = "relative"; |
| 1649 | + |
| 1650 | + offsetSupport.subtractsBorderForOverflowNotVisible = ( inner.offsetTop === -5 ); |
| 1651 | + offsetSupport.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== conMarginTop ); |
| 1652 | + |
| 1653 | + body.removeChild( container ); |
| 1654 | + testElement = container = null; |
| 1655 | + |
| 1656 | + jQuery.extend( support, offsetSupport ); |
| 1657 | + }); |
| 1658 | + |
| 1659 | + testElement.innerHTML = ""; |
| 1660 | + testElementParent.removeChild( testElement ); |
| 1661 | + |
| 1662 | + // Null connected elements to avoid leaks in IE |
| 1663 | + testElement = fragment = select = opt = body = marginDiv = div = input = null; |
| 1664 | + |
| 1665 | + return support; |
| 1666 | +})(); |
| 1667 | + |
| 1668 | +// Keep track of boxModel |
| 1669 | +jQuery.boxModel = jQuery.support.boxModel; |
| 1670 | + |
| 1671 | + |
| 1672 | + |
| 1673 | + |
| 1674 | +var rbrace = /^(?:\{.*\}|\[.*\])$/, |
| 1675 | + rmultiDash = /([A-Z])/g; |
| 1676 | + |
| 1677 | +jQuery.extend({ |
| 1678 | + cache: {}, |
| 1679 | + |
| 1680 | + // Please use with caution |
| 1681 | + uuid: 0, |
| 1682 | + |
| 1683 | + // Unique for each copy of jQuery on the page |
| 1684 | + // Non-digits removed to match rinlinejQuery |
| 1685 | + expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ), |
| 1686 | + |
| 1687 | + // The following elements throw uncatchable exceptions if you |
| 1688 | + // attempt to add expando properties to them. |
| 1689 | + noData: { |
| 1690 | + "embed": true, |
| 1691 | + // Ban all objects except for Flash (which handle expandos) |
| 1692 | + "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000", |
| 1693 | + "applet": true |
| 1694 | + }, |
| 1695 | + |
| 1696 | + hasData: function( elem ) { |
| 1697 | + elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ]; |
| 1698 | + return !!elem && !isEmptyDataObject( elem ); |
| 1699 | + }, |
| 1700 | + |
| 1701 | + data: function( elem, name, data, pvt /* Internal Use Only */ ) { |
| 1702 | + if ( !jQuery.acceptData( elem ) ) { |
| 1703 | + return; |
| 1704 | + } |
| 1705 | + |
| 1706 | + var privateCache, thisCache, ret, |
| 1707 | + internalKey = jQuery.expando, |
| 1708 | + getByName = typeof name === "string", |
| 1709 | + |
| 1710 | + // We have to handle DOM nodes and JS objects differently because IE6-7 |
| 1711 | + // can't GC object references properly across the DOM-JS boundary |
| 1712 | + isNode = elem.nodeType, |
| 1713 | + |
| 1714 | + // Only DOM nodes need the global jQuery cache; JS object data is |
| 1715 | + // attached directly to the object so GC can occur automatically |
| 1716 | + cache = isNode ? jQuery.cache : elem, |
| 1717 | + |
| 1718 | + // Only defining an ID for JS objects if its cache already exists allows |
| 1719 | + // the code to shortcut on the same path as a DOM node with no cache |
| 1720 | + id = isNode ? elem[ jQuery.expando ] : elem[ jQuery.expando ] && jQuery.expando, |
| 1721 | + isEvents = name === "events"; |
| 1722 | + |
| 1723 | + // Avoid doing any more work than we need to when trying to get data on an |
| 1724 | + // object that has no data at all |
| 1725 | + if ( (!id || !cache[id] || (!isEvents && !pvt && !cache[id].data)) && getByName && data === undefined ) { |
| 1726 | + return; |
| 1727 | + } |
| 1728 | + |
| 1729 | + if ( !id ) { |
| 1730 | + // Only DOM nodes need a new unique ID for each element since their data |
| 1731 | + // ends up in the global cache |
| 1732 | + if ( isNode ) { |
| 1733 | + elem[ jQuery.expando ] = id = ++jQuery.uuid; |
| 1734 | + } else { |
| 1735 | + id = jQuery.expando; |
| 1736 | + } |
| 1737 | + } |
| 1738 | + |
| 1739 | + if ( !cache[ id ] ) { |
| 1740 | + cache[ id ] = {}; |
| 1741 | + |
| 1742 | + // Avoids exposing jQuery metadata on plain JS objects when the object |
| 1743 | + // is serialized using JSON.stringify |
| 1744 | + if ( !isNode ) { |
| 1745 | + cache[ id ].toJSON = jQuery.noop; |
| 1746 | + } |
| 1747 | + } |
| 1748 | + |
| 1749 | + // An object can be passed to jQuery.data instead of a key/value pair; this gets |
| 1750 | + // shallow copied over onto the existing cache |
| 1751 | + if ( typeof name === "object" || typeof name === "function" ) { |
| 1752 | + if ( pvt ) { |
| 1753 | + cache[ id ] = jQuery.extend( cache[ id ], name ); |
| 1754 | + } else { |
| 1755 | + cache[ id ].data = jQuery.extend( cache[ id ].data, name ); |
| 1756 | + } |
| 1757 | + } |
| 1758 | + |
| 1759 | + privateCache = thisCache = cache[ id ]; |
| 1760 | + |
| 1761 | + // jQuery data() is stored in a separate object inside the object's internal data |
| 1762 | + // cache in order to avoid key collisions between internal data and user-defined |
| 1763 | + // data. |
| 1764 | + if ( !pvt ) { |
| 1765 | + if ( !thisCache.data ) { |
| 1766 | + thisCache.data = {}; |
| 1767 | + } |
| 1768 | + |
| 1769 | + thisCache = thisCache.data; |
| 1770 | + } |
| 1771 | + |
| 1772 | + if ( data !== undefined ) { |
| 1773 | + thisCache[ jQuery.camelCase( name ) ] = data; |
| 1774 | + } |
| 1775 | + |
| 1776 | + // Users should not attempt to inspect the internal events object using jQuery.data, |
| 1777 | + // it is undocumented and subject to change. But does anyone listen? No. |
| 1778 | + if ( isEvents && !thisCache[ name ] ) { |
| 1779 | + return privateCache.events; |
| 1780 | + } |
| 1781 | + |
| 1782 | + // Check for both converted-to-camel and non-converted data property names |
| 1783 | + // If a data property was specified |
| 1784 | + if ( getByName ) { |
| 1785 | + |
| 1786 | + // First Try to find as-is property data |
| 1787 | + ret = thisCache[ name ]; |
| 1788 | + |
| 1789 | + // Test for null|undefined property data |
| 1790 | + if ( ret == null ) { |
| 1791 | + |
| 1792 | + // Try to find the camelCased property |
| 1793 | + ret = thisCache[ jQuery.camelCase( name ) ]; |
| 1794 | + } |
| 1795 | + } else { |
| 1796 | + ret = thisCache; |
| 1797 | + } |
| 1798 | + |
| 1799 | + return ret; |
| 1800 | + }, |
| 1801 | + |
| 1802 | + removeData: function( elem, name, pvt /* Internal Use Only */ ) { |
| 1803 | + if ( !jQuery.acceptData( elem ) ) { |
| 1804 | + return; |
| 1805 | + } |
| 1806 | + |
| 1807 | + var thisCache, i, l, |
| 1808 | + |
| 1809 | + // Reference to internal data cache key |
| 1810 | + internalKey = jQuery.expando, |
| 1811 | + |
| 1812 | + isNode = elem.nodeType, |
| 1813 | + |
| 1814 | + // See jQuery.data for more information |
| 1815 | + cache = isNode ? jQuery.cache : elem, |
| 1816 | + |
| 1817 | + // See jQuery.data for more information |
| 1818 | + id = isNode ? elem[ jQuery.expando ] : jQuery.expando; |
| 1819 | + |
| 1820 | + // If there is already no cache entry for this object, there is no |
| 1821 | + // purpose in continuing |
| 1822 | + if ( !cache[ id ] ) { |
| 1823 | + return; |
| 1824 | + } |
| 1825 | + |
| 1826 | + if ( name ) { |
| 1827 | + |
| 1828 | + thisCache = pvt ? cache[ id ] : cache[ id ].data; |
| 1829 | + |
| 1830 | + if ( thisCache ) { |
| 1831 | + |
| 1832 | + // Support space separated names |
| 1833 | + if ( jQuery.isArray( name ) ) { |
| 1834 | + name = name; |
| 1835 | + } else if ( name in thisCache ) { |
| 1836 | + name = [ name ]; |
| 1837 | + } else { |
| 1838 | + |
| 1839 | + // split the camel cased version by spaces |
| 1840 | + name = jQuery.camelCase( name ); |
| 1841 | + if ( name in thisCache ) { |
| 1842 | + name = [ name ]; |
| 1843 | + } else { |
| 1844 | + name = name.split( " " ); |
| 1845 | + } |
| 1846 | + } |
| 1847 | + |
| 1848 | + for ( i = 0, l = name.length; i < l; i++ ) { |
| 1849 | + delete thisCache[ name[i] ]; |
| 1850 | + } |
| 1851 | + |
| 1852 | + // If there is no data left in the cache, we want to continue |
| 1853 | + // and let the cache object itself get destroyed |
| 1854 | + if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) { |
| 1855 | + return; |
| 1856 | + } |
| 1857 | + } |
| 1858 | + } |
| 1859 | + |
| 1860 | + // See jQuery.data for more information |
| 1861 | + if ( !pvt ) { |
| 1862 | + delete cache[ id ].data; |
| 1863 | + |
| 1864 | + // Don't destroy the parent cache unless the internal data object |
| 1865 | + // had been the only thing left in it |
| 1866 | + if ( !isEmptyDataObject(cache[ id ]) ) { |
| 1867 | + return; |
| 1868 | + } |
| 1869 | + } |
| 1870 | + |
| 1871 | + // Browsers that fail expando deletion also refuse to delete expandos on |
| 1872 | + // the window, but it will allow it on all other JS objects; other browsers |
| 1873 | + // don't care |
| 1874 | + // Ensure that `cache` is not a window object #10080 |
| 1875 | + if ( jQuery.support.deleteExpando || !cache.setInterval ) { |
| 1876 | + delete cache[ id ]; |
| 1877 | + } else { |
| 1878 | + cache[ id ] = null; |
| 1879 | + } |
| 1880 | + |
| 1881 | + // We destroyed the cache and need to eliminate the expando on the node to avoid |
| 1882 | + // false lookups in the cache for entries that no longer exist |
| 1883 | + if ( isNode ) { |
| 1884 | + // IE does not allow us to delete expando properties from nodes, |
| 1885 | + // nor does it have a removeAttribute function on Document nodes; |
| 1886 | + // we must handle all of these cases |
| 1887 | + if ( jQuery.support.deleteExpando ) { |
| 1888 | + delete elem[ jQuery.expando ]; |
| 1889 | + } else if ( elem.removeAttribute ) { |
| 1890 | + elem.removeAttribute( jQuery.expando ); |
| 1891 | + } else { |
| 1892 | + elem[ jQuery.expando ] = null; |
| 1893 | + } |
| 1894 | + } |
| 1895 | + }, |
| 1896 | + |
| 1897 | + // For internal use only. |
| 1898 | + _data: function( elem, name, data ) { |
| 1899 | + return jQuery.data( elem, name, data, true ); |
| 1900 | + }, |
| 1901 | + |
| 1902 | + // A method for determining if a DOM node can handle the data expando |
| 1903 | + acceptData: function( elem ) { |
| 1904 | + if ( elem.nodeName ) { |
| 1905 | + var match = jQuery.noData[ elem.nodeName.toLowerCase() ]; |
| 1906 | + |
| 1907 | + if ( match ) { |
| 1908 | + return !(match === true || elem.getAttribute("classid") !== match); |
| 1909 | + } |
| 1910 | + } |
| 1911 | + |
| 1912 | + return true; |
| 1913 | + } |
| 1914 | +}); |
| 1915 | + |
| 1916 | +jQuery.fn.extend({ |
| 1917 | + data: function( key, value ) { |
| 1918 | + var parts, attr, name, |
| 1919 | + data = null; |
| 1920 | + |
| 1921 | + if ( typeof key === "undefined" ) { |
| 1922 | + if ( this.length ) { |
| 1923 | + data = jQuery.data( this[0] ); |
| 1924 | + |
| 1925 | + if ( this[0].nodeType === 1 && !jQuery._data( this[0], "parsedAttrs" ) ) { |
| 1926 | + attr = this[0].attributes; |
| 1927 | + for ( var i = 0, l = attr.length; i < l; i++ ) { |
| 1928 | + name = attr[i].name; |
| 1929 | + |
| 1930 | + if ( name.indexOf( "data-" ) === 0 ) { |
| 1931 | + name = jQuery.camelCase( name.substring(5) ); |
| 1932 | + |
| 1933 | + dataAttr( this[0], name, data[ name ] ); |
| 1934 | + } |
| 1935 | + } |
| 1936 | + jQuery._data( this[0], "parsedAttrs", true ); |
| 1937 | + } |
| 1938 | + } |
| 1939 | + |
| 1940 | + return data; |
| 1941 | + |
| 1942 | + } else if ( typeof key === "object" ) { |
| 1943 | + return this.each(function() { |
| 1944 | + jQuery.data( this, key ); |
| 1945 | + }); |
| 1946 | + } |
| 1947 | + |
| 1948 | + parts = key.split("."); |
| 1949 | + parts[1] = parts[1] ? "." + parts[1] : ""; |
| 1950 | + |
| 1951 | + if ( value === undefined ) { |
| 1952 | + data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]); |
| 1953 | + |
| 1954 | + // Try to fetch any internally stored data first |
| 1955 | + if ( data === undefined && this.length ) { |
| 1956 | + data = jQuery.data( this[0], key ); |
| 1957 | + data = dataAttr( this[0], key, data ); |
| 1958 | + } |
| 1959 | + |
| 1960 | + return data === undefined && parts[1] ? |
| 1961 | + this.data( parts[0] ) : |
| 1962 | + data; |
| 1963 | + |
| 1964 | + } else { |
| 1965 | + return this.each(function() { |
| 1966 | + var $this = jQuery( this ), |
| 1967 | + args = [ parts[0], value ]; |
| 1968 | + |
| 1969 | + $this.triggerHandler( "setData" + parts[1] + "!", args ); |
| 1970 | + jQuery.data( this, key, value ); |
| 1971 | + $this.triggerHandler( "changeData" + parts[1] + "!", args ); |
| 1972 | + }); |
| 1973 | + } |
| 1974 | + }, |
| 1975 | + |
| 1976 | + removeData: function( key ) { |
| 1977 | + return this.each(function() { |
| 1978 | + jQuery.removeData( this, key ); |
| 1979 | + }); |
| 1980 | + } |
| 1981 | +}); |
| 1982 | + |
| 1983 | +function dataAttr( elem, key, data ) { |
| 1984 | + // If nothing was found internally, try to fetch any |
| 1985 | + // data from the HTML5 data-* attribute |
| 1986 | + if ( data === undefined && elem.nodeType === 1 ) { |
| 1987 | + |
| 1988 | + var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); |
| 1989 | + |
| 1990 | + data = elem.getAttribute( name ); |
| 1991 | + |
| 1992 | + if ( typeof data === "string" ) { |
| 1993 | + try { |
| 1994 | + data = data === "true" ? true : |
| 1995 | + data === "false" ? false : |
| 1996 | + data === "null" ? null : |
| 1997 | + jQuery.isNumeric( data ) ? parseFloat( data ) : |
| 1998 | + rbrace.test( data ) ? jQuery.parseJSON( data ) : |
| 1999 | + data; |
| 2000 | + } catch( e ) {} |
| 2001 | + |
| 2002 | + // Make sure we set the data so it isn't changed later |
| 2003 | + jQuery.data( elem, key, data ); |
| 2004 | + |
| 2005 | + } else { |
| 2006 | + data = undefined; |
| 2007 | + } |
| 2008 | + } |
| 2009 | + |
| 2010 | + return data; |
| 2011 | +} |
| 2012 | + |
| 2013 | +// checks a cache object for emptiness |
| 2014 | +function isEmptyDataObject( obj ) { |
| 2015 | + for ( var name in obj ) { |
| 2016 | + |
| 2017 | + // if the public data object is empty, the private is still empty |
| 2018 | + if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) { |
| 2019 | + continue; |
| 2020 | + } |
| 2021 | + if ( name !== "toJSON" ) { |
| 2022 | + return false; |
| 2023 | + } |
| 2024 | + } |
| 2025 | + |
| 2026 | + return true; |
| 2027 | +} |
| 2028 | + |
| 2029 | + |
| 2030 | + |
| 2031 | + |
| 2032 | +function handleQueueMarkDefer( elem, type, src ) { |
| 2033 | + var deferDataKey = type + "defer", |
| 2034 | + queueDataKey = type + "queue", |
| 2035 | + markDataKey = type + "mark", |
| 2036 | + defer = jQuery._data( elem, deferDataKey ); |
| 2037 | + if ( defer && |
| 2038 | + ( src === "queue" || !jQuery._data(elem, queueDataKey) ) && |
| 2039 | + ( src === "mark" || !jQuery._data(elem, markDataKey) ) ) { |
| 2040 | + // Give room for hard-coded callbacks to fire first |
| 2041 | + // and eventually mark/queue something else on the element |
| 2042 | + setTimeout( function() { |
| 2043 | + if ( !jQuery._data( elem, queueDataKey ) && |
| 2044 | + !jQuery._data( elem, markDataKey ) ) { |
| 2045 | + jQuery.removeData( elem, deferDataKey, true ); |
| 2046 | + defer.fire(); |
| 2047 | + } |
| 2048 | + }, 0 ); |
| 2049 | + } |
| 2050 | +} |
| 2051 | + |
| 2052 | +jQuery.extend({ |
| 2053 | + |
| 2054 | + _mark: function( elem, type ) { |
| 2055 | + if ( elem ) { |
| 2056 | + type = ( type || "fx" ) + "mark"; |
| 2057 | + jQuery._data( elem, type, (jQuery._data( elem, type ) || 0) + 1 ); |
| 2058 | + } |
| 2059 | + }, |
| 2060 | + |
| 2061 | + _unmark: function( force, elem, type ) { |
| 2062 | + if ( force !== true ) { |
| 2063 | + type = elem; |
| 2064 | + elem = force; |
| 2065 | + force = false; |
| 2066 | + } |
| 2067 | + if ( elem ) { |
| 2068 | + type = type || "fx"; |
| 2069 | + var key = type + "mark", |
| 2070 | + count = force ? 0 : ( (jQuery._data( elem, key ) || 1) - 1 ); |
| 2071 | + if ( count ) { |
| 2072 | + jQuery._data( elem, key, count ); |
| 2073 | + } else { |
| 2074 | + jQuery.removeData( elem, key, true ); |
| 2075 | + handleQueueMarkDefer( elem, type, "mark" ); |
| 2076 | + } |
| 2077 | + } |
| 2078 | + }, |
| 2079 | + |
| 2080 | + queue: function( elem, type, data ) { |
| 2081 | + var q; |
| 2082 | + if ( elem ) { |
| 2083 | + type = ( type || "fx" ) + "queue"; |
| 2084 | + q = jQuery._data( elem, type ); |
| 2085 | + |
| 2086 | + // Speed up dequeue by getting out quickly if this is just a lookup |
| 2087 | + if ( data ) { |
| 2088 | + if ( !q || jQuery.isArray(data) ) { |
| 2089 | + q = jQuery._data( elem, type, jQuery.makeArray(data) ); |
| 2090 | + } else { |
| 2091 | + q.push( data ); |
| 2092 | + } |
| 2093 | + } |
| 2094 | + return q || []; |
| 2095 | + } |
| 2096 | + }, |
| 2097 | + |
| 2098 | + dequeue: function( elem, type ) { |
| 2099 | + type = type || "fx"; |
| 2100 | + |
| 2101 | + var queue = jQuery.queue( elem, type ), |
| 2102 | + fn = queue.shift(), |
| 2103 | + hooks = {}; |
| 2104 | + |
| 2105 | + // If the fx queue is dequeued, always remove the progress sentinel |
| 2106 | + if ( fn === "inprogress" ) { |
| 2107 | + fn = queue.shift(); |
| 2108 | + } |
| 2109 | + |
| 2110 | + if ( fn ) { |
| 2111 | + // Add a progress sentinel to prevent the fx queue from being |
| 2112 | + // automatically dequeued |
| 2113 | + if ( type === "fx" ) { |
| 2114 | + queue.unshift( "inprogress" ); |
| 2115 | + } |
| 2116 | + |
| 2117 | + jQuery._data( elem, type + ".run", hooks ); |
| 2118 | + fn.call( elem, function() { |
| 2119 | + jQuery.dequeue( elem, type ); |
| 2120 | + }, hooks ); |
| 2121 | + } |
| 2122 | + |
| 2123 | + if ( !queue.length ) { |
| 2124 | + jQuery.removeData( elem, type + "queue " + type + ".run", true ); |
| 2125 | + handleQueueMarkDefer( elem, type, "queue" ); |
| 2126 | + } |
| 2127 | + } |
| 2128 | +}); |
| 2129 | + |
| 2130 | +jQuery.fn.extend({ |
| 2131 | + queue: function( type, data ) { |
| 2132 | + if ( typeof type !== "string" ) { |
| 2133 | + data = type; |
| 2134 | + type = "fx"; |
| 2135 | + } |
| 2136 | + |
| 2137 | + if ( data === undefined ) { |
| 2138 | + return jQuery.queue( this[0], type ); |
| 2139 | + } |
| 2140 | + return this.each(function() { |
| 2141 | + var queue = jQuery.queue( this, type, data ); |
| 2142 | + |
| 2143 | + if ( type === "fx" && queue[0] !== "inprogress" ) { |
| 2144 | + jQuery.dequeue( this, type ); |
| 2145 | + } |
| 2146 | + }); |
| 2147 | + }, |
| 2148 | + dequeue: function( type ) { |
| 2149 | + return this.each(function() { |
| 2150 | + jQuery.dequeue( this, type ); |
| 2151 | + }); |
| 2152 | + }, |
| 2153 | + // Based off of the plugin by Clint Helfers, with permission. |
| 2154 | + // http://blindsignals.com/index.php/2009/07/jquery-delay/ |
| 2155 | + delay: function( time, type ) { |
| 2156 | + time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; |
| 2157 | + type = type || "fx"; |
| 2158 | + |
| 2159 | + return this.queue( type, function( next, hooks ) { |
| 2160 | + var timeout = setTimeout( next, time ); |
| 2161 | + hooks.stop = function() { |
| 2162 | + clearTimeout( timeout ); |
| 2163 | + }; |
| 2164 | + }); |
| 2165 | + }, |
| 2166 | + clearQueue: function( type ) { |
| 2167 | + return this.queue( type || "fx", [] ); |
| 2168 | + }, |
| 2169 | + // Get a promise resolved when queues of a certain type |
| 2170 | + // are emptied (fx is the type by default) |
| 2171 | + promise: function( type, object ) { |
| 2172 | + if ( typeof type !== "string" ) { |
| 2173 | + object = type; |
| 2174 | + type = undefined; |
| 2175 | + } |
| 2176 | + type = type || "fx"; |
| 2177 | + var defer = jQuery.Deferred(), |
| 2178 | + elements = this, |
| 2179 | + i = elements.length, |
| 2180 | + count = 1, |
| 2181 | + deferDataKey = type + "defer", |
| 2182 | + queueDataKey = type + "queue", |
| 2183 | + markDataKey = type + "mark", |
| 2184 | + tmp; |
| 2185 | + function resolve() { |
| 2186 | + if ( !( --count ) ) { |
| 2187 | + defer.resolveWith( elements, [ elements ] ); |
| 2188 | + } |
| 2189 | + } |
| 2190 | + while( i-- ) { |
| 2191 | + if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) || |
| 2192 | + ( jQuery.data( elements[ i ], queueDataKey, undefined, true ) || |
| 2193 | + jQuery.data( elements[ i ], markDataKey, undefined, true ) ) && |
| 2194 | + jQuery.data( elements[ i ], deferDataKey, jQuery.Callbacks( "once memory" ), true ) )) { |
| 2195 | + count++; |
| 2196 | + tmp.add( resolve ); |
| 2197 | + } |
| 2198 | + } |
| 2199 | + resolve(); |
| 2200 | + return defer.promise(); |
| 2201 | + } |
| 2202 | +}); |
| 2203 | + |
| 2204 | + |
| 2205 | + |
| 2206 | + |
| 2207 | +var rclass = /[\n\t\r]/g, |
| 2208 | + rspace = /\s+/, |
| 2209 | + rreturn = /\r/g, |
| 2210 | + rtype = /^(?:button|input)$/i, |
| 2211 | + rfocusable = /^(?:button|input|object|select|textarea)$/i, |
| 2212 | + rclickable = /^a(?:rea)?$/i, |
| 2213 | + rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i, |
| 2214 | + getSetAttribute = jQuery.support.getSetAttribute, |
| 2215 | + nodeHook, boolHook, fixSpecified; |
| 2216 | + |
| 2217 | +jQuery.fn.extend({ |
| 2218 | + attr: function( name, value ) { |
| 2219 | + return jQuery.access( this, name, value, true, jQuery.attr ); |
| 2220 | + }, |
| 2221 | + |
| 2222 | + removeAttr: function( name ) { |
| 2223 | + return this.each(function() { |
| 2224 | + jQuery.removeAttr( this, name ); |
| 2225 | + }); |
| 2226 | + }, |
| 2227 | + |
| 2228 | + prop: function( name, value ) { |
| 2229 | + return jQuery.access( this, name, value, true, jQuery.prop ); |
| 2230 | + }, |
| 2231 | + |
| 2232 | + removeProp: function( name ) { |
| 2233 | + name = jQuery.propFix[ name ] || name; |
| 2234 | + return this.each(function() { |
| 2235 | + // try/catch handles cases where IE balks (such as removing a property on window) |
| 2236 | + try { |
| 2237 | + this[ name ] = undefined; |
| 2238 | + delete this[ name ]; |
| 2239 | + } catch( e ) {} |
| 2240 | + }); |
| 2241 | + }, |
| 2242 | + |
| 2243 | + addClass: function( value ) { |
| 2244 | + var classNames, i, l, elem, |
| 2245 | + setClass, c, cl; |
| 2246 | + |
| 2247 | + if ( jQuery.isFunction( value ) ) { |
| 2248 | + return this.each(function( j ) { |
| 2249 | + jQuery( this ).addClass( value.call(this, j, this.className) ); |
| 2250 | + }); |
| 2251 | + } |
| 2252 | + |
| 2253 | + if ( value && typeof value === "string" ) { |
| 2254 | + classNames = value.split( rspace ); |
| 2255 | + |
| 2256 | + for ( i = 0, l = this.length; i < l; i++ ) { |
| 2257 | + elem = this[ i ]; |
| 2258 | + |
| 2259 | + if ( elem.nodeType === 1 ) { |
| 2260 | + if ( !elem.className && classNames.length === 1 ) { |
| 2261 | + elem.className = value; |
| 2262 | + |
| 2263 | + } else { |
| 2264 | + setClass = " " + elem.className + " "; |
| 2265 | + |
| 2266 | + for ( c = 0, cl = classNames.length; c < cl; c++ ) { |
| 2267 | + if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) { |
| 2268 | + setClass += classNames[ c ] + " "; |
| 2269 | + } |
| 2270 | + } |
| 2271 | + elem.className = jQuery.trim( setClass ); |
| 2272 | + } |
| 2273 | + } |
| 2274 | + } |
| 2275 | + } |
| 2276 | + |
| 2277 | + return this; |
| 2278 | + }, |
| 2279 | + |
| 2280 | + removeClass: function( value ) { |
| 2281 | + var classNames, i, l, elem, className, c, cl; |
| 2282 | + |
| 2283 | + if ( jQuery.isFunction( value ) ) { |
| 2284 | + return this.each(function( j ) { |
| 2285 | + jQuery( this ).removeClass( value.call(this, j, this.className) ); |
| 2286 | + }); |
| 2287 | + } |
| 2288 | + |
| 2289 | + if ( (value && typeof value === "string") || value === undefined ) { |
| 2290 | + classNames = ( value || "" ).split( rspace ); |
| 2291 | + |
| 2292 | + for ( i = 0, l = this.length; i < l; i++ ) { |
| 2293 | + elem = this[ i ]; |
| 2294 | + |
| 2295 | + if ( elem.nodeType === 1 && elem.className ) { |
| 2296 | + if ( value ) { |
| 2297 | + className = (" " + elem.className + " ").replace( rclass, " " ); |
| 2298 | + for ( c = 0, cl = classNames.length; c < cl; c++ ) { |
| 2299 | + className = className.replace(" " + classNames[ c ] + " ", " "); |
| 2300 | + } |
| 2301 | + elem.className = jQuery.trim( className ); |
| 2302 | + |
| 2303 | + } else { |
| 2304 | + elem.className = ""; |
| 2305 | + } |
| 2306 | + } |
| 2307 | + } |
| 2308 | + } |
| 2309 | + |
| 2310 | + return this; |
| 2311 | + }, |
| 2312 | + |
| 2313 | + toggleClass: function( value, stateVal ) { |
| 2314 | + var type = typeof value, |
| 2315 | + isBool = typeof stateVal === "boolean"; |
| 2316 | + |
| 2317 | + if ( jQuery.isFunction( value ) ) { |
| 2318 | + return this.each(function( i ) { |
| 2319 | + jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal ); |
| 2320 | + }); |
| 2321 | + } |
| 2322 | + |
| 2323 | + return this.each(function() { |
| 2324 | + if ( type === "string" ) { |
| 2325 | + // toggle individual class names |
| 2326 | + var className, |
| 2327 | + i = 0, |
| 2328 | + self = jQuery( this ), |
| 2329 | + state = stateVal, |
| 2330 | + classNames = value.split( rspace ); |
| 2331 | + |
| 2332 | + while ( (className = classNames[ i++ ]) ) { |
| 2333 | + // check each className given, space seperated list |
| 2334 | + state = isBool ? state : !self.hasClass( className ); |
| 2335 | + self[ state ? "addClass" : "removeClass" ]( className ); |
| 2336 | + } |
| 2337 | + |
| 2338 | + } else if ( type === "undefined" || type === "boolean" ) { |
| 2339 | + if ( this.className ) { |
| 2340 | + // store className if set |
| 2341 | + jQuery._data( this, "__className__", this.className ); |
| 2342 | + } |
| 2343 | + |
| 2344 | + // toggle whole className |
| 2345 | + this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || ""; |
| 2346 | + } |
| 2347 | + }); |
| 2348 | + }, |
| 2349 | + |
| 2350 | + hasClass: function( selector ) { |
| 2351 | + var className = " " + selector + " ", |
| 2352 | + i = 0, |
| 2353 | + l = this.length; |
| 2354 | + for ( ; i < l; i++ ) { |
| 2355 | + if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) { |
| 2356 | + return true; |
| 2357 | + } |
| 2358 | + } |
| 2359 | + |
| 2360 | + return false; |
| 2361 | + }, |
| 2362 | + |
| 2363 | + val: function( value ) { |
| 2364 | + var hooks, ret, isFunction, |
| 2365 | + elem = this[0]; |
| 2366 | + |
| 2367 | + if ( !arguments.length ) { |
| 2368 | + if ( elem ) { |
| 2369 | + hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ]; |
| 2370 | + |
| 2371 | + if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { |
| 2372 | + return ret; |
| 2373 | + } |
| 2374 | + |
| 2375 | + ret = elem.value; |
| 2376 | + |
| 2377 | + return typeof ret === "string" ? |
| 2378 | + // handle most common string cases |
| 2379 | + ret.replace(rreturn, "") : |
| 2380 | + // handle cases where value is null/undef or number |
| 2381 | + ret == null ? "" : ret; |
| 2382 | + } |
| 2383 | + |
| 2384 | + return undefined; |
| 2385 | + } |
| 2386 | + |
| 2387 | + isFunction = jQuery.isFunction( value ); |
| 2388 | + |
| 2389 | + return this.each(function( i ) { |
| 2390 | + var self = jQuery(this), val; |
| 2391 | + |
| 2392 | + if ( this.nodeType !== 1 ) { |
| 2393 | + return; |
| 2394 | + } |
| 2395 | + |
| 2396 | + if ( isFunction ) { |
| 2397 | + val = value.call( this, i, self.val() ); |
| 2398 | + } else { |
| 2399 | + val = value; |
| 2400 | + } |
| 2401 | + |
| 2402 | + // Treat null/undefined as ""; convert numbers to string |
| 2403 | + if ( val == null ) { |
| 2404 | + val = ""; |
| 2405 | + } else if ( typeof val === "number" ) { |
| 2406 | + val += ""; |
| 2407 | + } else if ( jQuery.isArray( val ) ) { |
| 2408 | + val = jQuery.map(val, function ( value ) { |
| 2409 | + return value == null ? "" : value + ""; |
| 2410 | + }); |
| 2411 | + } |
| 2412 | + |
| 2413 | + hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ]; |
| 2414 | + |
| 2415 | + // If set returns undefined, fall back to normal setting |
| 2416 | + if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) { |
| 2417 | + this.value = val; |
| 2418 | + } |
| 2419 | + }); |
| 2420 | + } |
| 2421 | +}); |
| 2422 | + |
| 2423 | +jQuery.extend({ |
| 2424 | + valHooks: { |
| 2425 | + option: { |
| 2426 | + get: function( elem ) { |
| 2427 | + // attributes.value is undefined in Blackberry 4.7 but |
| 2428 | + // uses .value. See #6932 |
| 2429 | + var val = elem.attributes.value; |
| 2430 | + return !val || val.specified ? elem.value : elem.text; |
| 2431 | + } |
| 2432 | + }, |
| 2433 | + select: { |
| 2434 | + get: function( elem ) { |
| 2435 | + var value, i, max, option, |
| 2436 | + index = elem.selectedIndex, |
| 2437 | + values = [], |
| 2438 | + options = elem.options, |
| 2439 | + one = elem.type === "select-one"; |
| 2440 | + |
| 2441 | + // Nothing was selected |
| 2442 | + if ( index < 0 ) { |
| 2443 | + return null; |
| 2444 | + } |
| 2445 | + |
| 2446 | + // Loop through all the selected options |
| 2447 | + i = one ? index : 0; |
| 2448 | + max = one ? index + 1 : options.length; |
| 2449 | + for ( ; i < max; i++ ) { |
| 2450 | + option = options[ i ]; |
| 2451 | + |
| 2452 | + // Don't return options that are disabled or in a disabled optgroup |
| 2453 | + if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) && |
| 2454 | + (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) { |
| 2455 | + |
| 2456 | + // Get the specific value for the option |
| 2457 | + value = jQuery( option ).val(); |
| 2458 | + |
| 2459 | + // We don't need an array for one selects |
| 2460 | + if ( one ) { |
| 2461 | + return value; |
| 2462 | + } |
| 2463 | + |
| 2464 | + // Multi-Selects return an array |
| 2465 | + values.push( value ); |
| 2466 | + } |
| 2467 | + } |
| 2468 | + |
| 2469 | + // Fixes Bug #2551 -- select.val() broken in IE after form.reset() |
| 2470 | + if ( one && !values.length && options.length ) { |
| 2471 | + return jQuery( options[ index ] ).val(); |
| 2472 | + } |
| 2473 | + |
| 2474 | + return values; |
| 2475 | + }, |
| 2476 | + |
| 2477 | + set: function( elem, value ) { |
| 2478 | + var values = jQuery.makeArray( value ); |
| 2479 | + |
| 2480 | + jQuery(elem).find("option").each(function() { |
| 2481 | + this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0; |
| 2482 | + }); |
| 2483 | + |
| 2484 | + if ( !values.length ) { |
| 2485 | + elem.selectedIndex = -1; |
| 2486 | + } |
| 2487 | + return values; |
| 2488 | + } |
| 2489 | + } |
| 2490 | + }, |
| 2491 | + |
| 2492 | + attrFn: { |
| 2493 | + val: true, |
| 2494 | + css: true, |
| 2495 | + html: true, |
| 2496 | + text: true, |
| 2497 | + data: true, |
| 2498 | + width: true, |
| 2499 | + height: true, |
| 2500 | + offset: true |
| 2501 | + }, |
| 2502 | + |
| 2503 | + attr: function( elem, name, value, pass ) { |
| 2504 | + var ret, hooks, notxml, |
| 2505 | + nType = elem.nodeType; |
| 2506 | + |
| 2507 | + // don't get/set attributes on text, comment and attribute nodes |
| 2508 | + if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { |
| 2509 | + return undefined; |
| 2510 | + } |
| 2511 | + |
| 2512 | + if ( pass && name in jQuery.attrFn ) { |
| 2513 | + return jQuery( elem )[ name ]( value ); |
| 2514 | + } |
| 2515 | + |
| 2516 | + // Fallback to prop when attributes are not supported |
| 2517 | + if ( !("getAttribute" in elem) ) { |
| 2518 | + return jQuery.prop( elem, name, value ); |
| 2519 | + } |
| 2520 | + |
| 2521 | + notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); |
| 2522 | + |
| 2523 | + // All attributes are lowercase |
| 2524 | + // Grab necessary hook if one is defined |
| 2525 | + if ( notxml ) { |
| 2526 | + name = name.toLowerCase(); |
| 2527 | + hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook ); |
| 2528 | + } |
| 2529 | + |
| 2530 | + if ( value !== undefined ) { |
| 2531 | + |
| 2532 | + if ( value === null ) { |
| 2533 | + jQuery.removeAttr( elem, name ); |
| 2534 | + return undefined; |
| 2535 | + |
| 2536 | + } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) { |
| 2537 | + return ret; |
| 2538 | + |
| 2539 | + } else { |
| 2540 | + elem.setAttribute( name, "" + value ); |
| 2541 | + return value; |
| 2542 | + } |
| 2543 | + |
| 2544 | + } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) { |
| 2545 | + return ret; |
| 2546 | + |
| 2547 | + } else { |
| 2548 | + |
| 2549 | + ret = elem.getAttribute( name ); |
| 2550 | + |
| 2551 | + // Non-existent attributes return null, we normalize to undefined |
| 2552 | + return ret === null ? |
| 2553 | + undefined : |
| 2554 | + ret; |
| 2555 | + } |
| 2556 | + }, |
| 2557 | + |
| 2558 | + removeAttr: function( elem, value ) { |
| 2559 | + var propName, attrNames, name, l, |
| 2560 | + i = 0; |
| 2561 | + |
| 2562 | + if ( elem.nodeType === 1 ) { |
| 2563 | + attrNames = ( value || "" ).split( rspace ); |
| 2564 | + l = attrNames.length; |
| 2565 | + |
| 2566 | + for ( ; i < l; i++ ) { |
| 2567 | + name = attrNames[ i ].toLowerCase(); |
| 2568 | + propName = jQuery.propFix[ name ] || name; |
| 2569 | + |
| 2570 | + // See #9699 for explanation of this approach (setting first, then removal) |
| 2571 | + jQuery.attr( elem, name, "" ); |
| 2572 | + elem.removeAttribute( getSetAttribute ? name : propName ); |
| 2573 | + |
| 2574 | + // Set corresponding property to false for boolean attributes |
| 2575 | + if ( rboolean.test( name ) && propName in elem ) { |
| 2576 | + elem[ propName ] = false; |
| 2577 | + } |
| 2578 | + } |
| 2579 | + } |
| 2580 | + }, |
| 2581 | + |
| 2582 | + attrHooks: { |
| 2583 | + type: { |
| 2584 | + set: function( elem, value ) { |
| 2585 | + // We can't allow the type property to be changed (since it causes problems in IE) |
| 2586 | + if ( rtype.test( elem.nodeName ) && elem.parentNode ) { |
| 2587 | + jQuery.error( "type property can't be changed" ); |
| 2588 | + } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) { |
| 2589 | + // Setting the type on a radio button after the value resets the value in IE6-9 |
| 2590 | + // Reset value to it's default in case type is set after value |
| 2591 | + // This is for element creation |
| 2592 | + var val = elem.value; |
| 2593 | + elem.setAttribute( "type", value ); |
| 2594 | + if ( val ) { |
| 2595 | + elem.value = val; |
| 2596 | + } |
| 2597 | + return value; |
| 2598 | + } |
| 2599 | + } |
| 2600 | + }, |
| 2601 | + // Use the value property for back compat |
| 2602 | + // Use the nodeHook for button elements in IE6/7 (#1954) |
| 2603 | + value: { |
| 2604 | + get: function( elem, name ) { |
| 2605 | + if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { |
| 2606 | + return nodeHook.get( elem, name ); |
| 2607 | + } |
| 2608 | + return name in elem ? |
| 2609 | + elem.value : |
| 2610 | + null; |
| 2611 | + }, |
| 2612 | + set: function( elem, value, name ) { |
| 2613 | + if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { |
| 2614 | + return nodeHook.set( elem, value, name ); |
| 2615 | + } |
| 2616 | + // Does not return so that setAttribute is also used |
| 2617 | + elem.value = value; |
| 2618 | + } |
| 2619 | + } |
| 2620 | + }, |
| 2621 | + |
| 2622 | + propFix: { |
| 2623 | + tabindex: "tabIndex", |
| 2624 | + readonly: "readOnly", |
| 2625 | + "for": "htmlFor", |
| 2626 | + "class": "className", |
| 2627 | + maxlength: "maxLength", |
| 2628 | + cellspacing: "cellSpacing", |
| 2629 | + cellpadding: "cellPadding", |
| 2630 | + rowspan: "rowSpan", |
| 2631 | + colspan: "colSpan", |
| 2632 | + usemap: "useMap", |
| 2633 | + frameborder: "frameBorder", |
| 2634 | + contenteditable: "contentEditable" |
| 2635 | + }, |
| 2636 | + |
| 2637 | + prop: function( elem, name, value ) { |
| 2638 | + var ret, hooks, notxml, |
| 2639 | + nType = elem.nodeType; |
| 2640 | + |
| 2641 | + // don't get/set properties on text, comment and attribute nodes |
| 2642 | + if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { |
| 2643 | + return undefined; |
| 2644 | + } |
| 2645 | + |
| 2646 | + notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); |
| 2647 | + |
| 2648 | + if ( notxml ) { |
| 2649 | + // Fix name and attach hooks |
| 2650 | + name = jQuery.propFix[ name ] || name; |
| 2651 | + hooks = jQuery.propHooks[ name ]; |
| 2652 | + } |
| 2653 | + |
| 2654 | + if ( value !== undefined ) { |
| 2655 | + if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { |
| 2656 | + return ret; |
| 2657 | + |
| 2658 | + } else { |
| 2659 | + return ( elem[ name ] = value ); |
| 2660 | + } |
| 2661 | + |
| 2662 | + } else { |
| 2663 | + if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) { |
| 2664 | + return ret; |
| 2665 | + |
| 2666 | + } else { |
| 2667 | + return elem[ name ]; |
| 2668 | + } |
| 2669 | + } |
| 2670 | + }, |
| 2671 | + |
| 2672 | + propHooks: { |
| 2673 | + tabIndex: { |
| 2674 | + get: function( elem ) { |
| 2675 | + // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set |
| 2676 | + // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ |
| 2677 | + var attributeNode = elem.getAttributeNode("tabindex"); |
| 2678 | + |
| 2679 | + return attributeNode && attributeNode.specified ? |
| 2680 | + parseInt( attributeNode.value, 10 ) : |
| 2681 | + rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? |
| 2682 | + 0 : |
| 2683 | + undefined; |
| 2684 | + } |
| 2685 | + } |
| 2686 | + } |
| 2687 | +}); |
| 2688 | + |
| 2689 | +// Add the tabIndex propHook to attrHooks for back-compat (different case is intentional) |
| 2690 | +jQuery.attrHooks.tabindex = jQuery.propHooks.tabIndex; |
| 2691 | + |
| 2692 | +// Hook for boolean attributes |
| 2693 | +boolHook = { |
| 2694 | + get: function( elem, name ) { |
| 2695 | + // Align boolean attributes with corresponding properties |
| 2696 | + // Fall back to attribute presence where some booleans are not supported |
| 2697 | + var attrNode, |
| 2698 | + property = jQuery.prop( elem, name ); |
| 2699 | + return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ? |
| 2700 | + name.toLowerCase() : |
| 2701 | + undefined; |
| 2702 | + }, |
| 2703 | + set: function( elem, value, name ) { |
| 2704 | + var propName; |
| 2705 | + if ( value === false ) { |
| 2706 | + // Remove boolean attributes when set to false |
| 2707 | + jQuery.removeAttr( elem, name ); |
| 2708 | + } else { |
| 2709 | + // value is true since we know at this point it's type boolean and not false |
| 2710 | + // Set boolean attributes to the same name and set the DOM property |
| 2711 | + propName = jQuery.propFix[ name ] || name; |
| 2712 | + if ( propName in elem ) { |
| 2713 | + // Only set the IDL specifically if it already exists on the element |
| 2714 | + elem[ propName ] = true; |
| 2715 | + } |
| 2716 | + |
| 2717 | + elem.setAttribute( name, name.toLowerCase() ); |
| 2718 | + } |
| 2719 | + return name; |
| 2720 | + } |
| 2721 | +}; |
| 2722 | + |
| 2723 | +// IE6/7 do not support getting/setting some attributes with get/setAttribute |
| 2724 | +if ( !getSetAttribute ) { |
| 2725 | + |
| 2726 | + fixSpecified = { |
| 2727 | + name: true, |
| 2728 | + id: true |
| 2729 | + }; |
| 2730 | + |
| 2731 | + // Use this for any attribute in IE6/7 |
| 2732 | + // This fixes almost every IE6/7 issue |
| 2733 | + nodeHook = jQuery.valHooks.button = { |
| 2734 | + get: function( elem, name ) { |
| 2735 | + var ret; |
| 2736 | + ret = elem.getAttributeNode( name ); |
| 2737 | + return ret && ( fixSpecified[ name ] ? ret.nodeValue !== "" : ret.specified ) ? |
| 2738 | + ret.nodeValue : |
| 2739 | + undefined; |
| 2740 | + }, |
| 2741 | + set: function( elem, value, name ) { |
| 2742 | + // Set the existing or create a new attribute node |
| 2743 | + var ret = elem.getAttributeNode( name ); |
| 2744 | + if ( !ret ) { |
| 2745 | + ret = document.createAttribute( name ); |
| 2746 | + elem.setAttributeNode( ret ); |
| 2747 | + } |
| 2748 | + return ( ret.nodeValue = value + "" ); |
| 2749 | + } |
| 2750 | + }; |
| 2751 | + |
| 2752 | + // Apply the nodeHook to tabindex |
| 2753 | + jQuery.attrHooks.tabindex.set = nodeHook.set; |
| 2754 | + |
| 2755 | + // Set width and height to auto instead of 0 on empty string( Bug #8150 ) |
| 2756 | + // This is for removals |
| 2757 | + jQuery.each([ "width", "height" ], function( i, name ) { |
| 2758 | + jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { |
| 2759 | + set: function( elem, value ) { |
| 2760 | + if ( value === "" ) { |
| 2761 | + elem.setAttribute( name, "auto" ); |
| 2762 | + return value; |
| 2763 | + } |
| 2764 | + } |
| 2765 | + }); |
| 2766 | + }); |
| 2767 | + |
| 2768 | + // Set contenteditable to false on removals(#10429) |
| 2769 | + // Setting to empty string throws an error as an invalid value |
| 2770 | + jQuery.attrHooks.contenteditable = { |
| 2771 | + get: nodeHook.get, |
| 2772 | + set: function( elem, value, name ) { |
| 2773 | + if ( value === "" ) { |
| 2774 | + value = "false"; |
| 2775 | + } |
| 2776 | + nodeHook.set( elem, value, name ); |
| 2777 | + } |
| 2778 | + }; |
| 2779 | +} |
| 2780 | + |
| 2781 | + |
| 2782 | +// Some attributes require a special call on IE |
| 2783 | +if ( !jQuery.support.hrefNormalized ) { |
| 2784 | + jQuery.each([ "href", "src", "width", "height" ], function( i, name ) { |
| 2785 | + jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { |
| 2786 | + get: function( elem ) { |
| 2787 | + var ret = elem.getAttribute( name, 2 ); |
| 2788 | + return ret === null ? undefined : ret; |
| 2789 | + } |
| 2790 | + }); |
| 2791 | + }); |
| 2792 | +} |
| 2793 | + |
| 2794 | +if ( !jQuery.support.style ) { |
| 2795 | + jQuery.attrHooks.style = { |
| 2796 | + get: function( elem ) { |
| 2797 | + // Return undefined in the case of empty string |
| 2798 | + // Normalize to lowercase since IE uppercases css property names |
| 2799 | + return elem.style.cssText.toLowerCase() || undefined; |
| 2800 | + }, |
| 2801 | + set: function( elem, value ) { |
| 2802 | + return ( elem.style.cssText = "" + value ); |
| 2803 | + } |
| 2804 | + }; |
| 2805 | +} |
| 2806 | + |
| 2807 | +// Safari mis-reports the default selected property of an option |
| 2808 | +// Accessing the parent's selectedIndex property fixes it |
| 2809 | +if ( !jQuery.support.optSelected ) { |
| 2810 | + jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, { |
| 2811 | + get: function( elem ) { |
| 2812 | + var parent = elem.parentNode; |
| 2813 | + |
| 2814 | + if ( parent ) { |
| 2815 | + parent.selectedIndex; |
| 2816 | + |
| 2817 | + // Make sure that it also works with optgroups, see #5701 |
| 2818 | + if ( parent.parentNode ) { |
| 2819 | + parent.parentNode.selectedIndex; |
| 2820 | + } |
| 2821 | + } |
| 2822 | + return null; |
| 2823 | + } |
| 2824 | + }); |
| 2825 | +} |
| 2826 | + |
| 2827 | +// IE6/7 call enctype encoding |
| 2828 | +if ( !jQuery.support.enctype ) { |
| 2829 | + jQuery.propFix.enctype = "encoding"; |
| 2830 | +} |
| 2831 | + |
| 2832 | +// Radios and checkboxes getter/setter |
| 2833 | +if ( !jQuery.support.checkOn ) { |
| 2834 | + jQuery.each([ "radio", "checkbox" ], function() { |
| 2835 | + jQuery.valHooks[ this ] = { |
| 2836 | + get: function( elem ) { |
| 2837 | + // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified |
| 2838 | + return elem.getAttribute("value") === null ? "on" : elem.value; |
| 2839 | + } |
| 2840 | + }; |
| 2841 | + }); |
| 2842 | +} |
| 2843 | +jQuery.each([ "radio", "checkbox" ], function() { |
| 2844 | + jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], { |
| 2845 | + set: function( elem, value ) { |
| 2846 | + if ( jQuery.isArray( value ) ) { |
| 2847 | + return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 ); |
| 2848 | + } |
| 2849 | + } |
| 2850 | + }); |
| 2851 | +}); |
| 2852 | + |
| 2853 | + |
| 2854 | + |
| 2855 | + |
| 2856 | +var rnamespaces = /\.(.*)$/, |
| 2857 | + rformElems = /^(?:textarea|input|select)$/i, |
| 2858 | + rperiod = /\./g, |
| 2859 | + rspaces = / /g, |
| 2860 | + rescape = /[^\w\s.|`]/g, |
| 2861 | + rtypenamespace = /^([^\.]*)?(?:\.(.+))?$/, |
| 2862 | + rhoverHack = /\bhover(\.\S+)?/, |
| 2863 | + rkeyEvent = /^key/, |
| 2864 | + rmouseEvent = /^(?:mouse|contextmenu)|click/, |
| 2865 | + rquickIs = /^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/, |
| 2866 | + quickParse = function( selector ) { |
| 2867 | + var quick = rquickIs.exec( selector ); |
| 2868 | + if ( quick ) { |
| 2869 | + // 0 1 2 3 |
| 2870 | + // [ _, tag, id, class ] |
| 2871 | + quick[1] = ( quick[1] || "" ).toLowerCase(); |
| 2872 | + quick[3] = quick[3] && new RegExp( "(?:^|\\s)" + quick[3] + "(?:\\s|$)" ); |
| 2873 | + } |
| 2874 | + return quick; |
| 2875 | + }, |
| 2876 | + quickIs = function( elem, m ) { |
| 2877 | + return ( |
| 2878 | + (!m[1] || elem.nodeName.toLowerCase() === m[1]) && |
| 2879 | + (!m[2] || elem.id === m[2]) && |
| 2880 | + (!m[3] || m[3].test( elem.className )) |
| 2881 | + ); |
| 2882 | + }, |
| 2883 | + hoverHack = function( events ) { |
| 2884 | + return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" ); |
| 2885 | + }; |
| 2886 | + |
| 2887 | +/* |
| 2888 | + * Helper functions for managing events -- not part of the public interface. |
| 2889 | + * Props to Dean Edwards' addEvent library for many of the ideas. |
| 2890 | + */ |
| 2891 | +jQuery.event = { |
| 2892 | + |
| 2893 | + add: function( elem, types, handler, data, selector ) { |
| 2894 | + |
| 2895 | + var elemData, eventHandle, events, |
| 2896 | + t, tns, type, namespaces, handleObj, |
| 2897 | + handleObjIn, quick, handlers, special; |
| 2898 | + |
| 2899 | + // Don't attach events to noData or text/comment nodes (allow plain objects tho) |
| 2900 | + if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) { |
| 2901 | + return; |
| 2902 | + } |
| 2903 | + |
| 2904 | + // Caller can pass in an object of custom data in lieu of the handler |
| 2905 | + if ( handler.handler ) { |
| 2906 | + handleObjIn = handler; |
| 2907 | + handler = handleObjIn.handler; |
| 2908 | + } |
| 2909 | + |
| 2910 | + // Make sure that the handler has a unique ID, used to find/remove it later |
| 2911 | + if ( !handler.guid ) { |
| 2912 | + handler.guid = jQuery.guid++; |
| 2913 | + } |
| 2914 | + |
| 2915 | + // Init the element's event structure and main handler, if this is the first |
| 2916 | + events = elemData.events; |
| 2917 | + if ( !events ) { |
| 2918 | + elemData.events = events = {}; |
| 2919 | + } |
| 2920 | + eventHandle = elemData.handle; |
| 2921 | + if ( !eventHandle ) { |
| 2922 | + elemData.handle = eventHandle = function( e ) { |
| 2923 | + // Discard the second event of a jQuery.event.trigger() and |
| 2924 | + // when an event is called after a page has unloaded |
| 2925 | + return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ? |
| 2926 | + jQuery.event.dispatch.apply( eventHandle.elem, arguments ) : |
| 2927 | + undefined; |
| 2928 | + }; |
| 2929 | + // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events |
| 2930 | + eventHandle.elem = elem; |
| 2931 | + } |
| 2932 | + |
| 2933 | + // Handle multiple events separated by a space |
| 2934 | + // jQuery(...).bind("mouseover mouseout", fn); |
| 2935 | + types = hoverHack(types).split( " " ); |
| 2936 | + for ( t = 0; t < types.length; t++ ) { |
| 2937 | + |
| 2938 | + tns = rtypenamespace.exec( types[t] ) || []; |
| 2939 | + type = tns[1]; |
| 2940 | + namespaces = ( tns[2] || "" ).split( "." ).sort(); |
| 2941 | + |
| 2942 | + // If event changes its type, use the special event handlers for the changed type |
| 2943 | + special = jQuery.event.special[ type ] || {}; |
| 2944 | + |
| 2945 | + // If selector defined, determine special event api type, otherwise given type |
| 2946 | + type = ( selector ? special.delegateType : special.bindType ) || type; |
| 2947 | + |
| 2948 | + // Update special based on newly reset type |
| 2949 | + special = jQuery.event.special[ type ] || {}; |
| 2950 | + |
| 2951 | + // handleObj is passed to all event handlers |
| 2952 | + handleObj = jQuery.extend({ |
| 2953 | + type: type, |
| 2954 | + origType: tns[1], |
| 2955 | + data: data, |
| 2956 | + handler: handler, |
| 2957 | + guid: handler.guid, |
| 2958 | + selector: selector, |
| 2959 | + namespace: namespaces.join(".") |
| 2960 | + }, handleObjIn ); |
| 2961 | + |
| 2962 | + // Delegated event; pre-analyze selector so it's processed quickly on event dispatch |
| 2963 | + if ( selector ) { |
| 2964 | + handleObj.quick = quickParse( selector ); |
| 2965 | + if ( !handleObj.quick && jQuery.expr.match.POS.test( selector ) ) { |
| 2966 | + handleObj.isPositional = true; |
| 2967 | + } |
| 2968 | + } |
| 2969 | + |
| 2970 | + // Init the event handler queue if we're the first |
| 2971 | + handlers = events[ type ]; |
| 2972 | + if ( !handlers ) { |
| 2973 | + handlers = events[ type ] = []; |
| 2974 | + handlers.delegateCount = 0; |
| 2975 | + |
| 2976 | + // Only use addEventListener/attachEvent if the special events handler returns false |
| 2977 | + if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { |
| 2978 | + // Bind the global event handler to the element |
| 2979 | + if ( elem.addEventListener ) { |
| 2980 | + elem.addEventListener( type, eventHandle, false ); |
| 2981 | + |
| 2982 | + } else if ( elem.attachEvent ) { |
| 2983 | + elem.attachEvent( "on" + type, eventHandle ); |
| 2984 | + } |
| 2985 | + } |
| 2986 | + } |
| 2987 | + |
| 2988 | + if ( special.add ) { |
| 2989 | + special.add.call( elem, handleObj ); |
| 2990 | + |
| 2991 | + if ( !handleObj.handler.guid ) { |
| 2992 | + handleObj.handler.guid = handler.guid; |
| 2993 | + } |
| 2994 | + } |
| 2995 | + |
| 2996 | + // Add to the element's handler list, delegates in front |
| 2997 | + if ( selector ) { |
| 2998 | + handlers.splice( handlers.delegateCount++, 0, handleObj ); |
| 2999 | + } else { |
| 3000 | + handlers.push( handleObj ); |
| 3001 | + } |
| 3002 | + |
| 3003 | + // Keep track of which events have ever been used, for event optimization |
| 3004 | + jQuery.event.global[ type ] = true; |
| 3005 | + } |
| 3006 | + |
| 3007 | + // Nullify elem to prevent memory leaks in IE |
| 3008 | + elem = null; |
| 3009 | + }, |
| 3010 | + |
| 3011 | + global: {}, |
| 3012 | + |
| 3013 | + // Detach an event or set of events from an element |
| 3014 | + remove: function( elem, types, handler, selector ) { |
| 3015 | + |
| 3016 | + var elemData = jQuery.hasData( elem ) && jQuery._data( elem ), |
| 3017 | + t, tns, type, namespaces, origCount, |
| 3018 | + j, events, special, handle, eventType, handleObj; |
| 3019 | + |
| 3020 | + if ( !elemData || !(events = elemData.events) ) { |
| 3021 | + return; |
| 3022 | + } |
| 3023 | + |
| 3024 | + // Once for each type.namespace in types; type may be omitted |
| 3025 | + types = hoverHack( types || "" ).split(" "); |
| 3026 | + for ( t = 0; t < types.length; t++ ) { |
| 3027 | + tns = rtypenamespace.exec( types[t] ) || []; |
| 3028 | + type = tns[1]; |
| 3029 | + namespaces = tns[2]; |
| 3030 | + |
| 3031 | + // Unbind all events (on this namespace, if provided) for the element |
| 3032 | + if ( !type ) { |
| 3033 | + namespaces = namespaces? "." + namespaces : ""; |
| 3034 | + for ( j in events ) { |
| 3035 | + jQuery.event.remove( elem, j + namespaces, handler, selector ); |
| 3036 | + } |
| 3037 | + return; |
| 3038 | + } |
| 3039 | + |
| 3040 | + special = jQuery.event.special[ type ] || {}; |
| 3041 | + type = ( selector? special.delegateType : special.bindType ) || type; |
| 3042 | + eventType = events[ type ] || []; |
| 3043 | + origCount = eventType.length; |
| 3044 | + namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.)?") + "(\\.|$)") : null; |
| 3045 | + |
| 3046 | + // Only need to loop for special events or selective removal |
| 3047 | + if ( handler || namespaces || selector || special.remove ) { |
| 3048 | + for ( j = 0; j < eventType.length; j++ ) { |
| 3049 | + handleObj = eventType[ j ]; |
| 3050 | + |
| 3051 | + if ( !handler || handler.guid === handleObj.guid ) { |
| 3052 | + if ( !namespaces || namespaces.test( handleObj.namespace ) ) { |
| 3053 | + if ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) { |
| 3054 | + eventType.splice( j--, 1 ); |
| 3055 | + |
| 3056 | + if ( handleObj.selector ) { |
| 3057 | + eventType.delegateCount--; |
| 3058 | + } |
| 3059 | + if ( special.remove ) { |
| 3060 | + special.remove.call( elem, handleObj ); |
| 3061 | + } |
| 3062 | + } |
| 3063 | + } |
| 3064 | + } |
| 3065 | + } |
| 3066 | + } else { |
| 3067 | + // Removing all events |
| 3068 | + eventType.length = 0; |
| 3069 | + } |
| 3070 | + |
| 3071 | + // Remove generic event handler if we removed something and no more handlers exist |
| 3072 | + // (avoids potential for endless recursion during removal of special event handlers) |
| 3073 | + if ( eventType.length === 0 && origCount !== eventType.length ) { |
| 3074 | + if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) { |
| 3075 | + jQuery.removeEvent( elem, type, elemData.handle ); |
| 3076 | + } |
| 3077 | + |
| 3078 | + delete events[ type ]; |
| 3079 | + } |
| 3080 | + } |
| 3081 | + |
| 3082 | + // Remove the expando if it's no longer used |
| 3083 | + if ( jQuery.isEmptyObject( events ) ) { |
| 3084 | + handle = elemData.handle; |
| 3085 | + if ( handle ) { |
| 3086 | + handle.elem = null; |
| 3087 | + } |
| 3088 | + |
| 3089 | + // removeData also checks for emptiness and clears the expando if empty |
| 3090 | + // so use it instead of delete |
| 3091 | + jQuery.removeData( elem, [ "events", "handle" ], true ); |
| 3092 | + } |
| 3093 | + }, |
| 3094 | + |
| 3095 | + // Events that are safe to short-circuit if no handlers are attached. |
| 3096 | + // Native DOM events should not be added, they may have inline handlers. |
| 3097 | + customEvent: { |
| 3098 | + "getData": true, |
| 3099 | + "setData": true, |
| 3100 | + "changeData": true |
| 3101 | + }, |
| 3102 | + |
| 3103 | + trigger: function( event, data, elem, onlyHandlers ) { |
| 3104 | + // Don't do events on text and comment nodes |
| 3105 | + if ( elem && (elem.nodeType === 3 || elem.nodeType === 8) ) { |
| 3106 | + return; |
| 3107 | + } |
| 3108 | + |
| 3109 | + // Event object or event type |
| 3110 | + var type = event.type || event, |
| 3111 | + namespaces = [], |
| 3112 | + cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType; |
| 3113 | + |
| 3114 | + if ( type.indexOf( "!" ) >= 0 ) { |
| 3115 | + // Exclusive events trigger only for the exact event (no namespaces) |
| 3116 | + type = type.slice(0, -1); |
| 3117 | + exclusive = true; |
| 3118 | + } |
| 3119 | + |
| 3120 | + if ( type.indexOf( "." ) >= 0 ) { |
| 3121 | + // Namespaced trigger; create a regexp to match event type in handle() |
| 3122 | + namespaces = type.split("."); |
| 3123 | + type = namespaces.shift(); |
| 3124 | + namespaces.sort(); |
| 3125 | + } |
| 3126 | + |
| 3127 | + if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) { |
| 3128 | + // No jQuery handlers for this event type, and it can't have inline handlers |
| 3129 | + return; |
| 3130 | + } |
| 3131 | + |
| 3132 | + // Caller can pass in an Event, Object, or just an event type string |
| 3133 | + event = typeof event === "object" ? |
| 3134 | + // jQuery.Event object |
| 3135 | + event[ jQuery.expando ] ? event : |
| 3136 | + // Object literal |
| 3137 | + new jQuery.Event( type, event ) : |
| 3138 | + // Just the event type (string) |
| 3139 | + new jQuery.Event( type ); |
| 3140 | + |
| 3141 | + event.type = type; |
| 3142 | + event.isTrigger = true; |
| 3143 | + event.exclusive = exclusive; |
| 3144 | + event.namespace = namespaces.join( "." ); |
| 3145 | + event.namespace_re = event.namespace? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)") : null; |
| 3146 | + ontype = type.indexOf( ":" ) < 0 ? "on" + type : ""; |
| 3147 | + |
| 3148 | + // triggerHandler() and global events don't bubble or run the default action |
| 3149 | + if ( onlyHandlers || !elem ) { |
| 3150 | + event.preventDefault(); |
| 3151 | + } |
| 3152 | + |
| 3153 | + // Handle a global trigger |
| 3154 | + if ( !elem ) { |
| 3155 | + |
| 3156 | + // TODO: Stop taunting the data cache; remove global events and always attach to document |
| 3157 | + cache = jQuery.cache; |
| 3158 | + for ( i in cache ) { |
| 3159 | + if ( cache[ i ].events && cache[ i ].events[ type ] ) { |
| 3160 | + jQuery.event.trigger( event, data, cache[ i ].handle.elem, true ); |
| 3161 | + } |
| 3162 | + } |
| 3163 | + return; |
| 3164 | + } |
| 3165 | + |
| 3166 | + // Clean up the event in case it is being reused |
| 3167 | + event.result = undefined; |
| 3168 | + if ( !event.target ) { |
| 3169 | + event.target = elem; |
| 3170 | + } |
| 3171 | + |
| 3172 | + // Clone any incoming data and prepend the event, creating the handler arg list |
| 3173 | + data = data != null ? jQuery.makeArray( data ) : []; |
| 3174 | + data.unshift( event ); |
| 3175 | + |
| 3176 | + // Allow special events to draw outside the lines |
| 3177 | + special = jQuery.event.special[ type ] || {}; |
| 3178 | + if ( special.trigger && special.trigger.apply( elem, data ) === false ) { |
| 3179 | + return; |
| 3180 | + } |
| 3181 | + |
| 3182 | + // Determine event propagation path in advance, per W3C events spec (#9951) |
| 3183 | + // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) |
| 3184 | + eventPath = [[ elem, special.bindType || type ]]; |
| 3185 | + if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { |
| 3186 | + |
| 3187 | + bubbleType = special.delegateType || type; |
| 3188 | + old = null; |
| 3189 | + for ( cur = elem.parentNode; cur; cur = cur.parentNode ) { |
| 3190 | + eventPath.push([ cur, bubbleType ]); |
| 3191 | + old = cur; |
| 3192 | + } |
| 3193 | + |
| 3194 | + // Only add window if we got to document (e.g., not plain obj or detached DOM) |
| 3195 | + if ( old && old === elem.ownerDocument ) { |
| 3196 | + eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]); |
| 3197 | + } |
| 3198 | + } |
| 3199 | + |
| 3200 | + // Fire handlers on the event path |
| 3201 | + for ( i = 0; i < eventPath.length; i++ ) { |
| 3202 | + |
| 3203 | + cur = eventPath[i][0]; |
| 3204 | + event.type = eventPath[i][1]; |
| 3205 | + |
| 3206 | + handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" ); |
| 3207 | + if ( handle ) { |
| 3208 | + handle.apply( cur, data ); |
| 3209 | + } |
| 3210 | + handle = ontype && cur[ ontype ]; |
| 3211 | + if ( handle && jQuery.acceptData( cur ) ) { |
| 3212 | + handle.apply( cur, data ); |
| 3213 | + } |
| 3214 | + |
| 3215 | + if ( event.isPropagationStopped() ) { |
| 3216 | + break; |
| 3217 | + } |
| 3218 | + } |
| 3219 | + event.type = type; |
| 3220 | + |
| 3221 | + // If nobody prevented the default action, do it now |
| 3222 | + if ( !event.isDefaultPrevented() ) { |
| 3223 | + |
| 3224 | + if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) && |
| 3225 | + !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) { |
| 3226 | + |
| 3227 | + // Call a native DOM method on the target with the same name name as the event. |
| 3228 | + // Can't use an .isFunction() check here because IE6/7 fails that test. |
| 3229 | + // Don't do default actions on window, that's where global variables be (#6170) |
| 3230 | + // IE<9 dies on focus/blur to hidden element (#1486) |
| 3231 | + if ( ontype && elem[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) && !jQuery.isWindow( elem ) ) { |
| 3232 | + |
| 3233 | + // Don't re-trigger an onFOO event when we call its FOO() method |
| 3234 | + old = elem[ ontype ]; |
| 3235 | + |
| 3236 | + if ( old ) { |
| 3237 | + elem[ ontype ] = null; |
| 3238 | + } |
| 3239 | + |
| 3240 | + // Prevent re-triggering of the same event, since we already bubbled it above |
| 3241 | + jQuery.event.triggered = type; |
| 3242 | + elem[ type ](); |
| 3243 | + jQuery.event.triggered = undefined; |
| 3244 | + |
| 3245 | + if ( old ) { |
| 3246 | + elem[ ontype ] = old; |
| 3247 | + } |
| 3248 | + } |
| 3249 | + } |
| 3250 | + } |
| 3251 | + |
| 3252 | + return event.result; |
| 3253 | + }, |
| 3254 | + |
| 3255 | + dispatch: function( event ) { |
| 3256 | + |
| 3257 | + // Make a writable jQuery.Event from the native event object |
| 3258 | + event = jQuery.event.fix( event || window.event ); |
| 3259 | + |
| 3260 | + var handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []), |
| 3261 | + delegateCount = handlers.delegateCount, |
| 3262 | + args = [].slice.call( arguments, 0 ), |
| 3263 | + run_all = !event.exclusive && !event.namespace, |
| 3264 | + specialHandle = ( jQuery.event.special[ event.type ] || {} ).handle, |
| 3265 | + handlerQueue = [], |
| 3266 | + i, j, cur, ret, selMatch, matched, matches, handleObj, sel, hit, related; |
| 3267 | + |
| 3268 | + // Use the fix-ed jQuery.Event rather than the (read-only) native event |
| 3269 | + args[0] = event; |
| 3270 | + event.delegateTarget = this; |
| 3271 | + |
| 3272 | + // Determine handlers that should run if there are delegated events |
| 3273 | + // Avoid disabled elements in IE (#6911) and non-left-click bubbling in Firefox (#3861) |
| 3274 | + if ( delegateCount && !event.target.disabled && !(event.button && event.type === "click") ) { |
| 3275 | + |
| 3276 | + for ( cur = event.target; cur != this; cur = cur.parentNode || this ) { |
| 3277 | + selMatch = {}; |
| 3278 | + matches = []; |
| 3279 | + for ( i = 0; i < delegateCount; i++ ) { |
| 3280 | + handleObj = handlers[ i ]; |
| 3281 | + sel = handleObj.selector; |
| 3282 | + hit = selMatch[ sel ]; |
| 3283 | + |
| 3284 | + if ( handleObj.isPositional ) { |
| 3285 | + // Since .is() does not work for positionals; see http://jsfiddle.net/eJ4yd/3/ |
| 3286 | + hit = ( hit || (selMatch[ sel ] = jQuery( sel )) ).index( cur ) >= 0; |
| 3287 | + } else if ( hit === undefined ) { |
| 3288 | + hit = selMatch[ sel ] = ( handleObj.quick ? quickIs( cur, handleObj.quick ) : jQuery( cur ).is( sel ) ); |
| 3289 | + } |
| 3290 | + if ( hit ) { |
| 3291 | + matches.push( handleObj ); |
| 3292 | + } |
| 3293 | + } |
| 3294 | + if ( matches.length ) { |
| 3295 | + handlerQueue.push({ elem: cur, matches: matches }); |
| 3296 | + } |
| 3297 | + } |
| 3298 | + } |
| 3299 | + |
| 3300 | + // Add the remaining (directly-bound) handlers |
| 3301 | + if ( handlers.length > delegateCount ) { |
| 3302 | + handlerQueue.push({ elem: this, matches: handlers.slice( delegateCount ) }); |
| 3303 | + } |
| 3304 | + |
| 3305 | + // Run delegates first; they may want to stop propagation beneath us |
| 3306 | + for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) { |
| 3307 | + matched = handlerQueue[ i ]; |
| 3308 | + event.currentTarget = matched.elem; |
| 3309 | + |
| 3310 | + for ( j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++ ) { |
| 3311 | + handleObj = matched.matches[ j ]; |
| 3312 | + |
| 3313 | + // Triggered event must either 1) be non-exclusive and have no namespace, or |
| 3314 | + // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace). |
| 3315 | + if ( run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) { |
| 3316 | + |
| 3317 | + event.data = handleObj.data; |
| 3318 | + event.handleObj = handleObj; |
| 3319 | + |
| 3320 | + ret = ( specialHandle || handleObj.handler ).apply( matched.elem, args ); |
| 3321 | + |
| 3322 | + if ( ret !== undefined ) { |
| 3323 | + event.result = ret; |
| 3324 | + if ( ret === false ) { |
| 3325 | + event.preventDefault(); |
| 3326 | + event.stopPropagation(); |
| 3327 | + } |
| 3328 | + } |
| 3329 | + } |
| 3330 | + } |
| 3331 | + } |
| 3332 | + |
| 3333 | + return event.result; |
| 3334 | + }, |
| 3335 | + |
| 3336 | + // Includes some event props shared by KeyEvent and MouseEvent |
| 3337 | + // *** attrChange attrName relatedNode srcElement are not normalized, non-W3C, deprecated, will be removed in 1.8 *** |
| 3338 | + props: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), |
| 3339 | + |
| 3340 | + fixHooks: {}, |
| 3341 | + |
| 3342 | + keyHooks: { |
| 3343 | + props: "char charCode key keyCode".split(" "), |
| 3344 | + filter: function( event, original ) { |
| 3345 | + |
| 3346 | + // Add which for key events |
| 3347 | + if ( event.which == null ) { |
| 3348 | + event.which = original.charCode != null ? original.charCode : original.keyCode; |
| 3349 | + } |
| 3350 | + |
| 3351 | + return event; |
| 3352 | + } |
| 3353 | + }, |
| 3354 | + |
| 3355 | + mouseHooks: { |
| 3356 | + props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement wheelDelta".split(" "), |
| 3357 | + filter: function( event, original ) { |
| 3358 | + var eventDoc, doc, body, |
| 3359 | + button = original.button, |
| 3360 | + fromElement = original.fromElement; |
| 3361 | + |
| 3362 | + // Calculate pageX/Y if missing and clientX/Y available |
| 3363 | + if ( event.pageX == null && original.clientX != null ) { |
| 3364 | + eventDoc = event.target.ownerDocument || document; |
| 3365 | + doc = eventDoc.documentElement; |
| 3366 | + body = eventDoc.body; |
| 3367 | + |
| 3368 | + event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 ); |
| 3369 | + event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 ); |
| 3370 | + } |
| 3371 | + |
| 3372 | + // Add relatedTarget, if necessary |
| 3373 | + if ( !event.relatedTarget && fromElement ) { |
| 3374 | + event.relatedTarget = fromElement === event.target ? original.toElement : fromElement; |
| 3375 | + } |
| 3376 | + |
| 3377 | + // Add which for click: 1 === left; 2 === middle; 3 === right |
| 3378 | + // Note: button is not normalized, so don't use it |
| 3379 | + if ( !event.which && button !== undefined ) { |
| 3380 | + event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); |
| 3381 | + } |
| 3382 | + |
| 3383 | + return event; |
| 3384 | + } |
| 3385 | + }, |
| 3386 | + |
| 3387 | + fix: function( event ) { |
| 3388 | + if ( event[ jQuery.expando ] ) { |
| 3389 | + return event; |
| 3390 | + } |
| 3391 | + |
| 3392 | + // Create a writable copy of the event object and normalize some properties |
| 3393 | + var i, prop, |
| 3394 | + originalEvent = event, |
| 3395 | + fixHook = jQuery.event.fixHooks[ event.type ] || {}, |
| 3396 | + copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; |
| 3397 | + |
| 3398 | + event = jQuery.Event( originalEvent ); |
| 3399 | + |
| 3400 | + for ( i = copy.length; i; ) { |
| 3401 | + prop = copy[ --i ]; |
| 3402 | + event[ prop ] = originalEvent[ prop ]; |
| 3403 | + } |
| 3404 | + |
| 3405 | + // Fix target property, if necessary (#1925, IE 6/7/8 & Safari2) |
| 3406 | + if ( !event.target ) { |
| 3407 | + event.target = originalEvent.srcElement || document; |
| 3408 | + } |
| 3409 | + |
| 3410 | + // Target should not be a text node (#504, Safari) |
| 3411 | + if ( event.target.nodeType === 3 ) { |
| 3412 | + event.target = event.target.parentNode; |
| 3413 | + } |
| 3414 | + |
| 3415 | + // For mouse/key events; add metaKey if it's not there (#3368, IE6/7/8) |
| 3416 | + if ( event.metaKey === undefined ) { |
| 3417 | + event.metaKey = event.ctrlKey; |
| 3418 | + } |
| 3419 | + |
| 3420 | + return fixHook.filter? fixHook.filter( event, originalEvent ) : event; |
| 3421 | + }, |
| 3422 | + |
| 3423 | + special: { |
| 3424 | + ready: { |
| 3425 | + // Make sure the ready event is setup |
| 3426 | + setup: jQuery.bindReady |
| 3427 | + }, |
| 3428 | + |
| 3429 | + focus: { |
| 3430 | + delegateType: "focusin", |
| 3431 | + noBubble: true |
| 3432 | + }, |
| 3433 | + blur: { |
| 3434 | + delegateType: "focusout", |
| 3435 | + noBubble: true |
| 3436 | + }, |
| 3437 | + |
| 3438 | + beforeunload: { |
| 3439 | + setup: function( data, namespaces, eventHandle ) { |
| 3440 | + // We only want to do this special case on windows |
| 3441 | + if ( jQuery.isWindow( this ) ) { |
| 3442 | + this.onbeforeunload = eventHandle; |
| 3443 | + } |
| 3444 | + }, |
| 3445 | + |
| 3446 | + teardown: function( namespaces, eventHandle ) { |
| 3447 | + if ( this.onbeforeunload === eventHandle ) { |
| 3448 | + this.onbeforeunload = null; |
| 3449 | + } |
| 3450 | + } |
| 3451 | + } |
| 3452 | + }, |
| 3453 | + |
| 3454 | + simulate: function( type, elem, event, bubble ) { |
| 3455 | + // Piggyback on a donor event to simulate a different one. |
| 3456 | + // Fake originalEvent to avoid donor's stopPropagation, but if the |
| 3457 | + // simulated event prevents default then we do the same on the donor. |
| 3458 | + var e = jQuery.extend( |
| 3459 | + new jQuery.Event(), |
| 3460 | + event, |
| 3461 | + { type: type, |
| 3462 | + isSimulated: true, |
| 3463 | + originalEvent: {} |
| 3464 | + } |
| 3465 | + ); |
| 3466 | + if ( bubble ) { |
| 3467 | + jQuery.event.trigger( e, null, elem ); |
| 3468 | + } else { |
| 3469 | + jQuery.event.dispatch.call( elem, e ); |
| 3470 | + } |
| 3471 | + if ( e.isDefaultPrevented() ) { |
| 3472 | + event.preventDefault(); |
| 3473 | + } |
| 3474 | + } |
| 3475 | +}; |
| 3476 | + |
| 3477 | +// Some plugins are using, but it's undocumented/deprecated and will be removed. |
| 3478 | +// The 1.7 special event interface should provide all the hooks needed now. |
| 3479 | +jQuery.event.handle = jQuery.event.dispatch; |
| 3480 | + |
| 3481 | +jQuery.removeEvent = document.removeEventListener ? |
| 3482 | + function( elem, type, handle ) { |
| 3483 | + if ( elem.removeEventListener ) { |
| 3484 | + elem.removeEventListener( type, handle, false ); |
| 3485 | + } |
| 3486 | + } : |
| 3487 | + function( elem, type, handle ) { |
| 3488 | + if ( elem.detachEvent ) { |
| 3489 | + elem.detachEvent( "on" + type, handle ); |
| 3490 | + } |
| 3491 | + }; |
| 3492 | + |
| 3493 | +jQuery.Event = function( src, props ) { |
| 3494 | + // Allow instantiation without the 'new' keyword |
| 3495 | + if ( !(this instanceof jQuery.Event) ) { |
| 3496 | + return new jQuery.Event( src, props ); |
| 3497 | + } |
| 3498 | + |
| 3499 | + // Event object |
| 3500 | + if ( src && src.type ) { |
| 3501 | + this.originalEvent = src; |
| 3502 | + this.type = src.type; |
| 3503 | + |
| 3504 | + // Events bubbling up the document may have been marked as prevented |
| 3505 | + // by a handler lower down the tree; reflect the correct value. |
| 3506 | + this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false || |
| 3507 | + src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse; |
| 3508 | + |
| 3509 | + // Event type |
| 3510 | + } else { |
| 3511 | + this.type = src; |
| 3512 | + } |
| 3513 | + |
| 3514 | + // Put explicitly provided properties onto the event object |
| 3515 | + if ( props ) { |
| 3516 | + jQuery.extend( this, props ); |
| 3517 | + } |
| 3518 | + |
| 3519 | + // Create a timestamp if incoming event doesn't have one |
| 3520 | + this.timeStamp = src && src.timeStamp || jQuery.now(); |
| 3521 | + |
| 3522 | + // Mark it as fixed |
| 3523 | + this[ jQuery.expando ] = true; |
| 3524 | +}; |
| 3525 | + |
| 3526 | +function returnFalse() { |
| 3527 | + return false; |
| 3528 | +} |
| 3529 | +function returnTrue() { |
| 3530 | + return true; |
| 3531 | +} |
| 3532 | + |
| 3533 | +// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding |
| 3534 | +// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html |
| 3535 | +jQuery.Event.prototype = { |
| 3536 | + preventDefault: function() { |
| 3537 | + this.isDefaultPrevented = returnTrue; |
| 3538 | + |
| 3539 | + var e = this.originalEvent; |
| 3540 | + if ( !e ) { |
| 3541 | + return; |
| 3542 | + } |
| 3543 | + |
| 3544 | + // if preventDefault exists run it on the original event |
| 3545 | + if ( e.preventDefault ) { |
| 3546 | + e.preventDefault(); |
| 3547 | + |
| 3548 | + // otherwise set the returnValue property of the original event to false (IE) |
| 3549 | + } else { |
| 3550 | + e.returnValue = false; |
| 3551 | + } |
| 3552 | + }, |
| 3553 | + stopPropagation: function() { |
| 3554 | + this.isPropagationStopped = returnTrue; |
| 3555 | + |
| 3556 | + var e = this.originalEvent; |
| 3557 | + if ( !e ) { |
| 3558 | + return; |
| 3559 | + } |
| 3560 | + // if stopPropagation exists run it on the original event |
| 3561 | + if ( e.stopPropagation ) { |
| 3562 | + e.stopPropagation(); |
| 3563 | + } |
| 3564 | + // otherwise set the cancelBubble property of the original event to true (IE) |
| 3565 | + e.cancelBubble = true; |
| 3566 | + }, |
| 3567 | + stopImmediatePropagation: function() { |
| 3568 | + this.isImmediatePropagationStopped = returnTrue; |
| 3569 | + this.stopPropagation(); |
| 3570 | + }, |
| 3571 | + isDefaultPrevented: returnFalse, |
| 3572 | + isPropagationStopped: returnFalse, |
| 3573 | + isImmediatePropagationStopped: returnFalse |
| 3574 | +}; |
| 3575 | + |
| 3576 | +// Create mouseenter/leave events using mouseover/out and event-time checks |
| 3577 | +jQuery.each({ |
| 3578 | + mouseenter: "mouseover", |
| 3579 | + mouseleave: "mouseout" |
| 3580 | +}, function( orig, fix ) { |
| 3581 | + jQuery.event.special[ orig ] = jQuery.event.special[ fix ] = { |
| 3582 | + delegateType: fix, |
| 3583 | + bindType: fix, |
| 3584 | + |
| 3585 | + handle: function( event ) { |
| 3586 | + var target = this, |
| 3587 | + related = event.relatedTarget, |
| 3588 | + handleObj = event.handleObj, |
| 3589 | + selector = handleObj.selector, |
| 3590 | + oldType, ret; |
| 3591 | + |
| 3592 | + // For a real mouseover/out, always call the handler; for |
| 3593 | + // mousenter/leave call the handler if related is outside the target. |
| 3594 | + // NB: No relatedTarget if the mouse left/entered the browser window |
| 3595 | + if ( !related || handleObj.origType === event.type || (related !== target && !jQuery.contains( target, related )) ) { |
| 3596 | + oldType = event.type; |
| 3597 | + event.type = handleObj.origType; |
| 3598 | + ret = handleObj.handler.apply( this, arguments ); |
| 3599 | + event.type = oldType; |
| 3600 | + } |
| 3601 | + return ret; |
| 3602 | + } |
| 3603 | + }; |
| 3604 | +}); |
| 3605 | + |
| 3606 | +// IE submit delegation |
| 3607 | +if ( !jQuery.support.submitBubbles ) { |
| 3608 | + |
| 3609 | + jQuery.event.special.submit = { |
| 3610 | + setup: function() { |
| 3611 | + // Only need this for delegated form submit events |
| 3612 | + if ( jQuery.nodeName( this, "form" ) ) { |
| 3613 | + return false; |
| 3614 | + } |
| 3615 | + |
| 3616 | + // Lazy-add a submit handler when a descendant form may potentially be submitted |
| 3617 | + jQuery.event.add( this, "click._submit keypress._submit", function( e ) { |
| 3618 | + // Node name check avoids a VML-related crash in IE (#9807) |
| 3619 | + var elem = e.target, |
| 3620 | + form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined; |
| 3621 | + if ( form && !form._submit_attached ) { |
| 3622 | + jQuery.event.add( form, "submit._submit", function( event ) { |
| 3623 | + // Form was submitted, bubble the event up the tree |
| 3624 | + if ( this.parentNode ) { |
| 3625 | + jQuery.event.simulate( "submit", this.parentNode, event, true ); |
| 3626 | + } |
| 3627 | + }); |
| 3628 | + form._submit_attached = true; |
| 3629 | + } |
| 3630 | + }); |
| 3631 | + // return undefined since we don't need an event listener |
| 3632 | + }, |
| 3633 | + |
| 3634 | + teardown: function() { |
| 3635 | + // Only need this for delegated form submit events |
| 3636 | + if ( jQuery.nodeName( this, "form" ) ) { |
| 3637 | + return false; |
| 3638 | + } |
| 3639 | + |
| 3640 | + // Remove delegated handlers; cleanData eventually reaps submit handlers attached above |
| 3641 | + jQuery.event.remove( this, "._submit" ); |
| 3642 | + } |
| 3643 | + }; |
| 3644 | +} |
| 3645 | + |
| 3646 | +// IE change delegation and checkbox/radio fix |
| 3647 | +if ( !jQuery.support.changeBubbles ) { |
| 3648 | + |
| 3649 | + jQuery.event.special.change = { |
| 3650 | + |
| 3651 | + setup: function() { |
| 3652 | + |
| 3653 | + if ( rformElems.test( this.nodeName ) ) { |
| 3654 | + // IE doesn't fire change on a check/radio until blur; trigger it on click |
| 3655 | + // after a propertychange. Eat the blur-change in special.change.handle. |
| 3656 | + // This still fires onchange a second time for check/radio after blur. |
| 3657 | + if ( this.type === "checkbox" || this.type === "radio" ) { |
| 3658 | + jQuery.event.add( this, "propertychange._change", function( event ) { |
| 3659 | + if ( event.originalEvent.propertyName === "checked" ) { |
| 3660 | + this._just_changed = true; |
| 3661 | + } |
| 3662 | + }); |
| 3663 | + jQuery.event.add( this, "click._change", function( event ) { |
| 3664 | + if ( this._just_changed ) { |
| 3665 | + this._just_changed = false; |
| 3666 | + jQuery.event.simulate( "change", this, event, true ); |
| 3667 | + } |
| 3668 | + }); |
| 3669 | + } |
| 3670 | + return false; |
| 3671 | + } |
| 3672 | + // Delegated event; lazy-add a change handler on descendant inputs |
| 3673 | + jQuery.event.add( this, "beforeactivate._change", function( e ) { |
| 3674 | + var elem = e.target; |
| 3675 | + |
| 3676 | + if ( rformElems.test( elem.nodeName ) && !elem._change_attached ) { |
| 3677 | + jQuery.event.add( elem, "change._change", function( event ) { |
| 3678 | + if ( this.parentNode && !event.isSimulated ) { |
| 3679 | + jQuery.event.simulate( "change", this.parentNode, event, true ); |
| 3680 | + } |
| 3681 | + }); |
| 3682 | + elem._change_attached = true; |
| 3683 | + } |
| 3684 | + }); |
| 3685 | + }, |
| 3686 | + |
| 3687 | + handle: function( event ) { |
| 3688 | + var elem = event.target; |
| 3689 | + |
| 3690 | + // Swallow native change events from checkbox/radio, we already triggered them above |
| 3691 | + if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) { |
| 3692 | + return event.handleObj.handler.apply( this, arguments ); |
| 3693 | + } |
| 3694 | + }, |
| 3695 | + |
| 3696 | + teardown: function() { |
| 3697 | + jQuery.event.remove( this, "._change" ); |
| 3698 | + |
| 3699 | + return rformElems.test( this.nodeName ); |
| 3700 | + } |
| 3701 | + }; |
| 3702 | +} |
| 3703 | + |
| 3704 | +// Create "bubbling" focus and blur events |
| 3705 | +if ( !jQuery.support.focusinBubbles ) { |
| 3706 | + jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { |
| 3707 | + |
| 3708 | + // Attach a single capturing handler while someone wants focusin/focusout |
| 3709 | + var attaches = 0, |
| 3710 | + handler = function( event ) { |
| 3711 | + jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true ); |
| 3712 | + }; |
| 3713 | + |
| 3714 | + jQuery.event.special[ fix ] = { |
| 3715 | + setup: function() { |
| 3716 | + if ( attaches++ === 0 ) { |
| 3717 | + document.addEventListener( orig, handler, true ); |
| 3718 | + } |
| 3719 | + }, |
| 3720 | + teardown: function() { |
| 3721 | + if ( --attaches === 0 ) { |
| 3722 | + document.removeEventListener( orig, handler, true ); |
| 3723 | + } |
| 3724 | + } |
| 3725 | + }; |
| 3726 | + }); |
| 3727 | +} |
| 3728 | + |
| 3729 | +jQuery.fn.extend({ |
| 3730 | + |
| 3731 | + on: function( types, selector, data, fn, /*INTERNAL*/ one ) { |
| 3732 | + var origFn, type; |
| 3733 | + |
| 3734 | + // Types can be a map of types/handlers |
| 3735 | + if ( typeof types === "object" ) { |
| 3736 | + // ( types-Object, selector, data ) |
| 3737 | + if ( typeof selector !== "string" ) { |
| 3738 | + // ( types-Object, data ) |
| 3739 | + data = selector; |
| 3740 | + selector = undefined; |
| 3741 | + } |
| 3742 | + for ( type in types ) { |
| 3743 | + this.on( type, selector, data, types[ type ], one ); |
| 3744 | + } |
| 3745 | + return this; |
| 3746 | + } |
| 3747 | + |
| 3748 | + if ( data == null && fn == null ) { |
| 3749 | + // ( types, fn ) |
| 3750 | + fn = selector; |
| 3751 | + data = selector = undefined; |
| 3752 | + } else if ( fn == null ) { |
| 3753 | + if ( typeof selector === "string" ) { |
| 3754 | + // ( types, selector, fn ) |
| 3755 | + fn = data; |
| 3756 | + data = undefined; |
| 3757 | + } else { |
| 3758 | + // ( types, data, fn ) |
| 3759 | + fn = data; |
| 3760 | + data = selector; |
| 3761 | + selector = undefined; |
| 3762 | + } |
| 3763 | + } |
| 3764 | + if ( fn === false ) { |
| 3765 | + fn = returnFalse; |
| 3766 | + } else if ( !fn ) { |
| 3767 | + return this; |
| 3768 | + } |
| 3769 | + |
| 3770 | + if ( one === 1 ) { |
| 3771 | + origFn = fn; |
| 3772 | + fn = function( event ) { |
| 3773 | + // Can use an empty set, since event contains the info |
| 3774 | + jQuery().off( event ); |
| 3775 | + return origFn.apply( this, arguments ); |
| 3776 | + }; |
| 3777 | + // Use same guid so caller can remove using origFn |
| 3778 | + fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); |
| 3779 | + } |
| 3780 | + return this.each( function() { |
| 3781 | + jQuery.event.add( this, types, fn, data, selector ); |
| 3782 | + }); |
| 3783 | + }, |
| 3784 | + one: function( types, selector, data, fn ) { |
| 3785 | + return this.on.call( this, types, selector, data, fn, 1 ); |
| 3786 | + }, |
| 3787 | + off: function( types, selector, fn ) { |
| 3788 | + if ( types && types.preventDefault && types.handleObj ) { |
| 3789 | + // ( event ) dispatched jQuery.Event |
| 3790 | + var handleObj = types.handleObj; |
| 3791 | + jQuery( types.delegateTarget ).off( |
| 3792 | + handleObj.namespace? handleObj.type + "." + handleObj.namespace : handleObj.type, |
| 3793 | + handleObj.selector, |
| 3794 | + handleObj.handler |
| 3795 | + ); |
| 3796 | + return this; |
| 3797 | + } |
| 3798 | + if ( typeof types === "object" ) { |
| 3799 | + // ( types-object [, selector] ) |
| 3800 | + for ( var type in types ) { |
| 3801 | + this.off( type, selector, types[ type ] ); |
| 3802 | + } |
| 3803 | + return this; |
| 3804 | + } |
| 3805 | + if ( selector === false || typeof selector === "function" ) { |
| 3806 | + // ( types [, fn] ) |
| 3807 | + fn = selector; |
| 3808 | + selector = undefined; |
| 3809 | + } |
| 3810 | + if ( fn === false ) { |
| 3811 | + fn = returnFalse; |
| 3812 | + } |
| 3813 | + return this.each(function() { |
| 3814 | + jQuery.event.remove( this, types, fn, selector ); |
| 3815 | + }); |
| 3816 | + }, |
| 3817 | + |
| 3818 | + bind: function( types, data, fn ) { |
| 3819 | + return this.on( types, null, data, fn ); |
| 3820 | + }, |
| 3821 | + unbind: function( types, fn ) { |
| 3822 | + return this.off( types, null, fn ); |
| 3823 | + }, |
| 3824 | + |
| 3825 | + live: function( types, data, fn ) { |
| 3826 | + jQuery( this.context ).on( types, this.selector, data, fn ); |
| 3827 | + return this; |
| 3828 | + }, |
| 3829 | + die: function( types, fn ) { |
| 3830 | + jQuery( this.context ).off( types, this.selector || "**", fn ); |
| 3831 | + return this; |
| 3832 | + }, |
| 3833 | + |
| 3834 | + delegate: function( selector, types, data, fn ) { |
| 3835 | + return this.on( types, selector, data, fn ); |
| 3836 | + }, |
| 3837 | + undelegate: function( selector, types, fn ) { |
| 3838 | + // ( namespace ) or ( selector, types [, fn] ) |
| 3839 | + return arguments.length == 1? this.off( selector, "**" ) : this.off( types, selector, fn ); |
| 3840 | + }, |
| 3841 | + |
| 3842 | + trigger: function( type, data ) { |
| 3843 | + return this.each(function() { |
| 3844 | + jQuery.event.trigger( type, data, this ); |
| 3845 | + }); |
| 3846 | + }, |
| 3847 | + triggerHandler: function( type, data ) { |
| 3848 | + if ( this[0] ) { |
| 3849 | + return jQuery.event.trigger( type, data, this[0], true ); |
| 3850 | + } |
| 3851 | + }, |
| 3852 | + |
| 3853 | + toggle: function( fn ) { |
| 3854 | + // Save reference to arguments for access in closure |
| 3855 | + var args = arguments, |
| 3856 | + guid = fn.guid || jQuery.guid++, |
| 3857 | + i = 0, |
| 3858 | + toggler = function( event ) { |
| 3859 | + // Figure out which function to execute |
| 3860 | + var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i; |
| 3861 | + jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 ); |
| 3862 | + |
| 3863 | + // Make sure that clicks stop |
| 3864 | + event.preventDefault(); |
| 3865 | + |
| 3866 | + // and execute the function |
| 3867 | + return args[ lastToggle ].apply( this, arguments ) || false; |
| 3868 | + }; |
| 3869 | + |
| 3870 | + // link all the functions, so any of them can unbind this click handler |
| 3871 | + toggler.guid = guid; |
| 3872 | + while ( i < args.length ) { |
| 3873 | + args[ i++ ].guid = guid; |
| 3874 | + } |
| 3875 | + |
| 3876 | + return this.click( toggler ); |
| 3877 | + }, |
| 3878 | + |
| 3879 | + hover: function( fnOver, fnOut ) { |
| 3880 | + return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); |
| 3881 | + } |
| 3882 | +}); |
| 3883 | + |
| 3884 | +jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " + |
| 3885 | + "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + |
| 3886 | + "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) { |
| 3887 | + |
| 3888 | + // Handle event binding |
| 3889 | + jQuery.fn[ name ] = function( data, fn ) { |
| 3890 | + if ( fn == null ) { |
| 3891 | + fn = data; |
| 3892 | + data = null; |
| 3893 | + } |
| 3894 | + |
| 3895 | + return arguments.length > 0 ? |
| 3896 | + this.bind( name, data, fn ) : |
| 3897 | + this.trigger( name ); |
| 3898 | + }; |
| 3899 | + |
| 3900 | + if ( jQuery.attrFn ) { |
| 3901 | + jQuery.attrFn[ name ] = true; |
| 3902 | + } |
| 3903 | + |
| 3904 | + if ( rkeyEvent.test( name ) ) { |
| 3905 | + jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks; |
| 3906 | + } |
| 3907 | + |
| 3908 | + if ( rmouseEvent.test( name ) ) { |
| 3909 | + jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks; |
| 3910 | + } |
| 3911 | +}); |
| 3912 | + |
| 3913 | + |
| 3914 | + |
| 3915 | +/*! |
| 3916 | + * Sizzle CSS Selector Engine |
| 3917 | + * Copyright 2011, The Dojo Foundation |
| 3918 | + * Released under the MIT, BSD, and GPL Licenses. |
| 3919 | + * More information: http://sizzlejs.com/ |
| 3920 | + */ |
| 3921 | +(function(){ |
| 3922 | + |
| 3923 | +var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g, |
| 3924 | + expando = "sizcache" + (Math.random() + '').replace('.', ''), |
| 3925 | + done = 0, |
| 3926 | + toString = Object.prototype.toString, |
| 3927 | + hasDuplicate = false, |
| 3928 | + baseHasDuplicate = true, |
| 3929 | + rBackslash = /\\/g, |
| 3930 | + rReturn = /\r\n/g, |
| 3931 | + rNonWord = /\W/; |
| 3932 | + |
| 3933 | +// Here we check if the JavaScript engine is using some sort of |
| 3934 | +// optimization where it does not always call our comparision |
| 3935 | +// function. If that is the case, discard the hasDuplicate value. |
| 3936 | +// Thus far that includes Google Chrome. |
| 3937 | +[0, 0].sort(function() { |
| 3938 | + baseHasDuplicate = false; |
| 3939 | + return 0; |
| 3940 | +}); |
| 3941 | + |
| 3942 | +var Sizzle = function( selector, context, results, seed ) { |
| 3943 | + results = results || []; |
| 3944 | + context = context || document; |
| 3945 | + |
| 3946 | + var origContext = context; |
| 3947 | + |
| 3948 | + if ( context.nodeType !== 1 && context.nodeType !== 9 ) { |
| 3949 | + return []; |
| 3950 | + } |
| 3951 | + |
| 3952 | + if ( !selector || typeof selector !== "string" ) { |
| 3953 | + return results; |
| 3954 | + } |
| 3955 | + |
| 3956 | + var m, set, checkSet, extra, ret, cur, pop, i, |
| 3957 | + prune = true, |
| 3958 | + contextXML = Sizzle.isXML( context ), |
| 3959 | + parts = [], |
| 3960 | + soFar = selector; |
| 3961 | + |
| 3962 | + // Reset the position of the chunker regexp (start from head) |
| 3963 | + do { |
| 3964 | + chunker.exec( "" ); |
| 3965 | + m = chunker.exec( soFar ); |
| 3966 | + |
| 3967 | + if ( m ) { |
| 3968 | + soFar = m[3]; |
| 3969 | + |
| 3970 | + parts.push( m[1] ); |
| 3971 | + |
| 3972 | + if ( m[2] ) { |
| 3973 | + extra = m[3]; |
| 3974 | + break; |
| 3975 | + } |
| 3976 | + } |
| 3977 | + } while ( m ); |
| 3978 | + |
| 3979 | + if ( parts.length > 1 && origPOS.exec( selector ) ) { |
| 3980 | + |
| 3981 | + if ( parts.length === 2 && Expr.relative[ parts[0] ] ) { |
| 3982 | + set = posProcess( parts[0] + parts[1], context, seed ); |
| 3983 | + |
| 3984 | + } else { |
| 3985 | + set = Expr.relative[ parts[0] ] ? |
| 3986 | + [ context ] : |
| 3987 | + Sizzle( parts.shift(), context ); |
| 3988 | + |
| 3989 | + while ( parts.length ) { |
| 3990 | + selector = parts.shift(); |
| 3991 | + |
| 3992 | + if ( Expr.relative[ selector ] ) { |
| 3993 | + selector += parts.shift(); |
| 3994 | + } |
| 3995 | + |
| 3996 | + set = posProcess( selector, set, seed ); |
| 3997 | + } |
| 3998 | + } |
| 3999 | + |
| 4000 | + } else { |
| 4001 | + // Take a shortcut and set the context if the root selector is an ID |
| 4002 | + // (but not if it'll be faster if the inner selector is an ID) |
| 4003 | + if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML && |
| 4004 | + Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) { |
| 4005 | + |
| 4006 | + ret = Sizzle.find( parts.shift(), context, contextXML ); |
| 4007 | + context = ret.expr ? |
| 4008 | + Sizzle.filter( ret.expr, ret.set )[0] : |
| 4009 | + ret.set[0]; |
| 4010 | + } |
| 4011 | + |
| 4012 | + if ( context ) { |
| 4013 | + ret = seed ? |
| 4014 | + { expr: parts.pop(), set: makeArray(seed) } : |
| 4015 | + Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML ); |
| 4016 | + |
| 4017 | + set = ret.expr ? |
| 4018 | + Sizzle.filter( ret.expr, ret.set ) : |
| 4019 | + ret.set; |
| 4020 | + |
| 4021 | + if ( parts.length > 0 ) { |
| 4022 | + checkSet = makeArray( set ); |
| 4023 | + |
| 4024 | + } else { |
| 4025 | + prune = false; |
| 4026 | + } |
| 4027 | + |
| 4028 | + while ( parts.length ) { |
| 4029 | + cur = parts.pop(); |
| 4030 | + pop = cur; |
| 4031 | + |
| 4032 | + if ( !Expr.relative[ cur ] ) { |
| 4033 | + cur = ""; |
| 4034 | + } else { |
| 4035 | + pop = parts.pop(); |
| 4036 | + } |
| 4037 | + |
| 4038 | + if ( pop == null ) { |
| 4039 | + pop = context; |
| 4040 | + } |
| 4041 | + |
| 4042 | + Expr.relative[ cur ]( checkSet, pop, contextXML ); |
| 4043 | + } |
| 4044 | + |
| 4045 | + } else { |
| 4046 | + checkSet = parts = []; |
| 4047 | + } |
| 4048 | + } |
| 4049 | + |
| 4050 | + if ( !checkSet ) { |
| 4051 | + checkSet = set; |
| 4052 | + } |
| 4053 | + |
| 4054 | + if ( !checkSet ) { |
| 4055 | + Sizzle.error( cur || selector ); |
| 4056 | + } |
| 4057 | + |
| 4058 | + if ( toString.call(checkSet) === "[object Array]" ) { |
| 4059 | + if ( !prune ) { |
| 4060 | + results.push.apply( results, checkSet ); |
| 4061 | + |
| 4062 | + } else if ( context && context.nodeType === 1 ) { |
| 4063 | + for ( i = 0; checkSet[i] != null; i++ ) { |
| 4064 | + if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) { |
| 4065 | + results.push( set[i] ); |
| 4066 | + } |
| 4067 | + } |
| 4068 | + |
| 4069 | + } else { |
| 4070 | + for ( i = 0; checkSet[i] != null; i++ ) { |
| 4071 | + if ( checkSet[i] && checkSet[i].nodeType === 1 ) { |
| 4072 | + results.push( set[i] ); |
| 4073 | + } |
| 4074 | + } |
| 4075 | + } |
| 4076 | + |
| 4077 | + } else { |
| 4078 | + makeArray( checkSet, results ); |
| 4079 | + } |
| 4080 | + |
| 4081 | + if ( extra ) { |
| 4082 | + Sizzle( extra, origContext, results, seed ); |
| 4083 | + Sizzle.uniqueSort( results ); |
| 4084 | + } |
| 4085 | + |
| 4086 | + return results; |
| 4087 | +}; |
| 4088 | + |
| 4089 | +Sizzle.uniqueSort = function( results ) { |
| 4090 | + if ( sortOrder ) { |
| 4091 | + hasDuplicate = baseHasDuplicate; |
| 4092 | + results.sort( sortOrder ); |
| 4093 | + |
| 4094 | + if ( hasDuplicate ) { |
| 4095 | + for ( var i = 1; i < results.length; i++ ) { |
| 4096 | + if ( results[i] === results[ i - 1 ] ) { |
| 4097 | + results.splice( i--, 1 ); |
| 4098 | + } |
| 4099 | + } |
| 4100 | + } |
| 4101 | + } |
| 4102 | + |
| 4103 | + return results; |
| 4104 | +}; |
| 4105 | + |
| 4106 | +Sizzle.matches = function( expr, set ) { |
| 4107 | + return Sizzle( expr, null, null, set ); |
| 4108 | +}; |
| 4109 | + |
| 4110 | +Sizzle.matchesSelector = function( node, expr ) { |
| 4111 | + return Sizzle( expr, null, null, [node] ).length > 0; |
| 4112 | +}; |
| 4113 | + |
| 4114 | +Sizzle.find = function( expr, context, isXML ) { |
| 4115 | + var set, i, len, match, type, left; |
| 4116 | + |
| 4117 | + if ( !expr ) { |
| 4118 | + return []; |
| 4119 | + } |
| 4120 | + |
| 4121 | + for ( i = 0, len = Expr.order.length; i < len; i++ ) { |
| 4122 | + type = Expr.order[i]; |
| 4123 | + |
| 4124 | + if ( (match = Expr.leftMatch[ type ].exec( expr )) ) { |
| 4125 | + left = match[1]; |
| 4126 | + match.splice( 1, 1 ); |
| 4127 | + |
| 4128 | + if ( left.substr( left.length - 1 ) !== "\\" ) { |
| 4129 | + match[1] = (match[1] || "").replace( rBackslash, "" ); |
| 4130 | + set = Expr.find[ type ]( match, context, isXML ); |
| 4131 | + |
| 4132 | + if ( set != null ) { |
| 4133 | + expr = expr.replace( Expr.match[ type ], "" ); |
| 4134 | + break; |
| 4135 | + } |
| 4136 | + } |
| 4137 | + } |
| 4138 | + } |
| 4139 | + |
| 4140 | + if ( !set ) { |
| 4141 | + set = typeof context.getElementsByTagName !== "undefined" ? |
| 4142 | + context.getElementsByTagName( "*" ) : |
| 4143 | + []; |
| 4144 | + } |
| 4145 | + |
| 4146 | + return { set: set, expr: expr }; |
| 4147 | +}; |
| 4148 | + |
| 4149 | +Sizzle.filter = function( expr, set, inplace, not ) { |
| 4150 | + var match, anyFound, |
| 4151 | + type, found, item, filter, left, |
| 4152 | + i, pass, |
| 4153 | + old = expr, |
| 4154 | + result = [], |
| 4155 | + curLoop = set, |
| 4156 | + isXMLFilter = set && set[0] && Sizzle.isXML( set[0] ); |
| 4157 | + |
| 4158 | + while ( expr && set.length ) { |
| 4159 | + for ( type in Expr.filter ) { |
| 4160 | + if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) { |
| 4161 | + filter = Expr.filter[ type ]; |
| 4162 | + left = match[1]; |
| 4163 | + |
| 4164 | + anyFound = false; |
| 4165 | + |
| 4166 | + match.splice(1,1); |
| 4167 | + |
| 4168 | + if ( left.substr( left.length - 1 ) === "\\" ) { |
| 4169 | + continue; |
| 4170 | + } |
| 4171 | + |
| 4172 | + if ( curLoop === result ) { |
| 4173 | + result = []; |
| 4174 | + } |
| 4175 | + |
| 4176 | + if ( Expr.preFilter[ type ] ) { |
| 4177 | + match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter ); |
| 4178 | + |
| 4179 | + if ( !match ) { |
| 4180 | + anyFound = found = true; |
| 4181 | + |
| 4182 | + } else if ( match === true ) { |
| 4183 | + continue; |
| 4184 | + } |
| 4185 | + } |
| 4186 | + |
| 4187 | + if ( match ) { |
| 4188 | + for ( i = 0; (item = curLoop[i]) != null; i++ ) { |
| 4189 | + if ( item ) { |
| 4190 | + found = filter( item, match, i, curLoop ); |
| 4191 | + pass = not ^ found; |
| 4192 | + |
| 4193 | + if ( inplace && found != null ) { |
| 4194 | + if ( pass ) { |
| 4195 | + anyFound = true; |
| 4196 | + |
| 4197 | + } else { |
| 4198 | + curLoop[i] = false; |
| 4199 | + } |
| 4200 | + |
| 4201 | + } else if ( pass ) { |
| 4202 | + result.push( item ); |
| 4203 | + anyFound = true; |
| 4204 | + } |
| 4205 | + } |
| 4206 | + } |
| 4207 | + } |
| 4208 | + |
| 4209 | + if ( found !== undefined ) { |
| 4210 | + if ( !inplace ) { |
| 4211 | + curLoop = result; |
| 4212 | + } |
| 4213 | + |
| 4214 | + expr = expr.replace( Expr.match[ type ], "" ); |
| 4215 | + |
| 4216 | + if ( !anyFound ) { |
| 4217 | + return []; |
| 4218 | + } |
| 4219 | + |
| 4220 | + break; |
| 4221 | + } |
| 4222 | + } |
| 4223 | + } |
| 4224 | + |
| 4225 | + // Improper expression |
| 4226 | + if ( expr === old ) { |
| 4227 | + if ( anyFound == null ) { |
| 4228 | + Sizzle.error( expr ); |
| 4229 | + |
| 4230 | + } else { |
| 4231 | + break; |
| 4232 | + } |
| 4233 | + } |
| 4234 | + |
| 4235 | + old = expr; |
| 4236 | + } |
| 4237 | + |
| 4238 | + return curLoop; |
| 4239 | +}; |
| 4240 | + |
| 4241 | +Sizzle.error = function( msg ) { |
| 4242 | + throw "Syntax error, unrecognized expression: " + msg; |
| 4243 | +}; |
| 4244 | + |
| 4245 | +/** |
| 4246 | + * Utility function for retreiving the text value of an array of DOM nodes |
| 4247 | + * @param {Array|Element} elem |
| 4248 | + */ |
| 4249 | +var getText = Sizzle.getText = function( elem ) { |
| 4250 | + var i, node, |
| 4251 | + nodeType = elem.nodeType, |
| 4252 | + ret = ""; |
| 4253 | + |
| 4254 | + if ( nodeType ) { |
| 4255 | + if ( nodeType === 1 ) { |
| 4256 | + // Use textContent || innerText for elements |
| 4257 | + if ( typeof elem.textContent === 'string' ) { |
| 4258 | + return elem.textContent; |
| 4259 | + } else if ( typeof elem.innerText === 'string' ) { |
| 4260 | + // Replace IE's carriage returns |
| 4261 | + return elem.innerText.replace( rReturn, '' ); |
| 4262 | + } else { |
| 4263 | + // Traverse it's children |
| 4264 | + for ( elem = elem.firstChild; elem; elem = elem.nextSibling) { |
| 4265 | + ret += getText( elem ); |
| 4266 | + } |
| 4267 | + } |
| 4268 | + } else if ( nodeType === 3 || nodeType === 4 ) { |
| 4269 | + return elem.nodeValue; |
| 4270 | + } |
| 4271 | + } else { |
| 4272 | + |
| 4273 | + // If no nodeType, this is expected to be an array |
| 4274 | + for ( i = 0; (node = elem[i]); i++ ) { |
| 4275 | + // Do not traverse comment nodes |
| 4276 | + if ( node.nodeType !== 8 ) { |
| 4277 | + ret += getText( node ); |
| 4278 | + } |
| 4279 | + } |
| 4280 | + } |
| 4281 | + return ret; |
| 4282 | +}; |
| 4283 | + |
| 4284 | +var Expr = Sizzle.selectors = { |
| 4285 | + order: [ "ID", "NAME", "TAG" ], |
| 4286 | + |
| 4287 | + match: { |
| 4288 | + ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, |
| 4289 | + CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, |
| 4290 | + NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/, |
| 4291 | + ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/, |
| 4292 | + TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/, |
| 4293 | + CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/, |
| 4294 | + POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/, |
| 4295 | + PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/ |
| 4296 | + }, |
| 4297 | + |
| 4298 | + leftMatch: {}, |
| 4299 | + |
| 4300 | + attrMap: { |
| 4301 | + "class": "className", |
| 4302 | + "for": "htmlFor" |
| 4303 | + }, |
| 4304 | + |
| 4305 | + attrHandle: { |
| 4306 | + href: function( elem ) { |
| 4307 | + return elem.getAttribute( "href" ); |
| 4308 | + }, |
| 4309 | + type: function( elem ) { |
| 4310 | + return elem.getAttribute( "type" ); |
| 4311 | + } |
| 4312 | + }, |
| 4313 | + |
| 4314 | + relative: { |
| 4315 | + "+": function(checkSet, part){ |
| 4316 | + var isPartStr = typeof part === "string", |
| 4317 | + isTag = isPartStr && !rNonWord.test( part ), |
| 4318 | + isPartStrNotTag = isPartStr && !isTag; |
| 4319 | + |
| 4320 | + if ( isTag ) { |
| 4321 | + part = part.toLowerCase(); |
| 4322 | + } |
| 4323 | + |
| 4324 | + for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) { |
| 4325 | + if ( (elem = checkSet[i]) ) { |
| 4326 | + while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {} |
| 4327 | + |
| 4328 | + checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ? |
| 4329 | + elem || false : |
| 4330 | + elem === part; |
| 4331 | + } |
| 4332 | + } |
| 4333 | + |
| 4334 | + if ( isPartStrNotTag ) { |
| 4335 | + Sizzle.filter( part, checkSet, true ); |
| 4336 | + } |
| 4337 | + }, |
| 4338 | + |
| 4339 | + ">": function( checkSet, part ) { |
| 4340 | + var elem, |
| 4341 | + isPartStr = typeof part === "string", |
| 4342 | + i = 0, |
| 4343 | + l = checkSet.length; |
| 4344 | + |
| 4345 | + if ( isPartStr && !rNonWord.test( part ) ) { |
| 4346 | + part = part.toLowerCase(); |
| 4347 | + |
| 4348 | + for ( ; i < l; i++ ) { |
| 4349 | + elem = checkSet[i]; |
| 4350 | + |
| 4351 | + if ( elem ) { |
| 4352 | + var parent = elem.parentNode; |
| 4353 | + checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false; |
| 4354 | + } |
| 4355 | + } |
| 4356 | + |
| 4357 | + } else { |
| 4358 | + for ( ; i < l; i++ ) { |
| 4359 | + elem = checkSet[i]; |
| 4360 | + |
| 4361 | + if ( elem ) { |
| 4362 | + checkSet[i] = isPartStr ? |
| 4363 | + elem.parentNode : |
| 4364 | + elem.parentNode === part; |
| 4365 | + } |
| 4366 | + } |
| 4367 | + |
| 4368 | + if ( isPartStr ) { |
| 4369 | + Sizzle.filter( part, checkSet, true ); |
| 4370 | + } |
| 4371 | + } |
| 4372 | + }, |
| 4373 | + |
| 4374 | + "": function(checkSet, part, isXML){ |
| 4375 | + var nodeCheck, |
| 4376 | + doneName = done++, |
| 4377 | + checkFn = dirCheck; |
| 4378 | + |
| 4379 | + if ( typeof part === "string" && !rNonWord.test( part ) ) { |
| 4380 | + part = part.toLowerCase(); |
| 4381 | + nodeCheck = part; |
| 4382 | + checkFn = dirNodeCheck; |
| 4383 | + } |
| 4384 | + |
| 4385 | + checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML ); |
| 4386 | + }, |
| 4387 | + |
| 4388 | + "~": function( checkSet, part, isXML ) { |
| 4389 | + var nodeCheck, |
| 4390 | + doneName = done++, |
| 4391 | + checkFn = dirCheck; |
| 4392 | + |
| 4393 | + if ( typeof part === "string" && !rNonWord.test( part ) ) { |
| 4394 | + part = part.toLowerCase(); |
| 4395 | + nodeCheck = part; |
| 4396 | + checkFn = dirNodeCheck; |
| 4397 | + } |
| 4398 | + |
| 4399 | + checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML ); |
| 4400 | + } |
| 4401 | + }, |
| 4402 | + |
| 4403 | + find: { |
| 4404 | + ID: function( match, context, isXML ) { |
| 4405 | + if ( typeof context.getElementById !== "undefined" && !isXML ) { |
| 4406 | + var m = context.getElementById(match[1]); |
| 4407 | + // Check parentNode to catch when Blackberry 4.6 returns |
| 4408 | + // nodes that are no longer in the document #6963 |
| 4409 | + return m && m.parentNode ? [m] : []; |
| 4410 | + } |
| 4411 | + }, |
| 4412 | + |
| 4413 | + NAME: function( match, context ) { |
| 4414 | + if ( typeof context.getElementsByName !== "undefined" ) { |
| 4415 | + var ret = [], |
| 4416 | + results = context.getElementsByName( match[1] ); |
| 4417 | + |
| 4418 | + for ( var i = 0, l = results.length; i < l; i++ ) { |
| 4419 | + if ( results[i].getAttribute("name") === match[1] ) { |
| 4420 | + ret.push( results[i] ); |
| 4421 | + } |
| 4422 | + } |
| 4423 | + |
| 4424 | + return ret.length === 0 ? null : ret; |
| 4425 | + } |
| 4426 | + }, |
| 4427 | + |
| 4428 | + TAG: function( match, context ) { |
| 4429 | + if ( typeof context.getElementsByTagName !== "undefined" ) { |
| 4430 | + return context.getElementsByTagName( match[1] ); |
| 4431 | + } |
| 4432 | + } |
| 4433 | + }, |
| 4434 | + preFilter: { |
| 4435 | + CLASS: function( match, curLoop, inplace, result, not, isXML ) { |
| 4436 | + match = " " + match[1].replace( rBackslash, "" ) + " "; |
| 4437 | + |
| 4438 | + if ( isXML ) { |
| 4439 | + return match; |
| 4440 | + } |
| 4441 | + |
| 4442 | + for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) { |
| 4443 | + if ( elem ) { |
| 4444 | + if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) { |
| 4445 | + if ( !inplace ) { |
| 4446 | + result.push( elem ); |
| 4447 | + } |
| 4448 | + |
| 4449 | + } else if ( inplace ) { |
| 4450 | + curLoop[i] = false; |
| 4451 | + } |
| 4452 | + } |
| 4453 | + } |
| 4454 | + |
| 4455 | + return false; |
| 4456 | + }, |
| 4457 | + |
| 4458 | + ID: function( match ) { |
| 4459 | + return match[1].replace( rBackslash, "" ); |
| 4460 | + }, |
| 4461 | + |
| 4462 | + TAG: function( match, curLoop ) { |
| 4463 | + return match[1].replace( rBackslash, "" ).toLowerCase(); |
| 4464 | + }, |
| 4465 | + |
| 4466 | + CHILD: function( match ) { |
| 4467 | + if ( match[1] === "nth" ) { |
| 4468 | + if ( !match[2] ) { |
| 4469 | + Sizzle.error( match[0] ); |
| 4470 | + } |
| 4471 | + |
| 4472 | + match[2] = match[2].replace(/^\+|\s*/g, ''); |
| 4473 | + |
| 4474 | + // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6' |
| 4475 | + var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec( |
| 4476 | + match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" || |
| 4477 | + !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]); |
| 4478 | + |
| 4479 | + // calculate the numbers (first)n+(last) including if they are negative |
| 4480 | + match[2] = (test[1] + (test[2] || 1)) - 0; |
| 4481 | + match[3] = test[3] - 0; |
| 4482 | + } |
| 4483 | + else if ( match[2] ) { |
| 4484 | + Sizzle.error( match[0] ); |
| 4485 | + } |
| 4486 | + |
| 4487 | + // TODO: Move to normal caching system |
| 4488 | + match[0] = done++; |
| 4489 | + |
| 4490 | + return match; |
| 4491 | + }, |
| 4492 | + |
| 4493 | + ATTR: function( match, curLoop, inplace, result, not, isXML ) { |
| 4494 | + var name = match[1] = match[1].replace( rBackslash, "" ); |
| 4495 | + |
| 4496 | + if ( !isXML && Expr.attrMap[name] ) { |
| 4497 | + match[1] = Expr.attrMap[name]; |
| 4498 | + } |
| 4499 | + |
| 4500 | + // Handle if an un-quoted value was used |
| 4501 | + match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" ); |
| 4502 | + |
| 4503 | + if ( match[2] === "~=" ) { |
| 4504 | + match[4] = " " + match[4] + " "; |
| 4505 | + } |
| 4506 | + |
| 4507 | + return match; |
| 4508 | + }, |
| 4509 | + |
| 4510 | + PSEUDO: function( match, curLoop, inplace, result, not ) { |
| 4511 | + if ( match[1] === "not" ) { |
| 4512 | + // If we're dealing with a complex expression, or a simple one |
| 4513 | + if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) { |
| 4514 | + match[3] = Sizzle(match[3], null, null, curLoop); |
| 4515 | + |
| 4516 | + } else { |
| 4517 | + var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not); |
| 4518 | + |
| 4519 | + if ( !inplace ) { |
| 4520 | + result.push.apply( result, ret ); |
| 4521 | + } |
| 4522 | + |
| 4523 | + return false; |
| 4524 | + } |
| 4525 | + |
| 4526 | + } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { |
| 4527 | + return true; |
| 4528 | + } |
| 4529 | + |
| 4530 | + return match; |
| 4531 | + }, |
| 4532 | + |
| 4533 | + POS: function( match ) { |
| 4534 | + match.unshift( true ); |
| 4535 | + |
| 4536 | + return match; |
| 4537 | + } |
| 4538 | + }, |
| 4539 | + |
| 4540 | + filters: { |
| 4541 | + enabled: function( elem ) { |
| 4542 | + return elem.disabled === false && elem.type !== "hidden"; |
| 4543 | + }, |
| 4544 | + |
| 4545 | + disabled: function( elem ) { |
| 4546 | + return elem.disabled === true; |
| 4547 | + }, |
| 4548 | + |
| 4549 | + checked: function( elem ) { |
| 4550 | + return elem.checked === true; |
| 4551 | + }, |
| 4552 | + |
| 4553 | + selected: function( elem ) { |
| 4554 | + // Accessing this property makes selected-by-default |
| 4555 | + // options in Safari work properly |
| 4556 | + if ( elem.parentNode ) { |
| 4557 | + elem.parentNode.selectedIndex; |
| 4558 | + } |
| 4559 | + |
| 4560 | + return elem.selected === true; |
| 4561 | + }, |
| 4562 | + |
| 4563 | + parent: function( elem ) { |
| 4564 | + return !!elem.firstChild; |
| 4565 | + }, |
| 4566 | + |
| 4567 | + empty: function( elem ) { |
| 4568 | + return !elem.firstChild; |
| 4569 | + }, |
| 4570 | + |
| 4571 | + has: function( elem, i, match ) { |
| 4572 | + return !!Sizzle( match[3], elem ).length; |
| 4573 | + }, |
| 4574 | + |
| 4575 | + header: function( elem ) { |
| 4576 | + return (/h\d/i).test( elem.nodeName ); |
| 4577 | + }, |
| 4578 | + |
| 4579 | + text: function( elem ) { |
| 4580 | + var attr = elem.getAttribute( "type" ), type = elem.type; |
| 4581 | + // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) |
| 4582 | + // use getAttribute instead to test this case |
| 4583 | + return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null ); |
| 4584 | + }, |
| 4585 | + |
| 4586 | + radio: function( elem ) { |
| 4587 | + return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type; |
| 4588 | + }, |
| 4589 | + |
| 4590 | + checkbox: function( elem ) { |
| 4591 | + return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type; |
| 4592 | + }, |
| 4593 | + |
| 4594 | + file: function( elem ) { |
| 4595 | + return elem.nodeName.toLowerCase() === "input" && "file" === elem.type; |
| 4596 | + }, |
| 4597 | + |
| 4598 | + password: function( elem ) { |
| 4599 | + return elem.nodeName.toLowerCase() === "input" && "password" === elem.type; |
| 4600 | + }, |
| 4601 | + |
| 4602 | + submit: function( elem ) { |
| 4603 | + var name = elem.nodeName.toLowerCase(); |
| 4604 | + return (name === "input" || name === "button") && "submit" === elem.type; |
| 4605 | + }, |
| 4606 | + |
| 4607 | + image: function( elem ) { |
| 4608 | + return elem.nodeName.toLowerCase() === "input" && "image" === elem.type; |
| 4609 | + }, |
| 4610 | + |
| 4611 | + reset: function( elem ) { |
| 4612 | + var name = elem.nodeName.toLowerCase(); |
| 4613 | + return (name === "input" || name === "button") && "reset" === elem.type; |
| 4614 | + }, |
| 4615 | + |
| 4616 | + button: function( elem ) { |
| 4617 | + var name = elem.nodeName.toLowerCase(); |
| 4618 | + return name === "input" && "button" === elem.type || name === "button"; |
| 4619 | + }, |
| 4620 | + |
| 4621 | + input: function( elem ) { |
| 4622 | + return (/input|select|textarea|button/i).test( elem.nodeName ); |
| 4623 | + }, |
| 4624 | + |
| 4625 | + focus: function( elem ) { |
| 4626 | + return elem === elem.ownerDocument.activeElement; |
| 4627 | + } |
| 4628 | + }, |
| 4629 | + setFilters: { |
| 4630 | + first: function( elem, i ) { |
| 4631 | + return i === 0; |
| 4632 | + }, |
| 4633 | + |
| 4634 | + last: function( elem, i, match, array ) { |
| 4635 | + return i === array.length - 1; |
| 4636 | + }, |
| 4637 | + |
| 4638 | + even: function( elem, i ) { |
| 4639 | + return i % 2 === 0; |
| 4640 | + }, |
| 4641 | + |
| 4642 | + odd: function( elem, i ) { |
| 4643 | + return i % 2 === 1; |
| 4644 | + }, |
| 4645 | + |
| 4646 | + lt: function( elem, i, match ) { |
| 4647 | + return i < match[3] - 0; |
| 4648 | + }, |
| 4649 | + |
| 4650 | + gt: function( elem, i, match ) { |
| 4651 | + return i > match[3] - 0; |
| 4652 | + }, |
| 4653 | + |
| 4654 | + nth: function( elem, i, match ) { |
| 4655 | + return match[3] - 0 === i; |
| 4656 | + }, |
| 4657 | + |
| 4658 | + eq: function( elem, i, match ) { |
| 4659 | + return match[3] - 0 === i; |
| 4660 | + } |
| 4661 | + }, |
| 4662 | + filter: { |
| 4663 | + PSEUDO: function( elem, match, i, array ) { |
| 4664 | + var name = match[1], |
| 4665 | + filter = Expr.filters[ name ]; |
| 4666 | + |
| 4667 | + if ( filter ) { |
| 4668 | + return filter( elem, i, match, array ); |
| 4669 | + |
| 4670 | + } else if ( name === "contains" ) { |
| 4671 | + return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0; |
| 4672 | + |
| 4673 | + } else if ( name === "not" ) { |
| 4674 | + var not = match[3]; |
| 4675 | + |
| 4676 | + for ( var j = 0, l = not.length; j < l; j++ ) { |
| 4677 | + if ( not[j] === elem ) { |
| 4678 | + return false; |
| 4679 | + } |
| 4680 | + } |
| 4681 | + |
| 4682 | + return true; |
| 4683 | + |
| 4684 | + } else { |
| 4685 | + Sizzle.error( name ); |
| 4686 | + } |
| 4687 | + }, |
| 4688 | + |
| 4689 | + CHILD: function( elem, match ) { |
| 4690 | + var first, last, |
| 4691 | + doneName, parent, cache, |
| 4692 | + count, diff, |
| 4693 | + type = match[1], |
| 4694 | + node = elem; |
| 4695 | + |
| 4696 | + switch ( type ) { |
| 4697 | + case "only": |
| 4698 | + case "first": |
| 4699 | + while ( (node = node.previousSibling) ) { |
| 4700 | + if ( node.nodeType === 1 ) { |
| 4701 | + return false; |
| 4702 | + } |
| 4703 | + } |
| 4704 | + |
| 4705 | + if ( type === "first" ) { |
| 4706 | + return true; |
| 4707 | + } |
| 4708 | + |
| 4709 | + node = elem; |
| 4710 | + |
| 4711 | + case "last": |
| 4712 | + while ( (node = node.nextSibling) ) { |
| 4713 | + if ( node.nodeType === 1 ) { |
| 4714 | + return false; |
| 4715 | + } |
| 4716 | + } |
| 4717 | + |
| 4718 | + return true; |
| 4719 | + |
| 4720 | + case "nth": |
| 4721 | + first = match[2]; |
| 4722 | + last = match[3]; |
| 4723 | + |
| 4724 | + if ( first === 1 && last === 0 ) { |
| 4725 | + return true; |
| 4726 | + } |
| 4727 | + |
| 4728 | + doneName = match[0]; |
| 4729 | + parent = elem.parentNode; |
| 4730 | + |
| 4731 | + if ( parent && (parent[ expando ] !== doneName || !elem.nodeIndex) ) { |
| 4732 | + count = 0; |
| 4733 | + |
| 4734 | + for ( node = parent.firstChild; node; node = node.nextSibling ) { |
| 4735 | + if ( node.nodeType === 1 ) { |
| 4736 | + node.nodeIndex = ++count; |
| 4737 | + } |
| 4738 | + } |
| 4739 | + |
| 4740 | + parent[ expando ] = doneName; |
| 4741 | + } |
| 4742 | + |
| 4743 | + diff = elem.nodeIndex - last; |
| 4744 | + |
| 4745 | + if ( first === 0 ) { |
| 4746 | + return diff === 0; |
| 4747 | + |
| 4748 | + } else { |
| 4749 | + return ( diff % first === 0 && diff / first >= 0 ); |
| 4750 | + } |
| 4751 | + } |
| 4752 | + }, |
| 4753 | + |
| 4754 | + ID: function( elem, match ) { |
| 4755 | + return elem.nodeType === 1 && elem.getAttribute("id") === match; |
| 4756 | + }, |
| 4757 | + |
| 4758 | + TAG: function( elem, match ) { |
| 4759 | + return (match === "*" && elem.nodeType === 1) || !!elem.nodeName && elem.nodeName.toLowerCase() === match; |
| 4760 | + }, |
| 4761 | + |
| 4762 | + CLASS: function( elem, match ) { |
| 4763 | + return (" " + (elem.className || elem.getAttribute("class")) + " ") |
| 4764 | + .indexOf( match ) > -1; |
| 4765 | + }, |
| 4766 | + |
| 4767 | + ATTR: function( elem, match ) { |
| 4768 | + var name = match[1], |
| 4769 | + result = Sizzle.attr ? |
| 4770 | + Sizzle.attr( elem, name ) : |
| 4771 | + Expr.attrHandle[ name ] ? |
| 4772 | + Expr.attrHandle[ name ]( elem ) : |
| 4773 | + elem[ name ] != null ? |
| 4774 | + elem[ name ] : |
| 4775 | + elem.getAttribute( name ), |
| 4776 | + value = result + "", |
| 4777 | + type = match[2], |
| 4778 | + check = match[4]; |
| 4779 | + |
| 4780 | + return result == null ? |
| 4781 | + type === "!=" : |
| 4782 | + !type && Sizzle.attr ? |
| 4783 | + result != null : |
| 4784 | + type === "=" ? |
| 4785 | + value === check : |
| 4786 | + type === "*=" ? |
| 4787 | + value.indexOf(check) >= 0 : |
| 4788 | + type === "~=" ? |
| 4789 | + (" " + value + " ").indexOf(check) >= 0 : |
| 4790 | + !check ? |
| 4791 | + value && result !== false : |
| 4792 | + type === "!=" ? |
| 4793 | + value !== check : |
| 4794 | + type === "^=" ? |
| 4795 | + value.indexOf(check) === 0 : |
| 4796 | + type === "$=" ? |
| 4797 | + value.substr(value.length - check.length) === check : |
| 4798 | + type === "|=" ? |
| 4799 | + value === check || value.substr(0, check.length + 1) === check + "-" : |
| 4800 | + false; |
| 4801 | + }, |
| 4802 | + |
| 4803 | + POS: function( elem, match, i, array ) { |
| 4804 | + var name = match[2], |
| 4805 | + filter = Expr.setFilters[ name ]; |
| 4806 | + |
| 4807 | + if ( filter ) { |
| 4808 | + return filter( elem, i, match, array ); |
| 4809 | + } |
| 4810 | + } |
| 4811 | + } |
| 4812 | +}; |
| 4813 | + |
| 4814 | +var origPOS = Expr.match.POS, |
| 4815 | + fescape = function(all, num){ |
| 4816 | + return "\\" + (num - 0 + 1); |
| 4817 | + }; |
| 4818 | + |
| 4819 | +for ( var type in Expr.match ) { |
| 4820 | + Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) ); |
| 4821 | + Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) ); |
| 4822 | +} |
| 4823 | + |
| 4824 | +var makeArray = function( array, results ) { |
| 4825 | + array = Array.prototype.slice.call( array, 0 ); |
| 4826 | + |
| 4827 | + if ( results ) { |
| 4828 | + results.push.apply( results, array ); |
| 4829 | + return results; |
| 4830 | + } |
| 4831 | + |
| 4832 | + return array; |
| 4833 | +}; |
| 4834 | + |
| 4835 | +// Perform a simple check to determine if the browser is capable of |
| 4836 | +// converting a NodeList to an array using builtin methods. |
| 4837 | +// Also verifies that the returned array holds DOM nodes |
| 4838 | +// (which is not the case in the Blackberry browser) |
| 4839 | +try { |
| 4840 | + Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType; |
| 4841 | + |
| 4842 | +// Provide a fallback method if it does not work |
| 4843 | +} catch( e ) { |
| 4844 | + makeArray = function( array, results ) { |
| 4845 | + var i = 0, |
| 4846 | + ret = results || []; |
| 4847 | + |
| 4848 | + if ( toString.call(array) === "[object Array]" ) { |
| 4849 | + Array.prototype.push.apply( ret, array ); |
| 4850 | + |
| 4851 | + } else { |
| 4852 | + if ( typeof array.length === "number" ) { |
| 4853 | + for ( var l = array.length; i < l; i++ ) { |
| 4854 | + ret.push( array[i] ); |
| 4855 | + } |
| 4856 | + |
| 4857 | + } else { |
| 4858 | + for ( ; array[i]; i++ ) { |
| 4859 | + ret.push( array[i] ); |
| 4860 | + } |
| 4861 | + } |
| 4862 | + } |
| 4863 | + |
| 4864 | + return ret; |
| 4865 | + }; |
| 4866 | +} |
| 4867 | + |
| 4868 | +var sortOrder, siblingCheck; |
| 4869 | + |
| 4870 | +if ( document.documentElement.compareDocumentPosition ) { |
| 4871 | + sortOrder = function( a, b ) { |
| 4872 | + if ( a === b ) { |
| 4873 | + hasDuplicate = true; |
| 4874 | + return 0; |
| 4875 | + } |
| 4876 | + |
| 4877 | + if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) { |
| 4878 | + return a.compareDocumentPosition ? -1 : 1; |
| 4879 | + } |
| 4880 | + |
| 4881 | + return a.compareDocumentPosition(b) & 4 ? -1 : 1; |
| 4882 | + }; |
| 4883 | + |
| 4884 | +} else { |
| 4885 | + sortOrder = function( a, b ) { |
| 4886 | + // The nodes are identical, we can exit early |
| 4887 | + if ( a === b ) { |
| 4888 | + hasDuplicate = true; |
| 4889 | + return 0; |
| 4890 | + |
| 4891 | + // Fallback to using sourceIndex (in IE) if it's available on both nodes |
| 4892 | + } else if ( a.sourceIndex && b.sourceIndex ) { |
| 4893 | + return a.sourceIndex - b.sourceIndex; |
| 4894 | + } |
| 4895 | + |
| 4896 | + var al, bl, |
| 4897 | + ap = [], |
| 4898 | + bp = [], |
| 4899 | + aup = a.parentNode, |
| 4900 | + bup = b.parentNode, |
| 4901 | + cur = aup; |
| 4902 | + |
| 4903 | + // If the nodes are siblings (or identical) we can do a quick check |
| 4904 | + if ( aup === bup ) { |
| 4905 | + return siblingCheck( a, b ); |
| 4906 | + |
| 4907 | + // If no parents were found then the nodes are disconnected |
| 4908 | + } else if ( !aup ) { |
| 4909 | + return -1; |
| 4910 | + |
| 4911 | + } else if ( !bup ) { |
| 4912 | + return 1; |
| 4913 | + } |
| 4914 | + |
| 4915 | + // Otherwise they're somewhere else in the tree so we need |
| 4916 | + // to build up a full list of the parentNodes for comparison |
| 4917 | + while ( cur ) { |
| 4918 | + ap.unshift( cur ); |
| 4919 | + cur = cur.parentNode; |
| 4920 | + } |
| 4921 | + |
| 4922 | + cur = bup; |
| 4923 | + |
| 4924 | + while ( cur ) { |
| 4925 | + bp.unshift( cur ); |
| 4926 | + cur = cur.parentNode; |
| 4927 | + } |
| 4928 | + |
| 4929 | + al = ap.length; |
| 4930 | + bl = bp.length; |
| 4931 | + |
| 4932 | + // Start walking down the tree looking for a discrepancy |
| 4933 | + for ( var i = 0; i < al && i < bl; i++ ) { |
| 4934 | + if ( ap[i] !== bp[i] ) { |
| 4935 | + return siblingCheck( ap[i], bp[i] ); |
| 4936 | + } |
| 4937 | + } |
| 4938 | + |
| 4939 | + // We ended someplace up the tree so do a sibling check |
| 4940 | + return i === al ? |
| 4941 | + siblingCheck( a, bp[i], -1 ) : |
| 4942 | + siblingCheck( ap[i], b, 1 ); |
| 4943 | + }; |
| 4944 | + |
| 4945 | + siblingCheck = function( a, b, ret ) { |
| 4946 | + if ( a === b ) { |
| 4947 | + return ret; |
| 4948 | + } |
| 4949 | + |
| 4950 | + var cur = a.nextSibling; |
| 4951 | + |
| 4952 | + while ( cur ) { |
| 4953 | + if ( cur === b ) { |
| 4954 | + return -1; |
| 4955 | + } |
| 4956 | + |
| 4957 | + cur = cur.nextSibling; |
| 4958 | + } |
| 4959 | + |
| 4960 | + return 1; |
| 4961 | + }; |
| 4962 | +} |
| 4963 | + |
| 4964 | +// Check to see if the browser returns elements by name when |
| 4965 | +// querying by getElementById (and provide a workaround) |
| 4966 | +(function(){ |
| 4967 | + // We're going to inject a fake input element with a specified name |
| 4968 | + var form = document.createElement("div"), |
| 4969 | + id = "script" + (new Date()).getTime(), |
| 4970 | + root = document.documentElement; |
| 4971 | + |
| 4972 | + form.innerHTML = "<a name='" + id + "'/>"; |
| 4973 | + |
| 4974 | + // Inject it into the root element, check its status, and remove it quickly |
| 4975 | + root.insertBefore( form, root.firstChild ); |
| 4976 | + |
| 4977 | + // The workaround has to do additional checks after a getElementById |
| 4978 | + // Which slows things down for other browsers (hence the branching) |
| 4979 | + if ( document.getElementById( id ) ) { |
| 4980 | + Expr.find.ID = function( match, context, isXML ) { |
| 4981 | + if ( typeof context.getElementById !== "undefined" && !isXML ) { |
| 4982 | + var m = context.getElementById(match[1]); |
| 4983 | + |
| 4984 | + return m ? |
| 4985 | + m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? |
| 4986 | + [m] : |
| 4987 | + undefined : |
| 4988 | + []; |
| 4989 | + } |
| 4990 | + }; |
| 4991 | + |
| 4992 | + Expr.filter.ID = function( elem, match ) { |
| 4993 | + var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); |
| 4994 | + |
| 4995 | + return elem.nodeType === 1 && node && node.nodeValue === match; |
| 4996 | + }; |
| 4997 | + } |
| 4998 | + |
| 4999 | + root.removeChild( form ); |
| 5000 | + |
| 5001 | + // release memory in IE |
| 5002 | + root = form = null; |
| 5003 | +})(); |
| 5004 | + |
| 5005 | +(function(){ |
| 5006 | + // Check to see if the browser returns only elements |
| 5007 | + // when doing getElementsByTagName("*") |
| 5008 | + |
| 5009 | + // Create a fake element |
| 5010 | + var div = document.createElement("div"); |
| 5011 | + div.appendChild( document.createComment("") ); |
| 5012 | + |
| 5013 | + // Make sure no comments are found |
| 5014 | + if ( div.getElementsByTagName("*").length > 0 ) { |
| 5015 | + Expr.find.TAG = function( match, context ) { |
| 5016 | + var results = context.getElementsByTagName( match[1] ); |
| 5017 | + |
| 5018 | + // Filter out possible comments |
| 5019 | + if ( match[1] === "*" ) { |
| 5020 | + var tmp = []; |
| 5021 | + |
| 5022 | + for ( var i = 0; results[i]; i++ ) { |
| 5023 | + if ( results[i].nodeType === 1 ) { |
| 5024 | + tmp.push( results[i] ); |
| 5025 | + } |
| 5026 | + } |
| 5027 | + |
| 5028 | + results = tmp; |
| 5029 | + } |
| 5030 | + |
| 5031 | + return results; |
| 5032 | + }; |
| 5033 | + } |
| 5034 | + |
| 5035 | + // Check to see if an attribute returns normalized href attributes |
| 5036 | + div.innerHTML = "<a href='#'></a>"; |
| 5037 | + |
| 5038 | + if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" && |
| 5039 | + div.firstChild.getAttribute("href") !== "#" ) { |
| 5040 | + |
| 5041 | + Expr.attrHandle.href = function( elem ) { |
| 5042 | + return elem.getAttribute( "href", 2 ); |
| 5043 | + }; |
| 5044 | + } |
| 5045 | + |
| 5046 | + // release memory in IE |
| 5047 | + div = null; |
| 5048 | +})(); |
| 5049 | + |
| 5050 | +if ( document.querySelectorAll ) { |
| 5051 | + (function(){ |
| 5052 | + var oldSizzle = Sizzle, |
| 5053 | + div = document.createElement("div"), |
| 5054 | + id = "__sizzle__"; |
| 5055 | + |
| 5056 | + div.innerHTML = "<p class='TEST'></p>"; |
| 5057 | + |
| 5058 | + // Safari can't handle uppercase or unicode characters when |
| 5059 | + // in quirks mode. |
| 5060 | + if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { |
| 5061 | + return; |
| 5062 | + } |
| 5063 | + |
| 5064 | + Sizzle = function( query, context, extra, seed ) { |
| 5065 | + context = context || document; |
| 5066 | + |
| 5067 | + // Only use querySelectorAll on non-XML documents |
| 5068 | + // (ID selectors don't work in non-HTML documents) |
| 5069 | + if ( !seed && !Sizzle.isXML(context) ) { |
| 5070 | + // See if we find a selector to speed up |
| 5071 | + var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query ); |
| 5072 | + |
| 5073 | + if ( match && (context.nodeType === 1 || context.nodeType === 9) ) { |
| 5074 | + // Speed-up: Sizzle("TAG") |
| 5075 | + if ( match[1] ) { |
| 5076 | + return makeArray( context.getElementsByTagName( query ), extra ); |
| 5077 | + |
| 5078 | + // Speed-up: Sizzle(".CLASS") |
| 5079 | + } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) { |
| 5080 | + return makeArray( context.getElementsByClassName( match[2] ), extra ); |
| 5081 | + } |
| 5082 | + } |
| 5083 | + |
| 5084 | + if ( context.nodeType === 9 ) { |
| 5085 | + // Speed-up: Sizzle("body") |
| 5086 | + // The body element only exists once, optimize finding it |
| 5087 | + if ( query === "body" && context.body ) { |
| 5088 | + return makeArray( [ context.body ], extra ); |
| 5089 | + |
| 5090 | + // Speed-up: Sizzle("#ID") |
| 5091 | + } else if ( match && match[3] ) { |
| 5092 | + var elem = context.getElementById( match[3] ); |
| 5093 | + |
| 5094 | + // Check parentNode to catch when Blackberry 4.6 returns |
| 5095 | + // nodes that are no longer in the document #6963 |
| 5096 | + if ( elem && elem.parentNode ) { |
| 5097 | + // Handle the case where IE and Opera return items |
| 5098 | + // by name instead of ID |
| 5099 | + if ( elem.id === match[3] ) { |
| 5100 | + return makeArray( [ elem ], extra ); |
| 5101 | + } |
| 5102 | + |
| 5103 | + } else { |
| 5104 | + return makeArray( [], extra ); |
| 5105 | + } |
| 5106 | + } |
| 5107 | + |
| 5108 | + try { |
| 5109 | + return makeArray( context.querySelectorAll(query), extra ); |
| 5110 | + } catch(qsaError) {} |
| 5111 | + |
| 5112 | + // qSA works strangely on Element-rooted queries |
| 5113 | + // We can work around this by specifying an extra ID on the root |
| 5114 | + // and working up from there (Thanks to Andrew Dupont for the technique) |
| 5115 | + // IE 8 doesn't work on object elements |
| 5116 | + } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { |
| 5117 | + var oldContext = context, |
| 5118 | + old = context.getAttribute( "id" ), |
| 5119 | + nid = old || id, |
| 5120 | + hasParent = context.parentNode, |
| 5121 | + relativeHierarchySelector = /^\s*[+~]/.test( query ); |
| 5122 | + |
| 5123 | + if ( !old ) { |
| 5124 | + context.setAttribute( "id", nid ); |
| 5125 | + } else { |
| 5126 | + nid = nid.replace( /'/g, "\\$&" ); |
| 5127 | + } |
| 5128 | + if ( relativeHierarchySelector && hasParent ) { |
| 5129 | + context = context.parentNode; |
| 5130 | + } |
| 5131 | + |
| 5132 | + try { |
| 5133 | + if ( !relativeHierarchySelector || hasParent ) { |
| 5134 | + return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra ); |
| 5135 | + } |
| 5136 | + |
| 5137 | + } catch(pseudoError) { |
| 5138 | + } finally { |
| 5139 | + if ( !old ) { |
| 5140 | + oldContext.removeAttribute( "id" ); |
| 5141 | + } |
| 5142 | + } |
| 5143 | + } |
| 5144 | + } |
| 5145 | + |
| 5146 | + return oldSizzle(query, context, extra, seed); |
| 5147 | + }; |
| 5148 | + |
| 5149 | + for ( var prop in oldSizzle ) { |
| 5150 | + Sizzle[ prop ] = oldSizzle[ prop ]; |
| 5151 | + } |
| 5152 | + |
| 5153 | + // release memory in IE |
| 5154 | + div = null; |
| 5155 | + })(); |
| 5156 | +} |
| 5157 | + |
| 5158 | +(function(){ |
| 5159 | + var html = document.documentElement, |
| 5160 | + matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector; |
| 5161 | + |
| 5162 | + if ( matches ) { |
| 5163 | + // Check to see if it's possible to do matchesSelector |
| 5164 | + // on a disconnected node (IE 9 fails this) |
| 5165 | + var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ), |
| 5166 | + pseudoWorks = false; |
| 5167 | + |
| 5168 | + try { |
| 5169 | + // This should fail with an exception |
| 5170 | + // Gecko does not error, returns false instead |
| 5171 | + matches.call( document.documentElement, "[test!='']:sizzle" ); |
| 5172 | + |
| 5173 | + } catch( pseudoError ) { |
| 5174 | + pseudoWorks = true; |
| 5175 | + } |
| 5176 | + |
| 5177 | + Sizzle.matchesSelector = function( node, expr ) { |
| 5178 | + // Make sure that attribute selectors are quoted |
| 5179 | + expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"); |
| 5180 | + |
| 5181 | + if ( !Sizzle.isXML( node ) ) { |
| 5182 | + try { |
| 5183 | + if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) { |
| 5184 | + var ret = matches.call( node, expr ); |
| 5185 | + |
| 5186 | + // IE 9's matchesSelector returns false on disconnected nodes |
| 5187 | + if ( ret || !disconnectedMatch || |
| 5188 | + // As well, disconnected nodes are said to be in a document |
| 5189 | + // fragment in IE 9, so check for that |
| 5190 | + node.document && node.document.nodeType !== 11 ) { |
| 5191 | + return ret; |
| 5192 | + } |
| 5193 | + } |
| 5194 | + } catch(e) {} |
| 5195 | + } |
| 5196 | + |
| 5197 | + return Sizzle(expr, null, null, [node]).length > 0; |
| 5198 | + }; |
| 5199 | + } |
| 5200 | +})(); |
| 5201 | + |
| 5202 | +(function(){ |
| 5203 | + var div = document.createElement("div"); |
| 5204 | + |
| 5205 | + div.innerHTML = "<div class='test e'></div><div class='test'></div>"; |
| 5206 | + |
| 5207 | + // Opera can't find a second classname (in 9.6) |
| 5208 | + // Also, make sure that getElementsByClassName actually exists |
| 5209 | + if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) { |
| 5210 | + return; |
| 5211 | + } |
| 5212 | + |
| 5213 | + // Safari caches class attributes, doesn't catch changes (in 3.2) |
| 5214 | + div.lastChild.className = "e"; |
| 5215 | + |
| 5216 | + if ( div.getElementsByClassName("e").length === 1 ) { |
| 5217 | + return; |
| 5218 | + } |
| 5219 | + |
| 5220 | + Expr.order.splice(1, 0, "CLASS"); |
| 5221 | + Expr.find.CLASS = function( match, context, isXML ) { |
| 5222 | + if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { |
| 5223 | + return context.getElementsByClassName(match[1]); |
| 5224 | + } |
| 5225 | + }; |
| 5226 | + |
| 5227 | + // release memory in IE |
| 5228 | + div = null; |
| 5229 | +})(); |
| 5230 | + |
| 5231 | +function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { |
| 5232 | + for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
| 5233 | + var elem = checkSet[i]; |
| 5234 | + |
| 5235 | + if ( elem ) { |
| 5236 | + var match = false; |
| 5237 | + |
| 5238 | + elem = elem[dir]; |
| 5239 | + |
| 5240 | + while ( elem ) { |
| 5241 | + if ( elem[ expando ] === doneName ) { |
| 5242 | + match = checkSet[elem.sizset]; |
| 5243 | + break; |
| 5244 | + } |
| 5245 | + |
| 5246 | + if ( elem.nodeType === 1 && !isXML ){ |
| 5247 | + elem[ expando ] = doneName; |
| 5248 | + elem.sizset = i; |
| 5249 | + } |
| 5250 | + |
| 5251 | + if ( elem.nodeName.toLowerCase() === cur ) { |
| 5252 | + match = elem; |
| 5253 | + break; |
| 5254 | + } |
| 5255 | + |
| 5256 | + elem = elem[dir]; |
| 5257 | + } |
| 5258 | + |
| 5259 | + checkSet[i] = match; |
| 5260 | + } |
| 5261 | + } |
| 5262 | +} |
| 5263 | + |
| 5264 | +function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { |
| 5265 | + for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
| 5266 | + var elem = checkSet[i]; |
| 5267 | + |
| 5268 | + if ( elem ) { |
| 5269 | + var match = false; |
| 5270 | + |
| 5271 | + elem = elem[dir]; |
| 5272 | + |
| 5273 | + while ( elem ) { |
| 5274 | + if ( elem[ expando ] === doneName ) { |
| 5275 | + match = checkSet[elem.sizset]; |
| 5276 | + break; |
| 5277 | + } |
| 5278 | + |
| 5279 | + if ( elem.nodeType === 1 ) { |
| 5280 | + if ( !isXML ) { |
| 5281 | + elem[ expando ] = doneName; |
| 5282 | + elem.sizset = i; |
| 5283 | + } |
| 5284 | + |
| 5285 | + if ( typeof cur !== "string" ) { |
| 5286 | + if ( elem === cur ) { |
| 5287 | + match = true; |
| 5288 | + break; |
| 5289 | + } |
| 5290 | + |
| 5291 | + } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) { |
| 5292 | + match = elem; |
| 5293 | + break; |
| 5294 | + } |
| 5295 | + } |
| 5296 | + |
| 5297 | + elem = elem[dir]; |
| 5298 | + } |
| 5299 | + |
| 5300 | + checkSet[i] = match; |
| 5301 | + } |
| 5302 | + } |
| 5303 | +} |
| 5304 | + |
| 5305 | +if ( document.documentElement.contains ) { |
| 5306 | + Sizzle.contains = function( a, b ) { |
| 5307 | + return a !== b && (a.contains ? a.contains(b) : true); |
| 5308 | + }; |
| 5309 | + |
| 5310 | +} else if ( document.documentElement.compareDocumentPosition ) { |
| 5311 | + Sizzle.contains = function( a, b ) { |
| 5312 | + return !!(a.compareDocumentPosition(b) & 16); |
| 5313 | + }; |
| 5314 | + |
| 5315 | +} else { |
| 5316 | + Sizzle.contains = function() { |
| 5317 | + return false; |
| 5318 | + }; |
| 5319 | +} |
| 5320 | + |
| 5321 | +Sizzle.isXML = function( elem ) { |
| 5322 | + // documentElement is verified for cases where it doesn't yet exist |
| 5323 | + // (such as loading iframes in IE - #4833) |
| 5324 | + var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement; |
| 5325 | + |
| 5326 | + return documentElement ? documentElement.nodeName !== "HTML" : false; |
| 5327 | +}; |
| 5328 | + |
| 5329 | +var posProcess = function( selector, context, seed ) { |
| 5330 | + var match, |
| 5331 | + tmpSet = [], |
| 5332 | + later = "", |
| 5333 | + root = context.nodeType ? [context] : context; |
| 5334 | + |
| 5335 | + // Position selectors must be done after the filter |
| 5336 | + // And so must :not(positional) so we move all PSEUDOs to the end |
| 5337 | + while ( (match = Expr.match.PSEUDO.exec( selector )) ) { |
| 5338 | + later += match[0]; |
| 5339 | + selector = selector.replace( Expr.match.PSEUDO, "" ); |
| 5340 | + } |
| 5341 | + |
| 5342 | + selector = Expr.relative[selector] ? selector + "*" : selector; |
| 5343 | + |
| 5344 | + for ( var i = 0, l = root.length; i < l; i++ ) { |
| 5345 | + Sizzle( selector, root[i], tmpSet, seed ); |
| 5346 | + } |
| 5347 | + |
| 5348 | + return Sizzle.filter( later, tmpSet ); |
| 5349 | +}; |
| 5350 | + |
| 5351 | +// EXPOSE |
| 5352 | +// Override sizzle attribute retrieval |
| 5353 | +Sizzle.attr = jQuery.attr; |
| 5354 | +Sizzle.selectors.attrMap = {}; |
| 5355 | +jQuery.find = Sizzle; |
| 5356 | +jQuery.expr = Sizzle.selectors; |
| 5357 | +jQuery.expr[":"] = jQuery.expr.filters; |
| 5358 | +jQuery.unique = Sizzle.uniqueSort; |
| 5359 | +jQuery.text = Sizzle.getText; |
| 5360 | +jQuery.isXMLDoc = Sizzle.isXML; |
| 5361 | +jQuery.contains = Sizzle.contains; |
| 5362 | + |
| 5363 | + |
| 5364 | +})(); |
| 5365 | + |
| 5366 | + |
| 5367 | +var runtil = /Until$/, |
| 5368 | + rparentsprev = /^(?:parents|prevUntil|prevAll)/, |
| 5369 | + // Note: This RegExp should be improved, or likely pulled from Sizzle |
| 5370 | + rmultiselector = /,/, |
| 5371 | + isSimple = /^.[^:#\[\.,]*$/, |
| 5372 | + slice = Array.prototype.slice, |
| 5373 | + POS = jQuery.expr.match.POS, |
| 5374 | + // methods guaranteed to produce a unique set when starting from a unique set |
| 5375 | + guaranteedUnique = { |
| 5376 | + children: true, |
| 5377 | + contents: true, |
| 5378 | + next: true, |
| 5379 | + prev: true |
| 5380 | + }; |
| 5381 | + |
| 5382 | +jQuery.fn.extend({ |
| 5383 | + find: function( selector ) { |
| 5384 | + var self = this, |
| 5385 | + i, l; |
| 5386 | + |
| 5387 | + if ( typeof selector !== "string" ) { |
| 5388 | + return jQuery( selector ).filter(function() { |
| 5389 | + for ( i = 0, l = self.length; i < l; i++ ) { |
| 5390 | + if ( jQuery.contains( self[ i ], this ) ) { |
| 5391 | + return true; |
| 5392 | + } |
| 5393 | + } |
| 5394 | + }); |
| 5395 | + } |
| 5396 | + |
| 5397 | + var ret = this.pushStack( "", "find", selector ), |
| 5398 | + length, n, r; |
| 5399 | + |
| 5400 | + for ( i = 0, l = this.length; i < l; i++ ) { |
| 5401 | + length = ret.length; |
| 5402 | + jQuery.find( selector, this[i], ret ); |
| 5403 | + |
| 5404 | + if ( i > 0 ) { |
| 5405 | + // Make sure that the results are unique |
| 5406 | + for ( n = length; n < ret.length; n++ ) { |
| 5407 | + for ( r = 0; r < length; r++ ) { |
| 5408 | + if ( ret[r] === ret[n] ) { |
| 5409 | + ret.splice(n--, 1); |
| 5410 | + break; |
| 5411 | + } |
| 5412 | + } |
| 5413 | + } |
| 5414 | + } |
| 5415 | + } |
| 5416 | + |
| 5417 | + return ret; |
| 5418 | + }, |
| 5419 | + |
| 5420 | + has: function( target ) { |
| 5421 | + var targets = jQuery( target ); |
| 5422 | + return this.filter(function() { |
| 5423 | + for ( var i = 0, l = targets.length; i < l; i++ ) { |
| 5424 | + if ( jQuery.contains( this, targets[i] ) ) { |
| 5425 | + return true; |
| 5426 | + } |
| 5427 | + } |
| 5428 | + }); |
| 5429 | + }, |
| 5430 | + |
| 5431 | + not: function( selector ) { |
| 5432 | + return this.pushStack( winnow(this, selector, false), "not", selector); |
| 5433 | + }, |
| 5434 | + |
| 5435 | + filter: function( selector ) { |
| 5436 | + return this.pushStack( winnow(this, selector, true), "filter", selector ); |
| 5437 | + }, |
| 5438 | + |
| 5439 | + is: function( selector ) { |
| 5440 | + return !!selector && ( |
| 5441 | + typeof selector === "string" ? |
| 5442 | + // If this is a positional selector, check membership in the returned set |
| 5443 | + // so $("p:first").is("p:last") won't return true for a doc with two "p". |
| 5444 | + POS.test( selector ) ? |
| 5445 | + jQuery( selector, this.context ).index( this[0] ) >= 0 : |
| 5446 | + jQuery.filter( selector, this ).length > 0 : |
| 5447 | + this.filter( selector ).length > 0 ); |
| 5448 | + }, |
| 5449 | + |
| 5450 | + closest: function( selectors, context ) { |
| 5451 | + var ret = [], i, l, cur = this[0]; |
| 5452 | + |
| 5453 | + // Array (deprecated as of jQuery 1.7) |
| 5454 | + if ( jQuery.isArray( selectors ) ) { |
| 5455 | + var level = 1; |
| 5456 | + |
| 5457 | + while ( cur && cur.ownerDocument && cur !== context ) { |
| 5458 | + for ( i = 0; i < selectors.length; i++ ) { |
| 5459 | + |
| 5460 | + if ( jQuery( cur ).is( selectors[ i ] ) ) { |
| 5461 | + ret.push({ selector: selectors[ i ], elem: cur, level: level }); |
| 5462 | + } |
| 5463 | + } |
| 5464 | + |
| 5465 | + cur = cur.parentNode; |
| 5466 | + level++; |
| 5467 | + } |
| 5468 | + |
| 5469 | + return ret; |
| 5470 | + } |
| 5471 | + |
| 5472 | + // String |
| 5473 | + var pos = POS.test( selectors ) || typeof selectors !== "string" ? |
| 5474 | + jQuery( selectors, context || this.context ) : |
| 5475 | + 0; |
| 5476 | + |
| 5477 | + for ( i = 0, l = this.length; i < l; i++ ) { |
| 5478 | + cur = this[i]; |
| 5479 | + |
| 5480 | + while ( cur ) { |
| 5481 | + if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) { |
| 5482 | + ret.push( cur ); |
| 5483 | + break; |
| 5484 | + |
| 5485 | + } else { |
| 5486 | + cur = cur.parentNode; |
| 5487 | + if ( !cur || !cur.ownerDocument || cur === context || cur.nodeType === 11 ) { |
| 5488 | + break; |
| 5489 | + } |
| 5490 | + } |
| 5491 | + } |
| 5492 | + } |
| 5493 | + |
| 5494 | + ret = ret.length > 1 ? jQuery.unique( ret ) : ret; |
| 5495 | + |
| 5496 | + return this.pushStack( ret, "closest", selectors ); |
| 5497 | + }, |
| 5498 | + |
| 5499 | + // Determine the position of an element within |
| 5500 | + // the matched set of elements |
| 5501 | + index: function( elem ) { |
| 5502 | + |
| 5503 | + // No argument, return index in parent |
| 5504 | + if ( !elem ) { |
| 5505 | + return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1; |
| 5506 | + } |
| 5507 | + |
| 5508 | + // index in selector |
| 5509 | + if ( typeof elem === "string" ) { |
| 5510 | + return jQuery.inArray( this[0], jQuery( elem ) ); |
| 5511 | + } |
| 5512 | + |
| 5513 | + // Locate the position of the desired element |
| 5514 | + return jQuery.inArray( |
| 5515 | + // If it receives a jQuery object, the first element is used |
| 5516 | + elem.jquery ? elem[0] : elem, this ); |
| 5517 | + }, |
| 5518 | + |
| 5519 | + add: function( selector, context ) { |
| 5520 | + var set = typeof selector === "string" ? |
| 5521 | + jQuery( selector, context ) : |
| 5522 | + jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ), |
| 5523 | + all = jQuery.merge( this.get(), set ); |
| 5524 | + |
| 5525 | + return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ? |
| 5526 | + all : |
| 5527 | + jQuery.unique( all ) ); |
| 5528 | + }, |
| 5529 | + |
| 5530 | + andSelf: function() { |
| 5531 | + return this.add( this.prevObject ); |
| 5532 | + } |
| 5533 | +}); |
| 5534 | + |
| 5535 | +// A painfully simple check to see if an element is disconnected |
| 5536 | +// from a document (should be improved, where feasible). |
| 5537 | +function isDisconnected( node ) { |
| 5538 | + return !node || !node.parentNode || node.parentNode.nodeType === 11; |
| 5539 | +} |
| 5540 | + |
| 5541 | +jQuery.each({ |
| 5542 | + parent: function( elem ) { |
| 5543 | + var parent = elem.parentNode; |
| 5544 | + return parent && parent.nodeType !== 11 ? parent : null; |
| 5545 | + }, |
| 5546 | + parents: function( elem ) { |
| 5547 | + return jQuery.dir( elem, "parentNode" ); |
| 5548 | + }, |
| 5549 | + parentsUntil: function( elem, i, until ) { |
| 5550 | + return jQuery.dir( elem, "parentNode", until ); |
| 5551 | + }, |
| 5552 | + next: function( elem ) { |
| 5553 | + return jQuery.nth( elem, 2, "nextSibling" ); |
| 5554 | + }, |
| 5555 | + prev: function( elem ) { |
| 5556 | + return jQuery.nth( elem, 2, "previousSibling" ); |
| 5557 | + }, |
| 5558 | + nextAll: function( elem ) { |
| 5559 | + return jQuery.dir( elem, "nextSibling" ); |
| 5560 | + }, |
| 5561 | + prevAll: function( elem ) { |
| 5562 | + return jQuery.dir( elem, "previousSibling" ); |
| 5563 | + }, |
| 5564 | + nextUntil: function( elem, i, until ) { |
| 5565 | + return jQuery.dir( elem, "nextSibling", until ); |
| 5566 | + }, |
| 5567 | + prevUntil: function( elem, i, until ) { |
| 5568 | + return jQuery.dir( elem, "previousSibling", until ); |
| 5569 | + }, |
| 5570 | + siblings: function( elem ) { |
| 5571 | + return jQuery.sibling( elem.parentNode.firstChild, elem ); |
| 5572 | + }, |
| 5573 | + children: function( elem ) { |
| 5574 | + return jQuery.sibling( elem.firstChild ); |
| 5575 | + }, |
| 5576 | + contents: function( elem ) { |
| 5577 | + return jQuery.nodeName( elem, "iframe" ) ? |
| 5578 | + elem.contentDocument || elem.contentWindow.document : |
| 5579 | + jQuery.makeArray( elem.childNodes ); |
| 5580 | + } |
| 5581 | +}, function( name, fn ) { |
| 5582 | + jQuery.fn[ name ] = function( until, selector ) { |
| 5583 | + var ret = jQuery.map( this, fn, until ), |
| 5584 | + // The variable 'args' was introduced in |
| 5585 | + // https://github.com/jquery/jquery/commit/52a0238 |
| 5586 | + // to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed. |
| 5587 | + // http://code.google.com/p/v8/issues/detail?id=1050 |
| 5588 | + args = slice.call(arguments); |
| 5589 | + |
| 5590 | + if ( !runtil.test( name ) ) { |
| 5591 | + selector = until; |
| 5592 | + } |
| 5593 | + |
| 5594 | + if ( selector && typeof selector === "string" ) { |
| 5595 | + ret = jQuery.filter( selector, ret ); |
| 5596 | + } |
| 5597 | + |
| 5598 | + ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret; |
| 5599 | + |
| 5600 | + if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) { |
| 5601 | + ret = ret.reverse(); |
| 5602 | + } |
| 5603 | + |
| 5604 | + return this.pushStack( ret, name, args.join(",") ); |
| 5605 | + }; |
| 5606 | +}); |
| 5607 | + |
| 5608 | +jQuery.extend({ |
| 5609 | + filter: function( expr, elems, not ) { |
| 5610 | + if ( not ) { |
| 5611 | + expr = ":not(" + expr + ")"; |
| 5612 | + } |
| 5613 | + |
| 5614 | + return elems.length === 1 ? |
| 5615 | + jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] : |
| 5616 | + jQuery.find.matches(expr, elems); |
| 5617 | + }, |
| 5618 | + |
| 5619 | + dir: function( elem, dir, until ) { |
| 5620 | + var matched = [], |
| 5621 | + cur = elem[ dir ]; |
| 5622 | + |
| 5623 | + while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) { |
| 5624 | + if ( cur.nodeType === 1 ) { |
| 5625 | + matched.push( cur ); |
| 5626 | + } |
| 5627 | + cur = cur[dir]; |
| 5628 | + } |
| 5629 | + return matched; |
| 5630 | + }, |
| 5631 | + |
| 5632 | + nth: function( cur, result, dir, elem ) { |
| 5633 | + result = result || 1; |
| 5634 | + var num = 0; |
| 5635 | + |
| 5636 | + for ( ; cur; cur = cur[dir] ) { |
| 5637 | + if ( cur.nodeType === 1 && ++num === result ) { |
| 5638 | + break; |
| 5639 | + } |
| 5640 | + } |
| 5641 | + |
| 5642 | + return cur; |
| 5643 | + }, |
| 5644 | + |
| 5645 | + sibling: function( n, elem ) { |
| 5646 | + var r = []; |
| 5647 | + |
| 5648 | + for ( ; n; n = n.nextSibling ) { |
| 5649 | + if ( n.nodeType === 1 && n !== elem ) { |
| 5650 | + r.push( n ); |
| 5651 | + } |
| 5652 | + } |
| 5653 | + |
| 5654 | + return r; |
| 5655 | + } |
| 5656 | +}); |
| 5657 | + |
| 5658 | +// Implement the identical functionality for filter and not |
| 5659 | +function winnow( elements, qualifier, keep ) { |
| 5660 | + |
| 5661 | + // Can't pass null or undefined to indexOf in Firefox 4 |
| 5662 | + // Set to 0 to skip string check |
| 5663 | + qualifier = qualifier || 0; |
| 5664 | + |
| 5665 | + if ( jQuery.isFunction( qualifier ) ) { |
| 5666 | + return jQuery.grep(elements, function( elem, i ) { |
| 5667 | + var retVal = !!qualifier.call( elem, i, elem ); |
| 5668 | + return retVal === keep; |
| 5669 | + }); |
| 5670 | + |
| 5671 | + } else if ( qualifier.nodeType ) { |
| 5672 | + return jQuery.grep(elements, function( elem, i ) { |
| 5673 | + return ( elem === qualifier ) === keep; |
| 5674 | + }); |
| 5675 | + |
| 5676 | + } else if ( typeof qualifier === "string" ) { |
| 5677 | + var filtered = jQuery.grep(elements, function( elem ) { |
| 5678 | + return elem.nodeType === 1; |
| 5679 | + }); |
| 5680 | + |
| 5681 | + if ( isSimple.test( qualifier ) ) { |
| 5682 | + return jQuery.filter(qualifier, filtered, !keep); |
| 5683 | + } else { |
| 5684 | + qualifier = jQuery.filter( qualifier, filtered ); |
| 5685 | + } |
| 5686 | + } |
| 5687 | + |
| 5688 | + return jQuery.grep(elements, function( elem, i ) { |
| 5689 | + return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep; |
| 5690 | + }); |
| 5691 | +} |
| 5692 | + |
| 5693 | + |
| 5694 | + |
| 5695 | + |
| 5696 | +function createSafeFragment( document ) { |
| 5697 | + var list = nodeNames.split( " " ), |
| 5698 | + safeFrag = document.createDocumentFragment(); |
| 5699 | + |
| 5700 | + if ( safeFrag.createElement ) { |
| 5701 | + while ( list.length ) { |
| 5702 | + safeFrag.createElement( |
| 5703 | + list.pop() |
| 5704 | + ); |
| 5705 | + } |
| 5706 | + } |
| 5707 | + return safeFrag; |
| 5708 | +} |
| 5709 | + |
| 5710 | +var nodeNames = "abbr article aside audio canvas datalist details figcaption figure footer " + |
| 5711 | + "header hgroup mark meter nav output progress section summary time video", |
| 5712 | + rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, |
| 5713 | + rleadingWhitespace = /^\s+/, |
| 5714 | + rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig, |
| 5715 | + rtagName = /<([\w:]+)/, |
| 5716 | + rtbody = /<tbody/i, |
| 5717 | + rhtml = /<|&#?\w+;/, |
| 5718 | + rnoInnerhtml = /<(?:script|style)/i, |
| 5719 | + rnocache = /<(?:script|object|embed|option|style)/i, |
| 5720 | + rnoshimcache = new RegExp("<(?:" + nodeNames.replace(" ", "|") + ")", "i"), |
| 5721 | + // checked="checked" or checked |
| 5722 | + rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, |
| 5723 | + rscriptType = /\/(java|ecma)script/i, |
| 5724 | + rcleanScript = /^\s*<!(?:\[CDATA\[|\-\-)/, |
| 5725 | + wrapMap = { |
| 5726 | + option: [ 1, "<select multiple='multiple'>", "</select>" ], |
| 5727 | + legend: [ 1, "<fieldset>", "</fieldset>" ], |
| 5728 | + thead: [ 1, "<table>", "</table>" ], |
| 5729 | + tr: [ 2, "<table><tbody>", "</tbody></table>" ], |
| 5730 | + td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ], |
| 5731 | + col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ], |
| 5732 | + area: [ 1, "<map>", "</map>" ], |
| 5733 | + _default: [ 0, "", "" ] |
| 5734 | + }, |
| 5735 | + safeFragment = createSafeFragment( document ); |
| 5736 | + |
| 5737 | +wrapMap.optgroup = wrapMap.option; |
| 5738 | +wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; |
| 5739 | +wrapMap.th = wrapMap.td; |
| 5740 | + |
| 5741 | +// IE can't serialize <link> and <script> tags normally |
| 5742 | +if ( !jQuery.support.htmlSerialize ) { |
| 5743 | + wrapMap._default = [ 1, "div<div>", "</div>" ]; |
| 5744 | +} |
| 5745 | + |
| 5746 | +jQuery.fn.extend({ |
| 5747 | + text: function( text ) { |
| 5748 | + if ( jQuery.isFunction(text) ) { |
| 5749 | + return this.each(function(i) { |
| 5750 | + var self = jQuery( this ); |
| 5751 | + |
| 5752 | + self.text( text.call(this, i, self.text()) ); |
| 5753 | + }); |
| 5754 | + } |
| 5755 | + |
| 5756 | + if ( typeof text !== "object" && text !== undefined ) { |
| 5757 | + return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) ); |
| 5758 | + } |
| 5759 | + |
| 5760 | + return jQuery.text( this ); |
| 5761 | + }, |
| 5762 | + |
| 5763 | + wrapAll: function( html ) { |
| 5764 | + if ( jQuery.isFunction( html ) ) { |
| 5765 | + return this.each(function(i) { |
| 5766 | + jQuery(this).wrapAll( html.call(this, i) ); |
| 5767 | + }); |
| 5768 | + } |
| 5769 | + |
| 5770 | + if ( this[0] ) { |
| 5771 | + // The elements to wrap the target around |
| 5772 | + var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true); |
| 5773 | + |
| 5774 | + if ( this[0].parentNode ) { |
| 5775 | + wrap.insertBefore( this[0] ); |
| 5776 | + } |
| 5777 | + |
| 5778 | + wrap.map(function() { |
| 5779 | + var elem = this; |
| 5780 | + |
| 5781 | + while ( elem.firstChild && elem.firstChild.nodeType === 1 ) { |
| 5782 | + elem = elem.firstChild; |
| 5783 | + } |
| 5784 | + |
| 5785 | + return elem; |
| 5786 | + }).append( this ); |
| 5787 | + } |
| 5788 | + |
| 5789 | + return this; |
| 5790 | + }, |
| 5791 | + |
| 5792 | + wrapInner: function( html ) { |
| 5793 | + if ( jQuery.isFunction( html ) ) { |
| 5794 | + return this.each(function(i) { |
| 5795 | + jQuery(this).wrapInner( html.call(this, i) ); |
| 5796 | + }); |
| 5797 | + } |
| 5798 | + |
| 5799 | + return this.each(function() { |
| 5800 | + var self = jQuery( this ), |
| 5801 | + contents = self.contents(); |
| 5802 | + |
| 5803 | + if ( contents.length ) { |
| 5804 | + contents.wrapAll( html ); |
| 5805 | + |
| 5806 | + } else { |
| 5807 | + self.append( html ); |
| 5808 | + } |
| 5809 | + }); |
| 5810 | + }, |
| 5811 | + |
| 5812 | + wrap: function( html ) { |
| 5813 | + return this.each(function() { |
| 5814 | + jQuery( this ).wrapAll( html ); |
| 5815 | + }); |
| 5816 | + }, |
| 5817 | + |
| 5818 | + unwrap: function() { |
| 5819 | + return this.parent().each(function() { |
| 5820 | + if ( !jQuery.nodeName( this, "body" ) ) { |
| 5821 | + jQuery( this ).replaceWith( this.childNodes ); |
| 5822 | + } |
| 5823 | + }).end(); |
| 5824 | + }, |
| 5825 | + |
| 5826 | + append: function() { |
| 5827 | + return this.domManip(arguments, true, function( elem ) { |
| 5828 | + if ( this.nodeType === 1 ) { |
| 5829 | + this.appendChild( elem ); |
| 5830 | + } |
| 5831 | + }); |
| 5832 | + }, |
| 5833 | + |
| 5834 | + prepend: function() { |
| 5835 | + return this.domManip(arguments, true, function( elem ) { |
| 5836 | + if ( this.nodeType === 1 ) { |
| 5837 | + this.insertBefore( elem, this.firstChild ); |
| 5838 | + } |
| 5839 | + }); |
| 5840 | + }, |
| 5841 | + |
| 5842 | + before: function() { |
| 5843 | + if ( this[0] && this[0].parentNode ) { |
| 5844 | + return this.domManip(arguments, false, function( elem ) { |
| 5845 | + this.parentNode.insertBefore( elem, this ); |
| 5846 | + }); |
| 5847 | + } else if ( arguments.length ) { |
| 5848 | + var set = jQuery(arguments[0]); |
| 5849 | + set.push.apply( set, this.toArray() ); |
| 5850 | + return this.pushStack( set, "before", arguments ); |
| 5851 | + } |
| 5852 | + }, |
| 5853 | + |
| 5854 | + after: function() { |
| 5855 | + if ( this[0] && this[0].parentNode ) { |
| 5856 | + return this.domManip(arguments, false, function( elem ) { |
| 5857 | + this.parentNode.insertBefore( elem, this.nextSibling ); |
| 5858 | + }); |
| 5859 | + } else if ( arguments.length ) { |
| 5860 | + var set = this.pushStack( this, "after", arguments ); |
| 5861 | + set.push.apply( set, jQuery(arguments[0]).toArray() ); |
| 5862 | + return set; |
| 5863 | + } |
| 5864 | + }, |
| 5865 | + |
| 5866 | + // keepData is for internal use only--do not document |
| 5867 | + remove: function( selector, keepData ) { |
| 5868 | + for ( var i = 0, elem; (elem = this[i]) != null; i++ ) { |
| 5869 | + if ( !selector || jQuery.filter( selector, [ elem ] ).length ) { |
| 5870 | + if ( !keepData && elem.nodeType === 1 ) { |
| 5871 | + jQuery.cleanData( elem.getElementsByTagName("*") ); |
| 5872 | + jQuery.cleanData( [ elem ] ); |
| 5873 | + } |
| 5874 | + |
| 5875 | + if ( elem.parentNode ) { |
| 5876 | + elem.parentNode.removeChild( elem ); |
| 5877 | + } |
| 5878 | + } |
| 5879 | + } |
| 5880 | + |
| 5881 | + return this; |
| 5882 | + }, |
| 5883 | + |
| 5884 | + empty: function() { |
| 5885 | + for ( var i = 0, elem; (elem = this[i]) != null; i++ ) { |
| 5886 | + // Remove element nodes and prevent memory leaks |
| 5887 | + if ( elem.nodeType === 1 ) { |
| 5888 | + jQuery.cleanData( elem.getElementsByTagName("*") ); |
| 5889 | + } |
| 5890 | + |
| 5891 | + // Remove any remaining nodes |
| 5892 | + while ( elem.firstChild ) { |
| 5893 | + elem.removeChild( elem.firstChild ); |
| 5894 | + } |
| 5895 | + } |
| 5896 | + |
| 5897 | + return this; |
| 5898 | + }, |
| 5899 | + |
| 5900 | + clone: function( dataAndEvents, deepDataAndEvents ) { |
| 5901 | + dataAndEvents = dataAndEvents == null ? false : dataAndEvents; |
| 5902 | + deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; |
| 5903 | + |
| 5904 | + return this.map( function () { |
| 5905 | + return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); |
| 5906 | + }); |
| 5907 | + }, |
| 5908 | + |
| 5909 | + html: function( value ) { |
| 5910 | + if ( value === undefined ) { |
| 5911 | + return this[0] && this[0].nodeType === 1 ? |
| 5912 | + this[0].innerHTML.replace(rinlinejQuery, "") : |
| 5913 | + null; |
| 5914 | + |
| 5915 | + // See if we can take a shortcut and just use innerHTML |
| 5916 | + } else if ( typeof value === "string" && !rnoInnerhtml.test( value ) && |
| 5917 | + (jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) && |
| 5918 | + !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) { |
| 5919 | + |
| 5920 | + value = value.replace(rxhtmlTag, "<$1></$2>"); |
| 5921 | + |
| 5922 | + try { |
| 5923 | + for ( var i = 0, l = this.length; i < l; i++ ) { |
| 5924 | + // Remove element nodes and prevent memory leaks |
| 5925 | + if ( this[i].nodeType === 1 ) { |
| 5926 | + jQuery.cleanData( this[i].getElementsByTagName("*") ); |
| 5927 | + this[i].innerHTML = value; |
| 5928 | + } |
| 5929 | + } |
| 5930 | + |
| 5931 | + // If using innerHTML throws an exception, use the fallback method |
| 5932 | + } catch(e) { |
| 5933 | + this.empty().append( value ); |
| 5934 | + } |
| 5935 | + |
| 5936 | + } else if ( jQuery.isFunction( value ) ) { |
| 5937 | + this.each(function(i){ |
| 5938 | + var self = jQuery( this ); |
| 5939 | + |
| 5940 | + self.html( value.call(this, i, self.html()) ); |
| 5941 | + }); |
| 5942 | + |
| 5943 | + } else { |
| 5944 | + this.empty().append( value ); |
| 5945 | + } |
| 5946 | + |
| 5947 | + return this; |
| 5948 | + }, |
| 5949 | + |
| 5950 | + replaceWith: function( value ) { |
| 5951 | + if ( this[0] && this[0].parentNode ) { |
| 5952 | + // Make sure that the elements are removed from the DOM before they are inserted |
| 5953 | + // this can help fix replacing a parent with child elements |
| 5954 | + if ( jQuery.isFunction( value ) ) { |
| 5955 | + return this.each(function(i) { |
| 5956 | + var self = jQuery(this), old = self.html(); |
| 5957 | + self.replaceWith( value.call( this, i, old ) ); |
| 5958 | + }); |
| 5959 | + } |
| 5960 | + |
| 5961 | + if ( typeof value !== "string" ) { |
| 5962 | + value = jQuery( value ).detach(); |
| 5963 | + } |
| 5964 | + |
| 5965 | + return this.each(function() { |
| 5966 | + var next = this.nextSibling, |
| 5967 | + parent = this.parentNode; |
| 5968 | + |
| 5969 | + jQuery( this ).remove(); |
| 5970 | + |
| 5971 | + if ( next ) { |
| 5972 | + jQuery(next).before( value ); |
| 5973 | + } else { |
| 5974 | + jQuery(parent).append( value ); |
| 5975 | + } |
| 5976 | + }); |
| 5977 | + } else { |
| 5978 | + return this.length ? |
| 5979 | + this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) : |
| 5980 | + this; |
| 5981 | + } |
| 5982 | + }, |
| 5983 | + |
| 5984 | + detach: function( selector ) { |
| 5985 | + return this.remove( selector, true ); |
| 5986 | + }, |
| 5987 | + |
| 5988 | + domManip: function( args, table, callback ) { |
| 5989 | + var results, first, fragment, parent, |
| 5990 | + value = args[0], |
| 5991 | + scripts = []; |
| 5992 | + |
| 5993 | + // We can't cloneNode fragments that contain checked, in WebKit |
| 5994 | + if ( !jQuery.support.checkClone && arguments.length === 3 && typeof value === "string" && rchecked.test( value ) ) { |
| 5995 | + return this.each(function() { |
| 5996 | + jQuery(this).domManip( args, table, callback, true ); |
| 5997 | + }); |
| 5998 | + } |
| 5999 | + |
| 6000 | + if ( jQuery.isFunction(value) ) { |
| 6001 | + return this.each(function(i) { |
| 6002 | + var self = jQuery(this); |
| 6003 | + args[0] = value.call(this, i, table ? self.html() : undefined); |
| 6004 | + self.domManip( args, table, callback ); |
| 6005 | + }); |
| 6006 | + } |
| 6007 | + |
| 6008 | + if ( this[0] ) { |
| 6009 | + parent = value && value.parentNode; |
| 6010 | + |
| 6011 | + // If we're in a fragment, just use that instead of building a new one |
| 6012 | + if ( jQuery.support.parentNode && parent && parent.nodeType === 11 && parent.childNodes.length === this.length ) { |
| 6013 | + results = { fragment: parent }; |
| 6014 | + |
| 6015 | + } else { |
| 6016 | + results = jQuery.buildFragment( args, this, scripts ); |
| 6017 | + } |
| 6018 | + |
| 6019 | + fragment = results.fragment; |
| 6020 | + |
| 6021 | + if ( fragment.childNodes.length === 1 ) { |
| 6022 | + first = fragment = fragment.firstChild; |
| 6023 | + } else { |
| 6024 | + first = fragment.firstChild; |
| 6025 | + } |
| 6026 | + |
| 6027 | + if ( first ) { |
| 6028 | + table = table && jQuery.nodeName( first, "tr" ); |
| 6029 | + |
| 6030 | + for ( var i = 0, l = this.length, lastIndex = l - 1; i < l; i++ ) { |
| 6031 | + callback.call( |
| 6032 | + table ? |
| 6033 | + root(this[i], first) : |
| 6034 | + this[i], |
| 6035 | + // Make sure that we do not leak memory by inadvertently discarding |
| 6036 | + // the original fragment (which might have attached data) instead of |
| 6037 | + // using it; in addition, use the original fragment object for the last |
| 6038 | + // item instead of first because it can end up being emptied incorrectly |
| 6039 | + // in certain situations (Bug #8070). |
| 6040 | + // Fragments from the fragment cache must always be cloned and never used |
| 6041 | + // in place. |
| 6042 | + results.cacheable || ( l > 1 && i < lastIndex ) ? |
| 6043 | + jQuery.clone( fragment, true, true ) : |
| 6044 | + fragment |
| 6045 | + ); |
| 6046 | + } |
| 6047 | + } |
| 6048 | + |
| 6049 | + if ( scripts.length ) { |
| 6050 | + jQuery.each( scripts, evalScript ); |
| 6051 | + } |
| 6052 | + } |
| 6053 | + |
| 6054 | + return this; |
| 6055 | + } |
| 6056 | +}); |
| 6057 | + |
| 6058 | +function root( elem, cur ) { |
| 6059 | + return jQuery.nodeName(elem, "table") ? |
| 6060 | + (elem.getElementsByTagName("tbody")[0] || |
| 6061 | + elem.appendChild(elem.ownerDocument.createElement("tbody"))) : |
| 6062 | + elem; |
| 6063 | +} |
| 6064 | + |
| 6065 | +function cloneCopyEvent( src, dest ) { |
| 6066 | + |
| 6067 | + if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) { |
| 6068 | + return; |
| 6069 | + } |
| 6070 | + |
| 6071 | + var type, i, l, |
| 6072 | + oldData = jQuery._data( src ), |
| 6073 | + curData = jQuery._data( dest, oldData ), |
| 6074 | + events = oldData.events; |
| 6075 | + |
| 6076 | + if ( events ) { |
| 6077 | + delete curData.handle; |
| 6078 | + curData.events = {}; |
| 6079 | + |
| 6080 | + for ( type in events ) { |
| 6081 | + for ( i = 0, l = events[ type ].length; i < l; i++ ) { |
| 6082 | + jQuery.event.add( dest, type + ( events[ type ][ i ].namespace ? "." : "" ) + events[ type ][ i ].namespace, events[ type ][ i ], events[ type ][ i ].data ); |
| 6083 | + } |
| 6084 | + } |
| 6085 | + } |
| 6086 | + |
| 6087 | + // make the cloned public data object a copy from the original |
| 6088 | + if ( curData.data ) { |
| 6089 | + curData.data = jQuery.extend( {}, curData.data ); |
| 6090 | + } |
| 6091 | +} |
| 6092 | + |
| 6093 | +function cloneFixAttributes( src, dest ) { |
| 6094 | + var nodeName; |
| 6095 | + |
| 6096 | + // We do not need to do anything for non-Elements |
| 6097 | + if ( dest.nodeType !== 1 ) { |
| 6098 | + return; |
| 6099 | + } |
| 6100 | + |
| 6101 | + // clearAttributes removes the attributes, which we don't want, |
| 6102 | + // but also removes the attachEvent events, which we *do* want |
| 6103 | + if ( dest.clearAttributes ) { |
| 6104 | + dest.clearAttributes(); |
| 6105 | + } |
| 6106 | + |
| 6107 | + // mergeAttributes, in contrast, only merges back on the |
| 6108 | + // original attributes, not the events |
| 6109 | + if ( dest.mergeAttributes ) { |
| 6110 | + dest.mergeAttributes( src ); |
| 6111 | + } |
| 6112 | + |
| 6113 | + nodeName = dest.nodeName.toLowerCase(); |
| 6114 | + |
| 6115 | + // IE6-8 fail to clone children inside object elements that use |
| 6116 | + // the proprietary classid attribute value (rather than the type |
| 6117 | + // attribute) to identify the type of content to display |
| 6118 | + if ( nodeName === "object" ) { |
| 6119 | + dest.outerHTML = src.outerHTML; |
| 6120 | + |
| 6121 | + } else if ( nodeName === "input" && (src.type === "checkbox" || src.type === "radio") ) { |
| 6122 | + // IE6-8 fails to persist the checked state of a cloned checkbox |
| 6123 | + // or radio button. Worse, IE6-7 fail to give the cloned element |
| 6124 | + // a checked appearance if the defaultChecked value isn't also set |
| 6125 | + if ( src.checked ) { |
| 6126 | + dest.defaultChecked = dest.checked = src.checked; |
| 6127 | + } |
| 6128 | + |
| 6129 | + // IE6-7 get confused and end up setting the value of a cloned |
| 6130 | + // checkbox/radio button to an empty string instead of "on" |
| 6131 | + if ( dest.value !== src.value ) { |
| 6132 | + dest.value = src.value; |
| 6133 | + } |
| 6134 | + |
| 6135 | + // IE6-8 fails to return the selected option to the default selected |
| 6136 | + // state when cloning options |
| 6137 | + } else if ( nodeName === "option" ) { |
| 6138 | + dest.selected = src.defaultSelected; |
| 6139 | + |
| 6140 | + // IE6-8 fails to set the defaultValue to the correct value when |
| 6141 | + // cloning other types of input fields |
| 6142 | + } else if ( nodeName === "input" || nodeName === "textarea" ) { |
| 6143 | + dest.defaultValue = src.defaultValue; |
| 6144 | + } |
| 6145 | + |
| 6146 | + // Event data gets referenced instead of copied if the expando |
| 6147 | + // gets copied too |
| 6148 | + dest.removeAttribute( jQuery.expando ); |
| 6149 | +} |
| 6150 | + |
| 6151 | +jQuery.buildFragment = function( args, nodes, scripts ) { |
| 6152 | + var fragment, cacheable, cacheresults, doc, |
| 6153 | + first = args[ 0 ]; |
| 6154 | + |
| 6155 | + // nodes may contain either an explicit document object, |
| 6156 | + // a jQuery collection or context object. |
| 6157 | + // If nodes[0] contains a valid object to assign to doc |
| 6158 | + if ( nodes && nodes[0] ) { |
| 6159 | + doc = nodes[0].ownerDocument || nodes[0]; |
| 6160 | + } |
| 6161 | + |
| 6162 | + // Ensure that an attr object doesn't incorrectly stand in as a document object |
| 6163 | + // Chrome and Firefox seem to allow this to occur and will throw exception |
| 6164 | + // Fixes #8950 |
| 6165 | + if ( !doc.createDocumentFragment ) { |
| 6166 | + doc = document; |
| 6167 | + } |
| 6168 | + |
| 6169 | + // Only cache "small" (1/2 KB) HTML strings that are associated with the main document |
| 6170 | + // Cloning options loses the selected state, so don't cache them |
| 6171 | + // IE 6 doesn't like it when you put <object> or <embed> elements in a fragment |
| 6172 | + // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache |
| 6173 | + // Lastly, IE6,7,8 will not correctly reuse cached fragments that were created from unknown elems #10501 |
| 6174 | + if ( args.length === 1 && typeof first === "string" && first.length < 512 && doc === document && |
| 6175 | + first.charAt(0) === "<" && !rnocache.test( first ) && |
| 6176 | + (jQuery.support.checkClone || !rchecked.test( first )) && |
| 6177 | + (!jQuery.support.unknownElems && rnoshimcache.test( first )) ) { |
| 6178 | + |
| 6179 | + cacheable = true; |
| 6180 | + |
| 6181 | + cacheresults = jQuery.fragments[ first ]; |
| 6182 | + if ( cacheresults && cacheresults !== 1 ) { |
| 6183 | + fragment = cacheresults; |
| 6184 | + } |
| 6185 | + } |
| 6186 | + |
| 6187 | + if ( !fragment ) { |
| 6188 | + fragment = doc.createDocumentFragment(); |
| 6189 | + jQuery.clean( args, doc, fragment, scripts ); |
| 6190 | + } |
| 6191 | + |
| 6192 | + if ( cacheable ) { |
| 6193 | + jQuery.fragments[ first ] = cacheresults ? fragment : 1; |
| 6194 | + } |
| 6195 | + |
| 6196 | + return { fragment: fragment, cacheable: cacheable }; |
| 6197 | +}; |
| 6198 | + |
| 6199 | +jQuery.fragments = {}; |
| 6200 | + |
| 6201 | +jQuery.each({ |
| 6202 | + appendTo: "append", |
| 6203 | + prependTo: "prepend", |
| 6204 | + insertBefore: "before", |
| 6205 | + insertAfter: "after", |
| 6206 | + replaceAll: "replaceWith" |
| 6207 | +}, function( name, original ) { |
| 6208 | + jQuery.fn[ name ] = function( selector ) { |
| 6209 | + var ret = [], |
| 6210 | + insert = jQuery( selector ), |
| 6211 | + parent = this.length === 1 && this[0].parentNode; |
| 6212 | + |
| 6213 | + if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) { |
| 6214 | + insert[ original ]( this[0] ); |
| 6215 | + return this; |
| 6216 | + |
| 6217 | + } else { |
| 6218 | + for ( var i = 0, l = insert.length; i < l; i++ ) { |
| 6219 | + var elems = ( i > 0 ? this.clone(true) : this ).get(); |
| 6220 | + jQuery( insert[i] )[ original ]( elems ); |
| 6221 | + ret = ret.concat( elems ); |
| 6222 | + } |
| 6223 | + |
| 6224 | + return this.pushStack( ret, name, insert.selector ); |
| 6225 | + } |
| 6226 | + }; |
| 6227 | +}); |
| 6228 | + |
| 6229 | +function getAll( elem ) { |
| 6230 | + if ( typeof elem.getElementsByTagName !== "undefined" ) { |
| 6231 | + return elem.getElementsByTagName( "*" ); |
| 6232 | + |
| 6233 | + } else if ( typeof elem.querySelectorAll !== "undefined" ) { |
| 6234 | + return elem.querySelectorAll( "*" ); |
| 6235 | + |
| 6236 | + } else { |
| 6237 | + return []; |
| 6238 | + } |
| 6239 | +} |
| 6240 | + |
| 6241 | +// Used in clean, fixes the defaultChecked property |
| 6242 | +function fixDefaultChecked( elem ) { |
| 6243 | + if ( elem.type === "checkbox" || elem.type === "radio" ) { |
| 6244 | + elem.defaultChecked = elem.checked; |
| 6245 | + } |
| 6246 | +} |
| 6247 | +// Finds all inputs and passes them to fixDefaultChecked |
| 6248 | +function findInputs( elem ) { |
| 6249 | + var nodeName = ( elem.nodeName || "" ).toLowerCase(); |
| 6250 | + if ( nodeName === "input" ) { |
| 6251 | + fixDefaultChecked( elem ); |
| 6252 | + // Skip scripts, get other children |
| 6253 | + } else if ( nodeName !== "script" && typeof elem.getElementsByTagName !== "undefined" ) { |
| 6254 | + jQuery.grep( elem.getElementsByTagName("input"), fixDefaultChecked ); |
| 6255 | + } |
| 6256 | +} |
| 6257 | + |
| 6258 | +jQuery.extend({ |
| 6259 | + clone: function( elem, dataAndEvents, deepDataAndEvents ) { |
| 6260 | + var clone = elem.cloneNode(true), |
| 6261 | + srcElements, |
| 6262 | + destElements, |
| 6263 | + i; |
| 6264 | + |
| 6265 | + if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) && |
| 6266 | + (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) { |
| 6267 | + // IE copies events bound via attachEvent when using cloneNode. |
| 6268 | + // Calling detachEvent on the clone will also remove the events |
| 6269 | + // from the original. In order to get around this, we use some |
| 6270 | + // proprietary methods to clear the events. Thanks to MooTools |
| 6271 | + // guys for this hotness. |
| 6272 | + |
| 6273 | + cloneFixAttributes( elem, clone ); |
| 6274 | + |
| 6275 | + // Using Sizzle here is crazy slow, so we use getElementsByTagName |
| 6276 | + // instead |
| 6277 | + srcElements = getAll( elem ); |
| 6278 | + destElements = getAll( clone ); |
| 6279 | + |
| 6280 | + // Weird iteration because IE will replace the length property |
| 6281 | + // with an element if you are cloning the body and one of the |
| 6282 | + // elements on the page has a name or id of "length" |
| 6283 | + for ( i = 0; srcElements[i]; ++i ) { |
| 6284 | + // Ensure that the destination node is not null; Fixes #9587 |
| 6285 | + if ( destElements[i] ) { |
| 6286 | + cloneFixAttributes( srcElements[i], destElements[i] ); |
| 6287 | + } |
| 6288 | + } |
| 6289 | + } |
| 6290 | + |
| 6291 | + // Copy the events from the original to the clone |
| 6292 | + if ( dataAndEvents ) { |
| 6293 | + cloneCopyEvent( elem, clone ); |
| 6294 | + |
| 6295 | + if ( deepDataAndEvents ) { |
| 6296 | + srcElements = getAll( elem ); |
| 6297 | + destElements = getAll( clone ); |
| 6298 | + |
| 6299 | + for ( i = 0; srcElements[i]; ++i ) { |
| 6300 | + cloneCopyEvent( srcElements[i], destElements[i] ); |
| 6301 | + } |
| 6302 | + } |
| 6303 | + } |
| 6304 | + |
| 6305 | + srcElements = destElements = null; |
| 6306 | + |
| 6307 | + // Return the cloned set |
| 6308 | + return clone; |
| 6309 | + }, |
| 6310 | + |
| 6311 | + clean: function( elems, context, fragment, scripts ) { |
| 6312 | + var checkScriptType; |
| 6313 | + |
| 6314 | + context = context || document; |
| 6315 | + |
| 6316 | + // !context.createElement fails in IE with an error but returns typeof 'object' |
| 6317 | + if ( typeof context.createElement === "undefined" ) { |
| 6318 | + context = context.ownerDocument || context[0] && context[0].ownerDocument || document; |
| 6319 | + } |
| 6320 | + |
| 6321 | + var ret = [], j; |
| 6322 | + |
| 6323 | + for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) { |
| 6324 | + if ( typeof elem === "number" ) { |
| 6325 | + elem += ""; |
| 6326 | + } |
| 6327 | + |
| 6328 | + if ( !elem ) { |
| 6329 | + continue; |
| 6330 | + } |
| 6331 | + |
| 6332 | + // Convert html string into DOM nodes |
| 6333 | + if ( typeof elem === "string" ) { |
| 6334 | + if ( !rhtml.test( elem ) ) { |
| 6335 | + elem = context.createTextNode( elem ); |
| 6336 | + } else { |
| 6337 | + // Fix "XHTML"-style tags in all browsers |
| 6338 | + elem = elem.replace(rxhtmlTag, "<$1></$2>"); |
| 6339 | + |
| 6340 | + // Trim whitespace, otherwise indexOf won't work as expected |
| 6341 | + var tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase(), |
| 6342 | + wrap = wrapMap[ tag ] || wrapMap._default, |
| 6343 | + depth = wrap[0], |
| 6344 | + div = context.createElement("div"); |
| 6345 | + |
| 6346 | + // Append wrapper element to unknown element safe doc fragment |
| 6347 | + if ( context === document ) { |
| 6348 | + // Use the fragment we've already created for this document |
| 6349 | + safeFragment.appendChild( div ); |
| 6350 | + } else { |
| 6351 | + // Use a fragment created with the owner document |
| 6352 | + createSafeFragment( context ).appendChild( div ); |
| 6353 | + } |
| 6354 | + |
| 6355 | + // Go to html and back, then peel off extra wrappers |
| 6356 | + div.innerHTML = wrap[1] + elem + wrap[2]; |
| 6357 | + |
| 6358 | + // Move to the right depth |
| 6359 | + while ( depth-- ) { |
| 6360 | + div = div.lastChild; |
| 6361 | + } |
| 6362 | + |
| 6363 | + // Remove IE's autoinserted <tbody> from table fragments |
| 6364 | + if ( !jQuery.support.tbody ) { |
| 6365 | + |
| 6366 | + // String was a <table>, *may* have spurious <tbody> |
| 6367 | + var hasBody = rtbody.test(elem), |
| 6368 | + tbody = tag === "table" && !hasBody ? |
| 6369 | + div.firstChild && div.firstChild.childNodes : |
| 6370 | + |
| 6371 | + // String was a bare <thead> or <tfoot> |
| 6372 | + wrap[1] === "<table>" && !hasBody ? |
| 6373 | + div.childNodes : |
| 6374 | + []; |
| 6375 | + |
| 6376 | + for ( j = tbody.length - 1; j >= 0 ; --j ) { |
| 6377 | + if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) { |
| 6378 | + tbody[ j ].parentNode.removeChild( tbody[ j ] ); |
| 6379 | + } |
| 6380 | + } |
| 6381 | + } |
| 6382 | + |
| 6383 | + // IE completely kills leading whitespace when innerHTML is used |
| 6384 | + if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) { |
| 6385 | + div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild ); |
| 6386 | + } |
| 6387 | + |
| 6388 | + elem = div.childNodes; |
| 6389 | + } |
| 6390 | + } |
| 6391 | + |
| 6392 | + // Resets defaultChecked for any radios and checkboxes |
| 6393 | + // about to be appended to the DOM in IE 6/7 (#8060) |
| 6394 | + var len; |
| 6395 | + if ( !jQuery.support.appendChecked ) { |
| 6396 | + if ( elem[0] && typeof (len = elem.length) === "number" ) { |
| 6397 | + for ( j = 0; j < len; j++ ) { |
| 6398 | + findInputs( elem[j] ); |
| 6399 | + } |
| 6400 | + } else { |
| 6401 | + findInputs( elem ); |
| 6402 | + } |
| 6403 | + } |
| 6404 | + |
| 6405 | + if ( elem.nodeType ) { |
| 6406 | + ret.push( elem ); |
| 6407 | + } else { |
| 6408 | + ret = jQuery.merge( ret, elem ); |
| 6409 | + } |
| 6410 | + } |
| 6411 | + |
| 6412 | + if ( fragment ) { |
| 6413 | + checkScriptType = function( elem ) { |
| 6414 | + return !elem.type || rscriptType.test( elem.type ); |
| 6415 | + }; |
| 6416 | + for ( i = 0; ret[i]; i++ ) { |
| 6417 | + if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) { |
| 6418 | + scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] ); |
| 6419 | + |
| 6420 | + } else { |
| 6421 | + if ( ret[i].nodeType === 1 ) { |
| 6422 | + var jsTags = jQuery.grep( ret[i].getElementsByTagName( "script" ), checkScriptType ); |
| 6423 | + |
| 6424 | + ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) ); |
| 6425 | + } |
| 6426 | + fragment.appendChild( ret[i] ); |
| 6427 | + } |
| 6428 | + } |
| 6429 | + } |
| 6430 | + |
| 6431 | + return ret; |
| 6432 | + }, |
| 6433 | + |
| 6434 | + cleanData: function( elems ) { |
| 6435 | + var data, id, |
| 6436 | + cache = jQuery.cache, |
| 6437 | + special = jQuery.event.special, |
| 6438 | + deleteExpando = jQuery.support.deleteExpando; |
| 6439 | + |
| 6440 | + for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) { |
| 6441 | + if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) { |
| 6442 | + continue; |
| 6443 | + } |
| 6444 | + |
| 6445 | + id = elem[ jQuery.expando ]; |
| 6446 | + |
| 6447 | + if ( id ) { |
| 6448 | + data = cache[ id ]; |
| 6449 | + |
| 6450 | + if ( data && data.events ) { |
| 6451 | + for ( var type in data.events ) { |
| 6452 | + if ( special[ type ] ) { |
| 6453 | + jQuery.event.remove( elem, type ); |
| 6454 | + |
| 6455 | + // This is a shortcut to avoid jQuery.event.remove's overhead |
| 6456 | + } else { |
| 6457 | + jQuery.removeEvent( elem, type, data.handle ); |
| 6458 | + } |
| 6459 | + } |
| 6460 | + |
| 6461 | + // Null the DOM reference to avoid IE6/7/8 leak (#7054) |
| 6462 | + if ( data.handle ) { |
| 6463 | + data.handle.elem = null; |
| 6464 | + } |
| 6465 | + } |
| 6466 | + |
| 6467 | + if ( deleteExpando ) { |
| 6468 | + delete elem[ jQuery.expando ]; |
| 6469 | + |
| 6470 | + } else if ( elem.removeAttribute ) { |
| 6471 | + elem.removeAttribute( jQuery.expando ); |
| 6472 | + } |
| 6473 | + |
| 6474 | + delete cache[ id ]; |
| 6475 | + } |
| 6476 | + } |
| 6477 | + } |
| 6478 | +}); |
| 6479 | + |
| 6480 | +function evalScript( i, elem ) { |
| 6481 | + if ( elem.src ) { |
| 6482 | + jQuery.ajax({ |
| 6483 | + url: elem.src, |
| 6484 | + async: false, |
| 6485 | + dataType: "script" |
| 6486 | + }); |
| 6487 | + } else { |
| 6488 | + jQuery.globalEval( ( elem.text || elem.textContent || elem.innerHTML || "" ).replace( rcleanScript, "/*$0*/" ) ); |
| 6489 | + } |
| 6490 | + |
| 6491 | + if ( elem.parentNode ) { |
| 6492 | + elem.parentNode.removeChild( elem ); |
| 6493 | + } |
| 6494 | +} |
| 6495 | + |
| 6496 | + |
| 6497 | + |
| 6498 | + |
| 6499 | +var ralpha = /alpha\([^)]*\)/i, |
| 6500 | + ropacity = /opacity=([^)]*)/, |
| 6501 | + // fixed for IE9, see #8346 |
| 6502 | + rupper = /([A-Z]|^ms)/g, |
| 6503 | + rnumpx = /^-?\d+(?:px)?$/i, |
| 6504 | + rnum = /^-?\d/, |
| 6505 | + rrelNum = /^([\-+])=([\-+.\de]+)/, |
| 6506 | + |
| 6507 | + cssShow = { position: "absolute", visibility: "hidden", display: "block" }, |
| 6508 | + cssWidth = [ "Left", "Right" ], |
| 6509 | + cssHeight = [ "Top", "Bottom" ], |
| 6510 | + curCSS, |
| 6511 | + |
| 6512 | + getComputedStyle, |
| 6513 | + currentStyle; |
| 6514 | + |
| 6515 | +jQuery.fn.css = function( name, value ) { |
| 6516 | + // Setting 'undefined' is a no-op |
| 6517 | + if ( arguments.length === 2 && value === undefined ) { |
| 6518 | + return this; |
| 6519 | + } |
| 6520 | + |
| 6521 | + return jQuery.access( this, name, value, true, function( elem, name, value ) { |
| 6522 | + return value !== undefined ? |
| 6523 | + jQuery.style( elem, name, value ) : |
| 6524 | + jQuery.css( elem, name ); |
| 6525 | + }); |
| 6526 | +}; |
| 6527 | + |
| 6528 | +jQuery.extend({ |
| 6529 | + // Add in style property hooks for overriding the default |
| 6530 | + // behavior of getting and setting a style property |
| 6531 | + cssHooks: { |
| 6532 | + opacity: { |
| 6533 | + get: function( elem, computed ) { |
| 6534 | + if ( computed ) { |
| 6535 | + // We should always get a number back from opacity |
| 6536 | + var ret = curCSS( elem, "opacity", "opacity" ); |
| 6537 | + return ret === "" ? "1" : ret; |
| 6538 | + |
| 6539 | + } else { |
| 6540 | + return elem.style.opacity; |
| 6541 | + } |
| 6542 | + } |
| 6543 | + } |
| 6544 | + }, |
| 6545 | + |
| 6546 | + // Exclude the following css properties to add px |
| 6547 | + cssNumber: { |
| 6548 | + "fillOpacity": true, |
| 6549 | + "fontWeight": true, |
| 6550 | + "lineHeight": true, |
| 6551 | + "opacity": true, |
| 6552 | + "orphans": true, |
| 6553 | + "widows": true, |
| 6554 | + "zIndex": true, |
| 6555 | + "zoom": true |
| 6556 | + }, |
| 6557 | + |
| 6558 | + // Add in properties whose names you wish to fix before |
| 6559 | + // setting or getting the value |
| 6560 | + cssProps: { |
| 6561 | + // normalize float css property |
| 6562 | + "float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat" |
| 6563 | + }, |
| 6564 | + |
| 6565 | + // Get and set the style property on a DOM Node |
| 6566 | + style: function( elem, name, value, extra ) { |
| 6567 | + // Don't set styles on text and comment nodes |
| 6568 | + if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) { |
| 6569 | + return; |
| 6570 | + } |
| 6571 | + |
| 6572 | + // Make sure that we're working with the right name |
| 6573 | + var ret, type, origName = jQuery.camelCase( name ), |
| 6574 | + style = elem.style, hooks = jQuery.cssHooks[ origName ]; |
| 6575 | + |
| 6576 | + name = jQuery.cssProps[ origName ] || origName; |
| 6577 | + |
| 6578 | + // Check if we're setting a value |
| 6579 | + if ( value !== undefined ) { |
| 6580 | + type = typeof value; |
| 6581 | + |
| 6582 | + // convert relative number strings (+= or -=) to relative numbers. #7345 |
| 6583 | + if ( type === "string" && (ret = rrelNum.exec( value )) ) { |
| 6584 | + value = ( +( ret[1] + 1) * +ret[2] ) + parseFloat( jQuery.css( elem, name ) ); |
| 6585 | + // Fixes bug #9237 |
| 6586 | + type = "number"; |
| 6587 | + } |
| 6588 | + |
| 6589 | + // Make sure that NaN and null values aren't set. See: #7116 |
| 6590 | + if ( value == null || type === "number" && isNaN( value ) ) { |
| 6591 | + return; |
| 6592 | + } |
| 6593 | + |
| 6594 | + // If a number was passed in, add 'px' to the (except for certain CSS properties) |
| 6595 | + if ( type === "number" && !jQuery.cssNumber[ origName ] ) { |
| 6596 | + value += "px"; |
| 6597 | + } |
| 6598 | + |
| 6599 | + // If a hook was provided, use that value, otherwise just set the specified value |
| 6600 | + if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value )) !== undefined ) { |
| 6601 | + // Wrapped to prevent IE from throwing errors when 'invalid' values are provided |
| 6602 | + // Fixes bug #5509 |
| 6603 | + try { |
| 6604 | + style[ name ] = value; |
| 6605 | + } catch(e) {} |
| 6606 | + } |
| 6607 | + |
| 6608 | + } else { |
| 6609 | + // If a hook was provided get the non-computed value from there |
| 6610 | + if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) { |
| 6611 | + return ret; |
| 6612 | + } |
| 6613 | + |
| 6614 | + // Otherwise just get the value from the style object |
| 6615 | + return style[ name ]; |
| 6616 | + } |
| 6617 | + }, |
| 6618 | + |
| 6619 | + css: function( elem, name, extra ) { |
| 6620 | + var ret, hooks; |
| 6621 | + |
| 6622 | + // Make sure that we're working with the right name |
| 6623 | + name = jQuery.camelCase( name ); |
| 6624 | + hooks = jQuery.cssHooks[ name ]; |
| 6625 | + name = jQuery.cssProps[ name ] || name; |
| 6626 | + |
| 6627 | + // cssFloat needs a special treatment |
| 6628 | + if ( name === "cssFloat" ) { |
| 6629 | + name = "float"; |
| 6630 | + } |
| 6631 | + |
| 6632 | + // If a hook was provided get the computed value from there |
| 6633 | + if ( hooks && "get" in hooks && (ret = hooks.get( elem, true, extra )) !== undefined ) { |
| 6634 | + return ret; |
| 6635 | + |
| 6636 | + // Otherwise, if a way to get the computed value exists, use that |
| 6637 | + } else if ( curCSS ) { |
| 6638 | + return curCSS( elem, name ); |
| 6639 | + } |
| 6640 | + }, |
| 6641 | + |
| 6642 | + // A method for quickly swapping in/out CSS properties to get correct calculations |
| 6643 | + swap: function( elem, options, callback ) { |
| 6644 | + var old = {}; |
| 6645 | + |
| 6646 | + // Remember the old values, and insert the new ones |
| 6647 | + for ( var name in options ) { |
| 6648 | + old[ name ] = elem.style[ name ]; |
| 6649 | + elem.style[ name ] = options[ name ]; |
| 6650 | + } |
| 6651 | + |
| 6652 | + callback.call( elem ); |
| 6653 | + |
| 6654 | + // Revert the old values |
| 6655 | + for ( name in options ) { |
| 6656 | + elem.style[ name ] = old[ name ]; |
| 6657 | + } |
| 6658 | + } |
| 6659 | +}); |
| 6660 | + |
| 6661 | +// DEPRECATED, Use jQuery.css() instead |
| 6662 | +jQuery.curCSS = jQuery.css; |
| 6663 | + |
| 6664 | +jQuery.each(["height", "width"], function( i, name ) { |
| 6665 | + jQuery.cssHooks[ name ] = { |
| 6666 | + get: function( elem, computed, extra ) { |
| 6667 | + var val; |
| 6668 | + |
| 6669 | + if ( computed ) { |
| 6670 | + if ( elem.offsetWidth !== 0 ) { |
| 6671 | + return getWH( elem, name, extra ); |
| 6672 | + } else { |
| 6673 | + jQuery.swap( elem, cssShow, function() { |
| 6674 | + val = getWH( elem, name, extra ); |
| 6675 | + }); |
| 6676 | + } |
| 6677 | + |
| 6678 | + return val; |
| 6679 | + } |
| 6680 | + }, |
| 6681 | + |
| 6682 | + set: function( elem, value ) { |
| 6683 | + if ( rnumpx.test( value ) ) { |
| 6684 | + // ignore negative width and height values #1599 |
| 6685 | + value = parseFloat( value ); |
| 6686 | + |
| 6687 | + if ( value >= 0 ) { |
| 6688 | + return value + "px"; |
| 6689 | + } |
| 6690 | + |
| 6691 | + } else { |
| 6692 | + return value; |
| 6693 | + } |
| 6694 | + } |
| 6695 | + }; |
| 6696 | +}); |
| 6697 | + |
| 6698 | +if ( !jQuery.support.opacity ) { |
| 6699 | + jQuery.cssHooks.opacity = { |
| 6700 | + get: function( elem, computed ) { |
| 6701 | + // IE uses filters for opacity |
| 6702 | + return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ? |
| 6703 | + ( parseFloat( RegExp.$1 ) / 100 ) + "" : |
| 6704 | + computed ? "1" : ""; |
| 6705 | + }, |
| 6706 | + |
| 6707 | + set: function( elem, value ) { |
| 6708 | + var style = elem.style, |
| 6709 | + currentStyle = elem.currentStyle, |
| 6710 | + opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "", |
| 6711 | + filter = currentStyle && currentStyle.filter || style.filter || ""; |
| 6712 | + |
| 6713 | + // IE has trouble with opacity if it does not have layout |
| 6714 | + // Force it by setting the zoom level |
| 6715 | + style.zoom = 1; |
| 6716 | + |
| 6717 | + // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652 |
| 6718 | + if ( value >= 1 && jQuery.trim( filter.replace( ralpha, "" ) ) === "" ) { |
| 6719 | + |
| 6720 | + // Setting style.filter to null, "" & " " still leave "filter:" in the cssText |
| 6721 | + // if "filter:" is present at all, clearType is disabled, we want to avoid this |
| 6722 | + // style.removeAttribute is IE Only, but so apparently is this code path... |
| 6723 | + style.removeAttribute( "filter" ); |
| 6724 | + |
| 6725 | + // if there there is no filter style applied in a css rule, we are done |
| 6726 | + if ( currentStyle && !currentStyle.filter ) { |
| 6727 | + return; |
| 6728 | + } |
| 6729 | + } |
| 6730 | + |
| 6731 | + // otherwise, set new filter values |
| 6732 | + style.filter = ralpha.test( filter ) ? |
| 6733 | + filter.replace( ralpha, opacity ) : |
| 6734 | + filter + " " + opacity; |
| 6735 | + } |
| 6736 | + }; |
| 6737 | +} |
| 6738 | + |
| 6739 | +jQuery(function() { |
| 6740 | + // This hook cannot be added until DOM ready because the support test |
| 6741 | + // for it is not run until after DOM ready |
| 6742 | + if ( !jQuery.support.reliableMarginRight ) { |
| 6743 | + jQuery.cssHooks.marginRight = { |
| 6744 | + get: function( elem, computed ) { |
| 6745 | + // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right |
| 6746 | + // Work around by temporarily setting element display to inline-block |
| 6747 | + var ret; |
| 6748 | + jQuery.swap( elem, { "display": "inline-block" }, function() { |
| 6749 | + if ( computed ) { |
| 6750 | + ret = curCSS( elem, "margin-right", "marginRight" ); |
| 6751 | + } else { |
| 6752 | + ret = elem.style.marginRight; |
| 6753 | + } |
| 6754 | + }); |
| 6755 | + return ret; |
| 6756 | + } |
| 6757 | + }; |
| 6758 | + } |
| 6759 | +}); |
| 6760 | + |
| 6761 | +if ( document.defaultView && document.defaultView.getComputedStyle ) { |
| 6762 | + getComputedStyle = function( elem, name ) { |
| 6763 | + var ret, defaultView, computedStyle; |
| 6764 | + |
| 6765 | + name = name.replace( rupper, "-$1" ).toLowerCase(); |
| 6766 | + |
| 6767 | + if ( !(defaultView = elem.ownerDocument.defaultView) ) { |
| 6768 | + return undefined; |
| 6769 | + } |
| 6770 | + |
| 6771 | + if ( (computedStyle = defaultView.getComputedStyle( elem, null )) ) { |
| 6772 | + ret = computedStyle.getPropertyValue( name ); |
| 6773 | + if ( ret === "" && !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) { |
| 6774 | + ret = jQuery.style( elem, name ); |
| 6775 | + } |
| 6776 | + } |
| 6777 | + |
| 6778 | + return ret; |
| 6779 | + }; |
| 6780 | +} |
| 6781 | + |
| 6782 | +if ( document.documentElement.currentStyle ) { |
| 6783 | + currentStyle = function( elem, name ) { |
| 6784 | + var left, rsLeft, uncomputed, |
| 6785 | + ret = elem.currentStyle && elem.currentStyle[ name ], |
| 6786 | + style = elem.style; |
| 6787 | + |
| 6788 | + // Avoid setting ret to empty string here |
| 6789 | + // so we don't default to auto |
| 6790 | + if ( ret === null && style && (uncomputed = style[ name ]) ) { |
| 6791 | + ret = uncomputed; |
| 6792 | + } |
| 6793 | + |
| 6794 | + // From the awesome hack by Dean Edwards |
| 6795 | + // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 |
| 6796 | + |
| 6797 | + // If we're not dealing with a regular pixel number |
| 6798 | + // but a number that has a weird ending, we need to convert it to pixels |
| 6799 | + if ( !rnumpx.test( ret ) && rnum.test( ret ) ) { |
| 6800 | + |
| 6801 | + // Remember the original values |
| 6802 | + left = style.left; |
| 6803 | + rsLeft = elem.runtimeStyle && elem.runtimeStyle.left; |
| 6804 | + |
| 6805 | + // Put in the new values to get a computed value out |
| 6806 | + if ( rsLeft ) { |
| 6807 | + elem.runtimeStyle.left = elem.currentStyle.left; |
| 6808 | + } |
| 6809 | + style.left = name === "fontSize" ? "1em" : ( ret || 0 ); |
| 6810 | + ret = style.pixelLeft + "px"; |
| 6811 | + |
| 6812 | + // Revert the changed values |
| 6813 | + style.left = left; |
| 6814 | + if ( rsLeft ) { |
| 6815 | + elem.runtimeStyle.left = rsLeft; |
| 6816 | + } |
| 6817 | + } |
| 6818 | + |
| 6819 | + return ret === "" ? "auto" : ret; |
| 6820 | + }; |
| 6821 | +} |
| 6822 | + |
| 6823 | +curCSS = getComputedStyle || currentStyle; |
| 6824 | + |
| 6825 | +function getWH( elem, name, extra ) { |
| 6826 | + |
| 6827 | + // Start with offset property |
| 6828 | + var val = name === "width" ? elem.offsetWidth : elem.offsetHeight, |
| 6829 | + which = name === "width" ? cssWidth : cssHeight; |
| 6830 | + |
| 6831 | + if ( val > 0 ) { |
| 6832 | + if ( extra !== "border" ) { |
| 6833 | + jQuery.each( which, function() { |
| 6834 | + if ( !extra ) { |
| 6835 | + val -= parseFloat( jQuery.css( elem, "padding" + this ) ) || 0; |
| 6836 | + } |
| 6837 | + if ( extra === "margin" ) { |
| 6838 | + val += parseFloat( jQuery.css( elem, extra + this ) ) || 0; |
| 6839 | + } else { |
| 6840 | + val -= parseFloat( jQuery.css( elem, "border" + this + "Width" ) ) || 0; |
| 6841 | + } |
| 6842 | + }); |
| 6843 | + } |
| 6844 | + |
| 6845 | + return val + "px"; |
| 6846 | + } |
| 6847 | + |
| 6848 | + // Fall back to computed then uncomputed css if necessary |
| 6849 | + val = curCSS( elem, name, name ); |
| 6850 | + if ( val < 0 || val == null ) { |
| 6851 | + val = elem.style[ name ] || 0; |
| 6852 | + } |
| 6853 | + // Normalize "", auto, and prepare for extra |
| 6854 | + val = parseFloat( val ) || 0; |
| 6855 | + |
| 6856 | + // Add padding, border, margin |
| 6857 | + if ( extra ) { |
| 6858 | + jQuery.each( which, function() { |
| 6859 | + val += parseFloat( jQuery.css( elem, "padding" + this ) ) || 0; |
| 6860 | + if ( extra !== "padding" ) { |
| 6861 | + val += parseFloat( jQuery.css( elem, "border" + this + "Width" ) ) || 0; |
| 6862 | + } |
| 6863 | + if ( extra === "margin" ) { |
| 6864 | + val += parseFloat( jQuery.css( elem, extra + this ) ) || 0; |
| 6865 | + } |
| 6866 | + }); |
| 6867 | + } |
| 6868 | + |
| 6869 | + return val + "px"; |
| 6870 | +} |
| 6871 | + |
| 6872 | +if ( jQuery.expr && jQuery.expr.filters ) { |
| 6873 | + jQuery.expr.filters.hidden = function( elem ) { |
| 6874 | + var width = elem.offsetWidth, |
| 6875 | + height = elem.offsetHeight; |
| 6876 | + |
| 6877 | + return ( width === 0 && height === 0 ) || (!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || jQuery.css( elem, "display" )) === "none"); |
| 6878 | + }; |
| 6879 | + |
| 6880 | + jQuery.expr.filters.visible = function( elem ) { |
| 6881 | + return !jQuery.expr.filters.hidden( elem ); |
| 6882 | + }; |
| 6883 | +} |
| 6884 | + |
| 6885 | + |
| 6886 | + |
| 6887 | + |
| 6888 | +var r20 = /%20/g, |
| 6889 | + rbracket = /\[\]$/, |
| 6890 | + rCRLF = /\r?\n/g, |
| 6891 | + rhash = /#.*$/, |
| 6892 | + rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL |
| 6893 | + rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i, |
| 6894 | + // #7653, #8125, #8152: local protocol detection |
| 6895 | + rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/, |
| 6896 | + rnoContent = /^(?:GET|HEAD)$/, |
| 6897 | + rprotocol = /^\/\//, |
| 6898 | + rquery = /\?/, |
| 6899 | + rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, |
| 6900 | + rselectTextarea = /^(?:select|textarea)/i, |
| 6901 | + rspacesAjax = /\s+/, |
| 6902 | + rts = /([?&])_=[^&]*/, |
| 6903 | + rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/, |
| 6904 | + |
| 6905 | + // Keep a copy of the old load method |
| 6906 | + _load = jQuery.fn.load, |
| 6907 | + |
| 6908 | + /* Prefilters |
| 6909 | + * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example) |
| 6910 | + * 2) These are called: |
| 6911 | + * - BEFORE asking for a transport |
| 6912 | + * - AFTER param serialization (s.data is a string if s.processData is true) |
| 6913 | + * 3) key is the dataType |
| 6914 | + * 4) the catchall symbol "*" can be used |
| 6915 | + * 5) execution will start with transport dataType and THEN continue down to "*" if needed |
| 6916 | + */ |
| 6917 | + prefilters = {}, |
| 6918 | + |
| 6919 | + /* Transports bindings |
| 6920 | + * 1) key is the dataType |
| 6921 | + * 2) the catchall symbol "*" can be used |
| 6922 | + * 3) selection will start with transport dataType and THEN go to "*" if needed |
| 6923 | + */ |
| 6924 | + transports = {}, |
| 6925 | + |
| 6926 | + // Document location |
| 6927 | + ajaxLocation, |
| 6928 | + |
| 6929 | + // Document location segments |
| 6930 | + ajaxLocParts, |
| 6931 | + |
| 6932 | + // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression |
| 6933 | + allTypes = ["*/"] + ["*"]; |
| 6934 | + |
| 6935 | +// #8138, IE may throw an exception when accessing |
| 6936 | +// a field from window.location if document.domain has been set |
| 6937 | +try { |
| 6938 | + ajaxLocation = location.href; |
| 6939 | +} catch( e ) { |
| 6940 | + // Use the href attribute of an A element |
| 6941 | + // since IE will modify it given document.location |
| 6942 | + ajaxLocation = document.createElement( "a" ); |
| 6943 | + ajaxLocation.href = ""; |
| 6944 | + ajaxLocation = ajaxLocation.href; |
| 6945 | +} |
| 6946 | + |
| 6947 | +// Segment location into parts |
| 6948 | +ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || []; |
| 6949 | + |
| 6950 | +// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport |
| 6951 | +function addToPrefiltersOrTransports( structure ) { |
| 6952 | + |
| 6953 | + // dataTypeExpression is optional and defaults to "*" |
| 6954 | + return function( dataTypeExpression, func ) { |
| 6955 | + |
| 6956 | + if ( typeof dataTypeExpression !== "string" ) { |
| 6957 | + func = dataTypeExpression; |
| 6958 | + dataTypeExpression = "*"; |
| 6959 | + } |
| 6960 | + |
| 6961 | + if ( jQuery.isFunction( func ) ) { |
| 6962 | + var dataTypes = dataTypeExpression.toLowerCase().split( rspacesAjax ), |
| 6963 | + i = 0, |
| 6964 | + length = dataTypes.length, |
| 6965 | + dataType, |
| 6966 | + list, |
| 6967 | + placeBefore; |
| 6968 | + |
| 6969 | + // For each dataType in the dataTypeExpression |
| 6970 | + for ( ; i < length; i++ ) { |
| 6971 | + dataType = dataTypes[ i ]; |
| 6972 | + // We control if we're asked to add before |
| 6973 | + // any existing element |
| 6974 | + placeBefore = /^\+/.test( dataType ); |
| 6975 | + if ( placeBefore ) { |
| 6976 | + dataType = dataType.substr( 1 ) || "*"; |
| 6977 | + } |
| 6978 | + list = structure[ dataType ] = structure[ dataType ] || []; |
| 6979 | + // then we add to the structure accordingly |
| 6980 | + list[ placeBefore ? "unshift" : "push" ]( func ); |
| 6981 | + } |
| 6982 | + } |
| 6983 | + }; |
| 6984 | +} |
| 6985 | + |
| 6986 | +// Base inspection function for prefilters and transports |
| 6987 | +function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR, |
| 6988 | + dataType /* internal */, inspected /* internal */ ) { |
| 6989 | + |
| 6990 | + dataType = dataType || options.dataTypes[ 0 ]; |
| 6991 | + inspected = inspected || {}; |
| 6992 | + |
| 6993 | + inspected[ dataType ] = true; |
| 6994 | + |
| 6995 | + var list = structure[ dataType ], |
| 6996 | + i = 0, |
| 6997 | + length = list ? list.length : 0, |
| 6998 | + executeOnly = ( structure === prefilters ), |
| 6999 | + selection; |
| 7000 | + |
| 7001 | + for ( ; i < length && ( executeOnly || !selection ); i++ ) { |
| 7002 | + selection = list[ i ]( options, originalOptions, jqXHR ); |
| 7003 | + // If we got redirected to another dataType |
| 7004 | + // we try there if executing only and not done already |
| 7005 | + if ( typeof selection === "string" ) { |
| 7006 | + if ( !executeOnly || inspected[ selection ] ) { |
| 7007 | + selection = undefined; |
| 7008 | + } else { |
| 7009 | + options.dataTypes.unshift( selection ); |
| 7010 | + selection = inspectPrefiltersOrTransports( |
| 7011 | + structure, options, originalOptions, jqXHR, selection, inspected ); |
| 7012 | + } |
| 7013 | + } |
| 7014 | + } |
| 7015 | + // If we're only executing or nothing was selected |
| 7016 | + // we try the catchall dataType if not done already |
| 7017 | + if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) { |
| 7018 | + selection = inspectPrefiltersOrTransports( |
| 7019 | + structure, options, originalOptions, jqXHR, "*", inspected ); |
| 7020 | + } |
| 7021 | + // unnecessary when only executing (prefilters) |
| 7022 | + // but it'll be ignored by the caller in that case |
| 7023 | + return selection; |
| 7024 | +} |
| 7025 | + |
| 7026 | +// A special extend for ajax options |
| 7027 | +// that takes "flat" options (not to be deep extended) |
| 7028 | +// Fixes #9887 |
| 7029 | +function ajaxExtend( target, src ) { |
| 7030 | + var key, deep, |
| 7031 | + flatOptions = jQuery.ajaxSettings.flatOptions || {}; |
| 7032 | + for ( key in src ) { |
| 7033 | + if ( src[ key ] !== undefined ) { |
| 7034 | + ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ]; |
| 7035 | + } |
| 7036 | + } |
| 7037 | + if ( deep ) { |
| 7038 | + jQuery.extend( true, target, deep ); |
| 7039 | + } |
| 7040 | +} |
| 7041 | + |
| 7042 | +jQuery.fn.extend({ |
| 7043 | + load: function( url, params, callback ) { |
| 7044 | + if ( typeof url !== "string" && _load ) { |
| 7045 | + return _load.apply( this, arguments ); |
| 7046 | + |
| 7047 | + // Don't do a request if no elements are being requested |
| 7048 | + } else if ( !this.length ) { |
| 7049 | + return this; |
| 7050 | + } |
| 7051 | + |
| 7052 | + var off = url.indexOf( " " ); |
| 7053 | + if ( off >= 0 ) { |
| 7054 | + var selector = url.slice( off, url.length ); |
| 7055 | + url = url.slice( 0, off ); |
| 7056 | + } |
| 7057 | + |
| 7058 | + // Default to a GET request |
| 7059 | + var type = "GET"; |
| 7060 | + |
| 7061 | + // If the second parameter was provided |
| 7062 | + if ( params ) { |
| 7063 | + // If it's a function |
| 7064 | + if ( jQuery.isFunction( params ) ) { |
| 7065 | + // We assume that it's the callback |
| 7066 | + callback = params; |
| 7067 | + params = undefined; |
| 7068 | + |
| 7069 | + // Otherwise, build a param string |
| 7070 | + } else if ( typeof params === "object" ) { |
| 7071 | + params = jQuery.param( params, jQuery.ajaxSettings.traditional ); |
| 7072 | + type = "POST"; |
| 7073 | + } |
| 7074 | + } |
| 7075 | + |
| 7076 | + var self = this; |
| 7077 | + |
| 7078 | + // Request the remote document |
| 7079 | + jQuery.ajax({ |
| 7080 | + url: url, |
| 7081 | + type: type, |
| 7082 | + dataType: "html", |
| 7083 | + data: params, |
| 7084 | + // Complete callback (responseText is used internally) |
| 7085 | + complete: function( jqXHR, status, responseText ) { |
| 7086 | + // Store the response as specified by the jqXHR object |
| 7087 | + responseText = jqXHR.responseText; |
| 7088 | + // If successful, inject the HTML into all the matched elements |
| 7089 | + if ( jqXHR.isResolved() ) { |
| 7090 | + // #4825: Get the actual response in case |
| 7091 | + // a dataFilter is present in ajaxSettings |
| 7092 | + jqXHR.done(function( r ) { |
| 7093 | + responseText = r; |
| 7094 | + }); |
| 7095 | + // See if a selector was specified |
| 7096 | + self.html( selector ? |
| 7097 | + // Create a dummy div to hold the results |
| 7098 | + jQuery("<div>") |
| 7099 | + // inject the contents of the document in, removing the scripts |
| 7100 | + // to avoid any 'Permission Denied' errors in IE |
| 7101 | + .append(responseText.replace(rscript, "")) |
| 7102 | + |
| 7103 | + // Locate the specified elements |
| 7104 | + .find(selector) : |
| 7105 | + |
| 7106 | + // If not, just inject the full result |
| 7107 | + responseText ); |
| 7108 | + } |
| 7109 | + |
| 7110 | + if ( callback ) { |
| 7111 | + self.each( callback, [ responseText, status, jqXHR ] ); |
| 7112 | + } |
| 7113 | + } |
| 7114 | + }); |
| 7115 | + |
| 7116 | + return this; |
| 7117 | + }, |
| 7118 | + |
| 7119 | + serialize: function() { |
| 7120 | + return jQuery.param( this.serializeArray() ); |
| 7121 | + }, |
| 7122 | + |
| 7123 | + serializeArray: function() { |
| 7124 | + return this.map(function(){ |
| 7125 | + return this.elements ? jQuery.makeArray( this.elements ) : this; |
| 7126 | + }) |
| 7127 | + .filter(function(){ |
| 7128 | + return this.name && !this.disabled && |
| 7129 | + ( this.checked || rselectTextarea.test( this.nodeName ) || |
| 7130 | + rinput.test( this.type ) ); |
| 7131 | + }) |
| 7132 | + .map(function( i, elem ){ |
| 7133 | + var val = jQuery( this ).val(); |
| 7134 | + |
| 7135 | + return val == null ? |
| 7136 | + null : |
| 7137 | + jQuery.isArray( val ) ? |
| 7138 | + jQuery.map( val, function( val, i ){ |
| 7139 | + return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; |
| 7140 | + }) : |
| 7141 | + { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; |
| 7142 | + }).get(); |
| 7143 | + } |
| 7144 | +}); |
| 7145 | + |
| 7146 | +// Attach a bunch of functions for handling common AJAX events |
| 7147 | +jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i, o ){ |
| 7148 | + jQuery.fn[ o ] = function( f ){ |
| 7149 | + return this.bind( o, f ); |
| 7150 | + }; |
| 7151 | +}); |
| 7152 | + |
| 7153 | +jQuery.each( [ "get", "post" ], function( i, method ) { |
| 7154 | + jQuery[ method ] = function( url, data, callback, type ) { |
| 7155 | + // shift arguments if data argument was omitted |
| 7156 | + if ( jQuery.isFunction( data ) ) { |
| 7157 | + type = type || callback; |
| 7158 | + callback = data; |
| 7159 | + data = undefined; |
| 7160 | + } |
| 7161 | + |
| 7162 | + return jQuery.ajax({ |
| 7163 | + type: method, |
| 7164 | + url: url, |
| 7165 | + data: data, |
| 7166 | + success: callback, |
| 7167 | + dataType: type |
| 7168 | + }); |
| 7169 | + }; |
| 7170 | +}); |
| 7171 | + |
| 7172 | +jQuery.extend({ |
| 7173 | + |
| 7174 | + getScript: function( url, callback ) { |
| 7175 | + return jQuery.get( url, undefined, callback, "script" ); |
| 7176 | + }, |
| 7177 | + |
| 7178 | + getJSON: function( url, data, callback ) { |
| 7179 | + return jQuery.get( url, data, callback, "json" ); |
| 7180 | + }, |
| 7181 | + |
| 7182 | + // Creates a full fledged settings object into target |
| 7183 | + // with both ajaxSettings and settings fields. |
| 7184 | + // If target is omitted, writes into ajaxSettings. |
| 7185 | + ajaxSetup: function( target, settings ) { |
| 7186 | + if ( settings ) { |
| 7187 | + // Building a settings object |
| 7188 | + ajaxExtend( target, jQuery.ajaxSettings ); |
| 7189 | + } else { |
| 7190 | + // Extending ajaxSettings |
| 7191 | + settings = target; |
| 7192 | + target = jQuery.ajaxSettings; |
| 7193 | + } |
| 7194 | + ajaxExtend( target, settings ); |
| 7195 | + return target; |
| 7196 | + }, |
| 7197 | + |
| 7198 | + ajaxSettings: { |
| 7199 | + url: ajaxLocation, |
| 7200 | + isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ), |
| 7201 | + global: true, |
| 7202 | + type: "GET", |
| 7203 | + contentType: "application/x-www-form-urlencoded", |
| 7204 | + processData: true, |
| 7205 | + async: true, |
| 7206 | + /* |
| 7207 | + timeout: 0, |
| 7208 | + data: null, |
| 7209 | + dataType: null, |
| 7210 | + username: null, |
| 7211 | + password: null, |
| 7212 | + cache: null, |
| 7213 | + traditional: false, |
| 7214 | + headers: {}, |
| 7215 | + */ |
| 7216 | + |
| 7217 | + accepts: { |
| 7218 | + xml: "application/xml, text/xml", |
| 7219 | + html: "text/html", |
| 7220 | + text: "text/plain", |
| 7221 | + json: "application/json, text/javascript", |
| 7222 | + "*": allTypes |
| 7223 | + }, |
| 7224 | + |
| 7225 | + contents: { |
| 7226 | + xml: /xml/, |
| 7227 | + html: /html/, |
| 7228 | + json: /json/ |
| 7229 | + }, |
| 7230 | + |
| 7231 | + responseFields: { |
| 7232 | + xml: "responseXML", |
| 7233 | + text: "responseText" |
| 7234 | + }, |
| 7235 | + |
| 7236 | + // List of data converters |
| 7237 | + // 1) key format is "source_type destination_type" (a single space in-between) |
| 7238 | + // 2) the catchall symbol "*" can be used for source_type |
| 7239 | + converters: { |
| 7240 | + |
| 7241 | + // Convert anything to text |
| 7242 | + "* text": window.String, |
| 7243 | + |
| 7244 | + // Text to html (true = no transformation) |
| 7245 | + "text html": true, |
| 7246 | + |
| 7247 | + // Evaluate text as a json expression |
| 7248 | + "text json": jQuery.parseJSON, |
| 7249 | + |
| 7250 | + // Parse text as xml |
| 7251 | + "text xml": jQuery.parseXML |
| 7252 | + }, |
| 7253 | + |
| 7254 | + // For options that shouldn't be deep extended: |
| 7255 | + // you can add your own custom options here if |
| 7256 | + // and when you create one that shouldn't be |
| 7257 | + // deep extended (see ajaxExtend) |
| 7258 | + flatOptions: { |
| 7259 | + context: true, |
| 7260 | + url: true |
| 7261 | + } |
| 7262 | + }, |
| 7263 | + |
| 7264 | + ajaxPrefilter: addToPrefiltersOrTransports( prefilters ), |
| 7265 | + ajaxTransport: addToPrefiltersOrTransports( transports ), |
| 7266 | + |
| 7267 | + // Main method |
| 7268 | + ajax: function( url, options ) { |
| 7269 | + |
| 7270 | + // If url is an object, simulate pre-1.5 signature |
| 7271 | + if ( typeof url === "object" ) { |
| 7272 | + options = url; |
| 7273 | + url = undefined; |
| 7274 | + } |
| 7275 | + |
| 7276 | + // Force options to be an object |
| 7277 | + options = options || {}; |
| 7278 | + |
| 7279 | + var // Create the final options object |
| 7280 | + s = jQuery.ajaxSetup( {}, options ), |
| 7281 | + // Callbacks context |
| 7282 | + callbackContext = s.context || s, |
| 7283 | + // Context for global events |
| 7284 | + // It's the callbackContext if one was provided in the options |
| 7285 | + // and if it's a DOM node or a jQuery collection |
| 7286 | + globalEventContext = callbackContext !== s && |
| 7287 | + ( callbackContext.nodeType || callbackContext instanceof jQuery ) ? |
| 7288 | + jQuery( callbackContext ) : jQuery.event, |
| 7289 | + // Deferreds |
| 7290 | + deferred = jQuery.Deferred(), |
| 7291 | + completeDeferred = jQuery.Callbacks( "once memory" ), |
| 7292 | + // Status-dependent callbacks |
| 7293 | + statusCode = s.statusCode || {}, |
| 7294 | + // ifModified key |
| 7295 | + ifModifiedKey, |
| 7296 | + // Headers (they are sent all at once) |
| 7297 | + requestHeaders = {}, |
| 7298 | + requestHeadersNames = {}, |
| 7299 | + // Response headers |
| 7300 | + responseHeadersString, |
| 7301 | + responseHeaders, |
| 7302 | + // transport |
| 7303 | + transport, |
| 7304 | + // timeout handle |
| 7305 | + timeoutTimer, |
| 7306 | + // Cross-domain detection vars |
| 7307 | + parts, |
| 7308 | + // The jqXHR state |
| 7309 | + state = 0, |
| 7310 | + // To know if global events are to be dispatched |
| 7311 | + fireGlobals, |
| 7312 | + // Loop variable |
| 7313 | + i, |
| 7314 | + // Fake xhr |
| 7315 | + jqXHR = { |
| 7316 | + |
| 7317 | + readyState: 0, |
| 7318 | + |
| 7319 | + // Caches the header |
| 7320 | + setRequestHeader: function( name, value ) { |
| 7321 | + if ( !state ) { |
| 7322 | + var lname = name.toLowerCase(); |
| 7323 | + name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name; |
| 7324 | + requestHeaders[ name ] = value; |
| 7325 | + } |
| 7326 | + return this; |
| 7327 | + }, |
| 7328 | + |
| 7329 | + // Raw string |
| 7330 | + getAllResponseHeaders: function() { |
| 7331 | + return state === 2 ? responseHeadersString : null; |
| 7332 | + }, |
| 7333 | + |
| 7334 | + // Builds headers hashtable if needed |
| 7335 | + getResponseHeader: function( key ) { |
| 7336 | + var match; |
| 7337 | + if ( state === 2 ) { |
| 7338 | + if ( !responseHeaders ) { |
| 7339 | + responseHeaders = {}; |
| 7340 | + while( ( match = rheaders.exec( responseHeadersString ) ) ) { |
| 7341 | + responseHeaders[ match[1].toLowerCase() ] = match[ 2 ]; |
| 7342 | + } |
| 7343 | + } |
| 7344 | + match = responseHeaders[ key.toLowerCase() ]; |
| 7345 | + } |
| 7346 | + return match === undefined ? null : match; |
| 7347 | + }, |
| 7348 | + |
| 7349 | + // Overrides response content-type header |
| 7350 | + overrideMimeType: function( type ) { |
| 7351 | + if ( !state ) { |
| 7352 | + s.mimeType = type; |
| 7353 | + } |
| 7354 | + return this; |
| 7355 | + }, |
| 7356 | + |
| 7357 | + // Cancel the request |
| 7358 | + abort: function( statusText ) { |
| 7359 | + statusText = statusText || "abort"; |
| 7360 | + if ( transport ) { |
| 7361 | + transport.abort( statusText ); |
| 7362 | + } |
| 7363 | + done( 0, statusText ); |
| 7364 | + return this; |
| 7365 | + } |
| 7366 | + }; |
| 7367 | + |
| 7368 | + // Callback for when everything is done |
| 7369 | + // It is defined here because jslint complains if it is declared |
| 7370 | + // at the end of the function (which would be more logical and readable) |
| 7371 | + function done( status, nativeStatusText, responses, headers ) { |
| 7372 | + |
| 7373 | + // Called once |
| 7374 | + if ( state === 2 ) { |
| 7375 | + return; |
| 7376 | + } |
| 7377 | + |
| 7378 | + // State is "done" now |
| 7379 | + state = 2; |
| 7380 | + |
| 7381 | + // Clear timeout if it exists |
| 7382 | + if ( timeoutTimer ) { |
| 7383 | + clearTimeout( timeoutTimer ); |
| 7384 | + } |
| 7385 | + |
| 7386 | + // Dereference transport for early garbage collection |
| 7387 | + // (no matter how long the jqXHR object will be used) |
| 7388 | + transport = undefined; |
| 7389 | + |
| 7390 | + // Cache response headers |
| 7391 | + responseHeadersString = headers || ""; |
| 7392 | + |
| 7393 | + // Set readyState |
| 7394 | + jqXHR.readyState = status > 0 ? 4 : 0; |
| 7395 | + |
| 7396 | + var isSuccess, |
| 7397 | + success, |
| 7398 | + error, |
| 7399 | + statusText = nativeStatusText, |
| 7400 | + response = responses ? ajaxHandleResponses( s, jqXHR, responses ) : undefined, |
| 7401 | + lastModified, |
| 7402 | + etag; |
| 7403 | + |
| 7404 | + // If successful, handle type chaining |
| 7405 | + if ( status >= 200 && status < 300 || status === 304 ) { |
| 7406 | + |
| 7407 | + // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. |
| 7408 | + if ( s.ifModified ) { |
| 7409 | + |
| 7410 | + if ( ( lastModified = jqXHR.getResponseHeader( "Last-Modified" ) ) ) { |
| 7411 | + jQuery.lastModified[ ifModifiedKey ] = lastModified; |
| 7412 | + } |
| 7413 | + if ( ( etag = jqXHR.getResponseHeader( "Etag" ) ) ) { |
| 7414 | + jQuery.etag[ ifModifiedKey ] = etag; |
| 7415 | + } |
| 7416 | + } |
| 7417 | + |
| 7418 | + // If not modified |
| 7419 | + if ( status === 304 ) { |
| 7420 | + |
| 7421 | + statusText = "notmodified"; |
| 7422 | + isSuccess = true; |
| 7423 | + |
| 7424 | + // If we have data |
| 7425 | + } else { |
| 7426 | + |
| 7427 | + try { |
| 7428 | + success = ajaxConvert( s, response ); |
| 7429 | + statusText = "success"; |
| 7430 | + isSuccess = true; |
| 7431 | + } catch(e) { |
| 7432 | + // We have a parsererror |
| 7433 | + statusText = "parsererror"; |
| 7434 | + error = e; |
| 7435 | + } |
| 7436 | + } |
| 7437 | + } else { |
| 7438 | + // We extract error from statusText |
| 7439 | + // then normalize statusText and status for non-aborts |
| 7440 | + error = statusText; |
| 7441 | + if ( !statusText || status ) { |
| 7442 | + statusText = "error"; |
| 7443 | + if ( status < 0 ) { |
| 7444 | + status = 0; |
| 7445 | + } |
| 7446 | + } |
| 7447 | + } |
| 7448 | + |
| 7449 | + // Set data for the fake xhr object |
| 7450 | + jqXHR.status = status; |
| 7451 | + jqXHR.statusText = "" + ( nativeStatusText || statusText ); |
| 7452 | + |
| 7453 | + // Success/Error |
| 7454 | + if ( isSuccess ) { |
| 7455 | + deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] ); |
| 7456 | + } else { |
| 7457 | + deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] ); |
| 7458 | + } |
| 7459 | + |
| 7460 | + // Status-dependent callbacks |
| 7461 | + jqXHR.statusCode( statusCode ); |
| 7462 | + statusCode = undefined; |
| 7463 | + |
| 7464 | + if ( fireGlobals ) { |
| 7465 | + globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ), |
| 7466 | + [ jqXHR, s, isSuccess ? success : error ] ); |
| 7467 | + } |
| 7468 | + |
| 7469 | + // Complete |
| 7470 | + completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] ); |
| 7471 | + |
| 7472 | + if ( fireGlobals ) { |
| 7473 | + globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] ); |
| 7474 | + // Handle the global AJAX counter |
| 7475 | + if ( !( --jQuery.active ) ) { |
| 7476 | + jQuery.event.trigger( "ajaxStop" ); |
| 7477 | + } |
| 7478 | + } |
| 7479 | + } |
| 7480 | + |
| 7481 | + // Attach deferreds |
| 7482 | + deferred.promise( jqXHR ); |
| 7483 | + jqXHR.success = jqXHR.done; |
| 7484 | + jqXHR.error = jqXHR.fail; |
| 7485 | + jqXHR.complete = completeDeferred.add; |
| 7486 | + |
| 7487 | + // Status-dependent callbacks |
| 7488 | + jqXHR.statusCode = function( map ) { |
| 7489 | + if ( map ) { |
| 7490 | + var tmp; |
| 7491 | + if ( state < 2 ) { |
| 7492 | + for ( tmp in map ) { |
| 7493 | + statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ]; |
| 7494 | + } |
| 7495 | + } else { |
| 7496 | + tmp = map[ jqXHR.status ]; |
| 7497 | + jqXHR.then( tmp, tmp ); |
| 7498 | + } |
| 7499 | + } |
| 7500 | + return this; |
| 7501 | + }; |
| 7502 | + |
| 7503 | + // Remove hash character (#7531: and string promotion) |
| 7504 | + // Add protocol if not provided (#5866: IE7 issue with protocol-less urls) |
| 7505 | + // We also use the url parameter if available |
| 7506 | + s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" ); |
| 7507 | + |
| 7508 | + // Extract dataTypes list |
| 7509 | + s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( rspacesAjax ); |
| 7510 | + |
| 7511 | + // Determine if a cross-domain request is in order |
| 7512 | + if ( s.crossDomain == null ) { |
| 7513 | + parts = rurl.exec( s.url.toLowerCase() ); |
| 7514 | + s.crossDomain = !!( parts && |
| 7515 | + ( parts[ 1 ] != ajaxLocParts[ 1 ] || parts[ 2 ] != ajaxLocParts[ 2 ] || |
| 7516 | + ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) != |
| 7517 | + ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) ) |
| 7518 | + ); |
| 7519 | + } |
| 7520 | + |
| 7521 | + // Convert data if not already a string |
| 7522 | + if ( s.data && s.processData && typeof s.data !== "string" ) { |
| 7523 | + s.data = jQuery.param( s.data, s.traditional ); |
| 7524 | + } |
| 7525 | + |
| 7526 | + // Apply prefilters |
| 7527 | + inspectPrefiltersOrTransports( prefilters, s, options, jqXHR ); |
| 7528 | + |
| 7529 | + // If request was aborted inside a prefiler, stop there |
| 7530 | + if ( state === 2 ) { |
| 7531 | + return false; |
| 7532 | + } |
| 7533 | + |
| 7534 | + // We can fire global events as of now if asked to |
| 7535 | + fireGlobals = s.global; |
| 7536 | + |
| 7537 | + // Uppercase the type |
| 7538 | + s.type = s.type.toUpperCase(); |
| 7539 | + |
| 7540 | + // Determine if request has content |
| 7541 | + s.hasContent = !rnoContent.test( s.type ); |
| 7542 | + |
| 7543 | + // Watch for a new set of requests |
| 7544 | + if ( fireGlobals && jQuery.active++ === 0 ) { |
| 7545 | + jQuery.event.trigger( "ajaxStart" ); |
| 7546 | + } |
| 7547 | + |
| 7548 | + // More options handling for requests with no content |
| 7549 | + if ( !s.hasContent ) { |
| 7550 | + |
| 7551 | + // If data is available, append data to url |
| 7552 | + if ( s.data ) { |
| 7553 | + s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data; |
| 7554 | + // #9682: remove data so that it's not used in an eventual retry |
| 7555 | + delete s.data; |
| 7556 | + } |
| 7557 | + |
| 7558 | + // Get ifModifiedKey before adding the anti-cache parameter |
| 7559 | + ifModifiedKey = s.url; |
| 7560 | + |
| 7561 | + // Add anti-cache in url if needed |
| 7562 | + if ( s.cache === false ) { |
| 7563 | + |
| 7564 | + var ts = jQuery.now(), |
| 7565 | + // try replacing _= if it is there |
| 7566 | + ret = s.url.replace( rts, "$1_=" + ts ); |
| 7567 | + |
| 7568 | + // if nothing was replaced, add timestamp to the end |
| 7569 | + s.url = ret + ( ( ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" ); |
| 7570 | + } |
| 7571 | + } |
| 7572 | + |
| 7573 | + // Set the correct header, if data is being sent |
| 7574 | + if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) { |
| 7575 | + jqXHR.setRequestHeader( "Content-Type", s.contentType ); |
| 7576 | + } |
| 7577 | + |
| 7578 | + // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. |
| 7579 | + if ( s.ifModified ) { |
| 7580 | + ifModifiedKey = ifModifiedKey || s.url; |
| 7581 | + if ( jQuery.lastModified[ ifModifiedKey ] ) { |
| 7582 | + jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ ifModifiedKey ] ); |
| 7583 | + } |
| 7584 | + if ( jQuery.etag[ ifModifiedKey ] ) { |
| 7585 | + jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ ifModifiedKey ] ); |
| 7586 | + } |
| 7587 | + } |
| 7588 | + |
| 7589 | + // Set the Accepts header for the server, depending on the dataType |
| 7590 | + jqXHR.setRequestHeader( |
| 7591 | + "Accept", |
| 7592 | + s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ? |
| 7593 | + s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) : |
| 7594 | + s.accepts[ "*" ] |
| 7595 | + ); |
| 7596 | + |
| 7597 | + // Check for headers option |
| 7598 | + for ( i in s.headers ) { |
| 7599 | + jqXHR.setRequestHeader( i, s.headers[ i ] ); |
| 7600 | + } |
| 7601 | + |
| 7602 | + // Allow custom headers/mimetypes and early abort |
| 7603 | + if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) { |
| 7604 | + // Abort if not done already |
| 7605 | + jqXHR.abort(); |
| 7606 | + return false; |
| 7607 | + |
| 7608 | + } |
| 7609 | + |
| 7610 | + // Install callbacks on deferreds |
| 7611 | + for ( i in { success: 1, error: 1, complete: 1 } ) { |
| 7612 | + jqXHR[ i ]( s[ i ] ); |
| 7613 | + } |
| 7614 | + |
| 7615 | + // Get transport |
| 7616 | + transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR ); |
| 7617 | + |
| 7618 | + // If no transport, we auto-abort |
| 7619 | + if ( !transport ) { |
| 7620 | + done( -1, "No Transport" ); |
| 7621 | + } else { |
| 7622 | + jqXHR.readyState = 1; |
| 7623 | + // Send global event |
| 7624 | + if ( fireGlobals ) { |
| 7625 | + globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] ); |
| 7626 | + } |
| 7627 | + // Timeout |
| 7628 | + if ( s.async && s.timeout > 0 ) { |
| 7629 | + timeoutTimer = setTimeout( function(){ |
| 7630 | + jqXHR.abort( "timeout" ); |
| 7631 | + }, s.timeout ); |
| 7632 | + } |
| 7633 | + |
| 7634 | + try { |
| 7635 | + state = 1; |
| 7636 | + transport.send( requestHeaders, done ); |
| 7637 | + } catch (e) { |
| 7638 | + // Propagate exception as error if not done |
| 7639 | + if ( state < 2 ) { |
| 7640 | + done( -1, e ); |
| 7641 | + // Simply rethrow otherwise |
| 7642 | + } else { |
| 7643 | + jQuery.error( e ); |
| 7644 | + } |
| 7645 | + } |
| 7646 | + } |
| 7647 | + |
| 7648 | + return jqXHR; |
| 7649 | + }, |
| 7650 | + |
| 7651 | + // Serialize an array of form elements or a set of |
| 7652 | + // key/values into a query string |
| 7653 | + param: function( a, traditional ) { |
| 7654 | + var s = [], |
| 7655 | + add = function( key, value ) { |
| 7656 | + // If value is a function, invoke it and return its value |
| 7657 | + value = jQuery.isFunction( value ) ? value() : value; |
| 7658 | + s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value ); |
| 7659 | + }; |
| 7660 | + |
| 7661 | + // Set traditional to true for jQuery <= 1.3.2 behavior. |
| 7662 | + if ( traditional === undefined ) { |
| 7663 | + traditional = jQuery.ajaxSettings.traditional; |
| 7664 | + } |
| 7665 | + |
| 7666 | + // If an array was passed in, assume that it is an array of form elements. |
| 7667 | + if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { |
| 7668 | + // Serialize the form elements |
| 7669 | + jQuery.each( a, function() { |
| 7670 | + add( this.name, this.value ); |
| 7671 | + }); |
| 7672 | + |
| 7673 | + } else { |
| 7674 | + // If traditional, encode the "old" way (the way 1.3.2 or older |
| 7675 | + // did it), otherwise encode params recursively. |
| 7676 | + for ( var prefix in a ) { |
| 7677 | + buildParams( prefix, a[ prefix ], traditional, add ); |
| 7678 | + } |
| 7679 | + } |
| 7680 | + |
| 7681 | + // Return the resulting serialization |
| 7682 | + return s.join( "&" ).replace( r20, "+" ); |
| 7683 | + } |
| 7684 | +}); |
| 7685 | + |
| 7686 | +function buildParams( prefix, obj, traditional, add ) { |
| 7687 | + if ( jQuery.isArray( obj ) ) { |
| 7688 | + // Serialize array item. |
| 7689 | + jQuery.each( obj, function( i, v ) { |
| 7690 | + if ( traditional || rbracket.test( prefix ) ) { |
| 7691 | + // Treat each array item as a scalar. |
| 7692 | + add( prefix, v ); |
| 7693 | + |
| 7694 | + } else { |
| 7695 | + // If array item is non-scalar (array or object), encode its |
| 7696 | + // numeric index to resolve deserialization ambiguity issues. |
| 7697 | + // Note that rack (as of 1.0.0) can't currently deserialize |
| 7698 | + // nested arrays properly, and attempting to do so may cause |
| 7699 | + // a server error. Possible fixes are to modify rack's |
| 7700 | + // deserialization algorithm or to provide an option or flag |
| 7701 | + // to force array serialization to be shallow. |
| 7702 | + buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v, traditional, add ); |
| 7703 | + } |
| 7704 | + }); |
| 7705 | + |
| 7706 | + } else if ( !traditional && obj != null && typeof obj === "object" ) { |
| 7707 | + // Serialize object item. |
| 7708 | + for ( var name in obj ) { |
| 7709 | + buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); |
| 7710 | + } |
| 7711 | + |
| 7712 | + } else { |
| 7713 | + // Serialize scalar item. |
| 7714 | + add( prefix, obj ); |
| 7715 | + } |
| 7716 | +} |
| 7717 | + |
| 7718 | +// This is still on the jQuery object... for now |
| 7719 | +// Want to move this to jQuery.ajax some day |
| 7720 | +jQuery.extend({ |
| 7721 | + |
| 7722 | + // Counter for holding the number of active queries |
| 7723 | + active: 0, |
| 7724 | + |
| 7725 | + // Last-Modified header cache for next request |
| 7726 | + lastModified: {}, |
| 7727 | + etag: {} |
| 7728 | + |
| 7729 | +}); |
| 7730 | + |
| 7731 | +/* Handles responses to an ajax request: |
| 7732 | + * - sets all responseXXX fields accordingly |
| 7733 | + * - finds the right dataType (mediates between content-type and expected dataType) |
| 7734 | + * - returns the corresponding response |
| 7735 | + */ |
| 7736 | +function ajaxHandleResponses( s, jqXHR, responses ) { |
| 7737 | + |
| 7738 | + var contents = s.contents, |
| 7739 | + dataTypes = s.dataTypes, |
| 7740 | + responseFields = s.responseFields, |
| 7741 | + ct, |
| 7742 | + type, |
| 7743 | + finalDataType, |
| 7744 | + firstDataType; |
| 7745 | + |
| 7746 | + // Fill responseXXX fields |
| 7747 | + for ( type in responseFields ) { |
| 7748 | + if ( type in responses ) { |
| 7749 | + jqXHR[ responseFields[type] ] = responses[ type ]; |
| 7750 | + } |
| 7751 | + } |
| 7752 | + |
| 7753 | + // Remove auto dataType and get content-type in the process |
| 7754 | + while( dataTypes[ 0 ] === "*" ) { |
| 7755 | + dataTypes.shift(); |
| 7756 | + if ( ct === undefined ) { |
| 7757 | + ct = s.mimeType || jqXHR.getResponseHeader( "content-type" ); |
| 7758 | + } |
| 7759 | + } |
| 7760 | + |
| 7761 | + // Check if we're dealing with a known content-type |
| 7762 | + if ( ct ) { |
| 7763 | + for ( type in contents ) { |
| 7764 | + if ( contents[ type ] && contents[ type ].test( ct ) ) { |
| 7765 | + dataTypes.unshift( type ); |
| 7766 | + break; |
| 7767 | + } |
| 7768 | + } |
| 7769 | + } |
| 7770 | + |
| 7771 | + // Check to see if we have a response for the expected dataType |
| 7772 | + if ( dataTypes[ 0 ] in responses ) { |
| 7773 | + finalDataType = dataTypes[ 0 ]; |
| 7774 | + } else { |
| 7775 | + // Try convertible dataTypes |
| 7776 | + for ( type in responses ) { |
| 7777 | + if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) { |
| 7778 | + finalDataType = type; |
| 7779 | + break; |
| 7780 | + } |
| 7781 | + if ( !firstDataType ) { |
| 7782 | + firstDataType = type; |
| 7783 | + } |
| 7784 | + } |
| 7785 | + // Or just use first one |
| 7786 | + finalDataType = finalDataType || firstDataType; |
| 7787 | + } |
| 7788 | + |
| 7789 | + // If we found a dataType |
| 7790 | + // We add the dataType to the list if needed |
| 7791 | + // and return the corresponding response |
| 7792 | + if ( finalDataType ) { |
| 7793 | + if ( finalDataType !== dataTypes[ 0 ] ) { |
| 7794 | + dataTypes.unshift( finalDataType ); |
| 7795 | + } |
| 7796 | + return responses[ finalDataType ]; |
| 7797 | + } |
| 7798 | +} |
| 7799 | + |
| 7800 | +// Chain conversions given the request and the original response |
| 7801 | +function ajaxConvert( s, response ) { |
| 7802 | + |
| 7803 | + // Apply the dataFilter if provided |
| 7804 | + if ( s.dataFilter ) { |
| 7805 | + response = s.dataFilter( response, s.dataType ); |
| 7806 | + } |
| 7807 | + |
| 7808 | + var dataTypes = s.dataTypes, |
| 7809 | + converters = {}, |
| 7810 | + i, |
| 7811 | + key, |
| 7812 | + length = dataTypes.length, |
| 7813 | + tmp, |
| 7814 | + // Current and previous dataTypes |
| 7815 | + current = dataTypes[ 0 ], |
| 7816 | + prev, |
| 7817 | + // Conversion expression |
| 7818 | + conversion, |
| 7819 | + // Conversion function |
| 7820 | + conv, |
| 7821 | + // Conversion functions (transitive conversion) |
| 7822 | + conv1, |
| 7823 | + conv2; |
| 7824 | + |
| 7825 | + // For each dataType in the chain |
| 7826 | + for ( i = 1; i < length; i++ ) { |
| 7827 | + |
| 7828 | + // Create converters map |
| 7829 | + // with lowercased keys |
| 7830 | + if ( i === 1 ) { |
| 7831 | + for ( key in s.converters ) { |
| 7832 | + if ( typeof key === "string" ) { |
| 7833 | + converters[ key.toLowerCase() ] = s.converters[ key ]; |
| 7834 | + } |
| 7835 | + } |
| 7836 | + } |
| 7837 | + |
| 7838 | + // Get the dataTypes |
| 7839 | + prev = current; |
| 7840 | + current = dataTypes[ i ]; |
| 7841 | + |
| 7842 | + // If current is auto dataType, update it to prev |
| 7843 | + if ( current === "*" ) { |
| 7844 | + current = prev; |
| 7845 | + // If no auto and dataTypes are actually different |
| 7846 | + } else if ( prev !== "*" && prev !== current ) { |
| 7847 | + |
| 7848 | + // Get the converter |
| 7849 | + conversion = prev + " " + current; |
| 7850 | + conv = converters[ conversion ] || converters[ "* " + current ]; |
| 7851 | + |
| 7852 | + // If there is no direct converter, search transitively |
| 7853 | + if ( !conv ) { |
| 7854 | + conv2 = undefined; |
| 7855 | + for ( conv1 in converters ) { |
| 7856 | + tmp = conv1.split( " " ); |
| 7857 | + if ( tmp[ 0 ] === prev || tmp[ 0 ] === "*" ) { |
| 7858 | + conv2 = converters[ tmp[1] + " " + current ]; |
| 7859 | + if ( conv2 ) { |
| 7860 | + conv1 = converters[ conv1 ]; |
| 7861 | + if ( conv1 === true ) { |
| 7862 | + conv = conv2; |
| 7863 | + } else if ( conv2 === true ) { |
| 7864 | + conv = conv1; |
| 7865 | + } |
| 7866 | + break; |
| 7867 | + } |
| 7868 | + } |
| 7869 | + } |
| 7870 | + } |
| 7871 | + // If we found no converter, dispatch an error |
| 7872 | + if ( !( conv || conv2 ) ) { |
| 7873 | + jQuery.error( "No conversion from " + conversion.replace(" "," to ") ); |
| 7874 | + } |
| 7875 | + // If found converter is not an equivalence |
| 7876 | + if ( conv !== true ) { |
| 7877 | + // Convert with 1 or 2 converters accordingly |
| 7878 | + response = conv ? conv( response ) : conv2( conv1(response) ); |
| 7879 | + } |
| 7880 | + } |
| 7881 | + } |
| 7882 | + return response; |
| 7883 | +} |
| 7884 | + |
| 7885 | + |
| 7886 | + |
| 7887 | + |
| 7888 | +var jsc = jQuery.now(), |
| 7889 | + jsre = /(\=)\?(&|$)|\?\?/i; |
| 7890 | + |
| 7891 | +// Default jsonp settings |
| 7892 | +jQuery.ajaxSetup({ |
| 7893 | + jsonp: "callback", |
| 7894 | + jsonpCallback: function() { |
| 7895 | + return jQuery.expando + "_" + ( jsc++ ); |
| 7896 | + } |
| 7897 | +}); |
| 7898 | + |
| 7899 | +// Detect, normalize options and install callbacks for jsonp requests |
| 7900 | +jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { |
| 7901 | + |
| 7902 | + var inspectData = s.contentType === "application/x-www-form-urlencoded" && |
| 7903 | + ( typeof s.data === "string" ); |
| 7904 | + |
| 7905 | + if ( s.dataTypes[ 0 ] === "jsonp" || |
| 7906 | + s.jsonp !== false && ( jsre.test( s.url ) || |
| 7907 | + inspectData && jsre.test( s.data ) ) ) { |
| 7908 | + |
| 7909 | + var responseContainer, |
| 7910 | + jsonpCallback = s.jsonpCallback = |
| 7911 | + jQuery.isFunction( s.jsonpCallback ) ? s.jsonpCallback() : s.jsonpCallback, |
| 7912 | + previous = window[ jsonpCallback ], |
| 7913 | + url = s.url, |
| 7914 | + data = s.data, |
| 7915 | + replace = "$1" + jsonpCallback + "$2"; |
| 7916 | + |
| 7917 | + if ( s.jsonp !== false ) { |
| 7918 | + url = url.replace( jsre, replace ); |
| 7919 | + if ( s.url === url ) { |
| 7920 | + if ( inspectData ) { |
| 7921 | + data = data.replace( jsre, replace ); |
| 7922 | + } |
| 7923 | + if ( s.data === data ) { |
| 7924 | + // Add callback manually |
| 7925 | + url += (/\?/.test( url ) ? "&" : "?") + s.jsonp + "=" + jsonpCallback; |
| 7926 | + } |
| 7927 | + } |
| 7928 | + } |
| 7929 | + |
| 7930 | + s.url = url; |
| 7931 | + s.data = data; |
| 7932 | + |
| 7933 | + // Install callback |
| 7934 | + window[ jsonpCallback ] = function( response ) { |
| 7935 | + responseContainer = [ response ]; |
| 7936 | + }; |
| 7937 | + |
| 7938 | + // Clean-up function |
| 7939 | + jqXHR.always(function() { |
| 7940 | + // Set callback back to previous value |
| 7941 | + window[ jsonpCallback ] = previous; |
| 7942 | + // Call if it was a function and we have a response |
| 7943 | + if ( responseContainer && jQuery.isFunction( previous ) ) { |
| 7944 | + window[ jsonpCallback ]( responseContainer[ 0 ] ); |
| 7945 | + } |
| 7946 | + }); |
| 7947 | + |
| 7948 | + // Use data converter to retrieve json after script execution |
| 7949 | + s.converters["script json"] = function() { |
| 7950 | + if ( !responseContainer ) { |
| 7951 | + jQuery.error( jsonpCallback + " was not called" ); |
| 7952 | + } |
| 7953 | + return responseContainer[ 0 ]; |
| 7954 | + }; |
| 7955 | + |
| 7956 | + // force json dataType |
| 7957 | + s.dataTypes[ 0 ] = "json"; |
| 7958 | + |
| 7959 | + // Delegate to script |
| 7960 | + return "script"; |
| 7961 | + } |
| 7962 | +}); |
| 7963 | + |
| 7964 | + |
| 7965 | + |
| 7966 | + |
| 7967 | +// Install script dataType |
| 7968 | +jQuery.ajaxSetup({ |
| 7969 | + accepts: { |
| 7970 | + script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript" |
| 7971 | + }, |
| 7972 | + contents: { |
| 7973 | + script: /javascript|ecmascript/ |
| 7974 | + }, |
| 7975 | + converters: { |
| 7976 | + "text script": function( text ) { |
| 7977 | + jQuery.globalEval( text ); |
| 7978 | + return text; |
| 7979 | + } |
| 7980 | + } |
| 7981 | +}); |
| 7982 | + |
| 7983 | +// Handle cache's special case and global |
| 7984 | +jQuery.ajaxPrefilter( "script", function( s ) { |
| 7985 | + if ( s.cache === undefined ) { |
| 7986 | + s.cache = false; |
| 7987 | + } |
| 7988 | + if ( s.crossDomain ) { |
| 7989 | + s.type = "GET"; |
| 7990 | + s.global = false; |
| 7991 | + } |
| 7992 | +}); |
| 7993 | + |
| 7994 | +// Bind script tag hack transport |
| 7995 | +jQuery.ajaxTransport( "script", function(s) { |
| 7996 | + |
| 7997 | + // This transport only deals with cross domain requests |
| 7998 | + if ( s.crossDomain ) { |
| 7999 | + |
| 8000 | + var script, |
| 8001 | + head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement; |
| 8002 | + |
| 8003 | + return { |
| 8004 | + |
| 8005 | + send: function( _, callback ) { |
| 8006 | + |
| 8007 | + script = document.createElement( "script" ); |
| 8008 | + |
| 8009 | + script.async = "async"; |
| 8010 | + |
| 8011 | + if ( s.scriptCharset ) { |
| 8012 | + script.charset = s.scriptCharset; |
| 8013 | + } |
| 8014 | + |
| 8015 | + script.src = s.url; |
| 8016 | + |
| 8017 | + // Attach handlers for all browsers |
| 8018 | + script.onload = script.onreadystatechange = function( _, isAbort ) { |
| 8019 | + |
| 8020 | + if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) { |
| 8021 | + |
| 8022 | + // Handle memory leak in IE |
| 8023 | + script.onload = script.onreadystatechange = null; |
| 8024 | + |
| 8025 | + // Remove the script |
| 8026 | + if ( head && script.parentNode ) { |
| 8027 | + head.removeChild( script ); |
| 8028 | + } |
| 8029 | + |
| 8030 | + // Dereference the script |
| 8031 | + script = undefined; |
| 8032 | + |
| 8033 | + // Callback if not abort |
| 8034 | + if ( !isAbort ) { |
| 8035 | + callback( 200, "success" ); |
| 8036 | + } |
| 8037 | + } |
| 8038 | + }; |
| 8039 | + // Use insertBefore instead of appendChild to circumvent an IE6 bug. |
| 8040 | + // This arises when a base node is used (#2709 and #4378). |
| 8041 | + head.insertBefore( script, head.firstChild ); |
| 8042 | + }, |
| 8043 | + |
| 8044 | + abort: function() { |
| 8045 | + if ( script ) { |
| 8046 | + script.onload( 0, 1 ); |
| 8047 | + } |
| 8048 | + } |
| 8049 | + }; |
| 8050 | + } |
| 8051 | +}); |
| 8052 | + |
| 8053 | + |
| 8054 | + |
| 8055 | + |
| 8056 | +var // #5280: Internet Explorer will keep connections alive if we don't abort on unload |
| 8057 | + xhrOnUnloadAbort = window.ActiveXObject ? function() { |
| 8058 | + // Abort all pending requests |
| 8059 | + for ( var key in xhrCallbacks ) { |
| 8060 | + xhrCallbacks[ key ]( 0, 1 ); |
| 8061 | + } |
| 8062 | + } : false, |
| 8063 | + xhrId = 0, |
| 8064 | + xhrCallbacks; |
| 8065 | + |
| 8066 | +// Functions to create xhrs |
| 8067 | +function createStandardXHR() { |
| 8068 | + try { |
| 8069 | + return new window.XMLHttpRequest(); |
| 8070 | + } catch( e ) {} |
| 8071 | +} |
| 8072 | + |
| 8073 | +function createActiveXHR() { |
| 8074 | + try { |
| 8075 | + return new window.ActiveXObject( "Microsoft.XMLHTTP" ); |
| 8076 | + } catch( e ) {} |
| 8077 | +} |
| 8078 | + |
| 8079 | +// Create the request object |
| 8080 | +// (This is still attached to ajaxSettings for backward compatibility) |
| 8081 | +jQuery.ajaxSettings.xhr = window.ActiveXObject ? |
| 8082 | + /* Microsoft failed to properly |
| 8083 | + * implement the XMLHttpRequest in IE7 (can't request local files), |
| 8084 | + * so we use the ActiveXObject when it is available |
| 8085 | + * Additionally XMLHttpRequest can be disabled in IE7/IE8 so |
| 8086 | + * we need a fallback. |
| 8087 | + */ |
| 8088 | + function() { |
| 8089 | + return !this.isLocal && createStandardXHR() || createActiveXHR(); |
| 8090 | + } : |
| 8091 | + // For all other browsers, use the standard XMLHttpRequest object |
| 8092 | + createStandardXHR; |
| 8093 | + |
| 8094 | +// Determine support properties |
| 8095 | +(function( xhr ) { |
| 8096 | + jQuery.extend( jQuery.support, { |
| 8097 | + ajax: !!xhr, |
| 8098 | + cors: !!xhr && ( "withCredentials" in xhr ) |
| 8099 | + }); |
| 8100 | +})( jQuery.ajaxSettings.xhr() ); |
| 8101 | + |
| 8102 | +// Create transport if the browser can provide an xhr |
| 8103 | +if ( jQuery.support.ajax ) { |
| 8104 | + |
| 8105 | + jQuery.ajaxTransport(function( s ) { |
| 8106 | + // Cross domain only allowed if supported through XMLHttpRequest |
| 8107 | + if ( !s.crossDomain || jQuery.support.cors ) { |
| 8108 | + |
| 8109 | + var callback; |
| 8110 | + |
| 8111 | + return { |
| 8112 | + send: function( headers, complete ) { |
| 8113 | + |
| 8114 | + // Get a new xhr |
| 8115 | + var xhr = s.xhr(), |
| 8116 | + handle, |
| 8117 | + i; |
| 8118 | + |
| 8119 | + // Open the socket |
| 8120 | + // Passing null username, generates a login popup on Opera (#2865) |
| 8121 | + if ( s.username ) { |
| 8122 | + xhr.open( s.type, s.url, s.async, s.username, s.password ); |
| 8123 | + } else { |
| 8124 | + xhr.open( s.type, s.url, s.async ); |
| 8125 | + } |
| 8126 | + |
| 8127 | + // Apply custom fields if provided |
| 8128 | + if ( s.xhrFields ) { |
| 8129 | + for ( i in s.xhrFields ) { |
| 8130 | + xhr[ i ] = s.xhrFields[ i ]; |
| 8131 | + } |
| 8132 | + } |
| 8133 | + |
| 8134 | + // Override mime type if needed |
| 8135 | + if ( s.mimeType && xhr.overrideMimeType ) { |
| 8136 | + xhr.overrideMimeType( s.mimeType ); |
| 8137 | + } |
| 8138 | + |
| 8139 | + // X-Requested-With header |
| 8140 | + // For cross-domain requests, seeing as conditions for a preflight are |
| 8141 | + // akin to a jigsaw puzzle, we simply never set it to be sure. |
| 8142 | + // (it can always be set on a per-request basis or even using ajaxSetup) |
| 8143 | + // For same-domain requests, won't change header if already provided. |
| 8144 | + if ( !s.crossDomain && !headers["X-Requested-With"] ) { |
| 8145 | + headers[ "X-Requested-With" ] = "XMLHttpRequest"; |
| 8146 | + } |
| 8147 | + |
| 8148 | + // Need an extra try/catch for cross domain requests in Firefox 3 |
| 8149 | + try { |
| 8150 | + for ( i in headers ) { |
| 8151 | + xhr.setRequestHeader( i, headers[ i ] ); |
| 8152 | + } |
| 8153 | + } catch( _ ) {} |
| 8154 | + |
| 8155 | + // Do send the request |
| 8156 | + // This may raise an exception which is actually |
| 8157 | + // handled in jQuery.ajax (so no try/catch here) |
| 8158 | + xhr.send( ( s.hasContent && s.data ) || null ); |
| 8159 | + |
| 8160 | + // Listener |
| 8161 | + callback = function( _, isAbort ) { |
| 8162 | + |
| 8163 | + var status, |
| 8164 | + statusText, |
| 8165 | + responseHeaders, |
| 8166 | + responses, |
| 8167 | + xml; |
| 8168 | + |
| 8169 | + // Firefox throws exceptions when accessing properties |
| 8170 | + // of an xhr when a network error occured |
| 8171 | + // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE) |
| 8172 | + try { |
| 8173 | + |
| 8174 | + // Was never called and is aborted or complete |
| 8175 | + if ( callback && ( isAbort || xhr.readyState === 4 ) ) { |
| 8176 | + |
| 8177 | + // Only called once |
| 8178 | + callback = undefined; |
| 8179 | + |
| 8180 | + // Do not keep as active anymore |
| 8181 | + if ( handle ) { |
| 8182 | + xhr.onreadystatechange = jQuery.noop; |
| 8183 | + if ( xhrOnUnloadAbort ) { |
| 8184 | + delete xhrCallbacks[ handle ]; |
| 8185 | + } |
| 8186 | + } |
| 8187 | + |
| 8188 | + // If it's an abort |
| 8189 | + if ( isAbort ) { |
| 8190 | + // Abort it manually if needed |
| 8191 | + if ( xhr.readyState !== 4 ) { |
| 8192 | + xhr.abort(); |
| 8193 | + } |
| 8194 | + } else { |
| 8195 | + status = xhr.status; |
| 8196 | + responseHeaders = xhr.getAllResponseHeaders(); |
| 8197 | + responses = {}; |
| 8198 | + xml = xhr.responseXML; |
| 8199 | + |
| 8200 | + // Construct response list |
| 8201 | + if ( xml && xml.documentElement /* #4958 */ ) { |
| 8202 | + responses.xml = xml; |
| 8203 | + } |
| 8204 | + responses.text = xhr.responseText; |
| 8205 | + |
| 8206 | + // Firefox throws an exception when accessing |
| 8207 | + // statusText for faulty cross-domain requests |
| 8208 | + try { |
| 8209 | + statusText = xhr.statusText; |
| 8210 | + } catch( e ) { |
| 8211 | + // We normalize with Webkit giving an empty statusText |
| 8212 | + statusText = ""; |
| 8213 | + } |
| 8214 | + |
| 8215 | + // Filter status for non standard behaviors |
| 8216 | + |
| 8217 | + // If the request is local and we have data: assume a success |
| 8218 | + // (success with no data won't get notified, that's the best we |
| 8219 | + // can do given current implementations) |
| 8220 | + if ( !status && s.isLocal && !s.crossDomain ) { |
| 8221 | + status = responses.text ? 200 : 404; |
| 8222 | + // IE - #1450: sometimes returns 1223 when it should be 204 |
| 8223 | + } else if ( status === 1223 ) { |
| 8224 | + status = 204; |
| 8225 | + } |
| 8226 | + } |
| 8227 | + } |
| 8228 | + } catch( firefoxAccessException ) { |
| 8229 | + if ( !isAbort ) { |
| 8230 | + complete( -1, firefoxAccessException ); |
| 8231 | + } |
| 8232 | + } |
| 8233 | + |
| 8234 | + // Call complete if needed |
| 8235 | + if ( responses ) { |
| 8236 | + complete( status, statusText, responses, responseHeaders ); |
| 8237 | + } |
| 8238 | + }; |
| 8239 | + |
| 8240 | + // if we're in sync mode or it's in cache |
| 8241 | + // and has been retrieved directly (IE6 & IE7) |
| 8242 | + // we need to manually fire the callback |
| 8243 | + if ( !s.async || xhr.readyState === 4 ) { |
| 8244 | + callback(); |
| 8245 | + } else { |
| 8246 | + handle = ++xhrId; |
| 8247 | + if ( xhrOnUnloadAbort ) { |
| 8248 | + // Create the active xhrs callbacks list if needed |
| 8249 | + // and attach the unload handler |
| 8250 | + if ( !xhrCallbacks ) { |
| 8251 | + xhrCallbacks = {}; |
| 8252 | + jQuery( window ).unload( xhrOnUnloadAbort ); |
| 8253 | + } |
| 8254 | + // Add to list of active xhrs callbacks |
| 8255 | + xhrCallbacks[ handle ] = callback; |
| 8256 | + } |
| 8257 | + xhr.onreadystatechange = callback; |
| 8258 | + } |
| 8259 | + }, |
| 8260 | + |
| 8261 | + abort: function() { |
| 8262 | + if ( callback ) { |
| 8263 | + callback(0,1); |
| 8264 | + } |
| 8265 | + } |
| 8266 | + }; |
| 8267 | + } |
| 8268 | + }); |
| 8269 | +} |
| 8270 | + |
| 8271 | + |
| 8272 | + |
| 8273 | + |
| 8274 | +var elemdisplay = {}, |
| 8275 | + iframe, iframeDoc, |
| 8276 | + rfxtypes = /^(?:toggle|show|hide)$/, |
| 8277 | + rfxnum = /^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i, |
| 8278 | + timerId, |
| 8279 | + fxAttrs = [ |
| 8280 | + // height animations |
| 8281 | + [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ], |
| 8282 | + // width animations |
| 8283 | + [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ], |
| 8284 | + // opacity animations |
| 8285 | + [ "opacity" ] |
| 8286 | + ], |
| 8287 | + fxNow; |
| 8288 | + |
| 8289 | +jQuery.fn.extend({ |
| 8290 | + show: function( speed, easing, callback ) { |
| 8291 | + var elem, display; |
| 8292 | + |
| 8293 | + if ( speed || speed === 0 ) { |
| 8294 | + return this.animate( genFx("show", 3), speed, easing, callback ); |
| 8295 | + |
| 8296 | + } else { |
| 8297 | + for ( var i = 0, j = this.length; i < j; i++ ) { |
| 8298 | + elem = this[ i ]; |
| 8299 | + |
| 8300 | + if ( elem.style ) { |
| 8301 | + display = elem.style.display; |
| 8302 | + |
| 8303 | + // Reset the inline display of this element to learn if it is |
| 8304 | + // being hidden by cascaded rules or not |
| 8305 | + if ( !jQuery._data(elem, "olddisplay") && display === "none" ) { |
| 8306 | + display = elem.style.display = ""; |
| 8307 | + } |
| 8308 | + |
| 8309 | + // Set elements which have been overridden with display: none |
| 8310 | + // in a stylesheet to whatever the default browser style is |
| 8311 | + // for such an element |
| 8312 | + if ( display === "" && jQuery.css(elem, "display") === "none" ) { |
| 8313 | + jQuery._data( elem, "olddisplay", defaultDisplay(elem.nodeName) ); |
| 8314 | + } |
| 8315 | + } |
| 8316 | + } |
| 8317 | + |
| 8318 | + // Set the display of most of the elements in a second loop |
| 8319 | + // to avoid the constant reflow |
| 8320 | + for ( i = 0; i < j; i++ ) { |
| 8321 | + elem = this[ i ]; |
| 8322 | + |
| 8323 | + if ( elem.style ) { |
| 8324 | + display = elem.style.display; |
| 8325 | + |
| 8326 | + if ( display === "" || display === "none" ) { |
| 8327 | + elem.style.display = jQuery._data( elem, "olddisplay" ) || ""; |
| 8328 | + } |
| 8329 | + } |
| 8330 | + } |
| 8331 | + |
| 8332 | + return this; |
| 8333 | + } |
| 8334 | + }, |
| 8335 | + |
| 8336 | + hide: function( speed, easing, callback ) { |
| 8337 | + if ( speed || speed === 0 ) { |
| 8338 | + return this.animate( genFx("hide", 3), speed, easing, callback); |
| 8339 | + |
| 8340 | + } else { |
| 8341 | + var elem, display, |
| 8342 | + i = 0, |
| 8343 | + j = this.length; |
| 8344 | + |
| 8345 | + for ( ; i < j; i++ ) { |
| 8346 | + elem = this[i]; |
| 8347 | + if ( elem.style ) { |
| 8348 | + display = jQuery.css( elem, "display" ); |
| 8349 | + |
| 8350 | + if ( display !== "none" && !jQuery._data( elem, "olddisplay" ) ) { |
| 8351 | + jQuery._data( elem, "olddisplay", display ); |
| 8352 | + } |
| 8353 | + } |
| 8354 | + } |
| 8355 | + |
| 8356 | + // Set the display of the elements in a second loop |
| 8357 | + // to avoid the constant reflow |
| 8358 | + for ( i = 0; i < j; i++ ) { |
| 8359 | + if ( this[i].style ) { |
| 8360 | + this[i].style.display = "none"; |
| 8361 | + } |
| 8362 | + } |
| 8363 | + |
| 8364 | + return this; |
| 8365 | + } |
| 8366 | + }, |
| 8367 | + |
| 8368 | + // Save the old toggle function |
| 8369 | + _toggle: jQuery.fn.toggle, |
| 8370 | + |
| 8371 | + toggle: function( fn, fn2, callback ) { |
| 8372 | + var bool = typeof fn === "boolean"; |
| 8373 | + |
| 8374 | + if ( jQuery.isFunction(fn) && jQuery.isFunction(fn2) ) { |
| 8375 | + this._toggle.apply( this, arguments ); |
| 8376 | + |
| 8377 | + } else if ( fn == null || bool ) { |
| 8378 | + this.each(function() { |
| 8379 | + var state = bool ? fn : jQuery(this).is(":hidden"); |
| 8380 | + jQuery(this)[ state ? "show" : "hide" ](); |
| 8381 | + }); |
| 8382 | + |
| 8383 | + } else { |
| 8384 | + this.animate(genFx("toggle", 3), fn, fn2, callback); |
| 8385 | + } |
| 8386 | + |
| 8387 | + return this; |
| 8388 | + }, |
| 8389 | + |
| 8390 | + fadeTo: function( speed, to, easing, callback ) { |
| 8391 | + return this.filter(":hidden").css("opacity", 0).show().end() |
| 8392 | + .animate({opacity: to}, speed, easing, callback); |
| 8393 | + }, |
| 8394 | + |
| 8395 | + animate: function( prop, speed, easing, callback ) { |
| 8396 | + var optall = jQuery.speed( speed, easing, callback ); |
| 8397 | + |
| 8398 | + if ( jQuery.isEmptyObject( prop ) ) { |
| 8399 | + return this.each( optall.complete, [ false ] ); |
| 8400 | + } |
| 8401 | + |
| 8402 | + // Do not change referenced properties as per-property easing will be lost |
| 8403 | + prop = jQuery.extend( {}, prop ); |
| 8404 | + |
| 8405 | + function doAnimation() { |
| 8406 | + // XXX 'this' does not always have a nodeName when running the |
| 8407 | + // test suite |
| 8408 | + |
| 8409 | + if ( optall.queue === false ) { |
| 8410 | + jQuery._mark( this ); |
| 8411 | + } |
| 8412 | + |
| 8413 | + var opt = jQuery.extend( {}, optall ), |
| 8414 | + isElement = this.nodeType === 1, |
| 8415 | + hidden = isElement && jQuery(this).is(":hidden"), |
| 8416 | + name, val, p, e, |
| 8417 | + parts, start, end, unit, |
| 8418 | + method; |
| 8419 | + |
| 8420 | + // will store per property easing and be used to determine when an animation is complete |
| 8421 | + opt.animatedProperties = {}; |
| 8422 | + |
| 8423 | + for ( p in prop ) { |
| 8424 | + |
| 8425 | + // property name normalization |
| 8426 | + name = jQuery.camelCase( p ); |
| 8427 | + if ( p !== name ) { |
| 8428 | + prop[ name ] = prop[ p ]; |
| 8429 | + delete prop[ p ]; |
| 8430 | + } |
| 8431 | + |
| 8432 | + val = prop[ name ]; |
| 8433 | + |
| 8434 | + // easing resolution: per property > opt.specialEasing > opt.easing > 'swing' (default) |
| 8435 | + if ( jQuery.isArray( val ) ) { |
| 8436 | + opt.animatedProperties[ name ] = val[ 1 ]; |
| 8437 | + val = prop[ name ] = val[ 0 ]; |
| 8438 | + } else { |
| 8439 | + opt.animatedProperties[ name ] = opt.specialEasing && opt.specialEasing[ name ] || opt.easing || 'swing'; |
| 8440 | + } |
| 8441 | + |
| 8442 | + if ( val === "hide" && hidden || val === "show" && !hidden ) { |
| 8443 | + return opt.complete.call( this ); |
| 8444 | + } |
| 8445 | + |
| 8446 | + if ( isElement && ( name === "height" || name === "width" ) ) { |
| 8447 | + // Make sure that nothing sneaks out |
| 8448 | + // Record all 3 overflow attributes because IE does not |
| 8449 | + // change the overflow attribute when overflowX and |
| 8450 | + // overflowY are set to the same value |
| 8451 | + opt.overflow = [ this.style.overflow, this.style.overflowX, this.style.overflowY ]; |
| 8452 | + |
| 8453 | + // Set display property to inline-block for height/width |
| 8454 | + // animations on inline elements that are having width/height animated |
| 8455 | + if ( jQuery.css( this, "display" ) === "inline" && |
| 8456 | + jQuery.css( this, "float" ) === "none" ) { |
| 8457 | + |
| 8458 | + // inline-level elements accept inline-block; |
| 8459 | + // block-level elements need to be inline with layout |
| 8460 | + if ( !jQuery.support.inlineBlockNeedsLayout || defaultDisplay( this.nodeName ) === "inline" ) { |
| 8461 | + this.style.display = "inline-block"; |
| 8462 | + |
| 8463 | + } else { |
| 8464 | + this.style.zoom = 1; |
| 8465 | + } |
| 8466 | + } |
| 8467 | + } |
| 8468 | + } |
| 8469 | + |
| 8470 | + if ( opt.overflow != null ) { |
| 8471 | + this.style.overflow = "hidden"; |
| 8472 | + } |
| 8473 | + |
| 8474 | + for ( p in prop ) { |
| 8475 | + e = new jQuery.fx( this, opt, p ); |
| 8476 | + val = prop[ p ]; |
| 8477 | + |
| 8478 | + if ( rfxtypes.test( val ) ) { |
| 8479 | + |
| 8480 | + // Tracks whether to show or hide based on private |
| 8481 | + // data attached to the element |
| 8482 | + method = jQuery._data( this, "toggle" + p ) || ( val === "toggle" ? hidden ? "show" : "hide" : 0 ); |
| 8483 | + if ( method ) { |
| 8484 | + jQuery._data( this, "toggle" + p, method === "show" ? "hide" : "show" ); |
| 8485 | + e[ method ](); |
| 8486 | + } else { |
| 8487 | + e[ val ](); |
| 8488 | + } |
| 8489 | + |
| 8490 | + } else { |
| 8491 | + parts = rfxnum.exec( val ); |
| 8492 | + start = e.cur(); |
| 8493 | + |
| 8494 | + if ( parts ) { |
| 8495 | + end = parseFloat( parts[2] ); |
| 8496 | + unit = parts[3] || ( jQuery.cssNumber[ p ] ? "" : "px" ); |
| 8497 | + |
| 8498 | + // We need to compute starting value |
| 8499 | + if ( unit !== "px" ) { |
| 8500 | + jQuery.style( this, p, (end || 1) + unit); |
| 8501 | + start = ( (end || 1) / e.cur() ) * start; |
| 8502 | + jQuery.style( this, p, start + unit); |
| 8503 | + } |
| 8504 | + |
| 8505 | + // If a +=/-= token was provided, we're doing a relative animation |
| 8506 | + if ( parts[1] ) { |
| 8507 | + end = ( (parts[ 1 ] === "-=" ? -1 : 1) * end ) + start; |
| 8508 | + } |
| 8509 | + |
| 8510 | + e.custom( start, end, unit ); |
| 8511 | + |
| 8512 | + } else { |
| 8513 | + e.custom( start, val, "" ); |
| 8514 | + } |
| 8515 | + } |
| 8516 | + } |
| 8517 | + |
| 8518 | + // For JS strict compliance |
| 8519 | + return true; |
| 8520 | + } |
| 8521 | + |
| 8522 | + return optall.queue === false ? |
| 8523 | + this.each( doAnimation ) : |
| 8524 | + this.queue( optall.queue, doAnimation ); |
| 8525 | + }, |
| 8526 | + |
| 8527 | + stop: function( type, clearQueue, gotoEnd ) { |
| 8528 | + if ( typeof type !== "string" ) { |
| 8529 | + gotoEnd = clearQueue; |
| 8530 | + clearQueue = type; |
| 8531 | + type = undefined; |
| 8532 | + } |
| 8533 | + if ( clearQueue && type !== false ) { |
| 8534 | + this.queue( type || "fx", [] ); |
| 8535 | + } |
| 8536 | + |
| 8537 | + return this.each(function() { |
| 8538 | + var i, |
| 8539 | + hadTimers = false, |
| 8540 | + timers = jQuery.timers, |
| 8541 | + data = jQuery._data( this ); |
| 8542 | + |
| 8543 | + // clear marker counters if we know they won't be |
| 8544 | + if ( !gotoEnd ) { |
| 8545 | + jQuery._unmark( true, this ); |
| 8546 | + } |
| 8547 | + |
| 8548 | + function stopQueue( elem, data, i ) { |
| 8549 | + var hooks = data[ i ]; |
| 8550 | + jQuery.removeData( elem, i, true ); |
| 8551 | + hooks.stop( gotoEnd ); |
| 8552 | + } |
| 8553 | + |
| 8554 | + if ( type == null ) { |
| 8555 | + for ( i in data ) { |
| 8556 | + if ( data[ i ].stop && i.indexOf(".run") === i.length - 4 ) { |
| 8557 | + stopQueue( this, data, i ); |
| 8558 | + } |
| 8559 | + } |
| 8560 | + } else if ( data[ i = type + ".run" ] && data[ i ].stop ){ |
| 8561 | + stopQueue( this, data, i ); |
| 8562 | + } |
| 8563 | + |
| 8564 | + for ( i = timers.length; i--; ) { |
| 8565 | + if ( timers[ i ].elem === this && (type == null || timers[ i ].queue === type) ) { |
| 8566 | + if ( gotoEnd ) { |
| 8567 | + |
| 8568 | + // force the next step to be the last |
| 8569 | + timers[ i ]( true ); |
| 8570 | + } else { |
| 8571 | + timers[ i ].saveState(); |
| 8572 | + } |
| 8573 | + hadTimers = true; |
| 8574 | + timers.splice( i, 1 ); |
| 8575 | + } |
| 8576 | + } |
| 8577 | + |
| 8578 | + // start the next in the queue if the last step wasn't forced |
| 8579 | + // timers currently will call their complete callbacks, which will dequeue |
| 8580 | + // but only if they were gotoEnd |
| 8581 | + if ( !( gotoEnd && hadTimers ) ) { |
| 8582 | + jQuery.dequeue( this, type ); |
| 8583 | + } |
| 8584 | + }); |
| 8585 | + } |
| 8586 | + |
| 8587 | +}); |
| 8588 | + |
| 8589 | +// Animations created synchronously will run synchronously |
| 8590 | +function createFxNow() { |
| 8591 | + setTimeout( clearFxNow, 0 ); |
| 8592 | + return ( fxNow = jQuery.now() ); |
| 8593 | +} |
| 8594 | + |
| 8595 | +function clearFxNow() { |
| 8596 | + fxNow = undefined; |
| 8597 | +} |
| 8598 | + |
| 8599 | +// Generate parameters to create a standard animation |
| 8600 | +function genFx( type, num ) { |
| 8601 | + var obj = {}; |
| 8602 | + |
| 8603 | + jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice( 0, num )), function() { |
| 8604 | + obj[ this ] = type; |
| 8605 | + }); |
| 8606 | + |
| 8607 | + return obj; |
| 8608 | +} |
| 8609 | + |
| 8610 | +// Generate shortcuts for custom animations |
| 8611 | +jQuery.each({ |
| 8612 | + slideDown: genFx( "show", 1 ), |
| 8613 | + slideUp: genFx( "hide", 1 ), |
| 8614 | + slideToggle: genFx( "toggle", 1 ), |
| 8615 | + fadeIn: { opacity: "show" }, |
| 8616 | + fadeOut: { opacity: "hide" }, |
| 8617 | + fadeToggle: { opacity: "toggle" } |
| 8618 | +}, function( name, props ) { |
| 8619 | + jQuery.fn[ name ] = function( speed, easing, callback ) { |
| 8620 | + return this.animate( props, speed, easing, callback ); |
| 8621 | + }; |
| 8622 | +}); |
| 8623 | + |
| 8624 | +jQuery.extend({ |
| 8625 | + speed: function( speed, easing, fn ) { |
| 8626 | + var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : { |
| 8627 | + complete: fn || !fn && easing || |
| 8628 | + jQuery.isFunction( speed ) && speed, |
| 8629 | + duration: speed, |
| 8630 | + easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing |
| 8631 | + }; |
| 8632 | + |
| 8633 | + opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration : |
| 8634 | + opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default; |
| 8635 | + |
| 8636 | + // normalize opt.queue - true/undefined/null -> "fx" |
| 8637 | + if ( opt.queue == null || opt.queue === true ) { |
| 8638 | + opt.queue = "fx"; |
| 8639 | + } |
| 8640 | + |
| 8641 | + // Queueing |
| 8642 | + opt.old = opt.complete; |
| 8643 | + |
| 8644 | + opt.complete = function( noUnmark ) { |
| 8645 | + if ( jQuery.isFunction( opt.old ) ) { |
| 8646 | + opt.old.call( this ); |
| 8647 | + } |
| 8648 | + |
| 8649 | + if ( opt.queue ) { |
| 8650 | + jQuery.dequeue( this, opt.queue ); |
| 8651 | + } else if ( noUnmark !== false ) { |
| 8652 | + jQuery._unmark( this ); |
| 8653 | + } |
| 8654 | + }; |
| 8655 | + |
| 8656 | + return opt; |
| 8657 | + }, |
| 8658 | + |
| 8659 | + easing: { |
| 8660 | + linear: function( p, n, firstNum, diff ) { |
| 8661 | + return firstNum + diff * p; |
| 8662 | + }, |
| 8663 | + swing: function( p, n, firstNum, diff ) { |
| 8664 | + return ( ( -Math.cos( p*Math.PI ) / 2 ) + 0.5 ) * diff + firstNum; |
| 8665 | + } |
| 8666 | + }, |
| 8667 | + |
| 8668 | + timers: [], |
| 8669 | + |
| 8670 | + fx: function( elem, options, prop ) { |
| 8671 | + this.options = options; |
| 8672 | + this.elem = elem; |
| 8673 | + this.prop = prop; |
| 8674 | + |
| 8675 | + options.orig = options.orig || {}; |
| 8676 | + } |
| 8677 | + |
| 8678 | +}); |
| 8679 | + |
| 8680 | +jQuery.fx.prototype = { |
| 8681 | + // Simple function for setting a style value |
| 8682 | + update: function() { |
| 8683 | + if ( this.options.step ) { |
| 8684 | + this.options.step.call( this.elem, this.now, this ); |
| 8685 | + } |
| 8686 | + |
| 8687 | + ( jQuery.fx.step[ this.prop ] || jQuery.fx.step._default )( this ); |
| 8688 | + }, |
| 8689 | + |
| 8690 | + // Get the current size |
| 8691 | + cur: function() { |
| 8692 | + if ( this.elem[ this.prop ] != null && (!this.elem.style || this.elem.style[ this.prop ] == null) ) { |
| 8693 | + return this.elem[ this.prop ]; |
| 8694 | + } |
| 8695 | + |
| 8696 | + var parsed, |
| 8697 | + r = jQuery.css( this.elem, this.prop ); |
| 8698 | + // Empty strings, null, undefined and "auto" are converted to 0, |
| 8699 | + // complex values such as "rotate(1rad)" are returned as is, |
| 8700 | + // simple values such as "10px" are parsed to Float. |
| 8701 | + return isNaN( parsed = parseFloat( r ) ) ? !r || r === "auto" ? 0 : r : parsed; |
| 8702 | + }, |
| 8703 | + |
| 8704 | + // Start an animation from one number to another |
| 8705 | + custom: function( from, to, unit ) { |
| 8706 | + var self = this, |
| 8707 | + fx = jQuery.fx; |
| 8708 | + |
| 8709 | + this.startTime = fxNow || createFxNow(); |
| 8710 | + this.end = to; |
| 8711 | + this.now = this.start = from; |
| 8712 | + this.pos = this.state = 0; |
| 8713 | + this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" ); |
| 8714 | + |
| 8715 | + function t( gotoEnd ) { |
| 8716 | + return self.step( gotoEnd ); |
| 8717 | + } |
| 8718 | + |
| 8719 | + t.queue = this.options.queue; |
| 8720 | + t.elem = this.elem; |
| 8721 | + t.saveState = function() { |
| 8722 | + if ( self.options.hide && jQuery._data( self.elem, "fxshow" + self.prop ) === undefined ) { |
| 8723 | + jQuery._data( self.elem, "fxshow" + self.prop, self.start ); |
| 8724 | + } |
| 8725 | + }; |
| 8726 | + |
| 8727 | + if ( t() && jQuery.timers.push(t) && !timerId ) { |
| 8728 | + timerId = setInterval( fx.tick, fx.interval ); |
| 8729 | + } |
| 8730 | + }, |
| 8731 | + |
| 8732 | + // Simple 'show' function |
| 8733 | + show: function() { |
| 8734 | + var dataShow = jQuery._data( this.elem, "fxshow" + this.prop ); |
| 8735 | + |
| 8736 | + // Remember where we started, so that we can go back to it later |
| 8737 | + this.options.orig[ this.prop ] = dataShow || jQuery.style( this.elem, this.prop ); |
| 8738 | + this.options.show = true; |
| 8739 | + |
| 8740 | + // Begin the animation |
| 8741 | + // Make sure that we start at a small width/height to avoid any flash of content |
| 8742 | + if ( dataShow !== undefined ) { |
| 8743 | + // This show is picking up where a previous hide or show left off |
| 8744 | + this.custom( this.cur(), dataShow ); |
| 8745 | + } else { |
| 8746 | + this.custom( this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur() ); |
| 8747 | + } |
| 8748 | + |
| 8749 | + // Start by showing the element |
| 8750 | + jQuery( this.elem ).show(); |
| 8751 | + }, |
| 8752 | + |
| 8753 | + // Simple 'hide' function |
| 8754 | + hide: function() { |
| 8755 | + // Remember where we started, so that we can go back to it later |
| 8756 | + this.options.orig[ this.prop ] = jQuery._data( this.elem, "fxshow" + this.prop ) || jQuery.style( this.elem, this.prop ); |
| 8757 | + this.options.hide = true; |
| 8758 | + |
| 8759 | + // Begin the animation |
| 8760 | + this.custom( this.cur(), 0 ); |
| 8761 | + }, |
| 8762 | + |
| 8763 | + // Each step of an animation |
| 8764 | + step: function( gotoEnd ) { |
| 8765 | + var p, n, complete, |
| 8766 | + t = fxNow || createFxNow(), |
| 8767 | + done = true, |
| 8768 | + elem = this.elem, |
| 8769 | + options = this.options; |
| 8770 | + |
| 8771 | + if ( gotoEnd || t >= options.duration + this.startTime ) { |
| 8772 | + this.now = this.end; |
| 8773 | + this.pos = this.state = 1; |
| 8774 | + this.update(); |
| 8775 | + |
| 8776 | + options.animatedProperties[ this.prop ] = true; |
| 8777 | + |
| 8778 | + for ( p in options.animatedProperties ) { |
| 8779 | + if ( options.animatedProperties[ p ] !== true ) { |
| 8780 | + done = false; |
| 8781 | + } |
| 8782 | + } |
| 8783 | + |
| 8784 | + if ( done ) { |
| 8785 | + // Reset the overflow |
| 8786 | + if ( options.overflow != null && !jQuery.support.shrinkWrapBlocks ) { |
| 8787 | + |
| 8788 | + jQuery.each( [ "", "X", "Y" ], function( index, value ) { |
| 8789 | + elem.style[ "overflow" + value ] = options.overflow[ index ]; |
| 8790 | + }); |
| 8791 | + } |
| 8792 | + |
| 8793 | + // Hide the element if the "hide" operation was done |
| 8794 | + if ( options.hide ) { |
| 8795 | + jQuery( elem ).hide(); |
| 8796 | + } |
| 8797 | + |
| 8798 | + // Reset the properties, if the item has been hidden or shown |
| 8799 | + if ( options.hide || options.show ) { |
| 8800 | + for ( p in options.animatedProperties ) { |
| 8801 | + jQuery.style( elem, p, options.orig[ p ] ); |
| 8802 | + jQuery.removeData( elem, "fxshow" + p, true ); |
| 8803 | + // Toggle data is no longer needed |
| 8804 | + jQuery.removeData( elem, "toggle" + p, true ); |
| 8805 | + } |
| 8806 | + } |
| 8807 | + |
| 8808 | + // Execute the complete function |
| 8809 | + // in the event that the complete function throws an exception |
| 8810 | + // we must ensure it won't be called twice. #5684 |
| 8811 | + |
| 8812 | + complete = options.complete; |
| 8813 | + if ( complete ) { |
| 8814 | + |
| 8815 | + options.complete = false; |
| 8816 | + complete.call( elem ); |
| 8817 | + } |
| 8818 | + } |
| 8819 | + |
| 8820 | + return false; |
| 8821 | + |
| 8822 | + } else { |
| 8823 | + // classical easing cannot be used with an Infinity duration |
| 8824 | + if ( options.duration == Infinity ) { |
| 8825 | + this.now = t; |
| 8826 | + } else { |
| 8827 | + n = t - this.startTime; |
| 8828 | + this.state = n / options.duration; |
| 8829 | + |
| 8830 | + // Perform the easing function, defaults to swing |
| 8831 | + this.pos = jQuery.easing[ options.animatedProperties[this.prop] ]( this.state, n, 0, 1, options.duration ); |
| 8832 | + this.now = this.start + ( (this.end - this.start) * this.pos ); |
| 8833 | + } |
| 8834 | + // Perform the next step of the animation |
| 8835 | + this.update(); |
| 8836 | + } |
| 8837 | + |
| 8838 | + return true; |
| 8839 | + } |
| 8840 | +}; |
| 8841 | + |
| 8842 | +jQuery.extend( jQuery.fx, { |
| 8843 | + tick: function() { |
| 8844 | + var timer, |
| 8845 | + timers = jQuery.timers, |
| 8846 | + i = 0; |
| 8847 | + |
| 8848 | + for ( ; i < timers.length; i++ ) { |
| 8849 | + timer = timers[ i ]; |
| 8850 | + // Checks the timer has not already been removed |
| 8851 | + if ( !timer() && timers[ i ] === timer ) { |
| 8852 | + timers.splice( i--, 1 ); |
| 8853 | + } |
| 8854 | + } |
| 8855 | + |
| 8856 | + if ( !timers.length ) { |
| 8857 | + jQuery.fx.stop(); |
| 8858 | + } |
| 8859 | + }, |
| 8860 | + |
| 8861 | + interval: 13, |
| 8862 | + |
| 8863 | + stop: function() { |
| 8864 | + clearInterval( timerId ); |
| 8865 | + timerId = null; |
| 8866 | + }, |
| 8867 | + |
| 8868 | + speeds: { |
| 8869 | + slow: 600, |
| 8870 | + fast: 200, |
| 8871 | + // Default speed |
| 8872 | + _default: 400 |
| 8873 | + }, |
| 8874 | + |
| 8875 | + step: { |
| 8876 | + opacity: function( fx ) { |
| 8877 | + jQuery.style( fx.elem, "opacity", fx.now ); |
| 8878 | + }, |
| 8879 | + |
| 8880 | + _default: function( fx ) { |
| 8881 | + if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) { |
| 8882 | + fx.elem.style[ fx.prop ] = fx.now + fx.unit; |
| 8883 | + } else { |
| 8884 | + fx.elem[ fx.prop ] = fx.now; |
| 8885 | + } |
| 8886 | + } |
| 8887 | + } |
| 8888 | +}); |
| 8889 | + |
| 8890 | +// Adds width/height step functions |
| 8891 | +// Do not set anything below 0 |
| 8892 | +jQuery.each([ "width", "height" ], function( i, prop ) { |
| 8893 | + jQuery.fx.step[ prop ] = function( fx ) { |
| 8894 | + jQuery.style( fx.elem, prop, Math.max(0, fx.now) ); |
| 8895 | + }; |
| 8896 | +}); |
| 8897 | + |
| 8898 | +if ( jQuery.expr && jQuery.expr.filters ) { |
| 8899 | + jQuery.expr.filters.animated = function( elem ) { |
| 8900 | + return jQuery.grep(jQuery.timers, function( fn ) { |
| 8901 | + return elem === fn.elem; |
| 8902 | + }).length; |
| 8903 | + }; |
| 8904 | +} |
| 8905 | + |
| 8906 | +// Try to restore the default display value of an element |
| 8907 | +function defaultDisplay( nodeName ) { |
| 8908 | + |
| 8909 | + if ( !elemdisplay[ nodeName ] ) { |
| 8910 | + |
| 8911 | + var body = document.body, |
| 8912 | + elem = jQuery( "<" + nodeName + ">" ).appendTo( body ), |
| 8913 | + display = elem.css( "display" ); |
| 8914 | + elem.remove(); |
| 8915 | + |
| 8916 | + // If the simple way fails, |
| 8917 | + // get element's real default display by attaching it to a temp iframe |
| 8918 | + if ( display === "none" || display === "" ) { |
| 8919 | + // No iframe to use yet, so create it |
| 8920 | + if ( !iframe ) { |
| 8921 | + iframe = document.createElement( "iframe" ); |
| 8922 | + iframe.frameBorder = iframe.width = iframe.height = 0; |
| 8923 | + } |
| 8924 | + |
| 8925 | + body.appendChild( iframe ); |
| 8926 | + |
| 8927 | + // Create a cacheable copy of the iframe document on first call. |
| 8928 | + // IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML |
| 8929 | + // document to it; WebKit & Firefox won't allow reusing the iframe document. |
| 8930 | + if ( !iframeDoc || !iframe.createElement ) { |
| 8931 | + iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document; |
| 8932 | + iframeDoc.write( ( document.compatMode === "CSS1Compat" ? "<!doctype html>" : "" ) + "<html><body>" ); |
| 8933 | + iframeDoc.close(); |
| 8934 | + } |
| 8935 | + |
| 8936 | + elem = iframeDoc.createElement( nodeName ); |
| 8937 | + |
| 8938 | + iframeDoc.body.appendChild( elem ); |
| 8939 | + |
| 8940 | + display = jQuery.css( elem, "display" ); |
| 8941 | + body.removeChild( iframe ); |
| 8942 | + } |
| 8943 | + |
| 8944 | + // Store the correct default display |
| 8945 | + elemdisplay[ nodeName ] = display; |
| 8946 | + } |
| 8947 | + |
| 8948 | + return elemdisplay[ nodeName ]; |
| 8949 | +} |
| 8950 | + |
| 8951 | + |
| 8952 | + |
| 8953 | + |
| 8954 | +var rtable = /^t(?:able|d|h)$/i, |
| 8955 | + rroot = /^(?:body|html)$/i; |
| 8956 | + |
| 8957 | +if ( "getBoundingClientRect" in document.documentElement ) { |
| 8958 | + jQuery.fn.offset = function( options ) { |
| 8959 | + var elem = this[0], box; |
| 8960 | + |
| 8961 | + if ( options ) { |
| 8962 | + return this.each(function( i ) { |
| 8963 | + jQuery.offset.setOffset( this, options, i ); |
| 8964 | + }); |
| 8965 | + } |
| 8966 | + |
| 8967 | + if ( !elem || !elem.ownerDocument ) { |
| 8968 | + return null; |
| 8969 | + } |
| 8970 | + |
| 8971 | + if ( elem === elem.ownerDocument.body ) { |
| 8972 | + return jQuery.offset.bodyOffset( elem ); |
| 8973 | + } |
| 8974 | + |
| 8975 | + try { |
| 8976 | + box = elem.getBoundingClientRect(); |
| 8977 | + } catch(e) {} |
| 8978 | + |
| 8979 | + var doc = elem.ownerDocument, |
| 8980 | + docElem = doc.documentElement; |
| 8981 | + |
| 8982 | + // Make sure we're not dealing with a disconnected DOM node |
| 8983 | + if ( !box || !jQuery.contains( docElem, elem ) ) { |
| 8984 | + return box ? { top: box.top, left: box.left } : { top: 0, left: 0 }; |
| 8985 | + } |
| 8986 | + |
| 8987 | + var body = doc.body, |
| 8988 | + win = getWindow(doc), |
| 8989 | + clientTop = docElem.clientTop || body.clientTop || 0, |
| 8990 | + clientLeft = docElem.clientLeft || body.clientLeft || 0, |
| 8991 | + scrollTop = win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop, |
| 8992 | + scrollLeft = win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft, |
| 8993 | + top = box.top + scrollTop - clientTop, |
| 8994 | + left = box.left + scrollLeft - clientLeft; |
| 8995 | + |
| 8996 | + return { top: top, left: left }; |
| 8997 | + }; |
| 8998 | + |
| 8999 | +} else { |
| 9000 | + jQuery.fn.offset = function( options ) { |
| 9001 | + var elem = this[0]; |
| 9002 | + |
| 9003 | + if ( options ) { |
| 9004 | + return this.each(function( i ) { |
| 9005 | + jQuery.offset.setOffset( this, options, i ); |
| 9006 | + }); |
| 9007 | + } |
| 9008 | + |
| 9009 | + if ( !elem || !elem.ownerDocument ) { |
| 9010 | + return null; |
| 9011 | + } |
| 9012 | + |
| 9013 | + if ( elem === elem.ownerDocument.body ) { |
| 9014 | + return jQuery.offset.bodyOffset( elem ); |
| 9015 | + } |
| 9016 | + |
| 9017 | + var computedStyle, |
| 9018 | + offsetParent = elem.offsetParent, |
| 9019 | + prevOffsetParent = elem, |
| 9020 | + doc = elem.ownerDocument, |
| 9021 | + docElem = doc.documentElement, |
| 9022 | + body = doc.body, |
| 9023 | + defaultView = doc.defaultView, |
| 9024 | + prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle, |
| 9025 | + top = elem.offsetTop, |
| 9026 | + left = elem.offsetLeft; |
| 9027 | + |
| 9028 | + while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) { |
| 9029 | + if ( jQuery.support.fixedPosition && prevComputedStyle.position === "fixed" ) { |
| 9030 | + break; |
| 9031 | + } |
| 9032 | + |
| 9033 | + computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle; |
| 9034 | + top -= elem.scrollTop; |
| 9035 | + left -= elem.scrollLeft; |
| 9036 | + |
| 9037 | + if ( elem === offsetParent ) { |
| 9038 | + top += elem.offsetTop; |
| 9039 | + left += elem.offsetLeft; |
| 9040 | + |
| 9041 | + if ( jQuery.support.doesNotAddBorder && !(jQuery.support.doesAddBorderForTableAndCells && rtable.test(elem.nodeName)) ) { |
| 9042 | + top += parseFloat( computedStyle.borderTopWidth ) || 0; |
| 9043 | + left += parseFloat( computedStyle.borderLeftWidth ) || 0; |
| 9044 | + } |
| 9045 | + |
| 9046 | + prevOffsetParent = offsetParent; |
| 9047 | + offsetParent = elem.offsetParent; |
| 9048 | + } |
| 9049 | + |
| 9050 | + if ( jQuery.support.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) { |
| 9051 | + top += parseFloat( computedStyle.borderTopWidth ) || 0; |
| 9052 | + left += parseFloat( computedStyle.borderLeftWidth ) || 0; |
| 9053 | + } |
| 9054 | + |
| 9055 | + prevComputedStyle = computedStyle; |
| 9056 | + } |
| 9057 | + |
| 9058 | + if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) { |
| 9059 | + top += body.offsetTop; |
| 9060 | + left += body.offsetLeft; |
| 9061 | + } |
| 9062 | + |
| 9063 | + if ( jQuery.support.fixedPosition && prevComputedStyle.position === "fixed" ) { |
| 9064 | + top += Math.max( docElem.scrollTop, body.scrollTop ); |
| 9065 | + left += Math.max( docElem.scrollLeft, body.scrollLeft ); |
| 9066 | + } |
| 9067 | + |
| 9068 | + return { top: top, left: left }; |
| 9069 | + }; |
| 9070 | +} |
| 9071 | + |
| 9072 | +jQuery.offset = { |
| 9073 | + |
| 9074 | + bodyOffset: function( body ) { |
| 9075 | + var top = body.offsetTop, |
| 9076 | + left = body.offsetLeft; |
| 9077 | + |
| 9078 | + if ( jQuery.support.doesNotIncludeMarginInBodyOffset ) { |
| 9079 | + top += parseFloat( jQuery.css(body, "marginTop") ) || 0; |
| 9080 | + left += parseFloat( jQuery.css(body, "marginLeft") ) || 0; |
| 9081 | + } |
| 9082 | + |
| 9083 | + return { top: top, left: left }; |
| 9084 | + }, |
| 9085 | + |
| 9086 | + setOffset: function( elem, options, i ) { |
| 9087 | + var position = jQuery.css( elem, "position" ); |
| 9088 | + |
| 9089 | + // set position first, in-case top/left are set even on static elem |
| 9090 | + if ( position === "static" ) { |
| 9091 | + elem.style.position = "relative"; |
| 9092 | + } |
| 9093 | + |
| 9094 | + var curElem = jQuery( elem ), |
| 9095 | + curOffset = curElem.offset(), |
| 9096 | + curCSSTop = jQuery.css( elem, "top" ), |
| 9097 | + curCSSLeft = jQuery.css( elem, "left" ), |
| 9098 | + calculatePosition = ( position === "absolute" || position === "fixed" ) && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1, |
| 9099 | + props = {}, curPosition = {}, curTop, curLeft; |
| 9100 | + |
| 9101 | + // need to be able to calculate position if either top or left is auto and position is either absolute or fixed |
| 9102 | + if ( calculatePosition ) { |
| 9103 | + curPosition = curElem.position(); |
| 9104 | + curTop = curPosition.top; |
| 9105 | + curLeft = curPosition.left; |
| 9106 | + } else { |
| 9107 | + curTop = parseFloat( curCSSTop ) || 0; |
| 9108 | + curLeft = parseFloat( curCSSLeft ) || 0; |
| 9109 | + } |
| 9110 | + |
| 9111 | + if ( jQuery.isFunction( options ) ) { |
| 9112 | + options = options.call( elem, i, curOffset ); |
| 9113 | + } |
| 9114 | + |
| 9115 | + if ( options.top != null ) { |
| 9116 | + props.top = ( options.top - curOffset.top ) + curTop; |
| 9117 | + } |
| 9118 | + if ( options.left != null ) { |
| 9119 | + props.left = ( options.left - curOffset.left ) + curLeft; |
| 9120 | + } |
| 9121 | + |
| 9122 | + if ( "using" in options ) { |
| 9123 | + options.using.call( elem, props ); |
| 9124 | + } else { |
| 9125 | + curElem.css( props ); |
| 9126 | + } |
| 9127 | + } |
| 9128 | +}; |
| 9129 | + |
| 9130 | + |
| 9131 | +jQuery.fn.extend({ |
| 9132 | + |
| 9133 | + position: function() { |
| 9134 | + if ( !this[0] ) { |
| 9135 | + return null; |
| 9136 | + } |
| 9137 | + |
| 9138 | + var elem = this[0], |
| 9139 | + |
| 9140 | + // Get *real* offsetParent |
| 9141 | + offsetParent = this.offsetParent(), |
| 9142 | + |
| 9143 | + // Get correct offsets |
| 9144 | + offset = this.offset(), |
| 9145 | + parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset(); |
| 9146 | + |
| 9147 | + // Subtract element margins |
| 9148 | + // note: when an element has margin: auto the offsetLeft and marginLeft |
| 9149 | + // are the same in Safari causing offset.left to incorrectly be 0 |
| 9150 | + offset.top -= parseFloat( jQuery.css(elem, "marginTop") ) || 0; |
| 9151 | + offset.left -= parseFloat( jQuery.css(elem, "marginLeft") ) || 0; |
| 9152 | + |
| 9153 | + // Add offsetParent borders |
| 9154 | + parentOffset.top += parseFloat( jQuery.css(offsetParent[0], "borderTopWidth") ) || 0; |
| 9155 | + parentOffset.left += parseFloat( jQuery.css(offsetParent[0], "borderLeftWidth") ) || 0; |
| 9156 | + |
| 9157 | + // Subtract the two offsets |
| 9158 | + return { |
| 9159 | + top: offset.top - parentOffset.top, |
| 9160 | + left: offset.left - parentOffset.left |
| 9161 | + }; |
| 9162 | + }, |
| 9163 | + |
| 9164 | + offsetParent: function() { |
| 9165 | + return this.map(function() { |
| 9166 | + var offsetParent = this.offsetParent || document.body; |
| 9167 | + while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) { |
| 9168 | + offsetParent = offsetParent.offsetParent; |
| 9169 | + } |
| 9170 | + return offsetParent; |
| 9171 | + }); |
| 9172 | + } |
| 9173 | +}); |
| 9174 | + |
| 9175 | + |
| 9176 | +// Create scrollLeft and scrollTop methods |
| 9177 | +jQuery.each( ["Left", "Top"], function( i, name ) { |
| 9178 | + var method = "scroll" + name; |
| 9179 | + |
| 9180 | + jQuery.fn[ method ] = function( val ) { |
| 9181 | + var elem, win; |
| 9182 | + |
| 9183 | + if ( val === undefined ) { |
| 9184 | + elem = this[ 0 ]; |
| 9185 | + |
| 9186 | + if ( !elem ) { |
| 9187 | + return null; |
| 9188 | + } |
| 9189 | + |
| 9190 | + win = getWindow( elem ); |
| 9191 | + |
| 9192 | + // Return the scroll offset |
| 9193 | + return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] : |
| 9194 | + jQuery.support.boxModel && win.document.documentElement[ method ] || |
| 9195 | + win.document.body[ method ] : |
| 9196 | + elem[ method ]; |
| 9197 | + } |
| 9198 | + |
| 9199 | + // Set the scroll offset |
| 9200 | + return this.each(function() { |
| 9201 | + win = getWindow( this ); |
| 9202 | + |
| 9203 | + if ( win ) { |
| 9204 | + win.scrollTo( |
| 9205 | + !i ? val : jQuery( win ).scrollLeft(), |
| 9206 | + i ? val : jQuery( win ).scrollTop() |
| 9207 | + ); |
| 9208 | + |
| 9209 | + } else { |
| 9210 | + this[ method ] = val; |
| 9211 | + } |
| 9212 | + }); |
| 9213 | + }; |
| 9214 | +}); |
| 9215 | + |
| 9216 | +function getWindow( elem ) { |
| 9217 | + return jQuery.isWindow( elem ) ? |
| 9218 | + elem : |
| 9219 | + elem.nodeType === 9 ? |
| 9220 | + elem.defaultView || elem.parentWindow : |
| 9221 | + false; |
| 9222 | +} |
| 9223 | + |
| 9224 | + |
| 9225 | + |
| 9226 | + |
| 9227 | +// Create width, height, innerHeight, innerWidth, outerHeight and outerWidth methods |
| 9228 | +jQuery.each([ "Height", "Width" ], function( i, name ) { |
| 9229 | + |
| 9230 | + var type = name.toLowerCase(); |
| 9231 | + |
| 9232 | + // innerHeight and innerWidth |
| 9233 | + jQuery.fn[ "inner" + name ] = function() { |
| 9234 | + var elem = this[0]; |
| 9235 | + return elem ? |
| 9236 | + elem.style ? |
| 9237 | + parseFloat( jQuery.css( elem, type, "padding" ) ) : |
| 9238 | + this[ type ]() : |
| 9239 | + null; |
| 9240 | + }; |
| 9241 | + |
| 9242 | + // outerHeight and outerWidth |
| 9243 | + jQuery.fn[ "outer" + name ] = function( margin ) { |
| 9244 | + var elem = this[0]; |
| 9245 | + return elem ? |
| 9246 | + elem.style ? |
| 9247 | + parseFloat( jQuery.css( elem, type, margin ? "margin" : "border" ) ) : |
| 9248 | + this[ type ]() : |
| 9249 | + null; |
| 9250 | + }; |
| 9251 | + |
| 9252 | + jQuery.fn[ type ] = function( size ) { |
| 9253 | + // Get window width or height |
| 9254 | + var elem = this[0]; |
| 9255 | + if ( !elem ) { |
| 9256 | + return size == null ? null : this; |
| 9257 | + } |
| 9258 | + |
| 9259 | + if ( jQuery.isFunction( size ) ) { |
| 9260 | + return this.each(function( i ) { |
| 9261 | + var self = jQuery( this ); |
| 9262 | + self[ type ]( size.call( this, i, self[ type ]() ) ); |
| 9263 | + }); |
| 9264 | + } |
| 9265 | + |
| 9266 | + if ( jQuery.isWindow( elem ) ) { |
| 9267 | + // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode |
| 9268 | + // 3rd condition allows Nokia support, as it supports the docElem prop but not CSS1Compat |
| 9269 | + var docElemProp = elem.document.documentElement[ "client" + name ], |
| 9270 | + body = elem.document.body; |
| 9271 | + return elem.document.compatMode === "CSS1Compat" && docElemProp || |
| 9272 | + body && body[ "client" + name ] || docElemProp; |
| 9273 | + |
| 9274 | + // Get document width or height |
| 9275 | + } else if ( elem.nodeType === 9 ) { |
| 9276 | + // Either scroll[Width/Height] or offset[Width/Height], whichever is greater |
| 9277 | + return Math.max( |
| 9278 | + elem.documentElement["client" + name], |
| 9279 | + elem.body["scroll" + name], elem.documentElement["scroll" + name], |
| 9280 | + elem.body["offset" + name], elem.documentElement["offset" + name] |
| 9281 | + ); |
| 9282 | + |
| 9283 | + // Get or set width or height on the element |
| 9284 | + } else if ( size === undefined ) { |
| 9285 | + var orig = jQuery.css( elem, type ), |
| 9286 | + ret = parseFloat( orig ); |
| 9287 | + |
| 9288 | + return jQuery.isNumeric( ret ) ? ret : orig; |
| 9289 | + |
| 9290 | + // Set the width or height on the element (default to pixels if value is unitless) |
| 9291 | + } else { |
| 9292 | + return this.css( type, typeof size === "string" ? size : size + "px" ); |
| 9293 | + } |
| 9294 | + }; |
| 9295 | + |
| 9296 | +}); |
| 9297 | + |
| 9298 | + |
| 9299 | +// Expose jQuery to the global object |
| 9300 | +window.jQuery = window.$ = jQuery; |
| 9301 | +})( window ); |
Property changes on: trunk/extensions/VisualEditor/modules/jquery.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 9302 | + native |
Added: svn:mime-type |
2 | 9303 | + text/plain |