PageSourceSearch

https://indepreneur.io/wp-content/plugins/membermouse/resources/js/common/jquery.blockUI.js

js indepreneur.io collected 2026-10-02 06:26:13 UTC 22,293 bytes, 540 lines download raw bytes

vendor: 20,994 bytes, lines 1-497
1/*!
2 * jQuery blockUI plugin
3 * Version 2.47 (28-SEP-2012)
4 * @requires jQuery v1.3 or later
5 *
6 * Examples at: http://malsup.com/jquery/block/
7 * Copyright (c) 2007-2012 M. Alsup
8 * Dual licensed under the MIT and GPL licenses:
9 * http://www.opensource.org/licenses/mit-license.php
10 * http://www.gnu.org/licenses/gpl.html
11 *
12 * Thanks to Amir-Hossein Sobhi for some excellent contributions!
13 */
14
15; (function () {
16    "use strict";
17
18    function setup($) {
19        $.fn._fadeIn = $.fn.fadeIn;
20
21        var noOp = $.noop || function () { };
22
23        // this bit is to ensure we don't call setExpression when we shouldn't (with extra muscle to handle
24        // retarded userAgent strings on Vista)
25        var msie = /MSIE/.test(navigator.userAgent);
26        var ie6 = /MSIE 6.0/.test(navigator.userAgent);
27        var mode = document.documentMode || 0;
28        // var setExpr = msie && (($.browser.version < 8 && !mode) || mode < 8);
29        var setExpr = $.isFunction(document.createElement('div').style.setExpression);
30
31        // global $ methods for blocking/unblocking the entire page
32        $.blockUI = function (opts) { install(window, opts); };
33        $.unblockUI = function (opts) { remove(window, opts); };
34
35        // convenience method for quick growl-like notifications  (http://www.google.com/search?q=growl)
36        $.growlUI = function (title, message, timeout, onClose) {
37            var $m = $('<div class="growlUI"></div>');
38            if (title) $m.append('<h1>' + title + '</h1>');
39            if (message) $m.append('<h2>' + message + '</h2>');
40            if (timeout === undefined) timeout = 3000;
41            $.blockUI({
42                message: $m, fadeIn: 700, fadeOut: 1000, centerY: false,
43                timeout: timeout, showOverlay: false,
44                onUnblock: onClose,
45                css: $.blockUI.defaults.growlCSS
46            });
47        };
48
49        // plugin method for blocking element content
50        $.fn.block = function (opts) {
51            var fullOpts = $.extend({}, $.blockUI.defaults, opts || {});
52            this.each(function () {
53                var $el = $(this);
54                if (fullOpts.ignoreIfBlocked && $el.data('blockUI.isBlocked'))
55                    return;
56                $el.unblock({ fadeOut: 0 });
57            });
58
59            return this.each(function () {
60                if ($.css(this, 'position') == 'static')
61                    this.style.position = 'relative';
62                this.style.zoom = 1; // force 'hasLayout' in ie
63                install(this, opts);
64            });
65        };
66
67        // plugin method for unblocking element content
68        $.fn.unblock = function (opts) {
69            return this.each(function () {
70                remove(this, opts);
71            });
72        };
73
74        $.blockUI.version = 2.47; // 2nd generation blocking at no extra cost!
75
76        // override these in your code to change the default behavior and style
77        $.blockUI.defaults = {
78            // message displayed when blocking (use null for no message)
79            message: '<h1>Please wait...</h1>',
80
81            title: null,		// title string; only used when theme == true
82            draggable: true,	// only used when theme == true (requires jquery-ui.js to be loaded)
83
84            theme: false, // set to true to use with jQuery UI themes
85
86            // styles for the message when blocking; if you wish to disable
87            // these and use an external stylesheet then do this in your code:
88            // $.blockUI.defaults.css = {};
89            css: {
90                padding: 0,
91                margin: 0,
92                width: '40%',
93                top: '40%',
94                left: '35%',
95                textAlign: 'center',
96                color: '#000',
97                border: '3px solid #aaa',
98                backgroundColor: '#fff',
99                cursor: 'wait'
100            },
101
102            // minimal style set used when themes are used
103            themedCSS: {
104                width: '30%',
105                top: '40%',
106                left: '35%'
107            },
108
109            // styles for the overlay
110            overlayCSS: {
111                backgroundColor: '#000',
112                opacity: 0.6,
113                cursor: 'wait'
114            },
115
116            // styles applied when using $.growlUI
117            growlCSS: {
118                width: '350px',
119                top: '10px',
120                left: '',
121                right: '10px',
122                border: 'none',
123                padding: '5px',
124                opacity: 0.6,
125                cursor: 'default',
126                color: '#fff',
127                backgroundColor: '#000',
128                '-webkit-border-radius': '10px',
129                '-moz-border-radius': '10px',
130                'border-radius': '10px'
131            },
132
133            // IE issues: 'about:blank' fails on HTTPS and javascript:false is s-l-o-w
134            // (hat tip to Jorge H. N. de Vasconcelos)
135            /*jshint scripturl:true */
136            iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank',
137
138            // force usage of iframe in non-IE browsers (handy for blocking applets)
139            forceIframe: false,
140
141            // z-index for the blocking overlay
142            baseZ: 1000,
143
144            // set these to true to have the message automatically centered
145            centerX: true, // <-- only effects element blocking (page block controlled via css above)
146            centerY: true,
147
148            // allow body element to be stetched in ie6; this makes blocking look better
149            // on "short" pages.  disable if you wish to prevent changes to the body height
150            allowBodyStretch: true,
151
152            // enable if you want key and mouse events to be disabled for content that is blocked
153            bindEvents: true,
154
155            // be default blockUI will supress tab navigation from leaving blocking content
156            // (if bindEvents is true)
157            constrainTabKey: true,
158
159            // fadeIn time in millis; set to 0 to disable fadeIn on block
160            fadeIn: 200,
161
162            // fadeOut time in millis; set to 0 to disable fadeOut on unblock
163            fadeOut: 400,
164
165            // time in millis to wait before auto-unblocking; set to 0 to disable auto-unblock
166            timeout: 0,
167
168            // disable if you don't want to show the overlay
169            showOverlay: true,
170
171            // if true, focus will be placed in the first available input field when
172            // page blocking
173            focusInput: true,
174
175            // suppresses the use of overlay styles on FF/Linux (due to performance issues with opacity)
176            // no longer needed in 2012
177            // applyPlatformOpacityRules: true,
178
179            // callback method invoked when fadeIn has completed and blocking message is visible
180            onBlock: null,
181
182            // callback method invoked when unblocking has completed; the callback is
183            // passed the element that has been unblocked (which is the window object for page
184            // blocks) and the options that were passed to the unblock call:
185            //	onUnblock(element, options)
186            onUnblock: null,
187
188            // don't ask; if you really must know: http://groups.google.com/group/jquery-en/browse_thread/thread/36640a8730503595/2f6a79a77a78e493#2f6a79a77a78e493
189            quirksmodeOffsetHack: 4,
190
191            // class name of the message block
192            blockMsgClass: 'blockMsg',
193
194            // if it is already blocked, then ignore it (don't unblock and reblock)
195            ignoreIfBlocked: false
196        };
197
198        // private data and functions follow...
199
200        var pageBlock = null;
201        var pageBlockEls = [];
202
203        function install(el, opts) {
204            var css, themedCSS;
205            var full = (el == window);
206            var msg = (opts && opts.message !== undefined ? opts.message : undefined);
207            opts = $.extend({}, $.blockUI.defaults, opts || {});
208
209            if (opts.ignoreIfBlocked && $(el).data('blockUI.isBlocked'))
210                return;
211
212            opts.overlayCSS = $.extend({}, $.blockUI.defaults.overlayCSS, opts.overlayCSS || {});
213            css = $.extend({}, $.blockUI.defaults.css, opts.css || {});
214            themedCSS = $.extend({}, $.blockUI.defaults.themedCSS, opts.themedCSS || {});
215            msg = msg === undefined ? opts.message : msg;
216
217            // remove the current block (if there is one)
218            if (full && pageBlock)
219                remove(window, { fadeOut: 0 });
220
221            // if an existing element is being used as the blocking content then we capture
222            // its current place in the DOM (and current display style) so we can restore
223            // it when we unblock
224            if (msg && typeof msg != 'string' && (msg.parentNode || msg.jquery)) {
225                var node = msg.jquery ? msg[0] : msg;
226                var data = {};
227                $(el).data('blockUI.history', data);
228                data.el = node;
229                data.parent = node.parentNode;
230                data.display = node.style.display;
231                data.position = node.style.position;
232                if (data.parent)
233                    data.parent.removeChild(node);
234            }
235
236            $(el).data('blockUI.onUnblock', opts.onUnblock);
237            var z = opts.baseZ;
238
239            // blockUI uses 3 layers for blocking, for simplicity they are all used on every platform;
240            // layer1 is the iframe layer which is used to supress bleed through of underlying content
241            // layer2 is the overlay layer which has opacity and a wait cursor (by default)
242            // layer3 is the message content that is displayed while blocking
243            var lyr1, lyr2, lyr3, s;
244            if (msie || opts.forceIframe)
245                lyr1 = $('<iframe class="blockUI" style="z-index:' + (z++) + ';display:none;border:none;margin:0;padding:0;position:absolute;width:100%;height:100%;top:0;left:0" src="' + opts.iframeSrc + '"></iframe>');
246            else
247                lyr1 = $('<div class="blockUI" style="display:none"></div>');
248
249            if (opts.theme)
250                lyr2 = $('<div class="blockUI blockOverlay ui-widget-overlay" style="z-index:' + (z++) + ';display:none"></div>');
251            else
252                lyr2 = $('<div class="blockUI blockOverlay" style="z-index:' + (z++) + ';display:none;border:none;margin:0;padding:0;width:100%;height:100%;top:0;left:0"></div>');
253
254            if (opts.theme && full) {
255                s = '<div class="blockUI ' + opts.blockMsgClass + ' blockPage ui-dialog ui-widget ui-corner-all" style="z-index:' + (z + 10) + ';display:none;position:fixed">';
256                if (opts.title) {
257                    s += '<div class="ui-widget-header ui-dialog-titlebar ui-corner-all blockTitle">' + (opts.title || '&nbsp;') + '</div>';
258                }
259                s += '<div class="ui-widget-content ui-dialog-content"></div>';
260                s += '</div>';
261            }
262            else if (opts.theme) {
263                s = '<div class="blockUI ' + opts.blockMsgClass + ' blockElement ui-dialog ui-widget ui-corner-all" style="z-index:' + (z + 10) + ';display:none;position:absolute">';
264                if (opts.title) {
265                    s += '<div class="ui-widget-header ui-dialog-titlebar ui-corner-all blockTitle">' + (opts.title || '&nbsp;') + '</div>';
266                }
267                s += '<div class="ui-widget-content ui-dialog-content"></div>';
268                s += '</div>';
269            }
270            else if (full) {
271                s = '<div class="blockUI ' + opts.blockMsgClass + ' blockPage" style="z-index:' + (z + 10) + ';display:none;position:fixed"></div>';
272            }
273            else {
274                s = '<div class="blockUI ' + opts.blockMsgClass + ' blockElement" style="z-index:' + (z + 10) + ';display:none;position:absolute"></div>';
275            }
276            lyr3 = $(s);
277
278            // if we have a message, style it
279            if (msg) {
280                if (opts.theme) {
281                    lyr3.css(themedCSS);
282                    lyr3.addClass('ui-widget-content');
283                }
284                else
285                    lyr3.css(css);
286            }
287
288            // style the overlay
289            if (!opts.theme /*&& (!opts.applyPlatformOpacityRules)*/)
290                lyr2.css(opts.overlayCSS);
291            lyr2.css('position', full ? 'fixed' : 'absolute');
292
293            // make iframe layer transparent in IE
294            if (msie || opts.forceIframe)
295                lyr1.css('opacity', 0.0);
296
297            //$([lyr1[0],lyr2[0],lyr3[0]]).appendTo(full ? 'body' : el);
298            var layers = [lyr1, lyr2, lyr3], $par = full ? $('body') : $(el);
299            $.each(layers, function () {
300                this.appendTo($par);
301            });
302
303            if (opts.theme && opts.draggable && $.fn.draggable) {
304                lyr3.draggable({
305                    handle: '.ui-dialog-titlebar',
306                    cancel: 'li'
307                });
308            }
309
310            // ie7 must use absolute positioning in quirks mode and to account for activex issues (when scrolling)
311            var expr = setExpr && (!$.support.boxModel || $('object,embed', full ? null : el).length > 0);
312            if (ie6 || expr) {
313                // give body 100% height
314                if (full && opts.allowBodyStretch && $.support.boxModel)
315                    $('html,body').css('height', '100%');
316
317                // fix ie6 issue when blocked element has a border width
318                if ((ie6 || !$.support.boxModel) && !full) {
319                    var t = sz(el, 'borderTopWidth'), l = sz(el, 'borderLeftWidth');
320                    var fixT = t ? '(0 - ' + t + ')' : 0;
321                    var fixL = l ? '(0 - ' + l + ')' : 0;
322                }
323
324                // simulate fixed position
325                $.each(layers, function (i, o) {
326                    var s = o[0].style;
327                    s.position = 'absolute';
328                    if (i < 2) {
329                        if (full)
330                            s.setExpression('height', 'Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.support.boxModel?0:' + opts.quirksmodeOffsetHack + ') + "px"');
331                        else
332                            s.setExpression('height', 'this.parentNode.offsetHeight + "px"');
333                        if (full)
334                            s.setExpression('width', 'jQuery.support.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"');
335                        else
336                            s.setExpression('width', 'this.parentNode.offsetWidth + "px"');
337                        if (fixL) s.setExpression('left', fixL);
338                        if (fixT) s.setExpression('top', fixT);
339                    }
340                    else if (opts.centerY) {
341                        if (full) s.setExpression('top', '(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"');
342                        s.marginTop = 0;
343                    }
344                    else if (!opts.centerY && full) {
345                        var top = (opts.css && opts.css.top) ? parseInt(opts.css.top, 10) : 0;
346                        var expression = '((document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + ' + top + ') + "px"';
347                        s.setExpression('top', expression);
348                    }
349                });
350            }
351
352            // show the message
353            if (msg) {
354                if (opts.theme)
355                    lyr3.find('.ui-widget-content').append(msg);
356                else
357                    lyr3.append(msg);
358                if (msg.jquery || msg.nodeType)
359                    $(msg).show();
360            }
361
362            if ((msie || opts.forceIframe) && opts.showOverlay)
363                lyr1.show(); // opacity is zero
364            if (opts.fadeIn) {
365                var cb = opts.onBlock ? opts.onBlock : noOp;
366                var cb1 = (opts.showOverlay && !msg) ? cb : noOp;
367                var cb2 = msg ? cb : noOp;
368                if (opts.showOverlay)
369                    lyr2._fadeIn(opts.fadeIn, cb1);
370                if (msg)
371                    lyr3._fadeIn(opts.fadeIn, cb2);
372            }
373            else {
374                if (opts.showOverlay)
375                    lyr2.show();
376                if (msg)
377                    lyr3.show();
378                if (opts.onBlock)
379                    opts.onBlock();
380            }
381
382            // bind key and mouse events
383            bind(1, el, opts);
384
385            if (full) {
386                pageBlock = lyr3[0];
387                pageBlockEls = $(':input:enabled:visible', pageBlock);
388                if (opts.focusInput)
389                    setTimeout(focus, 20);
390            }
391            else
392                center(lyr3[0], opts.centerX, opts.centerY);
393
394            if (opts.timeout) {
395                // auto-unblock
396                var to = setTimeout(function () {
397                    if (full)
398                        $.unblockUI(opts);
399                    else
400                        $(el).unblock(opts);
401                }, opts.timeout);
402                $(el).data('blockUI.timeout', to);
403            }
404        }
405
406        // remove the block
407        function remove(el, opts) {
408            var full = (el == window);
409            var $el = $(el);
410            var data = $el.data('blockUI.history');
411            var to = $el.data('blockUI.timeout');
412            if (to) {
413                clearTimeout(to);
414                $el.removeData('blockUI.timeout');
415            }
416            opts = $.extend({}, $.blockUI.defaults, opts || {});
417            bind(0, el, opts); // unbind events
418
419            if (opts.onUnblock === null) {
420                opts.onUnblock = $el.data('blockUI.onUnblock');
421                $el.removeData('blockUI.onUnblock');
422            }
423
424            var els;
425            if (full) // crazy selector to handle odd field errors in ie6/7
426                els = $('body').children().filter('.blockUI').add('body > .blockUI');
427            else
428                els = $el.find('>.blockUI');
429
430            if (full)
431                pageBlock = pageBlockEls = null;
432
433            if (opts.fadeOut) {
434                els.fadeOut(opts.fadeOut);
435                setTimeout(function () { reset(els, data, opts, el); }, opts.fadeOut);
436            }
437            else
438                reset(els, data, opts, el);
439        }
440
441        // move blocking element back into the DOM where it started
442        function reset(els, data, opts, el) {
443            els.each(function (i, o) {
444                // remove via DOM calls so we don't lose event handlers
445                if (this.parentNode)
446                    this.parentNode.removeChild(this);
447            });
448
449            if (data && data.el) {
450                data.el.style.display = data.display;
451                data.el.style.position = data.position;
452                if (data.parent)
453                    data.parent.appendChild(data.el);
454                $(el).removeData('blockUI.history');
455            }
456
457            if (typeof opts.onUnblock == 'function')
458                opts.onUnblock(el, opts);
459        }
460
461        // bind/unbind the handler
462        function bind(b, el, opts) {
463            var full = el == window, $el = $(el);
464
465            // don't bother unbinding if there is nothing to unbind
466            if (!b && (full && !pageBlock || !full && !$el.data('blockUI.isBlocked')))
467                return;
468
469            $el.data('blockUI.isBlocked', b);
470
471            // don't bind events when overlay is not in use or if bindEvents is false
472            if (!opts.bindEvents || (b && !opts.showOverlay))
473                return;
474
475            // bind anchors and inputs for mouse and key events
476            var events = 'mousedown mouseup keydown keypress';
477            if (b)
478                $(document).bind(events, opts, handler);
479            else
480                $(document).unbind(events, handler);
481
482            // former impl...
483            //		var $e = $('a,:input');
484            //		b ? $e.bind(events, opts, handler) : $e.unbind(events, handler);
485        }
486
487        // event handler to suppress keyboard/mouse events when blocking
488        function handler(e) {
489            // allow tab navigation (conditionally)
490            if (e.keyCode && e.keyCode == 9) {
491                if (pageBlock && e.data.constrainTabKey) {
492                    var els = pageBlockEls;
493                    var fwd = !e.shiftKey && e.target === els[els.length - 1];
494                    var back = e.shiftKey && e.target === els[0];
495                    if (fwd || back) {
496                        setTimeout(function () { focus(back); }, 10);
497                        return false;
vendor: 1,299 bytes, lines 498-540
498                    }
499                }
500            }
501            var opts = e.data;
502            // allow events within the message content
503            if ($(e.target).parents('div.' + opts.blockMsgClass).length > 0)
504                return true;
505
506            // allow events for content that is not being blocked
507            return $(e.target).parents().children().filter('div.blockUI').length === 0;
508        }
509
510        function focus(back) {
511            if (!pageBlockEls)
512                return;
513            var e = pageBlockEls[back === true ? pageBlockEls.length - 1 : 0];
514            if (e)
515                e.focus();
516        }
517
518        function center(el, x, y) {
519            var p = el.parentNode, s = el.style;
520            var l = ((p.offsetWidth - el.offsetWidth) / 2) - sz(p, 'borderLeftWidth');
521            var t = ((p.offsetHeight - el.offsetHeight) / 2) - sz(p, 'borderTopWidth');
522            if (x) s.left = l > 0 ? (l + 'px') : '0';
523            if (y) s.top = t > 0 ? (t + 'px') : '0';
524        }
525
526        function sz(el, p) {
527            return parseInt($.css(el, p), 10) || 0;
528        }
529
530    }
531
532
533    /*global define:true */
534    if (typeof define === 'function' && define.amd && define.amd.jQuery) {
535        define(['jquery'], setup);
536    } else {
537        setup(jQuery);
538    }
539
540})();

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.