editor.js/modules/notifications.js
khaydarov bc8fb1aed9 cover restoring and fetch function fixed (#101)
* cover restoring fixed

* upd

* fetch fixed in safari

* updated

* plugins

* plugins ready

* code improved

* fixed bug with backspace

* improved architecture
2016-12-25 17:41:57 +03:00

42 lines
1.1 KiB
JavaScript

var notifications = (function(notifications) {
/**
* Error notificator. Shows block with message
* @protected
*/
notifications.errorThrown = function(errorMsg, event) {
codex.notifications.send('This action is not available currently', event.type, false);
};
/**
* Appends notification with different types
* @param message {string} - Error or alert message
* @param type {string} - Type of message notification. Ex: Error, Warning, Danger ...
* @param append {boolean} - can be True or False when notification should be inserted after
*/
notifications.send = function(message, type, append) {
var notification = codex.draw.block('div');
notification.textContent = message;
notification.classList.add('ce_notification-item', 'ce_notification-' + type, 'flipInX');
if (!append) {
codex.nodes.notifications.innerHTML = '';
}
codex.nodes.notifications.appendChild(notification);
setTimeout(function () {
notification.remove();
}, 3000);
};
return notifications;
})({});
module.exports = notifications;