Update
This commit is contained in:
@@ -259,6 +259,25 @@ this.BX = this.BX || {};
|
||||
_this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Popup).call(this));
|
||||
_classPrivateMethodInitSpec(babelHelpers.assertThisInitialized(_this), _enableTargetScroll);
|
||||
_classPrivateMethodInitSpec(babelHelpers.assertThisInitialized(_this), _disableTargetScroll);
|
||||
babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "handleAutoHide", function (event) {
|
||||
if (_this.isDestroyed()) {
|
||||
return;
|
||||
}
|
||||
if (_this.autoHideHandler !== null) {
|
||||
if (_this.autoHideHandler(event)) {
|
||||
_this._tryCloseByEvent(event);
|
||||
}
|
||||
} else if (event.target !== _this.getPopupContainer() && !_this.getPopupContainer().contains(event.target)) {
|
||||
_this._tryCloseByEvent(event);
|
||||
}
|
||||
});
|
||||
babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "handleDocumentKeyUp", function (event) {
|
||||
if (event.keyCode === 27) {
|
||||
checkEscPressed(_this.getZindex(), function () {
|
||||
_this.close();
|
||||
});
|
||||
}
|
||||
});
|
||||
_this.setEventNamespace('BX.Main.Popup');
|
||||
var _arguments = Array.prototype.slice.call(arguments),
|
||||
popupId = _arguments[0],
|
||||
@@ -303,7 +322,6 @@ this.BX = this.BX || {};
|
||||
_this.autoHide = params.autoHide === true;
|
||||
_this.disableScroll = params.disableScroll === true || params.isScrollBlock === true;
|
||||
_this.autoHideHandler = main_core.Type.isFunction(params.autoHideHandler) ? params.autoHideHandler : null;
|
||||
_this.handleAutoHide = _this.handleAutoHide.bind(babelHelpers.assertThisInitialized(_this));
|
||||
_this.handleOverlayClick = _this.handleOverlayClick.bind(babelHelpers.assertThisInitialized(_this));
|
||||
_this.isAutoHideBinded = false;
|
||||
_this.closeByEsc = params.closeByEsc === true;
|
||||
@@ -324,7 +342,7 @@ this.BX = this.BX || {};
|
||||
_this.contentBackground = null;
|
||||
_this.borderRadius = null;
|
||||
_this.contentBorderRadius = null;
|
||||
_this.targetContainer = main_core.Type.isElementNode(params.targetContainer) ? params.targetContainer : document.body;
|
||||
_this.setTargetContainer(params.targetContainer);
|
||||
_this.dragOptions = {
|
||||
cursor: '',
|
||||
callback: function callback() {},
|
||||
@@ -338,7 +356,6 @@ this.BX = this.BX || {};
|
||||
_this.animationCloseEventType = null;
|
||||
_this.handleDocumentMouseMove = _this.handleDocumentMouseMove.bind(babelHelpers.assertThisInitialized(_this));
|
||||
_this.handleDocumentMouseUp = _this.handleDocumentMouseUp.bind(babelHelpers.assertThisInitialized(_this));
|
||||
_this.handleDocumentKeyUp = _this.handleDocumentKeyUp.bind(babelHelpers.assertThisInitialized(_this));
|
||||
_this.handleResizeWindow = _this.handleResizeWindow.bind(babelHelpers.assertThisInitialized(_this));
|
||||
_this.handleResize = _this.handleResize.bind(babelHelpers.assertThisInitialized(_this));
|
||||
_this.handleMove = _this.handleMove.bind(babelHelpers.assertThisInitialized(_this));
|
||||
@@ -380,7 +397,7 @@ this.BX = this.BX || {};
|
||||
* @private
|
||||
*/
|
||||
_this.popupContainer = main_core.Tag.render(_templateObject4 || (_templateObject4 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t<div\n\t\t\t\tclass=\"", "\"\n\t\t\t\tid=\"", "\"\n\t\t\t\tstyle=\"display: none; position: absolute; left: 0; top: 0;\"\n\t\t\t>", "</div>\n\t\t"])), popupClassName, popupId, [_this.titleBar, _this.contentContainer, _this.closeIcon]);
|
||||
_this.targetContainer.appendChild(_this.popupContainer);
|
||||
_this.getTargetContainer().append(_this.popupContainer);
|
||||
_this.zIndexComponent = main_core_zIndexManager.ZIndexManager.register(_this.popupContainer, params.zIndexOptions);
|
||||
_this.buttonsContainer = null;
|
||||
if (params.contentColor && main_core.Type.isStringFilled(params.contentColor)) {
|
||||
@@ -985,6 +1002,23 @@ this.BX = this.BX || {};
|
||||
this.designSystemContext = context;
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "setTargetContainer",
|
||||
value: function setTargetContainer(targetContainer) {
|
||||
var newTargetContainer = main_core.Type.isElementNode(targetContainer) ? targetContainer : document.body;
|
||||
if (newTargetContainer === this.targetContainer) {
|
||||
return;
|
||||
}
|
||||
this.targetContainer = newTargetContainer;
|
||||
if (this.getPopupContainer()) {
|
||||
main_core_zIndexManager.ZIndexManager.unregister(this.getPopupContainer());
|
||||
this.getTargetContainer().append(this.getPopupContainer());
|
||||
main_core_zIndexManager.ZIndexManager.register(this.getPopupContainer());
|
||||
}
|
||||
if (this.overlay) {
|
||||
main_core.Dom.append(this.overlay.element, this.getTargetContainer());
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "getTargetContainer",
|
||||
value: function getTargetContainer() {
|
||||
@@ -1159,7 +1193,7 @@ this.BX = this.BX || {};
|
||||
key: "bindClosingByEsc",
|
||||
value: function bindClosingByEsc() {
|
||||
if (this.closeByEsc && !this.isCloseByEscBinded) {
|
||||
main_core.Event.bind(document, 'keyup', this.handleDocumentKeyUp);
|
||||
main_core.Event.bind(this.targetContainer.ownerDocument, 'keyup', this.handleDocumentKeyUp, true);
|
||||
this.isCloseByEscBinded = true;
|
||||
}
|
||||
}
|
||||
@@ -1170,7 +1204,7 @@ this.BX = this.BX || {};
|
||||
key: "unbindClosingByEsc",
|
||||
value: function unbindClosingByEsc() {
|
||||
if (this.isCloseByEscBinded) {
|
||||
main_core.Event.unbind(document, 'keyup', this.handleDocumentKeyUp);
|
||||
main_core.Event.unbind(this.targetContainer.ownerDocument, 'keyup', this.handleDocumentKeyUp, true);
|
||||
this.isCloseByEscBinded = false;
|
||||
}
|
||||
}
|
||||
@@ -1201,9 +1235,9 @@ this.BX = this.BX || {};
|
||||
main_core.Event.bind(this.overlay.element, 'click', this.handleOverlayClick);
|
||||
} else {
|
||||
if (this.isCompatibleMode()) {
|
||||
main_core.Event.bind(document, 'click', this.handleAutoHide);
|
||||
main_core.Event.bind(this.targetContainer.ownerDocument, 'click', this.handleAutoHide);
|
||||
} else {
|
||||
document.addEventListener('click', this.handleAutoHide, true);
|
||||
this.targetContainer.ownerDocument.addEventListener('click', this.handleAutoHide, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1223,9 +1257,9 @@ this.BX = this.BX || {};
|
||||
main_core.Event.unbind(this.overlay.element, 'click', this.handleOverlayClick);
|
||||
} else {
|
||||
if (this.isCompatibleMode()) {
|
||||
main_core.Event.unbind(document, 'click', this.handleAutoHide);
|
||||
main_core.Event.unbind(this.targetContainer.ownerDocument, 'click', this.handleAutoHide);
|
||||
} else {
|
||||
document.removeEventListener('click', this.handleAutoHide, true);
|
||||
this.targetContainer.ownerDocument.removeEventListener('click', this.handleAutoHide, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1234,24 +1268,10 @@ this.BX = this.BX || {};
|
||||
* @private
|
||||
*/
|
||||
}, {
|
||||
key: "handleAutoHide",
|
||||
value: function handleAutoHide(event) {
|
||||
if (this.isDestroyed()) {
|
||||
return;
|
||||
}
|
||||
if (this.autoHideHandler !== null) {
|
||||
if (this.autoHideHandler(event)) {
|
||||
this._tryCloseByEvent(event);
|
||||
}
|
||||
} else if (event.target !== this.getPopupContainer() && !this.getPopupContainer().contains(event.target)) {
|
||||
this._tryCloseByEvent(event);
|
||||
}
|
||||
}
|
||||
key: "_tryCloseByEvent",
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
}, {
|
||||
key: "_tryCloseByEvent",
|
||||
value: function _tryCloseByEvent(event) {
|
||||
var _this2 = this;
|
||||
if (this.isCompatibleMode()) {
|
||||
@@ -1289,7 +1309,7 @@ this.BX = this.BX || {};
|
||||
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())
|
||||
};
|
||||
this.resizeOverlay();
|
||||
main_core.Dom.append(this.overlay.element, this.targetContainer);
|
||||
main_core.Dom.append(this.overlay.element, this.getTargetContainer());
|
||||
this.getZIndexComponent().setOverlay(this.overlay.element);
|
||||
}
|
||||
if (main_core.Type.isNumber(params === null || params === void 0 ? void 0 : params.opacity) && params.opacity >= 0 && params.opacity <= 100) {
|
||||
@@ -1553,7 +1573,8 @@ this.BX = this.BX || {};
|
||||
}, {
|
||||
key: "isShown",
|
||||
value: function isShown() {
|
||||
return !this.isDestroyed() && this.getPopupContainer().style.display === 'block';
|
||||
var _this$getPopupContain;
|
||||
return !this.isDestroyed() && ((_this$getPopupContain = this.getPopupContainer()) === null || _this$getPopupContain === void 0 ? void 0 : _this$getPopupContain.style.display) === 'block';
|
||||
}
|
||||
}, {
|
||||
key: "destroy",
|
||||
@@ -1753,20 +1774,10 @@ this.BX = this.BX || {};
|
||||
* @private
|
||||
*/
|
||||
}, {
|
||||
key: "handleDocumentKeyUp",
|
||||
value: function handleDocumentKeyUp(event) {
|
||||
var _this7 = this;
|
||||
if (event.keyCode === 27) {
|
||||
checkEscPressed(this.getZindex(), function () {
|
||||
_this7.close();
|
||||
});
|
||||
}
|
||||
}
|
||||
key: "handleResizeWindow",
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
}, {
|
||||
key: "handleResizeWindow",
|
||||
value: function handleResizeWindow() {
|
||||
if (this.isShown()) {
|
||||
this.adjustPosition();
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -166,7 +166,6 @@ export default class Popup extends EventEmitter
|
||||
this.autoHide = params.autoHide === true;
|
||||
this.disableScroll = params.disableScroll === true || params.isScrollBlock === true;
|
||||
this.autoHideHandler = Type.isFunction(params.autoHideHandler) ? params.autoHideHandler : null;
|
||||
this.handleAutoHide = this.handleAutoHide.bind(this);
|
||||
this.handleOverlayClick = this.handleOverlayClick.bind(this);
|
||||
this.isAutoHideBinded = false;
|
||||
this.closeByEsc = params.closeByEsc === true;
|
||||
@@ -192,7 +191,7 @@ export default class Popup extends EventEmitter
|
||||
this.borderRadius = null;
|
||||
this.contentBorderRadius = null;
|
||||
|
||||
this.targetContainer = Type.isElementNode(params.targetContainer) ? params.targetContainer : document.body;
|
||||
this.setTargetContainer(params.targetContainer);
|
||||
|
||||
this.dragOptions = {
|
||||
cursor: '',
|
||||
@@ -211,7 +210,6 @@ export default class Popup extends EventEmitter
|
||||
|
||||
this.handleDocumentMouseMove = this.handleDocumentMouseMove.bind(this);
|
||||
this.handleDocumentMouseUp = this.handleDocumentMouseUp.bind(this);
|
||||
this.handleDocumentKeyUp = this.handleDocumentKeyUp.bind(this);
|
||||
this.handleResizeWindow = this.handleResizeWindow.bind(this);
|
||||
this.handleResize = this.handleResize.bind(this);
|
||||
this.handleMove = this.handleMove.bind(this);
|
||||
@@ -284,7 +282,7 @@ export default class Popup extends EventEmitter
|
||||
>${[this.titleBar, this.contentContainer, this.closeIcon]}</div>
|
||||
`;
|
||||
|
||||
this.targetContainer.appendChild(this.popupContainer);
|
||||
this.getTargetContainer().append(this.popupContainer);
|
||||
|
||||
this.zIndexComponent = ZIndexManager.register(this.popupContainer, params.zIndexOptions);
|
||||
|
||||
@@ -1050,6 +1048,28 @@ export default class Popup extends EventEmitter
|
||||
}
|
||||
}
|
||||
|
||||
setTargetContainer(targetContainer: HTMLElement): void
|
||||
{
|
||||
const newTargetContainer = Type.isElementNode(targetContainer) ? targetContainer : document.body;
|
||||
if (newTargetContainer === this.targetContainer)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.targetContainer = newTargetContainer;
|
||||
if (this.getPopupContainer())
|
||||
{
|
||||
ZIndexManager.unregister(this.getPopupContainer());
|
||||
this.getTargetContainer().append(this.getPopupContainer());
|
||||
ZIndexManager.register(this.getPopupContainer());
|
||||
}
|
||||
|
||||
if (this.overlay)
|
||||
{
|
||||
Dom.append(this.overlay.element, this.getTargetContainer());
|
||||
}
|
||||
}
|
||||
|
||||
getTargetContainer(): HTMLElement
|
||||
{
|
||||
return this.targetContainer;
|
||||
@@ -1265,7 +1285,7 @@ export default class Popup extends EventEmitter
|
||||
{
|
||||
if (this.closeByEsc && !this.isCloseByEscBinded)
|
||||
{
|
||||
Event.bind(document, 'keyup', this.handleDocumentKeyUp);
|
||||
Event.bind(this.targetContainer.ownerDocument, 'keyup', this.handleDocumentKeyUp, true);
|
||||
this.isCloseByEscBinded = true;
|
||||
}
|
||||
}
|
||||
@@ -1277,7 +1297,7 @@ export default class Popup extends EventEmitter
|
||||
{
|
||||
if (this.isCloseByEscBinded)
|
||||
{
|
||||
Event.unbind(document, 'keyup', this.handleDocumentKeyUp);
|
||||
Event.unbind(this.targetContainer.ownerDocument, 'keyup', this.handleDocumentKeyUp, true);
|
||||
this.isCloseByEscBinded = false;
|
||||
}
|
||||
}
|
||||
@@ -1319,11 +1339,11 @@ export default class Popup extends EventEmitter
|
||||
{
|
||||
if (this.isCompatibleMode())
|
||||
{
|
||||
Event.bind(document, 'click', this.handleAutoHide);
|
||||
Event.bind(this.targetContainer.ownerDocument, 'click', this.handleAutoHide);
|
||||
}
|
||||
else
|
||||
{
|
||||
document.addEventListener('click', this.handleAutoHide, true);
|
||||
this.targetContainer.ownerDocument.addEventListener('click', this.handleAutoHide, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1351,11 +1371,11 @@ export default class Popup extends EventEmitter
|
||||
{
|
||||
if (this.isCompatibleMode())
|
||||
{
|
||||
Event.unbind(document, 'click', this.handleAutoHide);
|
||||
Event.unbind(this.targetContainer.ownerDocument, 'click', this.handleAutoHide);
|
||||
}
|
||||
else
|
||||
{
|
||||
document.removeEventListener('click', this.handleAutoHide, true);
|
||||
this.targetContainer.ownerDocument.removeEventListener('click', this.handleAutoHide, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1364,8 +1384,7 @@ export default class Popup extends EventEmitter
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
handleAutoHide(event): void
|
||||
{
|
||||
handleAutoHide = (event): void => {
|
||||
if (this.isDestroyed())
|
||||
{
|
||||
return;
|
||||
@@ -1382,7 +1401,7 @@ export default class Popup extends EventEmitter
|
||||
{
|
||||
this._tryCloseByEvent(event);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -1433,7 +1452,7 @@ export default class Popup extends EventEmitter
|
||||
|
||||
this.resizeOverlay();
|
||||
|
||||
Dom.append(this.overlay.element, this.targetContainer);
|
||||
Dom.append(this.overlay.element, this.getTargetContainer());
|
||||
this.getZIndexComponent().setOverlay(this.overlay.element);
|
||||
}
|
||||
|
||||
@@ -1814,7 +1833,7 @@ export default class Popup extends EventEmitter
|
||||
|
||||
isShown(): boolean
|
||||
{
|
||||
return !this.isDestroyed() && this.getPopupContainer().style.display === 'block';
|
||||
return !this.isDestroyed() && this.getPopupContainer()?.style.display === 'block';
|
||||
}
|
||||
|
||||
destroy(): void
|
||||
@@ -2095,15 +2114,14 @@ export default class Popup extends EventEmitter
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
handleDocumentKeyUp(event): void
|
||||
{
|
||||
handleDocumentKeyUp = (event): void => {
|
||||
if (event.keyCode === 27)
|
||||
{
|
||||
checkEscPressed(this.getZindex(), () => {
|
||||
this.close();
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
||||
Reference in New Issue
Block a user