Skip to content

Instantly share code, notes, and snippets.

@IlanF
Created November 8, 2016 07:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IlanF/ab84a2684be3673cc301316f88b85048 to your computer and use it in GitHub Desktop.
Save IlanF/ab84a2684be3673cc301316f88b85048 to your computer and use it in GitHub Desktop.
;(function($) {
'use strict';
swal.setDefaults({
allowEscapeKey: true,
reverseButtons: true
});
$(window).on('ajaxErrorMessage', function (evt, message) {
evt.preventDefault();
// give swal enough time to finish animating the overlay with multiple consecutive modals
setTimeout(function() {
swal({
text: message,
buttonsStyling: false,
confirmButtonClass: 'button is-primary is-medium',
showCancelButton: false,
reverseButtons: true,
allowEscapeKey: true
}).then(function() {
swal.resetDefaults();
});
}, 150);
}).on('ajaxConfirmMessage', function (evt, message) {
evt.preventDefault();
swal({
text: message,
buttonsStyling: false,
confirmButtonClass: 'button is-primary is-medium',
cancelButtonClass: 'button is-light is-medium',
showCancelButton: true,
reverseButtons: true,
allowEscapeKey: true
}).then(function() {
swal.resetDefaults();
evt.promise.resolve(message);
}, function(dismiss) {
swal.resetDefaults();
evt.promise.reject();
});
return true;
});
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment