// noinspection EqualityComparisonWithCoercionJS /** * -------------------------------------------- * AdminLTE Toasts.js * License MIT * -------------------------------------------- */ import $ from 'jquery' /** * 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}` const EVENT_CREATED = `created${EVENT_KEY}` const EVENT_REMOVED = `removed${EVENT_KEY}` const SELECTOR_CONTAINER_TOP_RIGHT = '#toastsContainerTopRight' const SELECTOR_CONTAINER_TOP_LEFT = '#toastsContainerTopLeft' const SELECTOR_CONTAINER_BOTTOM_RIGHT = '#toastsContainerBottomRight' const SELECTOR_CONTAINER_BOTTOM_LEFT = '#toastsContainerBottomLeft' const CLASS_NAME_TOP_RIGHT = 'toasts-top-right' const CLASS_NAME_TOP_LEFT = 'toasts-top-left' const CLASS_NAME_BOTTOM_RIGHT = 'toasts-bottom-right' const CLASS_NAME_BOTTOM_LEFT = 'toasts-bottom-left' const POSITION_TOP_RIGHT = 'topRight' const POSITION_TOP_LEFT = 'topLeft' const POSITION_BOTTOM_RIGHT = 'bottomRight' const POSITION_BOTTOM_LEFT = 'bottomLeft' 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() $('body').trigger($.Event(EVENT_INIT)) } // Public create() { const 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) } const toastHeader = $('