web-apps/apps/spreadsheeteditor/main/app/view/ImageSettingsAdvanced.js

176 lines
6.8 KiB
JavaScript
Raw Normal View History

/*
*
2018-03-01 12:16:38 +00:00
* (c) Copyright Ascensio System Limited 2010-2018
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
/**
* ImageSettingsAdvanced.js
*
* Created by Julia Radzhabova on 1/19/17
2018-03-01 12:16:38 +00:00
* Copyright (c) 2018 Ascensio System SIA. All rights reserved.
*
*/
define([ 'text!spreadsheeteditor/main/app/template/ImageSettingsAdvanced.template',
'common/main/lib/view/AdvancedSettingsWindow',
2018-08-30 15:41:09 +00:00
'common/main/lib/component/InputField',
'common/main/lib/component/MetricSpinner',
'common/main/lib/component/CheckBox'
], function (contentTemplate) {
'use strict';
SSE.Views.ImageSettingsAdvanced = Common.Views.AdvancedSettingsWindow.extend(_.extend({
options: {
contentWidth: 300,
height: 342,
toggleGroup: 'image-adv-settings-group',
properties: null,
storageName: 'sse-image-settings-adv-category'
},
initialize : function(options) {
_.extend(this.options, {
title: this.textTitle,
items: [
2018-08-30 15:41:09 +00:00
{panelId: 'id-adv-image-rotate', panelCaption: this.textRotation},
{panelId: 'id-adv-image-alttext', panelCaption: this.textAlt}
],
contentTemplate: _.template(contentTemplate)({
scope: this
})
}, options);
Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options);
this._originalProps = this.options.imageProps;
this._changedProps = null;
},
render: function() {
Common.Views.AdvancedSettingsWindow.prototype.render.call(this);
var me = this;
2018-08-30 15:41:09 +00:00
// Rotation
this.spnAngle = new Common.UI.MetricSpinner({
el: $('#image-advanced-spin-angle'),
step: 1,
width: 80,
defaultUnit : "°",
value: '0 °',
maxValue: 3600,
minValue: -3600
});
this.chFlipHor = new Common.UI.CheckBox({
el: $('#image-advanced-checkbox-hor'),
labelText: this.textHorizontally
});
this.chFlipVert = new Common.UI.CheckBox({
el: $('#image-advanced-checkbox-vert'),
labelText: this.textVertically
});
// Alt Text
this.inputAltTitle = new Common.UI.InputField({
el : $('#image-advanced-alt-title'),
allowBlank : true,
validateOnBlur: false,
style : 'width: 100%;'
}).on('changed:after', function() {
me.isAltTitleChanged = true;
});
this.textareaAltDescription = this.$window.find('textarea');
this.textareaAltDescription.keydown(function (event) {
if (event.keyCode == Common.UI.Keys.RETURN) {
event.stopPropagation();
}
me.isAltDescChanged = true;
});
this.afterRender();
},
afterRender: function() {
this._setDefaults(this._originalProps);
if (this.storageName) {
var value = Common.localStorage.getItem(this.storageName);
this.setActiveCategory((value!==null) ? parseInt(value) : 0);
}
},
_setDefaults: function(props) {
if (props ){
var value = props.asc_getTitle();
this.inputAltTitle.setValue(value ? value : '');
value = props.asc_getDescription();
this.textareaAltDescription.val(value ? value : '');
2018-08-30 15:41:09 +00:00
value = props.asc_getRot();
this.spnAngle.setValue((value==undefined || value===null) ? '' : Math.floor(value*180/3.14159265358979+0.5), true);
this.chFlipHor.setValue(props.asc_getFlipH());
this.chFlipVert.setValue(props.asc_getFlipV());
this._changedProps = new Asc.asc_CImgProperty();
}
},
getSettings: function() {
if (this.isAltTitleChanged)
this._changedProps.asc_putTitle(this.inputAltTitle.getValue());
if (this.isAltDescChanged)
this._changedProps.asc_putDescription(this.textareaAltDescription.val());
2018-08-30 15:41:09 +00:00
this._changedProps.asc_putRot(this.spnAngle.getNumberValue() * 3.14159265358979 / 180);
this._changedProps.asc_putFlipH(this.chFlipHor.getValue()=='checked');
this._changedProps.asc_putFlipV(this.chFlipVert.getValue()=='checked');
return { imageProps: this._changedProps} ;
},
textTitle: 'Image - Advanced Settings',
cancelButtonText: 'Cancel',
okButtonText: 'Ok',
textAlt: 'Alternative Text',
textAltTitle: 'Title',
textAltDescription: 'Description',
2018-08-30 15:41:09 +00:00
textAltTip: 'The alternative text-based representation of the visual object information, which will be read to the people with vision or cognitive impairments to help them better understand what information there is in the image, autoshape, chart or table.',
textRotation: 'Rotation',
textAngle: 'Angle',
textFlipped: 'Flipped',
textHorizontally: 'Horizontally',
textVertically: 'Vertically'
}, SSE.Views.ImageSettingsAdvanced || {}));
});