57 |
63 |
58 var toString = class2type.toString; |
64 var toString = class2type.toString; |
59 |
65 |
60 var hasOwn = class2type.hasOwnProperty; |
66 var hasOwn = class2type.hasOwnProperty; |
61 |
67 |
|
68 var fnToString = hasOwn.toString; |
|
69 |
|
70 var ObjectFunctionString = fnToString.call( Object ); |
|
71 |
62 var support = {}; |
72 var support = {}; |
63 |
73 |
|
74 var isFunction = function isFunction( obj ) { |
|
75 |
|
76 // Support: Chrome <=57, Firefox <=52 |
|
77 // In some browsers, typeof returns "function" for HTML <object> elements |
|
78 // (i.e., `typeof document.createElement( "object" ) === "function"`). |
|
79 // We don't want to classify *any* DOM node as a function. |
|
80 return typeof obj === "function" && typeof obj.nodeType !== "number"; |
|
81 }; |
|
82 |
|
83 |
|
84 var isWindow = function isWindow( obj ) { |
|
85 return obj != null && obj === obj.window; |
|
86 }; |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 var preservedScriptAttributes = { |
|
92 type: true, |
|
93 src: true, |
|
94 nonce: true, |
|
95 noModule: true |
|
96 }; |
|
97 |
|
98 function DOMEval( code, node, doc ) { |
|
99 doc = doc || document; |
|
100 |
|
101 var i, val, |
|
102 script = doc.createElement( "script" ); |
|
103 |
|
104 script.text = code; |
|
105 if ( node ) { |
|
106 for ( i in preservedScriptAttributes ) { |
|
107 |
|
108 // Support: Firefox 64+, Edge 18+ |
|
109 // Some browsers don't support the "nonce" property on scripts. |
|
110 // On the other hand, just using `getAttribute` is not enough as |
|
111 // the `nonce` attribute is reset to an empty string whenever it |
|
112 // becomes browsing-context connected. |
|
113 // See https://github.com/whatwg/html/issues/2369 |
|
114 // See https://html.spec.whatwg.org/#nonce-attributes |
|
115 // The `node.getAttribute` check was added for the sake of |
|
116 // `jQuery.globalEval` so that it can fake a nonce-containing node |
|
117 // via an object. |
|
118 val = node[ i ] || node.getAttribute && node.getAttribute( i ); |
|
119 if ( val ) { |
|
120 script.setAttribute( i, val ); |
|
121 } |
|
122 } |
|
123 } |
|
124 doc.head.appendChild( script ).parentNode.removeChild( script ); |
|
125 } |
|
126 |
|
127 |
|
128 function toType( obj ) { |
|
129 if ( obj == null ) { |
|
130 return obj + ""; |
|
131 } |
|
132 |
|
133 // Support: Android <=2.3 only (functionish RegExp) |
|
134 return typeof obj === "object" || typeof obj === "function" ? |
|
135 class2type[ toString.call( obj ) ] || "object" : |
|
136 typeof obj; |
|
137 } |
|
138 /* global Symbol */ |
|
139 // Defining this global in .eslintrc.json would create a danger of using the global |
|
140 // unguarded in another place, it seems safer to define global only for this module |
|
141 |
64 |
142 |
65 |
143 |
66 var |
144 var |
67 // Use the correct document accordingly with window argument (sandbox) |
145 version = "3.4.1", |
68 document = window.document, |
|
69 |
|
70 version = "2.1.4", |
|
71 |
146 |
72 // Define a local copy of jQuery |
147 // Define a local copy of jQuery |
73 jQuery = function( selector, context ) { |
148 jQuery = function( selector, context ) { |
|
149 |
74 // The jQuery object is actually just the init constructor 'enhanced' |
150 // The jQuery object is actually just the init constructor 'enhanced' |
75 // Need init if jQuery is called (just allow error to be thrown if not included) |
151 // Need init if jQuery is called (just allow error to be thrown if not included) |
76 return new jQuery.fn.init( selector, context ); |
152 return new jQuery.fn.init( selector, context ); |
77 }, |
153 }, |
78 |
154 |
79 // Support: Android<4.1 |
155 // Support: Android <=4.0 only |
80 // Make sure we trim BOM and NBSP |
156 // Make sure we trim BOM and NBSP |
81 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, |
157 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g; |
82 |
|
83 // Matches dashed string for camelizing |
|
84 rmsPrefix = /^-ms-/, |
|
85 rdashAlpha = /-([\da-z])/gi, |
|
86 |
|
87 // Used by jQuery.camelCase as callback to replace() |
|
88 fcamelCase = function( all, letter ) { |
|
89 return letter.toUpperCase(); |
|
90 }; |
|
91 |
158 |
92 jQuery.fn = jQuery.prototype = { |
159 jQuery.fn = jQuery.prototype = { |
|
160 |
93 // The current version of jQuery being used |
161 // The current version of jQuery being used |
94 jquery: version, |
162 jquery: version, |
95 |
163 |
96 constructor: jQuery, |
164 constructor: jQuery, |
97 |
|
98 // Start with an empty selector |
|
99 selector: "", |
|
100 |
165 |
101 // The default length of a jQuery object is 0 |
166 // The default length of a jQuery object is 0 |
102 length: 0, |
167 length: 0, |
103 |
168 |
104 toArray: function() { |
169 toArray: function() { |
250 throw new Error( msg ); |
321 throw new Error( msg ); |
251 }, |
322 }, |
252 |
323 |
253 noop: function() {}, |
324 noop: function() {}, |
254 |
325 |
255 isFunction: function( obj ) { |
|
256 return jQuery.type(obj) === "function"; |
|
257 }, |
|
258 |
|
259 isArray: Array.isArray, |
|
260 |
|
261 isWindow: function( obj ) { |
|
262 return obj != null && obj === obj.window; |
|
263 }, |
|
264 |
|
265 isNumeric: function( obj ) { |
|
266 // parseFloat NaNs numeric-cast false positives (null|true|false|"") |
|
267 // ...but misinterprets leading-number strings, particularly hex literals ("0x...") |
|
268 // subtraction forces infinities to NaN |
|
269 // adding 1 corrects loss of precision from parseFloat (#15100) |
|
270 return !jQuery.isArray( obj ) && (obj - parseFloat( obj ) + 1) >= 0; |
|
271 }, |
|
272 |
|
273 isPlainObject: function( obj ) { |
326 isPlainObject: function( obj ) { |
274 // Not plain objects: |
327 var proto, Ctor; |
275 // - Any object or value whose internal [[Class]] property is not "[object Object]" |
328 |
276 // - DOM nodes |
329 // Detect obvious negatives |
277 // - window |
330 // Use toString instead of jQuery.type to catch host objects |
278 if ( jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { |
331 if ( !obj || toString.call( obj ) !== "[object Object]" ) { |
279 return false; |
332 return false; |
280 } |
333 } |
281 |
334 |
282 if ( obj.constructor && |
335 proto = getProto( obj ); |
283 !hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) { |
336 |
284 return false; |
337 // Objects with no prototype (e.g., `Object.create( null )`) are plain |
285 } |
338 if ( !proto ) { |
286 |
339 return true; |
287 // If the function hasn't returned already, we're confident that |
340 } |
288 // |obj| is a plain object, created by {} or constructed with new Object |
341 |
289 return true; |
342 // Objects with prototype are plain iff they were constructed by a global Object function |
|
343 Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor; |
|
344 return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString; |
290 }, |
345 }, |
291 |
346 |
292 isEmptyObject: function( obj ) { |
347 isEmptyObject: function( obj ) { |
293 var name; |
348 var name; |
|
349 |
294 for ( name in obj ) { |
350 for ( name in obj ) { |
295 return false; |
351 return false; |
296 } |
352 } |
297 return true; |
353 return true; |
298 }, |
354 }, |
299 |
355 |
300 type: function( obj ) { |
|
301 if ( obj == null ) { |
|
302 return obj + ""; |
|
303 } |
|
304 // Support: Android<4.0, iOS<6 (functionish RegExp) |
|
305 return typeof obj === "object" || typeof obj === "function" ? |
|
306 class2type[ toString.call(obj) ] || "object" : |
|
307 typeof obj; |
|
308 }, |
|
309 |
|
310 // Evaluates a script in a global context |
356 // Evaluates a script in a global context |
311 globalEval: function( code ) { |
357 globalEval: function( code, options ) { |
312 var script, |
358 DOMEval( code, { nonce: options && options.nonce } ); |
313 indirect = eval; |
359 }, |
314 |
360 |
315 code = jQuery.trim( code ); |
361 each: function( obj, callback ) { |
316 |
362 var length, i = 0; |
317 if ( code ) { |
363 |
318 // If the code includes a valid, prologue position |
364 if ( isArrayLike( obj ) ) { |
319 // strict mode pragma, execute code by injecting a |
365 length = obj.length; |
320 // script tag into the document. |
366 for ( ; i < length; i++ ) { |
321 if ( code.indexOf("use strict") === 1 ) { |
367 if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { |
322 script = document.createElement("script"); |
368 break; |
323 script.text = code; |
369 } |
324 document.head.appendChild( script ).parentNode.removeChild( script ); |
370 } |
325 } else { |
|
326 // Otherwise, avoid the DOM node creation, insertion |
|
327 // and removal by using an indirect global eval |
|
328 indirect( code ); |
|
329 } |
|
330 } |
|
331 }, |
|
332 |
|
333 // Convert dashed to camelCase; used by the css and data modules |
|
334 // Support: IE9-11+ |
|
335 // Microsoft forgot to hump their vendor prefix (#9572) |
|
336 camelCase: function( string ) { |
|
337 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); |
|
338 }, |
|
339 |
|
340 nodeName: function( elem, name ) { |
|
341 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); |
|
342 }, |
|
343 |
|
344 // args is for internal usage only |
|
345 each: function( obj, callback, args ) { |
|
346 var value, |
|
347 i = 0, |
|
348 length = obj.length, |
|
349 isArray = isArraylike( obj ); |
|
350 |
|
351 if ( args ) { |
|
352 if ( isArray ) { |
|
353 for ( ; i < length; i++ ) { |
|
354 value = callback.apply( obj[ i ], args ); |
|
355 |
|
356 if ( value === false ) { |
|
357 break; |
|
358 } |
|
359 } |
|
360 } else { |
|
361 for ( i in obj ) { |
|
362 value = callback.apply( obj[ i ], args ); |
|
363 |
|
364 if ( value === false ) { |
|
365 break; |
|
366 } |
|
367 } |
|
368 } |
|
369 |
|
370 // A special, fast, case for the most common use of each |
|
371 } else { |
371 } else { |
372 if ( isArray ) { |
372 for ( i in obj ) { |
373 for ( ; i < length; i++ ) { |
373 if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { |
374 value = callback.call( obj[ i ], i, obj[ i ] ); |
374 break; |
375 |
|
376 if ( value === false ) { |
|
377 break; |
|
378 } |
|
379 } |
|
380 } else { |
|
381 for ( i in obj ) { |
|
382 value = callback.call( obj[ i ], i, obj[ i ] ); |
|
383 |
|
384 if ( value === false ) { |
|
385 break; |
|
386 } |
|
387 } |
375 } |
388 } |
376 } |
389 } |
377 } |
390 |
378 |
391 return obj; |
379 return obj; |
392 }, |
380 }, |
393 |
381 |
394 // Support: Android<4.1 |
382 // Support: Android <=4.0 only |
395 trim: function( text ) { |
383 trim: function( text ) { |
396 return text == null ? |
384 return text == null ? |
397 "" : |
385 "" : |
398 ( text + "" ).replace( rtrim, "" ); |
386 ( text + "" ).replace( rtrim, "" ); |
399 }, |
387 }, |
746 } |
725 } |
747 }; |
726 }; |
748 } |
727 } |
749 |
728 |
750 function Sizzle( selector, context, results, seed ) { |
729 function Sizzle( selector, context, results, seed ) { |
751 var match, elem, m, nodeType, |
730 var m, i, elem, nid, match, groups, newSelector, |
752 // QSA vars |
731 newContext = context && context.ownerDocument, |
753 i, groups, old, nid, newContext, newSelector; |
732 |
754 |
733 // nodeType defaults to 9, since context defaults to document |
755 if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) { |
734 nodeType = context ? context.nodeType : 9; |
756 setDocument( context ); |
735 |
757 } |
|
758 |
|
759 context = context || document; |
|
760 results = results || []; |
736 results = results || []; |
761 nodeType = context.nodeType; |
737 |
762 |
738 // Return early from calls with invalid selector or context |
763 if ( typeof selector !== "string" || !selector || |
739 if ( typeof selector !== "string" || !selector || |
764 nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) { |
740 nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) { |
765 |
741 |
766 return results; |
742 return results; |
767 } |
743 } |
768 |
744 |
769 if ( !seed && documentIsHTML ) { |
745 // Try to shortcut find operations (as opposed to filters) in HTML documents |
770 |
746 if ( !seed ) { |
771 // Try to shortcut find operations when possible (e.g., not under DocumentFragment) |
747 |
772 if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) { |
748 if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) { |
773 // Speed-up: Sizzle("#ID") |
749 setDocument( context ); |
774 if ( (m = match[1]) ) { |
750 } |
775 if ( nodeType === 9 ) { |
751 context = context || document; |
776 elem = context.getElementById( m ); |
752 |
777 // Check parentNode to catch when Blackberry 4.6 returns |
753 if ( documentIsHTML ) { |
778 // nodes that are no longer in the document (jQuery #6963) |
754 |
779 if ( elem && elem.parentNode ) { |
755 // If the selector is sufficiently simple, try using a "get*By*" DOM method |
780 // Handle the case where IE, Opera, and Webkit return items |
756 // (excepting DocumentFragment context, where the methods don't exist) |
781 // by name instead of ID |
757 if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) { |
782 if ( elem.id === m ) { |
758 |
|
759 // ID selector |
|
760 if ( (m = match[1]) ) { |
|
761 |
|
762 // Document context |
|
763 if ( nodeType === 9 ) { |
|
764 if ( (elem = context.getElementById( m )) ) { |
|
765 |
|
766 // Support: IE, Opera, Webkit |
|
767 // TODO: identify versions |
|
768 // getElementById can match elements by name instead of ID |
|
769 if ( elem.id === m ) { |
|
770 results.push( elem ); |
|
771 return results; |
|
772 } |
|
773 } else { |
|
774 return results; |
|
775 } |
|
776 |
|
777 // Element context |
|
778 } else { |
|
779 |
|
780 // Support: IE, Opera, Webkit |
|
781 // TODO: identify versions |
|
782 // getElementById can match elements by name instead of ID |
|
783 if ( newContext && (elem = newContext.getElementById( m )) && |
|
784 contains( context, elem ) && |
|
785 elem.id === m ) { |
|
786 |
783 results.push( elem ); |
787 results.push( elem ); |
784 return results; |
788 return results; |
785 } |
789 } |
|
790 } |
|
791 |
|
792 // Type selector |
|
793 } else if ( match[2] ) { |
|
794 push.apply( results, context.getElementsByTagName( selector ) ); |
|
795 return results; |
|
796 |
|
797 // Class selector |
|
798 } else if ( (m = match[3]) && support.getElementsByClassName && |
|
799 context.getElementsByClassName ) { |
|
800 |
|
801 push.apply( results, context.getElementsByClassName( m ) ); |
|
802 return results; |
|
803 } |
|
804 } |
|
805 |
|
806 // Take advantage of querySelectorAll |
|
807 if ( support.qsa && |
|
808 !nonnativeSelectorCache[ selector + " " ] && |
|
809 (!rbuggyQSA || !rbuggyQSA.test( selector )) && |
|
810 |
|
811 // Support: IE 8 only |
|
812 // Exclude object elements |
|
813 (nodeType !== 1 || context.nodeName.toLowerCase() !== "object") ) { |
|
814 |
|
815 newSelector = selector; |
|
816 newContext = context; |
|
817 |
|
818 // qSA considers elements outside a scoping root when evaluating child or |
|
819 // descendant combinators, which is not what we want. |
|
820 // In such cases, we work around the behavior by prefixing every selector in the |
|
821 // list with an ID selector referencing the scope context. |
|
822 // Thanks to Andrew Dupont for this technique. |
|
823 if ( nodeType === 1 && rdescend.test( selector ) ) { |
|
824 |
|
825 // Capture the context ID, setting it first if necessary |
|
826 if ( (nid = context.getAttribute( "id" )) ) { |
|
827 nid = nid.replace( rcssescape, fcssescape ); |
786 } else { |
828 } else { |
787 return results; |
829 context.setAttribute( "id", (nid = expando) ); |
788 } |
830 } |
789 } else { |
831 |
790 // Context is not a document |
832 // Prefix every selector in the list |
791 if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) && |
833 groups = tokenize( selector ); |
792 contains( context, elem ) && elem.id === m ) { |
834 i = groups.length; |
793 results.push( elem ); |
835 while ( i-- ) { |
794 return results; |
836 groups[i] = "#" + nid + " " + toSelector( groups[i] ); |
795 } |
837 } |
796 } |
838 newSelector = groups.join( "," ); |
797 |
839 |
798 // Speed-up: Sizzle("TAG") |
840 // Expand context for sibling selectors |
799 } else if ( match[2] ) { |
841 newContext = rsibling.test( selector ) && testContext( context.parentNode ) || |
800 push.apply( results, context.getElementsByTagName( selector ) ); |
842 context; |
801 return results; |
843 } |
802 |
844 |
803 // Speed-up: Sizzle(".CLASS") |
|
804 } else if ( (m = match[3]) && support.getElementsByClassName ) { |
|
805 push.apply( results, context.getElementsByClassName( m ) ); |
|
806 return results; |
|
807 } |
|
808 } |
|
809 |
|
810 // QSA path |
|
811 if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) { |
|
812 nid = old = expando; |
|
813 newContext = context; |
|
814 newSelector = nodeType !== 1 && selector; |
|
815 |
|
816 // qSA works strangely on Element-rooted queries |
|
817 // We can work around this by specifying an extra ID on the root |
|
818 // and working up from there (Thanks to Andrew Dupont for the technique) |
|
819 // IE 8 doesn't work on object elements |
|
820 if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { |
|
821 groups = tokenize( selector ); |
|
822 |
|
823 if ( (old = context.getAttribute("id")) ) { |
|
824 nid = old.replace( rescape, "\\$&" ); |
|
825 } else { |
|
826 context.setAttribute( "id", nid ); |
|
827 } |
|
828 nid = "[id='" + nid + "'] "; |
|
829 |
|
830 i = groups.length; |
|
831 while ( i-- ) { |
|
832 groups[i] = nid + toSelector( groups[i] ); |
|
833 } |
|
834 newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context; |
|
835 newSelector = groups.join(","); |
|
836 } |
|
837 |
|
838 if ( newSelector ) { |
|
839 try { |
845 try { |
840 push.apply( results, |
846 push.apply( results, |
841 newContext.querySelectorAll( newSelector ) |
847 newContext.querySelectorAll( newSelector ) |
842 ); |
848 ); |
843 return results; |
849 return results; |
844 } catch(qsaError) { |
850 } catch ( qsaError ) { |
|
851 nonnativeSelectorCache( selector, true ); |
845 } finally { |
852 } finally { |
846 if ( !old ) { |
853 if ( nid === expando ) { |
847 context.removeAttribute("id"); |
854 context.removeAttribute( "id" ); |
848 } |
855 } |
849 } |
856 } |
850 } |
857 } |
851 } |
858 } |
852 } |
859 } |
1008 * Detects XML nodes |
1070 * Detects XML nodes |
1009 * @param {Element|Object} elem An element or a document |
1071 * @param {Element|Object} elem An element or a document |
1010 * @returns {Boolean} True iff elem is a non-HTML XML node |
1072 * @returns {Boolean} True iff elem is a non-HTML XML node |
1011 */ |
1073 */ |
1012 isXML = Sizzle.isXML = function( elem ) { |
1074 isXML = Sizzle.isXML = function( elem ) { |
1013 // documentElement is verified for cases where it doesn't yet exist |
1075 var namespace = elem.namespaceURI, |
1014 // (such as loading iframes in IE - #4833) |
1076 docElem = (elem.ownerDocument || elem).documentElement; |
1015 var documentElement = elem && (elem.ownerDocument || elem).documentElement; |
1077 |
1016 return documentElement ? documentElement.nodeName !== "HTML" : false; |
1078 // Support: IE <=8 |
|
1079 // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes |
|
1080 // https://bugs.jquery.com/ticket/4833 |
|
1081 return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" ); |
1017 }; |
1082 }; |
1018 |
1083 |
1019 /** |
1084 /** |
1020 * Sets document-related variables once based on the current document |
1085 * Sets document-related variables once based on the current document |
1021 * @param {Element|Object} [doc] An element or document object to use to set the document |
1086 * @param {Element|Object} [doc] An element or document object to use to set the document |
1022 * @returns {Object} Returns the current document |
1087 * @returns {Object} Returns the current document |
1023 */ |
1088 */ |
1024 setDocument = Sizzle.setDocument = function( node ) { |
1089 setDocument = Sizzle.setDocument = function( node ) { |
1025 var hasCompare, parent, |
1090 var hasCompare, subWindow, |
1026 doc = node ? node.ownerDocument || node : preferredDoc; |
1091 doc = node ? node.ownerDocument || node : preferredDoc; |
1027 |
1092 |
1028 // If no document and documentElement is available, return |
1093 // Return early if doc is invalid or already selected |
1029 if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) { |
1094 if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) { |
1030 return document; |
1095 return document; |
1031 } |
1096 } |
1032 |
1097 |
1033 // Set our document |
1098 // Update global variables |
1034 document = doc; |
1099 document = doc; |
1035 docElem = doc.documentElement; |
1100 docElem = document.documentElement; |
1036 parent = doc.defaultView; |
1101 documentIsHTML = !isXML( document ); |
1037 |
1102 |
1038 // Support: IE>8 |
1103 // Support: IE 9-11, Edge |
1039 // If iframe document is assigned to "document" variable and if iframe has been reloaded, |
1104 // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936) |
1040 // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936 |
1105 if ( preferredDoc !== document && |
1041 // IE6-8 do not support the defaultView property so parent will be undefined |
1106 (subWindow = document.defaultView) && subWindow.top !== subWindow ) { |
1042 if ( parent && parent !== parent.top ) { |
1107 |
1043 // IE11 does not have attachEvent, so all must suffer |
1108 // Support: IE 11, Edge |
1044 if ( parent.addEventListener ) { |
1109 if ( subWindow.addEventListener ) { |
1045 parent.addEventListener( "unload", unloadHandler, false ); |
1110 subWindow.addEventListener( "unload", unloadHandler, false ); |
1046 } else if ( parent.attachEvent ) { |
1111 |
1047 parent.attachEvent( "onunload", unloadHandler ); |
1112 // Support: IE 9 - 10 only |
1048 } |
1113 } else if ( subWindow.attachEvent ) { |
1049 } |
1114 subWindow.attachEvent( "onunload", unloadHandler ); |
1050 |
1115 } |
1051 /* Support tests |
1116 } |
1052 ---------------------------------------------------------------------- */ |
|
1053 documentIsHTML = !isXML( doc ); |
|
1054 |
1117 |
1055 /* Attributes |
1118 /* Attributes |
1056 ---------------------------------------------------------------------- */ |
1119 ---------------------------------------------------------------------- */ |
1057 |
1120 |
1058 // Support: IE<8 |
1121 // Support: IE<8 |
1059 // Verify that getAttribute really returns attributes and not properties |
1122 // Verify that getAttribute really returns attributes and not properties |
1060 // (excepting IE8 booleans) |
1123 // (excepting IE8 booleans) |
1061 support.attributes = assert(function( div ) { |
1124 support.attributes = assert(function( el ) { |
1062 div.className = "i"; |
1125 el.className = "i"; |
1063 return !div.getAttribute("className"); |
1126 return !el.getAttribute("className"); |
1064 }); |
1127 }); |
1065 |
1128 |
1066 /* getElement(s)By* |
1129 /* getElement(s)By* |
1067 ---------------------------------------------------------------------- */ |
1130 ---------------------------------------------------------------------- */ |
1068 |
1131 |
1069 // Check if getElementsByTagName("*") returns only elements |
1132 // Check if getElementsByTagName("*") returns only elements |
1070 support.getElementsByTagName = assert(function( div ) { |
1133 support.getElementsByTagName = assert(function( el ) { |
1071 div.appendChild( doc.createComment("") ); |
1134 el.appendChild( document.createComment("") ); |
1072 return !div.getElementsByTagName("*").length; |
1135 return !el.getElementsByTagName("*").length; |
1073 }); |
1136 }); |
1074 |
1137 |
1075 // Support: IE<9 |
1138 // Support: IE<9 |
1076 support.getElementsByClassName = rnative.test( doc.getElementsByClassName ); |
1139 support.getElementsByClassName = rnative.test( document.getElementsByClassName ); |
1077 |
1140 |
1078 // Support: IE<10 |
1141 // Support: IE<10 |
1079 // Check if getElementById returns elements by name |
1142 // Check if getElementById returns elements by name |
1080 // The broken getElementById methods don't pick up programatically-set names, |
1143 // The broken getElementById methods don't pick up programmatically-set names, |
1081 // so use a roundabout getElementsByName test |
1144 // so use a roundabout getElementsByName test |
1082 support.getById = assert(function( div ) { |
1145 support.getById = assert(function( el ) { |
1083 docElem.appendChild( div ).id = expando; |
1146 docElem.appendChild( el ).id = expando; |
1084 return !doc.getElementsByName || !doc.getElementsByName( expando ).length; |
1147 return !document.getElementsByName || !document.getElementsByName( expando ).length; |
1085 }); |
1148 }); |
1086 |
1149 |
1087 // ID find and filter |
1150 // ID filter and find |
1088 if ( support.getById ) { |
1151 if ( support.getById ) { |
1089 Expr.find["ID"] = function( id, context ) { |
|
1090 if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { |
|
1091 var m = context.getElementById( id ); |
|
1092 // Check parentNode to catch when Blackberry 4.6 returns |
|
1093 // nodes that are no longer in the document #6963 |
|
1094 return m && m.parentNode ? [ m ] : []; |
|
1095 } |
|
1096 }; |
|
1097 Expr.filter["ID"] = function( id ) { |
1152 Expr.filter["ID"] = function( id ) { |
1098 var attrId = id.replace( runescape, funescape ); |
1153 var attrId = id.replace( runescape, funescape ); |
1099 return function( elem ) { |
1154 return function( elem ) { |
1100 return elem.getAttribute("id") === attrId; |
1155 return elem.getAttribute("id") === attrId; |
1101 }; |
1156 }; |
1102 }; |
1157 }; |
|
1158 Expr.find["ID"] = function( id, context ) { |
|
1159 if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { |
|
1160 var elem = context.getElementById( id ); |
|
1161 return elem ? [ elem ] : []; |
|
1162 } |
|
1163 }; |
1103 } else { |
1164 } else { |
1104 // Support: IE6/7 |
|
1105 // getElementById is not reliable as a find shortcut |
|
1106 delete Expr.find["ID"]; |
|
1107 |
|
1108 Expr.filter["ID"] = function( id ) { |
1165 Expr.filter["ID"] = function( id ) { |
1109 var attrId = id.replace( runescape, funescape ); |
1166 var attrId = id.replace( runescape, funescape ); |
1110 return function( elem ) { |
1167 return function( elem ) { |
1111 var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); |
1168 var node = typeof elem.getAttributeNode !== "undefined" && |
|
1169 elem.getAttributeNode("id"); |
1112 return node && node.value === attrId; |
1170 return node && node.value === attrId; |
1113 }; |
1171 }; |
|
1172 }; |
|
1173 |
|
1174 // Support: IE 6 - 7 only |
|
1175 // getElementById is not reliable as a find shortcut |
|
1176 Expr.find["ID"] = function( id, context ) { |
|
1177 if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { |
|
1178 var node, i, elems, |
|
1179 elem = context.getElementById( id ); |
|
1180 |
|
1181 if ( elem ) { |
|
1182 |
|
1183 // Verify the id attribute |
|
1184 node = elem.getAttributeNode("id"); |
|
1185 if ( node && node.value === id ) { |
|
1186 return [ elem ]; |
|
1187 } |
|
1188 |
|
1189 // Fall back on getElementsByName |
|
1190 elems = context.getElementsByName( id ); |
|
1191 i = 0; |
|
1192 while ( (elem = elems[i++]) ) { |
|
1193 node = elem.getAttributeNode("id"); |
|
1194 if ( node && node.value === id ) { |
|
1195 return [ elem ]; |
|
1196 } |
|
1197 } |
|
1198 } |
|
1199 |
|
1200 return []; |
|
1201 } |
1114 }; |
1202 }; |
1115 } |
1203 } |
1116 |
1204 |
1117 // Tag |
1205 // Tag |
1118 Expr.find["TAG"] = support.getElementsByTagName ? |
1206 Expr.find["TAG"] = support.getElementsByTagName ? |
1163 |
1251 |
1164 // qSa(:focus) reports false when true (Chrome 21) |
1252 // qSa(:focus) reports false when true (Chrome 21) |
1165 // We allow this because of a bug in IE8/9 that throws an error |
1253 // We allow this because of a bug in IE8/9 that throws an error |
1166 // whenever `document.activeElement` is accessed on an iframe |
1254 // whenever `document.activeElement` is accessed on an iframe |
1167 // So, we allow :focus to pass through QSA all the time to avoid the IE error |
1255 // So, we allow :focus to pass through QSA all the time to avoid the IE error |
1168 // See http://bugs.jquery.com/ticket/13378 |
1256 // See https://bugs.jquery.com/ticket/13378 |
1169 rbuggyQSA = []; |
1257 rbuggyQSA = []; |
1170 |
1258 |
1171 if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) { |
1259 if ( (support.qsa = rnative.test( document.querySelectorAll )) ) { |
1172 // Build QSA regex |
1260 // Build QSA regex |
1173 // Regex strategy adopted from Diego Perini |
1261 // Regex strategy adopted from Diego Perini |
1174 assert(function( div ) { |
1262 assert(function( el ) { |
1175 // Select is set to empty string on purpose |
1263 // Select is set to empty string on purpose |
1176 // This is to test IE's treatment of not explicitly |
1264 // This is to test IE's treatment of not explicitly |
1177 // setting a boolean content attribute, |
1265 // setting a boolean content attribute, |
1178 // since its presence should be enough |
1266 // since its presence should be enough |
1179 // http://bugs.jquery.com/ticket/12359 |
1267 // https://bugs.jquery.com/ticket/12359 |
1180 docElem.appendChild( div ).innerHTML = "<a id='" + expando + "'></a>" + |
1268 docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" + |
1181 "<select id='" + expando + "-\f]' msallowcapture=''>" + |
1269 "<select id='" + expando + "-\r\\' msallowcapture=''>" + |
1182 "<option selected=''></option></select>"; |
1270 "<option selected=''></option></select>"; |
1183 |
1271 |
1184 // Support: IE8, Opera 11-12.16 |
1272 // Support: IE8, Opera 11-12.16 |
1185 // Nothing should be selected when empty strings follow ^= or $= or *= |
1273 // Nothing should be selected when empty strings follow ^= or $= or *= |
1186 // The test attribute must be unknown in Opera but "safe" for WinRT |
1274 // The test attribute must be unknown in Opera but "safe" for WinRT |
1187 // http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section |
1275 // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section |
1188 if ( div.querySelectorAll("[msallowcapture^='']").length ) { |
1276 if ( el.querySelectorAll("[msallowcapture^='']").length ) { |
1189 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" ); |
1277 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" ); |
1190 } |
1278 } |
1191 |
1279 |
1192 // Support: IE8 |
1280 // Support: IE8 |
1193 // Boolean attributes and "value" are not treated correctly |
1281 // Boolean attributes and "value" are not treated correctly |
1194 if ( !div.querySelectorAll("[selected]").length ) { |
1282 if ( !el.querySelectorAll("[selected]").length ) { |
1195 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" ); |
1283 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" ); |
1196 } |
1284 } |
1197 |
1285 |
1198 // Support: Chrome<29, Android<4.2+, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.7+ |
1286 // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+ |
1199 if ( !div.querySelectorAll( "[id~=" + expando + "-]" ).length ) { |
1287 if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) { |
1200 rbuggyQSA.push("~="); |
1288 rbuggyQSA.push("~="); |
1201 } |
1289 } |
1202 |
1290 |
1203 // Webkit/Opera - :checked should return selected option elements |
1291 // Webkit/Opera - :checked should return selected option elements |
1204 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked |
1292 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked |
1205 // IE8 throws error here and will not see later tests |
1293 // IE8 throws error here and will not see later tests |
1206 if ( !div.querySelectorAll(":checked").length ) { |
1294 if ( !el.querySelectorAll(":checked").length ) { |
1207 rbuggyQSA.push(":checked"); |
1295 rbuggyQSA.push(":checked"); |
1208 } |
1296 } |
1209 |
1297 |
1210 // Support: Safari 8+, iOS 8+ |
1298 // Support: Safari 8+, iOS 8+ |
1211 // https://bugs.webkit.org/show_bug.cgi?id=136851 |
1299 // https://bugs.webkit.org/show_bug.cgi?id=136851 |
1212 // In-page `selector#id sibing-combinator selector` fails |
1300 // In-page `selector#id sibling-combinator selector` fails |
1213 if ( !div.querySelectorAll( "a#" + expando + "+*" ).length ) { |
1301 if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) { |
1214 rbuggyQSA.push(".#.+[+~]"); |
1302 rbuggyQSA.push(".#.+[+~]"); |
1215 } |
1303 } |
1216 }); |
1304 }); |
1217 |
1305 |
1218 assert(function( div ) { |
1306 assert(function( el ) { |
|
1307 el.innerHTML = "<a href='' disabled='disabled'></a>" + |
|
1308 "<select disabled='disabled'><option/></select>"; |
|
1309 |
1219 // Support: Windows 8 Native Apps |
1310 // Support: Windows 8 Native Apps |
1220 // The type and name attributes are restricted during .innerHTML assignment |
1311 // The type and name attributes are restricted during .innerHTML assignment |
1221 var input = doc.createElement("input"); |
1312 var input = document.createElement("input"); |
1222 input.setAttribute( "type", "hidden" ); |
1313 input.setAttribute( "type", "hidden" ); |
1223 div.appendChild( input ).setAttribute( "name", "D" ); |
1314 el.appendChild( input ).setAttribute( "name", "D" ); |
1224 |
1315 |
1225 // Support: IE8 |
1316 // Support: IE8 |
1226 // Enforce case-sensitivity of name attribute |
1317 // Enforce case-sensitivity of name attribute |
1227 if ( div.querySelectorAll("[name=d]").length ) { |
1318 if ( el.querySelectorAll("[name=d]").length ) { |
1228 rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" ); |
1319 rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" ); |
1229 } |
1320 } |
1230 |
1321 |
1231 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) |
1322 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) |
1232 // IE8 throws error here and will not see later tests |
1323 // IE8 throws error here and will not see later tests |
1233 if ( !div.querySelectorAll(":enabled").length ) { |
1324 if ( el.querySelectorAll(":enabled").length !== 2 ) { |
1234 rbuggyQSA.push( ":enabled", ":disabled" ); |
1325 rbuggyQSA.push( ":enabled", ":disabled" ); |
1235 } |
1326 } |
1236 |
1327 |
|
1328 // Support: IE9-11+ |
|
1329 // IE's :disabled selector does not pick up the children of disabled fieldsets |
|
1330 docElem.appendChild( el ).disabled = true; |
|
1331 if ( el.querySelectorAll(":disabled").length !== 2 ) { |
|
1332 rbuggyQSA.push( ":enabled", ":disabled" ); |
|
1333 } |
|
1334 |
1237 // Opera 10-11 does not throw on post-comma invalid pseudos |
1335 // Opera 10-11 does not throw on post-comma invalid pseudos |
1238 div.querySelectorAll("*,:x"); |
1336 el.querySelectorAll("*,:x"); |
1239 rbuggyQSA.push(",.*:"); |
1337 rbuggyQSA.push(",.*:"); |
1240 }); |
1338 }); |
1241 } |
1339 } |
1242 |
1340 |
1243 if ( (support.matchesSelector = rnative.test( (matches = docElem.matches || |
1341 if ( (support.matchesSelector = rnative.test( (matches = docElem.matches || |
1244 docElem.webkitMatchesSelector || |
1342 docElem.webkitMatchesSelector || |
1245 docElem.mozMatchesSelector || |
1343 docElem.mozMatchesSelector || |
1246 docElem.oMatchesSelector || |
1344 docElem.oMatchesSelector || |
1247 docElem.msMatchesSelector) )) ) { |
1345 docElem.msMatchesSelector) )) ) { |
1248 |
1346 |
1249 assert(function( div ) { |
1347 assert(function( el ) { |
1250 // Check to see if it's possible to do matchesSelector |
1348 // Check to see if it's possible to do matchesSelector |
1251 // on a disconnected node (IE 9) |
1349 // on a disconnected node (IE 9) |
1252 support.disconnectedMatch = matches.call( div, "div" ); |
1350 support.disconnectedMatch = matches.call( el, "*" ); |
1253 |
1351 |
1254 // This should fail with an exception |
1352 // This should fail with an exception |
1255 // Gecko does not error, returns false instead |
1353 // Gecko does not error, returns false instead |
1256 matches.call( div, "[s!='']:x" ); |
1354 matches.call( el, "[s!='']:x" ); |
1257 rbuggyMatches.push( "!=", pseudos ); |
1355 rbuggyMatches.push( "!=", pseudos ); |
1258 }); |
1356 }); |
1259 } |
1357 } |
1260 |
1358 |
1261 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") ); |
1359 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") ); |
2612 |
2776 |
2613 |
2777 |
2614 |
2778 |
2615 jQuery.find = Sizzle; |
2779 jQuery.find = Sizzle; |
2616 jQuery.expr = Sizzle.selectors; |
2780 jQuery.expr = Sizzle.selectors; |
2617 jQuery.expr[":"] = jQuery.expr.pseudos; |
2781 |
2618 jQuery.unique = Sizzle.uniqueSort; |
2782 // Deprecated |
|
2783 jQuery.expr[ ":" ] = jQuery.expr.pseudos; |
|
2784 jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort; |
2619 jQuery.text = Sizzle.getText; |
2785 jQuery.text = Sizzle.getText; |
2620 jQuery.isXMLDoc = Sizzle.isXML; |
2786 jQuery.isXMLDoc = Sizzle.isXML; |
2621 jQuery.contains = Sizzle.contains; |
2787 jQuery.contains = Sizzle.contains; |
2622 |
2788 jQuery.escapeSelector = Sizzle.escape; |
|
2789 |
|
2790 |
|
2791 |
|
2792 |
|
2793 var dir = function( elem, dir, until ) { |
|
2794 var matched = [], |
|
2795 truncate = until !== undefined; |
|
2796 |
|
2797 while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) { |
|
2798 if ( elem.nodeType === 1 ) { |
|
2799 if ( truncate && jQuery( elem ).is( until ) ) { |
|
2800 break; |
|
2801 } |
|
2802 matched.push( elem ); |
|
2803 } |
|
2804 } |
|
2805 return matched; |
|
2806 }; |
|
2807 |
|
2808 |
|
2809 var siblings = function( n, elem ) { |
|
2810 var matched = []; |
|
2811 |
|
2812 for ( ; n; n = n.nextSibling ) { |
|
2813 if ( n.nodeType === 1 && n !== elem ) { |
|
2814 matched.push( n ); |
|
2815 } |
|
2816 } |
|
2817 |
|
2818 return matched; |
|
2819 }; |
2623 |
2820 |
2624 |
2821 |
2625 var rneedsContext = jQuery.expr.match.needsContext; |
2822 var rneedsContext = jQuery.expr.match.needsContext; |
2626 |
2823 |
2627 var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/); |
2824 |
2628 |
2825 |
2629 |
2826 function nodeName( elem, name ) { |
2630 |
2827 |
2631 var risSimple = /^.[^:#\[\.,]*$/; |
2828 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); |
|
2829 |
|
2830 }; |
|
2831 var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i ); |
|
2832 |
|
2833 |
2632 |
2834 |
2633 // Implement the identical functionality for filter and not |
2835 // Implement the identical functionality for filter and not |
2634 function winnow( elements, qualifier, not ) { |
2836 function winnow( elements, qualifier, not ) { |
2635 if ( jQuery.isFunction( qualifier ) ) { |
2837 if ( isFunction( qualifier ) ) { |
2636 return jQuery.grep( elements, function( elem, i ) { |
2838 return jQuery.grep( elements, function( elem, i ) { |
2637 /* jshint -W018 */ |
|
2638 return !!qualifier.call( elem, i, elem ) !== not; |
2839 return !!qualifier.call( elem, i, elem ) !== not; |
2639 }); |
2840 } ); |
2640 |
2841 } |
2641 } |
2842 |
2642 |
2843 // Single element |
2643 if ( qualifier.nodeType ) { |
2844 if ( qualifier.nodeType ) { |
2644 return jQuery.grep( elements, function( elem ) { |
2845 return jQuery.grep( elements, function( elem ) { |
2645 return ( elem === qualifier ) !== not; |
2846 return ( elem === qualifier ) !== not; |
2646 }); |
2847 } ); |
2647 |
2848 } |
2648 } |
2849 |
2649 |
2850 // Arraylike of elements (jQuery, arguments, Array) |
2650 if ( typeof qualifier === "string" ) { |
2851 if ( typeof qualifier !== "string" ) { |
2651 if ( risSimple.test( qualifier ) ) { |
2852 return jQuery.grep( elements, function( elem ) { |
2652 return jQuery.filter( qualifier, elements, not ); |
2853 return ( indexOf.call( qualifier, elem ) > -1 ) !== not; |
2653 } |
2854 } ); |
2654 |
2855 } |
2655 qualifier = jQuery.filter( qualifier, elements ); |
2856 |
2656 } |
2857 // Filtered directly for both simple and complex selectors |
2657 |
2858 return jQuery.filter( qualifier, elements, not ); |
2658 return jQuery.grep( elements, function( elem ) { |
|
2659 return ( indexOf.call( qualifier, elem ) >= 0 ) !== not; |
|
2660 }); |
|
2661 } |
2859 } |
2662 |
2860 |
2663 jQuery.filter = function( expr, elems, not ) { |
2861 jQuery.filter = function( expr, elems, not ) { |
2664 var elem = elems[ 0 ]; |
2862 var elem = elems[ 0 ]; |
2665 |
2863 |
2666 if ( not ) { |
2864 if ( not ) { |
2667 expr = ":not(" + expr + ")"; |
2865 expr = ":not(" + expr + ")"; |
2668 } |
2866 } |
2669 |
2867 |
2670 return elems.length === 1 && elem.nodeType === 1 ? |
2868 if ( elems.length === 1 && elem.nodeType === 1 ) { |
2671 jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] : |
2869 return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : []; |
2672 jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) { |
2870 } |
2673 return elem.nodeType === 1; |
2871 |
2674 })); |
2872 return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) { |
|
2873 return elem.nodeType === 1; |
|
2874 } ) ); |
2675 }; |
2875 }; |
2676 |
2876 |
2677 jQuery.fn.extend({ |
2877 jQuery.fn.extend( { |
2678 find: function( selector ) { |
2878 find: function( selector ) { |
2679 var i, |
2879 var i, ret, |
2680 len = this.length, |
2880 len = this.length, |
2681 ret = [], |
|
2682 self = this; |
2881 self = this; |
2683 |
2882 |
2684 if ( typeof selector !== "string" ) { |
2883 if ( typeof selector !== "string" ) { |
2685 return this.pushStack( jQuery( selector ).filter(function() { |
2884 return this.pushStack( jQuery( selector ).filter( function() { |
2686 for ( i = 0; i < len; i++ ) { |
2885 for ( i = 0; i < len; i++ ) { |
2687 if ( jQuery.contains( self[ i ], this ) ) { |
2886 if ( jQuery.contains( self[ i ], this ) ) { |
2688 return true; |
2887 return true; |
2689 } |
2888 } |
2690 } |
2889 } |
2691 }) ); |
2890 } ) ); |
2692 } |
2891 } |
|
2892 |
|
2893 ret = this.pushStack( [] ); |
2693 |
2894 |
2694 for ( i = 0; i < len; i++ ) { |
2895 for ( i = 0; i < len; i++ ) { |
2695 jQuery.find( selector, self[ i ], ret ); |
2896 jQuery.find( selector, self[ i ], ret ); |
2696 } |
2897 } |
2697 |
2898 |
2698 // Needed because $( selector, context ) becomes $( context ).find( selector ) |
2899 return len > 1 ? jQuery.uniqueSort( ret ) : ret; |
2699 ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret ); |
|
2700 ret.selector = this.selector ? this.selector + " " + selector : selector; |
|
2701 return ret; |
|
2702 }, |
2900 }, |
2703 filter: function( selector ) { |
2901 filter: function( selector ) { |
2704 return this.pushStack( winnow(this, selector || [], false) ); |
2902 return this.pushStack( winnow( this, selector || [], false ) ); |
2705 }, |
2903 }, |
2706 not: function( selector ) { |
2904 not: function( selector ) { |
2707 return this.pushStack( winnow(this, selector || [], true) ); |
2905 return this.pushStack( winnow( this, selector || [], true ) ); |
2708 }, |
2906 }, |
2709 is: function( selector ) { |
2907 is: function( selector ) { |
2710 return !!winnow( |
2908 return !!winnow( |
2711 this, |
2909 this, |
2712 |
2910 |
2940 ); |
3113 ); |
2941 }, |
3114 }, |
2942 |
3115 |
2943 add: function( selector, context ) { |
3116 add: function( selector, context ) { |
2944 return this.pushStack( |
3117 return this.pushStack( |
2945 jQuery.unique( |
3118 jQuery.uniqueSort( |
2946 jQuery.merge( this.get(), jQuery( selector, context ) ) |
3119 jQuery.merge( this.get(), jQuery( selector, context ) ) |
2947 ) |
3120 ) |
2948 ); |
3121 ); |
2949 }, |
3122 }, |
2950 |
3123 |
2951 addBack: function( selector ) { |
3124 addBack: function( selector ) { |
2952 return this.add( selector == null ? |
3125 return this.add( selector == null ? |
2953 this.prevObject : this.prevObject.filter(selector) |
3126 this.prevObject : this.prevObject.filter( selector ) |
2954 ); |
3127 ); |
2955 } |
3128 } |
2956 }); |
3129 } ); |
2957 |
3130 |
2958 function sibling( cur, dir ) { |
3131 function sibling( cur, dir ) { |
2959 while ( (cur = cur[dir]) && cur.nodeType !== 1 ) {} |
3132 while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {} |
2960 return cur; |
3133 return cur; |
2961 } |
3134 } |
2962 |
3135 |
2963 jQuery.each({ |
3136 jQuery.each( { |
2964 parent: function( elem ) { |
3137 parent: function( elem ) { |
2965 var parent = elem.parentNode; |
3138 var parent = elem.parentNode; |
2966 return parent && parent.nodeType !== 11 ? parent : null; |
3139 return parent && parent.nodeType !== 11 ? parent : null; |
2967 }, |
3140 }, |
2968 parents: function( elem ) { |
3141 parents: function( elem ) { |
2969 return jQuery.dir( elem, "parentNode" ); |
3142 return dir( elem, "parentNode" ); |
2970 }, |
3143 }, |
2971 parentsUntil: function( elem, i, until ) { |
3144 parentsUntil: function( elem, i, until ) { |
2972 return jQuery.dir( elem, "parentNode", until ); |
3145 return dir( elem, "parentNode", until ); |
2973 }, |
3146 }, |
2974 next: function( elem ) { |
3147 next: function( elem ) { |
2975 return sibling( elem, "nextSibling" ); |
3148 return sibling( elem, "nextSibling" ); |
2976 }, |
3149 }, |
2977 prev: function( elem ) { |
3150 prev: function( elem ) { |
2978 return sibling( elem, "previousSibling" ); |
3151 return sibling( elem, "previousSibling" ); |
2979 }, |
3152 }, |
2980 nextAll: function( elem ) { |
3153 nextAll: function( elem ) { |
2981 return jQuery.dir( elem, "nextSibling" ); |
3154 return dir( elem, "nextSibling" ); |
2982 }, |
3155 }, |
2983 prevAll: function( elem ) { |
3156 prevAll: function( elem ) { |
2984 return jQuery.dir( elem, "previousSibling" ); |
3157 return dir( elem, "previousSibling" ); |
2985 }, |
3158 }, |
2986 nextUntil: function( elem, i, until ) { |
3159 nextUntil: function( elem, i, until ) { |
2987 return jQuery.dir( elem, "nextSibling", until ); |
3160 return dir( elem, "nextSibling", until ); |
2988 }, |
3161 }, |
2989 prevUntil: function( elem, i, until ) { |
3162 prevUntil: function( elem, i, until ) { |
2990 return jQuery.dir( elem, "previousSibling", until ); |
3163 return dir( elem, "previousSibling", until ); |
2991 }, |
3164 }, |
2992 siblings: function( elem ) { |
3165 siblings: function( elem ) { |
2993 return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem ); |
3166 return siblings( ( elem.parentNode || {} ).firstChild, elem ); |
2994 }, |
3167 }, |
2995 children: function( elem ) { |
3168 children: function( elem ) { |
2996 return jQuery.sibling( elem.firstChild ); |
3169 return siblings( elem.firstChild ); |
2997 }, |
3170 }, |
2998 contents: function( elem ) { |
3171 contents: function( elem ) { |
2999 return elem.contentDocument || jQuery.merge( [], elem.childNodes ); |
3172 if ( typeof elem.contentDocument !== "undefined" ) { |
|
3173 return elem.contentDocument; |
|
3174 } |
|
3175 |
|
3176 // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only |
|
3177 // Treat the template element as a regular one in browsers that |
|
3178 // don't support it. |
|
3179 if ( nodeName( elem, "template" ) ) { |
|
3180 elem = elem.content || elem; |
|
3181 } |
|
3182 |
|
3183 return jQuery.merge( [], elem.childNodes ); |
3000 } |
3184 } |
3001 }, function( name, fn ) { |
3185 }, function( name, fn ) { |
3002 jQuery.fn[ name ] = function( until, selector ) { |
3186 jQuery.fn[ name ] = function( until, selector ) { |
3003 var matched = jQuery.map( this, fn, until ); |
3187 var matched = jQuery.map( this, fn, until ); |
3004 |
3188 |
3066 jQuery.Callbacks = function( options ) { |
3248 jQuery.Callbacks = function( options ) { |
3067 |
3249 |
3068 // Convert options from String-formatted to Object-formatted if needed |
3250 // Convert options from String-formatted to Object-formatted if needed |
3069 // (we check in cache first) |
3251 // (we check in cache first) |
3070 options = typeof options === "string" ? |
3252 options = typeof options === "string" ? |
3071 ( optionsCache[ options ] || createOptions( options ) ) : |
3253 createOptions( options ) : |
3072 jQuery.extend( {}, options ); |
3254 jQuery.extend( {}, options ); |
3073 |
3255 |
3074 var // Last fire value (for non-forgettable lists) |
3256 var // Flag to know if list is currently firing |
|
3257 firing, |
|
3258 |
|
3259 // Last fire value for non-forgettable lists |
3075 memory, |
3260 memory, |
|
3261 |
3076 // Flag to know if list was already fired |
3262 // Flag to know if list was already fired |
3077 fired, |
3263 fired, |
3078 // Flag to know if list is currently firing |
3264 |
3079 firing, |
3265 // Flag to prevent firing |
3080 // First callback to fire (used internally by add and fireWith) |
3266 locked, |
3081 firingStart, |
3267 |
3082 // End of the loop when firing |
|
3083 firingLength, |
|
3084 // Index of currently firing callback (modified by remove if needed) |
|
3085 firingIndex, |
|
3086 // Actual callback list |
3268 // Actual callback list |
3087 list = [], |
3269 list = [], |
3088 // Stack of fire calls for repeatable lists |
3270 |
3089 stack = !options.once && [], |
3271 // Queue of execution data for repeatable lists |
|
3272 queue = [], |
|
3273 |
|
3274 // Index of currently firing callback (modified by add/remove as needed) |
|
3275 firingIndex = -1, |
|
3276 |
3090 // Fire callbacks |
3277 // Fire callbacks |
3091 fire = function( data ) { |
3278 fire = function() { |
3092 memory = options.memory && data; |
3279 |
3093 fired = true; |
3280 // Enforce single-firing |
3094 firingIndex = firingStart || 0; |
3281 locked = locked || options.once; |
3095 firingStart = 0; |
3282 |
3096 firingLength = list.length; |
3283 // Execute callbacks for all pending executions, |
3097 firing = true; |
3284 // respecting firingIndex overrides and runtime changes |
3098 for ( ; list && firingIndex < firingLength; firingIndex++ ) { |
3285 fired = firing = true; |
3099 if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) { |
3286 for ( ; queue.length; firingIndex = -1 ) { |
3100 memory = false; // To prevent further calls using add |
3287 memory = queue.shift(); |
3101 break; |
3288 while ( ++firingIndex < list.length ) { |
3102 } |
3289 |
3103 } |
3290 // Run callback and check for early termination |
|
3291 if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false && |
|
3292 options.stopOnFalse ) { |
|
3293 |
|
3294 // Jump to end and forget the data so .add doesn't re-fire |
|
3295 firingIndex = list.length; |
|
3296 memory = false; |
|
3297 } |
|
3298 } |
|
3299 } |
|
3300 |
|
3301 // Forget the data if we're done with it |
|
3302 if ( !options.memory ) { |
|
3303 memory = false; |
|
3304 } |
|
3305 |
3104 firing = false; |
3306 firing = false; |
3105 if ( list ) { |
3307 |
3106 if ( stack ) { |
3308 // Clean up if we're done firing for good |
3107 if ( stack.length ) { |
3309 if ( locked ) { |
3108 fire( stack.shift() ); |
3310 |
3109 } |
3311 // Keep an empty list if we have data for future add calls |
3110 } else if ( memory ) { |
3312 if ( memory ) { |
3111 list = []; |
3313 list = []; |
|
3314 |
|
3315 // Otherwise, this object is spent |
3112 } else { |
3316 } else { |
3113 self.disable(); |
3317 list = ""; |
3114 } |
3318 } |
3115 } |
3319 } |
3116 }, |
3320 }, |
|
3321 |
3117 // Actual Callbacks object |
3322 // Actual Callbacks object |
3118 self = { |
3323 self = { |
|
3324 |
3119 // Add a callback or a collection of callbacks to the list |
3325 // Add a callback or a collection of callbacks to the list |
3120 add: function() { |
3326 add: function() { |
3121 if ( list ) { |
3327 if ( list ) { |
3122 // First, we save the current length |
3328 |
3123 var start = list.length; |
3329 // If we have memory from a past run, we should fire after adding |
3124 (function add( args ) { |
3330 if ( memory && !firing ) { |
|
3331 firingIndex = list.length - 1; |
|
3332 queue.push( memory ); |
|
3333 } |
|
3334 |
|
3335 ( function add( args ) { |
3125 jQuery.each( args, function( _, arg ) { |
3336 jQuery.each( args, function( _, arg ) { |
3126 var type = jQuery.type( arg ); |
3337 if ( isFunction( arg ) ) { |
3127 if ( type === "function" ) { |
|
3128 if ( !options.unique || !self.has( arg ) ) { |
3338 if ( !options.unique || !self.has( arg ) ) { |
3129 list.push( arg ); |
3339 list.push( arg ); |
3130 } |
3340 } |
3131 } else if ( arg && arg.length && type !== "string" ) { |
3341 } else if ( arg && arg.length && toType( arg ) !== "string" ) { |
|
3342 |
3132 // Inspect recursively |
3343 // Inspect recursively |
3133 add( arg ); |
3344 add( arg ); |
3134 } |
3345 } |
3135 }); |
3346 } ); |
3136 })( arguments ); |
3347 } )( arguments ); |
3137 // Do we need to add the callbacks to the |
3348 |
3138 // current firing batch? |
3349 if ( memory && !firing ) { |
3139 if ( firing ) { |
3350 fire(); |
3140 firingLength = list.length; |
|
3141 // With memory, if we're not firing then |
|
3142 // we should call right away |
|
3143 } else if ( memory ) { |
|
3144 firingStart = start; |
|
3145 fire( memory ); |
|
3146 } |
3351 } |
3147 } |
3352 } |
3148 return this; |
3353 return this; |
3149 }, |
3354 }, |
|
3355 |
3150 // Remove a callback from the list |
3356 // Remove a callback from the list |
3151 remove: function() { |
3357 remove: function() { |
3152 if ( list ) { |
3358 jQuery.each( arguments, function( _, arg ) { |
3153 jQuery.each( arguments, function( _, arg ) { |
3359 var index; |
3154 var index; |
3360 while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { |
3155 while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { |
3361 list.splice( index, 1 ); |
3156 list.splice( index, 1 ); |
3362 |
3157 // Handle firing indexes |
3363 // Handle firing indexes |
3158 if ( firing ) { |
3364 if ( index <= firingIndex ) { |
3159 if ( index <= firingLength ) { |
3365 firingIndex--; |
3160 firingLength--; |
|
3161 } |
|
3162 if ( index <= firingIndex ) { |
|
3163 firingIndex--; |
|
3164 } |
|
3165 } |
|
3166 } |
3366 } |
3167 }); |
3367 } |
3168 } |
3368 } ); |
3169 return this; |
3369 return this; |
3170 }, |
3370 }, |
|
3371 |
3171 // Check if a given callback is in the list. |
3372 // Check if a given callback is in the list. |
3172 // If no argument is given, return whether or not list has callbacks attached. |
3373 // If no argument is given, return whether or not list has callbacks attached. |
3173 has: function( fn ) { |
3374 has: function( fn ) { |
3174 return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length ); |
3375 return fn ? |
|
3376 jQuery.inArray( fn, list ) > -1 : |
|
3377 list.length > 0; |
3175 }, |
3378 }, |
|
3379 |
3176 // Remove all callbacks from the list |
3380 // Remove all callbacks from the list |
3177 empty: function() { |
3381 empty: function() { |
3178 list = []; |
3382 if ( list ) { |
3179 firingLength = 0; |
3383 list = []; |
|
3384 } |
3180 return this; |
3385 return this; |
3181 }, |
3386 }, |
3182 // Have the list do nothing anymore |
3387 |
|
3388 // Disable .fire and .add |
|
3389 // Abort any current/pending executions |
|
3390 // Clear all callbacks and values |
3183 disable: function() { |
3391 disable: function() { |
3184 list = stack = memory = undefined; |
3392 locked = queue = []; |
|
3393 list = memory = ""; |
3185 return this; |
3394 return this; |
3186 }, |
3395 }, |
3187 // Is it disabled? |
|
3188 disabled: function() { |
3396 disabled: function() { |
3189 return !list; |
3397 return !list; |
3190 }, |
3398 }, |
3191 // Lock the list in its current state |
3399 |
|
3400 // Disable .fire |
|
3401 // Also disable .add unless we have memory (since it would have no effect) |
|
3402 // Abort any pending executions |
3192 lock: function() { |
3403 lock: function() { |
3193 stack = undefined; |
3404 locked = queue = []; |
3194 if ( !memory ) { |
3405 if ( !memory && !firing ) { |
3195 self.disable(); |
3406 list = memory = ""; |
3196 } |
3407 } |
3197 return this; |
3408 return this; |
3198 }, |
3409 }, |
3199 // Is it locked? |
|
3200 locked: function() { |
3410 locked: function() { |
3201 return !stack; |
3411 return !!locked; |
3202 }, |
3412 }, |
|
3413 |
3203 // Call all callbacks with the given context and arguments |
3414 // Call all callbacks with the given context and arguments |
3204 fireWith: function( context, args ) { |
3415 fireWith: function( context, args ) { |
3205 if ( list && ( !fired || stack ) ) { |
3416 if ( !locked ) { |
3206 args = args || []; |
3417 args = args || []; |
3207 args = [ context, args.slice ? args.slice() : args ]; |
3418 args = [ context, args.slice ? args.slice() : args ]; |
3208 if ( firing ) { |
3419 queue.push( args ); |
3209 stack.push( args ); |
3420 if ( !firing ) { |
3210 } else { |
3421 fire(); |
3211 fire( args ); |
|
3212 } |
3422 } |
3213 } |
3423 } |
3214 return this; |
3424 return this; |
3215 }, |
3425 }, |
|
3426 |
3216 // Call all the callbacks with the given arguments |
3427 // Call all the callbacks with the given arguments |
3217 fire: function() { |
3428 fire: function() { |
3218 self.fireWith( this, arguments ); |
3429 self.fireWith( this, arguments ); |
3219 return this; |
3430 return this; |
3220 }, |
3431 }, |
|
3432 |
3221 // To know if the callbacks have already been called at least once |
3433 // To know if the callbacks have already been called at least once |
3222 fired: function() { |
3434 fired: function() { |
3223 return !!fired; |
3435 return !!fired; |
3224 } |
3436 } |
3225 }; |
3437 }; |
3226 |
3438 |
3227 return self; |
3439 return self; |
3228 }; |
3440 }; |
3229 |
3441 |
3230 |
3442 |
3231 jQuery.extend({ |
3443 function Identity( v ) { |
|
3444 return v; |
|
3445 } |
|
3446 function Thrower( ex ) { |
|
3447 throw ex; |
|
3448 } |
|
3449 |
|
3450 function adoptValue( value, resolve, reject, noValue ) { |
|
3451 var method; |
|
3452 |
|
3453 try { |
|
3454 |
|
3455 // Check for promise aspect first to privilege synchronous behavior |
|
3456 if ( value && isFunction( ( method = value.promise ) ) ) { |
|
3457 method.call( value ).done( resolve ).fail( reject ); |
|
3458 |
|
3459 // Other thenables |
|
3460 } else if ( value && isFunction( ( method = value.then ) ) ) { |
|
3461 method.call( value, resolve, reject ); |
|
3462 |
|
3463 // Other non-thenables |
|
3464 } else { |
|
3465 |
|
3466 // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer: |
|
3467 // * false: [ value ].slice( 0 ) => resolve( value ) |
|
3468 // * true: [ value ].slice( 1 ) => resolve() |
|
3469 resolve.apply( undefined, [ value ].slice( noValue ) ); |
|
3470 } |
|
3471 |
|
3472 // For Promises/A+, convert exceptions into rejections |
|
3473 // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in |
|
3474 // Deferred#then to conditionally suppress rejection. |
|
3475 } catch ( value ) { |
|
3476 |
|
3477 // Support: Android 4.0 only |
|
3478 // Strict mode functions invoked without .call/.apply get global-object context |
|
3479 reject.apply( undefined, [ value ] ); |
|
3480 } |
|
3481 } |
|
3482 |
|
3483 jQuery.extend( { |
3232 |
3484 |
3233 Deferred: function( func ) { |
3485 Deferred: function( func ) { |
3234 var tuples = [ |
3486 var tuples = [ |
3235 // action, add listener, listener list, final state |
3487 |
3236 [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ], |
3488 // action, add listener, callbacks, |
3237 [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ], |
3489 // ... .then handlers, argument index, [final state] |
3238 [ "notify", "progress", jQuery.Callbacks("memory") ] |
3490 [ "notify", "progress", jQuery.Callbacks( "memory" ), |
|
3491 jQuery.Callbacks( "memory" ), 2 ], |
|
3492 [ "resolve", "done", jQuery.Callbacks( "once memory" ), |
|
3493 jQuery.Callbacks( "once memory" ), 0, "resolved" ], |
|
3494 [ "reject", "fail", jQuery.Callbacks( "once memory" ), |
|
3495 jQuery.Callbacks( "once memory" ), 1, "rejected" ] |
3239 ], |
3496 ], |
3240 state = "pending", |
3497 state = "pending", |
3241 promise = { |
3498 promise = { |
3242 state: function() { |
3499 state: function() { |
3243 return state; |
3500 return state; |
3244 }, |
3501 }, |
3245 always: function() { |
3502 always: function() { |
3246 deferred.done( arguments ).fail( arguments ); |
3503 deferred.done( arguments ).fail( arguments ); |
3247 return this; |
3504 return this; |
3248 }, |
3505 }, |
3249 then: function( /* fnDone, fnFail, fnProgress */ ) { |
3506 "catch": function( fn ) { |
|
3507 return promise.then( null, fn ); |
|
3508 }, |
|
3509 |
|
3510 // Keep pipe for back-compat |
|
3511 pipe: function( /* fnDone, fnFail, fnProgress */ ) { |
3250 var fns = arguments; |
3512 var fns = arguments; |
3251 return jQuery.Deferred(function( newDefer ) { |
3513 |
|
3514 return jQuery.Deferred( function( newDefer ) { |
3252 jQuery.each( tuples, function( i, tuple ) { |
3515 jQuery.each( tuples, function( i, tuple ) { |
3253 var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ]; |
3516 |
3254 // deferred[ done | fail | progress ] for forwarding actions to newDefer |
3517 // Map tuples (progress, done, fail) to arguments (done, fail, progress) |
3255 deferred[ tuple[1] ](function() { |
3518 var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ]; |
|
3519 |
|
3520 // deferred.progress(function() { bind to newDefer or newDefer.notify }) |
|
3521 // deferred.done(function() { bind to newDefer or newDefer.resolve }) |
|
3522 // deferred.fail(function() { bind to newDefer or newDefer.reject }) |
|
3523 deferred[ tuple[ 1 ] ]( function() { |
3256 var returned = fn && fn.apply( this, arguments ); |
3524 var returned = fn && fn.apply( this, arguments ); |
3257 if ( returned && jQuery.isFunction( returned.promise ) ) { |
3525 if ( returned && isFunction( returned.promise ) ) { |
3258 returned.promise() |
3526 returned.promise() |
|
3527 .progress( newDefer.notify ) |
3259 .done( newDefer.resolve ) |
3528 .done( newDefer.resolve ) |
3260 .fail( newDefer.reject ) |
3529 .fail( newDefer.reject ); |
3261 .progress( newDefer.notify ); |
|
3262 } else { |
3530 } else { |
3263 newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments ); |
3531 newDefer[ tuple[ 0 ] + "With" ]( |
|
3532 this, |
|
3533 fn ? [ returned ] : arguments |
|
3534 ); |
3264 } |
3535 } |
3265 }); |
3536 } ); |
3266 }); |
3537 } ); |
3267 fns = null; |
3538 fns = null; |
3268 }).promise(); |
3539 } ).promise(); |
3269 }, |
3540 }, |
|
3541 then: function( onFulfilled, onRejected, onProgress ) { |
|
3542 var maxDepth = 0; |
|
3543 function resolve( depth, deferred, handler, special ) { |
|
3544 return function() { |
|
3545 var that = this, |
|
3546 args = arguments, |
|
3547 mightThrow = function() { |
|
3548 var returned, then; |
|
3549 |
|
3550 // Support: Promises/A+ section 2.3.3.3.3 |
|
3551 // https://promisesaplus.com/#point-59 |
|
3552 // Ignore double-resolution attempts |
|
3553 if ( depth < maxDepth ) { |
|
3554 return; |
|
3555 } |
|
3556 |
|
3557 returned = handler.apply( that, args ); |
|
3558 |
|
3559 // Support: Promises/A+ section 2.3.1 |
|
3560 // https://promisesaplus.com/#point-48 |
|
3561 if ( returned === deferred.promise() ) { |
|
3562 throw new TypeError( "Thenable self-resolution" ); |
|
3563 } |
|
3564 |
|
3565 // Support: Promises/A+ sections 2.3.3.1, 3.5 |
|
3566 // https://promisesaplus.com/#point-54 |
|
3567 // https://promisesaplus.com/#point-75 |
|
3568 // Retrieve `then` only once |
|
3569 then = returned && |
|
3570 |
|
3571 // Support: Promises/A+ section 2.3.4 |
|
3572 // https://promisesaplus.com/#point-64 |
|
3573 // Only check objects and functions for thenability |
|
3574 ( typeof returned === "object" || |
|
3575 typeof returned === "function" ) && |
|
3576 returned.then; |
|
3577 |
|
3578 // Handle a returned thenable |
|
3579 if ( isFunction( then ) ) { |
|
3580 |
|
3581 // Special processors (notify) just wait for resolution |
|
3582 if ( special ) { |
|
3583 then.call( |
|
3584 returned, |
|
3585 resolve( maxDepth, deferred, Identity, special ), |
|
3586 resolve( maxDepth, deferred, Thrower, special ) |
|
3587 ); |
|
3588 |
|
3589 // Normal processors (resolve) also hook into progress |
|
3590 } else { |
|
3591 |
|
3592 // ...and disregard older resolution values |
|
3593 maxDepth++; |
|
3594 |
|
3595 then.call( |
|
3596 returned, |
|
3597 resolve( maxDepth, deferred, Identity, special ), |
|
3598 resolve( maxDepth, deferred, Thrower, special ), |
|
3599 resolve( maxDepth, deferred, Identity, |
|
3600 deferred.notifyWith ) |
|
3601 ); |
|
3602 } |
|
3603 |
|
3604 // Handle all other returned values |
|
3605 } else { |
|
3606 |
|
3607 // Only substitute handlers pass on context |
|
3608 // and multiple values (non-spec behavior) |
|
3609 if ( handler !== Identity ) { |
|
3610 that = undefined; |
|
3611 args = [ returned ]; |
|
3612 } |
|
3613 |
|
3614 // Process the value(s) |
|
3615 // Default process is resolve |
|
3616 ( special || deferred.resolveWith )( that, args ); |
|
3617 } |
|
3618 }, |
|
3619 |
|
3620 // Only normal processors (resolve) catch and reject exceptions |
|
3621 process = special ? |
|
3622 mightThrow : |
|
3623 function() { |
|
3624 try { |
|
3625 mightThrow(); |
|
3626 } catch ( e ) { |
|
3627 |
|
3628 if ( jQuery.Deferred.exceptionHook ) { |
|
3629 jQuery.Deferred.exceptionHook( e, |
|
3630 process.stackTrace ); |
|
3631 } |
|
3632 |
|
3633 // Support: Promises/A+ section 2.3.3.3.4.1 |
|
3634 // https://promisesaplus.com/#point-61 |
|
3635 // Ignore post-resolution exceptions |
|
3636 if ( depth + 1 >= maxDepth ) { |
|
3637 |
|
3638 // Only substitute handlers pass on context |
|
3639 // and multiple values (non-spec behavior) |
|
3640 if ( handler !== Thrower ) { |
|
3641 that = undefined; |
|
3642 args = [ e ]; |
|
3643 } |
|
3644 |
|
3645 deferred.rejectWith( that, args ); |
|
3646 } |
|
3647 } |
|
3648 }; |
|
3649 |
|
3650 // Support: Promises/A+ section 2.3.3.3.1 |
|
3651 // https://promisesaplus.com/#point-57 |
|
3652 // Re-resolve promises immediately to dodge false rejection from |
|
3653 // subsequent errors |
|
3654 if ( depth ) { |
|
3655 process(); |
|
3656 } else { |
|
3657 |
|
3658 // Call an optional hook to record the stack, in case of exception |
|
3659 // since it's otherwise lost when execution goes async |
|
3660 if ( jQuery.Deferred.getStackHook ) { |
|
3661 process.stackTrace = jQuery.Deferred.getStackHook(); |
|
3662 } |
|
3663 window.setTimeout( process ); |
|
3664 } |
|
3665 }; |
|
3666 } |
|
3667 |
|
3668 return jQuery.Deferred( function( newDefer ) { |
|
3669 |
|
3670 // progress_handlers.add( ... ) |
|
3671 tuples[ 0 ][ 3 ].add( |
|
3672 resolve( |
|
3673 0, |
|
3674 newDefer, |
|
3675 isFunction( onProgress ) ? |
|
3676 onProgress : |
|
3677 Identity, |
|
3678 newDefer.notifyWith |
|
3679 ) |
|
3680 ); |
|
3681 |
|
3682 // fulfilled_handlers.add( ... ) |
|
3683 tuples[ 1 ][ 3 ].add( |
|
3684 resolve( |
|
3685 0, |
|
3686 newDefer, |
|
3687 isFunction( onFulfilled ) ? |
|
3688 onFulfilled : |
|
3689 Identity |
|
3690 ) |
|
3691 ); |
|
3692 |
|
3693 // rejected_handlers.add( ... ) |
|
3694 tuples[ 2 ][ 3 ].add( |
|
3695 resolve( |
|
3696 0, |
|
3697 newDefer, |
|
3698 isFunction( onRejected ) ? |
|
3699 onRejected : |
|
3700 Thrower |
|
3701 ) |
|
3702 ); |
|
3703 } ).promise(); |
|
3704 }, |
|
3705 |
3270 // Get a promise for this deferred |
3706 // Get a promise for this deferred |
3271 // If obj is provided, the promise aspect is added to the object |
3707 // If obj is provided, the promise aspect is added to the object |
3272 promise: function( obj ) { |
3708 promise: function( obj ) { |
3273 return obj != null ? jQuery.extend( obj, promise ) : promise; |
3709 return obj != null ? jQuery.extend( obj, promise ) : promise; |
3274 } |
3710 } |
3275 }, |
3711 }, |
3276 deferred = {}; |
3712 deferred = {}; |
3277 |
3713 |
3278 // Keep pipe for back-compat |
|
3279 promise.pipe = promise.then; |
|
3280 |
|
3281 // Add list-specific methods |
3714 // Add list-specific methods |
3282 jQuery.each( tuples, function( i, tuple ) { |
3715 jQuery.each( tuples, function( i, tuple ) { |
3283 var list = tuple[ 2 ], |
3716 var list = tuple[ 2 ], |
3284 stateString = tuple[ 3 ]; |
3717 stateString = tuple[ 5 ]; |
3285 |
3718 |
3286 // promise[ done | fail | progress ] = list.add |
3719 // promise.progress = list.add |
3287 promise[ tuple[1] ] = list.add; |
3720 // promise.done = list.add |
|
3721 // promise.fail = list.add |
|
3722 promise[ tuple[ 1 ] ] = list.add; |
3288 |
3723 |
3289 // Handle state |
3724 // Handle state |
3290 if ( stateString ) { |
3725 if ( stateString ) { |
3291 list.add(function() { |
3726 list.add( |
3292 // state = [ resolved | rejected ] |
3727 function() { |
3293 state = stateString; |
3728 |
3294 |
3729 // state = "resolved" (i.e., fulfilled) |
3295 // [ reject_list | resolve_list ].disable; progress_list.lock |
3730 // state = "rejected" |
3296 }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock ); |
3731 state = stateString; |
3297 } |
3732 }, |
3298 |
3733 |
3299 // deferred[ resolve | reject | notify ] |
3734 // rejected_callbacks.disable |
3300 deferred[ tuple[0] ] = function() { |
3735 // fulfilled_callbacks.disable |
3301 deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments ); |
3736 tuples[ 3 - i ][ 2 ].disable, |
|
3737 |
|
3738 // rejected_handlers.disable |
|
3739 // fulfilled_handlers.disable |
|
3740 tuples[ 3 - i ][ 3 ].disable, |
|
3741 |
|
3742 // progress_callbacks.lock |
|
3743 tuples[ 0 ][ 2 ].lock, |
|
3744 |
|
3745 // progress_handlers.lock |
|
3746 tuples[ 0 ][ 3 ].lock |
|
3747 ); |
|
3748 } |
|
3749 |
|
3750 // progress_handlers.fire |
|
3751 // fulfilled_handlers.fire |
|
3752 // rejected_handlers.fire |
|
3753 list.add( tuple[ 3 ].fire ); |
|
3754 |
|
3755 // deferred.notify = function() { deferred.notifyWith(...) } |
|
3756 // deferred.resolve = function() { deferred.resolveWith(...) } |
|
3757 // deferred.reject = function() { deferred.rejectWith(...) } |
|
3758 deferred[ tuple[ 0 ] ] = function() { |
|
3759 deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments ); |
3302 return this; |
3760 return this; |
3303 }; |
3761 }; |
3304 deferred[ tuple[0] + "With" ] = list.fireWith; |
3762 |
3305 }); |
3763 // deferred.notifyWith = list.fireWith |
|
3764 // deferred.resolveWith = list.fireWith |
|
3765 // deferred.rejectWith = list.fireWith |
|
3766 deferred[ tuple[ 0 ] + "With" ] = list.fireWith; |
|
3767 } ); |
3306 |
3768 |
3307 // Make the deferred a promise |
3769 // Make the deferred a promise |
3308 promise.promise( deferred ); |
3770 promise.promise( deferred ); |
3309 |
3771 |
3310 // Call given func if any |
3772 // Call given func if any |
3315 // All done! |
3777 // All done! |
3316 return deferred; |
3778 return deferred; |
3317 }, |
3779 }, |
3318 |
3780 |
3319 // Deferred helper |
3781 // Deferred helper |
3320 when: function( subordinate /* , ..., subordinateN */ ) { |
3782 when: function( singleValue ) { |
3321 var i = 0, |
3783 var |
|
3784 |
|
3785 // count of uncompleted subordinates |
|
3786 remaining = arguments.length, |
|
3787 |
|
3788 // count of unprocessed arguments |
|
3789 i = remaining, |
|
3790 |
|
3791 // subordinate fulfillment data |
|
3792 resolveContexts = Array( i ), |
3322 resolveValues = slice.call( arguments ), |
3793 resolveValues = slice.call( arguments ), |
3323 length = resolveValues.length, |
3794 |
3324 |
3795 // the master Deferred |
3325 // the count of uncompleted subordinates |
3796 master = jQuery.Deferred(), |
3326 remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0, |
3797 |
3327 |
3798 // subordinate callback factory |
3328 // the master Deferred. If resolveValues consist of only a single Deferred, just use that. |
3799 updateFunc = function( i ) { |
3329 deferred = remaining === 1 ? subordinate : jQuery.Deferred(), |
|
3330 |
|
3331 // Update function for both resolve and progress values |
|
3332 updateFunc = function( i, contexts, values ) { |
|
3333 return function( value ) { |
3800 return function( value ) { |
3334 contexts[ i ] = this; |
3801 resolveContexts[ i ] = this; |
3335 values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value; |
3802 resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value; |
3336 if ( values === progressValues ) { |
3803 if ( !( --remaining ) ) { |
3337 deferred.notifyWith( contexts, values ); |
3804 master.resolveWith( resolveContexts, resolveValues ); |
3338 } else if ( !( --remaining ) ) { |
|
3339 deferred.resolveWith( contexts, values ); |
|
3340 } |
3805 } |
3341 }; |
3806 }; |
3342 }, |
3807 }; |
3343 |
3808 |
3344 progressValues, progressContexts, resolveContexts; |
3809 // Single- and empty arguments are adopted like Promise.resolve |
3345 |
3810 if ( remaining <= 1 ) { |
3346 // Add listeners to Deferred subordinates; treat others as resolved |
3811 adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject, |
3347 if ( length > 1 ) { |
3812 !remaining ); |
3348 progressValues = new Array( length ); |
3813 |
3349 progressContexts = new Array( length ); |
3814 // Use .then() to unwrap secondary thenables (cf. gh-3000) |
3350 resolveContexts = new Array( length ); |
3815 if ( master.state() === "pending" || |
3351 for ( ; i < length; i++ ) { |
3816 isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) { |
3352 if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) { |
3817 |
3353 resolveValues[ i ].promise() |
3818 return master.then(); |
3354 .done( updateFunc( i, resolveContexts, resolveValues ) ) |
3819 } |
3355 .fail( deferred.reject ) |
3820 } |
3356 .progress( updateFunc( i, progressContexts, progressValues ) ); |
3821 |
3357 } else { |
3822 // Multiple arguments are aggregated like Promise.all array elements |
3358 --remaining; |
3823 while ( i-- ) { |
3359 } |
3824 adoptValue( resolveValues[ i ], updateFunc( i ), master.reject ); |
3360 } |
3825 } |
3361 } |
3826 |
3362 |
3827 return master.promise(); |
3363 // If we're not waiting on anything, resolve the master |
3828 } |
3364 if ( !remaining ) { |
3829 } ); |
3365 deferred.resolveWith( resolveContexts, resolveValues ); |
3830 |
3366 } |
3831 |
3367 |
3832 // These usually indicate a programmer mistake during development, |
3368 return deferred.promise(); |
3833 // warn about them ASAP rather than swallowing them by default. |
3369 } |
3834 var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/; |
3370 }); |
3835 |
|
3836 jQuery.Deferred.exceptionHook = function( error, stack ) { |
|
3837 |
|
3838 // Support: IE 8 - 9 only |
|
3839 // Console exists when dev tools are open, which can happen at any time |
|
3840 if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) { |
|
3841 window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack ); |
|
3842 } |
|
3843 }; |
|
3844 |
|
3845 |
|
3846 |
|
3847 |
|
3848 jQuery.readyException = function( error ) { |
|
3849 window.setTimeout( function() { |
|
3850 throw error; |
|
3851 } ); |
|
3852 }; |
|
3853 |
|
3854 |
3371 |
3855 |
3372 |
3856 |
3373 // The deferred used on DOM ready |
3857 // The deferred used on DOM ready |
3374 var readyList; |
3858 var readyList = jQuery.Deferred(); |
3375 |
3859 |
3376 jQuery.fn.ready = function( fn ) { |
3860 jQuery.fn.ready = function( fn ) { |
3377 // Add the callback |
3861 |
3378 jQuery.ready.promise().done( fn ); |
3862 readyList |
|
3863 .then( fn ) |
|
3864 |
|
3865 // Wrap jQuery.readyException in a function so that the lookup |
|
3866 // happens at the time of error handling instead of callback |
|
3867 // registration. |
|
3868 .catch( function( error ) { |
|
3869 jQuery.readyException( error ); |
|
3870 } ); |
3379 |
3871 |
3380 return this; |
3872 return this; |
3381 }; |
3873 }; |
3382 |
3874 |
3383 jQuery.extend({ |
3875 jQuery.extend( { |
|
3876 |
3384 // Is the DOM ready to be used? Set to true once it occurs. |
3877 // Is the DOM ready to be used? Set to true once it occurs. |
3385 isReady: false, |
3878 isReady: false, |
3386 |
3879 |
3387 // A counter to track how many items to wait for before |
3880 // A counter to track how many items to wait for before |
3388 // the ready event fires. See #6781 |
3881 // the ready event fires. See #6781 |
3389 readyWait: 1, |
3882 readyWait: 1, |
3390 |
3883 |
3391 // Hold (or release) the ready event |
|
3392 holdReady: function( hold ) { |
|
3393 if ( hold ) { |
|
3394 jQuery.readyWait++; |
|
3395 } else { |
|
3396 jQuery.ready( true ); |
|
3397 } |
|
3398 }, |
|
3399 |
|
3400 // Handle when the DOM is ready |
3884 // Handle when the DOM is ready |
3401 ready: function( wait ) { |
3885 ready: function( wait ) { |
3402 |
3886 |
3403 // Abort if there are pending holds or we're already ready |
3887 // Abort if there are pending holds or we're already ready |
3404 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { |
3888 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { |
3413 return; |
3897 return; |
3414 } |
3898 } |
3415 |
3899 |
3416 // If there are functions bound, to execute |
3900 // If there are functions bound, to execute |
3417 readyList.resolveWith( document, [ jQuery ] ); |
3901 readyList.resolveWith( document, [ jQuery ] ); |
3418 |
3902 } |
3419 // Trigger any bound ready events |
3903 } ); |
3420 if ( jQuery.fn.triggerHandler ) { |
3904 |
3421 jQuery( document ).triggerHandler( "ready" ); |
3905 jQuery.ready.then = readyList.then; |
3422 jQuery( document ).off( "ready" ); |
3906 |
3423 } |
3907 // The ready event handler and self cleanup method |
3424 } |
|
3425 }); |
|
3426 |
|
3427 /** |
|
3428 * The ready event handler and self cleanup method |
|
3429 */ |
|
3430 function completed() { |
3908 function completed() { |
3431 document.removeEventListener( "DOMContentLoaded", completed, false ); |
3909 document.removeEventListener( "DOMContentLoaded", completed ); |
3432 window.removeEventListener( "load", completed, false ); |
3910 window.removeEventListener( "load", completed ); |
3433 jQuery.ready(); |
3911 jQuery.ready(); |
3434 } |
3912 } |
3435 |
3913 |
3436 jQuery.ready.promise = function( obj ) { |
3914 // Catch cases where $(document).ready() is called |
3437 if ( !readyList ) { |
3915 // after the browser event has already occurred. |
3438 |
3916 // Support: IE <=9 - 10 only |
3439 readyList = jQuery.Deferred(); |
3917 // Older IE sometimes signals "interactive" too soon |
3440 |
3918 if ( document.readyState === "complete" || |
3441 // Catch cases where $(document).ready() is called after the browser event has already occurred. |
3919 ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) { |
3442 // We once tried to use readyState "interactive" here, but it caused issues like the one |
3920 |
3443 // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15 |
3921 // Handle it asynchronously to allow scripts the opportunity to delay ready |
3444 if ( document.readyState === "complete" ) { |
3922 window.setTimeout( jQuery.ready ); |
3445 // Handle it asynchronously to allow scripts the opportunity to delay ready |
3923 |
3446 setTimeout( jQuery.ready ); |
3924 } else { |
3447 |
3925 |
3448 } else { |
3926 // Use the handy event callback |
3449 |
3927 document.addEventListener( "DOMContentLoaded", completed ); |
3450 // Use the handy event callback |
3928 |
3451 document.addEventListener( "DOMContentLoaded", completed, false ); |
3929 // A fallback to window.onload, that will always work |
3452 |
3930 window.addEventListener( "load", completed ); |
3453 // A fallback to window.onload, that will always work |
3931 } |
3454 window.addEventListener( "load", completed, false ); |
|
3455 } |
|
3456 } |
|
3457 return readyList.promise( obj ); |
|
3458 }; |
|
3459 |
|
3460 // Kick off the DOM ready check even if the user does not |
|
3461 jQuery.ready.promise(); |
|
3462 |
3932 |
3463 |
3933 |
3464 |
3934 |
3465 |
3935 |
3466 // Multifunctional method to get and set values of a collection |
3936 // Multifunctional method to get and set values of a collection |
3467 // The value/s can optionally be executed if it's a function |
3937 // The value/s can optionally be executed if it's a function |
3468 var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) { |
3938 var access = function( elems, fn, key, value, chainable, emptyGet, raw ) { |
3469 var i = 0, |
3939 var i = 0, |
3470 len = elems.length, |
3940 len = elems.length, |
3471 bulk = key == null; |
3941 bulk = key == null; |
3472 |
3942 |
3473 // Sets many values |
3943 // Sets many values |
3474 if ( jQuery.type( key ) === "object" ) { |
3944 if ( toType( key ) === "object" ) { |
3475 chainable = true; |
3945 chainable = true; |
3476 for ( i in key ) { |
3946 for ( i in key ) { |
3477 jQuery.access( elems, fn, i, key[i], true, emptyGet, raw ); |
3947 access( elems, fn, i, key[ i ], true, emptyGet, raw ); |
3478 } |
3948 } |
3479 |
3949 |
3480 // Sets one value |
3950 // Sets one value |
3481 } else if ( value !== undefined ) { |
3951 } else if ( value !== undefined ) { |
3482 chainable = true; |
3952 chainable = true; |
3483 |
3953 |
3484 if ( !jQuery.isFunction( value ) ) { |
3954 if ( !isFunction( value ) ) { |
3485 raw = true; |
3955 raw = true; |
3486 } |
3956 } |
3487 |
3957 |
3488 if ( bulk ) { |
3958 if ( bulk ) { |
|
3959 |
3489 // Bulk operations run against the entire set |
3960 // Bulk operations run against the entire set |
3490 if ( raw ) { |
3961 if ( raw ) { |
3491 fn.call( elems, value ); |
3962 fn.call( elems, value ); |
3492 fn = null; |
3963 fn = null; |
3493 |
3964 |
3500 } |
3971 } |
3501 } |
3972 } |
3502 |
3973 |
3503 if ( fn ) { |
3974 if ( fn ) { |
3504 for ( ; i < len; i++ ) { |
3975 for ( ; i < len; i++ ) { |
3505 fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) ); |
3976 fn( |
3506 } |
3977 elems[ i ], key, raw ? |
3507 } |
3978 value : |
3508 } |
3979 value.call( elems[ i ], i, fn( elems[ i ], key ) ) |
3509 |
3980 ); |
3510 return chainable ? |
3981 } |
3511 elems : |
3982 } |
3512 |
3983 } |
3513 // Gets |
3984 |
3514 bulk ? |
3985 if ( chainable ) { |
3515 fn.call( elems ) : |
3986 return elems; |
3516 len ? fn( elems[0], key ) : emptyGet; |
3987 } |
|
3988 |
|
3989 // Gets |
|
3990 if ( bulk ) { |
|
3991 return fn.call( elems ); |
|
3992 } |
|
3993 |
|
3994 return len ? fn( elems[ 0 ], key ) : emptyGet; |
3517 }; |
3995 }; |
3518 |
3996 |
3519 |
3997 |
3520 /** |
3998 // Matches dashed string for camelizing |
3521 * Determines whether an object can have data |
3999 var rmsPrefix = /^-ms-/, |
3522 */ |
4000 rdashAlpha = /-([a-z])/g; |
3523 jQuery.acceptData = function( owner ) { |
4001 |
|
4002 // Used by camelCase as callback to replace() |
|
4003 function fcamelCase( all, letter ) { |
|
4004 return letter.toUpperCase(); |
|
4005 } |
|
4006 |
|
4007 // Convert dashed to camelCase; used by the css and data modules |
|
4008 // Support: IE <=9 - 11, Edge 12 - 15 |
|
4009 // Microsoft forgot to hump their vendor prefix (#9572) |
|
4010 function camelCase( string ) { |
|
4011 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); |
|
4012 } |
|
4013 var acceptData = function( owner ) { |
|
4014 |
3524 // Accepts only: |
4015 // Accepts only: |
3525 // - Node |
4016 // - Node |
3526 // - Node.ELEMENT_NODE |
4017 // - Node.ELEMENT_NODE |
3527 // - Node.DOCUMENT_NODE |
4018 // - Node.DOCUMENT_NODE |
3528 // - Object |
4019 // - Object |
3529 // - Any |
4020 // - Any |
3530 /* jshint -W018 */ |
|
3531 return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType ); |
4021 return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType ); |
3532 }; |
4022 }; |
3533 |
4023 |
3534 |
4024 |
|
4025 |
|
4026 |
3535 function Data() { |
4027 function Data() { |
3536 // Support: Android<4, |
|
3537 // Old WebKit does not have Object.preventExtensions/freeze method, |
|
3538 // return new empty object instead with no [[set]] accessor |
|
3539 Object.defineProperty( this.cache = {}, 0, { |
|
3540 get: function() { |
|
3541 return {}; |
|
3542 } |
|
3543 }); |
|
3544 |
|
3545 this.expando = jQuery.expando + Data.uid++; |
4028 this.expando = jQuery.expando + Data.uid++; |
3546 } |
4029 } |
3547 |
4030 |
3548 Data.uid = 1; |
4031 Data.uid = 1; |
3549 Data.accepts = jQuery.acceptData; |
|
3550 |
4032 |
3551 Data.prototype = { |
4033 Data.prototype = { |
3552 key: function( owner ) { |
4034 |
3553 // We can accept data for non-element nodes in modern browsers, |
4035 cache: function( owner ) { |
3554 // but we should not, see #8335. |
4036 |
3555 // Always return the key for a frozen object. |
4037 // Check if the owner object already has a cache |
3556 if ( !Data.accepts( owner ) ) { |
4038 var value = owner[ this.expando ]; |
3557 return 0; |
|
3558 } |
|
3559 |
|
3560 var descriptor = {}, |
|
3561 // Check if the owner object already has a cache key |
|
3562 unlock = owner[ this.expando ]; |
|
3563 |
4039 |
3564 // If not, create one |
4040 // If not, create one |
3565 if ( !unlock ) { |
4041 if ( !value ) { |
3566 unlock = Data.uid++; |
4042 value = {}; |
3567 |
4043 |
3568 // Secure it in a non-enumerable, non-writable property |
4044 // We can accept data for non-element nodes in modern browsers, |
3569 try { |
4045 // but we should not, see #8335. |
3570 descriptor[ this.expando ] = { value: unlock }; |
4046 // Always return an empty object. |
3571 Object.defineProperties( owner, descriptor ); |
4047 if ( acceptData( owner ) ) { |
3572 |
4048 |
3573 // Support: Android<4 |
4049 // If it is a node unlikely to be stringify-ed or looped over |
3574 // Fallback to a less secure definition |
4050 // use plain assignment |
3575 } catch ( e ) { |
4051 if ( owner.nodeType ) { |
3576 descriptor[ this.expando ] = unlock; |
4052 owner[ this.expando ] = value; |
3577 jQuery.extend( owner, descriptor ); |
4053 |
3578 } |
4054 // Otherwise secure it in a non-enumerable property |
3579 } |
4055 // configurable must be true to allow the property to be |
3580 |
4056 // deleted when data is removed |
3581 // Ensure the cache object |
4057 } else { |
3582 if ( !this.cache[ unlock ] ) { |
4058 Object.defineProperty( owner, this.expando, { |
3583 this.cache[ unlock ] = {}; |
4059 value: value, |
3584 } |
4060 configurable: true |
3585 |
4061 } ); |
3586 return unlock; |
4062 } |
|
4063 } |
|
4064 } |
|
4065 |
|
4066 return value; |
3587 }, |
4067 }, |
3588 set: function( owner, data, value ) { |
4068 set: function( owner, data, value ) { |
3589 var prop, |
4069 var prop, |
3590 // There may be an unlock assigned to this node, |
4070 cache = this.cache( owner ); |
3591 // if there is no entry for this "owner", create one inline |
|
3592 // and set the unlock as though an owner entry had always existed |
|
3593 unlock = this.key( owner ), |
|
3594 cache = this.cache[ unlock ]; |
|
3595 |
4071 |
3596 // Handle: [ owner, key, value ] args |
4072 // Handle: [ owner, key, value ] args |
|
4073 // Always use camelCase key (gh-2257) |
3597 if ( typeof data === "string" ) { |
4074 if ( typeof data === "string" ) { |
3598 cache[ data ] = value; |
4075 cache[ camelCase( data ) ] = value; |
3599 |
4076 |
3600 // Handle: [ owner, { properties } ] args |
4077 // Handle: [ owner, { properties } ] args |
3601 } else { |
4078 } else { |
3602 // Fresh assignments by object are shallow copied |
4079 |
3603 if ( jQuery.isEmptyObject( cache ) ) { |
4080 // Copy the properties one-by-one to the cache object |
3604 jQuery.extend( this.cache[ unlock ], data ); |
4081 for ( prop in data ) { |
3605 // Otherwise, copy the properties one-by-one to the cache object |
4082 cache[ camelCase( prop ) ] = data[ prop ]; |
3606 } else { |
|
3607 for ( prop in data ) { |
|
3608 cache[ prop ] = data[ prop ]; |
|
3609 } |
|
3610 } |
4083 } |
3611 } |
4084 } |
3612 return cache; |
4085 return cache; |
3613 }, |
4086 }, |
3614 get: function( owner, key ) { |
4087 get: function( owner, key ) { |
3615 // Either a valid cache is found, or will be created. |
|
3616 // New caches will be created and the unlock returned, |
|
3617 // allowing direct access to the newly created |
|
3618 // empty data object. A valid owner object must be provided. |
|
3619 var cache = this.cache[ this.key( owner ) ]; |
|
3620 |
|
3621 return key === undefined ? |
4088 return key === undefined ? |
3622 cache : cache[ key ]; |
4089 this.cache( owner ) : |
|
4090 |
|
4091 // Always use camelCase key (gh-2257) |
|
4092 owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ]; |
3623 }, |
4093 }, |
3624 access: function( owner, key, value ) { |
4094 access: function( owner, key, value ) { |
3625 var stored; |
4095 |
3626 // In cases where either: |
4096 // In cases where either: |
3627 // |
4097 // |
3628 // 1. No key was specified |
4098 // 1. No key was specified |
3629 // 2. A string key was specified, but no value provided |
4099 // 2. A string key was specified, but no value provided |
3630 // |
4100 // |
3719 // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData) |
4189 // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData) |
3720 // 5. Avoid exposing implementation details on user objects (eg. expando properties) |
4190 // 5. Avoid exposing implementation details on user objects (eg. expando properties) |
3721 // 6. Provide a clear path for implementation upgrade to WeakMap in 2014 |
4191 // 6. Provide a clear path for implementation upgrade to WeakMap in 2014 |
3722 |
4192 |
3723 var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, |
4193 var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, |
3724 rmultiDash = /([A-Z])/g; |
4194 rmultiDash = /[A-Z]/g; |
|
4195 |
|
4196 function getData( data ) { |
|
4197 if ( data === "true" ) { |
|
4198 return true; |
|
4199 } |
|
4200 |
|
4201 if ( data === "false" ) { |
|
4202 return false; |
|
4203 } |
|
4204 |
|
4205 if ( data === "null" ) { |
|
4206 return null; |
|
4207 } |
|
4208 |
|
4209 // Only convert to a number if it doesn't change the string |
|
4210 if ( data === +data + "" ) { |
|
4211 return +data; |
|
4212 } |
|
4213 |
|
4214 if ( rbrace.test( data ) ) { |
|
4215 return JSON.parse( data ); |
|
4216 } |
|
4217 |
|
4218 return data; |
|
4219 } |
3725 |
4220 |
3726 function dataAttr( elem, key, data ) { |
4221 function dataAttr( elem, key, data ) { |
3727 var name; |
4222 var name; |
3728 |
4223 |
3729 // If nothing was found internally, try to fetch any |
4224 // If nothing was found internally, try to fetch any |
3730 // data from the HTML5 data-* attribute |
4225 // data from the HTML5 data-* attribute |
3731 if ( data === undefined && elem.nodeType === 1 ) { |
4226 if ( data === undefined && elem.nodeType === 1 ) { |
3732 name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); |
4227 name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase(); |
3733 data = elem.getAttribute( name ); |
4228 data = elem.getAttribute( name ); |
3734 |
4229 |
3735 if ( typeof data === "string" ) { |
4230 if ( typeof data === "string" ) { |
3736 try { |
4231 try { |
3737 data = data === "true" ? true : |
4232 data = getData( data ); |
3738 data === "false" ? false : |
4233 } catch ( e ) {} |
3739 data === "null" ? null : |
|
3740 // Only convert to a number if it doesn't change the string |
|
3741 +data + "" === data ? +data : |
|
3742 rbrace.test( data ) ? jQuery.parseJSON( data ) : |
|
3743 data; |
|
3744 } catch( e ) {} |
|
3745 |
4234 |
3746 // Make sure we set the data so it isn't changed later |
4235 // Make sure we set the data so it isn't changed later |
3747 data_user.set( elem, key, data ); |
4236 dataUser.set( elem, key, data ); |
3748 } else { |
4237 } else { |
3749 data = undefined; |
4238 data = undefined; |
3750 } |
4239 } |
3751 } |
4240 } |
3752 return data; |
4241 return data; |
3753 } |
4242 } |
3754 |
4243 |
3755 jQuery.extend({ |
4244 jQuery.extend( { |
3756 hasData: function( elem ) { |
4245 hasData: function( elem ) { |
3757 return data_user.hasData( elem ) || data_priv.hasData( elem ); |
4246 return dataUser.hasData( elem ) || dataPriv.hasData( elem ); |
3758 }, |
4247 }, |
3759 |
4248 |
3760 data: function( elem, name, data ) { |
4249 data: function( elem, name, data ) { |
3761 return data_user.access( elem, name, data ); |
4250 return dataUser.access( elem, name, data ); |
3762 }, |
4251 }, |
3763 |
4252 |
3764 removeData: function( elem, name ) { |
4253 removeData: function( elem, name ) { |
3765 data_user.remove( elem, name ); |
4254 dataUser.remove( elem, name ); |
3766 }, |
4255 }, |
3767 |
4256 |
3768 // TODO: Now that all calls to _data and _removeData have been replaced |
4257 // TODO: Now that all calls to _data and _removeData have been replaced |
3769 // with direct calls to data_priv methods, these can be deprecated. |
4258 // with direct calls to dataPriv methods, these can be deprecated. |
3770 _data: function( elem, name, data ) { |
4259 _data: function( elem, name, data ) { |
3771 return data_priv.access( elem, name, data ); |
4260 return dataPriv.access( elem, name, data ); |
3772 }, |
4261 }, |
3773 |
4262 |
3774 _removeData: function( elem, name ) { |
4263 _removeData: function( elem, name ) { |
3775 data_priv.remove( elem, name ); |
4264 dataPriv.remove( elem, name ); |
3776 } |
4265 } |
3777 }); |
4266 } ); |
3778 |
4267 |
3779 jQuery.fn.extend({ |
4268 jQuery.fn.extend( { |
3780 data: function( key, value ) { |
4269 data: function( key, value ) { |
3781 var i, name, data, |
4270 var i, name, data, |
3782 elem = this[ 0 ], |
4271 elem = this[ 0 ], |
3783 attrs = elem && elem.attributes; |
4272 attrs = elem && elem.attributes; |
3784 |
4273 |
3785 // Gets all values |
4274 // Gets all values |
3786 if ( key === undefined ) { |
4275 if ( key === undefined ) { |
3787 if ( this.length ) { |
4276 if ( this.length ) { |
3788 data = data_user.get( elem ); |
4277 data = dataUser.get( elem ); |
3789 |
4278 |
3790 if ( elem.nodeType === 1 && !data_priv.get( elem, "hasDataAttrs" ) ) { |
4279 if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) { |
3791 i = attrs.length; |
4280 i = attrs.length; |
3792 while ( i-- ) { |
4281 while ( i-- ) { |
3793 |
4282 |
3794 // Support: IE11+ |
4283 // Support: IE 11 only |
3795 // The attrs elements can be null (#14894) |
4284 // The attrs elements can be null (#14894) |
3796 if ( attrs[ i ] ) { |
4285 if ( attrs[ i ] ) { |
3797 name = attrs[ i ].name; |
4286 name = attrs[ i ].name; |
3798 if ( name.indexOf( "data-" ) === 0 ) { |
4287 if ( name.indexOf( "data-" ) === 0 ) { |
3799 name = jQuery.camelCase( name.slice(5) ); |
4288 name = camelCase( name.slice( 5 ) ); |
3800 dataAttr( elem, name, data[ name ] ); |
4289 dataAttr( elem, name, data[ name ] ); |
3801 } |
4290 } |
3802 } |
4291 } |
3803 } |
4292 } |
3804 data_priv.set( elem, "hasDataAttrs", true ); |
4293 dataPriv.set( elem, "hasDataAttrs", true ); |
3805 } |
4294 } |
3806 } |
4295 } |
3807 |
4296 |
3808 return data; |
4297 return data; |
3809 } |
4298 } |
3810 |
4299 |
3811 // Sets multiple values |
4300 // Sets multiple values |
3812 if ( typeof key === "object" ) { |
4301 if ( typeof key === "object" ) { |
3813 return this.each(function() { |
4302 return this.each( function() { |
3814 data_user.set( this, key ); |
4303 dataUser.set( this, key ); |
3815 }); |
4304 } ); |
3816 } |
4305 } |
3817 |
4306 |
3818 return access( this, function( value ) { |
4307 return access( this, function( value ) { |
3819 var data, |
4308 var data; |
3820 camelKey = jQuery.camelCase( key ); |
|
3821 |
4309 |
3822 // The calling jQuery object (element matches) is not empty |
4310 // The calling jQuery object (element matches) is not empty |
3823 // (and therefore has an element appears at this[ 0 ]) and the |
4311 // (and therefore has an element appears at this[ 0 ]) and the |
3824 // `value` parameter was not undefined. An empty jQuery object |
4312 // `value` parameter was not undefined. An empty jQuery object |
3825 // will result in `undefined` for elem = this[ 0 ] which will |
4313 // will result in `undefined` for elem = this[ 0 ] which will |
3826 // throw an exception if an attempt to read a data cache is made. |
4314 // throw an exception if an attempt to read a data cache is made. |
3827 if ( elem && value === undefined ) { |
4315 if ( elem && value === undefined ) { |
|
4316 |
3828 // Attempt to get data from the cache |
4317 // Attempt to get data from the cache |
3829 // with the key as-is |
4318 // The key will always be camelCased in Data |
3830 data = data_user.get( elem, key ); |
4319 data = dataUser.get( elem, key ); |
3831 if ( data !== undefined ) { |
4320 if ( data !== undefined ) { |
3832 return data; |
4321 return data; |
3833 } |
4322 } |
3834 |
4323 |
3835 // Attempt to get data from the cache |
4324 // Attempt to "discover" the data in |
3836 // with the key camelized |
4325 // HTML5 custom data-* attrs |
3837 data = data_user.get( elem, camelKey ); |
4326 data = dataAttr( elem, key ); |
3838 if ( data !== undefined ) { |
4327 if ( data !== undefined ) { |
3839 return data; |
4328 return data; |
3840 } |
4329 } |
3841 |
4330 |
3842 // Attempt to "discover" the data in |
|
3843 // HTML5 custom data-* attrs |
|
3844 data = dataAttr( elem, camelKey, undefined ); |
|
3845 if ( data !== undefined ) { |
|
3846 return data; |
|
3847 } |
|
3848 |
|
3849 // We tried really hard, but the data doesn't exist. |
4331 // We tried really hard, but the data doesn't exist. |
3850 return; |
4332 return; |
3851 } |
4333 } |
3852 |
4334 |
3853 // Set the data... |
4335 // Set the data... |
3854 this.each(function() { |
4336 this.each( function() { |
3855 // First, attempt to store a copy or reference of any |
4337 |
3856 // data that might've been store with a camelCased key. |
4338 // We always store the camelCased key |
3857 var data = data_user.get( this, camelKey ); |
4339 dataUser.set( this, key, value ); |
3858 |
4340 } ); |
3859 // For HTML5 data-* attribute interop, we have to |
|
3860 // store property names with dashes in a camelCase form. |
|
3861 // This might not apply to all properties...* |
|
3862 data_user.set( this, camelKey, value ); |
|
3863 |
|
3864 // *... In the case of properties that might _actually_ |
|
3865 // have dashes, we need to also store a copy of that |
|
3866 // unchanged property. |
|
3867 if ( key.indexOf("-") !== -1 && data !== undefined ) { |
|
3868 data_user.set( this, key, value ); |
|
3869 } |
|
3870 }); |
|
3871 }, null, value, arguments.length > 1, null, true ); |
4341 }, null, value, arguments.length > 1, null, true ); |
3872 }, |
4342 }, |
3873 |
4343 |
3874 removeData: function( key ) { |
4344 removeData: function( key ) { |
3875 return this.each(function() { |
4345 return this.each( function() { |
3876 data_user.remove( this, key ); |
4346 dataUser.remove( this, key ); |
3877 }); |
4347 } ); |
3878 } |
4348 } |
3879 }); |
4349 } ); |
3880 |
4350 |
3881 |
4351 |
3882 jQuery.extend({ |
4352 jQuery.extend( { |
3883 queue: function( elem, type, data ) { |
4353 queue: function( elem, type, data ) { |
3884 var queue; |
4354 var queue; |
3885 |
4355 |
3886 if ( elem ) { |
4356 if ( elem ) { |
3887 type = ( type || "fx" ) + "queue"; |
4357 type = ( type || "fx" ) + "queue"; |
3888 queue = data_priv.get( elem, type ); |
4358 queue = dataPriv.get( elem, type ); |
3889 |
4359 |
3890 // Speed up dequeue by getting out quickly if this is just a lookup |
4360 // Speed up dequeue by getting out quickly if this is just a lookup |
3891 if ( data ) { |
4361 if ( data ) { |
3892 if ( !queue || jQuery.isArray( data ) ) { |
4362 if ( !queue || Array.isArray( data ) ) { |
3893 queue = data_priv.access( elem, type, jQuery.makeArray(data) ); |
4363 queue = dataPriv.access( elem, type, jQuery.makeArray( data ) ); |
3894 } else { |
4364 } else { |
3895 queue.push( data ); |
4365 queue.push( data ); |
3896 } |
4366 } |
3897 } |
4367 } |
3898 return queue || []; |
4368 return queue || []; |
3999 type = undefined; |
4470 type = undefined; |
4000 } |
4471 } |
4001 type = type || "fx"; |
4472 type = type || "fx"; |
4002 |
4473 |
4003 while ( i-- ) { |
4474 while ( i-- ) { |
4004 tmp = data_priv.get( elements[ i ], type + "queueHooks" ); |
4475 tmp = dataPriv.get( elements[ i ], type + "queueHooks" ); |
4005 if ( tmp && tmp.empty ) { |
4476 if ( tmp && tmp.empty ) { |
4006 count++; |
4477 count++; |
4007 tmp.empty.add( resolve ); |
4478 tmp.empty.add( resolve ); |
4008 } |
4479 } |
4009 } |
4480 } |
4010 resolve(); |
4481 resolve(); |
4011 return defer.promise( obj ); |
4482 return defer.promise( obj ); |
4012 } |
4483 } |
4013 }); |
4484 } ); |
4014 var pnum = (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source; |
4485 var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source; |
|
4486 |
|
4487 var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ); |
|
4488 |
4015 |
4489 |
4016 var cssExpand = [ "Top", "Right", "Bottom", "Left" ]; |
4490 var cssExpand = [ "Top", "Right", "Bottom", "Left" ]; |
4017 |
4491 |
4018 var isHidden = function( elem, el ) { |
4492 var documentElement = document.documentElement; |
4019 // isHidden might be called from jQuery#filter function; |
4493 |
|
4494 |
|
4495 |
|
4496 var isAttached = function( elem ) { |
|
4497 return jQuery.contains( elem.ownerDocument, elem ); |
|
4498 }, |
|
4499 composed = { composed: true }; |
|
4500 |
|
4501 // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only |
|
4502 // Check attachment across shadow DOM boundaries when possible (gh-3504) |
|
4503 // Support: iOS 10.0-10.2 only |
|
4504 // Early iOS 10 versions support `attachShadow` but not `getRootNode`, |
|
4505 // leading to errors. We need to check for `getRootNode`. |
|
4506 if ( documentElement.getRootNode ) { |
|
4507 isAttached = function( elem ) { |
|
4508 return jQuery.contains( elem.ownerDocument, elem ) || |
|
4509 elem.getRootNode( composed ) === elem.ownerDocument; |
|
4510 }; |
|
4511 } |
|
4512 var isHiddenWithinTree = function( elem, el ) { |
|
4513 |
|
4514 // isHiddenWithinTree might be called from jQuery#filter function; |
4020 // in that case, element will be second argument |
4515 // in that case, element will be second argument |
4021 elem = el || elem; |
4516 elem = el || elem; |
4022 return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem ); |
4517 |
|
4518 // Inline style trumps all |
|
4519 return elem.style.display === "none" || |
|
4520 elem.style.display === "" && |
|
4521 |
|
4522 // Otherwise, check computed style |
|
4523 // Support: Firefox <=43 - 45 |
|
4524 // Disconnected elements can have computed display: none, so first confirm that elem is |
|
4525 // in the document. |
|
4526 isAttached( elem ) && |
|
4527 |
|
4528 jQuery.css( elem, "display" ) === "none"; |
4023 }; |
4529 }; |
4024 |
4530 |
4025 var rcheckableType = (/^(?:checkbox|radio)$/i); |
4531 var swap = function( elem, options, callback, args ) { |
4026 |
4532 var ret, name, |
4027 |
4533 old = {}; |
4028 |
4534 |
4029 (function() { |
4535 // Remember the old values, and insert the new ones |
|
4536 for ( name in options ) { |
|
4537 old[ name ] = elem.style[ name ]; |
|
4538 elem.style[ name ] = options[ name ]; |
|
4539 } |
|
4540 |
|
4541 ret = callback.apply( elem, args || [] ); |
|
4542 |
|
4543 // Revert the old values |
|
4544 for ( name in options ) { |
|
4545 elem.style[ name ] = old[ name ]; |
|
4546 } |
|
4547 |
|
4548 return ret; |
|
4549 }; |
|
4550 |
|
4551 |
|
4552 |
|
4553 |
|
4554 function adjustCSS( elem, prop, valueParts, tween ) { |
|
4555 var adjusted, scale, |
|
4556 maxIterations = 20, |
|
4557 currentValue = tween ? |
|
4558 function() { |
|
4559 return tween.cur(); |
|
4560 } : |
|
4561 function() { |
|
4562 return jQuery.css( elem, prop, "" ); |
|
4563 }, |
|
4564 initial = currentValue(), |
|
4565 unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ), |
|
4566 |
|
4567 // Starting value computation is required for potential unit mismatches |
|
4568 initialInUnit = elem.nodeType && |
|
4569 ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) && |
|
4570 rcssNum.exec( jQuery.css( elem, prop ) ); |
|
4571 |
|
4572 if ( initialInUnit && initialInUnit[ 3 ] !== unit ) { |
|
4573 |
|
4574 // Support: Firefox <=54 |
|
4575 // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144) |
|
4576 initial = initial / 2; |
|
4577 |
|
4578 // Trust units reported by jQuery.css |
|
4579 unit = unit || initialInUnit[ 3 ]; |
|
4580 |
|
4581 // Iteratively approximate from a nonzero starting point |
|
4582 initialInUnit = +initial || 1; |
|
4583 |
|
4584 while ( maxIterations-- ) { |
|
4585 |
|
4586 // Evaluate and update our best guess (doubling guesses that zero out). |
|
4587 // Finish if the scale equals or crosses 1 (making the old*new product non-positive). |
|
4588 jQuery.style( elem, prop, initialInUnit + unit ); |
|
4589 if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) { |
|
4590 maxIterations = 0; |
|
4591 } |
|
4592 initialInUnit = initialInUnit / scale; |
|
4593 |
|
4594 } |
|
4595 |
|
4596 initialInUnit = initialInUnit * 2; |
|
4597 jQuery.style( elem, prop, initialInUnit + unit ); |
|
4598 |
|
4599 // Make sure we update the tween properties later on |
|
4600 valueParts = valueParts || []; |
|
4601 } |
|
4602 |
|
4603 if ( valueParts ) { |
|
4604 initialInUnit = +initialInUnit || +initial || 0; |
|
4605 |
|
4606 // Apply relative offset (+=/-=) if specified |
|
4607 adjusted = valueParts[ 1 ] ? |
|
4608 initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] : |
|
4609 +valueParts[ 2 ]; |
|
4610 if ( tween ) { |
|
4611 tween.unit = unit; |
|
4612 tween.start = initialInUnit; |
|
4613 tween.end = adjusted; |
|
4614 } |
|
4615 } |
|
4616 return adjusted; |
|
4617 } |
|
4618 |
|
4619 |
|
4620 var defaultDisplayMap = {}; |
|
4621 |
|
4622 function getDefaultDisplay( elem ) { |
|
4623 var temp, |
|
4624 doc = elem.ownerDocument, |
|
4625 nodeName = elem.nodeName, |
|
4626 display = defaultDisplayMap[ nodeName ]; |
|
4627 |
|
4628 if ( display ) { |
|
4629 return display; |
|
4630 } |
|
4631 |
|
4632 temp = doc.body.appendChild( doc.createElement( nodeName ) ); |
|
4633 display = jQuery.css( temp, "display" ); |
|
4634 |
|
4635 temp.parentNode.removeChild( temp ); |
|
4636 |
|
4637 if ( display === "none" ) { |
|
4638 display = "block"; |
|
4639 } |
|
4640 defaultDisplayMap[ nodeName ] = display; |
|
4641 |
|
4642 return display; |
|
4643 } |
|
4644 |
|
4645 function showHide( elements, show ) { |
|
4646 var display, elem, |
|
4647 values = [], |
|
4648 index = 0, |
|
4649 length = elements.length; |
|
4650 |
|
4651 // Determine new display value for elements that need to change |
|
4652 for ( ; index < length; index++ ) { |
|
4653 elem = elements[ index ]; |
|
4654 if ( !elem.style ) { |
|
4655 continue; |
|
4656 } |
|
4657 |
|
4658 display = elem.style.display; |
|
4659 if ( show ) { |
|
4660 |
|
4661 // Since we force visibility upon cascade-hidden elements, an immediate (and slow) |
|
4662 // check is required in this first loop unless we have a nonempty display value (either |
|
4663 // inline or about-to-be-restored) |
|
4664 if ( display === "none" ) { |
|
4665 values[ index ] = dataPriv.get( elem, "display" ) || null; |
|
4666 if ( !values[ index ] ) { |
|
4667 elem.style.display = ""; |
|
4668 } |
|
4669 } |
|
4670 if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) { |
|
4671 values[ index ] = getDefaultDisplay( elem ); |
|
4672 } |
|
4673 } else { |
|
4674 if ( display !== "none" ) { |
|
4675 values[ index ] = "none"; |
|
4676 |
|
4677 // Remember what we're overwriting |
|
4678 dataPriv.set( elem, "display", display ); |
|
4679 } |
|
4680 } |
|
4681 } |
|
4682 |
|
4683 // Set the display of the elements in a second loop to avoid constant reflow |
|
4684 for ( index = 0; index < length; index++ ) { |
|
4685 if ( values[ index ] != null ) { |
|
4686 elements[ index ].style.display = values[ index ]; |
|
4687 } |
|
4688 } |
|
4689 |
|
4690 return elements; |
|
4691 } |
|
4692 |
|
4693 jQuery.fn.extend( { |
|
4694 show: function() { |
|
4695 return showHide( this, true ); |
|
4696 }, |
|
4697 hide: function() { |
|
4698 return showHide( this ); |
|
4699 }, |
|
4700 toggle: function( state ) { |
|
4701 if ( typeof state === "boolean" ) { |
|
4702 return state ? this.show() : this.hide(); |
|
4703 } |
|
4704 |
|
4705 return this.each( function() { |
|
4706 if ( isHiddenWithinTree( this ) ) { |
|
4707 jQuery( this ).show(); |
|
4708 } else { |
|
4709 jQuery( this ).hide(); |
|
4710 } |
|
4711 } ); |
|
4712 } |
|
4713 } ); |
|
4714 var rcheckableType = ( /^(?:checkbox|radio)$/i ); |
|
4715 |
|
4716 var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i ); |
|
4717 |
|
4718 var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i ); |
|
4719 |
|
4720 |
|
4721 |
|
4722 // We have to close these tags to support XHTML (#13200) |
|
4723 var wrapMap = { |
|
4724 |
|
4725 // Support: IE <=9 only |
|
4726 option: [ 1, "<select multiple='multiple'>", "</select>" ], |
|
4727 |
|
4728 // XHTML parsers do not magically insert elements in the |
|
4729 // same way that tag soup parsers do. So we cannot shorten |
|
4730 // this by omitting <tbody> or other required elements. |
|
4731 thead: [ 1, "<table>", "</table>" ], |
|
4732 col: [ 2, "<table><colgroup>", "</colgroup></table>" ], |
|
4733 tr: [ 2, "<table><tbody>", "</tbody></table>" ], |
|
4734 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ], |
|
4735 |
|
4736 _default: [ 0, "", "" ] |
|
4737 }; |
|
4738 |
|
4739 // Support: IE <=9 only |
|
4740 wrapMap.optgroup = wrapMap.option; |
|
4741 |
|
4742 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; |
|
4743 wrapMap.th = wrapMap.td; |
|
4744 |
|
4745 |
|
4746 function getAll( context, tag ) { |
|
4747 |
|
4748 // Support: IE <=9 - 11 only |
|
4749 // Use typeof to avoid zero-argument method invocation on host objects (#15151) |
|
4750 var ret; |
|
4751 |
|
4752 if ( typeof context.getElementsByTagName !== "undefined" ) { |
|
4753 ret = context.getElementsByTagName( tag || "*" ); |
|
4754 |
|
4755 } else if ( typeof context.querySelectorAll !== "undefined" ) { |
|
4756 ret = context.querySelectorAll( tag || "*" ); |
|
4757 |
|
4758 } else { |
|
4759 ret = []; |
|
4760 } |
|
4761 |
|
4762 if ( tag === undefined || tag && nodeName( context, tag ) ) { |
|
4763 return jQuery.merge( [ context ], ret ); |
|
4764 } |
|
4765 |
|
4766 return ret; |
|
4767 } |
|
4768 |
|
4769 |
|
4770 // Mark scripts as having already been evaluated |
|
4771 function setGlobalEval( elems, refElements ) { |
|
4772 var i = 0, |
|
4773 l = elems.length; |
|
4774 |
|
4775 for ( ; i < l; i++ ) { |
|
4776 dataPriv.set( |
|
4777 elems[ i ], |
|
4778 "globalEval", |
|
4779 !refElements || dataPriv.get( refElements[ i ], "globalEval" ) |
|
4780 ); |
|
4781 } |
|
4782 } |
|
4783 |
|
4784 |
|
4785 var rhtml = /<|&#?\w+;/; |
|
4786 |
|
4787 function buildFragment( elems, context, scripts, selection, ignored ) { |
|
4788 var elem, tmp, tag, wrap, attached, j, |
|
4789 fragment = context.createDocumentFragment(), |
|
4790 nodes = [], |
|
4791 i = 0, |
|
4792 l = elems.length; |
|
4793 |
|
4794 for ( ; i < l; i++ ) { |
|
4795 elem = elems[ i ]; |
|
4796 |
|
4797 if ( elem || elem === 0 ) { |
|
4798 |
|
4799 // Add nodes directly |
|
4800 if ( toType( elem ) === "object" ) { |
|
4801 |
|
4802 // Support: Android <=4.0 only, PhantomJS 1 only |
|
4803 // push.apply(_, arraylike) throws on ancient WebKit |
|
4804 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem ); |
|
4805 |
|
4806 // Convert non-html into a text node |
|
4807 } else if ( !rhtml.test( elem ) ) { |
|
4808 nodes.push( context.createTextNode( elem ) ); |
|
4809 |
|
4810 // Convert html into DOM nodes |
|
4811 } else { |
|
4812 tmp = tmp || fragment.appendChild( context.createElement( "div" ) ); |
|
4813 |
|
4814 // Deserialize a standard representation |
|
4815 tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase(); |
|
4816 wrap = wrapMap[ tag ] || wrapMap._default; |
|
4817 tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ]; |
|
4818 |
|
4819 // Descend through wrappers to the right content |
|
4820 j = wrap[ 0 ]; |
|
4821 while ( j-- ) { |
|
4822 tmp = tmp.lastChild; |
|
4823 } |
|
4824 |
|
4825 // Support: Android <=4.0 only, PhantomJS 1 only |
|
4826 // push.apply(_, arraylike) throws on ancient WebKit |
|
4827 jQuery.merge( nodes, tmp.childNodes ); |
|
4828 |
|
4829 // Remember the top-level container |
|
4830 tmp = fragment.firstChild; |
|
4831 |
|
4832 // Ensure the created nodes are orphaned (#12392) |
|
4833 tmp.textContent = ""; |
|
4834 } |
|
4835 } |
|
4836 } |
|
4837 |
|
4838 // Remove wrapper from fragment |
|
4839 fragment.textContent = ""; |
|
4840 |
|
4841 i = 0; |
|
4842 while ( ( elem = nodes[ i++ ] ) ) { |
|
4843 |
|
4844 // Skip elements already in the context collection (trac-4087) |
|
4845 if ( selection && jQuery.inArray( elem, selection ) > -1 ) { |
|
4846 if ( ignored ) { |
|
4847 ignored.push( elem ); |
|
4848 } |
|
4849 continue; |
|
4850 } |
|
4851 |
|
4852 attached = isAttached( elem ); |
|
4853 |
|
4854 // Append to fragment |
|
4855 tmp = getAll( fragment.appendChild( elem ), "script" ); |
|
4856 |
|
4857 // Preserve script evaluation history |
|
4858 if ( attached ) { |
|
4859 setGlobalEval( tmp ); |
|
4860 } |
|
4861 |
|
4862 // Capture executables |
|
4863 if ( scripts ) { |
|
4864 j = 0; |
|
4865 while ( ( elem = tmp[ j++ ] ) ) { |
|
4866 if ( rscriptType.test( elem.type || "" ) ) { |
|
4867 scripts.push( elem ); |
|
4868 } |
|
4869 } |
|
4870 } |
|
4871 } |
|
4872 |
|
4873 return fragment; |
|
4874 } |
|
4875 |
|
4876 |
|
4877 ( function() { |
4030 var fragment = document.createDocumentFragment(), |
4878 var fragment = document.createDocumentFragment(), |
4031 div = fragment.appendChild( document.createElement( "div" ) ), |
4879 div = fragment.appendChild( document.createElement( "div" ) ), |
4032 input = document.createElement( "input" ); |
4880 input = document.createElement( "input" ); |
4033 |
4881 |
4034 // Support: Safari<=5.1 |
4882 // Support: Android 4.0 - 4.3 only |
4035 // Check state lost if the name is set (#11217) |
4883 // Check state lost if the name is set (#11217) |
4036 // Support: Windows Web Apps (WWA) |
4884 // Support: Windows Web Apps (WWA) |
4037 // `name` and `type` must use .setAttribute for WWA (#14901) |
4885 // `name` and `type` must use .setAttribute for WWA (#14901) |
4038 input.setAttribute( "type", "radio" ); |
4886 input.setAttribute( "type", "radio" ); |
4039 input.setAttribute( "checked", "checked" ); |
4887 input.setAttribute( "checked", "checked" ); |
4040 input.setAttribute( "name", "t" ); |
4888 input.setAttribute( "name", "t" ); |
4041 |
4889 |
4042 div.appendChild( input ); |
4890 div.appendChild( input ); |
4043 |
4891 |
4044 // Support: Safari<=5.1, Android<4.2 |
4892 // Support: Android <=4.1 only |
4045 // Older WebKit doesn't clone checked state correctly in fragments |
4893 // Older WebKit doesn't clone checked state correctly in fragments |
4046 support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; |
4894 support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; |
4047 |
4895 |
4048 // Support: IE<=11+ |
4896 // Support: IE <=11 only |
4049 // Make sure textarea (and checkbox) defaultValue is properly cloned |
4897 // Make sure textarea (and checkbox) defaultValue is properly cloned |
4050 div.innerHTML = "<textarea>x</textarea>"; |
4898 div.innerHTML = "<textarea>x</textarea>"; |
4051 support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue; |
4899 support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue; |
4052 })(); |
4900 } )(); |
4053 var strundefined = typeof undefined; |
|
4054 |
|
4055 |
|
4056 |
|
4057 support.focusinBubbles = "onfocusin" in window; |
|
4058 |
4901 |
4059 |
4902 |
4060 var |
4903 var |
4061 rkeyEvent = /^key/, |
4904 rkeyEvent = /^key/, |
4062 rmouseEvent = /^(?:mouse|pointer|contextmenu)|click/, |
4905 rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/, |
4063 rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, |
4906 rtypenamespace = /^([^.]*)(?:\.(.+)|)/; |
4064 rtypenamespace = /^([^.]*)(?:\.(.+)|)$/; |
|
4065 |
4907 |
4066 function returnTrue() { |
4908 function returnTrue() { |
4067 return true; |
4909 return true; |
4068 } |
4910 } |
4069 |
4911 |
4070 function returnFalse() { |
4912 function returnFalse() { |
4071 return false; |
4913 return false; |
4072 } |
4914 } |
4073 |
4915 |
|
4916 // Support: IE <=9 - 11+ |
|
4917 // focus() and blur() are asynchronous, except when they are no-op. |
|
4918 // So expect focus to be synchronous when the element is already active, |
|
4919 // and blur to be synchronous when the element is not already active. |
|
4920 // (focus and blur are always synchronous in other supported browsers, |
|
4921 // this just defines when we can count on it). |
|
4922 function expectSync( elem, type ) { |
|
4923 return ( elem === safeActiveElement() ) === ( type === "focus" ); |
|
4924 } |
|
4925 |
|
4926 // Support: IE <=9 only |
|
4927 // Accessing document.activeElement can throw unexpectedly |
|
4928 // https://bugs.jquery.com/ticket/13393 |
4074 function safeActiveElement() { |
4929 function safeActiveElement() { |
4075 try { |
4930 try { |
4076 return document.activeElement; |
4931 return document.activeElement; |
4077 } catch ( err ) { } |
4932 } catch ( err ) { } |
4078 } |
4933 } |
4079 |
4934 |
|
4935 function on( elem, types, selector, data, fn, one ) { |
|
4936 var origFn, type; |
|
4937 |
|
4938 // Types can be a map of types/handlers |
|
4939 if ( typeof types === "object" ) { |
|
4940 |
|
4941 // ( types-Object, selector, data ) |
|
4942 if ( typeof selector !== "string" ) { |
|
4943 |
|
4944 // ( types-Object, data ) |
|
4945 data = data || selector; |
|
4946 selector = undefined; |
|
4947 } |
|
4948 for ( type in types ) { |
|
4949 on( elem, type, selector, data, types[ type ], one ); |
|
4950 } |
|
4951 return elem; |
|
4952 } |
|
4953 |
|
4954 if ( data == null && fn == null ) { |
|
4955 |
|
4956 // ( types, fn ) |
|
4957 fn = selector; |
|
4958 data = selector = undefined; |
|
4959 } else if ( fn == null ) { |
|
4960 if ( typeof selector === "string" ) { |
|
4961 |
|
4962 // ( types, selector, fn ) |
|
4963 fn = data; |
|
4964 data = undefined; |
|
4965 } else { |
|
4966 |
|
4967 // ( types, data, fn ) |
|
4968 fn = data; |
|
4969 data = selector; |
|
4970 selector = undefined; |
|
4971 } |
|
4972 } |
|
4973 if ( fn === false ) { |
|
4974 fn = returnFalse; |
|
4975 } else if ( !fn ) { |
|
4976 return elem; |
|
4977 } |
|
4978 |
|
4979 if ( one === 1 ) { |
|
4980 origFn = fn; |
|
4981 fn = function( event ) { |
|
4982 |
|
4983 // Can use an empty set, since event contains the info |
|
4984 jQuery().off( event ); |
|
4985 return origFn.apply( this, arguments ); |
|
4986 }; |
|
4987 |
|
4988 // Use same guid so caller can remove using origFn |
|
4989 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); |
|
4990 } |
|
4991 return elem.each( function() { |
|
4992 jQuery.event.add( this, types, fn, data, selector ); |
|
4993 } ); |
|
4994 } |
|
4995 |
4080 /* |
4996 /* |
4081 * Helper functions for managing events -- not part of the public interface. |
4997 * Helper functions for managing events -- not part of the public interface. |
4082 * Props to Dean Edwards' addEvent library for many of the ideas. |
4998 * Props to Dean Edwards' addEvent library for many of the ideas. |
4083 */ |
4999 */ |
4084 jQuery.event = { |
5000 jQuery.event = { |
4244 } |
5171 } |
4245 |
5172 |
4246 // Remove generic event handler if we removed something and no more handlers exist |
5173 // Remove generic event handler if we removed something and no more handlers exist |
4247 // (avoids potential for endless recursion during removal of special event handlers) |
5174 // (avoids potential for endless recursion during removal of special event handlers) |
4248 if ( origCount && !handlers.length ) { |
5175 if ( origCount && !handlers.length ) { |
4249 if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) { |
5176 if ( !special.teardown || |
|
5177 special.teardown.call( elem, namespaces, elemData.handle ) === false ) { |
|
5178 |
4250 jQuery.removeEvent( elem, type, elemData.handle ); |
5179 jQuery.removeEvent( elem, type, elemData.handle ); |
4251 } |
5180 } |
4252 |
5181 |
4253 delete events[ type ]; |
5182 delete events[ type ]; |
4254 } |
5183 } |
4255 } |
5184 } |
4256 |
5185 |
4257 // Remove the expando if it's no longer used |
5186 // Remove data and the expando if it's no longer used |
4258 if ( jQuery.isEmptyObject( events ) ) { |
5187 if ( jQuery.isEmptyObject( events ) ) { |
4259 delete elemData.handle; |
5188 dataPriv.remove( elem, "handle events" ); |
4260 data_priv.remove( elem, "events" ); |
5189 } |
4261 } |
5190 }, |
4262 }, |
5191 |
4263 |
5192 dispatch: function( nativeEvent ) { |
4264 trigger: function( event, data, elem, onlyHandlers ) { |
|
4265 |
|
4266 var i, cur, tmp, bubbleType, ontype, handle, special, |
|
4267 eventPath = [ elem || document ], |
|
4268 type = hasOwn.call( event, "type" ) ? event.type : event, |
|
4269 namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : []; |
|
4270 |
|
4271 cur = tmp = elem = elem || document; |
|
4272 |
|
4273 // Don't do events on text and comment nodes |
|
4274 if ( elem.nodeType === 3 || elem.nodeType === 8 ) { |
|
4275 return; |
|
4276 } |
|
4277 |
|
4278 // focus/blur morphs to focusin/out; ensure we're not firing them right now |
|
4279 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { |
|
4280 return; |
|
4281 } |
|
4282 |
|
4283 if ( type.indexOf(".") >= 0 ) { |
|
4284 // Namespaced trigger; create a regexp to match event type in handle() |
|
4285 namespaces = type.split("."); |
|
4286 type = namespaces.shift(); |
|
4287 namespaces.sort(); |
|
4288 } |
|
4289 ontype = type.indexOf(":") < 0 && "on" + type; |
|
4290 |
|
4291 // Caller can pass in a jQuery.Event object, Object, or just an event type string |
|
4292 event = event[ jQuery.expando ] ? |
|
4293 event : |
|
4294 new jQuery.Event( type, typeof event === "object" && event ); |
|
4295 |
|
4296 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true) |
|
4297 event.isTrigger = onlyHandlers ? 2 : 3; |
|
4298 event.namespace = namespaces.join("."); |
|
4299 event.namespace_re = event.namespace ? |
|
4300 new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) : |
|
4301 null; |
|
4302 |
|
4303 // Clean up the event in case it is being reused |
|
4304 event.result = undefined; |
|
4305 if ( !event.target ) { |
|
4306 event.target = elem; |
|
4307 } |
|
4308 |
|
4309 // Clone any incoming data and prepend the event, creating the handler arg list |
|
4310 data = data == null ? |
|
4311 [ event ] : |
|
4312 jQuery.makeArray( data, [ event ] ); |
|
4313 |
|
4314 // Allow special events to draw outside the lines |
|
4315 special = jQuery.event.special[ type ] || {}; |
|
4316 if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) { |
|
4317 return; |
|
4318 } |
|
4319 |
|
4320 // Determine event propagation path in advance, per W3C events spec (#9951) |
|
4321 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) |
|
4322 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { |
|
4323 |
|
4324 bubbleType = special.delegateType || type; |
|
4325 if ( !rfocusMorph.test( bubbleType + type ) ) { |
|
4326 cur = cur.parentNode; |
|
4327 } |
|
4328 for ( ; cur; cur = cur.parentNode ) { |
|
4329 eventPath.push( cur ); |
|
4330 tmp = cur; |
|
4331 } |
|
4332 |
|
4333 // Only add window if we got to document (e.g., not plain obj or detached DOM) |
|
4334 if ( tmp === (elem.ownerDocument || document) ) { |
|
4335 eventPath.push( tmp.defaultView || tmp.parentWindow || window ); |
|
4336 } |
|
4337 } |
|
4338 |
|
4339 // Fire handlers on the event path |
|
4340 i = 0; |
|
4341 while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) { |
|
4342 |
|
4343 event.type = i > 1 ? |
|
4344 bubbleType : |
|
4345 special.bindType || type; |
|
4346 |
|
4347 // jQuery handler |
|
4348 handle = ( data_priv.get( cur, "events" ) || {} )[ event.type ] && data_priv.get( cur, "handle" ); |
|
4349 if ( handle ) { |
|
4350 handle.apply( cur, data ); |
|
4351 } |
|
4352 |
|
4353 // Native handler |
|
4354 handle = ontype && cur[ ontype ]; |
|
4355 if ( handle && handle.apply && jQuery.acceptData( cur ) ) { |
|
4356 event.result = handle.apply( cur, data ); |
|
4357 if ( event.result === false ) { |
|
4358 event.preventDefault(); |
|
4359 } |
|
4360 } |
|
4361 } |
|
4362 event.type = type; |
|
4363 |
|
4364 // If nobody prevented the default action, do it now |
|
4365 if ( !onlyHandlers && !event.isDefaultPrevented() ) { |
|
4366 |
|
4367 if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) && |
|
4368 jQuery.acceptData( elem ) ) { |
|
4369 |
|
4370 // Call a native DOM method on the target with the same name name as the event. |
|
4371 // Don't do default actions on window, that's where global variables be (#6170) |
|
4372 if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) { |
|
4373 |
|
4374 // Don't re-trigger an onFOO event when we call its FOO() method |
|
4375 tmp = elem[ ontype ]; |
|
4376 |
|
4377 if ( tmp ) { |
|
4378 elem[ ontype ] = null; |
|
4379 } |
|
4380 |
|
4381 // Prevent re-triggering of the same event, since we already bubbled it above |
|
4382 jQuery.event.triggered = type; |
|
4383 elem[ type ](); |
|
4384 jQuery.event.triggered = undefined; |
|
4385 |
|
4386 if ( tmp ) { |
|
4387 elem[ ontype ] = tmp; |
|
4388 } |
|
4389 } |
|
4390 } |
|
4391 } |
|
4392 |
|
4393 return event.result; |
|
4394 }, |
|
4395 |
|
4396 dispatch: function( event ) { |
|
4397 |
5193 |
4398 // Make a writable jQuery.Event from the native event object |
5194 // Make a writable jQuery.Event from the native event object |
4399 event = jQuery.event.fix( event ); |
5195 var event = jQuery.event.fix( nativeEvent ); |
4400 |
5196 |
4401 var i, j, ret, matched, handleObj, |
5197 var i, j, ret, matched, handleObj, handlerQueue, |
4402 handlerQueue = [], |
5198 args = new Array( arguments.length ), |
4403 args = slice.call( arguments ), |
5199 handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [], |
4404 handlers = ( data_priv.get( this, "events" ) || {} )[ event.type ] || [], |
|
4405 special = jQuery.event.special[ event.type ] || {}; |
5200 special = jQuery.event.special[ event.type ] || {}; |
4406 |
5201 |
4407 // Use the fix-ed jQuery.Event rather than the (read-only) native event |
5202 // Use the fix-ed jQuery.Event rather than the (read-only) native event |
4408 args[0] = event; |
5203 args[ 0 ] = event; |
|
5204 |
|
5205 for ( i = 1; i < arguments.length; i++ ) { |
|
5206 args[ i ] = arguments[ i ]; |
|
5207 } |
|
5208 |
4409 event.delegateTarget = this; |
5209 event.delegateTarget = this; |
4410 |
5210 |
4411 // Call the preDispatch hook for the mapped type, and let it bail if desired |
5211 // Call the preDispatch hook for the mapped type, and let it bail if desired |
4412 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { |
5212 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { |
4413 return; |
5213 return; |
4451 |
5253 |
4452 return event.result; |
5254 return event.result; |
4453 }, |
5255 }, |
4454 |
5256 |
4455 handlers: function( event, handlers ) { |
5257 handlers: function( event, handlers ) { |
4456 var i, matches, sel, handleObj, |
5258 var i, handleObj, sel, matchedHandlers, matchedSelectors, |
4457 handlerQueue = [], |
5259 handlerQueue = [], |
4458 delegateCount = handlers.delegateCount, |
5260 delegateCount = handlers.delegateCount, |
4459 cur = event.target; |
5261 cur = event.target; |
4460 |
5262 |
4461 // Find delegate handlers |
5263 // Find delegate handlers |
4462 // Black-hole SVG <use> instance trees (#13180) |
5264 if ( delegateCount && |
4463 // Avoid non-left-click bubbling in Firefox (#3861) |
5265 |
4464 if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) { |
5266 // Support: IE <=9 |
|
5267 // Black-hole SVG <use> instance trees (trac-13180) |
|
5268 cur.nodeType && |
|
5269 |
|
5270 // Support: Firefox <=42 |
|
5271 // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861) |
|
5272 // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click |
|
5273 // Support: IE 11 only |
|
5274 // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343) |
|
5275 !( event.type === "click" && event.button >= 1 ) ) { |
4465 |
5276 |
4466 for ( ; cur !== this; cur = cur.parentNode || this ) { |
5277 for ( ; cur !== this; cur = cur.parentNode || this ) { |
4467 |
5278 |
|
5279 // Don't check non-elements (#13208) |
4468 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764) |
5280 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764) |
4469 if ( cur.disabled !== true || event.type !== "click" ) { |
5281 if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) { |
4470 matches = []; |
5282 matchedHandlers = []; |
|
5283 matchedSelectors = {}; |
4471 for ( i = 0; i < delegateCount; i++ ) { |
5284 for ( i = 0; i < delegateCount; i++ ) { |
4472 handleObj = handlers[ i ]; |
5285 handleObj = handlers[ i ]; |
4473 |
5286 |
4474 // Don't conflict with Object.prototype properties (#13203) |
5287 // Don't conflict with Object.prototype properties (#13203) |
4475 sel = handleObj.selector + " "; |
5288 sel = handleObj.selector + " "; |
4476 |
5289 |
4477 if ( matches[ sel ] === undefined ) { |
5290 if ( matchedSelectors[ sel ] === undefined ) { |
4478 matches[ sel ] = handleObj.needsContext ? |
5291 matchedSelectors[ sel ] = handleObj.needsContext ? |
4479 jQuery( sel, this ).index( cur ) >= 0 : |
5292 jQuery( sel, this ).index( cur ) > -1 : |
4480 jQuery.find( sel, this, null, [ cur ] ).length; |
5293 jQuery.find( sel, this, null, [ cur ] ).length; |
4481 } |
5294 } |
4482 if ( matches[ sel ] ) { |
5295 if ( matchedSelectors[ sel ] ) { |
4483 matches.push( handleObj ); |
5296 matchedHandlers.push( handleObj ); |
4484 } |
5297 } |
4485 } |
5298 } |
4486 if ( matches.length ) { |
5299 if ( matchedHandlers.length ) { |
4487 handlerQueue.push({ elem: cur, handlers: matches }); |
5300 handlerQueue.push( { elem: cur, handlers: matchedHandlers } ); |
4488 } |
5301 } |
4489 } |
5302 } |
4490 } |
5303 } |
4491 } |
5304 } |
4492 |
5305 |
4493 // Add the remaining (directly-bound) handlers |
5306 // Add the remaining (directly-bound) handlers |
|
5307 cur = this; |
4494 if ( delegateCount < handlers.length ) { |
5308 if ( delegateCount < handlers.length ) { |
4495 handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) }); |
5309 handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } ); |
4496 } |
5310 } |
4497 |
5311 |
4498 return handlerQueue; |
5312 return handlerQueue; |
4499 }, |
5313 }, |
4500 |
5314 |
4501 // Includes some event props shared by KeyEvent and MouseEvent |
5315 addProp: function( name, hook ) { |
4502 props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), |
5316 Object.defineProperty( jQuery.Event.prototype, name, { |
4503 |
5317 enumerable: true, |
4504 fixHooks: {}, |
5318 configurable: true, |
4505 |
5319 |
4506 keyHooks: { |
5320 get: isFunction( hook ) ? |
4507 props: "char charCode key keyCode".split(" "), |
5321 function() { |
4508 filter: function( event, original ) { |
5322 if ( this.originalEvent ) { |
4509 |
5323 return hook( this.originalEvent ); |
4510 // Add which for key events |
5324 } |
4511 if ( event.which == null ) { |
5325 } : |
4512 event.which = original.charCode != null ? original.charCode : original.keyCode; |
5326 function() { |
4513 } |
5327 if ( this.originalEvent ) { |
4514 |
5328 return this.originalEvent[ name ]; |
4515 return event; |
5329 } |
4516 } |
5330 }, |
4517 }, |
5331 |
4518 |
5332 set: function( value ) { |
4519 mouseHooks: { |
5333 Object.defineProperty( this, name, { |
4520 props: "button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "), |
5334 enumerable: true, |
4521 filter: function( event, original ) { |
5335 configurable: true, |
4522 var eventDoc, doc, body, |
5336 writable: true, |
4523 button = original.button; |
5337 value: value |
4524 |
5338 } ); |
4525 // Calculate pageX/Y if missing and clientX/Y available |
5339 } |
4526 if ( event.pageX == null && original.clientX != null ) { |
5340 } ); |
4527 eventDoc = event.target.ownerDocument || document; |
5341 }, |
4528 doc = eventDoc.documentElement; |
5342 |
4529 body = eventDoc.body; |
5343 fix: function( originalEvent ) { |
4530 |
5344 return originalEvent[ jQuery.expando ] ? |
4531 event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 ); |
5345 originalEvent : |
4532 event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 ); |
5346 new jQuery.Event( originalEvent ); |
4533 } |
|
4534 |
|
4535 // Add which for click: 1 === left; 2 === middle; 3 === right |
|
4536 // Note: button is not normalized, so don't use it |
|
4537 if ( !event.which && button !== undefined ) { |
|
4538 event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); |
|
4539 } |
|
4540 |
|
4541 return event; |
|
4542 } |
|
4543 }, |
|
4544 |
|
4545 fix: function( event ) { |
|
4546 if ( event[ jQuery.expando ] ) { |
|
4547 return event; |
|
4548 } |
|
4549 |
|
4550 // Create a writable copy of the event object and normalize some properties |
|
4551 var i, prop, copy, |
|
4552 type = event.type, |
|
4553 originalEvent = event, |
|
4554 fixHook = this.fixHooks[ type ]; |
|
4555 |
|
4556 if ( !fixHook ) { |
|
4557 this.fixHooks[ type ] = fixHook = |
|
4558 rmouseEvent.test( type ) ? this.mouseHooks : |
|
4559 rkeyEvent.test( type ) ? this.keyHooks : |
|
4560 {}; |
|
4561 } |
|
4562 copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; |
|
4563 |
|
4564 event = new jQuery.Event( originalEvent ); |
|
4565 |
|
4566 i = copy.length; |
|
4567 while ( i-- ) { |
|
4568 prop = copy[ i ]; |
|
4569 event[ prop ] = originalEvent[ prop ]; |
|
4570 } |
|
4571 |
|
4572 // Support: Cordova 2.5 (WebKit) (#13255) |
|
4573 // All events should have a target; Cordova deviceready doesn't |
|
4574 if ( !event.target ) { |
|
4575 event.target = document; |
|
4576 } |
|
4577 |
|
4578 // Support: Safari 6.0+, Chrome<28 |
|
4579 // Target should not be a text node (#504, #13143) |
|
4580 if ( event.target.nodeType === 3 ) { |
|
4581 event.target = event.target.parentNode; |
|
4582 } |
|
4583 |
|
4584 return fixHook.filter ? fixHook.filter( event, originalEvent ) : event; |
|
4585 }, |
5347 }, |
4586 |
5348 |
4587 special: { |
5349 special: { |
4588 load: { |
5350 load: { |
|
5351 |
4589 // Prevent triggered image.load events from bubbling to window.load |
5352 // Prevent triggered image.load events from bubbling to window.load |
4590 noBubble: true |
5353 noBubble: true |
4591 }, |
5354 }, |
4592 focus: { |
5355 click: { |
4593 // Fire native event if possible so blur/focus sequence is correct |
5356 |
4594 trigger: function() { |
5357 // Utilize native event to ensure correct state for checkable inputs |
4595 if ( this !== safeActiveElement() && this.focus ) { |
5358 setup: function( data ) { |
4596 this.focus(); |
5359 |
4597 return false; |
5360 // For mutual compressibility with _default, replace `this` access with a local var. |
4598 } |
5361 // `|| data` is dead code meant only to preserve the variable through minification. |
|
5362 var el = this || data; |
|
5363 |
|
5364 // Claim the first handler |
|
5365 if ( rcheckableType.test( el.type ) && |
|
5366 el.click && nodeName( el, "input" ) ) { |
|
5367 |
|
5368 // dataPriv.set( el, "click", ... ) |
|
5369 leverageNative( el, "click", returnTrue ); |
|
5370 } |
|
5371 |
|
5372 // Return false to allow normal processing in the caller |
|
5373 return false; |
4599 }, |
5374 }, |
4600 delegateType: "focusin" |
5375 trigger: function( data ) { |
4601 }, |
5376 |
4602 blur: { |
5377 // For mutual compressibility with _default, replace `this` access with a local var. |
4603 trigger: function() { |
5378 // `|| data` is dead code meant only to preserve the variable through minification. |
4604 if ( this === safeActiveElement() && this.blur ) { |
5379 var el = this || data; |
4605 this.blur(); |
5380 |
4606 return false; |
5381 // Force setup before triggering a click |
4607 } |
5382 if ( rcheckableType.test( el.type ) && |
|
5383 el.click && nodeName( el, "input" ) ) { |
|
5384 |
|
5385 leverageNative( el, "click" ); |
|
5386 } |
|
5387 |
|
5388 // Return non-false to allow normal event-path propagation |
|
5389 return true; |
4608 }, |
5390 }, |
4609 delegateType: "focusout" |
5391 |
4610 }, |
5392 // For cross-browser consistency, suppress native .click() on links |
4611 click: { |
5393 // Also prevent it if we're currently inside a leveraged native-event stack |
4612 // For checkbox, fire native event so checked state will be right |
|
4613 trigger: function() { |
|
4614 if ( this.type === "checkbox" && this.click && jQuery.nodeName( this, "input" ) ) { |
|
4615 this.click(); |
|
4616 return false; |
|
4617 } |
|
4618 }, |
|
4619 |
|
4620 // For cross-browser consistency, don't fire native .click() on links |
|
4621 _default: function( event ) { |
5394 _default: function( event ) { |
4622 return jQuery.nodeName( event.target, "a" ); |
5395 var target = event.target; |
|
5396 return rcheckableType.test( target.type ) && |
|
5397 target.click && nodeName( target, "input" ) && |
|
5398 dataPriv.get( target, "click" ) || |
|
5399 nodeName( target, "a" ); |
4623 } |
5400 } |
4624 }, |
5401 }, |
4625 |
5402 |
4626 beforeunload: { |
5403 beforeunload: { |
4627 postDispatch: function( event ) { |
5404 postDispatch: function( event ) { |
4631 if ( event.result !== undefined && event.originalEvent ) { |
5408 if ( event.result !== undefined && event.originalEvent ) { |
4632 event.originalEvent.returnValue = event.result; |
5409 event.originalEvent.returnValue = event.result; |
4633 } |
5410 } |
4634 } |
5411 } |
4635 } |
5412 } |
4636 }, |
|
4637 |
|
4638 simulate: function( type, elem, event, bubble ) { |
|
4639 // Piggyback on a donor event to simulate a different one. |
|
4640 // Fake originalEvent to avoid donor's stopPropagation, but if the |
|
4641 // simulated event prevents default then we do the same on the donor. |
|
4642 var e = jQuery.extend( |
|
4643 new jQuery.Event(), |
|
4644 event, |
|
4645 { |
|
4646 type: type, |
|
4647 isSimulated: true, |
|
4648 originalEvent: {} |
|
4649 } |
|
4650 ); |
|
4651 if ( bubble ) { |
|
4652 jQuery.event.trigger( e, null, elem ); |
|
4653 } else { |
|
4654 jQuery.event.dispatch.call( elem, e ); |
|
4655 } |
|
4656 if ( e.isDefaultPrevented() ) { |
|
4657 event.preventDefault(); |
|
4658 } |
|
4659 } |
5413 } |
4660 }; |
5414 }; |
4661 |
5415 |
|
5416 // Ensure the presence of an event listener that handles manually-triggered |
|
5417 // synthetic events by interrupting progress until reinvoked in response to |
|
5418 // *native* events that it fires directly, ensuring that state changes have |
|
5419 // already occurred before other listeners are invoked. |
|
5420 function leverageNative( el, type, expectSync ) { |
|
5421 |
|
5422 // Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add |
|
5423 if ( !expectSync ) { |
|
5424 if ( dataPriv.get( el, type ) === undefined ) { |
|
5425 jQuery.event.add( el, type, returnTrue ); |
|
5426 } |
|
5427 return; |
|
5428 } |
|
5429 |
|
5430 // Register the controller as a special universal handler for all event namespaces |
|
5431 dataPriv.set( el, type, false ); |
|
5432 jQuery.event.add( el, type, { |
|
5433 namespace: false, |
|
5434 handler: function( event ) { |
|
5435 var notAsync, result, |
|
5436 saved = dataPriv.get( this, type ); |
|
5437 |
|
5438 if ( ( event.isTrigger & 1 ) && this[ type ] ) { |
|
5439 |
|
5440 // Interrupt processing of the outer synthetic .trigger()ed event |
|
5441 // Saved data should be false in such cases, but might be a leftover capture object |
|
5442 // from an async native handler (gh-4350) |
|
5443 if ( !saved.length ) { |
|
5444 |
|
5445 // Store arguments for use when handling the inner native event |
|
5446 // There will always be at least one argument (an event object), so this array |
|
5447 // will not be confused with a leftover capture object. |
|
5448 saved = slice.call( arguments ); |
|
5449 dataPriv.set( this, type, saved ); |
|
5450 |
|
5451 // Trigger the native event and capture its result |
|
5452 // Support: IE <=9 - 11+ |
|
5453 // focus() and blur() are asynchronous |
|
5454 notAsync = expectSync( this, type ); |
|
5455 this[ type ](); |
|
5456 result = dataPriv.get( this, type ); |
|
5457 if ( saved !== result || notAsync ) { |
|
5458 dataPriv.set( this, type, false ); |
|
5459 } else { |
|
5460 result = {}; |
|
5461 } |
|
5462 if ( saved !== result ) { |
|
5463 |
|
5464 // Cancel the outer synthetic event |
|
5465 event.stopImmediatePropagation(); |
|
5466 event.preventDefault(); |
|
5467 return result.value; |
|
5468 } |
|
5469 |
|
5470 // If this is an inner synthetic event for an event with a bubbling surrogate |
|
5471 // (focus or blur), assume that the surrogate already propagated from triggering the |
|
5472 // native event and prevent that from happening again here. |
|
5473 // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the |
|
5474 // bubbling surrogate propagates *after* the non-bubbling base), but that seems |
|
5475 // less bad than duplication. |
|
5476 } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) { |
|
5477 event.stopPropagation(); |
|
5478 } |
|
5479 |
|
5480 // If this is a native event triggered above, everything is now in order |
|
5481 // Fire an inner synthetic event with the original arguments |
|
5482 } else if ( saved.length ) { |
|
5483 |
|
5484 // ...and capture the result |
|
5485 dataPriv.set( this, type, { |
|
5486 value: jQuery.event.trigger( |
|
5487 |
|
5488 // Support: IE <=9 - 11+ |
|
5489 // Extend with the prototype to reset the above stopImmediatePropagation() |
|
5490 jQuery.extend( saved[ 0 ], jQuery.Event.prototype ), |
|
5491 saved.slice( 1 ), |
|
5492 this |
|
5493 ) |
|
5494 } ); |
|
5495 |
|
5496 // Abort handling of the native event |
|
5497 event.stopImmediatePropagation(); |
|
5498 } |
|
5499 } |
|
5500 } ); |
|
5501 } |
|
5502 |
4662 jQuery.removeEvent = function( elem, type, handle ) { |
5503 jQuery.removeEvent = function( elem, type, handle ) { |
|
5504 |
|
5505 // This "if" is needed for plain objects |
4663 if ( elem.removeEventListener ) { |
5506 if ( elem.removeEventListener ) { |
4664 elem.removeEventListener( type, handle, false ); |
5507 elem.removeEventListener( type, handle ); |
4665 } |
5508 } |
4666 }; |
5509 }; |
4667 |
5510 |
4668 jQuery.Event = function( src, props ) { |
5511 jQuery.Event = function( src, props ) { |
|
5512 |
4669 // Allow instantiation without the 'new' keyword |
5513 // Allow instantiation without the 'new' keyword |
4670 if ( !(this instanceof jQuery.Event) ) { |
5514 if ( !( this instanceof jQuery.Event ) ) { |
4671 return new jQuery.Event( src, props ); |
5515 return new jQuery.Event( src, props ); |
4672 } |
5516 } |
4673 |
5517 |
4674 // Event object |
5518 // Event object |
4675 if ( src && src.type ) { |
5519 if ( src && src.type ) { |
4694 if ( props ) { |
5549 if ( props ) { |
4695 jQuery.extend( this, props ); |
5550 jQuery.extend( this, props ); |
4696 } |
5551 } |
4697 |
5552 |
4698 // Create a timestamp if incoming event doesn't have one |
5553 // Create a timestamp if incoming event doesn't have one |
4699 this.timeStamp = src && src.timeStamp || jQuery.now(); |
5554 this.timeStamp = src && src.timeStamp || Date.now(); |
4700 |
5555 |
4701 // Mark it as fixed |
5556 // Mark it as fixed |
4702 this[ jQuery.expando ] = true; |
5557 this[ jQuery.expando ] = true; |
4703 }; |
5558 }; |
4704 |
5559 |
4705 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding |
5560 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding |
4706 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html |
5561 // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html |
4707 jQuery.Event.prototype = { |
5562 jQuery.Event.prototype = { |
|
5563 constructor: jQuery.Event, |
4708 isDefaultPrevented: returnFalse, |
5564 isDefaultPrevented: returnFalse, |
4709 isPropagationStopped: returnFalse, |
5565 isPropagationStopped: returnFalse, |
4710 isImmediatePropagationStopped: returnFalse, |
5566 isImmediatePropagationStopped: returnFalse, |
|
5567 isSimulated: false, |
4711 |
5568 |
4712 preventDefault: function() { |
5569 preventDefault: function() { |
4713 var e = this.originalEvent; |
5570 var e = this.originalEvent; |
4714 |
5571 |
4715 this.isDefaultPrevented = returnTrue; |
5572 this.isDefaultPrevented = returnTrue; |
4716 |
5573 |
4717 if ( e && e.preventDefault ) { |
5574 if ( e && !this.isSimulated ) { |
4718 e.preventDefault(); |
5575 e.preventDefault(); |
4719 } |
5576 } |
4720 }, |
5577 }, |
4721 stopPropagation: function() { |
5578 stopPropagation: function() { |
4722 var e = this.originalEvent; |
5579 var e = this.originalEvent; |
4723 |
5580 |
4724 this.isPropagationStopped = returnTrue; |
5581 this.isPropagationStopped = returnTrue; |
4725 |
5582 |
4726 if ( e && e.stopPropagation ) { |
5583 if ( e && !this.isSimulated ) { |
4727 e.stopPropagation(); |
5584 e.stopPropagation(); |
4728 } |
5585 } |
4729 }, |
5586 }, |
4730 stopImmediatePropagation: function() { |
5587 stopImmediatePropagation: function() { |
4731 var e = this.originalEvent; |
5588 var e = this.originalEvent; |
4732 |
5589 |
4733 this.isImmediatePropagationStopped = returnTrue; |
5590 this.isImmediatePropagationStopped = returnTrue; |
4734 |
5591 |
4735 if ( e && e.stopImmediatePropagation ) { |
5592 if ( e && !this.isSimulated ) { |
4736 e.stopImmediatePropagation(); |
5593 e.stopImmediatePropagation(); |
4737 } |
5594 } |
4738 |
5595 |
4739 this.stopPropagation(); |
5596 this.stopPropagation(); |
4740 } |
5597 } |
4741 }; |
5598 }; |
4742 |
5599 |
|
5600 // Includes all common event props including KeyEvent and MouseEvent specific props |
|
5601 jQuery.each( { |
|
5602 altKey: true, |
|
5603 bubbles: true, |
|
5604 cancelable: true, |
|
5605 changedTouches: true, |
|
5606 ctrlKey: true, |
|
5607 detail: true, |
|
5608 eventPhase: true, |
|
5609 metaKey: true, |
|
5610 pageX: true, |
|
5611 pageY: true, |
|
5612 shiftKey: true, |
|
5613 view: true, |
|
5614 "char": true, |
|
5615 code: true, |
|
5616 charCode: true, |
|
5617 key: true, |
|
5618 keyCode: true, |
|
5619 button: true, |
|
5620 buttons: true, |
|
5621 clientX: true, |
|
5622 clientY: true, |
|
5623 offsetX: true, |
|
5624 offsetY: true, |
|
5625 pointerId: true, |
|
5626 pointerType: true, |
|
5627 screenX: true, |
|
5628 screenY: true, |
|
5629 targetTouches: true, |
|
5630 toElement: true, |
|
5631 touches: true, |
|
5632 |
|
5633 which: function( event ) { |
|
5634 var button = event.button; |
|
5635 |
|
5636 // Add which for key events |
|
5637 if ( event.which == null && rkeyEvent.test( event.type ) ) { |
|
5638 return event.charCode != null ? event.charCode : event.keyCode; |
|
5639 } |
|
5640 |
|
5641 // Add which for click: 1 === left; 2 === middle; 3 === right |
|
5642 if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) { |
|
5643 if ( button & 1 ) { |
|
5644 return 1; |
|
5645 } |
|
5646 |
|
5647 if ( button & 2 ) { |
|
5648 return 3; |
|
5649 } |
|
5650 |
|
5651 if ( button & 4 ) { |
|
5652 return 2; |
|
5653 } |
|
5654 |
|
5655 return 0; |
|
5656 } |
|
5657 |
|
5658 return event.which; |
|
5659 } |
|
5660 }, jQuery.event.addProp ); |
|
5661 |
|
5662 jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) { |
|
5663 jQuery.event.special[ type ] = { |
|
5664 |
|
5665 // Utilize native event if possible so blur/focus sequence is correct |
|
5666 setup: function() { |
|
5667 |
|
5668 // Claim the first handler |
|
5669 // dataPriv.set( this, "focus", ... ) |
|
5670 // dataPriv.set( this, "blur", ... ) |
|
5671 leverageNative( this, type, expectSync ); |
|
5672 |
|
5673 // Return false to allow normal processing in the caller |
|
5674 return false; |
|
5675 }, |
|
5676 trigger: function() { |
|
5677 |
|
5678 // Force setup before trigger |
|
5679 leverageNative( this, type ); |
|
5680 |
|
5681 // Return non-false to allow normal event-path propagation |
|
5682 return true; |
|
5683 }, |
|
5684 |
|
5685 delegateType: delegateType |
|
5686 }; |
|
5687 } ); |
|
5688 |
4743 // Create mouseenter/leave events using mouseover/out and event-time checks |
5689 // Create mouseenter/leave events using mouseover/out and event-time checks |
4744 // Support: Chrome 15+ |
5690 // so that event delegation works in jQuery. |
4745 jQuery.each({ |
5691 // Do the same for pointerenter/pointerleave and pointerover/pointerout |
|
5692 // |
|
5693 // Support: Safari 7 only |
|
5694 // Safari sends mouseenter too often; see: |
|
5695 // https://bugs.chromium.org/p/chromium/issues/detail?id=470258 |
|
5696 // for the description of the bug (it existed in older Chrome versions as well). |
|
5697 jQuery.each( { |
4746 mouseenter: "mouseover", |
5698 mouseenter: "mouseover", |
4747 mouseleave: "mouseout", |
5699 mouseleave: "mouseout", |
4748 pointerenter: "pointerover", |
5700 pointerenter: "pointerover", |
4749 pointerleave: "pointerout" |
5701 pointerleave: "pointerout" |
4750 }, function( orig, fix ) { |
5702 }, function( orig, fix ) { |
4756 var ret, |
5708 var ret, |
4757 target = this, |
5709 target = this, |
4758 related = event.relatedTarget, |
5710 related = event.relatedTarget, |
4759 handleObj = event.handleObj; |
5711 handleObj = event.handleObj; |
4760 |
5712 |
4761 // For mousenter/leave call the handler if related is outside the target. |
5713 // For mouseenter/leave call the handler if related is outside the target. |
4762 // NB: No relatedTarget if the mouse left/entered the browser window |
5714 // NB: No relatedTarget if the mouse left/entered the browser window |
4763 if ( !related || (related !== target && !jQuery.contains( target, related )) ) { |
5715 if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) { |
4764 event.type = handleObj.origType; |
5716 event.type = handleObj.origType; |
4765 ret = handleObj.handler.apply( this, arguments ); |
5717 ret = handleObj.handler.apply( this, arguments ); |
4766 event.type = fix; |
5718 event.type = fix; |
4767 } |
5719 } |
4768 return ret; |
5720 return ret; |
4769 } |
5721 } |
4770 }; |
5722 }; |
4771 }); |
5723 } ); |
4772 |
5724 |
4773 // Support: Firefox, Chrome, Safari |
5725 jQuery.fn.extend( { |
4774 // Create "bubbling" focus and blur events |
5726 |
4775 if ( !support.focusinBubbles ) { |
5727 on: function( types, selector, data, fn ) { |
4776 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { |
5728 return on( this, types, selector, data, fn ); |
4777 |
|
4778 // Attach a single capturing handler on the document while someone wants focusin/focusout |
|
4779 var handler = function( event ) { |
|
4780 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true ); |
|
4781 }; |
|
4782 |
|
4783 jQuery.event.special[ fix ] = { |
|
4784 setup: function() { |
|
4785 var doc = this.ownerDocument || this, |
|
4786 attaches = data_priv.access( doc, fix ); |
|
4787 |
|
4788 if ( !attaches ) { |
|
4789 doc.addEventListener( orig, handler, true ); |
|
4790 } |
|
4791 data_priv.access( doc, fix, ( attaches || 0 ) + 1 ); |
|
4792 }, |
|
4793 teardown: function() { |
|
4794 var doc = this.ownerDocument || this, |
|
4795 attaches = data_priv.access( doc, fix ) - 1; |
|
4796 |
|
4797 if ( !attaches ) { |
|
4798 doc.removeEventListener( orig, handler, true ); |
|
4799 data_priv.remove( doc, fix ); |
|
4800 |
|
4801 } else { |
|
4802 data_priv.access( doc, fix, attaches ); |
|
4803 } |
|
4804 } |
|
4805 }; |
|
4806 }); |
|
4807 } |
|
4808 |
|
4809 jQuery.fn.extend({ |
|
4810 |
|
4811 on: function( types, selector, data, fn, /*INTERNAL*/ one ) { |
|
4812 var origFn, type; |
|
4813 |
|
4814 // Types can be a map of types/handlers |
|
4815 if ( typeof types === "object" ) { |
|
4816 // ( types-Object, selector, data ) |
|
4817 if ( typeof selector !== "string" ) { |
|
4818 // ( types-Object, data ) |
|
4819 data = data || selector; |
|
4820 selector = undefined; |
|
4821 } |
|
4822 for ( type in types ) { |
|
4823 this.on( type, selector, data, types[ type ], one ); |
|
4824 } |
|
4825 return this; |
|
4826 } |
|
4827 |
|
4828 if ( data == null && fn == null ) { |
|
4829 // ( types, fn ) |
|
4830 fn = selector; |
|
4831 data = selector = undefined; |
|
4832 } else if ( fn == null ) { |
|
4833 if ( typeof selector === "string" ) { |
|
4834 // ( types, selector, fn ) |
|
4835 fn = data; |
|
4836 data = undefined; |
|
4837 } else { |
|
4838 // ( types, data, fn ) |
|
4839 fn = data; |
|
4840 data = selector; |
|
4841 selector = undefined; |
|
4842 } |
|
4843 } |
|
4844 if ( fn === false ) { |
|
4845 fn = returnFalse; |
|
4846 } else if ( !fn ) { |
|
4847 return this; |
|
4848 } |
|
4849 |
|
4850 if ( one === 1 ) { |
|
4851 origFn = fn; |
|
4852 fn = function( event ) { |
|
4853 // Can use an empty set, since event contains the info |
|
4854 jQuery().off( event ); |
|
4855 return origFn.apply( this, arguments ); |
|
4856 }; |
|
4857 // Use same guid so caller can remove using origFn |
|
4858 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); |
|
4859 } |
|
4860 return this.each( function() { |
|
4861 jQuery.event.add( this, types, fn, data, selector ); |
|
4862 }); |
|
4863 }, |
5729 }, |
4864 one: function( types, selector, data, fn ) { |
5730 one: function( types, selector, data, fn ) { |
4865 return this.on( types, selector, data, fn, 1 ); |
5731 return on( this, types, selector, data, fn, 1 ); |
4866 }, |
5732 }, |
4867 off: function( types, selector, fn ) { |
5733 off: function( types, selector, fn ) { |
4868 var handleObj, type; |
5734 var handleObj, type; |
4869 if ( types && types.preventDefault && types.handleObj ) { |
5735 if ( types && types.preventDefault && types.handleObj ) { |
|
5736 |
4870 // ( event ) dispatched jQuery.Event |
5737 // ( event ) dispatched jQuery.Event |
4871 handleObj = types.handleObj; |
5738 handleObj = types.handleObj; |
4872 jQuery( types.delegateTarget ).off( |
5739 jQuery( types.delegateTarget ).off( |
4873 handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType, |
5740 handleObj.namespace ? |
|
5741 handleObj.origType + "." + handleObj.namespace : |
|
5742 handleObj.origType, |
4874 handleObj.selector, |
5743 handleObj.selector, |
4875 handleObj.handler |
5744 handleObj.handler |
4876 ); |
5745 ); |
4877 return this; |
5746 return this; |
4878 } |
5747 } |
4879 if ( typeof types === "object" ) { |
5748 if ( typeof types === "object" ) { |
|
5749 |
4880 // ( types-object [, selector] ) |
5750 // ( types-object [, selector] ) |
4881 for ( type in types ) { |
5751 for ( type in types ) { |
4882 this.off( type, selector, types[ type ] ); |
5752 this.off( type, selector, types[ type ] ); |
4883 } |
5753 } |
4884 return this; |
5754 return this; |
4885 } |
5755 } |
4886 if ( selector === false || typeof selector === "function" ) { |
5756 if ( selector === false || typeof selector === "function" ) { |
|
5757 |
4887 // ( types [, fn] ) |
5758 // ( types [, fn] ) |
4888 fn = selector; |
5759 fn = selector; |
4889 selector = undefined; |
5760 selector = undefined; |
4890 } |
5761 } |
4891 if ( fn === false ) { |
5762 if ( fn === false ) { |
4892 fn = returnFalse; |
5763 fn = returnFalse; |
4893 } |
5764 } |
4894 return this.each(function() { |
5765 return this.each( function() { |
4895 jQuery.event.remove( this, types, fn, selector ); |
5766 jQuery.event.remove( this, types, fn, selector ); |
4896 }); |
5767 } ); |
4897 }, |
5768 } |
4898 |
5769 } ); |
4899 trigger: function( type, data ) { |
|
4900 return this.each(function() { |
|
4901 jQuery.event.trigger( type, data, this ); |
|
4902 }); |
|
4903 }, |
|
4904 triggerHandler: function( type, data ) { |
|
4905 var elem = this[0]; |
|
4906 if ( elem ) { |
|
4907 return jQuery.event.trigger( type, data, elem, true ); |
|
4908 } |
|
4909 } |
|
4910 }); |
|
4911 |
5770 |
4912 |
5771 |
4913 var |
5772 var |
4914 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, |
5773 |
4915 rtagName = /<([\w:]+)/, |
5774 /* eslint-disable max-len */ |
4916 rhtml = /<|&#?\w+;/, |
5775 |
4917 rnoInnerhtml = /<(?:script|style|link)/i, |
5776 // See https://github.com/eslint/eslint/issues/3229 |
|
5777 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi, |
|
5778 |
|
5779 /* eslint-enable */ |
|
5780 |
|
5781 // Support: IE <=10 - 11, Edge 12 - 13 only |
|
5782 // In IE/Edge using regex groups here causes severe slowdowns. |
|
5783 // See https://connect.microsoft.com/IE/feedback/details/1736512/ |
|
5784 rnoInnerhtml = /<script|<style|<link/i, |
|
5785 |
4918 // checked="checked" or checked |
5786 // checked="checked" or checked |
4919 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, |
5787 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, |
4920 rscriptType = /^$|\/(?:java|ecma)script/i, |
5788 rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g; |
4921 rscriptTypeMasked = /^true\/(.*)/, |
5789 |
4922 rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g, |
5790 // Prefer a tbody over its parent table for containing new rows |
4923 |
|
4924 // We have to close these tags to support XHTML (#13200) |
|
4925 wrapMap = { |
|
4926 |
|
4927 // Support: IE9 |
|
4928 option: [ 1, "<select multiple='multiple'>", "</select>" ], |
|
4929 |
|
4930 thead: [ 1, "<table>", "</table>" ], |
|
4931 col: [ 2, "<table><colgroup>", "</colgroup></table>" ], |
|
4932 tr: [ 2, "<table><tbody>", "</tbody></table>" ], |
|
4933 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ], |
|
4934 |
|
4935 _default: [ 0, "", "" ] |
|
4936 }; |
|
4937 |
|
4938 // Support: IE9 |
|
4939 wrapMap.optgroup = wrapMap.option; |
|
4940 |
|
4941 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; |
|
4942 wrapMap.th = wrapMap.td; |
|
4943 |
|
4944 // Support: 1.x compatibility |
|
4945 // Manipulating tables requires a tbody |
|
4946 function manipulationTarget( elem, content ) { |
5791 function manipulationTarget( elem, content ) { |
4947 return jQuery.nodeName( elem, "table" ) && |
5792 if ( nodeName( elem, "table" ) && |
4948 jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ? |
5793 nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) { |
4949 |
5794 |
4950 elem.getElementsByTagName("tbody")[0] || |
5795 return jQuery( elem ).children( "tbody" )[ 0 ] || elem; |
4951 elem.appendChild( elem.ownerDocument.createElement("tbody") ) : |
5796 } |
4952 elem; |
5797 |
|
5798 return elem; |
4953 } |
5799 } |
4954 |
5800 |
4955 // Replace/restore the type attribute of script elements for safe DOM manipulation |
5801 // Replace/restore the type attribute of script elements for safe DOM manipulation |
4956 function disableScript( elem ) { |
5802 function disableScript( elem ) { |
4957 elem.type = (elem.getAttribute("type") !== null) + "/" + elem.type; |
5803 elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type; |
4958 return elem; |
5804 return elem; |
4959 } |
5805 } |
4960 function restoreScript( elem ) { |
5806 function restoreScript( elem ) { |
4961 var match = rscriptTypeMasked.exec( elem.type ); |
5807 if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) { |
4962 |
5808 elem.type = elem.type.slice( 5 ); |
4963 if ( match ) { |
|
4964 elem.type = match[ 1 ]; |
|
4965 } else { |
5809 } else { |
4966 elem.removeAttribute("type"); |
5810 elem.removeAttribute( "type" ); |
4967 } |
5811 } |
4968 |
5812 |
4969 return elem; |
5813 return elem; |
4970 } |
5814 } |
4971 |
5815 |
4972 // Mark scripts as having already been evaluated |
|
4973 function setGlobalEval( elems, refElements ) { |
|
4974 var i = 0, |
|
4975 l = elems.length; |
|
4976 |
|
4977 for ( ; i < l; i++ ) { |
|
4978 data_priv.set( |
|
4979 elems[ i ], "globalEval", !refElements || data_priv.get( refElements[ i ], "globalEval" ) |
|
4980 ); |
|
4981 } |
|
4982 } |
|
4983 |
|
4984 function cloneCopyEvent( src, dest ) { |
5816 function cloneCopyEvent( src, dest ) { |
4985 var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events; |
5817 var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events; |
4986 |
5818 |
4987 if ( dest.nodeType !== 1 ) { |
5819 if ( dest.nodeType !== 1 ) { |
4988 return; |
5820 return; |
4989 } |
5821 } |
4990 |
5822 |
4991 // 1. Copy private data: events, handlers, etc. |
5823 // 1. Copy private data: events, handlers, etc. |
4992 if ( data_priv.hasData( src ) ) { |
5824 if ( dataPriv.hasData( src ) ) { |
4993 pdataOld = data_priv.access( src ); |
5825 pdataOld = dataPriv.access( src ); |
4994 pdataCur = data_priv.set( dest, pdataOld ); |
5826 pdataCur = dataPriv.set( dest, pdataOld ); |
4995 events = pdataOld.events; |
5827 events = pdataOld.events; |
4996 |
5828 |
4997 if ( events ) { |
5829 if ( events ) { |
4998 delete pdataCur.handle; |
5830 delete pdataCur.handle; |
4999 pdataCur.events = {}; |
5831 pdataCur.events = {}; |
5037 } else if ( nodeName === "input" || nodeName === "textarea" ) { |
5859 } else if ( nodeName === "input" || nodeName === "textarea" ) { |
5038 dest.defaultValue = src.defaultValue; |
5860 dest.defaultValue = src.defaultValue; |
5039 } |
5861 } |
5040 } |
5862 } |
5041 |
5863 |
5042 jQuery.extend({ |
5864 function domManip( collection, args, callback, ignored ) { |
|
5865 |
|
5866 // Flatten any nested arrays |
|
5867 args = concat.apply( [], args ); |
|
5868 |
|
5869 var fragment, first, scripts, hasScripts, node, doc, |
|
5870 i = 0, |
|
5871 l = collection.length, |
|
5872 iNoClone = l - 1, |
|
5873 value = args[ 0 ], |
|
5874 valueIsFunction = isFunction( value ); |
|
5875 |
|
5876 // We can't cloneNode fragments that contain checked, in WebKit |
|
5877 if ( valueIsFunction || |
|
5878 ( l > 1 && typeof value === "string" && |
|
5879 !support.checkClone && rchecked.test( value ) ) ) { |
|
5880 return collection.each( function( index ) { |
|
5881 var self = collection.eq( index ); |
|
5882 if ( valueIsFunction ) { |
|
5883 args[ 0 ] = value.call( this, index, self.html() ); |
|
5884 } |
|
5885 domManip( self, args, callback, ignored ); |
|
5886 } ); |
|
5887 } |
|
5888 |
|
5889 if ( l ) { |
|
5890 fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored ); |
|
5891 first = fragment.firstChild; |
|
5892 |
|
5893 if ( fragment.childNodes.length === 1 ) { |
|
5894 fragment = first; |
|
5895 } |
|
5896 |
|
5897 // Require either new content or an interest in ignored elements to invoke the callback |
|
5898 if ( first || ignored ) { |
|
5899 scripts = jQuery.map( getAll( fragment, "script" ), disableScript ); |
|
5900 hasScripts = scripts.length; |
|
5901 |
|
5902 // Use the original fragment for the last item |
|
5903 // instead of the first because it can end up |
|
5904 // being emptied incorrectly in certain situations (#8070). |
|
5905 for ( ; i < l; i++ ) { |
|
5906 node = fragment; |
|
5907 |
|
5908 if ( i !== iNoClone ) { |
|
5909 node = jQuery.clone( node, true, true ); |
|
5910 |
|
5911 // Keep references to cloned scripts for later restoration |
|
5912 if ( hasScripts ) { |
|
5913 |
|
5914 // Support: Android <=4.0 only, PhantomJS 1 only |
|
5915 // push.apply(_, arraylike) throws on ancient WebKit |
|
5916 jQuery.merge( scripts, getAll( node, "script" ) ); |
|
5917 } |
|
5918 } |
|
5919 |
|
5920 callback.call( collection[ i ], node, i ); |
|
5921 } |
|
5922 |
|
5923 if ( hasScripts ) { |
|
5924 doc = scripts[ scripts.length - 1 ].ownerDocument; |
|
5925 |
|
5926 // Reenable scripts |
|
5927 jQuery.map( scripts, restoreScript ); |
|
5928 |
|
5929 // Evaluate executable scripts on first document insertion |
|
5930 for ( i = 0; i < hasScripts; i++ ) { |
|
5931 node = scripts[ i ]; |
|
5932 if ( rscriptType.test( node.type || "" ) && |
|
5933 !dataPriv.access( node, "globalEval" ) && |
|
5934 jQuery.contains( doc, node ) ) { |
|
5935 |
|
5936 if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) { |
|
5937 |
|
5938 // Optional AJAX dependency, but won't run scripts if not present |
|
5939 if ( jQuery._evalUrl && !node.noModule ) { |
|
5940 jQuery._evalUrl( node.src, { |
|
5941 nonce: node.nonce || node.getAttribute( "nonce" ) |
|
5942 } ); |
|
5943 } |
|
5944 } else { |
|
5945 DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc ); |
|
5946 } |
|
5947 } |
|
5948 } |
|
5949 } |
|
5950 } |
|
5951 } |
|
5952 |
|
5953 return collection; |
|
5954 } |
|
5955 |
|
5956 function remove( elem, selector, keepData ) { |
|
5957 var node, |
|
5958 nodes = selector ? jQuery.filter( selector, elem ) : elem, |
|
5959 i = 0; |
|
5960 |
|
5961 for ( ; ( node = nodes[ i ] ) != null; i++ ) { |
|
5962 if ( !keepData && node.nodeType === 1 ) { |
|
5963 jQuery.cleanData( getAll( node ) ); |
|
5964 } |
|
5965 |
|
5966 if ( node.parentNode ) { |
|
5967 if ( keepData && isAttached( node ) ) { |
|
5968 setGlobalEval( getAll( node, "script" ) ); |
|
5969 } |
|
5970 node.parentNode.removeChild( node ); |
|
5971 } |
|
5972 } |
|
5973 |
|
5974 return elem; |
|
5975 } |
|
5976 |
|
5977 jQuery.extend( { |
|
5978 htmlPrefilter: function( html ) { |
|
5979 return html.replace( rxhtmlTag, "<$1></$2>" ); |
|
5980 }, |
|
5981 |
5043 clone: function( elem, dataAndEvents, deepDataAndEvents ) { |
5982 clone: function( elem, dataAndEvents, deepDataAndEvents ) { |
5044 var i, l, srcElements, destElements, |
5983 var i, l, srcElements, destElements, |
5045 clone = elem.cloneNode( true ), |
5984 clone = elem.cloneNode( true ), |
5046 inPage = jQuery.contains( elem.ownerDocument, elem ); |
5985 inPage = isAttached( elem ); |
5047 |
5986 |
5048 // Fix IE cloning issues |
5987 // Fix IE cloning issues |
5049 if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) && |
5988 if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) && |
5050 !jQuery.isXMLDoc( elem ) ) { |
5989 !jQuery.isXMLDoc( elem ) ) { |
5051 |
5990 |
5052 // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2 |
5991 // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2 |
5053 destElements = getAll( clone ); |
5992 destElements = getAll( clone ); |
5054 srcElements = getAll( elem ); |
5993 srcElements = getAll( elem ); |
5055 |
5994 |
5056 for ( i = 0, l = srcElements.length; i < l; i++ ) { |
5995 for ( i = 0, l = srcElements.length; i < l; i++ ) { |
5057 fixInput( srcElements[ i ], destElements[ i ] ); |
5996 fixInput( srcElements[ i ], destElements[ i ] ); |
5187 } else { |
6038 } else { |
5188 jQuery.removeEvent( elem, type, data.handle ); |
6039 jQuery.removeEvent( elem, type, data.handle ); |
5189 } |
6040 } |
5190 } |
6041 } |
5191 } |
6042 } |
5192 if ( data_priv.cache[ key ] ) { |
6043 |
5193 // Discard any remaining `private` data |
6044 // Support: Chrome <=35 - 45+ |
5194 delete data_priv.cache[ key ]; |
6045 // Assign undefined instead of using delete, see Data#remove |
5195 } |
6046 elem[ dataPriv.expando ] = undefined; |
5196 } |
6047 } |
5197 } |
6048 if ( elem[ dataUser.expando ] ) { |
5198 // Discard any remaining `user` data |
6049 |
5199 delete data_user.cache[ elem[ data_user.expando ] ]; |
6050 // Support: Chrome <=35 - 45+ |
5200 } |
6051 // Assign undefined instead of using delete, see Data#remove |
5201 } |
6052 elem[ dataUser.expando ] = undefined; |
5202 }); |
6053 } |
5203 |
6054 } |
5204 jQuery.fn.extend({ |
6055 } |
|
6056 } |
|
6057 } ); |
|
6058 |
|
6059 jQuery.fn.extend( { |
|
6060 detach: function( selector ) { |
|
6061 return remove( this, selector, true ); |
|
6062 }, |
|
6063 |
|
6064 remove: function( selector ) { |
|
6065 return remove( this, selector ); |
|
6066 }, |
|
6067 |
5205 text: function( value ) { |
6068 text: function( value ) { |
5206 return access( this, function( value ) { |
6069 return access( this, function( value ) { |
5207 return value === undefined ? |
6070 return value === undefined ? |
5208 jQuery.text( this ) : |
6071 jQuery.text( this ) : |
5209 this.empty().each(function() { |
6072 this.empty().each( function() { |
5210 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { |
6073 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { |
5211 this.textContent = value; |
6074 this.textContent = value; |
5212 } |
6075 } |
5213 }); |
6076 } ); |
5214 }, null, value, arguments.length ); |
6077 }, null, value, arguments.length ); |
5215 }, |
6078 }, |
5216 |
6079 |
5217 append: function() { |
6080 append: function() { |
5218 return this.domManip( arguments, function( elem ) { |
6081 return domManip( this, arguments, function( elem ) { |
5219 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { |
6082 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { |
5220 var target = manipulationTarget( this, elem ); |
6083 var target = manipulationTarget( this, elem ); |
5221 target.appendChild( elem ); |
6084 target.appendChild( elem ); |
5222 } |
6085 } |
5223 }); |
6086 } ); |
5224 }, |
6087 }, |
5225 |
6088 |
5226 prepend: function() { |
6089 prepend: function() { |
5227 return this.domManip( arguments, function( elem ) { |
6090 return domManip( this, arguments, function( elem ) { |
5228 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { |
6091 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { |
5229 var target = manipulationTarget( this, elem ); |
6092 var target = manipulationTarget( this, elem ); |
5230 target.insertBefore( elem, target.firstChild ); |
6093 target.insertBefore( elem, target.firstChild ); |
5231 } |
6094 } |
5232 }); |
6095 } ); |
5233 }, |
6096 }, |
5234 |
6097 |
5235 before: function() { |
6098 before: function() { |
5236 return this.domManip( arguments, function( elem ) { |
6099 return domManip( this, arguments, function( elem ) { |
5237 if ( this.parentNode ) { |
6100 if ( this.parentNode ) { |
5238 this.parentNode.insertBefore( elem, this ); |
6101 this.parentNode.insertBefore( elem, this ); |
5239 } |
6102 } |
5240 }); |
6103 } ); |
5241 }, |
6104 }, |
5242 |
6105 |
5243 after: function() { |
6106 after: function() { |
5244 return this.domManip( arguments, function( elem ) { |
6107 return domManip( this, arguments, function( elem ) { |
5245 if ( this.parentNode ) { |
6108 if ( this.parentNode ) { |
5246 this.parentNode.insertBefore( elem, this.nextSibling ); |
6109 this.parentNode.insertBefore( elem, this.nextSibling ); |
5247 } |
6110 } |
5248 }); |
6111 } ); |
5249 }, |
|
5250 |
|
5251 remove: function( selector, keepData /* Internal Use Only */ ) { |
|
5252 var elem, |
|
5253 elems = selector ? jQuery.filter( selector, this ) : this, |
|
5254 i = 0; |
|
5255 |
|
5256 for ( ; (elem = elems[i]) != null; i++ ) { |
|
5257 if ( !keepData && elem.nodeType === 1 ) { |
|
5258 jQuery.cleanData( getAll( elem ) ); |
|
5259 } |
|
5260 |
|
5261 if ( elem.parentNode ) { |
|
5262 if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) { |
|
5263 setGlobalEval( getAll( elem, "script" ) ); |
|
5264 } |
|
5265 elem.parentNode.removeChild( elem ); |
|
5266 } |
|
5267 } |
|
5268 |
|
5269 return this; |
|
5270 }, |
6112 }, |
5271 |
6113 |
5272 empty: function() { |
6114 empty: function() { |
5273 var elem, |
6115 var elem, |
5274 i = 0; |
6116 i = 0; |
5275 |
6117 |
5276 for ( ; (elem = this[i]) != null; i++ ) { |
6118 for ( ; ( elem = this[ i ] ) != null; i++ ) { |
5277 if ( elem.nodeType === 1 ) { |
6119 if ( elem.nodeType === 1 ) { |
5278 |
6120 |
5279 // Prevent memory leaks |
6121 // Prevent memory leaks |
5280 jQuery.cleanData( getAll( elem, false ) ); |
6122 jQuery.cleanData( getAll( elem, false ) ); |
5281 |
6123 |
5324 } |
6166 } |
5325 |
6167 |
5326 elem = 0; |
6168 elem = 0; |
5327 |
6169 |
5328 // If using innerHTML throws an exception, use the fallback method |
6170 // If using innerHTML throws an exception, use the fallback method |
5329 } catch( e ) {} |
6171 } catch ( e ) {} |
5330 } |
6172 } |
5331 |
6173 |
5332 if ( elem ) { |
6174 if ( elem ) { |
5333 this.empty().append( value ); |
6175 this.empty().append( value ); |
5334 } |
6176 } |
5335 }, null, value, arguments.length ); |
6177 }, null, value, arguments.length ); |
5336 }, |
6178 }, |
5337 |
6179 |
5338 replaceWith: function() { |
6180 replaceWith: function() { |
5339 var arg = arguments[ 0 ]; |
6181 var ignored = []; |
5340 |
6182 |
5341 // Make the changes, replacing each context element with the new content |
6183 // Make the changes, replacing each non-ignored context element with the new content |
5342 this.domManip( arguments, function( elem ) { |
6184 return domManip( this, arguments, function( elem ) { |
5343 arg = this.parentNode; |
6185 var parent = this.parentNode; |
5344 |
6186 |
5345 jQuery.cleanData( getAll( this ) ); |
6187 if ( jQuery.inArray( this, ignored ) < 0 ) { |
5346 |
6188 jQuery.cleanData( getAll( this ) ); |
5347 if ( arg ) { |
6189 if ( parent ) { |
5348 arg.replaceChild( elem, this ); |
6190 parent.replaceChild( elem, this ); |
5349 } |
6191 } |
5350 }); |
6192 } |
5351 |
6193 |
5352 // Force removal if there was no new content (e.g., from empty arguments) |
6194 // Force callback invocation |
5353 return arg && (arg.length || arg.nodeType) ? this : this.remove(); |
6195 }, ignored ); |
5354 }, |
6196 } |
5355 |
6197 } ); |
5356 detach: function( selector ) { |
6198 |
5357 return this.remove( selector, true ); |
6199 jQuery.each( { |
5358 }, |
|
5359 |
|
5360 domManip: function( args, callback ) { |
|
5361 |
|
5362 // Flatten any nested arrays |
|
5363 args = concat.apply( [], args ); |
|
5364 |
|
5365 var fragment, first, scripts, hasScripts, node, doc, |
|
5366 i = 0, |
|
5367 l = this.length, |
|
5368 set = this, |
|
5369 iNoClone = l - 1, |
|
5370 value = args[ 0 ], |
|
5371 isFunction = jQuery.isFunction( value ); |
|
5372 |
|
5373 // We can't cloneNode fragments that contain checked, in WebKit |
|
5374 if ( isFunction || |
|
5375 ( l > 1 && typeof value === "string" && |
|
5376 !support.checkClone && rchecked.test( value ) ) ) { |
|
5377 return this.each(function( index ) { |
|
5378 var self = set.eq( index ); |
|
5379 if ( isFunction ) { |
|
5380 args[ 0 ] = value.call( this, index, self.html() ); |
|
5381 } |
|
5382 self.domManip( args, callback ); |
|
5383 }); |
|
5384 } |
|
5385 |
|
5386 if ( l ) { |
|
5387 fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this ); |
|
5388 first = fragment.firstChild; |
|
5389 |
|
5390 if ( fragment.childNodes.length === 1 ) { |
|
5391 fragment = first; |
|
5392 } |
|
5393 |
|
5394 if ( first ) { |
|
5395 scripts = jQuery.map( getAll( fragment, "script" ), disableScript ); |
|
5396 hasScripts = scripts.length; |
|
5397 |
|
5398 // Use the original fragment for the last item instead of the first because it can end up |
|
5399 // being emptied incorrectly in certain situations (#8070). |
|
5400 for ( ; i < l; i++ ) { |
|
5401 node = fragment; |
|
5402 |
|
5403 if ( i !== iNoClone ) { |
|
5404 node = jQuery.clone( node, true, true ); |
|
5405 |
|
5406 // Keep references to cloned scripts for later restoration |
|
5407 if ( hasScripts ) { |
|
5408 // Support: QtWebKit |
|
5409 // jQuery.merge because push.apply(_, arraylike) throws |
|
5410 jQuery.merge( scripts, getAll( node, "script" ) ); |
|
5411 } |
|
5412 } |
|
5413 |
|
5414 callback.call( this[ i ], node, i ); |
|
5415 } |
|
5416 |
|
5417 if ( hasScripts ) { |
|
5418 doc = scripts[ scripts.length - 1 ].ownerDocument; |
|
5419 |
|
5420 // Reenable scripts |
|
5421 jQuery.map( scripts, restoreScript ); |
|
5422 |
|
5423 // Evaluate executable scripts on first document insertion |
|
5424 for ( i = 0; i < hasScripts; i++ ) { |
|
5425 node = scripts[ i ]; |
|
5426 if ( rscriptType.test( node.type || "" ) && |
|
5427 !data_priv.access( node, "globalEval" ) && jQuery.contains( doc, node ) ) { |
|
5428 |
|
5429 if ( node.src ) { |
|
5430 // Optional AJAX dependency, but won't run scripts if not present |
|
5431 if ( jQuery._evalUrl ) { |
|
5432 jQuery._evalUrl( node.src ); |
|
5433 } |
|
5434 } else { |
|
5435 jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) ); |
|
5436 } |
|
5437 } |
|
5438 } |
|
5439 } |
|
5440 } |
|
5441 } |
|
5442 |
|
5443 return this; |
|
5444 } |
|
5445 }); |
|
5446 |
|
5447 jQuery.each({ |
|
5448 appendTo: "append", |
6200 appendTo: "append", |
5449 prependTo: "prepend", |
6201 prependTo: "prepend", |
5450 insertBefore: "before", |
6202 insertBefore: "before", |
5451 insertAfter: "after", |
6203 insertAfter: "after", |
5452 replaceAll: "replaceWith" |
6204 replaceAll: "replaceWith" |
5460 |
6212 |
5461 for ( ; i <= last; i++ ) { |
6213 for ( ; i <= last; i++ ) { |
5462 elems = i === last ? this : this.clone( true ); |
6214 elems = i === last ? this : this.clone( true ); |
5463 jQuery( insert[ i ] )[ original ]( elems ); |
6215 jQuery( insert[ i ] )[ original ]( elems ); |
5464 |
6216 |
5465 // Support: QtWebKit |
6217 // Support: Android <=4.0 only, PhantomJS 1 only |
5466 // .get() because push.apply(_, arraylike) throws |
6218 // .get() because push.apply(_, arraylike) throws on ancient WebKit |
5467 push.apply( ret, elems.get() ); |
6219 push.apply( ret, elems.get() ); |
5468 } |
6220 } |
5469 |
6221 |
5470 return this.pushStack( ret ); |
6222 return this.pushStack( ret ); |
5471 }; |
6223 }; |
5472 }); |
6224 } ); |
5473 |
|
5474 |
|
5475 var iframe, |
|
5476 elemdisplay = {}; |
|
5477 |
|
5478 /** |
|
5479 * Retrieve the actual display of a element |
|
5480 * @param {String} name nodeName of the element |
|
5481 * @param {Object} doc Document object |
|
5482 */ |
|
5483 // Called only from within defaultDisplay |
|
5484 function actualDisplay( name, doc ) { |
|
5485 var style, |
|
5486 elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ), |
|
5487 |
|
5488 // getDefaultComputedStyle might be reliably used only on attached element |
|
5489 display = window.getDefaultComputedStyle && ( style = window.getDefaultComputedStyle( elem[ 0 ] ) ) ? |
|
5490 |
|
5491 // Use of this method is a temporary fix (more like optimization) until something better comes along, |
|
5492 // since it was removed from specification and supported only in FF |
|
5493 style.display : jQuery.css( elem[ 0 ], "display" ); |
|
5494 |
|
5495 // We don't have any data stored on the element, |
|
5496 // so use "detach" method as fast way to get rid of the element |
|
5497 elem.detach(); |
|
5498 |
|
5499 return display; |
|
5500 } |
|
5501 |
|
5502 /** |
|
5503 * Try to determine the default display value of an element |
|
5504 * @param {String} nodeName |
|
5505 */ |
|
5506 function defaultDisplay( nodeName ) { |
|
5507 var doc = document, |
|
5508 display = elemdisplay[ nodeName ]; |
|
5509 |
|
5510 if ( !display ) { |
|
5511 display = actualDisplay( nodeName, doc ); |
|
5512 |
|
5513 // If the simple way fails, read from inside an iframe |
|
5514 if ( display === "none" || !display ) { |
|
5515 |
|
5516 // Use the already-created iframe if possible |
|
5517 iframe = (iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" )).appendTo( doc.documentElement ); |
|
5518 |
|
5519 // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse |
|
5520 doc = iframe[ 0 ].contentDocument; |
|
5521 |
|
5522 // Support: IE |
|
5523 doc.write(); |
|
5524 doc.close(); |
|
5525 |
|
5526 display = actualDisplay( nodeName, doc ); |
|
5527 iframe.detach(); |
|
5528 } |
|
5529 |
|
5530 // Store the correct default display |
|
5531 elemdisplay[ nodeName ] = display; |
|
5532 } |
|
5533 |
|
5534 return display; |
|
5535 } |
|
5536 var rmargin = (/^margin/); |
|
5537 |
|
5538 var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" ); |
6225 var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" ); |
5539 |
6226 |
5540 var getStyles = function( elem ) { |
6227 var getStyles = function( elem ) { |
5541 // Support: IE<=11+, Firefox<=30+ (#15098, #14150) |
6228 |
|
6229 // Support: IE <=11 only, Firefox <=30 (#15098, #14150) |
5542 // IE throws on elements created in popups |
6230 // IE throws on elements created in popups |
5543 // FF meanwhile throws on frame elements through "defaultView.getComputedStyle" |
6231 // FF meanwhile throws on frame elements through "defaultView.getComputedStyle" |
5544 if ( elem.ownerDocument.defaultView.opener ) { |
6232 var view = elem.ownerDocument.defaultView; |
5545 return elem.ownerDocument.defaultView.getComputedStyle( elem, null ); |
6233 |
5546 } |
6234 if ( !view || !view.opener ) { |
5547 |
6235 view = window; |
5548 return window.getComputedStyle( elem, null ); |
6236 } |
|
6237 |
|
6238 return view.getComputedStyle( elem ); |
5549 }; |
6239 }; |
5550 |
6240 |
|
6241 var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" ); |
|
6242 |
|
6243 |
|
6244 |
|
6245 ( function() { |
|
6246 |
|
6247 // Executing both pixelPosition & boxSizingReliable tests require only one layout |
|
6248 // so they're executed at the same time to save the second computation. |
|
6249 function computeStyleTests() { |
|
6250 |
|
6251 // This is a singleton, we need to execute it only once |
|
6252 if ( !div ) { |
|
6253 return; |
|
6254 } |
|
6255 |
|
6256 container.style.cssText = "position:absolute;left:-11111px;width:60px;" + |
|
6257 "margin-top:1px;padding:0;border:0"; |
|
6258 div.style.cssText = |
|
6259 "position:relative;display:block;box-sizing:border-box;overflow:scroll;" + |
|
6260 "margin:auto;border:1px;padding:1px;" + |
|
6261 "width:60%;top:1%"; |
|
6262 documentElement.appendChild( container ).appendChild( div ); |
|
6263 |
|
6264 var divStyle = window.getComputedStyle( div ); |
|
6265 pixelPositionVal = divStyle.top !== "1%"; |
|
6266 |
|
6267 // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44 |
|
6268 reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12; |
|
6269 |
|
6270 // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3 |
|
6271 // Some styles come back with percentage values, even though they shouldn't |
|
6272 div.style.right = "60%"; |
|
6273 pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36; |
|
6274 |
|
6275 // Support: IE 9 - 11 only |
|
6276 // Detect misreporting of content dimensions for box-sizing:border-box elements |
|
6277 boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36; |
|
6278 |
|
6279 // Support: IE 9 only |
|
6280 // Detect overflow:scroll screwiness (gh-3699) |
|
6281 // Support: Chrome <=64 |
|
6282 // Don't get tricked when zoom affects offsetWidth (gh-4029) |
|
6283 div.style.position = "absolute"; |
|
6284 scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12; |
|
6285 |
|
6286 documentElement.removeChild( container ); |
|
6287 |
|
6288 // Nullify the div so it wouldn't be stored in the memory and |
|
6289 // it will also be a sign that checks already performed |
|
6290 div = null; |
|
6291 } |
|
6292 |
|
6293 function roundPixelMeasures( measure ) { |
|
6294 return Math.round( parseFloat( measure ) ); |
|
6295 } |
|
6296 |
|
6297 var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal, |
|
6298 reliableMarginLeftVal, |
|
6299 container = document.createElement( "div" ), |
|
6300 div = document.createElement( "div" ); |
|
6301 |
|
6302 // Finish early in limited (non-browser) environments |
|
6303 if ( !div.style ) { |
|
6304 return; |
|
6305 } |
|
6306 |
|
6307 // Support: IE <=9 - 11 only |
|
6308 // Style of cloned element affects source element cloned (#8908) |
|
6309 div.style.backgroundClip = "content-box"; |
|
6310 div.cloneNode( true ).style.backgroundClip = ""; |
|
6311 support.clearCloneStyle = div.style.backgroundClip === "content-box"; |
|
6312 |
|
6313 jQuery.extend( support, { |
|
6314 boxSizingReliable: function() { |
|
6315 computeStyleTests(); |
|
6316 return boxSizingReliableVal; |
|
6317 }, |
|
6318 pixelBoxStyles: function() { |
|
6319 computeStyleTests(); |
|
6320 return pixelBoxStylesVal; |
|
6321 }, |
|
6322 pixelPosition: function() { |
|
6323 computeStyleTests(); |
|
6324 return pixelPositionVal; |
|
6325 }, |
|
6326 reliableMarginLeft: function() { |
|
6327 computeStyleTests(); |
|
6328 return reliableMarginLeftVal; |
|
6329 }, |
|
6330 scrollboxSize: function() { |
|
6331 computeStyleTests(); |
|
6332 return scrollboxSizeVal; |
|
6333 } |
|
6334 } ); |
|
6335 } )(); |
5551 |
6336 |
5552 |
6337 |
5553 function curCSS( elem, name, computed ) { |
6338 function curCSS( elem, name, computed ) { |
5554 var width, minWidth, maxWidth, ret, |
6339 var width, minWidth, maxWidth, ret, |
|
6340 |
|
6341 // Support: Firefox 51+ |
|
6342 // Retrieving style before computed somehow |
|
6343 // fixes an issue with getting wrong values |
|
6344 // on detached elements |
5555 style = elem.style; |
6345 style = elem.style; |
5556 |
6346 |
5557 computed = computed || getStyles( elem ); |
6347 computed = computed || getStyles( elem ); |
5558 |
6348 |
5559 // Support: IE9 |
6349 // getPropertyValue is needed for: |
5560 // getPropertyValue is only needed for .css('filter') (#12537) |
6350 // .css('filter') (IE 9 only, #12537) |
|
6351 // .css('--customProperty) (#3144) |
5561 if ( computed ) { |
6352 if ( computed ) { |
5562 ret = computed.getPropertyValue( name ) || computed[ name ]; |
6353 ret = computed.getPropertyValue( name ) || computed[ name ]; |
5563 } |
6354 |
5564 |
6355 if ( ret === "" && !isAttached( elem ) ) { |
5565 if ( computed ) { |
|
5566 |
|
5567 if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) { |
|
5568 ret = jQuery.style( elem, name ); |
6356 ret = jQuery.style( elem, name ); |
5569 } |
6357 } |
5570 |
6358 |
5571 // Support: iOS < 6 |
|
5572 // A tribute to the "awesome hack by Dean Edwards" |
6359 // A tribute to the "awesome hack by Dean Edwards" |
5573 // iOS < 6 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels |
6360 // Android Browser returns percentage for some values, |
5574 // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values |
6361 // but width seems to be reliably pixels. |
5575 if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) { |
6362 // This is against the CSSOM draft spec: |
|
6363 // https://drafts.csswg.org/cssom/#resolved-values |
|
6364 if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) { |
5576 |
6365 |
5577 // Remember the original values |
6366 // Remember the original values |
5578 width = style.width; |
6367 width = style.width; |
5579 minWidth = style.minWidth; |
6368 minWidth = style.minWidth; |
5580 maxWidth = style.maxWidth; |
6369 maxWidth = style.maxWidth; |
5589 style.maxWidth = maxWidth; |
6378 style.maxWidth = maxWidth; |
5590 } |
6379 } |
5591 } |
6380 } |
5592 |
6381 |
5593 return ret !== undefined ? |
6382 return ret !== undefined ? |
5594 // Support: IE |
6383 |
|
6384 // Support: IE <=9 - 11 only |
5595 // IE returns zIndex value as an integer. |
6385 // IE returns zIndex value as an integer. |
5596 ret + "" : |
6386 ret + "" : |
5597 ret; |
6387 ret; |
5598 } |
6388 } |
5599 |
6389 |
5600 |
6390 |
5601 function addGetHookIf( conditionFn, hookFn ) { |
6391 function addGetHookIf( conditionFn, hookFn ) { |
|
6392 |
5602 // Define the hook, we'll check on the first run if it's really needed. |
6393 // Define the hook, we'll check on the first run if it's really needed. |
5603 return { |
6394 return { |
5604 get: function() { |
6395 get: function() { |
5605 if ( conditionFn() ) { |
6396 if ( conditionFn() ) { |
|
6397 |
5606 // Hook not needed (or it's not possible to use it due |
6398 // Hook not needed (or it's not possible to use it due |
5607 // to missing dependency), remove it. |
6399 // to missing dependency), remove it. |
5608 delete this.get; |
6400 delete this.get; |
5609 return; |
6401 return; |
5610 } |
6402 } |
5611 |
6403 |
5612 // Hook needed; redefine it so that the support test is not executed again. |
6404 // Hook needed; redefine it so that the support test is not executed again. |
5613 return (this.get = hookFn).apply( this, arguments ); |
6405 return ( this.get = hookFn ).apply( this, arguments ); |
5614 } |
6406 } |
5615 }; |
6407 }; |
5616 } |
6408 } |
5617 |
6409 |
5618 |
6410 |
5619 (function() { |
6411 var cssPrefixes = [ "Webkit", "Moz", "ms" ], |
5620 var pixelPositionVal, boxSizingReliableVal, |
6412 emptyStyle = document.createElement( "div" ).style, |
5621 docElem = document.documentElement, |
6413 vendorProps = {}; |
5622 container = document.createElement( "div" ), |
6414 |
5623 div = document.createElement( "div" ); |
6415 // Return a vendor-prefixed property or undefined |
5624 |
6416 function vendorPropName( name ) { |
5625 if ( !div.style ) { |
6417 |
5626 return; |
6418 // Check for vendor prefixed names |
5627 } |
6419 var capName = name[ 0 ].toUpperCase() + name.slice( 1 ), |
5628 |
6420 i = cssPrefixes.length; |
5629 // Support: IE9-11+ |
6421 |
5630 // Style of cloned element affects source element cloned (#8908) |
6422 while ( i-- ) { |
5631 div.style.backgroundClip = "content-box"; |
6423 name = cssPrefixes[ i ] + capName; |
5632 div.cloneNode( true ).style.backgroundClip = ""; |
6424 if ( name in emptyStyle ) { |
5633 support.clearCloneStyle = div.style.backgroundClip === "content-box"; |
6425 return name; |
5634 |
6426 } |
5635 container.style.cssText = "border:0;width:0;height:0;top:0;left:-9999px;margin-top:1px;" + |
6427 } |
5636 "position:absolute"; |
6428 } |
5637 container.appendChild( div ); |
6429 |
5638 |
6430 // Return a potentially-mapped jQuery.cssProps or vendor prefixed property |
5639 // Executing both pixelPosition & boxSizingReliable tests require only one layout |
6431 function finalPropName( name ) { |
5640 // so they're executed at the same time to save the second computation. |
6432 var final = jQuery.cssProps[ name ] || vendorProps[ name ]; |
5641 function computePixelPositionAndBoxSizingReliable() { |
6433 |
5642 div.style.cssText = |
6434 if ( final ) { |
5643 // Support: Firefox<29, Android 2.3 |
6435 return final; |
5644 // Vendor-prefix box-sizing |
6436 } |
5645 "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;" + |
6437 if ( name in emptyStyle ) { |
5646 "box-sizing:border-box;display:block;margin-top:1%;top:1%;" + |
6438 return name; |
5647 "border:1px;padding:1px;width:4px;position:absolute"; |
6439 } |
5648 div.innerHTML = ""; |
6440 return vendorProps[ name ] = vendorPropName( name ) || name; |
5649 docElem.appendChild( container ); |
6441 } |
5650 |
|
5651 var divStyle = window.getComputedStyle( div, null ); |
|
5652 pixelPositionVal = divStyle.top !== "1%"; |
|
5653 boxSizingReliableVal = divStyle.width === "4px"; |
|
5654 |
|
5655 docElem.removeChild( container ); |
|
5656 } |
|
5657 |
|
5658 // Support: node.js jsdom |
|
5659 // Don't assume that getComputedStyle is a property of the global object |
|
5660 if ( window.getComputedStyle ) { |
|
5661 jQuery.extend( support, { |
|
5662 pixelPosition: function() { |
|
5663 |
|
5664 // This test is executed only once but we still do memoizing |
|
5665 // since we can use the boxSizingReliable pre-computing. |
|
5666 // No need to check if the test was already performed, though. |
|
5667 computePixelPositionAndBoxSizingReliable(); |
|
5668 return pixelPositionVal; |
|
5669 }, |
|
5670 boxSizingReliable: function() { |
|
5671 if ( boxSizingReliableVal == null ) { |
|
5672 computePixelPositionAndBoxSizingReliable(); |
|
5673 } |
|
5674 return boxSizingReliableVal; |
|
5675 }, |
|
5676 reliableMarginRight: function() { |
|
5677 |
|
5678 // Support: Android 2.3 |
|
5679 // Check if div with explicit width and no margin-right incorrectly |
|
5680 // gets computed margin-right based on width of container. (#3333) |
|
5681 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right |
|
5682 // This support function is only executed once so no memoizing is needed. |
|
5683 var ret, |
|
5684 marginDiv = div.appendChild( document.createElement( "div" ) ); |
|
5685 |
|
5686 // Reset CSS: box-sizing; display; margin; border; padding |
|
5687 marginDiv.style.cssText = div.style.cssText = |
|
5688 // Support: Firefox<29, Android 2.3 |
|
5689 // Vendor-prefix box-sizing |
|
5690 "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" + |
|
5691 "box-sizing:content-box;display:block;margin:0;border:0;padding:0"; |
|
5692 marginDiv.style.marginRight = marginDiv.style.width = "0"; |
|
5693 div.style.width = "1px"; |
|
5694 docElem.appendChild( container ); |
|
5695 |
|
5696 ret = !parseFloat( window.getComputedStyle( marginDiv, null ).marginRight ); |
|
5697 |
|
5698 docElem.removeChild( container ); |
|
5699 div.removeChild( marginDiv ); |
|
5700 |
|
5701 return ret; |
|
5702 } |
|
5703 }); |
|
5704 } |
|
5705 })(); |
|
5706 |
|
5707 |
|
5708 // A method for quickly swapping in/out CSS properties to get correct calculations. |
|
5709 jQuery.swap = function( elem, options, callback, args ) { |
|
5710 var ret, name, |
|
5711 old = {}; |
|
5712 |
|
5713 // Remember the old values, and insert the new ones |
|
5714 for ( name in options ) { |
|
5715 old[ name ] = elem.style[ name ]; |
|
5716 elem.style[ name ] = options[ name ]; |
|
5717 } |
|
5718 |
|
5719 ret = callback.apply( elem, args || [] ); |
|
5720 |
|
5721 // Revert the old values |
|
5722 for ( name in options ) { |
|
5723 elem.style[ name ] = old[ name ]; |
|
5724 } |
|
5725 |
|
5726 return ret; |
|
5727 }; |
|
5728 |
6442 |
5729 |
6443 |
5730 var |
6444 var |
5731 // Swappable if display is none or starts with table except "table", "table-cell", or "table-caption" |
6445 |
|
6446 // Swappable if display is none or starts with table |
|
6447 // except "table", "table-cell", or "table-caption" |
5732 // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display |
6448 // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display |
5733 rdisplayswap = /^(none|table(?!-c[ea]).+)/, |
6449 rdisplayswap = /^(none|table(?!-c[ea]).+)/, |
5734 rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ), |
6450 rcustomProp = /^--/, |
5735 rrelNum = new RegExp( "^([+-])=(" + pnum + ")", "i" ), |
|
5736 |
|
5737 cssShow = { position: "absolute", visibility: "hidden", display: "block" }, |
6451 cssShow = { position: "absolute", visibility: "hidden", display: "block" }, |
5738 cssNormalTransform = { |
6452 cssNormalTransform = { |
5739 letterSpacing: "0", |
6453 letterSpacing: "0", |
5740 fontWeight: "400" |
6454 fontWeight: "400" |
5741 }, |
6455 }; |
5742 |
|
5743 cssPrefixes = [ "Webkit", "O", "Moz", "ms" ]; |
|
5744 |
|
5745 // Return a css property mapped to a potentially vendor prefixed property |
|
5746 function vendorPropName( style, name ) { |
|
5747 |
|
5748 // Shortcut for names that are not vendor prefixed |
|
5749 if ( name in style ) { |
|
5750 return name; |
|
5751 } |
|
5752 |
|
5753 // Check for vendor prefixed names |
|
5754 var capName = name[0].toUpperCase() + name.slice(1), |
|
5755 origName = name, |
|
5756 i = cssPrefixes.length; |
|
5757 |
|
5758 while ( i-- ) { |
|
5759 name = cssPrefixes[ i ] + capName; |
|
5760 if ( name in style ) { |
|
5761 return name; |
|
5762 } |
|
5763 } |
|
5764 |
|
5765 return origName; |
|
5766 } |
|
5767 |
6456 |
5768 function setPositiveNumber( elem, value, subtract ) { |
6457 function setPositiveNumber( elem, value, subtract ) { |
5769 var matches = rnumsplit.exec( value ); |
6458 |
|
6459 // Any relative (+/-) values have already been |
|
6460 // normalized at this point |
|
6461 var matches = rcssNum.exec( value ); |
5770 return matches ? |
6462 return matches ? |
|
6463 |
5771 // Guard against undefined "subtract", e.g., when used as in cssHooks |
6464 // Guard against undefined "subtract", e.g., when used as in cssHooks |
5772 Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) : |
6465 Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) : |
5773 value; |
6466 value; |
5774 } |
6467 } |
5775 |
6468 |
5776 function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) { |
6469 function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) { |
5777 var i = extra === ( isBorderBox ? "border" : "content" ) ? |
6470 var i = dimension === "width" ? 1 : 0, |
5778 // If we already have the right measurement, avoid augmentation |
6471 extra = 0, |
5779 4 : |
6472 delta = 0; |
5780 // Otherwise initialize for horizontal or vertical properties |
6473 |
5781 name === "width" ? 1 : 0, |
6474 // Adjustment may not be necessary |
5782 |
6475 if ( box === ( isBorderBox ? "border" : "content" ) ) { |
5783 val = 0; |
6476 return 0; |
|
6477 } |
5784 |
6478 |
5785 for ( ; i < 4; i += 2 ) { |
6479 for ( ; i < 4; i += 2 ) { |
5786 // Both box models exclude margin, so add it if we want it |
6480 |
5787 if ( extra === "margin" ) { |
6481 // Both box models exclude margin |
5788 val += jQuery.css( elem, extra + cssExpand[ i ], true, styles ); |
6482 if ( box === "margin" ) { |
5789 } |
6483 delta += jQuery.css( elem, box + cssExpand[ i ], true, styles ); |
5790 |
6484 } |
5791 if ( isBorderBox ) { |
6485 |
5792 // border-box includes padding, so remove it if we want content |
6486 // If we get here with a content-box, we're seeking "padding" or "border" or "margin" |
5793 if ( extra === "content" ) { |
6487 if ( !isBorderBox ) { |
5794 val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); |
6488 |
5795 } |
6489 // Add padding |
5796 |
6490 delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); |
5797 // At this point, extra isn't border nor margin, so remove border |
6491 |
5798 if ( extra !== "margin" ) { |
6492 // For "border" or "margin", add border |
5799 val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); |
6493 if ( box !== "padding" ) { |
5800 } |
6494 delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); |
|
6495 |
|
6496 // But still keep track of it otherwise |
|
6497 } else { |
|
6498 extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); |
|
6499 } |
|
6500 |
|
6501 // If we get here with a border-box (content + padding + border), we're seeking "content" or |
|
6502 // "padding" or "margin" |
5801 } else { |
6503 } else { |
5802 // At this point, extra isn't content, so add padding |
6504 |
5803 val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); |
6505 // For "content", subtract padding |
5804 |
6506 if ( box === "content" ) { |
5805 // At this point, extra isn't content nor padding, so add border |
6507 delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); |
5806 if ( extra !== "padding" ) { |
6508 } |
5807 val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); |
6509 |
5808 } |
6510 // For "content" or "padding", subtract border |
5809 } |
6511 if ( box !== "margin" ) { |
5810 } |
6512 delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); |
5811 |
6513 } |
5812 return val; |
6514 } |
|
6515 } |
|
6516 |
|
6517 // Account for positive content-box scroll gutter when requested by providing computedVal |
|
6518 if ( !isBorderBox && computedVal >= 0 ) { |
|
6519 |
|
6520 // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border |
|
6521 // Assuming integer scroll gutter, subtract the rest and round down |
|
6522 delta += Math.max( 0, Math.ceil( |
|
6523 elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] - |
|
6524 computedVal - |
|
6525 delta - |
|
6526 extra - |
|
6527 0.5 |
|
6528 |
|
6529 // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter |
|
6530 // Use an explicit zero to avoid NaN (gh-3964) |
|
6531 ) ) || 0; |
|
6532 } |
|
6533 |
|
6534 return delta; |
5813 } |
6535 } |
5814 |
6536 |
5815 function getWidthOrHeight( elem, name, extra ) { |
6537 function getWidthOrHeight( elem, dimension, extra ) { |
5816 |
6538 |
5817 // Start with offset property, which is equivalent to the border-box value |
6539 // Start with computed style |
5818 var valueIsBorderBox = true, |
6540 var styles = getStyles( elem ), |
5819 val = name === "width" ? elem.offsetWidth : elem.offsetHeight, |
6541 |
5820 styles = getStyles( elem ), |
6542 // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322). |
|
6543 // Fake content-box until we know it's needed to know the true value. |
|
6544 boxSizingNeeded = !support.boxSizingReliable() || extra, |
|
6545 isBorderBox = boxSizingNeeded && |
|
6546 jQuery.css( elem, "boxSizing", false, styles ) === "border-box", |
|
6547 valueIsBorderBox = isBorderBox, |
|
6548 |
|
6549 val = curCSS( elem, dimension, styles ), |
|
6550 offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ); |
|
6551 |
|
6552 // Support: Firefox <=54 |
|
6553 // Return a confounding non-pixel value or feign ignorance, as appropriate. |
|
6554 if ( rnumnonpx.test( val ) ) { |
|
6555 if ( !extra ) { |
|
6556 return val; |
|
6557 } |
|
6558 val = "auto"; |
|
6559 } |
|
6560 |
|
6561 |
|
6562 // Fall back to offsetWidth/offsetHeight when value is "auto" |
|
6563 // This happens for inline elements with no explicit setting (gh-3571) |
|
6564 // Support: Android <=4.1 - 4.3 only |
|
6565 // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602) |
|
6566 // Support: IE 9-11 only |
|
6567 // Also use offsetWidth/offsetHeight for when box sizing is unreliable |
|
6568 // We use getClientRects() to check for hidden/disconnected. |
|
6569 // In those cases, the computed value can be trusted to be border-box |
|
6570 if ( ( !support.boxSizingReliable() && isBorderBox || |
|
6571 val === "auto" || |
|
6572 !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) && |
|
6573 elem.getClientRects().length ) { |
|
6574 |
5821 isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; |
6575 isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; |
5822 |
6576 |
5823 // Some non-html elements return undefined for offsetWidth, so check for null/undefined |
6577 // Where available, offsetWidth/offsetHeight approximate border box dimensions. |
5824 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285 |
6578 // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the |
5825 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668 |
6579 // retrieved value as a content box dimension. |
5826 if ( val <= 0 || val == null ) { |
6580 valueIsBorderBox = offsetProp in elem; |
5827 // Fall back to computed then uncomputed css if necessary |
6581 if ( valueIsBorderBox ) { |
5828 val = curCSS( elem, name, styles ); |
6582 val = elem[ offsetProp ]; |
5829 if ( val < 0 || val == null ) { |
6583 } |
5830 val = elem.style[ name ]; |
6584 } |
5831 } |
6585 |
5832 |
6586 // Normalize "" and auto |
5833 // Computed unit is not pixels. Stop here and return. |
6587 val = parseFloat( val ) || 0; |
5834 if ( rnumnonpx.test(val) ) { |
6588 |
5835 return val; |
6589 // Adjust for the element's box model |
5836 } |
|
5837 |
|
5838 // Check for style in case a browser which returns unreliable values |
|
5839 // for getComputedStyle silently falls back to the reliable elem.style |
|
5840 valueIsBorderBox = isBorderBox && |
|
5841 ( support.boxSizingReliable() || val === elem.style[ name ] ); |
|
5842 |
|
5843 // Normalize "", auto, and prepare for extra |
|
5844 val = parseFloat( val ) || 0; |
|
5845 } |
|
5846 |
|
5847 // Use the active box-sizing model to add/subtract irrelevant styles |
|
5848 return ( val + |
6590 return ( val + |
5849 augmentWidthOrHeight( |
6591 boxModelAdjustment( |
5850 elem, |
6592 elem, |
5851 name, |
6593 dimension, |
5852 extra || ( isBorderBox ? "border" : "content" ), |
6594 extra || ( isBorderBox ? "border" : "content" ), |
5853 valueIsBorderBox, |
6595 valueIsBorderBox, |
5854 styles |
6596 styles, |
|
6597 |
|
6598 // Provide the current computed size to request scroll gutter calculation (gh-3589) |
|
6599 val |
5855 ) |
6600 ) |
5856 ) + "px"; |
6601 ) + "px"; |
5857 } |
6602 } |
5858 |
6603 |
5859 function showHide( elements, show ) { |
6604 jQuery.extend( { |
5860 var display, elem, hidden, |
|
5861 values = [], |
|
5862 index = 0, |
|
5863 length = elements.length; |
|
5864 |
|
5865 for ( ; index < length; index++ ) { |
|
5866 elem = elements[ index ]; |
|
5867 if ( !elem.style ) { |
|
5868 continue; |
|
5869 } |
|
5870 |
|
5871 values[ index ] = data_priv.get( elem, "olddisplay" ); |
|
5872 display = elem.style.display; |
|
5873 if ( show ) { |
|
5874 // Reset the inline display of this element to learn if it is |
|
5875 // being hidden by cascaded rules or not |
|
5876 if ( !values[ index ] && display === "none" ) { |
|
5877 elem.style.display = ""; |
|
5878 } |
|
5879 |
|
5880 // Set elements which have been overridden with display: none |
|
5881 // in a stylesheet to whatever the default browser style is |
|
5882 // for such an element |
|
5883 if ( elem.style.display === "" && isHidden( elem ) ) { |
|
5884 values[ index ] = data_priv.access( elem, "olddisplay", defaultDisplay(elem.nodeName) ); |
|
5885 } |
|
5886 } else { |
|
5887 hidden = isHidden( elem ); |
|
5888 |
|
5889 if ( display !== "none" || !hidden ) { |
|
5890 data_priv.set( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) ); |
|
5891 } |
|
5892 } |
|
5893 } |
|
5894 |
|
5895 // Set the display of most of the elements in a second loop |
|
5896 // to avoid the constant reflow |
|
5897 for ( index = 0; index < length; index++ ) { |
|
5898 elem = elements[ index ]; |
|
5899 if ( !elem.style ) { |
|
5900 continue; |
|
5901 } |
|
5902 if ( !show || elem.style.display === "none" || elem.style.display === "" ) { |
|
5903 elem.style.display = show ? values[ index ] || "" : "none"; |
|
5904 } |
|
5905 } |
|
5906 |
|
5907 return elements; |
|
5908 } |
|
5909 |
|
5910 jQuery.extend({ |
|
5911 |
6605 |
5912 // Add in style property hooks for overriding the default |
6606 // Add in style property hooks for overriding the default |
5913 // behavior of getting and setting a style property |
6607 // behavior of getting and setting a style property |
5914 cssHooks: { |
6608 cssHooks: { |
5915 opacity: { |
6609 opacity: { |
5954 return; |
6654 return; |
5955 } |
6655 } |
5956 |
6656 |
5957 // Make sure that we're working with the right name |
6657 // Make sure that we're working with the right name |
5958 var ret, type, hooks, |
6658 var ret, type, hooks, |
5959 origName = jQuery.camelCase( name ), |
6659 origName = camelCase( name ), |
|
6660 isCustomProp = rcustomProp.test( name ), |
5960 style = elem.style; |
6661 style = elem.style; |
5961 |
6662 |
5962 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) ); |
6663 // Make sure that we're working with the right name. We don't |
|
6664 // want to query the value if it is a CSS custom property |
|
6665 // since they are user-defined. |
|
6666 if ( !isCustomProp ) { |
|
6667 name = finalPropName( origName ); |
|
6668 } |
5963 |
6669 |
5964 // Gets hook for the prefixed version, then unprefixed version |
6670 // Gets hook for the prefixed version, then unprefixed version |
5965 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; |
6671 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; |
5966 |
6672 |
5967 // Check if we're setting a value |
6673 // Check if we're setting a value |
5968 if ( value !== undefined ) { |
6674 if ( value !== undefined ) { |
5969 type = typeof value; |
6675 type = typeof value; |
5970 |
6676 |
5971 // Convert "+=" or "-=" to relative numbers (#7345) |
6677 // Convert "+=" or "-=" to relative numbers (#7345) |
5972 if ( type === "string" && (ret = rrelNum.exec( value )) ) { |
6678 if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) { |
5973 value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) ); |
6679 value = adjustCSS( elem, name, ret ); |
|
6680 |
5974 // Fixes bug #9237 |
6681 // Fixes bug #9237 |
5975 type = "number"; |
6682 type = "number"; |
5976 } |
6683 } |
5977 |
6684 |
5978 // Make sure that null and NaN values aren't set (#7116) |
6685 // Make sure that null and NaN values aren't set (#7116) |
5979 if ( value == null || value !== value ) { |
6686 if ( value == null || value !== value ) { |
5980 return; |
6687 return; |
5981 } |
6688 } |
5982 |
6689 |
5983 // If a number, add 'px' to the (except for certain CSS properties) |
6690 // If a number was passed in, add the unit (except for certain CSS properties) |
5984 if ( type === "number" && !jQuery.cssNumber[ origName ] ) { |
6691 // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append |
5985 value += "px"; |
6692 // "px" to a few hardcoded values. |
5986 } |
6693 if ( type === "number" && !isCustomProp ) { |
5987 |
6694 value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" ); |
5988 // Support: IE9-11+ |
6695 } |
|
6696 |
5989 // background-* props affect original clone's values |
6697 // background-* props affect original clone's values |
5990 if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) { |
6698 if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) { |
5991 style[ name ] = "inherit"; |
6699 style[ name ] = "inherit"; |
5992 } |
6700 } |
5993 |
6701 |
5994 // If a hook was provided, use that value, otherwise just set the specified value |
6702 // If a hook was provided, use that value, otherwise just set the specified value |
5995 if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) { |
6703 if ( !hooks || !( "set" in hooks ) || |
5996 style[ name ] = value; |
6704 ( value = hooks.set( elem, value, extra ) ) !== undefined ) { |
|
6705 |
|
6706 if ( isCustomProp ) { |
|
6707 style.setProperty( name, value ); |
|
6708 } else { |
|
6709 style[ name ] = value; |
|
6710 } |
5997 } |
6711 } |
5998 |
6712 |
5999 } else { |
6713 } else { |
|
6714 |
6000 // If a hook was provided get the non-computed value from there |
6715 // If a hook was provided get the non-computed value from there |
6001 if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) { |
6716 if ( hooks && "get" in hooks && |
|
6717 ( ret = hooks.get( elem, false, extra ) ) !== undefined ) { |
|
6718 |
6002 return ret; |
6719 return ret; |
6003 } |
6720 } |
6004 |
6721 |
6005 // Otherwise just get the value from the style object |
6722 // Otherwise just get the value from the style object |
6006 return style[ name ]; |
6723 return style[ name ]; |
6007 } |
6724 } |
6008 }, |
6725 }, |
6009 |
6726 |
6010 css: function( elem, name, extra, styles ) { |
6727 css: function( elem, name, extra, styles ) { |
6011 var val, num, hooks, |
6728 var val, num, hooks, |
6012 origName = jQuery.camelCase( name ); |
6729 origName = camelCase( name ), |
6013 |
6730 isCustomProp = rcustomProp.test( name ); |
6014 // Make sure that we're working with the right name |
6731 |
6015 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) ); |
6732 // Make sure that we're working with the right name. We don't |
|
6733 // want to modify the value if it is a CSS custom property |
|
6734 // since they are user-defined. |
|
6735 if ( !isCustomProp ) { |
|
6736 name = finalPropName( origName ); |
|
6737 } |
6016 |
6738 |
6017 // Try prefixed name followed by the unprefixed name |
6739 // Try prefixed name followed by the unprefixed name |
6018 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; |
6740 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; |
6019 |
6741 |
6020 // If a hook was provided get the computed value from there |
6742 // If a hook was provided get the computed value from there |
6033 } |
6755 } |
6034 |
6756 |
6035 // Make numeric if forced or a qualifier was provided and val looks numeric |
6757 // Make numeric if forced or a qualifier was provided and val looks numeric |
6036 if ( extra === "" || extra ) { |
6758 if ( extra === "" || extra ) { |
6037 num = parseFloat( val ); |
6759 num = parseFloat( val ); |
6038 return extra === true || jQuery.isNumeric( num ) ? num || 0 : val; |
6760 return extra === true || isFinite( num ) ? num || 0 : val; |
6039 } |
6761 } |
|
6762 |
6040 return val; |
6763 return val; |
6041 } |
6764 } |
6042 }); |
6765 } ); |
6043 |
6766 |
6044 jQuery.each([ "height", "width" ], function( i, name ) { |
6767 jQuery.each( [ "height", "width" ], function( i, dimension ) { |
6045 jQuery.cssHooks[ name ] = { |
6768 jQuery.cssHooks[ dimension ] = { |
6046 get: function( elem, computed, extra ) { |
6769 get: function( elem, computed, extra ) { |
6047 if ( computed ) { |
6770 if ( computed ) { |
6048 |
6771 |
6049 // Certain elements can have dimension info if we invisibly show them |
6772 // Certain elements can have dimension info if we invisibly show them |
6050 // but it must have a current display style that would benefit |
6773 // but it must have a current display style that would benefit |
6051 return rdisplayswap.test( jQuery.css( elem, "display" ) ) && elem.offsetWidth === 0 ? |
6774 return rdisplayswap.test( jQuery.css( elem, "display" ) ) && |
6052 jQuery.swap( elem, cssShow, function() { |
6775 |
6053 return getWidthOrHeight( elem, name, extra ); |
6776 // Support: Safari 8+ |
6054 }) : |
6777 // Table columns in Safari have non-zero offsetWidth & zero |
6055 getWidthOrHeight( elem, name, extra ); |
6778 // getBoundingClientRect().width unless display is changed. |
|
6779 // Support: IE <=11 only |
|
6780 // Running getBoundingClientRect on a disconnected node |
|
6781 // in IE throws an error. |
|
6782 ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ? |
|
6783 swap( elem, cssShow, function() { |
|
6784 return getWidthOrHeight( elem, dimension, extra ); |
|
6785 } ) : |
|
6786 getWidthOrHeight( elem, dimension, extra ); |
6056 } |
6787 } |
6057 }, |
6788 }, |
6058 |
6789 |
6059 set: function( elem, value, extra ) { |
6790 set: function( elem, value, extra ) { |
6060 var styles = extra && getStyles( elem ); |
6791 var matches, |
6061 return setPositiveNumber( elem, value, extra ? |
6792 styles = getStyles( elem ), |
6062 augmentWidthOrHeight( |
6793 |
6063 elem, |
6794 // Only read styles.position if the test has a chance to fail |
6064 name, |
6795 // to avoid forcing a reflow. |
6065 extra, |
6796 scrollboxSizeBuggy = !support.scrollboxSize() && |
|
6797 styles.position === "absolute", |
|
6798 |
|
6799 // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991) |
|
6800 boxSizingNeeded = scrollboxSizeBuggy || extra, |
|
6801 isBorderBox = boxSizingNeeded && |
6066 jQuery.css( elem, "boxSizing", false, styles ) === "border-box", |
6802 jQuery.css( elem, "boxSizing", false, styles ) === "border-box", |
6067 styles |
6803 subtract = extra ? |
6068 ) : 0 |
6804 boxModelAdjustment( |
6069 ); |
6805 elem, |
|
6806 dimension, |
|
6807 extra, |
|
6808 isBorderBox, |
|
6809 styles |
|
6810 ) : |
|
6811 0; |
|
6812 |
|
6813 // Account for unreliable border-box dimensions by comparing offset* to computed and |
|
6814 // faking a content-box to get border and padding (gh-3699) |
|
6815 if ( isBorderBox && scrollboxSizeBuggy ) { |
|
6816 subtract -= Math.ceil( |
|
6817 elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] - |
|
6818 parseFloat( styles[ dimension ] ) - |
|
6819 boxModelAdjustment( elem, dimension, "border", false, styles ) - |
|
6820 0.5 |
|
6821 ); |
|
6822 } |
|
6823 |
|
6824 // Convert to pixels if value adjustment is needed |
|
6825 if ( subtract && ( matches = rcssNum.exec( value ) ) && |
|
6826 ( matches[ 3 ] || "px" ) !== "px" ) { |
|
6827 |
|
6828 elem.style[ dimension ] = value; |
|
6829 value = jQuery.css( elem, dimension ); |
|
6830 } |
|
6831 |
|
6832 return setPositiveNumber( elem, value, subtract ); |
6070 } |
6833 } |
6071 }; |
6834 }; |
6072 }); |
6835 } ); |
6073 |
6836 |
6074 // Support: Android 2.3 |
6837 jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft, |
6075 jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight, |
|
6076 function( elem, computed ) { |
6838 function( elem, computed ) { |
6077 if ( computed ) { |
6839 if ( computed ) { |
6078 return jQuery.swap( elem, { "display": "inline-block" }, |
6840 return ( parseFloat( curCSS( elem, "marginLeft" ) ) || |
6079 curCSS, [ elem, "marginRight" ] ); |
6841 elem.getBoundingClientRect().left - |
|
6842 swap( elem, { marginLeft: 0 }, function() { |
|
6843 return elem.getBoundingClientRect().left; |
|
6844 } ) |
|
6845 ) + "px"; |
6080 } |
6846 } |
6081 } |
6847 } |
6082 ); |
6848 ); |
6083 |
6849 |
6084 // These hooks are used by animate to expand properties |
6850 // These hooks are used by animate to expand properties |
6085 jQuery.each({ |
6851 jQuery.each( { |
6086 margin: "", |
6852 margin: "", |
6087 padding: "", |
6853 padding: "", |
6088 border: "Width" |
6854 border: "Width" |
6089 }, function( prefix, suffix ) { |
6855 }, function( prefix, suffix ) { |
6090 jQuery.cssHooks[ prefix + suffix ] = { |
6856 jQuery.cssHooks[ prefix + suffix ] = { |
6091 expand: function( value ) { |
6857 expand: function( value ) { |
6092 var i = 0, |
6858 var i = 0, |
6093 expanded = {}, |
6859 expanded = {}, |
6094 |
6860 |
6095 // Assumes a single number if not a string |
6861 // Assumes a single number if not a string |
6096 parts = typeof value === "string" ? value.split(" ") : [ value ]; |
6862 parts = typeof value === "string" ? value.split( " " ) : [ value ]; |
6097 |
6863 |
6098 for ( ; i < 4; i++ ) { |
6864 for ( ; i < 4; i++ ) { |
6099 expanded[ prefix + cssExpand[ i ] + suffix ] = |
6865 expanded[ prefix + cssExpand[ i ] + suffix ] = |
6100 parts[ i ] || parts[ i - 2 ] || parts[ 0 ]; |
6866 parts[ i ] || parts[ i - 2 ] || parts[ 0 ]; |
6101 } |
6867 } |
6102 |
6868 |
6103 return expanded; |
6869 return expanded; |
6104 } |
6870 } |
6105 }; |
6871 }; |
6106 |
6872 |
6107 if ( !rmargin.test( prefix ) ) { |
6873 if ( prefix !== "margin" ) { |
6108 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber; |
6874 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber; |
6109 } |
6875 } |
6110 }); |
6876 } ); |
6111 |
6877 |
6112 jQuery.fn.extend({ |
6878 jQuery.fn.extend( { |
6113 css: function( name, value ) { |
6879 css: function( name, value ) { |
6114 return access( this, function( elem, name, value ) { |
6880 return access( this, function( elem, name, value ) { |
6115 var styles, len, |
6881 var styles, len, |
6116 map = {}, |
6882 map = {}, |
6117 i = 0; |
6883 i = 0; |
6118 |
6884 |
6119 if ( jQuery.isArray( name ) ) { |
6885 if ( Array.isArray( name ) ) { |
6120 styles = getStyles( elem ); |
6886 styles = getStyles( elem ); |
6121 len = name.length; |
6887 len = name.length; |
6122 |
6888 |
6123 for ( ; i < len; i++ ) { |
6889 for ( ; i < len; i++ ) { |
6124 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles ); |
6890 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles ); |
6386 } |
7100 } |
6387 }; |
7101 }; |
6388 } |
7102 } |
6389 hooks.unqueued++; |
7103 hooks.unqueued++; |
6390 |
7104 |
6391 anim.always(function() { |
7105 anim.always( function() { |
|
7106 |
6392 // Ensure the complete handler is called before this completes |
7107 // Ensure the complete handler is called before this completes |
6393 anim.always(function() { |
7108 anim.always( function() { |
6394 hooks.unqueued--; |
7109 hooks.unqueued--; |
6395 if ( !jQuery.queue( elem, "fx" ).length ) { |
7110 if ( !jQuery.queue( elem, "fx" ).length ) { |
6396 hooks.empty.fire(); |
7111 hooks.empty.fire(); |
6397 } |
7112 } |
6398 }); |
7113 } ); |
6399 }); |
7114 } ); |
6400 } |
7115 } |
6401 |
7116 |
6402 // Height/width overflow pass |
7117 // Detect show/hide animations |
6403 if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) { |
7118 for ( prop in props ) { |
6404 // Make sure that nothing sneaks out |
7119 value = props[ prop ]; |
6405 // Record all 3 overflow attributes because IE9-10 do not |
7120 if ( rfxtypes.test( value ) ) { |
6406 // change the overflow attribute when overflowX and |
7121 delete props[ prop ]; |
6407 // overflowY are set to the same value |
7122 toggle = toggle || value === "toggle"; |
|
7123 if ( value === ( hidden ? "hide" : "show" ) ) { |
|
7124 |
|
7125 // Pretend to be hidden if this is a "show" and |
|
7126 // there is still data from a stopped show/hide |
|
7127 if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) { |
|
7128 hidden = true; |
|
7129 |
|
7130 // Ignore all other no-op show/hide data |
|
7131 } else { |
|
7132 continue; |
|
7133 } |
|
7134 } |
|
7135 orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop ); |
|
7136 } |
|
7137 } |
|
7138 |
|
7139 // Bail out if this is a no-op like .hide().hide() |
|
7140 propTween = !jQuery.isEmptyObject( props ); |
|
7141 if ( !propTween && jQuery.isEmptyObject( orig ) ) { |
|
7142 return; |
|
7143 } |
|
7144 |
|
7145 // Restrict "overflow" and "display" styles during box animations |
|
7146 if ( isBox && elem.nodeType === 1 ) { |
|
7147 |
|
7148 // Support: IE <=9 - 11, Edge 12 - 15 |
|
7149 // Record all 3 overflow attributes because IE does not infer the shorthand |
|
7150 // from identically-valued overflowX and overflowY and Edge just mirrors |
|
7151 // the overflowX value there. |
6408 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ]; |
7152 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ]; |
6409 |
7153 |
6410 // Set display property to inline-block for height/width |
7154 // Identify a display type, preferring old show/hide data over the CSS cascade |
6411 // animations on inline elements that are having width/height animated |
7155 restoreDisplay = dataShow && dataShow.display; |
|
7156 if ( restoreDisplay == null ) { |
|
7157 restoreDisplay = dataPriv.get( elem, "display" ); |
|
7158 } |
6412 display = jQuery.css( elem, "display" ); |
7159 display = jQuery.css( elem, "display" ); |
6413 |
7160 if ( display === "none" ) { |
6414 // Test default display if display is currently "none" |
7161 if ( restoreDisplay ) { |
6415 checkDisplay = display === "none" ? |
7162 display = restoreDisplay; |
6416 data_priv.get( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display; |
7163 } else { |
6417 |
7164 |
6418 if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) { |
7165 // Get nonempty value(s) by temporarily forcing visibility |
6419 style.display = "inline-block"; |
7166 showHide( [ elem ], true ); |
|
7167 restoreDisplay = elem.style.display || restoreDisplay; |
|
7168 display = jQuery.css( elem, "display" ); |
|
7169 showHide( [ elem ] ); |
|
7170 } |
|
7171 } |
|
7172 |
|
7173 // Animate inline elements as inline-block |
|
7174 if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) { |
|
7175 if ( jQuery.css( elem, "float" ) === "none" ) { |
|
7176 |
|
7177 // Restore the original display value at the end of pure show/hide animations |
|
7178 if ( !propTween ) { |
|
7179 anim.done( function() { |
|
7180 style.display = restoreDisplay; |
|
7181 } ); |
|
7182 if ( restoreDisplay == null ) { |
|
7183 display = style.display; |
|
7184 restoreDisplay = display === "none" ? "" : display; |
|
7185 } |
|
7186 } |
|
7187 style.display = "inline-block"; |
|
7188 } |
6420 } |
7189 } |
6421 } |
7190 } |
6422 |
7191 |
6423 if ( opts.overflow ) { |
7192 if ( opts.overflow ) { |
6424 style.overflow = "hidden"; |
7193 style.overflow = "hidden"; |
6425 anim.always(function() { |
7194 anim.always( function() { |
6426 style.overflow = opts.overflow[ 0 ]; |
7195 style.overflow = opts.overflow[ 0 ]; |
6427 style.overflowX = opts.overflow[ 1 ]; |
7196 style.overflowX = opts.overflow[ 1 ]; |
6428 style.overflowY = opts.overflow[ 2 ]; |
7197 style.overflowY = opts.overflow[ 2 ]; |
6429 }); |
7198 } ); |
6430 } |
7199 } |
6431 |
7200 |
6432 // show/hide pass |
7201 // Implement show/hide animations |
6433 for ( prop in props ) { |
7202 propTween = false; |
6434 value = props[ prop ]; |
7203 for ( prop in orig ) { |
6435 if ( rfxtypes.exec( value ) ) { |
7204 |
6436 delete props[ prop ]; |
7205 // General show/hide setup for this element animation |
6437 toggle = toggle || value === "toggle"; |
7206 if ( !propTween ) { |
6438 if ( value === ( hidden ? "hide" : "show" ) ) { |
7207 if ( dataShow ) { |
6439 |
7208 if ( "hidden" in dataShow ) { |
6440 // If there is dataShow left over from a stopped hide or show and we are going to proceed with show, we should pretend to be hidden |
7209 hidden = dataShow.hidden; |
6441 if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) { |
7210 } |
6442 hidden = true; |
7211 } else { |
6443 } else { |
7212 dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } ); |
6444 continue; |
7213 } |
6445 } |
7214 |
6446 } |
7215 // Store hidden/visible for toggle so `.stop().toggle()` "reverses" |
6447 orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop ); |
7216 if ( toggle ) { |
6448 |
7217 dataShow.hidden = !hidden; |
6449 // Any non-fx value stops us from restoring the original display value |
7218 } |
6450 } else { |
7219 |
6451 display = undefined; |
7220 // Show elements before animating them |
6452 } |
7221 if ( hidden ) { |
6453 } |
7222 showHide( [ elem ], true ); |
6454 |
7223 } |
6455 if ( !jQuery.isEmptyObject( orig ) ) { |
7224 |
6456 if ( dataShow ) { |
7225 /* eslint-disable no-loop-func */ |
6457 if ( "hidden" in dataShow ) { |
7226 |
6458 hidden = dataShow.hidden; |
7227 anim.done( function() { |
6459 } |
7228 |
6460 } else { |
7229 /* eslint-enable no-loop-func */ |
6461 dataShow = data_priv.access( elem, "fxshow", {} ); |
7230 |
6462 } |
7231 // The final step of a "hide" animation is actually hiding the element |
6463 |
7232 if ( !hidden ) { |
6464 // Store state if its toggle - enables .stop().toggle() to "reverse" |
7233 showHide( [ elem ] ); |
6465 if ( toggle ) { |
7234 } |
6466 dataShow.hidden = !hidden; |
7235 dataPriv.remove( elem, "fxshow" ); |
6467 } |
7236 for ( prop in orig ) { |
6468 if ( hidden ) { |
7237 jQuery.style( elem, prop, orig[ prop ] ); |
6469 jQuery( elem ).show(); |
7238 } |
6470 } else { |
7239 } ); |
6471 anim.done(function() { |
7240 } |
6472 jQuery( elem ).hide(); |
7241 |
6473 }); |
7242 // Per-property setup |
6474 } |
7243 propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim ); |
6475 anim.done(function() { |
7244 if ( !( prop in dataShow ) ) { |
6476 var prop; |
7245 dataShow[ prop ] = propTween.start; |
6477 |
7246 if ( hidden ) { |
6478 data_priv.remove( elem, "fxshow" ); |
7247 propTween.end = propTween.start; |
6479 for ( prop in orig ) { |
7248 propTween.start = 0; |
6480 jQuery.style( elem, prop, orig[ prop ] ); |
7249 } |
6481 } |
7250 } |
6482 }); |
|
6483 for ( prop in orig ) { |
|
6484 tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim ); |
|
6485 |
|
6486 if ( !( prop in dataShow ) ) { |
|
6487 dataShow[ prop ] = tween.start; |
|
6488 if ( hidden ) { |
|
6489 tween.end = tween.start; |
|
6490 tween.start = prop === "width" || prop === "height" ? 1 : 0; |
|
6491 } |
|
6492 } |
|
6493 } |
|
6494 |
|
6495 // If this is a noop like .hide().hide(), restore an overwritten display value |
|
6496 } else if ( (display === "none" ? defaultDisplay( elem.nodeName ) : display) === "inline" ) { |
|
6497 style.display = display; |
|
6498 } |
7251 } |
6499 } |
7252 } |
6500 |
7253 |
6501 function propFilter( props, specialEasing ) { |
7254 function propFilter( props, specialEasing ) { |
6502 var index, name, easing, value, hooks; |
7255 var index, name, easing, value, hooks; |
6503 |
7256 |
6504 // camelCase, specialEasing and expand cssHook pass |
7257 // camelCase, specialEasing and expand cssHook pass |
6505 for ( index in props ) { |
7258 for ( index in props ) { |
6506 name = jQuery.camelCase( index ); |
7259 name = camelCase( index ); |
6507 easing = specialEasing[ name ]; |
7260 easing = specialEasing[ name ]; |
6508 value = props[ index ]; |
7261 value = props[ index ]; |
6509 if ( jQuery.isArray( value ) ) { |
7262 if ( Array.isArray( value ) ) { |
6510 easing = value[ 1 ]; |
7263 easing = value[ 1 ]; |
6511 value = props[ index ] = value[ 0 ]; |
7264 value = props[ index ] = value[ 0 ]; |
6512 } |
7265 } |
6513 |
7266 |
6514 if ( index !== name ) { |
7267 if ( index !== name ) { |
6585 animation.tweens.push( tween ); |
7350 animation.tweens.push( tween ); |
6586 return tween; |
7351 return tween; |
6587 }, |
7352 }, |
6588 stop: function( gotoEnd ) { |
7353 stop: function( gotoEnd ) { |
6589 var index = 0, |
7354 var index = 0, |
|
7355 |
6590 // If we are going to the end, we want to run all the tweens |
7356 // If we are going to the end, we want to run all the tweens |
6591 // otherwise we skip this part |
7357 // otherwise we skip this part |
6592 length = gotoEnd ? animation.tweens.length : 0; |
7358 length = gotoEnd ? animation.tweens.length : 0; |
6593 if ( stopped ) { |
7359 if ( stopped ) { |
6594 return this; |
7360 return this; |
6595 } |
7361 } |
6596 stopped = true; |
7362 stopped = true; |
6597 for ( ; index < length ; index++ ) { |
7363 for ( ; index < length; index++ ) { |
6598 animation.tweens[ index ].run( 1 ); |
7364 animation.tweens[ index ].run( 1 ); |
6599 } |
7365 } |
6600 |
7366 |
6601 // Resolve when we played the last frame; otherwise, reject |
7367 // Resolve when we played the last frame; otherwise, reject |
6602 if ( gotoEnd ) { |
7368 if ( gotoEnd ) { |
|
7369 deferred.notifyWith( elem, [ animation, 1, 0 ] ); |
6603 deferred.resolveWith( elem, [ animation, gotoEnd ] ); |
7370 deferred.resolveWith( elem, [ animation, gotoEnd ] ); |
6604 } else { |
7371 } else { |
6605 deferred.rejectWith( elem, [ animation, gotoEnd ] ); |
7372 deferred.rejectWith( elem, [ animation, gotoEnd ] ); |
6606 } |
7373 } |
6607 return this; |
7374 return this; |
6608 } |
7375 } |
6609 }), |
7376 } ), |
6610 props = animation.props; |
7377 props = animation.props; |
6611 |
7378 |
6612 propFilter( props, animation.opts.specialEasing ); |
7379 propFilter( props, animation.opts.specialEasing ); |
6613 |
7380 |
6614 for ( ; index < length ; index++ ) { |
7381 for ( ; index < length; index++ ) { |
6615 result = animationPrefilters[ index ].call( animation, elem, props, animation.opts ); |
7382 result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts ); |
6616 if ( result ) { |
7383 if ( result ) { |
|
7384 if ( isFunction( result.stop ) ) { |
|
7385 jQuery._queueHooks( animation.elem, animation.opts.queue ).stop = |
|
7386 result.stop.bind( result ); |
|
7387 } |
6617 return result; |
7388 return result; |
6618 } |
7389 } |
6619 } |
7390 } |
6620 |
7391 |
6621 jQuery.map( props, createTween, animation ); |
7392 jQuery.map( props, createTween, animation ); |
6622 |
7393 |
6623 if ( jQuery.isFunction( animation.opts.start ) ) { |
7394 if ( isFunction( animation.opts.start ) ) { |
6624 animation.opts.start.call( elem, animation ); |
7395 animation.opts.start.call( elem, animation ); |
6625 } |
7396 } |
|
7397 |
|
7398 // Attach callbacks from options |
|
7399 animation |
|
7400 .progress( animation.opts.progress ) |
|
7401 .done( animation.opts.done, animation.opts.complete ) |
|
7402 .fail( animation.opts.fail ) |
|
7403 .always( animation.opts.always ); |
6626 |
7404 |
6627 jQuery.fx.timer( |
7405 jQuery.fx.timer( |
6628 jQuery.extend( tick, { |
7406 jQuery.extend( tick, { |
6629 elem: elem, |
7407 elem: elem, |
6630 anim: animation, |
7408 anim: animation, |
6631 queue: animation.opts.queue |
7409 queue: animation.opts.queue |
6632 }) |
7410 } ) |
6633 ); |
7411 ); |
6634 |
7412 |
6635 // attach callbacks from options |
7413 return animation; |
6636 return animation.progress( animation.opts.progress ) |
|
6637 .done( animation.opts.done, animation.opts.complete ) |
|
6638 .fail( animation.opts.fail ) |
|
6639 .always( animation.opts.always ); |
|
6640 } |
7414 } |
6641 |
7415 |
6642 jQuery.Animation = jQuery.extend( Animation, { |
7416 jQuery.Animation = jQuery.extend( Animation, { |
6643 |
7417 |
|
7418 tweeners: { |
|
7419 "*": [ function( prop, value ) { |
|
7420 var tween = this.createTween( prop, value ); |
|
7421 adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween ); |
|
7422 return tween; |
|
7423 } ] |
|
7424 }, |
|
7425 |
6644 tweener: function( props, callback ) { |
7426 tweener: function( props, callback ) { |
6645 if ( jQuery.isFunction( props ) ) { |
7427 if ( isFunction( props ) ) { |
6646 callback = props; |
7428 callback = props; |
6647 props = [ "*" ]; |
7429 props = [ "*" ]; |
6648 } else { |
7430 } else { |
6649 props = props.split(" "); |
7431 props = props.match( rnothtmlwhite ); |
6650 } |
7432 } |
6651 |
7433 |
6652 var prop, |
7434 var prop, |
6653 index = 0, |
7435 index = 0, |
6654 length = props.length; |
7436 length = props.length; |
6655 |
7437 |
6656 for ( ; index < length ; index++ ) { |
7438 for ( ; index < length; index++ ) { |
6657 prop = props[ index ]; |
7439 prop = props[ index ]; |
6658 tweeners[ prop ] = tweeners[ prop ] || []; |
7440 Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || []; |
6659 tweeners[ prop ].unshift( callback ); |
7441 Animation.tweeners[ prop ].unshift( callback ); |
6660 } |
7442 } |
6661 }, |
7443 }, |
|
7444 |
|
7445 prefilters: [ defaultPrefilter ], |
6662 |
7446 |
6663 prefilter: function( callback, prepend ) { |
7447 prefilter: function( callback, prepend ) { |
6664 if ( prepend ) { |
7448 if ( prepend ) { |
6665 animationPrefilters.unshift( callback ); |
7449 Animation.prefilters.unshift( callback ); |
6666 } else { |
7450 } else { |
6667 animationPrefilters.push( callback ); |
7451 Animation.prefilters.push( callback ); |
6668 } |
7452 } |
6669 } |
7453 } |
6670 }); |
7454 } ); |
6671 |
7455 |
6672 jQuery.speed = function( speed, easing, fn ) { |
7456 jQuery.speed = function( speed, easing, fn ) { |
6673 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : { |
7457 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : { |
6674 complete: fn || !fn && easing || |
7458 complete: fn || !fn && easing || |
6675 jQuery.isFunction( speed ) && speed, |
7459 isFunction( speed ) && speed, |
6676 duration: speed, |
7460 duration: speed, |
6677 easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing |
7461 easing: fn && easing || easing && !isFunction( easing ) && easing |
6678 }; |
7462 }; |
6679 |
7463 |
6680 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration : |
7464 // Go to the end state if fx are off |
6681 opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default; |
7465 if ( jQuery.fx.off ) { |
|
7466 opt.duration = 0; |
|
7467 |
|
7468 } else { |
|
7469 if ( typeof opt.duration !== "number" ) { |
|
7470 if ( opt.duration in jQuery.fx.speeds ) { |
|
7471 opt.duration = jQuery.fx.speeds[ opt.duration ]; |
|
7472 |
|
7473 } else { |
|
7474 opt.duration = jQuery.fx.speeds._default; |
|
7475 } |
|
7476 } |
|
7477 } |
6682 |
7478 |
6683 // Normalize opt.queue - true/undefined/null -> "fx" |
7479 // Normalize opt.queue - true/undefined/null -> "fx" |
6684 if ( opt.queue == null || opt.queue === true ) { |
7480 if ( opt.queue == null || opt.queue === true ) { |
6685 opt.queue = "fx"; |
7481 opt.queue = "fx"; |
6686 } |
7482 } |
6687 |
7483 |
6688 // Queueing |
7484 // Queueing |
6689 opt.old = opt.complete; |
7485 opt.old = opt.complete; |
6690 |
7486 |
6691 opt.complete = function() { |
7487 opt.complete = function() { |
6692 if ( jQuery.isFunction( opt.old ) ) { |
7488 if ( isFunction( opt.old ) ) { |
6693 opt.old.call( this ); |
7489 opt.old.call( this ); |
6694 } |
7490 } |
6695 |
7491 |
6696 if ( opt.queue ) { |
7492 if ( opt.queue ) { |
6697 jQuery.dequeue( this, opt.queue ); |
7493 jQuery.dequeue( this, opt.queue ); |
6866 fxNow = undefined; |
7666 fxNow = undefined; |
6867 }; |
7667 }; |
6868 |
7668 |
6869 jQuery.fx.timer = function( timer ) { |
7669 jQuery.fx.timer = function( timer ) { |
6870 jQuery.timers.push( timer ); |
7670 jQuery.timers.push( timer ); |
6871 if ( timer() ) { |
7671 jQuery.fx.start(); |
6872 jQuery.fx.start(); |
|
6873 } else { |
|
6874 jQuery.timers.pop(); |
|
6875 } |
|
6876 }; |
7672 }; |
6877 |
7673 |
6878 jQuery.fx.interval = 13; |
7674 jQuery.fx.interval = 13; |
6879 |
|
6880 jQuery.fx.start = function() { |
7675 jQuery.fx.start = function() { |
6881 if ( !timerId ) { |
7676 if ( inProgress ) { |
6882 timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval ); |
7677 return; |
6883 } |
7678 } |
|
7679 |
|
7680 inProgress = true; |
|
7681 schedule(); |
6884 }; |
7682 }; |
6885 |
7683 |
6886 jQuery.fx.stop = function() { |
7684 jQuery.fx.stop = function() { |
6887 clearInterval( timerId ); |
7685 inProgress = null; |
6888 timerId = null; |
|
6889 }; |
7686 }; |
6890 |
7687 |
6891 jQuery.fx.speeds = { |
7688 jQuery.fx.speeds = { |
6892 slow: 600, |
7689 slow: 600, |
6893 fast: 200, |
7690 fast: 200, |
|
7691 |
6894 // Default speed |
7692 // Default speed |
6895 _default: 400 |
7693 _default: 400 |
6896 }; |
7694 }; |
6897 |
7695 |
6898 |
7696 |
6899 // Based off of the plugin by Clint Helfers, with permission. |
7697 // Based off of the plugin by Clint Helfers, with permission. |
6900 // http://blindsignals.com/index.php/2009/07/jquery-delay/ |
7698 // https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/ |
6901 jQuery.fn.delay = function( time, type ) { |
7699 jQuery.fn.delay = function( time, type ) { |
6902 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; |
7700 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; |
6903 type = type || "fx"; |
7701 type = type || "fx"; |
6904 |
7702 |
6905 return this.queue( type, function( next, hooks ) { |
7703 return this.queue( type, function( next, hooks ) { |
6906 var timeout = setTimeout( next, time ); |
7704 var timeout = window.setTimeout( next, time ); |
6907 hooks.stop = function() { |
7705 hooks.stop = function() { |
6908 clearTimeout( timeout ); |
7706 window.clearTimeout( timeout ); |
6909 }; |
7707 }; |
6910 }); |
7708 } ); |
6911 }; |
7709 }; |
6912 |
7710 |
6913 |
7711 |
6914 (function() { |
7712 ( function() { |
6915 var input = document.createElement( "input" ), |
7713 var input = document.createElement( "input" ), |
6916 select = document.createElement( "select" ), |
7714 select = document.createElement( "select" ), |
6917 opt = select.appendChild( document.createElement( "option" ) ); |
7715 opt = select.appendChild( document.createElement( "option" ) ); |
6918 |
7716 |
6919 input.type = "checkbox"; |
7717 input.type = "checkbox"; |
6920 |
7718 |
6921 // Support: iOS<=5.1, Android<=4.2+ |
7719 // Support: Android <=4.3 only |
6922 // Default value for a checkbox should be "on" |
7720 // Default value for a checkbox should be "on" |
6923 support.checkOn = input.value !== ""; |
7721 support.checkOn = input.value !== ""; |
6924 |
7722 |
6925 // Support: IE<=11+ |
7723 // Support: IE <=11 only |
6926 // Must access selectedIndex to make default options select |
7724 // Must access selectedIndex to make default options select |
6927 support.optSelected = opt.selected; |
7725 support.optSelected = opt.selected; |
6928 |
7726 |
6929 // Support: Android<=2.3 |
7727 // Support: IE <=11 only |
6930 // Options inside disabled selects are incorrectly marked as disabled |
|
6931 select.disabled = true; |
|
6932 support.optDisabled = !opt.disabled; |
|
6933 |
|
6934 // Support: IE<=11+ |
|
6935 // An input loses its value after becoming a radio |
7728 // An input loses its value after becoming a radio |
6936 input = document.createElement( "input" ); |
7729 input = document.createElement( "input" ); |
6937 input.value = "t"; |
7730 input.value = "t"; |
6938 input.type = "radio"; |
7731 input.type = "radio"; |
6939 support.radioValue = input.value === "t"; |
7732 support.radioValue = input.value === "t"; |
6940 })(); |
7733 } )(); |
6941 |
7734 |
6942 |
7735 |
6943 var nodeHook, boolHook, |
7736 var boolHook, |
6944 attrHandle = jQuery.expr.attrHandle; |
7737 attrHandle = jQuery.expr.attrHandle; |
6945 |
7738 |
6946 jQuery.fn.extend({ |
7739 jQuery.fn.extend( { |
6947 attr: function( name, value ) { |
7740 attr: function( name, value ) { |
6948 return access( this, jQuery.attr, name, value, arguments.length > 1 ); |
7741 return access( this, jQuery.attr, name, value, arguments.length > 1 ); |
6949 }, |
7742 }, |
6950 |
7743 |
6951 removeAttr: function( name ) { |
7744 removeAttr: function( name ) { |
6952 return this.each(function() { |
7745 return this.each( function() { |
6953 jQuery.removeAttr( this, name ); |
7746 jQuery.removeAttr( this, name ); |
6954 }); |
7747 } ); |
6955 } |
7748 } |
6956 }); |
7749 } ); |
6957 |
7750 |
6958 jQuery.extend({ |
7751 jQuery.extend( { |
6959 attr: function( elem, name, value ) { |
7752 attr: function( elem, name, value ) { |
6960 var hooks, ret, |
7753 var ret, hooks, |
6961 nType = elem.nodeType; |
7754 nType = elem.nodeType; |
6962 |
7755 |
6963 // don't get/set attributes on text, comment and attribute nodes |
7756 // Don't get/set attributes on text, comment and attribute nodes |
6964 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { |
7757 if ( nType === 3 || nType === 8 || nType === 2 ) { |
6965 return; |
7758 return; |
6966 } |
7759 } |
6967 |
7760 |
6968 // Fallback to prop when attributes are not supported |
7761 // Fallback to prop when attributes are not supported |
6969 if ( typeof elem.getAttribute === strundefined ) { |
7762 if ( typeof elem.getAttribute === "undefined" ) { |
6970 return jQuery.prop( elem, name, value ); |
7763 return jQuery.prop( elem, name, value ); |
6971 } |
7764 } |
6972 |
7765 |
6973 // All attributes are lowercase |
7766 // Attribute hooks are determined by the lowercase version |
6974 // Grab necessary hook if one is defined |
7767 // Grab necessary hook if one is defined |
6975 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { |
7768 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { |
6976 name = name.toLowerCase(); |
7769 hooks = jQuery.attrHooks[ name.toLowerCase() ] || |
6977 hooks = jQuery.attrHooks[ name ] || |
7770 ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined ); |
6978 ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook ); |
|
6979 } |
7771 } |
6980 |
7772 |
6981 if ( value !== undefined ) { |
7773 if ( value !== undefined ) { |
6982 |
|
6983 if ( value === null ) { |
7774 if ( value === null ) { |
6984 jQuery.removeAttr( elem, name ); |
7775 jQuery.removeAttr( elem, name ); |
6985 |
7776 return; |
6986 } else if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { |
7777 } |
|
7778 |
|
7779 if ( hooks && "set" in hooks && |
|
7780 ( ret = hooks.set( elem, value, name ) ) !== undefined ) { |
6987 return ret; |
7781 return ret; |
6988 |
7782 } |
6989 } else { |
7783 |
6990 elem.setAttribute( name, value + "" ); |
7784 elem.setAttribute( name, value + "" ); |
6991 return value; |
7785 return value; |
6992 } |
7786 } |
6993 |
7787 |
6994 } else if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) { |
7788 if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) { |
6995 return ret; |
7789 return ret; |
6996 |
7790 } |
6997 } else { |
7791 |
6998 ret = jQuery.find.attr( elem, name ); |
7792 ret = jQuery.find.attr( elem, name ); |
6999 |
7793 |
7000 // Non-existent attributes return null, we normalize to undefined |
7794 // Non-existent attributes return null, we normalize to undefined |
7001 return ret == null ? |
7795 return ret == null ? undefined : ret; |
7002 undefined : |
|
7003 ret; |
|
7004 } |
|
7005 }, |
|
7006 |
|
7007 removeAttr: function( elem, value ) { |
|
7008 var name, propName, |
|
7009 i = 0, |
|
7010 attrNames = value && value.match( rnotwhite ); |
|
7011 |
|
7012 if ( attrNames && elem.nodeType === 1 ) { |
|
7013 while ( (name = attrNames[i++]) ) { |
|
7014 propName = jQuery.propFix[ name ] || name; |
|
7015 |
|
7016 // Boolean attributes get special treatment (#10870) |
|
7017 if ( jQuery.expr.match.bool.test( name ) ) { |
|
7018 // Set corresponding property to false |
|
7019 elem[ propName ] = false; |
|
7020 } |
|
7021 |
|
7022 elem.removeAttribute( name ); |
|
7023 } |
|
7024 } |
|
7025 }, |
7796 }, |
7026 |
7797 |
7027 attrHooks: { |
7798 attrHooks: { |
7028 type: { |
7799 type: { |
7029 set: function( elem, value ) { |
7800 set: function( elem, value ) { |
7030 if ( !support.radioValue && value === "radio" && |
7801 if ( !support.radioValue && value === "radio" && |
7031 jQuery.nodeName( elem, "input" ) ) { |
7802 nodeName( elem, "input" ) ) { |
7032 var val = elem.value; |
7803 var val = elem.value; |
7033 elem.setAttribute( "type", value ); |
7804 elem.setAttribute( "type", value ); |
7034 if ( val ) { |
7805 if ( val ) { |
7035 elem.value = val; |
7806 elem.value = val; |
7036 } |
7807 } |
7037 return value; |
7808 return value; |
7038 } |
7809 } |
7039 } |
7810 } |
7040 } |
7811 } |
7041 } |
7812 }, |
7042 }); |
7813 |
|
7814 removeAttr: function( elem, value ) { |
|
7815 var name, |
|
7816 i = 0, |
|
7817 |
|
7818 // Attribute names can contain non-HTML whitespace characters |
|
7819 // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2 |
|
7820 attrNames = value && value.match( rnothtmlwhite ); |
|
7821 |
|
7822 if ( attrNames && elem.nodeType === 1 ) { |
|
7823 while ( ( name = attrNames[ i++ ] ) ) { |
|
7824 elem.removeAttribute( name ); |
|
7825 } |
|
7826 } |
|
7827 } |
|
7828 } ); |
7043 |
7829 |
7044 // Hooks for boolean attributes |
7830 // Hooks for boolean attributes |
7045 boolHook = { |
7831 boolHook = { |
7046 set: function( elem, value, name ) { |
7832 set: function( elem, value, name ) { |
7047 if ( value === false ) { |
7833 if ( value === false ) { |
|
7834 |
7048 // Remove boolean attributes when set to false |
7835 // Remove boolean attributes when set to false |
7049 jQuery.removeAttr( elem, name ); |
7836 jQuery.removeAttr( elem, name ); |
7050 } else { |
7837 } else { |
7051 elem.setAttribute( name, name ); |
7838 elem.setAttribute( name, name ); |
7052 } |
7839 } |
7053 return name; |
7840 return name; |
7054 } |
7841 } |
7055 }; |
7842 }; |
|
7843 |
7056 jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) { |
7844 jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) { |
7057 var getter = attrHandle[ name ] || jQuery.find.attr; |
7845 var getter = attrHandle[ name ] || jQuery.find.attr; |
7058 |
7846 |
7059 attrHandle[ name ] = function( elem, name, isXML ) { |
7847 attrHandle[ name ] = function( elem, name, isXML ) { |
7060 var ret, handle; |
7848 var ret, handle, |
|
7849 lowercaseName = name.toLowerCase(); |
|
7850 |
7061 if ( !isXML ) { |
7851 if ( !isXML ) { |
|
7852 |
7062 // Avoid an infinite loop by temporarily removing this function from the getter |
7853 // Avoid an infinite loop by temporarily removing this function from the getter |
7063 handle = attrHandle[ name ]; |
7854 handle = attrHandle[ lowercaseName ]; |
7064 attrHandle[ name ] = ret; |
7855 attrHandle[ lowercaseName ] = ret; |
7065 ret = getter( elem, name, isXML ) != null ? |
7856 ret = getter( elem, name, isXML ) != null ? |
7066 name.toLowerCase() : |
7857 lowercaseName : |
7067 null; |
7858 null; |
7068 attrHandle[ name ] = handle; |
7859 attrHandle[ lowercaseName ] = handle; |
7069 } |
7860 } |
7070 return ret; |
7861 return ret; |
7071 }; |
7862 }; |
7072 }); |
7863 } ); |
7073 |
7864 |
7074 |
7865 |
7075 |
7866 |
7076 |
7867 |
7077 var rfocusable = /^(?:input|select|textarea|button)$/i; |
7868 var rfocusable = /^(?:input|select|textarea|button)$/i, |
7078 |
7869 rclickable = /^(?:a|area)$/i; |
7079 jQuery.fn.extend({ |
7870 |
|
7871 jQuery.fn.extend( { |
7080 prop: function( name, value ) { |
7872 prop: function( name, value ) { |
7081 return access( this, jQuery.prop, name, value, arguments.length > 1 ); |
7873 return access( this, jQuery.prop, name, value, arguments.length > 1 ); |
7082 }, |
7874 }, |
7083 |
7875 |
7084 removeProp: function( name ) { |
7876 removeProp: function( name ) { |
7085 return this.each(function() { |
7877 return this.each( function() { |
7086 delete this[ jQuery.propFix[ name ] || name ]; |
7878 delete this[ jQuery.propFix[ name ] || name ]; |
7087 }); |
7879 } ); |
7088 } |
7880 } |
7089 }); |
7881 } ); |
7090 |
7882 |
7091 jQuery.extend({ |
7883 jQuery.extend( { |
|
7884 prop: function( elem, name, value ) { |
|
7885 var ret, hooks, |
|
7886 nType = elem.nodeType; |
|
7887 |
|
7888 // Don't get/set properties on text, comment and attribute nodes |
|
7889 if ( nType === 3 || nType === 8 || nType === 2 ) { |
|
7890 return; |
|
7891 } |
|
7892 |
|
7893 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { |
|
7894 |
|
7895 // Fix name and attach hooks |
|
7896 name = jQuery.propFix[ name ] || name; |
|
7897 hooks = jQuery.propHooks[ name ]; |
|
7898 } |
|
7899 |
|
7900 if ( value !== undefined ) { |
|
7901 if ( hooks && "set" in hooks && |
|
7902 ( ret = hooks.set( elem, value, name ) ) !== undefined ) { |
|
7903 return ret; |
|
7904 } |
|
7905 |
|
7906 return ( elem[ name ] = value ); |
|
7907 } |
|
7908 |
|
7909 if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) { |
|
7910 return ret; |
|
7911 } |
|
7912 |
|
7913 return elem[ name ]; |
|
7914 }, |
|
7915 |
|
7916 propHooks: { |
|
7917 tabIndex: { |
|
7918 get: function( elem ) { |
|
7919 |
|
7920 // Support: IE <=9 - 11 only |
|
7921 // elem.tabIndex doesn't always return the |
|
7922 // correct value when it hasn't been explicitly set |
|
7923 // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ |
|
7924 // Use proper attribute retrieval(#12072) |
|
7925 var tabindex = jQuery.find.attr( elem, "tabindex" ); |
|
7926 |
|
7927 if ( tabindex ) { |
|
7928 return parseInt( tabindex, 10 ); |
|
7929 } |
|
7930 |
|
7931 if ( |
|
7932 rfocusable.test( elem.nodeName ) || |
|
7933 rclickable.test( elem.nodeName ) && |
|
7934 elem.href |
|
7935 ) { |
|
7936 return 0; |
|
7937 } |
|
7938 |
|
7939 return -1; |
|
7940 } |
|
7941 } |
|
7942 }, |
|
7943 |
7092 propFix: { |
7944 propFix: { |
7093 "for": "htmlFor", |
7945 "for": "htmlFor", |
7094 "class": "className" |
7946 "class": "className" |
7095 }, |
7947 } |
7096 |
7948 } ); |
7097 prop: function( elem, name, value ) { |
7949 |
7098 var ret, hooks, notxml, |
7950 // Support: IE <=11 only |
7099 nType = elem.nodeType; |
7951 // Accessing the selectedIndex property |
7100 |
7952 // forces the browser to respect setting selected |
7101 // Don't get/set properties on text, comment and attribute nodes |
7953 // on the option |
7102 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { |
7954 // The getter ensures a default option is selected |
7103 return; |
7955 // when in an optgroup |
7104 } |
7956 // eslint rule "no-unused-expressions" is disabled for this code |
7105 |
7957 // since it considers such accessions noop |
7106 notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); |
|
7107 |
|
7108 if ( notxml ) { |
|
7109 // Fix name and attach hooks |
|
7110 name = jQuery.propFix[ name ] || name; |
|
7111 hooks = jQuery.propHooks[ name ]; |
|
7112 } |
|
7113 |
|
7114 if ( value !== undefined ) { |
|
7115 return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ? |
|
7116 ret : |
|
7117 ( elem[ name ] = value ); |
|
7118 |
|
7119 } else { |
|
7120 return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ? |
|
7121 ret : |
|
7122 elem[ name ]; |
|
7123 } |
|
7124 }, |
|
7125 |
|
7126 propHooks: { |
|
7127 tabIndex: { |
|
7128 get: function( elem ) { |
|
7129 return elem.hasAttribute( "tabindex" ) || rfocusable.test( elem.nodeName ) || elem.href ? |
|
7130 elem.tabIndex : |
|
7131 -1; |
|
7132 } |
|
7133 } |
|
7134 } |
|
7135 }); |
|
7136 |
|
7137 if ( !support.optSelected ) { |
7958 if ( !support.optSelected ) { |
7138 jQuery.propHooks.selected = { |
7959 jQuery.propHooks.selected = { |
7139 get: function( elem ) { |
7960 get: function( elem ) { |
|
7961 |
|
7962 /* eslint no-unused-expressions: "off" */ |
|
7963 |
7140 var parent = elem.parentNode; |
7964 var parent = elem.parentNode; |
7141 if ( parent && parent.parentNode ) { |
7965 if ( parent && parent.parentNode ) { |
7142 parent.parentNode.selectedIndex; |
7966 parent.parentNode.selectedIndex; |
7143 } |
7967 } |
7144 return null; |
7968 return null; |
|
7969 }, |
|
7970 set: function( elem ) { |
|
7971 |
|
7972 /* eslint no-unused-expressions: "off" */ |
|
7973 |
|
7974 var parent = elem.parentNode; |
|
7975 if ( parent ) { |
|
7976 parent.selectedIndex; |
|
7977 |
|
7978 if ( parent.parentNode ) { |
|
7979 parent.parentNode.selectedIndex; |
|
7980 } |
|
7981 } |
7145 } |
7982 } |
7146 }; |
7983 }; |
7147 } |
7984 } |
7148 |
7985 |
7149 jQuery.each([ |
7986 jQuery.each( [ |
7150 "tabIndex", |
7987 "tabIndex", |
7151 "readOnly", |
7988 "readOnly", |
7152 "maxLength", |
7989 "maxLength", |
7153 "cellSpacing", |
7990 "cellSpacing", |
7154 "cellPadding", |
7991 "cellPadding", |
7157 "useMap", |
7994 "useMap", |
7158 "frameBorder", |
7995 "frameBorder", |
7159 "contentEditable" |
7996 "contentEditable" |
7160 ], function() { |
7997 ], function() { |
7161 jQuery.propFix[ this.toLowerCase() ] = this; |
7998 jQuery.propFix[ this.toLowerCase() ] = this; |
7162 }); |
7999 } ); |
7163 |
8000 |
7164 |
8001 |
7165 |
8002 |
7166 |
8003 |
7167 var rclass = /[\t\r\n\f]/g; |
8004 // Strip and collapse whitespace according to HTML spec |
7168 |
8005 // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace |
7169 jQuery.fn.extend({ |
8006 function stripAndCollapse( value ) { |
|
8007 var tokens = value.match( rnothtmlwhite ) || []; |
|
8008 return tokens.join( " " ); |
|
8009 } |
|
8010 |
|
8011 |
|
8012 function getClass( elem ) { |
|
8013 return elem.getAttribute && elem.getAttribute( "class" ) || ""; |
|
8014 } |
|
8015 |
|
8016 function classesToArray( value ) { |
|
8017 if ( Array.isArray( value ) ) { |
|
8018 return value; |
|
8019 } |
|
8020 if ( typeof value === "string" ) { |
|
8021 return value.match( rnothtmlwhite ) || []; |
|
8022 } |
|
8023 return []; |
|
8024 } |
|
8025 |
|
8026 jQuery.fn.extend( { |
7170 addClass: function( value ) { |
8027 addClass: function( value ) { |
7171 var classes, elem, cur, clazz, j, finalValue, |
8028 var classes, elem, cur, curValue, clazz, j, finalValue, |
7172 proceed = typeof value === "string" && value, |
8029 i = 0; |
7173 i = 0, |
8030 |
7174 len = this.length; |
8031 if ( isFunction( value ) ) { |
7175 |
8032 return this.each( function( j ) { |
7176 if ( jQuery.isFunction( value ) ) { |
8033 jQuery( this ).addClass( value.call( this, j, getClass( this ) ) ); |
7177 return this.each(function( j ) { |
8034 } ); |
7178 jQuery( this ).addClass( value.call( this, j, this.className ) ); |
8035 } |
7179 }); |
8036 |
7180 } |
8037 classes = classesToArray( value ); |
7181 |
8038 |
7182 if ( proceed ) { |
8039 if ( classes.length ) { |
7183 // The disjunction here is for better compressibility (see removeClass) |
8040 while ( ( elem = this[ i++ ] ) ) { |
7184 classes = ( value || "" ).match( rnotwhite ) || []; |
8041 curValue = getClass( elem ); |
7185 |
8042 cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " ); |
7186 for ( ; i < len; i++ ) { |
|
7187 elem = this[ i ]; |
|
7188 cur = elem.nodeType === 1 && ( elem.className ? |
|
7189 ( " " + elem.className + " " ).replace( rclass, " " ) : |
|
7190 " " |
|
7191 ); |
|
7192 |
8043 |
7193 if ( cur ) { |
8044 if ( cur ) { |
7194 j = 0; |
8045 j = 0; |
7195 while ( (clazz = classes[j++]) ) { |
8046 while ( ( clazz = classes[ j++ ] ) ) { |
7196 if ( cur.indexOf( " " + clazz + " " ) < 0 ) { |
8047 if ( cur.indexOf( " " + clazz + " " ) < 0 ) { |
7197 cur += clazz + " "; |
8048 cur += clazz + " "; |
7198 } |
8049 } |
7199 } |
8050 } |
7200 |
8051 |
7201 // only assign if different to avoid unneeded rendering. |
8052 // Only assign if different to avoid unneeded rendering. |
7202 finalValue = jQuery.trim( cur ); |
8053 finalValue = stripAndCollapse( cur ); |
7203 if ( elem.className !== finalValue ) { |
8054 if ( curValue !== finalValue ) { |
7204 elem.className = finalValue; |
8055 elem.setAttribute( "class", finalValue ); |
7205 } |
8056 } |
7206 } |
8057 } |
7207 } |
8058 } |
7208 } |
8059 } |
7209 |
8060 |
7210 return this; |
8061 return this; |
7211 }, |
8062 }, |
7212 |
8063 |
7213 removeClass: function( value ) { |
8064 removeClass: function( value ) { |
7214 var classes, elem, cur, clazz, j, finalValue, |
8065 var classes, elem, cur, curValue, clazz, j, finalValue, |
7215 proceed = arguments.length === 0 || typeof value === "string" && value, |
8066 i = 0; |
7216 i = 0, |
8067 |
7217 len = this.length; |
8068 if ( isFunction( value ) ) { |
7218 |
8069 return this.each( function( j ) { |
7219 if ( jQuery.isFunction( value ) ) { |
8070 jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) ); |
7220 return this.each(function( j ) { |
8071 } ); |
7221 jQuery( this ).removeClass( value.call( this, j, this.className ) ); |
8072 } |
7222 }); |
8073 |
7223 } |
8074 if ( !arguments.length ) { |
7224 if ( proceed ) { |
8075 return this.attr( "class", "" ); |
7225 classes = ( value || "" ).match( rnotwhite ) || []; |
8076 } |
7226 |
8077 |
7227 for ( ; i < len; i++ ) { |
8078 classes = classesToArray( value ); |
7228 elem = this[ i ]; |
8079 |
|
8080 if ( classes.length ) { |
|
8081 while ( ( elem = this[ i++ ] ) ) { |
|
8082 curValue = getClass( elem ); |
|
8083 |
7229 // This expression is here for better compressibility (see addClass) |
8084 // This expression is here for better compressibility (see addClass) |
7230 cur = elem.nodeType === 1 && ( elem.className ? |
8085 cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " ); |
7231 ( " " + elem.className + " " ).replace( rclass, " " ) : |
|
7232 "" |
|
7233 ); |
|
7234 |
8086 |
7235 if ( cur ) { |
8087 if ( cur ) { |
7236 j = 0; |
8088 j = 0; |
7237 while ( (clazz = classes[j++]) ) { |
8089 while ( ( clazz = classes[ j++ ] ) ) { |
|
8090 |
7238 // Remove *all* instances |
8091 // Remove *all* instances |
7239 while ( cur.indexOf( " " + clazz + " " ) >= 0 ) { |
8092 while ( cur.indexOf( " " + clazz + " " ) > -1 ) { |
7240 cur = cur.replace( " " + clazz + " ", " " ); |
8093 cur = cur.replace( " " + clazz + " ", " " ); |
7241 } |
8094 } |
7242 } |
8095 } |
7243 |
8096 |
7244 // Only assign if different to avoid unneeded rendering. |
8097 // Only assign if different to avoid unneeded rendering. |
7245 finalValue = value ? jQuery.trim( cur ) : ""; |
8098 finalValue = stripAndCollapse( cur ); |
7246 if ( elem.className !== finalValue ) { |
8099 if ( curValue !== finalValue ) { |
7247 elem.className = finalValue; |
8100 elem.setAttribute( "class", finalValue ); |
7248 } |
8101 } |
7249 } |
8102 } |
7250 } |
8103 } |
7251 } |
8104 } |
7252 |
8105 |
7253 return this; |
8106 return this; |
7254 }, |
8107 }, |
7255 |
8108 |
7256 toggleClass: function( value, stateVal ) { |
8109 toggleClass: function( value, stateVal ) { |
7257 var type = typeof value; |
8110 var type = typeof value, |
7258 |
8111 isValidValue = type === "string" || Array.isArray( value ); |
7259 if ( typeof stateVal === "boolean" && type === "string" ) { |
8112 |
|
8113 if ( typeof stateVal === "boolean" && isValidValue ) { |
7260 return stateVal ? this.addClass( value ) : this.removeClass( value ); |
8114 return stateVal ? this.addClass( value ) : this.removeClass( value ); |
7261 } |
8115 } |
7262 |
8116 |
7263 if ( jQuery.isFunction( value ) ) { |
8117 if ( isFunction( value ) ) { |
7264 return this.each(function( i ) { |
8118 return this.each( function( i ) { |
7265 jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal ); |
8119 jQuery( this ).toggleClass( |
7266 }); |
8120 value.call( this, i, getClass( this ), stateVal ), |
7267 } |
8121 stateVal |
7268 |
8122 ); |
7269 return this.each(function() { |
8123 } ); |
7270 if ( type === "string" ) { |
8124 } |
|
8125 |
|
8126 return this.each( function() { |
|
8127 var className, i, self, classNames; |
|
8128 |
|
8129 if ( isValidValue ) { |
|
8130 |
7271 // Toggle individual class names |
8131 // Toggle individual class names |
7272 var className, |
8132 i = 0; |
7273 i = 0, |
8133 self = jQuery( this ); |
7274 self = jQuery( this ), |
8134 classNames = classesToArray( value ); |
7275 classNames = value.match( rnotwhite ) || []; |
8135 |
7276 |
8136 while ( ( className = classNames[ i++ ] ) ) { |
7277 while ( (className = classNames[ i++ ]) ) { |
8137 |
7278 // Check each className given, space separated list |
8138 // Check each className given, space separated list |
7279 if ( self.hasClass( className ) ) { |
8139 if ( self.hasClass( className ) ) { |
7280 self.removeClass( className ); |
8140 self.removeClass( className ); |
7281 } else { |
8141 } else { |
7282 self.addClass( className ); |
8142 self.addClass( className ); |
7283 } |
8143 } |
7284 } |
8144 } |
7285 |
8145 |
7286 // Toggle whole class name |
8146 // Toggle whole class name |
7287 } else if ( type === strundefined || type === "boolean" ) { |
8147 } else if ( value === undefined || type === "boolean" ) { |
7288 if ( this.className ) { |
8148 className = getClass( this ); |
7289 // store className if set |
8149 if ( className ) { |
7290 data_priv.set( this, "__className__", this.className ); |
8150 |
|
8151 // Store className if set |
|
8152 dataPriv.set( this, "__className__", className ); |
7291 } |
8153 } |
7292 |
8154 |
7293 // If the element has a class name or if we're passed `false`, |
8155 // If the element has a class name or if we're passed `false`, |
7294 // then remove the whole classname (if there was one, the above saved it). |
8156 // then remove the whole classname (if there was one, the above saved it). |
7295 // Otherwise bring back whatever was previously saved (if anything), |
8157 // Otherwise bring back whatever was previously saved (if anything), |
7296 // falling back to the empty string if nothing was stored. |
8158 // falling back to the empty string if nothing was stored. |
7297 this.className = this.className || value === false ? "" : data_priv.get( this, "__className__" ) || ""; |
8159 if ( this.setAttribute ) { |
7298 } |
8160 this.setAttribute( "class", |
7299 }); |
8161 className || value === false ? |
|
8162 "" : |
|
8163 dataPriv.get( this, "__className__" ) || "" |
|
8164 ); |
|
8165 } |
|
8166 } |
|
8167 } ); |
7300 }, |
8168 }, |
7301 |
8169 |
7302 hasClass: function( selector ) { |
8170 hasClass: function( selector ) { |
7303 var className = " " + selector + " ", |
8171 var className, elem, |
7304 i = 0, |
8172 i = 0; |
7305 l = this.length; |
8173 |
7306 for ( ; i < l; i++ ) { |
8174 className = " " + selector + " "; |
7307 if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) { |
8175 while ( ( elem = this[ i++ ] ) ) { |
7308 return true; |
8176 if ( elem.nodeType === 1 && |
|
8177 ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) { |
|
8178 return true; |
7309 } |
8179 } |
7310 } |
8180 } |
7311 |
8181 |
7312 return false; |
8182 return false; |
7313 } |
8183 } |
7314 }); |
8184 } ); |
7315 |
8185 |
7316 |
8186 |
7317 |
8187 |
7318 |
8188 |
7319 var rreturn = /\r/g; |
8189 var rreturn = /\r/g; |
7320 |
8190 |
7321 jQuery.fn.extend({ |
8191 jQuery.fn.extend( { |
7322 val: function( value ) { |
8192 val: function( value ) { |
7323 var hooks, ret, isFunction, |
8193 var hooks, ret, valueIsFunction, |
7324 elem = this[0]; |
8194 elem = this[ 0 ]; |
7325 |
8195 |
7326 if ( !arguments.length ) { |
8196 if ( !arguments.length ) { |
7327 if ( elem ) { |
8197 if ( elem ) { |
7328 hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ]; |
8198 hooks = jQuery.valHooks[ elem.type ] || |
7329 |
8199 jQuery.valHooks[ elem.nodeName.toLowerCase() ]; |
7330 if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { |
8200 |
|
8201 if ( hooks && |
|
8202 "get" in hooks && |
|
8203 ( ret = hooks.get( elem, "value" ) ) !== undefined |
|
8204 ) { |
7331 return ret; |
8205 return ret; |
7332 } |
8206 } |
7333 |
8207 |
7334 ret = elem.value; |
8208 ret = elem.value; |
7335 |
8209 |
7336 return typeof ret === "string" ? |
8210 // Handle most common string cases |
7337 // Handle most common string cases |
8211 if ( typeof ret === "string" ) { |
7338 ret.replace(rreturn, "") : |
8212 return ret.replace( rreturn, "" ); |
7339 // Handle cases where value is null/undef or number |
8213 } |
7340 ret == null ? "" : ret; |
8214 |
|
8215 // Handle cases where value is null/undef or number |
|
8216 return ret == null ? "" : ret; |
7341 } |
8217 } |
7342 |
8218 |
7343 return; |
8219 return; |
7344 } |
8220 } |
7345 |
8221 |
7346 isFunction = jQuery.isFunction( value ); |
8222 valueIsFunction = isFunction( value ); |
7347 |
8223 |
7348 return this.each(function( i ) { |
8224 return this.each( function( i ) { |
7349 var val; |
8225 var val; |
7350 |
8226 |
7351 if ( this.nodeType !== 1 ) { |
8227 if ( this.nodeType !== 1 ) { |
7352 return; |
8228 return; |
7353 } |
8229 } |
7354 |
8230 |
7355 if ( isFunction ) { |
8231 if ( valueIsFunction ) { |
7356 val = value.call( this, i, jQuery( this ).val() ); |
8232 val = value.call( this, i, jQuery( this ).val() ); |
7357 } else { |
8233 } else { |
7358 val = value; |
8234 val = value; |
7359 } |
8235 } |
7360 |
8236 |
7437 values = jQuery.makeArray( value ), |
8324 values = jQuery.makeArray( value ), |
7438 i = options.length; |
8325 i = options.length; |
7439 |
8326 |
7440 while ( i-- ) { |
8327 while ( i-- ) { |
7441 option = options[ i ]; |
8328 option = options[ i ]; |
7442 if ( (option.selected = jQuery.inArray( option.value, values ) >= 0) ) { |
8329 |
|
8330 /* eslint-disable no-cond-assign */ |
|
8331 |
|
8332 if ( option.selected = |
|
8333 jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1 |
|
8334 ) { |
7443 optionSet = true; |
8335 optionSet = true; |
7444 } |
8336 } |
|
8337 |
|
8338 /* eslint-enable no-cond-assign */ |
7445 } |
8339 } |
7446 |
8340 |
7447 // Force browsers to behave consistently when non-matching value is set |
8341 // Force browsers to behave consistently when non-matching value is set |
7448 if ( !optionSet ) { |
8342 if ( !optionSet ) { |
7449 elem.selectedIndex = -1; |
8343 elem.selectedIndex = -1; |
7450 } |
8344 } |
7451 return values; |
8345 return values; |
7452 } |
8346 } |
7453 } |
8347 } |
7454 } |
8348 } |
7455 }); |
8349 } ); |
7456 |
8350 |
7457 // Radios and checkboxes getter/setter |
8351 // Radios and checkboxes getter/setter |
7458 jQuery.each([ "radio", "checkbox" ], function() { |
8352 jQuery.each( [ "radio", "checkbox" ], function() { |
7459 jQuery.valHooks[ this ] = { |
8353 jQuery.valHooks[ this ] = { |
7460 set: function( elem, value ) { |
8354 set: function( elem, value ) { |
7461 if ( jQuery.isArray( value ) ) { |
8355 if ( Array.isArray( value ) ) { |
7462 return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 ); |
8356 return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 ); |
7463 } |
8357 } |
7464 } |
8358 } |
7465 }; |
8359 }; |
7466 if ( !support.checkOn ) { |
8360 if ( !support.checkOn ) { |
7467 jQuery.valHooks[ this ].get = function( elem ) { |
8361 jQuery.valHooks[ this ].get = function( elem ) { |
7468 return elem.getAttribute("value") === null ? "on" : elem.value; |
8362 return elem.getAttribute( "value" ) === null ? "on" : elem.value; |
7469 }; |
8363 }; |
7470 } |
8364 } |
7471 }); |
8365 } ); |
7472 |
8366 |
7473 |
8367 |
7474 |
8368 |
7475 |
8369 |
7476 // Return jQuery for attributes-only inclusion |
8370 // Return jQuery for attributes-only inclusion |
7477 |
8371 |
7478 |
8372 |
7479 jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " + |
8373 support.focusin = "onfocusin" in window; |
7480 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + |
8374 |
7481 "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) { |
8375 |
7482 |
8376 var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, |
7483 // Handle event binding |
8377 stopPropagationCallback = function( e ) { |
7484 jQuery.fn[ name ] = function( data, fn ) { |
8378 e.stopPropagation(); |
7485 return arguments.length > 0 ? |
|
7486 this.on( name, null, data, fn ) : |
|
7487 this.trigger( name ); |
|
7488 }; |
8379 }; |
7489 }); |
8380 |
7490 |
8381 jQuery.extend( jQuery.event, { |
7491 jQuery.fn.extend({ |
8382 |
7492 hover: function( fnOver, fnOut ) { |
8383 trigger: function( event, data, elem, onlyHandlers ) { |
7493 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); |
8384 |
7494 }, |
8385 var i, cur, tmp, bubbleType, ontype, handle, special, lastElement, |
7495 |
8386 eventPath = [ elem || document ], |
7496 bind: function( types, data, fn ) { |
8387 type = hasOwn.call( event, "type" ) ? event.type : event, |
7497 return this.on( types, null, data, fn ); |
8388 namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : []; |
7498 }, |
8389 |
7499 unbind: function( types, fn ) { |
8390 cur = lastElement = tmp = elem = elem || document; |
7500 return this.off( types, null, fn ); |
8391 |
7501 }, |
8392 // Don't do events on text and comment nodes |
7502 |
8393 if ( elem.nodeType === 3 || elem.nodeType === 8 ) { |
7503 delegate: function( selector, types, data, fn ) { |
8394 return; |
7504 return this.on( types, selector, data, fn ); |
8395 } |
7505 }, |
8396 |
7506 undelegate: function( selector, types, fn ) { |
8397 // focus/blur morphs to focusin/out; ensure we're not firing them right now |
7507 // ( namespace ) or ( selector, types [, fn] ) |
8398 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { |
7508 return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn ); |
8399 return; |
7509 } |
8400 } |
7510 }); |
8401 |
7511 |
8402 if ( type.indexOf( "." ) > -1 ) { |
7512 |
8403 |
7513 var nonce = jQuery.now(); |
8404 // Namespaced trigger; create a regexp to match event type in handle() |
7514 |
8405 namespaces = type.split( "." ); |
7515 var rquery = (/\?/); |
8406 type = namespaces.shift(); |
7516 |
8407 namespaces.sort(); |
7517 |
8408 } |
7518 |
8409 ontype = type.indexOf( ":" ) < 0 && "on" + type; |
7519 // Support: Android 2.3 |
8410 |
7520 // Workaround failure to string-cast null input |
8411 // Caller can pass in a jQuery.Event object, Object, or just an event type string |
7521 jQuery.parseJSON = function( data ) { |
8412 event = event[ jQuery.expando ] ? |
7522 return JSON.parse( data + "" ); |
8413 event : |
7523 }; |
8414 new jQuery.Event( type, typeof event === "object" && event ); |
|
8415 |
|
8416 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true) |
|
8417 event.isTrigger = onlyHandlers ? 2 : 3; |
|
8418 event.namespace = namespaces.join( "." ); |
|
8419 event.rnamespace = event.namespace ? |
|
8420 new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) : |
|
8421 null; |
|
8422 |
|
8423 // Clean up the event in case it is being reused |
|
8424 event.result = undefined; |
|
8425 if ( !event.target ) { |
|
8426 event.target = elem; |
|
8427 } |
|
8428 |
|
8429 // Clone any incoming data and prepend the event, creating the handler arg list |
|
8430 data = data == null ? |
|
8431 [ event ] : |
|
8432 jQuery.makeArray( data, [ event ] ); |
|
8433 |
|
8434 // Allow special events to draw outside the lines |
|
8435 special = jQuery.event.special[ type ] || {}; |
|
8436 if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) { |
|
8437 return; |
|
8438 } |
|
8439 |
|
8440 // Determine event propagation path in advance, per W3C events spec (#9951) |
|
8441 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) |
|
8442 if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) { |
|
8443 |
|
8444 bubbleType = special.delegateType || type; |
|
8445 if ( !rfocusMorph.test( bubbleType + type ) ) { |
|
8446 cur = cur.parentNode; |
|
8447 } |
|
8448 for ( ; cur; cur = cur.parentNode ) { |
|
8449 eventPath.push( cur ); |
|
8450 tmp = cur; |
|
8451 } |
|
8452 |
|
8453 // Only add window if we got to document (e.g., not plain obj or detached DOM) |
|
8454 if ( tmp === ( elem.ownerDocument || document ) ) { |
|
8455 eventPath.push( tmp.defaultView || tmp.parentWindow || window ); |
|
8456 } |
|
8457 } |
|
8458 |
|
8459 // Fire handlers on the event path |
|
8460 i = 0; |
|
8461 while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) { |
|
8462 lastElement = cur; |
|
8463 event.type = i > 1 ? |
|
8464 bubbleType : |
|
8465 special.bindType || type; |
|
8466 |
|
8467 // jQuery handler |
|
8468 handle = ( dataPriv.get( cur, "events" ) || {} )[ event.type ] && |
|
8469 dataPriv.get( cur, "handle" ); |
|
8470 if ( handle ) { |
|
8471 handle.apply( cur, data ); |
|
8472 } |
|
8473 |
|
8474 // Native handler |
|
8475 handle = ontype && cur[ ontype ]; |
|
8476 if ( handle && handle.apply && acceptData( cur ) ) { |
|
8477 event.result = handle.apply( cur, data ); |
|
8478 if ( event.result === false ) { |
|
8479 event.preventDefault(); |
|
8480 } |
|
8481 } |
|
8482 } |
|
8483 event.type = type; |
|
8484 |
|
8485 // If nobody prevented the default action, do it now |
|
8486 if ( !onlyHandlers && !event.isDefaultPrevented() ) { |
|
8487 |
|
8488 if ( ( !special._default || |
|
8489 special._default.apply( eventPath.pop(), data ) === false ) && |
|
8490 acceptData( elem ) ) { |
|
8491 |
|
8492 // Call a native DOM method on the target with the same name as the event. |
|
8493 // Don't do default actions on window, that's where global variables be (#6170) |
|
8494 if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) { |
|
8495 |
|
8496 // Don't re-trigger an onFOO event when we call its FOO() method |
|
8497 tmp = elem[ ontype ]; |
|
8498 |
|
8499 if ( tmp ) { |
|
8500 elem[ ontype ] = null; |
|
8501 } |
|
8502 |
|
8503 // Prevent re-triggering of the same event, since we already bubbled it above |
|
8504 jQuery.event.triggered = type; |
|
8505 |
|
8506 if ( event.isPropagationStopped() ) { |
|
8507 lastElement.addEventListener( type, stopPropagationCallback ); |
|
8508 } |
|
8509 |
|
8510 elem[ type ](); |
|
8511 |
|
8512 if ( event.isPropagationStopped() ) { |
|
8513 lastElement.removeEventListener( type, stopPropagationCallback ); |
|
8514 } |
|
8515 |
|
8516 jQuery.event.triggered = undefined; |
|
8517 |
|
8518 if ( tmp ) { |
|
8519 elem[ ontype ] = tmp; |
|
8520 } |
|
8521 } |
|
8522 } |
|
8523 } |
|
8524 |
|
8525 return event.result; |
|
8526 }, |
|
8527 |
|
8528 // Piggyback on a donor event to simulate a different one |
|
8529 // Used only for `focus(in | out)` events |
|
8530 simulate: function( type, elem, event ) { |
|
8531 var e = jQuery.extend( |
|
8532 new jQuery.Event(), |
|
8533 event, |
|
8534 { |
|
8535 type: type, |
|
8536 isSimulated: true |
|
8537 } |
|
8538 ); |
|
8539 |
|
8540 jQuery.event.trigger( e, null, elem ); |
|
8541 } |
|
8542 |
|
8543 } ); |
|
8544 |
|
8545 jQuery.fn.extend( { |
|
8546 |
|
8547 trigger: function( type, data ) { |
|
8548 return this.each( function() { |
|
8549 jQuery.event.trigger( type, data, this ); |
|
8550 } ); |
|
8551 }, |
|
8552 triggerHandler: function( type, data ) { |
|
8553 var elem = this[ 0 ]; |
|
8554 if ( elem ) { |
|
8555 return jQuery.event.trigger( type, data, elem, true ); |
|
8556 } |
|
8557 } |
|
8558 } ); |
|
8559 |
|
8560 |
|
8561 // Support: Firefox <=44 |
|
8562 // Firefox doesn't have focus(in | out) events |
|
8563 // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787 |
|
8564 // |
|
8565 // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1 |
|
8566 // focus(in | out) events fire after focus & blur events, |
|
8567 // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order |
|
8568 // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857 |
|
8569 if ( !support.focusin ) { |
|
8570 jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) { |
|
8571 |
|
8572 // Attach a single capturing handler on the document while someone wants focusin/focusout |
|
8573 var handler = function( event ) { |
|
8574 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) ); |
|
8575 }; |
|
8576 |
|
8577 jQuery.event.special[ fix ] = { |
|
8578 setup: function() { |
|
8579 var doc = this.ownerDocument || this, |
|
8580 attaches = dataPriv.access( doc, fix ); |
|
8581 |
|
8582 if ( !attaches ) { |
|
8583 doc.addEventListener( orig, handler, true ); |
|
8584 } |
|
8585 dataPriv.access( doc, fix, ( attaches || 0 ) + 1 ); |
|
8586 }, |
|
8587 teardown: function() { |
|
8588 var doc = this.ownerDocument || this, |
|
8589 attaches = dataPriv.access( doc, fix ) - 1; |
|
8590 |
|
8591 if ( !attaches ) { |
|
8592 doc.removeEventListener( orig, handler, true ); |
|
8593 dataPriv.remove( doc, fix ); |
|
8594 |
|
8595 } else { |
|
8596 dataPriv.access( doc, fix, attaches ); |
|
8597 } |
|
8598 } |
|
8599 }; |
|
8600 } ); |
|
8601 } |
|
8602 var location = window.location; |
|
8603 |
|
8604 var nonce = Date.now(); |
|
8605 |
|
8606 var rquery = ( /\?/ ); |
|
8607 |
7524 |
8608 |
7525 |
8609 |
7526 // Cross-browser xml parsing |
8610 // Cross-browser xml parsing |
7527 jQuery.parseXML = function( data ) { |
8611 jQuery.parseXML = function( data ) { |
7528 var xml, tmp; |
8612 var xml; |
7529 if ( !data || typeof data !== "string" ) { |
8613 if ( !data || typeof data !== "string" ) { |
7530 return null; |
8614 return null; |
7531 } |
8615 } |
7532 |
8616 |
7533 // Support: IE9 |
8617 // Support: IE 9 - 11 only |
|
8618 // IE throws on parseFromString with invalid input. |
7534 try { |
8619 try { |
7535 tmp = new DOMParser(); |
8620 xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" ); |
7536 xml = tmp.parseFromString( data, "text/xml" ); |
|
7537 } catch ( e ) { |
8621 } catch ( e ) { |
7538 xml = undefined; |
8622 xml = undefined; |
7539 } |
8623 } |
7540 |
8624 |
7541 if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) { |
8625 if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) { |
7544 return xml; |
8628 return xml; |
7545 }; |
8629 }; |
7546 |
8630 |
7547 |
8631 |
7548 var |
8632 var |
|
8633 rbracket = /\[\]$/, |
|
8634 rCRLF = /\r?\n/g, |
|
8635 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i, |
|
8636 rsubmittable = /^(?:input|select|textarea|keygen)/i; |
|
8637 |
|
8638 function buildParams( prefix, obj, traditional, add ) { |
|
8639 var name; |
|
8640 |
|
8641 if ( Array.isArray( obj ) ) { |
|
8642 |
|
8643 // Serialize array item. |
|
8644 jQuery.each( obj, function( i, v ) { |
|
8645 if ( traditional || rbracket.test( prefix ) ) { |
|
8646 |
|
8647 // Treat each array item as a scalar. |
|
8648 add( prefix, v ); |
|
8649 |
|
8650 } else { |
|
8651 |
|
8652 // Item is non-scalar (array or object), encode its numeric index. |
|
8653 buildParams( |
|
8654 prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]", |
|
8655 v, |
|
8656 traditional, |
|
8657 add |
|
8658 ); |
|
8659 } |
|
8660 } ); |
|
8661 |
|
8662 } else if ( !traditional && toType( obj ) === "object" ) { |
|
8663 |
|
8664 // Serialize object item. |
|
8665 for ( name in obj ) { |
|
8666 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); |
|
8667 } |
|
8668 |
|
8669 } else { |
|
8670 |
|
8671 // Serialize scalar item. |
|
8672 add( prefix, obj ); |
|
8673 } |
|
8674 } |
|
8675 |
|
8676 // Serialize an array of form elements or a set of |
|
8677 // key/values into a query string |
|
8678 jQuery.param = function( a, traditional ) { |
|
8679 var prefix, |
|
8680 s = [], |
|
8681 add = function( key, valueOrFunction ) { |
|
8682 |
|
8683 // If value is a function, invoke it and use its return value |
|
8684 var value = isFunction( valueOrFunction ) ? |
|
8685 valueOrFunction() : |
|
8686 valueOrFunction; |
|
8687 |
|
8688 s[ s.length ] = encodeURIComponent( key ) + "=" + |
|
8689 encodeURIComponent( value == null ? "" : value ); |
|
8690 }; |
|
8691 |
|
8692 if ( a == null ) { |
|
8693 return ""; |
|
8694 } |
|
8695 |
|
8696 // If an array was passed in, assume that it is an array of form elements. |
|
8697 if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { |
|
8698 |
|
8699 // Serialize the form elements |
|
8700 jQuery.each( a, function() { |
|
8701 add( this.name, this.value ); |
|
8702 } ); |
|
8703 |
|
8704 } else { |
|
8705 |
|
8706 // If traditional, encode the "old" way (the way 1.3.2 or older |
|
8707 // did it), otherwise encode params recursively. |
|
8708 for ( prefix in a ) { |
|
8709 buildParams( prefix, a[ prefix ], traditional, add ); |
|
8710 } |
|
8711 } |
|
8712 |
|
8713 // Return the resulting serialization |
|
8714 return s.join( "&" ); |
|
8715 }; |
|
8716 |
|
8717 jQuery.fn.extend( { |
|
8718 serialize: function() { |
|
8719 return jQuery.param( this.serializeArray() ); |
|
8720 }, |
|
8721 serializeArray: function() { |
|
8722 return this.map( function() { |
|
8723 |
|
8724 // Can add propHook for "elements" to filter or add form elements |
|
8725 var elements = jQuery.prop( this, "elements" ); |
|
8726 return elements ? jQuery.makeArray( elements ) : this; |
|
8727 } ) |
|
8728 .filter( function() { |
|
8729 var type = this.type; |
|
8730 |
|
8731 // Use .is( ":disabled" ) so that fieldset[disabled] works |
|
8732 return this.name && !jQuery( this ).is( ":disabled" ) && |
|
8733 rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) && |
|
8734 ( this.checked || !rcheckableType.test( type ) ); |
|
8735 } ) |
|
8736 .map( function( i, elem ) { |
|
8737 var val = jQuery( this ).val(); |
|
8738 |
|
8739 if ( val == null ) { |
|
8740 return null; |
|
8741 } |
|
8742 |
|
8743 if ( Array.isArray( val ) ) { |
|
8744 return jQuery.map( val, function( val ) { |
|
8745 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; |
|
8746 } ); |
|
8747 } |
|
8748 |
|
8749 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; |
|
8750 } ).get(); |
|
8751 } |
|
8752 } ); |
|
8753 |
|
8754 |
|
8755 var |
|
8756 r20 = /%20/g, |
7549 rhash = /#.*$/, |
8757 rhash = /#.*$/, |
7550 rts = /([?&])_=[^&]*/, |
8758 rantiCache = /([?&])_=[^&]*/, |
7551 rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg, |
8759 rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg, |
|
8760 |
7552 // #7653, #8125, #8152: local protocol detection |
8761 // #7653, #8125, #8152: local protocol detection |
7553 rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/, |
8762 rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/, |
7554 rnoContent = /^(?:GET|HEAD)$/, |
8763 rnoContent = /^(?:GET|HEAD)$/, |
7555 rprotocol = /^\/\//, |
8764 rprotocol = /^\/\//, |
7556 rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/, |
|
7557 |
8765 |
7558 /* Prefilters |
8766 /* Prefilters |
7559 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example) |
8767 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example) |
7560 * 2) These are called: |
8768 * 2) These are called: |
7561 * - BEFORE asking for a transport |
8769 * - BEFORE asking for a transport |
7912 |
9130 |
7913 // Force options to be an object |
9131 // Force options to be an object |
7914 options = options || {}; |
9132 options = options || {}; |
7915 |
9133 |
7916 var transport, |
9134 var transport, |
|
9135 |
7917 // URL without anti-cache param |
9136 // URL without anti-cache param |
7918 cacheURL, |
9137 cacheURL, |
|
9138 |
7919 // Response headers |
9139 // Response headers |
7920 responseHeadersString, |
9140 responseHeadersString, |
7921 responseHeaders, |
9141 responseHeaders, |
|
9142 |
7922 // timeout handle |
9143 // timeout handle |
7923 timeoutTimer, |
9144 timeoutTimer, |
7924 // Cross-domain detection vars |
9145 |
7925 parts, |
9146 // Url cleanup var |
|
9147 urlAnchor, |
|
9148 |
|
9149 // Request state (becomes false upon send and true upon completion) |
|
9150 completed, |
|
9151 |
7926 // To know if global events are to be dispatched |
9152 // To know if global events are to be dispatched |
7927 fireGlobals, |
9153 fireGlobals, |
|
9154 |
7928 // Loop variable |
9155 // Loop variable |
7929 i, |
9156 i, |
|
9157 |
|
9158 // uncached part of the url |
|
9159 uncached, |
|
9160 |
7930 // Create the final options object |
9161 // Create the final options object |
7931 s = jQuery.ajaxSetup( {}, options ), |
9162 s = jQuery.ajaxSetup( {}, options ), |
|
9163 |
7932 // Callbacks context |
9164 // Callbacks context |
7933 callbackContext = s.context || s, |
9165 callbackContext = s.context || s, |
|
9166 |
7934 // Context for global events is callbackContext if it is a DOM node or jQuery collection |
9167 // Context for global events is callbackContext if it is a DOM node or jQuery collection |
7935 globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ? |
9168 globalEventContext = s.context && |
7936 jQuery( callbackContext ) : |
9169 ( callbackContext.nodeType || callbackContext.jquery ) ? |
7937 jQuery.event, |
9170 jQuery( callbackContext ) : |
|
9171 jQuery.event, |
|
9172 |
7938 // Deferreds |
9173 // Deferreds |
7939 deferred = jQuery.Deferred(), |
9174 deferred = jQuery.Deferred(), |
7940 completeDeferred = jQuery.Callbacks("once memory"), |
9175 completeDeferred = jQuery.Callbacks( "once memory" ), |
|
9176 |
7941 // Status-dependent callbacks |
9177 // Status-dependent callbacks |
7942 statusCode = s.statusCode || {}, |
9178 statusCode = s.statusCode || {}, |
|
9179 |
7943 // Headers (they are sent all at once) |
9180 // Headers (they are sent all at once) |
7944 requestHeaders = {}, |
9181 requestHeaders = {}, |
7945 requestHeadersNames = {}, |
9182 requestHeadersNames = {}, |
7946 // The jqXHR state |
9183 |
7947 state = 0, |
|
7948 // Default abort message |
9184 // Default abort message |
7949 strAbort = "canceled", |
9185 strAbort = "canceled", |
|
9186 |
7950 // Fake xhr |
9187 // Fake xhr |
7951 jqXHR = { |
9188 jqXHR = { |
7952 readyState: 0, |
9189 readyState: 0, |
7953 |
9190 |
7954 // Builds headers hashtable if needed |
9191 // Builds headers hashtable if needed |
7955 getResponseHeader: function( key ) { |
9192 getResponseHeader: function( key ) { |
7956 var match; |
9193 var match; |
7957 if ( state === 2 ) { |
9194 if ( completed ) { |
7958 if ( !responseHeaders ) { |
9195 if ( !responseHeaders ) { |
7959 responseHeaders = {}; |
9196 responseHeaders = {}; |
7960 while ( (match = rheaders.exec( responseHeadersString )) ) { |
9197 while ( ( match = rheaders.exec( responseHeadersString ) ) ) { |
7961 responseHeaders[ match[1].toLowerCase() ] = match[ 2 ]; |
9198 responseHeaders[ match[ 1 ].toLowerCase() + " " ] = |
|
9199 ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] ) |
|
9200 .concat( match[ 2 ] ); |
7962 } |
9201 } |
7963 } |
9202 } |
7964 match = responseHeaders[ key.toLowerCase() ]; |
9203 match = responseHeaders[ key.toLowerCase() + " " ]; |
7965 } |
9204 } |
7966 return match == null ? null : match; |
9205 return match == null ? null : match.join( ", " ); |
7967 }, |
9206 }, |
7968 |
9207 |
7969 // Raw string |
9208 // Raw string |
7970 getAllResponseHeaders: function() { |
9209 getAllResponseHeaders: function() { |
7971 return state === 2 ? responseHeadersString : null; |
9210 return completed ? responseHeadersString : null; |
7972 }, |
9211 }, |
7973 |
9212 |
7974 // Caches the header |
9213 // Caches the header |
7975 setRequestHeader: function( name, value ) { |
9214 setRequestHeader: function( name, value ) { |
7976 var lname = name.toLowerCase(); |
9215 if ( completed == null ) { |
7977 if ( !state ) { |
9216 name = requestHeadersNames[ name.toLowerCase() ] = |
7978 name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name; |
9217 requestHeadersNames[ name.toLowerCase() ] || name; |
7979 requestHeaders[ name ] = value; |
9218 requestHeaders[ name ] = value; |
7980 } |
9219 } |
7981 return this; |
9220 return this; |
7982 }, |
9221 }, |
7983 |
9222 |
7984 // Overrides response content-type header |
9223 // Overrides response content-type header |
7985 overrideMimeType: function( type ) { |
9224 overrideMimeType: function( type ) { |
7986 if ( !state ) { |
9225 if ( completed == null ) { |
7987 s.mimeType = type; |
9226 s.mimeType = type; |
7988 } |
9227 } |
7989 return this; |
9228 return this; |
7990 }, |
9229 }, |
7991 |
9230 |
7992 // Status-dependent callbacks |
9231 // Status-dependent callbacks |
7993 statusCode: function( map ) { |
9232 statusCode: function( map ) { |
7994 var code; |
9233 var code; |
7995 if ( map ) { |
9234 if ( map ) { |
7996 if ( state < 2 ) { |
9235 if ( completed ) { |
|
9236 |
|
9237 // Execute the appropriate callbacks |
|
9238 jqXHR.always( map[ jqXHR.status ] ); |
|
9239 } else { |
|
9240 |
|
9241 // Lazy-add the new callbacks in a way that preserves old ones |
7997 for ( code in map ) { |
9242 for ( code in map ) { |
7998 // Lazy-add the new callback in a way that preserves old ones |
|
7999 statusCode[ code ] = [ statusCode[ code ], map[ code ] ]; |
9243 statusCode[ code ] = [ statusCode[ code ], map[ code ] ]; |
8000 } |
9244 } |
8001 } else { |
|
8002 // Execute the appropriate callbacks |
|
8003 jqXHR.always( map[ jqXHR.status ] ); |
|
8004 } |
9245 } |
8005 } |
9246 } |
8006 return this; |
9247 return this; |
8007 }, |
9248 }, |
8008 |
9249 |
8295 }, |
9565 }, |
8296 |
9566 |
8297 getScript: function( url, callback ) { |
9567 getScript: function( url, callback ) { |
8298 return jQuery.get( url, undefined, callback, "script" ); |
9568 return jQuery.get( url, undefined, callback, "script" ); |
8299 } |
9569 } |
8300 }); |
9570 } ); |
8301 |
9571 |
8302 jQuery.each( [ "get", "post" ], function( i, method ) { |
9572 jQuery.each( [ "get", "post" ], function( i, method ) { |
8303 jQuery[ method ] = function( url, data, callback, type ) { |
9573 jQuery[ method ] = function( url, data, callback, type ) { |
|
9574 |
8304 // Shift arguments if data argument was omitted |
9575 // Shift arguments if data argument was omitted |
8305 if ( jQuery.isFunction( data ) ) { |
9576 if ( isFunction( data ) ) { |
8306 type = type || callback; |
9577 type = type || callback; |
8307 callback = data; |
9578 callback = data; |
8308 data = undefined; |
9579 data = undefined; |
8309 } |
9580 } |
8310 |
9581 |
8311 return jQuery.ajax({ |
9582 // The url can be an options object (which then must have .url) |
|
9583 return jQuery.ajax( jQuery.extend( { |
8312 url: url, |
9584 url: url, |
8313 type: method, |
9585 type: method, |
8314 dataType: type, |
9586 dataType: type, |
8315 data: data, |
9587 data: data, |
8316 success: callback |
9588 success: callback |
8317 }); |
9589 }, jQuery.isPlainObject( url ) && url ) ); |
8318 }; |
9590 }; |
8319 }); |
9591 } ); |
8320 |
9592 |
8321 |
9593 |
8322 jQuery._evalUrl = function( url ) { |
9594 jQuery._evalUrl = function( url, options ) { |
8323 return jQuery.ajax({ |
9595 return jQuery.ajax( { |
8324 url: url, |
9596 url: url, |
|
9597 |
|
9598 // Make this explicit, since user can override this through ajaxSetup (#11264) |
8325 type: "GET", |
9599 type: "GET", |
8326 dataType: "script", |
9600 dataType: "script", |
|
9601 cache: true, |
8327 async: false, |
9602 async: false, |
8328 global: false, |
9603 global: false, |
8329 "throws": true |
9604 |
8330 }); |
9605 // Only evaluate the response if it is successful (gh-4126) |
|
9606 // dataFilter is not invoked for failure responses, so using it instead |
|
9607 // of the default converter is kludgy but it works. |
|
9608 converters: { |
|
9609 "text script": function() {} |
|
9610 }, |
|
9611 dataFilter: function( response ) { |
|
9612 jQuery.globalEval( response, options ); |
|
9613 } |
|
9614 } ); |
8331 }; |
9615 }; |
8332 |
9616 |
8333 |
9617 |
8334 jQuery.fn.extend({ |
9618 jQuery.fn.extend( { |
8335 wrapAll: function( html ) { |
9619 wrapAll: function( html ) { |
8336 var wrap; |
9620 var wrap; |
8337 |
9621 |
8338 if ( jQuery.isFunction( html ) ) { |
|
8339 return this.each(function( i ) { |
|
8340 jQuery( this ).wrapAll( html.call(this, i) ); |
|
8341 }); |
|
8342 } |
|
8343 |
|
8344 if ( this[ 0 ] ) { |
9622 if ( this[ 0 ] ) { |
|
9623 if ( isFunction( html ) ) { |
|
9624 html = html.call( this[ 0 ] ); |
|
9625 } |
8345 |
9626 |
8346 // The elements to wrap the target around |
9627 // The elements to wrap the target around |
8347 wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true ); |
9628 wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true ); |
8348 |
9629 |
8349 if ( this[ 0 ].parentNode ) { |
9630 if ( this[ 0 ].parentNode ) { |
8350 wrap.insertBefore( this[ 0 ] ); |
9631 wrap.insertBefore( this[ 0 ] ); |
8351 } |
9632 } |
8352 |
9633 |
8353 wrap.map(function() { |
9634 wrap.map( function() { |
8354 var elem = this; |
9635 var elem = this; |
8355 |
9636 |
8356 while ( elem.firstElementChild ) { |
9637 while ( elem.firstElementChild ) { |
8357 elem = elem.firstElementChild; |
9638 elem = elem.firstElementChild; |
8358 } |
9639 } |
8359 |
9640 |
8360 return elem; |
9641 return elem; |
8361 }).append( this ); |
9642 } ).append( this ); |
8362 } |
9643 } |
8363 |
9644 |
8364 return this; |
9645 return this; |
8365 }, |
9646 }, |
8366 |
9647 |
8367 wrapInner: function( html ) { |
9648 wrapInner: function( html ) { |
8368 if ( jQuery.isFunction( html ) ) { |
9649 if ( isFunction( html ) ) { |
8369 return this.each(function( i ) { |
9650 return this.each( function( i ) { |
8370 jQuery( this ).wrapInner( html.call(this, i) ); |
9651 jQuery( this ).wrapInner( html.call( this, i ) ); |
8371 }); |
9652 } ); |
8372 } |
9653 } |
8373 |
9654 |
8374 return this.each(function() { |
9655 return this.each( function() { |
8375 var self = jQuery( this ), |
9656 var self = jQuery( this ), |
8376 contents = self.contents(); |
9657 contents = self.contents(); |
8377 |
9658 |
8378 if ( contents.length ) { |
9659 if ( contents.length ) { |
8379 contents.wrapAll( html ); |
9660 contents.wrapAll( html ); |
8380 |
9661 |
8381 } else { |
9662 } else { |
8382 self.append( html ); |
9663 self.append( html ); |
8383 } |
9664 } |
8384 }); |
9665 } ); |
8385 }, |
9666 }, |
8386 |
9667 |
8387 wrap: function( html ) { |
9668 wrap: function( html ) { |
8388 var isFunction = jQuery.isFunction( html ); |
9669 var htmlIsFunction = isFunction( html ); |
8389 |
9670 |
8390 return this.each(function( i ) { |
9671 return this.each( function( i ) { |
8391 jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html ); |
9672 jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html ); |
8392 }); |
9673 } ); |
8393 }, |
9674 }, |
8394 |
9675 |
8395 unwrap: function() { |
9676 unwrap: function( selector ) { |
8396 return this.parent().each(function() { |
9677 this.parent( selector ).not( "body" ).each( function() { |
8397 if ( !jQuery.nodeName( this, "body" ) ) { |
9678 jQuery( this ).replaceWith( this.childNodes ); |
8398 jQuery( this ).replaceWith( this.childNodes ); |
9679 } ); |
8399 } |
9680 return this; |
8400 }).end(); |
9681 } |
8401 } |
9682 } ); |
8402 }); |
9683 |
8403 |
9684 |
8404 |
9685 jQuery.expr.pseudos.hidden = function( elem ) { |
8405 jQuery.expr.filters.hidden = function( elem ) { |
9686 return !jQuery.expr.pseudos.visible( elem ); |
8406 // Support: Opera <= 12.12 |
|
8407 // Opera reports offsetWidths and offsetHeights less than zero on some elements |
|
8408 return elem.offsetWidth <= 0 && elem.offsetHeight <= 0; |
|
8409 }; |
9687 }; |
8410 jQuery.expr.filters.visible = function( elem ) { |
9688 jQuery.expr.pseudos.visible = function( elem ) { |
8411 return !jQuery.expr.filters.hidden( elem ); |
9689 return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length ); |
8412 }; |
9690 }; |
8413 |
9691 |
8414 |
9692 |
8415 |
|
8416 |
|
8417 var r20 = /%20/g, |
|
8418 rbracket = /\[\]$/, |
|
8419 rCRLF = /\r?\n/g, |
|
8420 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i, |
|
8421 rsubmittable = /^(?:input|select|textarea|keygen)/i; |
|
8422 |
|
8423 function buildParams( prefix, obj, traditional, add ) { |
|
8424 var name; |
|
8425 |
|
8426 if ( jQuery.isArray( obj ) ) { |
|
8427 // Serialize array item. |
|
8428 jQuery.each( obj, function( i, v ) { |
|
8429 if ( traditional || rbracket.test( prefix ) ) { |
|
8430 // Treat each array item as a scalar. |
|
8431 add( prefix, v ); |
|
8432 |
|
8433 } else { |
|
8434 // Item is non-scalar (array or object), encode its numeric index. |
|
8435 buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add ); |
|
8436 } |
|
8437 }); |
|
8438 |
|
8439 } else if ( !traditional && jQuery.type( obj ) === "object" ) { |
|
8440 // Serialize object item. |
|
8441 for ( name in obj ) { |
|
8442 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); |
|
8443 } |
|
8444 |
|
8445 } else { |
|
8446 // Serialize scalar item. |
|
8447 add( prefix, obj ); |
|
8448 } |
|
8449 } |
|
8450 |
|
8451 // Serialize an array of form elements or a set of |
|
8452 // key/values into a query string |
|
8453 jQuery.param = function( a, traditional ) { |
|
8454 var prefix, |
|
8455 s = [], |
|
8456 add = function( key, value ) { |
|
8457 // If value is a function, invoke it and return its value |
|
8458 value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value ); |
|
8459 s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value ); |
|
8460 }; |
|
8461 |
|
8462 // Set traditional to true for jQuery <= 1.3.2 behavior. |
|
8463 if ( traditional === undefined ) { |
|
8464 traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional; |
|
8465 } |
|
8466 |
|
8467 // If an array was passed in, assume that it is an array of form elements. |
|
8468 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { |
|
8469 // Serialize the form elements |
|
8470 jQuery.each( a, function() { |
|
8471 add( this.name, this.value ); |
|
8472 }); |
|
8473 |
|
8474 } else { |
|
8475 // If traditional, encode the "old" way (the way 1.3.2 or older |
|
8476 // did it), otherwise encode params recursively. |
|
8477 for ( prefix in a ) { |
|
8478 buildParams( prefix, a[ prefix ], traditional, add ); |
|
8479 } |
|
8480 } |
|
8481 |
|
8482 // Return the resulting serialization |
|
8483 return s.join( "&" ).replace( r20, "+" ); |
|
8484 }; |
|
8485 |
|
8486 jQuery.fn.extend({ |
|
8487 serialize: function() { |
|
8488 return jQuery.param( this.serializeArray() ); |
|
8489 }, |
|
8490 serializeArray: function() { |
|
8491 return this.map(function() { |
|
8492 // Can add propHook for "elements" to filter or add form elements |
|
8493 var elements = jQuery.prop( this, "elements" ); |
|
8494 return elements ? jQuery.makeArray( elements ) : this; |
|
8495 }) |
|
8496 .filter(function() { |
|
8497 var type = this.type; |
|
8498 |
|
8499 // Use .is( ":disabled" ) so that fieldset[disabled] works |
|
8500 return this.name && !jQuery( this ).is( ":disabled" ) && |
|
8501 rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) && |
|
8502 ( this.checked || !rcheckableType.test( type ) ); |
|
8503 }) |
|
8504 .map(function( i, elem ) { |
|
8505 var val = jQuery( this ).val(); |
|
8506 |
|
8507 return val == null ? |
|
8508 null : |
|
8509 jQuery.isArray( val ) ? |
|
8510 jQuery.map( val, function( val ) { |
|
8511 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; |
|
8512 }) : |
|
8513 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; |
|
8514 }).get(); |
|
8515 } |
|
8516 }); |
|
8517 |
9693 |
8518 |
9694 |
8519 jQuery.ajaxSettings.xhr = function() { |
9695 jQuery.ajaxSettings.xhr = function() { |
8520 try { |
9696 try { |
8521 return new XMLHttpRequest(); |
9697 return new window.XMLHttpRequest(); |
8522 } catch( e ) {} |
9698 } catch ( e ) {} |
8523 }; |
9699 }; |
8524 |
9700 |
8525 var xhrId = 0, |
9701 var xhrSuccessStatus = { |
8526 xhrCallbacks = {}, |
9702 |
8527 xhrSuccessStatus = { |
9703 // File protocol always yields status code 0, assume 200 |
8528 // file protocol always yields status code 0, assume 200 |
|
8529 0: 200, |
9704 0: 200, |
8530 // Support: IE9 |
9705 |
|
9706 // Support: IE <=9 only |
8531 // #1450: sometimes IE returns 1223 when it should be 204 |
9707 // #1450: sometimes IE returns 1223 when it should be 204 |
8532 1223: 204 |
9708 1223: 204 |
8533 }, |
9709 }, |
8534 xhrSupported = jQuery.ajaxSettings.xhr(); |
9710 xhrSupported = jQuery.ajaxSettings.xhr(); |
8535 |
9711 |
8536 // Support: IE9 |
|
8537 // Open requests must be manually aborted on unload (#5280) |
|
8538 // See https://support.microsoft.com/kb/2856746 for more info |
|
8539 if ( window.attachEvent ) { |
|
8540 window.attachEvent( "onunload", function() { |
|
8541 for ( var key in xhrCallbacks ) { |
|
8542 xhrCallbacks[ key ](); |
|
8543 } |
|
8544 }); |
|
8545 } |
|
8546 |
|
8547 support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported ); |
9712 support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported ); |
8548 support.ajax = xhrSupported = !!xhrSupported; |
9713 support.ajax = xhrSupported = !!xhrSupported; |
8549 |
9714 |
8550 jQuery.ajaxTransport(function( options ) { |
9715 jQuery.ajaxTransport( function( options ) { |
8551 var callback; |
9716 var callback, errorCallback; |
8552 |
9717 |
8553 // Cross domain only allowed if supported through XMLHttpRequest |
9718 // Cross domain only allowed if supported through XMLHttpRequest |
8554 if ( support.cors || xhrSupported && !options.crossDomain ) { |
9719 if ( support.cors || xhrSupported && !options.crossDomain ) { |
8555 return { |
9720 return { |
8556 send: function( headers, complete ) { |
9721 send: function( headers, complete ) { |
8557 var i, |
9722 var i, |
8558 xhr = options.xhr(), |
9723 xhr = options.xhr(); |
8559 id = ++xhrId; |
9724 |
8560 |
9725 xhr.open( |
8561 xhr.open( options.type, options.url, options.async, options.username, options.password ); |
9726 options.type, |
|
9727 options.url, |
|
9728 options.async, |
|
9729 options.username, |
|
9730 options.password |
|
9731 ); |
8562 |
9732 |
8563 // Apply custom fields if provided |
9733 // Apply custom fields if provided |
8564 if ( options.xhrFields ) { |
9734 if ( options.xhrFields ) { |
8565 for ( i in options.xhrFields ) { |
9735 for ( i in options.xhrFields ) { |
8566 xhr[ i ] = options.xhrFields[ i ]; |
9736 xhr[ i ] = options.xhrFields[ i ]; |
8641 callback(); |
9849 callback(); |
8642 } |
9850 } |
8643 } |
9851 } |
8644 }; |
9852 }; |
8645 } |
9853 } |
8646 }); |
9854 } ); |
8647 |
9855 |
8648 |
9856 |
8649 |
9857 |
|
9858 |
|
9859 // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432) |
|
9860 jQuery.ajaxPrefilter( function( s ) { |
|
9861 if ( s.crossDomain ) { |
|
9862 s.contents.script = false; |
|
9863 } |
|
9864 } ); |
8650 |
9865 |
8651 // Install script dataType |
9866 // Install script dataType |
8652 jQuery.ajaxSetup({ |
9867 jQuery.ajaxSetup( { |
8653 accepts: { |
9868 accepts: { |
8654 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript" |
9869 script: "text/javascript, application/javascript, " + |
|
9870 "application/ecmascript, application/x-ecmascript" |
8655 }, |
9871 }, |
8656 contents: { |
9872 contents: { |
8657 script: /(?:java|ecma)script/ |
9873 script: /\b(?:java|ecma)script\b/ |
8658 }, |
9874 }, |
8659 converters: { |
9875 converters: { |
8660 "text script": function( text ) { |
9876 "text script": function( text ) { |
8661 jQuery.globalEval( text ); |
9877 jQuery.globalEval( text ); |
8662 return text; |
9878 return text; |
8663 } |
9879 } |
8664 } |
9880 } |
8665 }); |
9881 } ); |
8666 |
9882 |
8667 // Handle cache's special case and crossDomain |
9883 // Handle cache's special case and crossDomain |
8668 jQuery.ajaxPrefilter( "script", function( s ) { |
9884 jQuery.ajaxPrefilter( "script", function( s ) { |
8669 if ( s.cache === undefined ) { |
9885 if ( s.cache === undefined ) { |
8670 s.cache = false; |
9886 s.cache = false; |
8671 } |
9887 } |
8672 if ( s.crossDomain ) { |
9888 if ( s.crossDomain ) { |
8673 s.type = "GET"; |
9889 s.type = "GET"; |
8674 } |
9890 } |
8675 }); |
9891 } ); |
8676 |
9892 |
8677 // Bind script tag hack transport |
9893 // Bind script tag hack transport |
8678 jQuery.ajaxTransport( "script", function( s ) { |
9894 jQuery.ajaxTransport( "script", function( s ) { |
8679 // This transport only deals with cross domain requests |
9895 |
8680 if ( s.crossDomain ) { |
9896 // This transport only deals with cross domain or forced-by-attrs requests |
|
9897 if ( s.crossDomain || s.scriptAttrs ) { |
8681 var script, callback; |
9898 var script, callback; |
8682 return { |
9899 return { |
8683 send: function( _, complete ) { |
9900 send: function( _, complete ) { |
8684 script = jQuery("<script>").prop({ |
9901 script = jQuery( "<script>" ) |
8685 async: true, |
9902 .attr( s.scriptAttrs || {} ) |
8686 charset: s.scriptCharset, |
9903 .prop( { charset: s.scriptCharset, src: s.url } ) |
8687 src: s.url |
9904 .on( "load error", callback = function( evt ) { |
8688 }).on( |
|
8689 "load error", |
|
8690 callback = function( evt ) { |
|
8691 script.remove(); |
9905 script.remove(); |
8692 callback = null; |
9906 callback = null; |
8693 if ( evt ) { |
9907 if ( evt ) { |
8694 complete( evt.type === "error" ? 404 : 200, evt.type ); |
9908 complete( evt.type === "error" ? 404 : 200, evt.type ); |
8695 } |
9909 } |
8696 } |
9910 } ); |
8697 ); |
9911 |
|
9912 // Use native DOM manipulation to avoid our domManip AJAX trickery |
8698 document.head.appendChild( script[ 0 ] ); |
9913 document.head.appendChild( script[ 0 ] ); |
8699 }, |
9914 }, |
8700 abort: function() { |
9915 abort: function() { |
8701 if ( callback ) { |
9916 if ( callback ) { |
8702 callback(); |
9917 callback(); |
8703 } |
9918 } |
8704 } |
9919 } |
8705 }; |
9920 }; |
8706 } |
9921 } |
8707 }); |
9922 } ); |
8708 |
9923 |
8709 |
9924 |
8710 |
9925 |
8711 |
9926 |
8712 var oldCallbacks = [], |
9927 var oldCallbacks = [], |
8713 rjsonp = /(=)\?(?=&|$)|\?\?/; |
9928 rjsonp = /(=)\?(?=&|$)|\?\?/; |
8714 |
9929 |
8715 // Default jsonp settings |
9930 // Default jsonp settings |
8716 jQuery.ajaxSetup({ |
9931 jQuery.ajaxSetup( { |
8717 jsonp: "callback", |
9932 jsonp: "callback", |
8718 jsonpCallback: function() { |
9933 jsonpCallback: function() { |
8719 var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) ); |
9934 var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) ); |
8720 this[ callback ] = true; |
9935 this[ callback ] = true; |
8721 return callback; |
9936 return callback; |
8722 } |
9937 } |
8723 }); |
9938 } ); |
8724 |
9939 |
8725 // Detect, normalize options and install callbacks for jsonp requests |
9940 // Detect, normalize options and install callbacks for jsonp requests |
8726 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { |
9941 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { |
8727 |
9942 |
8728 var callbackName, overwritten, responseContainer, |
9943 var callbackName, overwritten, responseContainer, |
8729 jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ? |
9944 jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ? |
8730 "url" : |
9945 "url" : |
8731 typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data" |
9946 typeof s.data === "string" && |
|
9947 ( s.contentType || "" ) |
|
9948 .indexOf( "application/x-www-form-urlencoded" ) === 0 && |
|
9949 rjsonp.test( s.data ) && "data" |
8732 ); |
9950 ); |
8733 |
9951 |
8734 // Handle iff the expected data type is "jsonp" or we have a parameter to set |
9952 // Handle iff the expected data type is "jsonp" or we have a parameter to set |
8735 if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) { |
9953 if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) { |
8736 |
9954 |
8737 // Get callback name, remembering preexisting value associated with it |
9955 // Get callback name, remembering preexisting value associated with it |
8738 callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ? |
9956 callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ? |
8739 s.jsonpCallback() : |
9957 s.jsonpCallback() : |
8740 s.jsonpCallback; |
9958 s.jsonpCallback; |
8741 |
9959 |
8742 // Insert callback into url or form data |
9960 // Insert callback into url or form data |
8743 if ( jsonProp ) { |
9961 if ( jsonProp ) { |
8745 } else if ( s.jsonp !== false ) { |
9963 } else if ( s.jsonp !== false ) { |
8746 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName; |
9964 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName; |
8747 } |
9965 } |
8748 |
9966 |
8749 // Use data converter to retrieve json after script execution |
9967 // Use data converter to retrieve json after script execution |
8750 s.converters["script json"] = function() { |
9968 s.converters[ "script json" ] = function() { |
8751 if ( !responseContainer ) { |
9969 if ( !responseContainer ) { |
8752 jQuery.error( callbackName + " was not called" ); |
9970 jQuery.error( callbackName + " was not called" ); |
8753 } |
9971 } |
8754 return responseContainer[ 0 ]; |
9972 return responseContainer[ 0 ]; |
8755 }; |
9973 }; |
8756 |
9974 |
8757 // force json dataType |
9975 // Force json dataType |
8758 s.dataTypes[ 0 ] = "json"; |
9976 s.dataTypes[ 0 ] = "json"; |
8759 |
9977 |
8760 // Install callback |
9978 // Install callback |
8761 overwritten = window[ callbackName ]; |
9979 overwritten = window[ callbackName ]; |
8762 window[ callbackName ] = function() { |
9980 window[ callbackName ] = function() { |
8763 responseContainer = arguments; |
9981 responseContainer = arguments; |
8764 }; |
9982 }; |
8765 |
9983 |
8766 // Clean-up function (fires after converters) |
9984 // Clean-up function (fires after converters) |
8767 jqXHR.always(function() { |
9985 jqXHR.always( function() { |
8768 // Restore preexisting value |
9986 |
8769 window[ callbackName ] = overwritten; |
9987 // If previous value didn't exist - remove it |
|
9988 if ( overwritten === undefined ) { |
|
9989 jQuery( window ).removeProp( callbackName ); |
|
9990 |
|
9991 // Otherwise restore preexisting value |
|
9992 } else { |
|
9993 window[ callbackName ] = overwritten; |
|
9994 } |
8770 |
9995 |
8771 // Save back as free |
9996 // Save back as free |
8772 if ( s[ callbackName ] ) { |
9997 if ( s[ callbackName ] ) { |
8773 // make sure that re-using the options doesn't screw things around |
9998 |
|
9999 // Make sure that re-using the options doesn't screw things around |
8774 s.jsonpCallback = originalSettings.jsonpCallback; |
10000 s.jsonpCallback = originalSettings.jsonpCallback; |
8775 |
10001 |
8776 // save the callback name for future use |
10002 // Save the callback name for future use |
8777 oldCallbacks.push( callbackName ); |
10003 oldCallbacks.push( callbackName ); |
8778 } |
10004 } |
8779 |
10005 |
8780 // Call if it was a function and we have a response |
10006 // Call if it was a function and we have a response |
8781 if ( responseContainer && jQuery.isFunction( overwritten ) ) { |
10007 if ( responseContainer && isFunction( overwritten ) ) { |
8782 overwritten( responseContainer[ 0 ] ); |
10008 overwritten( responseContainer[ 0 ] ); |
8783 } |
10009 } |
8784 |
10010 |
8785 responseContainer = overwritten = undefined; |
10011 responseContainer = overwritten = undefined; |
8786 }); |
10012 } ); |
8787 |
10013 |
8788 // Delegate to script |
10014 // Delegate to script |
8789 return "script"; |
10015 return "script"; |
8790 } |
10016 } |
8791 }); |
10017 } ); |
8792 |
10018 |
8793 |
10019 |
8794 |
10020 |
8795 |
10021 |
8796 // data: string of html |
10022 // Support: Safari 8 only |
8797 // context (optional): If specified, the fragment will be created in this context, defaults to document |
10023 // In Safari 8 documents created via document.implementation.createHTMLDocument |
|
10024 // collapse sibling forms: the second one becomes a child of the first one. |
|
10025 // Because of that, this security measure has to be disabled in Safari 8. |
|
10026 // https://bugs.webkit.org/show_bug.cgi?id=137337 |
|
10027 support.createHTMLDocument = ( function() { |
|
10028 var body = document.implementation.createHTMLDocument( "" ).body; |
|
10029 body.innerHTML = "<form></form><form></form>"; |
|
10030 return body.childNodes.length === 2; |
|
10031 } )(); |
|
10032 |
|
10033 |
|
10034 // Argument "data" should be string of html |
|
10035 // context (optional): If specified, the fragment will be created in this context, |
|
10036 // defaults to document |
8798 // keepScripts (optional): If true, will include scripts passed in the html string |
10037 // keepScripts (optional): If true, will include scripts passed in the html string |
8799 jQuery.parseHTML = function( data, context, keepScripts ) { |
10038 jQuery.parseHTML = function( data, context, keepScripts ) { |
8800 if ( !data || typeof data !== "string" ) { |
10039 if ( typeof data !== "string" ) { |
8801 return null; |
10040 return []; |
8802 } |
10041 } |
8803 if ( typeof context === "boolean" ) { |
10042 if ( typeof context === "boolean" ) { |
8804 keepScripts = context; |
10043 keepScripts = context; |
8805 context = false; |
10044 context = false; |
8806 } |
10045 } |
8807 context = context || document; |
10046 |
8808 |
10047 var base, parsed, scripts; |
8809 var parsed = rsingleTag.exec( data ), |
10048 |
8810 scripts = !keepScripts && []; |
10049 if ( !context ) { |
|
10050 |
|
10051 // Stop scripts or inline event handlers from being executed immediately |
|
10052 // by using document.implementation |
|
10053 if ( support.createHTMLDocument ) { |
|
10054 context = document.implementation.createHTMLDocument( "" ); |
|
10055 |
|
10056 // Set the base href for the created document |
|
10057 // so any parsed elements with URLs |
|
10058 // are based on the document's URL (gh-2965) |
|
10059 base = context.createElement( "base" ); |
|
10060 base.href = document.location.href; |
|
10061 context.head.appendChild( base ); |
|
10062 } else { |
|
10063 context = document; |
|
10064 } |
|
10065 } |
|
10066 |
|
10067 parsed = rsingleTag.exec( data ); |
|
10068 scripts = !keepScripts && []; |
8811 |
10069 |
8812 // Single tag |
10070 // Single tag |
8813 if ( parsed ) { |
10071 if ( parsed ) { |
8814 return [ context.createElement( parsed[1] ) ]; |
10072 return [ context.createElement( parsed[ 1 ] ) ]; |
8815 } |
10073 } |
8816 |
10074 |
8817 parsed = jQuery.buildFragment( [ data ], context, scripts ); |
10075 parsed = buildFragment( [ data ], context, scripts ); |
8818 |
10076 |
8819 if ( scripts && scripts.length ) { |
10077 if ( scripts && scripts.length ) { |
8820 jQuery( scripts ).remove(); |
10078 jQuery( scripts ).remove(); |
8821 } |
10079 } |
8822 |
10080 |
8823 return jQuery.merge( [], parsed.childNodes ); |
10081 return jQuery.merge( [], parsed.childNodes ); |
8824 }; |
10082 }; |
8825 |
10083 |
8826 |
|
8827 // Keep a copy of the old load method |
|
8828 var _load = jQuery.fn.load; |
|
8829 |
10084 |
8830 /** |
10085 /** |
8831 * Load a url into a page |
10086 * Load a url into a page |
8832 */ |
10087 */ |
8833 jQuery.fn.load = function( url, params, callback ) { |
10088 jQuery.fn.load = function( url, params, callback ) { |
8834 if ( typeof url !== "string" && _load ) { |
|
8835 return _load.apply( this, arguments ); |
|
8836 } |
|
8837 |
|
8838 var selector, type, response, |
10089 var selector, type, response, |
8839 self = this, |
10090 self = this, |
8840 off = url.indexOf(" "); |
10091 off = url.indexOf( " " ); |
8841 |
10092 |
8842 if ( off >= 0 ) { |
10093 if ( off > -1 ) { |
8843 selector = jQuery.trim( url.slice( off ) ); |
10094 selector = stripAndCollapse( url.slice( off ) ); |
8844 url = url.slice( 0, off ); |
10095 url = url.slice( 0, off ); |
8845 } |
10096 } |
8846 |
10097 |
8847 // If it's a function |
10098 // If it's a function |
8848 if ( jQuery.isFunction( params ) ) { |
10099 if ( isFunction( params ) ) { |
8849 |
10100 |
8850 // We assume that it's the callback |
10101 // We assume that it's the callback |
8851 callback = params; |
10102 callback = params; |
8852 params = undefined; |
10103 params = undefined; |
8853 |
10104 |
8966 curElem.css( props ); |
10224 curElem.css( props ); |
8967 } |
10225 } |
8968 } |
10226 } |
8969 }; |
10227 }; |
8970 |
10228 |
8971 jQuery.fn.extend({ |
10229 jQuery.fn.extend( { |
|
10230 |
|
10231 // offset() relates an element's border box to the document origin |
8972 offset: function( options ) { |
10232 offset: function( options ) { |
|
10233 |
|
10234 // Preserve chaining for setter |
8973 if ( arguments.length ) { |
10235 if ( arguments.length ) { |
8974 return options === undefined ? |
10236 return options === undefined ? |
8975 this : |
10237 this : |
8976 this.each(function( i ) { |
10238 this.each( function( i ) { |
8977 jQuery.offset.setOffset( this, options, i ); |
10239 jQuery.offset.setOffset( this, options, i ); |
8978 }); |
10240 } ); |
8979 } |
10241 } |
8980 |
10242 |
8981 var docElem, win, |
10243 var rect, win, |
8982 elem = this[ 0 ], |
10244 elem = this[ 0 ]; |
8983 box = { top: 0, left: 0 }, |
10245 |
8984 doc = elem && elem.ownerDocument; |
10246 if ( !elem ) { |
8985 |
|
8986 if ( !doc ) { |
|
8987 return; |
10247 return; |
8988 } |
10248 } |
8989 |
10249 |
8990 docElem = doc.documentElement; |
10250 // Return zeros for disconnected and hidden (display: none) elements (gh-2310) |
8991 |
10251 // Support: IE <=11 only |
8992 // Make sure it's not a disconnected DOM node |
10252 // Running getBoundingClientRect on a |
8993 if ( !jQuery.contains( docElem, elem ) ) { |
10253 // disconnected node in IE throws an error |
8994 return box; |
10254 if ( !elem.getClientRects().length ) { |
8995 } |
10255 return { top: 0, left: 0 }; |
8996 |
10256 } |
8997 // Support: BlackBerry 5, iOS 3 (original iPhone) |
10257 |
8998 // If we don't have gBCR, just use 0,0 rather than error |
10258 // Get document-relative position by adding viewport scroll to viewport-relative gBCR |
8999 if ( typeof elem.getBoundingClientRect !== strundefined ) { |
10259 rect = elem.getBoundingClientRect(); |
9000 box = elem.getBoundingClientRect(); |
10260 win = elem.ownerDocument.defaultView; |
9001 } |
|
9002 win = getWindow( doc ); |
|
9003 return { |
10261 return { |
9004 top: box.top + win.pageYOffset - docElem.clientTop, |
10262 top: rect.top + win.pageYOffset, |
9005 left: box.left + win.pageXOffset - docElem.clientLeft |
10263 left: rect.left + win.pageXOffset |
9006 }; |
10264 }; |
9007 }, |
10265 }, |
9008 |
10266 |
|
10267 // position() relates an element's margin box to its offset parent's padding box |
|
10268 // This corresponds to the behavior of CSS absolute positioning |
9009 position: function() { |
10269 position: function() { |
9010 if ( !this[ 0 ] ) { |
10270 if ( !this[ 0 ] ) { |
9011 return; |
10271 return; |
9012 } |
10272 } |
9013 |
10273 |
9014 var offsetParent, offset, |
10274 var offsetParent, offset, doc, |
9015 elem = this[ 0 ], |
10275 elem = this[ 0 ], |
9016 parentOffset = { top: 0, left: 0 }; |
10276 parentOffset = { top: 0, left: 0 }; |
9017 |
10277 |
9018 // Fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is its only offset parent |
10278 // position:fixed elements are offset from the viewport, which itself always has zero offset |
9019 if ( jQuery.css( elem, "position" ) === "fixed" ) { |
10279 if ( jQuery.css( elem, "position" ) === "fixed" ) { |
9020 // Assume getBoundingClientRect is there when computed position is fixed |
10280 |
|
10281 // Assume position:fixed implies availability of getBoundingClientRect |
9021 offset = elem.getBoundingClientRect(); |
10282 offset = elem.getBoundingClientRect(); |
9022 |
10283 |
9023 } else { |
10284 } else { |
9024 // Get *real* offsetParent |
|
9025 offsetParent = this.offsetParent(); |
|
9026 |
|
9027 // Get correct offsets |
|
9028 offset = this.offset(); |
10285 offset = this.offset(); |
9029 if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) { |
10286 |
9030 parentOffset = offsetParent.offset(); |
10287 // Account for the *real* offset parent, which can be the document or its root element |
9031 } |
10288 // when a statically positioned element is identified |
9032 |
10289 doc = elem.ownerDocument; |
9033 // Add offsetParent borders |
10290 offsetParent = elem.offsetParent || doc.documentElement; |
9034 parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true ); |
10291 while ( offsetParent && |
9035 parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true ); |
10292 ( offsetParent === doc.body || offsetParent === doc.documentElement ) && |
|
10293 jQuery.css( offsetParent, "position" ) === "static" ) { |
|
10294 |
|
10295 offsetParent = offsetParent.parentNode; |
|
10296 } |
|
10297 if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) { |
|
10298 |
|
10299 // Incorporate borders into its offset, since they are outside its content origin |
|
10300 parentOffset = jQuery( offsetParent ).offset(); |
|
10301 parentOffset.top += jQuery.css( offsetParent, "borderTopWidth", true ); |
|
10302 parentOffset.left += jQuery.css( offsetParent, "borderLeftWidth", true ); |
|
10303 } |
9036 } |
10304 } |
9037 |
10305 |
9038 // Subtract parent offsets and element margins |
10306 // Subtract parent offsets and element margins |
9039 return { |
10307 return { |
9040 top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ), |
10308 top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ), |
9041 left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true ) |
10309 left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true ) |
9042 }; |
10310 }; |
9043 }, |
10311 }, |
9044 |
10312 |
|
10313 // This method will return documentElement in the following cases: |
|
10314 // 1) For the element inside the iframe without offsetParent, this method will return |
|
10315 // documentElement of the parent window |
|
10316 // 2) For the hidden or detached element |
|
10317 // 3) For body or html element, i.e. in case of the html node - it will return itself |
|
10318 // |
|
10319 // but those exceptions were never presented as a real life use-cases |
|
10320 // and might be considered as more preferable results. |
|
10321 // |
|
10322 // This logic, however, is not guaranteed and can change at any point in the future |
9045 offsetParent: function() { |
10323 offsetParent: function() { |
9046 return this.map(function() { |
10324 return this.map( function() { |
9047 var offsetParent = this.offsetParent || docElem; |
10325 var offsetParent = this.offsetParent; |
9048 |
10326 |
9049 while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && jQuery.css( offsetParent, "position" ) === "static" ) ) { |
10327 while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) { |
9050 offsetParent = offsetParent.offsetParent; |
10328 offsetParent = offsetParent.offsetParent; |
9051 } |
10329 } |
9052 |
10330 |
9053 return offsetParent || docElem; |
10331 return offsetParent || documentElement; |
9054 }); |
10332 } ); |
9055 } |
10333 } |
9056 }); |
10334 } ); |
9057 |
10335 |
9058 // Create scrollLeft and scrollTop methods |
10336 // Create scrollLeft and scrollTop methods |
9059 jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) { |
10337 jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) { |
9060 var top = "pageYOffset" === prop; |
10338 var top = "pageYOffset" === prop; |
9061 |
10339 |
9062 jQuery.fn[ method ] = function( val ) { |
10340 jQuery.fn[ method ] = function( val ) { |
9063 return access( this, function( elem, method, val ) { |
10341 return access( this, function( elem, method, val ) { |
9064 var win = getWindow( elem ); |
10342 |
|
10343 // Coalesce documents and windows |
|
10344 var win; |
|
10345 if ( isWindow( elem ) ) { |
|
10346 win = elem; |
|
10347 } else if ( elem.nodeType === 9 ) { |
|
10348 win = elem.defaultView; |
|
10349 } |
9065 |
10350 |
9066 if ( val === undefined ) { |
10351 if ( val === undefined ) { |
9067 return win ? win[ prop ] : elem[ method ]; |
10352 return win ? win[ prop ] : elem[ method ]; |
9068 } |
10353 } |
9069 |
10354 |
9070 if ( win ) { |
10355 if ( win ) { |
9071 win.scrollTo( |
10356 win.scrollTo( |
9072 !top ? val : window.pageXOffset, |
10357 !top ? val : win.pageXOffset, |
9073 top ? val : window.pageYOffset |
10358 top ? val : win.pageYOffset |
9074 ); |
10359 ); |
9075 |
10360 |
9076 } else { |
10361 } else { |
9077 elem[ method ] = val; |
10362 elem[ method ] = val; |
9078 } |
10363 } |
9079 }, method, val, arguments.length, null ); |
10364 }, method, val, arguments.length ); |
9080 }; |
10365 }; |
9081 }); |
10366 } ); |
9082 |
10367 |
9083 // Support: Safari<7+, Chrome<37+ |
10368 // Support: Safari <=7 - 9.1, Chrome <=37 - 49 |
9084 // Add the top/left cssHooks using jQuery.fn.position |
10369 // Add the top/left cssHooks using jQuery.fn.position |
9085 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084 |
10370 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084 |
9086 // Blink bug: https://code.google.com/p/chromium/issues/detail?id=229280 |
10371 // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347 |
9087 // getComputedStyle returns percent when specified for top/left/bottom/right; |
10372 // getComputedStyle returns percent when specified for top/left/bottom/right; |
9088 // rather than make the css module depend on the offset module, just check for it here |
10373 // rather than make the css module depend on the offset module, just check for it here |
9089 jQuery.each( [ "top", "left" ], function( i, prop ) { |
10374 jQuery.each( [ "top", "left" ], function( i, prop ) { |
9090 jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition, |
10375 jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition, |
9091 function( elem, computed ) { |
10376 function( elem, computed ) { |
9092 if ( computed ) { |
10377 if ( computed ) { |
9093 computed = curCSS( elem, prop ); |
10378 computed = curCSS( elem, prop ); |
|
10379 |
9094 // If curCSS returns percentage, fallback to offset |
10380 // If curCSS returns percentage, fallback to offset |
9095 return rnumnonpx.test( computed ) ? |
10381 return rnumnonpx.test( computed ) ? |
9096 jQuery( elem ).position()[ prop ] + "px" : |
10382 jQuery( elem ).position()[ prop ] + "px" : |
9097 computed; |
10383 computed; |
9098 } |
10384 } |
9099 } |
10385 } |
9100 ); |
10386 ); |
9101 }); |
10387 } ); |
9102 |
10388 |
9103 |
10389 |
9104 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods |
10390 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods |
9105 jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { |
10391 jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { |
9106 jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) { |
10392 jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, |
|
10393 function( defaultExtra, funcName ) { |
|
10394 |
9107 // Margin is only for outerHeight, outerWidth |
10395 // Margin is only for outerHeight, outerWidth |
9108 jQuery.fn[ funcName ] = function( margin, value ) { |
10396 jQuery.fn[ funcName ] = function( margin, value ) { |
9109 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ), |
10397 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ), |
9110 extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" ); |
10398 extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" ); |
9111 |
10399 |
9112 return access( this, function( elem, type, value ) { |
10400 return access( this, function( elem, type, value ) { |
9113 var doc; |
10401 var doc; |
9114 |
10402 |
9115 if ( jQuery.isWindow( elem ) ) { |
10403 if ( isWindow( elem ) ) { |
9116 // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there |
10404 |
9117 // isn't a whole lot we can do. See pull request at this URL for discussion: |
10405 // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729) |
9118 // https://github.com/jquery/jquery/pull/764 |
10406 return funcName.indexOf( "outer" ) === 0 ? |
9119 return elem.document.documentElement[ "client" + name ]; |
10407 elem[ "inner" + name ] : |
|
10408 elem.document.documentElement[ "client" + name ]; |
9120 } |
10409 } |
9121 |
10410 |
9122 // Get document width or height |
10411 // Get document width or height |
9123 if ( elem.nodeType === 9 ) { |
10412 if ( elem.nodeType === 9 ) { |
9124 doc = elem.documentElement; |
10413 doc = elem.documentElement; |
9131 doc[ "client" + name ] |
10420 doc[ "client" + name ] |
9132 ); |
10421 ); |
9133 } |
10422 } |
9134 |
10423 |
9135 return value === undefined ? |
10424 return value === undefined ? |
|
10425 |
9136 // Get width or height on the element, requesting but not forcing parseFloat |
10426 // Get width or height on the element, requesting but not forcing parseFloat |
9137 jQuery.css( elem, type, extra ) : |
10427 jQuery.css( elem, type, extra ) : |
9138 |
10428 |
9139 // Set width or height on the element |
10429 // Set width or height on the element |
9140 jQuery.style( elem, type, value, extra ); |
10430 jQuery.style( elem, type, value, extra ); |
9141 }, type, chainable ? margin : undefined, chainable, null ); |
10431 }, type, chainable ? margin : undefined, chainable ); |
9142 }; |
10432 }; |
9143 }); |
10433 } ); |
9144 }); |
10434 } ); |
9145 |
10435 |
9146 |
10436 |
9147 // The number of elements contained in the matched element set |
10437 jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " + |
9148 jQuery.fn.size = function() { |
10438 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + |
9149 return this.length; |
10439 "change select submit keydown keypress keyup contextmenu" ).split( " " ), |
|
10440 function( i, name ) { |
|
10441 |
|
10442 // Handle event binding |
|
10443 jQuery.fn[ name ] = function( data, fn ) { |
|
10444 return arguments.length > 0 ? |
|
10445 this.on( name, null, data, fn ) : |
|
10446 this.trigger( name ); |
|
10447 }; |
|
10448 } ); |
|
10449 |
|
10450 jQuery.fn.extend( { |
|
10451 hover: function( fnOver, fnOut ) { |
|
10452 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); |
|
10453 } |
|
10454 } ); |
|
10455 |
|
10456 |
|
10457 |
|
10458 |
|
10459 jQuery.fn.extend( { |
|
10460 |
|
10461 bind: function( types, data, fn ) { |
|
10462 return this.on( types, null, data, fn ); |
|
10463 }, |
|
10464 unbind: function( types, fn ) { |
|
10465 return this.off( types, null, fn ); |
|
10466 }, |
|
10467 |
|
10468 delegate: function( selector, types, data, fn ) { |
|
10469 return this.on( types, selector, data, fn ); |
|
10470 }, |
|
10471 undelegate: function( selector, types, fn ) { |
|
10472 |
|
10473 // ( namespace ) or ( selector, types [, fn] ) |
|
10474 return arguments.length === 1 ? |
|
10475 this.off( selector, "**" ) : |
|
10476 this.off( types, selector || "**", fn ); |
|
10477 } |
|
10478 } ); |
|
10479 |
|
10480 // Bind a function to a context, optionally partially applying any |
|
10481 // arguments. |
|
10482 // jQuery.proxy is deprecated to promote standards (specifically Function#bind) |
|
10483 // However, it is not slated for removal any time soon |
|
10484 jQuery.proxy = function( fn, context ) { |
|
10485 var tmp, args, proxy; |
|
10486 |
|
10487 if ( typeof context === "string" ) { |
|
10488 tmp = fn[ context ]; |
|
10489 context = fn; |
|
10490 fn = tmp; |
|
10491 } |
|
10492 |
|
10493 // Quick check to determine if target is callable, in the spec |
|
10494 // this throws a TypeError, but we will just return undefined. |
|
10495 if ( !isFunction( fn ) ) { |
|
10496 return undefined; |
|
10497 } |
|
10498 |
|
10499 // Simulated bind |
|
10500 args = slice.call( arguments, 2 ); |
|
10501 proxy = function() { |
|
10502 return fn.apply( context || this, args.concat( slice.call( arguments ) ) ); |
|
10503 }; |
|
10504 |
|
10505 // Set the guid of unique handler to the same of original handler, so it can be removed |
|
10506 proxy.guid = fn.guid = fn.guid || jQuery.guid++; |
|
10507 |
|
10508 return proxy; |
9150 }; |
10509 }; |
9151 |
10510 |
9152 jQuery.fn.andSelf = jQuery.fn.addBack; |
10511 jQuery.holdReady = function( hold ) { |
|
10512 if ( hold ) { |
|
10513 jQuery.readyWait++; |
|
10514 } else { |
|
10515 jQuery.ready( true ); |
|
10516 } |
|
10517 }; |
|
10518 jQuery.isArray = Array.isArray; |
|
10519 jQuery.parseJSON = JSON.parse; |
|
10520 jQuery.nodeName = nodeName; |
|
10521 jQuery.isFunction = isFunction; |
|
10522 jQuery.isWindow = isWindow; |
|
10523 jQuery.camelCase = camelCase; |
|
10524 jQuery.type = toType; |
|
10525 |
|
10526 jQuery.now = Date.now; |
|
10527 |
|
10528 jQuery.isNumeric = function( obj ) { |
|
10529 |
|
10530 // As of jQuery 3.0, isNumeric is limited to |
|
10531 // strings and numbers (primitives or objects) |
|
10532 // that can be coerced to finite numbers (gh-2662) |
|
10533 var type = jQuery.type( obj ); |
|
10534 return ( type === "number" || type === "string" ) && |
|
10535 |
|
10536 // parseFloat NaNs numeric-cast false positives ("") |
|
10537 // ...but misinterprets leading-number strings, particularly hex literals ("0x...") |
|
10538 // subtraction forces infinities to NaN |
|
10539 !isNaN( obj - parseFloat( obj ) ); |
|
10540 }; |
9153 |
10541 |
9154 |
10542 |
9155 |
10543 |
9156 |
10544 |
9157 // Register as a named AMD module, since jQuery can be concatenated with other |
10545 // Register as a named AMD module, since jQuery can be concatenated with other |