Skip to content

Commit

Permalink
FIX #36
Browse files Browse the repository at this point in the history
add blockCounting option. If this option is true, multiple block calls are possible. This option does not work with "timeout" option, and is meaningless with "ignoreIfBlocked" option.
  • Loading branch information
Arnon Yaari committed Sep 19, 2014
1 parent b38dd8f commit 65c5fa3
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions jquery.blockUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@
var $el = $(this);
if (fullOpts.ignoreIfBlocked && $el.data('blockUI.isBlocked'))
return;
if (fullOpts.blockCounting)
return;
$el.unblock({ fadeOut: 0 });
});

Expand Down Expand Up @@ -118,6 +120,8 @@
draggable: true, // only used when theme == true (requires jquery-ui.js to be loaded)

theme: false, // set to true to use with jQuery UI themes

blockCounting: false,

// styles for the message when blocking; if you wish to disable
// these and use an external stylesheet then do this in your code:
Expand Down Expand Up @@ -256,6 +260,15 @@
if (opts.ignoreIfBlocked && $(el).data('blockUI.isBlocked'))
return;

if (opts.blockCounting) {
var blockCount = $(el).data('blockUI.blockCount');
if (blockCount == undefined) blockCount = 0;
blockCount++;
$(el).data('blockUI.blockCount', blockCount);
if (blockCount > 1)
return;
}

opts.overlayCSS = $.extend({}, $.blockUI.defaults.overlayCSS, opts.overlayCSS || {});
css = $.extend({}, $.blockUI.defaults.css, opts.css || {});
if (opts.onOverlayClick)
Expand Down Expand Up @@ -465,6 +478,16 @@
$el.removeData('blockUI.timeout');
}
opts = $.extend({}, $.blockUI.defaults, opts || {});

if (opts.blockCounting) {
var blockCount = $(el).data('blockUI.blockCount');
if (blockCount == undefined) blockCount = 0;
else blockCount--;
$(el).data('blockUI.blockCount', blockCount);
if (blockCount > 0)
return;
}

bind(0, el, opts); // unbind events

if (opts.onUnblock === null) {
Expand Down

0 comments on commit 65c5fa3

Please sign in to comment.