PageSourceSearch

https://www.prairiequilt.com/site-configuration/js/jquery.blockUI.js

js prairiequilt.com collected 2026-09-25 20:59:39 UTC 26,236 bytes, 638 lines download raw bytes

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

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.