From eaab1e2fa325a465d44f7fd3e0140c2107e0c6f3 Mon Sep 17 00:00:00 2001 From: OVSharova Date: Wed, 12 Jan 2022 04:32:04 +0300 Subject: [PATCH] Change numRepeat --- .../main/app/controller/Animation.js | 66 ++++++++++++------- .../main/app/template/Toolbar.template | 2 +- .../main/app/view/Animation.js | 48 ++++++++++---- 3 files changed, 78 insertions(+), 38 deletions(-) diff --git a/apps/presentationeditor/main/app/controller/Animation.js b/apps/presentationeditor/main/app/controller/Animation.js index 0cf112e03..1754ff442 100644 --- a/apps/presentationeditor/main/app/controller/Animation.js +++ b/apps/presentationeditor/main/app/controller/Animation.js @@ -63,21 +63,24 @@ define([ this.addListeners({ 'PE.Views.Animation': { - 'animation:preview': _.bind(this.onPreviewClick, this), - 'animation:parameters': _.bind(this.onParameterClick, this), - 'animation:duration': _.bind(this.onDurationChange, this), - 'animation:selecteffect': _.bind(this.onEffectSelect, this), - 'animation:delay': _.bind(this.onDelayChange, this), - 'animation:animationpane': _.bind(this.onAnimationPane, this), - 'animation:addanimation': _.bind(this.onAddAnimation, this), - 'animation:startselect': _.bind(this.onStartSelect, this), - 'animation:checkrewind': _.bind(this.onCheckRewindChange,this), - 'animation:repeat': _.bind(this.onRepeatChange, this), - 'animation:additional': _.bind(this.onAnimationAdditional, this), - 'animation:trigger': _.bind(this.onTriggerClick, this), - 'animation:triggerclickof': _.bind(this.onTriggerClickOfClick, this), - 'animation:moveearlier': _.bind(this.onMoveEarlier, this), - 'animation:movelater': _.bind(this.onMoveLater, this) + 'animation:preview': _.bind(this.onPreviewClick, this), + 'animation:parameters': _.bind(this.onParameterClick, this), + 'animation:duration': _.bind(this.onDurationChange, this), + 'animation:selecteffect': _.bind(this.onEffectSelect, this), + 'animation:delay': _.bind(this.onDelayChange, this), + 'animation:animationpane': _.bind(this.onAnimationPane, this), + 'animation:addanimation': _.bind(this.onAddAnimation, this), + 'animation:startselect': _.bind(this.onStartSelect, this), + 'animation:checkrewind': _.bind(this.onCheckRewindChange,this), + 'animation:repeat': _.bind(this.onRepeatChange, this), + 'animation:additional': _.bind(this.onAnimationAdditional, this), + 'animation:trigger': _.bind(this.onTriggerClick, this), + 'animation:triggerclickof': _.bind(this.onTriggerClickOfClick, this), + 'animation:moveearlier': _.bind(this.onMoveEarlier, this), + 'animation:movelater': _.bind(this.onMoveLater, this), + 'animation:repeatchangebefore': _.bind(this.onRepeatChange, this), + 'animation:repeatchangeafter': _.bind(this.onRepeatChange, this), + 'animation:repeatselected': _.bind(this.onRepeatSelected, this) }, 'Toolbar': { 'tab:active': _.bind(this.onActiveTab, this) @@ -197,14 +200,32 @@ define([ this.api.asc_SetAnimationProperties(this.AnimationProperties); } }, + onRepeatChange: function (before,combo, record, e){ + var value, + me = this; + if(before) + { - onRepeatChange: function (field, newValue, oldValue, eOpts){ + } else { + + } + }, + + onRepeatSelected: function (combo, record) { if (this.api) { - this.AnimationProperties.asc_putRepeatCount(field.getNumberValue() * 1000); + this.AnimationProperties.asc_putRepeatCount(record.value); this.api.asc_SetAnimationProperties(this.AnimationProperties); } }, + onRepeatComboOpen: 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); + }, + onMoveEarlier: function () { if(this.api) { this.api.asc_moveAnimationEarlier(); @@ -250,6 +271,8 @@ define([ } }, + + onCheckRewindChange: function (field, newValue, oldValue, eOpts) { if (this.api && this.AnimationProperties) { this.AnimationProperties.asc_putRewind(field.getValue() == 'checked'); @@ -359,13 +382,8 @@ define([ this._state.Delay = value; view.numDelay.setValue((this._state.Delay !== null && this._state.Delay !== undefined) ? this._state.Delay / 1000. : '', true); } - value = this.AnimationProperties.asc_getRepeatCount(); - if (Math.abs(this._state.Repeat - value) > 0.001 || - (this._state.Repeat === null || value === null) && (this._state.Repeat !== value) || - (this._state.Repeat === undefined || value === undefined) && (this._state.Repeat !== value)) { - this._state.Repeat = value; - view.numRepeat.setValue((this._state.Repeat !== null && this._state.Repeat !== undefined) ? this._state.Repeat / 1000. : '', true); - } + this._state.Repeat = this.AnimationProperties.asc_getRepeatCount(); + view.cmbRepeat.setValue((this._state.Repeat !== null && this._state.Repeat !== undefined) ? this._state.Repeat/1000. : 1); this._state.StartSelect = this.AnimationProperties.asc_getStartType(); view.cmbStart.setValue(this._state.StartSelect!==undefined ? this._state.StartSelect : AscFormat.NODE_TYPE_CLICKEFFECT); diff --git a/apps/presentationeditor/main/app/template/Toolbar.template b/apps/presentationeditor/main/app/template/Toolbar.template index 6842594d2..c9c617790 100644 --- a/apps/presentationeditor/main/app/template/Toolbar.template +++ b/apps/presentationeditor/main/app/template/Toolbar.template @@ -260,7 +260,7 @@
- +
diff --git a/apps/presentationeditor/main/app/view/Animation.js b/apps/presentationeditor/main/app/view/Animation.js index 6a9e273a3..1dceb8b58 100644 --- a/apps/presentationeditor/main/app/view/Animation.js +++ b/apps/presentationeditor/main/app/view/Animation.js @@ -117,9 +117,21 @@ define([ }); } - if (me.numRepeat) { - me.numRepeat.on('change', function(bth) { - me.fireEvent('animation:repeat', [me.numRepeat]); + if (me.cmbRepeat) { + me.cmbRepeat.on('change:before', function (combo, record) { + me.fireEvent('animation:repeatchangebefore', [true, combo, record]); + }, me); + me.cmbRepeat.on('change:after', function (combo, record) { + me.fireEvent('animation:repeatchangeafter', [false, combo, record]); + }, me); + me.cmbRepeat.on('selected', function (combo, record) { + me.fireEvent('animation:repeatselected', [combo, record]); + }, me); + me.cmbRepeat.on('show:after', function (needfocus, combo) { + me.fireEvent('animation:repeatopen', [needfocus, combo]); + }, me); + me.cmbRepeat.on('combo:focusin', function (needfocus, combo) { + me.fireEvent('animation:repeatopen', [needfocus, combo]); }, me); } @@ -344,20 +356,27 @@ define([ }); this.lockedControls.push(this.chRewind); - this.numRepeat = new Common.UI.MetricSpinner({ + this.cmbRepeat = new Common.UI.ComboBox({ el: this.$el.find('#animation-spin-repeat'), - step: 1, - width: 55, - value: '', - maxValue: 1000, - minValue: 0, - defaultUnit: '', + cls: 'input-group-nr', + menuStyle: 'min-width: 100%;', + editable: true, lock: [_set.slideDeleted, _set.noSlides, _set.noGraphic, _set.noAnimation], + data: [ + {value: 1, displayValue: this.textNoRepeat}, + {value: 2, displayValue: "2"}, + {value: 3, displayValue: "3"}, + {value: 4, displayValue: "4"}, + {value: 5, displayValue: "5"}, + {value: 10, displayValue: "10"}, + {value: AscFormat.untilNextClick, displayValue: this.textUntilNextClick}, + {value: AscFormat.untilNextSlide, displayValue: this.textUntilEndOfSlide} + ], dataHint: '1', dataHintDirection: 'top', dataHintOffset: 'small' }); - this.lockedControls.push(this.numRepeat); + this.lockedControls.push(this.cmbRepeat); this.btnMoveEarlier = new Common.UI.Button({ parentEl: $('#animation-moveearlier'), @@ -457,7 +476,7 @@ define([ this.cmbStart && this.cmbStart.render(this.$el.find('#animation-start')); this.renderComponent('#animation-spin-duration', this.numDuration); this.renderComponent('#animation-spin-delay', this.numDelay); - this.renderComponent('#animation-spin-repeat', this.numRepeat); + this.renderComponent('#animation-spin-repeat', this.cmbRepeat); this.$el.find("#animation-duration").innerText = this.strDuration; this.$el.find("#animation-delay").innerText = this.strDelay; this.$el.find("#animation-label-start").innerText = this.strStart; @@ -534,7 +553,10 @@ define([ textMultiple: 'Multiple', textMoreEffects: 'Show More Effects', textMoveEarlier: 'Move Earlier', - textMoveLater: 'Move Later' + textMoveLater: 'Move Later', + textNoRepeat: '(none)', + textUntilNextClick: 'Until Next Click', + textUntilEndOfSlide: 'Until End of Slide' } }()), PE.Views.Animation || {}));