1*7f2fe78bSCy Schubert/*! 2*7f2fe78bSCy Schubert * jQuery JavaScript Library v3.6.0 3*7f2fe78bSCy Schubert * https://jquery.com/ 4*7f2fe78bSCy Schubert * 5*7f2fe78bSCy Schubert * Includes Sizzle.js 6*7f2fe78bSCy Schubert * https://sizzlejs.com/ 7*7f2fe78bSCy Schubert * 8*7f2fe78bSCy Schubert * Copyright OpenJS Foundation and other contributors 9*7f2fe78bSCy Schubert * Released under the MIT license 10*7f2fe78bSCy Schubert * https://jquery.org/license 11*7f2fe78bSCy Schubert */ 12*7f2fe78bSCy Schubert( function( global, factory ) { 13*7f2fe78bSCy Schubert 14*7f2fe78bSCy Schubert "use strict"; 15*7f2fe78bSCy Schubert 16*7f2fe78bSCy Schubert if ( typeof module === "object" && typeof module.exports === "object" ) { 17*7f2fe78bSCy Schubert 18*7f2fe78bSCy Schubert // For CommonJS and CommonJS-like environments where a proper `window` 19*7f2fe78bSCy Schubert // is present, execute the factory and get jQuery. 20*7f2fe78bSCy Schubert // For environments that do not have a `window` with a `document` 21*7f2fe78bSCy Schubert // (such as Node.js), expose a factory as module.exports. 22*7f2fe78bSCy Schubert // This accentuates the need for the creation of a real `window`. 23*7f2fe78bSCy Schubert // e.g. var jQuery = require("jquery")(window); 24*7f2fe78bSCy Schubert // See ticket #14549 for more info. 25*7f2fe78bSCy Schubert module.exports = global.document ? 26*7f2fe78bSCy Schubert factory( global, true ) : 27*7f2fe78bSCy Schubert function( w ) { 28*7f2fe78bSCy Schubert if ( !w.document ) { 29*7f2fe78bSCy Schubert throw new Error( "jQuery requires a window with a document" ); 30*7f2fe78bSCy Schubert } 31*7f2fe78bSCy Schubert return factory( w ); 32*7f2fe78bSCy Schubert }; 33*7f2fe78bSCy Schubert } else { 34*7f2fe78bSCy Schubert factory( global ); 35*7f2fe78bSCy Schubert } 36*7f2fe78bSCy Schubert 37*7f2fe78bSCy Schubert// Pass this if window is not defined yet 38*7f2fe78bSCy Schubert} )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) { 39*7f2fe78bSCy Schubert 40*7f2fe78bSCy Schubert// Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1 41*7f2fe78bSCy Schubert// throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode 42*7f2fe78bSCy Schubert// arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common 43*7f2fe78bSCy Schubert// enough that all such attempts are guarded in a try block. 44*7f2fe78bSCy Schubert"use strict"; 45*7f2fe78bSCy Schubert 46*7f2fe78bSCy Schubertvar arr = []; 47*7f2fe78bSCy Schubert 48*7f2fe78bSCy Schubertvar getProto = Object.getPrototypeOf; 49*7f2fe78bSCy Schubert 50*7f2fe78bSCy Schubertvar slice = arr.slice; 51*7f2fe78bSCy Schubert 52*7f2fe78bSCy Schubertvar flat = arr.flat ? function( array ) { 53*7f2fe78bSCy Schubert return arr.flat.call( array ); 54*7f2fe78bSCy Schubert} : function( array ) { 55*7f2fe78bSCy Schubert return arr.concat.apply( [], array ); 56*7f2fe78bSCy Schubert}; 57*7f2fe78bSCy Schubert 58*7f2fe78bSCy Schubert 59*7f2fe78bSCy Schubertvar push = arr.push; 60*7f2fe78bSCy Schubert 61*7f2fe78bSCy Schubertvar indexOf = arr.indexOf; 62*7f2fe78bSCy Schubert 63*7f2fe78bSCy Schubertvar class2type = {}; 64*7f2fe78bSCy Schubert 65*7f2fe78bSCy Schubertvar toString = class2type.toString; 66*7f2fe78bSCy Schubert 67*7f2fe78bSCy Schubertvar hasOwn = class2type.hasOwnProperty; 68*7f2fe78bSCy Schubert 69*7f2fe78bSCy Schubertvar fnToString = hasOwn.toString; 70*7f2fe78bSCy Schubert 71*7f2fe78bSCy Schubertvar ObjectFunctionString = fnToString.call( Object ); 72*7f2fe78bSCy Schubert 73*7f2fe78bSCy Schubertvar support = {}; 74*7f2fe78bSCy Schubert 75*7f2fe78bSCy Schubertvar isFunction = function isFunction( obj ) { 76*7f2fe78bSCy Schubert 77*7f2fe78bSCy Schubert // Support: Chrome <=57, Firefox <=52 78*7f2fe78bSCy Schubert // In some browsers, typeof returns "function" for HTML <object> elements 79*7f2fe78bSCy Schubert // (i.e., `typeof document.createElement( "object" ) === "function"`). 80*7f2fe78bSCy Schubert // We don't want to classify *any* DOM node as a function. 81*7f2fe78bSCy Schubert // Support: QtWeb <=3.8.5, WebKit <=534.34, wkhtmltopdf tool <=0.12.5 82*7f2fe78bSCy Schubert // Plus for old WebKit, typeof returns "function" for HTML collections 83*7f2fe78bSCy Schubert // (e.g., `typeof document.getElementsByTagName("div") === "function"`). (gh-4756) 84*7f2fe78bSCy Schubert return typeof obj === "function" && typeof obj.nodeType !== "number" && 85*7f2fe78bSCy Schubert typeof obj.item !== "function"; 86*7f2fe78bSCy Schubert }; 87*7f2fe78bSCy Schubert 88*7f2fe78bSCy Schubert 89*7f2fe78bSCy Schubertvar isWindow = function isWindow( obj ) { 90*7f2fe78bSCy Schubert return obj != null && obj === obj.window; 91*7f2fe78bSCy Schubert }; 92*7f2fe78bSCy Schubert 93*7f2fe78bSCy Schubert 94*7f2fe78bSCy Schubertvar document = window.document; 95*7f2fe78bSCy Schubert 96*7f2fe78bSCy Schubert 97*7f2fe78bSCy Schubert 98*7f2fe78bSCy Schubert var preservedScriptAttributes = { 99*7f2fe78bSCy Schubert type: true, 100*7f2fe78bSCy Schubert src: true, 101*7f2fe78bSCy Schubert nonce: true, 102*7f2fe78bSCy Schubert noModule: true 103*7f2fe78bSCy Schubert }; 104*7f2fe78bSCy Schubert 105*7f2fe78bSCy Schubert function DOMEval( code, node, doc ) { 106*7f2fe78bSCy Schubert doc = doc || document; 107*7f2fe78bSCy Schubert 108*7f2fe78bSCy Schubert var i, val, 109*7f2fe78bSCy Schubert script = doc.createElement( "script" ); 110*7f2fe78bSCy Schubert 111*7f2fe78bSCy Schubert script.text = code; 112*7f2fe78bSCy Schubert if ( node ) { 113*7f2fe78bSCy Schubert for ( i in preservedScriptAttributes ) { 114*7f2fe78bSCy Schubert 115*7f2fe78bSCy Schubert // Support: Firefox 64+, Edge 18+ 116*7f2fe78bSCy Schubert // Some browsers don't support the "nonce" property on scripts. 117*7f2fe78bSCy Schubert // On the other hand, just using `getAttribute` is not enough as 118*7f2fe78bSCy Schubert // the `nonce` attribute is reset to an empty string whenever it 119*7f2fe78bSCy Schubert // becomes browsing-context connected. 120*7f2fe78bSCy Schubert // See https://github.com/whatwg/html/issues/2369 121*7f2fe78bSCy Schubert // See https://html.spec.whatwg.org/#nonce-attributes 122*7f2fe78bSCy Schubert // The `node.getAttribute` check was added for the sake of 123*7f2fe78bSCy Schubert // `jQuery.globalEval` so that it can fake a nonce-containing node 124*7f2fe78bSCy Schubert // via an object. 125*7f2fe78bSCy Schubert val = node[ i ] || node.getAttribute && node.getAttribute( i ); 126*7f2fe78bSCy Schubert if ( val ) { 127*7f2fe78bSCy Schubert script.setAttribute( i, val ); 128*7f2fe78bSCy Schubert } 129*7f2fe78bSCy Schubert } 130*7f2fe78bSCy Schubert } 131*7f2fe78bSCy Schubert doc.head.appendChild( script ).parentNode.removeChild( script ); 132*7f2fe78bSCy Schubert } 133*7f2fe78bSCy Schubert 134*7f2fe78bSCy Schubert 135*7f2fe78bSCy Schubertfunction toType( obj ) { 136*7f2fe78bSCy Schubert if ( obj == null ) { 137*7f2fe78bSCy Schubert return obj + ""; 138*7f2fe78bSCy Schubert } 139*7f2fe78bSCy Schubert 140*7f2fe78bSCy Schubert // Support: Android <=2.3 only (functionish RegExp) 141*7f2fe78bSCy Schubert return typeof obj === "object" || typeof obj === "function" ? 142*7f2fe78bSCy Schubert class2type[ toString.call( obj ) ] || "object" : 143*7f2fe78bSCy Schubert typeof obj; 144*7f2fe78bSCy Schubert} 145*7f2fe78bSCy Schubert/* global Symbol */ 146*7f2fe78bSCy Schubert// Defining this global in .eslintrc.json would create a danger of using the global 147*7f2fe78bSCy Schubert// unguarded in another place, it seems safer to define global only for this module 148*7f2fe78bSCy Schubert 149*7f2fe78bSCy Schubert 150*7f2fe78bSCy Schubert 151*7f2fe78bSCy Schubertvar 152*7f2fe78bSCy Schubert version = "3.6.0", 153*7f2fe78bSCy Schubert 154*7f2fe78bSCy Schubert // Define a local copy of jQuery 155*7f2fe78bSCy Schubert jQuery = function( selector, context ) { 156*7f2fe78bSCy Schubert 157*7f2fe78bSCy Schubert // The jQuery object is actually just the init constructor 'enhanced' 158*7f2fe78bSCy Schubert // Need init if jQuery is called (just allow error to be thrown if not included) 159*7f2fe78bSCy Schubert return new jQuery.fn.init( selector, context ); 160*7f2fe78bSCy Schubert }; 161*7f2fe78bSCy Schubert 162*7f2fe78bSCy SchubertjQuery.fn = jQuery.prototype = { 163*7f2fe78bSCy Schubert 164*7f2fe78bSCy Schubert // The current version of jQuery being used 165*7f2fe78bSCy Schubert jquery: version, 166*7f2fe78bSCy Schubert 167*7f2fe78bSCy Schubert constructor: jQuery, 168*7f2fe78bSCy Schubert 169*7f2fe78bSCy Schubert // The default length of a jQuery object is 0 170*7f2fe78bSCy Schubert length: 0, 171*7f2fe78bSCy Schubert 172*7f2fe78bSCy Schubert toArray: function() { 173*7f2fe78bSCy Schubert return slice.call( this ); 174*7f2fe78bSCy Schubert }, 175*7f2fe78bSCy Schubert 176*7f2fe78bSCy Schubert // Get the Nth element in the matched element set OR 177*7f2fe78bSCy Schubert // Get the whole matched element set as a clean array 178*7f2fe78bSCy Schubert get: function( num ) { 179*7f2fe78bSCy Schubert 180*7f2fe78bSCy Schubert // Return all the elements in a clean array 181*7f2fe78bSCy Schubert if ( num == null ) { 182*7f2fe78bSCy Schubert return slice.call( this ); 183*7f2fe78bSCy Schubert } 184*7f2fe78bSCy Schubert 185*7f2fe78bSCy Schubert // Return just the one element from the set 186*7f2fe78bSCy Schubert return num < 0 ? this[ num + this.length ] : this[ num ]; 187*7f2fe78bSCy Schubert }, 188*7f2fe78bSCy Schubert 189*7f2fe78bSCy Schubert // Take an array of elements and push it onto the stack 190*7f2fe78bSCy Schubert // (returning the new matched element set) 191*7f2fe78bSCy Schubert pushStack: function( elems ) { 192*7f2fe78bSCy Schubert 193*7f2fe78bSCy Schubert // Build a new jQuery matched element set 194*7f2fe78bSCy Schubert var ret = jQuery.merge( this.constructor(), elems ); 195*7f2fe78bSCy Schubert 196*7f2fe78bSCy Schubert // Add the old object onto the stack (as a reference) 197*7f2fe78bSCy Schubert ret.prevObject = this; 198*7f2fe78bSCy Schubert 199*7f2fe78bSCy Schubert // Return the newly-formed element set 200*7f2fe78bSCy Schubert return ret; 201*7f2fe78bSCy Schubert }, 202*7f2fe78bSCy Schubert 203*7f2fe78bSCy Schubert // Execute a callback for every element in the matched set. 204*7f2fe78bSCy Schubert each: function( callback ) { 205*7f2fe78bSCy Schubert return jQuery.each( this, callback ); 206*7f2fe78bSCy Schubert }, 207*7f2fe78bSCy Schubert 208*7f2fe78bSCy Schubert map: function( callback ) { 209*7f2fe78bSCy Schubert return this.pushStack( jQuery.map( this, function( elem, i ) { 210*7f2fe78bSCy Schubert return callback.call( elem, i, elem ); 211*7f2fe78bSCy Schubert } ) ); 212*7f2fe78bSCy Schubert }, 213*7f2fe78bSCy Schubert 214*7f2fe78bSCy Schubert slice: function() { 215*7f2fe78bSCy Schubert return this.pushStack( slice.apply( this, arguments ) ); 216*7f2fe78bSCy Schubert }, 217*7f2fe78bSCy Schubert 218*7f2fe78bSCy Schubert first: function() { 219*7f2fe78bSCy Schubert return this.eq( 0 ); 220*7f2fe78bSCy Schubert }, 221*7f2fe78bSCy Schubert 222*7f2fe78bSCy Schubert last: function() { 223*7f2fe78bSCy Schubert return this.eq( -1 ); 224*7f2fe78bSCy Schubert }, 225*7f2fe78bSCy Schubert 226*7f2fe78bSCy Schubert even: function() { 227*7f2fe78bSCy Schubert return this.pushStack( jQuery.grep( this, function( _elem, i ) { 228*7f2fe78bSCy Schubert return ( i + 1 ) % 2; 229*7f2fe78bSCy Schubert } ) ); 230*7f2fe78bSCy Schubert }, 231*7f2fe78bSCy Schubert 232*7f2fe78bSCy Schubert odd: function() { 233*7f2fe78bSCy Schubert return this.pushStack( jQuery.grep( this, function( _elem, i ) { 234*7f2fe78bSCy Schubert return i % 2; 235*7f2fe78bSCy Schubert } ) ); 236*7f2fe78bSCy Schubert }, 237*7f2fe78bSCy Schubert 238*7f2fe78bSCy Schubert eq: function( i ) { 239*7f2fe78bSCy Schubert var len = this.length, 240*7f2fe78bSCy Schubert j = +i + ( i < 0 ? len : 0 ); 241*7f2fe78bSCy Schubert return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] ); 242*7f2fe78bSCy Schubert }, 243*7f2fe78bSCy Schubert 244*7f2fe78bSCy Schubert end: function() { 245*7f2fe78bSCy Schubert return this.prevObject || this.constructor(); 246*7f2fe78bSCy Schubert }, 247*7f2fe78bSCy Schubert 248*7f2fe78bSCy Schubert // For internal use only. 249*7f2fe78bSCy Schubert // Behaves like an Array's method, not like a jQuery method. 250*7f2fe78bSCy Schubert push: push, 251*7f2fe78bSCy Schubert sort: arr.sort, 252*7f2fe78bSCy Schubert splice: arr.splice 253*7f2fe78bSCy Schubert}; 254*7f2fe78bSCy Schubert 255*7f2fe78bSCy SchubertjQuery.extend = jQuery.fn.extend = function() { 256*7f2fe78bSCy Schubert var options, name, src, copy, copyIsArray, clone, 257*7f2fe78bSCy Schubert target = arguments[ 0 ] || {}, 258*7f2fe78bSCy Schubert i = 1, 259*7f2fe78bSCy Schubert length = arguments.length, 260*7f2fe78bSCy Schubert deep = false; 261*7f2fe78bSCy Schubert 262*7f2fe78bSCy Schubert // Handle a deep copy situation 263*7f2fe78bSCy Schubert if ( typeof target === "boolean" ) { 264*7f2fe78bSCy Schubert deep = target; 265*7f2fe78bSCy Schubert 266*7f2fe78bSCy Schubert // Skip the boolean and the target 267*7f2fe78bSCy Schubert target = arguments[ i ] || {}; 268*7f2fe78bSCy Schubert i++; 269*7f2fe78bSCy Schubert } 270*7f2fe78bSCy Schubert 271*7f2fe78bSCy Schubert // Handle case when target is a string or something (possible in deep copy) 272*7f2fe78bSCy Schubert if ( typeof target !== "object" && !isFunction( target ) ) { 273*7f2fe78bSCy Schubert target = {}; 274*7f2fe78bSCy Schubert } 275*7f2fe78bSCy Schubert 276*7f2fe78bSCy Schubert // Extend jQuery itself if only one argument is passed 277*7f2fe78bSCy Schubert if ( i === length ) { 278*7f2fe78bSCy Schubert target = this; 279*7f2fe78bSCy Schubert i--; 280*7f2fe78bSCy Schubert } 281*7f2fe78bSCy Schubert 282*7f2fe78bSCy Schubert for ( ; i < length; i++ ) { 283*7f2fe78bSCy Schubert 284*7f2fe78bSCy Schubert // Only deal with non-null/undefined values 285*7f2fe78bSCy Schubert if ( ( options = arguments[ i ] ) != null ) { 286*7f2fe78bSCy Schubert 287*7f2fe78bSCy Schubert // Extend the base object 288*7f2fe78bSCy Schubert for ( name in options ) { 289*7f2fe78bSCy Schubert copy = options[ name ]; 290*7f2fe78bSCy Schubert 291*7f2fe78bSCy Schubert // Prevent Object.prototype pollution 292*7f2fe78bSCy Schubert // Prevent never-ending loop 293*7f2fe78bSCy Schubert if ( name === "__proto__" || target === copy ) { 294*7f2fe78bSCy Schubert continue; 295*7f2fe78bSCy Schubert } 296*7f2fe78bSCy Schubert 297*7f2fe78bSCy Schubert // Recurse if we're merging plain objects or arrays 298*7f2fe78bSCy Schubert if ( deep && copy && ( jQuery.isPlainObject( copy ) || 299*7f2fe78bSCy Schubert ( copyIsArray = Array.isArray( copy ) ) ) ) { 300*7f2fe78bSCy Schubert src = target[ name ]; 301*7f2fe78bSCy Schubert 302*7f2fe78bSCy Schubert // Ensure proper type for the source value 303*7f2fe78bSCy Schubert if ( copyIsArray && !Array.isArray( src ) ) { 304*7f2fe78bSCy Schubert clone = []; 305*7f2fe78bSCy Schubert } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) { 306*7f2fe78bSCy Schubert clone = {}; 307*7f2fe78bSCy Schubert } else { 308*7f2fe78bSCy Schubert clone = src; 309*7f2fe78bSCy Schubert } 310*7f2fe78bSCy Schubert copyIsArray = false; 311*7f2fe78bSCy Schubert 312*7f2fe78bSCy Schubert // Never move original objects, clone them 313*7f2fe78bSCy Schubert target[ name ] = jQuery.extend( deep, clone, copy ); 314*7f2fe78bSCy Schubert 315*7f2fe78bSCy Schubert // Don't bring in undefined values 316*7f2fe78bSCy Schubert } else if ( copy !== undefined ) { 317*7f2fe78bSCy Schubert target[ name ] = copy; 318*7f2fe78bSCy Schubert } 319*7f2fe78bSCy Schubert } 320*7f2fe78bSCy Schubert } 321*7f2fe78bSCy Schubert } 322*7f2fe78bSCy Schubert 323*7f2fe78bSCy Schubert // Return the modified object 324*7f2fe78bSCy Schubert return target; 325*7f2fe78bSCy Schubert}; 326*7f2fe78bSCy Schubert 327*7f2fe78bSCy SchubertjQuery.extend( { 328*7f2fe78bSCy Schubert 329*7f2fe78bSCy Schubert // Unique for each copy of jQuery on the page 330*7f2fe78bSCy Schubert expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ), 331*7f2fe78bSCy Schubert 332*7f2fe78bSCy Schubert // Assume jQuery is ready without the ready module 333*7f2fe78bSCy Schubert isReady: true, 334*7f2fe78bSCy Schubert 335*7f2fe78bSCy Schubert error: function( msg ) { 336*7f2fe78bSCy Schubert throw new Error( msg ); 337*7f2fe78bSCy Schubert }, 338*7f2fe78bSCy Schubert 339*7f2fe78bSCy Schubert noop: function() {}, 340*7f2fe78bSCy Schubert 341*7f2fe78bSCy Schubert isPlainObject: function( obj ) { 342*7f2fe78bSCy Schubert var proto, Ctor; 343*7f2fe78bSCy Schubert 344*7f2fe78bSCy Schubert // Detect obvious negatives 345*7f2fe78bSCy Schubert // Use toString instead of jQuery.type to catch host objects 346*7f2fe78bSCy Schubert if ( !obj || toString.call( obj ) !== "[object Object]" ) { 347*7f2fe78bSCy Schubert return false; 348*7f2fe78bSCy Schubert } 349*7f2fe78bSCy Schubert 350*7f2fe78bSCy Schubert proto = getProto( obj ); 351*7f2fe78bSCy Schubert 352*7f2fe78bSCy Schubert // Objects with no prototype (e.g., `Object.create( null )`) are plain 353*7f2fe78bSCy Schubert if ( !proto ) { 354*7f2fe78bSCy Schubert return true; 355*7f2fe78bSCy Schubert } 356*7f2fe78bSCy Schubert 357*7f2fe78bSCy Schubert // Objects with prototype are plain iff they were constructed by a global Object function 358*7f2fe78bSCy Schubert Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor; 359*7f2fe78bSCy Schubert return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString; 360*7f2fe78bSCy Schubert }, 361*7f2fe78bSCy Schubert 362*7f2fe78bSCy Schubert isEmptyObject: function( obj ) { 363*7f2fe78bSCy Schubert var name; 364*7f2fe78bSCy Schubert 365*7f2fe78bSCy Schubert for ( name in obj ) { 366*7f2fe78bSCy Schubert return false; 367*7f2fe78bSCy Schubert } 368*7f2fe78bSCy Schubert return true; 369*7f2fe78bSCy Schubert }, 370*7f2fe78bSCy Schubert 371*7f2fe78bSCy Schubert // Evaluates a script in a provided context; falls back to the global one 372*7f2fe78bSCy Schubert // if not specified. 373*7f2fe78bSCy Schubert globalEval: function( code, options, doc ) { 374*7f2fe78bSCy Schubert DOMEval( code, { nonce: options && options.nonce }, doc ); 375*7f2fe78bSCy Schubert }, 376*7f2fe78bSCy Schubert 377*7f2fe78bSCy Schubert each: function( obj, callback ) { 378*7f2fe78bSCy Schubert var length, i = 0; 379*7f2fe78bSCy Schubert 380*7f2fe78bSCy Schubert if ( isArrayLike( obj ) ) { 381*7f2fe78bSCy Schubert length = obj.length; 382*7f2fe78bSCy Schubert for ( ; i < length; i++ ) { 383*7f2fe78bSCy Schubert if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { 384*7f2fe78bSCy Schubert break; 385*7f2fe78bSCy Schubert } 386*7f2fe78bSCy Schubert } 387*7f2fe78bSCy Schubert } else { 388*7f2fe78bSCy Schubert for ( i in obj ) { 389*7f2fe78bSCy Schubert if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { 390*7f2fe78bSCy Schubert break; 391*7f2fe78bSCy Schubert } 392*7f2fe78bSCy Schubert } 393*7f2fe78bSCy Schubert } 394*7f2fe78bSCy Schubert 395*7f2fe78bSCy Schubert return obj; 396*7f2fe78bSCy Schubert }, 397*7f2fe78bSCy Schubert 398*7f2fe78bSCy Schubert // results is for internal usage only 399*7f2fe78bSCy Schubert makeArray: function( arr, results ) { 400*7f2fe78bSCy Schubert var ret = results || []; 401*7f2fe78bSCy Schubert 402*7f2fe78bSCy Schubert if ( arr != null ) { 403*7f2fe78bSCy Schubert if ( isArrayLike( Object( arr ) ) ) { 404*7f2fe78bSCy Schubert jQuery.merge( ret, 405*7f2fe78bSCy Schubert typeof arr === "string" ? 406*7f2fe78bSCy Schubert [ arr ] : arr 407*7f2fe78bSCy Schubert ); 408*7f2fe78bSCy Schubert } else { 409*7f2fe78bSCy Schubert push.call( ret, arr ); 410*7f2fe78bSCy Schubert } 411*7f2fe78bSCy Schubert } 412*7f2fe78bSCy Schubert 413*7f2fe78bSCy Schubert return ret; 414*7f2fe78bSCy Schubert }, 415*7f2fe78bSCy Schubert 416*7f2fe78bSCy Schubert inArray: function( elem, arr, i ) { 417*7f2fe78bSCy Schubert return arr == null ? -1 : indexOf.call( arr, elem, i ); 418*7f2fe78bSCy Schubert }, 419*7f2fe78bSCy Schubert 420*7f2fe78bSCy Schubert // Support: Android <=4.0 only, PhantomJS 1 only 421*7f2fe78bSCy Schubert // push.apply(_, arraylike) throws on ancient WebKit 422*7f2fe78bSCy Schubert merge: function( first, second ) { 423*7f2fe78bSCy Schubert var len = +second.length, 424*7f2fe78bSCy Schubert j = 0, 425*7f2fe78bSCy Schubert i = first.length; 426*7f2fe78bSCy Schubert 427*7f2fe78bSCy Schubert for ( ; j < len; j++ ) { 428*7f2fe78bSCy Schubert first[ i++ ] = second[ j ]; 429*7f2fe78bSCy Schubert } 430*7f2fe78bSCy Schubert 431*7f2fe78bSCy Schubert first.length = i; 432*7f2fe78bSCy Schubert 433*7f2fe78bSCy Schubert return first; 434*7f2fe78bSCy Schubert }, 435*7f2fe78bSCy Schubert 436*7f2fe78bSCy Schubert grep: function( elems, callback, invert ) { 437*7f2fe78bSCy Schubert var callbackInverse, 438*7f2fe78bSCy Schubert matches = [], 439*7f2fe78bSCy Schubert i = 0, 440*7f2fe78bSCy Schubert length = elems.length, 441*7f2fe78bSCy Schubert callbackExpect = !invert; 442*7f2fe78bSCy Schubert 443*7f2fe78bSCy Schubert // Go through the array, only saving the items 444*7f2fe78bSCy Schubert // that pass the validator function 445*7f2fe78bSCy Schubert for ( ; i < length; i++ ) { 446*7f2fe78bSCy Schubert callbackInverse = !callback( elems[ i ], i ); 447*7f2fe78bSCy Schubert if ( callbackInverse !== callbackExpect ) { 448*7f2fe78bSCy Schubert matches.push( elems[ i ] ); 449*7f2fe78bSCy Schubert } 450*7f2fe78bSCy Schubert } 451*7f2fe78bSCy Schubert 452*7f2fe78bSCy Schubert return matches; 453*7f2fe78bSCy Schubert }, 454*7f2fe78bSCy Schubert 455*7f2fe78bSCy Schubert // arg is for internal usage only 456*7f2fe78bSCy Schubert map: function( elems, callback, arg ) { 457*7f2fe78bSCy Schubert var length, value, 458*7f2fe78bSCy Schubert i = 0, 459*7f2fe78bSCy Schubert ret = []; 460*7f2fe78bSCy Schubert 461*7f2fe78bSCy Schubert // Go through the array, translating each of the items to their new values 462*7f2fe78bSCy Schubert if ( isArrayLike( elems ) ) { 463*7f2fe78bSCy Schubert length = elems.length; 464*7f2fe78bSCy Schubert for ( ; i < length; i++ ) { 465*7f2fe78bSCy Schubert value = callback( elems[ i ], i, arg ); 466*7f2fe78bSCy Schubert 467*7f2fe78bSCy Schubert if ( value != null ) { 468*7f2fe78bSCy Schubert ret.push( value ); 469*7f2fe78bSCy Schubert } 470*7f2fe78bSCy Schubert } 471*7f2fe78bSCy Schubert 472*7f2fe78bSCy Schubert // Go through every key on the object, 473*7f2fe78bSCy Schubert } else { 474*7f2fe78bSCy Schubert for ( i in elems ) { 475*7f2fe78bSCy Schubert value = callback( elems[ i ], i, arg ); 476*7f2fe78bSCy Schubert 477*7f2fe78bSCy Schubert if ( value != null ) { 478*7f2fe78bSCy Schubert ret.push( value ); 479*7f2fe78bSCy Schubert } 480*7f2fe78bSCy Schubert } 481*7f2fe78bSCy Schubert } 482*7f2fe78bSCy Schubert 483*7f2fe78bSCy Schubert // Flatten any nested arrays 484*7f2fe78bSCy Schubert return flat( ret ); 485*7f2fe78bSCy Schubert }, 486*7f2fe78bSCy Schubert 487*7f2fe78bSCy Schubert // A global GUID counter for objects 488*7f2fe78bSCy Schubert guid: 1, 489*7f2fe78bSCy Schubert 490*7f2fe78bSCy Schubert // jQuery.support is not used in Core but other projects attach their 491*7f2fe78bSCy Schubert // properties to it so it needs to exist. 492*7f2fe78bSCy Schubert support: support 493*7f2fe78bSCy Schubert} ); 494*7f2fe78bSCy Schubert 495*7f2fe78bSCy Schubertif ( typeof Symbol === "function" ) { 496*7f2fe78bSCy Schubert jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ]; 497*7f2fe78bSCy Schubert} 498*7f2fe78bSCy Schubert 499*7f2fe78bSCy Schubert// Populate the class2type map 500*7f2fe78bSCy SchubertjQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ), 501*7f2fe78bSCy Schubert function( _i, name ) { 502*7f2fe78bSCy Schubert class2type[ "[object " + name + "]" ] = name.toLowerCase(); 503*7f2fe78bSCy Schubert } ); 504*7f2fe78bSCy Schubert 505*7f2fe78bSCy Schubertfunction isArrayLike( obj ) { 506*7f2fe78bSCy Schubert 507*7f2fe78bSCy Schubert // Support: real iOS 8.2 only (not reproducible in simulator) 508*7f2fe78bSCy Schubert // `in` check used to prevent JIT error (gh-2145) 509*7f2fe78bSCy Schubert // hasOwn isn't used here due to false negatives 510*7f2fe78bSCy Schubert // regarding Nodelist length in IE 511*7f2fe78bSCy Schubert var length = !!obj && "length" in obj && obj.length, 512*7f2fe78bSCy Schubert type = toType( obj ); 513*7f2fe78bSCy Schubert 514*7f2fe78bSCy Schubert if ( isFunction( obj ) || isWindow( obj ) ) { 515*7f2fe78bSCy Schubert return false; 516*7f2fe78bSCy Schubert } 517*7f2fe78bSCy Schubert 518*7f2fe78bSCy Schubert return type === "array" || length === 0 || 519*7f2fe78bSCy Schubert typeof length === "number" && length > 0 && ( length - 1 ) in obj; 520*7f2fe78bSCy Schubert} 521*7f2fe78bSCy Schubertvar Sizzle = 522*7f2fe78bSCy Schubert/*! 523*7f2fe78bSCy Schubert * Sizzle CSS Selector Engine v2.3.6 524*7f2fe78bSCy Schubert * https://sizzlejs.com/ 525*7f2fe78bSCy Schubert * 526*7f2fe78bSCy Schubert * Copyright JS Foundation and other contributors 527*7f2fe78bSCy Schubert * Released under the MIT license 528*7f2fe78bSCy Schubert * https://js.foundation/ 529*7f2fe78bSCy Schubert * 530*7f2fe78bSCy Schubert * Date: 2021-02-16 531*7f2fe78bSCy Schubert */ 532*7f2fe78bSCy Schubert( function( window ) { 533*7f2fe78bSCy Schubertvar i, 534*7f2fe78bSCy Schubert support, 535*7f2fe78bSCy Schubert Expr, 536*7f2fe78bSCy Schubert getText, 537*7f2fe78bSCy Schubert isXML, 538*7f2fe78bSCy Schubert tokenize, 539*7f2fe78bSCy Schubert compile, 540*7f2fe78bSCy Schubert select, 541*7f2fe78bSCy Schubert outermostContext, 542*7f2fe78bSCy Schubert sortInput, 543*7f2fe78bSCy Schubert hasDuplicate, 544*7f2fe78bSCy Schubert 545*7f2fe78bSCy Schubert // Local document vars 546*7f2fe78bSCy Schubert setDocument, 547*7f2fe78bSCy Schubert document, 548*7f2fe78bSCy Schubert docElem, 549*7f2fe78bSCy Schubert documentIsHTML, 550*7f2fe78bSCy Schubert rbuggyQSA, 551*7f2fe78bSCy Schubert rbuggyMatches, 552*7f2fe78bSCy Schubert matches, 553*7f2fe78bSCy Schubert contains, 554*7f2fe78bSCy Schubert 555*7f2fe78bSCy Schubert // Instance-specific data 556*7f2fe78bSCy Schubert expando = "sizzle" + 1 * new Date(), 557*7f2fe78bSCy Schubert preferredDoc = window.document, 558*7f2fe78bSCy Schubert dirruns = 0, 559*7f2fe78bSCy Schubert done = 0, 560*7f2fe78bSCy Schubert classCache = createCache(), 561*7f2fe78bSCy Schubert tokenCache = createCache(), 562*7f2fe78bSCy Schubert compilerCache = createCache(), 563*7f2fe78bSCy Schubert nonnativeSelectorCache = createCache(), 564*7f2fe78bSCy Schubert sortOrder = function( a, b ) { 565*7f2fe78bSCy Schubert if ( a === b ) { 566*7f2fe78bSCy Schubert hasDuplicate = true; 567*7f2fe78bSCy Schubert } 568*7f2fe78bSCy Schubert return 0; 569*7f2fe78bSCy Schubert }, 570*7f2fe78bSCy Schubert 571*7f2fe78bSCy Schubert // Instance methods 572*7f2fe78bSCy Schubert hasOwn = ( {} ).hasOwnProperty, 573*7f2fe78bSCy Schubert arr = [], 574*7f2fe78bSCy Schubert pop = arr.pop, 575*7f2fe78bSCy Schubert pushNative = arr.push, 576*7f2fe78bSCy Schubert push = arr.push, 577*7f2fe78bSCy Schubert slice = arr.slice, 578*7f2fe78bSCy Schubert 579*7f2fe78bSCy Schubert // Use a stripped-down indexOf as it's faster than native 580*7f2fe78bSCy Schubert // https://jsperf.com/thor-indexof-vs-for/5 581*7f2fe78bSCy Schubert indexOf = function( list, elem ) { 582*7f2fe78bSCy Schubert var i = 0, 583*7f2fe78bSCy Schubert len = list.length; 584*7f2fe78bSCy Schubert for ( ; i < len; i++ ) { 585*7f2fe78bSCy Schubert if ( list[ i ] === elem ) { 586*7f2fe78bSCy Schubert return i; 587*7f2fe78bSCy Schubert } 588*7f2fe78bSCy Schubert } 589*7f2fe78bSCy Schubert return -1; 590*7f2fe78bSCy Schubert }, 591*7f2fe78bSCy Schubert 592*7f2fe78bSCy Schubert booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|" + 593*7f2fe78bSCy Schubert "ismap|loop|multiple|open|readonly|required|scoped", 594*7f2fe78bSCy Schubert 595*7f2fe78bSCy Schubert // Regular expressions 596*7f2fe78bSCy Schubert 597*7f2fe78bSCy Schubert // http://www.w3.org/TR/css3-selectors/#whitespace 598*7f2fe78bSCy Schubert whitespace = "[\\x20\\t\\r\\n\\f]", 599*7f2fe78bSCy Schubert 600*7f2fe78bSCy Schubert // https://www.w3.org/TR/css-syntax-3/#ident-token-diagram 601*7f2fe78bSCy Schubert identifier = "(?:\\\\[\\da-fA-F]{1,6}" + whitespace + 602*7f2fe78bSCy Schubert "?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+", 603*7f2fe78bSCy Schubert 604*7f2fe78bSCy Schubert // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors 605*7f2fe78bSCy Schubert attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace + 606*7f2fe78bSCy Schubert 607*7f2fe78bSCy Schubert // Operator (capture 2) 608*7f2fe78bSCy Schubert "*([*^$|!~]?=)" + whitespace + 609*7f2fe78bSCy Schubert 610*7f2fe78bSCy Schubert // "Attribute values must be CSS identifiers [capture 5] 611*7f2fe78bSCy Schubert // or strings [capture 3 or capture 4]" 612*7f2fe78bSCy Schubert "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + 613*7f2fe78bSCy Schubert whitespace + "*\\]", 614*7f2fe78bSCy Schubert 615*7f2fe78bSCy Schubert pseudos = ":(" + identifier + ")(?:\\((" + 616*7f2fe78bSCy Schubert 617*7f2fe78bSCy Schubert // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments: 618*7f2fe78bSCy Schubert // 1. quoted (capture 3; capture 4 or capture 5) 619*7f2fe78bSCy Schubert "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" + 620*7f2fe78bSCy Schubert 621*7f2fe78bSCy Schubert // 2. simple (capture 6) 622*7f2fe78bSCy Schubert "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" + 623*7f2fe78bSCy Schubert 624*7f2fe78bSCy Schubert // 3. anything else (capture 2) 625*7f2fe78bSCy Schubert ".*" + 626*7f2fe78bSCy Schubert ")\\)|)", 627*7f2fe78bSCy Schubert 628*7f2fe78bSCy Schubert // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter 629*7f2fe78bSCy Schubert rwhitespace = new RegExp( whitespace + "+", "g" ), 630*7f2fe78bSCy Schubert rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + 631*7f2fe78bSCy Schubert whitespace + "+$", "g" ), 632*7f2fe78bSCy Schubert 633*7f2fe78bSCy Schubert rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), 634*7f2fe78bSCy Schubert rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + 635*7f2fe78bSCy Schubert "*" ), 636*7f2fe78bSCy Schubert rdescend = new RegExp( whitespace + "|>" ), 637*7f2fe78bSCy Schubert 638*7f2fe78bSCy Schubert rpseudo = new RegExp( pseudos ), 639*7f2fe78bSCy Schubert ridentifier = new RegExp( "^" + identifier + "$" ), 640*7f2fe78bSCy Schubert 641*7f2fe78bSCy Schubert matchExpr = { 642*7f2fe78bSCy Schubert "ID": new RegExp( "^#(" + identifier + ")" ), 643*7f2fe78bSCy Schubert "CLASS": new RegExp( "^\\.(" + identifier + ")" ), 644*7f2fe78bSCy Schubert "TAG": new RegExp( "^(" + identifier + "|[*])" ), 645*7f2fe78bSCy Schubert "ATTR": new RegExp( "^" + attributes ), 646*7f2fe78bSCy Schubert "PSEUDO": new RegExp( "^" + pseudos ), 647*7f2fe78bSCy Schubert "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + 648*7f2fe78bSCy Schubert whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + 649*7f2fe78bSCy Schubert whitespace + "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), 650*7f2fe78bSCy Schubert "bool": new RegExp( "^(?:" + booleans + ")$", "i" ), 651*7f2fe78bSCy Schubert 652*7f2fe78bSCy Schubert // For use in libraries implementing .is() 653*7f2fe78bSCy Schubert // We use this for POS matching in `select` 654*7f2fe78bSCy Schubert "needsContext": new RegExp( "^" + whitespace + 655*7f2fe78bSCy Schubert "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace + 656*7f2fe78bSCy Schubert "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" ) 657*7f2fe78bSCy Schubert }, 658*7f2fe78bSCy Schubert 659*7f2fe78bSCy Schubert rhtml = /HTML$/i, 660*7f2fe78bSCy Schubert rinputs = /^(?:input|select|textarea|button)$/i, 661*7f2fe78bSCy Schubert rheader = /^h\d$/i, 662*7f2fe78bSCy Schubert 663*7f2fe78bSCy Schubert rnative = /^[^{]+\{\s*\[native \w/, 664*7f2fe78bSCy Schubert 665*7f2fe78bSCy Schubert // Easily-parseable/retrievable ID or TAG or CLASS selectors 666*7f2fe78bSCy Schubert rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, 667*7f2fe78bSCy Schubert 668*7f2fe78bSCy Schubert rsibling = /[+~]/, 669*7f2fe78bSCy Schubert 670*7f2fe78bSCy Schubert // CSS escapes 671*7f2fe78bSCy Schubert // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters 672*7f2fe78bSCy Schubert runescape = new RegExp( "\\\\[\\da-fA-F]{1,6}" + whitespace + "?|\\\\([^\\r\\n\\f])", "g" ), 673*7f2fe78bSCy Schubert funescape = function( escape, nonHex ) { 674*7f2fe78bSCy Schubert var high = "0x" + escape.slice( 1 ) - 0x10000; 675*7f2fe78bSCy Schubert 676*7f2fe78bSCy Schubert return nonHex ? 677*7f2fe78bSCy Schubert 678*7f2fe78bSCy Schubert // Strip the backslash prefix from a non-hex escape sequence 679*7f2fe78bSCy Schubert nonHex : 680*7f2fe78bSCy Schubert 681*7f2fe78bSCy Schubert // Replace a hexadecimal escape sequence with the encoded Unicode code point 682*7f2fe78bSCy Schubert // Support: IE <=11+ 683*7f2fe78bSCy Schubert // For values outside the Basic Multilingual Plane (BMP), manually construct a 684*7f2fe78bSCy Schubert // surrogate pair 685*7f2fe78bSCy Schubert high < 0 ? 686*7f2fe78bSCy Schubert String.fromCharCode( high + 0x10000 ) : 687*7f2fe78bSCy Schubert String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 ); 688*7f2fe78bSCy Schubert }, 689*7f2fe78bSCy Schubert 690*7f2fe78bSCy Schubert // CSS string/identifier serialization 691*7f2fe78bSCy Schubert // https://drafts.csswg.org/cssom/#common-serializing-idioms 692*7f2fe78bSCy Schubert rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g, 693*7f2fe78bSCy Schubert fcssescape = function( ch, asCodePoint ) { 694*7f2fe78bSCy Schubert if ( asCodePoint ) { 695*7f2fe78bSCy Schubert 696*7f2fe78bSCy Schubert // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER 697*7f2fe78bSCy Schubert if ( ch === "\0" ) { 698*7f2fe78bSCy Schubert return "\uFFFD"; 699*7f2fe78bSCy Schubert } 700*7f2fe78bSCy Schubert 701*7f2fe78bSCy Schubert // Control characters and (dependent upon position) numbers get escaped as code points 702*7f2fe78bSCy Schubert return ch.slice( 0, -1 ) + "\\" + 703*7f2fe78bSCy Schubert ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " "; 704*7f2fe78bSCy Schubert } 705*7f2fe78bSCy Schubert 706*7f2fe78bSCy Schubert // Other potentially-special ASCII characters get backslash-escaped 707*7f2fe78bSCy Schubert return "\\" + ch; 708*7f2fe78bSCy Schubert }, 709*7f2fe78bSCy Schubert 710*7f2fe78bSCy Schubert // Used for iframes 711*7f2fe78bSCy Schubert // See setDocument() 712*7f2fe78bSCy Schubert // Removing the function wrapper causes a "Permission Denied" 713*7f2fe78bSCy Schubert // error in IE 714*7f2fe78bSCy Schubert unloadHandler = function() { 715*7f2fe78bSCy Schubert setDocument(); 716*7f2fe78bSCy Schubert }, 717*7f2fe78bSCy Schubert 718*7f2fe78bSCy Schubert inDisabledFieldset = addCombinator( 719*7f2fe78bSCy Schubert function( elem ) { 720*7f2fe78bSCy Schubert return elem.disabled === true && elem.nodeName.toLowerCase() === "fieldset"; 721*7f2fe78bSCy Schubert }, 722*7f2fe78bSCy Schubert { dir: "parentNode", next: "legend" } 723*7f2fe78bSCy Schubert ); 724*7f2fe78bSCy Schubert 725*7f2fe78bSCy Schubert// Optimize for push.apply( _, NodeList ) 726*7f2fe78bSCy Schuberttry { 727*7f2fe78bSCy Schubert push.apply( 728*7f2fe78bSCy Schubert ( arr = slice.call( preferredDoc.childNodes ) ), 729*7f2fe78bSCy Schubert preferredDoc.childNodes 730*7f2fe78bSCy Schubert ); 731*7f2fe78bSCy Schubert 732*7f2fe78bSCy Schubert // Support: Android<4.0 733*7f2fe78bSCy Schubert // Detect silently failing push.apply 734*7f2fe78bSCy Schubert // eslint-disable-next-line no-unused-expressions 735*7f2fe78bSCy Schubert arr[ preferredDoc.childNodes.length ].nodeType; 736*7f2fe78bSCy Schubert} catch ( e ) { 737*7f2fe78bSCy Schubert push = { apply: arr.length ? 738*7f2fe78bSCy Schubert 739*7f2fe78bSCy Schubert // Leverage slice if possible 740*7f2fe78bSCy Schubert function( target, els ) { 741*7f2fe78bSCy Schubert pushNative.apply( target, slice.call( els ) ); 742*7f2fe78bSCy Schubert } : 743*7f2fe78bSCy Schubert 744*7f2fe78bSCy Schubert // Support: IE<9 745*7f2fe78bSCy Schubert // Otherwise append directly 746*7f2fe78bSCy Schubert function( target, els ) { 747*7f2fe78bSCy Schubert var j = target.length, 748*7f2fe78bSCy Schubert i = 0; 749*7f2fe78bSCy Schubert 750*7f2fe78bSCy Schubert // Can't trust NodeList.length 751*7f2fe78bSCy Schubert while ( ( target[ j++ ] = els[ i++ ] ) ) {} 752*7f2fe78bSCy Schubert target.length = j - 1; 753*7f2fe78bSCy Schubert } 754*7f2fe78bSCy Schubert }; 755*7f2fe78bSCy Schubert} 756*7f2fe78bSCy Schubert 757*7f2fe78bSCy Schubertfunction Sizzle( selector, context, results, seed ) { 758*7f2fe78bSCy Schubert var m, i, elem, nid, match, groups, newSelector, 759*7f2fe78bSCy Schubert newContext = context && context.ownerDocument, 760*7f2fe78bSCy Schubert 761*7f2fe78bSCy Schubert // nodeType defaults to 9, since context defaults to document 762*7f2fe78bSCy Schubert nodeType = context ? context.nodeType : 9; 763*7f2fe78bSCy Schubert 764*7f2fe78bSCy Schubert results = results || []; 765*7f2fe78bSCy Schubert 766*7f2fe78bSCy Schubert // Return early from calls with invalid selector or context 767*7f2fe78bSCy Schubert if ( typeof selector !== "string" || !selector || 768*7f2fe78bSCy Schubert nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) { 769*7f2fe78bSCy Schubert 770*7f2fe78bSCy Schubert return results; 771*7f2fe78bSCy Schubert } 772*7f2fe78bSCy Schubert 773*7f2fe78bSCy Schubert // Try to shortcut find operations (as opposed to filters) in HTML documents 774*7f2fe78bSCy Schubert if ( !seed ) { 775*7f2fe78bSCy Schubert setDocument( context ); 776*7f2fe78bSCy Schubert context = context || document; 777*7f2fe78bSCy Schubert 778*7f2fe78bSCy Schubert if ( documentIsHTML ) { 779*7f2fe78bSCy Schubert 780*7f2fe78bSCy Schubert // If the selector is sufficiently simple, try using a "get*By*" DOM method 781*7f2fe78bSCy Schubert // (excepting DocumentFragment context, where the methods don't exist) 782*7f2fe78bSCy Schubert if ( nodeType !== 11 && ( match = rquickExpr.exec( selector ) ) ) { 783*7f2fe78bSCy Schubert 784*7f2fe78bSCy Schubert // ID selector 785*7f2fe78bSCy Schubert if ( ( m = match[ 1 ] ) ) { 786*7f2fe78bSCy Schubert 787*7f2fe78bSCy Schubert // Document context 788*7f2fe78bSCy Schubert if ( nodeType === 9 ) { 789*7f2fe78bSCy Schubert if ( ( elem = context.getElementById( m ) ) ) { 790*7f2fe78bSCy Schubert 791*7f2fe78bSCy Schubert // Support: IE, Opera, Webkit 792*7f2fe78bSCy Schubert // TODO: identify versions 793*7f2fe78bSCy Schubert // getElementById can match elements by name instead of ID 794*7f2fe78bSCy Schubert if ( elem.id === m ) { 795*7f2fe78bSCy Schubert results.push( elem ); 796*7f2fe78bSCy Schubert return results; 797*7f2fe78bSCy Schubert } 798*7f2fe78bSCy Schubert } else { 799*7f2fe78bSCy Schubert return results; 800*7f2fe78bSCy Schubert } 801*7f2fe78bSCy Schubert 802*7f2fe78bSCy Schubert // Element context 803*7f2fe78bSCy Schubert } else { 804*7f2fe78bSCy Schubert 805*7f2fe78bSCy Schubert // Support: IE, Opera, Webkit 806*7f2fe78bSCy Schubert // TODO: identify versions 807*7f2fe78bSCy Schubert // getElementById can match elements by name instead of ID 808*7f2fe78bSCy Schubert if ( newContext && ( elem = newContext.getElementById( m ) ) && 809*7f2fe78bSCy Schubert contains( context, elem ) && 810*7f2fe78bSCy Schubert elem.id === m ) { 811*7f2fe78bSCy Schubert 812*7f2fe78bSCy Schubert results.push( elem ); 813*7f2fe78bSCy Schubert return results; 814*7f2fe78bSCy Schubert } 815*7f2fe78bSCy Schubert } 816*7f2fe78bSCy Schubert 817*7f2fe78bSCy Schubert // Type selector 818*7f2fe78bSCy Schubert } else if ( match[ 2 ] ) { 819*7f2fe78bSCy Schubert push.apply( results, context.getElementsByTagName( selector ) ); 820*7f2fe78bSCy Schubert return results; 821*7f2fe78bSCy Schubert 822*7f2fe78bSCy Schubert // Class selector 823*7f2fe78bSCy Schubert } else if ( ( m = match[ 3 ] ) && support.getElementsByClassName && 824*7f2fe78bSCy Schubert context.getElementsByClassName ) { 825*7f2fe78bSCy Schubert 826*7f2fe78bSCy Schubert push.apply( results, context.getElementsByClassName( m ) ); 827*7f2fe78bSCy Schubert return results; 828*7f2fe78bSCy Schubert } 829*7f2fe78bSCy Schubert } 830*7f2fe78bSCy Schubert 831*7f2fe78bSCy Schubert // Take advantage of querySelectorAll 832*7f2fe78bSCy Schubert if ( support.qsa && 833*7f2fe78bSCy Schubert !nonnativeSelectorCache[ selector + " " ] && 834*7f2fe78bSCy Schubert ( !rbuggyQSA || !rbuggyQSA.test( selector ) ) && 835*7f2fe78bSCy Schubert 836*7f2fe78bSCy Schubert // Support: IE 8 only 837*7f2fe78bSCy Schubert // Exclude object elements 838*7f2fe78bSCy Schubert ( nodeType !== 1 || context.nodeName.toLowerCase() !== "object" ) ) { 839*7f2fe78bSCy Schubert 840*7f2fe78bSCy Schubert newSelector = selector; 841*7f2fe78bSCy Schubert newContext = context; 842*7f2fe78bSCy Schubert 843*7f2fe78bSCy Schubert // qSA considers elements outside a scoping root when evaluating child or 844*7f2fe78bSCy Schubert // descendant combinators, which is not what we want. 845*7f2fe78bSCy Schubert // In such cases, we work around the behavior by prefixing every selector in the 846*7f2fe78bSCy Schubert // list with an ID selector referencing the scope context. 847*7f2fe78bSCy Schubert // The technique has to be used as well when a leading combinator is used 848*7f2fe78bSCy Schubert // as such selectors are not recognized by querySelectorAll. 849*7f2fe78bSCy Schubert // Thanks to Andrew Dupont for this technique. 850*7f2fe78bSCy Schubert if ( nodeType === 1 && 851*7f2fe78bSCy Schubert ( rdescend.test( selector ) || rcombinators.test( selector ) ) ) { 852*7f2fe78bSCy Schubert 853*7f2fe78bSCy Schubert // Expand context for sibling selectors 854*7f2fe78bSCy Schubert newContext = rsibling.test( selector ) && testContext( context.parentNode ) || 855*7f2fe78bSCy Schubert context; 856*7f2fe78bSCy Schubert 857*7f2fe78bSCy Schubert // We can use :scope instead of the ID hack if the browser 858*7f2fe78bSCy Schubert // supports it & if we're not changing the context. 859*7f2fe78bSCy Schubert if ( newContext !== context || !support.scope ) { 860*7f2fe78bSCy Schubert 861*7f2fe78bSCy Schubert // Capture the context ID, setting it first if necessary 862*7f2fe78bSCy Schubert if ( ( nid = context.getAttribute( "id" ) ) ) { 863*7f2fe78bSCy Schubert nid = nid.replace( rcssescape, fcssescape ); 864*7f2fe78bSCy Schubert } else { 865*7f2fe78bSCy Schubert context.setAttribute( "id", ( nid = expando ) ); 866*7f2fe78bSCy Schubert } 867*7f2fe78bSCy Schubert } 868*7f2fe78bSCy Schubert 869*7f2fe78bSCy Schubert // Prefix every selector in the list 870*7f2fe78bSCy Schubert groups = tokenize( selector ); 871*7f2fe78bSCy Schubert i = groups.length; 872*7f2fe78bSCy Schubert while ( i-- ) { 873*7f2fe78bSCy Schubert groups[ i ] = ( nid ? "#" + nid : ":scope" ) + " " + 874*7f2fe78bSCy Schubert toSelector( groups[ i ] ); 875*7f2fe78bSCy Schubert } 876*7f2fe78bSCy Schubert newSelector = groups.join( "," ); 877*7f2fe78bSCy Schubert } 878*7f2fe78bSCy Schubert 879*7f2fe78bSCy Schubert try { 880*7f2fe78bSCy Schubert push.apply( results, 881*7f2fe78bSCy Schubert newContext.querySelectorAll( newSelector ) 882*7f2fe78bSCy Schubert ); 883*7f2fe78bSCy Schubert return results; 884*7f2fe78bSCy Schubert } catch ( qsaError ) { 885*7f2fe78bSCy Schubert nonnativeSelectorCache( selector, true ); 886*7f2fe78bSCy Schubert } finally { 887*7f2fe78bSCy Schubert if ( nid === expando ) { 888*7f2fe78bSCy Schubert context.removeAttribute( "id" ); 889*7f2fe78bSCy Schubert } 890*7f2fe78bSCy Schubert } 891*7f2fe78bSCy Schubert } 892*7f2fe78bSCy Schubert } 893*7f2fe78bSCy Schubert } 894*7f2fe78bSCy Schubert 895*7f2fe78bSCy Schubert // All others 896*7f2fe78bSCy Schubert return select( selector.replace( rtrim, "$1" ), context, results, seed ); 897*7f2fe78bSCy Schubert} 898*7f2fe78bSCy Schubert 899*7f2fe78bSCy Schubert/** 900*7f2fe78bSCy Schubert * Create key-value caches of limited size 901*7f2fe78bSCy Schubert * @returns {function(string, object)} Returns the Object data after storing it on itself with 902*7f2fe78bSCy Schubert * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength) 903*7f2fe78bSCy Schubert * deleting the oldest entry 904*7f2fe78bSCy Schubert */ 905*7f2fe78bSCy Schubertfunction createCache() { 906*7f2fe78bSCy Schubert var keys = []; 907*7f2fe78bSCy Schubert 908*7f2fe78bSCy Schubert function cache( key, value ) { 909*7f2fe78bSCy Schubert 910*7f2fe78bSCy Schubert // Use (key + " ") to avoid collision with native prototype properties (see Issue #157) 911*7f2fe78bSCy Schubert if ( keys.push( key + " " ) > Expr.cacheLength ) { 912*7f2fe78bSCy Schubert 913*7f2fe78bSCy Schubert // Only keep the most recent entries 914*7f2fe78bSCy Schubert delete cache[ keys.shift() ]; 915*7f2fe78bSCy Schubert } 916*7f2fe78bSCy Schubert return ( cache[ key + " " ] = value ); 917*7f2fe78bSCy Schubert } 918*7f2fe78bSCy Schubert return cache; 919*7f2fe78bSCy Schubert} 920*7f2fe78bSCy Schubert 921*7f2fe78bSCy Schubert/** 922*7f2fe78bSCy Schubert * Mark a function for special use by Sizzle 923*7f2fe78bSCy Schubert * @param {Function} fn The function to mark 924*7f2fe78bSCy Schubert */ 925*7f2fe78bSCy Schubertfunction markFunction( fn ) { 926*7f2fe78bSCy Schubert fn[ expando ] = true; 927*7f2fe78bSCy Schubert return fn; 928*7f2fe78bSCy Schubert} 929*7f2fe78bSCy Schubert 930*7f2fe78bSCy Schubert/** 931*7f2fe78bSCy Schubert * Support testing using an element 932*7f2fe78bSCy Schubert * @param {Function} fn Passed the created element and returns a boolean result 933*7f2fe78bSCy Schubert */ 934*7f2fe78bSCy Schubertfunction assert( fn ) { 935*7f2fe78bSCy Schubert var el = document.createElement( "fieldset" ); 936*7f2fe78bSCy Schubert 937*7f2fe78bSCy Schubert try { 938*7f2fe78bSCy Schubert return !!fn( el ); 939*7f2fe78bSCy Schubert } catch ( e ) { 940*7f2fe78bSCy Schubert return false; 941*7f2fe78bSCy Schubert } finally { 942*7f2fe78bSCy Schubert 943*7f2fe78bSCy Schubert // Remove from its parent by default 944*7f2fe78bSCy Schubert if ( el.parentNode ) { 945*7f2fe78bSCy Schubert el.parentNode.removeChild( el ); 946*7f2fe78bSCy Schubert } 947*7f2fe78bSCy Schubert 948*7f2fe78bSCy Schubert // release memory in IE 949*7f2fe78bSCy Schubert el = null; 950*7f2fe78bSCy Schubert } 951*7f2fe78bSCy Schubert} 952*7f2fe78bSCy Schubert 953*7f2fe78bSCy Schubert/** 954*7f2fe78bSCy Schubert * Adds the same handler for all of the specified attrs 955*7f2fe78bSCy Schubert * @param {String} attrs Pipe-separated list of attributes 956*7f2fe78bSCy Schubert * @param {Function} handler The method that will be applied 957*7f2fe78bSCy Schubert */ 958*7f2fe78bSCy Schubertfunction addHandle( attrs, handler ) { 959*7f2fe78bSCy Schubert var arr = attrs.split( "|" ), 960*7f2fe78bSCy Schubert i = arr.length; 961*7f2fe78bSCy Schubert 962*7f2fe78bSCy Schubert while ( i-- ) { 963*7f2fe78bSCy Schubert Expr.attrHandle[ arr[ i ] ] = handler; 964*7f2fe78bSCy Schubert } 965*7f2fe78bSCy Schubert} 966*7f2fe78bSCy Schubert 967*7f2fe78bSCy Schubert/** 968*7f2fe78bSCy Schubert * Checks document order of two siblings 969*7f2fe78bSCy Schubert * @param {Element} a 970*7f2fe78bSCy Schubert * @param {Element} b 971*7f2fe78bSCy Schubert * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b 972*7f2fe78bSCy Schubert */ 973*7f2fe78bSCy Schubertfunction siblingCheck( a, b ) { 974*7f2fe78bSCy Schubert var cur = b && a, 975*7f2fe78bSCy Schubert diff = cur && a.nodeType === 1 && b.nodeType === 1 && 976*7f2fe78bSCy Schubert a.sourceIndex - b.sourceIndex; 977*7f2fe78bSCy Schubert 978*7f2fe78bSCy Schubert // Use IE sourceIndex if available on both nodes 979*7f2fe78bSCy Schubert if ( diff ) { 980*7f2fe78bSCy Schubert return diff; 981*7f2fe78bSCy Schubert } 982*7f2fe78bSCy Schubert 983*7f2fe78bSCy Schubert // Check if b follows a 984*7f2fe78bSCy Schubert if ( cur ) { 985*7f2fe78bSCy Schubert while ( ( cur = cur.nextSibling ) ) { 986*7f2fe78bSCy Schubert if ( cur === b ) { 987*7f2fe78bSCy Schubert return -1; 988*7f2fe78bSCy Schubert } 989*7f2fe78bSCy Schubert } 990*7f2fe78bSCy Schubert } 991*7f2fe78bSCy Schubert 992*7f2fe78bSCy Schubert return a ? 1 : -1; 993*7f2fe78bSCy Schubert} 994*7f2fe78bSCy Schubert 995*7f2fe78bSCy Schubert/** 996*7f2fe78bSCy Schubert * Returns a function to use in pseudos for input types 997*7f2fe78bSCy Schubert * @param {String} type 998*7f2fe78bSCy Schubert */ 999*7f2fe78bSCy Schubertfunction createInputPseudo( type ) { 1000*7f2fe78bSCy Schubert return function( elem ) { 1001*7f2fe78bSCy Schubert var name = elem.nodeName.toLowerCase(); 1002*7f2fe78bSCy Schubert return name === "input" && elem.type === type; 1003*7f2fe78bSCy Schubert }; 1004*7f2fe78bSCy Schubert} 1005*7f2fe78bSCy Schubert 1006*7f2fe78bSCy Schubert/** 1007*7f2fe78bSCy Schubert * Returns a function to use in pseudos for buttons 1008*7f2fe78bSCy Schubert * @param {String} type 1009*7f2fe78bSCy Schubert */ 1010*7f2fe78bSCy Schubertfunction createButtonPseudo( type ) { 1011*7f2fe78bSCy Schubert return function( elem ) { 1012*7f2fe78bSCy Schubert var name = elem.nodeName.toLowerCase(); 1013*7f2fe78bSCy Schubert return ( name === "input" || name === "button" ) && elem.type === type; 1014*7f2fe78bSCy Schubert }; 1015*7f2fe78bSCy Schubert} 1016*7f2fe78bSCy Schubert 1017*7f2fe78bSCy Schubert/** 1018*7f2fe78bSCy Schubert * Returns a function to use in pseudos for :enabled/:disabled 1019*7f2fe78bSCy Schubert * @param {Boolean} disabled true for :disabled; false for :enabled 1020*7f2fe78bSCy Schubert */ 1021*7f2fe78bSCy Schubertfunction createDisabledPseudo( disabled ) { 1022*7f2fe78bSCy Schubert 1023*7f2fe78bSCy Schubert // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable 1024*7f2fe78bSCy Schubert return function( elem ) { 1025*7f2fe78bSCy Schubert 1026*7f2fe78bSCy Schubert // Only certain elements can match :enabled or :disabled 1027*7f2fe78bSCy Schubert // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled 1028*7f2fe78bSCy Schubert // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled 1029*7f2fe78bSCy Schubert if ( "form" in elem ) { 1030*7f2fe78bSCy Schubert 1031*7f2fe78bSCy Schubert // Check for inherited disabledness on relevant non-disabled elements: 1032*7f2fe78bSCy Schubert // * listed form-associated elements in a disabled fieldset 1033*7f2fe78bSCy Schubert // https://html.spec.whatwg.org/multipage/forms.html#category-listed 1034*7f2fe78bSCy Schubert // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled 1035*7f2fe78bSCy Schubert // * option elements in a disabled optgroup 1036*7f2fe78bSCy Schubert // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled 1037*7f2fe78bSCy Schubert // All such elements have a "form" property. 1038*7f2fe78bSCy Schubert if ( elem.parentNode && elem.disabled === false ) { 1039*7f2fe78bSCy Schubert 1040*7f2fe78bSCy Schubert // Option elements defer to a parent optgroup if present 1041*7f2fe78bSCy Schubert if ( "label" in elem ) { 1042*7f2fe78bSCy Schubert if ( "label" in elem.parentNode ) { 1043*7f2fe78bSCy Schubert return elem.parentNode.disabled === disabled; 1044*7f2fe78bSCy Schubert } else { 1045*7f2fe78bSCy Schubert return elem.disabled === disabled; 1046*7f2fe78bSCy Schubert } 1047*7f2fe78bSCy Schubert } 1048*7f2fe78bSCy Schubert 1049*7f2fe78bSCy Schubert // Support: IE 6 - 11 1050*7f2fe78bSCy Schubert // Use the isDisabled shortcut property to check for disabled fieldset ancestors 1051*7f2fe78bSCy Schubert return elem.isDisabled === disabled || 1052*7f2fe78bSCy Schubert 1053*7f2fe78bSCy Schubert // Where there is no isDisabled, check manually 1054*7f2fe78bSCy Schubert /* jshint -W018 */ 1055*7f2fe78bSCy Schubert elem.isDisabled !== !disabled && 1056*7f2fe78bSCy Schubert inDisabledFieldset( elem ) === disabled; 1057*7f2fe78bSCy Schubert } 1058*7f2fe78bSCy Schubert 1059*7f2fe78bSCy Schubert return elem.disabled === disabled; 1060*7f2fe78bSCy Schubert 1061*7f2fe78bSCy Schubert // Try to winnow out elements that can't be disabled before trusting the disabled property. 1062*7f2fe78bSCy Schubert // Some victims get caught in our net (label, legend, menu, track), but it shouldn't 1063*7f2fe78bSCy Schubert // even exist on them, let alone have a boolean value. 1064*7f2fe78bSCy Schubert } else if ( "label" in elem ) { 1065*7f2fe78bSCy Schubert return elem.disabled === disabled; 1066*7f2fe78bSCy Schubert } 1067*7f2fe78bSCy Schubert 1068*7f2fe78bSCy Schubert // Remaining elements are neither :enabled nor :disabled 1069*7f2fe78bSCy Schubert return false; 1070*7f2fe78bSCy Schubert }; 1071*7f2fe78bSCy Schubert} 1072*7f2fe78bSCy Schubert 1073*7f2fe78bSCy Schubert/** 1074*7f2fe78bSCy Schubert * Returns a function to use in pseudos for positionals 1075*7f2fe78bSCy Schubert * @param {Function} fn 1076*7f2fe78bSCy Schubert */ 1077*7f2fe78bSCy Schubertfunction createPositionalPseudo( fn ) { 1078*7f2fe78bSCy Schubert return markFunction( function( argument ) { 1079*7f2fe78bSCy Schubert argument = +argument; 1080*7f2fe78bSCy Schubert return markFunction( function( seed, matches ) { 1081*7f2fe78bSCy Schubert var j, 1082*7f2fe78bSCy Schubert matchIndexes = fn( [], seed.length, argument ), 1083*7f2fe78bSCy Schubert i = matchIndexes.length; 1084*7f2fe78bSCy Schubert 1085*7f2fe78bSCy Schubert // Match elements found at the specified indexes 1086*7f2fe78bSCy Schubert while ( i-- ) { 1087*7f2fe78bSCy Schubert if ( seed[ ( j = matchIndexes[ i ] ) ] ) { 1088*7f2fe78bSCy Schubert seed[ j ] = !( matches[ j ] = seed[ j ] ); 1089*7f2fe78bSCy Schubert } 1090*7f2fe78bSCy Schubert } 1091*7f2fe78bSCy Schubert } ); 1092*7f2fe78bSCy Schubert } ); 1093*7f2fe78bSCy Schubert} 1094*7f2fe78bSCy Schubert 1095*7f2fe78bSCy Schubert/** 1096*7f2fe78bSCy Schubert * Checks a node for validity as a Sizzle context 1097*7f2fe78bSCy Schubert * @param {Element|Object=} context 1098*7f2fe78bSCy Schubert * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value 1099*7f2fe78bSCy Schubert */ 1100*7f2fe78bSCy Schubertfunction testContext( context ) { 1101*7f2fe78bSCy Schubert return context && typeof context.getElementsByTagName !== "undefined" && context; 1102*7f2fe78bSCy Schubert} 1103*7f2fe78bSCy Schubert 1104*7f2fe78bSCy Schubert// Expose support vars for convenience 1105*7f2fe78bSCy Schubertsupport = Sizzle.support = {}; 1106*7f2fe78bSCy Schubert 1107*7f2fe78bSCy Schubert/** 1108*7f2fe78bSCy Schubert * Detects XML nodes 1109*7f2fe78bSCy Schubert * @param {Element|Object} elem An element or a document 1110*7f2fe78bSCy Schubert * @returns {Boolean} True iff elem is a non-HTML XML node 1111*7f2fe78bSCy Schubert */ 1112*7f2fe78bSCy SchubertisXML = Sizzle.isXML = function( elem ) { 1113*7f2fe78bSCy Schubert var namespace = elem && elem.namespaceURI, 1114*7f2fe78bSCy Schubert docElem = elem && ( elem.ownerDocument || elem ).documentElement; 1115*7f2fe78bSCy Schubert 1116*7f2fe78bSCy Schubert // Support: IE <=8 1117*7f2fe78bSCy Schubert // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes 1118*7f2fe78bSCy Schubert // https://bugs.jquery.com/ticket/4833 1119*7f2fe78bSCy Schubert return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" ); 1120*7f2fe78bSCy Schubert}; 1121*7f2fe78bSCy Schubert 1122*7f2fe78bSCy Schubert/** 1123*7f2fe78bSCy Schubert * Sets document-related variables once based on the current document 1124*7f2fe78bSCy Schubert * @param {Element|Object} [doc] An element or document object to use to set the document 1125*7f2fe78bSCy Schubert * @returns {Object} Returns the current document 1126*7f2fe78bSCy Schubert */ 1127*7f2fe78bSCy SchubertsetDocument = Sizzle.setDocument = function( node ) { 1128*7f2fe78bSCy Schubert var hasCompare, subWindow, 1129*7f2fe78bSCy Schubert doc = node ? node.ownerDocument || node : preferredDoc; 1130*7f2fe78bSCy Schubert 1131*7f2fe78bSCy Schubert // Return early if doc is invalid or already selected 1132*7f2fe78bSCy Schubert // Support: IE 11+, Edge 17 - 18+ 1133*7f2fe78bSCy Schubert // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 1134*7f2fe78bSCy Schubert // two documents; shallow comparisons work. 1135*7f2fe78bSCy Schubert // eslint-disable-next-line eqeqeq 1136*7f2fe78bSCy Schubert if ( doc == document || doc.nodeType !== 9 || !doc.documentElement ) { 1137*7f2fe78bSCy Schubert return document; 1138*7f2fe78bSCy Schubert } 1139*7f2fe78bSCy Schubert 1140*7f2fe78bSCy Schubert // Update global variables 1141*7f2fe78bSCy Schubert document = doc; 1142*7f2fe78bSCy Schubert docElem = document.documentElement; 1143*7f2fe78bSCy Schubert documentIsHTML = !isXML( document ); 1144*7f2fe78bSCy Schubert 1145*7f2fe78bSCy Schubert // Support: IE 9 - 11+, Edge 12 - 18+ 1146*7f2fe78bSCy Schubert // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936) 1147*7f2fe78bSCy Schubert // Support: IE 11+, Edge 17 - 18+ 1148*7f2fe78bSCy Schubert // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 1149*7f2fe78bSCy Schubert // two documents; shallow comparisons work. 1150*7f2fe78bSCy Schubert // eslint-disable-next-line eqeqeq 1151*7f2fe78bSCy Schubert if ( preferredDoc != document && 1152*7f2fe78bSCy Schubert ( subWindow = document.defaultView ) && subWindow.top !== subWindow ) { 1153*7f2fe78bSCy Schubert 1154*7f2fe78bSCy Schubert // Support: IE 11, Edge 1155*7f2fe78bSCy Schubert if ( subWindow.addEventListener ) { 1156*7f2fe78bSCy Schubert subWindow.addEventListener( "unload", unloadHandler, false ); 1157*7f2fe78bSCy Schubert 1158*7f2fe78bSCy Schubert // Support: IE 9 - 10 only 1159*7f2fe78bSCy Schubert } else if ( subWindow.attachEvent ) { 1160*7f2fe78bSCy Schubert subWindow.attachEvent( "onunload", unloadHandler ); 1161*7f2fe78bSCy Schubert } 1162*7f2fe78bSCy Schubert } 1163*7f2fe78bSCy Schubert 1164*7f2fe78bSCy Schubert // Support: IE 8 - 11+, Edge 12 - 18+, Chrome <=16 - 25 only, Firefox <=3.6 - 31 only, 1165*7f2fe78bSCy Schubert // Safari 4 - 5 only, Opera <=11.6 - 12.x only 1166*7f2fe78bSCy Schubert // IE/Edge & older browsers don't support the :scope pseudo-class. 1167*7f2fe78bSCy Schubert // Support: Safari 6.0 only 1168*7f2fe78bSCy Schubert // Safari 6.0 supports :scope but it's an alias of :root there. 1169*7f2fe78bSCy Schubert support.scope = assert( function( el ) { 1170*7f2fe78bSCy Schubert docElem.appendChild( el ).appendChild( document.createElement( "div" ) ); 1171*7f2fe78bSCy Schubert return typeof el.querySelectorAll !== "undefined" && 1172*7f2fe78bSCy Schubert !el.querySelectorAll( ":scope fieldset div" ).length; 1173*7f2fe78bSCy Schubert } ); 1174*7f2fe78bSCy Schubert 1175*7f2fe78bSCy Schubert /* Attributes 1176*7f2fe78bSCy Schubert ---------------------------------------------------------------------- */ 1177*7f2fe78bSCy Schubert 1178*7f2fe78bSCy Schubert // Support: IE<8 1179*7f2fe78bSCy Schubert // Verify that getAttribute really returns attributes and not properties 1180*7f2fe78bSCy Schubert // (excepting IE8 booleans) 1181*7f2fe78bSCy Schubert support.attributes = assert( function( el ) { 1182*7f2fe78bSCy Schubert el.className = "i"; 1183*7f2fe78bSCy Schubert return !el.getAttribute( "className" ); 1184*7f2fe78bSCy Schubert } ); 1185*7f2fe78bSCy Schubert 1186*7f2fe78bSCy Schubert /* getElement(s)By* 1187*7f2fe78bSCy Schubert ---------------------------------------------------------------------- */ 1188*7f2fe78bSCy Schubert 1189*7f2fe78bSCy Schubert // Check if getElementsByTagName("*") returns only elements 1190*7f2fe78bSCy Schubert support.getElementsByTagName = assert( function( el ) { 1191*7f2fe78bSCy Schubert el.appendChild( document.createComment( "" ) ); 1192*7f2fe78bSCy Schubert return !el.getElementsByTagName( "*" ).length; 1193*7f2fe78bSCy Schubert } ); 1194*7f2fe78bSCy Schubert 1195*7f2fe78bSCy Schubert // Support: IE<9 1196*7f2fe78bSCy Schubert support.getElementsByClassName = rnative.test( document.getElementsByClassName ); 1197*7f2fe78bSCy Schubert 1198*7f2fe78bSCy Schubert // Support: IE<10 1199*7f2fe78bSCy Schubert // Check if getElementById returns elements by name 1200*7f2fe78bSCy Schubert // The broken getElementById methods don't pick up programmatically-set names, 1201*7f2fe78bSCy Schubert // so use a roundabout getElementsByName test 1202*7f2fe78bSCy Schubert support.getById = assert( function( el ) { 1203*7f2fe78bSCy Schubert docElem.appendChild( el ).id = expando; 1204*7f2fe78bSCy Schubert return !document.getElementsByName || !document.getElementsByName( expando ).length; 1205*7f2fe78bSCy Schubert } ); 1206*7f2fe78bSCy Schubert 1207*7f2fe78bSCy Schubert // ID filter and find 1208*7f2fe78bSCy Schubert if ( support.getById ) { 1209*7f2fe78bSCy Schubert Expr.filter[ "ID" ] = function( id ) { 1210*7f2fe78bSCy Schubert var attrId = id.replace( runescape, funescape ); 1211*7f2fe78bSCy Schubert return function( elem ) { 1212*7f2fe78bSCy Schubert return elem.getAttribute( "id" ) === attrId; 1213*7f2fe78bSCy Schubert }; 1214*7f2fe78bSCy Schubert }; 1215*7f2fe78bSCy Schubert Expr.find[ "ID" ] = function( id, context ) { 1216*7f2fe78bSCy Schubert if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { 1217*7f2fe78bSCy Schubert var elem = context.getElementById( id ); 1218*7f2fe78bSCy Schubert return elem ? [ elem ] : []; 1219*7f2fe78bSCy Schubert } 1220*7f2fe78bSCy Schubert }; 1221*7f2fe78bSCy Schubert } else { 1222*7f2fe78bSCy Schubert Expr.filter[ "ID" ] = function( id ) { 1223*7f2fe78bSCy Schubert var attrId = id.replace( runescape, funescape ); 1224*7f2fe78bSCy Schubert return function( elem ) { 1225*7f2fe78bSCy Schubert var node = typeof elem.getAttributeNode !== "undefined" && 1226*7f2fe78bSCy Schubert elem.getAttributeNode( "id" ); 1227*7f2fe78bSCy Schubert return node && node.value === attrId; 1228*7f2fe78bSCy Schubert }; 1229*7f2fe78bSCy Schubert }; 1230*7f2fe78bSCy Schubert 1231*7f2fe78bSCy Schubert // Support: IE 6 - 7 only 1232*7f2fe78bSCy Schubert // getElementById is not reliable as a find shortcut 1233*7f2fe78bSCy Schubert Expr.find[ "ID" ] = function( id, context ) { 1234*7f2fe78bSCy Schubert if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { 1235*7f2fe78bSCy Schubert var node, i, elems, 1236*7f2fe78bSCy Schubert elem = context.getElementById( id ); 1237*7f2fe78bSCy Schubert 1238*7f2fe78bSCy Schubert if ( elem ) { 1239*7f2fe78bSCy Schubert 1240*7f2fe78bSCy Schubert // Verify the id attribute 1241*7f2fe78bSCy Schubert node = elem.getAttributeNode( "id" ); 1242*7f2fe78bSCy Schubert if ( node && node.value === id ) { 1243*7f2fe78bSCy Schubert return [ elem ]; 1244*7f2fe78bSCy Schubert } 1245*7f2fe78bSCy Schubert 1246*7f2fe78bSCy Schubert // Fall back on getElementsByName 1247*7f2fe78bSCy Schubert elems = context.getElementsByName( id ); 1248*7f2fe78bSCy Schubert i = 0; 1249*7f2fe78bSCy Schubert while ( ( elem = elems[ i++ ] ) ) { 1250*7f2fe78bSCy Schubert node = elem.getAttributeNode( "id" ); 1251*7f2fe78bSCy Schubert if ( node && node.value === id ) { 1252*7f2fe78bSCy Schubert return [ elem ]; 1253*7f2fe78bSCy Schubert } 1254*7f2fe78bSCy Schubert } 1255*7f2fe78bSCy Schubert } 1256*7f2fe78bSCy Schubert 1257*7f2fe78bSCy Schubert return []; 1258*7f2fe78bSCy Schubert } 1259*7f2fe78bSCy Schubert }; 1260*7f2fe78bSCy Schubert } 1261*7f2fe78bSCy Schubert 1262*7f2fe78bSCy Schubert // Tag 1263*7f2fe78bSCy Schubert Expr.find[ "TAG" ] = support.getElementsByTagName ? 1264*7f2fe78bSCy Schubert function( tag, context ) { 1265*7f2fe78bSCy Schubert if ( typeof context.getElementsByTagName !== "undefined" ) { 1266*7f2fe78bSCy Schubert return context.getElementsByTagName( tag ); 1267*7f2fe78bSCy Schubert 1268*7f2fe78bSCy Schubert // DocumentFragment nodes don't have gEBTN 1269*7f2fe78bSCy Schubert } else if ( support.qsa ) { 1270*7f2fe78bSCy Schubert return context.querySelectorAll( tag ); 1271*7f2fe78bSCy Schubert } 1272*7f2fe78bSCy Schubert } : 1273*7f2fe78bSCy Schubert 1274*7f2fe78bSCy Schubert function( tag, context ) { 1275*7f2fe78bSCy Schubert var elem, 1276*7f2fe78bSCy Schubert tmp = [], 1277*7f2fe78bSCy Schubert i = 0, 1278*7f2fe78bSCy Schubert 1279*7f2fe78bSCy Schubert // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too 1280*7f2fe78bSCy Schubert results = context.getElementsByTagName( tag ); 1281*7f2fe78bSCy Schubert 1282*7f2fe78bSCy Schubert // Filter out possible comments 1283*7f2fe78bSCy Schubert if ( tag === "*" ) { 1284*7f2fe78bSCy Schubert while ( ( elem = results[ i++ ] ) ) { 1285*7f2fe78bSCy Schubert if ( elem.nodeType === 1 ) { 1286*7f2fe78bSCy Schubert tmp.push( elem ); 1287*7f2fe78bSCy Schubert } 1288*7f2fe78bSCy Schubert } 1289*7f2fe78bSCy Schubert 1290*7f2fe78bSCy Schubert return tmp; 1291*7f2fe78bSCy Schubert } 1292*7f2fe78bSCy Schubert return results; 1293*7f2fe78bSCy Schubert }; 1294*7f2fe78bSCy Schubert 1295*7f2fe78bSCy Schubert // Class 1296*7f2fe78bSCy Schubert Expr.find[ "CLASS" ] = support.getElementsByClassName && function( className, context ) { 1297*7f2fe78bSCy Schubert if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) { 1298*7f2fe78bSCy Schubert return context.getElementsByClassName( className ); 1299*7f2fe78bSCy Schubert } 1300*7f2fe78bSCy Schubert }; 1301*7f2fe78bSCy Schubert 1302*7f2fe78bSCy Schubert /* QSA/matchesSelector 1303*7f2fe78bSCy Schubert ---------------------------------------------------------------------- */ 1304*7f2fe78bSCy Schubert 1305*7f2fe78bSCy Schubert // QSA and matchesSelector support 1306*7f2fe78bSCy Schubert 1307*7f2fe78bSCy Schubert // matchesSelector(:active) reports false when true (IE9/Opera 11.5) 1308*7f2fe78bSCy Schubert rbuggyMatches = []; 1309*7f2fe78bSCy Schubert 1310*7f2fe78bSCy Schubert // qSa(:focus) reports false when true (Chrome 21) 1311*7f2fe78bSCy Schubert // We allow this because of a bug in IE8/9 that throws an error 1312*7f2fe78bSCy Schubert // whenever `document.activeElement` is accessed on an iframe 1313*7f2fe78bSCy Schubert // So, we allow :focus to pass through QSA all the time to avoid the IE error 1314*7f2fe78bSCy Schubert // See https://bugs.jquery.com/ticket/13378 1315*7f2fe78bSCy Schubert rbuggyQSA = []; 1316*7f2fe78bSCy Schubert 1317*7f2fe78bSCy Schubert if ( ( support.qsa = rnative.test( document.querySelectorAll ) ) ) { 1318*7f2fe78bSCy Schubert 1319*7f2fe78bSCy Schubert // Build QSA regex 1320*7f2fe78bSCy Schubert // Regex strategy adopted from Diego Perini 1321*7f2fe78bSCy Schubert assert( function( el ) { 1322*7f2fe78bSCy Schubert 1323*7f2fe78bSCy Schubert var input; 1324*7f2fe78bSCy Schubert 1325*7f2fe78bSCy Schubert // Select is set to empty string on purpose 1326*7f2fe78bSCy Schubert // This is to test IE's treatment of not explicitly 1327*7f2fe78bSCy Schubert // setting a boolean content attribute, 1328*7f2fe78bSCy Schubert // since its presence should be enough 1329*7f2fe78bSCy Schubert // https://bugs.jquery.com/ticket/12359 1330*7f2fe78bSCy Schubert docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" + 1331*7f2fe78bSCy Schubert "<select id='" + expando + "-\r\\' msallowcapture=''>" + 1332*7f2fe78bSCy Schubert "<option selected=''></option></select>"; 1333*7f2fe78bSCy Schubert 1334*7f2fe78bSCy Schubert // Support: IE8, Opera 11-12.16 1335*7f2fe78bSCy Schubert // Nothing should be selected when empty strings follow ^= or $= or *= 1336*7f2fe78bSCy Schubert // The test attribute must be unknown in Opera but "safe" for WinRT 1337*7f2fe78bSCy Schubert // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section 1338*7f2fe78bSCy Schubert if ( el.querySelectorAll( "[msallowcapture^='']" ).length ) { 1339*7f2fe78bSCy Schubert rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" ); 1340*7f2fe78bSCy Schubert } 1341*7f2fe78bSCy Schubert 1342*7f2fe78bSCy Schubert // Support: IE8 1343*7f2fe78bSCy Schubert // Boolean attributes and "value" are not treated correctly 1344*7f2fe78bSCy Schubert if ( !el.querySelectorAll( "[selected]" ).length ) { 1345*7f2fe78bSCy Schubert rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" ); 1346*7f2fe78bSCy Schubert } 1347*7f2fe78bSCy Schubert 1348*7f2fe78bSCy Schubert // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+ 1349*7f2fe78bSCy Schubert if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) { 1350*7f2fe78bSCy Schubert rbuggyQSA.push( "~=" ); 1351*7f2fe78bSCy Schubert } 1352*7f2fe78bSCy Schubert 1353*7f2fe78bSCy Schubert // Support: IE 11+, Edge 15 - 18+ 1354*7f2fe78bSCy Schubert // IE 11/Edge don't find elements on a `[name='']` query in some cases. 1355*7f2fe78bSCy Schubert // Adding a temporary attribute to the document before the selection works 1356*7f2fe78bSCy Schubert // around the issue. 1357*7f2fe78bSCy Schubert // Interestingly, IE 10 & older don't seem to have the issue. 1358*7f2fe78bSCy Schubert input = document.createElement( "input" ); 1359*7f2fe78bSCy Schubert input.setAttribute( "name", "" ); 1360*7f2fe78bSCy Schubert el.appendChild( input ); 1361*7f2fe78bSCy Schubert if ( !el.querySelectorAll( "[name='']" ).length ) { 1362*7f2fe78bSCy Schubert rbuggyQSA.push( "\\[" + whitespace + "*name" + whitespace + "*=" + 1363*7f2fe78bSCy Schubert whitespace + "*(?:''|\"\")" ); 1364*7f2fe78bSCy Schubert } 1365*7f2fe78bSCy Schubert 1366*7f2fe78bSCy Schubert // Webkit/Opera - :checked should return selected option elements 1367*7f2fe78bSCy Schubert // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked 1368*7f2fe78bSCy Schubert // IE8 throws error here and will not see later tests 1369*7f2fe78bSCy Schubert if ( !el.querySelectorAll( ":checked" ).length ) { 1370*7f2fe78bSCy Schubert rbuggyQSA.push( ":checked" ); 1371*7f2fe78bSCy Schubert } 1372*7f2fe78bSCy Schubert 1373*7f2fe78bSCy Schubert // Support: Safari 8+, iOS 8+ 1374*7f2fe78bSCy Schubert // https://bugs.webkit.org/show_bug.cgi?id=136851 1375*7f2fe78bSCy Schubert // In-page `selector#id sibling-combinator selector` fails 1376*7f2fe78bSCy Schubert if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) { 1377*7f2fe78bSCy Schubert rbuggyQSA.push( ".#.+[+~]" ); 1378*7f2fe78bSCy Schubert } 1379*7f2fe78bSCy Schubert 1380*7f2fe78bSCy Schubert // Support: Firefox <=3.6 - 5 only 1381*7f2fe78bSCy Schubert // Old Firefox doesn't throw on a badly-escaped identifier. 1382*7f2fe78bSCy Schubert el.querySelectorAll( "\\\f" ); 1383*7f2fe78bSCy Schubert rbuggyQSA.push( "[\\r\\n\\f]" ); 1384*7f2fe78bSCy Schubert } ); 1385*7f2fe78bSCy Schubert 1386*7f2fe78bSCy Schubert assert( function( el ) { 1387*7f2fe78bSCy Schubert el.innerHTML = "<a href='' disabled='disabled'></a>" + 1388*7f2fe78bSCy Schubert "<select disabled='disabled'><option/></select>"; 1389*7f2fe78bSCy Schubert 1390*7f2fe78bSCy Schubert // Support: Windows 8 Native Apps 1391*7f2fe78bSCy Schubert // The type and name attributes are restricted during .innerHTML assignment 1392*7f2fe78bSCy Schubert var input = document.createElement( "input" ); 1393*7f2fe78bSCy Schubert input.setAttribute( "type", "hidden" ); 1394*7f2fe78bSCy Schubert el.appendChild( input ).setAttribute( "name", "D" ); 1395*7f2fe78bSCy Schubert 1396*7f2fe78bSCy Schubert // Support: IE8 1397*7f2fe78bSCy Schubert // Enforce case-sensitivity of name attribute 1398*7f2fe78bSCy Schubert if ( el.querySelectorAll( "[name=d]" ).length ) { 1399*7f2fe78bSCy Schubert rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" ); 1400*7f2fe78bSCy Schubert } 1401*7f2fe78bSCy Schubert 1402*7f2fe78bSCy Schubert // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) 1403*7f2fe78bSCy Schubert // IE8 throws error here and will not see later tests 1404*7f2fe78bSCy Schubert if ( el.querySelectorAll( ":enabled" ).length !== 2 ) { 1405*7f2fe78bSCy Schubert rbuggyQSA.push( ":enabled", ":disabled" ); 1406*7f2fe78bSCy Schubert } 1407*7f2fe78bSCy Schubert 1408*7f2fe78bSCy Schubert // Support: IE9-11+ 1409*7f2fe78bSCy Schubert // IE's :disabled selector does not pick up the children of disabled fieldsets 1410*7f2fe78bSCy Schubert docElem.appendChild( el ).disabled = true; 1411*7f2fe78bSCy Schubert if ( el.querySelectorAll( ":disabled" ).length !== 2 ) { 1412*7f2fe78bSCy Schubert rbuggyQSA.push( ":enabled", ":disabled" ); 1413*7f2fe78bSCy Schubert } 1414*7f2fe78bSCy Schubert 1415*7f2fe78bSCy Schubert // Support: Opera 10 - 11 only 1416*7f2fe78bSCy Schubert // Opera 10-11 does not throw on post-comma invalid pseudos 1417*7f2fe78bSCy Schubert el.querySelectorAll( "*,:x" ); 1418*7f2fe78bSCy Schubert rbuggyQSA.push( ",.*:" ); 1419*7f2fe78bSCy Schubert } ); 1420*7f2fe78bSCy Schubert } 1421*7f2fe78bSCy Schubert 1422*7f2fe78bSCy Schubert if ( ( support.matchesSelector = rnative.test( ( matches = docElem.matches || 1423*7f2fe78bSCy Schubert docElem.webkitMatchesSelector || 1424*7f2fe78bSCy Schubert docElem.mozMatchesSelector || 1425*7f2fe78bSCy Schubert docElem.oMatchesSelector || 1426*7f2fe78bSCy Schubert docElem.msMatchesSelector ) ) ) ) { 1427*7f2fe78bSCy Schubert 1428*7f2fe78bSCy Schubert assert( function( el ) { 1429*7f2fe78bSCy Schubert 1430*7f2fe78bSCy Schubert // Check to see if it's possible to do matchesSelector 1431*7f2fe78bSCy Schubert // on a disconnected node (IE 9) 1432*7f2fe78bSCy Schubert support.disconnectedMatch = matches.call( el, "*" ); 1433*7f2fe78bSCy Schubert 1434*7f2fe78bSCy Schubert // This should fail with an exception 1435*7f2fe78bSCy Schubert // Gecko does not error, returns false instead 1436*7f2fe78bSCy Schubert matches.call( el, "[s!='']:x" ); 1437*7f2fe78bSCy Schubert rbuggyMatches.push( "!=", pseudos ); 1438*7f2fe78bSCy Schubert } ); 1439*7f2fe78bSCy Schubert } 1440*7f2fe78bSCy Schubert 1441*7f2fe78bSCy Schubert rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join( "|" ) ); 1442*7f2fe78bSCy Schubert rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join( "|" ) ); 1443*7f2fe78bSCy Schubert 1444*7f2fe78bSCy Schubert /* Contains 1445*7f2fe78bSCy Schubert ---------------------------------------------------------------------- */ 1446*7f2fe78bSCy Schubert hasCompare = rnative.test( docElem.compareDocumentPosition ); 1447*7f2fe78bSCy Schubert 1448*7f2fe78bSCy Schubert // Element contains another 1449*7f2fe78bSCy Schubert // Purposefully self-exclusive 1450*7f2fe78bSCy Schubert // As in, an element does not contain itself 1451*7f2fe78bSCy Schubert contains = hasCompare || rnative.test( docElem.contains ) ? 1452*7f2fe78bSCy Schubert function( a, b ) { 1453*7f2fe78bSCy Schubert var adown = a.nodeType === 9 ? a.documentElement : a, 1454*7f2fe78bSCy Schubert bup = b && b.parentNode; 1455*7f2fe78bSCy Schubert return a === bup || !!( bup && bup.nodeType === 1 && ( 1456*7f2fe78bSCy Schubert adown.contains ? 1457*7f2fe78bSCy Schubert adown.contains( bup ) : 1458*7f2fe78bSCy Schubert a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16 1459*7f2fe78bSCy Schubert ) ); 1460*7f2fe78bSCy Schubert } : 1461*7f2fe78bSCy Schubert function( a, b ) { 1462*7f2fe78bSCy Schubert if ( b ) { 1463*7f2fe78bSCy Schubert while ( ( b = b.parentNode ) ) { 1464*7f2fe78bSCy Schubert if ( b === a ) { 1465*7f2fe78bSCy Schubert return true; 1466*7f2fe78bSCy Schubert } 1467*7f2fe78bSCy Schubert } 1468*7f2fe78bSCy Schubert } 1469*7f2fe78bSCy Schubert return false; 1470*7f2fe78bSCy Schubert }; 1471*7f2fe78bSCy Schubert 1472*7f2fe78bSCy Schubert /* Sorting 1473*7f2fe78bSCy Schubert ---------------------------------------------------------------------- */ 1474*7f2fe78bSCy Schubert 1475*7f2fe78bSCy Schubert // Document order sorting 1476*7f2fe78bSCy Schubert sortOrder = hasCompare ? 1477*7f2fe78bSCy Schubert function( a, b ) { 1478*7f2fe78bSCy Schubert 1479*7f2fe78bSCy Schubert // Flag for duplicate removal 1480*7f2fe78bSCy Schubert if ( a === b ) { 1481*7f2fe78bSCy Schubert hasDuplicate = true; 1482*7f2fe78bSCy Schubert return 0; 1483*7f2fe78bSCy Schubert } 1484*7f2fe78bSCy Schubert 1485*7f2fe78bSCy Schubert // Sort on method existence if only one input has compareDocumentPosition 1486*7f2fe78bSCy Schubert var compare = !a.compareDocumentPosition - !b.compareDocumentPosition; 1487*7f2fe78bSCy Schubert if ( compare ) { 1488*7f2fe78bSCy Schubert return compare; 1489*7f2fe78bSCy Schubert } 1490*7f2fe78bSCy Schubert 1491*7f2fe78bSCy Schubert // Calculate position if both inputs belong to the same document 1492*7f2fe78bSCy Schubert // Support: IE 11+, Edge 17 - 18+ 1493*7f2fe78bSCy Schubert // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 1494*7f2fe78bSCy Schubert // two documents; shallow comparisons work. 1495*7f2fe78bSCy Schubert // eslint-disable-next-line eqeqeq 1496*7f2fe78bSCy Schubert compare = ( a.ownerDocument || a ) == ( b.ownerDocument || b ) ? 1497*7f2fe78bSCy Schubert a.compareDocumentPosition( b ) : 1498*7f2fe78bSCy Schubert 1499*7f2fe78bSCy Schubert // Otherwise we know they are disconnected 1500*7f2fe78bSCy Schubert 1; 1501*7f2fe78bSCy Schubert 1502*7f2fe78bSCy Schubert // Disconnected nodes 1503*7f2fe78bSCy Schubert if ( compare & 1 || 1504*7f2fe78bSCy Schubert ( !support.sortDetached && b.compareDocumentPosition( a ) === compare ) ) { 1505*7f2fe78bSCy Schubert 1506*7f2fe78bSCy Schubert // Choose the first element that is related to our preferred document 1507*7f2fe78bSCy Schubert // Support: IE 11+, Edge 17 - 18+ 1508*7f2fe78bSCy Schubert // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 1509*7f2fe78bSCy Schubert // two documents; shallow comparisons work. 1510*7f2fe78bSCy Schubert // eslint-disable-next-line eqeqeq 1511*7f2fe78bSCy Schubert if ( a == document || a.ownerDocument == preferredDoc && 1512*7f2fe78bSCy Schubert contains( preferredDoc, a ) ) { 1513*7f2fe78bSCy Schubert return -1; 1514*7f2fe78bSCy Schubert } 1515*7f2fe78bSCy Schubert 1516*7f2fe78bSCy Schubert // Support: IE 11+, Edge 17 - 18+ 1517*7f2fe78bSCy Schubert // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 1518*7f2fe78bSCy Schubert // two documents; shallow comparisons work. 1519*7f2fe78bSCy Schubert // eslint-disable-next-line eqeqeq 1520*7f2fe78bSCy Schubert if ( b == document || b.ownerDocument == preferredDoc && 1521*7f2fe78bSCy Schubert contains( preferredDoc, b ) ) { 1522*7f2fe78bSCy Schubert return 1; 1523*7f2fe78bSCy Schubert } 1524*7f2fe78bSCy Schubert 1525*7f2fe78bSCy Schubert // Maintain original order 1526*7f2fe78bSCy Schubert return sortInput ? 1527*7f2fe78bSCy Schubert ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : 1528*7f2fe78bSCy Schubert 0; 1529*7f2fe78bSCy Schubert } 1530*7f2fe78bSCy Schubert 1531*7f2fe78bSCy Schubert return compare & 4 ? -1 : 1; 1532*7f2fe78bSCy Schubert } : 1533*7f2fe78bSCy Schubert function( a, b ) { 1534*7f2fe78bSCy Schubert 1535*7f2fe78bSCy Schubert // Exit early if the nodes are identical 1536*7f2fe78bSCy Schubert if ( a === b ) { 1537*7f2fe78bSCy Schubert hasDuplicate = true; 1538*7f2fe78bSCy Schubert return 0; 1539*7f2fe78bSCy Schubert } 1540*7f2fe78bSCy Schubert 1541*7f2fe78bSCy Schubert var cur, 1542*7f2fe78bSCy Schubert i = 0, 1543*7f2fe78bSCy Schubert aup = a.parentNode, 1544*7f2fe78bSCy Schubert bup = b.parentNode, 1545*7f2fe78bSCy Schubert ap = [ a ], 1546*7f2fe78bSCy Schubert bp = [ b ]; 1547*7f2fe78bSCy Schubert 1548*7f2fe78bSCy Schubert // Parentless nodes are either documents or disconnected 1549*7f2fe78bSCy Schubert if ( !aup || !bup ) { 1550*7f2fe78bSCy Schubert 1551*7f2fe78bSCy Schubert // Support: IE 11+, Edge 17 - 18+ 1552*7f2fe78bSCy Schubert // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 1553*7f2fe78bSCy Schubert // two documents; shallow comparisons work. 1554*7f2fe78bSCy Schubert /* eslint-disable eqeqeq */ 1555*7f2fe78bSCy Schubert return a == document ? -1 : 1556*7f2fe78bSCy Schubert b == document ? 1 : 1557*7f2fe78bSCy Schubert /* eslint-enable eqeqeq */ 1558*7f2fe78bSCy Schubert aup ? -1 : 1559*7f2fe78bSCy Schubert bup ? 1 : 1560*7f2fe78bSCy Schubert sortInput ? 1561*7f2fe78bSCy Schubert ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : 1562*7f2fe78bSCy Schubert 0; 1563*7f2fe78bSCy Schubert 1564*7f2fe78bSCy Schubert // If the nodes are siblings, we can do a quick check 1565*7f2fe78bSCy Schubert } else if ( aup === bup ) { 1566*7f2fe78bSCy Schubert return siblingCheck( a, b ); 1567*7f2fe78bSCy Schubert } 1568*7f2fe78bSCy Schubert 1569*7f2fe78bSCy Schubert // Otherwise we need full lists of their ancestors for comparison 1570*7f2fe78bSCy Schubert cur = a; 1571*7f2fe78bSCy Schubert while ( ( cur = cur.parentNode ) ) { 1572*7f2fe78bSCy Schubert ap.unshift( cur ); 1573*7f2fe78bSCy Schubert } 1574*7f2fe78bSCy Schubert cur = b; 1575*7f2fe78bSCy Schubert while ( ( cur = cur.parentNode ) ) { 1576*7f2fe78bSCy Schubert bp.unshift( cur ); 1577*7f2fe78bSCy Schubert } 1578*7f2fe78bSCy Schubert 1579*7f2fe78bSCy Schubert // Walk down the tree looking for a discrepancy 1580*7f2fe78bSCy Schubert while ( ap[ i ] === bp[ i ] ) { 1581*7f2fe78bSCy Schubert i++; 1582*7f2fe78bSCy Schubert } 1583*7f2fe78bSCy Schubert 1584*7f2fe78bSCy Schubert return i ? 1585*7f2fe78bSCy Schubert 1586*7f2fe78bSCy Schubert // Do a sibling check if the nodes have a common ancestor 1587*7f2fe78bSCy Schubert siblingCheck( ap[ i ], bp[ i ] ) : 1588*7f2fe78bSCy Schubert 1589*7f2fe78bSCy Schubert // Otherwise nodes in our document sort first 1590*7f2fe78bSCy Schubert // Support: IE 11+, Edge 17 - 18+ 1591*7f2fe78bSCy Schubert // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 1592*7f2fe78bSCy Schubert // two documents; shallow comparisons work. 1593*7f2fe78bSCy Schubert /* eslint-disable eqeqeq */ 1594*7f2fe78bSCy Schubert ap[ i ] == preferredDoc ? -1 : 1595*7f2fe78bSCy Schubert bp[ i ] == preferredDoc ? 1 : 1596*7f2fe78bSCy Schubert /* eslint-enable eqeqeq */ 1597*7f2fe78bSCy Schubert 0; 1598*7f2fe78bSCy Schubert }; 1599*7f2fe78bSCy Schubert 1600*7f2fe78bSCy Schubert return document; 1601*7f2fe78bSCy Schubert}; 1602*7f2fe78bSCy Schubert 1603*7f2fe78bSCy SchubertSizzle.matches = function( expr, elements ) { 1604*7f2fe78bSCy Schubert return Sizzle( expr, null, null, elements ); 1605*7f2fe78bSCy Schubert}; 1606*7f2fe78bSCy Schubert 1607*7f2fe78bSCy SchubertSizzle.matchesSelector = function( elem, expr ) { 1608*7f2fe78bSCy Schubert setDocument( elem ); 1609*7f2fe78bSCy Schubert 1610*7f2fe78bSCy Schubert if ( support.matchesSelector && documentIsHTML && 1611*7f2fe78bSCy Schubert !nonnativeSelectorCache[ expr + " " ] && 1612*7f2fe78bSCy Schubert ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) && 1613*7f2fe78bSCy Schubert ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) { 1614*7f2fe78bSCy Schubert 1615*7f2fe78bSCy Schubert try { 1616*7f2fe78bSCy Schubert var ret = matches.call( elem, expr ); 1617*7f2fe78bSCy Schubert 1618*7f2fe78bSCy Schubert // IE 9's matchesSelector returns false on disconnected nodes 1619*7f2fe78bSCy Schubert if ( ret || support.disconnectedMatch || 1620*7f2fe78bSCy Schubert 1621*7f2fe78bSCy Schubert // As well, disconnected nodes are said to be in a document 1622*7f2fe78bSCy Schubert // fragment in IE 9 1623*7f2fe78bSCy Schubert elem.document && elem.document.nodeType !== 11 ) { 1624*7f2fe78bSCy Schubert return ret; 1625*7f2fe78bSCy Schubert } 1626*7f2fe78bSCy Schubert } catch ( e ) { 1627*7f2fe78bSCy Schubert nonnativeSelectorCache( expr, true ); 1628*7f2fe78bSCy Schubert } 1629*7f2fe78bSCy Schubert } 1630*7f2fe78bSCy Schubert 1631*7f2fe78bSCy Schubert return Sizzle( expr, document, null, [ elem ] ).length > 0; 1632*7f2fe78bSCy Schubert}; 1633*7f2fe78bSCy Schubert 1634*7f2fe78bSCy SchubertSizzle.contains = function( context, elem ) { 1635*7f2fe78bSCy Schubert 1636*7f2fe78bSCy Schubert // Set document vars if needed 1637*7f2fe78bSCy Schubert // Support: IE 11+, Edge 17 - 18+ 1638*7f2fe78bSCy Schubert // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 1639*7f2fe78bSCy Schubert // two documents; shallow comparisons work. 1640*7f2fe78bSCy Schubert // eslint-disable-next-line eqeqeq 1641*7f2fe78bSCy Schubert if ( ( context.ownerDocument || context ) != document ) { 1642*7f2fe78bSCy Schubert setDocument( context ); 1643*7f2fe78bSCy Schubert } 1644*7f2fe78bSCy Schubert return contains( context, elem ); 1645*7f2fe78bSCy Schubert}; 1646*7f2fe78bSCy Schubert 1647*7f2fe78bSCy SchubertSizzle.attr = function( elem, name ) { 1648*7f2fe78bSCy Schubert 1649*7f2fe78bSCy Schubert // Set document vars if needed 1650*7f2fe78bSCy Schubert // Support: IE 11+, Edge 17 - 18+ 1651*7f2fe78bSCy Schubert // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 1652*7f2fe78bSCy Schubert // two documents; shallow comparisons work. 1653*7f2fe78bSCy Schubert // eslint-disable-next-line eqeqeq 1654*7f2fe78bSCy Schubert if ( ( elem.ownerDocument || elem ) != document ) { 1655*7f2fe78bSCy Schubert setDocument( elem ); 1656*7f2fe78bSCy Schubert } 1657*7f2fe78bSCy Schubert 1658*7f2fe78bSCy Schubert var fn = Expr.attrHandle[ name.toLowerCase() ], 1659*7f2fe78bSCy Schubert 1660*7f2fe78bSCy Schubert // Don't get fooled by Object.prototype properties (jQuery #13807) 1661*7f2fe78bSCy Schubert val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ? 1662*7f2fe78bSCy Schubert fn( elem, name, !documentIsHTML ) : 1663*7f2fe78bSCy Schubert undefined; 1664*7f2fe78bSCy Schubert 1665*7f2fe78bSCy Schubert return val !== undefined ? 1666*7f2fe78bSCy Schubert val : 1667*7f2fe78bSCy Schubert support.attributes || !documentIsHTML ? 1668*7f2fe78bSCy Schubert elem.getAttribute( name ) : 1669*7f2fe78bSCy Schubert ( val = elem.getAttributeNode( name ) ) && val.specified ? 1670*7f2fe78bSCy Schubert val.value : 1671*7f2fe78bSCy Schubert null; 1672*7f2fe78bSCy Schubert}; 1673*7f2fe78bSCy Schubert 1674*7f2fe78bSCy SchubertSizzle.escape = function( sel ) { 1675*7f2fe78bSCy Schubert return ( sel + "" ).replace( rcssescape, fcssescape ); 1676*7f2fe78bSCy Schubert}; 1677*7f2fe78bSCy Schubert 1678*7f2fe78bSCy SchubertSizzle.error = function( msg ) { 1679*7f2fe78bSCy Schubert throw new Error( "Syntax error, unrecognized expression: " + msg ); 1680*7f2fe78bSCy Schubert}; 1681*7f2fe78bSCy Schubert 1682*7f2fe78bSCy Schubert/** 1683*7f2fe78bSCy Schubert * Document sorting and removing duplicates 1684*7f2fe78bSCy Schubert * @param {ArrayLike} results 1685*7f2fe78bSCy Schubert */ 1686*7f2fe78bSCy SchubertSizzle.uniqueSort = function( results ) { 1687*7f2fe78bSCy Schubert var elem, 1688*7f2fe78bSCy Schubert duplicates = [], 1689*7f2fe78bSCy Schubert j = 0, 1690*7f2fe78bSCy Schubert i = 0; 1691*7f2fe78bSCy Schubert 1692*7f2fe78bSCy Schubert // Unless we *know* we can detect duplicates, assume their presence 1693*7f2fe78bSCy Schubert hasDuplicate = !support.detectDuplicates; 1694*7f2fe78bSCy Schubert sortInput = !support.sortStable && results.slice( 0 ); 1695*7f2fe78bSCy Schubert results.sort( sortOrder ); 1696*7f2fe78bSCy Schubert 1697*7f2fe78bSCy Schubert if ( hasDuplicate ) { 1698*7f2fe78bSCy Schubert while ( ( elem = results[ i++ ] ) ) { 1699*7f2fe78bSCy Schubert if ( elem === results[ i ] ) { 1700*7f2fe78bSCy Schubert j = duplicates.push( i ); 1701*7f2fe78bSCy Schubert } 1702*7f2fe78bSCy Schubert } 1703*7f2fe78bSCy Schubert while ( j-- ) { 1704*7f2fe78bSCy Schubert results.splice( duplicates[ j ], 1 ); 1705*7f2fe78bSCy Schubert } 1706*7f2fe78bSCy Schubert } 1707*7f2fe78bSCy Schubert 1708*7f2fe78bSCy Schubert // Clear input after sorting to release objects 1709*7f2fe78bSCy Schubert // See https://github.com/jquery/sizzle/pull/225 1710*7f2fe78bSCy Schubert sortInput = null; 1711*7f2fe78bSCy Schubert 1712*7f2fe78bSCy Schubert return results; 1713*7f2fe78bSCy Schubert}; 1714*7f2fe78bSCy Schubert 1715*7f2fe78bSCy Schubert/** 1716*7f2fe78bSCy Schubert * Utility function for retrieving the text value of an array of DOM nodes 1717*7f2fe78bSCy Schubert * @param {Array|Element} elem 1718*7f2fe78bSCy Schubert */ 1719*7f2fe78bSCy SchubertgetText = Sizzle.getText = function( elem ) { 1720*7f2fe78bSCy Schubert var node, 1721*7f2fe78bSCy Schubert ret = "", 1722*7f2fe78bSCy Schubert i = 0, 1723*7f2fe78bSCy Schubert nodeType = elem.nodeType; 1724*7f2fe78bSCy Schubert 1725*7f2fe78bSCy Schubert if ( !nodeType ) { 1726*7f2fe78bSCy Schubert 1727*7f2fe78bSCy Schubert // If no nodeType, this is expected to be an array 1728*7f2fe78bSCy Schubert while ( ( node = elem[ i++ ] ) ) { 1729*7f2fe78bSCy Schubert 1730*7f2fe78bSCy Schubert // Do not traverse comment nodes 1731*7f2fe78bSCy Schubert ret += getText( node ); 1732*7f2fe78bSCy Schubert } 1733*7f2fe78bSCy Schubert } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { 1734*7f2fe78bSCy Schubert 1735*7f2fe78bSCy Schubert // Use textContent for elements 1736*7f2fe78bSCy Schubert // innerText usage removed for consistency of new lines (jQuery #11153) 1737*7f2fe78bSCy Schubert if ( typeof elem.textContent === "string" ) { 1738*7f2fe78bSCy Schubert return elem.textContent; 1739*7f2fe78bSCy Schubert } else { 1740*7f2fe78bSCy Schubert 1741*7f2fe78bSCy Schubert // Traverse its children 1742*7f2fe78bSCy Schubert for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { 1743*7f2fe78bSCy Schubert ret += getText( elem ); 1744*7f2fe78bSCy Schubert } 1745*7f2fe78bSCy Schubert } 1746*7f2fe78bSCy Schubert } else if ( nodeType === 3 || nodeType === 4 ) { 1747*7f2fe78bSCy Schubert return elem.nodeValue; 1748*7f2fe78bSCy Schubert } 1749*7f2fe78bSCy Schubert 1750*7f2fe78bSCy Schubert // Do not include comment or processing instruction nodes 1751*7f2fe78bSCy Schubert 1752*7f2fe78bSCy Schubert return ret; 1753*7f2fe78bSCy Schubert}; 1754*7f2fe78bSCy Schubert 1755*7f2fe78bSCy SchubertExpr = Sizzle.selectors = { 1756*7f2fe78bSCy Schubert 1757*7f2fe78bSCy Schubert // Can be adjusted by the user 1758*7f2fe78bSCy Schubert cacheLength: 50, 1759*7f2fe78bSCy Schubert 1760*7f2fe78bSCy Schubert createPseudo: markFunction, 1761*7f2fe78bSCy Schubert 1762*7f2fe78bSCy Schubert match: matchExpr, 1763*7f2fe78bSCy Schubert 1764*7f2fe78bSCy Schubert attrHandle: {}, 1765*7f2fe78bSCy Schubert 1766*7f2fe78bSCy Schubert find: {}, 1767*7f2fe78bSCy Schubert 1768*7f2fe78bSCy Schubert relative: { 1769*7f2fe78bSCy Schubert ">": { dir: "parentNode", first: true }, 1770*7f2fe78bSCy Schubert " ": { dir: "parentNode" }, 1771*7f2fe78bSCy Schubert "+": { dir: "previousSibling", first: true }, 1772*7f2fe78bSCy Schubert "~": { dir: "previousSibling" } 1773*7f2fe78bSCy Schubert }, 1774*7f2fe78bSCy Schubert 1775*7f2fe78bSCy Schubert preFilter: { 1776*7f2fe78bSCy Schubert "ATTR": function( match ) { 1777*7f2fe78bSCy Schubert match[ 1 ] = match[ 1 ].replace( runescape, funescape ); 1778*7f2fe78bSCy Schubert 1779*7f2fe78bSCy Schubert // Move the given value to match[3] whether quoted or unquoted 1780*7f2fe78bSCy Schubert match[ 3 ] = ( match[ 3 ] || match[ 4 ] || 1781*7f2fe78bSCy Schubert match[ 5 ] || "" ).replace( runescape, funescape ); 1782*7f2fe78bSCy Schubert 1783*7f2fe78bSCy Schubert if ( match[ 2 ] === "~=" ) { 1784*7f2fe78bSCy Schubert match[ 3 ] = " " + match[ 3 ] + " "; 1785*7f2fe78bSCy Schubert } 1786*7f2fe78bSCy Schubert 1787*7f2fe78bSCy Schubert return match.slice( 0, 4 ); 1788*7f2fe78bSCy Schubert }, 1789*7f2fe78bSCy Schubert 1790*7f2fe78bSCy Schubert "CHILD": function( match ) { 1791*7f2fe78bSCy Schubert 1792*7f2fe78bSCy Schubert /* matches from matchExpr["CHILD"] 1793*7f2fe78bSCy Schubert 1 type (only|nth|...) 1794*7f2fe78bSCy Schubert 2 what (child|of-type) 1795*7f2fe78bSCy Schubert 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...) 1796*7f2fe78bSCy Schubert 4 xn-component of xn+y argument ([+-]?\d*n|) 1797*7f2fe78bSCy Schubert 5 sign of xn-component 1798*7f2fe78bSCy Schubert 6 x of xn-component 1799*7f2fe78bSCy Schubert 7 sign of y-component 1800*7f2fe78bSCy Schubert 8 y of y-component 1801*7f2fe78bSCy Schubert */ 1802*7f2fe78bSCy Schubert match[ 1 ] = match[ 1 ].toLowerCase(); 1803*7f2fe78bSCy Schubert 1804*7f2fe78bSCy Schubert if ( match[ 1 ].slice( 0, 3 ) === "nth" ) { 1805*7f2fe78bSCy Schubert 1806*7f2fe78bSCy Schubert // nth-* requires argument 1807*7f2fe78bSCy Schubert if ( !match[ 3 ] ) { 1808*7f2fe78bSCy Schubert Sizzle.error( match[ 0 ] ); 1809*7f2fe78bSCy Schubert } 1810*7f2fe78bSCy Schubert 1811*7f2fe78bSCy Schubert // numeric x and y parameters for Expr.filter.CHILD 1812*7f2fe78bSCy Schubert // remember that false/true cast respectively to 0/1 1813*7f2fe78bSCy Schubert match[ 4 ] = +( match[ 4 ] ? 1814*7f2fe78bSCy Schubert match[ 5 ] + ( match[ 6 ] || 1 ) : 1815*7f2fe78bSCy Schubert 2 * ( match[ 3 ] === "even" || match[ 3 ] === "odd" ) ); 1816*7f2fe78bSCy Schubert match[ 5 ] = +( ( match[ 7 ] + match[ 8 ] ) || match[ 3 ] === "odd" ); 1817*7f2fe78bSCy Schubert 1818*7f2fe78bSCy Schubert // other types prohibit arguments 1819*7f2fe78bSCy Schubert } else if ( match[ 3 ] ) { 1820*7f2fe78bSCy Schubert Sizzle.error( match[ 0 ] ); 1821*7f2fe78bSCy Schubert } 1822*7f2fe78bSCy Schubert 1823*7f2fe78bSCy Schubert return match; 1824*7f2fe78bSCy Schubert }, 1825*7f2fe78bSCy Schubert 1826*7f2fe78bSCy Schubert "PSEUDO": function( match ) { 1827*7f2fe78bSCy Schubert var excess, 1828*7f2fe78bSCy Schubert unquoted = !match[ 6 ] && match[ 2 ]; 1829*7f2fe78bSCy Schubert 1830*7f2fe78bSCy Schubert if ( matchExpr[ "CHILD" ].test( match[ 0 ] ) ) { 1831*7f2fe78bSCy Schubert return null; 1832*7f2fe78bSCy Schubert } 1833*7f2fe78bSCy Schubert 1834*7f2fe78bSCy Schubert // Accept quoted arguments as-is 1835*7f2fe78bSCy Schubert if ( match[ 3 ] ) { 1836*7f2fe78bSCy Schubert match[ 2 ] = match[ 4 ] || match[ 5 ] || ""; 1837*7f2fe78bSCy Schubert 1838*7f2fe78bSCy Schubert // Strip excess characters from unquoted arguments 1839*7f2fe78bSCy Schubert } else if ( unquoted && rpseudo.test( unquoted ) && 1840*7f2fe78bSCy Schubert 1841*7f2fe78bSCy Schubert // Get excess from tokenize (recursively) 1842*7f2fe78bSCy Schubert ( excess = tokenize( unquoted, true ) ) && 1843*7f2fe78bSCy Schubert 1844*7f2fe78bSCy Schubert // advance to the next closing parenthesis 1845*7f2fe78bSCy Schubert ( excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length ) ) { 1846*7f2fe78bSCy Schubert 1847*7f2fe78bSCy Schubert // excess is a negative index 1848*7f2fe78bSCy Schubert match[ 0 ] = match[ 0 ].slice( 0, excess ); 1849*7f2fe78bSCy Schubert match[ 2 ] = unquoted.slice( 0, excess ); 1850*7f2fe78bSCy Schubert } 1851*7f2fe78bSCy Schubert 1852*7f2fe78bSCy Schubert // Return only captures needed by the pseudo filter method (type and argument) 1853*7f2fe78bSCy Schubert return match.slice( 0, 3 ); 1854*7f2fe78bSCy Schubert } 1855*7f2fe78bSCy Schubert }, 1856*7f2fe78bSCy Schubert 1857*7f2fe78bSCy Schubert filter: { 1858*7f2fe78bSCy Schubert 1859*7f2fe78bSCy Schubert "TAG": function( nodeNameSelector ) { 1860*7f2fe78bSCy Schubert var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase(); 1861*7f2fe78bSCy Schubert return nodeNameSelector === "*" ? 1862*7f2fe78bSCy Schubert function() { 1863*7f2fe78bSCy Schubert return true; 1864*7f2fe78bSCy Schubert } : 1865*7f2fe78bSCy Schubert function( elem ) { 1866*7f2fe78bSCy Schubert return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; 1867*7f2fe78bSCy Schubert }; 1868*7f2fe78bSCy Schubert }, 1869*7f2fe78bSCy Schubert 1870*7f2fe78bSCy Schubert "CLASS": function( className ) { 1871*7f2fe78bSCy Schubert var pattern = classCache[ className + " " ]; 1872*7f2fe78bSCy Schubert 1873*7f2fe78bSCy Schubert return pattern || 1874*7f2fe78bSCy Schubert ( pattern = new RegExp( "(^|" + whitespace + 1875*7f2fe78bSCy Schubert ")" + className + "(" + whitespace + "|$)" ) ) && classCache( 1876*7f2fe78bSCy Schubert className, function( elem ) { 1877*7f2fe78bSCy Schubert return pattern.test( 1878*7f2fe78bSCy Schubert typeof elem.className === "string" && elem.className || 1879*7f2fe78bSCy Schubert typeof elem.getAttribute !== "undefined" && 1880*7f2fe78bSCy Schubert elem.getAttribute( "class" ) || 1881*7f2fe78bSCy Schubert "" 1882*7f2fe78bSCy Schubert ); 1883*7f2fe78bSCy Schubert } ); 1884*7f2fe78bSCy Schubert }, 1885*7f2fe78bSCy Schubert 1886*7f2fe78bSCy Schubert "ATTR": function( name, operator, check ) { 1887*7f2fe78bSCy Schubert return function( elem ) { 1888*7f2fe78bSCy Schubert var result = Sizzle.attr( elem, name ); 1889*7f2fe78bSCy Schubert 1890*7f2fe78bSCy Schubert if ( result == null ) { 1891*7f2fe78bSCy Schubert return operator === "!="; 1892*7f2fe78bSCy Schubert } 1893*7f2fe78bSCy Schubert if ( !operator ) { 1894*7f2fe78bSCy Schubert return true; 1895*7f2fe78bSCy Schubert } 1896*7f2fe78bSCy Schubert 1897*7f2fe78bSCy Schubert result += ""; 1898*7f2fe78bSCy Schubert 1899*7f2fe78bSCy Schubert /* eslint-disable max-len */ 1900*7f2fe78bSCy Schubert 1901*7f2fe78bSCy Schubert return operator === "=" ? result === check : 1902*7f2fe78bSCy Schubert operator === "!=" ? result !== check : 1903*7f2fe78bSCy Schubert operator === "^=" ? check && result.indexOf( check ) === 0 : 1904*7f2fe78bSCy Schubert operator === "*=" ? check && result.indexOf( check ) > -1 : 1905*7f2fe78bSCy Schubert operator === "$=" ? check && result.slice( -check.length ) === check : 1906*7f2fe78bSCy Schubert operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 : 1907*7f2fe78bSCy Schubert operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" : 1908*7f2fe78bSCy Schubert false; 1909*7f2fe78bSCy Schubert /* eslint-enable max-len */ 1910*7f2fe78bSCy Schubert 1911*7f2fe78bSCy Schubert }; 1912*7f2fe78bSCy Schubert }, 1913*7f2fe78bSCy Schubert 1914*7f2fe78bSCy Schubert "CHILD": function( type, what, _argument, first, last ) { 1915*7f2fe78bSCy Schubert var simple = type.slice( 0, 3 ) !== "nth", 1916*7f2fe78bSCy Schubert forward = type.slice( -4 ) !== "last", 1917*7f2fe78bSCy Schubert ofType = what === "of-type"; 1918*7f2fe78bSCy Schubert 1919*7f2fe78bSCy Schubert return first === 1 && last === 0 ? 1920*7f2fe78bSCy Schubert 1921*7f2fe78bSCy Schubert // Shortcut for :nth-*(n) 1922*7f2fe78bSCy Schubert function( elem ) { 1923*7f2fe78bSCy Schubert return !!elem.parentNode; 1924*7f2fe78bSCy Schubert } : 1925*7f2fe78bSCy Schubert 1926*7f2fe78bSCy Schubert function( elem, _context, xml ) { 1927*7f2fe78bSCy Schubert var cache, uniqueCache, outerCache, node, nodeIndex, start, 1928*7f2fe78bSCy Schubert dir = simple !== forward ? "nextSibling" : "previousSibling", 1929*7f2fe78bSCy Schubert parent = elem.parentNode, 1930*7f2fe78bSCy Schubert name = ofType && elem.nodeName.toLowerCase(), 1931*7f2fe78bSCy Schubert useCache = !xml && !ofType, 1932*7f2fe78bSCy Schubert diff = false; 1933*7f2fe78bSCy Schubert 1934*7f2fe78bSCy Schubert if ( parent ) { 1935*7f2fe78bSCy Schubert 1936*7f2fe78bSCy Schubert // :(first|last|only)-(child|of-type) 1937*7f2fe78bSCy Schubert if ( simple ) { 1938*7f2fe78bSCy Schubert while ( dir ) { 1939*7f2fe78bSCy Schubert node = elem; 1940*7f2fe78bSCy Schubert while ( ( node = node[ dir ] ) ) { 1941*7f2fe78bSCy Schubert if ( ofType ? 1942*7f2fe78bSCy Schubert node.nodeName.toLowerCase() === name : 1943*7f2fe78bSCy Schubert node.nodeType === 1 ) { 1944*7f2fe78bSCy Schubert 1945*7f2fe78bSCy Schubert return false; 1946*7f2fe78bSCy Schubert } 1947*7f2fe78bSCy Schubert } 1948*7f2fe78bSCy Schubert 1949*7f2fe78bSCy Schubert // Reverse direction for :only-* (if we haven't yet done so) 1950*7f2fe78bSCy Schubert start = dir = type === "only" && !start && "nextSibling"; 1951*7f2fe78bSCy Schubert } 1952*7f2fe78bSCy Schubert return true; 1953*7f2fe78bSCy Schubert } 1954*7f2fe78bSCy Schubert 1955*7f2fe78bSCy Schubert start = [ forward ? parent.firstChild : parent.lastChild ]; 1956*7f2fe78bSCy Schubert 1957*7f2fe78bSCy Schubert // non-xml :nth-child(...) stores cache data on `parent` 1958*7f2fe78bSCy Schubert if ( forward && useCache ) { 1959*7f2fe78bSCy Schubert 1960*7f2fe78bSCy Schubert // Seek `elem` from a previously-cached index 1961*7f2fe78bSCy Schubert 1962*7f2fe78bSCy Schubert // ...in a gzip-friendly way 1963*7f2fe78bSCy Schubert node = parent; 1964*7f2fe78bSCy Schubert outerCache = node[ expando ] || ( node[ expando ] = {} ); 1965*7f2fe78bSCy Schubert 1966*7f2fe78bSCy Schubert // Support: IE <9 only 1967*7f2fe78bSCy Schubert // Defend against cloned attroperties (jQuery gh-1709) 1968*7f2fe78bSCy Schubert uniqueCache = outerCache[ node.uniqueID ] || 1969*7f2fe78bSCy Schubert ( outerCache[ node.uniqueID ] = {} ); 1970*7f2fe78bSCy Schubert 1971*7f2fe78bSCy Schubert cache = uniqueCache[ type ] || []; 1972*7f2fe78bSCy Schubert nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; 1973*7f2fe78bSCy Schubert diff = nodeIndex && cache[ 2 ]; 1974*7f2fe78bSCy Schubert node = nodeIndex && parent.childNodes[ nodeIndex ]; 1975*7f2fe78bSCy Schubert 1976*7f2fe78bSCy Schubert while ( ( node = ++nodeIndex && node && node[ dir ] || 1977*7f2fe78bSCy Schubert 1978*7f2fe78bSCy Schubert // Fallback to seeking `elem` from the start 1979*7f2fe78bSCy Schubert ( diff = nodeIndex = 0 ) || start.pop() ) ) { 1980*7f2fe78bSCy Schubert 1981*7f2fe78bSCy Schubert // When found, cache indexes on `parent` and break 1982*7f2fe78bSCy Schubert if ( node.nodeType === 1 && ++diff && node === elem ) { 1983*7f2fe78bSCy Schubert uniqueCache[ type ] = [ dirruns, nodeIndex, diff ]; 1984*7f2fe78bSCy Schubert break; 1985*7f2fe78bSCy Schubert } 1986*7f2fe78bSCy Schubert } 1987*7f2fe78bSCy Schubert 1988*7f2fe78bSCy Schubert } else { 1989*7f2fe78bSCy Schubert 1990*7f2fe78bSCy Schubert // Use previously-cached element index if available 1991*7f2fe78bSCy Schubert if ( useCache ) { 1992*7f2fe78bSCy Schubert 1993*7f2fe78bSCy Schubert // ...in a gzip-friendly way 1994*7f2fe78bSCy Schubert node = elem; 1995*7f2fe78bSCy Schubert outerCache = node[ expando ] || ( node[ expando ] = {} ); 1996*7f2fe78bSCy Schubert 1997*7f2fe78bSCy Schubert // Support: IE <9 only 1998*7f2fe78bSCy Schubert // Defend against cloned attroperties (jQuery gh-1709) 1999*7f2fe78bSCy Schubert uniqueCache = outerCache[ node.uniqueID ] || 2000*7f2fe78bSCy Schubert ( outerCache[ node.uniqueID ] = {} ); 2001*7f2fe78bSCy Schubert 2002*7f2fe78bSCy Schubert cache = uniqueCache[ type ] || []; 2003*7f2fe78bSCy Schubert nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; 2004*7f2fe78bSCy Schubert diff = nodeIndex; 2005*7f2fe78bSCy Schubert } 2006*7f2fe78bSCy Schubert 2007*7f2fe78bSCy Schubert // xml :nth-child(...) 2008*7f2fe78bSCy Schubert // or :nth-last-child(...) or :nth(-last)?-of-type(...) 2009*7f2fe78bSCy Schubert if ( diff === false ) { 2010*7f2fe78bSCy Schubert 2011*7f2fe78bSCy Schubert // Use the same loop as above to seek `elem` from the start 2012*7f2fe78bSCy Schubert while ( ( node = ++nodeIndex && node && node[ dir ] || 2013*7f2fe78bSCy Schubert ( diff = nodeIndex = 0 ) || start.pop() ) ) { 2014*7f2fe78bSCy Schubert 2015*7f2fe78bSCy Schubert if ( ( ofType ? 2016*7f2fe78bSCy Schubert node.nodeName.toLowerCase() === name : 2017*7f2fe78bSCy Schubert node.nodeType === 1 ) && 2018*7f2fe78bSCy Schubert ++diff ) { 2019*7f2fe78bSCy Schubert 2020*7f2fe78bSCy Schubert // Cache the index of each encountered element 2021*7f2fe78bSCy Schubert if ( useCache ) { 2022*7f2fe78bSCy Schubert outerCache = node[ expando ] || 2023*7f2fe78bSCy Schubert ( node[ expando ] = {} ); 2024*7f2fe78bSCy Schubert 2025*7f2fe78bSCy Schubert // Support: IE <9 only 2026*7f2fe78bSCy Schubert // Defend against cloned attroperties (jQuery gh-1709) 2027*7f2fe78bSCy Schubert uniqueCache = outerCache[ node.uniqueID ] || 2028*7f2fe78bSCy Schubert ( outerCache[ node.uniqueID ] = {} ); 2029*7f2fe78bSCy Schubert 2030*7f2fe78bSCy Schubert uniqueCache[ type ] = [ dirruns, diff ]; 2031*7f2fe78bSCy Schubert } 2032*7f2fe78bSCy Schubert 2033*7f2fe78bSCy Schubert if ( node === elem ) { 2034*7f2fe78bSCy Schubert break; 2035*7f2fe78bSCy Schubert } 2036*7f2fe78bSCy Schubert } 2037*7f2fe78bSCy Schubert } 2038*7f2fe78bSCy Schubert } 2039*7f2fe78bSCy Schubert } 2040*7f2fe78bSCy Schubert 2041*7f2fe78bSCy Schubert // Incorporate the offset, then check against cycle size 2042*7f2fe78bSCy Schubert diff -= last; 2043*7f2fe78bSCy Schubert return diff === first || ( diff % first === 0 && diff / first >= 0 ); 2044*7f2fe78bSCy Schubert } 2045*7f2fe78bSCy Schubert }; 2046*7f2fe78bSCy Schubert }, 2047*7f2fe78bSCy Schubert 2048*7f2fe78bSCy Schubert "PSEUDO": function( pseudo, argument ) { 2049*7f2fe78bSCy Schubert 2050*7f2fe78bSCy Schubert // pseudo-class names are case-insensitive 2051*7f2fe78bSCy Schubert // http://www.w3.org/TR/selectors/#pseudo-classes 2052*7f2fe78bSCy Schubert // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters 2053*7f2fe78bSCy Schubert // Remember that setFilters inherits from pseudos 2054*7f2fe78bSCy Schubert var args, 2055*7f2fe78bSCy Schubert fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] || 2056*7f2fe78bSCy Schubert Sizzle.error( "unsupported pseudo: " + pseudo ); 2057*7f2fe78bSCy Schubert 2058*7f2fe78bSCy Schubert // The user may use createPseudo to indicate that 2059*7f2fe78bSCy Schubert // arguments are needed to create the filter function 2060*7f2fe78bSCy Schubert // just as Sizzle does 2061*7f2fe78bSCy Schubert if ( fn[ expando ] ) { 2062*7f2fe78bSCy Schubert return fn( argument ); 2063*7f2fe78bSCy Schubert } 2064*7f2fe78bSCy Schubert 2065*7f2fe78bSCy Schubert // But maintain support for old signatures 2066*7f2fe78bSCy Schubert if ( fn.length > 1 ) { 2067*7f2fe78bSCy Schubert args = [ pseudo, pseudo, "", argument ]; 2068*7f2fe78bSCy Schubert return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ? 2069*7f2fe78bSCy Schubert markFunction( function( seed, matches ) { 2070*7f2fe78bSCy Schubert var idx, 2071*7f2fe78bSCy Schubert matched = fn( seed, argument ), 2072*7f2fe78bSCy Schubert i = matched.length; 2073*7f2fe78bSCy Schubert while ( i-- ) { 2074*7f2fe78bSCy Schubert idx = indexOf( seed, matched[ i ] ); 2075*7f2fe78bSCy Schubert seed[ idx ] = !( matches[ idx ] = matched[ i ] ); 2076*7f2fe78bSCy Schubert } 2077*7f2fe78bSCy Schubert } ) : 2078*7f2fe78bSCy Schubert function( elem ) { 2079*7f2fe78bSCy Schubert return fn( elem, 0, args ); 2080*7f2fe78bSCy Schubert }; 2081*7f2fe78bSCy Schubert } 2082*7f2fe78bSCy Schubert 2083*7f2fe78bSCy Schubert return fn; 2084*7f2fe78bSCy Schubert } 2085*7f2fe78bSCy Schubert }, 2086*7f2fe78bSCy Schubert 2087*7f2fe78bSCy Schubert pseudos: { 2088*7f2fe78bSCy Schubert 2089*7f2fe78bSCy Schubert // Potentially complex pseudos 2090*7f2fe78bSCy Schubert "not": markFunction( function( selector ) { 2091*7f2fe78bSCy Schubert 2092*7f2fe78bSCy Schubert // Trim the selector passed to compile 2093*7f2fe78bSCy Schubert // to avoid treating leading and trailing 2094*7f2fe78bSCy Schubert // spaces as combinators 2095*7f2fe78bSCy Schubert var input = [], 2096*7f2fe78bSCy Schubert results = [], 2097*7f2fe78bSCy Schubert matcher = compile( selector.replace( rtrim, "$1" ) ); 2098*7f2fe78bSCy Schubert 2099*7f2fe78bSCy Schubert return matcher[ expando ] ? 2100*7f2fe78bSCy Schubert markFunction( function( seed, matches, _context, xml ) { 2101*7f2fe78bSCy Schubert var elem, 2102*7f2fe78bSCy Schubert unmatched = matcher( seed, null, xml, [] ), 2103*7f2fe78bSCy Schubert i = seed.length; 2104*7f2fe78bSCy Schubert 2105*7f2fe78bSCy Schubert // Match elements unmatched by `matcher` 2106*7f2fe78bSCy Schubert while ( i-- ) { 2107*7f2fe78bSCy Schubert if ( ( elem = unmatched[ i ] ) ) { 2108*7f2fe78bSCy Schubert seed[ i ] = !( matches[ i ] = elem ); 2109*7f2fe78bSCy Schubert } 2110*7f2fe78bSCy Schubert } 2111*7f2fe78bSCy Schubert } ) : 2112*7f2fe78bSCy Schubert function( elem, _context, xml ) { 2113*7f2fe78bSCy Schubert input[ 0 ] = elem; 2114*7f2fe78bSCy Schubert matcher( input, null, xml, results ); 2115*7f2fe78bSCy Schubert 2116*7f2fe78bSCy Schubert // Don't keep the element (issue #299) 2117*7f2fe78bSCy Schubert input[ 0 ] = null; 2118*7f2fe78bSCy Schubert return !results.pop(); 2119*7f2fe78bSCy Schubert }; 2120*7f2fe78bSCy Schubert } ), 2121*7f2fe78bSCy Schubert 2122*7f2fe78bSCy Schubert "has": markFunction( function( selector ) { 2123*7f2fe78bSCy Schubert return function( elem ) { 2124*7f2fe78bSCy Schubert return Sizzle( selector, elem ).length > 0; 2125*7f2fe78bSCy Schubert }; 2126*7f2fe78bSCy Schubert } ), 2127*7f2fe78bSCy Schubert 2128*7f2fe78bSCy Schubert "contains": markFunction( function( text ) { 2129*7f2fe78bSCy Schubert text = text.replace( runescape, funescape ); 2130*7f2fe78bSCy Schubert return function( elem ) { 2131*7f2fe78bSCy Schubert return ( elem.textContent || getText( elem ) ).indexOf( text ) > -1; 2132*7f2fe78bSCy Schubert }; 2133*7f2fe78bSCy Schubert } ), 2134*7f2fe78bSCy Schubert 2135*7f2fe78bSCy Schubert // "Whether an element is represented by a :lang() selector 2136*7f2fe78bSCy Schubert // is based solely on the element's language value 2137*7f2fe78bSCy Schubert // being equal to the identifier C, 2138*7f2fe78bSCy Schubert // or beginning with the identifier C immediately followed by "-". 2139*7f2fe78bSCy Schubert // The matching of C against the element's language value is performed case-insensitively. 2140*7f2fe78bSCy Schubert // The identifier C does not have to be a valid language name." 2141*7f2fe78bSCy Schubert // http://www.w3.org/TR/selectors/#lang-pseudo 2142*7f2fe78bSCy Schubert "lang": markFunction( function( lang ) { 2143*7f2fe78bSCy Schubert 2144*7f2fe78bSCy Schubert // lang value must be a valid identifier 2145*7f2fe78bSCy Schubert if ( !ridentifier.test( lang || "" ) ) { 2146*7f2fe78bSCy Schubert Sizzle.error( "unsupported lang: " + lang ); 2147*7f2fe78bSCy Schubert } 2148*7f2fe78bSCy Schubert lang = lang.replace( runescape, funescape ).toLowerCase(); 2149*7f2fe78bSCy Schubert return function( elem ) { 2150*7f2fe78bSCy Schubert var elemLang; 2151*7f2fe78bSCy Schubert do { 2152*7f2fe78bSCy Schubert if ( ( elemLang = documentIsHTML ? 2153*7f2fe78bSCy Schubert elem.lang : 2154*7f2fe78bSCy Schubert elem.getAttribute( "xml:lang" ) || elem.getAttribute( "lang" ) ) ) { 2155*7f2fe78bSCy Schubert 2156*7f2fe78bSCy Schubert elemLang = elemLang.toLowerCase(); 2157*7f2fe78bSCy Schubert return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0; 2158*7f2fe78bSCy Schubert } 2159*7f2fe78bSCy Schubert } while ( ( elem = elem.parentNode ) && elem.nodeType === 1 ); 2160*7f2fe78bSCy Schubert return false; 2161*7f2fe78bSCy Schubert }; 2162*7f2fe78bSCy Schubert } ), 2163*7f2fe78bSCy Schubert 2164*7f2fe78bSCy Schubert // Miscellaneous 2165*7f2fe78bSCy Schubert "target": function( elem ) { 2166*7f2fe78bSCy Schubert var hash = window.location && window.location.hash; 2167*7f2fe78bSCy Schubert return hash && hash.slice( 1 ) === elem.id; 2168*7f2fe78bSCy Schubert }, 2169*7f2fe78bSCy Schubert 2170*7f2fe78bSCy Schubert "root": function( elem ) { 2171*7f2fe78bSCy Schubert return elem === docElem; 2172*7f2fe78bSCy Schubert }, 2173*7f2fe78bSCy Schubert 2174*7f2fe78bSCy Schubert "focus": function( elem ) { 2175*7f2fe78bSCy Schubert return elem === document.activeElement && 2176*7f2fe78bSCy Schubert ( !document.hasFocus || document.hasFocus() ) && 2177*7f2fe78bSCy Schubert !!( elem.type || elem.href || ~elem.tabIndex ); 2178*7f2fe78bSCy Schubert }, 2179*7f2fe78bSCy Schubert 2180*7f2fe78bSCy Schubert // Boolean properties 2181*7f2fe78bSCy Schubert "enabled": createDisabledPseudo( false ), 2182*7f2fe78bSCy Schubert "disabled": createDisabledPseudo( true ), 2183*7f2fe78bSCy Schubert 2184*7f2fe78bSCy Schubert "checked": function( elem ) { 2185*7f2fe78bSCy Schubert 2186*7f2fe78bSCy Schubert // In CSS3, :checked should return both checked and selected elements 2187*7f2fe78bSCy Schubert // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked 2188*7f2fe78bSCy Schubert var nodeName = elem.nodeName.toLowerCase(); 2189*7f2fe78bSCy Schubert return ( nodeName === "input" && !!elem.checked ) || 2190*7f2fe78bSCy Schubert ( nodeName === "option" && !!elem.selected ); 2191*7f2fe78bSCy Schubert }, 2192*7f2fe78bSCy Schubert 2193*7f2fe78bSCy Schubert "selected": function( elem ) { 2194*7f2fe78bSCy Schubert 2195*7f2fe78bSCy Schubert // Accessing this property makes selected-by-default 2196*7f2fe78bSCy Schubert // options in Safari work properly 2197*7f2fe78bSCy Schubert if ( elem.parentNode ) { 2198*7f2fe78bSCy Schubert // eslint-disable-next-line no-unused-expressions 2199*7f2fe78bSCy Schubert elem.parentNode.selectedIndex; 2200*7f2fe78bSCy Schubert } 2201*7f2fe78bSCy Schubert 2202*7f2fe78bSCy Schubert return elem.selected === true; 2203*7f2fe78bSCy Schubert }, 2204*7f2fe78bSCy Schubert 2205*7f2fe78bSCy Schubert // Contents 2206*7f2fe78bSCy Schubert "empty": function( elem ) { 2207*7f2fe78bSCy Schubert 2208*7f2fe78bSCy Schubert // http://www.w3.org/TR/selectors/#empty-pseudo 2209*7f2fe78bSCy Schubert // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5), 2210*7f2fe78bSCy Schubert // but not by others (comment: 8; processing instruction: 7; etc.) 2211*7f2fe78bSCy Schubert // nodeType < 6 works because attributes (2) do not appear as children 2212*7f2fe78bSCy Schubert for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { 2213*7f2fe78bSCy Schubert if ( elem.nodeType < 6 ) { 2214*7f2fe78bSCy Schubert return false; 2215*7f2fe78bSCy Schubert } 2216*7f2fe78bSCy Schubert } 2217*7f2fe78bSCy Schubert return true; 2218*7f2fe78bSCy Schubert }, 2219*7f2fe78bSCy Schubert 2220*7f2fe78bSCy Schubert "parent": function( elem ) { 2221*7f2fe78bSCy Schubert return !Expr.pseudos[ "empty" ]( elem ); 2222*7f2fe78bSCy Schubert }, 2223*7f2fe78bSCy Schubert 2224*7f2fe78bSCy Schubert // Element/input types 2225*7f2fe78bSCy Schubert "header": function( elem ) { 2226*7f2fe78bSCy Schubert return rheader.test( elem.nodeName ); 2227*7f2fe78bSCy Schubert }, 2228*7f2fe78bSCy Schubert 2229*7f2fe78bSCy Schubert "input": function( elem ) { 2230*7f2fe78bSCy Schubert return rinputs.test( elem.nodeName ); 2231*7f2fe78bSCy Schubert }, 2232*7f2fe78bSCy Schubert 2233*7f2fe78bSCy Schubert "button": function( elem ) { 2234*7f2fe78bSCy Schubert var name = elem.nodeName.toLowerCase(); 2235*7f2fe78bSCy Schubert return name === "input" && elem.type === "button" || name === "button"; 2236*7f2fe78bSCy Schubert }, 2237*7f2fe78bSCy Schubert 2238*7f2fe78bSCy Schubert "text": function( elem ) { 2239*7f2fe78bSCy Schubert var attr; 2240*7f2fe78bSCy Schubert return elem.nodeName.toLowerCase() === "input" && 2241*7f2fe78bSCy Schubert elem.type === "text" && 2242*7f2fe78bSCy Schubert 2243*7f2fe78bSCy Schubert // Support: IE<8 2244*7f2fe78bSCy Schubert // New HTML5 attribute values (e.g., "search") appear with elem.type === "text" 2245*7f2fe78bSCy Schubert ( ( attr = elem.getAttribute( "type" ) ) == null || 2246*7f2fe78bSCy Schubert attr.toLowerCase() === "text" ); 2247*7f2fe78bSCy Schubert }, 2248*7f2fe78bSCy Schubert 2249*7f2fe78bSCy Schubert // Position-in-collection 2250*7f2fe78bSCy Schubert "first": createPositionalPseudo( function() { 2251*7f2fe78bSCy Schubert return [ 0 ]; 2252*7f2fe78bSCy Schubert } ), 2253*7f2fe78bSCy Schubert 2254*7f2fe78bSCy Schubert "last": createPositionalPseudo( function( _matchIndexes, length ) { 2255*7f2fe78bSCy Schubert return [ length - 1 ]; 2256*7f2fe78bSCy Schubert } ), 2257*7f2fe78bSCy Schubert 2258*7f2fe78bSCy Schubert "eq": createPositionalPseudo( function( _matchIndexes, length, argument ) { 2259*7f2fe78bSCy Schubert return [ argument < 0 ? argument + length : argument ]; 2260*7f2fe78bSCy Schubert } ), 2261*7f2fe78bSCy Schubert 2262*7f2fe78bSCy Schubert "even": createPositionalPseudo( function( matchIndexes, length ) { 2263*7f2fe78bSCy Schubert var i = 0; 2264*7f2fe78bSCy Schubert for ( ; i < length; i += 2 ) { 2265*7f2fe78bSCy Schubert matchIndexes.push( i ); 2266*7f2fe78bSCy Schubert } 2267*7f2fe78bSCy Schubert return matchIndexes; 2268*7f2fe78bSCy Schubert } ), 2269*7f2fe78bSCy Schubert 2270*7f2fe78bSCy Schubert "odd": createPositionalPseudo( function( matchIndexes, length ) { 2271*7f2fe78bSCy Schubert var i = 1; 2272*7f2fe78bSCy Schubert for ( ; i < length; i += 2 ) { 2273*7f2fe78bSCy Schubert matchIndexes.push( i ); 2274*7f2fe78bSCy Schubert } 2275*7f2fe78bSCy Schubert return matchIndexes; 2276*7f2fe78bSCy Schubert } ), 2277*7f2fe78bSCy Schubert 2278*7f2fe78bSCy Schubert "lt": createPositionalPseudo( function( matchIndexes, length, argument ) { 2279*7f2fe78bSCy Schubert var i = argument < 0 ? 2280*7f2fe78bSCy Schubert argument + length : 2281*7f2fe78bSCy Schubert argument > length ? 2282*7f2fe78bSCy Schubert length : 2283*7f2fe78bSCy Schubert argument; 2284*7f2fe78bSCy Schubert for ( ; --i >= 0; ) { 2285*7f2fe78bSCy Schubert matchIndexes.push( i ); 2286*7f2fe78bSCy Schubert } 2287*7f2fe78bSCy Schubert return matchIndexes; 2288*7f2fe78bSCy Schubert } ), 2289*7f2fe78bSCy Schubert 2290*7f2fe78bSCy Schubert "gt": createPositionalPseudo( function( matchIndexes, length, argument ) { 2291*7f2fe78bSCy Schubert var i = argument < 0 ? argument + length : argument; 2292*7f2fe78bSCy Schubert for ( ; ++i < length; ) { 2293*7f2fe78bSCy Schubert matchIndexes.push( i ); 2294*7f2fe78bSCy Schubert } 2295*7f2fe78bSCy Schubert return matchIndexes; 2296*7f2fe78bSCy Schubert } ) 2297*7f2fe78bSCy Schubert } 2298*7f2fe78bSCy Schubert}; 2299*7f2fe78bSCy Schubert 2300*7f2fe78bSCy SchubertExpr.pseudos[ "nth" ] = Expr.pseudos[ "eq" ]; 2301*7f2fe78bSCy Schubert 2302*7f2fe78bSCy Schubert// Add button/input type pseudos 2303*7f2fe78bSCy Schubertfor ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) { 2304*7f2fe78bSCy Schubert Expr.pseudos[ i ] = createInputPseudo( i ); 2305*7f2fe78bSCy Schubert} 2306*7f2fe78bSCy Schubertfor ( i in { submit: true, reset: true } ) { 2307*7f2fe78bSCy Schubert Expr.pseudos[ i ] = createButtonPseudo( i ); 2308*7f2fe78bSCy Schubert} 2309*7f2fe78bSCy Schubert 2310*7f2fe78bSCy Schubert// Easy API for creating new setFilters 2311*7f2fe78bSCy Schubertfunction setFilters() {} 2312*7f2fe78bSCy SchubertsetFilters.prototype = Expr.filters = Expr.pseudos; 2313*7f2fe78bSCy SchubertExpr.setFilters = new setFilters(); 2314*7f2fe78bSCy Schubert 2315*7f2fe78bSCy Schuberttokenize = Sizzle.tokenize = function( selector, parseOnly ) { 2316*7f2fe78bSCy Schubert var matched, match, tokens, type, 2317*7f2fe78bSCy Schubert soFar, groups, preFilters, 2318*7f2fe78bSCy Schubert cached = tokenCache[ selector + " " ]; 2319*7f2fe78bSCy Schubert 2320*7f2fe78bSCy Schubert if ( cached ) { 2321*7f2fe78bSCy Schubert return parseOnly ? 0 : cached.slice( 0 ); 2322*7f2fe78bSCy Schubert } 2323*7f2fe78bSCy Schubert 2324*7f2fe78bSCy Schubert soFar = selector; 2325*7f2fe78bSCy Schubert groups = []; 2326*7f2fe78bSCy Schubert preFilters = Expr.preFilter; 2327*7f2fe78bSCy Schubert 2328*7f2fe78bSCy Schubert while ( soFar ) { 2329*7f2fe78bSCy Schubert 2330*7f2fe78bSCy Schubert // Comma and first run 2331*7f2fe78bSCy Schubert if ( !matched || ( match = rcomma.exec( soFar ) ) ) { 2332*7f2fe78bSCy Schubert if ( match ) { 2333*7f2fe78bSCy Schubert 2334*7f2fe78bSCy Schubert // Don't consume trailing commas as valid 2335*7f2fe78bSCy Schubert soFar = soFar.slice( match[ 0 ].length ) || soFar; 2336*7f2fe78bSCy Schubert } 2337*7f2fe78bSCy Schubert groups.push( ( tokens = [] ) ); 2338*7f2fe78bSCy Schubert } 2339*7f2fe78bSCy Schubert 2340*7f2fe78bSCy Schubert matched = false; 2341*7f2fe78bSCy Schubert 2342*7f2fe78bSCy Schubert // Combinators 2343*7f2fe78bSCy Schubert if ( ( match = rcombinators.exec( soFar ) ) ) { 2344*7f2fe78bSCy Schubert matched = match.shift(); 2345*7f2fe78bSCy Schubert tokens.push( { 2346*7f2fe78bSCy Schubert value: matched, 2347*7f2fe78bSCy Schubert 2348*7f2fe78bSCy Schubert // Cast descendant combinators to space 2349*7f2fe78bSCy Schubert type: match[ 0 ].replace( rtrim, " " ) 2350*7f2fe78bSCy Schubert } ); 2351*7f2fe78bSCy Schubert soFar = soFar.slice( matched.length ); 2352*7f2fe78bSCy Schubert } 2353*7f2fe78bSCy Schubert 2354*7f2fe78bSCy Schubert // Filters 2355*7f2fe78bSCy Schubert for ( type in Expr.filter ) { 2356*7f2fe78bSCy Schubert if ( ( match = matchExpr[ type ].exec( soFar ) ) && ( !preFilters[ type ] || 2357*7f2fe78bSCy Schubert ( match = preFilters[ type ]( match ) ) ) ) { 2358*7f2fe78bSCy Schubert matched = match.shift(); 2359*7f2fe78bSCy Schubert tokens.push( { 2360*7f2fe78bSCy Schubert value: matched, 2361*7f2fe78bSCy Schubert type: type, 2362*7f2fe78bSCy Schubert matches: match 2363*7f2fe78bSCy Schubert } ); 2364*7f2fe78bSCy Schubert soFar = soFar.slice( matched.length ); 2365*7f2fe78bSCy Schubert } 2366*7f2fe78bSCy Schubert } 2367*7f2fe78bSCy Schubert 2368*7f2fe78bSCy Schubert if ( !matched ) { 2369*7f2fe78bSCy Schubert break; 2370*7f2fe78bSCy Schubert } 2371*7f2fe78bSCy Schubert } 2372*7f2fe78bSCy Schubert 2373*7f2fe78bSCy Schubert // Return the length of the invalid excess 2374*7f2fe78bSCy Schubert // if we're just parsing 2375*7f2fe78bSCy Schubert // Otherwise, throw an error or return tokens 2376*7f2fe78bSCy Schubert return parseOnly ? 2377*7f2fe78bSCy Schubert soFar.length : 2378*7f2fe78bSCy Schubert soFar ? 2379*7f2fe78bSCy Schubert Sizzle.error( selector ) : 2380*7f2fe78bSCy Schubert 2381*7f2fe78bSCy Schubert // Cache the tokens 2382*7f2fe78bSCy Schubert tokenCache( selector, groups ).slice( 0 ); 2383*7f2fe78bSCy Schubert}; 2384*7f2fe78bSCy Schubert 2385*7f2fe78bSCy Schubertfunction toSelector( tokens ) { 2386*7f2fe78bSCy Schubert var i = 0, 2387*7f2fe78bSCy Schubert len = tokens.length, 2388*7f2fe78bSCy Schubert selector = ""; 2389*7f2fe78bSCy Schubert for ( ; i < len; i++ ) { 2390*7f2fe78bSCy Schubert selector += tokens[ i ].value; 2391*7f2fe78bSCy Schubert } 2392*7f2fe78bSCy Schubert return selector; 2393*7f2fe78bSCy Schubert} 2394*7f2fe78bSCy Schubert 2395*7f2fe78bSCy Schubertfunction addCombinator( matcher, combinator, base ) { 2396*7f2fe78bSCy Schubert var dir = combinator.dir, 2397*7f2fe78bSCy Schubert skip = combinator.next, 2398*7f2fe78bSCy Schubert key = skip || dir, 2399*7f2fe78bSCy Schubert checkNonElements = base && key === "parentNode", 2400*7f2fe78bSCy Schubert doneName = done++; 2401*7f2fe78bSCy Schubert 2402*7f2fe78bSCy Schubert return combinator.first ? 2403*7f2fe78bSCy Schubert 2404*7f2fe78bSCy Schubert // Check against closest ancestor/preceding element 2405*7f2fe78bSCy Schubert function( elem, context, xml ) { 2406*7f2fe78bSCy Schubert while ( ( elem = elem[ dir ] ) ) { 2407*7f2fe78bSCy Schubert if ( elem.nodeType === 1 || checkNonElements ) { 2408*7f2fe78bSCy Schubert return matcher( elem, context, xml ); 2409*7f2fe78bSCy Schubert } 2410*7f2fe78bSCy Schubert } 2411*7f2fe78bSCy Schubert return false; 2412*7f2fe78bSCy Schubert } : 2413*7f2fe78bSCy Schubert 2414*7f2fe78bSCy Schubert // Check against all ancestor/preceding elements 2415*7f2fe78bSCy Schubert function( elem, context, xml ) { 2416*7f2fe78bSCy Schubert var oldCache, uniqueCache, outerCache, 2417*7f2fe78bSCy Schubert newCache = [ dirruns, doneName ]; 2418*7f2fe78bSCy Schubert 2419*7f2fe78bSCy Schubert // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching 2420*7f2fe78bSCy Schubert if ( xml ) { 2421*7f2fe78bSCy Schubert while ( ( elem = elem[ dir ] ) ) { 2422*7f2fe78bSCy Schubert if ( elem.nodeType === 1 || checkNonElements ) { 2423*7f2fe78bSCy Schubert if ( matcher( elem, context, xml ) ) { 2424*7f2fe78bSCy Schubert return true; 2425*7f2fe78bSCy Schubert } 2426*7f2fe78bSCy Schubert } 2427*7f2fe78bSCy Schubert } 2428*7f2fe78bSCy Schubert } else { 2429*7f2fe78bSCy Schubert while ( ( elem = elem[ dir ] ) ) { 2430*7f2fe78bSCy Schubert if ( elem.nodeType === 1 || checkNonElements ) { 2431*7f2fe78bSCy Schubert outerCache = elem[ expando ] || ( elem[ expando ] = {} ); 2432*7f2fe78bSCy Schubert 2433*7f2fe78bSCy Schubert // Support: IE <9 only 2434*7f2fe78bSCy Schubert // Defend against cloned attroperties (jQuery gh-1709) 2435*7f2fe78bSCy Schubert uniqueCache = outerCache[ elem.uniqueID ] || 2436*7f2fe78bSCy Schubert ( outerCache[ elem.uniqueID ] = {} ); 2437*7f2fe78bSCy Schubert 2438*7f2fe78bSCy Schubert if ( skip && skip === elem.nodeName.toLowerCase() ) { 2439*7f2fe78bSCy Schubert elem = elem[ dir ] || elem; 2440*7f2fe78bSCy Schubert } else if ( ( oldCache = uniqueCache[ key ] ) && 2441*7f2fe78bSCy Schubert oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) { 2442*7f2fe78bSCy Schubert 2443*7f2fe78bSCy Schubert // Assign to newCache so results back-propagate to previous elements 2444*7f2fe78bSCy Schubert return ( newCache[ 2 ] = oldCache[ 2 ] ); 2445*7f2fe78bSCy Schubert } else { 2446*7f2fe78bSCy Schubert 2447*7f2fe78bSCy Schubert // Reuse newcache so results back-propagate to previous elements 2448*7f2fe78bSCy Schubert uniqueCache[ key ] = newCache; 2449*7f2fe78bSCy Schubert 2450*7f2fe78bSCy Schubert // A match means we're done; a fail means we have to keep checking 2451*7f2fe78bSCy Schubert if ( ( newCache[ 2 ] = matcher( elem, context, xml ) ) ) { 2452*7f2fe78bSCy Schubert return true; 2453*7f2fe78bSCy Schubert } 2454*7f2fe78bSCy Schubert } 2455*7f2fe78bSCy Schubert } 2456*7f2fe78bSCy Schubert } 2457*7f2fe78bSCy Schubert } 2458*7f2fe78bSCy Schubert return false; 2459*7f2fe78bSCy Schubert }; 2460*7f2fe78bSCy Schubert} 2461*7f2fe78bSCy Schubert 2462*7f2fe78bSCy Schubertfunction elementMatcher( matchers ) { 2463*7f2fe78bSCy Schubert return matchers.length > 1 ? 2464*7f2fe78bSCy Schubert function( elem, context, xml ) { 2465*7f2fe78bSCy Schubert var i = matchers.length; 2466*7f2fe78bSCy Schubert while ( i-- ) { 2467*7f2fe78bSCy Schubert if ( !matchers[ i ]( elem, context, xml ) ) { 2468*7f2fe78bSCy Schubert return false; 2469*7f2fe78bSCy Schubert } 2470*7f2fe78bSCy Schubert } 2471*7f2fe78bSCy Schubert return true; 2472*7f2fe78bSCy Schubert } : 2473*7f2fe78bSCy Schubert matchers[ 0 ]; 2474*7f2fe78bSCy Schubert} 2475*7f2fe78bSCy Schubert 2476*7f2fe78bSCy Schubertfunction multipleContexts( selector, contexts, results ) { 2477*7f2fe78bSCy Schubert var i = 0, 2478*7f2fe78bSCy Schubert len = contexts.length; 2479*7f2fe78bSCy Schubert for ( ; i < len; i++ ) { 2480*7f2fe78bSCy Schubert Sizzle( selector, contexts[ i ], results ); 2481*7f2fe78bSCy Schubert } 2482*7f2fe78bSCy Schubert return results; 2483*7f2fe78bSCy Schubert} 2484*7f2fe78bSCy Schubert 2485*7f2fe78bSCy Schubertfunction condense( unmatched, map, filter, context, xml ) { 2486*7f2fe78bSCy Schubert var elem, 2487*7f2fe78bSCy Schubert newUnmatched = [], 2488*7f2fe78bSCy Schubert i = 0, 2489*7f2fe78bSCy Schubert len = unmatched.length, 2490*7f2fe78bSCy Schubert mapped = map != null; 2491*7f2fe78bSCy Schubert 2492*7f2fe78bSCy Schubert for ( ; i < len; i++ ) { 2493*7f2fe78bSCy Schubert if ( ( elem = unmatched[ i ] ) ) { 2494*7f2fe78bSCy Schubert if ( !filter || filter( elem, context, xml ) ) { 2495*7f2fe78bSCy Schubert newUnmatched.push( elem ); 2496*7f2fe78bSCy Schubert if ( mapped ) { 2497*7f2fe78bSCy Schubert map.push( i ); 2498*7f2fe78bSCy Schubert } 2499*7f2fe78bSCy Schubert } 2500*7f2fe78bSCy Schubert } 2501*7f2fe78bSCy Schubert } 2502*7f2fe78bSCy Schubert 2503*7f2fe78bSCy Schubert return newUnmatched; 2504*7f2fe78bSCy Schubert} 2505*7f2fe78bSCy Schubert 2506*7f2fe78bSCy Schubertfunction setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { 2507*7f2fe78bSCy Schubert if ( postFilter && !postFilter[ expando ] ) { 2508*7f2fe78bSCy Schubert postFilter = setMatcher( postFilter ); 2509*7f2fe78bSCy Schubert } 2510*7f2fe78bSCy Schubert if ( postFinder && !postFinder[ expando ] ) { 2511*7f2fe78bSCy Schubert postFinder = setMatcher( postFinder, postSelector ); 2512*7f2fe78bSCy Schubert } 2513*7f2fe78bSCy Schubert return markFunction( function( seed, results, context, xml ) { 2514*7f2fe78bSCy Schubert var temp, i, elem, 2515*7f2fe78bSCy Schubert preMap = [], 2516*7f2fe78bSCy Schubert postMap = [], 2517*7f2fe78bSCy Schubert preexisting = results.length, 2518*7f2fe78bSCy Schubert 2519*7f2fe78bSCy Schubert // Get initial elements from seed or context 2520*7f2fe78bSCy Schubert elems = seed || multipleContexts( 2521*7f2fe78bSCy Schubert selector || "*", 2522*7f2fe78bSCy Schubert context.nodeType ? [ context ] : context, 2523*7f2fe78bSCy Schubert [] 2524*7f2fe78bSCy Schubert ), 2525*7f2fe78bSCy Schubert 2526*7f2fe78bSCy Schubert // Prefilter to get matcher input, preserving a map for seed-results synchronization 2527*7f2fe78bSCy Schubert matcherIn = preFilter && ( seed || !selector ) ? 2528*7f2fe78bSCy Schubert condense( elems, preMap, preFilter, context, xml ) : 2529*7f2fe78bSCy Schubert elems, 2530*7f2fe78bSCy Schubert 2531*7f2fe78bSCy Schubert matcherOut = matcher ? 2532*7f2fe78bSCy Schubert 2533*7f2fe78bSCy Schubert // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, 2534*7f2fe78bSCy Schubert postFinder || ( seed ? preFilter : preexisting || postFilter ) ? 2535*7f2fe78bSCy Schubert 2536*7f2fe78bSCy Schubert // ...intermediate processing is necessary 2537*7f2fe78bSCy Schubert [] : 2538*7f2fe78bSCy Schubert 2539*7f2fe78bSCy Schubert // ...otherwise use results directly 2540*7f2fe78bSCy Schubert results : 2541*7f2fe78bSCy Schubert matcherIn; 2542*7f2fe78bSCy Schubert 2543*7f2fe78bSCy Schubert // Find primary matches 2544*7f2fe78bSCy Schubert if ( matcher ) { 2545*7f2fe78bSCy Schubert matcher( matcherIn, matcherOut, context, xml ); 2546*7f2fe78bSCy Schubert } 2547*7f2fe78bSCy Schubert 2548*7f2fe78bSCy Schubert // Apply postFilter 2549*7f2fe78bSCy Schubert if ( postFilter ) { 2550*7f2fe78bSCy Schubert temp = condense( matcherOut, postMap ); 2551*7f2fe78bSCy Schubert postFilter( temp, [], context, xml ); 2552*7f2fe78bSCy Schubert 2553*7f2fe78bSCy Schubert // Un-match failing elements by moving them back to matcherIn 2554*7f2fe78bSCy Schubert i = temp.length; 2555*7f2fe78bSCy Schubert while ( i-- ) { 2556*7f2fe78bSCy Schubert if ( ( elem = temp[ i ] ) ) { 2557*7f2fe78bSCy Schubert matcherOut[ postMap[ i ] ] = !( matcherIn[ postMap[ i ] ] = elem ); 2558*7f2fe78bSCy Schubert } 2559*7f2fe78bSCy Schubert } 2560*7f2fe78bSCy Schubert } 2561*7f2fe78bSCy Schubert 2562*7f2fe78bSCy Schubert if ( seed ) { 2563*7f2fe78bSCy Schubert if ( postFinder || preFilter ) { 2564*7f2fe78bSCy Schubert if ( postFinder ) { 2565*7f2fe78bSCy Schubert 2566*7f2fe78bSCy Schubert // Get the final matcherOut by condensing this intermediate into postFinder contexts 2567*7f2fe78bSCy Schubert temp = []; 2568*7f2fe78bSCy Schubert i = matcherOut.length; 2569*7f2fe78bSCy Schubert while ( i-- ) { 2570*7f2fe78bSCy Schubert if ( ( elem = matcherOut[ i ] ) ) { 2571*7f2fe78bSCy Schubert 2572*7f2fe78bSCy Schubert // Restore matcherIn since elem is not yet a final match 2573*7f2fe78bSCy Schubert temp.push( ( matcherIn[ i ] = elem ) ); 2574*7f2fe78bSCy Schubert } 2575*7f2fe78bSCy Schubert } 2576*7f2fe78bSCy Schubert postFinder( null, ( matcherOut = [] ), temp, xml ); 2577*7f2fe78bSCy Schubert } 2578*7f2fe78bSCy Schubert 2579*7f2fe78bSCy Schubert // Move matched elements from seed to results to keep them synchronized 2580*7f2fe78bSCy Schubert i = matcherOut.length; 2581*7f2fe78bSCy Schubert while ( i-- ) { 2582*7f2fe78bSCy Schubert if ( ( elem = matcherOut[ i ] ) && 2583*7f2fe78bSCy Schubert ( temp = postFinder ? indexOf( seed, elem ) : preMap[ i ] ) > -1 ) { 2584*7f2fe78bSCy Schubert 2585*7f2fe78bSCy Schubert seed[ temp ] = !( results[ temp ] = elem ); 2586*7f2fe78bSCy Schubert } 2587*7f2fe78bSCy Schubert } 2588*7f2fe78bSCy Schubert } 2589*7f2fe78bSCy Schubert 2590*7f2fe78bSCy Schubert // Add elements to results, through postFinder if defined 2591*7f2fe78bSCy Schubert } else { 2592*7f2fe78bSCy Schubert matcherOut = condense( 2593*7f2fe78bSCy Schubert matcherOut === results ? 2594*7f2fe78bSCy Schubert matcherOut.splice( preexisting, matcherOut.length ) : 2595*7f2fe78bSCy Schubert matcherOut 2596*7f2fe78bSCy Schubert ); 2597*7f2fe78bSCy Schubert if ( postFinder ) { 2598*7f2fe78bSCy Schubert postFinder( null, results, matcherOut, xml ); 2599*7f2fe78bSCy Schubert } else { 2600*7f2fe78bSCy Schubert push.apply( results, matcherOut ); 2601*7f2fe78bSCy Schubert } 2602*7f2fe78bSCy Schubert } 2603*7f2fe78bSCy Schubert } ); 2604*7f2fe78bSCy Schubert} 2605*7f2fe78bSCy Schubert 2606*7f2fe78bSCy Schubertfunction matcherFromTokens( tokens ) { 2607*7f2fe78bSCy Schubert var checkContext, matcher, j, 2608*7f2fe78bSCy Schubert len = tokens.length, 2609*7f2fe78bSCy Schubert leadingRelative = Expr.relative[ tokens[ 0 ].type ], 2610*7f2fe78bSCy Schubert implicitRelative = leadingRelative || Expr.relative[ " " ], 2611*7f2fe78bSCy Schubert i = leadingRelative ? 1 : 0, 2612*7f2fe78bSCy Schubert 2613*7f2fe78bSCy Schubert // The foundational matcher ensures that elements are reachable from top-level context(s) 2614*7f2fe78bSCy Schubert matchContext = addCombinator( function( elem ) { 2615*7f2fe78bSCy Schubert return elem === checkContext; 2616*7f2fe78bSCy Schubert }, implicitRelative, true ), 2617*7f2fe78bSCy Schubert matchAnyContext = addCombinator( function( elem ) { 2618*7f2fe78bSCy Schubert return indexOf( checkContext, elem ) > -1; 2619*7f2fe78bSCy Schubert }, implicitRelative, true ), 2620*7f2fe78bSCy Schubert matchers = [ function( elem, context, xml ) { 2621*7f2fe78bSCy Schubert var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( 2622*7f2fe78bSCy Schubert ( checkContext = context ).nodeType ? 2623*7f2fe78bSCy Schubert matchContext( elem, context, xml ) : 2624*7f2fe78bSCy Schubert matchAnyContext( elem, context, xml ) ); 2625*7f2fe78bSCy Schubert 2626*7f2fe78bSCy Schubert // Avoid hanging onto element (issue #299) 2627*7f2fe78bSCy Schubert checkContext = null; 2628*7f2fe78bSCy Schubert return ret; 2629*7f2fe78bSCy Schubert } ]; 2630*7f2fe78bSCy Schubert 2631*7f2fe78bSCy Schubert for ( ; i < len; i++ ) { 2632*7f2fe78bSCy Schubert if ( ( matcher = Expr.relative[ tokens[ i ].type ] ) ) { 2633*7f2fe78bSCy Schubert matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ]; 2634*7f2fe78bSCy Schubert } else { 2635*7f2fe78bSCy Schubert matcher = Expr.filter[ tokens[ i ].type ].apply( null, tokens[ i ].matches ); 2636*7f2fe78bSCy Schubert 2637*7f2fe78bSCy Schubert // Return special upon seeing a positional matcher 2638*7f2fe78bSCy Schubert if ( matcher[ expando ] ) { 2639*7f2fe78bSCy Schubert 2640*7f2fe78bSCy Schubert // Find the next relative operator (if any) for proper handling 2641*7f2fe78bSCy Schubert j = ++i; 2642*7f2fe78bSCy Schubert for ( ; j < len; j++ ) { 2643*7f2fe78bSCy Schubert if ( Expr.relative[ tokens[ j ].type ] ) { 2644*7f2fe78bSCy Schubert break; 2645*7f2fe78bSCy Schubert } 2646*7f2fe78bSCy Schubert } 2647*7f2fe78bSCy Schubert return setMatcher( 2648*7f2fe78bSCy Schubert i > 1 && elementMatcher( matchers ), 2649*7f2fe78bSCy Schubert i > 1 && toSelector( 2650*7f2fe78bSCy Schubert 2651*7f2fe78bSCy Schubert // If the preceding token was a descendant combinator, insert an implicit any-element `*` 2652*7f2fe78bSCy Schubert tokens 2653*7f2fe78bSCy Schubert .slice( 0, i - 1 ) 2654*7f2fe78bSCy Schubert .concat( { value: tokens[ i - 2 ].type === " " ? "*" : "" } ) 2655*7f2fe78bSCy Schubert ).replace( rtrim, "$1" ), 2656*7f2fe78bSCy Schubert matcher, 2657*7f2fe78bSCy Schubert i < j && matcherFromTokens( tokens.slice( i, j ) ), 2658*7f2fe78bSCy Schubert j < len && matcherFromTokens( ( tokens = tokens.slice( j ) ) ), 2659*7f2fe78bSCy Schubert j < len && toSelector( tokens ) 2660*7f2fe78bSCy Schubert ); 2661*7f2fe78bSCy Schubert } 2662*7f2fe78bSCy Schubert matchers.push( matcher ); 2663*7f2fe78bSCy Schubert } 2664*7f2fe78bSCy Schubert } 2665*7f2fe78bSCy Schubert 2666*7f2fe78bSCy Schubert return elementMatcher( matchers ); 2667*7f2fe78bSCy Schubert} 2668*7f2fe78bSCy Schubert 2669*7f2fe78bSCy Schubertfunction matcherFromGroupMatchers( elementMatchers, setMatchers ) { 2670*7f2fe78bSCy Schubert var bySet = setMatchers.length > 0, 2671*7f2fe78bSCy Schubert byElement = elementMatchers.length > 0, 2672*7f2fe78bSCy Schubert superMatcher = function( seed, context, xml, results, outermost ) { 2673*7f2fe78bSCy Schubert var elem, j, matcher, 2674*7f2fe78bSCy Schubert matchedCount = 0, 2675*7f2fe78bSCy Schubert i = "0", 2676*7f2fe78bSCy Schubert unmatched = seed && [], 2677*7f2fe78bSCy Schubert setMatched = [], 2678*7f2fe78bSCy Schubert contextBackup = outermostContext, 2679*7f2fe78bSCy Schubert 2680*7f2fe78bSCy Schubert // We must always have either seed elements or outermost context 2681*7f2fe78bSCy Schubert elems = seed || byElement && Expr.find[ "TAG" ]( "*", outermost ), 2682*7f2fe78bSCy Schubert 2683*7f2fe78bSCy Schubert // Use integer dirruns iff this is the outermost matcher 2684*7f2fe78bSCy Schubert dirrunsUnique = ( dirruns += contextBackup == null ? 1 : Math.random() || 0.1 ), 2685*7f2fe78bSCy Schubert len = elems.length; 2686*7f2fe78bSCy Schubert 2687*7f2fe78bSCy Schubert if ( outermost ) { 2688*7f2fe78bSCy Schubert 2689*7f2fe78bSCy Schubert // Support: IE 11+, Edge 17 - 18+ 2690*7f2fe78bSCy Schubert // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 2691*7f2fe78bSCy Schubert // two documents; shallow comparisons work. 2692*7f2fe78bSCy Schubert // eslint-disable-next-line eqeqeq 2693*7f2fe78bSCy Schubert outermostContext = context == document || context || outermost; 2694*7f2fe78bSCy Schubert } 2695*7f2fe78bSCy Schubert 2696*7f2fe78bSCy Schubert // Add elements passing elementMatchers directly to results 2697*7f2fe78bSCy Schubert // Support: IE<9, Safari 2698*7f2fe78bSCy Schubert // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id 2699*7f2fe78bSCy Schubert for ( ; i !== len && ( elem = elems[ i ] ) != null; i++ ) { 2700*7f2fe78bSCy Schubert if ( byElement && elem ) { 2701*7f2fe78bSCy Schubert j = 0; 2702*7f2fe78bSCy Schubert 2703*7f2fe78bSCy Schubert // Support: IE 11+, Edge 17 - 18+ 2704*7f2fe78bSCy Schubert // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 2705*7f2fe78bSCy Schubert // two documents; shallow comparisons work. 2706*7f2fe78bSCy Schubert // eslint-disable-next-line eqeqeq 2707*7f2fe78bSCy Schubert if ( !context && elem.ownerDocument != document ) { 2708*7f2fe78bSCy Schubert setDocument( elem ); 2709*7f2fe78bSCy Schubert xml = !documentIsHTML; 2710*7f2fe78bSCy Schubert } 2711*7f2fe78bSCy Schubert while ( ( matcher = elementMatchers[ j++ ] ) ) { 2712*7f2fe78bSCy Schubert if ( matcher( elem, context || document, xml ) ) { 2713*7f2fe78bSCy Schubert results.push( elem ); 2714*7f2fe78bSCy Schubert break; 2715*7f2fe78bSCy Schubert } 2716*7f2fe78bSCy Schubert } 2717*7f2fe78bSCy Schubert if ( outermost ) { 2718*7f2fe78bSCy Schubert dirruns = dirrunsUnique; 2719*7f2fe78bSCy Schubert } 2720*7f2fe78bSCy Schubert } 2721*7f2fe78bSCy Schubert 2722*7f2fe78bSCy Schubert // Track unmatched elements for set filters 2723*7f2fe78bSCy Schubert if ( bySet ) { 2724*7f2fe78bSCy Schubert 2725*7f2fe78bSCy Schubert // They will have gone through all possible matchers 2726*7f2fe78bSCy Schubert if ( ( elem = !matcher && elem ) ) { 2727*7f2fe78bSCy Schubert matchedCount--; 2728*7f2fe78bSCy Schubert } 2729*7f2fe78bSCy Schubert 2730*7f2fe78bSCy Schubert // Lengthen the array for every element, matched or not 2731*7f2fe78bSCy Schubert if ( seed ) { 2732*7f2fe78bSCy Schubert unmatched.push( elem ); 2733*7f2fe78bSCy Schubert } 2734*7f2fe78bSCy Schubert } 2735*7f2fe78bSCy Schubert } 2736*7f2fe78bSCy Schubert 2737*7f2fe78bSCy Schubert // `i` is now the count of elements visited above, and adding it to `matchedCount` 2738*7f2fe78bSCy Schubert // makes the latter nonnegative. 2739*7f2fe78bSCy Schubert matchedCount += i; 2740*7f2fe78bSCy Schubert 2741*7f2fe78bSCy Schubert // Apply set filters to unmatched elements 2742*7f2fe78bSCy Schubert // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount` 2743*7f2fe78bSCy Schubert // equals `i`), unless we didn't visit _any_ elements in the above loop because we have 2744*7f2fe78bSCy Schubert // no element matchers and no seed. 2745*7f2fe78bSCy Schubert // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that 2746*7f2fe78bSCy Schubert // case, which will result in a "00" `matchedCount` that differs from `i` but is also 2747*7f2fe78bSCy Schubert // numerically zero. 2748*7f2fe78bSCy Schubert if ( bySet && i !== matchedCount ) { 2749*7f2fe78bSCy Schubert j = 0; 2750*7f2fe78bSCy Schubert while ( ( matcher = setMatchers[ j++ ] ) ) { 2751*7f2fe78bSCy Schubert matcher( unmatched, setMatched, context, xml ); 2752*7f2fe78bSCy Schubert } 2753*7f2fe78bSCy Schubert 2754*7f2fe78bSCy Schubert if ( seed ) { 2755*7f2fe78bSCy Schubert 2756*7f2fe78bSCy Schubert // Reintegrate element matches to eliminate the need for sorting 2757*7f2fe78bSCy Schubert if ( matchedCount > 0 ) { 2758*7f2fe78bSCy Schubert while ( i-- ) { 2759*7f2fe78bSCy Schubert if ( !( unmatched[ i ] || setMatched[ i ] ) ) { 2760*7f2fe78bSCy Schubert setMatched[ i ] = pop.call( results ); 2761*7f2fe78bSCy Schubert } 2762*7f2fe78bSCy Schubert } 2763*7f2fe78bSCy Schubert } 2764*7f2fe78bSCy Schubert 2765*7f2fe78bSCy Schubert // Discard index placeholder values to get only actual matches 2766*7f2fe78bSCy Schubert setMatched = condense( setMatched ); 2767*7f2fe78bSCy Schubert } 2768*7f2fe78bSCy Schubert 2769*7f2fe78bSCy Schubert // Add matches to results 2770*7f2fe78bSCy Schubert push.apply( results, setMatched ); 2771*7f2fe78bSCy Schubert 2772*7f2fe78bSCy Schubert // Seedless set matches succeeding multiple successful matchers stipulate sorting 2773*7f2fe78bSCy Schubert if ( outermost && !seed && setMatched.length > 0 && 2774*7f2fe78bSCy Schubert ( matchedCount + setMatchers.length ) > 1 ) { 2775*7f2fe78bSCy Schubert 2776*7f2fe78bSCy Schubert Sizzle.uniqueSort( results ); 2777*7f2fe78bSCy Schubert } 2778*7f2fe78bSCy Schubert } 2779*7f2fe78bSCy Schubert 2780*7f2fe78bSCy Schubert // Override manipulation of globals by nested matchers 2781*7f2fe78bSCy Schubert if ( outermost ) { 2782*7f2fe78bSCy Schubert dirruns = dirrunsUnique; 2783*7f2fe78bSCy Schubert outermostContext = contextBackup; 2784*7f2fe78bSCy Schubert } 2785*7f2fe78bSCy Schubert 2786*7f2fe78bSCy Schubert return unmatched; 2787*7f2fe78bSCy Schubert }; 2788*7f2fe78bSCy Schubert 2789*7f2fe78bSCy Schubert return bySet ? 2790*7f2fe78bSCy Schubert markFunction( superMatcher ) : 2791*7f2fe78bSCy Schubert superMatcher; 2792*7f2fe78bSCy Schubert} 2793*7f2fe78bSCy Schubert 2794*7f2fe78bSCy Schubertcompile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) { 2795*7f2fe78bSCy Schubert var i, 2796*7f2fe78bSCy Schubert setMatchers = [], 2797*7f2fe78bSCy Schubert elementMatchers = [], 2798*7f2fe78bSCy Schubert cached = compilerCache[ selector + " " ]; 2799*7f2fe78bSCy Schubert 2800*7f2fe78bSCy Schubert if ( !cached ) { 2801*7f2fe78bSCy Schubert 2802*7f2fe78bSCy Schubert // Generate a function of recursive functions that can be used to check each element 2803*7f2fe78bSCy Schubert if ( !match ) { 2804*7f2fe78bSCy Schubert match = tokenize( selector ); 2805*7f2fe78bSCy Schubert } 2806*7f2fe78bSCy Schubert i = match.length; 2807*7f2fe78bSCy Schubert while ( i-- ) { 2808*7f2fe78bSCy Schubert cached = matcherFromTokens( match[ i ] ); 2809*7f2fe78bSCy Schubert if ( cached[ expando ] ) { 2810*7f2fe78bSCy Schubert setMatchers.push( cached ); 2811*7f2fe78bSCy Schubert } else { 2812*7f2fe78bSCy Schubert elementMatchers.push( cached ); 2813*7f2fe78bSCy Schubert } 2814*7f2fe78bSCy Schubert } 2815*7f2fe78bSCy Schubert 2816*7f2fe78bSCy Schubert // Cache the compiled function 2817*7f2fe78bSCy Schubert cached = compilerCache( 2818*7f2fe78bSCy Schubert selector, 2819*7f2fe78bSCy Schubert matcherFromGroupMatchers( elementMatchers, setMatchers ) 2820*7f2fe78bSCy Schubert ); 2821*7f2fe78bSCy Schubert 2822*7f2fe78bSCy Schubert // Save selector and tokenization 2823*7f2fe78bSCy Schubert cached.selector = selector; 2824*7f2fe78bSCy Schubert } 2825*7f2fe78bSCy Schubert return cached; 2826*7f2fe78bSCy Schubert}; 2827*7f2fe78bSCy Schubert 2828*7f2fe78bSCy Schubert/** 2829*7f2fe78bSCy Schubert * A low-level selection function that works with Sizzle's compiled 2830*7f2fe78bSCy Schubert * selector functions 2831*7f2fe78bSCy Schubert * @param {String|Function} selector A selector or a pre-compiled 2832*7f2fe78bSCy Schubert * selector function built with Sizzle.compile 2833*7f2fe78bSCy Schubert * @param {Element} context 2834*7f2fe78bSCy Schubert * @param {Array} [results] 2835*7f2fe78bSCy Schubert * @param {Array} [seed] A set of elements to match against 2836*7f2fe78bSCy Schubert */ 2837*7f2fe78bSCy Schubertselect = Sizzle.select = function( selector, context, results, seed ) { 2838*7f2fe78bSCy Schubert var i, tokens, token, type, find, 2839*7f2fe78bSCy Schubert compiled = typeof selector === "function" && selector, 2840*7f2fe78bSCy Schubert match = !seed && tokenize( ( selector = compiled.selector || selector ) ); 2841*7f2fe78bSCy Schubert 2842*7f2fe78bSCy Schubert results = results || []; 2843*7f2fe78bSCy Schubert 2844*7f2fe78bSCy Schubert // Try to minimize operations if there is only one selector in the list and no seed 2845*7f2fe78bSCy Schubert // (the latter of which guarantees us context) 2846*7f2fe78bSCy Schubert if ( match.length === 1 ) { 2847*7f2fe78bSCy Schubert 2848*7f2fe78bSCy Schubert // Reduce context if the leading compound selector is an ID 2849*7f2fe78bSCy Schubert tokens = match[ 0 ] = match[ 0 ].slice( 0 ); 2850*7f2fe78bSCy Schubert if ( tokens.length > 2 && ( token = tokens[ 0 ] ).type === "ID" && 2851*7f2fe78bSCy Schubert context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[ 1 ].type ] ) { 2852*7f2fe78bSCy Schubert 2853*7f2fe78bSCy Schubert context = ( Expr.find[ "ID" ]( token.matches[ 0 ] 2854*7f2fe78bSCy Schubert .replace( runescape, funescape ), context ) || [] )[ 0 ]; 2855*7f2fe78bSCy Schubert if ( !context ) { 2856*7f2fe78bSCy Schubert return results; 2857*7f2fe78bSCy Schubert 2858*7f2fe78bSCy Schubert // Precompiled matchers will still verify ancestry, so step up a level 2859*7f2fe78bSCy Schubert } else if ( compiled ) { 2860*7f2fe78bSCy Schubert context = context.parentNode; 2861*7f2fe78bSCy Schubert } 2862*7f2fe78bSCy Schubert 2863*7f2fe78bSCy Schubert selector = selector.slice( tokens.shift().value.length ); 2864*7f2fe78bSCy Schubert } 2865*7f2fe78bSCy Schubert 2866*7f2fe78bSCy Schubert // Fetch a seed set for right-to-left matching 2867*7f2fe78bSCy Schubert i = matchExpr[ "needsContext" ].test( selector ) ? 0 : tokens.length; 2868*7f2fe78bSCy Schubert while ( i-- ) { 2869*7f2fe78bSCy Schubert token = tokens[ i ]; 2870*7f2fe78bSCy Schubert 2871*7f2fe78bSCy Schubert // Abort if we hit a combinator 2872*7f2fe78bSCy Schubert if ( Expr.relative[ ( type = token.type ) ] ) { 2873*7f2fe78bSCy Schubert break; 2874*7f2fe78bSCy Schubert } 2875*7f2fe78bSCy Schubert if ( ( find = Expr.find[ type ] ) ) { 2876*7f2fe78bSCy Schubert 2877*7f2fe78bSCy Schubert // Search, expanding context for leading sibling combinators 2878*7f2fe78bSCy Schubert if ( ( seed = find( 2879*7f2fe78bSCy Schubert token.matches[ 0 ].replace( runescape, funescape ), 2880*7f2fe78bSCy Schubert rsibling.test( tokens[ 0 ].type ) && testContext( context.parentNode ) || 2881*7f2fe78bSCy Schubert context 2882*7f2fe78bSCy Schubert ) ) ) { 2883*7f2fe78bSCy Schubert 2884*7f2fe78bSCy Schubert // If seed is empty or no tokens remain, we can return early 2885*7f2fe78bSCy Schubert tokens.splice( i, 1 ); 2886*7f2fe78bSCy Schubert selector = seed.length && toSelector( tokens ); 2887*7f2fe78bSCy Schubert if ( !selector ) { 2888*7f2fe78bSCy Schubert push.apply( results, seed ); 2889*7f2fe78bSCy Schubert return results; 2890*7f2fe78bSCy Schubert } 2891*7f2fe78bSCy Schubert 2892*7f2fe78bSCy Schubert break; 2893*7f2fe78bSCy Schubert } 2894*7f2fe78bSCy Schubert } 2895*7f2fe78bSCy Schubert } 2896*7f2fe78bSCy Schubert } 2897*7f2fe78bSCy Schubert 2898*7f2fe78bSCy Schubert // Compile and execute a filtering function if one is not provided 2899*7f2fe78bSCy Schubert // Provide `match` to avoid retokenization if we modified the selector above 2900*7f2fe78bSCy Schubert ( compiled || compile( selector, match ) )( 2901*7f2fe78bSCy Schubert seed, 2902*7f2fe78bSCy Schubert context, 2903*7f2fe78bSCy Schubert !documentIsHTML, 2904*7f2fe78bSCy Schubert results, 2905*7f2fe78bSCy Schubert !context || rsibling.test( selector ) && testContext( context.parentNode ) || context 2906*7f2fe78bSCy Schubert ); 2907*7f2fe78bSCy Schubert return results; 2908*7f2fe78bSCy Schubert}; 2909*7f2fe78bSCy Schubert 2910*7f2fe78bSCy Schubert// One-time assignments 2911*7f2fe78bSCy Schubert 2912*7f2fe78bSCy Schubert// Sort stability 2913*7f2fe78bSCy Schubertsupport.sortStable = expando.split( "" ).sort( sortOrder ).join( "" ) === expando; 2914*7f2fe78bSCy Schubert 2915*7f2fe78bSCy Schubert// Support: Chrome 14-35+ 2916*7f2fe78bSCy Schubert// Always assume duplicates if they aren't passed to the comparison function 2917*7f2fe78bSCy Schubertsupport.detectDuplicates = !!hasDuplicate; 2918*7f2fe78bSCy Schubert 2919*7f2fe78bSCy Schubert// Initialize against the default document 2920*7f2fe78bSCy SchubertsetDocument(); 2921*7f2fe78bSCy Schubert 2922*7f2fe78bSCy Schubert// Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27) 2923*7f2fe78bSCy Schubert// Detached nodes confoundingly follow *each other* 2924*7f2fe78bSCy Schubertsupport.sortDetached = assert( function( el ) { 2925*7f2fe78bSCy Schubert 2926*7f2fe78bSCy Schubert // Should return 1, but returns 4 (following) 2927*7f2fe78bSCy Schubert return el.compareDocumentPosition( document.createElement( "fieldset" ) ) & 1; 2928*7f2fe78bSCy Schubert} ); 2929*7f2fe78bSCy Schubert 2930*7f2fe78bSCy Schubert// Support: IE<8 2931*7f2fe78bSCy Schubert// Prevent attribute/property "interpolation" 2932*7f2fe78bSCy Schubert// https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx 2933*7f2fe78bSCy Schubertif ( !assert( function( el ) { 2934*7f2fe78bSCy Schubert el.innerHTML = "<a href='#'></a>"; 2935*7f2fe78bSCy Schubert return el.firstChild.getAttribute( "href" ) === "#"; 2936*7f2fe78bSCy Schubert} ) ) { 2937*7f2fe78bSCy Schubert addHandle( "type|href|height|width", function( elem, name, isXML ) { 2938*7f2fe78bSCy Schubert if ( !isXML ) { 2939*7f2fe78bSCy Schubert return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 ); 2940*7f2fe78bSCy Schubert } 2941*7f2fe78bSCy Schubert } ); 2942*7f2fe78bSCy Schubert} 2943*7f2fe78bSCy Schubert 2944*7f2fe78bSCy Schubert// Support: IE<9 2945*7f2fe78bSCy Schubert// Use defaultValue in place of getAttribute("value") 2946*7f2fe78bSCy Schubertif ( !support.attributes || !assert( function( el ) { 2947*7f2fe78bSCy Schubert el.innerHTML = "<input/>"; 2948*7f2fe78bSCy Schubert el.firstChild.setAttribute( "value", "" ); 2949*7f2fe78bSCy Schubert return el.firstChild.getAttribute( "value" ) === ""; 2950*7f2fe78bSCy Schubert} ) ) { 2951*7f2fe78bSCy Schubert addHandle( "value", function( elem, _name, isXML ) { 2952*7f2fe78bSCy Schubert if ( !isXML && elem.nodeName.toLowerCase() === "input" ) { 2953*7f2fe78bSCy Schubert return elem.defaultValue; 2954*7f2fe78bSCy Schubert } 2955*7f2fe78bSCy Schubert } ); 2956*7f2fe78bSCy Schubert} 2957*7f2fe78bSCy Schubert 2958*7f2fe78bSCy Schubert// Support: IE<9 2959*7f2fe78bSCy Schubert// Use getAttributeNode to fetch booleans when getAttribute lies 2960*7f2fe78bSCy Schubertif ( !assert( function( el ) { 2961*7f2fe78bSCy Schubert return el.getAttribute( "disabled" ) == null; 2962*7f2fe78bSCy Schubert} ) ) { 2963*7f2fe78bSCy Schubert addHandle( booleans, function( elem, name, isXML ) { 2964*7f2fe78bSCy Schubert var val; 2965*7f2fe78bSCy Schubert if ( !isXML ) { 2966*7f2fe78bSCy Schubert return elem[ name ] === true ? name.toLowerCase() : 2967*7f2fe78bSCy Schubert ( val = elem.getAttributeNode( name ) ) && val.specified ? 2968*7f2fe78bSCy Schubert val.value : 2969*7f2fe78bSCy Schubert null; 2970*7f2fe78bSCy Schubert } 2971*7f2fe78bSCy Schubert } ); 2972*7f2fe78bSCy Schubert} 2973*7f2fe78bSCy Schubert 2974*7f2fe78bSCy Schubertreturn Sizzle; 2975*7f2fe78bSCy Schubert 2976*7f2fe78bSCy Schubert} )( window ); 2977*7f2fe78bSCy Schubert 2978*7f2fe78bSCy Schubert 2979*7f2fe78bSCy Schubert 2980*7f2fe78bSCy SchubertjQuery.find = Sizzle; 2981*7f2fe78bSCy SchubertjQuery.expr = Sizzle.selectors; 2982*7f2fe78bSCy Schubert 2983*7f2fe78bSCy Schubert// Deprecated 2984*7f2fe78bSCy SchubertjQuery.expr[ ":" ] = jQuery.expr.pseudos; 2985*7f2fe78bSCy SchubertjQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort; 2986*7f2fe78bSCy SchubertjQuery.text = Sizzle.getText; 2987*7f2fe78bSCy SchubertjQuery.isXMLDoc = Sizzle.isXML; 2988*7f2fe78bSCy SchubertjQuery.contains = Sizzle.contains; 2989*7f2fe78bSCy SchubertjQuery.escapeSelector = Sizzle.escape; 2990*7f2fe78bSCy Schubert 2991*7f2fe78bSCy Schubert 2992*7f2fe78bSCy Schubert 2993*7f2fe78bSCy Schubert 2994*7f2fe78bSCy Schubertvar dir = function( elem, dir, until ) { 2995*7f2fe78bSCy Schubert var matched = [], 2996*7f2fe78bSCy Schubert truncate = until !== undefined; 2997*7f2fe78bSCy Schubert 2998*7f2fe78bSCy Schubert while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) { 2999*7f2fe78bSCy Schubert if ( elem.nodeType === 1 ) { 3000*7f2fe78bSCy Schubert if ( truncate && jQuery( elem ).is( until ) ) { 3001*7f2fe78bSCy Schubert break; 3002*7f2fe78bSCy Schubert } 3003*7f2fe78bSCy Schubert matched.push( elem ); 3004*7f2fe78bSCy Schubert } 3005*7f2fe78bSCy Schubert } 3006*7f2fe78bSCy Schubert return matched; 3007*7f2fe78bSCy Schubert}; 3008*7f2fe78bSCy Schubert 3009*7f2fe78bSCy Schubert 3010*7f2fe78bSCy Schubertvar siblings = function( n, elem ) { 3011*7f2fe78bSCy Schubert var matched = []; 3012*7f2fe78bSCy Schubert 3013*7f2fe78bSCy Schubert for ( ; n; n = n.nextSibling ) { 3014*7f2fe78bSCy Schubert if ( n.nodeType === 1 && n !== elem ) { 3015*7f2fe78bSCy Schubert matched.push( n ); 3016*7f2fe78bSCy Schubert } 3017*7f2fe78bSCy Schubert } 3018*7f2fe78bSCy Schubert 3019*7f2fe78bSCy Schubert return matched; 3020*7f2fe78bSCy Schubert}; 3021*7f2fe78bSCy Schubert 3022*7f2fe78bSCy Schubert 3023*7f2fe78bSCy Schubertvar rneedsContext = jQuery.expr.match.needsContext; 3024*7f2fe78bSCy Schubert 3025*7f2fe78bSCy Schubert 3026*7f2fe78bSCy Schubert 3027*7f2fe78bSCy Schubertfunction nodeName( elem, name ) { 3028*7f2fe78bSCy Schubert 3029*7f2fe78bSCy Schubert return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); 3030*7f2fe78bSCy Schubert 3031*7f2fe78bSCy Schubert} 3032*7f2fe78bSCy Schubertvar rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i ); 3033*7f2fe78bSCy Schubert 3034*7f2fe78bSCy Schubert 3035*7f2fe78bSCy Schubert 3036*7f2fe78bSCy Schubert// Implement the identical functionality for filter and not 3037*7f2fe78bSCy Schubertfunction winnow( elements, qualifier, not ) { 3038*7f2fe78bSCy Schubert if ( isFunction( qualifier ) ) { 3039*7f2fe78bSCy Schubert return jQuery.grep( elements, function( elem, i ) { 3040*7f2fe78bSCy Schubert return !!qualifier.call( elem, i, elem ) !== not; 3041*7f2fe78bSCy Schubert } ); 3042*7f2fe78bSCy Schubert } 3043*7f2fe78bSCy Schubert 3044*7f2fe78bSCy Schubert // Single element 3045*7f2fe78bSCy Schubert if ( qualifier.nodeType ) { 3046*7f2fe78bSCy Schubert return jQuery.grep( elements, function( elem ) { 3047*7f2fe78bSCy Schubert return ( elem === qualifier ) !== not; 3048*7f2fe78bSCy Schubert } ); 3049*7f2fe78bSCy Schubert } 3050*7f2fe78bSCy Schubert 3051*7f2fe78bSCy Schubert // Arraylike of elements (jQuery, arguments, Array) 3052*7f2fe78bSCy Schubert if ( typeof qualifier !== "string" ) { 3053*7f2fe78bSCy Schubert return jQuery.grep( elements, function( elem ) { 3054*7f2fe78bSCy Schubert return ( indexOf.call( qualifier, elem ) > -1 ) !== not; 3055*7f2fe78bSCy Schubert } ); 3056*7f2fe78bSCy Schubert } 3057*7f2fe78bSCy Schubert 3058*7f2fe78bSCy Schubert // Filtered directly for both simple and complex selectors 3059*7f2fe78bSCy Schubert return jQuery.filter( qualifier, elements, not ); 3060*7f2fe78bSCy Schubert} 3061*7f2fe78bSCy Schubert 3062*7f2fe78bSCy SchubertjQuery.filter = function( expr, elems, not ) { 3063*7f2fe78bSCy Schubert var elem = elems[ 0 ]; 3064*7f2fe78bSCy Schubert 3065*7f2fe78bSCy Schubert if ( not ) { 3066*7f2fe78bSCy Schubert expr = ":not(" + expr + ")"; 3067*7f2fe78bSCy Schubert } 3068*7f2fe78bSCy Schubert 3069*7f2fe78bSCy Schubert if ( elems.length === 1 && elem.nodeType === 1 ) { 3070*7f2fe78bSCy Schubert return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : []; 3071*7f2fe78bSCy Schubert } 3072*7f2fe78bSCy Schubert 3073*7f2fe78bSCy Schubert return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) { 3074*7f2fe78bSCy Schubert return elem.nodeType === 1; 3075*7f2fe78bSCy Schubert } ) ); 3076*7f2fe78bSCy Schubert}; 3077*7f2fe78bSCy Schubert 3078*7f2fe78bSCy SchubertjQuery.fn.extend( { 3079*7f2fe78bSCy Schubert find: function( selector ) { 3080*7f2fe78bSCy Schubert var i, ret, 3081*7f2fe78bSCy Schubert len = this.length, 3082*7f2fe78bSCy Schubert self = this; 3083*7f2fe78bSCy Schubert 3084*7f2fe78bSCy Schubert if ( typeof selector !== "string" ) { 3085*7f2fe78bSCy Schubert return this.pushStack( jQuery( selector ).filter( function() { 3086*7f2fe78bSCy Schubert for ( i = 0; i < len; i++ ) { 3087*7f2fe78bSCy Schubert if ( jQuery.contains( self[ i ], this ) ) { 3088*7f2fe78bSCy Schubert return true; 3089*7f2fe78bSCy Schubert } 3090*7f2fe78bSCy Schubert } 3091*7f2fe78bSCy Schubert } ) ); 3092*7f2fe78bSCy Schubert } 3093*7f2fe78bSCy Schubert 3094*7f2fe78bSCy Schubert ret = this.pushStack( [] ); 3095*7f2fe78bSCy Schubert 3096*7f2fe78bSCy Schubert for ( i = 0; i < len; i++ ) { 3097*7f2fe78bSCy Schubert jQuery.find( selector, self[ i ], ret ); 3098*7f2fe78bSCy Schubert } 3099*7f2fe78bSCy Schubert 3100*7f2fe78bSCy Schubert return len > 1 ? jQuery.uniqueSort( ret ) : ret; 3101*7f2fe78bSCy Schubert }, 3102*7f2fe78bSCy Schubert filter: function( selector ) { 3103*7f2fe78bSCy Schubert return this.pushStack( winnow( this, selector || [], false ) ); 3104*7f2fe78bSCy Schubert }, 3105*7f2fe78bSCy Schubert not: function( selector ) { 3106*7f2fe78bSCy Schubert return this.pushStack( winnow( this, selector || [], true ) ); 3107*7f2fe78bSCy Schubert }, 3108*7f2fe78bSCy Schubert is: function( selector ) { 3109*7f2fe78bSCy Schubert return !!winnow( 3110*7f2fe78bSCy Schubert this, 3111*7f2fe78bSCy Schubert 3112*7f2fe78bSCy Schubert // If this is a positional/relative selector, check membership in the returned set 3113*7f2fe78bSCy Schubert // so $("p:first").is("p:last") won't return true for a doc with two "p". 3114*7f2fe78bSCy Schubert typeof selector === "string" && rneedsContext.test( selector ) ? 3115*7f2fe78bSCy Schubert jQuery( selector ) : 3116*7f2fe78bSCy Schubert selector || [], 3117*7f2fe78bSCy Schubert false 3118*7f2fe78bSCy Schubert ).length; 3119*7f2fe78bSCy Schubert } 3120*7f2fe78bSCy Schubert} ); 3121*7f2fe78bSCy Schubert 3122*7f2fe78bSCy Schubert 3123*7f2fe78bSCy Schubert// Initialize a jQuery object 3124*7f2fe78bSCy Schubert 3125*7f2fe78bSCy Schubert 3126*7f2fe78bSCy Schubert// A central reference to the root jQuery(document) 3127*7f2fe78bSCy Schubertvar rootjQuery, 3128*7f2fe78bSCy Schubert 3129*7f2fe78bSCy Schubert // A simple way to check for HTML strings 3130*7f2fe78bSCy Schubert // Prioritize #id over <tag> to avoid XSS via location.hash (#9521) 3131*7f2fe78bSCy Schubert // Strict HTML recognition (#11290: must start with <) 3132*7f2fe78bSCy Schubert // Shortcut simple #id case for speed 3133*7f2fe78bSCy Schubert rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/, 3134*7f2fe78bSCy Schubert 3135*7f2fe78bSCy Schubert init = jQuery.fn.init = function( selector, context, root ) { 3136*7f2fe78bSCy Schubert var match, elem; 3137*7f2fe78bSCy Schubert 3138*7f2fe78bSCy Schubert // HANDLE: $(""), $(null), $(undefined), $(false) 3139*7f2fe78bSCy Schubert if ( !selector ) { 3140*7f2fe78bSCy Schubert return this; 3141*7f2fe78bSCy Schubert } 3142*7f2fe78bSCy Schubert 3143*7f2fe78bSCy Schubert // Method init() accepts an alternate rootjQuery 3144*7f2fe78bSCy Schubert // so migrate can support jQuery.sub (gh-2101) 3145*7f2fe78bSCy Schubert root = root || rootjQuery; 3146*7f2fe78bSCy Schubert 3147*7f2fe78bSCy Schubert // Handle HTML strings 3148*7f2fe78bSCy Schubert if ( typeof selector === "string" ) { 3149*7f2fe78bSCy Schubert if ( selector[ 0 ] === "<" && 3150*7f2fe78bSCy Schubert selector[ selector.length - 1 ] === ">" && 3151*7f2fe78bSCy Schubert selector.length >= 3 ) { 3152*7f2fe78bSCy Schubert 3153*7f2fe78bSCy Schubert // Assume that strings that start and end with <> are HTML and skip the regex check 3154*7f2fe78bSCy Schubert match = [ null, selector, null ]; 3155*7f2fe78bSCy Schubert 3156*7f2fe78bSCy Schubert } else { 3157*7f2fe78bSCy Schubert match = rquickExpr.exec( selector ); 3158*7f2fe78bSCy Schubert } 3159*7f2fe78bSCy Schubert 3160*7f2fe78bSCy Schubert // Match html or make sure no context is specified for #id 3161*7f2fe78bSCy Schubert if ( match && ( match[ 1 ] || !context ) ) { 3162*7f2fe78bSCy Schubert 3163*7f2fe78bSCy Schubert // HANDLE: $(html) -> $(array) 3164*7f2fe78bSCy Schubert if ( match[ 1 ] ) { 3165*7f2fe78bSCy Schubert context = context instanceof jQuery ? context[ 0 ] : context; 3166*7f2fe78bSCy Schubert 3167*7f2fe78bSCy Schubert // Option to run scripts is true for back-compat 3168*7f2fe78bSCy Schubert // Intentionally let the error be thrown if parseHTML is not present 3169*7f2fe78bSCy Schubert jQuery.merge( this, jQuery.parseHTML( 3170*7f2fe78bSCy Schubert match[ 1 ], 3171*7f2fe78bSCy Schubert context && context.nodeType ? context.ownerDocument || context : document, 3172*7f2fe78bSCy Schubert true 3173*7f2fe78bSCy Schubert ) ); 3174*7f2fe78bSCy Schubert 3175*7f2fe78bSCy Schubert // HANDLE: $(html, props) 3176*7f2fe78bSCy Schubert if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) { 3177*7f2fe78bSCy Schubert for ( match in context ) { 3178*7f2fe78bSCy Schubert 3179*7f2fe78bSCy Schubert // Properties of context are called as methods if possible 3180*7f2fe78bSCy Schubert if ( isFunction( this[ match ] ) ) { 3181*7f2fe78bSCy Schubert this[ match ]( context[ match ] ); 3182*7f2fe78bSCy Schubert 3183*7f2fe78bSCy Schubert // ...and otherwise set as attributes 3184*7f2fe78bSCy Schubert } else { 3185*7f2fe78bSCy Schubert this.attr( match, context[ match ] ); 3186*7f2fe78bSCy Schubert } 3187*7f2fe78bSCy Schubert } 3188*7f2fe78bSCy Schubert } 3189*7f2fe78bSCy Schubert 3190*7f2fe78bSCy Schubert return this; 3191*7f2fe78bSCy Schubert 3192*7f2fe78bSCy Schubert // HANDLE: $(#id) 3193*7f2fe78bSCy Schubert } else { 3194*7f2fe78bSCy Schubert elem = document.getElementById( match[ 2 ] ); 3195*7f2fe78bSCy Schubert 3196*7f2fe78bSCy Schubert if ( elem ) { 3197*7f2fe78bSCy Schubert 3198*7f2fe78bSCy Schubert // Inject the element directly into the jQuery object 3199*7f2fe78bSCy Schubert this[ 0 ] = elem; 3200*7f2fe78bSCy Schubert this.length = 1; 3201*7f2fe78bSCy Schubert } 3202*7f2fe78bSCy Schubert return this; 3203*7f2fe78bSCy Schubert } 3204*7f2fe78bSCy Schubert 3205*7f2fe78bSCy Schubert // HANDLE: $(expr, $(...)) 3206*7f2fe78bSCy Schubert } else if ( !context || context.jquery ) { 3207*7f2fe78bSCy Schubert return ( context || root ).find( selector ); 3208*7f2fe78bSCy Schubert 3209*7f2fe78bSCy Schubert // HANDLE: $(expr, context) 3210*7f2fe78bSCy Schubert // (which is just equivalent to: $(context).find(expr) 3211*7f2fe78bSCy Schubert } else { 3212*7f2fe78bSCy Schubert return this.constructor( context ).find( selector ); 3213*7f2fe78bSCy Schubert } 3214*7f2fe78bSCy Schubert 3215*7f2fe78bSCy Schubert // HANDLE: $(DOMElement) 3216*7f2fe78bSCy Schubert } else if ( selector.nodeType ) { 3217*7f2fe78bSCy Schubert this[ 0 ] = selector; 3218*7f2fe78bSCy Schubert this.length = 1; 3219*7f2fe78bSCy Schubert return this; 3220*7f2fe78bSCy Schubert 3221*7f2fe78bSCy Schubert // HANDLE: $(function) 3222*7f2fe78bSCy Schubert // Shortcut for document ready 3223*7f2fe78bSCy Schubert } else if ( isFunction( selector ) ) { 3224*7f2fe78bSCy Schubert return root.ready !== undefined ? 3225*7f2fe78bSCy Schubert root.ready( selector ) : 3226*7f2fe78bSCy Schubert 3227*7f2fe78bSCy Schubert // Execute immediately if ready is not present 3228*7f2fe78bSCy Schubert selector( jQuery ); 3229*7f2fe78bSCy Schubert } 3230*7f2fe78bSCy Schubert 3231*7f2fe78bSCy Schubert return jQuery.makeArray( selector, this ); 3232*7f2fe78bSCy Schubert }; 3233*7f2fe78bSCy Schubert 3234*7f2fe78bSCy Schubert// Give the init function the jQuery prototype for later instantiation 3235*7f2fe78bSCy Schubertinit.prototype = jQuery.fn; 3236*7f2fe78bSCy Schubert 3237*7f2fe78bSCy Schubert// Initialize central reference 3238*7f2fe78bSCy SchubertrootjQuery = jQuery( document ); 3239*7f2fe78bSCy Schubert 3240*7f2fe78bSCy Schubert 3241*7f2fe78bSCy Schubertvar rparentsprev = /^(?:parents|prev(?:Until|All))/, 3242*7f2fe78bSCy Schubert 3243*7f2fe78bSCy Schubert // Methods guaranteed to produce a unique set when starting from a unique set 3244*7f2fe78bSCy Schubert guaranteedUnique = { 3245*7f2fe78bSCy Schubert children: true, 3246*7f2fe78bSCy Schubert contents: true, 3247*7f2fe78bSCy Schubert next: true, 3248*7f2fe78bSCy Schubert prev: true 3249*7f2fe78bSCy Schubert }; 3250*7f2fe78bSCy Schubert 3251*7f2fe78bSCy SchubertjQuery.fn.extend( { 3252*7f2fe78bSCy Schubert has: function( target ) { 3253*7f2fe78bSCy Schubert var targets = jQuery( target, this ), 3254*7f2fe78bSCy Schubert l = targets.length; 3255*7f2fe78bSCy Schubert 3256*7f2fe78bSCy Schubert return this.filter( function() { 3257*7f2fe78bSCy Schubert var i = 0; 3258*7f2fe78bSCy Schubert for ( ; i < l; i++ ) { 3259*7f2fe78bSCy Schubert if ( jQuery.contains( this, targets[ i ] ) ) { 3260*7f2fe78bSCy Schubert return true; 3261*7f2fe78bSCy Schubert } 3262*7f2fe78bSCy Schubert } 3263*7f2fe78bSCy Schubert } ); 3264*7f2fe78bSCy Schubert }, 3265*7f2fe78bSCy Schubert 3266*7f2fe78bSCy Schubert closest: function( selectors, context ) { 3267*7f2fe78bSCy Schubert var cur, 3268*7f2fe78bSCy Schubert i = 0, 3269*7f2fe78bSCy Schubert l = this.length, 3270*7f2fe78bSCy Schubert matched = [], 3271*7f2fe78bSCy Schubert targets = typeof selectors !== "string" && jQuery( selectors ); 3272*7f2fe78bSCy Schubert 3273*7f2fe78bSCy Schubert // Positional selectors never match, since there's no _selection_ context 3274*7f2fe78bSCy Schubert if ( !rneedsContext.test( selectors ) ) { 3275*7f2fe78bSCy Schubert for ( ; i < l; i++ ) { 3276*7f2fe78bSCy Schubert for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) { 3277*7f2fe78bSCy Schubert 3278*7f2fe78bSCy Schubert // Always skip document fragments 3279*7f2fe78bSCy Schubert if ( cur.nodeType < 11 && ( targets ? 3280*7f2fe78bSCy Schubert targets.index( cur ) > -1 : 3281*7f2fe78bSCy Schubert 3282*7f2fe78bSCy Schubert // Don't pass non-elements to Sizzle 3283*7f2fe78bSCy Schubert cur.nodeType === 1 && 3284*7f2fe78bSCy Schubert jQuery.find.matchesSelector( cur, selectors ) ) ) { 3285*7f2fe78bSCy Schubert 3286*7f2fe78bSCy Schubert matched.push( cur ); 3287*7f2fe78bSCy Schubert break; 3288*7f2fe78bSCy Schubert } 3289*7f2fe78bSCy Schubert } 3290*7f2fe78bSCy Schubert } 3291*7f2fe78bSCy Schubert } 3292*7f2fe78bSCy Schubert 3293*7f2fe78bSCy Schubert return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched ); 3294*7f2fe78bSCy Schubert }, 3295*7f2fe78bSCy Schubert 3296*7f2fe78bSCy Schubert // Determine the position of an element within the set 3297*7f2fe78bSCy Schubert index: function( elem ) { 3298*7f2fe78bSCy Schubert 3299*7f2fe78bSCy Schubert // No argument, return index in parent 3300*7f2fe78bSCy Schubert if ( !elem ) { 3301*7f2fe78bSCy Schubert return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1; 3302*7f2fe78bSCy Schubert } 3303*7f2fe78bSCy Schubert 3304*7f2fe78bSCy Schubert // Index in selector 3305*7f2fe78bSCy Schubert if ( typeof elem === "string" ) { 3306*7f2fe78bSCy Schubert return indexOf.call( jQuery( elem ), this[ 0 ] ); 3307*7f2fe78bSCy Schubert } 3308*7f2fe78bSCy Schubert 3309*7f2fe78bSCy Schubert // Locate the position of the desired element 3310*7f2fe78bSCy Schubert return indexOf.call( this, 3311*7f2fe78bSCy Schubert 3312*7f2fe78bSCy Schubert // If it receives a jQuery object, the first element is used 3313*7f2fe78bSCy Schubert elem.jquery ? elem[ 0 ] : elem 3314*7f2fe78bSCy Schubert ); 3315*7f2fe78bSCy Schubert }, 3316*7f2fe78bSCy Schubert 3317*7f2fe78bSCy Schubert add: function( selector, context ) { 3318*7f2fe78bSCy Schubert return this.pushStack( 3319*7f2fe78bSCy Schubert jQuery.uniqueSort( 3320*7f2fe78bSCy Schubert jQuery.merge( this.get(), jQuery( selector, context ) ) 3321*7f2fe78bSCy Schubert ) 3322*7f2fe78bSCy Schubert ); 3323*7f2fe78bSCy Schubert }, 3324*7f2fe78bSCy Schubert 3325*7f2fe78bSCy Schubert addBack: function( selector ) { 3326*7f2fe78bSCy Schubert return this.add( selector == null ? 3327*7f2fe78bSCy Schubert this.prevObject : this.prevObject.filter( selector ) 3328*7f2fe78bSCy Schubert ); 3329*7f2fe78bSCy Schubert } 3330*7f2fe78bSCy Schubert} ); 3331*7f2fe78bSCy Schubert 3332*7f2fe78bSCy Schubertfunction sibling( cur, dir ) { 3333*7f2fe78bSCy Schubert while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {} 3334*7f2fe78bSCy Schubert return cur; 3335*7f2fe78bSCy Schubert} 3336*7f2fe78bSCy Schubert 3337*7f2fe78bSCy SchubertjQuery.each( { 3338*7f2fe78bSCy Schubert parent: function( elem ) { 3339*7f2fe78bSCy Schubert var parent = elem.parentNode; 3340*7f2fe78bSCy Schubert return parent && parent.nodeType !== 11 ? parent : null; 3341*7f2fe78bSCy Schubert }, 3342*7f2fe78bSCy Schubert parents: function( elem ) { 3343*7f2fe78bSCy Schubert return dir( elem, "parentNode" ); 3344*7f2fe78bSCy Schubert }, 3345*7f2fe78bSCy Schubert parentsUntil: function( elem, _i, until ) { 3346*7f2fe78bSCy Schubert return dir( elem, "parentNode", until ); 3347*7f2fe78bSCy Schubert }, 3348*7f2fe78bSCy Schubert next: function( elem ) { 3349*7f2fe78bSCy Schubert return sibling( elem, "nextSibling" ); 3350*7f2fe78bSCy Schubert }, 3351*7f2fe78bSCy Schubert prev: function( elem ) { 3352*7f2fe78bSCy Schubert return sibling( elem, "previousSibling" ); 3353*7f2fe78bSCy Schubert }, 3354*7f2fe78bSCy Schubert nextAll: function( elem ) { 3355*7f2fe78bSCy Schubert return dir( elem, "nextSibling" ); 3356*7f2fe78bSCy Schubert }, 3357*7f2fe78bSCy Schubert prevAll: function( elem ) { 3358*7f2fe78bSCy Schubert return dir( elem, "previousSibling" ); 3359*7f2fe78bSCy Schubert }, 3360*7f2fe78bSCy Schubert nextUntil: function( elem, _i, until ) { 3361*7f2fe78bSCy Schubert return dir( elem, "nextSibling", until ); 3362*7f2fe78bSCy Schubert }, 3363*7f2fe78bSCy Schubert prevUntil: function( elem, _i, until ) { 3364*7f2fe78bSCy Schubert return dir( elem, "previousSibling", until ); 3365*7f2fe78bSCy Schubert }, 3366*7f2fe78bSCy Schubert siblings: function( elem ) { 3367*7f2fe78bSCy Schubert return siblings( ( elem.parentNode || {} ).firstChild, elem ); 3368*7f2fe78bSCy Schubert }, 3369*7f2fe78bSCy Schubert children: function( elem ) { 3370*7f2fe78bSCy Schubert return siblings( elem.firstChild ); 3371*7f2fe78bSCy Schubert }, 3372*7f2fe78bSCy Schubert contents: function( elem ) { 3373*7f2fe78bSCy Schubert if ( elem.contentDocument != null && 3374*7f2fe78bSCy Schubert 3375*7f2fe78bSCy Schubert // Support: IE 11+ 3376*7f2fe78bSCy Schubert // <object> elements with no `data` attribute has an object 3377*7f2fe78bSCy Schubert // `contentDocument` with a `null` prototype. 3378*7f2fe78bSCy Schubert getProto( elem.contentDocument ) ) { 3379*7f2fe78bSCy Schubert 3380*7f2fe78bSCy Schubert return elem.contentDocument; 3381*7f2fe78bSCy Schubert } 3382*7f2fe78bSCy Schubert 3383*7f2fe78bSCy Schubert // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only 3384*7f2fe78bSCy Schubert // Treat the template element as a regular one in browsers that 3385*7f2fe78bSCy Schubert // don't support it. 3386*7f2fe78bSCy Schubert if ( nodeName( elem, "template" ) ) { 3387*7f2fe78bSCy Schubert elem = elem.content || elem; 3388*7f2fe78bSCy Schubert } 3389*7f2fe78bSCy Schubert 3390*7f2fe78bSCy Schubert return jQuery.merge( [], elem.childNodes ); 3391*7f2fe78bSCy Schubert } 3392*7f2fe78bSCy Schubert}, function( name, fn ) { 3393*7f2fe78bSCy Schubert jQuery.fn[ name ] = function( until, selector ) { 3394*7f2fe78bSCy Schubert var matched = jQuery.map( this, fn, until ); 3395*7f2fe78bSCy Schubert 3396*7f2fe78bSCy Schubert if ( name.slice( -5 ) !== "Until" ) { 3397*7f2fe78bSCy Schubert selector = until; 3398*7f2fe78bSCy Schubert } 3399*7f2fe78bSCy Schubert 3400*7f2fe78bSCy Schubert if ( selector && typeof selector === "string" ) { 3401*7f2fe78bSCy Schubert matched = jQuery.filter( selector, matched ); 3402*7f2fe78bSCy Schubert } 3403*7f2fe78bSCy Schubert 3404*7f2fe78bSCy Schubert if ( this.length > 1 ) { 3405*7f2fe78bSCy Schubert 3406*7f2fe78bSCy Schubert // Remove duplicates 3407*7f2fe78bSCy Schubert if ( !guaranteedUnique[ name ] ) { 3408*7f2fe78bSCy Schubert jQuery.uniqueSort( matched ); 3409*7f2fe78bSCy Schubert } 3410*7f2fe78bSCy Schubert 3411*7f2fe78bSCy Schubert // Reverse order for parents* and prev-derivatives 3412*7f2fe78bSCy Schubert if ( rparentsprev.test( name ) ) { 3413*7f2fe78bSCy Schubert matched.reverse(); 3414*7f2fe78bSCy Schubert } 3415*7f2fe78bSCy Schubert } 3416*7f2fe78bSCy Schubert 3417*7f2fe78bSCy Schubert return this.pushStack( matched ); 3418*7f2fe78bSCy Schubert }; 3419*7f2fe78bSCy Schubert} ); 3420*7f2fe78bSCy Schubertvar rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g ); 3421*7f2fe78bSCy Schubert 3422*7f2fe78bSCy Schubert 3423*7f2fe78bSCy Schubert 3424*7f2fe78bSCy Schubert// Convert String-formatted options into Object-formatted ones 3425*7f2fe78bSCy Schubertfunction createOptions( options ) { 3426*7f2fe78bSCy Schubert var object = {}; 3427*7f2fe78bSCy Schubert jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) { 3428*7f2fe78bSCy Schubert object[ flag ] = true; 3429*7f2fe78bSCy Schubert } ); 3430*7f2fe78bSCy Schubert return object; 3431*7f2fe78bSCy Schubert} 3432*7f2fe78bSCy Schubert 3433*7f2fe78bSCy Schubert/* 3434*7f2fe78bSCy Schubert * Create a callback list using the following parameters: 3435*7f2fe78bSCy Schubert * 3436*7f2fe78bSCy Schubert * options: an optional list of space-separated options that will change how 3437*7f2fe78bSCy Schubert * the callback list behaves or a more traditional option object 3438*7f2fe78bSCy Schubert * 3439*7f2fe78bSCy Schubert * By default a callback list will act like an event callback list and can be 3440*7f2fe78bSCy Schubert * "fired" multiple times. 3441*7f2fe78bSCy Schubert * 3442*7f2fe78bSCy Schubert * Possible options: 3443*7f2fe78bSCy Schubert * 3444*7f2fe78bSCy Schubert * once: will ensure the callback list can only be fired once (like a Deferred) 3445*7f2fe78bSCy Schubert * 3446*7f2fe78bSCy Schubert * memory: will keep track of previous values and will call any callback added 3447*7f2fe78bSCy Schubert * after the list has been fired right away with the latest "memorized" 3448*7f2fe78bSCy Schubert * values (like a Deferred) 3449*7f2fe78bSCy Schubert * 3450*7f2fe78bSCy Schubert * unique: will ensure a callback can only be added once (no duplicate in the list) 3451*7f2fe78bSCy Schubert * 3452*7f2fe78bSCy Schubert * stopOnFalse: interrupt callings when a callback returns false 3453*7f2fe78bSCy Schubert * 3454*7f2fe78bSCy Schubert */ 3455*7f2fe78bSCy SchubertjQuery.Callbacks = function( options ) { 3456*7f2fe78bSCy Schubert 3457*7f2fe78bSCy Schubert // Convert options from String-formatted to Object-formatted if needed 3458*7f2fe78bSCy Schubert // (we check in cache first) 3459*7f2fe78bSCy Schubert options = typeof options === "string" ? 3460*7f2fe78bSCy Schubert createOptions( options ) : 3461*7f2fe78bSCy Schubert jQuery.extend( {}, options ); 3462*7f2fe78bSCy Schubert 3463*7f2fe78bSCy Schubert var // Flag to know if list is currently firing 3464*7f2fe78bSCy Schubert firing, 3465*7f2fe78bSCy Schubert 3466*7f2fe78bSCy Schubert // Last fire value for non-forgettable lists 3467*7f2fe78bSCy Schubert memory, 3468*7f2fe78bSCy Schubert 3469*7f2fe78bSCy Schubert // Flag to know if list was already fired 3470*7f2fe78bSCy Schubert fired, 3471*7f2fe78bSCy Schubert 3472*7f2fe78bSCy Schubert // Flag to prevent firing 3473*7f2fe78bSCy Schubert locked, 3474*7f2fe78bSCy Schubert 3475*7f2fe78bSCy Schubert // Actual callback list 3476*7f2fe78bSCy Schubert list = [], 3477*7f2fe78bSCy Schubert 3478*7f2fe78bSCy Schubert // Queue of execution data for repeatable lists 3479*7f2fe78bSCy Schubert queue = [], 3480*7f2fe78bSCy Schubert 3481*7f2fe78bSCy Schubert // Index of currently firing callback (modified by add/remove as needed) 3482*7f2fe78bSCy Schubert firingIndex = -1, 3483*7f2fe78bSCy Schubert 3484*7f2fe78bSCy Schubert // Fire callbacks 3485*7f2fe78bSCy Schubert fire = function() { 3486*7f2fe78bSCy Schubert 3487*7f2fe78bSCy Schubert // Enforce single-firing 3488*7f2fe78bSCy Schubert locked = locked || options.once; 3489*7f2fe78bSCy Schubert 3490*7f2fe78bSCy Schubert // Execute callbacks for all pending executions, 3491*7f2fe78bSCy Schubert // respecting firingIndex overrides and runtime changes 3492*7f2fe78bSCy Schubert fired = firing = true; 3493*7f2fe78bSCy Schubert for ( ; queue.length; firingIndex = -1 ) { 3494*7f2fe78bSCy Schubert memory = queue.shift(); 3495*7f2fe78bSCy Schubert while ( ++firingIndex < list.length ) { 3496*7f2fe78bSCy Schubert 3497*7f2fe78bSCy Schubert // Run callback and check for early termination 3498*7f2fe78bSCy Schubert if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false && 3499*7f2fe78bSCy Schubert options.stopOnFalse ) { 3500*7f2fe78bSCy Schubert 3501*7f2fe78bSCy Schubert // Jump to end and forget the data so .add doesn't re-fire 3502*7f2fe78bSCy Schubert firingIndex = list.length; 3503*7f2fe78bSCy Schubert memory = false; 3504*7f2fe78bSCy Schubert } 3505*7f2fe78bSCy Schubert } 3506*7f2fe78bSCy Schubert } 3507*7f2fe78bSCy Schubert 3508*7f2fe78bSCy Schubert // Forget the data if we're done with it 3509*7f2fe78bSCy Schubert if ( !options.memory ) { 3510*7f2fe78bSCy Schubert memory = false; 3511*7f2fe78bSCy Schubert } 3512*7f2fe78bSCy Schubert 3513*7f2fe78bSCy Schubert firing = false; 3514*7f2fe78bSCy Schubert 3515*7f2fe78bSCy Schubert // Clean up if we're done firing for good 3516*7f2fe78bSCy Schubert if ( locked ) { 3517*7f2fe78bSCy Schubert 3518*7f2fe78bSCy Schubert // Keep an empty list if we have data for future add calls 3519*7f2fe78bSCy Schubert if ( memory ) { 3520*7f2fe78bSCy Schubert list = []; 3521*7f2fe78bSCy Schubert 3522*7f2fe78bSCy Schubert // Otherwise, this object is spent 3523*7f2fe78bSCy Schubert } else { 3524*7f2fe78bSCy Schubert list = ""; 3525*7f2fe78bSCy Schubert } 3526*7f2fe78bSCy Schubert } 3527*7f2fe78bSCy Schubert }, 3528*7f2fe78bSCy Schubert 3529*7f2fe78bSCy Schubert // Actual Callbacks object 3530*7f2fe78bSCy Schubert self = { 3531*7f2fe78bSCy Schubert 3532*7f2fe78bSCy Schubert // Add a callback or a collection of callbacks to the list 3533*7f2fe78bSCy Schubert add: function() { 3534*7f2fe78bSCy Schubert if ( list ) { 3535*7f2fe78bSCy Schubert 3536*7f2fe78bSCy Schubert // If we have memory from a past run, we should fire after adding 3537*7f2fe78bSCy Schubert if ( memory && !firing ) { 3538*7f2fe78bSCy Schubert firingIndex = list.length - 1; 3539*7f2fe78bSCy Schubert queue.push( memory ); 3540*7f2fe78bSCy Schubert } 3541*7f2fe78bSCy Schubert 3542*7f2fe78bSCy Schubert ( function add( args ) { 3543*7f2fe78bSCy Schubert jQuery.each( args, function( _, arg ) { 3544*7f2fe78bSCy Schubert if ( isFunction( arg ) ) { 3545*7f2fe78bSCy Schubert if ( !options.unique || !self.has( arg ) ) { 3546*7f2fe78bSCy Schubert list.push( arg ); 3547*7f2fe78bSCy Schubert } 3548*7f2fe78bSCy Schubert } else if ( arg && arg.length && toType( arg ) !== "string" ) { 3549*7f2fe78bSCy Schubert 3550*7f2fe78bSCy Schubert // Inspect recursively 3551*7f2fe78bSCy Schubert add( arg ); 3552*7f2fe78bSCy Schubert } 3553*7f2fe78bSCy Schubert } ); 3554*7f2fe78bSCy Schubert } )( arguments ); 3555*7f2fe78bSCy Schubert 3556*7f2fe78bSCy Schubert if ( memory && !firing ) { 3557*7f2fe78bSCy Schubert fire(); 3558*7f2fe78bSCy Schubert } 3559*7f2fe78bSCy Schubert } 3560*7f2fe78bSCy Schubert return this; 3561*7f2fe78bSCy Schubert }, 3562*7f2fe78bSCy Schubert 3563*7f2fe78bSCy Schubert // Remove a callback from the list 3564*7f2fe78bSCy Schubert remove: function() { 3565*7f2fe78bSCy Schubert jQuery.each( arguments, function( _, arg ) { 3566*7f2fe78bSCy Schubert var index; 3567*7f2fe78bSCy Schubert while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { 3568*7f2fe78bSCy Schubert list.splice( index, 1 ); 3569*7f2fe78bSCy Schubert 3570*7f2fe78bSCy Schubert // Handle firing indexes 3571*7f2fe78bSCy Schubert if ( index <= firingIndex ) { 3572*7f2fe78bSCy Schubert firingIndex--; 3573*7f2fe78bSCy Schubert } 3574*7f2fe78bSCy Schubert } 3575*7f2fe78bSCy Schubert } ); 3576*7f2fe78bSCy Schubert return this; 3577*7f2fe78bSCy Schubert }, 3578*7f2fe78bSCy Schubert 3579*7f2fe78bSCy Schubert // Check if a given callback is in the list. 3580*7f2fe78bSCy Schubert // If no argument is given, return whether or not list has callbacks attached. 3581*7f2fe78bSCy Schubert has: function( fn ) { 3582*7f2fe78bSCy Schubert return fn ? 3583*7f2fe78bSCy Schubert jQuery.inArray( fn, list ) > -1 : 3584*7f2fe78bSCy Schubert list.length > 0; 3585*7f2fe78bSCy Schubert }, 3586*7f2fe78bSCy Schubert 3587*7f2fe78bSCy Schubert // Remove all callbacks from the list 3588*7f2fe78bSCy Schubert empty: function() { 3589*7f2fe78bSCy Schubert if ( list ) { 3590*7f2fe78bSCy Schubert list = []; 3591*7f2fe78bSCy Schubert } 3592*7f2fe78bSCy Schubert return this; 3593*7f2fe78bSCy Schubert }, 3594*7f2fe78bSCy Schubert 3595*7f2fe78bSCy Schubert // Disable .fire and .add 3596*7f2fe78bSCy Schubert // Abort any current/pending executions 3597*7f2fe78bSCy Schubert // Clear all callbacks and values 3598*7f2fe78bSCy Schubert disable: function() { 3599*7f2fe78bSCy Schubert locked = queue = []; 3600*7f2fe78bSCy Schubert list = memory = ""; 3601*7f2fe78bSCy Schubert return this; 3602*7f2fe78bSCy Schubert }, 3603*7f2fe78bSCy Schubert disabled: function() { 3604*7f2fe78bSCy Schubert return !list; 3605*7f2fe78bSCy Schubert }, 3606*7f2fe78bSCy Schubert 3607*7f2fe78bSCy Schubert // Disable .fire 3608*7f2fe78bSCy Schubert // Also disable .add unless we have memory (since it would have no effect) 3609*7f2fe78bSCy Schubert // Abort any pending executions 3610*7f2fe78bSCy Schubert lock: function() { 3611*7f2fe78bSCy Schubert locked = queue = []; 3612*7f2fe78bSCy Schubert if ( !memory && !firing ) { 3613*7f2fe78bSCy Schubert list = memory = ""; 3614*7f2fe78bSCy Schubert } 3615*7f2fe78bSCy Schubert return this; 3616*7f2fe78bSCy Schubert }, 3617*7f2fe78bSCy Schubert locked: function() { 3618*7f2fe78bSCy Schubert return !!locked; 3619*7f2fe78bSCy Schubert }, 3620*7f2fe78bSCy Schubert 3621*7f2fe78bSCy Schubert // Call all callbacks with the given context and arguments 3622*7f2fe78bSCy Schubert fireWith: function( context, args ) { 3623*7f2fe78bSCy Schubert if ( !locked ) { 3624*7f2fe78bSCy Schubert args = args || []; 3625*7f2fe78bSCy Schubert args = [ context, args.slice ? args.slice() : args ]; 3626*7f2fe78bSCy Schubert queue.push( args ); 3627*7f2fe78bSCy Schubert if ( !firing ) { 3628*7f2fe78bSCy Schubert fire(); 3629*7f2fe78bSCy Schubert } 3630*7f2fe78bSCy Schubert } 3631*7f2fe78bSCy Schubert return this; 3632*7f2fe78bSCy Schubert }, 3633*7f2fe78bSCy Schubert 3634*7f2fe78bSCy Schubert // Call all the callbacks with the given arguments 3635*7f2fe78bSCy Schubert fire: function() { 3636*7f2fe78bSCy Schubert self.fireWith( this, arguments ); 3637*7f2fe78bSCy Schubert return this; 3638*7f2fe78bSCy Schubert }, 3639*7f2fe78bSCy Schubert 3640*7f2fe78bSCy Schubert // To know if the callbacks have already been called at least once 3641*7f2fe78bSCy Schubert fired: function() { 3642*7f2fe78bSCy Schubert return !!fired; 3643*7f2fe78bSCy Schubert } 3644*7f2fe78bSCy Schubert }; 3645*7f2fe78bSCy Schubert 3646*7f2fe78bSCy Schubert return self; 3647*7f2fe78bSCy Schubert}; 3648*7f2fe78bSCy Schubert 3649*7f2fe78bSCy Schubert 3650*7f2fe78bSCy Schubertfunction Identity( v ) { 3651*7f2fe78bSCy Schubert return v; 3652*7f2fe78bSCy Schubert} 3653*7f2fe78bSCy Schubertfunction Thrower( ex ) { 3654*7f2fe78bSCy Schubert throw ex; 3655*7f2fe78bSCy Schubert} 3656*7f2fe78bSCy Schubert 3657*7f2fe78bSCy Schubertfunction adoptValue( value, resolve, reject, noValue ) { 3658*7f2fe78bSCy Schubert var method; 3659*7f2fe78bSCy Schubert 3660*7f2fe78bSCy Schubert try { 3661*7f2fe78bSCy Schubert 3662*7f2fe78bSCy Schubert // Check for promise aspect first to privilege synchronous behavior 3663*7f2fe78bSCy Schubert if ( value && isFunction( ( method = value.promise ) ) ) { 3664*7f2fe78bSCy Schubert method.call( value ).done( resolve ).fail( reject ); 3665*7f2fe78bSCy Schubert 3666*7f2fe78bSCy Schubert // Other thenables 3667*7f2fe78bSCy Schubert } else if ( value && isFunction( ( method = value.then ) ) ) { 3668*7f2fe78bSCy Schubert method.call( value, resolve, reject ); 3669*7f2fe78bSCy Schubert 3670*7f2fe78bSCy Schubert // Other non-thenables 3671*7f2fe78bSCy Schubert } else { 3672*7f2fe78bSCy Schubert 3673*7f2fe78bSCy Schubert // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer: 3674*7f2fe78bSCy Schubert // * false: [ value ].slice( 0 ) => resolve( value ) 3675*7f2fe78bSCy Schubert // * true: [ value ].slice( 1 ) => resolve() 3676*7f2fe78bSCy Schubert resolve.apply( undefined, [ value ].slice( noValue ) ); 3677*7f2fe78bSCy Schubert } 3678*7f2fe78bSCy Schubert 3679*7f2fe78bSCy Schubert // For Promises/A+, convert exceptions into rejections 3680*7f2fe78bSCy Schubert // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in 3681*7f2fe78bSCy Schubert // Deferred#then to conditionally suppress rejection. 3682*7f2fe78bSCy Schubert } catch ( value ) { 3683*7f2fe78bSCy Schubert 3684*7f2fe78bSCy Schubert // Support: Android 4.0 only 3685*7f2fe78bSCy Schubert // Strict mode functions invoked without .call/.apply get global-object context 3686*7f2fe78bSCy Schubert reject.apply( undefined, [ value ] ); 3687*7f2fe78bSCy Schubert } 3688*7f2fe78bSCy Schubert} 3689*7f2fe78bSCy Schubert 3690*7f2fe78bSCy SchubertjQuery.extend( { 3691*7f2fe78bSCy Schubert 3692*7f2fe78bSCy Schubert Deferred: function( func ) { 3693*7f2fe78bSCy Schubert var tuples = [ 3694*7f2fe78bSCy Schubert 3695*7f2fe78bSCy Schubert // action, add listener, callbacks, 3696*7f2fe78bSCy Schubert // ... .then handlers, argument index, [final state] 3697*7f2fe78bSCy Schubert [ "notify", "progress", jQuery.Callbacks( "memory" ), 3698*7f2fe78bSCy Schubert jQuery.Callbacks( "memory" ), 2 ], 3699*7f2fe78bSCy Schubert [ "resolve", "done", jQuery.Callbacks( "once memory" ), 3700*7f2fe78bSCy Schubert jQuery.Callbacks( "once memory" ), 0, "resolved" ], 3701*7f2fe78bSCy Schubert [ "reject", "fail", jQuery.Callbacks( "once memory" ), 3702*7f2fe78bSCy Schubert jQuery.Callbacks( "once memory" ), 1, "rejected" ] 3703*7f2fe78bSCy Schubert ], 3704*7f2fe78bSCy Schubert state = "pending", 3705*7f2fe78bSCy Schubert promise = { 3706*7f2fe78bSCy Schubert state: function() { 3707*7f2fe78bSCy Schubert return state; 3708*7f2fe78bSCy Schubert }, 3709*7f2fe78bSCy Schubert always: function() { 3710*7f2fe78bSCy Schubert deferred.done( arguments ).fail( arguments ); 3711*7f2fe78bSCy Schubert return this; 3712*7f2fe78bSCy Schubert }, 3713*7f2fe78bSCy Schubert "catch": function( fn ) { 3714*7f2fe78bSCy Schubert return promise.then( null, fn ); 3715*7f2fe78bSCy Schubert }, 3716*7f2fe78bSCy Schubert 3717*7f2fe78bSCy Schubert // Keep pipe for back-compat 3718*7f2fe78bSCy Schubert pipe: function( /* fnDone, fnFail, fnProgress */ ) { 3719*7f2fe78bSCy Schubert var fns = arguments; 3720*7f2fe78bSCy Schubert 3721*7f2fe78bSCy Schubert return jQuery.Deferred( function( newDefer ) { 3722*7f2fe78bSCy Schubert jQuery.each( tuples, function( _i, tuple ) { 3723*7f2fe78bSCy Schubert 3724*7f2fe78bSCy Schubert // Map tuples (progress, done, fail) to arguments (done, fail, progress) 3725*7f2fe78bSCy Schubert var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ]; 3726*7f2fe78bSCy Schubert 3727*7f2fe78bSCy Schubert // deferred.progress(function() { bind to newDefer or newDefer.notify }) 3728*7f2fe78bSCy Schubert // deferred.done(function() { bind to newDefer or newDefer.resolve }) 3729*7f2fe78bSCy Schubert // deferred.fail(function() { bind to newDefer or newDefer.reject }) 3730*7f2fe78bSCy Schubert deferred[ tuple[ 1 ] ]( function() { 3731*7f2fe78bSCy Schubert var returned = fn && fn.apply( this, arguments ); 3732*7f2fe78bSCy Schubert if ( returned && isFunction( returned.promise ) ) { 3733*7f2fe78bSCy Schubert returned.promise() 3734*7f2fe78bSCy Schubert .progress( newDefer.notify ) 3735*7f2fe78bSCy Schubert .done( newDefer.resolve ) 3736*7f2fe78bSCy Schubert .fail( newDefer.reject ); 3737*7f2fe78bSCy Schubert } else { 3738*7f2fe78bSCy Schubert newDefer[ tuple[ 0 ] + "With" ]( 3739*7f2fe78bSCy Schubert this, 3740*7f2fe78bSCy Schubert fn ? [ returned ] : arguments 3741*7f2fe78bSCy Schubert ); 3742*7f2fe78bSCy Schubert } 3743*7f2fe78bSCy Schubert } ); 3744*7f2fe78bSCy Schubert } ); 3745*7f2fe78bSCy Schubert fns = null; 3746*7f2fe78bSCy Schubert } ).promise(); 3747*7f2fe78bSCy Schubert }, 3748*7f2fe78bSCy Schubert then: function( onFulfilled, onRejected, onProgress ) { 3749*7f2fe78bSCy Schubert var maxDepth = 0; 3750*7f2fe78bSCy Schubert function resolve( depth, deferred, handler, special ) { 3751*7f2fe78bSCy Schubert return function() { 3752*7f2fe78bSCy Schubert var that = this, 3753*7f2fe78bSCy Schubert args = arguments, 3754*7f2fe78bSCy Schubert mightThrow = function() { 3755*7f2fe78bSCy Schubert var returned, then; 3756*7f2fe78bSCy Schubert 3757*7f2fe78bSCy Schubert // Support: Promises/A+ section 2.3.3.3.3 3758*7f2fe78bSCy Schubert // https://promisesaplus.com/#point-59 3759*7f2fe78bSCy Schubert // Ignore double-resolution attempts 3760*7f2fe78bSCy Schubert if ( depth < maxDepth ) { 3761*7f2fe78bSCy Schubert return; 3762*7f2fe78bSCy Schubert } 3763*7f2fe78bSCy Schubert 3764*7f2fe78bSCy Schubert returned = handler.apply( that, args ); 3765*7f2fe78bSCy Schubert 3766*7f2fe78bSCy Schubert // Support: Promises/A+ section 2.3.1 3767*7f2fe78bSCy Schubert // https://promisesaplus.com/#point-48 3768*7f2fe78bSCy Schubert if ( returned === deferred.promise() ) { 3769*7f2fe78bSCy Schubert throw new TypeError( "Thenable self-resolution" ); 3770*7f2fe78bSCy Schubert } 3771*7f2fe78bSCy Schubert 3772*7f2fe78bSCy Schubert // Support: Promises/A+ sections 2.3.3.1, 3.5 3773*7f2fe78bSCy Schubert // https://promisesaplus.com/#point-54 3774*7f2fe78bSCy Schubert // https://promisesaplus.com/#point-75 3775*7f2fe78bSCy Schubert // Retrieve `then` only once 3776*7f2fe78bSCy Schubert then = returned && 3777*7f2fe78bSCy Schubert 3778*7f2fe78bSCy Schubert // Support: Promises/A+ section 2.3.4 3779*7f2fe78bSCy Schubert // https://promisesaplus.com/#point-64 3780*7f2fe78bSCy Schubert // Only check objects and functions for thenability 3781*7f2fe78bSCy Schubert ( typeof returned === "object" || 3782*7f2fe78bSCy Schubert typeof returned === "function" ) && 3783*7f2fe78bSCy Schubert returned.then; 3784*7f2fe78bSCy Schubert 3785*7f2fe78bSCy Schubert // Handle a returned thenable 3786*7f2fe78bSCy Schubert if ( isFunction( then ) ) { 3787*7f2fe78bSCy Schubert 3788*7f2fe78bSCy Schubert // Special processors (notify) just wait for resolution 3789*7f2fe78bSCy Schubert if ( special ) { 3790*7f2fe78bSCy Schubert then.call( 3791*7f2fe78bSCy Schubert returned, 3792*7f2fe78bSCy Schubert resolve( maxDepth, deferred, Identity, special ), 3793*7f2fe78bSCy Schubert resolve( maxDepth, deferred, Thrower, special ) 3794*7f2fe78bSCy Schubert ); 3795*7f2fe78bSCy Schubert 3796*7f2fe78bSCy Schubert // Normal processors (resolve) also hook into progress 3797*7f2fe78bSCy Schubert } else { 3798*7f2fe78bSCy Schubert 3799*7f2fe78bSCy Schubert // ...and disregard older resolution values 3800*7f2fe78bSCy Schubert maxDepth++; 3801*7f2fe78bSCy Schubert 3802*7f2fe78bSCy Schubert then.call( 3803*7f2fe78bSCy Schubert returned, 3804*7f2fe78bSCy Schubert resolve( maxDepth, deferred, Identity, special ), 3805*7f2fe78bSCy Schubert resolve( maxDepth, deferred, Thrower, special ), 3806*7f2fe78bSCy Schubert resolve( maxDepth, deferred, Identity, 3807*7f2fe78bSCy Schubert deferred.notifyWith ) 3808*7f2fe78bSCy Schubert ); 3809*7f2fe78bSCy Schubert } 3810*7f2fe78bSCy Schubert 3811*7f2fe78bSCy Schubert // Handle all other returned values 3812*7f2fe78bSCy Schubert } else { 3813*7f2fe78bSCy Schubert 3814*7f2fe78bSCy Schubert // Only substitute handlers pass on context 3815*7f2fe78bSCy Schubert // and multiple values (non-spec behavior) 3816*7f2fe78bSCy Schubert if ( handler !== Identity ) { 3817*7f2fe78bSCy Schubert that = undefined; 3818*7f2fe78bSCy Schubert args = [ returned ]; 3819*7f2fe78bSCy Schubert } 3820*7f2fe78bSCy Schubert 3821*7f2fe78bSCy Schubert // Process the value(s) 3822*7f2fe78bSCy Schubert // Default process is resolve 3823*7f2fe78bSCy Schubert ( special || deferred.resolveWith )( that, args ); 3824*7f2fe78bSCy Schubert } 3825*7f2fe78bSCy Schubert }, 3826*7f2fe78bSCy Schubert 3827*7f2fe78bSCy Schubert // Only normal processors (resolve) catch and reject exceptions 3828*7f2fe78bSCy Schubert process = special ? 3829*7f2fe78bSCy Schubert mightThrow : 3830*7f2fe78bSCy Schubert function() { 3831*7f2fe78bSCy Schubert try { 3832*7f2fe78bSCy Schubert mightThrow(); 3833*7f2fe78bSCy Schubert } catch ( e ) { 3834*7f2fe78bSCy Schubert 3835*7f2fe78bSCy Schubert if ( jQuery.Deferred.exceptionHook ) { 3836*7f2fe78bSCy Schubert jQuery.Deferred.exceptionHook( e, 3837*7f2fe78bSCy Schubert process.stackTrace ); 3838*7f2fe78bSCy Schubert } 3839*7f2fe78bSCy Schubert 3840*7f2fe78bSCy Schubert // Support: Promises/A+ section 2.3.3.3.4.1 3841*7f2fe78bSCy Schubert // https://promisesaplus.com/#point-61 3842*7f2fe78bSCy Schubert // Ignore post-resolution exceptions 3843*7f2fe78bSCy Schubert if ( depth + 1 >= maxDepth ) { 3844*7f2fe78bSCy Schubert 3845*7f2fe78bSCy Schubert // Only substitute handlers pass on context 3846*7f2fe78bSCy Schubert // and multiple values (non-spec behavior) 3847*7f2fe78bSCy Schubert if ( handler !== Thrower ) { 3848*7f2fe78bSCy Schubert that = undefined; 3849*7f2fe78bSCy Schubert args = [ e ]; 3850*7f2fe78bSCy Schubert } 3851*7f2fe78bSCy Schubert 3852*7f2fe78bSCy Schubert deferred.rejectWith( that, args ); 3853*7f2fe78bSCy Schubert } 3854*7f2fe78bSCy Schubert } 3855*7f2fe78bSCy Schubert }; 3856*7f2fe78bSCy Schubert 3857*7f2fe78bSCy Schubert // Support: Promises/A+ section 2.3.3.3.1 3858*7f2fe78bSCy Schubert // https://promisesaplus.com/#point-57 3859*7f2fe78bSCy Schubert // Re-resolve promises immediately to dodge false rejection from 3860*7f2fe78bSCy Schubert // subsequent errors 3861*7f2fe78bSCy Schubert if ( depth ) { 3862*7f2fe78bSCy Schubert process(); 3863*7f2fe78bSCy Schubert } else { 3864*7f2fe78bSCy Schubert 3865*7f2fe78bSCy Schubert // Call an optional hook to record the stack, in case of exception 3866*7f2fe78bSCy Schubert // since it's otherwise lost when execution goes async 3867*7f2fe78bSCy Schubert if ( jQuery.Deferred.getStackHook ) { 3868*7f2fe78bSCy Schubert process.stackTrace = jQuery.Deferred.getStackHook(); 3869*7f2fe78bSCy Schubert } 3870*7f2fe78bSCy Schubert window.setTimeout( process ); 3871*7f2fe78bSCy Schubert } 3872*7f2fe78bSCy Schubert }; 3873*7f2fe78bSCy Schubert } 3874*7f2fe78bSCy Schubert 3875*7f2fe78bSCy Schubert return jQuery.Deferred( function( newDefer ) { 3876*7f2fe78bSCy Schubert 3877*7f2fe78bSCy Schubert // progress_handlers.add( ... ) 3878*7f2fe78bSCy Schubert tuples[ 0 ][ 3 ].add( 3879*7f2fe78bSCy Schubert resolve( 3880*7f2fe78bSCy Schubert 0, 3881*7f2fe78bSCy Schubert newDefer, 3882*7f2fe78bSCy Schubert isFunction( onProgress ) ? 3883*7f2fe78bSCy Schubert onProgress : 3884*7f2fe78bSCy Schubert Identity, 3885*7f2fe78bSCy Schubert newDefer.notifyWith 3886*7f2fe78bSCy Schubert ) 3887*7f2fe78bSCy Schubert ); 3888*7f2fe78bSCy Schubert 3889*7f2fe78bSCy Schubert // fulfilled_handlers.add( ... ) 3890*7f2fe78bSCy Schubert tuples[ 1 ][ 3 ].add( 3891*7f2fe78bSCy Schubert resolve( 3892*7f2fe78bSCy Schubert 0, 3893*7f2fe78bSCy Schubert newDefer, 3894*7f2fe78bSCy Schubert isFunction( onFulfilled ) ? 3895*7f2fe78bSCy Schubert onFulfilled : 3896*7f2fe78bSCy Schubert Identity 3897*7f2fe78bSCy Schubert ) 3898*7f2fe78bSCy Schubert ); 3899*7f2fe78bSCy Schubert 3900*7f2fe78bSCy Schubert // rejected_handlers.add( ... ) 3901*7f2fe78bSCy Schubert tuples[ 2 ][ 3 ].add( 3902*7f2fe78bSCy Schubert resolve( 3903*7f2fe78bSCy Schubert 0, 3904*7f2fe78bSCy Schubert newDefer, 3905*7f2fe78bSCy Schubert isFunction( onRejected ) ? 3906*7f2fe78bSCy Schubert onRejected : 3907*7f2fe78bSCy Schubert Thrower 3908*7f2fe78bSCy Schubert ) 3909*7f2fe78bSCy Schubert ); 3910*7f2fe78bSCy Schubert } ).promise(); 3911*7f2fe78bSCy Schubert }, 3912*7f2fe78bSCy Schubert 3913*7f2fe78bSCy Schubert // Get a promise for this deferred 3914*7f2fe78bSCy Schubert // If obj is provided, the promise aspect is added to the object 3915*7f2fe78bSCy Schubert promise: function( obj ) { 3916*7f2fe78bSCy Schubert return obj != null ? jQuery.extend( obj, promise ) : promise; 3917*7f2fe78bSCy Schubert } 3918*7f2fe78bSCy Schubert }, 3919*7f2fe78bSCy Schubert deferred = {}; 3920*7f2fe78bSCy Schubert 3921*7f2fe78bSCy Schubert // Add list-specific methods 3922*7f2fe78bSCy Schubert jQuery.each( tuples, function( i, tuple ) { 3923*7f2fe78bSCy Schubert var list = tuple[ 2 ], 3924*7f2fe78bSCy Schubert stateString = tuple[ 5 ]; 3925*7f2fe78bSCy Schubert 3926*7f2fe78bSCy Schubert // promise.progress = list.add 3927*7f2fe78bSCy Schubert // promise.done = list.add 3928*7f2fe78bSCy Schubert // promise.fail = list.add 3929*7f2fe78bSCy Schubert promise[ tuple[ 1 ] ] = list.add; 3930*7f2fe78bSCy Schubert 3931*7f2fe78bSCy Schubert // Handle state 3932*7f2fe78bSCy Schubert if ( stateString ) { 3933*7f2fe78bSCy Schubert list.add( 3934*7f2fe78bSCy Schubert function() { 3935*7f2fe78bSCy Schubert 3936*7f2fe78bSCy Schubert // state = "resolved" (i.e., fulfilled) 3937*7f2fe78bSCy Schubert // state = "rejected" 3938*7f2fe78bSCy Schubert state = stateString; 3939*7f2fe78bSCy Schubert }, 3940*7f2fe78bSCy Schubert 3941*7f2fe78bSCy Schubert // rejected_callbacks.disable 3942*7f2fe78bSCy Schubert // fulfilled_callbacks.disable 3943*7f2fe78bSCy Schubert tuples[ 3 - i ][ 2 ].disable, 3944*7f2fe78bSCy Schubert 3945*7f2fe78bSCy Schubert // rejected_handlers.disable 3946*7f2fe78bSCy Schubert // fulfilled_handlers.disable 3947*7f2fe78bSCy Schubert tuples[ 3 - i ][ 3 ].disable, 3948*7f2fe78bSCy Schubert 3949*7f2fe78bSCy Schubert // progress_callbacks.lock 3950*7f2fe78bSCy Schubert tuples[ 0 ][ 2 ].lock, 3951*7f2fe78bSCy Schubert 3952*7f2fe78bSCy Schubert // progress_handlers.lock 3953*7f2fe78bSCy Schubert tuples[ 0 ][ 3 ].lock 3954*7f2fe78bSCy Schubert ); 3955*7f2fe78bSCy Schubert } 3956*7f2fe78bSCy Schubert 3957*7f2fe78bSCy Schubert // progress_handlers.fire 3958*7f2fe78bSCy Schubert // fulfilled_handlers.fire 3959*7f2fe78bSCy Schubert // rejected_handlers.fire 3960*7f2fe78bSCy Schubert list.add( tuple[ 3 ].fire ); 3961*7f2fe78bSCy Schubert 3962*7f2fe78bSCy Schubert // deferred.notify = function() { deferred.notifyWith(...) } 3963*7f2fe78bSCy Schubert // deferred.resolve = function() { deferred.resolveWith(...) } 3964*7f2fe78bSCy Schubert // deferred.reject = function() { deferred.rejectWith(...) } 3965*7f2fe78bSCy Schubert deferred[ tuple[ 0 ] ] = function() { 3966*7f2fe78bSCy Schubert deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments ); 3967*7f2fe78bSCy Schubert return this; 3968*7f2fe78bSCy Schubert }; 3969*7f2fe78bSCy Schubert 3970*7f2fe78bSCy Schubert // deferred.notifyWith = list.fireWith 3971*7f2fe78bSCy Schubert // deferred.resolveWith = list.fireWith 3972*7f2fe78bSCy Schubert // deferred.rejectWith = list.fireWith 3973*7f2fe78bSCy Schubert deferred[ tuple[ 0 ] + "With" ] = list.fireWith; 3974*7f2fe78bSCy Schubert } ); 3975*7f2fe78bSCy Schubert 3976*7f2fe78bSCy Schubert // Make the deferred a promise 3977*7f2fe78bSCy Schubert promise.promise( deferred ); 3978*7f2fe78bSCy Schubert 3979*7f2fe78bSCy Schubert // Call given func if any 3980*7f2fe78bSCy Schubert if ( func ) { 3981*7f2fe78bSCy Schubert func.call( deferred, deferred ); 3982*7f2fe78bSCy Schubert } 3983*7f2fe78bSCy Schubert 3984*7f2fe78bSCy Schubert // All done! 3985*7f2fe78bSCy Schubert return deferred; 3986*7f2fe78bSCy Schubert }, 3987*7f2fe78bSCy Schubert 3988*7f2fe78bSCy Schubert // Deferred helper 3989*7f2fe78bSCy Schubert when: function( singleValue ) { 3990*7f2fe78bSCy Schubert var 3991*7f2fe78bSCy Schubert 3992*7f2fe78bSCy Schubert // count of uncompleted subordinates 3993*7f2fe78bSCy Schubert remaining = arguments.length, 3994*7f2fe78bSCy Schubert 3995*7f2fe78bSCy Schubert // count of unprocessed arguments 3996*7f2fe78bSCy Schubert i = remaining, 3997*7f2fe78bSCy Schubert 3998*7f2fe78bSCy Schubert // subordinate fulfillment data 3999*7f2fe78bSCy Schubert resolveContexts = Array( i ), 4000*7f2fe78bSCy Schubert resolveValues = slice.call( arguments ), 4001*7f2fe78bSCy Schubert 4002*7f2fe78bSCy Schubert // the primary Deferred 4003*7f2fe78bSCy Schubert primary = jQuery.Deferred(), 4004*7f2fe78bSCy Schubert 4005*7f2fe78bSCy Schubert // subordinate callback factory 4006*7f2fe78bSCy Schubert updateFunc = function( i ) { 4007*7f2fe78bSCy Schubert return function( value ) { 4008*7f2fe78bSCy Schubert resolveContexts[ i ] = this; 4009*7f2fe78bSCy Schubert resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value; 4010*7f2fe78bSCy Schubert if ( !( --remaining ) ) { 4011*7f2fe78bSCy Schubert primary.resolveWith( resolveContexts, resolveValues ); 4012*7f2fe78bSCy Schubert } 4013*7f2fe78bSCy Schubert }; 4014*7f2fe78bSCy Schubert }; 4015*7f2fe78bSCy Schubert 4016*7f2fe78bSCy Schubert // Single- and empty arguments are adopted like Promise.resolve 4017*7f2fe78bSCy Schubert if ( remaining <= 1 ) { 4018*7f2fe78bSCy Schubert adoptValue( singleValue, primary.done( updateFunc( i ) ).resolve, primary.reject, 4019*7f2fe78bSCy Schubert !remaining ); 4020*7f2fe78bSCy Schubert 4021*7f2fe78bSCy Schubert // Use .then() to unwrap secondary thenables (cf. gh-3000) 4022*7f2fe78bSCy Schubert if ( primary.state() === "pending" || 4023*7f2fe78bSCy Schubert isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) { 4024*7f2fe78bSCy Schubert 4025*7f2fe78bSCy Schubert return primary.then(); 4026*7f2fe78bSCy Schubert } 4027*7f2fe78bSCy Schubert } 4028*7f2fe78bSCy Schubert 4029*7f2fe78bSCy Schubert // Multiple arguments are aggregated like Promise.all array elements 4030*7f2fe78bSCy Schubert while ( i-- ) { 4031*7f2fe78bSCy Schubert adoptValue( resolveValues[ i ], updateFunc( i ), primary.reject ); 4032*7f2fe78bSCy Schubert } 4033*7f2fe78bSCy Schubert 4034*7f2fe78bSCy Schubert return primary.promise(); 4035*7f2fe78bSCy Schubert } 4036*7f2fe78bSCy Schubert} ); 4037*7f2fe78bSCy Schubert 4038*7f2fe78bSCy Schubert 4039*7f2fe78bSCy Schubert// These usually indicate a programmer mistake during development, 4040*7f2fe78bSCy Schubert// warn about them ASAP rather than swallowing them by default. 4041*7f2fe78bSCy Schubertvar rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/; 4042*7f2fe78bSCy Schubert 4043*7f2fe78bSCy SchubertjQuery.Deferred.exceptionHook = function( error, stack ) { 4044*7f2fe78bSCy Schubert 4045*7f2fe78bSCy Schubert // Support: IE 8 - 9 only 4046*7f2fe78bSCy Schubert // Console exists when dev tools are open, which can happen at any time 4047*7f2fe78bSCy Schubert if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) { 4048*7f2fe78bSCy Schubert window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack ); 4049*7f2fe78bSCy Schubert } 4050*7f2fe78bSCy Schubert}; 4051*7f2fe78bSCy Schubert 4052*7f2fe78bSCy Schubert 4053*7f2fe78bSCy Schubert 4054*7f2fe78bSCy Schubert 4055*7f2fe78bSCy SchubertjQuery.readyException = function( error ) { 4056*7f2fe78bSCy Schubert window.setTimeout( function() { 4057*7f2fe78bSCy Schubert throw error; 4058*7f2fe78bSCy Schubert } ); 4059*7f2fe78bSCy Schubert}; 4060*7f2fe78bSCy Schubert 4061*7f2fe78bSCy Schubert 4062*7f2fe78bSCy Schubert 4063*7f2fe78bSCy Schubert 4064*7f2fe78bSCy Schubert// The deferred used on DOM ready 4065*7f2fe78bSCy Schubertvar readyList = jQuery.Deferred(); 4066*7f2fe78bSCy Schubert 4067*7f2fe78bSCy SchubertjQuery.fn.ready = function( fn ) { 4068*7f2fe78bSCy Schubert 4069*7f2fe78bSCy Schubert readyList 4070*7f2fe78bSCy Schubert .then( fn ) 4071*7f2fe78bSCy Schubert 4072*7f2fe78bSCy Schubert // Wrap jQuery.readyException in a function so that the lookup 4073*7f2fe78bSCy Schubert // happens at the time of error handling instead of callback 4074*7f2fe78bSCy Schubert // registration. 4075*7f2fe78bSCy Schubert .catch( function( error ) { 4076*7f2fe78bSCy Schubert jQuery.readyException( error ); 4077*7f2fe78bSCy Schubert } ); 4078*7f2fe78bSCy Schubert 4079*7f2fe78bSCy Schubert return this; 4080*7f2fe78bSCy Schubert}; 4081*7f2fe78bSCy Schubert 4082*7f2fe78bSCy SchubertjQuery.extend( { 4083*7f2fe78bSCy Schubert 4084*7f2fe78bSCy Schubert // Is the DOM ready to be used? Set to true once it occurs. 4085*7f2fe78bSCy Schubert isReady: false, 4086*7f2fe78bSCy Schubert 4087*7f2fe78bSCy Schubert // A counter to track how many items to wait for before 4088*7f2fe78bSCy Schubert // the ready event fires. See #6781 4089*7f2fe78bSCy Schubert readyWait: 1, 4090*7f2fe78bSCy Schubert 4091*7f2fe78bSCy Schubert // Handle when the DOM is ready 4092*7f2fe78bSCy Schubert ready: function( wait ) { 4093*7f2fe78bSCy Schubert 4094*7f2fe78bSCy Schubert // Abort if there are pending holds or we're already ready 4095*7f2fe78bSCy Schubert if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { 4096*7f2fe78bSCy Schubert return; 4097*7f2fe78bSCy Schubert } 4098*7f2fe78bSCy Schubert 4099*7f2fe78bSCy Schubert // Remember that the DOM is ready 4100*7f2fe78bSCy Schubert jQuery.isReady = true; 4101*7f2fe78bSCy Schubert 4102*7f2fe78bSCy Schubert // If a normal DOM Ready event fired, decrement, and wait if need be 4103*7f2fe78bSCy Schubert if ( wait !== true && --jQuery.readyWait > 0 ) { 4104*7f2fe78bSCy Schubert return; 4105*7f2fe78bSCy Schubert } 4106*7f2fe78bSCy Schubert 4107*7f2fe78bSCy Schubert // If there are functions bound, to execute 4108*7f2fe78bSCy Schubert readyList.resolveWith( document, [ jQuery ] ); 4109*7f2fe78bSCy Schubert } 4110*7f2fe78bSCy Schubert} ); 4111*7f2fe78bSCy Schubert 4112*7f2fe78bSCy SchubertjQuery.ready.then = readyList.then; 4113*7f2fe78bSCy Schubert 4114*7f2fe78bSCy Schubert// The ready event handler and self cleanup method 4115*7f2fe78bSCy Schubertfunction completed() { 4116*7f2fe78bSCy Schubert document.removeEventListener( "DOMContentLoaded", completed ); 4117*7f2fe78bSCy Schubert window.removeEventListener( "load", completed ); 4118*7f2fe78bSCy Schubert jQuery.ready(); 4119*7f2fe78bSCy Schubert} 4120*7f2fe78bSCy Schubert 4121*7f2fe78bSCy Schubert// Catch cases where $(document).ready() is called 4122*7f2fe78bSCy Schubert// after the browser event has already occurred. 4123*7f2fe78bSCy Schubert// Support: IE <=9 - 10 only 4124*7f2fe78bSCy Schubert// Older IE sometimes signals "interactive" too soon 4125*7f2fe78bSCy Schubertif ( document.readyState === "complete" || 4126*7f2fe78bSCy Schubert ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) { 4127*7f2fe78bSCy Schubert 4128*7f2fe78bSCy Schubert // Handle it asynchronously to allow scripts the opportunity to delay ready 4129*7f2fe78bSCy Schubert window.setTimeout( jQuery.ready ); 4130*7f2fe78bSCy Schubert 4131*7f2fe78bSCy Schubert} else { 4132*7f2fe78bSCy Schubert 4133*7f2fe78bSCy Schubert // Use the handy event callback 4134*7f2fe78bSCy Schubert document.addEventListener( "DOMContentLoaded", completed ); 4135*7f2fe78bSCy Schubert 4136*7f2fe78bSCy Schubert // A fallback to window.onload, that will always work 4137*7f2fe78bSCy Schubert window.addEventListener( "load", completed ); 4138*7f2fe78bSCy Schubert} 4139*7f2fe78bSCy Schubert 4140*7f2fe78bSCy Schubert 4141*7f2fe78bSCy Schubert 4142*7f2fe78bSCy Schubert 4143*7f2fe78bSCy Schubert// Multifunctional method to get and set values of a collection 4144*7f2fe78bSCy Schubert// The value/s can optionally be executed if it's a function 4145*7f2fe78bSCy Schubertvar access = function( elems, fn, key, value, chainable, emptyGet, raw ) { 4146*7f2fe78bSCy Schubert var i = 0, 4147*7f2fe78bSCy Schubert len = elems.length, 4148*7f2fe78bSCy Schubert bulk = key == null; 4149*7f2fe78bSCy Schubert 4150*7f2fe78bSCy Schubert // Sets many values 4151*7f2fe78bSCy Schubert if ( toType( key ) === "object" ) { 4152*7f2fe78bSCy Schubert chainable = true; 4153*7f2fe78bSCy Schubert for ( i in key ) { 4154*7f2fe78bSCy Schubert access( elems, fn, i, key[ i ], true, emptyGet, raw ); 4155*7f2fe78bSCy Schubert } 4156*7f2fe78bSCy Schubert 4157*7f2fe78bSCy Schubert // Sets one value 4158*7f2fe78bSCy Schubert } else if ( value !== undefined ) { 4159*7f2fe78bSCy Schubert chainable = true; 4160*7f2fe78bSCy Schubert 4161*7f2fe78bSCy Schubert if ( !isFunction( value ) ) { 4162*7f2fe78bSCy Schubert raw = true; 4163*7f2fe78bSCy Schubert } 4164*7f2fe78bSCy Schubert 4165*7f2fe78bSCy Schubert if ( bulk ) { 4166*7f2fe78bSCy Schubert 4167*7f2fe78bSCy Schubert // Bulk operations run against the entire set 4168*7f2fe78bSCy Schubert if ( raw ) { 4169*7f2fe78bSCy Schubert fn.call( elems, value ); 4170*7f2fe78bSCy Schubert fn = null; 4171*7f2fe78bSCy Schubert 4172*7f2fe78bSCy Schubert // ...except when executing function values 4173*7f2fe78bSCy Schubert } else { 4174*7f2fe78bSCy Schubert bulk = fn; 4175*7f2fe78bSCy Schubert fn = function( elem, _key, value ) { 4176*7f2fe78bSCy Schubert return bulk.call( jQuery( elem ), value ); 4177*7f2fe78bSCy Schubert }; 4178*7f2fe78bSCy Schubert } 4179*7f2fe78bSCy Schubert } 4180*7f2fe78bSCy Schubert 4181*7f2fe78bSCy Schubert if ( fn ) { 4182*7f2fe78bSCy Schubert for ( ; i < len; i++ ) { 4183*7f2fe78bSCy Schubert fn( 4184*7f2fe78bSCy Schubert elems[ i ], key, raw ? 4185*7f2fe78bSCy Schubert value : 4186*7f2fe78bSCy Schubert value.call( elems[ i ], i, fn( elems[ i ], key ) ) 4187*7f2fe78bSCy Schubert ); 4188*7f2fe78bSCy Schubert } 4189*7f2fe78bSCy Schubert } 4190*7f2fe78bSCy Schubert } 4191*7f2fe78bSCy Schubert 4192*7f2fe78bSCy Schubert if ( chainable ) { 4193*7f2fe78bSCy Schubert return elems; 4194*7f2fe78bSCy Schubert } 4195*7f2fe78bSCy Schubert 4196*7f2fe78bSCy Schubert // Gets 4197*7f2fe78bSCy Schubert if ( bulk ) { 4198*7f2fe78bSCy Schubert return fn.call( elems ); 4199*7f2fe78bSCy Schubert } 4200*7f2fe78bSCy Schubert 4201*7f2fe78bSCy Schubert return len ? fn( elems[ 0 ], key ) : emptyGet; 4202*7f2fe78bSCy Schubert}; 4203*7f2fe78bSCy Schubert 4204*7f2fe78bSCy Schubert 4205*7f2fe78bSCy Schubert// Matches dashed string for camelizing 4206*7f2fe78bSCy Schubertvar rmsPrefix = /^-ms-/, 4207*7f2fe78bSCy Schubert rdashAlpha = /-([a-z])/g; 4208*7f2fe78bSCy Schubert 4209*7f2fe78bSCy Schubert// Used by camelCase as callback to replace() 4210*7f2fe78bSCy Schubertfunction fcamelCase( _all, letter ) { 4211*7f2fe78bSCy Schubert return letter.toUpperCase(); 4212*7f2fe78bSCy Schubert} 4213*7f2fe78bSCy Schubert 4214*7f2fe78bSCy Schubert// Convert dashed to camelCase; used by the css and data modules 4215*7f2fe78bSCy Schubert// Support: IE <=9 - 11, Edge 12 - 15 4216*7f2fe78bSCy Schubert// Microsoft forgot to hump their vendor prefix (#9572) 4217*7f2fe78bSCy Schubertfunction camelCase( string ) { 4218*7f2fe78bSCy Schubert return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); 4219*7f2fe78bSCy Schubert} 4220*7f2fe78bSCy Schubertvar acceptData = function( owner ) { 4221*7f2fe78bSCy Schubert 4222*7f2fe78bSCy Schubert // Accepts only: 4223*7f2fe78bSCy Schubert // - Node 4224*7f2fe78bSCy Schubert // - Node.ELEMENT_NODE 4225*7f2fe78bSCy Schubert // - Node.DOCUMENT_NODE 4226*7f2fe78bSCy Schubert // - Object 4227*7f2fe78bSCy Schubert // - Any 4228*7f2fe78bSCy Schubert return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType ); 4229*7f2fe78bSCy Schubert}; 4230*7f2fe78bSCy Schubert 4231*7f2fe78bSCy Schubert 4232*7f2fe78bSCy Schubert 4233*7f2fe78bSCy Schubert 4234*7f2fe78bSCy Schubertfunction Data() { 4235*7f2fe78bSCy Schubert this.expando = jQuery.expando + Data.uid++; 4236*7f2fe78bSCy Schubert} 4237*7f2fe78bSCy Schubert 4238*7f2fe78bSCy SchubertData.uid = 1; 4239*7f2fe78bSCy Schubert 4240*7f2fe78bSCy SchubertData.prototype = { 4241*7f2fe78bSCy Schubert 4242*7f2fe78bSCy Schubert cache: function( owner ) { 4243*7f2fe78bSCy Schubert 4244*7f2fe78bSCy Schubert // Check if the owner object already has a cache 4245*7f2fe78bSCy Schubert var value = owner[ this.expando ]; 4246*7f2fe78bSCy Schubert 4247*7f2fe78bSCy Schubert // If not, create one 4248*7f2fe78bSCy Schubert if ( !value ) { 4249*7f2fe78bSCy Schubert value = {}; 4250*7f2fe78bSCy Schubert 4251*7f2fe78bSCy Schubert // We can accept data for non-element nodes in modern browsers, 4252*7f2fe78bSCy Schubert // but we should not, see #8335. 4253*7f2fe78bSCy Schubert // Always return an empty object. 4254*7f2fe78bSCy Schubert if ( acceptData( owner ) ) { 4255*7f2fe78bSCy Schubert 4256*7f2fe78bSCy Schubert // If it is a node unlikely to be stringify-ed or looped over 4257*7f2fe78bSCy Schubert // use plain assignment 4258*7f2fe78bSCy Schubert if ( owner.nodeType ) { 4259*7f2fe78bSCy Schubert owner[ this.expando ] = value; 4260*7f2fe78bSCy Schubert 4261*7f2fe78bSCy Schubert // Otherwise secure it in a non-enumerable property 4262*7f2fe78bSCy Schubert // configurable must be true to allow the property to be 4263*7f2fe78bSCy Schubert // deleted when data is removed 4264*7f2fe78bSCy Schubert } else { 4265*7f2fe78bSCy Schubert Object.defineProperty( owner, this.expando, { 4266*7f2fe78bSCy Schubert value: value, 4267*7f2fe78bSCy Schubert configurable: true 4268*7f2fe78bSCy Schubert } ); 4269*7f2fe78bSCy Schubert } 4270*7f2fe78bSCy Schubert } 4271*7f2fe78bSCy Schubert } 4272*7f2fe78bSCy Schubert 4273*7f2fe78bSCy Schubert return value; 4274*7f2fe78bSCy Schubert }, 4275*7f2fe78bSCy Schubert set: function( owner, data, value ) { 4276*7f2fe78bSCy Schubert var prop, 4277*7f2fe78bSCy Schubert cache = this.cache( owner ); 4278*7f2fe78bSCy Schubert 4279*7f2fe78bSCy Schubert // Handle: [ owner, key, value ] args 4280*7f2fe78bSCy Schubert // Always use camelCase key (gh-2257) 4281*7f2fe78bSCy Schubert if ( typeof data === "string" ) { 4282*7f2fe78bSCy Schubert cache[ camelCase( data ) ] = value; 4283*7f2fe78bSCy Schubert 4284*7f2fe78bSCy Schubert // Handle: [ owner, { properties } ] args 4285*7f2fe78bSCy Schubert } else { 4286*7f2fe78bSCy Schubert 4287*7f2fe78bSCy Schubert // Copy the properties one-by-one to the cache object 4288*7f2fe78bSCy Schubert for ( prop in data ) { 4289*7f2fe78bSCy Schubert cache[ camelCase( prop ) ] = data[ prop ]; 4290*7f2fe78bSCy Schubert } 4291*7f2fe78bSCy Schubert } 4292*7f2fe78bSCy Schubert return cache; 4293*7f2fe78bSCy Schubert }, 4294*7f2fe78bSCy Schubert get: function( owner, key ) { 4295*7f2fe78bSCy Schubert return key === undefined ? 4296*7f2fe78bSCy Schubert this.cache( owner ) : 4297*7f2fe78bSCy Schubert 4298*7f2fe78bSCy Schubert // Always use camelCase key (gh-2257) 4299*7f2fe78bSCy Schubert owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ]; 4300*7f2fe78bSCy Schubert }, 4301*7f2fe78bSCy Schubert access: function( owner, key, value ) { 4302*7f2fe78bSCy Schubert 4303*7f2fe78bSCy Schubert // In cases where either: 4304*7f2fe78bSCy Schubert // 4305*7f2fe78bSCy Schubert // 1. No key was specified 4306*7f2fe78bSCy Schubert // 2. A string key was specified, but no value provided 4307*7f2fe78bSCy Schubert // 4308*7f2fe78bSCy Schubert // Take the "read" path and allow the get method to determine 4309*7f2fe78bSCy Schubert // which value to return, respectively either: 4310*7f2fe78bSCy Schubert // 4311*7f2fe78bSCy Schubert // 1. The entire cache object 4312*7f2fe78bSCy Schubert // 2. The data stored at the key 4313*7f2fe78bSCy Schubert // 4314*7f2fe78bSCy Schubert if ( key === undefined || 4315*7f2fe78bSCy Schubert ( ( key && typeof key === "string" ) && value === undefined ) ) { 4316*7f2fe78bSCy Schubert 4317*7f2fe78bSCy Schubert return this.get( owner, key ); 4318*7f2fe78bSCy Schubert } 4319*7f2fe78bSCy Schubert 4320*7f2fe78bSCy Schubert // When the key is not a string, or both a key and value 4321*7f2fe78bSCy Schubert // are specified, set or extend (existing objects) with either: 4322*7f2fe78bSCy Schubert // 4323*7f2fe78bSCy Schubert // 1. An object of properties 4324*7f2fe78bSCy Schubert // 2. A key and value 4325*7f2fe78bSCy Schubert // 4326*7f2fe78bSCy Schubert this.set( owner, key, value ); 4327*7f2fe78bSCy Schubert 4328*7f2fe78bSCy Schubert // Since the "set" path can have two possible entry points 4329*7f2fe78bSCy Schubert // return the expected data based on which path was taken[*] 4330*7f2fe78bSCy Schubert return value !== undefined ? value : key; 4331*7f2fe78bSCy Schubert }, 4332*7f2fe78bSCy Schubert remove: function( owner, key ) { 4333*7f2fe78bSCy Schubert var i, 4334*7f2fe78bSCy Schubert cache = owner[ this.expando ]; 4335*7f2fe78bSCy Schubert 4336*7f2fe78bSCy Schubert if ( cache === undefined ) { 4337*7f2fe78bSCy Schubert return; 4338*7f2fe78bSCy Schubert } 4339*7f2fe78bSCy Schubert 4340*7f2fe78bSCy Schubert if ( key !== undefined ) { 4341*7f2fe78bSCy Schubert 4342*7f2fe78bSCy Schubert // Support array or space separated string of keys 4343*7f2fe78bSCy Schubert if ( Array.isArray( key ) ) { 4344*7f2fe78bSCy Schubert 4345*7f2fe78bSCy Schubert // If key is an array of keys... 4346*7f2fe78bSCy Schubert // We always set camelCase keys, so remove that. 4347*7f2fe78bSCy Schubert key = key.map( camelCase ); 4348*7f2fe78bSCy Schubert } else { 4349*7f2fe78bSCy Schubert key = camelCase( key ); 4350*7f2fe78bSCy Schubert 4351*7f2fe78bSCy Schubert // If a key with the spaces exists, use it. 4352*7f2fe78bSCy Schubert // Otherwise, create an array by matching non-whitespace 4353*7f2fe78bSCy Schubert key = key in cache ? 4354*7f2fe78bSCy Schubert [ key ] : 4355*7f2fe78bSCy Schubert ( key.match( rnothtmlwhite ) || [] ); 4356*7f2fe78bSCy Schubert } 4357*7f2fe78bSCy Schubert 4358*7f2fe78bSCy Schubert i = key.length; 4359*7f2fe78bSCy Schubert 4360*7f2fe78bSCy Schubert while ( i-- ) { 4361*7f2fe78bSCy Schubert delete cache[ key[ i ] ]; 4362*7f2fe78bSCy Schubert } 4363*7f2fe78bSCy Schubert } 4364*7f2fe78bSCy Schubert 4365*7f2fe78bSCy Schubert // Remove the expando if there's no more data 4366*7f2fe78bSCy Schubert if ( key === undefined || jQuery.isEmptyObject( cache ) ) { 4367*7f2fe78bSCy Schubert 4368*7f2fe78bSCy Schubert // Support: Chrome <=35 - 45 4369*7f2fe78bSCy Schubert // Webkit & Blink performance suffers when deleting properties 4370*7f2fe78bSCy Schubert // from DOM nodes, so set to undefined instead 4371*7f2fe78bSCy Schubert // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted) 4372*7f2fe78bSCy Schubert if ( owner.nodeType ) { 4373*7f2fe78bSCy Schubert owner[ this.expando ] = undefined; 4374*7f2fe78bSCy Schubert } else { 4375*7f2fe78bSCy Schubert delete owner[ this.expando ]; 4376*7f2fe78bSCy Schubert } 4377*7f2fe78bSCy Schubert } 4378*7f2fe78bSCy Schubert }, 4379*7f2fe78bSCy Schubert hasData: function( owner ) { 4380*7f2fe78bSCy Schubert var cache = owner[ this.expando ]; 4381*7f2fe78bSCy Schubert return cache !== undefined && !jQuery.isEmptyObject( cache ); 4382*7f2fe78bSCy Schubert } 4383*7f2fe78bSCy Schubert}; 4384*7f2fe78bSCy Schubertvar dataPriv = new Data(); 4385*7f2fe78bSCy Schubert 4386*7f2fe78bSCy Schubertvar dataUser = new Data(); 4387*7f2fe78bSCy Schubert 4388*7f2fe78bSCy Schubert 4389*7f2fe78bSCy Schubert 4390*7f2fe78bSCy Schubert// Implementation Summary 4391*7f2fe78bSCy Schubert// 4392*7f2fe78bSCy Schubert// 1. Enforce API surface and semantic compatibility with 1.9.x branch 4393*7f2fe78bSCy Schubert// 2. Improve the module's maintainability by reducing the storage 4394*7f2fe78bSCy Schubert// paths to a single mechanism. 4395*7f2fe78bSCy Schubert// 3. Use the same single mechanism to support "private" and "user" data. 4396*7f2fe78bSCy Schubert// 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData) 4397*7f2fe78bSCy Schubert// 5. Avoid exposing implementation details on user objects (eg. expando properties) 4398*7f2fe78bSCy Schubert// 6. Provide a clear path for implementation upgrade to WeakMap in 2014 4399*7f2fe78bSCy Schubert 4400*7f2fe78bSCy Schubertvar rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, 4401*7f2fe78bSCy Schubert rmultiDash = /[A-Z]/g; 4402*7f2fe78bSCy Schubert 4403*7f2fe78bSCy Schubertfunction getData( data ) { 4404*7f2fe78bSCy Schubert if ( data === "true" ) { 4405*7f2fe78bSCy Schubert return true; 4406*7f2fe78bSCy Schubert } 4407*7f2fe78bSCy Schubert 4408*7f2fe78bSCy Schubert if ( data === "false" ) { 4409*7f2fe78bSCy Schubert return false; 4410*7f2fe78bSCy Schubert } 4411*7f2fe78bSCy Schubert 4412*7f2fe78bSCy Schubert if ( data === "null" ) { 4413*7f2fe78bSCy Schubert return null; 4414*7f2fe78bSCy Schubert } 4415*7f2fe78bSCy Schubert 4416*7f2fe78bSCy Schubert // Only convert to a number if it doesn't change the string 4417*7f2fe78bSCy Schubert if ( data === +data + "" ) { 4418*7f2fe78bSCy Schubert return +data; 4419*7f2fe78bSCy Schubert } 4420*7f2fe78bSCy Schubert 4421*7f2fe78bSCy Schubert if ( rbrace.test( data ) ) { 4422*7f2fe78bSCy Schubert return JSON.parse( data ); 4423*7f2fe78bSCy Schubert } 4424*7f2fe78bSCy Schubert 4425*7f2fe78bSCy Schubert return data; 4426*7f2fe78bSCy Schubert} 4427*7f2fe78bSCy Schubert 4428*7f2fe78bSCy Schubertfunction dataAttr( elem, key, data ) { 4429*7f2fe78bSCy Schubert var name; 4430*7f2fe78bSCy Schubert 4431*7f2fe78bSCy Schubert // If nothing was found internally, try to fetch any 4432*7f2fe78bSCy Schubert // data from the HTML5 data-* attribute 4433*7f2fe78bSCy Schubert if ( data === undefined && elem.nodeType === 1 ) { 4434*7f2fe78bSCy Schubert name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase(); 4435*7f2fe78bSCy Schubert data = elem.getAttribute( name ); 4436*7f2fe78bSCy Schubert 4437*7f2fe78bSCy Schubert if ( typeof data === "string" ) { 4438*7f2fe78bSCy Schubert try { 4439*7f2fe78bSCy Schubert data = getData( data ); 4440*7f2fe78bSCy Schubert } catch ( e ) {} 4441*7f2fe78bSCy Schubert 4442*7f2fe78bSCy Schubert // Make sure we set the data so it isn't changed later 4443*7f2fe78bSCy Schubert dataUser.set( elem, key, data ); 4444*7f2fe78bSCy Schubert } else { 4445*7f2fe78bSCy Schubert data = undefined; 4446*7f2fe78bSCy Schubert } 4447*7f2fe78bSCy Schubert } 4448*7f2fe78bSCy Schubert return data; 4449*7f2fe78bSCy Schubert} 4450*7f2fe78bSCy Schubert 4451*7f2fe78bSCy SchubertjQuery.extend( { 4452*7f2fe78bSCy Schubert hasData: function( elem ) { 4453*7f2fe78bSCy Schubert return dataUser.hasData( elem ) || dataPriv.hasData( elem ); 4454*7f2fe78bSCy Schubert }, 4455*7f2fe78bSCy Schubert 4456*7f2fe78bSCy Schubert data: function( elem, name, data ) { 4457*7f2fe78bSCy Schubert return dataUser.access( elem, name, data ); 4458*7f2fe78bSCy Schubert }, 4459*7f2fe78bSCy Schubert 4460*7f2fe78bSCy Schubert removeData: function( elem, name ) { 4461*7f2fe78bSCy Schubert dataUser.remove( elem, name ); 4462*7f2fe78bSCy Schubert }, 4463*7f2fe78bSCy Schubert 4464*7f2fe78bSCy Schubert // TODO: Now that all calls to _data and _removeData have been replaced 4465*7f2fe78bSCy Schubert // with direct calls to dataPriv methods, these can be deprecated. 4466*7f2fe78bSCy Schubert _data: function( elem, name, data ) { 4467*7f2fe78bSCy Schubert return dataPriv.access( elem, name, data ); 4468*7f2fe78bSCy Schubert }, 4469*7f2fe78bSCy Schubert 4470*7f2fe78bSCy Schubert _removeData: function( elem, name ) { 4471*7f2fe78bSCy Schubert dataPriv.remove( elem, name ); 4472*7f2fe78bSCy Schubert } 4473*7f2fe78bSCy Schubert} ); 4474*7f2fe78bSCy Schubert 4475*7f2fe78bSCy SchubertjQuery.fn.extend( { 4476*7f2fe78bSCy Schubert data: function( key, value ) { 4477*7f2fe78bSCy Schubert var i, name, data, 4478*7f2fe78bSCy Schubert elem = this[ 0 ], 4479*7f2fe78bSCy Schubert attrs = elem && elem.attributes; 4480*7f2fe78bSCy Schubert 4481*7f2fe78bSCy Schubert // Gets all values 4482*7f2fe78bSCy Schubert if ( key === undefined ) { 4483*7f2fe78bSCy Schubert if ( this.length ) { 4484*7f2fe78bSCy Schubert data = dataUser.get( elem ); 4485*7f2fe78bSCy Schubert 4486*7f2fe78bSCy Schubert if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) { 4487*7f2fe78bSCy Schubert i = attrs.length; 4488*7f2fe78bSCy Schubert while ( i-- ) { 4489*7f2fe78bSCy Schubert 4490*7f2fe78bSCy Schubert // Support: IE 11 only 4491*7f2fe78bSCy Schubert // The attrs elements can be null (#14894) 4492*7f2fe78bSCy Schubert if ( attrs[ i ] ) { 4493*7f2fe78bSCy Schubert name = attrs[ i ].name; 4494*7f2fe78bSCy Schubert if ( name.indexOf( "data-" ) === 0 ) { 4495*7f2fe78bSCy Schubert name = camelCase( name.slice( 5 ) ); 4496*7f2fe78bSCy Schubert dataAttr( elem, name, data[ name ] ); 4497*7f2fe78bSCy Schubert } 4498*7f2fe78bSCy Schubert } 4499*7f2fe78bSCy Schubert } 4500*7f2fe78bSCy Schubert dataPriv.set( elem, "hasDataAttrs", true ); 4501*7f2fe78bSCy Schubert } 4502*7f2fe78bSCy Schubert } 4503*7f2fe78bSCy Schubert 4504*7f2fe78bSCy Schubert return data; 4505*7f2fe78bSCy Schubert } 4506*7f2fe78bSCy Schubert 4507*7f2fe78bSCy Schubert // Sets multiple values 4508*7f2fe78bSCy Schubert if ( typeof key === "object" ) { 4509*7f2fe78bSCy Schubert return this.each( function() { 4510*7f2fe78bSCy Schubert dataUser.set( this, key ); 4511*7f2fe78bSCy Schubert } ); 4512*7f2fe78bSCy Schubert } 4513*7f2fe78bSCy Schubert 4514*7f2fe78bSCy Schubert return access( this, function( value ) { 4515*7f2fe78bSCy Schubert var data; 4516*7f2fe78bSCy Schubert 4517*7f2fe78bSCy Schubert // The calling jQuery object (element matches) is not empty 4518*7f2fe78bSCy Schubert // (and therefore has an element appears at this[ 0 ]) and the 4519*7f2fe78bSCy Schubert // `value` parameter was not undefined. An empty jQuery object 4520*7f2fe78bSCy Schubert // will result in `undefined` for elem = this[ 0 ] which will 4521*7f2fe78bSCy Schubert // throw an exception if an attempt to read a data cache is made. 4522*7f2fe78bSCy Schubert if ( elem && value === undefined ) { 4523*7f2fe78bSCy Schubert 4524*7f2fe78bSCy Schubert // Attempt to get data from the cache 4525*7f2fe78bSCy Schubert // The key will always be camelCased in Data 4526*7f2fe78bSCy Schubert data = dataUser.get( elem, key ); 4527*7f2fe78bSCy Schubert if ( data !== undefined ) { 4528*7f2fe78bSCy Schubert return data; 4529*7f2fe78bSCy Schubert } 4530*7f2fe78bSCy Schubert 4531*7f2fe78bSCy Schubert // Attempt to "discover" the data in 4532*7f2fe78bSCy Schubert // HTML5 custom data-* attrs 4533*7f2fe78bSCy Schubert data = dataAttr( elem, key ); 4534*7f2fe78bSCy Schubert if ( data !== undefined ) { 4535*7f2fe78bSCy Schubert return data; 4536*7f2fe78bSCy Schubert } 4537*7f2fe78bSCy Schubert 4538*7f2fe78bSCy Schubert // We tried really hard, but the data doesn't exist. 4539*7f2fe78bSCy Schubert return; 4540*7f2fe78bSCy Schubert } 4541*7f2fe78bSCy Schubert 4542*7f2fe78bSCy Schubert // Set the data... 4543*7f2fe78bSCy Schubert this.each( function() { 4544*7f2fe78bSCy Schubert 4545*7f2fe78bSCy Schubert // We always store the camelCased key 4546*7f2fe78bSCy Schubert dataUser.set( this, key, value ); 4547*7f2fe78bSCy Schubert } ); 4548*7f2fe78bSCy Schubert }, null, value, arguments.length > 1, null, true ); 4549*7f2fe78bSCy Schubert }, 4550*7f2fe78bSCy Schubert 4551*7f2fe78bSCy Schubert removeData: function( key ) { 4552*7f2fe78bSCy Schubert return this.each( function() { 4553*7f2fe78bSCy Schubert dataUser.remove( this, key ); 4554*7f2fe78bSCy Schubert } ); 4555*7f2fe78bSCy Schubert } 4556*7f2fe78bSCy Schubert} ); 4557*7f2fe78bSCy Schubert 4558*7f2fe78bSCy Schubert 4559*7f2fe78bSCy SchubertjQuery.extend( { 4560*7f2fe78bSCy Schubert queue: function( elem, type, data ) { 4561*7f2fe78bSCy Schubert var queue; 4562*7f2fe78bSCy Schubert 4563*7f2fe78bSCy Schubert if ( elem ) { 4564*7f2fe78bSCy Schubert type = ( type || "fx" ) + "queue"; 4565*7f2fe78bSCy Schubert queue = dataPriv.get( elem, type ); 4566*7f2fe78bSCy Schubert 4567*7f2fe78bSCy Schubert // Speed up dequeue by getting out quickly if this is just a lookup 4568*7f2fe78bSCy Schubert if ( data ) { 4569*7f2fe78bSCy Schubert if ( !queue || Array.isArray( data ) ) { 4570*7f2fe78bSCy Schubert queue = dataPriv.access( elem, type, jQuery.makeArray( data ) ); 4571*7f2fe78bSCy Schubert } else { 4572*7f2fe78bSCy Schubert queue.push( data ); 4573*7f2fe78bSCy Schubert } 4574*7f2fe78bSCy Schubert } 4575*7f2fe78bSCy Schubert return queue || []; 4576*7f2fe78bSCy Schubert } 4577*7f2fe78bSCy Schubert }, 4578*7f2fe78bSCy Schubert 4579*7f2fe78bSCy Schubert dequeue: function( elem, type ) { 4580*7f2fe78bSCy Schubert type = type || "fx"; 4581*7f2fe78bSCy Schubert 4582*7f2fe78bSCy Schubert var queue = jQuery.queue( elem, type ), 4583*7f2fe78bSCy Schubert startLength = queue.length, 4584*7f2fe78bSCy Schubert fn = queue.shift(), 4585*7f2fe78bSCy Schubert hooks = jQuery._queueHooks( elem, type ), 4586*7f2fe78bSCy Schubert next = function() { 4587*7f2fe78bSCy Schubert jQuery.dequeue( elem, type ); 4588*7f2fe78bSCy Schubert }; 4589*7f2fe78bSCy Schubert 4590*7f2fe78bSCy Schubert // If the fx queue is dequeued, always remove the progress sentinel 4591*7f2fe78bSCy Schubert if ( fn === "inprogress" ) { 4592*7f2fe78bSCy Schubert fn = queue.shift(); 4593*7f2fe78bSCy Schubert startLength--; 4594*7f2fe78bSCy Schubert } 4595*7f2fe78bSCy Schubert 4596*7f2fe78bSCy Schubert if ( fn ) { 4597*7f2fe78bSCy Schubert 4598*7f2fe78bSCy Schubert // Add a progress sentinel to prevent the fx queue from being 4599*7f2fe78bSCy Schubert // automatically dequeued 4600*7f2fe78bSCy Schubert if ( type === "fx" ) { 4601*7f2fe78bSCy Schubert queue.unshift( "inprogress" ); 4602*7f2fe78bSCy Schubert } 4603*7f2fe78bSCy Schubert 4604*7f2fe78bSCy Schubert // Clear up the last queue stop function 4605*7f2fe78bSCy Schubert delete hooks.stop; 4606*7f2fe78bSCy Schubert fn.call( elem, next, hooks ); 4607*7f2fe78bSCy Schubert } 4608*7f2fe78bSCy Schubert 4609*7f2fe78bSCy Schubert if ( !startLength && hooks ) { 4610*7f2fe78bSCy Schubert hooks.empty.fire(); 4611*7f2fe78bSCy Schubert } 4612*7f2fe78bSCy Schubert }, 4613*7f2fe78bSCy Schubert 4614*7f2fe78bSCy Schubert // Not public - generate a queueHooks object, or return the current one 4615*7f2fe78bSCy Schubert _queueHooks: function( elem, type ) { 4616*7f2fe78bSCy Schubert var key = type + "queueHooks"; 4617*7f2fe78bSCy Schubert return dataPriv.get( elem, key ) || dataPriv.access( elem, key, { 4618*7f2fe78bSCy Schubert empty: jQuery.Callbacks( "once memory" ).add( function() { 4619*7f2fe78bSCy Schubert dataPriv.remove( elem, [ type + "queue", key ] ); 4620*7f2fe78bSCy Schubert } ) 4621*7f2fe78bSCy Schubert } ); 4622*7f2fe78bSCy Schubert } 4623*7f2fe78bSCy Schubert} ); 4624*7f2fe78bSCy Schubert 4625*7f2fe78bSCy SchubertjQuery.fn.extend( { 4626*7f2fe78bSCy Schubert queue: function( type, data ) { 4627*7f2fe78bSCy Schubert var setter = 2; 4628*7f2fe78bSCy Schubert 4629*7f2fe78bSCy Schubert if ( typeof type !== "string" ) { 4630*7f2fe78bSCy Schubert data = type; 4631*7f2fe78bSCy Schubert type = "fx"; 4632*7f2fe78bSCy Schubert setter--; 4633*7f2fe78bSCy Schubert } 4634*7f2fe78bSCy Schubert 4635*7f2fe78bSCy Schubert if ( arguments.length < setter ) { 4636*7f2fe78bSCy Schubert return jQuery.queue( this[ 0 ], type ); 4637*7f2fe78bSCy Schubert } 4638*7f2fe78bSCy Schubert 4639*7f2fe78bSCy Schubert return data === undefined ? 4640*7f2fe78bSCy Schubert this : 4641*7f2fe78bSCy Schubert this.each( function() { 4642*7f2fe78bSCy Schubert var queue = jQuery.queue( this, type, data ); 4643*7f2fe78bSCy Schubert 4644*7f2fe78bSCy Schubert // Ensure a hooks for this queue 4645*7f2fe78bSCy Schubert jQuery._queueHooks( this, type ); 4646*7f2fe78bSCy Schubert 4647*7f2fe78bSCy Schubert if ( type === "fx" && queue[ 0 ] !== "inprogress" ) { 4648*7f2fe78bSCy Schubert jQuery.dequeue( this, type ); 4649*7f2fe78bSCy Schubert } 4650*7f2fe78bSCy Schubert } ); 4651*7f2fe78bSCy Schubert }, 4652*7f2fe78bSCy Schubert dequeue: function( type ) { 4653*7f2fe78bSCy Schubert return this.each( function() { 4654*7f2fe78bSCy Schubert jQuery.dequeue( this, type ); 4655*7f2fe78bSCy Schubert } ); 4656*7f2fe78bSCy Schubert }, 4657*7f2fe78bSCy Schubert clearQueue: function( type ) { 4658*7f2fe78bSCy Schubert return this.queue( type || "fx", [] ); 4659*7f2fe78bSCy Schubert }, 4660*7f2fe78bSCy Schubert 4661*7f2fe78bSCy Schubert // Get a promise resolved when queues of a certain type 4662*7f2fe78bSCy Schubert // are emptied (fx is the type by default) 4663*7f2fe78bSCy Schubert promise: function( type, obj ) { 4664*7f2fe78bSCy Schubert var tmp, 4665*7f2fe78bSCy Schubert count = 1, 4666*7f2fe78bSCy Schubert defer = jQuery.Deferred(), 4667*7f2fe78bSCy Schubert elements = this, 4668*7f2fe78bSCy Schubert i = this.length, 4669*7f2fe78bSCy Schubert resolve = function() { 4670*7f2fe78bSCy Schubert if ( !( --count ) ) { 4671*7f2fe78bSCy Schubert defer.resolveWith( elements, [ elements ] ); 4672*7f2fe78bSCy Schubert } 4673*7f2fe78bSCy Schubert }; 4674*7f2fe78bSCy Schubert 4675*7f2fe78bSCy Schubert if ( typeof type !== "string" ) { 4676*7f2fe78bSCy Schubert obj = type; 4677*7f2fe78bSCy Schubert type = undefined; 4678*7f2fe78bSCy Schubert } 4679*7f2fe78bSCy Schubert type = type || "fx"; 4680*7f2fe78bSCy Schubert 4681*7f2fe78bSCy Schubert while ( i-- ) { 4682*7f2fe78bSCy Schubert tmp = dataPriv.get( elements[ i ], type + "queueHooks" ); 4683*7f2fe78bSCy Schubert if ( tmp && tmp.empty ) { 4684*7f2fe78bSCy Schubert count++; 4685*7f2fe78bSCy Schubert tmp.empty.add( resolve ); 4686*7f2fe78bSCy Schubert } 4687*7f2fe78bSCy Schubert } 4688*7f2fe78bSCy Schubert resolve(); 4689*7f2fe78bSCy Schubert return defer.promise( obj ); 4690*7f2fe78bSCy Schubert } 4691*7f2fe78bSCy Schubert} ); 4692*7f2fe78bSCy Schubertvar pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source; 4693*7f2fe78bSCy Schubert 4694*7f2fe78bSCy Schubertvar rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ); 4695*7f2fe78bSCy Schubert 4696*7f2fe78bSCy Schubert 4697*7f2fe78bSCy Schubertvar cssExpand = [ "Top", "Right", "Bottom", "Left" ]; 4698*7f2fe78bSCy Schubert 4699*7f2fe78bSCy Schubertvar documentElement = document.documentElement; 4700*7f2fe78bSCy Schubert 4701*7f2fe78bSCy Schubert 4702*7f2fe78bSCy Schubert 4703*7f2fe78bSCy Schubert var isAttached = function( elem ) { 4704*7f2fe78bSCy Schubert return jQuery.contains( elem.ownerDocument, elem ); 4705*7f2fe78bSCy Schubert }, 4706*7f2fe78bSCy Schubert composed = { composed: true }; 4707*7f2fe78bSCy Schubert 4708*7f2fe78bSCy Schubert // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only 4709*7f2fe78bSCy Schubert // Check attachment across shadow DOM boundaries when possible (gh-3504) 4710*7f2fe78bSCy Schubert // Support: iOS 10.0-10.2 only 4711*7f2fe78bSCy Schubert // Early iOS 10 versions support `attachShadow` but not `getRootNode`, 4712*7f2fe78bSCy Schubert // leading to errors. We need to check for `getRootNode`. 4713*7f2fe78bSCy Schubert if ( documentElement.getRootNode ) { 4714*7f2fe78bSCy Schubert isAttached = function( elem ) { 4715*7f2fe78bSCy Schubert return jQuery.contains( elem.ownerDocument, elem ) || 4716*7f2fe78bSCy Schubert elem.getRootNode( composed ) === elem.ownerDocument; 4717*7f2fe78bSCy Schubert }; 4718*7f2fe78bSCy Schubert } 4719*7f2fe78bSCy Schubertvar isHiddenWithinTree = function( elem, el ) { 4720*7f2fe78bSCy Schubert 4721*7f2fe78bSCy Schubert // isHiddenWithinTree might be called from jQuery#filter function; 4722*7f2fe78bSCy Schubert // in that case, element will be second argument 4723*7f2fe78bSCy Schubert elem = el || elem; 4724*7f2fe78bSCy Schubert 4725*7f2fe78bSCy Schubert // Inline style trumps all 4726*7f2fe78bSCy Schubert return elem.style.display === "none" || 4727*7f2fe78bSCy Schubert elem.style.display === "" && 4728*7f2fe78bSCy Schubert 4729*7f2fe78bSCy Schubert // Otherwise, check computed style 4730*7f2fe78bSCy Schubert // Support: Firefox <=43 - 45 4731*7f2fe78bSCy Schubert // Disconnected elements can have computed display: none, so first confirm that elem is 4732*7f2fe78bSCy Schubert // in the document. 4733*7f2fe78bSCy Schubert isAttached( elem ) && 4734*7f2fe78bSCy Schubert 4735*7f2fe78bSCy Schubert jQuery.css( elem, "display" ) === "none"; 4736*7f2fe78bSCy Schubert }; 4737*7f2fe78bSCy Schubert 4738*7f2fe78bSCy Schubert 4739*7f2fe78bSCy Schubert 4740*7f2fe78bSCy Schubertfunction adjustCSS( elem, prop, valueParts, tween ) { 4741*7f2fe78bSCy Schubert var adjusted, scale, 4742*7f2fe78bSCy Schubert maxIterations = 20, 4743*7f2fe78bSCy Schubert currentValue = tween ? 4744*7f2fe78bSCy Schubert function() { 4745*7f2fe78bSCy Schubert return tween.cur(); 4746*7f2fe78bSCy Schubert } : 4747*7f2fe78bSCy Schubert function() { 4748*7f2fe78bSCy Schubert return jQuery.css( elem, prop, "" ); 4749*7f2fe78bSCy Schubert }, 4750*7f2fe78bSCy Schubert initial = currentValue(), 4751*7f2fe78bSCy Schubert unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ), 4752*7f2fe78bSCy Schubert 4753*7f2fe78bSCy Schubert // Starting value computation is required for potential unit mismatches 4754*7f2fe78bSCy Schubert initialInUnit = elem.nodeType && 4755*7f2fe78bSCy Schubert ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) && 4756*7f2fe78bSCy Schubert rcssNum.exec( jQuery.css( elem, prop ) ); 4757*7f2fe78bSCy Schubert 4758*7f2fe78bSCy Schubert if ( initialInUnit && initialInUnit[ 3 ] !== unit ) { 4759*7f2fe78bSCy Schubert 4760*7f2fe78bSCy Schubert // Support: Firefox <=54 4761*7f2fe78bSCy Schubert // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144) 4762*7f2fe78bSCy Schubert initial = initial / 2; 4763*7f2fe78bSCy Schubert 4764*7f2fe78bSCy Schubert // Trust units reported by jQuery.css 4765*7f2fe78bSCy Schubert unit = unit || initialInUnit[ 3 ]; 4766*7f2fe78bSCy Schubert 4767*7f2fe78bSCy Schubert // Iteratively approximate from a nonzero starting point 4768*7f2fe78bSCy Schubert initialInUnit = +initial || 1; 4769*7f2fe78bSCy Schubert 4770*7f2fe78bSCy Schubert while ( maxIterations-- ) { 4771*7f2fe78bSCy Schubert 4772*7f2fe78bSCy Schubert // Evaluate and update our best guess (doubling guesses that zero out). 4773*7f2fe78bSCy Schubert // Finish if the scale equals or crosses 1 (making the old*new product non-positive). 4774*7f2fe78bSCy Schubert jQuery.style( elem, prop, initialInUnit + unit ); 4775*7f2fe78bSCy Schubert if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) { 4776*7f2fe78bSCy Schubert maxIterations = 0; 4777*7f2fe78bSCy Schubert } 4778*7f2fe78bSCy Schubert initialInUnit = initialInUnit / scale; 4779*7f2fe78bSCy Schubert 4780*7f2fe78bSCy Schubert } 4781*7f2fe78bSCy Schubert 4782*7f2fe78bSCy Schubert initialInUnit = initialInUnit * 2; 4783*7f2fe78bSCy Schubert jQuery.style( elem, prop, initialInUnit + unit ); 4784*7f2fe78bSCy Schubert 4785*7f2fe78bSCy Schubert // Make sure we update the tween properties later on 4786*7f2fe78bSCy Schubert valueParts = valueParts || []; 4787*7f2fe78bSCy Schubert } 4788*7f2fe78bSCy Schubert 4789*7f2fe78bSCy Schubert if ( valueParts ) { 4790*7f2fe78bSCy Schubert initialInUnit = +initialInUnit || +initial || 0; 4791*7f2fe78bSCy Schubert 4792*7f2fe78bSCy Schubert // Apply relative offset (+=/-=) if specified 4793*7f2fe78bSCy Schubert adjusted = valueParts[ 1 ] ? 4794*7f2fe78bSCy Schubert initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] : 4795*7f2fe78bSCy Schubert +valueParts[ 2 ]; 4796*7f2fe78bSCy Schubert if ( tween ) { 4797*7f2fe78bSCy Schubert tween.unit = unit; 4798*7f2fe78bSCy Schubert tween.start = initialInUnit; 4799*7f2fe78bSCy Schubert tween.end = adjusted; 4800*7f2fe78bSCy Schubert } 4801*7f2fe78bSCy Schubert } 4802*7f2fe78bSCy Schubert return adjusted; 4803*7f2fe78bSCy Schubert} 4804*7f2fe78bSCy Schubert 4805*7f2fe78bSCy Schubert 4806*7f2fe78bSCy Schubertvar defaultDisplayMap = {}; 4807*7f2fe78bSCy Schubert 4808*7f2fe78bSCy Schubertfunction getDefaultDisplay( elem ) { 4809*7f2fe78bSCy Schubert var temp, 4810*7f2fe78bSCy Schubert doc = elem.ownerDocument, 4811*7f2fe78bSCy Schubert nodeName = elem.nodeName, 4812*7f2fe78bSCy Schubert display = defaultDisplayMap[ nodeName ]; 4813*7f2fe78bSCy Schubert 4814*7f2fe78bSCy Schubert if ( display ) { 4815*7f2fe78bSCy Schubert return display; 4816*7f2fe78bSCy Schubert } 4817*7f2fe78bSCy Schubert 4818*7f2fe78bSCy Schubert temp = doc.body.appendChild( doc.createElement( nodeName ) ); 4819*7f2fe78bSCy Schubert display = jQuery.css( temp, "display" ); 4820*7f2fe78bSCy Schubert 4821*7f2fe78bSCy Schubert temp.parentNode.removeChild( temp ); 4822*7f2fe78bSCy Schubert 4823*7f2fe78bSCy Schubert if ( display === "none" ) { 4824*7f2fe78bSCy Schubert display = "block"; 4825*7f2fe78bSCy Schubert } 4826*7f2fe78bSCy Schubert defaultDisplayMap[ nodeName ] = display; 4827*7f2fe78bSCy Schubert 4828*7f2fe78bSCy Schubert return display; 4829*7f2fe78bSCy Schubert} 4830*7f2fe78bSCy Schubert 4831*7f2fe78bSCy Schubertfunction showHide( elements, show ) { 4832*7f2fe78bSCy Schubert var display, elem, 4833*7f2fe78bSCy Schubert values = [], 4834*7f2fe78bSCy Schubert index = 0, 4835*7f2fe78bSCy Schubert length = elements.length; 4836*7f2fe78bSCy Schubert 4837*7f2fe78bSCy Schubert // Determine new display value for elements that need to change 4838*7f2fe78bSCy Schubert for ( ; index < length; index++ ) { 4839*7f2fe78bSCy Schubert elem = elements[ index ]; 4840*7f2fe78bSCy Schubert if ( !elem.style ) { 4841*7f2fe78bSCy Schubert continue; 4842*7f2fe78bSCy Schubert } 4843*7f2fe78bSCy Schubert 4844*7f2fe78bSCy Schubert display = elem.style.display; 4845*7f2fe78bSCy Schubert if ( show ) { 4846*7f2fe78bSCy Schubert 4847*7f2fe78bSCy Schubert // Since we force visibility upon cascade-hidden elements, an immediate (and slow) 4848*7f2fe78bSCy Schubert // check is required in this first loop unless we have a nonempty display value (either 4849*7f2fe78bSCy Schubert // inline or about-to-be-restored) 4850*7f2fe78bSCy Schubert if ( display === "none" ) { 4851*7f2fe78bSCy Schubert values[ index ] = dataPriv.get( elem, "display" ) || null; 4852*7f2fe78bSCy Schubert if ( !values[ index ] ) { 4853*7f2fe78bSCy Schubert elem.style.display = ""; 4854*7f2fe78bSCy Schubert } 4855*7f2fe78bSCy Schubert } 4856*7f2fe78bSCy Schubert if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) { 4857*7f2fe78bSCy Schubert values[ index ] = getDefaultDisplay( elem ); 4858*7f2fe78bSCy Schubert } 4859*7f2fe78bSCy Schubert } else { 4860*7f2fe78bSCy Schubert if ( display !== "none" ) { 4861*7f2fe78bSCy Schubert values[ index ] = "none"; 4862*7f2fe78bSCy Schubert 4863*7f2fe78bSCy Schubert // Remember what we're overwriting 4864*7f2fe78bSCy Schubert dataPriv.set( elem, "display", display ); 4865*7f2fe78bSCy Schubert } 4866*7f2fe78bSCy Schubert } 4867*7f2fe78bSCy Schubert } 4868*7f2fe78bSCy Schubert 4869*7f2fe78bSCy Schubert // Set the display of the elements in a second loop to avoid constant reflow 4870*7f2fe78bSCy Schubert for ( index = 0; index < length; index++ ) { 4871*7f2fe78bSCy Schubert if ( values[ index ] != null ) { 4872*7f2fe78bSCy Schubert elements[ index ].style.display = values[ index ]; 4873*7f2fe78bSCy Schubert } 4874*7f2fe78bSCy Schubert } 4875*7f2fe78bSCy Schubert 4876*7f2fe78bSCy Schubert return elements; 4877*7f2fe78bSCy Schubert} 4878*7f2fe78bSCy Schubert 4879*7f2fe78bSCy SchubertjQuery.fn.extend( { 4880*7f2fe78bSCy Schubert show: function() { 4881*7f2fe78bSCy Schubert return showHide( this, true ); 4882*7f2fe78bSCy Schubert }, 4883*7f2fe78bSCy Schubert hide: function() { 4884*7f2fe78bSCy Schubert return showHide( this ); 4885*7f2fe78bSCy Schubert }, 4886*7f2fe78bSCy Schubert toggle: function( state ) { 4887*7f2fe78bSCy Schubert if ( typeof state === "boolean" ) { 4888*7f2fe78bSCy Schubert return state ? this.show() : this.hide(); 4889*7f2fe78bSCy Schubert } 4890*7f2fe78bSCy Schubert 4891*7f2fe78bSCy Schubert return this.each( function() { 4892*7f2fe78bSCy Schubert if ( isHiddenWithinTree( this ) ) { 4893*7f2fe78bSCy Schubert jQuery( this ).show(); 4894*7f2fe78bSCy Schubert } else { 4895*7f2fe78bSCy Schubert jQuery( this ).hide(); 4896*7f2fe78bSCy Schubert } 4897*7f2fe78bSCy Schubert } ); 4898*7f2fe78bSCy Schubert } 4899*7f2fe78bSCy Schubert} ); 4900*7f2fe78bSCy Schubertvar rcheckableType = ( /^(?:checkbox|radio)$/i ); 4901*7f2fe78bSCy Schubert 4902*7f2fe78bSCy Schubertvar rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i ); 4903*7f2fe78bSCy Schubert 4904*7f2fe78bSCy Schubertvar rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i ); 4905*7f2fe78bSCy Schubert 4906*7f2fe78bSCy Schubert 4907*7f2fe78bSCy Schubert 4908*7f2fe78bSCy Schubert( function() { 4909*7f2fe78bSCy Schubert var fragment = document.createDocumentFragment(), 4910*7f2fe78bSCy Schubert div = fragment.appendChild( document.createElement( "div" ) ), 4911*7f2fe78bSCy Schubert input = document.createElement( "input" ); 4912*7f2fe78bSCy Schubert 4913*7f2fe78bSCy Schubert // Support: Android 4.0 - 4.3 only 4914*7f2fe78bSCy Schubert // Check state lost if the name is set (#11217) 4915*7f2fe78bSCy Schubert // Support: Windows Web Apps (WWA) 4916*7f2fe78bSCy Schubert // `name` and `type` must use .setAttribute for WWA (#14901) 4917*7f2fe78bSCy Schubert input.setAttribute( "type", "radio" ); 4918*7f2fe78bSCy Schubert input.setAttribute( "checked", "checked" ); 4919*7f2fe78bSCy Schubert input.setAttribute( "name", "t" ); 4920*7f2fe78bSCy Schubert 4921*7f2fe78bSCy Schubert div.appendChild( input ); 4922*7f2fe78bSCy Schubert 4923*7f2fe78bSCy Schubert // Support: Android <=4.1 only 4924*7f2fe78bSCy Schubert // Older WebKit doesn't clone checked state correctly in fragments 4925*7f2fe78bSCy Schubert support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; 4926*7f2fe78bSCy Schubert 4927*7f2fe78bSCy Schubert // Support: IE <=11 only 4928*7f2fe78bSCy Schubert // Make sure textarea (and checkbox) defaultValue is properly cloned 4929*7f2fe78bSCy Schubert div.innerHTML = "<textarea>x</textarea>"; 4930*7f2fe78bSCy Schubert support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue; 4931*7f2fe78bSCy Schubert 4932*7f2fe78bSCy Schubert // Support: IE <=9 only 4933*7f2fe78bSCy Schubert // IE <=9 replaces <option> tags with their contents when inserted outside of 4934*7f2fe78bSCy Schubert // the select element. 4935*7f2fe78bSCy Schubert div.innerHTML = "<option></option>"; 4936*7f2fe78bSCy Schubert support.option = !!div.lastChild; 4937*7f2fe78bSCy Schubert} )(); 4938*7f2fe78bSCy Schubert 4939*7f2fe78bSCy Schubert 4940*7f2fe78bSCy Schubert// We have to close these tags to support XHTML (#13200) 4941*7f2fe78bSCy Schubertvar wrapMap = { 4942*7f2fe78bSCy Schubert 4943*7f2fe78bSCy Schubert // XHTML parsers do not magically insert elements in the 4944*7f2fe78bSCy Schubert // same way that tag soup parsers do. So we cannot shorten 4945*7f2fe78bSCy Schubert // this by omitting <tbody> or other required elements. 4946*7f2fe78bSCy Schubert thead: [ 1, "<table>", "</table>" ], 4947*7f2fe78bSCy Schubert col: [ 2, "<table><colgroup>", "</colgroup></table>" ], 4948*7f2fe78bSCy Schubert tr: [ 2, "<table><tbody>", "</tbody></table>" ], 4949*7f2fe78bSCy Schubert td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ], 4950*7f2fe78bSCy Schubert 4951*7f2fe78bSCy Schubert _default: [ 0, "", "" ] 4952*7f2fe78bSCy Schubert}; 4953*7f2fe78bSCy Schubert 4954*7f2fe78bSCy SchubertwrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; 4955*7f2fe78bSCy SchubertwrapMap.th = wrapMap.td; 4956*7f2fe78bSCy Schubert 4957*7f2fe78bSCy Schubert// Support: IE <=9 only 4958*7f2fe78bSCy Schubertif ( !support.option ) { 4959*7f2fe78bSCy Schubert wrapMap.optgroup = wrapMap.option = [ 1, "<select multiple='multiple'>", "</select>" ]; 4960*7f2fe78bSCy Schubert} 4961*7f2fe78bSCy Schubert 4962*7f2fe78bSCy Schubert 4963*7f2fe78bSCy Schubertfunction getAll( context, tag ) { 4964*7f2fe78bSCy Schubert 4965*7f2fe78bSCy Schubert // Support: IE <=9 - 11 only 4966*7f2fe78bSCy Schubert // Use typeof to avoid zero-argument method invocation on host objects (#15151) 4967*7f2fe78bSCy Schubert var ret; 4968*7f2fe78bSCy Schubert 4969*7f2fe78bSCy Schubert if ( typeof context.getElementsByTagName !== "undefined" ) { 4970*7f2fe78bSCy Schubert ret = context.getElementsByTagName( tag || "*" ); 4971*7f2fe78bSCy Schubert 4972*7f2fe78bSCy Schubert } else if ( typeof context.querySelectorAll !== "undefined" ) { 4973*7f2fe78bSCy Schubert ret = context.querySelectorAll( tag || "*" ); 4974*7f2fe78bSCy Schubert 4975*7f2fe78bSCy Schubert } else { 4976*7f2fe78bSCy Schubert ret = []; 4977*7f2fe78bSCy Schubert } 4978*7f2fe78bSCy Schubert 4979*7f2fe78bSCy Schubert if ( tag === undefined || tag && nodeName( context, tag ) ) { 4980*7f2fe78bSCy Schubert return jQuery.merge( [ context ], ret ); 4981*7f2fe78bSCy Schubert } 4982*7f2fe78bSCy Schubert 4983*7f2fe78bSCy Schubert return ret; 4984*7f2fe78bSCy Schubert} 4985*7f2fe78bSCy Schubert 4986*7f2fe78bSCy Schubert 4987*7f2fe78bSCy Schubert// Mark scripts as having already been evaluated 4988*7f2fe78bSCy Schubertfunction setGlobalEval( elems, refElements ) { 4989*7f2fe78bSCy Schubert var i = 0, 4990*7f2fe78bSCy Schubert l = elems.length; 4991*7f2fe78bSCy Schubert 4992*7f2fe78bSCy Schubert for ( ; i < l; i++ ) { 4993*7f2fe78bSCy Schubert dataPriv.set( 4994*7f2fe78bSCy Schubert elems[ i ], 4995*7f2fe78bSCy Schubert "globalEval", 4996*7f2fe78bSCy Schubert !refElements || dataPriv.get( refElements[ i ], "globalEval" ) 4997*7f2fe78bSCy Schubert ); 4998*7f2fe78bSCy Schubert } 4999*7f2fe78bSCy Schubert} 5000*7f2fe78bSCy Schubert 5001*7f2fe78bSCy Schubert 5002*7f2fe78bSCy Schubertvar rhtml = /<|&#?\w+;/; 5003*7f2fe78bSCy Schubert 5004*7f2fe78bSCy Schubertfunction buildFragment( elems, context, scripts, selection, ignored ) { 5005*7f2fe78bSCy Schubert var elem, tmp, tag, wrap, attached, j, 5006*7f2fe78bSCy Schubert fragment = context.createDocumentFragment(), 5007*7f2fe78bSCy Schubert nodes = [], 5008*7f2fe78bSCy Schubert i = 0, 5009*7f2fe78bSCy Schubert l = elems.length; 5010*7f2fe78bSCy Schubert 5011*7f2fe78bSCy Schubert for ( ; i < l; i++ ) { 5012*7f2fe78bSCy Schubert elem = elems[ i ]; 5013*7f2fe78bSCy Schubert 5014*7f2fe78bSCy Schubert if ( elem || elem === 0 ) { 5015*7f2fe78bSCy Schubert 5016*7f2fe78bSCy Schubert // Add nodes directly 5017*7f2fe78bSCy Schubert if ( toType( elem ) === "object" ) { 5018*7f2fe78bSCy Schubert 5019*7f2fe78bSCy Schubert // Support: Android <=4.0 only, PhantomJS 1 only 5020*7f2fe78bSCy Schubert // push.apply(_, arraylike) throws on ancient WebKit 5021*7f2fe78bSCy Schubert jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem ); 5022*7f2fe78bSCy Schubert 5023*7f2fe78bSCy Schubert // Convert non-html into a text node 5024*7f2fe78bSCy Schubert } else if ( !rhtml.test( elem ) ) { 5025*7f2fe78bSCy Schubert nodes.push( context.createTextNode( elem ) ); 5026*7f2fe78bSCy Schubert 5027*7f2fe78bSCy Schubert // Convert html into DOM nodes 5028*7f2fe78bSCy Schubert } else { 5029*7f2fe78bSCy Schubert tmp = tmp || fragment.appendChild( context.createElement( "div" ) ); 5030*7f2fe78bSCy Schubert 5031*7f2fe78bSCy Schubert // Deserialize a standard representation 5032*7f2fe78bSCy Schubert tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase(); 5033*7f2fe78bSCy Schubert wrap = wrapMap[ tag ] || wrapMap._default; 5034*7f2fe78bSCy Schubert tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ]; 5035*7f2fe78bSCy Schubert 5036*7f2fe78bSCy Schubert // Descend through wrappers to the right content 5037*7f2fe78bSCy Schubert j = wrap[ 0 ]; 5038*7f2fe78bSCy Schubert while ( j-- ) { 5039*7f2fe78bSCy Schubert tmp = tmp.lastChild; 5040*7f2fe78bSCy Schubert } 5041*7f2fe78bSCy Schubert 5042*7f2fe78bSCy Schubert // Support: Android <=4.0 only, PhantomJS 1 only 5043*7f2fe78bSCy Schubert // push.apply(_, arraylike) throws on ancient WebKit 5044*7f2fe78bSCy Schubert jQuery.merge( nodes, tmp.childNodes ); 5045*7f2fe78bSCy Schubert 5046*7f2fe78bSCy Schubert // Remember the top-level container 5047*7f2fe78bSCy Schubert tmp = fragment.firstChild; 5048*7f2fe78bSCy Schubert 5049*7f2fe78bSCy Schubert // Ensure the created nodes are orphaned (#12392) 5050*7f2fe78bSCy Schubert tmp.textContent = ""; 5051*7f2fe78bSCy Schubert } 5052*7f2fe78bSCy Schubert } 5053*7f2fe78bSCy Schubert } 5054*7f2fe78bSCy Schubert 5055*7f2fe78bSCy Schubert // Remove wrapper from fragment 5056*7f2fe78bSCy Schubert fragment.textContent = ""; 5057*7f2fe78bSCy Schubert 5058*7f2fe78bSCy Schubert i = 0; 5059*7f2fe78bSCy Schubert while ( ( elem = nodes[ i++ ] ) ) { 5060*7f2fe78bSCy Schubert 5061*7f2fe78bSCy Schubert // Skip elements already in the context collection (trac-4087) 5062*7f2fe78bSCy Schubert if ( selection && jQuery.inArray( elem, selection ) > -1 ) { 5063*7f2fe78bSCy Schubert if ( ignored ) { 5064*7f2fe78bSCy Schubert ignored.push( elem ); 5065*7f2fe78bSCy Schubert } 5066*7f2fe78bSCy Schubert continue; 5067*7f2fe78bSCy Schubert } 5068*7f2fe78bSCy Schubert 5069*7f2fe78bSCy Schubert attached = isAttached( elem ); 5070*7f2fe78bSCy Schubert 5071*7f2fe78bSCy Schubert // Append to fragment 5072*7f2fe78bSCy Schubert tmp = getAll( fragment.appendChild( elem ), "script" ); 5073*7f2fe78bSCy Schubert 5074*7f2fe78bSCy Schubert // Preserve script evaluation history 5075*7f2fe78bSCy Schubert if ( attached ) { 5076*7f2fe78bSCy Schubert setGlobalEval( tmp ); 5077*7f2fe78bSCy Schubert } 5078*7f2fe78bSCy Schubert 5079*7f2fe78bSCy Schubert // Capture executables 5080*7f2fe78bSCy Schubert if ( scripts ) { 5081*7f2fe78bSCy Schubert j = 0; 5082*7f2fe78bSCy Schubert while ( ( elem = tmp[ j++ ] ) ) { 5083*7f2fe78bSCy Schubert if ( rscriptType.test( elem.type || "" ) ) { 5084*7f2fe78bSCy Schubert scripts.push( elem ); 5085*7f2fe78bSCy Schubert } 5086*7f2fe78bSCy Schubert } 5087*7f2fe78bSCy Schubert } 5088*7f2fe78bSCy Schubert } 5089*7f2fe78bSCy Schubert 5090*7f2fe78bSCy Schubert return fragment; 5091*7f2fe78bSCy Schubert} 5092*7f2fe78bSCy Schubert 5093*7f2fe78bSCy Schubert 5094*7f2fe78bSCy Schubertvar rtypenamespace = /^([^.]*)(?:\.(.+)|)/; 5095*7f2fe78bSCy Schubert 5096*7f2fe78bSCy Schubertfunction returnTrue() { 5097*7f2fe78bSCy Schubert return true; 5098*7f2fe78bSCy Schubert} 5099*7f2fe78bSCy Schubert 5100*7f2fe78bSCy Schubertfunction returnFalse() { 5101*7f2fe78bSCy Schubert return false; 5102*7f2fe78bSCy Schubert} 5103*7f2fe78bSCy Schubert 5104*7f2fe78bSCy Schubert// Support: IE <=9 - 11+ 5105*7f2fe78bSCy Schubert// focus() and blur() are asynchronous, except when they are no-op. 5106*7f2fe78bSCy Schubert// So expect focus to be synchronous when the element is already active, 5107*7f2fe78bSCy Schubert// and blur to be synchronous when the element is not already active. 5108*7f2fe78bSCy Schubert// (focus and blur are always synchronous in other supported browsers, 5109*7f2fe78bSCy Schubert// this just defines when we can count on it). 5110*7f2fe78bSCy Schubertfunction expectSync( elem, type ) { 5111*7f2fe78bSCy Schubert return ( elem === safeActiveElement() ) === ( type === "focus" ); 5112*7f2fe78bSCy Schubert} 5113*7f2fe78bSCy Schubert 5114*7f2fe78bSCy Schubert// Support: IE <=9 only 5115*7f2fe78bSCy Schubert// Accessing document.activeElement can throw unexpectedly 5116*7f2fe78bSCy Schubert// https://bugs.jquery.com/ticket/13393 5117*7f2fe78bSCy Schubertfunction safeActiveElement() { 5118*7f2fe78bSCy Schubert try { 5119*7f2fe78bSCy Schubert return document.activeElement; 5120*7f2fe78bSCy Schubert } catch ( err ) { } 5121*7f2fe78bSCy Schubert} 5122*7f2fe78bSCy Schubert 5123*7f2fe78bSCy Schubertfunction on( elem, types, selector, data, fn, one ) { 5124*7f2fe78bSCy Schubert var origFn, type; 5125*7f2fe78bSCy Schubert 5126*7f2fe78bSCy Schubert // Types can be a map of types/handlers 5127*7f2fe78bSCy Schubert if ( typeof types === "object" ) { 5128*7f2fe78bSCy Schubert 5129*7f2fe78bSCy Schubert // ( types-Object, selector, data ) 5130*7f2fe78bSCy Schubert if ( typeof selector !== "string" ) { 5131*7f2fe78bSCy Schubert 5132*7f2fe78bSCy Schubert // ( types-Object, data ) 5133*7f2fe78bSCy Schubert data = data || selector; 5134*7f2fe78bSCy Schubert selector = undefined; 5135*7f2fe78bSCy Schubert } 5136*7f2fe78bSCy Schubert for ( type in types ) { 5137*7f2fe78bSCy Schubert on( elem, type, selector, data, types[ type ], one ); 5138*7f2fe78bSCy Schubert } 5139*7f2fe78bSCy Schubert return elem; 5140*7f2fe78bSCy Schubert } 5141*7f2fe78bSCy Schubert 5142*7f2fe78bSCy Schubert if ( data == null && fn == null ) { 5143*7f2fe78bSCy Schubert 5144*7f2fe78bSCy Schubert // ( types, fn ) 5145*7f2fe78bSCy Schubert fn = selector; 5146*7f2fe78bSCy Schubert data = selector = undefined; 5147*7f2fe78bSCy Schubert } else if ( fn == null ) { 5148*7f2fe78bSCy Schubert if ( typeof selector === "string" ) { 5149*7f2fe78bSCy Schubert 5150*7f2fe78bSCy Schubert // ( types, selector, fn ) 5151*7f2fe78bSCy Schubert fn = data; 5152*7f2fe78bSCy Schubert data = undefined; 5153*7f2fe78bSCy Schubert } else { 5154*7f2fe78bSCy Schubert 5155*7f2fe78bSCy Schubert // ( types, data, fn ) 5156*7f2fe78bSCy Schubert fn = data; 5157*7f2fe78bSCy Schubert data = selector; 5158*7f2fe78bSCy Schubert selector = undefined; 5159*7f2fe78bSCy Schubert } 5160*7f2fe78bSCy Schubert } 5161*7f2fe78bSCy Schubert if ( fn === false ) { 5162*7f2fe78bSCy Schubert fn = returnFalse; 5163*7f2fe78bSCy Schubert } else if ( !fn ) { 5164*7f2fe78bSCy Schubert return elem; 5165*7f2fe78bSCy Schubert } 5166*7f2fe78bSCy Schubert 5167*7f2fe78bSCy Schubert if ( one === 1 ) { 5168*7f2fe78bSCy Schubert origFn = fn; 5169*7f2fe78bSCy Schubert fn = function( event ) { 5170*7f2fe78bSCy Schubert 5171*7f2fe78bSCy Schubert // Can use an empty set, since event contains the info 5172*7f2fe78bSCy Schubert jQuery().off( event ); 5173*7f2fe78bSCy Schubert return origFn.apply( this, arguments ); 5174*7f2fe78bSCy Schubert }; 5175*7f2fe78bSCy Schubert 5176*7f2fe78bSCy Schubert // Use same guid so caller can remove using origFn 5177*7f2fe78bSCy Schubert fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); 5178*7f2fe78bSCy Schubert } 5179*7f2fe78bSCy Schubert return elem.each( function() { 5180*7f2fe78bSCy Schubert jQuery.event.add( this, types, fn, data, selector ); 5181*7f2fe78bSCy Schubert } ); 5182*7f2fe78bSCy Schubert} 5183*7f2fe78bSCy Schubert 5184*7f2fe78bSCy Schubert/* 5185*7f2fe78bSCy Schubert * Helper functions for managing events -- not part of the public interface. 5186*7f2fe78bSCy Schubert * Props to Dean Edwards' addEvent library for many of the ideas. 5187*7f2fe78bSCy Schubert */ 5188*7f2fe78bSCy SchubertjQuery.event = { 5189*7f2fe78bSCy Schubert 5190*7f2fe78bSCy Schubert global: {}, 5191*7f2fe78bSCy Schubert 5192*7f2fe78bSCy Schubert add: function( elem, types, handler, data, selector ) { 5193*7f2fe78bSCy Schubert 5194*7f2fe78bSCy Schubert var handleObjIn, eventHandle, tmp, 5195*7f2fe78bSCy Schubert events, t, handleObj, 5196*7f2fe78bSCy Schubert special, handlers, type, namespaces, origType, 5197*7f2fe78bSCy Schubert elemData = dataPriv.get( elem ); 5198*7f2fe78bSCy Schubert 5199*7f2fe78bSCy Schubert // Only attach events to objects that accept data 5200*7f2fe78bSCy Schubert if ( !acceptData( elem ) ) { 5201*7f2fe78bSCy Schubert return; 5202*7f2fe78bSCy Schubert } 5203*7f2fe78bSCy Schubert 5204*7f2fe78bSCy Schubert // Caller can pass in an object of custom data in lieu of the handler 5205*7f2fe78bSCy Schubert if ( handler.handler ) { 5206*7f2fe78bSCy Schubert handleObjIn = handler; 5207*7f2fe78bSCy Schubert handler = handleObjIn.handler; 5208*7f2fe78bSCy Schubert selector = handleObjIn.selector; 5209*7f2fe78bSCy Schubert } 5210*7f2fe78bSCy Schubert 5211*7f2fe78bSCy Schubert // Ensure that invalid selectors throw exceptions at attach time 5212*7f2fe78bSCy Schubert // Evaluate against documentElement in case elem is a non-element node (e.g., document) 5213*7f2fe78bSCy Schubert if ( selector ) { 5214*7f2fe78bSCy Schubert jQuery.find.matchesSelector( documentElement, selector ); 5215*7f2fe78bSCy Schubert } 5216*7f2fe78bSCy Schubert 5217*7f2fe78bSCy Schubert // Make sure that the handler has a unique ID, used to find/remove it later 5218*7f2fe78bSCy Schubert if ( !handler.guid ) { 5219*7f2fe78bSCy Schubert handler.guid = jQuery.guid++; 5220*7f2fe78bSCy Schubert } 5221*7f2fe78bSCy Schubert 5222*7f2fe78bSCy Schubert // Init the element's event structure and main handler, if this is the first 5223*7f2fe78bSCy Schubert if ( !( events = elemData.events ) ) { 5224*7f2fe78bSCy Schubert events = elemData.events = Object.create( null ); 5225*7f2fe78bSCy Schubert } 5226*7f2fe78bSCy Schubert if ( !( eventHandle = elemData.handle ) ) { 5227*7f2fe78bSCy Schubert eventHandle = elemData.handle = function( e ) { 5228*7f2fe78bSCy Schubert 5229*7f2fe78bSCy Schubert // Discard the second event of a jQuery.event.trigger() and 5230*7f2fe78bSCy Schubert // when an event is called after a page has unloaded 5231*7f2fe78bSCy Schubert return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ? 5232*7f2fe78bSCy Schubert jQuery.event.dispatch.apply( elem, arguments ) : undefined; 5233*7f2fe78bSCy Schubert }; 5234*7f2fe78bSCy Schubert } 5235*7f2fe78bSCy Schubert 5236*7f2fe78bSCy Schubert // Handle multiple events separated by a space 5237*7f2fe78bSCy Schubert types = ( types || "" ).match( rnothtmlwhite ) || [ "" ]; 5238*7f2fe78bSCy Schubert t = types.length; 5239*7f2fe78bSCy Schubert while ( t-- ) { 5240*7f2fe78bSCy Schubert tmp = rtypenamespace.exec( types[ t ] ) || []; 5241*7f2fe78bSCy Schubert type = origType = tmp[ 1 ]; 5242*7f2fe78bSCy Schubert namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort(); 5243*7f2fe78bSCy Schubert 5244*7f2fe78bSCy Schubert // There *must* be a type, no attaching namespace-only handlers 5245*7f2fe78bSCy Schubert if ( !type ) { 5246*7f2fe78bSCy Schubert continue; 5247*7f2fe78bSCy Schubert } 5248*7f2fe78bSCy Schubert 5249*7f2fe78bSCy Schubert // If event changes its type, use the special event handlers for the changed type 5250*7f2fe78bSCy Schubert special = jQuery.event.special[ type ] || {}; 5251*7f2fe78bSCy Schubert 5252*7f2fe78bSCy Schubert // If selector defined, determine special event api type, otherwise given type 5253*7f2fe78bSCy Schubert type = ( selector ? special.delegateType : special.bindType ) || type; 5254*7f2fe78bSCy Schubert 5255*7f2fe78bSCy Schubert // Update special based on newly reset type 5256*7f2fe78bSCy Schubert special = jQuery.event.special[ type ] || {}; 5257*7f2fe78bSCy Schubert 5258*7f2fe78bSCy Schubert // handleObj is passed to all event handlers 5259*7f2fe78bSCy Schubert handleObj = jQuery.extend( { 5260*7f2fe78bSCy Schubert type: type, 5261*7f2fe78bSCy Schubert origType: origType, 5262*7f2fe78bSCy Schubert data: data, 5263*7f2fe78bSCy Schubert handler: handler, 5264*7f2fe78bSCy Schubert guid: handler.guid, 5265*7f2fe78bSCy Schubert selector: selector, 5266*7f2fe78bSCy Schubert needsContext: selector && jQuery.expr.match.needsContext.test( selector ), 5267*7f2fe78bSCy Schubert namespace: namespaces.join( "." ) 5268*7f2fe78bSCy Schubert }, handleObjIn ); 5269*7f2fe78bSCy Schubert 5270*7f2fe78bSCy Schubert // Init the event handler queue if we're the first 5271*7f2fe78bSCy Schubert if ( !( handlers = events[ type ] ) ) { 5272*7f2fe78bSCy Schubert handlers = events[ type ] = []; 5273*7f2fe78bSCy Schubert handlers.delegateCount = 0; 5274*7f2fe78bSCy Schubert 5275*7f2fe78bSCy Schubert // Only use addEventListener if the special events handler returns false 5276*7f2fe78bSCy Schubert if ( !special.setup || 5277*7f2fe78bSCy Schubert special.setup.call( elem, data, namespaces, eventHandle ) === false ) { 5278*7f2fe78bSCy Schubert 5279*7f2fe78bSCy Schubert if ( elem.addEventListener ) { 5280*7f2fe78bSCy Schubert elem.addEventListener( type, eventHandle ); 5281*7f2fe78bSCy Schubert } 5282*7f2fe78bSCy Schubert } 5283*7f2fe78bSCy Schubert } 5284*7f2fe78bSCy Schubert 5285*7f2fe78bSCy Schubert if ( special.add ) { 5286*7f2fe78bSCy Schubert special.add.call( elem, handleObj ); 5287*7f2fe78bSCy Schubert 5288*7f2fe78bSCy Schubert if ( !handleObj.handler.guid ) { 5289*7f2fe78bSCy Schubert handleObj.handler.guid = handler.guid; 5290*7f2fe78bSCy Schubert } 5291*7f2fe78bSCy Schubert } 5292*7f2fe78bSCy Schubert 5293*7f2fe78bSCy Schubert // Add to the element's handler list, delegates in front 5294*7f2fe78bSCy Schubert if ( selector ) { 5295*7f2fe78bSCy Schubert handlers.splice( handlers.delegateCount++, 0, handleObj ); 5296*7f2fe78bSCy Schubert } else { 5297*7f2fe78bSCy Schubert handlers.push( handleObj ); 5298*7f2fe78bSCy Schubert } 5299*7f2fe78bSCy Schubert 5300*7f2fe78bSCy Schubert // Keep track of which events have ever been used, for event optimization 5301*7f2fe78bSCy Schubert jQuery.event.global[ type ] = true; 5302*7f2fe78bSCy Schubert } 5303*7f2fe78bSCy Schubert 5304*7f2fe78bSCy Schubert }, 5305*7f2fe78bSCy Schubert 5306*7f2fe78bSCy Schubert // Detach an event or set of events from an element 5307*7f2fe78bSCy Schubert remove: function( elem, types, handler, selector, mappedTypes ) { 5308*7f2fe78bSCy Schubert 5309*7f2fe78bSCy Schubert var j, origCount, tmp, 5310*7f2fe78bSCy Schubert events, t, handleObj, 5311*7f2fe78bSCy Schubert special, handlers, type, namespaces, origType, 5312*7f2fe78bSCy Schubert elemData = dataPriv.hasData( elem ) && dataPriv.get( elem ); 5313*7f2fe78bSCy Schubert 5314*7f2fe78bSCy Schubert if ( !elemData || !( events = elemData.events ) ) { 5315*7f2fe78bSCy Schubert return; 5316*7f2fe78bSCy Schubert } 5317*7f2fe78bSCy Schubert 5318*7f2fe78bSCy Schubert // Once for each type.namespace in types; type may be omitted 5319*7f2fe78bSCy Schubert types = ( types || "" ).match( rnothtmlwhite ) || [ "" ]; 5320*7f2fe78bSCy Schubert t = types.length; 5321*7f2fe78bSCy Schubert while ( t-- ) { 5322*7f2fe78bSCy Schubert tmp = rtypenamespace.exec( types[ t ] ) || []; 5323*7f2fe78bSCy Schubert type = origType = tmp[ 1 ]; 5324*7f2fe78bSCy Schubert namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort(); 5325*7f2fe78bSCy Schubert 5326*7f2fe78bSCy Schubert // Unbind all events (on this namespace, if provided) for the element 5327*7f2fe78bSCy Schubert if ( !type ) { 5328*7f2fe78bSCy Schubert for ( type in events ) { 5329*7f2fe78bSCy Schubert jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); 5330*7f2fe78bSCy Schubert } 5331*7f2fe78bSCy Schubert continue; 5332*7f2fe78bSCy Schubert } 5333*7f2fe78bSCy Schubert 5334*7f2fe78bSCy Schubert special = jQuery.event.special[ type ] || {}; 5335*7f2fe78bSCy Schubert type = ( selector ? special.delegateType : special.bindType ) || type; 5336*7f2fe78bSCy Schubert handlers = events[ type ] || []; 5337*7f2fe78bSCy Schubert tmp = tmp[ 2 ] && 5338*7f2fe78bSCy Schubert new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ); 5339*7f2fe78bSCy Schubert 5340*7f2fe78bSCy Schubert // Remove matching events 5341*7f2fe78bSCy Schubert origCount = j = handlers.length; 5342*7f2fe78bSCy Schubert while ( j-- ) { 5343*7f2fe78bSCy Schubert handleObj = handlers[ j ]; 5344*7f2fe78bSCy Schubert 5345*7f2fe78bSCy Schubert if ( ( mappedTypes || origType === handleObj.origType ) && 5346*7f2fe78bSCy Schubert ( !handler || handler.guid === handleObj.guid ) && 5347*7f2fe78bSCy Schubert ( !tmp || tmp.test( handleObj.namespace ) ) && 5348*7f2fe78bSCy Schubert ( !selector || selector === handleObj.selector || 5349*7f2fe78bSCy Schubert selector === "**" && handleObj.selector ) ) { 5350*7f2fe78bSCy Schubert handlers.splice( j, 1 ); 5351*7f2fe78bSCy Schubert 5352*7f2fe78bSCy Schubert if ( handleObj.selector ) { 5353*7f2fe78bSCy Schubert handlers.delegateCount--; 5354*7f2fe78bSCy Schubert } 5355*7f2fe78bSCy Schubert if ( special.remove ) { 5356*7f2fe78bSCy Schubert special.remove.call( elem, handleObj ); 5357*7f2fe78bSCy Schubert } 5358*7f2fe78bSCy Schubert } 5359*7f2fe78bSCy Schubert } 5360*7f2fe78bSCy Schubert 5361*7f2fe78bSCy Schubert // Remove generic event handler if we removed something and no more handlers exist 5362*7f2fe78bSCy Schubert // (avoids potential for endless recursion during removal of special event handlers) 5363*7f2fe78bSCy Schubert if ( origCount && !handlers.length ) { 5364*7f2fe78bSCy Schubert if ( !special.teardown || 5365*7f2fe78bSCy Schubert special.teardown.call( elem, namespaces, elemData.handle ) === false ) { 5366*7f2fe78bSCy Schubert 5367*7f2fe78bSCy Schubert jQuery.removeEvent( elem, type, elemData.handle ); 5368*7f2fe78bSCy Schubert } 5369*7f2fe78bSCy Schubert 5370*7f2fe78bSCy Schubert delete events[ type ]; 5371*7f2fe78bSCy Schubert } 5372*7f2fe78bSCy Schubert } 5373*7f2fe78bSCy Schubert 5374*7f2fe78bSCy Schubert // Remove data and the expando if it's no longer used 5375*7f2fe78bSCy Schubert if ( jQuery.isEmptyObject( events ) ) { 5376*7f2fe78bSCy Schubert dataPriv.remove( elem, "handle events" ); 5377*7f2fe78bSCy Schubert } 5378*7f2fe78bSCy Schubert }, 5379*7f2fe78bSCy Schubert 5380*7f2fe78bSCy Schubert dispatch: function( nativeEvent ) { 5381*7f2fe78bSCy Schubert 5382*7f2fe78bSCy Schubert var i, j, ret, matched, handleObj, handlerQueue, 5383*7f2fe78bSCy Schubert args = new Array( arguments.length ), 5384*7f2fe78bSCy Schubert 5385*7f2fe78bSCy Schubert // Make a writable jQuery.Event from the native event object 5386*7f2fe78bSCy Schubert event = jQuery.event.fix( nativeEvent ), 5387*7f2fe78bSCy Schubert 5388*7f2fe78bSCy Schubert handlers = ( 5389*7f2fe78bSCy Schubert dataPriv.get( this, "events" ) || Object.create( null ) 5390*7f2fe78bSCy Schubert )[ event.type ] || [], 5391*7f2fe78bSCy Schubert special = jQuery.event.special[ event.type ] || {}; 5392*7f2fe78bSCy Schubert 5393*7f2fe78bSCy Schubert // Use the fix-ed jQuery.Event rather than the (read-only) native event 5394*7f2fe78bSCy Schubert args[ 0 ] = event; 5395*7f2fe78bSCy Schubert 5396*7f2fe78bSCy Schubert for ( i = 1; i < arguments.length; i++ ) { 5397*7f2fe78bSCy Schubert args[ i ] = arguments[ i ]; 5398*7f2fe78bSCy Schubert } 5399*7f2fe78bSCy Schubert 5400*7f2fe78bSCy Schubert event.delegateTarget = this; 5401*7f2fe78bSCy Schubert 5402*7f2fe78bSCy Schubert // Call the preDispatch hook for the mapped type, and let it bail if desired 5403*7f2fe78bSCy Schubert if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { 5404*7f2fe78bSCy Schubert return; 5405*7f2fe78bSCy Schubert } 5406*7f2fe78bSCy Schubert 5407*7f2fe78bSCy Schubert // Determine handlers 5408*7f2fe78bSCy Schubert handlerQueue = jQuery.event.handlers.call( this, event, handlers ); 5409*7f2fe78bSCy Schubert 5410*7f2fe78bSCy Schubert // Run delegates first; they may want to stop propagation beneath us 5411*7f2fe78bSCy Schubert i = 0; 5412*7f2fe78bSCy Schubert while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) { 5413*7f2fe78bSCy Schubert event.currentTarget = matched.elem; 5414*7f2fe78bSCy Schubert 5415*7f2fe78bSCy Schubert j = 0; 5416*7f2fe78bSCy Schubert while ( ( handleObj = matched.handlers[ j++ ] ) && 5417*7f2fe78bSCy Schubert !event.isImmediatePropagationStopped() ) { 5418*7f2fe78bSCy Schubert 5419*7f2fe78bSCy Schubert // If the event is namespaced, then each handler is only invoked if it is 5420*7f2fe78bSCy Schubert // specially universal or its namespaces are a superset of the event's. 5421*7f2fe78bSCy Schubert if ( !event.rnamespace || handleObj.namespace === false || 5422*7f2fe78bSCy Schubert event.rnamespace.test( handleObj.namespace ) ) { 5423*7f2fe78bSCy Schubert 5424*7f2fe78bSCy Schubert event.handleObj = handleObj; 5425*7f2fe78bSCy Schubert event.data = handleObj.data; 5426*7f2fe78bSCy Schubert 5427*7f2fe78bSCy Schubert ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle || 5428*7f2fe78bSCy Schubert handleObj.handler ).apply( matched.elem, args ); 5429*7f2fe78bSCy Schubert 5430*7f2fe78bSCy Schubert if ( ret !== undefined ) { 5431*7f2fe78bSCy Schubert if ( ( event.result = ret ) === false ) { 5432*7f2fe78bSCy Schubert event.preventDefault(); 5433*7f2fe78bSCy Schubert event.stopPropagation(); 5434*7f2fe78bSCy Schubert } 5435*7f2fe78bSCy Schubert } 5436*7f2fe78bSCy Schubert } 5437*7f2fe78bSCy Schubert } 5438*7f2fe78bSCy Schubert } 5439*7f2fe78bSCy Schubert 5440*7f2fe78bSCy Schubert // Call the postDispatch hook for the mapped type 5441*7f2fe78bSCy Schubert if ( special.postDispatch ) { 5442*7f2fe78bSCy Schubert special.postDispatch.call( this, event ); 5443*7f2fe78bSCy Schubert } 5444*7f2fe78bSCy Schubert 5445*7f2fe78bSCy Schubert return event.result; 5446*7f2fe78bSCy Schubert }, 5447*7f2fe78bSCy Schubert 5448*7f2fe78bSCy Schubert handlers: function( event, handlers ) { 5449*7f2fe78bSCy Schubert var i, handleObj, sel, matchedHandlers, matchedSelectors, 5450*7f2fe78bSCy Schubert handlerQueue = [], 5451*7f2fe78bSCy Schubert delegateCount = handlers.delegateCount, 5452*7f2fe78bSCy Schubert cur = event.target; 5453*7f2fe78bSCy Schubert 5454*7f2fe78bSCy Schubert // Find delegate handlers 5455*7f2fe78bSCy Schubert if ( delegateCount && 5456*7f2fe78bSCy Schubert 5457*7f2fe78bSCy Schubert // Support: IE <=9 5458*7f2fe78bSCy Schubert // Black-hole SVG <use> instance trees (trac-13180) 5459*7f2fe78bSCy Schubert cur.nodeType && 5460*7f2fe78bSCy Schubert 5461*7f2fe78bSCy Schubert // Support: Firefox <=42 5462*7f2fe78bSCy Schubert // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861) 5463*7f2fe78bSCy Schubert // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click 5464*7f2fe78bSCy Schubert // Support: IE 11 only 5465*7f2fe78bSCy Schubert // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343) 5466*7f2fe78bSCy Schubert !( event.type === "click" && event.button >= 1 ) ) { 5467*7f2fe78bSCy Schubert 5468*7f2fe78bSCy Schubert for ( ; cur !== this; cur = cur.parentNode || this ) { 5469*7f2fe78bSCy Schubert 5470*7f2fe78bSCy Schubert // Don't check non-elements (#13208) 5471*7f2fe78bSCy Schubert // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764) 5472*7f2fe78bSCy Schubert if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) { 5473*7f2fe78bSCy Schubert matchedHandlers = []; 5474*7f2fe78bSCy Schubert matchedSelectors = {}; 5475*7f2fe78bSCy Schubert for ( i = 0; i < delegateCount; i++ ) { 5476*7f2fe78bSCy Schubert handleObj = handlers[ i ]; 5477*7f2fe78bSCy Schubert 5478*7f2fe78bSCy Schubert // Don't conflict with Object.prototype properties (#13203) 5479*7f2fe78bSCy Schubert sel = handleObj.selector + " "; 5480*7f2fe78bSCy Schubert 5481*7f2fe78bSCy Schubert if ( matchedSelectors[ sel ] === undefined ) { 5482*7f2fe78bSCy Schubert matchedSelectors[ sel ] = handleObj.needsContext ? 5483*7f2fe78bSCy Schubert jQuery( sel, this ).index( cur ) > -1 : 5484*7f2fe78bSCy Schubert jQuery.find( sel, this, null, [ cur ] ).length; 5485*7f2fe78bSCy Schubert } 5486*7f2fe78bSCy Schubert if ( matchedSelectors[ sel ] ) { 5487*7f2fe78bSCy Schubert matchedHandlers.push( handleObj ); 5488*7f2fe78bSCy Schubert } 5489*7f2fe78bSCy Schubert } 5490*7f2fe78bSCy Schubert if ( matchedHandlers.length ) { 5491*7f2fe78bSCy Schubert handlerQueue.push( { elem: cur, handlers: matchedHandlers } ); 5492*7f2fe78bSCy Schubert } 5493*7f2fe78bSCy Schubert } 5494*7f2fe78bSCy Schubert } 5495*7f2fe78bSCy Schubert } 5496*7f2fe78bSCy Schubert 5497*7f2fe78bSCy Schubert // Add the remaining (directly-bound) handlers 5498*7f2fe78bSCy Schubert cur = this; 5499*7f2fe78bSCy Schubert if ( delegateCount < handlers.length ) { 5500*7f2fe78bSCy Schubert handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } ); 5501*7f2fe78bSCy Schubert } 5502*7f2fe78bSCy Schubert 5503*7f2fe78bSCy Schubert return handlerQueue; 5504*7f2fe78bSCy Schubert }, 5505*7f2fe78bSCy Schubert 5506*7f2fe78bSCy Schubert addProp: function( name, hook ) { 5507*7f2fe78bSCy Schubert Object.defineProperty( jQuery.Event.prototype, name, { 5508*7f2fe78bSCy Schubert enumerable: true, 5509*7f2fe78bSCy Schubert configurable: true, 5510*7f2fe78bSCy Schubert 5511*7f2fe78bSCy Schubert get: isFunction( hook ) ? 5512*7f2fe78bSCy Schubert function() { 5513*7f2fe78bSCy Schubert if ( this.originalEvent ) { 5514*7f2fe78bSCy Schubert return hook( this.originalEvent ); 5515*7f2fe78bSCy Schubert } 5516*7f2fe78bSCy Schubert } : 5517*7f2fe78bSCy Schubert function() { 5518*7f2fe78bSCy Schubert if ( this.originalEvent ) { 5519*7f2fe78bSCy Schubert return this.originalEvent[ name ]; 5520*7f2fe78bSCy Schubert } 5521*7f2fe78bSCy Schubert }, 5522*7f2fe78bSCy Schubert 5523*7f2fe78bSCy Schubert set: function( value ) { 5524*7f2fe78bSCy Schubert Object.defineProperty( this, name, { 5525*7f2fe78bSCy Schubert enumerable: true, 5526*7f2fe78bSCy Schubert configurable: true, 5527*7f2fe78bSCy Schubert writable: true, 5528*7f2fe78bSCy Schubert value: value 5529*7f2fe78bSCy Schubert } ); 5530*7f2fe78bSCy Schubert } 5531*7f2fe78bSCy Schubert } ); 5532*7f2fe78bSCy Schubert }, 5533*7f2fe78bSCy Schubert 5534*7f2fe78bSCy Schubert fix: function( originalEvent ) { 5535*7f2fe78bSCy Schubert return originalEvent[ jQuery.expando ] ? 5536*7f2fe78bSCy Schubert originalEvent : 5537*7f2fe78bSCy Schubert new jQuery.Event( originalEvent ); 5538*7f2fe78bSCy Schubert }, 5539*7f2fe78bSCy Schubert 5540*7f2fe78bSCy Schubert special: { 5541*7f2fe78bSCy Schubert load: { 5542*7f2fe78bSCy Schubert 5543*7f2fe78bSCy Schubert // Prevent triggered image.load events from bubbling to window.load 5544*7f2fe78bSCy Schubert noBubble: true 5545*7f2fe78bSCy Schubert }, 5546*7f2fe78bSCy Schubert click: { 5547*7f2fe78bSCy Schubert 5548*7f2fe78bSCy Schubert // Utilize native event to ensure correct state for checkable inputs 5549*7f2fe78bSCy Schubert setup: function( data ) { 5550*7f2fe78bSCy Schubert 5551*7f2fe78bSCy Schubert // For mutual compressibility with _default, replace `this` access with a local var. 5552*7f2fe78bSCy Schubert // `|| data` is dead code meant only to preserve the variable through minification. 5553*7f2fe78bSCy Schubert var el = this || data; 5554*7f2fe78bSCy Schubert 5555*7f2fe78bSCy Schubert // Claim the first handler 5556*7f2fe78bSCy Schubert if ( rcheckableType.test( el.type ) && 5557*7f2fe78bSCy Schubert el.click && nodeName( el, "input" ) ) { 5558*7f2fe78bSCy Schubert 5559*7f2fe78bSCy Schubert // dataPriv.set( el, "click", ... ) 5560*7f2fe78bSCy Schubert leverageNative( el, "click", returnTrue ); 5561*7f2fe78bSCy Schubert } 5562*7f2fe78bSCy Schubert 5563*7f2fe78bSCy Schubert // Return false to allow normal processing in the caller 5564*7f2fe78bSCy Schubert return false; 5565*7f2fe78bSCy Schubert }, 5566*7f2fe78bSCy Schubert trigger: function( data ) { 5567*7f2fe78bSCy Schubert 5568*7f2fe78bSCy Schubert // For mutual compressibility with _default, replace `this` access with a local var. 5569*7f2fe78bSCy Schubert // `|| data` is dead code meant only to preserve the variable through minification. 5570*7f2fe78bSCy Schubert var el = this || data; 5571*7f2fe78bSCy Schubert 5572*7f2fe78bSCy Schubert // Force setup before triggering a click 5573*7f2fe78bSCy Schubert if ( rcheckableType.test( el.type ) && 5574*7f2fe78bSCy Schubert el.click && nodeName( el, "input" ) ) { 5575*7f2fe78bSCy Schubert 5576*7f2fe78bSCy Schubert leverageNative( el, "click" ); 5577*7f2fe78bSCy Schubert } 5578*7f2fe78bSCy Schubert 5579*7f2fe78bSCy Schubert // Return non-false to allow normal event-path propagation 5580*7f2fe78bSCy Schubert return true; 5581*7f2fe78bSCy Schubert }, 5582*7f2fe78bSCy Schubert 5583*7f2fe78bSCy Schubert // For cross-browser consistency, suppress native .click() on links 5584*7f2fe78bSCy Schubert // Also prevent it if we're currently inside a leveraged native-event stack 5585*7f2fe78bSCy Schubert _default: function( event ) { 5586*7f2fe78bSCy Schubert var target = event.target; 5587*7f2fe78bSCy Schubert return rcheckableType.test( target.type ) && 5588*7f2fe78bSCy Schubert target.click && nodeName( target, "input" ) && 5589*7f2fe78bSCy Schubert dataPriv.get( target, "click" ) || 5590*7f2fe78bSCy Schubert nodeName( target, "a" ); 5591*7f2fe78bSCy Schubert } 5592*7f2fe78bSCy Schubert }, 5593*7f2fe78bSCy Schubert 5594*7f2fe78bSCy Schubert beforeunload: { 5595*7f2fe78bSCy Schubert postDispatch: function( event ) { 5596*7f2fe78bSCy Schubert 5597*7f2fe78bSCy Schubert // Support: Firefox 20+ 5598*7f2fe78bSCy Schubert // Firefox doesn't alert if the returnValue field is not set. 5599*7f2fe78bSCy Schubert if ( event.result !== undefined && event.originalEvent ) { 5600*7f2fe78bSCy Schubert event.originalEvent.returnValue = event.result; 5601*7f2fe78bSCy Schubert } 5602*7f2fe78bSCy Schubert } 5603*7f2fe78bSCy Schubert } 5604*7f2fe78bSCy Schubert } 5605*7f2fe78bSCy Schubert}; 5606*7f2fe78bSCy Schubert 5607*7f2fe78bSCy Schubert// Ensure the presence of an event listener that handles manually-triggered 5608*7f2fe78bSCy Schubert// synthetic events by interrupting progress until reinvoked in response to 5609*7f2fe78bSCy Schubert// *native* events that it fires directly, ensuring that state changes have 5610*7f2fe78bSCy Schubert// already occurred before other listeners are invoked. 5611*7f2fe78bSCy Schubertfunction leverageNative( el, type, expectSync ) { 5612*7f2fe78bSCy Schubert 5613*7f2fe78bSCy Schubert // Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add 5614*7f2fe78bSCy Schubert if ( !expectSync ) { 5615*7f2fe78bSCy Schubert if ( dataPriv.get( el, type ) === undefined ) { 5616*7f2fe78bSCy Schubert jQuery.event.add( el, type, returnTrue ); 5617*7f2fe78bSCy Schubert } 5618*7f2fe78bSCy Schubert return; 5619*7f2fe78bSCy Schubert } 5620*7f2fe78bSCy Schubert 5621*7f2fe78bSCy Schubert // Register the controller as a special universal handler for all event namespaces 5622*7f2fe78bSCy Schubert dataPriv.set( el, type, false ); 5623*7f2fe78bSCy Schubert jQuery.event.add( el, type, { 5624*7f2fe78bSCy Schubert namespace: false, 5625*7f2fe78bSCy Schubert handler: function( event ) { 5626*7f2fe78bSCy Schubert var notAsync, result, 5627*7f2fe78bSCy Schubert saved = dataPriv.get( this, type ); 5628*7f2fe78bSCy Schubert 5629*7f2fe78bSCy Schubert if ( ( event.isTrigger & 1 ) && this[ type ] ) { 5630*7f2fe78bSCy Schubert 5631*7f2fe78bSCy Schubert // Interrupt processing of the outer synthetic .trigger()ed event 5632*7f2fe78bSCy Schubert // Saved data should be false in such cases, but might be a leftover capture object 5633*7f2fe78bSCy Schubert // from an async native handler (gh-4350) 5634*7f2fe78bSCy Schubert if ( !saved.length ) { 5635*7f2fe78bSCy Schubert 5636*7f2fe78bSCy Schubert // Store arguments for use when handling the inner native event 5637*7f2fe78bSCy Schubert // There will always be at least one argument (an event object), so this array 5638*7f2fe78bSCy Schubert // will not be confused with a leftover capture object. 5639*7f2fe78bSCy Schubert saved = slice.call( arguments ); 5640*7f2fe78bSCy Schubert dataPriv.set( this, type, saved ); 5641*7f2fe78bSCy Schubert 5642*7f2fe78bSCy Schubert // Trigger the native event and capture its result 5643*7f2fe78bSCy Schubert // Support: IE <=9 - 11+ 5644*7f2fe78bSCy Schubert // focus() and blur() are asynchronous 5645*7f2fe78bSCy Schubert notAsync = expectSync( this, type ); 5646*7f2fe78bSCy Schubert this[ type ](); 5647*7f2fe78bSCy Schubert result = dataPriv.get( this, type ); 5648*7f2fe78bSCy Schubert if ( saved !== result || notAsync ) { 5649*7f2fe78bSCy Schubert dataPriv.set( this, type, false ); 5650*7f2fe78bSCy Schubert } else { 5651*7f2fe78bSCy Schubert result = {}; 5652*7f2fe78bSCy Schubert } 5653*7f2fe78bSCy Schubert if ( saved !== result ) { 5654*7f2fe78bSCy Schubert 5655*7f2fe78bSCy Schubert // Cancel the outer synthetic event 5656*7f2fe78bSCy Schubert event.stopImmediatePropagation(); 5657*7f2fe78bSCy Schubert event.preventDefault(); 5658*7f2fe78bSCy Schubert 5659*7f2fe78bSCy Schubert // Support: Chrome 86+ 5660*7f2fe78bSCy Schubert // In Chrome, if an element having a focusout handler is blurred by 5661*7f2fe78bSCy Schubert // clicking outside of it, it invokes the handler synchronously. If 5662*7f2fe78bSCy Schubert // that handler calls `.remove()` on the element, the data is cleared, 5663*7f2fe78bSCy Schubert // leaving `result` undefined. We need to guard against this. 5664*7f2fe78bSCy Schubert return result && result.value; 5665*7f2fe78bSCy Schubert } 5666*7f2fe78bSCy Schubert 5667*7f2fe78bSCy Schubert // If this is an inner synthetic event for an event with a bubbling surrogate 5668*7f2fe78bSCy Schubert // (focus or blur), assume that the surrogate already propagated from triggering the 5669*7f2fe78bSCy Schubert // native event and prevent that from happening again here. 5670*7f2fe78bSCy Schubert // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the 5671*7f2fe78bSCy Schubert // bubbling surrogate propagates *after* the non-bubbling base), but that seems 5672*7f2fe78bSCy Schubert // less bad than duplication. 5673*7f2fe78bSCy Schubert } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) { 5674*7f2fe78bSCy Schubert event.stopPropagation(); 5675*7f2fe78bSCy Schubert } 5676*7f2fe78bSCy Schubert 5677*7f2fe78bSCy Schubert // If this is a native event triggered above, everything is now in order 5678*7f2fe78bSCy Schubert // Fire an inner synthetic event with the original arguments 5679*7f2fe78bSCy Schubert } else if ( saved.length ) { 5680*7f2fe78bSCy Schubert 5681*7f2fe78bSCy Schubert // ...and capture the result 5682*7f2fe78bSCy Schubert dataPriv.set( this, type, { 5683*7f2fe78bSCy Schubert value: jQuery.event.trigger( 5684*7f2fe78bSCy Schubert 5685*7f2fe78bSCy Schubert // Support: IE <=9 - 11+ 5686*7f2fe78bSCy Schubert // Extend with the prototype to reset the above stopImmediatePropagation() 5687*7f2fe78bSCy Schubert jQuery.extend( saved[ 0 ], jQuery.Event.prototype ), 5688*7f2fe78bSCy Schubert saved.slice( 1 ), 5689*7f2fe78bSCy Schubert this 5690*7f2fe78bSCy Schubert ) 5691*7f2fe78bSCy Schubert } ); 5692*7f2fe78bSCy Schubert 5693*7f2fe78bSCy Schubert // Abort handling of the native event 5694*7f2fe78bSCy Schubert event.stopImmediatePropagation(); 5695*7f2fe78bSCy Schubert } 5696*7f2fe78bSCy Schubert } 5697*7f2fe78bSCy Schubert } ); 5698*7f2fe78bSCy Schubert} 5699*7f2fe78bSCy Schubert 5700*7f2fe78bSCy SchubertjQuery.removeEvent = function( elem, type, handle ) { 5701*7f2fe78bSCy Schubert 5702*7f2fe78bSCy Schubert // This "if" is needed for plain objects 5703*7f2fe78bSCy Schubert if ( elem.removeEventListener ) { 5704*7f2fe78bSCy Schubert elem.removeEventListener( type, handle ); 5705*7f2fe78bSCy Schubert } 5706*7f2fe78bSCy Schubert}; 5707*7f2fe78bSCy Schubert 5708*7f2fe78bSCy SchubertjQuery.Event = function( src, props ) { 5709*7f2fe78bSCy Schubert 5710*7f2fe78bSCy Schubert // Allow instantiation without the 'new' keyword 5711*7f2fe78bSCy Schubert if ( !( this instanceof jQuery.Event ) ) { 5712*7f2fe78bSCy Schubert return new jQuery.Event( src, props ); 5713*7f2fe78bSCy Schubert } 5714*7f2fe78bSCy Schubert 5715*7f2fe78bSCy Schubert // Event object 5716*7f2fe78bSCy Schubert if ( src && src.type ) { 5717*7f2fe78bSCy Schubert this.originalEvent = src; 5718*7f2fe78bSCy Schubert this.type = src.type; 5719*7f2fe78bSCy Schubert 5720*7f2fe78bSCy Schubert // Events bubbling up the document may have been marked as prevented 5721*7f2fe78bSCy Schubert // by a handler lower down the tree; reflect the correct value. 5722*7f2fe78bSCy Schubert this.isDefaultPrevented = src.defaultPrevented || 5723*7f2fe78bSCy Schubert src.defaultPrevented === undefined && 5724*7f2fe78bSCy Schubert 5725*7f2fe78bSCy Schubert // Support: Android <=2.3 only 5726*7f2fe78bSCy Schubert src.returnValue === false ? 5727*7f2fe78bSCy Schubert returnTrue : 5728*7f2fe78bSCy Schubert returnFalse; 5729*7f2fe78bSCy Schubert 5730*7f2fe78bSCy Schubert // Create target properties 5731*7f2fe78bSCy Schubert // Support: Safari <=6 - 7 only 5732*7f2fe78bSCy Schubert // Target should not be a text node (#504, #13143) 5733*7f2fe78bSCy Schubert this.target = ( src.target && src.target.nodeType === 3 ) ? 5734*7f2fe78bSCy Schubert src.target.parentNode : 5735*7f2fe78bSCy Schubert src.target; 5736*7f2fe78bSCy Schubert 5737*7f2fe78bSCy Schubert this.currentTarget = src.currentTarget; 5738*7f2fe78bSCy Schubert this.relatedTarget = src.relatedTarget; 5739*7f2fe78bSCy Schubert 5740*7f2fe78bSCy Schubert // Event type 5741*7f2fe78bSCy Schubert } else { 5742*7f2fe78bSCy Schubert this.type = src; 5743*7f2fe78bSCy Schubert } 5744*7f2fe78bSCy Schubert 5745*7f2fe78bSCy Schubert // Put explicitly provided properties onto the event object 5746*7f2fe78bSCy Schubert if ( props ) { 5747*7f2fe78bSCy Schubert jQuery.extend( this, props ); 5748*7f2fe78bSCy Schubert } 5749*7f2fe78bSCy Schubert 5750*7f2fe78bSCy Schubert // Create a timestamp if incoming event doesn't have one 5751*7f2fe78bSCy Schubert this.timeStamp = src && src.timeStamp || Date.now(); 5752*7f2fe78bSCy Schubert 5753*7f2fe78bSCy Schubert // Mark it as fixed 5754*7f2fe78bSCy Schubert this[ jQuery.expando ] = true; 5755*7f2fe78bSCy Schubert}; 5756*7f2fe78bSCy Schubert 5757*7f2fe78bSCy Schubert// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding 5758*7f2fe78bSCy Schubert// https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html 5759*7f2fe78bSCy SchubertjQuery.Event.prototype = { 5760*7f2fe78bSCy Schubert constructor: jQuery.Event, 5761*7f2fe78bSCy Schubert isDefaultPrevented: returnFalse, 5762*7f2fe78bSCy Schubert isPropagationStopped: returnFalse, 5763*7f2fe78bSCy Schubert isImmediatePropagationStopped: returnFalse, 5764*7f2fe78bSCy Schubert isSimulated: false, 5765*7f2fe78bSCy Schubert 5766*7f2fe78bSCy Schubert preventDefault: function() { 5767*7f2fe78bSCy Schubert var e = this.originalEvent; 5768*7f2fe78bSCy Schubert 5769*7f2fe78bSCy Schubert this.isDefaultPrevented = returnTrue; 5770*7f2fe78bSCy Schubert 5771*7f2fe78bSCy Schubert if ( e && !this.isSimulated ) { 5772*7f2fe78bSCy Schubert e.preventDefault(); 5773*7f2fe78bSCy Schubert } 5774*7f2fe78bSCy Schubert }, 5775*7f2fe78bSCy Schubert stopPropagation: function() { 5776*7f2fe78bSCy Schubert var e = this.originalEvent; 5777*7f2fe78bSCy Schubert 5778*7f2fe78bSCy Schubert this.isPropagationStopped = returnTrue; 5779*7f2fe78bSCy Schubert 5780*7f2fe78bSCy Schubert if ( e && !this.isSimulated ) { 5781*7f2fe78bSCy Schubert e.stopPropagation(); 5782*7f2fe78bSCy Schubert } 5783*7f2fe78bSCy Schubert }, 5784*7f2fe78bSCy Schubert stopImmediatePropagation: function() { 5785*7f2fe78bSCy Schubert var e = this.originalEvent; 5786*7f2fe78bSCy Schubert 5787*7f2fe78bSCy Schubert this.isImmediatePropagationStopped = returnTrue; 5788*7f2fe78bSCy Schubert 5789*7f2fe78bSCy Schubert if ( e && !this.isSimulated ) { 5790*7f2fe78bSCy Schubert e.stopImmediatePropagation(); 5791*7f2fe78bSCy Schubert } 5792*7f2fe78bSCy Schubert 5793*7f2fe78bSCy Schubert this.stopPropagation(); 5794*7f2fe78bSCy Schubert } 5795*7f2fe78bSCy Schubert}; 5796*7f2fe78bSCy Schubert 5797*7f2fe78bSCy Schubert// Includes all common event props including KeyEvent and MouseEvent specific props 5798*7f2fe78bSCy SchubertjQuery.each( { 5799*7f2fe78bSCy Schubert altKey: true, 5800*7f2fe78bSCy Schubert bubbles: true, 5801*7f2fe78bSCy Schubert cancelable: true, 5802*7f2fe78bSCy Schubert changedTouches: true, 5803*7f2fe78bSCy Schubert ctrlKey: true, 5804*7f2fe78bSCy Schubert detail: true, 5805*7f2fe78bSCy Schubert eventPhase: true, 5806*7f2fe78bSCy Schubert metaKey: true, 5807*7f2fe78bSCy Schubert pageX: true, 5808*7f2fe78bSCy Schubert pageY: true, 5809*7f2fe78bSCy Schubert shiftKey: true, 5810*7f2fe78bSCy Schubert view: true, 5811*7f2fe78bSCy Schubert "char": true, 5812*7f2fe78bSCy Schubert code: true, 5813*7f2fe78bSCy Schubert charCode: true, 5814*7f2fe78bSCy Schubert key: true, 5815*7f2fe78bSCy Schubert keyCode: true, 5816*7f2fe78bSCy Schubert button: true, 5817*7f2fe78bSCy Schubert buttons: true, 5818*7f2fe78bSCy Schubert clientX: true, 5819*7f2fe78bSCy Schubert clientY: true, 5820*7f2fe78bSCy Schubert offsetX: true, 5821*7f2fe78bSCy Schubert offsetY: true, 5822*7f2fe78bSCy Schubert pointerId: true, 5823*7f2fe78bSCy Schubert pointerType: true, 5824*7f2fe78bSCy Schubert screenX: true, 5825*7f2fe78bSCy Schubert screenY: true, 5826*7f2fe78bSCy Schubert targetTouches: true, 5827*7f2fe78bSCy Schubert toElement: true, 5828*7f2fe78bSCy Schubert touches: true, 5829*7f2fe78bSCy Schubert which: true 5830*7f2fe78bSCy Schubert}, jQuery.event.addProp ); 5831*7f2fe78bSCy Schubert 5832*7f2fe78bSCy SchubertjQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) { 5833*7f2fe78bSCy Schubert jQuery.event.special[ type ] = { 5834*7f2fe78bSCy Schubert 5835*7f2fe78bSCy Schubert // Utilize native event if possible so blur/focus sequence is correct 5836*7f2fe78bSCy Schubert setup: function() { 5837*7f2fe78bSCy Schubert 5838*7f2fe78bSCy Schubert // Claim the first handler 5839*7f2fe78bSCy Schubert // dataPriv.set( this, "focus", ... ) 5840*7f2fe78bSCy Schubert // dataPriv.set( this, "blur", ... ) 5841*7f2fe78bSCy Schubert leverageNative( this, type, expectSync ); 5842*7f2fe78bSCy Schubert 5843*7f2fe78bSCy Schubert // Return false to allow normal processing in the caller 5844*7f2fe78bSCy Schubert return false; 5845*7f2fe78bSCy Schubert }, 5846*7f2fe78bSCy Schubert trigger: function() { 5847*7f2fe78bSCy Schubert 5848*7f2fe78bSCy Schubert // Force setup before trigger 5849*7f2fe78bSCy Schubert leverageNative( this, type ); 5850*7f2fe78bSCy Schubert 5851*7f2fe78bSCy Schubert // Return non-false to allow normal event-path propagation 5852*7f2fe78bSCy Schubert return true; 5853*7f2fe78bSCy Schubert }, 5854*7f2fe78bSCy Schubert 5855*7f2fe78bSCy Schubert // Suppress native focus or blur as it's already being fired 5856*7f2fe78bSCy Schubert // in leverageNative. 5857*7f2fe78bSCy Schubert _default: function() { 5858*7f2fe78bSCy Schubert return true; 5859*7f2fe78bSCy Schubert }, 5860*7f2fe78bSCy Schubert 5861*7f2fe78bSCy Schubert delegateType: delegateType 5862*7f2fe78bSCy Schubert }; 5863*7f2fe78bSCy Schubert} ); 5864*7f2fe78bSCy Schubert 5865*7f2fe78bSCy Schubert// Create mouseenter/leave events using mouseover/out and event-time checks 5866*7f2fe78bSCy Schubert// so that event delegation works in jQuery. 5867*7f2fe78bSCy Schubert// Do the same for pointerenter/pointerleave and pointerover/pointerout 5868*7f2fe78bSCy Schubert// 5869*7f2fe78bSCy Schubert// Support: Safari 7 only 5870*7f2fe78bSCy Schubert// Safari sends mouseenter too often; see: 5871*7f2fe78bSCy Schubert// https://bugs.chromium.org/p/chromium/issues/detail?id=470258 5872*7f2fe78bSCy Schubert// for the description of the bug (it existed in older Chrome versions as well). 5873*7f2fe78bSCy SchubertjQuery.each( { 5874*7f2fe78bSCy Schubert mouseenter: "mouseover", 5875*7f2fe78bSCy Schubert mouseleave: "mouseout", 5876*7f2fe78bSCy Schubert pointerenter: "pointerover", 5877*7f2fe78bSCy Schubert pointerleave: "pointerout" 5878*7f2fe78bSCy Schubert}, function( orig, fix ) { 5879*7f2fe78bSCy Schubert jQuery.event.special[ orig ] = { 5880*7f2fe78bSCy Schubert delegateType: fix, 5881*7f2fe78bSCy Schubert bindType: fix, 5882*7f2fe78bSCy Schubert 5883*7f2fe78bSCy Schubert handle: function( event ) { 5884*7f2fe78bSCy Schubert var ret, 5885*7f2fe78bSCy Schubert target = this, 5886*7f2fe78bSCy Schubert related = event.relatedTarget, 5887*7f2fe78bSCy Schubert handleObj = event.handleObj; 5888*7f2fe78bSCy Schubert 5889*7f2fe78bSCy Schubert // For mouseenter/leave call the handler if related is outside the target. 5890*7f2fe78bSCy Schubert // NB: No relatedTarget if the mouse left/entered the browser window 5891*7f2fe78bSCy Schubert if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) { 5892*7f2fe78bSCy Schubert event.type = handleObj.origType; 5893*7f2fe78bSCy Schubert ret = handleObj.handler.apply( this, arguments ); 5894*7f2fe78bSCy Schubert event.type = fix; 5895*7f2fe78bSCy Schubert } 5896*7f2fe78bSCy Schubert return ret; 5897*7f2fe78bSCy Schubert } 5898*7f2fe78bSCy Schubert }; 5899*7f2fe78bSCy Schubert} ); 5900*7f2fe78bSCy Schubert 5901*7f2fe78bSCy SchubertjQuery.fn.extend( { 5902*7f2fe78bSCy Schubert 5903*7f2fe78bSCy Schubert on: function( types, selector, data, fn ) { 5904*7f2fe78bSCy Schubert return on( this, types, selector, data, fn ); 5905*7f2fe78bSCy Schubert }, 5906*7f2fe78bSCy Schubert one: function( types, selector, data, fn ) { 5907*7f2fe78bSCy Schubert return on( this, types, selector, data, fn, 1 ); 5908*7f2fe78bSCy Schubert }, 5909*7f2fe78bSCy Schubert off: function( types, selector, fn ) { 5910*7f2fe78bSCy Schubert var handleObj, type; 5911*7f2fe78bSCy Schubert if ( types && types.preventDefault && types.handleObj ) { 5912*7f2fe78bSCy Schubert 5913*7f2fe78bSCy Schubert // ( event ) dispatched jQuery.Event 5914*7f2fe78bSCy Schubert handleObj = types.handleObj; 5915*7f2fe78bSCy Schubert jQuery( types.delegateTarget ).off( 5916*7f2fe78bSCy Schubert handleObj.namespace ? 5917*7f2fe78bSCy Schubert handleObj.origType + "." + handleObj.namespace : 5918*7f2fe78bSCy Schubert handleObj.origType, 5919*7f2fe78bSCy Schubert handleObj.selector, 5920*7f2fe78bSCy Schubert handleObj.handler 5921*7f2fe78bSCy Schubert ); 5922*7f2fe78bSCy Schubert return this; 5923*7f2fe78bSCy Schubert } 5924*7f2fe78bSCy Schubert if ( typeof types === "object" ) { 5925*7f2fe78bSCy Schubert 5926*7f2fe78bSCy Schubert // ( types-object [, selector] ) 5927*7f2fe78bSCy Schubert for ( type in types ) { 5928*7f2fe78bSCy Schubert this.off( type, selector, types[ type ] ); 5929*7f2fe78bSCy Schubert } 5930*7f2fe78bSCy Schubert return this; 5931*7f2fe78bSCy Schubert } 5932*7f2fe78bSCy Schubert if ( selector === false || typeof selector === "function" ) { 5933*7f2fe78bSCy Schubert 5934*7f2fe78bSCy Schubert // ( types [, fn] ) 5935*7f2fe78bSCy Schubert fn = selector; 5936*7f2fe78bSCy Schubert selector = undefined; 5937*7f2fe78bSCy Schubert } 5938*7f2fe78bSCy Schubert if ( fn === false ) { 5939*7f2fe78bSCy Schubert fn = returnFalse; 5940*7f2fe78bSCy Schubert } 5941*7f2fe78bSCy Schubert return this.each( function() { 5942*7f2fe78bSCy Schubert jQuery.event.remove( this, types, fn, selector ); 5943*7f2fe78bSCy Schubert } ); 5944*7f2fe78bSCy Schubert } 5945*7f2fe78bSCy Schubert} ); 5946*7f2fe78bSCy Schubert 5947*7f2fe78bSCy Schubert 5948*7f2fe78bSCy Schubertvar 5949*7f2fe78bSCy Schubert 5950*7f2fe78bSCy Schubert // Support: IE <=10 - 11, Edge 12 - 13 only 5951*7f2fe78bSCy Schubert // In IE/Edge using regex groups here causes severe slowdowns. 5952*7f2fe78bSCy Schubert // See https://connect.microsoft.com/IE/feedback/details/1736512/ 5953*7f2fe78bSCy Schubert rnoInnerhtml = /<script|<style|<link/i, 5954*7f2fe78bSCy Schubert 5955*7f2fe78bSCy Schubert // checked="checked" or checked 5956*7f2fe78bSCy Schubert rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, 5957*7f2fe78bSCy Schubert rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g; 5958*7f2fe78bSCy Schubert 5959*7f2fe78bSCy Schubert// Prefer a tbody over its parent table for containing new rows 5960*7f2fe78bSCy Schubertfunction manipulationTarget( elem, content ) { 5961*7f2fe78bSCy Schubert if ( nodeName( elem, "table" ) && 5962*7f2fe78bSCy Schubert nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) { 5963*7f2fe78bSCy Schubert 5964*7f2fe78bSCy Schubert return jQuery( elem ).children( "tbody" )[ 0 ] || elem; 5965*7f2fe78bSCy Schubert } 5966*7f2fe78bSCy Schubert 5967*7f2fe78bSCy Schubert return elem; 5968*7f2fe78bSCy Schubert} 5969*7f2fe78bSCy Schubert 5970*7f2fe78bSCy Schubert// Replace/restore the type attribute of script elements for safe DOM manipulation 5971*7f2fe78bSCy Schubertfunction disableScript( elem ) { 5972*7f2fe78bSCy Schubert elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type; 5973*7f2fe78bSCy Schubert return elem; 5974*7f2fe78bSCy Schubert} 5975*7f2fe78bSCy Schubertfunction restoreScript( elem ) { 5976*7f2fe78bSCy Schubert if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) { 5977*7f2fe78bSCy Schubert elem.type = elem.type.slice( 5 ); 5978*7f2fe78bSCy Schubert } else { 5979*7f2fe78bSCy Schubert elem.removeAttribute( "type" ); 5980*7f2fe78bSCy Schubert } 5981*7f2fe78bSCy Schubert 5982*7f2fe78bSCy Schubert return elem; 5983*7f2fe78bSCy Schubert} 5984*7f2fe78bSCy Schubert 5985*7f2fe78bSCy Schubertfunction cloneCopyEvent( src, dest ) { 5986*7f2fe78bSCy Schubert var i, l, type, pdataOld, udataOld, udataCur, events; 5987*7f2fe78bSCy Schubert 5988*7f2fe78bSCy Schubert if ( dest.nodeType !== 1 ) { 5989*7f2fe78bSCy Schubert return; 5990*7f2fe78bSCy Schubert } 5991*7f2fe78bSCy Schubert 5992*7f2fe78bSCy Schubert // 1. Copy private data: events, handlers, etc. 5993*7f2fe78bSCy Schubert if ( dataPriv.hasData( src ) ) { 5994*7f2fe78bSCy Schubert pdataOld = dataPriv.get( src ); 5995*7f2fe78bSCy Schubert events = pdataOld.events; 5996*7f2fe78bSCy Schubert 5997*7f2fe78bSCy Schubert if ( events ) { 5998*7f2fe78bSCy Schubert dataPriv.remove( dest, "handle events" ); 5999*7f2fe78bSCy Schubert 6000*7f2fe78bSCy Schubert for ( type in events ) { 6001*7f2fe78bSCy Schubert for ( i = 0, l = events[ type ].length; i < l; i++ ) { 6002*7f2fe78bSCy Schubert jQuery.event.add( dest, type, events[ type ][ i ] ); 6003*7f2fe78bSCy Schubert } 6004*7f2fe78bSCy Schubert } 6005*7f2fe78bSCy Schubert } 6006*7f2fe78bSCy Schubert } 6007*7f2fe78bSCy Schubert 6008*7f2fe78bSCy Schubert // 2. Copy user data 6009*7f2fe78bSCy Schubert if ( dataUser.hasData( src ) ) { 6010*7f2fe78bSCy Schubert udataOld = dataUser.access( src ); 6011*7f2fe78bSCy Schubert udataCur = jQuery.extend( {}, udataOld ); 6012*7f2fe78bSCy Schubert 6013*7f2fe78bSCy Schubert dataUser.set( dest, udataCur ); 6014*7f2fe78bSCy Schubert } 6015*7f2fe78bSCy Schubert} 6016*7f2fe78bSCy Schubert 6017*7f2fe78bSCy Schubert// Fix IE bugs, see support tests 6018*7f2fe78bSCy Schubertfunction fixInput( src, dest ) { 6019*7f2fe78bSCy Schubert var nodeName = dest.nodeName.toLowerCase(); 6020*7f2fe78bSCy Schubert 6021*7f2fe78bSCy Schubert // Fails to persist the checked state of a cloned checkbox or radio button. 6022*7f2fe78bSCy Schubert if ( nodeName === "input" && rcheckableType.test( src.type ) ) { 6023*7f2fe78bSCy Schubert dest.checked = src.checked; 6024*7f2fe78bSCy Schubert 6025*7f2fe78bSCy Schubert // Fails to return the selected option to the default selected state when cloning options 6026*7f2fe78bSCy Schubert } else if ( nodeName === "input" || nodeName === "textarea" ) { 6027*7f2fe78bSCy Schubert dest.defaultValue = src.defaultValue; 6028*7f2fe78bSCy Schubert } 6029*7f2fe78bSCy Schubert} 6030*7f2fe78bSCy Schubert 6031*7f2fe78bSCy Schubertfunction domManip( collection, args, callback, ignored ) { 6032*7f2fe78bSCy Schubert 6033*7f2fe78bSCy Schubert // Flatten any nested arrays 6034*7f2fe78bSCy Schubert args = flat( args ); 6035*7f2fe78bSCy Schubert 6036*7f2fe78bSCy Schubert var fragment, first, scripts, hasScripts, node, doc, 6037*7f2fe78bSCy Schubert i = 0, 6038*7f2fe78bSCy Schubert l = collection.length, 6039*7f2fe78bSCy Schubert iNoClone = l - 1, 6040*7f2fe78bSCy Schubert value = args[ 0 ], 6041*7f2fe78bSCy Schubert valueIsFunction = isFunction( value ); 6042*7f2fe78bSCy Schubert 6043*7f2fe78bSCy Schubert // We can't cloneNode fragments that contain checked, in WebKit 6044*7f2fe78bSCy Schubert if ( valueIsFunction || 6045*7f2fe78bSCy Schubert ( l > 1 && typeof value === "string" && 6046*7f2fe78bSCy Schubert !support.checkClone && rchecked.test( value ) ) ) { 6047*7f2fe78bSCy Schubert return collection.each( function( index ) { 6048*7f2fe78bSCy Schubert var self = collection.eq( index ); 6049*7f2fe78bSCy Schubert if ( valueIsFunction ) { 6050*7f2fe78bSCy Schubert args[ 0 ] = value.call( this, index, self.html() ); 6051*7f2fe78bSCy Schubert } 6052*7f2fe78bSCy Schubert domManip( self, args, callback, ignored ); 6053*7f2fe78bSCy Schubert } ); 6054*7f2fe78bSCy Schubert } 6055*7f2fe78bSCy Schubert 6056*7f2fe78bSCy Schubert if ( l ) { 6057*7f2fe78bSCy Schubert fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored ); 6058*7f2fe78bSCy Schubert first = fragment.firstChild; 6059*7f2fe78bSCy Schubert 6060*7f2fe78bSCy Schubert if ( fragment.childNodes.length === 1 ) { 6061*7f2fe78bSCy Schubert fragment = first; 6062*7f2fe78bSCy Schubert } 6063*7f2fe78bSCy Schubert 6064*7f2fe78bSCy Schubert // Require either new content or an interest in ignored elements to invoke the callback 6065*7f2fe78bSCy Schubert if ( first || ignored ) { 6066*7f2fe78bSCy Schubert scripts = jQuery.map( getAll( fragment, "script" ), disableScript ); 6067*7f2fe78bSCy Schubert hasScripts = scripts.length; 6068*7f2fe78bSCy Schubert 6069*7f2fe78bSCy Schubert // Use the original fragment for the last item 6070*7f2fe78bSCy Schubert // instead of the first because it can end up 6071*7f2fe78bSCy Schubert // being emptied incorrectly in certain situations (#8070). 6072*7f2fe78bSCy Schubert for ( ; i < l; i++ ) { 6073*7f2fe78bSCy Schubert node = fragment; 6074*7f2fe78bSCy Schubert 6075*7f2fe78bSCy Schubert if ( i !== iNoClone ) { 6076*7f2fe78bSCy Schubert node = jQuery.clone( node, true, true ); 6077*7f2fe78bSCy Schubert 6078*7f2fe78bSCy Schubert // Keep references to cloned scripts for later restoration 6079*7f2fe78bSCy Schubert if ( hasScripts ) { 6080*7f2fe78bSCy Schubert 6081*7f2fe78bSCy Schubert // Support: Android <=4.0 only, PhantomJS 1 only 6082*7f2fe78bSCy Schubert // push.apply(_, arraylike) throws on ancient WebKit 6083*7f2fe78bSCy Schubert jQuery.merge( scripts, getAll( node, "script" ) ); 6084*7f2fe78bSCy Schubert } 6085*7f2fe78bSCy Schubert } 6086*7f2fe78bSCy Schubert 6087*7f2fe78bSCy Schubert callback.call( collection[ i ], node, i ); 6088*7f2fe78bSCy Schubert } 6089*7f2fe78bSCy Schubert 6090*7f2fe78bSCy Schubert if ( hasScripts ) { 6091*7f2fe78bSCy Schubert doc = scripts[ scripts.length - 1 ].ownerDocument; 6092*7f2fe78bSCy Schubert 6093*7f2fe78bSCy Schubert // Reenable scripts 6094*7f2fe78bSCy Schubert jQuery.map( scripts, restoreScript ); 6095*7f2fe78bSCy Schubert 6096*7f2fe78bSCy Schubert // Evaluate executable scripts on first document insertion 6097*7f2fe78bSCy Schubert for ( i = 0; i < hasScripts; i++ ) { 6098*7f2fe78bSCy Schubert node = scripts[ i ]; 6099*7f2fe78bSCy Schubert if ( rscriptType.test( node.type || "" ) && 6100*7f2fe78bSCy Schubert !dataPriv.access( node, "globalEval" ) && 6101*7f2fe78bSCy Schubert jQuery.contains( doc, node ) ) { 6102*7f2fe78bSCy Schubert 6103*7f2fe78bSCy Schubert if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) { 6104*7f2fe78bSCy Schubert 6105*7f2fe78bSCy Schubert // Optional AJAX dependency, but won't run scripts if not present 6106*7f2fe78bSCy Schubert if ( jQuery._evalUrl && !node.noModule ) { 6107*7f2fe78bSCy Schubert jQuery._evalUrl( node.src, { 6108*7f2fe78bSCy Schubert nonce: node.nonce || node.getAttribute( "nonce" ) 6109*7f2fe78bSCy Schubert }, doc ); 6110*7f2fe78bSCy Schubert } 6111*7f2fe78bSCy Schubert } else { 6112*7f2fe78bSCy Schubert DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc ); 6113*7f2fe78bSCy Schubert } 6114*7f2fe78bSCy Schubert } 6115*7f2fe78bSCy Schubert } 6116*7f2fe78bSCy Schubert } 6117*7f2fe78bSCy Schubert } 6118*7f2fe78bSCy Schubert } 6119*7f2fe78bSCy Schubert 6120*7f2fe78bSCy Schubert return collection; 6121*7f2fe78bSCy Schubert} 6122*7f2fe78bSCy Schubert 6123*7f2fe78bSCy Schubertfunction remove( elem, selector, keepData ) { 6124*7f2fe78bSCy Schubert var node, 6125*7f2fe78bSCy Schubert nodes = selector ? jQuery.filter( selector, elem ) : elem, 6126*7f2fe78bSCy Schubert i = 0; 6127*7f2fe78bSCy Schubert 6128*7f2fe78bSCy Schubert for ( ; ( node = nodes[ i ] ) != null; i++ ) { 6129*7f2fe78bSCy Schubert if ( !keepData && node.nodeType === 1 ) { 6130*7f2fe78bSCy Schubert jQuery.cleanData( getAll( node ) ); 6131*7f2fe78bSCy Schubert } 6132*7f2fe78bSCy Schubert 6133*7f2fe78bSCy Schubert if ( node.parentNode ) { 6134*7f2fe78bSCy Schubert if ( keepData && isAttached( node ) ) { 6135*7f2fe78bSCy Schubert setGlobalEval( getAll( node, "script" ) ); 6136*7f2fe78bSCy Schubert } 6137*7f2fe78bSCy Schubert node.parentNode.removeChild( node ); 6138*7f2fe78bSCy Schubert } 6139*7f2fe78bSCy Schubert } 6140*7f2fe78bSCy Schubert 6141*7f2fe78bSCy Schubert return elem; 6142*7f2fe78bSCy Schubert} 6143*7f2fe78bSCy Schubert 6144*7f2fe78bSCy SchubertjQuery.extend( { 6145*7f2fe78bSCy Schubert htmlPrefilter: function( html ) { 6146*7f2fe78bSCy Schubert return html; 6147*7f2fe78bSCy Schubert }, 6148*7f2fe78bSCy Schubert 6149*7f2fe78bSCy Schubert clone: function( elem, dataAndEvents, deepDataAndEvents ) { 6150*7f2fe78bSCy Schubert var i, l, srcElements, destElements, 6151*7f2fe78bSCy Schubert clone = elem.cloneNode( true ), 6152*7f2fe78bSCy Schubert inPage = isAttached( elem ); 6153*7f2fe78bSCy Schubert 6154*7f2fe78bSCy Schubert // Fix IE cloning issues 6155*7f2fe78bSCy Schubert if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) && 6156*7f2fe78bSCy Schubert !jQuery.isXMLDoc( elem ) ) { 6157*7f2fe78bSCy Schubert 6158*7f2fe78bSCy Schubert // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2 6159*7f2fe78bSCy Schubert destElements = getAll( clone ); 6160*7f2fe78bSCy Schubert srcElements = getAll( elem ); 6161*7f2fe78bSCy Schubert 6162*7f2fe78bSCy Schubert for ( i = 0, l = srcElements.length; i < l; i++ ) { 6163*7f2fe78bSCy Schubert fixInput( srcElements[ i ], destElements[ i ] ); 6164*7f2fe78bSCy Schubert } 6165*7f2fe78bSCy Schubert } 6166*7f2fe78bSCy Schubert 6167*7f2fe78bSCy Schubert // Copy the events from the original to the clone 6168*7f2fe78bSCy Schubert if ( dataAndEvents ) { 6169*7f2fe78bSCy Schubert if ( deepDataAndEvents ) { 6170*7f2fe78bSCy Schubert srcElements = srcElements || getAll( elem ); 6171*7f2fe78bSCy Schubert destElements = destElements || getAll( clone ); 6172*7f2fe78bSCy Schubert 6173*7f2fe78bSCy Schubert for ( i = 0, l = srcElements.length; i < l; i++ ) { 6174*7f2fe78bSCy Schubert cloneCopyEvent( srcElements[ i ], destElements[ i ] ); 6175*7f2fe78bSCy Schubert } 6176*7f2fe78bSCy Schubert } else { 6177*7f2fe78bSCy Schubert cloneCopyEvent( elem, clone ); 6178*7f2fe78bSCy Schubert } 6179*7f2fe78bSCy Schubert } 6180*7f2fe78bSCy Schubert 6181*7f2fe78bSCy Schubert // Preserve script evaluation history 6182*7f2fe78bSCy Schubert destElements = getAll( clone, "script" ); 6183*7f2fe78bSCy Schubert if ( destElements.length > 0 ) { 6184*7f2fe78bSCy Schubert setGlobalEval( destElements, !inPage && getAll( elem, "script" ) ); 6185*7f2fe78bSCy Schubert } 6186*7f2fe78bSCy Schubert 6187*7f2fe78bSCy Schubert // Return the cloned set 6188*7f2fe78bSCy Schubert return clone; 6189*7f2fe78bSCy Schubert }, 6190*7f2fe78bSCy Schubert 6191*7f2fe78bSCy Schubert cleanData: function( elems ) { 6192*7f2fe78bSCy Schubert var data, elem, type, 6193*7f2fe78bSCy Schubert special = jQuery.event.special, 6194*7f2fe78bSCy Schubert i = 0; 6195*7f2fe78bSCy Schubert 6196*7f2fe78bSCy Schubert for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) { 6197*7f2fe78bSCy Schubert if ( acceptData( elem ) ) { 6198*7f2fe78bSCy Schubert if ( ( data = elem[ dataPriv.expando ] ) ) { 6199*7f2fe78bSCy Schubert if ( data.events ) { 6200*7f2fe78bSCy Schubert for ( type in data.events ) { 6201*7f2fe78bSCy Schubert if ( special[ type ] ) { 6202*7f2fe78bSCy Schubert jQuery.event.remove( elem, type ); 6203*7f2fe78bSCy Schubert 6204*7f2fe78bSCy Schubert // This is a shortcut to avoid jQuery.event.remove's overhead 6205*7f2fe78bSCy Schubert } else { 6206*7f2fe78bSCy Schubert jQuery.removeEvent( elem, type, data.handle ); 6207*7f2fe78bSCy Schubert } 6208*7f2fe78bSCy Schubert } 6209*7f2fe78bSCy Schubert } 6210*7f2fe78bSCy Schubert 6211*7f2fe78bSCy Schubert // Support: Chrome <=35 - 45+ 6212*7f2fe78bSCy Schubert // Assign undefined instead of using delete, see Data#remove 6213*7f2fe78bSCy Schubert elem[ dataPriv.expando ] = undefined; 6214*7f2fe78bSCy Schubert } 6215*7f2fe78bSCy Schubert if ( elem[ dataUser.expando ] ) { 6216*7f2fe78bSCy Schubert 6217*7f2fe78bSCy Schubert // Support: Chrome <=35 - 45+ 6218*7f2fe78bSCy Schubert // Assign undefined instead of using delete, see Data#remove 6219*7f2fe78bSCy Schubert elem[ dataUser.expando ] = undefined; 6220*7f2fe78bSCy Schubert } 6221*7f2fe78bSCy Schubert } 6222*7f2fe78bSCy Schubert } 6223*7f2fe78bSCy Schubert } 6224*7f2fe78bSCy Schubert} ); 6225*7f2fe78bSCy Schubert 6226*7f2fe78bSCy SchubertjQuery.fn.extend( { 6227*7f2fe78bSCy Schubert detach: function( selector ) { 6228*7f2fe78bSCy Schubert return remove( this, selector, true ); 6229*7f2fe78bSCy Schubert }, 6230*7f2fe78bSCy Schubert 6231*7f2fe78bSCy Schubert remove: function( selector ) { 6232*7f2fe78bSCy Schubert return remove( this, selector ); 6233*7f2fe78bSCy Schubert }, 6234*7f2fe78bSCy Schubert 6235*7f2fe78bSCy Schubert text: function( value ) { 6236*7f2fe78bSCy Schubert return access( this, function( value ) { 6237*7f2fe78bSCy Schubert return value === undefined ? 6238*7f2fe78bSCy Schubert jQuery.text( this ) : 6239*7f2fe78bSCy Schubert this.empty().each( function() { 6240*7f2fe78bSCy Schubert if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { 6241*7f2fe78bSCy Schubert this.textContent = value; 6242*7f2fe78bSCy Schubert } 6243*7f2fe78bSCy Schubert } ); 6244*7f2fe78bSCy Schubert }, null, value, arguments.length ); 6245*7f2fe78bSCy Schubert }, 6246*7f2fe78bSCy Schubert 6247*7f2fe78bSCy Schubert append: function() { 6248*7f2fe78bSCy Schubert return domManip( this, arguments, function( elem ) { 6249*7f2fe78bSCy Schubert if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { 6250*7f2fe78bSCy Schubert var target = manipulationTarget( this, elem ); 6251*7f2fe78bSCy Schubert target.appendChild( elem ); 6252*7f2fe78bSCy Schubert } 6253*7f2fe78bSCy Schubert } ); 6254*7f2fe78bSCy Schubert }, 6255*7f2fe78bSCy Schubert 6256*7f2fe78bSCy Schubert prepend: function() { 6257*7f2fe78bSCy Schubert return domManip( this, arguments, function( elem ) { 6258*7f2fe78bSCy Schubert if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { 6259*7f2fe78bSCy Schubert var target = manipulationTarget( this, elem ); 6260*7f2fe78bSCy Schubert target.insertBefore( elem, target.firstChild ); 6261*7f2fe78bSCy Schubert } 6262*7f2fe78bSCy Schubert } ); 6263*7f2fe78bSCy Schubert }, 6264*7f2fe78bSCy Schubert 6265*7f2fe78bSCy Schubert before: function() { 6266*7f2fe78bSCy Schubert return domManip( this, arguments, function( elem ) { 6267*7f2fe78bSCy Schubert if ( this.parentNode ) { 6268*7f2fe78bSCy Schubert this.parentNode.insertBefore( elem, this ); 6269*7f2fe78bSCy Schubert } 6270*7f2fe78bSCy Schubert } ); 6271*7f2fe78bSCy Schubert }, 6272*7f2fe78bSCy Schubert 6273*7f2fe78bSCy Schubert after: function() { 6274*7f2fe78bSCy Schubert return domManip( this, arguments, function( elem ) { 6275*7f2fe78bSCy Schubert if ( this.parentNode ) { 6276*7f2fe78bSCy Schubert this.parentNode.insertBefore( elem, this.nextSibling ); 6277*7f2fe78bSCy Schubert } 6278*7f2fe78bSCy Schubert } ); 6279*7f2fe78bSCy Schubert }, 6280*7f2fe78bSCy Schubert 6281*7f2fe78bSCy Schubert empty: function() { 6282*7f2fe78bSCy Schubert var elem, 6283*7f2fe78bSCy Schubert i = 0; 6284*7f2fe78bSCy Schubert 6285*7f2fe78bSCy Schubert for ( ; ( elem = this[ i ] ) != null; i++ ) { 6286*7f2fe78bSCy Schubert if ( elem.nodeType === 1 ) { 6287*7f2fe78bSCy Schubert 6288*7f2fe78bSCy Schubert // Prevent memory leaks 6289*7f2fe78bSCy Schubert jQuery.cleanData( getAll( elem, false ) ); 6290*7f2fe78bSCy Schubert 6291*7f2fe78bSCy Schubert // Remove any remaining nodes 6292*7f2fe78bSCy Schubert elem.textContent = ""; 6293*7f2fe78bSCy Schubert } 6294*7f2fe78bSCy Schubert } 6295*7f2fe78bSCy Schubert 6296*7f2fe78bSCy Schubert return this; 6297*7f2fe78bSCy Schubert }, 6298*7f2fe78bSCy Schubert 6299*7f2fe78bSCy Schubert clone: function( dataAndEvents, deepDataAndEvents ) { 6300*7f2fe78bSCy Schubert dataAndEvents = dataAndEvents == null ? false : dataAndEvents; 6301*7f2fe78bSCy Schubert deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; 6302*7f2fe78bSCy Schubert 6303*7f2fe78bSCy Schubert return this.map( function() { 6304*7f2fe78bSCy Schubert return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); 6305*7f2fe78bSCy Schubert } ); 6306*7f2fe78bSCy Schubert }, 6307*7f2fe78bSCy Schubert 6308*7f2fe78bSCy Schubert html: function( value ) { 6309*7f2fe78bSCy Schubert return access( this, function( value ) { 6310*7f2fe78bSCy Schubert var elem = this[ 0 ] || {}, 6311*7f2fe78bSCy Schubert i = 0, 6312*7f2fe78bSCy Schubert l = this.length; 6313*7f2fe78bSCy Schubert 6314*7f2fe78bSCy Schubert if ( value === undefined && elem.nodeType === 1 ) { 6315*7f2fe78bSCy Schubert return elem.innerHTML; 6316*7f2fe78bSCy Schubert } 6317*7f2fe78bSCy Schubert 6318*7f2fe78bSCy Schubert // See if we can take a shortcut and just use innerHTML 6319*7f2fe78bSCy Schubert if ( typeof value === "string" && !rnoInnerhtml.test( value ) && 6320*7f2fe78bSCy Schubert !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) { 6321*7f2fe78bSCy Schubert 6322*7f2fe78bSCy Schubert value = jQuery.htmlPrefilter( value ); 6323*7f2fe78bSCy Schubert 6324*7f2fe78bSCy Schubert try { 6325*7f2fe78bSCy Schubert for ( ; i < l; i++ ) { 6326*7f2fe78bSCy Schubert elem = this[ i ] || {}; 6327*7f2fe78bSCy Schubert 6328*7f2fe78bSCy Schubert // Remove element nodes and prevent memory leaks 6329*7f2fe78bSCy Schubert if ( elem.nodeType === 1 ) { 6330*7f2fe78bSCy Schubert jQuery.cleanData( getAll( elem, false ) ); 6331*7f2fe78bSCy Schubert elem.innerHTML = value; 6332*7f2fe78bSCy Schubert } 6333*7f2fe78bSCy Schubert } 6334*7f2fe78bSCy Schubert 6335*7f2fe78bSCy Schubert elem = 0; 6336*7f2fe78bSCy Schubert 6337*7f2fe78bSCy Schubert // If using innerHTML throws an exception, use the fallback method 6338*7f2fe78bSCy Schubert } catch ( e ) {} 6339*7f2fe78bSCy Schubert } 6340*7f2fe78bSCy Schubert 6341*7f2fe78bSCy Schubert if ( elem ) { 6342*7f2fe78bSCy Schubert this.empty().append( value ); 6343*7f2fe78bSCy Schubert } 6344*7f2fe78bSCy Schubert }, null, value, arguments.length ); 6345*7f2fe78bSCy Schubert }, 6346*7f2fe78bSCy Schubert 6347*7f2fe78bSCy Schubert replaceWith: function() { 6348*7f2fe78bSCy Schubert var ignored = []; 6349*7f2fe78bSCy Schubert 6350*7f2fe78bSCy Schubert // Make the changes, replacing each non-ignored context element with the new content 6351*7f2fe78bSCy Schubert return domManip( this, arguments, function( elem ) { 6352*7f2fe78bSCy Schubert var parent = this.parentNode; 6353*7f2fe78bSCy Schubert 6354*7f2fe78bSCy Schubert if ( jQuery.inArray( this, ignored ) < 0 ) { 6355*7f2fe78bSCy Schubert jQuery.cleanData( getAll( this ) ); 6356*7f2fe78bSCy Schubert if ( parent ) { 6357*7f2fe78bSCy Schubert parent.replaceChild( elem, this ); 6358*7f2fe78bSCy Schubert } 6359*7f2fe78bSCy Schubert } 6360*7f2fe78bSCy Schubert 6361*7f2fe78bSCy Schubert // Force callback invocation 6362*7f2fe78bSCy Schubert }, ignored ); 6363*7f2fe78bSCy Schubert } 6364*7f2fe78bSCy Schubert} ); 6365*7f2fe78bSCy Schubert 6366*7f2fe78bSCy SchubertjQuery.each( { 6367*7f2fe78bSCy Schubert appendTo: "append", 6368*7f2fe78bSCy Schubert prependTo: "prepend", 6369*7f2fe78bSCy Schubert insertBefore: "before", 6370*7f2fe78bSCy Schubert insertAfter: "after", 6371*7f2fe78bSCy Schubert replaceAll: "replaceWith" 6372*7f2fe78bSCy Schubert}, function( name, original ) { 6373*7f2fe78bSCy Schubert jQuery.fn[ name ] = function( selector ) { 6374*7f2fe78bSCy Schubert var elems, 6375*7f2fe78bSCy Schubert ret = [], 6376*7f2fe78bSCy Schubert insert = jQuery( selector ), 6377*7f2fe78bSCy Schubert last = insert.length - 1, 6378*7f2fe78bSCy Schubert i = 0; 6379*7f2fe78bSCy Schubert 6380*7f2fe78bSCy Schubert for ( ; i <= last; i++ ) { 6381*7f2fe78bSCy Schubert elems = i === last ? this : this.clone( true ); 6382*7f2fe78bSCy Schubert jQuery( insert[ i ] )[ original ]( elems ); 6383*7f2fe78bSCy Schubert 6384*7f2fe78bSCy Schubert // Support: Android <=4.0 only, PhantomJS 1 only 6385*7f2fe78bSCy Schubert // .get() because push.apply(_, arraylike) throws on ancient WebKit 6386*7f2fe78bSCy Schubert push.apply( ret, elems.get() ); 6387*7f2fe78bSCy Schubert } 6388*7f2fe78bSCy Schubert 6389*7f2fe78bSCy Schubert return this.pushStack( ret ); 6390*7f2fe78bSCy Schubert }; 6391*7f2fe78bSCy Schubert} ); 6392*7f2fe78bSCy Schubertvar rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" ); 6393*7f2fe78bSCy Schubert 6394*7f2fe78bSCy Schubertvar getStyles = function( elem ) { 6395*7f2fe78bSCy Schubert 6396*7f2fe78bSCy Schubert // Support: IE <=11 only, Firefox <=30 (#15098, #14150) 6397*7f2fe78bSCy Schubert // IE throws on elements created in popups 6398*7f2fe78bSCy Schubert // FF meanwhile throws on frame elements through "defaultView.getComputedStyle" 6399*7f2fe78bSCy Schubert var view = elem.ownerDocument.defaultView; 6400*7f2fe78bSCy Schubert 6401*7f2fe78bSCy Schubert if ( !view || !view.opener ) { 6402*7f2fe78bSCy Schubert view = window; 6403*7f2fe78bSCy Schubert } 6404*7f2fe78bSCy Schubert 6405*7f2fe78bSCy Schubert return view.getComputedStyle( elem ); 6406*7f2fe78bSCy Schubert }; 6407*7f2fe78bSCy Schubert 6408*7f2fe78bSCy Schubertvar swap = function( elem, options, callback ) { 6409*7f2fe78bSCy Schubert var ret, name, 6410*7f2fe78bSCy Schubert old = {}; 6411*7f2fe78bSCy Schubert 6412*7f2fe78bSCy Schubert // Remember the old values, and insert the new ones 6413*7f2fe78bSCy Schubert for ( name in options ) { 6414*7f2fe78bSCy Schubert old[ name ] = elem.style[ name ]; 6415*7f2fe78bSCy Schubert elem.style[ name ] = options[ name ]; 6416*7f2fe78bSCy Schubert } 6417*7f2fe78bSCy Schubert 6418*7f2fe78bSCy Schubert ret = callback.call( elem ); 6419*7f2fe78bSCy Schubert 6420*7f2fe78bSCy Schubert // Revert the old values 6421*7f2fe78bSCy Schubert for ( name in options ) { 6422*7f2fe78bSCy Schubert elem.style[ name ] = old[ name ]; 6423*7f2fe78bSCy Schubert } 6424*7f2fe78bSCy Schubert 6425*7f2fe78bSCy Schubert return ret; 6426*7f2fe78bSCy Schubert}; 6427*7f2fe78bSCy Schubert 6428*7f2fe78bSCy Schubert 6429*7f2fe78bSCy Schubertvar rboxStyle = new RegExp( cssExpand.join( "|" ), "i" ); 6430*7f2fe78bSCy Schubert 6431*7f2fe78bSCy Schubert 6432*7f2fe78bSCy Schubert 6433*7f2fe78bSCy Schubert( function() { 6434*7f2fe78bSCy Schubert 6435*7f2fe78bSCy Schubert // Executing both pixelPosition & boxSizingReliable tests require only one layout 6436*7f2fe78bSCy Schubert // so they're executed at the same time to save the second computation. 6437*7f2fe78bSCy Schubert function computeStyleTests() { 6438*7f2fe78bSCy Schubert 6439*7f2fe78bSCy Schubert // This is a singleton, we need to execute it only once 6440*7f2fe78bSCy Schubert if ( !div ) { 6441*7f2fe78bSCy Schubert return; 6442*7f2fe78bSCy Schubert } 6443*7f2fe78bSCy Schubert 6444*7f2fe78bSCy Schubert container.style.cssText = "position:absolute;left:-11111px;width:60px;" + 6445*7f2fe78bSCy Schubert "margin-top:1px;padding:0;border:0"; 6446*7f2fe78bSCy Schubert div.style.cssText = 6447*7f2fe78bSCy Schubert "position:relative;display:block;box-sizing:border-box;overflow:scroll;" + 6448*7f2fe78bSCy Schubert "margin:auto;border:1px;padding:1px;" + 6449*7f2fe78bSCy Schubert "width:60%;top:1%"; 6450*7f2fe78bSCy Schubert documentElement.appendChild( container ).appendChild( div ); 6451*7f2fe78bSCy Schubert 6452*7f2fe78bSCy Schubert var divStyle = window.getComputedStyle( div ); 6453*7f2fe78bSCy Schubert pixelPositionVal = divStyle.top !== "1%"; 6454*7f2fe78bSCy Schubert 6455*7f2fe78bSCy Schubert // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44 6456*7f2fe78bSCy Schubert reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12; 6457*7f2fe78bSCy Schubert 6458*7f2fe78bSCy Schubert // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3 6459*7f2fe78bSCy Schubert // Some styles come back with percentage values, even though they shouldn't 6460*7f2fe78bSCy Schubert div.style.right = "60%"; 6461*7f2fe78bSCy Schubert pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36; 6462*7f2fe78bSCy Schubert 6463*7f2fe78bSCy Schubert // Support: IE 9 - 11 only 6464*7f2fe78bSCy Schubert // Detect misreporting of content dimensions for box-sizing:border-box elements 6465*7f2fe78bSCy Schubert boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36; 6466*7f2fe78bSCy Schubert 6467*7f2fe78bSCy Schubert // Support: IE 9 only 6468*7f2fe78bSCy Schubert // Detect overflow:scroll screwiness (gh-3699) 6469*7f2fe78bSCy Schubert // Support: Chrome <=64 6470*7f2fe78bSCy Schubert // Don't get tricked when zoom affects offsetWidth (gh-4029) 6471*7f2fe78bSCy Schubert div.style.position = "absolute"; 6472*7f2fe78bSCy Schubert scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12; 6473*7f2fe78bSCy Schubert 6474*7f2fe78bSCy Schubert documentElement.removeChild( container ); 6475*7f2fe78bSCy Schubert 6476*7f2fe78bSCy Schubert // Nullify the div so it wouldn't be stored in the memory and 6477*7f2fe78bSCy Schubert // it will also be a sign that checks already performed 6478*7f2fe78bSCy Schubert div = null; 6479*7f2fe78bSCy Schubert } 6480*7f2fe78bSCy Schubert 6481*7f2fe78bSCy Schubert function roundPixelMeasures( measure ) { 6482*7f2fe78bSCy Schubert return Math.round( parseFloat( measure ) ); 6483*7f2fe78bSCy Schubert } 6484*7f2fe78bSCy Schubert 6485*7f2fe78bSCy Schubert var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal, 6486*7f2fe78bSCy Schubert reliableTrDimensionsVal, reliableMarginLeftVal, 6487*7f2fe78bSCy Schubert container = document.createElement( "div" ), 6488*7f2fe78bSCy Schubert div = document.createElement( "div" ); 6489*7f2fe78bSCy Schubert 6490*7f2fe78bSCy Schubert // Finish early in limited (non-browser) environments 6491*7f2fe78bSCy Schubert if ( !div.style ) { 6492*7f2fe78bSCy Schubert return; 6493*7f2fe78bSCy Schubert } 6494*7f2fe78bSCy Schubert 6495*7f2fe78bSCy Schubert // Support: IE <=9 - 11 only 6496*7f2fe78bSCy Schubert // Style of cloned element affects source element cloned (#8908) 6497*7f2fe78bSCy Schubert div.style.backgroundClip = "content-box"; 6498*7f2fe78bSCy Schubert div.cloneNode( true ).style.backgroundClip = ""; 6499*7f2fe78bSCy Schubert support.clearCloneStyle = div.style.backgroundClip === "content-box"; 6500*7f2fe78bSCy Schubert 6501*7f2fe78bSCy Schubert jQuery.extend( support, { 6502*7f2fe78bSCy Schubert boxSizingReliable: function() { 6503*7f2fe78bSCy Schubert computeStyleTests(); 6504*7f2fe78bSCy Schubert return boxSizingReliableVal; 6505*7f2fe78bSCy Schubert }, 6506*7f2fe78bSCy Schubert pixelBoxStyles: function() { 6507*7f2fe78bSCy Schubert computeStyleTests(); 6508*7f2fe78bSCy Schubert return pixelBoxStylesVal; 6509*7f2fe78bSCy Schubert }, 6510*7f2fe78bSCy Schubert pixelPosition: function() { 6511*7f2fe78bSCy Schubert computeStyleTests(); 6512*7f2fe78bSCy Schubert return pixelPositionVal; 6513*7f2fe78bSCy Schubert }, 6514*7f2fe78bSCy Schubert reliableMarginLeft: function() { 6515*7f2fe78bSCy Schubert computeStyleTests(); 6516*7f2fe78bSCy Schubert return reliableMarginLeftVal; 6517*7f2fe78bSCy Schubert }, 6518*7f2fe78bSCy Schubert scrollboxSize: function() { 6519*7f2fe78bSCy Schubert computeStyleTests(); 6520*7f2fe78bSCy Schubert return scrollboxSizeVal; 6521*7f2fe78bSCy Schubert }, 6522*7f2fe78bSCy Schubert 6523*7f2fe78bSCy Schubert // Support: IE 9 - 11+, Edge 15 - 18+ 6524*7f2fe78bSCy Schubert // IE/Edge misreport `getComputedStyle` of table rows with width/height 6525*7f2fe78bSCy Schubert // set in CSS while `offset*` properties report correct values. 6526*7f2fe78bSCy Schubert // Behavior in IE 9 is more subtle than in newer versions & it passes 6527*7f2fe78bSCy Schubert // some versions of this test; make sure not to make it pass there! 6528*7f2fe78bSCy Schubert // 6529*7f2fe78bSCy Schubert // Support: Firefox 70+ 6530*7f2fe78bSCy Schubert // Only Firefox includes border widths 6531*7f2fe78bSCy Schubert // in computed dimensions. (gh-4529) 6532*7f2fe78bSCy Schubert reliableTrDimensions: function() { 6533*7f2fe78bSCy Schubert var table, tr, trChild, trStyle; 6534*7f2fe78bSCy Schubert if ( reliableTrDimensionsVal == null ) { 6535*7f2fe78bSCy Schubert table = document.createElement( "table" ); 6536*7f2fe78bSCy Schubert tr = document.createElement( "tr" ); 6537*7f2fe78bSCy Schubert trChild = document.createElement( "div" ); 6538*7f2fe78bSCy Schubert 6539*7f2fe78bSCy Schubert table.style.cssText = "position:absolute;left:-11111px;border-collapse:separate"; 6540*7f2fe78bSCy Schubert tr.style.cssText = "border:1px solid"; 6541*7f2fe78bSCy Schubert 6542*7f2fe78bSCy Schubert // Support: Chrome 86+ 6543*7f2fe78bSCy Schubert // Height set through cssText does not get applied. 6544*7f2fe78bSCy Schubert // Computed height then comes back as 0. 6545*7f2fe78bSCy Schubert tr.style.height = "1px"; 6546*7f2fe78bSCy Schubert trChild.style.height = "9px"; 6547*7f2fe78bSCy Schubert 6548*7f2fe78bSCy Schubert // Support: Android 8 Chrome 86+ 6549*7f2fe78bSCy Schubert // In our bodyBackground.html iframe, 6550*7f2fe78bSCy Schubert // display for all div elements is set to "inline", 6551*7f2fe78bSCy Schubert // which causes a problem only in Android 8 Chrome 86. 6552*7f2fe78bSCy Schubert // Ensuring the div is display: block 6553*7f2fe78bSCy Schubert // gets around this issue. 6554*7f2fe78bSCy Schubert trChild.style.display = "block"; 6555*7f2fe78bSCy Schubert 6556*7f2fe78bSCy Schubert documentElement 6557*7f2fe78bSCy Schubert .appendChild( table ) 6558*7f2fe78bSCy Schubert .appendChild( tr ) 6559*7f2fe78bSCy Schubert .appendChild( trChild ); 6560*7f2fe78bSCy Schubert 6561*7f2fe78bSCy Schubert trStyle = window.getComputedStyle( tr ); 6562*7f2fe78bSCy Schubert reliableTrDimensionsVal = ( parseInt( trStyle.height, 10 ) + 6563*7f2fe78bSCy Schubert parseInt( trStyle.borderTopWidth, 10 ) + 6564*7f2fe78bSCy Schubert parseInt( trStyle.borderBottomWidth, 10 ) ) === tr.offsetHeight; 6565*7f2fe78bSCy Schubert 6566*7f2fe78bSCy Schubert documentElement.removeChild( table ); 6567*7f2fe78bSCy Schubert } 6568*7f2fe78bSCy Schubert return reliableTrDimensionsVal; 6569*7f2fe78bSCy Schubert } 6570*7f2fe78bSCy Schubert } ); 6571*7f2fe78bSCy Schubert} )(); 6572*7f2fe78bSCy Schubert 6573*7f2fe78bSCy Schubert 6574*7f2fe78bSCy Schubertfunction curCSS( elem, name, computed ) { 6575*7f2fe78bSCy Schubert var width, minWidth, maxWidth, ret, 6576*7f2fe78bSCy Schubert 6577*7f2fe78bSCy Schubert // Support: Firefox 51+ 6578*7f2fe78bSCy Schubert // Retrieving style before computed somehow 6579*7f2fe78bSCy Schubert // fixes an issue with getting wrong values 6580*7f2fe78bSCy Schubert // on detached elements 6581*7f2fe78bSCy Schubert style = elem.style; 6582*7f2fe78bSCy Schubert 6583*7f2fe78bSCy Schubert computed = computed || getStyles( elem ); 6584*7f2fe78bSCy Schubert 6585*7f2fe78bSCy Schubert // getPropertyValue is needed for: 6586*7f2fe78bSCy Schubert // .css('filter') (IE 9 only, #12537) 6587*7f2fe78bSCy Schubert // .css('--customProperty) (#3144) 6588*7f2fe78bSCy Schubert if ( computed ) { 6589*7f2fe78bSCy Schubert ret = computed.getPropertyValue( name ) || computed[ name ]; 6590*7f2fe78bSCy Schubert 6591*7f2fe78bSCy Schubert if ( ret === "" && !isAttached( elem ) ) { 6592*7f2fe78bSCy Schubert ret = jQuery.style( elem, name ); 6593*7f2fe78bSCy Schubert } 6594*7f2fe78bSCy Schubert 6595*7f2fe78bSCy Schubert // A tribute to the "awesome hack by Dean Edwards" 6596*7f2fe78bSCy Schubert // Android Browser returns percentage for some values, 6597*7f2fe78bSCy Schubert // but width seems to be reliably pixels. 6598*7f2fe78bSCy Schubert // This is against the CSSOM draft spec: 6599*7f2fe78bSCy Schubert // https://drafts.csswg.org/cssom/#resolved-values 6600*7f2fe78bSCy Schubert if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) { 6601*7f2fe78bSCy Schubert 6602*7f2fe78bSCy Schubert // Remember the original values 6603*7f2fe78bSCy Schubert width = style.width; 6604*7f2fe78bSCy Schubert minWidth = style.minWidth; 6605*7f2fe78bSCy Schubert maxWidth = style.maxWidth; 6606*7f2fe78bSCy Schubert 6607*7f2fe78bSCy Schubert // Put in the new values to get a computed value out 6608*7f2fe78bSCy Schubert style.minWidth = style.maxWidth = style.width = ret; 6609*7f2fe78bSCy Schubert ret = computed.width; 6610*7f2fe78bSCy Schubert 6611*7f2fe78bSCy Schubert // Revert the changed values 6612*7f2fe78bSCy Schubert style.width = width; 6613*7f2fe78bSCy Schubert style.minWidth = minWidth; 6614*7f2fe78bSCy Schubert style.maxWidth = maxWidth; 6615*7f2fe78bSCy Schubert } 6616*7f2fe78bSCy Schubert } 6617*7f2fe78bSCy Schubert 6618*7f2fe78bSCy Schubert return ret !== undefined ? 6619*7f2fe78bSCy Schubert 6620*7f2fe78bSCy Schubert // Support: IE <=9 - 11 only 6621*7f2fe78bSCy Schubert // IE returns zIndex value as an integer. 6622*7f2fe78bSCy Schubert ret + "" : 6623*7f2fe78bSCy Schubert ret; 6624*7f2fe78bSCy Schubert} 6625*7f2fe78bSCy Schubert 6626*7f2fe78bSCy Schubert 6627*7f2fe78bSCy Schubertfunction addGetHookIf( conditionFn, hookFn ) { 6628*7f2fe78bSCy Schubert 6629*7f2fe78bSCy Schubert // Define the hook, we'll check on the first run if it's really needed. 6630*7f2fe78bSCy Schubert return { 6631*7f2fe78bSCy Schubert get: function() { 6632*7f2fe78bSCy Schubert if ( conditionFn() ) { 6633*7f2fe78bSCy Schubert 6634*7f2fe78bSCy Schubert // Hook not needed (or it's not possible to use it due 6635*7f2fe78bSCy Schubert // to missing dependency), remove it. 6636*7f2fe78bSCy Schubert delete this.get; 6637*7f2fe78bSCy Schubert return; 6638*7f2fe78bSCy Schubert } 6639*7f2fe78bSCy Schubert 6640*7f2fe78bSCy Schubert // Hook needed; redefine it so that the support test is not executed again. 6641*7f2fe78bSCy Schubert return ( this.get = hookFn ).apply( this, arguments ); 6642*7f2fe78bSCy Schubert } 6643*7f2fe78bSCy Schubert }; 6644*7f2fe78bSCy Schubert} 6645*7f2fe78bSCy Schubert 6646*7f2fe78bSCy Schubert 6647*7f2fe78bSCy Schubertvar cssPrefixes = [ "Webkit", "Moz", "ms" ], 6648*7f2fe78bSCy Schubert emptyStyle = document.createElement( "div" ).style, 6649*7f2fe78bSCy Schubert vendorProps = {}; 6650*7f2fe78bSCy Schubert 6651*7f2fe78bSCy Schubert// Return a vendor-prefixed property or undefined 6652*7f2fe78bSCy Schubertfunction vendorPropName( name ) { 6653*7f2fe78bSCy Schubert 6654*7f2fe78bSCy Schubert // Check for vendor prefixed names 6655*7f2fe78bSCy Schubert var capName = name[ 0 ].toUpperCase() + name.slice( 1 ), 6656*7f2fe78bSCy Schubert i = cssPrefixes.length; 6657*7f2fe78bSCy Schubert 6658*7f2fe78bSCy Schubert while ( i-- ) { 6659*7f2fe78bSCy Schubert name = cssPrefixes[ i ] + capName; 6660*7f2fe78bSCy Schubert if ( name in emptyStyle ) { 6661*7f2fe78bSCy Schubert return name; 6662*7f2fe78bSCy Schubert } 6663*7f2fe78bSCy Schubert } 6664*7f2fe78bSCy Schubert} 6665*7f2fe78bSCy Schubert 6666*7f2fe78bSCy Schubert// Return a potentially-mapped jQuery.cssProps or vendor prefixed property 6667*7f2fe78bSCy Schubertfunction finalPropName( name ) { 6668*7f2fe78bSCy Schubert var final = jQuery.cssProps[ name ] || vendorProps[ name ]; 6669*7f2fe78bSCy Schubert 6670*7f2fe78bSCy Schubert if ( final ) { 6671*7f2fe78bSCy Schubert return final; 6672*7f2fe78bSCy Schubert } 6673*7f2fe78bSCy Schubert if ( name in emptyStyle ) { 6674*7f2fe78bSCy Schubert return name; 6675*7f2fe78bSCy Schubert } 6676*7f2fe78bSCy Schubert return vendorProps[ name ] = vendorPropName( name ) || name; 6677*7f2fe78bSCy Schubert} 6678*7f2fe78bSCy Schubert 6679*7f2fe78bSCy Schubert 6680*7f2fe78bSCy Schubertvar 6681*7f2fe78bSCy Schubert 6682*7f2fe78bSCy Schubert // Swappable if display is none or starts with table 6683*7f2fe78bSCy Schubert // except "table", "table-cell", or "table-caption" 6684*7f2fe78bSCy Schubert // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display 6685*7f2fe78bSCy Schubert rdisplayswap = /^(none|table(?!-c[ea]).+)/, 6686*7f2fe78bSCy Schubert rcustomProp = /^--/, 6687*7f2fe78bSCy Schubert cssShow = { position: "absolute", visibility: "hidden", display: "block" }, 6688*7f2fe78bSCy Schubert cssNormalTransform = { 6689*7f2fe78bSCy Schubert letterSpacing: "0", 6690*7f2fe78bSCy Schubert fontWeight: "400" 6691*7f2fe78bSCy Schubert }; 6692*7f2fe78bSCy Schubert 6693*7f2fe78bSCy Schubertfunction setPositiveNumber( _elem, value, subtract ) { 6694*7f2fe78bSCy Schubert 6695*7f2fe78bSCy Schubert // Any relative (+/-) values have already been 6696*7f2fe78bSCy Schubert // normalized at this point 6697*7f2fe78bSCy Schubert var matches = rcssNum.exec( value ); 6698*7f2fe78bSCy Schubert return matches ? 6699*7f2fe78bSCy Schubert 6700*7f2fe78bSCy Schubert // Guard against undefined "subtract", e.g., when used as in cssHooks 6701*7f2fe78bSCy Schubert Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) : 6702*7f2fe78bSCy Schubert value; 6703*7f2fe78bSCy Schubert} 6704*7f2fe78bSCy Schubert 6705*7f2fe78bSCy Schubertfunction boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) { 6706*7f2fe78bSCy Schubert var i = dimension === "width" ? 1 : 0, 6707*7f2fe78bSCy Schubert extra = 0, 6708*7f2fe78bSCy Schubert delta = 0; 6709*7f2fe78bSCy Schubert 6710*7f2fe78bSCy Schubert // Adjustment may not be necessary 6711*7f2fe78bSCy Schubert if ( box === ( isBorderBox ? "border" : "content" ) ) { 6712*7f2fe78bSCy Schubert return 0; 6713*7f2fe78bSCy Schubert } 6714*7f2fe78bSCy Schubert 6715*7f2fe78bSCy Schubert for ( ; i < 4; i += 2 ) { 6716*7f2fe78bSCy Schubert 6717*7f2fe78bSCy Schubert // Both box models exclude margin 6718*7f2fe78bSCy Schubert if ( box === "margin" ) { 6719*7f2fe78bSCy Schubert delta += jQuery.css( elem, box + cssExpand[ i ], true, styles ); 6720*7f2fe78bSCy Schubert } 6721*7f2fe78bSCy Schubert 6722*7f2fe78bSCy Schubert // If we get here with a content-box, we're seeking "padding" or "border" or "margin" 6723*7f2fe78bSCy Schubert if ( !isBorderBox ) { 6724*7f2fe78bSCy Schubert 6725*7f2fe78bSCy Schubert // Add padding 6726*7f2fe78bSCy Schubert delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); 6727*7f2fe78bSCy Schubert 6728*7f2fe78bSCy Schubert // For "border" or "margin", add border 6729*7f2fe78bSCy Schubert if ( box !== "padding" ) { 6730*7f2fe78bSCy Schubert delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); 6731*7f2fe78bSCy Schubert 6732*7f2fe78bSCy Schubert // But still keep track of it otherwise 6733*7f2fe78bSCy Schubert } else { 6734*7f2fe78bSCy Schubert extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); 6735*7f2fe78bSCy Schubert } 6736*7f2fe78bSCy Schubert 6737*7f2fe78bSCy Schubert // If we get here with a border-box (content + padding + border), we're seeking "content" or 6738*7f2fe78bSCy Schubert // "padding" or "margin" 6739*7f2fe78bSCy Schubert } else { 6740*7f2fe78bSCy Schubert 6741*7f2fe78bSCy Schubert // For "content", subtract padding 6742*7f2fe78bSCy Schubert if ( box === "content" ) { 6743*7f2fe78bSCy Schubert delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); 6744*7f2fe78bSCy Schubert } 6745*7f2fe78bSCy Schubert 6746*7f2fe78bSCy Schubert // For "content" or "padding", subtract border 6747*7f2fe78bSCy Schubert if ( box !== "margin" ) { 6748*7f2fe78bSCy Schubert delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); 6749*7f2fe78bSCy Schubert } 6750*7f2fe78bSCy Schubert } 6751*7f2fe78bSCy Schubert } 6752*7f2fe78bSCy Schubert 6753*7f2fe78bSCy Schubert // Account for positive content-box scroll gutter when requested by providing computedVal 6754*7f2fe78bSCy Schubert if ( !isBorderBox && computedVal >= 0 ) { 6755*7f2fe78bSCy Schubert 6756*7f2fe78bSCy Schubert // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border 6757*7f2fe78bSCy Schubert // Assuming integer scroll gutter, subtract the rest and round down 6758*7f2fe78bSCy Schubert delta += Math.max( 0, Math.ceil( 6759*7f2fe78bSCy Schubert elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] - 6760*7f2fe78bSCy Schubert computedVal - 6761*7f2fe78bSCy Schubert delta - 6762*7f2fe78bSCy Schubert extra - 6763*7f2fe78bSCy Schubert 0.5 6764*7f2fe78bSCy Schubert 6765*7f2fe78bSCy Schubert // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter 6766*7f2fe78bSCy Schubert // Use an explicit zero to avoid NaN (gh-3964) 6767*7f2fe78bSCy Schubert ) ) || 0; 6768*7f2fe78bSCy Schubert } 6769*7f2fe78bSCy Schubert 6770*7f2fe78bSCy Schubert return delta; 6771*7f2fe78bSCy Schubert} 6772*7f2fe78bSCy Schubert 6773*7f2fe78bSCy Schubertfunction getWidthOrHeight( elem, dimension, extra ) { 6774*7f2fe78bSCy Schubert 6775*7f2fe78bSCy Schubert // Start with computed style 6776*7f2fe78bSCy Schubert var styles = getStyles( elem ), 6777*7f2fe78bSCy Schubert 6778*7f2fe78bSCy Schubert // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322). 6779*7f2fe78bSCy Schubert // Fake content-box until we know it's needed to know the true value. 6780*7f2fe78bSCy Schubert boxSizingNeeded = !support.boxSizingReliable() || extra, 6781*7f2fe78bSCy Schubert isBorderBox = boxSizingNeeded && 6782*7f2fe78bSCy Schubert jQuery.css( elem, "boxSizing", false, styles ) === "border-box", 6783*7f2fe78bSCy Schubert valueIsBorderBox = isBorderBox, 6784*7f2fe78bSCy Schubert 6785*7f2fe78bSCy Schubert val = curCSS( elem, dimension, styles ), 6786*7f2fe78bSCy Schubert offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ); 6787*7f2fe78bSCy Schubert 6788*7f2fe78bSCy Schubert // Support: Firefox <=54 6789*7f2fe78bSCy Schubert // Return a confounding non-pixel value or feign ignorance, as appropriate. 6790*7f2fe78bSCy Schubert if ( rnumnonpx.test( val ) ) { 6791*7f2fe78bSCy Schubert if ( !extra ) { 6792*7f2fe78bSCy Schubert return val; 6793*7f2fe78bSCy Schubert } 6794*7f2fe78bSCy Schubert val = "auto"; 6795*7f2fe78bSCy Schubert } 6796*7f2fe78bSCy Schubert 6797*7f2fe78bSCy Schubert 6798*7f2fe78bSCy Schubert // Support: IE 9 - 11 only 6799*7f2fe78bSCy Schubert // Use offsetWidth/offsetHeight for when box sizing is unreliable. 6800*7f2fe78bSCy Schubert // In those cases, the computed value can be trusted to be border-box. 6801*7f2fe78bSCy Schubert if ( ( !support.boxSizingReliable() && isBorderBox || 6802*7f2fe78bSCy Schubert 6803*7f2fe78bSCy Schubert // Support: IE 10 - 11+, Edge 15 - 18+ 6804*7f2fe78bSCy Schubert // IE/Edge misreport `getComputedStyle` of table rows with width/height 6805*7f2fe78bSCy Schubert // set in CSS while `offset*` properties report correct values. 6806*7f2fe78bSCy Schubert // Interestingly, in some cases IE 9 doesn't suffer from this issue. 6807*7f2fe78bSCy Schubert !support.reliableTrDimensions() && nodeName( elem, "tr" ) || 6808*7f2fe78bSCy Schubert 6809*7f2fe78bSCy Schubert // Fall back to offsetWidth/offsetHeight when value is "auto" 6810*7f2fe78bSCy Schubert // This happens for inline elements with no explicit setting (gh-3571) 6811*7f2fe78bSCy Schubert val === "auto" || 6812*7f2fe78bSCy Schubert 6813*7f2fe78bSCy Schubert // Support: Android <=4.1 - 4.3 only 6814*7f2fe78bSCy Schubert // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602) 6815*7f2fe78bSCy Schubert !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) && 6816*7f2fe78bSCy Schubert 6817*7f2fe78bSCy Schubert // Make sure the element is visible & connected 6818*7f2fe78bSCy Schubert elem.getClientRects().length ) { 6819*7f2fe78bSCy Schubert 6820*7f2fe78bSCy Schubert isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; 6821*7f2fe78bSCy Schubert 6822*7f2fe78bSCy Schubert // Where available, offsetWidth/offsetHeight approximate border box dimensions. 6823*7f2fe78bSCy Schubert // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the 6824*7f2fe78bSCy Schubert // retrieved value as a content box dimension. 6825*7f2fe78bSCy Schubert valueIsBorderBox = offsetProp in elem; 6826*7f2fe78bSCy Schubert if ( valueIsBorderBox ) { 6827*7f2fe78bSCy Schubert val = elem[ offsetProp ]; 6828*7f2fe78bSCy Schubert } 6829*7f2fe78bSCy Schubert } 6830*7f2fe78bSCy Schubert 6831*7f2fe78bSCy Schubert // Normalize "" and auto 6832*7f2fe78bSCy Schubert val = parseFloat( val ) || 0; 6833*7f2fe78bSCy Schubert 6834*7f2fe78bSCy Schubert // Adjust for the element's box model 6835*7f2fe78bSCy Schubert return ( val + 6836*7f2fe78bSCy Schubert boxModelAdjustment( 6837*7f2fe78bSCy Schubert elem, 6838*7f2fe78bSCy Schubert dimension, 6839*7f2fe78bSCy Schubert extra || ( isBorderBox ? "border" : "content" ), 6840*7f2fe78bSCy Schubert valueIsBorderBox, 6841*7f2fe78bSCy Schubert styles, 6842*7f2fe78bSCy Schubert 6843*7f2fe78bSCy Schubert // Provide the current computed size to request scroll gutter calculation (gh-3589) 6844*7f2fe78bSCy Schubert val 6845*7f2fe78bSCy Schubert ) 6846*7f2fe78bSCy Schubert ) + "px"; 6847*7f2fe78bSCy Schubert} 6848*7f2fe78bSCy Schubert 6849*7f2fe78bSCy SchubertjQuery.extend( { 6850*7f2fe78bSCy Schubert 6851*7f2fe78bSCy Schubert // Add in style property hooks for overriding the default 6852*7f2fe78bSCy Schubert // behavior of getting and setting a style property 6853*7f2fe78bSCy Schubert cssHooks: { 6854*7f2fe78bSCy Schubert opacity: { 6855*7f2fe78bSCy Schubert get: function( elem, computed ) { 6856*7f2fe78bSCy Schubert if ( computed ) { 6857*7f2fe78bSCy Schubert 6858*7f2fe78bSCy Schubert // We should always get a number back from opacity 6859*7f2fe78bSCy Schubert var ret = curCSS( elem, "opacity" ); 6860*7f2fe78bSCy Schubert return ret === "" ? "1" : ret; 6861*7f2fe78bSCy Schubert } 6862*7f2fe78bSCy Schubert } 6863*7f2fe78bSCy Schubert } 6864*7f2fe78bSCy Schubert }, 6865*7f2fe78bSCy Schubert 6866*7f2fe78bSCy Schubert // Don't automatically add "px" to these possibly-unitless properties 6867*7f2fe78bSCy Schubert cssNumber: { 6868*7f2fe78bSCy Schubert "animationIterationCount": true, 6869*7f2fe78bSCy Schubert "columnCount": true, 6870*7f2fe78bSCy Schubert "fillOpacity": true, 6871*7f2fe78bSCy Schubert "flexGrow": true, 6872*7f2fe78bSCy Schubert "flexShrink": true, 6873*7f2fe78bSCy Schubert "fontWeight": true, 6874*7f2fe78bSCy Schubert "gridArea": true, 6875*7f2fe78bSCy Schubert "gridColumn": true, 6876*7f2fe78bSCy Schubert "gridColumnEnd": true, 6877*7f2fe78bSCy Schubert "gridColumnStart": true, 6878*7f2fe78bSCy Schubert "gridRow": true, 6879*7f2fe78bSCy Schubert "gridRowEnd": true, 6880*7f2fe78bSCy Schubert "gridRowStart": true, 6881*7f2fe78bSCy Schubert "lineHeight": true, 6882*7f2fe78bSCy Schubert "opacity": true, 6883*7f2fe78bSCy Schubert "order": true, 6884*7f2fe78bSCy Schubert "orphans": true, 6885*7f2fe78bSCy Schubert "widows": true, 6886*7f2fe78bSCy Schubert "zIndex": true, 6887*7f2fe78bSCy Schubert "zoom": true 6888*7f2fe78bSCy Schubert }, 6889*7f2fe78bSCy Schubert 6890*7f2fe78bSCy Schubert // Add in properties whose names you wish to fix before 6891*7f2fe78bSCy Schubert // setting or getting the value 6892*7f2fe78bSCy Schubert cssProps: {}, 6893*7f2fe78bSCy Schubert 6894*7f2fe78bSCy Schubert // Get and set the style property on a DOM Node 6895*7f2fe78bSCy Schubert style: function( elem, name, value, extra ) { 6896*7f2fe78bSCy Schubert 6897*7f2fe78bSCy Schubert // Don't set styles on text and comment nodes 6898*7f2fe78bSCy Schubert if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) { 6899*7f2fe78bSCy Schubert return; 6900*7f2fe78bSCy Schubert } 6901*7f2fe78bSCy Schubert 6902*7f2fe78bSCy Schubert // Make sure that we're working with the right name 6903*7f2fe78bSCy Schubert var ret, type, hooks, 6904*7f2fe78bSCy Schubert origName = camelCase( name ), 6905*7f2fe78bSCy Schubert isCustomProp = rcustomProp.test( name ), 6906*7f2fe78bSCy Schubert style = elem.style; 6907*7f2fe78bSCy Schubert 6908*7f2fe78bSCy Schubert // Make sure that we're working with the right name. We don't 6909*7f2fe78bSCy Schubert // want to query the value if it is a CSS custom property 6910*7f2fe78bSCy Schubert // since they are user-defined. 6911*7f2fe78bSCy Schubert if ( !isCustomProp ) { 6912*7f2fe78bSCy Schubert name = finalPropName( origName ); 6913*7f2fe78bSCy Schubert } 6914*7f2fe78bSCy Schubert 6915*7f2fe78bSCy Schubert // Gets hook for the prefixed version, then unprefixed version 6916*7f2fe78bSCy Schubert hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; 6917*7f2fe78bSCy Schubert 6918*7f2fe78bSCy Schubert // Check if we're setting a value 6919*7f2fe78bSCy Schubert if ( value !== undefined ) { 6920*7f2fe78bSCy Schubert type = typeof value; 6921*7f2fe78bSCy Schubert 6922*7f2fe78bSCy Schubert // Convert "+=" or "-=" to relative numbers (#7345) 6923*7f2fe78bSCy Schubert if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) { 6924*7f2fe78bSCy Schubert value = adjustCSS( elem, name, ret ); 6925*7f2fe78bSCy Schubert 6926*7f2fe78bSCy Schubert // Fixes bug #9237 6927*7f2fe78bSCy Schubert type = "number"; 6928*7f2fe78bSCy Schubert } 6929*7f2fe78bSCy Schubert 6930*7f2fe78bSCy Schubert // Make sure that null and NaN values aren't set (#7116) 6931*7f2fe78bSCy Schubert if ( value == null || value !== value ) { 6932*7f2fe78bSCy Schubert return; 6933*7f2fe78bSCy Schubert } 6934*7f2fe78bSCy Schubert 6935*7f2fe78bSCy Schubert // If a number was passed in, add the unit (except for certain CSS properties) 6936*7f2fe78bSCy Schubert // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append 6937*7f2fe78bSCy Schubert // "px" to a few hardcoded values. 6938*7f2fe78bSCy Schubert if ( type === "number" && !isCustomProp ) { 6939*7f2fe78bSCy Schubert value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" ); 6940*7f2fe78bSCy Schubert } 6941*7f2fe78bSCy Schubert 6942*7f2fe78bSCy Schubert // background-* props affect original clone's values 6943*7f2fe78bSCy Schubert if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) { 6944*7f2fe78bSCy Schubert style[ name ] = "inherit"; 6945*7f2fe78bSCy Schubert } 6946*7f2fe78bSCy Schubert 6947*7f2fe78bSCy Schubert // If a hook was provided, use that value, otherwise just set the specified value 6948*7f2fe78bSCy Schubert if ( !hooks || !( "set" in hooks ) || 6949*7f2fe78bSCy Schubert ( value = hooks.set( elem, value, extra ) ) !== undefined ) { 6950*7f2fe78bSCy Schubert 6951*7f2fe78bSCy Schubert if ( isCustomProp ) { 6952*7f2fe78bSCy Schubert style.setProperty( name, value ); 6953*7f2fe78bSCy Schubert } else { 6954*7f2fe78bSCy Schubert style[ name ] = value; 6955*7f2fe78bSCy Schubert } 6956*7f2fe78bSCy Schubert } 6957*7f2fe78bSCy Schubert 6958*7f2fe78bSCy Schubert } else { 6959*7f2fe78bSCy Schubert 6960*7f2fe78bSCy Schubert // If a hook was provided get the non-computed value from there 6961*7f2fe78bSCy Schubert if ( hooks && "get" in hooks && 6962*7f2fe78bSCy Schubert ( ret = hooks.get( elem, false, extra ) ) !== undefined ) { 6963*7f2fe78bSCy Schubert 6964*7f2fe78bSCy Schubert return ret; 6965*7f2fe78bSCy Schubert } 6966*7f2fe78bSCy Schubert 6967*7f2fe78bSCy Schubert // Otherwise just get the value from the style object 6968*7f2fe78bSCy Schubert return style[ name ]; 6969*7f2fe78bSCy Schubert } 6970*7f2fe78bSCy Schubert }, 6971*7f2fe78bSCy Schubert 6972*7f2fe78bSCy Schubert css: function( elem, name, extra, styles ) { 6973*7f2fe78bSCy Schubert var val, num, hooks, 6974*7f2fe78bSCy Schubert origName = camelCase( name ), 6975*7f2fe78bSCy Schubert isCustomProp = rcustomProp.test( name ); 6976*7f2fe78bSCy Schubert 6977*7f2fe78bSCy Schubert // Make sure that we're working with the right name. We don't 6978*7f2fe78bSCy Schubert // want to modify the value if it is a CSS custom property 6979*7f2fe78bSCy Schubert // since they are user-defined. 6980*7f2fe78bSCy Schubert if ( !isCustomProp ) { 6981*7f2fe78bSCy Schubert name = finalPropName( origName ); 6982*7f2fe78bSCy Schubert } 6983*7f2fe78bSCy Schubert 6984*7f2fe78bSCy Schubert // Try prefixed name followed by the unprefixed name 6985*7f2fe78bSCy Schubert hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; 6986*7f2fe78bSCy Schubert 6987*7f2fe78bSCy Schubert // If a hook was provided get the computed value from there 6988*7f2fe78bSCy Schubert if ( hooks && "get" in hooks ) { 6989*7f2fe78bSCy Schubert val = hooks.get( elem, true, extra ); 6990*7f2fe78bSCy Schubert } 6991*7f2fe78bSCy Schubert 6992*7f2fe78bSCy Schubert // Otherwise, if a way to get the computed value exists, use that 6993*7f2fe78bSCy Schubert if ( val === undefined ) { 6994*7f2fe78bSCy Schubert val = curCSS( elem, name, styles ); 6995*7f2fe78bSCy Schubert } 6996*7f2fe78bSCy Schubert 6997*7f2fe78bSCy Schubert // Convert "normal" to computed value 6998*7f2fe78bSCy Schubert if ( val === "normal" && name in cssNormalTransform ) { 6999*7f2fe78bSCy Schubert val = cssNormalTransform[ name ]; 7000*7f2fe78bSCy Schubert } 7001*7f2fe78bSCy Schubert 7002*7f2fe78bSCy Schubert // Make numeric if forced or a qualifier was provided and val looks numeric 7003*7f2fe78bSCy Schubert if ( extra === "" || extra ) { 7004*7f2fe78bSCy Schubert num = parseFloat( val ); 7005*7f2fe78bSCy Schubert return extra === true || isFinite( num ) ? num || 0 : val; 7006*7f2fe78bSCy Schubert } 7007*7f2fe78bSCy Schubert 7008*7f2fe78bSCy Schubert return val; 7009*7f2fe78bSCy Schubert } 7010*7f2fe78bSCy Schubert} ); 7011*7f2fe78bSCy Schubert 7012*7f2fe78bSCy SchubertjQuery.each( [ "height", "width" ], function( _i, dimension ) { 7013*7f2fe78bSCy Schubert jQuery.cssHooks[ dimension ] = { 7014*7f2fe78bSCy Schubert get: function( elem, computed, extra ) { 7015*7f2fe78bSCy Schubert if ( computed ) { 7016*7f2fe78bSCy Schubert 7017*7f2fe78bSCy Schubert // Certain elements can have dimension info if we invisibly show them 7018*7f2fe78bSCy Schubert // but it must have a current display style that would benefit 7019*7f2fe78bSCy Schubert return rdisplayswap.test( jQuery.css( elem, "display" ) ) && 7020*7f2fe78bSCy Schubert 7021*7f2fe78bSCy Schubert // Support: Safari 8+ 7022*7f2fe78bSCy Schubert // Table columns in Safari have non-zero offsetWidth & zero 7023*7f2fe78bSCy Schubert // getBoundingClientRect().width unless display is changed. 7024*7f2fe78bSCy Schubert // Support: IE <=11 only 7025*7f2fe78bSCy Schubert // Running getBoundingClientRect on a disconnected node 7026*7f2fe78bSCy Schubert // in IE throws an error. 7027*7f2fe78bSCy Schubert ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ? 7028*7f2fe78bSCy Schubert swap( elem, cssShow, function() { 7029*7f2fe78bSCy Schubert return getWidthOrHeight( elem, dimension, extra ); 7030*7f2fe78bSCy Schubert } ) : 7031*7f2fe78bSCy Schubert getWidthOrHeight( elem, dimension, extra ); 7032*7f2fe78bSCy Schubert } 7033*7f2fe78bSCy Schubert }, 7034*7f2fe78bSCy Schubert 7035*7f2fe78bSCy Schubert set: function( elem, value, extra ) { 7036*7f2fe78bSCy Schubert var matches, 7037*7f2fe78bSCy Schubert styles = getStyles( elem ), 7038*7f2fe78bSCy Schubert 7039*7f2fe78bSCy Schubert // Only read styles.position if the test has a chance to fail 7040*7f2fe78bSCy Schubert // to avoid forcing a reflow. 7041*7f2fe78bSCy Schubert scrollboxSizeBuggy = !support.scrollboxSize() && 7042*7f2fe78bSCy Schubert styles.position === "absolute", 7043*7f2fe78bSCy Schubert 7044*7f2fe78bSCy Schubert // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991) 7045*7f2fe78bSCy Schubert boxSizingNeeded = scrollboxSizeBuggy || extra, 7046*7f2fe78bSCy Schubert isBorderBox = boxSizingNeeded && 7047*7f2fe78bSCy Schubert jQuery.css( elem, "boxSizing", false, styles ) === "border-box", 7048*7f2fe78bSCy Schubert subtract = extra ? 7049*7f2fe78bSCy Schubert boxModelAdjustment( 7050*7f2fe78bSCy Schubert elem, 7051*7f2fe78bSCy Schubert dimension, 7052*7f2fe78bSCy Schubert extra, 7053*7f2fe78bSCy Schubert isBorderBox, 7054*7f2fe78bSCy Schubert styles 7055*7f2fe78bSCy Schubert ) : 7056*7f2fe78bSCy Schubert 0; 7057*7f2fe78bSCy Schubert 7058*7f2fe78bSCy Schubert // Account for unreliable border-box dimensions by comparing offset* to computed and 7059*7f2fe78bSCy Schubert // faking a content-box to get border and padding (gh-3699) 7060*7f2fe78bSCy Schubert if ( isBorderBox && scrollboxSizeBuggy ) { 7061*7f2fe78bSCy Schubert subtract -= Math.ceil( 7062*7f2fe78bSCy Schubert elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] - 7063*7f2fe78bSCy Schubert parseFloat( styles[ dimension ] ) - 7064*7f2fe78bSCy Schubert boxModelAdjustment( elem, dimension, "border", false, styles ) - 7065*7f2fe78bSCy Schubert 0.5 7066*7f2fe78bSCy Schubert ); 7067*7f2fe78bSCy Schubert } 7068*7f2fe78bSCy Schubert 7069*7f2fe78bSCy Schubert // Convert to pixels if value adjustment is needed 7070*7f2fe78bSCy Schubert if ( subtract && ( matches = rcssNum.exec( value ) ) && 7071*7f2fe78bSCy Schubert ( matches[ 3 ] || "px" ) !== "px" ) { 7072*7f2fe78bSCy Schubert 7073*7f2fe78bSCy Schubert elem.style[ dimension ] = value; 7074*7f2fe78bSCy Schubert value = jQuery.css( elem, dimension ); 7075*7f2fe78bSCy Schubert } 7076*7f2fe78bSCy Schubert 7077*7f2fe78bSCy Schubert return setPositiveNumber( elem, value, subtract ); 7078*7f2fe78bSCy Schubert } 7079*7f2fe78bSCy Schubert }; 7080*7f2fe78bSCy Schubert} ); 7081*7f2fe78bSCy Schubert 7082*7f2fe78bSCy SchubertjQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft, 7083*7f2fe78bSCy Schubert function( elem, computed ) { 7084*7f2fe78bSCy Schubert if ( computed ) { 7085*7f2fe78bSCy Schubert return ( parseFloat( curCSS( elem, "marginLeft" ) ) || 7086*7f2fe78bSCy Schubert elem.getBoundingClientRect().left - 7087*7f2fe78bSCy Schubert swap( elem, { marginLeft: 0 }, function() { 7088*7f2fe78bSCy Schubert return elem.getBoundingClientRect().left; 7089*7f2fe78bSCy Schubert } ) 7090*7f2fe78bSCy Schubert ) + "px"; 7091*7f2fe78bSCy Schubert } 7092*7f2fe78bSCy Schubert } 7093*7f2fe78bSCy Schubert); 7094*7f2fe78bSCy Schubert 7095*7f2fe78bSCy Schubert// These hooks are used by animate to expand properties 7096*7f2fe78bSCy SchubertjQuery.each( { 7097*7f2fe78bSCy Schubert margin: "", 7098*7f2fe78bSCy Schubert padding: "", 7099*7f2fe78bSCy Schubert border: "Width" 7100*7f2fe78bSCy Schubert}, function( prefix, suffix ) { 7101*7f2fe78bSCy Schubert jQuery.cssHooks[ prefix + suffix ] = { 7102*7f2fe78bSCy Schubert expand: function( value ) { 7103*7f2fe78bSCy Schubert var i = 0, 7104*7f2fe78bSCy Schubert expanded = {}, 7105*7f2fe78bSCy Schubert 7106*7f2fe78bSCy Schubert // Assumes a single number if not a string 7107*7f2fe78bSCy Schubert parts = typeof value === "string" ? value.split( " " ) : [ value ]; 7108*7f2fe78bSCy Schubert 7109*7f2fe78bSCy Schubert for ( ; i < 4; i++ ) { 7110*7f2fe78bSCy Schubert expanded[ prefix + cssExpand[ i ] + suffix ] = 7111*7f2fe78bSCy Schubert parts[ i ] || parts[ i - 2 ] || parts[ 0 ]; 7112*7f2fe78bSCy Schubert } 7113*7f2fe78bSCy Schubert 7114*7f2fe78bSCy Schubert return expanded; 7115*7f2fe78bSCy Schubert } 7116*7f2fe78bSCy Schubert }; 7117*7f2fe78bSCy Schubert 7118*7f2fe78bSCy Schubert if ( prefix !== "margin" ) { 7119*7f2fe78bSCy Schubert jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber; 7120*7f2fe78bSCy Schubert } 7121*7f2fe78bSCy Schubert} ); 7122*7f2fe78bSCy Schubert 7123*7f2fe78bSCy SchubertjQuery.fn.extend( { 7124*7f2fe78bSCy Schubert css: function( name, value ) { 7125*7f2fe78bSCy Schubert return access( this, function( elem, name, value ) { 7126*7f2fe78bSCy Schubert var styles, len, 7127*7f2fe78bSCy Schubert map = {}, 7128*7f2fe78bSCy Schubert i = 0; 7129*7f2fe78bSCy Schubert 7130*7f2fe78bSCy Schubert if ( Array.isArray( name ) ) { 7131*7f2fe78bSCy Schubert styles = getStyles( elem ); 7132*7f2fe78bSCy Schubert len = name.length; 7133*7f2fe78bSCy Schubert 7134*7f2fe78bSCy Schubert for ( ; i < len; i++ ) { 7135*7f2fe78bSCy Schubert map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles ); 7136*7f2fe78bSCy Schubert } 7137*7f2fe78bSCy Schubert 7138*7f2fe78bSCy Schubert return map; 7139*7f2fe78bSCy Schubert } 7140*7f2fe78bSCy Schubert 7141*7f2fe78bSCy Schubert return value !== undefined ? 7142*7f2fe78bSCy Schubert jQuery.style( elem, name, value ) : 7143*7f2fe78bSCy Schubert jQuery.css( elem, name ); 7144*7f2fe78bSCy Schubert }, name, value, arguments.length > 1 ); 7145*7f2fe78bSCy Schubert } 7146*7f2fe78bSCy Schubert} ); 7147*7f2fe78bSCy Schubert 7148*7f2fe78bSCy Schubert 7149*7f2fe78bSCy Schubertfunction Tween( elem, options, prop, end, easing ) { 7150*7f2fe78bSCy Schubert return new Tween.prototype.init( elem, options, prop, end, easing ); 7151*7f2fe78bSCy Schubert} 7152*7f2fe78bSCy SchubertjQuery.Tween = Tween; 7153*7f2fe78bSCy Schubert 7154*7f2fe78bSCy SchubertTween.prototype = { 7155*7f2fe78bSCy Schubert constructor: Tween, 7156*7f2fe78bSCy Schubert init: function( elem, options, prop, end, easing, unit ) { 7157*7f2fe78bSCy Schubert this.elem = elem; 7158*7f2fe78bSCy Schubert this.prop = prop; 7159*7f2fe78bSCy Schubert this.easing = easing || jQuery.easing._default; 7160*7f2fe78bSCy Schubert this.options = options; 7161*7f2fe78bSCy Schubert this.start = this.now = this.cur(); 7162*7f2fe78bSCy Schubert this.end = end; 7163*7f2fe78bSCy Schubert this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" ); 7164*7f2fe78bSCy Schubert }, 7165*7f2fe78bSCy Schubert cur: function() { 7166*7f2fe78bSCy Schubert var hooks = Tween.propHooks[ this.prop ]; 7167*7f2fe78bSCy Schubert 7168*7f2fe78bSCy Schubert return hooks && hooks.get ? 7169*7f2fe78bSCy Schubert hooks.get( this ) : 7170*7f2fe78bSCy Schubert Tween.propHooks._default.get( this ); 7171*7f2fe78bSCy Schubert }, 7172*7f2fe78bSCy Schubert run: function( percent ) { 7173*7f2fe78bSCy Schubert var eased, 7174*7f2fe78bSCy Schubert hooks = Tween.propHooks[ this.prop ]; 7175*7f2fe78bSCy Schubert 7176*7f2fe78bSCy Schubert if ( this.options.duration ) { 7177*7f2fe78bSCy Schubert this.pos = eased = jQuery.easing[ this.easing ]( 7178*7f2fe78bSCy Schubert percent, this.options.duration * percent, 0, 1, this.options.duration 7179*7f2fe78bSCy Schubert ); 7180*7f2fe78bSCy Schubert } else { 7181*7f2fe78bSCy Schubert this.pos = eased = percent; 7182*7f2fe78bSCy Schubert } 7183*7f2fe78bSCy Schubert this.now = ( this.end - this.start ) * eased + this.start; 7184*7f2fe78bSCy Schubert 7185*7f2fe78bSCy Schubert if ( this.options.step ) { 7186*7f2fe78bSCy Schubert this.options.step.call( this.elem, this.now, this ); 7187*7f2fe78bSCy Schubert } 7188*7f2fe78bSCy Schubert 7189*7f2fe78bSCy Schubert if ( hooks && hooks.set ) { 7190*7f2fe78bSCy Schubert hooks.set( this ); 7191*7f2fe78bSCy Schubert } else { 7192*7f2fe78bSCy Schubert Tween.propHooks._default.set( this ); 7193*7f2fe78bSCy Schubert } 7194*7f2fe78bSCy Schubert return this; 7195*7f2fe78bSCy Schubert } 7196*7f2fe78bSCy Schubert}; 7197*7f2fe78bSCy Schubert 7198*7f2fe78bSCy SchubertTween.prototype.init.prototype = Tween.prototype; 7199*7f2fe78bSCy Schubert 7200*7f2fe78bSCy SchubertTween.propHooks = { 7201*7f2fe78bSCy Schubert _default: { 7202*7f2fe78bSCy Schubert get: function( tween ) { 7203*7f2fe78bSCy Schubert var result; 7204*7f2fe78bSCy Schubert 7205*7f2fe78bSCy Schubert // Use a property on the element directly when it is not a DOM element, 7206*7f2fe78bSCy Schubert // or when there is no matching style property that exists. 7207*7f2fe78bSCy Schubert if ( tween.elem.nodeType !== 1 || 7208*7f2fe78bSCy Schubert tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) { 7209*7f2fe78bSCy Schubert return tween.elem[ tween.prop ]; 7210*7f2fe78bSCy Schubert } 7211*7f2fe78bSCy Schubert 7212*7f2fe78bSCy Schubert // Passing an empty string as a 3rd parameter to .css will automatically 7213*7f2fe78bSCy Schubert // attempt a parseFloat and fallback to a string if the parse fails. 7214*7f2fe78bSCy Schubert // Simple values such as "10px" are parsed to Float; 7215*7f2fe78bSCy Schubert // complex values such as "rotate(1rad)" are returned as-is. 7216*7f2fe78bSCy Schubert result = jQuery.css( tween.elem, tween.prop, "" ); 7217*7f2fe78bSCy Schubert 7218*7f2fe78bSCy Schubert // Empty strings, null, undefined and "auto" are converted to 0. 7219*7f2fe78bSCy Schubert return !result || result === "auto" ? 0 : result; 7220*7f2fe78bSCy Schubert }, 7221*7f2fe78bSCy Schubert set: function( tween ) { 7222*7f2fe78bSCy Schubert 7223*7f2fe78bSCy Schubert // Use step hook for back compat. 7224*7f2fe78bSCy Schubert // Use cssHook if its there. 7225*7f2fe78bSCy Schubert // Use .style if available and use plain properties where available. 7226*7f2fe78bSCy Schubert if ( jQuery.fx.step[ tween.prop ] ) { 7227*7f2fe78bSCy Schubert jQuery.fx.step[ tween.prop ]( tween ); 7228*7f2fe78bSCy Schubert } else if ( tween.elem.nodeType === 1 && ( 7229*7f2fe78bSCy Schubert jQuery.cssHooks[ tween.prop ] || 7230*7f2fe78bSCy Schubert tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) { 7231*7f2fe78bSCy Schubert jQuery.style( tween.elem, tween.prop, tween.now + tween.unit ); 7232*7f2fe78bSCy Schubert } else { 7233*7f2fe78bSCy Schubert tween.elem[ tween.prop ] = tween.now; 7234*7f2fe78bSCy Schubert } 7235*7f2fe78bSCy Schubert } 7236*7f2fe78bSCy Schubert } 7237*7f2fe78bSCy Schubert}; 7238*7f2fe78bSCy Schubert 7239*7f2fe78bSCy Schubert// Support: IE <=9 only 7240*7f2fe78bSCy Schubert// Panic based approach to setting things on disconnected nodes 7241*7f2fe78bSCy SchubertTween.propHooks.scrollTop = Tween.propHooks.scrollLeft = { 7242*7f2fe78bSCy Schubert set: function( tween ) { 7243*7f2fe78bSCy Schubert if ( tween.elem.nodeType && tween.elem.parentNode ) { 7244*7f2fe78bSCy Schubert tween.elem[ tween.prop ] = tween.now; 7245*7f2fe78bSCy Schubert } 7246*7f2fe78bSCy Schubert } 7247*7f2fe78bSCy Schubert}; 7248*7f2fe78bSCy Schubert 7249*7f2fe78bSCy SchubertjQuery.easing = { 7250*7f2fe78bSCy Schubert linear: function( p ) { 7251*7f2fe78bSCy Schubert return p; 7252*7f2fe78bSCy Schubert }, 7253*7f2fe78bSCy Schubert swing: function( p ) { 7254*7f2fe78bSCy Schubert return 0.5 - Math.cos( p * Math.PI ) / 2; 7255*7f2fe78bSCy Schubert }, 7256*7f2fe78bSCy Schubert _default: "swing" 7257*7f2fe78bSCy Schubert}; 7258*7f2fe78bSCy Schubert 7259*7f2fe78bSCy SchubertjQuery.fx = Tween.prototype.init; 7260*7f2fe78bSCy Schubert 7261*7f2fe78bSCy Schubert// Back compat <1.8 extension point 7262*7f2fe78bSCy SchubertjQuery.fx.step = {}; 7263*7f2fe78bSCy Schubert 7264*7f2fe78bSCy Schubert 7265*7f2fe78bSCy Schubert 7266*7f2fe78bSCy Schubert 7267*7f2fe78bSCy Schubertvar 7268*7f2fe78bSCy Schubert fxNow, inProgress, 7269*7f2fe78bSCy Schubert rfxtypes = /^(?:toggle|show|hide)$/, 7270*7f2fe78bSCy Schubert rrun = /queueHooks$/; 7271*7f2fe78bSCy Schubert 7272*7f2fe78bSCy Schubertfunction schedule() { 7273*7f2fe78bSCy Schubert if ( inProgress ) { 7274*7f2fe78bSCy Schubert if ( document.hidden === false && window.requestAnimationFrame ) { 7275*7f2fe78bSCy Schubert window.requestAnimationFrame( schedule ); 7276*7f2fe78bSCy Schubert } else { 7277*7f2fe78bSCy Schubert window.setTimeout( schedule, jQuery.fx.interval ); 7278*7f2fe78bSCy Schubert } 7279*7f2fe78bSCy Schubert 7280*7f2fe78bSCy Schubert jQuery.fx.tick(); 7281*7f2fe78bSCy Schubert } 7282*7f2fe78bSCy Schubert} 7283*7f2fe78bSCy Schubert 7284*7f2fe78bSCy Schubert// Animations created synchronously will run synchronously 7285*7f2fe78bSCy Schubertfunction createFxNow() { 7286*7f2fe78bSCy Schubert window.setTimeout( function() { 7287*7f2fe78bSCy Schubert fxNow = undefined; 7288*7f2fe78bSCy Schubert } ); 7289*7f2fe78bSCy Schubert return ( fxNow = Date.now() ); 7290*7f2fe78bSCy Schubert} 7291*7f2fe78bSCy Schubert 7292*7f2fe78bSCy Schubert// Generate parameters to create a standard animation 7293*7f2fe78bSCy Schubertfunction genFx( type, includeWidth ) { 7294*7f2fe78bSCy Schubert var which, 7295*7f2fe78bSCy Schubert i = 0, 7296*7f2fe78bSCy Schubert attrs = { height: type }; 7297*7f2fe78bSCy Schubert 7298*7f2fe78bSCy Schubert // If we include width, step value is 1 to do all cssExpand values, 7299*7f2fe78bSCy Schubert // otherwise step value is 2 to skip over Left and Right 7300*7f2fe78bSCy Schubert includeWidth = includeWidth ? 1 : 0; 7301*7f2fe78bSCy Schubert for ( ; i < 4; i += 2 - includeWidth ) { 7302*7f2fe78bSCy Schubert which = cssExpand[ i ]; 7303*7f2fe78bSCy Schubert attrs[ "margin" + which ] = attrs[ "padding" + which ] = type; 7304*7f2fe78bSCy Schubert } 7305*7f2fe78bSCy Schubert 7306*7f2fe78bSCy Schubert if ( includeWidth ) { 7307*7f2fe78bSCy Schubert attrs.opacity = attrs.width = type; 7308*7f2fe78bSCy Schubert } 7309*7f2fe78bSCy Schubert 7310*7f2fe78bSCy Schubert return attrs; 7311*7f2fe78bSCy Schubert} 7312*7f2fe78bSCy Schubert 7313*7f2fe78bSCy Schubertfunction createTween( value, prop, animation ) { 7314*7f2fe78bSCy Schubert var tween, 7315*7f2fe78bSCy Schubert collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ), 7316*7f2fe78bSCy Schubert index = 0, 7317*7f2fe78bSCy Schubert length = collection.length; 7318*7f2fe78bSCy Schubert for ( ; index < length; index++ ) { 7319*7f2fe78bSCy Schubert if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) { 7320*7f2fe78bSCy Schubert 7321*7f2fe78bSCy Schubert // We're done with this property 7322*7f2fe78bSCy Schubert return tween; 7323*7f2fe78bSCy Schubert } 7324*7f2fe78bSCy Schubert } 7325*7f2fe78bSCy Schubert} 7326*7f2fe78bSCy Schubert 7327*7f2fe78bSCy Schubertfunction defaultPrefilter( elem, props, opts ) { 7328*7f2fe78bSCy Schubert var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display, 7329*7f2fe78bSCy Schubert isBox = "width" in props || "height" in props, 7330*7f2fe78bSCy Schubert anim = this, 7331*7f2fe78bSCy Schubert orig = {}, 7332*7f2fe78bSCy Schubert style = elem.style, 7333*7f2fe78bSCy Schubert hidden = elem.nodeType && isHiddenWithinTree( elem ), 7334*7f2fe78bSCy Schubert dataShow = dataPriv.get( elem, "fxshow" ); 7335*7f2fe78bSCy Schubert 7336*7f2fe78bSCy Schubert // Queue-skipping animations hijack the fx hooks 7337*7f2fe78bSCy Schubert if ( !opts.queue ) { 7338*7f2fe78bSCy Schubert hooks = jQuery._queueHooks( elem, "fx" ); 7339*7f2fe78bSCy Schubert if ( hooks.unqueued == null ) { 7340*7f2fe78bSCy Schubert hooks.unqueued = 0; 7341*7f2fe78bSCy Schubert oldfire = hooks.empty.fire; 7342*7f2fe78bSCy Schubert hooks.empty.fire = function() { 7343*7f2fe78bSCy Schubert if ( !hooks.unqueued ) { 7344*7f2fe78bSCy Schubert oldfire(); 7345*7f2fe78bSCy Schubert } 7346*7f2fe78bSCy Schubert }; 7347*7f2fe78bSCy Schubert } 7348*7f2fe78bSCy Schubert hooks.unqueued++; 7349*7f2fe78bSCy Schubert 7350*7f2fe78bSCy Schubert anim.always( function() { 7351*7f2fe78bSCy Schubert 7352*7f2fe78bSCy Schubert // Ensure the complete handler is called before this completes 7353*7f2fe78bSCy Schubert anim.always( function() { 7354*7f2fe78bSCy Schubert hooks.unqueued--; 7355*7f2fe78bSCy Schubert if ( !jQuery.queue( elem, "fx" ).length ) { 7356*7f2fe78bSCy Schubert hooks.empty.fire(); 7357*7f2fe78bSCy Schubert } 7358*7f2fe78bSCy Schubert } ); 7359*7f2fe78bSCy Schubert } ); 7360*7f2fe78bSCy Schubert } 7361*7f2fe78bSCy Schubert 7362*7f2fe78bSCy Schubert // Detect show/hide animations 7363*7f2fe78bSCy Schubert for ( prop in props ) { 7364*7f2fe78bSCy Schubert value = props[ prop ]; 7365*7f2fe78bSCy Schubert if ( rfxtypes.test( value ) ) { 7366*7f2fe78bSCy Schubert delete props[ prop ]; 7367*7f2fe78bSCy Schubert toggle = toggle || value === "toggle"; 7368*7f2fe78bSCy Schubert if ( value === ( hidden ? "hide" : "show" ) ) { 7369*7f2fe78bSCy Schubert 7370*7f2fe78bSCy Schubert // Pretend to be hidden if this is a "show" and 7371*7f2fe78bSCy Schubert // there is still data from a stopped show/hide 7372*7f2fe78bSCy Schubert if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) { 7373*7f2fe78bSCy Schubert hidden = true; 7374*7f2fe78bSCy Schubert 7375*7f2fe78bSCy Schubert // Ignore all other no-op show/hide data 7376*7f2fe78bSCy Schubert } else { 7377*7f2fe78bSCy Schubert continue; 7378*7f2fe78bSCy Schubert } 7379*7f2fe78bSCy Schubert } 7380*7f2fe78bSCy Schubert orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop ); 7381*7f2fe78bSCy Schubert } 7382*7f2fe78bSCy Schubert } 7383*7f2fe78bSCy Schubert 7384*7f2fe78bSCy Schubert // Bail out if this is a no-op like .hide().hide() 7385*7f2fe78bSCy Schubert propTween = !jQuery.isEmptyObject( props ); 7386*7f2fe78bSCy Schubert if ( !propTween && jQuery.isEmptyObject( orig ) ) { 7387*7f2fe78bSCy Schubert return; 7388*7f2fe78bSCy Schubert } 7389*7f2fe78bSCy Schubert 7390*7f2fe78bSCy Schubert // Restrict "overflow" and "display" styles during box animations 7391*7f2fe78bSCy Schubert if ( isBox && elem.nodeType === 1 ) { 7392*7f2fe78bSCy Schubert 7393*7f2fe78bSCy Schubert // Support: IE <=9 - 11, Edge 12 - 15 7394*7f2fe78bSCy Schubert // Record all 3 overflow attributes because IE does not infer the shorthand 7395*7f2fe78bSCy Schubert // from identically-valued overflowX and overflowY and Edge just mirrors 7396*7f2fe78bSCy Schubert // the overflowX value there. 7397*7f2fe78bSCy Schubert opts.overflow = [ style.overflow, style.overflowX, style.overflowY ]; 7398*7f2fe78bSCy Schubert 7399*7f2fe78bSCy Schubert // Identify a display type, preferring old show/hide data over the CSS cascade 7400*7f2fe78bSCy Schubert restoreDisplay = dataShow && dataShow.display; 7401*7f2fe78bSCy Schubert if ( restoreDisplay == null ) { 7402*7f2fe78bSCy Schubert restoreDisplay = dataPriv.get( elem, "display" ); 7403*7f2fe78bSCy Schubert } 7404*7f2fe78bSCy Schubert display = jQuery.css( elem, "display" ); 7405*7f2fe78bSCy Schubert if ( display === "none" ) { 7406*7f2fe78bSCy Schubert if ( restoreDisplay ) { 7407*7f2fe78bSCy Schubert display = restoreDisplay; 7408*7f2fe78bSCy Schubert } else { 7409*7f2fe78bSCy Schubert 7410*7f2fe78bSCy Schubert // Get nonempty value(s) by temporarily forcing visibility 7411*7f2fe78bSCy Schubert showHide( [ elem ], true ); 7412*7f2fe78bSCy Schubert restoreDisplay = elem.style.display || restoreDisplay; 7413*7f2fe78bSCy Schubert display = jQuery.css( elem, "display" ); 7414*7f2fe78bSCy Schubert showHide( [ elem ] ); 7415*7f2fe78bSCy Schubert } 7416*7f2fe78bSCy Schubert } 7417*7f2fe78bSCy Schubert 7418*7f2fe78bSCy Schubert // Animate inline elements as inline-block 7419*7f2fe78bSCy Schubert if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) { 7420*7f2fe78bSCy Schubert if ( jQuery.css( elem, "float" ) === "none" ) { 7421*7f2fe78bSCy Schubert 7422*7f2fe78bSCy Schubert // Restore the original display value at the end of pure show/hide animations 7423*7f2fe78bSCy Schubert if ( !propTween ) { 7424*7f2fe78bSCy Schubert anim.done( function() { 7425*7f2fe78bSCy Schubert style.display = restoreDisplay; 7426*7f2fe78bSCy Schubert } ); 7427*7f2fe78bSCy Schubert if ( restoreDisplay == null ) { 7428*7f2fe78bSCy Schubert display = style.display; 7429*7f2fe78bSCy Schubert restoreDisplay = display === "none" ? "" : display; 7430*7f2fe78bSCy Schubert } 7431*7f2fe78bSCy Schubert } 7432*7f2fe78bSCy Schubert style.display = "inline-block"; 7433*7f2fe78bSCy Schubert } 7434*7f2fe78bSCy Schubert } 7435*7f2fe78bSCy Schubert } 7436*7f2fe78bSCy Schubert 7437*7f2fe78bSCy Schubert if ( opts.overflow ) { 7438*7f2fe78bSCy Schubert style.overflow = "hidden"; 7439*7f2fe78bSCy Schubert anim.always( function() { 7440*7f2fe78bSCy Schubert style.overflow = opts.overflow[ 0 ]; 7441*7f2fe78bSCy Schubert style.overflowX = opts.overflow[ 1 ]; 7442*7f2fe78bSCy Schubert style.overflowY = opts.overflow[ 2 ]; 7443*7f2fe78bSCy Schubert } ); 7444*7f2fe78bSCy Schubert } 7445*7f2fe78bSCy Schubert 7446*7f2fe78bSCy Schubert // Implement show/hide animations 7447*7f2fe78bSCy Schubert propTween = false; 7448*7f2fe78bSCy Schubert for ( prop in orig ) { 7449*7f2fe78bSCy Schubert 7450*7f2fe78bSCy Schubert // General show/hide setup for this element animation 7451*7f2fe78bSCy Schubert if ( !propTween ) { 7452*7f2fe78bSCy Schubert if ( dataShow ) { 7453*7f2fe78bSCy Schubert if ( "hidden" in dataShow ) { 7454*7f2fe78bSCy Schubert hidden = dataShow.hidden; 7455*7f2fe78bSCy Schubert } 7456*7f2fe78bSCy Schubert } else { 7457*7f2fe78bSCy Schubert dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } ); 7458*7f2fe78bSCy Schubert } 7459*7f2fe78bSCy Schubert 7460*7f2fe78bSCy Schubert // Store hidden/visible for toggle so `.stop().toggle()` "reverses" 7461*7f2fe78bSCy Schubert if ( toggle ) { 7462*7f2fe78bSCy Schubert dataShow.hidden = !hidden; 7463*7f2fe78bSCy Schubert } 7464*7f2fe78bSCy Schubert 7465*7f2fe78bSCy Schubert // Show elements before animating them 7466*7f2fe78bSCy Schubert if ( hidden ) { 7467*7f2fe78bSCy Schubert showHide( [ elem ], true ); 7468*7f2fe78bSCy Schubert } 7469*7f2fe78bSCy Schubert 7470*7f2fe78bSCy Schubert /* eslint-disable no-loop-func */ 7471*7f2fe78bSCy Schubert 7472*7f2fe78bSCy Schubert anim.done( function() { 7473*7f2fe78bSCy Schubert 7474*7f2fe78bSCy Schubert /* eslint-enable no-loop-func */ 7475*7f2fe78bSCy Schubert 7476*7f2fe78bSCy Schubert // The final step of a "hide" animation is actually hiding the element 7477*7f2fe78bSCy Schubert if ( !hidden ) { 7478*7f2fe78bSCy Schubert showHide( [ elem ] ); 7479*7f2fe78bSCy Schubert } 7480*7f2fe78bSCy Schubert dataPriv.remove( elem, "fxshow" ); 7481*7f2fe78bSCy Schubert for ( prop in orig ) { 7482*7f2fe78bSCy Schubert jQuery.style( elem, prop, orig[ prop ] ); 7483*7f2fe78bSCy Schubert } 7484*7f2fe78bSCy Schubert } ); 7485*7f2fe78bSCy Schubert } 7486*7f2fe78bSCy Schubert 7487*7f2fe78bSCy Schubert // Per-property setup 7488*7f2fe78bSCy Schubert propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim ); 7489*7f2fe78bSCy Schubert if ( !( prop in dataShow ) ) { 7490*7f2fe78bSCy Schubert dataShow[ prop ] = propTween.start; 7491*7f2fe78bSCy Schubert if ( hidden ) { 7492*7f2fe78bSCy Schubert propTween.end = propTween.start; 7493*7f2fe78bSCy Schubert propTween.start = 0; 7494*7f2fe78bSCy Schubert } 7495*7f2fe78bSCy Schubert } 7496*7f2fe78bSCy Schubert } 7497*7f2fe78bSCy Schubert} 7498*7f2fe78bSCy Schubert 7499*7f2fe78bSCy Schubertfunction propFilter( props, specialEasing ) { 7500*7f2fe78bSCy Schubert var index, name, easing, value, hooks; 7501*7f2fe78bSCy Schubert 7502*7f2fe78bSCy Schubert // camelCase, specialEasing and expand cssHook pass 7503*7f2fe78bSCy Schubert for ( index in props ) { 7504*7f2fe78bSCy Schubert name = camelCase( index ); 7505*7f2fe78bSCy Schubert easing = specialEasing[ name ]; 7506*7f2fe78bSCy Schubert value = props[ index ]; 7507*7f2fe78bSCy Schubert if ( Array.isArray( value ) ) { 7508*7f2fe78bSCy Schubert easing = value[ 1 ]; 7509*7f2fe78bSCy Schubert value = props[ index ] = value[ 0 ]; 7510*7f2fe78bSCy Schubert } 7511*7f2fe78bSCy Schubert 7512*7f2fe78bSCy Schubert if ( index !== name ) { 7513*7f2fe78bSCy Schubert props[ name ] = value; 7514*7f2fe78bSCy Schubert delete props[ index ]; 7515*7f2fe78bSCy Schubert } 7516*7f2fe78bSCy Schubert 7517*7f2fe78bSCy Schubert hooks = jQuery.cssHooks[ name ]; 7518*7f2fe78bSCy Schubert if ( hooks && "expand" in hooks ) { 7519*7f2fe78bSCy Schubert value = hooks.expand( value ); 7520*7f2fe78bSCy Schubert delete props[ name ]; 7521*7f2fe78bSCy Schubert 7522*7f2fe78bSCy Schubert // Not quite $.extend, this won't overwrite existing keys. 7523*7f2fe78bSCy Schubert // Reusing 'index' because we have the correct "name" 7524*7f2fe78bSCy Schubert for ( index in value ) { 7525*7f2fe78bSCy Schubert if ( !( index in props ) ) { 7526*7f2fe78bSCy Schubert props[ index ] = value[ index ]; 7527*7f2fe78bSCy Schubert specialEasing[ index ] = easing; 7528*7f2fe78bSCy Schubert } 7529*7f2fe78bSCy Schubert } 7530*7f2fe78bSCy Schubert } else { 7531*7f2fe78bSCy Schubert specialEasing[ name ] = easing; 7532*7f2fe78bSCy Schubert } 7533*7f2fe78bSCy Schubert } 7534*7f2fe78bSCy Schubert} 7535*7f2fe78bSCy Schubert 7536*7f2fe78bSCy Schubertfunction Animation( elem, properties, options ) { 7537*7f2fe78bSCy Schubert var result, 7538*7f2fe78bSCy Schubert stopped, 7539*7f2fe78bSCy Schubert index = 0, 7540*7f2fe78bSCy Schubert length = Animation.prefilters.length, 7541*7f2fe78bSCy Schubert deferred = jQuery.Deferred().always( function() { 7542*7f2fe78bSCy Schubert 7543*7f2fe78bSCy Schubert // Don't match elem in the :animated selector 7544*7f2fe78bSCy Schubert delete tick.elem; 7545*7f2fe78bSCy Schubert } ), 7546*7f2fe78bSCy Schubert tick = function() { 7547*7f2fe78bSCy Schubert if ( stopped ) { 7548*7f2fe78bSCy Schubert return false; 7549*7f2fe78bSCy Schubert } 7550*7f2fe78bSCy Schubert var currentTime = fxNow || createFxNow(), 7551*7f2fe78bSCy Schubert remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ), 7552*7f2fe78bSCy Schubert 7553*7f2fe78bSCy Schubert // Support: Android 2.3 only 7554*7f2fe78bSCy Schubert // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497) 7555*7f2fe78bSCy Schubert temp = remaining / animation.duration || 0, 7556*7f2fe78bSCy Schubert percent = 1 - temp, 7557*7f2fe78bSCy Schubert index = 0, 7558*7f2fe78bSCy Schubert length = animation.tweens.length; 7559*7f2fe78bSCy Schubert 7560*7f2fe78bSCy Schubert for ( ; index < length; index++ ) { 7561*7f2fe78bSCy Schubert animation.tweens[ index ].run( percent ); 7562*7f2fe78bSCy Schubert } 7563*7f2fe78bSCy Schubert 7564*7f2fe78bSCy Schubert deferred.notifyWith( elem, [ animation, percent, remaining ] ); 7565*7f2fe78bSCy Schubert 7566*7f2fe78bSCy Schubert // If there's more to do, yield 7567*7f2fe78bSCy Schubert if ( percent < 1 && length ) { 7568*7f2fe78bSCy Schubert return remaining; 7569*7f2fe78bSCy Schubert } 7570*7f2fe78bSCy Schubert 7571*7f2fe78bSCy Schubert // If this was an empty animation, synthesize a final progress notification 7572*7f2fe78bSCy Schubert if ( !length ) { 7573*7f2fe78bSCy Schubert deferred.notifyWith( elem, [ animation, 1, 0 ] ); 7574*7f2fe78bSCy Schubert } 7575*7f2fe78bSCy Schubert 7576*7f2fe78bSCy Schubert // Resolve the animation and report its conclusion 7577*7f2fe78bSCy Schubert deferred.resolveWith( elem, [ animation ] ); 7578*7f2fe78bSCy Schubert return false; 7579*7f2fe78bSCy Schubert }, 7580*7f2fe78bSCy Schubert animation = deferred.promise( { 7581*7f2fe78bSCy Schubert elem: elem, 7582*7f2fe78bSCy Schubert props: jQuery.extend( {}, properties ), 7583*7f2fe78bSCy Schubert opts: jQuery.extend( true, { 7584*7f2fe78bSCy Schubert specialEasing: {}, 7585*7f2fe78bSCy Schubert easing: jQuery.easing._default 7586*7f2fe78bSCy Schubert }, options ), 7587*7f2fe78bSCy Schubert originalProperties: properties, 7588*7f2fe78bSCy Schubert originalOptions: options, 7589*7f2fe78bSCy Schubert startTime: fxNow || createFxNow(), 7590*7f2fe78bSCy Schubert duration: options.duration, 7591*7f2fe78bSCy Schubert tweens: [], 7592*7f2fe78bSCy Schubert createTween: function( prop, end ) { 7593*7f2fe78bSCy Schubert var tween = jQuery.Tween( elem, animation.opts, prop, end, 7594*7f2fe78bSCy Schubert animation.opts.specialEasing[ prop ] || animation.opts.easing ); 7595*7f2fe78bSCy Schubert animation.tweens.push( tween ); 7596*7f2fe78bSCy Schubert return tween; 7597*7f2fe78bSCy Schubert }, 7598*7f2fe78bSCy Schubert stop: function( gotoEnd ) { 7599*7f2fe78bSCy Schubert var index = 0, 7600*7f2fe78bSCy Schubert 7601*7f2fe78bSCy Schubert // If we are going to the end, we want to run all the tweens 7602*7f2fe78bSCy Schubert // otherwise we skip this part 7603*7f2fe78bSCy Schubert length = gotoEnd ? animation.tweens.length : 0; 7604*7f2fe78bSCy Schubert if ( stopped ) { 7605*7f2fe78bSCy Schubert return this; 7606*7f2fe78bSCy Schubert } 7607*7f2fe78bSCy Schubert stopped = true; 7608*7f2fe78bSCy Schubert for ( ; index < length; index++ ) { 7609*7f2fe78bSCy Schubert animation.tweens[ index ].run( 1 ); 7610*7f2fe78bSCy Schubert } 7611*7f2fe78bSCy Schubert 7612*7f2fe78bSCy Schubert // Resolve when we played the last frame; otherwise, reject 7613*7f2fe78bSCy Schubert if ( gotoEnd ) { 7614*7f2fe78bSCy Schubert deferred.notifyWith( elem, [ animation, 1, 0 ] ); 7615*7f2fe78bSCy Schubert deferred.resolveWith( elem, [ animation, gotoEnd ] ); 7616*7f2fe78bSCy Schubert } else { 7617*7f2fe78bSCy Schubert deferred.rejectWith( elem, [ animation, gotoEnd ] ); 7618*7f2fe78bSCy Schubert } 7619*7f2fe78bSCy Schubert return this; 7620*7f2fe78bSCy Schubert } 7621*7f2fe78bSCy Schubert } ), 7622*7f2fe78bSCy Schubert props = animation.props; 7623*7f2fe78bSCy Schubert 7624*7f2fe78bSCy Schubert propFilter( props, animation.opts.specialEasing ); 7625*7f2fe78bSCy Schubert 7626*7f2fe78bSCy Schubert for ( ; index < length; index++ ) { 7627*7f2fe78bSCy Schubert result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts ); 7628*7f2fe78bSCy Schubert if ( result ) { 7629*7f2fe78bSCy Schubert if ( isFunction( result.stop ) ) { 7630*7f2fe78bSCy Schubert jQuery._queueHooks( animation.elem, animation.opts.queue ).stop = 7631*7f2fe78bSCy Schubert result.stop.bind( result ); 7632*7f2fe78bSCy Schubert } 7633*7f2fe78bSCy Schubert return result; 7634*7f2fe78bSCy Schubert } 7635*7f2fe78bSCy Schubert } 7636*7f2fe78bSCy Schubert 7637*7f2fe78bSCy Schubert jQuery.map( props, createTween, animation ); 7638*7f2fe78bSCy Schubert 7639*7f2fe78bSCy Schubert if ( isFunction( animation.opts.start ) ) { 7640*7f2fe78bSCy Schubert animation.opts.start.call( elem, animation ); 7641*7f2fe78bSCy Schubert } 7642*7f2fe78bSCy Schubert 7643*7f2fe78bSCy Schubert // Attach callbacks from options 7644*7f2fe78bSCy Schubert animation 7645*7f2fe78bSCy Schubert .progress( animation.opts.progress ) 7646*7f2fe78bSCy Schubert .done( animation.opts.done, animation.opts.complete ) 7647*7f2fe78bSCy Schubert .fail( animation.opts.fail ) 7648*7f2fe78bSCy Schubert .always( animation.opts.always ); 7649*7f2fe78bSCy Schubert 7650*7f2fe78bSCy Schubert jQuery.fx.timer( 7651*7f2fe78bSCy Schubert jQuery.extend( tick, { 7652*7f2fe78bSCy Schubert elem: elem, 7653*7f2fe78bSCy Schubert anim: animation, 7654*7f2fe78bSCy Schubert queue: animation.opts.queue 7655*7f2fe78bSCy Schubert } ) 7656*7f2fe78bSCy Schubert ); 7657*7f2fe78bSCy Schubert 7658*7f2fe78bSCy Schubert return animation; 7659*7f2fe78bSCy Schubert} 7660*7f2fe78bSCy Schubert 7661*7f2fe78bSCy SchubertjQuery.Animation = jQuery.extend( Animation, { 7662*7f2fe78bSCy Schubert 7663*7f2fe78bSCy Schubert tweeners: { 7664*7f2fe78bSCy Schubert "*": [ function( prop, value ) { 7665*7f2fe78bSCy Schubert var tween = this.createTween( prop, value ); 7666*7f2fe78bSCy Schubert adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween ); 7667*7f2fe78bSCy Schubert return tween; 7668*7f2fe78bSCy Schubert } ] 7669*7f2fe78bSCy Schubert }, 7670*7f2fe78bSCy Schubert 7671*7f2fe78bSCy Schubert tweener: function( props, callback ) { 7672*7f2fe78bSCy Schubert if ( isFunction( props ) ) { 7673*7f2fe78bSCy Schubert callback = props; 7674*7f2fe78bSCy Schubert props = [ "*" ]; 7675*7f2fe78bSCy Schubert } else { 7676*7f2fe78bSCy Schubert props = props.match( rnothtmlwhite ); 7677*7f2fe78bSCy Schubert } 7678*7f2fe78bSCy Schubert 7679*7f2fe78bSCy Schubert var prop, 7680*7f2fe78bSCy Schubert index = 0, 7681*7f2fe78bSCy Schubert length = props.length; 7682*7f2fe78bSCy Schubert 7683*7f2fe78bSCy Schubert for ( ; index < length; index++ ) { 7684*7f2fe78bSCy Schubert prop = props[ index ]; 7685*7f2fe78bSCy Schubert Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || []; 7686*7f2fe78bSCy Schubert Animation.tweeners[ prop ].unshift( callback ); 7687*7f2fe78bSCy Schubert } 7688*7f2fe78bSCy Schubert }, 7689*7f2fe78bSCy Schubert 7690*7f2fe78bSCy Schubert prefilters: [ defaultPrefilter ], 7691*7f2fe78bSCy Schubert 7692*7f2fe78bSCy Schubert prefilter: function( callback, prepend ) { 7693*7f2fe78bSCy Schubert if ( prepend ) { 7694*7f2fe78bSCy Schubert Animation.prefilters.unshift( callback ); 7695*7f2fe78bSCy Schubert } else { 7696*7f2fe78bSCy Schubert Animation.prefilters.push( callback ); 7697*7f2fe78bSCy Schubert } 7698*7f2fe78bSCy Schubert } 7699*7f2fe78bSCy Schubert} ); 7700*7f2fe78bSCy Schubert 7701*7f2fe78bSCy SchubertjQuery.speed = function( speed, easing, fn ) { 7702*7f2fe78bSCy Schubert var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : { 7703*7f2fe78bSCy Schubert complete: fn || !fn && easing || 7704*7f2fe78bSCy Schubert isFunction( speed ) && speed, 7705*7f2fe78bSCy Schubert duration: speed, 7706*7f2fe78bSCy Schubert easing: fn && easing || easing && !isFunction( easing ) && easing 7707*7f2fe78bSCy Schubert }; 7708*7f2fe78bSCy Schubert 7709*7f2fe78bSCy Schubert // Go to the end state if fx are off 7710*7f2fe78bSCy Schubert if ( jQuery.fx.off ) { 7711*7f2fe78bSCy Schubert opt.duration = 0; 7712*7f2fe78bSCy Schubert 7713*7f2fe78bSCy Schubert } else { 7714*7f2fe78bSCy Schubert if ( typeof opt.duration !== "number" ) { 7715*7f2fe78bSCy Schubert if ( opt.duration in jQuery.fx.speeds ) { 7716*7f2fe78bSCy Schubert opt.duration = jQuery.fx.speeds[ opt.duration ]; 7717*7f2fe78bSCy Schubert 7718*7f2fe78bSCy Schubert } else { 7719*7f2fe78bSCy Schubert opt.duration = jQuery.fx.speeds._default; 7720*7f2fe78bSCy Schubert } 7721*7f2fe78bSCy Schubert } 7722*7f2fe78bSCy Schubert } 7723*7f2fe78bSCy Schubert 7724*7f2fe78bSCy Schubert // Normalize opt.queue - true/undefined/null -> "fx" 7725*7f2fe78bSCy Schubert if ( opt.queue == null || opt.queue === true ) { 7726*7f2fe78bSCy Schubert opt.queue = "fx"; 7727*7f2fe78bSCy Schubert } 7728*7f2fe78bSCy Schubert 7729*7f2fe78bSCy Schubert // Queueing 7730*7f2fe78bSCy Schubert opt.old = opt.complete; 7731*7f2fe78bSCy Schubert 7732*7f2fe78bSCy Schubert opt.complete = function() { 7733*7f2fe78bSCy Schubert if ( isFunction( opt.old ) ) { 7734*7f2fe78bSCy Schubert opt.old.call( this ); 7735*7f2fe78bSCy Schubert } 7736*7f2fe78bSCy Schubert 7737*7f2fe78bSCy Schubert if ( opt.queue ) { 7738*7f2fe78bSCy Schubert jQuery.dequeue( this, opt.queue ); 7739*7f2fe78bSCy Schubert } 7740*7f2fe78bSCy Schubert }; 7741*7f2fe78bSCy Schubert 7742*7f2fe78bSCy Schubert return opt; 7743*7f2fe78bSCy Schubert}; 7744*7f2fe78bSCy Schubert 7745*7f2fe78bSCy SchubertjQuery.fn.extend( { 7746*7f2fe78bSCy Schubert fadeTo: function( speed, to, easing, callback ) { 7747*7f2fe78bSCy Schubert 7748*7f2fe78bSCy Schubert // Show any hidden elements after setting opacity to 0 7749*7f2fe78bSCy Schubert return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show() 7750*7f2fe78bSCy Schubert 7751*7f2fe78bSCy Schubert // Animate to the value specified 7752*7f2fe78bSCy Schubert .end().animate( { opacity: to }, speed, easing, callback ); 7753*7f2fe78bSCy Schubert }, 7754*7f2fe78bSCy Schubert animate: function( prop, speed, easing, callback ) { 7755*7f2fe78bSCy Schubert var empty = jQuery.isEmptyObject( prop ), 7756*7f2fe78bSCy Schubert optall = jQuery.speed( speed, easing, callback ), 7757*7f2fe78bSCy Schubert doAnimation = function() { 7758*7f2fe78bSCy Schubert 7759*7f2fe78bSCy Schubert // Operate on a copy of prop so per-property easing won't be lost 7760*7f2fe78bSCy Schubert var anim = Animation( this, jQuery.extend( {}, prop ), optall ); 7761*7f2fe78bSCy Schubert 7762*7f2fe78bSCy Schubert // Empty animations, or finishing resolves immediately 7763*7f2fe78bSCy Schubert if ( empty || dataPriv.get( this, "finish" ) ) { 7764*7f2fe78bSCy Schubert anim.stop( true ); 7765*7f2fe78bSCy Schubert } 7766*7f2fe78bSCy Schubert }; 7767*7f2fe78bSCy Schubert 7768*7f2fe78bSCy Schubert doAnimation.finish = doAnimation; 7769*7f2fe78bSCy Schubert 7770*7f2fe78bSCy Schubert return empty || optall.queue === false ? 7771*7f2fe78bSCy Schubert this.each( doAnimation ) : 7772*7f2fe78bSCy Schubert this.queue( optall.queue, doAnimation ); 7773*7f2fe78bSCy Schubert }, 7774*7f2fe78bSCy Schubert stop: function( type, clearQueue, gotoEnd ) { 7775*7f2fe78bSCy Schubert var stopQueue = function( hooks ) { 7776*7f2fe78bSCy Schubert var stop = hooks.stop; 7777*7f2fe78bSCy Schubert delete hooks.stop; 7778*7f2fe78bSCy Schubert stop( gotoEnd ); 7779*7f2fe78bSCy Schubert }; 7780*7f2fe78bSCy Schubert 7781*7f2fe78bSCy Schubert if ( typeof type !== "string" ) { 7782*7f2fe78bSCy Schubert gotoEnd = clearQueue; 7783*7f2fe78bSCy Schubert clearQueue = type; 7784*7f2fe78bSCy Schubert type = undefined; 7785*7f2fe78bSCy Schubert } 7786*7f2fe78bSCy Schubert if ( clearQueue ) { 7787*7f2fe78bSCy Schubert this.queue( type || "fx", [] ); 7788*7f2fe78bSCy Schubert } 7789*7f2fe78bSCy Schubert 7790*7f2fe78bSCy Schubert return this.each( function() { 7791*7f2fe78bSCy Schubert var dequeue = true, 7792*7f2fe78bSCy Schubert index = type != null && type + "queueHooks", 7793*7f2fe78bSCy Schubert timers = jQuery.timers, 7794*7f2fe78bSCy Schubert data = dataPriv.get( this ); 7795*7f2fe78bSCy Schubert 7796*7f2fe78bSCy Schubert if ( index ) { 7797*7f2fe78bSCy Schubert if ( data[ index ] && data[ index ].stop ) { 7798*7f2fe78bSCy Schubert stopQueue( data[ index ] ); 7799*7f2fe78bSCy Schubert } 7800*7f2fe78bSCy Schubert } else { 7801*7f2fe78bSCy Schubert for ( index in data ) { 7802*7f2fe78bSCy Schubert if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) { 7803*7f2fe78bSCy Schubert stopQueue( data[ index ] ); 7804*7f2fe78bSCy Schubert } 7805*7f2fe78bSCy Schubert } 7806*7f2fe78bSCy Schubert } 7807*7f2fe78bSCy Schubert 7808*7f2fe78bSCy Schubert for ( index = timers.length; index--; ) { 7809*7f2fe78bSCy Schubert if ( timers[ index ].elem === this && 7810*7f2fe78bSCy Schubert ( type == null || timers[ index ].queue === type ) ) { 7811*7f2fe78bSCy Schubert 7812*7f2fe78bSCy Schubert timers[ index ].anim.stop( gotoEnd ); 7813*7f2fe78bSCy Schubert dequeue = false; 7814*7f2fe78bSCy Schubert timers.splice( index, 1 ); 7815*7f2fe78bSCy Schubert } 7816*7f2fe78bSCy Schubert } 7817*7f2fe78bSCy Schubert 7818*7f2fe78bSCy Schubert // Start the next in the queue if the last step wasn't forced. 7819*7f2fe78bSCy Schubert // Timers currently will call their complete callbacks, which 7820*7f2fe78bSCy Schubert // will dequeue but only if they were gotoEnd. 7821*7f2fe78bSCy Schubert if ( dequeue || !gotoEnd ) { 7822*7f2fe78bSCy Schubert jQuery.dequeue( this, type ); 7823*7f2fe78bSCy Schubert } 7824*7f2fe78bSCy Schubert } ); 7825*7f2fe78bSCy Schubert }, 7826*7f2fe78bSCy Schubert finish: function( type ) { 7827*7f2fe78bSCy Schubert if ( type !== false ) { 7828*7f2fe78bSCy Schubert type = type || "fx"; 7829*7f2fe78bSCy Schubert } 7830*7f2fe78bSCy Schubert return this.each( function() { 7831*7f2fe78bSCy Schubert var index, 7832*7f2fe78bSCy Schubert data = dataPriv.get( this ), 7833*7f2fe78bSCy Schubert queue = data[ type + "queue" ], 7834*7f2fe78bSCy Schubert hooks = data[ type + "queueHooks" ], 7835*7f2fe78bSCy Schubert timers = jQuery.timers, 7836*7f2fe78bSCy Schubert length = queue ? queue.length : 0; 7837*7f2fe78bSCy Schubert 7838*7f2fe78bSCy Schubert // Enable finishing flag on private data 7839*7f2fe78bSCy Schubert data.finish = true; 7840*7f2fe78bSCy Schubert 7841*7f2fe78bSCy Schubert // Empty the queue first 7842*7f2fe78bSCy Schubert jQuery.queue( this, type, [] ); 7843*7f2fe78bSCy Schubert 7844*7f2fe78bSCy Schubert if ( hooks && hooks.stop ) { 7845*7f2fe78bSCy Schubert hooks.stop.call( this, true ); 7846*7f2fe78bSCy Schubert } 7847*7f2fe78bSCy Schubert 7848*7f2fe78bSCy Schubert // Look for any active animations, and finish them 7849*7f2fe78bSCy Schubert for ( index = timers.length; index--; ) { 7850*7f2fe78bSCy Schubert if ( timers[ index ].elem === this && timers[ index ].queue === type ) { 7851*7f2fe78bSCy Schubert timers[ index ].anim.stop( true ); 7852*7f2fe78bSCy Schubert timers.splice( index, 1 ); 7853*7f2fe78bSCy Schubert } 7854*7f2fe78bSCy Schubert } 7855*7f2fe78bSCy Schubert 7856*7f2fe78bSCy Schubert // Look for any animations in the old queue and finish them 7857*7f2fe78bSCy Schubert for ( index = 0; index < length; index++ ) { 7858*7f2fe78bSCy Schubert if ( queue[ index ] && queue[ index ].finish ) { 7859*7f2fe78bSCy Schubert queue[ index ].finish.call( this ); 7860*7f2fe78bSCy Schubert } 7861*7f2fe78bSCy Schubert } 7862*7f2fe78bSCy Schubert 7863*7f2fe78bSCy Schubert // Turn off finishing flag 7864*7f2fe78bSCy Schubert delete data.finish; 7865*7f2fe78bSCy Schubert } ); 7866*7f2fe78bSCy Schubert } 7867*7f2fe78bSCy Schubert} ); 7868*7f2fe78bSCy Schubert 7869*7f2fe78bSCy SchubertjQuery.each( [ "toggle", "show", "hide" ], function( _i, name ) { 7870*7f2fe78bSCy Schubert var cssFn = jQuery.fn[ name ]; 7871*7f2fe78bSCy Schubert jQuery.fn[ name ] = function( speed, easing, callback ) { 7872*7f2fe78bSCy Schubert return speed == null || typeof speed === "boolean" ? 7873*7f2fe78bSCy Schubert cssFn.apply( this, arguments ) : 7874*7f2fe78bSCy Schubert this.animate( genFx( name, true ), speed, easing, callback ); 7875*7f2fe78bSCy Schubert }; 7876*7f2fe78bSCy Schubert} ); 7877*7f2fe78bSCy Schubert 7878*7f2fe78bSCy Schubert// Generate shortcuts for custom animations 7879*7f2fe78bSCy SchubertjQuery.each( { 7880*7f2fe78bSCy Schubert slideDown: genFx( "show" ), 7881*7f2fe78bSCy Schubert slideUp: genFx( "hide" ), 7882*7f2fe78bSCy Schubert slideToggle: genFx( "toggle" ), 7883*7f2fe78bSCy Schubert fadeIn: { opacity: "show" }, 7884*7f2fe78bSCy Schubert fadeOut: { opacity: "hide" }, 7885*7f2fe78bSCy Schubert fadeToggle: { opacity: "toggle" } 7886*7f2fe78bSCy Schubert}, function( name, props ) { 7887*7f2fe78bSCy Schubert jQuery.fn[ name ] = function( speed, easing, callback ) { 7888*7f2fe78bSCy Schubert return this.animate( props, speed, easing, callback ); 7889*7f2fe78bSCy Schubert }; 7890*7f2fe78bSCy Schubert} ); 7891*7f2fe78bSCy Schubert 7892*7f2fe78bSCy SchubertjQuery.timers = []; 7893*7f2fe78bSCy SchubertjQuery.fx.tick = function() { 7894*7f2fe78bSCy Schubert var timer, 7895*7f2fe78bSCy Schubert i = 0, 7896*7f2fe78bSCy Schubert timers = jQuery.timers; 7897*7f2fe78bSCy Schubert 7898*7f2fe78bSCy Schubert fxNow = Date.now(); 7899*7f2fe78bSCy Schubert 7900*7f2fe78bSCy Schubert for ( ; i < timers.length; i++ ) { 7901*7f2fe78bSCy Schubert timer = timers[ i ]; 7902*7f2fe78bSCy Schubert 7903*7f2fe78bSCy Schubert // Run the timer and safely remove it when done (allowing for external removal) 7904*7f2fe78bSCy Schubert if ( !timer() && timers[ i ] === timer ) { 7905*7f2fe78bSCy Schubert timers.splice( i--, 1 ); 7906*7f2fe78bSCy Schubert } 7907*7f2fe78bSCy Schubert } 7908*7f2fe78bSCy Schubert 7909*7f2fe78bSCy Schubert if ( !timers.length ) { 7910*7f2fe78bSCy Schubert jQuery.fx.stop(); 7911*7f2fe78bSCy Schubert } 7912*7f2fe78bSCy Schubert fxNow = undefined; 7913*7f2fe78bSCy Schubert}; 7914*7f2fe78bSCy Schubert 7915*7f2fe78bSCy SchubertjQuery.fx.timer = function( timer ) { 7916*7f2fe78bSCy Schubert jQuery.timers.push( timer ); 7917*7f2fe78bSCy Schubert jQuery.fx.start(); 7918*7f2fe78bSCy Schubert}; 7919*7f2fe78bSCy Schubert 7920*7f2fe78bSCy SchubertjQuery.fx.interval = 13; 7921*7f2fe78bSCy SchubertjQuery.fx.start = function() { 7922*7f2fe78bSCy Schubert if ( inProgress ) { 7923*7f2fe78bSCy Schubert return; 7924*7f2fe78bSCy Schubert } 7925*7f2fe78bSCy Schubert 7926*7f2fe78bSCy Schubert inProgress = true; 7927*7f2fe78bSCy Schubert schedule(); 7928*7f2fe78bSCy Schubert}; 7929*7f2fe78bSCy Schubert 7930*7f2fe78bSCy SchubertjQuery.fx.stop = function() { 7931*7f2fe78bSCy Schubert inProgress = null; 7932*7f2fe78bSCy Schubert}; 7933*7f2fe78bSCy Schubert 7934*7f2fe78bSCy SchubertjQuery.fx.speeds = { 7935*7f2fe78bSCy Schubert slow: 600, 7936*7f2fe78bSCy Schubert fast: 200, 7937*7f2fe78bSCy Schubert 7938*7f2fe78bSCy Schubert // Default speed 7939*7f2fe78bSCy Schubert _default: 400 7940*7f2fe78bSCy Schubert}; 7941*7f2fe78bSCy Schubert 7942*7f2fe78bSCy Schubert 7943*7f2fe78bSCy Schubert// Based off of the plugin by Clint Helfers, with permission. 7944*7f2fe78bSCy Schubert// https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/ 7945*7f2fe78bSCy SchubertjQuery.fn.delay = function( time, type ) { 7946*7f2fe78bSCy Schubert time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; 7947*7f2fe78bSCy Schubert type = type || "fx"; 7948*7f2fe78bSCy Schubert 7949*7f2fe78bSCy Schubert return this.queue( type, function( next, hooks ) { 7950*7f2fe78bSCy Schubert var timeout = window.setTimeout( next, time ); 7951*7f2fe78bSCy Schubert hooks.stop = function() { 7952*7f2fe78bSCy Schubert window.clearTimeout( timeout ); 7953*7f2fe78bSCy Schubert }; 7954*7f2fe78bSCy Schubert } ); 7955*7f2fe78bSCy Schubert}; 7956*7f2fe78bSCy Schubert 7957*7f2fe78bSCy Schubert 7958*7f2fe78bSCy Schubert( function() { 7959*7f2fe78bSCy Schubert var input = document.createElement( "input" ), 7960*7f2fe78bSCy Schubert select = document.createElement( "select" ), 7961*7f2fe78bSCy Schubert opt = select.appendChild( document.createElement( "option" ) ); 7962*7f2fe78bSCy Schubert 7963*7f2fe78bSCy Schubert input.type = "checkbox"; 7964*7f2fe78bSCy Schubert 7965*7f2fe78bSCy Schubert // Support: Android <=4.3 only 7966*7f2fe78bSCy Schubert // Default value for a checkbox should be "on" 7967*7f2fe78bSCy Schubert support.checkOn = input.value !== ""; 7968*7f2fe78bSCy Schubert 7969*7f2fe78bSCy Schubert // Support: IE <=11 only 7970*7f2fe78bSCy Schubert // Must access selectedIndex to make default options select 7971*7f2fe78bSCy Schubert support.optSelected = opt.selected; 7972*7f2fe78bSCy Schubert 7973*7f2fe78bSCy Schubert // Support: IE <=11 only 7974*7f2fe78bSCy Schubert // An input loses its value after becoming a radio 7975*7f2fe78bSCy Schubert input = document.createElement( "input" ); 7976*7f2fe78bSCy Schubert input.value = "t"; 7977*7f2fe78bSCy Schubert input.type = "radio"; 7978*7f2fe78bSCy Schubert support.radioValue = input.value === "t"; 7979*7f2fe78bSCy Schubert} )(); 7980*7f2fe78bSCy Schubert 7981*7f2fe78bSCy Schubert 7982*7f2fe78bSCy Schubertvar boolHook, 7983*7f2fe78bSCy Schubert attrHandle = jQuery.expr.attrHandle; 7984*7f2fe78bSCy Schubert 7985*7f2fe78bSCy SchubertjQuery.fn.extend( { 7986*7f2fe78bSCy Schubert attr: function( name, value ) { 7987*7f2fe78bSCy Schubert return access( this, jQuery.attr, name, value, arguments.length > 1 ); 7988*7f2fe78bSCy Schubert }, 7989*7f2fe78bSCy Schubert 7990*7f2fe78bSCy Schubert removeAttr: function( name ) { 7991*7f2fe78bSCy Schubert return this.each( function() { 7992*7f2fe78bSCy Schubert jQuery.removeAttr( this, name ); 7993*7f2fe78bSCy Schubert } ); 7994*7f2fe78bSCy Schubert } 7995*7f2fe78bSCy Schubert} ); 7996*7f2fe78bSCy Schubert 7997*7f2fe78bSCy SchubertjQuery.extend( { 7998*7f2fe78bSCy Schubert attr: function( elem, name, value ) { 7999*7f2fe78bSCy Schubert var ret, hooks, 8000*7f2fe78bSCy Schubert nType = elem.nodeType; 8001*7f2fe78bSCy Schubert 8002*7f2fe78bSCy Schubert // Don't get/set attributes on text, comment and attribute nodes 8003*7f2fe78bSCy Schubert if ( nType === 3 || nType === 8 || nType === 2 ) { 8004*7f2fe78bSCy Schubert return; 8005*7f2fe78bSCy Schubert } 8006*7f2fe78bSCy Schubert 8007*7f2fe78bSCy Schubert // Fallback to prop when attributes are not supported 8008*7f2fe78bSCy Schubert if ( typeof elem.getAttribute === "undefined" ) { 8009*7f2fe78bSCy Schubert return jQuery.prop( elem, name, value ); 8010*7f2fe78bSCy Schubert } 8011*7f2fe78bSCy Schubert 8012*7f2fe78bSCy Schubert // Attribute hooks are determined by the lowercase version 8013*7f2fe78bSCy Schubert // Grab necessary hook if one is defined 8014*7f2fe78bSCy Schubert if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { 8015*7f2fe78bSCy Schubert hooks = jQuery.attrHooks[ name.toLowerCase() ] || 8016*7f2fe78bSCy Schubert ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined ); 8017*7f2fe78bSCy Schubert } 8018*7f2fe78bSCy Schubert 8019*7f2fe78bSCy Schubert if ( value !== undefined ) { 8020*7f2fe78bSCy Schubert if ( value === null ) { 8021*7f2fe78bSCy Schubert jQuery.removeAttr( elem, name ); 8022*7f2fe78bSCy Schubert return; 8023*7f2fe78bSCy Schubert } 8024*7f2fe78bSCy Schubert 8025*7f2fe78bSCy Schubert if ( hooks && "set" in hooks && 8026*7f2fe78bSCy Schubert ( ret = hooks.set( elem, value, name ) ) !== undefined ) { 8027*7f2fe78bSCy Schubert return ret; 8028*7f2fe78bSCy Schubert } 8029*7f2fe78bSCy Schubert 8030*7f2fe78bSCy Schubert elem.setAttribute( name, value + "" ); 8031*7f2fe78bSCy Schubert return value; 8032*7f2fe78bSCy Schubert } 8033*7f2fe78bSCy Schubert 8034*7f2fe78bSCy Schubert if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) { 8035*7f2fe78bSCy Schubert return ret; 8036*7f2fe78bSCy Schubert } 8037*7f2fe78bSCy Schubert 8038*7f2fe78bSCy Schubert ret = jQuery.find.attr( elem, name ); 8039*7f2fe78bSCy Schubert 8040*7f2fe78bSCy Schubert // Non-existent attributes return null, we normalize to undefined 8041*7f2fe78bSCy Schubert return ret == null ? undefined : ret; 8042*7f2fe78bSCy Schubert }, 8043*7f2fe78bSCy Schubert 8044*7f2fe78bSCy Schubert attrHooks: { 8045*7f2fe78bSCy Schubert type: { 8046*7f2fe78bSCy Schubert set: function( elem, value ) { 8047*7f2fe78bSCy Schubert if ( !support.radioValue && value === "radio" && 8048*7f2fe78bSCy Schubert nodeName( elem, "input" ) ) { 8049*7f2fe78bSCy Schubert var val = elem.value; 8050*7f2fe78bSCy Schubert elem.setAttribute( "type", value ); 8051*7f2fe78bSCy Schubert if ( val ) { 8052*7f2fe78bSCy Schubert elem.value = val; 8053*7f2fe78bSCy Schubert } 8054*7f2fe78bSCy Schubert return value; 8055*7f2fe78bSCy Schubert } 8056*7f2fe78bSCy Schubert } 8057*7f2fe78bSCy Schubert } 8058*7f2fe78bSCy Schubert }, 8059*7f2fe78bSCy Schubert 8060*7f2fe78bSCy Schubert removeAttr: function( elem, value ) { 8061*7f2fe78bSCy Schubert var name, 8062*7f2fe78bSCy Schubert i = 0, 8063*7f2fe78bSCy Schubert 8064*7f2fe78bSCy Schubert // Attribute names can contain non-HTML whitespace characters 8065*7f2fe78bSCy Schubert // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2 8066*7f2fe78bSCy Schubert attrNames = value && value.match( rnothtmlwhite ); 8067*7f2fe78bSCy Schubert 8068*7f2fe78bSCy Schubert if ( attrNames && elem.nodeType === 1 ) { 8069*7f2fe78bSCy Schubert while ( ( name = attrNames[ i++ ] ) ) { 8070*7f2fe78bSCy Schubert elem.removeAttribute( name ); 8071*7f2fe78bSCy Schubert } 8072*7f2fe78bSCy Schubert } 8073*7f2fe78bSCy Schubert } 8074*7f2fe78bSCy Schubert} ); 8075*7f2fe78bSCy Schubert 8076*7f2fe78bSCy Schubert// Hooks for boolean attributes 8077*7f2fe78bSCy SchubertboolHook = { 8078*7f2fe78bSCy Schubert set: function( elem, value, name ) { 8079*7f2fe78bSCy Schubert if ( value === false ) { 8080*7f2fe78bSCy Schubert 8081*7f2fe78bSCy Schubert // Remove boolean attributes when set to false 8082*7f2fe78bSCy Schubert jQuery.removeAttr( elem, name ); 8083*7f2fe78bSCy Schubert } else { 8084*7f2fe78bSCy Schubert elem.setAttribute( name, name ); 8085*7f2fe78bSCy Schubert } 8086*7f2fe78bSCy Schubert return name; 8087*7f2fe78bSCy Schubert } 8088*7f2fe78bSCy Schubert}; 8089*7f2fe78bSCy Schubert 8090*7f2fe78bSCy SchubertjQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( _i, name ) { 8091*7f2fe78bSCy Schubert var getter = attrHandle[ name ] || jQuery.find.attr; 8092*7f2fe78bSCy Schubert 8093*7f2fe78bSCy Schubert attrHandle[ name ] = function( elem, name, isXML ) { 8094*7f2fe78bSCy Schubert var ret, handle, 8095*7f2fe78bSCy Schubert lowercaseName = name.toLowerCase(); 8096*7f2fe78bSCy Schubert 8097*7f2fe78bSCy Schubert if ( !isXML ) { 8098*7f2fe78bSCy Schubert 8099*7f2fe78bSCy Schubert // Avoid an infinite loop by temporarily removing this function from the getter 8100*7f2fe78bSCy Schubert handle = attrHandle[ lowercaseName ]; 8101*7f2fe78bSCy Schubert attrHandle[ lowercaseName ] = ret; 8102*7f2fe78bSCy Schubert ret = getter( elem, name, isXML ) != null ? 8103*7f2fe78bSCy Schubert lowercaseName : 8104*7f2fe78bSCy Schubert null; 8105*7f2fe78bSCy Schubert attrHandle[ lowercaseName ] = handle; 8106*7f2fe78bSCy Schubert } 8107*7f2fe78bSCy Schubert return ret; 8108*7f2fe78bSCy Schubert }; 8109*7f2fe78bSCy Schubert} ); 8110*7f2fe78bSCy Schubert 8111*7f2fe78bSCy Schubert 8112*7f2fe78bSCy Schubert 8113*7f2fe78bSCy Schubert 8114*7f2fe78bSCy Schubertvar rfocusable = /^(?:input|select|textarea|button)$/i, 8115*7f2fe78bSCy Schubert rclickable = /^(?:a|area)$/i; 8116*7f2fe78bSCy Schubert 8117*7f2fe78bSCy SchubertjQuery.fn.extend( { 8118*7f2fe78bSCy Schubert prop: function( name, value ) { 8119*7f2fe78bSCy Schubert return access( this, jQuery.prop, name, value, arguments.length > 1 ); 8120*7f2fe78bSCy Schubert }, 8121*7f2fe78bSCy Schubert 8122*7f2fe78bSCy Schubert removeProp: function( name ) { 8123*7f2fe78bSCy Schubert return this.each( function() { 8124*7f2fe78bSCy Schubert delete this[ jQuery.propFix[ name ] || name ]; 8125*7f2fe78bSCy Schubert } ); 8126*7f2fe78bSCy Schubert } 8127*7f2fe78bSCy Schubert} ); 8128*7f2fe78bSCy Schubert 8129*7f2fe78bSCy SchubertjQuery.extend( { 8130*7f2fe78bSCy Schubert prop: function( elem, name, value ) { 8131*7f2fe78bSCy Schubert var ret, hooks, 8132*7f2fe78bSCy Schubert nType = elem.nodeType; 8133*7f2fe78bSCy Schubert 8134*7f2fe78bSCy Schubert // Don't get/set properties on text, comment and attribute nodes 8135*7f2fe78bSCy Schubert if ( nType === 3 || nType === 8 || nType === 2 ) { 8136*7f2fe78bSCy Schubert return; 8137*7f2fe78bSCy Schubert } 8138*7f2fe78bSCy Schubert 8139*7f2fe78bSCy Schubert if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { 8140*7f2fe78bSCy Schubert 8141*7f2fe78bSCy Schubert // Fix name and attach hooks 8142*7f2fe78bSCy Schubert name = jQuery.propFix[ name ] || name; 8143*7f2fe78bSCy Schubert hooks = jQuery.propHooks[ name ]; 8144*7f2fe78bSCy Schubert } 8145*7f2fe78bSCy Schubert 8146*7f2fe78bSCy Schubert if ( value !== undefined ) { 8147*7f2fe78bSCy Schubert if ( hooks && "set" in hooks && 8148*7f2fe78bSCy Schubert ( ret = hooks.set( elem, value, name ) ) !== undefined ) { 8149*7f2fe78bSCy Schubert return ret; 8150*7f2fe78bSCy Schubert } 8151*7f2fe78bSCy Schubert 8152*7f2fe78bSCy Schubert return ( elem[ name ] = value ); 8153*7f2fe78bSCy Schubert } 8154*7f2fe78bSCy Schubert 8155*7f2fe78bSCy Schubert if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) { 8156*7f2fe78bSCy Schubert return ret; 8157*7f2fe78bSCy Schubert } 8158*7f2fe78bSCy Schubert 8159*7f2fe78bSCy Schubert return elem[ name ]; 8160*7f2fe78bSCy Schubert }, 8161*7f2fe78bSCy Schubert 8162*7f2fe78bSCy Schubert propHooks: { 8163*7f2fe78bSCy Schubert tabIndex: { 8164*7f2fe78bSCy Schubert get: function( elem ) { 8165*7f2fe78bSCy Schubert 8166*7f2fe78bSCy Schubert // Support: IE <=9 - 11 only 8167*7f2fe78bSCy Schubert // elem.tabIndex doesn't always return the 8168*7f2fe78bSCy Schubert // correct value when it hasn't been explicitly set 8169*7f2fe78bSCy Schubert // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ 8170*7f2fe78bSCy Schubert // Use proper attribute retrieval(#12072) 8171*7f2fe78bSCy Schubert var tabindex = jQuery.find.attr( elem, "tabindex" ); 8172*7f2fe78bSCy Schubert 8173*7f2fe78bSCy Schubert if ( tabindex ) { 8174*7f2fe78bSCy Schubert return parseInt( tabindex, 10 ); 8175*7f2fe78bSCy Schubert } 8176*7f2fe78bSCy Schubert 8177*7f2fe78bSCy Schubert if ( 8178*7f2fe78bSCy Schubert rfocusable.test( elem.nodeName ) || 8179*7f2fe78bSCy Schubert rclickable.test( elem.nodeName ) && 8180*7f2fe78bSCy Schubert elem.href 8181*7f2fe78bSCy Schubert ) { 8182*7f2fe78bSCy Schubert return 0; 8183*7f2fe78bSCy Schubert } 8184*7f2fe78bSCy Schubert 8185*7f2fe78bSCy Schubert return -1; 8186*7f2fe78bSCy Schubert } 8187*7f2fe78bSCy Schubert } 8188*7f2fe78bSCy Schubert }, 8189*7f2fe78bSCy Schubert 8190*7f2fe78bSCy Schubert propFix: { 8191*7f2fe78bSCy Schubert "for": "htmlFor", 8192*7f2fe78bSCy Schubert "class": "className" 8193*7f2fe78bSCy Schubert } 8194*7f2fe78bSCy Schubert} ); 8195*7f2fe78bSCy Schubert 8196*7f2fe78bSCy Schubert// Support: IE <=11 only 8197*7f2fe78bSCy Schubert// Accessing the selectedIndex property 8198*7f2fe78bSCy Schubert// forces the browser to respect setting selected 8199*7f2fe78bSCy Schubert// on the option 8200*7f2fe78bSCy Schubert// The getter ensures a default option is selected 8201*7f2fe78bSCy Schubert// when in an optgroup 8202*7f2fe78bSCy Schubert// eslint rule "no-unused-expressions" is disabled for this code 8203*7f2fe78bSCy Schubert// since it considers such accessions noop 8204*7f2fe78bSCy Schubertif ( !support.optSelected ) { 8205*7f2fe78bSCy Schubert jQuery.propHooks.selected = { 8206*7f2fe78bSCy Schubert get: function( elem ) { 8207*7f2fe78bSCy Schubert 8208*7f2fe78bSCy Schubert /* eslint no-unused-expressions: "off" */ 8209*7f2fe78bSCy Schubert 8210*7f2fe78bSCy Schubert var parent = elem.parentNode; 8211*7f2fe78bSCy Schubert if ( parent && parent.parentNode ) { 8212*7f2fe78bSCy Schubert parent.parentNode.selectedIndex; 8213*7f2fe78bSCy Schubert } 8214*7f2fe78bSCy Schubert return null; 8215*7f2fe78bSCy Schubert }, 8216*7f2fe78bSCy Schubert set: function( elem ) { 8217*7f2fe78bSCy Schubert 8218*7f2fe78bSCy Schubert /* eslint no-unused-expressions: "off" */ 8219*7f2fe78bSCy Schubert 8220*7f2fe78bSCy Schubert var parent = elem.parentNode; 8221*7f2fe78bSCy Schubert if ( parent ) { 8222*7f2fe78bSCy Schubert parent.selectedIndex; 8223*7f2fe78bSCy Schubert 8224*7f2fe78bSCy Schubert if ( parent.parentNode ) { 8225*7f2fe78bSCy Schubert parent.parentNode.selectedIndex; 8226*7f2fe78bSCy Schubert } 8227*7f2fe78bSCy Schubert } 8228*7f2fe78bSCy Schubert } 8229*7f2fe78bSCy Schubert }; 8230*7f2fe78bSCy Schubert} 8231*7f2fe78bSCy Schubert 8232*7f2fe78bSCy SchubertjQuery.each( [ 8233*7f2fe78bSCy Schubert "tabIndex", 8234*7f2fe78bSCy Schubert "readOnly", 8235*7f2fe78bSCy Schubert "maxLength", 8236*7f2fe78bSCy Schubert "cellSpacing", 8237*7f2fe78bSCy Schubert "cellPadding", 8238*7f2fe78bSCy Schubert "rowSpan", 8239*7f2fe78bSCy Schubert "colSpan", 8240*7f2fe78bSCy Schubert "useMap", 8241*7f2fe78bSCy Schubert "frameBorder", 8242*7f2fe78bSCy Schubert "contentEditable" 8243*7f2fe78bSCy Schubert], function() { 8244*7f2fe78bSCy Schubert jQuery.propFix[ this.toLowerCase() ] = this; 8245*7f2fe78bSCy Schubert} ); 8246*7f2fe78bSCy Schubert 8247*7f2fe78bSCy Schubert 8248*7f2fe78bSCy Schubert 8249*7f2fe78bSCy Schubert 8250*7f2fe78bSCy Schubert // Strip and collapse whitespace according to HTML spec 8251*7f2fe78bSCy Schubert // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace 8252*7f2fe78bSCy Schubert function stripAndCollapse( value ) { 8253*7f2fe78bSCy Schubert var tokens = value.match( rnothtmlwhite ) || []; 8254*7f2fe78bSCy Schubert return tokens.join( " " ); 8255*7f2fe78bSCy Schubert } 8256*7f2fe78bSCy Schubert 8257*7f2fe78bSCy Schubert 8258*7f2fe78bSCy Schubertfunction getClass( elem ) { 8259*7f2fe78bSCy Schubert return elem.getAttribute && elem.getAttribute( "class" ) || ""; 8260*7f2fe78bSCy Schubert} 8261*7f2fe78bSCy Schubert 8262*7f2fe78bSCy Schubertfunction classesToArray( value ) { 8263*7f2fe78bSCy Schubert if ( Array.isArray( value ) ) { 8264*7f2fe78bSCy Schubert return value; 8265*7f2fe78bSCy Schubert } 8266*7f2fe78bSCy Schubert if ( typeof value === "string" ) { 8267*7f2fe78bSCy Schubert return value.match( rnothtmlwhite ) || []; 8268*7f2fe78bSCy Schubert } 8269*7f2fe78bSCy Schubert return []; 8270*7f2fe78bSCy Schubert} 8271*7f2fe78bSCy Schubert 8272*7f2fe78bSCy SchubertjQuery.fn.extend( { 8273*7f2fe78bSCy Schubert addClass: function( value ) { 8274*7f2fe78bSCy Schubert var classes, elem, cur, curValue, clazz, j, finalValue, 8275*7f2fe78bSCy Schubert i = 0; 8276*7f2fe78bSCy Schubert 8277*7f2fe78bSCy Schubert if ( isFunction( value ) ) { 8278*7f2fe78bSCy Schubert return this.each( function( j ) { 8279*7f2fe78bSCy Schubert jQuery( this ).addClass( value.call( this, j, getClass( this ) ) ); 8280*7f2fe78bSCy Schubert } ); 8281*7f2fe78bSCy Schubert } 8282*7f2fe78bSCy Schubert 8283*7f2fe78bSCy Schubert classes = classesToArray( value ); 8284*7f2fe78bSCy Schubert 8285*7f2fe78bSCy Schubert if ( classes.length ) { 8286*7f2fe78bSCy Schubert while ( ( elem = this[ i++ ] ) ) { 8287*7f2fe78bSCy Schubert curValue = getClass( elem ); 8288*7f2fe78bSCy Schubert cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " ); 8289*7f2fe78bSCy Schubert 8290*7f2fe78bSCy Schubert if ( cur ) { 8291*7f2fe78bSCy Schubert j = 0; 8292*7f2fe78bSCy Schubert while ( ( clazz = classes[ j++ ] ) ) { 8293*7f2fe78bSCy Schubert if ( cur.indexOf( " " + clazz + " " ) < 0 ) { 8294*7f2fe78bSCy Schubert cur += clazz + " "; 8295*7f2fe78bSCy Schubert } 8296*7f2fe78bSCy Schubert } 8297*7f2fe78bSCy Schubert 8298*7f2fe78bSCy Schubert // Only assign if different to avoid unneeded rendering. 8299*7f2fe78bSCy Schubert finalValue = stripAndCollapse( cur ); 8300*7f2fe78bSCy Schubert if ( curValue !== finalValue ) { 8301*7f2fe78bSCy Schubert elem.setAttribute( "class", finalValue ); 8302*7f2fe78bSCy Schubert } 8303*7f2fe78bSCy Schubert } 8304*7f2fe78bSCy Schubert } 8305*7f2fe78bSCy Schubert } 8306*7f2fe78bSCy Schubert 8307*7f2fe78bSCy Schubert return this; 8308*7f2fe78bSCy Schubert }, 8309*7f2fe78bSCy Schubert 8310*7f2fe78bSCy Schubert removeClass: function( value ) { 8311*7f2fe78bSCy Schubert var classes, elem, cur, curValue, clazz, j, finalValue, 8312*7f2fe78bSCy Schubert i = 0; 8313*7f2fe78bSCy Schubert 8314*7f2fe78bSCy Schubert if ( isFunction( value ) ) { 8315*7f2fe78bSCy Schubert return this.each( function( j ) { 8316*7f2fe78bSCy Schubert jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) ); 8317*7f2fe78bSCy Schubert } ); 8318*7f2fe78bSCy Schubert } 8319*7f2fe78bSCy Schubert 8320*7f2fe78bSCy Schubert if ( !arguments.length ) { 8321*7f2fe78bSCy Schubert return this.attr( "class", "" ); 8322*7f2fe78bSCy Schubert } 8323*7f2fe78bSCy Schubert 8324*7f2fe78bSCy Schubert classes = classesToArray( value ); 8325*7f2fe78bSCy Schubert 8326*7f2fe78bSCy Schubert if ( classes.length ) { 8327*7f2fe78bSCy Schubert while ( ( elem = this[ i++ ] ) ) { 8328*7f2fe78bSCy Schubert curValue = getClass( elem ); 8329*7f2fe78bSCy Schubert 8330*7f2fe78bSCy Schubert // This expression is here for better compressibility (see addClass) 8331*7f2fe78bSCy Schubert cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " ); 8332*7f2fe78bSCy Schubert 8333*7f2fe78bSCy Schubert if ( cur ) { 8334*7f2fe78bSCy Schubert j = 0; 8335*7f2fe78bSCy Schubert while ( ( clazz = classes[ j++ ] ) ) { 8336*7f2fe78bSCy Schubert 8337*7f2fe78bSCy Schubert // Remove *all* instances 8338*7f2fe78bSCy Schubert while ( cur.indexOf( " " + clazz + " " ) > -1 ) { 8339*7f2fe78bSCy Schubert cur = cur.replace( " " + clazz + " ", " " ); 8340*7f2fe78bSCy Schubert } 8341*7f2fe78bSCy Schubert } 8342*7f2fe78bSCy Schubert 8343*7f2fe78bSCy Schubert // Only assign if different to avoid unneeded rendering. 8344*7f2fe78bSCy Schubert finalValue = stripAndCollapse( cur ); 8345*7f2fe78bSCy Schubert if ( curValue !== finalValue ) { 8346*7f2fe78bSCy Schubert elem.setAttribute( "class", finalValue ); 8347*7f2fe78bSCy Schubert } 8348*7f2fe78bSCy Schubert } 8349*7f2fe78bSCy Schubert } 8350*7f2fe78bSCy Schubert } 8351*7f2fe78bSCy Schubert 8352*7f2fe78bSCy Schubert return this; 8353*7f2fe78bSCy Schubert }, 8354*7f2fe78bSCy Schubert 8355*7f2fe78bSCy Schubert toggleClass: function( value, stateVal ) { 8356*7f2fe78bSCy Schubert var type = typeof value, 8357*7f2fe78bSCy Schubert isValidValue = type === "string" || Array.isArray( value ); 8358*7f2fe78bSCy Schubert 8359*7f2fe78bSCy Schubert if ( typeof stateVal === "boolean" && isValidValue ) { 8360*7f2fe78bSCy Schubert return stateVal ? this.addClass( value ) : this.removeClass( value ); 8361*7f2fe78bSCy Schubert } 8362*7f2fe78bSCy Schubert 8363*7f2fe78bSCy Schubert if ( isFunction( value ) ) { 8364*7f2fe78bSCy Schubert return this.each( function( i ) { 8365*7f2fe78bSCy Schubert jQuery( this ).toggleClass( 8366*7f2fe78bSCy Schubert value.call( this, i, getClass( this ), stateVal ), 8367*7f2fe78bSCy Schubert stateVal 8368*7f2fe78bSCy Schubert ); 8369*7f2fe78bSCy Schubert } ); 8370*7f2fe78bSCy Schubert } 8371*7f2fe78bSCy Schubert 8372*7f2fe78bSCy Schubert return this.each( function() { 8373*7f2fe78bSCy Schubert var className, i, self, classNames; 8374*7f2fe78bSCy Schubert 8375*7f2fe78bSCy Schubert if ( isValidValue ) { 8376*7f2fe78bSCy Schubert 8377*7f2fe78bSCy Schubert // Toggle individual class names 8378*7f2fe78bSCy Schubert i = 0; 8379*7f2fe78bSCy Schubert self = jQuery( this ); 8380*7f2fe78bSCy Schubert classNames = classesToArray( value ); 8381*7f2fe78bSCy Schubert 8382*7f2fe78bSCy Schubert while ( ( className = classNames[ i++ ] ) ) { 8383*7f2fe78bSCy Schubert 8384*7f2fe78bSCy Schubert // Check each className given, space separated list 8385*7f2fe78bSCy Schubert if ( self.hasClass( className ) ) { 8386*7f2fe78bSCy Schubert self.removeClass( className ); 8387*7f2fe78bSCy Schubert } else { 8388*7f2fe78bSCy Schubert self.addClass( className ); 8389*7f2fe78bSCy Schubert } 8390*7f2fe78bSCy Schubert } 8391*7f2fe78bSCy Schubert 8392*7f2fe78bSCy Schubert // Toggle whole class name 8393*7f2fe78bSCy Schubert } else if ( value === undefined || type === "boolean" ) { 8394*7f2fe78bSCy Schubert className = getClass( this ); 8395*7f2fe78bSCy Schubert if ( className ) { 8396*7f2fe78bSCy Schubert 8397*7f2fe78bSCy Schubert // Store className if set 8398*7f2fe78bSCy Schubert dataPriv.set( this, "__className__", className ); 8399*7f2fe78bSCy Schubert } 8400*7f2fe78bSCy Schubert 8401*7f2fe78bSCy Schubert // If the element has a class name or if we're passed `false`, 8402*7f2fe78bSCy Schubert // then remove the whole classname (if there was one, the above saved it). 8403*7f2fe78bSCy Schubert // Otherwise bring back whatever was previously saved (if anything), 8404*7f2fe78bSCy Schubert // falling back to the empty string if nothing was stored. 8405*7f2fe78bSCy Schubert if ( this.setAttribute ) { 8406*7f2fe78bSCy Schubert this.setAttribute( "class", 8407*7f2fe78bSCy Schubert className || value === false ? 8408*7f2fe78bSCy Schubert "" : 8409*7f2fe78bSCy Schubert dataPriv.get( this, "__className__" ) || "" 8410*7f2fe78bSCy Schubert ); 8411*7f2fe78bSCy Schubert } 8412*7f2fe78bSCy Schubert } 8413*7f2fe78bSCy Schubert } ); 8414*7f2fe78bSCy Schubert }, 8415*7f2fe78bSCy Schubert 8416*7f2fe78bSCy Schubert hasClass: function( selector ) { 8417*7f2fe78bSCy Schubert var className, elem, 8418*7f2fe78bSCy Schubert i = 0; 8419*7f2fe78bSCy Schubert 8420*7f2fe78bSCy Schubert className = " " + selector + " "; 8421*7f2fe78bSCy Schubert while ( ( elem = this[ i++ ] ) ) { 8422*7f2fe78bSCy Schubert if ( elem.nodeType === 1 && 8423*7f2fe78bSCy Schubert ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) { 8424*7f2fe78bSCy Schubert return true; 8425*7f2fe78bSCy Schubert } 8426*7f2fe78bSCy Schubert } 8427*7f2fe78bSCy Schubert 8428*7f2fe78bSCy Schubert return false; 8429*7f2fe78bSCy Schubert } 8430*7f2fe78bSCy Schubert} ); 8431*7f2fe78bSCy Schubert 8432*7f2fe78bSCy Schubert 8433*7f2fe78bSCy Schubert 8434*7f2fe78bSCy Schubert 8435*7f2fe78bSCy Schubertvar rreturn = /\r/g; 8436*7f2fe78bSCy Schubert 8437*7f2fe78bSCy SchubertjQuery.fn.extend( { 8438*7f2fe78bSCy Schubert val: function( value ) { 8439*7f2fe78bSCy Schubert var hooks, ret, valueIsFunction, 8440*7f2fe78bSCy Schubert elem = this[ 0 ]; 8441*7f2fe78bSCy Schubert 8442*7f2fe78bSCy Schubert if ( !arguments.length ) { 8443*7f2fe78bSCy Schubert if ( elem ) { 8444*7f2fe78bSCy Schubert hooks = jQuery.valHooks[ elem.type ] || 8445*7f2fe78bSCy Schubert jQuery.valHooks[ elem.nodeName.toLowerCase() ]; 8446*7f2fe78bSCy Schubert 8447*7f2fe78bSCy Schubert if ( hooks && 8448*7f2fe78bSCy Schubert "get" in hooks && 8449*7f2fe78bSCy Schubert ( ret = hooks.get( elem, "value" ) ) !== undefined 8450*7f2fe78bSCy Schubert ) { 8451*7f2fe78bSCy Schubert return ret; 8452*7f2fe78bSCy Schubert } 8453*7f2fe78bSCy Schubert 8454*7f2fe78bSCy Schubert ret = elem.value; 8455*7f2fe78bSCy Schubert 8456*7f2fe78bSCy Schubert // Handle most common string cases 8457*7f2fe78bSCy Schubert if ( typeof ret === "string" ) { 8458*7f2fe78bSCy Schubert return ret.replace( rreturn, "" ); 8459*7f2fe78bSCy Schubert } 8460*7f2fe78bSCy Schubert 8461*7f2fe78bSCy Schubert // Handle cases where value is null/undef or number 8462*7f2fe78bSCy Schubert return ret == null ? "" : ret; 8463*7f2fe78bSCy Schubert } 8464*7f2fe78bSCy Schubert 8465*7f2fe78bSCy Schubert return; 8466*7f2fe78bSCy Schubert } 8467*7f2fe78bSCy Schubert 8468*7f2fe78bSCy Schubert valueIsFunction = isFunction( value ); 8469*7f2fe78bSCy Schubert 8470*7f2fe78bSCy Schubert return this.each( function( i ) { 8471*7f2fe78bSCy Schubert var val; 8472*7f2fe78bSCy Schubert 8473*7f2fe78bSCy Schubert if ( this.nodeType !== 1 ) { 8474*7f2fe78bSCy Schubert return; 8475*7f2fe78bSCy Schubert } 8476*7f2fe78bSCy Schubert 8477*7f2fe78bSCy Schubert if ( valueIsFunction ) { 8478*7f2fe78bSCy Schubert val = value.call( this, i, jQuery( this ).val() ); 8479*7f2fe78bSCy Schubert } else { 8480*7f2fe78bSCy Schubert val = value; 8481*7f2fe78bSCy Schubert } 8482*7f2fe78bSCy Schubert 8483*7f2fe78bSCy Schubert // Treat null/undefined as ""; convert numbers to string 8484*7f2fe78bSCy Schubert if ( val == null ) { 8485*7f2fe78bSCy Schubert val = ""; 8486*7f2fe78bSCy Schubert 8487*7f2fe78bSCy Schubert } else if ( typeof val === "number" ) { 8488*7f2fe78bSCy Schubert val += ""; 8489*7f2fe78bSCy Schubert 8490*7f2fe78bSCy Schubert } else if ( Array.isArray( val ) ) { 8491*7f2fe78bSCy Schubert val = jQuery.map( val, function( value ) { 8492*7f2fe78bSCy Schubert return value == null ? "" : value + ""; 8493*7f2fe78bSCy Schubert } ); 8494*7f2fe78bSCy Schubert } 8495*7f2fe78bSCy Schubert 8496*7f2fe78bSCy Schubert hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; 8497*7f2fe78bSCy Schubert 8498*7f2fe78bSCy Schubert // If set returns undefined, fall back to normal setting 8499*7f2fe78bSCy Schubert if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) { 8500*7f2fe78bSCy Schubert this.value = val; 8501*7f2fe78bSCy Schubert } 8502*7f2fe78bSCy Schubert } ); 8503*7f2fe78bSCy Schubert } 8504*7f2fe78bSCy Schubert} ); 8505*7f2fe78bSCy Schubert 8506*7f2fe78bSCy SchubertjQuery.extend( { 8507*7f2fe78bSCy Schubert valHooks: { 8508*7f2fe78bSCy Schubert option: { 8509*7f2fe78bSCy Schubert get: function( elem ) { 8510*7f2fe78bSCy Schubert 8511*7f2fe78bSCy Schubert var val = jQuery.find.attr( elem, "value" ); 8512*7f2fe78bSCy Schubert return val != null ? 8513*7f2fe78bSCy Schubert val : 8514*7f2fe78bSCy Schubert 8515*7f2fe78bSCy Schubert // Support: IE <=10 - 11 only 8516*7f2fe78bSCy Schubert // option.text throws exceptions (#14686, #14858) 8517*7f2fe78bSCy Schubert // Strip and collapse whitespace 8518*7f2fe78bSCy Schubert // https://html.spec.whatwg.org/#strip-and-collapse-whitespace 8519*7f2fe78bSCy Schubert stripAndCollapse( jQuery.text( elem ) ); 8520*7f2fe78bSCy Schubert } 8521*7f2fe78bSCy Schubert }, 8522*7f2fe78bSCy Schubert select: { 8523*7f2fe78bSCy Schubert get: function( elem ) { 8524*7f2fe78bSCy Schubert var value, option, i, 8525*7f2fe78bSCy Schubert options = elem.options, 8526*7f2fe78bSCy Schubert index = elem.selectedIndex, 8527*7f2fe78bSCy Schubert one = elem.type === "select-one", 8528*7f2fe78bSCy Schubert values = one ? null : [], 8529*7f2fe78bSCy Schubert max = one ? index + 1 : options.length; 8530*7f2fe78bSCy Schubert 8531*7f2fe78bSCy Schubert if ( index < 0 ) { 8532*7f2fe78bSCy Schubert i = max; 8533*7f2fe78bSCy Schubert 8534*7f2fe78bSCy Schubert } else { 8535*7f2fe78bSCy Schubert i = one ? index : 0; 8536*7f2fe78bSCy Schubert } 8537*7f2fe78bSCy Schubert 8538*7f2fe78bSCy Schubert // Loop through all the selected options 8539*7f2fe78bSCy Schubert for ( ; i < max; i++ ) { 8540*7f2fe78bSCy Schubert option = options[ i ]; 8541*7f2fe78bSCy Schubert 8542*7f2fe78bSCy Schubert // Support: IE <=9 only 8543*7f2fe78bSCy Schubert // IE8-9 doesn't update selected after form reset (#2551) 8544*7f2fe78bSCy Schubert if ( ( option.selected || i === index ) && 8545*7f2fe78bSCy Schubert 8546*7f2fe78bSCy Schubert // Don't return options that are disabled or in a disabled optgroup 8547*7f2fe78bSCy Schubert !option.disabled && 8548*7f2fe78bSCy Schubert ( !option.parentNode.disabled || 8549*7f2fe78bSCy Schubert !nodeName( option.parentNode, "optgroup" ) ) ) { 8550*7f2fe78bSCy Schubert 8551*7f2fe78bSCy Schubert // Get the specific value for the option 8552*7f2fe78bSCy Schubert value = jQuery( option ).val(); 8553*7f2fe78bSCy Schubert 8554*7f2fe78bSCy Schubert // We don't need an array for one selects 8555*7f2fe78bSCy Schubert if ( one ) { 8556*7f2fe78bSCy Schubert return value; 8557*7f2fe78bSCy Schubert } 8558*7f2fe78bSCy Schubert 8559*7f2fe78bSCy Schubert // Multi-Selects return an array 8560*7f2fe78bSCy Schubert values.push( value ); 8561*7f2fe78bSCy Schubert } 8562*7f2fe78bSCy Schubert } 8563*7f2fe78bSCy Schubert 8564*7f2fe78bSCy Schubert return values; 8565*7f2fe78bSCy Schubert }, 8566*7f2fe78bSCy Schubert 8567*7f2fe78bSCy Schubert set: function( elem, value ) { 8568*7f2fe78bSCy Schubert var optionSet, option, 8569*7f2fe78bSCy Schubert options = elem.options, 8570*7f2fe78bSCy Schubert values = jQuery.makeArray( value ), 8571*7f2fe78bSCy Schubert i = options.length; 8572*7f2fe78bSCy Schubert 8573*7f2fe78bSCy Schubert while ( i-- ) { 8574*7f2fe78bSCy Schubert option = options[ i ]; 8575*7f2fe78bSCy Schubert 8576*7f2fe78bSCy Schubert /* eslint-disable no-cond-assign */ 8577*7f2fe78bSCy Schubert 8578*7f2fe78bSCy Schubert if ( option.selected = 8579*7f2fe78bSCy Schubert jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1 8580*7f2fe78bSCy Schubert ) { 8581*7f2fe78bSCy Schubert optionSet = true; 8582*7f2fe78bSCy Schubert } 8583*7f2fe78bSCy Schubert 8584*7f2fe78bSCy Schubert /* eslint-enable no-cond-assign */ 8585*7f2fe78bSCy Schubert } 8586*7f2fe78bSCy Schubert 8587*7f2fe78bSCy Schubert // Force browsers to behave consistently when non-matching value is set 8588*7f2fe78bSCy Schubert if ( !optionSet ) { 8589*7f2fe78bSCy Schubert elem.selectedIndex = -1; 8590*7f2fe78bSCy Schubert } 8591*7f2fe78bSCy Schubert return values; 8592*7f2fe78bSCy Schubert } 8593*7f2fe78bSCy Schubert } 8594*7f2fe78bSCy Schubert } 8595*7f2fe78bSCy Schubert} ); 8596*7f2fe78bSCy Schubert 8597*7f2fe78bSCy Schubert// Radios and checkboxes getter/setter 8598*7f2fe78bSCy SchubertjQuery.each( [ "radio", "checkbox" ], function() { 8599*7f2fe78bSCy Schubert jQuery.valHooks[ this ] = { 8600*7f2fe78bSCy Schubert set: function( elem, value ) { 8601*7f2fe78bSCy Schubert if ( Array.isArray( value ) ) { 8602*7f2fe78bSCy Schubert return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 ); 8603*7f2fe78bSCy Schubert } 8604*7f2fe78bSCy Schubert } 8605*7f2fe78bSCy Schubert }; 8606*7f2fe78bSCy Schubert if ( !support.checkOn ) { 8607*7f2fe78bSCy Schubert jQuery.valHooks[ this ].get = function( elem ) { 8608*7f2fe78bSCy Schubert return elem.getAttribute( "value" ) === null ? "on" : elem.value; 8609*7f2fe78bSCy Schubert }; 8610*7f2fe78bSCy Schubert } 8611*7f2fe78bSCy Schubert} ); 8612*7f2fe78bSCy Schubert 8613*7f2fe78bSCy Schubert 8614*7f2fe78bSCy Schubert 8615*7f2fe78bSCy Schubert 8616*7f2fe78bSCy Schubert// Return jQuery for attributes-only inclusion 8617*7f2fe78bSCy Schubert 8618*7f2fe78bSCy Schubert 8619*7f2fe78bSCy Schubertsupport.focusin = "onfocusin" in window; 8620*7f2fe78bSCy Schubert 8621*7f2fe78bSCy Schubert 8622*7f2fe78bSCy Schubertvar rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, 8623*7f2fe78bSCy Schubert stopPropagationCallback = function( e ) { 8624*7f2fe78bSCy Schubert e.stopPropagation(); 8625*7f2fe78bSCy Schubert }; 8626*7f2fe78bSCy Schubert 8627*7f2fe78bSCy SchubertjQuery.extend( jQuery.event, { 8628*7f2fe78bSCy Schubert 8629*7f2fe78bSCy Schubert trigger: function( event, data, elem, onlyHandlers ) { 8630*7f2fe78bSCy Schubert 8631*7f2fe78bSCy Schubert var i, cur, tmp, bubbleType, ontype, handle, special, lastElement, 8632*7f2fe78bSCy Schubert eventPath = [ elem || document ], 8633*7f2fe78bSCy Schubert type = hasOwn.call( event, "type" ) ? event.type : event, 8634*7f2fe78bSCy Schubert namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : []; 8635*7f2fe78bSCy Schubert 8636*7f2fe78bSCy Schubert cur = lastElement = tmp = elem = elem || document; 8637*7f2fe78bSCy Schubert 8638*7f2fe78bSCy Schubert // Don't do events on text and comment nodes 8639*7f2fe78bSCy Schubert if ( elem.nodeType === 3 || elem.nodeType === 8 ) { 8640*7f2fe78bSCy Schubert return; 8641*7f2fe78bSCy Schubert } 8642*7f2fe78bSCy Schubert 8643*7f2fe78bSCy Schubert // focus/blur morphs to focusin/out; ensure we're not firing them right now 8644*7f2fe78bSCy Schubert if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { 8645*7f2fe78bSCy Schubert return; 8646*7f2fe78bSCy Schubert } 8647*7f2fe78bSCy Schubert 8648*7f2fe78bSCy Schubert if ( type.indexOf( "." ) > -1 ) { 8649*7f2fe78bSCy Schubert 8650*7f2fe78bSCy Schubert // Namespaced trigger; create a regexp to match event type in handle() 8651*7f2fe78bSCy Schubert namespaces = type.split( "." ); 8652*7f2fe78bSCy Schubert type = namespaces.shift(); 8653*7f2fe78bSCy Schubert namespaces.sort(); 8654*7f2fe78bSCy Schubert } 8655*7f2fe78bSCy Schubert ontype = type.indexOf( ":" ) < 0 && "on" + type; 8656*7f2fe78bSCy Schubert 8657*7f2fe78bSCy Schubert // Caller can pass in a jQuery.Event object, Object, or just an event type string 8658*7f2fe78bSCy Schubert event = event[ jQuery.expando ] ? 8659*7f2fe78bSCy Schubert event : 8660*7f2fe78bSCy Schubert new jQuery.Event( type, typeof event === "object" && event ); 8661*7f2fe78bSCy Schubert 8662*7f2fe78bSCy Schubert // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true) 8663*7f2fe78bSCy Schubert event.isTrigger = onlyHandlers ? 2 : 3; 8664*7f2fe78bSCy Schubert event.namespace = namespaces.join( "." ); 8665*7f2fe78bSCy Schubert event.rnamespace = event.namespace ? 8666*7f2fe78bSCy Schubert new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) : 8667*7f2fe78bSCy Schubert null; 8668*7f2fe78bSCy Schubert 8669*7f2fe78bSCy Schubert // Clean up the event in case it is being reused 8670*7f2fe78bSCy Schubert event.result = undefined; 8671*7f2fe78bSCy Schubert if ( !event.target ) { 8672*7f2fe78bSCy Schubert event.target = elem; 8673*7f2fe78bSCy Schubert } 8674*7f2fe78bSCy Schubert 8675*7f2fe78bSCy Schubert // Clone any incoming data and prepend the event, creating the handler arg list 8676*7f2fe78bSCy Schubert data = data == null ? 8677*7f2fe78bSCy Schubert [ event ] : 8678*7f2fe78bSCy Schubert jQuery.makeArray( data, [ event ] ); 8679*7f2fe78bSCy Schubert 8680*7f2fe78bSCy Schubert // Allow special events to draw outside the lines 8681*7f2fe78bSCy Schubert special = jQuery.event.special[ type ] || {}; 8682*7f2fe78bSCy Schubert if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) { 8683*7f2fe78bSCy Schubert return; 8684*7f2fe78bSCy Schubert } 8685*7f2fe78bSCy Schubert 8686*7f2fe78bSCy Schubert // Determine event propagation path in advance, per W3C events spec (#9951) 8687*7f2fe78bSCy Schubert // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) 8688*7f2fe78bSCy Schubert if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) { 8689*7f2fe78bSCy Schubert 8690*7f2fe78bSCy Schubert bubbleType = special.delegateType || type; 8691*7f2fe78bSCy Schubert if ( !rfocusMorph.test( bubbleType + type ) ) { 8692*7f2fe78bSCy Schubert cur = cur.parentNode; 8693*7f2fe78bSCy Schubert } 8694*7f2fe78bSCy Schubert for ( ; cur; cur = cur.parentNode ) { 8695*7f2fe78bSCy Schubert eventPath.push( cur ); 8696*7f2fe78bSCy Schubert tmp = cur; 8697*7f2fe78bSCy Schubert } 8698*7f2fe78bSCy Schubert 8699*7f2fe78bSCy Schubert // Only add window if we got to document (e.g., not plain obj or detached DOM) 8700*7f2fe78bSCy Schubert if ( tmp === ( elem.ownerDocument || document ) ) { 8701*7f2fe78bSCy Schubert eventPath.push( tmp.defaultView || tmp.parentWindow || window ); 8702*7f2fe78bSCy Schubert } 8703*7f2fe78bSCy Schubert } 8704*7f2fe78bSCy Schubert 8705*7f2fe78bSCy Schubert // Fire handlers on the event path 8706*7f2fe78bSCy Schubert i = 0; 8707*7f2fe78bSCy Schubert while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) { 8708*7f2fe78bSCy Schubert lastElement = cur; 8709*7f2fe78bSCy Schubert event.type = i > 1 ? 8710*7f2fe78bSCy Schubert bubbleType : 8711*7f2fe78bSCy Schubert special.bindType || type; 8712*7f2fe78bSCy Schubert 8713*7f2fe78bSCy Schubert // jQuery handler 8714*7f2fe78bSCy Schubert handle = ( dataPriv.get( cur, "events" ) || Object.create( null ) )[ event.type ] && 8715*7f2fe78bSCy Schubert dataPriv.get( cur, "handle" ); 8716*7f2fe78bSCy Schubert if ( handle ) { 8717*7f2fe78bSCy Schubert handle.apply( cur, data ); 8718*7f2fe78bSCy Schubert } 8719*7f2fe78bSCy Schubert 8720*7f2fe78bSCy Schubert // Native handler 8721*7f2fe78bSCy Schubert handle = ontype && cur[ ontype ]; 8722*7f2fe78bSCy Schubert if ( handle && handle.apply && acceptData( cur ) ) { 8723*7f2fe78bSCy Schubert event.result = handle.apply( cur, data ); 8724*7f2fe78bSCy Schubert if ( event.result === false ) { 8725*7f2fe78bSCy Schubert event.preventDefault(); 8726*7f2fe78bSCy Schubert } 8727*7f2fe78bSCy Schubert } 8728*7f2fe78bSCy Schubert } 8729*7f2fe78bSCy Schubert event.type = type; 8730*7f2fe78bSCy Schubert 8731*7f2fe78bSCy Schubert // If nobody prevented the default action, do it now 8732*7f2fe78bSCy Schubert if ( !onlyHandlers && !event.isDefaultPrevented() ) { 8733*7f2fe78bSCy Schubert 8734*7f2fe78bSCy Schubert if ( ( !special._default || 8735*7f2fe78bSCy Schubert special._default.apply( eventPath.pop(), data ) === false ) && 8736*7f2fe78bSCy Schubert acceptData( elem ) ) { 8737*7f2fe78bSCy Schubert 8738*7f2fe78bSCy Schubert // Call a native DOM method on the target with the same name as the event. 8739*7f2fe78bSCy Schubert // Don't do default actions on window, that's where global variables be (#6170) 8740*7f2fe78bSCy Schubert if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) { 8741*7f2fe78bSCy Schubert 8742*7f2fe78bSCy Schubert // Don't re-trigger an onFOO event when we call its FOO() method 8743*7f2fe78bSCy Schubert tmp = elem[ ontype ]; 8744*7f2fe78bSCy Schubert 8745*7f2fe78bSCy Schubert if ( tmp ) { 8746*7f2fe78bSCy Schubert elem[ ontype ] = null; 8747*7f2fe78bSCy Schubert } 8748*7f2fe78bSCy Schubert 8749*7f2fe78bSCy Schubert // Prevent re-triggering of the same event, since we already bubbled it above 8750*7f2fe78bSCy Schubert jQuery.event.triggered = type; 8751*7f2fe78bSCy Schubert 8752*7f2fe78bSCy Schubert if ( event.isPropagationStopped() ) { 8753*7f2fe78bSCy Schubert lastElement.addEventListener( type, stopPropagationCallback ); 8754*7f2fe78bSCy Schubert } 8755*7f2fe78bSCy Schubert 8756*7f2fe78bSCy Schubert elem[ type ](); 8757*7f2fe78bSCy Schubert 8758*7f2fe78bSCy Schubert if ( event.isPropagationStopped() ) { 8759*7f2fe78bSCy Schubert lastElement.removeEventListener( type, stopPropagationCallback ); 8760*7f2fe78bSCy Schubert } 8761*7f2fe78bSCy Schubert 8762*7f2fe78bSCy Schubert jQuery.event.triggered = undefined; 8763*7f2fe78bSCy Schubert 8764*7f2fe78bSCy Schubert if ( tmp ) { 8765*7f2fe78bSCy Schubert elem[ ontype ] = tmp; 8766*7f2fe78bSCy Schubert } 8767*7f2fe78bSCy Schubert } 8768*7f2fe78bSCy Schubert } 8769*7f2fe78bSCy Schubert } 8770*7f2fe78bSCy Schubert 8771*7f2fe78bSCy Schubert return event.result; 8772*7f2fe78bSCy Schubert }, 8773*7f2fe78bSCy Schubert 8774*7f2fe78bSCy Schubert // Piggyback on a donor event to simulate a different one 8775*7f2fe78bSCy Schubert // Used only for `focus(in | out)` events 8776*7f2fe78bSCy Schubert simulate: function( type, elem, event ) { 8777*7f2fe78bSCy Schubert var e = jQuery.extend( 8778*7f2fe78bSCy Schubert new jQuery.Event(), 8779*7f2fe78bSCy Schubert event, 8780*7f2fe78bSCy Schubert { 8781*7f2fe78bSCy Schubert type: type, 8782*7f2fe78bSCy Schubert isSimulated: true 8783*7f2fe78bSCy Schubert } 8784*7f2fe78bSCy Schubert ); 8785*7f2fe78bSCy Schubert 8786*7f2fe78bSCy Schubert jQuery.event.trigger( e, null, elem ); 8787*7f2fe78bSCy Schubert } 8788*7f2fe78bSCy Schubert 8789*7f2fe78bSCy Schubert} ); 8790*7f2fe78bSCy Schubert 8791*7f2fe78bSCy SchubertjQuery.fn.extend( { 8792*7f2fe78bSCy Schubert 8793*7f2fe78bSCy Schubert trigger: function( type, data ) { 8794*7f2fe78bSCy Schubert return this.each( function() { 8795*7f2fe78bSCy Schubert jQuery.event.trigger( type, data, this ); 8796*7f2fe78bSCy Schubert } ); 8797*7f2fe78bSCy Schubert }, 8798*7f2fe78bSCy Schubert triggerHandler: function( type, data ) { 8799*7f2fe78bSCy Schubert var elem = this[ 0 ]; 8800*7f2fe78bSCy Schubert if ( elem ) { 8801*7f2fe78bSCy Schubert return jQuery.event.trigger( type, data, elem, true ); 8802*7f2fe78bSCy Schubert } 8803*7f2fe78bSCy Schubert } 8804*7f2fe78bSCy Schubert} ); 8805*7f2fe78bSCy Schubert 8806*7f2fe78bSCy Schubert 8807*7f2fe78bSCy Schubert// Support: Firefox <=44 8808*7f2fe78bSCy Schubert// Firefox doesn't have focus(in | out) events 8809*7f2fe78bSCy Schubert// Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787 8810*7f2fe78bSCy Schubert// 8811*7f2fe78bSCy Schubert// Support: Chrome <=48 - 49, Safari <=9.0 - 9.1 8812*7f2fe78bSCy Schubert// focus(in | out) events fire after focus & blur events, 8813*7f2fe78bSCy Schubert// which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order 8814*7f2fe78bSCy Schubert// Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857 8815*7f2fe78bSCy Schubertif ( !support.focusin ) { 8816*7f2fe78bSCy Schubert jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) { 8817*7f2fe78bSCy Schubert 8818*7f2fe78bSCy Schubert // Attach a single capturing handler on the document while someone wants focusin/focusout 8819*7f2fe78bSCy Schubert var handler = function( event ) { 8820*7f2fe78bSCy Schubert jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) ); 8821*7f2fe78bSCy Schubert }; 8822*7f2fe78bSCy Schubert 8823*7f2fe78bSCy Schubert jQuery.event.special[ fix ] = { 8824*7f2fe78bSCy Schubert setup: function() { 8825*7f2fe78bSCy Schubert 8826*7f2fe78bSCy Schubert // Handle: regular nodes (via `this.ownerDocument`), window 8827*7f2fe78bSCy Schubert // (via `this.document`) & document (via `this`). 8828*7f2fe78bSCy Schubert var doc = this.ownerDocument || this.document || this, 8829*7f2fe78bSCy Schubert attaches = dataPriv.access( doc, fix ); 8830*7f2fe78bSCy Schubert 8831*7f2fe78bSCy Schubert if ( !attaches ) { 8832*7f2fe78bSCy Schubert doc.addEventListener( orig, handler, true ); 8833*7f2fe78bSCy Schubert } 8834*7f2fe78bSCy Schubert dataPriv.access( doc, fix, ( attaches || 0 ) + 1 ); 8835*7f2fe78bSCy Schubert }, 8836*7f2fe78bSCy Schubert teardown: function() { 8837*7f2fe78bSCy Schubert var doc = this.ownerDocument || this.document || this, 8838*7f2fe78bSCy Schubert attaches = dataPriv.access( doc, fix ) - 1; 8839*7f2fe78bSCy Schubert 8840*7f2fe78bSCy Schubert if ( !attaches ) { 8841*7f2fe78bSCy Schubert doc.removeEventListener( orig, handler, true ); 8842*7f2fe78bSCy Schubert dataPriv.remove( doc, fix ); 8843*7f2fe78bSCy Schubert 8844*7f2fe78bSCy Schubert } else { 8845*7f2fe78bSCy Schubert dataPriv.access( doc, fix, attaches ); 8846*7f2fe78bSCy Schubert } 8847*7f2fe78bSCy Schubert } 8848*7f2fe78bSCy Schubert }; 8849*7f2fe78bSCy Schubert } ); 8850*7f2fe78bSCy Schubert} 8851*7f2fe78bSCy Schubertvar location = window.location; 8852*7f2fe78bSCy Schubert 8853*7f2fe78bSCy Schubertvar nonce = { guid: Date.now() }; 8854*7f2fe78bSCy Schubert 8855*7f2fe78bSCy Schubertvar rquery = ( /\?/ ); 8856*7f2fe78bSCy Schubert 8857*7f2fe78bSCy Schubert 8858*7f2fe78bSCy Schubert 8859*7f2fe78bSCy Schubert// Cross-browser xml parsing 8860*7f2fe78bSCy SchubertjQuery.parseXML = function( data ) { 8861*7f2fe78bSCy Schubert var xml, parserErrorElem; 8862*7f2fe78bSCy Schubert if ( !data || typeof data !== "string" ) { 8863*7f2fe78bSCy Schubert return null; 8864*7f2fe78bSCy Schubert } 8865*7f2fe78bSCy Schubert 8866*7f2fe78bSCy Schubert // Support: IE 9 - 11 only 8867*7f2fe78bSCy Schubert // IE throws on parseFromString with invalid input. 8868*7f2fe78bSCy Schubert try { 8869*7f2fe78bSCy Schubert xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" ); 8870*7f2fe78bSCy Schubert } catch ( e ) {} 8871*7f2fe78bSCy Schubert 8872*7f2fe78bSCy Schubert parserErrorElem = xml && xml.getElementsByTagName( "parsererror" )[ 0 ]; 8873*7f2fe78bSCy Schubert if ( !xml || parserErrorElem ) { 8874*7f2fe78bSCy Schubert jQuery.error( "Invalid XML: " + ( 8875*7f2fe78bSCy Schubert parserErrorElem ? 8876*7f2fe78bSCy Schubert jQuery.map( parserErrorElem.childNodes, function( el ) { 8877*7f2fe78bSCy Schubert return el.textContent; 8878*7f2fe78bSCy Schubert } ).join( "\n" ) : 8879*7f2fe78bSCy Schubert data 8880*7f2fe78bSCy Schubert ) ); 8881*7f2fe78bSCy Schubert } 8882*7f2fe78bSCy Schubert return xml; 8883*7f2fe78bSCy Schubert}; 8884*7f2fe78bSCy Schubert 8885*7f2fe78bSCy Schubert 8886*7f2fe78bSCy Schubertvar 8887*7f2fe78bSCy Schubert rbracket = /\[\]$/, 8888*7f2fe78bSCy Schubert rCRLF = /\r?\n/g, 8889*7f2fe78bSCy Schubert rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i, 8890*7f2fe78bSCy Schubert rsubmittable = /^(?:input|select|textarea|keygen)/i; 8891*7f2fe78bSCy Schubert 8892*7f2fe78bSCy Schubertfunction buildParams( prefix, obj, traditional, add ) { 8893*7f2fe78bSCy Schubert var name; 8894*7f2fe78bSCy Schubert 8895*7f2fe78bSCy Schubert if ( Array.isArray( obj ) ) { 8896*7f2fe78bSCy Schubert 8897*7f2fe78bSCy Schubert // Serialize array item. 8898*7f2fe78bSCy Schubert jQuery.each( obj, function( i, v ) { 8899*7f2fe78bSCy Schubert if ( traditional || rbracket.test( prefix ) ) { 8900*7f2fe78bSCy Schubert 8901*7f2fe78bSCy Schubert // Treat each array item as a scalar. 8902*7f2fe78bSCy Schubert add( prefix, v ); 8903*7f2fe78bSCy Schubert 8904*7f2fe78bSCy Schubert } else { 8905*7f2fe78bSCy Schubert 8906*7f2fe78bSCy Schubert // Item is non-scalar (array or object), encode its numeric index. 8907*7f2fe78bSCy Schubert buildParams( 8908*7f2fe78bSCy Schubert prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]", 8909*7f2fe78bSCy Schubert v, 8910*7f2fe78bSCy Schubert traditional, 8911*7f2fe78bSCy Schubert add 8912*7f2fe78bSCy Schubert ); 8913*7f2fe78bSCy Schubert } 8914*7f2fe78bSCy Schubert } ); 8915*7f2fe78bSCy Schubert 8916*7f2fe78bSCy Schubert } else if ( !traditional && toType( obj ) === "object" ) { 8917*7f2fe78bSCy Schubert 8918*7f2fe78bSCy Schubert // Serialize object item. 8919*7f2fe78bSCy Schubert for ( name in obj ) { 8920*7f2fe78bSCy Schubert buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); 8921*7f2fe78bSCy Schubert } 8922*7f2fe78bSCy Schubert 8923*7f2fe78bSCy Schubert } else { 8924*7f2fe78bSCy Schubert 8925*7f2fe78bSCy Schubert // Serialize scalar item. 8926*7f2fe78bSCy Schubert add( prefix, obj ); 8927*7f2fe78bSCy Schubert } 8928*7f2fe78bSCy Schubert} 8929*7f2fe78bSCy Schubert 8930*7f2fe78bSCy Schubert// Serialize an array of form elements or a set of 8931*7f2fe78bSCy Schubert// key/values into a query string 8932*7f2fe78bSCy SchubertjQuery.param = function( a, traditional ) { 8933*7f2fe78bSCy Schubert var prefix, 8934*7f2fe78bSCy Schubert s = [], 8935*7f2fe78bSCy Schubert add = function( key, valueOrFunction ) { 8936*7f2fe78bSCy Schubert 8937*7f2fe78bSCy Schubert // If value is a function, invoke it and use its return value 8938*7f2fe78bSCy Schubert var value = isFunction( valueOrFunction ) ? 8939*7f2fe78bSCy Schubert valueOrFunction() : 8940*7f2fe78bSCy Schubert valueOrFunction; 8941*7f2fe78bSCy Schubert 8942*7f2fe78bSCy Schubert s[ s.length ] = encodeURIComponent( key ) + "=" + 8943*7f2fe78bSCy Schubert encodeURIComponent( value == null ? "" : value ); 8944*7f2fe78bSCy Schubert }; 8945*7f2fe78bSCy Schubert 8946*7f2fe78bSCy Schubert if ( a == null ) { 8947*7f2fe78bSCy Schubert return ""; 8948*7f2fe78bSCy Schubert } 8949*7f2fe78bSCy Schubert 8950*7f2fe78bSCy Schubert // If an array was passed in, assume that it is an array of form elements. 8951*7f2fe78bSCy Schubert if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { 8952*7f2fe78bSCy Schubert 8953*7f2fe78bSCy Schubert // Serialize the form elements 8954*7f2fe78bSCy Schubert jQuery.each( a, function() { 8955*7f2fe78bSCy Schubert add( this.name, this.value ); 8956*7f2fe78bSCy Schubert } ); 8957*7f2fe78bSCy Schubert 8958*7f2fe78bSCy Schubert } else { 8959*7f2fe78bSCy Schubert 8960*7f2fe78bSCy Schubert // If traditional, encode the "old" way (the way 1.3.2 or older 8961*7f2fe78bSCy Schubert // did it), otherwise encode params recursively. 8962*7f2fe78bSCy Schubert for ( prefix in a ) { 8963*7f2fe78bSCy Schubert buildParams( prefix, a[ prefix ], traditional, add ); 8964*7f2fe78bSCy Schubert } 8965*7f2fe78bSCy Schubert } 8966*7f2fe78bSCy Schubert 8967*7f2fe78bSCy Schubert // Return the resulting serialization 8968*7f2fe78bSCy Schubert return s.join( "&" ); 8969*7f2fe78bSCy Schubert}; 8970*7f2fe78bSCy Schubert 8971*7f2fe78bSCy SchubertjQuery.fn.extend( { 8972*7f2fe78bSCy Schubert serialize: function() { 8973*7f2fe78bSCy Schubert return jQuery.param( this.serializeArray() ); 8974*7f2fe78bSCy Schubert }, 8975*7f2fe78bSCy Schubert serializeArray: function() { 8976*7f2fe78bSCy Schubert return this.map( function() { 8977*7f2fe78bSCy Schubert 8978*7f2fe78bSCy Schubert // Can add propHook for "elements" to filter or add form elements 8979*7f2fe78bSCy Schubert var elements = jQuery.prop( this, "elements" ); 8980*7f2fe78bSCy Schubert return elements ? jQuery.makeArray( elements ) : this; 8981*7f2fe78bSCy Schubert } ).filter( function() { 8982*7f2fe78bSCy Schubert var type = this.type; 8983*7f2fe78bSCy Schubert 8984*7f2fe78bSCy Schubert // Use .is( ":disabled" ) so that fieldset[disabled] works 8985*7f2fe78bSCy Schubert return this.name && !jQuery( this ).is( ":disabled" ) && 8986*7f2fe78bSCy Schubert rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) && 8987*7f2fe78bSCy Schubert ( this.checked || !rcheckableType.test( type ) ); 8988*7f2fe78bSCy Schubert } ).map( function( _i, elem ) { 8989*7f2fe78bSCy Schubert var val = jQuery( this ).val(); 8990*7f2fe78bSCy Schubert 8991*7f2fe78bSCy Schubert if ( val == null ) { 8992*7f2fe78bSCy Schubert return null; 8993*7f2fe78bSCy Schubert } 8994*7f2fe78bSCy Schubert 8995*7f2fe78bSCy Schubert if ( Array.isArray( val ) ) { 8996*7f2fe78bSCy Schubert return jQuery.map( val, function( val ) { 8997*7f2fe78bSCy Schubert return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; 8998*7f2fe78bSCy Schubert } ); 8999*7f2fe78bSCy Schubert } 9000*7f2fe78bSCy Schubert 9001*7f2fe78bSCy Schubert return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; 9002*7f2fe78bSCy Schubert } ).get(); 9003*7f2fe78bSCy Schubert } 9004*7f2fe78bSCy Schubert} ); 9005*7f2fe78bSCy Schubert 9006*7f2fe78bSCy Schubert 9007*7f2fe78bSCy Schubertvar 9008*7f2fe78bSCy Schubert r20 = /%20/g, 9009*7f2fe78bSCy Schubert rhash = /#.*$/, 9010*7f2fe78bSCy Schubert rantiCache = /([?&])_=[^&]*/, 9011*7f2fe78bSCy Schubert rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg, 9012*7f2fe78bSCy Schubert 9013*7f2fe78bSCy Schubert // #7653, #8125, #8152: local protocol detection 9014*7f2fe78bSCy Schubert rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/, 9015*7f2fe78bSCy Schubert rnoContent = /^(?:GET|HEAD)$/, 9016*7f2fe78bSCy Schubert rprotocol = /^\/\//, 9017*7f2fe78bSCy Schubert 9018*7f2fe78bSCy Schubert /* Prefilters 9019*7f2fe78bSCy Schubert * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example) 9020*7f2fe78bSCy Schubert * 2) These are called: 9021*7f2fe78bSCy Schubert * - BEFORE asking for a transport 9022*7f2fe78bSCy Schubert * - AFTER param serialization (s.data is a string if s.processData is true) 9023*7f2fe78bSCy Schubert * 3) key is the dataType 9024*7f2fe78bSCy Schubert * 4) the catchall symbol "*" can be used 9025*7f2fe78bSCy Schubert * 5) execution will start with transport dataType and THEN continue down to "*" if needed 9026*7f2fe78bSCy Schubert */ 9027*7f2fe78bSCy Schubert prefilters = {}, 9028*7f2fe78bSCy Schubert 9029*7f2fe78bSCy Schubert /* Transports bindings 9030*7f2fe78bSCy Schubert * 1) key is the dataType 9031*7f2fe78bSCy Schubert * 2) the catchall symbol "*" can be used 9032*7f2fe78bSCy Schubert * 3) selection will start with transport dataType and THEN go to "*" if needed 9033*7f2fe78bSCy Schubert */ 9034*7f2fe78bSCy Schubert transports = {}, 9035*7f2fe78bSCy Schubert 9036*7f2fe78bSCy Schubert // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression 9037*7f2fe78bSCy Schubert allTypes = "*/".concat( "*" ), 9038*7f2fe78bSCy Schubert 9039*7f2fe78bSCy Schubert // Anchor tag for parsing the document origin 9040*7f2fe78bSCy Schubert originAnchor = document.createElement( "a" ); 9041*7f2fe78bSCy Schubert 9042*7f2fe78bSCy SchubertoriginAnchor.href = location.href; 9043*7f2fe78bSCy Schubert 9044*7f2fe78bSCy Schubert// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport 9045*7f2fe78bSCy Schubertfunction addToPrefiltersOrTransports( structure ) { 9046*7f2fe78bSCy Schubert 9047*7f2fe78bSCy Schubert // dataTypeExpression is optional and defaults to "*" 9048*7f2fe78bSCy Schubert return function( dataTypeExpression, func ) { 9049*7f2fe78bSCy Schubert 9050*7f2fe78bSCy Schubert if ( typeof dataTypeExpression !== "string" ) { 9051*7f2fe78bSCy Schubert func = dataTypeExpression; 9052*7f2fe78bSCy Schubert dataTypeExpression = "*"; 9053*7f2fe78bSCy Schubert } 9054*7f2fe78bSCy Schubert 9055*7f2fe78bSCy Schubert var dataType, 9056*7f2fe78bSCy Schubert i = 0, 9057*7f2fe78bSCy Schubert dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || []; 9058*7f2fe78bSCy Schubert 9059*7f2fe78bSCy Schubert if ( isFunction( func ) ) { 9060*7f2fe78bSCy Schubert 9061*7f2fe78bSCy Schubert // For each dataType in the dataTypeExpression 9062*7f2fe78bSCy Schubert while ( ( dataType = dataTypes[ i++ ] ) ) { 9063*7f2fe78bSCy Schubert 9064*7f2fe78bSCy Schubert // Prepend if requested 9065*7f2fe78bSCy Schubert if ( dataType[ 0 ] === "+" ) { 9066*7f2fe78bSCy Schubert dataType = dataType.slice( 1 ) || "*"; 9067*7f2fe78bSCy Schubert ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func ); 9068*7f2fe78bSCy Schubert 9069*7f2fe78bSCy Schubert // Otherwise append 9070*7f2fe78bSCy Schubert } else { 9071*7f2fe78bSCy Schubert ( structure[ dataType ] = structure[ dataType ] || [] ).push( func ); 9072*7f2fe78bSCy Schubert } 9073*7f2fe78bSCy Schubert } 9074*7f2fe78bSCy Schubert } 9075*7f2fe78bSCy Schubert }; 9076*7f2fe78bSCy Schubert} 9077*7f2fe78bSCy Schubert 9078*7f2fe78bSCy Schubert// Base inspection function for prefilters and transports 9079*7f2fe78bSCy Schubertfunction inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) { 9080*7f2fe78bSCy Schubert 9081*7f2fe78bSCy Schubert var inspected = {}, 9082*7f2fe78bSCy Schubert seekingTransport = ( structure === transports ); 9083*7f2fe78bSCy Schubert 9084*7f2fe78bSCy Schubert function inspect( dataType ) { 9085*7f2fe78bSCy Schubert var selected; 9086*7f2fe78bSCy Schubert inspected[ dataType ] = true; 9087*7f2fe78bSCy Schubert jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) { 9088*7f2fe78bSCy Schubert var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR ); 9089*7f2fe78bSCy Schubert if ( typeof dataTypeOrTransport === "string" && 9090*7f2fe78bSCy Schubert !seekingTransport && !inspected[ dataTypeOrTransport ] ) { 9091*7f2fe78bSCy Schubert 9092*7f2fe78bSCy Schubert options.dataTypes.unshift( dataTypeOrTransport ); 9093*7f2fe78bSCy Schubert inspect( dataTypeOrTransport ); 9094*7f2fe78bSCy Schubert return false; 9095*7f2fe78bSCy Schubert } else if ( seekingTransport ) { 9096*7f2fe78bSCy Schubert return !( selected = dataTypeOrTransport ); 9097*7f2fe78bSCy Schubert } 9098*7f2fe78bSCy Schubert } ); 9099*7f2fe78bSCy Schubert return selected; 9100*7f2fe78bSCy Schubert } 9101*7f2fe78bSCy Schubert 9102*7f2fe78bSCy Schubert return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" ); 9103*7f2fe78bSCy Schubert} 9104*7f2fe78bSCy Schubert 9105*7f2fe78bSCy Schubert// A special extend for ajax options 9106*7f2fe78bSCy Schubert// that takes "flat" options (not to be deep extended) 9107*7f2fe78bSCy Schubert// Fixes #9887 9108*7f2fe78bSCy Schubertfunction ajaxExtend( target, src ) { 9109*7f2fe78bSCy Schubert var key, deep, 9110*7f2fe78bSCy Schubert flatOptions = jQuery.ajaxSettings.flatOptions || {}; 9111*7f2fe78bSCy Schubert 9112*7f2fe78bSCy Schubert for ( key in src ) { 9113*7f2fe78bSCy Schubert if ( src[ key ] !== undefined ) { 9114*7f2fe78bSCy Schubert ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ]; 9115*7f2fe78bSCy Schubert } 9116*7f2fe78bSCy Schubert } 9117*7f2fe78bSCy Schubert if ( deep ) { 9118*7f2fe78bSCy Schubert jQuery.extend( true, target, deep ); 9119*7f2fe78bSCy Schubert } 9120*7f2fe78bSCy Schubert 9121*7f2fe78bSCy Schubert return target; 9122*7f2fe78bSCy Schubert} 9123*7f2fe78bSCy Schubert 9124*7f2fe78bSCy Schubert/* Handles responses to an ajax request: 9125*7f2fe78bSCy Schubert * - finds the right dataType (mediates between content-type and expected dataType) 9126*7f2fe78bSCy Schubert * - returns the corresponding response 9127*7f2fe78bSCy Schubert */ 9128*7f2fe78bSCy Schubertfunction ajaxHandleResponses( s, jqXHR, responses ) { 9129*7f2fe78bSCy Schubert 9130*7f2fe78bSCy Schubert var ct, type, finalDataType, firstDataType, 9131*7f2fe78bSCy Schubert contents = s.contents, 9132*7f2fe78bSCy Schubert dataTypes = s.dataTypes; 9133*7f2fe78bSCy Schubert 9134*7f2fe78bSCy Schubert // Remove auto dataType and get content-type in the process 9135*7f2fe78bSCy Schubert while ( dataTypes[ 0 ] === "*" ) { 9136*7f2fe78bSCy Schubert dataTypes.shift(); 9137*7f2fe78bSCy Schubert if ( ct === undefined ) { 9138*7f2fe78bSCy Schubert ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" ); 9139*7f2fe78bSCy Schubert } 9140*7f2fe78bSCy Schubert } 9141*7f2fe78bSCy Schubert 9142*7f2fe78bSCy Schubert // Check if we're dealing with a known content-type 9143*7f2fe78bSCy Schubert if ( ct ) { 9144*7f2fe78bSCy Schubert for ( type in contents ) { 9145*7f2fe78bSCy Schubert if ( contents[ type ] && contents[ type ].test( ct ) ) { 9146*7f2fe78bSCy Schubert dataTypes.unshift( type ); 9147*7f2fe78bSCy Schubert break; 9148*7f2fe78bSCy Schubert } 9149*7f2fe78bSCy Schubert } 9150*7f2fe78bSCy Schubert } 9151*7f2fe78bSCy Schubert 9152*7f2fe78bSCy Schubert // Check to see if we have a response for the expected dataType 9153*7f2fe78bSCy Schubert if ( dataTypes[ 0 ] in responses ) { 9154*7f2fe78bSCy Schubert finalDataType = dataTypes[ 0 ]; 9155*7f2fe78bSCy Schubert } else { 9156*7f2fe78bSCy Schubert 9157*7f2fe78bSCy Schubert // Try convertible dataTypes 9158*7f2fe78bSCy Schubert for ( type in responses ) { 9159*7f2fe78bSCy Schubert if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) { 9160*7f2fe78bSCy Schubert finalDataType = type; 9161*7f2fe78bSCy Schubert break; 9162*7f2fe78bSCy Schubert } 9163*7f2fe78bSCy Schubert if ( !firstDataType ) { 9164*7f2fe78bSCy Schubert firstDataType = type; 9165*7f2fe78bSCy Schubert } 9166*7f2fe78bSCy Schubert } 9167*7f2fe78bSCy Schubert 9168*7f2fe78bSCy Schubert // Or just use first one 9169*7f2fe78bSCy Schubert finalDataType = finalDataType || firstDataType; 9170*7f2fe78bSCy Schubert } 9171*7f2fe78bSCy Schubert 9172*7f2fe78bSCy Schubert // If we found a dataType 9173*7f2fe78bSCy Schubert // We add the dataType to the list if needed 9174*7f2fe78bSCy Schubert // and return the corresponding response 9175*7f2fe78bSCy Schubert if ( finalDataType ) { 9176*7f2fe78bSCy Schubert if ( finalDataType !== dataTypes[ 0 ] ) { 9177*7f2fe78bSCy Schubert dataTypes.unshift( finalDataType ); 9178*7f2fe78bSCy Schubert } 9179*7f2fe78bSCy Schubert return responses[ finalDataType ]; 9180*7f2fe78bSCy Schubert } 9181*7f2fe78bSCy Schubert} 9182*7f2fe78bSCy Schubert 9183*7f2fe78bSCy Schubert/* Chain conversions given the request and the original response 9184*7f2fe78bSCy Schubert * Also sets the responseXXX fields on the jqXHR instance 9185*7f2fe78bSCy Schubert */ 9186*7f2fe78bSCy Schubertfunction ajaxConvert( s, response, jqXHR, isSuccess ) { 9187*7f2fe78bSCy Schubert var conv2, current, conv, tmp, prev, 9188*7f2fe78bSCy Schubert converters = {}, 9189*7f2fe78bSCy Schubert 9190*7f2fe78bSCy Schubert // Work with a copy of dataTypes in case we need to modify it for conversion 9191*7f2fe78bSCy Schubert dataTypes = s.dataTypes.slice(); 9192*7f2fe78bSCy Schubert 9193*7f2fe78bSCy Schubert // Create converters map with lowercased keys 9194*7f2fe78bSCy Schubert if ( dataTypes[ 1 ] ) { 9195*7f2fe78bSCy Schubert for ( conv in s.converters ) { 9196*7f2fe78bSCy Schubert converters[ conv.toLowerCase() ] = s.converters[ conv ]; 9197*7f2fe78bSCy Schubert } 9198*7f2fe78bSCy Schubert } 9199*7f2fe78bSCy Schubert 9200*7f2fe78bSCy Schubert current = dataTypes.shift(); 9201*7f2fe78bSCy Schubert 9202*7f2fe78bSCy Schubert // Convert to each sequential dataType 9203*7f2fe78bSCy Schubert while ( current ) { 9204*7f2fe78bSCy Schubert 9205*7f2fe78bSCy Schubert if ( s.responseFields[ current ] ) { 9206*7f2fe78bSCy Schubert jqXHR[ s.responseFields[ current ] ] = response; 9207*7f2fe78bSCy Schubert } 9208*7f2fe78bSCy Schubert 9209*7f2fe78bSCy Schubert // Apply the dataFilter if provided 9210*7f2fe78bSCy Schubert if ( !prev && isSuccess && s.dataFilter ) { 9211*7f2fe78bSCy Schubert response = s.dataFilter( response, s.dataType ); 9212*7f2fe78bSCy Schubert } 9213*7f2fe78bSCy Schubert 9214*7f2fe78bSCy Schubert prev = current; 9215*7f2fe78bSCy Schubert current = dataTypes.shift(); 9216*7f2fe78bSCy Schubert 9217*7f2fe78bSCy Schubert if ( current ) { 9218*7f2fe78bSCy Schubert 9219*7f2fe78bSCy Schubert // There's only work to do if current dataType is non-auto 9220*7f2fe78bSCy Schubert if ( current === "*" ) { 9221*7f2fe78bSCy Schubert 9222*7f2fe78bSCy Schubert current = prev; 9223*7f2fe78bSCy Schubert 9224*7f2fe78bSCy Schubert // Convert response if prev dataType is non-auto and differs from current 9225*7f2fe78bSCy Schubert } else if ( prev !== "*" && prev !== current ) { 9226*7f2fe78bSCy Schubert 9227*7f2fe78bSCy Schubert // Seek a direct converter 9228*7f2fe78bSCy Schubert conv = converters[ prev + " " + current ] || converters[ "* " + current ]; 9229*7f2fe78bSCy Schubert 9230*7f2fe78bSCy Schubert // If none found, seek a pair 9231*7f2fe78bSCy Schubert if ( !conv ) { 9232*7f2fe78bSCy Schubert for ( conv2 in converters ) { 9233*7f2fe78bSCy Schubert 9234*7f2fe78bSCy Schubert // If conv2 outputs current 9235*7f2fe78bSCy Schubert tmp = conv2.split( " " ); 9236*7f2fe78bSCy Schubert if ( tmp[ 1 ] === current ) { 9237*7f2fe78bSCy Schubert 9238*7f2fe78bSCy Schubert // If prev can be converted to accepted input 9239*7f2fe78bSCy Schubert conv = converters[ prev + " " + tmp[ 0 ] ] || 9240*7f2fe78bSCy Schubert converters[ "* " + tmp[ 0 ] ]; 9241*7f2fe78bSCy Schubert if ( conv ) { 9242*7f2fe78bSCy Schubert 9243*7f2fe78bSCy Schubert // Condense equivalence converters 9244*7f2fe78bSCy Schubert if ( conv === true ) { 9245*7f2fe78bSCy Schubert conv = converters[ conv2 ]; 9246*7f2fe78bSCy Schubert 9247*7f2fe78bSCy Schubert // Otherwise, insert the intermediate dataType 9248*7f2fe78bSCy Schubert } else if ( converters[ conv2 ] !== true ) { 9249*7f2fe78bSCy Schubert current = tmp[ 0 ]; 9250*7f2fe78bSCy Schubert dataTypes.unshift( tmp[ 1 ] ); 9251*7f2fe78bSCy Schubert } 9252*7f2fe78bSCy Schubert break; 9253*7f2fe78bSCy Schubert } 9254*7f2fe78bSCy Schubert } 9255*7f2fe78bSCy Schubert } 9256*7f2fe78bSCy Schubert } 9257*7f2fe78bSCy Schubert 9258*7f2fe78bSCy Schubert // Apply converter (if not an equivalence) 9259*7f2fe78bSCy Schubert if ( conv !== true ) { 9260*7f2fe78bSCy Schubert 9261*7f2fe78bSCy Schubert // Unless errors are allowed to bubble, catch and return them 9262*7f2fe78bSCy Schubert if ( conv && s.throws ) { 9263*7f2fe78bSCy Schubert response = conv( response ); 9264*7f2fe78bSCy Schubert } else { 9265*7f2fe78bSCy Schubert try { 9266*7f2fe78bSCy Schubert response = conv( response ); 9267*7f2fe78bSCy Schubert } catch ( e ) { 9268*7f2fe78bSCy Schubert return { 9269*7f2fe78bSCy Schubert state: "parsererror", 9270*7f2fe78bSCy Schubert error: conv ? e : "No conversion from " + prev + " to " + current 9271*7f2fe78bSCy Schubert }; 9272*7f2fe78bSCy Schubert } 9273*7f2fe78bSCy Schubert } 9274*7f2fe78bSCy Schubert } 9275*7f2fe78bSCy Schubert } 9276*7f2fe78bSCy Schubert } 9277*7f2fe78bSCy Schubert } 9278*7f2fe78bSCy Schubert 9279*7f2fe78bSCy Schubert return { state: "success", data: response }; 9280*7f2fe78bSCy Schubert} 9281*7f2fe78bSCy Schubert 9282*7f2fe78bSCy SchubertjQuery.extend( { 9283*7f2fe78bSCy Schubert 9284*7f2fe78bSCy Schubert // Counter for holding the number of active queries 9285*7f2fe78bSCy Schubert active: 0, 9286*7f2fe78bSCy Schubert 9287*7f2fe78bSCy Schubert // Last-Modified header cache for next request 9288*7f2fe78bSCy Schubert lastModified: {}, 9289*7f2fe78bSCy Schubert etag: {}, 9290*7f2fe78bSCy Schubert 9291*7f2fe78bSCy Schubert ajaxSettings: { 9292*7f2fe78bSCy Schubert url: location.href, 9293*7f2fe78bSCy Schubert type: "GET", 9294*7f2fe78bSCy Schubert isLocal: rlocalProtocol.test( location.protocol ), 9295*7f2fe78bSCy Schubert global: true, 9296*7f2fe78bSCy Schubert processData: true, 9297*7f2fe78bSCy Schubert async: true, 9298*7f2fe78bSCy Schubert contentType: "application/x-www-form-urlencoded; charset=UTF-8", 9299*7f2fe78bSCy Schubert 9300*7f2fe78bSCy Schubert /* 9301*7f2fe78bSCy Schubert timeout: 0, 9302*7f2fe78bSCy Schubert data: null, 9303*7f2fe78bSCy Schubert dataType: null, 9304*7f2fe78bSCy Schubert username: null, 9305*7f2fe78bSCy Schubert password: null, 9306*7f2fe78bSCy Schubert cache: null, 9307*7f2fe78bSCy Schubert throws: false, 9308*7f2fe78bSCy Schubert traditional: false, 9309*7f2fe78bSCy Schubert headers: {}, 9310*7f2fe78bSCy Schubert */ 9311*7f2fe78bSCy Schubert 9312*7f2fe78bSCy Schubert accepts: { 9313*7f2fe78bSCy Schubert "*": allTypes, 9314*7f2fe78bSCy Schubert text: "text/plain", 9315*7f2fe78bSCy Schubert html: "text/html", 9316*7f2fe78bSCy Schubert xml: "application/xml, text/xml", 9317*7f2fe78bSCy Schubert json: "application/json, text/javascript" 9318*7f2fe78bSCy Schubert }, 9319*7f2fe78bSCy Schubert 9320*7f2fe78bSCy Schubert contents: { 9321*7f2fe78bSCy Schubert xml: /\bxml\b/, 9322*7f2fe78bSCy Schubert html: /\bhtml/, 9323*7f2fe78bSCy Schubert json: /\bjson\b/ 9324*7f2fe78bSCy Schubert }, 9325*7f2fe78bSCy Schubert 9326*7f2fe78bSCy Schubert responseFields: { 9327*7f2fe78bSCy Schubert xml: "responseXML", 9328*7f2fe78bSCy Schubert text: "responseText", 9329*7f2fe78bSCy Schubert json: "responseJSON" 9330*7f2fe78bSCy Schubert }, 9331*7f2fe78bSCy Schubert 9332*7f2fe78bSCy Schubert // Data converters 9333*7f2fe78bSCy Schubert // Keys separate source (or catchall "*") and destination types with a single space 9334*7f2fe78bSCy Schubert converters: { 9335*7f2fe78bSCy Schubert 9336*7f2fe78bSCy Schubert // Convert anything to text 9337*7f2fe78bSCy Schubert "* text": String, 9338*7f2fe78bSCy Schubert 9339*7f2fe78bSCy Schubert // Text to html (true = no transformation) 9340*7f2fe78bSCy Schubert "text html": true, 9341*7f2fe78bSCy Schubert 9342*7f2fe78bSCy Schubert // Evaluate text as a json expression 9343*7f2fe78bSCy Schubert "text json": JSON.parse, 9344*7f2fe78bSCy Schubert 9345*7f2fe78bSCy Schubert // Parse text as xml 9346*7f2fe78bSCy Schubert "text xml": jQuery.parseXML 9347*7f2fe78bSCy Schubert }, 9348*7f2fe78bSCy Schubert 9349*7f2fe78bSCy Schubert // For options that shouldn't be deep extended: 9350*7f2fe78bSCy Schubert // you can add your own custom options here if 9351*7f2fe78bSCy Schubert // and when you create one that shouldn't be 9352*7f2fe78bSCy Schubert // deep extended (see ajaxExtend) 9353*7f2fe78bSCy Schubert flatOptions: { 9354*7f2fe78bSCy Schubert url: true, 9355*7f2fe78bSCy Schubert context: true 9356*7f2fe78bSCy Schubert } 9357*7f2fe78bSCy Schubert }, 9358*7f2fe78bSCy Schubert 9359*7f2fe78bSCy Schubert // Creates a full fledged settings object into target 9360*7f2fe78bSCy Schubert // with both ajaxSettings and settings fields. 9361*7f2fe78bSCy Schubert // If target is omitted, writes into ajaxSettings. 9362*7f2fe78bSCy Schubert ajaxSetup: function( target, settings ) { 9363*7f2fe78bSCy Schubert return settings ? 9364*7f2fe78bSCy Schubert 9365*7f2fe78bSCy Schubert // Building a settings object 9366*7f2fe78bSCy Schubert ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) : 9367*7f2fe78bSCy Schubert 9368*7f2fe78bSCy Schubert // Extending ajaxSettings 9369*7f2fe78bSCy Schubert ajaxExtend( jQuery.ajaxSettings, target ); 9370*7f2fe78bSCy Schubert }, 9371*7f2fe78bSCy Schubert 9372*7f2fe78bSCy Schubert ajaxPrefilter: addToPrefiltersOrTransports( prefilters ), 9373*7f2fe78bSCy Schubert ajaxTransport: addToPrefiltersOrTransports( transports ), 9374*7f2fe78bSCy Schubert 9375*7f2fe78bSCy Schubert // Main method 9376*7f2fe78bSCy Schubert ajax: function( url, options ) { 9377*7f2fe78bSCy Schubert 9378*7f2fe78bSCy Schubert // If url is an object, simulate pre-1.5 signature 9379*7f2fe78bSCy Schubert if ( typeof url === "object" ) { 9380*7f2fe78bSCy Schubert options = url; 9381*7f2fe78bSCy Schubert url = undefined; 9382*7f2fe78bSCy Schubert } 9383*7f2fe78bSCy Schubert 9384*7f2fe78bSCy Schubert // Force options to be an object 9385*7f2fe78bSCy Schubert options = options || {}; 9386*7f2fe78bSCy Schubert 9387*7f2fe78bSCy Schubert var transport, 9388*7f2fe78bSCy Schubert 9389*7f2fe78bSCy Schubert // URL without anti-cache param 9390*7f2fe78bSCy Schubert cacheURL, 9391*7f2fe78bSCy Schubert 9392*7f2fe78bSCy Schubert // Response headers 9393*7f2fe78bSCy Schubert responseHeadersString, 9394*7f2fe78bSCy Schubert responseHeaders, 9395*7f2fe78bSCy Schubert 9396*7f2fe78bSCy Schubert // timeout handle 9397*7f2fe78bSCy Schubert timeoutTimer, 9398*7f2fe78bSCy Schubert 9399*7f2fe78bSCy Schubert // Url cleanup var 9400*7f2fe78bSCy Schubert urlAnchor, 9401*7f2fe78bSCy Schubert 9402*7f2fe78bSCy Schubert // Request state (becomes false upon send and true upon completion) 9403*7f2fe78bSCy Schubert completed, 9404*7f2fe78bSCy Schubert 9405*7f2fe78bSCy Schubert // To know if global events are to be dispatched 9406*7f2fe78bSCy Schubert fireGlobals, 9407*7f2fe78bSCy Schubert 9408*7f2fe78bSCy Schubert // Loop variable 9409*7f2fe78bSCy Schubert i, 9410*7f2fe78bSCy Schubert 9411*7f2fe78bSCy Schubert // uncached part of the url 9412*7f2fe78bSCy Schubert uncached, 9413*7f2fe78bSCy Schubert 9414*7f2fe78bSCy Schubert // Create the final options object 9415*7f2fe78bSCy Schubert s = jQuery.ajaxSetup( {}, options ), 9416*7f2fe78bSCy Schubert 9417*7f2fe78bSCy Schubert // Callbacks context 9418*7f2fe78bSCy Schubert callbackContext = s.context || s, 9419*7f2fe78bSCy Schubert 9420*7f2fe78bSCy Schubert // Context for global events is callbackContext if it is a DOM node or jQuery collection 9421*7f2fe78bSCy Schubert globalEventContext = s.context && 9422*7f2fe78bSCy Schubert ( callbackContext.nodeType || callbackContext.jquery ) ? 9423*7f2fe78bSCy Schubert jQuery( callbackContext ) : 9424*7f2fe78bSCy Schubert jQuery.event, 9425*7f2fe78bSCy Schubert 9426*7f2fe78bSCy Schubert // Deferreds 9427*7f2fe78bSCy Schubert deferred = jQuery.Deferred(), 9428*7f2fe78bSCy Schubert completeDeferred = jQuery.Callbacks( "once memory" ), 9429*7f2fe78bSCy Schubert 9430*7f2fe78bSCy Schubert // Status-dependent callbacks 9431*7f2fe78bSCy Schubert statusCode = s.statusCode || {}, 9432*7f2fe78bSCy Schubert 9433*7f2fe78bSCy Schubert // Headers (they are sent all at once) 9434*7f2fe78bSCy Schubert requestHeaders = {}, 9435*7f2fe78bSCy Schubert requestHeadersNames = {}, 9436*7f2fe78bSCy Schubert 9437*7f2fe78bSCy Schubert // Default abort message 9438*7f2fe78bSCy Schubert strAbort = "canceled", 9439*7f2fe78bSCy Schubert 9440*7f2fe78bSCy Schubert // Fake xhr 9441*7f2fe78bSCy Schubert jqXHR = { 9442*7f2fe78bSCy Schubert readyState: 0, 9443*7f2fe78bSCy Schubert 9444*7f2fe78bSCy Schubert // Builds headers hashtable if needed 9445*7f2fe78bSCy Schubert getResponseHeader: function( key ) { 9446*7f2fe78bSCy Schubert var match; 9447*7f2fe78bSCy Schubert if ( completed ) { 9448*7f2fe78bSCy Schubert if ( !responseHeaders ) { 9449*7f2fe78bSCy Schubert responseHeaders = {}; 9450*7f2fe78bSCy Schubert while ( ( match = rheaders.exec( responseHeadersString ) ) ) { 9451*7f2fe78bSCy Schubert responseHeaders[ match[ 1 ].toLowerCase() + " " ] = 9452*7f2fe78bSCy Schubert ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] ) 9453*7f2fe78bSCy Schubert .concat( match[ 2 ] ); 9454*7f2fe78bSCy Schubert } 9455*7f2fe78bSCy Schubert } 9456*7f2fe78bSCy Schubert match = responseHeaders[ key.toLowerCase() + " " ]; 9457*7f2fe78bSCy Schubert } 9458*7f2fe78bSCy Schubert return match == null ? null : match.join( ", " ); 9459*7f2fe78bSCy Schubert }, 9460*7f2fe78bSCy Schubert 9461*7f2fe78bSCy Schubert // Raw string 9462*7f2fe78bSCy Schubert getAllResponseHeaders: function() { 9463*7f2fe78bSCy Schubert return completed ? responseHeadersString : null; 9464*7f2fe78bSCy Schubert }, 9465*7f2fe78bSCy Schubert 9466*7f2fe78bSCy Schubert // Caches the header 9467*7f2fe78bSCy Schubert setRequestHeader: function( name, value ) { 9468*7f2fe78bSCy Schubert if ( completed == null ) { 9469*7f2fe78bSCy Schubert name = requestHeadersNames[ name.toLowerCase() ] = 9470*7f2fe78bSCy Schubert requestHeadersNames[ name.toLowerCase() ] || name; 9471*7f2fe78bSCy Schubert requestHeaders[ name ] = value; 9472*7f2fe78bSCy Schubert } 9473*7f2fe78bSCy Schubert return this; 9474*7f2fe78bSCy Schubert }, 9475*7f2fe78bSCy Schubert 9476*7f2fe78bSCy Schubert // Overrides response content-type header 9477*7f2fe78bSCy Schubert overrideMimeType: function( type ) { 9478*7f2fe78bSCy Schubert if ( completed == null ) { 9479*7f2fe78bSCy Schubert s.mimeType = type; 9480*7f2fe78bSCy Schubert } 9481*7f2fe78bSCy Schubert return this; 9482*7f2fe78bSCy Schubert }, 9483*7f2fe78bSCy Schubert 9484*7f2fe78bSCy Schubert // Status-dependent callbacks 9485*7f2fe78bSCy Schubert statusCode: function( map ) { 9486*7f2fe78bSCy Schubert var code; 9487*7f2fe78bSCy Schubert if ( map ) { 9488*7f2fe78bSCy Schubert if ( completed ) { 9489*7f2fe78bSCy Schubert 9490*7f2fe78bSCy Schubert // Execute the appropriate callbacks 9491*7f2fe78bSCy Schubert jqXHR.always( map[ jqXHR.status ] ); 9492*7f2fe78bSCy Schubert } else { 9493*7f2fe78bSCy Schubert 9494*7f2fe78bSCy Schubert // Lazy-add the new callbacks in a way that preserves old ones 9495*7f2fe78bSCy Schubert for ( code in map ) { 9496*7f2fe78bSCy Schubert statusCode[ code ] = [ statusCode[ code ], map[ code ] ]; 9497*7f2fe78bSCy Schubert } 9498*7f2fe78bSCy Schubert } 9499*7f2fe78bSCy Schubert } 9500*7f2fe78bSCy Schubert return this; 9501*7f2fe78bSCy Schubert }, 9502*7f2fe78bSCy Schubert 9503*7f2fe78bSCy Schubert // Cancel the request 9504*7f2fe78bSCy Schubert abort: function( statusText ) { 9505*7f2fe78bSCy Schubert var finalText = statusText || strAbort; 9506*7f2fe78bSCy Schubert if ( transport ) { 9507*7f2fe78bSCy Schubert transport.abort( finalText ); 9508*7f2fe78bSCy Schubert } 9509*7f2fe78bSCy Schubert done( 0, finalText ); 9510*7f2fe78bSCy Schubert return this; 9511*7f2fe78bSCy Schubert } 9512*7f2fe78bSCy Schubert }; 9513*7f2fe78bSCy Schubert 9514*7f2fe78bSCy Schubert // Attach deferreds 9515*7f2fe78bSCy Schubert deferred.promise( jqXHR ); 9516*7f2fe78bSCy Schubert 9517*7f2fe78bSCy Schubert // Add protocol if not provided (prefilters might expect it) 9518*7f2fe78bSCy Schubert // Handle falsy url in the settings object (#10093: consistency with old signature) 9519*7f2fe78bSCy Schubert // We also use the url parameter if available 9520*7f2fe78bSCy Schubert s.url = ( ( url || s.url || location.href ) + "" ) 9521*7f2fe78bSCy Schubert .replace( rprotocol, location.protocol + "//" ); 9522*7f2fe78bSCy Schubert 9523*7f2fe78bSCy Schubert // Alias method option to type as per ticket #12004 9524*7f2fe78bSCy Schubert s.type = options.method || options.type || s.method || s.type; 9525*7f2fe78bSCy Schubert 9526*7f2fe78bSCy Schubert // Extract dataTypes list 9527*7f2fe78bSCy Schubert s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ]; 9528*7f2fe78bSCy Schubert 9529*7f2fe78bSCy Schubert // A cross-domain request is in order when the origin doesn't match the current origin. 9530*7f2fe78bSCy Schubert if ( s.crossDomain == null ) { 9531*7f2fe78bSCy Schubert urlAnchor = document.createElement( "a" ); 9532*7f2fe78bSCy Schubert 9533*7f2fe78bSCy Schubert // Support: IE <=8 - 11, Edge 12 - 15 9534*7f2fe78bSCy Schubert // IE throws exception on accessing the href property if url is malformed, 9535*7f2fe78bSCy Schubert // e.g. http://example.com:80x/ 9536*7f2fe78bSCy Schubert try { 9537*7f2fe78bSCy Schubert urlAnchor.href = s.url; 9538*7f2fe78bSCy Schubert 9539*7f2fe78bSCy Schubert // Support: IE <=8 - 11 only 9540*7f2fe78bSCy Schubert // Anchor's host property isn't correctly set when s.url is relative 9541*7f2fe78bSCy Schubert urlAnchor.href = urlAnchor.href; 9542*7f2fe78bSCy Schubert s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !== 9543*7f2fe78bSCy Schubert urlAnchor.protocol + "//" + urlAnchor.host; 9544*7f2fe78bSCy Schubert } catch ( e ) { 9545*7f2fe78bSCy Schubert 9546*7f2fe78bSCy Schubert // If there is an error parsing the URL, assume it is crossDomain, 9547*7f2fe78bSCy Schubert // it can be rejected by the transport if it is invalid 9548*7f2fe78bSCy Schubert s.crossDomain = true; 9549*7f2fe78bSCy Schubert } 9550*7f2fe78bSCy Schubert } 9551*7f2fe78bSCy Schubert 9552*7f2fe78bSCy Schubert // Convert data if not already a string 9553*7f2fe78bSCy Schubert if ( s.data && s.processData && typeof s.data !== "string" ) { 9554*7f2fe78bSCy Schubert s.data = jQuery.param( s.data, s.traditional ); 9555*7f2fe78bSCy Schubert } 9556*7f2fe78bSCy Schubert 9557*7f2fe78bSCy Schubert // Apply prefilters 9558*7f2fe78bSCy Schubert inspectPrefiltersOrTransports( prefilters, s, options, jqXHR ); 9559*7f2fe78bSCy Schubert 9560*7f2fe78bSCy Schubert // If request was aborted inside a prefilter, stop there 9561*7f2fe78bSCy Schubert if ( completed ) { 9562*7f2fe78bSCy Schubert return jqXHR; 9563*7f2fe78bSCy Schubert } 9564*7f2fe78bSCy Schubert 9565*7f2fe78bSCy Schubert // We can fire global events as of now if asked to 9566*7f2fe78bSCy Schubert // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118) 9567*7f2fe78bSCy Schubert fireGlobals = jQuery.event && s.global; 9568*7f2fe78bSCy Schubert 9569*7f2fe78bSCy Schubert // Watch for a new set of requests 9570*7f2fe78bSCy Schubert if ( fireGlobals && jQuery.active++ === 0 ) { 9571*7f2fe78bSCy Schubert jQuery.event.trigger( "ajaxStart" ); 9572*7f2fe78bSCy Schubert } 9573*7f2fe78bSCy Schubert 9574*7f2fe78bSCy Schubert // Uppercase the type 9575*7f2fe78bSCy Schubert s.type = s.type.toUpperCase(); 9576*7f2fe78bSCy Schubert 9577*7f2fe78bSCy Schubert // Determine if request has content 9578*7f2fe78bSCy Schubert s.hasContent = !rnoContent.test( s.type ); 9579*7f2fe78bSCy Schubert 9580*7f2fe78bSCy Schubert // Save the URL in case we're toying with the If-Modified-Since 9581*7f2fe78bSCy Schubert // and/or If-None-Match header later on 9582*7f2fe78bSCy Schubert // Remove hash to simplify url manipulation 9583*7f2fe78bSCy Schubert cacheURL = s.url.replace( rhash, "" ); 9584*7f2fe78bSCy Schubert 9585*7f2fe78bSCy Schubert // More options handling for requests with no content 9586*7f2fe78bSCy Schubert if ( !s.hasContent ) { 9587*7f2fe78bSCy Schubert 9588*7f2fe78bSCy Schubert // Remember the hash so we can put it back 9589*7f2fe78bSCy Schubert uncached = s.url.slice( cacheURL.length ); 9590*7f2fe78bSCy Schubert 9591*7f2fe78bSCy Schubert // If data is available and should be processed, append data to url 9592*7f2fe78bSCy Schubert if ( s.data && ( s.processData || typeof s.data === "string" ) ) { 9593*7f2fe78bSCy Schubert cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data; 9594*7f2fe78bSCy Schubert 9595*7f2fe78bSCy Schubert // #9682: remove data so that it's not used in an eventual retry 9596*7f2fe78bSCy Schubert delete s.data; 9597*7f2fe78bSCy Schubert } 9598*7f2fe78bSCy Schubert 9599*7f2fe78bSCy Schubert // Add or update anti-cache param if needed 9600*7f2fe78bSCy Schubert if ( s.cache === false ) { 9601*7f2fe78bSCy Schubert cacheURL = cacheURL.replace( rantiCache, "$1" ); 9602*7f2fe78bSCy Schubert uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce.guid++ ) + 9603*7f2fe78bSCy Schubert uncached; 9604*7f2fe78bSCy Schubert } 9605*7f2fe78bSCy Schubert 9606*7f2fe78bSCy Schubert // Put hash and anti-cache on the URL that will be requested (gh-1732) 9607*7f2fe78bSCy Schubert s.url = cacheURL + uncached; 9608*7f2fe78bSCy Schubert 9609*7f2fe78bSCy Schubert // Change '%20' to '+' if this is encoded form body content (gh-2658) 9610*7f2fe78bSCy Schubert } else if ( s.data && s.processData && 9611*7f2fe78bSCy Schubert ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) { 9612*7f2fe78bSCy Schubert s.data = s.data.replace( r20, "+" ); 9613*7f2fe78bSCy Schubert } 9614*7f2fe78bSCy Schubert 9615*7f2fe78bSCy Schubert // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. 9616*7f2fe78bSCy Schubert if ( s.ifModified ) { 9617*7f2fe78bSCy Schubert if ( jQuery.lastModified[ cacheURL ] ) { 9618*7f2fe78bSCy Schubert jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] ); 9619*7f2fe78bSCy Schubert } 9620*7f2fe78bSCy Schubert if ( jQuery.etag[ cacheURL ] ) { 9621*7f2fe78bSCy Schubert jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] ); 9622*7f2fe78bSCy Schubert } 9623*7f2fe78bSCy Schubert } 9624*7f2fe78bSCy Schubert 9625*7f2fe78bSCy Schubert // Set the correct header, if data is being sent 9626*7f2fe78bSCy Schubert if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) { 9627*7f2fe78bSCy Schubert jqXHR.setRequestHeader( "Content-Type", s.contentType ); 9628*7f2fe78bSCy Schubert } 9629*7f2fe78bSCy Schubert 9630*7f2fe78bSCy Schubert // Set the Accepts header for the server, depending on the dataType 9631*7f2fe78bSCy Schubert jqXHR.setRequestHeader( 9632*7f2fe78bSCy Schubert "Accept", 9633*7f2fe78bSCy Schubert s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ? 9634*7f2fe78bSCy Schubert s.accepts[ s.dataTypes[ 0 ] ] + 9635*7f2fe78bSCy Schubert ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) : 9636*7f2fe78bSCy Schubert s.accepts[ "*" ] 9637*7f2fe78bSCy Schubert ); 9638*7f2fe78bSCy Schubert 9639*7f2fe78bSCy Schubert // Check for headers option 9640*7f2fe78bSCy Schubert for ( i in s.headers ) { 9641*7f2fe78bSCy Schubert jqXHR.setRequestHeader( i, s.headers[ i ] ); 9642*7f2fe78bSCy Schubert } 9643*7f2fe78bSCy Schubert 9644*7f2fe78bSCy Schubert // Allow custom headers/mimetypes and early abort 9645*7f2fe78bSCy Schubert if ( s.beforeSend && 9646*7f2fe78bSCy Schubert ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) { 9647*7f2fe78bSCy Schubert 9648*7f2fe78bSCy Schubert // Abort if not done already and return 9649*7f2fe78bSCy Schubert return jqXHR.abort(); 9650*7f2fe78bSCy Schubert } 9651*7f2fe78bSCy Schubert 9652*7f2fe78bSCy Schubert // Aborting is no longer a cancellation 9653*7f2fe78bSCy Schubert strAbort = "abort"; 9654*7f2fe78bSCy Schubert 9655*7f2fe78bSCy Schubert // Install callbacks on deferreds 9656*7f2fe78bSCy Schubert completeDeferred.add( s.complete ); 9657*7f2fe78bSCy Schubert jqXHR.done( s.success ); 9658*7f2fe78bSCy Schubert jqXHR.fail( s.error ); 9659*7f2fe78bSCy Schubert 9660*7f2fe78bSCy Schubert // Get transport 9661*7f2fe78bSCy Schubert transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR ); 9662*7f2fe78bSCy Schubert 9663*7f2fe78bSCy Schubert // If no transport, we auto-abort 9664*7f2fe78bSCy Schubert if ( !transport ) { 9665*7f2fe78bSCy Schubert done( -1, "No Transport" ); 9666*7f2fe78bSCy Schubert } else { 9667*7f2fe78bSCy Schubert jqXHR.readyState = 1; 9668*7f2fe78bSCy Schubert 9669*7f2fe78bSCy Schubert // Send global event 9670*7f2fe78bSCy Schubert if ( fireGlobals ) { 9671*7f2fe78bSCy Schubert globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] ); 9672*7f2fe78bSCy Schubert } 9673*7f2fe78bSCy Schubert 9674*7f2fe78bSCy Schubert // If request was aborted inside ajaxSend, stop there 9675*7f2fe78bSCy Schubert if ( completed ) { 9676*7f2fe78bSCy Schubert return jqXHR; 9677*7f2fe78bSCy Schubert } 9678*7f2fe78bSCy Schubert 9679*7f2fe78bSCy Schubert // Timeout 9680*7f2fe78bSCy Schubert if ( s.async && s.timeout > 0 ) { 9681*7f2fe78bSCy Schubert timeoutTimer = window.setTimeout( function() { 9682*7f2fe78bSCy Schubert jqXHR.abort( "timeout" ); 9683*7f2fe78bSCy Schubert }, s.timeout ); 9684*7f2fe78bSCy Schubert } 9685*7f2fe78bSCy Schubert 9686*7f2fe78bSCy Schubert try { 9687*7f2fe78bSCy Schubert completed = false; 9688*7f2fe78bSCy Schubert transport.send( requestHeaders, done ); 9689*7f2fe78bSCy Schubert } catch ( e ) { 9690*7f2fe78bSCy Schubert 9691*7f2fe78bSCy Schubert // Rethrow post-completion exceptions 9692*7f2fe78bSCy Schubert if ( completed ) { 9693*7f2fe78bSCy Schubert throw e; 9694*7f2fe78bSCy Schubert } 9695*7f2fe78bSCy Schubert 9696*7f2fe78bSCy Schubert // Propagate others as results 9697*7f2fe78bSCy Schubert done( -1, e ); 9698*7f2fe78bSCy Schubert } 9699*7f2fe78bSCy Schubert } 9700*7f2fe78bSCy Schubert 9701*7f2fe78bSCy Schubert // Callback for when everything is done 9702*7f2fe78bSCy Schubert function done( status, nativeStatusText, responses, headers ) { 9703*7f2fe78bSCy Schubert var isSuccess, success, error, response, modified, 9704*7f2fe78bSCy Schubert statusText = nativeStatusText; 9705*7f2fe78bSCy Schubert 9706*7f2fe78bSCy Schubert // Ignore repeat invocations 9707*7f2fe78bSCy Schubert if ( completed ) { 9708*7f2fe78bSCy Schubert return; 9709*7f2fe78bSCy Schubert } 9710*7f2fe78bSCy Schubert 9711*7f2fe78bSCy Schubert completed = true; 9712*7f2fe78bSCy Schubert 9713*7f2fe78bSCy Schubert // Clear timeout if it exists 9714*7f2fe78bSCy Schubert if ( timeoutTimer ) { 9715*7f2fe78bSCy Schubert window.clearTimeout( timeoutTimer ); 9716*7f2fe78bSCy Schubert } 9717*7f2fe78bSCy Schubert 9718*7f2fe78bSCy Schubert // Dereference transport for early garbage collection 9719*7f2fe78bSCy Schubert // (no matter how long the jqXHR object will be used) 9720*7f2fe78bSCy Schubert transport = undefined; 9721*7f2fe78bSCy Schubert 9722*7f2fe78bSCy Schubert // Cache response headers 9723*7f2fe78bSCy Schubert responseHeadersString = headers || ""; 9724*7f2fe78bSCy Schubert 9725*7f2fe78bSCy Schubert // Set readyState 9726*7f2fe78bSCy Schubert jqXHR.readyState = status > 0 ? 4 : 0; 9727*7f2fe78bSCy Schubert 9728*7f2fe78bSCy Schubert // Determine if successful 9729*7f2fe78bSCy Schubert isSuccess = status >= 200 && status < 300 || status === 304; 9730*7f2fe78bSCy Schubert 9731*7f2fe78bSCy Schubert // Get response data 9732*7f2fe78bSCy Schubert if ( responses ) { 9733*7f2fe78bSCy Schubert response = ajaxHandleResponses( s, jqXHR, responses ); 9734*7f2fe78bSCy Schubert } 9735*7f2fe78bSCy Schubert 9736*7f2fe78bSCy Schubert // Use a noop converter for missing script but not if jsonp 9737*7f2fe78bSCy Schubert if ( !isSuccess && 9738*7f2fe78bSCy Schubert jQuery.inArray( "script", s.dataTypes ) > -1 && 9739*7f2fe78bSCy Schubert jQuery.inArray( "json", s.dataTypes ) < 0 ) { 9740*7f2fe78bSCy Schubert s.converters[ "text script" ] = function() {}; 9741*7f2fe78bSCy Schubert } 9742*7f2fe78bSCy Schubert 9743*7f2fe78bSCy Schubert // Convert no matter what (that way responseXXX fields are always set) 9744*7f2fe78bSCy Schubert response = ajaxConvert( s, response, jqXHR, isSuccess ); 9745*7f2fe78bSCy Schubert 9746*7f2fe78bSCy Schubert // If successful, handle type chaining 9747*7f2fe78bSCy Schubert if ( isSuccess ) { 9748*7f2fe78bSCy Schubert 9749*7f2fe78bSCy Schubert // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. 9750*7f2fe78bSCy Schubert if ( s.ifModified ) { 9751*7f2fe78bSCy Schubert modified = jqXHR.getResponseHeader( "Last-Modified" ); 9752*7f2fe78bSCy Schubert if ( modified ) { 9753*7f2fe78bSCy Schubert jQuery.lastModified[ cacheURL ] = modified; 9754*7f2fe78bSCy Schubert } 9755*7f2fe78bSCy Schubert modified = jqXHR.getResponseHeader( "etag" ); 9756*7f2fe78bSCy Schubert if ( modified ) { 9757*7f2fe78bSCy Schubert jQuery.etag[ cacheURL ] = modified; 9758*7f2fe78bSCy Schubert } 9759*7f2fe78bSCy Schubert } 9760*7f2fe78bSCy Schubert 9761*7f2fe78bSCy Schubert // if no content 9762*7f2fe78bSCy Schubert if ( status === 204 || s.type === "HEAD" ) { 9763*7f2fe78bSCy Schubert statusText = "nocontent"; 9764*7f2fe78bSCy Schubert 9765*7f2fe78bSCy Schubert // if not modified 9766*7f2fe78bSCy Schubert } else if ( status === 304 ) { 9767*7f2fe78bSCy Schubert statusText = "notmodified"; 9768*7f2fe78bSCy Schubert 9769*7f2fe78bSCy Schubert // If we have data, let's convert it 9770*7f2fe78bSCy Schubert } else { 9771*7f2fe78bSCy Schubert statusText = response.state; 9772*7f2fe78bSCy Schubert success = response.data; 9773*7f2fe78bSCy Schubert error = response.error; 9774*7f2fe78bSCy Schubert isSuccess = !error; 9775*7f2fe78bSCy Schubert } 9776*7f2fe78bSCy Schubert } else { 9777*7f2fe78bSCy Schubert 9778*7f2fe78bSCy Schubert // Extract error from statusText and normalize for non-aborts 9779*7f2fe78bSCy Schubert error = statusText; 9780*7f2fe78bSCy Schubert if ( status || !statusText ) { 9781*7f2fe78bSCy Schubert statusText = "error"; 9782*7f2fe78bSCy Schubert if ( status < 0 ) { 9783*7f2fe78bSCy Schubert status = 0; 9784*7f2fe78bSCy Schubert } 9785*7f2fe78bSCy Schubert } 9786*7f2fe78bSCy Schubert } 9787*7f2fe78bSCy Schubert 9788*7f2fe78bSCy Schubert // Set data for the fake xhr object 9789*7f2fe78bSCy Schubert jqXHR.status = status; 9790*7f2fe78bSCy Schubert jqXHR.statusText = ( nativeStatusText || statusText ) + ""; 9791*7f2fe78bSCy Schubert 9792*7f2fe78bSCy Schubert // Success/Error 9793*7f2fe78bSCy Schubert if ( isSuccess ) { 9794*7f2fe78bSCy Schubert deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] ); 9795*7f2fe78bSCy Schubert } else { 9796*7f2fe78bSCy Schubert deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] ); 9797*7f2fe78bSCy Schubert } 9798*7f2fe78bSCy Schubert 9799*7f2fe78bSCy Schubert // Status-dependent callbacks 9800*7f2fe78bSCy Schubert jqXHR.statusCode( statusCode ); 9801*7f2fe78bSCy Schubert statusCode = undefined; 9802*7f2fe78bSCy Schubert 9803*7f2fe78bSCy Schubert if ( fireGlobals ) { 9804*7f2fe78bSCy Schubert globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError", 9805*7f2fe78bSCy Schubert [ jqXHR, s, isSuccess ? success : error ] ); 9806*7f2fe78bSCy Schubert } 9807*7f2fe78bSCy Schubert 9808*7f2fe78bSCy Schubert // Complete 9809*7f2fe78bSCy Schubert completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] ); 9810*7f2fe78bSCy Schubert 9811*7f2fe78bSCy Schubert if ( fireGlobals ) { 9812*7f2fe78bSCy Schubert globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] ); 9813*7f2fe78bSCy Schubert 9814*7f2fe78bSCy Schubert // Handle the global AJAX counter 9815*7f2fe78bSCy Schubert if ( !( --jQuery.active ) ) { 9816*7f2fe78bSCy Schubert jQuery.event.trigger( "ajaxStop" ); 9817*7f2fe78bSCy Schubert } 9818*7f2fe78bSCy Schubert } 9819*7f2fe78bSCy Schubert } 9820*7f2fe78bSCy Schubert 9821*7f2fe78bSCy Schubert return jqXHR; 9822*7f2fe78bSCy Schubert }, 9823*7f2fe78bSCy Schubert 9824*7f2fe78bSCy Schubert getJSON: function( url, data, callback ) { 9825*7f2fe78bSCy Schubert return jQuery.get( url, data, callback, "json" ); 9826*7f2fe78bSCy Schubert }, 9827*7f2fe78bSCy Schubert 9828*7f2fe78bSCy Schubert getScript: function( url, callback ) { 9829*7f2fe78bSCy Schubert return jQuery.get( url, undefined, callback, "script" ); 9830*7f2fe78bSCy Schubert } 9831*7f2fe78bSCy Schubert} ); 9832*7f2fe78bSCy Schubert 9833*7f2fe78bSCy SchubertjQuery.each( [ "get", "post" ], function( _i, method ) { 9834*7f2fe78bSCy Schubert jQuery[ method ] = function( url, data, callback, type ) { 9835*7f2fe78bSCy Schubert 9836*7f2fe78bSCy Schubert // Shift arguments if data argument was omitted 9837*7f2fe78bSCy Schubert if ( isFunction( data ) ) { 9838*7f2fe78bSCy Schubert type = type || callback; 9839*7f2fe78bSCy Schubert callback = data; 9840*7f2fe78bSCy Schubert data = undefined; 9841*7f2fe78bSCy Schubert } 9842*7f2fe78bSCy Schubert 9843*7f2fe78bSCy Schubert // The url can be an options object (which then must have .url) 9844*7f2fe78bSCy Schubert return jQuery.ajax( jQuery.extend( { 9845*7f2fe78bSCy Schubert url: url, 9846*7f2fe78bSCy Schubert type: method, 9847*7f2fe78bSCy Schubert dataType: type, 9848*7f2fe78bSCy Schubert data: data, 9849*7f2fe78bSCy Schubert success: callback 9850*7f2fe78bSCy Schubert }, jQuery.isPlainObject( url ) && url ) ); 9851*7f2fe78bSCy Schubert }; 9852*7f2fe78bSCy Schubert} ); 9853*7f2fe78bSCy Schubert 9854*7f2fe78bSCy SchubertjQuery.ajaxPrefilter( function( s ) { 9855*7f2fe78bSCy Schubert var i; 9856*7f2fe78bSCy Schubert for ( i in s.headers ) { 9857*7f2fe78bSCy Schubert if ( i.toLowerCase() === "content-type" ) { 9858*7f2fe78bSCy Schubert s.contentType = s.headers[ i ] || ""; 9859*7f2fe78bSCy Schubert } 9860*7f2fe78bSCy Schubert } 9861*7f2fe78bSCy Schubert} ); 9862*7f2fe78bSCy Schubert 9863*7f2fe78bSCy Schubert 9864*7f2fe78bSCy SchubertjQuery._evalUrl = function( url, options, doc ) { 9865*7f2fe78bSCy Schubert return jQuery.ajax( { 9866*7f2fe78bSCy Schubert url: url, 9867*7f2fe78bSCy Schubert 9868*7f2fe78bSCy Schubert // Make this explicit, since user can override this through ajaxSetup (#11264) 9869*7f2fe78bSCy Schubert type: "GET", 9870*7f2fe78bSCy Schubert dataType: "script", 9871*7f2fe78bSCy Schubert cache: true, 9872*7f2fe78bSCy Schubert async: false, 9873*7f2fe78bSCy Schubert global: false, 9874*7f2fe78bSCy Schubert 9875*7f2fe78bSCy Schubert // Only evaluate the response if it is successful (gh-4126) 9876*7f2fe78bSCy Schubert // dataFilter is not invoked for failure responses, so using it instead 9877*7f2fe78bSCy Schubert // of the default converter is kludgy but it works. 9878*7f2fe78bSCy Schubert converters: { 9879*7f2fe78bSCy Schubert "text script": function() {} 9880*7f2fe78bSCy Schubert }, 9881*7f2fe78bSCy Schubert dataFilter: function( response ) { 9882*7f2fe78bSCy Schubert jQuery.globalEval( response, options, doc ); 9883*7f2fe78bSCy Schubert } 9884*7f2fe78bSCy Schubert } ); 9885*7f2fe78bSCy Schubert}; 9886*7f2fe78bSCy Schubert 9887*7f2fe78bSCy Schubert 9888*7f2fe78bSCy SchubertjQuery.fn.extend( { 9889*7f2fe78bSCy Schubert wrapAll: function( html ) { 9890*7f2fe78bSCy Schubert var wrap; 9891*7f2fe78bSCy Schubert 9892*7f2fe78bSCy Schubert if ( this[ 0 ] ) { 9893*7f2fe78bSCy Schubert if ( isFunction( html ) ) { 9894*7f2fe78bSCy Schubert html = html.call( this[ 0 ] ); 9895*7f2fe78bSCy Schubert } 9896*7f2fe78bSCy Schubert 9897*7f2fe78bSCy Schubert // The elements to wrap the target around 9898*7f2fe78bSCy Schubert wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true ); 9899*7f2fe78bSCy Schubert 9900*7f2fe78bSCy Schubert if ( this[ 0 ].parentNode ) { 9901*7f2fe78bSCy Schubert wrap.insertBefore( this[ 0 ] ); 9902*7f2fe78bSCy Schubert } 9903*7f2fe78bSCy Schubert 9904*7f2fe78bSCy Schubert wrap.map( function() { 9905*7f2fe78bSCy Schubert var elem = this; 9906*7f2fe78bSCy Schubert 9907*7f2fe78bSCy Schubert while ( elem.firstElementChild ) { 9908*7f2fe78bSCy Schubert elem = elem.firstElementChild; 9909*7f2fe78bSCy Schubert } 9910*7f2fe78bSCy Schubert 9911*7f2fe78bSCy Schubert return elem; 9912*7f2fe78bSCy Schubert } ).append( this ); 9913*7f2fe78bSCy Schubert } 9914*7f2fe78bSCy Schubert 9915*7f2fe78bSCy Schubert return this; 9916*7f2fe78bSCy Schubert }, 9917*7f2fe78bSCy Schubert 9918*7f2fe78bSCy Schubert wrapInner: function( html ) { 9919*7f2fe78bSCy Schubert if ( isFunction( html ) ) { 9920*7f2fe78bSCy Schubert return this.each( function( i ) { 9921*7f2fe78bSCy Schubert jQuery( this ).wrapInner( html.call( this, i ) ); 9922*7f2fe78bSCy Schubert } ); 9923*7f2fe78bSCy Schubert } 9924*7f2fe78bSCy Schubert 9925*7f2fe78bSCy Schubert return this.each( function() { 9926*7f2fe78bSCy Schubert var self = jQuery( this ), 9927*7f2fe78bSCy Schubert contents = self.contents(); 9928*7f2fe78bSCy Schubert 9929*7f2fe78bSCy Schubert if ( contents.length ) { 9930*7f2fe78bSCy Schubert contents.wrapAll( html ); 9931*7f2fe78bSCy Schubert 9932*7f2fe78bSCy Schubert } else { 9933*7f2fe78bSCy Schubert self.append( html ); 9934*7f2fe78bSCy Schubert } 9935*7f2fe78bSCy Schubert } ); 9936*7f2fe78bSCy Schubert }, 9937*7f2fe78bSCy Schubert 9938*7f2fe78bSCy Schubert wrap: function( html ) { 9939*7f2fe78bSCy Schubert var htmlIsFunction = isFunction( html ); 9940*7f2fe78bSCy Schubert 9941*7f2fe78bSCy Schubert return this.each( function( i ) { 9942*7f2fe78bSCy Schubert jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html ); 9943*7f2fe78bSCy Schubert } ); 9944*7f2fe78bSCy Schubert }, 9945*7f2fe78bSCy Schubert 9946*7f2fe78bSCy Schubert unwrap: function( selector ) { 9947*7f2fe78bSCy Schubert this.parent( selector ).not( "body" ).each( function() { 9948*7f2fe78bSCy Schubert jQuery( this ).replaceWith( this.childNodes ); 9949*7f2fe78bSCy Schubert } ); 9950*7f2fe78bSCy Schubert return this; 9951*7f2fe78bSCy Schubert } 9952*7f2fe78bSCy Schubert} ); 9953*7f2fe78bSCy Schubert 9954*7f2fe78bSCy Schubert 9955*7f2fe78bSCy SchubertjQuery.expr.pseudos.hidden = function( elem ) { 9956*7f2fe78bSCy Schubert return !jQuery.expr.pseudos.visible( elem ); 9957*7f2fe78bSCy Schubert}; 9958*7f2fe78bSCy SchubertjQuery.expr.pseudos.visible = function( elem ) { 9959*7f2fe78bSCy Schubert return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length ); 9960*7f2fe78bSCy Schubert}; 9961*7f2fe78bSCy Schubert 9962*7f2fe78bSCy Schubert 9963*7f2fe78bSCy Schubert 9964*7f2fe78bSCy Schubert 9965*7f2fe78bSCy SchubertjQuery.ajaxSettings.xhr = function() { 9966*7f2fe78bSCy Schubert try { 9967*7f2fe78bSCy Schubert return new window.XMLHttpRequest(); 9968*7f2fe78bSCy Schubert } catch ( e ) {} 9969*7f2fe78bSCy Schubert}; 9970*7f2fe78bSCy Schubert 9971*7f2fe78bSCy Schubertvar xhrSuccessStatus = { 9972*7f2fe78bSCy Schubert 9973*7f2fe78bSCy Schubert // File protocol always yields status code 0, assume 200 9974*7f2fe78bSCy Schubert 0: 200, 9975*7f2fe78bSCy Schubert 9976*7f2fe78bSCy Schubert // Support: IE <=9 only 9977*7f2fe78bSCy Schubert // #1450: sometimes IE returns 1223 when it should be 204 9978*7f2fe78bSCy Schubert 1223: 204 9979*7f2fe78bSCy Schubert }, 9980*7f2fe78bSCy Schubert xhrSupported = jQuery.ajaxSettings.xhr(); 9981*7f2fe78bSCy Schubert 9982*7f2fe78bSCy Schubertsupport.cors = !!xhrSupported && ( "withCredentials" in xhrSupported ); 9983*7f2fe78bSCy Schubertsupport.ajax = xhrSupported = !!xhrSupported; 9984*7f2fe78bSCy Schubert 9985*7f2fe78bSCy SchubertjQuery.ajaxTransport( function( options ) { 9986*7f2fe78bSCy Schubert var callback, errorCallback; 9987*7f2fe78bSCy Schubert 9988*7f2fe78bSCy Schubert // Cross domain only allowed if supported through XMLHttpRequest 9989*7f2fe78bSCy Schubert if ( support.cors || xhrSupported && !options.crossDomain ) { 9990*7f2fe78bSCy Schubert return { 9991*7f2fe78bSCy Schubert send: function( headers, complete ) { 9992*7f2fe78bSCy Schubert var i, 9993*7f2fe78bSCy Schubert xhr = options.xhr(); 9994*7f2fe78bSCy Schubert 9995*7f2fe78bSCy Schubert xhr.open( 9996*7f2fe78bSCy Schubert options.type, 9997*7f2fe78bSCy Schubert options.url, 9998*7f2fe78bSCy Schubert options.async, 9999*7f2fe78bSCy Schubert options.username, 10000*7f2fe78bSCy Schubert options.password 10001*7f2fe78bSCy Schubert ); 10002*7f2fe78bSCy Schubert 10003*7f2fe78bSCy Schubert // Apply custom fields if provided 10004*7f2fe78bSCy Schubert if ( options.xhrFields ) { 10005*7f2fe78bSCy Schubert for ( i in options.xhrFields ) { 10006*7f2fe78bSCy Schubert xhr[ i ] = options.xhrFields[ i ]; 10007*7f2fe78bSCy Schubert } 10008*7f2fe78bSCy Schubert } 10009*7f2fe78bSCy Schubert 10010*7f2fe78bSCy Schubert // Override mime type if needed 10011*7f2fe78bSCy Schubert if ( options.mimeType && xhr.overrideMimeType ) { 10012*7f2fe78bSCy Schubert xhr.overrideMimeType( options.mimeType ); 10013*7f2fe78bSCy Schubert } 10014*7f2fe78bSCy Schubert 10015*7f2fe78bSCy Schubert // X-Requested-With header 10016*7f2fe78bSCy Schubert // For cross-domain requests, seeing as conditions for a preflight are 10017*7f2fe78bSCy Schubert // akin to a jigsaw puzzle, we simply never set it to be sure. 10018*7f2fe78bSCy Schubert // (it can always be set on a per-request basis or even using ajaxSetup) 10019*7f2fe78bSCy Schubert // For same-domain requests, won't change header if already provided. 10020*7f2fe78bSCy Schubert if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) { 10021*7f2fe78bSCy Schubert headers[ "X-Requested-With" ] = "XMLHttpRequest"; 10022*7f2fe78bSCy Schubert } 10023*7f2fe78bSCy Schubert 10024*7f2fe78bSCy Schubert // Set headers 10025*7f2fe78bSCy Schubert for ( i in headers ) { 10026*7f2fe78bSCy Schubert xhr.setRequestHeader( i, headers[ i ] ); 10027*7f2fe78bSCy Schubert } 10028*7f2fe78bSCy Schubert 10029*7f2fe78bSCy Schubert // Callback 10030*7f2fe78bSCy Schubert callback = function( type ) { 10031*7f2fe78bSCy Schubert return function() { 10032*7f2fe78bSCy Schubert if ( callback ) { 10033*7f2fe78bSCy Schubert callback = errorCallback = xhr.onload = 10034*7f2fe78bSCy Schubert xhr.onerror = xhr.onabort = xhr.ontimeout = 10035*7f2fe78bSCy Schubert xhr.onreadystatechange = null; 10036*7f2fe78bSCy Schubert 10037*7f2fe78bSCy Schubert if ( type === "abort" ) { 10038*7f2fe78bSCy Schubert xhr.abort(); 10039*7f2fe78bSCy Schubert } else if ( type === "error" ) { 10040*7f2fe78bSCy Schubert 10041*7f2fe78bSCy Schubert // Support: IE <=9 only 10042*7f2fe78bSCy Schubert // On a manual native abort, IE9 throws 10043*7f2fe78bSCy Schubert // errors on any property access that is not readyState 10044*7f2fe78bSCy Schubert if ( typeof xhr.status !== "number" ) { 10045*7f2fe78bSCy Schubert complete( 0, "error" ); 10046*7f2fe78bSCy Schubert } else { 10047*7f2fe78bSCy Schubert complete( 10048*7f2fe78bSCy Schubert 10049*7f2fe78bSCy Schubert // File: protocol always yields status 0; see #8605, #14207 10050*7f2fe78bSCy Schubert xhr.status, 10051*7f2fe78bSCy Schubert xhr.statusText 10052*7f2fe78bSCy Schubert ); 10053*7f2fe78bSCy Schubert } 10054*7f2fe78bSCy Schubert } else { 10055*7f2fe78bSCy Schubert complete( 10056*7f2fe78bSCy Schubert xhrSuccessStatus[ xhr.status ] || xhr.status, 10057*7f2fe78bSCy Schubert xhr.statusText, 10058*7f2fe78bSCy Schubert 10059*7f2fe78bSCy Schubert // Support: IE <=9 only 10060*7f2fe78bSCy Schubert // IE9 has no XHR2 but throws on binary (trac-11426) 10061*7f2fe78bSCy Schubert // For XHR2 non-text, let the caller handle it (gh-2498) 10062*7f2fe78bSCy Schubert ( xhr.responseType || "text" ) !== "text" || 10063*7f2fe78bSCy Schubert typeof xhr.responseText !== "string" ? 10064*7f2fe78bSCy Schubert { binary: xhr.response } : 10065*7f2fe78bSCy Schubert { text: xhr.responseText }, 10066*7f2fe78bSCy Schubert xhr.getAllResponseHeaders() 10067*7f2fe78bSCy Schubert ); 10068*7f2fe78bSCy Schubert } 10069*7f2fe78bSCy Schubert } 10070*7f2fe78bSCy Schubert }; 10071*7f2fe78bSCy Schubert }; 10072*7f2fe78bSCy Schubert 10073*7f2fe78bSCy Schubert // Listen to events 10074*7f2fe78bSCy Schubert xhr.onload = callback(); 10075*7f2fe78bSCy Schubert errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" ); 10076*7f2fe78bSCy Schubert 10077*7f2fe78bSCy Schubert // Support: IE 9 only 10078*7f2fe78bSCy Schubert // Use onreadystatechange to replace onabort 10079*7f2fe78bSCy Schubert // to handle uncaught aborts 10080*7f2fe78bSCy Schubert if ( xhr.onabort !== undefined ) { 10081*7f2fe78bSCy Schubert xhr.onabort = errorCallback; 10082*7f2fe78bSCy Schubert } else { 10083*7f2fe78bSCy Schubert xhr.onreadystatechange = function() { 10084*7f2fe78bSCy Schubert 10085*7f2fe78bSCy Schubert // Check readyState before timeout as it changes 10086*7f2fe78bSCy Schubert if ( xhr.readyState === 4 ) { 10087*7f2fe78bSCy Schubert 10088*7f2fe78bSCy Schubert // Allow onerror to be called first, 10089*7f2fe78bSCy Schubert // but that will not handle a native abort 10090*7f2fe78bSCy Schubert // Also, save errorCallback to a variable 10091*7f2fe78bSCy Schubert // as xhr.onerror cannot be accessed 10092*7f2fe78bSCy Schubert window.setTimeout( function() { 10093*7f2fe78bSCy Schubert if ( callback ) { 10094*7f2fe78bSCy Schubert errorCallback(); 10095*7f2fe78bSCy Schubert } 10096*7f2fe78bSCy Schubert } ); 10097*7f2fe78bSCy Schubert } 10098*7f2fe78bSCy Schubert }; 10099*7f2fe78bSCy Schubert } 10100*7f2fe78bSCy Schubert 10101*7f2fe78bSCy Schubert // Create the abort callback 10102*7f2fe78bSCy Schubert callback = callback( "abort" ); 10103*7f2fe78bSCy Schubert 10104*7f2fe78bSCy Schubert try { 10105*7f2fe78bSCy Schubert 10106*7f2fe78bSCy Schubert // Do send the request (this may raise an exception) 10107*7f2fe78bSCy Schubert xhr.send( options.hasContent && options.data || null ); 10108*7f2fe78bSCy Schubert } catch ( e ) { 10109*7f2fe78bSCy Schubert 10110*7f2fe78bSCy Schubert // #14683: Only rethrow if this hasn't been notified as an error yet 10111*7f2fe78bSCy Schubert if ( callback ) { 10112*7f2fe78bSCy Schubert throw e; 10113*7f2fe78bSCy Schubert } 10114*7f2fe78bSCy Schubert } 10115*7f2fe78bSCy Schubert }, 10116*7f2fe78bSCy Schubert 10117*7f2fe78bSCy Schubert abort: function() { 10118*7f2fe78bSCy Schubert if ( callback ) { 10119*7f2fe78bSCy Schubert callback(); 10120*7f2fe78bSCy Schubert } 10121*7f2fe78bSCy Schubert } 10122*7f2fe78bSCy Schubert }; 10123*7f2fe78bSCy Schubert } 10124*7f2fe78bSCy Schubert} ); 10125*7f2fe78bSCy Schubert 10126*7f2fe78bSCy Schubert 10127*7f2fe78bSCy Schubert 10128*7f2fe78bSCy Schubert 10129*7f2fe78bSCy Schubert// Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432) 10130*7f2fe78bSCy SchubertjQuery.ajaxPrefilter( function( s ) { 10131*7f2fe78bSCy Schubert if ( s.crossDomain ) { 10132*7f2fe78bSCy Schubert s.contents.script = false; 10133*7f2fe78bSCy Schubert } 10134*7f2fe78bSCy Schubert} ); 10135*7f2fe78bSCy Schubert 10136*7f2fe78bSCy Schubert// Install script dataType 10137*7f2fe78bSCy SchubertjQuery.ajaxSetup( { 10138*7f2fe78bSCy Schubert accepts: { 10139*7f2fe78bSCy Schubert script: "text/javascript, application/javascript, " + 10140*7f2fe78bSCy Schubert "application/ecmascript, application/x-ecmascript" 10141*7f2fe78bSCy Schubert }, 10142*7f2fe78bSCy Schubert contents: { 10143*7f2fe78bSCy Schubert script: /\b(?:java|ecma)script\b/ 10144*7f2fe78bSCy Schubert }, 10145*7f2fe78bSCy Schubert converters: { 10146*7f2fe78bSCy Schubert "text script": function( text ) { 10147*7f2fe78bSCy Schubert jQuery.globalEval( text ); 10148*7f2fe78bSCy Schubert return text; 10149*7f2fe78bSCy Schubert } 10150*7f2fe78bSCy Schubert } 10151*7f2fe78bSCy Schubert} ); 10152*7f2fe78bSCy Schubert 10153*7f2fe78bSCy Schubert// Handle cache's special case and crossDomain 10154*7f2fe78bSCy SchubertjQuery.ajaxPrefilter( "script", function( s ) { 10155*7f2fe78bSCy Schubert if ( s.cache === undefined ) { 10156*7f2fe78bSCy Schubert s.cache = false; 10157*7f2fe78bSCy Schubert } 10158*7f2fe78bSCy Schubert if ( s.crossDomain ) { 10159*7f2fe78bSCy Schubert s.type = "GET"; 10160*7f2fe78bSCy Schubert } 10161*7f2fe78bSCy Schubert} ); 10162*7f2fe78bSCy Schubert 10163*7f2fe78bSCy Schubert// Bind script tag hack transport 10164*7f2fe78bSCy SchubertjQuery.ajaxTransport( "script", function( s ) { 10165*7f2fe78bSCy Schubert 10166*7f2fe78bSCy Schubert // This transport only deals with cross domain or forced-by-attrs requests 10167*7f2fe78bSCy Schubert if ( s.crossDomain || s.scriptAttrs ) { 10168*7f2fe78bSCy Schubert var script, callback; 10169*7f2fe78bSCy Schubert return { 10170*7f2fe78bSCy Schubert send: function( _, complete ) { 10171*7f2fe78bSCy Schubert script = jQuery( "<script>" ) 10172*7f2fe78bSCy Schubert .attr( s.scriptAttrs || {} ) 10173*7f2fe78bSCy Schubert .prop( { charset: s.scriptCharset, src: s.url } ) 10174*7f2fe78bSCy Schubert .on( "load error", callback = function( evt ) { 10175*7f2fe78bSCy Schubert script.remove(); 10176*7f2fe78bSCy Schubert callback = null; 10177*7f2fe78bSCy Schubert if ( evt ) { 10178*7f2fe78bSCy Schubert complete( evt.type === "error" ? 404 : 200, evt.type ); 10179*7f2fe78bSCy Schubert } 10180*7f2fe78bSCy Schubert } ); 10181*7f2fe78bSCy Schubert 10182*7f2fe78bSCy Schubert // Use native DOM manipulation to avoid our domManip AJAX trickery 10183*7f2fe78bSCy Schubert document.head.appendChild( script[ 0 ] ); 10184*7f2fe78bSCy Schubert }, 10185*7f2fe78bSCy Schubert abort: function() { 10186*7f2fe78bSCy Schubert if ( callback ) { 10187*7f2fe78bSCy Schubert callback(); 10188*7f2fe78bSCy Schubert } 10189*7f2fe78bSCy Schubert } 10190*7f2fe78bSCy Schubert }; 10191*7f2fe78bSCy Schubert } 10192*7f2fe78bSCy Schubert} ); 10193*7f2fe78bSCy Schubert 10194*7f2fe78bSCy Schubert 10195*7f2fe78bSCy Schubert 10196*7f2fe78bSCy Schubert 10197*7f2fe78bSCy Schubertvar oldCallbacks = [], 10198*7f2fe78bSCy Schubert rjsonp = /(=)\?(?=&|$)|\?\?/; 10199*7f2fe78bSCy Schubert 10200*7f2fe78bSCy Schubert// Default jsonp settings 10201*7f2fe78bSCy SchubertjQuery.ajaxSetup( { 10202*7f2fe78bSCy Schubert jsonp: "callback", 10203*7f2fe78bSCy Schubert jsonpCallback: function() { 10204*7f2fe78bSCy Schubert var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce.guid++ ) ); 10205*7f2fe78bSCy Schubert this[ callback ] = true; 10206*7f2fe78bSCy Schubert return callback; 10207*7f2fe78bSCy Schubert } 10208*7f2fe78bSCy Schubert} ); 10209*7f2fe78bSCy Schubert 10210*7f2fe78bSCy Schubert// Detect, normalize options and install callbacks for jsonp requests 10211*7f2fe78bSCy SchubertjQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { 10212*7f2fe78bSCy Schubert 10213*7f2fe78bSCy Schubert var callbackName, overwritten, responseContainer, 10214*7f2fe78bSCy Schubert jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ? 10215*7f2fe78bSCy Schubert "url" : 10216*7f2fe78bSCy Schubert typeof s.data === "string" && 10217*7f2fe78bSCy Schubert ( s.contentType || "" ) 10218*7f2fe78bSCy Schubert .indexOf( "application/x-www-form-urlencoded" ) === 0 && 10219*7f2fe78bSCy Schubert rjsonp.test( s.data ) && "data" 10220*7f2fe78bSCy Schubert ); 10221*7f2fe78bSCy Schubert 10222*7f2fe78bSCy Schubert // Handle iff the expected data type is "jsonp" or we have a parameter to set 10223*7f2fe78bSCy Schubert if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) { 10224*7f2fe78bSCy Schubert 10225*7f2fe78bSCy Schubert // Get callback name, remembering preexisting value associated with it 10226*7f2fe78bSCy Schubert callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ? 10227*7f2fe78bSCy Schubert s.jsonpCallback() : 10228*7f2fe78bSCy Schubert s.jsonpCallback; 10229*7f2fe78bSCy Schubert 10230*7f2fe78bSCy Schubert // Insert callback into url or form data 10231*7f2fe78bSCy Schubert if ( jsonProp ) { 10232*7f2fe78bSCy Schubert s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName ); 10233*7f2fe78bSCy Schubert } else if ( s.jsonp !== false ) { 10234*7f2fe78bSCy Schubert s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName; 10235*7f2fe78bSCy Schubert } 10236*7f2fe78bSCy Schubert 10237*7f2fe78bSCy Schubert // Use data converter to retrieve json after script execution 10238*7f2fe78bSCy Schubert s.converters[ "script json" ] = function() { 10239*7f2fe78bSCy Schubert if ( !responseContainer ) { 10240*7f2fe78bSCy Schubert jQuery.error( callbackName + " was not called" ); 10241*7f2fe78bSCy Schubert } 10242*7f2fe78bSCy Schubert return responseContainer[ 0 ]; 10243*7f2fe78bSCy Schubert }; 10244*7f2fe78bSCy Schubert 10245*7f2fe78bSCy Schubert // Force json dataType 10246*7f2fe78bSCy Schubert s.dataTypes[ 0 ] = "json"; 10247*7f2fe78bSCy Schubert 10248*7f2fe78bSCy Schubert // Install callback 10249*7f2fe78bSCy Schubert overwritten = window[ callbackName ]; 10250*7f2fe78bSCy Schubert window[ callbackName ] = function() { 10251*7f2fe78bSCy Schubert responseContainer = arguments; 10252*7f2fe78bSCy Schubert }; 10253*7f2fe78bSCy Schubert 10254*7f2fe78bSCy Schubert // Clean-up function (fires after converters) 10255*7f2fe78bSCy Schubert jqXHR.always( function() { 10256*7f2fe78bSCy Schubert 10257*7f2fe78bSCy Schubert // If previous value didn't exist - remove it 10258*7f2fe78bSCy Schubert if ( overwritten === undefined ) { 10259*7f2fe78bSCy Schubert jQuery( window ).removeProp( callbackName ); 10260*7f2fe78bSCy Schubert 10261*7f2fe78bSCy Schubert // Otherwise restore preexisting value 10262*7f2fe78bSCy Schubert } else { 10263*7f2fe78bSCy Schubert window[ callbackName ] = overwritten; 10264*7f2fe78bSCy Schubert } 10265*7f2fe78bSCy Schubert 10266*7f2fe78bSCy Schubert // Save back as free 10267*7f2fe78bSCy Schubert if ( s[ callbackName ] ) { 10268*7f2fe78bSCy Schubert 10269*7f2fe78bSCy Schubert // Make sure that re-using the options doesn't screw things around 10270*7f2fe78bSCy Schubert s.jsonpCallback = originalSettings.jsonpCallback; 10271*7f2fe78bSCy Schubert 10272*7f2fe78bSCy Schubert // Save the callback name for future use 10273*7f2fe78bSCy Schubert oldCallbacks.push( callbackName ); 10274*7f2fe78bSCy Schubert } 10275*7f2fe78bSCy Schubert 10276*7f2fe78bSCy Schubert // Call if it was a function and we have a response 10277*7f2fe78bSCy Schubert if ( responseContainer && isFunction( overwritten ) ) { 10278*7f2fe78bSCy Schubert overwritten( responseContainer[ 0 ] ); 10279*7f2fe78bSCy Schubert } 10280*7f2fe78bSCy Schubert 10281*7f2fe78bSCy Schubert responseContainer = overwritten = undefined; 10282*7f2fe78bSCy Schubert } ); 10283*7f2fe78bSCy Schubert 10284*7f2fe78bSCy Schubert // Delegate to script 10285*7f2fe78bSCy Schubert return "script"; 10286*7f2fe78bSCy Schubert } 10287*7f2fe78bSCy Schubert} ); 10288*7f2fe78bSCy Schubert 10289*7f2fe78bSCy Schubert 10290*7f2fe78bSCy Schubert 10291*7f2fe78bSCy Schubert 10292*7f2fe78bSCy Schubert// Support: Safari 8 only 10293*7f2fe78bSCy Schubert// In Safari 8 documents created via document.implementation.createHTMLDocument 10294*7f2fe78bSCy Schubert// collapse sibling forms: the second one becomes a child of the first one. 10295*7f2fe78bSCy Schubert// Because of that, this security measure has to be disabled in Safari 8. 10296*7f2fe78bSCy Schubert// https://bugs.webkit.org/show_bug.cgi?id=137337 10297*7f2fe78bSCy Schubertsupport.createHTMLDocument = ( function() { 10298*7f2fe78bSCy Schubert var body = document.implementation.createHTMLDocument( "" ).body; 10299*7f2fe78bSCy Schubert body.innerHTML = "<form></form><form></form>"; 10300*7f2fe78bSCy Schubert return body.childNodes.length === 2; 10301*7f2fe78bSCy Schubert} )(); 10302*7f2fe78bSCy Schubert 10303*7f2fe78bSCy Schubert 10304*7f2fe78bSCy Schubert// Argument "data" should be string of html 10305*7f2fe78bSCy Schubert// context (optional): If specified, the fragment will be created in this context, 10306*7f2fe78bSCy Schubert// defaults to document 10307*7f2fe78bSCy Schubert// keepScripts (optional): If true, will include scripts passed in the html string 10308*7f2fe78bSCy SchubertjQuery.parseHTML = function( data, context, keepScripts ) { 10309*7f2fe78bSCy Schubert if ( typeof data !== "string" ) { 10310*7f2fe78bSCy Schubert return []; 10311*7f2fe78bSCy Schubert } 10312*7f2fe78bSCy Schubert if ( typeof context === "boolean" ) { 10313*7f2fe78bSCy Schubert keepScripts = context; 10314*7f2fe78bSCy Schubert context = false; 10315*7f2fe78bSCy Schubert } 10316*7f2fe78bSCy Schubert 10317*7f2fe78bSCy Schubert var base, parsed, scripts; 10318*7f2fe78bSCy Schubert 10319*7f2fe78bSCy Schubert if ( !context ) { 10320*7f2fe78bSCy Schubert 10321*7f2fe78bSCy Schubert // Stop scripts or inline event handlers from being executed immediately 10322*7f2fe78bSCy Schubert // by using document.implementation 10323*7f2fe78bSCy Schubert if ( support.createHTMLDocument ) { 10324*7f2fe78bSCy Schubert context = document.implementation.createHTMLDocument( "" ); 10325*7f2fe78bSCy Schubert 10326*7f2fe78bSCy Schubert // Set the base href for the created document 10327*7f2fe78bSCy Schubert // so any parsed elements with URLs 10328*7f2fe78bSCy Schubert // are based on the document's URL (gh-2965) 10329*7f2fe78bSCy Schubert base = context.createElement( "base" ); 10330*7f2fe78bSCy Schubert base.href = document.location.href; 10331*7f2fe78bSCy Schubert context.head.appendChild( base ); 10332*7f2fe78bSCy Schubert } else { 10333*7f2fe78bSCy Schubert context = document; 10334*7f2fe78bSCy Schubert } 10335*7f2fe78bSCy Schubert } 10336*7f2fe78bSCy Schubert 10337*7f2fe78bSCy Schubert parsed = rsingleTag.exec( data ); 10338*7f2fe78bSCy Schubert scripts = !keepScripts && []; 10339*7f2fe78bSCy Schubert 10340*7f2fe78bSCy Schubert // Single tag 10341*7f2fe78bSCy Schubert if ( parsed ) { 10342*7f2fe78bSCy Schubert return [ context.createElement( parsed[ 1 ] ) ]; 10343*7f2fe78bSCy Schubert } 10344*7f2fe78bSCy Schubert 10345*7f2fe78bSCy Schubert parsed = buildFragment( [ data ], context, scripts ); 10346*7f2fe78bSCy Schubert 10347*7f2fe78bSCy Schubert if ( scripts && scripts.length ) { 10348*7f2fe78bSCy Schubert jQuery( scripts ).remove(); 10349*7f2fe78bSCy Schubert } 10350*7f2fe78bSCy Schubert 10351*7f2fe78bSCy Schubert return jQuery.merge( [], parsed.childNodes ); 10352*7f2fe78bSCy Schubert}; 10353*7f2fe78bSCy Schubert 10354*7f2fe78bSCy Schubert 10355*7f2fe78bSCy Schubert/** 10356*7f2fe78bSCy Schubert * Load a url into a page 10357*7f2fe78bSCy Schubert */ 10358*7f2fe78bSCy SchubertjQuery.fn.load = function( url, params, callback ) { 10359*7f2fe78bSCy Schubert var selector, type, response, 10360*7f2fe78bSCy Schubert self = this, 10361*7f2fe78bSCy Schubert off = url.indexOf( " " ); 10362*7f2fe78bSCy Schubert 10363*7f2fe78bSCy Schubert if ( off > -1 ) { 10364*7f2fe78bSCy Schubert selector = stripAndCollapse( url.slice( off ) ); 10365*7f2fe78bSCy Schubert url = url.slice( 0, off ); 10366*7f2fe78bSCy Schubert } 10367*7f2fe78bSCy Schubert 10368*7f2fe78bSCy Schubert // If it's a function 10369*7f2fe78bSCy Schubert if ( isFunction( params ) ) { 10370*7f2fe78bSCy Schubert 10371*7f2fe78bSCy Schubert // We assume that it's the callback 10372*7f2fe78bSCy Schubert callback = params; 10373*7f2fe78bSCy Schubert params = undefined; 10374*7f2fe78bSCy Schubert 10375*7f2fe78bSCy Schubert // Otherwise, build a param string 10376*7f2fe78bSCy Schubert } else if ( params && typeof params === "object" ) { 10377*7f2fe78bSCy Schubert type = "POST"; 10378*7f2fe78bSCy Schubert } 10379*7f2fe78bSCy Schubert 10380*7f2fe78bSCy Schubert // If we have elements to modify, make the request 10381*7f2fe78bSCy Schubert if ( self.length > 0 ) { 10382*7f2fe78bSCy Schubert jQuery.ajax( { 10383*7f2fe78bSCy Schubert url: url, 10384*7f2fe78bSCy Schubert 10385*7f2fe78bSCy Schubert // If "type" variable is undefined, then "GET" method will be used. 10386*7f2fe78bSCy Schubert // Make value of this field explicit since 10387*7f2fe78bSCy Schubert // user can override it through ajaxSetup method 10388*7f2fe78bSCy Schubert type: type || "GET", 10389*7f2fe78bSCy Schubert dataType: "html", 10390*7f2fe78bSCy Schubert data: params 10391*7f2fe78bSCy Schubert } ).done( function( responseText ) { 10392*7f2fe78bSCy Schubert 10393*7f2fe78bSCy Schubert // Save response for use in complete callback 10394*7f2fe78bSCy Schubert response = arguments; 10395*7f2fe78bSCy Schubert 10396*7f2fe78bSCy Schubert self.html( selector ? 10397*7f2fe78bSCy Schubert 10398*7f2fe78bSCy Schubert // If a selector was specified, locate the right elements in a dummy div 10399*7f2fe78bSCy Schubert // Exclude scripts to avoid IE 'Permission Denied' errors 10400*7f2fe78bSCy Schubert jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) : 10401*7f2fe78bSCy Schubert 10402*7f2fe78bSCy Schubert // Otherwise use the full result 10403*7f2fe78bSCy Schubert responseText ); 10404*7f2fe78bSCy Schubert 10405*7f2fe78bSCy Schubert // If the request succeeds, this function gets "data", "status", "jqXHR" 10406*7f2fe78bSCy Schubert // but they are ignored because response was set above. 10407*7f2fe78bSCy Schubert // If it fails, this function gets "jqXHR", "status", "error" 10408*7f2fe78bSCy Schubert } ).always( callback && function( jqXHR, status ) { 10409*7f2fe78bSCy Schubert self.each( function() { 10410*7f2fe78bSCy Schubert callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] ); 10411*7f2fe78bSCy Schubert } ); 10412*7f2fe78bSCy Schubert } ); 10413*7f2fe78bSCy Schubert } 10414*7f2fe78bSCy Schubert 10415*7f2fe78bSCy Schubert return this; 10416*7f2fe78bSCy Schubert}; 10417*7f2fe78bSCy Schubert 10418*7f2fe78bSCy Schubert 10419*7f2fe78bSCy Schubert 10420*7f2fe78bSCy Schubert 10421*7f2fe78bSCy SchubertjQuery.expr.pseudos.animated = function( elem ) { 10422*7f2fe78bSCy Schubert return jQuery.grep( jQuery.timers, function( fn ) { 10423*7f2fe78bSCy Schubert return elem === fn.elem; 10424*7f2fe78bSCy Schubert } ).length; 10425*7f2fe78bSCy Schubert}; 10426*7f2fe78bSCy Schubert 10427*7f2fe78bSCy Schubert 10428*7f2fe78bSCy Schubert 10429*7f2fe78bSCy Schubert 10430*7f2fe78bSCy SchubertjQuery.offset = { 10431*7f2fe78bSCy Schubert setOffset: function( elem, options, i ) { 10432*7f2fe78bSCy Schubert var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition, 10433*7f2fe78bSCy Schubert position = jQuery.css( elem, "position" ), 10434*7f2fe78bSCy Schubert curElem = jQuery( elem ), 10435*7f2fe78bSCy Schubert props = {}; 10436*7f2fe78bSCy Schubert 10437*7f2fe78bSCy Schubert // Set position first, in-case top/left are set even on static elem 10438*7f2fe78bSCy Schubert if ( position === "static" ) { 10439*7f2fe78bSCy Schubert elem.style.position = "relative"; 10440*7f2fe78bSCy Schubert } 10441*7f2fe78bSCy Schubert 10442*7f2fe78bSCy Schubert curOffset = curElem.offset(); 10443*7f2fe78bSCy Schubert curCSSTop = jQuery.css( elem, "top" ); 10444*7f2fe78bSCy Schubert curCSSLeft = jQuery.css( elem, "left" ); 10445*7f2fe78bSCy Schubert calculatePosition = ( position === "absolute" || position === "fixed" ) && 10446*7f2fe78bSCy Schubert ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1; 10447*7f2fe78bSCy Schubert 10448*7f2fe78bSCy Schubert // Need to be able to calculate position if either 10449*7f2fe78bSCy Schubert // top or left is auto and position is either absolute or fixed 10450*7f2fe78bSCy Schubert if ( calculatePosition ) { 10451*7f2fe78bSCy Schubert curPosition = curElem.position(); 10452*7f2fe78bSCy Schubert curTop = curPosition.top; 10453*7f2fe78bSCy Schubert curLeft = curPosition.left; 10454*7f2fe78bSCy Schubert 10455*7f2fe78bSCy Schubert } else { 10456*7f2fe78bSCy Schubert curTop = parseFloat( curCSSTop ) || 0; 10457*7f2fe78bSCy Schubert curLeft = parseFloat( curCSSLeft ) || 0; 10458*7f2fe78bSCy Schubert } 10459*7f2fe78bSCy Schubert 10460*7f2fe78bSCy Schubert if ( isFunction( options ) ) { 10461*7f2fe78bSCy Schubert 10462*7f2fe78bSCy Schubert // Use jQuery.extend here to allow modification of coordinates argument (gh-1848) 10463*7f2fe78bSCy Schubert options = options.call( elem, i, jQuery.extend( {}, curOffset ) ); 10464*7f2fe78bSCy Schubert } 10465*7f2fe78bSCy Schubert 10466*7f2fe78bSCy Schubert if ( options.top != null ) { 10467*7f2fe78bSCy Schubert props.top = ( options.top - curOffset.top ) + curTop; 10468*7f2fe78bSCy Schubert } 10469*7f2fe78bSCy Schubert if ( options.left != null ) { 10470*7f2fe78bSCy Schubert props.left = ( options.left - curOffset.left ) + curLeft; 10471*7f2fe78bSCy Schubert } 10472*7f2fe78bSCy Schubert 10473*7f2fe78bSCy Schubert if ( "using" in options ) { 10474*7f2fe78bSCy Schubert options.using.call( elem, props ); 10475*7f2fe78bSCy Schubert 10476*7f2fe78bSCy Schubert } else { 10477*7f2fe78bSCy Schubert curElem.css( props ); 10478*7f2fe78bSCy Schubert } 10479*7f2fe78bSCy Schubert } 10480*7f2fe78bSCy Schubert}; 10481*7f2fe78bSCy Schubert 10482*7f2fe78bSCy SchubertjQuery.fn.extend( { 10483*7f2fe78bSCy Schubert 10484*7f2fe78bSCy Schubert // offset() relates an element's border box to the document origin 10485*7f2fe78bSCy Schubert offset: function( options ) { 10486*7f2fe78bSCy Schubert 10487*7f2fe78bSCy Schubert // Preserve chaining for setter 10488*7f2fe78bSCy Schubert if ( arguments.length ) { 10489*7f2fe78bSCy Schubert return options === undefined ? 10490*7f2fe78bSCy Schubert this : 10491*7f2fe78bSCy Schubert this.each( function( i ) { 10492*7f2fe78bSCy Schubert jQuery.offset.setOffset( this, options, i ); 10493*7f2fe78bSCy Schubert } ); 10494*7f2fe78bSCy Schubert } 10495*7f2fe78bSCy Schubert 10496*7f2fe78bSCy Schubert var rect, win, 10497*7f2fe78bSCy Schubert elem = this[ 0 ]; 10498*7f2fe78bSCy Schubert 10499*7f2fe78bSCy Schubert if ( !elem ) { 10500*7f2fe78bSCy Schubert return; 10501*7f2fe78bSCy Schubert } 10502*7f2fe78bSCy Schubert 10503*7f2fe78bSCy Schubert // Return zeros for disconnected and hidden (display: none) elements (gh-2310) 10504*7f2fe78bSCy Schubert // Support: IE <=11 only 10505*7f2fe78bSCy Schubert // Running getBoundingClientRect on a 10506*7f2fe78bSCy Schubert // disconnected node in IE throws an error 10507*7f2fe78bSCy Schubert if ( !elem.getClientRects().length ) { 10508*7f2fe78bSCy Schubert return { top: 0, left: 0 }; 10509*7f2fe78bSCy Schubert } 10510*7f2fe78bSCy Schubert 10511*7f2fe78bSCy Schubert // Get document-relative position by adding viewport scroll to viewport-relative gBCR 10512*7f2fe78bSCy Schubert rect = elem.getBoundingClientRect(); 10513*7f2fe78bSCy Schubert win = elem.ownerDocument.defaultView; 10514*7f2fe78bSCy Schubert return { 10515*7f2fe78bSCy Schubert top: rect.top + win.pageYOffset, 10516*7f2fe78bSCy Schubert left: rect.left + win.pageXOffset 10517*7f2fe78bSCy Schubert }; 10518*7f2fe78bSCy Schubert }, 10519*7f2fe78bSCy Schubert 10520*7f2fe78bSCy Schubert // position() relates an element's margin box to its offset parent's padding box 10521*7f2fe78bSCy Schubert // This corresponds to the behavior of CSS absolute positioning 10522*7f2fe78bSCy Schubert position: function() { 10523*7f2fe78bSCy Schubert if ( !this[ 0 ] ) { 10524*7f2fe78bSCy Schubert return; 10525*7f2fe78bSCy Schubert } 10526*7f2fe78bSCy Schubert 10527*7f2fe78bSCy Schubert var offsetParent, offset, doc, 10528*7f2fe78bSCy Schubert elem = this[ 0 ], 10529*7f2fe78bSCy Schubert parentOffset = { top: 0, left: 0 }; 10530*7f2fe78bSCy Schubert 10531*7f2fe78bSCy Schubert // position:fixed elements are offset from the viewport, which itself always has zero offset 10532*7f2fe78bSCy Schubert if ( jQuery.css( elem, "position" ) === "fixed" ) { 10533*7f2fe78bSCy Schubert 10534*7f2fe78bSCy Schubert // Assume position:fixed implies availability of getBoundingClientRect 10535*7f2fe78bSCy Schubert offset = elem.getBoundingClientRect(); 10536*7f2fe78bSCy Schubert 10537*7f2fe78bSCy Schubert } else { 10538*7f2fe78bSCy Schubert offset = this.offset(); 10539*7f2fe78bSCy Schubert 10540*7f2fe78bSCy Schubert // Account for the *real* offset parent, which can be the document or its root element 10541*7f2fe78bSCy Schubert // when a statically positioned element is identified 10542*7f2fe78bSCy Schubert doc = elem.ownerDocument; 10543*7f2fe78bSCy Schubert offsetParent = elem.offsetParent || doc.documentElement; 10544*7f2fe78bSCy Schubert while ( offsetParent && 10545*7f2fe78bSCy Schubert ( offsetParent === doc.body || offsetParent === doc.documentElement ) && 10546*7f2fe78bSCy Schubert jQuery.css( offsetParent, "position" ) === "static" ) { 10547*7f2fe78bSCy Schubert 10548*7f2fe78bSCy Schubert offsetParent = offsetParent.parentNode; 10549*7f2fe78bSCy Schubert } 10550*7f2fe78bSCy Schubert if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) { 10551*7f2fe78bSCy Schubert 10552*7f2fe78bSCy Schubert // Incorporate borders into its offset, since they are outside its content origin 10553*7f2fe78bSCy Schubert parentOffset = jQuery( offsetParent ).offset(); 10554*7f2fe78bSCy Schubert parentOffset.top += jQuery.css( offsetParent, "borderTopWidth", true ); 10555*7f2fe78bSCy Schubert parentOffset.left += jQuery.css( offsetParent, "borderLeftWidth", true ); 10556*7f2fe78bSCy Schubert } 10557*7f2fe78bSCy Schubert } 10558*7f2fe78bSCy Schubert 10559*7f2fe78bSCy Schubert // Subtract parent offsets and element margins 10560*7f2fe78bSCy Schubert return { 10561*7f2fe78bSCy Schubert top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ), 10562*7f2fe78bSCy Schubert left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true ) 10563*7f2fe78bSCy Schubert }; 10564*7f2fe78bSCy Schubert }, 10565*7f2fe78bSCy Schubert 10566*7f2fe78bSCy Schubert // This method will return documentElement in the following cases: 10567*7f2fe78bSCy Schubert // 1) For the element inside the iframe without offsetParent, this method will return 10568*7f2fe78bSCy Schubert // documentElement of the parent window 10569*7f2fe78bSCy Schubert // 2) For the hidden or detached element 10570*7f2fe78bSCy Schubert // 3) For body or html element, i.e. in case of the html node - it will return itself 10571*7f2fe78bSCy Schubert // 10572*7f2fe78bSCy Schubert // but those exceptions were never presented as a real life use-cases 10573*7f2fe78bSCy Schubert // and might be considered as more preferable results. 10574*7f2fe78bSCy Schubert // 10575*7f2fe78bSCy Schubert // This logic, however, is not guaranteed and can change at any point in the future 10576*7f2fe78bSCy Schubert offsetParent: function() { 10577*7f2fe78bSCy Schubert return this.map( function() { 10578*7f2fe78bSCy Schubert var offsetParent = this.offsetParent; 10579*7f2fe78bSCy Schubert 10580*7f2fe78bSCy Schubert while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) { 10581*7f2fe78bSCy Schubert offsetParent = offsetParent.offsetParent; 10582*7f2fe78bSCy Schubert } 10583*7f2fe78bSCy Schubert 10584*7f2fe78bSCy Schubert return offsetParent || documentElement; 10585*7f2fe78bSCy Schubert } ); 10586*7f2fe78bSCy Schubert } 10587*7f2fe78bSCy Schubert} ); 10588*7f2fe78bSCy Schubert 10589*7f2fe78bSCy Schubert// Create scrollLeft and scrollTop methods 10590*7f2fe78bSCy SchubertjQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) { 10591*7f2fe78bSCy Schubert var top = "pageYOffset" === prop; 10592*7f2fe78bSCy Schubert 10593*7f2fe78bSCy Schubert jQuery.fn[ method ] = function( val ) { 10594*7f2fe78bSCy Schubert return access( this, function( elem, method, val ) { 10595*7f2fe78bSCy Schubert 10596*7f2fe78bSCy Schubert // Coalesce documents and windows 10597*7f2fe78bSCy Schubert var win; 10598*7f2fe78bSCy Schubert if ( isWindow( elem ) ) { 10599*7f2fe78bSCy Schubert win = elem; 10600*7f2fe78bSCy Schubert } else if ( elem.nodeType === 9 ) { 10601*7f2fe78bSCy Schubert win = elem.defaultView; 10602*7f2fe78bSCy Schubert } 10603*7f2fe78bSCy Schubert 10604*7f2fe78bSCy Schubert if ( val === undefined ) { 10605*7f2fe78bSCy Schubert return win ? win[ prop ] : elem[ method ]; 10606*7f2fe78bSCy Schubert } 10607*7f2fe78bSCy Schubert 10608*7f2fe78bSCy Schubert if ( win ) { 10609*7f2fe78bSCy Schubert win.scrollTo( 10610*7f2fe78bSCy Schubert !top ? val : win.pageXOffset, 10611*7f2fe78bSCy Schubert top ? val : win.pageYOffset 10612*7f2fe78bSCy Schubert ); 10613*7f2fe78bSCy Schubert 10614*7f2fe78bSCy Schubert } else { 10615*7f2fe78bSCy Schubert elem[ method ] = val; 10616*7f2fe78bSCy Schubert } 10617*7f2fe78bSCy Schubert }, method, val, arguments.length ); 10618*7f2fe78bSCy Schubert }; 10619*7f2fe78bSCy Schubert} ); 10620*7f2fe78bSCy Schubert 10621*7f2fe78bSCy Schubert// Support: Safari <=7 - 9.1, Chrome <=37 - 49 10622*7f2fe78bSCy Schubert// Add the top/left cssHooks using jQuery.fn.position 10623*7f2fe78bSCy Schubert// Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084 10624*7f2fe78bSCy Schubert// Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347 10625*7f2fe78bSCy Schubert// getComputedStyle returns percent when specified for top/left/bottom/right; 10626*7f2fe78bSCy Schubert// rather than make the css module depend on the offset module, just check for it here 10627*7f2fe78bSCy SchubertjQuery.each( [ "top", "left" ], function( _i, prop ) { 10628*7f2fe78bSCy Schubert jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition, 10629*7f2fe78bSCy Schubert function( elem, computed ) { 10630*7f2fe78bSCy Schubert if ( computed ) { 10631*7f2fe78bSCy Schubert computed = curCSS( elem, prop ); 10632*7f2fe78bSCy Schubert 10633*7f2fe78bSCy Schubert // If curCSS returns percentage, fallback to offset 10634*7f2fe78bSCy Schubert return rnumnonpx.test( computed ) ? 10635*7f2fe78bSCy Schubert jQuery( elem ).position()[ prop ] + "px" : 10636*7f2fe78bSCy Schubert computed; 10637*7f2fe78bSCy Schubert } 10638*7f2fe78bSCy Schubert } 10639*7f2fe78bSCy Schubert ); 10640*7f2fe78bSCy Schubert} ); 10641*7f2fe78bSCy Schubert 10642*7f2fe78bSCy Schubert 10643*7f2fe78bSCy Schubert// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods 10644*7f2fe78bSCy SchubertjQuery.each( { Height: "height", Width: "width" }, function( name, type ) { 10645*7f2fe78bSCy Schubert jQuery.each( { 10646*7f2fe78bSCy Schubert padding: "inner" + name, 10647*7f2fe78bSCy Schubert content: type, 10648*7f2fe78bSCy Schubert "": "outer" + name 10649*7f2fe78bSCy Schubert }, function( defaultExtra, funcName ) { 10650*7f2fe78bSCy Schubert 10651*7f2fe78bSCy Schubert // Margin is only for outerHeight, outerWidth 10652*7f2fe78bSCy Schubert jQuery.fn[ funcName ] = function( margin, value ) { 10653*7f2fe78bSCy Schubert var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ), 10654*7f2fe78bSCy Schubert extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" ); 10655*7f2fe78bSCy Schubert 10656*7f2fe78bSCy Schubert return access( this, function( elem, type, value ) { 10657*7f2fe78bSCy Schubert var doc; 10658*7f2fe78bSCy Schubert 10659*7f2fe78bSCy Schubert if ( isWindow( elem ) ) { 10660*7f2fe78bSCy Schubert 10661*7f2fe78bSCy Schubert // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729) 10662*7f2fe78bSCy Schubert return funcName.indexOf( "outer" ) === 0 ? 10663*7f2fe78bSCy Schubert elem[ "inner" + name ] : 10664*7f2fe78bSCy Schubert elem.document.documentElement[ "client" + name ]; 10665*7f2fe78bSCy Schubert } 10666*7f2fe78bSCy Schubert 10667*7f2fe78bSCy Schubert // Get document width or height 10668*7f2fe78bSCy Schubert if ( elem.nodeType === 9 ) { 10669*7f2fe78bSCy Schubert doc = elem.documentElement; 10670*7f2fe78bSCy Schubert 10671*7f2fe78bSCy Schubert // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], 10672*7f2fe78bSCy Schubert // whichever is greatest 10673*7f2fe78bSCy Schubert return Math.max( 10674*7f2fe78bSCy Schubert elem.body[ "scroll" + name ], doc[ "scroll" + name ], 10675*7f2fe78bSCy Schubert elem.body[ "offset" + name ], doc[ "offset" + name ], 10676*7f2fe78bSCy Schubert doc[ "client" + name ] 10677*7f2fe78bSCy Schubert ); 10678*7f2fe78bSCy Schubert } 10679*7f2fe78bSCy Schubert 10680*7f2fe78bSCy Schubert return value === undefined ? 10681*7f2fe78bSCy Schubert 10682*7f2fe78bSCy Schubert // Get width or height on the element, requesting but not forcing parseFloat 10683*7f2fe78bSCy Schubert jQuery.css( elem, type, extra ) : 10684*7f2fe78bSCy Schubert 10685*7f2fe78bSCy Schubert // Set width or height on the element 10686*7f2fe78bSCy Schubert jQuery.style( elem, type, value, extra ); 10687*7f2fe78bSCy Schubert }, type, chainable ? margin : undefined, chainable ); 10688*7f2fe78bSCy Schubert }; 10689*7f2fe78bSCy Schubert } ); 10690*7f2fe78bSCy Schubert} ); 10691*7f2fe78bSCy Schubert 10692*7f2fe78bSCy Schubert 10693*7f2fe78bSCy SchubertjQuery.each( [ 10694*7f2fe78bSCy Schubert "ajaxStart", 10695*7f2fe78bSCy Schubert "ajaxStop", 10696*7f2fe78bSCy Schubert "ajaxComplete", 10697*7f2fe78bSCy Schubert "ajaxError", 10698*7f2fe78bSCy Schubert "ajaxSuccess", 10699*7f2fe78bSCy Schubert "ajaxSend" 10700*7f2fe78bSCy Schubert], function( _i, type ) { 10701*7f2fe78bSCy Schubert jQuery.fn[ type ] = function( fn ) { 10702*7f2fe78bSCy Schubert return this.on( type, fn ); 10703*7f2fe78bSCy Schubert }; 10704*7f2fe78bSCy Schubert} ); 10705*7f2fe78bSCy Schubert 10706*7f2fe78bSCy Schubert 10707*7f2fe78bSCy Schubert 10708*7f2fe78bSCy Schubert 10709*7f2fe78bSCy SchubertjQuery.fn.extend( { 10710*7f2fe78bSCy Schubert 10711*7f2fe78bSCy Schubert bind: function( types, data, fn ) { 10712*7f2fe78bSCy Schubert return this.on( types, null, data, fn ); 10713*7f2fe78bSCy Schubert }, 10714*7f2fe78bSCy Schubert unbind: function( types, fn ) { 10715*7f2fe78bSCy Schubert return this.off( types, null, fn ); 10716*7f2fe78bSCy Schubert }, 10717*7f2fe78bSCy Schubert 10718*7f2fe78bSCy Schubert delegate: function( selector, types, data, fn ) { 10719*7f2fe78bSCy Schubert return this.on( types, selector, data, fn ); 10720*7f2fe78bSCy Schubert }, 10721*7f2fe78bSCy Schubert undelegate: function( selector, types, fn ) { 10722*7f2fe78bSCy Schubert 10723*7f2fe78bSCy Schubert // ( namespace ) or ( selector, types [, fn] ) 10724*7f2fe78bSCy Schubert return arguments.length === 1 ? 10725*7f2fe78bSCy Schubert this.off( selector, "**" ) : 10726*7f2fe78bSCy Schubert this.off( types, selector || "**", fn ); 10727*7f2fe78bSCy Schubert }, 10728*7f2fe78bSCy Schubert 10729*7f2fe78bSCy Schubert hover: function( fnOver, fnOut ) { 10730*7f2fe78bSCy Schubert return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); 10731*7f2fe78bSCy Schubert } 10732*7f2fe78bSCy Schubert} ); 10733*7f2fe78bSCy Schubert 10734*7f2fe78bSCy SchubertjQuery.each( 10735*7f2fe78bSCy Schubert ( "blur focus focusin focusout resize scroll click dblclick " + 10736*7f2fe78bSCy Schubert "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + 10737*7f2fe78bSCy Schubert "change select submit keydown keypress keyup contextmenu" ).split( " " ), 10738*7f2fe78bSCy Schubert function( _i, name ) { 10739*7f2fe78bSCy Schubert 10740*7f2fe78bSCy Schubert // Handle event binding 10741*7f2fe78bSCy Schubert jQuery.fn[ name ] = function( data, fn ) { 10742*7f2fe78bSCy Schubert return arguments.length > 0 ? 10743*7f2fe78bSCy Schubert this.on( name, null, data, fn ) : 10744*7f2fe78bSCy Schubert this.trigger( name ); 10745*7f2fe78bSCy Schubert }; 10746*7f2fe78bSCy Schubert } 10747*7f2fe78bSCy Schubert); 10748*7f2fe78bSCy Schubert 10749*7f2fe78bSCy Schubert 10750*7f2fe78bSCy Schubert 10751*7f2fe78bSCy Schubert 10752*7f2fe78bSCy Schubert// Support: Android <=4.0 only 10753*7f2fe78bSCy Schubert// Make sure we trim BOM and NBSP 10754*7f2fe78bSCy Schubertvar rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g; 10755*7f2fe78bSCy Schubert 10756*7f2fe78bSCy Schubert// Bind a function to a context, optionally partially applying any 10757*7f2fe78bSCy Schubert// arguments. 10758*7f2fe78bSCy Schubert// jQuery.proxy is deprecated to promote standards (specifically Function#bind) 10759*7f2fe78bSCy Schubert// However, it is not slated for removal any time soon 10760*7f2fe78bSCy SchubertjQuery.proxy = function( fn, context ) { 10761*7f2fe78bSCy Schubert var tmp, args, proxy; 10762*7f2fe78bSCy Schubert 10763*7f2fe78bSCy Schubert if ( typeof context === "string" ) { 10764*7f2fe78bSCy Schubert tmp = fn[ context ]; 10765*7f2fe78bSCy Schubert context = fn; 10766*7f2fe78bSCy Schubert fn = tmp; 10767*7f2fe78bSCy Schubert } 10768*7f2fe78bSCy Schubert 10769*7f2fe78bSCy Schubert // Quick check to determine if target is callable, in the spec 10770*7f2fe78bSCy Schubert // this throws a TypeError, but we will just return undefined. 10771*7f2fe78bSCy Schubert if ( !isFunction( fn ) ) { 10772*7f2fe78bSCy Schubert return undefined; 10773*7f2fe78bSCy Schubert } 10774*7f2fe78bSCy Schubert 10775*7f2fe78bSCy Schubert // Simulated bind 10776*7f2fe78bSCy Schubert args = slice.call( arguments, 2 ); 10777*7f2fe78bSCy Schubert proxy = function() { 10778*7f2fe78bSCy Schubert return fn.apply( context || this, args.concat( slice.call( arguments ) ) ); 10779*7f2fe78bSCy Schubert }; 10780*7f2fe78bSCy Schubert 10781*7f2fe78bSCy Schubert // Set the guid of unique handler to the same of original handler, so it can be removed 10782*7f2fe78bSCy Schubert proxy.guid = fn.guid = fn.guid || jQuery.guid++; 10783*7f2fe78bSCy Schubert 10784*7f2fe78bSCy Schubert return proxy; 10785*7f2fe78bSCy Schubert}; 10786*7f2fe78bSCy Schubert 10787*7f2fe78bSCy SchubertjQuery.holdReady = function( hold ) { 10788*7f2fe78bSCy Schubert if ( hold ) { 10789*7f2fe78bSCy Schubert jQuery.readyWait++; 10790*7f2fe78bSCy Schubert } else { 10791*7f2fe78bSCy Schubert jQuery.ready( true ); 10792*7f2fe78bSCy Schubert } 10793*7f2fe78bSCy Schubert}; 10794*7f2fe78bSCy SchubertjQuery.isArray = Array.isArray; 10795*7f2fe78bSCy SchubertjQuery.parseJSON = JSON.parse; 10796*7f2fe78bSCy SchubertjQuery.nodeName = nodeName; 10797*7f2fe78bSCy SchubertjQuery.isFunction = isFunction; 10798*7f2fe78bSCy SchubertjQuery.isWindow = isWindow; 10799*7f2fe78bSCy SchubertjQuery.camelCase = camelCase; 10800*7f2fe78bSCy SchubertjQuery.type = toType; 10801*7f2fe78bSCy Schubert 10802*7f2fe78bSCy SchubertjQuery.now = Date.now; 10803*7f2fe78bSCy Schubert 10804*7f2fe78bSCy SchubertjQuery.isNumeric = function( obj ) { 10805*7f2fe78bSCy Schubert 10806*7f2fe78bSCy Schubert // As of jQuery 3.0, isNumeric is limited to 10807*7f2fe78bSCy Schubert // strings and numbers (primitives or objects) 10808*7f2fe78bSCy Schubert // that can be coerced to finite numbers (gh-2662) 10809*7f2fe78bSCy Schubert var type = jQuery.type( obj ); 10810*7f2fe78bSCy Schubert return ( type === "number" || type === "string" ) && 10811*7f2fe78bSCy Schubert 10812*7f2fe78bSCy Schubert // parseFloat NaNs numeric-cast false positives ("") 10813*7f2fe78bSCy Schubert // ...but misinterprets leading-number strings, particularly hex literals ("0x...") 10814*7f2fe78bSCy Schubert // subtraction forces infinities to NaN 10815*7f2fe78bSCy Schubert !isNaN( obj - parseFloat( obj ) ); 10816*7f2fe78bSCy Schubert}; 10817*7f2fe78bSCy Schubert 10818*7f2fe78bSCy SchubertjQuery.trim = function( text ) { 10819*7f2fe78bSCy Schubert return text == null ? 10820*7f2fe78bSCy Schubert "" : 10821*7f2fe78bSCy Schubert ( text + "" ).replace( rtrim, "" ); 10822*7f2fe78bSCy Schubert}; 10823*7f2fe78bSCy Schubert 10824*7f2fe78bSCy Schubert 10825*7f2fe78bSCy Schubert 10826*7f2fe78bSCy Schubert// Register as a named AMD module, since jQuery can be concatenated with other 10827*7f2fe78bSCy Schubert// files that may use define, but not via a proper concatenation script that 10828*7f2fe78bSCy Schubert// understands anonymous AMD modules. A named AMD is safest and most robust 10829*7f2fe78bSCy Schubert// way to register. Lowercase jquery is used because AMD module names are 10830*7f2fe78bSCy Schubert// derived from file names, and jQuery is normally delivered in a lowercase 10831*7f2fe78bSCy Schubert// file name. Do this after creating the global so that if an AMD module wants 10832*7f2fe78bSCy Schubert// to call noConflict to hide this version of jQuery, it will work. 10833*7f2fe78bSCy Schubert 10834*7f2fe78bSCy Schubert// Note that for maximum portability, libraries that are not jQuery should 10835*7f2fe78bSCy Schubert// declare themselves as anonymous modules, and avoid setting a global if an 10836*7f2fe78bSCy Schubert// AMD loader is present. jQuery is a special case. For more information, see 10837*7f2fe78bSCy Schubert// https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon 10838*7f2fe78bSCy Schubert 10839*7f2fe78bSCy Schubertif ( typeof define === "function" && define.amd ) { 10840*7f2fe78bSCy Schubert define( "jquery", [], function() { 10841*7f2fe78bSCy Schubert return jQuery; 10842*7f2fe78bSCy Schubert } ); 10843*7f2fe78bSCy Schubert} 10844*7f2fe78bSCy Schubert 10845*7f2fe78bSCy Schubert 10846*7f2fe78bSCy Schubert 10847*7f2fe78bSCy Schubert 10848*7f2fe78bSCy Schubertvar 10849*7f2fe78bSCy Schubert 10850*7f2fe78bSCy Schubert // Map over jQuery in case of overwrite 10851*7f2fe78bSCy Schubert _jQuery = window.jQuery, 10852*7f2fe78bSCy Schubert 10853*7f2fe78bSCy Schubert // Map over the $ in case of overwrite 10854*7f2fe78bSCy Schubert _$ = window.$; 10855*7f2fe78bSCy Schubert 10856*7f2fe78bSCy SchubertjQuery.noConflict = function( deep ) { 10857*7f2fe78bSCy Schubert if ( window.$ === jQuery ) { 10858*7f2fe78bSCy Schubert window.$ = _$; 10859*7f2fe78bSCy Schubert } 10860*7f2fe78bSCy Schubert 10861*7f2fe78bSCy Schubert if ( deep && window.jQuery === jQuery ) { 10862*7f2fe78bSCy Schubert window.jQuery = _jQuery; 10863*7f2fe78bSCy Schubert } 10864*7f2fe78bSCy Schubert 10865*7f2fe78bSCy Schubert return jQuery; 10866*7f2fe78bSCy Schubert}; 10867*7f2fe78bSCy Schubert 10868*7f2fe78bSCy Schubert// Expose jQuery and $ identifiers, even in AMD 10869*7f2fe78bSCy Schubert// (#7102#comment:10, https://github.com/jquery/jquery/pull/557) 10870*7f2fe78bSCy Schubert// and CommonJS for browser emulators (#13566) 10871*7f2fe78bSCy Schubertif ( typeof noGlobal === "undefined" ) { 10872*7f2fe78bSCy Schubert window.jQuery = window.$ = jQuery; 10873*7f2fe78bSCy Schubert} 10874*7f2fe78bSCy Schubert 10875*7f2fe78bSCy Schubert 10876*7f2fe78bSCy Schubert 10877*7f2fe78bSCy Schubert 10878*7f2fe78bSCy Schubertreturn jQuery; 10879*7f2fe78bSCy Schubert} ); 10880