Merge branch 'feature/animation_tab' into feature/combo-data-view-animation

This commit is contained in:
Julia Radzhabova 2021-12-03 12:13:31 +03:00
commit 83a5f74c03
4 changed files with 1007 additions and 2292 deletions

File diff suppressed because it is too large Load diff

View file

@ -63,18 +63,19 @@ 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: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)
},
'Toolbar': {
'tab:active': _.bind(this.onActiveTab, this)
'tab:active': _.bind(this.onActiveTab, this)
}
});
this.EffectGroups = Common.define.effectData.getEffectGroupData();
@ -87,16 +88,16 @@ define([
setConfig: function (config) {
this.appConfig = config.mode;
this.view = this.createView('PE.Views.Animation', {
toolbar: config.toolbar,
mode: config.mode
toolbar : config.toolbar,
mode : config.mode
});
return this;
},
setApi: function (api) {
this.api = api;
this.api.asc_registerCallback('asc_onFocusObject', _.bind(this.onFocusObject, this));
this.api.asc_registerCallback('asc_onCountPages', _.bind(this.onApiCountPages, this));
this.api.asc_registerCallback('asc_onFocusObject', _.bind(this.onFocusObject, this));
this.api.asc_registerCallback('asc_onCountPages', _.bind(this.onApiCountPages, this));
return this;
},
@ -125,36 +126,28 @@ define([
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() {
(new PE.Views.AnimationDialog({
api: this.api,
activEffect: this.Effect
api : this.api,
activeEffect : this._state.Effect
})).show();
},
onAddAnimation: function(picker, record) {
var type = record.get('value');
var group = _.findWhere(Common.define.effectData.getEffectGroupData(),{id: record.get('group')}).value;
this.addNewEffect(type, group);
this._state.EffectGroups = group;
this._state.Effect = type;
var group = _.findWhere(Common.define.effectData.getEffectGroupData(), {id: record.get('group')}).value;
this.addNewEffect(type, group, false);
},
addNewEffect: function (type, group, replace) {
if (this._state.Effect == type) return;
var parameter= this.view.setMenuParameters(type, undefined, group == this._state.EffectGroups);
this.api.asc_AddAnimation(this._state.EffectGroups, type, parameter!==undefined ? parameter : 0, !!replace);
if (parameter!= undefined)
this.onParameterClick(parameter);
var parameter = this.view.setMenuParameters(type, undefined, group == this._state.EffectGroups);
this.api.asc_AddAnimation(group, type, (parameter != undefined)?parameter:0, replace);
this._state.EffectGroups = group;
this._state.Effect = type;
},
onDurationChange: function(field, newValue, oldValue, eOpts) {
@ -173,17 +166,24 @@ define([
}
},
onRepeatChange: function (field, newValue, oldValue, eOpts){
if (this.api) {
this._state.Repeat = field.getNumberValue() * 1000;
this.AnimationProperties.asc_putRepeatCount(this._state.Repeat);
this.api.asc_SetAnimationProperties(this.AnimationProperties);
}
},
onEffectSelect: function (combo, record) {
var type = record.get('value');
var group = _.findWhere(Common.define.effectData.getEffectGroupData(),{id: record.get('group')}).value;
this.addNewEffect(type, group, true);
this._state.EffectGroups = group;
this._state.Effect = type;
if (this.api) {
var type = record.get('value');
var group = (type != AscFormat.ANIM_PRESET_NONE) ? _.findWhere(Common.define.effectData.getEffectGroupData(), {id: record.get('group')}).value : undefined;
this.addNewEffect(type, group, this._state.Effect != AscFormat.ANIM_PRESET_NONE);
}
},
onStartSelect: function (combo, record) {
if (this.api) {
this._state.StartEffect =record.value;
this._state.StartEffect = record.value;
this.AnimationProperties.asc_putStartType(this._state.StartEffect);
this.api.asc_SetAnimationProperties(this.AnimationProperties);
}
@ -197,6 +197,7 @@ define([
},
onFocusObject: function(selectedObjects) {
var isAnimtionObject = false, isAnimation = false;
for (var i = 0; i<selectedObjects.length; i++) {
var eltype = selectedObjects[i].get_ObjectType();
@ -205,24 +206,48 @@ define([
if (eltype == Asc.c_oAscTypeSelectElement.Animation) {
this.AnimationProperties = selectedObjects[i].get_ObjectValue();
this.loadSettings(this.AnimationProperties);
if (this._state.onactivetab) {
this.setLocked();
this.setSettings();
isAnimation = true;
}
}
}
},
getAnimationProperties: function() {
var selectedElements = this.api.getSelectedElements();
for (var i = 0; i<selectedElements.length; i++) {
if (selectedElements[i].get_ObjectType() === Asc.c_oAscTypeSelectElement.Animation) {
this.AnimationProperties = selectedElements[i].get_ObjectValue();
return;
else if((eltype == Asc.c_oAscTypeSelectElement.Shape) ||
(eltype == Asc.c_oAscTypeSelectElement.Tab) ||
(eltype == Asc.c_oAscTypeSelectElement.Text) ||
(eltype == Asc.c_oAscTypeSelectElement.Image)) {
isAnimtionObject = true;
}
}
return;
this.setLockedByObjects (isAnimtionObject, isAnimation);
},
setLockedByObjects: function (isAnimtionObject, isAnimation) {
if(isAnimtionObject)
{
if(isAnimation) {
if (this._state.Effect == AscFormat.ANIM_PRESET_NONE) {
this.view.setDisabled(true);
this.view.listEffects.setDisabled(false);
this.view.effectId = AscFormat.ANIM_PRESET_NONE;
} else {
this.view.setDisabled(false);
this.view.btnParameters.setDisabled(this.view.btnParameters.menu.items.length == 0)
}
}
else {
this.view.setDisabled(true);
this.view.listEffects.setDisabled(false);
}
}
else
this.view.setDisabled(true);
this.view.btnAddAnimation.setDisabled(this.view.listEffects.isDisabled());
},
loadSettings: function (props) {
@ -230,9 +255,8 @@ define([
var value;
this._state.EffectGroup = this.AnimationProperties.asc_getClass();
value = this.AnimationProperties.asc_getType();
value = !value ? AscFormat.ANIM_PRESET_NONE : value;
(value == undefined) && (value = AscFormat.ANIM_PRESET_NONE);
this._state.EffectOption = this.AnimationProperties.asc_getSubtype();
this.view.setMenuParameters(value,this._state.EffectOption,true);
this._state.Effect = value;
value = this.AnimationProperties.asc_getDuration();
@ -248,6 +272,14 @@ define([
(this._state.Delay === undefined || value === undefined) && (this._state.Delay !== value)) {
this._state.Delay = value;
}
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;
}
this._state.StartSelect = this.AnimationProperties.asc_getStartType();
this._state.RepeatCount = this.AnimationProperties.asc_getRepeatCount();
this._state.Rewind = this.AnimationProperties.asc_getRewind();
@ -256,6 +288,7 @@ define([
onActiveTab: function(tab) {
if (tab == 'animate') {
this._state.onactivetab = true;
this.setLocked();
this.setSettings();
}
@ -267,8 +300,8 @@ define([
},
setLocked: function() {
if (this._state.lockedtransition != undefined)
this.lockToolbar(PE.enumLock.transitLock, this._state.lockedtransition);
/* if (this._state.lockedanimation != undefined)
this.lockToolbar(PE.enumLock.animationLock, this._state.lockedanimation);*/
},
setSettings: function () {
@ -280,11 +313,12 @@ define([
this.view.btnParameters.setIconCls('toolbar__icon icon ' + item.get('imageUrl'));
}
if (me.btnParameters.menu.items.length > 0 && this._state.EffectOption !== undefined)
me.setMenuParameters(this._state.Effect, this._state.EffectOption, true);
if (this._state.EffectOption !== undefined)
me.setMenuParameters(this._state.Effect, this._state.EffectOption);
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);
me.numRepeat.setValue((this._state.Repeat !== null && this._state.Repeat !== undefined) ? this._state.Repeat / 1000. : '', true);
(this._state.StartSelect==undefined)&&(this._state.StartSelect = AscFormat.NODE_TYPE_CLICKEFFECT);
item = me.cmbStart.store.findWhere({value: this._state.StartSelect});

View file

@ -178,7 +178,7 @@ define([
caption: this.txtPreview,
split: false,
iconCls: 'toolbar__icon preview-transitions',
//lock: [_set.slideDeleted, _set.noSlides, _set.disableOnStart, _set.transitLock],
//lock: [_set.slideDeleted, _set.noSlides, _set.disableOnStart],
dataHint: '1',
dataHintDirection: 'left',
dataHintOffset: 'medium'
@ -219,6 +219,7 @@ define([
dataHintDirection: 'bottom',
dataHintOffset: 'small'
});
this.lockedControls.push(this.btnAddAnimation);
this.numDuration = new Common.UI.MetricSpinner({
@ -296,6 +297,7 @@ define([
value: '',
maxValue: 1000,
minValue: 0,
defaultUnit: '',
//lock: [_set.slideDeleted, _set.noSlides, _set.disableOnStart, _set.transitLock],
dataHint: '1',
dataHintDirection: 'bottom',
@ -319,43 +321,6 @@ define([
return this;
},
createParametersMenuItems: function()
{
var arrEffectType = [
{caption: this.textSmoothly, value: Asc.c_oAscSlideTransitionParams.Fade_Smoothly},
{caption: this.textBlack, value: Asc.c_oAscSlideTransitionParams.Fade_Through_Black},
{caption: this.textLeft, value: Asc.c_oAscSlideTransitionParams.Param_Left},
{caption: this.textTop, value: Asc.c_oAscSlideTransitionParams.Param_Top},
{caption: this.textRight, value: Asc.c_oAscSlideTransitionParams.Param_Right},
{caption: this.textBottom, value: Asc.c_oAscSlideTransitionParams.Param_Bottom},
{caption: this.textTopLeft, value: Asc.c_oAscSlideTransitionParams.Param_TopLeft},
{caption: this.textTopRight, value: Asc.c_oAscSlideTransitionParams.Param_TopRight},
{caption: this.textBottomLeft, value: Asc.c_oAscSlideTransitionParams.Param_BottomLeft},
{caption: this.textBottomRight, value: Asc.c_oAscSlideTransitionParams.Param_BottomRight},
{caption: this.textVerticalIn, value: Asc.c_oAscSlideTransitionParams.Split_VerticalIn},
{caption: this.textVerticalOut, value: Asc.c_oAscSlideTransitionParams.Split_VerticalOut},
{caption: this.textHorizontalIn, value: Asc.c_oAscSlideTransitionParams.Split_HorizontalIn},
{caption: this.textHorizontalOut, value: Asc.c_oAscSlideTransitionParams.Split_HorizontalOut},
{caption: this.textClockwise, value: Asc.c_oAscSlideTransitionParams.Clock_Clockwise},
{caption: this.textCounterclockwise, value: Asc.c_oAscSlideTransitionParams.Clock_Counterclockwise},
{caption: this.textWedge, value: Asc.c_oAscSlideTransitionParams.Clock_Wedge},
{caption: this.textZoomIn, value: Asc.c_oAscSlideTransitionParams.Zoom_In},
{caption: this.textZoomOut, value: Asc.c_oAscSlideTransitionParams.Zoom_Out},
{caption: this.textZoomRotate, value: Asc.c_oAscSlideTransitionParams.Zoom_AndRotate}
];
var itemsMenu = [];
_.each(arrEffectType, function (item) {
itemsMenu.push({
caption: item.caption,
value: item.value,
checkable: true,
toggleGroup: 'effects'
});
});
return itemsMenu;
},
onAppReady: function (config) {
var me = this;
(new Promise(function (accept, reject) {
@ -459,42 +424,38 @@ define([
this.widthDuration = this.widthRow(this.$el.find("#animation-duration"), this.$el.find("#animation-label-trigger"),this.widthDuration);
},
setMenuParameters: function (effectId, option, reload)
setMenuParameters: function (effectId, option)
{
var effect = this.listEffects.store.findWhere({value: effectId}).attributes;
if(reload) {
this._arrEffectOptions = Common.define.effectData.getEffectOptionsData(effect.group);
}
var effect = this.listEffects.store.findWhere({value: effectId});
var arrEffectOptions = Common.define.effectData.getEffectOptionsData(effect.get('group'), effect.get('value'));
if (!this.listEffects.isDisabled()) {
this.btnParameters.setDisabled(effect.group === 'none' || !this._arrEffectOptions);
this.btnPreview.setDisabled(effect.group === 'none');
this.numDuration.setDisabled(effect.group === 'none');
this.btnParameters.setDisabled(!arrEffectOptions);
}
if(!this._arrEffectOptions)
return undefined;
if(!arrEffectOptions) {
this.btnParameters.menu.removeAll();
this._effectId = effectId
return undefined;
}
var selectedElement;
this.btnParameters.menu.removeAll();
if(this._arrEffectOptions[effect.value] && this._arrEffectOptions[effect.value].length>0) {
var i=0;
this._arrEffectOptions[effect.value].forEach(function (opt, index) {
if (this._effectId != effectId) {
this.btnParameters.menu.removeAll();
arrEffectOptions.forEach(function (opt, index) {
opt.checkable = true;
opt.toggleGroup ='animateeffects';
this.btnParameters.menu.addItem(opt);
this.btnParameters.menu.items[index].checkable=true;
if((option!=undefined)&&(opt.value==option))
i = index;
(opt.value==option) && (selectedElement = this.btnParameters.menu.items[index]);
}, this);
selectedElement = this.btnParameters.menu.items[i];
selectedElement.setChecked(true);
}
else {
selectedElement = undefined;
this.btnParameters.menu.items.forEach(function (opt) {
(opt.value == option) && (selectedElement = opt);
});
}
if (!this.listEffects.isDisabled()) {
this.btnParameters.setDisabled(!selectedElement);
}
return (selectedElement)?selectedElement.value:undefined;
(selectedElement == undefined) && (selectedElement = this.btnParameters.menu.items[0])
selectedElement.setChecked(true);
this._effectId = effectId;
return selectedElement.value;
},
@ -509,41 +470,10 @@ define([
strRewind: 'Rewind',
strRepeat: 'Repeat',
strTrigger: 'Trigger',
textStartOnClick: 'On Click',
textStartWithPrevious: 'With Previous',
textStartAfterPrevious: 'After Previous',
textNone: 'None',
textFade: 'Fade',
textPush: 'Push',
textWipe: 'Wipe',
textSplit: 'Split',
textUnCover: 'UnCover',
textCover: 'Cover',
textClock: 'Clock',
textZoom: 'Zoom',
textSmoothly: 'Smoothly',
textBlack: 'Through Black',
textLeft: 'Left',
textTop: 'Top',
textRight: 'Right',
textBottom: 'Bottom',
textTopLeft: 'Top-Left',
textTopRight: 'Top-Right',
textBottomLeft: 'Bottom-Left',
textBottomRight: 'Bottom-Right',
textVerticalIn: 'Vertical In',
textVerticalOut: 'Vertical Out',
textHorizontalIn: 'Horizontal In',
textHorizontalOut: 'Horizontal Out',
textClockwise: 'Clockwise',
textCounterclockwise: 'Counterclockwise',
textWedge: 'Wedge',
textZoomIn: 'Zoom In',
textZoomOut: 'Zoom Out',
textZoomRotate: 'Zoom and Rotate'
textNone: 'None'
}
}()), PE.Views.Animation || {}));

View file

@ -64,17 +64,15 @@ define([
this.allEffects = Common.define.effectData.getEffectFullData();
this.options.tpl = _.template(this.template)(this.options);
this.api = this.options.api;
this.activEffect = this.options.Effect;
if (this.activEffect != undefined) {
var itemEffect= this.allEffects.findWhere({value: this.activEffect});
this.activeEffect = this.options.Effect;
if (this.activeEffect != undefined) {
var itemEffect= this.allEffects.findWhere({value: this.activeEffect});
this.activeGroup = itemEffect.group;
this.activeLevel = itemEffect.level;
}
Common.UI.Window.prototype.initialize.call(this, this.options);
},
setEvents: function() {
this.cmbGroup.on('selected', _.bind(this.onGroupSelect,this));
} ,
render: function() {
Common.UI.Window.prototype.render.call(this);
@ -92,35 +90,45 @@ define([
data : Common.define.effectData.getEffectGroupData(),
value : (this.activEffect != undefined)?this.activeGroup:undefined
});
this.cmbGroup.on('selected', _.bind(this.onGroupSelect,this));
this.cmbLevel = new Common.UI.ComboBox({
el : $('#animation-level'),
cls: 'input-group-nr',
editable: false,
style : 'margin-top: 16px; width: 100%;',
takeFocusOnClose: true,
data : Common.define.effectData.getLevelEffect(false)
takeFocusOnClose: true
});
this.cmbLevel.on('selected', _.bind(this.onLevelSelect,this));
this.lstEffectList = new Common.UI.ListView({
el : $('#animation-list'),
scroll : true,
data : (this.activEffect != undefined)?this.allEffects.where({group: this.activeGroup, level: this.activeLevel}):undefined
itemTemplate: _.template('<div id="<%= id %>" class="list-item" style=""><%= displayValue %></div>'),
scroll : true
});
this.chPreview = new Common.UI.CheckBox({
el : $('#animation-setpreview'),
labelText : this.textPreviewEffect
});
this.setEvents.call(this);
this.cmbGroup.selectRecord(this.cmbGroup.store.models[0]);
this.onGroupSelect(undefined,this.cmbGroup.store.models[0]);
},
onGroupSelect: function (combo, record) {
this.activeGroup = record.value;
this.cmbLevel.data=Common.define.effectData.getLevelEffect(record.id == 'menu-effect-group-path');
this.cmbLevel.setValue(this.cmbLevel.data[0].displayValue);
this.activeGroup = record.id;
this.cmbLevel.store.reset(Common.define.effectData.getLevelEffect(record.id == 'menu-effect-group-path'));
this.cmbLevel.selectRecord(this.cmbLevel.store.models[0]);
this.onLevelSelect(undefined,this.cmbLevel.store.models[0]);
},
onLevelSelect: function (combo, record) {
this.activeLevel = record.id;
var arr = _.where(this.allEffects, {group: this.activeGroup, level: this.activeLevel });
this.lstEffectList.store.reset(arr);
this.lstEffectList.selectRecord(this.lstEffectList.store.models[0]);
},
textTitle: 'More Effects',
textPreviewEffect: 'Preview Effect'