{"version":3,"file":"main.popup.bundle.js","sources":["../src/compatibility/button.js","../src/popup/popup.js","../src/popup/popup-manager.js","../src/menu/menu-item.js","../src/menu/menu.js","../src/menu/menu-manager.js","../src/compatibility/popup-window.js","../src/compatibility/popup-window-button.js","../src/compatibility/buttonlink.js","../src/compatibility/popup-window-button-link.js","../src/compatibility/custombutton.js","../src/compatibility/popup-window-custom-button.js","../src/compatibility/popup-menu-window.js","../src/compatibility/popup-menu-item.js","../src/compatibility/input-popup.js","../src/index.js"],"sourcesContent":["import { Type, Dom } from 'main.core';\n\ndeclare type ButtonOptions = {\n\tid?: string,\n\ttext?: string,\n\tclassName?: string,\n\tevents?: { [event: string]: (event) => {} }\n};\n\n/**\n * @memberOf BX.Main.Popup\n * @deprecated use BX.UI.Button\n */\nexport default class Button\n{\n\tconstructor(params: ButtonOptions)\n\t{\n\t\tthis.popupWindow = null;\n\n\t\tthis.params = params || {};\n\n\t\tthis.text = this.params.text || '';\n\t\tthis.id = this.params.id || '';\n\t\tthis.className = this.params.className || '';\n\t\tthis.events = this.params.events || {};\n\n\t\tthis.contextEvents = {};\n\t\tfor (let eventName in this.events)\n\t\t{\n\t\t\tif (Type.isFunction(this.events[eventName]))\n\t\t\t{\n\t\t\t\tthis.contextEvents[eventName] = this.events[eventName].bind(this);\n\t\t\t}\n\t\t}\n\n\t\tthis.buttonNode = Dom.create(\n\t\t\t'span',\n\t\t\t{\n\t\t\t\tprops: {\n\t\t\t\t\tclassName: 'popup-window-button' + (this.className.length > 0 ? ' ' + this.className : ''),\n\t\t\t\t\tid: this.id\n\t\t\t\t},\n\t\t\t\tevents: this.contextEvents,\n\t\t\t\ttext: this.text\n\t\t\t}\n\t\t);\n\t}\n\n\trender(): Element\n\t{\n\t\treturn this.buttonNode;\n\t}\n\n\tgetId(): string\n\t{\n\t\treturn this.id;\n\t}\n\n\tgetContainer(): Element\n\t{\n\t\treturn this.buttonNode;\n\t}\n\n\tgetName(): string\n\t{\n\t\treturn this.text;\n\t}\n\n\tsetName(name: string)\n\t{\n\t\tthis.text = name || '';\n\t\tif (this.buttonNode)\n\t\t{\n\t\t\tDom.clean(this.buttonNode);\n\t\t\tDom.adjust(this.buttonNode, { text: this.text });\n\t\t}\n\t}\n\n\tsetClassName(className: string)\n\t{\n\t\tif (this.buttonNode)\n\t\t{\n\t\t\tif (Type.isString(this.className) && (this.className !== ''))\n\t\t\t{\n\t\t\t\tDom.removeClass(this.buttonNode, this.className);\n\t\t\t}\n\n\t\t\tDom.addClass(this.buttonNode, className);\n\t\t}\n\n\t\tthis.className = className;\n\t}\n\n\taddClassName(className: string)\n\t{\n\t\tif (this.buttonNode)\n\t\t{\n\t\t\tDom.addClass(this.buttonNode, className);\n\t\t\tthis.className = this.buttonNode.className;\n\t\t}\n\t}\n\n\tremoveClassName(className: string)\n\t{\n\t\tif (this.buttonNode)\n\t\t{\n\t\t\tDom.removeClass(this.buttonNode, className);\n\t\t\tthis.className = this.buttonNode.className;\n\t\t}\n\t}\n}","import Button from '../compatibility/button';\n\nimport { Type, Text, Tag, Event, Dom, Browser, Reflection } from 'main.core';\nimport { EventEmitter, BaseEvent } from 'main.core.events';\nimport { type PopupOptions, type PopupTarget, type PopupAnimationOptions } from './popup-types';\nimport { ZIndexManager, ZIndexComponent } from 'main.core.z-index-manager';\n\ndeclare type TargetPosition = {\n\tleft: number,\n\ttop: number,\n\tbottom: number,\n\twindowSize: number,\n\twindowScroll: number,\n\tpopupWidth: number,\n\tpopupHeight: number\n};\n\nconst aliases = {\n\tonPopupWindowInit: { namespace: 'BX.Main.Popup', eventName: 'onInit' },\n\tonPopupWindowIsInitialized: { namespace: 'BX.Main.Popup', eventName: 'onAfterInit' },\n\tonPopupFirstShow: { namespace: 'BX.Main.Popup', eventName: 'onFirstShow' },\n\tonPopupShow: { namespace: 'BX.Main.Popup', eventName: 'onShow' },\n\tonAfterPopupShow: { namespace: 'BX.Main.Popup', eventName: 'onAfterShow' },\n\tonPopupClose: { namespace: 'BX.Main.Popup', eventName: 'onClose' },\n\tonPopupAfterClose: { namespace: 'BX.Main.Popup', eventName: 'onAfterClose' },\n\tonPopupDestroy: { namespace: 'BX.Main.Popup', eventName: 'onDestroy' },\n\tonPopupFullscreenLeave: { namespace: 'BX.Main.Popup', eventName: 'onFullscreenLeave' },\n\tonPopupFullscreenEnter: { namespace: 'BX.Main.Popup', eventName: 'onFullscreenEnter' },\n\tonPopupDragStart: { namespace: 'BX.Main.Popup', eventName: 'onDragStart' },\n\tonPopupDrag: { namespace: 'BX.Main.Popup', eventName: 'onDrag' },\n\tonPopupDragEnd: { namespace: 'BX.Main.Popup', eventName: 'onDragEnd' },\n\tonPopupResizeStart: { namespace: 'BX.Main.Popup', eventName: 'onResizeStart' },\n\tonPopupResize: { namespace: 'BX.Main.Popup', eventName: 'onResize' },\n\tonPopupResizeEnd: { namespace: 'BX.Main.Popup', eventName: 'onResizeEnd' }\n};\n\nEventEmitter.registerAliases(aliases);\n\n/**\n * @memberof BX.Main\n */\nexport default class Popup extends EventEmitter\n{\n\t/**\n\t * @private\n\t */\n\tstatic options = {};\n\n\t/**\n\t * @private\n\t */\n\tstatic defaultOptions = {\n\n\t\t//left offset for popup about target\n\t\tangleLeftOffset: 40,\n\n\t\t//when popup position is 'top' offset distance between popup body and target node\n\t\tpositionTopXOffset: -11,\n\n\t\t//offset distance between popup body and target node if use angle, sum with positionTopXOffset\n\t\tangleTopOffset: 10,\n\n\t\tpopupZindex: 1000,\n\t\tpopupOverlayZindex: 1100,\n\n\t\tangleMinLeft: 10,\n\t\tangleMaxLeft: 30,\n\n\t\tangleMinRight: 10,\n\t\tangleMaxRight: 30,\n\n\t\tangleMinBottom: 23,\n\t\tangleMaxBottom: 25,\n\n\t\tangleMinTop: 23,\n\t\tangleMaxTop: 25,\n\n\t\toffsetLeft: 0,\n\t\toffsetTop: 0\n\t};\n\n\tstatic setOptions(options: { [name: string]: any })\n\t{\n\t\tif (!Type.isPlainObject(options))\n\t\t{\n\t\t\treturn;\n\t\t}\n\n\t\tfor (let option in options)\n\t\t{\n\t\t\tthis.options[option] = options[option];\n\t\t}\n\t}\n\n\tstatic getOption(option: string, defaultValue?: any)\n\t{\n\t\tif (!Type.isUndefined(this.options[option]))\n\t\t{\n\t\t\treturn this.options[option];\n\t\t}\n\t\telse if (!Type.isUndefined(defaultValue))\n\t\t{\n\t\t\treturn defaultValue;\n\t\t}\n\t\telse\n\t\t{\n\t\t\treturn this.defaultOptions[option];\n\t\t}\n\t}\n\n\tconstructor(options?: PopupOptions)\n\t{\n\t\tsuper();\n\t\tthis.setEventNamespace('BX.Main.Popup');\n\n\t\tlet [popupId: string, bindElement: PopupTarget, params: PopupOptions] = arguments; //compatible arguments\n\n\t\tthis.compatibleMode = params && Type.isBoolean(params.compatibleMode) ? params.compatibleMode : true;\n\t\tif (Type.isPlainObject(options) && !bindElement && !params)\n\t\t{\n\t\t\tparams = options;\n\t\t\tpopupId = options.id;\n\t\t\tbindElement = options.bindElement;\n\t\t\tthis.compatibleMode = false;\n\t\t}\n\n\t\tparams = params || {};\n\t\tthis.params = params;\n\n\t\tif (!Type.isStringFilled(popupId))\n\t\t{\n\t\t\tpopupId = 'popup-window-' + Text.getRandom().toLowerCase();\n\t\t}\n\n\t\tthis.emit('onInit', new BaseEvent({ compatData: [popupId, bindElement, params] }));\n\n\t\t/**\n\t\t * @private\n\t\t */\n\t\tthis.uniquePopupId = popupId;\n\t\tthis.params.zIndex = Type.isNumber(params.zIndex) ? parseInt(params.zIndex) : 0;\n\t\tthis.params.zIndexAbsolute = Type.isNumber(params.zIndexAbsolute) ? parseInt(params.zIndexAbsolute) : 0;\n\t\tthis.buttons = params.buttons && Type.isArray(params.buttons) ? params.buttons : [];\n\t\tthis.offsetTop = Popup.getOption('offsetTop');\n\t\tthis.offsetLeft = Popup.getOption('offsetLeft');\n\t\tthis.firstShow = false;\n\t\tthis.bordersWidth = 20;\n\t\tthis.bindElementPos = null;\n\t\tthis.closeIcon = null;\n\t\tthis.resizeIcon = null;\n\t\tthis.angle = null;\n\t\tthis.overlay = null;\n\t\tthis.titleBar = null;\n\t\tthis.bindOptions = typeof (params.bindOptions) === 'object' ? params.bindOptions : {};\n\t\tthis.autoHide = params.autoHide === true;\n\t\tthis.autoHideHandler = Type.isFunction(params.autoHideHandler) ? params.autoHideHandler : null;\n\t\tthis.handleAutoHide = this.handleAutoHide.bind(this);\n\t\tthis.handleOverlayClick = this.handleOverlayClick.bind(this);\n\t\tthis.isAutoHideBinded = false;\n\t\tthis.closeByEsc = params.closeByEsc === true;\n\t\tthis.isCloseByEscBinded = false;\n\t\tthis.toFrontOnShow = true;\n\n\t\tthis.cacheable = true;\n\t\tthis.destroyed = false;\n\n\t\tthis.width = null;\n\t\tthis.height = null;\n\t\tthis.minWidth = null;\n\t\tthis.minHeight = null;\n\t\tthis.maxWidth = null;\n\t\tthis.maxHeight = null;\n\n\t\tthis.padding = null;\n\t\tthis.contentPadding = null;\n\t\tthis.background = null;\n\t\tthis.contentBackground = null;\n\n\t\tthis.targetContainer = Type.isElementNode(params.targetContainer) ? params.targetContainer : document.body;\n\n\t\tthis.dragOptions = {\n\t\t\tcursor: '',\n\t\t\tcallback: function() {\n\t\t\t},\n\t\t\teventName: ''\n\t\t};\n\n\t\tthis.dragged = false;\n\t\tthis.dragPageX = 0;\n\t\tthis.dragPageY = 0;\n\n\t\tthis.animationShowClassName = null;\n\t\tthis.animationCloseClassName = null;\n\t\tthis.animationCloseEventType = null;\n\n\t\tthis.handleDocumentMouseMove = this.handleDocumentMouseMove.bind(this);\n\t\tthis.handleDocumentMouseUp = this.handleDocumentMouseUp.bind(this);\n\t\tthis.handleDocumentKeyUp = this.handleDocumentKeyUp.bind(this);\n\t\tthis.handleResizeWindow = this.handleResizeWindow.bind(this);\n\t\tthis.handleResize = this.handleResize.bind(this);\n\t\tthis.handleMove = this.handleMove.bind(this);\n\t\tthis.onTitleMouseDown = this.onTitleMouseDown.bind(this);\n\t\tthis.handleFullScreen = this.handleFullScreen.bind(this);\n\n\t\tthis.subscribeFromOptions(params.events);\n\n\t\tlet popupClassName = 'popup-window';\n\n\t\tif (params.contentColor && Type.isStringFilled(params.contentColor))\n\t\t{\n\t\t\tpopupClassName += ' popup-window-content-' + params.contentColor;\n\t\t}\n\n\t\tif (params.titleBar)\n\t\t{\n\t\t\tpopupClassName += ' popup-window-with-titlebar';\n\t\t}\n\n\t\tif (params.className && Type.isStringFilled(params.className))\n\t\t{\n\t\t\tpopupClassName += ' ' + params.className;\n\t\t}\n\n\t\tif (params.darkMode)\n\t\t{\n\t\t\tpopupClassName += ' popup-window-dark';\n\t\t}\n\n\t\tif (params.titleBar)\n\t\t{\n\t\t\tthis.titleBar = Tag.render`\n\t\t\t\t
\n\t\t\t`;\n\t\t}\n\n\t\tif (params.closeIcon)\n\t\t{\n\t\t\tconst className = 'popup-window-close-icon' + (params.titleBar ? ' popup-window-titlebar-close-icon' : '');\n\t\t\tthis.closeIcon = Tag.render`\n\t\t\t\t\n\t\t\t`;\n\n\t\t\tif (Type.isPlainObject(params.closeIcon))\n\t\t\t{\n\t\t\t\tDom.style(this.closeIcon, params.closeIcon);\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * @private\n\t\t */\n\t\tthis.contentContainer = Tag.render\n\t\t\t``\n\t\t;\n\n\t\t/**\n\t\t * @private\n\t\t */\n\t\tthis.popupContainer = Tag.render\n\t\t\t`