From 1adbbe2d90d6159908b45b27638f32d915d4ace3 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 3 Sep 2014 22:29:14 +0100 Subject: [PATCH] CRM-13863 - Fix blockUI to completely block dialogs --- js/Common.js | 20 ++++++++++++++++++++ js/crm.ajax.js | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/js/Common.js b/js/Common.js index f3a170df57..9c0e21ed3a 100644 --- a/js/Common.js +++ b/js/Common.js @@ -898,6 +898,25 @@ CRM.strings = CRM.strings || {}; }); } + var originalBlock = $.fn.block, + originalUnblock = $.fn.unblock; + + $.fn.block = function(opts) { + if ($(this).is('.ui-dialog-content')) { + originalBlock.call($(this).parents('.ui-dialog'), opts); + return $(this); + } + return originalBlock.call(this, opts); + } + + $.fn.unblock = function(opts) { + if ($(this).is('.ui-dialog-content')) { + originalUnblock.call($(this).parents('.ui-dialog'), opts); + return $(this); + } + return originalUnblock.call(this, opts); + } + // Preprocess all cj ajax calls to display messages $(document).ajaxSuccess(function(event, xhr, settings) { try { @@ -916,6 +935,7 @@ CRM.strings = CRM.strings || {}; $(function () { $.blockUI.defaults.message = null; + $.blockUI.defaults.ignoreIfBlocked = true; if ($('#crm-container').hasClass('crm-public')) { $.fn.select2.defaults.dropdownCssClass = $.ui.dialog.prototype.options.dialogClass = 'crm-container crm-public'; diff --git a/js/crm.ajax.js b/js/crm.ajax.js index 9b8ecb1f85..5b78b0ef18 100644 --- a/js/crm.ajax.js +++ b/js/crm.ajax.js @@ -245,8 +245,9 @@ if (this._originalContent === null) { this._originalContent = this.element.contents().detach(); } - this.options.block && $('.blockOverlay', this.element).length < 1 && this.element.block(); + this.options.block && this.element.block(); $.getJSON(url, function(data) { + that.options.block && that.element.unblock(); if (!$.isPlainObject(data)) { that._onFailure(data); return; -- 2.25.1