CRM-13863 - Fix blockUI to completely block dialogs
authorColeman Watts <coleman@civicrm.org>
Wed, 3 Sep 2014 21:29:14 +0000 (22:29 +0100)
committerColeman Watts <coleman@civicrm.org>
Wed, 3 Sep 2014 21:29:14 +0000 (22:29 +0100)
js/Common.js
js/crm.ajax.js

index f3a170df57ffdacc21d1c05d957a317ec258f094..9c0e21ed3a96ef54c32d6780ad2c106048008eba 100644 (file)
@@ -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';
index 9b8ecb1f8596e8c3827c88e749e6a67b1e16f3fe..5b78b0ef182939a7cadbcf7d9cabf87a07cf9ead 100644 (file)
       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;