PageSourceSearch

https://www.franzoesischkochen.de/wp-content/themes/stuffpost/assets/js/jquery.wait.js

js franzoesischkochen.de collected 2026-10-02 11:45:14 UTC 2,923 bytes, 89 lines download raw bytes

1/**
2 * jquery.wait - insert simple delays into your jquery method chains
3 * @author Matthew Lee [email protected]
4 */
5
6(function ($) {
7    function jQueryDummy ($real, delay, _fncQueue) {
8        // A Fake jQuery-like object that allows us to resolve the entire jQuery
9        // method chain, pause, and resume execution later.
10
11        var dummy = this;
12        this._fncQueue = (typeof _fncQueue === 'undefined') ? [] : _fncQueue;
13        this._delayCompleted = false;
14        this._$real = $real;
15
16        if (typeof delay === 'number' && delay >= 0 && delay < Infinity)
17            this.timeoutKey = window.setTimeout(function () {
18                dummy._performDummyQueueActions();
19            }, delay);
20
21        else if (delay !== null && typeof delay === 'object' && typeof delay.promise === 'function')
22            delay.then(function () {
23                dummy._performDummyQueueActions();
24            });
25
26        else if (typeof delay === 'string')
27            $real.one(delay, function () {
28                dummy._performDummyQueueActions();
29            });
30
31        else
32            return $real;
33    }
34
35    jQueryDummy.prototype._addToQueue = function(fnc, arg){
36        // When dummy functions are called, the name of the function and
37        // arguments are put into a queue to execute later
38
39        this._fncQueue.unshift({ fnc: fnc, arg: arg });
40
41        if (this._delayCompleted)
42            return this._performDummyQueueActions();
43        else
44            return this;
45    };
46
47    jQueryDummy.prototype._performDummyQueueActions = function(){
48        // Start executing queued actions.  If another `wait` is encountered,
49        // pass the remaining stack to a new jQueryDummy
50
51        this._delayCompleted = true;
52
53        var next;
54        while (this._fncQueue.length > 0) {
55            next = this._fncQueue.pop();
56
57            if (next.fnc === 'wait') {
58                next.arg.push(this._fncQueue);
59                return this._$real = this._$real[next.fnc].apply(this._$real, next.arg);
60            }
61
62            this._$real = this._$real[next.fnc].apply(this._$real, next.arg);
63        }
64
65        return this;
66    };
67
68    $.fn.wait = function(delay, _queue) {
69        // Creates dummy object that dequeues after a times delay OR promise
70
71        return new jQueryDummy(this, delay, _queue);
72    };
73
74    for (var fnc in $.fn) {
75        // Add shadow methods for all jQuery methods in existence.  Will not
76        // shadow methods added to jQuery _after_ this!
77        // skip non-function properties or properties of Object.prototype
78
79        if (typeof $.fn[fnc] !== 'function' || !$.fn.hasOwnProperty(fnc))
80            continue;
81
82        jQueryDummy.prototype[fnc] = (function (fnc) {
83            return function(){
84                var arg = Array.prototype.slice.call(arguments);
85                return this._addToQueue(fnc, arg);
86            };
87        })(fnc);
88    }
89})(jQuery);

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.