[DE PE SSE] Fix bug 54241

This commit is contained in:
JuliaSvinareva 2021-12-15 18:46:10 +03:00
parent 05961f64ad
commit 51942c7e02
5 changed files with 97 additions and 42 deletions

View file

@ -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);
})
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 + '%');
}
});
}, 10);
}
} else
this.applyZoom(record.value);
},
onBtnZoomTo: function(type) {
@ -246,10 +243,8 @@ define([
},
onComboBlur: function() {
this.fireEvent('editcomplete', this);
},
textZoomErr: 'The entered value is incorrect.<br>Please enter a value between 25% and 500%.'
Common.NotificationCenter.trigger('edit:complete', this.view);
}
}, DE.Controllers.ViewTab || {}));
});

View file

@ -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 || {}));
});

View file

@ -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 },

View file

@ -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 () {

View file

@ -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 },