From: Alexander Ebert Date: Wed, 25 Sep 2013 13:38:25 +0000 (+0200) Subject: Improved $.ui.wcfDialog and rebuild data worker X-Git-Tag: 2.0.0_Beta_10~6^2~13 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=af7da802373ecac0c870ae8c18ba10da6d14f2a7;p=GitHub%2FWoltLab%2FWCF.git Improved $.ui.wcfDialog and rebuild data worker --- diff --git a/wcfsetup/install/files/acp/js/WCF.ACP.js b/wcfsetup/install/files/acp/js/WCF.ACP.js index 3a1e721b9d..09e14ac280 100644 --- a/wcfsetup/install/files/acp/js/WCF.ACP.js +++ b/wcfsetup/install/files/acp/js/WCF.ACP.js @@ -1598,6 +1598,12 @@ WCF.ACP.Options = Class.extend({ * @param object callback */ WCF.ACP.Worker = Class.extend({ + /** + * worker aborted + * @var boolean + */ + _aborted: false, + /** * callback invoked after worker completed * @var object @@ -1636,8 +1642,10 @@ WCF.ACP.Worker = Class.extend({ * @param string title * @param object parameters * @param object callback + * @param object confirmMessage */ init: function(dialogID, className, title, parameters, callback) { + this._aborted = false; this._callback = callback || null; this._dialogID = dialogID + 'Worker'; this._dialog = null; @@ -1664,13 +1672,22 @@ WCF.ACP.Worker = Class.extend({ if (this._dialog === null) { this._dialog = $('
').hide().appendTo(document.body); this._dialog.wcfDialog({ + closeConfirmMessage: WCF.Language.get('wcf.acp.worker.abort.confirmMessage'), + closeViaModal: false, onClose: $.proxy(function() { + this._aborted = true; this._proxy.abortPrevious(); + + window.location.reload(); }, this), title: this._title }); } + if (this._aborted) { + return; + } + if (data.template) { this._dialog.html(data.template); } diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index 1dfab15523..47a9c8c482 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -8555,6 +8555,8 @@ $.widget('ui.wcfDialog', { autoOpen: true, closable: true, closeButtonLabel: null, + closeConfirmMessage: null, + closeViaModal: true, hideTitle: false, modal: true, title: '', @@ -8620,7 +8622,7 @@ $.widget('ui.wcfDialog', { this._overlay = $('
').css({ height: '100%', zIndex: 399 }).hide().appendTo(document.body); } - if (this.options.closable) { + if (this.options.closable && this.options.closeViaModal) { this._overlay.click($.proxy(this.close, this)); $(document).keyup($.proxy(function(event) { @@ -8714,6 +8716,28 @@ $.widget('ui.wcfDialog', { return; } + if (this.options.closeConfirmMessage) { + WCF.System.Confirmation.show(this.options.closeConfirmMessage, $.proxy(function(action) { + if (action === 'confirm') { + this._close(); + } + }, this)); + } + else { + this._close(); + } + + if (event !== undefined) { + event.preventDefault(); + } + }, + + /** + * Handles dialog closing, should never be called directly. + * + * @see $.ui.wcfDialog.close() + */ + _close: function() { this._isOpen = false; this._container.wcfFadeOut(); @@ -8728,10 +8752,6 @@ $.widget('ui.wcfDialog', { if (this.options.onClose !== null) { this.options.onClose(); } - - if (event !== undefined) { - event.preventDefault(); - } }, /**