Skip to content

Instantly share code, notes, and snippets.

@melloc01
Created December 5, 2015 19:42
Show Gist options
  • Save melloc01/742c2f568c6517c54129 to your computer and use it in GitHub Desktop.
Save melloc01/742c2f568c6517c54129 to your computer and use it in GitHub Desktop.
function Notification() {
// constructor
function Notification() {
}
this.notify = function (title, text, type, confirmButtonText, cancelButtonText, timer, showConfirmButton) {
return swal({
title: title || '',
text: text,
type: type,
confirmButtonText: confirmButtonText || 'Ok',
cancelButtonText: cancelButtonText || 'Cancelar',
timer: (typeof(timer) === 'undefined' ? 2000 : timer),
showConfirmButton: showConfirmButton || false,
allowOutsideClick: true
});
}
this.error = function (title, text) {
return this.notify(title, text, 'error');
}
this.success = function (title, text) {
return this.notify(title, text, 'success');
}
this.info = function (title, text) {
return this.notify(title, text, 'info');
}
this.confirm = function (title, cb, text, type, confirmButtonText, cancelButtonText, confirmButtonColor, closeOnConfirm, closeOnCancel) {
swal({
title: title,
text: text,
type: type || 'warning',
showCancelButton: true,
confirmButtonColor: confirmButtonColor || "#DD6B55",
confirmButtonText: confirmButtonText || 'Ok',
cancelButtonText: cancelButtonText || 'Cancelar',
closeOnConfirm: closeOnConfirm || true,
closeOnCancel: closeOnCancel || true,
allowOutsideClick: true,
showLoaderOnConfirm: true
}, cb);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment