UNPKG

devextreme

Version:

HTML5 JavaScript Component Suite for Responsive Web Development

135 lines (132 loc) 4.18 kB
/** * DevExtreme (cjs/__internal/scheduler/r1/appointment_popup/config.js) * Version: 23.2.6 * Build date: Wed May 01 2024 * * Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isPopupFullScreenNeeded = exports.getPopupToolbarItems = exports.getPopupSize = exports.getMaxWidth = exports.defaultAnimation = exports.POPUP_WIDTH = void 0; var _devices = _interopRequireDefault(require("../../../../core/devices")); var _size = require("../../../../core/utils/size"); var _window = require("../../../../core/utils/window"); var _message = _interopRequireDefault(require("../../../../localization/message")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj } } function _extends() { _extends = Object.assign ? Object.assign.bind() : function(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key] } } } return target }; return _extends.apply(this, arguments) } const POPUP_WIDTH = { DEFAULT: 485, RECURRENCE: 970, FULLSCREEN: 1e3, MOBILE: { DEFAULT: 350, FULLSCREEN: 500 } }; exports.POPUP_WIDTH = POPUP_WIDTH; const defaultAnimation = { show: { type: "pop", duration: 300, from: { scale: .55 } }, hide: { type: "pop", duration: 300, to: { opacity: 0, scale: .55 }, from: { opacity: 1, scale: 1 } } }; exports.defaultAnimation = defaultAnimation; const isMobile = () => "desktop" !== _devices.default.current().deviceType; const isIOSPlatform = () => "ios" === _devices.default.current().platform; const TOOLBAR_LOCATION = { AFTER: "after", BEFORE: "before" }; const getButtonsConfig = () => ({ doneButton: { shortcut: "done", options: { text: _message.default.format("Done") }, location: TOOLBAR_LOCATION.AFTER }, cancelButton: { shortcut: "cancel", location: "ios" === _devices.default.current().platform ? TOOLBAR_LOCATION.BEFORE : TOOLBAR_LOCATION.AFTER } }); const getPopupToolbarItems = (allowUpdating, doneClick) => { const result = []; const buttonsConfig = { doneButton: { shortcut: "done", options: { text: _message.default.format("Done") }, location: TOOLBAR_LOCATION.AFTER }, cancelButton: { shortcut: "cancel", location: "ios" === _devices.default.current().platform ? TOOLBAR_LOCATION.BEFORE : TOOLBAR_LOCATION.AFTER } }; if (allowUpdating) { result.push(_extends(_extends({}, buttonsConfig.doneButton), { onClick: doneClick })) } result.push(buttonsConfig.cancelButton); return result }; exports.getPopupToolbarItems = getPopupToolbarItems; const isPopupFullScreenNeeded = () => { const window = (0, _window.getWindow)(); const width = window && (0, _size.getWidth)(window); if (width) { return isMobile() ? width < POPUP_WIDTH.MOBILE.FULLSCREEN : width < POPUP_WIDTH.FULLSCREEN } return false }; exports.isPopupFullScreenNeeded = isPopupFullScreenNeeded; const getMaxWidth = isRecurrence => { if (isMobile()) { return POPUP_WIDTH.MOBILE.DEFAULT } return isRecurrence ? POPUP_WIDTH.RECURRENCE : POPUP_WIDTH.DEFAULT }; exports.getMaxWidth = getMaxWidth; const getPopupSize = isRecurrence => ({ fullScreen: isPopupFullScreenNeeded(), maxWidth: getMaxWidth(isRecurrence) }); exports.getPopupSize = getPopupSize;