2016-04-01 13:17:09 +00:00
/ *
*
2019-01-17 13:05:03 +00:00
* ( c ) Copyright Ascensio System SIA 2010 - 2019
2016-04-01 13:17:09 +00:00
*
* This program is a free software product . You can redistribute it and / or
* modify it under the terms of the GNU Affero General Public License ( AGPL )
* version 3 as published by the Free Software Foundation . In accordance with
* Section 7 ( a ) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non - infringement
* of any third - party rights .
*
* This program is distributed WITHOUT ANY WARRANTY ; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . For
* details , see the GNU AGPL at : http : //www.gnu.org/licenses/agpl-3.0.html
*
2019-01-17 13:00:34 +00:00
* You can contact Ascensio System SIA at 20 A - 12 Ernesta Birznieka - Upisha
* street , Riga , Latvia , EU , LV - 1050.
2016-04-01 13:17:09 +00:00
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices , as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7 ( b ) of the License you must retain the original Product
* logo when distributing the program . Pursuant to Section 7 ( e ) we decline to
* grant you any rights under trademark law for use of our trademarks .
*
* All the Product ' s GUI elements , including illustrations and icon sets , as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution - ShareAlike 4.0 International . See the License
* terms at http : //creativecommons.org/licenses/by-sa/4.0/legalcode
*
* /
2016-03-11 00:48:53 +00:00
/ * *
* Toolbar . js
*
* Created by Alexander Yuzhin on 3 / 31 / 14
2018-03-01 12:16:38 +00:00
* Copyright ( c ) 2018 Ascensio System SIA . All rights reserved .
2016-03-11 00:48:53 +00:00
*
* /
define ( [
'core' ,
'common/main/lib/component/Window' ,
'common/main/lib/view/CopyWarningDialog' ,
'common/main/lib/view/ImageFromUrlDialog' ,
2018-10-03 11:00:08 +00:00
'common/main/lib/view/SelectFileDlg' ,
2019-11-14 08:48:58 +00:00
'common/main/lib/view/SymbolTableDialog' ,
2020-10-15 11:09:23 +00:00
'common/main/lib/view/OptionsDialog' ,
2016-10-21 09:33:49 +00:00
'common/main/lib/util/define' ,
2022-05-30 17:46:20 +00:00
'common/main/lib/view/SearchBar' ,
2016-03-11 00:48:53 +00:00
'spreadsheeteditor/main/app/view/Toolbar' ,
'spreadsheeteditor/main/app/collection/TableTemplates' ,
2017-06-30 14:49:58 +00:00
'spreadsheeteditor/main/app/controller/PivotTable' ,
2016-03-11 00:48:53 +00:00
'spreadsheeteditor/main/app/view/HyperlinkSettingsDialog' ,
'spreadsheeteditor/main/app/view/TableOptionsDialog' ,
'spreadsheeteditor/main/app/view/NamedRangeEditDlg' ,
'spreadsheeteditor/main/app/view/NamedRangePasteDlg' ,
2017-01-16 08:48:21 +00:00
'spreadsheeteditor/main/app/view/NameManagerDlg' ,
2018-06-29 07:55:05 +00:00
'spreadsheeteditor/main/app/view/FormatSettingsDialog' ,
2018-10-11 11:25:53 +00:00
'spreadsheeteditor/main/app/view/PageMarginsDialog' ,
2019-08-21 10:55:40 +00:00
'spreadsheeteditor/main/app/view/HeaderFooterDialog' ,
2020-03-17 12:06:40 +00:00
'spreadsheeteditor/main/app/view/PrintTitlesDialog' ,
2020-04-14 17:32:48 +00:00
'spreadsheeteditor/main/app/view/ScaleDialog' ,
2020-05-15 11:29:20 +00:00
'spreadsheeteditor/main/app/view/FormatRulesManagerDlg' ,
2020-05-12 10:17:52 +00:00
'spreadsheeteditor/main/app/view/SlicerAddDialog' ,
2021-03-23 14:51:50 +00:00
'spreadsheeteditor/main/app/view/AdvancedSeparatorDialog' ,
'spreadsheeteditor/main/app/view/CreateSparklineDialog'
2016-03-11 00:48:53 +00:00
] , function ( ) { 'use strict' ;
SSE . Controllers . Toolbar = Backbone . Controller . extend ( _ . extend ( {
models : [ ] ,
collections : [ ] ,
views : [
'Toolbar'
] ,
initialize : function ( ) {
var me = this ;
this . addListeners ( {
2017-04-27 15:40:27 +00:00
'Toolbar' : {
2019-09-02 09:52:14 +00:00
'change:compact' : this . onClickChangeCompact . bind ( me ) ,
2019-09-03 10:52:52 +00:00
'add:chart' : this . onSelectChart ,
2021-03-22 19:21:03 +00:00
'add:spark' : this . onSelectSpark ,
2019-09-18 13:32:26 +00:00
'insert:textart' : this . onInsertTextart ,
2019-09-13 14:45:09 +00:00
'change:scalespn' : this . onClickChangeScaleInMenu . bind ( me ) ,
2020-09-17 13:29:48 +00:00
'click:customscale' : this . onScaleClick . bind ( me ) ,
2022-10-12 18:17:43 +00:00
'home:open' : this . onHomeOpen ,
'generate:smartart' : this . generateSmartArt ,
'insert:smartart' : this . onInsertSmartArt
2017-04-27 15:40:27 +00:00
} ,
'FileMenu' : {
'menu:hide' : me . onFileMenu . bind ( me , 'hide' ) ,
'menu:show' : me . onFileMenu . bind ( me , 'show' )
} ,
2016-03-11 00:48:53 +00:00
'Statusbar' : {
'sheet:changed' : _ . bind ( this . onApiSheetChanged , this )
} ,
2017-07-21 10:41:56 +00:00
'Common.Views.Header' : {
2017-08-23 11:51:27 +00:00
'print' : function ( opts ) {
var _main = this . getApplication ( ) . getController ( 'Main' ) ;
_main . onPrint ( ) ;
} ,
2022-11-16 11:28:07 +00:00
'print-quick' : function ( opts ) {
var _main = this . getApplication ( ) . getController ( 'Main' ) ;
_main . onPrintQuick ( ) ;
} ,
2018-01-24 11:10:33 +00:00
'save' : function ( opts ) {
this . api . asc _Save ( ) ;
} ,
'undo' : this . onUndo ,
'redo' : this . onRedo ,
2017-07-21 10:41:56 +00:00
'downloadas' : function ( opts ) {
2017-07-21 14:55:27 +00:00
var _main = this . getApplication ( ) . getController ( 'Main' ) ;
var _file _type = _main . appOptions . spreadsheet . fileType ,
_format ;
if ( ! ! _file _type ) {
_format = Asc . c _oAscFileType [ _file _type . toUpperCase ( ) ] ;
}
var _supported = [
Asc . c _oAscFileType . XLSX ,
Asc . c _oAscFileType . ODS ,
2018-07-18 11:07:24 +00:00
Asc . c _oAscFileType . CSV ,
2019-02-21 13:10:37 +00:00
Asc . c _oAscFileType . PDFA ,
Asc . c _oAscFileType . XLTX ,
2021-07-29 15:52:37 +00:00
Asc . c _oAscFileType . OTS ,
Asc . c _oAscFileType . XLSM
2017-07-21 14:55:27 +00:00
] ;
if ( ! _format || _supported . indexOf ( _format ) < 0 )
_format = Asc . c _oAscFileType . PDF ;
2018-07-18 11:07:24 +00:00
if ( _format == Asc . c _oAscFileType . PDF || _format == Asc . c _oAscFileType . PDFA )
Common . NotificationCenter . trigger ( 'download:settings' , this . toolbar , _format ) ;
2018-04-05 11:29:37 +00:00
else
2019-07-24 08:36:13 +00:00
_main . api . asc _DownloadAs ( new Asc . asc _CDownloadOptions ( _format ) ) ;
2017-07-21 14:55:27 +00:00
} ,
2017-07-21 10:41:56 +00:00
'go:editor' : function ( ) {
Common . Gateway . requestEditRights ( ) ;
}
2019-05-31 14:48:14 +00:00
} ,
'DataTab' : {
2019-06-03 10:20:24 +00:00
'data:sort' : this . onSortType ,
'data:setfilter' : this . onAutoFilter ,
'data:clearfilter' : this . onClearFilter
2020-02-26 10:49:57 +00:00
} ,
'FormulaTab' : {
'function:namedrange' : this . onNamedRangeMenu ,
'function:namedrange-open' : this . onNamedRangeMenuOpen
2021-03-15 20:10:47 +00:00
} ,
'CellSettings' : {
'cf:init' : this . onShowBeforeCondFormat
2021-12-12 14:49:49 +00:00
} ,
'ViewTab' : {
'viewtab:showtoolbar' : this . onChangeViewMode . bind ( this )
2022-05-30 17:46:20 +00:00
} ,
'LeftMenu' : {
'search:show' : this . searchShow . bind ( this )
2016-03-11 00:48:53 +00:00
}
} ) ;
2018-06-28 09:27:11 +00:00
Common . NotificationCenter . on ( 'page:settings' , _ . bind ( this . onApiSheetChanged , this ) ) ;
2019-03-04 13:02:57 +00:00
Common . NotificationCenter . on ( 'formula:settings' , _ . bind ( this . applyFormulaSettings , this ) ) ;
2021-12-22 23:00:22 +00:00
Common . NotificationCenter . on ( 'toolbar:collapse' , _ . bind ( function ( ) {
this . toolbar . collapse ( ) ;
} , this ) ) ;
2022-06-01 11:11:02 +00:00
Common . NotificationCenter . on ( 'oleedit:close' , _ . bind ( this . onOleEditClose , this ) ) ;
2018-06-28 09:27:11 +00:00
2016-03-11 00:48:53 +00:00
this . editMode = true ;
this . _isAddingShape = false ;
this . _state = {
2018-09-25 13:19:33 +00:00
activated : false ,
2016-03-11 00:48:53 +00:00
prstyle : undefined ,
clrtext : undefined ,
pralign : undefined ,
clrback : undefined ,
valign : undefined ,
can _undo : undefined ,
can _redo : undefined ,
bold : undefined ,
italic : undefined ,
underline : undefined ,
2017-12-05 13:58:01 +00:00
strikeout : undefined ,
subscript : undefined ,
superscript : undefined ,
2016-03-11 00:48:53 +00:00
wrap : undefined ,
merge : undefined ,
angle : undefined ,
controlsdisabled : {
filters : undefined
} ,
selection _type : undefined ,
2017-04-11 11:05:56 +00:00
filter : undefined ,
filterapplied : false ,
2016-03-11 00:48:53 +00:00
tablestylename : undefined ,
tablename : undefined ,
namedrange _locked : false ,
2016-11-01 12:42:46 +00:00
fontsize : undefined ,
2016-12-28 11:28:27 +00:00
multiselect : false ,
2017-01-12 14:14:51 +00:00
sparklines _disabled : false ,
2017-02-07 09:56:32 +00:00
numformatinfo : undefined ,
2017-01-17 12:58:20 +00:00
numformattype : undefined ,
2017-01-19 11:34:37 +00:00
numformat : undefined ,
2018-06-28 09:27:11 +00:00
langId : undefined ,
pgsize : [ 0 , 0 ] ,
pgmargins : undefined ,
2018-07-19 12:48:12 +00:00
pgorient : undefined ,
2021-03-12 09:41:05 +00:00
lock _doc : undefined ,
2021-03-24 15:39:00 +00:00
cf _locked : [ ] ,
2021-07-16 12:47:24 +00:00
selectedCells : 0 ,
wsLock : false ,
2021-11-26 14:12:28 +00:00
wsProps : [ ] ,
is _lockText : false ,
is _lockShape : false
2016-03-11 00:48:53 +00:00
} ;
2019-08-21 14:08:21 +00:00
this . binding = { } ;
2016-03-11 00:48:53 +00:00
var checkInsertAutoshape = function ( e , action ) {
var cmp = $ ( e . target ) ,
cmp _sdk = cmp . closest ( '#editor_sdk' ) ,
btn _id = cmp . closest ( 'button' ) . attr ( 'id' ) ;
if ( btn _id === undefined )
btn _id = cmp . closest ( '.btn-group' ) . attr ( 'id' ) ;
if ( me . api && me . api . asc _isAddAutoshape ( ) ) {
if ( cmp _sdk . length <= 0 || action == 'cancel' ) {
if ( me . toolbar . btnInsertText . pressed && btn _id != me . toolbar . btnInsertText . id ||
me . toolbar . btnInsertShape . pressed && btn _id != me . toolbar . btnInsertShape . id ) {
me . _isAddingShape = false ;
me . _addAutoshape ( false ) ;
me . toolbar . btnInsertShape . toggle ( false , true ) ;
me . toolbar . btnInsertText . toggle ( false , true ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , me . toolbar ) ;
} else if ( me . toolbar . btnInsertShape . pressed && btn _id == me . toolbar . btnInsertShape . id ) {
_ . defer ( function ( ) {
me . api . asc _endAddShape ( ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , me . toolbar ) ;
} , 100 ) ;
}
}
}
} ;
this . checkInsertAutoshape = function ( cmp ) {
checkInsertAutoshape ( { } , cmp . action ) ;
} ;
this . _addAutoshape = function ( isstart , type ) {
if ( this . api ) {
if ( isstart ) {
this . api . asc _startAddShape ( type ) ;
$ ( document . body ) . on ( 'mouseup' , checkInsertAutoshape ) ;
} else {
this . api . asc _endAddShape ( ) ;
$ ( document . body ) . off ( 'mouseup' , checkInsertAutoshape ) ;
}
}
} ;
this . onApiEndAddShape = function ( ) {
if ( this . toolbar . btnInsertShape . pressed ) this . toolbar . btnInsertShape . toggle ( false , true ) ;
2022-10-05 21:01:02 +00:00
if ( this . toolbar . btnInsertText . pressed ) {
this . toolbar . btnInsertText . toggle ( false , true ) ;
this . toolbar . btnInsertText . menu . clearAll ( ) ;
}
2016-03-11 00:48:53 +00:00
$ ( document . body ) . off ( 'mouseup' , checkInsertAutoshape ) ;
} ;
} ,
onLaunch : function ( ) {
// Create toolbar view
this . toolbar = this . createView ( 'Toolbar' ) ;
2017-04-27 15:40:27 +00:00
Common . NotificationCenter . on ( 'app:ready' , this . onAppReady . bind ( this ) ) ;
Common . NotificationCenter . on ( 'app:face' , this . onAppShowed . bind ( this ) ) ;
2016-03-11 00:48:53 +00:00
} ,
2018-05-15 14:32:10 +00:00
setMode : function ( mode ) {
this . mode = mode ;
this . toolbar . applyLayout ( mode ) ;
} ,
2017-04-28 14:28:35 +00:00
attachUIEvents : function ( toolbar ) {
2016-03-11 00:48:53 +00:00
var me = this ;
/ * *
* UI Events
* /
2017-04-27 15:40:27 +00:00
if ( me . appConfig . isEditDiagram ) {
2017-08-03 14:40:28 +00:00
toolbar . btnUndo . on ( 'click' , _ . bind ( this . onUndo , this ) ) ;
toolbar . btnRedo . on ( 'click' , _ . bind ( this . onRedo , this ) ) ;
2022-06-29 11:34:58 +00:00
toolbar . btnCopy . on ( 'click' , _ . bind ( this . onCopyPaste , this , 'copy' ) ) ;
toolbar . btnPaste . on ( 'click' , _ . bind ( this . onCopyPaste , this , 'paste' ) ) ;
2017-04-27 15:40:27 +00:00
toolbar . btnInsertFormula . on ( 'click' , _ . bind ( this . onInsertFormulaMenu , this ) ) ;
toolbar . btnInsertFormula . menu . on ( 'item:click' , _ . bind ( this . onInsertFormulaMenu , this ) ) ;
toolbar . btnDecDecimal . on ( 'click' , _ . bind ( this . onDecrement , this ) ) ;
toolbar . btnIncDecimal . on ( 'click' , _ . bind ( this . onIncrement , this ) ) ;
toolbar . cmbNumberFormat . on ( 'selected' , _ . bind ( this . onNumberFormatSelect , this ) ) ;
toolbar . cmbNumberFormat . on ( 'show:before' , _ . bind ( this . onNumberFormatOpenBefore , this , true ) ) ;
if ( toolbar . cmbNumberFormat . cmpEl )
toolbar . cmbNumberFormat . cmpEl . on ( 'click' , '#id-toolbar-mnu-item-more-formats a' , _ . bind ( this . onNumberFormatSelect , this ) ) ;
toolbar . btnEditChart . on ( 'click' , _ . bind ( this . onEditChart , this ) ) ;
2020-10-02 15:33:07 +00:00
toolbar . btnEditChartData . on ( 'click' , _ . bind ( this . onEditChartData , this ) ) ;
2020-12-08 09:48:23 +00:00
toolbar . btnEditChartType . on ( 'click' , _ . bind ( this . onEditChartType , this ) ) ;
2017-04-27 15:40:27 +00:00
} else
if ( me . appConfig . isEditMailMerge ) {
2017-08-03 14:40:28 +00:00
toolbar . btnUndo . on ( 'click' , _ . bind ( this . onUndo , this ) ) ;
toolbar . btnRedo . on ( 'click' , _ . bind ( this . onRedo , this ) ) ;
2022-06-29 11:34:58 +00:00
toolbar . btnCopy . on ( 'click' , _ . bind ( this . onCopyPaste , this , 'copy' ) ) ;
toolbar . btnPaste . on ( 'click' , _ . bind ( this . onCopyPaste , this , 'paste' ) ) ;
2022-05-30 17:46:20 +00:00
toolbar . btnSearch . on ( 'toggle' , _ . bind ( this . onSearch , this ) ) ;
2017-04-27 15:40:27 +00:00
toolbar . btnSortDown . on ( 'click' , _ . bind ( this . onSortType , this , Asc . c _oAscSortOptions . Ascending ) ) ;
toolbar . btnSortUp . on ( 'click' , _ . bind ( this . onSortType , this , Asc . c _oAscSortOptions . Descending ) ) ;
toolbar . btnSetAutofilter . on ( 'click' , _ . bind ( this . onAutoFilter , this ) ) ;
toolbar . btnClearAutofilter . on ( 'click' , _ . bind ( this . onClearFilter , this ) ) ;
2022-03-11 10:58:15 +00:00
} else
if ( me . appConfig . isEditOle ) {
toolbar . btnUndo . on ( 'click' , _ . bind ( this . onUndo , this ) ) ;
toolbar . btnRedo . on ( 'click' , _ . bind ( this . onRedo , this ) ) ;
2022-06-29 11:34:58 +00:00
toolbar . btnCopy . on ( 'click' , _ . bind ( this . onCopyPaste , this , 'copy' ) ) ;
toolbar . btnPaste . on ( 'click' , _ . bind ( this . onCopyPaste , this , 'paste' ) ) ;
2022-05-30 17:46:20 +00:00
toolbar . btnSearch . on ( 'toggle' , _ . bind ( this . onSearch , this ) ) ;
2022-03-16 11:17:25 +00:00
toolbar . btnInsertFormula . on ( 'click' , _ . bind ( this . onInsertFormulaMenu , this ) ) ;
toolbar . btnInsertFormula . menu . on ( 'item:click' , _ . bind ( this . onInsertFormulaMenu , this ) ) ;
toolbar . cmbNumberFormat . on ( 'selected' , _ . bind ( this . onNumberFormatSelect , this ) ) ;
toolbar . cmbNumberFormat . on ( 'show:before' , _ . bind ( this . onNumberFormatOpenBefore , this , true ) ) ;
if ( toolbar . cmbNumberFormat . cmpEl )
toolbar . cmbNumberFormat . cmpEl . on ( 'click' , '#id-toolbar-mnu-item-more-formats a' , _ . bind ( this . onNumberFormatSelect , this ) ) ;
2022-05-31 08:34:43 +00:00
toolbar . btnWrap . on ( 'click' , _ . bind ( this . onWrap , this ) ) ;
toolbar . btnTextColor . on ( 'click' , _ . bind ( this . onTextColor , this ) ) ;
toolbar . btnTextColor . on ( 'color:select' , _ . bind ( this . onTextColorSelect , this ) ) ;
toolbar . btnTextColor . on ( 'auto:select' , _ . bind ( this . onAutoFontColor , this ) ) ;
toolbar . btnBackColor . on ( 'click' , _ . bind ( this . onBackColor , this ) ) ;
toolbar . btnBackColor . on ( 'color:select' , _ . bind ( this . onBackColorSelect , this ) ) ;
toolbar . btnBorders . on ( 'click' , _ . bind ( this . onBorders , this ) ) ;
if ( toolbar . btnBorders . rendered ) {
toolbar . btnBorders . menu . on ( 'item:click' , _ . bind ( this . onBordersMenu , this ) ) ;
toolbar . mnuBorderWidth . on ( 'item:toggle' , _ . bind ( this . onBordersWidth , this ) ) ;
toolbar . mnuBorderColorPicker . on ( 'select' , _ . bind ( this . onBordersColor , this ) ) ;
$ ( '#id-toolbar-menu-auto-bordercolor' ) . on ( 'click' , _ . bind ( this . onAutoBorderColor , this ) ) ;
}
toolbar . btnMerge . on ( 'click' , _ . bind ( this . onMergeCellsMenu , this , toolbar . btnMerge . menu , toolbar . btnMerge . menu . items [ 0 ] ) ) ;
toolbar . btnMerge . menu . on ( 'item:click' , _ . bind ( this . onMergeCellsMenu , this ) ) ;
toolbar . btnTableTemplate . menu . on ( 'show:after' , _ . bind ( this . onTableTplMenuOpen , this ) ) ;
2022-09-22 19:06:58 +00:00
toolbar . btnCellStyle . menu . on ( 'show:after' , _ . bind ( this . onCellStyleMenuOpen , this ) ) ;
2022-05-27 18:04:06 +00:00
toolbar . btnVisibleArea . menu . on ( 'item:click' , _ . bind ( this . onVisibleAreaMenu , this ) ) ;
toolbar . btnVisibleAreaClose . on ( 'click' , _ . bind ( this . onVisibleAreaClose , this ) ) ;
2022-05-31 08:34:43 +00:00
toolbar . cmbFontName . on ( 'selected' , _ . bind ( this . onFontNameSelect , this ) ) ;
toolbar . cmbFontName . on ( 'show:after' , _ . bind ( this . onComboOpen , this , true ) ) ;
toolbar . cmbFontName . on ( 'hide:after' , _ . bind ( this . onHideMenus , this ) ) ;
toolbar . cmbFontName . on ( 'combo:blur' , _ . bind ( this . onComboBlur , this ) ) ;
toolbar . cmbFontName . on ( 'combo:focusin' , _ . bind ( this . onComboOpen , this , false ) ) ;
toolbar . cmbFontSize . on ( 'selected' , _ . bind ( this . onFontSizeSelect , this ) ) ;
toolbar . cmbFontSize . on ( 'changed:before' , _ . bind ( this . onFontSizeChanged , this , true ) ) ;
toolbar . cmbFontSize . on ( 'changed:after' , _ . bind ( this . onFontSizeChanged , this , false ) ) ;
toolbar . cmbFontSize . on ( 'show:after' , _ . bind ( this . onComboOpen , this , true ) ) ;
toolbar . cmbFontSize . on ( 'hide:after' , _ . bind ( this . onHideMenus , this ) ) ;
toolbar . cmbFontSize . on ( 'combo:blur' , _ . bind ( this . onComboBlur , this ) ) ;
toolbar . cmbFontSize . on ( 'combo:focusin' , _ . bind ( this . onComboOpen , this , false ) ) ;
2022-05-31 20:46:19 +00:00
toolbar . btnTextFormatting . menu . on ( 'item:click' , _ . bind ( this . onTextFormattingMenu , this ) ) ;
toolbar . btnHorizontalAlign . menu . on ( 'item:click' , _ . bind ( this . onHorizontalAlignMenu , this ) ) ;
toolbar . btnVerticalAlign . menu . on ( 'item:click' , _ . bind ( this . onVerticalAlignMenu , this ) ) ;
2017-04-27 15:40:27 +00:00
} else {
toolbar . btnPrint . on ( 'click' , _ . bind ( this . onPrint , this ) ) ;
2018-09-25 14:09:59 +00:00
toolbar . btnPrint . on ( 'disabled' , _ . bind ( this . onBtnChangeState , this , 'print:disabled' ) ) ;
2017-04-27 15:40:27 +00:00
toolbar . btnSave . on ( 'click' , _ . bind ( this . onSave , this ) ) ;
2018-02-15 23:56:17 +00:00
toolbar . btnSave . on ( 'disabled' , _ . bind ( this . onBtnChangeState , this , 'save:disabled' ) ) ;
2017-04-27 15:40:27 +00:00
toolbar . btnUndo . on ( 'click' , _ . bind ( this . onUndo , this ) ) ;
2018-02-15 23:56:17 +00:00
toolbar . btnUndo . on ( 'disabled' , _ . bind ( this . onBtnChangeState , this , 'undo:disabled' ) ) ;
2017-04-27 15:40:27 +00:00
toolbar . btnRedo . on ( 'click' , _ . bind ( this . onRedo , this ) ) ;
2018-02-15 23:56:17 +00:00
toolbar . btnRedo . on ( 'disabled' , _ . bind ( this . onBtnChangeState , this , 'redo:disabled' ) ) ;
2022-06-29 11:34:58 +00:00
toolbar . btnCopy . on ( 'click' , _ . bind ( this . onCopyPaste , this , 'copy' ) ) ;
toolbar . btnPaste . on ( 'click' , _ . bind ( this . onCopyPaste , this , 'paste' ) ) ;
toolbar . btnCut . on ( 'click' , _ . bind ( this . onCopyPaste , this , 'cut' ) ) ;
toolbar . btnSelectAll . on ( 'click' , _ . bind ( this . onSelectAll , this ) ) ;
2017-04-27 15:40:27 +00:00
toolbar . btnIncFontSize . on ( 'click' , _ . bind ( this . onIncreaseFontSize , this ) ) ;
toolbar . btnDecFontSize . on ( 'click' , _ . bind ( this . onDecreaseFontSize , this ) ) ;
toolbar . btnBold . on ( 'click' , _ . bind ( this . onBold , this ) ) ;
toolbar . btnItalic . on ( 'click' , _ . bind ( this . onItalic , this ) ) ;
toolbar . btnUnderline . on ( 'click' , _ . bind ( this . onUnderline , this ) ) ;
2017-12-05 13:58:01 +00:00
toolbar . btnStrikeout . on ( 'click' , _ . bind ( this . onStrikeout , this ) ) ;
toolbar . btnSubscript . on ( 'click' , _ . bind ( this . onSubscript , this ) ) ;
toolbar . btnSubscript . menu . on ( 'item:click' , _ . bind ( this . onSubscriptMenu , this ) ) ;
2017-04-27 15:40:27 +00:00
toolbar . btnTextColor . on ( 'click' , _ . bind ( this . onTextColor , this ) ) ;
2021-07-10 23:25:12 +00:00
toolbar . btnTextColor . on ( 'color:select' , _ . bind ( this . onTextColorSelect , this ) ) ;
toolbar . btnTextColor . on ( 'auto:select' , _ . bind ( this . onAutoFontColor , this ) ) ;
2017-04-27 15:40:27 +00:00
toolbar . btnBackColor . on ( 'click' , _ . bind ( this . onBackColor , this ) ) ;
2021-07-10 23:25:12 +00:00
toolbar . btnBackColor . on ( 'color:select' , _ . bind ( this . onBackColorSelect , this ) ) ;
2017-04-27 15:40:27 +00:00
toolbar . btnBorders . on ( 'click' , _ . bind ( this . onBorders , this ) ) ;
if ( toolbar . btnBorders . rendered ) {
toolbar . btnBorders . menu . on ( 'item:click' , _ . bind ( this . onBordersMenu , this ) ) ;
toolbar . mnuBorderWidth . on ( 'item:toggle' , _ . bind ( this . onBordersWidth , this ) ) ;
toolbar . mnuBorderColorPicker . on ( 'select' , _ . bind ( this . onBordersColor , this ) ) ;
2021-01-20 15:38:07 +00:00
$ ( '#id-toolbar-menu-auto-bordercolor' ) . on ( 'click' , _ . bind ( this . onAutoBorderColor , this ) ) ;
2017-04-27 15:40:27 +00:00
}
2017-08-24 11:22:59 +00:00
toolbar . btnAlignLeft . on ( 'click' , _ . bind ( this . onHorizontalAlign , this , AscCommon . align _Left ) ) ;
toolbar . btnAlignCenter . on ( 'click' , _ . bind ( this . onHorizontalAlign , this , AscCommon . align _Center ) ) ;
toolbar . btnAlignRight . on ( 'click' , _ . bind ( this . onHorizontalAlign , this , AscCommon . align _Right ) ) ;
toolbar . btnAlignJust . on ( 'click' , _ . bind ( this . onHorizontalAlign , this , AscCommon . align _Justify ) ) ;
2017-04-27 15:40:27 +00:00
toolbar . btnMerge . on ( 'click' , _ . bind ( this . onMergeCellsMenu , this , toolbar . btnMerge . menu , toolbar . btnMerge . menu . items [ 0 ] ) ) ;
toolbar . btnMerge . menu . on ( 'item:click' , _ . bind ( this . onMergeCellsMenu , this ) ) ;
2017-08-24 11:22:59 +00:00
toolbar . btnAlignTop . on ( 'click' , _ . bind ( this . onVerticalAlign , this , Asc . c _oAscVAlign . Top ) ) ;
toolbar . btnAlignMiddle . on ( 'click' , _ . bind ( this . onVerticalAlign , this , Asc . c _oAscVAlign . Center ) ) ;
toolbar . btnAlignBottom . on ( 'click' , _ . bind ( this . onVerticalAlign , this , Asc . c _oAscVAlign . Bottom ) ) ;
2017-04-27 15:40:27 +00:00
toolbar . btnWrap . on ( 'click' , _ . bind ( this . onWrap , this ) ) ;
toolbar . btnTextOrient . menu . on ( 'item:click' , _ . bind ( this . onTextOrientationMenu , this ) ) ;
2019-06-13 11:28:26 +00:00
toolbar . btnInsertTable . on ( 'click' , _ . bind ( this . onBtnInsertTableClick , this ) ) ;
2017-04-27 15:40:27 +00:00
toolbar . btnInsertImage . menu . on ( 'item:click' , _ . bind ( this . onInsertImageMenu , this ) ) ;
toolbar . btnInsertHyperlink . on ( 'click' , _ . bind ( this . onHyperlink , this ) ) ;
toolbar . btnInsertText . on ( 'click' , _ . bind ( this . onBtnInsertTextClick , this ) ) ;
2022-10-05 21:01:02 +00:00
toolbar . btnInsertText . menu . on ( 'item:click' , _ . bind ( this . onMenuInsertTextClick , this ) ) ;
2017-04-27 15:40:27 +00:00
toolbar . btnInsertShape . menu . on ( 'hide:after' , _ . bind ( this . onInsertShapeHide , this ) ) ;
toolbar . btnInsertEquation . on ( 'click' , _ . bind ( this . onInsertEquationClick , this ) ) ;
2019-11-14 08:48:58 +00:00
toolbar . btnInsertSymbol . on ( 'click' , _ . bind ( this . onInsertSymbolClick , this ) ) ;
2020-04-10 14:50:58 +00:00
toolbar . btnInsertSlicer . on ( 'click' , _ . bind ( this . onInsertSlicerClick , this ) ) ;
2017-04-27 15:40:27 +00:00
toolbar . btnTableTemplate . menu . on ( 'show:after' , _ . bind ( this . onTableTplMenuOpen , this ) ) ;
toolbar . btnPercentStyle . on ( 'click' , _ . bind ( this . onNumberFormat , this ) ) ;
toolbar . btnCurrencyStyle . on ( 'click' , _ . bind ( this . onNumberFormat , this ) ) ;
toolbar . btnDecDecimal . on ( 'click' , _ . bind ( this . onDecrement , this ) ) ;
toolbar . btnIncDecimal . on ( 'click' , _ . bind ( this . onIncrement , this ) ) ;
toolbar . btnInsertFormula . on ( 'click' , _ . bind ( this . onInsertFormulaMenu , this ) ) ;
toolbar . btnInsertFormula . menu . on ( 'item:click' , _ . bind ( this . onInsertFormulaMenu , this ) ) ;
toolbar . btnNamedRange . menu . on ( 'item:click' , _ . bind ( this . onNamedRangeMenu , this ) ) ;
toolbar . btnNamedRange . menu . on ( 'show:after' , _ . bind ( this . onNamedRangeMenuOpen , this ) ) ;
toolbar . btnClearStyle . menu . on ( 'item:click' , _ . bind ( this . onClearStyleMenu , this ) ) ;
toolbar . btnAddCell . menu . on ( 'item:click' , _ . bind ( this . onCellInsertMenu , this ) ) ;
toolbar . btnCopyStyle . on ( 'toggle' , _ . bind ( this . onCopyStyleToggle , this ) ) ;
toolbar . btnDeleteCell . menu . on ( 'item:click' , _ . bind ( this . onCellDeleteMenu , this ) ) ;
toolbar . btnColorSchemas . menu . on ( 'item:click' , _ . bind ( this . onColorSchemaClick , this ) ) ;
2019-08-20 12:56:29 +00:00
toolbar . btnColorSchemas . menu . on ( 'show:after' , _ . bind ( this . onColorSchemaShow , this ) ) ;
2017-04-27 15:40:27 +00:00
toolbar . cmbFontName . on ( 'selected' , _ . bind ( this . onFontNameSelect , this ) ) ;
toolbar . cmbFontName . on ( 'show:after' , _ . bind ( this . onComboOpen , this , true ) ) ;
toolbar . cmbFontName . on ( 'hide:after' , _ . bind ( this . onHideMenus , this ) ) ;
toolbar . cmbFontName . on ( 'combo:blur' , _ . bind ( this . onComboBlur , this ) ) ;
toolbar . cmbFontName . on ( 'combo:focusin' , _ . bind ( this . onComboOpen , this , false ) ) ;
toolbar . cmbFontSize . on ( 'selected' , _ . bind ( this . onFontSizeSelect , this ) ) ;
toolbar . cmbFontSize . on ( 'changed:before' , _ . bind ( this . onFontSizeChanged , this , true ) ) ;
toolbar . cmbFontSize . on ( 'changed:after' , _ . bind ( this . onFontSizeChanged , this , false ) ) ;
toolbar . cmbFontSize . on ( 'show:after' , _ . bind ( this . onComboOpen , this , true ) ) ;
toolbar . cmbFontSize . on ( 'hide:after' , _ . bind ( this . onHideMenus , this ) ) ;
toolbar . cmbFontSize . on ( 'combo:blur' , _ . bind ( this . onComboBlur , this ) ) ;
toolbar . cmbFontSize . on ( 'combo:focusin' , _ . bind ( this . onComboOpen , this , false ) ) ;
toolbar . listStyles . on ( 'click' , _ . bind ( this . onListStyleSelect , this ) ) ;
toolbar . cmbNumberFormat . on ( 'selected' , _ . bind ( this . onNumberFormatSelect , this ) ) ;
toolbar . cmbNumberFormat . on ( 'show:before' , _ . bind ( this . onNumberFormatOpenBefore , this , true ) ) ;
if ( toolbar . cmbNumberFormat . cmpEl )
toolbar . cmbNumberFormat . cmpEl . on ( 'click' , '#id-toolbar-mnu-item-more-formats a' , _ . bind ( this . onNumberFormatSelect , this ) ) ;
toolbar . btnCurrencyStyle . menu . on ( 'item:click' , _ . bind ( this . onNumberFormatMenu , this ) ) ;
$ ( '#id-toolbar-menu-new-bordercolor' ) . on ( 'click' , _ . bind ( this . onNewBorderColor , this ) ) ;
2018-06-28 09:27:11 +00:00
toolbar . btnPageOrient . menu . on ( 'item:click' , _ . bind ( this . onPageOrientSelect , this ) ) ;
toolbar . btnPageMargins . menu . on ( 'item:click' , _ . bind ( this . onPageMarginsSelect , this ) ) ;
toolbar . mnuPageSize . on ( 'item:click' , _ . bind ( this . onPageSizeClick , this ) ) ;
2019-10-15 12:07:03 +00:00
toolbar . mnuScale . on ( 'item:click' , _ . bind ( this . onScaleClick , this , 'scale' ) ) ;
toolbar . menuWidthScale . on ( 'item:click' , _ . bind ( this . onScaleClick , this , 'width' ) ) ;
toolbar . menuHeightScale . on ( 'item:click' , _ . bind ( this . onScaleClick , this , 'height' ) ) ;
2018-09-04 10:18:46 +00:00
toolbar . btnPrintArea . menu . on ( 'item:click' , _ . bind ( this . onPrintAreaClick , this ) ) ;
toolbar . btnPrintArea . menu . on ( 'show:after' , _ . bind ( this . onPrintAreaMenuOpen , this ) ) ;
2018-06-28 09:27:11 +00:00
toolbar . btnImgGroup . menu . on ( 'item:click' , _ . bind ( this . onImgGroupSelect , this ) ) ;
toolbar . btnImgBackward . menu . on ( 'item:click' , _ . bind ( this . onImgArrangeSelect , this ) ) ;
toolbar . btnImgForward . menu . on ( 'item:click' , _ . bind ( this . onImgArrangeSelect , this ) ) ;
toolbar . btnImgAlign . menu . on ( 'item:click' , _ . bind ( this . onImgAlignSelect , this ) ) ;
toolbar . btnImgForward . on ( 'click' , this . onImgArrangeSelect . bind ( this , 'forward' ) ) ;
toolbar . btnImgBackward . on ( 'click' , this . onImgArrangeSelect . bind ( this , 'backward' ) ) ;
2019-09-04 14:58:43 +00:00
toolbar . btnsEditHeader . forEach ( function ( button ) {
2022-04-07 14:12:39 +00:00
button . on ( 'click' , _ . bind ( me . onEditHeaderClick , me , undefined ) ) ;
2019-09-04 14:58:43 +00:00
} ) ;
2020-03-17 12:06:40 +00:00
toolbar . btnPrintTitles . on ( 'click' , _ . bind ( this . onPrintTitlesClick , this ) ) ;
2021-10-21 16:52:17 +00:00
toolbar . chPrintGridlines . on ( 'change' , _ . bind ( this . onPrintGridlinesChange , this ) ) ;
toolbar . chPrintHeadings . on ( 'change' , _ . bind ( this . onPrintHeadingsChange , this ) ) ;
2020-04-14 14:31:47 +00:00
if ( toolbar . btnCondFormat . rendered ) {
2021-03-15 20:10:47 +00:00
toolbar . btnCondFormat . menu . on ( 'show:before' , _ . bind ( this . onShowBeforeCondFormat , this , this . toolbar , 'toolbar' ) ) ;
2020-04-14 14:31:47 +00:00
}
2019-07-26 11:49:53 +00:00
Common . Gateway . on ( 'insertimage' , _ . bind ( this . insertImage , this ) ) ;
2017-04-27 15:40:27 +00:00
this . onSetupCopyStyleButton ( ) ;
}
2016-03-11 00:48:53 +00:00
} ,
setApi : function ( api ) {
this . api = api ;
2017-04-27 15:40:27 +00:00
var config = SSE . getController ( 'Main' ) . appOptions ;
2019-11-15 11:01:08 +00:00
if ( config . isEdit ) {
2022-03-11 10:58:15 +00:00
if ( ! config . isEditDiagram && ! config . isEditMailMerge && ! config . isEditOle ) {
2019-11-15 11:01:08 +00:00
this . api . asc _registerCallback ( 'asc_onSendThemeColors' , _ . bind ( this . onSendThemeColors , this ) ) ;
this . api . asc _registerCallback ( 'asc_onMathTypes' , _ . bind ( this . onApiMathTypes , this ) ) ;
this . api . asc _registerCallback ( 'asc_onContextMenu' , _ . bind ( this . onContextMenu , this ) ) ;
2020-05-13 14:20:58 +00:00
Common . NotificationCenter . on ( 'storage:image-load' , _ . bind ( this . openImageFromStorage , this ) ) ;
Common . NotificationCenter . on ( 'storage:image-insert' , _ . bind ( this . insertImageFromStorage , this ) ) ;
2021-03-24 15:39:00 +00:00
this . api . asc _registerCallback ( 'asc_onSelectionMathChanged' , _ . bind ( this . onApiMathChanged , this ) ) ;
2019-11-15 11:01:08 +00:00
}
this . api . asc _registerCallback ( 'asc_onInitEditorStyles' , _ . bind ( this . onApiInitEditorStyles , this ) ) ;
this . api . asc _registerCallback ( 'asc_onCoAuthoringDisconnect' , _ . bind ( this . onApiCoAuthoringDisconnect , this ) ) ;
Common . NotificationCenter . on ( 'api:disconnect' , _ . bind ( this . onApiCoAuthoringDisconnect , this ) ) ;
this . api . asc _registerCallback ( 'asc_onLockDefNameManager' , _ . bind ( this . onLockDefNameManager , this ) ) ;
2021-03-12 09:41:05 +00:00
this . api . asc _registerCallback ( 'asc_onLockCFManager' , _ . bind ( this . onLockCFManager , this ) ) ;
this . api . asc _registerCallback ( 'asc_onUnLockCFManager' , _ . bind ( this . onUnLockCFManager , this ) ) ;
2019-11-15 11:01:08 +00:00
this . api . asc _registerCallback ( 'asc_onZoomChanged' , _ . bind ( this . onApiZoomChange , this ) ) ;
Common . NotificationCenter . on ( 'fonts:change' , _ . bind ( this . onApiChangeFont , this ) ) ;
2022-10-12 18:17:43 +00:00
this . api . asc _registerCallback ( 'asc_onBeginSmartArtPreview' , _ . bind ( this . onApiBeginSmartArtPreview , this ) ) ;
this . api . asc _registerCallback ( 'asc_onAddSmartArtPreview' , _ . bind ( this . onApiAddSmartArtPreview , this ) ) ;
2022-10-13 09:13:20 +00:00
this . api . asc _registerCallback ( 'asc_onEndSmartArtPreview' , _ . bind ( this . onApiEndSmartArtPreview , this ) ) ;
2022-05-31 08:34:43 +00:00
} else if ( config . isEditOle ) {
Common . NotificationCenter . on ( 'fonts:change' , _ . bind ( this . onApiChangeFont , this ) ) ;
2021-09-06 23:02:15 +00:00
} else if ( config . isRestrictedEdit ) {
2019-11-15 11:01:08 +00:00
this . api . asc _registerCallback ( 'asc_onSelectionChanged' , _ . bind ( this . onApiSelectionChangedRestricted , this ) ) ;
2021-09-06 23:02:15 +00:00
Common . NotificationCenter . on ( 'protect:wslock' , _ . bind ( this . onChangeProtectSheet , this ) ) ;
}
2016-03-11 00:48:53 +00:00
} ,
2017-04-27 15:25:02 +00:00
// onNewDocument: function(btn, e) {
// this.api.asc_openNewDocument();
//
// Common.NotificationCenter.trigger('edit:complete', this.toolbar);
// Common.component.Analytics.trackEvent('ToolBar', 'New Document');
// },
//
// onOpenDocument: function(btn, e) {
// this.api.asc_loadDocumentFromDisk();
//
// Common.NotificationCenter.trigger('edit:complete', this.toolbar);
// Common.component.Analytics.trackEvent('ToolBar', 'Open Document');
// },
2016-03-11 00:48:53 +00:00
2019-02-01 10:13:44 +00:00
onApiChangeFont : function ( font ) {
2020-04-22 09:35:55 +00:00
! Common . Utils . ModalWindow . isVisible ( ) && this . toolbar . cmbFontName . onApiChangeFont ( font ) ;
2019-02-01 10:13:44 +00:00
} ,
2017-04-28 14:43:12 +00:00
onContextMenu : function ( ) {
2017-07-18 12:59:14 +00:00
this . toolbar . collapse ( ) ;
2017-04-28 14:43:12 +00:00
} ,
2016-03-11 00:48:53 +00:00
onPrint : function ( e ) {
2016-04-04 08:17:21 +00:00
Common . NotificationCenter . trigger ( 'print' , this . toolbar ) ;
2016-03-11 00:48:53 +00:00
} ,
onSave : function ( e ) {
if ( this . api ) {
var isModified = this . api . asc _isDocumentCanSave ( ) ;
2019-11-20 09:42:39 +00:00
var isSyncButton = this . toolbar . btnCollabChanges && this . toolbar . btnCollabChanges . cmpEl . hasClass ( 'notify' ) ;
2017-04-11 11:05:56 +00:00
if ( ! isModified && ! isSyncButton && ! this . toolbar . mode . forcesave )
2016-03-11 00:48:53 +00:00
return ;
this . api . asc _Save ( ) ;
}
// Common.NotificationCenter.trigger('edit:complete', this.toolbar);
Common . component . Analytics . trackEvent ( 'Save' ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Save' ) ;
} ,
2018-02-15 23:56:17 +00:00
onBtnChangeState : function ( prop ) {
if ( /\:disabled$/ . test ( prop ) ) {
var _is _disabled = arguments [ 2 ] ;
this . toolbar . fireEvent ( prop , [ _is _disabled ] ) ;
}
} ,
2016-03-11 00:48:53 +00:00
onUndo : function ( btn , e ) {
if ( this . api )
this . api . asc _Undo ( ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Undo' ) ;
} ,
onRedo : function ( btn , e ) {
if ( this . api )
this . api . asc _Redo ( ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Redo' ) ;
} ,
2022-06-29 11:34:58 +00:00
onCopyPaste : function ( type , e ) {
2016-03-11 00:48:53 +00:00
var me = this ;
if ( me . api ) {
2022-06-29 11:34:58 +00:00
var res = ( type === 'cut' ) ? me . api . asc _Cut ( ) : ( ( type === 'copy' ) ? me . api . asc _Copy ( ) : me . api . asc _Paste ( ) ) ;
2016-07-26 14:46:42 +00:00
if ( ! res ) {
2016-03-11 00:48:53 +00:00
var value = Common . localStorage . getItem ( "sse-hide-copywarning" ) ;
if ( ! ( value && parseInt ( value ) == 1 ) ) {
( new Common . Views . CopyWarningDialog ( {
handler : function ( dontshow ) {
if ( dontshow ) Common . localStorage . setItem ( "sse-hide-copywarning" , 1 ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , me . toolbar ) ;
}
} ) ) . show ( ) ;
}
2016-07-26 14:46:42 +00:00
} else
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Copy Warning' ) ;
2016-03-11 00:48:53 +00:00
}
2016-07-26 14:46:42 +00:00
Common . NotificationCenter . trigger ( 'edit:complete' , me . toolbar ) ;
2016-03-11 00:48:53 +00:00
} ,
2022-06-29 11:34:58 +00:00
onSelectAll : function ( e ) {
if ( this . api )
this . api . asc _EditSelectAll ( ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Select All' ) ;
} ,
2016-03-11 00:48:53 +00:00
onIncreaseFontSize : function ( e ) {
if ( this . api )
this . api . asc _increaseFontSize ( ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar , { restorefocus : true } ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Font Size' ) ;
} ,
onDecreaseFontSize : function ( e ) {
if ( this . api )
this . api . asc _decreaseFontSize ( ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar , { restorefocus : true } ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Font Size' ) ;
} ,
onBold : function ( btn , e ) {
this . _state . bold = undefined ;
if ( this . api )
this . api . asc _setCellBold ( btn . pressed ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar , { restorefocus : true } ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Bold' ) ;
} ,
onItalic : function ( btn , e ) {
this . _state . italic = undefined ;
if ( this . api )
this . api . asc _setCellItalic ( btn . pressed ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar , { restorefocus : true } ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Italic' ) ;
} ,
onUnderline : function ( btn , e ) {
this . _state . underline = undefined ;
if ( this . api )
this . api . asc _setCellUnderline ( btn . pressed ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar , { restorefocus : true } ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Underline' ) ;
} ,
2017-12-05 13:58:01 +00:00
onStrikeout : function ( btn , e ) {
this . _state . strikeout = undefined ;
if ( this . api )
this . api . asc _setCellStrikeout ( btn . pressed ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar , { restorefocus : true } ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Strikeout' ) ;
} ,
onSubscriptMenu : function ( menu , item ) {
2018-02-26 13:23:07 +00:00
var btnSubscript = this . toolbar . btnSubscript ;
2017-12-05 13:58:01 +00:00
if ( item . value == 'sub' ) {
this . _state . subscript = undefined ;
this . api . asc _setCellSubscript ( item . checked ) ;
} else {
this . _state . superscript = undefined ;
this . api . asc _setCellSuperscript ( item . checked ) ;
}
if ( item . checked ) {
2018-02-26 13:23:07 +00:00
btnSubscript . $icon . removeClass ( btnSubscript . options . icls ) . addClass ( item . options . icls ) ;
2017-12-05 13:58:01 +00:00
btnSubscript . options . icls = item . options . icls ;
}
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , ( item . value == 'sub' ) ? 'Subscript' : 'Superscript' ) ;
} ,
onSubscript : function ( btn , e ) {
var subscript = ( btn . options . icls == 'btn-subscript' ) ;
if ( subscript ) {
this . _state . subscript = undefined ;
this . api . asc _setCellSubscript ( btn . pressed ) ;
} else {
this . _state . superscript = undefined ;
this . api . asc _setCellSuperscript ( btn . pressed ) ;
}
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , ( subscript ) ? 'Subscript' : 'Superscript' ) ;
} ,
2016-03-11 00:48:53 +00:00
onTextColor : function ( ) {
2021-11-09 13:56:05 +00:00
this . toolbar . mnuTextColorPicker . trigger ( 'select' , this . toolbar . mnuTextColorPicker , this . toolbar . mnuTextColorPicker . currentColor ) ;
2016-03-11 00:48:53 +00:00
} ,
onBackColor : function ( ) {
2021-11-09 13:56:05 +00:00
this . toolbar . mnuBackColorPicker . trigger ( 'select' , this . toolbar . mnuBackColorPicker , this . toolbar . mnuBackColorPicker . currentColor ) ;
2016-03-11 00:48:53 +00:00
} ,
2021-11-09 13:56:05 +00:00
onTextColorSelect : function ( btn , color ) {
2016-03-11 00:48:53 +00:00
this . _state . clrtext _asccolor = this . _state . clrtext = undefined ;
this . toolbar . btnTextColor . currentColor = color ;
this . toolbar . mnuTextColorPicker . currentColor = color ;
if ( this . api ) {
2021-01-21 21:45:44 +00:00
this . api . asc _setCellTextColor ( color . isAuto ? color . color : Common . Utils . ThemeColor . getRgbColor ( color ) ) ;
2016-03-11 00:48:53 +00:00
}
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar , { restorefocus : true } ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Text Color' ) ;
} ,
2021-11-09 13:56:05 +00:00
onBackColorSelect : function ( btn , color ) {
2016-03-11 00:48:53 +00:00
this . _state . clrshd _asccolor = this . _state . clrback = undefined ;
this . toolbar . btnBackColor . currentColor = color ;
2021-07-10 23:25:12 +00:00
2016-03-11 00:48:53 +00:00
this . toolbar . mnuBackColorPicker . currentColor = color ;
if ( this . api ) {
this . api . asc _setCellBackgroundColor ( color == 'transparent' ? null : Common . Utils . ThemeColor . getRgbColor ( color ) ) ;
}
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Background Color' ) ;
} ,
onNewBorderColor : function ( picker , color ) {
this . toolbar . btnBorders . menu . hide ( ) ;
this . toolbar . btnBorders . toggle ( false , true ) ;
this . toolbar . mnuBorderColorPicker . addNewColor ( ) ;
} ,
2021-01-21 21:45:44 +00:00
onAutoFontColor : function ( e ) {
this . _state . clrtext _asccolor = this . _state . clrtext = undefined ;
var color = new Asc . asc _CColor ( ) ;
color . put _auto ( true ) ;
this . toolbar . btnTextColor . currentColor = { color : color , isAuto : true } ;
this . toolbar . mnuTextColorPicker . currentColor = { color : color , isAuto : true } ;
if ( this . api ) {
this . api . asc _setCellTextColor ( color ) ;
}
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar , { restorefocus : true } ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Text Color' ) ;
} ,
2016-03-11 00:48:53 +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 ( me . api && ! _ . isUndefined ( item . options . borderId ) ) {
var btnBorders = me . toolbar . btnBorders ,
new _borders = [ ] ,
bordersWidth = btnBorders . options . borderswidth ,
bordersColor = btnBorders . options . borderscolor ;
2018-02-26 13:23:07 +00:00
if ( btnBorders . rendered ) {
btnBorders . $icon . removeClass ( btnBorders . options . icls ) . addClass ( item . options . icls ) ;
btnBorders . options . icls = item . options . icls ;
2016-03-11 00:48:53 +00:00
}
btnBorders . options . borderId = item . options . borderId ;
if ( item . options . borderId == 'inner' ) {
2016-04-05 11:52:34 +00:00
new _borders [ Asc . c _oAscBorderOptions . InnerV ] = new Asc . asc _CBorder ( bordersWidth , bordersColor ) ;
new _borders [ Asc . c _oAscBorderOptions . InnerH ] = new Asc . asc _CBorder ( bordersWidth , bordersColor ) ;
2016-03-11 00:48:53 +00:00
} else if ( item . options . borderId == 'all' ) {
2016-04-05 11:52:34 +00:00
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 ) ;
2016-03-11 00:48:53 +00:00
} else if ( item . options . borderId == 'outer' ) {
2016-04-05 11:52:34 +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 ) ;
2016-03-11 00:48:53 +00:00
} else if ( item . options . borderId != 'none' ) {
new _borders [ item . options . borderId ] = new Asc . asc _CBorder ( bordersWidth , bordersColor ) ;
}
me . api . asc _setCellBorders ( new _borders ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , me . toolbar ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Borders' ) ;
}
} ,
onBordersWidth : function ( menu , item , state ) {
if ( state ) {
this . toolbar . btnBorders . options . borderswidth = item . value ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Border Width' ) ;
}
} ,
onBordersColor : function ( picker , color ) {
2021-01-20 15:38:07 +00:00
$ ( '#id-toolbar-mnu-item-border-color > a .menu-item-icon' ) . css ( 'border-color' , '#' + ( ( typeof ( color ) == 'object' ) ? color . color : color ) ) ;
2016-03-11 00:48:53 +00:00
this . toolbar . mnuBorderColor . onUnHoverItem ( ) ;
this . toolbar . btnBorders . options . borderscolor = Common . Utils . ThemeColor . getRgbColor ( color ) ;
this . toolbar . mnuBorderColorPicker . currentColor = color ;
2021-01-20 15:38:07 +00:00
var clr _item = this . toolbar . btnBorders . menu . $el . find ( '#id-toolbar-menu-auto-bordercolor > a' ) ;
clr _item . hasClass ( 'selected' ) && clr _item . removeClass ( 'selected' ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Border Color' ) ;
} ,
onAutoBorderColor : function ( e ) {
2021-01-21 21:45:44 +00:00
$ ( '#id-toolbar-mnu-item-border-color > a .menu-item-icon' ) . css ( 'border-color' , '#000' ) ;
2021-01-20 15:38:07 +00:00
this . toolbar . mnuBorderColor . onUnHoverItem ( ) ;
2021-01-21 21:45:44 +00:00
var color = new Asc . asc _CColor ( ) ;
color . put _auto ( true ) ;
this . toolbar . btnBorders . options . borderscolor = color ;
2021-01-20 15:38:07 +00:00
this . toolbar . mnuBorderColorPicker . clearSelection ( ) ;
this . toolbar . mnuBorderColorPicker . currentColor = { color : color , isAuto : true } ;
var clr _item = this . toolbar . btnBorders . menu . $el . find ( '#id-toolbar-menu-auto-bordercolor > a' ) ;
! clr _item . hasClass ( 'selected' ) && clr _item . addClass ( 'selected' ) ;
2016-03-11 00:48:53 +00:00
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Border Color' ) ;
} ,
onHorizontalAlign : function ( type , btn , e ) {
this . _state . pralign = undefined ;
if ( this . api ) {
2017-08-24 11:22:59 +00:00
this . api . asc _setCellAlign ( ! btn . pressed ? null : type ) ;
this . toolbar . btnWrap . allowDepress = ! ( type == AscCommon . align _Justify ) ;
2016-03-11 00:48:53 +00:00
}
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Horizontal align' ) ;
} ,
onVerticalAlign : function ( type , btn , e ) {
this . _state . valign = undefined ;
if ( this . api ) {
2017-08-24 11:22:59 +00:00
this . api . asc _setCellVertAlign ( ! btn . pressed ? Asc . c _oAscVAlign . Bottom : type ) ;
2016-03-11 00:48:53 +00:00
}
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Vertical align' ) ;
} ,
onMergeCellsMenu : function ( menu , item ) {
var me = this ;
function doMergeCells ( how ) {
me . _state . merge = undefined ;
me . api . asc _mergeCells ( how ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , me . toolbar ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Merge' ) ;
}
if ( me . api ) {
2020-05-14 09:16:27 +00:00
var merged = me . api . asc _getCellInfo ( ) . asc _getMerge ( ) ;
2017-04-11 11:05:56 +00:00
if ( ( merged !== Asc . c _oAscMergeOptions . Merge ) && me . api . asc _mergeCellsDataLost ( item . value ) ) {
2016-03-11 00:48:53 +00:00
Common . UI . warning ( {
msg : me . warnMergeLostData ,
buttons : [ 'yes' , 'no' ] ,
primary : 'yes' ,
callback : function ( btn ) {
if ( btn == 'yes' ) {
doMergeCells ( item . value ) ;
} else {
me . toolbar . btnMerge . toggle ( false , true ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , me . toolbar ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Merge' ) ;
}
}
} ) ;
} else {
doMergeCells ( item . value ) ;
}
}
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Merge cells' ) ;
} ,
onWrap : function ( btn , e ) {
this . _state . wrap = undefined ;
if ( this . api )
this . api . asc _setCellTextWrap ( btn . pressed ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Wrap' ) ;
} ,
onTextOrientationMenu : function ( menu , item ) {
2017-05-15 13:32:01 +00:00
var angle = 0 ;
2016-03-11 00:48:53 +00:00
2017-05-15 13:32:01 +00:00
switch ( item . value ) {
case 'countcw' : angle = 45 ; break ;
case 'clockwise' : angle = - 45 ; break ;
2020-05-28 10:17:21 +00:00
case 'vertical' : angle = 255 ; break ;
2017-05-15 13:32:01 +00:00
case 'rotateup' : angle = 90 ; break ;
case 'rotatedown' : angle = - 90 ; break ;
}
this . _state . angle = undefined ;
if ( this . api )
this . api . asc _setCellAngle ( angle ) ;
2016-03-11 00:48:53 +00:00
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Text orientation' ) ;
} ,
2019-06-13 11:28:26 +00:00
onBtnInsertTableClick : function ( btn , e ) {
if ( this . api )
this . _setTableFormat ( this . api . asc _getDefaultTableStyle ( ) ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Table' ) ;
} ,
2016-03-11 00:48:53 +00:00
onInsertImageMenu : function ( menu , item , e ) {
2019-09-11 13:21:12 +00:00
var me = this ;
2016-03-11 00:48:53 +00:00
if ( item . value === 'file' ) {
this . toolbar . fireEvent ( 'insertimage' , this . toolbar ) ;
if ( this . api )
2021-05-11 12:24:53 +00:00
setTimeout ( function ( ) { me . api . asc _addImage ( ) ; } , 1 ) ;
2016-03-11 00:48:53 +00:00
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Image' ) ;
2018-10-03 11:00:08 +00:00
} else if ( item . value === 'url' ) {
2016-03-11 00:48:53 +00:00
( new Common . Views . ImageFromUrlDialog ( {
handler : function ( result , value ) {
if ( result == 'ok' ) {
if ( me . api ) {
var checkUrl = value . replace ( /\s/g , '' ) ;
if ( ! _ . isEmpty ( checkUrl ) ) {
me . toolbar . fireEvent ( 'insertimage' , me . toolbar ) ;
2021-08-26 12:14:29 +00:00
me . api . asc _addImageDrawingObject ( [ checkUrl ] ) ;
2016-03-11 00:48:53 +00:00
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Image' ) ;
} else {
Common . UI . warning ( {
msg : this . textEmptyImgUrl
} ) ;
}
}
Common . NotificationCenter . trigger ( 'edit:complete' , me . toolbar ) ;
}
}
} ) ) . show ( ) ;
2018-10-03 11:00:08 +00:00
} else if ( item . value === 'storage' ) {
2020-05-13 14:20:58 +00:00
Common . NotificationCenter . trigger ( 'storage:image-load' , 'add' ) ;
2019-07-26 11:49:53 +00:00
}
} ,
2020-05-13 14:20:58 +00:00
openImageFromStorage : function ( type ) {
var me = this ;
if ( this . toolbar . mode . canRequestInsertImage ) {
Common . Gateway . requestInsertImage ( type ) ;
} else {
( new Common . Views . SelectFileDlg ( {
fileChoiceUrl : this . toolbar . mode . fileChoiceUrl . replace ( "{fileExt}" , "" ) . replace ( "{documentType}" , "ImagesOnly" )
} ) ) . on ( 'selectfile' , function ( obj , file ) {
file && ( file . c = type ) ;
2021-10-04 16:29:27 +00:00
! file . images && ( file . images = [ { fileType : file . fileType , url : file . url } ] ) ; // SelectFileDlg uses old format for inserting image
file . url = null ;
2020-05-13 14:20:58 +00:00
me . insertImage ( file ) ;
} ) . show ( ) ;
2019-07-26 11:49:53 +00:00
}
} ,
2020-05-13 14:20:58 +00:00
insertImageFromStorage : function ( data ) {
2021-08-27 11:07:50 +00:00
if ( data && data . _urls && ( ! data . c || data . c == 'add' ) ) {
2019-07-26 11:49:53 +00:00
this . toolbar . fireEvent ( 'insertimage' , this . toolbar ) ;
2021-08-27 11:07:50 +00:00
( data . _urls . length > 0 ) && this . api . asc _addImageDrawingObject ( data . _urls , undefined , data . token ) ; // for loading from storage
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Image' ) ;
}
} ,
insertImage : function ( data ) { // gateway
if ( data && ( data . url || data . images ) ) {
2021-08-30 21:12:45 +00:00
data . url && console . log ( "Obsolete: The 'url' parameter of the 'insertImage' method is deprecated. Please use 'images' parameter instead." ) ;
2021-08-26 12:14:29 +00:00
var arr = [ ] ;
if ( data . images && data . images . length > 0 ) {
for ( var i = 0 ; i < data . images . length ; i ++ ) {
data . images [ i ] && data . images [ i ] . url && arr . push ( data . images [ i ] . url ) ;
}
} else
data . url && arr . push ( data . url ) ;
2021-08-27 11:07:50 +00:00
data . _urls = arr ;
2016-03-11 00:48:53 +00:00
}
2020-05-13 14:20:58 +00:00
Common . NotificationCenter . trigger ( 'storage:image-insert' , data ) ;
} ,
2016-03-11 00:48:53 +00:00
onHyperlink : function ( btn ) {
2021-07-19 20:50:45 +00:00
Common . NotificationCenter . trigger ( 'protect:check' , this . onHyperlinkCallback , this , [ btn ] ) ;
} ,
onHyperlinkCallback : function ( btn ) {
2016-03-11 00:48:53 +00:00
var me = this ;
var win ,
props ;
if ( me . api ) {
var wc = me . api . asc _getWorksheetsCount ( ) ,
i = - 1 ,
items = [ ] ;
while ( ++ i < wc ) {
2020-03-16 10:30:51 +00:00
items . push ( { name : me . api . asc _getWorksheetName ( i ) , hidden : me . api . asc _isWorksheetHidden ( i ) } ) ;
2016-03-11 00:48:53 +00:00
}
var handlerDlg = function ( dlg , result ) {
if ( result == 'ok' ) {
props = dlg . getSettings ( ) ;
me . api . asc _insertHyperlink ( props ) ;
}
Common . NotificationCenter . trigger ( 'edit:complete' , me . toolbar ) ;
} ;
var cell = me . api . asc _getCellInfo ( ) ,
2020-05-14 08:39:04 +00:00
seltype = cell . asc _getSelectionType ( ) ;
2016-03-11 00:48:53 +00:00
props = cell . asc _getHyperlink ( ) ;
win = new SSE . Views . HyperlinkSettingsDialog ( {
api : me . api ,
2020-03-20 12:29:47 +00:00
appOptions : me . appOptions ,
2016-03-11 00:48:53 +00:00
handler : handlerDlg
} ) ;
win . show ( ) ;
win . setSettings ( {
sheets : items ,
2020-08-20 08:14:36 +00:00
ranges : me . api . asc _getDefinedNames ( Asc . c _oAscGetDefinedNamesList . All , true ) ,
2016-03-11 00:48:53 +00:00
currentSheet : me . api . asc _getWorksheetName ( me . api . asc _getActiveWorksheetIndex ( ) ) ,
props : props ,
text : cell . asc _getText ( ) ,
2020-05-14 08:50:34 +00:00
isLock : cell . asc _getLockText ( ) ,
2016-04-05 11:52:34 +00:00
allowInternal : ( seltype !== Asc . c _oAscSelectionType . RangeImage && seltype !== Asc . c _oAscSelectionType . RangeShape &&
seltype !== Asc . c _oAscSelectionType . RangeShapeText && seltype !== Asc . c _oAscSelectionType . RangeChart &&
2020-06-05 16:28:11 +00:00
seltype !== Asc . c _oAscSelectionType . RangeChartText && seltype !== Asc . c _oAscSelectionType . RangeSlicer )
2016-03-11 00:48:53 +00:00
} ) ;
}
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Add Hyperlink' ) ;
} ,
2016-12-16 08:37:57 +00:00
onEditChart : function ( btn ) {
2016-03-11 00:48:53 +00:00
if ( ! this . editMode ) return ;
var me = this , info = me . api . asc _getCellInfo ( ) ;
2020-05-14 08:39:04 +00:00
var selectType = info . asc _getSelectionType ( ) ;
if ( selectType !== Asc . c _oAscSelectionType . RangeImage ) {
2016-03-11 00:48:53 +00:00
var win , props ;
if ( me . api ) {
props = me . api . asc _getChartObject ( ) ;
2017-04-11 11:05:56 +00:00
var selectedObjects = me . api . asc _getGraphicObjectProps ( ) ,
imageSettings = null ;
for ( var i = 0 ; i < selectedObjects . length ; i ++ ) {
if ( selectedObjects [ i ] . asc _getObjectType ( ) == Asc . c _oAscTypeSelectElement . Image ) {
var elValue = selectedObjects [ i ] . asc _getObjectValue ( ) ;
if ( elValue . asc _getChartProperties ( ) )
imageSettings = elValue ;
}
}
2016-03-11 00:48:53 +00:00
if ( props ) {
2020-05-14 08:39:04 +00:00
var ischartedit = ( me . toolbar . mode . isEditDiagram || selectType === Asc . c _oAscSelectionType . RangeChart || selectType === Asc . c _oAscSelectionType . RangeChartText ) ;
2016-03-11 00:48:53 +00:00
( new SSE . Views . ChartSettingsDlg (
{
chartSettings : props ,
2017-04-11 11:05:56 +00:00
imageSettings : imageSettings ,
2020-12-08 09:48:23 +00:00
// isDiagramMode: me.toolbar.mode.isEditDiagram,
2016-09-14 13:34:08 +00:00
isChart : true ,
2016-03-11 00:48:53 +00:00
api : me . api ,
handler : function ( result , value ) {
if ( result == 'ok' ) {
if ( me . api ) {
( ischartedit ) ? me . api . asc _editChartDrawingObject ( value . chartSettings ) : me . api . asc _addChartDrawingObject ( value . chartSettings ) ;
2017-04-11 11:05:56 +00:00
if ( value . imageSettings )
me . api . asc _setGraphicObjectProps ( value . imageSettings ) ;
2016-03-11 00:48:53 +00:00
}
}
Common . NotificationCenter . trigger ( 'edit:complete' , me . toolbar ) ;
}
} ) ) . show ( ) ;
}
}
}
} ,
2020-10-02 15:33:07 +00:00
onEditChartData : function ( btn ) {
if ( ! this . editMode ) return ;
var me = this ;
var props ;
if ( me . api ) {
props = me . api . asc _getChartObject ( ) ;
if ( props ) {
me . _isEditRanges = true ;
props . startEdit ( ) ;
var win = new SSE . Views . ChartDataDialog ( {
chartSettings : props ,
api : me . api ,
handler : function ( result , value ) {
if ( result == 'ok' ) {
props . endEdit ( ) ;
me . _isEditRanges = false ;
}
Common . NotificationCenter . trigger ( 'edit:complete' , me ) ;
}
} ) . on ( 'close' , function ( ) {
me . _isEditRanges && props . cancelEdit ( ) ;
me . _isEditRanges = false ;
} ) ;
win . show ( ) ;
}
}
} ,
2020-12-08 09:48:23 +00:00
onEditChartType : function ( btn ) {
if ( ! this . editMode ) return ;
var me = this ;
var props ;
if ( me . api ) {
props = me . api . asc _getChartObject ( ) ;
if ( props ) {
me . _isEditType = true ;
props . startEdit ( ) ;
var win = new SSE . Views . ChartTypeDialog ( {
chartSettings : props ,
api : me . api ,
handler : function ( result , value ) {
if ( result == 'ok' ) {
props . endEdit ( ) ;
me . _isEditType = false ;
}
Common . NotificationCenter . trigger ( 'edit:complete' , me ) ;
}
} ) . on ( 'close' , function ( ) {
me . _isEditType && props . cancelEdit ( ) ;
me . _isEditType = false ;
} ) ;
win . show ( ) ;
}
}
} ,
2019-09-02 09:52:14 +00:00
onSelectChart : function ( group , type ) {
if ( ! this . editMode ) return ;
2016-12-16 08:37:57 +00:00
var me = this ,
info = me . api . asc _getCellInfo ( ) ,
2021-03-23 14:51:50 +00:00
seltype = info . asc _getSelectionType ( ) ;
2016-12-16 08:37:57 +00:00
2019-10-02 07:15:36 +00:00
if ( me . api ) {
2016-09-14 13:34:08 +00:00
var win , props ;
2021-03-23 14:51:50 +00:00
var ischartedit = ( seltype == Asc . c _oAscSelectionType . RangeChart || seltype == Asc . c _oAscSelectionType . RangeChartText ) ;
props = me . api . asc _getChartObject ( true ) ; // don't lock chart object
if ( props ) {
2021-05-21 09:28:54 +00:00
if ( ischartedit )
props . changeType ( type ) ;
else {
props . putType ( type ) ;
var range = props . getRange ( ) ,
isvalid = ( ! _ . isEmpty ( range ) ) ? me . api . asc _checkDataRange ( Asc . c _oAscSelectionDialogType . Chart , range , true , props . getInRows ( ) , props . getType ( ) ) : Asc . c _oAscError . ID . No ;
if ( isvalid == Asc . c _oAscError . ID . No ) {
me . api . asc _addChartDrawingObject ( props ) ;
} else {
var msg = me . txtInvalidRange ;
switch ( isvalid ) {
case Asc . c _oAscError . ID . StockChartError :
msg = me . errorStockChart ;
break ;
case Asc . c _oAscError . ID . MaxDataSeriesError :
msg = me . errorMaxRows ;
break ;
case Asc . c _oAscError . ID . ComboSeriesError :
msg = me . errorComboSeries ;
break ;
2021-03-23 14:51:50 +00:00
}
2021-05-21 09:28:54 +00:00
Common . UI . warning ( {
msg : msg ,
callback : function ( ) {
_ . defer ( function ( btn ) {
Common . NotificationCenter . trigger ( 'edit:complete' , me . toolbar ) ;
} )
}
} ) ;
}
2016-09-14 13:34:08 +00:00
}
2021-03-22 19:21:03 +00:00
}
}
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
} ,
onSelectSpark : function ( type ) {
if ( ! this . editMode ) return ;
var me = this ,
info = me . api . asc _getCellInfo ( ) ,
seltype = info . asc _getSelectionType ( ) ;
if ( me . api ) {
if ( seltype == Asc . c _oAscSelectionType . RangeCells || seltype == Asc . c _oAscSelectionType . RangeCol ||
seltype == Asc . c _oAscSelectionType . RangeRow || seltype == Asc . c _oAscSelectionType . RangeMax ) {
2016-12-16 08:37:57 +00:00
var sparkLineInfo = info . asc _getSparklineInfo ( ) ;
if ( ! ! sparkLineInfo ) {
var props = new Asc . sparklineGroup ( ) ;
2019-09-02 09:52:14 +00:00
props . asc _setType ( type ) ;
2016-12-16 08:37:57 +00:00
this . api . asc _setSparklineGroup ( sparkLineInfo . asc _getId ( ) , props ) ;
2016-09-14 13:34:08 +00:00
} else {
2021-03-23 14:51:50 +00:00
var me = this ;
( new SSE . Views . CreateSparklineDialog (
{
api : me . api ,
2021-03-24 15:39:00 +00:00
props : { selectedCells : me . _state . selectedCells } ,
2021-03-23 14:51:50 +00:00
handler : function ( result , settings ) {
if ( result == 'ok' && settings ) {
me . view && me . view . fireEvent ( 'insertspark' , me . view ) ;
if ( settings . destination )
me . api . asc _addSparklineGroup ( type , settings . source , settings . destination ) ;
}
Common . NotificationCenter . trigger ( 'edit:complete' , me ) ;
2017-04-18 13:16:03 +00:00
}
2021-03-23 14:51:50 +00:00
} ) ) . show ( ) ;
2016-09-14 13:34:08 +00:00
}
}
}
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
} ,
2021-03-24 15:39:00 +00:00
onApiMathChanged : function ( info ) {
this . _state . selectedCells = info . asc _getCount ( ) ; // not empty cells
} ,
2019-09-03 10:52:52 +00:00
onInsertTextart : function ( data ) {
if ( this . api ) {
this . toolbar . fireEvent ( 'inserttextart' , this . toolbar ) ;
this . api . asc _addTextArt ( data ) ;
if ( this . toolbar . btnInsertShape . pressed )
this . toolbar . btnInsertShape . toggle ( false , true ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar , this . toolbar . btnInsertTextArt ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Add Text Art' ) ;
}
} ,
2016-03-11 00:48:53 +00:00
onBtnInsertTextClick : function ( btn , e ) {
2022-10-05 21:01:02 +00:00
btn . menu . items . forEach ( function ( item ) {
if ( item . value == btn . options . textboxType )
item . setChecked ( true ) ;
} ) ;
if ( ! this . toolbar . btnInsertText . pressed ) {
this . toolbar . btnInsertText . menu . clearAll ( ) ;
}
this . onInsertText ( btn . options . textboxType , btn , e ) ;
} ,
onMenuInsertTextClick : function ( btn , e ) {
var oldType = this . toolbar . btnInsertText . options . textboxType ;
var newType = e . value ;
this . toolbar . btnInsertText . toggle ( true ) ;
if ( newType != oldType ) {
this . toolbar . btnInsertText . changeIcon ( {
next : e . options . iconClsForMainBtn ,
curr : this . toolbar . btnInsertText . menu . items . filter ( function ( item ) { return item . value == oldType } ) [ 0 ] . options . iconClsForMainBtn
} ) ;
this . toolbar . btnInsertText . updateHint ( [ e . caption , this . views . Toolbar . prototype . tipInsertText ] ) ;
this . toolbar . btnInsertText . options . textboxType = newType ;
}
this . onInsertText ( newType , btn , e ) ;
} ,
onInsertText : function ( type , btn , e ) {
2016-03-11 00:48:53 +00:00
if ( this . api )
2022-10-02 18:31:12 +00:00
this . _addAutoshape ( this . toolbar . btnInsertText . pressed , type ) ;
2016-03-11 00:48:53 +00:00
if ( this . toolbar . btnInsertShape . pressed )
this . toolbar . btnInsertShape . toggle ( false , true ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar , this . toolbar . btnInsertShape ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Add Text' ) ;
} ,
onInsertShapeHide : function ( btn , e ) {
if ( this . toolbar . btnInsertShape . pressed && ! this . _isAddingShape ) {
this . toolbar . btnInsertShape . toggle ( false , true ) ;
}
this . _isAddingShape = false ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
} ,
onSortType : function ( type , btn ) {
2021-07-19 21:02:30 +00:00
Common . NotificationCenter . trigger ( 'protect:check' , this . onSortTypeCallback , this , [ type , btn ] ) ;
} ,
onSortTypeCallback : function ( type , btn ) {
2017-02-06 14:12:59 +00:00
if ( this . api ) {
2020-06-05 16:28:11 +00:00
if ( this . api . asc _getCellInfo ( ) . asc _getSelectionType ( ) == Asc . c _oAscSelectionType . RangeSlicer ) {
var selectedObjects = this . api . asc _getGraphicObjectProps ( ) ;
for ( var i = 0 ; i < selectedObjects . length ; i ++ ) {
if ( selectedObjects [ i ] . asc _getObjectType ( ) == Asc . c _oAscTypeSelectElement . Image ) {
var elValue = selectedObjects [ i ] . asc _getObjectValue ( ) ;
if ( elValue . asc _getSlicerProperties ( ) ) {
elValue . asc _getSlicerProperties ( ) . asc _setSortOrder ( type == Asc . c _oAscSortOptions . Ascending ? Asc . ST _tabularSlicerCacheSortOrder . Ascending : Asc . ST _tabularSlicerCacheSortOrder . Descending ) ;
this . api . asc _setGraphicObjectProps ( elValue ) ;
break ;
2017-02-06 14:12:59 +00:00
}
2020-06-05 16:28:11 +00:00
}
}
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
} else {
2021-08-10 21:24:12 +00:00
var me = this ;
2020-06-05 16:28:11 +00:00
var res = this . api . asc _sortCellsRangeExpand ( ) ;
2021-08-10 21:24:12 +00:00
switch ( res ) {
case Asc . c _oAscSelectionSortExpand . showExpandMessage :
var config = {
width : 500 ,
title : this . txtSorting ,
msg : this . txtExpandSort ,
buttons : [ { caption : this . txtExpand , primary : true , value : 'expand' } ,
{ caption : this . txtSortSelected , primary : true , value : 'sort' } ,
'cancel' ] ,
callback : function ( btn ) {
if ( btn == 'expand' || btn == 'sort' ) {
me . api . asc _sortColFilter ( type , '' , undefined , undefined , btn == 'expand' )
}
2020-06-05 16:28:11 +00:00
}
2021-08-10 21:24:12 +00:00
} ;
Common . UI . alert ( config ) ;
break ;
case Asc . c _oAscSelectionSortExpand . showLockMessage :
var config = {
width : 500 ,
title : this . txtSorting ,
msg : this . txtLockSort ,
buttons : [ 'yes' , 'no' ] ,
primary : 'yes' ,
callback : function ( btn ) {
( btn == 'yes' ) && me . api . asc _sortColFilter ( type , '' , undefined , undefined , false ) ;
}
} ;
Common . UI . alert ( config ) ;
break ;
case Asc . c _oAscSelectionSortExpand . expandAndNotShowMessage :
case Asc . c _oAscSelectionSortExpand . notExpandAndNotShowMessage :
this . api . asc _sortColFilter ( type , '' , undefined , undefined , res === Asc . c _oAscSelectionSortExpand . expandAndNotShowMessage ) ;
break ;
}
2020-06-05 16:28:11 +00:00
}
2017-02-06 14:12:59 +00:00
}
2016-03-11 00:48:53 +00:00
} ,
2022-05-30 17:46:20 +00:00
searchShow : function ( ) {
2022-06-10 14:36:11 +00:00
if ( this . toolbar . btnSearch ) {
if ( this . searchBar && this . searchBar . isVisible ( ) ) {
this . searchBar . focus ( ) ;
return ;
}
2022-05-30 17:46:20 +00:00
this . toolbar . btnSearch . toggle ( true ) ;
}
} ,
2016-03-11 00:48:53 +00:00
onSearch : function ( type , btn ) {
2022-05-30 17:46:20 +00:00
if ( ! this . searchBar ) {
this . searchBar = new Common . UI . SearchBar ( {
showOpenPanel : false ,
width : 303
} ) ;
this . searchBar . on ( 'hide' , _ . bind ( function ( ) {
this . toolbar . btnSearch . toggle ( false , true ) ;
} , this ) ) ;
}
if ( this . toolbar . btnSearch . pressed ) {
this . searchBar . show ( this . api . asc _GetSelectedText ( ) ) ;
} else {
this . searchBar . hide ( ) ;
}
2016-03-11 00:48:53 +00:00
} ,
onAutoFilter : function ( btn ) {
var state = this . _state . filter ;
this . _state . filter = undefined ;
if ( this . api ) {
if ( this . _state . tablename || state )
2016-04-05 11:52:34 +00:00
this . api . asc _changeAutoFilter ( this . _state . tablename , Asc . c _oAscChangeFilterOptions . filter , ! state ) ;
2016-03-11 00:48:53 +00:00
else
this . api . asc _addAutoFilter ( ) ;
}
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Auto filter' ) ;
} ,
onClearFilter : function ( btn ) {
if ( this . api )
this . api . asc _clearFilter ( ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Clear filter' ) ;
} ,
onNumberFormat : function ( btn ) {
2016-08-24 08:35:32 +00:00
if ( this . api )
this . api . asc _setCellStyle ( btn . options . styleName ) ;
2016-03-11 00:48:53 +00:00
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Number Format' ) ;
} ,
onNumberFormatMenu : function ( menu , item ) {
2017-04-11 11:05:56 +00:00
if ( this . api ) {
2019-06-28 14:41:18 +00:00
if ( item . value == - 1 ) {
// show more formats
2019-07-08 09:12:41 +00:00
if ( this . _state . numformatinfo && this . _state . numformatinfo . asc _getType ( ) == Asc . c _oAscNumFormatType . Accounting )
this . onCustomNumberFormat ( ) ;
else {
var value = this . api . asc _getLocale ( ) ;
( ! value ) && ( value = ( ( this . toolbar . mode . lang ) ? parseInt ( Common . util . LanguageInfo . getLocalLanguageCode ( this . toolbar . mode . lang ) ) : 0x0409 ) ) ;
var info = new Asc . asc _CFormatCellsInfo ( ) ;
info . asc _setType ( Asc . c _oAscNumFormatType . Accounting ) ;
info . asc _setSeparator ( false ) ;
info . asc _setSymbol ( value ) ;
var format = this . api . asc _getFormatCells ( info ) ;
this . onCustomNumberFormat ( ( format && format . length > 0 ) ? format [ 0 ] : undefined , info ) ;
}
2019-06-28 14:41:18 +00:00
} else {
var info = new Asc . asc _CFormatCellsInfo ( ) ;
info . asc _setType ( Asc . c _oAscNumFormatType . Accounting ) ;
info . asc _setSeparator ( false ) ;
info . asc _setSymbol ( item . value ) ;
var format = this . api . asc _getFormatCells ( info ) ;
if ( format && format . length > 0 )
this . api . asc _setCellFormat ( format [ 0 ] ) ;
}
2017-04-11 11:05:56 +00:00
}
2016-03-11 00:48:53 +00:00
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Number Format' ) ;
} ,
2017-01-12 14:14:51 +00:00
onNumberFormatSelect : function ( combo , record ) {
2017-01-16 08:48:21 +00:00
if ( record ) {
if ( this . api )
this . api . asc _setCellFormat ( record . format ) ;
} else {
2017-01-17 13:40:18 +00:00
this . onCustomNumberFormat ( ) ;
2017-01-16 08:48:21 +00:00
}
2017-01-12 14:14:51 +00:00
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Number Format' ) ;
} ,
2019-07-08 09:12:41 +00:00
onCustomNumberFormat : function ( format , formatInfo ) {
2017-01-17 13:40:18 +00:00
var me = this ,
2017-06-01 13:48:33 +00:00
value = me . api . asc _getLocale ( ) ;
( ! value ) && ( value = ( ( me . toolbar . mode . lang ) ? parseInt ( Common . util . LanguageInfo . getLocalLanguageCode ( me . toolbar . mode . lang ) ) : 0x0409 ) ) ;
2017-01-17 13:40:18 +00:00
( new SSE . Views . FormatSettingsDialog ( {
api : me . api ,
handler : function ( result , settings ) {
if ( settings ) {
me . api . asc _setCellFormat ( settings . format ) ;
}
Common . NotificationCenter . trigger ( 'edit:complete' , me . toolbar ) ;
} ,
2019-07-08 09:12:41 +00:00
props : { format : format ? format : me . _state . numformat , formatInfo : formatInfo ? formatInfo : me . _state . numformatinfo , langId : value }
2017-01-17 13:40:18 +00:00
} ) ) . show ( ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Number Format' ) ;
} ,
2017-01-12 14:14:51 +00:00
onNumberFormatOpenBefore : function ( combo ) {
if ( this . api ) {
2017-06-01 13:48:33 +00:00
var me = this ,
value = me . api . asc _getLocale ( ) ;
( ! value ) && ( value = ( ( me . toolbar . mode . lang ) ? parseInt ( Common . util . LanguageInfo . getLocalLanguageCode ( me . toolbar . mode . lang ) ) : 0x0409 ) ) ;
2017-01-17 12:58:20 +00:00
if ( this . _state . langId !== value ) {
this . _state . langId = value ;
var info = new Asc . asc _CFormatCellsInfo ( ) ;
info . asc _setType ( Asc . c _oAscNumFormatType . None ) ;
info . asc _setSymbol ( this . _state . langId ) ;
var arr = this . api . asc _getFormatCells ( info ) ; // all formats
me . toolbar . numFormatData . forEach ( function ( item , index ) {
me . toolbar . numFormatData [ index ] . format = arr [ index ] ;
} ) ;
}
2017-01-12 14:14:51 +00:00
me . toolbar . numFormatData . forEach ( function ( item , index ) {
2017-01-17 10:15:36 +00:00
item . exampleval = me . api . asc _getLocaleExample ( item . format ) ;
2017-01-12 14:14:51 +00:00
} ) ;
me . toolbar . cmbNumberFormat . setData ( me . toolbar . numFormatData ) ;
me . toolbar . cmbNumberFormat . setValue ( me . _state . numformattype , me . toolbar . txtCustom ) ;
}
} ,
2016-03-11 00:48:53 +00:00
onDecrement : function ( btn ) {
if ( this . api )
this . api . asc _decreaseCellDigitNumbers ( ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Decrement' ) ;
} ,
onIncrement : function ( btn ) {
if ( this . api )
this . api . asc _increaseCellDigitNumbers ( ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Increment' ) ;
} ,
onInsertFormulaMenu : function ( menu , item , e ) {
if ( this . api ) {
if ( item . value === 'more' ) {
var controller = this . getApplication ( ) . getController ( 'FormulaDialog' ) ;
if ( controller ) {
controller . showDialog ( ) ;
}
} else {
item . value = item . value || 'SUM' ;
2019-06-24 12:57:28 +00:00
this . toolbar . fireEvent ( 'function:apply' , [ { name : this . api . asc _getFormulaLocaleName ( item . value ) , origin : item . value } , true ] ) ;
2016-03-11 00:48:53 +00:00
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Insert formula' ) ;
}
}
} ,
onNamedRangeMenu : function ( menu , item , e ) {
if ( this . api ) {
var me = this ;
if ( item . value === 'paste' ) {
( new SSE . Views . NamedRangePasteDlg ( {
handler : function ( result , settings ) {
if ( result == 'ok' && settings ) {
2020-06-10 10:38:50 +00:00
me . api . asc _insertInCell ( settings . asc _getName ( true ) , ( settings . asc _getType ( ) === Asc . c _oAscDefNameType . table ) ? Asc . c _oAscPopUpSelectorType . Table : Asc . c _oAscPopUpSelectorType . Range , false ) ;
2016-03-11 00:48:53 +00:00
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Paste Named Range' ) ;
}
Common . NotificationCenter . trigger ( 'edit:complete' , me . toolbar ) ;
} ,
2016-04-05 11:52:34 +00:00
ranges : me . api . asc _getDefinedNames ( Asc . c _oAscGetDefinedNamesList . WorksheetWorkbook ) // names only for current sheet and workbook
2016-03-11 00:48:53 +00:00
} ) ) . show ( ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Paste Named Range' ) ;
} else {
var wc = me . api . asc _getWorksheetsCount ( ) ,
i = - 1 ,
items = [ ] , sheetNames = [ ] ;
if ( item . value === 'new' ) {
if ( this . _state . namedrange _locked ) {
Common . NotificationCenter . trigger ( 'namedrange:locked' ) ;
return ;
}
while ( ++ i < wc ) {
if ( ! this . api . asc _isWorksheetHidden ( i ) ) {
items . push ( { displayValue : me . api . asc _getWorksheetName ( i ) , value : i } ) ;
}
}
( new SSE . Views . NamedRangeEditDlg ( {
api : me . api ,
handler : function ( result , settings ) {
if ( result == 'ok' && settings ) {
me . api . asc _setDefinedNames ( settings ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'New Named Range' ) ;
}
Common . NotificationCenter . trigger ( 'edit:complete' , me . toolbar ) ;
} ,
sheets : items ,
props : me . api . asc _getDefaultDefinedName ( ) ,
isEdit : false
} ) ) . show ( ) ;
} else {
var cellEditor = this . getApplication ( ) . getController ( 'CellEditor' ) ;
while ( ++ i < wc ) {
if ( ! this . api . asc _isWorksheetHidden ( i ) ) {
sheetNames [ i ] = me . api . asc _getWorksheetName ( i ) ;
items . push ( { displayValue : sheetNames [ i ] , value : i } ) ;
}
}
( new SSE . Views . NameManagerDlg ( {
api : me . api ,
handler : function ( result ) {
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Name Manager' ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , me . toolbar ) ;
} ,
locked : me . _state . namedrange _locked ,
sheets : items ,
sheetNames : sheetNames ,
2016-04-05 11:52:34 +00:00
ranges : me . api . asc _getDefinedNames ( Asc . c _oAscGetDefinedNamesList . All ) ,
2016-03-11 00:48:53 +00:00
props : me . api . asc _getDefaultDefinedName ( ) ,
sort : cellEditor . rangeListSort
} ) ) . on ( 'close' , function ( win ) {
cellEditor . rangeListSort = win . getSettings ( ) ;
} ) . show ( ) ;
}
}
}
} ,
2020-02-26 10:49:57 +00:00
onNamedRangeMenuOpen : function ( menu ) {
if ( this . api && menu ) {
2016-04-05 11:52:34 +00:00
var names = this . api . asc _getDefinedNames ( Asc . c _oAscGetDefinedNamesList . WorksheetWorkbook ) ;
2020-02-26 10:49:57 +00:00
menu . items [ 2 ] . setDisabled ( names . length < 1 ) ;
2016-03-11 00:48:53 +00:00
}
} ,
onClearStyleMenu : function ( menu , item , e ) {
2021-08-11 15:42:03 +00:00
if ( item . value == Asc . c _oAscCleanOptions . Format && ( ! this . _state . wsProps [ 'FormatCells' ] || ! this . api . asc _checkLockedCells ( ) ) ||
item . value == Asc . c _oAscCleanOptions . All && ! this . api . asc _checkLockedCells ( ) )
2021-08-10 14:49:40 +00:00
this . onClearStyleMenuCallback ( menu , item ) ;
else if ( item . value == Asc . c _oAscCleanOptions . Comments ) {
this . _state . wsProps [ 'Objects' ] ? Common . NotificationCenter . trigger ( 'showerror' , Asc . c _oAscError . ID . ChangeOnProtectedSheet , Asc . c _oAscError . Level . NoCritical ) : this . onClearStyleMenuCallback ( menu , item ) ;
} else
Common . NotificationCenter . trigger ( 'protect:check' , this . onClearStyleMenuCallback , this , [ menu , item ] ) ;
2021-07-20 10:03:44 +00:00
} ,
onClearStyleMenuCallback : function ( menu , item , e ) {
2021-03-23 15:16:31 +00:00
if ( this . api ) {
if ( item . value == Asc . c _oAscCleanOptions . Comments ) {
this . api . asc _RemoveAllComments ( ! this . mode . canDeleteComments , true ) ; // 1 param = true if remove only my comments, 2 param - remove current comments
} else
this . api . asc _emptyCells ( item . value , item . value == Asc . c _oAscCleanOptions . All && ! this . mode . canDeleteComments ) ;
}
2016-03-11 00:48:53 +00:00
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Clear' ) ;
} ,
onCopyStyleToggle : function ( btn , state , e ) {
if ( this . api )
this . api . asc _formatPainter ( state ? 1 : 0 ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
this . modeAlwaysSetStyle = state ;
} ,
onCellInsertMenu : function ( menu , item , e ) {
if ( this . api )
this . api . asc _insertCells ( item . value ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Cell insert' ) ;
} ,
onCellDeleteMenu : function ( menu , item , e ) {
if ( this . api )
this . api . asc _deleteCells ( item . value ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Cell delete' ) ;
} ,
onColorSchemaClick : function ( menu , item ) {
if ( this . api ) {
2019-12-19 08:00:49 +00:00
this . api . asc _ChangeColorSchemeByIdx ( item . value ) ;
2016-03-11 00:48:53 +00:00
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Color Scheme' ) ;
}
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
} ,
2019-08-20 12:56:29 +00:00
onColorSchemaShow : function ( menu ) {
if ( this . api ) {
2019-12-19 08:00:49 +00:00
var value = this . api . asc _GetCurrentColorSchemeIndex ( ) ;
2019-08-20 12:56:29 +00:00
var item = _ . find ( menu . items , function ( item ) { return item . value == value ; } ) ;
( item ) ? item . setChecked ( true ) : menu . clearAll ( ) ;
}
} ,
2016-03-11 00:48:53 +00:00
onComboBlur : function ( ) {
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
} ,
onFontNameSelect : function ( combo , record ) {
if ( this . api ) {
if ( record . isNewFont ) {
2020-04-22 09:35:55 +00:00
! Common . Utils . ModalWindow . isVisible ( ) &&
2016-03-11 00:48:53 +00:00
Common . UI . warning ( {
width : 500 ,
msg : this . confirmAddFontName ,
buttons : [ 'yes' , 'no' ] ,
primary : 'yes' ,
callback : _ . bind ( function ( btn ) {
if ( btn == 'yes' ) {
this . api . asc _setCellFontName ( record . name ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Font Name' ) ;
} else {
2020-05-15 07:42:00 +00:00
this . toolbar . cmbFontName . setValue ( this . api . asc _getCellInfo ( ) . asc _getXfs ( ) . asc _getFontName ( ) ) ;
2016-03-11 00:48:53 +00:00
}
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar , { restorefocus : true } ) ;
} , this )
} ) ;
} else {
this . api . asc _setCellFontName ( record . name ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Font Name' ) ;
}
}
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar , { restorefocus : true } ) ;
} ,
onComboOpen : function ( needfocus , combo ) {
_ . delay ( function ( ) {
var input = $ ( 'input' , combo . cmpEl ) . select ( ) ;
if ( needfocus ) input . focus ( ) ;
else if ( ! combo . isMenuOpen ( ) ) input . one ( 'mouseup' , function ( e ) { e . preventDefault ( ) ; } ) ;
} , 10 ) ;
} ,
onFontSizeSelect : function ( combo , record ) {
this . _state . fontsize = undefined ;
if ( this . api )
this . api . asc _setCellFontSize ( record . value ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar , { restorefocus : true } ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Font Size' ) ;
} ,
onFontSizeChanged : function ( before , combo , record , e ) {
var value ,
me = this ;
if ( before ) {
var item = combo . store . findWhere ( {
displayValue : record . value
} ) ;
if ( ! item ) {
2020-03-31 13:49:33 +00:00
value = /^\+?(\d*(\.|,)?\d+)$|^\+?(\d+(\.|,)?\d*)$/ . exec ( record . value ) ;
2016-03-11 00:48:53 +00:00
if ( ! value ) {
value = this . _getApiTextSize ( ) ;
2022-02-16 19:51:34 +00:00
setTimeout ( function ( ) {
Common . UI . warning ( {
msg : me . textFontSizeErr ,
callback : function ( ) {
_ . defer ( function ( btn ) {
$ ( 'input' , combo . cmpEl ) . focus ( ) ;
} )
}
} ) ;
} , 1 ) ;
2016-03-11 00:48:53 +00:00
combo . setRawValue ( value ) ;
e . preventDefault ( ) ;
return false ;
}
}
} else {
2020-03-31 13:49:33 +00:00
value = Common . Utils . String . parseFloat ( record . value ) ;
2016-03-11 00:48:53 +00:00
value = value > 409 ? 409 :
value < 1 ? 1 : Math . floor ( ( value + 0.4 ) * 2 ) / 2 ;
combo . setRawValue ( value ) ;
this . _state . fontsize = undefined ;
if ( this . api )
this . api . asc _setCellFontSize ( value ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
}
} ,
onListStyleSelect : function ( combo , record ) {
this . _state . prstyle = undefined ;
if ( this . api ) {
this . api . asc _setCellStyle ( record . get ( 'name' ) ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Style' ) ;
}
} ,
2021-03-15 20:10:47 +00:00
onShowBeforeCondFormat : function ( cmp , id ) {
if ( cmp . mnuDataBars . menu . items . length > 0 ) // menu is inited
2021-03-03 11:05:31 +00:00
return ;
2021-03-15 20:10:47 +00:00
cmp . btnCondFormat . menu . on ( 'item:click' , _ . bind ( this . onCondFormatMenu , this ) ) ;
for ( var i = 0 ; i < 7 ; i ++ ) {
cmp . btnCondFormat . menu . items [ i ] . menu . on ( 'item:click' , _ . bind ( this . onCondFormatMenu , this ) ) ;
}
cmp . btnCondFormat . menu . items [ 15 ] . menu . on ( 'item:click' , _ . bind ( this . onCondFormatMenu , this ) ) ;
2021-03-03 11:05:31 +00:00
var collectionPresets = SSE . getCollection ( 'ConditionalFormatIconsPresets' ) ;
if ( collectionPresets . length < 1 )
SSE . getController ( 'Main' ) . fillCondFormatIconsPresets ( this . api . asc _getCFIconsByType ( ) ) ;
2021-03-02 21:30:04 +00:00
var collectionIcons = SSE . getCollection ( 'ConditionalFormatIcons' ) ;
if ( collectionIcons . length < 1 )
SSE . getController ( 'Main' ) . fillCondFormatIcons ( this . api . asc _getFullCFIcons ( ) ) ;
2021-02-25 15:45:24 +00:00
var me = this ;
2021-03-15 20:10:47 +00:00
var menuItem = cmp . mnuDataBars ;
2021-02-25 15:45:24 +00:00
menuItem . menu . addItem ( new Common . UI . MenuItem ( {
2021-03-15 20:10:47 +00:00
template : _ . template ( '<div id="id-' + id + '-menu-databar" class="menu-shapes" style="margin-left: 5px; width: 203px;"></div>' )
2021-02-25 15:45:24 +00:00
} ) ) ;
var picker = new Common . UI . DataViewSimple ( {
2021-03-15 20:10:47 +00:00
el : $ ( '#id-' + id + '-menu-databar' , menuItem . $el ) ,
2021-02-25 15:45:24 +00:00
parentMenu : menuItem . menu ,
2021-02-26 13:36:24 +00:00
itemTemplate : _ . template ( '<div class="item-databar" id="<%= id %>"><svg width="25" height="25" class=\"icon\"><use xlink:href=\"#bar-<%= data.name %>\"></use></svg></div>' )
2021-02-25 15:45:24 +00:00
} ) ;
picker . on ( 'item:click' , function ( picker , item , record , e ) {
if ( me . api ) {
if ( record ) {
me . api . asc _setCF ( [ ] , [ ] , [ Asc . c _oAscCFRuleTypeSettings . dataBar , record . get ( 'data' ) . index ] ) ;
}
if ( e . type !== 'click' )
2021-03-15 20:10:47 +00:00
cmp . btnCondFormat . menu . hide ( ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , cmp , cmp . btnCondFormat ) ;
2021-02-25 15:45:24 +00:00
}
} ) ;
var arr = [
{ data : { name : 'gradient-blue' , index : 0 } } ,
{ data : { name : 'gradient-green' , index : 1 } } ,
{ data : { name : 'gradient-red' , index : 2 } } ,
{ data : { name : 'gradient-yellow' , index : 3 } } ,
{ data : { name : 'gradient-lightblue' , index : 4 } } ,
{ data : { name : 'gradient-purple' , index : 5 } } ,
{ data : { name : 'solid-blue' , index : 6 } } ,
{ data : { name : 'solid-green' , index : 7 } } ,
{ data : { name : 'solid-red' , index : 8 } } ,
{ data : { name : 'solid-yellow' , index : 9 } } ,
{ data : { name : 'solid-lightblue' , index : 10 } } ,
{ data : { name : 'solid-purple' , index : 11 } }
] ;
picker . setStore ( new Common . UI . DataViewStore ( arr ) ) ;
2021-03-15 20:10:47 +00:00
menuItem = cmp . mnuColorScales ;
2021-02-25 15:45:24 +00:00
menuItem . menu . addItem ( new Common . UI . MenuItem ( {
2021-03-15 20:10:47 +00:00
template : _ . template ( '<div id="id-' + id + '-menu-colorscales" class="menu-shapes" style="margin-left: 5px; width: 136px;"></div>' )
2021-02-25 15:45:24 +00:00
} ) ) ;
picker = new Common . UI . DataViewSimple ( {
2021-03-15 20:10:47 +00:00
el : $ ( '#id-' + id + '-menu-colorscales' , menuItem . $el ) ,
2021-02-25 15:45:24 +00:00
parentMenu : menuItem . menu ,
2021-02-26 13:36:24 +00:00
itemTemplate : _ . template ( '<div class="item-colorscale" id="<%= id %>"><svg width="25" height="25" class=\"icon\"><use xlink:href=\"#color-scale-<%= data.name %>\"></use></svg></div>' )
2021-02-25 15:45:24 +00:00
} ) ;
picker . on ( 'item:click' , function ( picker , item , record , e ) {
if ( me . api ) {
if ( record ) {
me . api . asc _setCF ( [ ] , [ ] , [ Asc . c _oAscCFRuleTypeSettings . colorScale , record . get ( 'data' ) . index ] ) ;
}
if ( e . type !== 'click' )
2021-03-15 20:10:47 +00:00
cmp . btnCondFormat . menu . hide ( ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , cmp , cmp . btnCondFormat ) ;
2021-02-25 15:45:24 +00:00
}
} ) ;
arr = [
{ data : { name : 'green-yellow-red' , index : 0 } } ,
{ data : { name : 'red-yellow-green' , index : 1 } } ,
{ data : { name : 'green-white-red' , index : 2 } } ,
{ data : { name : 'red-white-green' , index : 3 } } ,
{ data : { name : 'blue-white-red' , index : 4 } } ,
{ data : { name : 'red-white-blue' , index : 5 } } ,
{ data : { name : 'white-red' , index : 6 } } ,
{ data : { name : 'red-white' , index : 7 } } ,
{ data : { name : 'green-white' , index : 8 } } ,
{ data : { name : 'white-green' , index : 9 } } ,
{ data : { name : 'green-yellow' , index : 10 } } ,
{ data : { name : 'yellow-green' , index : 11 } }
] ;
picker . setStore ( new Common . UI . DataViewStore ( arr ) ) ;
2021-03-15 20:10:47 +00:00
menuItem = cmp . mnuIconSets ;
2021-02-25 20:15:05 +00:00
menuItem . menu . addItem ( new Common . UI . MenuItem ( {
2021-03-15 20:10:47 +00:00
template : _ . template ( '<div id="id-' + id + '-menu-iconsets" class="menu-iconsets" style="width: 227px;"></div>' )
2021-02-25 15:45:24 +00:00
} ) ) ;
2021-02-25 20:15:05 +00:00
arr = [ ] ;
var indexes = [ Asc . EIconSetType . Arrows3 , Asc . EIconSetType . Arrows3Gray , Asc . EIconSetType . Triangles3 , Asc . EIconSetType . Arrows4Gray , Asc . EIconSetType . Arrows4 , Asc . EIconSetType . Arrows5Gray , Asc . EIconSetType . Arrows5 ] ;
for ( var i = 0 ; i < indexes . length ; i ++ ) {
2021-03-03 11:05:31 +00:00
arr . push ( { group : 'menu-iconset-group-direct' , data : { index : indexes [ i ] , iconSet : collectionPresets . at ( [ indexes [ i ] ] ) . get ( 'icons' ) , icons : collectionIcons } } ) ;
2021-02-25 20:15:05 +00:00
}
indexes = [ Asc . EIconSetType . Traffic3Lights1 , Asc . EIconSetType . Traffic3Lights2 , Asc . EIconSetType . Signs3 , Asc . EIconSetType . Traffic4Lights , Asc . EIconSetType . RedToBlack4 ] ;
for ( var i = 0 ; i < indexes . length ; i ++ ) {
2021-03-03 11:05:31 +00:00
arr . push ( { group : 'menu-iconset-group-shape' , data : { index : indexes [ i ] , iconSet : collectionPresets . at ( [ indexes [ i ] ] ) . get ( 'icons' ) , icons : collectionIcons } } ) ;
2021-02-25 20:15:05 +00:00
}
indexes = [ Asc . EIconSetType . Symbols3 , Asc . EIconSetType . Symbols3 _2 , Asc . EIconSetType . Flags3 ] ;
for ( var i = 0 ; i < indexes . length ; i ++ ) {
2021-03-03 11:05:31 +00:00
arr . push ( { group : 'menu-iconset-group-indicator' , data : { index : indexes [ i ] , iconSet : collectionPresets . at ( [ indexes [ i ] ] ) . get ( 'icons' ) , icons : collectionIcons } } ) ;
2021-02-25 20:15:05 +00:00
}
indexes = [ Asc . EIconSetType . Stars3 , Asc . EIconSetType . Rating4 , Asc . EIconSetType . Quarters5 , Asc . EIconSetType . Rating5 , Asc . EIconSetType . Boxes5 ] ;
for ( var i = 0 ; i < indexes . length ; i ++ ) {
2021-03-03 11:05:31 +00:00
arr . push ( { group : 'menu-iconset-group-rating' , data : { index : indexes [ i ] , iconSet : collectionPresets . at ( [ indexes [ i ] ] ) . get ( 'icons' ) , icons : collectionIcons } } ) ;
2021-02-25 20:15:05 +00:00
}
picker = new Common . UI . DataView ( {
2021-03-15 20:10:47 +00:00
el : $ ( '#id-' + id + '-menu-iconsets' , menuItem . $el ) ,
2021-02-25 20:15:05 +00:00
parentMenu : menuItem . menu ,
groups : new Common . UI . DataViewGroupStore ( [
{ id : 'menu-iconset-group-direct' , caption : this . textDirectional } ,
{ id : 'menu-iconset-group-shape' , caption : this . textShapes } ,
{ id : 'menu-iconset-group-indicator' , caption : this . textIndicator } ,
{ id : 'menu-iconset-group-rating' , caption : this . textRating }
] ) ,
store : new Common . UI . DataViewStore ( arr ) ,
2021-03-02 21:30:04 +00:00
showLast : false ,
2021-02-25 20:15:05 +00:00
itemTemplate : _ . template ( '<div class="item-iconset" id="<%= id %>">' +
2021-03-02 21:30:04 +00:00
'<% _.each(data.iconSet, function(icon) { %>' +
'<img src="<%= data.icons.at(icon-1).get(\'icon\') %>" style="width:16px;height:16px;">' +
2021-02-25 20:15:05 +00:00
'<% }) %>' +
'</div>' )
} ) ;
picker . on ( 'item:click' , function ( picker , item , record , e ) {
if ( me . api ) {
if ( record ) {
me . api . asc _setCF ( [ ] , [ ] , [ Asc . c _oAscCFRuleTypeSettings . icons , record . get ( 'data' ) . index ] ) ;
}
if ( e . type !== 'click' )
2021-03-15 20:10:47 +00:00
cmp . btnCondFormat . menu . hide ( ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , cmp , cmp . btnCondFormat ) ;
2021-02-25 20:15:05 +00:00
}
} ) ;
2021-02-25 15:45:24 +00:00
} ,
2020-04-14 14:31:47 +00:00
onCondFormatMenu : function ( menu , item ) {
2020-04-17 11:16:09 +00:00
var me = this ;
2020-05-19 16:57:24 +00:00
var value = this . api . asc _getLocale ( ) ;
( ! value ) && ( value = ( ( this . toolbar . mode . lang ) ? parseInt ( Common . util . LanguageInfo . getLocalLanguageCode ( this . toolbar . mode . lang ) ) : 0x0409 ) ) ;
2020-04-14 14:31:47 +00:00
if ( item . value == 'manage' ) {
2020-04-15 17:08:56 +00:00
( new SSE . Views . FormatRulesManagerDlg ( {
api : me . api ,
2020-05-19 16:57:24 +00:00
langId : value ,
2021-03-12 09:41:05 +00:00
locked : ! ! me . _state . cf _locked [ this . api . asc _getActiveWorksheetIndex ( ) ] ,
2020-04-15 17:08:56 +00:00
handler : function ( result , settings ) {
2021-01-26 16:41:51 +00:00
if ( me && me . api && result == 'ok' ) {
2021-01-28 15:21:07 +00:00
me . api . asc _setCF ( settings . rules , settings . deleted ) ;
2020-04-14 14:31:47 +00:00
}
2020-04-15 17:08:56 +00:00
}
} ) ) . show ( ) ;
2020-04-17 11:16:09 +00:00
} else if ( item . value == 'clear' ) {
2021-02-24 15:49:05 +00:00
me . api . asc _clearCF ( item . options . type ) ;
2020-04-17 11:16:09 +00:00
} else {
( new SSE . Views . FormatRulesEditDlg ( {
api : me . api ,
props : null ,
type : item . options . type ,
subtype : item . value ,
2021-03-15 15:31:39 +00:00
percent : item . options . percent ,
2020-04-17 11:16:09 +00:00
isEdit : false ,
2020-05-19 16:57:24 +00:00
langId : value ,
2020-04-17 11:16:09 +00:00
handler : function ( result , settings ) {
if ( result == 'ok' && settings ) {
2021-03-10 09:14:44 +00:00
me . api . asc _setCF ( [ settings ] , [ ] ) ;
2020-04-17 11:16:09 +00:00
}
}
} ) ) . show ( ) ;
2020-04-14 14:31:47 +00:00
}
} ,
2016-03-11 00:48:53 +00:00
createDelayedElements : function ( ) {
var me = this ;
2016-08-24 14:46:45 +00:00
this . toolbar . createDelayedElements ( ) ;
2017-04-28 14:28:35 +00:00
this . attachUIEvents ( this . toolbar ) ;
2016-08-24 14:46:45 +00:00
2022-03-11 10:58:15 +00:00
if ( ! this . appConfig . isEditDiagram && ! this . appConfig . isEditMailMerge && ! this . appConfig . isEditOle ) {
2017-04-27 15:40:27 +00:00
this . api . asc _registerCallback ( 'asc_onSheetsChanged' , _ . bind ( this . onApiSheetChanged , this ) ) ;
this . api . asc _registerCallback ( 'asc_onUpdateSheetViewSettings' , _ . bind ( this . onApiSheetChanged , this ) ) ;
2017-04-28 12:24:57 +00:00
this . api . asc _registerCallback ( 'asc_onEndAddShape' , _ . bind ( this . onApiEndAddShape , this ) ) ;
2017-04-28 13:37:28 +00:00
this . api . asc _registerCallback ( 'asc_onEditorSelectionChanged' , _ . bind ( this . onApiEditorSelectionChanged , this ) ) ;
2018-07-19 12:48:12 +00:00
this . api . asc _registerCallback ( 'asc_onUpdateDocumentProps' , _ . bind ( this . onUpdateDocumentProps , this ) ) ;
this . api . asc _registerCallback ( 'asc_onLockDocumentProps' , _ . bind ( this . onApiLockDocumentProps , this ) ) ;
this . api . asc _registerCallback ( 'asc_onUnLockDocumentProps' , _ . bind ( this . onApiUnLockDocumentProps , this ) ) ;
2021-07-16 22:31:56 +00:00
Common . NotificationCenter . on ( 'protect:wslock' , _ . bind ( this . onChangeProtectSheet , this ) ) ;
2017-04-28 13:37:28 +00:00
}
2022-05-31 08:34:43 +00:00
if ( this . appConfig . isEditOle ) {
this . api . asc _registerCallback ( 'asc_onEditorSelectionChanged' , _ . bind ( this . onApiEditorSelectionChanged _OleEditor , this ) ) ;
}
2017-04-28 13:37:28 +00:00
if ( ! this . appConfig . isEditMailMerge ) {
this . applyFormulaSettings ( ) ;
2017-04-27 15:40:27 +00:00
}
2016-03-11 00:48:53 +00:00
this . api . asc _registerCallback ( 'asc_onShowChartDialog' , _ . bind ( this . onApiChartDblClick , this ) ) ;
this . api . asc _registerCallback ( 'asc_onCanUndoChanged' , _ . bind ( this . onApiCanRevert , this , 'undo' ) ) ;
this . api . asc _registerCallback ( 'asc_onCanRedoChanged' , _ . bind ( this . onApiCanRevert , this , 'redo' ) ) ;
this . api . asc _registerCallback ( 'asc_onEditCell' , _ . bind ( this . onApiEditCell , this ) ) ;
this . api . asc _registerCallback ( 'asc_onStopFormatPainter' , _ . bind ( this . onApiStyleChange , this ) ) ;
2017-04-28 12:24:57 +00:00
this . api . asc _registerCallback ( 'asc_onSelectionChanged' , _ . bind ( this . onApiSelectionChanged , this ) ) ;
2016-03-11 00:48:53 +00:00
2020-08-14 13:58:41 +00:00
var shortcuts = {
2016-03-11 00:48:53 +00:00
'command+l,ctrl+l' : function ( e ) {
2021-07-17 21:22:55 +00:00
if ( me . editMode && ! me . _state . multiselect && me . appConfig . canModifyFilter && ! me . _state . wsLock ) {
2017-09-18 10:41:39 +00:00
var cellinfo = me . api . asc _getCellInfo ( ) ,
filterinfo = cellinfo . asc _getAutoFilterInfo ( ) ,
formattableinfo = cellinfo . asc _getFormatTableInfo ( ) ;
filterinfo = ( filterinfo ) ? filterinfo . asc _getIsAutoFilter ( ) : null ;
if ( filterinfo !== null && ! formattableinfo ) {
2019-06-10 11:50:12 +00:00
me . _setTableFormat ( me . api . asc _getDefaultTableStyle ( ) ) ;
2017-04-11 11:05:56 +00:00
}
2016-03-15 10:53:55 +00:00
}
2016-03-11 00:48:53 +00:00
return false ;
} ,
'command+shift+l,ctrl+shift+l' : function ( e ) {
2021-07-17 21:22:55 +00:00
if ( me . editMode && me . api && ! me . _state . multiselect && me . appConfig . canModifyFilter && ! me . _state . wsLock ) {
2017-10-19 10:14:12 +00:00
var state = me . _state . filter ;
me . _state . filter = undefined ;
2016-03-11 00:48:53 +00:00
if ( me . _state . tablename || state )
2016-04-05 11:52:34 +00:00
me . api . asc _changeAutoFilter ( me . _state . tablename , Asc . c _oAscChangeFilterOptions . filter , ! state ) ;
2016-03-11 00:48:53 +00:00
else
me . api . asc _addAutoFilter ( ) ;
}
return false ;
} ,
'command+s,ctrl+s' : function ( e ) {
me . onSave ( ) ;
e . preventDefault ( ) ;
e . stopPropagation ( ) ;
} ,
'command+k,ctrl+k' : function ( e ) {
2022-03-11 10:58:15 +00:00
if ( me . editMode && ! me . toolbar . mode . isEditMailMerge && ! me . toolbar . mode . isEditDiagram && ! me . toolbar . mode . isEditOle && ! me . api . isCellEdited && ! me . _state . multiselect && ! me . _state . inpivot &&
2021-07-17 21:22:55 +00:00
! me . getApplication ( ) . getController ( 'LeftMenu' ) . leftMenu . menuFile . isVisible ( ) && ! me . _state . wsProps [ 'InsertHyperlinks' ] ) {
2020-02-05 12:31:45 +00:00
var cellinfo = me . api . asc _getCellInfo ( ) ,
2020-05-14 08:39:04 +00:00
selectionType = cellinfo . asc _getSelectionType ( ) ;
2020-02-05 12:31:45 +00:00
if ( selectionType !== Asc . c _oAscSelectionType . RangeShapeText || me . api . asc _canAddShapeHyperlink ( ) !== false )
me . onHyperlink ( ) ;
}
2016-03-11 00:48:53 +00:00
e . preventDefault ( ) ;
2017-01-17 13:40:18 +00:00
} ,
'command+1,ctrl+1' : function ( e ) {
2022-03-11 10:58:15 +00:00
if ( me . editMode && ! me . toolbar . mode . isEditMailMerge && ! me . toolbar . mode . isEditOle && ! me . api . isCellEdited && ! me . toolbar . cmbNumberFormat . isDisabled ( ) ) {
2017-01-17 13:40:18 +00:00
me . onCustomNumberFormat ( ) ;
}
2020-05-07 16:42:27 +00:00
return false ;
} ,
'shift+f3' : function ( e ) {
if ( me . editMode && ! me . toolbar . btnInsertFormula . isDisabled ( ) ) {
var controller = me . getApplication ( ) . getController ( 'FormulaDialog' ) ;
if ( controller ) {
controller . showDialog ( ) ;
}
}
2020-05-08 17:18:53 +00:00
return false ;
2020-08-14 13:58:41 +00:00
}
} ;
2022-11-23 09:55:22 +00:00
shortcuts [ 'command+shift+=,ctrl+shift+=,command+shift+numplus,ctrl+shift+numplus' + ( Common . Utils . isGecko ? ',command+shift+ff=,ctrl+shift+ff=' : '' ) ] = function ( e ) {
2022-11-03 20:02:33 +00:00
if ( me . editMode && ! me . toolbar . mode . isEditMailMerge && ! me . toolbar . mode . isEditDiagram && ! me . toolbar . mode . isEditOle && ! me . toolbar . btnAddCell . isDisabled ( ) ) {
2020-08-13 12:03:53 +00:00
var cellinfo = me . api . asc _getCellInfo ( ) ,
selectionType = cellinfo . asc _getSelectionType ( ) ;
if ( selectionType === Asc . c _oAscSelectionType . RangeRow || selectionType === Asc . c _oAscSelectionType . RangeCol ) {
2021-07-17 21:22:55 +00:00
( selectionType === Asc . c _oAscSelectionType . RangeRow ) && ! me . toolbar . btnAddCell . menu . items [ 2 ] . isDisabled ( ) && me . api . asc _insertCells ( Asc . c _oAscInsertOptions . InsertRows ) ;
( selectionType === Asc . c _oAscSelectionType . RangeCol ) && ! me . toolbar . btnAddCell . menu . items [ 3 ] . isDisabled ( ) && me . api . asc _insertCells ( Asc . c _oAscInsertOptions . InsertColumns ) ;
2020-08-13 12:03:53 +00:00
Common . NotificationCenter . trigger ( 'edit:complete' , me . toolbar ) ;
} else {
var items = me . toolbar . btnAddCell . menu . items ,
2021-07-17 21:22:55 +00:00
arr = [ ] ,
enabled = false ;
for ( var i = 0 ; i < 4 ; i ++ ) {
2020-08-13 12:03:53 +00:00
arr . push ( { caption : items [ i ] . caption , value : items [ i ] . value , disabled : items [ i ] . isDisabled ( ) } ) ;
2021-07-17 21:22:55 +00:00
! items [ i ] . isDisabled ( ) && ( enabled = true ) ;
}
enabled && ( new Common . Views . OptionsDialog ( {
2020-08-13 12:03:53 +00:00
title : me . txtInsertCells ,
items : arr ,
handler : function ( dlg , result ) {
if ( result == 'ok' ) {
me . api . asc _insertCells ( dlg . getSettings ( ) ) ;
}
Common . NotificationCenter . trigger ( 'edit:complete' , me . toolbar ) ;
2020-05-08 17:18:53 +00:00
}
2020-08-13 12:03:53 +00:00
} ) ) . show ( ) ;
}
2020-05-08 17:18:53 +00:00
}
return false ;
2020-08-14 13:58:41 +00:00
} ;
2022-11-23 09:55:22 +00:00
shortcuts [ 'command+shift+-,ctrl+shift+-,command+shift+numminus,ctrl+shift+numminus' + ( Common . Utils . isGecko ? ',command+shift+ff-,ctrl+shift+ff-' : '' ) ] = function ( e ) {
2022-11-03 20:02:33 +00:00
if ( me . editMode && ! me . toolbar . mode . isEditMailMerge && ! me . toolbar . mode . isEditDiagram && ! me . toolbar . mode . isEditOle && ! me . toolbar . btnDeleteCell . isDisabled ( ) ) {
2020-08-13 12:03:53 +00:00
var cellinfo = me . api . asc _getCellInfo ( ) ,
selectionType = cellinfo . asc _getSelectionType ( ) ;
if ( selectionType === Asc . c _oAscSelectionType . RangeRow || selectionType === Asc . c _oAscSelectionType . RangeCol ) {
me . api . asc _deleteCells ( selectionType === Asc . c _oAscSelectionType . RangeRow ? Asc . c _oAscDeleteOptions . DeleteRows : Asc . c _oAscDeleteOptions . DeleteColumns ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , me . toolbar ) ;
} else {
var items = me . toolbar . btnDeleteCell . menu . items ,
2021-07-17 21:22:55 +00:00
arr = [ ] ,
enabled = false ;
for ( var i = 0 ; i < 4 ; i ++ ) {
2020-08-13 12:03:53 +00:00
arr . push ( { caption : items [ i ] . caption , value : items [ i ] . value , disabled : items [ i ] . isDisabled ( ) } ) ;
2021-07-17 21:22:55 +00:00
! items [ i ] . isDisabled ( ) && ( enabled = true ) ;
}
enabled && ( new Common . Views . OptionsDialog ( {
2020-08-13 12:03:53 +00:00
title : me . txtDeleteCells ,
items : arr ,
handler : function ( dlg , result ) {
if ( result == 'ok' ) {
me . api . asc _deleteCells ( dlg . getSettings ( ) ) ;
}
Common . NotificationCenter . trigger ( 'edit:complete' , me . toolbar ) ;
2020-05-08 17:18:53 +00:00
}
2020-08-13 12:03:53 +00:00
} ) ) . show ( ) ;
}
2020-05-08 17:18:53 +00:00
}
2017-01-17 13:40:18 +00:00
return false ;
2020-08-14 13:58:41 +00:00
} ;
Common . util . Shortcuts . delegateShortcuts ( { shortcuts : shortcuts } ) ;
2016-03-11 00:48:53 +00:00
2021-07-16 22:31:56 +00:00
this . onChangeProtectSheet ( ) ;
2016-03-11 00:48:53 +00:00
this . attachToControlEvents ( ) ;
this . onApiSheetChanged ( ) ;
Common . NotificationCenter . on ( 'cells:range' , _ . bind ( this . onCellsRange , this ) ) ;
} ,
onChangeViewMode : function ( item , compact ) {
2018-05-17 10:44:46 +00:00
this . toolbar . setFolded ( compact ) ;
2017-04-27 15:40:27 +00:00
this . toolbar . fireEvent ( 'view:compact' , [ this , compact ] ) ;
2016-03-11 00:48:53 +00:00
2017-04-27 15:40:27 +00:00
Common . localStorage . setBool ( 'sse-compact-toolbar' , compact ) ;
Common . NotificationCenter . trigger ( 'layout:changed' , 'toolbar' ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
} ,
2016-03-11 00:48:53 +00:00
2017-04-27 15:40:27 +00:00
onClickChangeCompact : function ( from ) {
if ( from != 'file' ) {
Common . Utils . asyncCall ( function ( ) {
this . onChangeViewMode ( null , ! this . toolbar . isCompact ( ) ) ;
} , this ) ;
2016-03-11 00:48:53 +00:00
}
} ,
fillTableTemplates : function ( ) {
2016-09-23 11:24:54 +00:00
if ( ! this . toolbar . btnTableTemplate . rendered ) return ;
2016-03-11 00:48:53 +00:00
2016-09-23 11:24:54 +00:00
var me = this ;
2016-03-11 00:48:53 +00:00
function createPicker ( element , menu ) {
var picker = new Common . UI . DataView ( {
el : element ,
parentMenu : menu ,
restoreHeight : 300 ,
2022-07-22 12:51:54 +00:00
groups : new Common . UI . DataViewGroupStore ( ) ,
2016-03-11 00:48:53 +00:00
style : 'max-height: 300px;' ,
store : me . getCollection ( 'TableTemplates' ) ,
2021-09-08 15:42:05 +00:00
itemTemplate : _ . template ( '<div class="item-template"><img src="<%= imageUrl %>" id="<%= id %>" style="width:60px;height:44px;"></div>' ) ,
delayRenderTips : true
2016-03-11 00:48:53 +00:00
} ) ;
picker . on ( 'item:click' , function ( picker , item , record ) {
if ( me . api ) {
me . _state . tablestylename = null ;
2019-06-10 11:50:12 +00:00
me . _setTableFormat ( record ? record . get ( 'name' ) : me . api . asc _getDefaultTableStyle ( ) ) ;
2016-03-11 00:48:53 +00:00
Common . NotificationCenter . trigger ( 'edit:complete' , me . toolbar ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Table Templates' ) ;
}
} ) ;
if ( picker . scroller ) {
picker . scroller . update ( { alwaysVisibleY : true } ) ;
}
return picker ;
}
if ( _ . isUndefined ( this . toolbar . mnuTableTemplatePicker ) ) {
this . toolbar . mnuTableTemplatePicker = createPicker ( $ ( '#id-toolbar-menu-table-templates' ) , this . toolbar . btnTableTemplate . menu ) ;
}
// if (_.isUndefined(this.toolbar.mnuTableTemplatePickerShort)) {
// this.toolbar.mnuTableTemplatePickerShort = createPicker($('#id-toolbar-short-menu-table-templates'));
// }
} ,
2022-08-29 13:55:13 +00:00
onTableTplMenuOpen : function ( menu ) {
2016-11-29 12:48:18 +00:00
this . onApiInitTableTemplates ( this . api . asc _getTablePictures ( this . api . asc _getCellInfo ( ) . asc _getFormatTableInfo ( ) ) ) ;
2016-03-11 00:48:53 +00:00
2022-08-29 13:55:13 +00:00
if ( menu && this . toolbar . mnuTableTemplatePicker ) {
var picker = this . toolbar . mnuTableTemplatePicker ,
columnCount = 7 ;
if ( picker . cmpEl ) {
var itemEl = $ ( picker . cmpEl . find ( '.dataview.inner .item-template' ) . get ( 0 ) ) . parent ( ) ,
itemMargin = 8 ,
itemWidth = itemEl . is ( ':visible' ) ? parseFloat ( itemEl . css ( 'width' ) ) : 60 ;
var menuWidth = columnCount * ( itemMargin + itemWidth ) + 11 , // for scroller
menuMargins = parseFloat ( picker . cmpEl . css ( 'margin-left' ) ) + parseFloat ( picker . cmpEl . css ( 'margin-right' ) ) ;
if ( menuWidth + menuMargins > Common . Utils . innerWidth ( ) )
menuWidth = Math . max ( Math . floor ( ( Common . Utils . innerWidth ( ) - menuMargins - 11 ) / ( itemMargin + itemWidth ) ) , 2 ) * ( itemMargin + itemWidth ) + 11 ;
picker . cmpEl . css ( {
'width' : menuWidth
} ) ;
menu . alignPosition ( ) ;
}
}
2016-11-29 12:48:18 +00:00
var scroller = this . toolbar . mnuTableTemplatePicker . scroller ;
2016-03-11 00:48:53 +00:00
if ( scroller ) {
scroller . update ( { alwaysVisibleY : true } ) ;
scroller . scrollTop ( 0 ) ;
}
2017-01-19 11:46:00 +00:00
var val = this . toolbar . mnuTableTemplatePicker . store . findWhere ( { name : this . _state . tablestylename } ) ;
if ( val )
this . toolbar . mnuTableTemplatePicker . selectRecord ( val ) ;
else
2017-01-19 12:08:55 +00:00
this . toolbar . mnuTableTemplatePicker . deselectAll ( ) ;
2016-03-11 00:48:53 +00:00
} ,
2016-11-29 12:48:18 +00:00
onSendThemeColors : function ( ) {
// get new table templates
if ( this . toolbar . btnTableTemplate . rendered && this . toolbar . btnTableTemplate . cmpEl . hasClass ( 'open' ) )
this . onTableTplMenuOpen ( ) ;
} ,
2016-03-11 00:48:53 +00:00
onApiInitTableTemplates : function ( images ) {
2019-09-19 10:31:23 +00:00
var me = this ;
2016-03-11 00:48:53 +00:00
var store = this . getCollection ( 'TableTemplates' ) ;
2022-07-22 12:51:54 +00:00
this . fillTableTemplates ( ) ;
2016-03-11 00:48:53 +00:00
if ( store ) {
var templates = [ ] ;
2022-07-22 12:51:54 +00:00
var groups = [
2022-07-23 13:15:32 +00:00
{ id : 'menu-table-group-custom' , caption : me . txtGroupTable _Custom , templates : [ ] } ,
{ id : 'menu-table-group-light' , caption : me . txtGroupTable _Light , templates : [ ] } ,
{ id : 'menu-table-group-medium' , caption : me . txtGroupTable _Medium , templates : [ ] } ,
{ id : 'menu-table-group-dark' , caption : me . txtGroupTable _Dark , templates : [ ] } ,
{ id : 'menu-table-group-no-name' , caption : ' ' , templates : [ ] } ,
2022-07-22 12:51:54 +00:00
] ;
2016-03-11 00:48:53 +00:00
_ . each ( images , function ( item ) {
2019-09-19 10:31:23 +00:00
var tip = item . asc _getDisplayName ( ) ;
2022-07-22 12:51:54 +00:00
var groupItem = '' ;
2022-07-23 13:15:32 +00:00
2019-09-19 10:31:23 +00:00
if ( item . asc _getType ( ) == 0 ) {
var arr = tip . split ( ' ' ) ,
last = arr . pop ( ) ;
2022-07-23 13:15:32 +00:00
if ( tip == 'None' ) {
groupItem = 'menu-table-group-light' ;
2022-07-22 12:51:54 +00:00
}
2022-07-23 13:15:32 +00:00
else {
if ( arr . length > 0 ) {
groupItem = 'menu-table-group-' + arr [ arr . length - 1 ] . toLowerCase ( ) ;
}
if ( groups . some ( function ( item ) { return item . id === groupItem ; } ) == false ) {
groupItem = 'menu-table-group-no-name' ;
}
2022-07-22 12:51:54 +00:00
}
2019-09-19 10:31:23 +00:00
arr = 'txtTable_' + arr . join ( '' ) ;
tip = me [ arr ] ? me [ arr ] + ' ' + last : tip ;
}
2022-07-22 12:51:54 +00:00
else {
groupItem = 'menu-table-group-custom'
}
2022-07-23 13:15:32 +00:00
groups . filter ( function ( item ) { return item . id == groupItem ; } ) [ 0 ] . templates . push ( {
2016-03-11 00:48:53 +00:00
name : item . asc _getName ( ) ,
caption : item . asc _getDisplayName ( ) ,
type : item . asc _getType ( ) ,
imageUrl : item . asc _getImage ( ) ,
2022-07-22 12:51:54 +00:00
group : groupItem ,
2016-03-11 00:48:53 +00:00
allowSelected : true ,
2016-11-29 12:01:29 +00:00
selected : false ,
2019-09-19 10:31:23 +00:00
tip : tip
2016-03-11 00:48:53 +00:00
} ) ;
} ) ;
2022-07-23 13:15:32 +00:00
groups = groups . filter ( function ( item , index ) {
return item . templates . length > 0
} ) ;
2022-07-22 12:51:54 +00:00
2022-07-23 13:15:32 +00:00
groups . forEach ( function ( item ) {
templates = templates . concat ( item . templates ) ;
delete item . templates ;
} ) ;
2022-07-22 12:51:54 +00:00
me . toolbar . mnuTableTemplatePicker . groups . reset ( groups ) ;
2019-08-30 13:24:15 +00:00
store . reset ( templates ) ;
2016-03-11 00:48:53 +00:00
}
} ,
2022-09-22 19:06:58 +00:00
onCellStyleMenuOpen : function ( menu ) {
if ( menu && this . toolbar . mnuCellStylePicker ) {
var picker = this . toolbar . mnuCellStylePicker ,
columnCount = 6 ;
if ( picker . cmpEl ) {
var itemEl = $ ( picker . cmpEl . find ( '.dataview.inner .item' ) . get ( 0 ) ) ,
itemMargin = parseFloat ( itemEl . css ( 'margin-left' ) ) + parseFloat ( itemEl . css ( 'margin-right' ) ) ,
itemWidth = itemEl . is ( ':visible' ) ? parseFloat ( itemEl . css ( 'width' ) ) : 106 ;
var menuWidth = columnCount * ( itemMargin + itemWidth ) + 15 , // for scroller
menuMargins = parseFloat ( picker . cmpEl . css ( 'margin-left' ) ) + parseFloat ( picker . cmpEl . css ( 'margin-right' ) ) ;
if ( menuWidth + menuMargins > Common . Utils . innerWidth ( ) )
menuWidth = Math . max ( Math . floor ( ( Common . Utils . innerWidth ( ) - menuMargins - 11 ) / ( itemMargin + itemWidth ) ) , 2 ) * ( itemMargin + itemWidth ) + 11 ;
picker . cmpEl . css ( {
'width' : menuWidth
} ) ;
menu . alignPosition ( ) ;
}
}
var scroller = this . toolbar . mnuCellStylePicker . scroller ;
if ( scroller ) {
scroller . update ( { alwaysVisibleY : true } ) ;
scroller . scrollTop ( 0 ) ;
}
var val = this . toolbar . mnuCellStylePicker . store . findWhere ( { name : this . _state . prstyle } ) ;
if ( val )
this . toolbar . mnuCellStylePicker . selectRecord ( val ) ;
else
this . toolbar . mnuCellStylePicker . deselectAll ( ) ;
2016-03-11 00:48:53 +00:00
} ,
onApiInitEditorStyles : function ( styles ) {
window . styles _loaded = false ;
2022-09-22 19:06:58 +00:00
if ( this . toolbar . mode . isEditOle ) {
var me = this ;
function createPicker ( element , menu ) {
var picker = new Common . UI . DataView ( {
el : element ,
parentMenu : menu ,
restoreHeight : 380 ,
groups : new Common . UI . DataViewGroupStore ( ) ,
store : new Common . UI . DataViewStore ( ) ,
style : 'max-height: 380px;' ,
itemTemplate : _ . template ( '<div class="style"><img src="<%= imageUrl %>" id="<%= id %>" style="width:100px;height:20px;"></div>' ) ,
delayRenderTips : true
} ) ;
picker . on ( 'item:click' , function ( picker , item , record ) {
me . onListStyleSelect ( picker , record ) ;
} ) ;
if ( picker . scroller ) {
picker . scroller . update ( { alwaysVisibleY : true } ) ;
}
return picker ;
}
if ( _ . isUndefined ( this . toolbar . mnuCellStylePicker ) ) {
this . toolbar . mnuCellStylePicker = createPicker ( $ ( '#id-toolbar-menu-cell-styles' ) , this . toolbar . btnCellStyle . menu ) ;
}
}
2016-03-11 00:48:53 +00:00
var self = this ,
2022-09-30 14:05:01 +00:00
listStyles = this . toolbar . mode . isEditOle ? self . toolbar . mnuCellStylePicker : self . toolbar . listStyles ;
2016-03-11 00:48:53 +00:00
if ( ! listStyles ) {
self . styles = styles ;
return ;
}
2022-09-30 14:05:01 +00:00
var menuPicker = this . toolbar . mode . isEditOle ? listStyles : listStyles . menuPicker ;
2017-06-27 09:52:29 +00:00
var mainController = this . getApplication ( ) . getController ( 'Main' ) ;
2022-09-22 19:06:58 +00:00
var count = menuPicker . store . length ;
var rec = menuPicker . getSelectedRec ( ) ;
var groupStore = [
{ id : 'menu-style-group-custom' , caption : this . txtGroupCell _Custom } ,
{ id : 'menu-style-group-color' , caption : this . txtGroupCell _GoodBadAndNeutral } ,
{ id : 'menu-style-group-model' , caption : this . txtGroupCell _DataAndModel } ,
{ id : 'menu-style-group-title' , caption : this . txtGroupCell _TitlesAndHeadings } ,
{ id : 'menu-style-group-themed' , caption : this . txtGroupCell _ThemedCallStyles } ,
{ id : 'menu-style-group-number' , caption : this . txtGroupCell _NumberFormat } ,
{ id : 'menu-style-group-no-name' , caption : this . txtGroupCell _NoName }
] ;
2022-07-13 16:22:06 +00:00
var groups = [ ] ;
2022-07-15 12:56:54 +00:00
for ( var i = 0 ; i < 4 ; i ++ ) { groups . push ( 'menu-style-group-color' ) ; }
for ( var i = 0 ; i < 8 ; i ++ ) { groups . push ( 'menu-style-group-model' ) ; }
for ( var i = 0 ; i < 6 ; i ++ ) { groups . push ( 'menu-style-group-title' ) ; }
for ( var i = 0 ; i < 24 ; i ++ ) { groups . push ( 'menu-style-group-themed' ) ; }
for ( var i = 0 ; i < 5 ; i ++ ) { groups . push ( 'menu-style-group-number' ) ; }
2022-07-13 16:22:06 +00:00
2020-09-16 13:40:09 +00:00
if ( count > 0 && count == styles . length ) {
2022-09-22 19:06:58 +00:00
var data = menuPicker . dataViewItems ;
2020-09-16 13:40:09 +00:00
data && _ . each ( styles , function ( style , index ) {
var img = style . asc _getImage ( ) ;
data [ index ] . model . set ( 'imageUrl' , img , { silent : true } ) ;
data [ index ] . model . set ( {
name : style . asc _getName ( ) ,
tip : mainController . translationTable [ style . get _Name ( ) ] || style . get _Name ( )
} ) ;
$ ( data [ index ] . el ) . find ( 'img' ) . attr ( 'src' , img ) ;
2016-03-11 00:48:53 +00:00
} ) ;
2020-09-16 13:40:09 +00:00
} else {
var arr = [ ] ;
2022-07-13 16:22:06 +00:00
var countCustomStyles = 0 ;
2022-07-19 17:45:41 +00:00
var hasNoNameGroup = false ;
2022-07-13 16:22:06 +00:00
_ . each ( styles , function ( style , index ) {
2022-07-19 17:45:41 +00:00
var styleGroup ;
if ( style . asc _getType ( ) == 0 ) {
if ( index - countCustomStyles < groups . length ) {
styleGroup = groups [ index - countCustomStyles ] ;
}
else {
styleGroup = 'menu-style-group-no-name' ;
hasNoNameGroup = true ;
}
}
else {
styleGroup = 'menu-style-group-custom' ;
}
2020-09-16 13:40:09 +00:00
arr . push ( {
imageUrl : style . asc _getImage ( ) ,
name : style . asc _getName ( ) ,
2022-07-19 17:45:41 +00:00
group : styleGroup ,
2020-09-16 13:40:09 +00:00
tip : mainController . translationTable [ style . get _Name ( ) ] || style . get _Name ( ) ,
uid : Common . UI . getId ( )
} ) ;
2022-07-13 16:22:06 +00:00
if ( style . asc _getType ( ) == 1 ) {
countCustomStyles += 1 ;
}
2020-09-16 13:40:09 +00:00
} ) ;
2022-07-19 17:45:41 +00:00
2022-07-13 16:22:06 +00:00
if ( countCustomStyles == 0 ) {
2022-09-22 19:06:58 +00:00
groupStore = groupStore . filter ( function ( item ) { return item . id != 'menu-style-group-custom' ; } ) ;
2022-07-13 16:22:06 +00:00
}
2022-07-19 17:45:41 +00:00
if ( hasNoNameGroup === false ) {
2022-09-22 19:06:58 +00:00
groupStore = groupStore . filter ( function ( item ) { return item . id != 'menu-style-group-no-name' ; } ) ;
2022-07-19 17:45:41 +00:00
}
2022-09-22 19:06:58 +00:00
menuPicker . groups . reset ( groupStore ) ;
menuPicker . store . reset ( arr ) ;
2020-09-16 13:40:09 +00:00
}
2022-09-22 19:06:58 +00:00
if ( ! this . toolbar . mode . isEditOle && menuPicker . store . length > 0 && listStyles . rendered ) {
rec = rec ? menuPicker . store . findWhere ( { name : rec . get ( 'name' ) } ) : null ;
listStyles . fillComboView ( rec ? rec : menuPicker . store . at ( 0 ) , true , true ) ;
2016-03-11 00:48:53 +00:00
}
window . styles _loaded = true ;
} ,
2020-09-17 13:29:48 +00:00
onHomeOpen : function ( ) {
var listStyles = this . toolbar . listStyles ;
if ( listStyles && listStyles . needFillComboView && listStyles . menuPicker . store . length > 0 && listStyles . rendered ) {
var styleRec ;
if ( this . _state . prstyle ) styleRec = listStyles . menuPicker . store . findWhere ( { name : this . _state . prstyle } ) ;
listStyles . fillComboView ( ( styleRec ) ? styleRec : listStyles . menuPicker . store . at ( 0 ) , true ) ;
}
} ,
2018-10-25 13:19:29 +00:00
onApiCoAuthoringDisconnect : function ( enableDownload ) {
this . toolbar . setMode ( { isDisconnected : true , enableDownload : ! ! enableDownload } ) ;
2016-03-11 00:48:53 +00:00
this . editMode = false ;
} ,
onApiChartDblClick : function ( ) {
2016-12-16 08:37:57 +00:00
this . onEditChart ( this . btnInsertChart ) ;
2016-03-11 00:48:53 +00:00
} ,
onApiCanRevert : function ( which , can ) {
if ( which == 'undo' ) {
if ( this . _state . can _undo !== can ) {
this . toolbar . btnUndo . setDisabled ( ! can ) ;
this . _state . can _undo = can ;
}
} else {
if ( this . _state . can _redo !== can ) {
this . toolbar . btnRedo . setDisabled ( ! can ) ;
this . _state . can _redo = can ;
}
}
} ,
setDisabledComponents : function ( components , disable ) {
_ . each ( [ ] . concat ( components ) , function ( component ) {
if ( component . isDisabled ( ) !== disable ) component . setDisabled ( disable )
} ) ;
} ,
onApiEditCell : function ( state ) {
2019-06-06 08:27:17 +00:00
if ( $ ( '.asc-window.enable-key-events:visible' ) . length > 0 ) return ;
2019-05-28 13:34:57 +00:00
2016-03-11 00:48:53 +00:00
var toolbar = this . toolbar ;
2022-05-31 20:46:19 +00:00
if ( toolbar . mode . isEditDiagram || toolbar . mode . isEditMailMerge ) {
var is _cell _edited = ( state == Asc . c _oAscCellEditorState . editStart ) ;
2021-12-29 16:41:15 +00:00
toolbar . lockToolbar ( Common . enumLock . editCell , state == Asc . c _oAscCellEditorState . editStart , { array : [ toolbar . btnDecDecimal , toolbar . btnIncDecimal , toolbar . cmbNumberFormat , toolbar . btnEditChartData , toolbar . btnEditChartType ] } ) ;
2022-05-31 20:46:19 +00:00
} else if ( toolbar . mode . isEditOle ) {
if ( state == Asc . c _oAscCellEditorState . editStart || state == Asc . c _oAscCellEditorState . editEnd ) {
var is _cell _edited = ( state == Asc . c _oAscCellEditorState . editStart ) ;
toolbar . lockToolbar ( Common . enumLock . editCell , state == Asc . c _oAscCellEditorState . editStart , { array : [ toolbar . cmbNumberFormat , toolbar . btnWrap , toolbar . btnMerge , toolbar . btnBackColor ,
toolbar . btnBorders , toolbar . btnTableTemplate , toolbar . btnHorizontalAlign , toolbar . btnVerticalAlign ] ,
merge : true ,
clear : [ Common . enumLock . editFormula , Common . enumLock . editText ] } ) ;
( is _cell _edited ) ? Common . util . Shortcuts . suspendEvents ( 'command+l, ctrl+l, command+shift+l, ctrl+shift+l' ) :
Common . util . Shortcuts . resumeEvents ( 'command+l, ctrl+l, command+shift+l, ctrl+shift+l' ) ;
} else {
if ( state == Asc . c _oAscCellEditorState . editText ) var is _text = true , is _formula = false ; else
if ( state == Asc . c _oAscCellEditorState . editFormula ) is _text = ! ( is _formula = true ) ; else
if ( state == Asc . c _oAscCellEditorState . editEmptyCell ) is _text = is _formula = false ;
toolbar . lockToolbar ( Common . enumLock . editFormula , is _formula , { array : [ toolbar . cmbFontName , toolbar . cmbFontSize , toolbar . btnTextFormatting , toolbar . btnTextColor ] } ) ;
toolbar . lockToolbar ( Common . enumLock . editText , is _text , { array : [ toolbar . btnInsertFormula ] } ) ;
}
2016-03-11 00:48:53 +00:00
} else
2016-04-05 11:52:34 +00:00
if ( state == Asc . c _oAscCellEditorState . editStart || state == Asc . c _oAscCellEditorState . editEnd ) {
2021-12-29 16:41:15 +00:00
toolbar . lockToolbar ( Common . enumLock . editCell , state == Asc . c _oAscCellEditorState . editStart , {
2016-03-11 00:48:53 +00:00
array : [
toolbar . btnClearStyle . menu . items [ 1 ] ,
toolbar . btnClearStyle . menu . items [ 2 ] ,
toolbar . btnClearStyle . menu . items [ 3 ] ,
toolbar . btnClearStyle . menu . items [ 4 ] ,
toolbar . btnNamedRange . menu . items [ 0 ] ,
toolbar . btnNamedRange . menu . items [ 1 ]
2020-02-26 10:49:57 +00:00
] . concat ( toolbar . itemsNamedRange ) ,
2016-03-11 00:48:53 +00:00
merge : true ,
2021-12-29 16:41:15 +00:00
clear : [ Common . enumLock . editFormula , Common . enumLock . editText ]
2016-03-11 00:48:53 +00:00
} ) ;
2016-04-05 11:52:34 +00:00
var is _cell _edited = ( state == Asc . c _oAscCellEditorState . editStart ) ;
2017-01-17 13:40:18 +00:00
( is _cell _edited ) ? Common . util . Shortcuts . suspendEvents ( 'command+l, ctrl+l, command+shift+l, ctrl+shift+l, command+k, ctrl+k, alt+h, command+1, ctrl+1' ) :
Common . util . Shortcuts . resumeEvents ( 'command+l, ctrl+l, command+shift+l, ctrl+shift+l, command+k, ctrl+k, alt+h, command+1, ctrl+1' ) ;
2016-03-11 00:48:53 +00:00
if ( is _cell _edited ) {
toolbar . listStyles . suspendEvents ( ) ;
toolbar . listStyles . menuPicker . selectRecord ( null ) ;
toolbar . listStyles . resumeEvents ( ) ;
this . _state . prstyle = undefined ;
}
2021-06-10 15:43:36 +00:00
if ( this . appConfig . isDesktopApp && this . appConfig . canProtect ) {
this . getApplication ( ) . getController ( 'Common.Controllers.Protection' ) . SetDisabled ( is _cell _edited , false ) ;
}
2016-03-11 00:48:53 +00:00
} else {
2016-04-05 11:52:34 +00:00
if ( state == Asc . c _oAscCellEditorState . editText ) var is _text = true , is _formula = false ; else
if ( state == Asc . c _oAscCellEditorState . editFormula ) is _text = ! ( is _formula = true ) ; else
if ( state == Asc . c _oAscCellEditorState . editEmptyCell ) is _text = is _formula = false ;
2016-03-11 00:48:53 +00:00
2021-12-29 16:41:15 +00:00
toolbar . lockToolbar ( Common . enumLock . editFormula , is _formula ,
2016-03-11 00:48:53 +00:00
{ array : [ toolbar . cmbFontName , toolbar . cmbFontSize , toolbar . btnIncFontSize , toolbar . btnDecFontSize ,
2017-12-05 13:58:01 +00:00
toolbar . btnBold , toolbar . btnItalic , toolbar . btnUnderline , toolbar . btnStrikeout , toolbar . btnSubscript , toolbar . btnTextColor ] } ) ;
2021-12-29 16:41:15 +00:00
toolbar . lockToolbar ( Common . enumLock . editText , is _text , { array : [ toolbar . btnInsertFormula ] . concat ( toolbar . btnsFormula ) } ) ;
2016-03-11 00:48:53 +00:00
}
this . _state . coauthdisable = undefined ;
this . _state . selection _type = undefined ;
this . checkInsertAutoshape ( { action : 'cancel' } ) ;
} ,
2018-03-21 11:28:28 +00:00
onApiZoomChange : function ( zf , type ) { } ,
2016-03-11 00:48:53 +00:00
2018-07-19 12:48:12 +00:00
2018-06-28 09:27:11 +00:00
onApiSheetChanged : function ( ) {
2022-03-11 10:58:15 +00:00
if ( ! this . toolbar . mode || ! this . toolbar . mode . isEdit || this . toolbar . mode . isEditDiagram || this . toolbar . mode . isEditMailMerge || this . toolbar . mode . isEditOle ) return ;
2018-06-28 09:27:11 +00:00
2018-07-19 12:48:12 +00:00
var currentSheet = this . api . asc _getActiveWorksheetIndex ( ) ,
props = this . api . asc _getPageOptions ( currentSheet ) ,
2018-06-28 09:27:11 +00:00
opt = props . asc _getPageSetup ( ) ;
this . onApiPageOrient ( opt . asc _getOrientation ( ) ) ;
this . onApiPageSize ( opt . asc _getWidth ( ) , opt . asc _getHeight ( ) ) ;
this . onApiPageMargins ( props . asc _getPageMargins ( ) ) ;
2019-09-12 07:15:07 +00:00
this . onChangeScaleSettings ( opt . asc _getFitToWidth ( ) , opt . asc _getFitToHeight ( ) , opt . asc _getScale ( ) ) ;
2021-10-27 11:11:23 +00:00
this . onApiGridLines ( props . asc _getGridLines ( ) ) ;
this . onApiHeadings ( props . asc _getHeadings ( ) ) ;
2018-07-19 12:48:12 +00:00
this . api . asc _isLayoutLocked ( currentSheet ) ? this . onApiLockDocumentProps ( currentSheet ) : this . onApiUnLockDocumentProps ( currentSheet ) ;
2021-12-29 16:41:15 +00:00
this . toolbar . lockToolbar ( Common . enumLock . printAreaLock , this . api . asc _isPrintAreaLocked ( currentSheet ) , { array : [ this . toolbar . btnPrintArea ] } ) ;
2018-07-19 12:48:12 +00:00
} ,
onUpdateDocumentProps : function ( nIndex ) {
if ( nIndex == this . api . asc _getActiveWorksheetIndex ( ) )
this . onApiSheetChanged ( ) ;
2018-06-28 09:27:11 +00:00
} ,
2021-10-27 11:11:23 +00:00
onApiGridLines : function ( checked ) {
this . toolbar . chPrintGridlines . setValue ( checked , true ) ;
} ,
onApiHeadings : function ( checked ) {
this . toolbar . chPrintHeadings . setValue ( checked , true ) ;
} ,
2018-06-28 09:27:11 +00:00
onApiPageSize : function ( w , h ) {
if ( this . _state . pgorient === undefined ) return ;
2018-08-10 10:46:19 +00:00
if ( Math . abs ( this . _state . pgsize [ 0 ] - w ) > 0.1 ||
Math . abs ( this . _state . pgsize [ 1 ] - h ) > 0.1 ) {
2018-06-28 09:27:11 +00:00
this . _state . pgsize = [ w , h ] ;
if ( this . toolbar . mnuPageSize ) {
this . toolbar . mnuPageSize . clearAll ( ) ;
_ . each ( this . toolbar . mnuPageSize . items , function ( item ) {
if ( item . value && typeof ( item . value ) == 'object' &&
2018-08-10 10:46:19 +00:00
Math . abs ( item . value [ 0 ] - w ) < 0.1 && Math . abs ( item . value [ 1 ] - h ) < 0.1 ) {
2018-06-28 09:27:11 +00:00
item . setChecked ( true ) ;
return false ;
}
} , this ) ;
}
}
} ,
onApiPageMargins : function ( props ) {
if ( props ) {
var left = props . asc _getLeft ( ) ,
top = props . asc _getTop ( ) ,
right = props . asc _getRight ( ) ,
bottom = props . asc _getBottom ( ) ;
2018-08-10 10:46:19 +00:00
if ( ! this . _state . pgmargins || Math . abs ( this . _state . pgmargins [ 0 ] - top ) > 0.1 ||
Math . abs ( this . _state . pgmargins [ 1 ] - left ) > 0.1 || Math . abs ( this . _state . pgmargins [ 2 ] - bottom ) > 0.1 ||
Math . abs ( this . _state . pgmargins [ 3 ] - right ) > 0.1 ) {
2018-06-28 09:27:11 +00:00
this . _state . pgmargins = [ top , left , bottom , right ] ;
if ( this . toolbar . btnPageMargins . menu ) {
this . toolbar . btnPageMargins . menu . clearAll ( ) ;
_ . each ( this . toolbar . btnPageMargins . menu . items , function ( item ) {
if ( item . value && typeof ( item . value ) == 'object' &&
2018-08-10 10:46:19 +00:00
Math . abs ( item . value [ 0 ] - top ) < 0.1 && Math . abs ( item . value [ 1 ] - left ) < 0.1 &&
Math . abs ( item . value [ 2 ] - bottom ) < 0.1 && Math . abs ( item . value [ 3 ] - right ) < 0.1 ) {
2018-06-28 09:27:11 +00:00
item . setChecked ( true ) ;
return false ;
}
} , this ) ;
}
}
}
} ,
onApiPageOrient : function ( orient ) {
if ( this . _state . pgorient !== orient ) {
2018-06-28 12:42:01 +00:00
this . toolbar . btnPageOrient . menu . items [ orient == Asc . c _oAscPageOrientation . PagePortrait ? 0 : 1 ] . setChecked ( true ) ;
2018-06-28 09:27:11 +00:00
this . _state . pgorient = orient ;
}
} ,
2016-03-11 00:48:53 +00:00
2019-09-12 07:15:07 +00:00
onChangeScaleSettings : function ( width , height , scale ) {
if ( this . toolbar . btnScale . menu ) {
if ( width !== undefined ) {
2019-10-15 12:07:03 +00:00
var isWidth = false ,
isHeight = false ;
var width = width || 0 ,
height = height || 0 ;
if ( scale !== undefined ) {
this . toolbar . setValueCustomScale ( scale ) ;
2019-09-12 07:15:07 +00:00
} else {
2019-10-15 12:07:03 +00:00
this . toolbar . setValueCustomScale ( this . api . asc _getPageOptions ( ) . asc _getPageSetup ( ) . asc _getScale ( ) ) ;
2019-09-12 07:15:07 +00:00
}
2019-10-15 12:07:03 +00:00
this . toolbar . menuWidthScale . clearAll ( ) ;
this . toolbar . menuWidthScale . items . forEach ( function ( item ) {
if ( item . value === width ) {
item . setChecked ( true ) ;
isWidth = true ;
return false ;
}
} ) ;
if ( ! isWidth ) {
this . toolbar . menuWidthScale . items [ 11 ] . setChecked ( true ) ;
2019-09-12 07:15:07 +00:00
}
2019-10-15 12:07:03 +00:00
this . toolbar . menuHeightScale . clearAll ( ) ;
this . toolbar . menuHeightScale . items . forEach ( function ( item ) {
if ( item . value === height ) {
item . setChecked ( true ) ;
isHeight = true ;
return false ;
}
} ) ;
if ( ! isHeight ) {
this . toolbar . menuHeightScale . items [ 11 ] . setChecked ( true ) ;
}
if ( this . toolbar . btnCustomScaleUp && this . toolbar . btnCustomScaleDown ) {
this . toolbar . btnCustomScaleUp . setDisabled ( ! ( ! width && ! height ) ) ;
this . toolbar . btnCustomScaleDown . setDisabled ( ! ( ! width && ! height ) ) ;
2019-10-21 14:43:34 +00:00
this . toolbar . mnuCustomScale . setDisabled ( ! ( ! width && ! height ) ) ;
2019-10-15 12:07:03 +00:00
}
this . _state . scaleWidth = width ;
this . _state . scaleHeight = height ;
this . _state . scale = scale ;
} else {
if ( this . toolbar . btnCustomScaleUp && this . toolbar . btnCustomScaleDown ) {
this . toolbar . btnCustomScaleUp . setDisabled ( ! ( ! this . _state . scaleWidth && ! this . _state . scaleHeight ) ) ;
this . toolbar . btnCustomScaleDown . setDisabled ( ! ( ! this . _state . scaleWidth && ! this . _state . scaleHeight ) ) ;
2019-10-21 14:43:34 +00:00
this . toolbar . mnuCustomScale . setDisabled ( ! ( ! this . _state . scaleWidth && ! this . _state . scaleHeight ) ) ;
2019-10-15 12:07:03 +00:00
}
}
2019-09-12 07:15:07 +00:00
}
} ,
2018-07-19 12:48:12 +00:00
onApiLockDocumentProps : function ( nIndex ) {
if ( this . _state . lock _doc !== true && nIndex == this . api . asc _getActiveWorksheetIndex ( ) ) {
2021-12-29 16:41:15 +00:00
this . toolbar . lockToolbar ( Common . enumLock . docPropsLock , true , { array : [ this . toolbar . btnPageSize , this . toolbar . btnPageMargins , this . toolbar . btnPageOrient , this . toolbar . btnScale , this . toolbar . btnPrintTitles ] } ) ;
2018-07-19 12:48:12 +00:00
this . _state . lock _doc = true ;
}
} ,
onApiUnLockDocumentProps : function ( nIndex ) {
if ( this . _state . lock _doc !== false && nIndex == this . api . asc _getActiveWorksheetIndex ( ) ) {
2021-12-29 16:41:15 +00:00
this . toolbar . lockToolbar ( Common . enumLock . docPropsLock , false , { array : [ this . toolbar . btnPageSize , this . toolbar . btnPageMargins , this . toolbar . btnPageOrient , this . toolbar . btnScale , this . toolbar . btnPrintTitles ] } ) ;
2018-07-19 12:48:12 +00:00
this . _state . lock _doc = false ;
}
} ,
2016-03-11 00:48:53 +00:00
onApiEditorSelectionChanged : function ( fontobj ) {
2019-06-06 08:27:17 +00:00
if ( ! this . editMode || $ ( '.asc-window.enable-key-events:visible' ) . length > 0 ) return ;
2016-03-11 00:48:53 +00:00
var toolbar = this . toolbar ,
val ;
/* read font name */
2021-01-23 13:40:40 +00:00
Common . NotificationCenter . trigger ( 'fonts:change' , fontobj ) ;
2016-03-11 00:48:53 +00:00
/* read font params */
2022-03-11 10:58:15 +00:00
if ( ! toolbar . mode . isEditMailMerge && ! toolbar . mode . isEditDiagram && ! toolbar . mode . isEditOle ) {
2020-05-15 08:32:21 +00:00
val = fontobj . asc _getFontBold ( ) ;
2016-03-11 00:48:53 +00:00
if ( this . _state . bold !== val ) {
toolbar . btnBold . toggle ( val === true , true ) ;
this . _state . bold = val ;
}
2020-05-15 08:32:21 +00:00
val = fontobj . asc _getFontItalic ( ) ;
2016-03-11 00:48:53 +00:00
if ( this . _state . italic !== val ) {
toolbar . btnItalic . toggle ( val === true , true ) ;
this . _state . italic = val ;
}
2020-05-15 08:32:21 +00:00
val = fontobj . asc _getFontUnderline ( ) ;
2016-03-11 00:48:53 +00:00
if ( this . _state . underline !== val ) {
toolbar . btnUnderline . toggle ( val === true , true ) ;
this . _state . underline = val ;
}
2020-05-15 08:32:21 +00:00
val = fontobj . asc _getFontStrikeout ( ) ;
2017-12-05 13:58:01 +00:00
if ( this . _state . strikeout !== val ) {
toolbar . btnStrikeout . toggle ( val === true , true ) ;
this . _state . strikeout = val ;
}
2020-05-15 08:32:21 +00:00
var subsc = fontobj . asc _getFontSubscript ( ) ,
supersc = fontobj . asc _getFontSuperscript ( ) ;
2017-12-05 13:58:01 +00:00
if ( this . _state . subscript !== subsc || this . _state . superscript !== supersc ) {
2018-01-10 13:08:42 +00:00
var index = ( supersc ) ? 0 : ( subsc ? 1 : - 1 ) ,
2017-12-05 13:58:01 +00:00
btnSubscript = toolbar . btnSubscript ;
btnSubscript . toggle ( index > - 1 , true ) ;
if ( index < 0 ) {
2018-01-15 14:47:46 +00:00
btnSubscript . menu . clearAll ( ) ;
2017-12-05 13:58:01 +00:00
} else {
btnSubscript . menu . items [ index ] . setChecked ( true ) ;
2018-02-26 13:23:07 +00:00
if ( btnSubscript . rendered && btnSubscript . $icon ) {
btnSubscript . $icon . removeClass ( btnSubscript . options . icls ) ;
btnSubscript . options . icls = btnSubscript . menu . items [ index ] . options . icls ;
btnSubscript . $icon . addClass ( btnSubscript . options . icls ) ;
2017-12-05 13:58:01 +00:00
}
}
this . _state . subscript = subsc ;
this . _state . superscript = supersc ;
}
2016-03-11 00:48:53 +00:00
}
/* read font size */
2020-05-15 08:32:21 +00:00
var str _size = fontobj . asc _getFontSize ( ) ;
2016-03-11 00:48:53 +00:00
if ( this . _state . fontsize !== str _size ) {
toolbar . cmbFontSize . setValue ( ( str _size !== undefined ) ? str _size : '' ) ;
this . _state . fontsize = str _size ;
}
/* read font color */
var clr ,
color ,
fontColorPicker = this . toolbar . mnuTextColorPicker ;
2021-11-09 13:56:05 +00:00
if ( ! fontColorPicker . isDummy ) {
2020-05-15 08:32:21 +00:00
color = fontobj . asc _getFontColor ( ) ;
2016-03-11 00:48:53 +00:00
if ( color ) {
2021-01-21 21:45:44 +00:00
if ( color . get _auto ( ) ) {
if ( this . _state . clrtext !== 'auto' ) {
fontColorPicker . clearSelection ( ) ;
2021-07-10 23:25:12 +00:00
this . toolbar . btnTextColor . setAutoColor ( true ) ;
2021-01-21 21:45:44 +00:00
this . _state . clrtext = 'auto' ;
}
2016-03-11 00:48:53 +00:00
} else {
2021-01-21 21:45:44 +00:00
if ( color . get _type ( ) == Asc . c _oAscColor . COLOR _TYPE _SCHEME ) {
clr = { color : Common . Utils . ThemeColor . getHexColor ( color . get _r ( ) , color . get _g ( ) , color . get _b ( ) ) , effectValue : color . get _value ( ) } ;
} else {
clr = Common . Utils . ThemeColor . getHexColor ( color . get _r ( ) , color . get _g ( ) , color . get _b ( ) ) ;
}
var type1 = typeof ( clr ) ,
type2 = typeof ( this . _state . clrtext ) ;
if ( ( this . _state . clrtext == 'auto' ) || ( type1 !== type2 ) || ( type1 == 'object' &&
( clr . effectValue !== this . _state . clrtext . effectValue || this . _state . clrtext . color . indexOf ( clr . color ) < 0 ) ) ||
( type1 != 'object' && this . _state . clrtext !== undefined && this . _state . clrtext . indexOf ( clr ) < 0 ) ) {
2021-07-10 23:25:12 +00:00
this . toolbar . btnTextColor . setAutoColor ( false ) ;
2021-01-21 21:45:44 +00:00
if ( _ . isObject ( clr ) ) {
var isselected = false ;
for ( var i = 0 ; i < 10 ; i ++ ) {
if ( Common . Utils . ThemeColor . ThemeValues [ i ] == clr . effectValue ) {
fontColorPicker . select ( clr , true ) ;
isselected = true ;
break ;
}
}
if ( ! isselected ) fontColorPicker . clearSelection ( ) ;
} else {
2016-03-11 00:48:53 +00:00
fontColorPicker . select ( clr , true ) ;
}
2021-01-21 21:45:44 +00:00
this . _state . clrtext = clr ;
2016-03-11 00:48:53 +00:00
}
}
}
this . _state . clrtext _asccolor = color ;
}
} ,
onApiSelectionChanged : function ( info ) {
2022-10-28 14:02:42 +00:00
if ( ! this . editMode || $ ( '.asc-window.enable-key-events:visible' ) . length > 0 || ! info ) return ;
2017-04-28 12:24:57 +00:00
if ( this . toolbar . mode . isEditDiagram )
2017-04-28 13:37:28 +00:00
return this . onApiSelectionChanged _DiagramEditor ( info ) ; else
if ( this . toolbar . mode . isEditMailMerge )
2022-03-11 10:58:15 +00:00
return this . onApiSelectionChanged _MailMergeEditor ( info ) ; else
if ( this . toolbar . mode . isEditOle )
return this . onApiSelectionChanged _OleEditor ( info ) ;
2016-03-11 00:48:53 +00:00
2020-05-14 08:39:04 +00:00
var selectionType = info . asc _getSelectionType ( ) ,
2022-03-11 10:58:15 +00:00
coauth _disable = ( ! this . toolbar . mode . isEditMailMerge && ! this . toolbar . mode . isEditDiagram && ! this . toolbar . mode . isEditOle ) ? ( info . asc _getLocked ( ) === true || info . asc _getLockedTable ( ) === true || info . asc _getLockedPivotTable ( ) === true ) : false ,
2016-11-07 13:00:11 +00:00
editOptionsDisabled = this . _disableEditOptions ( selectionType , coauth _disable ) ,
me = this ,
2016-03-11 00:48:53 +00:00
toolbar = this . toolbar ,
2020-05-15 10:52:52 +00:00
xfs = info . asc _getXfs ( ) ,
2016-03-11 00:48:53 +00:00
val , need _disable = false ;
/* read font name */
2021-01-23 13:40:40 +00:00
Common . NotificationCenter . trigger ( 'fonts:change' , xfs ) ;
2016-03-11 00:48:53 +00:00
2016-11-07 13:00:11 +00:00
/* read font size */
2020-05-15 10:52:52 +00:00
var str _size = xfs . asc _getFontSize ( ) ;
2017-04-28 12:24:57 +00:00
if ( this . _state . fontsize !== str _size ) {
toolbar . cmbFontSize . setValue ( ( str _size !== undefined ) ? str _size : '' ) ;
this . _state . fontsize = str _size ;
2016-11-07 13:00:11 +00:00
}
2021-12-29 16:41:15 +00:00
toolbar . lockToolbar ( Common . enumLock . cantHyperlink , ( selectionType === Asc . c _oAscSelectionType . RangeShapeText ) && ( this . api . asc _canAddShapeHyperlink ( ) === false ) , { array : [ toolbar . btnInsertHyperlink ] } ) ;
2016-11-23 13:38:30 +00:00
2017-05-11 07:39:58 +00:00
/ *
2016-12-28 11:28:27 +00:00
need _disable = selectionType != Asc . c _oAscSelectionType . RangeCells && selectionType != Asc . c _oAscSelectionType . RangeCol &&
2017-04-28 12:24:57 +00:00
selectionType != Asc . c _oAscSelectionType . RangeRow && selectionType != Asc . c _oAscSelectionType . RangeMax ;
2016-12-28 11:28:27 +00:00
if ( this . _state . sparklines _disabled !== need _disable ) {
2017-04-28 12:22:37 +00:00
this . _state . sparklines _disabled = need _disable ;
2016-12-28 11:28:27 +00:00
var len = toolbar . mnuInsertChartPicker . store . length ;
2017-04-28 12:24:57 +00:00
for ( var i = 0 ; i < 3 ; i ++ ) {
2016-12-28 11:28:27 +00:00
toolbar . mnuInsertChartPicker . store . at ( len - i - 1 ) . set ( { disabled : need _disable } ) ;
}
}
2017-05-11 07:39:58 +00:00
* /
2016-12-28 11:28:27 +00:00
2020-05-15 07:42:00 +00:00
need _disable = ( selectionType === Asc . c _oAscSelectionType . RangeCells || selectionType === Asc . c _oAscSelectionType . RangeCol ||
selectionType === Asc . c _oAscSelectionType . RangeRow || selectionType === Asc . c _oAscSelectionType . RangeMax ) ;
2021-12-29 16:41:15 +00:00
toolbar . lockToolbar ( Common . enumLock . selRange , need _disable , { array : [ toolbar . btnImgAlign , toolbar . btnImgBackward , toolbar . btnImgForward , toolbar . btnImgGroup ] } ) ;
2018-06-28 12:42:01 +00:00
var cangroup = this . api . asc _canGroupGraphicsObjects ( ) ,
canungroup = this . api . asc _canUnGroupGraphicsObjects ( ) ;
2021-12-29 16:41:15 +00:00
toolbar . lockToolbar ( Common . enumLock . cantGroupUngroup , ! cangroup && ! canungroup , { array : [ toolbar . btnImgGroup ] } ) ;
2018-06-28 12:42:01 +00:00
toolbar . btnImgGroup . menu . items [ 0 ] . setDisabled ( ! cangroup ) ;
toolbar . btnImgGroup . menu . items [ 1 ] . setDisabled ( ! canungroup ) ;
2021-12-29 16:41:15 +00:00
toolbar . lockToolbar ( Common . enumLock . cantGroup , ! cangroup , { array : [ toolbar . btnImgAlign ] } ) ;
2018-06-28 09:27:11 +00:00
2019-02-14 14:50:36 +00:00
var objcount = this . api . asc _getSelectedDrawingObjectsCount ( ) ;
toolbar . btnImgAlign . menu . items [ 7 ] . setDisabled ( objcount < 3 ) ;
toolbar . btnImgAlign . menu . items [ 8 ] . setDisabled ( objcount < 3 ) ;
2021-07-16 12:47:24 +00:00
// disable on protected sheet
2021-08-05 16:09:21 +00:00
// lock formatting controls in cell with FormatCells protection or in shape and Objects protection
2021-07-16 12:47:24 +00:00
need _disable = ( selectionType === Asc . c _oAscSelectionType . RangeImage || selectionType === Asc . c _oAscSelectionType . RangeChart || selectionType === Asc . c _oAscSelectionType . RangeChartText ||
selectionType === Asc . c _oAscSelectionType . RangeShape || selectionType === Asc . c _oAscSelectionType . RangeShapeText || selectionType === Asc . c _oAscSelectionType . RangeSlicer ) ;
2021-12-29 16:41:15 +00:00
toolbar . lockToolbar ( Common . enumLock . wsLockFormat , need _disable && ! ! this . _state . wsProps [ 'Objects' ] && ! ! this . _state . is _lockText || ! need _disable && ! ! this . _state . wsProps [ 'FormatCells' ] ) ;
toolbar . lockToolbar ( Common . enumLock . wsLockFormatFill , need _disable && ! ! this . _state . wsProps [ 'Objects' ] && ! ! this . _state . is _lockShape || ! need _disable && ! ! this . _state . wsProps [ 'FormatCells' ] ) ;
2021-08-05 16:09:21 +00:00
2021-12-29 16:41:15 +00:00
toolbar . lockToolbar ( Common . enumLock [ 'Objects' ] , ! ! this . _state . wsProps [ 'Objects' ] ) ;
toolbar . lockToolbar ( Common . enumLock [ 'FormatCells' ] , ! ! this . _state . wsProps [ 'FormatCells' ] ) ;
2021-07-16 12:47:24 +00:00
2022-10-22 18:33:14 +00:00
// info.asc_getComments()===null - has comment, but no permissions to view it
toolbar . lockToolbar ( Common . enumLock . commentLock ,
( selectionType == Asc . c _oAscSelectionType . RangeCells ) && ( ! info . asc _getComments ( ) || info . asc _getComments ( ) . length > 0 || info . asc _getLocked ( ) )
|| selectionType != Asc . c _oAscSelectionType . RangeCells ,
{ array : this . btnsComment } ) ;
2016-11-07 13:00:11 +00:00
if ( editOptionsDisabled ) return ;
2016-03-11 00:48:53 +00:00
/* read font params */
2022-03-11 10:58:15 +00:00
if ( ! toolbar . mode . isEditMailMerge && ! toolbar . mode . isEditDiagram && ! toolbar . mode . isEditOle ) {
2020-05-15 10:52:52 +00:00
val = xfs . asc _getFontBold ( ) ;
2016-03-11 00:48:53 +00:00
if ( this . _state . bold !== val ) {
toolbar . btnBold . toggle ( val === true , true ) ;
this . _state . bold = val ;
}
2020-05-15 10:52:52 +00:00
val = xfs . asc _getFontItalic ( ) ;
2016-03-11 00:48:53 +00:00
if ( this . _state . italic !== val ) {
toolbar . btnItalic . toggle ( val === true , true ) ;
this . _state . italic = val ;
}
2020-05-15 10:52:52 +00:00
val = xfs . asc _getFontUnderline ( ) ;
2016-03-11 00:48:53 +00:00
if ( this . _state . underline !== val ) {
toolbar . btnUnderline . toggle ( val === true , true ) ;
this . _state . underline = val ;
}
2020-05-15 10:52:52 +00:00
val = xfs . asc _getFontStrikeout ( ) ;
2017-12-05 13:58:01 +00:00
if ( this . _state . strikeout !== val ) {
toolbar . btnStrikeout . toggle ( val === true , true ) ;
this . _state . strikeout = val ;
}
2020-05-15 10:52:52 +00:00
var subsc = xfs . asc _getFontSubscript ( ) ,
supersc = xfs . asc _getFontSuperscript ( ) ;
2017-12-05 13:58:01 +00:00
if ( this . _state . subscript !== subsc || this . _state . superscript !== supersc ) {
2018-01-10 13:08:42 +00:00
var index = ( supersc ) ? 0 : ( subsc ? 1 : - 1 ) ,
2017-12-05 13:58:01 +00:00
btnSubscript = toolbar . btnSubscript ;
btnSubscript . toggle ( index > - 1 , true ) ;
if ( index < 0 ) {
2018-01-15 14:47:46 +00:00
btnSubscript . menu . clearAll ( ) ;
2017-12-05 13:58:01 +00:00
} else {
btnSubscript . menu . items [ index ] . setChecked ( true ) ;
2018-02-26 13:23:07 +00:00
if ( btnSubscript . rendered ) {
btnSubscript . $icon . removeClass ( btnSubscript . options . icls ) ;
btnSubscript . options . icls = btnSubscript . menu . items [ index ] . options . icls ;
btnSubscript . $icon . addClass ( btnSubscript . options . icls ) ;
2017-12-05 13:58:01 +00:00
}
}
this . _state . subscript = subsc ;
this . _state . superscript = supersc ;
}
2016-03-11 00:48:53 +00:00
}
/* read font color */
var clr ,
color ,
fontColorPicker = this . toolbar . mnuTextColorPicker ,
paragraphColorPicker = this . toolbar . mnuBackColorPicker ;
2021-11-09 13:56:05 +00:00
if ( ! fontColorPicker . isDummy ) {
2020-05-15 10:52:52 +00:00
color = xfs . asc _getFontColor ( ) ;
2016-03-11 00:48:53 +00:00
if ( color ) {
2021-01-21 21:45:44 +00:00
if ( color . get _auto ( ) ) {
if ( this . _state . clrtext !== 'auto' ) {
fontColorPicker . clearSelection ( ) ;
2021-07-10 23:25:12 +00:00
toolbar . btnTextColor . setAutoColor ( true ) ;
2021-01-21 21:45:44 +00:00
this . _state . clrtext = 'auto' ;
}
2016-03-11 00:48:53 +00:00
} else {
2021-01-21 21:45:44 +00:00
if ( color . get _type ( ) == Asc . c _oAscColor . COLOR _TYPE _SCHEME ) {
clr = { color : Common . Utils . ThemeColor . getHexColor ( color . get _r ( ) , color . get _g ( ) , color . get _b ( ) ) , effectValue : color . get _value ( ) } ;
} else {
clr = Common . Utils . ThemeColor . getHexColor ( color . get _r ( ) , color . get _g ( ) , color . get _b ( ) ) ;
}
var type1 = typeof ( clr ) ,
type2 = typeof ( this . _state . clrtext ) ;
if ( ( this . _state . clrtext == 'auto' ) || ( type1 !== type2 ) || ( type1 == 'object' &&
( clr . effectValue !== this . _state . clrtext . effectValue || this . _state . clrtext . color . indexOf ( clr . color ) < 0 ) ) ||
( type1 != 'object' && this . _state . clrtext !== undefined && this . _state . clrtext . indexOf ( clr ) < 0 ) ) {
2021-07-10 23:25:12 +00:00
toolbar . btnTextColor . setAutoColor ( false ) ;
2021-01-21 21:45:44 +00:00
if ( _ . isObject ( clr ) ) {
var isselected = false ;
for ( var i = 0 ; i < 10 ; i ++ ) {
if ( Common . Utils . ThemeColor . ThemeValues [ i ] == clr . effectValue ) {
fontColorPicker . select ( clr , true ) ;
isselected = true ;
break ;
}
}
if ( ! isselected ) fontColorPicker . clearSelection ( ) ;
} else {
2016-03-11 00:48:53 +00:00
fontColorPicker . select ( clr , true ) ;
}
2021-01-21 21:45:44 +00:00
this . _state . clrtext = clr ;
2016-03-11 00:48:53 +00:00
}
}
}
this . _state . clrtext _asccolor = color ;
}
/* read cell background color */
2021-11-09 13:56:05 +00:00
if ( ! paragraphColorPicker . isDummy ) {
2020-05-15 10:52:52 +00:00
color = xfs . asc _getFillColor ( ) ;
2021-11-09 13:56:05 +00:00
if ( color && ! color . get _auto ( ) ) {
2016-04-05 11:52:34 +00:00
if ( color . get _type ( ) == Asc . c _oAscColor . COLOR _TYPE _SCHEME ) {
2016-03-11 00:48:53 +00:00
clr = { color : Common . Utils . ThemeColor . getHexColor ( color . get _r ( ) , color . get _g ( ) , color . get _b ( ) ) , effectValue : color . get _value ( ) } ;
} else {
clr = Common . Utils . ThemeColor . getHexColor ( color . get _r ( ) , color . get _g ( ) , color . get _b ( ) ) ;
}
} else {
clr = 'transparent' ;
}
type1 = typeof ( clr ) ;
type2 = typeof ( this . _state . clrback ) ;
if ( ( type1 !== type2 ) || ( type1 == 'object' &&
( clr . effectValue !== this . _state . clrback . effectValue || this . _state . clrback . color . indexOf ( clr . color ) < 0 ) ) ||
( type1 != 'object' && this . _state . clrback !== undefined && this . _state . clrback . indexOf ( clr ) < 0 ) ) {
if ( _ . isObject ( clr ) ) {
var isselected = false ;
for ( i = 0 ; i < 10 ; i ++ ) {
if ( Common . Utils . ThemeColor . ThemeValues [ i ] == clr . effectValue ) {
paragraphColorPicker . select ( clr , true ) ;
isselected = true ;
break ;
}
}
if ( ! isselected ) paragraphColorPicker . clearSelection ( ) ;
} else {
paragraphColorPicker . select ( clr , true ) ;
}
this . _state . clrback = clr ;
}
this . _state . clrshd _asccolor = color ;
}
2017-08-29 12:43:16 +00:00
var in _chart = ( selectionType == Asc . c _oAscSelectionType . RangeChart || selectionType == Asc . c _oAscSelectionType . RangeChartText ) ;
if ( in _chart !== this . _state . in _chart ) {
toolbar . btnInsertChart . updateHint ( in _chart ? toolbar . tipChangeChart : toolbar . tipInsertChart ) ;
this . _state . in _chart = in _chart ;
}
if ( in _chart ) return ;
2016-03-11 00:48:53 +00:00
if ( ! toolbar . mode . isEditDiagram )
{
// (coauth_disable !== toolbar.btnClearStyle.isDisabled()) && toolbar.btnClearStyle.setDisabled(coauth_disable);
// (coauth_disable !== toolbar.btnCopyStyle.isDisabled()) && toolbar.btnCopyStyle.setDisabled(coauth_disable);
2016-03-29 14:35:28 +00:00
var filterInfo = info . asc _getAutoFilterInfo ( ) ,
formatTableInfo = info . asc _getFormatTableInfo ( ) ;
2016-03-11 00:48:53 +00:00
if ( ! toolbar . mode . isEditMailMerge ) {
/* read cell horizontal align */
2021-01-23 13:40:40 +00:00
var fontparam = xfs . asc _getHorAlign ( ) ;
2016-03-11 00:48:53 +00:00
if ( this . _state . pralign !== fontparam ) {
this . _state . pralign = fontparam ;
var index = - 1 , align ;
switch ( fontparam ) {
2017-08-24 11:22:59 +00:00
case AscCommon . align _Left : index = 0 ; align = 'btn-align-left' ; break ;
case AscCommon . align _Center : index = 1 ; align = 'btn-align-center' ; break ;
case AscCommon . align _Right : index = 2 ; align = 'btn-align-right' ; break ;
case AscCommon . align _Justify : index = 3 ; align = 'btn-align-just' ; break ;
2016-03-11 00:48:53 +00:00
default : index = - 255 ; align = 'btn-align-left' ; break ;
}
if ( ! ( index < 0 ) ) {
toolbar . btnAlignRight . toggle ( index === 2 , true ) ;
toolbar . btnAlignLeft . toggle ( index === 0 , true ) ;
toolbar . btnAlignCenter . toggle ( index === 1 , true ) ;
toolbar . btnAlignJust . toggle ( index === 3 , true ) ;
} else if ( index == - 255 ) {
toolbar . btnAlignRight . toggle ( false , true ) ;
toolbar . btnAlignLeft . toggle ( false , true ) ;
toolbar . btnAlignCenter . toggle ( false , true ) ;
toolbar . btnAlignJust . toggle ( false , true ) ;
}
}
2020-05-14 09:56:09 +00:00
need _disable = ( fontparam == AscCommon . align _Justify || selectionType == Asc . c _oAscSelectionType . RangeShapeText || selectionType == Asc . c _oAscSelectionType . RangeShape ) ;
2017-05-15 13:32:01 +00:00
toolbar . btnTextOrient . menu . items [ 1 ] . setDisabled ( need _disable ) ;
toolbar . btnTextOrient . menu . items [ 2 ] . setDisabled ( need _disable ) ;
2020-05-28 10:17:21 +00:00
toolbar . btnTextOrient . menu . items [ 3 ] . setDisabled ( need _disable ) ;
2017-05-15 13:32:01 +00:00
2016-03-11 00:48:53 +00:00
/* read cell vertical align */
2020-05-15 10:52:52 +00:00
fontparam = xfs . asc _getVertAlign ( ) ;
2016-03-11 00:48:53 +00:00
if ( this . _state . valign !== fontparam ) {
this . _state . valign = fontparam ;
index = - 1 ; align = '' ;
switch ( fontparam ) {
2017-08-24 11:22:59 +00:00
case Asc . c _oAscVAlign . Top : index = 0 ; align = 'btn-valign-top' ; break ;
case Asc . c _oAscVAlign . Center : index = 1 ; align = 'btn-valign-middle' ; break ;
case Asc . c _oAscVAlign . Bottom : index = 2 ; align = 'btn-valign-bottom' ; break ;
2016-03-11 00:48:53 +00:00
}
2020-05-13 17:47:56 +00:00
toolbar . btnAlignTop . toggle ( index === 0 , true ) ;
toolbar . btnAlignMiddle . toggle ( index === 1 , true ) ;
toolbar . btnAlignBottom . toggle ( index === 2 , true ) ;
2016-03-11 00:48:53 +00:00
}
2016-03-29 14:35:28 +00:00
need _disable = this . _state . controlsdisabled . filters || formatTableInfo !== null || filterInfo && filterInfo . asc _getIsAutoFilter ( ) === null ;
2016-03-11 00:48:53 +00:00
// (need_disable !== toolbar.btnMerge.isDisabled()) && toolbar.btnMerge.setDisabled(need_disable);
2021-12-29 16:41:15 +00:00
toolbar . lockToolbar ( Common . enumLock . ruleMerge , need _disable , { array : [ toolbar . btnMerge , toolbar . btnInsertTable ] } ) ;
2016-03-11 00:48:53 +00:00
2020-05-14 09:16:27 +00:00
val = info . asc _getMerge ( ) ;
2016-03-11 00:48:53 +00:00
if ( this . _state . merge !== val ) {
2017-04-11 11:05:56 +00:00
toolbar . btnMerge . toggle ( val === Asc . c _oAscMergeOptions . Merge , true ) ;
2016-03-11 00:48:53 +00:00
this . _state . merge = val ;
}
/* read cell text wrapping */
if ( ! toolbar . btnWrap . isDisabled ( ) ) {
2020-05-15 10:52:52 +00:00
val = xfs . asc _getWrapText ( ) ;
2016-03-11 00:48:53 +00:00
if ( this . _state . wrap !== val ) {
toolbar . btnWrap . toggle ( val === true , true ) ;
this . _state . wrap = val ;
}
}
}
val = ( filterInfo ) ? filterInfo . asc _getIsAutoFilter ( ) : null ;
if ( this . _state . filter !== val ) {
2019-06-11 11:27:25 +00:00
toolbar . btnsSetAutofilter . toggle ( val === true , true ) ;
2016-03-11 00:48:53 +00:00
this . _state . filter = val ;
}
need _disable = this . _state . controlsdisabled . filters || ( val === null ) ;
2021-12-29 16:41:15 +00:00
toolbar . lockToolbar ( Common . enumLock . ruleFilter , need _disable ,
2020-11-11 20:55:11 +00:00
{ array : toolbar . btnsSetAutofilter . concat ( toolbar . btnCustomSort , toolbar . btnTableTemplate , toolbar . btnInsertTable , toolbar . btnRemoveDuplicates , toolbar . btnDataValidation ) } ) ;
2020-06-05 16:28:11 +00:00
2021-12-29 16:41:15 +00:00
toolbar . lockToolbar ( Common . enumLock . tableHasSlicer , filterInfo && filterInfo . asc _getIsSlicerAdded ( ) , { array : toolbar . btnsSetAutofilter } ) ;
2020-06-05 16:28:11 +00:00
need _disable = ( selectionType !== Asc . c _oAscSelectionType . RangeSlicer ) && ( this . _state . controlsdisabled . filters || ( val === null ) ) ;
2021-12-29 16:41:15 +00:00
toolbar . lockToolbar ( Common . enumLock . cantSort , need _disable , { array : toolbar . btnsSortDown . concat ( toolbar . btnsSortUp ) } ) ;
2016-03-11 00:48:53 +00:00
2016-03-29 14:35:28 +00:00
val = ( formatTableInfo ) ? formatTableInfo . asc _getTableStyleName ( ) : null ;
2016-03-11 00:48:53 +00:00
if ( this . _state . tablestylename !== val && this . toolbar . mnuTableTemplatePicker ) {
val = this . toolbar . mnuTableTemplatePicker . store . findWhere ( { name : val } ) ;
if ( val ) {
this . toolbar . mnuTableTemplatePicker . selectRecord ( val ) ;
this . _state . tablestylename = val . get ( 'name' ) ;
} else {
toolbar . mnuTableTemplatePicker . deselectAll ( ) ;
this . _state . tablestylename = null ;
}
}
need _disable = this . _state . controlsdisabled . filters || ! filterInfo || ( filterInfo . asc _getIsApplyAutoFilter ( ) !== true ) ;
2021-12-29 16:41:15 +00:00
toolbar . lockToolbar ( Common . enumLock . ruleDelFilter , need _disable , { array : toolbar . btnsClearAutofilter } ) ;
2017-04-11 11:05:56 +00:00
var old _name = this . _state . tablename ;
this . _state . tablename = ( formatTableInfo ) ? formatTableInfo . asc _getTableName ( ) : undefined ;
var old _applied = this . _state . filterapplied ;
this . _state . filterapplied = this . _state . filter && filterInfo . asc _getIsApplyAutoFilter ( ) ;
if ( this . _state . tablename !== old _name || this . _state . filterapplied !== old _applied )
this . getApplication ( ) . getController ( 'Statusbar' ) . onApiFilterInfo ( ! need _disable ) ;
2016-11-01 12:42:46 +00:00
2020-05-14 08:45:23 +00:00
this . _state . multiselect = info . asc _getMultiselect ( ) ;
2021-12-29 16:41:15 +00:00
toolbar . lockToolbar ( Common . enumLock . multiselect , this . _state . multiselect , { array : [ toolbar . btnTableTemplate , toolbar . btnInsertHyperlink , toolbar . btnInsertTable ] } ) ;
2017-06-21 09:47:22 +00:00
2018-02-21 08:51:36 +00:00
this . _state . inpivot = ! ! info . asc _getPivotTableInfo ( ) ;
2021-12-29 16:41:15 +00:00
toolbar . lockToolbar ( Common . enumLock . editPivot , this . _state . inpivot , { array : toolbar . btnsSetAutofilter . concat ( toolbar . btnCustomSort ,
2020-11-11 20:55:11 +00:00
toolbar . btnMerge , toolbar . btnInsertHyperlink , toolbar . btnInsertTable , toolbar . btnRemoveDuplicates , toolbar . btnDataValidation ) } ) ;
2021-12-29 16:41:15 +00:00
toolbar . lockToolbar ( Common . enumLock . noSlicerSource , ! ( this . _state . inpivot || formatTableInfo ) , { array : [ toolbar . btnInsertSlicer ] } ) ;
2017-10-19 10:14:12 +00:00
need _disable = ! this . appConfig . canModifyFilter ;
2021-12-29 16:41:15 +00:00
toolbar . lockToolbar ( Common . enumLock . cantModifyFilter , need _disable , { array : toolbar . btnsSetAutofilter . concat ( toolbar . btnsSortDown , toolbar . btnsSortUp , toolbar . btnCustomSort , toolbar . btnTableTemplate ,
2020-11-11 20:55:11 +00:00
toolbar . btnClearStyle . menu . items [ 0 ] , toolbar . btnClearStyle . menu . items [ 2 ] , toolbar . btnInsertTable , toolbar . btnRemoveDuplicates , toolbar . btnDataValidation ) } ) ;
2017-10-19 10:14:12 +00:00
2016-03-11 00:48:53 +00:00
}
2020-05-15 10:52:52 +00:00
val = xfs . asc _getNumFormatInfo ( ) ;
2017-01-20 10:34:52 +00:00
if ( val ) {
2020-05-15 10:52:52 +00:00
this . _state . numformat = xfs . asc _getNumFormat ( ) ;
2017-02-07 09:56:32 +00:00
this . _state . numformatinfo = val ;
2017-01-20 10:34:52 +00:00
val = val . asc _getType ( ) ;
if ( this . _state . numformattype !== val ) {
toolbar . cmbNumberFormat . setValue ( val , toolbar . txtCustom ) ;
this . _state . numformattype = val ;
}
2017-01-12 14:14:51 +00:00
}
2016-03-11 00:48:53 +00:00
2020-05-15 10:52:52 +00:00
val = xfs . asc _getAngle ( ) ;
2016-03-11 00:48:53 +00:00
if ( this . _state . angle !== val ) {
2017-11-13 08:41:32 +00:00
toolbar . btnTextOrient . menu . clearAll ( ) ;
2016-03-11 00:48:53 +00:00
switch ( val ) {
case 45 : toolbar . btnTextOrient . menu . items [ 1 ] . setChecked ( true , true ) ; break ;
case - 45 : toolbar . btnTextOrient . menu . items [ 2 ] . setChecked ( true , true ) ; break ;
2020-05-28 10:17:21 +00:00
case 255 : toolbar . btnTextOrient . menu . items [ 3 ] . setChecked ( true , true ) ; break ;
case 90 : toolbar . btnTextOrient . menu . items [ 4 ] . setChecked ( true , true ) ; break ;
case - 90 : toolbar . btnTextOrient . menu . items [ 5 ] . setChecked ( true , true ) ; break ;
2020-05-13 17:47:56 +00:00
case 0 : toolbar . btnTextOrient . menu . items [ 0 ] . setChecked ( true , true ) ; break ;
2016-03-11 00:48:53 +00:00
}
this . _state . angle = val ;
}
val = info . asc _getStyleName ( ) ;
if ( this . _state . prstyle != val && ! this . toolbar . listStyles . isDisabled ( ) ) {
var listStyle = this . toolbar . listStyles ,
listStylesVisible = ( listStyle . rendered ) ;
if ( listStylesVisible ) {
listStyle . suspendEvents ( ) ;
var styleRec = listStyle . menuPicker . store . findWhere ( {
name : val
} ) ;
this . _state . prstyle = ( listStyle . menuPicker . store . length > 0 ) ? val : undefined ;
listStyle . menuPicker . selectRecord ( styleRec ) ;
listStyle . resumeEvents ( ) ;
}
}
2021-07-17 21:22:55 +00:00
var selCol = selectionType == Asc . c _oAscSelectionType . RangeCol ,
selRow = selectionType == Asc . c _oAscSelectionType . RangeRow ,
selMax = selectionType == Asc . c _oAscSelectionType . RangeMax ;
need _disable = selRow || selMax && this . _state . wsLock || this . _state . wsProps [ 'InsertColumns' ] ;
toolbar . btnAddCell . menu . items [ 3 ] . setDisabled ( need _disable ) ;
need _disable = selRow || selMax && this . _state . wsLock || ! selCol && this . _state . wsLock || this . _state . wsProps [ 'DeleteColumns' ] ;
toolbar . btnDeleteCell . menu . items [ 3 ] . setDisabled ( need _disable ) ;
need _disable = selCol || selMax && this . _state . wsLock || this . _state . wsProps [ 'InsertRows' ] ;
toolbar . btnAddCell . menu . items [ 2 ] . setDisabled ( need _disable ) ;
need _disable = selCol || selMax && this . _state . wsLock || ! selRow && this . _state . wsLock || this . _state . wsProps [ 'DeleteRows' ] ;
toolbar . btnDeleteCell . menu . items [ 2 ] . setDisabled ( need _disable ) ;
2016-03-11 00:48:53 +00:00
val = filterInfo && filterInfo . asc _getIsApplyAutoFilter ( ) ;
2021-07-17 21:22:55 +00:00
need _disable = selRow || val || ! ( selCol || selMax ) && this . _state . wsLock || selCol && this . _state . wsProps [ 'InsertColumns' ] || selMax && this . _state . wsProps [ 'InsertColumns' ] && this . _state . wsProps [ 'InsertRows' ] ;
toolbar . btnAddCell . menu . items [ 0 ] . setDisabled ( need _disable ) ;
need _disable = selRow || val || ! ( selCol || selMax ) && this . _state . wsLock || selCol && this . _state . wsProps [ 'DeleteColumns' ] || selMax && this . _state . wsProps [ 'DeleteColumns' ] && this . _state . wsProps [ 'DeleteRows' ] ;
toolbar . btnDeleteCell . menu . items [ 0 ] . setDisabled ( need _disable ) ;
need _disable = selCol || val || ! ( selRow || selMax ) && this . _state . wsLock || selRow && this . _state . wsProps [ 'InsertRows' ] || selMax && this . _state . wsProps [ 'InsertColumns' ] && this . _state . wsProps [ 'InsertRows' ] ;
toolbar . btnAddCell . menu . items [ 1 ] . setDisabled ( need _disable ) ;
need _disable = selCol || val || ! ( selRow || selMax ) && this . _state . wsLock || selRow && this . _state . wsProps [ 'DeleteRows' ] || selMax && this . _state . wsProps [ 'DeleteColumns' ] && this . _state . wsProps [ 'DeleteRows' ] ;
toolbar . btnDeleteCell . menu . items [ 1 ] . setDisabled ( need _disable ) ;
2017-06-28 11:20:49 +00:00
2021-07-17 22:09:26 +00:00
var items = toolbar . btnAddCell . menu . items ,
enabled = false ;
for ( var i = 0 ; i < 4 ; i ++ ) {
! items [ i ] . isDisabled ( ) && ( enabled = true ) ;
2016-03-11 00:48:53 +00:00
}
2021-12-29 16:41:15 +00:00
toolbar . lockToolbar ( Common . enumLock . itemsDisabled , ! enabled , { array : [ toolbar . btnAddCell ] } ) ;
2021-07-17 22:09:26 +00:00
items = me . toolbar . btnDeleteCell . menu . items ;
enabled = false ;
for ( var i = 0 ; i < 4 ; i ++ ) {
! items [ i ] . isDisabled ( ) && ( enabled = true ) ;
2016-03-11 00:48:53 +00:00
}
2021-12-29 16:41:15 +00:00
toolbar . lockToolbar ( Common . enumLock . itemsDisabled , ! enabled , { array : [ toolbar . btnDeleteCell ] } ) ;
2017-06-28 11:20:49 +00:00
2019-07-25 08:32:14 +00:00
2021-12-29 16:41:15 +00:00
toolbar . lockToolbar ( Common . enumLock . headerLock , info . asc _getLockedHeaderFooter ( ) , { array : this . toolbar . btnsEditHeader } ) ;
2016-03-11 00:48:53 +00:00
} ,
2019-11-15 11:01:08 +00:00
onApiSelectionChangedRestricted : function ( info ) {
2022-10-28 14:02:42 +00:00
if ( ! this . appConfig . isRestrictedEdit || ! info ) return ;
2021-09-06 23:02:15 +00:00
2020-05-14 08:39:04 +00:00
var selectionType = info . asc _getSelectionType ( ) ;
2022-10-24 15:49:15 +00:00
this . toolbar . lockToolbar ( Common . enumLock . commentLock ,
( selectionType == Asc . c _oAscSelectionType . RangeCells ) && ( ! info . asc _getComments ( ) || info . asc _getComments ( ) . length > 0 || info . asc _getLocked ( ) )
|| selectionType != Asc . c _oAscSelectionType . RangeCells ,
{ array : this . btnsComment } ) ;
2021-12-29 16:41:15 +00:00
this . toolbar . lockToolbar ( Common . enumLock [ 'Objects' ] , ! ! this . _state . wsProps [ 'Objects' ] , { array : this . btnsComment } ) ;
2019-11-15 11:01:08 +00:00
} ,
2017-04-28 12:24:57 +00:00
onApiSelectionChanged _DiagramEditor : function ( info ) {
2022-10-28 14:02:42 +00:00
if ( ! this . editMode || this . api . isCellEdited || this . api . isRangeSelection || ! info ) return ;
2017-04-28 12:24:57 +00:00
var me = this ;
var _disableEditOptions = function ( seltype , coauth _disable ) {
var is _chart _text = seltype == Asc . c _oAscSelectionType . RangeChartText ,
is _chart = seltype == Asc . c _oAscSelectionType . RangeChart ,
is _shape _text = seltype == Asc . c _oAscSelectionType . RangeShapeText ,
is _shape = seltype == Asc . c _oAscSelectionType . RangeShape ,
2020-06-05 16:28:11 +00:00
is _image = seltype == Asc . c _oAscSelectionType . RangeImage || seltype == Asc . c _oAscSelectionType . RangeSlicer ,
2017-04-28 12:24:57 +00:00
is _mode _2 = is _shape _text || is _shape || is _chart _text || is _chart ,
is _objLocked = false ;
if ( ! ( is _mode _2 || is _image ) &&
me . _state . selection _type === seltype &&
me . _state . coauthdisable === coauth _disable )
return ( seltype === Asc . c _oAscSelectionType . RangeImage ) ;
if ( is _mode _2 ) {
var selectedObjects = me . api . asc _getGraphicObjectProps ( ) ;
is _objLocked = selectedObjects . some ( function ( object ) {
return object . asc _getObjectType ( ) == Asc . c _oAscTypeSelectElement . Image && object . asc _getObjectValue ( ) . asc _getLocked ( ) ;
} ) ;
}
2021-12-29 16:41:15 +00:00
var _set = Common . enumLock ;
2017-04-28 12:24:57 +00:00
var type = seltype ;
switch ( seltype ) {
2020-06-05 16:28:11 +00:00
case Asc . c _oAscSelectionType . RangeSlicer :
2017-04-28 12:24:57 +00:00
case Asc . c _oAscSelectionType . RangeImage : type = _set . selImage ; break ;
case Asc . c _oAscSelectionType . RangeShape : type = _set . selShape ; break ;
case Asc . c _oAscSelectionType . RangeShapeText : type = _set . selShapeText ; break ;
case Asc . c _oAscSelectionType . RangeChart : type = _set . selChart ; break ;
case Asc . c _oAscSelectionType . RangeChartText : type = _set . selChartText ; break ;
}
me . toolbar . lockToolbar ( type , type != seltype , {
clear : [ _set . selImage , _set . selChart , _set . selChartText , _set . selShape , _set . selShapeText , _set . coAuth ]
} ) ;
2021-12-29 16:41:15 +00:00
me . toolbar . lockToolbar ( Common . enumLock . coAuthText , is _objLocked ) ;
2017-04-28 12:24:57 +00:00
return is _image ;
} ;
2020-05-14 08:39:04 +00:00
var selectionType = info . asc _getSelectionType ( ) ,
2020-05-15 10:52:52 +00:00
xfs = info . asc _getXfs ( ) ,
2017-04-28 12:24:57 +00:00
coauth _disable = false ;
if ( _disableEditOptions ( selectionType , coauth _disable ) ) return ;
2020-10-02 15:33:07 +00:00
var need _disable = ( selectionType === Asc . c _oAscSelectionType . RangeCells || selectionType === Asc . c _oAscSelectionType . RangeCol ||
selectionType === Asc . c _oAscSelectionType . RangeRow || selectionType === Asc . c _oAscSelectionType . RangeMax ) ;
2021-12-29 16:41:15 +00:00
this . toolbar . lockToolbar ( Common . enumLock . selRange , need _disable , { array : [ this . toolbar . btnEditChartData , this . toolbar . btnEditChartType ] } ) ;
2020-10-02 15:33:07 +00:00
2017-04-28 12:24:57 +00:00
if ( selectionType == Asc . c _oAscSelectionType . RangeChart || selectionType == Asc . c _oAscSelectionType . RangeChartText )
return ;
2020-05-15 10:52:52 +00:00
var val = xfs . asc _getNumFormatInfo ( ) ;
2017-04-28 12:24:57 +00:00
if ( val ) {
2020-05-15 10:52:52 +00:00
this . _state . numformat = xfs . asc _getNumFormat ( ) ;
2017-04-28 12:24:57 +00:00
this . _state . numformatinfo = val ;
val = val . asc _getType ( ) ;
if ( this . _state . numformattype !== val ) {
me . toolbar . cmbNumberFormat . setValue ( val , me . toolbar . txtCustom ) ;
this . _state . numformattype = val ;
}
}
} ,
2017-04-28 13:37:28 +00:00
onApiSelectionChanged _MailMergeEditor : function ( info ) {
2022-10-28 14:02:42 +00:00
if ( ! this . editMode || this . api . isCellEdited || this . api . isRangeSelection || ! info ) return ;
2017-04-28 13:37:28 +00:00
var me = this ;
var _disableEditOptions = function ( seltype , coauth _disable ) {
var is _chart _text = seltype == Asc . c _oAscSelectionType . RangeChartText ,
is _chart = seltype == Asc . c _oAscSelectionType . RangeChart ,
is _shape _text = seltype == Asc . c _oAscSelectionType . RangeShapeText ,
is _shape = seltype == Asc . c _oAscSelectionType . RangeShape ,
2020-06-05 16:28:11 +00:00
is _image = seltype == Asc . c _oAscSelectionType . RangeImage || seltype == Asc . c _oAscSelectionType . RangeSlicer ,
2017-04-28 13:37:28 +00:00
is _mode _2 = is _shape _text || is _shape || is _chart _text || is _chart ,
is _objLocked = false ;
if ( ! ( is _mode _2 || is _image ) &&
me . _state . selection _type === seltype &&
me . _state . coauthdisable === coauth _disable )
return seltype === Asc . c _oAscSelectionType . RangeImage ;
if ( is _mode _2 ) {
var selectedObjects = me . api . asc _getGraphicObjectProps ( ) ;
is _objLocked = selectedObjects . some ( function ( object ) {
return object . asc _getObjectType ( ) == Asc . c _oAscTypeSelectElement . Image && object . asc _getObjectValue ( ) . asc _getLocked ( ) ;
} ) ;
}
2021-12-29 16:41:15 +00:00
me . toolbar . lockToolbar ( Common . enumLock . coAuthText , is _objLocked ) ;
2017-04-28 13:37:28 +00:00
return is _image ;
} ;
2020-05-14 08:39:04 +00:00
var selectionType = info . asc _getSelectionType ( ) ,
2017-04-28 13:37:28 +00:00
coauth _disable = false ,
editOptionsDisabled = _disableEditOptions ( selectionType , coauth _disable ) ,
val , need _disable = false ;
if ( editOptionsDisabled ) return ;
if ( selectionType == Asc . c _oAscSelectionType . RangeChart || selectionType == Asc . c _oAscSelectionType . RangeChartText )
return ;
if ( ! me . toolbar . mode . isEditDiagram ) {
var filterInfo = info . asc _getAutoFilterInfo ( ) ;
val = filterInfo ? filterInfo . asc _getIsAutoFilter ( ) : null ;
if ( this . _state . filter !== val ) {
me . toolbar . btnSetAutofilter . toggle ( val === true , true ) ;
this . _state . filter = val ;
}
need _disable = this . _state . controlsdisabled . filters || ( val === null ) ;
2021-12-29 16:41:15 +00:00
me . toolbar . lockToolbar ( Common . enumLock . ruleFilter , need _disable ,
2019-06-03 10:20:24 +00:00
{ array : [ me . toolbar . btnSetAutofilter , me . toolbar . btnSortDown , me . toolbar . btnSortUp ] } ) ;
2017-04-28 13:37:28 +00:00
need _disable = this . _state . controlsdisabled . filters || ! filterInfo || ( filterInfo . asc _getIsApplyAutoFilter ( ) !== true ) ;
2021-12-29 16:41:15 +00:00
me . toolbar . lockToolbar ( Common . enumLock . ruleDelFilter , need _disable , { array : [ me . toolbar . btnClearAutofilter ] } ) ;
2017-04-28 13:37:28 +00:00
}
} ,
2022-03-11 10:58:15 +00:00
onApiSelectionChanged _OleEditor : function ( info ) {
2022-10-28 14:02:42 +00:00
if ( ! this . editMode || this . api . isCellEdited || this . api . isRangeSelection || ! info ) return ;
2022-03-11 10:58:15 +00:00
var me = this ;
var _disableEditOptions = function ( seltype , coauth _disable ) {
var is _chart _text = seltype == Asc . c _oAscSelectionType . RangeChartText ,
is _chart = seltype == Asc . c _oAscSelectionType . RangeChart ,
is _shape _text = seltype == Asc . c _oAscSelectionType . RangeShapeText ,
is _shape = seltype == Asc . c _oAscSelectionType . RangeShape ,
is _image = seltype == Asc . c _oAscSelectionType . RangeImage || seltype == Asc . c _oAscSelectionType . RangeSlicer ,
is _mode _2 = is _shape _text || is _shape || is _chart _text || is _chart ,
is _objLocked = false ;
if ( ! ( is _mode _2 || is _image ) &&
me . _state . selection _type === seltype &&
me . _state . coauthdisable === coauth _disable )
return seltype === Asc . c _oAscSelectionType . RangeImage ;
if ( is _mode _2 ) {
var selectedObjects = me . api . asc _getGraphicObjectProps ( ) ;
is _objLocked = selectedObjects . some ( function ( object ) {
return object . asc _getObjectType ( ) == Asc . c _oAscTypeSelectElement . Image && object . asc _getObjectValue ( ) . asc _getLocked ( ) ;
} ) ;
}
2022-03-16 11:17:25 +00:00
var _set = Common . enumLock ;
var type = seltype ;
switch ( seltype ) {
case Asc . c _oAscSelectionType . RangeSlicer :
case Asc . c _oAscSelectionType . RangeImage : type = _set . selImage ; break ;
case Asc . c _oAscSelectionType . RangeShape : type = _set . selShape ; break ;
case Asc . c _oAscSelectionType . RangeShapeText : type = _set . selShapeText ; break ;
case Asc . c _oAscSelectionType . RangeChart : type = _set . selChart ; break ;
case Asc . c _oAscSelectionType . RangeChartText : type = _set . selChartText ; break ;
}
me . toolbar . lockToolbar ( type , type != seltype , {
clear : [ _set . selImage , _set . selChart , _set . selChartText , _set . selShape , _set . selShapeText , _set . coAuth ]
} ) ;
2022-03-11 10:58:15 +00:00
me . toolbar . lockToolbar ( Common . enumLock . coAuthText , is _objLocked ) ;
2022-05-31 08:34:43 +00:00
me . _state . controlsdisabled . filters = is _image || is _mode _2 ;
2022-03-11 10:58:15 +00:00
return is _image ;
} ;
var selectionType = info . asc _getSelectionType ( ) ,
2022-03-16 11:17:25 +00:00
xfs = info . asc _getXfs ( ) ,
2022-05-31 08:34:43 +00:00
toolbar = this . toolbar ,
2022-03-11 10:58:15 +00:00
coauth _disable = false ,
editOptionsDisabled = _disableEditOptions ( selectionType , coauth _disable ) ,
val , need _disable = false ;
if ( editOptionsDisabled ) return ;
if ( selectionType == Asc . c _oAscSelectionType . RangeChart || selectionType == Asc . c _oAscSelectionType . RangeChartText )
return ;
2022-05-31 08:34:43 +00:00
Common . NotificationCenter . trigger ( 'fonts:change' , xfs ) ;
2022-03-11 10:58:15 +00:00
2022-05-31 08:34:43 +00:00
/* read font size */
var str _size = xfs . asc _getFontSize ( ) ;
if ( this . _state . fontsize !== str _size ) {
toolbar . cmbFontSize . setValue ( ( str _size !== undefined ) ? str _size : '' ) ;
this . _state . fontsize = str _size ;
}
2022-05-31 20:46:19 +00:00
val = xfs . asc _getFontBold ( ) ;
if ( this . _state . bold !== val ) {
toolbar . btnTextFormatting . menu . items [ 0 ] . setChecked ( val === true ) ;
this . _state . bold = val ;
}
val = xfs . asc _getFontItalic ( ) ;
if ( this . _state . italic !== val ) {
toolbar . btnTextFormatting . menu . items [ 1 ] . setChecked ( val === true ) ;
this . _state . italic = val ;
}
val = xfs . asc _getFontUnderline ( ) ;
if ( this . _state . underline !== val ) {
toolbar . btnTextFormatting . menu . items [ 2 ] . setChecked ( val === true ) ;
this . _state . underline = val ;
}
val = xfs . asc _getFontStrikeout ( ) ;
if ( this . _state . strikeout !== val ) {
toolbar . btnTextFormatting . menu . items [ 3 ] . setChecked ( val === true ) ;
this . _state . strikeout = val ;
}
val = xfs . asc _getFontSuperscript ( ) ;
if ( this . _state . superscript !== val ) {
toolbar . btnTextFormatting . menu . items [ 4 ] . setChecked ( val === true ) ;
this . _state . superscript = val ;
}
val = xfs . asc _getFontSubscript ( ) ;
if ( this . _state . subscript !== val ) {
toolbar . btnTextFormatting . menu . items [ 5 ] . setChecked ( val === true ) ;
this . _state . subscript = val ;
}
2022-05-31 08:34:43 +00:00
/* read font color */
var clr ,
color ,
fontColorPicker = toolbar . mnuTextColorPicker ,
paragraphColorPicker = toolbar . mnuBackColorPicker ;
if ( ! fontColorPicker . isDummy ) {
color = xfs . asc _getFontColor ( ) ;
if ( color ) {
if ( color . get _auto ( ) ) {
if ( this . _state . clrtext !== 'auto' ) {
fontColorPicker . clearSelection ( ) ;
toolbar . btnTextColor . setAutoColor ( true ) ;
this . _state . clrtext = 'auto' ;
}
} else {
if ( color . get _type ( ) == Asc . c _oAscColor . COLOR _TYPE _SCHEME ) {
clr = { color : Common . Utils . ThemeColor . getHexColor ( color . get _r ( ) , color . get _g ( ) , color . get _b ( ) ) , effectValue : color . get _value ( ) } ;
} else {
clr = Common . Utils . ThemeColor . getHexColor ( color . get _r ( ) , color . get _g ( ) , color . get _b ( ) ) ;
}
var type1 = typeof ( clr ) ,
type2 = typeof ( this . _state . clrtext ) ;
if ( ( this . _state . clrtext == 'auto' ) || ( type1 !== type2 ) || ( type1 == 'object' &&
( clr . effectValue !== this . _state . clrtext . effectValue || this . _state . clrtext . color . indexOf ( clr . color ) < 0 ) ) ||
( type1 != 'object' && this . _state . clrtext !== undefined && this . _state . clrtext . indexOf ( clr ) < 0 ) ) {
toolbar . btnTextColor . setAutoColor ( false ) ;
if ( _ . isObject ( clr ) ) {
var isselected = false ;
for ( var i = 0 ; i < 10 ; i ++ ) {
if ( Common . Utils . ThemeColor . ThemeValues [ i ] == clr . effectValue ) {
fontColorPicker . select ( clr , true ) ;
isselected = true ;
break ;
}
}
if ( ! isselected ) fontColorPicker . clearSelection ( ) ;
} else {
fontColorPicker . select ( clr , true ) ;
}
this . _state . clrtext = clr ;
}
}
2022-03-11 10:58:15 +00:00
}
2022-05-31 08:34:43 +00:00
this . _state . clrtext _asccolor = color ;
}
2022-03-11 10:58:15 +00:00
2022-05-31 08:34:43 +00:00
/* read cell background color */
if ( ! paragraphColorPicker . isDummy ) {
color = xfs . asc _getFillColor ( ) ;
if ( color && ! color . get _auto ( ) ) {
if ( color . get _type ( ) == Asc . c _oAscColor . COLOR _TYPE _SCHEME ) {
clr = { color : Common . Utils . ThemeColor . getHexColor ( color . get _r ( ) , color . get _g ( ) , color . get _b ( ) ) , effectValue : color . get _value ( ) } ;
} else {
clr = Common . Utils . ThemeColor . getHexColor ( color . get _r ( ) , color . get _g ( ) , color . get _b ( ) ) ;
}
} else {
clr = 'transparent' ;
}
2022-03-11 10:58:15 +00:00
2022-05-31 08:34:43 +00:00
type1 = typeof ( clr ) ;
type2 = typeof ( this . _state . clrback ) ;
if ( ( type1 !== type2 ) || ( type1 == 'object' &&
( clr . effectValue !== this . _state . clrback . effectValue || this . _state . clrback . color . indexOf ( clr . color ) < 0 ) ) ||
( type1 != 'object' && this . _state . clrback !== undefined && this . _state . clrback . indexOf ( clr ) < 0 ) ) {
if ( _ . isObject ( clr ) ) {
var isselected = false ;
for ( i = 0 ; i < 10 ; i ++ ) {
if ( Common . Utils . ThemeColor . ThemeValues [ i ] == clr . effectValue ) {
paragraphColorPicker . select ( clr , true ) ;
isselected = true ;
break ;
}
}
if ( ! isselected ) paragraphColorPicker . clearSelection ( ) ;
} else {
paragraphColorPicker . select ( clr , true ) ;
}
this . _state . clrback = clr ;
}
this . _state . clrshd _asccolor = color ;
2022-03-11 10:58:15 +00:00
}
2022-03-16 11:17:25 +00:00
2022-05-31 08:34:43 +00:00
var filterInfo = info . asc _getAutoFilterInfo ( ) ,
formatTableInfo = info . asc _getFormatTableInfo ( ) ;
/* read cell horizontal align */
2022-05-31 20:46:19 +00:00
2022-05-31 08:34:43 +00:00
var fontparam = xfs . asc _getHorAlign ( ) ;
if ( this . _state . pralign !== fontparam ) {
this . _state . pralign = fontparam ;
var index = - 1 , align ;
switch ( fontparam ) {
case AscCommon . align _Left : index = 0 ; align = 'btn-align-left' ; break ;
case AscCommon . align _Center : index = 1 ; align = 'btn-align-center' ; break ;
case AscCommon . align _Right : index = 2 ; align = 'btn-align-right' ; break ;
case AscCommon . align _Justify : index = 3 ; align = 'btn-align-just' ; break ;
default : index = - 255 ; align = 'btn-align-left' ; break ;
}
if ( ! ( index < 0 ) ) {
2022-05-31 20:46:19 +00:00
toolbar . btnHorizontalAlign . menu . items [ index ] . setChecked ( true ) ;
2022-05-31 08:34:43 +00:00
} else if ( index == - 255 ) {
2022-05-31 20:46:19 +00:00
toolbar . btnHorizontalAlign . menu . clearAll ( ) ;
}
if ( toolbar . btnHorizontalAlign . rendered && toolbar . btnHorizontalAlign . $icon ) {
toolbar . btnHorizontalAlign . $icon . removeClass ( toolbar . btnHorizontalAlign . options . icls ) . addClass ( align ) ;
toolbar . btnHorizontalAlign . options . icls = align ;
2022-05-31 08:34:43 +00:00
}
}
// read cell vertical align
fontparam = xfs . asc _getVertAlign ( ) ;
if ( this . _state . valign !== fontparam ) {
this . _state . valign = fontparam ;
index = - 1 ; align = '' ;
switch ( fontparam ) {
2022-05-31 20:46:19 +00:00
case Asc . c _oAscVAlign . Top : index = 0 ; align = 'btn-align-top' ; break ;
case Asc . c _oAscVAlign . Center : index = 1 ; align = 'btn-align-middle' ; break ;
case Asc . c _oAscVAlign . Bottom : index = 2 ; align = 'btn-align-bottom' ; break ;
}
if ( ! ( index < 0 ) ) {
toolbar . btnVerticalAlign . menu . items [ index ] . setChecked ( true ) ;
} else if ( index == - 255 ) {
toolbar . btnVerticalAlign . menu . clearAll ( ) ;
}
if ( toolbar . btnVerticalAlign . rendered && toolbar . btnVerticalAlign . $icon ) {
toolbar . btnVerticalAlign . $icon . removeClass ( toolbar . btnVerticalAlign . options . icls ) . addClass ( align ) ;
toolbar . btnVerticalAlign . options . icls = align ;
2022-05-31 08:34:43 +00:00
}
}
2022-05-31 20:46:19 +00:00
2022-05-31 08:34:43 +00:00
need _disable = this . _state . controlsdisabled . filters || formatTableInfo !== null || filterInfo && filterInfo . asc _getIsAutoFilter ( ) === null ;
toolbar . lockToolbar ( Common . enumLock . ruleMerge , need _disable , { array : [ toolbar . btnMerge ] } ) ;
val = info . asc _getMerge ( ) ;
if ( this . _state . merge !== val ) {
toolbar . btnMerge . toggle ( val === Asc . c _oAscMergeOptions . Merge , true ) ;
this . _state . merge = val ;
}
/* read cell text wrapping */
if ( ! toolbar . btnWrap . isDisabled ( ) ) {
val = xfs . asc _getWrapText ( ) ;
if ( this . _state . wrap !== val ) {
toolbar . btnWrap . toggle ( val === true , true ) ;
this . _state . wrap = val ;
}
}
val = ( filterInfo ) ? filterInfo . asc _getIsAutoFilter ( ) : null ;
this . _state . filter = val ;
need _disable = this . _state . controlsdisabled . filters || ( val === null ) ;
toolbar . lockToolbar ( Common . enumLock . ruleFilter , need _disable , { array : [ toolbar . btnTableTemplate ] } ) ;
val = ( formatTableInfo ) ? formatTableInfo . asc _getTableStyleName ( ) : null ;
if ( this . _state . tablestylename !== val && this . toolbar . mnuTableTemplatePicker ) {
val = this . toolbar . mnuTableTemplatePicker . store . findWhere ( { name : val } ) ;
if ( val ) {
this . toolbar . mnuTableTemplatePicker . selectRecord ( val ) ;
this . _state . tablestylename = val . get ( 'name' ) ;
} else {
toolbar . mnuTableTemplatePicker . deselectAll ( ) ;
this . _state . tablestylename = null ;
}
}
2022-09-22 19:06:58 +00:00
val = info . asc _getStyleName ( ) ;
if ( this . _state . prstyle != val && this . toolbar . mnuCellStylePicker ) {
val = this . toolbar . mnuCellStylePicker . store . findWhere ( { name : val } ) ;
if ( val ) {
this . toolbar . mnuCellStylePicker . selectRecord ( val ) ;
this . _state . prstyle = val . get ( 'name' ) ;
} else {
this . toolbar . mnuCellStylePicker . deselectAll ( ) ;
this . _state . prstyle = null ;
}
}
2022-05-31 21:03:59 +00:00
var old _name = this . _state . tablename ;
2022-05-31 08:34:43 +00:00
this . _state . tablename = ( formatTableInfo ) ? formatTableInfo . asc _getTableName ( ) : undefined ;
2022-05-31 21:03:59 +00:00
var old _applied = this . _state . filterapplied ;
2022-05-31 08:34:43 +00:00
this . _state . filterapplied = this . _state . filter && filterInfo . asc _getIsApplyAutoFilter ( ) ;
2022-05-31 21:03:59 +00:00
if ( this . _state . tablename !== old _name || this . _state . filterapplied !== old _applied )
this . getApplication ( ) . getController ( 'Statusbar' ) . onApiFilterInfo ( ! need _disable ) ;
2022-05-31 08:34:43 +00:00
this . _state . multiselect = info . asc _getMultiselect ( ) ;
toolbar . lockToolbar ( Common . enumLock . multiselect , this . _state . multiselect , { array : [ toolbar . btnTableTemplate ] } ) ;
this . _state . inpivot = ! ! info . asc _getPivotTableInfo ( ) ;
toolbar . lockToolbar ( Common . enumLock . editPivot , this . _state . inpivot , { array : [ toolbar . btnMerge ] } ) ;
need _disable = ! this . appConfig . canModifyFilter ;
toolbar . lockToolbar ( Common . enumLock . cantModifyFilter , need _disable , { array : [ toolbar . btnTableTemplate ] } ) ;
val = xfs . asc _getNumFormatInfo ( ) ;
2022-03-16 11:17:25 +00:00
if ( val ) {
this . _state . numformat = xfs . asc _getNumFormat ( ) ;
this . _state . numformatinfo = val ;
val = val . asc _getType ( ) ;
if ( this . _state . numformattype !== val ) {
me . toolbar . cmbNumberFormat . setValue ( val , me . toolbar . txtCustom ) ;
this . _state . numformattype = val ;
}
}
2022-03-11 10:58:15 +00:00
} ,
2022-05-31 08:34:43 +00:00
onApiEditorSelectionChanged _OleEditor : function ( fontobj ) {
if ( ! this . editMode || $ ( '.asc-window.enable-key-events:visible' ) . length > 0 ) return ;
var toolbar = this . toolbar ,
val ;
/* read font name */
Common . NotificationCenter . trigger ( 'fonts:change' , fontobj ) ;
/* read font params */
2022-05-31 20:46:19 +00:00
val = fontobj . asc _getFontBold ( ) ;
if ( this . _state . bold !== val ) {
toolbar . btnTextFormatting . menu . items [ 0 ] . setChecked ( val === true ) ;
this . _state . bold = val ;
}
val = fontobj . asc _getFontItalic ( ) ;
if ( this . _state . italic !== val ) {
toolbar . btnTextFormatting . menu . items [ 1 ] ( val === true ) ;
this . _state . italic = val ;
}
val = fontobj . asc _getFontUnderline ( ) ;
if ( this . _state . underline !== val ) {
toolbar . btnTextFormatting . menu . items [ 2 ] ( val === true ) ;
this . _state . underline = val ;
}
val = fontobj . asc _getFontStrikeout ( ) ;
if ( this . _state . strikeout !== val ) {
toolbar . btnTextFormatting . menu . items [ 3 ] ( val === true ) ;
this . _state . strikeout = val ;
}
val = fontobj . asc _getFontSubscript ( ) ;
if ( this . _state . subscript !== val ) {
toolbar . btnTextFormatting . menu . items [ 4 ] ( val === true ) ;
this . _state . subscript = val ;
}
val = fontobj . asc _getFontSuperscript ( ) ;
if ( this . _state . superscript !== val ) {
toolbar . btnTextFormatting . menu . items [ 5 ] ( val === true ) ;
this . _state . superscript = val ;
}
2022-05-31 08:34:43 +00:00
/* read font size */
var str _size = fontobj . asc _getFontSize ( ) ;
if ( this . _state . fontsize !== str _size ) {
toolbar . cmbFontSize . setValue ( ( str _size !== undefined ) ? str _size : '' ) ;
this . _state . fontsize = str _size ;
}
/* read font color */
2022-05-31 20:46:19 +00:00
var clr ,
color ,
fontColorPicker = this . toolbar . mnuTextColorPicker ;
2022-05-31 08:34:43 +00:00
2022-05-31 20:46:19 +00:00
if ( ! fontColorPicker . isDummy ) {
color = fontobj . asc _getFontColor ( ) ;
if ( color ) {
if ( color . get _auto ( ) ) {
if ( this . _state . clrtext !== 'auto' ) {
fontColorPicker . clearSelection ( ) ;
this . toolbar . btnTextColor . setAutoColor ( true ) ;
this . _state . clrtext = 'auto' ;
}
} else {
if ( color . get _type ( ) == Asc . c _oAscColor . COLOR _TYPE _SCHEME ) {
clr = { color : Common . Utils . ThemeColor . getHexColor ( color . get _r ( ) , color . get _g ( ) , color . get _b ( ) ) , effectValue : color . get _value ( ) } ;
} else {
clr = Common . Utils . ThemeColor . getHexColor ( color . get _r ( ) , color . get _g ( ) , color . get _b ( ) ) ;
}
var type1 = typeof ( clr ) ,
type2 = typeof ( this . _state . clrtext ) ;
if ( ( this . _state . clrtext == 'auto' ) || ( type1 !== type2 ) || ( type1 == 'object' &&
( clr . effectValue !== this . _state . clrtext . effectValue || this . _state . clrtext . color . indexOf ( clr . color ) < 0 ) ) ||
( type1 != 'object' && this . _state . clrtext !== undefined && this . _state . clrtext . indexOf ( clr ) < 0 ) ) {
this . toolbar . btnTextColor . setAutoColor ( false ) ;
if ( _ . isObject ( clr ) ) {
var isselected = false ;
for ( var i = 0 ; i < 10 ; i ++ ) {
if ( Common . Utils . ThemeColor . ThemeValues [ i ] == clr . effectValue ) {
fontColorPicker . select ( clr , true ) ;
isselected = true ;
break ;
}
}
if ( ! isselected ) fontColorPicker . clearSelection ( ) ;
} else {
fontColorPicker . select ( clr , true ) ;
}
this . _state . clrtext = clr ;
}
}
}
this . _state . clrtext _asccolor = color ;
}
2022-05-31 08:34:43 +00:00
} ,
2016-03-11 00:48:53 +00:00
onApiStyleChange : function ( ) {
this . toolbar . btnCopyStyle . toggle ( false , true ) ;
this . modeAlwaysSetStyle = false ;
} ,
updateThemeColors : function ( ) {
var updateColors = function ( picker , defaultColor ) {
if ( picker ) {
var clr ;
var effectcolors = Common . Utils . ThemeColor . getEffectColors ( ) ;
for ( var i = 0 ; i < effectcolors . length ; i ++ ) {
if ( typeof ( picker . currentColor ) == 'object' &&
clr === undefined &&
picker . currentColor . effectId == effectcolors [ i ] . effectId )
clr = effectcolors [ i ] ;
}
picker . updateColors ( effectcolors , Common . Utils . ThemeColor . getStandartColors ( ) ) ;
if ( picker . currentColor === undefined ) {
picker . currentColor = defaultColor ;
} else if ( clr !== undefined ) {
picker . currentColor = clr ;
}
}
} ;
updateColors ( this . toolbar . mnuTextColorPicker , Common . Utils . ThemeColor . getStandartColors ( ) [ 1 ] ) ;
2021-01-21 21:45:44 +00:00
if ( this . toolbar . btnTextColor . currentColor === undefined || ! this . toolbar . btnTextColor . currentColor . isAuto ) {
2016-03-11 00:48:53 +00:00
this . toolbar . btnTextColor . currentColor = Common . Utils . ThemeColor . getStandartColors ( ) [ 1 ] ;
2021-01-21 21:45:44 +00:00
this . toolbar . btnTextColor . setColor ( this . toolbar . btnTextColor . currentColor ) ;
}
2016-03-11 00:48:53 +00:00
updateColors ( this . toolbar . mnuBackColorPicker , Common . Utils . ThemeColor . getStandartColors ( ) [ 3 ] ) ;
if ( this . toolbar . btnBackColor . currentColor === undefined ) {
this . toolbar . btnBackColor . currentColor = Common . Utils . ThemeColor . getStandartColors ( ) [ 3 ] ;
} else
this . toolbar . btnBackColor . currentColor = this . toolbar . mnuBackColorPicker . currentColor . color || this . toolbar . mnuBackColorPicker . currentColor ;
2021-01-21 19:48:27 +00:00
this . toolbar . btnBackColor . setColor ( this . toolbar . btnBackColor . currentColor ) ;
2016-03-11 00:48:53 +00:00
if ( this . _state . clrtext _asccolor !== undefined || this . _state . clrshd _asccolor !== undefined ) {
this . _state . clrtext = undefined ;
this . _state . clrback = undefined ;
this . onApiSelectionChanged ( this . api . asc _getCellInfo ( ) ) ;
2017-04-28 12:24:57 +00:00
}
2016-03-11 00:48:53 +00:00
this . _state . clrtext _asccolor = undefined ;
this . _state . clrshd _asccolor = undefined ;
2016-09-01 14:45:04 +00:00
if ( this . toolbar . mnuBorderColorPicker ) {
2021-01-20 15:38:07 +00:00
updateColors ( this . toolbar . mnuBorderColorPicker , { color : '000' , isAuto : true } ) ;
var currentColor = this . toolbar . mnuBorderColorPicker . currentColor ;
if ( currentColor && currentColor . isAuto ) {
var clr _item = this . toolbar . btnBorders . menu . $el . find ( '#id-toolbar-menu-auto-bordercolor > a' ) ;
! clr _item . hasClass ( 'selected' ) && clr _item . addClass ( 'selected' ) ;
}
this . toolbar . btnBorders . options . borderscolor = currentColor . color || currentColor ;
$ ( '#id-toolbar-mnu-item-border-color > a .menu-item-icon' ) . css ( 'border-color' , '#' + this . toolbar . btnBorders . options . borderscolor ) ;
2016-09-01 14:45:04 +00:00
}
2016-03-11 00:48:53 +00:00
} ,
hideElements : function ( opts ) {
if ( ! _ . isUndefined ( opts . compact ) ) {
this . onChangeViewMode ( opts . compact ) ;
}
if ( ! _ . isUndefined ( opts . formula ) ) {
var cellEditor = this . getApplication ( ) . getController ( 'CellEditor' ) . getView ( 'CellEditor' ) ;
cellEditor && cellEditor . setVisible ( ! opts . formula ) ;
Common . NotificationCenter . trigger ( 'layout:changed' , 'celleditor' , opts . formula ? 'hidden' : 'showed' ) ;
}
if ( ! _ . isUndefined ( opts . headings ) ) {
if ( this . api ) {
2016-12-14 12:23:53 +00:00
this . api . asc _setDisplayHeadings ( ! opts . headings ) ;
2016-03-11 00:48:53 +00:00
}
}
if ( ! _ . isUndefined ( opts . gridlines ) ) {
if ( this . api ) {
2016-12-14 12:23:53 +00:00
this . api . asc _setDisplayGridlines ( ! opts . gridlines ) ;
2016-03-11 00:48:53 +00:00
}
}
2016-11-18 12:36:48 +00:00
if ( ! _ . isUndefined ( opts . freezepanes ) ) {
if ( this . api ) {
this . api . asc _freezePane ( ) ;
}
}
2016-03-11 00:48:53 +00:00
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
} ,
2019-08-20 11:05:13 +00:00
onApiAutoShapes : function ( ) {
var me = this ;
var onShowBefore = function ( menu ) {
me . fillAutoShapes ( ) ;
menu . off ( 'show:before' , onShowBefore ) ;
} ;
me . toolbar . btnInsertShape . menu . on ( 'show:before' , onShowBefore ) ;
} ,
2016-03-11 00:48:53 +00:00
fillAutoShapes : function ( ) {
2021-10-04 12:56:34 +00:00
var me = this ;
2016-03-11 00:48:53 +00:00
2021-09-16 17:47:48 +00:00
var menuitem = new Common . UI . MenuItem ( {
template : _ . template ( '<div id="id-toolbar-menu-insertshape" class="menu-insertshape"></div>' )
} ) ;
me . toolbar . btnInsertShape . menu . addItem ( menuitem ) ;
var recents = Common . localStorage . getItem ( 'sse-recent-shapes' ) ;
var shapePicker = new Common . UI . DataViewShape ( {
el : $ ( '#id-toolbar-menu-insertshape' ) ,
itemTemplate : _ . template ( '<div class="item-shape" id="<%= id %>"><svg width="20" height="20" class=\"icon\"><use xlink:href=\"#svg-icon-<%= data.shapeType %>\"></use></svg></div>' ) ,
2021-10-04 12:56:34 +00:00
groups : me . getApplication ( ) . getCollection ( 'ShapeGroups' ) ,
2021-09-16 17:47:48 +00:00
parentMenu : me . toolbar . btnInsertShape . menu ,
2022-01-17 16:44:25 +00:00
restoreHeight : 652 ,
2021-09-16 17:47:48 +00:00
textRecentlyUsed : me . textRecentlyUsed ,
recentShapes : recents ? JSON . parse ( recents ) : null
} ) ;
shapePicker . on ( 'item:click' , function ( picker , item , record , e ) {
if ( me . api ) {
if ( record ) {
me . _addAutoshape ( true , record . get ( 'data' ) . shapeType ) ;
me . _isAddingShape = true ;
}
2019-08-20 08:05:52 +00:00
2021-09-16 17:47:48 +00:00
if ( me . toolbar . btnInsertText . pressed ) {
me . toolbar . btnInsertText . toggle ( false , true ) ;
}
if ( e . type !== 'click' )
me . toolbar . btnInsertShape . menu . hide ( ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , me . toolbar , me . toolbar . btnInsertShape ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Add Shape' ) ;
2019-08-20 08:05:52 +00:00
}
2021-09-16 17:47:48 +00:00
} ) ;
2016-03-11 00:48:53 +00:00
} ,
2016-10-21 09:33:49 +00:00
fillEquations : function ( ) {
2016-10-24 10:58:34 +00:00
if ( ! this . toolbar . btnInsertEquation . rendered || this . toolbar . btnInsertEquation . menu . items . length > 0 ) return ;
2016-10-21 09:33:49 +00:00
var me = this , equationsStore = this . getApplication ( ) . getCollection ( 'EquationGroups' ) ;
me . toolbar . btnInsertEquation . menu . removeAll ( ) ;
2019-08-15 14:09:26 +00:00
var onShowAfter = function ( menu ) {
for ( var i = 0 ; i < equationsStore . length ; ++ i ) {
var equationPicker = new Common . UI . DataViewSimple ( {
el : $ ( '#id-toolbar-menu-equationgroup' + i ) ,
parentMenu : menu . items [ i ] . menu ,
store : equationsStore . at ( i ) . get ( 'groupStore' ) ,
scrollAlwaysVisible : true ,
2021-01-18 09:19:38 +00:00
itemTemplate : _ . template (
'<div class="item-equation">' +
'<div class="equation-icon" style="background-position:<%= posX %>px <%= posY %>px;width:<%= width %>px;height:<%= height %>px;" id="<%= id %>"></div>' +
2019-08-15 14:09:26 +00:00
'</div>' )
} ) ;
equationPicker . on ( 'item:click' , function ( picker , item , record , e ) {
if ( me . api ) {
if ( record )
me . api . asc _AddMath ( record . get ( 'data' ) . equationType ) ;
if ( me . toolbar . btnInsertText . pressed ) {
me . toolbar . btnInsertText . toggle ( false , true ) ;
}
if ( me . toolbar . btnInsertShape . pressed ) {
me . toolbar . btnInsertShape . toggle ( false , true ) ;
}
if ( e . type !== 'click' )
me . toolbar . btnInsertEquation . menu . hide ( ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , me . toolbar , me . toolbar . btnInsertEquation ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Add Equation' ) ;
}
} ) ;
}
2019-08-20 08:05:52 +00:00
menu . off ( 'show:after' , onShowAfter ) ;
2019-08-15 14:09:26 +00:00
} ;
me . toolbar . btnInsertEquation . menu . on ( 'show:after' , onShowAfter ) ;
2016-10-21 09:33:49 +00:00
for ( var i = 0 ; i < equationsStore . length ; ++ i ) {
var equationGroup = equationsStore . at ( i ) ;
var menuItem = new Common . UI . MenuItem ( {
caption : equationGroup . get ( 'groupName' ) ,
menu : new Common . UI . Menu ( {
menuAlign : 'tl-tr' ,
items : [
{ template : _ . template ( '<div id="id-toolbar-menu-equationgroup' + i +
'" class="menu-shape" style="width:' + ( equationGroup . get ( 'groupWidth' ) + 8 ) + 'px; ' +
2022-10-31 22:23:02 +00:00
equationGroup . get ( 'groupHeightStr' ) + 'margin-left:5px;"></div>' ) }
2016-10-21 09:33:49 +00:00
]
} )
} ) ;
me . toolbar . btnInsertEquation . menu . addItem ( menuItem ) ;
}
} ,
onInsertEquationClick : function ( ) {
2016-10-25 10:48:31 +00:00
if ( this . api ) {
2016-10-21 09:33:49 +00:00
this . api . asc _AddMath ( ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Add Equation' ) ;
}
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar , this . toolbar . btnInsertEquation ) ;
} ,
2019-11-14 08:48:58 +00:00
onInsertSymbolClick : function ( ) {
2021-07-19 21:02:30 +00:00
Common . NotificationCenter . trigger ( 'protect:check' , this . onInsertSymbolClickCallback , this , [ ] ) ;
} ,
onInsertSymbolClickCallback : function ( ) {
2019-11-14 08:48:58 +00:00
if ( this . api ) {
var me = this ,
2020-10-05 14:32:18 +00:00
selected = me . api . asc _GetSelectedText ( ) ,
2019-11-14 08:48:58 +00:00
win = new Common . Views . SymbolTableDialog ( {
api : me . api ,
lang : me . toolbar . mode . lang ,
type : 1 ,
2020-04-02 13:14:45 +00:00
special : true ,
2019-11-14 08:48:58 +00:00
buttons : [ { value : 'ok' , caption : this . textInsert } , 'close' ] ,
2020-10-05 14:32:18 +00:00
font : selected && selected . length > 0 ? me . api . asc _getCellInfo ( ) . asc _getXfs ( ) . asc _getFontName ( ) : undefined ,
symbol : selected && selected . length > 0 ? selected . charAt ( 0 ) : undefined ,
2019-11-14 08:48:58 +00:00
handler : function ( dlg , result , settings ) {
if ( result == 'ok' ) {
2020-08-27 15:54:14 +00:00
me . api . asc _insertSymbol ( settings . font ? settings . font : me . api . asc _getCellInfo ( ) . asc _getXfs ( ) . asc _getFontName ( ) , settings . code , settings . special ) ;
2019-11-14 08:48:58 +00:00
} else
Common . NotificationCenter . trigger ( 'edit:complete' , me . toolbar ) ;
}
} ) ;
win . show ( ) ;
2019-11-15 13:57:55 +00:00
win . on ( 'symbol:dblclick' , function ( cmp , result , settings ) {
2020-08-27 15:54:14 +00:00
me . api . asc _insertSymbol ( settings . font ? settings . font : me . api . asc _getCellInfo ( ) . asc _getXfs ( ) . asc _getFontName ( ) , settings . code , settings . special ) ;
2019-11-14 08:48:58 +00:00
} ) ;
}
} ,
2020-04-10 14:50:58 +00:00
onInsertSlicerClick : function ( ) {
var me = this ,
props = me . api . asc _beforeInsertSlicer ( ) ;
if ( props ) {
( new SSE . Views . SlicerAddDialog ( {
props : props ,
handler : function ( result , settings ) {
2020-05-28 15:09:35 +00:00
if ( me && me . api && result == 'ok' ) {
2020-04-10 14:50:58 +00:00
me . api . asc _insertSlicer ( settings ) ;
}
Common . NotificationCenter . trigger ( 'edit:complete' , me . toolbar ) ;
}
} ) ) . show ( ) ;
}
} ,
2019-08-15 14:09:26 +00:00
onApiMathTypes : function ( equation ) {
this . _equationTemp = equation ;
var me = this ;
var onShowBefore = function ( menu ) {
me . onMathTypes ( me . _equationTemp ) ;
2022-10-31 22:23:02 +00:00
if ( me . _equationTemp && me . _equationTemp . get _Data ( ) . length > 0 )
me . fillEquations ( ) ;
2019-08-15 14:09:26 +00:00
me . toolbar . btnInsertEquation . menu . off ( 'show:before' , onShowBefore ) ;
} ;
me . toolbar . btnInsertEquation . menu . on ( 'show:before' , onShowBefore ) ;
} ,
2016-10-21 09:33:49 +00:00
onMathTypes : function ( equation ) {
2022-10-31 22:23:02 +00:00
equation = equation || this . _equationTemp ;
2016-10-21 09:33:49 +00:00
var equationgrouparray = [ ] ,
equationsStore = this . getCollection ( 'EquationGroups' ) ;
2022-10-31 22:23:02 +00:00
if ( equationsStore . length > 0 )
return ;
2016-10-21 09:33:49 +00:00
// equations groups
var c _oAscMathMainTypeStrings = { } ;
// [translate, count cells, scroll]
2022-10-31 22:23:02 +00:00
c _oAscMathMainTypeStrings [ Common . define . c _oAscMathMainType . Symbol ] = [ this . textSymbols , 11 , false , 'svg-icon-symbols' ] ;
c _oAscMathMainTypeStrings [ Common . define . c _oAscMathMainType . Fraction ] = [ this . textFraction , 4 , false , 'svg-icon-fraction' ] ;
c _oAscMathMainTypeStrings [ Common . define . c _oAscMathMainType . Script ] = [ this . textScript , 4 , false , 'svg-icon-script' ] ;
c _oAscMathMainTypeStrings [ Common . define . c _oAscMathMainType . Radical ] = [ this . textRadical , 4 , false , 'svg-icon-radical' ] ;
c _oAscMathMainTypeStrings [ Common . define . c _oAscMathMainType . Integral ] = [ this . textIntegral , 3 , true , 'svg-icon-integral' ] ;
c _oAscMathMainTypeStrings [ Common . define . c _oAscMathMainType . LargeOperator ] = [ this . textLargeOperator , 5 , true , 'svg-icon-largeOperator' ] ;
c _oAscMathMainTypeStrings [ Common . define . c _oAscMathMainType . Bracket ] = [ this . textBracket , 4 , true , 'svg-icon-bracket' ] ;
c _oAscMathMainTypeStrings [ Common . define . c _oAscMathMainType . Function ] = [ this . textFunction , 3 , true , 'svg-icon-function' ] ;
c _oAscMathMainTypeStrings [ Common . define . c _oAscMathMainType . Accent ] = [ this . textAccent , 4 , false , 'svg-icon-accent' ] ;
c _oAscMathMainTypeStrings [ Common . define . c _oAscMathMainType . LimitLog ] = [ this . textLimitAndLog , 3 , false , 'svg-icon-limAndLog' ] ;
c _oAscMathMainTypeStrings [ Common . define . c _oAscMathMainType . Operator ] = [ this . textOperator , 4 , false , 'svg-icon-operator' ] ;
c _oAscMathMainTypeStrings [ Common . define . c _oAscMathMainType . Matrix ] = [ this . textMatrix , 4 , true , 'svg-icon-matrix' ] ;
2016-10-21 09:33:49 +00:00
// equations sub groups
// equations types
var translationTable = { } , name = '' , translate = '' ;
for ( name in Common . define . c _oAscMathType ) {
if ( Common . define . c _oAscMathType . hasOwnProperty ( name ) ) {
var arr = name . split ( '_' ) ;
if ( arr . length == 2 && arr [ 0 ] == 'Symbol' ) {
translate = 'txt' + arr [ 0 ] + '_' + arr [ 1 ] . toLocaleLowerCase ( ) ;
} else
translate = 'txt' + name ;
translationTable [ Common . define . c _oAscMathType [ name ] ] = this [ translate ] ;
}
}
2019-08-15 14:09:26 +00:00
var i , id = 0 , count = 0 , length = 0 , width = 0 , height = 0 , store = null , list = null , eqStore = null , eq = null , data ;
2016-10-21 09:33:49 +00:00
if ( equation ) {
2019-08-15 14:09:26 +00:00
data = equation . get _Data ( ) ;
count = data . length ;
2016-10-21 09:33:49 +00:00
if ( count ) {
for ( var j = 0 ; j < count ; ++ j ) {
2019-08-15 14:09:26 +00:00
var group = data [ j ] ;
id = group . get _Id ( ) ;
width = group . get _W ( ) ;
height = group . get _H ( ) ;
2016-10-21 09:33:49 +00:00
store = new Backbone . Collection ( [ ] , {
model : SSE . Models . EquationModel
} ) ;
if ( store ) {
2019-08-15 14:09:26 +00:00
var allItemsCount = 0 , itemsCount = 0 , ids = 0 , arr = [ ] ;
length = group . get _Data ( ) . length ;
2016-10-21 09:33:49 +00:00
for ( i = 0 ; i < length ; ++ i ) {
2019-08-15 14:09:26 +00:00
eqStore = group . get _Data ( ) [ i ] ;
2016-10-21 09:33:49 +00:00
itemsCount = eqStore . get _Data ( ) . length ;
for ( var p = 0 ; p < itemsCount ; ++ p ) {
eq = eqStore . get _Data ( ) [ p ] ;
ids = eq . get _Id ( ) ;
translate = '' ;
if ( translationTable . hasOwnProperty ( ids ) ) {
translate = translationTable [ ids ] ;
}
2019-08-15 14:09:26 +00:00
arr . push ( {
2016-10-21 09:33:49 +00:00
data : { equationType : ids } ,
tip : translate ,
allowSelected : true ,
selected : false ,
width : eqStore . get _W ( ) ,
height : eqStore . get _H ( ) ,
posX : - eq . get _X ( ) ,
posY : - eq . get _Y ( )
} ) ;
}
allItemsCount += itemsCount ;
}
2019-08-15 14:09:26 +00:00
store . add ( arr ) ;
2016-10-21 09:33:49 +00:00
width = c _oAscMathMainTypeStrings [ id ] [ 1 ] * ( width + 10 ) ; // 4px margin + 4px margin + 1px border + 1px border
var normHeight = parseInt ( 370 / ( height + 10 ) ) * ( height + 10 ) ;
equationgrouparray . push ( {
groupName : c _oAscMathMainTypeStrings [ id ] [ 0 ] ,
groupStore : store ,
groupWidth : width ,
2022-10-31 22:23:02 +00:00
groupHeight : normHeight ,
groupHeightStr : c _oAscMathMainTypeStrings [ id ] [ 2 ] ? ' height:' + normHeight + 'px!important; ' : '' ,
groupIcon : c _oAscMathMainTypeStrings [ id ] [ 3 ]
2016-10-21 09:33:49 +00:00
} ) ;
}
}
equationsStore . add ( equationgrouparray ) ;
2022-10-31 22:23:02 +00:00
// this.fillEquations();
2016-10-21 09:33:49 +00:00
}
}
} ,
2016-03-11 00:48:53 +00:00
attachToControlEvents : function ( ) {
// this.control({
// 'menu[action=table-templates]':{
// select: this._onMenuTableTemplate,
// itemmouseenter: function(obj, record, item, index, event, eOpts) {
// if (obj.tooltip) obj.tooltip.close();
// obj.tooltip = Ext.create('Ext.tip.ToolTip', {
// closeAction : 'destroy',
// dismissDelay : 2000,
// html : record.get('caption')
// });
// var xy = event.getXY();
// obj.tooltip.showAt([xy[0]+10,xy[1]+10]);
// },
// itemmouseleave: function(obj, record, item, index, e, eOpts) {
// if (obj.tooltip) obj.tooltip.close();
// },
// hide: function() {
// this.getToolbar().fireEvent('editcomplete', this.getToolbar());
// }
// },
// 'menu[action=number-format]': {
// click: this._handleNumberFormatMenu
// }
// });
} ,
_disableEditOptions : function ( seltype , coauth _disable ) {
if ( this . api . isCellEdited ) return true ;
if ( this . api . isRangeSelection ) return true ;
var toolbar = this . toolbar ,
2016-04-05 11:52:34 +00:00
is _chart _text = seltype == Asc . c _oAscSelectionType . RangeChartText ,
is _chart = seltype == Asc . c _oAscSelectionType . RangeChart ,
is _shape _text = seltype == Asc . c _oAscSelectionType . RangeShapeText ,
is _shape = seltype == Asc . c _oAscSelectionType . RangeShape ,
is _image = seltype == Asc . c _oAscSelectionType . RangeImage ,
2020-06-05 16:28:11 +00:00
is _slicer = seltype == Asc . c _oAscSelectionType . RangeSlicer ,
is _mode _2 = is _shape _text || is _shape || is _chart _text || is _chart || is _slicer ,
2021-11-09 18:22:00 +00:00
is _objLocked = false ,
2021-12-07 15:49:59 +00:00
is _smartart _internal = false ,
2021-11-26 14:12:28 +00:00
is _lockShape = false ,
is _lockText = false ;
2016-11-24 08:36:52 +00:00
if ( ! ( is _mode _2 || is _image ) && this . _state . selection _type === seltype && this . _state . coauthdisable === coauth _disable ) return ( seltype === Asc . c _oAscSelectionType . RangeImage ) ;
if ( is _mode _2 ) {
var SelectedObjects = this . api . asc _getGraphicObjectProps ( ) ;
for ( var i = 0 ; i < SelectedObjects . length ; ++ i )
{
2021-11-09 18:22:00 +00:00
if ( SelectedObjects [ i ] . asc _getObjectType ( ) == Asc . c _oAscTypeSelectElement . Image ) {
var value = SelectedObjects [ i ] . asc _getObjectValue ( ) ,
shapeProps = value ? value . asc _getShapeProperties ( ) : null ;
if ( shapeProps ) {
is _smartart _internal = shapeProps . asc _getFromSmartArtInternal ( ) ;
}
2021-12-07 15:49:59 +00:00
is _objLocked = is _objLocked || value . asc _getLocked ( ) ;
is _lockText = is _lockText || value . asc _getProtectionLockText ( ) ;
is _lockShape = is _lockShape || value . asc _getProtectionLocked ( ) ;
2021-11-09 18:22:00 +00:00
}
2016-11-24 08:36:52 +00:00
}
2021-11-26 14:12:28 +00:00
this . _state . is _lockText = is _lockText ;
this . _state . is _lockShape = is _lockShape ;
2016-11-24 08:36:52 +00:00
}
2016-03-11 00:48:53 +00:00
if ( coauth _disable ) {
2021-12-29 16:41:15 +00:00
toolbar . lockToolbar ( Common . enumLock . coAuth , coauth _disable ) ;
2016-03-11 00:48:53 +00:00
} else {
2021-12-29 16:41:15 +00:00
var _set = Common . enumLock ;
2016-03-11 00:48:53 +00:00
var type = seltype ;
switch ( seltype ) {
2016-04-05 11:52:34 +00:00
case Asc . c _oAscSelectionType . RangeImage : type = _set . selImage ; break ;
case Asc . c _oAscSelectionType . RangeShape : type = _set . selShape ; break ;
case Asc . c _oAscSelectionType . RangeShapeText : type = _set . selShapeText ; break ;
case Asc . c _oAscSelectionType . RangeChart : type = _set . selChart ; break ;
case Asc . c _oAscSelectionType . RangeChartText : type = _set . selChartText ; break ;
2020-06-05 16:28:11 +00:00
case Asc . c _oAscSelectionType . RangeSlicer : type = _set . selSlicer ; break ;
2016-03-11 00:48:53 +00:00
}
2022-03-11 10:58:15 +00:00
if ( ! this . appConfig . isEditDiagram && ! this . appConfig . isEditMailMerge && ! this . appConfig . isEditOle )
2017-04-27 15:40:27 +00:00
toolbar . lockToolbar ( type , type != seltype , {
array : [
toolbar . btnClearStyle . menu . items [ 1 ] ,
toolbar . btnClearStyle . menu . items [ 2 ] ,
toolbar . btnClearStyle . menu . items [ 3 ] ,
2019-05-31 13:14:42 +00:00
toolbar . btnClearStyle . menu . items [ 4 ]
2017-06-30 11:33:31 +00:00
] ,
2017-04-27 15:40:27 +00:00
merge : true ,
2020-06-05 16:28:11 +00:00
clear : [ _set . selImage , _set . selChart , _set . selChartText , _set . selShape , _set . selShapeText , _set . selSlicer , _set . coAuth ]
2017-04-27 15:40:27 +00:00
} ) ;
2021-12-29 16:41:15 +00:00
toolbar . lockToolbar ( Common . enumLock . coAuthText , is _objLocked ) ;
toolbar . lockToolbar ( Common . enumLock . coAuthText , is _objLocked && ( seltype == Asc . c _oAscSelectionType . RangeChart || seltype == Asc . c _oAscSelectionType . RangeChartText ) , { array : [ toolbar . btnInsertChart ] } ) ;
toolbar . lockToolbar ( Common . enumLock . inSmartartInternal , is _smartart _internal ) ;
2016-03-11 00:48:53 +00:00
}
this . _state . controlsdisabled . filters = is _image || is _mode _2 || coauth _disable ;
if ( is _image || is _mode _2 || coauth _disable ) {
2017-04-27 15:40:27 +00:00
if ( toolbar . listStyles ) {
toolbar . listStyles . suspendEvents ( ) ;
toolbar . listStyles . menuPicker . selectRecord ( null ) ;
toolbar . listStyles . resumeEvents ( ) ;
}
2016-03-11 00:48:53 +00:00
this . _state . prstyle = undefined ;
}
this . _state . selection _type = seltype ;
this . _state . coauthdisable = coauth _disable ; // need to redisable coAuthControls
return is _image ;
} ,
_getApiTextSize : function ( ) {
var cellInfo = this . api . asc _getCellInfo ( ) ;
2020-05-15 08:32:21 +00:00
return cellInfo ? cellInfo . asc _getXfs ( ) . asc _getFontSize ( ) : 12 ;
2016-03-11 00:48:53 +00:00
} ,
_setTableFormat : function ( fmtname ) {
var me = this ;
if ( me . api . isRangeSelection !== true ) {
2016-10-05 15:53:56 +00:00
if ( ! me . api . asc _getCellInfo ( ) . asc _getFormatTableInfo ( ) ) {
2016-03-11 00:48:53 +00:00
var handlerDlg = function ( dlg , result ) {
if ( result == 'ok' ) {
me . _state . filter = undefined ;
2016-04-05 11:52:34 +00:00
me . api . asc _setSelectionDialogMode ( Asc . c _oAscSelectionDialogType . None ) ;
2016-03-11 00:48:53 +00:00
if ( me . _state . tablename )
2016-04-05 11:52:34 +00:00
me . api . asc _changeAutoFilter ( me . _state . tablename , Asc . c _oAscChangeFilterOptions . style , fmtname ) ;
2017-04-11 11:05:56 +00:00
else {
var settings = dlg . getSettings ( ) ;
if ( settings . selectionType == Asc . c _oAscSelectionType . RangeMax || settings . selectionType == Asc . c _oAscSelectionType . RangeRow ||
settings . selectionType == Asc . c _oAscSelectionType . RangeCol )
Common . UI . warning ( {
title : me . textLongOperation ,
msg : me . warnLongOperation ,
buttons : [ 'ok' , 'cancel' ] ,
callback : function ( btn ) {
if ( btn == 'ok' )
2018-06-14 13:40:27 +00:00
setTimeout ( function ( ) {
me . toolbar . fireEvent ( 'inserttable' , me . toolbar ) ;
me . api . asc _addAutoFilter ( fmtname , settings . range ) ;
} , 1 ) ;
2017-04-11 11:05:56 +00:00
Common . NotificationCenter . trigger ( 'edit:complete' , me . toolbar ) ;
}
} ) ;
2018-06-14 13:40:27 +00:00
else {
me . toolbar . fireEvent ( 'inserttable' , me . toolbar ) ;
2017-04-11 11:05:56 +00:00
me . api . asc _addAutoFilter ( fmtname , settings . range ) ;
2018-06-14 13:40:27 +00:00
}
2017-04-11 11:05:56 +00:00
}
2016-03-11 00:48:53 +00:00
}
Common . NotificationCenter . trigger ( 'edit:complete' , me . toolbar ) ;
} ;
var win = new SSE . Views . TableOptionsDialog ( {
handler : handlerDlg
} ) ;
win . show ( ) ;
win . setSettings ( {
2017-04-11 11:05:56 +00:00
api : me . api ,
2020-05-14 08:39:04 +00:00
selectionType : me . api . asc _getCellInfo ( ) . asc _getSelectionType ( )
2016-03-11 00:48:53 +00:00
} ) ;
} else {
me . _state . filter = undefined ;
if ( me . _state . tablename )
2016-04-05 11:52:34 +00:00
me . api . asc _changeAutoFilter ( me . _state . tablename , Asc . c _oAscChangeFilterOptions . style , fmtname ) ;
2017-04-11 11:05:56 +00:00
else {
2020-05-14 08:39:04 +00:00
var selectionType = me . api . asc _getCellInfo ( ) . asc _getSelectionType ( ) ;
2017-04-11 11:05:56 +00:00
if ( selectionType == Asc . c _oAscSelectionType . RangeMax || selectionType == Asc . c _oAscSelectionType . RangeRow ||
selectionType == Asc . c _oAscSelectionType . RangeCol )
Common . UI . warning ( {
title : me . textLongOperation ,
msg : me . warnLongOperation ,
buttons : [ 'ok' , 'cancel' ] ,
callback : function ( btn ) {
if ( btn == 'ok' )
2018-06-14 13:40:27 +00:00
setTimeout ( function ( ) {
me . toolbar . fireEvent ( 'inserttable' , me . toolbar ) ;
me . api . asc _addAutoFilter ( fmtname ) ;
} , 1 ) ;
2017-04-11 11:05:56 +00:00
Common . NotificationCenter . trigger ( 'edit:complete' , me . toolbar ) ;
}
} ) ;
2018-06-14 13:40:27 +00:00
else {
me . toolbar . fireEvent ( 'inserttable' , me . toolbar ) ;
2017-04-11 11:05:56 +00:00
me . api . asc _addAutoFilter ( fmtname ) ;
2018-06-14 13:40:27 +00:00
}
2017-04-11 11:05:56 +00:00
}
2016-03-11 00:48:53 +00:00
}
}
} ,
onHideMenus : function ( e ) {
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar , { restorefocus : true } ) ;
} ,
onSetupCopyStyleButton : function ( ) {
this . modeAlwaysSetStyle = false ;
var me = this ;
Common . NotificationCenter . on ( {
2020-06-03 10:10:31 +00:00
'edit:complete' : function ( cmp ) {
if ( me . api && me . modeAlwaysSetStyle && cmp !== 'tab' ) {
2019-02-19 12:47:50 +00:00
me . api . asc _formatPainter ( AscCommon . c _oAscFormatPainterState . kOff ) ;
2016-03-11 00:48:53 +00:00
me . toolbar . btnCopyStyle . toggle ( false , true ) ;
me . modeAlwaysSetStyle = false ;
}
}
} ) ;
$ ( me . toolbar . btnCopyStyle . cmpEl ) . dblclick ( function ( ) {
if ( me . api ) {
me . modeAlwaysSetStyle = true ;
me . toolbar . btnCopyStyle . toggle ( true , true ) ;
2019-02-19 12:47:50 +00:00
me . api . asc _formatPainter ( AscCommon . c _oAscFormatPainterState . kMultiple ) ;
2016-03-11 00:48:53 +00:00
}
} ) ;
} ,
onCellsRange : function ( status ) {
2016-04-05 11:52:34 +00:00
this . api . isRangeSelection = ( status != Asc . c _oAscSelectionDialogType . None ) ;
this . onApiEditCell ( this . api . isRangeSelection ? Asc . c _oAscCellEditorState . editStart : Asc . c _oAscCellEditorState . editEnd ) ;
2016-03-11 00:48:53 +00:00
var toolbar = this . toolbar ;
2021-12-29 16:41:15 +00:00
toolbar . lockToolbar ( Common . enumLock . selRangeEdit , this . api . isRangeSelection ) ;
2016-03-11 00:48:53 +00:00
this . setDisabledComponents ( [ toolbar . btnUndo ] , this . api . isRangeSelection || ! this . api . asc _getCanUndo ( ) ) ;
this . setDisabledComponents ( [ toolbar . btnRedo ] , this . api . isRangeSelection || ! this . api . asc _getCanRedo ( ) ) ;
this . onApiSelectionChanged ( this . api . asc _getCellInfo ( ) ) ;
} ,
onLockDefNameManager : function ( state ) {
2016-04-05 11:52:34 +00:00
this . _state . namedrange _locked = ( state == Asc . c _oAscDefinedNameReason . LockDefNameManager ) ;
2018-09-13 12:54:29 +00:00
2021-12-29 16:41:15 +00:00
this . toolbar . lockToolbar ( Common . enumLock . printAreaLock , this . api . asc _isPrintAreaLocked ( this . api . asc _getActiveWorksheetIndex ( ) ) , { array : [ this . toolbar . btnPrintArea ] } ) ;
this . toolbar . lockToolbar ( Common . enumLock . namedRangeLock , this . _state . namedrange _locked , { array : [ this . toolbar . btnPrintArea . menu . items [ 0 ] , this . toolbar . btnPrintArea . menu . items [ 2 ] ] } ) ;
2016-03-11 00:48:53 +00:00
} ,
2021-03-12 09:41:05 +00:00
onLockCFManager : function ( index ) {
this . _state . cf _locked [ index ] = true ;
} ,
onUnLockCFManager : function ( index ) {
this . _state . cf _locked [ index ] = false ;
} ,
2018-09-25 13:19:33 +00:00
activateControls : function ( ) {
2021-12-29 16:41:15 +00:00
this . toolbar . lockToolbar ( Common . enumLock . disableOnStart , false , { array : [ this . toolbar . btnPrint ] } ) ;
2018-09-25 13:19:33 +00:00
this . _state . activated = true ;
2016-03-11 00:48:53 +00:00
} ,
2017-11-28 11:25:08 +00:00
DisableToolbar : function ( disable , viewMode ) {
if ( viewMode !== undefined ) this . editMode = ! viewMode ;
disable = disable || ! this . editMode ;
2016-03-11 00:48:53 +00:00
var mask = $ ( '.toolbar-mask' ) ;
if ( disable && mask . length > 0 || ! disable && mask . length == 0 ) return ;
var toolbar = this . toolbar ;
2021-12-23 11:02:05 +00:00
toolbar . hideMoreBtns ( ) ;
2016-03-11 00:48:53 +00:00
toolbar . $el . find ( '.toolbar' ) . toggleClass ( 'masked' , disable ) ;
2021-12-29 16:41:15 +00:00
this . toolbar . lockToolbar ( Common . enumLock . menuFileOpen , disable ) ;
2016-03-11 00:48:53 +00:00
if ( disable ) {
2017-06-15 13:18:40 +00:00
mask = $ ( "<div class='toolbar-mask'>" ) . appendTo ( toolbar . $el . find ( '.toolbar' ) ) ;
2017-01-17 13:40:18 +00:00
Common . util . Shortcuts . suspendEvents ( 'command+l, ctrl+l, command+shift+l, ctrl+shift+l, command+k, ctrl+k, command+alt+h, ctrl+alt+h, command+1, ctrl+1' ) ;
2016-03-11 00:48:53 +00:00
} else {
mask . remove ( ) ;
2017-01-17 13:40:18 +00:00
Common . util . Shortcuts . resumeEvents ( 'command+l, ctrl+l, command+shift+l, ctrl+shift+l, command+k, ctrl+k, command+alt+h, ctrl+alt+h, command+1, ctrl+1' ) ;
2016-03-11 00:48:53 +00:00
}
} ,
applyFormulaSettings : function ( ) {
2018-05-15 14:32:10 +00:00
if ( this . toolbar . btnInsertFormula && this . toolbar . btnInsertFormula . rendered ) {
2017-06-14 11:53:29 +00:00
var formulas = this . toolbar . btnInsertFormula . menu . items ;
for ( var i = 0 ; i < Math . min ( 4 , formulas . length ) ; i ++ ) {
formulas [ i ] . setCaption ( this . api . asc _getFormulaLocaleName ( formulas [ i ] . value ) ) ;
}
2016-03-11 00:48:53 +00:00
}
} ,
2017-04-27 15:40:27 +00:00
onAppShowed : function ( config ) {
var me = this ;
me . appConfig = config ;
2022-03-16 11:17:25 +00:00
var compactview = ! config . isEdit ;
2022-03-11 10:58:15 +00:00
if ( config . isEdit && ! config . isEditDiagram && ! config . isEditMailMerge && ! config . isEditOle ) {
2017-04-27 15:40:27 +00:00
if ( Common . localStorage . itemExists ( "sse-compact-toolbar" ) ) {
compactview = Common . localStorage . getBool ( "sse-compact-toolbar" ) ;
} else
if ( config . customization && config . customization . compactToolbar )
compactview = true ;
}
2019-10-29 08:30:08 +00:00
me . toolbar . render ( _ . extend ( { isCompactView : compactview } , config ) ) ;
2022-03-11 10:58:15 +00:00
if ( ! config . isEditDiagram && ! config . isEditMailMerge && ! config . isEditOle ) {
2021-11-19 12:34:25 +00:00
var tab = { action : 'review' , caption : me . toolbar . textTabCollaboration , layoutname : 'toolbar-collaboration' , dataHintTitle : 'U' } ;
2019-11-15 11:01:08 +00:00
var $panel = me . getApplication ( ) . getController ( 'Common.Controllers.ReviewChanges' ) . createToolbarPanel ( ) ;
2020-12-22 12:37:05 +00:00
if ( $panel ) {
2019-11-15 11:01:08 +00:00
me . toolbar . addTab ( tab , $panel , 6 ) ;
2021-10-08 07:55:26 +00:00
me . toolbar . setVisible ( 'review' , ( config . isEdit || config . canViewReview || config . canCoAuthoring && config . canComments ) && Common . UI . LayoutManager . isElementVisible ( 'toolbar-collaboration' ) ) ;
2020-12-22 12:37:05 +00:00
}
2019-11-15 11:01:08 +00:00
}
2019-10-29 08:30:08 +00:00
if ( config . isEdit ) {
me . toolbar . setMode ( config ) ;
2017-10-27 13:03:03 +00:00
2019-10-29 08:30:08 +00:00
me . toolbar . btnSave && me . toolbar . btnSave . on ( 'disabled' , _ . bind ( me . onBtnChangeState , me , 'save:disabled' ) ) ;
me . toolbar . btnUndo && me . toolbar . btnUndo . on ( 'disabled' , _ . bind ( me . onBtnChangeState , me , 'undo:disabled' ) ) ;
me . toolbar . btnRedo && me . toolbar . btnRedo . on ( 'disabled' , _ . bind ( me . onBtnChangeState , me , 'redo:disabled' ) ) ;
me . toolbar . btnPrint && me . toolbar . btnPrint . on ( 'disabled' , _ . bind ( me . onBtnChangeState , me , 'print:disabled' ) ) ;
me . toolbar . setApi ( me . api ) ;
2017-11-17 14:35:40 +00:00
2022-03-11 10:58:15 +00:00
if ( ! config . isEditDiagram && ! config . isEditMailMerge && ! config . isEditOle ) {
2019-10-29 08:30:08 +00:00
var datatab = me . getApplication ( ) . getController ( 'DataTab' ) ;
datatab . setApi ( me . api ) . setConfig ( { toolbar : me } ) ;
2018-02-07 15:30:45 +00:00
2019-10-29 08:30:08 +00:00
datatab = datatab . getView ( 'DataTab' ) ;
Array . prototype . push . apply ( me . toolbar . lockControls , datatab . getButtons ( ) ) ;
me . toolbar . btnsSortDown = datatab . getButtons ( 'sort-down' ) ;
me . toolbar . btnsSortUp = datatab . getButtons ( 'sort-up' ) ;
me . toolbar . btnsSetAutofilter = datatab . getButtons ( 'set-filter' ) ;
me . toolbar . btnsClearAutofilter = datatab . getButtons ( 'clear-filter' ) ;
2019-11-27 08:45:21 +00:00
me . toolbar . btnCustomSort = datatab . getButtons ( 'sort-custom' ) ;
2020-04-08 08:51:55 +00:00
me . toolbar . btnRemoveDuplicates = datatab . getButtons ( 'rem-duplicates' ) ;
2020-11-11 20:55:11 +00:00
me . toolbar . btnDataValidation = datatab . getButtons ( 'data-validation' ) ;
2018-02-07 15:30:45 +00:00
2019-10-29 08:30:08 +00:00
var formulatab = me . getApplication ( ) . getController ( 'FormulaDialog' ) ;
formulatab . setConfig ( { toolbar : me } ) ;
formulatab = formulatab . getView ( 'FormulaTab' ) ;
me . toolbar . btnsFormula = formulatab . getButtons ( 'formula' ) ;
2020-02-26 10:49:57 +00:00
var namedRange = formulatab . getButtons ( 'range' ) ;
me . toolbar . itemsNamedRange = ( namedRange && namedRange . menu && namedRange . menu . items ) ? [ namedRange . menu . items [ 0 ] , namedRange . menu . items [ 1 ] ] : [ ] ;
2019-10-29 08:30:08 +00:00
Array . prototype . push . apply ( me . toolbar . lockControls , formulatab . getButtons ( ) ) ;
2020-03-20 14:58:03 +00:00
if ( config . canFeaturePivot ) {
2021-11-11 18:00:38 +00:00
tab = { action : 'pivot' , caption : me . textPivot , dataHintTitle : 'B' } ;
2019-12-06 12:28:39 +00:00
var pivottab = me . getApplication ( ) . getController ( 'PivotTable' ) ;
2020-09-23 18:15:45 +00:00
pivottab . setApi ( me . api ) . setConfig ( { toolbar : me } ) ;
2019-12-06 12:28:39 +00:00
$panel = pivottab . createToolbarPanel ( ) ;
2019-10-29 08:30:08 +00:00
if ( $panel ) {
me . toolbar . addTab ( tab , $panel , 5 ) ;
me . toolbar . setVisible ( 'pivot' , true ) ;
2019-12-06 12:28:39 +00:00
Array . prototype . push . apply ( me . toolbar . lockControls , pivottab . getView ( 'PivotTable' ) . getButtons ( ) ) ;
2019-09-25 09:50:58 +00:00
}
2019-10-29 08:30:08 +00:00
}
2018-02-07 15:30:45 +00:00
2019-10-29 08:30:08 +00:00
if ( ! ( config . customization && config . customization . compactHeader ) ) {
// hide 'print' and 'save' buttons group and next separator
me . toolbar . btnPrint . $el . parents ( '.group' ) . hide ( ) . next ( ) . hide ( ) ;
2018-02-07 15:30:45 +00:00
2019-10-29 08:30:08 +00:00
// hide 'undo' and 'redo' buttons and get container
var $box = me . toolbar . btnUndo . $el . hide ( ) . next ( ) . hide ( ) . parent ( ) ;
2018-02-07 15:30:45 +00:00
2019-10-29 08:30:08 +00:00
// move 'paste' button to the container instead of 'undo' and 'redo'
me . toolbar . btnPaste . $el . detach ( ) . appendTo ( $box ) ;
2021-11-12 13:21:01 +00:00
me . toolbar . btnPaste . $el . find ( 'button' ) . attr ( 'data-hint-direction' , 'bottom' ) ;
2019-10-29 08:30:08 +00:00
me . toolbar . btnCopy . $el . removeClass ( 'split' ) ;
2022-07-12 20:56:02 +00:00
me . toolbar . processPanelVisible ( null , true , true ) ;
2019-10-29 08:30:08 +00:00
}
2018-02-07 15:30:45 +00:00
2021-11-19 12:34:25 +00:00
var tab = { action : 'protect' , caption : me . toolbar . textTabProtect , layoutname : 'toolbar-protect' , dataHintTitle : 'T' } ;
2021-06-21 15:00:20 +00:00
var $panel = me . getApplication ( ) . getController ( 'Common.Controllers.Protection' ) . createToolbarPanel ( ) ;
if ( $panel ) {
config . canProtect && $panel . append ( $ ( '<div class="separator long"></div>' ) ) ;
2021-07-16 12:47:24 +00:00
var wbtab = me . getApplication ( ) . getController ( 'WBProtection' ) ;
$panel . append ( wbtab . createToolbarPanel ( ) ) ;
2021-06-21 15:00:20 +00:00
me . toolbar . addTab ( tab , $panel , 7 ) ;
2022-04-20 09:53:44 +00:00
me . toolbar . setVisible ( 'protect' , Common . UI . LayoutManager . isElementVisible ( 'toolbar-protect' ) ) ;
2021-07-16 12:47:24 +00:00
Array . prototype . push . apply ( me . toolbar . lockControls , wbtab . getView ( 'WBProtection' ) . getButtons ( ) ) ;
2017-11-28 14:35:51 +00:00
}
2019-09-25 09:50:58 +00:00
}
2019-10-29 08:30:08 +00:00
}
2022-03-11 10:58:15 +00:00
if ( ! config . isEditDiagram && ! config . isEditMailMerge && ! config . isEditOle ) {
2022-02-08 10:01:04 +00:00
tab = { caption : me . toolbar . textTabView , action : 'view' , extcls : config . isEdit ? 'canedit' : '' , layoutname : 'toolbar-view' , dataHintTitle : 'W' } ;
var viewtab = me . getApplication ( ) . getController ( 'ViewTab' ) ;
viewtab . setApi ( me . api ) . setConfig ( { toolbar : me , mode : config } ) ;
$panel = viewtab . createToolbarPanel ( ) ;
if ( $panel ) {
me . toolbar . addTab ( tab , $panel , 8 ) ;
me . toolbar . setVisible ( 'view' , Common . UI . LayoutManager . isElementVisible ( 'toolbar-view' ) ) ;
}
config . isEdit && Array . prototype . push . apply ( me . toolbar . lockControls , viewtab . getView ( 'ViewTab' ) . getButtons ( ) ) ;
}
2017-04-27 15:40:27 +00:00
} ,
onAppReady : function ( config ) {
var me = this ;
2018-05-16 14:41:47 +00:00
me . appOptions = config ;
2017-04-27 15:40:27 +00:00
2017-06-28 11:20:49 +00:00
this . btnsComment = [ ] ;
2017-06-15 13:18:40 +00:00
if ( config . canCoAuthoring && config . canComments ) {
2021-12-29 16:41:15 +00:00
var _set = Common . enumLock ;
2021-08-08 22:00:41 +00:00
this . btnsComment = Common . Utils . injectButtons ( this . toolbar . $el . find ( '.slot-comment' ) , 'tlbtn-addcomment-' , 'toolbar__icon btn-menu-comments' , this . toolbar . capBtnComment ,
[ _set . lostConnect , _set . commentLock , _set . editCell , _set [ 'Objects' ] ] , undefined , undefined , undefined , '1' , 'bottom' , 'small' ) ;
2017-04-27 15:40:27 +00:00
2017-06-28 11:20:49 +00:00
if ( this . btnsComment . length ) {
2017-04-27 15:40:27 +00:00
var _comments = SSE . getController ( 'Common.Controllers.Comments' ) . getView ( ) ;
2017-06-28 11:20:49 +00:00
Array . prototype . push . apply ( me . toolbar . lockControls , this . btnsComment ) ;
this . btnsComment . forEach ( function ( btn ) {
2017-08-02 13:47:40 +00:00
btn . updateHint ( _comments . textHintAddComment ) ;
2017-04-27 15:40:27 +00:00
btn . on ( 'click' , function ( btn , e ) {
2020-05-14 08:39:04 +00:00
Common . NotificationCenter . trigger ( 'app:comment:add' , 'toolbar' , me . api . asc _getCellInfo ( ) . asc _getSelectionType ( ) != Asc . c _oAscSelectionType . RangeCells ) ;
2017-04-27 15:40:27 +00:00
} ) ;
2019-11-06 14:22:12 +00:00
if ( btn . cmpEl . closest ( '#review-changes-panel' ) . length > 0 )
btn . setCaption ( me . toolbar . capBtnAddComment ) ;
2017-04-27 15:40:27 +00:00
} , this ) ;
}
}
Common . Utils . asyncCall ( function ( ) {
if ( config . isEdit ) {
me . toolbar . onAppReady ( config ) ;
}
} ) ;
} ,
onFileMenu : function ( opts ) {
2018-05-18 09:59:01 +00:00
if ( opts == 'show' ) {
if ( ! this . toolbar . isTabActive ( 'file' ) )
this . toolbar . setTab ( 'file' ) ;
} else {
2018-05-16 14:41:47 +00:00
if ( this . toolbar . isTabActive ( 'file' ) )
this . toolbar . setTab ( ) ;
}
2017-04-27 15:40:27 +00:00
} ,
2018-06-28 09:27:11 +00:00
onPageSizeClick : function ( menu , item , state ) {
if ( this . api && state ) {
this . _state . pgsize = [ 0 , 0 ] ;
2018-07-17 08:41:25 +00:00
this . api . asc _changeDocSize ( item . value [ 0 ] , item . value [ 1 ] , this . api . asc _getActiveWorksheetIndex ( ) ) ;
2018-06-28 09:27:11 +00:00
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Page Size' ) ;
}
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
} ,
onPageMarginsSelect : function ( menu , item ) {
if ( this . api ) {
this . _state . pgmargins = undefined ;
if ( item . value !== 'advanced' ) {
2018-07-17 08:41:25 +00:00
this . api . asc _changePageMargins ( item . value [ 1 ] , item . value [ 3 ] , item . value [ 0 ] , item . value [ 2 ] , this . api . asc _getActiveWorksheetIndex ( ) ) ;
2018-06-28 09:27:11 +00:00
} else {
2018-06-29 07:55:05 +00:00
var win , props ,
me = this ;
win = new SSE . Views . PageMarginsDialog ( {
handler : function ( dlg , result ) {
if ( result == 'ok' ) {
props = dlg . getSettings ( ) ;
var mnu = me . toolbar . btnPageMargins . menu . items [ 0 ] ;
mnu . setVisible ( true ) ;
mnu . setChecked ( true ) ;
mnu . options . value = mnu . value = [ props . asc _getTop ( ) , props . asc _getLeft ( ) , props . asc _getBottom ( ) , props . asc _getRight ( ) ] ;
$ ( mnu . el ) . html ( mnu . template ( { id : Common . UI . getId ( ) , caption : mnu . caption , options : mnu . options } ) ) ;
Common . localStorage . setItem ( "sse-pgmargins-top" , props . asc _getTop ( ) ) ;
Common . localStorage . setItem ( "sse-pgmargins-left" , props . asc _getLeft ( ) ) ;
Common . localStorage . setItem ( "sse-pgmargins-bottom" , props . asc _getBottom ( ) ) ;
Common . localStorage . setItem ( "sse-pgmargins-right" , props . asc _getRight ( ) ) ;
2018-07-17 08:41:25 +00:00
me . api . asc _changePageMargins ( props . asc _getLeft ( ) , props . asc _getRight ( ) , props . asc _getTop ( ) , props . asc _getBottom ( ) , me . api . asc _getActiveWorksheetIndex ( ) ) ;
2018-06-29 07:55:05 +00:00
Common . NotificationCenter . trigger ( 'edit:complete' , me . toolbar ) ;
}
}
} ) ;
win . show ( ) ;
win . setSettings ( me . api . asc _getPageOptions ( me . api . asc _getActiveWorksheetIndex ( ) ) ) ;
2018-06-28 09:27:11 +00:00
}
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Page Margins' ) ;
}
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
} ,
onPageOrientSelect : function ( menu , item ) {
this . _state . pgorient = undefined ;
if ( this . api && item . checked ) {
2018-07-17 10:10:23 +00:00
this . api . asc _changePageOrient ( item . value == Asc . c _oAscPageOrientation . PagePortrait , this . api . asc _getActiveWorksheetIndex ( ) ) ;
2018-06-28 09:27:11 +00:00
}
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Page Orientation' ) ;
} ,
onImgGroupSelect : function ( menu , item ) {
if ( this . api )
this . api [ ( item . value == 'grouping' ) ? 'asc_groupGraphicsObjects' : 'asc_unGroupGraphicsObjects' ] ( ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Objects Group' ) ;
} ,
onImgArrangeSelect : function ( menu , item ) {
if ( this . api ) {
if ( menu == 'forward' )
this . api . asc _setSelectedDrawingObjectLayer ( Asc . c _oAscDrawingLayerType . BringForward ) ;
else if ( menu == 'backward' )
this . api . asc _setSelectedDrawingObjectLayer ( Asc . c _oAscDrawingLayerType . SendBackward ) ;
else
this . api . asc _setSelectedDrawingObjectLayer ( item . value ) ;
}
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Objects Arrange' ) ;
} ,
onImgAlignSelect : function ( menu , item ) {
2019-02-14 14:50:36 +00:00
if ( this . api ) {
if ( item . value > - 1 && item . value < 6 ) {
this . api . asc _setSelectedDrawingObjectAlign ( item . value ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Objects Align' ) ;
} else if ( item . value == 6 ) {
this . api . asc _DistributeSelectedDrawingObjectHor ( ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Distribute' ) ;
} else if ( item . value == 7 ) {
this . api . asc _DistributeSelectedDrawingObjectVer ( ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Distribute' ) ;
}
}
2018-06-28 09:27:11 +00:00
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
} ,
2018-09-04 10:18:46 +00:00
onPrintAreaClick : function ( menu , item ) {
if ( this . api ) {
this . api . asc _ChangePrintArea ( item . value ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Print Area' ) ;
}
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
} ,
onPrintAreaMenuOpen : function ( ) {
if ( this . api )
this . toolbar . btnPrintArea . menu . items [ 2 ] . setVisible ( this . api . asc _CanAddPrintArea ( ) ) ;
} ,
2022-04-07 14:12:39 +00:00
onEditHeaderClick : function ( pageSetup , btn ) {
2018-10-11 11:25:53 +00:00
var me = this ;
if ( _ . isUndefined ( me . fontStore ) ) {
me . fontStore = new Common . Collections . Fonts ( ) ;
var fonts = me . toolbar . cmbFontName . store . toJSON ( ) ;
var arr = [ ] ;
_ . each ( fonts , function ( font , index ) {
if ( ! font . cloneid ) {
arr . push ( _ . clone ( font ) ) ;
}
} ) ;
me . fontStore . add ( arr ) ;
}
var win = new SSE . Views . HeaderFooterDialog ( {
api : me . api ,
fontStore : me . fontStore ,
2022-04-07 14:12:39 +00:00
pageSetup : pageSetup ,
2018-10-11 11:25:53 +00:00
handler : function ( dlg , result ) {
2022-02-18 12:53:23 +00:00
if ( result === 'ok' ) {
me . getApplication ( ) . getController ( 'Print' ) . updatePreview ( ) ;
}
2018-10-11 11:25:53 +00:00
Common . NotificationCenter . trigger ( 'edit:complete' ) ;
}
} ) ;
win . show ( ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
} ,
2019-09-13 14:45:09 +00:00
onClickChangeScaleInMenu : function ( type , curScale ) {
2019-09-12 07:15:07 +00:00
if ( this . api ) {
2019-09-13 14:45:09 +00:00
var scale ;
if ( type === 'up' ) {
if ( curScale % 5 > 0.001 ) {
scale = Math . ceil ( curScale / 5 ) * 5 ;
} else {
scale = curScale + 5 ;
}
} else {
if ( curScale % 5 > 0.001 ) {
scale = Math . floor ( curScale / 5 ) * 5 ;
} else {
scale = curScale - 5 ;
}
}
if ( scale > 400 ) {
scale = 400 ;
} else if ( scale < 10 ) {
scale = 10 ;
}
2019-09-12 07:15:07 +00:00
this . onChangeScaleSettings ( 0 , 0 , scale ) ;
}
} ,
2019-10-15 12:07:03 +00:00
onScaleClick : function ( type , menu , item , event , scale ) {
2019-08-21 10:55:40 +00:00
var me = this ;
2019-09-12 07:15:07 +00:00
if ( me . api ) {
2019-10-15 12:07:03 +00:00
if ( type === 'width' && item . value !== 'more' ) {
if ( me . _state . scaleHeight === undefined || me . _state . scaleHeight === null ) {
me . _state . scaleHeight = 0 ;
}
me . api . asc _SetPrintScale ( item . value , me . _state . scaleHeight , 100 ) ;
me . onChangeScaleSettings ( item . value , me . _state . scaleHeight , 100 ) ;
} else if ( type === 'height' && item . value !== 'more' ) {
if ( me . _state . scaleWidth === undefined || me . _state . scaleWidth === null ) {
me . _state . scaleWidth = 0 ;
}
me . api . asc _SetPrintScale ( me . _state . scaleWidth , item . value , 100 ) ;
me . onChangeScaleSettings ( me . _state . scaleWidth , item . value , 100 ) ;
} else if ( type === 'scale' && scale !== undefined ) {
2019-09-13 14:45:09 +00:00
me . api . asc _SetPrintScale ( 0 , 0 , scale ) ;
2019-10-15 12:07:03 +00:00
} else if ( item . value === 'custom' || item . value === 'more' ) {
var win = new SSE . Views . ScaleDialog ( {
api : me . api ,
props : null ,
handler : function ( dlg , result ) {
if ( dlg == 'ok' ) {
if ( me . api && result ) {
me . api . asc _SetPrintScale ( result . width , result . height , result . scale ) ;
me . onChangeScaleSettings ( result . width , result . height , result . scale ) ;
2019-09-12 07:15:07 +00:00
}
2019-10-15 12:07:03 +00:00
} else {
me . onChangeScaleSettings ( me . _state . scaleWidth , me . _state . scaleHeight , me . _state . scale ) ;
}
Common . NotificationCenter . trigger ( 'edit:complete' ) ;
}
} ) ;
win . show ( ) ;
2019-08-21 10:55:40 +00:00
}
2019-09-12 07:15:07 +00:00
}
2018-10-11 11:25:53 +00:00
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
} ,
2020-03-17 12:06:40 +00:00
onPrintTitlesClick : function ( btn ) {
if ( this . api ) {
var win , props ,
me = this ;
win = new SSE . Views . PrintTitlesDialog ( {
api : me . api ,
2020-03-17 15:03:42 +00:00
sheet : me . api . asc _getActiveWorksheetIndex ( ) ,
2020-03-17 12:06:40 +00:00
handler : function ( dlg , result ) {
if ( result == 'ok' ) {
props = dlg . getSettings ( ) ;
2020-03-17 12:24:23 +00:00
me . api . asc _changePrintTitles ( props . width , props . height , me . api . asc _getActiveWorksheetIndex ( ) ) ;
2020-03-17 12:06:40 +00:00
Common . NotificationCenter . trigger ( 'edit:complete' , me . toolbar ) ;
}
}
} ) ;
win . show ( ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Print Titles' ) ;
}
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
} ,
2021-07-16 22:31:56 +00:00
onChangeProtectSheet : function ( props ) {
if ( ! props ) {
var wbprotect = this . getApplication ( ) . getController ( 'WBProtection' ) ;
props = wbprotect ? wbprotect . getWSProps ( ) : null ;
}
if ( props ) {
this . _state . wsProps = props . wsProps ;
this . _state . wsLock = props . wsLock ;
2021-12-29 16:41:15 +00:00
this . toolbar . lockToolbar ( Common . enumLock . wsLock , this . _state . wsLock ) ;
this . toolbar . lockToolbar ( Common . enumLock [ 'InsertHyperlinks' ] , this . _state . wsProps [ 'InsertHyperlinks' ] , { array : [ this . toolbar . btnInsertHyperlink ] } ) ;
2021-09-06 23:02:15 +00:00
this . appConfig && this . appConfig . isEdit ? this . onApiSelectionChanged ( this . api . asc _getCellInfo ( ) ) : this . onApiSelectionChangedRestricted ( this . api . asc _getCellInfo ( ) ) ;
2021-07-16 21:49:36 +00:00
}
2021-07-16 12:47:24 +00:00
} ,
2021-10-27 11:11:23 +00:00
onPrintGridlinesChange : function ( field , value ) {
this . api . asc _SetPrintGridlines ( value === 'checked' ) ;
2021-10-21 16:52:17 +00:00
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
} ,
2021-10-27 11:11:23 +00:00
onPrintHeadingsChange : function ( field , value ) {
this . api . asc _SetPrintHeadings ( value === 'checked' ) ;
2021-10-21 16:52:17 +00:00
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
} ,
2022-05-27 18:04:06 +00:00
onVisibleAreaClose : function ( btn ) {
if ( this . api )
2022-06-01 11:11:02 +00:00
this . api . asc _toggleChangeVisibleAreaOleEditor ( false ) ;
2022-05-27 18:04:06 +00:00
this . toolbar . lockToolbar ( Common . enumLock . editVisibleArea , false ) ;
this . toolbar . btnVisibleArea . setVisible ( true ) ;
this . toolbar . btnVisibleAreaClose . setVisible ( false ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
} ,
onVisibleAreaMenu : function ( menu , item , e ) {
if ( this . api ) {
if ( item . value === 'edit' ) {
2022-06-01 11:11:02 +00:00
this . api . asc _toggleChangeVisibleAreaOleEditor ( true ) ;
2022-05-27 18:04:06 +00:00
this . toolbar . btnVisibleArea . setVisible ( false ) ;
this . toolbar . btnVisibleAreaClose . setVisible ( true ) ;
this . toolbar . lockToolbar ( Common . enumLock . editVisibleArea , true ) ;
} else { // show or hide
2022-06-01 11:11:02 +00:00
this . api . asc _toggleShowVisibleAreaOleEditor ( item . value === 'show' ) ;
2022-05-27 18:04:06 +00:00
this . toolbar . btnVisibleArea . menu . items [ 0 ] . setVisible ( item . value !== 'show' ) ;
this . toolbar . btnVisibleArea . menu . items [ 1 ] . setVisible ( item . value === 'show' ) ;
}
}
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
} ,
2022-06-01 11:11:02 +00:00
onOleEditClose : function ( ) {
if ( this . api ) {
this . api . asc _toggleChangeVisibleAreaOleEditor ( false ) ;
this . toolbar . btnVisibleArea . setVisible ( true ) ;
this . toolbar . btnVisibleAreaClose . setVisible ( false ) ;
this . toolbar . lockToolbar ( Common . enumLock . editVisibleArea , false ) ;
this . api . asc _toggleShowVisibleAreaOleEditor ( false ) ;
this . toolbar . btnVisibleArea . menu . items [ 0 ] . setVisible ( true ) ;
this . toolbar . btnVisibleArea . menu . items [ 1 ] . setVisible ( false ) ;
}
} ,
2022-05-31 20:46:19 +00:00
onTextFormattingMenu : function ( menu , item ) {
if ( this . api ) {
switch ( item . value ) {
case 'bold' :
this . _state . bold = undefined ;
this . api . asc _setCellBold ( item . checked ) ;
break ;
case 'italic' :
this . _state . italic = undefined ;
this . api . asc _setCellItalic ( item . checked ) ;
break ;
case 'underline' :
this . _state . underline = undefined ;
this . api . asc _setCellUnderline ( item . checked ) ;
break ;
case 'strikeout' :
this . _state . strikeout = undefined ;
this . api . asc _setCellStrikeout ( item . checked ) ;
break ;
case 'subscript' :
this . _state . subscript = undefined ;
this . api . asc _setCellSubscript ( item . checked ) ;
break ;
case 'superscript' :
this . _state . superscript = undefined ;
this . api . asc _setCellSuperscript ( item . checked ) ;
break ;
}
}
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Text Formatting' ) ;
} ,
onHorizontalAlignMenu : function ( menu , item ) {
this . _state . pralign = undefined ;
if ( this . api ) {
this . api . asc _setCellAlign ( ! item . checked ? null : item . value ) ;
this . toolbar . btnWrap . allowDepress = ! ( item . value == AscCommon . align _Justify ) ;
}
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Horizontal align' ) ;
} ,
onVerticalAlignMenu : function ( menu , item ) {
this . _state . valign = undefined ;
if ( this . api ) {
this . api . asc _setCellVertAlign ( ! item . checked ? Asc . c _oAscVAlign . Bottom : item . value ) ;
}
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Vertical align' ) ;
} ,
2022-10-12 18:17:43 +00:00
generateSmartArt : function ( groupName ) {
this . api . asc _generateSmartArtPreviews ( groupName ) ;
} ,
onApiBeginSmartArtPreview : function ( ) {
this . smartArtGroups = this . toolbar . btnInsertSmartArt . menu . items ;
this . smartArtData = Common . define . smartArt . getSmartArtData ( ) ;
} ,
onApiAddSmartArtPreview : function ( previews ) {
previews . forEach ( _ . bind ( function ( preview ) {
var image = preview . asc _getImage ( ) ,
sectionId = preview . asc _getSectionId ( ) ,
section = _ . findWhere ( this . smartArtData , { sectionId : sectionId } ) ,
item = _ . findWhere ( section . items , { type : image . asc _getName ( ) } ) ,
2022-10-13 09:13:20 +00:00
menu = _ . findWhere ( this . smartArtGroups , { value : sectionId } ) ,
menuPicker = menu . menuPicker ;
2022-10-12 18:17:43 +00:00
if ( item ) {
var arr = [ {
tip : item . tip ,
value : item . type ,
imageUrl : image . asc _getImage ( )
} ] ;
2022-10-13 09:13:20 +00:00
if ( menuPicker . store . length < 1 ) {
menuPicker . store . reset ( arr ) ;
2022-10-12 18:17:43 +00:00
} else {
2022-10-13 09:13:20 +00:00
menuPicker . store . add ( arr ) ;
2022-10-12 18:17:43 +00:00
}
}
2022-10-13 09:13:20 +00:00
this . currentSmartArtMenu = menu ;
2022-10-12 18:17:43 +00:00
} , this ) ) ;
} ,
2022-10-13 09:13:20 +00:00
onApiEndSmartArtPreview : function ( ) {
if ( this . currentSmartArtMenu ) {
this . currentSmartArtMenu . menu . alignPosition ( ) ;
}
} ,
2022-10-12 18:17:43 +00:00
onInsertSmartArt : function ( value ) {
if ( this . api ) {
this . api . asc _createSmartArt ( value ) ;
}
} ,
2016-03-11 00:48:53 +00:00
textEmptyImgUrl : 'You need to specify image URL.' ,
warnMergeLostData : 'Operation can destroy data in the selected cells.<br>Continue?' ,
textWarning : 'Warning' ,
textFontSizeErr : 'The entered value is incorrect.<br>Please enter a numeric value between 1 and 409' ,
2016-10-21 09:33:49 +00:00
confirmAddFontName : 'The font you are going to save is not available on the current device.<br>The text style will be displayed using one of the device fonts, the saved font will be used when it is available.<br>Do you want to continue?' ,
textSymbols : 'Symbols' ,
textFraction : 'Fraction' ,
textScript : 'Script' ,
textRadical : 'Radical' ,
textIntegral : 'Integral' ,
textLargeOperator : 'Large Operator' ,
textBracket : 'Bracket' ,
textFunction : 'Function' ,
textAccent : 'Accent' ,
textLimitAndLog : 'Limit And Log' ,
textOperator : 'Operator' ,
textMatrix : 'Matrix' ,
txtSymbol _pm : 'Plus Minus' ,
txtSymbol _infinity : 'Infinity' ,
txtSymbol _equals : 'Equal' ,
txtSymbol _neq : 'Not Equal To' ,
txtSymbol _about : 'Approximately' ,
txtSymbol _times : 'Multiplication Sign' ,
txtSymbol _div : 'Division Sign' ,
txtSymbol _factorial : 'Factorial' ,
txtSymbol _propto : 'Proportional To' ,
txtSymbol _less : 'Less Than' ,
txtSymbol _ll : 'Much Less Than' ,
txtSymbol _greater : 'Greater Than' ,
txtSymbol _gg : 'Much Greater Than' ,
txtSymbol _leq : 'Less Than or Equal To' ,
txtSymbol _geq : 'Greater Than or Equal To' ,
txtSymbol _mp : 'Minus Plus' ,
txtSymbol _cong : 'Approximately Equal To' ,
txtSymbol _approx : 'Almost Equal To' ,
txtSymbol _equiv : 'Identical To' ,
txtSymbol _forall : 'For All' ,
txtSymbol _additional : 'Complement' ,
txtSymbol _partial : 'Partial Differential' ,
txtSymbol _sqrt : 'Radical Sign' ,
txtSymbol _cbrt : 'Cube Root' ,
txtSymbol _qdrt : 'Fourth Root' ,
txtSymbol _cup : 'Union' ,
txtSymbol _cap : 'Intersection' ,
txtSymbol _emptyset : 'Empty Set' ,
txtSymbol _percent : 'Percentage' ,
txtSymbol _degree : 'Degrees' ,
txtSymbol _fahrenheit : 'Degrees Fahrenheit' ,
txtSymbol _celsius : 'Degrees Celsius' ,
txtSymbol _inc : 'Increment' ,
txtSymbol _nabla : 'Nabla' ,
txtSymbol _exists : 'There Exist' ,
txtSymbol _notexists : 'There Does Not Exist' ,
txtSymbol _in : 'Element Of' ,
txtSymbol _ni : 'Contains as Member' ,
txtSymbol _leftarrow : 'Left Arrow' ,
txtSymbol _uparrow : 'Up Arrow' ,
txtSymbol _rightarrow : 'Right Arrow' ,
txtSymbol _downarrow : 'Down Arrow' ,
txtSymbol _leftrightarrow : 'Left-Right Arrow' ,
txtSymbol _therefore : 'Therefore' ,
txtSymbol _plus : 'Plus' ,
txtSymbol _minus : 'Minus' ,
txtSymbol _not : 'Not Sign' ,
txtSymbol _ast : 'Asterisk Operator' ,
txtSymbol _bullet : 'Bulet Operator' ,
txtSymbol _vdots : 'Vertical Ellipsis' ,
txtSymbol _cdots : 'Midline Horizontal Ellipsis' ,
txtSymbol _rddots : 'Up Right Diagonal Ellipsis' ,
txtSymbol _ddots : 'Down Right Diagonal Ellipsis' ,
txtSymbol _aleph : 'Alef' ,
txtSymbol _beth : 'Bet' ,
txtSymbol _qed : 'End of Proof' ,
txtSymbol _alpha : 'Alpha' ,
txtSymbol _beta : 'Beta' ,
txtSymbol _gamma : 'Gamma' ,
txtSymbol _delta : 'Delta' ,
txtSymbol _varepsilon : 'Epsilon Variant' ,
txtSymbol _epsilon : 'Epsilon' ,
txtSymbol _zeta : 'Zeta' ,
txtSymbol _eta : 'Eta' ,
txtSymbol _theta : 'Theta' ,
txtSymbol _vartheta : 'Theta Variant' ,
txtSymbol _iota : 'Iota' ,
txtSymbol _kappa : 'Kappa' ,
txtSymbol _lambda : 'Lambda' ,
txtSymbol _mu : 'Mu' ,
txtSymbol _nu : 'Nu' ,
txtSymbol _xsi : 'Xi' ,
txtSymbol _o : 'Omicron' ,
txtSymbol _pi : 'Pi' ,
txtSymbol _varpi : 'Pi Variant' ,
txtSymbol _rho : 'Rho' ,
txtSymbol _varrho : 'Rho Variant' ,
txtSymbol _sigma : 'Sigma' ,
txtSymbol _varsigma : 'Sigma Variant' ,
txtSymbol _tau : 'Tau' ,
txtSymbol _upsilon : 'Upsilon' ,
txtSymbol _varphi : 'Phi Variant' ,
txtSymbol _phi : 'Phi' ,
txtSymbol _chi : 'Chi' ,
txtSymbol _psi : 'Psi' ,
txtSymbol _omega : 'Omega' ,
txtFractionVertical : 'Stacked Fraction' ,
txtFractionDiagonal : 'Skewed Fraction' ,
txtFractionHorizontal : 'Linear Fraction' ,
txtFractionSmall : 'Small Fraction' ,
txtFractionDifferential _1 : 'Differential' ,
txtFractionDifferential _2 : 'Differential' ,
txtFractionDifferential _3 : 'Differential' ,
txtFractionDifferential _4 : 'Differential' ,
txtFractionPi _2 : 'Pi Over 2' ,
txtScriptSup : 'Superscript' ,
txtScriptSub : 'Subscript' ,
txtScriptSubSup : 'Subscript-Superscript' ,
txtScriptSubSupLeft : 'Left Subscript-Superscript' ,
txtScriptCustom _1 : 'Script' ,
txtScriptCustom _2 : 'Script' ,
txtScriptCustom _3 : 'Script' ,
txtScriptCustom _4 : 'Script' ,
txtRadicalSqrt : 'Square Root' ,
txtRadicalRoot _n : 'Radical With Degree' ,
txtRadicalRoot _2 : 'Square Root With Degree' ,
txtRadicalRoot _3 : 'Cubic Root' ,
txtRadicalCustom _1 : 'Radical' ,
txtRadicalCustom _2 : 'Radical' ,
txtIntegral : 'Integral' ,
txtIntegralSubSup : 'Integral' ,
txtIntegralCenterSubSup : 'Integral' ,
txtIntegralDouble : 'Double Integral' ,
txtIntegralDoubleSubSup : 'Double Integral' ,
txtIntegralDoubleCenterSubSup : 'Double Integral' ,
txtIntegralTriple : 'Triple Integral' ,
txtIntegralTripleSubSup : 'Triple Integral' ,
txtIntegralTripleCenterSubSup : 'Triple Integral' ,
txtIntegralOriented : 'Contour Integral' ,
txtIntegralOrientedSubSup : 'Contour Integral' ,
txtIntegralOrientedCenterSubSup : 'Contour Integral' ,
txtIntegralOrientedDouble : 'Surface Integral' ,
txtIntegralOrientedDoubleSubSup : 'Surface Integral' ,
txtIntegralOrientedDoubleCenterSubSup : 'Surface Integral' ,
txtIntegralOrientedTriple : 'Volume Integral' ,
txtIntegralOrientedTripleSubSup : 'Volume Integral' ,
txtIntegralOrientedTripleCenterSubSup : 'Volume Integral' ,
txtIntegral _dx : 'Differential x' ,
txtIntegral _dy : 'Differential y' ,
txtIntegral _dtheta : 'Differential theta' ,
txtLargeOperator _Sum : 'Summation' ,
txtLargeOperator _Sum _CenterSubSup : 'Summation' ,
txtLargeOperator _Sum _SubSup : 'Summation' ,
txtLargeOperator _Sum _CenterSub : 'Summation' ,
txtLargeOperator _Sum _Sub : 'Summation' ,
txtLargeOperator _Prod : 'Product' ,
txtLargeOperator _Prod _CenterSubSup : 'Product' ,
txtLargeOperator _Prod _SubSup : 'Product' ,
txtLargeOperator _Prod _CenterSub : 'Product' ,
txtLargeOperator _Prod _Sub : 'Product' ,
txtLargeOperator _CoProd : 'Co-Product' ,
txtLargeOperator _CoProd _CenterSubSup : 'Co-Product' ,
txtLargeOperator _CoProd _SubSup : 'Co-Product' ,
txtLargeOperator _CoProd _CenterSub : 'Co-Product' ,
txtLargeOperator _CoProd _Sub : 'Co-Product' ,
txtLargeOperator _Union : 'Union' ,
txtLargeOperator _Union _CenterSubSup : 'Union' ,
txtLargeOperator _Union _SubSup : 'Union' ,
txtLargeOperator _Union _CenterSub : 'Union' ,
txtLargeOperator _Union _Sub : 'Union' ,
txtLargeOperator _Intersection : 'Intersection' ,
txtLargeOperator _Intersection _CenterSubSup : 'Intersection' ,
txtLargeOperator _Intersection _SubSup : 'Intersection' ,
txtLargeOperator _Intersection _CenterSub : 'Intersection' ,
txtLargeOperator _Intersection _Sub : 'Intersection' ,
txtLargeOperator _Disjunction : 'Vee' ,
txtLargeOperator _Disjunction _CenterSubSup : 'Vee' ,
txtLargeOperator _Disjunction _SubSup : 'Vee' ,
txtLargeOperator _Disjunction _CenterSub : 'Vee' ,
txtLargeOperator _Disjunction _Sub : 'Vee' ,
txtLargeOperator _Conjunction : 'Wedge' ,
txtLargeOperator _Conjunction _CenterSubSup : 'Wedge' ,
txtLargeOperator _Conjunction _SubSup : 'Wedge' ,
txtLargeOperator _Conjunction _CenterSub : 'Wedge' ,
txtLargeOperator _Conjunction _Sub : 'Wedge' ,
txtLargeOperator _Custom _1 : 'Summation' ,
txtLargeOperator _Custom _2 : 'Summation' ,
txtLargeOperator _Custom _3 : 'Summation' ,
txtLargeOperator _Custom _4 : 'Product' ,
txtLargeOperator _Custom _5 : 'Union' ,
txtBracket _Round : 'Brackets' ,
txtBracket _Square : 'Brackets' ,
txtBracket _Curve : 'Brackets' ,
txtBracket _Angle : 'Brackets' ,
txtBracket _LowLim : 'Brackets' ,
txtBracket _UppLim : 'Brackets' ,
txtBracket _Line : 'Brackets' ,
txtBracket _LineDouble : 'Brackets' ,
txtBracket _Square _OpenOpen : 'Brackets' ,
txtBracket _Square _CloseClose : 'Brackets' ,
txtBracket _Square _CloseOpen : 'Brackets' ,
txtBracket _SquareDouble : 'Brackets' ,
txtBracket _Round _Delimiter _2 : 'Brackets with Separators' ,
txtBracket _Curve _Delimiter _2 : 'Brackets with Separators' ,
txtBracket _Angle _Delimiter _2 : 'Brackets with Separators' ,
txtBracket _Angle _Delimiter _3 : 'Brackets with Separators' ,
txtBracket _Round _OpenNone : 'Single Bracket' ,
txtBracket _Round _NoneOpen : 'Single Bracket' ,
txtBracket _Square _OpenNone : 'Single Bracket' ,
txtBracket _Square _NoneOpen : 'Single Bracket' ,
txtBracket _Curve _OpenNone : 'Single Bracket' ,
txtBracket _Curve _NoneOpen : 'Single Bracket' ,
txtBracket _Angle _OpenNone : 'Single Bracket' ,
txtBracket _Angle _NoneOpen : 'Single Bracket' ,
txtBracket _LowLim _OpenNone : 'Single Bracket' ,
txtBracket _LowLim _NoneNone : 'Single Bracket' ,
txtBracket _UppLim _OpenNone : 'Single Bracket' ,
txtBracket _UppLim _NoneOpen : 'Single Bracket' ,
txtBracket _Line _OpenNone : 'Single Bracket' ,
txtBracket _Line _NoneOpen : 'Single Bracket' ,
txtBracket _LineDouble _OpenNone : 'Single Bracket' ,
txtBracket _LineDouble _NoneOpen : 'Single Bracket' ,
txtBracket _SquareDouble _OpenNone : 'Single Bracket' ,
txtBracket _SquareDouble _NoneOpen : 'Single Bracket' ,
txtBracket _Custom _1 : 'Case (Two Conditions)' ,
txtBracket _Custom _2 : 'Cases (Three Conditions)' ,
txtBracket _Custom _3 : 'Stack Object' ,
txtBracket _Custom _4 : 'Stack Object' ,
txtBracket _Custom _5 : 'Cases Example' ,
txtBracket _Custom _6 : 'Binomial Coefficient' ,
txtBracket _Custom _7 : 'Binomial Coefficient' ,
txtFunction _Sin : 'Sine Function' ,
txtFunction _Cos : 'Cosine Function' ,
txtFunction _Tan : 'Tangent Function' ,
txtFunction _Csc : 'Cosecant Function' ,
txtFunction _Sec : 'Secant Function' ,
txtFunction _Cot : 'Cotangent Function' ,
txtFunction _1 _Sin : 'Inverse Sine Function' ,
txtFunction _1 _Cos : 'Inverse Cosine Function' ,
txtFunction _1 _Tan : 'Inverse Tangent Function' ,
txtFunction _1 _Csc : 'Inverse Cosecant Function' ,
txtFunction _1 _Sec : 'Inverse Secant Function' ,
txtFunction _1 _Cot : 'Inverse Cotangent Function' ,
txtFunction _Sinh : 'Hyperbolic Sine Function' ,
txtFunction _Cosh : 'Hyperbolic Cosine Function' ,
txtFunction _Tanh : 'Hyperbolic Tangent Function' ,
txtFunction _Csch : 'Hyperbolic Cosecant Function' ,
txtFunction _Sech : 'Hyperbolic Secant Function' ,
txtFunction _Coth : 'Hyperbolic Cotangent Function' ,
txtFunction _1 _Sinh : 'Hyperbolic Inverse Sine Function' ,
txtFunction _1 _Cosh : 'Hyperbolic Inverse Cosine Function' ,
txtFunction _1 _Tanh : 'Hyperbolic Inverse Tangent Function' ,
txtFunction _1 _Csch : 'Hyperbolic Inverse Cosecant Function' ,
txtFunction _1 _Sech : 'Hyperbolic Inverse Secant Function' ,
txtFunction _1 _Coth : 'Hyperbolic Inverse Cotangent Function' ,
txtFunction _Custom _1 : 'Sine theta' ,
txtFunction _Custom _2 : 'Cos 2x' ,
txtFunction _Custom _3 : 'Tangent formula' ,
txtAccent _Dot : 'Dot' ,
txtAccent _DDot : 'Double Dot' ,
txtAccent _DDDot : 'Triple Dot' ,
txtAccent _Hat : 'Hat' ,
txtAccent _Check : 'Check' ,
txtAccent _Accent : 'Acute' ,
txtAccent _Grave : 'Grave' ,
txtAccent _Smile : 'Breve' ,
txtAccent _Tilde : 'Tilde' ,
txtAccent _Bar : 'Bar' ,
txtAccent _DoubleBar : 'Double Overbar' ,
txtAccent _CurveBracketTop : 'Overbrace' ,
txtAccent _CurveBracketBot : 'Underbrace' ,
txtAccent _GroupTop : 'Grouping Character Above' ,
txtAccent _GroupBot : 'Grouping Character Below' ,
txtAccent _ArrowL : 'Leftwards Arrow Above' ,
txtAccent _ArrowR : 'Rightwards Arrow Above' ,
txtAccent _ArrowD : 'Right-Left Arrow Above' ,
txtAccent _HarpoonL : 'Leftwards Harpoon Above' ,
txtAccent _HarpoonR : 'Rightwards Harpoon Above' ,
txtAccent _BorderBox : 'Boxed Formula (With Placeholder)' ,
txtAccent _BorderBoxCustom : 'Boxed Formula (Example)' ,
txtAccent _BarTop : 'Overbar' ,
txtAccent _BarBot : 'Underbar' ,
txtAccent _Custom _1 : 'Vector A' ,
txtAccent _Custom _2 : 'ABC With Overbar' ,
txtAccent _Custom _3 : 'x XOR y With Overbar' ,
txtLimitLog _LogBase : 'Logarithm' ,
txtLimitLog _Log : 'Logarithm' ,
txtLimitLog _Lim : 'Limit' ,
txtLimitLog _Min : 'Minimum' ,
txtLimitLog _Max : 'Maximum' ,
txtLimitLog _Ln : 'Natural Logarithm' ,
txtLimitLog _Custom _1 : 'Limit Example' ,
txtLimitLog _Custom _2 : 'Maximum Example' ,
txtOperator _ColonEquals : 'Colon Equal' ,
txtOperator _EqualsEquals : 'Equal Equal' ,
txtOperator _PlusEquals : 'Plus Equal' ,
txtOperator _MinusEquals : 'Minus Equal' ,
txtOperator _Definition : 'Equal to By Definition' ,
txtOperator _UnitOfMeasure : 'Measured By' ,
txtOperator _DeltaEquals : 'Delta Equal To' ,
txtOperator _ArrowL _Top : 'Leftwards Arrow Above' ,
txtOperator _ArrowR _Top : 'Rightwards Arrow Above' ,
txtOperator _ArrowL _Bot : 'Leftwards Arrow Below' ,
txtOperator _ArrowR _Bot : 'Rightwards Arrow Below' ,
txtOperator _DoubleArrowL _Top : 'Leftwards Arrow Above' ,
txtOperator _DoubleArrowR _Top : 'Rightwards Arrow Above' ,
txtOperator _DoubleArrowL _Bot : 'Leftwards Arrow Below' ,
txtOperator _DoubleArrowR _Bot : 'Rightwards Arrow Below' ,
txtOperator _ArrowD _Top : 'Right-Left Arrow Above' ,
txtOperator _ArrowD _Bot : 'Right-Left Arrow Above' ,
txtOperator _DoubleArrowD _Top : 'Right-Left Arrow Below' ,
txtOperator _DoubleArrowD _Bot : 'Right-Left Arrow Below' ,
txtOperator _Custom _1 : 'Yileds' ,
txtOperator _Custom _2 : 'Delta Yields' ,
txtMatrix _1 _2 : '1x2 Empty Matrix' ,
txtMatrix _2 _1 : '2x1 Empty Matrix' ,
txtMatrix _1 _3 : '1x3 Empty Matrix' ,
txtMatrix _3 _1 : '3x1 Empty Matrix' ,
txtMatrix _2 _2 : '2x2 Empty Matrix' ,
txtMatrix _2 _3 : '2x3 Empty Matrix' ,
txtMatrix _3 _2 : '3x2 Empty Matrix' ,
txtMatrix _3 _3 : '3x3 Empty Matrix' ,
txtMatrix _Dots _Center : 'Midline Dots' ,
txtMatrix _Dots _Baseline : 'Baseline Dots' ,
txtMatrix _Dots _Vertical : 'Vertical Dots' ,
txtMatrix _Dots _Diagonal : 'Diagonal Dots' ,
txtMatrix _Identity _2 : '2x2 Identity Matrix' ,
txtMatrix _Identity _2 _NoZeros : '3x3 Identity Matrix' ,
txtMatrix _Identity _3 : '3x3 Identity Matrix' ,
txtMatrix _Identity _3 _NoZeros : '3x3 Identity Matrix' ,
txtMatrix _2 _2 _RoundBracket : 'Empty Matrix with Brackets' ,
txtMatrix _2 _2 _SquareBracket : 'Empty Matrix with Brackets' ,
txtMatrix _2 _2 _LineBracket : 'Empty Matrix with Brackets' ,
txtMatrix _2 _2 _DLineBracket : 'Empty Matrix with Brackets' ,
txtMatrix _Flat _Round : 'Sparse Matrix' ,
2017-02-06 14:12:59 +00:00
txtMatrix _Flat _Square : 'Sparse Matrix' ,
txtExpandSort : 'The data next to the selection will not be sorted. Do you want to expand the selection to include the adjacent data or continue with sorting the currently selected cells only?' ,
txtExpand : 'Expand and sort' ,
txtSorting : 'Sorting' ,
2017-04-11 11:05:56 +00:00
txtSortSelected : 'Sort selected' ,
textLongOperation : 'Long operation' ,
2017-04-18 13:16:03 +00:00
warnLongOperation : 'The operation you are about to perform might take rather much time to complete.<br>Are you sure you want to continue?' ,
txtInvalidRange : 'ERROR! Invalid cells range' ,
errorMaxRows : 'ERROR! The maximum number of data series per chart is 255.' ,
2017-06-30 14:49:58 +00:00
errorStockChart : 'Incorrect row order. To build a stock chart place the data on the sheet in the following order:<br> opening price, max price, min price, closing price.' ,
2019-09-19 10:31:23 +00:00
textPivot : 'Pivot Table' ,
txtTable _TableStyleMedium : 'Table Style Medium' ,
txtTable _TableStyleDark : 'Table Style Dark' ,
2019-11-14 08:48:58 +00:00
txtTable _TableStyleLight : 'Table Style Light' ,
2022-07-22 12:51:54 +00:00
txtGroupTable _Custom : 'Custom' ,
txtGroupTable _Light : 'Light' ,
txtGroupTable _Medium : 'Medium' ,
txtGroupTable _Dark : 'Dark' ,
2022-09-22 19:06:58 +00:00
txtGroupCell _Custom : 'Custom' ,
txtGroupCell _GoodBadAndNeutral : 'Good, Bad, and Neutral' ,
txtGroupCell _DataAndModel : 'Data and Model' ,
txtGroupCell _TitlesAndHeadings : 'Titles and Headings' ,
txtGroupCell _ThemedCallStyles : 'Themed Call Styles' ,
txtGroupCell _NumberFormat : 'Number Format' ,
txtGroupCell _NoName : 'No name' ,
2020-05-08 17:18:53 +00:00
textInsert : 'Insert' ,
txtInsertCells : 'Insert Cells' ,
2020-12-08 08:48:28 +00:00
txtDeleteCells : 'Delete Cells' ,
2021-02-25 20:15:05 +00:00
errorComboSeries : 'To create a combination chart, select at least two series of data.' ,
textDirectional : 'Directional' ,
textShapes : 'Shapes' ,
textIndicator : 'Indicators' ,
2021-08-10 21:24:12 +00:00
textRating : 'Ratings' ,
2021-09-16 17:47:48 +00:00
txtLockSort : 'Data is found next to your selection, but you do not have sufficient permissions to change those cells.<br>Do you wish to continue with the current selection?' ,
textRecentlyUsed : 'Recently Used'
2017-02-06 14:12:59 +00:00
2016-03-11 00:48:53 +00:00
} , SSE . Controllers . Toolbar || { } ) ) ;
} ) ;