Created
November 8, 2016 07:39
-
-
Save IlanF/ab84a2684be3673cc301316f88b85048 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;(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