packages: bumped JS dependencies and added sweetAlert
This commit is contained in:
parent
4a6d14777b
commit
7b917e025b
6 changed files with 1971 additions and 420 deletions
|
|
@ -35,7 +35,8 @@
|
|||
"<%= dirs.js.node_modules %>/moment/min/moment.min.js",
|
||||
"<%= dirs.js.node_modules %>/clipboard/dist/clipboard.min.js",
|
||||
"<%= dirs.js.node_modules %>/favico.js/favico-0.3.10.min.js",
|
||||
"<%= dirs.js.node_modules %>/dropzone/dist/dropzone.js",
|
||||
"<%= dirs.js.node_modules %>/dropzone/dist/min/dropzone.min.js",
|
||||
"<%= dirs.js.node_modules %>/sweetalert2/dist/sweetalert2.min.js",
|
||||
"<%= dirs.js.node_modules %>/sticky-sidebar/dist/sticky-sidebar.min.js",
|
||||
"<%= dirs.js.node_modules %>/sticky-sidebar/dist/jquery.sticky-sidebar.min.js",
|
||||
"<%= dirs.js.node_modules %>/waypoints/lib/noframework.waypoints.min.js",
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
"grunt-contrib-watch": "^0.6.1",
|
||||
"grunt-webpack": "^3.1.3",
|
||||
"grunt-contrib-uglify": "^4.0.1",
|
||||
"sweetalert2": "^9.10.12",
|
||||
"jquery": "1.11.3",
|
||||
"mark.js": "8.11.1",
|
||||
"jshint": "^2.9.1-rc3",
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -27,6 +27,8 @@
|
|||
@import 'panels';
|
||||
@import 'deform';
|
||||
@import 'tooltips';
|
||||
@import 'sweetalert2';
|
||||
|
||||
|
||||
//--- BASE ------------------//
|
||||
.noscript-error {
|
||||
|
|
|
|||
1371
rhodecode/public/css/sweetalert2.less
Normal file
1371
rhodecode/public/css/sweetalert2.less
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -36,37 +36,88 @@ var toQueryString = function(o) {
|
|||
/**
|
||||
* ajax call wrappers
|
||||
*/
|
||||
var ajaxGET = function(url, success, failure) {
|
||||
var sUrl = url;
|
||||
var request = $.ajax({url: sUrl, headers: {'X-PARTIAL-XHR': true}})
|
||||
.done(function(data){
|
||||
success(data);
|
||||
})
|
||||
.fail(function(data, textStatus, xhr) {
|
||||
if (failure) {
|
||||
failure(data, textStatus, xhr);
|
||||
} else {
|
||||
alert("Error processing request. \n" +
|
||||
"Error code {0} ({1}).".format(data.status, data.statusText));
|
||||
}
|
||||
});
|
||||
return request;
|
||||
|
||||
var ajaxGET = function (url, success, failure) {
|
||||
var sUrl = url;
|
||||
var request = $.ajax({
|
||||
url: sUrl,
|
||||
headers: {'X-PARTIAL-XHR': true}
|
||||
})
|
||||
.done(function (data) {
|
||||
success(data);
|
||||
})
|
||||
.fail(function (jqXHR, textStatus, errorThrown) {
|
||||
if (failure) {
|
||||
failure(jqXHR, textStatus, errorThrown);
|
||||
} else {
|
||||
var message = formatErrorMessage(jqXHR, textStatus, errorThrown);
|
||||
ajaxErrorSwal(message);
|
||||
}
|
||||
});
|
||||
return request;
|
||||
};
|
||||
var ajaxPOST = function(url, postData, success, failure) {
|
||||
var sUrl = url;
|
||||
var postData = toQueryString(postData);
|
||||
var request = $.ajax({type: 'POST', data: postData, url: sUrl,
|
||||
headers: {'X-PARTIAL-XHR': true}})
|
||||
.done(function(data){
|
||||
success(data);
|
||||
})
|
||||
.fail(function(data, textStatus, xhr){
|
||||
if (failure) {
|
||||
failure(data, textStatus, xhr);
|
||||
} else {
|
||||
alert("Error processing request. \n" +
|
||||
"Error code {0} ({1}).".format(data.status, data.statusText));
|
||||
}
|
||||
});
|
||||
return request;
|
||||
|
||||
var ajaxPOST = function (url, postData, success, failure) {
|
||||
var sUrl = url;
|
||||
var postData = toQueryString(postData);
|
||||
var request = $.ajax({
|
||||
type: 'POST',
|
||||
url: sUrl,
|
||||
data: postData,
|
||||
headers: {'X-PARTIAL-XHR': true}
|
||||
})
|
||||
.done(function (data) {
|
||||
success(data);
|
||||
})
|
||||
.fail(function (jqXHR, textStatus, errorThrown) {
|
||||
if (failure) {
|
||||
failure(jqXHR, textStatus, errorThrown);
|
||||
} else {
|
||||
var message = formatErrorMessage(jqXHR, textStatus, errorThrown);
|
||||
ajaxErrorSwal(message);
|
||||
}
|
||||
});
|
||||
return request;
|
||||
};
|
||||
|
||||
function formatErrorMessage(jqXHR, textStatus, errorThrown, prefix) {
|
||||
if(typeof prefix === "undefined") {
|
||||
prefix = ''
|
||||
}
|
||||
|
||||
if (jqXHR.status === 0) {
|
||||
return (prefix + 'Not connected.\nPlease verify your network connection.');
|
||||
} else if (jqXHR.status == 401) {
|
||||
return (prefix + 'Unauthorized access. [401]');
|
||||
} else if (jqXHR.status == 404) {
|
||||
return (prefix + 'The requested page not found. [404]');
|
||||
} else if (jqXHR.status == 500) {
|
||||
return (prefix + 'Internal Server Error [500].');
|
||||
} else if (jqXHR.status == 503) {
|
||||
return (prefix + 'Service unavailable [503].');
|
||||
} else if (errorThrown === 'parsererror') {
|
||||
return (prefix + 'Requested JSON parse failed.');
|
||||
} else if (errorThrown === 'timeout') {
|
||||
return (prefix + 'Time out error.');
|
||||
} else if (errorThrown === 'abort') {
|
||||
return (prefix + 'Ajax request aborted.');
|
||||
} else {
|
||||
return (prefix + 'Uncaught Error.\n' + jqXHR.responseText);
|
||||
}
|
||||
}
|
||||
|
||||
function ajaxErrorSwal(message) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: _gettext('Ajax Error'),
|
||||
html: '<span style="white-space: pre-line">{0}</span>'.format(message),
|
||||
showClass: {
|
||||
popup: 'swal2-noanimation',
|
||||
backdrop: 'swal2-noanimation'
|
||||
},
|
||||
hideClass: {
|
||||
popup: '',
|
||||
backdrop: ''
|
||||
}
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue