Improved $.ui.wcfDialog and rebuild data worker
authorAlexander Ebert <ebert@woltlab.com>
Wed, 25 Sep 2013 13:38:25 +0000 (15:38 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 25 Sep 2013 13:38:25 +0000 (15:38 +0200)
wcfsetup/install/files/acp/js/WCF.ACP.js
wcfsetup/install/files/js/WCF.js

index 3a1e721b9dcc4b3e77ec0adc55c04f174d7c2b46..09e14ac28095a8986fb83604006f6a289e24e649 100644 (file)
@@ -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 = $('<div id="' + this._dialogID + '" />').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);
                }
index 1dfab155238c8349d552856e6a59da151017cd63..47a9c8c48208c59b15988b5412aedf8c859f7f45 100755 (executable)
@@ -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 = $('<div id="jsWcfDialogOverlay" class="dialogOverlay" />').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();
-               }
        },
        
        /**