Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion for two additional options: showOverlayDelay and stopAnimationInProgress #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 62 additions & 16 deletions jquery.blockUI.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*!
/*!
* jQuery blockUI plugin
* Version 2.39 (23-MAY-2011)
* @requires jQuery v1.2.3 or later
Expand Down Expand Up @@ -181,7 +181,13 @@ $.blockUI.defaults = {
quirksmodeOffsetHack: 4,

// class name of the message block
blockMsgClass: 'blockMsg'
blockMsgClass: 'blockMsg',

//defines delay for making overlay visible (non-trasparent) on the screen
showOverlayDelay: 0,

//defines whether running animation should be stopped before uninstalling screen blocker
stopAnimationInProgress: false
};

// private data and functions follow...
Expand Down Expand Up @@ -336,22 +342,52 @@ function install(el, opts) {

if (($.browser.msie || opts.forceIframe) && opts.showOverlay)
lyr1.show(); // opacity is zero

var showBlocker;

if (opts.fadeIn) {
var cb = opts.onBlock ? opts.onBlock : noOp;
var cb1 = (opts.showOverlay && !msg) ? cb : noOp;
var cb2 = msg ? cb : noOp;
if (opts.showOverlay)
lyr2._fadeIn(opts.fadeIn, cb1);
if (msg)
lyr3._fadeIn(opts.fadeIn, cb2);

showBlocker = function() {
if (opts.showOverlay)
lyr2._fadeIn(opts.fadeIn, cb1);
if (msg)
lyr3._fadeIn(opts.fadeIn, cb2);
};
}
else {
if (opts.showOverlay)
showBlocker = function() {
if (opts.showOverlay)
lyr2.show();
if (msg)
lyr3.show();
if (opts.onBlock)
opts.onBlock();
};
}

if (opts.showOverlayDelay) {
if (opts.showOverlay) {
lyr2.data('initialOpacity', lyr2.css('opacity'));
lyr2.css('opacity', 0.0);
lyr2.show();
if (msg)
lyr3.show();
if (opts.onBlock)
opts.onBlock();
}

var showBlockerDelayed = function() {
if (opts.showOverlay) {
lyr2.hide();
lyr2.css('opacity', lyr2.data('initialOpacity'));
}

showBlocker();
};

var delayTO = setTimeout(showBlockerDelayed, opts.showOverlayDelay);
$(el).data('blockUI.delayTimeout', delayTO);
} else {
showBlocker();
}

// bind key and mouse events
Expand All @@ -375,16 +411,23 @@ function install(el, opts) {
}
};

function clearSavedTimeout($el, attr) {
var to = $el.data(attr);
if (to) {
clearTimeout(to);
$el.removeData(attr);
}
};

// remove the block
function remove(el, opts) {
var full = (el == window);
var $el = $(el);
var data = $el.data('blockUI.history');
var to = $el.data('blockUI.timeout');
if (to) {
clearTimeout(to);
$el.removeData('blockUI.timeout');
}

clearSavedTimeout($el, 'blockUI.timeout');
clearSavedTimeout($el, 'blockUI.delayTimeout');

opts = $.extend({}, $.blockUI.defaults, opts || {});
bind(0, el, opts); // unbind events

Expand All @@ -403,6 +446,9 @@ function remove(el, opts) {
pageBlock = pageBlockEls = null;

if (opts.fadeOut) {
if (opts.stopAnimationInProgress) {
els.stop();
}
els.fadeOut(opts.fadeOut);
setTimeout(function() { reset(els,data,opts,el); }, opts.fadeOut);
}
Expand Down