2017-01-19 07:59:20 +00:00
/ *
*
2019-01-17 13:05:03 +00:00
* ( c ) Copyright Ascensio System SIA 2010 - 2019
2017-01-19 07:59:20 +00:00
*
* 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
*
2019-01-17 13:00:34 +00:00
* You can contact Ascensio System SIA at 20 A - 12 Ernesta Birznieka - Upisha
* street , Riga , Latvia , EU , LV - 1050.
2017-01-19 07:59:20 +00:00
*
* 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 .
2017-01-19 07:59:20 +00:00
*
* /
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'
2017-01-19 07:59:20 +00:00
] , 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 } ,
2019-10-03 13:56:19 +00:00
{ panelId : 'id-adv-image-snap' , panelCaption : this . textSnap } ,
2017-01-19 07:59:20 +00:00
{ 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
} ) ;
2019-10-03 13:56:19 +00:00
// Snapping
this . radioTwoCell = new Common . UI . RadioBox ( {
el : $ ( '#image-advanced-radio-twocell' ) ,
name : 'asc-radio-snap' ,
labelText : this . textTwoCell ,
value : AscCommon . c _oAscCellAnchorType . cellanchorTwoCell
} ) ;
this . radioTwoCell . on ( 'change' , _ . bind ( this . onRadioSnapChange , this ) ) ;
this . radioOneCell = new Common . UI . RadioBox ( {
el : $ ( '#image-advanced-radio-onecell' ) ,
name : 'asc-radio-snap' ,
labelText : this . textOneCell ,
value : AscCommon . c _oAscCellAnchorType . cellanchorOneCell
} ) ;
this . radioOneCell . on ( 'change' , _ . bind ( this . onRadioSnapChange , this ) ) ;
this . radioAbsolute = new Common . UI . RadioBox ( {
el : $ ( '#image-advanced-radio-absolute' ) ,
name : 'asc-radio-snap' ,
labelText : this . textAbsolute ,
value : AscCommon . c _oAscCellAnchorType . cellanchorAbsolute
} ) ;
this . radioAbsolute . on ( 'change' , _ . bind ( this . onRadioSnapChange , this ) ) ;
2017-01-19 07:59:20 +00:00
// 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 ( ) ;
} ,
2020-10-14 10:43:44 +00:00
getFocusedComponents : function ( ) {
return [
2021-04-13 22:12:59 +00:00
this . spnAngle , this . chFlipHor , this . chFlipVert , // 0 tab
2021-04-14 15:16:27 +00:00
this . radioTwoCell , this . radioOneCell , this . radioAbsolute , // 1 tab
2020-10-14 10:43:44 +00:00
this . inputAltTitle , this . textareaAltDescription // 2 tab
] ;
} ,
onCategoryClick : function ( btn , index ) {
Common . Views . AdvancedSettingsWindow . prototype . onCategoryClick . call ( this , btn , index ) ;
var me = this ;
setTimeout ( function ( ) {
switch ( index ) {
case 0 :
me . spnAngle . focus ( ) ;
break ;
2021-04-14 15:16:27 +00:00
case 1 :
me . radioTwoCell . focus ( ) ;
break ;
2020-10-14 10:43:44 +00:00
case 2 :
me . inputAltTitle . focus ( ) ;
break ;
}
} , 10 ) ;
} ,
2019-10-03 13:56:19 +00:00
onRadioSnapChange : function ( field , newValue , eOpts ) {
if ( newValue && this . _changedProps ) {
this . _changedProps . asc _putAnchor ( field . options . value ) ;
}
} ,
2017-01-19 07:59:20 +00:00
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 ( ) ) ;
2019-10-03 13:56:19 +00:00
value = props . asc _getAnchor ( ) ;
switch ( value ) {
case AscCommon . c _oAscCellAnchorType . cellanchorTwoCell :
this . radioTwoCell . setValue ( true , true ) ;
break ;
case AscCommon . c _oAscCellAnchorType . cellanchorOneCell :
this . radioOneCell . setValue ( true , true ) ;
break ;
case AscCommon . c _oAscCellAnchorType . cellanchorAbsolute :
this . radioAbsolute . setValue ( true , true ) ;
break ;
}
2019-06-14 07:53:20 +00:00
var pluginGuid = props . asc _getPluginGuid ( ) ;
this . btnsCategory [ 0 ] . setVisible ( pluginGuid === null || pluginGuid === undefined ) ; // Rotation
2017-01-19 07:59:20 +00:00
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' ) ;
2017-01-19 07:59:20 +00:00
return { imageProps : this . _changedProps } ;
} ,
textTitle : 'Image - Advanced Settings' ,
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' ,
2019-10-03 13:56:19 +00:00
textVertically : 'Vertically' ,
textSnap : 'Cell Snapping' ,
textAbsolute : 'Don\'t move or size with cells' ,
textOneCell : 'Move but don\'t size with cells' ,
textTwoCell : 'Move and size with cells'
2017-01-19 07:59:20 +00:00
} , SSE . Views . ImageSettingsAdvanced || { } ) ) ;
} ) ;