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.setTargetContainer(params.targetContainer); 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.getTargetContainer().append(_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: "setTargetContainer", 990 value: function setTargetContainer(targetContainer) { 991 var newTargetContainer = main_core.Type.isElementNode(targetContainer) ? targetContainer : document.body; 992 if (newTargetContainer === this.targetContainer) { 993 return; 994 } 995 this.targetContainer = newTargetContainer; 996 if (this.getPopupContainer()) { 997 this.getTargetContainer().append(this.getPopupContainer()); 998 } 999 if (this.overlay) { 1000 main_core.Dom.append(this.overlay.element, this.getTargetContainer()); 1001 } 1002 } 1003 }, { 1004 key: "getTargetContainer", 1005 value: function getTargetContainer() { 1006 return this.targetContainer; 1007 } 1008 }, { 1009 key: "isTargetDocumentBody", 1010 value: function isTargetDocumentBody() { 1011 return this.getTargetContainer() === document.body; 1012 } 1013 }, { 1014 key: "getPopupContainer", 1015 value: function getPopupContainer() { 1016 return this.popupContainer; 1017 } 1018 }, { 1019 key: "getContentContainer", 1020 value: function getContentContainer() { 1021 return this.contentContainer; 1022 } 1023 }, { 1024 key: "getResizableContainer", 1025 value: function getResizableContainer() { 1026 return main_core.Browser.isIE11() ? this.getContentContainer() : this.getPopupContainer(); 1027 } 1028 }, { 1029 key: "getTitleContainer", 1030 value: function getTitleContainer() { 1031 return this.titleBar; 1032 } 1033 /** 1034 * @private 1035 */ 1036 }, { 1037 key: "onTitleMouseDown", 1038 value: function onTitleMouseDown(event) { 1039 this._startDrag(event, { 1040 cursor: 'move', 1041 callback: this.handleMove, 1042 eventName: 'Drag' 1043 }); 1044 } 1045 /** 1046 * @private 1047 */ 1048 }, { 1049 key: "handleResizeMouseDown", 1050 value: function handleResizeMouseDown(event) { 1051 this._startDrag(event, { 1052 cursor: 'nwse-resize', 1053 eventName: 'Resize', 1054 callback: this.handleResize 1055 }); 1056 if (this.isTargetDocumentBody()) { 1057 this.resizeContentPos = main_core.Dom.getPosition(this.getResizableContainer()); 1058 this.resizeContentOffset = this.resizeContentPos.left - main_core.Dom.getPosition(this.getPopupContainer()).left; 1059 } else { 1060 this.resizeContentPos = this.getPositionRelativeToTarget(this.getResizableContainer()); 1061 this.resizeContentOffset = this.resizeContentPos.left - this.getPositionRelativeToTarget(this.getPopupContainer()).left; 1062 } 1063 this.resizeContentPos.offsetX = 0; 1064 this.resizeContentPos.offsetY = 0; 1065 } 1066 /** 1067 * @private 1068 */ 1069 }, { 1070 key: "handleResize", 1071 value: function handleResize(offsetX, offsetY, pageX, pageY) { 1072 this.resizeContentPos.offsetX += offsetX; 1073 this.resizeContentPos.offsetY += offsetY; 1074 var width = this.resizeContentPos.width + this.resizeContentPos.offsetX; 1075 var height = this.resizeContentPos.height + this.resizeContentPos.offsetY; 1076 var scrollWidth = this.isTargetDocumentBody() ? document.documentElement.scrollWidth : this.getTargetContainer().scrollWidth; 1077 if (this.resizeContentPos.left + width + this.resizeContentOffset >= scrollWidth) { 1078 width = scrollWidth - this.resizeContentPos.left - this.resizeContentOffset; 1079 } 1080 width = Math.max(width, this.getMinWidth()); 1081 height = Math.max(height, this.getMinHeight()); 1082 if (this.getMaxWidth() !== null) { 1083 width = Math.min(width, this.getMaxWidth()); 1084 } 1085 if (this.getMaxHeight() !== null) { 1086 height = Math.min(height, this.getMaxHeight()); 1087 } 1088 this.setWidth(width); 1089 this.setHeight(height); 1090 } 1091 }, { 1092 key: "isTopAngle", 1093 value: function isTopAngle() { 1094 return this.angle !== null && this.angle.position === 'top'; 1095 } 1096 }, { 1097 key: "isBottomAngle", 1098 value: function isBottomAngle() { 1099 return this.angle !== null && this.angle.position === 'bottom'; 1100 } 1101 }, { 1102 key: "isTopOrBottomAngle", 1103 value: function isTopOrBottomAngle() { 1104 return this.angle !== null && (this.angle.position === 'top' || this.angle.position === 'bottom'); 1105 } 1106 /** 1107 * @private 1108 */ 1109 }, { 1110 key: "getAngleHeight", 1111 value: function getAngleHeight() { 1112 return this.isTopOrBottomAngle() ? Popup.getOption('angleTopOffset') : 0; 1113 } 1114 }, { 1115 key: "setOffset", 1116 value: function setOffset(params) { 1117 if (!main_core.Type.isPlainObject(params)) { 1118 return; 1119 } 1120 if (main_core.Type.isNumber(params.offsetLeft)) { 1121 this.offsetLeft = params.offsetLeft + Popup.getOption('offsetLeft'); 1122 } 1123 if (main_core.Type.isNumber(params.offsetTop)) { 1124 this.offsetTop = params.offsetTop + Popup.getOption('offsetTop'); 1125 } 1126 } 1127 }, { 1128 key: "setTitleBar", 1129 value: function setTitleBar(params) { 1130 if (!this.titleBar) { 1131 return; 1132 } 1133 if (babelHelpers["typeof"](params) === 'object' && main_core.Type.isDomNode(params.content)) { 1134 this.titleBar.innerHTML = ''; 1135 this.titleBar.appendChild(params.content); 1136 } else if (typeof params === 'string') { 1137 this.titleBar.innerHTML = ''; 1138 this.titleBar.appendChild(main_core.Dom.create('span', { 1139 props: { 1140 className: 'popup-window-titlebar-text' 1141 }, 1142 text: params 1143 })); 1144 } 1145 } 1146 }, { 1147 key: "setDraggable", 1148 value: function setDraggable(draggable) { 1149 var _draggable$element; 1150 this.params.draggable = draggable; 1151 var element = (_draggable$element = draggable === null || draggable === void 0 ? void 0 : draggable.element) !== null && _draggable$element !== void 0 ? _draggable$element : this.titleBar; 1152 if (!draggable || !element) { 1153 return; 1154 }
1155 main_core.Dom.style(element, 'cursor', 'move'); 1156 main_core.Event.bind(element, 'mousedown', this.onTitleMouseDown); 1157 } 1158 }, { 1159 key: "setClosingByEsc", 1160 value: function setClosingByEsc(enable) { 1161 enable = main_core.Type.isBoolean(enable) ? enable : true; 1162 if (enable) { 1163 this.closeByEsc = true; 1164 this.bindClosingByEsc(); 1165 } else { 1166 this.closeByEsc = false; 1167 this.unbindClosingByEsc(); 1168 } 1169 } 1170 /** 1171 * @private 1172 */ 1173 }, { 1174 key: "bindClosingByEsc", 1175 value: function bindClosingByEsc() { 1176 if (this.closeByEsc && !this.isCloseByEscBinded) { 1177 main_core.Event.bind(document, 'keyup', this.handleDocumentKeyUp); 1178 this.isCloseByEscBinded = true; 1179 } 1180 } 1181 /** 1182 * @private 1183 */ 1184 }, { 1185 key: "unbindClosingByEsc", 1186 value: function unbindClosingByEsc() { 1187 if (this.isCloseByEscBinded) { 1188 main_core.Event.unbind(document, 'keyup', this.handleDocumentKeyUp); 1189 this.isCloseByEscBinded = false; 1190 } 1191 } 1192 }, { 1193 key: "setAutoHide", 1194 value: function setAutoHide(enable) { 1195 enable = main_core.Type.isBoolean(enable) ? enable : true; 1196 if (enable) { 1197 this.autoHide = true; 1198 this.bindAutoHide(); 1199 } else { 1200 this.autoHide = false;
1201 this.unbindAutoHide(); 1202 } 1203 } 1204 /** 1205 * @private 1206 */ 1207 }, { 1208 key: "bindAutoHide", 1209 value: function bindAutoHide() { 1210 if (this.autoHide && !this.isAutoHideBinded && this.isShown()) { 1211 this.isAutoHideBinded = true; 1212 if (this.isCompatibleMode()) { 1213 main_core.Event.bind(this.getPopupContainer(), 'click', this.handleContainerClick); 1214 } 1215 if (this.overlay && this.overlay.element) { 1216 main_core.Event.bind(this.overlay.element, 'click', this.handleOverlayClick); 1217 } else { 1218 if (this.isCompatibleMode()) { 1219 main_core.Event.bind(document, 'click', this.handleAutoHide); 1220 } else { 1221 document.addEventListener('click', this.handleAutoHide, true); 1222 } 1223 } 1224 } 1225 } 1226 /** 1227 * @private 1228 */ 1229 }, { 1230 key: "unbindAutoHide", 1231 value: function unbindAutoHide() { 1232 if (this.isAutoHideBinded) { 1233 this.isAutoHideBinded = false; 1234 if (this.isCompatibleMode()) { 1235 main_core.Event.unbind(this.getPopupContainer(), 'click', this.handleContainerClick); 1236 } 1237 if (this.overlay && this.overlay.element) { 1238 main_core.Event.unbind(this.overlay.element, 'click', this.handleOverlayClick); 1239 } else { 1240 if (this.isCompatibleMode()) { 1241 main_core.Event.unbind(document, 'click', this.handleAutoHide); 1242 } else { 1243 document.removeEventListener('click', this.handleAutoHide, true); 1244 } 1245 } 1246 } 1247 } 1248 /** 1249 * @private 1250 */ 1251 }, { 1252 key: "handleAutoHide", 1253 value: function handleAutoHide(event) { 1254 if (this.isDestroyed()) { 1255 return; 1256 } 1257 if (this.autoHideHandler !== null) { 1258 if (this.autoHideHandler(event)) { 1259 this._tryCloseByEvent(event); 1260 } 1261 } else if (event.target !== this.getPopupContainer() && !this.getPopupContainer().contains(event.target)) { 1262 this._tryCloseByEvent(event); 1263 } 1264 } 1265 /** 1266 * @private 1267 */ 1268 }, { 1269 key: "_tryCloseByEvent", 1270 value: function _tryCloseByEvent(event) { 1271 var _this2 = this; 1272 if (this.isCompatibleMode()) { 1273 this.tryCloseByEvent(event); 1274 } else { 1275 setTimeout(function () { 1276 _this2.tryCloseByEvent(event); 1277 }, 0); 1278 } 1279 } 1280 /** 1281 * @private 1282 */ 1283 }, { 1284 key: "tryCloseByEvent", 1285 value: function tryCloseByEvent(event) { 1286 if (event.button === 0) { 1287 this.close(); 1288 } 1289 } 1290 /** 1291 * @private 1292 */ 1293 }, { 1294 key: "handleOverlayClick", 1295 value: function handleOverlayClick(event) { 1296 this.tryCloseByEvent(event); 1297 event.stopPropagation(); 1298 } 1299 }, { 1300 key: "setOverlay", 1301 value: function setOverlay(params) { 1302 if (this.overlay === null) { 1303 this.overlay = { 1304 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()) 1305 }; 1306 this.resizeOverlay(); 1307 main_core.Dom.append(this.overlay.element, this.getTargetContainer()); 1308 this.getZIndexComponent().setOverlay(this.overlay.element); 1309 } 1310 if (main_core.Type.isNumber(params === null || params === void 0 ? void 0 : params.opacity) && params.opacity >= 0 && params.opacity <= 100) { 1311 main_core.Dom.style(this.overlay.element, 'opacity', parseFloat(params.opacity / 100).toPrecision(3)); 1312 } 1313 if (params !== null && params !== void 0 && params.backgroundColor) { 1314 main_core.Dom.style(this.overlay.element, 'background-color', params.backgroundColor); 1315 } 1316 if (params !== null && params !== void 0 && params.blur) { 1317 main_core.Dom.style(this.overlay.element, 'backdrop-filter', params.blur); 1318 } 1319 } 1320 }, { 1321 key: "removeOverlay", 1322 value: function removeOverlay() { 1323 if (this.overlay !== null && this.overlay.element !== null) { 1324 main_core.Dom.remove(this.overlay.element); 1325 this.getZIndexComponent().setOverlay(null); 1326 } 1327 if (this.overlayTimeout) { 1328 clearInterval(this.overlayTimeout); 1329 this.overlayTimeout = null; 1330 }
1331 this.overlay = null; 1332 } 1333 }, { 1334 key: "hideOverlay", 1335 value: function hideOverlay() { 1336 if (this.overlay !== null && this.overlay.element !== null) { 1337 if (this.overlayTimeout) { 1338 clearInterval(this.overlayTimeout); 1339 this.overlayTimeout = null; 1340 } 1341 this.overlay.element.style.display = 'none'; 1342 } 1343 } 1344 }, { 1345 key: "showOverlay", 1346 value: function showOverlay() { 1347 var _this3 = this; 1348 if (this.overlay !== null && this.overlay.element !== null) { 1349 this.overlay.element.style.display = 'block'; 1350 var popupHeight = this.getPopupContainer().offsetHeight; 1351 this.overlayTimeout = setInterval(function () { 1352 if (popupHeight !== _this3.getPopupContainer().offsetHeight) { 1353 _this3.resizeOverlay(); 1354 popupHeight = _this3.getPopupContainer().offsetHeight; 1355 } 1356 }, 1000); 1357 } 1358 } 1359 }, { 1360 key: "resizeOverlay", 1361 value: function resizeOverlay() { 1362 if (this.overlay !== null && this.overlay.element !== null) { 1363 var scrollWidth; 1364 var scrollHeight; 1365 if (this.isTargetDocumentBody()) { 1366 scrollWidth = document.documentElement.scrollWidth; 1367 scrollHeight = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight, document.body.offsetHeight, document.documentElement.offsetHeight, document.body.clientHeight, document.documentElement.clientHeight); 1368 } else { 1369 scrollWidth = this.getTargetContainer().scrollWidth; 1370 scrollHeight = this.getTargetContainer().scrollHeight; 1371 } 1372 this.overlay.element.style.width = scrollWidth + 'px'; 1373 this.overlay.element.style.height = scrollHeight + 'px'; 1374 } 1375 } 1376 }, { 1377 key: "getZindex", 1378 value: function getZindex() { 1379 return this.getZIndexComponent().getZIndex(); 1380 } 1381 }, { 1382 key: "getZIndexComponent", 1383 value: function getZIndexComponent() { 1384 return this.zIndexComponent; 1385 } 1386 }, { 1387 key: "setDisableScroll", 1388 value: function setDisableScroll(flag) { 1389 var disable = main_core.Type.isBoolean(flag) ? flag : true; 1390 if (disable) { 1391 this.disableScroll = true; 1392 _classPrivateMethodGet(this, _disableTargetScroll, _disableTargetScroll2).call(this); 1393 } else { 1394 this.disableScroll = false; 1395 _classPrivateMethodGet(this, _enableTargetScroll, _enableTargetScroll2).call(this); 1396 } 1397 } 1398 }, { 1399 key: "show", 1400 value: function show() { 1401 var _this4 = this; 1402 if (this.isShown() || this.isDestroyed()) { 1403 return; 1404 } 1405 this.emit('onBeforeShow'); 1406 this.showOverlay(); 1407 this.getPopupContainer().style.display = 'block'; 1408 main_core.Dom.addClass(this.getPopupContainer(), '--open'); 1409 if (this.shouldFrontOnShow()) { 1410 this.bringToFront(); 1411 } 1412 if (!this.firstShow) { 1413 this.emit('onFirstShow', new main_core_events.BaseEvent({ 1414 compatData: [this] 1415 })); 1416 this.firstShow = true; 1417 } 1418 this.emit('onShow', new main_core_events.BaseEvent({ 1419 compatData: [this] 1420 })); 1421 if (this.disableScroll) { 1422 _classPrivateMethodGet(this, _disableTargetScroll, _disableTargetScroll2).call(this); 1423 } 1424 this.adjustPosition(); 1425 this.animateOpening(function () { 1426 if (_this4.isDestroyed()) { 1427 return; 1428 } 1429 main_core.Dom.removeClass(_this4.getPopupContainer(), _this4.animationShowClassName); 1430 _this4.emit('onAfterShow', new main_core_events.BaseEvent({ 1431 compatData: [_this4] 1432 })); 1433 }); 1434 this.bindClosingByEsc(); 1435 if (this.isCompatibleMode()) { 1436 setTimeout(function () { 1437 _this4.bindAutoHide(); 1438 }, 100); 1439 } else { 1440 this.bindAutoHide(); 1441 } 1442 } 1443 }, { 1444 key: "close", 1445 value: function close() { 1446 var _this5 = this; 1447 if (this.isDestroyed() || !this.isShown()) { 1448 return; 1449 }
1450 this.emit('onClose', new main_core_events.BaseEvent({ 1451 compatData: [this] 1452 })); 1453 if (this.isDestroyed()) { 1454 return; 1455 } 1456 if (this.disableScroll) { 1457 _classPrivateMethodGet(this, _enableTargetScroll, _enableTargetScroll2).call(this); 1458 } 1459 this.animateClosing(function () { 1460 if (_this5.isDestroyed()) { 1461 return; 1462 } 1463 _this5.hideOverlay(); 1464 _this5.getPopupContainer().style.display = 'none'; 1465 main_core.Dom.removeClass(_this5.getPopupContainer(), '--open'); 1466 main_core.Dom.removeClass(_this5.getPopupContainer(), _this5.animationCloseClassName); 1467 _this5.unbindClosingByEsc(); 1468 if (_this5.isCompatibleMode()) { 1469 setTimeout(function () { 1470 _this5.unbindAutoHide(); 1471 }, 0); 1472 } else { 1473 _this5.unbindAutoHide(); 1474 } 1475 _this5.emit('onAfterClose', new main_core_events.BaseEvent({ 1476 compatData: [_this5] 1477 })); 1478 if (!_this5.isCacheable()) { 1479 _this5.destroy(); 1480 } 1481 }); 1482 } 1483 }, { 1484 key: "bringToFront", 1485 value: function bringToFront() { 1486 if (this.isShown()) { 1487 main_core_zIndexManager.ZIndexManager.bringToFront(this.getPopupContainer()); 1488 } 1489 } 1490 }, { 1491 key: "toggle", 1492 value: function toggle() { 1493 this.isShown() ? this.close() : this.show(); 1494 } 1495 /** 1496 * 1497 * @private 1498 */ 1499 }, { 1500 key: "animateOpening", 1501 value: function animateOpening(callback) { 1502 main_core.Dom.removeClass(this.getPopupContainer(), this.animationCloseClassName); 1503 if (this.animationShowClassName !== null) { 1504 main_core.Dom.addClass(this.getPopupContainer(), this.animationShowClassName); 1505 if (this.animationCloseEventType !== null) { 1506 var eventName = this.animationCloseEventType + 'end'; 1507 this.getPopupContainer().addEventListener(eventName, function handleTransitionEnd() { 1508 this.removeEventListener(eventName, handleTransitionEnd); 1509 callback(); 1510 }); 1511 } else { 1512 callback(); 1513 } 1514 } else { 1515 callback(); 1516 } 1517 } 1518 /** 1519 * @private 1520 */ 1521 }, { 1522 key: "animateClosing", 1523 value: function animateClosing(callback) { 1524 main_core.Dom.removeClass(this.getPopupContainer(), this.animationShowClassName); 1525 if (this.animationCloseClassName !== null) { 1526 main_core.Dom.addClass(this.getPopupContainer(), this.animationCloseClassName); 1527 if (this.animationCloseEventType !== null) { 1528 var eventName = this.animationCloseEventType + 'end'; 1529 this.getPopupContainer().addEventListener(eventName, function handleTransitionEnd() { 1530 this.removeEventListener(eventName, handleTransitionEnd); 1531 callback(); 1532 }); 1533 } else { 1534 callback(); 1535 } 1536 } else { 1537 callback(); 1538 } 1539 } 1540 }, { 1541 key: "setAnimation", 1542 value: function setAnimation(options) { 1543 if (main_core.Type.isPlainObject(options)) { 1544 this.animationShowClassName = main_core.Type.isStringFilled(options.showClassName) ? options.showClassName : null; 1545 this.animationCloseClassName = main_core.Type.isStringFilled(options.closeClassName) ? options.closeClassName : null; 1546 this.animationCloseEventType = options.closeAnimationType === 'animation' || options.closeAnimationType === 'transition' ? options.closeAnimationType : null; 1547 } else if (main_core.Type.isStringFilled(options)) { 1548 var animationName = options; 1549 if (animationName === 'fading') { 1550 this.animationShowClassName = 'popup-window-show-animation-opacity'; 1551 this.animationCloseClassName = 'popup-window-close-animation-opacity'; 1552 this.animationCloseEventType = 'animation'; 1553 } else if (animationName === 'fading-slide') { 1554 this.animationShowClassName = 'popup-window-show-animation-opacity-transform'; 1555 this.animationCloseClassName = 'popup-window-close-animation-opacity'; 1556 this.animationCloseEventType = 'animation'; 1557 } else if (animationName === 'scale') { 1558 this.animationShowClassName = 'popup-window-show-animation-scale'; 1559 this.animationCloseClassName = 'popup-window-close-animation-opacity'; 1560 this.animationCloseEventType = 'animation'; 1561 } 1562 } else if (options === false || options === null) { 1563 this.animationShowClassName = null; 1564 this.animationCloseClassName = null; 1565 this.animationCloseEventType = null; 1566 } 1567 } 1568 }, { 1569 key: "isShown", 1570 value: function isShown() { 1571 return !this.isDestroyed() && this.getPopupContainer().style.display === 'block'; 1572 } 1573 }, {
1574 key: "destroy", 1575 value: function destroy() { 1576 var _this6 = this; 1577 if (this.destroyed) { 1578 return; 1579 } 1580 if (this.disableScroll) { 1581 _classPrivateMethodGet(this, _enableTargetScroll, _enableTargetScroll2).call(this); 1582 } 1583 this.destroyed = true; 1584 this.emit('onDestroy', new main_core_events.BaseEvent({ 1585 compatData: [this] 1586 })); 1587 this.unbindClosingByEsc(); 1588 if (this.isCompatibleMode()) { 1589 setTimeout(function () { 1590 _this6.unbindAutoHide(); 1591 }, 0); 1592 } else { 1593 this.unbindAutoHide(); 1594 } 1595 main_core.Event.unbindAll(this); 1596 main_core.Event.unbind(document, 'mousemove', this.handleDocumentMouseMove); 1597 main_core.Event.unbind(document, 'mouseup', this.handleDocumentMouseUp); 1598 main_core.Event.unbind(window, 'resize', this.handleResizeWindow); 1599 this.removeOverlay(); 1600 main_core_zIndexManager.ZIndexManager.unregister(this.popupContainer); 1601 this.zIndexComponent = null; 1602 main_core.Dom.remove(this.popupContainer); 1603 this.popupContainer = null; 1604 this.contentContainer = null; 1605 this.closeIcon = null; 1606 this.titleBar = null; 1607 this.buttonsContainer = null; 1608 this.angle = null; 1609 this.angleArrowElement = null; 1610 this.resizeIcon = null; 1611 } 1612 }, { 1613 key: "adjustPosition", 1614 value: function adjustPosition(bindOptions) { 1615 if (bindOptions && babelHelpers["typeof"](bindOptions) === 'object') { 1616 this.bindOptions = bindOptions; 1617 } 1618 var bindElementPos = this.getBindElementPos(this.bindElement); 1619 if (!this.bindOptions.forceBindPosition && this.bindElementPos !== null && bindElementPos.top === this.bindElementPos.top && bindElementPos.left === this.bindElementPos.left) { 1620 return; 1621 } 1622 this.bindElementPos = bindElementPos; 1623 var windowSize = bindElementPos.windowSize ? bindElementPos.windowSize : this.getWindowSize(); 1624 var windowScroll = bindElementPos.windowScroll ? bindElementPos.windowScroll : this.getWindowScroll(); 1625 var popupWidth = bindElementPos.popupWidth ? bindElementPos.popupWidth : this.popupContainer.offsetWidth; 1626 var popupHeight = bindElementPos.popupHeight ? bindElementPos.popupHeight : this.popupContainer.offsetHeight; 1627 var angleTopOffset = Popup.getOption('angleTopOffset'); 1628 var left = this.bindElementPos.left + this.offsetLeft - (this.isTopOrBottomAngle() ? Popup.getOption('angleLeftOffset') : 0); 1629 if (!this.bindOptions.forceLeft && left + popupWidth + this.bordersWidth >= windowSize.innerWidth + windowScroll.scrollLeft && windowSize.innerWidth + windowScroll.scrollLeft - popupWidth - this.bordersWidth > 0) { 1630 var bindLeft = left; 1631 left = windowSize.innerWidth + windowScroll.scrollLeft - popupWidth - this.bordersWidth; 1632 if (this.isTopOrBottomAngle()) { 1633 this.setAngle({ 1634 offset: bindLeft - left + this.angle.defaultOffset 1635 }); 1636 } 1637 } else if (this.isTopOrBottomAngle()) { 1638 this.setAngle({ 1639 offset: this.angle.defaultOffset + (left < 0 ? left : 0) 1640 }); 1641 } 1642 if (left < 0) { 1643 left = 0; 1644 } 1645 var top = 0; 1646 if (this.bindOptions.position && this.bindOptions.position === 'top') { 1647 top = this.bindElementPos.top - popupHeight - this.offsetTop - (this.isBottomAngle() ? angleTopOffset : 0); 1648 if (top < 0 || !this.bindOptions.forceTop && top < windowScroll.scrollTop) { 1649 top = this.bindElementPos.bottom + this.offsetTop; 1650 if (this.angle !== null) { 1651 top += angleTopOffset; 1652 this.setAngle({ 1653 position: 'top' 1654 }); 1655 } 1656 } else if (this.isTopAngle()) { 1657 top = top - angleTopOffset + Popup.getOption('positionTopXOffset'); 1658 this.setAngle({ 1659 position: 'bottom' 1660 }); 1661 } else { 1662 top += Popup.getOption('positionTopXOffset'); 1663 } 1664 } else { 1665 top = this.bindElementPos.bottom + this.offsetTop + this.getAngleHeight(); 1666 if (!this.bindOptions.forceTop && top + popupHeight >
1666 windowSize.innerHeight + windowScroll.scrollTop && this.bindElementPos.top - popupHeight - this.getAngleHeight() >= 0) 1667 //Can we place the PopupWindow above the bindElement? 1668 { 1669 //The PopupWindow doesn't place below the bindElement. We should place it above. 1670 top = this.bindElementPos.top - popupHeight; 1671 if (this.isTopOrBottomAngle()) { 1672 top -= angleTopOffset; 1673 this.setAngle({ 1674 position: 'bottom' 1675 }); 1676 } 1677 top += Popup.getOption('positionTopXOffset'); 1678 } else if (this.isBottomAngle()) { 1679 top += angleTopOffset; 1680 this.setAngle({ 1681 position: 'top' 1682 }); 1683 } 1684 } 1685 if (top < 0) { 1686 top = 0; 1687 } 1688 var event = new PositionEvent(); 1689 event.left = left; 1690 event.top = top; 1691 this.emit('onBeforeAdjustPosition', event); 1692 main_core.Dom.adjust(this.popupContainer, { 1693 style: { 1694 top: event.top + 'px', 1695 left: event.left + 'px' 1696 } 1697 }); 1698 } 1699 }, { 1700 key: "enterFullScreen", 1701 value: function enterFullScreen() { 1702 if (Popup.fullscreenStatus) { 1703 if (document.cancelFullScreen) { 1704 document.cancelFullScreen(); 1705 } else if (document.mozCancelFullScreen) { 1706 document.mozCancelFullScreen(); 1707 } else if (document.webkitCancelFullScreen) { 1708 document.webkitCancelFullScreen(); 1709 } 1710 } else { 1711 if (this.contentContainer.requestFullScreen) { 1712 this.contentContainer.requestFullScreen(); 1713 main_core.Event.bind(window, 'fullscreenchange', this.handleFullScreen); 1714 } else if (this.contentContainer.mozRequestFullScreen) { 1715 this.contentContainer.mozRequestFullScreen(); 1716 main_core.Event.bind(window, 'mozfullscreenchange', this.handleFullScreen); 1717 } else if (this.contentContainer.webkitRequestFullScreen) { 1718 this.contentContainer.webkitRequestFullScreen(); 1719 main_core.Event.bind(window, 'webkitfullscreenchange', this.handleFullScreen); 1720 } else { 1721 console.log('fullscreen mode is not supported'); 1722 } 1723 } 1724 } 1725 /** 1726 * @private 1727 */ 1728 }, { 1729 key: "handleFullScreen", 1730 value: function handleFullScreen(event) { 1731 if (Popup.fullscreenStatus) { 1732 main_core.Event.unbind(window, 'fullscreenchange', this.handleFullScreen); 1733 main_core.Event.unbind(window, 'webkitfullscreenchange', this.handleFullScreen); 1734 main_core.Event.unbind(window, 'mozfullscreenchange', this.handleFullScreen); 1735 Popup.fullscreenStatus = false; 1736 if (!this.isDestroyed()) { 1737 main_core.Dom.removeClass(this.contentContainer, 'popup-window-fullscreen'); 1738 this.emit('onFullscreenLeave'); 1739 this.adjustPosition(); 1740 } 1741 } else { 1742 Popup.fullscreenStatus = true; 1743 if (!this.isDestroyed()) { 1744 main_core.Dom.addClass(this.contentContainer, 'popup-window-fullscreen'); 1745 this.emit('onFullscreenEnter'); 1746 this.adjustPosition(); 1747 } 1748 } 1749 } 1750 /** 1751 * @private 1752 */ 1753 }, { 1754 key: "handleCloseIconClick", 1755 value: function handleCloseIconClick(event) { 1756 this.tryCloseByEvent(event); 1757 event.stopPropagation(); 1758 } 1759 /** 1760 * @private 1761 */ 1762 }, { 1763 key: "handleContainerClick", 1764 value: function handleContainerClick(event) { 1765 event.stopPropagation(); 1766 } 1767 /** 1768 * @private 1769 */ 1770 }, { 1771 key: "handleDocumentKeyUp", 1772 value: function handleDocumentKeyUp(event) { 1773 var _this7 = this; 1774 if (event.keyCode === 27) { 1775 checkEscPressed(this.getZindex(), function () { 1776 _this7.close(); 1777 }); 1778 } 1779 } 1780 /** 1781 * @private 1782 */ 1783 }, { 1784 key: "handleResizeWindow", 1785 value: function handleResizeWindow() { 1786 if (this.isShown()) { 1787 this.adjustPosition(); 1788 if (this.overlay !== null) { 1789 this.resizeOverlay(); 1790 } 1791 } 1792 } 1793 /** 1794 * @private 1795 */ 1796 }, { 1797 key: "handleMove", 1798 value: function handleMove(offsetX, offsetY, pageX, pageY) { 1799 var left = parseInt(this.popupContainer.style.left) + offsetX; 1800 var top = parseInt(this.popupContainer.style.top) + offsetY; 1801 if (babelHelpers["typeof"](this.params.draggable) === 'object' && this.params.draggable.restrict) { 1802 //Left side 1803 if (left < 0) { 1804 left = 0; 1805 } 1806 var scrollWidth; 1807 var scrollHeight; 1808 if (this.isTargetDocumentBody()) { 1809 scrollWidth = document.documentElement.scrollWidth; 1810 scrollHeight = document.documentElement.scrollHeight; 1811 } else { 1812 scrollWidth = this.getTargetContainer().scrollWidth; 1813 scrollHeight = this.getTargetContainer().scrollHeight; 1814 } 1815 1816 //Right side 1817 var floatWidth = this.popupContainer.offsetWidth; 1818 var floatHeight = this.popupContainer.offsetHeight; 1819 if (left > scrollWidth - floatWidth) { 1820 left = scrollWidth - floatWidth; 1821 } 1822 if (top > scrollHeight - floatHeight) { 1823 top = scrollHeight - floatHeight; 1824 } 1825 1826 //Top side 1827 if (top < 0) { 1828 top = 0; 1829 } 1830 } 1831 this.popupContainer.style.left = left + 'px'; 1832 this.popupContainer.style.top = top + 'px'; 1833 } 1834 /** 1835 * @private 1836 */ 1837 }, { 1838 key: "_startDrag", 1839 value: function _startDrag(event, options) { 1840 options = options || {}; 1841 if (main_core.Type.isStringFilled(options.cursor)) { 1842 this.dragOptions.cursor = options.cursor; 1843 } 1844 if (main_core.Type.isStringFilled(options.eventName)) { 1845 this.dragOptions.eventName = options.eventName; 1846 } 1847 if (main_core.Type.isFunction(options.callback)) { 1848 this.dragOptions.callback = options.callback; 1849 } 1850 this.dragPageX = event.pageX; 1851 this.dragPageY = event.pageY; 1852 this.dragged = false;
1853 main_core.Event.bind(document, 'mousemove', this.handleDocumentMouseMove); 1854 main_core.Event.bind(document, 'mouseup', this.handleDocumentMouseUp); 1855 if (document.body.setCapture) { 1856 document.body.setCapture(); 1857 } 1858 document.body.ondrag = function () { 1859 return false; 1860 }; 1861 document.body.onselectstart = function () { 1862 return false; 1863 }; 1864 document.body.style.cursor = this.dragOptions.cursor; 1865 document.body.style.MozUserSelect = 'none'; 1866 this.popupContainer.style.MozUserSelect = 'none'; 1867 if (this.shouldFrontOnShow()) { 1868 this.bringToFront(); 1869 } 1870 event.preventDefault(); 1871 } 1872 /** 1873 * @private 1874 */ 1875 }, { 1876 key: "handleDocumentMouseMove", 1877 value: function handleDocumentMouseMove(event) { 1878 if (this.dragPageX === event.pageX && this.dragPageY === event.pageY) { 1879 return; 1880 } 1881 this.dragOptions.callback(event.pageX - this.dragPageX, event.pageY - this.dragPageY, event.pageX, event.pageY); 1882 this.dragPageX = event.pageX; 1883 this.dragPageY = event.pageY; 1884 if (!this.dragged) { 1885 this.emit("on".concat(this.dragOptions.eventName, "Start"), new main_core_events.BaseEvent({ 1886 compatData: [this] 1887 })); 1888 this.dragged = true; 1889 } 1890 this.emit("on".concat(this.dragOptions.eventName), new main_core_events.BaseEvent({ 1891 compatData: [this] 1892 })); 1893 } 1894 /** 1895 * @private 1896 */ 1897 }, { 1898 key: "handleDocumentMouseUp", 1899 value: function handleDocumentMouseUp(event) { 1900 if (document.body.releaseCapture) { 1901 document.body.releaseCapture(); 1902 } 1903 main_core.Event.unbind(document, 'mousemove', this.handleDocumentMouseMove); 1904 main_core.Event.unbind(document, 'mouseup', this.handleDocumentMouseUp); 1905 document.body.ondrag = null; 1906 document.body.onselectstart = null; 1907 document.body.style.cursor = ''; 1908 document.body.style.MozUserSelect = ''; 1909 this.popupContainer.style.MozUserSelect = ''; 1910 this.emit("on".concat(this.dragOptions.eventName, "End"), new main_core_events.BaseEvent({ 1911 compatData: [this] 1912 })); 1913 this.dragged = false; 1914 event.preventDefault(); 1915 } 1916 }]); 1917 return Popup; 1918 }(main_core_events.EventEmitter); 1919 function _disableTargetScroll2() { 1920 var target = this.getTargetContainer(); 1921 var popups = disabledScrolls.get(target); 1922 if (!popups) { 1923 popups = new Set(); 1924 disabledScrolls.set(target, popups); 1925 } 1926 popups.add(this); 1927 main_core.Dom.addClass(target, 'popup-window-disable-scroll'); 1928 } 1929 function _enableTargetScroll2() { 1930 var target = this.getTargetContainer(); 1931 var popups = disabledScrolls.get(target) || null; 1932 if (popups) { 1933 popups["delete"](this); 1934 } 1935 if (popups === null || popups.size === 0) { 1936 main_core.Dom.removeClass(target, 'popup-window-disable-scroll'); 1937 } 1938 } 1939 babelHelpers.defineProperty(Popup, "options", {}); 1940 babelHelpers.defineProperty(Popup, "defaultOptions", { 1941 //left offset for popup about target 1942 angleLeftOffset: 40, 1943 //when popup position is 'top' offset distance between popup body and target node 1944 positionTopXOffset: -11, 1945 //offset distance between popup body and target node if use angle, sum with positionTopXOffset 1946 angleTopOffset: 10, 1947 popupZindex: 1000, 1948 popupOverlayZindex: 1100, 1949 angleMinLeft: 10, 1950 angleMaxLeft: 30, 1951 angleMinRight: 10, 1952 angleMaxRight: 30, 1953 angleMinBottom: 23, 1954 angleMaxBottom: 25, 1955 angleMinTop: 23, 1956 angleMaxTop: 25, 1957 offsetLeft: 0, 1958 offsetTop: 0 1959 }); 1960 var escCallbackIndex = -1; 1961 var escCallback = null; 1962 function checkEscPressed(zIndex, callback) { 1963 if (zIndex === false) { 1964 if (escCallback && escCallback.length > 0) { 1965 for (var i = 0; i < escCallback.length; i++) { 1966 escCallback[i](); 1967 } 1968 escCallback = null; 1969 escCallbackIndex = -1; 1970 } 1971 } else { 1972 if (escCallback === null) { 1973 escCallback = []; 1974 escCallbackIndex = -1; 1975 setTimeout(function () { 1976 checkEscPressed(false); 1977 }, 10); 1978 } 1979 if (zIndex > escCallbackIndex) { 1980 escCallbackIndex = zIndex; 1981 escCallback = [callback]; 1982 } else if (zIndex === escCallbackIndex) { 1983 escCallback.push(callback); 1984 } 1985 } 1986 } 1987 1988 var PopupManager = /*#__PURE__*/function () { 1989 function PopupManager() { 1990 babelHelpers.classCallCheck(this, PopupManager); 1991 throw new Error('You cannot make an instance of PopupManager.'); 1992 } 1993 babelHelpers.createClass(PopupManager, null, [{ 1994 key: "create", 1995 value: function create(options) { 1996 var _arguments = Array.prototype.slice.call(arguments), 1997 popupId = _arguments[0], 1998 bindElement = _arguments[1], 1999 params = _arguments[2]; //compatible arguments 2000 2001 var id = popupId; 2002 var compatMode = true; 2003 if (main_core.Type.isPlainObject(popupId) && !bindElement && !params) { 2004 compatMode = false;
2005 id = popupId.id; 2006 if (!main_core.Type.isStringFilled(id)) { 2007 throw new Error('BX.Main.Popup.Manager: "id" parameter is required.'); 2008 } 2009 } 2010 var popupWindow = this.getPopupById(id); 2011 if (popupWindow === null) { 2012 popupWindow = compatMode ? new Popup(popupId, bindElement, params) : new Popup(options); 2013 popupWindow.subscribe('onShow', this.handlePopupShow); 2014 popupWindow.subscribe('onClose', this.handlePopupClose); 2015 } 2016 return popupWindow; 2017 } 2018 /** 2019 * @private 2020 */ 2021 }, { 2022 key: "handleOnAfterInit", 2023 value: function handleOnAfterInit(event) { 2024 event.getTarget().subscribeOnce('onDestroy', this.handlePopupDestroy); 2025 this._popups.forEach(function (popup) { 2026 if (popup.getId() === event.getTarget().getId()) { 2027 console.error("Duplicate id (".concat(popup.getId(), ") for the BX.Main.Popup instance.")); 2028 } 2029 }); 2030 this._popups.push(event.getTarget()); 2031 } 2032 /** 2033 * @private 2034 */ 2035 }, { 2036 key: "handlePopupDestroy", 2037 value: function handlePopupDestroy(event) { 2038 this._popups = this._popups.filter(function (popup) { 2039 return popup !== event.getTarget(); 2040 }); 2041 } 2042 /** 2043 * @private 2044 */ 2045 }, { 2046 key: "handlePopupShow", 2047 value: function handlePopupShow(event) { 2048 if (this._currentPopup !== null) { 2049 this._currentPopup.close(); 2050 } 2051 this._currentPopup = event.getTarget(); 2052 } 2053 /** 2054 * @private 2055 */ 2056 }, { 2057 key: "handlePopupClose", 2058 value: function handlePopupClose() { 2059 this._currentPopup = null; 2060 } 2061 }, { 2062 key: "getCurrentPopup", 2063 value: function getCurrentPopup() { 2064 return this._currentPopup; 2065 } 2066 }, { 2067 key: "isPopupExists", 2068 value: function isPopupExists(id) { 2069 return this.getPopupById(id) !== null; 2070 } 2071 }, { 2072 key: "isAnyPopupShown", 2073 value: function isAnyPopupShown() { 2074 for (var i = 0, length = this._popups.length; i < length; i++) { 2075 if (this._popups[i].isShown()) { 2076 return true; 2077 } 2078 } 2079 return false; 2080 } 2081 }, { 2082 key: "getPopupById", 2083 value: function getPopupById(id) { 2084 for (var i = 0; i < this._popups.length; i++) { 2085 if (this._popups[i].getId() === id) { 2086 return this._popups[i]; 2087 } 2088 } 2089 return null; 2090 } 2091 }, { 2092 key: "getMaxZIndex", 2093 value: function getMaxZIndex() { 2094 var zIndex = 0; 2095 this.getPopups().forEach(function (popup) { 2096 zIndex = Math.max(zIndex, popup.getZindex()); 2097 }); 2098 return zIndex; 2099 } 2100 }, { 2101 key: "getPopups", 2102 value: function getPopups() { 2103 return this._popups; 2104 } 2105 }]); 2106 return PopupManager; 2107 }(); 2108 babelHelpers.defineProperty(PopupManager, "_popups", []); 2109 babelHelpers.defineProperty(PopupManager, "_currentPopup", null); 2110 PopupManager.handlePopupDestroy = PopupManager.handlePopupDestroy.bind(PopupManager); 2111 PopupManager.handlePopupShow = PopupManager.handlePopupShow.bind(PopupManager); 2112 PopupManager.handlePopupClose = PopupManager.handlePopupClose.bind(PopupManager); 2113 PopupManager.handleOnAfterInit = PopupManager.handleOnAfterInit.bind(PopupManager); 2114 main_core_events.EventEmitter.subscribe('BX.Main.Popup:onAfterInit', PopupManager.handleOnAfterInit); 2115 2116 var _templateObject$1, _templateObject2$1, _templateObject3$1; 2117 var aliases$1 = { 2118 onSubMenuShow: { 2119 namespace: 'BX.Main.Menu.Item', 2120 eventName: 'SubMenu:onShow' 2121 }, 2122 onSubMenuClose: { 2123 namespace: 'BX.Main.Menu.Item', 2124 eventName: 'SubMenu:onClose' 2125 } 2126 }; 2127 var reEscape = /[<>'"]/g; 2128 var escapeEntities = { 2129 '<': '<', 2130 '>': '>', 2131 "'": ''', 2132 '"': '"' 2133 }; 2134 function encodeSafe(value) { 2135 if (main_core.Type.isString(value)) { 2136 return value.replace(reEscape, function (item) { 2137 return escapeEntities[item]; 2138 }); 2139 } 2140 return value; 2141 } 2142 main_core_events.EventEmitter.registerAliases(aliases$1); 2143 var MenuItem = /*#__PURE__*/function (_EventEmitter) { 2144 babelHelpers.inherits(MenuItem, _EventEmitter); 2145 function MenuItem(options) { 2146 var _this; 2147 babelHelpers.classCallCheck(this, MenuItem); 2148 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(MenuItem).call(this)); 2149 _this.setEventNamespace('BX.Main.Menu.Item'); 2150 options = options || {}; 2151 _this.options = options; 2152 _this.id = options.id || main_core.Text.getRandom(); 2153 _this.text = ''; 2154 _this.allowHtml = false;
2155 if (main_core.Type.isStringFilled(options.html) || main_core.Type.isElementNode(options.html)) { 2156 _this.text = options.html; 2157 _this.allowHtml = true; 2158 } else if (main_core.Type.isStringFilled(options.text)) { 2159 _this.text = options.text; 2160 if (_this.text.match(/<[^>]+>/)) { 2161 console.warn('BX.Main.MenuItem: use "html" option for the html item content.', _this.getText()); 2162 } 2163 } 2164 _this.title = main_core.Type.isStringFilled(options.title) ? options.title : ''; 2165 _this.delimiter = options.delimiter === true; 2166 _this.href = main_core.Type.isStringFilled(options.href) ? options.href : null; 2167 _this.target = main_core.Type.isStringFilled(options.target) ? options.target : null; 2168 _this.dataset = main_core.Type.isPlainObject(options.dataset) ? options.dataset : null; 2169 _this.className = main_core.Type.isStringFilled(options.className) ? options.className : null; 2170 _this.menuShowDelay = main_core.Type.isNumber(options.menuShowDelay) ? options.menuShowDelay : 300; 2171 _this.subMenuOffsetX = main_core.Type.isNumber(options.subMenuOffsetX) ? options.subMenuOffsetX : 4; 2172 _this._items = main_core.Type.isArray(options.items) ? options.items : []; 2173 _this.disabled = options.disabled === true; 2174 _this.cacheable = options.cacheable === true; 2175 2176 /** 2177 * 2178 * @type {function|string} 2179 */ 2180 _this.onclick = main_core.Type.isStringFilled(options.onclick) || main_core.Type.isFunction(options.onclick) ? options.onclick : null; 2181 _this.subscribeFromOptions(options.events, aliases$1); 2182 2183 /** 2184 * 2185 * @type {Menu} 2186 */ 2187 _this.menuWindow = null; 2188 2189 /** 2190 * 2191 * @type {Menu} 2192 */ 2193 _this.subMenuWindow = null; 2194 2195 /** 2196 * 2197 * @type {{item: HTMLElement, text: HTMLElement}} 2198 */ 2199 _this.layout = { 2200 item: null, 2201 text: null 2202 }; 2203 _this.getLayout(); //compatibility 2204 2205 //compatibility 2206 //now use this.options 2207 _this.events = {}; 2208 _this.items = []; 2209 for (var property in options) { 2210 if (options.hasOwnProperty(property) && typeof _this[property] === 'undefined') { 2211 _this[property] = options[property]; 2212 } 2213 } 2214 return _this; 2215 } 2216 babelHelpers.createClass(MenuItem, [{ 2217 key: "getLayout", 2218 value: function getLayout() { 2219 if (this.layout.item) { 2220 return this.layout; 2221 } 2222 if (this.delimiter) { 2223 if (main_core.Type.isStringFilled(this.getText())) { 2224 this.layout.item = main_core.Dom.create('span', { 2225 props: { 2226 className: ['popup-window-delimiter-section', this.className ? this.className : ''].join(' ') 2227 }, 2228 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()))] 2229 }); 2230 } else { 2231 this.layout.item = main_core.Tag.render(_templateObject2$1 || (_templateObject2$1 = babelHelpers.taggedTemplateLiteral(["<span class=\"popup-window-delimiter\">"]))); 2232 } 2233 } else { 2234 this.layout.item = main_core.Dom.create(this.href ? 'a' : 'span', { 2235 props: { 2236 className: ['menu-popup-item', this.className ? this.className : 'menu-popup-no-icon', this.hasSubMenu() ? 'menu-popup-item-submenu' : ''].join(' ') 2237 }, 2238 attrs: { 2239 title: this.title, 2240 onclick: main_core.Type.isString(this.onclick) ? this.onclick : '', 2241 // compatibility 2242 target: this.target ? this.target : '' 2243 }, 2244 dataset: this.dataset, 2245 events: main_core.Type.isFunction(this.onclick) ? { 2246 click: this.onItemClick.bind(this) 2247 } : null, 2248 children: [main_core.Dom.create('span', { 2249 props: { 2250 className: 'menu-popup-item-icon' 2251 } 2252 }
2252), 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()))] 2253 }); 2254 if (this.href) { 2255 this.layout.item.href = this.href; 2256 } 2257 if (this.isDisabled()) { 2258 this.disable(); 2259 } 2260 main_core.Event.bind(this.layout.item, 'mouseenter', this.onItemMouseEnter.bind(this)); 2261 main_core.Event.bind(this.layout.item, 'mouseleave', this.onItemMouseLeave.bind(this)); 2262 } 2263 return this.layout; 2264 } 2265 }, { 2266 key: "getContainer", 2267 value: function getContainer() { 2268 return this.getLayout().item; 2269 } 2270 }, { 2271 key: "getTextContainer", 2272 value: function getTextContainer() { 2273 return this.getLayout().text; 2274 } 2275 }, { 2276 key: "getText", 2277 value: function getText() { 2278 return this.text; 2279 } 2280 }, { 2281 key: "setText", 2282 value: function setText(text) { 2283 var allowHtml = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 2284 if (main_core.Type.isString(text) || main_core.Type.isElementNode(text)) { 2285 this.allowHtml = allowHtml; 2286 this.text = text; 2287 if (main_core.Type.isElementNode(text)) { 2288 main_core.Dom.clean(this.getTextContainer()); 2289 if (this.allowHtml) { 2290 main_core.Dom.append(text, this.getTextContainer()); 2291 } else { 2292 this.getTextContainer().innerHTML = encodeSafe(text.outerHTML); 2293 } 2294 } else { 2295 this.getTextContainer().innerHTML = this.allowHtml ? text : encodeSafe(text); 2296 } 2297 } 2298 } 2299 }, { 2300 key: "hasSubMenu", 2301 value: function hasSubMenu() { 2302 return this.subMenuWindow !== null || this._items.length; 2303 } 2304 }, { 2305 key: "showSubMenu", 2306 value: function showSubMenu() { 2307 if (!this.getMenuWindow().getPopupWindow().isShown()) { 2308 return; 2309 } 2310 this.addSubMenu(this._items); 2311 if (this.subMenuWindow) { 2312 main_core.Dom.addClass(this.layout.item, 'menu-popup-item-open'); 2313 this.closeSiblings(); 2314 this.closeChildren(); 2315 var popupWindow = this.subMenuWindow.getPopupWindow(); 2316 if (!popupWindow.isShown()) { 2317 this.emit('SubMenu:onShow'); 2318 popupWindow.show(); 2319 } 2320 this.adjustSubMenu(); 2321 } 2322 } 2323 }, { 2324 key: "addSubMenu", 2325 value: function addSubMenu(items) { 2326 if (this.subMenuWindow !== null || !main_core.Type.isArray(items) || !items.length) { 2327 return; 2328 } 2329 var rootMenuWindow = this.getMenuWindow().getRootMenuWindow() || this.getMenuWindow(); 2330 var rootOptions = Object.assign({}, rootMenuWindow.params); 2331 delete rootOptions.events; 2332 var subMenuOptions = main_core.Type.isPlainObject(rootMenuWindow.params.subMenuOptions) ? rootMenuWindow.params.subMenuOptions : {}; 2333 var options = Object.assign({}, rootOptions, subMenuOptions); 2334 2335 //Override root menu options 2336 options.autoHide = false;
2337 options.menuShowDelay = this.menuShowDelay; 2338 options.cacheable = this.isCacheable(); 2339 options.targetContainer = this.getMenuWindow().getPopupWindow().getTargetContainer(); 2340 options.bindOptions = { 2341 forceTop: true, 2342 forceLeft: true, 2343 forceBindPosition: true 2344 }; 2345 delete options.angle; 2346 delete options.overlay; 2347 this.subMenuWindow = new Menu('popup-submenu-' + this.id, this.layout.item, items, options); 2348 this.subMenuWindow.setParentMenuWindow(this.getMenuWindow()); 2349 this.subMenuWindow.setParentMenuItem(this); 2350 this.subMenuWindow.getPopupWindow().subscribe('onDestroy', this.handleSubMenuDestroy.bind(this)); 2351 main_core.Dom.addClass(this.layout.item, 'menu-popup-item-submenu'); 2352 return this.subMenuWindow; 2353 } 2354 }, { 2355 key: "closeSubMenu", 2356 value: function closeSubMenu() { 2357 this.clearSubMenuTimeout(); 2358 if (this.subMenuWindow) { 2359 main_core.Dom.removeClass(this.layout.item, 'menu-popup-item-open'); 2360 this.closeChildren(); 2361 var popup = this.subMenuWindow.getPopupWindow(); 2362 if (popup.isShown()) { 2363 this.emit('SubMenu:onClose'); 2364 } 2365 this.subMenuWindow.close(); 2366 } 2367 } 2368 }, { 2369 key: "closeSiblings", 2370 value: function closeSiblings() { 2371 var siblings = this.menuWindow.getMenuItems(); 2372 for (var i = 0; i < siblings.length; i++) { 2373 if (siblings[i] !== this) { 2374 siblings[i].closeSubMenu(); 2375 } 2376 } 2377 } 2378 }, { 2379 key: "closeChildren", 2380 value: function closeChildren() { 2381 if (this.subMenuWindow) { 2382 var children = this.subMenuWindow.getMenuItems(); 2383 for (var i = 0; i < children.length; i++) { 2384 children[i].closeSubMenu(); 2385 } 2386 } 2387 } 2388 }, { 2389 key: "destroySubMenu", 2390 value: function destroySubMenu() { 2391 if (this.subMenuWindow) { 2392 main_core.Dom.removeClass(this.layout.item, 'menu-popup-item-open menu-popup-item-submenu'); 2393 this.destroyChildren(); 2394 this.subMenuWindow.destroy(); 2395 this.subMenuWindow = null; 2396 this._items = []; 2397 } 2398 } 2399 }, { 2400 key: "destroyChildren", 2401 value: function destroyChildren() { 2402 if (this.subMenuWindow) { 2403 var children = this.subMenuWindow.getMenuItems(); 2404 for (var i = 0; i < children.length; i++) { 2405 children[i].destroySubMenu(); 2406 } 2407 } 2408 } 2409 }, { 2410 key: "adjustSubMenu", 2411 value: function adjustSubMenu() { 2412 if (!this.subMenuWindow || !this.layout.item) { 2413 return; 2414 } 2415 var popupWindow = this.subMenuWindow.getPopupWindow(); 2416 var itemRect = this.getBoundingClientRect(); 2417 var offsetLeft = itemRect.width + this.subMenuOffsetX; 2418 var offsetTop = itemRect.height + this.getPopupPadding(); 2419 var angleOffset = itemRect.height / 2 - this.getPopupPadding(); 2420 var anglePosition = 'left'; 2421 var popupWidth = popupWindow.getPopupContainer().offsetWidth; 2422 var popupHeight = popupWindow.getPopupContainer().offsetHeight; 2423 var popupBottom = itemRect.top + popupHeight; 2424 var targetContainer = this.getMenuWindow().getPopupWindow().getTargetContainer(); 2425 var isGlobalContext = this.getMenuWindow().getPopupWindow().isTargetDocumentBody(); 2426 var clientWidth = isGlobalContext ? document.documentElement.clientWidth : targetContainer.offsetWidth; 2427 var clientHeight = isGlobalContext ? document.documentElement.clientHeight : targetContainer.offsetHeight; 2428 2429 // let's try to fit a submenu to the browser viewport 2430 var exceeded = popupBottom - clientHeight; 2431 if (exceeded > 0) { 2432 var roundOffset = Math.ceil(exceeded / itemRect.height) * itemRect.height; 2433 if (roundOffset > itemRect.top) { 2434 // it cannot be higher than the browser viewport. 2435 roundOffset -= Math.ceil((roundOffset - itemRect.top) / itemRect.height) * itemRect.height; 2436 } 2437 if (itemRect.bottom > popupBottom - roundOffset) { 2438 // let's sync bottom boundaries. 2439 roundOffset -= itemRect.bottom - (popupBottom - roundOffset) + this.getPopupPadding(); 2440 } 2441 offsetTop += roundOffset; 2442 angleOffset += roundOffset; 2443 } 2444 if (itemRect.left + offsetLeft + popupWidth > clientWidth) { 2445 var left = itemRect.left - popupWidth - this.subMenuOffsetX; 2446 if (left > 0) { 2447 offsetLeft = -popupWidth - this.subMenuOffsetX; 2448 anglePosition = 'right'; 2449 } 2450 } 2451 popupWindow.setBindElement(this.layout.item); 2452 popupWindow.setOffset({ 2453 offsetLeft: offsetLeft, 2454 offsetTop: -offsetTop 2455 }); 2456 popupWindow.setAngle({ 2457 position: anglePosition, 2458 offset: angleOffset 2459 }); 2460 popupWindow.adjustPosition(); 2461 } 2462 }, { 2463 key: "getBoundingClientRect", 2464 value: function getBoundingClientRect() { 2465 var popup = this.getMenuWindow().getPopupWindow(); 2466 if (popup.isTargetDocumentBody()) { 2467 return this.layout.item.getBoundingClientRect(); 2468 } else { 2469 var rect = popup.getPositionRelativeToTarget(this.layout.item); 2470 var targetContainer = this.getMenuWindow().getPopupWindow().getTargetContainer(); 2471 return new DOMRect(rect.left - targetContainer.scrollLeft, rect.top - targetContainer.scrollTop, rect.width, rect.height); 2472 } 2473 } 2474 }, { 2475 key: "getPopupPadding", 2476 value: function getPopupPadding() { 2477 if (!main_core.Type.isNumber(this.popupPadding)) { 2478 if (this.subMenuWindow) { 2479 var menuContainer = this.subMenuWindow.layout.menuContainer; 2480 this.popupPadding = parseInt(main_core.Dom.style(menuContainer, 'paddingTop'), 10); 2481 } else { 2482 this.popupPadding = 0; 2483 } 2484 } 2485 return this.popupPadding; 2486 } 2487 }, { 2488 key: "getSubMenu", 2489 value: function getSubMenu() { 2490 return this.subMenuWindow; 2491 } 2492 }, { 2493 key: "getId", 2494 value: function getId() { 2495 return this.id; 2496 } 2497 }, { 2498 key: "setMenuWindow", 2499 value: function setMenuWindow(menu) { 2500 this.menuWindow = menu; 2501 } 2502 }, { 2503 key: "getMenuWindow", 2504 value: function getMenuWindow() { 2505 return this.menuWindow; 2506 } 2507 }, { 2508 key: "getMenuShowDelay", 2509 value: function getMenuShowDelay() { 2510 return this.menuShowDelay; 2511 } 2512 }, { 2513 key: "enable", 2514 value: function enable() { 2515 this.disabled = false;
2516 this.getContainer().classList.remove('menu-popup-item-disabled'); 2517 } 2518 }, { 2519 key: "disable", 2520 value: function disable() { 2521 this.disabled = true; 2522 this.closeSubMenu(); 2523 this.getContainer().classList.add('menu-popup-item-disabled'); 2524 } 2525 }, { 2526 key: "isDisabled", 2527 value: function isDisabled() { 2528 return this.disabled; 2529 } 2530 }, { 2531 key: "setCacheable", 2532 value: function setCacheable(cacheable) { 2533 this.cacheable = cacheable !== false; 2534 } 2535 }, { 2536 key: "isCacheable", 2537 value: function isCacheable() { 2538 return this.cacheable; 2539 } 2540 /** 2541 * @private 2542 */ 2543 }, { 2544 key: "onItemClick", 2545 value: function onItemClick(event) { 2546 this.onclick.call(this.menuWindow, event, this); //compatibility 2547 } 2548 /** 2549 * @private 2550 */ 2551 }, { 2552 key: "onItemMouseEnter", 2553 value: function onItemMouseEnter(mouseEvent) { 2554 if (this.isDisabled()) { 2555 return; 2556 } 2557 var event = new main_core_events.BaseEvent({ 2558 data: { 2559 mouseEvent: mouseEvent 2560 } 2561 }); 2562 main_core_events.EventEmitter.emit(this, 'onMouseEnter', event, { 2563 thisArg: this 2564 }); 2565 if (event.isDefaultPrevented()) { 2566 return; 2567 } 2568 this.clearSubMenuTimeout(); 2569 if (this.hasSubMenu()) { 2570 this.subMenuTimeout = setTimeout(function () { 2571 this.showSubMenu(); 2572 }.bind(this), this.menuShowDelay); 2573 } else { 2574 this.subMenuTimeout = setTimeout(function () { 2575 this.closeSiblings(); 2576 }.bind(this), this.menuShowDelay); 2577 } 2578 } 2579 /** 2580 * @private 2581 */ 2582 }, { 2583 key: "onItemMouseLeave", 2584 value: function onItemMouseLeave(mouseEvent) { 2585 if (this.isDisabled()) { 2586 return; 2587 } 2588 var event = new main_core_events.BaseEvent({ 2589 data: { 2590 mouseEvent: mouseEvent 2591 } 2592 }); 2593 main_core_events.EventEmitter.emit(this, 'onMouseLeave', event, { 2594 thisArg: this 2595 }); 2596 if (event.isDefaultPrevented()) { 2597 return; 2598 } 2599 this.clearSubMenuTimeout(); 2600 } 2601 /** 2602 * @private 2603 */ 2604 }, { 2605 key: "clearSubMenuTimeout", 2606 value: function clearSubMenuTimeout() { 2607 if (this.subMenuTimeout) { 2608 clearTimeout(this.subMenuTimeout); 2609 } 2610 this.subMenuTimeout = null; 2611 } 2612 /** 2613 * @private 2614 */ 2615 }, { 2616 key: "handleSubMenuDestroy", 2617 value: function handleSubMenuDestroy() { 2618 this.subMenuWindow = null; 2619 } 2620 }]); 2621 return MenuItem; 2622 }(main_core_events.EventEmitter); 2623 2624 var _templateObject$2, _templateObject2$2; 2625 /** 2626 * @memberof BX.Main 2627 */ 2628 var Menu = /*#__PURE__*/function (_EventEmitter) { 2629 babelHelpers.inherits(Menu, _EventEmitter); 2630 function Menu(options) { 2631 var _this; 2632 babelHelpers.classCallCheck(this, Menu); 2633 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Menu).call(this)); 2634 _this.setEventNamespace('BX.Main.Menu'); 2635 var _arguments = Array.prototype.slice.call(arguments), 2636 id = _arguments[0], 2637 bindElement = _arguments[1], 2638 menuItems = _arguments[2], 2639 params = _arguments[3]; 2640 if (main_core.Type.isPlainObject(options) && !bindElement && !menuItems && !params) { 2641 params = options; 2642 params.compatibleMode = false; 2643 id = options.id; 2644 bindElement = options.bindElement; 2645 menuItems = options.items; 2646 if (!main_core.Type.isStringFilled(id)) { 2647 id = "menu-popup-".concat(main_core.Text.getRandom()); 2648 } 2649 } 2650 _this.emit('onInit', { 2651 id: id, 2652 bindElement: bindElement, 2653 menuItems: menuItems, 2654 params: params 2655 }); 2656 _this.id = id; 2657 _this.bindElement = bindElement; 2658 2659 /** 2660 * 2661 * @type {MenuItem[]} 2662 */ 2663 _this.menuItems = []; 2664 _this.itemsContainer = null; 2665 _this.params = params && babelHelpers["typeof"](params) === 'object' ? params : {}; 2666 _this.parentMenuWindow = null; 2667 _this.parentMenuItem = null; 2668 if (menuItems && main_core.Type.isArray(menuItems)) { 2669 for (var i = 0; i < menuItems.length; i++) { 2670 _this.addMenuItemInternal(menuItems[i], null); 2671 } 2672 } 2673 _this.layout = { 2674 menuContainer: null, 2675 itemsContainer: null 2676 }; 2677 _this.popupWindow = _this.__createPopup(); 2678 return _this; 2679 } 2680 2681 /** 2682 * @private 2683 */ 2684 babelHelpers.createClass(Menu, [{ 2685 key: "__createPopup", 2686 value: function __createPopup() { 2687 var domItems = []; 2688 for (var i = 0; i < this.menuItems.length; i++) { 2689 var item = this.menuItems[i]; 2690 var itemLayout = item.getLayout(); 2691 domItems.push(itemLayout.item); 2692 } 2693 var defaults = { 2694 closeByEsc: false, 2695 angle: false, 2696 autoHide: true, 2697 offsetTop: 1, 2698 offsetLeft: 0, 2699 animation: 'fading' 2700 }; 2701 var options = Object.assign(defaults, this.params); 2702 2703 //Override user params 2704 options.noAllPaddings = true; 2705 options.darkMode = false;
2706 options.autoHideHandler = this.handleAutoHide.bind(this); 2707 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); 2708 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); 2709 this.itemsContainer = this.layout.itemsContainer; 2710 options.content = this.layout.menuContainer; 2711 2712 //Make internal event handlers first in the queue. 2713 options.events = { 2714 onClose: this.handlePopupClose.bind(this), 2715 onDestroy: this.handlePopupDestroy.bind(this) 2716 }; 2717 var id = options.compatibleMode === false ? this.getId() : 'menu-popup-' + this.getId(); 2718 var popup = new Popup(id, this.bindElement, options); 2719 if (this.params && this.params.events) { 2720 popup.subscribeFromOptions(this.params.events); 2721 } 2722 return popup; 2723 } 2724 }, { 2725 key: "getPopupWindow", 2726 value: function getPopupWindow() { 2727 return this.popupWindow; 2728 } 2729 }, { 2730 key: "show", 2731 value: function show() { 2732 this.getPopupWindow().show(); 2733 } 2734 }, { 2735 key: "close", 2736 value: function close() { 2737 this.getPopupWindow().close(); 2738 } 2739 }, { 2740 key: "destroy", 2741 value: function destroy() { 2742 this.getPopupWindow().destroy(); 2743 } 2744 }, { 2745 key: "toggle", 2746 value: function toggle() { 2747 if (this.getPopupWindow().isShown()) { 2748 this.close(); 2749 } else { 2750 this.show(); 2751 } 2752 } 2753 }, { 2754 key: "getId", 2755 value: function getId() { 2756 return this.id; 2757 } 2758 /** 2759 * @private 2760 */ 2761 }, { 2762 key: "handlePopupClose", 2763 value: function handlePopupClose() { 2764 for (var i = 0; i < this.menuItems.length; i++) { 2765 var item = this.menuItems[i]; 2766 item.closeSubMenu(); 2767 } 2768 } 2769 /** 2770 * @private 2771 */ 2772 }, { 2773 key: "handlePopupDestroy", 2774 value: function handlePopupDestroy() { 2775 for (var i = 0; i < this.menuItems.length; i++) { 2776 var item = this.menuItems[i]; 2777 item.destroySubMenu(); 2778 } 2779 } 2780 /** 2781 * @private 2782 */ 2783 }, { 2784 key: "handleAutoHide", 2785 value: function handleAutoHide(event) { 2786 return !this.containsTarget(event.target); 2787 } 2788 /** 2789 * @private 2790 */ 2791 }, { 2792 key: "containsTarget", 2793 value: function containsTarget(target) { 2794 var el = this.getPopupWindow().getPopupContainer(); 2795 if (this.getPopupWindow().isShown() && (target === el || el.contains(target))) { 2796 return true; 2797 } 2798 return this.getMenuItems().some(function (item) { 2799 return item.getSubMenu() && item.getSubMenu().containsTarget(target); 2800 }); 2801 } 2802 }, { 2803 key: "setParentMenuWindow", 2804 value: function setParentMenuWindow(parentMenu) { 2805 if (parentMenu instanceof Menu) { 2806 this.parentMenuWindow = parentMenu; 2807 } 2808 } 2809 }, { 2810 key: "getParentMenuWindow", 2811 value: function getParentMenuWindow() { 2812 return this.parentMenuWindow; 2813 } 2814 }, { 2815 key: "getRootMenuWindow", 2816 value: function getRootMenuWindow() { 2817 var root = null; 2818 var parent = this.getParentMenuWindow(); 2819 while (parent !== null) { 2820 root = parent; 2821 parent = parent.getParentMenuWindow(); 2822 } 2823 return root; 2824 } 2825 }, { 2826 key: "setParentMenuItem", 2827 value: function setParentMenuItem(parentItem) { 2828 if (parentItem instanceof MenuItem) { 2829 this.parentMenuItem = parentItem; 2830 } 2831 } 2832 }, { 2833 key: "getParentMenuItem", 2834 value: function getParentMenuItem() { 2835 return this.parentMenuItem; 2836 } 2837 }, { 2838 key: "addMenuItem", 2839 value: function addMenuItem(menuItemJson, targetItemId) { 2840 var menuItem = this.addMenuItemInternal(menuItemJson, targetItemId); 2841 if (!menuItem) { 2842 return null; 2843 } 2844 var itemLayout = menuItem.getLayout(); 2845 var targetItem = this.getMenuItem(targetItemId); 2846 if (targetItem !== null) { 2847 var targetLayout = targetItem.getLayout(); 2848 this.itemsContainer.insertBefore(itemLayout.item, targetLayout.item); 2849 } else { 2850 this.itemsContainer.appendChild(itemLayout.item); 2851 } 2852 return menuItem; 2853 } 2854 /** 2855 * @private 2856 */ 2857 }, { 2858 key: "addMenuItemInternal", 2859 value: function addMenuItemInternal(menuItemJson, targetItemId) { 2860 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) { 2861 return null; 2862 } 2863 if (main_core.Type.isNumber(this.params.menuShowDelay)) { 2864 menuItemJson.menuShowDelay = this.params.menuShowDelay; 2865 } 2866 var menuItem = new MenuItem(menuItemJson); 2867 menuItem.setMenuWindow(this); 2868 var position = this.getMenuItemPosition(targetItemId); 2869 if (position >= 0) { 2870 this.menuItems.splice(position, 0, menuItem); 2871 } else { 2872 this.menuItems.push(menuItem); 2873 } 2874 return menuItem; 2875 } 2876 }, { 2877 key: "removeMenuItem", 2878 value: function removeMenuItem(itemId) { 2879 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { 2880 destroyEmptyPopup: true 2881 }; 2882 var item = this.getMenuItem(itemId); 2883 if (!item) { 2884 return; 2885 } 2886 for (var position = 0; position < this.menuItems.length; position++) { 2887 if (this.menuItems[position] === item) { 2888 item.destroySubMenu(); 2889 this.menuItems.splice(position, 1); 2890 break; 2891 } 2892 } 2893 if (!this.menuItems.length) { 2894 var menuWindow = item.getMenuWindow(); 2895 if (menuWindow) { 2896 var parentMenuItem = menuWindow.getParentMenuItem(); 2897 if (parentMenuItem) { 2898 parentMenuItem.destroySubMenu(); 2899 } else if (options.destroyEmptyPopup) { 2900 menuWindow.destroy(); 2901 } 2902 } 2903 } 2904 item.layout.item.parentNode.removeChild(item.layout.item); 2905 item.layout = { 2906 item: null, 2907 text: null 2908 }; 2909 } 2910 }, { 2911 key: "getMenuItem", 2912 value: function getMenuItem(itemId) { 2913 for (var i = 0; i < this.menuItems.length; i++) { 2914 if (this.menuItems[i].id && this.menuItems[i].id === itemId) { 2915 return this.menuItems[i]; 2916 } 2917 } 2918 return null; 2919 } 2920 }, { 2921 key: "getMenuItems", 2922 value: function getMenuItems() { 2923 return this.menuItems; 2924 } 2925 }, { 2926 key: "getMenuItemPosition", 2927 value: function getMenuItemPosition(itemId) { 2928 if (itemId) { 2929 for (var i = 0; i < this.menuItems.length; i++) { 2930 if (this.menuItems[i].id && this.menuItems[i].id === itemId) { 2931 return i; 2932 } 2933 } 2934 } 2935 return -1; 2936 } 2937 }, { 2938 key: "getMenuContainer", 2939 value: function getMenuContainer() { 2940 return this.getPopupWindow().getPopupContainer(); 2941 } 2942 }]);
2943 return Menu; 2944 }(main_core_events.EventEmitter); 2945 2946 var MenuManager = /*#__PURE__*/function () { 2947 /** 2948 * @private 2949 */ 2950 2951 /** 2952 * @private 2953 */ 2954 2955 function MenuManager() { 2956 babelHelpers.classCallCheck(this, MenuManager); 2957 throw new Error('You cannot make an instance of MenuManager.'); 2958 } 2959 babelHelpers.createClass(MenuManager, null, [{ 2960 key: "show", 2961 value: function show() { 2962 if (this.currentItem !== null) { 2963 this.currentItem.popupWindow.close(); 2964 } 2965 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { 2966 args[_key] = arguments[_key]; 2967 } 2968 this.currentItem = this.create.apply(this, args); 2969 this.currentItem.popupWindow.show(); 2970 } 2971 }, { 2972 key: "create", 2973 value: function create(options) { 2974 var menuId = null; 2975 2976 //Compatibility 2977 var bindElement = arguments[1]; 2978 var menuItems = arguments[2]; 2979 var params = arguments[3]; 2980 if (main_core.Type.isPlainObject(options) && !bindElement && !menuItems && !params) { 2981 menuId = options.id; 2982 if (!main_core.Type.isStringFilled(menuId)) { 2983 throw new Error('BX.Main.Menu.create: "id" parameter is required.'); 2984 } 2985 } else { 2986 menuId = options; 2987 } 2988 if (!this.Data[menuId]) { 2989 var menu = new Menu(options, bindElement, menuItems, params); 2990 menu.getPopupWindow().subscribe('onDestroy', function () { 2991 MenuManager.destroy(menuId); 2992 }); 2993 this.Data[menuId] = menu; 2994 } 2995 return this.Data[menuId]; 2996 } 2997 }, { 2998 key: "getCurrentMenu", 2999 value: function getCurrentMenu() { 3000 return this.currentItem; 3001 } 3002 }, { 3003 key: "getMenuById", 3004 value: function getMenuById(id) { 3005 return this.Data[id] ? this.Data[id] : null; 3006 } 3007 /** 3008 * compatibility 3009 * @private 3010 */ 3011 }, { 3012 key: "onPopupDestroy", 3013 value: function onPopupDestroy(popupMenuWindow) { 3014 this.destroy(popupMenuWindow.id); 3015 } 3016 }, { 3017 key: "destroy", 3018 value: function destroy(id) { 3019 var menu = this.getMenuById(id); 3020 if (menu) { 3021 if (this.currentItem === menu) { 3022 this.currentItem = null; 3023 } 3024 delete this.Data[id]; 3025 menu.getPopupWindow().destroy(); 3026 } 3027 } 3028 }]); 3029 return MenuManager; 3030 }(); 3031 babelHelpers.defineProperty(MenuManager, "Data", {}); 3032 babelHelpers.defineProperty(MenuManager, "currentItem", null); 3033 3034 /** 3035 * @deprecated use Popup class instead: import { Popup } from 'main.popup' 3036 */ 3037 var PopupWindow = /*#__PURE__*/function (_Popup) { 3038 babelHelpers.inherits(PopupWindow, _Popup); 3039 function PopupWindow() { 3040 babelHelpers.classCallCheck(this, PopupWindow); 3041 return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(PopupWindow).apply(this, arguments)); 3042 } 3043 return PopupWindow; 3044 }(Popup); 3045 3046 /** 3047 * @deprecated use BX.UI.Button 3048 */ 3049 var PopupWindowButton = /*#__PURE__*/function (_Button) { 3050 babelHelpers.inherits(PopupWindowButton, _Button); 3051 function PopupWindowButton() { 3052 babelHelpers.classCallCheck(this, PopupWindowButton); 3053 return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(PopupWindowButton).apply(this, arguments)); 3054 } 3055 return PopupWindowButton; 3056 }(Button); 3057 3058 /** 3059 * @deprecated use BX.UI.Button 3060 */ 3061 var ButtonLink = /*#__PURE__*/function (_Button) { 3062 babelHelpers.inherits(ButtonLink, _Button); 3063 function ButtonLink(params) { 3064 var _this; 3065 babelHelpers.classCallCheck(this, ButtonLink); 3066 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(ButtonLink).call(this, params)); 3067 _this.buttonNode = main_core.Dom.create('span', { 3068 props: { 3069 className: 'popup-window-button popup-window-button-link' + (_this.className.length > 0 ? ' ' + _this.className : ''), 3070 id: _this.id 3071 }, 3072 text: _this.text, 3073 events: _this.contextEvents 3074 }); 3075 return _this; 3076 } 3077 return ButtonLink; 3078 }(Button); 3079 3080 /** 3081 * @deprecated use BX.UI.Button 3082 */ 3083 var PopupWindowButtonLink = /*#__PURE__*/function (_ButtonLink) { 3084 babelHelpers.inherits(PopupWindowButtonLink, _ButtonLink); 3085 function PopupWindowButtonLink() { 3086 babelHelpers.classCallCheck(this, PopupWindowButtonLink); 3087 return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(PopupWindowButtonLink).apply(this, arguments)); 3088 } 3089 return PopupWindowButtonLink; 3090 }(ButtonLink); 3091 3092 /** 3093 * @deprecated use BX.UI.Button 3094 */ 3095 var CustomButton = /*#__PURE__*/function (_Button) { 3096 babelHelpers.inherits(CustomButton, _Button); 3097 function CustomButton(params) { 3098 var _this; 3099 babelHelpers.classCallCheck(this, CustomButton); 3100 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(CustomButton).call(this, params)); 3101 _this.buttonNode = main_core.Dom.create('span', { 3102 props: { 3103 className: _this.className.length > 0 ? _this.className : '', 3104 id: _this.id 3105 }, 3106 events: _this.contextEvents, 3107 text: _this.text 3108 }); 3109 return _this; 3110 } 3111 return CustomButton; 3112 }(Button); 3113 3114 /** 3115 * @deprecated use BX.UI.Button 3116 */ 3117 var PopupWindowCustomButton = /*#__PURE__*/function (_CustomButton) { 3118 babelHelpers.inherits(PopupWindowCustomButton, _CustomButton); 3119 function PopupWindowCustomButton() { 3120 babelHelpers.classCallCheck(this, PopupWindowCustomButton); 3121 return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(PopupWindowCustomButton).apply(this, arguments)); 3122 } 3123 return PopupWindowCustomButton; 3124 }(CustomButton); 3125 3126 /** 3127 * @deprecated use Menu class instead: import { Menu } from 'main.popup' 3128 */ 3129 var PopupMenuWindow = /*#__PURE__*/function (_Menu) { 3130 babelHelpers.inherits(PopupMenuWindow, _Menu); 3131 function PopupMenuWindow() { 3132 babelHelpers.classCallCheck(this, PopupMenuWindow); 3133 return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(PopupMenuWindow).apply(this, arguments)); 3134 } 3135 return PopupMenuWindow; 3136 }(Menu); 3137 3138 /** 3139 * @deprecated use Menu.Item class instead: import { MenuItem } from 'main.popup' 3140 */ 3141 var PopupMenuItem = /*#__PURE__*/function (_MenuItem) { 3142 babelHelpers.inherits(PopupMenuItem, _MenuItem); 3143 function PopupMenuItem() { 3144 babelHelpers.classCallCheck(this, PopupMenuItem); 3145 return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(PopupMenuItem).apply(this, arguments)); 3146 } 3147 return PopupMenuItem; 3148 }(MenuItem); 3149 3150 /** 3151 * @deprecated 3152 */ 3153 var InputPopup = /*#__PURE__*/function () { 3154 function InputPopup(params) { 3155 babelHelpers.classCallCheck(this, InputPopup); 3156 this.id = params.id || 'bx-inp-popup-' + Math.round(Math.random() * 1000000); 3157 this.handler = params.handler || false; 3158 this.values = params.values || false; 3159 this.pInput = params.input; 3160 this.bValues = !!this.values; 3161 this.defaultValue = params.defaultValue || ''; 3162 this.openTitle = params.openTitle || ''; 3163 this.className = params.className || ''; 3164 this.noMRclassName = params.noMRclassName || 'ec-no-rm'; 3165 this.emptyClassName = params.noMRclassName || 'ec-label'; 3166 var _this = this; 3167 this.curInd = false;
3168 if (this.bValues) { 3169 this.pInput.onfocus = this.pInput.onclick = function (e) { 3170 if (this.value == _this.defaultValue) { 3171 this.value = ''; 3172 this.className = _this.className; 3173 } 3174 _this.ShowPopup(); 3175 return e.preventDefault(); 3176 }; 3177 this.pInput.onblur = function () { 3178 if (_this.bShowed) { 3179 setTimeout(function () { 3180 _this.ClosePopup(true); 3181 }, 200); 3182 } 3183 _this.OnChange(); 3184 }; 3185 } else { 3186 this.pInput.className = this.noMRclassName; 3187 this.pInput.onblur = this.OnChange.bind(this); 3188 } 3189 } 3190 babelHelpers.createClass(InputPopup, [{ 3191 key: "ShowPopup", 3192 value: function ShowPopup() { 3193 if (this.bShowed) { 3194 return; 3195 } 3196 var _this = this; 3197 if (!this.oPopup) { 3198 var pWnd = main_core.Dom.create('DIV', { 3199 props: { 3200 className: 'bxecpl-loc-popup ' + this.className 3201 } 3202 }); 3203 for (var i = 0, l = this.values.length; i < l; i++) { 3204 var pRow = pWnd.appendChild(main_core.Dom.create('DIV', { 3205 props: { 3206 id: 'bxecmr_' + i 3207 }, 3208 text: this.values[i].NAME, 3209 events: { 3210 mouseover: function mouseover() { 3211 main_core.Dom.addClass(this, 'bxecplloc-over'); 3212 }, 3213 mouseout: function mouseout() { 3214 main_core.Dom.removeClass(this, 'bxecplloc-over'); 3215 }, 3216 click: function click() { 3217 var ind = this.id.substr('bxecmr_'.length); 3218 _this.pInput.value = _this.values[ind].NAME; 3219 _this.curInd = ind; 3220 _this.OnChange(); 3221 _this.ClosePopup(true); 3222 } 3223 } 3224 })); 3225 if (this.values[i].DESCRIPTION) { 3226 pRow.title = this.values[i].DESCRIPTION; 3227 } 3228 if (this.values[i].CLASS_NAME) { 3229 main_core.Dom.addClass(pRow, this.values[i].CLASS_NAME); 3230 } 3231 if (this.values[i].URL) { 3232 pRow.appendChild(main_core.Dom.create('a', { 3233 props: { 3234 href: this.values[i].URL, 3235 className: 'bxecplloc-view', 3236 target: '_blank', 3237 title: this.openTitle 3238 } 3239 })); 3240 } 3241 } 3242 this.oPopup = new Popup(this.id, this.pInput, { 3243 autoHide: true, 3244 offsetTop: 1, 3245 offsetLeft: 0, 3246 lightShadow: true, 3247 closeByEsc: true, 3248 content: pWnd, 3249 events: { 3250 onClose: this.ClosePopup.bind(this) 3251 } 3252 }); 3253 } 3254 this.oPopup.show(); 3255 this.pInput.select(); 3256 this.bShowed = true; 3257 main_core_events.EventEmitter.emit(this, 'onInputPopupShow', new main_core_events.BaseEvent({ 3258 compatData: [this] 3259 })); 3260 } 3261 }, { 3262 key: "ClosePopup", 3263 value: function ClosePopup(bClosePopup) { 3264 this.bShowed = false; 3265 if (this.pInput.value === '') { 3266 this.OnChange(); 3267 } 3268 main_core_events.EventEmitter.emit(this, 'onInputPopupClose', new main_core_events.BaseEvent({ 3269 compatData: [this] 3270 })); 3271 if (bClosePopup === true) { 3272 this.oPopup.close(); 3273 } 3274 } 3275 }, { 3276 key: "OnChange", 3277 value: function OnChange() { 3278 var val = this.pInput.value; 3279 if (this.bValues) { 3280 if (this.pInput.value == '' || this.pInput.value == this.defaultValue) { 3281 this.pInput.value = this.defaultValue; 3282 this.pInput.className = this.emptyClassName; 3283 val = ''; 3284 } else { 3285 this.pInput.className = ''; 3286 } 3287 } 3288 if (isNaN(parseInt(this.curInd)) || this.curInd !== false && val != this.values[this.curInd].NAME) { 3289 this.curInd = false; 3290 } else { 3291 this.curInd = parseInt(this.curInd); 3292 } 3293 main_core_events.EventEmitter.emit(this, 'onInputPopupChanged', new main_core_events.BaseEvent({ 3294 compatData: [this, this.curInd, val] 3295 })); 3296 if (this.handler && typeof this.handler == 'function') { 3297 this.handler({ 3298 ind: this.curInd, 3299 value: val 3300 }); 3301 } 3302 } 3303 }, { 3304 key: "Set", 3305 value: function Set(ind, val, bOnChange) { 3306 this.curInd = ind; 3307 if (this.curInd !== false) { 3308 this.pInput.value = this.values[this.curInd].NAME; 3309 } else { 3310 this.pInput.value = val; 3311 } 3312 if (bOnChange !== false) { 3313 this.OnChange(); 3314 } 3315 } 3316 }, { 3317 key: "Get", 3318 value: function Get(ind) { 3319 var id = false;
3320 if (typeof ind == 'undefined') { 3321 ind = this.curInd; 3322 } 3323 if (ind !== false && this.values[ind]) { 3324 id = this.values[ind].ID; 3325 } 3326 return id; 3327 } 3328 }, { 3329 key: "GetIndex", 3330 value: function GetIndex(id) { 3331 for (var i = 0, l = this.values.length; i < l; i++) { 3332 if (this.values[i].ID == id) { 3333 return i; 3334 } 3335 } 3336 return false; 3337 } 3338 }, { 3339 key: "Deactivate", 3340 value: function Deactivate(bDeactivate) { 3341 if (this.pInput.value == '' || this.pInput.value == this.defaultValue) { 3342 if (bDeactivate) { 3343 this.pInput.value = ''; 3344 this.pInput.className = this.noMRclassName; 3345 } else if (this.oEC.bUseMR) { 3346 this.pInput.value = this.defaultValue; 3347 this.pInput.className = this.emptyClassName; 3348 } 3349 } 3350 this.pInput.disabled = bDeactivate; 3351 } 3352 }]); 3353 return InputPopup; 3354 }(); 3355 3356 /* 3357 3358 //ES6 3359 import { Popup, PopupManager, CloseIconSize } from 'main.popup'; 3360 const popup = new Popup(); 3361 PopupManager.create(); 3362 3363 //ES5 3364 var popup = new BX.Main.Popup(); 3365 BX.Main.PopupManager.create(); 3366 BX.Main.Popup.CloseIconSize; 3367 3368 //ES6 3369 import { Menu, MenuItem, MenuManager } from 'main.popup'; 3370 const menu = new Menu(); 3371 const item = new MenuItem(); 3372 MenuManager.create(); 3373 3374 //ES5 3375 var menu = new BX.Main.Menu(); 3376 var item = new BX.Main.MenuItem(); 3377 BX.Main.MenuManager.create(); 3378 3379 */ 3380 var BX = main_core.Reflection.namespace('BX'); 3381 3382 /** @deprecated use BX.Main.Popup or import { Popup } from 'main.popup' */ 3383 BX.PopupWindow = Popup; 3384 3385 /** @deprecated use BX.Main.PopupManager or import { PopupManager } from 'main.popup' */ 3386 BX.PopupWindowManager = PopupManager; 3387 3388 /** @deprecated use BX.Main.Menu or import { Menu } from 'main.popup' */ 3389 BX.PopupMenuWindow = Menu; 3390 3391 /** @deprecated use BX.Main.MenuManager or import { MenuManager } from 'main.popup' */ 3392 BX.PopupMenu = MenuManager; 3393 3394 /** @deprecated use BX.Main.MenuItem or import { MenuItem } from 'main.popup' */ 3395 BX.PopupMenuItem = MenuItem; 3396 3397 /** @deprecated use BX.UI.Button */ 3398 BX.PopupWindowButton = Button; 3399 3400 /** @deprecated use BX.UI.Button */ 3401 BX.PopupWindowButtonLink = ButtonLink; 3402 3403 /** @deprecated use BX.UI.Button */ 3404 BX.PopupWindowCustomButton = CustomButton; 3405 3406 /** @deprecated use another API */ 3407 window.BXInputPopup = InputPopup; 3408 3409 exports.Popup = Popup; 3410 exports.Menu = Menu; 3411 exports.MenuItem = MenuItem; 3412 exports.PopupManager = PopupManager; 3413 exports.MenuManager = MenuManager; 3414 exports.CloseIconSize = CloseIconSize; 3415 exports.PopupWindow = PopupWindow; 3416 exports.PopupMenuWindow = PopupMenuWindow; 3417 exports.PopupMenuItem = PopupMenuItem; 3418 exports.PopupWindowManager = PopupManager; 3419 exports.PopupMenu = MenuManager; 3420 exports.PopupWindowButton = PopupWindowButton; 3421 exports.PopupWindowButtonLink = PopupWindowButtonLink; 3422 exports.PopupWindowCustomButton = PopupWindowCustomButton; 3423 3424}((this.BX.Main = this.BX.Main || {}),BX,BX.Event,BX)); 3425//# 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.