* @param object callback
*/
WCF.ACP.Worker = Class.extend({
+ /**
+ * worker aborted
+ * @var boolean
+ */
+ _aborted: false,
+
/**
* callback invoked after worker completed
* @var object
* @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;
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);
}
autoOpen: true,
closable: true,
closeButtonLabel: null,
+ closeConfirmMessage: null,
+ closeViaModal: true,
hideTitle: false,
modal: true,
title: '',
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) {
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();
if (this.options.onClose !== null) {
this.options.onClose();
}
-
- if (event !== undefined) {
- event.preventDefault();
- }
},
/**