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