From 3099b6befb29026319e9a19b3b434c5b03a57b6b Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 19 Jan 2022 21:34:20 +0300 Subject: [PATCH] [PE] Fix repeat and duration settings for animation --- .../main/app/controller/Animation.js | 61 +++++++------------ .../main/app/view/Animation.js | 36 ++++++----- apps/presentationeditor/main/locale/en.json | 9 +++ 3 files changed, 52 insertions(+), 54 deletions(-) diff --git a/apps/presentationeditor/main/app/controller/Animation.js b/apps/presentationeditor/main/app/controller/Animation.js index 4277a2f1f..48c54b39a 100644 --- a/apps/presentationeditor/main/app/controller/Animation.js +++ b/apps/presentationeditor/main/app/controller/Animation.js @@ -199,16 +199,10 @@ define([ }); if (!item) { - value = /^\+?(\d*(\.|,).?\d+)$|^\+?(\d+(\.|,)?\d*)$/.exec(record.value); - - if (!value) { - value = this._state.Duration; - combo.setRawValue(value); - if(isNaN(record.value)) { - record.value = value; - if(value < 0) - record.displayValue = combo.store.findWhere({value: value}).get('displayValue'); - } + var expr = new RegExp('^\\s*(\\d*(\\.|,)?\\d+)\\s*(' + me.view.txtSec + ')?\\s*$'); + if (!expr.exec(record.value)) { + combo.setValue(this._state.Duration, this._state.Duration>=0 ? this._state.Duration + ' ' + this.view.txtSec : 1); + e.preventDefault(); return false; } } @@ -217,7 +211,7 @@ define([ value = Common.Utils.String.parseFloat(record.value); if(!record.displayValue) value = value > 600 ? 600 : - value < 0 ? 0.01 : value.toFixed(2); + value < 0 ? 0.01 : parseFloat(value.toFixed(2)); combo.setValue(value); this.setDuration(value); @@ -254,15 +248,9 @@ define([ if (!item) { value = /^\+?(\d*(\.|,).?\d+)$|^\+?(\d+(\.|,)?\d*)$/.exec(record.value); - if (!value) { - value = this._state.Repeat; - combo.setRawValue(value); - if(isNaN(record.value)) { - record.value = value; - if(value < 0) - record.displayValue = combo.store.findWhere({value: value}).get('displayValue'); - } + combo.setValue(this._state.Repeat, this._state.Repeat>=0 ? this._state.Repeat : 1); + e.preventDefault(); return false; } } @@ -441,8 +429,11 @@ define([ this._state.noAnimationParam = view.setMenuParameters(this._state.Effect, _.findWhere(this.EffectGroups,{value: this._state.EffectGroup}).id, this._state.EffectOption)===undefined; value = this.AnimationProperties.asc_getDuration(); - this._state.Duration = (value<0) ? value : value/1000; - view.cmbDuration.setValue( this._state.Duration !== undefined ? this._state.Duration : 1); + this._state.Duration = (value>=0) ? value/1000 : value ; // undefined or <0 + if (this._state.noAnimationDuration) + view.cmbDuration.setValue(''); + else + view.cmbDuration.setValue(this._state.Duration, this._state.Duration>=0 ? this._state.Duration + ' ' + this.view.txtSec : 1); value = this.AnimationProperties.asc_getDelay(); if (Math.abs(this._state.Delay - value) > 0.001 || @@ -453,7 +444,10 @@ define([ } value =this.AnimationProperties.asc_getRepeatCount(); this._state.Repeat = (value<0) ? value : value/1000; - view.cmbRepeat.setValue( this._state.Repeat !== undefined ? this._state.Repeat : 1); + if (this._state.noAnimationRepeat) + view.cmbRepeat.setValue(''); + else + view.cmbRepeat.setValue( this._state.Repeat, this._state.Repeat>=0 ? this._state.Repeat : 1); this._state.StartSelect = this.AnimationProperties.asc_getStartType(); view.cmbStart.setValue(this._state.StartSelect!==undefined ? this._state.StartSelect : AscFormat.NODE_TYPE_CLICKEFFECT); @@ -498,26 +492,17 @@ define([ (type == AscFormat.EMPHASIS_BOLD_REVEAL || type == AscFormat.EMPHASIS_TRANSPARENCY)) { this._state.noAnimationRepeat = true; if(this.view.cmbDuration.store.length == 6) { - - this.view.cmbDuration.setData([{value: 20, displayValue: 20}, - {value: 5, displayValue: 5}, - {value: 3, displayValue: 3}, - {value: 2, displayValue: 2}, - {value: 1, displayValue: 1}, - {value: 0.5, displayValue: 0.5}, - {value: AscFormat.untilNextClick, displayValue: this.view.textUntilNextClick}, - {value: AscFormat.untilNextSlide, displayValue: this.view.textUntilEndOfSlide}]); + this.view.cmbDuration.store.add([{value: AscFormat.untilNextClick, displayValue: this.view.textUntilNextClick}, + {value: AscFormat.untilNextSlide, displayValue: this.view.textUntilEndOfSlide}]); + this.view.cmbDuration.setData(this.view.cmbDuration.store.models); } } if((this.view.cmbDuration.store.length == 8) && ((this._state.EffectGroup != AscFormat.PRESET_CLASS_EMPH) || ((this._state.EffectGroup == AscFormat.PRESET_CLASS_EMPH) && (this._state.Effect != AscFormat.EMPHASIS_BOLD_REVEAL) && (this._state.Effect != AscFormat.EMPHASIS_TRANSPARENCY)))) { - this.view.cmbDuration.setData([{value: 20, displayValue: 20}, - {value: 5, displayValue: 5}, - {value: 3, displayValue: 3}, - {value: 2, displayValue: 2}, - {value: 1, displayValue: 1}, - {value: 0.5, displayValue: 0.5}]); + this.view.cmbDuration.store.pop(); + this.view.cmbDuration.store.pop(); + this.view.cmbDuration.setData(this.view.cmbDuration.store.models); } }, @@ -554,8 +539,6 @@ define([ this.lockToolbar(PE.enumLock.noAnimationRepeat, this._state.noAnimationRepeat); if (PE.enumLock.noAnimationDuration != undefined) this.lockToolbar(PE.enumLock.noAnimationDuration, this._state.noAnimationDuration); - - } }, PE.Controllers.Animation || {})); diff --git a/apps/presentationeditor/main/app/view/Animation.js b/apps/presentationeditor/main/app/view/Animation.js index eddd21902..7cb5d5189 100644 --- a/apps/presentationeditor/main/app/view/Animation.js +++ b/apps/presentationeditor/main/app/view/Animation.js @@ -99,11 +99,11 @@ define([ } if (me.cmbDuration) { - me.cmbDuration.on('changed:before', function (combo, record) { - me.fireEvent('animation:durationchange', [true, combo, record]); + me.cmbDuration.on('changed:before', function (combo, record, e) { + me.fireEvent('animation:durationchange', [true, combo, record, e]); }, me); - me.cmbDuration.on('changed:after', function (combo, record) { - me.fireEvent('animation:durationchange', [false, combo, record]); + me.cmbDuration.on('changed:after', function (combo, record, e) { + me.fireEvent('animation:durationchange', [false, combo, record, e]); }, me); me.cmbDuration.on('selected', function (combo, record) { me.fireEvent('animation:durationselected', [combo, record]); @@ -130,11 +130,11 @@ define([ } if (me.cmbRepeat) { - me.cmbRepeat.on('changed:before', function (combo, record) { - me.fireEvent('animation:repeatchange', [true, combo, record]); + me.cmbRepeat.on('changed:before', function (combo, record, e) { + me.fireEvent('animation:repeatchange', [true, combo, record, e]); }, me); - me.cmbRepeat.on('changed:after', function (combo, record) { - me.fireEvent('animation:repeatchange', [false, combo, record]); + me.cmbRepeat.on('changed:after', function (combo, record, e) { + me.fireEvent('animation:repeatchange', [false, combo, record, e]); }, me); me.cmbRepeat.on('selected', function (combo, record) { me.fireEvent('animation:repeatselected', [combo, record]); @@ -288,12 +288,12 @@ define([ menuStyle: 'min-width: 100%;', editable: true, data: [ - {value: 20, displayValue: 20}, - {value: 5, displayValue: 5}, - {value: 3, displayValue: 3}, - {value: 2, displayValue: 2}, - {value: 1, displayValue: 1}, - {value: 0.5, displayValue: 0.5} + {value: 20, displayValue: this.str20}, + {value: 5, displayValue: this.str5}, + {value: 3, displayValue: this.str3}, + {value: 2, displayValue: this.str2}, + {value: 1, displayValue: this.str1}, + {value: 0.5, displayValue: this.str0_5} ], lock: [_set.slideDeleted, _set.noSlides, _set.noGraphic, _set.noAnimation, _set.noAnimationDuration], dataHint: '1', @@ -571,7 +571,13 @@ define([ textMoveLater: 'Move Later', textNoRepeat: '(none)', textUntilNextClick: 'Until Next Click', - textUntilEndOfSlide: 'Until End of Slide' + textUntilEndOfSlide: 'Until End of Slide', + str20: '20 s (Extremely Slow)', + str5: '5 s (Very Slow)', + str3: '3 s (Slow)', + str2: '2 s (Medium)', + str1: '1 s (Fast)', + str0_5: '0.5 s (Very Fast)' } }()), PE.Views.Animation || {})); diff --git a/apps/presentationeditor/main/locale/en.json b/apps/presentationeditor/main/locale/en.json index 02a737a24..d34ce7e77 100644 --- a/apps/presentationeditor/main/locale/en.json +++ b/apps/presentationeditor/main/locale/en.json @@ -1305,6 +1305,15 @@ "PE.Views.Animation.txtParameters": "Parameters", "PE.Views.Animation.txtPreview": "Preview", "PE.Views.Animation.txtSec": "s", + "PE.Views.Animation.textNoRepeat": "(none)", + "PE.Views.Animation.textUntilNextClick": "Until Next Click", + "PE.Views.Animation.textUntilEndOfSlide": "Until End of Slide", + "PE.Views.Animation.str20": "20 s (Extremely Slow)", + "PE.Views.Animation.str5": "5 s (Very Slow)", + "PE.Views.Animation.str3": "3 s (Slow)", + "PE.Views.Animation.str2": "2 s (Medium)", + "PE.Views.Animation.str1": "1 s (Fast)", + "PE.Views.Animation.str0_5": "0.5 s (Very Fast)", "PE.Views.AnimationDialog.textPreviewEffect": "Preview Effect", "PE.Views.AnimationDialog.textTitle": "More Effects", "PE.Views.ChartSettings.textAdvanced": "Show advanced settings",