6fd5716ef40bf6db9431886eac09ad85396ed2f493620884d30b58e160903d4de0b62a67871f65da66199fd2def8084826581a78edba5edd5beb932c0f2aed 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. 'use strict';
  2. exports.__esModule = true;
  3. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  4. var _element = require('./../../../../helpers/dom/element');
  5. var _base = require('./_base');
  6. var _base2 = _interopRequireDefault(_base);
  7. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  10. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  11. /**
  12. * @class TopLeftCornerOverlay
  13. */
  14. var TopLeftCornerOverlay = function (_Overlay) {
  15. _inherits(TopLeftCornerOverlay, _Overlay);
  16. /**
  17. * @param {Walkontable} wotInstance
  18. */
  19. function TopLeftCornerOverlay(wotInstance) {
  20. _classCallCheck(this, TopLeftCornerOverlay);
  21. var _this = _possibleConstructorReturn(this, (TopLeftCornerOverlay.__proto__ || Object.getPrototypeOf(TopLeftCornerOverlay)).call(this, wotInstance));
  22. _this.clone = _this.makeClone(_base2.default.CLONE_TOP_LEFT_CORNER);
  23. return _this;
  24. }
  25. /**
  26. * Checks if overlay should be fully rendered
  27. *
  28. * @returns {Boolean}
  29. */
  30. _createClass(TopLeftCornerOverlay, [{
  31. key: 'shouldBeRendered',
  32. value: function shouldBeRendered() {
  33. return !!((this.wot.getSetting('fixedRowsTop') || this.wot.getSetting('columnHeaders').length) && (this.wot.getSetting('fixedColumnsLeft') || this.wot.getSetting('rowHeaders').length));
  34. }
  35. /**
  36. * Updates the corner overlay position
  37. */
  38. }, {
  39. key: 'resetFixedPosition',
  40. value: function resetFixedPosition() {
  41. this.updateTrimmingContainer();
  42. if (!this.wot.wtTable.holder.parentNode) {
  43. // removed from DOM
  44. return;
  45. }
  46. var overlayRoot = this.clone.wtTable.holder.parentNode;
  47. var tableHeight = (0, _element.outerHeight)(this.clone.wtTable.TABLE);
  48. var tableWidth = (0, _element.outerWidth)(this.clone.wtTable.TABLE);
  49. var preventOverflow = this.wot.getSetting('preventOverflow');
  50. if (this.trimmingContainer === window) {
  51. var box = this.wot.wtTable.hider.getBoundingClientRect();
  52. var top = Math.ceil(box.top);
  53. var left = Math.ceil(box.left);
  54. var bottom = Math.ceil(box.bottom);
  55. var right = Math.ceil(box.right);
  56. var finalLeft = '0';
  57. var finalTop = '0';
  58. if (!preventOverflow || preventOverflow === 'vertical') {
  59. if (left < 0 && right - overlayRoot.offsetWidth > 0) {
  60. finalLeft = -left + 'px';
  61. }
  62. }
  63. if (!preventOverflow || preventOverflow === 'horizontal') {
  64. if (top < 0 && bottom - overlayRoot.offsetHeight > 0) {
  65. finalTop = -top + 'px';
  66. }
  67. }
  68. (0, _element.setOverlayPosition)(overlayRoot, finalLeft, finalTop);
  69. } else {
  70. (0, _element.resetCssTransform)(overlayRoot);
  71. }
  72. overlayRoot.style.height = (tableHeight === 0 ? tableHeight : tableHeight + 4) + 'px';
  73. overlayRoot.style.width = (tableWidth === 0 ? tableWidth : tableWidth + 4) + 'px';
  74. }
  75. }]);
  76. return TopLeftCornerOverlay;
  77. }(_base2.default);
  78. _base2.default.registerOverlay(_base2.default.CLONE_TOP_LEFT_CORNER, TopLeftCornerOverlay);
  79. exports.default = TopLeftCornerOverlay;