100 lines
3.3 KiB
JavaScript
100 lines
3.3 KiB
JavaScript
"use strict";
|
|
|
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
|
|
exports.__esModule = true;
|
|
exports.default = void 0;
|
|
|
|
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
|
|
|
|
var _css3 = _interopRequireDefault(require("dom-helpers/css"));
|
|
|
|
var _querySelectorAll = _interopRequireDefault(require("dom-helpers/querySelectorAll"));
|
|
|
|
var _scrollbarSize = _interopRequireDefault(require("dom-helpers/scrollbarSize"));
|
|
|
|
var _ModalManager2 = _interopRequireDefault(require("react-overlays/ModalManager"));
|
|
|
|
var Selector = {
|
|
FIXED_CONTENT: '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top',
|
|
STICKY_CONTENT: '.sticky-top',
|
|
NAVBAR_TOGGLER: '.navbar-toggler'
|
|
};
|
|
|
|
var BootstrapModalManager =
|
|
/*#__PURE__*/
|
|
function (_ModalManager) {
|
|
(0, _inheritsLoose2.default)(BootstrapModalManager, _ModalManager);
|
|
|
|
function BootstrapModalManager() {
|
|
var _this;
|
|
|
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
args[_key] = arguments[_key];
|
|
}
|
|
|
|
_this = _ModalManager.call.apply(_ModalManager, [this].concat(args)) || this;
|
|
|
|
_this.adjustAndStore = function (prop, element, adjust) {
|
|
var _css;
|
|
|
|
var actual = element.style[prop];
|
|
element.dataset[prop] = actual;
|
|
(0, _css3.default)(element, (_css = {}, _css[prop] = parseFloat((0, _css3.default)(element, prop)) + adjust + "px", _css));
|
|
};
|
|
|
|
_this.restore = function (prop, element) {
|
|
var value = element.dataset[prop];
|
|
|
|
if (value !== undefined) {
|
|
var _css2;
|
|
|
|
delete element.dataset[prop];
|
|
(0, _css3.default)(element, (_css2 = {}, _css2[prop] = value, _css2));
|
|
}
|
|
};
|
|
|
|
return _this;
|
|
}
|
|
|
|
var _proto = BootstrapModalManager.prototype;
|
|
|
|
_proto.setContainerStyle = function setContainerStyle(containerState, container) {
|
|
var _this2 = this;
|
|
|
|
_ModalManager.prototype.setContainerStyle.call(this, containerState, container);
|
|
|
|
if (!containerState.overflowing) return;
|
|
var size = (0, _scrollbarSize.default)();
|
|
(0, _querySelectorAll.default)(container, Selector.FIXED_CONTENT).forEach(function (el) {
|
|
return _this2.adjustAndStore('paddingRight', el, size);
|
|
});
|
|
(0, _querySelectorAll.default)(container, Selector.STICKY_CONTENT).forEach(function (el) {
|
|
return _this2.adjustAndStore('margingRight', el, -size);
|
|
});
|
|
(0, _querySelectorAll.default)(container, Selector.NAVBAR_TOGGLER).forEach(function (el) {
|
|
return _this2.adjustAndStore('margingRight', el, size);
|
|
});
|
|
};
|
|
|
|
_proto.removeContainerStyle = function removeContainerStyle(containerState, container) {
|
|
var _this3 = this;
|
|
|
|
_ModalManager.prototype.removeContainerStyle.call(this, containerState, container);
|
|
|
|
(0, _querySelectorAll.default)(container, Selector.FIXED_CONTENT).forEach(function (el) {
|
|
return _this3.restore('paddingRight', el);
|
|
});
|
|
(0, _querySelectorAll.default)(container, Selector.STICKY_CONTENT).forEach(function (el) {
|
|
return _this3.restore('margingRight', el);
|
|
});
|
|
(0, _querySelectorAll.default)(container, Selector.NAVBAR_TOGGLER).forEach(function (el) {
|
|
return _this3.restore('margingRight', el);
|
|
});
|
|
};
|
|
|
|
return BootstrapModalManager;
|
|
}(_ModalManager2.default);
|
|
|
|
exports.default = BootstrapModalManager;
|
|
module.exports = exports["default"]; |