Dashboard sipadu mbip
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

BootstrapModalManager.js 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import _inheritsLoose from "@babel/runtime/helpers/esm/inheritsLoose";
  2. import qsa from 'dom-helpers/query/querySelectorAll';
  3. import css from 'dom-helpers/style';
  4. import getScrollbarSize from 'dom-helpers/util/scrollbarSize';
  5. import ModalManager from 'react-overlays/ModalManager';
  6. var Selector = {
  7. FIXED_CONTENT: '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top',
  8. STICKY_CONTENT: '.sticky-top',
  9. NAVBAR_TOGGLER: '.navbar-toggler'
  10. };
  11. var BootstrapModalManager =
  12. /*#__PURE__*/
  13. function (_ModalManager) {
  14. _inheritsLoose(BootstrapModalManager, _ModalManager);
  15. function BootstrapModalManager() {
  16. var _this;
  17. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  18. args[_key] = arguments[_key];
  19. }
  20. _this = _ModalManager.call.apply(_ModalManager, [this].concat(args)) || this;
  21. _this.adjustAndStore = function (prop, element, adjust) {
  22. var actual = element.style[prop];
  23. element.dataset[prop] = actual;
  24. css(element, prop, parseFloat(css(element, prop)) + adjust + "px");
  25. };
  26. _this.restore = function (prop, element) {
  27. var value = element.dataset[prop];
  28. if (value !== undefined) {
  29. delete element.dataset[prop];
  30. css(element, prop, value);
  31. }
  32. };
  33. return _this;
  34. }
  35. var _proto = BootstrapModalManager.prototype;
  36. _proto.setContainerStyle = function setContainerStyle(containerState, container) {
  37. var _this2 = this;
  38. _ModalManager.prototype.setContainerStyle.call(this, containerState, container);
  39. if (!containerState.overflowing) return;
  40. var size = getScrollbarSize();
  41. qsa(container, Selector.FIXED_CONTENT).forEach(function (el) {
  42. return _this2.adjustAndStore('paddingRight', el, size);
  43. });
  44. qsa(container, Selector.STICKY_CONTENT).forEach(function (el) {
  45. return _this2.adjustAndStore('margingRight', el, -size);
  46. });
  47. qsa(container, Selector.NAVBAR_TOGGLER).forEach(function (el) {
  48. return _this2.adjustAndStore('margingRight', el, size);
  49. });
  50. };
  51. _proto.removeContainerStyle = function removeContainerStyle(containerState, container) {
  52. var _this3 = this;
  53. _ModalManager.prototype.removeContainerStyle.call(this, containerState, container);
  54. qsa(container, Selector.FIXED_CONTENT).forEach(function (el) {
  55. return _this3.restore('paddingRight', el);
  56. });
  57. qsa(container, Selector.STICKY_CONTENT).forEach(function (el) {
  58. return _this3.restore('margingRight', el);
  59. });
  60. qsa(container, Selector.NAVBAR_TOGGLER).forEach(function (el) {
  61. return _this3.restore('margingRight', el);
  62. });
  63. };
  64. return BootstrapModalManager;
  65. }(ModalManager);
  66. export { BootstrapModalManager as default };