UNPKG

devextreme

Version:

HTML5 JavaScript Component Suite for Responsive Web Development

253 lines (248 loc) • 9.3 kB
/** * DevExtreme (cjs/ui/diagram/ui.diagram.floating_panel.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"; exports.default = void 0; var _size = require("../../core/utils/size"); var _renderer = _interopRequireDefault(require("../../core/renderer")); var _extend = require("../../core/utils/extend"); var _window = require("../../core/utils/window"); var _ui = _interopRequireDefault(require("../popup/ui.popup")); var _uiDiagram = _interopRequireDefault(require("./ui.diagram.panel")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj } } function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass) } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(o, p) { o.__proto__ = p; return o }; return _setPrototypeOf(o, p) } const DIAGRAM_MOBILE_POPUP_CLASS = "dx-diagram-mobile-popup"; let DiagramFloatingPanel = function(_DiagramPanel) { _inheritsLoose(DiagramFloatingPanel, _DiagramPanel); function DiagramFloatingPanel() { return _DiagramPanel.apply(this, arguments) || this } var _proto = DiagramFloatingPanel.prototype; _proto._init = function() { _DiagramPanel.prototype._init.call(this); this._createOnVisibilityChangingAction(); this._createOnVisibilityChangedAction() }; _proto.isVisible = function() { return this.option("isVisible") }; _proto.isMobileView = function() { return this.option("isMobileView") }; _proto._initMarkup = function() { _DiagramPanel.prototype._initMarkup.call(this); const $parent = this.$element(); const $popupElement = (0, _renderer.default)("<div>").addClass(this._getPopupClass()).addClass(this.isMobileView() && "dx-diagram-mobile-popup").appendTo($parent); this._popup = this._createComponent($popupElement, _ui.default, this._getPopupOptions()); this._updatePopupVisible() }; _proto.show = function() { this.option("isVisible", true) }; _proto.hide = function() { this.option("isVisible", false) }; _proto.toggle = function() { this.option("isVisible", !this.isVisible()) }; _proto.repaint = function() { this._popup.repaint() }; _proto._getPopupContent = function() { return this._popup.content() }; _proto._getPopupTitle = function() { const $content = (0, _renderer.default)(this._getPopupContent()); return $content.parent().find(".dx-popup-title") }; _proto._getPointerUpElements = function() { return [this._getPopupContent(), this._getPopupTitle()] }; _proto._getVerticalPaddingsAndBorders = function() { const $content = (0, _renderer.default)(this._getPopupContent()); return (0, _size.getOuterHeight)($content) - (0, _size.getHeight)($content) }; _proto._getHorizontalPaddingsAndBorders = function() { const $content = (0, _renderer.default)(this._getPopupContent()); return (0, _size.getOuterWidth)($content) - (0, _size.getWidth)($content) }; _proto._getPopupClass = function() { return "" }; _proto._getPopupWidth = function() { return this.option("width") || "auto" }; _proto._getPopupMaxWidth = function() { return this.option("maxWidth") }; _proto._getPopupMinWidth = function() { return this.option("minWidth") }; _proto._getPopupHeight = function() { return this.option("height") || "auto" }; _proto._getPopupMaxHeight = function() { return this.option("maxHeight") }; _proto._getPopupMinHeight = function() { return this.option("minHeight") }; _proto._getPopupPosition = function() { return {} }; _proto._getPopupContainer = function() { return this.option("container") }; _proto._getPopupSlideAnimationObject = function(properties) { return (0, _extend.extend)({ type: "slide", start: () => { (0, _renderer.default)("body").css("overflow", "hidden") }, complete: () => { (0, _renderer.default)("body").css("overflow", "") } }, properties) }; _proto._getPopupAnimation = function() { return { hide: { type: "fadeOut" }, show: { type: "fadeIn" } } }; _proto._getPopupOptions = function() { const that = this; return { animation: (0, _window.hasWindow)() ? this._getPopupAnimation() : null, shading: false, showTitle: false, focusStateEnabled: false, container: this._getPopupContainer(), width: this._getPopupWidth(), height: this._getPopupHeight(), maxWidth: this._getPopupMaxWidth(), maxHeight: this._getPopupMaxHeight(), minWidth: this._getPopupMinWidth(), minHeight: this._getPopupMinHeight(), position: this._getPopupPosition(), showCloseButton: true, copyRootClassesToWrapper: true, _ignoreCopyRootClassesToWrapperDeprecation: true, onContentReady: function() { that._renderPopupContent(that._popup.content()) }, onShowing: () => { this._onVisibilityChangingAction({ visible: true, component: this }) }, onShown: () => { this.option("isVisible", true); this._onVisibilityChangedAction({ visible: true, component: this }) }, onHiding: () => { this._onVisibilityChangingAction({ visible: false, component: this }) }, onHidden: () => { this.option("isVisible", false); this._onVisibilityChangedAction({ visible: false, component: this }) } } }; _proto._renderPopupContent = function($parent) {}; _proto._updatePopupVisible = function() { this._popup.option("visible", this.isVisible()) }; _proto._createOnVisibilityChangingAction = function() { this._onVisibilityChangingAction = this._createActionByOption("onVisibilityChanging") }; _proto._createOnVisibilityChangedAction = function() { this._onVisibilityChangedAction = this._createActionByOption("onVisibilityChanged") }; _proto._optionChanged = function(args) { switch (args.name) { case "onVisibilityChanging": this._createOnVisibilityChangingAction(); break; case "onVisibilityChanged": this._createOnVisibilityChangedAction(); break; case "container": this._popup.option("container", this._getPopupContainer()); break; case "width": this._popup.option("width", this._getPopupWidth()); break; case "height": this._popup.option("height", this._getPopupHeight()); break; case "maxWidth": this._popup.option("maxWidth", this._getPopupMaxWidth()); break; case "maxHeight": this._popup.option("maxHeight", this._getPopupMaxHeight()); break; case "minWidth": this._popup.option("minWidth", this._getPopupMinWidth()); break; case "minHeight": this._popup.option("minHeight", this._getPopupMinHeight()); break; case "isMobileView": this._invalidate(); break; case "isVisible": this._updatePopupVisible(); break; default: _DiagramPanel.prototype._optionChanged.call(this, args) } }; _proto._getDefaultOptions = function() { return (0, _extend.extend)(_DiagramPanel.prototype._getDefaultOptions.call(this), { isVisible: true, isMobileView: false, offsetX: 0, offsetY: 0 }) }; return DiagramFloatingPanel }(_uiDiagram.default); var _default = DiagramFloatingPanel; exports.default = _default; module.exports = exports.default; module.exports.default = exports.default;