2017-01-10 19:22:40 +01:00
|
|
|
/**
|
|
|
|
* Codex Editor Notification Module
|
|
|
|
*
|
|
|
|
* @author Codex Team
|
|
|
|
* @version 1.0
|
|
|
|
*/
|
|
|
|
|
2016-12-07 19:25:31 +01:00
|
|
|
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);
|
|
|
|
|
2016-12-25 15:41:57 +01:00
|
|
|
};
|
2016-12-07 19:25:31 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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;
|