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
define ( [
'core' ,
'common/main/lib/util/Shortcuts' ,
2018-09-27 12:25:15 +00:00
'common/main/lib/view/SaveAsDlg' ,
2016-03-11 00:48:53 +00:00
'spreadsheeteditor/main/app/view/LeftMenu' ,
'spreadsheeteditor/main/app/view/FileMenu'
] , function ( ) {
'use strict' ;
SSE . Controllers . LeftMenu = Backbone . Controller . extend ( _ . extend ( {
views : [
'LeftMenu' ,
'FileMenu'
] ,
initialize : function ( ) {
this . addListeners ( {
'Common.Views.Chat' : {
'hide' : _ . bind ( this . onHideChat , this )
} ,
2017-08-11 11:01:27 +00:00
'Common.Views.Plugins' : {
2017-12-06 11:25:29 +00:00
'plugin:open' : _ . bind ( this . onPluginOpen , this ) ,
'hide' : _ . bind ( this . onHidePlugins , this )
2017-08-11 11:01:27 +00:00
} ,
2017-08-22 08:06:21 +00:00
'Common.Views.Header' : {
2021-06-28 17:18:53 +00:00
'file:settings' : _ . bind ( this . clickToolbarSettings , this ) ,
'history:show' : function ( ) {
if ( ! this . leftMenu . panelHistory . isVisible ( ) )
this . clickMenuFileItem ( 'header' , 'history' ) ;
} . bind ( this )
2016-03-11 00:48:53 +00:00
} ,
'LeftMenu' : {
'file:show' : _ . bind ( this . fileShowHide , this , true ) ,
'file:hide' : _ . bind ( this . fileShowHide , this , false ) ,
'comments:show' : _ . bind ( this . commentsShowHide , this , true ) ,
'comments:hide' : _ . bind ( this . commentsShowHide , this , false )
} ,
'Common.Views.About' : {
'show' : _ . bind ( this . aboutShowHide , this , true ) ,
'hide' : _ . bind ( this . aboutShowHide , this , false )
} ,
'FileMenu' : {
2017-05-01 11:30:44 +00:00
'menu:hide' : _ . bind ( this . menuFilesShowHide , this , 'hide' ) ,
'menu:show' : _ . bind ( this . menuFilesShowHide , this , 'show' ) ,
2016-03-11 00:48:53 +00:00
'item:click' : _ . bind ( this . clickMenuFileItem , this ) ,
'saveas:format' : _ . bind ( this . clickSaveAsFormat , this ) ,
2018-09-27 12:25:15 +00:00
'savecopy:format' : _ . bind ( this . clickSaveCopyAsFormat , this ) ,
2016-03-11 00:48:53 +00:00
'settings:apply' : _ . bind ( this . applySettings , this ) ,
2019-11-29 13:57:42 +00:00
'spellcheck:apply' : _ . bind ( this . applySpellcheckSettings , this ) ,
2016-03-11 00:48:53 +00:00
'create:new' : _ . bind ( this . onCreateNew , this ) ,
2017-11-17 14:35:40 +00:00
'recent:open' : _ . bind ( this . onOpenRecent , this )
2016-03-11 00:48:53 +00:00
} ,
'Toolbar' : {
2017-04-27 15:40:27 +00:00
'file:settings' : _ . bind ( this . clickToolbarSettings , this ) ,
'file:open' : this . clickToolbarTab . bind ( this , 'file' ) ,
2018-02-15 23:56:17 +00:00
'file:close' : this . clickToolbarTab . bind ( this , 'other' ) ,
'save:disabled' : this . changeToolbarSaveState . bind ( this )
2016-03-11 00:48:53 +00:00
} ,
'SearchDialog' : {
'hide' : _ . bind ( this . onSearchDlgHide , this ) ,
'search:back' : _ . bind ( this . onQuerySearch , this , 'back' ) ,
'search:next' : _ . bind ( this . onQuerySearch , this , 'next' ) ,
'search:replace' : _ . bind ( this . onQueryReplace , this ) ,
2017-12-08 08:57:37 +00:00
'search:replaceall' : _ . bind ( this . onQueryReplaceAll , this ) ,
'search:highlight' : _ . bind ( this . onSearchHighlight , this )
2017-10-12 10:43:23 +00:00
} ,
'Common.Views.ReviewChanges' : {
'collaboration:chat' : _ . bind ( this . onShowHideChat , this )
2016-03-11 00:48:53 +00:00
}
} ) ;
2017-06-30 11:33:31 +00:00
Common . NotificationCenter . on ( 'app:comment:add' , _ . bind ( this . onAppAddComment , this ) ) ;
2021-07-06 22:51:19 +00:00
Common . NotificationCenter . on ( 'leftmenu:change' , _ . bind ( this . onMenuChange , this ) ) ;
2021-06-28 17:18:53 +00:00
Common . NotificationCenter . on ( 'collaboration:history' , _ . bind ( function ( ) {
if ( ! this . leftMenu . panelHistory . isVisible ( ) )
this . clickMenuFileItem ( null , 'history' ) ;
} , this ) ) ;
2021-10-21 13:01:30 +00:00
Common . NotificationCenter . on ( 'file:print' , _ . bind ( this . clickToolbarPrint , this ) ) ;
2016-03-11 00:48:53 +00:00
} ,
onLaunch : function ( ) {
this . leftMenu = this . createView ( 'LeftMenu' ) . render ( ) ;
this . leftMenu . btnSearch . on ( 'toggle' , _ . bind ( this . onMenuSearch , this ) ) ;
Common . util . Shortcuts . delegateShortcuts ( {
shortcuts : {
'command+shift+s,ctrl+shift+s' : _ . bind ( this . onShortcut , this , 'save' ) ,
'command+f,ctrl+f' : _ . bind ( this . onShortcut , this , 'search' ) ,
2018-10-12 11:36:01 +00:00
'ctrl+h' : _ . bind ( this . onShortcut , this , 'replace' ) ,
2016-03-11 00:48:53 +00:00
'alt+f' : _ . bind ( this . onShortcut , this , 'file' ) ,
'esc' : _ . bind ( this . onShortcut , this , 'escape' ) ,
/** coauthoring begin **/
'alt+q' : _ . bind ( this . onShortcut , this , 'chat' ) ,
'command+shift+h,ctrl+shift+h' : _ . bind ( this . onShortcut , this , 'comments' ) ,
/** coauthoring end **/
'f1' : _ . bind ( this . onShortcut , this , 'help' )
}
} ) ;
Common . util . Shortcuts . suspendEvents ( ) ;
var me = this ;
this . leftMenu . $el . find ( 'button' ) . each ( function ( ) {
$ ( this ) . on ( 'keydown' , function ( e ) {
if ( Common . UI . Keys . RETURN === e . keyCode || Common . UI . Keys . SPACE === e . keyCode ) {
me . leftMenu . btnAbout . toggle ( false ) ;
this . blur ( ) ;
e . preventDefault ( ) ;
me . api . asc _enableKeyEvents ( true ) ;
}
} ) ;
} ) ;
} ,
setApi : function ( api ) {
this . api = api ;
2018-10-25 13:19:29 +00:00
this . api . asc _registerCallback ( 'asc_onCoAuthoringDisconnect' , _ . bind ( this . onApiServerDisconnect , this ) ) ;
2016-03-11 00:48:53 +00:00
Common . NotificationCenter . on ( 'api:disconnect' , _ . bind ( this . onApiServerDisconnect , this ) ) ;
2018-09-27 12:25:15 +00:00
this . api . asc _registerCallback ( 'asc_onDownloadUrl' , _ . bind ( this . onDownloadUrl , this ) ) ;
2019-01-10 11:00:30 +00:00
Common . NotificationCenter . on ( 'download:cancel' , _ . bind ( this . onDownloadCancel , this ) ) ;
2016-03-11 00:48:53 +00:00
/** coauthoring begin **/
if ( this . mode . canCoAuthoring ) {
if ( this . mode . canChat )
this . api . asc _registerCallback ( 'asc_onCoAuthoringChatReceiveMessage' , _ . bind ( this . onApiChatMessage , this ) ) ;
if ( this . mode . canComments ) {
this . api . asc _registerCallback ( 'asc_onAddComment' , _ . bind ( this . onApiAddComment , this ) ) ;
this . api . asc _registerCallback ( 'asc_onAddComments' , _ . bind ( this . onApiAddComments , this ) ) ;
2018-11-16 13:44:11 +00:00
var comments = this . getApplication ( ) . getController ( 'Common.Controllers.Comments' ) . groupCollection ;
for ( var name in comments ) {
2019-02-20 11:13:10 +00:00
var collection = comments [ name ] ,
resolved = Common . Utils . InternalSettings . get ( "sse-settings-resolvedcomment" ) ;
2018-11-16 13:44:11 +00:00
for ( var i = 0 ; i < collection . length ; ++ i ) {
2021-07-23 14:40:21 +00:00
var comment = collection . at ( i ) ;
if ( ! comment . get ( 'hide' ) && comment . get ( 'userid' ) !== this . mode . user . id && ( resolved || ! comment . get ( 'resolved' ) ) ) {
2018-11-16 13:44:11 +00:00
this . leftMenu . markCoauthOptions ( 'comments' , true ) ;
break ;
}
2016-03-11 00:48:53 +00:00
}
}
}
}
/** coauthoring end **/
if ( ! this . mode . isEditMailMerge && ! this . mode . isEditDiagram )
this . api . asc _registerCallback ( 'asc_onEditCell' , _ . bind ( this . onApiEditCell , this ) ) ;
this . leftMenu . getMenu ( 'file' ) . setApi ( api ) ;
2021-06-28 17:18:53 +00:00
if ( this . mode . canUseHistory )
this . getApplication ( ) . getController ( 'Common.Controllers.History' ) . setApi ( this . api ) . setMode ( this . mode ) ;
2022-02-22 17:17:21 +00:00
this . getApplication ( ) . getController ( 'Search' ) . setApi ( this . api ) . setMode ( this . mode ) ;
this . leftMenu . setOptionsPanel ( 'advancedsearch' , this . getApplication ( ) . getController ( 'Search' ) . getView ( 'Common.Views.SearchPanel' ) ) ;
2016-03-11 00:48:53 +00:00
return this ;
} ,
setMode : function ( mode ) {
this . mode = mode ;
this . leftMenu . setMode ( mode ) ;
this . leftMenu . getMenu ( 'file' ) . setMode ( mode ) ;
2017-08-14 11:24:00 +00:00
if ( ! mode . isEdit ) // TODO: unlock 'save as', 'open file menu' for 'view' mode
Common . util . Shortcuts . removeShortcuts ( {
shortcuts : {
'command+shift+s,ctrl+shift+s' : _ . bind ( this . onShortcut , this , 'save' ) ,
'alt+f' : _ . bind ( this . onShortcut , this , 'file' )
}
} ) ;
2016-03-11 00:48:53 +00:00
return this ;
} ,
2021-07-01 21:54:55 +00:00
SetDisabled : function ( disable , options ) {
if ( this . leftMenu . _state . disabled !== disable ) {
this . leftMenu . _state . disabled = disable ;
if ( disable ) {
this . previsEdit = this . mode . isEdit ;
this . prevcanEdit = this . mode . canEdit ;
this . mode . isEdit = this . mode . canEdit = ! disable ;
} else {
this . mode . isEdit = this . previsEdit ;
this . mode . canEdit = this . prevcanEdit ;
}
}
2021-06-28 17:12:31 +00:00
if ( disable ) this . leftMenu . close ( ) ;
2020-09-23 16:01:44 +00:00
2021-07-01 21:54:55 +00:00
if ( ! options || options . comments && options . comments . disable )
this . leftMenu . btnComments . setDisabled ( disable ) ;
if ( ! options || options . chat )
this . leftMenu . btnChat . setDisabled ( disable ) ;
2020-09-23 16:01:44 +00:00
2021-06-28 17:12:31 +00:00
this . leftMenu . btnPlugins . setDisabled ( disable ) ;
this . leftMenu . btnSpellcheck . setDisabled ( disable ) ;
2020-09-23 16:01:44 +00:00
} ,
2016-03-11 00:48:53 +00:00
createDelayedElements : function ( ) {
/** coauthoring begin **/
if ( this . mode . canCoAuthoring ) {
2018-12-17 08:37:43 +00:00
this . leftMenu . btnComments [ ( this . mode . canViewComments && ! this . mode . isLightVersion ) ? 'show' : 'hide' ] ( ) ;
if ( this . mode . canViewComments )
2017-04-11 11:05:56 +00:00
this . leftMenu . setOptionsPanel ( 'comment' , this . getApplication ( ) . getController ( 'Common.Controllers.Comments' ) . getView ( 'Common.Views.Comments' ) ) ;
2016-03-11 00:48:53 +00:00
2016-06-30 09:38:54 +00:00
this . leftMenu . btnChat [ ( this . mode . canChat && ! this . mode . isLightVersion ) ? 'show' : 'hide' ] ( ) ;
2016-03-11 00:48:53 +00:00
if ( this . mode . canChat )
this . leftMenu . setOptionsPanel ( 'chat' , this . getApplication ( ) . getController ( 'Common.Controllers.Chat' ) . getView ( 'Common.Views.Chat' ) ) ;
} else {
this . leftMenu . btnChat . hide ( ) ;
this . leftMenu . btnComments . hide ( ) ;
}
2019-07-31 10:52:37 +00:00
2021-11-02 12:56:37 +00:00
if ( this . mode . isEdit && Common . UI . FeaturesManager . canChange ( 'spellcheck' ) ) {
2021-11-02 09:41:05 +00:00
Common . UI . LayoutManager . isElementVisible ( 'leftMenu-spellcheck' ) && this . leftMenu . btnSpellcheck . show ( ) ;
2019-08-06 11:27:47 +00:00
this . leftMenu . setOptionsPanel ( 'spellcheck' , this . getApplication ( ) . getController ( 'Spellcheck' ) . getView ( 'Spellcheck' ) ) ;
}
2021-06-28 17:18:53 +00:00
if ( this . mode . canUseHistory )
this . leftMenu . setOptionsPanel ( 'history' , this . getApplication ( ) . getController ( 'Common.Controllers.History' ) . getView ( 'Common.Views.History' ) ) ;
2019-07-31 10:52:37 +00:00
2020-11-02 20:26:17 +00:00
( this . mode . trialMode || this . mode . isBeta ) && this . leftMenu . setDeveloperMode ( this . mode . trialMode , this . mode . isBeta , this . mode . buildVersion ) ;
2016-03-11 00:48:53 +00:00
/** coauthoring end **/
Common . util . Shortcuts . resumeEvents ( ) ;
if ( ! this . mode . isEditMailMerge && ! this . mode . isEditDiagram )
Common . NotificationCenter . on ( 'cells:range' , _ . bind ( this . onCellsRange , this ) ) ;
return this ;
} ,
2016-07-05 12:21:26 +00:00
enablePlugins : function ( ) {
if ( this . mode . canPlugins ) {
2017-08-11 11:01:27 +00:00
// this.leftMenu.btnPlugins.show();
2016-07-05 12:21:26 +00:00
this . leftMenu . setOptionsPanel ( 'plugins' , this . getApplication ( ) . getController ( 'Common.Controllers.Plugins' ) . getView ( 'Common.Views.Plugins' ) ) ;
} else
this . leftMenu . btnPlugins . hide ( ) ;
2020-11-02 20:26:17 +00:00
( this . mode . trialMode || this . mode . isBeta ) && this . leftMenu . setDeveloperMode ( this . mode . trialMode , this . mode . isBeta , this . mode . buildVersion ) ;
2016-07-05 12:21:26 +00:00
} ,
2016-03-11 00:48:53 +00:00
clickMenuFileItem : function ( menu , action , isopts ) {
var close _menu = true ;
switch ( action ) {
case 'back' : break ;
case 'save' : this . api . asc _Save ( ) ; break ;
case 'save-desktop' : this . api . asc _DownloadAs ( ) ; break ;
2016-04-04 08:17:21 +00:00
case 'print' : Common . NotificationCenter . trigger ( 'print' , this . leftMenu ) ; break ;
2016-03-11 00:48:53 +00:00
case 'exit' : Common . NotificationCenter . trigger ( 'goback' ) ; break ;
case 'edit' :
2021-07-28 16:49:34 +00:00
this . getApplication ( ) . getController ( 'Statusbar' ) . setStatusCaption ( this . requestEditRightsText ) ;
2016-03-11 00:48:53 +00:00
Common . Gateway . requestEditRights ( ) ;
break ;
case 'new' :
if ( isopts ) close _menu = false ;
else this . onCreateNew ( undefined , 'blank' ) ;
break ;
2016-09-27 12:09:32 +00:00
case 'rename' :
var me = this ,
documentCaption = me . api . asc _getDocumentName ( ) ;
( new Common . Views . RenameDialog ( {
filename : documentCaption ,
2021-05-12 16:04:14 +00:00
maxLength : this . mode . wopi ? this . mode . wopi . FileNameMaxLength : undefined ,
2016-09-27 12:09:32 +00:00
handler : function ( result , value ) {
if ( result == 'ok' && ! _ . isEmpty ( value . trim ( ) ) && documentCaption !== value . trim ( ) ) {
2021-05-12 16:04:14 +00:00
me . mode . wopi ? me . api . asc _wopi _renameFile ( value ) : Common . Gateway . requestRename ( value ) ;
2016-09-27 12:09:32 +00:00
}
Common . NotificationCenter . trigger ( 'edit:complete' , me ) ;
}
} ) ) . show ( ) ;
break ;
2021-06-28 17:18:53 +00:00
case 'history' :
if ( ! this . leftMenu . panelHistory . isVisible ( ) ) {
if ( this . api . asc _isDocumentModified ( ) ) {
var me = this ;
this . api . asc _stopSaving ( ) ;
Common . UI . warning ( {
closable : false ,
width : 500 ,
title : this . notcriticalErrorTitle ,
msg : this . leavePageText ,
buttons : [ 'ok' , 'cancel' ] ,
primary : 'ok' ,
callback : function ( btn ) {
if ( btn == 'ok' ) {
me . api . asc _undoAllChanges ( ) ;
me . api . asc _continueSaving ( ) ;
me . showHistory ( ) ;
} else
me . api . asc _continueSaving ( ) ;
}
} ) ;
} else
this . showHistory ( ) ;
}
break ;
2016-03-11 00:48:53 +00:00
default : close _menu = false ;
}
2021-06-28 17:18:53 +00:00
if ( close _menu && menu ) {
2016-03-11 00:48:53 +00:00
menu . hide ( ) ;
}
} ,
clickSaveAsFormat : function ( menu , format ) {
2016-04-05 11:52:34 +00:00
if ( format == Asc . c _oAscFileType . CSV ) {
2016-03-11 00:48:53 +00:00
Common . UI . warning ( {
title : this . textWarning ,
msg : this . warnDownloadAs ,
buttons : [ 'ok' , 'cancel' ] ,
callback : _ . bind ( function ( btn ) {
if ( btn == 'ok' ) {
2019-07-25 07:14:45 +00:00
Common . NotificationCenter . trigger ( 'download:advanced' , Asc . c _oAscAdvancedOptionsID . CSV , this . api . asc _getAdvancedOptions ( ) , 2 , new Asc . asc _CDownloadOptions ( format ) ) ;
2016-03-11 00:48:53 +00:00
menu . hide ( ) ;
}
} , this )
} ) ;
2018-07-18 11:07:24 +00:00
} else if ( format == Asc . c _oAscFileType . PDF || format == Asc . c _oAscFileType . PDFA ) {
2018-04-05 11:29:37 +00:00
menu . hide ( ) ;
2018-07-18 11:07:24 +00:00
Common . NotificationCenter . trigger ( 'download:settings' , this . leftMenu , format ) ;
2016-03-11 00:48:53 +00:00
} else {
2019-07-24 08:36:13 +00:00
this . api . asc _DownloadAs ( new Asc . asc _CDownloadOptions ( format ) ) ;
2016-03-11 00:48:53 +00:00
menu . hide ( ) ;
}
} ,
2018-09-27 12:25:15 +00:00
clickSaveCopyAsFormat : function ( menu , format , ext ) {
if ( format == Asc . c _oAscFileType . CSV ) {
Common . UI . warning ( {
title : this . textWarning ,
msg : this . warnDownloadAs ,
buttons : [ 'ok' , 'cancel' ] ,
callback : _ . bind ( function ( btn ) {
if ( btn == 'ok' ) {
this . isFromFileDownloadAs = ext ;
2019-07-25 07:14:45 +00:00
Common . NotificationCenter . trigger ( 'download:advanced' , Asc . c _oAscAdvancedOptionsID . CSV , this . api . asc _getAdvancedOptions ( ) , 2 , new Asc . asc _CDownloadOptions ( format , true ) ) ;
2018-09-27 12:25:15 +00:00
menu . hide ( ) ;
}
} , this )
} ) ;
} else if ( format == Asc . c _oAscFileType . PDF || format == Asc . c _oAscFileType . PDFA ) {
this . isFromFileDownloadAs = ext ;
menu . hide ( ) ;
Common . NotificationCenter . trigger ( 'download:settings' , this . leftMenu , format , true ) ;
} else {
this . isFromFileDownloadAs = ext ;
2019-07-24 08:36:13 +00:00
this . api . asc _DownloadAs ( new Asc . asc _CDownloadOptions ( format , true ) ) ;
2018-09-27 12:25:15 +00:00
menu . hide ( ) ;
}
} ,
2021-07-29 22:01:33 +00:00
onDownloadUrl : function ( url , fileType ) {
2018-09-27 12:25:15 +00:00
if ( this . isFromFileDownloadAs ) {
var me = this ,
defFileName = this . getApplication ( ) . getController ( 'Viewport' ) . getView ( 'Common.Views.Header' ) . getDocumentCaption ( ) ;
! defFileName && ( defFileName = me . txtUntitled ) ;
if ( typeof this . isFromFileDownloadAs == 'string' ) {
var idx = defFileName . lastIndexOf ( '.' ) ;
if ( idx > 0 )
defFileName = defFileName . substring ( 0 , idx ) + this . isFromFileDownloadAs ;
}
2019-07-26 09:54:20 +00:00
if ( me . mode . canRequestSaveAs ) {
2021-07-29 22:01:33 +00:00
Common . Gateway . requestSaveAs ( url , defFileName , fileType ) ;
2019-07-26 09:54:20 +00:00
} else {
me . _saveCopyDlg = new Common . Views . SaveAsDlg ( {
saveFolderUrl : me . mode . saveAsUrl ,
saveFileUrl : url ,
defFileName : defFileName
} ) ;
me . _saveCopyDlg . on ( 'saveaserror' , function ( obj , err ) {
var config = {
closable : false ,
title : me . textWarning ,
msg : err ,
iconCls : 'warn' ,
buttons : [ 'ok' ] ,
callback : function ( btn ) {
Common . NotificationCenter . trigger ( 'edit:complete' , me ) ;
}
} ;
Common . UI . alert ( config ) ;
} ) . on ( 'close' , function ( obj ) {
me . _saveCopyDlg = undefined ;
} ) ;
me . _saveCopyDlg . show ( ) ;
}
2018-09-27 12:25:15 +00:00
}
this . isFromFileDownloadAs = false ;
} ,
2019-01-10 11:00:30 +00:00
onDownloadCancel : function ( ) {
this . isFromFileDownloadAs = false ;
} ,
2016-03-11 00:48:53 +00:00
applySettings : function ( menu ) {
2020-02-17 13:43:02 +00:00
var value = Common . localStorage . getBool ( "sse-settings-cachemode" , true ) ;
Common . Utils . InternalSettings . set ( "sse-settings-cachemode" , value ) ;
this . api . asc _setDefaultBlitMode ( value ) ;
value = Common . localStorage . getItem ( "sse-settings-fontrender" ) ;
2017-10-04 15:44:01 +00:00
Common . Utils . InternalSettings . set ( "sse-settings-fontrender" , value ) ;
this . api . asc _setFontRenderingMode ( parseInt ( value ) ) ;
2016-03-11 00:48:53 +00:00
/** coauthoring begin **/
2017-10-04 15:44:01 +00:00
value = Common . localStorage . getBool ( "sse-settings-livecomment" , true ) ;
Common . Utils . InternalSettings . set ( "sse-settings-livecomment" , value ) ;
2018-04-26 12:17:02 +00:00
var resolved = Common . localStorage . getBool ( "sse-settings-resolvedcomment" ) ;
2017-10-04 15:44:01 +00:00
Common . Utils . InternalSettings . set ( "sse-settings-resolvedcomment" , resolved ) ;
2018-12-17 08:37:43 +00:00
if ( this . mode . canViewComments && this . leftMenu . panelComments . isVisible ( ) )
2017-10-04 15:44:01 +00:00
value = resolved = true ;
( value ) ? this . api . asc _showComments ( resolved ) : this . api . asc _hideComments ( ) ;
2019-10-29 14:08:47 +00:00
this . getApplication ( ) . getController ( 'Common.Controllers.ReviewChanges' ) . commentsShowHide ( value ? 'show' : 'hide' ) ;
2016-03-11 00:48:53 +00:00
2018-11-14 15:11:36 +00:00
value = Common . localStorage . getBool ( "sse-settings-r1c1" ) ;
Common . Utils . InternalSettings . set ( "sse-settings-r1c1" , value ) ;
this . api . asc _setR1C1Mode ( value ) ;
2021-04-02 19:36:08 +00:00
var fast _coauth = Common . Utils . InternalSettings . get ( "sse-settings-coauthmode" ) ;
2016-12-20 14:29:37 +00:00
if ( this . mode . isEdit && ! this . mode . isOffline && this . mode . canCoAuthoring ) {
2021-04-02 19:36:08 +00:00
if ( this . mode . canChangeCoAuthoring ) {
fast _coauth = Common . localStorage . getBool ( "sse-settings-coauthmode" , true ) ;
Common . Utils . InternalSettings . set ( "sse-settings-coauthmode" , fast _coauth ) ;
this . api . asc _SetFastCollaborative ( fast _coauth ) ;
}
2016-03-11 00:48:53 +00:00
}
/** coauthoring end **/
2017-06-16 07:29:15 +00:00
if ( this . mode . isEdit ) {
2021-04-02 19:36:08 +00:00
if ( this . mode . canChangeCoAuthoring || ! fast _coauth ) { // can change co-auth. mode or for strict mode
value = parseInt ( Common . localStorage . getItem ( "sse-settings-autosave" ) ) ;
Common . Utils . InternalSettings . set ( "sse-settings-autosave" , value ) ;
this . api . asc _setAutoSaveGap ( value ) ;
}
2020-06-03 17:49:54 +00:00
value = parseInt ( Common . localStorage . getItem ( "sse-settings-paste-button" ) ) ;
Common . Utils . InternalSettings . set ( "sse-settings-paste-button" , value ) ;
this . api . asc _setVisiblePasteButton ( ! ! value ) ;
2017-06-16 07:29:15 +00:00
}
2016-03-11 00:48:53 +00:00
2019-11-29 08:29:13 +00:00
var reg = Common . localStorage . getItem ( "sse-settings-reg-settings" ) ,
2019-12-06 13:46:11 +00:00
baseRegSettings = Common . Utils . InternalSettings . get ( "sse-settings-use-base-separator" ) ;
if ( reg === null ) {
reg = this . api . asc _getLocale ( ) ;
}
if ( baseRegSettings ) {
this . api . asc _setLocale ( parseInt ( reg ) , undefined , undefined ) ;
}
else {
this . api . asc _setLocale ( parseInt ( reg ) , Common . localStorage . getItem ( "sse-settings-decimal-separator" ) , Common . localStorage . getItem ( "sse-settings-group-separator" ) ) ;
}
2016-03-11 00:48:53 +00:00
menu . hide ( ) ;
this . leftMenu . fireEvent ( 'settings:apply' ) ;
} ,
2019-11-29 13:57:42 +00:00
applySpellcheckSettings : function ( menu ) {
2021-11-02 12:56:37 +00:00
if ( this . mode . isEdit && this . api && Common . UI . FeaturesManager . canChange ( 'spellcheck' ) ) {
2019-11-29 13:57:42 +00:00
var value = Common . localStorage . getBool ( "sse-spellcheck-ignore-uppercase-words" ) ;
this . api . asc _ignoreUppercase ( value ) ;
value = Common . localStorage . getBool ( "sse-spellcheck-ignore-numbers-words" ) ;
this . api . asc _ignoreNumbers ( value ) ;
value = Common . localStorage . getItem ( "sse-spellcheck-locale" ) ;
if ( value ) {
this . api . asc _setDefaultLanguage ( parseInt ( value ) ) ;
}
}
menu . hide ( ) ;
this . leftMenu . fireEvent ( 'spellcheck:update' ) ;
} ,
2016-03-11 00:48:53 +00:00
onCreateNew : function ( menu , type ) {
2019-07-16 13:30:37 +00:00
if ( ! Common . Controllers . Desktop . process ( 'create:new' ) ) {
2021-08-24 13:16:04 +00:00
if ( type == 'blank' && this . mode . canRequestCreateNew )
2020-06-15 17:05:19 +00:00
Common . Gateway . requestCreateNew ( ) ;
else {
var newDocumentPage = window . open ( type == 'blank' ? this . mode . createUrl : type , "_blank" ) ;
if ( newDocumentPage ) newDocumentPage . focus ( ) ;
}
2019-07-16 13:30:37 +00:00
}
2016-03-11 00:48:53 +00:00
if ( menu ) {
menu . hide ( ) ;
}
} ,
onOpenRecent : function ( menu , url ) {
if ( menu ) {
menu . hide ( ) ;
}
var recentDocPage = window . open ( url ) ;
if ( recentDocPage )
recentDocPage . focus ( ) ;
Common . component . Analytics . trackEvent ( 'Open Recent' ) ;
} ,
clickToolbarSettings : function ( obj ) {
2017-04-27 15:34:19 +00:00
this . leftMenu . showMenu ( 'file:opts' ) ;
} ,
2017-04-27 15:40:27 +00:00
clickToolbarTab : function ( tab , e ) {
if ( tab == 'file' )
this . leftMenu . showMenu ( 'file' ) ; else
this . leftMenu . menuFile . hide ( ) ;
2016-03-11 00:48:53 +00:00
} ,
2021-10-21 13:01:30 +00:00
clickToolbarPrint : function ( ) {
this . leftMenu . showMenu ( 'file:printpreview' ) ;
} ,
2018-02-15 23:56:17 +00:00
changeToolbarSaveState : function ( state ) {
2018-07-25 08:21:18 +00:00
var btnSave = this . leftMenu . menuFile . getButton ( 'save' ) ;
btnSave && btnSave . setDisabled ( state ) ;
2018-02-15 23:56:17 +00:00
} ,
2016-03-11 00:48:53 +00:00
/** coauthoring begin **/
onHideChat : function ( ) {
$ ( this . leftMenu . btnChat . el ) . blur ( ) ;
Common . NotificationCenter . trigger ( 'layout:changed' , 'leftmenu' ) ;
} ,
2017-12-06 11:25:29 +00:00
onHidePlugins : function ( ) {
Common . NotificationCenter . trigger ( 'layout:changed' , 'leftmenu' ) ;
} ,
2016-03-11 00:48:53 +00:00
/** coauthoring end **/
onQuerySearch : function ( d , w , opts ) {
2021-09-30 19:07:16 +00:00
// if (opts.textsearch && opts.textsearch.length) {
2016-03-11 00:48:53 +00:00
var options = this . dlgSearch . findOptions ;
options . asc _setFindWhat ( opts . textsearch ) ;
options . asc _setScanForward ( d != 'back' ) ;
options . asc _setIsMatchCase ( opts . matchcase ) ;
options . asc _setIsWholeCell ( opts . matchword ) ;
options . asc _setScanOnOnlySheet ( this . dlgSearch . menuWithin . menu . items [ 0 ] . checked ) ;
options . asc _setScanByRows ( this . dlgSearch . menuSearch . menu . items [ 0 ] . checked ) ;
2016-04-05 11:52:34 +00:00
options . asc _setLookIn ( this . dlgSearch . menuLookin . menu . items [ 0 ] . checked ? Asc . c _oAscFindLookIn . Formulas : Asc . c _oAscFindLookIn . Value ) ;
2016-03-11 00:48:53 +00:00
if ( ! this . api . asc _findText ( options ) ) {
var me = this ;
Common . UI . info ( {
msg : this . textNoTextFound ,
callback : function ( ) {
me . dlgSearch . focus ( ) ;
}
} ) ;
}
2021-09-30 19:07:16 +00:00
// }
2016-03-11 00:48:53 +00:00
} ,
onQueryReplace : function ( w , opts ) {
2021-09-30 19:07:16 +00:00
// if (!_.isEmpty(opts.textsearch)) {
2016-03-11 00:48:53 +00:00
this . api . isReplaceAll = false ;
var options = this . dlgSearch . findOptions ;
options . asc _setFindWhat ( opts . textsearch ) ;
options . asc _setReplaceWith ( opts . textreplace ) ;
options . asc _setIsMatchCase ( opts . matchcase ) ;
options . asc _setIsWholeCell ( opts . matchword ) ;
options . asc _setScanOnOnlySheet ( this . dlgSearch . menuWithin . menu . items [ 0 ] . checked ) ;
options . asc _setScanByRows ( this . dlgSearch . menuSearch . menu . items [ 0 ] . checked ) ;
2016-04-05 11:52:34 +00:00
options . asc _setLookIn ( this . dlgSearch . menuLookin . menu . items [ 0 ] . checked ? Asc . c _oAscFindLookIn . Formulas : Asc . c _oAscFindLookIn . Value ) ;
2016-03-11 00:48:53 +00:00
options . asc _setIsReplaceAll ( false ) ;
this . api . asc _replaceText ( options ) ;
2021-09-30 19:07:16 +00:00
// }
2016-03-11 00:48:53 +00:00
} ,
onQueryReplaceAll : function ( w , opts ) {
2021-09-30 19:07:16 +00:00
// if (!_.isEmpty(opts.textsearch)) {
2016-03-11 00:48:53 +00:00
this . api . isReplaceAll = true ;
var options = this . dlgSearch . findOptions ;
options . asc _setFindWhat ( opts . textsearch ) ;
options . asc _setReplaceWith ( opts . textreplace ) ;
options . asc _setIsMatchCase ( opts . matchcase ) ;
options . asc _setIsWholeCell ( opts . matchword ) ;
options . asc _setScanOnOnlySheet ( this . dlgSearch . menuWithin . menu . items [ 0 ] . checked ) ;
options . asc _setScanByRows ( this . dlgSearch . menuSearch . menu . items [ 0 ] . checked ) ;
2016-04-05 11:52:34 +00:00
options . asc _setLookIn ( this . dlgSearch . menuLookin . menu . items [ 0 ] . checked ? Asc . c _oAscFindLookIn . Formulas : Asc . c _oAscFindLookIn . Value ) ;
2016-03-11 00:48:53 +00:00
options . asc _setIsReplaceAll ( true ) ;
this . api . asc _replaceText ( options ) ;
2021-09-30 19:07:16 +00:00
// }
2016-03-11 00:48:53 +00:00
} ,
2017-12-08 08:57:37 +00:00
onSearchHighlight : function ( w , highlight ) {
this . api . asc _selectSearchingResults ( highlight ) ;
} ,
2016-03-11 00:48:53 +00:00
showSearchDlg : function ( show , action ) {
if ( ! this . dlgSearch ) {
var menuWithin = new Common . UI . MenuItem ( {
caption : this . textWithin ,
menu : new Common . UI . Menu ( {
menuAlign : 'tl-tr' ,
items : [ {
caption : this . textSheet ,
toggleGroup : 'searchWithih' ,
checkable : true ,
checked : true
} , {
caption : this . textWorkbook ,
toggleGroup : 'searchWithih' ,
checkable : true ,
checked : false
} ]
} )
} ) ;
var menuSearch = new Common . UI . MenuItem ( {
caption : this . textSearch ,
menu : new Common . UI . Menu ( {
menuAlign : 'tl-tr' ,
items : [ {
caption : this . textByRows ,
toggleGroup : 'searchByrows' ,
checkable : true ,
checked : true
} , {
caption : this . textByColumns ,
toggleGroup : 'searchByrows' ,
checkable : true ,
checked : false
} ]
} )
} ) ;
var menuLookin = new Common . UI . MenuItem ( {
caption : this . textLookin ,
menu : new Common . UI . Menu ( {
menuAlign : 'tl-tr' ,
items : [ {
caption : this . textFormulas ,
toggleGroup : 'searchLookin' ,
checkable : true ,
checked : true
} , {
caption : this . textValues ,
toggleGroup : 'searchLookin' ,
checkable : true ,
checked : false
} ]
} )
} ) ;
this . dlgSearch = ( new Common . UI . SearchDialog ( {
matchcase : true ,
matchword : true ,
matchwordstr : this . textItemEntireCell ,
2017-12-08 08:57:37 +00:00
markresult : { applied : true } ,
2016-03-11 00:48:53 +00:00
extraoptions : [ menuWithin , menuSearch , menuLookin ]
} ) ) ;
this . dlgSearch . menuWithin = menuWithin ;
this . dlgSearch . menuSearch = menuSearch ;
this . dlgSearch . menuLookin = menuLookin ;
this . dlgSearch . findOptions = new Asc . asc _CFindOptions ( ) ;
}
if ( show ) {
2019-02-13 09:57:02 +00:00
var mode = this . mode . isEdit && ! this . viewmode ? ( action || undefined ) : 'no-replace' ;
2016-03-11 00:48:53 +00:00
if ( this . dlgSearch . isVisible ( ) ) {
this . dlgSearch . setMode ( mode ) ;
this . dlgSearch . focus ( ) ;
} else {
this . dlgSearch . show ( mode ) ;
}
this . api . asc _closeCellEditor ( ) ;
} else this . dlgSearch [ 'hide' ] ( ) ;
} ,
onMenuSearch : function ( obj , show ) {
this . showSearchDlg ( show ) ;
} ,
onSearchDlgHide : function ( ) {
this . leftMenu . btnSearch . toggle ( false , true ) ;
2017-12-08 08:57:37 +00:00
this . api . asc _selectSearchingResults ( false ) ;
2016-03-11 00:48:53 +00:00
$ ( this . leftMenu . btnSearch . el ) . blur ( ) ;
this . api . asc _enableKeyEvents ( true ) ;
} ,
2019-02-13 09:57:02 +00:00
setPreviewMode : function ( mode ) {
if ( this . viewmode === mode ) return ;
this . viewmode = mode ;
this . dlgSearch && this . dlgSearch . setMode ( this . viewmode ? 'no-replace' : 'search' ) ;
} ,
2018-10-25 13:19:29 +00:00
onApiServerDisconnect : function ( enableDownload ) {
2016-03-11 00:48:53 +00:00
this . mode . isEdit = false ;
this . leftMenu . close ( ) ;
/** coauthoring begin **/
this . leftMenu . btnComments . setDisabled ( true ) ;
this . leftMenu . btnChat . setDisabled ( true ) ;
/** coauthoring end **/
2016-07-05 12:21:26 +00:00
this . leftMenu . btnPlugins . setDisabled ( true ) ;
2019-07-31 10:52:37 +00:00
this . leftMenu . btnSpellcheck . setDisabled ( true ) ;
2016-03-11 00:48:53 +00:00
2018-10-25 13:19:29 +00:00
this . leftMenu . getMenu ( 'file' ) . setMode ( { isDisconnected : true , enableDownload : ! ! enableDownload } ) ;
2016-03-11 00:48:53 +00:00
if ( this . dlgSearch ) {
this . leftMenu . btnSearch . toggle ( false , true ) ;
this . dlgSearch [ 'hide' ] ( ) ;
}
} ,
/** coauthoring begin **/
onApiChatMessage : function ( ) {
this . leftMenu . markCoauthOptions ( 'chat' ) ;
} ,
onApiAddComment : function ( id , data ) {
2019-02-20 11:13:10 +00:00
var resolved = Common . Utils . InternalSettings . get ( "sse-settings-resolvedcomment" ) ;
2021-07-23 14:40:21 +00:00
if ( data && data . asc _getUserId ( ) !== this . mode . user . id && ( resolved || ! data . asc _getSolved ( ) ) && AscCommon . UserInfoParser . canViewComment ( data . asc _getUserName ( ) ) )
2016-03-11 00:48:53 +00:00
this . leftMenu . markCoauthOptions ( 'comments' ) ;
} ,
onApiAddComments : function ( data ) {
2019-02-20 11:13:10 +00:00
var resolved = Common . Utils . InternalSettings . get ( "sse-settings-resolvedcomment" ) ;
2016-03-11 00:48:53 +00:00
for ( var i = 0 ; i < data . length ; ++ i ) {
2021-08-09 10:39:58 +00:00
if ( data [ i ] . asc _getUserId ( ) !== this . mode . user . id && ( resolved || ! data [ i ] . asc _getSolved ( ) ) && AscCommon . UserInfoParser . canViewComment ( data [ i ] . asc _getUserName ( ) ) ) {
2016-03-11 00:48:53 +00:00
this . leftMenu . markCoauthOptions ( 'comments' ) ;
break ;
}
}
} ,
2017-06-30 11:33:31 +00:00
onAppAddComment : function ( sender , to _doc ) {
if ( to _doc ) {
var me = this ;
( new Promise ( function ( resolve , reject ) {
resolve ( ) ;
} ) ) . then ( function ( ) {
Common . UI . Menu . Manager . hideAll ( ) ;
me . leftMenu . showMenu ( 'comments' ) ;
var ctrl = SSE . getController ( 'Common.Controllers.Comments' ) ;
ctrl . getView ( ) . showEditContainer ( true ) ;
ctrl . onAfterShow ( ) ;
} ) ;
}
} ,
2016-03-11 00:48:53 +00:00
commentsShowHide : function ( state ) {
if ( this . api ) {
2017-10-04 15:44:01 +00:00
var value = Common . Utils . InternalSettings . get ( "sse-settings-livecomment" ) ,
resolved = Common . Utils . InternalSettings . get ( "sse-settings-resolvedcomment" ) ;
if ( ! value || ! resolved ) {
( state ) ? this . api . asc _showComments ( true ) : ( ( value ) ? this . api . asc _showComments ( resolved ) : this . api . asc _hideComments ( ) ) ;
2016-03-11 00:48:53 +00:00
}
if ( state ) {
this . getApplication ( ) . getController ( 'Common.Controllers.Comments' ) . onAfterShow ( ) ;
}
if ( ! state ) $ ( this . leftMenu . btnComments . el ) . blur ( ) ;
}
} ,
fileShowHide : function ( state ) {
if ( this . api ) {
this . api . asc _closeCellEditor ( ) ;
this . api . asc _enableKeyEvents ( ! state ) ;
}
} ,
aboutShowHide : function ( state ) {
if ( this . api ) {
this . api . asc _closeCellEditor ( ) ;
this . api . asc _enableKeyEvents ( ! state ) ;
if ( ! state ) $ ( this . leftMenu . btnAbout . el ) . blur ( ) ;
2017-08-18 14:08:45 +00:00
if ( ! state && this . leftMenu . _state . pluginIsRunning ) {
this . leftMenu . panelPlugins . show ( ) ;
if ( this . mode . canCoAuthoring ) {
2018-12-17 08:37:43 +00:00
this . mode . canViewComments && this . leftMenu . panelComments [ 'hide' ] ( ) ;
2017-08-18 14:08:45 +00:00
this . mode . canChat && this . leftMenu . panelChat [ 'hide' ] ( ) ;
}
}
2016-03-11 00:48:53 +00:00
}
} ,
2017-05-01 11:30:44 +00:00
menuFilesShowHide : function ( state ) {
2017-08-23 09:09:25 +00:00
if ( this . api ) {
this . api . asc _closeCellEditor ( ) ;
this . api . asc _enableKeyEvents ( ! ( state == 'show' ) ) ;
}
2017-05-01 11:30:44 +00:00
if ( this . dlgSearch ) {
if ( state == 'show' )
this . dlgSearch . suspendKeyEvents ( ) ;
else
2017-06-20 09:53:18 +00:00
Common . Utils . asyncCall ( this . dlgSearch . resumeKeyEvents , this . dlgSearch ) ;
2017-05-01 11:30:44 +00:00
}
} ,
2016-03-11 00:48:53 +00:00
/** coauthoring end **/
onShortcut : function ( s , e ) {
2018-02-06 10:54:40 +00:00
if ( ! this . mode ) return ;
2016-03-11 00:48:53 +00:00
if ( this . mode . isEditDiagram && s != 'escape' ) return false ;
if ( this . mode . isEditMailMerge && s != 'escape' && s != 'search' ) return false ;
switch ( s ) {
case 'replace' :
case 'search' :
if ( ! this . leftMenu . btnSearch . isDisabled ( ) ) {
Common . UI . Menu . Manager . hideAll ( ) ;
this . showSearchDlg ( true , s ) ;
this . leftMenu . btnSearch . toggle ( true , true ) ;
this . leftMenu . btnAbout . toggle ( false ) ;
2017-04-27 15:34:19 +00:00
this . leftMenu . menuFile . hide ( ) ;
2016-03-11 00:48:53 +00:00
}
return false ;
case 'save' :
2017-04-27 15:34:19 +00:00
if ( this . mode . canDownload ) {
2016-03-11 00:48:53 +00:00
if ( this . mode . isDesktopApp && this . mode . isOffline ) {
this . api . asc _DownloadAs ( ) ;
} else {
Common . UI . Menu . Manager . hideAll ( ) ;
this . leftMenu . showMenu ( 'file:saveas' ) ;
}
}
return false ;
case 'help' :
2018-04-19 14:26:42 +00:00
if ( this . mode . isEdit && this . mode . canHelp ) { // TODO: unlock 'help' panel for 'view' mode
2017-08-09 16:59:54 +00:00
Common . UI . Menu . Manager . hideAll ( ) ;
this . api . asc _closeCellEditor ( ) ;
this . leftMenu . showMenu ( 'file:help' ) ;
}
2017-04-27 15:34:19 +00:00
2016-03-11 00:48:53 +00:00
return false ;
case 'file' :
2017-04-27 15:34:19 +00:00
Common . UI . Menu . Manager . hideAll ( ) ;
this . leftMenu . showMenu ( 'file' ) ;
2016-03-11 00:48:53 +00:00
return false ;
case 'escape' :
2017-04-27 15:34:19 +00:00
if ( this . leftMenu . menuFile . isVisible ( ) ) {
2021-07-08 17:20:34 +00:00
if ( Common . UI . HintManager . needCloseFileMenu ( ) )
2021-06-10 20:05:49 +00:00
this . leftMenu . menuFile . hide ( ) ;
2017-04-27 15:34:19 +00:00
return false ;
}
2016-03-11 00:48:53 +00:00
var statusbar = SSE . getController ( 'Statusbar' ) ;
var menu _opened = statusbar . statusbar . $el . find ( '.open > [data-toggle="dropdown"]' ) ;
if ( menu _opened . length ) {
$ . fn . dropdown . Constructor . prototype . keydown . call ( menu _opened [ 0 ] , e ) ;
return false ;
}
2016-07-05 13:23:02 +00:00
if ( this . mode . canPlugins && this . leftMenu . panelPlugins && this . api . isCellEdited !== true ) {
2016-07-05 12:21:26 +00:00
menu _opened = this . leftMenu . panelPlugins . $el . find ( '#menu-plugin-container.open > [data-toggle="dropdown"]' ) ;
if ( menu _opened . length ) {
$ . fn . dropdown . Constructor . prototype . keydown . call ( menu _opened [ 0 ] , e ) ;
return false ;
}
}
2017-04-27 15:34:19 +00:00
if ( this . leftMenu . btnAbout . pressed ||
2016-08-18 14:46:21 +00:00
( $ ( e . target ) . parents ( '#left-menu' ) . length || this . leftMenu . btnPlugins . pressed || this . leftMenu . btnComments . pressed ) && this . api . isCellEdited !== true ) {
2021-07-08 17:20:34 +00:00
if ( ! Common . UI . HintManager . isHintVisible ( ) ) {
this . leftMenu . close ( ) ;
Common . NotificationCenter . trigger ( 'layout:changed' , 'leftmenu' ) ;
}
2016-03-11 00:48:53 +00:00
return false ;
}
if ( this . mode . isEditDiagram || this . mode . isEditMailMerge ) {
menu _opened = $ ( document . body ) . find ( '.open > .dropdown-menu' ) ;
if ( ! this . api . isCellEdited && ! menu _opened . length ) {
Common . Gateway . internalMessage ( 'shortcut' , { key : 'escape' } ) ;
return false ;
}
}
break ;
/** coauthoring begin **/
case 'chat' :
2016-06-30 09:38:54 +00:00
if ( this . mode . canCoAuthoring && this . mode . canChat && ! this . mode . isLightVersion ) {
2016-03-11 00:48:53 +00:00
Common . UI . Menu . Manager . hideAll ( ) ;
this . leftMenu . showMenu ( 'chat' ) ;
}
return false ;
case 'comments' :
2018-12-17 08:37:43 +00:00
if ( this . mode . canCoAuthoring && this . mode . canViewComments && ! this . mode . isLightVersion ) {
2016-03-11 00:48:53 +00:00
Common . UI . Menu . Manager . hideAll ( ) ;
this . leftMenu . showMenu ( 'comments' ) ;
this . getApplication ( ) . getController ( 'Common.Controllers.Comments' ) . onAfterShow ( ) ;
}
return false ;
/** coauthoring end **/
}
} ,
onCellsRange : function ( status ) {
2016-04-05 11:52:34 +00:00
var isRangeSelection = ( status != Asc . c _oAscSelectionDialogType . None ) ;
2016-03-11 00:48:53 +00:00
this . leftMenu . btnAbout . setDisabled ( isRangeSelection ) ;
this . leftMenu . btnSearch . setDisabled ( isRangeSelection ) ;
2019-07-31 10:52:37 +00:00
this . leftMenu . btnSpellcheck . setDisabled ( isRangeSelection ) ;
2016-07-05 14:12:45 +00:00
if ( this . mode . canPlugins && this . leftMenu . panelPlugins ) {
this . leftMenu . panelPlugins . setLocked ( isRangeSelection ) ;
this . leftMenu . panelPlugins . disableControls ( isRangeSelection ) ;
}
2016-03-11 00:48:53 +00:00
} ,
onApiEditCell : function ( state ) {
2016-04-05 11:52:34 +00:00
var isEditFormula = ( state == Asc . c _oAscCellEditorState . editFormula ) ;
2016-03-11 00:48:53 +00:00
this . leftMenu . btnAbout . setDisabled ( isEditFormula ) ;
this . leftMenu . btnSearch . setDisabled ( isEditFormula ) ;
2019-07-31 10:52:37 +00:00
this . leftMenu . btnSpellcheck . setDisabled ( isEditFormula ) ;
2016-07-05 14:12:45 +00:00
if ( this . mode . canPlugins && this . leftMenu . panelPlugins ) {
this . leftMenu . panelPlugins . setLocked ( isEditFormula ) ;
this . leftMenu . panelPlugins . disableControls ( isEditFormula ) ;
}
2016-03-11 00:48:53 +00:00
} ,
2017-08-11 11:01:27 +00:00
onPluginOpen : function ( panel , type , action ) {
2017-09-13 08:57:30 +00:00
if ( type == 'onboard' ) {
if ( action == 'open' ) {
2017-08-18 12:17:25 +00:00
this . leftMenu . close ( ) ;
2017-08-11 11:01:27 +00:00
this . leftMenu . panelPlugins . show ( ) ;
2017-09-13 08:57:30 +00:00
this . leftMenu . onBtnMenuClick ( { pressed : true , options : { action : 'plugins' } } ) ;
2017-08-18 14:08:45 +00:00
this . leftMenu . _state . pluginIsRunning = true ;
2017-08-11 11:01:27 +00:00
} else {
2017-08-18 14:08:45 +00:00
this . leftMenu . _state . pluginIsRunning = false ;
2017-08-11 11:01:27 +00:00
this . leftMenu . close ( ) ;
}
}
} ,
2017-10-12 10:43:23 +00:00
onShowHideChat : function ( state ) {
if ( this . mode . canCoAuthoring && this . mode . canChat && ! this . mode . isLightVersion ) {
if ( state ) {
Common . UI . Menu . Manager . hideAll ( ) ;
this . leftMenu . showMenu ( 'chat' ) ;
} else {
this . leftMenu . btnChat . toggle ( false , true ) ;
this . leftMenu . onBtnMenuClick ( this . leftMenu . btnChat ) ;
}
}
} ,
2021-07-06 22:51:19 +00:00
onMenuChange : function ( value ) {
if ( 'hide' === value ) {
if ( this . leftMenu . btnComments . isActive ( ) && this . api ) {
this . leftMenu . btnComments . toggle ( false ) ;
this . leftMenu . onBtnMenuClick ( this . leftMenu . btnComments ) ;
// focus to sdk
this . api . asc _enableKeyEvents ( true ) ;
2022-02-22 17:17:21 +00:00
} else if ( this . leftMenu . btnSearchBar . isActive ( ) && this . api ) {
this . leftMenu . btnSearchBar . toggle ( false ) ;
this . leftMenu . onBtnMenuClick ( this . leftMenu . btnSearchBar ) ;
2021-07-06 22:51:19 +00:00
}
}
} ,
2021-06-28 17:18:53 +00:00
showHistory : function ( ) {
if ( ! this . mode . wopi ) {
var maincontroller = this . getApplication ( ) . getController ( 'Main' ) ;
if ( ! maincontroller . loadMask )
maincontroller . loadMask = new Common . UI . LoadMask ( { owner : $ ( '#viewport' ) } ) ;
maincontroller . loadMask . setTitle ( this . textLoadHistory ) ;
maincontroller . loadMask . show ( ) ;
}
Common . Gateway . requestHistory ( ) ;
} ,
2021-08-20 14:38:32 +00:00
isCommentsVisible : function ( ) {
return this . leftMenu && this . leftMenu . panelComments && this . leftMenu . panelComments . isVisible ( ) ;
} ,
2016-03-11 00:48:53 +00:00
textNoTextFound : 'Text not found' ,
newDocumentTitle : 'Unnamed document' ,
textItemEntireCell : 'Entire cell contents' ,
requestEditRightsText : 'Requesting editing rights...' ,
warnDownloadAs : 'If you continue saving in this format all features except the text will be lost.<br>Are you sure you want to continue?' ,
textWarning : 'Warning' ,
textSheet : 'Sheet' ,
textWorkbook : 'Workbook' ,
textByColumns : 'By columns' ,
textByRows : 'By rows' ,
textFormulas : 'Formulas' ,
textValues : 'Values' ,
textWithin : 'Within' ,
textSearch : 'Search' ,
2018-09-27 12:25:15 +00:00
textLookin : 'Look in' ,
2021-06-28 17:18:53 +00:00
txtUntitled : 'Untitled' ,
textLoadHistory : 'Loading version history...' ,
leavePageText : 'All unsaved changes in this document will be lost.<br> Click \'Cancel\' then \'Save\' to save them. Click \'OK\' to discard all the unsaved changes.'
2016-03-11 00:48:53 +00:00
} , SSE . Controllers . LeftMenu || { } ) ) ;
} ) ;