/** * -------------------------------------------- * AdminLTE Toasts.js * License MIT * -------------------------------------------- */ const Toasts = (($) => { /** * Constants * ==================================================== */ const NAME = 'Toasts' const DATA_KEY = 'lte.toasts' const EVENT_KEY = `.${DATA_KEY}` const JQUERY_NO_CONFLICT = $.fn[NAME] const Event = { INIT: `init${EVENT_KEY}`, CREATED: `created${EVENT_KEY}`, REMOVED: `removed${EVENT_KEY}`, } const Selector = { BODY: 'toast-body', CONTAINER_TOP_RIGHT: '#toastsContainerTopRight', CONTAINER_TOP_LEFT: '#toastsContainerTopLeft', CONTAINER_BOTTOM_RIGHT: '#toastsContainerBottomRight', CONTAINER_BOTTOM_LEFT: '#toastsContainerBottomLeft', } const ClassName = { TOP_RIGHT: 'toasts-top-right', TOP_LEFT: 'toasts-top-left', BOTTOM_RIGHT: 'toasts-bottom-right', BOTTOM_LEFT: 'toasts-bottom-left', FADE: 'fade', } const Position = { TOP_RIGHT: 'topRight', TOP_LEFT: 'topLeft', BOTTOM_RIGHT: 'bottomRight', BOTTOM_LEFT: 'bottomLeft', } const Id = { CONTAINER_TOP_RIGHT: 'toastsContainerTopRight', CONTAINER_TOP_LEFT: 'toastsContainerTopLeft', CONTAINER_BOTTOM_RIGHT: 'toastsContainerBottomRight', CONTAINER_BOTTOM_LEFT: 'toastsContainerBottomLeft', } const Default = { position: Position.TOP_RIGHT, fixed: true, autohide: false, autoremove: true, delay: 1000, fade: true, icon: null, image: null, imageAlt: null, imageHeight: '25px', title: null, subtitle: null, close: true, body: null, class: null, } /** * Class Definition * ==================================================== */ class Toasts { constructor(element, config) { this._config = config this._prepareContainer(); const initEvent = $.Event(Event.INIT) $('body').trigger(initEvent) } // Public create() { var toast = $('
') toast.data('autohide', this._config.autohide) toast.data('animation', this._config.fade) if (this._config.class) { toast.addClass(this._config.class) } if (this._config.delay && this._config.delay != 500) { toast.data('delay', this._config.delay) } var toast_header = $('