2021-12-01 05:08:41 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* (c) Copyright Ascensio System SIA 2010-2019
|
|
|
|
*
|
|
|
|
* This program is a free software product. You can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
|
|
|
* version 3 as published by the Free Software Foundation. In accordance with
|
|
|
|
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
|
|
|
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
|
|
|
* of any third-party rights.
|
|
|
|
*
|
|
|
|
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
|
|
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
|
|
|
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
|
|
|
*
|
|
|
|
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
|
|
|
|
* street, Riga, Latvia, EU, LV-1050.
|
|
|
|
*
|
|
|
|
* The interactive user interfaces in modified source and object code versions
|
|
|
|
* of the Program must display Appropriate Legal Notices, as required under
|
|
|
|
* Section 5 of the GNU AGPL version 3.
|
|
|
|
*
|
|
|
|
* Pursuant to Section 7(b) of the License you must retain the original Product
|
|
|
|
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
|
|
|
* grant you any rights under trademark law for use of our trademarks.
|
|
|
|
*
|
|
|
|
* All the Product's GUI elements, including illustrations and icon sets, as
|
|
|
|
* well as technical writing content are licensed under the terms of the
|
|
|
|
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
|
|
|
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* AnimationDialog.js
|
|
|
|
*
|
|
|
|
* Created by Olga Sharova on 29/11/21
|
|
|
|
* Copyright (c) 2021 Ascensio System SIA. All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
define([
|
|
|
|
'common/main/lib/component/Window'
|
|
|
|
], function () { 'use strict';
|
|
|
|
PE.Views.AnimationDialog = Common.UI.Window.extend(_.extend({
|
|
|
|
options: {
|
|
|
|
width: 350,
|
|
|
|
height: 426,
|
|
|
|
header: true,
|
|
|
|
cls: 'animation-dlg',
|
|
|
|
buttons: ['ok', 'cancel']
|
|
|
|
},
|
|
|
|
initialize : function(options) {
|
|
|
|
_.extend(this.options, {
|
|
|
|
title: this.textTitle
|
|
|
|
}, options || {});
|
|
|
|
this.template = [
|
|
|
|
'<div class="box" style="width: 318px; margin: 0 auto">',
|
|
|
|
'<div class = "input-row" id = "animation-group"></div>',
|
|
|
|
'<div class = "input-row" id = "animation-level" ></div>',
|
|
|
|
'<div class = "input-row" id = "animation-list" style = "margin-top: 16px; height: 216px;"></div>',
|
|
|
|
'<div class = "input-row" id = "animation-setpreview" style = "margin: 16px 0;"></div>',
|
|
|
|
'</div>'
|
|
|
|
].join('');
|
|
|
|
this.allEffects = Common.define.effectData.getEffectFullData();
|
|
|
|
this.options.tpl = _.template(this.template)(this.options);
|
|
|
|
this.api = this.options.api;
|
2021-12-08 01:28:30 +00:00
|
|
|
this._state=[];
|
|
|
|
this.handler = this.options.handler;
|
2021-12-07 05:40:03 +00:00
|
|
|
this.EffectGroupData = Common.define.effectData.getEffectGroupData();
|
2021-12-10 18:39:27 +00:00
|
|
|
this._state.activeGroup = this.EffectGroupData[0].id;
|
|
|
|
this._state.activeGroupValue = this.EffectGroupData[0].value;
|
2021-12-07 05:40:03 +00:00
|
|
|
this.EffectGroupData.forEach(function (item) {item.displayValue = item.caption;});
|
2021-12-23 10:53:47 +00:00
|
|
|
if ((this.options.activeEffect != undefined) && (this.options.activeEffect != AscFormat.ANIM_PRESET_NONE) && (this.options.activeEffect !== AscFormat.ANIM_PRESET_MULTIPLE)){
|
2021-12-10 18:39:27 +00:00
|
|
|
this._state.activeEffect = this.options.activeEffect;
|
2021-12-20 16:07:49 +00:00
|
|
|
this._state.activeGroupValue = this.options.groupValue;
|
2021-12-23 12:53:38 +00:00
|
|
|
var group = _.findWhere(this.EffectGroupData, {value: this._state.activeGroupValue})
|
|
|
|
this._state.activeGroup = group.id;
|
|
|
|
var itemEffect = _.findWhere(this.allEffects, {
|
|
|
|
group: this._state.activeGroup,
|
|
|
|
value: this._state.activeEffect
|
|
|
|
});
|
|
|
|
if(itemEffect)
|
|
|
|
this.activeLevel = itemEffect.level;
|
|
|
|
|
2021-12-01 05:08:41 +00:00
|
|
|
}
|
|
|
|
Common.UI.Window.prototype.initialize.call(this, this.options);
|
|
|
|
},
|
2021-12-03 03:46:24 +00:00
|
|
|
|
2021-12-01 05:08:41 +00:00
|
|
|
render: function() {
|
|
|
|
Common.UI.Window.prototype.render.call(this);
|
|
|
|
|
|
|
|
var $window = this.getChild();
|
|
|
|
|
|
|
|
var footer = $window.find('.footer');
|
|
|
|
footer.css({"text-align": "center"});
|
|
|
|
|
|
|
|
this.cmbGroup = new Common.UI.ComboBox({
|
|
|
|
el : $('#animation-group'),
|
|
|
|
cls: 'input-group-nr',
|
|
|
|
editable: false,
|
|
|
|
style : 'margin-top: 16px; width: 100%;',
|
2021-12-17 17:40:07 +00:00
|
|
|
menuStyle: 'min-width: 100%;',
|
2021-12-01 05:08:41 +00:00
|
|
|
takeFocusOnClose: true,
|
2021-12-07 05:40:03 +00:00
|
|
|
data : this.EffectGroupData,
|
2021-12-08 01:28:30 +00:00
|
|
|
value : (this._state.activeEffect != undefined)?this._state.activeGroup:undefined
|
2021-12-01 05:08:41 +00:00
|
|
|
});
|
2021-12-03 03:46:24 +00:00
|
|
|
this.cmbGroup.on('selected', _.bind(this.onGroupSelect,this));
|
2021-12-01 05:08:41 +00:00
|
|
|
|
|
|
|
this.cmbLevel = new Common.UI.ComboBox({
|
|
|
|
el : $('#animation-level'),
|
|
|
|
cls: 'input-group-nr',
|
|
|
|
editable: false,
|
|
|
|
style : 'margin-top: 16px; width: 100%;',
|
2021-12-17 17:40:07 +00:00
|
|
|
menuStyle: 'min-width: 100%;',
|
2021-12-03 03:46:24 +00:00
|
|
|
takeFocusOnClose: true
|
2021-12-01 05:08:41 +00:00
|
|
|
});
|
2021-12-03 03:46:24 +00:00
|
|
|
this.cmbLevel.on('selected', _.bind(this.onLevelSelect,this));
|
2021-12-01 05:08:41 +00:00
|
|
|
|
|
|
|
this.lstEffectList = new Common.UI.ListView({
|
|
|
|
el : $('#animation-list'),
|
2021-12-03 03:46:24 +00:00
|
|
|
itemTemplate: _.template('<div id="<%= id %>" class="list-item" style=""><%= displayValue %></div>'),
|
|
|
|
scroll : true
|
2021-12-01 05:08:41 +00:00
|
|
|
});
|
2021-12-08 01:28:30 +00:00
|
|
|
this.lstEffectList.on('item:select', _.bind(this.onEffectListItem,this));
|
2021-12-01 05:08:41 +00:00
|
|
|
|
|
|
|
this.chPreview = new Common.UI.CheckBox({
|
|
|
|
el : $('#animation-setpreview'),
|
|
|
|
labelText : this.textPreviewEffect
|
|
|
|
});
|
2021-12-10 18:39:27 +00:00
|
|
|
|
|
|
|
this.cmbGroup.setValue(this._state.activeGroupValue);
|
|
|
|
this.fillLevel();
|
2021-12-08 01:28:30 +00:00
|
|
|
|
|
|
|
this.$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
|
2021-12-01 05:08:41 +00:00
|
|
|
},
|
2021-12-03 03:46:24 +00:00
|
|
|
|
2021-12-01 05:08:41 +00:00
|
|
|
onGroupSelect: function (combo, record) {
|
2021-12-08 01:28:30 +00:00
|
|
|
this._state.activeGroup = record.id;
|
2021-12-10 18:39:27 +00:00
|
|
|
this._state.activeGroupValue = record.value;
|
|
|
|
this.activeLevel = undefined;
|
|
|
|
this._state.activeEffect = undefined;
|
|
|
|
this.fillLevel();
|
|
|
|
},
|
|
|
|
|
|
|
|
fillLevel: function ()
|
|
|
|
{
|
|
|
|
this.cmbLevel.store.reset(Common.define.effectData.getLevelEffect(this._state.activeGroup == 'menu-effect-group-path'));
|
|
|
|
var item = (this.activeLevel)?this.cmbLevel.store.findWhere({id: this.activeLevel}):this.cmbLevel.store.at(0);
|
|
|
|
this.cmbLevel.setValue(item.get('displayValue'));
|
|
|
|
this.activeLevel = item.get('id');
|
|
|
|
this.fillEffect();
|
2021-12-03 03:46:24 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onLevelSelect: function (combo, record) {
|
|
|
|
this.activeLevel = record.id;
|
2021-12-10 18:39:27 +00:00
|
|
|
this._state.activeEffect = undefined;
|
|
|
|
this.fillEffect();
|
|
|
|
},
|
|
|
|
|
|
|
|
fillEffect: function () {
|
2021-12-08 01:28:30 +00:00
|
|
|
var arr = _.where(this.allEffects, {group: this._state.activeGroup, level: this.activeLevel });
|
2021-12-03 03:46:24 +00:00
|
|
|
this.lstEffectList.store.reset(arr);
|
2021-12-23 12:53:38 +00:00
|
|
|
var item = this.lstEffectList.store.findWhere({value: this._state.activeEffect});
|
|
|
|
if(!item)
|
|
|
|
item = this.lstEffectList.store.at(0);
|
2021-12-10 18:39:27 +00:00
|
|
|
this.lstEffectList.selectRecord(item);
|
|
|
|
this._state.activeEffect = item.get('value');
|
2021-12-01 05:08:41 +00:00
|
|
|
},
|
2021-12-03 03:46:24 +00:00
|
|
|
|
2021-12-08 01:28:30 +00:00
|
|
|
onEffectListItem: function (lisvView, itemView, record){
|
|
|
|
if (record) {
|
|
|
|
this._state.activeEffect = record.get('value');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onBtnClick: function (event)
|
|
|
|
{
|
|
|
|
this._handleInput(event.currentTarget.attributes['result'].value);
|
|
|
|
},
|
|
|
|
|
|
|
|
_handleInput: function(state) {
|
|
|
|
if (this.options.handler) {
|
|
|
|
this.options.handler.call(this, state, this._state);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.close();
|
|
|
|
},
|
|
|
|
|
2021-12-01 05:08:41 +00:00
|
|
|
textTitle: 'More Effects',
|
|
|
|
textPreviewEffect: 'Preview Effect'
|
|
|
|
|
|
|
|
}, PE.Views.AnimationDialog || {}));
|
|
|
|
});
|