/** * DevExtreme (ui/toast.js) * Version: 19.1.16 * Build date: Tue Oct 18 2022 * * Copyright (c) 2012 - 2022 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ "use strict"; var $ = require("../core/renderer"); var window = require("../core/utils/window").getWindow(); var domAdapter = require("../core/dom_adapter"); var eventsEngine = require("../events/core/events_engine"); var ready = require("../core/utils/ready_callbacks").add; var commonUtils = require("../core/utils/common"); var typeUtils = require("../core/utils/type"); var extend = require("../core/utils/extend").extend; var inArray = require("../core/utils/array").inArray; var pointerEvents = require("../events/pointer"); var registerComponent = require("../core/component_registrator"); var Overlay = require("./overlay"); var themes = require("./themes"); var TOAST_CLASS = "dx-toast"; var TOAST_CLASS_PREFIX = TOAST_CLASS + "-"; var TOAST_WRAPPER_CLASS = TOAST_CLASS_PREFIX + "wrapper"; var TOAST_CONTENT_CLASS = TOAST_CLASS_PREFIX + "content"; var TOAST_MESSAGE_CLASS = TOAST_CLASS_PREFIX + "message"; var TOAST_ICON_CLASS = TOAST_CLASS_PREFIX + "icon"; var WIDGET_NAME = "dxToast"; var toastTypes = ["info", "warning", "error", "success"]; var TOAST_STACK = []; var FIRST_Z_INDEX_OFFSET = 8e3; var visibleToastInstance = null; var POSITION_ALIASES = { top: { my: "top", at: "top", of: null, offset: "0 0" }, bottom: { my: "bottom", at: "bottom", of: null, offset: "0 -20" }, center: { my: "center", at: "center", of: null, offset: "0 0" }, right: { my: "center right", at: "center right", of: null, offset: "0 0" }, left: { my: "center left", at: "center left", of: null, offset: "0 0" } }; ready(function() { eventsEngine.subscribeGlobal(domAdapter.getDocument(), pointerEvents.down, function(e) { for (var i = TOAST_STACK.length - 1; i >= 0; i--) { if (!TOAST_STACK[i]._proxiedDocumentDownHandler(e)) { return } } }) }); var Toast = Overlay.inherit({ _getDefaultOptions: function() { return extend(this.callBase(), { message: "", type: "info", displayTime: 2e3, position: "bottom center", animation: { show: { type: "fade", duration: 400, from: 0, to: 1 }, hide: { type: "fade", duration: 400, to: 0 } }, shading: false, height: "auto", closeOnBackButton: false, closeOnSwipe: true, closeOnClick: false, resizeEnabled: false }) }, _defaultOptionsRules: function() { return this.callBase().concat([{ device: function(_device) { return "win" === _device.platform && _device.version && 8 === _device.version[0] }, options: { position: "top center", width: function() { return $(window).width() } } }, { device: function(_device2) { return "win" === _device2.platform && _device2.version && 10 === _device2.version[0] }, options: { position: "bottom right", width: "auto" } }, { device: { platform: "android" }, options: { closeOnOutsideClick: true, width: "auto", position: { at: "bottom left", my: "bottom left", offset: "20 -20" }, animation: { show: { type: "slide", duration: 200, from: { position: { my: "top", at: "bottom", of: window } } }, hide: { type: "slide", duration: 200, to: { position: { my: "top", at: "bottom", of: window } } } } } }, { device: function(_device3) { var isPhone = "phone" === _device3.deviceType; var isAndroid = "android" === _device3.platform; var isWin10 = "win" === _device3.platform && _device3.version && 10 === _device3.version[0]; return isPhone && (isAndroid || isWin10) }, options: { width: function() { return $(window).width() }, position: { at: "bottom center", my: "bottom center", offset: "0 0" } } }, { device: function() { return themes.isMaterial() }, options: { minWidth: 344, maxWidth: 568, displayTime: 4e3 } }]) }, _init: function() { this.callBase(); this._posStringToObject() }, _renderContentImpl: function() { if (this.option("message")) { this._message = $("