From 9fd0d688c2873628f8d695dc1ec9a29bd1137bc4 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 2 Sep 2024 17:44:16 +0300 Subject: [PATCH 1/2] Fix bugs with component positionin --- apps/common/main/lib/component/ComboBox.js | 10 ++-- apps/common/main/lib/component/DataView.js | 34 ++++++------ .../main/lib/component/HSBColorPicker.js | 6 +-- apps/common/main/lib/component/ListView.js | 2 +- apps/common/main/lib/component/Menu.js | 4 +- apps/common/main/lib/component/MenuItem.js | 2 +- apps/common/main/lib/component/Mixtbar.js | 16 +++--- apps/common/main/lib/component/Slider.js | 22 ++++---- .../main/lib/component/SynchronizeTip.js | 2 +- apps/common/main/lib/component/TabBar.js | 10 ++-- .../main/lib/component/ThemeColorPalette.js | 8 +-- .../common/main/lib/controller/HintManager.js | 8 +-- .../main/lib/controller/ReviewChanges.js | 2 +- .../common/main/lib/mods/perfect-scrollbar.js | 2 +- apps/common/main/lib/util/utils.js | 53 ++++++++++++++++++- .../main/app/controller/DocumentHolder.js | 18 +++---- .../main/app/controller/Navigation.js | 2 +- .../main/app/controller/Toolbar.js | 2 +- .../main/app/view/ShapeSettings.js | 2 +- apps/documenteditor/main/app/view/Toolbar.js | 2 +- .../main/app/controller/DocumentHolder.js | 28 +++++----- .../main/app/controller/Navigation.js | 2 +- apps/pdfeditor/main/app/view/ShapeSettings.js | 2 +- .../main/app/controller/DocumentHolder.js | 22 ++++---- .../main/app/view/ShapeSettings.js | 2 +- .../main/app/view/Toolbar.js | 2 +- .../main/app/controller/DocumentHolder.js | 24 ++++----- .../main/app/controller/Statusbar.js | 4 +- .../main/app/view/PivotTable.js | 2 +- .../main/app/view/ShapeSettings.js | 2 +- .../main/app/view/SortDialog.js | 4 +- .../main/app/view/Statusbar.js | 5 +- .../main/app/view/Toolbar.js | 2 +- 33 files changed, 179 insertions(+), 129 deletions(-) diff --git a/apps/common/main/lib/component/ComboBox.js b/apps/common/main/lib/component/ComboBox.js index 081c045d28..5b85951ed6 100644 --- a/apps/common/main/lib/component/ComboBox.js +++ b/apps/common/main/lib/component/ComboBox.js @@ -321,8 +321,8 @@ define([ var $list = this.cmpEl.find('ul'), isMenuAbsolute = $list.hasClass('menu-absolute'); if (this.options.restoreMenuHeightAndTop || isMenuAbsolute) { - var offset = this.cmpEl.offset(), - parentTop = this.options.menuAlignEl ? this.options.menuAlignEl.offset().top : 0, + var offset = Common.Utils.getOffset(this.cmpEl), + parentTop = this.options.menuAlignEl ? Common.Utils.getOffset(this.options.menuAlignEl).top : 0, marginTop = parseInt($list.css('margin-top')), menuTop = offset.top - parentTop + this.cmpEl.outerHeight() + marginTop, menuLeft = offset.left; @@ -386,16 +386,16 @@ define([ } } var cg = Common.Utils.croppedGeometry(), - parentTop = this.options.menuAlignEl ? this.options.menuAlignEl.offset().top : cg.top, + parentTop = this.options.menuAlignEl ? Common.Utils.getOffset(this.options.menuAlignEl).top : cg.top, parentHeight = this.options.menuAlignEl ? this.options.menuAlignEl.outerHeight() : cg.height - 10, menuH = $list.outerHeight(), - menuTop = $list.get(0).getBoundingClientRect().top, + menuTop = Common.Utils.getBoundingClientRect($list.get(0)).top, newH = menuH; if (menuH < this.restoreMenuHeight) newH = this.restoreMenuHeight; - var offset = this.cmpEl.offset(); + var offset = Common.Utils.getOffset(this.cmpEl); if (menuTop=0 && this.dataViewItems.length>idx) ? $(this.dataViewItems[idx].el) : innerEl.find('#' + record.get('id')); if (div.length<=0) return; - var div_top = div.offset().top, + var div_top = Common.Utils.getOffset(div).top, div_first = $(this.dataViewItems[0].el), div_first_top = (div_first.length>0) ? div_first[0].clientTop : 0; if (force || div_top < inner_top + div_first_top || div_top+div.outerHeight()*0.9 > inner_top + div_first_top + innerEl.height()) { @@ -1055,13 +1055,13 @@ define([ var el = $(this.dataViewItems[0].el), itemW = el.outerWidth() + parseFloat(el.css('margin-left')) + parseFloat(el.css('margin-right')), - offsetLeft = this.$el.offset().left, - offsetTop = el.offset().top, + offsetLeft = Common.Utils.getOffset(this.$el).left, + offsetTop = Common.Utils.getOffset(el).top, prevtop = -1, topIdx = 0, leftIdx = 0; for (var i=0; iprevtop) { prevtop = top; this._layoutParams.itemsIndexes.push([]); @@ -1360,14 +1360,14 @@ define([ scrollToRecord: function (record) { if (!record) return; var innerEl = $(this.el).find('.inner'), - inner_top = innerEl.offset().top, + inner_top = Common.Utils.getOffset(innerEl).top, idx = _.indexOf(this.store.models, record), div = (idx>=0 && this.dataViewItems.length>idx) ? this.dataViewItems[idx].el : innerEl.find('#' + record.get('id')); if (div.length<=0) return; - var div_top = div.offset().top, + var div_top = Common.Utils.getOffset(div).top, div_first = this.dataViewItems[0].el, - div_first_top = (div_first.length>0) ? div_first[0].offsetTop : 0; + div_first_top = (div_first.length>0) ? Common.Utils.getOffsetTop(div_first[0]) : 0; if (div_top < inner_top + div_first_top || div_top+div.outerHeight() > inner_top + innerEl.height()) { if (this.scroller) { this.scroller.scrollTop(innerEl.scrollTop() + div_top - inner_top - div_first_top, 0); @@ -1552,14 +1552,14 @@ define([ var el = this.dataViewItems[0].el, itemW = el.outerWidth() + parseFloat(el.css('margin-left')) + parseFloat(el.css('margin-right')), - offsetLeft = this.$el.offset().left, - offsetTop = el.offset().top, + offsetLeft = Common.Utils.getOffset(this.$el).left, + offsetTop = Common.Utils.getOffset(el).top, prevtop = -1, topIdx = 0, leftIdx = 0; for (var i=0; iprevtop) { prevtop = top; this._layoutParams.itemsIndexes.push([]); @@ -1938,15 +1938,15 @@ define([ } var itemW = el.outerWidth() + parseInt(el.css('margin-left')) + parseInt(el.css('margin-right')), - offsetLeft = this.$el.offset().left, - offsetTop = el.offset().top, + offsetLeft = Common.Utils.getOffset(this.$el).left, + offsetTop = Common.Utils.getOffset(el).top, prevtop = -1, topIdx = 0, leftIdx = first; for (var i=0; i prevtop) { prevtop = top; this._layoutParams.itemsIndexes.push([]); diff --git a/apps/common/main/lib/component/HSBColorPicker.js b/apps/common/main/lib/component/HSBColorPicker.js index 8a8b82b6e6..a61bbbe211 100644 --- a/apps/common/main/lib/component/HSBColorPicker.js +++ b/apps/common/main/lib/component/HSBColorPicker.js @@ -136,8 +136,8 @@ define([ var onSBAreaMouseMove = function(event, element, eOpts){ if (arrowSatBrightness.length>0 && areaSatBrightness.length>0) { var pos = [ - Math.max(0, Math.min(100, (parseInt((event.pageX*Common.Utils.zoom() - areaSatBrightness.offset().left) / areaSatBrightness.width() * 100)))), - Math.max(0, Math.min(100, (parseInt((event.pageY*Common.Utils.zoom() - areaSatBrightness.offset().top) / areaSatBrightness.height() * 100)))) + Math.max(0, Math.min(100, (parseInt((event.pageX*Common.Utils.zoom() - Common.Utils.getOffset(areaSatBrightness).left) / areaSatBrightness.width() * 100)))), + Math.max(0, Math.min(100, (parseInt((event.pageY*Common.Utils.zoom() - Common.Utils.getOffset(areaSatBrightness).top) / areaSatBrightness.height() * 100)))) ]; arrowSatBrightness.css('left', pos[0] + '%'); @@ -156,7 +156,7 @@ define([ var onHueAreaMouseMove = function(event, element, eOpts){ if (arrowHue&& areaHue) { - var pos = Math.max(0, Math.min(100, (parseInt((event.pageY*Common.Utils.zoom() - areaHue.offset().top) / areaHue.height() * 100)))); + var pos = Math.max(0, Math.min(100, (parseInt((event.pageY*Common.Utils.zoom() - Common.Utils.getOffset(areaHue).top) / areaHue.height() * 100)))); arrowHue.css('top', pos + '%'); hueVal = parseInt(360 * pos / 100.0); diff --git a/apps/common/main/lib/component/ListView.js b/apps/common/main/lib/component/ListView.js index c99ef78480..035cc01d68 100644 --- a/apps/common/main/lib/component/ListView.js +++ b/apps/common/main/lib/component/ListView.js @@ -297,7 +297,7 @@ define([ var div_top = div.position().top, div_height = div.outerHeight(), div_first = this.dataViewItems[0].el, - div_first_top = div_first ? div_first.offsetTop : 0, + div_first_top = div_first ? Common.Utils.getOffsetTop(div_first) : 0, newpos; if (force || div_top _right_bound_)) return false; @@ -539,7 +539,7 @@ define([ me.$boxpanels.width() - $active.outerWidth() + item.el.width()); } item.el.css('width', checkedwidth ? (checkedwidth + parseFloat(item.el.css('padding-left')) + parseFloat(item.el.css('padding-right'))) + 'px' : item.width); - data.rightedge = $active.get(0).getBoundingClientRect().right; + data.rightedge = Common.Utils.getBoundingClientRect($active.get(0)).right; } } } @@ -763,7 +763,7 @@ define([ if (_rightedge <= _maxright) // stop moving items break; - var rect = item.get(0).getBoundingClientRect(), + var rect = Common.Utils.getBoundingClientRect(item.get(0)), item_width = item.outerWidth(), children = item.children(); if (!item.attr('inner-width') && item.attr('group-state') !== 'open') { @@ -794,7 +794,7 @@ define([ hideAllMenus = true; break; } else { - var child_rect = child.get(0).getBoundingClientRect(), + var child_rect = Common.Utils.getBoundingClientRect(child.get(0)), child_width = child.outerWidth(); if ((Common.UI.isRTL() ? box_controls_width - child_rect.right : child_rect.left)+child_width>_maxright) { if (!last_group) { @@ -973,9 +973,9 @@ define([ onMoreShow: function(btn, e) { var moreContainer = btn.panel.parent(), - parentxy = moreContainer.parent().offset(), + parentxy = Common.Utils.getOffset(moreContainer.parent()), target = btn.$el, - showxy = target.offset(), + showxy = Common.Utils.getOffset(target), right = Common.Utils.innerWidth() - (showxy.left - parentxy.left + target.width()), top = showxy.top - parentxy.top + target.height() + 10; diff --git a/apps/common/main/lib/component/Slider.js b/apps/common/main/lib/component/Slider.js index 15fdf38961..36fa7e85a2 100644 --- a/apps/common/main/lib/component/Slider.js +++ b/apps/common/main/lib/component/Slider.js @@ -142,7 +142,7 @@ define([ e.stopPropagation(); var pos = Math.max(0, Math.min(100, (Math.round(( - me.direction === 'vertical' ? (e.pageY*Common.Utils.zoom() - me.cmpEl.offset().top) : (e.pageX*Common.Utils.zoom() - me.cmpEl.offset().left) - me._dragstart + me.direction === 'vertical' ? (e.pageY*Common.Utils.zoom() - Common.Utils.getOffset(me.cmpEl).top) : (e.pageX*Common.Utils.zoom() - Common.Utils.getOffset(me.cmpEl).left) - me._dragstart ) / me.width * 100)))); me.setThumbPosition(pos); @@ -165,7 +165,7 @@ define([ e.stopPropagation(); var pos = Math.max(0, Math.min(100, (Math.round(( - me.direction === 'vertical' ? (e.pageY*Common.Utils.zoom() - me.cmpEl.offset().top) : (e.pageX*Common.Utils.zoom() - me.cmpEl.offset().left) - me._dragstart + me.direction === 'vertical' ? (e.pageY*Common.Utils.zoom() - Common.Utils.getOffset(me.cmpEl).top) : (e.pageX*Common.Utils.zoom() - Common.Utils.getOffset(me.cmpEl).left) - me._dragstart ) / me.width * 100)))); me.setThumbPosition(pos); @@ -178,7 +178,7 @@ define([ var onMouseDown = function (e) { if ( me.disabled ) return; - me._dragstart = me.direction === 'vertical' ? (e.pageY*Common.Utils.zoom() - me.thumb.offset().top) : (e.pageX*Common.Utils.zoom() - me.thumb.offset().left) - 6; + me._dragstart = me.direction === 'vertical' ? (e.pageY*Common.Utils.zoom() - Common.Utils.getOffset(me.thumb).top) : (e.pageX*Common.Utils.zoom() - Common.Utils.getOffset(me.thumb).left) - 6; me.thumb.addClass('active'); $(document).on('mouseup', onMouseUp); @@ -192,7 +192,7 @@ define([ if ( me.disabled ) return; var pos = Math.max(0, Math.min(100, (Math.round(( - me.direction === 'vertical' ? (e.pageY*Common.Utils.zoom() - me.cmpEl.offset().top) : (e.pageX*Common.Utils.zoom() - me.cmpEl.offset().left) + me.direction === 'vertical' ? (e.pageY*Common.Utils.zoom() - Common.Utils.getOffset(me.cmpEl).top) : (e.pageX*Common.Utils.zoom() - Common.Utils.getOffset(me.cmpEl).left) ) / me.width * 100)))); me.setThumbPosition(pos); @@ -349,7 +349,7 @@ define([ var n = me.minValue; var getX = function (position) { - return (0.01 * me.width * position + me.cmpEl.offset().left + me._dragstart)/Common.Utils.zoom(); + return (0.01 * me.width * position + Common.Utils.getOffset(me.cmpEl).left + me._dragstart)/Common.Utils.zoom(); }; me.centers = []; @@ -381,7 +381,7 @@ define([ lastValue = me.thumbs[index].value, minValue = (index-1<0) ? 0 : me.thumbs[index-1].position, maxValue = (index+1 maxValue, pos = Math.max(0, Math.min(100, position)), value = pos/me.delta + me.minValue; @@ -420,7 +420,7 @@ define([ lastValue = me.thumbs[index].value, minValue = (index-1<0) ? 0 : me.thumbs[index-1].position, maxValue = (index+1 maxValue, pos = Math.max(0, Math.min(100, position)), value = pos/me.delta + me.minValue; @@ -431,7 +431,7 @@ define([ if (need_sort) me.sortThumbs(); - var positionY = e.pageY*Common.Utils.zoom() - me.cmpEl.offset().top; + var positionY = e.pageY*Common.Utils.zoom() - Common.Utils.getOffset(me.cmpEl).top; me.isRemoveThumb = positionY > me.cmpEl.height() || positionY < 0; me.setRemoveThumb(index, me.isRemoveThumb); @@ -445,7 +445,7 @@ define([ var index = e.data.index, thumb = me.thumbs[index].thumb; - me._dragstart = e.pageX*Common.Utils.zoom() - thumb.offset().left - 6.5; + me._dragstart = e.pageX*Common.Utils.zoom() - Common.Utils.getOffset(thumb).left - 6.5; setCenters(index); me.setActiveThumb(index); @@ -461,7 +461,7 @@ define([ var onTrackMouseUp = function (e) { if ( me.disabled || !_.isUndefined(me._dragstart) || me.thumbs.length > 9) return; - var pos = Math.max(0, Math.min(100, (Math.round((e.pageX*Common.Utils.zoom() - me.cmpEl.offset().left) / me.width * 100)))), + var pos = Math.max(0, Math.min(100, (Math.round((e.pageX*Common.Utils.zoom() - Common.Utils.getOffset(me.cmpEl).left) / me.width * 100)))), nearIndex = findThumb(pos), thumbColor = me.thumbs[nearIndex].colorValue, thumbValue = me.thumbs[nearIndex].value, @@ -479,7 +479,7 @@ define([ /*var onTrackMouseDown = function (e) { if ( me.disabled ) return; - var pos = Math.max(0, Math.min(100, (Math.round((e.pageX*Common.Utils.zoom() - me.cmpEl.offset().left) / me.width * 100)))), + var pos = Math.max(0, Math.min(100, (Math.round((e.pageX*Common.Utils.zoom() - Common.Utils.getOffset(me.cmpEl).left) / me.width * 100)))), index = findThumb(pos), lastValue = me.thumbs[index].value, value = pos/me.delta + me.minValue; diff --git a/apps/common/main/lib/component/SynchronizeTip.js b/apps/common/main/lib/component/SynchronizeTip.js index 8d81149bca..b20db3ad5d 100644 --- a/apps/common/main/lib/component/SynchronizeTip.js +++ b/apps/common/main/lib/component/SynchronizeTip.js @@ -132,7 +132,7 @@ define([ applyPlacement: function () { var target = this.target && this.target.length>0 ? this.target : $(document.body); - var showxy = target.offset(); + var showxy = Common.Utils.getOffset(target); if (this.placement=='target' && !this.position) { this.cmpEl.css({top : showxy.top + 5 + 'px', left: showxy.left + 5 + 'px'}); return; diff --git a/apps/common/main/lib/component/TabBar.js b/apps/common/main/lib/component/TabBar.js index 08b45af781..544cd398f4 100644 --- a/apps/common/main/lib/component/TabBar.js +++ b/apps/common/main/lib/component/TabBar.js @@ -100,7 +100,7 @@ define([ calculateBounds: function () { var me = this, length = me.bar.tabs.length, - barBounds = me.bar.$bar.get(0).getBoundingClientRect(); + barBounds = Common.Utils.getBoundingClientRect(me.bar.$bar.get(0)); me.leftBorder = barBounds.left; me.rightBorder = barBounds.right; @@ -110,7 +110,7 @@ define([ me.bar.scrollX = this.scrollLeft; for (var i = 0; i < length; ++i) { - this.bounds.push(me.bar.tabs[i].$el.get(0).getBoundingClientRect()); + this.bounds.push(Common.Utils.getBoundingClientRect(me.bar.tabs[i].$el.get(0))); } me.lastTabRight = me.bounds[length - 1].right; @@ -576,7 +576,7 @@ define([ }, hasInvisible: function() { - var _left_bound_ = this.$bar.offset().left, + var _left_bound_ = Common.Utils.getOffset(this.$bar).left, _right_bound_ = _left_bound_ + this.$bar.width(); for (var i = this.tabs.length; i-- > 0; ) { @@ -589,13 +589,13 @@ define([ }, isTabVisible: function(index) { - var leftbound = arguments[1] || this.$bar.offset().left, + var leftbound = arguments[1] || Common.Utils.getOffset(this.$bar).left, rightbound = arguments[2] || (leftbound + this.$bar.width()), left, right, tab, rect; if (index < this.tabs.length && index >= 0) { tab = this.tabs[index].$el; - rect = tab.get(0).getBoundingClientRect(); + rect = Common.Utils.getBoundingClientRect(tab.get(0)); left = rect.left; right = rect.right; diff --git a/apps/common/main/lib/component/ThemeColorPalette.js b/apps/common/main/lib/component/ThemeColorPalette.js index ee4c13f802..531e7c372a 100644 --- a/apps/common/main/lib/component/ThemeColorPalette.js +++ b/apps/common/main/lib/component/ThemeColorPalette.js @@ -674,13 +674,13 @@ define([ var el = $(this.colorItems[0].el), itemW = el.outerWidth() + parseInt(el.css('margin-left')) + parseInt(el.css('margin-right')), - offsetLeft = this.$el.offset().left, - offsetTop = el.offset().top, + offsetLeft = Common.Utils.getOffset(this.$el).left, + offsetTop = Common.Utils.getOffset(el).top, prevtop = -1, topIdx = 0, leftIdx = 0; for (var i=0; iprevtop) { prevtop = top; this._layoutParams.itemsIndexes.push([]); diff --git a/apps/common/main/lib/controller/HintManager.js b/apps/common/main/lib/controller/HintManager.js index d4b6f08021..8a2b531a3c 100644 --- a/apps/common/main/lib/controller/HintManager.js +++ b/apps/common/main/lib/controller/HintManager.js @@ -346,7 +346,7 @@ Common.UI.HintManager = new(function() { var docH = _isEditDiagram ? (window.parent.innerHeight * Common.Utils.zoom()) : (Common.Utils.innerHeight() - 20), docW = _isEditDiagram ? (window.parent.innerWidth * Common.Utils.zoom()) : (Common.Utils.innerWidth()), section = _isEditDiagram ? _currentSection[0] : _currentSection, - topSection = _currentLevel !== 0 && $(section).length > 0 && !_isEditDiagram ? $(section).offset().top : 0, + topSection = _currentLevel !== 0 && $(section).length > 0 && !_isEditDiagram ? Common.Utils.getOffset($(section)).top : 0, bottomSection = _currentLevel !== 0 && $(section).length > 0 && !_isEditDiagram ? topSection + $(section).height() : docH; if ($(section).prop('id') === 'toolbar' && $(section).outerHeight() < $(section).find('.box-controls').outerHeight()) { bottomSection += $(section).find('.box-controls').outerHeight(); @@ -364,13 +364,13 @@ Common.UI.HintManager = new(function() { } if (window.SSE && item.parent().prop('id') === 'statusbar_bottom') { var $statusbar = item.parent(); - if (item.offset().left > $statusbar.offset().left + $statusbar.width()) { + if (Common.Utils.getOffset(item).left > Common.Utils.getOffset($statusbar).left + $statusbar.width()) { return; } } if (_currentLevel === 0 && item.closest('.tabs.short').length > 0) { var blockTabs = item.closest('.tabs.short'); - leftBorder = blockTabs.offset().left; + leftBorder = Common.Utils.getOffset(blockTabs).left; rightBorder = leftBorder + blockTabs.width(); if (!item.hasClass('scroll')) { leftBorder += 20; @@ -416,7 +416,7 @@ Common.UI.HintManager = new(function() { } else { offsets = offsets ? item.attr('data-hint-offset').split(',').map(function (item) { return parseInt(item); }) : [0, 0]; } - var offset = item.offset(); + var offset = Common.Utils.getOffset(item); var top, left; if (direction === 'left-top') { top = offset.top - 10 + offsets[0]; diff --git a/apps/common/main/lib/controller/ReviewChanges.js b/apps/common/main/lib/controller/ReviewChanges.js index 6a8a671641..2f99eab6cd 100644 --- a/apps/common/main/lib/controller/ReviewChanges.js +++ b/apps/common/main/lib/controller/ReviewChanges.js @@ -972,7 +972,7 @@ define([ docProtection : me._state.docProtection })); var sdk = $('#editor_sdk'), - offset = sdk.offset(); + offset = Common.Utils.getOffset(sdk); me.dlgChanges.show(Math.max(10, offset.left + sdk.width() - 300), Math.max(10, offset.top + sdk.height() - 150)); } } else if (config.canViewReview) { diff --git a/apps/common/main/lib/mods/perfect-scrollbar.js b/apps/common/main/lib/mods/perfect-scrollbar.js index e81b30fdc6..00bd881806 100644 --- a/apps/common/main/lib/mods/perfect-scrollbar.js +++ b/apps/common/main/lib/mods/perfect-scrollbar.js @@ -247,7 +247,7 @@ $scrollbarYRail.addClass('in-scrolling'); var margin = parseInt($scrollbarYRail.css('margin-top')); - var rect = $scrollbarYRail[0].getBoundingClientRect(); + var rect = Common.Utils.getBoundingClientRect($scrollbarYRail[0]); $scrollbarYRail.css({ position: 'fixed', left: rect.left, diff --git a/apps/common/main/lib/util/utils.js b/apps/common/main/lib/util/utils.js index dd1de0012e..03195792cb 100644 --- a/apps/common/main/lib/util/utils.js +++ b/apps/common/main/lib/util/utils.js @@ -206,7 +206,53 @@ var utils = new(function() { checkSizeIE = function() { me.innerWidth = window.innerWidth; me.innerHeight = window.innerHeight; + }, + isOffsetUsedZoom = function() { + if (isChrome && 128 <= chromeVersion) + return (me.zoom === 1) ? false : true; + return false; + }, + getBoundingClientRect = function(element) { + let rect = element.getBoundingClientRect(); + if (!isOffsetUsedZoom()) + return rect; + + let koef = me.zoom; + let newRect = {} + if (rect.x!==undefined) newRect.x = rect.x * koef; + if (rect.y!==undefined) newRect.y = rect.y * koef; + if (rect.width!==undefined) newRect.width = rect.width * koef; + if (rect.height!==undefined) newRect.height = rect.height * koef; + + if (rect.left!==undefined) newRect.left = rect.left * koef; + if (rect.top!==undefined) newRect.top = rect.top * koef; + if (rect.right!==undefined) newRect.right = rect.right * koef; + if (rect.bottom!==undefined) newRect.bottom = rect.bottom * koef; + return newRect; + }, + getOffsetLeft = function(element) { + if (!isOffsetUsedZoom()) + return element.offsetLeft; + return element.offsetLeft * me.zoom; + }, + getOffsetTop = function(element) { + if (!isOffsetUsedZoom()) + return element.offsetTop; + return element.offsetTop * me.zoom; + }, + getOffset = function($element) { + let pos = $element.offset(); + if (!isOffsetUsedZoom()) + return pos; + return {left: pos.left * me.zoom, top: pos.top * me.zoom}; + }, + getPosition = function($element) { + let pos = $element.position(); + if (!isOffsetUsedZoom()) + return pos; + return {left: pos.left * me.zoom, top: pos.top * me.zoom}; }; + me.zoom = 1; me.applicationPixelRatio = 1; me.innerWidth = window.innerWidth; @@ -289,7 +335,12 @@ var utils = new(function() { innerWidth: function() {return me.innerWidth;}, innerHeight: function() {return me.innerHeight;}, croppedGeometry: function() {return {left:0, top: Common.Utils.InternalSettings.get('window-inactive-area-top'), - width: me.innerWidth, height: me.innerHeight - Common.Utils.InternalSettings.get('window-inactive-area-top')}} + width: me.innerWidth, height: me.innerHeight - Common.Utils.InternalSettings.get('window-inactive-area-top')}}, + getBoundingClientRect: getBoundingClientRect, + getOffsetLeft: getOffsetLeft, + getOffsetTop: getOffsetTop, + getOffset: getOffset, + getPosition: getPosition } })(); diff --git a/apps/documenteditor/main/app/controller/DocumentHolder.js b/apps/documenteditor/main/app/controller/DocumentHolder.js index 7409ba72ed..19cfef2ef6 100644 --- a/apps/documenteditor/main/app/controller/DocumentHolder.js +++ b/apps/documenteditor/main/app/controller/DocumentHolder.js @@ -780,8 +780,8 @@ define([ onDocumentHolderResize: function(e){ var me = this; me._XY = [ - me.documentHolder.cmpEl.offset().left - $(window).scrollLeft(), - me.documentHolder.cmpEl.offset().top - $(window).scrollTop() + Common.Utils.getOffset(me.documentHolder.cmpEl).left - $(window).scrollLeft(), + Common.Utils.getOffset(me.documentHolder.cmpEl).top - $(window).scrollTop() ]; me._Height = me.documentHolder.cmpEl.height(); me._Width = me.documentHolder.cmpEl.width(); @@ -1072,8 +1072,8 @@ define([ screenTip = me.screenTip; if (me._XY === undefined) { me._XY = [ - cmpEl.offset().left - $(window).scrollLeft(), - cmpEl.offset().top - $(window).scrollTop() + Common.Utils.getOffset(cmpEl).left - $(window).scrollLeft(), + Common.Utils.getOffset(cmpEl).top - $(window).scrollTop() ]; me._Height = cmpEl.height(); me._Width = cmpEl.width(); @@ -1557,7 +1557,7 @@ define([ this.cmpCalendar.setDate(val ? new Date(val) : new Date()); // align - var offset = controlsContainer.offset(), + var offset = Common.Utils.getOffset(controlsContainer), docW = Common.Utils.innerWidth(), docH = Common.Utils.innerHeight() - 10, // Yep, it's magic number menuW = this.cmpCalendar.cmpEl.outerWidth(), @@ -1796,8 +1796,8 @@ define([ var me = this, cmpEl = me.documentHolder.cmpEl; me._XY = [ - cmpEl.offset().left - $(window).scrollLeft(), - cmpEl.offset().top - $(window).scrollTop() + Common.Utils.getOffset(cmpEl).left - $(window).scrollLeft(), + Common.Utils.getOffset(cmpEl).top - $(window).scrollTop() ]; me._Height = cmpEl.height(); me._Width = cmpEl.width(); @@ -2657,8 +2657,8 @@ define([ if (me._XY === undefined) { me._XY = [ - documentHolder.cmpEl.offset().left - $(window).scrollLeft(), - documentHolder.cmpEl.offset().top - $(window).scrollTop() + Common.Utils.getOffset(documentHolder.cmpEl).left - $(window).scrollLeft(), + Common.Utils.getOffset(documentHolder.cmpEl).top - $(window).scrollTop() ]; me._Height = documentHolder.cmpEl.height(); me._Width = documentHolder.cmpEl.width(); diff --git a/apps/documenteditor/main/app/controller/Navigation.js b/apps/documenteditor/main/app/controller/Navigation.js index 14be80b3e9..ff19962c18 100644 --- a/apps/documenteditor/main/app/controller/Navigation.js +++ b/apps/documenteditor/main/app/controller/Navigation.js @@ -239,7 +239,7 @@ define([ menu.hide(); } - var parentOffset = this.panelNavigation.$el.offset(), + var parentOffset = Common.Utils.getOffset(this.panelNavigation.$el), top = e.clientY*Common.Utils.zoom(); showPoint = [e.clientX*Common.Utils.zoom() + 5, top - parentOffset.top + 5]; diff --git a/apps/documenteditor/main/app/controller/Toolbar.js b/apps/documenteditor/main/app/controller/Toolbar.js index aef293fb10..a81188288e 100644 --- a/apps/documenteditor/main/app/controller/Toolbar.js +++ b/apps/documenteditor/main/app/controller/Toolbar.js @@ -2638,7 +2638,7 @@ define([ menu.items[3].setDisabled(isAllDefailtNotModifaed); menu.items[4].setDisabled(isAllCustomDeleted); - var parentOffset = this.toolbar.$el.offset(), + var parentOffset = Common.Utils.getOffset(this.toolbar.$el), top = e.clientY*Common.Utils.zoom(); if ($('#header-container').is(":visible")) { top -= $('#header-container').height() diff --git a/apps/documenteditor/main/app/view/ShapeSettings.js b/apps/documenteditor/main/app/view/ShapeSettings.js index 8c80b06e80..93204a2dd3 100644 --- a/apps/documenteditor/main/app/view/ShapeSettings.js +++ b/apps/documenteditor/main/app/view/ShapeSettings.js @@ -1850,7 +1850,7 @@ define([ items: [], restoreHeightAndTop: true, additionalAlign: function(menuRoot, left, top) { - menuRoot.css({left: left, top: Math.max($(me.el).parent().offset().top, Common.Utils.innerHeight() - 10 - me.shapeRestoreHeight) - parseInt(menuRoot.css('margin-top'))}); + menuRoot.css({left: left, top: Math.max(Common.Utils.getOffset($(me.el).parent()).top, Common.Utils.innerHeight() - 10 - me.shapeRestoreHeight) - parseInt(menuRoot.css('margin-top'))}); } })} ] diff --git a/apps/documenteditor/main/app/view/Toolbar.js b/apps/documenteditor/main/app/view/Toolbar.js index 5c98eb7a30..637c5d706c 100644 --- a/apps/documenteditor/main/app/view/Toolbar.js +++ b/apps/documenteditor/main/app/view/Toolbar.js @@ -1679,7 +1679,7 @@ define([ menu.menuAlign = 'tl-tl'; var menuWidth = columnCount * (itemMargin + _width), - buttonOffsetLeft = cmp.openButton.$el.offset().left; + buttonOffsetLeft = Common.Utils.getOffset(cmp.openButton.$el).left; // if (menuWidth>buttonOffsetLeft) // menuWidth = Math.max(Math.floor(buttonOffsetLeft/(itemMargin + _width)), 2) * (itemMargin + _width); if (menuWidth>Common.Utils.innerWidth()) diff --git a/apps/pdfeditor/main/app/controller/DocumentHolder.js b/apps/pdfeditor/main/app/controller/DocumentHolder.js index 33e47b9e7a..50b8c95cfb 100644 --- a/apps/pdfeditor/main/app/controller/DocumentHolder.js +++ b/apps/pdfeditor/main/app/controller/DocumentHolder.js @@ -652,8 +652,8 @@ define([ onDocumentHolderResize: function(e){ var me = this; me._XY = [ - me.documentHolder.cmpEl.offset().left - $(window).scrollLeft(), - me.documentHolder.cmpEl.offset().top - $(window).scrollTop() + Common.Utils.getOffset(me.documentHolder.cmpEl).left - $(window).scrollLeft(), + Common.Utils.getOffset(me.documentHolder.cmpEl).top - $(window).scrollTop() ]; me._Height = me.documentHolder.cmpEl.height(); me._Width = me.documentHolder.cmpEl.width(); @@ -948,8 +948,8 @@ define([ screenTip = me.screenTip; if (me._XY === undefined) { me._XY = [ - cmpEl.offset().left - $(window).scrollLeft(), - cmpEl.offset().top - $(window).scrollTop() + Common.Utils.getOffset(cmpEl).left - $(window).scrollLeft(), + Common.Utils.getOffset(cmpEl).top - $(window).scrollTop() ]; me._Height = cmpEl.height(); me._Width = cmpEl.width(); @@ -1117,8 +1117,8 @@ define([ var me = this, cmpEl = me.documentHolder.cmpEl; me._XY = [ - cmpEl.offset().left - $(window).scrollLeft(), - cmpEl.offset().top - $(window).scrollTop() + Common.Utils.getOffset(cmpEl).left - $(window).scrollLeft(), + Common.Utils.getOffset(cmpEl).top - $(window).scrollTop() ]; me._Height = cmpEl.height(); me._Width = cmpEl.width(); @@ -1374,7 +1374,7 @@ define([ this.cmpCalendarPdf.setDate(val); // align - var offset = controlsContainer.offset(), + var offset = Common.Utils.getOffset(controlsContainer), docW = Common.Utils.innerWidth(), docH = Common.Utils.innerHeight() - 10, // Yep, it's magic number menuW = this.cmpCalendarPdf.cmpEl.outerWidth(), @@ -1680,7 +1680,7 @@ define([ this.cmpCalendar.setDate(val ? new Date(val) : new Date()); // align - var offset = controlsContainer.offset(), + var offset = Common.Utils.getOffset(controlsContainer), docW = Common.Utils.innerWidth(), docH = Common.Utils.innerHeight() - 10, // Yep, it's magic number menuW = this.cmpCalendar.cmpEl.outerWidth(), @@ -1816,8 +1816,8 @@ define([ if (_.isUndefined(me._XY)) { me._XY = [ - documentHolder.cmpEl.offset().left - $(window).scrollLeft(), - documentHolder.cmpEl.offset().top - $(window).scrollTop() + Common.Utils.getOffset(documentHolder.cmpEl).left - $(window).scrollLeft(), + Common.Utils.getOffset(documentHolder.cmpEl).top - $(window).scrollTop() ]; me._Width = documentHolder.cmpEl.width(); me._Height = documentHolder.cmpEl.height(); @@ -2411,8 +2411,8 @@ define([ if (_.isUndefined(this._XY)) { this._XY = [ - this.documentHolder.cmpEl.offset().left - $(window).scrollLeft(), - this.documentHolder.cmpEl.offset().top - $(window).scrollTop() + Common.Utils.getOffset(this.documentHolder.cmpEl).left - $(window).scrollLeft(), + Common.Utils.getOffset(this.documentHolder.cmpEl).top - $(window).scrollTop() ]; this._Width = this.documentHolder.cmpEl.width(); this._Height = this.documentHolder.cmpEl.height(); @@ -2804,8 +2804,8 @@ define([ if (_.isUndefined(this._XY)) { this._XY = [ - this.documentHolder.cmpEl.offset().left - $(window).scrollLeft(), - this.documentHolder.cmpEl.offset().top - $(window).scrollTop() + Common.Utils.getOffset(this.documentHolder.cmpEl).left - $(window).scrollLeft(), + Common.Utils.getOffset(this.documentHolder.cmpEl).top - $(window).scrollTop() ]; this._Width = this.documentHolder.cmpEl.width(); this._Height = this.documentHolder.cmpEl.height(); diff --git a/apps/pdfeditor/main/app/controller/Navigation.js b/apps/pdfeditor/main/app/controller/Navigation.js index c03fd92176..18cad8e221 100644 --- a/apps/pdfeditor/main/app/controller/Navigation.js +++ b/apps/pdfeditor/main/app/controller/Navigation.js @@ -113,7 +113,7 @@ define([ menu.hide(); } - var parentOffset = this.panelNavigation.$el.offset(), + var parentOffset = Common.Utils.getOffset(this.panelNavigation.$el), top = e.clientY*Common.Utils.zoom(); showPoint = [e.clientX*Common.Utils.zoom() + 5, top - parentOffset.top + 5]; diff --git a/apps/pdfeditor/main/app/view/ShapeSettings.js b/apps/pdfeditor/main/app/view/ShapeSettings.js index 7faf58e778..26ef22d68e 100644 --- a/apps/pdfeditor/main/app/view/ShapeSettings.js +++ b/apps/pdfeditor/main/app/view/ShapeSettings.js @@ -1712,7 +1712,7 @@ define([ items: [], restoreHeightAndTop: true, additionalAlign: function(menuRoot, left, top) { - menuRoot.css({left: left, top: Math.max($(me.el).parent().offset().top, Common.Utils.innerHeight() - 10 - me.shapeRestoreHeight) - parseInt(menuRoot.css('margin-top'))}); + menuRoot.css({left: left, top: Math.max(Common.Utils.getOffset($(me.el).parent()).top, Common.Utils.innerHeight() - 10 - me.shapeRestoreHeight) - parseInt(menuRoot.css('margin-top'))}); } })} ] diff --git a/apps/presentationeditor/main/app/controller/DocumentHolder.js b/apps/presentationeditor/main/app/controller/DocumentHolder.js index 6e4f657068..4c8c81f119 100644 --- a/apps/presentationeditor/main/app/controller/DocumentHolder.js +++ b/apps/presentationeditor/main/app/controller/DocumentHolder.js @@ -502,7 +502,7 @@ define([ showPoint[0] += event.get_ButtonWidth() + 2; showPoint[1] += event.get_ButtonHeight() + 2; menu.menuAlign = 'tr-br'; - if (me.documentHolder.cmpEl.offset().top + showPoint[1] + menu.menuRoot.outerHeight() > Common.Utils.innerHeight() - 10) { + if (Common.Utils.getOffset(me.documentHolder.cmpEl).top + showPoint[1] + menu.menuRoot.outerHeight() > Common.Utils.innerHeight() - 10) { showPoint[1] -= event.get_ButtonHeight() + 4; menu.menuAlign = 'br-tr'; } @@ -918,8 +918,8 @@ define([ screenTip = me.screenTip; if (_.isUndefined(me._XY)) { me._XY = [ - cmpEl.offset().left - $(window).scrollLeft(), - cmpEl.offset().top - $(window).scrollTop() + Common.Utils.getOffset(cmpEl).left - $(window).scrollLeft(), + Common.Utils.getOffset(cmpEl).top - $(window).scrollTop() ]; me._Width = cmpEl.width(); me._Height = cmpEl.height(); @@ -1221,8 +1221,8 @@ define([ var me = this; if (_.isUndefined(me._XY)) { me._XY = [ - me.documentHolder.cmpEl.offset().left - $(window).scrollLeft(), - me.documentHolder.cmpEl.offset().top - $(window).scrollTop() + Common.Utils.getOffset(me.documentHolder.cmpEl).left - $(window).scrollLeft(), + Common.Utils.getOffset(me.documentHolder.cmpEl).top - $(window).scrollTop() ]; me._Width = me.documentHolder.cmpEl.width(); me._Height = me.documentHolder.cmpEl.height(); @@ -1339,8 +1339,8 @@ define([ var me = this, cmpEl = me.documentHolder.cmpEl; me._XY = [ - cmpEl.offset().left - $(window).scrollLeft(), - cmpEl.offset().top - $(window).scrollTop() + Common.Utils.getOffset(cmpEl).left - $(window).scrollLeft(), + Common.Utils.getOffset(cmpEl).top - $(window).scrollTop() ]; me.onMouseMoveStart(); }, @@ -2527,8 +2527,8 @@ define([ } else { if (_.isUndefined(this._XY)) { this._XY = [ - this.documentHolder.cmpEl.offset().left - $(window).scrollLeft(), - this.documentHolder.cmpEl.offset().top - $(window).scrollTop() + Common.Utils.getOffset(this.documentHolder.cmpEl).left - $(window).scrollLeft(), + Common.Utils.getOffset(this.documentHolder.cmpEl).top - $(window).scrollTop() ]; this._Width = this.documentHolder.cmpEl.width(); this._Height = this.documentHolder.cmpEl.height(); @@ -2690,8 +2690,8 @@ define([ if (_.isUndefined(me._XY)) { me._XY = [ - documentHolder.cmpEl.offset().left - $(window).scrollLeft(), - documentHolder.cmpEl.offset().top - $(window).scrollTop() + Common.Utils.getOffset(documentHolder.cmpEl).left - $(window).scrollLeft(), + Common.Utils.getOffset(documentHolder.cmpEl).top - $(window).scrollTop() ]; me._Width = documentHolder.cmpEl.width(); me._Height = documentHolder.cmpEl.height(); diff --git a/apps/presentationeditor/main/app/view/ShapeSettings.js b/apps/presentationeditor/main/app/view/ShapeSettings.js index a54e7f6c56..b8fa1a7f42 100644 --- a/apps/presentationeditor/main/app/view/ShapeSettings.js +++ b/apps/presentationeditor/main/app/view/ShapeSettings.js @@ -1712,7 +1712,7 @@ define([ items: [], restoreHeightAndTop: true, additionalAlign: function(menuRoot, left, top) { - menuRoot.css({left: left, top: Math.max($(me.el).parent().offset().top, Common.Utils.innerHeight() - 10 - me.shapeRestoreHeight) - parseInt(menuRoot.css('margin-top'))}); + menuRoot.css({left: left, top: Math.max(Common.Utils.getOffset($(me.el).parent()).top, Common.Utils.innerHeight() - 10 - me.shapeRestoreHeight) - parseInt(menuRoot.css('margin-top'))}); } })} ] diff --git a/apps/presentationeditor/main/app/view/Toolbar.js b/apps/presentationeditor/main/app/view/Toolbar.js index 8f2247c626..2f03c39ba0 100644 --- a/apps/presentationeditor/main/app/view/Toolbar.js +++ b/apps/presentationeditor/main/app/view/Toolbar.js @@ -1172,7 +1172,7 @@ define([ menu.menuAlign = 'tl-tl'; var menuWidth = columnCount * (itemMargin + itemWidth), - buttonOffsetLeft = cmp.openButton.$el.offset().left; + buttonOffsetLeft = Common.Utils.getOffset(cmp.openButton.$el).left; // if (menuWidth>buttonOffsetLeft) // menuWidth = Math.max(Math.floor(buttonOffsetLeft/(itemMargin + itemWidth)), 2) * (itemMargin + itemWidth); if (menuWidth>Common.Utils.innerWidth()) diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index 561d9e7abd..971fcf09f6 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -1674,8 +1674,8 @@ define([ eyedropperTip = me.tooltips.eyedropper, placeholderTip = me.tooltips.placeholder, pos = [ - me.documentHolder.cmpEl.offset().left - $(window).scrollLeft(), - me.documentHolder.cmpEl.offset().top - $(window).scrollTop() + Common.Utils.getOffset(me.documentHolder.cmpEl).left - $(window).scrollLeft(), + Common.Utils.getOffset(me.documentHolder.cmpEl).top - $(window).scrollTop() ]; //close all tooltips @@ -2232,7 +2232,7 @@ define([ Common.UI.Menu.Manager.hideAll(); me.dlgFilter.setSettings(config); - var offset = me.documentHolder.cmpEl.offset(), + var offset = Common.Utils.getOffset(me.documentHolder.cmpEl), rect = config.asc_getCellCoord(), x = rect.asc_getX() + rect.asc_getWidth() +offset.left, y = rect.asc_getY() + rect.asc_getHeight() + offset.top; @@ -2364,8 +2364,8 @@ define([ var me = this; if (me.documentHolder) { me.tooltips.coauth.XY = [ - me.documentHolder.cmpEl.offset().left - $(window).scrollLeft(), - me.documentHolder.cmpEl.offset().top - $(window).scrollTop() + Common.Utils.getOffset(me.documentHolder.cmpEl).left - $(window).scrollLeft(), + Common.Utils.getOffset(me.documentHolder.cmpEl).top - $(window).scrollTop() ]; me.tooltips.coauth.apiHeight = me.documentHolder.cmpEl.height(); me.tooltips.coauth.apiWidth = me.documentHolder.cmpEl.width(); @@ -3139,7 +3139,7 @@ define([ var me = this, documentHolderView = me.documentHolder, - showPoint = [event.pageX*Common.Utils.zoom() - documentHolderView.cmpEl.offset().left, event.pageY*Common.Utils.zoom() - documentHolderView.cmpEl.offset().top], + showPoint = [event.pageX*Common.Utils.zoom() - Common.Utils.getOffset(documentHolderView.cmpEl).left, event.pageY*Common.Utils.zoom() - Common.Utils.getOffset(documentHolderView.cmpEl).top], menuContainer = documentHolderView.cmpEl.find(Common.Utils.String.format('#menu-container-{0}', menu.id)); if (!menu.rendered) { @@ -3419,7 +3419,7 @@ define([ li_focused = menuContainer.find('a.focus').closest('li'), innerHeight = innerEl.innerHeight(), padding = (innerHeight - innerEl.height())/2, - pos = li_focused.position().top, + pos = Common.Utils.getPosition(li_focused).top, itemHeight = li_focused.outerHeight(), newpos; if (pos<0) @@ -3539,12 +3539,12 @@ define([ var infocus = this.cellEditor.is(":focus"), showPoint; if (infocus || this.focusInCellEditor) { - var offset = this.cellEditor.offset(); + var offset = Common.Utils.getOffset(this.cellEditor); showPoint = [offset.left, offset.top + this.cellEditor.height() + 3]; } else { var pos = [ - this.documentHolder.cmpEl.offset().left - $(window).scrollLeft(), - this.documentHolder.cmpEl.offset().top - $(window).scrollTop() + Common.Utils.getOffset(this.documentHolder.cmpEl).left - $(window).scrollLeft(), + Common.Utils.getOffset(this.documentHolder.cmpEl).top - $(window).scrollTop() ], coord = this.api.asc_getActiveCellCoord(); showPoint = [coord.asc_getX() + pos[0] - 3, coord.asc_getY() + pos[1] - functip.ref.getBSTip().$tip.height() - 5]; @@ -3569,8 +3569,8 @@ define([ changeInputMessagePosition: function (inputTip) { var pos = [ - this.documentHolder.cmpEl.offset().left - $(window).scrollLeft(), - this.documentHolder.cmpEl.offset().top - $(window).scrollTop() + Common.Utils.getOffset(this.documentHolder.cmpEl).left - $(window).scrollLeft(), + Common.Utils.getOffset(this.documentHolder.cmpEl).top - $(window).scrollTop() ], coord = this.api.asc_getActiveCellCoord(), showPoint = [coord.asc_getX() + pos[0] - 3, coord.asc_getY() + pos[1] - inputTip.ref.getBSTip().$tip.height() - 5]; diff --git a/apps/spreadsheeteditor/main/app/controller/Statusbar.js b/apps/spreadsheeteditor/main/app/controller/Statusbar.js index a819dd023c..aa3dd762e0 100644 --- a/apps/spreadsheeteditor/main/app/controller/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Statusbar.js @@ -542,8 +542,8 @@ define([ } var tab = me.statusbar.tabbar.tabs[me.statusbar.tabbar.getActive()]; - var top = me.statusbar.$el.position().top - 115, - left = tab.$el.offset().left; + var top = Common.Utils.getPosition(me.statusbar.$el).top - 115, + left = Common.Utils.getOffset(tab.$el).left; var current = me.api.asc_getWorksheetName(me.api.asc_getActiveWorksheetIndex()); var win = (new SSE.Views.Statusbar.RenameDialog({ diff --git a/apps/spreadsheeteditor/main/app/view/PivotTable.js b/apps/spreadsheeteditor/main/app/view/PivotTable.js index e842d63abd..ac418da1c7 100644 --- a/apps/spreadsheeteditor/main/app/view/PivotTable.js +++ b/apps/spreadsheeteditor/main/app/view/PivotTable.js @@ -339,7 +339,7 @@ define([ menu.menuAlignEl = cmp.cmpEl; menu.menuAlign = 'tl-tl'; var menuWidth = columnCount * (itemMargin + itemWidth) + 17, // for scroller - buttonOffsetLeft = cmp.openButton.$el.offset().left; + buttonOffsetLeft = Common.Utils.getOffset(cmp.openButton.$el).left; if (menuWidth>Common.Utils.innerWidth()) menuWidth = Math.max(Math.floor((Common.Utils.innerWidth()-17)/(itemMargin + itemWidth)), 2) * (itemMargin + itemWidth) + 17; var offset = cmp.cmpEl.width() - cmp.openButton.$el.width() - Math.min(menuWidth, buttonOffsetLeft) - 1; diff --git a/apps/spreadsheeteditor/main/app/view/ShapeSettings.js b/apps/spreadsheeteditor/main/app/view/ShapeSettings.js index 7ef78c8209..031e0c326a 100644 --- a/apps/spreadsheeteditor/main/app/view/ShapeSettings.js +++ b/apps/spreadsheeteditor/main/app/view/ShapeSettings.js @@ -1728,7 +1728,7 @@ define([ items: [], restoreHeightAndTop: true, additionalAlign: function(menuRoot, left, top) { - menuRoot.css({left: left, top: Math.max($(me.el).parent().offset().top, Common.Utils.innerHeight() - 10 - me.shapeRestoreHeight) - parseInt(menuRoot.css('margin-top'))}); + menuRoot.css({left: left, top: Math.max(Common.Utils.getOffset($(me.el).parent()).top, Common.Utils.innerHeight() - 10 - me.shapeRestoreHeight) - parseInt(menuRoot.css('margin-top'))}); } })} ] diff --git a/apps/spreadsheeteditor/main/app/view/SortDialog.js b/apps/spreadsheeteditor/main/app/view/SortDialog.js index a24184aa6a..4f6cc5c3a7 100644 --- a/apps/spreadsheeteditor/main/app/view/SortDialog.js +++ b/apps/spreadsheeteditor/main/app/view/SortDialog.js @@ -322,7 +322,7 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', cmbEl = this.sortList.cmpEl.find('#sort-dialog-cmb-sort-0'), widthHeaderEl = this.sortList.headerEl.width(), paddingHeaderEl = parseFloat(this.sortList.headerEl.css(isRTL ? 'padding-right' : 'padding-left')), - pos = cmbEl.position(); + pos = Common.Utils.getPosition(cmbEl); if(isRTL) { pos && (firstLabelWidth = widthHeaderEl + paddingHeaderEl - (Math.floor(pos.left) + cmbEl.width())); @@ -333,7 +333,7 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', cmbEl = this.sortList.cmpEl.find('#sort-dialog-btn-color-0'); (!cmbEl[0]) && (cmbEl = this.sortList.cmpEl.find('#sort-dialog-cmb-order-0')); - pos = cmbEl.position(); + pos = Common.Utils.getPosition(cmbEl); if(isRTL) { pos && (secondLabelWidth = (widthHeaderEl + paddingHeaderEl - (Math.floor(pos.left) + cmbEl.width())) - firstLabelWidth); diff --git a/apps/spreadsheeteditor/main/app/view/Statusbar.js b/apps/spreadsheeteditor/main/app/view/Statusbar.js index dc29082da7..893c7dbecc 100644 --- a/apps/spreadsheeteditor/main/app/view/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/view/Statusbar.js @@ -613,9 +613,8 @@ define([ (this.rangeSelectionMode !== Asc.c_oAscSelectionDialogType.PrintTitles) && !this.mode.isDisconnected ) { if (tab && tab.sheetindex >= 0) { - var rect = tab.$el.get(0).getBoundingClientRect(), - childPos = tab.$el.offset(), - parentPos = tab.$el.parent().offset(); + var rect = Common.Utils.getBoundingClientRect(tab.$el.get(0)), + parentPos = Common.Utils.getOffset(tab.$el.parent()); if (!tab.isActive()) this.tabbar.setActive(tab); diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index 75e7cf675a..6e86ca1bd1 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -1442,7 +1442,7 @@ define([ var menuPickerEl = $(menu.menuRoot.find('.menu-picker-container').get(0)), paddings = 15 + parseFloat(groupContainerEl.css('padding-left')) + parseFloat(groupContainerEl.css('padding-right')) + parseFloat(menuPickerEl.css('margin-left')) + parseFloat(menuPickerEl.css('margin-right')), menuWidth = Math.ceil(+ columnCount * (itemWidth + itemMargin) + paddings), - buttonOffsetLeft = cmp.openButton.$el.offset().left; + buttonOffsetLeft = Common.Utils.getOffset(cmp.openButton.$el).left; if (menuWidth>Common.Utils.innerWidth()) menuWidth = Math.max(Math.floor((Common.Utils.innerWidth()-paddings)/(itemMargin + itemWidth)), 2) * (itemMargin + itemWidth) + paddings; var offset = cmp.cmpEl.width() - cmp.openButton.$el.width() - Math.min(menuWidth, buttonOffsetLeft) - 1; From eff23758d1b0f483ed788c9d8dca7371d4d6ee28 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 2 Sep 2024 17:55:32 +0300 Subject: [PATCH 2/2] Fix review/comment popover --- apps/common/main/lib/view/Comments.js | 4 ++-- apps/common/main/lib/view/ReviewPopover.js | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/common/main/lib/view/Comments.js b/apps/common/main/lib/view/Comments.js index b61f38bcc7..915e6d8e68 100644 --- a/apps/common/main/lib/view/Comments.js +++ b/apps/common/main/lib/view/Comments.js @@ -163,12 +163,12 @@ define([ autoScrollToEditButtons: function () { var button = $('#id-comments-change'), // TODO: add to cache btnBounds = null, - contentBounds = this.el.getBoundingClientRect(), + contentBounds = Common.Utils.getBoundingClientRect(this.el), moveY = 0, padding = 7; if (button.length) { - btnBounds = button.get(0).getBoundingClientRect(); + btnBounds = Common.Utils.getBoundingClientRect(button.get(0)); if (btnBounds && contentBounds) { moveY = contentBounds.bottom - (btnBounds.bottom + padding); if (moveY < 0) { diff --git a/apps/common/main/lib/view/ReviewPopover.js b/apps/common/main/lib/view/ReviewPopover.js index 0126ccbda8..d4439a52fc 100644 --- a/apps/common/main/lib/view/ReviewPopover.js +++ b/apps/common/main/lib/view/ReviewPopover.js @@ -764,7 +764,7 @@ define([ sdkBoundsTopPos = 0; if (commentsView && arrowView && editorView && editorView.get(0)) { - editorBounds = editorView.get(0).getBoundingClientRect(); + editorBounds = Common.Utils.getBoundingClientRect(editorView.get(0)); if (editorBounds) { sdkBoundsHeight = editorBounds.height - this.sdkBounds.padding * 2; @@ -886,11 +886,11 @@ define([ commentsView.css({height: '100%'}); - contentBounds = commentsView.get(0).getBoundingClientRect(); + contentBounds = Common.Utils.getBoundingClientRect(commentsView.get(0)); if (contentBounds) { editorView = $('#editor_sdk'); if (editorView && editorView.get(0)) { - editorBounds = editorView.get(0).getBoundingClientRect(); + editorBounds = Common.Utils.getBoundingClientRect(editorView.get(0)); if (editorBounds) { sdkBoundsHeight = editorBounds.height - this.sdkBounds.padding * 2; sdkBoundsTopPos = sdkBoundsTop; @@ -1176,12 +1176,12 @@ define([ autoScrollToEditButtons: function () { var button = $('#id-comments-change-popover'), // TODO: add to cache btnBounds = null, - contentBounds = this.$window[0].getBoundingClientRect(), + contentBounds = Common.Utils.getBoundingClientRect(this.$window[0]), moveY = 0, padding = 7; if (button.length) { - btnBounds = button.get(0).getBoundingClientRect(); + btnBounds = Common.Utils.getBoundingClientRect(button.get(0)); if (btnBounds && contentBounds) { moveY = contentBounds.bottom - (btnBounds.bottom + padding); if (moveY < 0) {