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