FossilRepo

fossilrepo / assets / admin / js / vendor / jquery / jquery.js
Source Blame History 10716 lines
afe42d0… ragelink 1 /*!
afe42d0… ragelink 2 * jQuery JavaScript Library v3.7.1
afe42d0… ragelink 3 * https://jquery.com/
afe42d0… ragelink 4 *
afe42d0… ragelink 5 * Copyright OpenJS Foundation and other contributors
afe42d0… ragelink 6 * Released under the MIT license
afe42d0… ragelink 7 * https://jquery.org/license
afe42d0… ragelink 8 *
afe42d0… ragelink 9 * Date: 2023-08-28T13:37Z
afe42d0… ragelink 10 */
afe42d0… ragelink 11 ( function( global, factory ) {
afe42d0… ragelink 12
afe42d0… ragelink 13 "use strict";
afe42d0… ragelink 14
afe42d0… ragelink 15 if ( typeof module === "object" && typeof module.exports === "object" ) {
afe42d0… ragelink 16
afe42d0… ragelink 17 // For CommonJS and CommonJS-like environments where a proper `window`
afe42d0… ragelink 18 // is present, execute the factory and get jQuery.
afe42d0… ragelink 19 // For environments that do not have a `window` with a `document`
afe42d0… ragelink 20 // (such as Node.js), expose a factory as module.exports.
afe42d0… ragelink 21 // This accentuates the need for the creation of a real `window`.
afe42d0… ragelink 22 // e.g. var jQuery = require("jquery")(window);
afe42d0… ragelink 23 // See ticket trac-14549 for more info.
afe42d0… ragelink 24 module.exports = global.document ?
afe42d0… ragelink 25 factory( global, true ) :
afe42d0… ragelink 26 function( w ) {
afe42d0… ragelink 27 if ( !w.document ) {
afe42d0… ragelink 28 throw new Error( "jQuery requires a window with a document" );
afe42d0… ragelink 29 }
afe42d0… ragelink 30 return factory( w );
afe42d0… ragelink 31 };
afe42d0… ragelink 32 } else {
afe42d0… ragelink 33 factory( global );
afe42d0… ragelink 34 }
afe42d0… ragelink 35
afe42d0… ragelink 36 // Pass this if window is not defined yet
afe42d0… ragelink 37 } )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
afe42d0… ragelink 38
afe42d0… ragelink 39 // Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1
afe42d0… ragelink 40 // throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode
afe42d0… ragelink 41 // arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common
afe42d0… ragelink 42 // enough that all such attempts are guarded in a try block.
afe42d0… ragelink 43 "use strict";
afe42d0… ragelink 44
afe42d0… ragelink 45 var arr = [];
afe42d0… ragelink 46
afe42d0… ragelink 47 var getProto = Object.getPrototypeOf;
afe42d0… ragelink 48
afe42d0… ragelink 49 var slice = arr.slice;
afe42d0… ragelink 50
afe42d0… ragelink 51 var flat = arr.flat ? function( array ) {
afe42d0… ragelink 52 return arr.flat.call( array );
afe42d0… ragelink 53 } : function( array ) {
afe42d0… ragelink 54 return arr.concat.apply( [], array );
afe42d0… ragelink 55 };
afe42d0… ragelink 56
afe42d0… ragelink 57
afe42d0… ragelink 58 var push = arr.push;
afe42d0… ragelink 59
afe42d0… ragelink 60 var indexOf = arr.indexOf;
afe42d0… ragelink 61
afe42d0… ragelink 62 var class2type = {};
afe42d0… ragelink 63
afe42d0… ragelink 64 var toString = class2type.toString;
afe42d0… ragelink 65
afe42d0… ragelink 66 var hasOwn = class2type.hasOwnProperty;
afe42d0… ragelink 67
afe42d0… ragelink 68 var fnToString = hasOwn.toString;
afe42d0… ragelink 69
afe42d0… ragelink 70 var ObjectFunctionString = fnToString.call( Object );
afe42d0… ragelink 71
afe42d0… ragelink 72 var support = {};
afe42d0… ragelink 73
afe42d0… ragelink 74 var isFunction = function isFunction( obj ) {
afe42d0… ragelink 75
afe42d0… ragelink 76 // Support: Chrome <=57, Firefox <=52
afe42d0… ragelink 77 // In some browsers, typeof returns "function" for HTML <object> elements
afe42d0… ragelink 78 // (i.e., `typeof document.createElement( "object" ) === "function"`).
afe42d0… ragelink 79 // We don't want to classify *any* DOM node as a function.
afe42d0… ragelink 80 // Support: QtWeb <=3.8.5, WebKit <=534.34, wkhtmltopdf tool <=0.12.5
afe42d0… ragelink 81 // Plus for old WebKit, typeof returns "function" for HTML collections
afe42d0… ragelink 82 // (e.g., `typeof document.getElementsByTagName("div") === "function"`). (gh-4756)
afe42d0… ragelink 83 return typeof obj === "function" && typeof obj.nodeType !== "number" &&
afe42d0… ragelink 84 typeof obj.item !== "function";
afe42d0… ragelink 85 };
afe42d0… ragelink 86
afe42d0… ragelink 87
afe42d0… ragelink 88 var isWindow = function isWindow( obj ) {
afe42d0… ragelink 89 return obj != null && obj === obj.window;
afe42d0… ragelink 90 };
afe42d0… ragelink 91
afe42d0… ragelink 92
afe42d0… ragelink 93 var document = window.document;
afe42d0… ragelink 94
afe42d0… ragelink 95
afe42d0… ragelink 96
afe42d0… ragelink 97 var preservedScriptAttributes = {
afe42d0… ragelink 98 type: true,
afe42d0… ragelink 99 src: true,
afe42d0… ragelink 100 nonce: true,
afe42d0… ragelink 101 noModule: true
afe42d0… ragelink 102 };
afe42d0… ragelink 103
afe42d0… ragelink 104 function DOMEval( code, node, doc ) {
afe42d0… ragelink 105 doc = doc || document;
afe42d0… ragelink 106
afe42d0… ragelink 107 var i, val,
afe42d0… ragelink 108 script = doc.createElement( "script" );
afe42d0… ragelink 109
afe42d0… ragelink 110 script.text = code;
afe42d0… ragelink 111 if ( node ) {
afe42d0… ragelink 112 for ( i in preservedScriptAttributes ) {
afe42d0… ragelink 113
afe42d0… ragelink 114 // Support: Firefox 64+, Edge 18+
afe42d0… ragelink 115 // Some browsers don't support the "nonce" property on scripts.
afe42d0… ragelink 116 // On the other hand, just using `getAttribute` is not enough as
afe42d0… ragelink 117 // the `nonce` attribute is reset to an empty string whenever it
afe42d0… ragelink 118 // becomes browsing-context connected.
afe42d0… ragelink 119 // See https://github.com/whatwg/html/issues/2369
afe42d0… ragelink 120 // See https://html.spec.whatwg.org/#nonce-attributes
afe42d0… ragelink 121 // The `node.getAttribute` check was added for the sake of
afe42d0… ragelink 122 // `jQuery.globalEval` so that it can fake a nonce-containing node
afe42d0… ragelink 123 // via an object.
afe42d0… ragelink 124 val = node[ i ] || node.getAttribute && node.getAttribute( i );
afe42d0… ragelink 125 if ( val ) {
afe42d0… ragelink 126 script.setAttribute( i, val );
afe42d0… ragelink 127 }
afe42d0… ragelink 128 }
afe42d0… ragelink 129 }
afe42d0… ragelink 130 doc.head.appendChild( script ).parentNode.removeChild( script );
afe42d0… ragelink 131 }
afe42d0… ragelink 132
afe42d0… ragelink 133
afe42d0… ragelink 134 function toType( obj ) {
afe42d0… ragelink 135 if ( obj == null ) {
afe42d0… ragelink 136 return obj + "";
afe42d0… ragelink 137 }
afe42d0… ragelink 138
afe42d0… ragelink 139 // Support: Android <=2.3 only (functionish RegExp)
afe42d0… ragelink 140 return typeof obj === "object" || typeof obj === "function" ?
afe42d0… ragelink 141 class2type[ toString.call( obj ) ] || "object" :
afe42d0… ragelink 142 typeof obj;
afe42d0… ragelink 143 }
afe42d0… ragelink 144 /* global Symbol */
afe42d0… ragelink 145 // Defining this global in .eslintrc.json would create a danger of using the global
afe42d0… ragelink 146 // unguarded in another place, it seems safer to define global only for this module
afe42d0… ragelink 147
afe42d0… ragelink 148
afe42d0… ragelink 149
afe42d0… ragelink 150 var version = "3.7.1",
afe42d0… ragelink 151
afe42d0… ragelink 152 rhtmlSuffix = /HTML$/i,
afe42d0… ragelink 153
afe42d0… ragelink 154 // Define a local copy of jQuery
afe42d0… ragelink 155 jQuery = function( selector, context ) {
afe42d0… ragelink 156
afe42d0… ragelink 157 // The jQuery object is actually just the init constructor 'enhanced'
afe42d0… ragelink 158 // Need init if jQuery is called (just allow error to be thrown if not included)
afe42d0… ragelink 159 return new jQuery.fn.init( selector, context );
afe42d0… ragelink 160 };
afe42d0… ragelink 161
afe42d0… ragelink 162 jQuery.fn = jQuery.prototype = {
afe42d0… ragelink 163
afe42d0… ragelink 164 // The current version of jQuery being used
afe42d0… ragelink 165 jquery: version,
afe42d0… ragelink 166
afe42d0… ragelink 167 constructor: jQuery,
afe42d0… ragelink 168
afe42d0… ragelink 169 // The default length of a jQuery object is 0
afe42d0… ragelink 170 length: 0,
afe42d0… ragelink 171
afe42d0… ragelink 172 toArray: function() {
afe42d0… ragelink 173 return slice.call( this );
afe42d0… ragelink 174 },
afe42d0… ragelink 175
afe42d0… ragelink 176 // Get the Nth element in the matched element set OR
afe42d0… ragelink 177 // Get the whole matched element set as a clean array
afe42d0… ragelink 178 get: function( num ) {
afe42d0… ragelink 179
afe42d0… ragelink 180 // Return all the elements in a clean array
afe42d0… ragelink 181 if ( num == null ) {
afe42d0… ragelink 182 return slice.call( this );
afe42d0… ragelink 183 }
afe42d0… ragelink 184
afe42d0… ragelink 185 // Return just the one element from the set
afe42d0… ragelink 186 return num < 0 ? this[ num + this.length ] : this[ num ];
afe42d0… ragelink 187 },
afe42d0… ragelink 188
afe42d0… ragelink 189 // Take an array of elements and push it onto the stack
afe42d0… ragelink 190 // (returning the new matched element set)
afe42d0… ragelink 191 pushStack: function( elems ) {
afe42d0… ragelink 192
afe42d0… ragelink 193 // Build a new jQuery matched element set
afe42d0… ragelink 194 var ret = jQuery.merge( this.constructor(), elems );
afe42d0… ragelink 195
afe42d0… ragelink 196 // Add the old object onto the stack (as a reference)
afe42d0… ragelink 197 ret.prevObject = this;
afe42d0… ragelink 198
afe42d0… ragelink 199 // Return the newly-formed element set
afe42d0… ragelink 200 return ret;
afe42d0… ragelink 201 },
afe42d0… ragelink 202
afe42d0… ragelink 203 // Execute a callback for every element in the matched set.
afe42d0… ragelink 204 each: function( callback ) {
afe42d0… ragelink 205 return jQuery.each( this, callback );
afe42d0… ragelink 206 },
afe42d0… ragelink 207
afe42d0… ragelink 208 map: function( callback ) {
afe42d0… ragelink 209 return this.pushStack( jQuery.map( this, function( elem, i ) {
afe42d0… ragelink 210 return callback.call( elem, i, elem );
afe42d0… ragelink 211 } ) );
afe42d0… ragelink 212 },
afe42d0… ragelink 213
afe42d0… ragelink 214 slice: function() {
afe42d0… ragelink 215 return this.pushStack( slice.apply( this, arguments ) );
afe42d0… ragelink 216 },
afe42d0… ragelink 217
afe42d0… ragelink 218 first: function() {
afe42d0… ragelink 219 return this.eq( 0 );
afe42d0… ragelink 220 },
afe42d0… ragelink 221
afe42d0… ragelink 222 last: function() {
afe42d0… ragelink 223 return this.eq( -1 );
afe42d0… ragelink 224 },
afe42d0… ragelink 225
afe42d0… ragelink 226 even: function() {
afe42d0… ragelink 227 return this.pushStack( jQuery.grep( this, function( _elem, i ) {
afe42d0… ragelink 228 return ( i + 1 ) % 2;
afe42d0… ragelink 229 } ) );
afe42d0… ragelink 230 },
afe42d0… ragelink 231
afe42d0… ragelink 232 odd: function() {
afe42d0… ragelink 233 return this.pushStack( jQuery.grep( this, function( _elem, i ) {
afe42d0… ragelink 234 return i % 2;
afe42d0… ragelink 235 } ) );
afe42d0… ragelink 236 },
afe42d0… ragelink 237
afe42d0… ragelink 238 eq: function( i ) {
afe42d0… ragelink 239 var len = this.length,
afe42d0… ragelink 240 j = +i + ( i < 0 ? len : 0 );
afe42d0… ragelink 241 return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
afe42d0… ragelink 242 },
afe42d0… ragelink 243
afe42d0… ragelink 244 end: function() {
afe42d0… ragelink 245 return this.prevObject || this.constructor();
afe42d0… ragelink 246 },
afe42d0… ragelink 247
afe42d0… ragelink 248 // For internal use only.
afe42d0… ragelink 249 // Behaves like an Array's method, not like a jQuery method.
afe42d0… ragelink 250 push: push,
afe42d0… ragelink 251 sort: arr.sort,
afe42d0… ragelink 252 splice: arr.splice
afe42d0… ragelink 253 };
afe42d0… ragelink 254
afe42d0… ragelink 255 jQuery.extend = jQuery.fn.extend = function() {
afe42d0… ragelink 256 var options, name, src, copy, copyIsArray, clone,
afe42d0… ragelink 257 target = arguments[ 0 ] || {},
afe42d0… ragelink 258 i = 1,
afe42d0… ragelink 259 length = arguments.length,
afe42d0… ragelink 260 deep = false;
afe42d0… ragelink 261
afe42d0… ragelink 262 // Handle a deep copy situation
afe42d0… ragelink 263 if ( typeof target === "boolean" ) {
afe42d0… ragelink 264 deep = target;
afe42d0… ragelink 265
afe42d0… ragelink 266 // Skip the boolean and the target
afe42d0… ragelink 267 target = arguments[ i ] || {};
afe42d0… ragelink 268 i++;
afe42d0… ragelink 269 }
afe42d0… ragelink 270
afe42d0… ragelink 271 // Handle case when target is a string or something (possible in deep copy)
afe42d0… ragelink 272 if ( typeof target !== "object" && !isFunction( target ) ) {
afe42d0… ragelink 273 target = {};
afe42d0… ragelink 274 }
afe42d0… ragelink 275
afe42d0… ragelink 276 // Extend jQuery itself if only one argument is passed
afe42d0… ragelink 277 if ( i === length ) {
afe42d0… ragelink 278 target = this;
afe42d0… ragelink 279 i--;
afe42d0… ragelink 280 }
afe42d0… ragelink 281
afe42d0… ragelink 282 for ( ; i < length; i++ ) {
afe42d0… ragelink 283
afe42d0… ragelink 284 // Only deal with non-null/undefined values
afe42d0… ragelink 285 if ( ( options = arguments[ i ] ) != null ) {
afe42d0… ragelink 286
afe42d0… ragelink 287 // Extend the base object
afe42d0… ragelink 288 for ( name in options ) {
afe42d0… ragelink 289 copy = options[ name ];
afe42d0… ragelink 290
afe42d0… ragelink 291 // Prevent Object.prototype pollution
afe42d0… ragelink 292 // Prevent never-ending loop
afe42d0… ragelink 293 if ( name === "__proto__" || target === copy ) {
afe42d0… ragelink 294 continue;
afe42d0… ragelink 295 }
afe42d0… ragelink 296
afe42d0… ragelink 297 // Recurse if we're merging plain objects or arrays
afe42d0… ragelink 298 if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
afe42d0… ragelink 299 ( copyIsArray = Array.isArray( copy ) ) ) ) {
afe42d0… ragelink 300 src = target[ name ];
afe42d0… ragelink 301
afe42d0… ragelink 302 // Ensure proper type for the source value
afe42d0… ragelink 303 if ( copyIsArray && !Array.isArray( src ) ) {
afe42d0… ragelink 304 clone = [];
afe42d0… ragelink 305 } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) {
afe42d0… ragelink 306 clone = {};
afe42d0… ragelink 307 } else {
afe42d0… ragelink 308 clone = src;
afe42d0… ragelink 309 }
afe42d0… ragelink 310 copyIsArray = false;
afe42d0… ragelink 311
afe42d0… ragelink 312 // Never move original objects, clone them
afe42d0… ragelink 313 target[ name ] = jQuery.extend( deep, clone, copy );
afe42d0… ragelink 314
afe42d0… ragelink 315 // Don't bring in undefined values
afe42d0… ragelink 316 } else if ( copy !== undefined ) {
afe42d0… ragelink 317 target[ name ] = copy;
afe42d0… ragelink 318 }
afe42d0… ragelink 319 }
afe42d0… ragelink 320 }
afe42d0… ragelink 321 }
afe42d0… ragelink 322
afe42d0… ragelink 323 // Return the modified object
afe42d0… ragelink 324 return target;
afe42d0… ragelink 325 };
afe42d0… ragelink 326
afe42d0… ragelink 327 jQuery.extend( {
afe42d0… ragelink 328
afe42d0… ragelink 329 // Unique for each copy of jQuery on the page
afe42d0… ragelink 330 expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
afe42d0… ragelink 331
afe42d0… ragelink 332 // Assume jQuery is ready without the ready module
afe42d0… ragelink 333 isReady: true,
afe42d0… ragelink 334
afe42d0… ragelink 335 error: function( msg ) {
afe42d0… ragelink 336 throw new Error( msg );
afe42d0… ragelink 337 },
afe42d0… ragelink 338
afe42d0… ragelink 339 noop: function() {},
afe42d0… ragelink 340
afe42d0… ragelink 341 isPlainObject: function( obj ) {
afe42d0… ragelink 342 var proto, Ctor;
afe42d0… ragelink 343
afe42d0… ragelink 344 // Detect obvious negatives
afe42d0… ragelink 345 // Use toString instead of jQuery.type to catch host objects
afe42d0… ragelink 346 if ( !obj || toString.call( obj ) !== "[object Object]" ) {
afe42d0… ragelink 347 return false;
afe42d0… ragelink 348 }
afe42d0… ragelink 349
afe42d0… ragelink 350 proto = getProto( obj );
afe42d0… ragelink 351
afe42d0… ragelink 352 // Objects with no prototype (e.g., `Object.create( null )`) are plain
afe42d0… ragelink 353 if ( !proto ) {
afe42d0… ragelink 354 return true;
afe42d0… ragelink 355 }
afe42d0… ragelink 356
afe42d0… ragelink 357 // Objects with prototype are plain iff they were constructed by a global Object function
afe42d0… ragelink 358 Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
afe42d0… ragelink 359 return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
afe42d0… ragelink 360 },
afe42d0… ragelink 361
afe42d0… ragelink 362 isEmptyObject: function( obj ) {
afe42d0… ragelink 363 var name;
afe42d0… ragelink 364
afe42d0… ragelink 365 for ( name in obj ) {
afe42d0… ragelink 366 return false;
afe42d0… ragelink 367 }
afe42d0… ragelink 368 return true;
afe42d0… ragelink 369 },
afe42d0… ragelink 370
afe42d0… ragelink 371 // Evaluates a script in a provided context; falls back to the global one
afe42d0… ragelink 372 // if not specified.
afe42d0… ragelink 373 globalEval: function( code, options, doc ) {
afe42d0… ragelink 374 DOMEval( code, { nonce: options && options.nonce }, doc );
afe42d0… ragelink 375 },
afe42d0… ragelink 376
afe42d0… ragelink 377 each: function( obj, callback ) {
afe42d0… ragelink 378 var length, i = 0;
afe42d0… ragelink 379
afe42d0… ragelink 380 if ( isArrayLike( obj ) ) {
afe42d0… ragelink 381 length = obj.length;
afe42d0… ragelink 382 for ( ; i < length; i++ ) {
afe42d0… ragelink 383 if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
afe42d0… ragelink 384 break;
afe42d0… ragelink 385 }
afe42d0… ragelink 386 }
afe42d0… ragelink 387 } else {
afe42d0… ragelink 388 for ( i in obj ) {
afe42d0… ragelink 389 if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
afe42d0… ragelink 390 break;
afe42d0… ragelink 391 }
afe42d0… ragelink 392 }
afe42d0… ragelink 393 }
afe42d0… ragelink 394
afe42d0… ragelink 395 return obj;
afe42d0… ragelink 396 },
afe42d0… ragelink 397
afe42d0… ragelink 398
afe42d0… ragelink 399 // Retrieve the text value of an array of DOM nodes
afe42d0… ragelink 400 text: function( elem ) {
afe42d0… ragelink 401 var node,
afe42d0… ragelink 402 ret = "",
afe42d0… ragelink 403 i = 0,
afe42d0… ragelink 404 nodeType = elem.nodeType;
afe42d0… ragelink 405
afe42d0… ragelink 406 if ( !nodeType ) {
afe42d0… ragelink 407
afe42d0… ragelink 408 // If no nodeType, this is expected to be an array
afe42d0… ragelink 409 while ( ( node = elem[ i++ ] ) ) {
afe42d0… ragelink 410
afe42d0… ragelink 411 // Do not traverse comment nodes
afe42d0… ragelink 412 ret += jQuery.text( node );
afe42d0… ragelink 413 }
afe42d0… ragelink 414 }
afe42d0… ragelink 415 if ( nodeType === 1 || nodeType === 11 ) {
afe42d0… ragelink 416 return elem.textContent;
afe42d0… ragelink 417 }
afe42d0… ragelink 418 if ( nodeType === 9 ) {
afe42d0… ragelink 419 return elem.documentElement.textContent;
afe42d0… ragelink 420 }
afe42d0… ragelink 421 if ( nodeType === 3 || nodeType === 4 ) {
afe42d0… ragelink 422 return elem.nodeValue;
afe42d0… ragelink 423 }
afe42d0… ragelink 424
afe42d0… ragelink 425 // Do not include comment or processing instruction nodes
afe42d0… ragelink 426
afe42d0… ragelink 427 return ret;
afe42d0… ragelink 428 },
afe42d0… ragelink 429
afe42d0… ragelink 430 // results is for internal usage only
afe42d0… ragelink 431 makeArray: function( arr, results ) {
afe42d0… ragelink 432 var ret = results || [];
afe42d0… ragelink 433
afe42d0… ragelink 434 if ( arr != null ) {
afe42d0… ragelink 435 if ( isArrayLike( Object( arr ) ) ) {
afe42d0… ragelink 436 jQuery.merge( ret,
afe42d0… ragelink 437 typeof arr === "string" ?
afe42d0… ragelink 438 [ arr ] : arr
afe42d0… ragelink 439 );
afe42d0… ragelink 440 } else {
afe42d0… ragelink 441 push.call( ret, arr );
afe42d0… ragelink 442 }
afe42d0… ragelink 443 }
afe42d0… ragelink 444
afe42d0… ragelink 445 return ret;
afe42d0… ragelink 446 },
afe42d0… ragelink 447
afe42d0… ragelink 448 inArray: function( elem, arr, i ) {
afe42d0… ragelink 449 return arr == null ? -1 : indexOf.call( arr, elem, i );
afe42d0… ragelink 450 },
afe42d0… ragelink 451
afe42d0… ragelink 452 isXMLDoc: function( elem ) {
afe42d0… ragelink 453 var namespace = elem && elem.namespaceURI,
afe42d0… ragelink 454 docElem = elem && ( elem.ownerDocument || elem ).documentElement;
afe42d0… ragelink 455
afe42d0… ragelink 456 // Assume HTML when documentElement doesn't yet exist, such as inside
afe42d0… ragelink 457 // document fragments.
afe42d0… ragelink 458 return !rhtmlSuffix.test( namespace || docElem && docElem.nodeName || "HTML" );
afe42d0… ragelink 459 },
afe42d0… ragelink 460
afe42d0… ragelink 461 // Support: Android <=4.0 only, PhantomJS 1 only
afe42d0… ragelink 462 // push.apply(_, arraylike) throws on ancient WebKit
afe42d0… ragelink 463 merge: function( first, second ) {
afe42d0… ragelink 464 var len = +second.length,
afe42d0… ragelink 465 j = 0,
afe42d0… ragelink 466 i = first.length;
afe42d0… ragelink 467
afe42d0… ragelink 468 for ( ; j < len; j++ ) {
afe42d0… ragelink 469 first[ i++ ] = second[ j ];
afe42d0… ragelink 470 }
afe42d0… ragelink 471
afe42d0… ragelink 472 first.length = i;
afe42d0… ragelink 473
afe42d0… ragelink 474 return first;
afe42d0… ragelink 475 },
afe42d0… ragelink 476
afe42d0… ragelink 477 grep: function( elems, callback, invert ) {
afe42d0… ragelink 478 var callbackInverse,
afe42d0… ragelink 479 matches = [],
afe42d0… ragelink 480 i = 0,
afe42d0… ragelink 481 length = elems.length,
afe42d0… ragelink 482 callbackExpect = !invert;
afe42d0… ragelink 483
afe42d0… ragelink 484 // Go through the array, only saving the items
afe42d0… ragelink 485 // that pass the validator function
afe42d0… ragelink 486 for ( ; i < length; i++ ) {
afe42d0… ragelink 487 callbackInverse = !callback( elems[ i ], i );
afe42d0… ragelink 488 if ( callbackInverse !== callbackExpect ) {
afe42d0… ragelink 489 matches.push( elems[ i ] );
afe42d0… ragelink 490 }
afe42d0… ragelink 491 }
afe42d0… ragelink 492
afe42d0… ragelink 493 return matches;
afe42d0… ragelink 494 },
afe42d0… ragelink 495
afe42d0… ragelink 496 // arg is for internal usage only
afe42d0… ragelink 497 map: function( elems, callback, arg ) {
afe42d0… ragelink 498 var length, value,
afe42d0… ragelink 499 i = 0,
afe42d0… ragelink 500 ret = [];
afe42d0… ragelink 501
afe42d0… ragelink 502 // Go through the array, translating each of the items to their new values
afe42d0… ragelink 503 if ( isArrayLike( elems ) ) {
afe42d0… ragelink 504 length = elems.length;
afe42d0… ragelink 505 for ( ; i < length; i++ ) {
afe42d0… ragelink 506 value = callback( elems[ i ], i, arg );
afe42d0… ragelink 507
afe42d0… ragelink 508 if ( value != null ) {
afe42d0… ragelink 509 ret.push( value );
afe42d0… ragelink 510 }
afe42d0… ragelink 511 }
afe42d0… ragelink 512
afe42d0… ragelink 513 // Go through every key on the object,
afe42d0… ragelink 514 } else {
afe42d0… ragelink 515 for ( i in elems ) {
afe42d0… ragelink 516 value = callback( elems[ i ], i, arg );
afe42d0… ragelink 517
afe42d0… ragelink 518 if ( value != null ) {
afe42d0… ragelink 519 ret.push( value );
afe42d0… ragelink 520 }
afe42d0… ragelink 521 }
afe42d0… ragelink 522 }
afe42d0… ragelink 523
afe42d0… ragelink 524 // Flatten any nested arrays
afe42d0… ragelink 525 return flat( ret );
afe42d0… ragelink 526 },
afe42d0… ragelink 527
afe42d0… ragelink 528 // A global GUID counter for objects
afe42d0… ragelink 529 guid: 1,
afe42d0… ragelink 530
afe42d0… ragelink 531 // jQuery.support is not used in Core but other projects attach their
afe42d0… ragelink 532 // properties to it so it needs to exist.
afe42d0… ragelink 533 support: support
afe42d0… ragelink 534 } );
afe42d0… ragelink 535
afe42d0… ragelink 536 if ( typeof Symbol === "function" ) {
afe42d0… ragelink 537 jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
afe42d0… ragelink 538 }
afe42d0… ragelink 539
afe42d0… ragelink 540 // Populate the class2type map
afe42d0… ragelink 541 jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
afe42d0… ragelink 542 function( _i, name ) {
afe42d0… ragelink 543 class2type[ "[object " + name + "]" ] = name.toLowerCase();
afe42d0… ragelink 544 } );
afe42d0… ragelink 545
afe42d0… ragelink 546 function isArrayLike( obj ) {
afe42d0… ragelink 547
afe42d0… ragelink 548 // Support: real iOS 8.2 only (not reproducible in simulator)
afe42d0… ragelink 549 // `in` check used to prevent JIT error (gh-2145)
afe42d0… ragelink 550 // hasOwn isn't used here due to false negatives
afe42d0… ragelink 551 // regarding Nodelist length in IE
afe42d0… ragelink 552 var length = !!obj && "length" in obj && obj.length,
afe42d0… ragelink 553 type = toType( obj );
afe42d0… ragelink 554
afe42d0… ragelink 555 if ( isFunction( obj ) || isWindow( obj ) ) {
afe42d0… ragelink 556 return false;
afe42d0… ragelink 557 }
afe42d0… ragelink 558
afe42d0… ragelink 559 return type === "array" || length === 0 ||
afe42d0… ragelink 560 typeof length === "number" && length > 0 && ( length - 1 ) in obj;
afe42d0… ragelink 561 }
afe42d0… ragelink 562
afe42d0… ragelink 563
afe42d0… ragelink 564 function nodeName( elem, name ) {
afe42d0… ragelink 565
afe42d0… ragelink 566 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
afe42d0… ragelink 567
afe42d0… ragelink 568 }
afe42d0… ragelink 569 var pop = arr.pop;
afe42d0… ragelink 570
afe42d0… ragelink 571
afe42d0… ragelink 572 var sort = arr.sort;
afe42d0… ragelink 573
afe42d0… ragelink 574
afe42d0… ragelink 575 var splice = arr.splice;
afe42d0… ragelink 576
afe42d0… ragelink 577
afe42d0… ragelink 578 var whitespace = "[\\x20\\t\\r\\n\\f]";
afe42d0… ragelink 579
afe42d0… ragelink 580
afe42d0… ragelink 581 var rtrimCSS = new RegExp(
afe42d0… ragelink 582 "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$",
afe42d0… ragelink 583 "g"
afe42d0… ragelink 584 );
afe42d0… ragelink 585
afe42d0… ragelink 586
afe42d0… ragelink 587
afe42d0… ragelink 588
afe42d0… ragelink 589 // Note: an element does not contain itself
afe42d0… ragelink 590 jQuery.contains = function( a, b ) {
afe42d0… ragelink 591 var bup = b && b.parentNode;
afe42d0… ragelink 592
afe42d0… ragelink 593 return a === bup || !!( bup && bup.nodeType === 1 && (
afe42d0… ragelink 594
afe42d0… ragelink 595 // Support: IE 9 - 11+
afe42d0… ragelink 596 // IE doesn't have `contains` on SVG.
afe42d0… ragelink 597 a.contains ?
afe42d0… ragelink 598 a.contains( bup ) :
afe42d0… ragelink 599 a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
afe42d0… ragelink 600 ) );
afe42d0… ragelink 601 };
afe42d0… ragelink 602
afe42d0… ragelink 603
afe42d0… ragelink 604
afe42d0… ragelink 605
afe42d0… ragelink 606 // CSS string/identifier serialization
afe42d0… ragelink 607 // https://drafts.csswg.org/cssom/#common-serializing-idioms
afe42d0… ragelink 608 var rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g;
afe42d0… ragelink 609
afe42d0… ragelink 610 function fcssescape( ch, asCodePoint ) {
afe42d0… ragelink 611 if ( asCodePoint ) {
afe42d0… ragelink 612
afe42d0… ragelink 613 // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
afe42d0… ragelink 614 if ( ch === "\0" ) {
afe42d0… ragelink 615 return "\uFFFD";
afe42d0… ragelink 616 }
afe42d0… ragelink 617
afe42d0… ragelink 618 // Control characters and (dependent upon position) numbers get escaped as code points
afe42d0… ragelink 619 return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
afe42d0… ragelink 620 }
afe42d0… ragelink 621
afe42d0… ragelink 622 // Other potentially-special ASCII characters get backslash-escaped
afe42d0… ragelink 623 return "\\" + ch;
afe42d0… ragelink 624 }
afe42d0… ragelink 625
afe42d0… ragelink 626 jQuery.escapeSelector = function( sel ) {
afe42d0… ragelink 627 return ( sel + "" ).replace( rcssescape, fcssescape );
afe42d0… ragelink 628 };
afe42d0… ragelink 629
afe42d0… ragelink 630
afe42d0… ragelink 631
afe42d0… ragelink 632
afe42d0… ragelink 633 var preferredDoc = document,
afe42d0… ragelink 634 pushNative = push;
afe42d0… ragelink 635
afe42d0… ragelink 636 ( function() {
afe42d0… ragelink 637
afe42d0… ragelink 638 var i,
afe42d0… ragelink 639 Expr,
afe42d0… ragelink 640 outermostContext,
afe42d0… ragelink 641 sortInput,
afe42d0… ragelink 642 hasDuplicate,
afe42d0… ragelink 643 push = pushNative,
afe42d0… ragelink 644
afe42d0… ragelink 645 // Local document vars
afe42d0… ragelink 646 document,
afe42d0… ragelink 647 documentElement,
afe42d0… ragelink 648 documentIsHTML,
afe42d0… ragelink 649 rbuggyQSA,
afe42d0… ragelink 650 matches,
afe42d0… ragelink 651
afe42d0… ragelink 652 // Instance-specific data
afe42d0… ragelink 653 expando = jQuery.expando,
afe42d0… ragelink 654 dirruns = 0,
afe42d0… ragelink 655 done = 0,
afe42d0… ragelink 656 classCache = createCache(),
afe42d0… ragelink 657 tokenCache = createCache(),
afe42d0… ragelink 658 compilerCache = createCache(),
afe42d0… ragelink 659 nonnativeSelectorCache = createCache(),
afe42d0… ragelink 660 sortOrder = function( a, b ) {
afe42d0… ragelink 661 if ( a === b ) {
afe42d0… ragelink 662 hasDuplicate = true;
afe42d0… ragelink 663 }
afe42d0… ragelink 664 return 0;
afe42d0… ragelink 665 },
afe42d0… ragelink 666
afe42d0… ragelink 667 booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|" +
afe42d0… ragelink 668 "loop|multiple|open|readonly|required|scoped",
afe42d0… ragelink 669
afe42d0… ragelink 670 // Regular expressions
afe42d0… ragelink 671
afe42d0… ragelink 672 // https://www.w3.org/TR/css-syntax-3/#ident-token-diagram
afe42d0… ragelink 673 identifier = "(?:\\\\[\\da-fA-F]{1,6}" + whitespace +
afe42d0… ragelink 674 "?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",
afe42d0… ragelink 675
afe42d0… ragelink 676 // Attribute selectors: https://www.w3.org/TR/selectors/#attribute-selectors
afe42d0… ragelink 677 attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
afe42d0… ragelink 678
afe42d0… ragelink 679 // Operator (capture 2)
afe42d0… ragelink 680 "*([*^$|!~]?=)" + whitespace +
afe42d0… ragelink 681
afe42d0… ragelink 682 // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
afe42d0… ragelink 683 "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" +
afe42d0… ragelink 684 whitespace + "*\\]",
afe42d0… ragelink 685
afe42d0… ragelink 686 pseudos = ":(" + identifier + ")(?:\\((" +
afe42d0… ragelink 687
afe42d0… ragelink 688 // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
afe42d0… ragelink 689 // 1. quoted (capture 3; capture 4 or capture 5)
afe42d0… ragelink 690 "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
afe42d0… ragelink 691
afe42d0… ragelink 692 // 2. simple (capture 6)
afe42d0… ragelink 693 "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
afe42d0… ragelink 694
afe42d0… ragelink 695 // 3. anything else (capture 2)
afe42d0… ragelink 696 ".*" +
afe42d0… ragelink 697 ")\\)|)",
afe42d0… ragelink 698
afe42d0… ragelink 699 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
afe42d0… ragelink 700 rwhitespace = new RegExp( whitespace + "+", "g" ),
afe42d0… ragelink 701
afe42d0… ragelink 702 rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
afe42d0… ragelink 703 rleadingCombinator = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" +
afe42d0… ragelink 704 whitespace + "*" ),
afe42d0… ragelink 705 rdescend = new RegExp( whitespace + "|>" ),
afe42d0… ragelink 706
afe42d0… ragelink 707 rpseudo = new RegExp( pseudos ),
afe42d0… ragelink 708 ridentifier = new RegExp( "^" + identifier + "$" ),
afe42d0… ragelink 709
afe42d0… ragelink 710 matchExpr = {
afe42d0… ragelink 711 ID: new RegExp( "^#(" + identifier + ")" ),
afe42d0… ragelink 712 CLASS: new RegExp( "^\\.(" + identifier + ")" ),
afe42d0… ragelink 713 TAG: new RegExp( "^(" + identifier + "|[*])" ),
afe42d0… ragelink 714 ATTR: new RegExp( "^" + attributes ),
afe42d0… ragelink 715 PSEUDO: new RegExp( "^" + pseudos ),
afe42d0… ragelink 716 CHILD: new RegExp(
afe42d0… ragelink 717 "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" +
afe42d0… ragelink 718 whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" +
afe42d0… ragelink 719 whitespace + "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
afe42d0… ragelink 720 bool: new RegExp( "^(?:" + booleans + ")$", "i" ),
afe42d0… ragelink 721
afe42d0… ragelink 722 // For use in libraries implementing .is()
afe42d0… ragelink 723 // We use this for POS matching in `select`
afe42d0… ragelink 724 needsContext: new RegExp( "^" + whitespace +
afe42d0… ragelink 725 "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace +
afe42d0… ragelink 726 "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
afe42d0… ragelink 727 },
afe42d0… ragelink 728
afe42d0… ragelink 729 rinputs = /^(?:input|select|textarea|button)$/i,
afe42d0… ragelink 730 rheader = /^h\d$/i,
afe42d0… ragelink 731
afe42d0… ragelink 732 // Easily-parseable/retrievable ID or TAG or CLASS selectors
afe42d0… ragelink 733 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
afe42d0… ragelink 734
afe42d0… ragelink 735 rsibling = /[+~]/,
afe42d0… ragelink 736
afe42d0… ragelink 737 // CSS escapes
afe42d0… ragelink 738 // https://www.w3.org/TR/CSS21/syndata.html#escaped-characters
afe42d0… ragelink 739 runescape = new RegExp( "\\\\[\\da-fA-F]{1,6}" + whitespace +
afe42d0… ragelink 740 "?|\\\\([^\\r\\n\\f])", "g" ),
afe42d0… ragelink 741 funescape = function( escape, nonHex ) {
afe42d0… ragelink 742 var high = "0x" + escape.slice( 1 ) - 0x10000;
afe42d0… ragelink 743
afe42d0… ragelink 744 if ( nonHex ) {
afe42d0… ragelink 745
afe42d0… ragelink 746 // Strip the backslash prefix from a non-hex escape sequence
afe42d0… ragelink 747 return nonHex;
afe42d0… ragelink 748 }
afe42d0… ragelink 749
afe42d0… ragelink 750 // Replace a hexadecimal escape sequence with the encoded Unicode code point
afe42d0… ragelink 751 // Support: IE <=11+
afe42d0… ragelink 752 // For values outside the Basic Multilingual Plane (BMP), manually construct a
afe42d0… ragelink 753 // surrogate pair
afe42d0… ragelink 754 return high < 0 ?
afe42d0… ragelink 755 String.fromCharCode( high + 0x10000 ) :
afe42d0… ragelink 756 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
afe42d0… ragelink 757 },
afe42d0… ragelink 758
afe42d0… ragelink 759 // Used for iframes; see `setDocument`.
afe42d0… ragelink 760 // Support: IE 9 - 11+, Edge 12 - 18+
afe42d0… ragelink 761 // Removing the function wrapper causes a "Permission Denied"
afe42d0… ragelink 762 // error in IE/Edge.
afe42d0… ragelink 763 unloadHandler = function() {
afe42d0… ragelink 764 setDocument();
afe42d0… ragelink 765 },
afe42d0… ragelink 766
afe42d0… ragelink 767 inDisabledFieldset = addCombinator(
afe42d0… ragelink 768 function( elem ) {
afe42d0… ragelink 769 return elem.disabled === true && nodeName( elem, "fieldset" );
afe42d0… ragelink 770 },
afe42d0… ragelink 771 { dir: "parentNode", next: "legend" }
afe42d0… ragelink 772 );
afe42d0… ragelink 773
afe42d0… ragelink 774 // Support: IE <=9 only
afe42d0… ragelink 775 // Accessing document.activeElement can throw unexpectedly
afe42d0… ragelink 776 // https://bugs.jquery.com/ticket/13393
afe42d0… ragelink 777 function safeActiveElement() {
afe42d0… ragelink 778 try {
afe42d0… ragelink 779 return document.activeElement;
afe42d0… ragelink 780 } catch ( err ) { }
afe42d0… ragelink 781 }
afe42d0… ragelink 782
afe42d0… ragelink 783 // Optimize for push.apply( _, NodeList )
afe42d0… ragelink 784 try {
afe42d0… ragelink 785 push.apply(
afe42d0… ragelink 786 ( arr = slice.call( preferredDoc.childNodes ) ),
afe42d0… ragelink 787 preferredDoc.childNodes
afe42d0… ragelink 788 );
afe42d0… ragelink 789
afe42d0… ragelink 790 // Support: Android <=4.0
afe42d0… ragelink 791 // Detect silently failing push.apply
afe42d0… ragelink 792 // eslint-disable-next-line no-unused-expressions
afe42d0… ragelink 793 arr[ preferredDoc.childNodes.length ].nodeType;
afe42d0… ragelink 794 } catch ( e ) {
afe42d0… ragelink 795 push = {
afe42d0… ragelink 796 apply: function( target, els ) {
afe42d0… ragelink 797 pushNative.apply( target, slice.call( els ) );
afe42d0… ragelink 798 },
afe42d0… ragelink 799 call: function( target ) {
afe42d0… ragelink 800 pushNative.apply( target, slice.call( arguments, 1 ) );
afe42d0… ragelink 801 }
afe42d0… ragelink 802 };
afe42d0… ragelink 803 }
afe42d0… ragelink 804
afe42d0… ragelink 805 function find( selector, context, results, seed ) {
afe42d0… ragelink 806 var m, i, elem, nid, match, groups, newSelector,
afe42d0… ragelink 807 newContext = context && context.ownerDocument,
afe42d0… ragelink 808
afe42d0… ragelink 809 // nodeType defaults to 9, since context defaults to document
afe42d0… ragelink 810 nodeType = context ? context.nodeType : 9;
afe42d0… ragelink 811
afe42d0… ragelink 812 results = results || [];
afe42d0… ragelink 813
afe42d0… ragelink 814 // Return early from calls with invalid selector or context
afe42d0… ragelink 815 if ( typeof selector !== "string" || !selector ||
afe42d0… ragelink 816 nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
afe42d0… ragelink 817
afe42d0… ragelink 818 return results;
afe42d0… ragelink 819 }
afe42d0… ragelink 820
afe42d0… ragelink 821 // Try to shortcut find operations (as opposed to filters) in HTML documents
afe42d0… ragelink 822 if ( !seed ) {
afe42d0… ragelink 823 setDocument( context );
afe42d0… ragelink 824 context = context || document;
afe42d0… ragelink 825
afe42d0… ragelink 826 if ( documentIsHTML ) {
afe42d0… ragelink 827
afe42d0… ragelink 828 // If the selector is sufficiently simple, try using a "get*By*" DOM method
afe42d0… ragelink 829 // (excepting DocumentFragment context, where the methods don't exist)
afe42d0… ragelink 830 if ( nodeType !== 11 && ( match = rquickExpr.exec( selector ) ) ) {
afe42d0… ragelink 831
afe42d0… ragelink 832 // ID selector
afe42d0… ragelink 833 if ( ( m = match[ 1 ] ) ) {
afe42d0… ragelink 834
afe42d0… ragelink 835 // Document context
afe42d0… ragelink 836 if ( nodeType === 9 ) {
afe42d0… ragelink 837 if ( ( elem = context.getElementById( m ) ) ) {
afe42d0… ragelink 838
afe42d0… ragelink 839 // Support: IE 9 only
afe42d0… ragelink 840 // getElementById can match elements by name instead of ID
afe42d0… ragelink 841 if ( elem.id === m ) {
afe42d0… ragelink 842 push.call( results, elem );
afe42d0… ragelink 843 return results;
afe42d0… ragelink 844 }
afe42d0… ragelink 845 } else {
afe42d0… ragelink 846 return results;
afe42d0… ragelink 847 }
afe42d0… ragelink 848
afe42d0… ragelink 849 // Element context
afe42d0… ragelink 850 } else {
afe42d0… ragelink 851
afe42d0… ragelink 852 // Support: IE 9 only
afe42d0… ragelink 853 // getElementById can match elements by name instead of ID
afe42d0… ragelink 854 if ( newContext && ( elem = newContext.getElementById( m ) ) &&
afe42d0… ragelink 855 find.contains( context, elem ) &&
afe42d0… ragelink 856 elem.id === m ) {
afe42d0… ragelink 857
afe42d0… ragelink 858 push.call( results, elem );
afe42d0… ragelink 859 return results;
afe42d0… ragelink 860 }
afe42d0… ragelink 861 }
afe42d0… ragelink 862
afe42d0… ragelink 863 // Type selector
afe42d0… ragelink 864 } else if ( match[ 2 ] ) {
afe42d0… ragelink 865 push.apply( results, context.getElementsByTagName( selector ) );
afe42d0… ragelink 866 return results;
afe42d0… ragelink 867
afe42d0… ragelink 868 // Class selector
afe42d0… ragelink 869 } else if ( ( m = match[ 3 ] ) && context.getElementsByClassName ) {
afe42d0… ragelink 870 push.apply( results, context.getElementsByClassName( m ) );
afe42d0… ragelink 871 return results;
afe42d0… ragelink 872 }
afe42d0… ragelink 873 }
afe42d0… ragelink 874
afe42d0… ragelink 875 // Take advantage of querySelectorAll
afe42d0… ragelink 876 if ( !nonnativeSelectorCache[ selector + " " ] &&
afe42d0… ragelink 877 ( !rbuggyQSA || !rbuggyQSA.test( selector ) ) ) {
afe42d0… ragelink 878
afe42d0… ragelink 879 newSelector = selector;
afe42d0… ragelink 880 newContext = context;
afe42d0… ragelink 881
afe42d0… ragelink 882 // qSA considers elements outside a scoping root when evaluating child or
afe42d0… ragelink 883 // descendant combinators, which is not what we want.
afe42d0… ragelink 884 // In such cases, we work around the behavior by prefixing every selector in the
afe42d0… ragelink 885 // list with an ID selector referencing the scope context.
afe42d0… ragelink 886 // The technique has to be used as well when a leading combinator is used
afe42d0… ragelink 887 // as such selectors are not recognized by querySelectorAll.
afe42d0… ragelink 888 // Thanks to Andrew Dupont for this technique.
afe42d0… ragelink 889 if ( nodeType === 1 &&
afe42d0… ragelink 890 ( rdescend.test( selector ) || rleadingCombinator.test( selector ) ) ) {
afe42d0… ragelink 891
afe42d0… ragelink 892 // Expand context for sibling selectors
afe42d0… ragelink 893 newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
afe42d0… ragelink 894 context;
afe42d0… ragelink 895
afe42d0… ragelink 896 // We can use :scope instead of the ID hack if the browser
afe42d0… ragelink 897 // supports it & if we're not changing the context.
afe42d0… ragelink 898 // Support: IE 11+, Edge 17 - 18+
afe42d0… ragelink 899 // IE/Edge sometimes throw a "Permission denied" error when
afe42d0… ragelink 900 // strict-comparing two documents; shallow comparisons work.
afe42d0… ragelink 901 // eslint-disable-next-line eqeqeq
afe42d0… ragelink 902 if ( newContext != context || !support.scope ) {
afe42d0… ragelink 903
afe42d0… ragelink 904 // Capture the context ID, setting it first if necessary
afe42d0… ragelink 905 if ( ( nid = context.getAttribute( "id" ) ) ) {
afe42d0… ragelink 906 nid = jQuery.escapeSelector( nid );
afe42d0… ragelink 907 } else {
afe42d0… ragelink 908 context.setAttribute( "id", ( nid = expando ) );
afe42d0… ragelink 909 }
afe42d0… ragelink 910 }
afe42d0… ragelink 911
afe42d0… ragelink 912 // Prefix every selector in the list
afe42d0… ragelink 913 groups = tokenize( selector );
afe42d0… ragelink 914 i = groups.length;
afe42d0… ragelink 915 while ( i-- ) {
afe42d0… ragelink 916 groups[ i ] = ( nid ? "#" + nid : ":scope" ) + " " +
afe42d0… ragelink 917 toSelector( groups[ i ] );
afe42d0… ragelink 918 }
afe42d0… ragelink 919 newSelector = groups.join( "," );
afe42d0… ragelink 920 }
afe42d0… ragelink 921
afe42d0… ragelink 922 try {
afe42d0… ragelink 923 push.apply( results,
afe42d0… ragelink 924 newContext.querySelectorAll( newSelector )
afe42d0… ragelink 925 );
afe42d0… ragelink 926 return results;
afe42d0… ragelink 927 } catch ( qsaError ) {
afe42d0… ragelink 928 nonnativeSelectorCache( selector, true );
afe42d0… ragelink 929 } finally {
afe42d0… ragelink 930 if ( nid === expando ) {
afe42d0… ragelink 931 context.removeAttribute( "id" );
afe42d0… ragelink 932 }
afe42d0… ragelink 933 }
afe42d0… ragelink 934 }
afe42d0… ragelink 935 }
afe42d0… ragelink 936 }
afe42d0… ragelink 937
afe42d0… ragelink 938 // All others
afe42d0… ragelink 939 return select( selector.replace( rtrimCSS, "$1" ), context, results, seed );
afe42d0… ragelink 940 }
afe42d0… ragelink 941
afe42d0… ragelink 942 /**
afe42d0… ragelink 943 * Create key-value caches of limited size
afe42d0… ragelink 944 * @returns {function(string, object)} Returns the Object data after storing it on itself with
afe42d0… ragelink 945 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
afe42d0… ragelink 946 * deleting the oldest entry
afe42d0… ragelink 947 */
afe42d0… ragelink 948 function createCache() {
afe42d0… ragelink 949 var keys = [];
afe42d0… ragelink 950
afe42d0… ragelink 951 function cache( key, value ) {
afe42d0… ragelink 952
afe42d0… ragelink 953 // Use (key + " ") to avoid collision with native prototype properties
afe42d0… ragelink 954 // (see https://github.com/jquery/sizzle/issues/157)
afe42d0… ragelink 955 if ( keys.push( key + " " ) > Expr.cacheLength ) {
afe42d0… ragelink 956
afe42d0… ragelink 957 // Only keep the most recent entries
afe42d0… ragelink 958 delete cache[ keys.shift() ];
afe42d0… ragelink 959 }
afe42d0… ragelink 960 return ( cache[ key + " " ] = value );
afe42d0… ragelink 961 }
afe42d0… ragelink 962 return cache;
afe42d0… ragelink 963 }
afe42d0… ragelink 964
afe42d0… ragelink 965 /**
afe42d0… ragelink 966 * Mark a function for special use by jQuery selector module
afe42d0… ragelink 967 * @param {Function} fn The function to mark
afe42d0… ragelink 968 */
afe42d0… ragelink 969 function markFunction( fn ) {
afe42d0… ragelink 970 fn[ expando ] = true;
afe42d0… ragelink 971 return fn;
afe42d0… ragelink 972 }
afe42d0… ragelink 973
afe42d0… ragelink 974 /**
afe42d0… ragelink 975 * Support testing using an element
afe42d0… ragelink 976 * @param {Function} fn Passed the created element and returns a boolean result
afe42d0… ragelink 977 */
afe42d0… ragelink 978 function assert( fn ) {
afe42d0… ragelink 979 var el = document.createElement( "fieldset" );
afe42d0… ragelink 980
afe42d0… ragelink 981 try {
afe42d0… ragelink 982 return !!fn( el );
afe42d0… ragelink 983 } catch ( e ) {
afe42d0… ragelink 984 return false;
afe42d0… ragelink 985 } finally {
afe42d0… ragelink 986
afe42d0… ragelink 987 // Remove from its parent by default
afe42d0… ragelink 988 if ( el.parentNode ) {
afe42d0… ragelink 989 el.parentNode.removeChild( el );
afe42d0… ragelink 990 }
afe42d0… ragelink 991
afe42d0… ragelink 992 // release memory in IE
afe42d0… ragelink 993 el = null;
afe42d0… ragelink 994 }
afe42d0… ragelink 995 }
afe42d0… ragelink 996
afe42d0… ragelink 997 /**
afe42d0… ragelink 998 * Returns a function to use in pseudos for input types
afe42d0… ragelink 999 * @param {String} type
afe42d0… ragelink 1000 */
afe42d0… ragelink 1001 function createInputPseudo( type ) {
afe42d0… ragelink 1002 return function( elem ) {
afe42d0… ragelink 1003 return nodeName( elem, "input" ) && elem.type === type;
afe42d0… ragelink 1004 };
afe42d0… ragelink 1005 }
afe42d0… ragelink 1006
afe42d0… ragelink 1007 /**
afe42d0… ragelink 1008 * Returns a function to use in pseudos for buttons
afe42d0… ragelink 1009 * @param {String} type
afe42d0… ragelink 1010 */
afe42d0… ragelink 1011 function createButtonPseudo( type ) {
afe42d0… ragelink 1012 return function( elem ) {
afe42d0… ragelink 1013 return ( nodeName( elem, "input" ) || nodeName( elem, "button" ) ) &&
afe42d0… ragelink 1014 elem.type === type;
afe42d0… ragelink 1015 };
afe42d0… ragelink 1016 }
afe42d0… ragelink 1017
afe42d0… ragelink 1018 /**
afe42d0… ragelink 1019 * Returns a function to use in pseudos for :enabled/:disabled
afe42d0… ragelink 1020 * @param {Boolean} disabled true for :disabled; false for :enabled
afe42d0… ragelink 1021 */
afe42d0… ragelink 1022 function createDisabledPseudo( disabled ) {
afe42d0… ragelink 1023
afe42d0… ragelink 1024 // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
afe42d0… ragelink 1025 return function( elem ) {
afe42d0… ragelink 1026
afe42d0… ragelink 1027 // Only certain elements can match :enabled or :disabled
afe42d0… ragelink 1028 // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
afe42d0… ragelink 1029 // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
afe42d0… ragelink 1030 if ( "form" in elem ) {
afe42d0… ragelink 1031
afe42d0… ragelink 1032 // Check for inherited disabledness on relevant non-disabled elements:
afe42d0… ragelink 1033 // * listed form-associated elements in a disabled fieldset
afe42d0… ragelink 1034 // https://html.spec.whatwg.org/multipage/forms.html#category-listed
afe42d0… ragelink 1035 // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
afe42d0… ragelink 1036 // * option elements in a disabled optgroup
afe42d0… ragelink 1037 // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
afe42d0… ragelink 1038 // All such elements have a "form" property.
afe42d0… ragelink 1039 if ( elem.parentNode && elem.disabled === false ) {
afe42d0… ragelink 1040
afe42d0… ragelink 1041 // Option elements defer to a parent optgroup if present
afe42d0… ragelink 1042 if ( "label" in elem ) {
afe42d0… ragelink 1043 if ( "label" in elem.parentNode ) {
afe42d0… ragelink 1044 return elem.parentNode.disabled === disabled;
afe42d0… ragelink 1045 } else {
afe42d0… ragelink 1046 return elem.disabled === disabled;
afe42d0… ragelink 1047 }
afe42d0… ragelink 1048 }
afe42d0… ragelink 1049
afe42d0… ragelink 1050 // Support: IE 6 - 11+
afe42d0… ragelink 1051 // Use the isDisabled shortcut property to check for disabled fieldset ancestors
afe42d0… ragelink 1052 return elem.isDisabled === disabled ||
afe42d0… ragelink 1053
afe42d0… ragelink 1054 // Where there is no isDisabled, check manually
afe42d0… ragelink 1055 elem.isDisabled !== !disabled &&
afe42d0… ragelink 1056 inDisabledFieldset( elem ) === disabled;
afe42d0… ragelink 1057 }
afe42d0… ragelink 1058
afe42d0… ragelink 1059 return elem.disabled === disabled;
afe42d0… ragelink 1060
afe42d0… ragelink 1061 // Try to winnow out elements that can't be disabled before trusting the disabled property.
afe42d0… ragelink 1062 // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
afe42d0… ragelink 1063 // even exist on them, let alone have a boolean value.
afe42d0… ragelink 1064 } else if ( "label" in elem ) {
afe42d0… ragelink 1065 return elem.disabled === disabled;
afe42d0… ragelink 1066 }
afe42d0… ragelink 1067
afe42d0… ragelink 1068 // Remaining elements are neither :enabled nor :disabled
afe42d0… ragelink 1069 return false;
afe42d0… ragelink 1070 };
afe42d0… ragelink 1071 }
afe42d0… ragelink 1072
afe42d0… ragelink 1073 /**
afe42d0… ragelink 1074 * Returns a function to use in pseudos for positionals
afe42d0… ragelink 1075 * @param {Function} fn
afe42d0… ragelink 1076 */
afe42d0… ragelink 1077 function createPositionalPseudo( fn ) {
afe42d0… ragelink 1078 return markFunction( function( argument ) {
afe42d0… ragelink 1079 argument = +argument;
afe42d0… ragelink 1080 return markFunction( function( seed, matches ) {
afe42d0… ragelink 1081 var j,
afe42d0… ragelink 1082 matchIndexes = fn( [], seed.length, argument ),
afe42d0… ragelink 1083 i = matchIndexes.length;
afe42d0… ragelink 1084
afe42d0… ragelink 1085 // Match elements found at the specified indexes
afe42d0… ragelink 1086 while ( i-- ) {
afe42d0… ragelink 1087 if ( seed[ ( j = matchIndexes[ i ] ) ] ) {
afe42d0… ragelink 1088 seed[ j ] = !( matches[ j ] = seed[ j ] );
afe42d0… ragelink 1089 }
afe42d0… ragelink 1090 }
afe42d0… ragelink 1091 } );
afe42d0… ragelink 1092 } );
afe42d0… ragelink 1093 }
afe42d0… ragelink 1094
afe42d0… ragelink 1095 /**
afe42d0… ragelink 1096 * Checks a node for validity as a jQuery selector context
afe42d0… ragelink 1097 * @param {Element|Object=} context
afe42d0… ragelink 1098 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
afe42d0… ragelink 1099 */
afe42d0… ragelink 1100 function testContext( context ) {
afe42d0… ragelink 1101 return context && typeof context.getElementsByTagName !== "undefined" && context;
afe42d0… ragelink 1102 }
afe42d0… ragelink 1103
afe42d0… ragelink 1104 /**
afe42d0… ragelink 1105 * Sets document-related variables once based on the current document
afe42d0… ragelink 1106 * @param {Element|Object} [node] An element or document object to use to set the document
afe42d0… ragelink 1107 * @returns {Object} Returns the current document
afe42d0… ragelink 1108 */
afe42d0… ragelink 1109 function setDocument( node ) {
afe42d0… ragelink 1110 var subWindow,
afe42d0… ragelink 1111 doc = node ? node.ownerDocument || node : preferredDoc;
afe42d0… ragelink 1112
afe42d0… ragelink 1113 // Return early if doc is invalid or already selected
afe42d0… ragelink 1114 // Support: IE 11+, Edge 17 - 18+
afe42d0… ragelink 1115 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
afe42d0… ragelink 1116 // two documents; shallow comparisons work.
afe42d0… ragelink 1117 // eslint-disable-next-line eqeqeq
afe42d0… ragelink 1118 if ( doc == document || doc.nodeType !== 9 || !doc.documentElement ) {
afe42d0… ragelink 1119 return document;
afe42d0… ragelink 1120 }
afe42d0… ragelink 1121
afe42d0… ragelink 1122 // Update global variables
afe42d0… ragelink 1123 document = doc;
afe42d0… ragelink 1124 documentElement = document.documentElement;
afe42d0… ragelink 1125 documentIsHTML = !jQuery.isXMLDoc( document );
afe42d0… ragelink 1126
afe42d0… ragelink 1127 // Support: iOS 7 only, IE 9 - 11+
afe42d0… ragelink 1128 // Older browsers didn't support unprefixed `matches`.
afe42d0… ragelink 1129 matches = documentElement.matches ||
afe42d0… ragelink 1130 documentElement.webkitMatchesSelector ||
afe42d0… ragelink 1131 documentElement.msMatchesSelector;
afe42d0… ragelink 1132
afe42d0… ragelink 1133 // Support: IE 9 - 11+, Edge 12 - 18+
afe42d0… ragelink 1134 // Accessing iframe documents after unload throws "permission denied" errors
afe42d0… ragelink 1135 // (see trac-13936).
afe42d0… ragelink 1136 // Limit the fix to IE & Edge Legacy; despite Edge 15+ implementing `matches`,
afe42d0… ragelink 1137 // all IE 9+ and Edge Legacy versions implement `msMatchesSelector` as well.
afe42d0… ragelink 1138 if ( documentElement.msMatchesSelector &&
afe42d0… ragelink 1139
afe42d0… ragelink 1140 // Support: IE 11+, Edge 17 - 18+
afe42d0… ragelink 1141 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
afe42d0… ragelink 1142 // two documents; shallow comparisons work.
afe42d0… ragelink 1143 // eslint-disable-next-line eqeqeq
afe42d0… ragelink 1144 preferredDoc != document &&
afe42d0… ragelink 1145 ( subWindow = document.defaultView ) && subWindow.top !== subWindow ) {
afe42d0… ragelink 1146
afe42d0… ragelink 1147 // Support: IE 9 - 11+, Edge 12 - 18+
afe42d0… ragelink 1148 subWindow.addEventListener( "unload", unloadHandler );
afe42d0… ragelink 1149 }
afe42d0… ragelink 1150
afe42d0… ragelink 1151 // Support: IE <10
afe42d0… ragelink 1152 // Check if getElementById returns elements by name
afe42d0… ragelink 1153 // The broken getElementById methods don't pick up programmatically-set names,
afe42d0… ragelink 1154 // so use a roundabout getElementsByName test
afe42d0… ragelink 1155 support.getById = assert( function( el ) {
afe42d0… ragelink 1156 documentElement.appendChild( el ).id = jQuery.expando;
afe42d0… ragelink 1157 return !document.getElementsByName ||
afe42d0… ragelink 1158 !document.getElementsByName( jQuery.expando ).length;
afe42d0… ragelink 1159 } );
afe42d0… ragelink 1160
afe42d0… ragelink 1161 // Support: IE 9 only
afe42d0… ragelink 1162 // Check to see if it's possible to do matchesSelector
afe42d0… ragelink 1163 // on a disconnected node.
afe42d0… ragelink 1164 support.disconnectedMatch = assert( function( el ) {
afe42d0… ragelink 1165 return matches.call( el, "*" );
afe42d0… ragelink 1166 } );
afe42d0… ragelink 1167
afe42d0… ragelink 1168 // Support: IE 9 - 11+, Edge 12 - 18+
afe42d0… ragelink 1169 // IE/Edge don't support the :scope pseudo-class.
afe42d0… ragelink 1170 support.scope = assert( function() {
afe42d0… ragelink 1171 return document.querySelectorAll( ":scope" );
afe42d0… ragelink 1172 } );
afe42d0… ragelink 1173
afe42d0… ragelink 1174 // Support: Chrome 105 - 111 only, Safari 15.4 - 16.3 only
afe42d0… ragelink 1175 // Make sure the `:has()` argument is parsed unforgivingly.
afe42d0… ragelink 1176 // We include `*` in the test to detect buggy implementations that are
afe42d0… ragelink 1177 // _selectively_ forgiving (specifically when the list includes at least
afe42d0… ragelink 1178 // one valid selector).
afe42d0… ragelink 1179 // Note that we treat complete lack of support for `:has()` as if it were
afe42d0… ragelink 1180 // spec-compliant support, which is fine because use of `:has()` in such
afe42d0… ragelink 1181 // environments will fail in the qSA path and fall back to jQuery traversal
afe42d0… ragelink 1182 // anyway.
afe42d0… ragelink 1183 support.cssHas = assert( function() {
afe42d0… ragelink 1184 try {
afe42d0… ragelink 1185 document.querySelector( ":has(*,:jqfake)" );
afe42d0… ragelink 1186 return false;
afe42d0… ragelink 1187 } catch ( e ) {
afe42d0… ragelink 1188 return true;
afe42d0… ragelink 1189 }
afe42d0… ragelink 1190 } );
afe42d0… ragelink 1191
afe42d0… ragelink 1192 // ID filter and find
afe42d0… ragelink 1193 if ( support.getById ) {
afe42d0… ragelink 1194 Expr.filter.ID = function( id ) {
afe42d0… ragelink 1195 var attrId = id.replace( runescape, funescape );
afe42d0… ragelink 1196 return function( elem ) {
afe42d0… ragelink 1197 return elem.getAttribute( "id" ) === attrId;
afe42d0… ragelink 1198 };
afe42d0… ragelink 1199 };
afe42d0… ragelink 1200 Expr.find.ID = function( id, context ) {
afe42d0… ragelink 1201 if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
afe42d0… ragelink 1202 var elem = context.getElementById( id );
afe42d0… ragelink 1203 return elem ? [ elem ] : [];
afe42d0… ragelink 1204 }
afe42d0… ragelink 1205 };
afe42d0… ragelink 1206 } else {
afe42d0… ragelink 1207 Expr.filter.ID = function( id ) {
afe42d0… ragelink 1208 var attrId = id.replace( runescape, funescape );
afe42d0… ragelink 1209 return function( elem ) {
afe42d0… ragelink 1210 var node = typeof elem.getAttributeNode !== "undefined" &&
afe42d0… ragelink 1211 elem.getAttributeNode( "id" );
afe42d0… ragelink 1212 return node && node.value === attrId;
afe42d0… ragelink 1213 };
afe42d0… ragelink 1214 };
afe42d0… ragelink 1215
afe42d0… ragelink 1216 // Support: IE 6 - 7 only
afe42d0… ragelink 1217 // getElementById is not reliable as a find shortcut
afe42d0… ragelink 1218 Expr.find.ID = function( id, context ) {
afe42d0… ragelink 1219 if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
afe42d0… ragelink 1220 var node, i, elems,
afe42d0… ragelink 1221 elem = context.getElementById( id );
afe42d0… ragelink 1222
afe42d0… ragelink 1223 if ( elem ) {
afe42d0… ragelink 1224
afe42d0… ragelink 1225 // Verify the id attribute
afe42d0… ragelink 1226 node = elem.getAttributeNode( "id" );
afe42d0… ragelink 1227 if ( node && node.value === id ) {
afe42d0… ragelink 1228 return [ elem ];
afe42d0… ragelink 1229 }
afe42d0… ragelink 1230
afe42d0… ragelink 1231 // Fall back on getElementsByName
afe42d0… ragelink 1232 elems = context.getElementsByName( id );
afe42d0… ragelink 1233 i = 0;
afe42d0… ragelink 1234 while ( ( elem = elems[ i++ ] ) ) {
afe42d0… ragelink 1235 node = elem.getAttributeNode( "id" );
afe42d0… ragelink 1236 if ( node && node.value === id ) {
afe42d0… ragelink 1237 return [ elem ];
afe42d0… ragelink 1238 }
afe42d0… ragelink 1239 }
afe42d0… ragelink 1240 }
afe42d0… ragelink 1241
afe42d0… ragelink 1242 return [];
afe42d0… ragelink 1243 }
afe42d0… ragelink 1244 };
afe42d0… ragelink 1245 }
afe42d0… ragelink 1246
afe42d0… ragelink 1247 // Tag
afe42d0… ragelink 1248 Expr.find.TAG = function( tag, context ) {
afe42d0… ragelink 1249 if ( typeof context.getElementsByTagName !== "undefined" ) {
afe42d0… ragelink 1250 return context.getElementsByTagName( tag );
afe42d0… ragelink 1251
afe42d0… ragelink 1252 // DocumentFragment nodes don't have gEBTN
afe42d0… ragelink 1253 } else {
afe42d0… ragelink 1254 return context.querySelectorAll( tag );
afe42d0… ragelink 1255 }
afe42d0… ragelink 1256 };
afe42d0… ragelink 1257
afe42d0… ragelink 1258 // Class
afe42d0… ragelink 1259 Expr.find.CLASS = function( className, context ) {
afe42d0… ragelink 1260 if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
afe42d0… ragelink 1261 return context.getElementsByClassName( className );
afe42d0… ragelink 1262 }
afe42d0… ragelink 1263 };
afe42d0… ragelink 1264
afe42d0… ragelink 1265 /* QSA/matchesSelector
afe42d0… ragelink 1266 ---------------------------------------------------------------------- */
afe42d0… ragelink 1267
afe42d0… ragelink 1268 // QSA and matchesSelector support
afe42d0… ragelink 1269
afe42d0… ragelink 1270 rbuggyQSA = [];
afe42d0… ragelink 1271
afe42d0… ragelink 1272 // Build QSA regex
afe42d0… ragelink 1273 // Regex strategy adopted from Diego Perini
afe42d0… ragelink 1274 assert( function( el ) {
afe42d0… ragelink 1275
afe42d0… ragelink 1276 var input;
afe42d0… ragelink 1277
afe42d0… ragelink 1278 documentElement.appendChild( el ).innerHTML =
afe42d0… ragelink 1279 "<a id='" + expando + "' href='' disabled='disabled'></a>" +
afe42d0… ragelink 1280 "<select id='" + expando + "-\r\\' disabled='disabled'>" +
afe42d0… ragelink 1281 "<option selected=''></option></select>";
afe42d0… ragelink 1282
afe42d0… ragelink 1283 // Support: iOS <=7 - 8 only
afe42d0… ragelink 1284 // Boolean attributes and "value" are not treated correctly in some XML documents
afe42d0… ragelink 1285 if ( !el.querySelectorAll( "[selected]" ).length ) {
afe42d0… ragelink 1286 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
afe42d0… ragelink 1287 }
afe42d0… ragelink 1288
afe42d0… ragelink 1289 // Support: iOS <=7 - 8 only
afe42d0… ragelink 1290 if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
afe42d0… ragelink 1291 rbuggyQSA.push( "~=" );
afe42d0… ragelink 1292 }
afe42d0… ragelink 1293
afe42d0… ragelink 1294 // Support: iOS 8 only
afe42d0… ragelink 1295 // https://bugs.webkit.org/show_bug.cgi?id=136851
afe42d0… ragelink 1296 // In-page `selector#id sibling-combinator selector` fails
afe42d0… ragelink 1297 if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
afe42d0… ragelink 1298 rbuggyQSA.push( ".#.+[+~]" );
afe42d0… ragelink 1299 }
afe42d0… ragelink 1300
afe42d0… ragelink 1301 // Support: Chrome <=105+, Firefox <=104+, Safari <=15.4+
afe42d0… ragelink 1302 // In some of the document kinds, these selectors wouldn't work natively.
afe42d0… ragelink 1303 // This is probably OK but for backwards compatibility we want to maintain
afe42d0… ragelink 1304 // handling them through jQuery traversal in jQuery 3.x.
afe42d0… ragelink 1305 if ( !el.querySelectorAll( ":checked" ).length ) {
afe42d0… ragelink 1306 rbuggyQSA.push( ":checked" );
afe42d0… ragelink 1307 }
afe42d0… ragelink 1308
afe42d0… ragelink 1309 // Support: Windows 8 Native Apps
afe42d0… ragelink 1310 // The type and name attributes are restricted during .innerHTML assignment
afe42d0… ragelink 1311 input = document.createElement( "input" );
afe42d0… ragelink 1312 input.setAttribute( "type", "hidden" );
afe42d0… ragelink 1313 el.appendChild( input ).setAttribute( "name", "D" );
afe42d0… ragelink 1314
afe42d0… ragelink 1315 // Support: IE 9 - 11+
afe42d0… ragelink 1316 // IE's :disabled selector does not pick up the children of disabled fieldsets
afe42d0… ragelink 1317 // Support: Chrome <=105+, Firefox <=104+, Safari <=15.4+
afe42d0… ragelink 1318 // In some of the document kinds, these selectors wouldn't work natively.
afe42d0… ragelink 1319 // This is probably OK but for backwards compatibility we want to maintain
afe42d0… ragelink 1320 // handling them through jQuery traversal in jQuery 3.x.
afe42d0… ragelink 1321 documentElement.appendChild( el ).disabled = true;
afe42d0… ragelink 1322 if ( el.querySelectorAll( ":disabled" ).length !== 2 ) {
afe42d0… ragelink 1323 rbuggyQSA.push( ":enabled", ":disabled" );
afe42d0… ragelink 1324 }
afe42d0… ragelink 1325
afe42d0… ragelink 1326 // Support: IE 11+, Edge 15 - 18+
afe42d0… ragelink 1327 // IE 11/Edge don't find elements on a `[name='']` query in some cases.
afe42d0… ragelink 1328 // Adding a temporary attribute to the document before the selection works
afe42d0… ragelink 1329 // around the issue.
afe42d0… ragelink 1330 // Interestingly, IE 10 & older don't seem to have the issue.
afe42d0… ragelink 1331 input = document.createElement( "input" );
afe42d0… ragelink 1332 input.setAttribute( "name", "" );
afe42d0… ragelink 1333 el.appendChild( input );
afe42d0… ragelink 1334 if ( !el.querySelectorAll( "[name='']" ).length ) {
afe42d0… ragelink 1335 rbuggyQSA.push( "\\[" + whitespace + "*name" + whitespace + "*=" +
afe42d0… ragelink 1336 whitespace + "*(?:''|\"\")" );
afe42d0… ragelink 1337 }
afe42d0… ragelink 1338 } );
afe42d0… ragelink 1339
afe42d0… ragelink 1340 if ( !support.cssHas ) {
afe42d0… ragelink 1341
afe42d0… ragelink 1342 // Support: Chrome 105 - 110+, Safari 15.4 - 16.3+
afe42d0… ragelink 1343 // Our regular `try-catch` mechanism fails to detect natively-unsupported
afe42d0… ragelink 1344 // pseudo-classes inside `:has()` (such as `:has(:contains("Foo"))`)
afe42d0… ragelink 1345 // in browsers that parse the `:has()` argument as a forgiving selector list.
afe42d0… ragelink 1346 // https://drafts.csswg.org/selectors/#relational now requires the argument
afe42d0… ragelink 1347 // to be parsed unforgivingly, but browsers have not yet fully adjusted.
afe42d0… ragelink 1348 rbuggyQSA.push( ":has" );
afe42d0… ragelink 1349 }
afe42d0… ragelink 1350
afe42d0… ragelink 1351 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join( "|" ) );
afe42d0… ragelink 1352
afe42d0… ragelink 1353 /* Sorting
afe42d0… ragelink 1354 ---------------------------------------------------------------------- */
afe42d0… ragelink 1355
afe42d0… ragelink 1356 // Document order sorting
afe42d0… ragelink 1357 sortOrder = function( a, b ) {
afe42d0… ragelink 1358
afe42d0… ragelink 1359 // Flag for duplicate removal
afe42d0… ragelink 1360 if ( a === b ) {
afe42d0… ragelink 1361 hasDuplicate = true;
afe42d0… ragelink 1362 return 0;
afe42d0… ragelink 1363 }
afe42d0… ragelink 1364
afe42d0… ragelink 1365 // Sort on method existence if only one input has compareDocumentPosition
afe42d0… ragelink 1366 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
afe42d0… ragelink 1367 if ( compare ) {
afe42d0… ragelink 1368 return compare;
afe42d0… ragelink 1369 }
afe42d0… ragelink 1370
afe42d0… ragelink 1371 // Calculate position if both inputs belong to the same document
afe42d0… ragelink 1372 // Support: IE 11+, Edge 17 - 18+
afe42d0… ragelink 1373 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
afe42d0… ragelink 1374 // two documents; shallow comparisons work.
afe42d0… ragelink 1375 // eslint-disable-next-line eqeqeq
afe42d0… ragelink 1376 compare = ( a.ownerDocument || a ) == ( b.ownerDocument || b ) ?
afe42d0… ragelink 1377 a.compareDocumentPosition( b ) :
afe42d0… ragelink 1378
afe42d0… ragelink 1379 // Otherwise we know they are disconnected
afe42d0… ragelink 1380 1;
afe42d0… ragelink 1381
afe42d0… ragelink 1382 // Disconnected nodes
afe42d0… ragelink 1383 if ( compare & 1 ||
afe42d0… ragelink 1384 ( !support.sortDetached && b.compareDocumentPosition( a ) === compare ) ) {
afe42d0… ragelink 1385
afe42d0… ragelink 1386 // Choose the first element that is related to our preferred document
afe42d0… ragelink 1387 // Support: IE 11+, Edge 17 - 18+
afe42d0… ragelink 1388 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
afe42d0… ragelink 1389 // two documents; shallow comparisons work.
afe42d0… ragelink 1390 // eslint-disable-next-line eqeqeq
afe42d0… ragelink 1391 if ( a === document || a.ownerDocument == preferredDoc &&
afe42d0… ragelink 1392 find.contains( preferredDoc, a ) ) {
afe42d0… ragelink 1393 return -1;
afe42d0… ragelink 1394 }
afe42d0… ragelink 1395
afe42d0… ragelink 1396 // Support: IE 11+, Edge 17 - 18+
afe42d0… ragelink 1397 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
afe42d0… ragelink 1398 // two documents; shallow comparisons work.
afe42d0… ragelink 1399 // eslint-disable-next-line eqeqeq
afe42d0… ragelink 1400 if ( b === document || b.ownerDocument == preferredDoc &&
afe42d0… ragelink 1401 find.contains( preferredDoc, b ) ) {
afe42d0… ragelink 1402 return 1;
afe42d0… ragelink 1403 }
afe42d0… ragelink 1404
afe42d0… ragelink 1405 // Maintain original order
afe42d0… ragelink 1406 return sortInput ?
afe42d0… ragelink 1407 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
afe42d0… ragelink 1408 0;
afe42d0… ragelink 1409 }
afe42d0… ragelink 1410
afe42d0… ragelink 1411 return compare & 4 ? -1 : 1;
afe42d0… ragelink 1412 };
afe42d0… ragelink 1413
afe42d0… ragelink 1414 return document;
afe42d0… ragelink 1415 }
afe42d0… ragelink 1416
afe42d0… ragelink 1417 find.matches = function( expr, elements ) {
afe42d0… ragelink 1418 return find( expr, null, null, elements );
afe42d0… ragelink 1419 };
afe42d0… ragelink 1420
afe42d0… ragelink 1421 find.matchesSelector = function( elem, expr ) {
afe42d0… ragelink 1422 setDocument( elem );
afe42d0… ragelink 1423
afe42d0… ragelink 1424 if ( documentIsHTML &&
afe42d0… ragelink 1425 !nonnativeSelectorCache[ expr + " " ] &&
afe42d0… ragelink 1426 ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
afe42d0… ragelink 1427
afe42d0… ragelink 1428 try {
afe42d0… ragelink 1429 var ret = matches.call( elem, expr );
afe42d0… ragelink 1430
afe42d0… ragelink 1431 // IE 9's matchesSelector returns false on disconnected nodes
afe42d0… ragelink 1432 if ( ret || support.disconnectedMatch ||
afe42d0… ragelink 1433
afe42d0… ragelink 1434 // As well, disconnected nodes are said to be in a document
afe42d0… ragelink 1435 // fragment in IE 9
afe42d0… ragelink 1436 elem.document && elem.document.nodeType !== 11 ) {
afe42d0… ragelink 1437 return ret;
afe42d0… ragelink 1438 }
afe42d0… ragelink 1439 } catch ( e ) {
afe42d0… ragelink 1440 nonnativeSelectorCache( expr, true );
afe42d0… ragelink 1441 }
afe42d0… ragelink 1442 }
afe42d0… ragelink 1443
afe42d0… ragelink 1444 return find( expr, document, null, [ elem ] ).length > 0;
afe42d0… ragelink 1445 };
afe42d0… ragelink 1446
afe42d0… ragelink 1447 find.contains = function( context, elem ) {
afe42d0… ragelink 1448
afe42d0… ragelink 1449 // Set document vars if needed
afe42d0… ragelink 1450 // Support: IE 11+, Edge 17 - 18+
afe42d0… ragelink 1451 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
afe42d0… ragelink 1452 // two documents; shallow comparisons work.
afe42d0… ragelink 1453 // eslint-disable-next-line eqeqeq
afe42d0… ragelink 1454 if ( ( context.ownerDocument || context ) != document ) {
afe42d0… ragelink 1455 setDocument( context );
afe42d0… ragelink 1456 }
afe42d0… ragelink 1457 return jQuery.contains( context, elem );
afe42d0… ragelink 1458 };
afe42d0… ragelink 1459
afe42d0… ragelink 1460
afe42d0… ragelink 1461 find.attr = function( elem, name ) {
afe42d0… ragelink 1462
afe42d0… ragelink 1463 // Set document vars if needed
afe42d0… ragelink 1464 // Support: IE 11+, Edge 17 - 18+
afe42d0… ragelink 1465 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
afe42d0… ragelink 1466 // two documents; shallow comparisons work.
afe42d0… ragelink 1467 // eslint-disable-next-line eqeqeq
afe42d0… ragelink 1468 if ( ( elem.ownerDocument || elem ) != document ) {
afe42d0… ragelink 1469 setDocument( elem );
afe42d0… ragelink 1470 }
afe42d0… ragelink 1471
afe42d0… ragelink 1472 var fn = Expr.attrHandle[ name.toLowerCase() ],
afe42d0… ragelink 1473
afe42d0… ragelink 1474 // Don't get fooled by Object.prototype properties (see trac-13807)
afe42d0… ragelink 1475 val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
afe42d0… ragelink 1476 fn( elem, name, !documentIsHTML ) :
afe42d0… ragelink 1477 undefined;
afe42d0… ragelink 1478
afe42d0… ragelink 1479 if ( val !== undefined ) {
afe42d0… ragelink 1480 return val;
afe42d0… ragelink 1481 }
afe42d0… ragelink 1482
afe42d0… ragelink 1483 return elem.getAttribute( name );
afe42d0… ragelink 1484 };
afe42d0… ragelink 1485
afe42d0… ragelink 1486 find.error = function( msg ) {
afe42d0… ragelink 1487 throw new Error( "Syntax error, unrecognized expression: " + msg );
afe42d0… ragelink 1488 };
afe42d0… ragelink 1489
afe42d0… ragelink 1490 /**
afe42d0… ragelink 1491 * Document sorting and removing duplicates
afe42d0… ragelink 1492 * @param {ArrayLike} results
afe42d0… ragelink 1493 */
afe42d0… ragelink 1494 jQuery.uniqueSort = function( results ) {
afe42d0… ragelink 1495 var elem,
afe42d0… ragelink 1496 duplicates = [],
afe42d0… ragelink 1497 j = 0,
afe42d0… ragelink 1498 i = 0;
afe42d0… ragelink 1499
afe42d0… ragelink 1500 // Unless we *know* we can detect duplicates, assume their presence
afe42d0… ragelink 1501 //
afe42d0… ragelink 1502 // Support: Android <=4.0+
afe42d0… ragelink 1503 // Testing for detecting duplicates is unpredictable so instead assume we can't
afe42d0… ragelink 1504 // depend on duplicate detection in all browsers without a stable sort.
afe42d0… ragelink 1505 hasDuplicate = !support.sortStable;
afe42d0… ragelink 1506 sortInput = !support.sortStable && slice.call( results, 0 );
afe42d0… ragelink 1507 sort.call( results, sortOrder );
afe42d0… ragelink 1508
afe42d0… ragelink 1509 if ( hasDuplicate ) {
afe42d0… ragelink 1510 while ( ( elem = results[ i++ ] ) ) {
afe42d0… ragelink 1511 if ( elem === results[ i ] ) {
afe42d0… ragelink 1512 j = duplicates.push( i );
afe42d0… ragelink 1513 }
afe42d0… ragelink 1514 }
afe42d0… ragelink 1515 while ( j-- ) {
afe42d0… ragelink 1516 splice.call( results, duplicates[ j ], 1 );
afe42d0… ragelink 1517 }
afe42d0… ragelink 1518 }
afe42d0… ragelink 1519
afe42d0… ragelink 1520 // Clear input after sorting to release objects
afe42d0… ragelink 1521 // See https://github.com/jquery/sizzle/pull/225
afe42d0… ragelink 1522 sortInput = null;
afe42d0… ragelink 1523
afe42d0… ragelink 1524 return results;
afe42d0… ragelink 1525 };
afe42d0… ragelink 1526
afe42d0… ragelink 1527 jQuery.fn.uniqueSort = function() {
afe42d0… ragelink 1528 return this.pushStack( jQuery.uniqueSort( slice.apply( this ) ) );
afe42d0… ragelink 1529 };
afe42d0… ragelink 1530
afe42d0… ragelink 1531 Expr = jQuery.expr = {
afe42d0… ragelink 1532
afe42d0… ragelink 1533 // Can be adjusted by the user
afe42d0… ragelink 1534 cacheLength: 50,
afe42d0… ragelink 1535
afe42d0… ragelink 1536 createPseudo: markFunction,
afe42d0… ragelink 1537
afe42d0… ragelink 1538 match: matchExpr,
afe42d0… ragelink 1539
afe42d0… ragelink 1540 attrHandle: {},
afe42d0… ragelink 1541
afe42d0… ragelink 1542 find: {},
afe42d0… ragelink 1543
afe42d0… ragelink 1544 relative: {
afe42d0… ragelink 1545 ">": { dir: "parentNode", first: true },
afe42d0… ragelink 1546 " ": { dir: "parentNode" },
afe42d0… ragelink 1547 "+": { dir: "previousSibling", first: true },
afe42d0… ragelink 1548 "~": { dir: "previousSibling" }
afe42d0… ragelink 1549 },
afe42d0… ragelink 1550
afe42d0… ragelink 1551 preFilter: {
afe42d0… ragelink 1552 ATTR: function( match ) {
afe42d0… ragelink 1553 match[ 1 ] = match[ 1 ].replace( runescape, funescape );
afe42d0… ragelink 1554
afe42d0… ragelink 1555 // Move the given value to match[3] whether quoted or unquoted
afe42d0… ragelink 1556 match[ 3 ] = ( match[ 3 ] || match[ 4 ] || match[ 5 ] || "" )
afe42d0… ragelink 1557 .replace( runescape, funescape );
afe42d0… ragelink 1558
afe42d0… ragelink 1559 if ( match[ 2 ] === "~=" ) {
afe42d0… ragelink 1560 match[ 3 ] = " " + match[ 3 ] + " ";
afe42d0… ragelink 1561 }
afe42d0… ragelink 1562
afe42d0… ragelink 1563 return match.slice( 0, 4 );
afe42d0… ragelink 1564 },
afe42d0… ragelink 1565
afe42d0… ragelink 1566 CHILD: function( match ) {
afe42d0… ragelink 1567
afe42d0… ragelink 1568 /* matches from matchExpr["CHILD"]
afe42d0… ragelink 1569 1 type (only|nth|...)
afe42d0… ragelink 1570 2 what (child|of-type)
afe42d0… ragelink 1571 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
afe42d0… ragelink 1572 4 xn-component of xn+y argument ([+-]?\d*n|)
afe42d0… ragelink 1573 5 sign of xn-component
afe42d0… ragelink 1574 6 x of xn-component
afe42d0… ragelink 1575 7 sign of y-component
afe42d0… ragelink 1576 8 y of y-component
afe42d0… ragelink 1577 */
afe42d0… ragelink 1578 match[ 1 ] = match[ 1 ].toLowerCase();
afe42d0… ragelink 1579
afe42d0… ragelink 1580 if ( match[ 1 ].slice( 0, 3 ) === "nth" ) {
afe42d0… ragelink 1581
afe42d0… ragelink 1582 // nth-* requires argument
afe42d0… ragelink 1583 if ( !match[ 3 ] ) {
afe42d0… ragelink 1584 find.error( match[ 0 ] );
afe42d0… ragelink 1585 }
afe42d0… ragelink 1586
afe42d0… ragelink 1587 // numeric x and y parameters for Expr.filter.CHILD
afe42d0… ragelink 1588 // remember that false/true cast respectively to 0/1
afe42d0… ragelink 1589 match[ 4 ] = +( match[ 4 ] ?
afe42d0… ragelink 1590 match[ 5 ] + ( match[ 6 ] || 1 ) :
afe42d0… ragelink 1591 2 * ( match[ 3 ] === "even" || match[ 3 ] === "odd" )
afe42d0… ragelink 1592 );
afe42d0… ragelink 1593 match[ 5 ] = +( ( match[ 7 ] + match[ 8 ] ) || match[ 3 ] === "odd" );
afe42d0… ragelink 1594
afe42d0… ragelink 1595 // other types prohibit arguments
afe42d0… ragelink 1596 } else if ( match[ 3 ] ) {
afe42d0… ragelink 1597 find.error( match[ 0 ] );
afe42d0… ragelink 1598 }
afe42d0… ragelink 1599
afe42d0… ragelink 1600 return match;
afe42d0… ragelink 1601 },
afe42d0… ragelink 1602
afe42d0… ragelink 1603 PSEUDO: function( match ) {
afe42d0… ragelink 1604 var excess,
afe42d0… ragelink 1605 unquoted = !match[ 6 ] && match[ 2 ];
afe42d0… ragelink 1606
afe42d0… ragelink 1607 if ( matchExpr.CHILD.test( match[ 0 ] ) ) {
afe42d0… ragelink 1608 return null;
afe42d0… ragelink 1609 }
afe42d0… ragelink 1610
afe42d0… ragelink 1611 // Accept quoted arguments as-is
afe42d0… ragelink 1612 if ( match[ 3 ] ) {
afe42d0… ragelink 1613 match[ 2 ] = match[ 4 ] || match[ 5 ] || "";
afe42d0… ragelink 1614
afe42d0… ragelink 1615 // Strip excess characters from unquoted arguments
afe42d0… ragelink 1616 } else if ( unquoted && rpseudo.test( unquoted ) &&
afe42d0… ragelink 1617
afe42d0… ragelink 1618 // Get excess from tokenize (recursively)
afe42d0… ragelink 1619 ( excess = tokenize( unquoted, true ) ) &&
afe42d0… ragelink 1620
afe42d0… ragelink 1621 // advance to the next closing parenthesis
afe42d0… ragelink 1622 ( excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length ) ) {
afe42d0… ragelink 1623
afe42d0… ragelink 1624 // excess is a negative index
afe42d0… ragelink 1625 match[ 0 ] = match[ 0 ].slice( 0, excess );
afe42d0… ragelink 1626 match[ 2 ] = unquoted.slice( 0, excess );
afe42d0… ragelink 1627 }
afe42d0… ragelink 1628
afe42d0… ragelink 1629 // Return only captures needed by the pseudo filter method (type and argument)
afe42d0… ragelink 1630 return match.slice( 0, 3 );
afe42d0… ragelink 1631 }
afe42d0… ragelink 1632 },
afe42d0… ragelink 1633
afe42d0… ragelink 1634 filter: {
afe42d0… ragelink 1635
afe42d0… ragelink 1636 TAG: function( nodeNameSelector ) {
afe42d0… ragelink 1637 var expectedNodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
afe42d0… ragelink 1638 return nodeNameSelector === "*" ?
afe42d0… ragelink 1639 function() {
afe42d0… ragelink 1640 return true;
afe42d0… ragelink 1641 } :
afe42d0… ragelink 1642 function( elem ) {
afe42d0… ragelink 1643 return nodeName( elem, expectedNodeName );
afe42d0… ragelink 1644 };
afe42d0… ragelink 1645 },
afe42d0… ragelink 1646
afe42d0… ragelink 1647 CLASS: function( className ) {
afe42d0… ragelink 1648 var pattern = classCache[ className + " " ];
afe42d0… ragelink 1649
afe42d0… ragelink 1650 return pattern ||
afe42d0… ragelink 1651 ( pattern = new RegExp( "(^|" + whitespace + ")" + className +
afe42d0… ragelink 1652 "(" + whitespace + "|$)" ) ) &&
afe42d0… ragelink 1653 classCache( className, function( elem ) {
afe42d0… ragelink 1654 return pattern.test(
afe42d0… ragelink 1655 typeof elem.className === "string" && elem.className ||
afe42d0… ragelink 1656 typeof elem.getAttribute !== "undefined" &&
afe42d0… ragelink 1657 elem.getAttribute( "class" ) ||
afe42d0… ragelink 1658 ""
afe42d0… ragelink 1659 );
afe42d0… ragelink 1660 } );
afe42d0… ragelink 1661 },
afe42d0… ragelink 1662
afe42d0… ragelink 1663 ATTR: function( name, operator, check ) {
afe42d0… ragelink 1664 return function( elem ) {
afe42d0… ragelink 1665 var result = find.attr( elem, name );
afe42d0… ragelink 1666
afe42d0… ragelink 1667 if ( result == null ) {
afe42d0… ragelink 1668 return operator === "!=";
afe42d0… ragelink 1669 }
afe42d0… ragelink 1670 if ( !operator ) {
afe42d0… ragelink 1671 return true;
afe42d0… ragelink 1672 }
afe42d0… ragelink 1673
afe42d0… ragelink 1674 result += "";
afe42d0… ragelink 1675
afe42d0… ragelink 1676 if ( operator === "=" ) {
afe42d0… ragelink 1677 return result === check;
afe42d0… ragelink 1678 }
afe42d0… ragelink 1679 if ( operator === "!=" ) {
afe42d0… ragelink 1680 return result !== check;
afe42d0… ragelink 1681 }
afe42d0… ragelink 1682 if ( operator === "^=" ) {
afe42d0… ragelink 1683 return check && result.indexOf( check ) === 0;
afe42d0… ragelink 1684 }
afe42d0… ragelink 1685 if ( operator === "*=" ) {
afe42d0… ragelink 1686 return check && result.indexOf( check ) > -1;
afe42d0… ragelink 1687 }
afe42d0… ragelink 1688 if ( operator === "$=" ) {
afe42d0… ragelink 1689 return check && result.slice( -check.length ) === check;
afe42d0… ragelink 1690 }
afe42d0… ragelink 1691 if ( operator === "~=" ) {
afe42d0… ragelink 1692 return ( " " + result.replace( rwhitespace, " " ) + " " )
afe42d0… ragelink 1693 .indexOf( check ) > -1;
afe42d0… ragelink 1694 }
afe42d0… ragelink 1695 if ( operator === "|=" ) {
afe42d0… ragelink 1696 return result === check || result.slice( 0, check.length + 1 ) === check + "-";
afe42d0… ragelink 1697 }
afe42d0… ragelink 1698
afe42d0… ragelink 1699 return false;
afe42d0… ragelink 1700 };
afe42d0… ragelink 1701 },
afe42d0… ragelink 1702
afe42d0… ragelink 1703 CHILD: function( type, what, _argument, first, last ) {
afe42d0… ragelink 1704 var simple = type.slice( 0, 3 ) !== "nth",
afe42d0… ragelink 1705 forward = type.slice( -4 ) !== "last",
afe42d0… ragelink 1706 ofType = what === "of-type";
afe42d0… ragelink 1707
afe42d0… ragelink 1708 return first === 1 && last === 0 ?
afe42d0… ragelink 1709
afe42d0… ragelink 1710 // Shortcut for :nth-*(n)
afe42d0… ragelink 1711 function( elem ) {
afe42d0… ragelink 1712 return !!elem.parentNode;
afe42d0… ragelink 1713 } :
afe42d0… ragelink 1714
afe42d0… ragelink 1715 function( elem, _context, xml ) {
afe42d0… ragelink 1716 var cache, outerCache, node, nodeIndex, start,
afe42d0… ragelink 1717 dir = simple !== forward ? "nextSibling" : "previousSibling",
afe42d0… ragelink 1718 parent = elem.parentNode,
afe42d0… ragelink 1719 name = ofType && elem.nodeName.toLowerCase(),
afe42d0… ragelink 1720 useCache = !xml && !ofType,
afe42d0… ragelink 1721 diff = false;
afe42d0… ragelink 1722
afe42d0… ragelink 1723 if ( parent ) {
afe42d0… ragelink 1724
afe42d0… ragelink 1725 // :(first|last|only)-(child|of-type)
afe42d0… ragelink 1726 if ( simple ) {
afe42d0… ragelink 1727 while ( dir ) {
afe42d0… ragelink 1728 node = elem;
afe42d0… ragelink 1729 while ( ( node = node[ dir ] ) ) {
afe42d0… ragelink 1730 if ( ofType ?
afe42d0… ragelink 1731 nodeName( node, name ) :
afe42d0… ragelink 1732 node.nodeType === 1 ) {
afe42d0… ragelink 1733
afe42d0… ragelink 1734 return false;
afe42d0… ragelink 1735 }
afe42d0… ragelink 1736 }
afe42d0… ragelink 1737
afe42d0… ragelink 1738 // Reverse direction for :only-* (if we haven't yet done so)
afe42d0… ragelink 1739 start = dir = type === "only" && !start && "nextSibling";
afe42d0… ragelink 1740 }
afe42d0… ragelink 1741 return true;
afe42d0… ragelink 1742 }
afe42d0… ragelink 1743
afe42d0… ragelink 1744 start = [ forward ? parent.firstChild : parent.lastChild ];
afe42d0… ragelink 1745
afe42d0… ragelink 1746 // non-xml :nth-child(...) stores cache data on `parent`
afe42d0… ragelink 1747 if ( forward && useCache ) {
afe42d0… ragelink 1748
afe42d0… ragelink 1749 // Seek `elem` from a previously-cached index
afe42d0… ragelink 1750 outerCache = parent[ expando ] || ( parent[ expando ] = {} );
afe42d0… ragelink 1751 cache = outerCache[ type ] || [];
afe42d0… ragelink 1752 nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
afe42d0… ragelink 1753 diff = nodeIndex && cache[ 2 ];
afe42d0… ragelink 1754 node = nodeIndex && parent.childNodes[ nodeIndex ];
afe42d0… ragelink 1755
afe42d0… ragelink 1756 while ( ( node = ++nodeIndex && node && node[ dir ] ||
afe42d0… ragelink 1757
afe42d0… ragelink 1758 // Fallback to seeking `elem` from the start
afe42d0… ragelink 1759 ( diff = nodeIndex = 0 ) || start.pop() ) ) {
afe42d0… ragelink 1760
afe42d0… ragelink 1761 // When found, cache indexes on `parent` and break
afe42d0… ragelink 1762 if ( node.nodeType === 1 && ++diff && node === elem ) {
afe42d0… ragelink 1763 outerCache[ type ] = [ dirruns, nodeIndex, diff ];
afe42d0… ragelink 1764 break;
afe42d0… ragelink 1765 }
afe42d0… ragelink 1766 }
afe42d0… ragelink 1767
afe42d0… ragelink 1768 } else {
afe42d0… ragelink 1769
afe42d0… ragelink 1770 // Use previously-cached element index if available
afe42d0… ragelink 1771 if ( useCache ) {
afe42d0… ragelink 1772 outerCache = elem[ expando ] || ( elem[ expando ] = {} );
afe42d0… ragelink 1773 cache = outerCache[ type ] || [];
afe42d0… ragelink 1774 nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
afe42d0… ragelink 1775 diff = nodeIndex;
afe42d0… ragelink 1776 }
afe42d0… ragelink 1777
afe42d0… ragelink 1778 // xml :nth-child(...)
afe42d0… ragelink 1779 // or :nth-last-child(...) or :nth(-last)?-of-type(...)
afe42d0… ragelink 1780 if ( diff === false ) {
afe42d0… ragelink 1781
afe42d0… ragelink 1782 // Use the same loop as above to seek `elem` from the start
afe42d0… ragelink 1783 while ( ( node = ++nodeIndex && node && node[ dir ] ||
afe42d0… ragelink 1784 ( diff = nodeIndex = 0 ) || start.pop() ) ) {
afe42d0… ragelink 1785
afe42d0… ragelink 1786 if ( ( ofType ?
afe42d0… ragelink 1787 nodeName( node, name ) :
afe42d0… ragelink 1788 node.nodeType === 1 ) &&
afe42d0… ragelink 1789 ++diff ) {
afe42d0… ragelink 1790
afe42d0… ragelink 1791 // Cache the index of each encountered element
afe42d0… ragelink 1792 if ( useCache ) {
afe42d0… ragelink 1793 outerCache = node[ expando ] ||
afe42d0… ragelink 1794 ( node[ expando ] = {} );
afe42d0… ragelink 1795 outerCache[ type ] = [ dirruns, diff ];
afe42d0… ragelink 1796 }
afe42d0… ragelink 1797
afe42d0… ragelink 1798 if ( node === elem ) {
afe42d0… ragelink 1799 break;
afe42d0… ragelink 1800 }
afe42d0… ragelink 1801 }
afe42d0… ragelink 1802 }
afe42d0… ragelink 1803 }
afe42d0… ragelink 1804 }
afe42d0… ragelink 1805
afe42d0… ragelink 1806 // Incorporate the offset, then check against cycle size
afe42d0… ragelink 1807 diff -= last;
afe42d0… ragelink 1808 return diff === first || ( diff % first === 0 && diff / first >= 0 );
afe42d0… ragelink 1809 }
afe42d0… ragelink 1810 };
afe42d0… ragelink 1811 },
afe42d0… ragelink 1812
afe42d0… ragelink 1813 PSEUDO: function( pseudo, argument ) {
afe42d0… ragelink 1814
afe42d0… ragelink 1815 // pseudo-class names are case-insensitive
afe42d0… ragelink 1816 // https://www.w3.org/TR/selectors/#pseudo-classes
afe42d0… ragelink 1817 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
afe42d0… ragelink 1818 // Remember that setFilters inherits from pseudos
afe42d0… ragelink 1819 var args,
afe42d0… ragelink 1820 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
afe42d0… ragelink 1821 find.error( "unsupported pseudo: " + pseudo );
afe42d0… ragelink 1822
afe42d0… ragelink 1823 // The user may use createPseudo to indicate that
afe42d0… ragelink 1824 // arguments are needed to create the filter function
afe42d0… ragelink 1825 // just as jQuery does
afe42d0… ragelink 1826 if ( fn[ expando ] ) {
afe42d0… ragelink 1827 return fn( argument );
afe42d0… ragelink 1828 }
afe42d0… ragelink 1829
afe42d0… ragelink 1830 // But maintain support for old signatures
afe42d0… ragelink 1831 if ( fn.length > 1 ) {
afe42d0… ragelink 1832 args = [ pseudo, pseudo, "", argument ];
afe42d0… ragelink 1833 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
afe42d0… ragelink 1834 markFunction( function( seed, matches ) {
afe42d0… ragelink 1835 var idx,
afe42d0… ragelink 1836 matched = fn( seed, argument ),
afe42d0… ragelink 1837 i = matched.length;
afe42d0… ragelink 1838 while ( i-- ) {
afe42d0… ragelink 1839 idx = indexOf.call( seed, matched[ i ] );
afe42d0… ragelink 1840 seed[ idx ] = !( matches[ idx ] = matched[ i ] );
afe42d0… ragelink 1841 }
afe42d0… ragelink 1842 } ) :
afe42d0… ragelink 1843 function( elem ) {
afe42d0… ragelink 1844 return fn( elem, 0, args );
afe42d0… ragelink 1845 };
afe42d0… ragelink 1846 }
afe42d0… ragelink 1847
afe42d0… ragelink 1848 return fn;
afe42d0… ragelink 1849 }
afe42d0… ragelink 1850 },
afe42d0… ragelink 1851
afe42d0… ragelink 1852 pseudos: {
afe42d0… ragelink 1853
afe42d0… ragelink 1854 // Potentially complex pseudos
afe42d0… ragelink 1855 not: markFunction( function( selector ) {
afe42d0… ragelink 1856
afe42d0… ragelink 1857 // Trim the selector passed to compile
afe42d0… ragelink 1858 // to avoid treating leading and trailing
afe42d0… ragelink 1859 // spaces as combinators
afe42d0… ragelink 1860 var input = [],
afe42d0… ragelink 1861 results = [],
afe42d0… ragelink 1862 matcher = compile( selector.replace( rtrimCSS, "$1" ) );
afe42d0… ragelink 1863
afe42d0… ragelink 1864 return matcher[ expando ] ?
afe42d0… ragelink 1865 markFunction( function( seed, matches, _context, xml ) {
afe42d0… ragelink 1866 var elem,
afe42d0… ragelink 1867 unmatched = matcher( seed, null, xml, [] ),
afe42d0… ragelink 1868 i = seed.length;
afe42d0… ragelink 1869
afe42d0… ragelink 1870 // Match elements unmatched by `matcher`
afe42d0… ragelink 1871 while ( i-- ) {
afe42d0… ragelink 1872 if ( ( elem = unmatched[ i ] ) ) {
afe42d0… ragelink 1873 seed[ i ] = !( matches[ i ] = elem );
afe42d0… ragelink 1874 }
afe42d0… ragelink 1875 }
afe42d0… ragelink 1876 } ) :
afe42d0… ragelink 1877 function( elem, _context, xml ) {
afe42d0… ragelink 1878 input[ 0 ] = elem;
afe42d0… ragelink 1879 matcher( input, null, xml, results );
afe42d0… ragelink 1880
afe42d0… ragelink 1881 // Don't keep the element
afe42d0… ragelink 1882 // (see https://github.com/jquery/sizzle/issues/299)
afe42d0… ragelink 1883 input[ 0 ] = null;
afe42d0… ragelink 1884 return !results.pop();
afe42d0… ragelink 1885 };
afe42d0… ragelink 1886 } ),
afe42d0… ragelink 1887
afe42d0… ragelink 1888 has: markFunction( function( selector ) {
afe42d0… ragelink 1889 return function( elem ) {
afe42d0… ragelink 1890 return find( selector, elem ).length > 0;
afe42d0… ragelink 1891 };
afe42d0… ragelink 1892 } ),
afe42d0… ragelink 1893
afe42d0… ragelink 1894 contains: markFunction( function( text ) {
afe42d0… ragelink 1895 text = text.replace( runescape, funescape );
afe42d0… ragelink 1896 return function( elem ) {
afe42d0… ragelink 1897 return ( elem.textContent || jQuery.text( elem ) ).indexOf( text ) > -1;
afe42d0… ragelink 1898 };
afe42d0… ragelink 1899 } ),
afe42d0… ragelink 1900
afe42d0… ragelink 1901 // "Whether an element is represented by a :lang() selector
afe42d0… ragelink 1902 // is based solely on the element's language value
afe42d0… ragelink 1903 // being equal to the identifier C,
afe42d0… ragelink 1904 // or beginning with the identifier C immediately followed by "-".
afe42d0… ragelink 1905 // The matching of C against the element's language value is performed case-insensitively.
afe42d0… ragelink 1906 // The identifier C does not have to be a valid language name."
afe42d0… ragelink 1907 // https://www.w3.org/TR/selectors/#lang-pseudo
afe42d0… ragelink 1908 lang: markFunction( function( lang ) {
afe42d0… ragelink 1909
afe42d0… ragelink 1910 // lang value must be a valid identifier
afe42d0… ragelink 1911 if ( !ridentifier.test( lang || "" ) ) {
afe42d0… ragelink 1912 find.error( "unsupported lang: " + lang );
afe42d0… ragelink 1913 }
afe42d0… ragelink 1914 lang = lang.replace( runescape, funescape ).toLowerCase();
afe42d0… ragelink 1915 return function( elem ) {
afe42d0… ragelink 1916 var elemLang;
afe42d0… ragelink 1917 do {
afe42d0… ragelink 1918 if ( ( elemLang = documentIsHTML ?
afe42d0… ragelink 1919 elem.lang :
afe42d0… ragelink 1920 elem.getAttribute( "xml:lang" ) || elem.getAttribute( "lang" ) ) ) {
afe42d0… ragelink 1921
afe42d0… ragelink 1922 elemLang = elemLang.toLowerCase();
afe42d0… ragelink 1923 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
afe42d0… ragelink 1924 }
afe42d0… ragelink 1925 } while ( ( elem = elem.parentNode ) && elem.nodeType === 1 );
afe42d0… ragelink 1926 return false;
afe42d0… ragelink 1927 };
afe42d0… ragelink 1928 } ),
afe42d0… ragelink 1929
afe42d0… ragelink 1930 // Miscellaneous
afe42d0… ragelink 1931 target: function( elem ) {
afe42d0… ragelink 1932 var hash = window.location && window.location.hash;
afe42d0… ragelink 1933 return hash && hash.slice( 1 ) === elem.id;
afe42d0… ragelink 1934 },
afe42d0… ragelink 1935
afe42d0… ragelink 1936 root: function( elem ) {
afe42d0… ragelink 1937 return elem === documentElement;
afe42d0… ragelink 1938 },
afe42d0… ragelink 1939
afe42d0… ragelink 1940 focus: function( elem ) {
afe42d0… ragelink 1941 return elem === safeActiveElement() &&
afe42d0… ragelink 1942 document.hasFocus() &&
afe42d0… ragelink 1943 !!( elem.type || elem.href || ~elem.tabIndex );
afe42d0… ragelink 1944 },
afe42d0… ragelink 1945
afe42d0… ragelink 1946 // Boolean properties
afe42d0… ragelink 1947 enabled: createDisabledPseudo( false ),
afe42d0… ragelink 1948 disabled: createDisabledPseudo( true ),
afe42d0… ragelink 1949
afe42d0… ragelink 1950 checked: function( elem ) {
afe42d0… ragelink 1951
afe42d0… ragelink 1952 // In CSS3, :checked should return both checked and selected elements
afe42d0… ragelink 1953 // https://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
afe42d0… ragelink 1954 return ( nodeName( elem, "input" ) && !!elem.checked ) ||
afe42d0… ragelink 1955 ( nodeName( elem, "option" ) && !!elem.selected );
afe42d0… ragelink 1956 },
afe42d0… ragelink 1957
afe42d0… ragelink 1958 selected: function( elem ) {
afe42d0… ragelink 1959
afe42d0… ragelink 1960 // Support: IE <=11+
afe42d0… ragelink 1961 // Accessing the selectedIndex property
afe42d0… ragelink 1962 // forces the browser to treat the default option as
afe42d0… ragelink 1963 // selected when in an optgroup.
afe42d0… ragelink 1964 if ( elem.parentNode ) {
afe42d0… ragelink 1965 // eslint-disable-next-line no-unused-expressions
afe42d0… ragelink 1966 elem.parentNode.selectedIndex;
afe42d0… ragelink 1967 }
afe42d0… ragelink 1968
afe42d0… ragelink 1969 return elem.selected === true;
afe42d0… ragelink 1970 },
afe42d0… ragelink 1971
afe42d0… ragelink 1972 // Contents
afe42d0… ragelink 1973 empty: function( elem ) {
afe42d0… ragelink 1974
afe42d0… ragelink 1975 // https://www.w3.org/TR/selectors/#empty-pseudo
afe42d0… ragelink 1976 // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
afe42d0… ragelink 1977 // but not by others (comment: 8; processing instruction: 7; etc.)
afe42d0… ragelink 1978 // nodeType < 6 works because attributes (2) do not appear as children
afe42d0… ragelink 1979 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
afe42d0… ragelink 1980 if ( elem.nodeType < 6 ) {
afe42d0… ragelink 1981 return false;
afe42d0… ragelink 1982 }
afe42d0… ragelink 1983 }
afe42d0… ragelink 1984 return true;
afe42d0… ragelink 1985 },
afe42d0… ragelink 1986
afe42d0… ragelink 1987 parent: function( elem ) {
afe42d0… ragelink 1988 return !Expr.pseudos.empty( elem );
afe42d0… ragelink 1989 },
afe42d0… ragelink 1990
afe42d0… ragelink 1991 // Element/input types
afe42d0… ragelink 1992 header: function( elem ) {
afe42d0… ragelink 1993 return rheader.test( elem.nodeName );
afe42d0… ragelink 1994 },
afe42d0… ragelink 1995
afe42d0… ragelink 1996 input: function( elem ) {
afe42d0… ragelink 1997 return rinputs.test( elem.nodeName );
afe42d0… ragelink 1998 },
afe42d0… ragelink 1999
afe42d0… ragelink 2000 button: function( elem ) {
afe42d0… ragelink 2001 return nodeName( elem, "input" ) && elem.type === "button" ||
afe42d0… ragelink 2002 nodeName( elem, "button" );
afe42d0… ragelink 2003 },
afe42d0… ragelink 2004
afe42d0… ragelink 2005 text: function( elem ) {
afe42d0… ragelink 2006 var attr;
afe42d0… ragelink 2007 return nodeName( elem, "input" ) && elem.type === "text" &&
afe42d0… ragelink 2008
afe42d0… ragelink 2009 // Support: IE <10 only
afe42d0… ragelink 2010 // New HTML5 attribute values (e.g., "search") appear
afe42d0… ragelink 2011 // with elem.type === "text"
afe42d0… ragelink 2012 ( ( attr = elem.getAttribute( "type" ) ) == null ||
afe42d0… ragelink 2013 attr.toLowerCase() === "text" );
afe42d0… ragelink 2014 },
afe42d0… ragelink 2015
afe42d0… ragelink 2016 // Position-in-collection
afe42d0… ragelink 2017 first: createPositionalPseudo( function() {
afe42d0… ragelink 2018 return [ 0 ];
afe42d0… ragelink 2019 } ),
afe42d0… ragelink 2020
afe42d0… ragelink 2021 last: createPositionalPseudo( function( _matchIndexes, length ) {
afe42d0… ragelink 2022 return [ length - 1 ];
afe42d0… ragelink 2023 } ),
afe42d0… ragelink 2024
afe42d0… ragelink 2025 eq: createPositionalPseudo( function( _matchIndexes, length, argument ) {
afe42d0… ragelink 2026 return [ argument < 0 ? argument + length : argument ];
afe42d0… ragelink 2027 } ),
afe42d0… ragelink 2028
afe42d0… ragelink 2029 even: createPositionalPseudo( function( matchIndexes, length ) {
afe42d0… ragelink 2030 var i = 0;
afe42d0… ragelink 2031 for ( ; i < length; i += 2 ) {
afe42d0… ragelink 2032 matchIndexes.push( i );
afe42d0… ragelink 2033 }
afe42d0… ragelink 2034 return matchIndexes;
afe42d0… ragelink 2035 } ),
afe42d0… ragelink 2036
afe42d0… ragelink 2037 odd: createPositionalPseudo( function( matchIndexes, length ) {
afe42d0… ragelink 2038 var i = 1;
afe42d0… ragelink 2039 for ( ; i < length; i += 2 ) {
afe42d0… ragelink 2040 matchIndexes.push( i );
afe42d0… ragelink 2041 }
afe42d0… ragelink 2042 return matchIndexes;
afe42d0… ragelink 2043 } ),
afe42d0… ragelink 2044
afe42d0… ragelink 2045 lt: createPositionalPseudo( function( matchIndexes, length, argument ) {
afe42d0… ragelink 2046 var i;
afe42d0… ragelink 2047
afe42d0… ragelink 2048 if ( argument < 0 ) {
afe42d0… ragelink 2049 i = argument + length;
afe42d0… ragelink 2050 } else if ( argument > length ) {
afe42d0… ragelink 2051 i = length;
afe42d0… ragelink 2052 } else {
afe42d0… ragelink 2053 i = argument;
afe42d0… ragelink 2054 }
afe42d0… ragelink 2055
afe42d0… ragelink 2056 for ( ; --i >= 0; ) {
afe42d0… ragelink 2057 matchIndexes.push( i );
afe42d0… ragelink 2058 }
afe42d0… ragelink 2059 return matchIndexes;
afe42d0… ragelink 2060 } ),
afe42d0… ragelink 2061
afe42d0… ragelink 2062 gt: createPositionalPseudo( function( matchIndexes, length, argument ) {
afe42d0… ragelink 2063 var i = argument < 0 ? argument + length : argument;
afe42d0… ragelink 2064 for ( ; ++i < length; ) {
afe42d0… ragelink 2065 matchIndexes.push( i );
afe42d0… ragelink 2066 }
afe42d0… ragelink 2067 return matchIndexes;
afe42d0… ragelink 2068 } )
afe42d0… ragelink 2069 }
afe42d0… ragelink 2070 };
afe42d0… ragelink 2071
afe42d0… ragelink 2072 Expr.pseudos.nth = Expr.pseudos.eq;
afe42d0… ragelink 2073
afe42d0… ragelink 2074 // Add button/input type pseudos
afe42d0… ragelink 2075 for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
afe42d0… ragelink 2076 Expr.pseudos[ i ] = createInputPseudo( i );
afe42d0… ragelink 2077 }
afe42d0… ragelink 2078 for ( i in { submit: true, reset: true } ) {
afe42d0… ragelink 2079 Expr.pseudos[ i ] = createButtonPseudo( i );
afe42d0… ragelink 2080 }
afe42d0… ragelink 2081
afe42d0… ragelink 2082 // Easy API for creating new setFilters
afe42d0… ragelink 2083 function setFilters() {}
afe42d0… ragelink 2084 setFilters.prototype = Expr.filters = Expr.pseudos;
afe42d0… ragelink 2085 Expr.setFilters = new setFilters();
afe42d0… ragelink 2086
afe42d0… ragelink 2087 function tokenize( selector, parseOnly ) {
afe42d0… ragelink 2088 var matched, match, tokens, type,
afe42d0… ragelink 2089 soFar, groups, preFilters,
afe42d0… ragelink 2090 cached = tokenCache[ selector + " " ];
afe42d0… ragelink 2091
afe42d0… ragelink 2092 if ( cached ) {
afe42d0… ragelink 2093 return parseOnly ? 0 : cached.slice( 0 );
afe42d0… ragelink 2094 }
afe42d0… ragelink 2095
afe42d0… ragelink 2096 soFar = selector;
afe42d0… ragelink 2097 groups = [];
afe42d0… ragelink 2098 preFilters = Expr.preFilter;
afe42d0… ragelink 2099
afe42d0… ragelink 2100 while ( soFar ) {
afe42d0… ragelink 2101
afe42d0… ragelink 2102 // Comma and first run
afe42d0… ragelink 2103 if ( !matched || ( match = rcomma.exec( soFar ) ) ) {
afe42d0… ragelink 2104 if ( match ) {
afe42d0… ragelink 2105
afe42d0… ragelink 2106 // Don't consume trailing commas as valid
afe42d0… ragelink 2107 soFar = soFar.slice( match[ 0 ].length ) || soFar;
afe42d0… ragelink 2108 }
afe42d0… ragelink 2109 groups.push( ( tokens = [] ) );
afe42d0… ragelink 2110 }
afe42d0… ragelink 2111
afe42d0… ragelink 2112 matched = false;
afe42d0… ragelink 2113
afe42d0… ragelink 2114 // Combinators
afe42d0… ragelink 2115 if ( ( match = rleadingCombinator.exec( soFar ) ) ) {
afe42d0… ragelink 2116 matched = match.shift();
afe42d0… ragelink 2117 tokens.push( {
afe42d0… ragelink 2118 value: matched,
afe42d0… ragelink 2119
afe42d0… ragelink 2120 // Cast descendant combinators to space
afe42d0… ragelink 2121 type: match[ 0 ].replace( rtrimCSS, " " )
afe42d0… ragelink 2122 } );
afe42d0… ragelink 2123 soFar = soFar.slice( matched.length );
afe42d0… ragelink 2124 }
afe42d0… ragelink 2125
afe42d0… ragelink 2126 // Filters
afe42d0… ragelink 2127 for ( type in Expr.filter ) {
afe42d0… ragelink 2128 if ( ( match = matchExpr[ type ].exec( soFar ) ) && ( !preFilters[ type ] ||
afe42d0… ragelink 2129 ( match = preFilters[ type ]( match ) ) ) ) {
afe42d0… ragelink 2130 matched = match.shift();
afe42d0… ragelink 2131 tokens.push( {
afe42d0… ragelink 2132 value: matched,
afe42d0… ragelink 2133 type: type,
afe42d0… ragelink 2134 matches: match
afe42d0… ragelink 2135 } );
afe42d0… ragelink 2136 soFar = soFar.slice( matched.length );
afe42d0… ragelink 2137 }
afe42d0… ragelink 2138 }
afe42d0… ragelink 2139
afe42d0… ragelink 2140 if ( !matched ) {
afe42d0… ragelink 2141 break;
afe42d0… ragelink 2142 }
afe42d0… ragelink 2143 }
afe42d0… ragelink 2144
afe42d0… ragelink 2145 // Return the length of the invalid excess
afe42d0… ragelink 2146 // if we're just parsing
afe42d0… ragelink 2147 // Otherwise, throw an error or return tokens
afe42d0… ragelink 2148 if ( parseOnly ) {
afe42d0… ragelink 2149 return soFar.length;
afe42d0… ragelink 2150 }
afe42d0… ragelink 2151
afe42d0… ragelink 2152 return soFar ?
afe42d0… ragelink 2153 find.error( selector ) :
afe42d0… ragelink 2154
afe42d0… ragelink 2155 // Cache the tokens
afe42d0… ragelink 2156 tokenCache( selector, groups ).slice( 0 );
afe42d0… ragelink 2157 }
afe42d0… ragelink 2158
afe42d0… ragelink 2159 function toSelector( tokens ) {
afe42d0… ragelink 2160 var i = 0,
afe42d0… ragelink 2161 len = tokens.length,
afe42d0… ragelink 2162 selector = "";
afe42d0… ragelink 2163 for ( ; i < len; i++ ) {
afe42d0… ragelink 2164 selector += tokens[ i ].value;
afe42d0… ragelink 2165 }
afe42d0… ragelink 2166 return selector;
afe42d0… ragelink 2167 }
afe42d0… ragelink 2168
afe42d0… ragelink 2169 function addCombinator( matcher, combinator, base ) {
afe42d0… ragelink 2170 var dir = combinator.dir,
afe42d0… ragelink 2171 skip = combinator.next,
afe42d0… ragelink 2172 key = skip || dir,
afe42d0… ragelink 2173 checkNonElements = base && key === "parentNode",
afe42d0… ragelink 2174 doneName = done++;
afe42d0… ragelink 2175
afe42d0… ragelink 2176 return combinator.first ?
afe42d0… ragelink 2177
afe42d0… ragelink 2178 // Check against closest ancestor/preceding element
afe42d0… ragelink 2179 function( elem, context, xml ) {
afe42d0… ragelink 2180 while ( ( elem = elem[ dir ] ) ) {
afe42d0… ragelink 2181 if ( elem.nodeType === 1 || checkNonElements ) {
afe42d0… ragelink 2182 return matcher( elem, context, xml );
afe42d0… ragelink 2183 }
afe42d0… ragelink 2184 }
afe42d0… ragelink 2185 return false;
afe42d0… ragelink 2186 } :
afe42d0… ragelink 2187
afe42d0… ragelink 2188 // Check against all ancestor/preceding elements
afe42d0… ragelink 2189 function( elem, context, xml ) {
afe42d0… ragelink 2190 var oldCache, outerCache,
afe42d0… ragelink 2191 newCache = [ dirruns, doneName ];
afe42d0… ragelink 2192
afe42d0… ragelink 2193 // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
afe42d0… ragelink 2194 if ( xml ) {
afe42d0… ragelink 2195 while ( ( elem = elem[ dir ] ) ) {
afe42d0… ragelink 2196 if ( elem.nodeType === 1 || checkNonElements ) {
afe42d0… ragelink 2197 if ( matcher( elem, context, xml ) ) {
afe42d0… ragelink 2198 return true;
afe42d0… ragelink 2199 }
afe42d0… ragelink 2200 }
afe42d0… ragelink 2201 }
afe42d0… ragelink 2202 } else {
afe42d0… ragelink 2203 while ( ( elem = elem[ dir ] ) ) {
afe42d0… ragelink 2204 if ( elem.nodeType === 1 || checkNonElements ) {
afe42d0… ragelink 2205 outerCache = elem[ expando ] || ( elem[ expando ] = {} );
afe42d0… ragelink 2206
afe42d0… ragelink 2207 if ( skip && nodeName( elem, skip ) ) {
afe42d0… ragelink 2208 elem = elem[ dir ] || elem;
afe42d0… ragelink 2209 } else if ( ( oldCache = outerCache[ key ] ) &&
afe42d0… ragelink 2210 oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
afe42d0… ragelink 2211
afe42d0… ragelink 2212 // Assign to newCache so results back-propagate to previous elements
afe42d0… ragelink 2213 return ( newCache[ 2 ] = oldCache[ 2 ] );
afe42d0… ragelink 2214 } else {
afe42d0… ragelink 2215
afe42d0… ragelink 2216 // Reuse newcache so results back-propagate to previous elements
afe42d0… ragelink 2217 outerCache[ key ] = newCache;
afe42d0… ragelink 2218
afe42d0… ragelink 2219 // A match means we're done; a fail means we have to keep checking
afe42d0… ragelink 2220 if ( ( newCache[ 2 ] = matcher( elem, context, xml ) ) ) {
afe42d0… ragelink 2221 return true;
afe42d0… ragelink 2222 }
afe42d0… ragelink 2223 }
afe42d0… ragelink 2224 }
afe42d0… ragelink 2225 }
afe42d0… ragelink 2226 }
afe42d0… ragelink 2227 return false;
afe42d0… ragelink 2228 };
afe42d0… ragelink 2229 }
afe42d0… ragelink 2230
afe42d0… ragelink 2231 function elementMatcher( matchers ) {
afe42d0… ragelink 2232 return matchers.length > 1 ?
afe42d0… ragelink 2233 function( elem, context, xml ) {
afe42d0… ragelink 2234 var i = matchers.length;
afe42d0… ragelink 2235 while ( i-- ) {
afe42d0… ragelink 2236 if ( !matchers[ i ]( elem, context, xml ) ) {
afe42d0… ragelink 2237 return false;
afe42d0… ragelink 2238 }
afe42d0… ragelink 2239 }
afe42d0… ragelink 2240 return true;
afe42d0… ragelink 2241 } :
afe42d0… ragelink 2242 matchers[ 0 ];
afe42d0… ragelink 2243 }
afe42d0… ragelink 2244
afe42d0… ragelink 2245 function multipleContexts( selector, contexts, results ) {
afe42d0… ragelink 2246 var i = 0,
afe42d0… ragelink 2247 len = contexts.length;
afe42d0… ragelink 2248 for ( ; i < len; i++ ) {
afe42d0… ragelink 2249 find( selector, contexts[ i ], results );
afe42d0… ragelink 2250 }
afe42d0… ragelink 2251 return results;
afe42d0… ragelink 2252 }
afe42d0… ragelink 2253
afe42d0… ragelink 2254 function condense( unmatched, map, filter, context, xml ) {
afe42d0… ragelink 2255 var elem,
afe42d0… ragelink 2256 newUnmatched = [],
afe42d0… ragelink 2257 i = 0,
afe42d0… ragelink 2258 len = unmatched.length,
afe42d0… ragelink 2259 mapped = map != null;
afe42d0… ragelink 2260
afe42d0… ragelink 2261 for ( ; i < len; i++ ) {
afe42d0… ragelink 2262 if ( ( elem = unmatched[ i ] ) ) {
afe42d0… ragelink 2263 if ( !filter || filter( elem, context, xml ) ) {
afe42d0… ragelink 2264 newUnmatched.push( elem );
afe42d0… ragelink 2265 if ( mapped ) {
afe42d0… ragelink 2266 map.push( i );
afe42d0… ragelink 2267 }
afe42d0… ragelink 2268 }
afe42d0… ragelink 2269 }
afe42d0… ragelink 2270 }
afe42d0… ragelink 2271
afe42d0… ragelink 2272 return newUnmatched;
afe42d0… ragelink 2273 }
afe42d0… ragelink 2274
afe42d0… ragelink 2275 function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
afe42d0… ragelink 2276 if ( postFilter && !postFilter[ expando ] ) {
afe42d0… ragelink 2277 postFilter = setMatcher( postFilter );
afe42d0… ragelink 2278 }
afe42d0… ragelink 2279 if ( postFinder && !postFinder[ expando ] ) {
afe42d0… ragelink 2280 postFinder = setMatcher( postFinder, postSelector );
afe42d0… ragelink 2281 }
afe42d0… ragelink 2282 return markFunction( function( seed, results, context, xml ) {
afe42d0… ragelink 2283 var temp, i, elem, matcherOut,
afe42d0… ragelink 2284 preMap = [],
afe42d0… ragelink 2285 postMap = [],
afe42d0… ragelink 2286 preexisting = results.length,
afe42d0… ragelink 2287
afe42d0… ragelink 2288 // Get initial elements from seed or context
afe42d0… ragelink 2289 elems = seed ||
afe42d0… ragelink 2290 multipleContexts( selector || "*",
afe42d0… ragelink 2291 context.nodeType ? [ context ] : context, [] ),
afe42d0… ragelink 2292
afe42d0… ragelink 2293 // Prefilter to get matcher input, preserving a map for seed-results synchronization
afe42d0… ragelink 2294 matcherIn = preFilter && ( seed || !selector ) ?
afe42d0… ragelink 2295 condense( elems, preMap, preFilter, context, xml ) :
afe42d0… ragelink 2296 elems;
afe42d0… ragelink 2297
afe42d0… ragelink 2298 if ( matcher ) {
afe42d0… ragelink 2299
afe42d0… ragelink 2300 // If we have a postFinder, or filtered seed, or non-seed postFilter
afe42d0… ragelink 2301 // or preexisting results,
afe42d0… ragelink 2302 matcherOut = postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
afe42d0… ragelink 2303
afe42d0… ragelink 2304 // ...intermediate processing is necessary
afe42d0… ragelink 2305 [] :
afe42d0… ragelink 2306
afe42d0… ragelink 2307 // ...otherwise use results directly
afe42d0… ragelink 2308 results;
afe42d0… ragelink 2309
afe42d0… ragelink 2310 // Find primary matches
afe42d0… ragelink 2311 matcher( matcherIn, matcherOut, context, xml );
afe42d0… ragelink 2312 } else {
afe42d0… ragelink 2313 matcherOut = matcherIn;
afe42d0… ragelink 2314 }
afe42d0… ragelink 2315
afe42d0… ragelink 2316 // Apply postFilter
afe42d0… ragelink 2317 if ( postFilter ) {
afe42d0… ragelink 2318 temp = condense( matcherOut, postMap );
afe42d0… ragelink 2319 postFilter( temp, [], context, xml );
afe42d0… ragelink 2320
afe42d0… ragelink 2321 // Un-match failing elements by moving them back to matcherIn
afe42d0… ragelink 2322 i = temp.length;
afe42d0… ragelink 2323 while ( i-- ) {
afe42d0… ragelink 2324 if ( ( elem = temp[ i ] ) ) {
afe42d0… ragelink 2325 matcherOut[ postMap[ i ] ] = !( matcherIn[ postMap[ i ] ] = elem );
afe42d0… ragelink 2326 }
afe42d0… ragelink 2327 }
afe42d0… ragelink 2328 }
afe42d0… ragelink 2329
afe42d0… ragelink 2330 if ( seed ) {
afe42d0… ragelink 2331 if ( postFinder || preFilter ) {
afe42d0… ragelink 2332 if ( postFinder ) {
afe42d0… ragelink 2333
afe42d0… ragelink 2334 // Get the final matcherOut by condensing this intermediate into postFinder contexts
afe42d0… ragelink 2335 temp = [];
afe42d0… ragelink 2336 i = matcherOut.length;
afe42d0… ragelink 2337 while ( i-- ) {
afe42d0… ragelink 2338 if ( ( elem = matcherOut[ i ] ) ) {
afe42d0… ragelink 2339
afe42d0… ragelink 2340 // Restore matcherIn since elem is not yet a final match
afe42d0… ragelink 2341 temp.push( ( matcherIn[ i ] = elem ) );
afe42d0… ragelink 2342 }
afe42d0… ragelink 2343 }
afe42d0… ragelink 2344 postFinder( null, ( matcherOut = [] ), temp, xml );
afe42d0… ragelink 2345 }
afe42d0… ragelink 2346
afe42d0… ragelink 2347 // Move matched elements from seed to results to keep them synchronized
afe42d0… ragelink 2348 i = matcherOut.length;
afe42d0… ragelink 2349 while ( i-- ) {
afe42d0… ragelink 2350 if ( ( elem = matcherOut[ i ] ) &&
afe42d0… ragelink 2351 ( temp = postFinder ? indexOf.call( seed, elem ) : preMap[ i ] ) > -1 ) {
afe42d0… ragelink 2352
afe42d0… ragelink 2353 seed[ temp ] = !( results[ temp ] = elem );
afe42d0… ragelink 2354 }
afe42d0… ragelink 2355 }
afe42d0… ragelink 2356 }
afe42d0… ragelink 2357
afe42d0… ragelink 2358 // Add elements to results, through postFinder if defined
afe42d0… ragelink 2359 } else {
afe42d0… ragelink 2360 matcherOut = condense(
afe42d0… ragelink 2361 matcherOut === results ?
afe42d0… ragelink 2362 matcherOut.splice( preexisting, matcherOut.length ) :
afe42d0… ragelink 2363 matcherOut
afe42d0… ragelink 2364 );
afe42d0… ragelink 2365 if ( postFinder ) {
afe42d0… ragelink 2366 postFinder( null, results, matcherOut, xml );
afe42d0… ragelink 2367 } else {
afe42d0… ragelink 2368 push.apply( results, matcherOut );
afe42d0… ragelink 2369 }
afe42d0… ragelink 2370 }
afe42d0… ragelink 2371 } );
afe42d0… ragelink 2372 }
afe42d0… ragelink 2373
afe42d0… ragelink 2374 function matcherFromTokens( tokens ) {
afe42d0… ragelink 2375 var checkContext, matcher, j,
afe42d0… ragelink 2376 len = tokens.length,
afe42d0… ragelink 2377 leadingRelative = Expr.relative[ tokens[ 0 ].type ],
afe42d0… ragelink 2378 implicitRelative = leadingRelative || Expr.relative[ " " ],
afe42d0… ragelink 2379 i = leadingRelative ? 1 : 0,
afe42d0… ragelink 2380
afe42d0… ragelink 2381 // The foundational matcher ensures that elements are reachable from top-level context(s)
afe42d0… ragelink 2382 matchContext = addCombinator( function( elem ) {
afe42d0… ragelink 2383 return elem === checkContext;
afe42d0… ragelink 2384 }, implicitRelative, true ),
afe42d0… ragelink 2385 matchAnyContext = addCombinator( function( elem ) {
afe42d0… ragelink 2386 return indexOf.call( checkContext, elem ) > -1;
afe42d0… ragelink 2387 }, implicitRelative, true ),
afe42d0… ragelink 2388 matchers = [ function( elem, context, xml ) {
afe42d0… ragelink 2389
afe42d0… ragelink 2390 // Support: IE 11+, Edge 17 - 18+
afe42d0… ragelink 2391 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
afe42d0… ragelink 2392 // two documents; shallow comparisons work.
afe42d0… ragelink 2393 // eslint-disable-next-line eqeqeq
afe42d0… ragelink 2394 var ret = ( !leadingRelative && ( xml || context != outermostContext ) ) || (
afe42d0… ragelink 2395 ( checkContext = context ).nodeType ?
afe42d0… ragelink 2396 matchContext( elem, context, xml ) :
afe42d0… ragelink 2397 matchAnyContext( elem, context, xml ) );
afe42d0… ragelink 2398
afe42d0… ragelink 2399 // Avoid hanging onto element
afe42d0… ragelink 2400 // (see https://github.com/jquery/sizzle/issues/299)
afe42d0… ragelink 2401 checkContext = null;
afe42d0… ragelink 2402 return ret;
afe42d0… ragelink 2403 } ];
afe42d0… ragelink 2404
afe42d0… ragelink 2405 for ( ; i < len; i++ ) {
afe42d0… ragelink 2406 if ( ( matcher = Expr.relative[ tokens[ i ].type ] ) ) {
afe42d0… ragelink 2407 matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ];
afe42d0… ragelink 2408 } else {
afe42d0… ragelink 2409 matcher = Expr.filter[ tokens[ i ].type ].apply( null, tokens[ i ].matches );
afe42d0… ragelink 2410
afe42d0… ragelink 2411 // Return special upon seeing a positional matcher
afe42d0… ragelink 2412 if ( matcher[ expando ] ) {
afe42d0… ragelink 2413
afe42d0… ragelink 2414 // Find the next relative operator (if any) for proper handling
afe42d0… ragelink 2415 j = ++i;
afe42d0… ragelink 2416 for ( ; j < len; j++ ) {
afe42d0… ragelink 2417 if ( Expr.relative[ tokens[ j ].type ] ) {
afe42d0… ragelink 2418 break;
afe42d0… ragelink 2419 }
afe42d0… ragelink 2420 }
afe42d0… ragelink 2421 return setMatcher(
afe42d0… ragelink 2422 i > 1 && elementMatcher( matchers ),
afe42d0… ragelink 2423 i > 1 && toSelector(
afe42d0… ragelink 2424
afe42d0… ragelink 2425 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
afe42d0… ragelink 2426 tokens.slice( 0, i - 1 )
afe42d0… ragelink 2427 .concat( { value: tokens[ i - 2 ].type === " " ? "*" : "" } )
afe42d0… ragelink 2428 ).replace( rtrimCSS, "$1" ),
afe42d0… ragelink 2429 matcher,
afe42d0… ragelink 2430 i < j && matcherFromTokens( tokens.slice( i, j ) ),
afe42d0… ragelink 2431 j < len && matcherFromTokens( ( tokens = tokens.slice( j ) ) ),
afe42d0… ragelink 2432 j < len && toSelector( tokens )
afe42d0… ragelink 2433 );
afe42d0… ragelink 2434 }
afe42d0… ragelink 2435 matchers.push( matcher );
afe42d0… ragelink 2436 }
afe42d0… ragelink 2437 }
afe42d0… ragelink 2438
afe42d0… ragelink 2439 return elementMatcher( matchers );
afe42d0… ragelink 2440 }
afe42d0… ragelink 2441
afe42d0… ragelink 2442 function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
afe42d0… ragelink 2443 var bySet = setMatchers.length > 0,
afe42d0… ragelink 2444 byElement = elementMatchers.length > 0,
afe42d0… ragelink 2445 superMatcher = function( seed, context, xml, results, outermost ) {
afe42d0… ragelink 2446 var elem, j, matcher,
afe42d0… ragelink 2447 matchedCount = 0,
afe42d0… ragelink 2448 i = "0",
afe42d0… ragelink 2449 unmatched = seed && [],
afe42d0… ragelink 2450 setMatched = [],
afe42d0… ragelink 2451 contextBackup = outermostContext,
afe42d0… ragelink 2452
afe42d0… ragelink 2453 // We must always have either seed elements or outermost context
afe42d0… ragelink 2454 elems = seed || byElement && Expr.find.TAG( "*", outermost ),
afe42d0… ragelink 2455
afe42d0… ragelink 2456 // Use integer dirruns iff this is the outermost matcher
afe42d0… ragelink 2457 dirrunsUnique = ( dirruns += contextBackup == null ? 1 : Math.random() || 0.1 ),
afe42d0… ragelink 2458 len = elems.length;
afe42d0… ragelink 2459
afe42d0… ragelink 2460 if ( outermost ) {
afe42d0… ragelink 2461
afe42d0… ragelink 2462 // Support: IE 11+, Edge 17 - 18+
afe42d0… ragelink 2463 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
afe42d0… ragelink 2464 // two documents; shallow comparisons work.
afe42d0… ragelink 2465 // eslint-disable-next-line eqeqeq
afe42d0… ragelink 2466 outermostContext = context == document || context || outermost;
afe42d0… ragelink 2467 }
afe42d0… ragelink 2468
afe42d0… ragelink 2469 // Add elements passing elementMatchers directly to results
afe42d0… ragelink 2470 // Support: iOS <=7 - 9 only
afe42d0… ragelink 2471 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching
afe42d0… ragelink 2472 // elements by id. (see trac-14142)
afe42d0… ragelink 2473 for ( ; i !== len && ( elem = elems[ i ] ) != null; i++ ) {
afe42d0… ragelink 2474 if ( byElement && elem ) {
afe42d0… ragelink 2475 j = 0;
afe42d0… ragelink 2476
afe42d0… ragelink 2477 // Support: IE 11+, Edge 17 - 18+
afe42d0… ragelink 2478 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
afe42d0… ragelink 2479 // two documents; shallow comparisons work.
afe42d0… ragelink 2480 // eslint-disable-next-line eqeqeq
afe42d0… ragelink 2481 if ( !context && elem.ownerDocument != document ) {
afe42d0… ragelink 2482 setDocument( elem );
afe42d0… ragelink 2483 xml = !documentIsHTML;
afe42d0… ragelink 2484 }
afe42d0… ragelink 2485 while ( ( matcher = elementMatchers[ j++ ] ) ) {
afe42d0… ragelink 2486 if ( matcher( elem, context || document, xml ) ) {
afe42d0… ragelink 2487 push.call( results, elem );
afe42d0… ragelink 2488 break;
afe42d0… ragelink 2489 }
afe42d0… ragelink 2490 }
afe42d0… ragelink 2491 if ( outermost ) {
afe42d0… ragelink 2492 dirruns = dirrunsUnique;
afe42d0… ragelink 2493 }
afe42d0… ragelink 2494 }
afe42d0… ragelink 2495
afe42d0… ragelink 2496 // Track unmatched elements for set filters
afe42d0… ragelink 2497 if ( bySet ) {
afe42d0… ragelink 2498
afe42d0… ragelink 2499 // They will have gone through all possible matchers
afe42d0… ragelink 2500 if ( ( elem = !matcher && elem ) ) {
afe42d0… ragelink 2501 matchedCount--;
afe42d0… ragelink 2502 }
afe42d0… ragelink 2503
afe42d0… ragelink 2504 // Lengthen the array for every element, matched or not
afe42d0… ragelink 2505 if ( seed ) {
afe42d0… ragelink 2506 unmatched.push( elem );
afe42d0… ragelink 2507 }
afe42d0… ragelink 2508 }
afe42d0… ragelink 2509 }
afe42d0… ragelink 2510
afe42d0… ragelink 2511 // `i` is now the count of elements visited above, and adding it to `matchedCount`
afe42d0… ragelink 2512 // makes the latter nonnegative.
afe42d0… ragelink 2513 matchedCount += i;
afe42d0… ragelink 2514
afe42d0… ragelink 2515 // Apply set filters to unmatched elements
afe42d0… ragelink 2516 // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
afe42d0… ragelink 2517 // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
afe42d0… ragelink 2518 // no element matchers and no seed.
afe42d0… ragelink 2519 // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
afe42d0… ragelink 2520 // case, which will result in a "00" `matchedCount` that differs from `i` but is also
afe42d0… ragelink 2521 // numerically zero.
afe42d0… ragelink 2522 if ( bySet && i !== matchedCount ) {
afe42d0… ragelink 2523 j = 0;
afe42d0… ragelink 2524 while ( ( matcher = setMatchers[ j++ ] ) ) {
afe42d0… ragelink 2525 matcher( unmatched, setMatched, context, xml );
afe42d0… ragelink 2526 }
afe42d0… ragelink 2527
afe42d0… ragelink 2528 if ( seed ) {
afe42d0… ragelink 2529
afe42d0… ragelink 2530 // Reintegrate element matches to eliminate the need for sorting
afe42d0… ragelink 2531 if ( matchedCount > 0 ) {
afe42d0… ragelink 2532 while ( i-- ) {
afe42d0… ragelink 2533 if ( !( unmatched[ i ] || setMatched[ i ] ) ) {
afe42d0… ragelink 2534 setMatched[ i ] = pop.call( results );
afe42d0… ragelink 2535 }
afe42d0… ragelink 2536 }
afe42d0… ragelink 2537 }
afe42d0… ragelink 2538
afe42d0… ragelink 2539 // Discard index placeholder values to get only actual matches
afe42d0… ragelink 2540 setMatched = condense( setMatched );
afe42d0… ragelink 2541 }
afe42d0… ragelink 2542
afe42d0… ragelink 2543 // Add matches to results
afe42d0… ragelink 2544 push.apply( results, setMatched );
afe42d0… ragelink 2545
afe42d0… ragelink 2546 // Seedless set matches succeeding multiple successful matchers stipulate sorting
afe42d0… ragelink 2547 if ( outermost && !seed && setMatched.length > 0 &&
afe42d0… ragelink 2548 ( matchedCount + setMatchers.length ) > 1 ) {
afe42d0… ragelink 2549
afe42d0… ragelink 2550 jQuery.uniqueSort( results );
afe42d0… ragelink 2551 }
afe42d0… ragelink 2552 }
afe42d0… ragelink 2553
afe42d0… ragelink 2554 // Override manipulation of globals by nested matchers
afe42d0… ragelink 2555 if ( outermost ) {
afe42d0… ragelink 2556 dirruns = dirrunsUnique;
afe42d0… ragelink 2557 outermostContext = contextBackup;
afe42d0… ragelink 2558 }
afe42d0… ragelink 2559
afe42d0… ragelink 2560 return unmatched;
afe42d0… ragelink 2561 };
afe42d0… ragelink 2562
afe42d0… ragelink 2563 return bySet ?
afe42d0… ragelink 2564 markFunction( superMatcher ) :
afe42d0… ragelink 2565 superMatcher;
afe42d0… ragelink 2566 }
afe42d0… ragelink 2567
afe42d0… ragelink 2568 function compile( selector, match /* Internal Use Only */ ) {
afe42d0… ragelink 2569 var i,
afe42d0… ragelink 2570 setMatchers = [],
afe42d0… ragelink 2571 elementMatchers = [],
afe42d0… ragelink 2572 cached = compilerCache[ selector + " " ];
afe42d0… ragelink 2573
afe42d0… ragelink 2574 if ( !cached ) {
afe42d0… ragelink 2575
afe42d0… ragelink 2576 // Generate a function of recursive functions that can be used to check each element
afe42d0… ragelink 2577 if ( !match ) {
afe42d0… ragelink 2578 match = tokenize( selector );
afe42d0… ragelink 2579 }
afe42d0… ragelink 2580 i = match.length;
afe42d0… ragelink 2581 while ( i-- ) {
afe42d0… ragelink 2582 cached = matcherFromTokens( match[ i ] );
afe42d0… ragelink 2583 if ( cached[ expando ] ) {
afe42d0… ragelink 2584 setMatchers.push( cached );
afe42d0… ragelink 2585 } else {
afe42d0… ragelink 2586 elementMatchers.push( cached );
afe42d0… ragelink 2587 }
afe42d0… ragelink 2588 }
afe42d0… ragelink 2589
afe42d0… ragelink 2590 // Cache the compiled function
afe42d0… ragelink 2591 cached = compilerCache( selector,
afe42d0… ragelink 2592 matcherFromGroupMatchers( elementMatchers, setMatchers ) );
afe42d0… ragelink 2593
afe42d0… ragelink 2594 // Save selector and tokenization
afe42d0… ragelink 2595 cached.selector = selector;
afe42d0… ragelink 2596 }
afe42d0… ragelink 2597 return cached;
afe42d0… ragelink 2598 }
afe42d0… ragelink 2599
afe42d0… ragelink 2600 /**
afe42d0… ragelink 2601 * A low-level selection function that works with jQuery's compiled
afe42d0… ragelink 2602 * selector functions
afe42d0… ragelink 2603 * @param {String|Function} selector A selector or a pre-compiled
afe42d0… ragelink 2604 * selector function built with jQuery selector compile
afe42d0… ragelink 2605 * @param {Element} context
afe42d0… ragelink 2606 * @param {Array} [results]
afe42d0… ragelink 2607 * @param {Array} [seed] A set of elements to match against
afe42d0… ragelink 2608 */
afe42d0… ragelink 2609 function select( selector, context, results, seed ) {
afe42d0… ragelink 2610 var i, tokens, token, type, find,
afe42d0… ragelink 2611 compiled = typeof selector === "function" && selector,
afe42d0… ragelink 2612 match = !seed && tokenize( ( selector = compiled.selector || selector ) );
afe42d0… ragelink 2613
afe42d0… ragelink 2614 results = results || [];
afe42d0… ragelink 2615
afe42d0… ragelink 2616 // Try to minimize operations if there is only one selector in the list and no seed
afe42d0… ragelink 2617 // (the latter of which guarantees us context)
afe42d0… ragelink 2618 if ( match.length === 1 ) {
afe42d0… ragelink 2619
afe42d0… ragelink 2620 // Reduce context if the leading compound selector is an ID
afe42d0… ragelink 2621 tokens = match[ 0 ] = match[ 0 ].slice( 0 );
afe42d0… ragelink 2622 if ( tokens.length > 2 && ( token = tokens[ 0 ] ).type === "ID" &&
afe42d0… ragelink 2623 context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[ 1 ].type ] ) {
afe42d0… ragelink 2624
afe42d0… ragelink 2625 context = ( Expr.find.ID(
afe42d0… ragelink 2626 token.matches[ 0 ].replace( runescape, funescape ),
afe42d0… ragelink 2627 context
afe42d0… ragelink 2628 ) || [] )[ 0 ];
afe42d0… ragelink 2629 if ( !context ) {
afe42d0… ragelink 2630 return results;
afe42d0… ragelink 2631
afe42d0… ragelink 2632 // Precompiled matchers will still verify ancestry, so step up a level
afe42d0… ragelink 2633 } else if ( compiled ) {
afe42d0… ragelink 2634 context = context.parentNode;
afe42d0… ragelink 2635 }
afe42d0… ragelink 2636
afe42d0… ragelink 2637 selector = selector.slice( tokens.shift().value.length );
afe42d0… ragelink 2638 }
afe42d0… ragelink 2639
afe42d0… ragelink 2640 // Fetch a seed set for right-to-left matching
afe42d0… ragelink 2641 i = matchExpr.needsContext.test( selector ) ? 0 : tokens.length;
afe42d0… ragelink 2642 while ( i-- ) {
afe42d0… ragelink 2643 token = tokens[ i ];
afe42d0… ragelink 2644
afe42d0… ragelink 2645 // Abort if we hit a combinator
afe42d0… ragelink 2646 if ( Expr.relative[ ( type = token.type ) ] ) {
afe42d0… ragelink 2647 break;
afe42d0… ragelink 2648 }
afe42d0… ragelink 2649 if ( ( find = Expr.find[ type ] ) ) {
afe42d0… ragelink 2650
afe42d0… ragelink 2651 // Search, expanding context for leading sibling combinators
afe42d0… ragelink 2652 if ( ( seed = find(
afe42d0… ragelink 2653 token.matches[ 0 ].replace( runescape, funescape ),
afe42d0… ragelink 2654 rsibling.test( tokens[ 0 ].type ) &&
afe42d0… ragelink 2655 testContext( context.parentNode ) || context
afe42d0… ragelink 2656 ) ) ) {
afe42d0… ragelink 2657
afe42d0… ragelink 2658 // If seed is empty or no tokens remain, we can return early
afe42d0… ragelink 2659 tokens.splice( i, 1 );
afe42d0… ragelink 2660 selector = seed.length && toSelector( tokens );
afe42d0… ragelink 2661 if ( !selector ) {
afe42d0… ragelink 2662 push.apply( results, seed );
afe42d0… ragelink 2663 return results;
afe42d0… ragelink 2664 }
afe42d0… ragelink 2665
afe42d0… ragelink 2666 break;
afe42d0… ragelink 2667 }
afe42d0… ragelink 2668 }
afe42d0… ragelink 2669 }
afe42d0… ragelink 2670 }
afe42d0… ragelink 2671
afe42d0… ragelink 2672 // Compile and execute a filtering function if one is not provided
afe42d0… ragelink 2673 // Provide `match` to avoid retokenization if we modified the selector above
afe42d0… ragelink 2674 ( compiled || compile( selector, match ) )(
afe42d0… ragelink 2675 seed,
afe42d0… ragelink 2676 context,
afe42d0… ragelink 2677 !documentIsHTML,
afe42d0… ragelink 2678 results,
afe42d0… ragelink 2679 !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
afe42d0… ragelink 2680 );
afe42d0… ragelink 2681 return results;
afe42d0… ragelink 2682 }
afe42d0… ragelink 2683
afe42d0… ragelink 2684 // One-time assignments
afe42d0… ragelink 2685
afe42d0… ragelink 2686 // Support: Android <=4.0 - 4.1+
afe42d0… ragelink 2687 // Sort stability
afe42d0… ragelink 2688 support.sortStable = expando.split( "" ).sort( sortOrder ).join( "" ) === expando;
afe42d0… ragelink 2689
afe42d0… ragelink 2690 // Initialize against the default document
afe42d0… ragelink 2691 setDocument();
afe42d0… ragelink 2692
afe42d0… ragelink 2693 // Support: Android <=4.0 - 4.1+
afe42d0… ragelink 2694 // Detached nodes confoundingly follow *each other*
afe42d0… ragelink 2695 support.sortDetached = assert( function( el ) {
afe42d0… ragelink 2696
afe42d0… ragelink 2697 // Should return 1, but returns 4 (following)
afe42d0… ragelink 2698 return el.compareDocumentPosition( document.createElement( "fieldset" ) ) & 1;
afe42d0… ragelink 2699 } );
afe42d0… ragelink 2700
afe42d0… ragelink 2701 jQuery.find = find;
afe42d0… ragelink 2702
afe42d0… ragelink 2703 // Deprecated
afe42d0… ragelink 2704 jQuery.expr[ ":" ] = jQuery.expr.pseudos;
afe42d0… ragelink 2705 jQuery.unique = jQuery.uniqueSort;
afe42d0… ragelink 2706
afe42d0… ragelink 2707 // These have always been private, but they used to be documented as part of
afe42d0… ragelink 2708 // Sizzle so let's maintain them for now for backwards compatibility purposes.
afe42d0… ragelink 2709 find.compile = compile;
afe42d0… ragelink 2710 find.select = select;
afe42d0… ragelink 2711 find.setDocument = setDocument;
afe42d0… ragelink 2712 find.tokenize = tokenize;
afe42d0… ragelink 2713
afe42d0… ragelink 2714 find.escape = jQuery.escapeSelector;
afe42d0… ragelink 2715 find.getText = jQuery.text;
afe42d0… ragelink 2716 find.isXML = jQuery.isXMLDoc;
afe42d0… ragelink 2717 find.selectors = jQuery.expr;
afe42d0… ragelink 2718 find.support = jQuery.support;
afe42d0… ragelink 2719 find.uniqueSort = jQuery.uniqueSort;
afe42d0… ragelink 2720
afe42d0… ragelink 2721 /* eslint-enable */
afe42d0… ragelink 2722
afe42d0… ragelink 2723 } )();
afe42d0… ragelink 2724
afe42d0… ragelink 2725
afe42d0… ragelink 2726 var dir = function( elem, dir, until ) {
afe42d0… ragelink 2727 var matched = [],
afe42d0… ragelink 2728 truncate = until !== undefined;
afe42d0… ragelink 2729
afe42d0… ragelink 2730 while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
afe42d0… ragelink 2731 if ( elem.nodeType === 1 ) {
afe42d0… ragelink 2732 if ( truncate && jQuery( elem ).is( until ) ) {
afe42d0… ragelink 2733 break;
afe42d0… ragelink 2734 }
afe42d0… ragelink 2735 matched.push( elem );
afe42d0… ragelink 2736 }
afe42d0… ragelink 2737 }
afe42d0… ragelink 2738 return matched;
afe42d0… ragelink 2739 };
afe42d0… ragelink 2740
afe42d0… ragelink 2741
afe42d0… ragelink 2742 var siblings = function( n, elem ) {
afe42d0… ragelink 2743 var matched = [];
afe42d0… ragelink 2744
afe42d0… ragelink 2745 for ( ; n; n = n.nextSibling ) {
afe42d0… ragelink 2746 if ( n.nodeType === 1 && n !== elem ) {
afe42d0… ragelink 2747 matched.push( n );
afe42d0… ragelink 2748 }
afe42d0… ragelink 2749 }
afe42d0… ragelink 2750
afe42d0… ragelink 2751 return matched;
afe42d0… ragelink 2752 };
afe42d0… ragelink 2753
afe42d0… ragelink 2754
afe42d0… ragelink 2755 var rneedsContext = jQuery.expr.match.needsContext;
afe42d0… ragelink 2756
afe42d0… ragelink 2757 var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
afe42d0… ragelink 2758
afe42d0… ragelink 2759
afe42d0… ragelink 2760
afe42d0… ragelink 2761 // Implement the identical functionality for filter and not
afe42d0… ragelink 2762 function winnow( elements, qualifier, not ) {
afe42d0… ragelink 2763 if ( isFunction( qualifier ) ) {
afe42d0… ragelink 2764 return jQuery.grep( elements, function( elem, i ) {
afe42d0… ragelink 2765 return !!qualifier.call( elem, i, elem ) !== not;
afe42d0… ragelink 2766 } );
afe42d0… ragelink 2767 }
afe42d0… ragelink 2768
afe42d0… ragelink 2769 // Single element
afe42d0… ragelink 2770 if ( qualifier.nodeType ) {
afe42d0… ragelink 2771 return jQuery.grep( elements, function( elem ) {
afe42d0… ragelink 2772 return ( elem === qualifier ) !== not;
afe42d0… ragelink 2773 } );
afe42d0… ragelink 2774 }
afe42d0… ragelink 2775
afe42d0… ragelink 2776 // Arraylike of elements (jQuery, arguments, Array)
afe42d0… ragelink 2777 if ( typeof qualifier !== "string" ) {
afe42d0… ragelink 2778 return jQuery.grep( elements, function( elem ) {
afe42d0… ragelink 2779 return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
afe42d0… ragelink 2780 } );
afe42d0… ragelink 2781 }
afe42d0… ragelink 2782
afe42d0… ragelink 2783 // Filtered directly for both simple and complex selectors
afe42d0… ragelink 2784 return jQuery.filter( qualifier, elements, not );
afe42d0… ragelink 2785 }
afe42d0… ragelink 2786
afe42d0… ragelink 2787 jQuery.filter = function( expr, elems, not ) {
afe42d0… ragelink 2788 var elem = elems[ 0 ];
afe42d0… ragelink 2789
afe42d0… ragelink 2790 if ( not ) {
afe42d0… ragelink 2791 expr = ":not(" + expr + ")";
afe42d0… ragelink 2792 }
afe42d0… ragelink 2793
afe42d0… ragelink 2794 if ( elems.length === 1 && elem.nodeType === 1 ) {
afe42d0… ragelink 2795 return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [];
afe42d0… ragelink 2796 }
afe42d0… ragelink 2797
afe42d0… ragelink 2798 return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
afe42d0… ragelink 2799 return elem.nodeType === 1;
afe42d0… ragelink 2800 } ) );
afe42d0… ragelink 2801 };
afe42d0… ragelink 2802
afe42d0… ragelink 2803 jQuery.fn.extend( {
afe42d0… ragelink 2804 find: function( selector ) {
afe42d0… ragelink 2805 var i, ret,
afe42d0… ragelink 2806 len = this.length,
afe42d0… ragelink 2807 self = this;
afe42d0… ragelink 2808
afe42d0… ragelink 2809 if ( typeof selector !== "string" ) {
afe42d0… ragelink 2810 return this.pushStack( jQuery( selector ).filter( function() {
afe42d0… ragelink 2811 for ( i = 0; i < len; i++ ) {
afe42d0… ragelink 2812 if ( jQuery.contains( self[ i ], this ) ) {
afe42d0… ragelink 2813 return true;
afe42d0… ragelink 2814 }
afe42d0… ragelink 2815 }
afe42d0… ragelink 2816 } ) );
afe42d0… ragelink 2817 }
afe42d0… ragelink 2818
afe42d0… ragelink 2819 ret = this.pushStack( [] );
afe42d0… ragelink 2820
afe42d0… ragelink 2821 for ( i = 0; i < len; i++ ) {
afe42d0… ragelink 2822 jQuery.find( selector, self[ i ], ret );
afe42d0… ragelink 2823 }
afe42d0… ragelink 2824
afe42d0… ragelink 2825 return len > 1 ? jQuery.uniqueSort( ret ) : ret;
afe42d0… ragelink 2826 },
afe42d0… ragelink 2827 filter: function( selector ) {
afe42d0… ragelink 2828 return this.pushStack( winnow( this, selector || [], false ) );
afe42d0… ragelink 2829 },
afe42d0… ragelink 2830 not: function( selector ) {
afe42d0… ragelink 2831 return this.pushStack( winnow( this, selector || [], true ) );
afe42d0… ragelink 2832 },
afe42d0… ragelink 2833 is: function( selector ) {
afe42d0… ragelink 2834 return !!winnow(
afe42d0… ragelink 2835 this,
afe42d0… ragelink 2836
afe42d0… ragelink 2837 // If this is a positional/relative selector, check membership in the returned set
afe42d0… ragelink 2838 // so $("p:first").is("p:last") won't return true for a doc with two "p".
afe42d0… ragelink 2839 typeof selector === "string" && rneedsContext.test( selector ) ?
afe42d0… ragelink 2840 jQuery( selector ) :
afe42d0… ragelink 2841 selector || [],
afe42d0… ragelink 2842 false
afe42d0… ragelink 2843 ).length;
afe42d0… ragelink 2844 }
afe42d0… ragelink 2845 } );
afe42d0… ragelink 2846
afe42d0… ragelink 2847
afe42d0… ragelink 2848 // Initialize a jQuery object
afe42d0… ragelink 2849
afe42d0… ragelink 2850
afe42d0… ragelink 2851 // A central reference to the root jQuery(document)
afe42d0… ragelink 2852 var rootjQuery,
afe42d0… ragelink 2853
afe42d0… ragelink 2854 // A simple way to check for HTML strings
afe42d0… ragelink 2855 // Prioritize #id over <tag> to avoid XSS via location.hash (trac-9521)
afe42d0… ragelink 2856 // Strict HTML recognition (trac-11290: must start with <)
afe42d0… ragelink 2857 // Shortcut simple #id case for speed
afe42d0… ragelink 2858 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
afe42d0… ragelink 2859
afe42d0… ragelink 2860 init = jQuery.fn.init = function( selector, context, root ) {
afe42d0… ragelink 2861 var match, elem;
afe42d0… ragelink 2862
afe42d0… ragelink 2863 // HANDLE: $(""), $(null), $(undefined), $(false)
afe42d0… ragelink 2864 if ( !selector ) {
afe42d0… ragelink 2865 return this;
afe42d0… ragelink 2866 }
afe42d0… ragelink 2867
afe42d0… ragelink 2868 // Method init() accepts an alternate rootjQuery
afe42d0… ragelink 2869 // so migrate can support jQuery.sub (gh-2101)
afe42d0… ragelink 2870 root = root || rootjQuery;
afe42d0… ragelink 2871
afe42d0… ragelink 2872 // Handle HTML strings
afe42d0… ragelink 2873 if ( typeof selector === "string" ) {
afe42d0… ragelink 2874 if ( selector[ 0 ] === "<" &&
afe42d0… ragelink 2875 selector[ selector.length - 1 ] === ">" &&
afe42d0… ragelink 2876 selector.length >= 3 ) {
afe42d0… ragelink 2877
afe42d0… ragelink 2878 // Assume that strings that start and end with <> are HTML and skip the regex check
afe42d0… ragelink 2879 match = [ null, selector, null ];
afe42d0… ragelink 2880
afe42d0… ragelink 2881 } else {
afe42d0… ragelink 2882 match = rquickExpr.exec( selector );
afe42d0… ragelink 2883 }
afe42d0… ragelink 2884
afe42d0… ragelink 2885 // Match html or make sure no context is specified for #id
afe42d0… ragelink 2886 if ( match && ( match[ 1 ] || !context ) ) {
afe42d0… ragelink 2887
afe42d0… ragelink 2888 // HANDLE: $(html) -> $(array)
afe42d0… ragelink 2889 if ( match[ 1 ] ) {
afe42d0… ragelink 2890 context = context instanceof jQuery ? context[ 0 ] : context;
afe42d0… ragelink 2891
afe42d0… ragelink 2892 // Option to run scripts is true for back-compat
afe42d0… ragelink 2893 // Intentionally let the error be thrown if parseHTML is not present
afe42d0… ragelink 2894 jQuery.merge( this, jQuery.parseHTML(
afe42d0… ragelink 2895 match[ 1 ],
afe42d0… ragelink 2896 context && context.nodeType ? context.ownerDocument || context : document,
afe42d0… ragelink 2897 true
afe42d0… ragelink 2898 ) );
afe42d0… ragelink 2899
afe42d0… ragelink 2900 // HANDLE: $(html, props)
afe42d0… ragelink 2901 if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
afe42d0… ragelink 2902 for ( match in context ) {
afe42d0… ragelink 2903
afe42d0… ragelink 2904 // Properties of context are called as methods if possible
afe42d0… ragelink 2905 if ( isFunction( this[ match ] ) ) {
afe42d0… ragelink 2906 this[ match ]( context[ match ] );
afe42d0… ragelink 2907
afe42d0… ragelink 2908 // ...and otherwise set as attributes
afe42d0… ragelink 2909 } else {
afe42d0… ragelink 2910 this.attr( match, context[ match ] );
afe42d0… ragelink 2911 }
afe42d0… ragelink 2912 }
afe42d0… ragelink 2913 }
afe42d0… ragelink 2914
afe42d0… ragelink 2915 return this;
afe42d0… ragelink 2916
afe42d0… ragelink 2917 // HANDLE: $(#id)
afe42d0… ragelink 2918 } else {
afe42d0… ragelink 2919 elem = document.getElementById( match[ 2 ] );
afe42d0… ragelink 2920
afe42d0… ragelink 2921 if ( elem ) {
afe42d0… ragelink 2922
afe42d0… ragelink 2923 // Inject the element directly into the jQuery object
afe42d0… ragelink 2924 this[ 0 ] = elem;
afe42d0… ragelink 2925 this.length = 1;
afe42d0… ragelink 2926 }
afe42d0… ragelink 2927 return this;
afe42d0… ragelink 2928 }
afe42d0… ragelink 2929
afe42d0… ragelink 2930 // HANDLE: $(expr, $(...))
afe42d0… ragelink 2931 } else if ( !context || context.jquery ) {
afe42d0… ragelink 2932 return ( context || root ).find( selector );
afe42d0… ragelink 2933
afe42d0… ragelink 2934 // HANDLE: $(expr, context)
afe42d0… ragelink 2935 // (which is just equivalent to: $(context).find(expr)
afe42d0… ragelink 2936 } else {
afe42d0… ragelink 2937 return this.constructor( context ).find( selector );
afe42d0… ragelink 2938 }
afe42d0… ragelink 2939
afe42d0… ragelink 2940 // HANDLE: $(DOMElement)
afe42d0… ragelink 2941 } else if ( selector.nodeType ) {
afe42d0… ragelink 2942 this[ 0 ] = selector;
afe42d0… ragelink 2943 this.length = 1;
afe42d0… ragelink 2944 return this;
afe42d0… ragelink 2945
afe42d0… ragelink 2946 // HANDLE: $(function)
afe42d0… ragelink 2947 // Shortcut for document ready
afe42d0… ragelink 2948 } else if ( isFunction( selector ) ) {
afe42d0… ragelink 2949 return root.ready !== undefined ?
afe42d0… ragelink 2950 root.ready( selector ) :
afe42d0… ragelink 2951
afe42d0… ragelink 2952 // Execute immediately if ready is not present
afe42d0… ragelink 2953 selector( jQuery );
afe42d0… ragelink 2954 }
afe42d0… ragelink 2955
afe42d0… ragelink 2956 return jQuery.makeArray( selector, this );
afe42d0… ragelink 2957 };
afe42d0… ragelink 2958
afe42d0… ragelink 2959 // Give the init function the jQuery prototype for later instantiation
afe42d0… ragelink 2960 init.prototype = jQuery.fn;
afe42d0… ragelink 2961
afe42d0… ragelink 2962 // Initialize central reference
afe42d0… ragelink 2963 rootjQuery = jQuery( document );
afe42d0… ragelink 2964
afe42d0… ragelink 2965
afe42d0… ragelink 2966 var rparentsprev = /^(?:parents|prev(?:Until|All))/,
afe42d0… ragelink 2967
afe42d0… ragelink 2968 // Methods guaranteed to produce a unique set when starting from a unique set
afe42d0… ragelink 2969 guaranteedUnique = {
afe42d0… ragelink 2970 children: true,
afe42d0… ragelink 2971 contents: true,
afe42d0… ragelink 2972 next: true,
afe42d0… ragelink 2973 prev: true
afe42d0… ragelink 2974 };
afe42d0… ragelink 2975
afe42d0… ragelink 2976 jQuery.fn.extend( {
afe42d0… ragelink 2977 has: function( target ) {
afe42d0… ragelink 2978 var targets = jQuery( target, this ),
afe42d0… ragelink 2979 l = targets.length;
afe42d0… ragelink 2980
afe42d0… ragelink 2981 return this.filter( function() {
afe42d0… ragelink 2982 var i = 0;
afe42d0… ragelink 2983 for ( ; i < l; i++ ) {
afe42d0… ragelink 2984 if ( jQuery.contains( this, targets[ i ] ) ) {
afe42d0… ragelink 2985 return true;
afe42d0… ragelink 2986 }
afe42d0… ragelink 2987 }
afe42d0… ragelink 2988 } );
afe42d0… ragelink 2989 },
afe42d0… ragelink 2990
afe42d0… ragelink 2991 closest: function( selectors, context ) {
afe42d0… ragelink 2992 var cur,
afe42d0… ragelink 2993 i = 0,
afe42d0… ragelink 2994 l = this.length,
afe42d0… ragelink 2995 matched = [],
afe42d0… ragelink 2996 targets = typeof selectors !== "string" && jQuery( selectors );
afe42d0… ragelink 2997
afe42d0… ragelink 2998 // Positional selectors never match, since there's no _selection_ context
afe42d0… ragelink 2999 if ( !rneedsContext.test( selectors ) ) {
afe42d0… ragelink 3000 for ( ; i < l; i++ ) {
afe42d0… ragelink 3001 for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
afe42d0… ragelink 3002
afe42d0… ragelink 3003 // Always skip document fragments
afe42d0… ragelink 3004 if ( cur.nodeType < 11 && ( targets ?
afe42d0… ragelink 3005 targets.index( cur ) > -1 :
afe42d0… ragelink 3006
afe42d0… ragelink 3007 // Don't pass non-elements to jQuery#find
afe42d0… ragelink 3008 cur.nodeType === 1 &&
afe42d0… ragelink 3009 jQuery.find.matchesSelector( cur, selectors ) ) ) {
afe42d0… ragelink 3010
afe42d0… ragelink 3011 matched.push( cur );
afe42d0… ragelink 3012 break;
afe42d0… ragelink 3013 }
afe42d0… ragelink 3014 }
afe42d0… ragelink 3015 }
afe42d0… ragelink 3016 }
afe42d0… ragelink 3017
afe42d0… ragelink 3018 return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
afe42d0… ragelink 3019 },
afe42d0… ragelink 3020
afe42d0… ragelink 3021 // Determine the position of an element within the set
afe42d0… ragelink 3022 index: function( elem ) {
afe42d0… ragelink 3023
afe42d0… ragelink 3024 // No argument, return index in parent
afe42d0… ragelink 3025 if ( !elem ) {
afe42d0… ragelink 3026 return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
afe42d0… ragelink 3027 }
afe42d0… ragelink 3028
afe42d0… ragelink 3029 // Index in selector
afe42d0… ragelink 3030 if ( typeof elem === "string" ) {
afe42d0… ragelink 3031 return indexOf.call( jQuery( elem ), this[ 0 ] );
afe42d0… ragelink 3032 }
afe42d0… ragelink 3033
afe42d0… ragelink 3034 // Locate the position of the desired element
afe42d0… ragelink 3035 return indexOf.call( this,
afe42d0… ragelink 3036
afe42d0… ragelink 3037 // If it receives a jQuery object, the first element is used
afe42d0… ragelink 3038 elem.jquery ? elem[ 0 ] : elem
afe42d0… ragelink 3039 );
afe42d0… ragelink 3040 },
afe42d0… ragelink 3041
afe42d0… ragelink 3042 add: function( selector, context ) {
afe42d0… ragelink 3043 return this.pushStack(
afe42d0… ragelink 3044 jQuery.uniqueSort(
afe42d0… ragelink 3045 jQuery.merge( this.get(), jQuery( selector, context ) )
afe42d0… ragelink 3046 )
afe42d0… ragelink 3047 );
afe42d0… ragelink 3048 },
afe42d0… ragelink 3049
afe42d0… ragelink 3050 addBack: function( selector ) {
afe42d0… ragelink 3051 return this.add( selector == null ?
afe42d0… ragelink 3052 this.prevObject : this.prevObject.filter( selector )
afe42d0… ragelink 3053 );
afe42d0… ragelink 3054 }
afe42d0… ragelink 3055 } );
afe42d0… ragelink 3056
afe42d0… ragelink 3057 function sibling( cur, dir ) {
afe42d0… ragelink 3058 while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
afe42d0… ragelink 3059 return cur;
afe42d0… ragelink 3060 }
afe42d0… ragelink 3061
afe42d0… ragelink 3062 jQuery.each( {
afe42d0… ragelink 3063 parent: function( elem ) {
afe42d0… ragelink 3064 var parent = elem.parentNode;
afe42d0… ragelink 3065 return parent && parent.nodeType !== 11 ? parent : null;
afe42d0… ragelink 3066 },
afe42d0… ragelink 3067 parents: function( elem ) {
afe42d0… ragelink 3068 return dir( elem, "parentNode" );
afe42d0… ragelink 3069 },
afe42d0… ragelink 3070 parentsUntil: function( elem, _i, until ) {
afe42d0… ragelink 3071 return dir( elem, "parentNode", until );
afe42d0… ragelink 3072 },
afe42d0… ragelink 3073 next: function( elem ) {
afe42d0… ragelink 3074 return sibling( elem, "nextSibling" );
afe42d0… ragelink 3075 },
afe42d0… ragelink 3076 prev: function( elem ) {
afe42d0… ragelink 3077 return sibling( elem, "previousSibling" );
afe42d0… ragelink 3078 },
afe42d0… ragelink 3079 nextAll: function( elem ) {
afe42d0… ragelink 3080 return dir( elem, "nextSibling" );
afe42d0… ragelink 3081 },
afe42d0… ragelink 3082 prevAll: function( elem ) {
afe42d0… ragelink 3083 return dir( elem, "previousSibling" );
afe42d0… ragelink 3084 },
afe42d0… ragelink 3085 nextUntil: function( elem, _i, until ) {
afe42d0… ragelink 3086 return dir( elem, "nextSibling", until );
afe42d0… ragelink 3087 },
afe42d0… ragelink 3088 prevUntil: function( elem, _i, until ) {
afe42d0… ragelink 3089 return dir( elem, "previousSibling", until );
afe42d0… ragelink 3090 },
afe42d0… ragelink 3091 siblings: function( elem ) {
afe42d0… ragelink 3092 return siblings( ( elem.parentNode || {} ).firstChild, elem );
afe42d0… ragelink 3093 },
afe42d0… ragelink 3094 children: function( elem ) {
afe42d0… ragelink 3095 return siblings( elem.firstChild );
afe42d0… ragelink 3096 },
afe42d0… ragelink 3097 contents: function( elem ) {
afe42d0… ragelink 3098 if ( elem.contentDocument != null &&
afe42d0… ragelink 3099
afe42d0… ragelink 3100 // Support: IE 11+
afe42d0… ragelink 3101 // <object> elements with no `data` attribute has an object
afe42d0… ragelink 3102 // `contentDocument` with a `null` prototype.
afe42d0… ragelink 3103 getProto( elem.contentDocument ) ) {
afe42d0… ragelink 3104
afe42d0… ragelink 3105 return elem.contentDocument;
afe42d0… ragelink 3106 }
afe42d0… ragelink 3107
afe42d0… ragelink 3108 // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
afe42d0… ragelink 3109 // Treat the template element as a regular one in browsers that
afe42d0… ragelink 3110 // don't support it.
afe42d0… ragelink 3111 if ( nodeName( elem, "template" ) ) {
afe42d0… ragelink 3112 elem = elem.content || elem;
afe42d0… ragelink 3113 }
afe42d0… ragelink 3114
afe42d0… ragelink 3115 return jQuery.merge( [], elem.childNodes );
afe42d0… ragelink 3116 }
afe42d0… ragelink 3117 }, function( name, fn ) {
afe42d0… ragelink 3118 jQuery.fn[ name ] = function( until, selector ) {
afe42d0… ragelink 3119 var matched = jQuery.map( this, fn, until );
afe42d0… ragelink 3120
afe42d0… ragelink 3121 if ( name.slice( -5 ) !== "Until" ) {
afe42d0… ragelink 3122 selector = until;
afe42d0… ragelink 3123 }
afe42d0… ragelink 3124
afe42d0… ragelink 3125 if ( selector && typeof selector === "string" ) {
afe42d0… ragelink 3126 matched = jQuery.filter( selector, matched );
afe42d0… ragelink 3127 }
afe42d0… ragelink 3128
afe42d0… ragelink 3129 if ( this.length > 1 ) {
afe42d0… ragelink 3130
afe42d0… ragelink 3131 // Remove duplicates
afe42d0… ragelink 3132 if ( !guaranteedUnique[ name ] ) {
afe42d0… ragelink 3133 jQuery.uniqueSort( matched );
afe42d0… ragelink 3134 }
afe42d0… ragelink 3135
afe42d0… ragelink 3136 // Reverse order for parents* and prev-derivatives
afe42d0… ragelink 3137 if ( rparentsprev.test( name ) ) {
afe42d0… ragelink 3138 matched.reverse();
afe42d0… ragelink 3139 }
afe42d0… ragelink 3140 }
afe42d0… ragelink 3141
afe42d0… ragelink 3142 return this.pushStack( matched );
afe42d0… ragelink 3143 };
afe42d0… ragelink 3144 } );
afe42d0… ragelink 3145 var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g );
afe42d0… ragelink 3146
afe42d0… ragelink 3147
afe42d0… ragelink 3148
afe42d0… ragelink 3149 // Convert String-formatted options into Object-formatted ones
afe42d0… ragelink 3150 function createOptions( options ) {
afe42d0… ragelink 3151 var object = {};
afe42d0… ragelink 3152 jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) {
afe42d0… ragelink 3153 object[ flag ] = true;
afe42d0… ragelink 3154 } );
afe42d0… ragelink 3155 return object;
afe42d0… ragelink 3156 }
afe42d0… ragelink 3157
afe42d0… ragelink 3158 /*
afe42d0… ragelink 3159 * Create a callback list using the following parameters:
afe42d0… ragelink 3160 *
afe42d0… ragelink 3161 * options: an optional list of space-separated options that will change how
afe42d0… ragelink 3162 * the callback list behaves or a more traditional option object
afe42d0… ragelink 3163 *
afe42d0… ragelink 3164 * By default a callback list will act like an event callback list and can be
afe42d0… ragelink 3165 * "fired" multiple times.
afe42d0… ragelink 3166 *
afe42d0… ragelink 3167 * Possible options:
afe42d0… ragelink 3168 *
afe42d0… ragelink 3169 * once: will ensure the callback list can only be fired once (like a Deferred)
afe42d0… ragelink 3170 *
afe42d0… ragelink 3171 * memory: will keep track of previous values and will call any callback added
afe42d0… ragelink 3172 * after the list has been fired right away with the latest "memorized"
afe42d0… ragelink 3173 * values (like a Deferred)
afe42d0… ragelink 3174 *
afe42d0… ragelink 3175 * unique: will ensure a callback can only be added once (no duplicate in the list)
afe42d0… ragelink 3176 *
afe42d0… ragelink 3177 * stopOnFalse: interrupt callings when a callback returns false
afe42d0… ragelink 3178 *
afe42d0… ragelink 3179 */
afe42d0… ragelink 3180 jQuery.Callbacks = function( options ) {
afe42d0… ragelink 3181
afe42d0… ragelink 3182 // Convert options from String-formatted to Object-formatted if needed
afe42d0… ragelink 3183 // (we check in cache first)
afe42d0… ragelink 3184 options = typeof options === "string" ?
afe42d0… ragelink 3185 createOptions( options ) :
afe42d0… ragelink 3186 jQuery.extend( {}, options );
afe42d0… ragelink 3187
afe42d0… ragelink 3188 var // Flag to know if list is currently firing
afe42d0… ragelink 3189 firing,
afe42d0… ragelink 3190
afe42d0… ragelink 3191 // Last fire value for non-forgettable lists
afe42d0… ragelink 3192 memory,
afe42d0… ragelink 3193
afe42d0… ragelink 3194 // Flag to know if list was already fired
afe42d0… ragelink 3195 fired,
afe42d0… ragelink 3196
afe42d0… ragelink 3197 // Flag to prevent firing
afe42d0… ragelink 3198 locked,
afe42d0… ragelink 3199
afe42d0… ragelink 3200 // Actual callback list
afe42d0… ragelink 3201 list = [],
afe42d0… ragelink 3202
afe42d0… ragelink 3203 // Queue of execution data for repeatable lists
afe42d0… ragelink 3204 queue = [],
afe42d0… ragelink 3205
afe42d0… ragelink 3206 // Index of currently firing callback (modified by add/remove as needed)
afe42d0… ragelink 3207 firingIndex = -1,
afe42d0… ragelink 3208
afe42d0… ragelink 3209 // Fire callbacks
afe42d0… ragelink 3210 fire = function() {
afe42d0… ragelink 3211
afe42d0… ragelink 3212 // Enforce single-firing
afe42d0… ragelink 3213 locked = locked || options.once;
afe42d0… ragelink 3214
afe42d0… ragelink 3215 // Execute callbacks for all pending executions,
afe42d0… ragelink 3216 // respecting firingIndex overrides and runtime changes
afe42d0… ragelink 3217 fired = firing = true;
afe42d0… ragelink 3218 for ( ; queue.length; firingIndex = -1 ) {
afe42d0… ragelink 3219 memory = queue.shift();
afe42d0… ragelink 3220 while ( ++firingIndex < list.length ) {
afe42d0… ragelink 3221
afe42d0… ragelink 3222 // Run callback and check for early termination
afe42d0… ragelink 3223 if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
afe42d0… ragelink 3224 options.stopOnFalse ) {
afe42d0… ragelink 3225
afe42d0… ragelink 3226 // Jump to end and forget the data so .add doesn't re-fire
afe42d0… ragelink 3227 firingIndex = list.length;
afe42d0… ragelink 3228 memory = false;
afe42d0… ragelink 3229 }
afe42d0… ragelink 3230 }
afe42d0… ragelink 3231 }
afe42d0… ragelink 3232
afe42d0… ragelink 3233 // Forget the data if we're done with it
afe42d0… ragelink 3234 if ( !options.memory ) {
afe42d0… ragelink 3235 memory = false;
afe42d0… ragelink 3236 }
afe42d0… ragelink 3237
afe42d0… ragelink 3238 firing = false;
afe42d0… ragelink 3239
afe42d0… ragelink 3240 // Clean up if we're done firing for good
afe42d0… ragelink 3241 if ( locked ) {
afe42d0… ragelink 3242
afe42d0… ragelink 3243 // Keep an empty list if we have data for future add calls
afe42d0… ragelink 3244 if ( memory ) {
afe42d0… ragelink 3245 list = [];
afe42d0… ragelink 3246
afe42d0… ragelink 3247 // Otherwise, this object is spent
afe42d0… ragelink 3248 } else {
afe42d0… ragelink 3249 list = "";
afe42d0… ragelink 3250 }
afe42d0… ragelink 3251 }
afe42d0… ragelink 3252 },
afe42d0… ragelink 3253
afe42d0… ragelink 3254 // Actual Callbacks object
afe42d0… ragelink 3255 self = {
afe42d0… ragelink 3256
afe42d0… ragelink 3257 // Add a callback or a collection of callbacks to the list
afe42d0… ragelink 3258 add: function() {
afe42d0… ragelink 3259 if ( list ) {
afe42d0… ragelink 3260
afe42d0… ragelink 3261 // If we have memory from a past run, we should fire after adding
afe42d0… ragelink 3262 if ( memory && !firing ) {
afe42d0… ragelink 3263 firingIndex = list.length - 1;
afe42d0… ragelink 3264 queue.push( memory );
afe42d0… ragelink 3265 }
afe42d0… ragelink 3266
afe42d0… ragelink 3267 ( function add( args ) {
afe42d0… ragelink 3268 jQuery.each( args, function( _, arg ) {
afe42d0… ragelink 3269 if ( isFunction( arg ) ) {
afe42d0… ragelink 3270 if ( !options.unique || !self.has( arg ) ) {
afe42d0… ragelink 3271 list.push( arg );
afe42d0… ragelink 3272 }
afe42d0… ragelink 3273 } else if ( arg && arg.length && toType( arg ) !== "string" ) {
afe42d0… ragelink 3274
afe42d0… ragelink 3275 // Inspect recursively
afe42d0… ragelink 3276 add( arg );
afe42d0… ragelink 3277 }
afe42d0… ragelink 3278 } );
afe42d0… ragelink 3279 } )( arguments );
afe42d0… ragelink 3280
afe42d0… ragelink 3281 if ( memory && !firing ) {
afe42d0… ragelink 3282 fire();
afe42d0… ragelink 3283 }
afe42d0… ragelink 3284 }
afe42d0… ragelink 3285 return this;
afe42d0… ragelink 3286 },
afe42d0… ragelink 3287
afe42d0… ragelink 3288 // Remove a callback from the list
afe42d0… ragelink 3289 remove: function() {
afe42d0… ragelink 3290 jQuery.each( arguments, function( _, arg ) {
afe42d0… ragelink 3291 var index;
afe42d0… ragelink 3292 while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
afe42d0… ragelink 3293 list.splice( index, 1 );
afe42d0… ragelink 3294
afe42d0… ragelink 3295 // Handle firing indexes
afe42d0… ragelink 3296 if ( index <= firingIndex ) {
afe42d0… ragelink 3297 firingIndex--;
afe42d0… ragelink 3298 }
afe42d0… ragelink 3299 }
afe42d0… ragelink 3300 } );
afe42d0… ragelink 3301 return this;
afe42d0… ragelink 3302 },
afe42d0… ragelink 3303
afe42d0… ragelink 3304 // Check if a given callback is in the list.
afe42d0… ragelink 3305 // If no argument is given, return whether or not list has callbacks attached.
afe42d0… ragelink 3306 has: function( fn ) {
afe42d0… ragelink 3307 return fn ?
afe42d0… ragelink 3308 jQuery.inArray( fn, list ) > -1 :
afe42d0… ragelink 3309 list.length > 0;
afe42d0… ragelink 3310 },
afe42d0… ragelink 3311
afe42d0… ragelink 3312 // Remove all callbacks from the list
afe42d0… ragelink 3313 empty: function() {
afe42d0… ragelink 3314 if ( list ) {
afe42d0… ragelink 3315 list = [];
afe42d0… ragelink 3316 }
afe42d0… ragelink 3317 return this;
afe42d0… ragelink 3318 },
afe42d0… ragelink 3319
afe42d0… ragelink 3320 // Disable .fire and .add
afe42d0… ragelink 3321 // Abort any current/pending executions
afe42d0… ragelink 3322 // Clear all callbacks and values
afe42d0… ragelink 3323 disable: function() {
afe42d0… ragelink 3324 locked = queue = [];
afe42d0… ragelink 3325 list = memory = "";
afe42d0… ragelink 3326 return this;
afe42d0… ragelink 3327 },
afe42d0… ragelink 3328 disabled: function() {
afe42d0… ragelink 3329 return !list;
afe42d0… ragelink 3330 },
afe42d0… ragelink 3331
afe42d0… ragelink 3332 // Disable .fire
afe42d0… ragelink 3333 // Also disable .add unless we have memory (since it would have no effect)
afe42d0… ragelink 3334 // Abort any pending executions
afe42d0… ragelink 3335 lock: function() {
afe42d0… ragelink 3336 locked = queue = [];
afe42d0… ragelink 3337 if ( !memory && !firing ) {
afe42d0… ragelink 3338 list = memory = "";
afe42d0… ragelink 3339 }
afe42d0… ragelink 3340 return this;
afe42d0… ragelink 3341 },
afe42d0… ragelink 3342 locked: function() {
afe42d0… ragelink 3343 return !!locked;
afe42d0… ragelink 3344 },
afe42d0… ragelink 3345
afe42d0… ragelink 3346 // Call all callbacks with the given context and arguments
afe42d0… ragelink 3347 fireWith: function( context, args ) {
afe42d0… ragelink 3348 if ( !locked ) {
afe42d0… ragelink 3349 args = args || [];
afe42d0… ragelink 3350 args = [ context, args.slice ? args.slice() : args ];
afe42d0… ragelink 3351 queue.push( args );
afe42d0… ragelink 3352 if ( !firing ) {
afe42d0… ragelink 3353 fire();
afe42d0… ragelink 3354 }
afe42d0… ragelink 3355 }
afe42d0… ragelink 3356 return this;
afe42d0… ragelink 3357 },
afe42d0… ragelink 3358
afe42d0… ragelink 3359 // Call all the callbacks with the given arguments
afe42d0… ragelink 3360 fire: function() {
afe42d0… ragelink 3361 self.fireWith( this, arguments );
afe42d0… ragelink 3362 return this;
afe42d0… ragelink 3363 },
afe42d0… ragelink 3364
afe42d0… ragelink 3365 // To know if the callbacks have already been called at least once
afe42d0… ragelink 3366 fired: function() {
afe42d0… ragelink 3367 return !!fired;
afe42d0… ragelink 3368 }
afe42d0… ragelink 3369 };
afe42d0… ragelink 3370
afe42d0… ragelink 3371 return self;
afe42d0… ragelink 3372 };
afe42d0… ragelink 3373
afe42d0… ragelink 3374
afe42d0… ragelink 3375 function Identity( v ) {
afe42d0… ragelink 3376 return v;
afe42d0… ragelink 3377 }
afe42d0… ragelink 3378 function Thrower( ex ) {
afe42d0… ragelink 3379 throw ex;
afe42d0… ragelink 3380 }
afe42d0… ragelink 3381
afe42d0… ragelink 3382 function adoptValue( value, resolve, reject, noValue ) {
afe42d0… ragelink 3383 var method;
afe42d0… ragelink 3384
afe42d0… ragelink 3385 try {
afe42d0… ragelink 3386
afe42d0… ragelink 3387 // Check for promise aspect first to privilege synchronous behavior
afe42d0… ragelink 3388 if ( value && isFunction( ( method = value.promise ) ) ) {
afe42d0… ragelink 3389 method.call( value ).done( resolve ).fail( reject );
afe42d0… ragelink 3390
afe42d0… ragelink 3391 // Other thenables
afe42d0… ragelink 3392 } else if ( value && isFunction( ( method = value.then ) ) ) {
afe42d0… ragelink 3393 method.call( value, resolve, reject );
afe42d0… ragelink 3394
afe42d0… ragelink 3395 // Other non-thenables
afe42d0… ragelink 3396 } else {
afe42d0… ragelink 3397
afe42d0… ragelink 3398 // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
afe42d0… ragelink 3399 // * false: [ value ].slice( 0 ) => resolve( value )
afe42d0… ragelink 3400 // * true: [ value ].slice( 1 ) => resolve()
afe42d0… ragelink 3401 resolve.apply( undefined, [ value ].slice( noValue ) );
afe42d0… ragelink 3402 }
afe42d0… ragelink 3403
afe42d0… ragelink 3404 // For Promises/A+, convert exceptions into rejections
afe42d0… ragelink 3405 // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
afe42d0… ragelink 3406 // Deferred#then to conditionally suppress rejection.
afe42d0… ragelink 3407 } catch ( value ) {
afe42d0… ragelink 3408
afe42d0… ragelink 3409 // Support: Android 4.0 only
afe42d0… ragelink 3410 // Strict mode functions invoked without .call/.apply get global-object context
afe42d0… ragelink 3411 reject.apply( undefined, [ value ] );
afe42d0… ragelink 3412 }
afe42d0… ragelink 3413 }
afe42d0… ragelink 3414
afe42d0… ragelink 3415 jQuery.extend( {
afe42d0… ragelink 3416
afe42d0… ragelink 3417 Deferred: function( func ) {
afe42d0… ragelink 3418 var tuples = [
afe42d0… ragelink 3419
afe42d0… ragelink 3420 // action, add listener, callbacks,
afe42d0… ragelink 3421 // ... .then handlers, argument index, [final state]
afe42d0… ragelink 3422 [ "notify", "progress", jQuery.Callbacks( "memory" ),
afe42d0… ragelink 3423 jQuery.Callbacks( "memory" ), 2 ],
afe42d0… ragelink 3424 [ "resolve", "done", jQuery.Callbacks( "once memory" ),
afe42d0… ragelink 3425 jQuery.Callbacks( "once memory" ), 0, "resolved" ],
afe42d0… ragelink 3426 [ "reject", "fail", jQuery.Callbacks( "once memory" ),
afe42d0… ragelink 3427 jQuery.Callbacks( "once memory" ), 1, "rejected" ]
afe42d0… ragelink 3428 ],
afe42d0… ragelink 3429 state = "pending",
afe42d0… ragelink 3430 promise = {
afe42d0… ragelink 3431 state: function() {
afe42d0… ragelink 3432 return state;
afe42d0… ragelink 3433 },
afe42d0… ragelink 3434 always: function() {
afe42d0… ragelink 3435 deferred.done( arguments ).fail( arguments );
afe42d0… ragelink 3436 return this;
afe42d0… ragelink 3437 },
afe42d0… ragelink 3438 "catch": function( fn ) {
afe42d0… ragelink 3439 return promise.then( null, fn );
afe42d0… ragelink 3440 },
afe42d0… ragelink 3441
afe42d0… ragelink 3442 // Keep pipe for back-compat
afe42d0… ragelink 3443 pipe: function( /* fnDone, fnFail, fnProgress */ ) {
afe42d0… ragelink 3444 var fns = arguments;
afe42d0… ragelink 3445
afe42d0… ragelink 3446 return jQuery.Deferred( function( newDefer ) {
afe42d0… ragelink 3447 jQuery.each( tuples, function( _i, tuple ) {
afe42d0… ragelink 3448
afe42d0… ragelink 3449 // Map tuples (progress, done, fail) to arguments (done, fail, progress)
afe42d0… ragelink 3450 var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
afe42d0… ragelink 3451
afe42d0… ragelink 3452 // deferred.progress(function() { bind to newDefer or newDefer.notify })
afe42d0… ragelink 3453 // deferred.done(function() { bind to newDefer or newDefer.resolve })
afe42d0… ragelink 3454 // deferred.fail(function() { bind to newDefer or newDefer.reject })
afe42d0… ragelink 3455 deferred[ tuple[ 1 ] ]( function() {
afe42d0… ragelink 3456 var returned = fn && fn.apply( this, arguments );
afe42d0… ragelink 3457 if ( returned && isFunction( returned.promise ) ) {
afe42d0… ragelink 3458 returned.promise()
afe42d0… ragelink 3459 .progress( newDefer.notify )
afe42d0… ragelink 3460 .done( newDefer.resolve )
afe42d0… ragelink 3461 .fail( newDefer.reject );
afe42d0… ragelink 3462 } else {
afe42d0… ragelink 3463 newDefer[ tuple[ 0 ] + "With" ](
afe42d0… ragelink 3464 this,
afe42d0… ragelink 3465 fn ? [ returned ] : arguments
afe42d0… ragelink 3466 );
afe42d0… ragelink 3467 }
afe42d0… ragelink 3468 } );
afe42d0… ragelink 3469 } );
afe42d0… ragelink 3470 fns = null;
afe42d0… ragelink 3471 } ).promise();
afe42d0… ragelink 3472 },
afe42d0… ragelink 3473 then: function( onFulfilled, onRejected, onProgress ) {
afe42d0… ragelink 3474 var maxDepth = 0;
afe42d0… ragelink 3475 function resolve( depth, deferred, handler, special ) {
afe42d0… ragelink 3476 return function() {
afe42d0… ragelink 3477 var that = this,
afe42d0… ragelink 3478 args = arguments,
afe42d0… ragelink 3479 mightThrow = function() {
afe42d0… ragelink 3480 var returned, then;
afe42d0… ragelink 3481
afe42d0… ragelink 3482 // Support: Promises/A+ section 2.3.3.3.3
afe42d0… ragelink 3483 // https://promisesaplus.com/#point-59
afe42d0… ragelink 3484 // Ignore double-resolution attempts
afe42d0… ragelink 3485 if ( depth < maxDepth ) {
afe42d0… ragelink 3486 return;
afe42d0… ragelink 3487 }
afe42d0… ragelink 3488
afe42d0… ragelink 3489 returned = handler.apply( that, args );
afe42d0… ragelink 3490
afe42d0… ragelink 3491 // Support: Promises/A+ section 2.3.1
afe42d0… ragelink 3492 // https://promisesaplus.com/#point-48
afe42d0… ragelink 3493 if ( returned === deferred.promise() ) {
afe42d0… ragelink 3494 throw new TypeError( "Thenable self-resolution" );
afe42d0… ragelink 3495 }
afe42d0… ragelink 3496
afe42d0… ragelink 3497 // Support: Promises/A+ sections 2.3.3.1, 3.5
afe42d0… ragelink 3498 // https://promisesaplus.com/#point-54
afe42d0… ragelink 3499 // https://promisesaplus.com/#point-75
afe42d0… ragelink 3500 // Retrieve `then` only once
afe42d0… ragelink 3501 then = returned &&
afe42d0… ragelink 3502
afe42d0… ragelink 3503 // Support: Promises/A+ section 2.3.4
afe42d0… ragelink 3504 // https://promisesaplus.com/#point-64
afe42d0… ragelink 3505 // Only check objects and functions for thenability
afe42d0… ragelink 3506 ( typeof returned === "object" ||
afe42d0… ragelink 3507 typeof returned === "function" ) &&
afe42d0… ragelink 3508 returned.then;
afe42d0… ragelink 3509
afe42d0… ragelink 3510 // Handle a returned thenable
afe42d0… ragelink 3511 if ( isFunction( then ) ) {
afe42d0… ragelink 3512
afe42d0… ragelink 3513 // Special processors (notify) just wait for resolution
afe42d0… ragelink 3514 if ( special ) {
afe42d0… ragelink 3515 then.call(
afe42d0… ragelink 3516 returned,
afe42d0… ragelink 3517 resolve( maxDepth, deferred, Identity, special ),
afe42d0… ragelink 3518 resolve( maxDepth, deferred, Thrower, special )
afe42d0… ragelink 3519 );
afe42d0… ragelink 3520
afe42d0… ragelink 3521 // Normal processors (resolve) also hook into progress
afe42d0… ragelink 3522 } else {
afe42d0… ragelink 3523
afe42d0… ragelink 3524 // ...and disregard older resolution values
afe42d0… ragelink 3525 maxDepth++;
afe42d0… ragelink 3526
afe42d0… ragelink 3527 then.call(
afe42d0… ragelink 3528 returned,
afe42d0… ragelink 3529 resolve( maxDepth, deferred, Identity, special ),
afe42d0… ragelink 3530 resolve( maxDepth, deferred, Thrower, special ),
afe42d0… ragelink 3531 resolve( maxDepth, deferred, Identity,
afe42d0… ragelink 3532 deferred.notifyWith )
afe42d0… ragelink 3533 );
afe42d0… ragelink 3534 }
afe42d0… ragelink 3535
afe42d0… ragelink 3536 // Handle all other returned values
afe42d0… ragelink 3537 } else {
afe42d0… ragelink 3538
afe42d0… ragelink 3539 // Only substitute handlers pass on context
afe42d0… ragelink 3540 // and multiple values (non-spec behavior)
afe42d0… ragelink 3541 if ( handler !== Identity ) {
afe42d0… ragelink 3542 that = undefined;
afe42d0… ragelink 3543 args = [ returned ];
afe42d0… ragelink 3544 }
afe42d0… ragelink 3545
afe42d0… ragelink 3546 // Process the value(s)
afe42d0… ragelink 3547 // Default process is resolve
afe42d0… ragelink 3548 ( special || deferred.resolveWith )( that, args );
afe42d0… ragelink 3549 }
afe42d0… ragelink 3550 },
afe42d0… ragelink 3551
afe42d0… ragelink 3552 // Only normal processors (resolve) catch and reject exceptions
afe42d0… ragelink 3553 process = special ?
afe42d0… ragelink 3554 mightThrow :
afe42d0… ragelink 3555 function() {
afe42d0… ragelink 3556 try {
afe42d0… ragelink 3557 mightThrow();
afe42d0… ragelink 3558 } catch ( e ) {
afe42d0… ragelink 3559
afe42d0… ragelink 3560 if ( jQuery.Deferred.exceptionHook ) {
afe42d0… ragelink 3561 jQuery.Deferred.exceptionHook( e,
afe42d0… ragelink 3562 process.error );
afe42d0… ragelink 3563 }
afe42d0… ragelink 3564
afe42d0… ragelink 3565 // Support: Promises/A+ section 2.3.3.3.4.1
afe42d0… ragelink 3566 // https://promisesaplus.com/#point-61
afe42d0… ragelink 3567 // Ignore post-resolution exceptions
afe42d0… ragelink 3568 if ( depth + 1 >= maxDepth ) {
afe42d0… ragelink 3569
afe42d0… ragelink 3570 // Only substitute handlers pass on context
afe42d0… ragelink 3571 // and multiple values (non-spec behavior)
afe42d0… ragelink 3572 if ( handler !== Thrower ) {
afe42d0… ragelink 3573 that = undefined;
afe42d0… ragelink 3574 args = [ e ];
afe42d0… ragelink 3575 }
afe42d0… ragelink 3576
afe42d0… ragelink 3577 deferred.rejectWith( that, args );
afe42d0… ragelink 3578 }
afe42d0… ragelink 3579 }
afe42d0… ragelink 3580 };
afe42d0… ragelink 3581
afe42d0… ragelink 3582 // Support: Promises/A+ section 2.3.3.3.1
afe42d0… ragelink 3583 // https://promisesaplus.com/#point-57
afe42d0… ragelink 3584 // Re-resolve promises immediately to dodge false rejection from
afe42d0… ragelink 3585 // subsequent errors
afe42d0… ragelink 3586 if ( depth ) {
afe42d0… ragelink 3587 process();
afe42d0… ragelink 3588 } else {
afe42d0… ragelink 3589
afe42d0… ragelink 3590 // Call an optional hook to record the error, in case of exception
afe42d0… ragelink 3591 // since it's otherwise lost when execution goes async
afe42d0… ragelink 3592 if ( jQuery.Deferred.getErrorHook ) {
afe42d0… ragelink 3593 process.error = jQuery.Deferred.getErrorHook();
afe42d0… ragelink 3594
afe42d0… ragelink 3595 // The deprecated alias of the above. While the name suggests
afe42d0… ragelink 3596 // returning the stack, not an error instance, jQuery just passes
afe42d0… ragelink 3597 // it directly to `console.warn` so both will work; an instance
afe42d0… ragelink 3598 // just better cooperates with source maps.
afe42d0… ragelink 3599 } else if ( jQuery.Deferred.getStackHook ) {
afe42d0… ragelink 3600 process.error = jQuery.Deferred.getStackHook();
afe42d0… ragelink 3601 }
afe42d0… ragelink 3602 window.setTimeout( process );
afe42d0… ragelink 3603 }
afe42d0… ragelink 3604 };
afe42d0… ragelink 3605 }
afe42d0… ragelink 3606
afe42d0… ragelink 3607 return jQuery.Deferred( function( newDefer ) {
afe42d0… ragelink 3608
afe42d0… ragelink 3609 // progress_handlers.add( ... )
afe42d0… ragelink 3610 tuples[ 0 ][ 3 ].add(
afe42d0… ragelink 3611 resolve(
afe42d0… ragelink 3612 0,
afe42d0… ragelink 3613 newDefer,
afe42d0… ragelink 3614 isFunction( onProgress ) ?
afe42d0… ragelink 3615 onProgress :
afe42d0… ragelink 3616 Identity,
afe42d0… ragelink 3617 newDefer.notifyWith
afe42d0… ragelink 3618 )
afe42d0… ragelink 3619 );
afe42d0… ragelink 3620
afe42d0… ragelink 3621 // fulfilled_handlers.add( ... )
afe42d0… ragelink 3622 tuples[ 1 ][ 3 ].add(
afe42d0… ragelink 3623 resolve(
afe42d0… ragelink 3624 0,
afe42d0… ragelink 3625 newDefer,
afe42d0… ragelink 3626 isFunction( onFulfilled ) ?
afe42d0… ragelink 3627 onFulfilled :
afe42d0… ragelink 3628 Identity
afe42d0… ragelink 3629 )
afe42d0… ragelink 3630 );
afe42d0… ragelink 3631
afe42d0… ragelink 3632 // rejected_handlers.add( ... )
afe42d0… ragelink 3633 tuples[ 2 ][ 3 ].add(
afe42d0… ragelink 3634 resolve(
afe42d0… ragelink 3635 0,
afe42d0… ragelink 3636 newDefer,
afe42d0… ragelink 3637 isFunction( onRejected ) ?
afe42d0… ragelink 3638 onRejected :
afe42d0… ragelink 3639 Thrower
afe42d0… ragelink 3640 )
afe42d0… ragelink 3641 );
afe42d0… ragelink 3642 } ).promise();
afe42d0… ragelink 3643 },
afe42d0… ragelink 3644
afe42d0… ragelink 3645 // Get a promise for this deferred
afe42d0… ragelink 3646 // If obj is provided, the promise aspect is added to the object
afe42d0… ragelink 3647 promise: function( obj ) {
afe42d0… ragelink 3648 return obj != null ? jQuery.extend( obj, promise ) : promise;
afe42d0… ragelink 3649 }
afe42d0… ragelink 3650 },
afe42d0… ragelink 3651 deferred = {};
afe42d0… ragelink 3652
afe42d0… ragelink 3653 // Add list-specific methods
afe42d0… ragelink 3654 jQuery.each( tuples, function( i, tuple ) {
afe42d0… ragelink 3655 var list = tuple[ 2 ],
afe42d0… ragelink 3656 stateString = tuple[ 5 ];
afe42d0… ragelink 3657
afe42d0… ragelink 3658 // promise.progress = list.add
afe42d0… ragelink 3659 // promise.done = list.add
afe42d0… ragelink 3660 // promise.fail = list.add
afe42d0… ragelink 3661 promise[ tuple[ 1 ] ] = list.add;
afe42d0… ragelink 3662
afe42d0… ragelink 3663 // Handle state
afe42d0… ragelink 3664 if ( stateString ) {
afe42d0… ragelink 3665 list.add(
afe42d0… ragelink 3666 function() {
afe42d0… ragelink 3667
afe42d0… ragelink 3668 // state = "resolved" (i.e., fulfilled)
afe42d0… ragelink 3669 // state = "rejected"
afe42d0… ragelink 3670 state = stateString;
afe42d0… ragelink 3671 },
afe42d0… ragelink 3672
afe42d0… ragelink 3673 // rejected_callbacks.disable
afe42d0… ragelink 3674 // fulfilled_callbacks.disable
afe42d0… ragelink 3675 tuples[ 3 - i ][ 2 ].disable,
afe42d0… ragelink 3676
afe42d0… ragelink 3677 // rejected_handlers.disable
afe42d0… ragelink 3678 // fulfilled_handlers.disable
afe42d0… ragelink 3679 tuples[ 3 - i ][ 3 ].disable,
afe42d0… ragelink 3680
afe42d0… ragelink 3681 // progress_callbacks.lock
afe42d0… ragelink 3682 tuples[ 0 ][ 2 ].lock,
afe42d0… ragelink 3683
afe42d0… ragelink 3684 // progress_handlers.lock
afe42d0… ragelink 3685 tuples[ 0 ][ 3 ].lock
afe42d0… ragelink 3686 );
afe42d0… ragelink 3687 }
afe42d0… ragelink 3688
afe42d0… ragelink 3689 // progress_handlers.fire
afe42d0… ragelink 3690 // fulfilled_handlers.fire
afe42d0… ragelink 3691 // rejected_handlers.fire
afe42d0… ragelink 3692 list.add( tuple[ 3 ].fire );
afe42d0… ragelink 3693
afe42d0… ragelink 3694 // deferred.notify = function() { deferred.notifyWith(...) }
afe42d0… ragelink 3695 // deferred.resolve = function() { deferred.resolveWith(...) }
afe42d0… ragelink 3696 // deferred.reject = function() { deferred.rejectWith(...) }
afe42d0… ragelink 3697 deferred[ tuple[ 0 ] ] = function() {
afe42d0… ragelink 3698 deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments );
afe42d0… ragelink 3699 return this;
afe42d0… ragelink 3700 };
afe42d0… ragelink 3701
afe42d0… ragelink 3702 // deferred.notifyWith = list.fireWith
afe42d0… ragelink 3703 // deferred.resolveWith = list.fireWith
afe42d0… ragelink 3704 // deferred.rejectWith = list.fireWith
afe42d0… ragelink 3705 deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
afe42d0… ragelink 3706 } );
afe42d0… ragelink 3707
afe42d0… ragelink 3708 // Make the deferred a promise
afe42d0… ragelink 3709 promise.promise( deferred );
afe42d0… ragelink 3710
afe42d0… ragelink 3711 // Call given func if any
afe42d0… ragelink 3712 if ( func ) {
afe42d0… ragelink 3713 func.call( deferred, deferred );
afe42d0… ragelink 3714 }
afe42d0… ragelink 3715
afe42d0… ragelink 3716 // All done!
afe42d0… ragelink 3717 return deferred;
afe42d0… ragelink 3718 },
afe42d0… ragelink 3719
afe42d0… ragelink 3720 // Deferred helper
afe42d0… ragelink 3721 when: function( singleValue ) {
afe42d0… ragelink 3722 var
afe42d0… ragelink 3723
afe42d0… ragelink 3724 // count of uncompleted subordinates
afe42d0… ragelink 3725 remaining = arguments.length,
afe42d0… ragelink 3726
afe42d0… ragelink 3727 // count of unprocessed arguments
afe42d0… ragelink 3728 i = remaining,
afe42d0… ragelink 3729
afe42d0… ragelink 3730 // subordinate fulfillment data
afe42d0… ragelink 3731 resolveContexts = Array( i ),
afe42d0… ragelink 3732 resolveValues = slice.call( arguments ),
afe42d0… ragelink 3733
afe42d0… ragelink 3734 // the primary Deferred
afe42d0… ragelink 3735 primary = jQuery.Deferred(),
afe42d0… ragelink 3736
afe42d0… ragelink 3737 // subordinate callback factory
afe42d0… ragelink 3738 updateFunc = function( i ) {
afe42d0… ragelink 3739 return function( value ) {
afe42d0… ragelink 3740 resolveContexts[ i ] = this;
afe42d0… ragelink 3741 resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
afe42d0… ragelink 3742 if ( !( --remaining ) ) {
afe42d0… ragelink 3743 primary.resolveWith( resolveContexts, resolveValues );
afe42d0… ragelink 3744 }
afe42d0… ragelink 3745 };
afe42d0… ragelink 3746 };
afe42d0… ragelink 3747
afe42d0… ragelink 3748 // Single- and empty arguments are adopted like Promise.resolve
afe42d0… ragelink 3749 if ( remaining <= 1 ) {
afe42d0… ragelink 3750 adoptValue( singleValue, primary.done( updateFunc( i ) ).resolve, primary.reject,
afe42d0… ragelink 3751 !remaining );
afe42d0… ragelink 3752
afe42d0… ragelink 3753 // Use .then() to unwrap secondary thenables (cf. gh-3000)
afe42d0… ragelink 3754 if ( primary.state() === "pending" ||
afe42d0… ragelink 3755 isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
afe42d0… ragelink 3756
afe42d0… ragelink 3757 return primary.then();
afe42d0… ragelink 3758 }
afe42d0… ragelink 3759 }
afe42d0… ragelink 3760
afe42d0… ragelink 3761 // Multiple arguments are aggregated like Promise.all array elements
afe42d0… ragelink 3762 while ( i-- ) {
afe42d0… ragelink 3763 adoptValue( resolveValues[ i ], updateFunc( i ), primary.reject );
afe42d0… ragelink 3764 }
afe42d0… ragelink 3765
afe42d0… ragelink 3766 return primary.promise();
afe42d0… ragelink 3767 }
afe42d0… ragelink 3768 } );
afe42d0… ragelink 3769
afe42d0… ragelink 3770
afe42d0… ragelink 3771 // These usually indicate a programmer mistake during development,
afe42d0… ragelink 3772 // warn about them ASAP rather than swallowing them by default.
afe42d0… ragelink 3773 var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
afe42d0… ragelink 3774
afe42d0… ragelink 3775 // If `jQuery.Deferred.getErrorHook` is defined, `asyncError` is an error
afe42d0… ragelink 3776 // captured before the async barrier to get the original error cause
afe42d0… ragelink 3777 // which may otherwise be hidden.
afe42d0… ragelink 3778 jQuery.Deferred.exceptionHook = function( error, asyncError ) {
afe42d0… ragelink 3779
afe42d0… ragelink 3780 // Support: IE 8 - 9 only
afe42d0… ragelink 3781 // Console exists when dev tools are open, which can happen at any time
afe42d0… ragelink 3782 if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {
afe42d0… ragelink 3783 window.console.warn( "jQuery.Deferred exception: " + error.message,
afe42d0… ragelink 3784 error.stack, asyncError );
afe42d0… ragelink 3785 }
afe42d0… ragelink 3786 };
afe42d0… ragelink 3787
afe42d0… ragelink 3788
afe42d0… ragelink 3789
afe42d0… ragelink 3790
afe42d0… ragelink 3791 jQuery.readyException = function( error ) {
afe42d0… ragelink 3792 window.setTimeout( function() {
afe42d0… ragelink 3793 throw error;
afe42d0… ragelink 3794 } );
afe42d0… ragelink 3795 };
afe42d0… ragelink 3796
afe42d0… ragelink 3797
afe42d0… ragelink 3798
afe42d0… ragelink 3799
afe42d0… ragelink 3800 // The deferred used on DOM ready
afe42d0… ragelink 3801 var readyList = jQuery.Deferred();
afe42d0… ragelink 3802
afe42d0… ragelink 3803 jQuery.fn.ready = function( fn ) {
afe42d0… ragelink 3804
afe42d0… ragelink 3805 readyList
afe42d0… ragelink 3806 .then( fn )
afe42d0… ragelink 3807
afe42d0… ragelink 3808 // Wrap jQuery.readyException in a function so that the lookup
afe42d0… ragelink 3809 // happens at the time of error handling instead of callback
afe42d0… ragelink 3810 // registration.
afe42d0… ragelink 3811 .catch( function( error ) {
afe42d0… ragelink 3812 jQuery.readyException( error );
afe42d0… ragelink 3813 } );
afe42d0… ragelink 3814
afe42d0… ragelink 3815 return this;
afe42d0… ragelink 3816 };
afe42d0… ragelink 3817
afe42d0… ragelink 3818 jQuery.extend( {
afe42d0… ragelink 3819
afe42d0… ragelink 3820 // Is the DOM ready to be used? Set to true once it occurs.
afe42d0… ragelink 3821 isReady: false,
afe42d0… ragelink 3822
afe42d0… ragelink 3823 // A counter to track how many items to wait for before
afe42d0… ragelink 3824 // the ready event fires. See trac-6781
afe42d0… ragelink 3825 readyWait: 1,
afe42d0… ragelink 3826
afe42d0… ragelink 3827 // Handle when the DOM is ready
afe42d0… ragelink 3828 ready: function( wait ) {
afe42d0… ragelink 3829
afe42d0… ragelink 3830 // Abort if there are pending holds or we're already ready
afe42d0… ragelink 3831 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
afe42d0… ragelink 3832 return;
afe42d0… ragelink 3833 }
afe42d0… ragelink 3834
afe42d0… ragelink 3835 // Remember that the DOM is ready
afe42d0… ragelink 3836 jQuery.isReady = true;
afe42d0… ragelink 3837
afe42d0… ragelink 3838 // If a normal DOM Ready event fired, decrement, and wait if need be
afe42d0… ragelink 3839 if ( wait !== true && --jQuery.readyWait > 0 ) {
afe42d0… ragelink 3840 return;
afe42d0… ragelink 3841 }
afe42d0… ragelink 3842
afe42d0… ragelink 3843 // If there are functions bound, to execute
afe42d0… ragelink 3844 readyList.resolveWith( document, [ jQuery ] );
afe42d0… ragelink 3845 }
afe42d0… ragelink 3846 } );
afe42d0… ragelink 3847
afe42d0… ragelink 3848 jQuery.ready.then = readyList.then;
afe42d0… ragelink 3849
afe42d0… ragelink 3850 // The ready event handler and self cleanup method
afe42d0… ragelink 3851 function completed() {
afe42d0… ragelink 3852 document.removeEventListener( "DOMContentLoaded", completed );
afe42d0… ragelink 3853 window.removeEventListener( "load", completed );
afe42d0… ragelink 3854 jQuery.ready();
afe42d0… ragelink 3855 }
afe42d0… ragelink 3856
afe42d0… ragelink 3857 // Catch cases where $(document).ready() is called
afe42d0… ragelink 3858 // after the browser event has already occurred.
afe42d0… ragelink 3859 // Support: IE <=9 - 10 only
afe42d0… ragelink 3860 // Older IE sometimes signals "interactive" too soon
afe42d0… ragelink 3861 if ( document.readyState === "complete" ||
afe42d0… ragelink 3862 ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
afe42d0… ragelink 3863
afe42d0… ragelink 3864 // Handle it asynchronously to allow scripts the opportunity to delay ready
afe42d0… ragelink 3865 window.setTimeout( jQuery.ready );
afe42d0… ragelink 3866
afe42d0… ragelink 3867 } else {
afe42d0… ragelink 3868
afe42d0… ragelink 3869 // Use the handy event callback
afe42d0… ragelink 3870 document.addEventListener( "DOMContentLoaded", completed );
afe42d0… ragelink 3871
afe42d0… ragelink 3872 // A fallback to window.onload, that will always work
afe42d0… ragelink 3873 window.addEventListener( "load", completed );
afe42d0… ragelink 3874 }
afe42d0… ragelink 3875
afe42d0… ragelink 3876
afe42d0… ragelink 3877
afe42d0… ragelink 3878
afe42d0… ragelink 3879 // Multifunctional method to get and set values of a collection
afe42d0… ragelink 3880 // The value/s can optionally be executed if it's a function
afe42d0… ragelink 3881 var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
afe42d0… ragelink 3882 var i = 0,
afe42d0… ragelink 3883 len = elems.length,
afe42d0… ragelink 3884 bulk = key == null;
afe42d0… ragelink 3885
afe42d0… ragelink 3886 // Sets many values
afe42d0… ragelink 3887 if ( toType( key ) === "object" ) {
afe42d0… ragelink 3888 chainable = true;
afe42d0… ragelink 3889 for ( i in key ) {
afe42d0… ragelink 3890 access( elems, fn, i, key[ i ], true, emptyGet, raw );
afe42d0… ragelink 3891 }
afe42d0… ragelink 3892
afe42d0… ragelink 3893 // Sets one value
afe42d0… ragelink 3894 } else if ( value !== undefined ) {
afe42d0… ragelink 3895 chainable = true;
afe42d0… ragelink 3896
afe42d0… ragelink 3897 if ( !isFunction( value ) ) {
afe42d0… ragelink 3898 raw = true;
afe42d0… ragelink 3899 }
afe42d0… ragelink 3900
afe42d0… ragelink 3901 if ( bulk ) {
afe42d0… ragelink 3902
afe42d0… ragelink 3903 // Bulk operations run against the entire set
afe42d0… ragelink 3904 if ( raw ) {
afe42d0… ragelink 3905 fn.call( elems, value );
afe42d0… ragelink 3906 fn = null;
afe42d0… ragelink 3907
afe42d0… ragelink 3908 // ...except when executing function values
afe42d0… ragelink 3909 } else {
afe42d0… ragelink 3910 bulk = fn;
afe42d0… ragelink 3911 fn = function( elem, _key, value ) {
afe42d0… ragelink 3912 return bulk.call( jQuery( elem ), value );
afe42d0… ragelink 3913 };
afe42d0… ragelink 3914 }
afe42d0… ragelink 3915 }
afe42d0… ragelink 3916
afe42d0… ragelink 3917 if ( fn ) {
afe42d0… ragelink 3918 for ( ; i < len; i++ ) {
afe42d0… ragelink 3919 fn(
afe42d0… ragelink 3920 elems[ i ], key, raw ?
afe42d0… ragelink 3921 value :
afe42d0… ragelink 3922 value.call( elems[ i ], i, fn( elems[ i ], key ) )
afe42d0… ragelink 3923 );
afe42d0… ragelink 3924 }
afe42d0… ragelink 3925 }
afe42d0… ragelink 3926 }
afe42d0… ragelink 3927
afe42d0… ragelink 3928 if ( chainable ) {
afe42d0… ragelink 3929 return elems;
afe42d0… ragelink 3930 }
afe42d0… ragelink 3931
afe42d0… ragelink 3932 // Gets
afe42d0… ragelink 3933 if ( bulk ) {
afe42d0… ragelink 3934 return fn.call( elems );
afe42d0… ragelink 3935 }
afe42d0… ragelink 3936
afe42d0… ragelink 3937 return len ? fn( elems[ 0 ], key ) : emptyGet;
afe42d0… ragelink 3938 };
afe42d0… ragelink 3939
afe42d0… ragelink 3940
afe42d0… ragelink 3941 // Matches dashed string for camelizing
afe42d0… ragelink 3942 var rmsPrefix = /^-ms-/,
afe42d0… ragelink 3943 rdashAlpha = /-([a-z])/g;
afe42d0… ragelink 3944
afe42d0… ragelink 3945 // Used by camelCase as callback to replace()
afe42d0… ragelink 3946 function fcamelCase( _all, letter ) {
afe42d0… ragelink 3947 return letter.toUpperCase();
afe42d0… ragelink 3948 }
afe42d0… ragelink 3949
afe42d0… ragelink 3950 // Convert dashed to camelCase; used by the css and data modules
afe42d0… ragelink 3951 // Support: IE <=9 - 11, Edge 12 - 15
afe42d0… ragelink 3952 // Microsoft forgot to hump their vendor prefix (trac-9572)
afe42d0… ragelink 3953 function camelCase( string ) {
afe42d0… ragelink 3954 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
afe42d0… ragelink 3955 }
afe42d0… ragelink 3956 var acceptData = function( owner ) {
afe42d0… ragelink 3957
afe42d0… ragelink 3958 // Accepts only:
afe42d0… ragelink 3959 // - Node
afe42d0… ragelink 3960 // - Node.ELEMENT_NODE
afe42d0… ragelink 3961 // - Node.DOCUMENT_NODE
afe42d0… ragelink 3962 // - Object
afe42d0… ragelink 3963 // - Any
afe42d0… ragelink 3964 return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
afe42d0… ragelink 3965 };
afe42d0… ragelink 3966
afe42d0… ragelink 3967
afe42d0… ragelink 3968
afe42d0… ragelink 3969
afe42d0… ragelink 3970 function Data() {
afe42d0… ragelink 3971 this.expando = jQuery.expando + Data.uid++;
afe42d0… ragelink 3972 }
afe42d0… ragelink 3973
afe42d0… ragelink 3974 Data.uid = 1;
afe42d0… ragelink 3975
afe42d0… ragelink 3976 Data.prototype = {
afe42d0… ragelink 3977
afe42d0… ragelink 3978 cache: function( owner ) {
afe42d0… ragelink 3979
afe42d0… ragelink 3980 // Check if the owner object already has a cache
afe42d0… ragelink 3981 var value = owner[ this.expando ];
afe42d0… ragelink 3982
afe42d0… ragelink 3983 // If not, create one
afe42d0… ragelink 3984 if ( !value ) {
afe42d0… ragelink 3985 value = {};
afe42d0… ragelink 3986
afe42d0… ragelink 3987 // We can accept data for non-element nodes in modern browsers,
afe42d0… ragelink 3988 // but we should not, see trac-8335.
afe42d0… ragelink 3989 // Always return an empty object.
afe42d0… ragelink 3990 if ( acceptData( owner ) ) {
afe42d0… ragelink 3991
afe42d0… ragelink 3992 // If it is a node unlikely to be stringify-ed or looped over
afe42d0… ragelink 3993 // use plain assignment
afe42d0… ragelink 3994 if ( owner.nodeType ) {
afe42d0… ragelink 3995 owner[ this.expando ] = value;
afe42d0… ragelink 3996
afe42d0… ragelink 3997 // Otherwise secure it in a non-enumerable property
afe42d0… ragelink 3998 // configurable must be true to allow the property to be
afe42d0… ragelink 3999 // deleted when data is removed
afe42d0… ragelink 4000 } else {
afe42d0… ragelink 4001 Object.defineProperty( owner, this.expando, {
afe42d0… ragelink 4002 value: value,
afe42d0… ragelink 4003 configurable: true
afe42d0… ragelink 4004 } );
afe42d0… ragelink 4005 }
afe42d0… ragelink 4006 }
afe42d0… ragelink 4007 }
afe42d0… ragelink 4008
afe42d0… ragelink 4009 return value;
afe42d0… ragelink 4010 },
afe42d0… ragelink 4011 set: function( owner, data, value ) {
afe42d0… ragelink 4012 var prop,
afe42d0… ragelink 4013 cache = this.cache( owner );
afe42d0… ragelink 4014
afe42d0… ragelink 4015 // Handle: [ owner, key, value ] args
afe42d0… ragelink 4016 // Always use camelCase key (gh-2257)
afe42d0… ragelink 4017 if ( typeof data === "string" ) {
afe42d0… ragelink 4018 cache[ camelCase( data ) ] = value;
afe42d0… ragelink 4019
afe42d0… ragelink 4020 // Handle: [ owner, { properties } ] args
afe42d0… ragelink 4021 } else {
afe42d0… ragelink 4022
afe42d0… ragelink 4023 // Copy the properties one-by-one to the cache object
afe42d0… ragelink 4024 for ( prop in data ) {
afe42d0… ragelink 4025 cache[ camelCase( prop ) ] = data[ prop ];
afe42d0… ragelink 4026 }
afe42d0… ragelink 4027 }
afe42d0… ragelink 4028 return cache;
afe42d0… ragelink 4029 },
afe42d0… ragelink 4030 get: function( owner, key ) {
afe42d0… ragelink 4031 return key === undefined ?
afe42d0… ragelink 4032 this.cache( owner ) :
afe42d0… ragelink 4033
afe42d0… ragelink 4034 // Always use camelCase key (gh-2257)
afe42d0… ragelink 4035 owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ];
afe42d0… ragelink 4036 },
afe42d0… ragelink 4037 access: function( owner, key, value ) {
afe42d0… ragelink 4038
afe42d0… ragelink 4039 // In cases where either:
afe42d0… ragelink 4040 //
afe42d0… ragelink 4041 // 1. No key was specified
afe42d0… ragelink 4042 // 2. A string key was specified, but no value provided
afe42d0… ragelink 4043 //
afe42d0… ragelink 4044 // Take the "read" path and allow the get method to determine
afe42d0… ragelink 4045 // which value to return, respectively either:
afe42d0… ragelink 4046 //
afe42d0… ragelink 4047 // 1. The entire cache object
afe42d0… ragelink 4048 // 2. The data stored at the key
afe42d0… ragelink 4049 //
afe42d0… ragelink 4050 if ( key === undefined ||
afe42d0… ragelink 4051 ( ( key && typeof key === "string" ) && value === undefined ) ) {
afe42d0… ragelink 4052
afe42d0… ragelink 4053 return this.get( owner, key );
afe42d0… ragelink 4054 }
afe42d0… ragelink 4055
afe42d0… ragelink 4056 // When the key is not a string, or both a key and value
afe42d0… ragelink 4057 // are specified, set or extend (existing objects) with either:
afe42d0… ragelink 4058 //
afe42d0… ragelink 4059 // 1. An object of properties
afe42d0… ragelink 4060 // 2. A key and value
afe42d0… ragelink 4061 //
afe42d0… ragelink 4062 this.set( owner, key, value );
afe42d0… ragelink 4063
afe42d0… ragelink 4064 // Since the "set" path can have two possible entry points
afe42d0… ragelink 4065 // return the expected data based on which path was taken[*]
afe42d0… ragelink 4066 return value !== undefined ? value : key;
afe42d0… ragelink 4067 },
afe42d0… ragelink 4068 remove: function( owner, key ) {
afe42d0… ragelink 4069 var i,
afe42d0… ragelink 4070 cache = owner[ this.expando ];
afe42d0… ragelink 4071
afe42d0… ragelink 4072 if ( cache === undefined ) {
afe42d0… ragelink 4073 return;
afe42d0… ragelink 4074 }
afe42d0… ragelink 4075
afe42d0… ragelink 4076 if ( key !== undefined ) {
afe42d0… ragelink 4077
afe42d0… ragelink 4078 // Support array or space separated string of keys
afe42d0… ragelink 4079 if ( Array.isArray( key ) ) {
afe42d0… ragelink 4080
afe42d0… ragelink 4081 // If key is an array of keys...
afe42d0… ragelink 4082 // We always set camelCase keys, so remove that.
afe42d0… ragelink 4083 key = key.map( camelCase );
afe42d0… ragelink 4084 } else {
afe42d0… ragelink 4085 key = camelCase( key );
afe42d0… ragelink 4086
afe42d0… ragelink 4087 // If a key with the spaces exists, use it.
afe42d0… ragelink 4088 // Otherwise, create an array by matching non-whitespace
afe42d0… ragelink 4089 key = key in cache ?
afe42d0… ragelink 4090 [ key ] :
afe42d0… ragelink 4091 ( key.match( rnothtmlwhite ) || [] );
afe42d0… ragelink 4092 }
afe42d0… ragelink 4093
afe42d0… ragelink 4094 i = key.length;
afe42d0… ragelink 4095
afe42d0… ragelink 4096 while ( i-- ) {
afe42d0… ragelink 4097 delete cache[ key[ i ] ];
afe42d0… ragelink 4098 }
afe42d0… ragelink 4099 }
afe42d0… ragelink 4100
afe42d0… ragelink 4101 // Remove the expando if there's no more data
afe42d0… ragelink 4102 if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
afe42d0… ragelink 4103
afe42d0… ragelink 4104 // Support: Chrome <=35 - 45
afe42d0… ragelink 4105 // Webkit & Blink performance suffers when deleting properties
afe42d0… ragelink 4106 // from DOM nodes, so set to undefined instead
afe42d0… ragelink 4107 // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
afe42d0… ragelink 4108 if ( owner.nodeType ) {
afe42d0… ragelink 4109 owner[ this.expando ] = undefined;
afe42d0… ragelink 4110 } else {
afe42d0… ragelink 4111 delete owner[ this.expando ];
afe42d0… ragelink 4112 }
afe42d0… ragelink 4113 }
afe42d0… ragelink 4114 },
afe42d0… ragelink 4115 hasData: function( owner ) {
afe42d0… ragelink 4116 var cache = owner[ this.expando ];
afe42d0… ragelink 4117 return cache !== undefined && !jQuery.isEmptyObject( cache );
afe42d0… ragelink 4118 }
afe42d0… ragelink 4119 };
afe42d0… ragelink 4120 var dataPriv = new Data();
afe42d0… ragelink 4121
afe42d0… ragelink 4122 var dataUser = new Data();
afe42d0… ragelink 4123
afe42d0… ragelink 4124
afe42d0… ragelink 4125
afe42d0… ragelink 4126 // Implementation Summary
afe42d0… ragelink 4127 //
afe42d0… ragelink 4128 // 1. Enforce API surface and semantic compatibility with 1.9.x branch
afe42d0… ragelink 4129 // 2. Improve the module's maintainability by reducing the storage
afe42d0… ragelink 4130 // paths to a single mechanism.
afe42d0… ragelink 4131 // 3. Use the same single mechanism to support "private" and "user" data.
afe42d0… ragelink 4132 // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
afe42d0… ragelink 4133 // 5. Avoid exposing implementation details on user objects (eg. expando properties)
afe42d0… ragelink 4134 // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
afe42d0… ragelink 4135
afe42d0… ragelink 4136 var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
afe42d0… ragelink 4137 rmultiDash = /[A-Z]/g;
afe42d0… ragelink 4138
afe42d0… ragelink 4139 function getData( data ) {
afe42d0… ragelink 4140 if ( data === "true" ) {
afe42d0… ragelink 4141 return true;
afe42d0… ragelink 4142 }
afe42d0… ragelink 4143
afe42d0… ragelink 4144 if ( data === "false" ) {
afe42d0… ragelink 4145 return false;
afe42d0… ragelink 4146 }
afe42d0… ragelink 4147
afe42d0… ragelink 4148 if ( data === "null" ) {
afe42d0… ragelink 4149 return null;
afe42d0… ragelink 4150 }
afe42d0… ragelink 4151
afe42d0… ragelink 4152 // Only convert to a number if it doesn't change the string
afe42d0… ragelink 4153 if ( data === +data + "" ) {
afe42d0… ragelink 4154 return +data;
afe42d0… ragelink 4155 }
afe42d0… ragelink 4156
afe42d0… ragelink 4157 if ( rbrace.test( data ) ) {
afe42d0… ragelink 4158 return JSON.parse( data );
afe42d0… ragelink 4159 }
afe42d0… ragelink 4160
afe42d0… ragelink 4161 return data;
afe42d0… ragelink 4162 }
afe42d0… ragelink 4163
afe42d0… ragelink 4164 function dataAttr( elem, key, data ) {
afe42d0… ragelink 4165 var name;
afe42d0… ragelink 4166
afe42d0… ragelink 4167 // If nothing was found internally, try to fetch any
afe42d0… ragelink 4168 // data from the HTML5 data-* attribute
afe42d0… ragelink 4169 if ( data === undefined && elem.nodeType === 1 ) {
afe42d0… ragelink 4170 name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
afe42d0… ragelink 4171 data = elem.getAttribute( name );
afe42d0… ragelink 4172
afe42d0… ragelink 4173 if ( typeof data === "string" ) {
afe42d0… ragelink 4174 try {
afe42d0… ragelink 4175 data = getData( data );
afe42d0… ragelink 4176 } catch ( e ) {}
afe42d0… ragelink 4177
afe42d0… ragelink 4178 // Make sure we set the data so it isn't changed later
afe42d0… ragelink 4179 dataUser.set( elem, key, data );
afe42d0… ragelink 4180 } else {
afe42d0… ragelink 4181 data = undefined;
afe42d0… ragelink 4182 }
afe42d0… ragelink 4183 }
afe42d0… ragelink 4184 return data;
afe42d0… ragelink 4185 }
afe42d0… ragelink 4186
afe42d0… ragelink 4187 jQuery.extend( {
afe42d0… ragelink 4188 hasData: function( elem ) {
afe42d0… ragelink 4189 return dataUser.hasData( elem ) || dataPriv.hasData( elem );
afe42d0… ragelink 4190 },
afe42d0… ragelink 4191
afe42d0… ragelink 4192 data: function( elem, name, data ) {
afe42d0… ragelink 4193 return dataUser.access( elem, name, data );
afe42d0… ragelink 4194 },
afe42d0… ragelink 4195
afe42d0… ragelink 4196 removeData: function( elem, name ) {
afe42d0… ragelink 4197 dataUser.remove( elem, name );
afe42d0… ragelink 4198 },
afe42d0… ragelink 4199
afe42d0… ragelink 4200 // TODO: Now that all calls to _data and _removeData have been replaced
afe42d0… ragelink 4201 // with direct calls to dataPriv methods, these can be deprecated.
afe42d0… ragelink 4202 _data: function( elem, name, data ) {
afe42d0… ragelink 4203 return dataPriv.access( elem, name, data );
afe42d0… ragelink 4204 },
afe42d0… ragelink 4205
afe42d0… ragelink 4206 _removeData: function( elem, name ) {
afe42d0… ragelink 4207 dataPriv.remove( elem, name );
afe42d0… ragelink 4208 }
afe42d0… ragelink 4209 } );
afe42d0… ragelink 4210
afe42d0… ragelink 4211 jQuery.fn.extend( {
afe42d0… ragelink 4212 data: function( key, value ) {
afe42d0… ragelink 4213 var i, name, data,
afe42d0… ragelink 4214 elem = this[ 0 ],
afe42d0… ragelink 4215 attrs = elem && elem.attributes;
afe42d0… ragelink 4216
afe42d0… ragelink 4217 // Gets all values
afe42d0… ragelink 4218 if ( key === undefined ) {
afe42d0… ragelink 4219 if ( this.length ) {
afe42d0… ragelink 4220 data = dataUser.get( elem );
afe42d0… ragelink 4221
afe42d0… ragelink 4222 if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
afe42d0… ragelink 4223 i = attrs.length;
afe42d0… ragelink 4224 while ( i-- ) {
afe42d0… ragelink 4225
afe42d0… ragelink 4226 // Support: IE 11 only
afe42d0… ragelink 4227 // The attrs elements can be null (trac-14894)
afe42d0… ragelink 4228 if ( attrs[ i ] ) {
afe42d0… ragelink 4229 name = attrs[ i ].name;
afe42d0… ragelink 4230 if ( name.indexOf( "data-" ) === 0 ) {
afe42d0… ragelink 4231 name = camelCase( name.slice( 5 ) );
afe42d0… ragelink 4232 dataAttr( elem, name, data[ name ] );
afe42d0… ragelink 4233 }
afe42d0… ragelink 4234 }
afe42d0… ragelink 4235 }
afe42d0… ragelink 4236 dataPriv.set( elem, "hasDataAttrs", true );
afe42d0… ragelink 4237 }
afe42d0… ragelink 4238 }
afe42d0… ragelink 4239
afe42d0… ragelink 4240 return data;
afe42d0… ragelink 4241 }
afe42d0… ragelink 4242
afe42d0… ragelink 4243 // Sets multiple values
afe42d0… ragelink 4244 if ( typeof key === "object" ) {
afe42d0… ragelink 4245 return this.each( function() {
afe42d0… ragelink 4246 dataUser.set( this, key );
afe42d0… ragelink 4247 } );
afe42d0… ragelink 4248 }
afe42d0… ragelink 4249
afe42d0… ragelink 4250 return access( this, function( value ) {
afe42d0… ragelink 4251 var data;
afe42d0… ragelink 4252
afe42d0… ragelink 4253 // The calling jQuery object (element matches) is not empty
afe42d0… ragelink 4254 // (and therefore has an element appears at this[ 0 ]) and the
afe42d0… ragelink 4255 // `value` parameter was not undefined. An empty jQuery object
afe42d0… ragelink 4256 // will result in `undefined` for elem = this[ 0 ] which will
afe42d0… ragelink 4257 // throw an exception if an attempt to read a data cache is made.
afe42d0… ragelink 4258 if ( elem && value === undefined ) {
afe42d0… ragelink 4259
afe42d0… ragelink 4260 // Attempt to get data from the cache
afe42d0… ragelink 4261 // The key will always be camelCased in Data
afe42d0… ragelink 4262 data = dataUser.get( elem, key );
afe42d0… ragelink 4263 if ( data !== undefined ) {
afe42d0… ragelink 4264 return data;
afe42d0… ragelink 4265 }
afe42d0… ragelink 4266
afe42d0… ragelink 4267 // Attempt to "discover" the data in
afe42d0… ragelink 4268 // HTML5 custom data-* attrs
afe42d0… ragelink 4269 data = dataAttr( elem, key );
afe42d0… ragelink 4270 if ( data !== undefined ) {
afe42d0… ragelink 4271 return data;
afe42d0… ragelink 4272 }
afe42d0… ragelink 4273
afe42d0… ragelink 4274 // We tried really hard, but the data doesn't exist.
afe42d0… ragelink 4275 return;
afe42d0… ragelink 4276 }
afe42d0… ragelink 4277
afe42d0… ragelink 4278 // Set the data...
afe42d0… ragelink 4279 this.each( function() {
afe42d0… ragelink 4280
afe42d0… ragelink 4281 // We always store the camelCased key
afe42d0… ragelink 4282 dataUser.set( this, key, value );
afe42d0… ragelink 4283 } );
afe42d0… ragelink 4284 }, null, value, arguments.length > 1, null, true );
afe42d0… ragelink 4285 },
afe42d0… ragelink 4286
afe42d0… ragelink 4287 removeData: function( key ) {
afe42d0… ragelink 4288 return this.each( function() {
afe42d0… ragelink 4289 dataUser.remove( this, key );
afe42d0… ragelink 4290 } );
afe42d0… ragelink 4291 }
afe42d0… ragelink 4292 } );
afe42d0… ragelink 4293
afe42d0… ragelink 4294
afe42d0… ragelink 4295 jQuery.extend( {
afe42d0… ragelink 4296 queue: function( elem, type, data ) {
afe42d0… ragelink 4297 var queue;
afe42d0… ragelink 4298
afe42d0… ragelink 4299 if ( elem ) {
afe42d0… ragelink 4300 type = ( type || "fx" ) + "queue";
afe42d0… ragelink 4301 queue = dataPriv.get( elem, type );
afe42d0… ragelink 4302
afe42d0… ragelink 4303 // Speed up dequeue by getting out quickly if this is just a lookup
afe42d0… ragelink 4304 if ( data ) {
afe42d0… ragelink 4305 if ( !queue || Array.isArray( data ) ) {
afe42d0… ragelink 4306 queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
afe42d0… ragelink 4307 } else {
afe42d0… ragelink 4308 queue.push( data );
afe42d0… ragelink 4309 }
afe42d0… ragelink 4310 }
afe42d0… ragelink 4311 return queue || [];
afe42d0… ragelink 4312 }
afe42d0… ragelink 4313 },
afe42d0… ragelink 4314
afe42d0… ragelink 4315 dequeue: function( elem, type ) {
afe42d0… ragelink 4316 type = type || "fx";
afe42d0… ragelink 4317
afe42d0… ragelink 4318 var queue = jQuery.queue( elem, type ),
afe42d0… ragelink 4319 startLength = queue.length,
afe42d0… ragelink 4320 fn = queue.shift(),
afe42d0… ragelink 4321 hooks = jQuery._queueHooks( elem, type ),
afe42d0… ragelink 4322 next = function() {
afe42d0… ragelink 4323 jQuery.dequeue( elem, type );
afe42d0… ragelink 4324 };
afe42d0… ragelink 4325
afe42d0… ragelink 4326 // If the fx queue is dequeued, always remove the progress sentinel
afe42d0… ragelink 4327 if ( fn === "inprogress" ) {
afe42d0… ragelink 4328 fn = queue.shift();
afe42d0… ragelink 4329 startLength--;
afe42d0… ragelink 4330 }
afe42d0… ragelink 4331
afe42d0… ragelink 4332 if ( fn ) {
afe42d0… ragelink 4333
afe42d0… ragelink 4334 // Add a progress sentinel to prevent the fx queue from being
afe42d0… ragelink 4335 // automatically dequeued
afe42d0… ragelink 4336 if ( type === "fx" ) {
afe42d0… ragelink 4337 queue.unshift( "inprogress" );
afe42d0… ragelink 4338 }
afe42d0… ragelink 4339
afe42d0… ragelink 4340 // Clear up the last queue stop function
afe42d0… ragelink 4341 delete hooks.stop;
afe42d0… ragelink 4342 fn.call( elem, next, hooks );
afe42d0… ragelink 4343 }
afe42d0… ragelink 4344
afe42d0… ragelink 4345 if ( !startLength && hooks ) {
afe42d0… ragelink 4346 hooks.empty.fire();
afe42d0… ragelink 4347 }
afe42d0… ragelink 4348 },
afe42d0… ragelink 4349
afe42d0… ragelink 4350 // Not public - generate a queueHooks object, or return the current one
afe42d0… ragelink 4351 _queueHooks: function( elem, type ) {
afe42d0… ragelink 4352 var key = type + "queueHooks";
afe42d0… ragelink 4353 return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
afe42d0… ragelink 4354 empty: jQuery.Callbacks( "once memory" ).add( function() {
afe42d0… ragelink 4355 dataPriv.remove( elem, [ type + "queue", key ] );
afe42d0… ragelink 4356 } )
afe42d0… ragelink 4357 } );
afe42d0… ragelink 4358 }
afe42d0… ragelink 4359 } );
afe42d0… ragelink 4360
afe42d0… ragelink 4361 jQuery.fn.extend( {
afe42d0… ragelink 4362 queue: function( type, data ) {
afe42d0… ragelink 4363 var setter = 2;
afe42d0… ragelink 4364
afe42d0… ragelink 4365 if ( typeof type !== "string" ) {
afe42d0… ragelink 4366 data = type;
afe42d0… ragelink 4367 type = "fx";
afe42d0… ragelink 4368 setter--;
afe42d0… ragelink 4369 }
afe42d0… ragelink 4370
afe42d0… ragelink 4371 if ( arguments.length < setter ) {
afe42d0… ragelink 4372 return jQuery.queue( this[ 0 ], type );
afe42d0… ragelink 4373 }
afe42d0… ragelink 4374
afe42d0… ragelink 4375 return data === undefined ?
afe42d0… ragelink 4376 this :
afe42d0… ragelink 4377 this.each( function() {
afe42d0… ragelink 4378 var queue = jQuery.queue( this, type, data );
afe42d0… ragelink 4379
afe42d0… ragelink 4380 // Ensure a hooks for this queue
afe42d0… ragelink 4381 jQuery._queueHooks( this, type );
afe42d0… ragelink 4382
afe42d0… ragelink 4383 if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
afe42d0… ragelink 4384 jQuery.dequeue( this, type );
afe42d0… ragelink 4385 }
afe42d0… ragelink 4386 } );
afe42d0… ragelink 4387 },
afe42d0… ragelink 4388 dequeue: function( type ) {
afe42d0… ragelink 4389 return this.each( function() {
afe42d0… ragelink 4390 jQuery.dequeue( this, type );
afe42d0… ragelink 4391 } );
afe42d0… ragelink 4392 },
afe42d0… ragelink 4393 clearQueue: function( type ) {
afe42d0… ragelink 4394 return this.queue( type || "fx", [] );
afe42d0… ragelink 4395 },
afe42d0… ragelink 4396
afe42d0… ragelink 4397 // Get a promise resolved when queues of a certain type
afe42d0… ragelink 4398 // are emptied (fx is the type by default)
afe42d0… ragelink 4399 promise: function( type, obj ) {
afe42d0… ragelink 4400 var tmp,
afe42d0… ragelink 4401 count = 1,
afe42d0… ragelink 4402 defer = jQuery.Deferred(),
afe42d0… ragelink 4403 elements = this,
afe42d0… ragelink 4404 i = this.length,
afe42d0… ragelink 4405 resolve = function() {
afe42d0… ragelink 4406 if ( !( --count ) ) {
afe42d0… ragelink 4407 defer.resolveWith( elements, [ elements ] );
afe42d0… ragelink 4408 }
afe42d0… ragelink 4409 };
afe42d0… ragelink 4410
afe42d0… ragelink 4411 if ( typeof type !== "string" ) {
afe42d0… ragelink 4412 obj = type;
afe42d0… ragelink 4413 type = undefined;
afe42d0… ragelink 4414 }
afe42d0… ragelink 4415 type = type || "fx";
afe42d0… ragelink 4416
afe42d0… ragelink 4417 while ( i-- ) {
afe42d0… ragelink 4418 tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
afe42d0… ragelink 4419 if ( tmp && tmp.empty ) {
afe42d0… ragelink 4420 count++;
afe42d0… ragelink 4421 tmp.empty.add( resolve );
afe42d0… ragelink 4422 }
afe42d0… ragelink 4423 }
afe42d0… ragelink 4424 resolve();
afe42d0… ragelink 4425 return defer.promise( obj );
afe42d0… ragelink 4426 }
afe42d0… ragelink 4427 } );
afe42d0… ragelink 4428 var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
afe42d0… ragelink 4429
afe42d0… ragelink 4430 var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
afe42d0… ragelink 4431
afe42d0… ragelink 4432
afe42d0… ragelink 4433 var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
afe42d0… ragelink 4434
afe42d0… ragelink 4435 var documentElement = document.documentElement;
afe42d0… ragelink 4436
afe42d0… ragelink 4437
afe42d0… ragelink 4438
afe42d0… ragelink 4439 var isAttached = function( elem ) {
afe42d0… ragelink 4440 return jQuery.contains( elem.ownerDocument, elem );
afe42d0… ragelink 4441 },
afe42d0… ragelink 4442 composed = { composed: true };
afe42d0… ragelink 4443
afe42d0… ragelink 4444 // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only
afe42d0… ragelink 4445 // Check attachment across shadow DOM boundaries when possible (gh-3504)
afe42d0… ragelink 4446 // Support: iOS 10.0-10.2 only
afe42d0… ragelink 4447 // Early iOS 10 versions support `attachShadow` but not `getRootNode`,
afe42d0… ragelink 4448 // leading to errors. We need to check for `getRootNode`.
afe42d0… ragelink 4449 if ( documentElement.getRootNode ) {
afe42d0… ragelink 4450 isAttached = function( elem ) {
afe42d0… ragelink 4451 return jQuery.contains( elem.ownerDocument, elem ) ||
afe42d0… ragelink 4452 elem.getRootNode( composed ) === elem.ownerDocument;
afe42d0… ragelink 4453 };
afe42d0… ragelink 4454 }
afe42d0… ragelink 4455 var isHiddenWithinTree = function( elem, el ) {
afe42d0… ragelink 4456
afe42d0… ragelink 4457 // isHiddenWithinTree might be called from jQuery#filter function;
afe42d0… ragelink 4458 // in that case, element will be second argument
afe42d0… ragelink 4459 elem = el || elem;
afe42d0… ragelink 4460
afe42d0… ragelink 4461 // Inline style trumps all
afe42d0… ragelink 4462 return elem.style.display === "none" ||
afe42d0… ragelink 4463 elem.style.display === "" &&
afe42d0… ragelink 4464
afe42d0… ragelink 4465 // Otherwise, check computed style
afe42d0… ragelink 4466 // Support: Firefox <=43 - 45
afe42d0… ragelink 4467 // Disconnected elements can have computed display: none, so first confirm that elem is
afe42d0… ragelink 4468 // in the document.
afe42d0… ragelink 4469 isAttached( elem ) &&
afe42d0… ragelink 4470
afe42d0… ragelink 4471 jQuery.css( elem, "display" ) === "none";
afe42d0… ragelink 4472 };
afe42d0… ragelink 4473
afe42d0… ragelink 4474
afe42d0… ragelink 4475
afe42d0… ragelink 4476 function adjustCSS( elem, prop, valueParts, tween ) {
afe42d0… ragelink 4477 var adjusted, scale,
afe42d0… ragelink 4478 maxIterations = 20,
afe42d0… ragelink 4479 currentValue = tween ?
afe42d0… ragelink 4480 function() {
afe42d0… ragelink 4481 return tween.cur();
afe42d0… ragelink 4482 } :
afe42d0… ragelink 4483 function() {
afe42d0… ragelink 4484 return jQuery.css( elem, prop, "" );
afe42d0… ragelink 4485 },
afe42d0… ragelink 4486 initial = currentValue(),
afe42d0… ragelink 4487 unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
afe42d0… ragelink 4488
afe42d0… ragelink 4489 // Starting value computation is required for potential unit mismatches
afe42d0… ragelink 4490 initialInUnit = elem.nodeType &&
afe42d0… ragelink 4491 ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
afe42d0… ragelink 4492 rcssNum.exec( jQuery.css( elem, prop ) );
afe42d0… ragelink 4493
afe42d0… ragelink 4494 if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
afe42d0… ragelink 4495
afe42d0… ragelink 4496 // Support: Firefox <=54
afe42d0… ragelink 4497 // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
afe42d0… ragelink 4498 initial = initial / 2;
afe42d0… ragelink 4499
afe42d0… ragelink 4500 // Trust units reported by jQuery.css
afe42d0… ragelink 4501 unit = unit || initialInUnit[ 3 ];
afe42d0… ragelink 4502
afe42d0… ragelink 4503 // Iteratively approximate from a nonzero starting point
afe42d0… ragelink 4504 initialInUnit = +initial || 1;
afe42d0… ragelink 4505
afe42d0… ragelink 4506 while ( maxIterations-- ) {
afe42d0… ragelink 4507
afe42d0… ragelink 4508 // Evaluate and update our best guess (doubling guesses that zero out).
afe42d0… ragelink 4509 // Finish if the scale equals or crosses 1 (making the old*new product non-positive).
afe42d0… ragelink 4510 jQuery.style( elem, prop, initialInUnit + unit );
afe42d0… ragelink 4511 if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) {
afe42d0… ragelink 4512 maxIterations = 0;
afe42d0… ragelink 4513 }
afe42d0… ragelink 4514 initialInUnit = initialInUnit / scale;
afe42d0… ragelink 4515
afe42d0… ragelink 4516 }
afe42d0… ragelink 4517
afe42d0… ragelink 4518 initialInUnit = initialInUnit * 2;
afe42d0… ragelink 4519 jQuery.style( elem, prop, initialInUnit + unit );
afe42d0… ragelink 4520
afe42d0… ragelink 4521 // Make sure we update the tween properties later on
afe42d0… ragelink 4522 valueParts = valueParts || [];
afe42d0… ragelink 4523 }
afe42d0… ragelink 4524
afe42d0… ragelink 4525 if ( valueParts ) {
afe42d0… ragelink 4526 initialInUnit = +initialInUnit || +initial || 0;
afe42d0… ragelink 4527
afe42d0… ragelink 4528 // Apply relative offset (+=/-=) if specified
afe42d0… ragelink 4529 adjusted = valueParts[ 1 ] ?
afe42d0… ragelink 4530 initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
afe42d0… ragelink 4531 +valueParts[ 2 ];
afe42d0… ragelink 4532 if ( tween ) {
afe42d0… ragelink 4533 tween.unit = unit;
afe42d0… ragelink 4534 tween.start = initialInUnit;
afe42d0… ragelink 4535 tween.end = adjusted;
afe42d0… ragelink 4536 }
afe42d0… ragelink 4537 }
afe42d0… ragelink 4538 return adjusted;
afe42d0… ragelink 4539 }
afe42d0… ragelink 4540
afe42d0… ragelink 4541
afe42d0… ragelink 4542 var defaultDisplayMap = {};
afe42d0… ragelink 4543
afe42d0… ragelink 4544 function getDefaultDisplay( elem ) {
afe42d0… ragelink 4545 var temp,
afe42d0… ragelink 4546 doc = elem.ownerDocument,
afe42d0… ragelink 4547 nodeName = elem.nodeName,
afe42d0… ragelink 4548 display = defaultDisplayMap[ nodeName ];
afe42d0… ragelink 4549
afe42d0… ragelink 4550 if ( display ) {
afe42d0… ragelink 4551 return display;
afe42d0… ragelink 4552 }
afe42d0… ragelink 4553
afe42d0… ragelink 4554 temp = doc.body.appendChild( doc.createElement( nodeName ) );
afe42d0… ragelink 4555 display = jQuery.css( temp, "display" );
afe42d0… ragelink 4556
afe42d0… ragelink 4557 temp.parentNode.removeChild( temp );
afe42d0… ragelink 4558
afe42d0… ragelink 4559 if ( display === "none" ) {
afe42d0… ragelink 4560 display = "block";
afe42d0… ragelink 4561 }
afe42d0… ragelink 4562 defaultDisplayMap[ nodeName ] = display;
afe42d0… ragelink 4563
afe42d0… ragelink 4564 return display;
afe42d0… ragelink 4565 }
afe42d0… ragelink 4566
afe42d0… ragelink 4567 function showHide( elements, show ) {
afe42d0… ragelink 4568 var display, elem,
afe42d0… ragelink 4569 values = [],
afe42d0… ragelink 4570 index = 0,
afe42d0… ragelink 4571 length = elements.length;
afe42d0… ragelink 4572
afe42d0… ragelink 4573 // Determine new display value for elements that need to change
afe42d0… ragelink 4574 for ( ; index < length; index++ ) {
afe42d0… ragelink 4575 elem = elements[ index ];
afe42d0… ragelink 4576 if ( !elem.style ) {
afe42d0… ragelink 4577 continue;
afe42d0… ragelink 4578 }
afe42d0… ragelink 4579
afe42d0… ragelink 4580 display = elem.style.display;
afe42d0… ragelink 4581 if ( show ) {
afe42d0… ragelink 4582
afe42d0… ragelink 4583 // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
afe42d0… ragelink 4584 // check is required in this first loop unless we have a nonempty display value (either
afe42d0… ragelink 4585 // inline or about-to-be-restored)
afe42d0… ragelink 4586 if ( display === "none" ) {
afe42d0… ragelink 4587 values[ index ] = dataPriv.get( elem, "display" ) || null;
afe42d0… ragelink 4588 if ( !values[ index ] ) {
afe42d0… ragelink 4589 elem.style.display = "";
afe42d0… ragelink 4590 }
afe42d0… ragelink 4591 }
afe42d0… ragelink 4592 if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
afe42d0… ragelink 4593 values[ index ] = getDefaultDisplay( elem );
afe42d0… ragelink 4594 }
afe42d0… ragelink 4595 } else {
afe42d0… ragelink 4596 if ( display !== "none" ) {
afe42d0… ragelink 4597 values[ index ] = "none";
afe42d0… ragelink 4598
afe42d0… ragelink 4599 // Remember what we're overwriting
afe42d0… ragelink 4600 dataPriv.set( elem, "display", display );
afe42d0… ragelink 4601 }
afe42d0… ragelink 4602 }
afe42d0… ragelink 4603 }
afe42d0… ragelink 4604
afe42d0… ragelink 4605 // Set the display of the elements in a second loop to avoid constant reflow
afe42d0… ragelink 4606 for ( index = 0; index < length; index++ ) {
afe42d0… ragelink 4607 if ( values[ index ] != null ) {
afe42d0… ragelink 4608 elements[ index ].style.display = values[ index ];
afe42d0… ragelink 4609 }
afe42d0… ragelink 4610 }
afe42d0… ragelink 4611
afe42d0… ragelink 4612 return elements;
afe42d0… ragelink 4613 }
afe42d0… ragelink 4614
afe42d0… ragelink 4615 jQuery.fn.extend( {
afe42d0… ragelink 4616 show: function() {
afe42d0… ragelink 4617 return showHide( this, true );
afe42d0… ragelink 4618 },
afe42d0… ragelink 4619 hide: function() {
afe42d0… ragelink 4620 return showHide( this );
afe42d0… ragelink 4621 },
afe42d0… ragelink 4622 toggle: function( state ) {
afe42d0… ragelink 4623 if ( typeof state === "boolean" ) {
afe42d0… ragelink 4624 return state ? this.show() : this.hide();
afe42d0… ragelink 4625 }
afe42d0… ragelink 4626
afe42d0… ragelink 4627 return this.each( function() {
afe42d0… ragelink 4628 if ( isHiddenWithinTree( this ) ) {
afe42d0… ragelink 4629 jQuery( this ).show();
afe42d0… ragelink 4630 } else {
afe42d0… ragelink 4631 jQuery( this ).hide();
afe42d0… ragelink 4632 }
afe42d0… ragelink 4633 } );
afe42d0… ragelink 4634 }
afe42d0… ragelink 4635 } );
afe42d0… ragelink 4636 var rcheckableType = ( /^(?:checkbox|radio)$/i );
afe42d0… ragelink 4637
afe42d0… ragelink 4638 var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i );
afe42d0… ragelink 4639
afe42d0… ragelink 4640 var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i );
afe42d0… ragelink 4641
afe42d0… ragelink 4642
afe42d0… ragelink 4643
afe42d0… ragelink 4644 ( function() {
afe42d0… ragelink 4645 var fragment = document.createDocumentFragment(),
afe42d0… ragelink 4646 div = fragment.appendChild( document.createElement( "div" ) ),
afe42d0… ragelink 4647 input = document.createElement( "input" );
afe42d0… ragelink 4648
afe42d0… ragelink 4649 // Support: Android 4.0 - 4.3 only
afe42d0… ragelink 4650 // Check state lost if the name is set (trac-11217)
afe42d0… ragelink 4651 // Support: Windows Web Apps (WWA)
afe42d0… ragelink 4652 // `name` and `type` must use .setAttribute for WWA (trac-14901)
afe42d0… ragelink 4653 input.setAttribute( "type", "radio" );
afe42d0… ragelink 4654 input.setAttribute( "checked", "checked" );
afe42d0… ragelink 4655 input.setAttribute( "name", "t" );
afe42d0… ragelink 4656
afe42d0… ragelink 4657 div.appendChild( input );
afe42d0… ragelink 4658
afe42d0… ragelink 4659 // Support: Android <=4.1 only
afe42d0… ragelink 4660 // Older WebKit doesn't clone checked state correctly in fragments
afe42d0… ragelink 4661 support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
afe42d0… ragelink 4662
afe42d0… ragelink 4663 // Support: IE <=11 only
afe42d0… ragelink 4664 // Make sure textarea (and checkbox) defaultValue is properly cloned
afe42d0… ragelink 4665 div.innerHTML = "<textarea>x</textarea>";
afe42d0… ragelink 4666 support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
afe42d0… ragelink 4667
afe42d0… ragelink 4668 // Support: IE <=9 only
afe42d0… ragelink 4669 // IE <=9 replaces <option> tags with their contents when inserted outside of
afe42d0… ragelink 4670 // the select element.
afe42d0… ragelink 4671 div.innerHTML = "<option></option>";
afe42d0… ragelink 4672 support.option = !!div.lastChild;
afe42d0… ragelink 4673 } )();
afe42d0… ragelink 4674
afe42d0… ragelink 4675
afe42d0… ragelink 4676 // We have to close these tags to support XHTML (trac-13200)
afe42d0… ragelink 4677 var wrapMap = {
afe42d0… ragelink 4678
afe42d0… ragelink 4679 // XHTML parsers do not magically insert elements in the
afe42d0… ragelink 4680 // same way that tag soup parsers do. So we cannot shorten
afe42d0… ragelink 4681 // this by omitting <tbody> or other required elements.
afe42d0… ragelink 4682 thead: [ 1, "<table>", "</table>" ],
afe42d0… ragelink 4683 col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
afe42d0… ragelink 4684 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
afe42d0… ragelink 4685 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
afe42d0… ragelink 4686
afe42d0… ragelink 4687 _default: [ 0, "", "" ]
afe42d0… ragelink 4688 };
afe42d0… ragelink 4689
afe42d0… ragelink 4690 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
afe42d0… ragelink 4691 wrapMap.th = wrapMap.td;
afe42d0… ragelink 4692
afe42d0… ragelink 4693 // Support: IE <=9 only
afe42d0… ragelink 4694 if ( !support.option ) {
afe42d0… ragelink 4695 wrapMap.optgroup = wrapMap.option = [ 1, "<select multiple='multiple'>", "</select>" ];
afe42d0… ragelink 4696 }
afe42d0… ragelink 4697
afe42d0… ragelink 4698
afe42d0… ragelink 4699 function getAll( context, tag ) {
afe42d0… ragelink 4700
afe42d0… ragelink 4701 // Support: IE <=9 - 11 only
afe42d0… ragelink 4702 // Use typeof to avoid zero-argument method invocation on host objects (trac-15151)
afe42d0… ragelink 4703 var ret;
afe42d0… ragelink 4704
afe42d0… ragelink 4705 if ( typeof context.getElementsByTagName !== "undefined" ) {
afe42d0… ragelink 4706 ret = context.getElementsByTagName( tag || "*" );
afe42d0… ragelink 4707
afe42d0… ragelink 4708 } else if ( typeof context.querySelectorAll !== "undefined" ) {
afe42d0… ragelink 4709 ret = context.querySelectorAll( tag || "*" );
afe42d0… ragelink 4710
afe42d0… ragelink 4711 } else {
afe42d0… ragelink 4712 ret = [];
afe42d0… ragelink 4713 }
afe42d0… ragelink 4714
afe42d0… ragelink 4715 if ( tag === undefined || tag && nodeName( context, tag ) ) {
afe42d0… ragelink 4716 return jQuery.merge( [ context ], ret );
afe42d0… ragelink 4717 }
afe42d0… ragelink 4718
afe42d0… ragelink 4719 return ret;
afe42d0… ragelink 4720 }
afe42d0… ragelink 4721
afe42d0… ragelink 4722
afe42d0… ragelink 4723 // Mark scripts as having already been evaluated
afe42d0… ragelink 4724 function setGlobalEval( elems, refElements ) {
afe42d0… ragelink 4725 var i = 0,
afe42d0… ragelink 4726 l = elems.length;
afe42d0… ragelink 4727
afe42d0… ragelink 4728 for ( ; i < l; i++ ) {
afe42d0… ragelink 4729 dataPriv.set(
afe42d0… ragelink 4730 elems[ i ],
afe42d0… ragelink 4731 "globalEval",
afe42d0… ragelink 4732 !refElements || dataPriv.get( refElements[ i ], "globalEval" )
afe42d0… ragelink 4733 );
afe42d0… ragelink 4734 }
afe42d0… ragelink 4735 }
afe42d0… ragelink 4736
afe42d0… ragelink 4737
afe42d0… ragelink 4738 var rhtml = /<|&#?\w+;/;
afe42d0… ragelink 4739
afe42d0… ragelink 4740 function buildFragment( elems, context, scripts, selection, ignored ) {
afe42d0… ragelink 4741 var elem, tmp, tag, wrap, attached, j,
afe42d0… ragelink 4742 fragment = context.createDocumentFragment(),
afe42d0… ragelink 4743 nodes = [],
afe42d0… ragelink 4744 i = 0,
afe42d0… ragelink 4745 l = elems.length;
afe42d0… ragelink 4746
afe42d0… ragelink 4747 for ( ; i < l; i++ ) {
afe42d0… ragelink 4748 elem = elems[ i ];
afe42d0… ragelink 4749
afe42d0… ragelink 4750 if ( elem || elem === 0 ) {
afe42d0… ragelink 4751
afe42d0… ragelink 4752 // Add nodes directly
afe42d0… ragelink 4753 if ( toType( elem ) === "object" ) {
afe42d0… ragelink 4754
afe42d0… ragelink 4755 // Support: Android <=4.0 only, PhantomJS 1 only
afe42d0… ragelink 4756 // push.apply(_, arraylike) throws on ancient WebKit
afe42d0… ragelink 4757 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
afe42d0… ragelink 4758
afe42d0… ragelink 4759 // Convert non-html into a text node
afe42d0… ragelink 4760 } else if ( !rhtml.test( elem ) ) {
afe42d0… ragelink 4761 nodes.push( context.createTextNode( elem ) );
afe42d0… ragelink 4762
afe42d0… ragelink 4763 // Convert html into DOM nodes
afe42d0… ragelink 4764 } else {
afe42d0… ragelink 4765 tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
afe42d0… ragelink 4766
afe42d0… ragelink 4767 // Deserialize a standard representation
afe42d0… ragelink 4768 tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
afe42d0… ragelink 4769 wrap = wrapMap[ tag ] || wrapMap._default;
afe42d0… ragelink 4770 tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
afe42d0… ragelink 4771
afe42d0… ragelink 4772 // Descend through wrappers to the right content
afe42d0… ragelink 4773 j = wrap[ 0 ];
afe42d0… ragelink 4774 while ( j-- ) {
afe42d0… ragelink 4775 tmp = tmp.lastChild;
afe42d0… ragelink 4776 }
afe42d0… ragelink 4777
afe42d0… ragelink 4778 // Support: Android <=4.0 only, PhantomJS 1 only
afe42d0… ragelink 4779 // push.apply(_, arraylike) throws on ancient WebKit
afe42d0… ragelink 4780 jQuery.merge( nodes, tmp.childNodes );
afe42d0… ragelink 4781
afe42d0… ragelink 4782 // Remember the top-level container
afe42d0… ragelink 4783 tmp = fragment.firstChild;
afe42d0… ragelink 4784
afe42d0… ragelink 4785 // Ensure the created nodes are orphaned (trac-12392)
afe42d0… ragelink 4786 tmp.textContent = "";
afe42d0… ragelink 4787 }
afe42d0… ragelink 4788 }
afe42d0… ragelink 4789 }
afe42d0… ragelink 4790
afe42d0… ragelink 4791 // Remove wrapper from fragment
afe42d0… ragelink 4792 fragment.textContent = "";
afe42d0… ragelink 4793
afe42d0… ragelink 4794 i = 0;
afe42d0… ragelink 4795 while ( ( elem = nodes[ i++ ] ) ) {
afe42d0… ragelink 4796
afe42d0… ragelink 4797 // Skip elements already in the context collection (trac-4087)
afe42d0… ragelink 4798 if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
afe42d0… ragelink 4799 if ( ignored ) {
afe42d0… ragelink 4800 ignored.push( elem );
afe42d0… ragelink 4801 }
afe42d0… ragelink 4802 continue;
afe42d0… ragelink 4803 }
afe42d0… ragelink 4804
afe42d0… ragelink 4805 attached = isAttached( elem );
afe42d0… ragelink 4806
afe42d0… ragelink 4807 // Append to fragment
afe42d0… ragelink 4808 tmp = getAll( fragment.appendChild( elem ), "script" );
afe42d0… ragelink 4809
afe42d0… ragelink 4810 // Preserve script evaluation history
afe42d0… ragelink 4811 if ( attached ) {
afe42d0… ragelink 4812 setGlobalEval( tmp );
afe42d0… ragelink 4813 }
afe42d0… ragelink 4814
afe42d0… ragelink 4815 // Capture executables
afe42d0… ragelink 4816 if ( scripts ) {
afe42d0… ragelink 4817 j = 0;
afe42d0… ragelink 4818 while ( ( elem = tmp[ j++ ] ) ) {
afe42d0… ragelink 4819 if ( rscriptType.test( elem.type || "" ) ) {
afe42d0… ragelink 4820 scripts.push( elem );
afe42d0… ragelink 4821 }
afe42d0… ragelink 4822 }
afe42d0… ragelink 4823 }
afe42d0… ragelink 4824 }
afe42d0… ragelink 4825
afe42d0… ragelink 4826 return fragment;
afe42d0… ragelink 4827 }
afe42d0… ragelink 4828
afe42d0… ragelink 4829
afe42d0… ragelink 4830 var rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
afe42d0… ragelink 4831
afe42d0… ragelink 4832 function returnTrue() {
afe42d0… ragelink 4833 return true;
afe42d0… ragelink 4834 }
afe42d0… ragelink 4835
afe42d0… ragelink 4836 function returnFalse() {
afe42d0… ragelink 4837 return false;
afe42d0… ragelink 4838 }
afe42d0… ragelink 4839
afe42d0… ragelink 4840 function on( elem, types, selector, data, fn, one ) {
afe42d0… ragelink 4841 var origFn, type;
afe42d0… ragelink 4842
afe42d0… ragelink 4843 // Types can be a map of types/handlers
afe42d0… ragelink 4844 if ( typeof types === "object" ) {
afe42d0… ragelink 4845
afe42d0… ragelink 4846 // ( types-Object, selector, data )
afe42d0… ragelink 4847 if ( typeof selector !== "string" ) {
afe42d0… ragelink 4848
afe42d0… ragelink 4849 // ( types-Object, data )
afe42d0… ragelink 4850 data = data || selector;
afe42d0… ragelink 4851 selector = undefined;
afe42d0… ragelink 4852 }
afe42d0… ragelink 4853 for ( type in types ) {
afe42d0… ragelink 4854 on( elem, type, selector, data, types[ type ], one );
afe42d0… ragelink 4855 }
afe42d0… ragelink 4856 return elem;
afe42d0… ragelink 4857 }
afe42d0… ragelink 4858
afe42d0… ragelink 4859 if ( data == null && fn == null ) {
afe42d0… ragelink 4860
afe42d0… ragelink 4861 // ( types, fn )
afe42d0… ragelink 4862 fn = selector;
afe42d0… ragelink 4863 data = selector = undefined;
afe42d0… ragelink 4864 } else if ( fn == null ) {
afe42d0… ragelink 4865 if ( typeof selector === "string" ) {
afe42d0… ragelink 4866
afe42d0… ragelink 4867 // ( types, selector, fn )
afe42d0… ragelink 4868 fn = data;
afe42d0… ragelink 4869 data = undefined;
afe42d0… ragelink 4870 } else {
afe42d0… ragelink 4871
afe42d0… ragelink 4872 // ( types, data, fn )
afe42d0… ragelink 4873 fn = data;
afe42d0… ragelink 4874 data = selector;
afe42d0… ragelink 4875 selector = undefined;
afe42d0… ragelink 4876 }
afe42d0… ragelink 4877 }
afe42d0… ragelink 4878 if ( fn === false ) {
afe42d0… ragelink 4879 fn = returnFalse;
afe42d0… ragelink 4880 } else if ( !fn ) {
afe42d0… ragelink 4881 return elem;
afe42d0… ragelink 4882 }
afe42d0… ragelink 4883
afe42d0… ragelink 4884 if ( one === 1 ) {
afe42d0… ragelink 4885 origFn = fn;
afe42d0… ragelink 4886 fn = function( event ) {
afe42d0… ragelink 4887
afe42d0… ragelink 4888 // Can use an empty set, since event contains the info
afe42d0… ragelink 4889 jQuery().off( event );
afe42d0… ragelink 4890 return origFn.apply( this, arguments );
afe42d0… ragelink 4891 };
afe42d0… ragelink 4892
afe42d0… ragelink 4893 // Use same guid so caller can remove using origFn
afe42d0… ragelink 4894 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
afe42d0… ragelink 4895 }
afe42d0… ragelink 4896 return elem.each( function() {
afe42d0… ragelink 4897 jQuery.event.add( this, types, fn, data, selector );
afe42d0… ragelink 4898 } );
afe42d0… ragelink 4899 }
afe42d0… ragelink 4900
afe42d0… ragelink 4901 /*
afe42d0… ragelink 4902 * Helper functions for managing events -- not part of the public interface.
afe42d0… ragelink 4903 * Props to Dean Edwards' addEvent library for many of the ideas.
afe42d0… ragelink 4904 */
afe42d0… ragelink 4905 jQuery.event = {
afe42d0… ragelink 4906
afe42d0… ragelink 4907 global: {},
afe42d0… ragelink 4908
afe42d0… ragelink 4909 add: function( elem, types, handler, data, selector ) {
afe42d0… ragelink 4910
afe42d0… ragelink 4911 var handleObjIn, eventHandle, tmp,
afe42d0… ragelink 4912 events, t, handleObj,
afe42d0… ragelink 4913 special, handlers, type, namespaces, origType,
afe42d0… ragelink 4914 elemData = dataPriv.get( elem );
afe42d0… ragelink 4915
afe42d0… ragelink 4916 // Only attach events to objects that accept data
afe42d0… ragelink 4917 if ( !acceptData( elem ) ) {
afe42d0… ragelink 4918 return;
afe42d0… ragelink 4919 }
afe42d0… ragelink 4920
afe42d0… ragelink 4921 // Caller can pass in an object of custom data in lieu of the handler
afe42d0… ragelink 4922 if ( handler.handler ) {
afe42d0… ragelink 4923 handleObjIn = handler;
afe42d0… ragelink 4924 handler = handleObjIn.handler;
afe42d0… ragelink 4925 selector = handleObjIn.selector;
afe42d0… ragelink 4926 }
afe42d0… ragelink 4927
afe42d0… ragelink 4928 // Ensure that invalid selectors throw exceptions at attach time
afe42d0… ragelink 4929 // Evaluate against documentElement in case elem is a non-element node (e.g., document)
afe42d0… ragelink 4930 if ( selector ) {
afe42d0… ragelink 4931 jQuery.find.matchesSelector( documentElement, selector );
afe42d0… ragelink 4932 }
afe42d0… ragelink 4933
afe42d0… ragelink 4934 // Make sure that the handler has a unique ID, used to find/remove it later
afe42d0… ragelink 4935 if ( !handler.guid ) {
afe42d0… ragelink 4936 handler.guid = jQuery.guid++;
afe42d0… ragelink 4937 }
afe42d0… ragelink 4938
afe42d0… ragelink 4939 // Init the element's event structure and main handler, if this is the first
afe42d0… ragelink 4940 if ( !( events = elemData.events ) ) {
afe42d0… ragelink 4941 events = elemData.events = Object.create( null );
afe42d0… ragelink 4942 }
afe42d0… ragelink 4943 if ( !( eventHandle = elemData.handle ) ) {
afe42d0… ragelink 4944 eventHandle = elemData.handle = function( e ) {
afe42d0… ragelink 4945
afe42d0… ragelink 4946 // Discard the second event of a jQuery.event.trigger() and
afe42d0… ragelink 4947 // when an event is called after a page has unloaded
afe42d0… ragelink 4948 return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
afe42d0… ragelink 4949 jQuery.event.dispatch.apply( elem, arguments ) : undefined;
afe42d0… ragelink 4950 };
afe42d0… ragelink 4951 }
afe42d0… ragelink 4952
afe42d0… ragelink 4953 // Handle multiple events separated by a space
afe42d0… ragelink 4954 types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
afe42d0… ragelink 4955 t = types.length;
afe42d0… ragelink 4956 while ( t-- ) {
afe42d0… ragelink 4957 tmp = rtypenamespace.exec( types[ t ] ) || [];
afe42d0… ragelink 4958 type = origType = tmp[ 1 ];
afe42d0… ragelink 4959 namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
afe42d0… ragelink 4960
afe42d0… ragelink 4961 // There *must* be a type, no attaching namespace-only handlers
afe42d0… ragelink 4962 if ( !type ) {
afe42d0… ragelink 4963 continue;
afe42d0… ragelink 4964 }
afe42d0… ragelink 4965
afe42d0… ragelink 4966 // If event changes its type, use the special event handlers for the changed type
afe42d0… ragelink 4967 special = jQuery.event.special[ type ] || {};
afe42d0… ragelink 4968
afe42d0… ragelink 4969 // If selector defined, determine special event api type, otherwise given type
afe42d0… ragelink 4970 type = ( selector ? special.delegateType : special.bindType ) || type;
afe42d0… ragelink 4971
afe42d0… ragelink 4972 // Update special based on newly reset type
afe42d0… ragelink 4973 special = jQuery.event.special[ type ] || {};
afe42d0… ragelink 4974
afe42d0… ragelink 4975 // handleObj is passed to all event handlers
afe42d0… ragelink 4976 handleObj = jQuery.extend( {
afe42d0… ragelink 4977 type: type,
afe42d0… ragelink 4978 origType: origType,
afe42d0… ragelink 4979 data: data,
afe42d0… ragelink 4980 handler: handler,
afe42d0… ragelink 4981 guid: handler.guid,
afe42d0… ragelink 4982 selector: selector,
afe42d0… ragelink 4983 needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
afe42d0… ragelink 4984 namespace: namespaces.join( "." )
afe42d0… ragelink 4985 }, handleObjIn );
afe42d0… ragelink 4986
afe42d0… ragelink 4987 // Init the event handler queue if we're the first
afe42d0… ragelink 4988 if ( !( handlers = events[ type ] ) ) {
afe42d0… ragelink 4989 handlers = events[ type ] = [];
afe42d0… ragelink 4990 handlers.delegateCount = 0;
afe42d0… ragelink 4991
afe42d0… ragelink 4992 // Only use addEventListener if the special events handler returns false
afe42d0… ragelink 4993 if ( !special.setup ||
afe42d0… ragelink 4994 special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
afe42d0… ragelink 4995
afe42d0… ragelink 4996 if ( elem.addEventListener ) {
afe42d0… ragelink 4997 elem.addEventListener( type, eventHandle );
afe42d0… ragelink 4998 }
afe42d0… ragelink 4999 }
afe42d0… ragelink 5000 }
afe42d0… ragelink 5001
afe42d0… ragelink 5002 if ( special.add ) {
afe42d0… ragelink 5003 special.add.call( elem, handleObj );
afe42d0… ragelink 5004
afe42d0… ragelink 5005 if ( !handleObj.handler.guid ) {
afe42d0… ragelink 5006 handleObj.handler.guid = handler.guid;
afe42d0… ragelink 5007 }
afe42d0… ragelink 5008 }
afe42d0… ragelink 5009
afe42d0… ragelink 5010 // Add to the element's handler list, delegates in front
afe42d0… ragelink 5011 if ( selector ) {
afe42d0… ragelink 5012 handlers.splice( handlers.delegateCount++, 0, handleObj );
afe42d0… ragelink 5013 } else {
afe42d0… ragelink 5014 handlers.push( handleObj );
afe42d0… ragelink 5015 }
afe42d0… ragelink 5016
afe42d0… ragelink 5017 // Keep track of which events have ever been used, for event optimization
afe42d0… ragelink 5018 jQuery.event.global[ type ] = true;
afe42d0… ragelink 5019 }
afe42d0… ragelink 5020
afe42d0… ragelink 5021 },
afe42d0… ragelink 5022
afe42d0… ragelink 5023 // Detach an event or set of events from an element
afe42d0… ragelink 5024 remove: function( elem, types, handler, selector, mappedTypes ) {
afe42d0… ragelink 5025
afe42d0… ragelink 5026 var j, origCount, tmp,
afe42d0… ragelink 5027 events, t, handleObj,
afe42d0… ragelink 5028 special, handlers, type, namespaces, origType,
afe42d0… ragelink 5029 elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
afe42d0… ragelink 5030
afe42d0… ragelink 5031 if ( !elemData || !( events = elemData.events ) ) {
afe42d0… ragelink 5032 return;
afe42d0… ragelink 5033 }
afe42d0… ragelink 5034
afe42d0… ragelink 5035 // Once for each type.namespace in types; type may be omitted
afe42d0… ragelink 5036 types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
afe42d0… ragelink 5037 t = types.length;
afe42d0… ragelink 5038 while ( t-- ) {
afe42d0… ragelink 5039 tmp = rtypenamespace.exec( types[ t ] ) || [];
afe42d0… ragelink 5040 type = origType = tmp[ 1 ];
afe42d0… ragelink 5041 namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
afe42d0… ragelink 5042
afe42d0… ragelink 5043 // Unbind all events (on this namespace, if provided) for the element
afe42d0… ragelink 5044 if ( !type ) {
afe42d0… ragelink 5045 for ( type in events ) {
afe42d0… ragelink 5046 jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
afe42d0… ragelink 5047 }
afe42d0… ragelink 5048 continue;
afe42d0… ragelink 5049 }
afe42d0… ragelink 5050
afe42d0… ragelink 5051 special = jQuery.event.special[ type ] || {};
afe42d0… ragelink 5052 type = ( selector ? special.delegateType : special.bindType ) || type;
afe42d0… ragelink 5053 handlers = events[ type ] || [];
afe42d0… ragelink 5054 tmp = tmp[ 2 ] &&
afe42d0… ragelink 5055 new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
afe42d0… ragelink 5056
afe42d0… ragelink 5057 // Remove matching events
afe42d0… ragelink 5058 origCount = j = handlers.length;
afe42d0… ragelink 5059 while ( j-- ) {
afe42d0… ragelink 5060 handleObj = handlers[ j ];
afe42d0… ragelink 5061
afe42d0… ragelink 5062 if ( ( mappedTypes || origType === handleObj.origType ) &&
afe42d0… ragelink 5063 ( !handler || handler.guid === handleObj.guid ) &&
afe42d0… ragelink 5064 ( !tmp || tmp.test( handleObj.namespace ) ) &&
afe42d0… ragelink 5065 ( !selector || selector === handleObj.selector ||
afe42d0… ragelink 5066 selector === "**" && handleObj.selector ) ) {
afe42d0… ragelink 5067 handlers.splice( j, 1 );
afe42d0… ragelink 5068
afe42d0… ragelink 5069 if ( handleObj.selector ) {
afe42d0… ragelink 5070 handlers.delegateCount--;
afe42d0… ragelink 5071 }
afe42d0… ragelink 5072 if ( special.remove ) {
afe42d0… ragelink 5073 special.remove.call( elem, handleObj );
afe42d0… ragelink 5074 }
afe42d0… ragelink 5075 }
afe42d0… ragelink 5076 }
afe42d0… ragelink 5077
afe42d0… ragelink 5078 // Remove generic event handler if we removed something and no more handlers exist
afe42d0… ragelink 5079 // (avoids potential for endless recursion during removal of special event handlers)
afe42d0… ragelink 5080 if ( origCount && !handlers.length ) {
afe42d0… ragelink 5081 if ( !special.teardown ||
afe42d0… ragelink 5082 special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
afe42d0… ragelink 5083
afe42d0… ragelink 5084 jQuery.removeEvent( elem, type, elemData.handle );
afe42d0… ragelink 5085 }
afe42d0… ragelink 5086
afe42d0… ragelink 5087 delete events[ type ];
afe42d0… ragelink 5088 }
afe42d0… ragelink 5089 }
afe42d0… ragelink 5090
afe42d0… ragelink 5091 // Remove data and the expando if it's no longer used
afe42d0… ragelink 5092 if ( jQuery.isEmptyObject( events ) ) {
afe42d0… ragelink 5093 dataPriv.remove( elem, "handle events" );
afe42d0… ragelink 5094 }
afe42d0… ragelink 5095 },
afe42d0… ragelink 5096
afe42d0… ragelink 5097 dispatch: function( nativeEvent ) {
afe42d0… ragelink 5098
afe42d0… ragelink 5099 var i, j, ret, matched, handleObj, handlerQueue,
afe42d0… ragelink 5100 args = new Array( arguments.length ),
afe42d0… ragelink 5101
afe42d0… ragelink 5102 // Make a writable jQuery.Event from the native event object
afe42d0… ragelink 5103 event = jQuery.event.fix( nativeEvent ),
afe42d0… ragelink 5104
afe42d0… ragelink 5105 handlers = (
afe42d0… ragelink 5106 dataPriv.get( this, "events" ) || Object.create( null )
afe42d0… ragelink 5107 )[ event.type ] || [],
afe42d0… ragelink 5108 special = jQuery.event.special[ event.type ] || {};
afe42d0… ragelink 5109
afe42d0… ragelink 5110 // Use the fix-ed jQuery.Event rather than the (read-only) native event
afe42d0… ragelink 5111 args[ 0 ] = event;
afe42d0… ragelink 5112
afe42d0… ragelink 5113 for ( i = 1; i < arguments.length; i++ ) {
afe42d0… ragelink 5114 args[ i ] = arguments[ i ];
afe42d0… ragelink 5115 }
afe42d0… ragelink 5116
afe42d0… ragelink 5117 event.delegateTarget = this;
afe42d0… ragelink 5118
afe42d0… ragelink 5119 // Call the preDispatch hook for the mapped type, and let it bail if desired
afe42d0… ragelink 5120 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
afe42d0… ragelink 5121 return;
afe42d0… ragelink 5122 }
afe42d0… ragelink 5123
afe42d0… ragelink 5124 // Determine handlers
afe42d0… ragelink 5125 handlerQueue = jQuery.event.handlers.call( this, event, handlers );
afe42d0… ragelink 5126
afe42d0… ragelink 5127 // Run delegates first; they may want to stop propagation beneath us
afe42d0… ragelink 5128 i = 0;
afe42d0… ragelink 5129 while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
afe42d0… ragelink 5130 event.currentTarget = matched.elem;
afe42d0… ragelink 5131
afe42d0… ragelink 5132 j = 0;
afe42d0… ragelink 5133 while ( ( handleObj = matched.handlers[ j++ ] ) &&
afe42d0… ragelink 5134 !event.isImmediatePropagationStopped() ) {
afe42d0… ragelink 5135
afe42d0… ragelink 5136 // If the event is namespaced, then each handler is only invoked if it is
afe42d0… ragelink 5137 // specially universal or its namespaces are a superset of the event's.
afe42d0… ragelink 5138 if ( !event.rnamespace || handleObj.namespace === false ||
afe42d0… ragelink 5139 event.rnamespace.test( handleObj.namespace ) ) {
afe42d0… ragelink 5140
afe42d0… ragelink 5141 event.handleObj = handleObj;
afe42d0… ragelink 5142 event.data = handleObj.data;
afe42d0… ragelink 5143
afe42d0… ragelink 5144 ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
afe42d0… ragelink 5145 handleObj.handler ).apply( matched.elem, args );
afe42d0… ragelink 5146
afe42d0… ragelink 5147 if ( ret !== undefined ) {
afe42d0… ragelink 5148 if ( ( event.result = ret ) === false ) {
afe42d0… ragelink 5149 event.preventDefault();
afe42d0… ragelink 5150 event.stopPropagation();
afe42d0… ragelink 5151 }
afe42d0… ragelink 5152 }
afe42d0… ragelink 5153 }
afe42d0… ragelink 5154 }
afe42d0… ragelink 5155 }
afe42d0… ragelink 5156
afe42d0… ragelink 5157 // Call the postDispatch hook for the mapped type
afe42d0… ragelink 5158 if ( special.postDispatch ) {
afe42d0… ragelink 5159 special.postDispatch.call( this, event );
afe42d0… ragelink 5160 }
afe42d0… ragelink 5161
afe42d0… ragelink 5162 return event.result;
afe42d0… ragelink 5163 },
afe42d0… ragelink 5164
afe42d0… ragelink 5165 handlers: function( event, handlers ) {
afe42d0… ragelink 5166 var i, handleObj, sel, matchedHandlers, matchedSelectors,
afe42d0… ragelink 5167 handlerQueue = [],
afe42d0… ragelink 5168 delegateCount = handlers.delegateCount,
afe42d0… ragelink 5169 cur = event.target;
afe42d0… ragelink 5170
afe42d0… ragelink 5171 // Find delegate handlers
afe42d0… ragelink 5172 if ( delegateCount &&
afe42d0… ragelink 5173
afe42d0… ragelink 5174 // Support: IE <=9
afe42d0… ragelink 5175 // Black-hole SVG <use> instance trees (trac-13180)
afe42d0… ragelink 5176 cur.nodeType &&
afe42d0… ragelink 5177
afe42d0… ragelink 5178 // Support: Firefox <=42
afe42d0… ragelink 5179 // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
afe42d0… ragelink 5180 // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
afe42d0… ragelink 5181 // Support: IE 11 only
afe42d0… ragelink 5182 // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
afe42d0… ragelink 5183 !( event.type === "click" && event.button >= 1 ) ) {
afe42d0… ragelink 5184
afe42d0… ragelink 5185 for ( ; cur !== this; cur = cur.parentNode || this ) {
afe42d0… ragelink 5186
afe42d0… ragelink 5187 // Don't check non-elements (trac-13208)
afe42d0… ragelink 5188 // Don't process clicks on disabled elements (trac-6911, trac-8165, trac-11382, trac-11764)
afe42d0… ragelink 5189 if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) {
afe42d0… ragelink 5190 matchedHandlers = [];
afe42d0… ragelink 5191 matchedSelectors = {};
afe42d0… ragelink 5192 for ( i = 0; i < delegateCount; i++ ) {
afe42d0… ragelink 5193 handleObj = handlers[ i ];
afe42d0… ragelink 5194
afe42d0… ragelink 5195 // Don't conflict with Object.prototype properties (trac-13203)
afe42d0… ragelink 5196 sel = handleObj.selector + " ";
afe42d0… ragelink 5197
afe42d0… ragelink 5198 if ( matchedSelectors[ sel ] === undefined ) {
afe42d0… ragelink 5199 matchedSelectors[ sel ] = handleObj.needsContext ?
afe42d0… ragelink 5200 jQuery( sel, this ).index( cur ) > -1 :
afe42d0… ragelink 5201 jQuery.find( sel, this, null, [ cur ] ).length;
afe42d0… ragelink 5202 }
afe42d0… ragelink 5203 if ( matchedSelectors[ sel ] ) {
afe42d0… ragelink 5204 matchedHandlers.push( handleObj );
afe42d0… ragelink 5205 }
afe42d0… ragelink 5206 }
afe42d0… ragelink 5207 if ( matchedHandlers.length ) {
afe42d0… ragelink 5208 handlerQueue.push( { elem: cur, handlers: matchedHandlers } );
afe42d0… ragelink 5209 }
afe42d0… ragelink 5210 }
afe42d0… ragelink 5211 }
afe42d0… ragelink 5212 }
afe42d0… ragelink 5213
afe42d0… ragelink 5214 // Add the remaining (directly-bound) handlers
afe42d0… ragelink 5215 cur = this;
afe42d0… ragelink 5216 if ( delegateCount < handlers.length ) {
afe42d0… ragelink 5217 handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } );
afe42d0… ragelink 5218 }
afe42d0… ragelink 5219
afe42d0… ragelink 5220 return handlerQueue;
afe42d0… ragelink 5221 },
afe42d0… ragelink 5222
afe42d0… ragelink 5223 addProp: function( name, hook ) {
afe42d0… ragelink 5224 Object.defineProperty( jQuery.Event.prototype, name, {
afe42d0… ragelink 5225 enumerable: true,
afe42d0… ragelink 5226 configurable: true,
afe42d0… ragelink 5227
afe42d0… ragelink 5228 get: isFunction( hook ) ?
afe42d0… ragelink 5229 function() {
afe42d0… ragelink 5230 if ( this.originalEvent ) {
afe42d0… ragelink 5231 return hook( this.originalEvent );
afe42d0… ragelink 5232 }
afe42d0… ragelink 5233 } :
afe42d0… ragelink 5234 function() {
afe42d0… ragelink 5235 if ( this.originalEvent ) {
afe42d0… ragelink 5236 return this.originalEvent[ name ];
afe42d0… ragelink 5237 }
afe42d0… ragelink 5238 },
afe42d0… ragelink 5239
afe42d0… ragelink 5240 set: function( value ) {
afe42d0… ragelink 5241 Object.defineProperty( this, name, {
afe42d0… ragelink 5242 enumerable: true,
afe42d0… ragelink 5243 configurable: true,
afe42d0… ragelink 5244 writable: true,
afe42d0… ragelink 5245 value: value
afe42d0… ragelink 5246 } );
afe42d0… ragelink 5247 }
afe42d0… ragelink 5248 } );
afe42d0… ragelink 5249 },
afe42d0… ragelink 5250
afe42d0… ragelink 5251 fix: function( originalEvent ) {
afe42d0… ragelink 5252 return originalEvent[ jQuery.expando ] ?
afe42d0… ragelink 5253 originalEvent :
afe42d0… ragelink 5254 new jQuery.Event( originalEvent );
afe42d0… ragelink 5255 },
afe42d0… ragelink 5256
afe42d0… ragelink 5257 special: {
afe42d0… ragelink 5258 load: {
afe42d0… ragelink 5259
afe42d0… ragelink 5260 // Prevent triggered image.load events from bubbling to window.load
afe42d0… ragelink 5261 noBubble: true
afe42d0… ragelink 5262 },
afe42d0… ragelink 5263 click: {
afe42d0… ragelink 5264
afe42d0… ragelink 5265 // Utilize native event to ensure correct state for checkable inputs
afe42d0… ragelink 5266 setup: function( data ) {
afe42d0… ragelink 5267
afe42d0… ragelink 5268 // For mutual compressibility with _default, replace `this` access with a local var.
afe42d0… ragelink 5269 // `|| data` is dead code meant only to preserve the variable through minification.
afe42d0… ragelink 5270 var el = this || data;
afe42d0… ragelink 5271
afe42d0… ragelink 5272 // Claim the first handler
afe42d0… ragelink 5273 if ( rcheckableType.test( el.type ) &&
afe42d0… ragelink 5274 el.click && nodeName( el, "input" ) ) {
afe42d0… ragelink 5275
afe42d0… ragelink 5276 // dataPriv.set( el, "click", ... )
afe42d0… ragelink 5277 leverageNative( el, "click", true );
afe42d0… ragelink 5278 }
afe42d0… ragelink 5279
afe42d0… ragelink 5280 // Return false to allow normal processing in the caller
afe42d0… ragelink 5281 return false;
afe42d0… ragelink 5282 },
afe42d0… ragelink 5283 trigger: function( data ) {
afe42d0… ragelink 5284
afe42d0… ragelink 5285 // For mutual compressibility with _default, replace `this` access with a local var.
afe42d0… ragelink 5286 // `|| data` is dead code meant only to preserve the variable through minification.
afe42d0… ragelink 5287 var el = this || data;
afe42d0… ragelink 5288
afe42d0… ragelink 5289 // Force setup before triggering a click
afe42d0… ragelink 5290 if ( rcheckableType.test( el.type ) &&
afe42d0… ragelink 5291 el.click && nodeName( el, "input" ) ) {
afe42d0… ragelink 5292
afe42d0… ragelink 5293 leverageNative( el, "click" );
afe42d0… ragelink 5294 }
afe42d0… ragelink 5295
afe42d0… ragelink 5296 // Return non-false to allow normal event-path propagation
afe42d0… ragelink 5297 return true;
afe42d0… ragelink 5298 },
afe42d0… ragelink 5299
afe42d0… ragelink 5300 // For cross-browser consistency, suppress native .click() on links
afe42d0… ragelink 5301 // Also prevent it if we're currently inside a leveraged native-event stack
afe42d0… ragelink 5302 _default: function( event ) {
afe42d0… ragelink 5303 var target = event.target;
afe42d0… ragelink 5304 return rcheckableType.test( target.type ) &&
afe42d0… ragelink 5305 target.click && nodeName( target, "input" ) &&
afe42d0… ragelink 5306 dataPriv.get( target, "click" ) ||
afe42d0… ragelink 5307 nodeName( target, "a" );
afe42d0… ragelink 5308 }
afe42d0… ragelink 5309 },
afe42d0… ragelink 5310
afe42d0… ragelink 5311 beforeunload: {
afe42d0… ragelink 5312 postDispatch: function( event ) {
afe42d0… ragelink 5313
afe42d0… ragelink 5314 // Support: Firefox 20+
afe42d0… ragelink 5315 // Firefox doesn't alert if the returnValue field is not set.
afe42d0… ragelink 5316 if ( event.result !== undefined && event.originalEvent ) {
afe42d0… ragelink 5317 event.originalEvent.returnValue = event.result;
afe42d0… ragelink 5318 }
afe42d0… ragelink 5319 }
afe42d0… ragelink 5320 }
afe42d0… ragelink 5321 }
afe42d0… ragelink 5322 };
afe42d0… ragelink 5323
afe42d0… ragelink 5324 // Ensure the presence of an event listener that handles manually-triggered
afe42d0… ragelink 5325 // synthetic events by interrupting progress until reinvoked in response to
afe42d0… ragelink 5326 // *native* events that it fires directly, ensuring that state changes have
afe42d0… ragelink 5327 // already occurred before other listeners are invoked.
afe42d0… ragelink 5328 function leverageNative( el, type, isSetup ) {
afe42d0… ragelink 5329
afe42d0… ragelink 5330 // Missing `isSetup` indicates a trigger call, which must force setup through jQuery.event.add
afe42d0… ragelink 5331 if ( !isSetup ) {
afe42d0… ragelink 5332 if ( dataPriv.get( el, type ) === undefined ) {
afe42d0… ragelink 5333 jQuery.event.add( el, type, returnTrue );
afe42d0… ragelink 5334 }
afe42d0… ragelink 5335 return;
afe42d0… ragelink 5336 }
afe42d0… ragelink 5337
afe42d0… ragelink 5338 // Register the controller as a special universal handler for all event namespaces
afe42d0… ragelink 5339 dataPriv.set( el, type, false );
afe42d0… ragelink 5340 jQuery.event.add( el, type, {
afe42d0… ragelink 5341 namespace: false,
afe42d0… ragelink 5342 handler: function( event ) {
afe42d0… ragelink 5343 var result,
afe42d0… ragelink 5344 saved = dataPriv.get( this, type );
afe42d0… ragelink 5345
afe42d0… ragelink 5346 if ( ( event.isTrigger & 1 ) && this[ type ] ) {
afe42d0… ragelink 5347
afe42d0… ragelink 5348 // Interrupt processing of the outer synthetic .trigger()ed event
afe42d0… ragelink 5349 if ( !saved ) {
afe42d0… ragelink 5350
afe42d0… ragelink 5351 // Store arguments for use when handling the inner native event
afe42d0… ragelink 5352 // There will always be at least one argument (an event object), so this array
afe42d0… ragelink 5353 // will not be confused with a leftover capture object.
afe42d0… ragelink 5354 saved = slice.call( arguments );
afe42d0… ragelink 5355 dataPriv.set( this, type, saved );
afe42d0… ragelink 5356
afe42d0… ragelink 5357 // Trigger the native event and capture its result
afe42d0… ragelink 5358 this[ type ]();
afe42d0… ragelink 5359 result = dataPriv.get( this, type );
afe42d0… ragelink 5360 dataPriv.set( this, type, false );
afe42d0… ragelink 5361
afe42d0… ragelink 5362 if ( saved !== result ) {
afe42d0… ragelink 5363
afe42d0… ragelink 5364 // Cancel the outer synthetic event
afe42d0… ragelink 5365 event.stopImmediatePropagation();
afe42d0… ragelink 5366 event.preventDefault();
afe42d0… ragelink 5367
afe42d0… ragelink 5368 return result;
afe42d0… ragelink 5369 }
afe42d0… ragelink 5370
afe42d0… ragelink 5371 // If this is an inner synthetic event for an event with a bubbling surrogate
afe42d0… ragelink 5372 // (focus or blur), assume that the surrogate already propagated from triggering
afe42d0… ragelink 5373 // the native event and prevent that from happening again here.
afe42d0… ragelink 5374 // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the
afe42d0… ragelink 5375 // bubbling surrogate propagates *after* the non-bubbling base), but that seems
afe42d0… ragelink 5376 // less bad than duplication.
afe42d0… ragelink 5377 } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) {
afe42d0… ragelink 5378 event.stopPropagation();
afe42d0… ragelink 5379 }
afe42d0… ragelink 5380
afe42d0… ragelink 5381 // If this is a native event triggered above, everything is now in order
afe42d0… ragelink 5382 // Fire an inner synthetic event with the original arguments
afe42d0… ragelink 5383 } else if ( saved ) {
afe42d0… ragelink 5384
afe42d0… ragelink 5385 // ...and capture the result
afe42d0… ragelink 5386 dataPriv.set( this, type, jQuery.event.trigger(
afe42d0… ragelink 5387 saved[ 0 ],
afe42d0… ragelink 5388 saved.slice( 1 ),
afe42d0… ragelink 5389 this
afe42d0… ragelink 5390 ) );
afe42d0… ragelink 5391
afe42d0… ragelink 5392 // Abort handling of the native event by all jQuery handlers while allowing
afe42d0… ragelink 5393 // native handlers on the same element to run. On target, this is achieved
afe42d0… ragelink 5394 // by stopping immediate propagation just on the jQuery event. However,
afe42d0… ragelink 5395 // the native event is re-wrapped by a jQuery one on each level of the
afe42d0… ragelink 5396 // propagation so the only way to stop it for jQuery is to stop it for
afe42d0… ragelink 5397 // everyone via native `stopPropagation()`. This is not a problem for
afe42d0… ragelink 5398 // focus/blur which don't bubble, but it does also stop click on checkboxes
afe42d0… ragelink 5399 // and radios. We accept this limitation.
afe42d0… ragelink 5400 event.stopPropagation();
afe42d0… ragelink 5401 event.isImmediatePropagationStopped = returnTrue;
afe42d0… ragelink 5402 }
afe42d0… ragelink 5403 }
afe42d0… ragelink 5404 } );
afe42d0… ragelink 5405 }
afe42d0… ragelink 5406
afe42d0… ragelink 5407 jQuery.removeEvent = function( elem, type, handle ) {
afe42d0… ragelink 5408
afe42d0… ragelink 5409 // This "if" is needed for plain objects
afe42d0… ragelink 5410 if ( elem.removeEventListener ) {
afe42d0… ragelink 5411 elem.removeEventListener( type, handle );
afe42d0… ragelink 5412 }
afe42d0… ragelink 5413 };
afe42d0… ragelink 5414
afe42d0… ragelink 5415 jQuery.Event = function( src, props ) {
afe42d0… ragelink 5416
afe42d0… ragelink 5417 // Allow instantiation without the 'new' keyword
afe42d0… ragelink 5418 if ( !( this instanceof jQuery.Event ) ) {
afe42d0… ragelink 5419 return new jQuery.Event( src, props );
afe42d0… ragelink 5420 }
afe42d0… ragelink 5421
afe42d0… ragelink 5422 // Event object
afe42d0… ragelink 5423 if ( src && src.type ) {
afe42d0… ragelink 5424 this.originalEvent = src;
afe42d0… ragelink 5425 this.type = src.type;
afe42d0… ragelink 5426
afe42d0… ragelink 5427 // Events bubbling up the document may have been marked as prevented
afe42d0… ragelink 5428 // by a handler lower down the tree; reflect the correct value.
afe42d0… ragelink 5429 this.isDefaultPrevented = src.defaultPrevented ||
afe42d0… ragelink 5430 src.defaultPrevented === undefined &&
afe42d0… ragelink 5431
afe42d0… ragelink 5432 // Support: Android <=2.3 only
afe42d0… ragelink 5433 src.returnValue === false ?
afe42d0… ragelink 5434 returnTrue :
afe42d0… ragelink 5435 returnFalse;
afe42d0… ragelink 5436
afe42d0… ragelink 5437 // Create target properties
afe42d0… ragelink 5438 // Support: Safari <=6 - 7 only
afe42d0… ragelink 5439 // Target should not be a text node (trac-504, trac-13143)
afe42d0… ragelink 5440 this.target = ( src.target && src.target.nodeType === 3 ) ?
afe42d0… ragelink 5441 src.target.parentNode :
afe42d0… ragelink 5442 src.target;
afe42d0… ragelink 5443
afe42d0… ragelink 5444 this.currentTarget = src.currentTarget;
afe42d0… ragelink 5445 this.relatedTarget = src.relatedTarget;
afe42d0… ragelink 5446
afe42d0… ragelink 5447 // Event type
afe42d0… ragelink 5448 } else {
afe42d0… ragelink 5449 this.type = src;
afe42d0… ragelink 5450 }
afe42d0… ragelink 5451
afe42d0… ragelink 5452 // Put explicitly provided properties onto the event object
afe42d0… ragelink 5453 if ( props ) {
afe42d0… ragelink 5454 jQuery.extend( this, props );
afe42d0… ragelink 5455 }
afe42d0… ragelink 5456
afe42d0… ragelink 5457 // Create a timestamp if incoming event doesn't have one
afe42d0… ragelink 5458 this.timeStamp = src && src.timeStamp || Date.now();
afe42d0… ragelink 5459
afe42d0… ragelink 5460 // Mark it as fixed
afe42d0… ragelink 5461 this[ jQuery.expando ] = true;
afe42d0… ragelink 5462 };
afe42d0… ragelink 5463
afe42d0… ragelink 5464 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
afe42d0… ragelink 5465 // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
afe42d0… ragelink 5466 jQuery.Event.prototype = {
afe42d0… ragelink 5467 constructor: jQuery.Event,
afe42d0… ragelink 5468 isDefaultPrevented: returnFalse,
afe42d0… ragelink 5469 isPropagationStopped: returnFalse,
afe42d0… ragelink 5470 isImmediatePropagationStopped: returnFalse,
afe42d0… ragelink 5471 isSimulated: false,
afe42d0… ragelink 5472
afe42d0… ragelink 5473 preventDefault: function() {
afe42d0… ragelink 5474 var e = this.originalEvent;
afe42d0… ragelink 5475
afe42d0… ragelink 5476 this.isDefaultPrevented = returnTrue;
afe42d0… ragelink 5477
afe42d0… ragelink 5478 if ( e && !this.isSimulated ) {
afe42d0… ragelink 5479 e.preventDefault();
afe42d0… ragelink 5480 }
afe42d0… ragelink 5481 },
afe42d0… ragelink 5482 stopPropagation: function() {
afe42d0… ragelink 5483 var e = this.originalEvent;
afe42d0… ragelink 5484
afe42d0… ragelink 5485 this.isPropagationStopped = returnTrue;
afe42d0… ragelink 5486
afe42d0… ragelink 5487 if ( e && !this.isSimulated ) {
afe42d0… ragelink 5488 e.stopPropagation();
afe42d0… ragelink 5489 }
afe42d0… ragelink 5490 },
afe42d0… ragelink 5491 stopImmediatePropagation: function() {
afe42d0… ragelink 5492 var e = this.originalEvent;
afe42d0… ragelink 5493
afe42d0… ragelink 5494 this.isImmediatePropagationStopped = returnTrue;
afe42d0… ragelink 5495
afe42d0… ragelink 5496 if ( e && !this.isSimulated ) {
afe42d0… ragelink 5497 e.stopImmediatePropagation();
afe42d0… ragelink 5498 }
afe42d0… ragelink 5499
afe42d0… ragelink 5500 this.stopPropagation();
afe42d0… ragelink 5501 }
afe42d0… ragelink 5502 };
afe42d0… ragelink 5503
afe42d0… ragelink 5504 // Includes all common event props including KeyEvent and MouseEvent specific props
afe42d0… ragelink 5505 jQuery.each( {
afe42d0… ragelink 5506 altKey: true,
afe42d0… ragelink 5507 bubbles: true,
afe42d0… ragelink 5508 cancelable: true,
afe42d0… ragelink 5509 changedTouches: true,
afe42d0… ragelink 5510 ctrlKey: true,
afe42d0… ragelink 5511 detail: true,
afe42d0… ragelink 5512 eventPhase: true,
afe42d0… ragelink 5513 metaKey: true,
afe42d0… ragelink 5514 pageX: true,
afe42d0… ragelink 5515 pageY: true,
afe42d0… ragelink 5516 shiftKey: true,
afe42d0… ragelink 5517 view: true,
afe42d0… ragelink 5518 "char": true,
afe42d0… ragelink 5519 code: true,
afe42d0… ragelink 5520 charCode: true,
afe42d0… ragelink 5521 key: true,
afe42d0… ragelink 5522 keyCode: true,
afe42d0… ragelink 5523 button: true,
afe42d0… ragelink 5524 buttons: true,
afe42d0… ragelink 5525 clientX: true,
afe42d0… ragelink 5526 clientY: true,
afe42d0… ragelink 5527 offsetX: true,
afe42d0… ragelink 5528 offsetY: true,
afe42d0… ragelink 5529 pointerId: true,
afe42d0… ragelink 5530 pointerType: true,
afe42d0… ragelink 5531 screenX: true,
afe42d0… ragelink 5532 screenY: true,
afe42d0… ragelink 5533 targetTouches: true,
afe42d0… ragelink 5534 toElement: true,
afe42d0… ragelink 5535 touches: true,
afe42d0… ragelink 5536 which: true
afe42d0… ragelink 5537 }, jQuery.event.addProp );
afe42d0… ragelink 5538
afe42d0… ragelink 5539 jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) {
afe42d0… ragelink 5540
afe42d0… ragelink 5541 function focusMappedHandler( nativeEvent ) {
afe42d0… ragelink 5542 if ( document.documentMode ) {
afe42d0… ragelink 5543
afe42d0… ragelink 5544 // Support: IE 11+
afe42d0… ragelink 5545 // Attach a single focusin/focusout handler on the document while someone wants
afe42d0… ragelink 5546 // focus/blur. This is because the former are synchronous in IE while the latter
afe42d0… ragelink 5547 // are async. In other browsers, all those handlers are invoked synchronously.
afe42d0… ragelink 5548
afe42d0… ragelink 5549 // `handle` from private data would already wrap the event, but we need
afe42d0… ragelink 5550 // to change the `type` here.
afe42d0… ragelink 5551 var handle = dataPriv.get( this, "handle" ),
afe42d0… ragelink 5552 event = jQuery.event.fix( nativeEvent );
afe42d0… ragelink 5553 event.type = nativeEvent.type === "focusin" ? "focus" : "blur";
afe42d0… ragelink 5554 event.isSimulated = true;
afe42d0… ragelink 5555
afe42d0… ragelink 5556 // First, handle focusin/focusout
afe42d0… ragelink 5557 handle( nativeEvent );
afe42d0… ragelink 5558
afe42d0… ragelink 5559 // ...then, handle focus/blur
afe42d0… ragelink 5560 //
afe42d0… ragelink 5561 // focus/blur don't bubble while focusin/focusout do; simulate the former by only
afe42d0… ragelink 5562 // invoking the handler at the lower level.
afe42d0… ragelink 5563 if ( event.target === event.currentTarget ) {
afe42d0… ragelink 5564
afe42d0… ragelink 5565 // The setup part calls `leverageNative`, which, in turn, calls
afe42d0… ragelink 5566 // `jQuery.event.add`, so event handle will already have been set
afe42d0… ragelink 5567 // by this point.
afe42d0… ragelink 5568 handle( event );
afe42d0… ragelink 5569 }
afe42d0… ragelink 5570 } else {
afe42d0… ragelink 5571
afe42d0… ragelink 5572 // For non-IE browsers, attach a single capturing handler on the document
afe42d0… ragelink 5573 // while someone wants focusin/focusout.
afe42d0… ragelink 5574 jQuery.event.simulate( delegateType, nativeEvent.target,
afe42d0… ragelink 5575 jQuery.event.fix( nativeEvent ) );
afe42d0… ragelink 5576 }
afe42d0… ragelink 5577 }
afe42d0… ragelink 5578
afe42d0… ragelink 5579 jQuery.event.special[ type ] = {
afe42d0… ragelink 5580
afe42d0… ragelink 5581 // Utilize native event if possible so blur/focus sequence is correct
afe42d0… ragelink 5582 setup: function() {
afe42d0… ragelink 5583
afe42d0… ragelink 5584 var attaches;
afe42d0… ragelink 5585
afe42d0… ragelink 5586 // Claim the first handler
afe42d0… ragelink 5587 // dataPriv.set( this, "focus", ... )
afe42d0… ragelink 5588 // dataPriv.set( this, "blur", ... )
afe42d0… ragelink 5589 leverageNative( this, type, true );
afe42d0… ragelink 5590
afe42d0… ragelink 5591 if ( document.documentMode ) {
afe42d0… ragelink 5592
afe42d0… ragelink 5593 // Support: IE 9 - 11+
afe42d0… ragelink 5594 // We use the same native handler for focusin & focus (and focusout & blur)
afe42d0… ragelink 5595 // so we need to coordinate setup & teardown parts between those events.
afe42d0… ragelink 5596 // Use `delegateType` as the key as `type` is already used by `leverageNative`.
afe42d0… ragelink 5597 attaches = dataPriv.get( this, delegateType );
afe42d0… ragelink 5598 if ( !attaches ) {
afe42d0… ragelink 5599 this.addEventListener( delegateType, focusMappedHandler );
afe42d0… ragelink 5600 }
afe42d0… ragelink 5601 dataPriv.set( this, delegateType, ( attaches || 0 ) + 1 );
afe42d0… ragelink 5602 } else {
afe42d0… ragelink 5603
afe42d0… ragelink 5604 // Return false to allow normal processing in the caller
afe42d0… ragelink 5605 return false;
afe42d0… ragelink 5606 }
afe42d0… ragelink 5607 },
afe42d0… ragelink 5608 trigger: function() {
afe42d0… ragelink 5609
afe42d0… ragelink 5610 // Force setup before trigger
afe42d0… ragelink 5611 leverageNative( this, type );
afe42d0… ragelink 5612
afe42d0… ragelink 5613 // Return non-false to allow normal event-path propagation
afe42d0… ragelink 5614 return true;
afe42d0… ragelink 5615 },
afe42d0… ragelink 5616
afe42d0… ragelink 5617 teardown: function() {
afe42d0… ragelink 5618 var attaches;
afe42d0… ragelink 5619
afe42d0… ragelink 5620 if ( document.documentMode ) {
afe42d0… ragelink 5621 attaches = dataPriv.get( this, delegateType ) - 1;
afe42d0… ragelink 5622 if ( !attaches ) {
afe42d0… ragelink 5623 this.removeEventListener( delegateType, focusMappedHandler );
afe42d0… ragelink 5624 dataPriv.remove( this, delegateType );
afe42d0… ragelink 5625 } else {
afe42d0… ragelink 5626 dataPriv.set( this, delegateType, attaches );
afe42d0… ragelink 5627 }
afe42d0… ragelink 5628 } else {
afe42d0… ragelink 5629
afe42d0… ragelink 5630 // Return false to indicate standard teardown should be applied
afe42d0… ragelink 5631 return false;
afe42d0… ragelink 5632 }
afe42d0… ragelink 5633 },
afe42d0… ragelink 5634
afe42d0… ragelink 5635 // Suppress native focus or blur if we're currently inside
afe42d0… ragelink 5636 // a leveraged native-event stack
afe42d0… ragelink 5637 _default: function( event ) {
afe42d0… ragelink 5638 return dataPriv.get( event.target, type );
afe42d0… ragelink 5639 },
afe42d0… ragelink 5640
afe42d0… ragelink 5641 delegateType: delegateType
afe42d0… ragelink 5642 };
afe42d0… ragelink 5643
afe42d0… ragelink 5644 // Support: Firefox <=44
afe42d0… ragelink 5645 // Firefox doesn't have focus(in | out) events
afe42d0… ragelink 5646 // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
afe42d0… ragelink 5647 //
afe42d0… ragelink 5648 // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
afe42d0… ragelink 5649 // focus(in | out) events fire after focus & blur events,
afe42d0… ragelink 5650 // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
afe42d0… ragelink 5651 // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
afe42d0… ragelink 5652 //
afe42d0… ragelink 5653 // Support: IE 9 - 11+
afe42d0… ragelink 5654 // To preserve relative focusin/focus & focusout/blur event order guaranteed on the 3.x branch,
afe42d0… ragelink 5655 // attach a single handler for both events in IE.
afe42d0… ragelink 5656 jQuery.event.special[ delegateType ] = {
afe42d0… ragelink 5657 setup: function() {
afe42d0… ragelink 5658
afe42d0… ragelink 5659 // Handle: regular nodes (via `this.ownerDocument`), window
afe42d0… ragelink 5660 // (via `this.document`) & document (via `this`).
afe42d0… ragelink 5661 var doc = this.ownerDocument || this.document || this,
afe42d0… ragelink 5662 dataHolder = document.documentMode ? this : doc,
afe42d0… ragelink 5663 attaches = dataPriv.get( dataHolder, delegateType );
afe42d0… ragelink 5664
afe42d0… ragelink 5665 // Support: IE 9 - 11+
afe42d0… ragelink 5666 // We use the same native handler for focusin & focus (and focusout & blur)
afe42d0… ragelink 5667 // so we need to coordinate setup & teardown parts between those events.
afe42d0… ragelink 5668 // Use `delegateType` as the key as `type` is already used by `leverageNative`.
afe42d0… ragelink 5669 if ( !attaches ) {
afe42d0… ragelink 5670 if ( document.documentMode ) {
afe42d0… ragelink 5671 this.addEventListener( delegateType, focusMappedHandler );
afe42d0… ragelink 5672 } else {
afe42d0… ragelink 5673 doc.addEventListener( type, focusMappedHandler, true );
afe42d0… ragelink 5674 }
afe42d0… ragelink 5675 }
afe42d0… ragelink 5676 dataPriv.set( dataHolder, delegateType, ( attaches || 0 ) + 1 );
afe42d0… ragelink 5677 },
afe42d0… ragelink 5678 teardown: function() {
afe42d0… ragelink 5679 var doc = this.ownerDocument || this.document || this,
afe42d0… ragelink 5680 dataHolder = document.documentMode ? this : doc,
afe42d0… ragelink 5681 attaches = dataPriv.get( dataHolder, delegateType ) - 1;
afe42d0… ragelink 5682
afe42d0… ragelink 5683 if ( !attaches ) {
afe42d0… ragelink 5684 if ( document.documentMode ) {
afe42d0… ragelink 5685 this.removeEventListener( delegateType, focusMappedHandler );
afe42d0… ragelink 5686 } else {
afe42d0… ragelink 5687 doc.removeEventListener( type, focusMappedHandler, true );
afe42d0… ragelink 5688 }
afe42d0… ragelink 5689 dataPriv.remove( dataHolder, delegateType );
afe42d0… ragelink 5690 } else {
afe42d0… ragelink 5691 dataPriv.set( dataHolder, delegateType, attaches );
afe42d0… ragelink 5692 }
afe42d0… ragelink 5693 }
afe42d0… ragelink 5694 };
afe42d0… ragelink 5695 } );
afe42d0… ragelink 5696
afe42d0… ragelink 5697 // Create mouseenter/leave events using mouseover/out and event-time checks
afe42d0… ragelink 5698 // so that event delegation works in jQuery.
afe42d0… ragelink 5699 // Do the same for pointerenter/pointerleave and pointerover/pointerout
afe42d0… ragelink 5700 //
afe42d0… ragelink 5701 // Support: Safari 7 only
afe42d0… ragelink 5702 // Safari sends mouseenter too often; see:
afe42d0… ragelink 5703 // https://bugs.chromium.org/p/chromium/issues/detail?id=470258
afe42d0… ragelink 5704 // for the description of the bug (it existed in older Chrome versions as well).
afe42d0… ragelink 5705 jQuery.each( {
afe42d0… ragelink 5706 mouseenter: "mouseover",
afe42d0… ragelink 5707 mouseleave: "mouseout",
afe42d0… ragelink 5708 pointerenter: "pointerover",
afe42d0… ragelink 5709 pointerleave: "pointerout"
afe42d0… ragelink 5710 }, function( orig, fix ) {
afe42d0… ragelink 5711 jQuery.event.special[ orig ] = {
afe42d0… ragelink 5712 delegateType: fix,
afe42d0… ragelink 5713 bindType: fix,
afe42d0… ragelink 5714
afe42d0… ragelink 5715 handle: function( event ) {
afe42d0… ragelink 5716 var ret,
afe42d0… ragelink 5717 target = this,
afe42d0… ragelink 5718 related = event.relatedTarget,
afe42d0… ragelink 5719 handleObj = event.handleObj;
afe42d0… ragelink 5720
afe42d0… ragelink 5721 // For mouseenter/leave call the handler if related is outside the target.
afe42d0… ragelink 5722 // NB: No relatedTarget if the mouse left/entered the browser window
afe42d0… ragelink 5723 if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
afe42d0… ragelink 5724 event.type = handleObj.origType;
afe42d0… ragelink 5725 ret = handleObj.handler.apply( this, arguments );
afe42d0… ragelink 5726 event.type = fix;
afe42d0… ragelink 5727 }
afe42d0… ragelink 5728 return ret;
afe42d0… ragelink 5729 }
afe42d0… ragelink 5730 };
afe42d0… ragelink 5731 } );
afe42d0… ragelink 5732
afe42d0… ragelink 5733 jQuery.fn.extend( {
afe42d0… ragelink 5734
afe42d0… ragelink 5735 on: function( types, selector, data, fn ) {
afe42d0… ragelink 5736 return on( this, types, selector, data, fn );
afe42d0… ragelink 5737 },
afe42d0… ragelink 5738 one: function( types, selector, data, fn ) {
afe42d0… ragelink 5739 return on( this, types, selector, data, fn, 1 );
afe42d0… ragelink 5740 },
afe42d0… ragelink 5741 off: function( types, selector, fn ) {
afe42d0… ragelink 5742 var handleObj, type;
afe42d0… ragelink 5743 if ( types && types.preventDefault && types.handleObj ) {
afe42d0… ragelink 5744
afe42d0… ragelink 5745 // ( event ) dispatched jQuery.Event
afe42d0… ragelink 5746 handleObj = types.handleObj;
afe42d0… ragelink 5747 jQuery( types.delegateTarget ).off(
afe42d0… ragelink 5748 handleObj.namespace ?
afe42d0… ragelink 5749 handleObj.origType + "." + handleObj.namespace :
afe42d0… ragelink 5750 handleObj.origType,
afe42d0… ragelink 5751 handleObj.selector,
afe42d0… ragelink 5752 handleObj.handler
afe42d0… ragelink 5753 );
afe42d0… ragelink 5754 return this;
afe42d0… ragelink 5755 }
afe42d0… ragelink 5756 if ( typeof types === "object" ) {
afe42d0… ragelink 5757
afe42d0… ragelink 5758 // ( types-object [, selector] )
afe42d0… ragelink 5759 for ( type in types ) {
afe42d0… ragelink 5760 this.off( type, selector, types[ type ] );
afe42d0… ragelink 5761 }
afe42d0… ragelink 5762 return this;
afe42d0… ragelink 5763 }
afe42d0… ragelink 5764 if ( selector === false || typeof selector === "function" ) {
afe42d0… ragelink 5765
afe42d0… ragelink 5766 // ( types [, fn] )
afe42d0… ragelink 5767 fn = selector;
afe42d0… ragelink 5768 selector = undefined;
afe42d0… ragelink 5769 }
afe42d0… ragelink 5770 if ( fn === false ) {
afe42d0… ragelink 5771 fn = returnFalse;
afe42d0… ragelink 5772 }
afe42d0… ragelink 5773 return this.each( function() {
afe42d0… ragelink 5774 jQuery.event.remove( this, types, fn, selector );
afe42d0… ragelink 5775 } );
afe42d0… ragelink 5776 }
afe42d0… ragelink 5777 } );
afe42d0… ragelink 5778
afe42d0… ragelink 5779
afe42d0… ragelink 5780 var
afe42d0… ragelink 5781
afe42d0… ragelink 5782 // Support: IE <=10 - 11, Edge 12 - 13 only
afe42d0… ragelink 5783 // In IE/Edge using regex groups here causes severe slowdowns.
afe42d0… ragelink 5784 // See https://connect.microsoft.com/IE/feedback/details/1736512/
afe42d0… ragelink 5785 rnoInnerhtml = /<script|<style|<link/i,
afe42d0… ragelink 5786
afe42d0… ragelink 5787 // checked="checked" or checked
afe42d0… ragelink 5788 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
afe42d0… ragelink 5789
afe42d0… ragelink 5790 rcleanScript = /^\s*<!\[CDATA\[|\]\]>\s*$/g;
afe42d0… ragelink 5791
afe42d0… ragelink 5792 // Prefer a tbody over its parent table for containing new rows
afe42d0… ragelink 5793 function manipulationTarget( elem, content ) {
afe42d0… ragelink 5794 if ( nodeName( elem, "table" ) &&
afe42d0… ragelink 5795 nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
afe42d0… ragelink 5796
afe42d0… ragelink 5797 return jQuery( elem ).children( "tbody" )[ 0 ] || elem;
afe42d0… ragelink 5798 }
afe42d0… ragelink 5799
afe42d0… ragelink 5800 return elem;
afe42d0… ragelink 5801 }
afe42d0… ragelink 5802
afe42d0… ragelink 5803 // Replace/restore the type attribute of script elements for safe DOM manipulation
afe42d0… ragelink 5804 function disableScript( elem ) {
afe42d0… ragelink 5805 elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
afe42d0… ragelink 5806 return elem;
afe42d0… ragelink 5807 }
afe42d0… ragelink 5808 function restoreScript( elem ) {
afe42d0… ragelink 5809 if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) {
afe42d0… ragelink 5810 elem.type = elem.type.slice( 5 );
afe42d0… ragelink 5811 } else {
afe42d0… ragelink 5812 elem.removeAttribute( "type" );
afe42d0… ragelink 5813 }
afe42d0… ragelink 5814
afe42d0… ragelink 5815 return elem;
afe42d0… ragelink 5816 }
afe42d0… ragelink 5817
afe42d0… ragelink 5818 function cloneCopyEvent( src, dest ) {
afe42d0… ragelink 5819 var i, l, type, pdataOld, udataOld, udataCur, events;
afe42d0… ragelink 5820
afe42d0… ragelink 5821 if ( dest.nodeType !== 1 ) {
afe42d0… ragelink 5822 return;
afe42d0… ragelink 5823 }
afe42d0… ragelink 5824
afe42d0… ragelink 5825 // 1. Copy private data: events, handlers, etc.
afe42d0… ragelink 5826 if ( dataPriv.hasData( src ) ) {
afe42d0… ragelink 5827 pdataOld = dataPriv.get( src );
afe42d0… ragelink 5828 events = pdataOld.events;
afe42d0… ragelink 5829
afe42d0… ragelink 5830 if ( events ) {
afe42d0… ragelink 5831 dataPriv.remove( dest, "handle events" );
afe42d0… ragelink 5832
afe42d0… ragelink 5833 for ( type in events ) {
afe42d0… ragelink 5834 for ( i = 0, l = events[ type ].length; i < l; i++ ) {
afe42d0… ragelink 5835 jQuery.event.add( dest, type, events[ type ][ i ] );
afe42d0… ragelink 5836 }
afe42d0… ragelink 5837 }
afe42d0… ragelink 5838 }
afe42d0… ragelink 5839 }
afe42d0… ragelink 5840
afe42d0… ragelink 5841 // 2. Copy user data
afe42d0… ragelink 5842 if ( dataUser.hasData( src ) ) {
afe42d0… ragelink 5843 udataOld = dataUser.access( src );
afe42d0… ragelink 5844 udataCur = jQuery.extend( {}, udataOld );
afe42d0… ragelink 5845
afe42d0… ragelink 5846 dataUser.set( dest, udataCur );
afe42d0… ragelink 5847 }
afe42d0… ragelink 5848 }
afe42d0… ragelink 5849
afe42d0… ragelink 5850 // Fix IE bugs, see support tests
afe42d0… ragelink 5851 function fixInput( src, dest ) {
afe42d0… ragelink 5852 var nodeName = dest.nodeName.toLowerCase();
afe42d0… ragelink 5853
afe42d0… ragelink 5854 // Fails to persist the checked state of a cloned checkbox or radio button.
afe42d0… ragelink 5855 if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
afe42d0… ragelink 5856 dest.checked = src.checked;
afe42d0… ragelink 5857
afe42d0… ragelink 5858 // Fails to return the selected option to the default selected state when cloning options
afe42d0… ragelink 5859 } else if ( nodeName === "input" || nodeName === "textarea" ) {
afe42d0… ragelink 5860 dest.defaultValue = src.defaultValue;
afe42d0… ragelink 5861 }
afe42d0… ragelink 5862 }
afe42d0… ragelink 5863
afe42d0… ragelink 5864 function domManip( collection, args, callback, ignored ) {
afe42d0… ragelink 5865
afe42d0… ragelink 5866 // Flatten any nested arrays
afe42d0… ragelink 5867 args = flat( args );
afe42d0… ragelink 5868
afe42d0… ragelink 5869 var fragment, first, scripts, hasScripts, node, doc,
afe42d0… ragelink 5870 i = 0,
afe42d0… ragelink 5871 l = collection.length,
afe42d0… ragelink 5872 iNoClone = l - 1,
afe42d0… ragelink 5873 value = args[ 0 ],
afe42d0… ragelink 5874 valueIsFunction = isFunction( value );
afe42d0… ragelink 5875
afe42d0… ragelink 5876 // We can't cloneNode fragments that contain checked, in WebKit
afe42d0… ragelink 5877 if ( valueIsFunction ||
afe42d0… ragelink 5878 ( l > 1 && typeof value === "string" &&
afe42d0… ragelink 5879 !support.checkClone && rchecked.test( value ) ) ) {
afe42d0… ragelink 5880 return collection.each( function( index ) {
afe42d0… ragelink 5881 var self = collection.eq( index );
afe42d0… ragelink 5882 if ( valueIsFunction ) {
afe42d0… ragelink 5883 args[ 0 ] = value.call( this, index, self.html() );
afe42d0… ragelink 5884 }
afe42d0… ragelink 5885 domManip( self, args, callback, ignored );
afe42d0… ragelink 5886 } );
afe42d0… ragelink 5887 }
afe42d0… ragelink 5888
afe42d0… ragelink 5889 if ( l ) {
afe42d0… ragelink 5890 fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
afe42d0… ragelink 5891 first = fragment.firstChild;
afe42d0… ragelink 5892
afe42d0… ragelink 5893 if ( fragment.childNodes.length === 1 ) {
afe42d0… ragelink 5894 fragment = first;
afe42d0… ragelink 5895 }
afe42d0… ragelink 5896
afe42d0… ragelink 5897 // Require either new content or an interest in ignored elements to invoke the callback
afe42d0… ragelink 5898 if ( first || ignored ) {
afe42d0… ragelink 5899 scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
afe42d0… ragelink 5900 hasScripts = scripts.length;
afe42d0… ragelink 5901
afe42d0… ragelink 5902 // Use the original fragment for the last item
afe42d0… ragelink 5903 // instead of the first because it can end up
afe42d0… ragelink 5904 // being emptied incorrectly in certain situations (trac-8070).
afe42d0… ragelink 5905 for ( ; i < l; i++ ) {
afe42d0… ragelink 5906 node = fragment;
afe42d0… ragelink 5907
afe42d0… ragelink 5908 if ( i !== iNoClone ) {
afe42d0… ragelink 5909 node = jQuery.clone( node, true, true );
afe42d0… ragelink 5910
afe42d0… ragelink 5911 // Keep references to cloned scripts for later restoration
afe42d0… ragelink 5912 if ( hasScripts ) {
afe42d0… ragelink 5913
afe42d0… ragelink 5914 // Support: Android <=4.0 only, PhantomJS 1 only
afe42d0… ragelink 5915 // push.apply(_, arraylike) throws on ancient WebKit
afe42d0… ragelink 5916 jQuery.merge( scripts, getAll( node, "script" ) );
afe42d0… ragelink 5917 }
afe42d0… ragelink 5918 }
afe42d0… ragelink 5919
afe42d0… ragelink 5920 callback.call( collection[ i ], node, i );
afe42d0… ragelink 5921 }
afe42d0… ragelink 5922
afe42d0… ragelink 5923 if ( hasScripts ) {
afe42d0… ragelink 5924 doc = scripts[ scripts.length - 1 ].ownerDocument;
afe42d0… ragelink 5925
afe42d0… ragelink 5926 // Re-enable scripts
afe42d0… ragelink 5927 jQuery.map( scripts, restoreScript );
afe42d0… ragelink 5928
afe42d0… ragelink 5929 // Evaluate executable scripts on first document insertion
afe42d0… ragelink 5930 for ( i = 0; i < hasScripts; i++ ) {
afe42d0… ragelink 5931 node = scripts[ i ];
afe42d0… ragelink 5932 if ( rscriptType.test( node.type || "" ) &&
afe42d0… ragelink 5933 !dataPriv.access( node, "globalEval" ) &&
afe42d0… ragelink 5934 jQuery.contains( doc, node ) ) {
afe42d0… ragelink 5935
afe42d0… ragelink 5936 if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) {
afe42d0… ragelink 5937
afe42d0… ragelink 5938 // Optional AJAX dependency, but won't run scripts if not present
afe42d0… ragelink 5939 if ( jQuery._evalUrl && !node.noModule ) {
afe42d0… ragelink 5940 jQuery._evalUrl( node.src, {
afe42d0… ragelink 5941 nonce: node.nonce || node.getAttribute( "nonce" )
afe42d0… ragelink 5942 }, doc );
afe42d0… ragelink 5943 }
afe42d0… ragelink 5944 } else {
afe42d0… ragelink 5945
afe42d0… ragelink 5946 // Unwrap a CDATA section containing script contents. This shouldn't be
afe42d0… ragelink 5947 // needed as in XML documents they're already not visible when
afe42d0… ragelink 5948 // inspecting element contents and in HTML documents they have no
afe42d0… ragelink 5949 // meaning but we're preserving that logic for backwards compatibility.
afe42d0… ragelink 5950 // This will be removed completely in 4.0. See gh-4904.
afe42d0… ragelink 5951 DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc );
afe42d0… ragelink 5952 }
afe42d0… ragelink 5953 }
afe42d0… ragelink 5954 }
afe42d0… ragelink 5955 }
afe42d0… ragelink 5956 }
afe42d0… ragelink 5957 }
afe42d0… ragelink 5958
afe42d0… ragelink 5959 return collection;
afe42d0… ragelink 5960 }
afe42d0… ragelink 5961
afe42d0… ragelink 5962 function remove( elem, selector, keepData ) {
afe42d0… ragelink 5963 var node,
afe42d0… ragelink 5964 nodes = selector ? jQuery.filter( selector, elem ) : elem,
afe42d0… ragelink 5965 i = 0;
afe42d0… ragelink 5966
afe42d0… ragelink 5967 for ( ; ( node = nodes[ i ] ) != null; i++ ) {
afe42d0… ragelink 5968 if ( !keepData && node.nodeType === 1 ) {
afe42d0… ragelink 5969 jQuery.cleanData( getAll( node ) );
afe42d0… ragelink 5970 }
afe42d0… ragelink 5971
afe42d0… ragelink 5972 if ( node.parentNode ) {
afe42d0… ragelink 5973 if ( keepData && isAttached( node ) ) {
afe42d0… ragelink 5974 setGlobalEval( getAll( node, "script" ) );
afe42d0… ragelink 5975 }
afe42d0… ragelink 5976 node.parentNode.removeChild( node );
afe42d0… ragelink 5977 }
afe42d0… ragelink 5978 }
afe42d0… ragelink 5979
afe42d0… ragelink 5980 return elem;
afe42d0… ragelink 5981 }
afe42d0… ragelink 5982
afe42d0… ragelink 5983 jQuery.extend( {
afe42d0… ragelink 5984 htmlPrefilter: function( html ) {
afe42d0… ragelink 5985 return html;
afe42d0… ragelink 5986 },
afe42d0… ragelink 5987
afe42d0… ragelink 5988 clone: function( elem, dataAndEvents, deepDataAndEvents ) {
afe42d0… ragelink 5989 var i, l, srcElements, destElements,
afe42d0… ragelink 5990 clone = elem.cloneNode( true ),
afe42d0… ragelink 5991 inPage = isAttached( elem );
afe42d0… ragelink 5992
afe42d0… ragelink 5993 // Fix IE cloning issues
afe42d0… ragelink 5994 if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
afe42d0… ragelink 5995 !jQuery.isXMLDoc( elem ) ) {
afe42d0… ragelink 5996
afe42d0… ragelink 5997 // We eschew jQuery#find here for performance reasons:
afe42d0… ragelink 5998 // https://jsperf.com/getall-vs-sizzle/2
afe42d0… ragelink 5999 destElements = getAll( clone );
afe42d0… ragelink 6000 srcElements = getAll( elem );
afe42d0… ragelink 6001
afe42d0… ragelink 6002 for ( i = 0, l = srcElements.length; i < l; i++ ) {
afe42d0… ragelink 6003 fixInput( srcElements[ i ], destElements[ i ] );
afe42d0… ragelink 6004 }
afe42d0… ragelink 6005 }
afe42d0… ragelink 6006
afe42d0… ragelink 6007 // Copy the events from the original to the clone
afe42d0… ragelink 6008 if ( dataAndEvents ) {
afe42d0… ragelink 6009 if ( deepDataAndEvents ) {
afe42d0… ragelink 6010 srcElements = srcElements || getAll( elem );
afe42d0… ragelink 6011 destElements = destElements || getAll( clone );
afe42d0… ragelink 6012
afe42d0… ragelink 6013 for ( i = 0, l = srcElements.length; i < l; i++ ) {
afe42d0… ragelink 6014 cloneCopyEvent( srcElements[ i ], destElements[ i ] );
afe42d0… ragelink 6015 }
afe42d0… ragelink 6016 } else {
afe42d0… ragelink 6017 cloneCopyEvent( elem, clone );
afe42d0… ragelink 6018 }
afe42d0… ragelink 6019 }
afe42d0… ragelink 6020
afe42d0… ragelink 6021 // Preserve script evaluation history
afe42d0… ragelink 6022 destElements = getAll( clone, "script" );
afe42d0… ragelink 6023 if ( destElements.length > 0 ) {
afe42d0… ragelink 6024 setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
afe42d0… ragelink 6025 }
afe42d0… ragelink 6026
afe42d0… ragelink 6027 // Return the cloned set
afe42d0… ragelink 6028 return clone;
afe42d0… ragelink 6029 },
afe42d0… ragelink 6030
afe42d0… ragelink 6031 cleanData: function( elems ) {
afe42d0… ragelink 6032 var data, elem, type,
afe42d0… ragelink 6033 special = jQuery.event.special,
afe42d0… ragelink 6034 i = 0;
afe42d0… ragelink 6035
afe42d0… ragelink 6036 for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {
afe42d0… ragelink 6037 if ( acceptData( elem ) ) {
afe42d0… ragelink 6038 if ( ( data = elem[ dataPriv.expando ] ) ) {
afe42d0… ragelink 6039 if ( data.events ) {
afe42d0… ragelink 6040 for ( type in data.events ) {
afe42d0… ragelink 6041 if ( special[ type ] ) {
afe42d0… ragelink 6042 jQuery.event.remove( elem, type );
afe42d0… ragelink 6043
afe42d0… ragelink 6044 // This is a shortcut to avoid jQuery.event.remove's overhead
afe42d0… ragelink 6045 } else {
afe42d0… ragelink 6046 jQuery.removeEvent( elem, type, data.handle );
afe42d0… ragelink 6047 }
afe42d0… ragelink 6048 }
afe42d0… ragelink 6049 }
afe42d0… ragelink 6050
afe42d0… ragelink 6051 // Support: Chrome <=35 - 45+
afe42d0… ragelink 6052 // Assign undefined instead of using delete, see Data#remove
afe42d0… ragelink 6053 elem[ dataPriv.expando ] = undefined;
afe42d0… ragelink 6054 }
afe42d0… ragelink 6055 if ( elem[ dataUser.expando ] ) {
afe42d0… ragelink 6056
afe42d0… ragelink 6057 // Support: Chrome <=35 - 45+
afe42d0… ragelink 6058 // Assign undefined instead of using delete, see Data#remove
afe42d0… ragelink 6059 elem[ dataUser.expando ] = undefined;
afe42d0… ragelink 6060 }
afe42d0… ragelink 6061 }
afe42d0… ragelink 6062 }
afe42d0… ragelink 6063 }
afe42d0… ragelink 6064 } );
afe42d0… ragelink 6065
afe42d0… ragelink 6066 jQuery.fn.extend( {
afe42d0… ragelink 6067 detach: function( selector ) {
afe42d0… ragelink 6068 return remove( this, selector, true );
afe42d0… ragelink 6069 },
afe42d0… ragelink 6070
afe42d0… ragelink 6071 remove: function( selector ) {
afe42d0… ragelink 6072 return remove( this, selector );
afe42d0… ragelink 6073 },
afe42d0… ragelink 6074
afe42d0… ragelink 6075 text: function( value ) {
afe42d0… ragelink 6076 return access( this, function( value ) {
afe42d0… ragelink 6077 return value === undefined ?
afe42d0… ragelink 6078 jQuery.text( this ) :
afe42d0… ragelink 6079 this.empty().each( function() {
afe42d0… ragelink 6080 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
afe42d0… ragelink 6081 this.textContent = value;
afe42d0… ragelink 6082 }
afe42d0… ragelink 6083 } );
afe42d0… ragelink 6084 }, null, value, arguments.length );
afe42d0… ragelink 6085 },
afe42d0… ragelink 6086
afe42d0… ragelink 6087 append: function() {
afe42d0… ragelink 6088 return domManip( this, arguments, function( elem ) {
afe42d0… ragelink 6089 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
afe42d0… ragelink 6090 var target = manipulationTarget( this, elem );
afe42d0… ragelink 6091 target.appendChild( elem );
afe42d0… ragelink 6092 }
afe42d0… ragelink 6093 } );
afe42d0… ragelink 6094 },
afe42d0… ragelink 6095
afe42d0… ragelink 6096 prepend: function() {
afe42d0… ragelink 6097 return domManip( this, arguments, function( elem ) {
afe42d0… ragelink 6098 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
afe42d0… ragelink 6099 var target = manipulationTarget( this, elem );
afe42d0… ragelink 6100 target.insertBefore( elem, target.firstChild );
afe42d0… ragelink 6101 }
afe42d0… ragelink 6102 } );
afe42d0… ragelink 6103 },
afe42d0… ragelink 6104
afe42d0… ragelink 6105 before: function() {
afe42d0… ragelink 6106 return domManip( this, arguments, function( elem ) {
afe42d0… ragelink 6107 if ( this.parentNode ) {
afe42d0… ragelink 6108 this.parentNode.insertBefore( elem, this );
afe42d0… ragelink 6109 }
afe42d0… ragelink 6110 } );
afe42d0… ragelink 6111 },
afe42d0… ragelink 6112
afe42d0… ragelink 6113 after: function() {
afe42d0… ragelink 6114 return domManip( this, arguments, function( elem ) {
afe42d0… ragelink 6115 if ( this.parentNode ) {
afe42d0… ragelink 6116 this.parentNode.insertBefore( elem, this.nextSibling );
afe42d0… ragelink 6117 }
afe42d0… ragelink 6118 } );
afe42d0… ragelink 6119 },
afe42d0… ragelink 6120
afe42d0… ragelink 6121 empty: function() {
afe42d0… ragelink 6122 var elem,
afe42d0… ragelink 6123 i = 0;
afe42d0… ragelink 6124
afe42d0… ragelink 6125 for ( ; ( elem = this[ i ] ) != null; i++ ) {
afe42d0… ragelink 6126 if ( elem.nodeType === 1 ) {
afe42d0… ragelink 6127
afe42d0… ragelink 6128 // Prevent memory leaks
afe42d0… ragelink 6129 jQuery.cleanData( getAll( elem, false ) );
afe42d0… ragelink 6130
afe42d0… ragelink 6131 // Remove any remaining nodes
afe42d0… ragelink 6132 elem.textContent = "";
afe42d0… ragelink 6133 }
afe42d0… ragelink 6134 }
afe42d0… ragelink 6135
afe42d0… ragelink 6136 return this;
afe42d0… ragelink 6137 },
afe42d0… ragelink 6138
afe42d0… ragelink 6139 clone: function( dataAndEvents, deepDataAndEvents ) {
afe42d0… ragelink 6140 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
afe42d0… ragelink 6141 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
afe42d0… ragelink 6142
afe42d0… ragelink 6143 return this.map( function() {
afe42d0… ragelink 6144 return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
afe42d0… ragelink 6145 } );
afe42d0… ragelink 6146 },
afe42d0… ragelink 6147
afe42d0… ragelink 6148 html: function( value ) {
afe42d0… ragelink 6149 return access( this, function( value ) {
afe42d0… ragelink 6150 var elem = this[ 0 ] || {},
afe42d0… ragelink 6151 i = 0,
afe42d0… ragelink 6152 l = this.length;
afe42d0… ragelink 6153
afe42d0… ragelink 6154 if ( value === undefined && elem.nodeType === 1 ) {
afe42d0… ragelink 6155 return elem.innerHTML;
afe42d0… ragelink 6156 }
afe42d0… ragelink 6157
afe42d0… ragelink 6158 // See if we can take a shortcut and just use innerHTML
afe42d0… ragelink 6159 if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
afe42d0… ragelink 6160 !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
afe42d0… ragelink 6161
afe42d0… ragelink 6162 value = jQuery.htmlPrefilter( value );
afe42d0… ragelink 6163
afe42d0… ragelink 6164 try {
afe42d0… ragelink 6165 for ( ; i < l; i++ ) {
afe42d0… ragelink 6166 elem = this[ i ] || {};
afe42d0… ragelink 6167
afe42d0… ragelink 6168 // Remove element nodes and prevent memory leaks
afe42d0… ragelink 6169 if ( elem.nodeType === 1 ) {
afe42d0… ragelink 6170 jQuery.cleanData( getAll( elem, false ) );
afe42d0… ragelink 6171 elem.innerHTML = value;
afe42d0… ragelink 6172 }
afe42d0… ragelink 6173 }
afe42d0… ragelink 6174
afe42d0… ragelink 6175 elem = 0;
afe42d0… ragelink 6176
afe42d0… ragelink 6177 // If using innerHTML throws an exception, use the fallback method
afe42d0… ragelink 6178 } catch ( e ) {}
afe42d0… ragelink 6179 }
afe42d0… ragelink 6180
afe42d0… ragelink 6181 if ( elem ) {
afe42d0… ragelink 6182 this.empty().append( value );
afe42d0… ragelink 6183 }
afe42d0… ragelink 6184 }, null, value, arguments.length );
afe42d0… ragelink 6185 },
afe42d0… ragelink 6186
afe42d0… ragelink 6187 replaceWith: function() {
afe42d0… ragelink 6188 var ignored = [];
afe42d0… ragelink 6189
afe42d0… ragelink 6190 // Make the changes, replacing each non-ignored context element with the new content
afe42d0… ragelink 6191 return domManip( this, arguments, function( elem ) {
afe42d0… ragelink 6192 var parent = this.parentNode;
afe42d0… ragelink 6193
afe42d0… ragelink 6194 if ( jQuery.inArray( this, ignored ) < 0 ) {
afe42d0… ragelink 6195 jQuery.cleanData( getAll( this ) );
afe42d0… ragelink 6196 if ( parent ) {
afe42d0… ragelink 6197 parent.replaceChild( elem, this );
afe42d0… ragelink 6198 }
afe42d0… ragelink 6199 }
afe42d0… ragelink 6200
afe42d0… ragelink 6201 // Force callback invocation
afe42d0… ragelink 6202 }, ignored );
afe42d0… ragelink 6203 }
afe42d0… ragelink 6204 } );
afe42d0… ragelink 6205
afe42d0… ragelink 6206 jQuery.each( {
afe42d0… ragelink 6207 appendTo: "append",
afe42d0… ragelink 6208 prependTo: "prepend",
afe42d0… ragelink 6209 insertBefore: "before",
afe42d0… ragelink 6210 insertAfter: "after",
afe42d0… ragelink 6211 replaceAll: "replaceWith"
afe42d0… ragelink 6212 }, function( name, original ) {
afe42d0… ragelink 6213 jQuery.fn[ name ] = function( selector ) {
afe42d0… ragelink 6214 var elems,
afe42d0… ragelink 6215 ret = [],
afe42d0… ragelink 6216 insert = jQuery( selector ),
afe42d0… ragelink 6217 last = insert.length - 1,
afe42d0… ragelink 6218 i = 0;
afe42d0… ragelink 6219
afe42d0… ragelink 6220 for ( ; i <= last; i++ ) {
afe42d0… ragelink 6221 elems = i === last ? this : this.clone( true );
afe42d0… ragelink 6222 jQuery( insert[ i ] )[ original ]( elems );
afe42d0… ragelink 6223
afe42d0… ragelink 6224 // Support: Android <=4.0 only, PhantomJS 1 only
afe42d0… ragelink 6225 // .get() because push.apply(_, arraylike) throws on ancient WebKit
afe42d0… ragelink 6226 push.apply( ret, elems.get() );
afe42d0… ragelink 6227 }
afe42d0… ragelink 6228
afe42d0… ragelink 6229 return this.pushStack( ret );
afe42d0… ragelink 6230 };
afe42d0… ragelink 6231 } );
afe42d0… ragelink 6232 var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
afe42d0… ragelink 6233
afe42d0… ragelink 6234 var rcustomProp = /^--/;
afe42d0… ragelink 6235
afe42d0… ragelink 6236
afe42d0… ragelink 6237 var getStyles = function( elem ) {
afe42d0… ragelink 6238
afe42d0… ragelink 6239 // Support: IE <=11 only, Firefox <=30 (trac-15098, trac-14150)
afe42d0… ragelink 6240 // IE throws on elements created in popups
afe42d0… ragelink 6241 // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
afe42d0… ragelink 6242 var view = elem.ownerDocument.defaultView;
afe42d0… ragelink 6243
afe42d0… ragelink 6244 if ( !view || !view.opener ) {
afe42d0… ragelink 6245 view = window;
afe42d0… ragelink 6246 }
afe42d0… ragelink 6247
afe42d0… ragelink 6248 return view.getComputedStyle( elem );
afe42d0… ragelink 6249 };
afe42d0… ragelink 6250
afe42d0… ragelink 6251 var swap = function( elem, options, callback ) {
afe42d0… ragelink 6252 var ret, name,
afe42d0… ragelink 6253 old = {};
afe42d0… ragelink 6254
afe42d0… ragelink 6255 // Remember the old values, and insert the new ones
afe42d0… ragelink 6256 for ( name in options ) {
afe42d0… ragelink 6257 old[ name ] = elem.style[ name ];
afe42d0… ragelink 6258 elem.style[ name ] = options[ name ];
afe42d0… ragelink 6259 }
afe42d0… ragelink 6260
afe42d0… ragelink 6261 ret = callback.call( elem );
afe42d0… ragelink 6262
afe42d0… ragelink 6263 // Revert the old values
afe42d0… ragelink 6264 for ( name in options ) {
afe42d0… ragelink 6265 elem.style[ name ] = old[ name ];
afe42d0… ragelink 6266 }
afe42d0… ragelink 6267
afe42d0… ragelink 6268 return ret;
afe42d0… ragelink 6269 };
afe42d0… ragelink 6270
afe42d0… ragelink 6271
afe42d0… ragelink 6272 var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" );
afe42d0… ragelink 6273
afe42d0… ragelink 6274
afe42d0… ragelink 6275
afe42d0… ragelink 6276 ( function() {
afe42d0… ragelink 6277
afe42d0… ragelink 6278 // Executing both pixelPosition & boxSizingReliable tests require only one layout
afe42d0… ragelink 6279 // so they're executed at the same time to save the second computation.
afe42d0… ragelink 6280 function computeStyleTests() {
afe42d0… ragelink 6281
afe42d0… ragelink 6282 // This is a singleton, we need to execute it only once
afe42d0… ragelink 6283 if ( !div ) {
afe42d0… ragelink 6284 return;
afe42d0… ragelink 6285 }
afe42d0… ragelink 6286
afe42d0… ragelink 6287 container.style.cssText = "position:absolute;left:-11111px;width:60px;" +
afe42d0… ragelink 6288 "margin-top:1px;padding:0;border:0";
afe42d0… ragelink 6289 div.style.cssText =
afe42d0… ragelink 6290 "position:relative;display:block;box-sizing:border-box;overflow:scroll;" +
afe42d0… ragelink 6291 "margin:auto;border:1px;padding:1px;" +
afe42d0… ragelink 6292 "width:60%;top:1%";
afe42d0… ragelink 6293 documentElement.appendChild( container ).appendChild( div );
afe42d0… ragelink 6294
afe42d0… ragelink 6295 var divStyle = window.getComputedStyle( div );
afe42d0… ragelink 6296 pixelPositionVal = divStyle.top !== "1%";
afe42d0… ragelink 6297
afe42d0… ragelink 6298 // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
afe42d0… ragelink 6299 reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12;
afe42d0… ragelink 6300
afe42d0… ragelink 6301 // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
afe42d0… ragelink 6302 // Some styles come back with percentage values, even though they shouldn't
afe42d0… ragelink 6303 div.style.right = "60%";
afe42d0… ragelink 6304 pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36;
afe42d0… ragelink 6305
afe42d0… ragelink 6306 // Support: IE 9 - 11 only
afe42d0… ragelink 6307 // Detect misreporting of content dimensions for box-sizing:border-box elements
afe42d0… ragelink 6308 boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36;
afe42d0… ragelink 6309
afe42d0… ragelink 6310 // Support: IE 9 only
afe42d0… ragelink 6311 // Detect overflow:scroll screwiness (gh-3699)
afe42d0… ragelink 6312 // Support: Chrome <=64
afe42d0… ragelink 6313 // Don't get tricked when zoom affects offsetWidth (gh-4029)
afe42d0… ragelink 6314 div.style.position = "absolute";
afe42d0… ragelink 6315 scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12;
afe42d0… ragelink 6316
afe42d0… ragelink 6317 documentElement.removeChild( container );
afe42d0… ragelink 6318
afe42d0… ragelink 6319 // Nullify the div so it wouldn't be stored in the memory and
afe42d0… ragelink 6320 // it will also be a sign that checks already performed
afe42d0… ragelink 6321 div = null;
afe42d0… ragelink 6322 }
afe42d0… ragelink 6323
afe42d0… ragelink 6324 function roundPixelMeasures( measure ) {
afe42d0… ragelink 6325 return Math.round( parseFloat( measure ) );
afe42d0… ragelink 6326 }
afe42d0… ragelink 6327
afe42d0… ragelink 6328 var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal,
afe42d0… ragelink 6329 reliableTrDimensionsVal, reliableMarginLeftVal,
afe42d0… ragelink 6330 container = document.createElement( "div" ),
afe42d0… ragelink 6331 div = document.createElement( "div" );
afe42d0… ragelink 6332
afe42d0… ragelink 6333 // Finish early in limited (non-browser) environments
afe42d0… ragelink 6334 if ( !div.style ) {
afe42d0… ragelink 6335 return;
afe42d0… ragelink 6336 }
afe42d0… ragelink 6337
afe42d0… ragelink 6338 // Support: IE <=9 - 11 only
afe42d0… ragelink 6339 // Style of cloned element affects source element cloned (trac-8908)
afe42d0… ragelink 6340 div.style.backgroundClip = "content-box";
afe42d0… ragelink 6341 div.cloneNode( true ).style.backgroundClip = "";
afe42d0… ragelink 6342 support.clearCloneStyle = div.style.backgroundClip === "content-box";
afe42d0… ragelink 6343
afe42d0… ragelink 6344 jQuery.extend( support, {
afe42d0… ragelink 6345 boxSizingReliable: function() {
afe42d0… ragelink 6346 computeStyleTests();
afe42d0… ragelink 6347 return boxSizingReliableVal;
afe42d0… ragelink 6348 },
afe42d0… ragelink 6349 pixelBoxStyles: function() {
afe42d0… ragelink 6350 computeStyleTests();
afe42d0… ragelink 6351 return pixelBoxStylesVal;
afe42d0… ragelink 6352 },
afe42d0… ragelink 6353 pixelPosition: function() {
afe42d0… ragelink 6354 computeStyleTests();
afe42d0… ragelink 6355 return pixelPositionVal;
afe42d0… ragelink 6356 },
afe42d0… ragelink 6357 reliableMarginLeft: function() {
afe42d0… ragelink 6358 computeStyleTests();
afe42d0… ragelink 6359 return reliableMarginLeftVal;
afe42d0… ragelink 6360 },
afe42d0… ragelink 6361 scrollboxSize: function() {
afe42d0… ragelink 6362 computeStyleTests();
afe42d0… ragelink 6363 return scrollboxSizeVal;
afe42d0… ragelink 6364 },
afe42d0… ragelink 6365
afe42d0… ragelink 6366 // Support: IE 9 - 11+, Edge 15 - 18+
afe42d0… ragelink 6367 // IE/Edge misreport `getComputedStyle` of table rows with width/height
afe42d0… ragelink 6368 // set in CSS while `offset*` properties report correct values.
afe42d0… ragelink 6369 // Behavior in IE 9 is more subtle than in newer versions & it passes
afe42d0… ragelink 6370 // some versions of this test; make sure not to make it pass there!
afe42d0… ragelink 6371 //
afe42d0… ragelink 6372 // Support: Firefox 70+
afe42d0… ragelink 6373 // Only Firefox includes border widths
afe42d0… ragelink 6374 // in computed dimensions. (gh-4529)
afe42d0… ragelink 6375 reliableTrDimensions: function() {
afe42d0… ragelink 6376 var table, tr, trChild, trStyle;
afe42d0… ragelink 6377 if ( reliableTrDimensionsVal == null ) {
afe42d0… ragelink 6378 table = document.createElement( "table" );
afe42d0… ragelink 6379 tr = document.createElement( "tr" );
afe42d0… ragelink 6380 trChild = document.createElement( "div" );
afe42d0… ragelink 6381
afe42d0… ragelink 6382 table.style.cssText = "position:absolute;left:-11111px;border-collapse:separate";
afe42d0… ragelink 6383 tr.style.cssText = "box-sizing:content-box;border:1px solid";
afe42d0… ragelink 6384
afe42d0… ragelink 6385 // Support: Chrome 86+
afe42d0… ragelink 6386 // Height set through cssText does not get applied.
afe42d0… ragelink 6387 // Computed height then comes back as 0.
afe42d0… ragelink 6388 tr.style.height = "1px";
afe42d0… ragelink 6389 trChild.style.height = "9px";
afe42d0… ragelink 6390
afe42d0… ragelink 6391 // Support: Android 8 Chrome 86+
afe42d0… ragelink 6392 // In our bodyBackground.html iframe,
afe42d0… ragelink 6393 // display for all div elements is set to "inline",
afe42d0… ragelink 6394 // which causes a problem only in Android 8 Chrome 86.
afe42d0… ragelink 6395 // Ensuring the div is `display: block`
afe42d0… ragelink 6396 // gets around this issue.
afe42d0… ragelink 6397 trChild.style.display = "block";
afe42d0… ragelink 6398
afe42d0… ragelink 6399 documentElement
afe42d0… ragelink 6400 .appendChild( table )
afe42d0… ragelink 6401 .appendChild( tr )
afe42d0… ragelink 6402 .appendChild( trChild );
afe42d0… ragelink 6403
afe42d0… ragelink 6404 trStyle = window.getComputedStyle( tr );
afe42d0… ragelink 6405 reliableTrDimensionsVal = ( parseInt( trStyle.height, 10 ) +
afe42d0… ragelink 6406 parseInt( trStyle.borderTopWidth, 10 ) +
afe42d0… ragelink 6407 parseInt( trStyle.borderBottomWidth, 10 ) ) === tr.offsetHeight;
afe42d0… ragelink 6408
afe42d0… ragelink 6409 documentElement.removeChild( table );
afe42d0… ragelink 6410 }
afe42d0… ragelink 6411 return reliableTrDimensionsVal;
afe42d0… ragelink 6412 }
afe42d0… ragelink 6413 } );
afe42d0… ragelink 6414 } )();
afe42d0… ragelink 6415
afe42d0… ragelink 6416
afe42d0… ragelink 6417 function curCSS( elem, name, computed ) {
afe42d0… ragelink 6418 var width, minWidth, maxWidth, ret,
afe42d0… ragelink 6419 isCustomProp = rcustomProp.test( name ),
afe42d0… ragelink 6420
afe42d0… ragelink 6421 // Support: Firefox 51+
afe42d0… ragelink 6422 // Retrieving style before computed somehow
afe42d0… ragelink 6423 // fixes an issue with getting wrong values
afe42d0… ragelink 6424 // on detached elements
afe42d0… ragelink 6425 style = elem.style;
afe42d0… ragelink 6426
afe42d0… ragelink 6427 computed = computed || getStyles( elem );
afe42d0… ragelink 6428
afe42d0… ragelink 6429 // getPropertyValue is needed for:
afe42d0… ragelink 6430 // .css('filter') (IE 9 only, trac-12537)
afe42d0… ragelink 6431 // .css('--customProperty) (gh-3144)
afe42d0… ragelink 6432 if ( computed ) {
afe42d0… ragelink 6433
afe42d0… ragelink 6434 // Support: IE <=9 - 11+
afe42d0… ragelink 6435 // IE only supports `"float"` in `getPropertyValue`; in computed styles
afe42d0… ragelink 6436 // it's only available as `"cssFloat"`. We no longer modify properties
afe42d0… ragelink 6437 // sent to `.css()` apart from camelCasing, so we need to check both.
afe42d0… ragelink 6438 // Normally, this would create difference in behavior: if
afe42d0… ragelink 6439 // `getPropertyValue` returns an empty string, the value returned
afe42d0… ragelink 6440 // by `.css()` would be `undefined`. This is usually the case for
afe42d0… ragelink 6441 // disconnected elements. However, in IE even disconnected elements
afe42d0… ragelink 6442 // with no styles return `"none"` for `getPropertyValue( "float" )`
afe42d0… ragelink 6443 ret = computed.getPropertyValue( name ) || computed[ name ];
afe42d0… ragelink 6444
afe42d0… ragelink 6445 if ( isCustomProp && ret ) {
afe42d0… ragelink 6446
afe42d0… ragelink 6447 // Support: Firefox 105+, Chrome <=105+
afe42d0… ragelink 6448 // Spec requires trimming whitespace for custom properties (gh-4926).
afe42d0… ragelink 6449 // Firefox only trims leading whitespace. Chrome just collapses
afe42d0… ragelink 6450 // both leading & trailing whitespace to a single space.
afe42d0… ragelink 6451 //
afe42d0… ragelink 6452 // Fall back to `undefined` if empty string returned.
afe42d0… ragelink 6453 // This collapses a missing definition with property defined
afe42d0… ragelink 6454 // and set to an empty string but there's no standard API
afe42d0… ragelink 6455 // allowing us to differentiate them without a performance penalty
afe42d0… ragelink 6456 // and returning `undefined` aligns with older jQuery.
afe42d0… ragelink 6457 //
afe42d0… ragelink 6458 // rtrimCSS treats U+000D CARRIAGE RETURN and U+000C FORM FEED
afe42d0… ragelink 6459 // as whitespace while CSS does not, but this is not a problem
afe42d0… ragelink 6460 // because CSS preprocessing replaces them with U+000A LINE FEED
afe42d0… ragelink 6461 // (which *is* CSS whitespace)
afe42d0… ragelink 6462 // https://www.w3.org/TR/css-syntax-3/#input-preprocessing
afe42d0… ragelink 6463 ret = ret.replace( rtrimCSS, "$1" ) || undefined;
afe42d0… ragelink 6464 }
afe42d0… ragelink 6465
afe42d0… ragelink 6466 if ( ret === "" && !isAttached( elem ) ) {
afe42d0… ragelink 6467 ret = jQuery.style( elem, name );
afe42d0… ragelink 6468 }
afe42d0… ragelink 6469
afe42d0… ragelink 6470 // A tribute to the "awesome hack by Dean Edwards"
afe42d0… ragelink 6471 // Android Browser returns percentage for some values,
afe42d0… ragelink 6472 // but width seems to be reliably pixels.
afe42d0… ragelink 6473 // This is against the CSSOM draft spec:
afe42d0… ragelink 6474 // https://drafts.csswg.org/cssom/#resolved-values
afe42d0… ragelink 6475 if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) {
afe42d0… ragelink 6476
afe42d0… ragelink 6477 // Remember the original values
afe42d0… ragelink 6478 width = style.width;
afe42d0… ragelink 6479 minWidth = style.minWidth;
afe42d0… ragelink 6480 maxWidth = style.maxWidth;
afe42d0… ragelink 6481
afe42d0… ragelink 6482 // Put in the new values to get a computed value out
afe42d0… ragelink 6483 style.minWidth = style.maxWidth = style.width = ret;
afe42d0… ragelink 6484 ret = computed.width;
afe42d0… ragelink 6485
afe42d0… ragelink 6486 // Revert the changed values
afe42d0… ragelink 6487 style.width = width;
afe42d0… ragelink 6488 style.minWidth = minWidth;
afe42d0… ragelink 6489 style.maxWidth = maxWidth;
afe42d0… ragelink 6490 }
afe42d0… ragelink 6491 }
afe42d0… ragelink 6492
afe42d0… ragelink 6493 return ret !== undefined ?
afe42d0… ragelink 6494
afe42d0… ragelink 6495 // Support: IE <=9 - 11 only
afe42d0… ragelink 6496 // IE returns zIndex value as an integer.
afe42d0… ragelink 6497 ret + "" :
afe42d0… ragelink 6498 ret;
afe42d0… ragelink 6499 }
afe42d0… ragelink 6500
afe42d0… ragelink 6501
afe42d0… ragelink 6502 function addGetHookIf( conditionFn, hookFn ) {
afe42d0… ragelink 6503
afe42d0… ragelink 6504 // Define the hook, we'll check on the first run if it's really needed.
afe42d0… ragelink 6505 return {
afe42d0… ragelink 6506 get: function() {
afe42d0… ragelink 6507 if ( conditionFn() ) {
afe42d0… ragelink 6508
afe42d0… ragelink 6509 // Hook not needed (or it's not possible to use it due
afe42d0… ragelink 6510 // to missing dependency), remove it.
afe42d0… ragelink 6511 delete this.get;
afe42d0… ragelink 6512 return;
afe42d0… ragelink 6513 }
afe42d0… ragelink 6514
afe42d0… ragelink 6515 // Hook needed; redefine it so that the support test is not executed again.
afe42d0… ragelink 6516 return ( this.get = hookFn ).apply( this, arguments );
afe42d0… ragelink 6517 }
afe42d0… ragelink 6518 };
afe42d0… ragelink 6519 }
afe42d0… ragelink 6520
afe42d0… ragelink 6521
afe42d0… ragelink 6522 var cssPrefixes = [ "Webkit", "Moz", "ms" ],
afe42d0… ragelink 6523 emptyStyle = document.createElement( "div" ).style,
afe42d0… ragelink 6524 vendorProps = {};
afe42d0… ragelink 6525
afe42d0… ragelink 6526 // Return a vendor-prefixed property or undefined
afe42d0… ragelink 6527 function vendorPropName( name ) {
afe42d0… ragelink 6528
afe42d0… ragelink 6529 // Check for vendor prefixed names
afe42d0… ragelink 6530 var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
afe42d0… ragelink 6531 i = cssPrefixes.length;
afe42d0… ragelink 6532
afe42d0… ragelink 6533 while ( i-- ) {
afe42d0… ragelink 6534 name = cssPrefixes[ i ] + capName;
afe42d0… ragelink 6535 if ( name in emptyStyle ) {
afe42d0… ragelink 6536 return name;
afe42d0… ragelink 6537 }
afe42d0… ragelink 6538 }
afe42d0… ragelink 6539 }
afe42d0… ragelink 6540
afe42d0… ragelink 6541 // Return a potentially-mapped jQuery.cssProps or vendor prefixed property
afe42d0… ragelink 6542 function finalPropName( name ) {
afe42d0… ragelink 6543 var final = jQuery.cssProps[ name ] || vendorProps[ name ];
afe42d0… ragelink 6544
afe42d0… ragelink 6545 if ( final ) {
afe42d0… ragelink 6546 return final;
afe42d0… ragelink 6547 }
afe42d0… ragelink 6548 if ( name in emptyStyle ) {
afe42d0… ragelink 6549 return name;
afe42d0… ragelink 6550 }
afe42d0… ragelink 6551 return vendorProps[ name ] = vendorPropName( name ) || name;
afe42d0… ragelink 6552 }
afe42d0… ragelink 6553
afe42d0… ragelink 6554
afe42d0… ragelink 6555 var
afe42d0… ragelink 6556
afe42d0… ragelink 6557 // Swappable if display is none or starts with table
afe42d0… ragelink 6558 // except "table", "table-cell", or "table-caption"
afe42d0… ragelink 6559 // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
afe42d0… ragelink 6560 rdisplayswap = /^(none|table(?!-c[ea]).+)/,
afe42d0… ragelink 6561 cssShow = { position: "absolute", visibility: "hidden", display: "block" },
afe42d0… ragelink 6562 cssNormalTransform = {
afe42d0… ragelink 6563 letterSpacing: "0",
afe42d0… ragelink 6564 fontWeight: "400"
afe42d0… ragelink 6565 };
afe42d0… ragelink 6566
afe42d0… ragelink 6567 function setPositiveNumber( _elem, value, subtract ) {
afe42d0… ragelink 6568
afe42d0… ragelink 6569 // Any relative (+/-) values have already been
afe42d0… ragelink 6570 // normalized at this point
afe42d0… ragelink 6571 var matches = rcssNum.exec( value );
afe42d0… ragelink 6572 return matches ?
afe42d0… ragelink 6573
afe42d0… ragelink 6574 // Guard against undefined "subtract", e.g., when used as in cssHooks
afe42d0… ragelink 6575 Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
afe42d0… ragelink 6576 value;
afe42d0… ragelink 6577 }
afe42d0… ragelink 6578
afe42d0… ragelink 6579 function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) {
afe42d0… ragelink 6580 var i = dimension === "width" ? 1 : 0,
afe42d0… ragelink 6581 extra = 0,
afe42d0… ragelink 6582 delta = 0,
afe42d0… ragelink 6583 marginDelta = 0;
afe42d0… ragelink 6584
afe42d0… ragelink 6585 // Adjustment may not be necessary
afe42d0… ragelink 6586 if ( box === ( isBorderBox ? "border" : "content" ) ) {
afe42d0… ragelink 6587 return 0;
afe42d0… ragelink 6588 }
afe42d0… ragelink 6589
afe42d0… ragelink 6590 for ( ; i < 4; i += 2 ) {
afe42d0… ragelink 6591
afe42d0… ragelink 6592 // Both box models exclude margin
afe42d0… ragelink 6593 // Count margin delta separately to only add it after scroll gutter adjustment.
afe42d0… ragelink 6594 // This is needed to make negative margins work with `outerHeight( true )` (gh-3982).
afe42d0… ragelink 6595 if ( box === "margin" ) {
afe42d0… ragelink 6596 marginDelta += jQuery.css( elem, box + cssExpand[ i ], true, styles );
afe42d0… ragelink 6597 }
afe42d0… ragelink 6598
afe42d0… ragelink 6599 // If we get here with a content-box, we're seeking "padding" or "border" or "margin"
afe42d0… ragelink 6600 if ( !isBorderBox ) {
afe42d0… ragelink 6601
afe42d0… ragelink 6602 // Add padding
afe42d0… ragelink 6603 delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
afe42d0… ragelink 6604
afe42d0… ragelink 6605 // For "border" or "margin", add border
afe42d0… ragelink 6606 if ( box !== "padding" ) {
afe42d0… ragelink 6607 delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
afe42d0… ragelink 6608
afe42d0… ragelink 6609 // But still keep track of it otherwise
afe42d0… ragelink 6610 } else {
afe42d0… ragelink 6611 extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
afe42d0… ragelink 6612 }
afe42d0… ragelink 6613
afe42d0… ragelink 6614 // If we get here with a border-box (content + padding + border), we're seeking "content" or
afe42d0… ragelink 6615 // "padding" or "margin"
afe42d0… ragelink 6616 } else {
afe42d0… ragelink 6617
afe42d0… ragelink 6618 // For "content", subtract padding
afe42d0… ragelink 6619 if ( box === "content" ) {
afe42d0… ragelink 6620 delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
afe42d0… ragelink 6621 }
afe42d0… ragelink 6622
afe42d0… ragelink 6623 // For "content" or "padding", subtract border
afe42d0… ragelink 6624 if ( box !== "margin" ) {
afe42d0… ragelink 6625 delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
afe42d0… ragelink 6626 }
afe42d0… ragelink 6627 }
afe42d0… ragelink 6628 }
afe42d0… ragelink 6629
afe42d0… ragelink 6630 // Account for positive content-box scroll gutter when requested by providing computedVal
afe42d0… ragelink 6631 if ( !isBorderBox && computedVal >= 0 ) {
afe42d0… ragelink 6632
afe42d0… ragelink 6633 // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
afe42d0… ragelink 6634 // Assuming integer scroll gutter, subtract the rest and round down
afe42d0… ragelink 6635 delta += Math.max( 0, Math.ceil(
afe42d0… ragelink 6636 elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
afe42d0… ragelink 6637 computedVal -
afe42d0… ragelink 6638 delta -
afe42d0… ragelink 6639 extra -
afe42d0… ragelink 6640 0.5
afe42d0… ragelink 6641
afe42d0… ragelink 6642 // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter
afe42d0… ragelink 6643 // Use an explicit zero to avoid NaN (gh-3964)
afe42d0… ragelink 6644 ) ) || 0;
afe42d0… ragelink 6645 }
afe42d0… ragelink 6646
afe42d0… ragelink 6647 return delta + marginDelta;
afe42d0… ragelink 6648 }
afe42d0… ragelink 6649
afe42d0… ragelink 6650 function getWidthOrHeight( elem, dimension, extra ) {
afe42d0… ragelink 6651
afe42d0… ragelink 6652 // Start with computed style
afe42d0… ragelink 6653 var styles = getStyles( elem ),
afe42d0… ragelink 6654
afe42d0… ragelink 6655 // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322).
afe42d0… ragelink 6656 // Fake content-box until we know it's needed to know the true value.
afe42d0… ragelink 6657 boxSizingNeeded = !support.boxSizingReliable() || extra,
afe42d0… ragelink 6658 isBorderBox = boxSizingNeeded &&
afe42d0… ragelink 6659 jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
afe42d0… ragelink 6660 valueIsBorderBox = isBorderBox,
afe42d0… ragelink 6661
afe42d0… ragelink 6662 val = curCSS( elem, dimension, styles ),
afe42d0… ragelink 6663 offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 );
afe42d0… ragelink 6664
afe42d0… ragelink 6665 // Support: Firefox <=54
afe42d0… ragelink 6666 // Return a confounding non-pixel value or feign ignorance, as appropriate.
afe42d0… ragelink 6667 if ( rnumnonpx.test( val ) ) {
afe42d0… ragelink 6668 if ( !extra ) {
afe42d0… ragelink 6669 return val;
afe42d0… ragelink 6670 }
afe42d0… ragelink 6671 val = "auto";
afe42d0… ragelink 6672 }
afe42d0… ragelink 6673
afe42d0… ragelink 6674
afe42d0… ragelink 6675 // Support: IE 9 - 11 only
afe42d0… ragelink 6676 // Use offsetWidth/offsetHeight for when box sizing is unreliable.
afe42d0… ragelink 6677 // In those cases, the computed value can be trusted to be border-box.
afe42d0… ragelink 6678 if ( ( !support.boxSizingReliable() && isBorderBox ||
afe42d0… ragelink 6679
afe42d0… ragelink 6680 // Support: IE 10 - 11+, Edge 15 - 18+
afe42d0… ragelink 6681 // IE/Edge misreport `getComputedStyle` of table rows with width/height
afe42d0… ragelink 6682 // set in CSS while `offset*` properties report correct values.
afe42d0… ragelink 6683 // Interestingly, in some cases IE 9 doesn't suffer from this issue.
afe42d0… ragelink 6684 !support.reliableTrDimensions() && nodeName( elem, "tr" ) ||
afe42d0… ragelink 6685
afe42d0… ragelink 6686 // Fall back to offsetWidth/offsetHeight when value is "auto"
afe42d0… ragelink 6687 // This happens for inline elements with no explicit setting (gh-3571)
afe42d0… ragelink 6688 val === "auto" ||
afe42d0… ragelink 6689
afe42d0… ragelink 6690 // Support: Android <=4.1 - 4.3 only
afe42d0… ragelink 6691 // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602)
afe42d0… ragelink 6692 !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) &&
afe42d0… ragelink 6693
afe42d0… ragelink 6694 // Make sure the element is visible & connected
afe42d0… ragelink 6695 elem.getClientRects().length ) {
afe42d0… ragelink 6696
afe42d0… ragelink 6697 isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
afe42d0… ragelink 6698
afe42d0… ragelink 6699 // Where available, offsetWidth/offsetHeight approximate border box dimensions.
afe42d0… ragelink 6700 // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the
afe42d0… ragelink 6701 // retrieved value as a content box dimension.
afe42d0… ragelink 6702 valueIsBorderBox = offsetProp in elem;
afe42d0… ragelink 6703 if ( valueIsBorderBox ) {
afe42d0… ragelink 6704 val = elem[ offsetProp ];
afe42d0… ragelink 6705 }
afe42d0… ragelink 6706 }
afe42d0… ragelink 6707
afe42d0… ragelink 6708 // Normalize "" and auto
afe42d0… ragelink 6709 val = parseFloat( val ) || 0;
afe42d0… ragelink 6710
afe42d0… ragelink 6711 // Adjust for the element's box model
afe42d0… ragelink 6712 return ( val +
afe42d0… ragelink 6713 boxModelAdjustment(
afe42d0… ragelink 6714 elem,
afe42d0… ragelink 6715 dimension,
afe42d0… ragelink 6716 extra || ( isBorderBox ? "border" : "content" ),
afe42d0… ragelink 6717 valueIsBorderBox,
afe42d0… ragelink 6718 styles,
afe42d0… ragelink 6719
afe42d0… ragelink 6720 // Provide the current computed size to request scroll gutter calculation (gh-3589)
afe42d0… ragelink 6721 val
afe42d0… ragelink 6722 )
afe42d0… ragelink 6723 ) + "px";
afe42d0… ragelink 6724 }
afe42d0… ragelink 6725
afe42d0… ragelink 6726 jQuery.extend( {
afe42d0… ragelink 6727
afe42d0… ragelink 6728 // Add in style property hooks for overriding the default
afe42d0… ragelink 6729 // behavior of getting and setting a style property
afe42d0… ragelink 6730 cssHooks: {
afe42d0… ragelink 6731 opacity: {
afe42d0… ragelink 6732 get: function( elem, computed ) {
afe42d0… ragelink 6733 if ( computed ) {
afe42d0… ragelink 6734
afe42d0… ragelink 6735 // We should always get a number back from opacity
afe42d0… ragelink 6736 var ret = curCSS( elem, "opacity" );
afe42d0… ragelink 6737 return ret === "" ? "1" : ret;
afe42d0… ragelink 6738 }
afe42d0… ragelink 6739 }
afe42d0… ragelink 6740 }
afe42d0… ragelink 6741 },
afe42d0… ragelink 6742
afe42d0… ragelink 6743 // Don't automatically add "px" to these possibly-unitless properties
afe42d0… ragelink 6744 cssNumber: {
afe42d0… ragelink 6745 animationIterationCount: true,
afe42d0… ragelink 6746 aspectRatio: true,
afe42d0… ragelink 6747 borderImageSlice: true,
afe42d0… ragelink 6748 columnCount: true,
afe42d0… ragelink 6749 flexGrow: true,
afe42d0… ragelink 6750 flexShrink: true,
afe42d0… ragelink 6751 fontWeight: true,
afe42d0… ragelink 6752 gridArea: true,
afe42d0… ragelink 6753 gridColumn: true,
afe42d0… ragelink 6754 gridColumnEnd: true,
afe42d0… ragelink 6755 gridColumnStart: true,
afe42d0… ragelink 6756 gridRow: true,
afe42d0… ragelink 6757 gridRowEnd: true,
afe42d0… ragelink 6758 gridRowStart: true,
afe42d0… ragelink 6759 lineHeight: true,
afe42d0… ragelink 6760 opacity: true,
afe42d0… ragelink 6761 order: true,
afe42d0… ragelink 6762 orphans: true,
afe42d0… ragelink 6763 scale: true,
afe42d0… ragelink 6764 widows: true,
afe42d0… ragelink 6765 zIndex: true,
afe42d0… ragelink 6766 zoom: true,
afe42d0… ragelink 6767
afe42d0… ragelink 6768 // SVG-related
afe42d0… ragelink 6769 fillOpacity: true,
afe42d0… ragelink 6770 floodOpacity: true,
afe42d0… ragelink 6771 stopOpacity: true,
afe42d0… ragelink 6772 strokeMiterlimit: true,
afe42d0… ragelink 6773 strokeOpacity: true
afe42d0… ragelink 6774 },
afe42d0… ragelink 6775
afe42d0… ragelink 6776 // Add in properties whose names you wish to fix before
afe42d0… ragelink 6777 // setting or getting the value
afe42d0… ragelink 6778 cssProps: {},
afe42d0… ragelink 6779
afe42d0… ragelink 6780 // Get and set the style property on a DOM Node
afe42d0… ragelink 6781 style: function( elem, name, value, extra ) {
afe42d0… ragelink 6782
afe42d0… ragelink 6783 // Don't set styles on text and comment nodes
afe42d0… ragelink 6784 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
afe42d0… ragelink 6785 return;
afe42d0… ragelink 6786 }
afe42d0… ragelink 6787
afe42d0… ragelink 6788 // Make sure that we're working with the right name
afe42d0… ragelink 6789 var ret, type, hooks,
afe42d0… ragelink 6790 origName = camelCase( name ),
afe42d0… ragelink 6791 isCustomProp = rcustomProp.test( name ),
afe42d0… ragelink 6792 style = elem.style;
afe42d0… ragelink 6793
afe42d0… ragelink 6794 // Make sure that we're working with the right name. We don't
afe42d0… ragelink 6795 // want to query the value if it is a CSS custom property
afe42d0… ragelink 6796 // since they are user-defined.
afe42d0… ragelink 6797 if ( !isCustomProp ) {
afe42d0… ragelink 6798 name = finalPropName( origName );
afe42d0… ragelink 6799 }
afe42d0… ragelink 6800
afe42d0… ragelink 6801 // Gets hook for the prefixed version, then unprefixed version
afe42d0… ragelink 6802 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
afe42d0… ragelink 6803
afe42d0… ragelink 6804 // Check if we're setting a value
afe42d0… ragelink 6805 if ( value !== undefined ) {
afe42d0… ragelink 6806 type = typeof value;
afe42d0… ragelink 6807
afe42d0… ragelink 6808 // Convert "+=" or "-=" to relative numbers (trac-7345)
afe42d0… ragelink 6809 if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
afe42d0… ragelink 6810 value = adjustCSS( elem, name, ret );
afe42d0… ragelink 6811
afe42d0… ragelink 6812 // Fixes bug trac-9237
afe42d0… ragelink 6813 type = "number";
afe42d0… ragelink 6814 }
afe42d0… ragelink 6815
afe42d0… ragelink 6816 // Make sure that null and NaN values aren't set (trac-7116)
afe42d0… ragelink 6817 if ( value == null || value !== value ) {
afe42d0… ragelink 6818 return;
afe42d0… ragelink 6819 }
afe42d0… ragelink 6820
afe42d0… ragelink 6821 // If a number was passed in, add the unit (except for certain CSS properties)
afe42d0… ragelink 6822 // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append
afe42d0… ragelink 6823 // "px" to a few hardcoded values.
afe42d0… ragelink 6824 if ( type === "number" && !isCustomProp ) {
afe42d0… ragelink 6825 value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
afe42d0… ragelink 6826 }
afe42d0… ragelink 6827
afe42d0… ragelink 6828 // background-* props affect original clone's values
afe42d0… ragelink 6829 if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
afe42d0… ragelink 6830 style[ name ] = "inherit";
afe42d0… ragelink 6831 }
afe42d0… ragelink 6832
afe42d0… ragelink 6833 // If a hook was provided, use that value, otherwise just set the specified value
afe42d0… ragelink 6834 if ( !hooks || !( "set" in hooks ) ||
afe42d0… ragelink 6835 ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
afe42d0… ragelink 6836
afe42d0… ragelink 6837 if ( isCustomProp ) {
afe42d0… ragelink 6838 style.setProperty( name, value );
afe42d0… ragelink 6839 } else {
afe42d0… ragelink 6840 style[ name ] = value;
afe42d0… ragelink 6841 }
afe42d0… ragelink 6842 }
afe42d0… ragelink 6843
afe42d0… ragelink 6844 } else {
afe42d0… ragelink 6845
afe42d0… ragelink 6846 // If a hook was provided get the non-computed value from there
afe42d0… ragelink 6847 if ( hooks && "get" in hooks &&
afe42d0… ragelink 6848 ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
afe42d0… ragelink 6849
afe42d0… ragelink 6850 return ret;
afe42d0… ragelink 6851 }
afe42d0… ragelink 6852
afe42d0… ragelink 6853 // Otherwise just get the value from the style object
afe42d0… ragelink 6854 return style[ name ];
afe42d0… ragelink 6855 }
afe42d0… ragelink 6856 },
afe42d0… ragelink 6857
afe42d0… ragelink 6858 css: function( elem, name, extra, styles ) {
afe42d0… ragelink 6859 var val, num, hooks,
afe42d0… ragelink 6860 origName = camelCase( name ),
afe42d0… ragelink 6861 isCustomProp = rcustomProp.test( name );
afe42d0… ragelink 6862
afe42d0… ragelink 6863 // Make sure that we're working with the right name. We don't
afe42d0… ragelink 6864 // want to modify the value if it is a CSS custom property
afe42d0… ragelink 6865 // since they are user-defined.
afe42d0… ragelink 6866 if ( !isCustomProp ) {
afe42d0… ragelink 6867 name = finalPropName( origName );
afe42d0… ragelink 6868 }
afe42d0… ragelink 6869
afe42d0… ragelink 6870 // Try prefixed name followed by the unprefixed name
afe42d0… ragelink 6871 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
afe42d0… ragelink 6872
afe42d0… ragelink 6873 // If a hook was provided get the computed value from there
afe42d0… ragelink 6874 if ( hooks && "get" in hooks ) {
afe42d0… ragelink 6875 val = hooks.get( elem, true, extra );
afe42d0… ragelink 6876 }
afe42d0… ragelink 6877
afe42d0… ragelink 6878 // Otherwise, if a way to get the computed value exists, use that
afe42d0… ragelink 6879 if ( val === undefined ) {
afe42d0… ragelink 6880 val = curCSS( elem, name, styles );
afe42d0… ragelink 6881 }
afe42d0… ragelink 6882
afe42d0… ragelink 6883 // Convert "normal" to computed value
afe42d0… ragelink 6884 if ( val === "normal" && name in cssNormalTransform ) {
afe42d0… ragelink 6885 val = cssNormalTransform[ name ];
afe42d0… ragelink 6886 }
afe42d0… ragelink 6887
afe42d0… ragelink 6888 // Make numeric if forced or a qualifier was provided and val looks numeric
afe42d0… ragelink 6889 if ( extra === "" || extra ) {
afe42d0… ragelink 6890 num = parseFloat( val );
afe42d0… ragelink 6891 return extra === true || isFinite( num ) ? num || 0 : val;
afe42d0… ragelink 6892 }
afe42d0… ragelink 6893
afe42d0… ragelink 6894 return val;
afe42d0… ragelink 6895 }
afe42d0… ragelink 6896 } );
afe42d0… ragelink 6897
afe42d0… ragelink 6898 jQuery.each( [ "height", "width" ], function( _i, dimension ) {
afe42d0… ragelink 6899 jQuery.cssHooks[ dimension ] = {
afe42d0… ragelink 6900 get: function( elem, computed, extra ) {
afe42d0… ragelink 6901 if ( computed ) {
afe42d0… ragelink 6902
afe42d0… ragelink 6903 // Certain elements can have dimension info if we invisibly show them
afe42d0… ragelink 6904 // but it must have a current display style that would benefit
afe42d0… ragelink 6905 return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
afe42d0… ragelink 6906
afe42d0… ragelink 6907 // Support: Safari 8+
afe42d0… ragelink 6908 // Table columns in Safari have non-zero offsetWidth & zero
afe42d0… ragelink 6909 // getBoundingClientRect().width unless display is changed.
afe42d0… ragelink 6910 // Support: IE <=11 only
afe42d0… ragelink 6911 // Running getBoundingClientRect on a disconnected node
afe42d0… ragelink 6912 // in IE throws an error.
afe42d0… ragelink 6913 ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
afe42d0… ragelink 6914 swap( elem, cssShow, function() {
afe42d0… ragelink 6915 return getWidthOrHeight( elem, dimension, extra );
afe42d0… ragelink 6916 } ) :
afe42d0… ragelink 6917 getWidthOrHeight( elem, dimension, extra );
afe42d0… ragelink 6918 }
afe42d0… ragelink 6919 },
afe42d0… ragelink 6920
afe42d0… ragelink 6921 set: function( elem, value, extra ) {
afe42d0… ragelink 6922 var matches,
afe42d0… ragelink 6923 styles = getStyles( elem ),
afe42d0… ragelink 6924
afe42d0… ragelink 6925 // Only read styles.position if the test has a chance to fail
afe42d0… ragelink 6926 // to avoid forcing a reflow.
afe42d0… ragelink 6927 scrollboxSizeBuggy = !support.scrollboxSize() &&
afe42d0… ragelink 6928 styles.position === "absolute",
afe42d0… ragelink 6929
afe42d0… ragelink 6930 // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991)
afe42d0… ragelink 6931 boxSizingNeeded = scrollboxSizeBuggy || extra,
afe42d0… ragelink 6932 isBorderBox = boxSizingNeeded &&
afe42d0… ragelink 6933 jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
afe42d0… ragelink 6934 subtract = extra ?
afe42d0… ragelink 6935 boxModelAdjustment(
afe42d0… ragelink 6936 elem,
afe42d0… ragelink 6937 dimension,
afe42d0… ragelink 6938 extra,
afe42d0… ragelink 6939 isBorderBox,
afe42d0… ragelink 6940 styles
afe42d0… ragelink 6941 ) :
afe42d0… ragelink 6942 0;
afe42d0… ragelink 6943
afe42d0… ragelink 6944 // Account for unreliable border-box dimensions by comparing offset* to computed and
afe42d0… ragelink 6945 // faking a content-box to get border and padding (gh-3699)
afe42d0… ragelink 6946 if ( isBorderBox && scrollboxSizeBuggy ) {
afe42d0… ragelink 6947 subtract -= Math.ceil(
afe42d0… ragelink 6948 elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
afe42d0… ragelink 6949 parseFloat( styles[ dimension ] ) -
afe42d0… ragelink 6950 boxModelAdjustment( elem, dimension, "border", false, styles ) -
afe42d0… ragelink 6951 0.5
afe42d0… ragelink 6952 );
afe42d0… ragelink 6953 }
afe42d0… ragelink 6954
afe42d0… ragelink 6955 // Convert to pixels if value adjustment is needed
afe42d0… ragelink 6956 if ( subtract && ( matches = rcssNum.exec( value ) ) &&
afe42d0… ragelink 6957 ( matches[ 3 ] || "px" ) !== "px" ) {
afe42d0… ragelink 6958
afe42d0… ragelink 6959 elem.style[ dimension ] = value;
afe42d0… ragelink 6960 value = jQuery.css( elem, dimension );
afe42d0… ragelink 6961 }
afe42d0… ragelink 6962
afe42d0… ragelink 6963 return setPositiveNumber( elem, value, subtract );
afe42d0… ragelink 6964 }
afe42d0… ragelink 6965 };
afe42d0… ragelink 6966 } );
afe42d0… ragelink 6967
afe42d0… ragelink 6968 jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
afe42d0… ragelink 6969 function( elem, computed ) {
afe42d0… ragelink 6970 if ( computed ) {
afe42d0… ragelink 6971 return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
afe42d0… ragelink 6972 elem.getBoundingClientRect().left -
afe42d0… ragelink 6973 swap( elem, { marginLeft: 0 }, function() {
afe42d0… ragelink 6974 return elem.getBoundingClientRect().left;
afe42d0… ragelink 6975 } )
afe42d0… ragelink 6976 ) + "px";
afe42d0… ragelink 6977 }
afe42d0… ragelink 6978 }
afe42d0… ragelink 6979 );
afe42d0… ragelink 6980
afe42d0… ragelink 6981 // These hooks are used by animate to expand properties
afe42d0… ragelink 6982 jQuery.each( {
afe42d0… ragelink 6983 margin: "",
afe42d0… ragelink 6984 padding: "",
afe42d0… ragelink 6985 border: "Width"
afe42d0… ragelink 6986 }, function( prefix, suffix ) {
afe42d0… ragelink 6987 jQuery.cssHooks[ prefix + suffix ] = {
afe42d0… ragelink 6988 expand: function( value ) {
afe42d0… ragelink 6989 var i = 0,
afe42d0… ragelink 6990 expanded = {},
afe42d0… ragelink 6991
afe42d0… ragelink 6992 // Assumes a single number if not a string
afe42d0… ragelink 6993 parts = typeof value === "string" ? value.split( " " ) : [ value ];
afe42d0… ragelink 6994
afe42d0… ragelink 6995 for ( ; i < 4; i++ ) {
afe42d0… ragelink 6996 expanded[ prefix + cssExpand[ i ] + suffix ] =
afe42d0… ragelink 6997 parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
afe42d0… ragelink 6998 }
afe42d0… ragelink 6999
afe42d0… ragelink 7000 return expanded;
afe42d0… ragelink 7001 }
afe42d0… ragelink 7002 };
afe42d0… ragelink 7003
afe42d0… ragelink 7004 if ( prefix !== "margin" ) {
afe42d0… ragelink 7005 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
afe42d0… ragelink 7006 }
afe42d0… ragelink 7007 } );
afe42d0… ragelink 7008
afe42d0… ragelink 7009 jQuery.fn.extend( {
afe42d0… ragelink 7010 css: function( name, value ) {
afe42d0… ragelink 7011 return access( this, function( elem, name, value ) {
afe42d0… ragelink 7012 var styles, len,
afe42d0… ragelink 7013 map = {},
afe42d0… ragelink 7014 i = 0;
afe42d0… ragelink 7015
afe42d0… ragelink 7016 if ( Array.isArray( name ) ) {
afe42d0… ragelink 7017 styles = getStyles( elem );
afe42d0… ragelink 7018 len = name.length;
afe42d0… ragelink 7019
afe42d0… ragelink 7020 for ( ; i < len; i++ ) {
afe42d0… ragelink 7021 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
afe42d0… ragelink 7022 }
afe42d0… ragelink 7023
afe42d0… ragelink 7024 return map;
afe42d0… ragelink 7025 }
afe42d0… ragelink 7026
afe42d0… ragelink 7027 return value !== undefined ?
afe42d0… ragelink 7028 jQuery.style( elem, name, value ) :
afe42d0… ragelink 7029 jQuery.css( elem, name );
afe42d0… ragelink 7030 }, name, value, arguments.length > 1 );
afe42d0… ragelink 7031 }
afe42d0… ragelink 7032 } );
afe42d0… ragelink 7033
afe42d0… ragelink 7034
afe42d0… ragelink 7035 function Tween( elem, options, prop, end, easing ) {
afe42d0… ragelink 7036 return new Tween.prototype.init( elem, options, prop, end, easing );
afe42d0… ragelink 7037 }
afe42d0… ragelink 7038 jQuery.Tween = Tween;
afe42d0… ragelink 7039
afe42d0… ragelink 7040 Tween.prototype = {
afe42d0… ragelink 7041 constructor: Tween,
afe42d0… ragelink 7042 init: function( elem, options, prop, end, easing, unit ) {
afe42d0… ragelink 7043 this.elem = elem;
afe42d0… ragelink 7044 this.prop = prop;
afe42d0… ragelink 7045 this.easing = easing || jQuery.easing._default;
afe42d0… ragelink 7046 this.options = options;
afe42d0… ragelink 7047 this.start = this.now = this.cur();
afe42d0… ragelink 7048 this.end = end;
afe42d0… ragelink 7049 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
afe42d0… ragelink 7050 },
afe42d0… ragelink 7051 cur: function() {
afe42d0… ragelink 7052 var hooks = Tween.propHooks[ this.prop ];
afe42d0… ragelink 7053
afe42d0… ragelink 7054 return hooks && hooks.get ?
afe42d0… ragelink 7055 hooks.get( this ) :
afe42d0… ragelink 7056 Tween.propHooks._default.get( this );
afe42d0… ragelink 7057 },
afe42d0… ragelink 7058 run: function( percent ) {
afe42d0… ragelink 7059 var eased,
afe42d0… ragelink 7060 hooks = Tween.propHooks[ this.prop ];
afe42d0… ragelink 7061
afe42d0… ragelink 7062 if ( this.options.duration ) {
afe42d0… ragelink 7063 this.pos = eased = jQuery.easing[ this.easing ](
afe42d0… ragelink 7064 percent, this.options.duration * percent, 0, 1, this.options.duration
afe42d0… ragelink 7065 );
afe42d0… ragelink 7066 } else {
afe42d0… ragelink 7067 this.pos = eased = percent;
afe42d0… ragelink 7068 }
afe42d0… ragelink 7069 this.now = ( this.end - this.start ) * eased + this.start;
afe42d0… ragelink 7070
afe42d0… ragelink 7071 if ( this.options.step ) {
afe42d0… ragelink 7072 this.options.step.call( this.elem, this.now, this );
afe42d0… ragelink 7073 }
afe42d0… ragelink 7074
afe42d0… ragelink 7075 if ( hooks && hooks.set ) {
afe42d0… ragelink 7076 hooks.set( this );
afe42d0… ragelink 7077 } else {
afe42d0… ragelink 7078 Tween.propHooks._default.set( this );
afe42d0… ragelink 7079 }
afe42d0… ragelink 7080 return this;
afe42d0… ragelink 7081 }
afe42d0… ragelink 7082 };
afe42d0… ragelink 7083
afe42d0… ragelink 7084 Tween.prototype.init.prototype = Tween.prototype;
afe42d0… ragelink 7085
afe42d0… ragelink 7086 Tween.propHooks = {
afe42d0… ragelink 7087 _default: {
afe42d0… ragelink 7088 get: function( tween ) {
afe42d0… ragelink 7089 var result;
afe42d0… ragelink 7090
afe42d0… ragelink 7091 // Use a property on the element directly when it is not a DOM element,
afe42d0… ragelink 7092 // or when there is no matching style property that exists.
afe42d0… ragelink 7093 if ( tween.elem.nodeType !== 1 ||
afe42d0… ragelink 7094 tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
afe42d0… ragelink 7095 return tween.elem[ tween.prop ];
afe42d0… ragelink 7096 }
afe42d0… ragelink 7097
afe42d0… ragelink 7098 // Passing an empty string as a 3rd parameter to .css will automatically
afe42d0… ragelink 7099 // attempt a parseFloat and fallback to a string if the parse fails.
afe42d0… ragelink 7100 // Simple values such as "10px" are parsed to Float;
afe42d0… ragelink 7101 // complex values such as "rotate(1rad)" are returned as-is.
afe42d0… ragelink 7102 result = jQuery.css( tween.elem, tween.prop, "" );
afe42d0… ragelink 7103
afe42d0… ragelink 7104 // Empty strings, null, undefined and "auto" are converted to 0.
afe42d0… ragelink 7105 return !result || result === "auto" ? 0 : result;
afe42d0… ragelink 7106 },
afe42d0… ragelink 7107 set: function( tween ) {
afe42d0… ragelink 7108
afe42d0… ragelink 7109 // Use step hook for back compat.
afe42d0… ragelink 7110 // Use cssHook if its there.
afe42d0… ragelink 7111 // Use .style if available and use plain properties where available.
afe42d0… ragelink 7112 if ( jQuery.fx.step[ tween.prop ] ) {
afe42d0… ragelink 7113 jQuery.fx.step[ tween.prop ]( tween );
afe42d0… ragelink 7114 } else if ( tween.elem.nodeType === 1 && (
afe42d0… ragelink 7115 jQuery.cssHooks[ tween.prop ] ||
afe42d0… ragelink 7116 tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) {
afe42d0… ragelink 7117 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
afe42d0… ragelink 7118 } else {
afe42d0… ragelink 7119 tween.elem[ tween.prop ] = tween.now;
afe42d0… ragelink 7120 }
afe42d0… ragelink 7121 }
afe42d0… ragelink 7122 }
afe42d0… ragelink 7123 };
afe42d0… ragelink 7124
afe42d0… ragelink 7125 // Support: IE <=9 only
afe42d0… ragelink 7126 // Panic based approach to setting things on disconnected nodes
afe42d0… ragelink 7127 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
afe42d0… ragelink 7128 set: function( tween ) {
afe42d0… ragelink 7129 if ( tween.elem.nodeType && tween.elem.parentNode ) {
afe42d0… ragelink 7130 tween.elem[ tween.prop ] = tween.now;
afe42d0… ragelink 7131 }
afe42d0… ragelink 7132 }
afe42d0… ragelink 7133 };
afe42d0… ragelink 7134
afe42d0… ragelink 7135 jQuery.easing = {
afe42d0… ragelink 7136 linear: function( p ) {
afe42d0… ragelink 7137 return p;
afe42d0… ragelink 7138 },
afe42d0… ragelink 7139 swing: function( p ) {
afe42d0… ragelink 7140 return 0.5 - Math.cos( p * Math.PI ) / 2;
afe42d0… ragelink 7141 },
afe42d0… ragelink 7142 _default: "swing"
afe42d0… ragelink 7143 };
afe42d0… ragelink 7144
afe42d0… ragelink 7145 jQuery.fx = Tween.prototype.init;
afe42d0… ragelink 7146
afe42d0… ragelink 7147 // Back compat <1.8 extension point
afe42d0… ragelink 7148 jQuery.fx.step = {};
afe42d0… ragelink 7149
afe42d0… ragelink 7150
afe42d0… ragelink 7151
afe42d0… ragelink 7152
afe42d0… ragelink 7153 var
afe42d0… ragelink 7154 fxNow, inProgress,
afe42d0… ragelink 7155 rfxtypes = /^(?:toggle|show|hide)$/,
afe42d0… ragelink 7156 rrun = /queueHooks$/;
afe42d0… ragelink 7157
afe42d0… ragelink 7158 function schedule() {
afe42d0… ragelink 7159 if ( inProgress ) {
afe42d0… ragelink 7160 if ( document.hidden === false && window.requestAnimationFrame ) {
afe42d0… ragelink 7161 window.requestAnimationFrame( schedule );
afe42d0… ragelink 7162 } else {
afe42d0… ragelink 7163 window.setTimeout( schedule, jQuery.fx.interval );
afe42d0… ragelink 7164 }
afe42d0… ragelink 7165
afe42d0… ragelink 7166 jQuery.fx.tick();
afe42d0… ragelink 7167 }
afe42d0… ragelink 7168 }
afe42d0… ragelink 7169
afe42d0… ragelink 7170 // Animations created synchronously will run synchronously
afe42d0… ragelink 7171 function createFxNow() {
afe42d0… ragelink 7172 window.setTimeout( function() {
afe42d0… ragelink 7173 fxNow = undefined;
afe42d0… ragelink 7174 } );
afe42d0… ragelink 7175 return ( fxNow = Date.now() );
afe42d0… ragelink 7176 }
afe42d0… ragelink 7177
afe42d0… ragelink 7178 // Generate parameters to create a standard animation
afe42d0… ragelink 7179 function genFx( type, includeWidth ) {
afe42d0… ragelink 7180 var which,
afe42d0… ragelink 7181 i = 0,
afe42d0… ragelink 7182 attrs = { height: type };
afe42d0… ragelink 7183
afe42d0… ragelink 7184 // If we include width, step value is 1 to do all cssExpand values,
afe42d0… ragelink 7185 // otherwise step value is 2 to skip over Left and Right
afe42d0… ragelink 7186 includeWidth = includeWidth ? 1 : 0;
afe42d0… ragelink 7187 for ( ; i < 4; i += 2 - includeWidth ) {
afe42d0… ragelink 7188 which = cssExpand[ i ];
afe42d0… ragelink 7189 attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
afe42d0… ragelink 7190 }
afe42d0… ragelink 7191
afe42d0… ragelink 7192 if ( includeWidth ) {
afe42d0… ragelink 7193 attrs.opacity = attrs.width = type;
afe42d0… ragelink 7194 }
afe42d0… ragelink 7195
afe42d0… ragelink 7196 return attrs;
afe42d0… ragelink 7197 }
afe42d0… ragelink 7198
afe42d0… ragelink 7199 function createTween( value, prop, animation ) {
afe42d0… ragelink 7200 var tween,
afe42d0… ragelink 7201 collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
afe42d0… ragelink 7202 index = 0,
afe42d0… ragelink 7203 length = collection.length;
afe42d0… ragelink 7204 for ( ; index < length; index++ ) {
afe42d0… ragelink 7205 if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
afe42d0… ragelink 7206
afe42d0… ragelink 7207 // We're done with this property
afe42d0… ragelink 7208 return tween;
afe42d0… ragelink 7209 }
afe42d0… ragelink 7210 }
afe42d0… ragelink 7211 }
afe42d0… ragelink 7212
afe42d0… ragelink 7213 function defaultPrefilter( elem, props, opts ) {
afe42d0… ragelink 7214 var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,
afe42d0… ragelink 7215 isBox = "width" in props || "height" in props,
afe42d0… ragelink 7216 anim = this,
afe42d0… ragelink 7217 orig = {},
afe42d0… ragelink 7218 style = elem.style,
afe42d0… ragelink 7219 hidden = elem.nodeType && isHiddenWithinTree( elem ),
afe42d0… ragelink 7220 dataShow = dataPriv.get( elem, "fxshow" );
afe42d0… ragelink 7221
afe42d0… ragelink 7222 // Queue-skipping animations hijack the fx hooks
afe42d0… ragelink 7223 if ( !opts.queue ) {
afe42d0… ragelink 7224 hooks = jQuery._queueHooks( elem, "fx" );
afe42d0… ragelink 7225 if ( hooks.unqueued == null ) {
afe42d0… ragelink 7226 hooks.unqueued = 0;
afe42d0… ragelink 7227 oldfire = hooks.empty.fire;
afe42d0… ragelink 7228 hooks.empty.fire = function() {
afe42d0… ragelink 7229 if ( !hooks.unqueued ) {
afe42d0… ragelink 7230 oldfire();
afe42d0… ragelink 7231 }
afe42d0… ragelink 7232 };
afe42d0… ragelink 7233 }
afe42d0… ragelink 7234 hooks.unqueued++;
afe42d0… ragelink 7235
afe42d0… ragelink 7236 anim.always( function() {
afe42d0… ragelink 7237
afe42d0… ragelink 7238 // Ensure the complete handler is called before this completes
afe42d0… ragelink 7239 anim.always( function() {
afe42d0… ragelink 7240 hooks.unqueued--;
afe42d0… ragelink 7241 if ( !jQuery.queue( elem, "fx" ).length ) {
afe42d0… ragelink 7242 hooks.empty.fire();
afe42d0… ragelink 7243 }
afe42d0… ragelink 7244 } );
afe42d0… ragelink 7245 } );
afe42d0… ragelink 7246 }
afe42d0… ragelink 7247
afe42d0… ragelink 7248 // Detect show/hide animations
afe42d0… ragelink 7249 for ( prop in props ) {
afe42d0… ragelink 7250 value = props[ prop ];
afe42d0… ragelink 7251 if ( rfxtypes.test( value ) ) {
afe42d0… ragelink 7252 delete props[ prop ];
afe42d0… ragelink 7253 toggle = toggle || value === "toggle";
afe42d0… ragelink 7254 if ( value === ( hidden ? "hide" : "show" ) ) {
afe42d0… ragelink 7255
afe42d0… ragelink 7256 // Pretend to be hidden if this is a "show" and
afe42d0… ragelink 7257 // there is still data from a stopped show/hide
afe42d0… ragelink 7258 if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
afe42d0… ragelink 7259 hidden = true;
afe42d0… ragelink 7260
afe42d0… ragelink 7261 // Ignore all other no-op show/hide data
afe42d0… ragelink 7262 } else {
afe42d0… ragelink 7263 continue;
afe42d0… ragelink 7264 }
afe42d0… ragelink 7265 }
afe42d0… ragelink 7266 orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
afe42d0… ragelink 7267 }
afe42d0… ragelink 7268 }
afe42d0… ragelink 7269
afe42d0… ragelink 7270 // Bail out if this is a no-op like .hide().hide()
afe42d0… ragelink 7271 propTween = !jQuery.isEmptyObject( props );
afe42d0… ragelink 7272 if ( !propTween && jQuery.isEmptyObject( orig ) ) {
afe42d0… ragelink 7273 return;
afe42d0… ragelink 7274 }
afe42d0… ragelink 7275
afe42d0… ragelink 7276 // Restrict "overflow" and "display" styles during box animations
afe42d0… ragelink 7277 if ( isBox && elem.nodeType === 1 ) {
afe42d0… ragelink 7278
afe42d0… ragelink 7279 // Support: IE <=9 - 11, Edge 12 - 15
afe42d0… ragelink 7280 // Record all 3 overflow attributes because IE does not infer the shorthand
afe42d0… ragelink 7281 // from identically-valued overflowX and overflowY and Edge just mirrors
afe42d0… ragelink 7282 // the overflowX value there.
afe42d0… ragelink 7283 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
afe42d0… ragelink 7284
afe42d0… ragelink 7285 // Identify a display type, preferring old show/hide data over the CSS cascade
afe42d0… ragelink 7286 restoreDisplay = dataShow && dataShow.display;
afe42d0… ragelink 7287 if ( restoreDisplay == null ) {
afe42d0… ragelink 7288 restoreDisplay = dataPriv.get( elem, "display" );
afe42d0… ragelink 7289 }
afe42d0… ragelink 7290 display = jQuery.css( elem, "display" );
afe42d0… ragelink 7291 if ( display === "none" ) {
afe42d0… ragelink 7292 if ( restoreDisplay ) {
afe42d0… ragelink 7293 display = restoreDisplay;
afe42d0… ragelink 7294 } else {
afe42d0… ragelink 7295
afe42d0… ragelink 7296 // Get nonempty value(s) by temporarily forcing visibility
afe42d0… ragelink 7297 showHide( [ elem ], true );
afe42d0… ragelink 7298 restoreDisplay = elem.style.display || restoreDisplay;
afe42d0… ragelink 7299 display = jQuery.css( elem, "display" );
afe42d0… ragelink 7300 showHide( [ elem ] );
afe42d0… ragelink 7301 }
afe42d0… ragelink 7302 }
afe42d0… ragelink 7303
afe42d0… ragelink 7304 // Animate inline elements as inline-block
afe42d0… ragelink 7305 if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) {
afe42d0… ragelink 7306 if ( jQuery.css( elem, "float" ) === "none" ) {
afe42d0… ragelink 7307
afe42d0… ragelink 7308 // Restore the original display value at the end of pure show/hide animations
afe42d0… ragelink 7309 if ( !propTween ) {
afe42d0… ragelink 7310 anim.done( function() {
afe42d0… ragelink 7311 style.display = restoreDisplay;
afe42d0… ragelink 7312 } );
afe42d0… ragelink 7313 if ( restoreDisplay == null ) {
afe42d0… ragelink 7314 display = style.display;
afe42d0… ragelink 7315 restoreDisplay = display === "none" ? "" : display;
afe42d0… ragelink 7316 }
afe42d0… ragelink 7317 }
afe42d0… ragelink 7318 style.display = "inline-block";
afe42d0… ragelink 7319 }
afe42d0… ragelink 7320 }
afe42d0… ragelink 7321 }
afe42d0… ragelink 7322
afe42d0… ragelink 7323 if ( opts.overflow ) {
afe42d0… ragelink 7324 style.overflow = "hidden";
afe42d0… ragelink 7325 anim.always( function() {
afe42d0… ragelink 7326 style.overflow = opts.overflow[ 0 ];
afe42d0… ragelink 7327 style.overflowX = opts.overflow[ 1 ];
afe42d0… ragelink 7328 style.overflowY = opts.overflow[ 2 ];
afe42d0… ragelink 7329 } );
afe42d0… ragelink 7330 }
afe42d0… ragelink 7331
afe42d0… ragelink 7332 // Implement show/hide animations
afe42d0… ragelink 7333 propTween = false;
afe42d0… ragelink 7334 for ( prop in orig ) {
afe42d0… ragelink 7335
afe42d0… ragelink 7336 // General show/hide setup for this element animation
afe42d0… ragelink 7337 if ( !propTween ) {
afe42d0… ragelink 7338 if ( dataShow ) {
afe42d0… ragelink 7339 if ( "hidden" in dataShow ) {
afe42d0… ragelink 7340 hidden = dataShow.hidden;
afe42d0… ragelink 7341 }
afe42d0… ragelink 7342 } else {
afe42d0… ragelink 7343 dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } );
afe42d0… ragelink 7344 }
afe42d0… ragelink 7345
afe42d0… ragelink 7346 // Store hidden/visible for toggle so `.stop().toggle()` "reverses"
afe42d0… ragelink 7347 if ( toggle ) {
afe42d0… ragelink 7348 dataShow.hidden = !hidden;
afe42d0… ragelink 7349 }
afe42d0… ragelink 7350
afe42d0… ragelink 7351 // Show elements before animating them
afe42d0… ragelink 7352 if ( hidden ) {
afe42d0… ragelink 7353 showHide( [ elem ], true );
afe42d0… ragelink 7354 }
afe42d0… ragelink 7355
afe42d0… ragelink 7356 /* eslint-disable no-loop-func */
afe42d0… ragelink 7357
afe42d0… ragelink 7358 anim.done( function() {
afe42d0… ragelink 7359
afe42d0… ragelink 7360 /* eslint-enable no-loop-func */
afe42d0… ragelink 7361
afe42d0… ragelink 7362 // The final step of a "hide" animation is actually hiding the element
afe42d0… ragelink 7363 if ( !hidden ) {
afe42d0… ragelink 7364 showHide( [ elem ] );
afe42d0… ragelink 7365 }
afe42d0… ragelink 7366 dataPriv.remove( elem, "fxshow" );
afe42d0… ragelink 7367 for ( prop in orig ) {
afe42d0… ragelink 7368 jQuery.style( elem, prop, orig[ prop ] );
afe42d0… ragelink 7369 }
afe42d0… ragelink 7370 } );
afe42d0… ragelink 7371 }
afe42d0… ragelink 7372
afe42d0… ragelink 7373 // Per-property setup
afe42d0… ragelink 7374 propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
afe42d0… ragelink 7375 if ( !( prop in dataShow ) ) {
afe42d0… ragelink 7376 dataShow[ prop ] = propTween.start;
afe42d0… ragelink 7377 if ( hidden ) {
afe42d0… ragelink 7378 propTween.end = propTween.start;
afe42d0… ragelink 7379 propTween.start = 0;
afe42d0… ragelink 7380 }
afe42d0… ragelink 7381 }
afe42d0… ragelink 7382 }
afe42d0… ragelink 7383 }
afe42d0… ragelink 7384
afe42d0… ragelink 7385 function propFilter( props, specialEasing ) {
afe42d0… ragelink 7386 var index, name, easing, value, hooks;
afe42d0… ragelink 7387
afe42d0… ragelink 7388 // camelCase, specialEasing and expand cssHook pass
afe42d0… ragelink 7389 for ( index in props ) {
afe42d0… ragelink 7390 name = camelCase( index );
afe42d0… ragelink 7391 easing = specialEasing[ name ];
afe42d0… ragelink 7392 value = props[ index ];
afe42d0… ragelink 7393 if ( Array.isArray( value ) ) {
afe42d0… ragelink 7394 easing = value[ 1 ];
afe42d0… ragelink 7395 value = props[ index ] = value[ 0 ];
afe42d0… ragelink 7396 }
afe42d0… ragelink 7397
afe42d0… ragelink 7398 if ( index !== name ) {
afe42d0… ragelink 7399 props[ name ] = value;
afe42d0… ragelink 7400 delete props[ index ];
afe42d0… ragelink 7401 }
afe42d0… ragelink 7402
afe42d0… ragelink 7403 hooks = jQuery.cssHooks[ name ];
afe42d0… ragelink 7404 if ( hooks && "expand" in hooks ) {
afe42d0… ragelink 7405 value = hooks.expand( value );
afe42d0… ragelink 7406 delete props[ name ];
afe42d0… ragelink 7407
afe42d0… ragelink 7408 // Not quite $.extend, this won't overwrite existing keys.
afe42d0… ragelink 7409 // Reusing 'index' because we have the correct "name"
afe42d0… ragelink 7410 for ( index in value ) {
afe42d0… ragelink 7411 if ( !( index in props ) ) {
afe42d0… ragelink 7412 props[ index ] = value[ index ];
afe42d0… ragelink 7413 specialEasing[ index ] = easing;
afe42d0… ragelink 7414 }
afe42d0… ragelink 7415 }
afe42d0… ragelink 7416 } else {
afe42d0… ragelink 7417 specialEasing[ name ] = easing;
afe42d0… ragelink 7418 }
afe42d0… ragelink 7419 }
afe42d0… ragelink 7420 }
afe42d0… ragelink 7421
afe42d0… ragelink 7422 function Animation( elem, properties, options ) {
afe42d0… ragelink 7423 var result,
afe42d0… ragelink 7424 stopped,
afe42d0… ragelink 7425 index = 0,
afe42d0… ragelink 7426 length = Animation.prefilters.length,
afe42d0… ragelink 7427 deferred = jQuery.Deferred().always( function() {
afe42d0… ragelink 7428
afe42d0… ragelink 7429 // Don't match elem in the :animated selector
afe42d0… ragelink 7430 delete tick.elem;
afe42d0… ragelink 7431 } ),
afe42d0… ragelink 7432 tick = function() {
afe42d0… ragelink 7433 if ( stopped ) {
afe42d0… ragelink 7434 return false;
afe42d0… ragelink 7435 }
afe42d0… ragelink 7436 var currentTime = fxNow || createFxNow(),
afe42d0… ragelink 7437 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
afe42d0… ragelink 7438
afe42d0… ragelink 7439 // Support: Android 2.3 only
afe42d0… ragelink 7440 // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (trac-12497)
afe42d0… ragelink 7441 temp = remaining / animation.duration || 0,
afe42d0… ragelink 7442 percent = 1 - temp,
afe42d0… ragelink 7443 index = 0,
afe42d0… ragelink 7444 length = animation.tweens.length;
afe42d0… ragelink 7445
afe42d0… ragelink 7446 for ( ; index < length; index++ ) {
afe42d0… ragelink 7447 animation.tweens[ index ].run( percent );
afe42d0… ragelink 7448 }
afe42d0… ragelink 7449
afe42d0… ragelink 7450 deferred.notifyWith( elem, [ animation, percent, remaining ] );
afe42d0… ragelink 7451
afe42d0… ragelink 7452 // If there's more to do, yield
afe42d0… ragelink 7453 if ( percent < 1 && length ) {
afe42d0… ragelink 7454 return remaining;
afe42d0… ragelink 7455 }
afe42d0… ragelink 7456
afe42d0… ragelink 7457 // If this was an empty animation, synthesize a final progress notification
afe42d0… ragelink 7458 if ( !length ) {
afe42d0… ragelink 7459 deferred.notifyWith( elem, [ animation, 1, 0 ] );
afe42d0… ragelink 7460 }
afe42d0… ragelink 7461
afe42d0… ragelink 7462 // Resolve the animation and report its conclusion
afe42d0… ragelink 7463 deferred.resolveWith( elem, [ animation ] );
afe42d0… ragelink 7464 return false;
afe42d0… ragelink 7465 },
afe42d0… ragelink 7466 animation = deferred.promise( {
afe42d0… ragelink 7467 elem: elem,
afe42d0… ragelink 7468 props: jQuery.extend( {}, properties ),
afe42d0… ragelink 7469 opts: jQuery.extend( true, {
afe42d0… ragelink 7470 specialEasing: {},
afe42d0… ragelink 7471 easing: jQuery.easing._default
afe42d0… ragelink 7472 }, options ),
afe42d0… ragelink 7473 originalProperties: properties,
afe42d0… ragelink 7474 originalOptions: options,
afe42d0… ragelink 7475 startTime: fxNow || createFxNow(),
afe42d0… ragelink 7476 duration: options.duration,
afe42d0… ragelink 7477 tweens: [],
afe42d0… ragelink 7478 createTween: function( prop, end ) {
afe42d0… ragelink 7479 var tween = jQuery.Tween( elem, animation.opts, prop, end,
afe42d0… ragelink 7480 animation.opts.specialEasing[ prop ] || animation.opts.easing );
afe42d0… ragelink 7481 animation.tweens.push( tween );
afe42d0… ragelink 7482 return tween;
afe42d0… ragelink 7483 },
afe42d0… ragelink 7484 stop: function( gotoEnd ) {
afe42d0… ragelink 7485 var index = 0,
afe42d0… ragelink 7486
afe42d0… ragelink 7487 // If we are going to the end, we want to run all the tweens
afe42d0… ragelink 7488 // otherwise we skip this part
afe42d0… ragelink 7489 length = gotoEnd ? animation.tweens.length : 0;
afe42d0… ragelink 7490 if ( stopped ) {
afe42d0… ragelink 7491 return this;
afe42d0… ragelink 7492 }
afe42d0… ragelink 7493 stopped = true;
afe42d0… ragelink 7494 for ( ; index < length; index++ ) {
afe42d0… ragelink 7495 animation.tweens[ index ].run( 1 );
afe42d0… ragelink 7496 }
afe42d0… ragelink 7497
afe42d0… ragelink 7498 // Resolve when we played the last frame; otherwise, reject
afe42d0… ragelink 7499 if ( gotoEnd ) {
afe42d0… ragelink 7500 deferred.notifyWith( elem, [ animation, 1, 0 ] );
afe42d0… ragelink 7501 deferred.resolveWith( elem, [ animation, gotoEnd ] );
afe42d0… ragelink 7502 } else {
afe42d0… ragelink 7503 deferred.rejectWith( elem, [ animation, gotoEnd ] );
afe42d0… ragelink 7504 }
afe42d0… ragelink 7505 return this;
afe42d0… ragelink 7506 }
afe42d0… ragelink 7507 } ),
afe42d0… ragelink 7508 props = animation.props;
afe42d0… ragelink 7509
afe42d0… ragelink 7510 propFilter( props, animation.opts.specialEasing );
afe42d0… ragelink 7511
afe42d0… ragelink 7512 for ( ; index < length; index++ ) {
afe42d0… ragelink 7513 result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
afe42d0… ragelink 7514 if ( result ) {
afe42d0… ragelink 7515 if ( isFunction( result.stop ) ) {
afe42d0… ragelink 7516 jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
afe42d0… ragelink 7517 result.stop.bind( result );
afe42d0… ragelink 7518 }
afe42d0… ragelink 7519 return result;
afe42d0… ragelink 7520 }
afe42d0… ragelink 7521 }
afe42d0… ragelink 7522
afe42d0… ragelink 7523 jQuery.map( props, createTween, animation );
afe42d0… ragelink 7524
afe42d0… ragelink 7525 if ( isFunction( animation.opts.start ) ) {
afe42d0… ragelink 7526 animation.opts.start.call( elem, animation );
afe42d0… ragelink 7527 }
afe42d0… ragelink 7528
afe42d0… ragelink 7529 // Attach callbacks from options
afe42d0… ragelink 7530 animation
afe42d0… ragelink 7531 .progress( animation.opts.progress )
afe42d0… ragelink 7532 .done( animation.opts.done, animation.opts.complete )
afe42d0… ragelink 7533 .fail( animation.opts.fail )
afe42d0… ragelink 7534 .always( animation.opts.always );
afe42d0… ragelink 7535
afe42d0… ragelink 7536 jQuery.fx.timer(
afe42d0… ragelink 7537 jQuery.extend( tick, {
afe42d0… ragelink 7538 elem: elem,
afe42d0… ragelink 7539 anim: animation,
afe42d0… ragelink 7540 queue: animation.opts.queue
afe42d0… ragelink 7541 } )
afe42d0… ragelink 7542 );
afe42d0… ragelink 7543
afe42d0… ragelink 7544 return animation;
afe42d0… ragelink 7545 }
afe42d0… ragelink 7546
afe42d0… ragelink 7547 jQuery.Animation = jQuery.extend( Animation, {
afe42d0… ragelink 7548
afe42d0… ragelink 7549 tweeners: {
afe42d0… ragelink 7550 "*": [ function( prop, value ) {
afe42d0… ragelink 7551 var tween = this.createTween( prop, value );
afe42d0… ragelink 7552 adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
afe42d0… ragelink 7553 return tween;
afe42d0… ragelink 7554 } ]
afe42d0… ragelink 7555 },
afe42d0… ragelink 7556
afe42d0… ragelink 7557 tweener: function( props, callback ) {
afe42d0… ragelink 7558 if ( isFunction( props ) ) {
afe42d0… ragelink 7559 callback = props;
afe42d0… ragelink 7560 props = [ "*" ];
afe42d0… ragelink 7561 } else {
afe42d0… ragelink 7562 props = props.match( rnothtmlwhite );
afe42d0… ragelink 7563 }
afe42d0… ragelink 7564
afe42d0… ragelink 7565 var prop,
afe42d0… ragelink 7566 index = 0,
afe42d0… ragelink 7567 length = props.length;
afe42d0… ragelink 7568
afe42d0… ragelink 7569 for ( ; index < length; index++ ) {
afe42d0… ragelink 7570 prop = props[ index ];
afe42d0… ragelink 7571 Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
afe42d0… ragelink 7572 Animation.tweeners[ prop ].unshift( callback );
afe42d0… ragelink 7573 }
afe42d0… ragelink 7574 },
afe42d0… ragelink 7575
afe42d0… ragelink 7576 prefilters: [ defaultPrefilter ],
afe42d0… ragelink 7577
afe42d0… ragelink 7578 prefilter: function( callback, prepend ) {
afe42d0… ragelink 7579 if ( prepend ) {
afe42d0… ragelink 7580 Animation.prefilters.unshift( callback );
afe42d0… ragelink 7581 } else {
afe42d0… ragelink 7582 Animation.prefilters.push( callback );
afe42d0… ragelink 7583 }
afe42d0… ragelink 7584 }
afe42d0… ragelink 7585 } );
afe42d0… ragelink 7586
afe42d0… ragelink 7587 jQuery.speed = function( speed, easing, fn ) {
afe42d0… ragelink 7588 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
afe42d0… ragelink 7589 complete: fn || !fn && easing ||
afe42d0… ragelink 7590 isFunction( speed ) && speed,
afe42d0… ragelink 7591 duration: speed,
afe42d0… ragelink 7592 easing: fn && easing || easing && !isFunction( easing ) && easing
afe42d0… ragelink 7593 };
afe42d0… ragelink 7594
afe42d0… ragelink 7595 // Go to the end state if fx are off
afe42d0… ragelink 7596 if ( jQuery.fx.off ) {
afe42d0… ragelink 7597 opt.duration = 0;
afe42d0… ragelink 7598
afe42d0… ragelink 7599 } else {
afe42d0… ragelink 7600 if ( typeof opt.duration !== "number" ) {
afe42d0… ragelink 7601 if ( opt.duration in jQuery.fx.speeds ) {
afe42d0… ragelink 7602 opt.duration = jQuery.fx.speeds[ opt.duration ];
afe42d0… ragelink 7603
afe42d0… ragelink 7604 } else {
afe42d0… ragelink 7605 opt.duration = jQuery.fx.speeds._default;
afe42d0… ragelink 7606 }
afe42d0… ragelink 7607 }
afe42d0… ragelink 7608 }
afe42d0… ragelink 7609
afe42d0… ragelink 7610 // Normalize opt.queue - true/undefined/null -> "fx"
afe42d0… ragelink 7611 if ( opt.queue == null || opt.queue === true ) {
afe42d0… ragelink 7612 opt.queue = "fx";
afe42d0… ragelink 7613 }
afe42d0… ragelink 7614
afe42d0… ragelink 7615 // Queueing
afe42d0… ragelink 7616 opt.old = opt.complete;
afe42d0… ragelink 7617
afe42d0… ragelink 7618 opt.complete = function() {
afe42d0… ragelink 7619 if ( isFunction( opt.old ) ) {
afe42d0… ragelink 7620 opt.old.call( this );
afe42d0… ragelink 7621 }
afe42d0… ragelink 7622
afe42d0… ragelink 7623 if ( opt.queue ) {
afe42d0… ragelink 7624 jQuery.dequeue( this, opt.queue );
afe42d0… ragelink 7625 }
afe42d0… ragelink 7626 };
afe42d0… ragelink 7627
afe42d0… ragelink 7628 return opt;
afe42d0… ragelink 7629 };
afe42d0… ragelink 7630
afe42d0… ragelink 7631 jQuery.fn.extend( {
afe42d0… ragelink 7632 fadeTo: function( speed, to, easing, callback ) {
afe42d0… ragelink 7633
afe42d0… ragelink 7634 // Show any hidden elements after setting opacity to 0
afe42d0… ragelink 7635 return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show()
afe42d0… ragelink 7636
afe42d0… ragelink 7637 // Animate to the value specified
afe42d0… ragelink 7638 .end().animate( { opacity: to }, speed, easing, callback );
afe42d0… ragelink 7639 },
afe42d0… ragelink 7640 animate: function( prop, speed, easing, callback ) {
afe42d0… ragelink 7641 var empty = jQuery.isEmptyObject( prop ),
afe42d0… ragelink 7642 optall = jQuery.speed( speed, easing, callback ),
afe42d0… ragelink 7643 doAnimation = function() {
afe42d0… ragelink 7644
afe42d0… ragelink 7645 // Operate on a copy of prop so per-property easing won't be lost
afe42d0… ragelink 7646 var anim = Animation( this, jQuery.extend( {}, prop ), optall );
afe42d0… ragelink 7647
afe42d0… ragelink 7648 // Empty animations, or finishing resolves immediately
afe42d0… ragelink 7649 if ( empty || dataPriv.get( this, "finish" ) ) {
afe42d0… ragelink 7650 anim.stop( true );
afe42d0… ragelink 7651 }
afe42d0… ragelink 7652 };
afe42d0… ragelink 7653
afe42d0… ragelink 7654 doAnimation.finish = doAnimation;
afe42d0… ragelink 7655
afe42d0… ragelink 7656 return empty || optall.queue === false ?
afe42d0… ragelink 7657 this.each( doAnimation ) :
afe42d0… ragelink 7658 this.queue( optall.queue, doAnimation );
afe42d0… ragelink 7659 },
afe42d0… ragelink 7660 stop: function( type, clearQueue, gotoEnd ) {
afe42d0… ragelink 7661 var stopQueue = function( hooks ) {
afe42d0… ragelink 7662 var stop = hooks.stop;
afe42d0… ragelink 7663 delete hooks.stop;
afe42d0… ragelink 7664 stop( gotoEnd );
afe42d0… ragelink 7665 };
afe42d0… ragelink 7666
afe42d0… ragelink 7667 if ( typeof type !== "string" ) {
afe42d0… ragelink 7668 gotoEnd = clearQueue;
afe42d0… ragelink 7669 clearQueue = type;
afe42d0… ragelink 7670 type = undefined;
afe42d0… ragelink 7671 }
afe42d0… ragelink 7672 if ( clearQueue ) {
afe42d0… ragelink 7673 this.queue( type || "fx", [] );
afe42d0… ragelink 7674 }
afe42d0… ragelink 7675
afe42d0… ragelink 7676 return this.each( function() {
afe42d0… ragelink 7677 var dequeue = true,
afe42d0… ragelink 7678 index = type != null && type + "queueHooks",
afe42d0… ragelink 7679 timers = jQuery.timers,
afe42d0… ragelink 7680 data = dataPriv.get( this );
afe42d0… ragelink 7681
afe42d0… ragelink 7682 if ( index ) {
afe42d0… ragelink 7683 if ( data[ index ] && data[ index ].stop ) {
afe42d0… ragelink 7684 stopQueue( data[ index ] );
afe42d0… ragelink 7685 }
afe42d0… ragelink 7686 } else {
afe42d0… ragelink 7687 for ( index in data ) {
afe42d0… ragelink 7688 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
afe42d0… ragelink 7689 stopQueue( data[ index ] );
afe42d0… ragelink 7690 }
afe42d0… ragelink 7691 }
afe42d0… ragelink 7692 }
afe42d0… ragelink 7693
afe42d0… ragelink 7694 for ( index = timers.length; index--; ) {
afe42d0… ragelink 7695 if ( timers[ index ].elem === this &&
afe42d0… ragelink 7696 ( type == null || timers[ index ].queue === type ) ) {
afe42d0… ragelink 7697
afe42d0… ragelink 7698 timers[ index ].anim.stop( gotoEnd );
afe42d0… ragelink 7699 dequeue = false;
afe42d0… ragelink 7700 timers.splice( index, 1 );
afe42d0… ragelink 7701 }
afe42d0… ragelink 7702 }
afe42d0… ragelink 7703
afe42d0… ragelink 7704 // Start the next in the queue if the last step wasn't forced.
afe42d0… ragelink 7705 // Timers currently will call their complete callbacks, which
afe42d0… ragelink 7706 // will dequeue but only if they were gotoEnd.
afe42d0… ragelink 7707 if ( dequeue || !gotoEnd ) {
afe42d0… ragelink 7708 jQuery.dequeue( this, type );
afe42d0… ragelink 7709 }
afe42d0… ragelink 7710 } );
afe42d0… ragelink 7711 },
afe42d0… ragelink 7712 finish: function( type ) {
afe42d0… ragelink 7713 if ( type !== false ) {
afe42d0… ragelink 7714 type = type || "fx";
afe42d0… ragelink 7715 }
afe42d0… ragelink 7716 return this.each( function() {
afe42d0… ragelink 7717 var index,
afe42d0… ragelink 7718 data = dataPriv.get( this ),
afe42d0… ragelink 7719 queue = data[ type + "queue" ],
afe42d0… ragelink 7720 hooks = data[ type + "queueHooks" ],
afe42d0… ragelink 7721 timers = jQuery.timers,
afe42d0… ragelink 7722 length = queue ? queue.length : 0;
afe42d0… ragelink 7723
afe42d0… ragelink 7724 // Enable finishing flag on private data
afe42d0… ragelink 7725 data.finish = true;
afe42d0… ragelink 7726
afe42d0… ragelink 7727 // Empty the queue first
afe42d0… ragelink 7728 jQuery.queue( this, type, [] );
afe42d0… ragelink 7729
afe42d0… ragelink 7730 if ( hooks && hooks.stop ) {
afe42d0… ragelink 7731 hooks.stop.call( this, true );
afe42d0… ragelink 7732 }
afe42d0… ragelink 7733
afe42d0… ragelink 7734 // Look for any active animations, and finish them
afe42d0… ragelink 7735 for ( index = timers.length; index--; ) {
afe42d0… ragelink 7736 if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
afe42d0… ragelink 7737 timers[ index ].anim.stop( true );
afe42d0… ragelink 7738 timers.splice( index, 1 );
afe42d0… ragelink 7739 }
afe42d0… ragelink 7740 }
afe42d0… ragelink 7741
afe42d0… ragelink 7742 // Look for any animations in the old queue and finish them
afe42d0… ragelink 7743 for ( index = 0; index < length; index++ ) {
afe42d0… ragelink 7744 if ( queue[ index ] && queue[ index ].finish ) {
afe42d0… ragelink 7745 queue[ index ].finish.call( this );
afe42d0… ragelink 7746 }
afe42d0… ragelink 7747 }
afe42d0… ragelink 7748
afe42d0… ragelink 7749 // Turn off finishing flag
afe42d0… ragelink 7750 delete data.finish;
afe42d0… ragelink 7751 } );
afe42d0… ragelink 7752 }
afe42d0… ragelink 7753 } );
afe42d0… ragelink 7754
afe42d0… ragelink 7755 jQuery.each( [ "toggle", "show", "hide" ], function( _i, name ) {
afe42d0… ragelink 7756 var cssFn = jQuery.fn[ name ];
afe42d0… ragelink 7757 jQuery.fn[ name ] = function( speed, easing, callback ) {
afe42d0… ragelink 7758 return speed == null || typeof speed === "boolean" ?
afe42d0… ragelink 7759 cssFn.apply( this, arguments ) :
afe42d0… ragelink 7760 this.animate( genFx( name, true ), speed, easing, callback );
afe42d0… ragelink 7761 };
afe42d0… ragelink 7762 } );
afe42d0… ragelink 7763
afe42d0… ragelink 7764 // Generate shortcuts for custom animations
afe42d0… ragelink 7765 jQuery.each( {
afe42d0… ragelink 7766 slideDown: genFx( "show" ),
afe42d0… ragelink 7767 slideUp: genFx( "hide" ),
afe42d0… ragelink 7768 slideToggle: genFx( "toggle" ),
afe42d0… ragelink 7769 fadeIn: { opacity: "show" },
afe42d0… ragelink 7770 fadeOut: { opacity: "hide" },
afe42d0… ragelink 7771 fadeToggle: { opacity: "toggle" }
afe42d0… ragelink 7772 }, function( name, props ) {
afe42d0… ragelink 7773 jQuery.fn[ name ] = function( speed, easing, callback ) {
afe42d0… ragelink 7774 return this.animate( props, speed, easing, callback );
afe42d0… ragelink 7775 };
afe42d0… ragelink 7776 } );
afe42d0… ragelink 7777
afe42d0… ragelink 7778 jQuery.timers = [];
afe42d0… ragelink 7779 jQuery.fx.tick = function() {
afe42d0… ragelink 7780 var timer,
afe42d0… ragelink 7781 i = 0,
afe42d0… ragelink 7782 timers = jQuery.timers;
afe42d0… ragelink 7783
afe42d0… ragelink 7784 fxNow = Date.now();
afe42d0… ragelink 7785
afe42d0… ragelink 7786 for ( ; i < timers.length; i++ ) {
afe42d0… ragelink 7787 timer = timers[ i ];
afe42d0… ragelink 7788
afe42d0… ragelink 7789 // Run the timer and safely remove it when done (allowing for external removal)
afe42d0… ragelink 7790 if ( !timer() && timers[ i ] === timer ) {
afe42d0… ragelink 7791 timers.splice( i--, 1 );
afe42d0… ragelink 7792 }
afe42d0… ragelink 7793 }
afe42d0… ragelink 7794
afe42d0… ragelink 7795 if ( !timers.length ) {
afe42d0… ragelink 7796 jQuery.fx.stop();
afe42d0… ragelink 7797 }
afe42d0… ragelink 7798 fxNow = undefined;
afe42d0… ragelink 7799 };
afe42d0… ragelink 7800
afe42d0… ragelink 7801 jQuery.fx.timer = function( timer ) {
afe42d0… ragelink 7802 jQuery.timers.push( timer );
afe42d0… ragelink 7803 jQuery.fx.start();
afe42d0… ragelink 7804 };
afe42d0… ragelink 7805
afe42d0… ragelink 7806 jQuery.fx.interval = 13;
afe42d0… ragelink 7807 jQuery.fx.start = function() {
afe42d0… ragelink 7808 if ( inProgress ) {
afe42d0… ragelink 7809 return;
afe42d0… ragelink 7810 }
afe42d0… ragelink 7811
afe42d0… ragelink 7812 inProgress = true;
afe42d0… ragelink 7813 schedule();
afe42d0… ragelink 7814 };
afe42d0… ragelink 7815
afe42d0… ragelink 7816 jQuery.fx.stop = function() {
afe42d0… ragelink 7817 inProgress = null;
afe42d0… ragelink 7818 };
afe42d0… ragelink 7819
afe42d0… ragelink 7820 jQuery.fx.speeds = {
afe42d0… ragelink 7821 slow: 600,
afe42d0… ragelink 7822 fast: 200,
afe42d0… ragelink 7823
afe42d0… ragelink 7824 // Default speed
afe42d0… ragelink 7825 _default: 400
afe42d0… ragelink 7826 };
afe42d0… ragelink 7827
afe42d0… ragelink 7828
afe42d0… ragelink 7829 // Based off of the plugin by Clint Helfers, with permission.
afe42d0… ragelink 7830 jQuery.fn.delay = function( time, type ) {
afe42d0… ragelink 7831 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
afe42d0… ragelink 7832 type = type || "fx";
afe42d0… ragelink 7833
afe42d0… ragelink 7834 return this.queue( type, function( next, hooks ) {
afe42d0… ragelink 7835 var timeout = window.setTimeout( next, time );
afe42d0… ragelink 7836 hooks.stop = function() {
afe42d0… ragelink 7837 window.clearTimeout( timeout );
afe42d0… ragelink 7838 };
afe42d0… ragelink 7839 } );
afe42d0… ragelink 7840 };
afe42d0… ragelink 7841
afe42d0… ragelink 7842
afe42d0… ragelink 7843 ( function() {
afe42d0… ragelink 7844 var input = document.createElement( "input" ),
afe42d0… ragelink 7845 select = document.createElement( "select" ),
afe42d0… ragelink 7846 opt = select.appendChild( document.createElement( "option" ) );
afe42d0… ragelink 7847
afe42d0… ragelink 7848 input.type = "checkbox";
afe42d0… ragelink 7849
afe42d0… ragelink 7850 // Support: Android <=4.3 only
afe42d0… ragelink 7851 // Default value for a checkbox should be "on"
afe42d0… ragelink 7852 support.checkOn = input.value !== "";
afe42d0… ragelink 7853
afe42d0… ragelink 7854 // Support: IE <=11 only
afe42d0… ragelink 7855 // Must access selectedIndex to make default options select
afe42d0… ragelink 7856 support.optSelected = opt.selected;
afe42d0… ragelink 7857
afe42d0… ragelink 7858 // Support: IE <=11 only
afe42d0… ragelink 7859 // An input loses its value after becoming a radio
afe42d0… ragelink 7860 input = document.createElement( "input" );
afe42d0… ragelink 7861 input.value = "t";
afe42d0… ragelink 7862 input.type = "radio";
afe42d0… ragelink 7863 support.radioValue = input.value === "t";
afe42d0… ragelink 7864 } )();
afe42d0… ragelink 7865
afe42d0… ragelink 7866
afe42d0… ragelink 7867 var boolHook,
afe42d0… ragelink 7868 attrHandle = jQuery.expr.attrHandle;
afe42d0… ragelink 7869
afe42d0… ragelink 7870 jQuery.fn.extend( {
afe42d0… ragelink 7871 attr: function( name, value ) {
afe42d0… ragelink 7872 return access( this, jQuery.attr, name, value, arguments.length > 1 );
afe42d0… ragelink 7873 },
afe42d0… ragelink 7874
afe42d0… ragelink 7875 removeAttr: function( name ) {
afe42d0… ragelink 7876 return this.each( function() {
afe42d0… ragelink 7877 jQuery.removeAttr( this, name );
afe42d0… ragelink 7878 } );
afe42d0… ragelink 7879 }
afe42d0… ragelink 7880 } );
afe42d0… ragelink 7881
afe42d0… ragelink 7882 jQuery.extend( {
afe42d0… ragelink 7883 attr: function( elem, name, value ) {
afe42d0… ragelink 7884 var ret, hooks,
afe42d0… ragelink 7885 nType = elem.nodeType;
afe42d0… ragelink 7886
afe42d0… ragelink 7887 // Don't get/set attributes on text, comment and attribute nodes
afe42d0… ragelink 7888 if ( nType === 3 || nType === 8 || nType === 2 ) {
afe42d0… ragelink 7889 return;
afe42d0… ragelink 7890 }
afe42d0… ragelink 7891
afe42d0… ragelink 7892 // Fallback to prop when attributes are not supported
afe42d0… ragelink 7893 if ( typeof elem.getAttribute === "undefined" ) {
afe42d0… ragelink 7894 return jQuery.prop( elem, name, value );
afe42d0… ragelink 7895 }
afe42d0… ragelink 7896
afe42d0… ragelink 7897 // Attribute hooks are determined by the lowercase version
afe42d0… ragelink 7898 // Grab necessary hook if one is defined
afe42d0… ragelink 7899 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
afe42d0… ragelink 7900 hooks = jQuery.attrHooks[ name.toLowerCase() ] ||
afe42d0… ragelink 7901 ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
afe42d0… ragelink 7902 }
afe42d0… ragelink 7903
afe42d0… ragelink 7904 if ( value !== undefined ) {
afe42d0… ragelink 7905 if ( value === null ) {
afe42d0… ragelink 7906 jQuery.removeAttr( elem, name );
afe42d0… ragelink 7907 return;
afe42d0… ragelink 7908 }
afe42d0… ragelink 7909
afe42d0… ragelink 7910 if ( hooks && "set" in hooks &&
afe42d0… ragelink 7911 ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
afe42d0… ragelink 7912 return ret;
afe42d0… ragelink 7913 }
afe42d0… ragelink 7914
afe42d0… ragelink 7915 elem.setAttribute( name, value + "" );
afe42d0… ragelink 7916 return value;
afe42d0… ragelink 7917 }
afe42d0… ragelink 7918
afe42d0… ragelink 7919 if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
afe42d0… ragelink 7920 return ret;
afe42d0… ragelink 7921 }
afe42d0… ragelink 7922
afe42d0… ragelink 7923 ret = jQuery.find.attr( elem, name );
afe42d0… ragelink 7924
afe42d0… ragelink 7925 // Non-existent attributes return null, we normalize to undefined
afe42d0… ragelink 7926 return ret == null ? undefined : ret;
afe42d0… ragelink 7927 },
afe42d0… ragelink 7928
afe42d0… ragelink 7929 attrHooks: {
afe42d0… ragelink 7930 type: {
afe42d0… ragelink 7931 set: function( elem, value ) {
afe42d0… ragelink 7932 if ( !support.radioValue && value === "radio" &&
afe42d0… ragelink 7933 nodeName( elem, "input" ) ) {
afe42d0… ragelink 7934 var val = elem.value;
afe42d0… ragelink 7935 elem.setAttribute( "type", value );
afe42d0… ragelink 7936 if ( val ) {
afe42d0… ragelink 7937 elem.value = val;
afe42d0… ragelink 7938 }
afe42d0… ragelink 7939 return value;
afe42d0… ragelink 7940 }
afe42d0… ragelink 7941 }
afe42d0… ragelink 7942 }
afe42d0… ragelink 7943 },
afe42d0… ragelink 7944
afe42d0… ragelink 7945 removeAttr: function( elem, value ) {
afe42d0… ragelink 7946 var name,
afe42d0… ragelink 7947 i = 0,
afe42d0… ragelink 7948
afe42d0… ragelink 7949 // Attribute names can contain non-HTML whitespace characters
afe42d0… ragelink 7950 // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
afe42d0… ragelink 7951 attrNames = value && value.match( rnothtmlwhite );
afe42d0… ragelink 7952
afe42d0… ragelink 7953 if ( attrNames && elem.nodeType === 1 ) {
afe42d0… ragelink 7954 while ( ( name = attrNames[ i++ ] ) ) {
afe42d0… ragelink 7955 elem.removeAttribute( name );
afe42d0… ragelink 7956 }
afe42d0… ragelink 7957 }
afe42d0… ragelink 7958 }
afe42d0… ragelink 7959 } );
afe42d0… ragelink 7960
afe42d0… ragelink 7961 // Hooks for boolean attributes
afe42d0… ragelink 7962 boolHook = {
afe42d0… ragelink 7963 set: function( elem, value, name ) {
afe42d0… ragelink 7964 if ( value === false ) {
afe42d0… ragelink 7965
afe42d0… ragelink 7966 // Remove boolean attributes when set to false
afe42d0… ragelink 7967 jQuery.removeAttr( elem, name );
afe42d0… ragelink 7968 } else {
afe42d0… ragelink 7969 elem.setAttribute( name, name );
afe42d0… ragelink 7970 }
afe42d0… ragelink 7971 return name;
afe42d0… ragelink 7972 }
afe42d0… ragelink 7973 };
afe42d0… ragelink 7974
afe42d0… ragelink 7975 jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( _i, name ) {
afe42d0… ragelink 7976 var getter = attrHandle[ name ] || jQuery.find.attr;
afe42d0… ragelink 7977
afe42d0… ragelink 7978 attrHandle[ name ] = function( elem, name, isXML ) {
afe42d0… ragelink 7979 var ret, handle,
afe42d0… ragelink 7980 lowercaseName = name.toLowerCase();
afe42d0… ragelink 7981
afe42d0… ragelink 7982 if ( !isXML ) {
afe42d0… ragelink 7983
afe42d0… ragelink 7984 // Avoid an infinite loop by temporarily removing this function from the getter
afe42d0… ragelink 7985 handle = attrHandle[ lowercaseName ];
afe42d0… ragelink 7986 attrHandle[ lowercaseName ] = ret;
afe42d0… ragelink 7987 ret = getter( elem, name, isXML ) != null ?
afe42d0… ragelink 7988 lowercaseName :
afe42d0… ragelink 7989 null;
afe42d0… ragelink 7990 attrHandle[ lowercaseName ] = handle;
afe42d0… ragelink 7991 }
afe42d0… ragelink 7992 return ret;
afe42d0… ragelink 7993 };
afe42d0… ragelink 7994 } );
afe42d0… ragelink 7995
afe42d0… ragelink 7996
afe42d0… ragelink 7997
afe42d0… ragelink 7998
afe42d0… ragelink 7999 var rfocusable = /^(?:input|select|textarea|button)$/i,
afe42d0… ragelink 8000 rclickable = /^(?:a|area)$/i;
afe42d0… ragelink 8001
afe42d0… ragelink 8002 jQuery.fn.extend( {
afe42d0… ragelink 8003 prop: function( name, value ) {
afe42d0… ragelink 8004 return access( this, jQuery.prop, name, value, arguments.length > 1 );
afe42d0… ragelink 8005 },
afe42d0… ragelink 8006
afe42d0… ragelink 8007 removeProp: function( name ) {
afe42d0… ragelink 8008 return this.each( function() {
afe42d0… ragelink 8009 delete this[ jQuery.propFix[ name ] || name ];
afe42d0… ragelink 8010 } );
afe42d0… ragelink 8011 }
afe42d0… ragelink 8012 } );
afe42d0… ragelink 8013
afe42d0… ragelink 8014 jQuery.extend( {
afe42d0… ragelink 8015 prop: function( elem, name, value ) {
afe42d0… ragelink 8016 var ret, hooks,
afe42d0… ragelink 8017 nType = elem.nodeType;
afe42d0… ragelink 8018
afe42d0… ragelink 8019 // Don't get/set properties on text, comment and attribute nodes
afe42d0… ragelink 8020 if ( nType === 3 || nType === 8 || nType === 2 ) {
afe42d0… ragelink 8021 return;
afe42d0… ragelink 8022 }
afe42d0… ragelink 8023
afe42d0… ragelink 8024 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
afe42d0… ragelink 8025
afe42d0… ragelink 8026 // Fix name and attach hooks
afe42d0… ragelink 8027 name = jQuery.propFix[ name ] || name;
afe42d0… ragelink 8028 hooks = jQuery.propHooks[ name ];
afe42d0… ragelink 8029 }
afe42d0… ragelink 8030
afe42d0… ragelink 8031 if ( value !== undefined ) {
afe42d0… ragelink 8032 if ( hooks && "set" in hooks &&
afe42d0… ragelink 8033 ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
afe42d0… ragelink 8034 return ret;
afe42d0… ragelink 8035 }
afe42d0… ragelink 8036
afe42d0… ragelink 8037 return ( elem[ name ] = value );
afe42d0… ragelink 8038 }
afe42d0… ragelink 8039
afe42d0… ragelink 8040 if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
afe42d0… ragelink 8041 return ret;
afe42d0… ragelink 8042 }
afe42d0… ragelink 8043
afe42d0… ragelink 8044 return elem[ name ];
afe42d0… ragelink 8045 },
afe42d0… ragelink 8046
afe42d0… ragelink 8047 propHooks: {
afe42d0… ragelink 8048 tabIndex: {
afe42d0… ragelink 8049 get: function( elem ) {
afe42d0… ragelink 8050
afe42d0… ragelink 8051 // Support: IE <=9 - 11 only
afe42d0… ragelink 8052 // elem.tabIndex doesn't always return the
afe42d0… ragelink 8053 // correct value when it hasn't been explicitly set
afe42d0… ragelink 8054 // Use proper attribute retrieval (trac-12072)
afe42d0… ragelink 8055 var tabindex = jQuery.find.attr( elem, "tabindex" );
afe42d0… ragelink 8056
afe42d0… ragelink 8057 if ( tabindex ) {
afe42d0… ragelink 8058 return parseInt( tabindex, 10 );
afe42d0… ragelink 8059 }
afe42d0… ragelink 8060
afe42d0… ragelink 8061 if (
afe42d0… ragelink 8062 rfocusable.test( elem.nodeName ) ||
afe42d0… ragelink 8063 rclickable.test( elem.nodeName ) &&
afe42d0… ragelink 8064 elem.href
afe42d0… ragelink 8065 ) {
afe42d0… ragelink 8066 return 0;
afe42d0… ragelink 8067 }
afe42d0… ragelink 8068
afe42d0… ragelink 8069 return -1;
afe42d0… ragelink 8070 }
afe42d0… ragelink 8071 }
afe42d0… ragelink 8072 },
afe42d0… ragelink 8073
afe42d0… ragelink 8074 propFix: {
afe42d0… ragelink 8075 "for": "htmlFor",
afe42d0… ragelink 8076 "class": "className"
afe42d0… ragelink 8077 }
afe42d0… ragelink 8078 } );
afe42d0… ragelink 8079
afe42d0… ragelink 8080 // Support: IE <=11 only
afe42d0… ragelink 8081 // Accessing the selectedIndex property
afe42d0… ragelink 8082 // forces the browser to respect setting selected
afe42d0… ragelink 8083 // on the option
afe42d0… ragelink 8084 // The getter ensures a default option is selected
afe42d0… ragelink 8085 // when in an optgroup
afe42d0… ragelink 8086 // eslint rule "no-unused-expressions" is disabled for this code
afe42d0… ragelink 8087 // since it considers such accessions noop
afe42d0… ragelink 8088 if ( !support.optSelected ) {
afe42d0… ragelink 8089 jQuery.propHooks.selected = {
afe42d0… ragelink 8090 get: function( elem ) {
afe42d0… ragelink 8091
afe42d0… ragelink 8092 /* eslint no-unused-expressions: "off" */
afe42d0… ragelink 8093
afe42d0… ragelink 8094 var parent = elem.parentNode;
afe42d0… ragelink 8095 if ( parent && parent.parentNode ) {
afe42d0… ragelink 8096 parent.parentNode.selectedIndex;
afe42d0… ragelink 8097 }
afe42d0… ragelink 8098 return null;
afe42d0… ragelink 8099 },
afe42d0… ragelink 8100 set: function( elem ) {
afe42d0… ragelink 8101
afe42d0… ragelink 8102 /* eslint no-unused-expressions: "off" */
afe42d0… ragelink 8103
afe42d0… ragelink 8104 var parent = elem.parentNode;
afe42d0… ragelink 8105 if ( parent ) {
afe42d0… ragelink 8106 parent.selectedIndex;
afe42d0… ragelink 8107
afe42d0… ragelink 8108 if ( parent.parentNode ) {
afe42d0… ragelink 8109 parent.parentNode.selectedIndex;
afe42d0… ragelink 8110 }
afe42d0… ragelink 8111 }
afe42d0… ragelink 8112 }
afe42d0… ragelink 8113 };
afe42d0… ragelink 8114 }
afe42d0… ragelink 8115
afe42d0… ragelink 8116 jQuery.each( [
afe42d0… ragelink 8117 "tabIndex",
afe42d0… ragelink 8118 "readOnly",
afe42d0… ragelink 8119 "maxLength",
afe42d0… ragelink 8120 "cellSpacing",
afe42d0… ragelink 8121 "cellPadding",
afe42d0… ragelink 8122 "rowSpan",
afe42d0… ragelink 8123 "colSpan",
afe42d0… ragelink 8124 "useMap",
afe42d0… ragelink 8125 "frameBorder",
afe42d0… ragelink 8126 "contentEditable"
afe42d0… ragelink 8127 ], function() {
afe42d0… ragelink 8128 jQuery.propFix[ this.toLowerCase() ] = this;
afe42d0… ragelink 8129 } );
afe42d0… ragelink 8130
afe42d0… ragelink 8131
afe42d0… ragelink 8132
afe42d0… ragelink 8133
afe42d0… ragelink 8134 // Strip and collapse whitespace according to HTML spec
afe42d0… ragelink 8135 // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace
afe42d0… ragelink 8136 function stripAndCollapse( value ) {
afe42d0… ragelink 8137 var tokens = value.match( rnothtmlwhite ) || [];
afe42d0… ragelink 8138 return tokens.join( " " );
afe42d0… ragelink 8139 }
afe42d0… ragelink 8140
afe42d0… ragelink 8141
afe42d0… ragelink 8142 function getClass( elem ) {
afe42d0… ragelink 8143 return elem.getAttribute && elem.getAttribute( "class" ) || "";
afe42d0… ragelink 8144 }
afe42d0… ragelink 8145
afe42d0… ragelink 8146 function classesToArray( value ) {
afe42d0… ragelink 8147 if ( Array.isArray( value ) ) {
afe42d0… ragelink 8148 return value;
afe42d0… ragelink 8149 }
afe42d0… ragelink 8150 if ( typeof value === "string" ) {
afe42d0… ragelink 8151 return value.match( rnothtmlwhite ) || [];
afe42d0… ragelink 8152 }
afe42d0… ragelink 8153 return [];
afe42d0… ragelink 8154 }
afe42d0… ragelink 8155
afe42d0… ragelink 8156 jQuery.fn.extend( {
afe42d0… ragelink 8157 addClass: function( value ) {
afe42d0… ragelink 8158 var classNames, cur, curValue, className, i, finalValue;
afe42d0… ragelink 8159
afe42d0… ragelink 8160 if ( isFunction( value ) ) {
afe42d0… ragelink 8161 return this.each( function( j ) {
afe42d0… ragelink 8162 jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
afe42d0… ragelink 8163 } );
afe42d0… ragelink 8164 }
afe42d0… ragelink 8165
afe42d0… ragelink 8166 classNames = classesToArray( value );
afe42d0… ragelink 8167
afe42d0… ragelink 8168 if ( classNames.length ) {
afe42d0… ragelink 8169 return this.each( function() {
afe42d0… ragelink 8170 curValue = getClass( this );
afe42d0… ragelink 8171 cur = this.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
afe42d0… ragelink 8172
afe42d0… ragelink 8173 if ( cur ) {
afe42d0… ragelink 8174 for ( i = 0; i < classNames.length; i++ ) {
afe42d0… ragelink 8175 className = classNames[ i ];
afe42d0… ragelink 8176 if ( cur.indexOf( " " + className + " " ) < 0 ) {
afe42d0… ragelink 8177 cur += className + " ";
afe42d0… ragelink 8178 }
afe42d0… ragelink 8179 }
afe42d0… ragelink 8180
afe42d0… ragelink 8181 // Only assign if different to avoid unneeded rendering.
afe42d0… ragelink 8182 finalValue = stripAndCollapse( cur );
afe42d0… ragelink 8183 if ( curValue !== finalValue ) {
afe42d0… ragelink 8184 this.setAttribute( "class", finalValue );
afe42d0… ragelink 8185 }
afe42d0… ragelink 8186 }
afe42d0… ragelink 8187 } );
afe42d0… ragelink 8188 }
afe42d0… ragelink 8189
afe42d0… ragelink 8190 return this;
afe42d0… ragelink 8191 },
afe42d0… ragelink 8192
afe42d0… ragelink 8193 removeClass: function( value ) {
afe42d0… ragelink 8194 var classNames, cur, curValue, className, i, finalValue;
afe42d0… ragelink 8195
afe42d0… ragelink 8196 if ( isFunction( value ) ) {
afe42d0… ragelink 8197 return this.each( function( j ) {
afe42d0… ragelink 8198 jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
afe42d0… ragelink 8199 } );
afe42d0… ragelink 8200 }
afe42d0… ragelink 8201
afe42d0… ragelink 8202 if ( !arguments.length ) {
afe42d0… ragelink 8203 return this.attr( "class", "" );
afe42d0… ragelink 8204 }
afe42d0… ragelink 8205
afe42d0… ragelink 8206 classNames = classesToArray( value );
afe42d0… ragelink 8207
afe42d0… ragelink 8208 if ( classNames.length ) {
afe42d0… ragelink 8209 return this.each( function() {
afe42d0… ragelink 8210 curValue = getClass( this );
afe42d0… ragelink 8211
afe42d0… ragelink 8212 // This expression is here for better compressibility (see addClass)
afe42d0… ragelink 8213 cur = this.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
afe42d0… ragelink 8214
afe42d0… ragelink 8215 if ( cur ) {
afe42d0… ragelink 8216 for ( i = 0; i < classNames.length; i++ ) {
afe42d0… ragelink 8217 className = classNames[ i ];
afe42d0… ragelink 8218
afe42d0… ragelink 8219 // Remove *all* instances
afe42d0… ragelink 8220 while ( cur.indexOf( " " + className + " " ) > -1 ) {
afe42d0… ragelink 8221 cur = cur.replace( " " + className + " ", " " );
afe42d0… ragelink 8222 }
afe42d0… ragelink 8223 }
afe42d0… ragelink 8224
afe42d0… ragelink 8225 // Only assign if different to avoid unneeded rendering.
afe42d0… ragelink 8226 finalValue = stripAndCollapse( cur );
afe42d0… ragelink 8227 if ( curValue !== finalValue ) {
afe42d0… ragelink 8228 this.setAttribute( "class", finalValue );
afe42d0… ragelink 8229 }
afe42d0… ragelink 8230 }
afe42d0… ragelink 8231 } );
afe42d0… ragelink 8232 }
afe42d0… ragelink 8233
afe42d0… ragelink 8234 return this;
afe42d0… ragelink 8235 },
afe42d0… ragelink 8236
afe42d0… ragelink 8237 toggleClass: function( value, stateVal ) {
afe42d0… ragelink 8238 var classNames, className, i, self,
afe42d0… ragelink 8239 type = typeof value,
afe42d0… ragelink 8240 isValidValue = type === "string" || Array.isArray( value );
afe42d0… ragelink 8241
afe42d0… ragelink 8242 if ( isFunction( value ) ) {
afe42d0… ragelink 8243 return this.each( function( i ) {
afe42d0… ragelink 8244 jQuery( this ).toggleClass(
afe42d0… ragelink 8245 value.call( this, i, getClass( this ), stateVal ),
afe42d0… ragelink 8246 stateVal
afe42d0… ragelink 8247 );
afe42d0… ragelink 8248 } );
afe42d0… ragelink 8249 }
afe42d0… ragelink 8250
afe42d0… ragelink 8251 if ( typeof stateVal === "boolean" && isValidValue ) {
afe42d0… ragelink 8252 return stateVal ? this.addClass( value ) : this.removeClass( value );
afe42d0… ragelink 8253 }
afe42d0… ragelink 8254
afe42d0… ragelink 8255 classNames = classesToArray( value );
afe42d0… ragelink 8256
afe42d0… ragelink 8257 return this.each( function() {
afe42d0… ragelink 8258 if ( isValidValue ) {
afe42d0… ragelink 8259
afe42d0… ragelink 8260 // Toggle individual class names
afe42d0… ragelink 8261 self = jQuery( this );
afe42d0… ragelink 8262
afe42d0… ragelink 8263 for ( i = 0; i < classNames.length; i++ ) {
afe42d0… ragelink 8264 className = classNames[ i ];
afe42d0… ragelink 8265
afe42d0… ragelink 8266 // Check each className given, space separated list
afe42d0… ragelink 8267 if ( self.hasClass( className ) ) {
afe42d0… ragelink 8268 self.removeClass( className );
afe42d0… ragelink 8269 } else {
afe42d0… ragelink 8270 self.addClass( className );
afe42d0… ragelink 8271 }
afe42d0… ragelink 8272 }
afe42d0… ragelink 8273
afe42d0… ragelink 8274 // Toggle whole class name
afe42d0… ragelink 8275 } else if ( value === undefined || type === "boolean" ) {
afe42d0… ragelink 8276 className = getClass( this );
afe42d0… ragelink 8277 if ( className ) {
afe42d0… ragelink 8278
afe42d0… ragelink 8279 // Store className if set
afe42d0… ragelink 8280 dataPriv.set( this, "__className__", className );
afe42d0… ragelink 8281 }
afe42d0… ragelink 8282
afe42d0… ragelink 8283 // If the element has a class name or if we're passed `false`,
afe42d0… ragelink 8284 // then remove the whole classname (if there was one, the above saved it).
afe42d0… ragelink 8285 // Otherwise bring back whatever was previously saved (if anything),
afe42d0… ragelink 8286 // falling back to the empty string if nothing was stored.
afe42d0… ragelink 8287 if ( this.setAttribute ) {
afe42d0… ragelink 8288 this.setAttribute( "class",
afe42d0… ragelink 8289 className || value === false ?
afe42d0… ragelink 8290 "" :
afe42d0… ragelink 8291 dataPriv.get( this, "__className__" ) || ""
afe42d0… ragelink 8292 );
afe42d0… ragelink 8293 }
afe42d0… ragelink 8294 }
afe42d0… ragelink 8295 } );
afe42d0… ragelink 8296 },
afe42d0… ragelink 8297
afe42d0… ragelink 8298 hasClass: function( selector ) {
afe42d0… ragelink 8299 var className, elem,
afe42d0… ragelink 8300 i = 0;
afe42d0… ragelink 8301
afe42d0… ragelink 8302 className = " " + selector + " ";
afe42d0… ragelink 8303 while ( ( elem = this[ i++ ] ) ) {
afe42d0… ragelink 8304 if ( elem.nodeType === 1 &&
afe42d0… ragelink 8305 ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
afe42d0… ragelink 8306 return true;
afe42d0… ragelink 8307 }
afe42d0… ragelink 8308 }
afe42d0… ragelink 8309
afe42d0… ragelink 8310 return false;
afe42d0… ragelink 8311 }
afe42d0… ragelink 8312 } );
afe42d0… ragelink 8313
afe42d0… ragelink 8314
afe42d0… ragelink 8315
afe42d0… ragelink 8316
afe42d0… ragelink 8317 var rreturn = /\r/g;
afe42d0… ragelink 8318
afe42d0… ragelink 8319 jQuery.fn.extend( {
afe42d0… ragelink 8320 val: function( value ) {
afe42d0… ragelink 8321 var hooks, ret, valueIsFunction,
afe42d0… ragelink 8322 elem = this[ 0 ];
afe42d0… ragelink 8323
afe42d0… ragelink 8324 if ( !arguments.length ) {
afe42d0… ragelink 8325 if ( elem ) {
afe42d0… ragelink 8326 hooks = jQuery.valHooks[ elem.type ] ||
afe42d0… ragelink 8327 jQuery.valHooks[ elem.nodeName.toLowerCase() ];
afe42d0… ragelink 8328
afe42d0… ragelink 8329 if ( hooks &&
afe42d0… ragelink 8330 "get" in hooks &&
afe42d0… ragelink 8331 ( ret = hooks.get( elem, "value" ) ) !== undefined
afe42d0… ragelink 8332 ) {
afe42d0… ragelink 8333 return ret;
afe42d0… ragelink 8334 }
afe42d0… ragelink 8335
afe42d0… ragelink 8336 ret = elem.value;
afe42d0… ragelink 8337
afe42d0… ragelink 8338 // Handle most common string cases
afe42d0… ragelink 8339 if ( typeof ret === "string" ) {
afe42d0… ragelink 8340 return ret.replace( rreturn, "" );
afe42d0… ragelink 8341 }
afe42d0… ragelink 8342
afe42d0… ragelink 8343 // Handle cases where value is null/undef or number
afe42d0… ragelink 8344 return ret == null ? "" : ret;
afe42d0… ragelink 8345 }
afe42d0… ragelink 8346
afe42d0… ragelink 8347 return;
afe42d0… ragelink 8348 }
afe42d0… ragelink 8349
afe42d0… ragelink 8350 valueIsFunction = isFunction( value );
afe42d0… ragelink 8351
afe42d0… ragelink 8352 return this.each( function( i ) {
afe42d0… ragelink 8353 var val;
afe42d0… ragelink 8354
afe42d0… ragelink 8355 if ( this.nodeType !== 1 ) {
afe42d0… ragelink 8356 return;
afe42d0… ragelink 8357 }
afe42d0… ragelink 8358
afe42d0… ragelink 8359 if ( valueIsFunction ) {
afe42d0… ragelink 8360 val = value.call( this, i, jQuery( this ).val() );
afe42d0… ragelink 8361 } else {
afe42d0… ragelink 8362 val = value;
afe42d0… ragelink 8363 }
afe42d0… ragelink 8364
afe42d0… ragelink 8365 // Treat null/undefined as ""; convert numbers to string
afe42d0… ragelink 8366 if ( val == null ) {
afe42d0… ragelink 8367 val = "";
afe42d0… ragelink 8368
afe42d0… ragelink 8369 } else if ( typeof val === "number" ) {
afe42d0… ragelink 8370 val += "";
afe42d0… ragelink 8371
afe42d0… ragelink 8372 } else if ( Array.isArray( val ) ) {
afe42d0… ragelink 8373 val = jQuery.map( val, function( value ) {
afe42d0… ragelink 8374 return value == null ? "" : value + "";
afe42d0… ragelink 8375 } );
afe42d0… ragelink 8376 }
afe42d0… ragelink 8377
afe42d0… ragelink 8378 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
afe42d0… ragelink 8379
afe42d0… ragelink 8380 // If set returns undefined, fall back to normal setting
afe42d0… ragelink 8381 if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
afe42d0… ragelink 8382 this.value = val;
afe42d0… ragelink 8383 }
afe42d0… ragelink 8384 } );
afe42d0… ragelink 8385 }
afe42d0… ragelink 8386 } );
afe42d0… ragelink 8387
afe42d0… ragelink 8388 jQuery.extend( {
afe42d0… ragelink 8389 valHooks: {
afe42d0… ragelink 8390 option: {
afe42d0… ragelink 8391 get: function( elem ) {
afe42d0… ragelink 8392
afe42d0… ragelink 8393 var val = jQuery.find.attr( elem, "value" );
afe42d0… ragelink 8394 return val != null ?
afe42d0… ragelink 8395 val :
afe42d0… ragelink 8396
afe42d0… ragelink 8397 // Support: IE <=10 - 11 only
afe42d0… ragelink 8398 // option.text throws exceptions (trac-14686, trac-14858)
afe42d0… ragelink 8399 // Strip and collapse whitespace
afe42d0… ragelink 8400 // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
afe42d0… ragelink 8401 stripAndCollapse( jQuery.text( elem ) );
afe42d0… ragelink 8402 }
afe42d0… ragelink 8403 },
afe42d0… ragelink 8404 select: {
afe42d0… ragelink 8405 get: function( elem ) {
afe42d0… ragelink 8406 var value, option, i,
afe42d0… ragelink 8407 options = elem.options,
afe42d0… ragelink 8408 index = elem.selectedIndex,
afe42d0… ragelink 8409 one = elem.type === "select-one",
afe42d0… ragelink 8410 values = one ? null : [],
afe42d0… ragelink 8411 max = one ? index + 1 : options.length;
afe42d0… ragelink 8412
afe42d0… ragelink 8413 if ( index < 0 ) {
afe42d0… ragelink 8414 i = max;
afe42d0… ragelink 8415
afe42d0… ragelink 8416 } else {
afe42d0… ragelink 8417 i = one ? index : 0;
afe42d0… ragelink 8418 }
afe42d0… ragelink 8419
afe42d0… ragelink 8420 // Loop through all the selected options
afe42d0… ragelink 8421 for ( ; i < max; i++ ) {
afe42d0… ragelink 8422 option = options[ i ];
afe42d0… ragelink 8423
afe42d0… ragelink 8424 // Support: IE <=9 only
afe42d0… ragelink 8425 // IE8-9 doesn't update selected after form reset (trac-2551)
afe42d0… ragelink 8426 if ( ( option.selected || i === index ) &&
afe42d0… ragelink 8427
afe42d0… ragelink 8428 // Don't return options that are disabled or in a disabled optgroup
afe42d0… ragelink 8429 !option.disabled &&
afe42d0… ragelink 8430 ( !option.parentNode.disabled ||
afe42d0… ragelink 8431 !nodeName( option.parentNode, "optgroup" ) ) ) {
afe42d0… ragelink 8432
afe42d0… ragelink 8433 // Get the specific value for the option
afe42d0… ragelink 8434 value = jQuery( option ).val();
afe42d0… ragelink 8435
afe42d0… ragelink 8436 // We don't need an array for one selects
afe42d0… ragelink 8437 if ( one ) {
afe42d0… ragelink 8438 return value;
afe42d0… ragelink 8439 }
afe42d0… ragelink 8440
afe42d0… ragelink 8441 // Multi-Selects return an array
afe42d0… ragelink 8442 values.push( value );
afe42d0… ragelink 8443 }
afe42d0… ragelink 8444 }
afe42d0… ragelink 8445
afe42d0… ragelink 8446 return values;
afe42d0… ragelink 8447 },
afe42d0… ragelink 8448
afe42d0… ragelink 8449 set: function( elem, value ) {
afe42d0… ragelink 8450 var optionSet, option,
afe42d0… ragelink 8451 options = elem.options,
afe42d0… ragelink 8452 values = jQuery.makeArray( value ),
afe42d0… ragelink 8453 i = options.length;
afe42d0… ragelink 8454
afe42d0… ragelink 8455 while ( i-- ) {
afe42d0… ragelink 8456 option = options[ i ];
afe42d0… ragelink 8457
afe42d0… ragelink 8458 /* eslint-disable no-cond-assign */
afe42d0… ragelink 8459
afe42d0… ragelink 8460 if ( option.selected =
afe42d0… ragelink 8461 jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
afe42d0… ragelink 8462 ) {
afe42d0… ragelink 8463 optionSet = true;
afe42d0… ragelink 8464 }
afe42d0… ragelink 8465
afe42d0… ragelink 8466 /* eslint-enable no-cond-assign */
afe42d0… ragelink 8467 }
afe42d0… ragelink 8468
afe42d0… ragelink 8469 // Force browsers to behave consistently when non-matching value is set
afe42d0… ragelink 8470 if ( !optionSet ) {
afe42d0… ragelink 8471 elem.selectedIndex = -1;
afe42d0… ragelink 8472 }
afe42d0… ragelink 8473 return values;
afe42d0… ragelink 8474 }
afe42d0… ragelink 8475 }
afe42d0… ragelink 8476 }
afe42d0… ragelink 8477 } );
afe42d0… ragelink 8478
afe42d0… ragelink 8479 // Radios and checkboxes getter/setter
afe42d0… ragelink 8480 jQuery.each( [ "radio", "checkbox" ], function() {
afe42d0… ragelink 8481 jQuery.valHooks[ this ] = {
afe42d0… ragelink 8482 set: function( elem, value ) {
afe42d0… ragelink 8483 if ( Array.isArray( value ) ) {
afe42d0… ragelink 8484 return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
afe42d0… ragelink 8485 }
afe42d0… ragelink 8486 }
afe42d0… ragelink 8487 };
afe42d0… ragelink 8488 if ( !support.checkOn ) {
afe42d0… ragelink 8489 jQuery.valHooks[ this ].get = function( elem ) {
afe42d0… ragelink 8490 return elem.getAttribute( "value" ) === null ? "on" : elem.value;
afe42d0… ragelink 8491 };
afe42d0… ragelink 8492 }
afe42d0… ragelink 8493 } );
afe42d0… ragelink 8494
afe42d0… ragelink 8495
afe42d0… ragelink 8496
afe42d0… ragelink 8497
afe42d0… ragelink 8498 // Return jQuery for attributes-only inclusion
afe42d0… ragelink 8499 var location = window.location;
afe42d0… ragelink 8500
afe42d0… ragelink 8501 var nonce = { guid: Date.now() };
afe42d0… ragelink 8502
afe42d0… ragelink 8503 var rquery = ( /\?/ );
afe42d0… ragelink 8504
afe42d0… ragelink 8505
afe42d0… ragelink 8506
afe42d0… ragelink 8507 // Cross-browser xml parsing
afe42d0… ragelink 8508 jQuery.parseXML = function( data ) {
afe42d0… ragelink 8509 var xml, parserErrorElem;
afe42d0… ragelink 8510 if ( !data || typeof data !== "string" ) {
afe42d0… ragelink 8511 return null;
afe42d0… ragelink 8512 }
afe42d0… ragelink 8513
afe42d0… ragelink 8514 // Support: IE 9 - 11 only
afe42d0… ragelink 8515 // IE throws on parseFromString with invalid input.
afe42d0… ragelink 8516 try {
afe42d0… ragelink 8517 xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
afe42d0… ragelink 8518 } catch ( e ) {}
afe42d0… ragelink 8519
afe42d0… ragelink 8520 parserErrorElem = xml && xml.getElementsByTagName( "parsererror" )[ 0 ];
afe42d0… ragelink 8521 if ( !xml || parserErrorElem ) {
afe42d0… ragelink 8522 jQuery.error( "Invalid XML: " + (
afe42d0… ragelink 8523 parserErrorElem ?
afe42d0… ragelink 8524 jQuery.map( parserErrorElem.childNodes, function( el ) {
afe42d0… ragelink 8525 return el.textContent;
afe42d0… ragelink 8526 } ).join( "\n" ) :
afe42d0… ragelink 8527 data
afe42d0… ragelink 8528 ) );
afe42d0… ragelink 8529 }
afe42d0… ragelink 8530 return xml;
afe42d0… ragelink 8531 };
afe42d0… ragelink 8532
afe42d0… ragelink 8533
afe42d0… ragelink 8534 var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
afe42d0… ragelink 8535 stopPropagationCallback = function( e ) {
afe42d0… ragelink 8536 e.stopPropagation();
afe42d0… ragelink 8537 };
afe42d0… ragelink 8538
afe42d0… ragelink 8539 jQuery.extend( jQuery.event, {
afe42d0… ragelink 8540
afe42d0… ragelink 8541 trigger: function( event, data, elem, onlyHandlers ) {
afe42d0… ragelink 8542
afe42d0… ragelink 8543 var i, cur, tmp, bubbleType, ontype, handle, special, lastElement,
afe42d0… ragelink 8544 eventPath = [ elem || document ],
afe42d0… ragelink 8545 type = hasOwn.call( event, "type" ) ? event.type : event,
afe42d0… ragelink 8546 namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
afe42d0… ragelink 8547
afe42d0… ragelink 8548 cur = lastElement = tmp = elem = elem || document;
afe42d0… ragelink 8549
afe42d0… ragelink 8550 // Don't do events on text and comment nodes
afe42d0… ragelink 8551 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
afe42d0… ragelink 8552 return;
afe42d0… ragelink 8553 }
afe42d0… ragelink 8554
afe42d0… ragelink 8555 // focus/blur morphs to focusin/out; ensure we're not firing them right now
afe42d0… ragelink 8556 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
afe42d0… ragelink 8557 return;
afe42d0… ragelink 8558 }
afe42d0… ragelink 8559
afe42d0… ragelink 8560 if ( type.indexOf( "." ) > -1 ) {
afe42d0… ragelink 8561
afe42d0… ragelink 8562 // Namespaced trigger; create a regexp to match event type in handle()
afe42d0… ragelink 8563 namespaces = type.split( "." );
afe42d0… ragelink 8564 type = namespaces.shift();
afe42d0… ragelink 8565 namespaces.sort();
afe42d0… ragelink 8566 }
afe42d0… ragelink 8567 ontype = type.indexOf( ":" ) < 0 && "on" + type;
afe42d0… ragelink 8568
afe42d0… ragelink 8569 // Caller can pass in a jQuery.Event object, Object, or just an event type string
afe42d0… ragelink 8570 event = event[ jQuery.expando ] ?
afe42d0… ragelink 8571 event :
afe42d0… ragelink 8572 new jQuery.Event( type, typeof event === "object" && event );
afe42d0… ragelink 8573
afe42d0… ragelink 8574 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
afe42d0… ragelink 8575 event.isTrigger = onlyHandlers ? 2 : 3;
afe42d0… ragelink 8576 event.namespace = namespaces.join( "." );
afe42d0… ragelink 8577 event.rnamespace = event.namespace ?
afe42d0… ragelink 8578 new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
afe42d0… ragelink 8579 null;
afe42d0… ragelink 8580
afe42d0… ragelink 8581 // Clean up the event in case it is being reused
afe42d0… ragelink 8582 event.result = undefined;
afe42d0… ragelink 8583 if ( !event.target ) {
afe42d0… ragelink 8584 event.target = elem;
afe42d0… ragelink 8585 }
afe42d0… ragelink 8586
afe42d0… ragelink 8587 // Clone any incoming data and prepend the event, creating the handler arg list
afe42d0… ragelink 8588 data = data == null ?
afe42d0… ragelink 8589 [ event ] :
afe42d0… ragelink 8590 jQuery.makeArray( data, [ event ] );
afe42d0… ragelink 8591
afe42d0… ragelink 8592 // Allow special events to draw outside the lines
afe42d0… ragelink 8593 special = jQuery.event.special[ type ] || {};
afe42d0… ragelink 8594 if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
afe42d0… ragelink 8595 return;
afe42d0… ragelink 8596 }
afe42d0… ragelink 8597
afe42d0… ragelink 8598 // Determine event propagation path in advance, per W3C events spec (trac-9951)
afe42d0… ragelink 8599 // Bubble up to document, then to window; watch for a global ownerDocument var (trac-9724)
afe42d0… ragelink 8600 if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) {
afe42d0… ragelink 8601
afe42d0… ragelink 8602 bubbleType = special.delegateType || type;
afe42d0… ragelink 8603 if ( !rfocusMorph.test( bubbleType + type ) ) {
afe42d0… ragelink 8604 cur = cur.parentNode;
afe42d0… ragelink 8605 }
afe42d0… ragelink 8606 for ( ; cur; cur = cur.parentNode ) {
afe42d0… ragelink 8607 eventPath.push( cur );
afe42d0… ragelink 8608 tmp = cur;
afe42d0… ragelink 8609 }
afe42d0… ragelink 8610
afe42d0… ragelink 8611 // Only add window if we got to document (e.g., not plain obj or detached DOM)
afe42d0… ragelink 8612 if ( tmp === ( elem.ownerDocument || document ) ) {
afe42d0… ragelink 8613 eventPath.push( tmp.defaultView || tmp.parentWindow || window );
afe42d0… ragelink 8614 }
afe42d0… ragelink 8615 }
afe42d0… ragelink 8616
afe42d0… ragelink 8617 // Fire handlers on the event path
afe42d0… ragelink 8618 i = 0;
afe42d0… ragelink 8619 while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
afe42d0… ragelink 8620 lastElement = cur;
afe42d0… ragelink 8621 event.type = i > 1 ?
afe42d0… ragelink 8622 bubbleType :
afe42d0… ragelink 8623 special.bindType || type;
afe42d0… ragelink 8624
afe42d0… ragelink 8625 // jQuery handler
afe42d0… ragelink 8626 handle = ( dataPriv.get( cur, "events" ) || Object.create( null ) )[ event.type ] &&
afe42d0… ragelink 8627 dataPriv.get( cur, "handle" );
afe42d0… ragelink 8628 if ( handle ) {
afe42d0… ragelink 8629 handle.apply( cur, data );
afe42d0… ragelink 8630 }
afe42d0… ragelink 8631
afe42d0… ragelink 8632 // Native handler
afe42d0… ragelink 8633 handle = ontype && cur[ ontype ];
afe42d0… ragelink 8634 if ( handle && handle.apply && acceptData( cur ) ) {
afe42d0… ragelink 8635 event.result = handle.apply( cur, data );
afe42d0… ragelink 8636 if ( event.result === false ) {
afe42d0… ragelink 8637 event.preventDefault();
afe42d0… ragelink 8638 }
afe42d0… ragelink 8639 }
afe42d0… ragelink 8640 }
afe42d0… ragelink 8641 event.type = type;
afe42d0… ragelink 8642
afe42d0… ragelink 8643 // If nobody prevented the default action, do it now
afe42d0… ragelink 8644 if ( !onlyHandlers && !event.isDefaultPrevented() ) {
afe42d0… ragelink 8645
afe42d0… ragelink 8646 if ( ( !special._default ||
afe42d0… ragelink 8647 special._default.apply( eventPath.pop(), data ) === false ) &&
afe42d0… ragelink 8648 acceptData( elem ) ) {
afe42d0… ragelink 8649
afe42d0… ragelink 8650 // Call a native DOM method on the target with the same name as the event.
afe42d0… ragelink 8651 // Don't do default actions on window, that's where global variables be (trac-6170)
afe42d0… ragelink 8652 if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) {
afe42d0… ragelink 8653
afe42d0… ragelink 8654 // Don't re-trigger an onFOO event when we call its FOO() method
afe42d0… ragelink 8655 tmp = elem[ ontype ];
afe42d0… ragelink 8656
afe42d0… ragelink 8657 if ( tmp ) {
afe42d0… ragelink 8658 elem[ ontype ] = null;
afe42d0… ragelink 8659 }
afe42d0… ragelink 8660
afe42d0… ragelink 8661 // Prevent re-triggering of the same event, since we already bubbled it above
afe42d0… ragelink 8662 jQuery.event.triggered = type;
afe42d0… ragelink 8663
afe42d0… ragelink 8664 if ( event.isPropagationStopped() ) {
afe42d0… ragelink 8665 lastElement.addEventListener( type, stopPropagationCallback );
afe42d0… ragelink 8666 }
afe42d0… ragelink 8667
afe42d0… ragelink 8668 elem[ type ]();
afe42d0… ragelink 8669
afe42d0… ragelink 8670 if ( event.isPropagationStopped() ) {
afe42d0… ragelink 8671 lastElement.removeEventListener( type, stopPropagationCallback );
afe42d0… ragelink 8672 }
afe42d0… ragelink 8673
afe42d0… ragelink 8674 jQuery.event.triggered = undefined;
afe42d0… ragelink 8675
afe42d0… ragelink 8676 if ( tmp ) {
afe42d0… ragelink 8677 elem[ ontype ] = tmp;
afe42d0… ragelink 8678 }
afe42d0… ragelink 8679 }
afe42d0… ragelink 8680 }
afe42d0… ragelink 8681 }
afe42d0… ragelink 8682
afe42d0… ragelink 8683 return event.result;
afe42d0… ragelink 8684 },
afe42d0… ragelink 8685
afe42d0… ragelink 8686 // Piggyback on a donor event to simulate a different one
afe42d0… ragelink 8687 // Used only for `focus(in | out)` events
afe42d0… ragelink 8688 simulate: function( type, elem, event ) {
afe42d0… ragelink 8689 var e = jQuery.extend(
afe42d0… ragelink 8690 new jQuery.Event(),
afe42d0… ragelink 8691 event,
afe42d0… ragelink 8692 {
afe42d0… ragelink 8693 type: type,
afe42d0… ragelink 8694 isSimulated: true
afe42d0… ragelink 8695 }
afe42d0… ragelink 8696 );
afe42d0… ragelink 8697
afe42d0… ragelink 8698 jQuery.event.trigger( e, null, elem );
afe42d0… ragelink 8699 }
afe42d0… ragelink 8700
afe42d0… ragelink 8701 } );
afe42d0… ragelink 8702
afe42d0… ragelink 8703 jQuery.fn.extend( {
afe42d0… ragelink 8704
afe42d0… ragelink 8705 trigger: function( type, data ) {
afe42d0… ragelink 8706 return this.each( function() {
afe42d0… ragelink 8707 jQuery.event.trigger( type, data, this );
afe42d0… ragelink 8708 } );
afe42d0… ragelink 8709 },
afe42d0… ragelink 8710 triggerHandler: function( type, data ) {
afe42d0… ragelink 8711 var elem = this[ 0 ];
afe42d0… ragelink 8712 if ( elem ) {
afe42d0… ragelink 8713 return jQuery.event.trigger( type, data, elem, true );
afe42d0… ragelink 8714 }
afe42d0… ragelink 8715 }
afe42d0… ragelink 8716 } );
afe42d0… ragelink 8717
afe42d0… ragelink 8718
afe42d0… ragelink 8719 var
afe42d0… ragelink 8720 rbracket = /\[\]$/,
afe42d0… ragelink 8721 rCRLF = /\r?\n/g,
afe42d0… ragelink 8722 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
afe42d0… ragelink 8723 rsubmittable = /^(?:input|select|textarea|keygen)/i;
afe42d0… ragelink 8724
afe42d0… ragelink 8725 function buildParams( prefix, obj, traditional, add ) {
afe42d0… ragelink 8726 var name;
afe42d0… ragelink 8727
afe42d0… ragelink 8728 if ( Array.isArray( obj ) ) {
afe42d0… ragelink 8729
afe42d0… ragelink 8730 // Serialize array item.
afe42d0… ragelink 8731 jQuery.each( obj, function( i, v ) {
afe42d0… ragelink 8732 if ( traditional || rbracket.test( prefix ) ) {
afe42d0… ragelink 8733
afe42d0… ragelink 8734 // Treat each array item as a scalar.
afe42d0… ragelink 8735 add( prefix, v );
afe42d0… ragelink 8736
afe42d0… ragelink 8737 } else {
afe42d0… ragelink 8738
afe42d0… ragelink 8739 // Item is non-scalar (array or object), encode its numeric index.
afe42d0… ragelink 8740 buildParams(
afe42d0… ragelink 8741 prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
afe42d0… ragelink 8742 v,
afe42d0… ragelink 8743 traditional,
afe42d0… ragelink 8744 add
afe42d0… ragelink 8745 );
afe42d0… ragelink 8746 }
afe42d0… ragelink 8747 } );
afe42d0… ragelink 8748
afe42d0… ragelink 8749 } else if ( !traditional && toType( obj ) === "object" ) {
afe42d0… ragelink 8750
afe42d0… ragelink 8751 // Serialize object item.
afe42d0… ragelink 8752 for ( name in obj ) {
afe42d0… ragelink 8753 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
afe42d0… ragelink 8754 }
afe42d0… ragelink 8755
afe42d0… ragelink 8756 } else {
afe42d0… ragelink 8757
afe42d0… ragelink 8758 // Serialize scalar item.
afe42d0… ragelink 8759 add( prefix, obj );
afe42d0… ragelink 8760 }
afe42d0… ragelink 8761 }
afe42d0… ragelink 8762
afe42d0… ragelink 8763 // Serialize an array of form elements or a set of
afe42d0… ragelink 8764 // key/values into a query string
afe42d0… ragelink 8765 jQuery.param = function( a, traditional ) {
afe42d0… ragelink 8766 var prefix,
afe42d0… ragelink 8767 s = [],
afe42d0… ragelink 8768 add = function( key, valueOrFunction ) {
afe42d0… ragelink 8769
afe42d0… ragelink 8770 // If value is a function, invoke it and use its return value
afe42d0… ragelink 8771 var value = isFunction( valueOrFunction ) ?
afe42d0… ragelink 8772 valueOrFunction() :
afe42d0… ragelink 8773 valueOrFunction;
afe42d0… ragelink 8774
afe42d0… ragelink 8775 s[ s.length ] = encodeURIComponent( key ) + "=" +
afe42d0… ragelink 8776 encodeURIComponent( value == null ? "" : value );
afe42d0… ragelink 8777 };
afe42d0… ragelink 8778
afe42d0… ragelink 8779 if ( a == null ) {
afe42d0… ragelink 8780 return "";
afe42d0… ragelink 8781 }
afe42d0… ragelink 8782
afe42d0… ragelink 8783 // If an array was passed in, assume that it is an array of form elements.
afe42d0… ragelink 8784 if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
afe42d0… ragelink 8785
afe42d0… ragelink 8786 // Serialize the form elements
afe42d0… ragelink 8787 jQuery.each( a, function() {
afe42d0… ragelink 8788 add( this.name, this.value );
afe42d0… ragelink 8789 } );
afe42d0… ragelink 8790
afe42d0… ragelink 8791 } else {
afe42d0… ragelink 8792
afe42d0… ragelink 8793 // If traditional, encode the "old" way (the way 1.3.2 or older
afe42d0… ragelink 8794 // did it), otherwise encode params recursively.
afe42d0… ragelink 8795 for ( prefix in a ) {
afe42d0… ragelink 8796 buildParams( prefix, a[ prefix ], traditional, add );
afe42d0… ragelink 8797 }
afe42d0… ragelink 8798 }
afe42d0… ragelink 8799
afe42d0… ragelink 8800 // Return the resulting serialization
afe42d0… ragelink 8801 return s.join( "&" );
afe42d0… ragelink 8802 };
afe42d0… ragelink 8803
afe42d0… ragelink 8804 jQuery.fn.extend( {
afe42d0… ragelink 8805 serialize: function() {
afe42d0… ragelink 8806 return jQuery.param( this.serializeArray() );
afe42d0… ragelink 8807 },
afe42d0… ragelink 8808 serializeArray: function() {
afe42d0… ragelink 8809 return this.map( function() {
afe42d0… ragelink 8810
afe42d0… ragelink 8811 // Can add propHook for "elements" to filter or add form elements
afe42d0… ragelink 8812 var elements = jQuery.prop( this, "elements" );
afe42d0… ragelink 8813 return elements ? jQuery.makeArray( elements ) : this;
afe42d0… ragelink 8814 } ).filter( function() {
afe42d0… ragelink 8815 var type = this.type;
afe42d0… ragelink 8816
afe42d0… ragelink 8817 // Use .is( ":disabled" ) so that fieldset[disabled] works
afe42d0… ragelink 8818 return this.name && !jQuery( this ).is( ":disabled" ) &&
afe42d0… ragelink 8819 rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
afe42d0… ragelink 8820 ( this.checked || !rcheckableType.test( type ) );
afe42d0… ragelink 8821 } ).map( function( _i, elem ) {
afe42d0… ragelink 8822 var val = jQuery( this ).val();
afe42d0… ragelink 8823
afe42d0… ragelink 8824 if ( val == null ) {
afe42d0… ragelink 8825 return null;
afe42d0… ragelink 8826 }
afe42d0… ragelink 8827
afe42d0… ragelink 8828 if ( Array.isArray( val ) ) {
afe42d0… ragelink 8829 return jQuery.map( val, function( val ) {
afe42d0… ragelink 8830 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
afe42d0… ragelink 8831 } );
afe42d0… ragelink 8832 }
afe42d0… ragelink 8833
afe42d0… ragelink 8834 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
afe42d0… ragelink 8835 } ).get();
afe42d0… ragelink 8836 }
afe42d0… ragelink 8837 } );
afe42d0… ragelink 8838
afe42d0… ragelink 8839
afe42d0… ragelink 8840 var
afe42d0… ragelink 8841 r20 = /%20/g,
afe42d0… ragelink 8842 rhash = /#.*$/,
afe42d0… ragelink 8843 rantiCache = /([?&])_=[^&]*/,
afe42d0… ragelink 8844 rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
afe42d0… ragelink 8845
afe42d0… ragelink 8846 // trac-7653, trac-8125, trac-8152: local protocol detection
afe42d0… ragelink 8847 rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
afe42d0… ragelink 8848 rnoContent = /^(?:GET|HEAD)$/,
afe42d0… ragelink 8849 rprotocol = /^\/\//,
afe42d0… ragelink 8850
afe42d0… ragelink 8851 /* Prefilters
afe42d0… ragelink 8852 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
afe42d0… ragelink 8853 * 2) These are called:
afe42d0… ragelink 8854 * - BEFORE asking for a transport
afe42d0… ragelink 8855 * - AFTER param serialization (s.data is a string if s.processData is true)
afe42d0… ragelink 8856 * 3) key is the dataType
afe42d0… ragelink 8857 * 4) the catchall symbol "*" can be used
afe42d0… ragelink 8858 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
afe42d0… ragelink 8859 */
afe42d0… ragelink 8860 prefilters = {},
afe42d0… ragelink 8861
afe42d0… ragelink 8862 /* Transports bindings
afe42d0… ragelink 8863 * 1) key is the dataType
afe42d0… ragelink 8864 * 2) the catchall symbol "*" can be used
afe42d0… ragelink 8865 * 3) selection will start with transport dataType and THEN go to "*" if needed
afe42d0… ragelink 8866 */
afe42d0… ragelink 8867 transports = {},
afe42d0… ragelink 8868
afe42d0… ragelink 8869 // Avoid comment-prolog char sequence (trac-10098); must appease lint and evade compression
afe42d0… ragelink 8870 allTypes = "*/".concat( "*" ),
afe42d0… ragelink 8871
afe42d0… ragelink 8872 // Anchor tag for parsing the document origin
afe42d0… ragelink 8873 originAnchor = document.createElement( "a" );
afe42d0… ragelink 8874
afe42d0… ragelink 8875 originAnchor.href = location.href;
afe42d0… ragelink 8876
afe42d0… ragelink 8877 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
afe42d0… ragelink 8878 function addToPrefiltersOrTransports( structure ) {
afe42d0… ragelink 8879
afe42d0… ragelink 8880 // dataTypeExpression is optional and defaults to "*"
afe42d0… ragelink 8881 return function( dataTypeExpression, func ) {
afe42d0… ragelink 8882
afe42d0… ragelink 8883 if ( typeof dataTypeExpression !== "string" ) {
afe42d0… ragelink 8884 func = dataTypeExpression;
afe42d0… ragelink 8885 dataTypeExpression = "*";
afe42d0… ragelink 8886 }
afe42d0… ragelink 8887
afe42d0… ragelink 8888 var dataType,
afe42d0… ragelink 8889 i = 0,
afe42d0… ragelink 8890 dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
afe42d0… ragelink 8891
afe42d0… ragelink 8892 if ( isFunction( func ) ) {
afe42d0… ragelink 8893
afe42d0… ragelink 8894 // For each dataType in the dataTypeExpression
afe42d0… ragelink 8895 while ( ( dataType = dataTypes[ i++ ] ) ) {
afe42d0… ragelink 8896
afe42d0… ragelink 8897 // Prepend if requested
afe42d0… ragelink 8898 if ( dataType[ 0 ] === "+" ) {
afe42d0… ragelink 8899 dataType = dataType.slice( 1 ) || "*";
afe42d0… ragelink 8900 ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
afe42d0… ragelink 8901
afe42d0… ragelink 8902 // Otherwise append
afe42d0… ragelink 8903 } else {
afe42d0… ragelink 8904 ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
afe42d0… ragelink 8905 }
afe42d0… ragelink 8906 }
afe42d0… ragelink 8907 }
afe42d0… ragelink 8908 };
afe42d0… ragelink 8909 }
afe42d0… ragelink 8910
afe42d0… ragelink 8911 // Base inspection function for prefilters and transports
afe42d0… ragelink 8912 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
afe42d0… ragelink 8913
afe42d0… ragelink 8914 var inspected = {},
afe42d0… ragelink 8915 seekingTransport = ( structure === transports );
afe42d0… ragelink 8916
afe42d0… ragelink 8917 function inspect( dataType ) {
afe42d0… ragelink 8918 var selected;
afe42d0… ragelink 8919 inspected[ dataType ] = true;
afe42d0… ragelink 8920 jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
afe42d0… ragelink 8921 var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
afe42d0… ragelink 8922 if ( typeof dataTypeOrTransport === "string" &&
afe42d0… ragelink 8923 !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
afe42d0… ragelink 8924
afe42d0… ragelink 8925 options.dataTypes.unshift( dataTypeOrTransport );
afe42d0… ragelink 8926 inspect( dataTypeOrTransport );
afe42d0… ragelink 8927 return false;
afe42d0… ragelink 8928 } else if ( seekingTransport ) {
afe42d0… ragelink 8929 return !( selected = dataTypeOrTransport );
afe42d0… ragelink 8930 }
afe42d0… ragelink 8931 } );
afe42d0… ragelink 8932 return selected;
afe42d0… ragelink 8933 }
afe42d0… ragelink 8934
afe42d0… ragelink 8935 return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
afe42d0… ragelink 8936 }
afe42d0… ragelink 8937
afe42d0… ragelink 8938 // A special extend for ajax options
afe42d0… ragelink 8939 // that takes "flat" options (not to be deep extended)
afe42d0… ragelink 8940 // Fixes trac-9887
afe42d0… ragelink 8941 function ajaxExtend( target, src ) {
afe42d0… ragelink 8942 var key, deep,
afe42d0… ragelink 8943 flatOptions = jQuery.ajaxSettings.flatOptions || {};
afe42d0… ragelink 8944
afe42d0… ragelink 8945 for ( key in src ) {
afe42d0… ragelink 8946 if ( src[ key ] !== undefined ) {
afe42d0… ragelink 8947 ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
afe42d0… ragelink 8948 }
afe42d0… ragelink 8949 }
afe42d0… ragelink 8950 if ( deep ) {
afe42d0… ragelink 8951 jQuery.extend( true, target, deep );
afe42d0… ragelink 8952 }
afe42d0… ragelink 8953
afe42d0… ragelink 8954 return target;
afe42d0… ragelink 8955 }
afe42d0… ragelink 8956
afe42d0… ragelink 8957 /* Handles responses to an ajax request:
afe42d0… ragelink 8958 * - finds the right dataType (mediates between content-type and expected dataType)
afe42d0… ragelink 8959 * - returns the corresponding response
afe42d0… ragelink 8960 */
afe42d0… ragelink 8961 function ajaxHandleResponses( s, jqXHR, responses ) {
afe42d0… ragelink 8962
afe42d0… ragelink 8963 var ct, type, finalDataType, firstDataType,
afe42d0… ragelink 8964 contents = s.contents,
afe42d0… ragelink 8965 dataTypes = s.dataTypes;
afe42d0… ragelink 8966
afe42d0… ragelink 8967 // Remove auto dataType and get content-type in the process
afe42d0… ragelink 8968 while ( dataTypes[ 0 ] === "*" ) {
afe42d0… ragelink 8969 dataTypes.shift();
afe42d0… ragelink 8970 if ( ct === undefined ) {
afe42d0… ragelink 8971 ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
afe42d0… ragelink 8972 }
afe42d0… ragelink 8973 }
afe42d0… ragelink 8974
afe42d0… ragelink 8975 // Check if we're dealing with a known content-type
afe42d0… ragelink 8976 if ( ct ) {
afe42d0… ragelink 8977 for ( type in contents ) {
afe42d0… ragelink 8978 if ( contents[ type ] && contents[ type ].test( ct ) ) {
afe42d0… ragelink 8979 dataTypes.unshift( type );
afe42d0… ragelink 8980 break;
afe42d0… ragelink 8981 }
afe42d0… ragelink 8982 }
afe42d0… ragelink 8983 }
afe42d0… ragelink 8984
afe42d0… ragelink 8985 // Check to see if we have a response for the expected dataType
afe42d0… ragelink 8986 if ( dataTypes[ 0 ] in responses ) {
afe42d0… ragelink 8987 finalDataType = dataTypes[ 0 ];
afe42d0… ragelink 8988 } else {
afe42d0… ragelink 8989
afe42d0… ragelink 8990 // Try convertible dataTypes
afe42d0… ragelink 8991 for ( type in responses ) {
afe42d0… ragelink 8992 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
afe42d0… ragelink 8993 finalDataType = type;
afe42d0… ragelink 8994 break;
afe42d0… ragelink 8995 }
afe42d0… ragelink 8996 if ( !firstDataType ) {
afe42d0… ragelink 8997 firstDataType = type;
afe42d0… ragelink 8998 }
afe42d0… ragelink 8999 }
afe42d0… ragelink 9000
afe42d0… ragelink 9001 // Or just use first one
afe42d0… ragelink 9002 finalDataType = finalDataType || firstDataType;
afe42d0… ragelink 9003 }
afe42d0… ragelink 9004
afe42d0… ragelink 9005 // If we found a dataType
afe42d0… ragelink 9006 // We add the dataType to the list if needed
afe42d0… ragelink 9007 // and return the corresponding response
afe42d0… ragelink 9008 if ( finalDataType ) {
afe42d0… ragelink 9009 if ( finalDataType !== dataTypes[ 0 ] ) {
afe42d0… ragelink 9010 dataTypes.unshift( finalDataType );
afe42d0… ragelink 9011 }
afe42d0… ragelink 9012 return responses[ finalDataType ];
afe42d0… ragelink 9013 }
afe42d0… ragelink 9014 }
afe42d0… ragelink 9015
afe42d0… ragelink 9016 /* Chain conversions given the request and the original response
afe42d0… ragelink 9017 * Also sets the responseXXX fields on the jqXHR instance
afe42d0… ragelink 9018 */
afe42d0… ragelink 9019 function ajaxConvert( s, response, jqXHR, isSuccess ) {
afe42d0… ragelink 9020 var conv2, current, conv, tmp, prev,
afe42d0… ragelink 9021 converters = {},
afe42d0… ragelink 9022
afe42d0… ragelink 9023 // Work with a copy of dataTypes in case we need to modify it for conversion
afe42d0… ragelink 9024 dataTypes = s.dataTypes.slice();
afe42d0… ragelink 9025
afe42d0… ragelink 9026 // Create converters map with lowercased keys
afe42d0… ragelink 9027 if ( dataTypes[ 1 ] ) {
afe42d0… ragelink 9028 for ( conv in s.converters ) {
afe42d0… ragelink 9029 converters[ conv.toLowerCase() ] = s.converters[ conv ];
afe42d0… ragelink 9030 }
afe42d0… ragelink 9031 }
afe42d0… ragelink 9032
afe42d0… ragelink 9033 current = dataTypes.shift();
afe42d0… ragelink 9034
afe42d0… ragelink 9035 // Convert to each sequential dataType
afe42d0… ragelink 9036 while ( current ) {
afe42d0… ragelink 9037
afe42d0… ragelink 9038 if ( s.responseFields[ current ] ) {
afe42d0… ragelink 9039 jqXHR[ s.responseFields[ current ] ] = response;
afe42d0… ragelink 9040 }
afe42d0… ragelink 9041
afe42d0… ragelink 9042 // Apply the dataFilter if provided
afe42d0… ragelink 9043 if ( !prev && isSuccess && s.dataFilter ) {
afe42d0… ragelink 9044 response = s.dataFilter( response, s.dataType );
afe42d0… ragelink 9045 }
afe42d0… ragelink 9046
afe42d0… ragelink 9047 prev = current;
afe42d0… ragelink 9048 current = dataTypes.shift();
afe42d0… ragelink 9049
afe42d0… ragelink 9050 if ( current ) {
afe42d0… ragelink 9051
afe42d0… ragelink 9052 // There's only work to do if current dataType is non-auto
afe42d0… ragelink 9053 if ( current === "*" ) {
afe42d0… ragelink 9054
afe42d0… ragelink 9055 current = prev;
afe42d0… ragelink 9056
afe42d0… ragelink 9057 // Convert response if prev dataType is non-auto and differs from current
afe42d0… ragelink 9058 } else if ( prev !== "*" && prev !== current ) {
afe42d0… ragelink 9059
afe42d0… ragelink 9060 // Seek a direct converter
afe42d0… ragelink 9061 conv = converters[ prev + " " + current ] || converters[ "* " + current ];
afe42d0… ragelink 9062
afe42d0… ragelink 9063 // If none found, seek a pair
afe42d0… ragelink 9064 if ( !conv ) {
afe42d0… ragelink 9065 for ( conv2 in converters ) {
afe42d0… ragelink 9066
afe42d0… ragelink 9067 // If conv2 outputs current
afe42d0… ragelink 9068 tmp = conv2.split( " " );
afe42d0… ragelink 9069 if ( tmp[ 1 ] === current ) {
afe42d0… ragelink 9070
afe42d0… ragelink 9071 // If prev can be converted to accepted input
afe42d0… ragelink 9072 conv = converters[ prev + " " + tmp[ 0 ] ] ||
afe42d0… ragelink 9073 converters[ "* " + tmp[ 0 ] ];
afe42d0… ragelink 9074 if ( conv ) {
afe42d0… ragelink 9075
afe42d0… ragelink 9076 // Condense equivalence converters
afe42d0… ragelink 9077 if ( conv === true ) {
afe42d0… ragelink 9078 conv = converters[ conv2 ];
afe42d0… ragelink 9079
afe42d0… ragelink 9080 // Otherwise, insert the intermediate dataType
afe42d0… ragelink 9081 } else if ( converters[ conv2 ] !== true ) {
afe42d0… ragelink 9082 current = tmp[ 0 ];
afe42d0… ragelink 9083 dataTypes.unshift( tmp[ 1 ] );
afe42d0… ragelink 9084 }
afe42d0… ragelink 9085 break;
afe42d0… ragelink 9086 }
afe42d0… ragelink 9087 }
afe42d0… ragelink 9088 }
afe42d0… ragelink 9089 }
afe42d0… ragelink 9090
afe42d0… ragelink 9091 // Apply converter (if not an equivalence)
afe42d0… ragelink 9092 if ( conv !== true ) {
afe42d0… ragelink 9093
afe42d0… ragelink 9094 // Unless errors are allowed to bubble, catch and return them
afe42d0… ragelink 9095 if ( conv && s.throws ) {
afe42d0… ragelink 9096 response = conv( response );
afe42d0… ragelink 9097 } else {
afe42d0… ragelink 9098 try {
afe42d0… ragelink 9099 response = conv( response );
afe42d0… ragelink 9100 } catch ( e ) {
afe42d0… ragelink 9101 return {
afe42d0… ragelink 9102 state: "parsererror",
afe42d0… ragelink 9103 error: conv ? e : "No conversion from " + prev + " to " + current
afe42d0… ragelink 9104 };
afe42d0… ragelink 9105 }
afe42d0… ragelink 9106 }
afe42d0… ragelink 9107 }
afe42d0… ragelink 9108 }
afe42d0… ragelink 9109 }
afe42d0… ragelink 9110 }
afe42d0… ragelink 9111
afe42d0… ragelink 9112 return { state: "success", data: response };
afe42d0… ragelink 9113 }
afe42d0… ragelink 9114
afe42d0… ragelink 9115 jQuery.extend( {
afe42d0… ragelink 9116
afe42d0… ragelink 9117 // Counter for holding the number of active queries
afe42d0… ragelink 9118 active: 0,
afe42d0… ragelink 9119
afe42d0… ragelink 9120 // Last-Modified header cache for next request
afe42d0… ragelink 9121 lastModified: {},
afe42d0… ragelink 9122 etag: {},
afe42d0… ragelink 9123
afe42d0… ragelink 9124 ajaxSettings: {
afe42d0… ragelink 9125 url: location.href,
afe42d0… ragelink 9126 type: "GET",
afe42d0… ragelink 9127 isLocal: rlocalProtocol.test( location.protocol ),
afe42d0… ragelink 9128 global: true,
afe42d0… ragelink 9129 processData: true,
afe42d0… ragelink 9130 async: true,
afe42d0… ragelink 9131 contentType: "application/x-www-form-urlencoded; charset=UTF-8",
afe42d0… ragelink 9132
afe42d0… ragelink 9133 /*
afe42d0… ragelink 9134 timeout: 0,
afe42d0… ragelink 9135 data: null,
afe42d0… ragelink 9136 dataType: null,
afe42d0… ragelink 9137 username: null,
afe42d0… ragelink 9138 password: null,
afe42d0… ragelink 9139 cache: null,
afe42d0… ragelink 9140 throws: false,
afe42d0… ragelink 9141 traditional: false,
afe42d0… ragelink 9142 headers: {},
afe42d0… ragelink 9143 */
afe42d0… ragelink 9144
afe42d0… ragelink 9145 accepts: {
afe42d0… ragelink 9146 "*": allTypes,
afe42d0… ragelink 9147 text: "text/plain",
afe42d0… ragelink 9148 html: "text/html",
afe42d0… ragelink 9149 xml: "application/xml, text/xml",
afe42d0… ragelink 9150 json: "application/json, text/javascript"
afe42d0… ragelink 9151 },
afe42d0… ragelink 9152
afe42d0… ragelink 9153 contents: {
afe42d0… ragelink 9154 xml: /\bxml\b/,
afe42d0… ragelink 9155 html: /\bhtml/,
afe42d0… ragelink 9156 json: /\bjson\b/
afe42d0… ragelink 9157 },
afe42d0… ragelink 9158
afe42d0… ragelink 9159 responseFields: {
afe42d0… ragelink 9160 xml: "responseXML",
afe42d0… ragelink 9161 text: "responseText",
afe42d0… ragelink 9162 json: "responseJSON"
afe42d0… ragelink 9163 },
afe42d0… ragelink 9164
afe42d0… ragelink 9165 // Data converters
afe42d0… ragelink 9166 // Keys separate source (or catchall "*") and destination types with a single space
afe42d0… ragelink 9167 converters: {
afe42d0… ragelink 9168
afe42d0… ragelink 9169 // Convert anything to text
afe42d0… ragelink 9170 "* text": String,
afe42d0… ragelink 9171
afe42d0… ragelink 9172 // Text to html (true = no transformation)
afe42d0… ragelink 9173 "text html": true,
afe42d0… ragelink 9174
afe42d0… ragelink 9175 // Evaluate text as a json expression
afe42d0… ragelink 9176 "text json": JSON.parse,
afe42d0… ragelink 9177
afe42d0… ragelink 9178 // Parse text as xml
afe42d0… ragelink 9179 "text xml": jQuery.parseXML
afe42d0… ragelink 9180 },
afe42d0… ragelink 9181
afe42d0… ragelink 9182 // For options that shouldn't be deep extended:
afe42d0… ragelink 9183 // you can add your own custom options here if
afe42d0… ragelink 9184 // and when you create one that shouldn't be
afe42d0… ragelink 9185 // deep extended (see ajaxExtend)
afe42d0… ragelink 9186 flatOptions: {
afe42d0… ragelink 9187 url: true,
afe42d0… ragelink 9188 context: true
afe42d0… ragelink 9189 }
afe42d0… ragelink 9190 },
afe42d0… ragelink 9191
afe42d0… ragelink 9192 // Creates a full fledged settings object into target
afe42d0… ragelink 9193 // with both ajaxSettings and settings fields.
afe42d0… ragelink 9194 // If target is omitted, writes into ajaxSettings.
afe42d0… ragelink 9195 ajaxSetup: function( target, settings ) {
afe42d0… ragelink 9196 return settings ?
afe42d0… ragelink 9197
afe42d0… ragelink 9198 // Building a settings object
afe42d0… ragelink 9199 ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
afe42d0… ragelink 9200
afe42d0… ragelink 9201 // Extending ajaxSettings
afe42d0… ragelink 9202 ajaxExtend( jQuery.ajaxSettings, target );
afe42d0… ragelink 9203 },
afe42d0… ragelink 9204
afe42d0… ragelink 9205 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
afe42d0… ragelink 9206 ajaxTransport: addToPrefiltersOrTransports( transports ),
afe42d0… ragelink 9207
afe42d0… ragelink 9208 // Main method
afe42d0… ragelink 9209 ajax: function( url, options ) {
afe42d0… ragelink 9210
afe42d0… ragelink 9211 // If url is an object, simulate pre-1.5 signature
afe42d0… ragelink 9212 if ( typeof url === "object" ) {
afe42d0… ragelink 9213 options = url;
afe42d0… ragelink 9214 url = undefined;
afe42d0… ragelink 9215 }
afe42d0… ragelink 9216
afe42d0… ragelink 9217 // Force options to be an object
afe42d0… ragelink 9218 options = options || {};
afe42d0… ragelink 9219
afe42d0… ragelink 9220 var transport,
afe42d0… ragelink 9221
afe42d0… ragelink 9222 // URL without anti-cache param
afe42d0… ragelink 9223 cacheURL,
afe42d0… ragelink 9224
afe42d0… ragelink 9225 // Response headers
afe42d0… ragelink 9226 responseHeadersString,
afe42d0… ragelink 9227 responseHeaders,
afe42d0… ragelink 9228
afe42d0… ragelink 9229 // timeout handle
afe42d0… ragelink 9230 timeoutTimer,
afe42d0… ragelink 9231
afe42d0… ragelink 9232 // Url cleanup var
afe42d0… ragelink 9233 urlAnchor,
afe42d0… ragelink 9234
afe42d0… ragelink 9235 // Request state (becomes false upon send and true upon completion)
afe42d0… ragelink 9236 completed,
afe42d0… ragelink 9237
afe42d0… ragelink 9238 // To know if global events are to be dispatched
afe42d0… ragelink 9239 fireGlobals,
afe42d0… ragelink 9240
afe42d0… ragelink 9241 // Loop variable
afe42d0… ragelink 9242 i,
afe42d0… ragelink 9243
afe42d0… ragelink 9244 // uncached part of the url
afe42d0… ragelink 9245 uncached,
afe42d0… ragelink 9246
afe42d0… ragelink 9247 // Create the final options object
afe42d0… ragelink 9248 s = jQuery.ajaxSetup( {}, options ),
afe42d0… ragelink 9249
afe42d0… ragelink 9250 // Callbacks context
afe42d0… ragelink 9251 callbackContext = s.context || s,
afe42d0… ragelink 9252
afe42d0… ragelink 9253 // Context for global events is callbackContext if it is a DOM node or jQuery collection
afe42d0… ragelink 9254 globalEventContext = s.context &&
afe42d0… ragelink 9255 ( callbackContext.nodeType || callbackContext.jquery ) ?
afe42d0… ragelink 9256 jQuery( callbackContext ) :
afe42d0… ragelink 9257 jQuery.event,
afe42d0… ragelink 9258
afe42d0… ragelink 9259 // Deferreds
afe42d0… ragelink 9260 deferred = jQuery.Deferred(),
afe42d0… ragelink 9261 completeDeferred = jQuery.Callbacks( "once memory" ),
afe42d0… ragelink 9262
afe42d0… ragelink 9263 // Status-dependent callbacks
afe42d0… ragelink 9264 statusCode = s.statusCode || {},
afe42d0… ragelink 9265
afe42d0… ragelink 9266 // Headers (they are sent all at once)
afe42d0… ragelink 9267 requestHeaders = {},
afe42d0… ragelink 9268 requestHeadersNames = {},
afe42d0… ragelink 9269
afe42d0… ragelink 9270 // Default abort message
afe42d0… ragelink 9271 strAbort = "canceled",
afe42d0… ragelink 9272
afe42d0… ragelink 9273 // Fake xhr
afe42d0… ragelink 9274 jqXHR = {
afe42d0… ragelink 9275 readyState: 0,
afe42d0… ragelink 9276
afe42d0… ragelink 9277 // Builds headers hashtable if needed
afe42d0… ragelink 9278 getResponseHeader: function( key ) {
afe42d0… ragelink 9279 var match;
afe42d0… ragelink 9280 if ( completed ) {
afe42d0… ragelink 9281 if ( !responseHeaders ) {
afe42d0… ragelink 9282 responseHeaders = {};
afe42d0… ragelink 9283 while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
afe42d0… ragelink 9284 responseHeaders[ match[ 1 ].toLowerCase() + " " ] =
afe42d0… ragelink 9285 ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] )
afe42d0… ragelink 9286 .concat( match[ 2 ] );
afe42d0… ragelink 9287 }
afe42d0… ragelink 9288 }
afe42d0… ragelink 9289 match = responseHeaders[ key.toLowerCase() + " " ];
afe42d0… ragelink 9290 }
afe42d0… ragelink 9291 return match == null ? null : match.join( ", " );
afe42d0… ragelink 9292 },
afe42d0… ragelink 9293
afe42d0… ragelink 9294 // Raw string
afe42d0… ragelink 9295 getAllResponseHeaders: function() {
afe42d0… ragelink 9296 return completed ? responseHeadersString : null;
afe42d0… ragelink 9297 },
afe42d0… ragelink 9298
afe42d0… ragelink 9299 // Caches the header
afe42d0… ragelink 9300 setRequestHeader: function( name, value ) {
afe42d0… ragelink 9301 if ( completed == null ) {
afe42d0… ragelink 9302 name = requestHeadersNames[ name.toLowerCase() ] =
afe42d0… ragelink 9303 requestHeadersNames[ name.toLowerCase() ] || name;
afe42d0… ragelink 9304 requestHeaders[ name ] = value;
afe42d0… ragelink 9305 }
afe42d0… ragelink 9306 return this;
afe42d0… ragelink 9307 },
afe42d0… ragelink 9308
afe42d0… ragelink 9309 // Overrides response content-type header
afe42d0… ragelink 9310 overrideMimeType: function( type ) {
afe42d0… ragelink 9311 if ( completed == null ) {
afe42d0… ragelink 9312 s.mimeType = type;
afe42d0… ragelink 9313 }
afe42d0… ragelink 9314 return this;
afe42d0… ragelink 9315 },
afe42d0… ragelink 9316
afe42d0… ragelink 9317 // Status-dependent callbacks
afe42d0… ragelink 9318 statusCode: function( map ) {
afe42d0… ragelink 9319 var code;
afe42d0… ragelink 9320 if ( map ) {
afe42d0… ragelink 9321 if ( completed ) {
afe42d0… ragelink 9322
afe42d0… ragelink 9323 // Execute the appropriate callbacks
afe42d0… ragelink 9324 jqXHR.always( map[ jqXHR.status ] );
afe42d0… ragelink 9325 } else {
afe42d0… ragelink 9326
afe42d0… ragelink 9327 // Lazy-add the new callbacks in a way that preserves old ones
afe42d0… ragelink 9328 for ( code in map ) {
afe42d0… ragelink 9329 statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
afe42d0… ragelink 9330 }
afe42d0… ragelink 9331 }
afe42d0… ragelink 9332 }
afe42d0… ragelink 9333 return this;
afe42d0… ragelink 9334 },
afe42d0… ragelink 9335
afe42d0… ragelink 9336 // Cancel the request
afe42d0… ragelink 9337 abort: function( statusText ) {
afe42d0… ragelink 9338 var finalText = statusText || strAbort;
afe42d0… ragelink 9339 if ( transport ) {
afe42d0… ragelink 9340 transport.abort( finalText );
afe42d0… ragelink 9341 }
afe42d0… ragelink 9342 done( 0, finalText );
afe42d0… ragelink 9343 return this;
afe42d0… ragelink 9344 }
afe42d0… ragelink 9345 };
afe42d0… ragelink 9346
afe42d0… ragelink 9347 // Attach deferreds
afe42d0… ragelink 9348 deferred.promise( jqXHR );
afe42d0… ragelink 9349
afe42d0… ragelink 9350 // Add protocol if not provided (prefilters might expect it)
afe42d0… ragelink 9351 // Handle falsy url in the settings object (trac-10093: consistency with old signature)
afe42d0… ragelink 9352 // We also use the url parameter if available
afe42d0… ragelink 9353 s.url = ( ( url || s.url || location.href ) + "" )
afe42d0… ragelink 9354 .replace( rprotocol, location.protocol + "//" );
afe42d0… ragelink 9355
afe42d0… ragelink 9356 // Alias method option to type as per ticket trac-12004
afe42d0… ragelink 9357 s.type = options.method || options.type || s.method || s.type;
afe42d0… ragelink 9358
afe42d0… ragelink 9359 // Extract dataTypes list
afe42d0… ragelink 9360 s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ];
afe42d0… ragelink 9361
afe42d0… ragelink 9362 // A cross-domain request is in order when the origin doesn't match the current origin.
afe42d0… ragelink 9363 if ( s.crossDomain == null ) {
afe42d0… ragelink 9364 urlAnchor = document.createElement( "a" );
afe42d0… ragelink 9365
afe42d0… ragelink 9366 // Support: IE <=8 - 11, Edge 12 - 15
afe42d0… ragelink 9367 // IE throws exception on accessing the href property if url is malformed,
afe42d0… ragelink 9368 // e.g. http://example.com:80x/
afe42d0… ragelink 9369 try {
afe42d0… ragelink 9370 urlAnchor.href = s.url;
afe42d0… ragelink 9371
afe42d0… ragelink 9372 // Support: IE <=8 - 11 only
afe42d0… ragelink 9373 // Anchor's host property isn't correctly set when s.url is relative
afe42d0… ragelink 9374 urlAnchor.href = urlAnchor.href;
afe42d0… ragelink 9375 s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
afe42d0… ragelink 9376 urlAnchor.protocol + "//" + urlAnchor.host;
afe42d0… ragelink 9377 } catch ( e ) {
afe42d0… ragelink 9378
afe42d0… ragelink 9379 // If there is an error parsing the URL, assume it is crossDomain,
afe42d0… ragelink 9380 // it can be rejected by the transport if it is invalid
afe42d0… ragelink 9381 s.crossDomain = true;
afe42d0… ragelink 9382 }
afe42d0… ragelink 9383 }
afe42d0… ragelink 9384
afe42d0… ragelink 9385 // Convert data if not already a string
afe42d0… ragelink 9386 if ( s.data && s.processData && typeof s.data !== "string" ) {
afe42d0… ragelink 9387 s.data = jQuery.param( s.data, s.traditional );
afe42d0… ragelink 9388 }
afe42d0… ragelink 9389
afe42d0… ragelink 9390 // Apply prefilters
afe42d0… ragelink 9391 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
afe42d0… ragelink 9392
afe42d0… ragelink 9393 // If request was aborted inside a prefilter, stop there
afe42d0… ragelink 9394 if ( completed ) {
afe42d0… ragelink 9395 return jqXHR;
afe42d0… ragelink 9396 }
afe42d0… ragelink 9397
afe42d0… ragelink 9398 // We can fire global events as of now if asked to
afe42d0… ragelink 9399 // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (trac-15118)
afe42d0… ragelink 9400 fireGlobals = jQuery.event && s.global;
afe42d0… ragelink 9401
afe42d0… ragelink 9402 // Watch for a new set of requests
afe42d0… ragelink 9403 if ( fireGlobals && jQuery.active++ === 0 ) {
afe42d0… ragelink 9404 jQuery.event.trigger( "ajaxStart" );
afe42d0… ragelink 9405 }
afe42d0… ragelink 9406
afe42d0… ragelink 9407 // Uppercase the type
afe42d0… ragelink 9408 s.type = s.type.toUpperCase();
afe42d0… ragelink 9409
afe42d0… ragelink 9410 // Determine if request has content
afe42d0… ragelink 9411 s.hasContent = !rnoContent.test( s.type );
afe42d0… ragelink 9412
afe42d0… ragelink 9413 // Save the URL in case we're toying with the If-Modified-Since
afe42d0… ragelink 9414 // and/or If-None-Match header later on
afe42d0… ragelink 9415 // Remove hash to simplify url manipulation
afe42d0… ragelink 9416 cacheURL = s.url.replace( rhash, "" );
afe42d0… ragelink 9417
afe42d0… ragelink 9418 // More options handling for requests with no content
afe42d0… ragelink 9419 if ( !s.hasContent ) {
afe42d0… ragelink 9420
afe42d0… ragelink 9421 // Remember the hash so we can put it back
afe42d0… ragelink 9422 uncached = s.url.slice( cacheURL.length );
afe42d0… ragelink 9423
afe42d0… ragelink 9424 // If data is available and should be processed, append data to url
afe42d0… ragelink 9425 if ( s.data && ( s.processData || typeof s.data === "string" ) ) {
afe42d0… ragelink 9426 cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data;
afe42d0… ragelink 9427
afe42d0… ragelink 9428 // trac-9682: remove data so that it's not used in an eventual retry
afe42d0… ragelink 9429 delete s.data;
afe42d0… ragelink 9430 }
afe42d0… ragelink 9431
afe42d0… ragelink 9432 // Add or update anti-cache param if needed
afe42d0… ragelink 9433 if ( s.cache === false ) {
afe42d0… ragelink 9434 cacheURL = cacheURL.replace( rantiCache, "$1" );
afe42d0… ragelink 9435 uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce.guid++ ) +
afe42d0… ragelink 9436 uncached;
afe42d0… ragelink 9437 }
afe42d0… ragelink 9438
afe42d0… ragelink 9439 // Put hash and anti-cache on the URL that will be requested (gh-1732)
afe42d0… ragelink 9440 s.url = cacheURL + uncached;
afe42d0… ragelink 9441
afe42d0… ragelink 9442 // Change '%20' to '+' if this is encoded form body content (gh-2658)
afe42d0… ragelink 9443 } else if ( s.data && s.processData &&
afe42d0… ragelink 9444 ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
afe42d0… ragelink 9445 s.data = s.data.replace( r20, "+" );
afe42d0… ragelink 9446 }
afe42d0… ragelink 9447
afe42d0… ragelink 9448 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
afe42d0… ragelink 9449 if ( s.ifModified ) {
afe42d0… ragelink 9450 if ( jQuery.lastModified[ cacheURL ] ) {
afe42d0… ragelink 9451 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
afe42d0… ragelink 9452 }
afe42d0… ragelink 9453 if ( jQuery.etag[ cacheURL ] ) {
afe42d0… ragelink 9454 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
afe42d0… ragelink 9455 }
afe42d0… ragelink 9456 }
afe42d0… ragelink 9457
afe42d0… ragelink 9458 // Set the correct header, if data is being sent
afe42d0… ragelink 9459 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
afe42d0… ragelink 9460 jqXHR.setRequestHeader( "Content-Type", s.contentType );
afe42d0… ragelink 9461 }
afe42d0… ragelink 9462
afe42d0… ragelink 9463 // Set the Accepts header for the server, depending on the dataType
afe42d0… ragelink 9464 jqXHR.setRequestHeader(
afe42d0… ragelink 9465 "Accept",
afe42d0… ragelink 9466 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
afe42d0… ragelink 9467 s.accepts[ s.dataTypes[ 0 ] ] +
afe42d0… ragelink 9468 ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
afe42d0… ragelink 9469 s.accepts[ "*" ]
afe42d0… ragelink 9470 );
afe42d0… ragelink 9471
afe42d0… ragelink 9472 // Check for headers option
afe42d0… ragelink 9473 for ( i in s.headers ) {
afe42d0… ragelink 9474 jqXHR.setRequestHeader( i, s.headers[ i ] );
afe42d0… ragelink 9475 }
afe42d0… ragelink 9476
afe42d0… ragelink 9477 // Allow custom headers/mimetypes and early abort
afe42d0… ragelink 9478 if ( s.beforeSend &&
afe42d0… ragelink 9479 ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) {
afe42d0… ragelink 9480
afe42d0… ragelink 9481 // Abort if not done already and return
afe42d0… ragelink 9482 return jqXHR.abort();
afe42d0… ragelink 9483 }
afe42d0… ragelink 9484
afe42d0… ragelink 9485 // Aborting is no longer a cancellation
afe42d0… ragelink 9486 strAbort = "abort";
afe42d0… ragelink 9487
afe42d0… ragelink 9488 // Install callbacks on deferreds
afe42d0… ragelink 9489 completeDeferred.add( s.complete );
afe42d0… ragelink 9490 jqXHR.done( s.success );
afe42d0… ragelink 9491 jqXHR.fail( s.error );
afe42d0… ragelink 9492
afe42d0… ragelink 9493 // Get transport
afe42d0… ragelink 9494 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
afe42d0… ragelink 9495
afe42d0… ragelink 9496 // If no transport, we auto-abort
afe42d0… ragelink 9497 if ( !transport ) {
afe42d0… ragelink 9498 done( -1, "No Transport" );
afe42d0… ragelink 9499 } else {
afe42d0… ragelink 9500 jqXHR.readyState = 1;
afe42d0… ragelink 9501
afe42d0… ragelink 9502 // Send global event
afe42d0… ragelink 9503 if ( fireGlobals ) {
afe42d0… ragelink 9504 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
afe42d0… ragelink 9505 }
afe42d0… ragelink 9506
afe42d0… ragelink 9507 // If request was aborted inside ajaxSend, stop there
afe42d0… ragelink 9508 if ( completed ) {
afe42d0… ragelink 9509 return jqXHR;
afe42d0… ragelink 9510 }
afe42d0… ragelink 9511
afe42d0… ragelink 9512 // Timeout
afe42d0… ragelink 9513 if ( s.async && s.timeout > 0 ) {
afe42d0… ragelink 9514 timeoutTimer = window.setTimeout( function() {
afe42d0… ragelink 9515 jqXHR.abort( "timeout" );
afe42d0… ragelink 9516 }, s.timeout );
afe42d0… ragelink 9517 }
afe42d0… ragelink 9518
afe42d0… ragelink 9519 try {
afe42d0… ragelink 9520 completed = false;
afe42d0… ragelink 9521 transport.send( requestHeaders, done );
afe42d0… ragelink 9522 } catch ( e ) {
afe42d0… ragelink 9523
afe42d0… ragelink 9524 // Rethrow post-completion exceptions
afe42d0… ragelink 9525 if ( completed ) {
afe42d0… ragelink 9526 throw e;
afe42d0… ragelink 9527 }
afe42d0… ragelink 9528
afe42d0… ragelink 9529 // Propagate others as results
afe42d0… ragelink 9530 done( -1, e );
afe42d0… ragelink 9531 }
afe42d0… ragelink 9532 }
afe42d0… ragelink 9533
afe42d0… ragelink 9534 // Callback for when everything is done
afe42d0… ragelink 9535 function done( status, nativeStatusText, responses, headers ) {
afe42d0… ragelink 9536 var isSuccess, success, error, response, modified,
afe42d0… ragelink 9537 statusText = nativeStatusText;
afe42d0… ragelink 9538
afe42d0… ragelink 9539 // Ignore repeat invocations
afe42d0… ragelink 9540 if ( completed ) {
afe42d0… ragelink 9541 return;
afe42d0… ragelink 9542 }
afe42d0… ragelink 9543
afe42d0… ragelink 9544 completed = true;
afe42d0… ragelink 9545
afe42d0… ragelink 9546 // Clear timeout if it exists
afe42d0… ragelink 9547 if ( timeoutTimer ) {
afe42d0… ragelink 9548 window.clearTimeout( timeoutTimer );
afe42d0… ragelink 9549 }
afe42d0… ragelink 9550
afe42d0… ragelink 9551 // Dereference transport for early garbage collection
afe42d0… ragelink 9552 // (no matter how long the jqXHR object will be used)
afe42d0… ragelink 9553 transport = undefined;
afe42d0… ragelink 9554
afe42d0… ragelink 9555 // Cache response headers
afe42d0… ragelink 9556 responseHeadersString = headers || "";
afe42d0… ragelink 9557
afe42d0… ragelink 9558 // Set readyState
afe42d0… ragelink 9559 jqXHR.readyState = status > 0 ? 4 : 0;
afe42d0… ragelink 9560
afe42d0… ragelink 9561 // Determine if successful
afe42d0… ragelink 9562 isSuccess = status >= 200 && status < 300 || status === 304;
afe42d0… ragelink 9563
afe42d0… ragelink 9564 // Get response data
afe42d0… ragelink 9565 if ( responses ) {
afe42d0… ragelink 9566 response = ajaxHandleResponses( s, jqXHR, responses );
afe42d0… ragelink 9567 }
afe42d0… ragelink 9568
afe42d0… ragelink 9569 // Use a noop converter for missing script but not if jsonp
afe42d0… ragelink 9570 if ( !isSuccess &&
afe42d0… ragelink 9571 jQuery.inArray( "script", s.dataTypes ) > -1 &&
afe42d0… ragelink 9572 jQuery.inArray( "json", s.dataTypes ) < 0 ) {
afe42d0… ragelink 9573 s.converters[ "text script" ] = function() {};
afe42d0… ragelink 9574 }
afe42d0… ragelink 9575
afe42d0… ragelink 9576 // Convert no matter what (that way responseXXX fields are always set)
afe42d0… ragelink 9577 response = ajaxConvert( s, response, jqXHR, isSuccess );
afe42d0… ragelink 9578
afe42d0… ragelink 9579 // If successful, handle type chaining
afe42d0… ragelink 9580 if ( isSuccess ) {
afe42d0… ragelink 9581
afe42d0… ragelink 9582 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
afe42d0… ragelink 9583 if ( s.ifModified ) {
afe42d0… ragelink 9584 modified = jqXHR.getResponseHeader( "Last-Modified" );
afe42d0… ragelink 9585 if ( modified ) {
afe42d0… ragelink 9586 jQuery.lastModified[ cacheURL ] = modified;
afe42d0… ragelink 9587 }
afe42d0… ragelink 9588 modified = jqXHR.getResponseHeader( "etag" );
afe42d0… ragelink 9589 if ( modified ) {
afe42d0… ragelink 9590 jQuery.etag[ cacheURL ] = modified;
afe42d0… ragelink 9591 }
afe42d0… ragelink 9592 }
afe42d0… ragelink 9593
afe42d0… ragelink 9594 // if no content
afe42d0… ragelink 9595 if ( status === 204 || s.type === "HEAD" ) {
afe42d0… ragelink 9596 statusText = "nocontent";
afe42d0… ragelink 9597
afe42d0… ragelink 9598 // if not modified
afe42d0… ragelink 9599 } else if ( status === 304 ) {
afe42d0… ragelink 9600 statusText = "notmodified";
afe42d0… ragelink 9601
afe42d0… ragelink 9602 // If we have data, let's convert it
afe42d0… ragelink 9603 } else {
afe42d0… ragelink 9604 statusText = response.state;
afe42d0… ragelink 9605 success = response.data;
afe42d0… ragelink 9606 error = response.error;
afe42d0… ragelink 9607 isSuccess = !error;
afe42d0… ragelink 9608 }
afe42d0… ragelink 9609 } else {
afe42d0… ragelink 9610
afe42d0… ragelink 9611 // Extract error from statusText and normalize for non-aborts
afe42d0… ragelink 9612 error = statusText;
afe42d0… ragelink 9613 if ( status || !statusText ) {
afe42d0… ragelink 9614 statusText = "error";
afe42d0… ragelink 9615 if ( status < 0 ) {
afe42d0… ragelink 9616 status = 0;
afe42d0… ragelink 9617 }
afe42d0… ragelink 9618 }
afe42d0… ragelink 9619 }
afe42d0… ragelink 9620
afe42d0… ragelink 9621 // Set data for the fake xhr object
afe42d0… ragelink 9622 jqXHR.status = status;
afe42d0… ragelink 9623 jqXHR.statusText = ( nativeStatusText || statusText ) + "";
afe42d0… ragelink 9624
afe42d0… ragelink 9625 // Success/Error
afe42d0… ragelink 9626 if ( isSuccess ) {
afe42d0… ragelink 9627 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
afe42d0… ragelink 9628 } else {
afe42d0… ragelink 9629 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
afe42d0… ragelink 9630 }
afe42d0… ragelink 9631
afe42d0… ragelink 9632 // Status-dependent callbacks
afe42d0… ragelink 9633 jqXHR.statusCode( statusCode );
afe42d0… ragelink 9634 statusCode = undefined;
afe42d0… ragelink 9635
afe42d0… ragelink 9636 if ( fireGlobals ) {
afe42d0… ragelink 9637 globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
afe42d0… ragelink 9638 [ jqXHR, s, isSuccess ? success : error ] );
afe42d0… ragelink 9639 }
afe42d0… ragelink 9640
afe42d0… ragelink 9641 // Complete
afe42d0… ragelink 9642 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
afe42d0… ragelink 9643
afe42d0… ragelink 9644 if ( fireGlobals ) {
afe42d0… ragelink 9645 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
afe42d0… ragelink 9646
afe42d0… ragelink 9647 // Handle the global AJAX counter
afe42d0… ragelink 9648 if ( !( --jQuery.active ) ) {
afe42d0… ragelink 9649 jQuery.event.trigger( "ajaxStop" );
afe42d0… ragelink 9650 }
afe42d0… ragelink 9651 }
afe42d0… ragelink 9652 }
afe42d0… ragelink 9653
afe42d0… ragelink 9654 return jqXHR;
afe42d0… ragelink 9655 },
afe42d0… ragelink 9656
afe42d0… ragelink 9657 getJSON: function( url, data, callback ) {
afe42d0… ragelink 9658 return jQuery.get( url, data, callback, "json" );
afe42d0… ragelink 9659 },
afe42d0… ragelink 9660
afe42d0… ragelink 9661 getScript: function( url, callback ) {
afe42d0… ragelink 9662 return jQuery.get( url, undefined, callback, "script" );
afe42d0… ragelink 9663 }
afe42d0… ragelink 9664 } );
afe42d0… ragelink 9665
afe42d0… ragelink 9666 jQuery.each( [ "get", "post" ], function( _i, method ) {
afe42d0… ragelink 9667 jQuery[ method ] = function( url, data, callback, type ) {
afe42d0… ragelink 9668
afe42d0… ragelink 9669 // Shift arguments if data argument was omitted
afe42d0… ragelink 9670 if ( isFunction( data ) ) {
afe42d0… ragelink 9671 type = type || callback;
afe42d0… ragelink 9672 callback = data;
afe42d0… ragelink 9673 data = undefined;
afe42d0… ragelink 9674 }
afe42d0… ragelink 9675
afe42d0… ragelink 9676 // The url can be an options object (which then must have .url)
afe42d0… ragelink 9677 return jQuery.ajax( jQuery.extend( {
afe42d0… ragelink 9678 url: url,
afe42d0… ragelink 9679 type: method,
afe42d0… ragelink 9680 dataType: type,
afe42d0… ragelink 9681 data: data,
afe42d0… ragelink 9682 success: callback
afe42d0… ragelink 9683 }, jQuery.isPlainObject( url ) && url ) );
afe42d0… ragelink 9684 };
afe42d0… ragelink 9685 } );
afe42d0… ragelink 9686
afe42d0… ragelink 9687 jQuery.ajaxPrefilter( function( s ) {
afe42d0… ragelink 9688 var i;
afe42d0… ragelink 9689 for ( i in s.headers ) {
afe42d0… ragelink 9690 if ( i.toLowerCase() === "content-type" ) {
afe42d0… ragelink 9691 s.contentType = s.headers[ i ] || "";
afe42d0… ragelink 9692 }
afe42d0… ragelink 9693 }
afe42d0… ragelink 9694 } );
afe42d0… ragelink 9695
afe42d0… ragelink 9696
afe42d0… ragelink 9697 jQuery._evalUrl = function( url, options, doc ) {
afe42d0… ragelink 9698 return jQuery.ajax( {
afe42d0… ragelink 9699 url: url,
afe42d0… ragelink 9700
afe42d0… ragelink 9701 // Make this explicit, since user can override this through ajaxSetup (trac-11264)
afe42d0… ragelink 9702 type: "GET",
afe42d0… ragelink 9703 dataType: "script",
afe42d0… ragelink 9704 cache: true,
afe42d0… ragelink 9705 async: false,
afe42d0… ragelink 9706 global: false,
afe42d0… ragelink 9707
afe42d0… ragelink 9708 // Only evaluate the response if it is successful (gh-4126)
afe42d0… ragelink 9709 // dataFilter is not invoked for failure responses, so using it instead
afe42d0… ragelink 9710 // of the default converter is kludgy but it works.
afe42d0… ragelink 9711 converters: {
afe42d0… ragelink 9712 "text script": function() {}
afe42d0… ragelink 9713 },
afe42d0… ragelink 9714 dataFilter: function( response ) {
afe42d0… ragelink 9715 jQuery.globalEval( response, options, doc );
afe42d0… ragelink 9716 }
afe42d0… ragelink 9717 } );
afe42d0… ragelink 9718 };
afe42d0… ragelink 9719
afe42d0… ragelink 9720
afe42d0… ragelink 9721 jQuery.fn.extend( {
afe42d0… ragelink 9722 wrapAll: function( html ) {
afe42d0… ragelink 9723 var wrap;
afe42d0… ragelink 9724
afe42d0… ragelink 9725 if ( this[ 0 ] ) {
afe42d0… ragelink 9726 if ( isFunction( html ) ) {
afe42d0… ragelink 9727 html = html.call( this[ 0 ] );
afe42d0… ragelink 9728 }
afe42d0… ragelink 9729
afe42d0… ragelink 9730 // The elements to wrap the target around
afe42d0… ragelink 9731 wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
afe42d0… ragelink 9732
afe42d0… ragelink 9733 if ( this[ 0 ].parentNode ) {
afe42d0… ragelink 9734 wrap.insertBefore( this[ 0 ] );
afe42d0… ragelink 9735 }
afe42d0… ragelink 9736
afe42d0… ragelink 9737 wrap.map( function() {
afe42d0… ragelink 9738 var elem = this;
afe42d0… ragelink 9739
afe42d0… ragelink 9740 while ( elem.firstElementChild ) {
afe42d0… ragelink 9741 elem = elem.firstElementChild;
afe42d0… ragelink 9742 }
afe42d0… ragelink 9743
afe42d0… ragelink 9744 return elem;
afe42d0… ragelink 9745 } ).append( this );
afe42d0… ragelink 9746 }
afe42d0… ragelink 9747
afe42d0… ragelink 9748 return this;
afe42d0… ragelink 9749 },
afe42d0… ragelink 9750
afe42d0… ragelink 9751 wrapInner: function( html ) {
afe42d0… ragelink 9752 if ( isFunction( html ) ) {
afe42d0… ragelink 9753 return this.each( function( i ) {
afe42d0… ragelink 9754 jQuery( this ).wrapInner( html.call( this, i ) );
afe42d0… ragelink 9755 } );
afe42d0… ragelink 9756 }
afe42d0… ragelink 9757
afe42d0… ragelink 9758 return this.each( function() {
afe42d0… ragelink 9759 var self = jQuery( this ),
afe42d0… ragelink 9760 contents = self.contents();
afe42d0… ragelink 9761
afe42d0… ragelink 9762 if ( contents.length ) {
afe42d0… ragelink 9763 contents.wrapAll( html );
afe42d0… ragelink 9764
afe42d0… ragelink 9765 } else {
afe42d0… ragelink 9766 self.append( html );
afe42d0… ragelink 9767 }
afe42d0… ragelink 9768 } );
afe42d0… ragelink 9769 },
afe42d0… ragelink 9770
afe42d0… ragelink 9771 wrap: function( html ) {
afe42d0… ragelink 9772 var htmlIsFunction = isFunction( html );
afe42d0… ragelink 9773
afe42d0… ragelink 9774 return this.each( function( i ) {
afe42d0… ragelink 9775 jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html );
afe42d0… ragelink 9776 } );
afe42d0… ragelink 9777 },
afe42d0… ragelink 9778
afe42d0… ragelink 9779 unwrap: function( selector ) {
afe42d0… ragelink 9780 this.parent( selector ).not( "body" ).each( function() {
afe42d0… ragelink 9781 jQuery( this ).replaceWith( this.childNodes );
afe42d0… ragelink 9782 } );
afe42d0… ragelink 9783 return this;
afe42d0… ragelink 9784 }
afe42d0… ragelink 9785 } );
afe42d0… ragelink 9786
afe42d0… ragelink 9787
afe42d0… ragelink 9788 jQuery.expr.pseudos.hidden = function( elem ) {
afe42d0… ragelink 9789 return !jQuery.expr.pseudos.visible( elem );
afe42d0… ragelink 9790 };
afe42d0… ragelink 9791 jQuery.expr.pseudos.visible = function( elem ) {
afe42d0… ragelink 9792 return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
afe42d0… ragelink 9793 };
afe42d0… ragelink 9794
afe42d0… ragelink 9795
afe42d0… ragelink 9796
afe42d0… ragelink 9797
afe42d0… ragelink 9798 jQuery.ajaxSettings.xhr = function() {
afe42d0… ragelink 9799 try {
afe42d0… ragelink 9800 return new window.XMLHttpRequest();
afe42d0… ragelink 9801 } catch ( e ) {}
afe42d0… ragelink 9802 };
afe42d0… ragelink 9803
afe42d0… ragelink 9804 var xhrSuccessStatus = {
afe42d0… ragelink 9805
afe42d0… ragelink 9806 // File protocol always yields status code 0, assume 200
afe42d0… ragelink 9807 0: 200,
afe42d0… ragelink 9808
afe42d0… ragelink 9809 // Support: IE <=9 only
afe42d0… ragelink 9810 // trac-1450: sometimes IE returns 1223 when it should be 204
afe42d0… ragelink 9811 1223: 204
afe42d0… ragelink 9812 },
afe42d0… ragelink 9813 xhrSupported = jQuery.ajaxSettings.xhr();
afe42d0… ragelink 9814
afe42d0… ragelink 9815 support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
afe42d0… ragelink 9816 support.ajax = xhrSupported = !!xhrSupported;
afe42d0… ragelink 9817
afe42d0… ragelink 9818 jQuery.ajaxTransport( function( options ) {
afe42d0… ragelink 9819 var callback, errorCallback;
afe42d0… ragelink 9820
afe42d0… ragelink 9821 // Cross domain only allowed if supported through XMLHttpRequest
afe42d0… ragelink 9822 if ( support.cors || xhrSupported && !options.crossDomain ) {
afe42d0… ragelink 9823 return {
afe42d0… ragelink 9824 send: function( headers, complete ) {
afe42d0… ragelink 9825 var i,
afe42d0… ragelink 9826 xhr = options.xhr();
afe42d0… ragelink 9827
afe42d0… ragelink 9828 xhr.open(
afe42d0… ragelink 9829 options.type,
afe42d0… ragelink 9830 options.url,
afe42d0… ragelink 9831 options.async,
afe42d0… ragelink 9832 options.username,
afe42d0… ragelink 9833 options.password
afe42d0… ragelink 9834 );
afe42d0… ragelink 9835
afe42d0… ragelink 9836 // Apply custom fields if provided
afe42d0… ragelink 9837 if ( options.xhrFields ) {
afe42d0… ragelink 9838 for ( i in options.xhrFields ) {
afe42d0… ragelink 9839 xhr[ i ] = options.xhrFields[ i ];
afe42d0… ragelink 9840 }
afe42d0… ragelink 9841 }
afe42d0… ragelink 9842
afe42d0… ragelink 9843 // Override mime type if needed
afe42d0… ragelink 9844 if ( options.mimeType && xhr.overrideMimeType ) {
afe42d0… ragelink 9845 xhr.overrideMimeType( options.mimeType );
afe42d0… ragelink 9846 }
afe42d0… ragelink 9847
afe42d0… ragelink 9848 // X-Requested-With header
afe42d0… ragelink 9849 // For cross-domain requests, seeing as conditions for a preflight are
afe42d0… ragelink 9850 // akin to a jigsaw puzzle, we simply never set it to be sure.
afe42d0… ragelink 9851 // (it can always be set on a per-request basis or even using ajaxSetup)
afe42d0… ragelink 9852 // For same-domain requests, won't change header if already provided.
afe42d0… ragelink 9853 if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
afe42d0… ragelink 9854 headers[ "X-Requested-With" ] = "XMLHttpRequest";
afe42d0… ragelink 9855 }
afe42d0… ragelink 9856
afe42d0… ragelink 9857 // Set headers
afe42d0… ragelink 9858 for ( i in headers ) {
afe42d0… ragelink 9859 xhr.setRequestHeader( i, headers[ i ] );
afe42d0… ragelink 9860 }
afe42d0… ragelink 9861
afe42d0… ragelink 9862 // Callback
afe42d0… ragelink 9863 callback = function( type ) {
afe42d0… ragelink 9864 return function() {
afe42d0… ragelink 9865 if ( callback ) {
afe42d0… ragelink 9866 callback = errorCallback = xhr.onload =
afe42d0… ragelink 9867 xhr.onerror = xhr.onabort = xhr.ontimeout =
afe42d0… ragelink 9868 xhr.onreadystatechange = null;
afe42d0… ragelink 9869
afe42d0… ragelink 9870 if ( type === "abort" ) {
afe42d0… ragelink 9871 xhr.abort();
afe42d0… ragelink 9872 } else if ( type === "error" ) {
afe42d0… ragelink 9873
afe42d0… ragelink 9874 // Support: IE <=9 only
afe42d0… ragelink 9875 // On a manual native abort, IE9 throws
afe42d0… ragelink 9876 // errors on any property access that is not readyState
afe42d0… ragelink 9877 if ( typeof xhr.status !== "number" ) {
afe42d0… ragelink 9878 complete( 0, "error" );
afe42d0… ragelink 9879 } else {
afe42d0… ragelink 9880 complete(
afe42d0… ragelink 9881
afe42d0… ragelink 9882 // File: protocol always yields status 0; see trac-8605, trac-14207
afe42d0… ragelink 9883 xhr.status,
afe42d0… ragelink 9884 xhr.statusText
afe42d0… ragelink 9885 );
afe42d0… ragelink 9886 }
afe42d0… ragelink 9887 } else {
afe42d0… ragelink 9888 complete(
afe42d0… ragelink 9889 xhrSuccessStatus[ xhr.status ] || xhr.status,
afe42d0… ragelink 9890 xhr.statusText,
afe42d0… ragelink 9891
afe42d0… ragelink 9892 // Support: IE <=9 only
afe42d0… ragelink 9893 // IE9 has no XHR2 but throws on binary (trac-11426)
afe42d0… ragelink 9894 // For XHR2 non-text, let the caller handle it (gh-2498)
afe42d0… ragelink 9895 ( xhr.responseType || "text" ) !== "text" ||
afe42d0… ragelink 9896 typeof xhr.responseText !== "string" ?
afe42d0… ragelink 9897 { binary: xhr.response } :
afe42d0… ragelink 9898 { text: xhr.responseText },
afe42d0… ragelink 9899 xhr.getAllResponseHeaders()
afe42d0… ragelink 9900 );
afe42d0… ragelink 9901 }
afe42d0… ragelink 9902 }
afe42d0… ragelink 9903 };
afe42d0… ragelink 9904 };
afe42d0… ragelink 9905
afe42d0… ragelink 9906 // Listen to events
afe42d0… ragelink 9907 xhr.onload = callback();
afe42d0… ragelink 9908 errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" );
afe42d0… ragelink 9909
afe42d0… ragelink 9910 // Support: IE 9 only
afe42d0… ragelink 9911 // Use onreadystatechange to replace onabort
afe42d0… ragelink 9912 // to handle uncaught aborts
afe42d0… ragelink 9913 if ( xhr.onabort !== undefined ) {
afe42d0… ragelink 9914 xhr.onabort = errorCallback;
afe42d0… ragelink 9915 } else {
afe42d0… ragelink 9916 xhr.onreadystatechange = function() {
afe42d0… ragelink 9917
afe42d0… ragelink 9918 // Check readyState before timeout as it changes
afe42d0… ragelink 9919 if ( xhr.readyState === 4 ) {
afe42d0… ragelink 9920
afe42d0… ragelink 9921 // Allow onerror to be called first,
afe42d0… ragelink 9922 // but that will not handle a native abort
afe42d0… ragelink 9923 // Also, save errorCallback to a variable
afe42d0… ragelink 9924 // as xhr.onerror cannot be accessed
afe42d0… ragelink 9925 window.setTimeout( function() {
afe42d0… ragelink 9926 if ( callback ) {
afe42d0… ragelink 9927 errorCallback();
afe42d0… ragelink 9928 }
afe42d0… ragelink 9929 } );
afe42d0… ragelink 9930 }
afe42d0… ragelink 9931 };
afe42d0… ragelink 9932 }
afe42d0… ragelink 9933
afe42d0… ragelink 9934 // Create the abort callback
afe42d0… ragelink 9935 callback = callback( "abort" );
afe42d0… ragelink 9936
afe42d0… ragelink 9937 try {
afe42d0… ragelink 9938
afe42d0… ragelink 9939 // Do send the request (this may raise an exception)
afe42d0… ragelink 9940 xhr.send( options.hasContent && options.data || null );
afe42d0… ragelink 9941 } catch ( e ) {
afe42d0… ragelink 9942
afe42d0… ragelink 9943 // trac-14683: Only rethrow if this hasn't been notified as an error yet
afe42d0… ragelink 9944 if ( callback ) {
afe42d0… ragelink 9945 throw e;
afe42d0… ragelink 9946 }
afe42d0… ragelink 9947 }
afe42d0… ragelink 9948 },
afe42d0… ragelink 9949
afe42d0… ragelink 9950 abort: function() {
afe42d0… ragelink 9951 if ( callback ) {
afe42d0… ragelink 9952 callback();
afe42d0… ragelink 9953 }
afe42d0… ragelink 9954 }
afe42d0… ragelink 9955 };
afe42d0… ragelink 9956 }
afe42d0… ragelink 9957 } );
afe42d0… ragelink 9958
afe42d0… ragelink 9959
afe42d0… ragelink 9960
afe42d0… ragelink 9961
afe42d0… ragelink 9962 // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
afe42d0… ragelink 9963 jQuery.ajaxPrefilter( function( s ) {
afe42d0… ragelink 9964 if ( s.crossDomain ) {
afe42d0… ragelink 9965 s.contents.script = false;
afe42d0… ragelink 9966 }
afe42d0… ragelink 9967 } );
afe42d0… ragelink 9968
afe42d0… ragelink 9969 // Install script dataType
afe42d0… ragelink 9970 jQuery.ajaxSetup( {
afe42d0… ragelink 9971 accepts: {
afe42d0… ragelink 9972 script: "text/javascript, application/javascript, " +
afe42d0… ragelink 9973 "application/ecmascript, application/x-ecmascript"
afe42d0… ragelink 9974 },
afe42d0… ragelink 9975 contents: {
afe42d0… ragelink 9976 script: /\b(?:java|ecma)script\b/
afe42d0… ragelink 9977 },
afe42d0… ragelink 9978 converters: {
afe42d0… ragelink 9979 "text script": function( text ) {
afe42d0… ragelink 9980 jQuery.globalEval( text );
afe42d0… ragelink 9981 return text;
afe42d0… ragelink 9982 }
afe42d0… ragelink 9983 }
afe42d0… ragelink 9984 } );
afe42d0… ragelink 9985
afe42d0… ragelink 9986 // Handle cache's special case and crossDomain
afe42d0… ragelink 9987 jQuery.ajaxPrefilter( "script", function( s ) {
afe42d0… ragelink 9988 if ( s.cache === undefined ) {
afe42d0… ragelink 9989 s.cache = false;
afe42d0… ragelink 9990 }
afe42d0… ragelink 9991 if ( s.crossDomain ) {
afe42d0… ragelink 9992 s.type = "GET";
afe42d0… ragelink 9993 }
afe42d0… ragelink 9994 } );
afe42d0… ragelink 9995
afe42d0… ragelink 9996 // Bind script tag hack transport
afe42d0… ragelink 9997 jQuery.ajaxTransport( "script", function( s ) {
afe42d0… ragelink 9998
afe42d0… ragelink 9999 // This transport only deals with cross domain or forced-by-attrs requests
afe42d0… ragelink 10000 if ( s.crossDomain || s.scriptAttrs ) {
afe42d0… ragelink 10001 var script, callback;
afe42d0… ragelink 10002 return {
afe42d0… ragelink 10003 send: function( _, complete ) {
afe42d0… ragelink 10004 script = jQuery( "<script>" )
afe42d0… ragelink 10005 .attr( s.scriptAttrs || {} )
afe42d0… ragelink 10006 .prop( { charset: s.scriptCharset, src: s.url } )
afe42d0… ragelink 10007 .on( "load error", callback = function( evt ) {
afe42d0… ragelink 10008 script.remove();
afe42d0… ragelink 10009 callback = null;
afe42d0… ragelink 10010 if ( evt ) {
afe42d0… ragelink 10011 complete( evt.type === "error" ? 404 : 200, evt.type );
afe42d0… ragelink 10012 }
afe42d0… ragelink 10013 } );
afe42d0… ragelink 10014
afe42d0… ragelink 10015 // Use native DOM manipulation to avoid our domManip AJAX trickery
afe42d0… ragelink 10016 document.head.appendChild( script[ 0 ] );
afe42d0… ragelink 10017 },
afe42d0… ragelink 10018 abort: function() {
afe42d0… ragelink 10019 if ( callback ) {
afe42d0… ragelink 10020 callback();
afe42d0… ragelink 10021 }
afe42d0… ragelink 10022 }
afe42d0… ragelink 10023 };
afe42d0… ragelink 10024 }
afe42d0… ragelink 10025 } );
afe42d0… ragelink 10026
afe42d0… ragelink 10027
afe42d0… ragelink 10028
afe42d0… ragelink 10029
afe42d0… ragelink 10030 var oldCallbacks = [],
afe42d0… ragelink 10031 rjsonp = /(=)\?(?=&|$)|\?\?/;
afe42d0… ragelink 10032
afe42d0… ragelink 10033 // Default jsonp settings
afe42d0… ragelink 10034 jQuery.ajaxSetup( {
afe42d0… ragelink 10035 jsonp: "callback",
afe42d0… ragelink 10036 jsonpCallback: function() {
afe42d0… ragelink 10037 var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce.guid++ ) );
afe42d0… ragelink 10038 this[ callback ] = true;
afe42d0… ragelink 10039 return callback;
afe42d0… ragelink 10040 }
afe42d0… ragelink 10041 } );
afe42d0… ragelink 10042
afe42d0… ragelink 10043 // Detect, normalize options and install callbacks for jsonp requests
afe42d0… ragelink 10044 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
afe42d0… ragelink 10045
afe42d0… ragelink 10046 var callbackName, overwritten, responseContainer,
afe42d0… ragelink 10047 jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
afe42d0… ragelink 10048 "url" :
afe42d0… ragelink 10049 typeof s.data === "string" &&
afe42d0… ragelink 10050 ( s.contentType || "" )
afe42d0… ragelink 10051 .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
afe42d0… ragelink 10052 rjsonp.test( s.data ) && "data"
afe42d0… ragelink 10053 );
afe42d0… ragelink 10054
afe42d0… ragelink 10055 // Handle iff the expected data type is "jsonp" or we have a parameter to set
afe42d0… ragelink 10056 if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
afe42d0… ragelink 10057
afe42d0… ragelink 10058 // Get callback name, remembering preexisting value associated with it
afe42d0… ragelink 10059 callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ?
afe42d0… ragelink 10060 s.jsonpCallback() :
afe42d0… ragelink 10061 s.jsonpCallback;
afe42d0… ragelink 10062
afe42d0… ragelink 10063 // Insert callback into url or form data
afe42d0… ragelink 10064 if ( jsonProp ) {
afe42d0… ragelink 10065 s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
afe42d0… ragelink 10066 } else if ( s.jsonp !== false ) {
afe42d0… ragelink 10067 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
afe42d0… ragelink 10068 }
afe42d0… ragelink 10069
afe42d0… ragelink 10070 // Use data converter to retrieve json after script execution
afe42d0… ragelink 10071 s.converters[ "script json" ] = function() {
afe42d0… ragelink 10072 if ( !responseContainer ) {
afe42d0… ragelink 10073 jQuery.error( callbackName + " was not called" );
afe42d0… ragelink 10074 }
afe42d0… ragelink 10075 return responseContainer[ 0 ];
afe42d0… ragelink 10076 };
afe42d0… ragelink 10077
afe42d0… ragelink 10078 // Force json dataType
afe42d0… ragelink 10079 s.dataTypes[ 0 ] = "json";
afe42d0… ragelink 10080
afe42d0… ragelink 10081 // Install callback
afe42d0… ragelink 10082 overwritten = window[ callbackName ];
afe42d0… ragelink 10083 window[ callbackName ] = function() {
afe42d0… ragelink 10084 responseContainer = arguments;
afe42d0… ragelink 10085 };
afe42d0… ragelink 10086
afe42d0… ragelink 10087 // Clean-up function (fires after converters)
afe42d0… ragelink 10088 jqXHR.always( function() {
afe42d0… ragelink 10089
afe42d0… ragelink 10090 // If previous value didn't exist - remove it
afe42d0… ragelink 10091 if ( overwritten === undefined ) {
afe42d0… ragelink 10092 jQuery( window ).removeProp( callbackName );
afe42d0… ragelink 10093
afe42d0… ragelink 10094 // Otherwise restore preexisting value
afe42d0… ragelink 10095 } else {
afe42d0… ragelink 10096 window[ callbackName ] = overwritten;
afe42d0… ragelink 10097 }
afe42d0… ragelink 10098
afe42d0… ragelink 10099 // Save back as free
afe42d0… ragelink 10100 if ( s[ callbackName ] ) {
afe42d0… ragelink 10101
afe42d0… ragelink 10102 // Make sure that re-using the options doesn't screw things around
afe42d0… ragelink 10103 s.jsonpCallback = originalSettings.jsonpCallback;
afe42d0… ragelink 10104
afe42d0… ragelink 10105 // Save the callback name for future use
afe42d0… ragelink 10106 oldCallbacks.push( callbackName );
afe42d0… ragelink 10107 }
afe42d0… ragelink 10108
afe42d0… ragelink 10109 // Call if it was a function and we have a response
afe42d0… ragelink 10110 if ( responseContainer && isFunction( overwritten ) ) {
afe42d0… ragelink 10111 overwritten( responseContainer[ 0 ] );
afe42d0… ragelink 10112 }
afe42d0… ragelink 10113
afe42d0… ragelink 10114 responseContainer = overwritten = undefined;
afe42d0… ragelink 10115 } );
afe42d0… ragelink 10116
afe42d0… ragelink 10117 // Delegate to script
afe42d0… ragelink 10118 return "script";
afe42d0… ragelink 10119 }
afe42d0… ragelink 10120 } );
afe42d0… ragelink 10121
afe42d0… ragelink 10122
afe42d0… ragelink 10123
afe42d0… ragelink 10124
afe42d0… ragelink 10125 // Support: Safari 8 only
afe42d0… ragelink 10126 // In Safari 8 documents created via document.implementation.createHTMLDocument
afe42d0… ragelink 10127 // collapse sibling forms: the second one becomes a child of the first one.
afe42d0… ragelink 10128 // Because of that, this security measure has to be disabled in Safari 8.
afe42d0… ragelink 10129 // https://bugs.webkit.org/show_bug.cgi?id=137337
afe42d0… ragelink 10130 support.createHTMLDocument = ( function() {
afe42d0… ragelink 10131 var body = document.implementation.createHTMLDocument( "" ).body;
afe42d0… ragelink 10132 body.innerHTML = "<form></form><form></form>";
afe42d0… ragelink 10133 return body.childNodes.length === 2;
afe42d0… ragelink 10134 } )();
afe42d0… ragelink 10135
afe42d0… ragelink 10136
afe42d0… ragelink 10137 // Argument "data" should be string of html
afe42d0… ragelink 10138 // context (optional): If specified, the fragment will be created in this context,
afe42d0… ragelink 10139 // defaults to document
afe42d0… ragelink 10140 // keepScripts (optional): If true, will include scripts passed in the html string
afe42d0… ragelink 10141 jQuery.parseHTML = function( data, context, keepScripts ) {
afe42d0… ragelink 10142 if ( typeof data !== "string" ) {
afe42d0… ragelink 10143 return [];
afe42d0… ragelink 10144 }
afe42d0… ragelink 10145 if ( typeof context === "boolean" ) {
afe42d0… ragelink 10146 keepScripts = context;
afe42d0… ragelink 10147 context = false;
afe42d0… ragelink 10148 }
afe42d0… ragelink 10149
afe42d0… ragelink 10150 var base, parsed, scripts;
afe42d0… ragelink 10151
afe42d0… ragelink 10152 if ( !context ) {
afe42d0… ragelink 10153
afe42d0… ragelink 10154 // Stop scripts or inline event handlers from being executed immediately
afe42d0… ragelink 10155 // by using document.implementation
afe42d0… ragelink 10156 if ( support.createHTMLDocument ) {
afe42d0… ragelink 10157 context = document.implementation.createHTMLDocument( "" );
afe42d0… ragelink 10158
afe42d0… ragelink 10159 // Set the base href for the created document
afe42d0… ragelink 10160 // so any parsed elements with URLs
afe42d0… ragelink 10161 // are based on the document's URL (gh-2965)
afe42d0… ragelink 10162 base = context.createElement( "base" );
afe42d0… ragelink 10163 base.href = document.location.href;
afe42d0… ragelink 10164 context.head.appendChild( base );
afe42d0… ragelink 10165 } else {
afe42d0… ragelink 10166 context = document;
afe42d0… ragelink 10167 }
afe42d0… ragelink 10168 }
afe42d0… ragelink 10169
afe42d0… ragelink 10170 parsed = rsingleTag.exec( data );
afe42d0… ragelink 10171 scripts = !keepScripts && [];
afe42d0… ragelink 10172
afe42d0… ragelink 10173 // Single tag
afe42d0… ragelink 10174 if ( parsed ) {
afe42d0… ragelink 10175 return [ context.createElement( parsed[ 1 ] ) ];
afe42d0… ragelink 10176 }
afe42d0… ragelink 10177
afe42d0… ragelink 10178 parsed = buildFragment( [ data ], context, scripts );
afe42d0… ragelink 10179
afe42d0… ragelink 10180 if ( scripts && scripts.length ) {
afe42d0… ragelink 10181 jQuery( scripts ).remove();
afe42d0… ragelink 10182 }
afe42d0… ragelink 10183
afe42d0… ragelink 10184 return jQuery.merge( [], parsed.childNodes );
afe42d0… ragelink 10185 };
afe42d0… ragelink 10186
afe42d0… ragelink 10187
afe42d0… ragelink 10188 /**
afe42d0… ragelink 10189 * Load a url into a page
afe42d0… ragelink 10190 */
afe42d0… ragelink 10191 jQuery.fn.load = function( url, params, callback ) {
afe42d0… ragelink 10192 var selector, type, response,
afe42d0… ragelink 10193 self = this,
afe42d0… ragelink 10194 off = url.indexOf( " " );
afe42d0… ragelink 10195
afe42d0… ragelink 10196 if ( off > -1 ) {
afe42d0… ragelink 10197 selector = stripAndCollapse( url.slice( off ) );
afe42d0… ragelink 10198 url = url.slice( 0, off );
afe42d0… ragelink 10199 }
afe42d0… ragelink 10200
afe42d0… ragelink 10201 // If it's a function
afe42d0… ragelink 10202 if ( isFunction( params ) ) {
afe42d0… ragelink 10203
afe42d0… ragelink 10204 // We assume that it's the callback
afe42d0… ragelink 10205 callback = params;
afe42d0… ragelink 10206 params = undefined;
afe42d0… ragelink 10207
afe42d0… ragelink 10208 // Otherwise, build a param string
afe42d0… ragelink 10209 } else if ( params && typeof params === "object" ) {
afe42d0… ragelink 10210 type = "POST";
afe42d0… ragelink 10211 }
afe42d0… ragelink 10212
afe42d0… ragelink 10213 // If we have elements to modify, make the request
afe42d0… ragelink 10214 if ( self.length > 0 ) {
afe42d0… ragelink 10215 jQuery.ajax( {
afe42d0… ragelink 10216 url: url,
afe42d0… ragelink 10217
afe42d0… ragelink 10218 // If "type" variable is undefined, then "GET" method will be used.
afe42d0… ragelink 10219 // Make value of this field explicit since
afe42d0… ragelink 10220 // user can override it through ajaxSetup method
afe42d0… ragelink 10221 type: type || "GET",
afe42d0… ragelink 10222 dataType: "html",
afe42d0… ragelink 10223 data: params
afe42d0… ragelink 10224 } ).done( function( responseText ) {
afe42d0… ragelink 10225
afe42d0… ragelink 10226 // Save response for use in complete callback
afe42d0… ragelink 10227 response = arguments;
afe42d0… ragelink 10228
afe42d0… ragelink 10229 self.html( selector ?
afe42d0… ragelink 10230
afe42d0… ragelink 10231 // If a selector was specified, locate the right elements in a dummy div
afe42d0… ragelink 10232 // Exclude scripts to avoid IE 'Permission Denied' errors
afe42d0… ragelink 10233 jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
afe42d0… ragelink 10234
afe42d0… ragelink 10235 // Otherwise use the full result
afe42d0… ragelink 10236 responseText );
afe42d0… ragelink 10237
afe42d0… ragelink 10238 // If the request succeeds, this function gets "data", "status", "jqXHR"
afe42d0… ragelink 10239 // but they are ignored because response was set above.
afe42d0… ragelink 10240 // If it fails, this function gets "jqXHR", "status", "error"
afe42d0… ragelink 10241 } ).always( callback && function( jqXHR, status ) {
afe42d0… ragelink 10242 self.each( function() {
afe42d0… ragelink 10243 callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
afe42d0… ragelink 10244 } );
afe42d0… ragelink 10245 } );
afe42d0… ragelink 10246 }
afe42d0… ragelink 10247
afe42d0… ragelink 10248 return this;
afe42d0… ragelink 10249 };
afe42d0… ragelink 10250
afe42d0… ragelink 10251
afe42d0… ragelink 10252
afe42d0… ragelink 10253
afe42d0… ragelink 10254 jQuery.expr.pseudos.animated = function( elem ) {
afe42d0… ragelink 10255 return jQuery.grep( jQuery.timers, function( fn ) {
afe42d0… ragelink 10256 return elem === fn.elem;
afe42d0… ragelink 10257 } ).length;
afe42d0… ragelink 10258 };
afe42d0… ragelink 10259
afe42d0… ragelink 10260
afe42d0… ragelink 10261
afe42d0… ragelink 10262
afe42d0… ragelink 10263 jQuery.offset = {
afe42d0… ragelink 10264 setOffset: function( elem, options, i ) {
afe42d0… ragelink 10265 var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
afe42d0… ragelink 10266 position = jQuery.css( elem, "position" ),
afe42d0… ragelink 10267 curElem = jQuery( elem ),
afe42d0… ragelink 10268 props = {};
afe42d0… ragelink 10269
afe42d0… ragelink 10270 // Set position first, in-case top/left are set even on static elem
afe42d0… ragelink 10271 if ( position === "static" ) {
afe42d0… ragelink 10272 elem.style.position = "relative";
afe42d0… ragelink 10273 }
afe42d0… ragelink 10274
afe42d0… ragelink 10275 curOffset = curElem.offset();
afe42d0… ragelink 10276 curCSSTop = jQuery.css( elem, "top" );
afe42d0… ragelink 10277 curCSSLeft = jQuery.css( elem, "left" );
afe42d0… ragelink 10278 calculatePosition = ( position === "absolute" || position === "fixed" ) &&
afe42d0… ragelink 10279 ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
afe42d0… ragelink 10280
afe42d0… ragelink 10281 // Need to be able to calculate position if either
afe42d0… ragelink 10282 // top or left is auto and position is either absolute or fixed
afe42d0… ragelink 10283 if ( calculatePosition ) {
afe42d0… ragelink 10284 curPosition = curElem.position();
afe42d0… ragelink 10285 curTop = curPosition.top;
afe42d0… ragelink 10286 curLeft = curPosition.left;
afe42d0… ragelink 10287
afe42d0… ragelink 10288 } else {
afe42d0… ragelink 10289 curTop = parseFloat( curCSSTop ) || 0;
afe42d0… ragelink 10290 curLeft = parseFloat( curCSSLeft ) || 0;
afe42d0… ragelink 10291 }
afe42d0… ragelink 10292
afe42d0… ragelink 10293 if ( isFunction( options ) ) {
afe42d0… ragelink 10294
afe42d0… ragelink 10295 // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
afe42d0… ragelink 10296 options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
afe42d0… ragelink 10297 }
afe42d0… ragelink 10298
afe42d0… ragelink 10299 if ( options.top != null ) {
afe42d0… ragelink 10300 props.top = ( options.top - curOffset.top ) + curTop;
afe42d0… ragelink 10301 }
afe42d0… ragelink 10302 if ( options.left != null ) {
afe42d0… ragelink 10303 props.left = ( options.left - curOffset.left ) + curLeft;
afe42d0… ragelink 10304 }
afe42d0… ragelink 10305
afe42d0… ragelink 10306 if ( "using" in options ) {
afe42d0… ragelink 10307 options.using.call( elem, props );
afe42d0… ragelink 10308
afe42d0… ragelink 10309 } else {
afe42d0… ragelink 10310 curElem.css( props );
afe42d0… ragelink 10311 }
afe42d0… ragelink 10312 }
afe42d0… ragelink 10313 };
afe42d0… ragelink 10314
afe42d0… ragelink 10315 jQuery.fn.extend( {
afe42d0… ragelink 10316
afe42d0… ragelink 10317 // offset() relates an element's border box to the document origin
afe42d0… ragelink 10318 offset: function( options ) {
afe42d0… ragelink 10319
afe42d0… ragelink 10320 // Preserve chaining for setter
afe42d0… ragelink 10321 if ( arguments.length ) {
afe42d0… ragelink 10322 return options === undefined ?
afe42d0… ragelink 10323 this :
afe42d0… ragelink 10324 this.each( function( i ) {
afe42d0… ragelink 10325 jQuery.offset.setOffset( this, options, i );
afe42d0… ragelink 10326 } );
afe42d0… ragelink 10327 }
afe42d0… ragelink 10328
afe42d0… ragelink 10329 var rect, win,
afe42d0… ragelink 10330 elem = this[ 0 ];
afe42d0… ragelink 10331
afe42d0… ragelink 10332 if ( !elem ) {
afe42d0… ragelink 10333 return;
afe42d0… ragelink 10334 }
afe42d0… ragelink 10335
afe42d0… ragelink 10336 // Return zeros for disconnected and hidden (display: none) elements (gh-2310)
afe42d0… ragelink 10337 // Support: IE <=11 only
afe42d0… ragelink 10338 // Running getBoundingClientRect on a
afe42d0… ragelink 10339 // disconnected node in IE throws an error
afe42d0… ragelink 10340 if ( !elem.getClientRects().length ) {
afe42d0… ragelink 10341 return { top: 0, left: 0 };
afe42d0… ragelink 10342 }
afe42d0… ragelink 10343
afe42d0… ragelink 10344 // Get document-relative position by adding viewport scroll to viewport-relative gBCR
afe42d0… ragelink 10345 rect = elem.getBoundingClientRect();
afe42d0… ragelink 10346 win = elem.ownerDocument.defaultView;
afe42d0… ragelink 10347 return {
afe42d0… ragelink 10348 top: rect.top + win.pageYOffset,
afe42d0… ragelink 10349 left: rect.left + win.pageXOffset
afe42d0… ragelink 10350 };
afe42d0… ragelink 10351 },
afe42d0… ragelink 10352
afe42d0… ragelink 10353 // position() relates an element's margin box to its offset parent's padding box
afe42d0… ragelink 10354 // This corresponds to the behavior of CSS absolute positioning
afe42d0… ragelink 10355 position: function() {
afe42d0… ragelink 10356 if ( !this[ 0 ] ) {
afe42d0… ragelink 10357 return;
afe42d0… ragelink 10358 }
afe42d0… ragelink 10359
afe42d0… ragelink 10360 var offsetParent, offset, doc,
afe42d0… ragelink 10361 elem = this[ 0 ],
afe42d0… ragelink 10362 parentOffset = { top: 0, left: 0 };
afe42d0… ragelink 10363
afe42d0… ragelink 10364 // position:fixed elements are offset from the viewport, which itself always has zero offset
afe42d0… ragelink 10365 if ( jQuery.css( elem, "position" ) === "fixed" ) {
afe42d0… ragelink 10366
afe42d0… ragelink 10367 // Assume position:fixed implies availability of getBoundingClientRect
afe42d0… ragelink 10368 offset = elem.getBoundingClientRect();
afe42d0… ragelink 10369
afe42d0… ragelink 10370 } else {
afe42d0… ragelink 10371 offset = this.offset();
afe42d0… ragelink 10372
afe42d0… ragelink 10373 // Account for the *real* offset parent, which can be the document or its root element
afe42d0… ragelink 10374 // when a statically positioned element is identified
afe42d0… ragelink 10375 doc = elem.ownerDocument;
afe42d0… ragelink 10376 offsetParent = elem.offsetParent || doc.documentElement;
afe42d0… ragelink 10377 while ( offsetParent &&
afe42d0… ragelink 10378 ( offsetParent === doc.body || offsetParent === doc.documentElement ) &&
afe42d0… ragelink 10379 jQuery.css( offsetParent, "position" ) === "static" ) {
afe42d0… ragelink 10380
afe42d0… ragelink 10381 offsetParent = offsetParent.parentNode;
afe42d0… ragelink 10382 }
afe42d0… ragelink 10383 if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) {
afe42d0… ragelink 10384
afe42d0… ragelink 10385 // Incorporate borders into its offset, since they are outside its content origin
afe42d0… ragelink 10386 parentOffset = jQuery( offsetParent ).offset();
afe42d0… ragelink 10387 parentOffset.top += jQuery.css( offsetParent, "borderTopWidth", true );
afe42d0… ragelink 10388 parentOffset.left += jQuery.css( offsetParent, "borderLeftWidth", true );
afe42d0… ragelink 10389 }
afe42d0… ragelink 10390 }
afe42d0… ragelink 10391
afe42d0… ragelink 10392 // Subtract parent offsets and element margins
afe42d0… ragelink 10393 return {
afe42d0… ragelink 10394 top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
afe42d0… ragelink 10395 left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
afe42d0… ragelink 10396 };
afe42d0… ragelink 10397 },
afe42d0… ragelink 10398
afe42d0… ragelink 10399 // This method will return documentElement in the following cases:
afe42d0… ragelink 10400 // 1) For the element inside the iframe without offsetParent, this method will return
afe42d0… ragelink 10401 // documentElement of the parent window
afe42d0… ragelink 10402 // 2) For the hidden or detached element
afe42d0… ragelink 10403 // 3) For body or html element, i.e. in case of the html node - it will return itself
afe42d0… ragelink 10404 //
afe42d0… ragelink 10405 // but those exceptions were never presented as a real life use-cases
afe42d0… ragelink 10406 // and might be considered as more preferable results.
afe42d0… ragelink 10407 //
afe42d0… ragelink 10408 // This logic, however, is not guaranteed and can change at any point in the future
afe42d0… ragelink 10409 offsetParent: function() {
afe42d0… ragelink 10410 return this.map( function() {
afe42d0… ragelink 10411 var offsetParent = this.offsetParent;
afe42d0… ragelink 10412
afe42d0… ragelink 10413 while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
afe42d0… ragelink 10414 offsetParent = offsetParent.offsetParent;
afe42d0… ragelink 10415 }
afe42d0… ragelink 10416
afe42d0… ragelink 10417 return offsetParent || documentElement;
afe42d0… ragelink 10418 } );
afe42d0… ragelink 10419 }
afe42d0… ragelink 10420 } );
afe42d0… ragelink 10421
afe42d0… ragelink 10422 // Create scrollLeft and scrollTop methods
afe42d0… ragelink 10423 jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
afe42d0… ragelink 10424 var top = "pageYOffset" === prop;
afe42d0… ragelink 10425
afe42d0… ragelink 10426 jQuery.fn[ method ] = function( val ) {
afe42d0… ragelink 10427 return access( this, function( elem, method, val ) {
afe42d0… ragelink 10428
afe42d0… ragelink 10429 // Coalesce documents and windows
afe42d0… ragelink 10430 var win;
afe42d0… ragelink 10431 if ( isWindow( elem ) ) {
afe42d0… ragelink 10432 win = elem;
afe42d0… ragelink 10433 } else if ( elem.nodeType === 9 ) {
afe42d0… ragelink 10434 win = elem.defaultView;
afe42d0… ragelink 10435 }
afe42d0… ragelink 10436
afe42d0… ragelink 10437 if ( val === undefined ) {
afe42d0… ragelink 10438 return win ? win[ prop ] : elem[ method ];
afe42d0… ragelink 10439 }
afe42d0… ragelink 10440
afe42d0… ragelink 10441 if ( win ) {
afe42d0… ragelink 10442 win.scrollTo(
afe42d0… ragelink 10443 !top ? val : win.pageXOffset,
afe42d0… ragelink 10444 top ? val : win.pageYOffset
afe42d0… ragelink 10445 );
afe42d0… ragelink 10446
afe42d0… ragelink 10447 } else {
afe42d0… ragelink 10448 elem[ method ] = val;
afe42d0… ragelink 10449 }
afe42d0… ragelink 10450 }, method, val, arguments.length );
afe42d0… ragelink 10451 };
afe42d0… ragelink 10452 } );
afe42d0… ragelink 10453
afe42d0… ragelink 10454 // Support: Safari <=7 - 9.1, Chrome <=37 - 49
afe42d0… ragelink 10455 // Add the top/left cssHooks using jQuery.fn.position
afe42d0… ragelink 10456 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
afe42d0… ragelink 10457 // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
afe42d0… ragelink 10458 // getComputedStyle returns percent when specified for top/left/bottom/right;
afe42d0… ragelink 10459 // rather than make the css module depend on the offset module, just check for it here
afe42d0… ragelink 10460 jQuery.each( [ "top", "left" ], function( _i, prop ) {
afe42d0… ragelink 10461 jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
afe42d0… ragelink 10462 function( elem, computed ) {
afe42d0… ragelink 10463 if ( computed ) {
afe42d0… ragelink 10464 computed = curCSS( elem, prop );
afe42d0… ragelink 10465
afe42d0… ragelink 10466 // If curCSS returns percentage, fallback to offset
afe42d0… ragelink 10467 return rnumnonpx.test( computed ) ?
afe42d0… ragelink 10468 jQuery( elem ).position()[ prop ] + "px" :
afe42d0… ragelink 10469 computed;
afe42d0… ragelink 10470 }
afe42d0… ragelink 10471 }
afe42d0… ragelink 10472 );
afe42d0… ragelink 10473 } );
afe42d0… ragelink 10474
afe42d0… ragelink 10475
afe42d0… ragelink 10476 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
afe42d0… ragelink 10477 jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
afe42d0… ragelink 10478 jQuery.each( {
afe42d0… ragelink 10479 padding: "inner" + name,
afe42d0… ragelink 10480 content: type,
afe42d0… ragelink 10481 "": "outer" + name
afe42d0… ragelink 10482 }, function( defaultExtra, funcName ) {
afe42d0… ragelink 10483
afe42d0… ragelink 10484 // Margin is only for outerHeight, outerWidth
afe42d0… ragelink 10485 jQuery.fn[ funcName ] = function( margin, value ) {
afe42d0… ragelink 10486 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
afe42d0… ragelink 10487 extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
afe42d0… ragelink 10488
afe42d0… ragelink 10489 return access( this, function( elem, type, value ) {
afe42d0… ragelink 10490 var doc;
afe42d0… ragelink 10491
afe42d0… ragelink 10492 if ( isWindow( elem ) ) {
afe42d0… ragelink 10493
afe42d0… ragelink 10494 // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
afe42d0… ragelink 10495 return funcName.indexOf( "outer" ) === 0 ?
afe42d0… ragelink 10496 elem[ "inner" + name ] :
afe42d0… ragelink 10497 elem.document.documentElement[ "client" + name ];
afe42d0… ragelink 10498 }
afe42d0… ragelink 10499
afe42d0… ragelink 10500 // Get document width or height
afe42d0… ragelink 10501 if ( elem.nodeType === 9 ) {
afe42d0… ragelink 10502 doc = elem.documentElement;
afe42d0… ragelink 10503
afe42d0… ragelink 10504 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
afe42d0… ragelink 10505 // whichever is greatest
afe42d0… ragelink 10506 return Math.max(
afe42d0… ragelink 10507 elem.body[ "scroll" + name ], doc[ "scroll" + name ],
afe42d0… ragelink 10508 elem.body[ "offset" + name ], doc[ "offset" + name ],
afe42d0… ragelink 10509 doc[ "client" + name ]
afe42d0… ragelink 10510 );
afe42d0… ragelink 10511 }
afe42d0… ragelink 10512
afe42d0… ragelink 10513 return value === undefined ?
afe42d0… ragelink 10514
afe42d0… ragelink 10515 // Get width or height on the element, requesting but not forcing parseFloat
afe42d0… ragelink 10516 jQuery.css( elem, type, extra ) :
afe42d0… ragelink 10517
afe42d0… ragelink 10518 // Set width or height on the element
afe42d0… ragelink 10519 jQuery.style( elem, type, value, extra );
afe42d0… ragelink 10520 }, type, chainable ? margin : undefined, chainable );
afe42d0… ragelink 10521 };
afe42d0… ragelink 10522 } );
afe42d0… ragelink 10523 } );
afe42d0… ragelink 10524
afe42d0… ragelink 10525
afe42d0… ragelink 10526 jQuery.each( [
afe42d0… ragelink 10527 "ajaxStart",
afe42d0… ragelink 10528 "ajaxStop",
afe42d0… ragelink 10529 "ajaxComplete",
afe42d0… ragelink 10530 "ajaxError",
afe42d0… ragelink 10531 "ajaxSuccess",
afe42d0… ragelink 10532 "ajaxSend"
afe42d0… ragelink 10533 ], function( _i, type ) {
afe42d0… ragelink 10534 jQuery.fn[ type ] = function( fn ) {
afe42d0… ragelink 10535 return this.on( type, fn );
afe42d0… ragelink 10536 };
afe42d0… ragelink 10537 } );
afe42d0… ragelink 10538
afe42d0… ragelink 10539
afe42d0… ragelink 10540
afe42d0… ragelink 10541
afe42d0… ragelink 10542 jQuery.fn.extend( {
afe42d0… ragelink 10543
afe42d0… ragelink 10544 bind: function( types, data, fn ) {
afe42d0… ragelink 10545 return this.on( types, null, data, fn );
afe42d0… ragelink 10546 },
afe42d0… ragelink 10547 unbind: function( types, fn ) {
afe42d0… ragelink 10548 return this.off( types, null, fn );
afe42d0… ragelink 10549 },
afe42d0… ragelink 10550
afe42d0… ragelink 10551 delegate: function( selector, types, data, fn ) {
afe42d0… ragelink 10552 return this.on( types, selector, data, fn );
afe42d0… ragelink 10553 },
afe42d0… ragelink 10554 undelegate: function( selector, types, fn ) {
afe42d0… ragelink 10555
afe42d0… ragelink 10556 // ( namespace ) or ( selector, types [, fn] )
afe42d0… ragelink 10557 return arguments.length === 1 ?
afe42d0… ragelink 10558 this.off( selector, "**" ) :
afe42d0… ragelink 10559 this.off( types, selector || "**", fn );
afe42d0… ragelink 10560 },
afe42d0… ragelink 10561
afe42d0… ragelink 10562 hover: function( fnOver, fnOut ) {
afe42d0… ragelink 10563 return this
afe42d0… ragelink 10564 .on( "mouseenter", fnOver )
afe42d0… ragelink 10565 .on( "mouseleave", fnOut || fnOver );
afe42d0… ragelink 10566 }
afe42d0… ragelink 10567 } );
afe42d0… ragelink 10568
afe42d0… ragelink 10569 jQuery.each(
afe42d0… ragelink 10570 ( "blur focus focusin focusout resize scroll click dblclick " +
afe42d0… ragelink 10571 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
afe42d0… ragelink 10572 "change select submit keydown keypress keyup contextmenu" ).split( " " ),
afe42d0… ragelink 10573 function( _i, name ) {
afe42d0… ragelink 10574
afe42d0… ragelink 10575 // Handle event binding
afe42d0… ragelink 10576 jQuery.fn[ name ] = function( data, fn ) {
afe42d0… ragelink 10577 return arguments.length > 0 ?
afe42d0… ragelink 10578 this.on( name, null, data, fn ) :
afe42d0… ragelink 10579 this.trigger( name );
afe42d0… ragelink 10580 };
afe42d0… ragelink 10581 }
afe42d0… ragelink 10582 );
afe42d0… ragelink 10583
afe42d0… ragelink 10584
afe42d0… ragelink 10585
afe42d0… ragelink 10586
afe42d0… ragelink 10587 // Support: Android <=4.0 only
afe42d0… ragelink 10588 // Make sure we trim BOM and NBSP
afe42d0… ragelink 10589 // Require that the "whitespace run" starts from a non-whitespace
afe42d0… ragelink 10590 // to avoid O(N^2) behavior when the engine would try matching "\s+$" at each space position.
afe42d0… ragelink 10591 var rtrim = /^[\s\uFEFF\xA0]+|([^\s\uFEFF\xA0])[\s\uFEFF\xA0]+$/g;
afe42d0… ragelink 10592
afe42d0… ragelink 10593 // Bind a function to a context, optionally partially applying any
afe42d0… ragelink 10594 // arguments.
afe42d0… ragelink 10595 // jQuery.proxy is deprecated to promote standards (specifically Function#bind)
afe42d0… ragelink 10596 // However, it is not slated for removal any time soon
afe42d0… ragelink 10597 jQuery.proxy = function( fn, context ) {
afe42d0… ragelink 10598 var tmp, args, proxy;
afe42d0… ragelink 10599
afe42d0… ragelink 10600 if ( typeof context === "string" ) {
afe42d0… ragelink 10601 tmp = fn[ context ];
afe42d0… ragelink 10602 context = fn;
afe42d0… ragelink 10603 fn = tmp;
afe42d0… ragelink 10604 }
afe42d0… ragelink 10605
afe42d0… ragelink 10606 // Quick check to determine if target is callable, in the spec
afe42d0… ragelink 10607 // this throws a TypeError, but we will just return undefined.
afe42d0… ragelink 10608 if ( !isFunction( fn ) ) {
afe42d0… ragelink 10609 return undefined;
afe42d0… ragelink 10610 }
afe42d0… ragelink 10611
afe42d0… ragelink 10612 // Simulated bind
afe42d0… ragelink 10613 args = slice.call( arguments, 2 );
afe42d0… ragelink 10614 proxy = function() {
afe42d0… ragelink 10615 return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
afe42d0… ragelink 10616 };
afe42d0… ragelink 10617
afe42d0… ragelink 10618 // Set the guid of unique handler to the same of original handler, so it can be removed
afe42d0… ragelink 10619 proxy.guid = fn.guid = fn.guid || jQuery.guid++;
afe42d0… ragelink 10620
afe42d0… ragelink 10621 return proxy;
afe42d0… ragelink 10622 };
afe42d0… ragelink 10623
afe42d0… ragelink 10624 jQuery.holdReady = function( hold ) {
afe42d0… ragelink 10625 if ( hold ) {
afe42d0… ragelink 10626 jQuery.readyWait++;
afe42d0… ragelink 10627 } else {
afe42d0… ragelink 10628 jQuery.ready( true );
afe42d0… ragelink 10629 }
afe42d0… ragelink 10630 };
afe42d0… ragelink 10631 jQuery.isArray = Array.isArray;
afe42d0… ragelink 10632 jQuery.parseJSON = JSON.parse;
afe42d0… ragelink 10633 jQuery.nodeName = nodeName;
afe42d0… ragelink 10634 jQuery.isFunction = isFunction;
afe42d0… ragelink 10635 jQuery.isWindow = isWindow;
afe42d0… ragelink 10636 jQuery.camelCase = camelCase;
afe42d0… ragelink 10637 jQuery.type = toType;
afe42d0… ragelink 10638
afe42d0… ragelink 10639 jQuery.now = Date.now;
afe42d0… ragelink 10640
afe42d0… ragelink 10641 jQuery.isNumeric = function( obj ) {
afe42d0… ragelink 10642
afe42d0… ragelink 10643 // As of jQuery 3.0, isNumeric is limited to
afe42d0… ragelink 10644 // strings and numbers (primitives or objects)
afe42d0… ragelink 10645 // that can be coerced to finite numbers (gh-2662)
afe42d0… ragelink 10646 var type = jQuery.type( obj );
afe42d0… ragelink 10647 return ( type === "number" || type === "string" ) &&
afe42d0… ragelink 10648
afe42d0… ragelink 10649 // parseFloat NaNs numeric-cast false positives ("")
afe42d0… ragelink 10650 // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
afe42d0… ragelink 10651 // subtraction forces infinities to NaN
afe42d0… ragelink 10652 !isNaN( obj - parseFloat( obj ) );
afe42d0… ragelink 10653 };
afe42d0… ragelink 10654
afe42d0… ragelink 10655 jQuery.trim = function( text ) {
afe42d0… ragelink 10656 return text == null ?
afe42d0… ragelink 10657 "" :
afe42d0… ragelink 10658 ( text + "" ).replace( rtrim, "$1" );
afe42d0… ragelink 10659 };
afe42d0… ragelink 10660
afe42d0… ragelink 10661
afe42d0… ragelink 10662
afe42d0… ragelink 10663 // Register as a named AMD module, since jQuery can be concatenated with other
afe42d0… ragelink 10664 // files that may use define, but not via a proper concatenation script that
afe42d0… ragelink 10665 // understands anonymous AMD modules. A named AMD is safest and most robust
afe42d0… ragelink 10666 // way to register. Lowercase jquery is used because AMD module names are
afe42d0… ragelink 10667 // derived from file names, and jQuery is normally delivered in a lowercase
afe42d0… ragelink 10668 // file name. Do this after creating the global so that if an AMD module wants
afe42d0… ragelink 10669 // to call noConflict to hide this version of jQuery, it will work.
afe42d0… ragelink 10670
afe42d0… ragelink 10671 // Note that for maximum portability, libraries that are not jQuery should
afe42d0… ragelink 10672 // declare themselves as anonymous modules, and avoid setting a global if an
afe42d0… ragelink 10673 // AMD loader is present. jQuery is a special case. For more information, see
afe42d0… ragelink 10674 // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
afe42d0… ragelink 10675
afe42d0… ragelink 10676 if ( typeof define === "function" && define.amd ) {
afe42d0… ragelink 10677 define( "jquery", [], function() {
afe42d0… ragelink 10678 return jQuery;
afe42d0… ragelink 10679 } );
afe42d0… ragelink 10680 }
afe42d0… ragelink 10681
afe42d0… ragelink 10682
afe42d0… ragelink 10683
afe42d0… ragelink 10684
afe42d0… ragelink 10685 var
afe42d0… ragelink 10686
afe42d0… ragelink 10687 // Map over jQuery in case of overwrite
afe42d0… ragelink 10688 _jQuery = window.jQuery,
afe42d0… ragelink 10689
afe42d0… ragelink 10690 // Map over the $ in case of overwrite
afe42d0… ragelink 10691 _$ = window.$;
afe42d0… ragelink 10692
afe42d0… ragelink 10693 jQuery.noConflict = function( deep ) {
afe42d0… ragelink 10694 if ( window.$ === jQuery ) {
afe42d0… ragelink 10695 window.$ = _$;
afe42d0… ragelink 10696 }
afe42d0… ragelink 10697
afe42d0… ragelink 10698 if ( deep && window.jQuery === jQuery ) {
afe42d0… ragelink 10699 window.jQuery = _jQuery;
afe42d0… ragelink 10700 }
afe42d0… ragelink 10701
afe42d0… ragelink 10702 return jQuery;
afe42d0… ragelink 10703 };
afe42d0… ragelink 10704
afe42d0… ragelink 10705 // Expose jQuery and $ identifiers, even in AMD
afe42d0… ragelink 10706 // (trac-7102#comment:10, https://github.com/jquery/jquery/pull/557)
afe42d0… ragelink 10707 // and CommonJS for browser emulators (trac-13566)
afe42d0… ragelink 10708 if ( typeof noGlobal === "undefined" ) {
afe42d0… ragelink 10709 window.jQuery = window.$ = jQuery;
afe42d0… ragelink 10710 }
afe42d0… ragelink 10711
afe42d0… ragelink 10712
afe42d0… ragelink 10713
afe42d0… ragelink 10714
afe42d0… ragelink 10715 return jQuery;
afe42d0… ragelink 10716 } );

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button