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