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
/ * *
* RightMenu . js
*
* Created by Julia Radzhabova on 1 / 17 / 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' ,
'documenteditor/main/app/view/RightMenu'
] , function ( ) {
'use strict' ;
DE . Controllers . RightMenu = Backbone . Controller . extend ( {
models : [ ] ,
collections : [ ] ,
views : [
'RightMenu'
] ,
initialize : function ( ) {
this . editMode = true ;
2020-11-11 14:46:13 +00:00
this . _initSettings = true ;
2022-09-27 22:01:27 +00:00
this . _state = {
docProtection : {
isReadOnly : false ,
isReviewOnly : false ,
isFormsOnly : false ,
isCommentsOnly : false
}
} ;
2016-03-11 00:48:53 +00:00
this . addListeners ( {
'RightMenu' : {
'rightmenuclick' : this . onRightMenuClick
2022-10-18 13:37:35 +00:00
} ,
'ViewTab' : {
'rightmenu:hide' : _ . bind ( this . onRightMenuHide , this )
2016-03-11 00:48:53 +00:00
}
} ) ;
2020-12-23 10:09:02 +00:00
Common . Utils . InternalSettings . set ( "de-rightpanel-active-form" , 1 ) ;
2016-03-11 00:48:53 +00:00
} ,
onLaunch : function ( ) {
this . rightmenu = this . createView ( 'RightMenu' ) ;
this . rightmenu . on ( 'render:after' , _ . bind ( this . onRightMenuAfterRender , this ) ) ;
} ,
onRightMenuAfterRender : function ( rightMenu ) {
2021-11-02 01:14:57 +00:00
rightMenu . imageSettings . application = rightMenu . shapeSettings . application = rightMenu . textartSettings . application = this . getApplication ( ) ;
2016-03-11 00:48:53 +00:00
this . _settings = [ ] ;
this . _settings [ Common . Utils . documentSettingsType . Paragraph ] = { panelId : "id-paragraph-settings" , panel : rightMenu . paragraphSettings , btn : rightMenu . btnText , hidden : 1 , locked : false } ;
this . _settings [ Common . Utils . documentSettingsType . Table ] = { panelId : "id-table-settings" , panel : rightMenu . tableSettings , btn : rightMenu . btnTable , hidden : 1 , locked : false } ;
this . _settings [ Common . Utils . documentSettingsType . Image ] = { panelId : "id-image-settings" , panel : rightMenu . imageSettings , btn : rightMenu . btnImage , hidden : 1 , locked : false } ;
this . _settings [ Common . Utils . documentSettingsType . Header ] = { panelId : "id-header-settings" , panel : rightMenu . headerSettings , btn : rightMenu . btnHeaderFooter , hidden : 1 , locked : false , needShow : true } ;
this . _settings [ Common . Utils . documentSettingsType . Shape ] = { panelId : "id-shape-settings" , panel : rightMenu . shapeSettings , btn : rightMenu . btnShape , hidden : 1 , locked : false } ;
this . _settings [ Common . Utils . documentSettingsType . TextArt ] = { panelId : "id-textart-settings" , panel : rightMenu . textartSettings , btn : rightMenu . btnTextArt , hidden : 1 , locked : false } ;
this . _settings [ Common . Utils . documentSettingsType . Chart ] = { panelId : "id-chart-settings" , panel : rightMenu . chartSettings , btn : rightMenu . btnChart , hidden : 1 , locked : false } ;
2017-05-24 13:42:04 +00:00
this . _settings [ Common . Utils . documentSettingsType . MailMerge ] = { panelId : "id-mail-merge-settings" , panel : rightMenu . mergeSettings , btn : rightMenu . btnMailMerge , hidden : 1 , props : { } , locked : false } ;
2017-11-15 12:52:37 +00:00
this . _settings [ Common . Utils . documentSettingsType . Signature ] = { panelId : "id-signature-settings" , panel : rightMenu . signatureSettings , btn : rightMenu . btnSignature , hidden : 1 , props : { } , locked : false } ;
2020-09-28 16:06:12 +00:00
this . _settings [ Common . Utils . documentSettingsType . Form ] = { panelId : "id-form-settings" , panel : rightMenu . formSettings , btn : rightMenu . btnForm , hidden : 1 , props : { } , locked : false } ;
2016-03-11 00:48:53 +00:00
} ,
setApi : function ( api ) {
this . api = api ;
2017-11-17 07:39:23 +00:00
this . api . asc _registerCallback ( 'asc_onUpdateSignatures' , _ . bind ( this . onApiUpdateSignatures , this ) ) ;
2022-09-23 12:13:58 +00:00
Common . NotificationCenter . on ( 'protect:doclock' , _ . bind ( this . onChangeProtectDocument , this ) ) ;
2016-03-11 00:48:53 +00:00
this . api . asc _registerCallback ( 'asc_onCoAuthoringDisconnect' , _ . bind ( this . onCoAuthoringDisconnect , this ) ) ;
Common . NotificationCenter . on ( 'api:disconnect' , _ . bind ( this . onCoAuthoringDisconnect , this ) ) ;
} ,
setMode : function ( mode ) {
this . editMode = mode . isEdit ;
} ,
2020-12-23 10:09:02 +00:00
onRightMenuClick : function ( menu , type , minimized , event ) {
2016-03-11 00:48:53 +00:00
if ( ! minimized && this . editMode ) {
2020-12-23 10:09:02 +00:00
if ( event ) { // user click event
if ( ! this . _settings [ Common . Utils . documentSettingsType . Form ] . hidden ) {
if ( type == Common . Utils . documentSettingsType . Form ) {
if ( ! this . _settings [ Common . Utils . documentSettingsType . Paragraph ] . hidden )
Common . Utils . InternalSettings . set ( "de-rightpanel-active-para" , 0 ) ;
if ( ! this . _settings [ Common . Utils . documentSettingsType . Image ] . hidden )
Common . Utils . InternalSettings . set ( "de-rightpanel-active-image" , 0 ) ;
if ( ! this . _settings [ Common . Utils . documentSettingsType . Shape ] . hidden )
Common . Utils . InternalSettings . set ( "de-rightpanel-active-shape" , 0 ) ;
} else if ( type == Common . Utils . documentSettingsType . Paragraph ) {
Common . Utils . InternalSettings . set ( "de-rightpanel-active-para" , 2 ) ;
} else if ( type == Common . Utils . documentSettingsType . Image ) {
Common . Utils . InternalSettings . set ( "de-rightpanel-active-image" , 2 ) ;
Common . Utils . InternalSettings . set ( "de-rightpanel-active-shape" , 0 ) ;
} else if ( type == Common . Utils . documentSettingsType . Shape ) {
Common . Utils . InternalSettings . set ( "de-rightpanel-active-shape" , 2 ) ;
Common . Utils . InternalSettings . set ( "de-rightpanel-active-image" , 0 ) ;
}
}
}
2016-03-11 00:48:53 +00:00
var panel = this . _settings [ type ] . panel ;
var props = this . _settings [ type ] . props ;
if ( props && panel )
2017-05-24 11:55:18 +00:00
panel . ChangeSettings . call ( panel , ( type == Common . Utils . documentSettingsType . MailMerge || type == Common . Utils . documentSettingsType . Signature ) ? undefined : props ) ;
2016-03-11 00:48:53 +00:00
} else if ( minimized && type == Common . Utils . documentSettingsType . MailMerge ) {
this . rightmenu . mergeSettings . disablePreviewMode ( ) ;
}
Common . NotificationCenter . trigger ( 'layout:changed' , 'rightmenu' ) ;
this . rightmenu . fireEvent ( 'editcomplete' , this . rightmenu ) ;
} ,
2022-02-10 16:13:09 +00:00
onApiFocusObject : function ( SelectedObjects ) {
this . onFocusObject ( SelectedObjects ) ;
} ,
2022-02-10 16:28:29 +00:00
onFocusObject : function ( SelectedObjects , forceSignature , forceOpen ) {
2021-08-30 20:12:11 +00:00
if ( ! this . editMode && ! forceSignature )
2016-03-11 00:48:53 +00:00
return ;
2022-02-10 16:28:29 +00:00
var open = this . _initSettings ? ! Common . localStorage . getBool ( "de-hide-right-settings" , this . rightmenu . defaultHideRightMenu ) : ! ! forceOpen ;
2020-11-11 14:46:13 +00:00
this . _initSettings = false ;
2016-03-11 00:48:53 +00:00
var can _add _table = false ,
in _equation = false ,
needhide = true ;
for ( var i = 0 ; i < this . _settings . length ; i ++ ) {
2017-05-24 11:55:18 +00:00
if ( i == Common . Utils . documentSettingsType . MailMerge || i == Common . Utils . documentSettingsType . Signature ) continue ;
2016-03-11 00:48:53 +00:00
if ( this . _settings [ i ] ) {
this . _settings [ i ] . hidden = 1 ;
this . _settings [ i ] . locked = false ;
}
}
this . _settings [ Common . Utils . documentSettingsType . MailMerge ] . locked = false ;
2017-05-24 11:55:18 +00:00
this . _settings [ Common . Utils . documentSettingsType . Signature ] . locked = false ;
2016-03-11 00:48:53 +00:00
2022-03-28 19:45:34 +00:00
var isChart = false ,
2022-09-23 12:13:58 +00:00
isSmartArtInternal = false ,
2022-09-27 22:01:27 +00:00
isProtected = this . _state . docProtection . isReadOnly || this . _state . docProtection . isFormsOnly || this . _state . docProtection . isCommentsOnly ;
2022-09-23 12:13:58 +00:00
2020-10-06 16:25:49 +00:00
var control _props = this . api . asc _IsContentControl ( ) ? this . api . asc _GetContentControlProperties ( ) : null ,
control _lock = false ;
2016-03-11 00:48:53 +00:00
for ( i = 0 ; i < SelectedObjects . length ; i ++ )
{
2019-12-20 13:23:44 +00:00
var content _locked = false ;
2016-03-11 00:48:53 +00:00
var eltype = SelectedObjects [ i ] . get _ObjectType ( ) ,
settingsType = this . getDocumentSettingsType ( eltype ) ;
2016-04-05 11:52:34 +00:00
if ( eltype === Asc . c _oAscTypeSelectElement . Math )
2016-03-11 00:48:53 +00:00
in _equation = true ;
if ( settingsType === undefined || settingsType >= this . _settings . length || this . _settings [ settingsType ] === undefined )
continue ;
var value = SelectedObjects [ i ] . get _ObjectValue ( ) ;
if ( settingsType == Common . Utils . documentSettingsType . Image ) {
2020-09-28 16:52:48 +00:00
var lock _type = ( control _props ) ? control _props . get _Lock ( ) : Asc . c _oAscSdtLockType . Unlocked ;
2019-12-20 13:23:44 +00:00
content _locked = lock _type == Asc . c _oAscSdtLockType . SdtContentLocked || lock _type == Asc . c _oAscSdtLockType . ContentLocked ;
2016-03-11 00:48:53 +00:00
if ( value . get _ChartProperties ( ) !== null ) {
isChart = true ;
settingsType = Common . Utils . documentSettingsType . Chart ;
} else if ( value . get _ShapeProperties ( ) !== null ) {
isChart = value . get _ShapeProperties ( ) . get _FromChart ( ) ;
2022-03-28 19:45:34 +00:00
isSmartArtInternal = value . get _ShapeProperties ( ) . get _FromSmartArtInternal ( ) ;
2016-03-11 00:48:53 +00:00
settingsType = Common . Utils . documentSettingsType . Shape ;
if ( value . get _ShapeProperties ( ) . asc _getTextArtProperties ( ) ) {
this . _settings [ Common . Utils . documentSettingsType . TextArt ] . props = value ;
this . _settings [ Common . Utils . documentSettingsType . TextArt ] . hidden = 0 ;
2022-09-26 15:37:20 +00:00
this . _settings [ Common . Utils . documentSettingsType . TextArt ] . locked = value . get _Locked ( ) || content _locked || isProtected ;
2016-03-11 00:48:53 +00:00
}
}
2020-10-06 16:25:49 +00:00
control _lock = control _lock || value . get _Locked ( ) ;
2016-03-11 00:48:53 +00:00
} else if ( settingsType == Common . Utils . documentSettingsType . Paragraph ) {
this . _settings [ settingsType ] . panel . isChart = isChart ;
2022-03-28 19:45:34 +00:00
this . _settings [ settingsType ] . panel . isSmartArtInternal = isSmartArtInternal ;
2016-03-11 00:48:53 +00:00
can _add _table = value . get _CanAddTable ( ) ;
2020-10-06 16:25:49 +00:00
control _lock = control _lock || value . get _Locked ( ) ;
2016-03-11 00:48:53 +00:00
}
this . _settings [ settingsType ] . props = value ;
this . _settings [ settingsType ] . hidden = 0 ;
2022-09-26 15:37:20 +00:00
this . _settings [ settingsType ] . locked = value . get _Locked ( ) || content _locked || isProtected ;
2016-03-11 00:48:53 +00:00
if ( ! this . _settings [ Common . Utils . documentSettingsType . MailMerge ] . locked ) // lock MailMerge-InsertField, если хотя бы один объект locked
2022-09-26 15:37:20 +00:00
this . _settings [ Common . Utils . documentSettingsType . MailMerge ] . locked = value . get _Locked ( ) || isProtected ;
2017-05-24 13:42:04 +00:00
if ( ! this . _settings [ Common . Utils . documentSettingsType . Signature ] . locked ) // lock Signature, если хотя бы один объект locked
2022-09-26 15:37:20 +00:00
this . _settings [ Common . Utils . documentSettingsType . Signature ] . locked = value . get _Locked ( ) || isProtected ;
2016-03-11 00:48:53 +00:00
}
2021-01-26 21:58:37 +00:00
if ( control _props && control _props . get _FormPr ( ) && this . rightmenu . formSettings ) {
2020-09-30 07:33:38 +00:00
var spectype = control _props . get _SpecificType ( ) ;
2022-10-14 13:38:54 +00:00
if ( spectype == Asc . c _oAscContentControlSpecificType . CheckBox || spectype == Asc . c _oAscContentControlSpecificType . Picture || spectype == Asc . c _oAscContentControlSpecificType . Complex ||
2020-09-30 07:33:38 +00:00
spectype == Asc . c _oAscContentControlSpecificType . ComboBox || spectype == Asc . c _oAscContentControlSpecificType . DropDownList || spectype == Asc . c _oAscContentControlSpecificType . None ) {
settingsType = Common . Utils . documentSettingsType . Form ;
this . _settings [ settingsType ] . props = control _props ;
2022-09-26 15:37:20 +00:00
this . _settings [ settingsType ] . locked = control _lock || isProtected ;
2020-09-30 07:33:38 +00:00
this . _settings [ settingsType ] . hidden = 0 ;
2021-11-13 10:56:35 +00:00
if ( control _props . get _FormPr ( ) . get _Fixed ( ) )
this . _settings [ Common . Utils . documentSettingsType . TextArt ] . hidden = 1 ;
2020-09-30 07:33:38 +00:00
}
2020-09-28 16:52:48 +00:00
}
2016-03-11 00:48:53 +00:00
if ( this . _settings [ Common . Utils . documentSettingsType . Header ] . locked ) { // если находимся в locked header/footer, то считаем, что все элементы в нем тоже недоступны
for ( i = 0 ; i < this . _settings . length ; i ++ ) {
if ( this . _settings [ i ] )
this . _settings [ i ] . locked = true ;
}
}
if ( ! this . _settings [ Common . Utils . documentSettingsType . MailMerge ] . locked ) { // disable MailMerge-InsertField when disable btnInsertTable
this . _settings [ Common . Utils . documentSettingsType . MailMerge ] . locked = ! can _add _table || in _equation ;
}
2016-10-18 08:26:16 +00:00
var lastactive = - 1 , currentactive , priorityactive = - 1 ,
activePane = this . rightmenu . GetActivePane ( ) ;
2016-03-11 00:48:53 +00:00
for ( i = 0 ; i < this . _settings . length ; i ++ ) {
var pnl = this . _settings [ i ] ;
if ( pnl === undefined || pnl . btn === undefined || pnl . panel === undefined ) continue ;
if ( pnl . hidden ) {
if ( ! pnl . btn . isDisabled ( ) ) pnl . btn . setDisabled ( true ) ;
2016-10-18 08:26:16 +00:00
if ( activePane == pnl . panelId )
2016-03-11 00:48:53 +00:00
currentactive = - 1 ;
} else {
if ( pnl . btn . isDisabled ( ) ) pnl . btn . setDisabled ( false ) ;
2017-05-24 11:55:18 +00:00
if ( i != Common . Utils . documentSettingsType . MailMerge && i != Common . Utils . documentSettingsType . Signature ) lastactive = i ;
2016-03-11 00:48:53 +00:00
if ( pnl . needShow ) {
pnl . needShow = false ;
priorityactive = i ;
2016-10-18 08:26:16 +00:00
} else if ( activePane == pnl . panelId )
2016-03-11 00:48:53 +00:00
currentactive = i ;
pnl . panel . setLocked ( pnl . locked ) ;
}
}
if ( ! this . _settings [ Common . Utils . documentSettingsType . MailMerge ] . hidden )
this . _settings [ Common . Utils . documentSettingsType . MailMerge ] . panel . setLocked ( this . _settings [ Common . Utils . documentSettingsType . MailMerge ] . locked ) ;
2016-03-30 08:51:07 +00:00
if ( ! this . rightmenu . minimizedMode || open ) {
2016-03-11 00:48:53 +00:00
var active ;
2020-12-23 10:09:02 +00:00
if ( priorityactive < 0 && ! this . _settings [ Common . Utils . documentSettingsType . Form ] . hidden &&
( ! this . _settings [ Common . Utils . documentSettingsType . Paragraph ] . hidden || ! this . _settings [ Common . Utils . documentSettingsType . Image ] . hidden
|| ! this . _settings [ Common . Utils . documentSettingsType . Shape ] . hidden ) ) {
var imageactive = Common . Utils . InternalSettings . get ( "de-rightpanel-active-image" ) || 0 ,
shapeactive = Common . Utils . InternalSettings . get ( "de-rightpanel-active-shape" ) || 0 ,
paraactive = Common . Utils . InternalSettings . get ( "de-rightpanel-active-para" ) || 0 ,
formactive = Common . Utils . InternalSettings . get ( "de-rightpanel-active-form" ) || 0 ;
if ( ! this . _settings [ Common . Utils . documentSettingsType . Paragraph ] . hidden ) {
priorityactive = ( formactive > paraactive ) ? Common . Utils . documentSettingsType . Form : Common . Utils . documentSettingsType . Paragraph ;
} else if ( ! this . _settings [ Common . Utils . documentSettingsType . Paragraph ] . Image || ! this . _settings [ Common . Utils . documentSettingsType . Shape ] . hidden ) {
if ( formactive > shapeactive && formactive > imageactive )
priorityactive = Common . Utils . documentSettingsType . Form ;
else if ( shapeactive > formactive && shapeactive > imageactive )
priorityactive = Common . Utils . documentSettingsType . Shape ;
else
priorityactive = Common . Utils . documentSettingsType . Image ;
}
}
2016-03-11 00:48:53 +00:00
if ( priorityactive > - 1 ) active = priorityactive ;
else if ( lastactive >= 0 && currentactive < 0 ) active = lastactive ;
else if ( currentactive >= 0 ) active = currentactive ;
2021-08-30 20:12:11 +00:00
else if ( forceSignature && ! this . _settings [ Common . Utils . documentSettingsType . Signature ] . hidden ) active = Common . Utils . documentSettingsType . Signature ;
2016-03-11 00:48:53 +00:00
else if ( ! this . _settings [ Common . Utils . documentSettingsType . MailMerge ] . hidden ) active = Common . Utils . documentSettingsType . MailMerge ;
2016-03-30 08:51:07 +00:00
if ( active == undefined && open && lastactive >= 0 )
active = lastactive ;
2016-03-11 00:48:53 +00:00
if ( active !== undefined ) {
2016-03-30 08:51:07 +00:00
this . rightmenu . SetActivePane ( active , open ) ;
2017-05-24 13:42:04 +00:00
if ( active != Common . Utils . documentSettingsType . MailMerge && active != Common . Utils . documentSettingsType . Signature )
2016-03-11 00:48:53 +00:00
this . _settings [ active ] . panel . ChangeSettings . call ( this . _settings [ active ] . panel , this . _settings [ active ] . props ) ;
else
this . _settings [ active ] . panel . ChangeSettings . call ( this . _settings [ active ] . panel ) ;
}
}
this . _settings [ Common . Utils . documentSettingsType . Image ] . needShow = false ;
this . _settings [ Common . Utils . documentSettingsType . Chart ] . needShow = false ;
} ,
onCoAuthoringDisconnect : function ( ) {
this . SetDisabled ( true , false ) ;
} ,
onInsertTable : function ( ) {
this . _settings [ Common . Utils . documentSettingsType . Table ] . needShow = true ;
} ,
onInsertImage : function ( ) {
this . _settings [ Common . Utils . documentSettingsType . Image ] . needShow = true ;
} ,
onInsertChart : function ( ) {
this . _settings [ Common . Utils . documentSettingsType . Chart ] . needShow = true ;
} ,
onInsertShape : function ( ) {
this . _settings [ Common . Utils . documentSettingsType . Shape ] . needShow = true ;
} ,
onInsertTextArt : function ( ) {
this . _settings [ Common . Utils . documentSettingsType . TextArt ] . needShow = true ;
} ,
2020-09-30 15:52:11 +00:00
onInsertControl : function ( ) {
if ( this . _settings [ Common . Utils . documentSettingsType . Form ] )
this . _settings [ Common . Utils . documentSettingsType . Form ] . needShow = true ;
} ,
2016-03-11 00:48:53 +00:00
UpdateThemeColors : function ( ) {
this . rightmenu . paragraphSettings . UpdateThemeColors ( ) ;
this . rightmenu . tableSettings . UpdateThemeColors ( ) ;
this . rightmenu . shapeSettings . UpdateThemeColors ( ) ;
this . rightmenu . textartSettings . UpdateThemeColors ( ) ;
2021-09-06 21:04:52 +00:00
this . rightmenu . formSettings && this . rightmenu . formSettings . UpdateThemeColors ( ) ;
2016-03-11 00:48:53 +00:00
} ,
updateMetricUnit : function ( ) {
this . rightmenu . headerSettings . updateMetricUnit ( ) ;
this . rightmenu . paragraphSettings . updateMetricUnit ( ) ;
this . rightmenu . chartSettings . updateMetricUnit ( ) ;
this . rightmenu . imageSettings . updateMetricUnit ( ) ;
2018-01-18 14:26:31 +00:00
this . rightmenu . tableSettings . updateMetricUnit ( ) ;
2020-09-28 16:06:12 +00:00
this . rightmenu . formSettings && this . rightmenu . formSettings . updateMetricUnit ( ) ;
2016-03-11 00:48:53 +00:00
} ,
createDelayedElements : function ( ) {
var me = this ;
if ( this . api ) {
2022-02-10 16:13:09 +00:00
this . api . asc _registerCallback ( 'asc_onFocusObject' , _ . bind ( this . onApiFocusObject , this ) ) ;
2016-03-11 00:48:53 +00:00
this . api . asc _registerCallback ( 'asc_doubleClickOnObject' , _ . bind ( this . onDoubleClickOnObject , this ) ) ;
if ( this . rightmenu . mergeSettings ) {
this . rightmenu . mergeSettings . setDocumentName ( this . getApplication ( ) . getController ( 'Viewport' ) . getView ( 'Common.Views.Header' ) . getDocumentCaption ( ) ) ;
this . api . asc _registerCallback ( 'asc_onStartMailMerge' , _ . bind ( this . onStartMailMerge , this ) ) ;
}
this . api . asc _registerCallback ( 'asc_onError' , _ . bind ( this . onError , this ) ) ;
}
if ( this . editMode && this . api ) {
2019-08-22 08:57:33 +00:00
// this.rightmenu.shapeSettings.createDelayedElements();
2016-03-11 00:48:53 +00:00
var selectedElements = this . api . getSelectedElements ( ) ;
2016-03-30 08:51:07 +00:00
if ( selectedElements . length > 0 ) {
2020-11-11 14:46:13 +00:00
this . onFocusObject ( selectedElements ) ;
2016-03-30 08:51:07 +00:00
}
2016-03-11 00:48:53 +00:00
}
2022-09-26 15:37:20 +00:00
this . onChangeProtectDocument ( ) ;
2016-03-11 00:48:53 +00:00
} ,
onDoubleClickOnObject : function ( obj ) {
if ( ! this . editMode ) return ;
var eltype = obj . get _ObjectType ( ) ,
settingsType = this . getDocumentSettingsType ( eltype ) ;
if ( settingsType === undefined || settingsType >= this . _settings . length || this . _settings [ settingsType ] === undefined )
return ;
var value = obj . get _ObjectValue ( ) ;
if ( settingsType == Common . Utils . documentSettingsType . Image ) {
if ( value . get _ChartProperties ( ) !== null ) {
settingsType = Common . Utils . documentSettingsType . Chart ;
} else if ( value . get _ShapeProperties ( ) !== null ) {
settingsType = Common . Utils . documentSettingsType . Shape ;
}
}
if ( settingsType !== Common . Utils . documentSettingsType . Paragraph ) {
this . rightmenu . SetActivePane ( settingsType , true ) ;
this . _settings [ settingsType ] . panel . ChangeSettings . call ( this . _settings [ settingsType ] . panel , this . _settings [ settingsType ] . props ) ;
}
} ,
onStartMailMerge : function ( ) {
var type = Common . Utils . documentSettingsType . MailMerge ;
this . _settings [ type ] . hidden = 0 ;
this . _settings [ type ] . btn . setDisabled ( false ) ;
this . rightmenu . SetActivePane ( type , true ) ;
2016-08-17 11:55:28 +00:00
this . _settings [ type ] . panel . setLocked ( this . _settings [ type ] . locked ) ;
2016-03-11 00:48:53 +00:00
this . _settings [ type ] . panel . ChangeSettings . call ( this . _settings [ type ] . panel ) ;
} ,
onError : function ( id , level , errData ) {
2016-04-05 11:52:34 +00:00
if ( id == Asc . c _oAscError . ID . MailMergeLoadFile ) {
2016-03-11 00:48:53 +00:00
this . _settings [ Common . Utils . documentSettingsType . MailMerge ] . hidden = 1 ;
this . _settings [ Common . Utils . documentSettingsType . MailMerge ] . btn . setDisabled ( true ) ;
var selectedElements = this . api . getSelectedElements ( ) ;
if ( selectedElements . length > 0 )
this . onFocusObject ( selectedElements ) ;
}
} ,
2017-11-15 12:52:37 +00:00
onApiUpdateSignatures : function ( valid , requested ) {
2017-11-17 07:39:23 +00:00
if ( ! this . rightmenu . signatureSettings ) return ;
2017-11-15 12:52:37 +00:00
var disabled = ( ! valid || valid . length < 1 ) && ( ! requested || requested . length < 1 ) ,
type = Common . Utils . documentSettingsType . Signature ;
this . _settings [ type ] . hidden = disabled ? 1 : 0 ;
this . _settings [ type ] . btn . setDisabled ( disabled ) ;
this . _settings [ type ] . panel . setLocked ( this . _settings [ type ] . locked ) ;
} ,
2017-11-08 14:52:03 +00:00
SetDisabled : function ( disabled , allowMerge , allowSignature ) {
2016-03-11 00:48:53 +00:00
this . setMode ( { isEdit : ! disabled } ) ;
2020-11-09 11:52:21 +00:00
if ( this . rightmenu && this . rightmenu . paragraphSettings ) {
2016-03-11 00:48:53 +00:00
this . rightmenu . paragraphSettings . disableControls ( disabled ) ;
this . rightmenu . shapeSettings . disableControls ( disabled ) ;
this . rightmenu . textartSettings . disableControls ( disabled ) ;
this . rightmenu . headerSettings . disableControls ( disabled ) ;
this . rightmenu . tableSettings . disableControls ( disabled ) ;
this . rightmenu . imageSettings . disableControls ( disabled ) ;
2020-09-28 16:06:12 +00:00
this . rightmenu . formSettings && this . rightmenu . formSettings . disableControls ( disabled ) ;
2016-03-11 00:48:53 +00:00
if ( ! allowMerge && this . rightmenu . mergeSettings ) {
this . rightmenu . mergeSettings . disableControls ( disabled ) ;
disabled && this . rightmenu . btnMailMerge . setDisabled ( disabled ) ;
}
this . rightmenu . chartSettings . disableControls ( disabled ) ;
2021-08-30 20:12:11 +00:00
if ( this . rightmenu . signatureSettings ) {
! allowSignature && this . rightmenu . btnSignature . setDisabled ( disabled ) ;
allowSignature && disabled && this . onFocusObject ( [ ] , true ) ; // force press signature button
2017-05-24 11:55:18 +00:00
}
2016-03-11 00:48:53 +00:00
if ( disabled ) {
this . rightmenu . btnText . setDisabled ( disabled ) ;
this . rightmenu . btnTable . setDisabled ( disabled ) ;
this . rightmenu . btnImage . setDisabled ( disabled ) ;
this . rightmenu . btnHeaderFooter . setDisabled ( disabled ) ;
this . rightmenu . btnShape . setDisabled ( disabled ) ;
this . rightmenu . btnTextArt . setDisabled ( disabled ) ;
this . rightmenu . btnChart . setDisabled ( disabled ) ;
2020-09-28 16:06:12 +00:00
this . rightmenu . btnForm && this . rightmenu . btnForm . setDisabled ( disabled ) ;
2016-03-11 00:48:53 +00:00
} else {
var selectedElements = this . api . getSelectedElements ( ) ;
if ( selectedElements . length > 0 )
2022-02-10 16:28:29 +00:00
this . onFocusObject ( selectedElements , false , ! Common . Utils . InternalSettings . get ( "de-hide-right-settings" ) ) ;
2016-03-11 00:48:53 +00:00
}
}
} ,
getDocumentSettingsType : function ( type ) {
switch ( type ) {
2016-04-05 11:52:34 +00:00
case Asc . c _oAscTypeSelectElement . Paragraph :
2016-03-11 00:48:53 +00:00
return Common . Utils . documentSettingsType . Paragraph ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscTypeSelectElement . Table :
2016-03-11 00:48:53 +00:00
return Common . Utils . documentSettingsType . Table ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscTypeSelectElement . Image :
2016-03-11 00:48:53 +00:00
return Common . Utils . documentSettingsType . Image ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscTypeSelectElement . Header :
2016-03-11 00:48:53 +00:00
return Common . Utils . documentSettingsType . Header ;
}
2022-09-23 12:13:58 +00:00
} ,
2022-09-27 22:01:27 +00:00
onChangeProtectDocument : function ( props ) {
if ( ! props ) {
var docprotect = this . getApplication ( ) . getController ( 'DocProtection' ) ;
props = docprotect ? docprotect . getDocProps ( ) : null ;
2022-09-23 12:13:58 +00:00
}
2022-09-27 22:01:27 +00:00
if ( props ) {
this . _state . docProtection = props ;
if ( this . api ) {
var selectedElements = this . api . getSelectedElements ( ) ;
if ( selectedElements . length > 0 )
this . onFocusObject ( selectedElements ) ;
}
2022-09-23 12:13:58 +00:00
}
2022-10-18 13:37:35 +00:00
} ,
onRightMenuHide : function ( view , status ) {
if ( this . rightmenu ) {
! status && this . rightmenu . clearSelection ( ) ;
status ? this . rightmenu . show ( ) : this . rightmenu . hide ( ) ;
Common . localStorage . setBool ( 'de-hidden-rightmenu' , ! status ) ;
}
Common . NotificationCenter . trigger ( 'layout:changed' , 'main' ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . rightmenu ) ;
2016-03-11 00:48:53 +00:00
}
} ) ;
} ) ;