Merge pull request #1473 from ONLYOFFICE/feature/change-repeat-for-animation

Change repeat for animation
This commit is contained in:
Julia Radzhabova 2022-01-14 11:58:42 +03:00 committed by GitHub
commit 309562657a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 122 additions and 54 deletions

View file

@ -774,10 +774,10 @@ define(function(){ 'use strict';
textToRight: 'To Right',
textToBottomRight: 'To Bottom-Right',
textSpoke1: '1 Spoke',
textSpoke2: '2 Spoke',
textSpoke3: '3 Spoke',
textSpoke4: '4 Spoke',
textSpoke8: '8 Spoke',
textSpoke2: '2 Spokes',
textSpoke3: '3 Spokes',
textSpoke4: '4 Spokes',
textSpoke8: '8 Spokes',
textCustomPath: 'Custom Path',
textHorizontalIn: 'Horizontal In',
textHorizontalOut: 'Horizontal Out',
@ -1132,10 +1132,10 @@ define(function(){ 'use strict';
case AscFormat.ENTRANCE_WHEEL:
return [
{value: AscFormat.ENTRANCE_WHEEL_1_SPOKE, caption: this.textSpoke1},
{value: AscFormat.ENTRANCE_WHEEL_2_SPOKE, caption: this.textSpoke2},
{value: AscFormat.ENTRANCE_WHEEL_3_SPOKE, caption: this.textSpoke3},
{value: AscFormat.ENTRANCE_WHEEL_4_SPOKE, caption: this.textSpoke4},
{value: AscFormat.ENTRANCE_WHEEL_8_SPOKE, caption: this.textSpoke8}
{value: AscFormat.ENTRANCE_WHEEL_2_SPOKES, caption: this.textSpoke2},
{value: AscFormat.ENTRANCE_WHEEL_3_SPOKES, caption: this.textSpoke3},
{value: AscFormat.ENTRANCE_WHEEL_4_SPOKES, caption: this.textSpoke4},
{value: AscFormat.ENTRANCE_WHEEL_8_SPOKES, caption: this.textSpoke8}
];
case AscFormat.ENTRANCE_WIPE_FROM:
return [
@ -1248,10 +1248,10 @@ define(function(){ 'use strict';
case AscFormat.EXIT_WHEEL:
return [
{value: AscFormat.EXIT_WHEEL_1_SPOKE, caption: this.textSpoke1},
{value: AscFormat.EXIT_WHEEL_2_SPOKE, caption: this.textSpoke2},
{value: AscFormat.EXIT_WHEEL_3_SPOKE, caption: this.textSpoke3},
{value: AscFormat.EXIT_WHEEL_4_SPOKE, caption: this.textSpoke4},
{value: AscFormat.EXIT_WHEEL_8_SPOKE, caption: this.textSpoke8}
{value: AscFormat.EXIT_WHEEL_2_SPOKES, caption: this.textSpoke2},
{value: AscFormat.EXIT_WHEEL_3_SPOKES, caption: this.textSpoke3},
{value: AscFormat.EXIT_WHEEL_4_SPOKES, caption: this.textSpoke4},
{value: AscFormat.EXIT_WHEEL_8_SPOKES, caption: this.textSpoke8}
];
case AscFormat.EXIT_WIPE_FROM:
return [

View file

@ -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: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:repeatchange': _.bind(this.onRepeatChange, this),
'animation:repeatfocusin': _.bind(this.onRepeatComboOpen, this),
'animation:repeatselected': _.bind(this.onRepeatSelected, this)
},
'Toolbar': {
'tab:active': _.bind(this.onActiveTab, this)
@ -197,14 +200,60 @@ define([
this.api.asc_SetAnimationProperties(this.AnimationProperties);
}
},
onRepeatChange: function (before,combo, record, e){
var value,
me = this;
if(before)
{
var item = combo.store.findWhere({
displayValue: record.value
});
onRepeatChange: function (field, newValue, oldValue, eOpts){
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');
}
return false;
}
}
} else {
value = Common.Utils.String.parseFloat(record.value);
if(!record.displayValue)
value = value > 9999 ? 9999 :
value < 1 ? 1 : Math.floor((value+0.4)*2)/2;
combo.setValue(value);
if (this.api) {
this.AnimationProperties.asc_putRepeatCount(value);
this.api.asc_SetAnimationProperties(this.AnimationProperties);
}
}
},
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 +299,8 @@ define([
}
},
onCheckRewindChange: function (field, newValue, oldValue, eOpts) {
if (this.api && this.AnimationProperties) {
this.AnimationProperties.asc_putRewind(field.getValue() == 'checked');
@ -359,13 +410,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 !== undefined ? 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);

View file

@ -260,7 +260,7 @@
<div class="group small">
<div class="elset font-normal">
<label id="animation-repeat"></label>
<span id="animation-spin-repeat" class="btn-slot text spinner" ></span>
<div id="animation-spin-repeat" style="width: 96px; " class="btn-slot" ></div>
</div>
<div class="elset font-normal">
<span class="btn-slot text" id="animation-checkbox-rewind"></span>

View file

@ -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('changed:before', function (combo, record) {
me.fireEvent('animation:repeatchange', [true, combo, record]);
}, me);
me.cmbRepeat.on('changed:after', function (combo, record) {
me.fireEvent('animation:repeatchange', [false, combo, record]);
}, me);
me.cmbRepeat.on('selected', function (combo, record) {
me.fireEvent('animation:repeatselected', [combo, record]);
}, me);
me.cmbRepeat.on('show:after', function (combo) {
me.fireEvent('animation:repeatfocusin', [true, combo]);
}, me);
me.cmbRepeat.on('combo:focusin', function (combo) {
me.fireEvent('animation:repeatfocusin', [false, 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 || {}));

View file

@ -194,10 +194,10 @@
"Common.define.effectData.textSpiralRight": "Spiral Right",
"Common.define.effectData.textSplit": "Split",
"Common.define.effectData.textSpoke1": "1 Spoke",
"Common.define.effectData.textSpoke2": "2 Spoke",
"Common.define.effectData.textSpoke3": "3 Spoke",
"Common.define.effectData.textSpoke4": "4 Spoke",
"Common.define.effectData.textSpoke8": "8 Spoke",
"Common.define.effectData.textSpoke2": "2 Spokes",
"Common.define.effectData.textSpoke3": "3 Spokes",
"Common.define.effectData.textSpoke4": "4 Spokes",
"Common.define.effectData.textSpoke8": "8 Spokes",
"Common.define.effectData.textSpring": "Spring",
"Common.define.effectData.textSquare": "Square",
"Common.define.effectData.textStairsDown": "Stairs Down",