1/* eslint-disable */ 2this.BX = this.BX || {}; 3(function (exports,main_core_zIndexManager,main_core_events,main_core) { 4 'use strict'; 5 6 /** 7 * @memberOf BX.Main.Popup 8 * @deprecated use BX.UI.Button 9 */ 10 var Button = /*#__PURE__*/function () { 11 function Button(params) { 12 babelHelpers.classCallCheck(this, Button); 13 this.popupWindow = null; 14 this.params = params || {}; 15 this.text = this.params.text || ''; 16 this.id = this.params.id || ''; 17 this.className = this.params.className || ''; 18 this.events = this.params.events || {}; 19 this.contextEvents = {}; 20 for (var eventName in this.events) { 21 if (main_core.Type.isFunction(this.events[eventName])) { 22 this.contextEvents[eventName] = this.events[eventName].bind(this); 23 } 24 } 25 this.buttonNode = main_core.Dom.create('span', { 26 props: { 27 className: 'popup-window-button' + (this.className.length > 0 ? ' ' + this.className : ''), 28 id: this.id 29 }, 30 events: this.contextEvents, 31 text: this.text 32 }); 33 } 34 babelHelpers.createClass(Button, [{ 35 key: "render", 36 value: function render() { 37 return this.buttonNode; 38 } 39 }, { 40 key: "getId", 41 value: function getId() { 42 return this.id; 43 } 44 }, { 45 key: "getContainer", 46 value: function getContainer() { 47 return this.buttonNode; 48 } 49 }, { 50 key: "getName", 51 value: function getName() { 52 return this.text; 53 } 54 }, { 55 key: "setName", 56 value: function setName(name) { 57 this.text = name || ''; 58 if (this.buttonNode) { 59 main_core.Dom.clean(this.buttonNode); 60 main_core.Dom.adjust(this.buttonNode, { 61 text: this.text 62 }); 63 } 64 } 65 }, { 66 key: "setClassName", 67 value: function setClassName(className) { 68 if (this.buttonNode) { 69 if (main_core.Type.isString(this.className) && this.className !== '') { 70 main_core.Dom.removeClass(this.buttonNode, this.className); 71 } 72 main_core.Dom.addClass(this.buttonNode, className); 73 } 74 this.className = className; 75 } 76 }, { 77 key: "addClassName", 78 value: function addClassName(className) { 79 if (this.buttonNode) { 80 main_core.Dom.addClass(this.buttonNode, className); 81 this.className = this.buttonNode.className; 82 } 83 } 84 }, { 85 key: "removeClassName", 86 value: function removeClassName(className) { 87 if (this.buttonNode) { 88 main_core.Dom.removeClass(this.buttonNode, className); 89 this.className = this.buttonNode.className; 90 } 91 } 92 }]); 93 return Button; 94 }(); 95 96 function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); } 97 function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } } 98 var _left = /*#__PURE__*/new WeakMap(); 99 var _top = /*#__PURE__*/new WeakMap(); 100 var PositionEvent = /*#__PURE__*/function (_BaseEvent) { 101 babelHelpers.inherits(PositionEvent, _BaseEvent); 102 function PositionEvent() { 103 var _this; 104 babelHelpers.classCallCheck(this, PositionEvent); 105 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(PositionEvent).call(this)); 106 _classPrivateFieldInitSpec(babelHelpers.assertThisInitialized(_this), _left, { 107 writable: true, 108 value: void 0 109 }); 110 _classPrivateFieldInitSpec(babelHelpers.assertThisInitialized(_this), _top, { 111 writable: true, 112 value: void 0 113 }); 114 return _this; 115 } 116 babelHelpers.createClass(PositionEvent, [{ 117 key: "left", 118 get: function get() { 119 return babelHelpers.classPrivateFieldGet(this, _left); 120 }, 121 set: function set(value) { 122 if (main_core.Type.isNumber(value)) { 123 babelHelpers.classPrivateFieldSet(this, _left, value); 124 } 125 } 126 }, { 127 key: "top", 128 get: function get() { 129 return babelHelpers.classPrivateFieldGet(this, _top); 130 }, 131 set: function set(value) { 132 if (main_core.Type.isNumber(value)) { 133 babelHelpers.classPrivateFieldSet(this, _top, value); 134 } 135 } 136 }]); 137 return PositionEvent; 138 }(main_core_events.BaseEvent); 139 140 /** 141 * @namespace {BX.Main.Popup} 142 */ 143 var CloseIconSize = Object.freeze({ 144 LARGE: 'large', 145 SMALL: 'small' 146 }); 147
148 var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9; 149 function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration$1(obj, privateSet); privateSet.add(obj); } 150 function _checkPrivateRedeclaration$1(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } } 151 function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; } 152 var aliases = { 153 onPopupWindowInit: { 154 namespace: 'BX.Main.Popup', 155 eventName: 'onInit' 156 }, 157 onPopupWindowIsInitialized: { 158 namespace: 'BX.Main.Popup', 159 eventName: 'onAfterInit' 160 }, 161 onPopupFirstShow: { 162 namespace: 'BX.Main.Popup', 163 eventName: 'onFirstShow' 164 }, 165 onPopupShow: { 166 namespace: 'BX.Main.Popup', 167 eventName: 'onShow' 168 }, 169 onAfterPopupShow: { 170 namespace: 'BX.Main.Popup', 171 eventName: 'onAfterShow' 172 }, 173 onPopupClose: { 174 namespace: 'BX.Main.Popup', 175 eventName: 'onClose' 176 }, 177 onPopupAfterClose: { 178 namespace: 'BX.Main.Popup', 179 eventName: 'onAfterClose' 180 }, 181 onPopupDestroy: { 182 namespace: 'BX.Main.Popup', 183 eventName: 'onDestroy' 184 }, 185 onPopupFullscreenLeave: { 186 namespace: 'BX.Main.Popup', 187 eventName: 'onFullscreenLeave' 188 }, 189 onPopupFullscreenEnter: { 190 namespace: 'BX.Main.Popup', 191 eventName: 'onFullscreenEnter' 192 }, 193 onPopupDragStart: { 194 namespace: 'BX.Main.Popup', 195 eventName: 'onDragStart' 196 }, 197 onPopupDrag: { 198 namespace: 'BX.Main.Popup', 199 eventName: 'onDrag' 200 }, 201 onPopupDragEnd: { 202 namespace: 'BX.Main.Popup', 203 eventName: 'onDragEnd' 204 }, 205 onPopupResizeStart: { 206 namespace: 'BX.Main.Popup', 207 eventName: 'onResizeStart' 208 }, 209 onPopupResize: { 210 namespace: 'BX.Main.Popup', 211 eventName: 'onResize' 212 }, 213 onPopupResizeEnd: { 214 namespace: 'BX.Main.Popup', 215 eventName: 'onResizeEnd' 216 } 217 }; 218 main_core_events.EventEmitter.registerAliases(aliases); 219 var disabledScrolls = new WeakMap(); 220 221 /** 222 * @memberof BX.Main 223 */ 224 var _disableTargetScroll = /*#__PURE__*/new WeakSet(); 225 var _enableTargetScroll = /*#__PURE__*/new WeakSet(); 226 var _startDrag = /*#__PURE__*/new WeakSet(); 227 var Popup = /*#__PURE__*/function (_EventEmitter) { 228 babelHelpers.inherits(Popup, _EventEmitter); 229 babelHelpers.createClass(Popup, null, [{ 230 key: "setOptions", 231 /** 232 * @private 233 */ 234 /** 235 * @private 236 */ 237 value: function setOptions(options) { 238 if (!main_core.Type.isPlainObject(options)) { 239 return; 240 } 241 for (var option in options) { 242 this.options[option] = options[option]; 243 } 244 } 245 }, { 246 key: "getOption", 247 value: function getOption(option, defaultValue) { 248 if (!main_core.Type.isUndefined(this.options[option])) { 249 return this.options[option]; 250 } 251 if (!main_core.Type.isUndefined(defaultValue)) { 252 return defaultValue; 253 } 254 return this.defaultOptions[option]; 255 } 256 }]); 257 function Popup(_options) { 258 var _this; 259 babelHelpers.classCallCheck(this, Popup); 260 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Popup).call(this)); 261 _classPrivateMethodInitSpec(babelHelpers.assertThisInitialized(_this), _startDrag); 262 _classPrivateMethodInitSpec(babelHelpers.assertThisInitialized(_this), _enableTargetScroll); 263 _classPrivateMethodInitSpec(babelHelpers.assertThisInitialized(_this), _disableTargetScroll); 264 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "handleAutoHide", function (event) { 265 if (_this.isDestroyed()) { 266 return; 267 } 268 if (_this.autoHideHandler !== null) { 269 if (_this.autoHideHandler(event)) { 270 _this._tryCloseByEvent(event); 271 } 272 } else if (event.target !== _this.getPopupContainer() && !_this.getPopupContainer().contains(event.target)) { 273 _this._tryCloseByEvent(event); 274 } 275 }); 276 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "handleDocumentKeyUp", function (event) { 277 if (event.keyCode === 27) { 278 checkEscPressed(_this.getZindex(), function () { 279 _this.close(); 280 }); 281 } 282 }); 283 _this.setEventNamespace('BX.Main.Popup'); 284 var _arguments = Array.prototype.slice.call(arguments), 285 popupId = _arguments[0], 286 bindElement = _arguments[1], 287 params = _arguments[2]; // compatible arguments 288 289 _this.compatibleMode = params && main_core.Type.isBoolean(params.compatibleMode) ? params.compatibleMode : true; 290 if (main_core.Type.isPlainObject(_options) && !bindElement && !params) { 291 params = _options; 292 popupId = _options.id; 293 bindElement = _options.bindElement; 294 _this.compatibleMode = false;
295 } 296 params = params || {}; 297 _this.params = params; 298 if (!main_core.Type.isStringFilled(popupId)) { 299 popupId = "popup-window-".concat(main_core.Text.getRandom().toLowerCase()); 300 } 301 _this.emit('onInit', new main_core_events.BaseEvent({ 302 compatData: [popupId, bindElement, params] 303 })); 304 305 /** 306 * @private 307 */ 308 _this.uniquePopupId = popupId; 309 _this.params.zIndex = main_core.Type.isNumber(params.zIndex) ? parseInt(params.zIndex) : 0; 310 _this.params.zIndexAbsolute = main_core.Type.isNumber(params.zIndexAbsolute) ? parseInt(params.zIndexAbsolute) : 0; 311 _this.buttons = params.buttons && main_core.Type.isArray(params.buttons) ? params.buttons : []; 312 _this.offsetTop = Popup.getOption('offsetTop'); 313 _this.offsetLeft = Popup.getOption('offsetLeft'); 314 _this.firstShow = false; 315 _this.bordersWidth = 20; 316 _this.bindElementPos = null; 317 _this.closeIcon = null; 318 _this.resizeIcon = null; 319 _this.angle = null; 320 _this.angleArrowElement = null; 321 _this.overlay = null; 322 _this.titleBar = null; 323 _this.bindOptions = main_core.Type.isObject(params.bindOptions) ? params.bindOptions : {}; 324 _this.autoHide = params.autoHide === true; 325 _this.disableScroll = params.disableScroll === true || params.isScrollBlock === true; 326 _this.autoHideHandler = main_core.Type.isFunction(params.autoHideHandler) ? params.autoHideHandler : null; 327 _this.isAutoHideBinded = false; 328 _this.closeByEsc = params.closeByEsc === true; 329 _this.isCloseByEscBinded = false; 330 _this.toFrontOnShow = true; 331 _this.cacheable = true; 332 _this.destroyed = false; 333 _this.fixed = false; 334 _this.width = null; 335 _this.height = null; 336 _this.minWidth = null; 337 _this.minHeight = null; 338 _this.maxWidth = null; 339 _this.maxHeight = null; 340 _this.padding = null; 341 _this.contentPadding = null; 342 _this.background = null; 343 _this.contentBackground = null; 344 _this.borderRadius = null; 345 _this.contentBorderRadius = null; 346 _this.setTargetContainer(params.targetContainer); 347 _this.dragOptions = { 348 cursor: '', 349 callback: function callback() {}, 350 eventName: '' 351 }; 352 _this.dragged = false; 353 _this.dragPageX = 0; 354 _this.dragPageY = 0; 355 _this.animationShowClassName = null; 356 _this.animationCloseClassName = null; 357 _this.animationCloseEventType = null; 358 _this.handleDocumentMouseMove = _this.handleDocumentMouseMove.bind(babelHelpers.assertThisInitialized(_this)); 359 _this.handleDocumentMouseUp = _this.handleDocumentMouseUp.bind(babelHelpers.assertThisInitialized(_this)); 360 _this.handleResizeWindow = _this.handleResizeWindow.bind(babelHelpers.assertThisInitialized(_this)); 361 _this.handleResize = _this.handleResize.bind(babelHelpers.assertThisInitialized(_this)); 362 _this.handleMove = _this.handleMove.bind(babelHelpers.assertThisInitialized(_this)); 363 _this.onTitleMouseDown = _this.onTitleMouseDown.bind(babelHelpers.assertThisInitialized(_this)); 364 _this.handleFullScreen = _this.handleFullScreen.bind(babelHelpers.assertThisInitialized(_this)); 365 _this.subscribeFromOptions(params.events); 366 var popupClassName = 'popup-window'; 367 if (params.titleBar) { 368 popupClassName += ' popup-window-with-titlebar'; 369 } 370 if (params.className && main_core.Type.isStringFilled(params.className)) { 371 popupClassName += " ".concat(params.className); 372 } 373 if (params.darkMode) { 374 popupClassName += ' popup-window-dark'; 375 } 376 _this.designSystemContext = params.darkMode ? '--ui-context-content-dark' : '--ui-context-content-light'; 377 popupClassName += " ".concat(_this.designSystemContext); 378 if (params.titleBar) { 379 _this.titleBar = main_core.Tag.render(_templateObject || (_templateObject = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<div class=\"popup-window-titlebar\" id=\"popup-window-titlebar-", "\"></div>\n\t\t\t"])), popupId); 380 } 381 if (params.closeIcon) { 382 var className = "popup-window-close-icon".concat(params.titleBar ? ' popup-window-titlebar-close-icon' : ''); 383 if (Object.values(CloseIconSize).includes(params.closeIconSize) && params.closeIconSize !== CloseIconSize.SMALL) { 384 className += " --".concat(params.closeIconSize); 385 }
386 _this.closeIcon = main_core.Tag.render(_templateObject2 || (_templateObject2 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<span class=\"", "\" onclick=\"", "\"></span>\n\t\t\t"])), className, _this.handleCloseIconClick.bind(babelHelpers.assertThisInitialized(_this))); 387 if (main_core.Type.isPlainObject(params.closeIcon)) { 388 main_core.Dom.style(_this.closeIcon, params.closeIcon); 389 } 390 } 391 392 /** 393 * @private 394 */ 395 _this.contentContainer = main_core.Tag.render(_templateObject3 || (_templateObject3 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t<div id=\"popup-window-content-", "\" class=\"popup-window-content\"></div>\n\t\t"])), popupId); 396 397 /** 398 * @private 399 */ 400 _this.popupContainer = main_core.Tag.render(_templateObject4 || (_templateObject4 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t<div\n\t\t\t\tclass=\"", "\"\n\t\t\t\tid=\"", "\"\n\t\t\t\tstyle=\"display: none; position: absolute; left: 0; top: 0;\"\n\t\t\t>", "</div>\n\t\t"])), popupClassName, popupId, [_this.titleBar, _this.contentContainer, _this.closeIcon]); 401 _this.getTargetContainer().append(_this.popupContainer); 402 _this.zIndexComponent = main_core_zIndexManager.ZIndexManager.register(_this.popupContainer, params.zIndexOptions); 403 _this.buttonsContainer = null; 404 if (params.contentColor && main_core.Type.isStringFilled(params.contentColor)) { 405 _this.setContentColor(params.contentColor); 406 } 407 if (params.angle) { 408 _this.setAngle(params.angle); 409 } 410 if (params.overlay) { 411 _this.setOverlay(params.overlay); 412 } 413 _this.setOffset(params); 414 _this.setBindElement(bindElement); 415 _this.setTitleBar(params.titleBar); 416 _this.setDraggable(params.draggable); 417 _this.setContent(params.content); 418 _this.setButtons(params.buttons); 419 _this.setWidth(params.width); 420 _this.setHeight(params.height); 421 _this.setMinWidth(params.minWidth); 422 _this.setMinHeight(params.minHeight); 423 _this.setMaxWidth(params.maxWidth); 424 _this.setMaxHeight(params.maxHeight); 425 _this.setResizeMode(params.resizable); 426 _this.setPadding(params.padding); 427 _this.setContentPadding(params.contentPadding); 428 _this.setBorderRadius(params.borderRadius); 429 _this.setContentBorderRadius(params.contentBorderRadius); 430 _this.setBackground(params.background); 431 _this.setContentBackground(params.contentBackground); 432 _this.setAnimation(params.animation); 433 _this.setCacheable(params.cacheable); 434 _this.setToFrontOnShow(params.toFrontOnShow); 435 _this.setFixed(params.fixed); 436 _this.setDesignSystemContext(params.designSystemContext); 437 438 // Compatibility 439 if (params.contentNoPaddings) { 440 _this.setContentPadding(0); 441 } 442 if (params.noAllPaddings) { 443 _this.setPadding(0); 444 _this.setContentPadding(0); 445 } 446 if (params.bindOnResize !== false) { 447 main_core.Event.bind(window, 'resize', _this.handleResizeWindow); 448 } 449 _this.emit('onAfterInit', new main_core_events.BaseEvent({ 450 compatData: [popupId, babelHelpers.assertThisInitialized(_this)] 451 })); 452 return _this; 453 } 454 455 /** 456 * @private 457 */ 458 babelHelpers.createClass(Popup, [{ 459 key: "subscribeFromOptions", 460 value: function subscribeFromOptions(events) { 461 babelHelpers.get(babelHelpers.getPrototypeOf(Popup.prototype), "subscribeFromOptions", this).call(this, events, aliases); 462 } 463 }, { 464 key: "getId", 465 value: function getId() { 466 return this.uniquePopupId; 467 } 468 }, { 469 key: "isCompatibleMode", 470 value: function isCompatibleMode() { 471 return this.compatibleMode; 472 } 473 }, { 474 key: "setContent", 475 value: function setContent(content) { 476 if (!this.contentContainer || !content) { 477 return; 478 } 479 if (main_core.Type.isElementNode(content)) { 480 main_core.Dom.clean(this.contentContainer); 481 var hasParent = main_core.Type.isDomNode(content.parentNode); 482 this.contentContainer.appendChild(content); 483 if (this.isCompatibleMode() || hasParent) { 484 content.style.display = 'block'; 485 } 486 } else if (main_core.Type.isString(content)) { 487 this.contentContainer.innerHTML = content; 488 } else { 489 this.contentContainer.innerHTML = ' '; 490 } 491 } 492 }, { 493 key: "setButtons", 494 value: function setButtons(buttons) { 495 this.buttons = buttons && main_core.Type.isArray(buttons) ? buttons : []; 496 if (this.buttonsContainer) { 497 main_core.Dom.remove(this.buttonsContainer); 498 } 499 var ButtonClass = main_core.Reflection.getClass('BX.UI.Button'); 500 if (this.buttons.length > 0 && this.contentContainer) { 501 var newButtons = []; 502 for (var i = 0; i < this.buttons.length; i++) { 503 var button = this.buttons[i]; 504 if (button instanceof Button) { 505 button.popupWindow = this; 506 newButtons.push(button.render()); 507 } else if (ButtonClass && button instanceof ButtonClass) { 508 button.setContext(this); 509 newButtons.push(button.render()); 510 } 511 } 512 this.buttonsContainer = this.contentContainer.parentNode.appendChild(main_core.Tag.render(_templateOb
512ject5 || (_templateObject5 = babelHelpers.taggedTemplateLiteral(["<div class=\"popup-window-buttons\">", "</div>"])), newButtons)); 513 } 514 } 515 }, { 516 key: "getButtons", 517 value: function getButtons() { 518 return this.buttons; 519 } 520 }, { 521 key: "getButton", 522 value: function getButton(id) { 523 for (var i = 0; i < this.buttons.length; i++) { 524 var button = this.buttons[i]; 525 if (button.getId() === id) { 526 return button; 527 } 528 } 529 return null; 530 } 531 }, { 532 key: "setBindElement", 533 value: function setBindElement(bindElement) { 534 if (bindElement === null) { 535 this.bindElement = null; 536 } else if (main_core.Type.isObject(bindElement)) { 537 if (main_core.Type.isDomNode(bindElement) || main_core.Type.isNumber(bindElement.top) && main_core.Type.isNumber(bindElement.left)) { 538 this.bindElement = bindElement; 539 } else if (main_core.Type.isNumber(bindElement.clientX) && main_core.Type.isNumber(bindElement.clientY)) { 540 this.bindElement = { 541 left: bindElement.pageX, 542 top: bindElement.pageY, 543 bottom: bindElement.pageY 544 }; 545 } 546 } 547 } 548 /** 549 * @private 550 */ 551 }, { 552 key: "getBindElementPos", 553 value: function getBindElementPos(bindElement) { 554 if (main_core.Type.isDomNode(bindElement)) { 555 if (this.isTargetDocumentBody()) { 556 return this.isFixed() ? bindElement.getBoundingClientRect() : main_core.Dom.getPosition(bindElement); 557 } 558 return this.getPositionRelativeToTarget(bindElement); 559 } 560 if (bindElement && main_core.Type.isObject(bindElement)) { 561 if (!main_core.Type.isNumber(bindElement.bottom)) { 562 bindElement.bottom = bindElement.top; 563 } 564 return bindElement; 565 } 566 var windowSize = this.getWindowSize(); 567 var windowScroll = this.getWindowScroll(); 568 var popupWidth = this.getPopupContainer().offsetWidth; 569 var popupHeight = this.getPopupContainer().offsetHeight; 570 this.bindOptions.forceTop = true; 571 return { 572 left: windowSize.innerWidth / 2 - popupWidth / 2 + windowScroll.scrollLeft, 573 top: windowSize.innerHeight / 2 - popupHeight / 2 + (this.isFixed() ? 0 : windowScroll.scrollTop), 574 bottom: windowSize.innerHeight / 2 - popupHeight / 2 + (this.isFixed() ? 0 : windowScroll.scrollTop), 575 // for optimisation purposes 576 windowSize: windowSize, 577 windowScroll: windowScroll, 578 popupWidth: popupWidth, 579 popupHeight: popupHeight 580 }; 581 } 582 /** 583 * @internal 584 */ 585 }, { 586 key: "getPositionRelativeToTarget", 587 value: function getPositionRelativeToTarget(element) { 588 var offsetLeft = element.offsetLeft; 589 var offsetTop = element.offsetTop; 590 var offsetElement = element.offsetParent; 591 while (offsetElement && offsetElement !== this.getTargetContainer()) { 592 offsetLeft += offsetElement.offsetLeft; 593 offsetTop += offsetElement.offsetTop; 594 offsetElement = offsetElement.offsetParent; 595 } 596 var elementRect = element.getBoundingClientRect(); 597 return new DOMRect(offsetLeft, offsetTop, elementRect.width, elementRect.height); 598 } // private 599 }, { 600 key: "getWindowSize", 601 value: function getWindowSize() { 602 if (this.isTargetDocumentBody()) { 603 return { 604 innerWidth: window.innerWidth, 605 innerHeight: window.innerHeight 606 }; 607 } 608 return { 609 innerWidth: this.getTargetContainer().offsetWidth, 610 innerHeight: this.getTargetContainer().offsetHeight 611 }; 612 } // private 613 }, { 614 key: "getWindowScroll", 615 value: function getWindowScroll() { 616 if (this.isTargetDocumentBody()) { 617 return { 618 scrollLeft: window.pageXOffset, 619 scrollTop: window.pageYOffset 620 }; 621 } 622 return { 623 scrollLeft: this.getTargetContainer().scrollLeft, 624 scrollTop: this.getTargetContainer().scrollTop 625 }; 626 } 627 }, { 628 key: "setAngle", 629 value: function setAngle(params) { 630 if (params === false) { 631 if (this.angle !== null) { 632 main_core.Dom.remove(this.angle.element); 633 } 634 this.angle = null; 635 this.angleArrowElement = null; 636 return; 637 } 638 var className = 'popup-window-angly'; 639 if (this.angle === null) { 640 var position = this.bindOptions.position && this.bindOptions.position === 'top' ? 'bottom' : 'top'; 641 var angleMinLeft = Popup.getOption(position === 'top' ? 'angleMinTop' : 'angleMinBottom'); 642 var defaultOffset = main_core.Type.isNumber(params.offset) ? params.offset : 0; 643 var angleLeftOffset = Popup.getOption('angleLeftOffset', null); 644 if (defaultOffset > 0 && main_core.Type.isNumber(angleLeftOffset)) { 645 defaultOffset += angleLeftOffset - Popup.defaultOptions.angleLeftOffset; 646 } 647 this.angleArrowElement = main_core.Tag.render(_templateOb
647ject6 || (_templateObject6 = babelHelpers.taggedTemplateLiteral(["<div class=\"popup-window-angly--arrow\"></div>"]))); 648 if (this.background) { 649 this.angleArrowElement.style.background = this.background; 650 } 651 this.angle = { 652 element: main_core.Tag.render(_templateObject7 || (_templateObject7 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t\t<div class=\"", " ", "-", "\">\n\t\t\t\t\t\t", "\n\t\t\t\t\t</div>\n\t\t\t\t"])), className, className, position, this.angleArrowElement), 653 position: position, 654 offset: 0, 655 defaultOffset: Math.max(defaultOffset, angleMinLeft) 656 // Math.max(Type.isNumber(params.offset) ? params.offset : 0, angleMinLeft) 657 }; 658 659 this.getPopupContainer().appendChild(this.angle.element); 660 } 661 if (main_core.Type.isObject(params) && params.position && ['top', 'right', 'bottom', 'left', 'hide'].includes(params.position)) { 662 main_core.Dom.removeClass(this.angle.element, "".concat(className, "-").concat(this.angle.position)); 663 main_core.Dom.addClass(this.angle.element, "".concat(className, "-").concat(params.position)); 664 this.angle.position = params.position; 665 } 666 if (main_core.Type.isObject(params) && main_core.Type.isNumber(params.offset)) { 667 var offset = params.offset; 668 var minOffset, maxOffset; 669 if (this.angle.position === 'top') { 670 minOffset = Popup.getOption('angleMinTop'); 671 maxOffset = this.getPopupContainer().offsetWidth - Popup.getOption('angleMaxTop'); 672 maxOffset = maxOffset < minOffset ? Math.max(minOffset, offset) : maxOffset; 673 this.angle.offset = Math.min(Math.max(minOffset, offset), maxOffset); 674 this.angle.element.style.left = "".concat(this.angle.offset, "px"); 675 this.angle.element.style.marginLeft = 0; 676 this.angle.element.style.removeProperty('top'); 677 } else if (this.angle.position === 'bottom') { 678 minOffset = Popup.getOption('angleMinBottom'); 679 maxOffset = this.getPopupContainer().offsetWidth - Popup.getOption('angleMaxBottom'); 680 maxOffset = maxOffset < minOffset ? Math.max(minOffset, offset) : maxOffset; 681 this.angle.offset = Math.min(Math.max(minOffset, offset), maxOffset); 682 this.angle.element.style.marginLeft = "".concat(this.angle.offset, "px"); 683 this.angle.element.style.left = 0; 684 this.angle.element.style.removeProperty('top'); 685 } else if (this.angle.position === 'right') { 686 minOffset = Popup.getOption('angleMinRight'); 687 maxOffset = this.getPopupContainer().offsetHeight - Popup.getOption('angleMaxRight'); 688 maxOffset = maxOffset < minOffset ? Math.max(minOffset, offset) : maxOffset; 689 this.angle.offset = Math.min(Math.max(minOffset, offset), maxOffset); 690 this.angle.element.style.top = "".concat(this.angle.offset, "px"); 691 this.angle.element.style.removeProperty('left'); 692 this.angle.element.style.removeProperty('margin-left'); 693 } else if (this.angle.position === 'left') { 694 minOffset = Popup.getOption('angleMinLeft'); 695 maxOffset = this.getPopupContainer().offsetHeight - Popup.getOption('angleMaxLeft'); 696 maxOffset = maxOffset < minOffset ? Math.max(minOffset, offset) : maxOffset; 697 this.angle.offset = Math.min(Math.max(minOffset, offset), maxOffset); 698 this.angle.element.style.top = "".concat(this.angle.offset, "px"); 699 this.angle.element.style.removeProperty('left'); 700 this.angle.element.style.removeProperty('margin-left'); 701 } 702 } 703 } 704 }, { 705 key: "getWidth", 706 value: function getWidth() { 707 return this.width; 708 } 709 }, { 710 key: "setWidth", 711 value: function setWidth(width) { 712 this.setWidthProperty('width', width); 713 } 714 }, { 715 key: "getHeight", 716 value: function getHeight() { 717 return this.height; 718 } 719 }, { 720 key: "setHeight", 721 value: function setHeight(height) { 722 this.setHeightProperty('height', height); 723 } 724 }, { 725 key: "getMinWidth", 726 value: function getMinWidth() { 727 return this.minWidth; 728 } 729 }, { 730 key: "setMinWidth", 731 value: function setMinWidth(width) { 732 this.setWidthProperty('minWidth', width); 733 } 734 }, { 735 key: "getMinHeight", 736 value: function getMinHeight() { 737 return this.minHeight; 738 } 739 }, { 740 key: "setMinHeight", 741 value: function setMinHeight(height) { 742 this.setHeightProperty('minHeight', height); 743 } 744 }, { 745 key: "getMaxWidth", 746 value: function getMaxWidth() { 747 return this.maxWidth; 748 } 749 }, { 750 key: "setMaxWidth", 751 value: function setMaxWidth(width) { 752 this.setWidthProperty('maxWidth', width); 753 } 754 }, { 755 key: "getMaxHeight", 756 value: function getMaxHeight() { 757 return this.maxHeight; 758 } 759 }, { 760 key: "setMaxHeight", 761 value: function setMaxHeight(height) { 762 this.setHeightProperty('maxHeight', height); 763 } 764 /** 765 * @private 766 */ 767 }, { 768 key: "setWidthProperty", 769 value: function setWidthProperty(property, width) { 770 var _this2 = this; 771 var props = ['width', 'minWidth', 'maxWidth']; 772 if (!props.includes(property)) { 773 return; 774 } 775 if (main_core.Type.isNumber(width) && width >= 0) { 776 this[property] = width; 777 this.getResizableContainer().style[property] = "".concat(width, "px"); 778 this.getContentContainer().style.overflowX = 'auto'; 779 this.getPopupContainer().classList.add('popup-window-fixed-width'); 780 } else if (width === null || width === false) { 781 this[property] = null; 782 this.getResizableContainer().style.removeProperty(main_core.Text.toKebabCase(property)); 783 var hasOtherProps = props.some(function (prop) { 784 return _this2.getResizableContainer().style.getPropertyValue(main_core.Text.toKebabCase(prop)) !== ''; 785 }); 786 if (!hasOtherProps) { 787 this.getContentContainer().style.removeProperty('overflow-x'); 788 this.getPopupContainer().classList.remove('popup-window-fixed-width'); 789 } 790 } 791 } 792 /** 793 * @private 794 */ 795 }, { 796 key: "setHeightProperty", 797 value: function setHeightProperty(property, height) { 798 var _this3 = this; 799 var props = ['height', 'minHeight', 'maxHeight']; 800 if (!props.includes(property)) { 801 return; 802 } 803 if (main_core.Type.isNumber(height) && height >= 0) { 804 this[property] = height; 805 this.getResizableContainer().style[property] = "".concat(height, "px"); 806 this.getContentContainer().style.overflowY = 'auto'; 807 this.getPopupContainer().classList.add('popup-window-fixed-height'); 808 } else if (height === null || height === false) { 809 this[property] = null; 810 this.getResizableContainer().style.removeProperty(main_core.Text.toKebabCase(property)); 811 var hasOtherProps = props.some(function (prop) { 812 return _this3.getResizableContainer().style.getPropertyValue(main_core.Text.toKebabCase(prop)) !== ''; 813 }); 814 if (!hasOtherProps) { 815 this.getContentContainer().style.removeProperty('overflow-y'); 816 this.getPopupContainer().classList.remove('popup-window-fixed-height'); 817 } 818 } 819 } 820 }, { 821 key: "setPadding", 822 value: function setPadding(padding) { 823 if (main_core.Type.isNumber(padding) && padding >= 0) { 824 this.padding = padding;
825 this.getPopupContainer().style.padding = "".concat(padding, "px"); 826 } else if (padding === null) { 827 this.padding = null; 828 this.getPopupContainer().style.removeProperty('padding'); 829 } 830 } 831 }, { 832 key: "getPadding", 833 value: function getPadding() { 834 return this.padding; 835 } 836 }, { 837 key: "setContentPadding", 838 value: function setContentPadding(padding) { 839 if (main_core.Type.isNumber(padding) && padding >= 0) { 840 this.contentPadding = padding; 841 this.getContentContainer().style.padding = "".concat(padding, "px"); 842 } else if (padding === null) { 843 this.contentPadding = null; 844 this.getContentContainer().style.removeProperty('padding'); 845 } 846 } 847 }, { 848 key: "getContentPadding", 849 value: function getContentPadding() { 850 return this.contentPadding; 851 } 852 }, { 853 key: "setBorderRadius", 854 value: function setBorderRadius(radius) { 855 if (main_core.Type.isStringFilled(radius)) { 856 this.borderRadius = radius; 857 this.getPopupContainer().style.setProperty('--popup-window-border-radius', radius); 858 } else if (radius === null) { 859 this.borderRadius = null; 860 this.getPopupContainer().style.removeProperty('--popup-window-border-radius'); 861 } 862 } 863 }, { 864 key: "setContentBorderRadius", 865 value: function setContentBorderRadius(radius) { 866 if (main_core.Type.isStringFilled(radius)) { 867 this.contentBorderRadius = radius; 868 this.getContentContainer().style.setProperty('--popup-window-content-border-radius', radius); 869 } else if (radius === null) { 870 this.contentBorderRadius = null; 871 this.getContentContainer().style.removeProperty('--popup-window-content-border-radius'); 872 } 873 } 874 }, { 875 key: "setContentColor", 876 value: function setContentColor(color) { 877 if (main_core.Type.isString(color) && this.contentContainer) { 878 this.contentContainer.style.backgroundColor = color; 879 } else if (color === null) { 880 this.contentContainer.style.style.removeProperty('background-color'); 881 } 882 } 883 }, { 884 key: "setBackground", 885 value: function setBackground(background) { 886 if (main_core.Type.isStringFilled(background)) { 887 this.background = background; 888 this.getPopupContainer().style.background = background; 889 if (this.angleArrowElement) { 890 this.angleArrowElement.style.background = background; 891 } 892 } else if (background === null) { 893 this.background = null; 894 this.getPopupContainer().style.removeProperty('background'); 895 if (this.angleArrowElement) { 896 this.angleArrowElement.style.removeProperty('background'); 897 } 898 } 899 } 900 }, { 901 key: "getBackground", 902 value: function getBackground() { 903 return this.background; 904 } 905 }, { 906 key: "setContentBackground", 907 value: function setContentBackground(background) { 908 if (main_core.Type.isStringFilled(background)) { 909 this.contentBackground = background; 910 this.getContentContainer().style.background = background; 911 } else if (background === null) { 912 this.contentBackground = null; 913 this.getContentContainer().style.removeProperty('background'); 914 } 915 } 916 }, { 917 key: "getContentBackground", 918 value: function getContentBackground() { 919 return this.contentBackground; 920 } 921 }, { 922 key: "isDestroyed", 923 value: function isDestroyed() { 924 return this.destroyed; 925 } 926 }, { 927 key: "setCacheable", 928 value: function setCacheable(cacheable) { 929 this.cacheable = cacheable !== false; 930 } 931 }, { 932 key: "isCacheable", 933 value: function isCacheable() { 934 return this.cacheable; 935 } 936 }, { 937 key: "setToFrontOnShow", 938 value: function setToFrontOnShow(flag) { 939 this.toFrontOnShow = flag !== false; 940 } 941 }, { 942 key: "shouldFrontOnShow", 943 value: function shouldFrontOnShow() { 944 return this.toFrontOnShow; 945 } 946 }, { 947 key: "setFixed", 948 value: function setFixed(flag) { 949 if (main_core.Type.isBoolean(flag)) { 950 this.fixed = flag; 951 if (flag) { 952 main_core.Dom.addClass(this.getPopupContainer(), '--fixed'); 953 } else { 954 main_core.Dom.removeClass(this.getPopupContainer(), '--fixed'); 955 } 956 } 957 } 958 }, { 959 key: "isFixed", 960 value: function isFixed() { 961 return this.fixed; 962 } 963 }, {
964 key: "setResizeMode", 965 value: function setResizeMode(mode) { 966 if (mode === true || main_core.Type.isPlainObject(mode)) { 967 if (!this.resizeIcon) { 968 this.resizeIcon = main_core.Tag.render(_templateObject8 || (_templateObject8 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t\t<div class=\"popup-window-resize\" onmousedown=\"", "\"></div>\n\t\t\t\t"])), this.handleResizeMouseDown.bind(this)); 969 this.getPopupContainer().appendChild(this.resizeIcon); 970 } 971 972 // Compatibility 973 this.setMinWidth(mode.minWidth); 974 this.setMinHeight(mode.minHeight); 975 } else if (mode === false && this.resizeIcon) { 976 main_core.Dom.remove(this.resizeIcon); 977 this.resizeIcon = null; 978 } 979 } 980 }, { 981 key: "getDesignSystemContext", 982 value: function getDesignSystemContext() { 983 return this.designSystemContext; 984 } 985 }, { 986 key: "setDesignSystemContext", 987 value: function setDesignSystemContext(context) { 988 if (main_core.Type.isString(context)) { 989 if (this.popupContainer !== null) { 990 main_core.Dom.removeClass(this.popupContainer, this.designSystemContext); 991 main_core.Dom.addClass(this.popupContainer, context); 992 } 993 this.designSystemContext = context; 994 } 995 } 996 }, { 997 key: "setTargetContainer", 998 value: function setTargetContainer(targetContainer) { 999 var newTargetContainer = main_core.Type.isElementNode(targetContainer) ? targetContainer : document.body; 1000 if (newTargetContainer === this.targetContainer) { 1001 return; 1002 } 1003 this.targetContainer = newTargetContainer; 1004 if (this.getPopupContainer()) { 1005 main_core_zIndexManager.ZIndexManager.unregister(this.getPopupContainer()); 1006 this.getTargetContainer().append(this.getPopupContainer()); 1007 main_core_zIndexManager.ZIndexManager.register(this.getPopupContainer()); 1008 } 1009 if (this.overlay) { 1010 main_core.Dom.append(this.overlay.element, this.getTargetContainer()); 1011 } 1012 } 1013 }, { 1014 key: "getTargetContainer", 1015 value: function getTargetContainer() { 1016 return this.targetContainer; 1017 } 1018 }, { 1019 key: "isTargetDocumentBody", 1020 value: function isTargetDocumentBody() { 1021 return this.getTargetContainer() === document.body; 1022 } 1023 }, { 1024 key: "getPopupContainer", 1025 value: function getPopupContainer() { 1026 return this.popupContainer; 1027 } 1028 }, { 1029 key: "getContentContainer", 1030 value: function getContentContainer() { 1031 return this.contentContainer; 1032 } 1033 }, { 1034 key: "getResizableContainer", 1035 value: function getResizableContainer() { 1036 return this.getPopupContainer(); 1037 } 1038 }, { 1039 key: "getTitleContainer", 1040 value: function getTitleContainer() { 1041 return this.titleBar; 1042 } 1043 /** 1044 * @private 1045 */ 1046 }, { 1047 key: "onTitleMouseDown", 1048 value: function onTitleMouseDown(event) { 1049 _classPrivateMethodGet(this, _startDrag, _startDrag2).call(this, event, { 1050 cursor: 'move', 1051 callback: this.handleMove, 1052 eventName: 'Drag' 1053 }); 1054 } 1055 /** 1056 * @private 1057 */ 1058 }, { 1059 key: "handleResizeMouseDown", 1060 value: function handleResizeMouseDown(event) { 1061 _classPrivateMethodGet(this, _startDrag, _startDrag2).call(this, event, { 1062 cursor: 'nwse-resize', 1063 eventName: 'Resize', 1064 callback: this.handleResize 1065 }); 1066 if (this.isTargetDocumentBody()) { 1067 this.resizeContentPos = main_core.Dom.getPosition(this.getResizableContainer()); 1068 this.resizeContentOffset = this.resizeContentPos.left - main_core.Dom.getPosition(this.getPopupContainer()).left; 1069 } else { 1070 this.resizeContentPos = this.getPositionRelativeToTarget(this.getResizableContainer()); 1071 this.resizeContentOffset = this.resizeContentPos.left - this.getPositionRelativeToTarget(this.getPopupContainer()).left; 1072 } 1073 this.resizeContentPos.offsetX = 0; 1074 this.resizeContentPos.offsetY = 0; 1075 } 1076 /** 1077 * @private 1078 */ 1079 }, { 1080 key: "handleResize", 1081 value: function handleResize(offsetX, offsetY, pageX, pageY) { 1082 this.resizeContentPos.offsetX += offsetX; 1083 this.resizeContentPos.offsetY += offsetY; 1084 var width = this.resizeContentPos.width + this.resizeContentPos.offsetX; 1085 var height = this.resizeContentPos.height + this.resizeContentPos.offsetY; 1086 var scrollWidth = this.isTargetDocumentBody() ? document.documentElement.scrollWidth : this.getTargetContainer().scrollWidth; 1087 if (this.resizeContentPos.left + width + this.resizeContentOffset >= scrollWidth) { 1088 width = scrollWidth - this.resizeContentPos.left - this.resizeContentOffset; 1089 } 1090 width = Math.max(width, this.getMinWidth()); 1091 height = Math.max(height, this.getMinHeight()); 1092 if (this.getMaxWidth() !== null) { 1093 width = Math.min(width, this.getMaxWidth()); 1094 } 1095 if (this.getMaxHeight() !== null) { 1096 height = Math.min(height, this.getMaxHeight()); 1097 } 1098 this.setWidth(width); 1099 this.setHeight(height); 1100 } 1101 }, { 1102 key: "isTopAngle", 1103 value: function isTopAngle() { 1104 return this.angle !== null && this.angle.position === 'top'; 1105 } 1106 }, { 1107 key: "isBottomAngle", 1108 value: function isBottomAngle() { 1109 return this.angle !== null && this.angle.position === 'bottom'; 1110 } 1111 }, { 1112 key: "isTopOrBottomAngle", 1113 value: function isTopOrBottomAngle() { 1114 return this.angle !== null && (this.angle.position === 'top' || this.angle.position === 'bottom'); 1115 } 1116 /** 1117 * @private 1118 */ 1119 }, { 1120 key: "getAngleHeight", 1121 value: function getAngleHeight() { 1122 return this.isTopOrBottomAngle() ? Popup.getOption('angleTopOffset') : 0; 1123 } 1124 }, { 1125 key: "setOffset", 1126 value: function setOffset(params) { 1127 if (!main_core.Type.isPlainObject(params)) { 1128 return; 1129 } 1130 if (main_core.Type.isNumber(params.offsetLeft)) { 1131 this.offsetLeft = params.offsetLeft + Popup.getOption('offsetLeft'); 1132 } 1133 if (main_core.Type.isNumber(params.offsetTop)) { 1134 this.offsetTop = params.offsetTop + Popup.getOption('offsetTop'); 1135 } 1136 } 1137 }, { 1138 key: "setTitleBar", 1139 value: function setTitleBar(params) { 1140 if (!this.titleBar) { 1141 return; 1142 } 1143 if (main_core.Type.isObject(params) && main_core.Type.isDomNode(params.content)) { 1144 this.titleBar.innerHTML = ''; 1145 this.titleBar.appendChild(params.content); 1146 } else if (main_core.Type.isString(params)) { 1147 this.titleBar.innerHTML = ''; 1148 this.titleBar.appendChild(main_core.Dom.create('span', { 1149 props: { 1150 className: 'popup-window-titlebar-text' 1151 }, 1152 text: params 1153 })); 1154 } 1155 } 1156 }, { 1157 key: "setDraggable", 1158 value: function setDraggable(draggable) { 1159 var _draggable$element; 1160 this.params.draggable = draggable; 1161 var element = (_draggable$element = draggable === null || draggable === void 0 ? void 0 : draggable.element) !== null && _draggable$element !== void 0 ? _draggable$element : this.titleBar; 1162 if (!draggable || !element) { 1163 return; 1164 }
1165 main_core.Dom.style(element, 'cursor', 'move'); 1166 main_core.Event.bind(element, 'mousedown', this.onTitleMouseDown); 1167 } 1168 }, { 1169 key: "setClosingByEsc", 1170 value: function setClosingByEsc(enable) { 1171 enable = main_core.Type.isBoolean(enable) ? enable : true; 1172 if (enable) { 1173 this.closeByEsc = true; 1174 this.bindClosingByEsc(); 1175 } else { 1176 this.closeByEsc = false; 1177 this.unbindClosingByEsc(); 1178 } 1179 } 1180 /** 1181 * @private 1182 */ 1183 }, { 1184 key: "bindClosingByEsc", 1185 value: function bindClosingByEsc() { 1186 if (this.closeByEsc && !this.isCloseByEscBinded) { 1187 main_core.Event.bind(this.targetContainer.ownerDocument, 'keyup', this.handleDocumentKeyUp, true); 1188 this.isCloseByEscBinded = true; 1189 } 1190 } 1191 /** 1192 * @private 1193 */ 1194 }, { 1195 key: "unbindClosingByEsc", 1196 value: function unbindClosingByEsc() { 1197 if (this.isCloseByEscBinded) { 1198 main_core.Event.unbind(this.targetContainer.ownerDocument, 'keyup', this.handleDocumentKeyUp, true); 1199 this.isCloseByEscBinded = false; 1200 } 1201 } 1202 }, { 1203 key: "setAutoHide", 1204 value: function setAutoHide(enable) { 1205 enable = main_core.Type.isBoolean(enable) ? enable : true; 1206 if (enable) { 1207 this.autoHide = true; 1208 this.bindAutoHide(); 1209 } else { 1210 this.autoHide = false;
1211 this.unbindAutoHide(); 1212 } 1213 } 1214 /** 1215 * @private 1216 */ 1217 }, { 1218 key: "bindAutoHide", 1219 value: function bindAutoHide() { 1220 if (this.autoHide && !this.isAutoHideBinded && this.isShown()) { 1221 this.isAutoHideBinded = true; 1222 if (this.isCompatibleMode()) { 1223 main_core.Event.bind(this.getPopupContainer(), 'click', this.handleContainerClick); 1224 } 1225 if (!this.hasOverlay()) { 1226 main_core.Event.bind(this.targetContainer.ownerDocument, 'click', this.handleAutoHide, !this.isCompatibleMode()); 1227 } 1228 } 1229 } 1230 /** 1231 * @private 1232 */ 1233 }, { 1234 key: "unbindAutoHide", 1235 value: function unbindAutoHide() { 1236 if (this.isAutoHideBinded) { 1237 this.isAutoHideBinded = false; 1238 if (this.isCompatibleMode()) { 1239 main_core.Event.unbind(this.getPopupContainer(), 'click', this.handleContainerClick); 1240 } 1241 if (!this.hasOverlay()) { 1242 main_core.Event.unbind(this.targetContainer.ownerDocument, 'click', this.handleAutoHide, !this.isCompatibleMode()); 1243 } 1244 } 1245 } 1246 /** 1247 * @private 1248 */ 1249 }, { 1250 key: "_tryCloseByEvent", 1251 /** 1252 * @private 1253 */ 1254 value: function _tryCloseByEvent(event) { 1255 var _this4 = this; 1256 if (this.isCompatibleMode()) { 1257 this.tryCloseByEvent(event); 1258 } else { 1259 setTimeout(function () { 1260 _this4.tryCloseByEvent(event); 1261 }, 0); 1262 } 1263 } 1264 /** 1265 * @private 1266 */ 1267 }, { 1268 key: "tryCloseByEvent", 1269 value: function tryCloseByEvent(event) { 1270 if (event.button === 0) { 1271 this.close(); 1272 } 1273 } 1274 /** 1275 * @private 1276 */ 1277 }, { 1278 key: "handleOverlayClick", 1279 value: function handleOverlayClick(event) { 1280 if (this.autoHide) { 1281 this.tryCloseByEvent(event); 1282 event.stopPropagation(); 1283 } 1284 } 1285 }, { 1286 key: "setOverlay", 1287 value: function setOverlay(params) { 1288 if (this.overlay === null) { 1289 this.unbindAutoHide(); 1290 this.overlay = { 1291 element: main_core.Tag.render(_templateObject9 || (_templateObject9 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t\t<div \n\t\t\t\t\t\tclass=\"popup-window-overlay\" \n\t\t\t\t\t\tid=\"popup-window-overlay-", "\"\n\t\t\t\t\t\tonclick=\"", "\"\n\t\t\t\t\t></div>\n\t\t\t\t"])), this.getId(), this.handleOverlayClick.bind(this)) 1292 }; 1293 this.resizeOverlay(); 1294 main_core.Dom.append(this.overlay.element, this.getTargetContainer()); 1295 this.getZIndexComponent().setOverlay(this.overlay.element); 1296 } 1297 if (main_core.Type.isNumber(params === null || params === void 0 ? void 0 : params.opacity) && params.opacity >= 0 && params.opacity <= 100) { 1298 main_core.Dom.style(this.overlay.element, 'opacity', parseFloat(params.opacity / 100).toPrecision(3)); 1299 } 1300 if (params !== null && params !== void 0 && params.backgroundColor) { 1301 main_core.Dom.style(this.overlay.element, 'background-color', params.backgroundColor); 1302 } 1303 if (params !== null && params !== void 0 && params.blur) { 1304 main_core.Dom.style(this.overlay.element, 'backdrop-filter', params.blur); 1305 } 1306 } 1307 }, { 1308 key: "hasOverlay", 1309 value: function hasOverlay() { 1310 return this.overlay !== null && this.overlay.element !== null; 1311 } 1312 }, { 1313 key: "removeOverlay", 1314 value: function removeOverlay() { 1315 if (this.overlay !== null && this.overlay.element !== null) { 1316 main_core.Dom.remove(this.overlay.element); 1317 this.getZIndexComponent().setOverlay(null); 1318 } 1319 if (this.overlayTimeout) { 1320 clearInterval(this.overlayTimeout); 1321 this.overlayTimeout = null; 1322 } 1323 this.overlay = null; 1324 } 1325 }, { 1326 key: "hideOverlay", 1327 value: function hideOverlay() { 1328 if (this.overlay !== null && this.overlay.element !== null) { 1329 if (this.overlayTimeout) { 1330 clearInterval(this.overlayTimeout); 1331 this.overlayTimeout = null; 1332 } 1333 this.overlay.element.style.display = 'none'; 1334 } 1335 } 1336 }, { 1337 key: "showOverlay", 1338 value: function showOverlay() { 1339 var _this5 = this; 1340 if (this.overlay !== null && this.overlay.element !== null) { 1341 this.overlay.element.style.display = 'block'; 1342 var popupHeight = this.getPopupContainer().offsetHeight; 1343 this.overlayTimeout = setInterval(function () { 1344 if (popupHeight !== _this5.getPopupContainer().offsetHeight) { 1345 _this5.resizeOverlay(); 1346 popupHeight = _this5.getPopupContainer().offsetHeight; 1347 } 1348 }, 1000); 1349 } 1350 } 1351 }, { 1352 key: "resizeOverlay", 1353 value: function resizeOverlay() { 1354 if (this.overlay !== null && this.overlay.element !== null) { 1355 var scrollWidth; 1356 var scrollHeight; 1357 if (this.isTargetDocumentBody()) { 1358 scrollWidth = document.documentElement.scrollWidth; 1359 scrollHeight = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight, document.body.offsetHeight, document.documentElement.offsetHeight, document.body.clientHeight, document.documentElement.clientHeight); 1360 } else { 1361 scrollWidth = this.getTargetContainer().scrollWidth; 1362 scrollHeight = this.getTargetContainer().scrollHeight; 1363 } 1364 this.overlay.element.style.width = "".concat(scrollWidth, "px"); 1365 this.overlay.element.style.height = "".concat(scrollHeight, "px"); 1366 } 1367 } 1368 }, { 1369 key: "getZindex", 1370 value: function getZindex() { 1371 return this.getZIndexComponent().getZIndex(); 1372 } 1373 }, { 1374 key: "getZIndexComponent", 1375 value: function getZIndexComponent() { 1376 return this.zIndexComponent; 1377 } 1378 }, { 1379 key: "setDisableScroll", 1380 value: function setDisableScroll(flag) { 1381 var disable = main_core.Type.isBoolean(flag) ? flag : true; 1382 if (disable) { 1383 this.disableScroll = true; 1384 _classPrivateMethodGet(this, _disableTargetScroll, _disableTargetScroll2).call(this); 1385 } else { 1386 this.disableScroll = false;
1387 _classPrivateMethodGet(this, _enableTargetScroll, _enableTargetScroll2).call(this); 1388 } 1389 } 1390 }, { 1391 key: "show", 1392 value: function show() { 1393 var _this6 = this; 1394 if (this.isShown() || this.isDestroyed()) { 1395 return; 1396 } 1397 this.emit('onBeforeShow'); 1398 this.showOverlay(); 1399 this.getPopupContainer().style.display = 'block'; 1400 main_core.Dom.addClass(this.getPopupContainer(), '--open'); 1401 if (this.shouldFrontOnShow()) { 1402 this.bringToFront(); 1403 } 1404 if (!this.firstShow) { 1405 this.emit('onFirstShow', new main_core_events.BaseEvent({ 1406 compatData: [this] 1407 })); 1408 this.firstShow = true; 1409 } 1410 this.emit('onShow', new main_core_events.BaseEvent({ 1411 compatData: [this] 1412 })); 1413 if (this.disableScroll) { 1414 _classPrivateMethodGet(this, _disableTargetScroll, _disableTargetScroll2).call(this); 1415 } 1416 this.adjustPosition(); 1417 this.animateOpening(function () { 1418 if (_this6.isDestroyed()) { 1419 return; 1420 } 1421 main_core.Dom.removeClass(_this6.getPopupContainer(), _this6.animationShowClassName); 1422 _this6.emit('onAfterShow', new main_core_events.BaseEvent({ 1423 compatData: [_this6] 1424 })); 1425 }); 1426 this.bindClosingByEsc(); 1427 if (this.isCompatibleMode()) { 1428 setTimeout(function () { 1429 _this6.bindAutoHide(); 1430 }, 100); 1431 } else { 1432 this.bindAutoHide(); 1433 } 1434 } 1435 }, { 1436 key: "close", 1437 value: function close() { 1438 var _this7 = this; 1439 if (this.isDestroyed() || !this.isShown()) { 1440 return; 1441 } 1442 this.emit('onClose', new main_core_events.BaseEvent({ 1443 compatData: [this] 1444 })); 1445 if (this.isDestroyed()) { 1446 return; 1447 } 1448 if (this.disableScroll) { 1449 _classPrivateMethodGet(this, _enableTargetScroll, _enableTargetScroll2).call(this); 1450 } 1451 this.animateClosing(function () { 1452 if (_this7.isDestroyed()) { 1453 return; 1454 } 1455 _this7.hideOverlay(); 1456 _this7.getPopupContainer().style.display = 'none'; 1457 main_core.Dom.removeClass(_this7.getPopupContainer(), '--open'); 1458 main_core.Dom.removeClass(_this7.getPopupContainer(), _this7.animationCloseClassName); 1459 _this7.unbindClosingByEsc(); 1460 if (_this7.isCompatibleMode()) { 1461 setTimeout(function () { 1462 _this7.unbindAutoHide(); 1463 }, 0); 1464 } else { 1465 _this7.unbindAutoHide(); 1466 } 1467 _this7.emit('onAfterClose', new main_core_events.BaseEvent({ 1468 compatData: [_this7] 1469 })); 1470 if (!_this7.isCacheable()) { 1471 _this7.destroy(); 1472 } 1473 }); 1474 } 1475 }, { 1476 key: "bringToFront", 1477 value: function bringToFront() { 1478 if (this.isShown()) { 1479 main_core_zIndexManager.ZIndexManager.bringToFront(this.getPopupContainer()); 1480 } 1481 } 1482 }, { 1483 key: "toggle", 1484 value: function toggle() { 1485 if (this.isShown()) { 1486 this.close(); 1487 } else { 1488 this.show(); 1489 } 1490 } 1491 /** 1492 * 1493 * @private 1494 */ 1495 }, { 1496 key: "animateOpening", 1497 value: function animateOpening(callback) { 1498 main_core.Dom.removeClass(this.getPopupContainer(), this.animationCloseClassName); 1499 if (this.animationShowClassName === null) { 1500 callback(); 1501 } else { 1502 main_core.Dom.addClass(this.getPopupContainer(), this.animationShowClassName); 1503 if (this.animationCloseEventType === null) { 1504 callback(); 1505 } else { 1506 var eventName = "".concat(this.animationCloseEventType, "end"); 1507 var className = this.animationShowClassName; 1508 this.getPopupContainer().addEventListener(eventName, function handleTransitionEnd(event) { 1509 if (!main_core.Dom.hasClass(event.target, className)) { 1510 return; 1511 } 1512 this.removeEventListener(eventName, handleTransitionEnd); 1513 callback(); 1514 }); 1515 } 1516 } 1517 } 1518 /** 1519 * @private 1520 */ 1521 }, { 1522 key: "animateClosing", 1523 value: function animateClosing(callback) { 1524 main_core.Dom.removeClass(this.getPopupContainer(), this.animationShowClassName); 1525 if (this.animationCloseClassName === null) { 1526 callback(); 1527 } else { 1528 main_core.Dom.addClass(this.getPopupContainer(), this.animationCloseClassName); 1529 if (this.animationCloseEventType === null) { 1530 callback(); 1531 } else { 1532 var eventName = "".concat(this.animationCloseEventType, "end"); 1533 var className = this.animationCloseClassName; 1534 this.getPopupContainer().addEventListener(eventName, function handleTransitionEnd(event) { 1535 if (!main_core.Dom.hasClass(event.target, className)) { 1536 return; 1537 } 1538 this.removeEventListener(eventName, handleTransitionEnd); 1539 callback(); 1540 }); 1541 } 1542 } 1543 } 1544 }, { 1545 key: "setAnimation", 1546 value: function setAnimation(options) { 1547 if (main_core.Type.isPlainObject(options)) { 1548 this.animationShowClassName = main_core.Type.isStringFilled(options.showClassName) ? options.showClassName : null; 1549 this.animationCloseClassName = main_core.Type.isStringFilled(options.closeClassName) ? options.closeClassName : null; 1550 this.animationCloseEventType = options.closeAnimationType === 'animation' || options.closeAnimationType === 'transition' ? options.closeAnimationType : null; 1551 } else if (main_core.Type.isStringFilled(options)) { 1552 var animationName = options; 1553 if (animationName === 'fading') { 1554 this.animationShowClassName = 'popup-window-show-animation-opacity'; 1555 this.animationCloseClassName = 'popup-window-close-animation-opacity'; 1556 this.animationCloseEventType = 'animation'; 1557 } else if (animationName === 'fading-slide') { 1558 this.animationShowClassName = 'popup-window-show-animation-opacity-transform'; 1559 this.animationCloseClassName = 'popup-window-close-animation-opacity'; 1560 this.animationCloseEventType = 'animation'; 1561 } else if (animationName === 'scale') { 1562 this.animationShowClassName = 'popup-window-show-animation-scale'; 1563 this.animationCloseClassName = 'popup-window-close-animation-opacity'; 1564 this.animationCloseEventType = 'animation'; 1565 } 1566 } else if (options === false || options === null) { 1567 this.animationShowClassName = null; 1568 this.animationCloseClassName = null; 1569 this.animationCloseEventType = null; 1570 } 1571 } 1572 }, { 1573 key: "isShown", 1574 value: function isShown() { 1575 var _this$getPopupContain; 1576 return !this.isDestroyed() && ((_this$getPopupContain = this.getPopupContainer()) === null || _this$getPopupContain === void 0 ? void 0 : _this$getPopupContain.style.display) === 'block'; 1577 } 1578 }, {
1579 key: "destroy", 1580 value: function destroy() { 1581 var _this8 = this; 1582 if (this.destroyed) { 1583 return; 1584 } 1585 if (this.disableScroll) { 1586 _classPrivateMethodGet(this, _enableTargetScroll, _enableTargetScroll2).call(this); 1587 } 1588 this.destroyed = true; 1589 this.emit('onDestroy', new main_core_events.BaseEvent({ 1590 compatData: [this] 1591 })); 1592 this.unbindClosingByEsc(); 1593 if (this.isCompatibleMode()) { 1594 setTimeout(function () { 1595 _this8.unbindAutoHide(); 1596 }, 0); 1597 } else { 1598 this.unbindAutoHide(); 1599 } 1600 main_core.Event.unbindAll(this); 1601 main_core.Event.unbind(document, 'mousemove', this.handleDocumentMouseMove); 1602 main_core.Event.unbind(document, 'mouseup', this.handleDocumentMouseUp); 1603 main_core.Event.unbind(window, 'resize', this.handleResizeWindow); 1604 this.removeOverlay(); 1605 main_core_zIndexManager.ZIndexManager.unregister(this.popupContainer); 1606 this.zIndexComponent = null; 1607 main_core.Dom.remove(this.popupContainer); 1608 this.popupContainer = null; 1609 this.contentContainer = null; 1610 this.closeIcon = null; 1611 this.titleBar = null; 1612 this.buttonsContainer = null; 1613 this.angle = null; 1614 this.angleArrowElement = null; 1615 this.resizeIcon = null; 1616 } 1617 }, { 1618 key: "adjustPosition", 1619 value: function adjustPosition(bindOptions) { 1620 var _bindElementPos$windo, _bindElementPos$windo2, _bindElementPos$popup, _bindElementPos$popup2; 1621 if (bindOptions && main_core.Type.isObject(bindOptions)) { 1622 this.bindOptions = bindOptions; 1623 } 1624 var bindElementPos = this.getBindElementPos(this.bindElement); 1625 if (!this.bindOptions.forceBindPosition && this.bindElementPos !== null && bindElementPos.top === this.bindElementPos.top && bindElementPos.left === this.bindElementPos.left) { 1626 return; 1627 } 1628 var bindElementVanished = bindElementPos.top === 0 && bindElementPos.left === 0 && bindElementPos.width === 0 && bindElementPos.height === 0; 1629 this.bindElementPos = bindElementVanished && this.bindElementPos !== null ? this.bindElementPos : bindElementPos; 1630 var windowSize = (_bindElementPos$windo = bindElementPos.windowSize) !== null && _bindElementPos$windo !== void 0 ? _bindElementPos$windo : this.getWindowSize(); 1631 var windowScroll = (_bindElementPos$windo2 = bindElementPos.windowScroll) !== null && _bindElementPos$windo2 !== void 0 ? _bindElementPos$windo2 : this.getWindowScroll(); 1632 var popupWidth = (_bindElementPos$popup = bindElementPos.popupWidth) !== null && _bindElementPos$popup !== void 0 ? _bindElementPos$popup : this.popupContainer.offsetWidth; 1633 var popupHeight = (_bindElementPos$popup2 = bindElementPos.popupHeight) !== null && _bindElementPos$popup2 !== void 0 ? _bindElementPos$popup2 : this.popupContainer.offsetHeight; 1634 var angleTopOffset = Popup.getOption('angleTopOffset'); 1635 var left = this.bindElementPos.left + this.offsetLeft - (this.isTopOrBottomAngle() ? Popup.getOption('angleLeftOffset') : 0); 1636 if (!this.bindOptions.forceLeft && left + popupWidth + this.bordersWidth >= windowSize.innerWidth + windowScroll.scrollLeft && windowSize.innerWidth + windowScroll.scrollLeft - popupWidth - this.bordersWidth > 0) { 1637 var bindLeft = left; 1638 left = windowSize.innerWidth + windowScroll.scrollLeft - popupWidth - this.bordersWidth; 1639 if (this.isTopOrBottomAngle()) { 1640 this.setAngle({ 1641 offset: bindLeft - left + this.angle.defaultOffset 1642 }); 1643 } 1644 } else if (this.isTopOrBottomAngle()) { 1645 this.setAngle({ 1646 offset: this.angle.defaultOffset + (left < 0 ? left : 0) 1647 }); 1648 } 1649 if (left < 0) { 1650 left = 0; 1651 } 1652 var top = 0; 1653 if (this.bindOptions.position && this.bindOptions.position === 'top') { 1654 top = this.bindElementPos.top - popupHeight - this.offsetTop - (this.isBottomAngle() ? angleTopOffset : 0); 1655 if (top < 0 || !this.bindOptions.forceTop && top < windowScroll.scrollTop) { 1656 top = this.bindElementPos.bottom + this.offsetTop; 1657 if (this.angle !== null) { 1658 top += angleTopOffset; 1659 this.setAngle({ 1660 position: 'top' 1661 }); 1662 } 1663 } else if (this.isTopAngle()) { 1664 top = top - angleTopOffset + Popup.getOption('positionTopXOffset'); 1665 this.setAngle({ 1666 position: 'bottom' 1667 }); 1668 } else { 1669 top += Popup.getOption('positionTopXOffset'); 1670 } 1671 } else { 1672 top = this.bindElementPos.bottom + this.offsetTop + this.getAngleHeight(); 1673 if (!this.bindOptions.forceTop && top + popupHeight >
1673 windowSize.innerHeight + windowScroll.scrollTop 1674 // Can we place the PopupWindow above the bindElement? 1675 && this.bindElementPos.top - popupHeight - this.getAngleHeight() >= 0) { 1676 // The PopupWindow doesn't place below the bindElement. We should place it above. 1677 top = this.bindElementPos.top - popupHeight; 1678 if (this.isTopOrBottomAngle()) { 1679 top -= angleTopOffset; 1680 this.setAngle({ 1681 position: 'bottom' 1682 }); 1683 } 1684 top += Popup.getOption('positionTopXOffset'); 1685 } else if (this.isBottomAngle()) { 1686 top += angleTopOffset; 1687 this.setAngle({ 1688 position: 'top' 1689 }); 1690 } 1691 } 1692 if (top < 0) { 1693 top = 0; 1694 } 1695 var event = new PositionEvent(); 1696 event.left = left; 1697 event.top = top; 1698 this.emit('onBeforeAdjustPosition', event); 1699 main_core.Dom.adjust(this.popupContainer, { 1700 style: { 1701 top: "".concat(event.top, "px"), 1702 left: "".concat(event.left, "px") 1703 } 1704 }); 1705 } 1706 }, { 1707 key: "enterFullScreen", 1708 value: function enterFullScreen() { 1709 if (Popup.fullscreenStatus) { 1710 if (document.cancelFullScreen) { 1711 document.cancelFullScreen(); 1712 } else if (document.mozCancelFullScreen) { 1713 document.mozCancelFullScreen(); 1714 } else if (document.webkitCancelFullScreen) { 1715 document.webkitCancelFullScreen(); 1716 } 1717 } else { 1718 if (this.contentContainer.requestFullScreen) { 1719 this.contentContainer.requestFullScreen(); 1720 main_core.Event.bind(window, 'fullscreenchange', this.handleFullScreen); 1721 } else if (this.contentContainer.mozRequestFullScreen) { 1722 this.contentContainer.mozRequestFullScreen(); 1723 main_core.Event.bind(window, 'mozfullscreenchange', this.handleFullScreen); 1724 } else if (this.contentContainer.webkitRequestFullScreen) { 1725 this.contentContainer.webkitRequestFullScreen(); 1726 main_core.Event.bind(window, 'webkitfullscreenchange', this.handleFullScreen); 1727 } else { 1728 console.log('fullscreen mode is not supported'); 1729 } 1730 } 1731 } 1732 /** 1733 * @private 1734 */ 1735 }, { 1736 key: "handleFullScreen", 1737 value: function handleFullScreen(event) { 1738 if (Popup.fullscreenStatus) { 1739 main_core.Event.unbind(window, 'fullscreenchange', this.handleFullScreen); 1740 main_core.Event.unbind(window, 'webkitfullscreenchange', this.handleFullScreen); 1741 main_core.Event.unbind(window, 'mozfullscreenchange', this.handleFullScreen); 1742 Popup.fullscreenStatus = false; 1743 if (!this.isDestroyed()) { 1744 main_core.Dom.removeClass(this.contentContainer, 'popup-window-fullscreen'); 1745 this.emit('onFullscreenLeave'); 1746 this.adjustPosition(); 1747 } 1748 } else { 1749 Popup.fullscreenStatus = true; 1750 if (!this.isDestroyed()) { 1751 main_core.Dom.addClass(this.contentContainer, 'popup-window-fullscreen'); 1752 this.emit('onFullscreenEnter'); 1753 this.adjustPosition(); 1754 } 1755 } 1756 } 1757 /** 1758 * @private 1759 */ 1760 }, { 1761 key: "handleCloseIconClick", 1762 value: function handleCloseIconClick(event) { 1763 this.tryCloseByEvent(event); 1764 event.stopPropagation(); 1765 } 1766 /** 1767 * @private 1768 */ 1769 }, { 1770 key: "handleContainerClick", 1771 value: function handleContainerClick(event) { 1772 event.stopPropagation(); 1773 } 1774 /** 1775 * @private 1776 */ 1777 }, { 1778 key: "handleResizeWindow", 1779 /** 1780 * @private 1781 */ 1782 value: function handleResizeWindow() { 1783 if (this.isShown()) { 1784 this.adjustPosition(); 1785 if (this.overlay !== null) { 1786 this.resizeOverlay(); 1787 } 1788 } 1789 } 1790 /** 1791 * @private 1792 */ 1793 }, { 1794 key: "handleMove", 1795 value: function handleMove(offsetX, offsetY, pageX, pageY) { 1796 var left = parseInt(this.popupContainer.style.left, 10) + offsetX; 1797 var top = parseInt(this.popupContainer.style.top, 10) + offsetY; 1798 if (main_core.Type.isObject(this.params.draggable) && this.params.draggable.restrict) { 1799 // Left side 1800 if (left < 0) { 1801 left = 0; 1802 } 1803 var scrollWidth; 1804 var scrollHeight; 1805 if (this.isTargetDocumentBody()) { 1806 scrollWidth = document.documentElement.scrollWidth; 1807 scrollHeight = document.documentElement.scrollHeight; 1808 } else { 1809 scrollWidth = this.getTargetContainer().scrollWidth; 1810 scrollHeight = this.getTargetContainer().scrollHeight; 1811 } 1812 1813 // Right side 1814 var floatWidth = this.popupContainer.offsetWidth; 1815 var floatHeight = this.popupContainer.offsetHeight; 1816 if (left > scrollWidth - floatWidth) { 1817 left = scrollWidth - floatWidth; 1818 } 1819 if (top > scrollHeight - floatHeight) { 1820 top = scrollHeight - floatHeight; 1821 } 1822 1823 // Top side 1824 if (top < 0) { 1825 top = 0; 1826 } 1827 } 1828 this.popupContainer.style.left = "".concat(left, "px"); 1829 this.popupContainer.style.top = "".concat(top, "px"); 1830 } 1831 /** 1832 * @private 1833 */ 1834 }, { 1835 key: "handleDocumentMouseMove", 1836 /** 1837 * @private 1838 */ 1839 value: function handleDocumentMouseMove(event) { 1840 if (this.dragPageX === event.pageX && this.dragPageY === event.pageY) { 1841 return; 1842 } 1843 this.dragOptions.callback(event.pageX - this.dragPageX, event.pageY - this.dragPageY, event.pageX, event.pageY); 1844 this.dragPageX = event.pageX; 1845 this.dragPageY = event.pageY; 1846 if (!this.dragged) {
1847 this.emit("on".concat(this.dragOptions.eventName, "Start"), new main_core_events.BaseEvent({ 1848 compatData: [this] 1849 })); 1850 this.dragged = true; 1851 } 1852 this.emit("on".concat(this.dragOptions.eventName), new main_core_events.BaseEvent({ 1853 compatData: [this] 1854 })); 1855 } 1856 /** 1857 * @private 1858 */ 1859 }, { 1860 key: "handleDocumentMouseUp", 1861 value: function handleDocumentMouseUp(event) { 1862 if (document.body.releaseCapture) { 1863 document.body.releaseCapture(); 1864 } 1865 main_core.Event.unbind(document, 'mousemove', this.handleDocumentMouseMove); 1866 main_core.Event.unbind(document, 'mouseup', this.handleDocumentMouseUp); 1867 document.body.ondrag = null; 1868 document.body.onselectstart = null; 1869 document.body.style.cursor = ''; 1870 document.body.style.MozUserSelect = ''; 1871 this.popupContainer.style.MozUserSelect = ''; 1872 this.emit("on".concat(this.dragOptions.eventName, "End"), new main_core_events.BaseEvent({ 1873 compatData: [this] 1874 })); 1875 this.dragged = false; 1876 event.preventDefault(); 1877 } 1878 }]); 1879 return Popup; 1880 }(main_core_events.EventEmitter); 1881 function _disableTargetScroll2() { 1882 var target = this.getTargetContainer(); 1883 var popups = disabledScrolls.get(target); 1884 if (!popups) { 1885 popups = new Set(); 1886 disabledScrolls.set(target, popups); 1887 } 1888 popups.add(this); 1889 main_core.Dom.addClass(target, 'popup-window-disable-scroll'); 1890 } 1891 function _enableTargetScroll2() { 1892 var target = this.getTargetContainer(); 1893 var popups = disabledScrolls.get(target) || null; 1894 if (popups) { 1895 popups["delete"](this); 1896 } 1897 if (popups === null || popups.size === 0) { 1898 main_core.Dom.removeClass(target, 'popup-window-disable-scroll'); 1899 } 1900 } 1901 function _startDrag2(event, options) { 1902 options = options || {}; 1903 if (main_core.Type.isStringFilled(options.cursor)) { 1904 this.dragOptions.cursor = options.cursor; 1905 } 1906 if (main_core.Type.isStringFilled(options.eventName)) { 1907 this.dragOptions.eventName = options.eventName; 1908 } 1909 if (main_core.Type.isFunction(options.callback)) { 1910 this.dragOptions.callback = options.callback; 1911 } 1912 this.dragPageX = event.pageX; 1913 this.dragPageY = event.pageY; 1914 this.dragged = false; 1915 main_core.Event.bind(document, 'mousemove', this.handleDocumentMouseMove); 1916 main_core.Event.bind(document, 'mouseup', this.handleDocumentMouseUp); 1917 if (document.body.setCapture) { 1918 document.body.setCapture(); 1919 } 1920 document.body.ondrag = function () { 1921 return false; 1922 }; 1923 document.body.onselectstart = function () { 1924 return false; 1925 }; 1926 document.body.style.cursor = this.dragOptions.cursor; 1927 document.body.style.MozUserSelect = 'none'; 1928 this.popupContainer.style.MozUserSelect = 'none'; 1929 if (this.shouldFrontOnShow()) { 1930 this.bringToFront(); 1931 } 1932 event.preventDefault(); 1933 } 1934 babelHelpers.defineProperty(Popup, "options", {}); 1935 babelHelpers.defineProperty(Popup, "defaultOptions", { 1936 // left offset for popup about target 1937 angleLeftOffset: 40, 1938 // when popup position is 'top' offset distance between popup body and target node 1939 positionTopXOffset: -11, 1940 // offset distance between popup body and target node if use angle, sum with positionTopXOffset 1941 angleTopOffset: 10, 1942 popupZindex: 1000, 1943 popupOverlayZindex: 1100, 1944 angleMinLeft: 10, 1945 angleMaxLeft: 30, 1946 angleMinRight: 10, 1947 angleMaxRight: 30, 1948 angleMinBottom: 23, 1949 angleMaxBottom: 25, 1950 angleMinTop: 23, 1951 angleMaxTop: 25, 1952 offsetLeft: 0, 1953 offsetTop: 0 1954 }); 1955 var escCallbackIndex = -1; 1956 var escCallback = null; 1957 function checkEscPressed(zIndex, callback) { 1958 if (zIndex === false) { 1959 if (escCallback && escCallback.length > 0) { 1960 for (var i = 0; i < escCallback.length; i++) { 1961 escCallback[i](); 1962 } 1963 escCallback = null; 1964 escCallbackIndex = -1; 1965 } 1966 } else { 1967 if (escCallback === null) { 1968 escCallback = []; 1969 escCallbackIndex = -1; 1970 setTimeout(function () { 1971 checkEscPressed(false); 1972 }, 10); 1973 } 1974 if (zIndex > escCallbackIndex) { 1975 escCallbackIndex = zIndex; 1976 escCallback = [callback]; 1977 } else if (zIndex === escCallbackIndex) { 1978 escCallback.push(callback); 1979 } 1980 } 1981 } 1982 1983 var PopupManager = /*#__PURE__*/function () { 1984 function PopupManager() { 1985 babelHelpers.classCallCheck(this, PopupManager); 1986 throw new Error('You cannot make an instance of PopupManager.'); 1987 } 1988 babelHelpers.createClass(PopupManager, null, [{ 1989 key: "create", 1990 value: function create(options) { 1991 var _arguments = Array.prototype.slice.call(arguments), 1992 popupId = _arguments[0], 1993 bindElement = _arguments[1], 1994 params = _arguments[2]; //compatible arguments 1995 1996 var id = popupId; 1997 var compatMode = true; 1998 if (main_core.Type.isPlainObject(popupId) && !bindElement && !params) { 1999 compatMode = false;
2000 id = popupId.id; 2001 if (!main_core.Type.isStringFilled(id)) { 2002 throw new Error('BX.Main.Popup.Manager: "id" parameter is required.'); 2003 } 2004 } 2005 var popupWindow = this.getPopupById(id); 2006 if (popupWindow === null) { 2007 popupWindow = compatMode ? new Popup(popupId, bindElement, params) : new Popup(options); 2008 popupWindow.subscribe('onShow', this.handlePopupShow); 2009 popupWindow.subscribe('onClose', this.handlePopupClose); 2010 } 2011 return popupWindow; 2012 } 2013 /** 2014 * @private 2015 */ 2016 }, { 2017 key: "handleOnAfterInit", 2018 value: function handleOnAfterInit(event) { 2019 event.getTarget().subscribeOnce('onDestroy', this.handlePopupDestroy); 2020 this._popups.forEach(function (popup) { 2021 if (popup.getId() === event.getTarget().getId()) { 2022 console.error("Duplicate id (".concat(popup.getId(), ") for the BX.Main.Popup instance.")); 2023 } 2024 }); 2025 this._popups.push(event.getTarget()); 2026 } 2027 /** 2028 * @private 2029 */ 2030 }, { 2031 key: "handlePopupDestroy", 2032 value: function handlePopupDestroy(event) { 2033 this._popups = this._popups.filter(function (popup) { 2034 return popup !== event.getTarget(); 2035 }); 2036 } 2037 /** 2038 * @private 2039 */ 2040 }, { 2041 key: "handlePopupShow", 2042 value: function handlePopupShow(event) { 2043 if (this._currentPopup !== null) { 2044 this._currentPopup.close(); 2045 } 2046 this._currentPopup = event.getTarget(); 2047 } 2048 /** 2049 * @private 2050 */ 2051 }, { 2052 key: "handlePopupClose", 2053 value: function handlePopupClose() { 2054 this._currentPopup = null; 2055 } 2056 }, { 2057 key: "getCurrentPopup", 2058 value: function getCurrentPopup() { 2059 return this._currentPopup; 2060 } 2061 }, { 2062 key: "isPopupExists", 2063 value: function isPopupExists(id) { 2064 return this.getPopupById(id) !== null; 2065 } 2066 }, { 2067 key: "isAnyPopupShown", 2068 value: function isAnyPopupShown() { 2069 for (var i = 0, length = this._popups.length; i < length; i++) { 2070 if (this._popups[i].isShown()) { 2071 return true; 2072 } 2073 } 2074 return false; 2075 } 2076 }, { 2077 key: "getPopupById", 2078 value: function getPopupById(id) { 2079 for (var i = 0; i < this._popups.length; i++) { 2080 if (this._popups[i].getId() === id) { 2081 return this._popups[i]; 2082 } 2083 } 2084 return null; 2085 } 2086 }, { 2087 key: "getMaxZIndex", 2088 value: function getMaxZIndex() { 2089 var zIndex = 0; 2090 this.getPopups().forEach(function (popup) { 2091 zIndex = Math.max(zIndex, popup.getZindex()); 2092 }); 2093 return zIndex; 2094 } 2095 }, { 2096 key: "getPopups", 2097 value: function getPopups() { 2098 return this._popups; 2099 } 2100 }]); 2101 return PopupManager; 2102 }(); 2103 babelHelpers.defineProperty(PopupManager, "_popups", []); 2104 babelHelpers.defineProperty(PopupManager, "_currentPopup", null); 2105 PopupManager.handlePopupDestroy = PopupManager.handlePopupDestroy.bind(PopupManager); 2106 PopupManager.handlePopupShow = PopupManager.handlePopupShow.bind(PopupManager); 2107 PopupManager.handlePopupClose = PopupManager.handlePopupClose.bind(PopupManager); 2108 PopupManager.handleOnAfterInit = PopupManager.handleOnAfterInit.bind(PopupManager); 2109 main_core_events.EventEmitter.subscribe('BX.Main.Popup:onAfterInit', PopupManager.handleOnAfterInit); 2110 2111 var _templateObject$1, _templateObject2$1, _templateObject3$1; 2112 var aliases$1 = { 2113 onSubMenuShow: { 2114 namespace: 'BX.Main.Menu.Item', 2115 eventName: 'SubMenu:onShow' 2116 }, 2117 onSubMenuClose: { 2118 namespace: 'BX.Main.Menu.Item', 2119 eventName: 'SubMenu:onClose' 2120 } 2121 }; 2122 var reEscape = /[<>'"]/g; 2123 var escapeEntities = { 2124 '<': '<', 2125 '>': '>', 2126 "'": ''', 2127 '"': '"' 2128 }; 2129 function encodeSafe(value) { 2130 if (main_core.Type.isString(value)) { 2131 return value.replace(reEscape, function (item) { 2132 return escapeEntities[item]; 2133 }); 2134 } 2135 return value; 2136 } 2137 main_core_events.EventEmitter.registerAliases(aliases$1); 2138 var MenuItem = /*#__PURE__*/function (_EventEmitter) { 2139 babelHelpers.inherits(MenuItem, _EventEmitter); 2140 function MenuItem(options) { 2141 var _this; 2142 babelHelpers.classCallCheck(this, MenuItem); 2143 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(MenuItem).call(this)); 2144 _this.setEventNamespace('BX.Main.Menu.Item'); 2145 options = options || {}; 2146 _this.options = options; 2147 _this.id = options.id || main_core.Text.getRandom(); 2148 _this.text = ''; 2149 _this.allowHtml = false;
2150 if (main_core.Type.isStringFilled(options.html) || main_core.Type.isElementNode(options.html)) { 2151 _this.text = options.html; 2152 _this.allowHtml = true; 2153 } else if (main_core.Type.isStringFilled(options.text)) { 2154 _this.text = options.text; 2155 if (_this.text.match(/<[^>]+>/)) { 2156 console.warn('BX.Main.MenuItem: use "html" option for the html item content.', _this.getText()); 2157 } 2158 } 2159 _this.title = main_core.Type.isStringFilled(options.title) ? options.title : ''; 2160 _this.delimiter = options.delimiter === true; 2161 _this.href = main_core.Type.isStringFilled(options.href) ? options.href : null; 2162 _this.target = main_core.Type.isStringFilled(options.target) ? options.target : null; 2163 _this.dataset = main_core.Type.isPlainObject(options.dataset) ? options.dataset : null; 2164 _this.className = main_core.Type.isStringFilled(options.className) ? options.className : null; 2165 _this.menuShowDelay = main_core.Type.isNumber(options.menuShowDelay) ? options.menuShowDelay : 300; 2166 _this.subMenuOffsetX = main_core.Type.isNumber(options.subMenuOffsetX) ? options.subMenuOffsetX : 4; 2167 _this._items = main_core.Type.isArray(options.items) ? options.items : []; 2168 _this.disabled = options.disabled === true; 2169 _this.cacheable = options.cacheable === true; 2170 2171 /** 2172 * 2173 * @type {function|string} 2174 */ 2175 _this.onclick = main_core.Type.isStringFilled(options.onclick) || main_core.Type.isFunction(options.onclick) ? options.onclick : null; 2176 _this.subscribeFromOptions(options.events, aliases$1); 2177 2178 /** 2179 * 2180 * @type {Menu} 2181 */ 2182 _this.menuWindow = null; 2183 2184 /** 2185 * 2186 * @type {Menu} 2187 */ 2188 _this.subMenuWindow = null; 2189 2190 /** 2191 * 2192 * @type {{item: HTMLElement, text: HTMLElement}} 2193 */ 2194 _this.layout = { 2195 item: null, 2196 text: null 2197 }; 2198 _this.getLayout(); //compatibility 2199 2200 //compatibility 2201 //now use this.options 2202 _this.events = {}; 2203 _this.items = []; 2204 for (var property in options) { 2205 if (options.hasOwnProperty(property) && typeof _this[property] === 'undefined') { 2206 _this[property] = options[property]; 2207 } 2208 } 2209 return _this; 2210 } 2211 babelHelpers.createClass(MenuItem, [{ 2212 key: "getLayout", 2213 value: function getLayout() { 2214 if (this.layout.item) { 2215 return this.layout; 2216 } 2217 if (this.delimiter) { 2218 if (main_core.Type.isStringFilled(this.getText())) { 2219 this.layout.item = main_core.Dom.create('span', { 2220 props: { 2221 className: ['popup-window-delimiter-section', this.className ? this.className : ''].join(' ') 2222 }, 2223 children: [this.layout.text = main_core.Tag.render(_templateObject$1 || (_templateObject$1 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t\t\t\t<span class=\"popup-window-delimiter-text\">", "</span>\n\t\t\t\t\t\t"])), this.allowHtml ? this.getText() : encodeSafe(this.getText()))] 2224 }); 2225 } else { 2226 this.layout.item = main_core.Tag.render(_templateObject2$1 || (_templateObject2$1 = babelHelpers.taggedTemplateLiteral(["<span class=\"popup-window-delimiter\">"]))); 2227 } 2228 } else { 2229 this.layout.item = main_core.Dom.create(this.href ? 'a' : 'span', { 2230 props: { 2231 className: ['menu-popup-item', this.className ? this.className : 'menu-popup-no-icon', this.hasSubMenu() ? 'menu-popup-item-submenu' : ''].join(' ') 2232 }, 2233 attrs: { 2234 title: this.title, 2235 onclick: main_core.Type.isString(this.onclick) ? this.onclick : '', 2236 // compatibility 2237 target: this.target ? this.target : '' 2238 }, 2239 dataset: this.dataset, 2240 events: main_core.Type.isFunction(this.onclick) ? { 2241 click: this.onItemClick.bind(this) 2242 } : null, 2243 children: [main_core.Dom.create('span', { 2244 props: { 2245 className: 'menu-popup-item-icon' 2246 } 2247 }
2247), this.layout.text = main_core.Tag.render(_templateObject3$1 || (_templateObject3$1 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t\t\t<span class=\"menu-popup-item-text\">", "</span>\n\t\t\t\t\t"])), this.allowHtml ? this.getText() : encodeSafe(this.getText()))] 2248 }); 2249 if (this.href) { 2250 this.layout.item.href = this.href; 2251 } 2252 if (this.isDisabled()) { 2253 this.disable(); 2254 } 2255 main_core.Event.bind(this.layout.item, 'mouseenter', this.onItemMouseEnter.bind(this)); 2256 main_core.Event.bind(this.layout.item, 'mouseleave', this.onItemMouseLeave.bind(this)); 2257 } 2258 return this.layout; 2259 } 2260 }, { 2261 key: "getContainer", 2262 value: function getContainer() { 2263 return this.getLayout().item; 2264 } 2265 }, { 2266 key: "getTextContainer", 2267 value: function getTextContainer() { 2268 return this.getLayout().text; 2269 } 2270 }, { 2271 key: "getText", 2272 value: function getText() { 2273 return this.text; 2274 } 2275 }, { 2276 key: "setText", 2277 value: function setText(text) { 2278 var allowHtml = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 2279 if (main_core.Type.isString(text) || main_core.Type.isElementNode(text)) { 2280 this.allowHtml = allowHtml; 2281 this.text = text; 2282 if (main_core.Type.isElementNode(text)) { 2283 main_core.Dom.clean(this.getTextContainer()); 2284 if (this.allowHtml) { 2285 main_core.Dom.append(text, this.getTextContainer()); 2286 } else { 2287 this.getTextContainer().innerHTML = encodeSafe(text.outerHTML); 2288 } 2289 } else { 2290 this.getTextContainer().innerHTML = this.allowHtml ? text : encodeSafe(text); 2291 } 2292 } 2293 } 2294 }, { 2295 key: "hasSubMenu", 2296 value: function hasSubMenu() { 2297 return this.subMenuWindow !== null || this._items.length; 2298 } 2299 }, { 2300 key: "showSubMenu", 2301 value: function showSubMenu() { 2302 if (!this.getMenuWindow().getPopupWindow().isShown()) { 2303 return; 2304 } 2305 this.addSubMenu(this._items); 2306 if (this.subMenuWindow) { 2307 main_core.Dom.addClass(this.layout.item, 'menu-popup-item-open'); 2308 this.closeSiblings(); 2309 this.closeChildren(); 2310 var popupWindow = this.subMenuWindow.getPopupWindow(); 2311 if (!popupWindow.isShown()) { 2312 this.emit('SubMenu:onShow'); 2313 popupWindow.show(); 2314 } 2315 this.adjustSubMenu(); 2316 } 2317 } 2318 }, { 2319 key: "addSubMenu", 2320 value: function addSubMenu(items) { 2321 if (this.subMenuWindow !== null || !main_core.Type.isArray(items) || !items.length) { 2322 return; 2323 } 2324 var rootMenuWindow = this.getMenuWindow().getRootMenuWindow() || this.getMenuWindow(); 2325 var rootOptions = Object.assign({}, rootMenuWindow.params); 2326 delete rootOptions.events; 2327 var subMenuOptions = main_core.Type.isPlainObject(rootMenuWindow.params.subMenuOptions) ? rootMenuWindow.params.subMenuOptions : {}; 2328 var options = Object.assign({}, rootOptions, subMenuOptions); 2329 2330 //Override root menu options 2331 options.autoHide = false;
2332 options.menuShowDelay = this.menuShowDelay; 2333 options.cacheable = this.isCacheable(); 2334 options.targetContainer = this.getMenuWindow().getPopupWindow().getTargetContainer(); 2335 options.bindOptions = { 2336 forceTop: true, 2337 forceLeft: true, 2338 forceBindPosition: true 2339 }; 2340 delete options.angle; 2341 delete options.overlay; 2342 this.subMenuWindow = new Menu('popup-submenu-' + this.id, this.layout.item, items, options); 2343 this.subMenuWindow.setParentMenuWindow(this.getMenuWindow()); 2344 this.subMenuWindow.setParentMenuItem(this); 2345 this.subMenuWindow.getPopupWindow().subscribe('onDestroy', this.handleSubMenuDestroy.bind(this)); 2346 main_core.Dom.addClass(this.layout.item, 'menu-popup-item-submenu'); 2347 return this.subMenuWindow; 2348 } 2349 }, { 2350 key: "closeSubMenu", 2351 value: function closeSubMenu() { 2352 this.clearSubMenuTimeout(); 2353 if (this.subMenuWindow) { 2354 main_core.Dom.removeClass(this.layout.item, 'menu-popup-item-open'); 2355 this.closeChildren(); 2356 var popup = this.subMenuWindow.getPopupWindow(); 2357 if (popup.isShown()) { 2358 this.emit('SubMenu:onClose'); 2359 } 2360 this.subMenuWindow.close(); 2361 } 2362 } 2363 }, { 2364 key: "closeSiblings", 2365 value: function closeSiblings() { 2366 var siblings = this.menuWindow.getMenuItems(); 2367 for (var i = 0; i < siblings.length; i++) { 2368 if (siblings[i] !== this) { 2369 siblings[i].closeSubMenu(); 2370 } 2371 } 2372 } 2373 }, { 2374 key: "closeChildren", 2375 value: function closeChildren() { 2376 if (this.subMenuWindow) { 2377 var children = this.subMenuWindow.getMenuItems(); 2378 for (var i = 0; i < children.length; i++) { 2379 children[i].closeSubMenu(); 2380 } 2381 } 2382 } 2383 }, { 2384 key: "destroySubMenu", 2385 value: function destroySubMenu() { 2386 if (this.subMenuWindow) { 2387 main_core.Dom.removeClass(this.layout.item, 'menu-popup-item-open menu-popup-item-submenu'); 2388 this.destroyChildren(); 2389 this.subMenuWindow.destroy(); 2390 this.subMenuWindow = null; 2391 this._items = []; 2392 } 2393 } 2394 }, { 2395 key: "destroyChildren", 2396 value: function destroyChildren() { 2397 if (this.subMenuWindow) { 2398 var children = this.subMenuWindow.getMenuItems(); 2399 for (var i = 0; i < children.length; i++) { 2400 children[i].destroySubMenu(); 2401 } 2402 } 2403 } 2404 }, { 2405 key: "adjustSubMenu", 2406 value: function adjustSubMenu() { 2407 if (!this.subMenuWindow || !this.layout.item) { 2408 return; 2409 } 2410 var popupWindow = this.subMenuWindow.getPopupWindow(); 2411 var itemRect = this.getBoundingClientRect(); 2412 var offsetLeft = itemRect.width + this.subMenuOffsetX; 2413 var offsetTop = itemRect.height + this.getPopupPadding(); 2414 var angleOffset = itemRect.height / 2 - this.getPopupPadding(); 2415 var anglePosition = 'left'; 2416 var popupWidth = popupWindow.getPopupContainer().offsetWidth; 2417 var popupHeight = popupWindow.getPopupContainer().offsetHeight; 2418 var popupBottom = itemRect.top + popupHeight; 2419 var targetContainer = this.getMenuWindow().getPopupWindow().getTargetContainer(); 2420 var isGlobalContext = this.getMenuWindow().getPopupWindow().isTargetDocumentBody(); 2421 var clientWidth = isGlobalContext ? document.documentElement.clientWidth : targetContainer.offsetWidth; 2422 var clientHeight = isGlobalContext ? document.documentElement.clientHeight : targetContainer.offsetHeight; 2423 2424 // let's try to fit a submenu to the browser viewport 2425 var exceeded = popupBottom - clientHeight; 2426 if (exceeded > 0) { 2427 var roundOffset = Math.ceil(exceeded / itemRect.height) * itemRect.height; 2428 if (roundOffset > itemRect.top) { 2429 // it cannot be higher than the browser viewport. 2430 roundOffset -= Math.ceil((roundOffset - itemRect.top) / itemRect.height) * itemRect.height; 2431 } 2432 if (itemRect.bottom > popupBottom - roundOffset) { 2433 // let's sync bottom boundaries. 2434 roundOffset -= itemRect.bottom - (popupBottom - roundOffset) + this.getPopupPadding(); 2435 } 2436 offsetTop += roundOffset; 2437 angleOffset += roundOffset; 2438 } 2439 if (itemRect.left + offsetLeft + popupWidth > clientWidth) { 2440 var left = itemRect.left - popupWidth - this.subMenuOffsetX; 2441 if (left > 0) { 2442 offsetLeft = -popupWidth - this.subMenuOffsetX; 2443 anglePosition = 'right'; 2444 } 2445 } 2446 popupWindow.setBindElement(this.layout.item); 2447 popupWindow.setOffset({ 2448 offsetLeft: offsetLeft, 2449 offsetTop: -offsetTop 2450 }); 2451 popupWindow.setAngle({ 2452 position: anglePosition, 2453 offset: angleOffset 2454 }); 2455 popupWindow.adjustPosition(); 2456 } 2457 }, { 2458 key: "getBoundingClientRect", 2459 value: function getBoundingClientRect() { 2460 var popup = this.getMenuWindow().getPopupWindow(); 2461 if (popup.isTargetDocumentBody()) { 2462 return this.layout.item.getBoundingClientRect(); 2463 } else { 2464 var rect = popup.getPositionRelativeToTarget(this.layout.item); 2465 var targetContainer = this.getMenuWindow().getPopupWindow().getTargetContainer(); 2466 return new DOMRect(rect.left - targetContainer.scrollLeft, rect.top - targetContainer.scrollTop, rect.width, rect.height); 2467 } 2468 } 2469 }, { 2470 key: "getPopupPadding", 2471 value: function getPopupPadding() { 2472 if (!main_core.Type.isNumber(this.popupPadding)) { 2473 if (this.subMenuWindow) { 2474 var menuContainer = this.subMenuWindow.layout.menuContainer; 2475 this.popupPadding = parseInt(main_core.Dom.style(menuContainer, 'paddingTop'), 10); 2476 } else { 2477 this.popupPadding = 0; 2478 } 2479 } 2480 return this.popupPadding; 2481 } 2482 }, { 2483 key: "getSubMenu", 2484 value: function getSubMenu() { 2485 return this.subMenuWindow; 2486 } 2487 }, { 2488 key: "getId", 2489 value: function getId() { 2490 return this.id; 2491 } 2492 }, { 2493 key: "setMenuWindow", 2494 value: function setMenuWindow(menu) { 2495 this.menuWindow = menu; 2496 } 2497 }, { 2498 key: "getMenuWindow", 2499 value: function getMenuWindow() { 2500 return this.menuWindow; 2501 } 2502 }, { 2503 key: "getMenuShowDelay", 2504 value: function getMenuShowDelay() { 2505 return this.menuShowDelay; 2506 } 2507 }, { 2508 key: "enable", 2509 value: function enable() { 2510 this.disabled = false;
2511 this.getContainer().classList.remove('menu-popup-item-disabled'); 2512 } 2513 }, { 2514 key: "disable", 2515 value: function disable() { 2516 this.disabled = true; 2517 this.closeSubMenu(); 2518 this.getContainer().classList.add('menu-popup-item-disabled'); 2519 } 2520 }, { 2521 key: "isDisabled", 2522 value: function isDisabled() { 2523 return this.disabled; 2524 } 2525 }, { 2526 key: "setCacheable", 2527 value: function setCacheable(cacheable) { 2528 this.cacheable = cacheable !== false; 2529 } 2530 }, { 2531 key: "isCacheable", 2532 value: function isCacheable() { 2533 return this.cacheable; 2534 } 2535 /** 2536 * @private 2537 */ 2538 }, { 2539 key: "onItemClick", 2540 value: function onItemClick(event) { 2541 this.onclick.call(this.menuWindow, event, this); //compatibility 2542 } 2543 /** 2544 * @private 2545 */ 2546 }, { 2547 key: "onItemMouseEnter", 2548 value: function onItemMouseEnter(mouseEvent) { 2549 if (this.isDisabled()) { 2550 return; 2551 } 2552 var event = new main_core_events.BaseEvent({ 2553 data: { 2554 mouseEvent: mouseEvent 2555 } 2556 }); 2557 main_core_events.EventEmitter.emit(this, 'onMouseEnter', event, { 2558 thisArg: this 2559 }); 2560 if (event.isDefaultPrevented()) { 2561 return; 2562 } 2563 this.clearSubMenuTimeout(); 2564 if (this.hasSubMenu()) { 2565 this.subMenuTimeout = setTimeout(function () { 2566 this.showSubMenu(); 2567 }.bind(this), this.menuShowDelay); 2568 } else { 2569 this.subMenuTimeout = setTimeout(function () { 2570 this.closeSiblings(); 2571 }.bind(this), this.menuShowDelay); 2572 } 2573 } 2574 /** 2575 * @private 2576 */ 2577 }, { 2578 key: "onItemMouseLeave", 2579 value: function onItemMouseLeave(mouseEvent) { 2580 if (this.isDisabled()) { 2581 return; 2582 } 2583 var event = new main_core_events.BaseEvent({ 2584 data: { 2585 mouseEvent: mouseEvent 2586 } 2587 }); 2588 main_core_events.EventEmitter.emit(this, 'onMouseLeave', event, { 2589 thisArg: this 2590 }); 2591 if (event.isDefaultPrevented()) { 2592 return; 2593 } 2594 this.clearSubMenuTimeout(); 2595 } 2596 /** 2597 * @private 2598 */ 2599 }, { 2600 key: "clearSubMenuTimeout", 2601 value: function clearSubMenuTimeout() { 2602 if (this.subMenuTimeout) { 2603 clearTimeout(this.subMenuTimeout); 2604 } 2605 this.subMenuTimeout = null; 2606 } 2607 /** 2608 * @private 2609 */ 2610 }, { 2611 key: "handleSubMenuDestroy", 2612 value: function handleSubMenuDestroy() { 2613 this.subMenuWindow = null; 2614 } 2615 }]); 2616 return MenuItem; 2617 }(main_core_events.EventEmitter); 2618 2619 var _templateObject$2, _templateObject2$2; 2620 /** 2621 * @memberof BX.Main 2622 */ 2623 var Menu = /*#__PURE__*/function (_EventEmitter) { 2624 babelHelpers.inherits(Menu, _EventEmitter); 2625 function Menu(options) { 2626 var _this; 2627 babelHelpers.classCallCheck(this, Menu); 2628 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Menu).call(this)); 2629 _this.setEventNamespace('BX.Main.Menu'); 2630 var _arguments = Array.prototype.slice.call(arguments), 2631 id = _arguments[0], 2632 bindElement = _arguments[1], 2633 menuItems = _arguments[2], 2634 params = _arguments[3]; 2635 if (main_core.Type.isPlainObject(options) && !bindElement && !menuItems && !params) { 2636 params = options; 2637 params.compatibleMode = false; 2638 id = options.id; 2639 bindElement = options.bindElement; 2640 menuItems = options.items; 2641 if (!main_core.Type.isStringFilled(id)) { 2642 id = "menu-popup-".concat(main_core.Text.getRandom()); 2643 } 2644 } 2645 _this.emit('onInit', { 2646 id: id, 2647 bindElement: bindElement, 2648 menuItems: menuItems, 2649 params: params 2650 }); 2651 _this.id = id; 2652 _this.bindElement = bindElement; 2653 2654 /** 2655 * 2656 * @type {MenuItem[]} 2657 */ 2658 _this.menuItems = []; 2659 _this.itemsContainer = null; 2660 _this.params = params && babelHelpers["typeof"](params) === 'object' ? params : {}; 2661 _this.parentMenuWindow = null; 2662 _this.parentMenuItem = null; 2663 if (menuItems && main_core.Type.isArray(menuItems)) { 2664 for (var i = 0; i < menuItems.length; i++) { 2665 _this.addMenuItemInternal(menuItems[i], null); 2666 } 2667 } 2668 _this.layout = { 2669 menuContainer: null, 2670 itemsContainer: null 2671 }; 2672 _this.popupWindow = _this.__createPopup(); 2673 return _this; 2674 } 2675 2676 /** 2677 * @private 2678 */ 2679 babelHelpers.createClass(Menu, [{ 2680 key: "__createPopup", 2681 value: function __createPopup() { 2682 var domItems = []; 2683 for (var i = 0; i < this.menuItems.length; i++) { 2684 var item = this.menuItems[i]; 2685 var itemLayout = item.getLayout(); 2686 domItems.push(itemLayout.item); 2687 } 2688 var defaults = { 2689 closeByEsc: false, 2690 angle: false, 2691 autoHide: true, 2692 offsetTop: 1, 2693 offsetLeft: 0, 2694 animation: 'fading' 2695 }; 2696 var options = Object.assign(defaults, this.params); 2697 2698 //Override user params 2699 options.noAllPaddings = true; 2700 options.darkMode = false;
2701 options.autoHideHandler = this.handleAutoHide.bind(this); 2702 this.layout.itemsContainer = main_core.Tag.render(_templateObject$2 || (_templateObject$2 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t<div class=\"menu-popup-items\">", "</div>\n\t\t"])), domItems); 2703 this.layout.menuContainer = main_core.Tag.render(_templateObject2$2 || (_templateObject2$2 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t<div class=\"menu-popup\">", "</div>\n\t\t"])), this.layout.itemsContainer); 2704 this.itemsContainer = this.layout.itemsContainer; 2705 options.content = this.layout.menuContainer; 2706 2707 //Make internal event handlers first in the queue. 2708 options.events = { 2709 onClose: this.handlePopupClose.bind(this), 2710 onDestroy: this.handlePopupDestroy.bind(this) 2711 }; 2712 var id = options.compatibleMode === false ? this.getId() : 'menu-popup-' + this.getId(); 2713 var popup = new Popup(id, this.bindElement, options); 2714 if (this.params && this.params.events) { 2715 popup.subscribeFromOptions(this.params.events); 2716 } 2717 return popup; 2718 } 2719 }, { 2720 key: "getPopupWindow", 2721 value: function getPopupWindow() { 2722 return this.popupWindow; 2723 } 2724 }, { 2725 key: "show", 2726 value: function show() { 2727 this.getPopupWindow().show(); 2728 } 2729 }, { 2730 key: "close", 2731 value: function close() { 2732 this.getPopupWindow().close(); 2733 } 2734 }, { 2735 key: "destroy", 2736 value: function destroy() { 2737 this.getPopupWindow().destroy(); 2738 } 2739 }, { 2740 key: "toggle", 2741 value: function toggle() { 2742 if (this.getPopupWindow().isShown()) { 2743 this.close(); 2744 } else { 2745 this.show(); 2746 } 2747 } 2748 }, { 2749 key: "getId", 2750 value: function getId() { 2751 return this.id; 2752 } 2753 /** 2754 * @private 2755 */ 2756 }, { 2757 key: "handlePopupClose", 2758 value: function handlePopupClose() { 2759 for (var i = 0; i < this.menuItems.length; i++) { 2760 var item = this.menuItems[i]; 2761 item.closeSubMenu(); 2762 } 2763 } 2764 /** 2765 * @private 2766 */ 2767 }, { 2768 key: "handlePopupDestroy", 2769 value: function handlePopupDestroy() { 2770 for (var i = 0; i < this.menuItems.length; i++) { 2771 var item = this.menuItems[i]; 2772 item.destroySubMenu(); 2773 } 2774 } 2775 /** 2776 * @private 2777 */ 2778 }, { 2779 key: "handleAutoHide", 2780 value: function handleAutoHide(event) { 2781 return !this.containsTarget(event.target); 2782 } 2783 /** 2784 * @private 2785 */ 2786 }, { 2787 key: "containsTarget", 2788 value: function containsTarget(target) { 2789 var el = this.getPopupWindow().getPopupContainer(); 2790 if (this.getPopupWindow().isShown() && (target === el || el.contains(target))) { 2791 return true; 2792 } 2793 return this.getMenuItems().some(function (item) { 2794 return item.getSubMenu() && item.getSubMenu().containsTarget(target); 2795 }); 2796 } 2797 }, { 2798 key: "setParentMenuWindow", 2799 value: function setParentMenuWindow(parentMenu) { 2800 if (parentMenu instanceof Menu) { 2801 this.parentMenuWindow = parentMenu; 2802 } 2803 } 2804 }, { 2805 key: "getParentMenuWindow", 2806 value: function getParentMenuWindow() { 2807 return this.parentMenuWindow; 2808 } 2809 }, { 2810 key: "getRootMenuWindow", 2811 value: function getRootMenuWindow() { 2812 var root = null; 2813 var parent = this.getParentMenuWindow(); 2814 while (parent !== null) { 2815 root = parent; 2816 parent = parent.getParentMenuWindow(); 2817 } 2818 return root; 2819 } 2820 }, { 2821 key: "setParentMenuItem", 2822 value: function setParentMenuItem(parentItem) { 2823 if (parentItem instanceof MenuItem) { 2824 this.parentMenuItem = parentItem; 2825 } 2826 } 2827 }, { 2828 key: "getParentMenuItem", 2829 value: function getParentMenuItem() { 2830 return this.parentMenuItem; 2831 } 2832 }, { 2833 key: "addMenuItem", 2834 value: function addMenuItem(menuItemJson, targetItemId) { 2835 var menuItem = this.addMenuItemInternal(menuItemJson, targetItemId); 2836 if (!menuItem) { 2837 return null; 2838 } 2839 var itemLayout = menuItem.getLayout(); 2840 var targetItem = this.getMenuItem(targetItemId); 2841 if (targetItem !== null) { 2842 var targetLayout = targetItem.getLayout(); 2843 this.itemsContainer.insertBefore(itemLayout.item, targetLayout.item); 2844 } else { 2845 this.itemsContainer.appendChild(itemLayout.item); 2846 } 2847 return menuItem; 2848 } 2849 /** 2850 * @private 2851 */ 2852 }, { 2853 key: "addMenuItemInternal", 2854 value: function addMenuItemInternal(menuItemJson, targetItemId) { 2855 if (!menuItemJson || !menuItemJson.delimiter && !main_core.Type.isStringFilled(menuItemJson.text) && !main_core.Type.isStringFilled(menuItemJson.html) && !main_core.Type.isElementNode(menuItemJson.html) || menuItemJson.id && this.getMenuItem(menuItemJson.id) !== null) { 2856 return null; 2857 } 2858 if (main_core.Type.isNumber(this.params.menuShowDelay)) { 2859 menuItemJson.menuShowDelay = this.params.menuShowDelay; 2860 } 2861 var menuItem = new MenuItem(menuItemJson); 2862 menuItem.setMenuWindow(this); 2863 var position = this.getMenuItemPosition(targetItemId); 2864 if (position >= 0) { 2865 this.menuItems.splice(position, 0, menuItem); 2866 } else { 2867 this.menuItems.push(menuItem); 2868 } 2869 return menuItem; 2870 } 2871 }, { 2872 key: "removeMenuItem", 2873 value: function removeMenuItem(itemId) { 2874 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { 2875 destroyEmptyPopup: true 2876 }; 2877 var item = this.getMenuItem(itemId); 2878 if (!item) { 2879 return; 2880 } 2881 for (var position = 0; position < this.menuItems.length; position++) { 2882 if (this.menuItems[position] === item) { 2883 item.destroySubMenu(); 2884 this.menuItems.splice(position, 1); 2885 break; 2886 } 2887 } 2888 if (!this.menuItems.length) { 2889 var menuWindow = item.getMenuWindow(); 2890 if (menuWindow) { 2891 var parentMenuItem = menuWindow.getParentMenuItem(); 2892 if (parentMenuItem) { 2893 parentMenuItem.destroySubMenu(); 2894 } else if (options.destroyEmptyPopup) { 2895 menuWindow.destroy(); 2896 } 2897 } 2898 } 2899 item.layout.item.parentNode.removeChild(item.layout.item); 2900 item.layout = { 2901 item: null, 2902 text: null 2903 }; 2904 } 2905 }, { 2906 key: "getMenuItem", 2907 value: function getMenuItem(itemId) { 2908 for (var i = 0; i < this.menuItems.length; i++) { 2909 if (this.menuItems[i].id && this.menuItems[i].id === itemId) { 2910 return this.menuItems[i]; 2911 } 2912 } 2913 return null; 2914 } 2915 }, { 2916 key: "getMenuItems", 2917 value: function getMenuItems() { 2918 return this.menuItems; 2919 } 2920 }, { 2921 key: "getMenuItemPosition", 2922 value: function getMenuItemPosition(itemId) { 2923 if (itemId) { 2924 for (var i = 0; i < this.menuItems.length; i++) { 2925 if (this.menuItems[i].id && this.menuItems[i].id === itemId) { 2926 return i; 2927 } 2928 } 2929 } 2930 return -1; 2931 } 2932 }, { 2933 key: "getMenuContainer", 2934 value: function getMenuContainer() { 2935 return this.getPopupWindow().getPopupContainer(); 2936 } 2937 }]);
2938 return Menu; 2939 }(main_core_events.EventEmitter); 2940 2941 var MenuManager = /*#__PURE__*/function () { 2942 /** 2943 * @private 2944 */ 2945 2946 /** 2947 * @private 2948 */ 2949 2950 function MenuManager() { 2951 babelHelpers.classCallCheck(this, MenuManager); 2952 throw new Error('You cannot make an instance of MenuManager.'); 2953 } 2954 babelHelpers.createClass(MenuManager, null, [{ 2955 key: "show", 2956 value: function show() { 2957 if (this.currentItem !== null) { 2958 this.currentItem.popupWindow.close(); 2959 } 2960 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { 2961 args[_key] = arguments[_key]; 2962 } 2963 this.currentItem = this.create.apply(this, args); 2964 this.currentItem.popupWindow.show(); 2965 } 2966 }, { 2967 key: "create", 2968 value: function create(options) { 2969 var menuId = null; 2970 2971 //Compatibility 2972 var bindElement = arguments[1]; 2973 var menuItems = arguments[2]; 2974 var params = arguments[3]; 2975 if (main_core.Type.isPlainObject(options) && !bindElement && !menuItems && !params) { 2976 menuId = options.id; 2977 if (!main_core.Type.isStringFilled(menuId)) { 2978 throw new Error('BX.Main.Menu.create: "id" parameter is required.'); 2979 } 2980 } else { 2981 menuId = options; 2982 } 2983 if (!this.Data[menuId]) { 2984 var menu = new Menu(options, bindElement, menuItems, params); 2985 menu.getPopupWindow().subscribe('onDestroy', function () { 2986 MenuManager.destroy(menuId); 2987 }); 2988 this.Data[menuId] = menu; 2989 } 2990 return this.Data[menuId]; 2991 } 2992 }, { 2993 key: "getCurrentMenu", 2994 value: function getCurrentMenu() { 2995 return this.currentItem; 2996 } 2997 }, { 2998 key: "getMenuById", 2999 value: function getMenuById(id) { 3000 return this.Data[id] ? this.Data[id] : null; 3001 } 3002 /** 3003 * compatibility 3004 * @private 3005 */ 3006 }, { 3007 key: "onPopupDestroy", 3008 value: function onPopupDestroy(popupMenuWindow) { 3009 this.destroy(popupMenuWindow.id); 3010 } 3011 }, { 3012 key: "destroy", 3013 value: function destroy(id) { 3014 var menu = this.getMenuById(id); 3015 if (menu) { 3016 if (this.currentItem === menu) { 3017 this.currentItem = null; 3018 } 3019 delete this.Data[id]; 3020 menu.getPopupWindow().destroy(); 3021 } 3022 } 3023 }]); 3024 return MenuManager; 3025 }(); 3026 babelHelpers.defineProperty(MenuManager, "Data", {}); 3027 babelHelpers.defineProperty(MenuManager, "currentItem", null); 3028 3029 /** 3030 * @deprecated use Popup class instead: import { Popup } from 'main.popup' 3031 */ 3032 var PopupWindow = /*#__PURE__*/function (_Popup) { 3033 babelHelpers.inherits(PopupWindow, _Popup); 3034 function PopupWindow() { 3035 babelHelpers.classCallCheck(this, PopupWindow); 3036 return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(PopupWindow).apply(this, arguments)); 3037 } 3038 return PopupWindow; 3039 }(Popup); 3040 3041 /** 3042 * @deprecated use BX.UI.Button 3043 */ 3044 var PopupWindowButton = /*#__PURE__*/function (_Button) { 3045 babelHelpers.inherits(PopupWindowButton, _Button); 3046 function PopupWindowButton() { 3047 babelHelpers.classCallCheck(this, PopupWindowButton); 3048 return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(PopupWindowButton).apply(this, arguments)); 3049 } 3050 return PopupWindowButton; 3051 }(Button); 3052 3053 /** 3054 * @deprecated use BX.UI.Button 3055 */ 3056 var ButtonLink = /*#__PURE__*/function (_Button) { 3057 babelHelpers.inherits(ButtonLink, _Button); 3058 function ButtonLink(params) { 3059 var _this; 3060 babelHelpers.classCallCheck(this, ButtonLink); 3061 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(ButtonLink).call(this, params)); 3062 _this.buttonNode = main_core.Dom.create('span', { 3063 props: { 3064 className: 'popup-window-button popup-window-button-link' + (_this.className.length > 0 ? ' ' + _this.className : ''), 3065 id: _this.id 3066 }, 3067 text: _this.text, 3068 events: _this.contextEvents 3069 }); 3070 return _this; 3071 } 3072 return ButtonLink; 3073 }(Button); 3074 3075 /** 3076 * @deprecated use BX.UI.Button 3077 */ 3078 var PopupWindowButtonLink = /*#__PURE__*/function (_ButtonLink) { 3079 babelHelpers.inherits(PopupWindowButtonLink, _ButtonLink); 3080 function PopupWindowButtonLink() { 3081 babelHelpers.classCallCheck(this, PopupWindowButtonLink); 3082 return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(PopupWindowButtonLink).apply(this, arguments)); 3083 } 3084 return PopupWindowButtonLink; 3085 }(ButtonLink); 3086 3087 /** 3088 * @deprecated use BX.UI.Button 3089 */ 3090 var CustomButton = /*#__PURE__*/function (_Button) { 3091 babelHelpers.inherits(CustomButton, _Button); 3092 function CustomButton(params) { 3093 var _this; 3094 babelHelpers.classCallCheck(this, CustomButton); 3095 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(CustomButton).call(this, params)); 3096 _this.buttonNode = main_core.Dom.create('span', { 3097 props: { 3098 className: _this.className.length > 0 ? _this.className : '', 3099 id: _this.id 3100 }, 3101 events: _this.contextEvents, 3102 text: _this.text 3103 }); 3104 return _this; 3105 } 3106 return CustomButton; 3107 }(Button); 3108 3109 /** 3110 * @deprecated use BX.UI.Button 3111 */ 3112 var PopupWindowCustomButton = /*#__PURE__*/function (_CustomButton) { 3113 babelHelpers.inherits(PopupWindowCustomButton, _CustomButton); 3114 function PopupWindowCustomButton() { 3115 babelHelpers.classCallCheck(this, PopupWindowCustomButton); 3116 return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(PopupWindowCustomButton).apply(this, arguments)); 3117 } 3118 return PopupWindowCustomButton; 3119 }(CustomButton); 3120 3121 /** 3122 * @deprecated use Menu class instead: import { Menu } from 'main.popup' 3123 */ 3124 var PopupMenuWindow = /*#__PURE__*/function (_Menu) { 3125 babelHelpers.inherits(PopupMenuWindow, _Menu); 3126 function PopupMenuWindow() { 3127 babelHelpers.classCallCheck(this, PopupMenuWindow); 3128 return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(PopupMenuWindow).apply(this, arguments)); 3129 } 3130 return PopupMenuWindow; 3131 }(Menu); 3132 3133 /** 3134 * @deprecated use Menu.Item class instead: import { MenuItem } from 'main.popup' 3135 */ 3136 var PopupMenuItem = /*#__PURE__*/function (_MenuItem) { 3137 babelHelpers.inherits(PopupMenuItem, _MenuItem); 3138 function PopupMenuItem() { 3139 babelHelpers.classCallCheck(this, PopupMenuItem); 3140 return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(PopupMenuItem).apply(this, arguments)); 3141 } 3142 return PopupMenuItem; 3143 }(MenuItem); 3144 3145 /** 3146 * @deprecated 3147 */ 3148 var InputPopup = /*#__PURE__*/function () { 3149 function InputPopup(params) { 3150 babelHelpers.classCallCheck(this, InputPopup); 3151 this.id = params.id || 'bx-inp-popup-' + Math.round(Math.random() * 1000000); 3152 this.handler = params.handler || false; 3153 this.values = params.values || false; 3154 this.pInput = params.input; 3155 this.bValues = !!this.values; 3156 this.defaultValue = params.defaultValue || ''; 3157 this.openTitle = params.openTitle || ''; 3158 this.className = params.className || ''; 3159 this.noMRclassName = params.noMRclassName || 'ec-no-rm'; 3160 this.emptyClassName = params.noMRclassName || 'ec-label'; 3161 var _this = this; 3162 this.curInd = false;
3163 if (this.bValues) { 3164 this.pInput.onfocus = this.pInput.onclick = function (e) { 3165 if (this.value == _this.defaultValue) { 3166 this.value = ''; 3167 this.className = _this.className; 3168 } 3169 _this.ShowPopup(); 3170 return e.preventDefault(); 3171 }; 3172 this.pInput.onblur = function () { 3173 if (_this.bShowed) { 3174 setTimeout(function () { 3175 _this.ClosePopup(true); 3176 }, 200); 3177 } 3178 _this.OnChange(); 3179 }; 3180 } else { 3181 this.pInput.className = this.noMRclassName; 3182 this.pInput.onblur = this.OnChange.bind(this); 3183 } 3184 } 3185 babelHelpers.createClass(InputPopup, [{ 3186 key: "ShowPopup", 3187 value: function ShowPopup() { 3188 if (this.bShowed) { 3189 return; 3190 } 3191 var _this = this; 3192 if (!this.oPopup) { 3193 var pWnd = main_core.Dom.create('DIV', { 3194 props: { 3195 className: 'bxecpl-loc-popup ' + this.className 3196 } 3197 }); 3198 for (var i = 0, l = this.values.length; i < l; i++) { 3199 var pRow = pWnd.appendChild(main_core.Dom.create('DIV', { 3200 props: { 3201 id: 'bxecmr_' + i 3202 }, 3203 text: this.values[i].NAME, 3204 events: { 3205 mouseover: function mouseover() { 3206 main_core.Dom.addClass(this, 'bxecplloc-over'); 3207 }, 3208 mouseout: function mouseout() { 3209 main_core.Dom.removeClass(this, 'bxecplloc-over'); 3210 }, 3211 click: function click() { 3212 var ind = this.id.substr('bxecmr_'.length); 3213 _this.pInput.value = _this.values[ind].NAME; 3214 _this.curInd = ind; 3215 _this.OnChange(); 3216 _this.ClosePopup(true); 3217 } 3218 } 3219 })); 3220 if (this.values[i].DESCRIPTION) { 3221 pRow.title = this.values[i].DESCRIPTION; 3222 } 3223 if (this.values[i].CLASS_NAME) { 3224 main_core.Dom.addClass(pRow, this.values[i].CLASS_NAME); 3225 } 3226 if (this.values[i].URL) { 3227 pRow.appendChild(main_core.Dom.create('a', { 3228 props: { 3229 href: this.values[i].URL, 3230 className: 'bxecplloc-view', 3231 target: '_blank', 3232 title: this.openTitle 3233 } 3234 })); 3235 } 3236 } 3237 this.oPopup = new Popup(this.id, this.pInput, { 3238 autoHide: true, 3239 offsetTop: 1, 3240 offsetLeft: 0, 3241 lightShadow: true, 3242 closeByEsc: true, 3243 content: pWnd, 3244 events: { 3245 onClose: this.ClosePopup.bind(this) 3246 } 3247 }); 3248 } 3249 this.oPopup.show(); 3250 this.pInput.select(); 3251 this.bShowed = true; 3252 main_core_events.EventEmitter.emit(this, 'onInputPopupShow', new main_core_events.BaseEvent({ 3253 compatData: [this] 3254 })); 3255 } 3256 }, { 3257 key: "ClosePopup", 3258 value: function ClosePopup(bClosePopup) { 3259 this.bShowed = false; 3260 if (this.pInput.value === '') { 3261 this.OnChange(); 3262 } 3263 main_core_events.EventEmitter.emit(this, 'onInputPopupClose', new main_core_events.BaseEvent({ 3264 compatData: [this] 3265 })); 3266 if (bClosePopup === true) { 3267 this.oPopup.close(); 3268 } 3269 } 3270 }, { 3271 key: "OnChange", 3272 value: function OnChange() { 3273 var val = this.pInput.value; 3274 if (this.bValues) { 3275 if (this.pInput.value == '' || this.pInput.value == this.defaultValue) { 3276 this.pInput.value = this.defaultValue; 3277 this.pInput.className = this.emptyClassName; 3278 val = ''; 3279 } else { 3280 this.pInput.className = ''; 3281 } 3282 } 3283 if (isNaN(parseInt(this.curInd)) || this.curInd !== false && val != this.values[this.curInd].NAME) { 3284 this.curInd = false; 3285 } else { 3286 this.curInd = parseInt(this.curInd); 3287 } 3288 main_core_events.EventEmitter.emit(this, 'onInputPopupChanged', new main_core_events.BaseEvent({ 3289 compatData: [this, this.curInd, val] 3290 })); 3291 if (this.handler && typeof this.handler == 'function') { 3292 this.handler({ 3293 ind: this.curInd, 3294 value: val 3295 }); 3296 } 3297 } 3298 }, { 3299 key: "Set", 3300 value: function Set(ind, val, bOnChange) { 3301 this.curInd = ind; 3302 if (this.curInd !== false) { 3303 this.pInput.value = this.values[this.curInd].NAME; 3304 } else { 3305 this.pInput.value = val; 3306 } 3307 if (bOnChange !== false) { 3308 this.OnChange(); 3309 } 3310 } 3311 }, { 3312 key: "Get", 3313 value: function Get(ind) { 3314 var id = false;
3315 if (typeof ind == 'undefined') { 3316 ind = this.curInd; 3317 } 3318 if (ind !== false && this.values[ind]) { 3319 id = this.values[ind].ID; 3320 } 3321 return id; 3322 } 3323 }, { 3324 key: "GetIndex", 3325 value: function GetIndex(id) { 3326 for (var i = 0, l = this.values.length; i < l; i++) { 3327 if (this.values[i].ID == id) { 3328 return i; 3329 } 3330 } 3331 return false; 3332 } 3333 }, { 3334 key: "Deactivate", 3335 value: function Deactivate(bDeactivate) { 3336 if (this.pInput.value == '' || this.pInput.value == this.defaultValue) { 3337 if (bDeactivate) { 3338 this.pInput.value = ''; 3339 this.pInput.className = this.noMRclassName; 3340 } else if (this.oEC.bUseMR) { 3341 this.pInput.value = this.defaultValue; 3342 this.pInput.className = this.emptyClassName; 3343 } 3344 } 3345 this.pInput.disabled = bDeactivate; 3346 } 3347 }]); 3348 return InputPopup; 3349 }(); 3350 3351 /* 3352 3353 //ES6 3354 import { Popup, PopupManager, CloseIconSize } from 'main.popup'; 3355 const popup = new Popup(); 3356 PopupManager.create(); 3357 3358 //ES5 3359 var popup = new BX.Main.Popup(); 3360 BX.Main.PopupManager.create(); 3361 BX.Main.Popup.CloseIconSize; 3362 3363 //ES6 3364 import { Menu, MenuItem, MenuManager } from 'main.popup'; 3365 const menu = new Menu(); 3366 const item = new MenuItem(); 3367 MenuManager.create(); 3368 3369 //ES5 3370 var menu = new BX.Main.Menu(); 3371 var item = new BX.Main.MenuItem(); 3372 BX.Main.MenuManager.create(); 3373 3374 */ 3375 var BX = main_core.Reflection.namespace('BX'); 3376 3377 /** @deprecated use BX.Main.Popup or import { Popup } from 'main.popup' */ 3378 BX.PopupWindow = Popup; 3379 3380 /** @deprecated use BX.Main.PopupManager or import { PopupManager } from 'main.popup' */ 3381 BX.PopupWindowManager = PopupManager; 3382 3383 /** @deprecated use BX.Main.Menu or import { Menu } from 'main.popup' */ 3384 BX.PopupMenuWindow = Menu; 3385 3386 /** @deprecated use BX.Main.MenuManager or import { MenuManager } from 'main.popup' */ 3387 BX.PopupMenu = MenuManager; 3388 3389 /** @deprecated use BX.Main.MenuItem or import { MenuItem } from 'main.popup' */ 3390 BX.PopupMenuItem = MenuItem; 3391 3392 /** @deprecated use BX.UI.Button */ 3393 BX.PopupWindowButton = Button; 3394 3395 /** @deprecated use BX.UI.Button */ 3396 BX.PopupWindowButtonLink = ButtonLink; 3397 3398 /** @deprecated use BX.UI.Button */ 3399 BX.PopupWindowCustomButton = CustomButton; 3400 3401 /** @deprecated use another API */ 3402 window.BXInputPopup = InputPopup; 3403 3404 exports.Popup = Popup; 3405 exports.Menu = Menu; 3406 exports.MenuItem = MenuItem; 3407 exports.PopupManager = PopupManager; 3408 exports.MenuManager = MenuManager; 3409 exports.CloseIconSize = CloseIconSize; 3410 exports.PopupWindow = PopupWindow; 3411 exports.PopupMenuWindow = PopupMenuWindow; 3412 exports.PopupMenuItem = PopupMenuItem; 3413 exports.PopupWindowManager = PopupManager; 3414 exports.PopupMenu = MenuManager; 3415 exports.PopupWindowButton = PopupWindowButton; 3416 exports.PopupWindowButtonLink = PopupWindowButtonLink; 3417 exports.PopupWindowCustomButton = PopupWindowCustomButton; 3418 3419}((this.BX.Main = this.BX.Main || {}),BX,BX.Event,BX)); 3420//# sourceMappingURL=main.popup.bundle.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.