2016-04-01 13:17:09 +00:00
/ *
*
2019-01-17 13:05:03 +00:00
* ( c ) Copyright Ascensio System SIA 2010 - 2019
2016-04-01 13:17:09 +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.
2016-04-01 13:17:09 +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
*
* /
2016-03-11 00:48:53 +00:00
/ * *
* ShapeSettings . js
*
* Created by Julia Radzhabova on 4 / 14 / 14
2018-03-01 12:16:38 +00:00
* Copyright ( c ) 2018 Ascensio System SIA . All rights reserved .
2016-03-11 00:48:53 +00:00
*
* /
define ( [
'text!presentationeditor/main/app/template/ShapeSettings.template' ,
'jquery' ,
'underscore' ,
'backbone' ,
'common/main/lib/component/ComboBox' ,
'common/main/lib/component/ComboBorderSize' ,
'common/main/lib/component/MetricSpinner' ,
'common/main/lib/component/ThemeColorPalette' ,
'common/main/lib/component/ColorButton' ,
'common/main/lib/component/ComboDataView' ,
'common/main/lib/component/Slider' ,
'common/main/lib/component/MultiSliderGradient' ,
'common/main/lib/view/ImageFromUrlDialog' ,
'presentationeditor/main/app/view/ShapeSettingsAdvanced'
] , function ( menuTemplate , $ , _ , Backbone ) {
'use strict' ;
PE . Views . ShapeSettings = Backbone . View . extend ( _ . extend ( {
el : '#id-shape-settings' ,
// Compile our stats template
template : _ . template ( menuTemplate ) ,
// Delegated events for creating new items, and clearing completed ones.
events : {
} ,
options : {
alias : 'ShapeSettings'
} ,
initialize : function ( ) {
this . _initSettings = true ;
this . _originalProps = null ;
this . _noApply = true ;
this . _sendUndoPoint = true ;
this . _sliderChanged = false ;
2019-08-30 12:04:02 +00:00
this . _texturearray = null ;
2016-03-11 00:48:53 +00:00
2016-04-06 13:38:54 +00:00
this . txtPt = Common . Utils . Metric . getMetricName ( Common . Utils . Metric . c _MetricUnits . pt ) ;
2016-03-11 00:48:53 +00:00
this . _state = {
Transparency : null ,
2016-04-05 11:52:34 +00:00
FillType : Asc . c _oAscFill . FILL _TYPE _SOLID ,
2016-03-11 00:48:53 +00:00
ShapeColor : 'transparent' ,
2016-04-05 11:52:34 +00:00
BlipFillType : Asc . c _oAscFillBlipType . STRETCH ,
StrokeType : Asc . c _oAscStrokeType . STROKE _COLOR ,
2016-03-11 00:48:53 +00:00
StrokeWidth : this . _pt2mm ( 1 ) ,
StrokeColor : '000000' ,
2016-07-01 08:16:09 +00:00
StrokeBorderType : Asc . c _oDashType . solid ,
2016-03-11 00:48:53 +00:00
FGColor : '000000' ,
BGColor : 'ffffff' ,
GradColor : '000000' ,
2016-04-05 11:52:34 +00:00
GradFillType : Asc . c _oAscFillGradType . GRAD _LINEAR ,
2016-03-11 00:48:53 +00:00
DisabledFillPanels : false ,
DisabledControls : false ,
HideShapeOnlySettings : false ,
2019-08-20 11:05:13 +00:00
HideChangeTypeSettings : false ,
isFromImage : false
2016-03-11 00:48:53 +00:00
} ;
this . lockedControls = [ ] ;
this . _locked = false ;
2016-04-05 11:52:34 +00:00
this . OriginalFillType = Asc . c _oAscFill . FILL _TYPE _SOLID ;
2016-03-11 00:48:53 +00:00
this . ShapeColor = { Value : 1 , Color : 'transparent' } ; // value=1 - цвет определен - прозрачный или другой, value=0 - цвет не определен, рисуем прозрачным
2016-04-05 11:52:34 +00:00
this . BlipFillType = Asc . c _oAscFillBlipType . STRETCH ;
this . GradFillType = Asc . c _oAscFillGradType . GRAD _LINEAR ;
2016-03-11 00:48:53 +00:00
this . GradColor = { values : [ 0 , 100 ] , colors : [ '000000' , 'ffffff' ] , currentIdx : 0 } ;
this . GradRadialDirectionIdx = 0 ;
this . GradLinearDirectionType = 0 ;
this . PatternFillType = 0 ;
this . FGColor = { Value : 1 , Color : '000000' } ; // value=1 - цвет определен - прозрачный или другой, value=0 - цвет не определен, рисуем прозрачным
this . BGColor = { Value : 1 , Color : 'ffffff' } ; // value=1 - цвет определен - прозрачный или другой, value=0 - цвет не определен, рисуем прозрачным
this . BorderColor = { Value : 1 , Color : 'transparent' } ; // value=1 - цвет определен - прозрачный или другой, value=0 - цвет не определен, рисуем прозрачным
this . BorderSize = 0 ;
2016-07-01 08:16:09 +00:00
this . BorderType = Asc . c _oDashType . solid ;
2016-03-11 00:48:53 +00:00
this . textureNames = [ this . txtCanvas , this . txtCarton , this . txtDarkFabric , this . txtGrain , this . txtGranite , this . txtGreyPaper ,
this . txtKnit , this . txtLeather , this . txtBrownPaper , this . txtPapyrus , this . txtWood ] ;
this . fillControls = [ ] ;
2021-10-01 22:20:52 +00:00
this . gradientColorsStr = "#000, #fff" ;
this . typeGradient = 90 ;
2016-03-11 00:48:53 +00:00
this . render ( ) ;
this . FillColorContainer = $ ( '#shape-panel-color-fill' ) ;
this . FillImageContainer = $ ( '#shape-panel-image-fill' ) ;
this . FillPatternContainer = $ ( '#shape-panel-pattern-fill' ) ;
this . FillGradientContainer = $ ( '#shape-panel-gradient-fill' ) ;
this . TransparencyContainer = $ ( '#shape-panel-transparent-fill' ) ;
this . ShapeOnlySettings = $ ( '.shape-only' ) ;
this . CanChangeType = $ ( '.change-type' ) ;
} ,
render : function ( ) {
var el = $ ( this . el ) ;
el . html ( this . template ( {
scope : this
} ) ) ;
} ,
setApi : function ( api ) {
this . api = api ;
if ( this . api ) {
2016-05-06 11:45:21 +00:00
this . api . asc _setInterfaceDrawImagePlaceShape ( 'shape-texture-img' ) ;
this . api . asc _registerCallback ( 'asc_onInitStandartTextures' , _ . bind ( this . onInitStandartTextures , this ) ) ;
2016-03-11 00:48:53 +00:00
}
2020-05-13 14:20:58 +00:00
Common . NotificationCenter . on ( 'storage:image-insert' , _ . bind ( this . insertImageFromStorage , this ) ) ;
2016-03-11 00:48:53 +00:00
return this ;
} ,
2020-05-13 14:20:58 +00:00
setMode : function ( mode ) {
this . mode = mode ;
} ,
2016-03-11 00:48:53 +00:00
onFillSrcSelect : function ( combo , record ) {
this . ShowHideElem ( record . value ) ;
switch ( record . value ) {
2016-04-05 11:52:34 +00:00
case Asc . c _oAscFill . FILL _TYPE _SOLID :
this . _state . FillType = Asc . c _oAscFill . FILL _TYPE _SOLID ;
2016-03-11 00:48:53 +00:00
if ( ! this . _noApply ) {
2016-04-18 12:21:15 +00:00
var props = new Asc . asc _CShapeProperty ( ) ;
var fill = new Asc . asc _CShapeFill ( ) ;
2016-04-05 11:52:34 +00:00
fill . put _type ( Asc . c _oAscFill . FILL _TYPE _SOLID ) ;
2016-04-18 12:21:15 +00:00
fill . put _fill ( new Asc . asc _CFillSolid ( ) ) ;
2016-03-11 00:48:53 +00:00
fill . get _fill ( ) . put _color ( Common . Utils . ThemeColor . getRgbColor ( ( this . ShapeColor . Color == 'transparent' ) ? { color : '4f81bd' , effectId : 24 } : this . ShapeColor . Color ) ) ;
props . put _fill ( fill ) ;
this . api . ShapeApply ( props ) ;
}
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscFill . FILL _TYPE _GRAD :
this . _state . FillType = Asc . c _oAscFill . FILL _TYPE _GRAD ;
2016-03-11 00:48:53 +00:00
if ( ! this . _noApply ) {
2016-04-18 12:21:15 +00:00
var props = new Asc . asc _CShapeProperty ( ) ;
var fill = new Asc . asc _CShapeFill ( ) ;
2016-04-05 11:52:34 +00:00
fill . put _type ( Asc . c _oAscFill . FILL _TYPE _GRAD ) ;
2016-04-18 12:21:15 +00:00
fill . put _fill ( new Asc . asc _CFillGrad ( ) ) ;
2016-03-11 00:48:53 +00:00
fill . get _fill ( ) . put _grad _type ( this . GradFillType ) ;
2016-04-05 11:52:34 +00:00
if ( this . GradFillType == Asc . c _oAscFillGradType . GRAD _LINEAR ) {
2016-03-11 00:48:53 +00:00
fill . get _fill ( ) . put _linear _angle ( this . GradLinearDirectionType * 60000 ) ;
fill . get _fill ( ) . put _linear _scale ( true ) ;
}
2016-04-05 11:52:34 +00:00
if ( this . OriginalFillType !== Asc . c _oAscFill . FILL _TYPE _GRAD ) {
2019-06-07 08:40:43 +00:00
this . GradColor . values = [ 0 , 100 ] ;
this . GradColor . colors = [ this . GradColor . colors [ 0 ] , this . GradColor . colors [ this . GradColor . colors . length - 1 ] ] ;
2019-06-07 11:15:15 +00:00
this . GradColor . currentIdx = 0 ;
2016-03-11 00:48:53 +00:00
var HexColor0 = Common . Utils . ThemeColor . getRgbColor ( this . GradColor . colors [ 0 ] ) . get _color ( ) . get _hex ( ) ,
HexColor1 = Common . Utils . ThemeColor . getRgbColor ( this . GradColor . colors [ 1 ] ) . get _color ( ) . get _hex ( ) ;
if ( HexColor0 === 'ffffff' && HexColor1 === 'ffffff' ) {
HexColor0 = { color : '4f81bd' , effectId : 24 } ; // color accent1
} else {
HexColor0 = this . GradColor . colors [ 0 ] ;
}
fill . get _fill ( ) . put _positions ( [ this . GradColor . values [ 0 ] * 1000 , this . GradColor . values [ 1 ] * 1000 ] ) ;
fill . get _fill ( ) . put _colors ( [ Common . Utils . ThemeColor . getRgbColor ( HexColor0 ) , Common . Utils . ThemeColor . getRgbColor ( this . GradColor . colors [ 1 ] ) ] ) ;
}
props . put _fill ( fill ) ;
this . api . ShapeApply ( props ) ;
}
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscFill . FILL _TYPE _BLIP :
this . _state . FillType = Asc . c _oAscFill . FILL _TYPE _BLIP ;
2016-03-11 00:48:53 +00:00
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscFill . FILL _TYPE _PATT :
this . _state . FillType = Asc . c _oAscFill . FILL _TYPE _PATT ;
2016-03-11 00:48:53 +00:00
if ( ! this . _noApply ) {
2016-04-18 12:21:15 +00:00
var props = new Asc . asc _CShapeProperty ( ) ;
var fill = new Asc . asc _CShapeFill ( ) ;
2016-04-05 11:52:34 +00:00
fill . put _type ( Asc . c _oAscFill . FILL _TYPE _PATT ) ;
2016-04-18 12:21:15 +00:00
fill . put _fill ( new Asc . asc _CFillHatch ( ) ) ;
2016-03-11 00:48:53 +00:00
fill . get _fill ( ) . put _pattern _type ( this . PatternFillType ) ;
var fHexColor = Common . Utils . ThemeColor . getRgbColor ( this . FGColor . Color ) . get _color ( ) . get _hex ( ) ;
var bHexColor = Common . Utils . ThemeColor . getRgbColor ( this . BGColor . Color ) . get _color ( ) . get _hex ( ) ;
if ( bHexColor === 'ffffff' && fHexColor === 'ffffff' ) {
fHexColor = { color : '4f81bd' , effectId : 24 } ; // color accent1
} else {
fHexColor = this . FGColor . Color ;
}
fill . get _fill ( ) . put _color _fg ( Common . Utils . ThemeColor . getRgbColor ( fHexColor ) ) ;
fill . get _fill ( ) . put _color _bg ( Common . Utils . ThemeColor . getRgbColor ( this . BGColor . Color ) ) ;
props . put _fill ( fill ) ;
this . api . ShapeApply ( props ) ;
}
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscFill . FILL _TYPE _NOFILL :
this . _state . FillType = Asc . c _oAscFill . FILL _TYPE _NOFILL ;
2016-03-11 00:48:53 +00:00
if ( ! this . _noApply ) {
2016-04-18 12:21:15 +00:00
var props = new Asc . asc _CShapeProperty ( ) ;
var fill = new Asc . asc _CShapeFill ( ) ;
2016-04-05 11:52:34 +00:00
fill . put _type ( Asc . c _oAscFill . FILL _TYPE _NOFILL ) ;
2016-03-11 00:48:53 +00:00
fill . put _fill ( null ) ;
props . put _fill ( fill ) ;
this . api . ShapeApply ( props ) ;
}
break ;
}
this . fireEvent ( 'editcomplete' , this ) ;
} ,
2020-04-29 17:32:18 +00:00
onColorsBackSelect : function ( btn , color ) {
2016-03-11 00:48:53 +00:00
this . ShapeColor = { Value : 1 , Color : color } ;
if ( this . api && ! this . _noApply ) {
2016-04-18 12:21:15 +00:00
var props = new Asc . asc _CShapeProperty ( ) ;
var fill = new Asc . asc _CShapeFill ( ) ;
2016-03-11 00:48:53 +00:00
if ( this . ShapeColor . Color == 'transparent' ) {
2016-04-05 11:52:34 +00:00
fill . put _type ( Asc . c _oAscFill . FILL _TYPE _NOFILL ) ;
2016-03-11 00:48:53 +00:00
fill . put _fill ( null ) ;
} else {
2016-04-05 11:52:34 +00:00
fill . put _type ( Asc . c _oAscFill . FILL _TYPE _SOLID ) ;
2016-04-18 12:21:15 +00:00
fill . put _fill ( new Asc . asc _CFillSolid ( ) ) ;
2016-03-11 00:48:53 +00:00
fill . get _fill ( ) . put _color ( Common . Utils . ThemeColor . getRgbColor ( this . ShapeColor . Color ) ) ;
}
props . put _fill ( fill ) ;
this . api . ShapeApply ( props ) ;
}
this . fireEvent ( 'editcomplete' , this ) ;
} ,
onPatternSelect : function ( combo , record ) {
if ( this . api && ! this . _noApply ) {
this . PatternFillType = record . get ( 'type' ) ;
2016-04-18 12:21:15 +00:00
var props = new Asc . asc _CShapeProperty ( ) ;
var fill = new Asc . asc _CShapeFill ( ) ;
2016-04-05 11:52:34 +00:00
fill . put _type ( Asc . c _oAscFill . FILL _TYPE _PATT ) ;
2016-04-18 12:21:15 +00:00
fill . put _fill ( new Asc . asc _CFillHatch ( ) ) ;
2016-03-11 00:48:53 +00:00
fill . get _fill ( ) . put _pattern _type ( this . PatternFillType ) ;
2016-04-05 11:52:34 +00:00
if ( this . OriginalFillType !== Asc . c _oAscFill . FILL _TYPE _PATT ) {
2016-03-11 00:48:53 +00:00
fill . get _fill ( ) . put _color _fg ( Common . Utils . ThemeColor . getRgbColor ( this . FGColor . Color ) ) ;
fill . get _fill ( ) . put _color _bg ( Common . Utils . ThemeColor . getRgbColor ( this . BGColor . Color ) ) ;
}
props . put _fill ( fill ) ;
this . api . ShapeApply ( props ) ;
}
this . fireEvent ( 'editcomplete' , this ) ;
} ,
2020-04-29 17:32:18 +00:00
onColorsFGSelect : function ( btn , color ) {
2016-03-11 00:48:53 +00:00
this . FGColor = { Value : 1 , Color : color } ;
if ( this . api && ! this . _noApply ) {
2016-04-18 12:21:15 +00:00
var props = new Asc . asc _CShapeProperty ( ) ;
var fill = new Asc . asc _CShapeFill ( ) ;
2016-04-05 11:52:34 +00:00
fill . put _type ( Asc . c _oAscFill . FILL _TYPE _PATT ) ;
2016-04-18 12:21:15 +00:00
fill . put _fill ( new Asc . asc _CFillHatch ( ) ) ;
2016-03-11 00:48:53 +00:00
fill . get _fill ( ) . put _color _fg ( Common . Utils . ThemeColor . getRgbColor ( this . FGColor . Color ) ) ;
2016-04-05 11:52:34 +00:00
if ( this . OriginalFillType !== Asc . c _oAscFill . FILL _TYPE _PATT ) {
2016-03-11 00:48:53 +00:00
fill . get _fill ( ) . put _pattern _type ( this . PatternFillType ) ;
fill . get _fill ( ) . put _color _bg ( Common . Utils . ThemeColor . getRgbColor ( this . BGColor . Color ) ) ;
}
props . put _fill ( fill ) ;
this . api . ShapeApply ( props ) ;
}
this . fireEvent ( 'editcomplete' , this ) ;
} ,
2020-04-29 17:32:18 +00:00
onColorsBGSelect : function ( btn , color ) {
2016-03-11 00:48:53 +00:00
this . BGColor = { Value : 1 , Color : color } ;
if ( this . api && ! this . _noApply ) {
2016-04-18 12:21:15 +00:00
var props = new Asc . asc _CShapeProperty ( ) ;
var fill = new Asc . asc _CShapeFill ( ) ;
2016-04-05 11:52:34 +00:00
fill . put _type ( Asc . c _oAscFill . FILL _TYPE _PATT ) ;
2016-04-18 12:21:15 +00:00
fill . put _fill ( new Asc . asc _CFillHatch ( ) ) ;
2016-04-05 11:52:34 +00:00
if ( this . OriginalFillType !== Asc . c _oAscFill . FILL _TYPE _PATT ) {
2016-03-11 00:48:53 +00:00
fill . get _fill ( ) . put _pattern _type ( this . PatternFillType ) ;
fill . get _fill ( ) . put _color _fg ( Common . Utils . ThemeColor . getRgbColor ( this . FGColor . Color ) ) ;
}
fill . get _fill ( ) . put _color _bg ( Common . Utils . ThemeColor . getRgbColor ( this . BGColor . Color ) ) ;
props . put _fill ( fill ) ;
this . api . ShapeApply ( props ) ;
}
this . fireEvent ( 'editcomplete' , this ) ;
} ,
onFillTypeSelect : function ( combo , record ) {
this . BlipFillType = record . value ;
2016-04-05 11:52:34 +00:00
if ( this . api && this . _fromTextureCmb !== true && this . OriginalFillType == Asc . c _oAscFill . FILL _TYPE _BLIP ) {
2016-04-18 12:21:15 +00:00
var props = new Asc . asc _CShapeProperty ( ) ;
var fill = new Asc . asc _CShapeFill ( ) ;
2016-04-05 11:52:34 +00:00
fill . put _type ( Asc . c _oAscFill . FILL _TYPE _BLIP ) ;
2016-04-18 12:21:15 +00:00
fill . put _fill ( new Asc . asc _CFillBlip ( ) ) ;
2016-03-11 00:48:53 +00:00
fill . get _fill ( ) . put _type ( this . BlipFillType ) ;
props . put _fill ( fill ) ;
this . api . ShapeApply ( props ) ;
}
this . fireEvent ( 'editcomplete' , this ) ;
} ,
onNumTransparencyChange : function ( field , newValue , oldValue , eOpts ) {
this . sldrTransparency . setValue ( field . getNumberValue ( ) , true ) ;
if ( this . api ) {
var num = field . getNumberValue ( ) ;
2016-04-18 12:21:15 +00:00
var props = new Asc . asc _CShapeProperty ( ) ;
var fill = new Asc . asc _CShapeFill ( ) ;
2016-03-11 00:48:53 +00:00
fill . put _transparent ( num * 2.55 ) ;
props . put _fill ( fill ) ;
this . api . ShapeApply ( props ) ;
}
} ,
onTransparencyChange : function ( field , newValue , oldValue ) {
this . _sliderChanged = newValue ;
this . numTransparency . setValue ( newValue , true ) ;
if ( this . _sendUndoPoint ) {
this . api . setStartPointHistory ( ) ;
this . _sendUndoPoint = false ;
this . updateslider = setInterval ( _ . bind ( this . _transparencyApplyFunc , this ) , 100 ) ;
}
} ,
onTransparencyChangeComplete : function ( field , newValue , oldValue ) {
clearInterval ( this . updateslider ) ;
this . _sliderChanged = newValue ;
2018-11-08 07:58:53 +00:00
if ( ! this . _sendUndoPoint ) { // start point was added
this . api . setEndPointHistory ( ) ;
this . _transparencyApplyFunc ( ) ;
}
2016-03-11 00:48:53 +00:00
this . _sendUndoPoint = true ;
} ,
_transparencyApplyFunc : function ( ) {
if ( this . _sliderChanged !== undefined ) {
2016-04-18 12:21:15 +00:00
var props = new Asc . asc _CShapeProperty ( ) ;
var fill = new Asc . asc _CShapeFill ( ) ;
2016-03-11 00:48:53 +00:00
fill . put _transparent ( this . _sliderChanged * 2.55 ) ;
props . put _fill ( fill ) ;
this . api . ShapeApply ( props ) ;
this . _sliderChanged = undefined ;
}
} ,
onGradTypeSelect : function ( combo , record ) {
this . GradFillType = record . value ;
2016-04-05 11:52:34 +00:00
if ( this . GradFillType == Asc . c _oAscFillGradType . GRAD _LINEAR ) {
2016-03-11 00:48:53 +00:00
this . mnuDirectionPicker . store . reset ( this . _viewDataLinear ) ;
this . mnuDirectionPicker . cmpEl . width ( 175 ) ;
this . mnuDirectionPicker . restoreHeight = 174 ;
var record = this . mnuDirectionPicker . store . findWhere ( { type : this . GradLinearDirectionType } ) ;
this . mnuDirectionPicker . selectRecord ( record , true ) ;
2021-09-30 02:16:32 +00:00
if ( record )
this . typeGradient = this . GradLinearDirectionType + 90 ;
2016-03-11 00:48:53 +00:00
else
2021-09-30 02:16:32 +00:00
this . typeGradient = - 1 ;
2020-10-16 14:35:56 +00:00
this . numGradientAngle . setValue ( this . GradLinearDirectionType , true ) ;
2020-09-10 14:36:45 +00:00
this . numGradientAngle . setDisabled ( this . _locked ) ;
2016-04-05 11:52:34 +00:00
} else if ( this . GradFillType == Asc . c _oAscFillGradType . GRAD _PATH ) {
2016-03-11 00:48:53 +00:00
this . mnuDirectionPicker . store . reset ( this . _viewDataRadial ) ;
this . mnuDirectionPicker . cmpEl . width ( 60 ) ;
this . mnuDirectionPicker . restoreHeight = 58 ;
this . mnuDirectionPicker . selectByIndex ( this . GradRadialDirectionIdx , true ) ;
if ( this . GradRadialDirectionIdx >= 0 )
2021-09-30 02:16:32 +00:00
this . typeGradient = this . _viewDataRadial [ this . GradRadialDirectionIdx ] . type ;
2016-03-11 00:48:53 +00:00
else
2021-09-30 02:16:32 +00:00
this . typeGradient = - 1 ;
2020-10-16 14:35:56 +00:00
this . numGradientAngle . setValue ( 0 , true ) ;
2020-09-10 14:36:45 +00:00
this . numGradientAngle . setDisabled ( true ) ;
2016-03-11 00:48:53 +00:00
}
if ( this . api && ! this . _noApply ) {
2016-04-18 12:21:15 +00:00
var props = new Asc . asc _CShapeProperty ( ) ;
var fill = new Asc . asc _CShapeFill ( ) ;
2016-04-05 11:52:34 +00:00
fill . put _type ( Asc . c _oAscFill . FILL _TYPE _GRAD ) ;
2016-04-18 12:21:15 +00:00
fill . put _fill ( new Asc . asc _CFillGrad ( ) ) ;
2016-03-11 00:48:53 +00:00
fill . get _fill ( ) . put _grad _type ( this . GradFillType ) ;
2016-04-05 11:52:34 +00:00
if ( this . GradFillType == Asc . c _oAscFillGradType . GRAD _LINEAR ) {
2016-03-11 00:48:53 +00:00
fill . get _fill ( ) . put _linear _angle ( this . GradLinearDirectionType * 60000 ) ;
fill . get _fill ( ) . put _linear _scale ( true ) ;
}
props . put _fill ( fill ) ;
this . api . ShapeApply ( props ) ;
}
this . fireEvent ( 'editcomplete' , this ) ;
} ,
onSelectGradient : function ( btn , picker , itemView , record ) {
if ( this . _noApply ) return ;
var rawData = { } ,
isPickerSelect = _ . isFunction ( record . toJSON ) ;
if ( isPickerSelect ) {
if ( record . get ( 'selected' ) ) {
rawData = record . toJSON ( ) ;
} else {
// record deselected
return ;
}
} else {
rawData = record ;
}
2021-09-30 02:16:32 +00:00
this . typeGradient = rawData . type + 90 ;
2016-04-05 11:52:34 +00:00
( this . GradFillType == Asc . c _oAscFillGradType . GRAD _LINEAR ) ? this . GradLinearDirectionType = rawData . type : this . GradRadialDirectionIdx = 0 ;
2016-03-11 00:48:53 +00:00
if ( this . api ) {
2016-04-05 11:52:34 +00:00
if ( this . GradFillType == Asc . c _oAscFillGradType . GRAD _LINEAR ) {
2020-10-16 14:35:56 +00:00
this . numGradientAngle . setValue ( rawData . type , true ) ;
2020-09-10 14:36:45 +00:00
2016-04-18 12:21:15 +00:00
var props = new Asc . asc _CShapeProperty ( ) ;
var fill = new Asc . asc _CShapeFill ( ) ;
2016-04-05 11:52:34 +00:00
fill . put _type ( Asc . c _oAscFill . FILL _TYPE _GRAD ) ;
2016-04-18 12:21:15 +00:00
fill . put _fill ( new Asc . asc _CFillGrad ( ) ) ;
2016-03-11 00:48:53 +00:00
fill . get _fill ( ) . put _grad _type ( this . GradFillType ) ;
fill . get _fill ( ) . put _linear _angle ( rawData . type * 60000 ) ;
fill . get _fill ( ) . put _linear _scale ( true ) ;
props . put _fill ( fill ) ;
this . api . ShapeApply ( props ) ;
}
}
this . fireEvent ( 'editcomplete' , this ) ;
} ,
2020-04-29 17:32:18 +00:00
onColorsGradientSelect : function ( btn , color ) {
2016-03-11 00:48:53 +00:00
this . GradColor . colors [ this . GradColor . currentIdx ] = color ;
this . sldrGradient . setColorValue ( Common . Utils . String . format ( '#{0}' , ( typeof ( color ) == 'object' ) ? color . color : color ) ) ;
if ( this . api && ! this . _noApply ) {
2016-04-18 12:21:15 +00:00
var props = new Asc . asc _CShapeProperty ( ) ;
var fill = new Asc . asc _CShapeFill ( ) ;
2016-04-05 11:52:34 +00:00
fill . put _type ( Asc . c _oAscFill . FILL _TYPE _GRAD ) ;
2016-04-18 12:21:15 +00:00
fill . put _fill ( new Asc . asc _CFillGrad ( ) ) ;
2016-03-11 00:48:53 +00:00
fill . get _fill ( ) . put _grad _type ( this . GradFillType ) ;
2019-06-07 08:40:43 +00:00
var arr = [ ] ;
this . GradColor . colors . forEach ( function ( item ) {
arr . push ( Common . Utils . ThemeColor . getRgbColor ( item ) ) ;
} ) ;
fill . get _fill ( ) . put _colors ( arr ) ;
2016-03-11 00:48:53 +00:00
2016-04-05 11:52:34 +00:00
if ( this . OriginalFillType !== Asc . c _oAscFill . FILL _TYPE _GRAD ) {
if ( this . GradFillType == Asc . c _oAscFillGradType . GRAD _LINEAR ) {
2016-03-11 00:48:53 +00:00
fill . get _fill ( ) . put _linear _angle ( this . GradLinearDirectionType * 60000 ) ;
fill . get _fill ( ) . put _linear _scale ( true ) ;
}
2019-06-07 08:40:43 +00:00
arr = [ ] ;
this . GradColor . values . forEach ( function ( item ) {
arr . push ( item * 1000 ) ;
} ) ;
fill . get _fill ( ) . put _positions ( arr ) ;
2016-03-11 00:48:53 +00:00
}
props . put _fill ( fill ) ;
this . api . ShapeApply ( props ) ;
}
this . fireEvent ( 'editcomplete' , this ) ;
} ,
onGradientChange : function ( slider , newValue , oldValue ) {
this . GradColor . values = slider . getValues ( ) ;
2020-07-10 15:21:45 +00:00
this . spnGradPosition . setValue ( this . GradColor . values [ this . GradColor . currentIdx ] , true ) ;
2016-03-11 00:48:53 +00:00
this . _sliderChanged = true ;
if ( this . api && ! this . _noApply ) {
if ( this . _sendUndoPoint ) {
this . api . setStartPointHistory ( ) ;
this . _sendUndoPoint = false ;
this . updateslider = setInterval ( _ . bind ( this . _gradientApplyFunc , this ) , 100 ) ;
}
}
} ,
onGradientChangeComplete : function ( slider , newValue , oldValue ) {
clearInterval ( this . updateslider ) ;
this . _sliderChanged = true ;
2018-11-08 07:58:53 +00:00
if ( ! this . _sendUndoPoint ) { // start point was added
this . api . setEndPointHistory ( ) ;
this . _gradientApplyFunc ( ) ;
}
2021-10-01 22:20:52 +00:00
var arrGrCollors = [ ] ;
var scale = ( this . GradFillType == Asc . c _oAscFillGradType . GRAD _LINEAR ) ? 1 : 0.7 ;
for ( var index = 0 ; index < slider . thumbs . length ; index ++ ) {
arrGrCollors . push ( slider . getColorValue ( index ) + ' ' + slider . getValue ( index ) * scale + '%' ) ;
}
this . btnDirectionRedraw ( slider , arrGrCollors . join ( ', ' ) ) ;
2016-03-11 00:48:53 +00:00
this . _sendUndoPoint = true ;
} ,
2021-10-01 22:20:52 +00:00
btnDirectionRedraw : function ( slider , gradientColorsStr ) {
this . gradientColorsStr = gradientColorsStr ;
if ( this . mnuDirectionPicker . dataViewItems . length == 1 )
this . mnuDirectionPicker . dataViewItems [ 0 ] . $el . children ( 0 ) . css ( { 'background' : 'radial-gradient(' + gradientColorsStr + ')' } ) ;
else
this . mnuDirectionPicker . dataViewItems . forEach ( function ( item ) {
2021-10-05 09:25:58 +00:00
var type = item . model . get ( 'type' ) + 90 ;
2021-10-01 22:20:52 +00:00
item . $el . children ( 0 ) . css ( { 'background' : 'linear-gradient(' + type + 'deg, ' + gradientColorsStr + ')' } ) ;
} ) ;
if ( this . typeGradient == - 1 )
this . btnDirection . $icon . css ( { 'background' : 'none' } ) ;
else if ( this . typeGradient == 2 )
this . btnDirection . $icon . css ( { 'background' : ( 'radial-gradient(' + gradientColorsStr + ')' ) } ) ;
else
this . btnDirection . $icon . css ( {
'background' : ( 'linear-gradient(' + this . typeGradient + 'deg, ' + gradientColorsStr + ')' )
} ) ;
} ,
2016-03-11 00:48:53 +00:00
_gradientApplyFunc : function ( ) {
if ( this . _sliderChanged ) {
2016-04-18 12:21:15 +00:00
var props = new Asc . asc _CShapeProperty ( ) ;
var fill = new Asc . asc _CShapeFill ( ) ;
2016-04-05 11:52:34 +00:00
fill . put _type ( Asc . c _oAscFill . FILL _TYPE _GRAD ) ;
2016-04-18 12:21:15 +00:00
fill . put _fill ( new Asc . asc _CFillGrad ( ) ) ;
2016-03-11 00:48:53 +00:00
fill . get _fill ( ) . put _grad _type ( this . GradFillType ) ;
2019-06-07 08:40:43 +00:00
var arr = [ ] ;
this . GradColor . values . forEach ( function ( item ) {
arr . push ( item * 1000 ) ;
} ) ;
fill . get _fill ( ) . put _positions ( arr ) ;
2016-03-11 00:48:53 +00:00
2019-11-14 06:43:04 +00:00
if ( this . GradFillType == Asc . c _oAscFillGradType . GRAD _LINEAR ) {
fill . get _fill ( ) . put _linear _angle ( this . GradLinearDirectionType * 60000 ) ;
fill . get _fill ( ) . put _linear _scale ( true ) ;
2016-03-11 00:48:53 +00:00
}
2019-11-14 06:43:04 +00:00
arr = [ ] ;
this . GradColor . colors . forEach ( function ( item ) {
arr . push ( Common . Utils . ThemeColor . getRgbColor ( item ) ) ;
} ) ;
fill . get _fill ( ) . put _colors ( arr ) ;
2016-03-11 00:48:53 +00:00
props . put _fill ( fill ) ;
this . api . ShapeApply ( props ) ;
this . _sliderChanged = false ;
}
} ,
applyBorderSize : function ( value ) {
2020-03-31 13:49:33 +00:00
value = Common . Utils . String . parseFloat ( value ) ;
2016-03-11 00:48:53 +00:00
value = isNaN ( value ) ? 0 : Math . max ( 0 , Math . min ( 1584 , value ) ) ;
this . BorderSize = value ;
if ( this . api && ! this . _noApply ) {
2016-04-18 12:21:15 +00:00
var props = new Asc . asc _CShapeProperty ( ) ;
var stroke = new Asc . asc _CStroke ( ) ;
2017-08-02 12:40:49 +00:00
if ( this . BorderSize < 0.00001 ) {
2016-04-05 11:52:34 +00:00
stroke . put _type ( Asc . c _oAscStrokeType . STROKE _NONE ) ;
2016-03-11 00:48:53 +00:00
this . _state . StrokeType = this . _state . StrokeWidth = - 1 ;
} else {
2016-04-05 11:52:34 +00:00
stroke . put _type ( Asc . c _oAscStrokeType . STROKE _COLOR ) ;
2016-03-11 00:48:53 +00:00
if ( this . BorderColor . Color == 'transparent' || this . BorderColor . Color . color == 'transparent' )
stroke . put _color ( Common . Utils . ThemeColor . getRgbColor ( { color : '000000' , effectId : 29 } ) ) ;
2016-04-05 11:52:34 +00:00
else if ( this . _state . StrokeType == Asc . c _oAscStrokeType . STROKE _NONE || this . _state . StrokeType === null )
2016-03-11 00:48:53 +00:00
stroke . put _color ( Common . Utils . ThemeColor . getRgbColor ( Common . Utils . ThemeColor . colorValue2EffectId ( this . BorderColor . Color ) ) ) ;
2016-07-01 08:16:09 +00:00
stroke . asc _putPrstDash ( this . BorderType ) ;
2016-03-11 00:48:53 +00:00
stroke . put _width ( this . _pt2mm ( this . BorderSize ) ) ;
}
props . put _stroke ( stroke ) ;
this . api . ShapeApply ( props ) ;
}
this . fireEvent ( 'editcomplete' , this ) ;
} ,
onComboBlur : function ( ) {
this . fireEvent ( 'editcomplete' , this ) ;
} ,
onBorderSizeChanged : function ( before , combo , record , e ) {
var me = this ;
if ( before ) {
2016-04-06 13:38:54 +00:00
var value = parseFloat ( record . value ) ,
expr = new RegExp ( '^\\s*(\\d*(\\.|,)?\\d+)\\s*(' + me . txtPt + ')?\\s*$' ) ;
if ( ! ( expr . exec ( record . value ) ) || value < 0 || value > 1584 ) {
2016-03-11 00:48:53 +00:00
this . _state . StrokeType = this . _state . StrokeWidth = - 1 ;
2021-04-26 14:05:45 +00:00
setTimeout ( function ( ) {
Common . UI . error ( {
msg : me . textBorderSizeErr ,
callback : function ( ) {
_ . defer ( function ( btn ) {
me . fireEvent ( 'editcomplete' , me ) ;
} )
}
} ) ;
} , 10 ) ;
2016-03-11 00:48:53 +00:00
}
} else
this . applyBorderSize ( record . value ) ;
} ,
onBorderSizeSelect : function ( combo , record ) {
this . applyBorderSize ( record . value ) ;
} ,
2016-07-01 08:16:09 +00:00
onBorderTypeSelect : function ( combo , record ) {
this . BorderType = record . value ;
if ( this . api && ! this . _noApply ) {
var props = new Asc . asc _CShapeProperty ( ) ;
var stroke = new Asc . asc _CStroke ( ) ;
2017-08-02 12:40:49 +00:00
if ( this . BorderSize < 0.00001 ) {
2016-07-01 08:16:09 +00:00
stroke . put _type ( Asc . c _oAscStrokeType . STROKE _NONE ) ;
} else {
stroke . put _type ( Asc . c _oAscStrokeType . STROKE _COLOR ) ;
stroke . put _color ( Common . Utils . ThemeColor . getRgbColor ( this . BorderColor . Color ) ) ;
stroke . put _width ( this . _pt2mm ( this . BorderSize ) ) ;
stroke . asc _putPrstDash ( this . BorderType ) ;
}
props . put _stroke ( stroke ) ;
this . api . ShapeApply ( props ) ;
}
this . fireEvent ( 'editcomplete' , this ) ;
} ,
2020-04-29 17:32:18 +00:00
onColorsBorderSelect : function ( btn , color ) {
2016-03-11 00:48:53 +00:00
this . BorderColor = { Value : 1 , Color : color } ;
if ( this . api && this . BorderSize > 0 && ! this . _noApply ) {
2016-04-18 12:21:15 +00:00
var props = new Asc . asc _CShapeProperty ( ) ;
var stroke = new Asc . asc _CStroke ( ) ;
2017-08-02 12:40:49 +00:00
if ( this . BorderSize < 0.00001 ) {
2016-04-05 11:52:34 +00:00
stroke . put _type ( Asc . c _oAscStrokeType . STROKE _NONE ) ;
2016-03-11 00:48:53 +00:00
} else {
2016-04-05 11:52:34 +00:00
stroke . put _type ( Asc . c _oAscStrokeType . STROKE _COLOR ) ;
2016-03-11 00:48:53 +00:00
stroke . put _color ( Common . Utils . ThemeColor . getRgbColor ( this . BorderColor . Color ) ) ;
stroke . put _width ( this . _pt2mm ( this . BorderSize ) ) ;
2016-07-01 08:16:09 +00:00
stroke . asc _putPrstDash ( this . BorderType ) ;
2016-03-11 00:48:53 +00:00
}
props . put _stroke ( stroke ) ;
this . api . ShapeApply ( props ) ;
}
this . fireEvent ( 'editcomplete' , this ) ;
} ,
2020-05-13 14:59:16 +00:00
setImageUrl : function ( url , token ) {
if ( this . BlipFillType !== null ) {
var props = new Asc . asc _CShapeProperty ( ) ;
var fill = new Asc . asc _CShapeFill ( ) ;
fill . put _type ( Asc . c _oAscFill . FILL _TYPE _BLIP ) ;
fill . put _fill ( new Asc . asc _CFillBlip ( ) ) ;
fill . get _fill ( ) . put _type ( this . BlipFillType ) ;
fill . get _fill ( ) . put _url ( url , token ) ;
props . put _fill ( fill ) ;
this . api . ShapeApply ( props ) ;
}
} ,
2020-05-13 14:20:58 +00:00
insertImageFromStorage : function ( data ) {
2021-08-27 11:07:50 +00:00
if ( data && data . _urls && data . c == 'fill' ) {
this . setImageUrl ( data . _urls [ 0 ] , data . token ) ;
2020-05-13 14:20:58 +00:00
}
} ,
onImageSelect : function ( menu , item ) {
if ( item . value == 1 ) {
var me = this ;
( new Common . Views . ImageFromUrlDialog ( {
handler : function ( result , value ) {
if ( result == 'ok' ) {
if ( me . api ) {
var checkUrl = value . replace ( / /g , '' ) ;
if ( ! _ . isEmpty ( checkUrl ) ) {
2020-05-13 14:59:16 +00:00
me . setImageUrl ( checkUrl ) ;
2016-03-11 00:48:53 +00:00
}
}
}
2020-05-13 14:20:58 +00:00
me . fireEvent ( 'editcomplete' , me ) ;
2016-03-11 00:48:53 +00:00
}
2020-05-13 14:20:58 +00:00
} ) ) . show ( ) ;
} else if ( item . value == 2 ) {
Common . NotificationCenter . trigger ( 'storage:image-load' , 'fill' ) ;
} else {
if ( this . api ) this . api . ChangeShapeImageFromFile ( this . BlipFillType ) ;
this . fireEvent ( 'editcomplete' , this ) ;
}
2016-03-11 00:48:53 +00:00
} ,
openAdvancedSettings : function ( e ) {
if ( this . linkAdvanced . hasClass ( 'disabled' ) ) return ;
var me = this ;
var win ;
if ( me . api && ! this . _locked ) {
var selectedElements = me . api . getSelectedElements ( ) ;
if ( selectedElements && selectedElements . length > 0 ) {
var elType , elValue ;
for ( var i = selectedElements . length - 1 ; i >= 0 ; i -- ) {
elType = selectedElements [ i ] . get _ObjectType ( ) ;
elValue = selectedElements [ i ] . get _ObjectValue ( ) ;
2016-04-05 11:52:34 +00:00
if ( Asc . c _oAscTypeSelectElement . Shape == elType ) {
2016-03-11 00:48:53 +00:00
( new PE . Views . ShapeSettingsAdvanced (
{
shapeProps : elValue ,
handler : function ( result , value ) {
if ( result == 'ok' ) {
if ( me . api ) {
me . api . ShapeApply ( value . shapeProps ) ;
}
}
me . fireEvent ( 'editcomplete' , me ) ;
}
} ) ) . show ( ) ;
break ;
}
}
}
}
} ,
ChangeSettings : function ( props ) {
if ( this . _initSettings )
this . createDelayedElements ( ) ;
if ( props )
{
this . _originalProps = props ;
this . _noApply = true ;
var shapetype = props . asc _getType ( ) ;
this . disableControls ( this . _locked == true , props . get _CanFill ( ) !== true ) ;
2018-02-06 08:56:13 +00:00
this . hideShapeOnlySettings ( props . get _FromChart ( ) || props . get _FromImage ( ) ) ;
var hidechangetype = props . get _FromChart ( ) || shapetype == 'line' || shapetype == 'bentConnector2' || shapetype == 'bentConnector3'
|| shapetype == 'bentConnector4' || shapetype == 'bentConnector5' || shapetype == 'curvedConnector2'
|| shapetype == 'curvedConnector3' || shapetype == 'curvedConnector4' || shapetype == 'curvedConnector5'
|| shapetype == 'straightConnector1' ;
this . hideChangeTypeSettings ( hidechangetype ) ;
2019-08-20 11:05:13 +00:00
this . _state . isFromImage = ! ! props . get _FromImage ( ) ;
if ( ! hidechangetype && this . btnChangeShape . menu . items . length ) {
2018-02-06 08:56:13 +00:00
this . btnChangeShape . menu . items [ 0 ] . setVisible ( props . get _FromImage ( ) ) ;
this . btnChangeShape . menu . items [ 1 ] . setVisible ( ! props . get _FromImage ( ) ) ;
}
2016-03-11 00:48:53 +00:00
// background colors
var rec = null ;
var fill = props . get _fill ( ) ;
var fill _type = fill . get _type ( ) ;
var color = null ;
var transparency = fill . get _transparent ( ) ;
if ( Math . abs ( this . _state . Transparency - transparency ) > 0.001 || Math . abs ( this . numTransparency . getNumberValue ( ) - transparency ) > 0.001 ||
( this . _state . Transparency === null || transparency === null ) && ( this . _state . Transparency !== transparency || this . numTransparency . getNumberValue ( ) !== transparency ) ) {
if ( transparency !== undefined ) {
this . sldrTransparency . setValue ( ( transparency === null ) ? 100 : transparency / 255 * 100 , true ) ;
this . numTransparency . setValue ( this . sldrTransparency . getValue ( ) , true ) ;
}
this . _state . Transparency = transparency ;
}
if ( fill === null || fill _type === null ) { // заливка не совпадает у неск. фигур
this . OriginalFillType = null ;
2016-04-05 11:52:34 +00:00
} else if ( fill _type == Asc . c _oAscFill . FILL _TYPE _NOFILL ) { // заливки нет
this . OriginalFillType = Asc . c _oAscFill . FILL _TYPE _NOFILL ;
} else if ( fill _type == Asc . c _oAscFill . FILL _TYPE _SOLID ) {
2016-03-11 00:48:53 +00:00
fill = fill . get _fill ( ) ;
color = fill . get _color ( ) ;
if ( color ) {
2016-04-05 11:52:34 +00:00
if ( color . get _type ( ) == Asc . c _oAscColor . COLOR _TYPE _SCHEME ) {
2016-03-11 00:48:53 +00:00
this . ShapeColor = { Value : 1 , Color : { color : Common . Utils . ThemeColor . getHexColor ( color . get _r ( ) , color . get _g ( ) , color . get _b ( ) ) , effectValue : color . get _value ( ) } } ;
} else {
this . ShapeColor = { Value : 1 , Color : Common . Utils . ThemeColor . getHexColor ( color . get _r ( ) , color . get _g ( ) , color . get _b ( ) ) } ;
}
} else
this . ShapeColor = { Value : 0 , Color : 'transparent' } ;
2016-04-05 11:52:34 +00:00
this . OriginalFillType = Asc . c _oAscFill . FILL _TYPE _SOLID ;
2016-03-11 00:48:53 +00:00
this . FGColor = ( this . ShapeColor . Color !== 'transparent' ) ? { Value : 1 , Color : Common . Utils . ThemeColor . colorValue2EffectId ( this . ShapeColor . Color ) } : { Value : 1 , Color : '000000' } ;
this . BGColor = { Value : 1 , Color : 'ffffff' } ;
this . GradColor . colors [ 0 ] = ( this . ShapeColor . Color !== 'transparent' ) ? Common . Utils . ThemeColor . colorValue2EffectId ( this . ShapeColor . Color ) : '000000' ;
2019-06-07 08:40:43 +00:00
this . GradColor . colors [ this . GradColor . colors . length - 1 ] = 'ffffff' ;
2016-04-05 11:52:34 +00:00
} else if ( fill _type == Asc . c _oAscFill . FILL _TYPE _BLIP ) {
2016-03-11 00:48:53 +00:00
fill = fill . get _fill ( ) ;
this . BlipFillType = fill . get _type ( ) ; // null - не совпадают у нескольких фигур
if ( this . _state . BlipFillType !== this . BlipFillType ) {
2016-04-05 11:52:34 +00:00
if ( this . BlipFillType == Asc . c _oAscFillBlipType . STRETCH || this . BlipFillType == Asc . c _oAscFillBlipType . TILE ) {
2016-03-11 00:48:53 +00:00
this . cmbFillType . setValue ( this . BlipFillType ) ;
} else
this . cmbFillType . setValue ( '' ) ;
this . _state . BlipFillType = this . BlipFillType ;
}
2016-04-05 11:52:34 +00:00
this . OriginalFillType = Asc . c _oAscFill . FILL _TYPE _BLIP ;
} else if ( fill _type == Asc . c _oAscFill . FILL _TYPE _PATT ) {
2016-03-11 00:48:53 +00:00
fill = fill . get _fill ( ) ;
this . PatternFillType = fill . get _pattern _type ( ) ; // null - не совпадают у нескольких фигур
if ( this . _state . PatternFillType !== this . PatternFillType ) {
this . cmbPattern . suspendEvents ( ) ;
var rec = this . cmbPattern . menuPicker . store . findWhere ( {
type : this . PatternFillType
} ) ;
this . cmbPattern . menuPicker . selectRecord ( rec ) ;
this . cmbPattern . resumeEvents ( ) ;
this . _state . PatternFillType = this . PatternFillType ;
}
color = fill . get _color _fg ( ) ;
if ( color ) {
2016-04-05 11:52:34 +00:00
if ( color . get _type ( ) == Asc . c _oAscColor . COLOR _TYPE _SCHEME ) {
2016-03-11 00:48:53 +00:00
this . FGColor = { Value : 1 , Color : { color : Common . Utils . ThemeColor . getHexColor ( color . get _r ( ) , color . get _g ( ) , color . get _b ( ) ) , effectValue : color . get _value ( ) } } ;
} else {
this . FGColor = { Value : 1 , Color : Common . Utils . ThemeColor . getHexColor ( color . get _r ( ) , color . get _g ( ) , color . get _b ( ) ) } ;
}
} else
this . FGColor = { Value : 1 , Color : '000000' } ;
color = fill . get _color _bg ( ) ;
if ( color ) {
2016-04-05 11:52:34 +00:00
if ( color . get _type ( ) == Asc . c _oAscColor . COLOR _TYPE _SCHEME ) {
2016-03-11 00:48:53 +00:00
this . BGColor = { Value : 1 , Color : { color : Common . Utils . ThemeColor . getHexColor ( color . get _r ( ) , color . get _g ( ) , color . get _b ( ) ) , effectValue : color . get _value ( ) } } ;
} else {
this . BGColor = { Value : 1 , Color : Common . Utils . ThemeColor . getHexColor ( color . get _r ( ) , color . get _g ( ) , color . get _b ( ) ) } ;
}
} else
this . BGColor = { Value : 1 , Color : 'ffffff' } ;
2016-04-05 11:52:34 +00:00
this . OriginalFillType = Asc . c _oAscFill . FILL _TYPE _PATT ;
2016-03-11 00:48:53 +00:00
this . ShapeColor = { Value : 1 , Color : Common . Utils . ThemeColor . colorValue2EffectId ( this . FGColor . Color ) } ;
this . GradColor . colors [ 0 ] = Common . Utils . ThemeColor . colorValue2EffectId ( this . FGColor . Color ) ;
2019-06-07 08:40:43 +00:00
this . GradColor . colors [ this . GradColor . colors . length - 1 ] = 'ffffff' ;
2016-04-05 11:52:34 +00:00
} else if ( fill _type == Asc . c _oAscFill . FILL _TYPE _GRAD ) {
2016-03-11 00:48:53 +00:00
fill = fill . get _fill ( ) ;
var gradfilltype = fill . get _grad _type ( ) ; // null - не совпадают у нескольких фигур
if ( this . _state . GradFillType !== gradfilltype || this . GradFillType !== gradfilltype ) {
this . GradFillType = gradfilltype ;
rec = undefined ;
2016-04-05 11:52:34 +00:00
if ( this . GradFillType == Asc . c _oAscFillGradType . GRAD _LINEAR || this . GradFillType == Asc . c _oAscFillGradType . GRAD _PATH ) {
2016-03-11 00:48:53 +00:00
this . cmbGradType . setValue ( this . GradFillType ) ;
rec = this . cmbGradType . store . findWhere ( { value : this . GradFillType } ) ;
this . onGradTypeSelect ( this . cmbGradType , rec . attributes ) ;
} else {
this . cmbGradType . setValue ( '' ) ;
2021-09-30 02:16:32 +00:00
this . typeGradient = - 1 ;
2016-03-11 00:48:53 +00:00
}
this . _state . GradFillType = this . GradFillType ;
}
2016-04-05 11:52:34 +00:00
if ( this . GradFillType == Asc . c _oAscFillGradType . GRAD _LINEAR ) {
2016-03-11 00:48:53 +00:00
var value = Math . floor ( fill . get _linear _angle ( ) / 60000 ) ;
if ( Math . abs ( this . GradLinearDirectionType - value ) > 0.001 ) {
this . GradLinearDirectionType = value ;
var record = this . mnuDirectionPicker . store . findWhere ( { type : value } ) ;
this . mnuDirectionPicker . selectRecord ( record , true ) ;
if ( record )
2021-09-30 02:16:32 +00:00
this . typeGradient = value + 90 ;
2016-03-11 00:48:53 +00:00
else
2021-09-30 02:16:32 +00:00
this . typeGradient = - 1 ;
2020-10-16 14:35:56 +00:00
this . numGradientAngle . setValue ( value , true ) ;
2016-03-11 00:48:53 +00:00
}
2020-09-10 14:36:45 +00:00
} else
2020-10-16 14:35:56 +00:00
this . numGradientAngle . setValue ( 0 , true ) ;
2016-03-11 00:48:53 +00:00
2019-06-07 08:40:43 +00:00
var me = this ;
var colors = fill . get _colors ( ) ,
positions = fill . get _positions ( ) ,
2019-12-05 08:16:19 +00:00
length = colors ? colors . length : this . GradColor . colors . length ;
2019-06-07 08:40:43 +00:00
this . sldrGradient . setThumbs ( length ) ;
if ( this . GradColor . colors . length > length ) {
this . GradColor . colors . splice ( length , this . GradColor . colors . length - length ) ;
this . GradColor . values . splice ( length , this . GradColor . colors . length - length ) ;
this . GradColor . currentIdx = 0 ;
}
colors && colors . forEach ( function ( color , index ) {
2016-03-11 00:48:53 +00:00
if ( color ) {
2016-04-05 11:52:34 +00:00
if ( color . get _type ( ) == Asc . c _oAscColor . COLOR _TYPE _SCHEME ) {
2019-06-07 08:40:43 +00:00
me . GradColor . colors [ index ] = { color : Common . Utils . ThemeColor . getHexColor ( color . get _r ( ) , color . get _g ( ) , color . get _b ( ) ) , effectValue : color . get _value ( ) } ;
Common . Utils . ThemeColor . colorValue2EffectId ( me . GradColor . colors [ index ] ) ;
2016-03-11 00:48:53 +00:00
} else {
2019-06-07 08:40:43 +00:00
me . GradColor . colors [ index ] = Common . Utils . ThemeColor . getHexColor ( color . get _r ( ) , color . get _g ( ) , color . get _b ( ) ) ;
2016-03-11 00:48:53 +00:00
}
} else
2019-06-07 08:40:43 +00:00
me . GradColor . colors [ index ] = '000000' ;
2016-03-11 00:48:53 +00:00
2019-06-07 08:40:43 +00:00
var position = positions [ index ] ;
2016-03-11 00:48:53 +00:00
if ( position !== null ) {
position = position / 1000 ;
2019-06-07 08:40:43 +00:00
me . GradColor . values [ index ] = position ;
2016-03-11 00:48:53 +00:00
}
2019-06-07 08:40:43 +00:00
} ) ;
2021-09-30 02:16:32 +00:00
var arrGrCollors = [ ] ;
var scale = ( this . GradFillType == Asc . c _oAscFillGradType . GRAD _LINEAR ) ? 1 : 0.7 ;
2019-06-07 08:40:43 +00:00
for ( var index = 0 ; index < length ; index ++ ) {
me . sldrGradient . setColorValue ( Common . Utils . String . format ( '#{0}' , ( typeof ( me . GradColor . colors [ index ] ) == 'object' ) ? me . GradColor . colors [ index ] . color : me . GradColor . colors [ index ] ) , index ) ;
me . sldrGradient . setValue ( index , me . GradColor . values [ index ] ) ;
2021-09-30 02:16:32 +00:00
arrGrCollors . push ( me . sldrGradient . getColorValue ( index ) + ' ' + me . sldrGradient . getValue ( index ) * scale + '%' ) ;
2016-03-11 00:48:53 +00:00
}
2021-10-01 22:20:52 +00:00
this . btnDirectionRedraw ( me . sldrGradient , arrGrCollors . join ( ', ' ) ) ;
2021-09-30 02:16:32 +00:00
2019-11-15 11:05:50 +00:00
if ( _ . isUndefined ( me . GradColor . currentIdx ) || me . GradColor . currentIdx >= this . GradColor . colors . length ) {
me . GradColor . currentIdx = 0 ;
2019-11-15 08:42:13 +00:00
}
2020-07-09 18:51:19 +00:00
this . sldrGradient . setActiveThumb ( me . GradColor . currentIdx ) ;
this . spnGradPosition . setValue ( this . GradColor . values [ this . GradColor . currentIdx ] ) ;
2016-04-05 11:52:34 +00:00
this . OriginalFillType = Asc . c _oAscFill . FILL _TYPE _GRAD ;
2016-03-11 00:48:53 +00:00
this . FGColor = { Value : 1 , Color : this . GradColor . colors [ 0 ] } ;
this . BGColor = { Value : 1 , Color : 'ffffff' } ;
this . ShapeColor = { Value : 1 , Color : this . GradColor . colors [ 0 ] } ;
}
if ( this . _state . FillType !== this . OriginalFillType ) {
this . cmbFillSrc . setValue ( ( this . OriginalFillType === null ) ? '' : this . OriginalFillType ) ;
this . _state . FillType = this . OriginalFillType ;
this . ShowHideElem ( this . OriginalFillType ) ;
}
$ ( this . btnTexture . el ) . find ( '.form-control' ) . prop ( 'innerHTML' , this . textSelectTexture ) ;
var type1 = typeof ( this . ShapeColor . Color ) ,
type2 = typeof ( this . _state . ShapeColor ) ;
if ( ( type1 !== type2 ) || ( type1 == 'object' &&
( this . ShapeColor . Color . effectValue !== this . _state . ShapeColor . effectValue || this . _state . ShapeColor . color . indexOf ( this . ShapeColor . Color . color ) < 0 ) ) ||
( type1 != 'object' && this . _state . ShapeColor . indexOf ( this . ShapeColor . Color ) < 0 ) ) {
this . btnBackColor . setColor ( this . ShapeColor . Color ) ;
if ( typeof ( this . ShapeColor . Color ) == 'object' ) {
var isselected = false ;
for ( var i = 0 ; i < 10 ; i ++ ) {
if ( Common . Utils . ThemeColor . ThemeValues [ i ] == this . ShapeColor . Color . effectValue ) {
this . colorsBack . select ( this . ShapeColor . Color , true ) ;
isselected = true ;
break ;
}
}
if ( ! isselected ) this . colorsBack . clearSelection ( ) ;
} else
this . colorsBack . select ( this . ShapeColor . Color , true ) ;
this . _state . ShapeColor = this . ShapeColor . Color ;
}
// border colors
2016-07-01 08:16:09 +00:00
var stroke = props . get _stroke ( ) ,
strokeType = stroke . get _type ( ) ,
2017-10-31 12:36:28 +00:00
borderType ,
update = ( this . _state . StrokeColor == 'transparent' && this . BorderColor . Color !== 'transparent' ) ; // border color was changed for shape without line and then shape was reselected (or apply other settings)
2016-03-11 00:48:53 +00:00
if ( stroke ) {
2016-04-05 11:52:34 +00:00
if ( strokeType == Asc . c _oAscStrokeType . STROKE _COLOR ) {
2016-03-11 00:48:53 +00:00
color = stroke . get _color ( ) ;
if ( color ) {
2016-04-05 11:52:34 +00:00
if ( color . get _type ( ) == Asc . c _oAscColor . COLOR _TYPE _SCHEME ) {
2016-03-11 00:48:53 +00:00
this . BorderColor = { Value : 1 , Color : { color : Common . Utils . ThemeColor . getHexColor ( color . get _r ( ) , color . get _g ( ) , color . get _b ( ) ) , effectValue : color . get _value ( ) } } ;
}
else
this . BorderColor = { Value : 1 , Color : Common . Utils . ThemeColor . getHexColor ( color . get _r ( ) , color . get _g ( ) , color . get _b ( ) ) } ;
}
else
this . BorderColor = { Value : 1 , Color : 'transparent' } ;
} else {
this . BorderColor = { Value : 1 , Color : 'transparent' } ;
}
2016-07-01 08:16:09 +00:00
borderType = stroke . asc _getPrstDash ( ) ;
2016-03-11 00:48:53 +00:00
} else { // no stroke
strokeType = null ;
this . BorderColor = { Value : 0 , Color : 'transparent' } ;
}
type1 = typeof ( this . BorderColor . Color ) ;
type2 = typeof ( this . _state . StrokeColor ) ;
2017-10-31 12:36:28 +00:00
if ( update || ( type1 !== type2 ) || ( type1 == 'object' &&
2016-03-11 00:48:53 +00:00
( this . BorderColor . Color . effectValue !== this . _state . StrokeColor . effectValue || this . _state . StrokeColor . color . indexOf ( this . BorderColor . Color . color ) < 0 ) ) ||
( type1 != 'object' && ( this . _state . StrokeColor . indexOf ( this . BorderColor . Color ) < 0 || typeof ( this . btnBorderColor . color ) == 'object' ) ) ) {
this . btnBorderColor . setColor ( this . BorderColor . Color ) ;
if ( typeof ( this . BorderColor . Color ) == 'object' ) {
var isselected = false ;
for ( var i = 0 ; i < 10 ; i ++ ) {
if ( Common . Utils . ThemeColor . ThemeValues [ i ] == this . BorderColor . Color . effectValue ) {
this . colorsBorder . select ( this . BorderColor . Color , true ) ;
isselected = true ;
break ;
}
}
if ( ! isselected ) this . colorsBorder . clearSelection ( ) ;
} else
this . colorsBorder . select ( this . BorderColor . Color , true ) ;
this . _state . StrokeColor = this . BorderColor . Color ;
}
2016-04-05 11:52:34 +00:00
if ( this . _state . StrokeType !== strokeType || strokeType == Asc . c _oAscStrokeType . STROKE _COLOR ) {
if ( strokeType == Asc . c _oAscStrokeType . STROKE _COLOR ) {
2016-03-11 00:48:53 +00:00
var w = stroke . get _width ( ) ;
2017-08-02 12:40:49 +00:00
var check _value = ( Math . abs ( this . _state . StrokeWidth - w ) < 0.00001 ) && ! ( ( new RegExp ( this . txtPt + '\\s*$' ) ) . test ( this . cmbBorderSize . getRawValue ( ) ) ) ;
if ( Math . abs ( this . _state . StrokeWidth - w ) > 0.00001 || check _value ||
2016-03-11 00:48:53 +00:00
( this . _state . StrokeWidth === null || w === null ) && ( this . _state . StrokeWidth !== w ) ) {
this . _state . StrokeWidth = w ;
if ( w !== null ) w = this . _mm2pt ( w ) ;
var _selectedItem = ( w === null ) ? w : _ . find ( this . cmbBorderSize . store . models , function ( item ) {
2017-08-02 12:40:49 +00:00
if ( w < item . attributes . value + 0.00001 && w > item . attributes . value - 0.00001 ) {
2016-03-11 00:48:53 +00:00
return true ;
}
} ) ;
if ( _selectedItem )
this . cmbBorderSize . selectRecord ( _selectedItem ) ;
else {
2016-04-06 13:38:54 +00:00
this . cmbBorderSize . setValue ( ( w !== null ) ? parseFloat ( w . toFixed ( 2 ) ) + ' ' + this . txtPt : '' ) ;
2016-03-11 00:48:53 +00:00
}
this . BorderSize = w ;
}
2016-04-05 11:52:34 +00:00
} else if ( strokeType == Asc . c _oAscStrokeType . STROKE _NONE ) {
2016-03-11 00:48:53 +00:00
this . _state . StrokeWidth = 0 ;
this . BorderSize = this . cmbBorderSize . store . at ( 0 ) . get ( 'value' ) ;
this . cmbBorderSize . setValue ( this . BorderSize ) ;
} else {
this . _state . StrokeWidth = null ;
this . BorderSize = - 1 ;
this . cmbBorderSize . setValue ( null ) ;
}
this . _state . StrokeType = strokeType ;
}
2016-10-14 10:48:04 +00:00
if ( this . _state . StrokeBorderType !== borderType ) {
this . BorderType = this . _state . StrokeBorderType = borderType ;
this . cmbBorderType . setValue ( borderType ) ;
}
// pattern colors
type1 = typeof ( this . FGColor . Color ) ;
type2 = typeof ( this . _state . FGColor ) ;
if ( ( type1 !== type2 ) || ( type1 == 'object' &&
( this . FGColor . Color . effectValue !== this . _state . FGColor . effectValue || this . _state . FGColor . color . indexOf ( this . FGColor . Color . color ) < 0 ) ) ||
( type1 != 'object' && this . _state . FGColor . indexOf ( this . FGColor . Color ) < 0 ) ) {
this . btnFGColor . setColor ( this . FGColor . Color ) ;
if ( typeof ( this . FGColor . Color ) == 'object' ) {
var isselected = false ;
for ( var i = 0 ; i < 10 ; i ++ ) {
if ( Common . Utils . ThemeColor . ThemeValues [ i ] == this . FGColor . Color . effectValue ) {
this . colorsFG . select ( this . FGColor . Color , true ) ;
isselected = true ;
break ;
}
}
if ( ! isselected ) this . colorsFG . clearSelection ( ) ;
} else
this . colorsFG . select ( this . FGColor . Color , true ) ;
this . _state . FGColor = this . FGColor . Color ;
}
type1 = typeof ( this . BGColor . Color ) ;
type2 = typeof ( this . _state . BGColor ) ;
if ( ( type1 !== type2 ) || ( type1 == 'object' &&
( this . BGColor . Color . effectValue !== this . _state . BGColor . effectValue || this . _state . BGColor . color . indexOf ( this . BGColor . Color . color ) < 0 ) ) ||
( type1 != 'object' && this . _state . BGColor . indexOf ( this . BGColor . Color ) < 0 ) ) {
this . btnBGColor . setColor ( this . BGColor . Color ) ;
if ( typeof ( this . BGColor . Color ) == 'object' ) {
var isselected = false ;
for ( var i = 0 ; i < 10 ; i ++ ) {
if ( Common . Utils . ThemeColor . ThemeValues [ i ] == this . BGColor . Color . effectValue ) {
this . colorsBG . select ( this . BGColor . Color , true ) ;
isselected = true ;
break ;
}
}
if ( ! isselected ) this . colorsBG . clearSelection ( ) ;
} else
this . colorsBG . select ( this . BGColor . Color , true ) ;
this . _state . BGColor = this . BGColor . Color ;
}
color = this . GradColor . colors [ this . GradColor . currentIdx ] ;
type1 = typeof ( color ) ;
type2 = typeof ( this . _state . GradColor ) ;
if ( ( type1 !== type2 ) || ( type1 == 'object' &&
( color . effectValue !== this . _state . GradColor . effectValue || this . _state . GradColor . color . indexOf ( color . color ) < 0 ) ) ||
( type1 != 'object' && this . _state . GradColor . indexOf ( color ) < 0 ) ) {
this . btnGradColor . setColor ( color ) ;
if ( typeof ( color ) == 'object' ) {
var isselected = false ;
for ( var i = 0 ; i < 10 ; i ++ ) {
if ( Common . Utils . ThemeColor . ThemeValues [ i ] == color . effectValue ) {
this . colorsGrad . select ( color , true ) ;
isselected = true ;
break ;
}
}
if ( ! isselected ) this . colorsGrad . clearSelection ( ) ;
} else
this . colorsGrad . select ( color , true ) ;
this . _state . GradColor = color ;
}
2019-08-05 15:15:29 +00:00
this . chShadow . setValue ( ! ! props . asc _getShadow ( ) , true ) ;
2019-08-05 11:12:50 +00:00
2016-10-14 10:48:04 +00:00
this . _noApply = false ;
}
} ,
createDelayedControls : function ( ) {
var me = this ;
this . _arrFillSrc = [
{ displayValue : this . textColor , value : Asc . c _oAscFill . FILL _TYPE _SOLID } ,
{ displayValue : this . textGradientFill , value : Asc . c _oAscFill . FILL _TYPE _GRAD } ,
{ displayValue : this . textImageTexture , value : Asc . c _oAscFill . FILL _TYPE _BLIP } ,
{ displayValue : this . textPatternFill , value : Asc . c _oAscFill . FILL _TYPE _PATT } ,
{ displayValue : this . textNoFill , value : Asc . c _oAscFill . FILL _TYPE _NOFILL }
] ;
this . cmbFillSrc = new Common . UI . ComboBox ( {
el : $ ( '#shape-combo-fill-src' ) ,
cls : 'input-group-nr' ,
style : 'width: 100%;' ,
2018-08-15 12:12:05 +00:00
menuStyle : 'min-width: 100%;' ,
2016-10-14 10:48:04 +00:00
editable : false ,
2021-06-16 13:43:51 +00:00
data : this . _arrFillSrc ,
dataHint : '1' ,
dataHintDirection : 'bottom' ,
dataHintOffset : 'big'
2016-10-14 10:48:04 +00:00
} ) ;
this . cmbFillSrc . setValue ( this . _arrFillSrc [ 0 ] . value ) ;
this . cmbFillSrc . on ( 'selected' , _ . bind ( this . onFillSrcSelect , this ) ) ;
this . fillControls . push ( this . cmbFillSrc ) ;
this . cmbPattern = new Common . UI . ComboDataView ( {
itemWidth : 28 ,
itemHeight : 28 ,
menuMaxHeight : 300 ,
enableKeyEvents : true ,
2021-06-16 13:43:51 +00:00
cls : 'combo-pattern' ,
dataHint : '1' ,
dataHintDirection : 'bottom' ,
dataHintOffset : 'big'
2016-10-14 10:48:04 +00:00
} ) ;
this . cmbPattern . menuPicker . itemTemplate = this . cmbPattern . fieldPicker . itemTemplate = _ . template ( [
'<div class="style" id="<%= id %>">' ,
'<img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class="combo-pattern-item" ' ,
'width="' + this . cmbPattern . itemWidth + '" height="' + this . cmbPattern . itemHeight + '" ' ,
'style="background-position: -<%= offsetx %>px -<%= offsety %>px;"/>' ,
'</div>'
] . join ( '' ) ) ;
this . cmbPattern . render ( $ ( '#shape-combo-pattern' ) ) ;
this . cmbPattern . openButton . menu . cmpEl . css ( {
'min-width' : 178 ,
'max-width' : 178
} ) ;
this . cmbPattern . on ( 'click' , _ . bind ( this . onPatternSelect , this ) ) ;
this . cmbPattern . openButton . menu . on ( 'show:after' , function ( ) {
me . cmbPattern . menuPicker . scroller . update ( { alwaysVisibleY : true } ) ;
} ) ;
this . fillControls . push ( this . cmbPattern ) ;
2020-05-13 14:20:58 +00:00
this . btnSelectImage = new Common . UI . Button ( {
parentEl : $ ( '#shape-button-replace' ) ,
cls : 'btn-text-menu-default' ,
caption : this . textSelectImage ,
style : "width:100%;" ,
menu : new Common . UI . Menu ( {
style : 'min-width: 194px;' ,
maxHeight : 200 ,
items : [
{ caption : this . textFromFile , value : 0 } ,
{ caption : this . textFromUrl , value : 1 } ,
{ caption : this . textFromStorage , value : 2 }
]
2021-06-16 13:43:51 +00:00
} ) ,
dataHint : '1' ,
dataHintDirection : 'bottom' ,
dataHintOffset : 'big'
2016-10-14 10:48:04 +00:00
} ) ;
2020-05-13 14:20:58 +00:00
this . fillControls . push ( this . btnSelectImage ) ;
this . btnSelectImage . menu . on ( 'item:click' , _ . bind ( this . onImageSelect , this ) ) ;
this . btnSelectImage . menu . items [ 2 ] . setVisible ( this . mode . canRequestInsertImage || this . mode . fileChoiceUrl && this . mode . fileChoiceUrl . indexOf ( "{documentType}" ) > - 1 ) ;
2016-10-14 10:48:04 +00:00
this . _arrFillType = [
{ displayValue : this . textStretch , value : Asc . c _oAscFillBlipType . STRETCH } ,
{ displayValue : this . textTile , value : Asc . c _oAscFillBlipType . TILE }
] ;
this . cmbFillType = new Common . UI . ComboBox ( {
el : $ ( '#shape-combo-fill-type' ) ,
cls : 'input-group-nr' ,
menuStyle : 'min-width: 90px;' ,
editable : false ,
2021-06-16 13:43:51 +00:00
data : this . _arrFillType ,
dataHint : '1' ,
dataHintDirection : 'bottom' ,
dataHintOffset : 'big'
2016-10-14 10:48:04 +00:00
} ) ;
this . cmbFillType . setValue ( this . _arrFillType [ 0 ] . value ) ;
this . cmbFillType . on ( 'selected' , _ . bind ( this . onFillTypeSelect , this ) ) ;
this . fillControls . push ( this . cmbFillType ) ;
2016-03-11 00:48:53 +00:00
2016-10-14 10:48:04 +00:00
this . numTransparency = new Common . UI . MetricSpinner ( {
el : $ ( '#shape-spin-transparency' ) ,
step : 1 ,
width : 62 ,
value : '100 %' ,
defaultUnit : "%" ,
maxValue : 100 ,
2021-06-16 13:43:51 +00:00
minValue : 0 ,
dataHint : '1' ,
dataHintDirection : 'bottom' ,
dataHintOffset : 'big'
2016-10-14 10:48:04 +00:00
} ) ;
this . numTransparency . on ( 'change' , _ . bind ( this . onNumTransparencyChange , this ) ) ;
2019-12-06 08:35:17 +00:00
this . numTransparency . on ( 'inputleave' , function ( ) { me . fireEvent ( 'editcomplete' , me ) ; } ) ;
2016-10-14 10:48:04 +00:00
this . fillControls . push ( this . numTransparency ) ;
2016-03-11 00:48:53 +00:00
2016-10-14 10:48:04 +00:00
this . sldrTransparency = new Common . UI . SingleSlider ( {
el : $ ( '#shape-slider-transparency' ) ,
width : 75 ,
minValue : 0 ,
maxValue : 100 ,
value : 100
} ) ;
this . sldrTransparency . on ( 'change' , _ . bind ( this . onTransparencyChange , this ) ) ;
this . sldrTransparency . on ( 'changecomplete' , _ . bind ( this . onTransparencyChangeComplete , this ) ) ;
this . fillControls . push ( this . sldrTransparency ) ;
2016-03-11 00:48:53 +00:00
2016-10-14 10:48:04 +00:00
this . lblTransparencyStart = $ ( this . el ) . find ( '#shape-lbl-transparency-start' ) ;
this . lblTransparencyEnd = $ ( this . el ) . find ( '#shape-lbl-transparency-end' ) ;
2016-03-11 00:48:53 +00:00
2016-10-14 10:48:04 +00:00
this . _arrGradType = [
{ displayValue : this . textLinear , value : Asc . c _oAscFillGradType . GRAD _LINEAR } ,
{ displayValue : this . textRadial , value : Asc . c _oAscFillGradType . GRAD _PATH }
] ;
2016-03-11 00:48:53 +00:00
2016-10-14 10:48:04 +00:00
this . cmbGradType = new Common . UI . ComboBox ( {
el : $ ( '#shape-combo-grad-type' ) ,
cls : 'input-group-nr' ,
menuStyle : 'min-width: 90px;' ,
editable : false ,
2021-06-16 13:43:51 +00:00
data : this . _arrGradType ,
dataHint : '1' ,
dataHintDirection : 'bottom' ,
dataHintOffset : 'big'
2016-10-14 10:48:04 +00:00
} ) ;
this . cmbGradType . setValue ( this . _arrGradType [ 0 ] . value ) ;
this . cmbGradType . on ( 'selected' , _ . bind ( this . onGradTypeSelect , this ) ) ;
this . fillControls . push ( this . cmbGradType ) ;
2016-03-11 00:48:53 +00:00
2016-10-14 10:48:04 +00:00
this . _viewDataLinear = [
2021-10-06 10:21:06 +00:00
{ type : 45 , subtype : - 1 } ,
{ type : 90 , subtype : 4 } ,
{ type : 135 , subtype : 5 } ,
{ type : 0 , subtype : 6 , cls : 'item-gradient-separator' , selected : true } ,
{ type : 180 , subtype : 1 } ,
{ type : 315 , subtype : 2 } ,
{ type : 270 , subtype : 3 } ,
{ type : 225 , subtype : 7 }
2016-10-14 10:48:04 +00:00
] ;
2016-03-11 00:48:53 +00:00
2016-10-14 10:48:04 +00:00
this . _viewDataRadial = [
2021-10-06 10:21:06 +00:00
{ type : 2 , subtype : 5 }
2016-10-14 10:48:04 +00:00
] ;
2016-03-11 00:48:53 +00:00
2016-10-14 10:48:04 +00:00
this . btnDirection = new Common . UI . Button ( {
cls : 'btn-large-dataview' ,
2021-09-30 02:16:32 +00:00
iconCls : 'item-gradient' ,
2016-10-14 10:48:04 +00:00
menu : new Common . UI . Menu ( {
style : 'min-width: 60px;' ,
menuAlign : 'tr-br' ,
items : [
{ template : _ . template ( '<div id="id-shape-menu-direction" style="width: 175px; margin: 0 5px;"></div>' ) }
]
2021-06-16 13:43:51 +00:00
} ) ,
dataHint : '1' ,
dataHintDirection : 'bottom' ,
dataHintOffset : 'big'
2016-10-14 10:48:04 +00:00
} ) ;
this . btnDirection . on ( 'render:after' , function ( btn ) {
me . mnuDirectionPicker = new Common . UI . DataView ( {
el : $ ( '#id-shape-menu-direction' ) ,
parentMenu : btn . menu ,
restoreHeight : 174 ,
store : new Common . UI . DataViewStore ( me . _viewDataLinear ) ,
2021-09-28 01:14:30 +00:00
itemTemplate : _ . template ( '<div id="<%= id %>" class="item-gradient" style="background: '
2021-10-01 22:20:52 +00:00
+ '<% if(type!=2) {%>linear-gradient(<%= type + 90 %>deg, ' + me . gradientColorsStr + ' )'
+ ' <%} else {%> radial-gradient( ' + me . gradientColorsStr + ' 70%) <%}%>;"></div>' )
2016-10-14 10:48:04 +00:00
} ) ;
} ) ;
this . btnDirection . render ( $ ( '#shape-button-direction' ) ) ;
this . mnuDirectionPicker . on ( 'item:click' , _ . bind ( this . onSelectGradient , this , this . btnDirection ) ) ;
this . fillControls . push ( this . btnDirection ) ;
2016-03-11 00:48:53 +00:00
2016-10-14 10:48:04 +00:00
this . sldrGradient = new Common . UI . MultiSliderGradient ( {
el : $ ( '#shape-slider-gradient' ) ,
2020-07-09 18:51:19 +00:00
width : 192 ,
2016-10-14 10:48:04 +00:00
minValue : 0 ,
maxValue : 100 ,
values : [ 0 , 100 ]
} ) ;
this . sldrGradient . on ( 'change' , _ . bind ( this . onGradientChange , this ) ) ;
this . sldrGradient . on ( 'changecomplete' , _ . bind ( this . onGradientChangeComplete , this ) ) ;
this . sldrGradient . on ( 'thumbclick' , function ( cmp , index ) {
me . GradColor . currentIdx = index ;
var color = me . GradColor . colors [ me . GradColor . currentIdx ] ;
me . btnGradColor . setColor ( color ) ;
me . colorsGrad . select ( color , false ) ;
2020-07-09 18:51:19 +00:00
var pos = me . GradColor . values [ me . GradColor . currentIdx ] ;
me . spnGradPosition . setValue ( pos , true ) ;
2016-10-14 10:48:04 +00:00
} ) ;
this . sldrGradient . on ( 'thumbdblclick' , function ( cmp ) {
me . btnGradColor . cmpEl . find ( 'button' ) . dropdown ( 'toggle' ) ;
} ) ;
2017-04-11 11:05:56 +00:00
this . sldrGradient . on ( 'sortthumbs' , function ( cmp , recalc _indexes ) {
var colors = [ ] ,
currentIdx ;
_ . each ( recalc _indexes , function ( recalc _index , index ) {
colors . push ( me . GradColor . colors [ recalc _index ] ) ;
if ( me . GradColor . currentIdx == recalc _index )
currentIdx = index ;
} ) ;
me . OriginalFillType = null ;
me . GradColor . colors = colors ;
me . GradColor . currentIdx = currentIdx ;
} ) ;
2020-07-13 19:14:51 +00:00
this . sldrGradient . on ( 'addthumb' , function ( cmp , index , pos ) {
me . GradColor . colors [ index ] = me . GradColor . colors [ me . GradColor . currentIdx ] ;
2019-11-15 12:10:03 +00:00
me . GradColor . currentIdx = index ;
2020-07-13 19:14:51 +00:00
var color = me . sldrGradient . addNewThumb ( index , pos ) ;
me . GradColor . colors [ me . GradColor . currentIdx ] = color ;
2019-11-14 06:43:04 +00:00
} ) ;
this . sldrGradient . on ( 'removethumb' , function ( cmp , index ) {
me . sldrGradient . removeThumb ( index ) ;
2019-11-15 08:42:13 +00:00
me . GradColor . values . splice ( index , 1 ) ;
2019-11-14 06:43:04 +00:00
me . sldrGradient . changeGradientStyle ( ) ;
2020-07-14 14:22:00 +00:00
if ( _ . isUndefined ( me . GradColor . currentIdx ) || me . GradColor . currentIdx >= me . GradColor . colors . length ) {
var newIndex = index > 0 ? index - 1 : index ;
newIndex = ( newIndex === 0 && me . GradColor . values . length > 2 ) ? me . GradColor . values . length - 2 : newIndex ;
me . GradColor . currentIdx = newIndex ;
}
me . sldrGradient . setActiveThumb ( me . GradColor . currentIdx ) ;
2019-11-14 06:43:04 +00:00
} ) ;
2016-10-14 10:48:04 +00:00
this . fillControls . push ( this . sldrGradient ) ;
2016-03-11 00:48:53 +00:00
2020-07-09 18:51:19 +00:00
this . spnGradPosition = new Common . UI . MetricSpinner ( {
el : $ ( '#shape-gradient-position' ) ,
step : 1 ,
width : 60 ,
defaultUnit : "%" ,
value : '50 %' ,
allowDecimal : false ,
maxValue : 100 ,
minValue : 0 ,
2021-06-16 13:43:51 +00:00
disabled : this . _locked ,
dataHint : '1' ,
dataHintDirection : 'bottom' ,
dataHintOffset : 'big'
2020-07-09 18:51:19 +00:00
} ) ;
2020-09-10 14:36:45 +00:00
this . fillControls . push ( this . spnGradPosition ) ;
2020-07-09 18:51:19 +00:00
this . spnGradPosition . on ( 'change' , _ . bind ( this . onPositionChange , this ) ) ;
2020-09-10 14:36:45 +00:00
this . spnGradPosition . on ( 'inputleave' , function ( ) { me . fireEvent ( 'editcomplete' , me ) ; } ) ;
2020-07-09 18:51:19 +00:00
this . btnAddGradientStep = new Common . UI . Button ( {
parentEl : $ ( '#shape-gradient-add-step' ) ,
cls : 'btn-toolbar' ,
iconCls : 'toolbar__icon btn-add-breakpoint' ,
disabled : this . _locked ,
2021-06-16 13:43:51 +00:00
hint : this . tipAddGradientPoint ,
dataHint : '1' ,
dataHintDirection : 'bottom'
2020-07-09 18:51:19 +00:00
} ) ;
this . btnAddGradientStep . on ( 'click' , _ . bind ( this . onAddGradientStep , this ) ) ;
2020-09-10 14:36:45 +00:00
this . fillControls . push ( this . btnAddGradientStep ) ;
2020-07-09 18:51:19 +00:00
this . btnRemoveGradientStep = new Common . UI . Button ( {
parentEl : $ ( '#shape-gradient-remove-step' ) ,
cls : 'btn-toolbar' ,
iconCls : 'toolbar__icon btn-remove-breakpoint' ,
disabled : this . _locked ,
2021-06-16 13:43:51 +00:00
hint : this . tipRemoveGradientPoint ,
dataHint : '1' ,
dataHintDirection : 'bottom'
2020-07-09 18:51:19 +00:00
} ) ;
this . btnRemoveGradientStep . on ( 'click' , _ . bind ( this . onRemoveGradientStep , this ) ) ;
2020-09-10 14:36:45 +00:00
this . fillControls . push ( this . btnRemoveGradientStep ) ;
this . numGradientAngle = new Common . UI . MetricSpinner ( {
el : $ ( '#shape-spin-gradient-angle' ) ,
2020-09-11 08:45:36 +00:00
step : 10 ,
2020-09-10 14:36:45 +00:00
width : 60 ,
defaultUnit : "°" ,
value : '0 °' ,
allowDecimal : true ,
maxValue : 359.9 ,
minValue : 0 ,
2021-06-16 13:43:51 +00:00
disabled : this . _locked ,
dataHint : '1' ,
dataHintDirection : 'bottom' ,
dataHintOffset : 'big'
2020-09-10 14:36:45 +00:00
} ) ;
this . fillControls . push ( this . numGradientAngle ) ;
this . numGradientAngle . on ( 'change' , _ . bind ( this . onGradientAngleChange , this ) ) ;
this . numGradientAngle . on ( 'inputleave' , function ( ) { me . fireEvent ( 'editcomplete' , me ) ; } ) ;
2020-07-09 18:51:19 +00:00
2016-10-14 10:48:04 +00:00
this . cmbBorderSize = new Common . UI . ComboBorderSizeEditable ( {
el : $ ( '#shape-combo-border-size' ) ,
style : "width: 93px;" ,
2021-06-16 13:43:51 +00:00
txtNoBorders : this . txtNoBorders ,
dataHint : '1' ,
dataHintDirection : 'bottom' ,
dataHintOffset : 'big'
2016-10-14 10:48:04 +00:00
} )
. on ( 'selected' , _ . bind ( this . onBorderSizeSelect , this ) )
. on ( 'changed:before' , _ . bind ( this . onBorderSizeChanged , this , true ) )
. on ( 'changed:after' , _ . bind ( this . onBorderSizeChanged , this , false ) )
. on ( 'combo:blur' , _ . bind ( this . onComboBlur , this , false ) ) ;
this . BorderSize = this . cmbBorderSize . store . at ( 2 ) . get ( 'value' ) ;
this . cmbBorderSize . setValue ( this . BorderSize ) ;
this . lockedControls . push ( this . cmbBorderSize ) ;
2016-03-11 00:48:53 +00:00
2016-10-14 10:48:04 +00:00
this . cmbBorderType = new Common . UI . ComboBorderType ( {
el : $ ( '#shape-combo-border-type' ) ,
style : "width: 93px;" ,
2021-06-16 13:43:51 +00:00
menuStyle : 'min-width: 93px;' ,
dataHint : '1' ,
dataHintDirection : 'bottom' ,
dataHintOffset : 'big'
2016-10-14 10:48:04 +00:00
} ) . on ( 'selected' , _ . bind ( this . onBorderTypeSelect , this ) )
. on ( 'combo:blur' , _ . bind ( this . onComboBlur , this , false ) ) ;
this . BorderType = Asc . c _oDashType . solid ;
this . cmbBorderType . setValue ( this . BorderType ) ;
this . lockedControls . push ( this . cmbBorderType ) ;
2016-03-11 00:48:53 +00:00
2016-10-14 10:48:04 +00:00
this . btnChangeShape = new Common . UI . Button ( {
2020-04-29 07:36:53 +00:00
parentEl : $ ( '#shape-btn-change' ) ,
2016-10-14 10:48:04 +00:00
cls : 'btn-icon-default' ,
iconCls : 'btn-change-shape' ,
menu : new Common . UI . Menu ( {
menuAlign : 'tr-br' ,
2021-09-16 13:53:48 +00:00
cls : 'menu-shapes menu-change-shape' ,
2016-10-14 10:48:04 +00:00
items : [ ]
2021-06-16 13:43:51 +00:00
} ) ,
dataHint : '1' ,
dataHintDirection : 'bottom' ,
dataHintOffset : 'big'
2016-10-14 10:48:04 +00:00
} ) ;
this . lockedControls . push ( this . btnChangeShape ) ;
2018-08-30 13:53:46 +00:00
this . btnRotate270 = new Common . UI . Button ( {
2020-04-29 07:36:53 +00:00
parentEl : $ ( '#shape-button-270' , me . $el ) ,
2018-08-30 13:53:46 +00:00
cls : 'btn-toolbar' ,
2019-11-21 16:10:02 +00:00
iconCls : 'toolbar__icon btn-rotate-270' ,
2018-08-30 13:53:46 +00:00
value : 0 ,
2021-06-16 13:43:51 +00:00
hint : this . textHint270 ,
dataHint : '1' ,
dataHintDirection : 'bottom'
2018-08-30 13:53:46 +00:00
} ) ;
this . btnRotate270 . on ( 'click' , _ . bind ( this . onBtnRotateClick , this ) ) ;
this . lockedControls . push ( this . btnRotate270 ) ;
this . btnRotate90 = new Common . UI . Button ( {
2020-04-29 07:36:53 +00:00
parentEl : $ ( '#shape-button-90' , me . $el ) ,
2018-08-30 13:53:46 +00:00
cls : 'btn-toolbar' ,
2019-11-21 16:10:02 +00:00
iconCls : 'toolbar__icon btn-rotate-90' ,
2018-08-30 13:53:46 +00:00
value : 1 ,
2021-06-16 13:43:51 +00:00
hint : this . textHint90 ,
dataHint : '1' ,
dataHintDirection : 'bottom'
2018-08-30 13:53:46 +00:00
} ) ;
this . btnRotate90 . on ( 'click' , _ . bind ( this . onBtnRotateClick , this ) ) ;
this . lockedControls . push ( this . btnRotate90 ) ;
this . btnFlipV = new Common . UI . Button ( {
2020-04-29 07:36:53 +00:00
parentEl : $ ( '#shape-button-flipv' , me . $el ) ,
2018-08-30 13:53:46 +00:00
cls : 'btn-toolbar' ,
2019-11-21 16:10:02 +00:00
iconCls : 'toolbar__icon btn-flip-vert' ,
2018-08-30 13:53:46 +00:00
value : 0 ,
2021-06-16 13:43:51 +00:00
hint : this . textHintFlipV ,
dataHint : '1' ,
dataHintDirection : 'bottom'
2018-08-30 13:53:46 +00:00
} ) ;
this . btnFlipV . on ( 'click' , _ . bind ( this . onBtnFlipClick , this ) ) ;
this . lockedControls . push ( this . btnFlipV ) ;
this . btnFlipH = new Common . UI . Button ( {
2020-04-29 07:36:53 +00:00
parentEl : $ ( '#shape-button-fliph' , me . $el ) ,
2018-08-30 13:53:46 +00:00
cls : 'btn-toolbar' ,
2019-11-21 16:10:02 +00:00
iconCls : 'toolbar__icon btn-flip-hor' ,
2018-08-30 13:53:46 +00:00
value : 1 ,
2021-06-16 13:43:51 +00:00
hint : this . textHintFlipH ,
dataHint : '1' ,
dataHintDirection : 'bottom'
2018-08-30 13:53:46 +00:00
} ) ;
this . btnFlipH . on ( 'click' , _ . bind ( this . onBtnFlipClick , this ) ) ;
this . lockedControls . push ( this . btnFlipH ) ;
2019-08-05 11:12:50 +00:00
this . chShadow = new Common . UI . CheckBox ( {
el : $ ( '#shape-checkbox-shadow' ) ,
2021-06-16 13:43:51 +00:00
labelText : this . strShadow ,
dataHint : '1' ,
dataHintDirection : 'left' ,
dataHintOffset : 'small'
2019-08-05 11:12:50 +00:00
} ) ;
this . chShadow . on ( 'change' , _ . bind ( this . onCheckShadow , this ) ) ;
this . lockedControls . push ( this . chShadow ) ;
2016-10-14 10:48:04 +00:00
this . linkAdvanced = $ ( '#shape-advanced-link' ) ;
$ ( this . el ) . on ( 'click' , '#shape-advanced-link' , _ . bind ( this . openAdvancedSettings , this ) ) ;
2016-03-11 00:48:53 +00:00
} ,
createDelayedElements : function ( ) {
2019-08-22 10:38:13 +00:00
this . _initSettings = false ;
2016-10-14 10:48:04 +00:00
this . createDelayedControls ( ) ;
2016-03-11 00:48:53 +00:00
var global _hatch _menu _map = [
0 , 1 , 3 , 2 , 4 ,
53 , 5 , 6 , 7 , 8 ,
9 , 10 , 11 , 12 , 13 ,
14 , 15 , 16 , 17 , 18 ,
19 , 20 , 22 , 23 , 24 ,
25 , 27 , 28 , 29 , 30 ,
31 , 32 , 33 , 34 , 35 ,
36 , 37 , 38 , 39 , 40 ,
41 , 42 , 43 , 44 , 45 ,
46 , 49 , 50 , 51 , 52
] ;
this . patternViewData = [ ] ;
for ( var i = 0 ; i < 13 ; i ++ ) {
for ( var j = 0 ; j < 4 ; j ++ ) {
var num = i * 4 + j ;
this . patternViewData [ num ] = { offsetx : j * 28 , offsety : i * 28 , type : global _hatch _menu _map [ num ] } ;
}
}
this . patternViewData . splice ( this . patternViewData . length - 2 , 2 ) ;
for ( var i = 0 ; i < this . patternViewData . length ; i ++ ) {
this . patternViewData [ i ] . id = Common . UI . getId ( ) ;
}
this . cmbPattern . menuPicker . store . add ( this . patternViewData ) ;
if ( this . cmbPattern . menuPicker . store . length > 0 ) {
this . cmbPattern . fillComboView ( this . cmbPattern . menuPicker . store . at ( 0 ) , true ) ;
this . PatternFillType = this . patternViewData [ 0 ] . type ;
}
2019-08-30 12:04:02 +00:00
this . onInitStandartTextures ( ) ;
2019-08-20 11:05:13 +00:00
this . onApiAutoShapes ( ) ;
2016-03-11 00:48:53 +00:00
this . UpdateThemeColors ( ) ;
} ,
onInitStandartTextures : function ( texture ) {
var me = this ;
if ( texture && texture . length > 0 ) {
2019-08-30 12:04:02 +00:00
me . _texturearray = [ ] ;
2016-03-11 00:48:53 +00:00
_ . each ( texture , function ( item ) {
2019-08-30 12:04:02 +00:00
me . _texturearray . push ( {
2016-03-11 00:48:53 +00:00
imageUrl : item . get _image ( ) ,
name : me . textureNames [ item . get _id ( ) ] ,
type : item . get _id ( ) ,
// allowSelected : false,
selected : false
} ) ;
} ) ;
2019-08-30 12:04:02 +00:00
}
if ( ! me . _texturearray || me . _texturearray . length < 1 ) return ;
if ( ! this . _initSettings && ! this . btnTexture ) {
this . btnTexture = new Common . UI . ComboBox ( {
el : $ ( '#shape-combo-fill-texture' ) ,
template : _ . template ( [
'<div class="input-group combobox combo-dataview-menu input-group-nr dropdown-toggle" tabindex="0" data-toggle="dropdown">' ,
2021-06-16 13:43:51 +00:00
'<div class="form-control text" style="width: 90px;" data-hint="1" data-hint-direction="bottom" data-hint-offset="big">' + this . textSelectTexture + '</div>' ,
2019-08-30 12:04:02 +00:00
'<div style="display: table-cell;"></div>' ,
2021-01-18 20:27:47 +00:00
'<button type="button" class="btn btn-default">' ,
'<span class="caret"></span>' ,
'</button>' ,
2019-08-30 12:04:02 +00:00
'</div>'
] . join ( '' ) )
2016-03-11 00:48:53 +00:00
} ) ;
2019-08-30 12:04:02 +00:00
this . textureMenu = new Common . UI . Menu ( {
items : [
{ template : _ . template ( '<div id="id-shape-menu-texture" style="width: 233px; margin: 0 5px;"></div>' ) }
]
} ) ;
this . textureMenu . render ( $ ( '#shape-combo-fill-texture' ) ) ;
this . fillControls . push ( this . btnTexture ) ;
var onShowBefore = function ( menu ) {
var mnuTexturePicker = new Common . UI . DataView ( {
el : $ ( '#id-shape-menu-texture' ) ,
restoreHeight : 174 ,
parentMenu : menu ,
showLast : false ,
store : new Common . UI . DataViewStore ( me . _texturearray || [ ] ) ,
itemTemplate : _ . template ( '<div class="item-texture"><img src="<%= imageUrl %>" id="<%= id %>"></div>' )
} ) ;
mnuTexturePicker . on ( 'item:click' , _ . bind ( me . onSelectTexture , me ) ) ;
menu . off ( 'show:before' , onShowBefore ) ;
} ;
this . textureMenu . on ( 'show:before' , onShowBefore ) ;
2016-03-11 00:48:53 +00:00
}
} ,
onSelectTexture : function ( picker , view , record ) {
this . _fromTextureCmb = true ;
this . cmbFillType . setValue ( this . _arrFillType [ 1 ] . value ) ;
this . _fromTextureCmb = false ;
if ( this . api ) {
2016-04-18 12:21:15 +00:00
var props = new Asc . asc _CShapeProperty ( ) ;
var fill = new Asc . asc _CShapeFill ( ) ;
2016-04-05 11:52:34 +00:00
fill . put _type ( Asc . c _oAscFill . FILL _TYPE _BLIP ) ;
2016-04-18 12:21:15 +00:00
fill . put _fill ( new Asc . asc _CFillBlip ( ) ) ;
2016-04-05 11:52:34 +00:00
fill . get _fill ( ) . put _type ( Asc . c _oAscFillBlipType . TILE ) ;
2016-03-11 00:48:53 +00:00
fill . get _fill ( ) . put _texture _id ( record . get ( 'type' ) ) ;
props . put _fill ( fill ) ;
this . api . ShapeApply ( props ) ;
}
$ ( this . btnTexture . el ) . find ( '.form-control' ) . prop ( 'innerHTML' , record . get ( 'name' ) ) ;
this . fireEvent ( 'editcomplete' , this ) ;
} ,
2019-08-05 11:12:50 +00:00
onCheckShadow : function ( field , newValue , oldValue , eOpts ) {
if ( this . api ) {
var props = new Asc . asc _CShapeProperty ( ) ;
2019-08-05 15:15:29 +00:00
props . asc _putShadow ( ( field . getValue ( ) == 'checked' ) ? new Asc . asc _CShadowProperty ( ) : null ) ;
2019-08-05 11:12:50 +00:00
this . api . ShapeApply ( props ) ;
}
this . fireEvent ( 'editcomplete' , this ) ;
} ,
2019-08-20 11:05:13 +00:00
onApiAutoShapes : function ( ) {
var me = this ;
var onShowBefore = function ( menu ) {
me . fillAutoShapes ( ) ;
menu . off ( 'show:before' , onShowBefore ) ;
} ;
me . btnChangeShape . menu . on ( 'show:before' , onShowBefore ) ;
} ,
2016-03-11 00:48:53 +00:00
fillAutoShapes : function ( ) {
var me = this ,
2021-09-16 13:53:48 +00:00
recents = Common . localStorage . getItem ( 'pe-recent-shapes' ) ;
for ( var i = 0 ; i < 2 ; i ++ ) {
var menuitem = new Common . UI . MenuItem ( {
template : _ . template ( '<div id="id-change-shape-menu-<%= options.index %>" class="menu-insertshape"></div>' ) ,
index : i
} ) ;
me . btnChangeShape . menu . addItem ( menuitem ) ;
var shapePicker = new Common . UI . DataViewShape ( {
el : $ ( '#id-change-shape-menu-' + i ) ,
itemTemplate : _ . template ( '<div class="item-shape" id="<%= id %>"><svg width="20" height="20" class=\"icon\"><use xlink:href=\"#svg-icon-<%= data.shapeType %>\"></use></svg></div>' ) ,
2021-10-04 12:56:34 +00:00
groups : me . application . getCollection ( 'ShapeGroups' ) ,
2021-09-16 13:53:48 +00:00
parentMenu : me . btnChangeShape . menu ,
2021-09-16 17:47:48 +00:00
restoreHeight : 640 ,
2021-09-16 13:53:48 +00:00
textRecentlyUsed : me . textRecentlyUsed ,
recentShapes : recents ? JSON . parse ( recents ) : null ,
isFromImage : i === 0
} ) ;
shapePicker . on ( 'item:click' , function ( picker , item , record , e ) {
if ( me . api ) {
2021-10-10 22:44:40 +00:00
PE . getController ( 'Toolbar' ) . toolbar . cmbInsertShape . updateComboView ( record ) ;
2021-09-16 13:53:48 +00:00
me . api . ChangeShapeType ( record . get ( 'data' ) . shapeType ) ;
me . fireEvent ( 'editcomplete' , me ) ;
2019-08-20 08:05:52 +00:00
}
2021-09-16 13:53:48 +00:00
if ( e . type !== 'click' )
me . btnChangeShape . menu . hide ( ) ;
2016-03-11 00:48:53 +00:00
} ) ;
}
2021-09-16 13:53:48 +00:00
2019-08-20 11:05:13 +00:00
me . btnChangeShape . menu . items [ 0 ] . setVisible ( me . _state . isFromImage ) ;
me . btnChangeShape . menu . items [ 1 ] . setVisible ( ! me . _state . isFromImage ) ;
2016-03-11 00:48:53 +00:00
} ,
UpdateThemeColors : function ( ) {
2019-08-22 10:38:13 +00:00
if ( this . _initSettings ) return ;
2016-10-14 10:48:04 +00:00
if ( ! this . btnBackColor ) {
this . btnBackColor = new Common . UI . ColorButton ( {
2020-04-29 17:32:18 +00:00
parentEl : $ ( '#shape-back-color-btn' ) ,
2020-04-30 12:11:03 +00:00
transparent : true ,
2021-06-16 13:43:51 +00:00
color : 'transparent' ,
dataHint : '1' ,
dataHintDirection : 'bottom' ,
dataHintOffset : 'big'
2016-10-14 10:48:04 +00:00
} ) ;
this . fillControls . push ( this . btnBackColor ) ;
2020-04-29 17:32:18 +00:00
this . colorsBack = this . btnBackColor . getPicker ( ) ;
this . btnBackColor . on ( 'color:select' , _ . bind ( this . onColorsBackSelect , this ) ) ;
2016-10-14 10:48:04 +00:00
this . btnFGColor = new Common . UI . ColorButton ( {
2020-04-30 12:11:03 +00:00
parentEl : $ ( '#shape-foreground-color-btn' ) ,
2021-06-16 13:43:51 +00:00
color : '000000' ,
dataHint : '1' ,
dataHintDirection : 'bottom' ,
dataHintOffset : 'big'
2016-10-14 10:48:04 +00:00
} ) ;
this . fillControls . push ( this . btnFGColor ) ;
2020-04-29 17:32:18 +00:00
this . colorsFG = this . btnFGColor . getPicker ( ) ;
this . btnFGColor . on ( 'color:select' , _ . bind ( this . onColorsFGSelect , this ) ) ;
2016-10-14 10:48:04 +00:00
this . btnBGColor = new Common . UI . ColorButton ( {
2020-04-30 12:11:03 +00:00
parentEl : $ ( '#shape-background-color-btn' ) ,
2021-06-16 13:43:51 +00:00
color : 'ffffff' ,
dataHint : '1' ,
dataHintDirection : 'bottom' ,
dataHintOffset : 'big'
2016-10-14 10:48:04 +00:00
} ) ;
this . fillControls . push ( this . btnBGColor ) ;
2020-04-29 17:32:18 +00:00
this . colorsBG = this . btnBGColor . getPicker ( ) ;
this . btnBGColor . on ( 'color:select' , _ . bind ( this . onColorsBGSelect , this ) ) ;
2016-10-14 10:48:04 +00:00
this . btnGradColor = new Common . UI . ColorButton ( {
2020-04-30 12:11:03 +00:00
parentEl : $ ( '#shape-gradient-color-btn' ) ,
2021-06-16 13:43:51 +00:00
color : '000000' ,
dataHint : '1' ,
dataHintDirection : 'bottom' ,
dataHintOffset : 'big'
2016-10-14 10:48:04 +00:00
} ) ;
this . fillControls . push ( this . btnGradColor ) ;
2020-04-29 17:32:18 +00:00
this . colorsGrad = this . btnGradColor . getPicker ( ) ;
this . btnGradColor . on ( 'color:select' , _ . bind ( this . onColorsGradientSelect , this ) ) ;
2016-10-14 10:48:04 +00:00
this . btnBorderColor = new Common . UI . ColorButton ( {
2020-04-30 12:11:03 +00:00
parentEl : $ ( '#shape-border-color-btn' ) ,
2021-06-16 13:43:51 +00:00
color : '000000' ,
dataHint : '1' ,
dataHintDirection : 'bottom' ,
dataHintOffset : 'big'
2016-10-14 10:48:04 +00:00
} ) ;
this . lockedControls . push ( this . btnBorderColor ) ;
2020-04-29 17:32:18 +00:00
this . colorsBorder = this . btnBorderColor . getPicker ( ) ;
this . btnBorderColor . on ( 'color:select' , _ . bind ( this . onColorsBorderSelect , this ) ) ;
2016-10-14 10:48:04 +00:00
}
2016-03-11 00:48:53 +00:00
this . colorsBorder . updateColors ( Common . Utils . ThemeColor . getEffectColors ( ) , Common . Utils . ThemeColor . getStandartColors ( ) ) ;
this . colorsBack . updateColors ( Common . Utils . ThemeColor . getEffectColors ( ) , Common . Utils . ThemeColor . getStandartColors ( ) ) ;
this . colorsFG . updateColors ( Common . Utils . ThemeColor . getEffectColors ( ) , Common . Utils . ThemeColor . getStandartColors ( ) ) ;
this . colorsBG . updateColors ( Common . Utils . ThemeColor . getEffectColors ( ) , Common . Utils . ThemeColor . getStandartColors ( ) ) ;
this . colorsGrad . updateColors ( Common . Utils . ThemeColor . getEffectColors ( ) , Common . Utils . ThemeColor . getStandartColors ( ) ) ;
} ,
2018-08-30 13:53:46 +00:00
onBtnRotateClick : function ( btn ) {
var properties = new Asc . asc _CShapeProperty ( ) ;
2019-01-14 14:42:58 +00:00
properties . asc _putRotAdd ( ( btn . options . value == 1 ? 90 : 270 ) * 3.14159265358979 / 180 ) ;
2018-08-30 13:53:46 +00:00
this . api . ShapeApply ( properties ) ;
this . fireEvent ( 'editcomplete' , this ) ;
} ,
onBtnFlipClick : function ( btn ) {
var properties = new Asc . asc _CShapeProperty ( ) ;
if ( btn . options . value == 1 )
2019-01-14 14:42:58 +00:00
properties . asc _putFlipHInvert ( true ) ;
2018-08-30 13:53:46 +00:00
else
2019-01-14 14:42:58 +00:00
properties . asc _putFlipVInvert ( true ) ;
2018-08-30 13:53:46 +00:00
this . api . ShapeApply ( properties ) ;
this . fireEvent ( 'editcomplete' , this ) ;
} ,
2016-03-11 00:48:53 +00:00
_pt2mm : function ( value ) {
return ( value * 25.4 / 72.0 ) ;
} ,
_mm2pt : function ( value ) {
return ( value * 72.0 / 25.4 ) ;
} ,
disableFillPanels : function ( disable ) {
if ( this . _state . DisabledFillPanels !== disable ) {
this . _state . DisabledFillPanels = disable ;
_ . each ( this . fillControls , function ( item ) {
item . setDisabled ( disable ) ;
} ) ;
this . lblTransparencyStart . toggleClass ( 'disabled' , disable ) ;
this . lblTransparencyEnd . toggleClass ( 'disabled' , disable ) ;
2020-09-10 14:36:45 +00:00
this . numGradientAngle . setDisabled ( disable || this . GradFillType !== Asc . c _oAscFillGradType . GRAD _LINEAR ) ;
2016-03-11 00:48:53 +00:00
}
} ,
ShowHideElem : function ( value ) {
2016-04-05 11:52:34 +00:00
this . FillColorContainer . toggleClass ( 'settings-hidden' , value !== Asc . c _oAscFill . FILL _TYPE _SOLID ) ;
this . FillImageContainer . toggleClass ( 'settings-hidden' , value !== Asc . c _oAscFill . FILL _TYPE _BLIP ) ;
this . FillPatternContainer . toggleClass ( 'settings-hidden' , value !== Asc . c _oAscFill . FILL _TYPE _PATT ) ;
this . FillGradientContainer . toggleClass ( 'settings-hidden' , value !== Asc . c _oAscFill . FILL _TYPE _GRAD ) ;
this . TransparencyContainer . toggleClass ( 'settings-hidden' , ( value === Asc . c _oAscFill . FILL _TYPE _NOFILL || value === null ) ) ;
2016-03-11 00:48:53 +00:00
} ,
setLocked : function ( locked ) {
this . _locked = locked ;
} ,
disableControls : function ( disable , disableFill ) {
2016-10-14 10:48:04 +00:00
if ( this . _initSettings ) return ;
2016-03-11 00:48:53 +00:00
this . disableFillPanels ( disable || disableFill ) ;
if ( this . _state . DisabledControls !== disable ) {
this . _state . DisabledControls = disable ;
_ . each ( this . lockedControls , function ( item ) {
item . setDisabled ( disable ) ;
} ) ;
this . linkAdvanced . toggleClass ( 'disabled' , disable ) ;
}
} ,
hideShapeOnlySettings : function ( value ) {
if ( this . _state . HideShapeOnlySettings !== value ) {
this . _state . HideShapeOnlySettings = value ;
this . ShapeOnlySettings . toggleClass ( 'hidden' , value == true ) ;
}
} ,
hideChangeTypeSettings : function ( value ) {
if ( this . _state . HideChangeTypeSettings !== value ) {
this . _state . HideChangeTypeSettings = value ;
this . CanChangeType . toggleClass ( 'hidden' , value == true ) ;
}
} ,
2020-07-09 18:51:19 +00:00
onPositionChange : function ( btn ) {
2020-07-10 15:21:45 +00:00
var pos = btn . getNumberValue ( ) ,
minValue = ( this . GradColor . currentIdx - 1 < 0 ) ? 0 : this . GradColor . values [ this . GradColor . currentIdx - 1 ] ,
maxValue = ( this . GradColor . currentIdx + 1 < this . GradColor . values . length ) ? this . GradColor . values [ this . GradColor . currentIdx + 1 ] : 100 ,
needSort = pos < minValue || pos > maxValue ;
2020-07-09 18:51:19 +00:00
if ( this . api ) {
this . GradColor . values [ this . GradColor . currentIdx ] = pos ;
var props = new Asc . asc _CShapeProperty ( ) ;
var fill = new Asc . asc _CShapeFill ( ) ;
fill . put _type ( Asc . c _oAscFill . FILL _TYPE _GRAD ) ;
fill . put _fill ( new Asc . asc _CFillGrad ( ) ) ;
fill . get _fill ( ) . put _grad _type ( this . GradFillType ) ;
var arr = [ ] ;
this . GradColor . values . forEach ( function ( item ) {
arr . push ( item * 1000 ) ;
} ) ;
fill . get _fill ( ) . put _positions ( arr ) ;
props . put _fill ( fill ) ;
this . api . ShapeApply ( props ) ;
2020-07-10 15:21:45 +00:00
if ( needSort ) {
this . sldrGradient . sortThumbs ( ) ;
this . sldrGradient . trigger ( 'change' , this . sldrGradient ) ;
this . sldrGradient . trigger ( 'changecomplete' , this . sldrGradient ) ;
}
2020-07-09 18:51:19 +00:00
}
} ,
onAddGradientStep : function ( ) {
if ( this . GradColor . colors . length > 9 ) return ;
var curIndex = this . GradColor . currentIdx ;
var pos = ( this . GradColor . values [ curIndex ] + this . GradColor . values [ curIndex < this . GradColor . colors . length - 1 ? curIndex + 1 : curIndex - 1 ] ) / 2 ;
this . GradColor . colors [ this . GradColor . colors . length ] = this . GradColor . colors [ curIndex ] ;
this . GradColor . currentIdx = this . GradColor . colors . length - 1 ;
2020-07-13 19:14:51 +00:00
var color = this . sldrGradient . addNewThumb ( undefined , pos , curIndex ) ;
this . GradColor . colors [ this . GradColor . currentIdx ] = color ;
2020-07-09 18:51:19 +00:00
this . sldrGradient . trigger ( 'change' , this . sldrGradient ) ;
this . sldrGradient . trigger ( 'changecomplete' , this . sldrGradient ) ;
} ,
onRemoveGradientStep : function ( ) {
if ( this . GradColor . values . length < 3 ) return ;
2020-07-14 14:22:00 +00:00
var index = this . GradColor . currentIdx ;
2020-07-09 18:51:19 +00:00
this . GradColor . values . splice ( this . GradColor . currentIdx , 1 ) ;
this . sldrGradient . removeThumb ( this . GradColor . currentIdx ) ;
if ( _ . isUndefined ( this . GradColor . currentIdx ) || this . GradColor . currentIdx >= this . GradColor . colors . length ) {
2020-07-14 14:22:00 +00:00
var newIndex = index > 0 ? index - 1 : index ;
newIndex = ( newIndex === 0 && this . GradColor . values . length > 2 ) ? this . GradColor . values . length - 2 : newIndex ;
this . GradColor . currentIdx = newIndex ;
2020-07-09 18:51:19 +00:00
}
this . sldrGradient . setActiveThumb ( this . GradColor . currentIdx ) ;
this . sldrGradient . trigger ( 'change' , this . sldrGradient ) ;
this . sldrGradient . trigger ( 'changecomplete' , this . sldrGradient ) ;
} ,
2020-09-10 14:36:45 +00:00
onGradientAngleChange : function ( field , newValue , oldValue , eOpts ) {
2020-10-16 14:35:56 +00:00
if ( this . api && ! this . _noApply ) {
2020-09-10 14:36:45 +00:00
var props = new Asc . asc _CShapeProperty ( ) ;
var fill = new Asc . asc _CShapeFill ( ) ;
fill . put _type ( Asc . c _oAscFill . FILL _TYPE _GRAD ) ;
fill . put _fill ( new Asc . asc _CFillGrad ( ) ) ;
fill . get _fill ( ) . put _grad _type ( this . GradFillType ) ;
fill . get _fill ( ) . put _linear _angle ( field . getNumberValue ( ) * 60000 ) ;
fill . get _fill ( ) . put _linear _scale ( true ) ;
props . put _fill ( fill ) ;
this . api . ShapeApply ( props ) ;
}
} ,
2016-03-11 00:48:53 +00:00
txtNoBorders : 'No Line' ,
strStroke : 'Stroke' ,
strColor : 'Color' ,
strSize : 'Size' ,
strChange : 'Change Autoshape' ,
strFill : 'Fill' ,
textColor : 'Color Fill' ,
textImageTexture : 'Picture or Texture' ,
textTexture : 'From Texture' ,
textFromUrl : 'From URL' ,
textFromFile : 'From File' ,
textStretch : 'Stretch' ,
textTile : 'Tile' ,
txtCanvas : 'Canvas' ,
txtCarton : 'Carton' ,
txtDarkFabric : 'Dark Fabric' ,
txtGrain : 'Grain' ,
txtGranite : 'Granite' ,
txtGreyPaper : 'Grey Paper' ,
txtKnit : 'Knit' ,
txtLeather : 'Leather' ,
txtBrownPaper : 'Brown Paper' ,
txtPapyrus : 'Papyrus' ,
txtWood : 'Wood' ,
textAdvanced : 'Show advanced settings' ,
strTransparency : 'Opacity' ,
textNoFill : 'No Fill' ,
textSelectTexture : 'Select' ,
textGradientFill : 'Gradient Fill' ,
textPatternFill : 'Pattern' ,
strBackground : 'Background color' ,
strForeground : 'Foreground color' ,
strPattern : 'Pattern' ,
textEmptyPattern : 'No Pattern' ,
textLinear : 'Linear' ,
textRadial : 'Radial' ,
textDirection : 'Direction' ,
textStyle : 'Style' ,
2020-09-10 14:36:45 +00:00
textGradient : 'Gradient Points' ,
2016-07-01 08:16:09 +00:00
textBorderSizeErr : 'The entered value is incorrect.<br>Please enter a value between 0 pt and 1584 pt.' ,
2018-08-30 13:53:46 +00:00
strType : 'Type' ,
textRotation : 'Rotation' ,
textRotate90 : 'Rotate 90°' ,
textFlip : 'Flip' ,
2019-04-01 13:10:35 +00:00
textHint270 : 'Rotate 90° Counterclockwise' ,
textHint90 : 'Rotate 90° Clockwise' ,
2019-02-26 16:36:02 +00:00
textHintFlipV : 'Flip Vertically' ,
2019-08-05 11:12:50 +00:00
textHintFlipH : 'Flip Horizontally' ,
2020-05-13 14:20:58 +00:00
strShadow : 'Show shadow' ,
textFromStorage : 'From Storage' ,
2020-07-09 18:51:19 +00:00
textSelectImage : 'Select Picture' ,
textPosition : 'Position' ,
tipAddGradientPoint : 'Add gradient point' ,
2020-09-10 14:36:45 +00:00
tipRemoveGradientPoint : 'Remove gradient point' ,
2021-09-16 13:53:48 +00:00
textAngle : 'Angle' ,
textRecentlyUsed : 'Recently Used'
2016-03-11 00:48:53 +00:00
} , PE . Views . ShapeSettings || { } ) ) ;
} ) ;