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