2021-07-16 14:31:23 +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
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
/**
|
2021-07-17 10:47:50 +00:00
|
|
|
* Transitions.js
|
2021-07-16 14:31:23 +00:00
|
|
|
*
|
2021-07-17 10:47:50 +00:00
|
|
|
* Created by Olga.Transitions on 15.07.21
|
|
|
|
* Copyright (c) 2021 Ascensio System SIA. All rights reserved.
|
2021-07-16 14:31:23 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
define([
|
|
|
|
'core',
|
2021-07-23 00:45:03 +00:00
|
|
|
'jquery',
|
|
|
|
'underscore',
|
|
|
|
'backbone',
|
2021-07-17 23:15:10 +00:00
|
|
|
'presentationeditor/main/app/view/Transitions'
|
2021-07-16 14:31:23 +00:00
|
|
|
], function () {
|
|
|
|
'use strict';
|
|
|
|
|
2021-07-17 23:15:10 +00:00
|
|
|
PE.Controllers.Transitions = Backbone.Controller.extend(_.extend({
|
2021-07-16 14:31:23 +00:00
|
|
|
models : [],
|
2021-08-06 03:05:27 +00:00
|
|
|
collections : [],
|
2021-07-16 14:31:23 +00:00
|
|
|
views : [
|
2021-07-17 23:15:10 +00:00
|
|
|
'PE.Views.Transitions'
|
2021-07-16 14:31:23 +00:00
|
|
|
],
|
2021-07-23 00:45:03 +00:00
|
|
|
options: {
|
|
|
|
alias: 'Transitions'
|
|
|
|
},
|
2021-07-16 14:31:23 +00:00
|
|
|
sdkViewName : '#id_main',
|
|
|
|
|
|
|
|
initialize: function () {
|
|
|
|
|
|
|
|
this.addListeners({
|
2021-07-17 23:15:10 +00:00
|
|
|
'PE.Views.Transitions': {
|
2021-07-20 02:35:56 +00:00
|
|
|
'transit:preview': _.bind(this.onPreviewClick, this),
|
2021-08-07 15:44:26 +00:00
|
|
|
'transit:parameters': _.bind(this.onParameterClick, this),
|
2021-08-06 03:05:27 +00:00
|
|
|
'transit:duration': _.bind(this.onDurationChange, this),
|
|
|
|
'transit:applytoall': _.bind(this.onApplyToAllClick, this),
|
2021-07-21 02:25:56 +00:00
|
|
|
'transit:selecteffect': _.bind(this.onEffectSelect, this),
|
2021-08-06 03:05:27 +00:00
|
|
|
'transit:startonclick': _.bind(this.onStartOnClickChange, this),
|
|
|
|
'transit:delay': _.bind(this.onDelayChange, this),
|
|
|
|
'transit:checkdelay': _.bind(this.onCheckDelayChange, this)
|
|
|
|
},
|
|
|
|
'Toolbar': {
|
|
|
|
'tab:active': _.bind(this.onActiveTab, this)
|
2021-07-16 14:31:23 +00:00
|
|
|
}
|
|
|
|
});
|
2021-07-20 02:35:56 +00:00
|
|
|
|
2021-07-16 14:31:23 +00:00
|
|
|
},
|
2021-08-06 03:05:27 +00:00
|
|
|
|
2021-07-16 14:31:23 +00:00
|
|
|
onLaunch: function () {
|
2021-07-19 12:08:11 +00:00
|
|
|
this._state = {};
|
2021-07-17 10:47:50 +00:00
|
|
|
},
|
2021-08-06 03:05:27 +00:00
|
|
|
|
2021-07-30 17:22:42 +00:00
|
|
|
setConfig: function (config) {
|
|
|
|
this.appConfig = config.mode;
|
|
|
|
|
|
|
|
this.view = this.createView('PE.Views.Transitions', {
|
|
|
|
toolbar: config.toolbar,
|
|
|
|
mode: config.mode
|
|
|
|
});
|
2021-07-16 14:31:23 +00:00
|
|
|
return this;
|
2021-08-06 03:05:27 +00:00
|
|
|
},
|
2021-08-02 01:37:23 +00:00
|
|
|
|
2021-07-16 14:31:23 +00:00
|
|
|
setApi: function (api) {
|
2021-07-19 12:08:11 +00:00
|
|
|
this.api = api;
|
2021-07-30 17:22:42 +00:00
|
|
|
this.api.asc_registerCallback('asc_onFocusObject', _.bind(this.onFocusObject, this));
|
2021-08-09 22:41:56 +00:00
|
|
|
this.api.asc_registerCallback('asc_onCountPages', _.bind(this.onApiCountPages, this));
|
2021-07-30 17:22:42 +00:00
|
|
|
return this;
|
2021-07-16 14:31:23 +00:00
|
|
|
},
|
|
|
|
|
2021-08-09 22:41:56 +00:00
|
|
|
onApiCountPages: function (count) {
|
|
|
|
if (this._state.no_slides !== (count<=0)) {
|
|
|
|
this._state.no_slides = (count<=0);
|
|
|
|
this.lockToolbar(PE.enumLock.noSlides, this._state.no_slides);
|
|
|
|
}
|
2021-07-16 14:31:23 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
createToolbarPanel: function() {
|
|
|
|
return this.view.getPanel();
|
2021-08-06 03:05:27 +00:00
|
|
|
},
|
2021-07-16 14:31:23 +00:00
|
|
|
|
|
|
|
getView: function(name) {
|
|
|
|
return !name && this.view ?
|
|
|
|
this.view : Backbone.Controller.prototype.getView.call(this, name);
|
|
|
|
},
|
|
|
|
|
2021-08-06 03:05:27 +00:00
|
|
|
onPreviewClick: function() {
|
2021-07-19 12:08:11 +00:00
|
|
|
if (this.api) {
|
|
|
|
this.api.SlideTransitionPlay();
|
|
|
|
}
|
2021-07-20 02:35:56 +00:00
|
|
|
},
|
2021-08-06 03:05:27 +00:00
|
|
|
|
2021-08-07 15:44:26 +00:00
|
|
|
onParameterClick: function (item) {
|
2021-07-20 02:35:56 +00:00
|
|
|
this.EffectType = item.value;
|
|
|
|
if (this.api && !this._noApply) {
|
|
|
|
var props = new Asc.CAscSlideProps();
|
|
|
|
var transition = new Asc.CAscSlideTransition();
|
|
|
|
transition.put_TransitionType(this.Effect);
|
|
|
|
transition.put_TransitionOption(this.EffectType);
|
|
|
|
props.put_transition(transition);
|
|
|
|
this.api.SetSlideProps(props);
|
|
|
|
}
|
|
|
|
},
|
2021-08-06 03:05:27 +00:00
|
|
|
|
|
|
|
onDurationChange: function(field, newValue, oldValue, eOpts) {
|
|
|
|
if (this.api && !this._noApply) {
|
2021-07-20 02:35:56 +00:00
|
|
|
var props = new Asc.CAscSlideProps();
|
|
|
|
var transition = new Asc.CAscSlideTransition();
|
|
|
|
transition.put_TransitionDuration(field.getNumberValue()*1000);
|
|
|
|
props.put_transition(transition);
|
|
|
|
this.api.SetSlideProps(props);
|
|
|
|
}
|
|
|
|
},
|
2021-08-06 03:05:27 +00:00
|
|
|
|
|
|
|
onStartOnClickChange: function(field, newValue, oldValue, eOpts) {
|
|
|
|
if (this.api && !this._noApply) {
|
2021-07-25 20:12:20 +00:00
|
|
|
var props = new Asc.CAscSlideProps();
|
|
|
|
var transition = new Asc.CAscSlideTransition();
|
2021-08-06 03:05:27 +00:00
|
|
|
transition.put_SlideAdvanceOnMouseClick(field.getValue() == 'checked');
|
2021-07-25 20:12:20 +00:00
|
|
|
props.put_transition(transition);
|
|
|
|
this.api.SetSlideProps(props);
|
|
|
|
}
|
|
|
|
},
|
2021-08-06 03:05:27 +00:00
|
|
|
|
|
|
|
onDelayChange: function(field, newValue, oldValue, eOpts) {
|
|
|
|
if (this.api && !this._noApply) {
|
2021-07-25 20:12:20 +00:00
|
|
|
var props = new Asc.CAscSlideProps();
|
|
|
|
var transition = new Asc.CAscSlideTransition();
|
|
|
|
transition.put_SlideAdvanceDuration(field.getNumberValue()*1000);
|
|
|
|
props.put_transition(transition);
|
|
|
|
this.api.SetSlideProps(props);
|
|
|
|
}
|
|
|
|
},
|
2021-08-06 03:05:27 +00:00
|
|
|
|
|
|
|
onCheckDelayChange: function(field, newValue, oldValue, eOpts) {
|
|
|
|
this.view.numDelay.setDisabled(field.getValue() !== 'checked');
|
|
|
|
if (this.api && !this._noApply) {
|
2021-07-25 20:12:20 +00:00
|
|
|
var props = new Asc.CAscSlideProps();
|
|
|
|
var transition = new Asc.CAscSlideTransition();
|
2021-08-06 03:05:27 +00:00
|
|
|
transition.put_SlideAdvanceAfter(field.getValue() == 'checked');
|
2021-07-25 20:12:20 +00:00
|
|
|
props.put_transition(transition);
|
|
|
|
this.api.SetSlideProps(props);
|
2021-07-21 02:25:56 +00:00
|
|
|
}
|
|
|
|
},
|
2021-08-06 03:05:27 +00:00
|
|
|
|
|
|
|
onApplyToAllClick: function () {
|
2021-07-20 02:35:56 +00:00
|
|
|
if (this.api) this.api.SlideTransitionApplyToAll();
|
2021-07-21 02:25:56 +00:00
|
|
|
},
|
2021-08-06 03:05:27 +00:00
|
|
|
|
|
|
|
onEffectSelect: function (combo, record) {
|
2021-07-21 02:25:56 +00:00
|
|
|
var type = record.get('value');
|
2021-08-06 03:05:27 +00:00
|
|
|
|
2021-07-21 02:25:56 +00:00
|
|
|
if (this.Effect !== type &&
|
2021-08-06 03:05:27 +00:00
|
|
|
!((this.Effect === Asc.c_oAscSlideTransitionTypes.Wipe || this.Effect === Asc.c_oAscSlideTransitionTypes.UnCover || this.Effect === Asc.c_oAscSlideTransitionTypes.Cover)&&
|
|
|
|
(type === Asc.c_oAscSlideTransitionTypes.Wipe || type === Asc.c_oAscSlideTransitionTypes.UnCover || type === Asc.c_oAscSlideTransitionTypes.Cover))) {
|
2021-08-07 15:44:26 +00:00
|
|
|
var parameter = this.view.setMenuParameters(type);
|
|
|
|
if (parameter)
|
2021-08-11 12:59:56 +00:00
|
|
|
this.onParameterClick(parameter);
|
2021-07-25 20:12:20 +00:00
|
|
|
}
|
2021-07-21 02:25:56 +00:00
|
|
|
this.Effect = type;
|
2021-08-06 03:05:27 +00:00
|
|
|
|
2021-07-21 02:25:56 +00:00
|
|
|
if (this.api && !this._noApply) {
|
|
|
|
var props = new Asc.CAscSlideProps();
|
|
|
|
var transition = new Asc.CAscSlideTransition();
|
|
|
|
transition.put_TransitionType(type);
|
|
|
|
transition.put_TransitionOption(this.EffectType);
|
|
|
|
props.put_transition(transition);
|
|
|
|
this.api.SetSlideProps(props);
|
|
|
|
}
|
2021-07-21 23:09:53 +00:00
|
|
|
},
|
2021-08-02 01:37:23 +00:00
|
|
|
|
2021-08-06 03:05:27 +00:00
|
|
|
onFocusObject: function(selectedObjects) {
|
|
|
|
var me = this;
|
2021-08-02 01:37:23 +00:00
|
|
|
|
2021-08-06 03:05:27 +00:00
|
|
|
for (var i = 0; i<selectedObjects.length; i++) {
|
2021-07-31 00:36:26 +00:00
|
|
|
var eltype = selectedObjects[i].get_ObjectType();
|
|
|
|
|
|
|
|
if (eltype === undefined)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (eltype == Asc.c_oAscTypeSelectElement.Slide) {
|
2021-08-06 03:05:27 +00:00
|
|
|
var locked_transition = undefined,
|
|
|
|
pr = selectedObjects[i].get_ObjectValue();
|
2021-08-02 23:06:03 +00:00
|
|
|
locked_transition = pr.get_LockTransition();
|
2021-08-02 01:37:23 +00:00
|
|
|
|
2021-08-06 03:05:27 +00:00
|
|
|
if (locked_transition !== undefined && me._state.lockedtransition !== locked_transition)
|
|
|
|
if (me.view.toolbar._state.activated) me._state.lockedtransition = locked_transition;
|
|
|
|
|
|
|
|
this.loadSettings(pr);
|
2021-08-02 01:37:23 +00:00
|
|
|
|
2021-08-06 03:05:27 +00:00
|
|
|
if (this._state.onactivetab) {
|
|
|
|
this.setLocked();
|
|
|
|
this.setSettings();
|
|
|
|
}
|
2021-07-31 00:36:26 +00:00
|
|
|
}
|
|
|
|
}
|
2021-08-02 01:37:23 +00:00
|
|
|
},
|
2021-07-25 20:12:20 +00:00
|
|
|
|
2021-08-06 03:05:27 +00:00
|
|
|
loadSettings: function (props) {
|
2021-07-21 23:09:53 +00:00
|
|
|
var transition = props.get_transition();
|
2021-07-23 00:45:03 +00:00
|
|
|
|
2021-08-06 03:05:27 +00:00
|
|
|
if (transition) {
|
|
|
|
this._state.Effect = transition.get_TransitionType();
|
|
|
|
this._state.EffectType = transition.get_TransitionOption();
|
2021-07-23 00:45:03 +00:00
|
|
|
|
2021-08-06 03:05:27 +00:00
|
|
|
var value = transition.get_TransitionDuration();
|
2021-07-23 00:45:03 +00:00
|
|
|
if (Math.abs(this._state.Duration - value) > 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;
|
|
|
|
}
|
2021-07-25 20:12:20 +00:00
|
|
|
|
2021-07-23 00:45:03 +00:00
|
|
|
value = transition.get_SlideAdvanceDuration();
|
|
|
|
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;
|
|
|
|
}
|
2021-07-21 23:09:53 +00:00
|
|
|
|
2021-08-06 03:05:27 +00:00
|
|
|
this._state.OnMouseClick = transition.get_SlideAdvanceOnMouseClick();
|
|
|
|
this._state.AdvanceAfter = transition.get_SlideAdvanceAfter();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onActiveTab: function(tab) {
|
|
|
|
if (tab == 'transit') {
|
|
|
|
this._state.onactivetab = true;
|
|
|
|
this.setLocked();
|
|
|
|
this.setSettings();
|
2021-07-25 20:12:20 +00:00
|
|
|
}
|
2021-08-06 03:05:27 +00:00
|
|
|
else this._state.onactivetab = false;
|
|
|
|
},
|
|
|
|
|
|
|
|
lockToolbar: function (causes, lock, opts) {
|
|
|
|
Common.Utils.lockControls(causes, lock, opts, this.view.lockedControls);
|
|
|
|
},
|
|
|
|
|
|
|
|
setLocked: function() {
|
|
|
|
if (this._state.lockedtransition != undefined)
|
|
|
|
this.lockToolbar(PE.enumLock.transitLock, this._state.lockedtransition);
|
|
|
|
},
|
|
|
|
|
|
|
|
setSettings: function () {
|
|
|
|
var me = this.view;
|
|
|
|
|
|
|
|
if (this._state.Effect !== undefined) {
|
|
|
|
var item = me.listEffects.store.findWhere({value: this._state.Effect});
|
|
|
|
me.listEffects.menuPicker.selectRecord(item ? item : me.listEffects.menuPicker.items[0]);
|
2021-08-11 12:59:56 +00:00
|
|
|
this.view.btnParameters.setIconCls('toolbar__icon icon ' + item.get('imageUrl'));
|
2021-08-06 03:05:27 +00:00
|
|
|
}
|
|
|
|
|
2021-08-07 15:44:26 +00:00
|
|
|
if (me.btnParameters.menu.items.length > 0 && this._state.EffectType !== undefined)
|
|
|
|
me.setMenuParameters(this._state.Effect, this._state.EffectType);
|
2021-08-06 03:05:27 +00:00
|
|
|
|
|
|
|
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.chStartOnClick.setValue((this._state.OnMouseClick !== null && this._state.OnMouseClick !== undefined) ? this._state.OnMouseClick : 'indeterminate', true);
|
|
|
|
me.chDelay.setValue((this._state.AdvanceAfter !== null && this._state.AdvanceAfter !== undefined) ? this._state.AdvanceAfter : 'indeterminate', true);
|
|
|
|
me.numDelay.setDisabled(me.chDelay.getValue() !== 'checked' || me.chDelay.disabled);
|
2021-07-17 10:47:50 +00:00
|
|
|
}
|
2021-08-06 03:05:27 +00:00
|
|
|
|
2021-07-17 23:15:10 +00:00
|
|
|
}, PE.Controllers.Transitions || {}));
|
2021-07-16 14:31:23 +00:00
|
|
|
});
|