improved notifications, now with animations, in center and show up properly in the dialogs

This commit is contained in:
azivner 2018-11-22 16:08:02 +01:00
parent 6cd8a2203e
commit 1db2f0c2c5
2 changed files with 63 additions and 10 deletions

View File

@ -5,13 +5,9 @@ function showMessage(message) {
console.debug(utils.now(), "message: ", message); console.debug(utils.now(), "message: ", message);
$.notify({ $.notify({
// options icon: 'jam jam-check',
message: message message: message
}, { }, getNotifySettings('success', 3000));
// options
type: 'success',
delay: 3000
});
} }
function showAndLogError(message, delay = 10000) { function showAndLogError(message, delay = 10000) {
@ -25,12 +21,28 @@ function showError(message, delay = 10000) {
$.notify({ $.notify({
// options // options
icon: 'jam jam-alert',
message: message message: message
}, { }, getNotifySettings('danger', delay));
// options }
type: 'danger',
function getNotifySettings(type, delay) {
return {
element: (glob.activeDialog && glob.activeDialog.hasClass("show"))
? glob.activeDialog.find('.modal-header')[0]
: 'body',
type: type,
z_index: 1031,
placement: {
from: "top",
align: "center"
},
animate: {
enter: 'animated fadeInDown',
exit: 'animated fadeOutUp'
},
delay: delay delay: delay
}); };
} }
function throwError(message) { function throwError(message) {

View File

@ -635,3 +635,44 @@ table.promoted-attributes-in-tooltip td, table.promoted-attributes-in-tooltip th
code { code {
color: inherit !important; color: inherit !important;
} }
.animated {
animation-duration: 1s;
animation-fill-mode: both;
}
@keyframes fadeInDown {
from {
opacity: 0;
transform: translate3d(0, -100%, 0);
}
to {
opacity: 1;
transform: translate3d(0, 0, 0);
}
}
.fadeInDown {
animation-name: fadeInDown;
}
@keyframes fadeOutUp {
from {
opacity: 1;
}
to {
opacity: 0;
-webkit-transform: translate3d(0, -100%, 0);
transform: translate3d(0, -100%, 0);
}
}
.fadeOutUp {
animation-name: fadeOutUp;
}
div[data-notify="container"] {
text-align: center;
}