* Prepares installation dialog.
*/
prepareInstallation: function() {
- WCF.showAJAXDialog('packageInstallationDialog', true, {
- ajax: true,
- closable: false,
- data: this._getParameters(),
- showLoadingOverlay: false,
- success: $.proxy(this._success, this),
- title: WCF.Language.get('wcf.acp.package.installation.title'),
- url: 'index.php/' + this._actionName + '/?t=' + SECURITY_TOKEN + SID_ARG_2ND
- });
+ this._proxy.setOption('data', this._getParameters());
+ this._proxy.sendRequest();
},
/**
_success: function(data, textStatus, jqXHR) {
this._shouldRender = false;
+ if (this._dialog === null) {
+ this._dialog = $('<div id="packageInstallationDialog" />').hide().appendTo(document.body);
+ this._dialog.wcfDialog({
+ closable: false,
+ title: WCF.Language.get('wcf.acp.package.installation.title')
+ });
+ }
+
if (data.step == 'rollback') {
this._dialog.wcfDialog('close');
return;
}
- if (this._dialog == null) {
- this._dialog = $('#packageInstallationDialog');
- }
-
// receive new queue id
if (data.queueID) {
this._queueID = data.queueID;
*/
_proxy: null,
+ /**
+ * dialog title
+ * @var string
+ */
+ _title: '',
+
/**
* Initializes a new worker instance.
*
this._dialogID = dialogID + 'Worker';
this._dialog = null;
this._proxy = new WCF.Action.Proxy({
- showLoadingOverlay: false,
- success: $.proxy(this._success, this),
- url: 'index.php/WorkerProxy/?t=' + SECURITY_TOKEN + SID_ARG_2ND
- });
-
- // initialize AJAX-based dialog
- WCF.showAJAXDialog(this._dialogID, true, {
- url: 'index.php/WorkerProxy/?t=' + SECURITY_TOKEN + SID_ARG_2ND,
- type: 'POST',
+ autoSend: true,
data: {
className: className,
parameters: parameters || { }
},
+ showLoadingOverlay: false,
success: $.proxy(this._success, this),
- onClose: $.proxy(function() { this._aborted = true; }, this),
- title: title
+ url: 'index.php/WorkerProxy/?t=' + SECURITY_TOKEN + SID_ARG_2ND
});
+ this._title = title;
},
/**
// init binding
if (this._dialog === null) {
- this._dialog = $('#' + $.wcfEscapeID(this._dialogID));
+ this._dialog = $('<div id="' + this._dialogID + '" />').hide().appendTo(document.body);
+ this._dialog.wcfDialog({
+ onClose: $.proxy(function() { this._aborted = true; }, this),
+ title: this._title
+ });
}
// update progress
activeDialogs: 0,
/**
- * Counter for dynamic element id's
+ * Counter for dynamic element ids
*
* @var integer
*/
_idCounter: 0,
- /**
- * Shows a modal dialog with a built-in AJAX-loader.
- *
- * @param string dialogID
- * @param boolean resetDialog
- * @return jQuery
- */
- showAJAXDialog: function(dialogID, resetDialog) {
- if (!dialogID) {
- dialogID = this.getRandomID();
- }
-
- if (!$.wcfIsset(dialogID)) {
- $('<div id="' + dialogID + '"></div>').appendTo(document.body);
- }
-
- var dialog = $('#' + $.wcfEscapeID(dialogID));
-
- if (resetDialog) {
- dialog.empty();
- }
-
- var dialogOptions = arguments[2] || {};
- dialogOptions.ajax = true;
-
- dialog.wcfDialog(dialogOptions);
-
- return dialog;
- },
-
- /**
- * Shows a modal dialog.
- *
- * @param string dialogID
- */
- showDialog: function(dialogID) {
- // we cannot work with a non-existant dialog, if you wish to
- // load content via AJAX, see showAJAXDialog() instead
- if (!$.wcfIsset(dialogID)) return;
-
- var $dialog = $('#' + $.wcfEscapeID(dialogID));
-
- var dialogOptions = arguments[1] || {};
- $dialog.wcfDialog(dialogOptions);
- },
-
/**
* Returns a dynamically created id.
*
title: '',
zIndex: 400,
- // AJAX support
- ajax: false,
- data: { },
- showLoadingOverlay: true,
- success: null,
- type: 'POST',
- url: 'index.php/AJAXProxy/?t=' + SECURITY_TOKEN + SID_ARG_2ND,
-
// event callbacks
onClose: null,
onShow: null
* Initializes a new dialog.
*/
_init: function() {
- if (this.options.ajax) {
- new WCF.Action.Proxy({
- autoSend: true,
- data: this.options.data,
- showLoadingOverlay: this.options.showLoadingOverlay,
- success: $.proxy(this._success, this),
- type: this.options.type,
- url: this.options.url
- });
- this.loading();
-
- // force open if using AJAX
- this.options.autoOpen = true;
- }
-
if (this.options.autoOpen) {
this.open();
}
return this;
},
- /**
- * Handles successful AJAX requests.
- *
- * @param object data
- * @param string textStatus
- * @param jQuery jqXHR
- */
- _success: function(data, textStatus, jqXHR) {
- if (this._isOpen) {
- // initialize dialog content
- this._initDialog(data);
-
- if (this.options.success !== null && $.isFunction(this.options.success)) {
- this.options.success(data, textStatus, jqXHR);
- }
- }
- },
-
- /**
- * Initializes dialog content if applicable.
- *
- * @param object data
- */
- _initDialog: function(data) {
- // remove spinner
- this._content.css('position', 'static').children('.icon-spinner').remove();
-
- // insert template
- if (this._getResponseValue(data, 'template')) {
- this._content.children().html(this._getResponseValue(data, 'template'));
- this.render(false, true);
- }
-
- // set title
- if (this._getResponseValue(data, 'title')) {
- this._setOption('title', this._getResponseValue(data, 'title'));
- }
- },
-
- /**
- * Returns a response value, taking care of different object
- * structure returned by AJAXProxy.
- *
- * @param object data
- * @param string key
- */
- _getResponseValue: function(data, key) {
- if (data.returnValues && data.returnValues[key]) {
- return data.returnValues[key];
- }
- else if (data[key]) {
- return data[key];
- }
-
- return null;
- },
-
/**
* Opens this dialog.
*/
return this._isOpen;
},
- /**
- * Clears the dialog and applies a loading overlay
- */
- loading: function() {
- $('<span class="icon icon48 icon-spinner" />').appendTo(this._content.css('position', 'relative'));
- this.render();
- },
-
/**
* Closes this dialog.
*/
/**
* Renders this dialog, should be called whenever content is updated.
- *
- * @param boolean loaded
- * @param boolean disableAnimation
*/
- render: function(loaded, disableAnimation) {
- loaded = loaded || false;
- disableAnimation = disableAnimation || false;
-
- if (loaded) {
- // remove spinner
- this._content.children('.icon-spinner').remove();
- }
-
+ render: function() {
// force dialog and it's contents to be visible
this._container.show();
this._content.children().show();