Dialogs should now longer trigger multiple overlays
authorAlexander Ebert <ebert@woltlab.com>
Fri, 24 Feb 2012 16:05:26 +0000 (17:05 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 24 Feb 2012 16:05:26 +0000 (17:05 +0100)
wcfsetup/install/files/js/WCF.js

index 1cc41a69683792c91dfa664b193d68411d325d05..0668827eb1093df7b2625709527da818db1a5314 100644 (file)
@@ -421,6 +421,12 @@ $.fn.extend({
  * WoltLab Community Framework core methods
  */
 $.extend(WCF, {
+       /**
+        * count of active dialogs
+        * @var integer
+        */
+       activeDialogs: 0,
+       
        /**
         * Counter for dynamic element id's
         *
@@ -4418,8 +4424,11 @@ $.widget('ui.wcfDialog', {
 
                // create modal view
                if (this.options.modal) {
-                       this._overlay = $('<div class="wcf-dialogOverlay"></div>').css({ height: '100%', zIndex: 900 }).appendTo(document.body);
-
+                       this._overlay = $('#jsWcfDialogOverlay');
+                       if (!this._overlay.length) {
+                               this._overlay = $('<div id="jsWcfDialogOverlay" class="wcf-dialogOverlay"></div>').css({ height: '100%', zIndex: 900 }).appendTo(document.body);
+                       }
+                       
                        if (this.options.closable) {
                                this._overlay.click($.proxy(this.close, this));
                                
@@ -4494,7 +4503,11 @@ $.widget('ui.wcfDialog', {
                }
 
                if (this._overlay !== null) {
-                       this._overlay.show();
+                       WCF.activeDialogs++;
+                       
+                       if (WCF.activeDialogs === 1) {
+                               this._overlay.show();
+                       }
                }
 
                this.render();
@@ -4522,7 +4535,11 @@ $.widget('ui.wcfDialog', {
                this._container.wcfFadeOut();
 
                if (this._overlay !== null) {
-                       this._overlay.hide();
+                       WCF.activeDialogs--;
+                       
+                       if (WCF.activeDialogs === 0) {
+                               this._overlay.hide();
+                       }
                }
                
                if (this.options.onClose !== null) {