1 | /*! |
---|
2 | * jQuery Migrate - v1.4.1 - 2016-05-19 |
---|
3 | * Copyright jQuery Foundation and other contributors |
---|
4 | */ |
---|
5 | (function( jQuery, window, undefined ) { |
---|
6 | // See http://bugs.jquery.com/ticket/13335 |
---|
7 | // "use strict"; |
---|
8 | |
---|
9 | |
---|
10 | jQuery.migrateVersion = "1.4.1"; |
---|
11 | |
---|
12 | |
---|
13 | var warnedAbout = {}; |
---|
14 | |
---|
15 | // List of warnings already given; public read only |
---|
16 | jQuery.migrateWarnings = []; |
---|
17 | |
---|
18 | // Set to true to prevent console output; migrateWarnings still maintained |
---|
19 | // jQuery.migrateMute = false; |
---|
20 | |
---|
21 | // Show a message on the console so devs know we're active |
---|
22 | if ( window.console && window.console.log ) { |
---|
23 | window.console.log( "JQMIGRATE: Migrate is installed" + |
---|
24 | ( jQuery.migrateMute ? "" : " with logging active" ) + |
---|
25 | ", version " + jQuery.migrateVersion ); |
---|
26 | } |
---|
27 | |
---|
28 | // Set to false to disable traces that appear with warnings |
---|
29 | if ( jQuery.migrateTrace === undefined ) { |
---|
30 | jQuery.migrateTrace = true; |
---|
31 | } |
---|
32 | |
---|
33 | // Forget any warnings we've already given; public |
---|
34 | jQuery.migrateReset = function() { |
---|
35 | warnedAbout = {}; |
---|
36 | jQuery.migrateWarnings.length = 0; |
---|
37 | }; |
---|
38 | |
---|
39 | function migrateWarn( msg) { |
---|
40 | var console = window.console; |
---|
41 | if ( !warnedAbout[ msg ] ) { |
---|
42 | warnedAbout[ msg ] = true; |
---|
43 | jQuery.migrateWarnings.push( msg ); |
---|
44 | if ( console && console.warn && !jQuery.migrateMute ) { |
---|
45 | console.warn( "JQMIGRATE: " + msg ); |
---|
46 | if ( jQuery.migrateTrace && console.trace ) { |
---|
47 | console.trace(); |
---|
48 | } |
---|
49 | } |
---|
50 | } |
---|
51 | } |
---|
52 | |
---|
53 | function migrateWarnProp( obj, prop, value, msg ) { |
---|
54 | if ( Object.defineProperty ) { |
---|
55 | // On ES5 browsers (non-oldIE), warn if the code tries to get prop; |
---|
56 | // allow property to be overwritten in case some other plugin wants it |
---|
57 | try { |
---|
58 | Object.defineProperty( obj, prop, { |
---|
59 | configurable: true, |
---|
60 | enumerable: true, |
---|
61 | get: function() { |
---|
62 | migrateWarn( msg ); |
---|
63 | return value; |
---|
64 | }, |
---|
65 | set: function( newValue ) { |
---|
66 | migrateWarn( msg ); |
---|
67 | value = newValue; |
---|
68 | } |
---|
69 | }); |
---|
70 | return; |
---|
71 | } catch( err ) { |
---|
72 | // IE8 is a dope about Object.defineProperty, can't warn there |
---|
73 | } |
---|
74 | } |
---|
75 | |
---|
76 | // Non-ES5 (or broken) browser; just set the property |
---|
77 | jQuery._definePropertyBroken = true; |
---|
78 | obj[ prop ] = value; |
---|
79 | } |
---|
80 | |
---|
81 | if ( document.compatMode === "BackCompat" ) { |
---|
82 | // jQuery has never supported or tested Quirks Mode |
---|
83 | migrateWarn( "jQuery is not compatible with Quirks Mode" ); |
---|
84 | } |
---|
85 | |
---|
86 | |
---|
87 | var attrFn = jQuery( "<input/>", { size: 1 } ).attr("size") && jQuery.attrFn, |
---|
88 | oldAttr = jQuery.attr, |
---|
89 | valueAttrGet = jQuery.attrHooks.value && jQuery.attrHooks.value.get || |
---|
90 | function() { return null; }, |
---|
91 | valueAttrSet = jQuery.attrHooks.value && jQuery.attrHooks.value.set || |
---|
92 | function() { return undefined; }, |
---|
93 | rnoType = /^(?:input|button)$/i, |
---|
94 | rnoAttrNodeType = /^[238]$/, |
---|
95 | rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i, |
---|
96 | ruseDefault = /^(?:checked|selected)$/i; |
---|
97 | |
---|
98 | // jQuery.attrFn |
---|
99 | migrateWarnProp( jQuery, "attrFn", attrFn || {}, "jQuery.attrFn is deprecated" ); |
---|
100 | |
---|
101 | jQuery.attr = function( elem, name, value, pass ) { |
---|
102 | var lowerName = name.toLowerCase(), |
---|
103 | nType = elem && elem.nodeType; |
---|
104 | |
---|
105 | if ( pass ) { |
---|
106 | // Since pass is used internally, we only warn for new jQuery |
---|
107 | // versions where there isn't a pass arg in the formal params |
---|
108 | if ( oldAttr.length < 4 ) { |
---|
109 | migrateWarn("jQuery.fn.attr( props, pass ) is deprecated"); |
---|
110 | } |
---|
111 | if ( elem && !rnoAttrNodeType.test( nType ) && |
---|
112 | (attrFn ? name in attrFn : jQuery.isFunction(jQuery.fn[name])) ) { |
---|
113 | return jQuery( elem )[ name ]( value ); |
---|
114 | } |
---|
115 | } |
---|
116 | |
---|
117 | // Warn if user tries to set `type`, since it breaks on IE 6/7/8; by checking |
---|
118 | // for disconnected elements we don't warn on $( "<button>", { type: "button" } ). |
---|
119 | if ( name === "type" && value !== undefined && rnoType.test( elem.nodeName ) && elem.parentNode ) { |
---|
120 | migrateWarn("Can't change the 'type' of an input or button in IE 6/7/8"); |
---|
121 | } |
---|
122 | |
---|
123 | // Restore boolHook for boolean property/attribute synchronization |
---|
124 | if ( !jQuery.attrHooks[ lowerName ] && rboolean.test( lowerName ) ) { |
---|
125 | jQuery.attrHooks[ lowerName ] = { |
---|
126 | get: function( elem, name ) { |
---|
127 | // Align boolean attributes with corresponding properties |
---|
128 | // Fall back to attribute presence where some booleans are not supported |
---|
129 | var attrNode, |
---|
130 | property = jQuery.prop( elem, name ); |
---|
131 | return property === true || typeof property !== "boolean" && |
---|
132 | ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ? |
---|
133 | |
---|
134 | name.toLowerCase() : |
---|
135 | undefined; |
---|
136 | }, |
---|
137 | set: function( elem, value, name ) { |
---|
138 | var propName; |
---|
139 | if ( value === false ) { |
---|
140 | // Remove boolean attributes when set to false |
---|
141 | jQuery.removeAttr( elem, name ); |
---|
142 | } else { |
---|
143 | // value is true since we know at this point it's type boolean and not false |
---|
144 | // Set boolean attributes to the same name and set the DOM property |
---|
145 | propName = jQuery.propFix[ name ] || name; |
---|
146 | if ( propName in elem ) { |
---|
147 | // Only set the IDL specifically if it already exists on the element |
---|
148 | elem[ propName ] = true; |
---|
149 | } |
---|
150 | |
---|
151 | elem.setAttribute( name, name.toLowerCase() ); |
---|
152 | } |
---|
153 | return name; |
---|
154 | } |
---|
155 | }; |
---|
156 | |
---|
157 | // Warn only for attributes that can remain distinct from their properties post-1.9 |
---|
158 | if ( ruseDefault.test( lowerName ) ) { |
---|
159 | migrateWarn( "jQuery.fn.attr('" + lowerName + "') might use property instead of attribute" ); |
---|
160 | } |
---|
161 | } |
---|
162 | |
---|
163 | return oldAttr.call( jQuery, elem, name, value ); |
---|
164 | }; |
---|
165 | |
---|
166 | // attrHooks: value |
---|
167 | jQuery.attrHooks.value = { |
---|
168 | get: function( elem, name ) { |
---|
169 | var nodeName = ( elem.nodeName || "" ).toLowerCase(); |
---|
170 | if ( nodeName === "button" ) { |
---|
171 | return valueAttrGet.apply( this, arguments ); |
---|
172 | } |
---|
173 | if ( nodeName !== "input" && nodeName !== "option" ) { |
---|
174 | migrateWarn("jQuery.fn.attr('value') no longer gets properties"); |
---|
175 | } |
---|
176 | return name in elem ? |
---|
177 | elem.value : |
---|
178 | null; |
---|
179 | }, |
---|
180 | set: function( elem, value ) { |
---|
181 | var nodeName = ( elem.nodeName || "" ).toLowerCase(); |
---|
182 | if ( nodeName === "button" ) { |
---|
183 | return valueAttrSet.apply( this, arguments ); |
---|
184 | } |
---|
185 | if ( nodeName !== "input" && nodeName !== "option" ) { |
---|
186 | migrateWarn("jQuery.fn.attr('value', val) no longer sets properties"); |
---|
187 | } |
---|
188 | // Does not return so that setAttribute is also used |
---|
189 | elem.value = value; |
---|
190 | } |
---|
191 | }; |
---|
192 | |
---|
193 | |
---|
194 | var matched, browser, |
---|
195 | oldInit = jQuery.fn.init, |
---|
196 | oldFind = jQuery.find, |
---|
197 | oldParseJSON = jQuery.parseJSON, |
---|
198 | rspaceAngle = /^\s*</, |
---|
199 | rattrHashTest = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/, |
---|
200 | rattrHashGlob = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/g, |
---|
201 | // Note: XSS check is done below after string is trimmed |
---|
202 | rquickExpr = /^([^<]*)(<[\w\W]+>)([^>]*)$/; |
---|
203 | |
---|
204 | // $(html) "looks like html" rule change |
---|
205 | jQuery.fn.init = function( selector, context, rootjQuery ) { |
---|
206 | var match, ret; |
---|
207 | |
---|
208 | if ( selector && typeof selector === "string" ) { |
---|
209 | if ( !jQuery.isPlainObject( context ) && |
---|
210 | (match = rquickExpr.exec( jQuery.trim( selector ) )) && match[ 0 ] ) { |
---|
211 | |
---|
212 | // This is an HTML string according to the "old" rules; is it still? |
---|
213 | if ( !rspaceAngle.test( selector ) ) { |
---|
214 | migrateWarn("$(html) HTML strings must start with '<' character"); |
---|
215 | } |
---|
216 | if ( match[ 3 ] ) { |
---|
217 | migrateWarn("$(html) HTML text after last tag is ignored"); |
---|
218 | } |
---|
219 | |
---|
220 | // Consistently reject any HTML-like string starting with a hash (gh-9521) |
---|
221 | // Note that this may break jQuery 1.6.x code that otherwise would work. |
---|
222 | if ( match[ 0 ].charAt( 0 ) === "#" ) { |
---|
223 | migrateWarn("HTML string cannot start with a '#' character"); |
---|
224 | jQuery.error("JQMIGRATE: Invalid selector string (XSS)"); |
---|
225 | } |
---|
226 | |
---|
227 | // Now process using loose rules; let pre-1.8 play too |
---|
228 | // Is this a jQuery context? parseHTML expects a DOM element (#178) |
---|
229 | if ( context && context.context && context.context.nodeType ) { |
---|
230 | context = context.context; |
---|
231 | } |
---|
232 | |
---|
233 | if ( jQuery.parseHTML ) { |
---|
234 | return oldInit.call( this, |
---|
235 | jQuery.parseHTML( match[ 2 ], context && context.ownerDocument || |
---|
236 | context || document, true ), context, rootjQuery ); |
---|
237 | } |
---|
238 | } |
---|
239 | } |
---|
240 | |
---|
241 | ret = oldInit.apply( this, arguments ); |
---|
242 | |
---|
243 | // Fill in selector and context properties so .live() works |
---|
244 | if ( selector && selector.selector !== undefined ) { |
---|
245 | // A jQuery object, copy its properties |
---|
246 | ret.selector = selector.selector; |
---|
247 | ret.context = selector.context; |
---|
248 | |
---|
249 | } else { |
---|
250 | ret.selector = typeof selector === "string" ? selector : ""; |
---|
251 | if ( selector ) { |
---|
252 | ret.context = selector.nodeType? selector : context || document; |
---|
253 | } |
---|
254 | } |
---|
255 | |
---|
256 | return ret; |
---|
257 | }; |
---|
258 | jQuery.fn.init.prototype = jQuery.fn; |
---|
259 | |
---|
260 | jQuery.find = function( selector ) { |
---|
261 | var args = Array.prototype.slice.call( arguments ); |
---|
262 | |
---|
263 | // Support: PhantomJS 1.x |
---|
264 | // String#match fails to match when used with a //g RegExp, only on some strings |
---|
265 | if ( typeof selector === "string" && rattrHashTest.test( selector ) ) { |
---|
266 | |
---|
267 | // The nonstandard and undocumented unquoted-hash was removed in jQuery 1.12.0 |
---|
268 | // First see if qS thinks it's a valid selector, if so avoid a false positive |
---|
269 | try { |
---|
270 | document.querySelector( selector ); |
---|
271 | } catch ( err1 ) { |
---|
272 | |
---|
273 | // Didn't *look* valid to qSA, warn and try quoting what we think is the value |
---|
274 | selector = selector.replace( rattrHashGlob, function( _, attr, op, value ) { |
---|
275 | return "[" + attr + op + "\"" + value + "\"]"; |
---|
276 | } ); |
---|
277 | |
---|
278 | // If the regexp *may* have created an invalid selector, don't update it |
---|
279 | // Note that there may be false alarms if selector uses jQuery extensions |
---|
280 | try { |
---|
281 | document.querySelector( selector ); |
---|
282 | migrateWarn( "Attribute selector with '#' must be quoted: " + args[ 0 ] ); |
---|
283 | args[ 0 ] = selector; |
---|
284 | } catch ( err2 ) { |
---|
285 | migrateWarn( "Attribute selector with '#' was not fixed: " + args[ 0 ] ); |
---|
286 | } |
---|
287 | } |
---|
288 | } |
---|
289 | |
---|
290 | return oldFind.apply( this, args ); |
---|
291 | }; |
---|
292 | |
---|
293 | // Copy properties attached to original jQuery.find method (e.g. .attr, .isXML) |
---|
294 | var findProp; |
---|
295 | for ( findProp in oldFind ) { |
---|
296 | if ( Object.prototype.hasOwnProperty.call( oldFind, findProp ) ) { |
---|
297 | jQuery.find[ findProp ] = oldFind[ findProp ]; |
---|
298 | } |
---|
299 | } |
---|
300 | |
---|
301 | // Let $.parseJSON(falsy_value) return null |
---|
302 | jQuery.parseJSON = function( json ) { |
---|
303 | if ( !json ) { |
---|
304 | migrateWarn("jQuery.parseJSON requires a valid JSON string"); |
---|
305 | return null; |
---|
306 | } |
---|
307 | return oldParseJSON.apply( this, arguments ); |
---|
308 | }; |
---|
309 | |
---|
310 | jQuery.uaMatch = function( ua ) { |
---|
311 | ua = ua.toLowerCase(); |
---|
312 | |
---|
313 | var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) || |
---|
314 | /(webkit)[ \/]([\w.]+)/.exec( ua ) || |
---|
315 | /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) || |
---|
316 | /(msie) ([\w.]+)/.exec( ua ) || |
---|
317 | ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) || |
---|
318 | []; |
---|
319 | |
---|
320 | return { |
---|
321 | browser: match[ 1 ] || "", |
---|
322 | version: match[ 2 ] || "0" |
---|
323 | }; |
---|
324 | }; |
---|
325 | |
---|
326 | // Don't clobber any existing jQuery.browser in case it's different |
---|
327 | if ( !jQuery.browser ) { |
---|
328 | matched = jQuery.uaMatch( navigator.userAgent ); |
---|
329 | browser = {}; |
---|
330 | |
---|
331 | if ( matched.browser ) { |
---|
332 | browser[ matched.browser ] = true; |
---|
333 | browser.version = matched.version; |
---|
334 | } |
---|
335 | |
---|
336 | // Chrome is Webkit, but Webkit is also Safari. |
---|
337 | if ( browser.chrome ) { |
---|
338 | browser.webkit = true; |
---|
339 | } else if ( browser.webkit ) { |
---|
340 | browser.safari = true; |
---|
341 | } |
---|
342 | |
---|
343 | jQuery.browser = browser; |
---|
344 | } |
---|
345 | |
---|
346 | // Warn if the code tries to get jQuery.browser |
---|
347 | migrateWarnProp( jQuery, "browser", jQuery.browser, "jQuery.browser is deprecated" ); |
---|
348 | |
---|
349 | // jQuery.boxModel deprecated in 1.3, jQuery.support.boxModel deprecated in 1.7 |
---|
350 | jQuery.boxModel = jQuery.support.boxModel = (document.compatMode === "CSS1Compat"); |
---|
351 | migrateWarnProp( jQuery, "boxModel", jQuery.boxModel, "jQuery.boxModel is deprecated" ); |
---|
352 | migrateWarnProp( jQuery.support, "boxModel", jQuery.support.boxModel, "jQuery.support.boxModel is deprecated" ); |
---|
353 | |
---|
354 | jQuery.sub = function() { |
---|
355 | function jQuerySub( selector, context ) { |
---|
356 | return new jQuerySub.fn.init( selector, context ); |
---|
357 | } |
---|
358 | jQuery.extend( true, jQuerySub, this ); |
---|
359 | jQuerySub.superclass = this; |
---|
360 | jQuerySub.fn = jQuerySub.prototype = this(); |
---|
361 | jQuerySub.fn.constructor = jQuerySub; |
---|
362 | jQuerySub.sub = this.sub; |
---|
363 | jQuerySub.fn.init = function init( selector, context ) { |
---|
364 | var instance = jQuery.fn.init.call( this, selector, context, rootjQuerySub ); |
---|
365 | return instance instanceof jQuerySub ? |
---|
366 | instance : |
---|
367 | jQuerySub( instance ); |
---|
368 | }; |
---|
369 | jQuerySub.fn.init.prototype = jQuerySub.fn; |
---|
370 | var rootjQuerySub = jQuerySub(document); |
---|
371 | migrateWarn( "jQuery.sub() is deprecated" ); |
---|
372 | return jQuerySub; |
---|
373 | }; |
---|
374 | |
---|
375 | // The number of elements contained in the matched element set |
---|
376 | jQuery.fn.size = function() { |
---|
377 | migrateWarn( "jQuery.fn.size() is deprecated; use the .length property" ); |
---|
378 | return this.length; |
---|
379 | }; |
---|
380 | |
---|
381 | |
---|
382 | var internalSwapCall = false; |
---|
383 | |
---|
384 | // If this version of jQuery has .swap(), don't false-alarm on internal uses |
---|
385 | if ( jQuery.swap ) { |
---|
386 | jQuery.each( [ "height", "width", "reliableMarginRight" ], function( _, name ) { |
---|
387 | var oldHook = jQuery.cssHooks[ name ] && jQuery.cssHooks[ name ].get; |
---|
388 | |
---|
389 | if ( oldHook ) { |
---|
390 | jQuery.cssHooks[ name ].get = function() { |
---|
391 | var ret; |
---|
392 | |
---|
393 | internalSwapCall = true; |
---|
394 | ret = oldHook.apply( this, arguments ); |
---|
395 | internalSwapCall = false; |
---|
396 | return ret; |
---|
397 | }; |
---|
398 | } |
---|
399 | }); |
---|
400 | } |
---|
401 | |
---|
402 | jQuery.swap = function( elem, options, callback, args ) { |
---|
403 | var ret, name, |
---|
404 | old = {}; |
---|
405 | |
---|
406 | if ( !internalSwapCall ) { |
---|
407 | migrateWarn( "jQuery.swap() is undocumented and deprecated" ); |
---|
408 | } |
---|
409 | |
---|
410 | // Remember the old values, and insert the new ones |
---|
411 | for ( name in options ) { |
---|
412 | old[ name ] = elem.style[ name ]; |
---|
413 | elem.style[ name ] = options[ name ]; |
---|
414 | } |
---|
415 | |
---|
416 | ret = callback.apply( elem, args || [] ); |
---|
417 | |
---|
418 | // Revert the old values |
---|
419 | for ( name in options ) { |
---|
420 | elem.style[ name ] = old[ name ]; |
---|
421 | } |
---|
422 | |
---|
423 | return ret; |
---|
424 | }; |
---|
425 | |
---|
426 | |
---|
427 | // Ensure that $.ajax gets the new parseJSON defined in core.js |
---|
428 | jQuery.ajaxSetup({ |
---|
429 | converters: { |
---|
430 | "text json": jQuery.parseJSON |
---|
431 | } |
---|
432 | }); |
---|
433 | |
---|
434 | |
---|
435 | var oldFnData = jQuery.fn.data; |
---|
436 | |
---|
437 | jQuery.fn.data = function( name ) { |
---|
438 | var ret, evt, |
---|
439 | elem = this[0]; |
---|
440 | |
---|
441 | // Handles 1.7 which has this behavior and 1.8 which doesn't |
---|
442 | if ( elem && name === "events" && arguments.length === 1 ) { |
---|
443 | ret = jQuery.data( elem, name ); |
---|
444 | evt = jQuery._data( elem, name ); |
---|
445 | if ( ( ret === undefined || ret === evt ) && evt !== undefined ) { |
---|
446 | migrateWarn("Use of jQuery.fn.data('events') is deprecated"); |
---|
447 | return evt; |
---|
448 | } |
---|
449 | } |
---|
450 | return oldFnData.apply( this, arguments ); |
---|
451 | }; |
---|
452 | |
---|
453 | |
---|
454 | var rscriptType = /\/(java|ecma)script/i; |
---|
455 | |
---|
456 | // Since jQuery.clean is used internally on older versions, we only shim if it's missing |
---|
457 | if ( !jQuery.clean ) { |
---|
458 | jQuery.clean = function( elems, context, fragment, scripts ) { |
---|
459 | // Set context per 1.8 logic |
---|
460 | context = context || document; |
---|
461 | context = !context.nodeType && context[0] || context; |
---|
462 | context = context.ownerDocument || context; |
---|
463 | |
---|
464 | migrateWarn("jQuery.clean() is deprecated"); |
---|
465 | |
---|
466 | var i, elem, handleScript, jsTags, |
---|
467 | ret = []; |
---|
468 | |
---|
469 | jQuery.merge( ret, jQuery.buildFragment( elems, context ).childNodes ); |
---|
470 | |
---|
471 | // Complex logic lifted directly from jQuery 1.8 |
---|
472 | if ( fragment ) { |
---|
473 | // Special handling of each script element |
---|
474 | handleScript = function( elem ) { |
---|
475 | // Check if we consider it executable |
---|
476 | if ( !elem.type || rscriptType.test( elem.type ) ) { |
---|
477 | // Detach the script and store it in the scripts array (if provided) or the fragment |
---|
478 | // Return truthy to indicate that it has been handled |
---|
479 | return scripts ? |
---|
480 | scripts.push( elem.parentNode ? elem.parentNode.removeChild( elem ) : elem ) : |
---|
481 | fragment.appendChild( elem ); |
---|
482 | } |
---|
483 | }; |
---|
484 | |
---|
485 | for ( i = 0; (elem = ret[i]) != null; i++ ) { |
---|
486 | // Check if we're done after handling an executable script |
---|
487 | if ( !( jQuery.nodeName( elem, "script" ) && handleScript( elem ) ) ) { |
---|
488 | // Append to fragment and handle embedded scripts |
---|
489 | fragment.appendChild( elem ); |
---|
490 | if ( typeof elem.getElementsByTagName !== "undefined" ) { |
---|
491 | // handleScript alters the DOM, so use jQuery.merge to ensure snapshot iteration |
---|
492 | jsTags = jQuery.grep( jQuery.merge( [], elem.getElementsByTagName("script") ), handleScript ); |
---|
493 | |
---|
494 | // Splice the scripts into ret after their former ancestor and advance our index beyond them |
---|
495 | ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) ); |
---|
496 | i += jsTags.length; |
---|
497 | } |
---|
498 | } |
---|
499 | } |
---|
500 | } |
---|
501 | |
---|
502 | return ret; |
---|
503 | }; |
---|
504 | } |
---|
505 | |
---|
506 | var eventAdd = jQuery.event.add, |
---|
507 | eventRemove = jQuery.event.remove, |
---|
508 | eventTrigger = jQuery.event.trigger, |
---|
509 | oldToggle = jQuery.fn.toggle, |
---|
510 | oldLive = jQuery.fn.live, |
---|
511 | oldDie = jQuery.fn.die, |
---|
512 | oldLoad = jQuery.fn.load, |
---|
513 | ajaxEvents = "ajaxStart|ajaxStop|ajaxSend|ajaxComplete|ajaxError|ajaxSuccess", |
---|
514 | rajaxEvent = new RegExp( "\\b(?:" + ajaxEvents + ")\\b" ), |
---|
515 | rhoverHack = /(?:^|\s)hover(\.\S+|)\b/, |
---|
516 | hoverHack = function( events ) { |
---|
517 | if ( typeof( events ) !== "string" || jQuery.event.special.hover ) { |
---|
518 | return events; |
---|
519 | } |
---|
520 | if ( rhoverHack.test( events ) ) { |
---|
521 | migrateWarn("'hover' pseudo-event is deprecated, use 'mouseenter mouseleave'"); |
---|
522 | } |
---|
523 | return events && events.replace( rhoverHack, "mouseenter$1 mouseleave$1" ); |
---|
524 | }; |
---|
525 | |
---|
526 | // Event props removed in 1.9, put them back if needed; no practical way to warn them |
---|
527 | if ( jQuery.event.props && jQuery.event.props[ 0 ] !== "attrChange" ) { |
---|
528 | jQuery.event.props.unshift( "attrChange", "attrName", "relatedNode", "srcElement" ); |
---|
529 | } |
---|
530 | |
---|
531 | // Undocumented jQuery.event.handle was "deprecated" in jQuery 1.7 |
---|
532 | if ( jQuery.event.dispatch ) { |
---|
533 | migrateWarnProp( jQuery.event, "handle", jQuery.event.dispatch, "jQuery.event.handle is undocumented and deprecated" ); |
---|
534 | } |
---|
535 | |
---|
536 | // Support for 'hover' pseudo-event and ajax event warnings |
---|
537 | jQuery.event.add = function( elem, types, handler, data, selector ){ |
---|
538 | if ( elem !== document && rajaxEvent.test( types ) ) { |
---|
539 | migrateWarn( "AJAX events should be attached to document: " + types ); |
---|
540 | } |
---|
541 | eventAdd.call( this, elem, hoverHack( types || "" ), handler, data, selector ); |
---|
542 | }; |
---|
543 | jQuery.event.remove = function( elem, types, handler, selector, mappedTypes ){ |
---|
544 | eventRemove.call( this, elem, hoverHack( types ) || "", handler, selector, mappedTypes ); |
---|
545 | }; |
---|
546 | |
---|
547 | jQuery.each( [ "load", "unload", "error" ], function( _, name ) { |
---|
548 | |
---|
549 | jQuery.fn[ name ] = function() { |
---|
550 | var args = Array.prototype.slice.call( arguments, 0 ); |
---|
551 | |
---|
552 | // If this is an ajax load() the first arg should be the string URL; |
---|
553 | // technically this could also be the "Anything" arg of the event .load() |
---|
554 | // which just goes to show why this dumb signature has been deprecated! |
---|
555 | // jQuery custom builds that exclude the Ajax module justifiably die here. |
---|
556 | if ( name === "load" && typeof args[ 0 ] === "string" ) { |
---|
557 | return oldLoad.apply( this, args ); |
---|
558 | } |
---|
559 | |
---|
560 | migrateWarn( "jQuery.fn." + name + "() is deprecated" ); |
---|
561 | |
---|
562 | args.splice( 0, 0, name ); |
---|
563 | if ( arguments.length ) { |
---|
564 | return this.bind.apply( this, args ); |
---|
565 | } |
---|
566 | |
---|
567 | // Use .triggerHandler here because: |
---|
568 | // - load and unload events don't need to bubble, only applied to window or image |
---|
569 | // - error event should not bubble to window, although it does pre-1.7 |
---|
570 | // See http://bugs.jquery.com/ticket/11820 |
---|
571 | this.triggerHandler.apply( this, args ); |
---|
572 | return this; |
---|
573 | }; |
---|
574 | |
---|
575 | }); |
---|
576 | |
---|
577 | jQuery.fn.toggle = function( fn, fn2 ) { |
---|
578 | |
---|
579 | // Don't mess with animation or css toggles |
---|
580 | if ( !jQuery.isFunction( fn ) || !jQuery.isFunction( fn2 ) ) { |
---|
581 | return oldToggle.apply( this, arguments ); |
---|
582 | } |
---|
583 | migrateWarn("jQuery.fn.toggle(handler, handler...) is deprecated"); |
---|
584 | |
---|
585 | // Save reference to arguments for access in closure |
---|
586 | var args = arguments, |
---|
587 | guid = fn.guid || jQuery.guid++, |
---|
588 | i = 0, |
---|
589 | toggler = function( event ) { |
---|
590 | // Figure out which function to execute |
---|
591 | var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i; |
---|
592 | jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 ); |
---|
593 | |
---|
594 | // Make sure that clicks stop |
---|
595 | event.preventDefault(); |
---|
596 | |
---|
597 | // and execute the function |
---|
598 | return args[ lastToggle ].apply( this, arguments ) || false; |
---|
599 | }; |
---|
600 | |
---|
601 | // link all the functions, so any of them can unbind this click handler |
---|
602 | toggler.guid = guid; |
---|
603 | while ( i < args.length ) { |
---|
604 | args[ i++ ].guid = guid; |
---|
605 | } |
---|
606 | |
---|
607 | return this.click( toggler ); |
---|
608 | }; |
---|
609 | |
---|
610 | jQuery.fn.live = function( types, data, fn ) { |
---|
611 | migrateWarn("jQuery.fn.live() is deprecated"); |
---|
612 | if ( oldLive ) { |
---|
613 | return oldLive.apply( this, arguments ); |
---|
614 | } |
---|
615 | jQuery( this.context ).on( types, this.selector, data, fn ); |
---|
616 | return this; |
---|
617 | }; |
---|
618 | |
---|
619 | jQuery.fn.die = function( types, fn ) { |
---|
620 | migrateWarn("jQuery.fn.die() is deprecated"); |
---|
621 | if ( oldDie ) { |
---|
622 | return oldDie.apply( this, arguments ); |
---|
623 | } |
---|
624 | jQuery( this.context ).off( types, this.selector || "**", fn ); |
---|
625 | return this; |
---|
626 | }; |
---|
627 | |
---|
628 | // Turn global events into document-triggered events |
---|
629 | jQuery.event.trigger = function( event, data, elem, onlyHandlers ){ |
---|
630 | if ( !elem && !rajaxEvent.test( event ) ) { |
---|
631 | migrateWarn( "Global events are undocumented and deprecated" ); |
---|
632 | } |
---|
633 | return eventTrigger.call( this, event, data, elem || document, onlyHandlers ); |
---|
634 | }; |
---|
635 | jQuery.each( ajaxEvents.split("|"), |
---|
636 | function( _, name ) { |
---|
637 | jQuery.event.special[ name ] = { |
---|
638 | setup: function() { |
---|
639 | var elem = this; |
---|
640 | |
---|
641 | // The document needs no shimming; must be !== for oldIE |
---|
642 | if ( elem !== document ) { |
---|
643 | jQuery.event.add( document, name + "." + jQuery.guid, function() { |
---|
644 | jQuery.event.trigger( name, Array.prototype.slice.call( arguments, 1 ), elem, true ); |
---|
645 | }); |
---|
646 | jQuery._data( this, name, jQuery.guid++ ); |
---|
647 | } |
---|
648 | return false; |
---|
649 | }, |
---|
650 | teardown: function() { |
---|
651 | if ( this !== document ) { |
---|
652 | jQuery.event.remove( document, name + "." + jQuery._data( this, name ) ); |
---|
653 | } |
---|
654 | return false; |
---|
655 | } |
---|
656 | }; |
---|
657 | } |
---|
658 | ); |
---|
659 | |
---|
660 | jQuery.event.special.ready = { |
---|
661 | setup: function() { |
---|
662 | if ( this === document ) { |
---|
663 | migrateWarn( "'ready' event is deprecated" ); |
---|
664 | } |
---|
665 | } |
---|
666 | }; |
---|
667 | |
---|
668 | var oldSelf = jQuery.fn.andSelf || jQuery.fn.addBack, |
---|
669 | oldFnFind = jQuery.fn.find; |
---|
670 | |
---|
671 | jQuery.fn.andSelf = function() { |
---|
672 | migrateWarn("jQuery.fn.andSelf() replaced by jQuery.fn.addBack()"); |
---|
673 | return oldSelf.apply( this, arguments ); |
---|
674 | }; |
---|
675 | |
---|
676 | jQuery.fn.find = function( selector ) { |
---|
677 | var ret = oldFnFind.apply( this, arguments ); |
---|
678 | ret.context = this.context; |
---|
679 | ret.selector = this.selector ? this.selector + " " + selector : selector; |
---|
680 | return ret; |
---|
681 | }; |
---|
682 | |
---|
683 | |
---|
684 | // jQuery 1.6 did not support Callbacks, do not warn there |
---|
685 | if ( jQuery.Callbacks ) { |
---|
686 | |
---|
687 | var oldDeferred = jQuery.Deferred, |
---|
688 | tuples = [ |
---|
689 | // action, add listener, callbacks, .then handlers, final state |
---|
690 | [ "resolve", "done", jQuery.Callbacks("once memory"), |
---|
691 | jQuery.Callbacks("once memory"), "resolved" ], |
---|
692 | [ "reject", "fail", jQuery.Callbacks("once memory"), |
---|
693 | jQuery.Callbacks("once memory"), "rejected" ], |
---|
694 | [ "notify", "progress", jQuery.Callbacks("memory"), |
---|
695 | jQuery.Callbacks("memory") ] |
---|
696 | ]; |
---|
697 | |
---|
698 | jQuery.Deferred = function( func ) { |
---|
699 | var deferred = oldDeferred(), |
---|
700 | promise = deferred.promise(); |
---|
701 | |
---|
702 | deferred.pipe = promise.pipe = function( /* fnDone, fnFail, fnProgress */ ) { |
---|
703 | var fns = arguments; |
---|
704 | |
---|
705 | migrateWarn( "deferred.pipe() is deprecated" ); |
---|
706 | |
---|
707 | return jQuery.Deferred(function( newDefer ) { |
---|
708 | jQuery.each( tuples, function( i, tuple ) { |
---|
709 | var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ]; |
---|
710 | // deferred.done(function() { bind to newDefer or newDefer.resolve }) |
---|
711 | // deferred.fail(function() { bind to newDefer or newDefer.reject }) |
---|
712 | // deferred.progress(function() { bind to newDefer or newDefer.notify }) |
---|
713 | deferred[ tuple[1] ](function() { |
---|
714 | var returned = fn && fn.apply( this, arguments ); |
---|
715 | if ( returned && jQuery.isFunction( returned.promise ) ) { |
---|
716 | returned.promise() |
---|
717 | .done( newDefer.resolve ) |
---|
718 | .fail( newDefer.reject ) |
---|
719 | .progress( newDefer.notify ); |
---|
720 | } else { |
---|
721 | newDefer[ tuple[ 0 ] + "With" ]( |
---|
722 | this === promise ? newDefer.promise() : this, |
---|
723 | fn ? [ returned ] : arguments |
---|
724 | ); |
---|
725 | } |
---|
726 | }); |
---|
727 | }); |
---|
728 | fns = null; |
---|
729 | }).promise(); |
---|
730 | |
---|
731 | }; |
---|
732 | |
---|
733 | deferred.isResolved = function() { |
---|
734 | migrateWarn( "deferred.isResolved is deprecated" ); |
---|
735 | return deferred.state() === "resolved"; |
---|
736 | }; |
---|
737 | |
---|
738 | deferred.isRejected = function() { |
---|
739 | migrateWarn( "deferred.isRejected is deprecated" ); |
---|
740 | return deferred.state() === "rejected"; |
---|
741 | }; |
---|
742 | |
---|
743 | if ( func ) { |
---|
744 | func.call( deferred, deferred ); |
---|
745 | } |
---|
746 | |
---|
747 | return deferred; |
---|
748 | }; |
---|
749 | |
---|
750 | } |
---|
751 | |
---|
752 | })( jQuery, window ); |
---|