import $ from 'jquery'; import domready from 'domready'; import is from 'is'; class Alert{ constructor(alertsContainer) { if(!Alert.instance){ Alert.instance = this; }else{ return Alert.instance; } this.container = alertsContainer; return Alert.instance; } pushNewAlert(type,msg){ let html = Alert.toAlertString(type,msg); $(this.container).append(html); } static toAlertString(type,msg){ return ` `; } } Alert.instance = null; Alert.TYPE = { WARN: 'warning', ERR: 'danger', INFO: 'info', OK: 'success' }; domready(function () { let alertsContainer = document.getElementById("flash-messages"); if (!is.nil(alertsContainer) && is.defined(alertsContainer)) { new Alert(alertsContainer); } }); export default Alert;