Skip to content

Commit

Permalink
Merge pull request 'fix/bug-65477' (#4) from fix/bug-65477 into relea…
Browse files Browse the repository at this point in the history
  • Loading branch information
Julia Radzhabova committed Sep 4, 2024
2 parents 3f5cf04 + cffbf48 commit 3e2fca8
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 26 deletions.
40 changes: 26 additions & 14 deletions apps/common/main/lib/mods/perfect-scrollbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@
scrollbarYTop,
scrollbarYRight = parseInt($scrollbarYRail.css('right'), 10),
scrollbarYRailHeight,
eventClassName = getEventClassName();
eventClassName = getEventClassName(),
canScrollX = false;

var updateContentScrollTop = function (currentTop, deltaY) {
var newTop = currentTop + deltaY,
Expand All @@ -122,9 +123,14 @@
};

var updateContentScrollLeft = function (currentLeft, deltaX) {
var newLeft = currentLeft + deltaX,
maxLeft = scrollbarXRailWidth - scrollbarXWidth;
var maxLeft = scrollbarXRailWidth - scrollbarXWidth;

if (Common.UI.isRTL()) {
currentLeft = maxLeft - currentLeft;
deltaX *= -1;
}

var newLeft = currentLeft + deltaX;
if (newLeft < 0) {
scrollbarXLeft = 0;
}
Expand All @@ -136,8 +142,9 @@
}

var scrollLeft = parseInt(scrollbarXLeft * (contentWidth - containerWidth) / (scrollbarXRailWidth - scrollbarXWidth), 10);
$this.scrollLeft(scrollLeft);
$this.scrollLeft(scrollLeft * (Common.UI.isRTL() ? -1 : 1));
$scrollbarYRail.css({right: scrollbarYRight - scrollLeft});
Common.UI.isRTL() && canScrollX && $scrollbarYRail.css({left: $this.scrollLeft() + 1});
};

var getSettingsAdjustedThumbSize = function (thumbSize) {
Expand All @@ -148,14 +155,16 @@
};

var updateScrollbarCss = function () {
$scrollbarXRail.css({left: $this.scrollLeft(), bottom: scrollbarXBottom - $this.scrollTop(), width: scrollbarXRailWidth, display: scrollbarXActive ? "inherit": "none"});
$scrollbarXRail.css({left: Common.UI.isRTL() ? 'auto' : $this.scrollLeft(), right: !Common.UI.isRTL() ? 'auto' : -$this.scrollLeft(), bottom: scrollbarXBottom - $this.scrollTop(), width: scrollbarXRailWidth, display: scrollbarXActive ? "inherit": "none"});

if ($scrollbarYRail.hasClass('in-scrolling'))
$scrollbarYRail.css({/*top: $this.scrollTop(),*/ right: scrollbarYRight - $this.scrollLeft(), height: scrollbarYRailHeight, display: scrollbarYActive ? "inherit": "none"});
else
$scrollbarYRail.css({top: $this.scrollTop(), right: scrollbarYRight - $this.scrollLeft(), height: scrollbarYRailHeight, display: scrollbarYActive ? "inherit": "none"});
else {
$scrollbarYRail.css({top: $this.scrollTop(), right: scrollbarYRight - $this.scrollLeft(), height: scrollbarYRailHeight, display: scrollbarYActive ? "inherit": "none"});
Common.UI.isRTL() && canScrollX && $scrollbarYRail.css({left: $this.scrollLeft() + 1});
}

$scrollbarX && $scrollbarX.css({left: scrollbarXLeft, width: scrollbarXWidth});
$scrollbarX && $scrollbarX.css({left: Common.UI.isRTL() ? 'auto' : scrollbarXLeft, right: !Common.UI.isRTL() ? 'auto' : scrollbarXLeft, width: scrollbarXWidth});
$scrollbarY && $scrollbarY.css({top: scrollbarYTop, height: scrollbarYHeight});
};

