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