From 81cb00a1a9f41ed0976bdebc1e808d42877e1a37 Mon Sep 17 00:00:00 2001 From: Marcin Kuzminski Date: Fri, 17 Apr 2020 12:16:21 +0200 Subject: [PATCH] comments: use better sweet alert confirm dialog. --- rhodecode/public/js/src/rhodecode/comments.js | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/rhodecode/public/js/src/rhodecode/comments.js b/rhodecode/public/js/src/rhodecode/comments.js index 33dc57df..800a8529 100644 --- a/rhodecode/public/js/src/rhodecode/comments.js +++ b/rhodecode/public/js/src/rhodecode/comments.js @@ -555,10 +555,7 @@ var CommentsController = function() { return self.scrollToComment(node, -1, true); }; - this.deleteComment = function(node) { - if (!confirm(_gettext('Delete this comment?'))) { - return false; - } + this._deleteComment = function(node) { var $node = $(node); var $td = $node.closest('td'); var $comment = $node.closest('.comment'); @@ -585,6 +582,24 @@ var CommentsController = function() { return false; }; ajaxPOST(url, postData, success, failure); + } + + this.deleteComment = function(node) { + var $comment = $(node).closest('.comment'); + var comment_id = $comment.attr('data-comment-id'); + + Swal.fire({ + title: 'Delete this comment?', + icon: 'warning', + showCancelButton: true, + confirmButtonColor: '#84a5d2', + cancelButtonColor: '#e85e4d', + confirmButtonText: _gettext('Yes, delete comment #{0}!').format(comment_id) + }).then(function(result) { + if (result.value) { + self._deleteComment(node); + } + }) }; this.toggleWideMode = function (node) {