Skip to content

Commit 65c5fa3

Browse files
author
Arnon Yaari
committed
FIX #36
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.
1 parent b38dd8f commit 65c5fa3

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

jquery.blockUI.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@
8383
var $el = $(this);
8484
if (fullOpts.ignoreIfBlocked && $el.data('blockUI.isBlocked'))
8585
return;
86+
if (fullOpts.blockCounting)
87+
return;
8688
$el.unblock({ fadeOut: 0 });
8789
});
8890

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

120122
theme: false, // set to true to use with jQuery UI themes
123+
124+
blockCounting: false,
121125

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

263+
if (opts.blockCounting) {
264+
var blockCount = $(el).data('blockUI.blockCount');
265+
if (blockCount == undefined) blockCount = 0;
266+
blockCount++;
267+
$(el).data('blockUI.blockCount', blockCount);
268+
if (blockCount > 1)
269+
return;
270+
}
271+
259272
opts.overlayCSS = $.extend({}, $.blockUI.defaults.overlayCSS, opts.overlayCSS || {});
260273
css = $.extend({}, $.blockUI.defaults.css, opts.css || {});
261274
if (opts.onOverlayClick)
@@ -465,6 +478,16 @@
465478
$el.removeData('blockUI.timeout');
466479
}
467480
opts = $.extend({}, $.blockUI.defaults, opts || {});
481+
482+
if (opts.blockCounting) {
483+
var blockCount = $(el).data('blockUI.blockCount');
484+
if (blockCount == undefined) blockCount = 0;
485+
else blockCount--;
486+
$(el).data('blockUI.blockCount', blockCount);
487+
if (blockCount > 0)
488+
return;
489+
}
490+
468491
bind(0, el, opts); // unbind events
469492

470493
if (opts.onUnblock === null) {

0 commit comments

Comments
 (0)