From: Alexander Ebert Date: Mon, 28 Nov 2011 14:06:24 +0000 (+0100) Subject: Better handling for parallel renderings X-Git-Tag: 2.0.0_Beta_1~1545^2~10 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=9acd5123ed9ef11254c39ca682a40035a64e9dbb;p=GitHub%2FWoltLab%2FWCF.git Better handling for parallel renderings --- diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index e7c2adbf19..8416768a30 100644 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -3222,6 +3222,12 @@ $.widget('ui.wcfDialog', { width: 0 }, + /** + * rendering state + * @var boolean + */ + _isRendering: false, + /** * modal overlay * @var jQuery @@ -3475,6 +3481,13 @@ $.widget('ui.wcfDialog', { $(this).show(); }); + // handle multiple rendering requests + if (this._isRendering) { + // stop current process + this._container.stop(); + this._content.stop(); + } + // calculate dimensions var $windowDimensions = $(window).getDimensions(); var $containerDimensions = this._container.getDimensions('outer'); @@ -3490,6 +3503,15 @@ $.widget('ui.wcfDialog', { $containerDimensions = this._container.getDimensions('outer'); } + // handle multiple rendering requests + if (this._isRendering) { + // use current dimensions as previous ones + this._contentDimensions = this._getContentDimensions($maximumHeight); + } + + // calculate new dimensions + $contentDimensions = this._getContentDimensions($maximumHeight); + // move container var $leftOffset = Math.round(($windowDimensions.width - $containerDimensions.width) / 2); var $topOffset = Math.round(($windowDimensions.height - $containerDimensions.height) / 2); @@ -3510,17 +3532,6 @@ $.widget('ui.wcfDialog', { top: $topOffset + 'px' }); - // set height to maximum height if exceeded - if ($contentDimensions.height > $maximumHeight) { - $contentDimensions.height = $maximumHeight; - } - - // fix dimensions - $contentDimensions = { - height: $contentDimensions.height - this._dimensionDifferences.height, - width: $contentDimensions.width - this._dimensionDifferences.width - }; - // save current dimensions this._contentDimensions = $contentDimensions; @@ -3531,7 +3542,9 @@ $.widget('ui.wcfDialog', { }); // fade in container - this._container.wcfFadeIn(); + this._container.wcfFadeIn($.proxy(function() { + this._isRendering = false; + })); } else { // save reference (used in callback) @@ -3543,17 +3556,6 @@ $.widget('ui.wcfDialog', { width: this._contentDimensions.width + 'px' }); - // set height to maximum height if exceeded - if ($contentDimensions.height > $maximumHeight) { - $contentDimensions.height = $maximumHeight; - } - - // fix dimensions - $contentDimensions = { - height: $contentDimensions.height - this._dimensionDifferences.height, - width: $contentDimensions.width - this._dimensionDifferences.width - }; - // apply new dimensions $content.animate({ height: ($contentDimensions.height) + 'px', @@ -3573,8 +3575,35 @@ $.widget('ui.wcfDialog', { this._container.animate({ left: $leftOffset + 'px', top: $topOffset + 'px' - }, 600); + }, 600, $.proxy(function() { + this._isRendering = false; + })); + } + + this._isRendering = true; + }, + + /** + * Returns calculated content dimensions. + * + * @param integer maximumHeight + * @return object + */ + _getContentDimensions: function(maximumHeight) { + var $contentDimensions = this._content.getDimensions(); + + // set height to maximum height if exceeded + if ($contentDimensions.height > maximumHeight) { + $contentDimensions.height = maximumHeight; } + + // fix dimensions + $contentDimensions = { + height: $contentDimensions.height - this._dimensionDifferences.height, + width: $contentDimensions.width - this._dimensionDifferences.width + }; + + return $contentDimensions; } });