diff --git a/rhodecode/public/js/src/plugins/jquery.autocomplete.js b/rhodecode/public/js/src/plugins/jquery.autocomplete.js --- a/rhodecode/public/js/src/plugins/jquery.autocomplete.js +++ b/rhodecode/public/js/src/plugins/jquery.autocomplete.js @@ -564,13 +564,15 @@ $.extend(ajaxSettings, options.ajaxSettings); - that.currentRequest = $.ajax(ajaxSettings).done(function (data) { + that.currentRequest = $.ajax(ajaxSettings) + .done(function (data) { var result; that.currentRequest = null; result = options.transformResult(data); that.processResponse(result, query, cacheKey); options.onSearchComplete.call(that.element, query, result.suggestions); - }).fail(function (jqXHR, textStatus, errorThrown) { + }) + .fail(function (jqXHR, textStatus, errorThrown) { options.onSearchError.call(that.element, query, jqXHR, textStatus, errorThrown); }); } diff --git a/rhodecode/public/js/src/rhodecode/comments.js b/rhodecode/public/js/src/rhodecode/comments.js --- a/rhodecode/public/js/src/rhodecode/comments.js +++ b/rhodecode/public/js/src/rhodecode/comments.js @@ -588,21 +588,12 @@ var CommentsController = function() { var $comment = $(node).closest('.comment'); var comment_id = $comment.attr('data-comment-id'); - Swal.fire({ + SwalNoAnimation.fire({ title: 'Delete this comment?', icon: 'warning', showCancelButton: true, - confirmButtonColor: '#84a5d2', - cancelButtonColor: '#e85e4d', confirmButtonText: _gettext('Yes, delete comment #{0}!').format(comment_id), - showClass: { - popup: 'swal2-noanimation', - backdrop: 'swal2-noanimation' - }, - hideClass: { - popup: '', - backdrop: '' - } + }).then(function(result) { if (result.value) { self._deleteComment(node); diff --git a/rhodecode/public/js/src/rhodecode/users.js b/rhodecode/public/js/src/rhodecode/users.js --- a/rhodecode/public/js/src/rhodecode/users.js +++ b/rhodecode/public/js/src/rhodecode/users.js @@ -50,19 +50,9 @@ var UsersAutoComplete = function(input_i var _showAuthToken = function (authTokenId, showUrl) { - Swal.fire({ + SwalNoAnimation.fire({ title: _gettext('Show this authentication token?'), showCancelButton: true, - confirmButtonColor: '#84a5d2', - cancelButtonColor: '#e85e4d', - showClass: { - popup: 'swal2-noanimation', - backdrop: 'swal2-noanimation' - }, - hideClass: { - popup: '', - backdrop: '' - }, confirmButtonText: _gettext('Show'), showLoaderOnConfirm: true, allowOutsideClick: function () { @@ -98,19 +88,9 @@ var _showAuthToken = function (authToken var tmpl = ('{0}' + ''); - Swal.fire({ + SwalNoAnimation.fire({ title: _gettext('Authentication Token'), html: tmpl.format(result.value.auth_token, result.value.auth_token), - confirmButtonColor: '#84a5d2', - cancelButtonColor: '#e85e4d', - showClass: { - popup: 'swal2-noanimation', - backdrop: 'swal2-noanimation' - }, - hideClass: { - popup: '', - backdrop: '' - }, }) } }) diff --git a/rhodecode/public/js/src/rhodecode/utils/ajax.js b/rhodecode/public/js/src/rhodecode/utils/ajax.js --- a/rhodecode/public/js/src/rhodecode/utils/ajax.js +++ b/rhodecode/public/js/src/rhodecode/utils/ajax.js @@ -80,6 +80,30 @@ var ajaxPOST = function (url, postData, return request; }; + +SwalNoAnimation = Swal.mixin({ + confirmButtonColor: '#84a5d2', + cancelButtonColor: '#e85e4d', + showClass: { + popup: 'swal2-noanimation', + backdrop: 'swal2-noanimation' + }, + hideClass: { + popup: '', + backdrop: '' + }, +}) + + +/* Example usage: +* + error: function(jqXHR, textStatus, errorThrown) { + var prefix = "Error while fetching entries.\n" + var message = formatErrorMessage(jqXHR, textStatus, errorThrown, prefix); + ajaxErrorSwal(message); + } +* +* */ function formatErrorMessage(jqXHR, textStatus, errorThrown, prefix) { if(typeof prefix === "undefined") { prefix = '' @@ -107,7 +131,7 @@ function formatErrorMessage(jqXHR, textS } function ajaxErrorSwal(message) { - Swal.fire({ + SwalNoAnimation.fire({ icon: 'error', title: _gettext('Ajax Request Error'), html: '{0}'.format(message), @@ -135,21 +159,13 @@ function submitConfirm(event, self, ques } event.preventDefault(); - Swal.fire({ + SwalNoAnimation.fire({ title: question, icon: 'warning', html: htmlText, - showClass: { - popup: 'swal2-noanimation', - backdrop: 'swal2-noanimation' - }, - hideClass: { - popup: '', - backdrop: '' - }, + showCancelButton: true, - confirmButtonColor: '#84a5d2', - cancelButtonColor: '#e85e4d', + confirmButtonText: confirmText }).then(function(result) { if (result.value) { diff --git a/rhodecode/templates/base/base.mako b/rhodecode/templates/base/base.mako --- a/rhodecode/templates/base/base.mako +++ b/rhodecode/templates/base/base.mako @@ -1069,8 +1069,14 @@ }, onSearchError: function (element, query, jqXHR, textStatus, errorThrown) { if (jqXHR !== 'abort') { - alert("Error during search.\nError code: {0}".format(textStatus)); - window.location = ''; + var message = formatErrorMessage(jqXHR, textStatus, errorThrown); + SwalNoAnimation.fire({ + icon: 'error', + title: _gettext('Error during search operation'), + html: '{0}'.format(message), + }).then(function(result) { + window.location.reload(); + }) } }, onSearchStart: function (params) {