2020-04-16 15:43:16 +00:00
/ *
*
* ( c ) Copyright Ascensio System SIA 2010 - 2020
*
* This program is a free software product . You can redistribute it and / or
* modify it under the terms of the GNU Affero General Public License ( AGPL )
* version 3 as published by the Free Software Foundation . In accordance with
* Section 7 ( a ) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non - infringement
* of any third - party rights .
*
* This program is distributed WITHOUT ANY WARRANTY ; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . For
* details , see the GNU AGPL at : http : //www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20 A - 12 Ernesta Birznieka - Upisha
* street , Riga , Latvia , EU , LV - 1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices , as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7 ( b ) of the License you must retain the original Product
* logo when distributing the program . Pursuant to Section 7 ( e ) we decline to
* grant you any rights under trademark law for use of our trademarks .
*
* All the Product ' s GUI elements , including illustrations and icon sets , as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution - ShareAlike 4.0 International . See the License
* terms at http : //creativecommons.org/licenses/by-sa/4.0/legalcode
*
* /
/ * *
*
* FormatRulesEditDlg . js
*
* Created by Julia . Radzhabova on 15.04 . 20
* Copyright ( c ) 2020 Ascensio System SIA . All rights reserved .
*
* /
2021-03-11 17:52:32 +00:00
define ( [ 'text!spreadsheeteditor/main/app/template/FormatRulesEditDlg.template' ,
2020-04-16 15:43:16 +00:00
'common/main/lib/view/AdvancedSettingsWindow' ,
'common/main/lib/component/ComboBox' ,
'common/main/lib/component/InputField'
2021-03-11 17:52:32 +00:00
] , function ( contentTemplate ) {
2020-04-16 15:43:16 +00:00
'use strict' ;
SSE . Views = SSE . Views || { } ;
SSE . Views . FormatRulesEditDlg = Common . Views . AdvancedSettingsWindow . extend ( _ . extend ( {
options : {
alias : 'FormatRulesEditDlg' ,
2020-04-27 19:17:43 +00:00
contentWidth : 490 ,
height : 445
2020-04-16 15:43:16 +00:00
} ,
initialize : function ( options ) {
var me = this ;
_ . extend ( this . options , {
title : this . txtTitleNew ,
template : [
'<div class="box" style="height:' + ( me . options . height - 85 ) + 'px;">' ,
2021-03-11 17:52:32 +00:00
'<div class="content-panel" style="padding: 0;">' + _ . template ( contentTemplate ) ( { scope : this } ) + '</div>' ,
2020-04-16 15:43:16 +00:00
'</div>' ,
'<div class="separator horizontal"></div>'
] . join ( '' )
} , options ) ;
this . api = options . api ;
this . handler = options . handler ;
this . isEdit = options . isEdit || false ;
this . props = options . props ;
2020-04-17 11:16:09 +00:00
this . type = options . type ; // rule category
this . subtype = options . subtype ; // rule
2021-03-15 15:31:39 +00:00
this . percent = options . percent ; //
this . langId = options . langId ; //
2020-04-16 15:43:16 +00:00
Common . Views . AdvancedSettingsWindow . prototype . initialize . call ( this , this . options ) ;
} ,
render : function ( ) {
Common . Views . AdvancedSettingsWindow . prototype . render . call ( this ) ;
var me = this ;
2021-03-12 14:00:15 +00:00
this . dataValTypes = [
{ value : Asc . c _oAscCfvoType . Number , displayValue : this . txtNumber } ,
{ value : Asc . c _oAscCfvoType . Percent , displayValue : this . textPercent } ,
{ value : Asc . c _oAscCfvoType . Formula , displayValue : this . textFormula } ,
{ value : Asc . c _oAscCfvoType . Percentile , displayValue : this . textPercentile }
] ;
2020-04-16 15:43:16 +00:00
var rules = [
{
2021-03-15 14:44:09 +00:00
name : Common . define . conditionalData . textValue ,
2020-04-16 15:43:16 +00:00
type : Asc . c _oAscCFType . cellIs ,
rules : [
2021-01-28 18:38:00 +00:00
{ name : Common . define . conditionalData . textGreater , subtype : Asc . c _oAscCFOperator . greaterThan } ,
{ name : Common . define . conditionalData . textGreaterEq , subtype : Asc . c _oAscCFOperator . greaterThanOrEqual } ,
{ name : Common . define . conditionalData . textLess , subtype : Asc . c _oAscCFOperator . lessThan } ,
{ name : Common . define . conditionalData . textLessEq , subtype : Asc . c _oAscCFOperator . lessThanOrEqual } ,
{ name : Common . define . conditionalData . textEqual , subtype : Asc . c _oAscCFOperator . equal } ,
{ name : Common . define . conditionalData . textNotEqual , subtype : Asc . c _oAscCFOperator . notEqual } ,
{ name : Common . define . conditionalData . textBetween , subtype : Asc . c _oAscCFOperator . between } ,
{ name : Common . define . conditionalData . textNotBetween , subtype : Asc . c _oAscCFOperator . notBetween }
2020-04-16 15:43:16 +00:00
]
} ,
{
2021-03-15 14:44:09 +00:00
name : Common . define . conditionalData . textTop + '/' + Common . define . conditionalData . textBottom ,
2020-04-16 15:43:16 +00:00
type : Asc . c _oAscCFType . top10 ,
rules : [
2021-01-28 18:38:00 +00:00
{ name : Common . define . conditionalData . textTop , subtype : 0 } ,
{ name : Common . define . conditionalData . textBottom , subtype : 1 }
2020-04-16 15:43:16 +00:00
]
} ,
{
2021-01-28 18:38:00 +00:00
name : Common . define . conditionalData . textAverage ,
2020-04-16 15:43:16 +00:00
type : Asc . c _oAscCFType . aboveAverage ,
rules : [
2021-01-28 18:38:00 +00:00
{ name : Common . define . conditionalData . textAbove , subtype : 0 } ,
{ name : Common . define . conditionalData . textBelow , subtype : 1 } ,
{ name : Common . define . conditionalData . textEqAbove , subtype : 2 } ,
{ name : Common . define . conditionalData . textEqBelow , subtype : 3 } ,
{ name : Common . define . conditionalData . text1Above , subtype : 4 } ,
{ name : Common . define . conditionalData . text1Below , subtype : 5 } ,
{ name : Common . define . conditionalData . text2Above , subtype : 6 } ,
{ name : Common . define . conditionalData . text2Below , subtype : 7 } ,
{ name : Common . define . conditionalData . text3Above , subtype : 8 } ,
{ name : Common . define . conditionalData . text3Below , subtype : 9 }
2020-04-16 15:43:16 +00:00
]
} ,
{
2021-01-28 18:38:00 +00:00
name : Common . define . conditionalData . textText ,
2020-04-16 15:43:16 +00:00
type : Asc . c _oAscCFType . containsText ,
rules : [
2021-01-28 18:38:00 +00:00
{ name : Common . define . conditionalData . textContains , type : Asc . c _oAscCFType . containsText } ,
{ name : Common . define . conditionalData . textNotContains , type : Asc . c _oAscCFType . notContainsText } ,
{ name : Common . define . conditionalData . textBegins , type : Asc . c _oAscCFType . beginsWith } ,
{ name : Common . define . conditionalData . textEnds , type : Asc . c _oAscCFType . endsWith }
2020-04-16 15:43:16 +00:00
]
} ,
{
2021-01-28 18:38:00 +00:00
name : Common . define . conditionalData . textDate ,
2020-04-16 15:43:16 +00:00
type : Asc . c _oAscCFType . timePeriod ,
rules : [
2021-01-28 18:38:00 +00:00
{ name : Common . define . conditionalData . textYesterday , subtype : Asc . c _oAscTimePeriod . yesterday } ,
{ name : Common . define . conditionalData . textToday , subtype : Asc . c _oAscTimePeriod . today } ,
{ name : Common . define . conditionalData . textTomorrow , subtype : Asc . c _oAscTimePeriod . tomorrow } ,
{ name : Common . define . conditionalData . textLast7days , subtype : Asc . c _oAscTimePeriod . last7Days } ,
{ name : Common . define . conditionalData . textLastWeek , subtype : Asc . c _oAscTimePeriod . lastWeek } ,
{ name : Common . define . conditionalData . textThisWeek , subtype : Asc . c _oAscTimePeriod . thisWeek } ,
{ name : Common . define . conditionalData . textNextWeek , subtype : Asc . c _oAscTimePeriod . nextWeek } ,
{ name : Common . define . conditionalData . textLastMonth , subtype : Asc . c _oAscTimePeriod . lastMonth } ,
{ name : Common . define . conditionalData . textThisMonth , subtype : Asc . c _oAscTimePeriod . thisMonth } ,
{ name : Common . define . conditionalData . textNextMonth , subtype : Asc . c _oAscTimePeriod . nextMonth }
2020-04-16 15:43:16 +00:00
]
} ,
{
2021-01-28 18:38:00 +00:00
name : Common . define . conditionalData . textBlank + '/' + Common . define . conditionalData . textError ,
2020-04-16 15:43:16 +00:00
type : Asc . c _oAscCFType . containsBlanks ,
rules : [
2021-01-28 18:38:00 +00:00
{ name : Common . define . conditionalData . textBlanks , type : Asc . c _oAscCFType . containsBlanks } ,
{ name : Common . define . conditionalData . textNotBlanks , type : Asc . c _oAscCFType . notContainsBlanks } ,
{ name : Common . define . conditionalData . textErrors , type : Asc . c _oAscCFType . containsErrors } ,
{ name : Common . define . conditionalData . textNotErrors , type : Asc . c _oAscCFType . notContainsErrors }
2020-04-16 15:43:16 +00:00
]
} ,
{
2021-01-28 18:38:00 +00:00
name : Common . define . conditionalData . textDuplicate + '/' + Common . define . conditionalData . textUnique ,
2020-04-16 15:43:16 +00:00
type : Asc . c _oAscCFType . duplicateValues ,
rules : [
2021-01-28 18:38:00 +00:00
{ name : Common . define . conditionalData . textDuplicate , type : Asc . c _oAscCFType . duplicateValues } ,
{ name : Common . define . conditionalData . textUnique , type : Asc . c _oAscCFType . uniqueValues }
2020-04-16 15:43:16 +00:00
]
} ,
{
2021-01-28 18:38:00 +00:00
name : this . text2Scales ,
2020-04-16 15:43:16 +00:00
type : Asc . c _oAscCFType . colorScale ,
num : 2
} ,
{
2021-01-28 18:38:00 +00:00
name : this . text3Scales ,
2020-04-16 15:43:16 +00:00
type : Asc . c _oAscCFType . colorScale ,
num : 3
} ,
{
2021-01-28 18:38:00 +00:00
name : Common . define . conditionalData . textDataBar ,
2020-04-16 15:43:16 +00:00
type : Asc . c _oAscCFType . dataBar
} ,
{
2021-01-28 18:38:00 +00:00
name : Common . define . conditionalData . textIconSets ,
2020-04-16 15:43:16 +00:00
type : Asc . c _oAscCFType . iconSet
} ,
{
2021-01-28 18:38:00 +00:00
name : Common . define . conditionalData . textFormula ,
2020-04-16 15:43:16 +00:00
type : Asc . c _oAscCFType . expression
}
] ;
var arrrules = [ ] ,
cmbData = [ ] ;
_ . each ( rules , function ( rule , index ) {
var arr = [ ] ;
rule . rules && _ . each ( rule . rules , function ( item , idx ) {
arr . push ( {
name : item . name ,
2020-04-17 11:16:09 +00:00
type : item . type ,
subtype : item . subtype ,
2020-04-16 15:43:16 +00:00
allowSelected : true ,
selected : false
} ) ;
} ) ;
var store = new Backbone . Collection ( arr ) ;
arrrules . push ( {
name : rule . name ,
type : rule . type ,
rules : store ,
num : rule . num ,
index : index
} ) ;
cmbData . push ( { value : index , displayValue : rule . name } ) ;
} ) ;
this . ruleStore = new Backbone . Collection ( arrrules ) ;
this . cmbCategory = new Common . UI . ComboBox ( {
el : $ ( '#format-rules-edit-combo-category' ) ,
style : 'width: 150px;' ,
menuStyle : 'min-width: 100%;max-height: 211px;' ,
editable : false ,
cls : 'input-group-nr' ,
2021-03-19 09:14:25 +00:00
data : cmbData ,
2021-07-12 15:12:39 +00:00
takeFocusOnClose : true ,
scrollAlwaysVisible : false
2020-04-16 15:43:16 +00:00
} ) . on ( 'selected' , function ( combo , record ) {
me . refreshRules ( record . value ) ;
} ) ;
2021-03-19 09:14:25 +00:00
Common . UI . FocusManager . add ( this , this . cmbCategory ) ;
2020-04-16 15:43:16 +00:00
this . cmbRule = new Common . UI . ComboBox ( {
el : $ ( '#format-rules-edit-combo-rule' ) ,
style : 'width: 150px;' ,
menuStyle : 'min-width: 100%;max-height: 211px;' ,
editable : false ,
cls : 'input-group-nr' ,
2021-03-19 09:14:25 +00:00
data : [ ] ,
takeFocusOnClose : true
2020-04-20 10:49:38 +00:00
} ) . on ( 'selected' , function ( combo , record ) {
me . setControls ( me . cmbCategory . getValue ( ) , record . value ) ;
2020-04-16 15:43:16 +00:00
} ) ;
2021-03-19 09:14:25 +00:00
Common . UI . FocusManager . add ( this , this . cmbRule ) ;
2020-04-16 15:43:16 +00:00
this . txtRange1 = new Common . UI . InputFieldBtn ( {
el : $ ( '#format-rules-edit-txt-r1' ) ,
name : 'range' ,
style : 'width: 150px;' ,
allowBlank : true ,
btnHint : this . textSelectData ,
validateOnChange : false
} ) ;
this . txtRange1 . on ( 'button:click' , _ . bind ( this . onSelectData , this ) ) ;
2021-03-19 09:14:25 +00:00
Common . UI . FocusManager . add ( this , this . txtRange1 ) ;
2020-04-16 15:43:16 +00:00
this . txtRange2 = new Common . UI . InputFieldBtn ( {
el : $ ( '#format-rules-edit-txt-r2' ) ,
name : 'range' ,
style : 'width: 150px;' ,
allowBlank : true ,
btnHint : this . textSelectData ,
validateOnChange : false
} ) ;
this . txtRange2 . on ( 'button:click' , _ . bind ( this . onSelectData , this ) ) ;
2021-03-19 09:14:25 +00:00
Common . UI . FocusManager . add ( this , this . txtRange2 ) ;
2020-04-16 15:43:16 +00:00
2020-04-20 12:40:16 +00:00
// top 10
this . cmbPercent = new Common . UI . ComboBox ( {
el : $ ( '#format-rules-edit-combo-percent' ) ,
style : 'width: 100px;' ,
menuStyle : 'min-width: 100%;max-height: 211px;' ,
editable : false ,
cls : 'input-group-nr' ,
data : [
2021-03-11 16:19:58 +00:00
{ value : 0 , displayValue : this . textItem } ,
{ value : 1 , displayValue : this . textPercent }
2021-03-19 09:14:25 +00:00
] ,
takeFocusOnClose : true
2020-04-20 12:40:16 +00:00
} ) . on ( 'selected' , function ( combo , record ) {
var percent = ! ! record . value ;
2021-03-11 11:54:57 +00:00
// me.numRank.setMaxValue(percent ? 100 : 1000);
2020-04-20 12:40:16 +00:00
me . numRank . setValue ( me . numRank . getNumberValue ( ) ) ;
} ) ;
this . cmbPercent . setValue ( 0 ) ;
2021-03-19 09:14:25 +00:00
Common . UI . FocusManager . add ( this , this . cmbPercent ) ;
2020-04-20 12:40:16 +00:00
this . numRank = new Common . UI . MetricSpinner ( {
el : $ ( '#format-rules-edit-spin-rank' ) ,
step : 1 ,
width : 100 ,
defaultUnit : "" ,
defaultValue : 10 ,
allowDecimal : false ,
value : '10' ,
2021-03-11 11:54:57 +00:00
maxValue : 1000000000000 ,
minValue : - 1000000000000
2020-04-20 12:40:16 +00:00
} ) ;
this . numRank . on ( 'change' , _ . bind ( function ( field , newValue , oldValue , eOpts ) {
} , this ) ) ;
2021-03-19 09:14:25 +00:00
Common . UI . FocusManager . add ( this , this . numRank ) ;
2020-04-20 12:40:16 +00:00
2020-04-16 15:43:16 +00:00
// Format
2021-03-12 14:00:15 +00:00
this . CFPresets = this . api . asc _getCFPresets ( ) ;
var formatPresets = this . CFPresets [ Asc . c _oAscCFRuleTypeSettings . format ] ;
2021-03-11 11:54:07 +00:00
var color _data = [ ] ;
2021-03-15 18:58:40 +00:00
var presetTemplate = _ . template ( [ '<a id="<%= id %>" tabindex="-1" type="menuitem" style="padding: 3px 10px;">' ,
'<div style="height: 22px;padding: 4px 0;<%= options.styleStr %>"><%= caption %></div>' ,
'</a>' ] . join ( '' ) ) ;
2021-03-11 11:54:07 +00:00
_ . each ( formatPresets , function ( preset , index ) {
color _data . push ( {
value : index ,
2021-03-15 18:58:40 +00:00
presetSettings : {
fontColor : preset [ 0 ] ,
fillColor : preset [ 1 ] ,
borderColor : preset [ 2 ] ,
2021-10-08 14:09:28 +00:00
styleObj : { 'background-color' : preset [ 1 ] ? '#' + preset [ 1 ] : '#ffffff' , color : preset [ 0 ] ? '#' + preset [ 0 ] : 'transparent' , border : preset [ 2 ] ? '1px solid #' + preset [ 2 ] : '' , 'text-align' : 'center' }
2021-03-15 18:58:40 +00:00
} ,
caption : preset [ 0 ] ? Common . define . conditionalData . exampleText : '' ,
template : presetTemplate ,
2021-10-08 14:09:28 +00:00
styleStr : 'background-color: ' + ( preset [ 1 ] ? '#' + preset [ 1 ] : '#ffffff' ) + ';color:' + ( preset [ 0 ] ? '#' + preset [ 0 ] : 'transparent' ) + ';' + ( preset [ 2 ] ? 'border: 1px solid #' + preset [ 2 ] + ';' : '' + 'text-align: center;' )
2021-03-11 11:54:07 +00:00
} ) ;
} ) ;
2021-03-15 18:58:40 +00:00
this . btnFormats = new Common . UI . Button ( {
parentEl : $ ( '#format-rules-format-preset' ) ,
cls : 'btn-text-menu-default' ,
caption : this . textPresets ,
style : 'width: 150px;' ,
menu : new Common . UI . Menu ( {
style : 'min-width: 150px;' ,
maxHeight : 211 ,
additionalAlign : this . menuAddAlign ,
items : color _data
} )
2020-04-16 15:43:16 +00:00
} ) ;
2021-03-15 18:58:40 +00:00
this . btnFormats . menu . on ( 'item:click' , _ . bind ( this . onFormatsSelect , this ) ) ;
2020-04-16 15:43:16 +00:00
this . btnBold = new Common . UI . Button ( {
2020-04-30 13:58:45 +00:00
parentEl : $ ( '#format-rules-bold' ) ,
2020-04-16 15:43:16 +00:00
cls : 'btn-toolbar' ,
iconCls : 'toolbar__icon btn-bold' ,
enableToggle : true ,
hint : this . textBold
} ) ;
2021-01-26 15:50:59 +00:00
this . btnBold . on ( 'click' , _ . bind ( this . onBoldClick , this ) ) ;
2020-04-16 15:43:16 +00:00
this . btnItalic = new Common . UI . Button ( {
2020-04-30 13:58:45 +00:00
parentEl : $ ( '#format-rules-italic' ) ,
2020-04-16 15:43:16 +00:00
cls : 'btn-toolbar' ,
iconCls : 'toolbar__icon btn-italic' ,
enableToggle : true ,
hint : this . textItalic
} ) ;
2021-01-26 15:50:59 +00:00
this . btnItalic . on ( 'click' , _ . bind ( this . onItalicClick , this ) ) ;
2020-04-16 15:43:16 +00:00
this . btnUnderline = new Common . UI . Button ( {
2020-04-30 13:58:45 +00:00
parentEl : $ ( '#format-rules-underline' ) ,
2020-04-16 15:43:16 +00:00
cls : 'btn-toolbar' ,
iconCls : 'toolbar__icon btn-underline' ,
enableToggle : true ,
hint : this . textUnderline
} ) ;
2021-01-26 15:50:59 +00:00
this . btnUnderline . on ( 'click' , _ . bind ( this . onUnderlineClick , this ) ) ;
2020-04-16 15:43:16 +00:00
this . btnStrikeout = new Common . UI . Button ( {
2020-04-30 13:58:45 +00:00
parentEl : $ ( '#format-rules-strikeout' ) ,
2020-04-16 15:43:16 +00:00
cls : 'btn-toolbar' ,
iconCls : 'toolbar__icon btn-strikeout' ,
enableToggle : true ,
hint : this . textStrikeout
} ) ;
2021-01-26 15:50:59 +00:00
this . btnStrikeout . on ( 'click' , _ . bind ( this . onStrikeoutClick , this ) ) ;
2020-04-16 15:43:16 +00:00
2021-07-11 09:03:01 +00:00
var initNewColor = function ( btn ) {
btn . setMenu ( ) ;
btn . currentColor = '000000' ;
var picker = btn . getPicker ( ) ;
picker . currentColor = btn . currentColor ;
2020-04-16 15:43:16 +00:00
return picker ;
} ;
2021-02-24 15:49:05 +00:00
this . btnTextColor = new Common . UI . ButtonColored ( {
2020-04-30 13:58:45 +00:00
parentEl : $ ( '#format-rules-fontcolor' ) ,
2020-04-16 15:43:16 +00:00
cls : 'btn-toolbar' ,
iconCls : 'toolbar__icon btn-fontcolor' ,
hint : this . textColor ,
2021-07-11 09:03:01 +00:00
additionalAlign : this . menuAddAlign ,
color : '000000' ,
menu : true
2020-04-16 15:43:16 +00:00
} ) ;
2021-07-11 09:03:01 +00:00
this . mnuTextColorPicker = initNewColor ( this . btnTextColor ) ;
this . btnTextColor . on ( 'color:select' , _ . bind ( this . onFormatTextColorSelect , this ) ) ;
2020-04-16 15:43:16 +00:00
2021-02-24 15:49:05 +00:00
this . btnFillColor = new Common . UI . ButtonColored ( {
2020-04-30 13:58:45 +00:00
parentEl : $ ( '#format-rules-fillcolor' ) ,
2020-04-16 15:43:16 +00:00
cls : 'btn-toolbar' ,
iconCls : 'toolbar__icon btn-paracolor' ,
hint : this . fillColor ,
2021-07-11 09:03:01 +00:00
additionalAlign : this . menuAddAlign ,
color : '000000' ,
transparent : true ,
menu : true
2020-04-16 15:43:16 +00:00
} ) ;
2021-07-11 09:03:01 +00:00
this . mnuFillColorPicker = initNewColor ( this . btnFillColor ) ;
this . btnFillColor . on ( 'color:select' , _ . bind ( this . onFormatFillColorSelect , this ) ) ;
2020-04-16 15:43:16 +00:00
2020-05-19 16:57:24 +00:00
this . btnBorders = new Common . UI . Button ( {
parentEl : $ ( '#format-rules-borders' ) ,
cls : 'btn-toolbar' ,
iconCls : 'toolbar__icon btn-border-out' ,
hint : this . tipBorders ,
icls : 'btn-border-out' ,
borderId : 'outer' ,
borderswidth : Asc . c _oAscBorderStyles . Thin ,
split : true ,
menu : new Common . UI . Menu ( {
items : [
{
caption : this . textOutBorders ,
iconCls : 'menu__icon btn-border-out' ,
icls : 'btn-border-out' ,
borderId : 'outer'
} ,
{
caption : this . textAllBorders ,
iconCls : 'menu__icon btn-border-all' ,
icls : 'btn-border-all' ,
borderId : 'all'
} ,
{
caption : this . textTopBorders ,
iconCls : 'menu__icon btn-border-top' ,
icls : 'btn-border-top' ,
borderId : Asc . c _oAscBorderOptions . Top
} ,
{
caption : this . textBottomBorders ,
iconCls : 'menu__icon btn-border-bottom' ,
icls : 'btn-border-bottom' ,
borderId : Asc . c _oAscBorderOptions . Bottom
} ,
{
caption : this . textLeftBorders ,
iconCls : 'menu__icon btn-border-left' ,
icls : 'btn-border-left' ,
borderId : Asc . c _oAscBorderOptions . Left
} ,
{
caption : this . textRightBorders ,
iconCls : 'menu__icon btn-border-right' ,
icls : 'btn-border-right' ,
borderId : Asc . c _oAscBorderOptions . Right
} ,
{
caption : this . textNoBorders ,
iconCls : 'menu__icon btn-border-no' ,
icls : 'btn-border-no' ,
borderId : 'none'
} ,
{ caption : '--' } ,
{
caption : this . textInsideBorders ,
iconCls : 'menu__icon btn-border-inside' ,
icls : 'btn-border-center' ,
borderId : 'inner'
} ,
{
caption : this . textCenterBorders ,
iconCls : 'menu__icon btn-border-insidevert' ,
icls : 'btn-border-vmiddle' ,
borderId : Asc . c _oAscBorderOptions . InnerV
} ,
{
caption : this . textMiddleBorders ,
iconCls : 'menu__icon btn-border-insidehor' ,
icls : 'btn-border-hmiddle' ,
borderId : Asc . c _oAscBorderOptions . InnerH
} ,
{
caption : this . textDiagUpBorder ,
iconCls : 'menu__icon btn-border-diagup' ,
icls : 'btn-border-diagup' ,
borderId : Asc . c _oAscBorderOptions . DiagU
} ,
{
caption : this . textDiagDownBorder ,
iconCls : 'menu__icon btn-border-diagdown' ,
icls : 'btn-border-diagdown' ,
borderId : Asc . c _oAscBorderOptions . DiagD
} ,
{ caption : '--' } ,
{
id : 'format-rules-borders-border-width' ,
caption : this . textBordersStyle ,
iconCls : 'menu__icon btn-border-style' ,
menu : ( function ( ) {
var itemTemplate = _ . template ( '<a id="<%= id %>" tabindex="-1" type="menuitem"><div class="border-size-item" style="background-position: 0 -<%= options.offsety %>px;"></div></a>' ) ;
me . mnuBorderWidth = new Common . UI . Menu ( {
style : 'min-width: 100px;' ,
menuAlign : 'tl-tr' ,
items : [
{ template : itemTemplate , stopPropagation : true , checkable : true , toggleGroup : 'border-width' , value : Asc . c _oAscBorderStyles . Thin , offsety : 0 , checked : true } ,
{ template : itemTemplate , stopPropagation : true , checkable : true , toggleGroup : 'border-width' , value : Asc . c _oAscBorderStyles . Hair , offsety : 20 } ,
{ template : itemTemplate , stopPropagation : true , checkable : true , toggleGroup : 'border-width' , value : Asc . c _oAscBorderStyles . Dotted , offsety : 40 } ,
{ template : itemTemplate , stopPropagation : true , checkable : true , toggleGroup : 'border-width' , value : Asc . c _oAscBorderStyles . Dashed , offsety : 60 } ,
{ template : itemTemplate , stopPropagation : true , checkable : true , toggleGroup : 'border-width' , value : Asc . c _oAscBorderStyles . DashDot , offsety : 80 } ,
{ template : itemTemplate , stopPropagation : true , checkable : true , toggleGroup : 'border-width' , value : Asc . c _oAscBorderStyles . DashDotDot , offsety : 100 } ,
{ template : itemTemplate , stopPropagation : true , checkable : true , toggleGroup : 'border-width' , value : Asc . c _oAscBorderStyles . Medium , offsety : 120 } ,
{ template : itemTemplate , stopPropagation : true , checkable : true , toggleGroup : 'border-width' , value : Asc . c _oAscBorderStyles . MediumDashed , offsety : 140 } ,
{ template : itemTemplate , stopPropagation : true , checkable : true , toggleGroup : 'border-width' , value : Asc . c _oAscBorderStyles . MediumDashDot , offsety : 160 } ,
{ template : itemTemplate , stopPropagation : true , checkable : true , toggleGroup : 'border-width' , value : Asc . c _oAscBorderStyles . MediumDashDotDot , offsety : 180 } ,
{ template : itemTemplate , stopPropagation : true , checkable : true , toggleGroup : 'border-width' , value : Asc . c _oAscBorderStyles . Thick , offsety : 200 }
]
} ) ;
return me . mnuBorderWidth ;
} ) ( )
} ,
this . mnuBorderColor = new Common . UI . MenuItem ( {
id : 'format-rules-borders-border-color' ,
caption : this . textBordersColor ,
iconCls : 'mnu-icon-item mnu-border-color' ,
2021-01-26 08:38:05 +00:00
template : _ . template ( '<a id="<%= id %>" tabindex="-1" type="menuitem"><span class="menu-item-icon" style="background-image: none; width: 12px; height: 12px; margin: 2px 9px 0 -11px; border-style: solid; border-width: 3px; border-color: #000;"></span><%= caption %></a>' ) ,
2020-05-19 16:57:24 +00:00
menu : new Common . UI . Menu ( {
menuAlign : 'tl-tr' ,
items : [
{ template : _ . template ( '<div id="format-rules-borders-menu-bordercolor" style="width: 169px; height: 220px; margin: 10px;"></div>' ) , stopPropagation : true } ,
{ template : _ . template ( '<a id="format-rules-borders-menu-new-bordercolor" style="padding-left:12px;">' + this . textNewColor + '</a>' ) , stopPropagation : true }
]
} )
} )
]
} )
} ) ;
2021-01-26 15:50:59 +00:00
this . btnBorders . menu . on ( 'item:click' , _ . bind ( this . onBordersMenu , this ) ) ;
this . btnBorders . on ( 'click' , _ . bind ( this . onBorders , this ) ) ;
2020-05-19 16:57:24 +00:00
this . mnuBorderColorPicker = new Common . UI . ThemeColorPalette ( {
el : $ ( '#format-rules-borders-menu-bordercolor' )
} ) ;
this . mnuBorderColorPicker . on ( 'select' , _ . bind ( this . onBordersColor , this ) ) ;
$ ( '#format-rules-borders-menu-new-bordercolor' ) . on ( 'click' , _ . bind ( function ( ) {
me . mnuBorderColorPicker . addNewColor ( ) ;
} , this ) ) ;
this . mnuBorderWidth . on ( 'item:toggle' , _ . bind ( this . onBordersWidth , this ) ) ;
this . ascFormatOptions = {
General : 'General' ,
Number : '0.00' ,
Currency : '$#,##0.00' ,
Accounting : '_($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_)' ,
DateShort : 'm/d/yyyy' ,
DateLong : '[$-F800]dddd, mmmm dd, yyyy' ,
Time : '[$-F400]h:mm:ss AM/PM' ,
Percentage : '0.00%' ,
Percent : '0%' ,
Fraction : '# ?/?' ,
Scientific : '0.00E+00' ,
Text : '@'
} ;
this . numFormatData = [
{ value : Asc . c _oAscNumFormatType . General , format : this . ascFormatOptions . General , displayValue : this . txtGeneral , exampleval : '100' } ,
{ value : Asc . c _oAscNumFormatType . Number , format : this . ascFormatOptions . Number , displayValue : this . txtNumber , exampleval : '100,00' } ,
{ value : Asc . c _oAscNumFormatType . Scientific , format : this . ascFormatOptions . Scientific , displayValue : this . txtScientific , exampleval : '1,00E+02' } ,
{ value : Asc . c _oAscNumFormatType . Accounting , format : this . ascFormatOptions . Accounting , displayValue : this . txtAccounting , exampleval : '100,00 $' } ,
{ value : Asc . c _oAscNumFormatType . Currency , format : this . ascFormatOptions . Currency , displayValue : this . txtCurrency , exampleval : '100,00 $' } ,
{ value : Asc . c _oAscNumFormatType . Date , format : 'MM-dd-yyyy' , displayValue : this . txtDate , exampleval : '04-09-1900' } ,
{ value : Asc . c _oAscNumFormatType . Time , format : 'HH:MM:ss' , displayValue : this . txtTime , exampleval : '00:00:00' } ,
{ value : Asc . c _oAscNumFormatType . Percent , format : this . ascFormatOptions . Percentage , displayValue : this . txtPercentage , exampleval : '100,00%' } ,
{ value : Asc . c _oAscNumFormatType . Fraction , format : this . ascFormatOptions . Fraction , displayValue : this . txtFraction , exampleval : '100' } ,
{ value : Asc . c _oAscNumFormatType . Text , format : this . ascFormatOptions . Text , displayValue : this . txtText , exampleval : '100' }
] ;
if ( this . api ) {
2021-03-12 14:00:15 +00:00
var info = new Asc . asc _CFormatCellsInfo ( ) ;
2020-05-19 16:57:24 +00:00
info . asc _setType ( Asc . c _oAscNumFormatType . None ) ;
info . asc _setSymbol ( this . langId ) ;
var arr = this . api . asc _getFormatCells ( info ) ; // all formats
this . numFormatData . forEach ( function ( item , index ) {
item . format = arr [ index ] ;
item . exampleval = me . api . asc _getLocaleExample ( item . format , 100 ) ;
} ) ;
}
var formatTemplate =
_ . template ( [
'<% _.each(items, function(item) { %>' ,
'<li id="<%= item.id %>" data-value="<%= item.value %>"><a tabindex="-1" type="menuitem">' ,
'<div style="position: relative;"><div style="position: absolute; left: 0; width: 100px;"><%= scope.getDisplayValue(item) %></div>' ,
'<div style="display: inline-block; width: 100%; max-width: 300px; overflow: hidden; text-overflow: ellipsis; text-align: right; vertical-align: bottom; padding-left: 100px; color: silver;white-space: nowrap;"><%= item.exampleval ? item.exampleval : "" %></div>' ,
'</div></a></li>' ,
'<% }); %>'
// ,'<li class="divider">',
// '<li id="id-toolbar-mnu-item-more-formats" data-value="-1"><a tabindex="-1" type="menuitem">' + me.textMoreFormats + '</a></li>'
] . join ( '' ) ) ;
this . cmbNumberFormat = new Common . UI . ComboBox ( {
el : $ ( '#format-rules-edit-combo-num-format' ) ,
cls : 'input-group-nr' ,
2021-03-11 17:52:32 +00:00
style : 'width: 113px;' ,
2020-05-19 16:57:24 +00:00
menuStyle : 'min-width: 100%;max-height: 211px;' ,
hint : this . tipNumFormat ,
itemsTemplate : formatTemplate ,
editable : false ,
2021-03-19 09:14:25 +00:00
data : this . numFormatData ,
takeFocusOnClose : true
2020-05-19 16:57:24 +00:00
} ) ;
this . cmbNumberFormat . setValue ( Asc . c _oAscNumFormatType . General ) ;
2021-01-26 15:50:59 +00:00
this . cmbNumberFormat . on ( 'selected' , _ . bind ( this . onNumberFormatSelect , this ) ) ;
2021-03-19 09:14:25 +00:00
Common . UI . FocusManager . add ( this , this . cmbNumberFormat ) ;
2020-05-19 16:57:24 +00:00
2021-03-11 16:19:58 +00:00
this . btnClear = new Common . UI . Button ( {
el : $ ( '#format-rules-edit-btn-clear' )
} ) ;
this . btnClear . on ( 'click' , _ . bind ( this . clearFormat , this ) ) ;
2021-03-12 14:00:15 +00:00
this . panels = {
format : { el : this . $window . find ( '.hasformat' ) , rendered : false , initColors : false } ,
scale : { el : this . $window . find ( '.scale' ) , rendered : false , initColors : false } ,
databar : { el : this . $window . find ( '.databar' ) , rendered : false , initColors : false } ,
iconset : { el : this . $window . find ( '.iconset' ) , rendered : false , initColors : false }
} ;
2020-04-24 11:19:22 +00:00
2021-03-12 14:00:15 +00:00
this . panels . format . rendered = true ;
this . afterRender ( ) ;
} ,
2020-04-24 11:19:22 +00:00
2021-03-12 14:00:15 +00:00
addNewIconsLine : function ( ) {
var me = this ;
var i = this . iconsControls . length ;
this . iconsControls . push ( { } ) ;
var combo = new Common . UI . ComboBox ( {
el : $ ( '#format-rules-combo-icon-' + ( i + 1 ) ) ,
type : i ,
template : _ . template ( [
'<div class="input-group combobox combo-dataview-menu input-group-nr dropdown-toggle" data-toggle="dropdown">' ,
2021-07-13 19:30:34 +00:00
'<div class="form-control image" style="display: block;width: 85px;">' ,
'<div style="display: inline-block;overflow: hidden;width: 100%;height: 100%;padding-top: 2px;background-repeat: no-repeat; background-position: 27px center;white-space:nowrap;"></div>' ,
2021-07-13 19:08:32 +00:00
'</div>' ,
2021-03-12 14:00:15 +00:00
'<div style="display: table-cell;"></div>' ,
'<button type="button" class="btn btn-default"><span class="caret"></span></button>' ,
'</div>'
] . join ( '' ) )
} ) ;
2021-03-19 09:14:25 +00:00
2021-03-12 14:00:15 +00:00
var menu = ( new Common . UI . Menu ( {
style : 'min-width: 105px;' ,
additionalAlign : this . menuAddAlign ,
items : [
2021-07-13 19:08:32 +00:00
{ caption : this . txtNoCellIcon , checkable : true , allowDepress : false , toggleGroup : 'no-cell-icons-' + ( i + 1 ) } ,
2021-03-12 14:00:15 +00:00
{ template : _ . template ( '<div id="format-rules-combo-menu-icon-' + ( i + 1 ) + '" style="width: 217px; margin: 0 5px;"></div>' ) }
]
} ) ) . render ( $ ( '#format-rules-combo-icon-' + ( i + 1 ) ) ) ;
var picker = new Common . UI . DataView ( {
el : $ ( '#format-rules-combo-menu-icon-' + ( i + 1 ) ) ,
parentMenu : menu ,
2021-09-20 14:38:41 +00:00
outerMenu : { menu : menu , index : 1 } ,
2021-03-12 14:00:15 +00:00
store : new Common . UI . DataViewStore ( me . iconsList ) ,
itemTemplate : _ . template ( '<img id="<%= id %>" class="item-icon" src="<%= imgUrl %>" style="width: 16px; height: 16px;">' ) ,
type : i
} ) ;
2021-07-13 19:08:32 +00:00
picker . on ( 'item:click' , _ . bind ( this . onSelectIcon , this , combo , menu . items [ 0 ] ) ) ;
2021-09-20 14:38:41 +00:00
menu . setInnerMenu ( [ { menu : picker , index : 1 } ] ) ;
2021-07-13 19:08:32 +00:00
menu . items [ 0 ] . on ( 'toggle' , _ . bind ( this . onSelectNoIcon , this , combo , picker ) ) ;
2021-03-12 14:00:15 +00:00
this . iconsControls [ i ] . cmbIcons = combo ;
this . iconsControls [ i ] . pickerIcons = picker ;
2021-07-13 19:08:32 +00:00
this . iconsControls [ i ] . itemNoIcons = menu . items [ 0 ] ;
2021-03-12 14:00:15 +00:00
combo = new Common . UI . ComboBox ( {
el : $ ( '#format-rules-edit-combo-op-' + ( i + 1 ) ) ,
style : 'width: 55px;' ,
menuStyle : 'min-width: 100%;' ,
editable : false ,
cls : 'input-group-nr' ,
data : [ { value : true , displayValue : '>=' , prevOp : '<' } , { value : false , displayValue : '>' , prevOp : '<=' } ] ,
2021-03-19 09:14:25 +00:00
type : i ,
takeFocusOnClose : true
2021-03-12 14:00:15 +00:00
} ) . on ( 'selected' , function ( combo , record ) {
me . fillIconsLabels ( ) ;
} ) ;
combo . setValue ( 1 ) ;
this . iconsControls [ i ] . cmbOperator = combo ;
2021-03-19 09:14:25 +00:00
Common . UI . FocusManager . add ( this , combo ) ;
2021-03-12 14:00:15 +00:00
var range = new Common . UI . InputFieldBtn ( {
el : $ ( '#format-rules-edit-txt-value-' + ( i + 1 ) ) ,
name : 'range' ,
style : 'width: 100px;' ,
allowBlank : true ,
btnHint : this . textSelectData ,
validateOnChange : false ,
type : i
} ) . on ( 'changed:after' , function ( input , newValue , oldValue , e ) {
me . fillIconsLabels ( ) ;
} ) ;
range . setValue ( '' ) ;
this . iconsControls [ i ] . value = range ;
range . on ( 'button:click' , _ . bind ( this . onSelectData , this ) ) ;
2021-03-19 09:14:25 +00:00
Common . UI . FocusManager . add ( this , range ) ;
combo = new Common . UI . ComboBox ( {
el : $ ( '#format-rules-edit-combo-type-' + ( i + 1 ) ) ,
style : 'width: 80px;' ,
menuStyle : 'min-width: 100%;max-height: 211px;' ,
editable : false ,
cls : 'input-group-nr' ,
data : this . dataValTypes ,
type : i ,
takeFocusOnClose : true
} ) . on ( 'selected' , function ( combo , record ) {
} ) ;
combo . setValue ( Asc . c _oAscCfvoType . Percent ) ;
this . iconsControls [ i ] . cmbType = combo ;
Common . UI . FocusManager . add ( this , combo ) ;
2021-03-12 14:00:15 +00:00
this . iconsControls [ i ] . label = $ ( '#format-rules-txt-icon-' + ( i + 1 ) ) ;
} ,
renderIconsPanel : function ( ) {
if ( this . panels . iconset . rendered ) return ;
// Icons
var me = this ;
this . collectionPresets = SSE . getCollection ( 'ConditionalFormatIconsPresets' ) ;
if ( this . collectionPresets . length < 1 )
SSE . getController ( 'Main' ) . fillCondFormatIconsPresets ( this . api . asc _getCFIconsByType ( ) ) ;
this . collectionIcons = SSE . getCollection ( 'ConditionalFormatIcons' ) ;
if ( this . collectionIcons . length < 1 )
SSE . getController ( 'Main' ) . fillCondFormatIcons ( this . api . asc _getFullCFIcons ( ) ) ;
this . iconsList = [ ] ;
me . collectionIcons . each ( function ( icon , index ) {
me . iconsList . push ( {
value : icon . get ( 'index' ) ,
imgUrl : icon . get ( 'icon' )
2020-04-24 11:19:22 +00:00
} ) ;
2021-03-12 14:00:15 +00:00
} ) ;
2020-04-24 11:19:22 +00:00
2021-03-12 14:00:15 +00:00
var arr = [ ] ;
var len = this . collectionPresets . length ;
var iconsPresets = this . CFPresets [ Asc . c _oAscCFRuleTypeSettings . icons ] ;
_ . each ( iconsPresets , function ( preset , index ) {
if ( index >= len ) return ;
var values = [ ] ;
for ( var i = 0 ; i < preset . length ; i ++ ) {
2021-04-30 15:30:08 +00:00
var formatValueObject = new Asc . asc _CConditionalFormatValueObject ( ) ;
2021-03-12 14:00:15 +00:00
formatValueObject . asc _setType ( preset [ i ] [ 0 ] ) ;
formatValueObject . asc _setVal ( preset [ i ] [ 1 ] ) ;
if ( preset [ i ] [ 2 ] ) {
2021-04-30 15:30:08 +00:00
// formatValueObject.asc_setFormula(new Asc.asc_CFormulaCF());
2021-03-12 14:00:15 +00:00
// formatValueObject.asc_getFormula().asc_setText(preset[1][i][2]);
}
values . push ( formatValueObject ) ;
}
arr . push ( {
value : index ,
data : {
iconSet : me . collectionPresets . at ( index ) . get ( 'icons' ) ,
values : values ,
icons : me . collectionIcons
}
2020-04-24 11:19:22 +00:00
} ) ;
2021-03-12 14:00:15 +00:00
} ) ;
this . cmbIconsPresets = new Common . UI . ComboBoxIcons ( {
el : $ ( '#format-rules-icon-style' ) ,
editable : false ,
style : 'width: 120px;' ,
menuStyle : 'max-height: 220px;min-width: 100%;' ,
data : arr
} ) . on ( 'selected' , function ( combo , record ) {
me . fillIconsControls ( record . value , record . data . values ) ;
2021-03-19 09:14:25 +00:00
_ . delay ( function ( ) {
me . iconsControls [ me . iconsControls . length - 1 ] . cmbOperator . focus ( ) ;
} , 50 ) ;
2021-03-12 14:00:15 +00:00
} ) ;
this . cmbIconsPresets . setValue ( 3 ) ;
this . iconsProps = { iconsSet : 3 } ;
this . chIconShow = new Common . UI . CheckBox ( {
el : $ ( '#format-rules-edit-chk-icon-show' ) ,
labelText : this . textShowIcon
} ) ;
this . chIconShow . on ( 'change' , function ( field , newValue , oldValue , eOpts ) {
} ) ;
2021-04-13 22:30:54 +00:00
Common . UI . FocusManager . add ( this , this . chIconShow ) ;
2021-03-12 14:00:15 +00:00
this . btnReverse = new Common . UI . Button ( {
el : $ ( '#format-rules-edit-btn-icon-reverse' )
} ) ;
this . btnReverse . on ( 'click' , function ( ) {
me . iconsProps . isReverse = ! me . iconsProps . isReverse ;
me . reverseIconsControls ( ) ;
} ) ;
this . iconsControls = [ ] ;
for ( var i = 0 ; i < 3 ; i ++ ) {
this . addNewIconsLine ( ) ;
2020-04-24 11:19:22 +00:00
}
2021-03-12 14:00:15 +00:00
var rec = this . cmbIconsPresets . getSelectedRecord ( ) ;
rec && this . fillIconsControls ( rec . value , rec . data . values ) ;
this . panels . iconset . rendered = true ;
} ,
renderDataBarPanel : function ( ) {
if ( this . panels . databar . rendered ) return ;
2020-04-27 19:17:43 +00:00
// Data Bar
2021-03-12 14:00:15 +00:00
var me = this ;
2020-04-27 19:17:43 +00:00
this . barControls = [ ] ;
for ( var i = 0 ; i < 2 ; i ++ ) {
2021-03-12 14:00:15 +00:00
var arr = this . dataValTypes ;
2020-04-27 19:17:43 +00:00
if ( i == 0 ) {
arr = [ { value : Asc . c _oAscCfvoType . Minimum , displayValue : this . textMinimum } ] . concat ( arr ) ;
2021-01-28 18:38:00 +00:00
arr . push ( { value : Asc . c _oAscCfvoType . AutoMin , displayValue : this . textAutomatic } ) ;
2020-04-27 19:17:43 +00:00
} else {
arr = [ { value : Asc . c _oAscCfvoType . Maximum , displayValue : this . textMaximum } ] . concat ( arr ) ;
2021-01-28 18:38:00 +00:00
arr . push ( { value : Asc . c _oAscCfvoType . AutoMax , displayValue : this . textAutomatic } ) ;
2020-04-27 19:17:43 +00:00
}
var combo = new Common . UI . ComboBox ( {
el : $ ( '#format-rules-edit-combo-bar-' + ( i + 1 ) ) ,
style : 'width: 100%;' ,
menuStyle : 'min-width: 100%;max-height: 211px;' ,
editable : false ,
cls : 'input-group-nr' ,
data : arr ,
2021-03-19 09:14:25 +00:00
type : i ,
takeFocusOnClose : true
2020-04-27 19:17:43 +00:00
} ) . on ( 'selected' , function ( combo , record ) {
me . barControls [ combo . options . type ] . range . setDisabled ( record . value == Asc . c _oAscCfvoType . Minimum || record . value == Asc . c _oAscCfvoType . Maximum ||
2021-03-12 14:00:15 +00:00
record . value == Asc . c _oAscCfvoType . AutoMin || record . value == Asc . c _oAscCfvoType . AutoMax ) ;
2021-02-24 19:39:04 +00:00
me . setDefComboValue ( combo . options . type , record . value , me . barControls [ combo . options . type ] . range ) ;
2020-04-27 19:17:43 +00:00
} ) ;
2021-07-20 20:38:25 +00:00
var value = ( i == 0 ) ? Asc . c _oAscCfvoType . AutoMin : Asc . c _oAscCfvoType . AutoMax ;
combo . setValue ( value ) ;
2021-03-19 09:14:25 +00:00
Common . UI . FocusManager . add ( this , combo ) ;
2020-04-27 19:17:43 +00:00
var range = new Common . UI . InputFieldBtn ( {
el : $ ( '#format-rules-edit-txt-bar-' + ( i + 1 ) ) ,
name : 'range' ,
style : 'width: 100%;' ,
allowBlank : true ,
btnHint : this . textSelectData ,
validateOnChange : false ,
2021-07-20 20:38:25 +00:00
type : i ,
disabled : ( value == Asc . c _oAscCfvoType . AutoMin || value == Asc . c _oAscCfvoType . AutoMax || value == Asc . c _oAscCfvoType . Minimum || value == Asc . c _oAscCfvoType . Maximum )
2020-04-27 19:17:43 +00:00
} ) ;
2021-07-20 20:38:25 +00:00
me . setDefComboValue ( i , value , range ) ;
2020-04-27 19:17:43 +00:00
range . on ( 'button:click' , _ . bind ( this . onSelectData , this ) ) ;
this . barControls . push ( { combo : combo , range : range } ) ;
2021-03-19 09:14:25 +00:00
Common . UI . FocusManager . add ( this , range ) ;
2020-04-27 19:17:43 +00:00
}
// Fill
this . cmbFill = new Common . UI . ComboBox ( {
el : $ ( '#format-rules-edit-combo-fill' ) ,
style : 'width: 100%;' ,
menuStyle : 'min-width: 100%;max-height: 211px;' ,
editable : false ,
cls : 'input-group-nr' ,
data : [
2021-01-28 18:38:00 +00:00
{ value : false , displayValue : this . textSolid } ,
{ value : true , displayValue : this . textGradient }
2021-03-19 09:14:25 +00:00
] ,
takeFocusOnClose : true
2020-04-27 19:17:43 +00:00
} ) . on ( 'selected' , function ( combo , record ) {
2021-02-24 18:48:40 +00:00
if ( me . barProps ) {
me . barProps . asc _setGradient ( record . value ) ;
me . previewFormat ( ) ;
}
2020-04-27 19:17:43 +00:00
} ) ;
this . cmbFill . setValue ( false ) ;
2021-03-19 09:14:25 +00:00
Common . UI . FocusManager . add ( this , this . cmbFill ) ;
2020-04-27 19:17:43 +00:00
this . btnPosFill = new Common . UI . ColorButton ( {
2020-04-30 13:58:45 +00:00
parentEl : $ ( '#format-rules-edit-color-pos-fill' ) ,
2020-04-27 19:17:43 +00:00
style : "width:45px;" ,
2020-04-30 13:58:45 +00:00
menu : true ,
2021-07-11 13:12:05 +00:00
color : '638EC6' ,
cls : 'move-focus' ,
takeFocusOnClose : true
2020-04-27 19:17:43 +00:00
} ) ;
2021-07-11 13:12:05 +00:00
Common . UI . FocusManager . add ( this , this . btnPosFill ) ;
2020-04-27 19:17:43 +00:00
this . btnNegFill = new Common . UI . ColorButton ( {
2020-04-30 13:58:45 +00:00
parentEl : $ ( '#format-rules-edit-color-neg-fill' ) ,
2020-04-27 19:17:43 +00:00
style : "width:45px;" ,
2020-04-30 13:58:45 +00:00
menu : true ,
2021-07-11 13:12:05 +00:00
color : 'FF0000' ,
cls : 'move-focus' ,
takeFocusOnClose : true
2020-04-27 19:17:43 +00:00
} ) ;
2021-07-11 13:12:05 +00:00
Common . UI . FocusManager . add ( this , this . btnNegFill ) ;
2020-04-27 19:17:43 +00:00
this . chFill = new Common . UI . CheckBox ( {
el : $ ( '#format-rules-edit-chk-fill' ) ,
2021-02-24 18:48:40 +00:00
labelText : this . textSameAs
2020-04-27 19:17:43 +00:00
} ) ;
this . chFill . on ( 'change' , function ( field , newValue , oldValue , eOpts ) {
me . btnNegFill . setDisabled ( field . getValue ( ) == 'checked' ) ;
} ) ;
2021-04-13 22:30:54 +00:00
Common . UI . FocusManager . add ( this , this . chFill ) ;
2020-04-27 19:17:43 +00:00
// Border
this . cmbBorder = new Common . UI . ComboBox ( {
el : $ ( '#format-rules-edit-combo-border' ) ,
style : 'width: 100%;' ,
menuStyle : 'min-width: 100%;max-height: 211px;' ,
editable : false ,
cls : 'input-group-nr' ,
data : [
2021-01-28 18:38:00 +00:00
{ value : false , displayValue : this . textSolid } ,
{ value : true , displayValue : this . textNone }
2021-03-19 09:14:25 +00:00
] ,
takeFocusOnClose : true
2020-04-27 19:17:43 +00:00
} ) . on ( 'selected' , function ( combo , record ) {
2021-02-24 18:48:40 +00:00
var hasBorder = ! record . value ;
me . btnPosBorder . setDisabled ( ! hasBorder ) ;
me . btnNegBorder . setDisabled ( ! hasBorder || me . chBorder . getValue ( ) == 'checked' ) ;
me . chBorder . setDisabled ( ! hasBorder ) ;
if ( me . barProps ) {
if ( hasBorder ) {
me . barProps . asc _setBorderColor ( Common . Utils . ThemeColor . getRgbColor ( me . btnPosBorder . colorPicker . currentColor ) ) ;
} else
me . barProps . asc _setBorderColor ( null ) ;
me . previewFormat ( ) ;
}
2020-04-27 19:17:43 +00:00
} ) ;
this . cmbBorder . setValue ( false ) ;
2021-03-19 09:14:25 +00:00
Common . UI . FocusManager . add ( this , this . cmbBorder ) ;
2020-04-27 19:17:43 +00:00
this . btnPosBorder = new Common . UI . ColorButton ( {
2020-04-30 13:58:45 +00:00
parentEl : $ ( '#format-rules-edit-color-pos-border' ) ,
2020-04-27 19:17:43 +00:00
style : "width:45px;" ,
2020-04-30 13:58:45 +00:00
menu : true ,
2021-07-11 13:12:05 +00:00
color : '000000' ,
cls : 'move-focus' ,
takeFocusOnClose : true
2020-04-27 19:17:43 +00:00
} ) ;
2021-07-11 13:12:05 +00:00
Common . UI . FocusManager . add ( this , this . btnPosBorder ) ;
2020-04-27 19:17:43 +00:00
this . btnNegBorder = new Common . UI . ColorButton ( {
2020-04-30 13:58:45 +00:00
parentEl : $ ( '#format-rules-edit-color-neg-border' ) ,
2020-04-27 19:17:43 +00:00
style : "width:45px;" ,
2020-04-30 13:58:45 +00:00
menu : true ,
2021-07-11 13:12:05 +00:00
color : '000000' ,
cls : 'move-focus' ,
takeFocusOnClose : true
2020-04-27 19:17:43 +00:00
} ) ;
2021-07-11 13:12:05 +00:00
Common . UI . FocusManager . add ( this , this . btnNegBorder ) ;
2020-04-27 19:17:43 +00:00
this . chBorder = new Common . UI . CheckBox ( {
el : $ ( '#format-rules-edit-chk-border' ) ,
2021-02-24 18:48:40 +00:00
labelText : this . textSameAs
2020-04-27 19:17:43 +00:00
} ) ;
this . chBorder . on ( 'change' , function ( field , newValue , oldValue , eOpts ) {
me . btnNegBorder . setDisabled ( field . getValue ( ) == 'checked' ) ;
} ) ;
2021-04-13 22:30:54 +00:00
Common . UI . FocusManager . add ( this , this . chBorder ) ;
2020-04-27 19:17:43 +00:00
// Axis
this . cmbBarDirection = new Common . UI . ComboBox ( {
el : $ ( '#format-rules-edit-combo-direction' ) ,
style : 'width: 100%;' ,
menuStyle : 'min-width: 100%;max-height: 211px;' ,
editable : false ,
cls : 'input-group-nr' ,
data : [
2021-01-28 18:38:00 +00:00
{ value : Asc . c _oAscDataBarDirection . context , displayValue : this . textContext } ,
{ value : Asc . c _oAscDataBarDirection . leftToRight , displayValue : this . textLeft2Right } ,
{ value : Asc . c _oAscDataBarDirection . rightToLeft , displayValue : this . textRight2Left }
2021-03-19 09:14:25 +00:00
] ,
takeFocusOnClose : true
2020-04-27 19:17:43 +00:00
} ) . on ( 'selected' , function ( combo , record ) {
2021-02-24 18:48:40 +00:00
if ( me . barProps ) {
me . barProps . asc _setDirection ( record . value ) ;
me . previewFormat ( ) ;
}
2020-04-27 19:17:43 +00:00
} ) ;
this . cmbBarDirection . setValue ( Asc . c _oAscDataBarDirection . context ) ;
2021-03-19 09:14:25 +00:00
Common . UI . FocusManager . add ( this , this . cmbBarDirection ) ;
2020-04-27 19:17:43 +00:00
this . chShowBar = new Common . UI . CheckBox ( {
el : $ ( '#format-rules-edit-chk-show-bar' ) ,
2021-02-24 18:48:40 +00:00
labelText : this . textShowBar
2020-04-27 19:17:43 +00:00
} ) ;
2021-04-13 22:30:54 +00:00
Common . UI . FocusManager . add ( this , this . chShowBar ) ;
2020-04-27 19:17:43 +00:00
this . cmbAxisPos = new Common . UI . ComboBox ( {
el : $ ( '#format-rules-edit-combo-axis-pos' ) ,
style : 'width: 150px;' ,
menuStyle : 'min-width: 100%;max-height: 211px;' ,
editable : false ,
cls : 'input-group-nr' ,
data : [
2021-01-28 18:38:00 +00:00
{ value : Asc . c _oAscDataBarAxisPosition . automatic , displayValue : this . textAutomatic } ,
{ value : Asc . c _oAscDataBarAxisPosition . middle , displayValue : this . textCellMidpoint } ,
{ value : Asc . c _oAscDataBarAxisPosition . none , displayValue : this . textNone }
2021-03-19 09:14:25 +00:00
] ,
takeFocusOnClose : true
2020-04-27 19:17:43 +00:00
} ) . on ( 'selected' , function ( combo , record ) {
me . btnAxisColor . setDisabled ( record . value == Asc . c _oAscDataBarAxisPosition . none ) ;
} ) ;
this . cmbAxisPos . setValue ( Asc . c _oAscDataBarDirection . context ) ;
2021-03-19 09:14:25 +00:00
Common . UI . FocusManager . add ( this , this . cmbAxisPos ) ;
2020-04-27 19:17:43 +00:00
this . btnAxisColor = new Common . UI . ColorButton ( {
2020-04-30 13:58:45 +00:00
parentEl : $ ( '#format-rules-edit-color-axis-color' ) ,
2020-04-27 19:17:43 +00:00
style : "width:45px;" ,
2020-04-30 13:58:45 +00:00
menu : true ,
2021-07-11 13:12:05 +00:00
color : '000000' ,
cls : 'move-focus' ,
takeFocusOnClose : true
2020-04-27 19:17:43 +00:00
} ) ;
2021-07-11 13:12:05 +00:00
Common . UI . FocusManager . add ( this , this . btnAxisColor ) ;
2020-04-27 19:17:43 +00:00
2021-03-12 14:00:15 +00:00
this . panels . databar . rendered = true ;
this . updateThemeColors ( ) ;
} ,
2021-03-03 11:05:31 +00:00
2021-03-12 14:00:15 +00:00
renderScalesPanel : function ( ) {
if ( this . panels . scale . rendered ) return ;
2021-03-03 11:05:31 +00:00
2021-03-12 14:00:15 +00:00
// Scale
var me = this ;
this . scaleControls = [ ] ;
this . lblMidScale = this . $window . find ( '#format-rules-edit-lbl-scale-2' ) ;
2021-03-03 11:05:31 +00:00
2021-03-12 14:00:15 +00:00
for ( var i = 0 ; i < 3 ; i ++ ) {
var arr = this . dataValTypes ;
if ( i == 0 )
arr = [ { value : Asc . c _oAscCfvoType . Minimum , displayValue : this . textMinimum } ] . concat ( arr ) ;
else if ( i == 2 )
arr = [ { value : Asc . c _oAscCfvoType . Maximum , displayValue : this . textMaximum } ] . concat ( arr ) ;
2021-03-03 11:05:31 +00:00
var combo = new Common . UI . ComboBox ( {
2021-03-12 14:00:15 +00:00
el : $ ( '#format-rules-edit-combo-scale-' + ( i + 1 ) ) ,
style : 'width: 100%;' ,
2021-03-03 11:05:31 +00:00
menuStyle : 'min-width: 100%;max-height: 211px;' ,
editable : false ,
cls : 'input-group-nr' ,
2021-03-12 14:00:15 +00:00
data : arr ,
2021-03-19 09:14:25 +00:00
type : i ,
takeFocusOnClose : true
2021-03-03 11:05:31 +00:00
} ) . on ( 'selected' , function ( combo , record ) {
2021-03-12 14:00:15 +00:00
me . scaleControls [ combo . options . type ] . range . setDisabled ( record . value == Asc . c _oAscCfvoType . Minimum || record . value == Asc . c _oAscCfvoType . Maximum ) ;
me . setDefComboValue ( combo . options . type , record . value , me . scaleControls [ combo . options . type ] . range ) ;
2021-03-03 11:05:31 +00:00
} ) ;
2021-03-12 14:00:15 +00:00
combo . setValue ( ( i == 1 ) ? Asc . c _oAscCfvoType . Percentile : arr [ 0 ] . value ) ;
2021-03-19 09:14:25 +00:00
Common . UI . FocusManager . add ( this , combo ) ;
2021-03-03 11:05:31 +00:00
var range = new Common . UI . InputFieldBtn ( {
2021-03-12 14:00:15 +00:00
el : $ ( '#format-rules-edit-txt-scale-' + ( i + 1 ) ) ,
2021-03-03 11:05:31 +00:00
name : 'range' ,
2021-03-12 14:00:15 +00:00
style : 'width: 100%;' ,
2021-03-03 11:05:31 +00:00
allowBlank : true ,
btnHint : this . textSelectData ,
validateOnChange : false ,
2021-03-12 14:00:15 +00:00
type : i ,
disabled : ( i != 1 )
2021-03-03 11:05:31 +00:00
} ) ;
2021-03-12 14:00:15 +00:00
range . setValue ( ( i == 1 ) ? 50 : '' ) ;
2021-03-10 16:53:38 +00:00
range . on ( 'button:click' , _ . bind ( this . onSelectData , this ) ) ;
2021-03-19 09:14:25 +00:00
Common . UI . FocusManager . add ( this , range ) ;
2021-03-03 11:05:31 +00:00
2021-03-12 14:00:15 +00:00
var color = new Common . UI . ColorButton ( {
parentEl : $ ( '#format-rules-edit-color-scale-' + ( i + 1 ) ) ,
menu : true ,
type : i ,
2021-07-11 13:12:05 +00:00
color : '000000' ,
cls : 'move-focus' ,
takeFocusOnClose : true
2021-03-12 14:00:15 +00:00
} ) ;
2021-07-11 13:12:05 +00:00
Common . UI . FocusManager . add ( this , color ) ;
2021-03-12 14:00:15 +00:00
this . scaleControls . push ( { combo : combo , range : range , color : color } ) ;
2021-03-03 11:05:31 +00:00
}
2021-03-12 14:00:15 +00:00
this . panels . scale . rendered = true ;
this . updateThemeColors ( ) ;
2020-04-16 15:43:16 +00:00
} ,
afterRender : function ( ) {
this . updateThemeColors ( ) ;
this . _setDefaults ( this . props ) ;
this . setTitle ( ( this . isEdit ) ? this . txtTitleEdit : this . txtTitleNew ) ;
} ,
show : function ( ) {
Common . Views . AdvancedSettingsWindow . prototype . show . apply ( this , arguments ) ;
} ,
_setDefaults : function ( props ) {
2021-02-02 14:01:24 +00:00
this . _originalProps = props ;
2020-04-17 11:16:09 +00:00
var type = props ? props . asc _getType ( ) : this . type ,
2020-04-20 10:49:38 +00:00
ruleType ,
2021-03-15 15:31:39 +00:00
subtype = this . subtype ,
isPercent = ! ! this . percent ;
2020-04-20 10:49:38 +00:00
if ( props ) {
var value ;
switch ( type ) {
case Asc . c _oAscCFType . containsText :
case Asc . c _oAscCFType . notContainsText :
case Asc . c _oAscCFType . beginsWith :
case Asc . c _oAscCFType . endsWith :
value = props . asc _getContainsText ( ) ;
2020-04-20 12:40:16 +00:00
this . txtRange1 . setValue ( value || '' ) ;
2020-04-20 10:49:38 +00:00
break ;
case Asc . c _oAscCFType . timePeriod :
subtype = props . asc _getTimePeriod ( ) ;
break ;
2020-04-20 12:40:16 +00:00
case Asc . c _oAscCFType . aboveAverage :
var above = props . asc _getAboveAverage ( ) ,
eq = props . asc _getEqualAverage ( ) ,
stddev = props . asc _getStdDev ( ) ;
subtype = ( above ) ? 0 : 1 ;
if ( eq )
subtype += 2 ;
else if ( stddev ) {
2020-04-28 12:42:19 +00:00
subtype += ( 2 + stddev * 2 ) ;
2020-04-20 12:40:16 +00:00
}
break ;
case Asc . c _oAscCFType . top10 :
subtype = props . asc _getBottom ( ) ? 1 : 0 ;
2021-03-15 15:31:39 +00:00
isPercent = props . asc _getPercent ( ) ;
2020-04-20 12:40:16 +00:00
this . numRank . setValue ( props . asc _getRank ( ) ? props . asc _getRank ( ) : 10 ) ;
break ;
2020-04-20 10:49:38 +00:00
case Asc . c _oAscCFType . cellIs :
subtype = props . asc _getOperator ( ) ;
2020-04-20 12:40:16 +00:00
this . txtRange1 . setValue ( props . asc _getValue1 ( ) || '' ) ;
this . txtRange2 . setValue ( props . asc _getValue2 ( ) || '' ) ;
break ;
case Asc . c _oAscCFType . expression :
this . txtRange1 . setValue ( props . asc _getValue1 ( ) || '' ) ;
2020-04-20 10:49:38 +00:00
break ;
2020-04-24 11:19:22 +00:00
case Asc . c _oAscCFType . colorScale :
2021-03-12 14:00:15 +00:00
this . renderScalesPanel ( ) ;
2020-04-24 11:19:22 +00:00
value = props . asc _getColorScaleOrDataBarOrIconSetRule ( ) ;
var scales = value . asc _getCFVOs ( ) ,
colors = value . asc _getColors ( ) ;
subtype = scales . length ;
var arr = ( scales . length == 2 ) ? [ this . scaleControls [ 0 ] , this . scaleControls [ 2 ] ] : this . scaleControls ;
for ( var i = 0 ; i < scales . length ; i ++ ) {
var scaletype = scales [ i ] . asc _getType ( ) ,
val = scales [ i ] . asc _getVal ( ) ,
2020-05-08 13:38:15 +00:00
color = colors [ i ] ,
2020-04-24 11:19:22 +00:00
controls = arr [ i ] ;
controls . combo . setValue ( scaletype ) ;
controls . range . setDisabled ( scaletype == Asc . c _oAscCfvoType . Minimum || scaletype == Asc . c _oAscCfvoType . Maximum ) ;
controls . range . setValue ( ( scaletype !== Asc . c _oAscCfvoType . Minimum && scaletype !== Asc . c _oAscCfvoType . Maximum && val !== null && val !== undefined ) ? val : '' ) ;
2021-03-11 11:54:07 +00:00
this . setColor ( color , controls . color ) ;
2020-04-24 11:19:22 +00:00
}
break ;
case Asc . c _oAscCFType . dataBar :
2021-03-12 14:00:15 +00:00
this . renderDataBarPanel ( ) ;
2020-04-24 11:19:22 +00:00
value = props . asc _getColorScaleOrDataBarOrIconSetRule ( ) ;
2020-04-27 19:17:43 +00:00
var bars = value . asc _getCFVOs ( ) ;
var arr = this . barControls ;
for ( var i = 0 ; i < bars . length ; i ++ ) {
var bartype = bars [ i ] . asc _getType ( ) ,
val = bars [ i ] . asc _getVal ( ) ,
controls = arr [ i ] ;
controls . combo . setValue ( bartype ) ;
controls . range . setDisabled ( bartype == Asc . c _oAscCfvoType . Minimum || bartype == Asc . c _oAscCfvoType . Maximum || bartype == Asc . c _oAscCfvoType . AutoMin || bartype == Asc . c _oAscCfvoType . AutoMax ) ;
controls . range . setValue ( ( bartype !== Asc . c _oAscCfvoType . Minimum && bartype !== Asc . c _oAscCfvoType . Maximum && bartype !== Asc . c _oAscCfvoType . AutoMin && bartype !== Asc . c _oAscCfvoType . AutoMax &&
val !== null && val !== undefined ) ? val : '' ) ;
}
this . cmbFill . setValue ( value . asc _getGradient ( ) ) ;
2021-03-11 11:54:07 +00:00
this . setColor ( value . asc _getColor ( ) , this . btnPosFill ) ;
this . setColor ( value . asc _getNegativeColor ( ) || value . asc _getColor ( ) , this . btnNegFill ) ;
2020-04-27 19:17:43 +00:00
this . chFill . setValue ( value . asc _getNegativeBarColorSameAsPositive ( ) ) ;
var color = value . asc _getBorderColor ( ) ;
this . cmbBorder . setValue ( color === null ) ;
this . btnPosBorder . setDisabled ( color === null ) ;
if ( color ) {
2021-03-11 11:54:07 +00:00
this . setColor ( value . asc _getBorderColor ( ) , this . btnPosBorder ) ;
this . setColor ( value . asc _getNegativeBorderColor ( ) || value . asc _getBorderColor ( ) , this . btnNegBorder ) ;
2020-04-27 19:17:43 +00:00
}
this . chBorder . setValue ( value . asc _getNegativeBarBorderColorSameAsPositive ( ) ) ;
this . chBorder . setDisabled ( color === null ) ;
this . btnNegBorder . setDisabled ( color === null || value . asc _getNegativeBarBorderColorSameAsPositive ( ) ) ;
this . cmbBarDirection . setValue ( value . asc _getDirection ( ) ) ;
this . chShowBar . setValue ( ! value . asc _getShowValue ( ) ) ;
this . cmbAxisPos . setValue ( value . asc _getAxisPosition ( ) ) ;
2021-03-11 11:54:07 +00:00
value . asc _getAxisColor ( ) && this . setColor ( value . asc _getAxisColor ( ) , this . btnAxisColor ) ;
2020-04-27 19:17:43 +00:00
this . btnAxisColor . setDisabled ( value . asc _getAxisPosition ( ) == Asc . c _oAscDataBarAxisPosition . none ) ;
2020-04-24 11:19:22 +00:00
break ;
case Asc . c _oAscCFType . iconSet :
2021-03-12 14:00:15 +00:00
this . renderIconsPanel ( ) ;
2020-04-24 11:19:22 +00:00
value = props . asc _getColorScaleOrDataBarOrIconSetRule ( ) ;
2021-03-03 17:58:06 +00:00
this . chIconShow . setValue ( ! value . asc _getShowValue ( ) ) ;
this . iconsProps . isReverse = value . asc _getReverse ( ) ;
2021-03-03 11:05:31 +00:00
this . fillIconsControls ( value . asc _getIconSet ( ) , value . asc _getCFVOs ( ) , value . asc _getIconSets ( ) ) ;
2020-04-24 11:19:22 +00:00
break ;
2020-04-20 10:49:38 +00:00
}
2021-03-11 11:54:07 +00:00
}
if ( type === Asc . c _oAscCFType . containsText || type === Asc . c _oAscCFType . notContainsText || type === Asc . c _oAscCFType . beginsWith ||
type === Asc . c _oAscCFType . endsWith || type === Asc . c _oAscCFType . containsBlanks || type === Asc . c _oAscCFType . notContainsBlanks ||
type === Asc . c _oAscCFType . duplicateValues || type === Asc . c _oAscCFType . uniqueValues ||
type === Asc . c _oAscCFType . containsErrors || type === Asc . c _oAscCFType . notContainsErrors ||
type === Asc . c _oAscCFType . timePeriod || type === Asc . c _oAscCFType . aboveAverage ||
type === Asc . c _oAscCFType . top10 || type === Asc . c _oAscCFType . cellIs || type === Asc . c _oAscCFType . expression ) {
if ( props )
2021-02-02 08:03:27 +00:00
this . xfsFormat = props . asc _getDxf ( ) ;
2021-03-11 11:54:07 +00:00
else {
2021-03-15 18:58:40 +00:00
this . onFormatsSelect ( this . btnFormats . menu , this . btnFormats . menu . items [ 0 ] ) ;
2021-02-02 08:03:27 +00:00
}
2020-04-20 10:49:38 +00:00
}
2020-04-17 11:16:09 +00:00
2020-04-24 11:19:22 +00:00
var rec = this . ruleStore . where ( { type : type } ) ;
if ( rec . length > 1 ) {
if ( type == Asc . c _oAscCFType . colorScale ) {
rec = ( subtype == rec [ 0 ] . get ( 'num' ) ) ? rec [ 0 ] : rec [ 1 ] ;
}
} else if ( rec . length == 0 ) {
2020-04-17 11:16:09 +00:00
var store = this . ruleStore ;
for ( var i = 0 ; i < store . length ; i ++ ) {
var item = store . at ( i ) ,
rules = item . get ( 'rules' ) ;
if ( rules && rules . findWhere ( { type : type } ) ) {
rec = item ;
ruleType = type ;
break ;
2020-04-16 15:43:16 +00:00
}
}
2020-04-17 11:16:09 +00:00
} else { // find rule
2020-04-24 11:19:22 +00:00
rec = rec [ 0 ] ;
2020-04-17 11:16:09 +00:00
var rules = rec . get ( 'rules' ) ;
if ( rules && rules . findWhere ( { type : type } ) ) {
ruleType = type ;
} else {
// find by subtype
if ( ( subtype !== undefined ) && rules && rules . findWhere ( { subtype : subtype } ) ) {
ruleType = subtype ;
}
2020-04-16 15:43:16 +00:00
}
2020-04-17 11:16:09 +00:00
}
if ( ! rec )
rec = this . ruleStore . at ( 0 ) ;
if ( rec ) {
this . cmbCategory . setValue ( rec . get ( 'index' ) ) ;
this . refreshRules ( rec . get ( 'index' ) , ruleType ) ;
2021-03-15 15:31:39 +00:00
if ( type === Asc . c _oAscCFType . top10 ) {
this . cmbPercent . setValue ( isPercent ? 1 : 0 ) ;
}
2020-04-17 11:16:09 +00:00
}
2021-04-30 15:33:33 +00:00
var xfs = this . xfsFormat ? this . xfsFormat : ( new Asc . asc _CellXfs ( ) ) ;
2021-03-15 18:58:40 +00:00
this . fillXfsFormatInfo ( xfs ) ;
2021-03-11 11:54:07 +00:00
this . previewFormat ( ) ;
} ,
setColor : function ( color , control , picker ) {
picker = control ? control . colorPicker : picker ;
2021-11-09 13:56:05 +00:00
if ( color && ! color . get _auto ( ) ) {
2021-03-11 11:54:07 +00:00
if ( color . get _type ( ) == Asc . c _oAscColor . COLOR _TYPE _SCHEME ) {
color = { color : Common . Utils . ThemeColor . getHexColor ( color . get _r ( ) , color . get _g ( ) , color . get _b ( ) ) , effectValue : color . get _value ( ) } ;
} else {
color = Common . Utils . ThemeColor . getHexColor ( color . get _r ( ) , color . get _g ( ) , color . get _b ( ) ) ;
}
} else {
color = picker . options . transparent ? 'transparent' : '000000' ;
}
control && control . setColor ( color ) ;
if ( _ . isObject ( color ) ) {
var isselected = false ;
for ( var i = 0 ; i < 10 ; i ++ ) {
if ( Common . Utils . ThemeColor . ThemeValues [ i ] == color . effectValue ) {
picker . select ( color , true ) ;
isselected = true ;
break ;
}
}
if ( ! isselected ) picker . clearSelection ( ) ;
} else {
picker . select ( color , true ) ;
}
picker && ( picker . currentColor = color ) ;
control && ( control . currentColor = color ) ;
return color ;
} ,
fillXfsFormatInfo : function ( xfs ) {
2021-01-28 18:56:57 +00:00
if ( xfs ) {
2021-01-28 11:00:40 +00:00
this . btnBold . toggle ( xfs . asc _getFontBold ( ) === true , true ) ;
this . btnItalic . toggle ( xfs . asc _getFontItalic ( ) === true , true ) ;
this . btnUnderline . toggle ( xfs . asc _getFontUnderline ( ) === true , true ) ;
this . btnStrikeout . toggle ( xfs . asc _getFontStrikeout ( ) === true , true ) ;
2021-07-11 09:03:01 +00:00
var color = this . setColor ( xfs . asc _getFontColor ( ) , this . btnTextColor , this . mnuTextColorPicker ) ;
color = this . setColor ( xfs . asc _getFillColor ( ) , this . btnFillColor , this . mnuFillColorPicker ) ;
2021-01-28 11:00:40 +00:00
var val = xfs . asc _getNumFormatInfo ( ) ;
val && this . cmbNumberFormat . setValue ( val . asc _getType ( ) , this . textCustom ) ;
2021-01-26 15:50:59 +00:00
}
2020-04-16 15:43:16 +00:00
} ,
2021-01-26 08:38:05 +00:00
getSettings : function ( ) {
var props ;
var rec = this . ruleStore . findWhere ( { index : this . cmbCategory . getValue ( ) } ) ;
if ( rec ) {
2021-04-30 15:30:08 +00:00
props = this . _originalProps || new Asc . asc _CConditionalFormattingRule ( ) ;
2021-07-14 15:57:23 +00:00
var type = rec . get ( 'type' ) ,
type _changed = ( type !== props . asc _getType ( ) ) ;
2021-01-26 08:38:05 +00:00
props . asc _setType ( type ) ;
2021-01-26 21:32:45 +00:00
if ( type == Asc . c _oAscCFType . containsText || type == Asc . c _oAscCFType . containsBlanks || type == Asc . c _oAscCFType . duplicateValues ||
type == Asc . c _oAscCFType . timePeriod || type == Asc . c _oAscCFType . aboveAverage ||
2021-01-26 08:38:05 +00:00
type == Asc . c _oAscCFType . top10 || type == Asc . c _oAscCFType . cellIs || type == Asc . c _oAscCFType . expression ) {
2021-08-09 09:55:55 +00:00
( this . xfsFormat || this . xfsFormat === null ) && props . asc _setDxf ( this . xfsFormat ) ;
2021-01-26 08:38:05 +00:00
}
switch ( type ) {
case Asc . c _oAscCFType . containsText :
2021-01-26 21:32:45 +00:00
var value = this . txtRange1 . getValue ( ) ;
2021-01-26 08:38:05 +00:00
value && props . asc _setContainsText ( value ) ;
2021-01-26 21:32:45 +00:00
props . asc _setType ( this . cmbRule . getValue ( ) ) ;
break ;
case Asc . c _oAscCFType . containsBlanks :
case Asc . c _oAscCFType . duplicateValues :
props . asc _setType ( this . cmbRule . getValue ( ) ) ;
2021-01-26 08:38:05 +00:00
break ;
case Asc . c _oAscCFType . timePeriod :
props . asc _setTimePeriod ( this . cmbRule . getValue ( ) ) ;
break ;
case Asc . c _oAscCFType . aboveAverage :
var val = this . cmbRule . getValue ( ) ;
var above = ! ( val % 2 ) ;
props . asc _setAboveAverage ( above ) ;
props . asc _setEqualAverage ( val == 2 || val == 3 ) ;
2021-08-03 08:53:44 +00:00
props . asc _setStdDev ( val > 3 ? ( Math . floor ( val / 2 ) - 1 ) : 0 ) ;
2021-01-26 08:38:05 +00:00
break ;
case Asc . c _oAscCFType . top10 :
props . asc _setBottom ( ! ! this . cmbRule . getValue ( ) ) ;
props . asc _setPercent ( ! ! this . cmbPercent . getValue ( ) ) ;
( this . numRank . getValue ( ) !== '' ) && props . asc _setRank ( this . numRank . getNumberValue ( ) ) ;
break ;
case Asc . c _oAscCFType . cellIs :
props . asc _setOperator ( this . cmbRule . getValue ( ) ) ;
props . asc _setValue1 ( this . txtRange1 . getValue ( ) ) ;
2021-08-02 13:02:07 +00:00
this . txtRange2 . isVisible ( ) && props . asc _setValue2 ( this . txtRange2 . getValue ( ) ) ;
2021-01-26 08:38:05 +00:00
break ;
case Asc . c _oAscCFType . expression :
2021-01-26 21:32:45 +00:00
props . asc _setValue1 ( this . txtRange1 . getValue ( ) ) ;
2021-01-26 08:38:05 +00:00
break ;
case Asc . c _oAscCFType . colorScale :
2021-07-14 15:57:23 +00:00
var scaleProps = ! type _changed ? props . asc _getColorScaleOrDataBarOrIconSetRule ( ) : new Asc . asc _CColorScale ( ) ;
2021-01-26 08:38:05 +00:00
var scalesCount = rec . get ( 'num' ) ;
2021-02-02 08:03:27 +00:00
var arr = ( scalesCount == 2 ) ? [ this . scaleControls [ 0 ] , this . scaleControls [ 2 ] ] : this . scaleControls ;
2021-01-26 08:38:05 +00:00
var colors = [ ] , scales = [ ] ;
for ( var i = 0 ; i < scalesCount ; i ++ ) {
2021-04-30 15:30:08 +00:00
var scale = new Asc . asc _CConditionalFormatValueObject ( ) ;
2021-01-26 08:38:05 +00:00
var controls = arr [ i ] ;
scale . asc _setType ( controls . combo . getValue ( ) ) ;
scale . asc _setVal ( controls . range . getValue ( ) ) ;
scales . push ( scale ) ;
2021-02-02 08:03:27 +00:00
colors . push ( Common . Utils . ThemeColor . getRgbColor ( controls . colorPicker . currentColor ) ) ;
2021-01-26 08:38:05 +00:00
}
2021-02-02 08:03:27 +00:00
scaleProps . asc _setColors ( colors ) ;
scaleProps . asc _setCFVOs ( scales ) ;
2021-01-26 08:38:05 +00:00
props . asc _setColorScaleOrDataBarOrIconSetRule ( scaleProps ) ;
break ;
case Asc . c _oAscCFType . dataBar :
2021-07-14 15:57:23 +00:00
var barProps = ! type _changed ? props . asc _getColorScaleOrDataBarOrIconSetRule ( ) : new Asc . asc _CDataBar ( ) ;
type _changed && barProps . asc _setInterfaceDefault ( ) ;
2021-02-24 18:48:40 +00:00
var arr = this . barControls ;
var bars = [ ] ;
for ( var i = 0 ; i < arr . length ; i ++ ) {
2021-04-30 15:30:08 +00:00
var bar = new Asc . asc _CConditionalFormatValueObject ( ) ;
2021-02-24 18:48:40 +00:00
var controls = arr [ i ] ,
bartype = controls . combo . getValue ( ) ;
bar . asc _setType ( bartype ) ;
if ( bartype !== Asc . c _oAscCfvoType . Minimum && bartype !== Asc . c _oAscCfvoType . Maximum && bartype !== Asc . c _oAscCfvoType . AutoMin && bartype !== Asc . c _oAscCfvoType . AutoMax )
bar . asc _setVal ( controls . range . getValue ( ) ) ;
bars . push ( bar ) ;
}
barProps . asc _setCFVOs ( bars ) ;
barProps . asc _setGradient ( this . cmbFill . getValue ( ) ) ;
barProps . asc _setColor ( Common . Utils . ThemeColor . getRgbColor ( this . btnPosFill . colorPicker . currentColor ) ) ;
barProps . asc _setNegativeColor ( Common . Utils . ThemeColor . getRgbColor ( this . chFill . getValue ( ) == 'checked' ? this . btnPosFill . colorPicker . currentColor : this . btnNegFill . colorPicker . currentColor ) ) ;
barProps . asc _setNegativeBarColorSameAsPositive ( this . chFill . getValue ( ) == 'checked' ) ;
var hasBorder = ! this . cmbBorder . getValue ( ) ;
if ( hasBorder ) {
barProps . asc _setBorderColor ( Common . Utils . ThemeColor . getRgbColor ( this . btnPosBorder . colorPicker . currentColor ) ) ;
barProps . asc _setNegativeBorderColor ( Common . Utils . ThemeColor . getRgbColor ( this . chBorder . getValue ( ) == 'checked' ? this . btnPosBorder . colorPicker . currentColor : this . btnNegBorder . colorPicker . currentColor ) ) ;
barProps . asc _setNegativeBarBorderColorSameAsPositive ( this . chBorder . getValue ( ) == 'checked' ) ;
2021-08-09 09:35:21 +00:00
} else {
2021-02-24 18:48:40 +00:00
barProps . asc _setBorderColor ( null ) ;
2021-08-09 09:35:21 +00:00
barProps . asc _setNegativeBorderColor ( null ) ;
}
2021-02-24 18:48:40 +00:00
barProps . asc _setDirection ( this . cmbBarDirection . getValue ( ) ) ;
barProps . asc _setShowValue ( this . chShowBar . getValue ( ) !== 'checked' ) ;
var pos = this . cmbAxisPos . getValue ( ) ;
barProps . asc _setAxisPosition ( pos ) ;
if ( pos !== Asc . c _oAscDataBarAxisPosition . none ) {
barProps . asc _setAxisColor ( Common . Utils . ThemeColor . getRgbColor ( this . btnAxisColor . colorPicker . currentColor ) ) ;
} else
barProps . asc _setAxisColor ( null ) ;
props . asc _setColorScaleOrDataBarOrIconSetRule ( barProps ) ;
2021-01-26 08:38:05 +00:00
break ;
case Asc . c _oAscCFType . iconSet :
2021-07-14 15:57:23 +00:00
var iconsProps = ! type _changed ? props . asc _getColorScaleOrDataBarOrIconSetRule ( ) : new Asc . asc _CIconSet ( ) ;
2021-03-03 17:58:06 +00:00
iconsProps . asc _setShowValue ( this . chIconShow . getValue ( ) !== 'checked' ) ;
iconsProps . asc _setReverse ( ! ! this . iconsProps . isReverse ) ;
iconsProps . asc _setIconSet ( this . iconsProps . iconsSet ) ;
var arr = this . iconsControls ,
len = this . iconsProps . iconsLength ,
icons = ( ! this . cmbIconsPresets . getSelectedRecord ( ) ) ? [ ] : null ,
values = [ ] ;
for ( var i = 0 ; i < len ; i ++ ) {
var controls = arr [ i ] ,
2021-04-30 15:30:08 +00:00
value = new Asc . asc _CConditionalFormatValueObject ( ) ;
2021-03-03 17:58:06 +00:00
value . asc _setType ( controls . cmbType . getValue ( ) ) ;
value . asc _setVal ( controls . value . getValue ( ) ) ;
2021-03-03 19:50:19 +00:00
value . asc _setGte ( controls . cmbOperator . getValue ( ) ) ;
2021-03-03 17:58:06 +00:00
values . push ( value ) ;
if ( icons ) {
2021-07-13 19:08:32 +00:00
if ( controls . itemNoIcons . isChecked ( ) ) {
var icon = new Asc . asc _CConditionalFormatIconSet ( ) ;
icon . asc _setIconSet ( Asc . EIconSetType . NoIcons ) ;
icon . asc _setIconId ( 0 ) ;
this . iconsProps . isReverse ? icons . unshift ( icon ) : icons . push ( icon ) ;
} else {
var icon = controls . pickerIcons . getSelectedRec ( ) . get ( 'value' ) + 1 ;
for ( var k = 0 ; k < this . collectionPresets . length ; k ++ ) {
var items = this . collectionPresets . at ( k ) . get ( 'icons' ) ;
for ( var j = 0 ; j < items . length ; j ++ ) {
if ( icon == items [ j ] ) {
icon = new Asc . asc _CConditionalFormatIconSet ( ) ;
icon . asc _setIconSet ( k ) ;
icon . asc _setIconId ( j ) ;
this . iconsProps . isReverse ? icons . unshift ( icon ) : icons . push ( icon ) ;
break ;
}
2021-03-03 22:11:57 +00:00
}
2021-07-13 19:08:32 +00:00
if ( typeof icon == 'object' ) break ;
2021-03-03 22:11:57 +00:00
}
}
2021-03-03 17:58:06 +00:00
}
}
iconsProps . asc _setCFVOs ( values ) ;
iconsProps . asc _setIconSets ( icons ) ;
props . asc _setColorScaleOrDataBarOrIconSetRule ( iconsProps ) ;
2021-01-26 08:38:05 +00:00
break ;
}
}
return props ;
} ,
2020-04-20 10:49:38 +00:00
refreshRules : function ( index , ruleType ) {
2020-04-16 15:43:16 +00:00
var rec = this . ruleStore . findWhere ( { index : index } ) ;
if ( rec ) {
var rules = rec . get ( 'rules' ) ,
cmbData = [ ] ;
rules && rules . each ( function ( rule , idx ) {
2020-04-17 11:16:09 +00:00
cmbData . push ( { value : ( rule . get ( 'type' ) !== undefined ) ? rule . get ( 'type' ) : rule . get ( 'subtype' ) , displayValue : rule . get ( 'name' ) } ) ;
2020-04-16 15:43:16 +00:00
} ) ;
this . cmbRule . setData ( cmbData ) ;
2020-04-20 10:49:38 +00:00
( cmbData . length > 0 ) && this . cmbRule . setValue ( ( ruleType !== undefined ) ? ruleType : cmbData [ 0 ] . value ) ;
2020-04-16 15:43:16 +00:00
}
2020-04-20 10:49:38 +00:00
this . setControls ( index , this . cmbRule . getValue ( ) ) ;
2021-03-11 20:11:42 +00:00
this . setHeight ( index == 9 ? 445 : 355 ) ;
2021-02-02 08:03:27 +00:00
if ( rec ) {
var type = rec . get ( 'type' ) ;
2021-04-30 15:30:08 +00:00
this . _changedProps = new Asc . asc _CConditionalFormattingRule ( ) ;
2021-02-02 08:03:27 +00:00
this . _changedProps . asc _setType ( type ) ;
if ( type == Asc . c _oAscCFType . containsText || type == Asc . c _oAscCFType . containsBlanks || type == Asc . c _oAscCFType . duplicateValues ||
type == Asc . c _oAscCFType . timePeriod || type == Asc . c _oAscCFType . aboveAverage ||
type == Asc . c _oAscCFType . top10 || type == Asc . c _oAscCFType . cellIs || type == Asc . c _oAscCFType . expression ) {
2021-08-09 09:55:55 +00:00
( this . xfsFormat || this . xfsFormat === null ) && this . _changedProps . asc _setDxf ( this . xfsFormat ) ;
2021-02-02 08:03:27 +00:00
} else if ( type == Asc . c _oAscCFType . colorScale ) {
var scalesCount = rec . get ( 'num' ) ;
var arr = ( scalesCount == 2 ) ? [ this . scaleControls [ 0 ] , this . scaleControls [ 2 ] ] : this . scaleControls ;
var colors = [ ] , scales = [ ] ;
for ( var i = 0 ; i < arr . length ; i ++ ) {
2021-04-30 15:30:08 +00:00
var scale = new Asc . asc _CConditionalFormatValueObject ( ) ;
2021-02-02 08:03:27 +00:00
var controls = arr [ i ] ;
scale . asc _setType ( controls . combo . getValue ( ) ) ;
scale . asc _setVal ( controls . range . getValue ( ) ) ;
scales . push ( scale ) ;
colors . push ( Common . Utils . ThemeColor . getRgbColor ( controls . colorPicker . currentColor ) ) ;
}
2021-04-30 15:30:08 +00:00
this . scaleProps = new Asc . asc _CColorScale ( ) ;
2021-02-02 08:03:27 +00:00
this . scaleProps . asc _setColors ( colors ) ;
this . scaleProps . asc _setCFVOs ( scales ) ;
this . _changedProps . asc _setColorScaleOrDataBarOrIconSetRule ( this . scaleProps ) ;
2021-02-24 18:48:40 +00:00
} else if ( type == Asc . c _oAscCFType . dataBar ) {
2021-04-30 15:30:08 +00:00
this . barProps = new Asc . asc _CDataBar ( ) ;
2021-07-14 15:57:23 +00:00
this . barProps . asc _setInterfaceDefault ( ) ;
2021-02-24 18:48:40 +00:00
this . barProps . asc _setGradient ( this . cmbFill . getValue ( ) ) ;
this . barProps . asc _setColor ( Common . Utils . ThemeColor . getRgbColor ( this . btnPosFill . colorPicker . currentColor ) ) ;
var hasBorder = ! this . cmbBorder . getValue ( ) ;
if ( hasBorder ) {
this . barProps . asc _setBorderColor ( Common . Utils . ThemeColor . getRgbColor ( this . btnPosBorder . colorPicker . currentColor ) ) ;
} else
this . barProps . asc _setBorderColor ( null ) ;
this . barProps . asc _setDirection ( this . cmbBarDirection . getValue ( ) ) ;
this . _changedProps . asc _setColorScaleOrDataBarOrIconSetRule ( this . barProps ) ;
2021-02-02 08:03:27 +00:00
}
this . previewFormat ( ) ;
}
2020-04-16 15:43:16 +00:00
} ,
2020-04-20 10:49:38 +00:00
setControls : function ( category , rule ) {
2020-04-16 15:43:16 +00:00
var hasformat = this . $window . find ( '.hasformat' ) ;
2020-04-20 10:49:38 +00:00
hasformat . toggleClass ( 'hidden' , category >= 7 && category <= 10 ) ;
2021-03-19 09:14:25 +00:00
var focused ;
2020-04-20 10:49:38 +00:00
2020-04-20 12:40:16 +00:00
this . cmbRule . setVisible ( category < 7 ) ;
this . txtRange1 . setVisible ( category == 0 || category == 3 || category == 11 ) ;
2020-04-20 10:49:38 +00:00
this . txtRange2 . setVisible ( category == 0 && ( rule == Asc . c _oAscCFOperator . between || rule == Asc . c _oAscCFOperator . notBetween ) ) ;
2020-04-20 12:40:16 +00:00
this . cmbPercent . setVisible ( category == 1 ) ;
this . numRank . setVisible ( category == 1 ) ;
2021-03-11 17:52:32 +00:00
this . txtRange1 . cmpEl . width ( category == 11 ? 310 : 150 ) ;
2020-04-24 11:19:22 +00:00
if ( category == 7 || category == 8 ) {
2021-03-12 14:00:15 +00:00
this . renderScalesPanel ( ) ;
2020-04-24 11:19:22 +00:00
this . scaleControls [ 1 ] . combo . setVisible ( category == 8 ) ;
this . scaleControls [ 1 ] . range . setVisible ( category == 8 ) ;
this . scaleControls [ 1 ] . color . setVisible ( category == 8 ) ;
this . lblMidScale . toggleClass ( 'hidden' , category == 7 ) ;
}
2021-03-12 14:00:15 +00:00
this . $window . find ( '.scale' ) . toggleClass ( 'hidden' , category < 7 || category > 8 ) ;
2020-04-27 19:17:43 +00:00
2021-03-12 14:00:15 +00:00
( category == 9 ) && this . renderDataBarPanel ( ) ;
( category == 10 ) && this . renderIconsPanel ( ) ;
2020-04-27 19:17:43 +00:00
this . $window . find ( '.databar' ) . toggleClass ( 'hidden' , category !== 9 ) ;
2021-03-03 11:05:31 +00:00
this . $window . find ( '.iconset' ) . toggleClass ( 'hidden' , category !== 10 ) ;
2021-03-19 09:14:25 +00:00
if ( category < 7 )
focused = this . cmbRule ;
else if ( category == 7 || category == 8 ) {
focused = this . scaleControls [ 0 ] . combo ;
} else if ( category == 9 ) {
focused = this . barControls [ 0 ] . combo ;
} else if ( category == 10 ) {
focused = this . iconsControls [ this . iconsControls . length - 1 ] . cmbOperator ;
}
focused && _ . delay ( function ( ) {
focused . focus ( ) ;
} , 50 ) ;
2020-04-16 15:43:16 +00:00
} ,
onSelectData : function ( cmp ) {
var me = this ;
if ( me . api ) {
var handlerDlg = function ( dlg , result ) {
if ( result == 'ok' ) {
cmp . setValue ( dlg . getSettings ( ) ) ;
cmp . checkValidate ( ) ;
}
} ;
var win = new SSE . Views . CellRangeDialog ( {
handler : handlerDlg
} ) . on ( 'close' , function ( ) {
me . show ( ) ;
} ) ;
var xy = me . $window . offset ( ) ;
me . hide ( ) ;
win . show ( xy . left + 160 , xy . top + 125 ) ;
win . setSettings ( {
api : me . api ,
range : ( ! _ . isEmpty ( cmp . getValue ( ) ) && ( cmp . checkValidate ( ) == true ) ) ? cmp . getValue ( ) : '' ,
2021-03-10 16:53:38 +00:00
type : Asc . c _oAscSelectionDialogType . ConditionalFormattingRule ,
validation : function ( ) { return true ; }
2020-04-16 15:43:16 +00:00
} ) ;
}
} ,
2021-03-15 18:58:40 +00:00
onFormatsSelect : function ( menu , item ) {
2021-04-30 15:33:33 +00:00
var xfs = new Asc . asc _CellXfs ( ) ;
2021-03-15 18:58:40 +00:00
var settings = item . options . presetSettings ;
settings && settings . fontColor && xfs . asc _setFontColor ( Common . Utils . ThemeColor . getRgbColor ( settings . fontColor ) ) ;
settings && settings . fillColor && xfs . asc _setFillColor ( Common . Utils . ThemeColor . getRgbColor ( settings . fillColor ) ) ;
if ( settings && settings . borderColor ) {
2021-03-11 11:54:07 +00:00
var new _borders = [ ] ,
bordersWidth = Asc . c _oAscBorderStyles . Thin ,
2021-03-15 18:58:40 +00:00
bordersColor = Common . Utils . ThemeColor . getRgbColor ( settings . borderColor ) ;
2021-03-11 11:54:07 +00:00
new _borders [ Asc . c _oAscBorderOptions . Left ] = new Asc . asc _CBorder ( bordersWidth , bordersColor ) ;
new _borders [ Asc . c _oAscBorderOptions . Top ] = new Asc . asc _CBorder ( bordersWidth , bordersColor ) ;
new _borders [ Asc . c _oAscBorderOptions . Right ] = new Asc . asc _CBorder ( bordersWidth , bordersColor ) ;
new _borders [ Asc . c _oAscBorderOptions . Bottom ] = new Asc . asc _CBorder ( bordersWidth , bordersColor ) ;
xfs . asc _setBorder ( new _borders ) ;
}
this . xfsFormat = xfs ;
this . _changedProps && this . _changedProps . asc _setDxf ( xfs ) ;
this . fillXfsFormatInfo ( xfs ) ;
this . previewFormat ( ) ;
} ,
2021-03-11 16:19:58 +00:00
clearFormat : function ( ) {
this . xfsFormat = null ;
this . _changedProps && this . _changedProps . asc _setDxf ( null ) ;
2021-04-30 15:33:33 +00:00
this . fillXfsFormatInfo ( new Asc . asc _CellXfs ( ) ) ;
2021-03-11 16:19:58 +00:00
this . previewFormat ( ) ;
} ,
2021-01-26 15:50:59 +00:00
onBoldClick : function ( ) {
2021-04-30 15:33:33 +00:00
! this . xfsFormat && ( this . xfsFormat = new Asc . asc _CellXfs ( ) ) ;
2021-01-26 15:50:59 +00:00
this . xfsFormat . asc _setFontBold ( this . btnBold . isActive ( ) ) ;
2021-01-28 18:56:57 +00:00
this . previewFormat ( ) ;
2021-01-26 15:50:59 +00:00
} ,
onItalicClick : function ( ) {
2021-04-30 15:33:33 +00:00
! this . xfsFormat && ( this . xfsFormat = new Asc . asc _CellXfs ( ) ) ;
2021-01-26 15:50:59 +00:00
this . xfsFormat . asc _setFontItalic ( this . btnItalic . isActive ( ) ) ;
2021-01-28 18:56:57 +00:00
this . previewFormat ( ) ;
2021-01-26 15:50:59 +00:00
} ,
onUnderlineClick : function ( ) {
2021-04-30 15:33:33 +00:00
! this . xfsFormat && ( this . xfsFormat = new Asc . asc _CellXfs ( ) ) ;
2021-01-26 15:50:59 +00:00
this . xfsFormat . asc _setFontUnderline ( this . btnUnderline . isActive ( ) ) ;
2021-01-28 18:56:57 +00:00
this . previewFormat ( ) ;
2021-01-26 15:50:59 +00:00
} ,
onStrikeoutClick : function ( ) {
2021-04-30 15:33:33 +00:00
! this . xfsFormat && ( this . xfsFormat = new Asc . asc _CellXfs ( ) ) ;
2021-01-26 15:50:59 +00:00
this . xfsFormat . asc _setFontStrikeout ( this . btnStrikeout . isActive ( ) ) ;
2021-01-28 18:56:57 +00:00
this . previewFormat ( ) ;
2021-01-26 15:50:59 +00:00
} ,
2020-05-19 16:57:24 +00:00
onBordersWidth : function ( menu , item , state ) {
if ( state ) {
this . btnBorders . options . borderswidth = item . value ;
}
} ,
onBordersColor : function ( picker , color ) {
$ ( '#format-rules-borders-border-color .menu-item-icon' ) . css ( 'border-color' , '#' + ( ( typeof ( color ) == 'object' ) ? color . color : color ) ) ;
this . mnuBorderColor . onUnHoverItem ( ) ;
this . btnBorders . options . borderscolor = Common . Utils . ThemeColor . getRgbColor ( color ) ;
} ,
2021-01-26 15:50:59 +00:00
onBorders : function ( btn ) {
var menuItem ;
_ . each ( btn . menu . items , function ( item ) {
if ( btn . options . borderId == item . options . borderId ) {
menuItem = item ;
return false ;
}
} ) ;
if ( menuItem ) {
this . onBordersMenu ( btn . menu , menuItem ) ;
}
} ,
onBordersMenu : function ( menu , item ) {
var me = this ;
if ( ! _ . isUndefined ( item . options . borderId ) ) {
var btnBorders = me . btnBorders ,
new _borders = [ ] ,
bordersWidth = btnBorders . options . borderswidth ,
bordersColor = btnBorders . options . borderscolor ;
if ( btnBorders . rendered ) {
btnBorders . $icon . removeClass ( btnBorders . options . icls ) . addClass ( item . options . icls ) ;
btnBorders . options . icls = item . options . icls ;
}
btnBorders . options . borderId = item . options . borderId ;
if ( item . options . borderId == 'inner' ) {
new _borders [ Asc . c _oAscBorderOptions . InnerV ] = new Asc . asc _CBorder ( bordersWidth , bordersColor ) ;
new _borders [ Asc . c _oAscBorderOptions . InnerH ] = new Asc . asc _CBorder ( bordersWidth , bordersColor ) ;
} else if ( item . options . borderId == 'all' ) {
new _borders [ Asc . c _oAscBorderOptions . InnerV ] = new Asc . asc _CBorder ( bordersWidth , bordersColor ) ;
new _borders [ Asc . c _oAscBorderOptions . InnerH ] = new Asc . asc _CBorder ( bordersWidth , bordersColor ) ;
new _borders [ Asc . c _oAscBorderOptions . Left ] = new Asc . asc _CBorder ( bordersWidth , bordersColor ) ;
new _borders [ Asc . c _oAscBorderOptions . Top ] = new Asc . asc _CBorder ( bordersWidth , bordersColor ) ;
new _borders [ Asc . c _oAscBorderOptions . Right ] = new Asc . asc _CBorder ( bordersWidth , bordersColor ) ;
new _borders [ Asc . c _oAscBorderOptions . Bottom ] = new Asc . asc _CBorder ( bordersWidth , bordersColor ) ;
} else if ( item . options . borderId == 'outer' ) {
new _borders [ Asc . c _oAscBorderOptions . Left ] = new Asc . asc _CBorder ( bordersWidth , bordersColor ) ;
new _borders [ Asc . c _oAscBorderOptions . Top ] = new Asc . asc _CBorder ( bordersWidth , bordersColor ) ;
new _borders [ Asc . c _oAscBorderOptions . Right ] = new Asc . asc _CBorder ( bordersWidth , bordersColor ) ;
new _borders [ Asc . c _oAscBorderOptions . Bottom ] = new Asc . asc _CBorder ( bordersWidth , bordersColor ) ;
} else if ( item . options . borderId != 'none' ) {
new _borders [ item . options . borderId ] = new Asc . asc _CBorder ( bordersWidth , bordersColor ) ;
}
2021-04-30 15:33:33 +00:00
! this . xfsFormat && ( this . xfsFormat = new Asc . asc _CellXfs ( ) ) ;
2021-01-26 15:50:59 +00:00
this . xfsFormat . asc _setBorder ( new _borders ) ;
2021-01-28 18:56:57 +00:00
this . previewFormat ( ) ;
2021-01-26 15:50:59 +00:00
}
} ,
2021-07-11 09:03:01 +00:00
onFormatTextColorSelect : function ( btn , color , fromBtn ) {
2021-01-26 15:50:59 +00:00
this . btnTextColor . currentColor = color ;
2021-07-11 09:03:01 +00:00
this . mnuTextColorPicker . currentColor = color ;
2021-01-26 15:50:59 +00:00
2021-04-30 15:33:33 +00:00
! this . xfsFormat && ( this . xfsFormat = new Asc . asc _CellXfs ( ) ) ;
2021-01-26 15:50:59 +00:00
this . xfsFormat . asc _setFontColor ( Common . Utils . ThemeColor . getRgbColor ( this . mnuTextColorPicker . currentColor ) ) ;
2021-01-28 18:56:57 +00:00
this . previewFormat ( ) ;
2021-01-26 15:50:59 +00:00
} ,
2021-07-11 09:03:01 +00:00
onFormatFillColorSelect : function ( btn , color , fromBtn ) {
2021-01-27 21:57:04 +00:00
this . btnFillColor . currentColor = color ;
2021-07-11 09:03:01 +00:00
this . mnuFillColorPicker . currentColor = color ;
2021-01-26 15:50:59 +00:00
2021-04-30 15:33:33 +00:00
! this . xfsFormat && ( this . xfsFormat = new Asc . asc _CellXfs ( ) ) ;
2021-01-28 11:00:40 +00:00
this . xfsFormat . asc _setFillColor ( this . mnuFillColorPicker . currentColor == 'transparent' ? null : Common . Utils . ThemeColor . getRgbColor ( this . mnuFillColorPicker . currentColor ) ) ;
2021-01-28 18:56:57 +00:00
this . previewFormat ( ) ;
2021-01-26 15:50:59 +00:00
} ,
onNumberFormatSelect : function ( combo , record ) {
2021-04-30 15:33:33 +00:00
! this . xfsFormat && ( this . xfsFormat = new Asc . asc _CellXfs ( ) ) ;
2021-01-26 16:30:37 +00:00
this . xfsFormat . asc _setNumFormatInfo ( record . format ) ;
2021-01-28 18:56:57 +00:00
this . previewFormat ( ) ;
} ,
previewFormat : function ( ) {
2021-02-02 08:03:27 +00:00
if ( this . _changedProps ) {
var type = this . _changedProps . asc _getType ( ) ;
2021-02-24 15:49:05 +00:00
if ( type == Asc . c _oAscCFType . containsText || type == Asc . c _oAscCFType . notContainsText || type == Asc . c _oAscCFType . beginsWith ||
type == Asc . c _oAscCFType . endsWith || type == Asc . c _oAscCFType . containsBlanks || type == Asc . c _oAscCFType . notContainsBlanks ||
type == Asc . c _oAscCFType . duplicateValues || type == Asc . c _oAscCFType . uniqueValues ||
type == Asc . c _oAscCFType . containsErrors || type == Asc . c _oAscCFType . notContainsErrors ||
2021-02-02 08:03:27 +00:00
type == Asc . c _oAscCFType . timePeriod || type == Asc . c _oAscCFType . aboveAverage ||
type == Asc . c _oAscCFType . top10 || type == Asc . c _oAscCFType . cellIs || type == Asc . c _oAscCFType . expression ) {
this . xfsFormat && ! this . _changedProps . asc _getDxf ( ) && this . _changedProps . asc _setDxf ( this . xfsFormat ) ;
this . _changedProps . asc _getPreview ( 'format-rules-edit-preview-format' , this . xfsFormat ? Common . define . conditionalData . exampleText : Common . define . conditionalData . noFormatText ) ;
} else if ( type == Asc . c _oAscCFType . colorScale ) {
this . _changedProps . asc _getPreview ( 'format-rules-edit-preview-scale' , '' ) ;
} else if ( type == Asc . c _oAscCFType . dataBar ) {
this . _changedProps . asc _getPreview ( 'format-rules-edit-preview-databar' , '' ) ;
}
}
2020-05-19 19:13:07 +00:00
} ,
2020-04-16 15:43:16 +00:00
updateThemeColors : function ( ) {
2021-03-12 14:00:15 +00:00
if ( this . panels . scale . rendered && ! this . panels . scale . initColors ) {
for ( var i = 0 ; i < this . scaleControls . length ; i ++ ) {
var btn = this . scaleControls [ i ] . color ;
btn . setMenu ( ) ;
var colorPicker = btn . getPicker ( ) ;
colorPicker . options . type = i ;
colorPicker . updateColors ( Common . Utils . ThemeColor . getEffectColors ( ) , Common . Utils . ThemeColor . getStandartColors ( ) ) ;
colorPicker . currentColor = ( i == 0 ) ? 'FFC000' : ( i == 1 ? 'FFFF00' : '92D050' ) ;
colorPicker . select ( colorPicker . currentColor , true ) ;
btn . setColor ( colorPicker . currentColor ) ;
this . scaleControls [ i ] . colorPicker = colorPicker ;
btn . on ( 'color:select' , _ . bind ( this . onScaleColorsSelect , this ) ) ;
}
this . panels . scale . initColors = true ;
2020-04-24 11:19:22 +00:00
}
2020-04-27 19:17:43 +00:00
2021-03-12 14:00:15 +00:00
if ( this . panels . databar . rendered && ! this . panels . databar . initColors ) {
var initColor = function ( btn ) {
btn . setMenu ( ) ;
var colorPicker = btn . getPicker ( ) ;
colorPicker . updateColors ( Common . Utils . ThemeColor . getEffectColors ( ) , Common . Utils . ThemeColor . getStandartColors ( ) ) ;
btn . colorPicker = colorPicker ;
colorPicker . currentColor = btn . color ;
colorPicker . select ( colorPicker . currentColor , true ) ;
} ;
initColor ( this . btnPosFill ) ;
this . btnPosFill . on ( 'color:select' , _ . bind ( this . onBarColorsSelect , this , 'pos' ) ) ;
initColor ( this . btnNegFill ) ;
this . btnNegFill . on ( 'color:select' , _ . bind ( this . onBarColorsSelect , this , '' ) ) ;
initColor ( this . btnPosBorder ) ;
this . btnPosBorder . on ( 'color:select' , _ . bind ( this . onBarColorsSelect , this , 'pos-border' ) ) ;
initColor ( this . btnNegBorder ) ;
this . btnNegBorder . on ( 'color:select' , _ . bind ( this . onBarColorsSelect , this , '' ) ) ;
initColor ( this . btnAxisColor ) ;
this . btnAxisColor . on ( 'color:select' , _ . bind ( this . onBarColorsSelect , this , '' ) ) ;
this . panels . databar . initColors = true ;
}
if ( this . panels . format . rendered && ! this . panels . format . initColors ) {
this . mnuTextColorPicker . updateColors ( Common . Utils . ThemeColor . getEffectColors ( ) , Common . Utils . ThemeColor . getStandartColors ( ) ) ;
this . mnuFillColorPicker . updateColors ( Common . Utils . ThemeColor . getEffectColors ( ) , Common . Utils . ThemeColor . getStandartColors ( ) ) ;
this . mnuBorderColorPicker . updateColors ( Common . Utils . ThemeColor . getEffectColors ( ) , Common . Utils . ThemeColor . getStandartColors ( ) ) ;
this . panels . format . initColors = true ;
}
2020-04-16 15:43:16 +00:00
} ,
2021-02-02 08:03:27 +00:00
onScaleColorsSelect : function ( picker , color ) {
2021-02-02 14:01:24 +00:00
picker . colorPicker . currentColor = color ;
2021-02-02 08:03:27 +00:00
if ( this . scaleProps ) {
var colors = this . scaleProps . asc _getColors ( ) ;
2021-02-02 14:01:24 +00:00
colors [ Math . min ( picker . options . type , colors . length - 1 ) ] = Common . Utils . ThemeColor . getRgbColor ( picker . colorPicker . currentColor ) ;
2021-02-02 08:03:27 +00:00
this . scaleProps . asc _setColors ( colors ) ;
this . previewFormat ( ) ;
}
} ,
2021-02-24 18:48:40 +00:00
onBarColorsSelect : function ( type , picker , color ) {
picker . colorPicker . currentColor = color ;
if ( this . barProps && ( type == 'pos' || type == 'pos-border' ) ) {
if ( type == 'pos' )
this . barProps . asc _setColor ( Common . Utils . ThemeColor . getRgbColor ( color ) ) ;
else
this . barProps . asc _setBorderColor ( Common . Utils . ThemeColor . getRgbColor ( color ) ) ;
this . previewFormat ( ) ;
}
} ,
2021-02-24 19:39:04 +00:00
setDefComboValue : function ( index , type , range ) {
var category = this . cmbCategory . getValue ( ) ,
value = '' ;
switch ( type ) {
case Asc . c _oAscCfvoType . Number :
value = 0 ;
break ;
case Asc . c _oAscCfvoType . Percent :
value = ( index == 0 ) ? 0 : ( index == 1 && category == 8 ? 50 : 100 ) ;
break ;
case Asc . c _oAscCfvoType . Percentile :
value = ( index == 0 ) ? 10 : ( index == 1 && category == 8 ? 50 : 90 ) ;
break ;
}
range . setValue ( value ) ;
2021-02-24 18:48:40 +00:00
} ,
2021-03-03 11:05:31 +00:00
fillIconsControls : function ( iconSet , values , icons ) {
2021-03-03 22:11:57 +00:00
var me = this ;
2021-03-03 17:58:06 +00:00
this . iconsProps . iconsSet = iconSet ;
this . iconsProps . iconsLength = values . length ;
this . $window . find ( '.icons-5' ) . toggleClass ( 'hidden' , this . iconsProps . iconsLength < 5 ) ;
this . $window . find ( '.icons-4' ) . toggleClass ( 'hidden' , this . iconsProps . iconsLength < 4 ) ;
2021-03-03 11:05:31 +00:00
var arr = this . iconsControls ;
2021-03-12 14:00:15 +00:00
( arr . length < this . iconsProps . iconsLength ) && this . addNewIconsLine ( ) ;
( arr . length < this . iconsProps . iconsLength ) && this . addNewIconsLine ( ) ;
2021-03-03 11:05:31 +00:00
for ( var i = 0 ; i < values . length ; i ++ ) {
2021-03-03 19:50:19 +00:00
var controls = arr [ i ] ;
controls . cmbType . setValue ( values [ i ] . asc _getType ( ) ) ;
controls . value . setValue ( values [ i ] . asc _getVal ( ) || '' ) ;
controls . cmbOperator . setValue ( values [ i ] . asc _getGte ( ) ) ;
2021-03-03 11:05:31 +00:00
}
2021-03-03 22:11:57 +00:00
var iconsIndexes = [ ] ;
2021-03-03 17:58:06 +00:00
if ( icons && icons . length > 0 ) {
this . cmbIconsPresets . setValue ( this . textCustom ) ;
2021-03-03 22:11:57 +00:00
_ . each ( icons , function ( item ) {
2021-07-13 19:08:32 +00:00
if ( item . asc _getIconSet ( ) == Asc . EIconSetType . NoIcons ) {
iconsIndexes . push ( - 1 ) ;
} else
iconsIndexes . push ( me . collectionPresets . at ( item . asc _getIconSet ( ) ) . get ( 'icons' ) [ item . asc _getIconId ( ) ] ) ;
2021-03-03 22:11:57 +00:00
} ) ;
2021-03-03 17:58:06 +00:00
} else {
this . cmbIconsPresets . setValue ( iconSet ) ;
2021-03-03 22:11:57 +00:00
iconsIndexes = me . collectionPresets . at ( iconSet ) . get ( 'icons' ) ;
2021-03-03 17:58:06 +00:00
}
var isReverse = this . iconsProps . isReverse ;
2021-03-03 22:11:57 +00:00
var len = iconsIndexes . length ;
for ( var i = 0 ; i < iconsIndexes . length ; i ++ ) {
2021-03-03 17:58:06 +00:00
var controls = arr [ isReverse ? len - i - 1 : i ] ;
2021-07-13 19:08:32 +00:00
var rec = ( iconsIndexes [ i ] == - 1 ) ? null : controls . pickerIcons . store . findWhere ( { value : iconsIndexes [ i ] - 1 } ) ;
rec ? controls . pickerIcons . selectRecord ( rec , true ) : controls . pickerIcons . deselectAll ( true ) ;
controls . itemNoIcons . setChecked ( ! rec , true ) ;
2021-03-03 17:58:06 +00:00
this . selectIconItem ( controls . cmbIcons , rec ) ;
}
this . fillIconsLabels ( ) ;
} ,
fillIconsLabels : function ( ) {
var arr = this . iconsControls ,
len = this . iconsProps . iconsLength ,
regstr = new RegExp ( '^\s*[0-9]+[,.]?[0-9]*\s*$' ) ;
var val = arr [ 1 ] . value . getValue ( ) ;
arr [ 0 ] . label . text ( Common . Utils . String . format ( this . textIconLabelFirst , arr [ 1 ] . cmbOperator . getSelectedRecord ( ) . prevOp , regstr . test ( val ) ? parseFloat ( val ) : this . textFormula ) ) ;
for ( var i = 1 ; i < len - 1 ; i ++ ) {
val = arr [ i + 1 ] . value . getValue ( ) ;
arr [ i ] . label . text ( Common . Utils . String . format ( this . textIconLabel , arr [ i + 1 ] . cmbOperator . getSelectedRecord ( ) . prevOp , regstr . test ( val ) ? parseFloat ( val ) : this . textFormula ) ) ;
}
arr [ len - 1 ] . label . text ( this . textIconLabelLast ) ;
} ,
reverseIconsControls : function ( ) {
var arr = this . iconsControls ,
len = this . iconsProps . iconsLength ;
for ( var i = 0 ; i < len / 2 ; i ++ ) {
var controls1 = arr [ i ] ,
controls2 = arr [ len - i - 1 ] ;
2021-07-13 19:08:32 +00:00
var icon1 = controls1 . itemNoIcons . isChecked ( ) ? - 1 : controls1 . pickerIcons . getSelectedRec ( ) . get ( 'value' ) ,
icon2 = controls2 . itemNoIcons . isChecked ( ) ? - 1 : controls2 . pickerIcons . getSelectedRec ( ) . get ( 'value' ) ;
2021-03-03 17:58:06 +00:00
var rec = controls1 . pickerIcons . store . findWhere ( { value : icon2 } ) ;
2021-07-13 19:08:32 +00:00
rec ? controls1 . pickerIcons . selectRecord ( rec , true ) : controls1 . pickerIcons . deselectAll ( true ) ;
controls1 . itemNoIcons . setChecked ( ! rec , true ) ;
2021-03-03 17:58:06 +00:00
this . selectIconItem ( controls1 . cmbIcons , rec ) ;
rec = controls2 . pickerIcons . store . findWhere ( { value : icon1 } ) ;
2021-07-13 19:08:32 +00:00
rec ? controls2 . pickerIcons . selectRecord ( rec , true ) : controls2 . pickerIcons . deselectAll ( true ) ;
controls2 . itemNoIcons . setChecked ( ! rec , true ) ;
2021-03-03 17:58:06 +00:00
this . selectIconItem ( controls2 . cmbIcons , rec ) ;
}
2021-03-03 11:05:31 +00:00
} ,
2021-07-13 19:08:32 +00:00
onSelectIcon : function ( combo , noIconItem , picker , view , record ) {
2021-03-03 11:05:31 +00:00
this . selectIconItem ( combo , record ) ;
2021-07-13 19:08:32 +00:00
noIconItem . setChecked ( false , true ) ;
this . cmbIconsPresets . setValue ( this . textCustom ) ;
} ,
onSelectNoIcon : function ( combo , picker , item , state ) {
if ( ! state ) return ;
this . selectIconItem ( combo ) ;
picker . deselectAll ( true ) ;
2021-03-10 09:14:44 +00:00
this . cmbIconsPresets . setValue ( this . textCustom ) ;
2021-03-03 11:05:31 +00:00
} ,
selectIconItem : function ( combo , record ) {
2021-07-13 19:08:32 +00:00
var formcontrol = $ ( combo . el ) . find ( '.form-control > div' ) ;
2021-03-03 17:58:06 +00:00
formcontrol . css ( 'background-image' , record ? 'url(' + record . get ( 'imgUrl' ) + ')' : '' ) ;
2021-07-13 19:08:32 +00:00
formcontrol . text ( record ? '' : this . txtNoCellIcon ) ;
2021-03-03 11:05:31 +00:00
} ,
2021-03-10 16:53:38 +00:00
isRangeValid : function ( ) {
var rec = this . ruleStore . findWhere ( { index : this . cmbCategory . getValue ( ) } ) ,
res ;
if ( rec ) {
var type = rec . get ( 'type' ) ,
arr = [ ] ,
msg ,
focusedInput ;
switch ( type ) {
case Asc . c _oAscCFType . containsText :
case Asc . c _oAscCFType . expression :
if ( this . txtRange1 . getValue ( ) === '' )
msg = ( type == Asc . c _oAscCFType . containsText ? this . textEmptyText : this . textEmptyFormulaExt ) ;
else {
res = this . api . asc _isValidDataRefCf ( type , [ [ this . txtRange1 . getValue ( ) ] ] ) ;
res && ( res = res [ 0 ] ) ;
}
( res || msg ) && ( focusedInput = this . txtRange1 ) ;
break ;
case Asc . c _oAscCFType . cellIs :
var subtype = this . cmbRule . getValue ( ) ;
if ( this . txtRange1 . getValue ( ) === '' ) {
msg = this . textEmptyValue ;
focusedInput = this . txtRange1 ;
} else if ( ( subtype == Asc . c _oAscCFOperator . notBetween || subtype == Asc . c _oAscCFOperator . between ) && ( this . txtRange2 . getValue ( ) === '' ) ) {
msg = this . textEmptyValue ;
focusedInput = this . txtRange2 ;
} else {
arr = [ [ this . txtRange1 . getValue ( ) ] ] ;
if ( subtype == Asc . c _oAscCFOperator . notBetween || subtype == Asc . c _oAscCFOperator . between )
arr . push ( [ this . txtRange2 . getValue ( ) ] ) ;
res = this . api . asc _isValidDataRefCf ( type , arr ) ;
if ( res ) {
focusedInput = res [ 1 ] ? this . txtRange2 : this . txtRange1 ;
res = res [ 0 ] ;
}
}
break ;
case Asc . c _oAscCFType . top10 :
var isPercent = ! ! this . cmbPercent . getValue ( ) ;
res = this . api . asc _isValidDataRefCf ( type , [ [ this . numRank . getNumberValue ( ) , isPercent ] ] ) ;
res && ( res = res [ 0 ] ) ;
if ( res == Asc . c _oAscError . ID . ErrorTop10Between )
msg = Common . Utils . String . format ( this . textErrorTop10Between , isPercent ? 0 : 1 , isPercent ? 100 : 1000 ) ;
break ;
case Asc . c _oAscCFType . colorScale :
var scalesCount = rec . get ( 'num' ) ;
var scaleControls = ( scalesCount == 2 ) ? [ this . scaleControls [ 0 ] , this . scaleControls [ 2 ] ] : this . scaleControls ;
for ( var i = 0 ; i < scalesCount ; i ++ ) {
if ( ! scaleControls [ i ] . range . isDisabled ( ) && scaleControls [ i ] . range . getValue ( ) === '' ) {
msg = ( scaleControls [ i ] . combo . getValue ( ) == Asc . c _oAscCfvoType . Formula ) ? this . textEmptyFormula : this . textEmptyText ;
focusedInput = scaleControls [ i ] . range ;
break ;
}
}
if ( ! msg ) {
for ( var i = 0 ; i < scalesCount ; i ++ ) {
arr . push ( [ scaleControls [ i ] . range . getValue ( ) , scaleControls [ i ] . combo . getValue ( ) ] ) ;
}
res = this . api . asc _isValidDataRefCf ( type , arr ) ;
if ( res ) {
var index = res [ 1 ] ;
focusedInput = scaleControls [ index ] . range ;
res = res [ 0 ] ;
if ( res == Asc . c _oAscError . ID . ValueMustBeGreaterThen ) {
msg = Common . Utils . String . format ( this . textErrorGreater , index == 0 ? this . textMinpoint : ( index == scalesCount - 1 ? this . textMaxpoint : this . textMidpoint ) ,
( index == scalesCount - 1 && scalesCount == 3 ) ? this . textMidpoint : this . textMinpoint ) ;
} else if ( res == Asc . c _oAscError . ID . NotValidPercentage )
msg = Common . Utils . String . format ( this . textNotValidPercentageExt , index == 0 ? this . textMinpoint : ( index == scalesCount - 1 ? this . textMaxpoint : this . textMidpoint ) ) ;
else if ( res == Asc . c _oAscError . ID . NotValidPercentile )
msg = Common . Utils . String . format ( this . textNotValidPercentileExt , index == 0 ? this . textMinpoint : ( index == scalesCount - 1 ? this . textMaxpoint : this . textMidpoint ) ) ;
}
}
break ;
case Asc . c _oAscCFType . dataBar :
var barControls = this . barControls ;
for ( var i = 0 ; i < barControls . length ; i ++ ) {
if ( ! barControls [ i ] . range . isDisabled ( ) && barControls [ i ] . range . getValue ( ) === '' ) {
msg = ( barControls [ i ] . combo . getValue ( ) == Asc . c _oAscCfvoType . Formula ) ? this . textEmptyFormula : this . textEmptyText ;
focusedInput = barControls [ i ] . range ;
break ;
}
}
if ( ! msg ) {
for ( var i = 0 ; i < barControls . length ; i ++ ) {
arr . push ( [ barControls [ i ] . range . getValue ( ) , barControls [ i ] . combo . getValue ( ) ] ) ;
}
res = this . api . asc _isValidDataRefCf ( type , arr ) ;
if ( res ) {
var index = res [ 1 ] ;
focusedInput = barControls [ index ] . range ;
res = res [ 0 ] ;
if ( res == Asc . c _oAscError . ID . NotValidPercentage )
msg = Common . Utils . String . format ( this . textNotValidPercentageExt , index ? this . textLongBar : this . textShortBar ) ;
else if ( res == Asc . c _oAscError . ID . NotValidPercentile )
msg = Common . Utils . String . format ( this . textNotValidPercentileExt , index ? this . textLongBar : this . textShortBar ) ;
}
}
break ;
case Asc . c _oAscCFType . iconSet :
var iconsControls = this . iconsControls ;
for ( var i = 0 ; i < this . iconsProps . iconsLength ; i ++ ) {
if ( ! iconsControls [ i ] . value . isDisabled ( ) && iconsControls [ i ] . value . getValue ( ) === '' ) {
msg = ( iconsControls [ i ] . cmbType . getValue ( ) == Asc . c _oAscCfvoType . Formula ) ? this . textEmptyFormula : this . textEmptyText ;
focusedInput = iconsControls [ i ] . value ;
break ;
}
}
if ( ! msg ) {
for ( var i = 0 ; i < this . iconsProps . iconsLength ; i ++ ) {
arr . push ( [ iconsControls [ i ] . value . getValue ( ) , iconsControls [ i ] . cmbType . getValue ( ) ] ) ;
}
res = this . api . asc _isValidDataRefCf ( type , arr ) ;
if ( res ) {
focusedInput = iconsControls [ res [ 1 ] ] . value ;
res = res [ 0 ] ;
}
}
break ;
}
if ( ! msg && res ) {
switch ( res ) {
case Asc . c _oAscError . ID . NotValidPercentile :
msg = this . textNotValidPercentile ;
break ;
case Asc . c _oAscError . ID . NotValidPercentage :
msg = this . textNotValidPercentage ;
break ;
case Asc . c _oAscError . ID . CannotAddConditionalFormatting :
msg = this . textCannotAddCF ;
break ;
case Asc . c _oAscError . ID . NotSingleReferenceCannotUsed :
msg = this . textSingleRef ;
break ;
case Asc . c _oAscError . ID . CannotUseRelativeReference :
msg = this . textRelativeRef ;
break ;
case Asc . c _oAscError . ID . IconDataRangesOverlap :
msg = this . textIconsOverlap ;
break ;
default :
msg = this . textInvalid ;
}
}
msg && Common . UI . warning ( {
msg : msg ,
maxwidth : 600 ,
callback : function ( btn ) {
focusedInput && focusedInput . focus ( ) ;
}
} ) ;
return ( ! msg ) ;
}
} ,
2020-04-16 15:43:16 +00:00
onPrimary : function ( ) {
this . onDlgBtnClick ( 'ok' ) ;
return false ;
} ,
onDlgBtnClick : function ( event ) {
var me = this ;
var state = ( typeof ( event ) == 'object' ) ? event . currentTarget . attributes [ 'result' ] . value : event ;
if ( state == 'ok' ) {
2021-03-10 16:53:38 +00:00
if ( ! this . isRangeValid ( ) )
return ;
2020-04-16 15:43:16 +00:00
this . handler && this . handler . call ( this , state , ( state == 'ok' ) ? this . getSettings ( ) : undefined ) ;
}
this . close ( ) ;
} ,
txtTitleNew : 'New Formatting Rule' ,
txtTitleEdit : 'Edit Formatting Rule' ,
textSelectData : 'Select Data' ,
textApply : 'Apply to Range' ,
textRule : 'Rule' ,
txtEmpty : 'This field is required' ,
textInvalidRange : 'ERROR! Invalid cells range' ,
notcriticalErrorTitle : 'Warning' ,
textFormat : 'Format' ,
textCustom : 'Custom' ,
textBold : 'Bold' ,
textItalic : 'Italic' ,
textUnderline : 'Underline' ,
textStrikeout : 'Strikeout' ,
textSuperscript : 'Superscript' ,
textSubscript : 'Subscript' ,
textColor : 'Text color' ,
2020-04-24 11:19:22 +00:00
fillColor : 'Background color' ,
textMinpoint : 'Minpoint' ,
textMidpoint : 'Midpoint' ,
2020-04-27 19:17:43 +00:00
textMaxpoint : 'Maxpoint' ,
textMinimum : 'Minimum' ,
textMaximum : 'Maximum' ,
2020-05-19 16:57:24 +00:00
textAppearance : 'Bar Appearance' ,
txtNumber : 'Number' ,
txtGeneral : 'General' ,
txtCurrency : 'Currency' ,
txtAccounting : 'Accounting' ,
txtDate : 'Date' ,
txtTime : 'Time' ,
txtPercentage : 'Percentage' ,
txtFraction : 'Fraction' ,
txtScientific : 'Scientific' ,
txtText : 'Text' ,
tipBorders : 'Borders' ,
textOutBorders : 'Outside Borders' ,
textAllBorders : 'All Borders' ,
textTopBorders : 'Top Borders' ,
textBottomBorders : 'Bottom Borders' ,
textLeftBorders : 'Left Borders' ,
textRightBorders : 'Right Borders' ,
textNoBorders : 'No Borders' ,
textInsideBorders : 'Inside Borders' ,
textMiddleBorders : 'Inside Horizontal Borders' ,
textCenterBorders : 'Inside Vertical Borders' ,
textDiagDownBorder : 'Diagonal Down Border' ,
textDiagUpBorder : 'Diagonal Up Border' ,
textBordersStyle : 'Border Style' ,
textBordersColor : 'Borders Color' ,
textNewColor : 'Add New Custom Color' ,
2021-01-26 15:50:59 +00:00
tipNumFormat : 'Number Format' ,
textPreview : 'Preview' ,
2021-01-28 18:38:00 +00:00
text2Scales : '2 Color scale' ,
text3Scales : '3 Color scale' ,
textPercent : 'Percent' ,
textFormula : 'Formula' ,
textPercentile : 'Percentile' ,
textAutomatic : 'Automatic' ,
textContext : 'Context' ,
textLeft2Right : 'Left to right' ,
textRight2Left : 'Right to left' ,
textNone : 'None' ,
textSolid : 'Solid' ,
textCellMidpoint : 'Cell midpoint' ,
2021-02-24 18:48:40 +00:00
textGradient : 'Gradient' ,
textFill : 'Fill' ,
textPositive : 'Positive' ,
textNegative : 'Negative' ,
textBorder : 'Border' ,
textBarDirection : 'Bar Direction' ,
textAxis : 'Axis' ,
textPosition : 'Position' ,
textShowBar : 'Show bar only' ,
2021-03-03 11:05:31 +00:00
textSameAs : 'Same as positive' ,
textIconStyle : 'Icon Style' ,
textReverse : 'Reverse Icons Order' ,
2021-03-03 17:58:06 +00:00
textShowIcon : 'Show icon only' ,
textIconLabelFirst : 'when {0} {1}' ,
textIconLabel : 'when {0} {1} and' ,
2021-03-10 16:53:38 +00:00
textIconLabelLast : 'when value is' ,
textEmptyText : 'Enter a value.' ,
textEmptyFormula : 'Enter a valid formula.' ,
textEmptyFormulaExt : 'The formula you entered does not evaluate to a number, date, time or string.' ,
textEmptyValue : 'The value you entered is not a valid number, date, time or string.' ,
textErrorTop10Between : 'Enter a number between {0} and {1}.' ,
textNotValidPercentage : 'One or more of the specified values is not a valid percentage.' ,
textNotValidPercentile : 'One or more of the specified values is not a valid percentile.' ,
textNotValidPercentageExt : 'The specified {0} value is not a valid percentage.' ,
textNotValidPercentileExt : 'The specified {0} value is not a valid percentile.' ,
textShortBar : 'shortest bar' ,
textLongBar : 'longest bar' ,
textCannotAddCF : 'Cannot add the conditional formatting.' ,
textIconsOverlap : 'One or more icon data ranges overlap.<br>Adjust icon data range values so that the ranges do not overlap.' ,
textSingleRef : 'This type of reference cannot be used in a conditional formatting formula.<br>Change the reference to a single cell, or use the reference with a worksheet function, such as =SUM(A1:B5).' ,
textRelativeRef : 'You cannot use relative references in conditional formatting criteria for color scales, data bars, and icon sets.' ,
textErrorGreater : 'The value for the {0} must be greater than the value for the {1}.' ,
2021-03-11 16:19:58 +00:00
textInvalid : 'Invalid data range.' ,
textClear : 'Clear' ,
2021-03-15 18:58:40 +00:00
textItem : 'Item' ,
2021-07-13 19:08:32 +00:00
textPresets : 'Presets' ,
txtNoCellIcon : 'No Icon'
2020-04-16 15:43:16 +00:00
} , SSE . Views . FormatRulesEditDlg || { } ) ) ;
} ) ;