UNPKG

devextreme

Version:

JavaScript/TypeScript Component Suite for Responsive Web Development

134 lines (133 loc) 4.87 kB
/** * DevExtreme (esm/__internal/ui/file_manager/ui.file_manager.dialog.js) * Version: 25.2.7 * Build date: Tue May 05 2026 * * Copyright (c) 2012 - 2026 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ import messageLocalization from "../../../common/core/localization/message"; import $ from "../../../core/renderer"; import { isDefined } from "../../../core/utils/type"; import Popup from "../../../ui/popup/ui.popup"; import Widget from "../../core/widget/widget"; const FILE_MANAGER_DIALOG_CONTENT = "dx-filemanager-dialog"; const FILE_MANAGER_DIALOG_POPUP = "dx-filemanager-dialog-popup"; class FileManagerDialogBase extends Widget { _initMarkup() { super._initMarkup(); this._createOnClosedAction(); const options = this._getDialogOptions(); const $popup = $("<div>").appendTo(this.$element()); const popupOptions = { showTitle: true, title: options.title, visible: false, hideOnOutsideClick: true, contentTemplate: this._createContentTemplate.bind(this), toolbarItems: [{ widget: "dxButton", toolbar: "bottom", location: "after", options: { text: options.buttonText, onClick: this._applyDialogChanges.bind(this) } }, { widget: "dxButton", toolbar: "bottom", location: "after", options: { text: messageLocalization.format("dxFileManager-dialogButtonCancel"), onClick: this._closeDialog.bind(this) } }], onInitialized: _ref => { let { component: component } = _ref; component.registerKeyHandler("enter", this._applyDialogChanges.bind(this)) }, onHiding: this._onPopupHiding.bind(this), onShown: this._onPopupShown.bind(this), _wrapperClassExternal: `${FILE_MANAGER_DIALOG_POPUP} ${options.popupCssClass??""}` }; if (isDefined(options.height)) { popupOptions.height = options.height } if (isDefined(options.maxHeight)) { popupOptions.maxHeight = options.maxHeight } this._popup = this._createComponent($popup, Popup, popupOptions) } show() { var _this$_popup; this._dialogResult = null; null === (_this$_popup = this._popup) || void 0 === _this$_popup || _this$_popup.show() } _getDialogOptions() { return { title: "Title", buttonText: "ButtonText", contentCssClass: "", popupCssClass: "" } } _createContentTemplate(element) { this._$contentElement = $("<div>").appendTo(element).addClass("dx-filemanager-dialog"); const cssClass = this._getDialogOptions().contentCssClass; if (cssClass) { this._$contentElement.addClass(cssClass) } } _getDialogResult() { return null } _applyDialogChanges() { const result = this._getDialogResult(); if (result) { this._dialogResult = result; this._closeDialog() } } _closeDialog() { var _this$_popup2; null === (_this$_popup2 = this._popup) || void 0 === _this$_popup2 || _this$_popup2.hide() } _onPopupHiding() { var _this$_onClosedAction; null === (_this$_onClosedAction = this._onClosedAction) || void 0 === _this$_onClosedAction || _this$_onClosedAction.call(this, { dialogResult: this._dialogResult }) } _onPopupShown() {} _createOnClosedAction() { this._onClosedAction = this._createActionByOption("onClosed") } _setTitle(newTitle) { var _this$_popup3; null === (_this$_popup3 = this._popup) || void 0 === _this$_popup3 || _this$_popup3.option("title", newTitle) } _setApplyButtonOptions(options) { var _this$_popup4; null === (_this$_popup4 = this._popup) || void 0 === _this$_popup4 || _this$_popup4.option("toolbarItems[0].options", options) } _getDefaultOptions() { return Object.assign({}, super._getDefaultOptions(), { onClosed: void 0 }) } _optionChanged(args) { const { name: name } = args; if ("onClosed" === name) { this._createOnClosedAction() } else { super._optionChanged(args) } } } export default FileManagerDialogBase;