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