Expand All @@ -170,7 +179,7 @@
if (!settings.suppressScrollX && containerWidth + settings.scrollXMarginOffset < contentWidth) {
scrollbarXActive = true;
scrollbarXWidth = getSettingsAdjustedThumbSize(parseInt(scrollbarXRailWidth * containerWidth / contentWidth, 10));
scrollbarXLeft = parseInt($this.scrollLeft() * (scrollbarXRailWidth - scrollbarXWidth) / (contentWidth - containerWidth), 10);
scrollbarXLeft = parseInt($this.scrollLeft() * (Common.UI.isRTL() ? -1 : 1) * (scrollbarXRailWidth - scrollbarXWidth) / (contentWidth - containerWidth), 10);
}
else {
scrollbarXActive = false;
Expand Down Expand Up @@ -210,6 +219,7 @@
currentPageX;

$scrollbarX.bind('mousedown' + eventClassName, function (e) {
canScrollX = true;
Common.NotificationCenter.trigger('hints:clear');
currentPageX = e.pageX;
currentLeft = $scrollbarX.position().left;
Expand Down Expand Up @@ -360,6 +370,7 @@
// useBothWheelAxes and only horizontal bar is active, so use both
// wheel axes for horizontal bar
if (deltaX) {
canScrollX = true;
$this.scrollLeft($this.scrollLeft() + (deltaX * settings.wheelSpeed));
} else {
$this.scrollLeft($this.scrollLeft() - (deltaY * settings.wheelSpeed));
Expand Down Expand Up @@ -465,17 +476,16 @@
$scrollbarX.bind('click' + eventClassName, stopPropagation);
$scrollbarXRail.bind('click' + eventClassName, function (e) {
var halfOfScrollbarLength = parseInt(scrollbarXWidth / 2, 10),
positionLeft = e.pageX - $scrollbarXRail.offset().left - halfOfScrollbarLength,
maxPositionLeft = scrollbarXRailWidth - scrollbarXWidth,
positionRatio = positionLeft / maxPositionLeft;

positionLeft = Common.UI.isRTL() ? maxPositionLeft - (e.pageX - $scrollbarXRail.offset().left) + halfOfScrollbarLength : e.pageX - $scrollbarXRail.offset().left - halfOfScrollbarLength,
positionRatio = (positionLeft / maxPositionLeft);
canScrollX = true;
if (positionRatio < 0) {
positionRatio = 0;
} else if (positionRatio > 1) {
positionRatio = 1;
}

$this.scrollLeft((contentWidth - containerWidth) * positionRatio);
$this.scrollLeft((contentWidth - containerWidth) * positionRatio * (Common.UI.isRTL() ? -1 : 1));
});
};

Expand Down Expand Up @@ -589,6 +599,8 @@
scrollbarYHeight =
scrollbarYTop =
scrollbarYRight = null;

canScrollX = false;
};

var ieSupport = function (version) {
Expand Down
57 changes: 50 additions & 7 deletions apps/spreadsheeteditor/main/app/controller/Print.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ define([
};

this._isPreviewVisible = false;
this.isZoomedToPage = true;

this.addListeners({
'PrintWithPreview': {
Expand Down Expand Up @@ -93,6 +94,7 @@ define([
this.comboSheetsChange(this.printSettings, combo, record);
if (this._isPreviewVisible) {
this.notUpdateSheetSettings = true;
this.updatePrintRenderContainerSize();
this.api.asc_drawPrintPreview(undefined, record.value);
}
}, this));
Expand All @@ -109,6 +111,8 @@ define([
}
this.printSettings.btnPrevPage.on('click', _.bind(this.onChangePreviewPage, this, false));
this.printSettings.btnNextPage.on('click', _.bind(this.onChangePreviewPage, this, true));
this.printSettings.btnZoomToPage.on('click', _.bind(this.onClickZoomToPageButton, this));
this.printSettings.btnZoomToPage.updateHint(this.txtZoomToPage);
this.printSettings.txtNumberPage.on({
'keypress:after': _.bind(this.onKeypressPageNumber, this),
'keyup:after': _.bind(this.onKeyupPageNumber, this)
Expand All @@ -122,6 +126,7 @@ define([
Common.NotificationCenter.on('window:resize', _.bind(function () {
if (this._isPreviewVisible) {
this.notUpdateSheetSettings = true;
this.updatePrintRenderContainerSize();
this.api.asc_drawPrintPreview(this._navigationPreview.currentPage);
}
}, this));
Expand Down Expand Up @@ -177,11 +182,11 @@ define([

panel.cmbSheet.store.reset(items);
},

updateSettings: function(panel) {
this.resetSheets(panel);
var item = panel.cmbSheet.store.findWhere({value: panel.cmbSheet.getValue()}) ||
panel.cmbSheet.store.findWhere({value: this.api.asc_getActiveWorksheetIndex()});
panel.cmbSheet.store.findWhere({value: this.api.asc_getActiveWorksheetIndex()});
if (item) {
panel.cmbSheet.setValue(item.get('value'));
panel.updateActiveSheet && panel.updateActiveSheet(item.get('displayValue'));
Expand Down Expand Up @@ -219,7 +224,7 @@ define([
panel.cmbPaperSize.setValue(item.get('value'));
else
panel.cmbPaperSize.setValue(this.txtCustom + ' (' + parseFloat(Common.Utils.Metric.fnRecalcFromMM(w).toFixed(2)) + Common.Utils.Metric.getCurrentMetricName() + ' x ' +
parseFloat(Common.Utils.Metric.fnRecalcFromMM(h).toFixed(2)) + Common.Utils.Metric.getCurrentMetricName() + ')');
parseFloat(Common.Utils.Metric.fnRecalcFromMM(h).toFixed(2)) + Common.Utils.Metric.getCurrentMetricName() + ')');

this.fitWidth = opt.asc_getFitToWidth();
this.fitHeight = opt.asc_getFitToHeight();
Expand Down Expand Up @@ -812,9 +817,43 @@ define([
index--;
index = Math.max(index, 0);
}
this.api.asc_drawPrintPreview(index);

this.api.asc_drawPrintPreview(index);
this.updateNavigationButtons(index, this._navigationPreview.pageCount);
this.updatePrintRenderContainerSize(true);
},

onClickZoomToPageButton: function(button) {
this.isZoomedToPage = button.pressed;
this.updatePreview();
},

updatePrintRenderContainerSize: function(rerender) {
var $preview = $('#print-preview');

if (!this.isZoomedToPage) {
var pageSetup = this._changedProps[this.printSettings.cmbSheet.getValue()].asc_getPageSetup(),
orientation = pageSetup.asc_getOrientation(),
width = AscCommon.mm2pix(pageSetup.asc_getWidth()),
height = AscCommon.mm2pix(pageSetup.asc_getHeight());

$preview.css({
width: 'max(100%, {}px)'.replace('{}', orientation===1 ? height : width),
height: 'max(100%, {}px)'.replace('{}', orientation===1 ? width : height)
});
this.printSettings.printScroller.update({ suppressScrollX: false, suppressScrollY: false });
} else {
$preview.css({ width: '', height: '' })
this.printSettings.printScroller.update({ suppressScrollX: true, suppressScrollY: true });
}

$('#print-preview-wrapper').css('display', this.isZoomedToPage ? '' : 'flex');

this.printSettings.printScroller.scrollTop(0);

if (rerender) {
this.api.asc_drawPrintPreview(this._navigationPreview.currentPage);
}
},

onPreviewWheel: function (e) {
Expand All @@ -841,8 +880,10 @@ define([

box.focus(); // for IE

this.api.asc_drawPrintPreview(page-1);
this.updateNavigationButtons(page-1, this._navigationPreview.pageCount);
var newPage = page - 1;
this.api.asc_drawPrintPreview(newPage);
this.updateNavigationButtons(newPage, this._navigationPreview.pageCount);
this.updatePrintRenderContainerSize(true);

return false;
}
Expand Down Expand Up @@ -902,6 +943,7 @@ define([
}

this.notUpdateSheetSettings = !needUpdate;
this.updatePrintRenderContainerSize();
this.api.asc_drawPrintPreview(newPage);

this.updateNavigationButtons(newPage, pageCount);
Expand Down Expand Up @@ -972,6 +1014,7 @@ define([
textFrozenRows: 'Frozen rows',
textFrozenCols: 'Frozen columns',
textFirstRow: 'First row',
textFirstCol: 'First column'
textFirstCol: 'First column',
txtZoomToPage: 'Zoom to page',
}, SSE.Controllers.Print || {}));
});
29 changes: 28 additions & 1 deletion apps/spreadsheeteditor/main/app/view/FileMenuPanels.js
Original file line number Diff line number Diff line change
Expand Up @@ -2591,7 +2591,9 @@ define([], function () {
'</div>',
'</div>',
'<div id="print-preview-box" class="no-padding">',
'<div id="print-preview"></div>',
'<div id="print-preview-wrapper">',
'<div id="print-preview"></div>',
'</div>',
'<div id="print-navigation">',
'<% if (!isRTL) { %>',
'<div id="print-prev-page"></div>',
Expand All @@ -2606,6 +2608,7 @@ define([], function () {
'<label id="print-count-page" class="margin-left-4"><%= scope.txtOf %></label>',
'</div>',
'<label id="print-active-sheet"><%= scope.txtSheet %></label>',
'<div id="print-zoom-to-page"></div>',
'</div>',
'</div>',
'<div id="print-preview-empty" class="hidden">',
Expand Down Expand Up @@ -3018,6 +3021,16 @@ define([], function () {
dataHintDirection: 'top'
});

this.btnZoomToPage = new Common.UI.Button({
parentEl: $markup.findById('#print-zoom-to-page'),
cls: 'btn-zoom-to-page btn-toolbar',
iconCls: 'toolbar__icon btn-ic-zoomtopage',
dataHint: '2',
dataHintDirection: 'top',
enableToggle: true,
pressed: true
});

this.countOfPages = $markup.findById('#print-count-page');

this.txtNumberPage = new Common.UI.InputField({
Expand Down Expand Up @@ -3057,6 +3070,16 @@ define([], function () {
});
}

if (_.isUndefined(this.printScroller)) {
this.printScroller = new Common.UI.Scroller({
el: $('#print-preview-wrapper'),
alwaysVisibleX: true,
alwaysVisibleY: true,
suppressScrollX: true,
suppressScrollY: true
});
}

Common.NotificationCenter.on({
'window:resize': function() {
me.isVisible() && me.updateScroller();
Expand Down Expand Up @@ -3090,6 +3113,10 @@ define([], function () {
this.scroller.update();
this.pnlSettings.toggleClass('bordered', this.scroller.isVisible());
}

if (this.printScroller) {
this.printScroller.update();
}
},

setMode: function(mode) {
Expand Down
1 change: 1 addition & 0 deletions apps/spreadsheeteditor/main/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1461,6 +1461,7 @@
"SSE.Controllers.Print.textRepeat": "Repeat...",
"SSE.Controllers.Print.textSelectRange": "Select range",
"SSE.Controllers.Print.txtCustom": "Custom",
"SSE.Controllers.Print.txtZoomToPage": "Zoom to page",
"SSE.Controllers.Search.textInvalidRange": "ERROR! Invalid cells range",
"SSE.Controllers.Search.textNoTextFound": "The data you have been searching for could not be found. Please adjust your search options.",
"SSE.Controllers.Search.textReplaceSkipped": "The replacement has been made. {0} occurrences were skipped.",
Expand Down
22 changes: 18 additions & 4 deletions apps/spreadsheeteditor/main/resources/less/leftmenu.less
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@
.print-titles-caret {
width: 24px;
height: 24px;
background-position: 3px -270px;
background-position: 4px -40px;
display: inline-block;
position: absolute;
left: 0;
Expand Down Expand Up @@ -893,8 +893,7 @@
}
#print-navigation {
height: 50px;
.padding-left-20();
padding-top: 10px;
padding: 15px 20px 0;
display: flex;
#print-prev-page {
display: inline-block;
Expand Down Expand Up @@ -938,6 +937,13 @@
transform: rotate(135deg) translate(4px, 0px);
}
}
#print-zoom-to-page {
margin-left: auto;
.rtl & {
margin-right: auto;
margin-left: unset;
}
}
.page-number {
display: flex;
align-items: center;
Expand All @@ -952,9 +958,17 @@
line-height: 20px;
}
}
#print-preview {

#print-preview-wrapper {
overflow: hidden;
height: calc(100% - 50px);
position: relative;
#print-preview {
height: calc(100% - 10px);
flex-shrink: 0;
}
}

#print-preview-box {
position: absolute;
left: 280px;
Expand Down

0 comments on commit 3e2fca8

Please sign in to comment.