From 05961f64ad673a9bf405f292c719cfd01b4579f9 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Tue, 14 Dec 2021 23:12:20 +0300 Subject: [PATCH 1/3] [DE] Bug 54241 --- .../main/app/controller/ViewTab.js | 43 +++++++++++++++++-- apps/documenteditor/main/app/view/ViewTab.js | 5 +-- 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/apps/documenteditor/main/app/controller/ViewTab.js b/apps/documenteditor/main/app/controller/ViewTab.js index 36beb7c6d3..2194829bc3 100644 --- a/apps/documenteditor/main/app/controller/ViewTab.js +++ b/apps/documenteditor/main/app/controller/ViewTab.js @@ -80,7 +80,6 @@ define([ }); this.addListeners({ 'ViewTab': { - 'zoom:value': _.bind(this.onChangeZoomValue, this), 'zoom:topage': _.bind(this.onBtnZoomTo, this, 'topage'), 'zoom:towidth': _.bind(this.onBtnZoomTo, this, 'towidth'), 'rulers:change': _.bind(this.onChangeRulers, this), @@ -125,6 +124,11 @@ define([ })).then(function(){ me.view.setEvents(); + me.view.cmbZoom.on('selected', _.bind(me.onSelectedZoomValue, me)) + .on('changed:before',_.bind(me.onZoomChanged, me, true)) + .on('changed:after', _.bind(me.onZoomChanged, me, false)) + .on('combo:blur', _.bind(me.onComboBlur, me, false)); + me.getApplication().getController('LeftMenu').leftMenu.btnNavigation.on('toggle', function (btn, state) { if (state !== me.view.btnNavigation.pressed) me.view.turnNavigation(state); @@ -166,11 +170,38 @@ define([ this.view.cmbZoom.setValue(percent, percent + '%'); }, - onChangeZoomValue: function (value) { - this.api.zoom(value); + applyZoom: function (value) { + var val = parseFloat(value); + val = isNaN(val) ? 25 : Math.max(25, Math.min(500, val)); + this.api.zoom(val); Common.NotificationCenter.trigger('edit:complete', this.view); }, + onSelectedZoomValue: function (combo, record) { + this.applyZoom(record.value); + }, + + onZoomChanged: function (before, combo, record, e) { + var me = this; + if (before) { + var value = parseFloat(record.value), + expr = new RegExp('^\\s*(\\d*(\\.|,)?\\d+)\\s*(%)?\\s*$'); + if (!(expr.exec(record.value)) || value<25 || value>500) { + setTimeout( function() { + Common.UI.error({ + msg: me.textZoomErr, + callback: function() { + _.defer(function() { + me.fireEvent('editcomplete', me); + }) + } + }); + }, 10); + } + } else + this.applyZoom(record.value); + }, + onBtnZoomTo: function(type) { var btn, func; if ( type === 'topage' ) { @@ -214,5 +245,11 @@ define([ } }, + onComboBlur: function() { + this.fireEvent('editcomplete', this); + }, + + textZoomErr: 'The entered value is incorrect.
Please enter a value between 25% and 500%.' + }, DE.Controllers.ViewTab || {})); }); \ No newline at end of file diff --git a/apps/documenteditor/main/app/view/ViewTab.js b/apps/documenteditor/main/app/view/ViewTab.js index 8e2710c58e..1dec42cd30 100644 --- a/apps/documenteditor/main/app/view/ViewTab.js +++ b/apps/documenteditor/main/app/view/ViewTab.js @@ -54,9 +54,6 @@ define([ me.btnNavigation.on('click', function (btn, e) { me.fireEvent('viewtab:navigation', [btn.pressed]); }); - me.cmbZoom.on('selected', function (combo, record) { - me.fireEvent('zoom:value', [record.value]); - }); me.btnFitToPage.on('click', function () { me.fireEvent('zoom:topage'); }); @@ -104,7 +101,7 @@ define([ el: $host.find('#slot-field-zoom'), cls: 'input-group-nr', menuStyle: 'min-width: 55px;', - editable: false, + editable: true, disabled: true, data: [ { displayValue: "50%", value: 50 }, From 51942c7e02bd67b7d034d650397adeb9c719acb3 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Wed, 15 Dec 2021 18:46:10 +0300 Subject: [PATCH 2/3] [DE PE SSE] Fix bug 54241 --- .../main/app/controller/ViewTab.js | 39 +++++++--------- .../main/app/controller/ViewTab.js | 45 +++++++++++++++---- .../main/app/view/ViewTab.js | 5 +-- .../main/app/controller/ViewTab.js | 36 +++++++++++++-- .../main/app/view/ViewTab.js | 14 ++++-- 5 files changed, 97 insertions(+), 42 deletions(-) diff --git a/apps/documenteditor/main/app/controller/ViewTab.js b/apps/documenteditor/main/app/controller/ViewTab.js index 2194829bc3..4f8128f23b 100644 --- a/apps/documenteditor/main/app/controller/ViewTab.js +++ b/apps/documenteditor/main/app/controller/ViewTab.js @@ -168,11 +168,12 @@ define([ this.view.btnFitToWidth.toggle(type == 1, true); this.view.cmbZoom.setValue(percent, percent + '%'); + + this._state.zoomValue = percent; }, applyZoom: function (value) { - var val = parseFloat(value); - val = isNaN(val) ? 25 : Math.max(25, Math.min(500, val)); + var val = Math.max(25, Math.min(500, value)); this.api.zoom(val); Common.NotificationCenter.trigger('edit:complete', this.view); }, @@ -182,24 +183,20 @@ define([ }, onZoomChanged: function (before, combo, record, e) { - var me = this; + var value = parseFloat(record.value); if (before) { - var value = parseFloat(record.value), - expr = new RegExp('^\\s*(\\d*(\\.|,)?\\d+)\\s*(%)?\\s*$'); - if (!(expr.exec(record.value)) || value<25 || value>500) { - setTimeout( function() { - Common.UI.error({ - msg: me.textZoomErr, - callback: function() { - _.defer(function() { - me.fireEvent('editcomplete', me); - }) - } - }); - }, 10); + var expr = new RegExp('^\\s*(\\d*(\\.|,)?\\d+)\\s*(%)?\\s*$'); + if (!expr.exec(record.value)) { + this.view.cmbZoom.setValue(this._state.zoomValue, this._state.zoomValue + '%'); + Common.NotificationCenter.trigger('edit:complete', this.view); } - } else - this.applyZoom(record.value); + } else { + if (this._state.zoomValue !== value && !isNaN(value)) { + this.applyZoom(value); + } else if (record.value !== this._state.zoomValue + '%') { + this.view.cmbZoom.setValue(this._state.zoomValue, this._state.zoomValue + '%'); + } + } }, onBtnZoomTo: function(type) { @@ -246,10 +243,8 @@ define([ }, onComboBlur: function() { - this.fireEvent('editcomplete', this); - }, - - textZoomErr: 'The entered value is incorrect.
Please enter a value between 25% and 500%.' + Common.NotificationCenter.trigger('edit:complete', this.view); + } }, DE.Controllers.ViewTab || {})); }); \ No newline at end of file diff --git a/apps/presentationeditor/main/app/controller/ViewTab.js b/apps/presentationeditor/main/app/controller/ViewTab.js index dd0ebd4237..bfd39f5fc2 100644 --- a/apps/presentationeditor/main/app/controller/ViewTab.js +++ b/apps/presentationeditor/main/app/controller/ViewTab.js @@ -82,7 +82,6 @@ define([ }); this.addListeners({ 'ViewTab': { - 'zoom:value': _.bind(this.onChangeZoomValue, this), 'zoom:toslide': _.bind(this.onBtnZoomTo, this, 'toslide'), 'zoom:towidth': _.bind(this.onBtnZoomTo, this, 'towidth'), 'rulers:change': _.bind(this.onChangeRulers, this), @@ -141,6 +140,10 @@ define([ accept(); })).then(function () { me.view.setEvents(); + me.view.cmbZoom.on('selected', _.bind(me.onSelectedZoomValue, me)) + .on('changed:before',_.bind(me.onZoomChanged, me, true)) + .on('changed:after', _.bind(me.onZoomChanged, me, false)) + .on('combo:blur', _.bind(me.onComboBlur, me, false)); }); var menuItems = [], @@ -165,13 +168,6 @@ define([ } }, - onChangeZoomValue: function (value) { - this._state.zoom_type = undefined; - this._state.zoom_percent = undefined; - this.api.zoom(value); - Common.NotificationCenter.trigger('edit:complete', this.view); - }, - onBtnZoomTo: function (type, btn) { this._state.zoom_type = undefined; this._state.zoom_percent = undefined; @@ -207,5 +203,38 @@ define([ } }, + applyZoom: function (value) { + this._state.zoom_percent = undefined; + this._state.zoom_type = undefined; + var val = Math.max(25, Math.min(500, value)); + this.api.zoom(val); + Common.NotificationCenter.trigger('edit:complete', this.view); + }, + + onSelectedZoomValue: function (combo, record) { + this.applyZoom(record.value); + }, + + onZoomChanged: function (before, combo, record, e) { + var value = parseFloat(record.value); + if (before) { + var expr = new RegExp('^\\s*(\\d*(\\.|,)?\\d+)\\s*(%)?\\s*$'); + if (!expr.exec(record.value)) { + this.view.cmbZoom.setValue(this._state.zoom_percent, this._state.zoom_percent + '%'); + Common.NotificationCenter.trigger('edit:complete', this.view); + } + } else { + if (this._state.zoom_percent !== value && !isNaN(value)) { + this.applyZoom(value); + } else if (record.value !== this._state.zoom_percent + '%') { + this.view.cmbZoom.setValue(this._state.zoom_percent, this._state.zoom_percent + '%'); + } + } + }, + + onComboBlur: function() { + Common.NotificationCenter.trigger('edit:complete', this.view); + } + }, PE.Controllers.ViewTab || {})); }); \ No newline at end of file diff --git a/apps/presentationeditor/main/app/view/ViewTab.js b/apps/presentationeditor/main/app/view/ViewTab.js index e493256c6b..b9b3a6f1a5 100644 --- a/apps/presentationeditor/main/app/view/ViewTab.js +++ b/apps/presentationeditor/main/app/view/ViewTab.js @@ -51,9 +51,6 @@ define([ setEvents: function () { var me = this; - me.cmbZoom && me.cmbZoom.on('selected', function (combo, record) { - me.fireEvent('zoom:value', [record.value]); - }); me.btnFitToSlide && me.btnFitToSlide.on('click', function () { me.fireEvent('zoom:toslide', [me.btnFitToSlide]); }); @@ -89,7 +86,7 @@ define([ el: $host.find('#slot-field-zoom'), cls: 'input-group-nr', menuStyle: 'min-width: 55px;', - editable: false, + editable: true, lock: [_set.disableOnStart], data: [ { displayValue: "50%", value: 50 }, diff --git a/apps/spreadsheeteditor/main/app/controller/ViewTab.js b/apps/spreadsheeteditor/main/app/controller/ViewTab.js index 3558a63143..beaa8ce92d 100644 --- a/apps/spreadsheeteditor/main/app/controller/ViewTab.js +++ b/apps/spreadsheeteditor/main/app/controller/ViewTab.js @@ -85,6 +85,9 @@ define([ }); this.addListeners({ 'ViewTab': { + 'zoom:selected': _.bind(this.onSelectedZoomValue, this), + 'zoom:changedbefore': _.bind(this.onZoomChanged, this), + 'zoom:changedafter': _.bind(this.onZoomChanged, this), 'viewtab:freeze': this.onFreeze, 'viewtab:freezeshadow': this.onFreezeShadow, 'viewtab:formula': this.onViewSettings, @@ -151,13 +154,36 @@ define([ Common.NotificationCenter.trigger('edit:complete', this.view); }, - onZoom: function(zoom) { - if (this.api) { - this.api.asc_setZoom(zoom/100); - } + applyZoom: function (value) { + var val = Math.max(25, Math.min(500, value)); + this.api.asc_setZoom(val/100); Common.NotificationCenter.trigger('edit:complete', this.view); }, + onSelectedZoomValue: function (combo, record) { + this.applyZoom(record.value); + }, + + onZoomChanged: function (before, combo, record, e) { + var value = parseFloat(record.value); + if (this._state.zoomValue === undefined) { + this._state.zoomValue = 100; + } + if (before) { + var expr = new RegExp('^\\s*(\\d*(\\.|,)?\\d+)\\s*(%)?\\s*$'); + if (!expr.exec(record.value)) { + this.view.cmbZoom.setValue(this._state.zoomValue, this._state.zoomValue + '%'); + Common.NotificationCenter.trigger('edit:complete', this.view); + } + } else { + if (this._state.zoomValue !== value && !isNaN(value)) { + this.applyZoom(value); + } else if (record.value !== this._state.zoomValue + '%') { + this.view.cmbZoom.setValue(this._state.zoomValue, this._state.zoomValue + '%'); + } + } + }, + onViewSettings: function(type, value){ if (this.api) { switch (type) { @@ -245,8 +271,10 @@ define([ }, onApiZoomChange: function(zf, type){ + console.log('zoom'); var value = Math.floor((zf + .005) * 100); this.view.cmbZoom.setValue(value, value + '%'); + this._state.zoomValue = value; }, onThemeChanged: function () { diff --git a/apps/spreadsheeteditor/main/app/view/ViewTab.js b/apps/spreadsheeteditor/main/app/view/ViewTab.js index 3b69969af0..b4b7e29ee7 100644 --- a/apps/spreadsheeteditor/main/app/view/ViewTab.js +++ b/apps/spreadsheeteditor/main/app/view/ViewTab.js @@ -76,15 +76,21 @@ define([ this.chZeros.on('change', function (field, value) { me.fireEvent('viewtab:zeros', [3, value]); }); - this.cmbZoom.on('selected', function(combo, record) { - me.fireEvent('viewtab:zoom', [record.value]); - }); this.chToolbar.on('change', function (field, value) { me.fireEvent('viewtab:showtoolbar', [field, value !== 'checked']); }); this.chStatusbar.on('change', function (field, value) { me.fireEvent('statusbar:setcompact', [field, value === 'checked']); }); + this.cmbZoom.on('selected', function (combo, record) { + me.fireEvent('zoom:selected', [combo, record]); + }).on('changed:before', function (combo, record) { + me.fireEvent('zoom:changedbefore', [true, combo, record]); + }).on('changed:after', function (combo, record) { + me.fireEvent('zoom:changedafter', [false, combo, record]); + }).on('combo:blur', function () { + me.fireEvent('editcomplete', me); + }); } return { @@ -160,7 +166,7 @@ define([ cls : 'input-group-nr', menuStyle : 'min-width: 55px;', hint : me.tipFontSize, - editable : false, + editable : true, lock : [_set.coAuth, _set.lostConnect, _set.editCell], data : [ { displayValue: "50%", value: 50 }, From 7dd6e0fd34f8663f04e0e267ff4d8ac936966073 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Fri, 17 Dec 2021 11:10:53 +0300 Subject: [PATCH 3/3] [DE PE SSE] Bug 54241 --- apps/documenteditor/main/app/view/ViewTab.js | 10 ++++++++++ apps/presentationeditor/main/app/view/ViewTab.js | 10 ++++++++++ apps/spreadsheeteditor/main/app/view/ViewTab.js | 11 ++++++++++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/apps/documenteditor/main/app/view/ViewTab.js b/apps/documenteditor/main/app/view/ViewTab.js index 1dec42cd30..6bc3c97244 100644 --- a/apps/documenteditor/main/app/view/ViewTab.js +++ b/apps/documenteditor/main/app/view/ViewTab.js @@ -72,6 +72,8 @@ define([ me.btnDarkDocument.on('click', _.bind(function () { me.fireEvent('darkmode:change'); }, me)); + me.cmbZoom.on('combo:focusin', _.bind(this.onComboOpen, this, false)); + me.cmbZoom.on('show:after', _.bind(this.onComboOpen, this, true)); }, initialize: function (options) { @@ -239,6 +241,14 @@ define([ this.btnNavigation && this.btnNavigation.toggle(state, true); }, + onComboOpen: function (needfocus, combo) { + _.delay(function() { + var input = $('input', combo.cmpEl).select(); + if (needfocus) input.focus(); + else if (!combo.isMenuOpen()) input.one('mouseup', function (e) { e.preventDefault(); }); + }, 10); + }, + textNavigation: 'Navigation', textZoom: 'Zoom', textFitToPage: 'Fit To Page', diff --git a/apps/presentationeditor/main/app/view/ViewTab.js b/apps/presentationeditor/main/app/view/ViewTab.js index b9b3a6f1a5..f34bbe04b1 100644 --- a/apps/presentationeditor/main/app/view/ViewTab.js +++ b/apps/presentationeditor/main/app/view/ViewTab.js @@ -69,6 +69,8 @@ define([ me.chNotes && me.chNotes.on('change', _.bind(function (checkbox, state) { me.fireEvent('notes:change', [me.chNotes, state === 'checked']); }, me)); + me.cmbZoom.on('combo:focusin', _.bind(this.onComboOpen, this, false)); + me.cmbZoom.on('show:after', _.bind(this.onComboOpen, this, true)); }, initialize: function (options) { @@ -218,6 +220,14 @@ define([ }, this); }, + onComboOpen: function (needfocus, combo) { + _.delay(function() { + var input = $('input', combo.cmpEl).select(); + if (needfocus) input.focus(); + else if (!combo.isMenuOpen()) input.one('mouseup', function (e) { e.preventDefault(); }); + }, 10); + }, + textZoom: 'Zoom', textFitToSlide: 'Fit To Slide', textFitToWidth: 'Fit To Width', diff --git a/apps/spreadsheeteditor/main/app/view/ViewTab.js b/apps/spreadsheeteditor/main/app/view/ViewTab.js index b4b7e29ee7..e6ad3cd1ba 100644 --- a/apps/spreadsheeteditor/main/app/view/ViewTab.js +++ b/apps/spreadsheeteditor/main/app/view/ViewTab.js @@ -90,7 +90,8 @@ define([ me.fireEvent('zoom:changedafter', [false, combo, record]); }).on('combo:blur', function () { me.fireEvent('editcomplete', me); - }); + }).on('combo:focusin', _.bind(this.onComboOpen, this, false)) + .on('show:after', _.bind(this.onComboOpen, this, true)); } return { @@ -402,6 +403,14 @@ define([ }, this); }, + onComboOpen: function (needfocus, combo) { + _.delay(function() { + var input = $('input', combo.cmpEl).select(); + if (needfocus) input.focus(); + else if (!combo.isMenuOpen()) input.one('mouseup', function (e) { e.preventDefault(); }); + }, 10); + }, + capBtnSheetView: 'Sheet View', capBtnFreeze: 'Freeze Panes', textZoom: 'Zoom',