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
/ * *
* ReviewChanges . js
*
* Created by Julia . Radzhabova on 05.08 . 15
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
*
* /
if ( Common === undefined )
var Common = { } ;
Common . Controllers = Common . Controllers || { } ;
define ( [
'core' ,
'common/main/lib/model/ReviewChange' ,
'common/main/lib/collection/ReviewChanges' ,
2017-04-26 08:34:55 +00:00
'common/main/lib/view/ReviewChanges' ,
2018-06-07 14:09:54 +00:00
'common/main/lib/view/ReviewPopover' ,
2020-10-15 12:37:48 +00:00
'common/main/lib/view/LanguageDialog' ,
'common/main/lib/view/OptionsDialog'
2016-03-11 00:48:53 +00:00
] , function ( ) {
'use strict' ;
Common . Controllers . ReviewChanges = Backbone . Controller . extend ( _ . extend ( {
models : [ ] ,
collections : [
'Common.Collections.ReviewChanges'
] ,
views : [
'Common.Views.ReviewChanges' ,
2018-06-07 14:09:54 +00:00
'Common.Views.ReviewPopover'
2016-03-11 00:48:53 +00:00
] ,
sdkViewName : '#id_main' ,
initialize : function ( ) {
this . addListeners ( {
2017-04-04 15:22:02 +00:00
'FileMenu' : {
'settings:apply' : this . applySettings . bind ( this )
} ,
2019-10-29 14:08:47 +00:00
'LeftMenu' : {
'comments:show' : _ . bind ( this . commentsShowHide , this , 'show' ) ,
'comments:hide' : _ . bind ( this . commentsShowHide , this , 'hide' )
} ,
2016-03-11 00:48:53 +00:00
'Common.Views.ReviewChanges' : {
'reviewchange:accept' : _ . bind ( this . onAcceptClick , this ) ,
'reviewchange:reject' : _ . bind ( this . onRejectClick , this ) ,
2017-02-27 12:04:18 +00:00
'reviewchange:delete' : _ . bind ( this . onDeleteClick , this ) ,
2017-04-04 15:22:02 +00:00
'reviewchange:preview' : _ . bind ( this . onBtnPreviewClick , this ) ,
2019-08-13 14:40:52 +00:00
'reviewchange:view' : _ . bind ( this . onReviewViewClick , this ) ,
'reviewchange:compare' : _ . bind ( this . onCompareClick , this ) ,
2017-10-07 13:06:51 +00:00
'lang:document' : _ . bind ( this . onDocLanguage , this ) ,
'collaboration:coauthmode' : _ . bind ( this . onCoAuthMode , this )
2017-06-09 14:30:52 +00:00
} ,
'Common.Views.ReviewChangesDialog' : {
'reviewchange:accept' : _ . bind ( this . onAcceptClick , this ) ,
'reviewchange:reject' : _ . bind ( this . onRejectClick , this ) ,
'reviewchange:preview' : _ . bind ( this . onBtnPreviewClick , this )
2018-06-07 14:09:54 +00:00
} ,
'Common.Views.ReviewPopover' : {
'reviewchange:accept' : _ . bind ( this . onAcceptClick , this ) ,
'reviewchange:reject' : _ . bind ( this . onRejectClick , this ) ,
2019-04-12 14:55:08 +00:00
'reviewchange:delete' : _ . bind ( this . onDeleteClick , this ) ,
'reviewchange:goto' : _ . bind ( this . onGotoClick , this )
2016-03-11 00:48:53 +00:00
}
} ) ;
} ,
onLaunch : function ( ) {
this . collection = this . getApplication ( ) . getCollection ( 'Common.Collections.ReviewChanges' ) ;
this . userCollection = this . getApplication ( ) . getCollection ( 'Common.Collections.Users' ) ;
2021-12-29 22:01:53 +00:00
this . viewmode = false ;
2016-03-11 00:48:53 +00:00
2021-09-08 15:45:12 +00:00
this . _state = { posx : - 1000 , posy : - 1000 , popoverVisible : false , previewMode : false , compareSettings : null , wsLock : false , wsProps : [ ] } ;
2017-03-29 11:19:57 +00:00
Common . NotificationCenter . on ( 'reviewchanges:turn' , this . onTurnPreview . bind ( this ) ) ;
2017-04-04 15:22:02 +00:00
Common . NotificationCenter . on ( 'spelling:turn' , this . onTurnSpelling . bind ( this ) ) ;
2017-03-29 11:19:57 +00:00
Common . NotificationCenter . on ( 'app:ready' , this . onAppReady . bind ( this ) ) ;
2017-11-23 13:29:05 +00:00
Common . NotificationCenter . on ( 'api:disconnect' , _ . bind ( this . onCoAuthoringDisconnect , this ) ) ;
2019-10-09 10:23:40 +00:00
Common . NotificationCenter . on ( 'collaboration:sharing' , this . changeAccessRights . bind ( this ) ) ;
Common . NotificationCenter . on ( 'collaboration:sharingdeny' , this . onLostEditRights . bind ( this ) ) ;
2021-08-20 14:38:32 +00:00
Common . NotificationCenter . on ( 'protect:wslock' , _ . bind ( this . onChangeProtectSheet , this ) ) ;
2018-06-04 11:45:22 +00:00
this . userCollection . on ( 'reset' , _ . bind ( this . onUpdateUsers , this ) ) ;
this . userCollection . on ( 'add' , _ . bind ( this . onUpdateUsers , this ) ) ;
2016-03-11 00:48:53 +00:00
} ,
setConfig : function ( data , api ) {
this . setApi ( api ) ;
if ( data ) {
2019-04-26 14:10:34 +00:00
this . currentUserId = data . config . user . id ;
2016-03-11 00:48:53 +00:00
this . sdkViewName = data [ 'sdkviewname' ] || this . sdkViewName ;
}
2019-10-09 10:23:40 +00:00
return this ;
2016-03-11 00:48:53 +00:00
} ,
setApi : function ( api ) {
if ( api ) {
this . api = api ;
2018-12-18 14:27:19 +00:00
if ( this . appConfig . canReview || this . appConfig . canViewReview ) {
2017-06-15 13:35:55 +00:00
this . api . asc _registerCallback ( 'asc_onShowRevisionsChange' , _ . bind ( this . onApiShowChange , this ) ) ;
this . api . asc _registerCallback ( 'asc_onUpdateRevisionsChangesPosition' , _ . bind ( this . onApiUpdateChangePosition , this ) ) ;
2019-11-14 10:25:01 +00:00
this . api . asc _registerCallback ( 'asc_onAuthParticipantsChanged' , _ . bind ( this . onAuthParticipantsChanged , this ) ) ;
this . api . asc _registerCallback ( 'asc_onParticipantsChanged' , _ . bind ( this . onAuthParticipantsChanged , this ) ) ;
2021-08-10 16:32:12 +00:00
this . api . asc _registerCallback ( 'asc_onChangeDisplayModeInReview' , _ . bind ( this . onChangeDisplayModeInReview , this ) ) ;
2017-06-15 13:35:55 +00:00
}
2021-04-23 22:30:36 +00:00
if ( this . appConfig . canReview )
2021-02-10 10:09:21 +00:00
this . api . asc _registerCallback ( 'asc_onOnTrackRevisionsChange' , _ . bind ( this . onApiTrackRevisionsChange , this ) ) ;
2019-10-09 14:33:29 +00:00
this . api . asc _registerCallback ( 'asc_onAcceptChangesBeforeCompare' , _ . bind ( this . onAcceptChangesBeforeCompare , this ) ) ;
2017-11-23 13:29:05 +00:00
this . api . asc _registerCallback ( 'asc_onCoAuthoringDisconnect' , _ . bind ( this . onCoAuthoringDisconnect , this ) ) ;
2019-10-11 12:12:59 +00:00
2019-10-15 08:44:38 +00:00
Common . Gateway . on ( 'setrevisedfile' , _ . bind ( this . setRevisedFile , this ) ) ;
2016-03-11 00:48:53 +00:00
}
} ,
setMode : function ( mode ) {
2017-04-05 09:11:15 +00:00
this . appConfig = mode ;
2017-06-15 13:35:55 +00:00
this . popoverChanges = new Common . Collections . ReviewChanges ( ) ;
2018-06-07 14:09:54 +00:00
this . view = this . createView ( 'Common.Views.ReviewChanges' , { mode : mode } ) ;
2017-04-05 09:11:15 +00:00
2019-11-28 13:54:14 +00:00
if ( ! ! this . appConfig . sharingSettingsUrl && this . appConfig . sharingSettingsUrl . length || this . appConfig . canRequestSharingSettings ) {
Common . Gateway . on ( 'showsharingsettings' , _ . bind ( this . changeAccessRights , this ) ) ;
Common . Gateway . on ( 'setsharingsettings' , _ . bind ( this . setSharingSettings , this ) ) ;
}
2019-10-09 10:23:40 +00:00
2016-03-11 00:48:53 +00:00
return this ;
} ,
2019-10-09 10:23:40 +00:00
loadDocument : function ( data ) {
this . document = data . doc ;
} ,
2021-12-30 11:49:19 +00:00
SetDisabled : function ( state , reviewMode , fillFormMode ) {
2017-06-15 13:35:55 +00:00
if ( this . dlgChanges )
this . dlgChanges . close ( ) ;
2021-12-29 22:01:53 +00:00
if ( reviewMode )
this . lockToolbar ( Common . enumLock . previewReviewMode , state ) ;
2021-12-30 11:49:19 +00:00
else if ( fillFormMode )
this . lockToolbar ( Common . enumLock . viewFormMode , state ) ;
2021-12-29 22:01:53 +00:00
else
this . lockToolbar ( Common . enumLock . viewMode , state ) ;
2019-02-04 13:43:25 +00:00
this . setPreviewMode ( state ) ;
} ,
2021-12-29 22:01:53 +00:00
lockToolbar : function ( causes , lock , opts ) {
Common . Utils . lockControls ( causes , lock , opts , this . view . getButtons ( ) ) ;
} ,
2019-02-04 13:43:25 +00:00
setPreviewMode : function ( mode ) { //disable accept/reject in popover
if ( this . viewmode === mode ) return ;
this . viewmode = mode ;
if ( mode )
this . prevcanReview = this . appConfig . canReview ;
this . appConfig . canReview = ( mode ) ? false : this . prevcanReview ;
var me = this ;
this . popoverChanges && this . popoverChanges . each ( function ( model ) {
model . set ( 'hint' , ! me . appConfig . canReview ) ;
} ) ;
2017-06-15 13:35:55 +00:00
} ,
2022-01-20 21:11:12 +00:00
isSelectedChangesLocked : function ( changes , isShow ) {
2022-01-18 18:44:27 +00:00
if ( ! changes || changes . length < 1 ) return true ;
2022-01-20 21:11:12 +00:00
if ( isShow )
2022-01-18 18:44:27 +00:00
return changes [ 0 ] . get ( 'lock' ) || ! changes [ 0 ] . get ( 'editable' ) ;
for ( var i = 0 ; i < changes . length ; i ++ ) {
var change = changes [ i ] ;
if ( change . get ( 'lock' ) || ! change . get ( 'editable' ) )
return true ; // lock button if at least one change is locked
}
return false ;
} ,
2022-01-20 21:11:12 +00:00
onApiShowChange : function ( sdkchange , isShow ) {
2022-01-18 18:44:27 +00:00
var btnlock = true ,
changes ;
if ( this . appConfig . canReview && ! this . appConfig . isReviewOnly ) {
if ( sdkchange && sdkchange . length > 0 ) {
changes = this . readSDKChange ( sdkchange ) ;
2022-01-20 21:11:12 +00:00
btnlock = this . isSelectedChangesLocked ( changes , isShow ) ;
2022-01-18 18:44:27 +00:00
}
if ( this . _state . lock !== btnlock ) {
2022-03-05 10:05:49 +00:00
Common . Utils . lockControls ( Common . enumLock . reviewChangelock , btnlock , { array : [ this . view . btnAccept , this . view . btnReject ] } ) ;
2022-01-18 18:44:27 +00:00
if ( this . dlgChanges ) {
this . dlgChanges . btnAccept . setDisabled ( btnlock ) ;
this . dlgChanges . btnReject . setDisabled ( btnlock ) ;
}
this . _state . lock = btnlock ;
Common . Utils . InternalSettings . set ( this . view . appPrefix + "accept-reject-lock" , btnlock ) ;
}
}
2016-03-11 00:48:53 +00:00
if ( this . getPopover ( ) ) {
2022-01-20 21:11:12 +00:00
if ( ! this . appConfig . reviewHoverMode && sdkchange && sdkchange . length > 0 && isShow ) { // show changes balloon only for current position, not selection
2016-03-11 00:48:53 +00:00
var i = 0 ,
posX = sdkchange [ 0 ] . get _X ( ) ,
posY = sdkchange [ 0 ] . get _Y ( ) ,
2017-08-10 10:07:18 +00:00
animate = ( Math . abs ( this . _state . posx - posX ) > 0.001 || Math . abs ( this . _state . posy - posY ) > 0.001 ) || ( sdkchange . length !== this . _state . changes _length ) ,
2016-03-11 00:48:53 +00:00
lock = ( sdkchange [ 0 ] . get _LockUserId ( ) !== null ) ,
2022-01-18 18:44:27 +00:00
lockUser = this . getUserName ( sdkchange [ 0 ] . get _LockUserId ( ) ) ;
2016-03-11 00:48:53 +00:00
2019-05-16 11:17:18 +00:00
this . getPopover ( ) . hideTips ( ) ;
2022-01-18 18:44:27 +00:00
this . popoverChanges . reset ( changes || this . readSDKChange ( sdkchange ) ) ;
2016-03-11 00:48:53 +00:00
if ( animate ) {
if ( this . getPopover ( ) . isVisible ( ) ) this . getPopover ( ) . hide ( ) ;
2018-06-07 14:09:54 +00:00
this . getPopover ( ) . setLeftTop ( posX , posY ) ;
2016-03-11 00:48:53 +00:00
}
2018-06-07 14:09:54 +00:00
this . getPopover ( ) . showReview ( animate , lock , lockUser ) ;
2016-03-11 00:48:53 +00:00
this . _state . posx = posX ;
this . _state . posy = posY ;
2017-08-10 10:07:18 +00:00
this . _state . changes _length = sdkchange . length ;
2016-03-11 00:48:53 +00:00
this . _state . popoverVisible = true ;
} else if ( this . _state . popoverVisible ) {
this . _state . posx = this . _state . posy = - 1000 ;
2017-08-10 10:07:18 +00:00
this . _state . changes _length = 0 ;
2016-03-11 00:48:53 +00:00
this . _state . popoverVisible = false ;
2019-04-16 10:13:49 +00:00
this . getPopover ( ) . hideTips ( ) ;
2016-03-11 00:48:53 +00:00
this . popoverChanges . reset ( ) ;
2018-06-07 14:09:54 +00:00
this . getPopover ( ) . hideReview ( ) ;
2016-03-11 00:48:53 +00:00
}
}
} ,
onApiUpdateChangePosition : function ( posX , posY ) {
var i , useAnimation = false ,
change = null ,
text = undefined ,
saveTxtId = '' ,
saveTxtReplyId = '' ;
if ( this . getPopover ( ) ) {
if ( posY < 0 || this . getPopover ( ) . sdkBounds . height < posY ) {
this . getPopover ( ) . hide ( ) ;
} else if ( this . popoverChanges . length > 0 ) {
if ( ! this . getPopover ( ) . isVisible ( ) )
this . getPopover ( ) . show ( false ) ;
2018-06-07 14:09:54 +00:00
this . getPopover ( ) . setLeftTop ( posX , posY ) ;
2016-03-11 00:48:53 +00:00
}
}
} ,
findChange : function ( uid , id ) {
if ( _ . isUndefined ( uid ) ) {
return this . collection . findWhere ( { id : id } ) ;
}
return this . collection . findWhere ( { uid : uid } ) ;
} ,
getPopover : function ( ) {
2018-12-18 14:27:19 +00:00
if ( ( this . appConfig . canReview || this . appConfig . canViewReview ) && _ . isUndefined ( this . popover ) ) {
2018-06-07 14:09:54 +00:00
this . popover = Common . Views . ReviewPopover . prototype . getPopover ( {
reviewStore : this . popoverChanges ,
2021-08-13 11:32:32 +00:00
renderTo : this . sdkViewName ,
2022-05-11 11:37:44 +00:00
canRequestUsers : ( this . appConfig ) ? this . appConfig . canRequestUsers : undefined ,
canRequestSendNotify : ( this . appConfig ) ? this . appConfig . canRequestSendNotify : undefined ,
mentionShare : ( this . appConfig ) ? this . appConfig . mentionShare : true ,
2021-08-13 11:32:32 +00:00
api : this . api
2018-06-07 14:09:54 +00:00
} ) ;
this . popover . setReviewStore ( this . popoverChanges ) ;
}
return this . popover ;
2016-03-11 00:48:53 +00:00
} ,
// helpers
readSDKChange : function ( data ) {
var me = this , arr = [ ] ;
_ . each ( data , function ( item ) {
var changetext = '' , proptext = '' ,
value = item . get _Value ( ) ,
2019-04-12 14:55:08 +00:00
movetype = item . get _MoveType ( ) ,
2016-03-11 00:48:53 +00:00
settings = false ;
switch ( item . get _Type ( ) ) {
2016-04-05 11:52:34 +00:00
case Asc . c _oAscRevisionsChangeType . TextAdd :
2019-04-12 14:55:08 +00:00
changetext = ( movetype == Asc . c _oAscRevisionsMove . NoMove ) ? me . textInserted : me . textParaMoveTo ;
2016-03-11 00:48:53 +00:00
if ( typeof value == 'object' ) {
_ . each ( value , function ( obj ) {
if ( typeof obj === 'string' )
2016-09-15 13:29:34 +00:00
changetext += ( ' ' + Common . Utils . String . htmlEncode ( obj ) ) ;
2016-03-11 00:48:53 +00:00
else {
switch ( obj ) {
case 0 :
changetext += ( ' <' + me . textImage + '>' ) ;
break ;
case 1 :
changetext += ( ' <' + me . textShape + '>' ) ;
break ;
case 2 :
changetext += ( ' <' + me . textChart + '>' ) ;
break ;
case 3 :
changetext += ( ' <' + me . textEquation + '>' ) ;
break ;
}
}
} )
} else if ( typeof value === 'string' ) {
2016-09-15 13:29:34 +00:00
changetext += ( ' ' + Common . Utils . String . htmlEncode ( value ) ) ;
2016-03-11 00:48:53 +00:00
}
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscRevisionsChangeType . TextRem :
2019-04-12 14:55:08 +00:00
changetext = ( movetype == Asc . c _oAscRevisionsMove . NoMove ) ? me . textDeleted : ( item . is _MovedDown ( ) ? me . textParaMoveFromDown : me . textParaMoveFromUp ) ;
2016-03-11 00:48:53 +00:00
if ( typeof value == 'object' ) {
_ . each ( value , function ( obj ) {
if ( typeof obj === 'string' )
2016-09-15 13:29:34 +00:00
changetext += ( ' ' + Common . Utils . String . htmlEncode ( obj ) ) ;
2016-03-11 00:48:53 +00:00
else {
switch ( obj ) {
case 0 :
changetext += ( ' <' + me . textImage + '>' ) ;
break ;
case 1 :
changetext += ( ' <' + me . textShape + '>' ) ;
break ;
case 2 :
changetext += ( ' <' + me . textChart + '>' ) ;
break ;
case 3 :
changetext += ( ' <' + me . textEquation + '>' ) ;
break ;
}
}
} )
} else if ( typeof value === 'string' ) {
2016-09-15 13:29:34 +00:00
changetext += ( ' ' + Common . Utils . String . htmlEncode ( value ) ) ;
2016-03-11 00:48:53 +00:00
}
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscRevisionsChangeType . ParaAdd :
2016-03-11 00:48:53 +00:00
changetext = me . textParaInserted ;
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscRevisionsChangeType . ParaRem :
2016-03-11 00:48:53 +00:00
changetext = me . textParaDeleted ;
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscRevisionsChangeType . TextPr :
2016-03-11 00:48:53 +00:00
changetext = '<b>' + me . textFormatted ;
if ( value . Get _Bold ( ) !== undefined )
proptext += ( ( value . Get _Bold ( ) ? '' : me . textNot ) + me . textBold + ', ' ) ;
if ( value . Get _Italic ( ) !== undefined )
proptext += ( ( value . Get _Italic ( ) ? '' : me . textNot ) + me . textItalic + ', ' ) ;
if ( value . Get _Underline ( ) !== undefined )
proptext += ( ( value . Get _Underline ( ) ? '' : me . textNot ) + me . textUnderline + ', ' ) ;
if ( value . Get _Strikeout ( ) !== undefined )
proptext += ( ( value . Get _Strikeout ( ) ? '' : me . textNot ) + me . textStrikeout + ', ' ) ;
if ( value . Get _DStrikeout ( ) !== undefined )
proptext += ( ( value . Get _DStrikeout ( ) ? '' : me . textNot ) + me . textDStrikeout + ', ' ) ;
if ( value . Get _Caps ( ) !== undefined )
proptext += ( ( value . Get _Caps ( ) ? '' : me . textNot ) + me . textCaps + ', ' ) ;
if ( value . Get _SmallCaps ( ) !== undefined )
proptext += ( ( value . Get _SmallCaps ( ) ? '' : me . textNot ) + me . textSmallCaps + ', ' ) ;
if ( value . Get _VertAlign ( ) !== undefined )
proptext += ( ( ( value . Get _VertAlign ( ) == 1 ) ? me . textSuperScript : ( ( value . Get _VertAlign ( ) == 2 ) ? me . textSubScript : me . textBaseline ) ) + ', ' ) ;
if ( value . Get _Color ( ) !== undefined )
proptext += ( me . textColor + ', ' ) ;
if ( value . Get _Highlight ( ) !== undefined )
proptext += ( me . textHighlight + ', ' ) ;
if ( value . Get _Shd ( ) !== undefined )
proptext += ( me . textShd + ', ' ) ;
if ( value . Get _FontFamily ( ) !== undefined )
proptext += ( value . Get _FontFamily ( ) + ', ' ) ;
if ( value . Get _FontSize ( ) !== undefined )
proptext += ( value . Get _FontSize ( ) + ', ' ) ;
if ( value . Get _Spacing ( ) !== undefined )
2016-04-06 13:38:54 +00:00
proptext += ( me . textSpacing + ' ' + Common . Utils . Metric . fnRecalcFromMM ( value . Get _Spacing ( ) ) . toFixed ( 2 ) + ' ' + Common . Utils . Metric . getCurrentMetricName ( ) + ', ' ) ;
2016-03-11 00:48:53 +00:00
if ( value . Get _Position ( ) !== undefined )
2016-04-06 13:38:54 +00:00
proptext += ( me . textPosition + ' ' + Common . Utils . Metric . fnRecalcFromMM ( value . Get _Position ( ) ) . toFixed ( 2 ) + ' ' + Common . Utils . Metric . getCurrentMetricName ( ) + ', ' ) ;
2016-03-11 00:48:53 +00:00
if ( value . Get _Lang ( ) !== undefined )
proptext += ( Common . util . LanguageInfo . getLocalLanguageName ( value . Get _Lang ( ) ) [ 1 ] + ', ' ) ;
if ( ! _ . isEmpty ( proptext ) ) {
changetext += ': ' ;
proptext = proptext . substring ( 0 , proptext . length - 2 ) ;
}
changetext += '</b>' ;
changetext += proptext ;
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscRevisionsChangeType . ParaPr :
2016-03-11 00:48:53 +00:00
changetext = '<b>' + me . textParaFormatted ;
if ( value . Get _ContextualSpacing ( ) )
proptext += ( ( value . Get _ContextualSpacing ( ) ? me . textContextual : me . textNoContextual ) + ', ' ) ;
if ( value . Get _IndLeft ( ) !== undefined )
2016-04-06 13:38:54 +00:00
proptext += ( me . textIndentLeft + ' ' + Common . Utils . Metric . fnRecalcFromMM ( value . Get _IndLeft ( ) ) . toFixed ( 2 ) + ' ' + Common . Utils . Metric . getCurrentMetricName ( ) + ', ' ) ;
2016-03-11 00:48:53 +00:00
if ( value . Get _IndRight ( ) !== undefined )
2016-04-06 13:38:54 +00:00
proptext += ( me . textIndentRight + ' ' + Common . Utils . Metric . fnRecalcFromMM ( value . Get _IndRight ( ) ) . toFixed ( 2 ) + ' ' + Common . Utils . Metric . getCurrentMetricName ( ) + ', ' ) ;
2016-03-11 00:48:53 +00:00
if ( value . Get _IndFirstLine ( ) !== undefined )
2016-04-06 13:38:54 +00:00
proptext += ( me . textFirstLine + ' ' + Common . Utils . Metric . fnRecalcFromMM ( value . Get _IndFirstLine ( ) ) . toFixed ( 2 ) + ' ' + Common . Utils . Metric . getCurrentMetricName ( ) + ', ' ) ;
2016-03-11 00:48:53 +00:00
if ( value . Get _Jc ( ) !== undefined ) {
switch ( value . Get _Jc ( ) ) {
case 0 :
proptext += ( me . textRight + ', ' ) ;
break ;
case 1 :
proptext += ( me . textLeft + ', ' ) ;
break ;
case 2 :
proptext += ( me . textCenter + ', ' ) ;
break ;
case 3 :
proptext += ( me . textJustify + ', ' ) ;
break ;
}
}
if ( value . Get _KeepLines ( ) !== undefined )
proptext += ( ( value . Get _KeepLines ( ) ? me . textKeepLines : me . textNoKeepLines ) + ', ' ) ;
if ( value . Get _KeepNext ( ) )
proptext += ( ( value . Get _KeepNext ( ) ? me . textKeepNext : me . textNoKeepNext ) + ', ' ) ;
if ( value . Get _PageBreakBefore ( ) )
proptext += ( ( value . Get _PageBreakBefore ( ) ? me . textBreakBefore : me . textNoBreakBefore ) + ', ' ) ;
if ( value . Get _SpacingLineRule ( ) !== undefined && value . Get _SpacingLine ( ) !== undefined ) {
proptext += me . textLineSpacing ;
proptext += ( ( ( value . Get _SpacingLineRule ( ) == c _paragraphLinerule . LINERULE _LEAST ) ? me . textAtLeast : ( ( value . Get _SpacingLineRule ( ) == c _paragraphLinerule . LINERULE _AUTO ) ? me . textMultiple : me . textExact ) ) + ' ' ) ;
2016-04-06 13:38:54 +00:00
proptext += ( ( ( value . Get _SpacingLineRule ( ) == c _paragraphLinerule . LINERULE _AUTO ) ? value . Get _SpacingLine ( ) : Common . Utils . Metric . fnRecalcFromMM ( value . Get _SpacingLine ( ) ) . toFixed ( 2 ) + ' ' + Common . Utils . Metric . getCurrentMetricName ( ) ) + ', ' ) ;
2016-03-11 00:48:53 +00:00
}
if ( value . Get _SpacingBeforeAutoSpacing ( ) )
proptext += ( me . textSpacingBefore + ' ' + me . textAuto + ', ' ) ;
else if ( value . Get _SpacingBefore ( ) !== undefined )
2016-04-06 13:38:54 +00:00
proptext += ( me . textSpacingBefore + ' ' + Common . Utils . Metric . fnRecalcFromMM ( value . Get _SpacingBefore ( ) ) . toFixed ( 2 ) + ' ' + Common . Utils . Metric . getCurrentMetricName ( ) + ', ' ) ;
2016-03-11 00:48:53 +00:00
if ( value . Get _SpacingAfterAutoSpacing ( ) )
proptext += ( me . textSpacingAfter + ' ' + me . textAuto + ', ' ) ;
else if ( value . Get _SpacingAfter ( ) !== undefined )
2016-04-06 13:38:54 +00:00
proptext += ( me . textSpacingAfter + ' ' + Common . Utils . Metric . fnRecalcFromMM ( value . Get _SpacingAfter ( ) ) . toFixed ( 2 ) + ' ' + Common . Utils . Metric . getCurrentMetricName ( ) + ', ' ) ;
2016-03-11 00:48:53 +00:00
if ( value . Get _WidowControl ( ) )
proptext += ( ( value . Get _WidowControl ( ) ? me . textWidow : me . textNoWidow ) + ', ' ) ;
if ( value . Get _Tabs ( ) !== undefined )
2020-02-14 14:39:13 +00:00
proptext += ( me . textTabs + ', ' ) ;
2016-03-11 00:48:53 +00:00
if ( value . Get _NumPr ( ) !== undefined )
2020-02-14 14:39:13 +00:00
proptext += ( me . textNum + ', ' ) ;
2016-03-11 00:48:53 +00:00
if ( value . Get _PStyle ( ) !== undefined ) {
var style = me . api . asc _GetStyleNameById ( value . Get _PStyle ( ) ) ;
if ( ! _ . isEmpty ( style ) ) proptext += ( style + ', ' ) ;
}
if ( ! _ . isEmpty ( proptext ) ) {
changetext += ': ' ;
proptext = proptext . substring ( 0 , proptext . length - 2 ) ;
}
changetext += '</b>' ;
changetext += proptext ;
break ;
2019-04-03 14:01:32 +00:00
case Asc . c _oAscRevisionsChangeType . TablePr :
changetext = me . textTableChanged ;
break ;
case Asc . c _oAscRevisionsChangeType . RowsAdd :
changetext = me . textTableRowsAdd ;
break ;
case Asc . c _oAscRevisionsChangeType . RowsRem :
changetext = me . textTableRowsDel ;
break ;
2016-03-11 00:48:53 +00:00
}
var date = ( item . get _DateTime ( ) == '' ) ? new Date ( ) : new Date ( item . get _DateTime ( ) ) ,
2018-06-04 11:45:22 +00:00
user = me . userCollection . findOriginalUser ( item . get _UserId ( ) ) ,
2016-03-11 00:48:53 +00:00
change = new Common . Models . ReviewChange ( {
uid : Common . UI . getId ( ) ,
userid : item . get _UserId ( ) ,
username : item . get _UserName ( ) ,
2018-06-04 11:45:22 +00:00
usercolor : ( user ) ? user . get ( 'color' ) : null ,
2016-03-11 00:48:53 +00:00
date : me . dateToLocaleTimeString ( date ) ,
changetext : changetext ,
id : Common . UI . getId ( ) ,
lock : ( item . get _LockUserId ( ) !== null ) ,
2019-03-25 14:21:27 +00:00
lockuser : me . getUserName ( item . get _LockUserId ( ) ) ,
2016-03-11 00:48:53 +00:00
type : item . get _Type ( ) ,
changedata : item ,
2018-12-18 14:27:19 +00:00
scope : me . view ,
2019-04-12 14:55:08 +00:00
hint : ! me . appConfig . canReview ,
2019-04-26 14:10:34 +00:00
goto : ( item . get _MoveType ( ) == Asc . c _oAscRevisionsMove . MoveTo || item . get _MoveType ( ) == Asc . c _oAscRevisionsMove . MoveFrom ) ,
2021-03-26 11:29:16 +00:00
editable : me . appConfig . isReviewOnly && ( item . get _UserId ( ) == me . currentUserId ) || ! me . appConfig . isReviewOnly && ( ! me . appConfig . canUseReviewPermissions || AscCommon . UserInfoParser . canEditReview ( item . get _UserName ( ) ) )
2016-03-11 00:48:53 +00:00
} ) ;
arr . push ( change ) ;
} ) ;
return arr ;
} ,
getUserName : function ( id ) {
if ( this . userCollection && id !== null ) {
var rec = this . userCollection . findUser ( id ) ;
2021-03-26 11:29:16 +00:00
if ( rec ) return AscCommon . UserInfoParser . getParsedName ( rec . get ( 'username' ) ) ;
2016-03-11 00:48:53 +00:00
}
return '' ;
} ,
dateToLocaleTimeString : function ( date ) {
function format ( date ) {
var strTime ,
hours = date . getHours ( ) ,
minutes = date . getMinutes ( ) ,
ampm = hours >= 12 ? 'pm' : 'am' ;
hours = hours % 12 ;
hours = hours ? hours : 12 ; // the hour '0' should be '12'
minutes = minutes < 10 ? '0' + minutes : minutes ;
strTime = hours + ':' + minutes + ' ' + ampm ;
return strTime ;
}
// MM/dd/yyyy hh:mm AM
return ( date . getMonth ( ) + 1 ) + '/' + ( date . getDate ( ) ) + '/' + date . getFullYear ( ) + ' ' + format ( date ) ;
} ,
2017-03-29 09:33:20 +00:00
onBtnPreviewClick : function ( btn , opts ) {
switch ( opts ) {
case 'prev' : this . api . asc _GetPrevRevisionsChange ( ) ; break ;
case 'next' : this . api . asc _GetNextRevisionsChange ( ) ; break ;
2016-03-11 00:48:53 +00:00
}
2017-02-27 12:04:18 +00:00
2016-03-11 00:48:53 +00:00
Common . NotificationCenter . trigger ( 'edit:complete' , this . view ) ;
} ,
onAcceptClick : function ( menu , item , e ) {
if ( this . api ) {
if ( item ) {
if ( item . value === 'all' ) {
this . api . asc _AcceptAllChanges ( ) ;
} else {
this . api . asc _AcceptChanges ( ) ;
}
} else {
this . api . asc _AcceptChanges ( menu ) ;
}
}
Common . NotificationCenter . trigger ( 'edit:complete' , this . view ) ;
} ,
onRejectClick : function ( menu , item , e ) {
if ( this . api ) {
if ( item ) {
if ( item . value === 'all' ) {
this . api . asc _RejectAllChanges ( ) ;
} else {
this . api . asc _RejectChanges ( ) ;
}
} else {
this . api . asc _RejectChanges ( menu ) ;
}
}
Common . NotificationCenter . trigger ( 'edit:complete' , this . view ) ;
} ,
onDeleteClick : function ( change ) {
if ( this . api ) {
this . api . asc _RejectChanges ( change ) ;
}
Common . NotificationCenter . trigger ( 'edit:complete' , this . view ) ;
} ,
2019-04-12 14:55:08 +00:00
onGotoClick : function ( change ) {
if ( this . api ) {
this . api . asc _FollowRevisionMove ( change ) ;
}
Common . NotificationCenter . trigger ( 'edit:complete' , this . view ) ;
} ,
2021-02-10 10:09:21 +00:00
onTurnPreview : function ( state , global , fromApi ) {
2017-04-05 09:11:15 +00:00
if ( this . appConfig . isReviewOnly ) {
2017-03-29 11:19:57 +00:00
this . view . turnChanges ( true ) ;
} else
2017-04-05 09:11:15 +00:00
if ( this . appConfig . canReview ) {
2021-04-24 20:39:27 +00:00
state = ( state == 'off' ) ? false : state ; // support of prev. version (on/off)
2021-02-27 09:43:32 +00:00
if ( ! ! global ) {
2021-02-26 12:11:57 +00:00
this . api . asc _SetLocalTrackRevisions ( null ) ;
this . api . asc _SetGlobalTrackRevisions ( ! ! state ) ;
} else
this . api . asc _SetLocalTrackRevisions ( ! ! state ) ;
2021-02-10 10:09:21 +00:00
}
} ,
2017-03-29 11:19:57 +00:00
2021-02-27 09:43:32 +00:00
onApiTrackRevisionsChange : function ( localFlag , globalFlag , userId ) {
if ( this . appConfig . isReviewOnly ) {
this . view . turnChanges ( true ) ;
} else
if ( this . appConfig . canReview ) {
var global = ( localFlag === null ) ,
state = global ? globalFlag : localFlag ;
Common . Utils . InternalSettings . set ( this . view . appPrefix + "track-changes" , ( state ? 0 : 1 ) + ( global ? 2 : 0 ) ) ;
this . view . turnChanges ( state , global ) ;
if ( userId && this . userCollection ) {
var rec = this . userCollection . findOriginalUser ( userId ) ;
2022-06-15 19:09:53 +00:00
rec && Common . NotificationCenter . trigger ( 'showmessage' , { msg : Common . Utils . String . format ( globalFlag ? this . textOnGlobal : this . textOffGlobal , AscCommon . UserInfoParser . getParsedName ( rec . get ( 'username' ) ) ) } ,
{ timeout : 5000 , hideCloseTip : true } ) ;
2021-02-26 12:11:57 +00:00
}
2017-03-29 11:19:57 +00:00
}
} ,
2021-11-01 18:13:34 +00:00
onTurnSpelling : function ( state , suspend ) {
2017-04-04 15:22:02 +00:00
state = ( state == 'on' ) ;
2021-11-01 18:13:34 +00:00
this . view && this . view . turnSpelling ( state ) ;
2017-04-04 15:22:02 +00:00
2021-11-01 18:13:34 +00:00
if ( Common . UI . FeaturesManager . canChange ( 'spellcheck' ) && ! suspend ) {
Common . localStorage . setItem ( this . view . appPrefix + "settings-spellcheck" , state ? 1 : 0 ) ;
this . api . asc _setSpellCheck ( state ) ;
Common . Utils . InternalSettings . set ( this . view . appPrefix + "settings-spellcheck" , state ) ;
}
2017-04-04 15:22:02 +00:00
} ,
2017-08-23 14:49:56 +00:00
onReviewViewClick : function ( menu , item , e ) {
2019-01-15 11:12:09 +00:00
this . turnDisplayMode ( item . value ) ;
2021-08-04 10:19:19 +00:00
if ( ! this . appConfig . isEdit && ! this . appConfig . isRestrictedEdit )
Common . localStorage . setItem ( this . view . appPrefix + "review-mode" , item . value ) ; // for viewer
else if ( item . value == 'markup' || item . value == 'simple' )
Common . localStorage . setItem ( this . view . appPrefix + "review-mode-editor" , item . value ) ; // for editor save only markup modes
2019-01-15 11:12:09 +00:00
Common . NotificationCenter . trigger ( 'edit:complete' , this . view ) ;
} ,
2019-08-13 14:40:52 +00:00
onCompareClick : function ( item ) {
if ( this . api ) {
2019-10-15 08:44:38 +00:00
var me = this ;
2019-08-14 13:18:57 +00:00
if ( ! this . _state . compareSettings ) {
this . _state . compareSettings = new AscCommonWord . ComparisonOptions ( ) ;
this . _state . compareSettings . putWords ( ! Common . localStorage . getBool ( "de-compare-char" ) ) ;
}
2019-08-13 14:40:52 +00:00
if ( item === 'file' ) {
2019-08-14 13:18:57 +00:00
if ( this . api )
this . api . asc _CompareDocumentFile ( this . _state . compareSettings ) ;
2019-08-13 14:40:52 +00:00
Common . NotificationCenter . trigger ( 'edit:complete' , this . view ) ;
} else if ( item === 'url' ) {
( new Common . Views . ImageFromUrlDialog ( {
title : me . textUrl ,
handler : function ( result , value ) {
if ( result == 'ok' ) {
if ( me . api ) {
var checkUrl = value . replace ( / /g , '' ) ;
if ( ! _ . isEmpty ( checkUrl ) ) {
2019-08-14 13:18:57 +00:00
me . api . asc _CompareDocumentUrl ( checkUrl , me . _state . compareSettings ) ;
2019-08-13 14:40:52 +00:00
}
}
Common . NotificationCenter . trigger ( 'edit:complete' , me . view ) ;
}
}
} ) ) . show ( ) ;
} else if ( item === 'storage' ) {
2019-10-15 08:44:38 +00:00
if ( this . appConfig . canRequestCompareFile ) {
Common . Gateway . requestCompareFile ( ) ;
} else {
2019-10-15 07:58:18 +00:00
( new Common . Views . SelectFileDlg ( {
fileChoiceUrl : this . appConfig . fileChoiceUrl . replace ( "{fileExt}" , "" ) . replace ( "{documentType}" , "DocumentsOnly" )
} ) ) . on ( 'selectfile' , function ( obj , file ) {
2019-10-15 08:44:38 +00:00
me . setRevisedFile ( file , me . _state . compareSettings ) ;
2019-10-15 07:58:18 +00:00
} ) . show ( ) ;
2019-10-15 08:44:38 +00:00
}
2019-08-13 14:40:52 +00:00
} else if ( item === 'settings' ) {
2020-10-15 12:37:48 +00:00
var value = me . _state . compareSettings ? me . _state . compareSettings . getWords ( ) : true ;
( new Common . Views . OptionsDialog ( {
title : me . textTitleComparison ,
items : [
{ caption : me . textChar , value : false , checked : ( value === false ) } ,
{ caption : me . textWord , value : true , checked : ( value !== false ) }
] ,
label : me . textShow ,
handler : function ( dlg , result ) {
if ( result == 'ok' ) {
me . _state . compareSettings = new AscCommonWord . ComparisonOptions ( ) ;
me . _state . compareSettings . putWords ( dlg . getSettings ( ) ) ;
2019-08-14 08:07:24 +00:00
}
Common . NotificationCenter . trigger ( 'edit:complete' , me . toolbar ) ;
}
} ) ) . show ( ) ;
2019-08-13 14:40:52 +00:00
}
}
Common . NotificationCenter . trigger ( 'edit:complete' , this . view ) ;
} ,
2019-10-15 08:44:38 +00:00
setRevisedFile : function ( data ) {
2019-10-11 12:12:59 +00:00
if ( ! this . _state . compareSettings ) {
this . _state . compareSettings = new AscCommonWord . ComparisonOptions ( ) ;
this . _state . compareSettings . putWords ( ! Common . localStorage . getBool ( "de-compare-char" ) ) ;
}
2019-08-13 14:40:52 +00:00
if ( data && data . url ) {
2019-10-11 12:12:59 +00:00
this . api . asc _CompareDocumentUrl ( data . url , this . _state . compareSettings , data . token ) ; // for loading from storage
2019-08-13 14:40:52 +00:00
}
} ,
2019-10-09 14:33:29 +00:00
onAcceptChangesBeforeCompare : function ( callback ) {
var me = this ;
Common . UI . warning ( {
width : 550 ,
msg : this . textAcceptBeforeCompare ,
buttons : [ 'yes' , 'no' ] ,
primary : 'yes' ,
callback : function ( result ) {
_ . defer ( function ( ) {
2019-10-25 10:46:37 +00:00
if ( callback ) callback ( result == 'yes' ) ;
2019-10-09 14:33:29 +00:00
} ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . view ) ;
}
} ) ;
} ,
2019-01-15 11:12:09 +00:00
turnDisplayMode : function ( mode ) {
2017-08-23 14:49:56 +00:00
if ( this . api ) {
2021-08-10 16:32:12 +00:00
var type = Asc . c _oAscDisplayModeInReview . Edit ;
switch ( mode ) {
case 'final' :
type = Asc . c _oAscDisplayModeInReview . Final ;
break ;
case 'original' :
type = Asc . c _oAscDisplayModeInReview . Original ;
break ;
case 'simple' :
type = Asc . c _oAscDisplayModeInReview . Simple ;
break ;
}
this . api . asc _SetDisplayModeInReview ( type ) ;
2017-08-23 14:49:56 +00:00
}
2019-01-15 11:12:09 +00:00
this . disableEditing ( mode == 'final' || mode == 'original' ) ;
this . _state . previewMode = ( mode == 'final' || mode == 'original' ) ;
2017-08-23 14:49:56 +00:00
} ,
2021-08-10 16:32:12 +00:00
onChangeDisplayModeInReview : function ( type ) {
this . disableEditing ( type === Asc . c _oAscDisplayModeInReview . Final || type === Asc . c _oAscDisplayModeInReview . Original ) ;
var mode = 'markup' ;
switch ( type ) {
case Asc . c _oAscDisplayModeInReview . Final :
mode = 'final' ;
break ;
case Asc . c _oAscDisplayModeInReview . Original :
mode = 'original' ;
break ;
case Asc . c _oAscDisplayModeInReview . Simple :
mode = 'simple' ;
break ;
}
this . view && this . view . turnDisplayMode ( mode ) ;
this . _state . previewMode = ( type === Asc . c _oAscDisplayModeInReview . Final || type === Asc . c _oAscDisplayModeInReview . Original ) ;
2021-07-19 11:06:01 +00:00
} ,
2017-08-25 09:25:54 +00:00
isPreviewChangesMode : function ( ) {
return this . _state . previewMode ;
} ,
2017-10-07 13:06:51 +00:00
onCoAuthMode : function ( menu , item , e ) {
2017-10-12 09:05:55 +00:00
Common . localStorage . setItem ( this . view . appPrefix + "settings-coauthmode" , item . value ) ;
2017-11-07 12:00:11 +00:00
Common . Utils . InternalSettings . set ( this . view . appPrefix + "settings-coauthmode" , item . value ) ;
2017-10-07 13:06:51 +00:00
if ( this . api ) {
this . api . asc _SetFastCollaborative ( item . value == 1 ) ;
2017-10-12 10:43:23 +00:00
if ( this . api . SetCollaborativeMarksShowType ) {
var value = Common . localStorage . getItem ( item . value ? this . view . appPrefix + "settings-showchanges-fast" : this . view . appPrefix + "settings-showchanges-strict" ) ;
if ( value !== null )
this . api . SetCollaborativeMarksShowType ( value == 'all' ? Asc . c _oAscCollaborativeMarksShowType . All :
value == 'none' ? Asc . c _oAscCollaborativeMarksShowType . None : Asc . c _oAscCollaborativeMarksShowType . LastChanges ) ;
else
this . api . SetCollaborativeMarksShowType ( item . value ? Asc . c _oAscCollaborativeMarksShowType . None : Asc . c _oAscCollaborativeMarksShowType . LastChanges ) ;
}
2017-10-07 13:06:51 +00:00
2017-10-12 09:05:55 +00:00
value = Common . localStorage . getItem ( this . view . appPrefix + "settings-autosave" ) ;
2017-10-07 13:06:51 +00:00
if ( value === null && this . appConfig . customization && this . appConfig . customization . autosave === false )
value = 0 ;
value = ( ! item . value && value !== null ) ? parseInt ( value ) : 1 ;
2017-10-12 09:05:55 +00:00
Common . localStorage . setItem ( this . view . appPrefix + "settings-autosave" , value ) ;
2017-11-07 12:00:11 +00:00
Common . Utils . InternalSettings . set ( this . view . appPrefix + "settings-autosave" , value ) ;
2017-10-07 13:06:51 +00:00
this . api . asc _setAutoSaveGap ( value ) ;
}
Common . NotificationCenter . trigger ( 'edit:complete' , this . view ) ;
2017-11-24 06:31:34 +00:00
this . view . fireEvent ( 'settings:apply' , [ this ] ) ;
2017-10-07 13:06:51 +00:00
} ,
2017-08-23 14:49:56 +00:00
disableEditing : function ( disable ) {
2021-06-29 13:27:44 +00:00
Common . NotificationCenter . trigger ( 'editing:disable' , disable , {
viewMode : false ,
reviewMode : true ,
2021-12-30 11:49:19 +00:00
fillFormMode : false ,
2021-06-29 13:27:44 +00:00
allowMerge : false ,
allowSignature : false ,
allowProtect : false ,
2022-02-10 16:28:29 +00:00
rightMenu : { clear : disable , disable : true } ,
2021-06-29 13:27:44 +00:00
statusBar : true ,
leftMenu : { disable : false , previewMode : true } ,
2021-06-29 21:31:55 +00:00
fileMenu : { protect : true } ,
2021-06-29 13:27:44 +00:00
navigation : { disable : false , previewMode : true } ,
comments : { disable : false , previewMode : true } ,
chat : false ,
2021-12-29 22:01:53 +00:00
review : true ,
2021-06-29 13:27:44 +00:00
viewport : false ,
documentHolder : true ,
toolbar : true ,
2021-12-30 09:10:23 +00:00
plugins : true ,
protect : true
2021-06-30 12:19:45 +00:00
} , 'review' ) ;
2017-08-23 14:49:56 +00:00
} ,
2017-03-29 11:19:57 +00:00
createToolbarPanel : function ( ) {
return this . view . getPanel ( ) ;
} ,
2017-03-29 09:33:20 +00:00
getView : function ( name ) {
return ! name && this . view ?
this . view : Backbone . Controller . prototype . getView . call ( this , name ) ;
} ,
2017-03-29 11:19:57 +00:00
onAppReady : function ( config ) {
2017-06-15 13:35:55 +00:00
var me = this ;
if ( config . canReview ) {
2017-03-29 11:19:57 +00:00
( new Promise ( function ( resolve ) {
resolve ( ) ;
} ) ) . then ( function ( ) {
2021-02-27 09:43:32 +00:00
// function _setReviewStatus(state, global) {
// me.view.turnChanges(state, global);
// !global && me.api.asc_SetLocalTrackRevisions(state);
// Common.Utils.InternalSettings.set(me.view.appPrefix + "track-changes", (state ? 0 : 1) + (global ? 2 : 0));
// };
2021-07-22 19:56:15 +00:00
var trackChanges = me . appConfig . customization && me . appConfig . customization . review ? me . appConfig . customization . review . trackChanges : undefined ;
( trackChanges === undefined ) && ( trackChanges = me . appConfig . customization ? me . appConfig . customization . trackChanges : undefined ) ;
2021-02-27 09:43:32 +00:00
if ( config . isReviewOnly || trackChanges !== undefined )
me . api . asc _SetLocalTrackRevisions ( config . isReviewOnly || trackChanges === true ) ;
else
me . onApiTrackRevisionsChange ( me . api . asc _GetLocalTrackRevisions ( ) , me . api . asc _GetGlobalTrackRevisions ( ) ) ;
2018-09-12 13:32:34 +00:00
me . api . asc _HaveRevisionsChanges ( ) && me . view . markChanges ( true ) ;
2021-02-27 09:43:32 +00:00
2021-08-04 10:19:19 +00:00
var val = Common . localStorage . getItem ( me . view . appPrefix + "review-mode-editor" ) ;
2021-08-25 17:51:35 +00:00
if ( val === null ) {
val = me . appConfig . customization && me . appConfig . customization . review ? me . appConfig . customization . review . reviewDisplay : undefined ;
! val && ( val = me . appConfig . customization ? me . appConfig . customization . reviewDisplay : undefined ) ;
val = /^(original|final|markup|simple)$/i . test ( val ) ? val . toLocaleLowerCase ( ) : 'markup' ;
}
2021-08-04 10:19:19 +00:00
me . turnDisplayMode ( val ) ; // load display mode for all modes (viewer or editor)
me . view . turnDisplayMode ( val ) ;
2017-04-04 15:22:02 +00:00
2021-07-22 19:56:15 +00:00
if ( typeof ( me . appConfig . customization ) == 'object' && ( me . appConfig . customization . review && me . appConfig . customization . review . showReviewChanges == true ||
( ! me . appConfig . customization . review || me . appConfig . customization . review . showReviewChanges === undefined ) && me . appConfig . customization . showReviewChanges == true ) ) {
2017-06-09 14:30:52 +00:00
me . dlgChanges = ( new Common . Views . ReviewChangesDialog ( {
popoverChanges : me . popoverChanges ,
mode : me . appConfig
} ) ) ;
var sdk = $ ( '#editor_sdk' ) ,
offset = sdk . offset ( ) ;
me . dlgChanges . show ( Math . max ( 10 , offset . left + sdk . width ( ) - 300 ) , Math . max ( 10 , offset . top + sdk . height ( ) - 150 ) ) ;
}
2017-03-29 11:19:57 +00:00
} ) ;
2019-01-15 11:12:09 +00:00
} else if ( config . canViewReview ) {
2019-08-23 14:23:44 +00:00
config . canViewReview = ( config . isEdit || me . api . asc _HaveRevisionsChanges ( true ) ) ; // check revisions from all users
2019-06-13 14:37:56 +00:00
if ( config . canViewReview ) {
2021-08-04 10:19:19 +00:00
var val = Common . localStorage . getItem ( me . view . appPrefix + ( config . isEdit || config . isRestrictedEdit ? "review-mode-editor" : "review-mode" ) ) ;
2021-07-22 19:56:15 +00:00
if ( val === null ) {
val = me . appConfig . customization && me . appConfig . customization . review ? me . appConfig . customization . review . reviewDisplay : undefined ;
! val && ( val = me . appConfig . customization ? me . appConfig . customization . reviewDisplay : undefined ) ;
2021-08-25 17:51:35 +00:00
val = /^(original|final|markup|simple)$/i . test ( val ) ? val . toLocaleLowerCase ( ) : ( config . isEdit || config . isRestrictedEdit ? 'markup' : 'original' ) ;
2021-07-22 19:56:15 +00:00
}
2021-08-25 17:51:35 +00:00
me . turnDisplayMode ( val ) ;
me . view . turnDisplayMode ( val ) ;
2019-06-13 14:37:56 +00:00
}
2017-03-29 11:19:57 +00:00
}
2017-10-10 12:14:27 +00:00
if ( me . view && me . view . btnChat ) {
me . getApplication ( ) . getController ( 'LeftMenu' ) . leftMenu . btnChat . on ( 'toggle' , function ( btn , state ) {
if ( state !== me . view . btnChat . pressed )
me . view . turnChat ( state ) ;
} ) ;
2019-10-29 14:08:47 +00:00
}
2021-08-20 14:38:32 +00:00
me . onChangeProtectSheet ( ) ;
2021-04-07 19:50:53 +00:00
if ( me . view ) {
2021-12-29 22:01:53 +00:00
me . lockToolbar ( Common . enumLock . hideComments , ! Common . localStorage . getBool ( me . view . appPrefix + "settings-livecomment" , true ) , { array : [ me . view . btnCommentRemove , me . view . btnCommentResolve ] } ) ;
me . lockToolbar ( Common . enumLock [ 'Objects' ] , ! ! this . _state . wsProps [ 'Objects' ] , { array : [ me . view . btnCommentRemove , me . view . btnCommentResolve ] } ) ;
2017-10-10 12:14:27 +00:00
}
2021-08-04 12:43:54 +00:00
var val = Common . localStorage . getItem ( me . view . appPrefix + "settings-review-hover-mode" ) ;
if ( val === null ) {
val = me . appConfig . customization && me . appConfig . customization . review ? ! ! me . appConfig . customization . review . hoverMode : false ;
} else
val = ! ! parseInt ( val ) ;
Common . Utils . InternalSettings . set ( me . view . appPrefix + "settings-review-hover-mode" , val ) ;
me . appConfig . reviewHoverMode = val ;
2017-03-29 11:19:57 +00:00
} ,
2017-04-04 15:22:02 +00:00
applySettings : function ( menu ) {
2017-10-12 09:05:55 +00:00
this . view && this . view . turnSpelling ( Common . localStorage . getBool ( this . view . appPrefix + "settings-spellcheck" , true ) ) ;
this . view && this . view . turnCoAuthMode ( Common . localStorage . getBool ( this . view . appPrefix + "settings-coauthmode" , true ) ) ;
2021-11-29 14:05:05 +00:00
if ( ( this . appConfig . canReview || this . appConfig . canViewReview ) && this . appConfig . reviewHoverMode )
this . onApiShowChange ( ) ;
2017-04-04 15:22:02 +00:00
} ,
2017-03-29 11:19:57 +00:00
synchronizeChanges : function ( ) {
2017-08-25 06:39:04 +00:00
if ( this . appConfig && this . appConfig . canReview ) {
2017-03-29 11:19:57 +00:00
this . view . markChanges ( this . api . asc _HaveRevisionsChanges ( ) ) ;
}
} ,
2017-04-04 15:22:02 +00:00
setLanguages : function ( array ) {
this . langs = array ;
2021-12-29 22:01:53 +00:00
this . lockToolbar ( Common . enumLock . noSpellcheckLangs , this . langs . length < 1 , { array : this . view . btnsDocLang } ) ;
2017-04-04 15:22:02 +00:00
} ,
onDocLanguage : function ( ) {
var me = this ;
2017-04-26 08:34:55 +00:00
( new Common . Views . LanguageDialog ( {
2019-01-28 13:51:07 +00:00
languages : me . langs ,
2017-04-04 15:22:02 +00:00
current : me . api . asc _getDefaultLanguage ( ) ,
2019-01-28 13:51:07 +00:00
handler : function ( result , value ) {
2017-04-04 15:22:02 +00:00
if ( result == 'ok' ) {
2019-01-28 13:51:07 +00:00
var record = _ . findWhere ( me . langs , { 'value' : value } ) ;
2017-04-04 15:22:02 +00:00
record && me . api . asc _setDefaultLanguage ( record . code ) ;
}
}
} ) ) . show ( ) ;
} ,
2017-10-07 13:06:51 +00:00
onLostEditRights : function ( ) {
2019-10-09 10:23:40 +00:00
this . _readonlyRights = true ;
2017-10-07 13:06:51 +00:00
this . view && this . view . onLostEditRights ( ) ;
2021-12-29 22:01:53 +00:00
this . view && this . lockToolbar ( Common . enumLock . cantShare , true , { array : [ this . view . btnSharing ] } ) ;
2017-10-07 13:06:51 +00:00
} ,
2019-10-09 10:23:40 +00:00
changeAccessRights : function ( btn , event , opts ) {
if ( this . _docAccessDlg || this . _readonlyRights ) return ;
2019-11-28 13:54:14 +00:00
if ( this . appConfig . canRequestSharingSettings ) {
Common . Gateway . requestSharingSettings ( ) ;
} else {
2021-05-12 21:57:01 +00:00
var me = this ;
me . _docAccessDlg = new Common . Views . DocumentAccessDialog ( {
settingsurl : this . appConfig . sharingSettingsUrl
} ) ;
me . _docAccessDlg . on ( 'accessrights' , function ( obj , rights ) {
me . setSharingSettings ( { sharingSettings : rights } ) ;
} ) . on ( 'close' , function ( obj ) {
me . _docAccessDlg = undefined ;
} ) ;
2019-10-09 10:23:40 +00:00
2021-05-12 21:57:01 +00:00
me . _docAccessDlg . show ( ) ;
2019-11-28 13:54:14 +00:00
}
2019-10-09 10:23:40 +00:00
} ,
setSharingSettings : function ( data ) {
if ( data ) {
this . document . info . sharingSettings = data . sharingSettings ;
Common . NotificationCenter . trigger ( 'collaboration:sharingupdate' , data . sharingSettings ) ;
Common . NotificationCenter . trigger ( 'mentions:clearusers' , this ) ;
}
} ,
2017-11-23 13:29:05 +00:00
onCoAuthoringDisconnect : function ( ) {
2021-12-29 22:01:53 +00:00
this . lockToolbar ( Common . enumLock . lostConnect , true )
2017-11-22 12:20:51 +00:00
} ,
2018-06-04 11:45:22 +00:00
onUpdateUsers : function ( ) {
var users = this . userCollection ;
2018-06-05 08:54:49 +00:00
this . popoverChanges && this . popoverChanges . each ( function ( model ) {
2018-06-04 11:45:22 +00:00
var user = users . findOriginalUser ( model . get ( 'userid' ) ) ;
model . set ( 'usercolor' , ( user ) ? user . get ( 'color' ) : null ) ;
} ) ;
} ,
2019-11-14 10:25:01 +00:00
onAuthParticipantsChanged : function ( users ) {
if ( this . view && this . view . btnCompare ) {
var length = 0 ;
_ . each ( users , function ( item ) {
if ( ! item . asc _getView ( ) )
length ++ ;
} ) ;
2021-12-29 22:01:53 +00:00
Common . Utils . lockControls ( Common . enumLock . hasCoeditingUsers , length > 1 , { array : [ this . view . btnCompare ] } ) ;
2019-11-14 10:25:01 +00:00
}
} ,
2019-10-29 14:08:47 +00:00
commentsShowHide : function ( mode ) {
if ( ! this . view ) return ;
var value = Common . Utils . InternalSettings . get ( this . view . appPrefix + "settings-livecomment" ) ;
2021-12-29 22:01:53 +00:00
( value !== undefined ) && this . lockToolbar ( Common . enumLock . hideComments , mode != 'show' && ! value , { array : [ this . view . btnCommentRemove , this . view . btnCommentResolve ] } ) ;
2021-08-20 14:38:32 +00:00
} ,
onChangeProtectSheet : function ( props ) {
if ( ! props ) {
var wbprotect = this . getApplication ( ) . getController ( 'WBProtection' ) ;
props = wbprotect ? wbprotect . getWSProps ( ) : null ;
}
2021-09-06 23:02:15 +00:00
this . _state . wsProps = props ? props . wsProps : [ ] ;
2021-08-20 14:38:32 +00:00
this . _state . wsLock = props ? props . wsLock : false ;
if ( ! this . view ) return ;
2021-12-29 22:01:53 +00:00
this . lockToolbar ( Common . enumLock [ 'Objects' ] , ! ! this . _state . wsProps [ 'Objects' ] , { array : [ this . view . btnCommentRemove , this . view . btnCommentResolve ] } ) ;
2019-10-29 14:08:47 +00:00
} ,
2016-03-11 00:48:53 +00:00
textInserted : '<b>Inserted:</b>' ,
textDeleted : '<b>Deleted:</b>' ,
textParaInserted : '<b>Paragraph Inserted</b> ' ,
textParaDeleted : '<b>Paragraph Deleted</b> ' ,
textFormatted : 'Formatted' ,
textParaFormatted : 'Paragraph Formatted' ,
textNot : 'Not ' ,
textBold : 'Bold' ,
textItalic : 'Italic' ,
textStrikeout : 'Strikeout' ,
textUnderline : 'Underline' ,
textColor : 'Font color' ,
textBaseline : 'Baseline' ,
textSuperScript : 'Superscript' ,
textSubScript : 'Subscript' ,
textHighlight : 'Highlight color' ,
textSpacing : 'Spacing' ,
textDStrikeout : 'Double strikeout' ,
textCaps : 'All caps' ,
textSmallCaps : 'Small caps' ,
textPosition : 'Position' ,
textFontSize : 'Font size' ,
textShd : 'Background color' ,
textContextual : 'Don\'t add interval between paragraphs of the same style' ,
textNoContextual : 'Add interval between paragraphs of the same style' ,
textIndentLeft : 'Indent left' ,
textIndentRight : 'Indent right' ,
textFirstLine : 'First line' ,
textRight : 'Align right' ,
textLeft : 'Align left' ,
textCenter : 'Align center' ,
textJustify : 'Align justify' ,
textBreakBefore : 'Page break before' ,
textKeepNext : 'Keep with next' ,
textKeepLines : 'Keep lines together' ,
textNoBreakBefore : 'No page break before' ,
textNoKeepNext : 'Don\'t keep with next' ,
textNoKeepLines : 'Don\'t keep lines together' ,
textLineSpacing : 'Line Spacing: ' ,
textMultiple : 'multiple' ,
textAtLeast : 'at least' ,
textExact : 'exactly' ,
textSpacingBefore : 'Spacing before' ,
textSpacingAfter : 'Spacing after' ,
textAuto : 'auto' ,
textWidow : 'Widow control' ,
textNoWidow : 'No widow control' ,
textTabs : 'Change tabs' ,
textNum : 'Change numbering' ,
textEquation : 'Equation' ,
textImage : 'Image' ,
textChart : 'Chart' ,
2019-04-03 14:01:32 +00:00
textShape : 'Shape' ,
textTableChanged : '<b>Table Settings Changed</b>' ,
2020-06-05 17:34:50 +00:00
textTableRowsAdd : '<b>Table Rows Added</b>' ,
textTableRowsDel : '<b>Table Rows Deleted</b>' ,
2019-04-12 14:55:08 +00:00
textParaMoveTo : '<b>Moved:</b>' ,
textParaMoveFromUp : '<b>Moved Up:</b>' ,
2019-08-13 14:40:52 +00:00
textParaMoveFromDown : '<b>Moved Down:</b>' ,
2019-10-09 14:33:29 +00:00
textUrl : 'Paste a document URL' ,
2020-10-15 12:37:48 +00:00
textAcceptBeforeCompare : 'In order to compare documents all the tracked changes in them will be considered to have been accepted. Do you want to continue?' ,
textTitleComparison : 'Comparison Settings' ,
textShow : 'Show changes at' ,
textChar : 'Character level' ,
2021-02-10 10:09:21 +00:00
textWord : 'Word level' ,
textOnGlobal : '{0} enabled Track Changes for everyone.' ,
textOffGlobal : '{0} disabled Track Changes for everyone.' ,
textOn : '{0} is now using Track Changes.' ,
textOff : '{0} is no longer using Track Changes.'
2020-10-15 12:37:48 +00:00
2016-03-11 00:48:53 +00:00
} , Common . Controllers . ReviewChanges || { } ) ) ;
} ) ;