diff --git a/PHPCI/View/BuildsTable.phtml b/PHPCI/View/BuildsTable.phtml index c2330d29..09cdd09b 100644 --- a/PHPCI/View/BuildsTable.phtml +++ b/PHPCI/View/BuildsTable.phtml @@ -73,7 +73,7 @@ switch($build->getStatus())
diff --git a/PHPCI/View/Project/view.phtml b/PHPCI/View/Project/view.phtml index 762e476a..2fd6cf6d 100644 --- a/PHPCI/View/Project/view.phtml +++ b/PHPCI/View/Project/view.phtml @@ -92,7 +92,9 @@ $(function() { $('#delete-project').on('click', function (e) { e.preventDefault(); - confirmDelete("= PHPCI_URL ?>project/delete/getId(); ?>"); + confirmDelete( + "= PHPCI_URL ?>project/delete/getId(); ?>", "Project" + ).onClose = function () {window.location = '/'}; }); }) diff --git a/PHPCI/View/User/index.phtml b/PHPCI/View/User/index.phtml index bcdcb7f1..86d6c61d 100644 --- a/PHPCI/View/User/index.phtml +++ b/PHPCI/View/User/index.phtml @@ -50,7 +50,7 @@ diff --git a/public/assets/js/phpci.js b/public/assets/js/phpci.js index 8f338b53..179597c3 100644 --- a/public/assets/js/phpci.js +++ b/public/assets/js/phpci.js @@ -30,25 +30,10 @@ if (!Function.prototype.bind) { /** * Used for delete buttons in the system, just to prevent accidental clicks. */ -function confirmDelete(url) -{ - if(confirm('Are you sure you want to delete this?')) - { - window.location.href = url; - } - else - { - return false; - } -} - -/** - * Used for delete build buttons in the system, just to prevent accidental clicks. - */ -function confirmDeleteBuild(url) { +function confirmDelete(url, subject, reloadAfter) { var dialog = new PHPCIConfirmDialog({ - message: 'This build will be permanently deleted. Are you sure?', + message: subject + ' will be permanently deleted. Are you sure?', confirmBtnCaption: 'Delete', /* confirm-btn click handler @@ -62,11 +47,11 @@ function confirmDeleteBuild(url) { */ $.ajax({ url: url, - 'success': function () { - if (refreshBuildsTable) { - dialog.$dialog.on('hidden.bs.modal', function () { - refreshBuildsTable(); - }); + 'success': function (data) { + if (reloadAfter) { + dialog.onClose = function () { + window.location.reload(); + }; } dialog.showStatusMessage('Successfully deleted!', 1000); @@ -79,6 +64,7 @@ function confirmDeleteBuild(url) { }); dialog.show(); + return dialog; } /** @@ -156,11 +142,14 @@ var PHPCIConfirmDialog = Class.extend({ this.confirmBtnClick = options.confirmed; /* - Re-bind on click handler + Re-bind handlers */ this.$confirmBtn.unbind('click'); this.$confirmBtn.click(this.onConfirm.bind(this)); + this.$confirmBtn.unbind('hidden.bs.modal'); + this.$dialog.on('hidden.bs.modal', function () {this.onClose()}.bind(this)); + /* Restore state if was changed previously */ @@ -187,6 +176,8 @@ var PHPCIConfirmDialog = Class.extend({ this.confirmBtnClick(e); }, + onClose: function () {}, + showStatusMessage: function (message, closeTimeout) { this.$confirmBtn.hide(); this.$cancelBtn.html('Close');