From ee55ea6bd9395ad87863cf67cc416eef27dfa0ae Mon Sep 17 00:00:00 2001 From: OVSharova Date: Mon, 29 Nov 2021 11:40:47 +0300 Subject: [PATCH] Add actions --- .../main/app/controller/Animation.js | 127 ++++++++++++------ .../main/app/view/Animation.js | 26 ++-- 2 files changed, 101 insertions(+), 52 deletions(-) diff --git a/apps/presentationeditor/main/app/controller/Animation.js b/apps/presentationeditor/main/app/controller/Animation.js index 0a05753bd..97e7120b3 100644 --- a/apps/presentationeditor/main/app/controller/Animation.js +++ b/apps/presentationeditor/main/app/controller/Animation.js @@ -70,6 +70,7 @@ define([ 'animation:animationpane':_.bind(this.onAnimationPane, this), 'animation:addanimation': _.bind(this.onAddAnimation, this), 'animation:startselect': _.bind(this.onStartSelect, this), + 'animation:checkrewind': _.bind(this.onCheckRewindChange,this), }, 'Toolbar': { 'tab:active': _.bind(this.onActiveTab, this) @@ -84,7 +85,6 @@ define([ setConfig: function (config) { this.appConfig = config.mode; - this.view = this.createView('PE.Views.Animation', { toolbar: config.toolbar, mode: config.mode @@ -121,64 +121,90 @@ define([ onParameterClick: function (value) { this._state.EffectOption = value; + if(this.api && this.AnimationProperties) { + this.AnimationProperties.asc_putSubtype(value); + this.api.asc_SetAnimationProperties(this.AnimationProperties); + this.getAnimationProperties(); + + console.log(this.AnimationProperties.asc_getSubtype()); + } }, - onAnimationPane: function() { + onAnimationPane: function(combo, record) { }, onAddAnimation: function() { - + var type = record.get('value'); + var parameter; + var group = Common.define.effectData.getEffectGroupData().findWhere({id: record.group}).value; + if (this._state.Effect !== type) { + parameter= this.view.setMenuParameters(type, undefined, group == this._state.EffectGroups); + this.api.asc_AddAnimation(this._state.EffectGroups, type, parameter); + if (parameter!= undefined) + this.onParameterClick(parameter); + } + this._state.EffectGroups = group; + this._state.Effect = type; }, onDurationChange: function(field, newValue, oldValue, eOpts) { - this._state.Duration = field.getNumberValue()*1000; + if (this.api) { + this._state.Duration = field.getNumberValue() * 1000; + this.AnimationProperties.asc_putDuration(this._state.Duration); + this.api.asc_SetAnimationProperties(this.AnimationProperties); + } }, onDelayChange: function(field, newValue, oldValue, eOpts) { - this._state.Delay = field.getNumberValue()*1000; + if (this.api) { + this._state.Delay = field.getNumberValue() * 1000; + this.AnimationProperties.asc_putDelay(this._state.Delay); + this.api.asc_SetAnimationProperties(this.AnimationProperties); + } }, onEffectSelect: function (combo, record) { - var type = record.get('value'); - var parameter = this._state.EffectOption; - - if (this.Effect !== type) { - parameter = this.view.setMenuParameters(type, parameter, true); - if (type != -10 && this.Effect == -10) - this.api.asc_AddAnimation(this.EffectGroups.findWhere({id: record.group}).value, type); - else - { - var selectedElements = this.api.getSelectedElements(); - for (var i = 0; i < selectedElements.length; i0) { - var elType = selectedElements[i].get_ObjectType(); - if(elType==Asc.c_oAscTypeSelectElement.Animation) - { - //selectedElements[i]. - } - } + var type = record.get('value'); + var parameter; + var group = _.findWhere(Common.define.effectData.getEffectGroupData(),{id: record.get('group')}).value; + if (this._state.Effect !== type) { + parameter= this.view.setMenuParameters(type, undefined, group != this._state.EffectGroups); + this.api.asc_AddAnimation(group, type, parameter); + if (parameter!= undefined) { + this.onParameterClick(parameter); } + //else this.api.asc_AddAnimation(group, type,-1); } + this._state.EffectGroups = group; this._state.Effect = type; - this.onParameterClick(parameter); }, onStartSelect: function (combo, record) { + if (this.api) { + this._state.StartEffect =record.value; + this.AnimationProperties.asc_putStartType(this._state.StartEffect); + this.api.asc_SetAnimationProperties(this.AnimationProperties); + } + }, + onCheckRewindChange: function (field, newValue, oldValue, eOpts) { + if (this.api && this.AnimationProperties) { + this.AnimationProperties.asc_putRewind(field.getValue() == 'checked'); + this.api.asc_SetAnimationProperties(this.AnimationProperties); + } }, onFocusObject: function(selectedObjects) { - var me = this; for (var i = 0; i 0.001 || (this._state.Duration === null || value === null) && (this._state.Duration !== value) || (this._state.Duration === undefined || value === undefined) && (this._state.Duration !== value)) { this._state.Duration = value; } - value = 1000; + value = this.AnimationProperties.asc_getDelay(); if (Math.abs(this._state.Delay - value) > 0.001 || (this._state.Delay === null || value === null) && (this._state.Delay !== value) || (this._state.Delay === undefined || value === undefined) && (this._state.Delay !== value)) { this._state.Delay = value; } - - this._state.StartSelect = 0; + this._state.StartSelect = this.AnimationProperties.asc_getStartType(); + this._state.RepeatCount = this.AnimationProperties.asc_getRepeatCount(); + this._state.Rewind = this.AnimationProperties.asc_getRewind(); }, onActiveTab: function(tab) { @@ -239,17 +280,15 @@ define([ } if (me.btnParameters.menu.items.length > 0 && this._state.EffectOption !== undefined) - me.setMenuParameters(this._state.Effect, this._state.EffectOption); + me.setMenuParameters(this._state.Effect, this._state.EffectOption, true); me.numDuration.setValue((this._state.Duration !== null && this._state.Duration !== undefined) ? this._state.Duration / 1000. : '', true); me.numDelay.setValue((this._state.Delay !== null && this._state.Delay !== undefined) ? this._state.Delay / 1000. : '', true); + + (this._state.StartSelect==undefined)&&(this._state.StartSelect = AscFormat.NODE_TYPE_CLICKEFFECT); item = me.cmbStart.store.findWhere({value: this._state.StartSelect}); - me.cmbStart.selectRecord(item ? item : me.cmbStart.items[0]); - - - //this.view.setWidthRow(); - - + me.cmbStart.selectRecord(item); + me.chRewind.setValue(this._state.Rewind); } }, PE.Controllers.Animation || {})); diff --git a/apps/presentationeditor/main/app/view/Animation.js b/apps/presentationeditor/main/app/view/Animation.js index 26ca23310..56a39d04e 100644 --- a/apps/presentationeditor/main/app/view/Animation.js +++ b/apps/presentationeditor/main/app/view/Animation.js @@ -111,6 +111,12 @@ define([ }, me); } + if (me.chRewind) { + me.chRewind.on('change', _.bind(function (e) { + me.fireEvent('animation:checkrewind', [me.chRewind, me.chRewind.value, me.chRewind.lastValue]); + }, me)); + } + } return { @@ -270,9 +276,9 @@ define([ menuStyle: 'width: 150px;', //lock: [_set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides, _set.noTextSelected, _set.shapeLock], data: [ - {value: 0, displayValue: this.textStartOnClick}, - {value: 1, displayValue: this.textStartBeforePrevious}, - {value: 2, displayValue: this.textStartAfterPrevious} + {value: AscFormat.NODE_TYPE_CLICKEFFECT, displayValue: this.textStartOnClick}, + {value: AscFormat.NODE_TYPE_WITHEFFECT, displayValue: this.textStartWithPrevious}, + {value: AscFormat.NODE_TYPE_AFTEREFFECT, displayValue: this.textStartAfterPrevious} ], dataHint: '1', dataHintDirection: 'top' @@ -444,12 +450,16 @@ define([ var selectedElement; this.btnParameters.menu.removeAll(); - //if(this._arrEffectOptions[effect.value].length>0) { if(this._arrEffectOptions[effect.value]) { - this._arrEffectOptions[effect.value].forEach(function (opt) { + var i=0; + this._arrEffectOptions[effect.value].forEach(function (opt, index) { this.btnParameters.menu.addItem(opt); + this.btnParameters.menu.items[index].checkable=true; + if((option!=undefined)&&(opt.value==option)) + i = index; }, this); - selectedElement = this.btnParameters.menu.items[0]; + selectedElement = this.btnParameters.menu.items[i]; + selectedElement.setChecked(true); } else { selectedElement = undefined; @@ -459,7 +469,7 @@ define([ this.btnParameters.setDisabled(!selectedElement); } - return (selectedElement)?selectedElement.value:-1; + return (selectedElement)?selectedElement.value:undefined; }, @@ -476,7 +486,7 @@ define([ strTrigger: 'Trigger', textStartOnClick: 'On Click', - textStartBeforePrevious: 'Before Previous', + textStartWithPrevious: 'With Previous', textStartAfterPrevious: 'After Previous', textNone: 'None',