diff --git a/PHPCI/View/Project/view.phtml b/PHPCI/View/Project/view.phtml
index 2fd6cf6d..036f9837 100644
--- a/PHPCI/View/Project/view.phtml
+++ b/PHPCI/View/Project/view.phtml
@@ -94,7 +94,7 @@
e.preventDefault();
confirmDelete(
"= PHPCI_URL ?>project/delete/getId(); ?>", "Project"
- ).onClose = function () {window.location = '/'};
+ ).onCloseConfirmed = function () {window.location = '/'};
});
})
diff --git a/public/assets/js/phpci.js b/public/assets/js/phpci.js
index 179597c3..7cf07458 100644
--- a/public/assets/js/phpci.js
+++ b/public/assets/js/phpci.js
@@ -82,6 +82,12 @@ var PHPCIConfirmDialogOptions = {
};
var PHPCIConfirmDialog = Class.extend({
+ /**
+ * @private
+ * @var {bool} Determines whether the dialog has been confirmed
+ */
+ confirmed: false,
+
/**
* @param {PHPCIConfirmDialogOptions} options
*/
@@ -148,13 +154,25 @@ var PHPCIConfirmDialog = Class.extend({
this.$confirmBtn.click(this.onConfirm.bind(this));
this.$confirmBtn.unbind('hidden.bs.modal');
+
+ /*
+ Bind the close event of the dialog to the set of onClose* methods
+ */
this.$dialog.on('hidden.bs.modal', function () {this.onClose()}.bind(this));
+ this.$dialog.on('hidden.bs.modal', function () {
+ if (this.confirmed) {
+ this.onCloseConfirmed();
+ } else {
+ this.onCloseCanceled();
+ }
+ }.bind(this));
/*
Restore state if was changed previously
*/
this.$cancelBtn.show();
this.$confirmBtn.show();
+ this.confirmed = false;
},
/**
@@ -172,10 +190,24 @@ var PHPCIConfirmDialog = Class.extend({
},
onConfirm: function (e) {
+ this.confirmed = true;
$(this).attr('disabled', 'disabled');
this.confirmBtnClick(e);
},
+ /**
+ * Called only when confirmed dialog was closed
+ */
+ onCloseConfirmed: function () {},
+
+ /**
+ * Called only when canceled dialog was closed
+ */
+ onCloseCanceled: function () {},
+
+ /**
+ * Called always when the dialog was closed
+ */
onClose: function () {},
showStatusMessage: function (message, closeTimeout) {