Delete maintenance/deleteRevision.php
[lhc/web/wiklou.git] / resources / lib / jquery / jquery.migrate.js
1 /*!
2 * jQuery Migrate - v3.0.0 - 2016-06-09
3 * Copyright jQuery Foundation and other contributors
4 */
5 (function( jQuery, window ) {
6 "use strict";
7
8
9 jQuery.migrateVersion = "3.0.0";
10
11
12 ( function() {
13
14 // Support: IE9 only
15 // IE9 only creates console object when dev tools are first opened
16 // Also, avoid Function#bind here to simplify PhantomJS usage
17 var log = window.console && window.console.log &&
18 function() { window.console.log.apply( window.console, arguments ); },
19 rbadVersions = /^[12]\./;
20
21 if ( !log ) {
22 return;
23 }
24
25 // Need jQuery 3.0.0+ and no older Migrate loaded
26 if ( !jQuery || rbadVersions.test( jQuery.fn.jquery ) ) {
27 log( "JQMIGRATE: jQuery 3.0.0+ REQUIRED" );
28 }
29 if ( jQuery.migrateWarnings ) {
30 log( "JQMIGRATE: Migrate plugin loaded multiple times" );
31 }
32
33 // Show a message on the console so devs know we're active
34 log( "JQMIGRATE: Migrate is installed" +
35 ( jQuery.migrateMute ? "" : " with logging active" ) +
36 ", version " + jQuery.migrateVersion );
37
38 } )();
39
40 var warnedAbout = {};
41
42 // List of warnings already given; public read only
43 jQuery.migrateWarnings = [];
44
45 // Set to false to disable traces that appear with warnings
46 if ( jQuery.migrateTrace === undefined ) {
47 jQuery.migrateTrace = true;
48 }
49
50 // Forget any warnings we've already given; public
51 jQuery.migrateReset = function() {
52 warnedAbout = {};
53 jQuery.migrateWarnings.length = 0;
54 };
55
56 function migrateWarn( msg ) {
57 var console = window.console;
58 if ( !warnedAbout[ msg ] ) {
59 warnedAbout[ msg ] = true;
60 jQuery.migrateWarnings.push( msg );
61 if ( console && console.warn && !jQuery.migrateMute ) {
62 console.warn( "JQMIGRATE: " + msg );
63 if ( jQuery.migrateTrace && console.trace ) {
64 console.trace();
65 }
66 }
67 }
68 }
69
70 function migrateWarnProp( obj, prop, value, msg ) {
71 Object.defineProperty( obj, prop, {
72 configurable: true,
73 enumerable: true,
74 get: function() {
75 migrateWarn( msg );
76 return value;
77 }
78 } );
79 }
80
81 if ( document.compatMode === "BackCompat" ) {
82
83 // JQuery has never supported or tested Quirks Mode
84 migrateWarn( "jQuery is not compatible with Quirks Mode" );
85 }
86
87
88 var oldInit = jQuery.fn.init,
89 oldIsNumeric = jQuery.isNumeric,
90 oldFind = jQuery.find,
91 rattrHashTest = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/,
92 rattrHashGlob = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/g;
93
94 jQuery.fn.init = function( arg1 ) {
95 var args = Array.prototype.slice.call( arguments );
96
97 if ( typeof arg1 === "string" && arg1 === "#" ) {
98
99 // JQuery( "#" ) is a bogus ID selector, but it returned an empty set before jQuery 3.0
100 migrateWarn( "jQuery( '#' ) is not a valid selector" );
101 args[ 0 ] = [];
102 }
103
104 return oldInit.apply( this, args );
105 };
106 jQuery.fn.init.prototype = jQuery.fn;
107
108 jQuery.find = function( selector ) {
109 var args = Array.prototype.slice.call( arguments );
110
111 // Support: PhantomJS 1.x
112 // String#match fails to match when used with a //g RegExp, only on some strings
113 if ( typeof selector === "string" && rattrHashTest.test( selector ) ) {
114
115 // The nonstandard and undocumented unquoted-hash was removed in jQuery 1.12.0
116 // First see if qS thinks it's a valid selector, if so avoid a false positive
117 try {
118 document.querySelector( selector );
119 } catch ( err1 ) {
120
121 // Didn't *look* valid to qSA, warn and try quoting what we think is the value
122 selector = selector.replace( rattrHashGlob, function( _, attr, op, value ) {
123 return "[" + attr + op + "\"" + value + "\"]";
124 } );
125
126 // If the regexp *may* have created an invalid selector, don't update it
127 // Note that there may be false alarms if selector uses jQuery extensions
128 try {
129 document.querySelector( selector );
130 migrateWarn( "Attribute selector with '#' must be quoted: " + args[ 0 ] );
131 args[ 0 ] = selector;
132 } catch ( err2 ) {
133 migrateWarn( "Attribute selector with '#' was not fixed: " + args[ 0 ] );
134 }
135 }
136 }
137
138 return oldFind.apply( this, args );
139 };
140
141 // Copy properties attached to original jQuery.find method (e.g. .attr, .isXML)
142 var findProp;
143 for ( findProp in oldFind ) {
144 if ( Object.prototype.hasOwnProperty.call( oldFind, findProp ) ) {
145 jQuery.find[ findProp ] = oldFind[ findProp ];
146 }
147 }
148
149 // The number of elements contained in the matched element set
150 jQuery.fn.size = function() {
151 migrateWarn( "jQuery.fn.size() is deprecated; use the .length property" );
152 return this.length;
153 };
154
155 jQuery.parseJSON = function() {
156 migrateWarn( "jQuery.parseJSON is deprecated; use JSON.parse" );
157 return JSON.parse.apply( null, arguments );
158 };
159
160 jQuery.isNumeric = function( val ) {
161
162 // The jQuery 2.2.3 implementation of isNumeric
163 function isNumeric2( obj ) {
164 var realStringObj = obj && obj.toString();
165 return !jQuery.isArray( obj ) && ( realStringObj - parseFloat( realStringObj ) + 1 ) >= 0;
166 }
167
168 var newValue = oldIsNumeric( val ),
169 oldValue = isNumeric2( val );
170
171 if ( newValue !== oldValue ) {
172 migrateWarn( "jQuery.isNumeric() should not be called on constructed objects" );
173 }
174
175 return oldValue;
176 };
177
178 migrateWarnProp( jQuery, "unique", jQuery.uniqueSort,
179 "jQuery.unique is deprecated, use jQuery.uniqueSort" );
180
181 // Now jQuery.expr.pseudos is the standard incantation
182 migrateWarnProp( jQuery.expr, "filters", jQuery.expr.pseudos,
183 "jQuery.expr.filters is now jQuery.expr.pseudos" );
184 migrateWarnProp( jQuery.expr, ":", jQuery.expr.pseudos,
185 "jQuery.expr[\":\"] is now jQuery.expr.pseudos" );
186
187
188 var oldAjax = jQuery.ajax;
189
190 jQuery.ajax = function( ) {
191 var jQXHR = oldAjax.apply( this, arguments );
192
193 // Be sure we got a jQXHR (e.g., not sync)
194 if ( jQXHR.promise ) {
195 migrateWarnProp( jQXHR, "success", jQXHR.done,
196 "jQXHR.success is deprecated and removed" );
197 migrateWarnProp( jQXHR, "error", jQXHR.fail,
198 "jQXHR.error is deprecated and removed" );
199 migrateWarnProp( jQXHR, "complete", jQXHR.always,
200 "jQXHR.complete is deprecated and removed" );
201 }
202
203 return jQXHR;
204 };
205
206
207 var oldRemoveAttr = jQuery.fn.removeAttr,
208 oldToggleClass = jQuery.fn.toggleClass,
209 rmatchNonSpace = /\S+/g;
210
211 jQuery.fn.removeAttr = function( name ) {
212 var self = this;
213
214 jQuery.each( name.match( rmatchNonSpace ), function( i, attr ) {
215 if ( jQuery.expr.match.bool.test( attr ) ) {
216 migrateWarn( "jQuery.fn.removeAttr no longer sets boolean properties: " + attr );
217 self.prop( attr, false );
218 }
219 } );
220
221 return oldRemoveAttr.apply( this, arguments );
222 };
223
224 jQuery.fn.toggleClass = function( state ) {
225
226 // Only deprecating no-args or single boolean arg
227 if ( state !== undefined && typeof state !== "boolean" ) {
228 return oldToggleClass.apply( this, arguments );
229 }
230
231 migrateWarn( "jQuery.fn.toggleClass( boolean ) is deprecated" );
232
233 // Toggle entire class name of each element
234 return this.each( function() {
235 var className = this.getAttribute && this.getAttribute( "class" ) || "";
236
237 if ( className ) {
238 jQuery.data( this, "__className__", className );
239 }
240
241 // If the element has a class name or if we're passed `false`,
242 // then remove the whole classname (if there was one, the above saved it).
243 // Otherwise bring back whatever was previously saved (if anything),
244 // falling back to the empty string if nothing was stored.
245 if ( this.setAttribute ) {
246 this.setAttribute( "class",
247 className || state === false ?
248 "" :
249 jQuery.data( this, "__className__" ) || ""
250 );
251 }
252 } );
253 };
254
255
256 var internalSwapCall = false;
257
258 // If this version of jQuery has .swap(), don't false-alarm on internal uses
259 if ( jQuery.swap ) {
260 jQuery.each( [ "height", "width", "reliableMarginRight" ], function( _, name ) {
261 var oldHook = jQuery.cssHooks[ name ] && jQuery.cssHooks[ name ].get;
262
263 if ( oldHook ) {
264 jQuery.cssHooks[ name ].get = function() {
265 var ret;
266
267 internalSwapCall = true;
268 ret = oldHook.apply( this, arguments );
269 internalSwapCall = false;
270 return ret;
271 };
272 }
273 } );
274 }
275
276 jQuery.swap = function( elem, options, callback, args ) {
277 var ret, name,
278 old = {};
279
280 if ( !internalSwapCall ) {
281 migrateWarn( "jQuery.swap() is undocumented and deprecated" );
282 }
283
284 // Remember the old values, and insert the new ones
285 for ( name in options ) {
286 old[ name ] = elem.style[ name ];
287 elem.style[ name ] = options[ name ];
288 }
289
290 ret = callback.apply( elem, args || [] );
291
292 // Revert the old values
293 for ( name in options ) {
294 elem.style[ name ] = old[ name ];
295 }
296
297 return ret;
298 };
299
300 var oldData = jQuery.data;
301
302 jQuery.data = function( elem, name, value ) {
303 var curData;
304
305 // If the name is transformed, look for the un-transformed name in the data object
306 if ( name && name !== jQuery.camelCase( name ) ) {
307 curData = jQuery.hasData( elem ) && oldData.call( this, elem );
308 if ( curData && name in curData ) {
309 migrateWarn( "jQuery.data() always sets/gets camelCased names: " + name );
310 if ( arguments.length > 2 ) {
311 curData[ name ] = value;
312 }
313 return curData[ name ];
314 }
315 }
316
317 return oldData.apply( this, arguments );
318 };
319
320 var oldTweenRun = jQuery.Tween.prototype.run;
321
322 jQuery.Tween.prototype.run = function( percent ) {
323 if ( jQuery.easing[ this.easing ].length > 1 ) {
324 migrateWarn(
325 "easing function " +
326 "\"jQuery.easing." + this.easing.toString() +
327 "\" should use only first argument"
328 );
329
330 jQuery.easing[ this.easing ] = jQuery.easing[ this.easing ].bind(
331 jQuery.easing,
332 percent, this.options.duration * percent, 0, 1, this.options.duration
333 );
334 }
335
336 oldTweenRun.apply( this, arguments );
337 };
338
339 var oldLoad = jQuery.fn.load,
340 originalFix = jQuery.event.fix;
341
342 jQuery.event.props = [];
343 jQuery.event.fixHooks = {};
344
345 jQuery.event.fix = function( originalEvent ) {
346 var event,
347 type = originalEvent.type,
348 fixHook = this.fixHooks[ type ],
349 props = jQuery.event.props;
350
351 if ( props.length ) {
352 migrateWarn( "jQuery.event.props are deprecated and removed: " + props.join() );
353 while ( props.length ) {
354 jQuery.event.addProp( props.pop() );
355 }
356 }
357
358 if ( fixHook && !fixHook._migrated_ ) {
359 fixHook._migrated_ = true;
360 migrateWarn( "jQuery.event.fixHooks are deprecated and removed: " + type );
361 if ( ( props = fixHook.props ) && props.length ) {
362 while ( props.length ) {
363 jQuery.event.addProp( props.pop() );
364 }
365 }
366 }
367
368 event = originalFix.call( this, originalEvent );
369
370 return fixHook && fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
371 };
372
373 jQuery.each( [ "load", "unload", "error" ], function( _, name ) {
374
375 jQuery.fn[ name ] = function() {
376 var args = Array.prototype.slice.call( arguments, 0 );
377
378 // If this is an ajax load() the first arg should be the string URL;
379 // technically this could also be the "Anything" arg of the event .load()
380 // which just goes to show why this dumb signature has been deprecated!
381 // jQuery custom builds that exclude the Ajax module justifiably die here.
382 if ( name === "load" && typeof args[ 0 ] === "string" ) {
383 return oldLoad.apply( this, args );
384 }
385
386 migrateWarn( "jQuery.fn." + name + "() is deprecated" );
387
388 args.splice( 0, 0, name );
389 if ( arguments.length ) {
390 return this.on.apply( this, args );
391 }
392
393 // Use .triggerHandler here because:
394 // - load and unload events don't need to bubble, only applied to window or image
395 // - error event should not bubble to window, although it does pre-1.7
396 // See http://bugs.jquery.com/ticket/11820
397 this.triggerHandler.apply( this, args );
398 return this;
399 };
400
401 } );
402
403 // Trigger "ready" event only once, on document ready
404 jQuery( function() {
405 jQuery( document ).triggerHandler( "ready" );
406 } );
407
408 jQuery.event.special.ready = {
409 setup: function() {
410 if ( this === document ) {
411 migrateWarn( "'ready' event is deprecated" );
412 }
413 }
414 };
415
416 jQuery.fn.extend( {
417
418 bind: function( types, data, fn ) {
419 migrateWarn( "jQuery.fn.bind() is deprecated" );
420 return this.on( types, null, data, fn );
421 },
422 unbind: function( types, fn ) {
423 migrateWarn( "jQuery.fn.unbind() is deprecated" );
424 return this.off( types, null, fn );
425 },
426 delegate: function( selector, types, data, fn ) {
427 migrateWarn( "jQuery.fn.delegate() is deprecated" );
428 return this.on( types, selector, data, fn );
429 },
430 undelegate: function( selector, types, fn ) {
431 migrateWarn( "jQuery.fn.undelegate() is deprecated" );
432 return arguments.length === 1 ?
433 this.off( selector, "**" ) :
434 this.off( types, selector || "**", fn );
435 }
436 } );
437
438
439 var oldOffset = jQuery.fn.offset;
440
441 jQuery.fn.offset = function() {
442 var docElem,
443 elem = this[ 0 ],
444 origin = { top: 0, left: 0 };
445
446 if ( !elem || !elem.nodeType ) {
447 migrateWarn( "jQuery.fn.offset() requires a valid DOM element" );
448 return origin;
449 }
450
451 docElem = ( elem.ownerDocument || document ).documentElement;
452 if ( !jQuery.contains( docElem, elem ) ) {
453 migrateWarn( "jQuery.fn.offset() requires an element connected to a document" );
454 return origin;
455 }
456
457 return oldOffset.apply( this, arguments );
458 };
459
460
461 var oldParam = jQuery.param;
462
463 jQuery.param = function( data, traditional ) {
464 var ajaxTraditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
465
466 if ( traditional === undefined && ajaxTraditional ) {
467
468 migrateWarn( "jQuery.param() no longer uses jQuery.ajaxSettings.traditional" );
469 traditional = ajaxTraditional;
470 }
471
472 return oldParam.call( this, data, traditional );
473 };
474
475 var oldSelf = jQuery.fn.andSelf || jQuery.fn.addBack;
476
477 jQuery.fn.andSelf = function() {
478 migrateWarn( "jQuery.fn.andSelf() replaced by jQuery.fn.addBack()" );
479 return oldSelf.apply( this, arguments );
480 };
481
482
483 var oldDeferred = jQuery.Deferred,
484 tuples = [
485
486 // Action, add listener, callbacks, .then handlers, final state
487 [ "resolve", "done", jQuery.Callbacks( "once memory" ),
488 jQuery.Callbacks( "once memory" ), "resolved" ],
489 [ "reject", "fail", jQuery.Callbacks( "once memory" ),
490 jQuery.Callbacks( "once memory" ), "rejected" ],
491 [ "notify", "progress", jQuery.Callbacks( "memory" ),
492 jQuery.Callbacks( "memory" ) ]
493 ];
494
495 jQuery.Deferred = function( func ) {
496 var deferred = oldDeferred(),
497 promise = deferred.promise();
498
499 deferred.pipe = promise.pipe = function( /* fnDone, fnFail, fnProgress */ ) {
500 var fns = arguments;
501
502 migrateWarn( "deferred.pipe() is deprecated" );
503
504 return jQuery.Deferred( function( newDefer ) {
505 jQuery.each( tuples, function( i, tuple ) {
506 var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
507
508 // Deferred.done(function() { bind to newDefer or newDefer.resolve })
509 // deferred.fail(function() { bind to newDefer or newDefer.reject })
510 // deferred.progress(function() { bind to newDefer or newDefer.notify })
511 deferred[ tuple[ 1 ] ]( function() {
512 var returned = fn && fn.apply( this, arguments );
513 if ( returned && jQuery.isFunction( returned.promise ) ) {
514 returned.promise()
515 .done( newDefer.resolve )
516 .fail( newDefer.reject )
517 .progress( newDefer.notify );
518 } else {
519 newDefer[ tuple[ 0 ] + "With" ](
520 this === promise ? newDefer.promise() : this,
521 fn ? [ returned ] : arguments
522 );
523 }
524 } );
525 } );
526 fns = null;
527 } ).promise();
528
529 };
530
531 if ( func ) {
532 func.call( deferred, deferred );
533 }
534
535 return deferred;
536 };
537
538 // Preserve handler of uncaught exceptions in promise chains
539 jQuery.Deferred.exceptionHook = oldDeferred.exceptionHook;
540
541
542 })( jQuery, window );