PageSourceSearch

https://oldoakscc.org/CMSScripts/jquery/jquery-migrate-3.0.0.js

js oldoakscc.org collected 2026-09-25 01:15:07 UTC 20,705 bytes, 599 lines download raw bytes

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

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.