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