2021-08-06 10:55:26 +00:00
define ( [
'core' ,
'irregularstack' ,
'gateway' ,
'common/main/lib/component/Window' ,
'common/main/lib/component/LoadMask' ,
'common/main/lib/component/Tooltip' ,
2021-08-19 20:09:18 +00:00
'common/main/lib/component/SynchronizeTip' ,
2021-08-19 21:01:46 +00:00
'common/main/lib/component/DataView' ,
'common/main/lib/component/Calendar' ,
2021-08-06 10:55:26 +00:00
'common/main/lib/util/LocalStorage' ,
'common/main/lib/util/Shortcuts' ,
2021-11-10 14:41:01 +00:00
'common/main/lib/view/CopyWarningDialog' ,
2021-11-29 12:02:22 +00:00
'common/main/lib/view/ImageFromUrlDialog' ,
'common/main/lib/view/SelectFileDlg' ,
2021-11-29 20:39:18 +00:00
'common/main/lib/view/SaveAsDlg' ,
2021-11-30 10:44:18 +00:00
'common/main/lib/view/OpenDialog' ,
2021-08-20 08:22:17 +00:00
'common/forms/lib/view/modals' ,
2021-08-06 10:55:26 +00:00
'documenteditor/forms/app/view/ApplicationView'
] , function ( Viewport ) {
'use strict' ;
var LoadingDocument = - 256 ,
maxPages = 0 ,
labelDocName ,
2021-08-19 20:09:18 +00:00
_submitFail ,
2021-08-18 23:04:30 +00:00
screenTip ,
mouseMoveData = null ,
isTooltipHiding = false ,
2021-08-06 17:07:03 +00:00
bodyWidth = 0 ,
ttOffset = [ 0 , - 10 ] ;
2021-08-06 10:55:26 +00:00
DE . Controllers . ApplicationController = Backbone . Controller . extend ( _ . assign ( {
views : [
'ApplicationView'
] ,
initialize : function ( ) {
} ,
onLaunch : function ( ) {
2021-08-18 20:15:52 +00:00
var me = this ;
2021-08-06 10:55:26 +00:00
if ( ! Common . Utils . isBrowserSupported ( ) ) {
Common . Utils . showBrowserRestriction ( ) ;
2021-09-01 22:11:52 +00:00
$ ( '#editor_sdk' ) . hide ( ) . remove ( ) ;
$ ( '#toolbar' ) . hide ( ) . remove ( ) ;
2021-08-06 10:55:26 +00:00
Common . Gateway . reportError ( undefined , this . unsupportedBrowserErrorText ) ;
return ;
}
this . stackLongActions = new Common . IrregularStack ( {
strongCompare : function ( obj1 , obj2 ) { return obj1 . id === obj2 . id && obj1 . type === obj2 . type ; } ,
weakCompare : function ( obj1 , obj2 ) { return obj1 . type === obj2 . type ; }
} ) ;
2021-12-06 09:01:39 +00:00
this . _state = { isDisconnected : false , licenseType : false , isDocModified : false } ;
2021-08-06 10:55:26 +00:00
this . view = this . createView ( 'ApplicationView' ) . render ( ) ;
window [ "flat_desine" ] = true ;
2021-11-23 10:41:03 +00:00
var translationTable = {
'Your text here' : this . txtArt ,
"Choose an item" : this . txtChoose ,
"Enter a date" : this . txtEnterDate ,
"Click to load image" : this . txtClickToLoad
}
2021-08-06 10:55:26 +00:00
this . api = new Asc . asc _docs _api ( {
'id-view' : 'editor_sdk' ,
2021-11-23 10:41:03 +00:00
'embedded' : true ,
'translate' : translationTable
2021-08-06 10:55:26 +00:00
} ) ;
2021-09-27 15:14:01 +00:00
Common . UI . Themes . init ( this . api ) ;
2021-08-06 10:55:26 +00:00
$ ( window ) . on ( 'resize' , this . onDocumentResize . bind ( this ) ) ;
this . boxSdk = $ ( '#editor_sdk' ) ;
this . boxSdk . on ( 'click' , function ( e ) {
2021-08-18 20:15:52 +00:00
if ( e . target . localName == 'canvas' ) {
if ( me . _preventClick )
me . _preventClick = false ;
else
me . boxSdk . focus ( ) ;
2021-08-06 10:55:26 +00:00
}
} ) ;
2021-08-18 20:15:52 +00:00
this . boxSdk . on ( 'mousedown' , function ( e ) {
if ( e . target . localName == 'canvas' )
Common . UI . Menu . Manager . hideAll ( ) ;
} ) ;
2021-08-06 10:55:26 +00:00
this . editorConfig = { } ;
this . embedConfig = { } ;
this . appOptions = { } ;
2021-11-29 12:02:22 +00:00
this . internalFormObj = null ;
2021-08-06 10:55:26 +00:00
if ( this . api ) {
this . api . asc _registerCallback ( 'asc_onError' , this . onError . bind ( this ) ) ;
this . api . asc _registerCallback ( 'asc_onDocumentContentReady' , this . onDocumentContentReady . bind ( this ) ) ;
this . api . asc _registerCallback ( 'asc_onOpenDocumentProgress' , this . onOpenDocument . bind ( this ) ) ;
this . api . asc _registerCallback ( 'asc_onDocumentUpdateVersion' , this . onUpdateVersion . bind ( this ) ) ;
this . api . asc _registerCallback ( 'asc_onServerVersion' , this . onServerVersion . bind ( this ) ) ;
2021-11-30 10:44:18 +00:00
this . api . asc _registerCallback ( 'asc_onAdvancedOptions' , this . onAdvancedOptions . bind ( this ) ) ;
2021-08-06 10:55:26 +00:00
this . api . asc _registerCallback ( 'asc_onCountPages' , this . onCountPages . bind ( this ) ) ;
this . api . asc _registerCallback ( 'asc_onCurrentPage' , this . onCurrentPage . bind ( this ) ) ;
2021-12-06 09:01:39 +00:00
this . api . asc _registerCallback ( 'asc_onDocumentModifiedChanged' , _ . bind ( this . onDocumentModifiedChanged , this ) ) ;
2021-12-15 13:43:21 +00:00
this . api . asc _registerCallback ( 'asc_onZoomChange' , this . onApiZoomChange . bind ( this ) ) ;
2022-01-24 16:07:47 +00:00
this . api . asc _registerCallback ( 'asc_onCoAuthoringDisconnect' , _ . bind ( this . onApiServerDisconnect , this ) ) ;
Common . NotificationCenter . on ( 'api:disconnect' , _ . bind ( this . onApiServerDisconnect , this ) ) ;
2021-08-06 10:55:26 +00:00
// Initialize api gateway
Common . Gateway . on ( 'init' , this . loadConfig . bind ( this ) ) ;
Common . Gateway . on ( 'opendocument' , this . loadDocument . bind ( this ) ) ;
Common . Gateway . on ( 'showmessage' , this . onExternalMessage . bind ( this ) ) ;
2021-12-07 16:57:04 +00:00
Common . NotificationCenter . on ( 'showmessage' , this . onExternalMessage . bind ( this ) ) ;
2021-08-06 10:55:26 +00:00
Common . Gateway . appReady ( ) ;
}
Common . NotificationCenter . on ( {
'modal:show' : function ( ) {
2021-08-18 23:04:30 +00:00
if ( screenTip ) {
screenTip . toolTip . hide ( ) ;
screenTip . isVisible = false ;
}
2021-08-06 10:55:26 +00:00
Common . Utils . ModalWindow . show ( ) ;
me . api . asc _enableKeyEvents ( false ) ;
} ,
'modal:close' : function ( dlg ) {
Common . Utils . ModalWindow . close ( ) ;
if ( ! Common . Utils . ModalWindow . isVisible ( ) )
me . api . asc _enableKeyEvents ( true ) ;
} ,
'modal:hide' : function ( dlg ) {
Common . Utils . ModalWindow . close ( ) ;
if ( ! Common . Utils . ModalWindow . isVisible ( ) )
me . api . asc _enableKeyEvents ( true ) ;
} ,
'dataview:blur' : function ( e ) {
if ( ! Common . Utils . ModalWindow . isVisible ( ) ) {
me . api . asc _enableKeyEvents ( true ) ;
}
} ,
'menu:hide' : function ( e , isFromInputControl ) {
if ( ! Common . Utils . ModalWindow . isVisible ( ) && ! isFromInputControl )
me . api . asc _enableKeyEvents ( true ) ;
}
} ) ;
$ ( document . body ) . on ( 'blur' , 'input, textarea' , function ( e ) {
if ( ! Common . Utils . ModalWindow . isVisible ( ) ) {
if ( ! /area_id/ . test ( e . target . id ) ) {
me . api . asc _enableKeyEvents ( true ) ;
}
}
} ) ;
window . onbeforeunload = _ . bind ( this . onBeforeUnload , this ) ;
2021-09-01 22:56:21 +00:00
this . warnNoLicense = this . warnNoLicense . replace ( /%1/g , '{{COMPANY_NAME}}' ) ;
this . warnNoLicenseUsers = this . warnNoLicenseUsers . replace ( /%1/g , '{{COMPANY_NAME}}' ) ;
this . textNoLicenseTitle = this . textNoLicenseTitle . replace ( /%1/g , '{{COMPANY_NAME}}' ) ;
this . warnLicenseExceeded = this . warnLicenseExceeded . replace ( /%1/g , '{{COMPANY_NAME}}' ) ;
this . warnLicenseUsersExceeded = this . warnLicenseUsersExceeded . replace ( /%1/g , '{{COMPANY_NAME}}' ) ;
2021-08-06 10:55:26 +00:00
} ,
onDocumentResize : function ( ) {
this . api && this . api . Resize ( ) ;
2021-08-06 17:07:03 +00:00
bodyWidth = $ ( 'body' ) . width ( ) ;
2021-08-06 10:55:26 +00:00
} ,
onBeforeUnload : function ( ) {
Common . localStorage . save ( ) ;
} ,
onError : function ( id , level , errData ) {
if ( id == Asc . c _oAscError . ID . LoadingScriptError ) {
this . showTips ( [ this . scriptLoadError ] ) ;
this . tooltip && this . tooltip . getBSTip ( ) . $tip . css ( 'z-index' , 10000 ) ;
return ;
}
this . hidePreloader ( ) ;
this . onLongActionEnd ( Asc . c _oAscAsyncActionType [ 'BlockInteraction' ] , LoadingDocument ) ;
var config = {
closable : true
} ;
switch ( id )
{
case Asc . c _oAscError . ID . Unknown :
config . msg = this . unknownErrorText ;
break ;
case Asc . c _oAscError . ID . ConvertationTimeout :
config . msg = this . convertationTimeoutText ;
break ;
case Asc . c _oAscError . ID . ConvertationError :
config . msg = this . convertationErrorText ;
break ;
2021-11-26 11:10:44 +00:00
case Asc . c _oAscError . ID . ConvertationOpenError :
config . msg = this . openErrorText ;
break ;
2021-08-06 10:55:26 +00:00
case Asc . c _oAscError . ID . DownloadError :
config . msg = this . downloadErrorText ;
break ;
2021-11-11 11:07:18 +00:00
case Asc . c _oAscError . ID . UplImageSize :
config . msg = this . uploadImageSizeMessage ;
break ;
case Asc . c _oAscError . ID . UplImageExt :
config . msg = this . uploadImageExtMessage ;
break ;
2021-08-06 10:55:26 +00:00
case Asc . c _oAscError . ID . ConvertationPassword :
config . msg = this . errorFilePassProtect ;
break ;
case Asc . c _oAscError . ID . UserDrop :
config . msg = this . errorUserDrop ;
break ;
case Asc . c _oAscError . ID . ConvertationOpenLimitError :
config . msg = this . errorFileSizeExceed ;
break ;
case Asc . c _oAscError . ID . UpdateVersion :
config . msg = this . errorUpdateVersionOnDisconnect ;
2022-04-20 15:18:15 +00:00
config . maxwidth = 600 ;
2021-08-06 10:55:26 +00:00
break ;
case Asc . c _oAscError . ID . AccessDeny :
config . msg = this . errorAccessDeny ;
break ;
case Asc . c _oAscError . ID . Submit :
config . msg = this . errorSubmit ;
2021-08-19 20:09:18 +00:00
_submitFail = true ;
this . submitedTooltip && this . submitedTooltip . hide ( ) ;
2021-08-06 10:55:26 +00:00
break ;
case Asc . c _oAscError . ID . EditingError :
2021-11-30 13:25:51 +00:00
config . msg = ( this . appOptions . isDesktopApp && this . appOptions . isOffline ) ? this . errorEditingSaveas : this . errorEditingDownloadas ;
2021-08-06 10:55:26 +00:00
break ;
case Asc . c _oAscError . ID . ForceSaveButton :
case Asc . c _oAscError . ID . ForceSaveTimeout :
config . msg = this . errorForceSave ;
2022-04-20 15:18:15 +00:00
config . maxwidth = 600 ;
2021-08-06 10:55:26 +00:00
break ;
2021-10-01 12:23:16 +00:00
case Asc . c _oAscError . ID . LoadingFontError :
config . msg = this . errorLoadingFont ;
break ;
2021-11-01 14:16:20 +00:00
case Asc . c _oAscError . ID . Warning :
config . msg = this . errorConnectToServer ;
config . closable = false ;
break ;
2021-11-30 09:47:56 +00:00
case Asc . c _oAscError . ID . VKeyEncrypt :
config . msg = this . errorToken ;
break ;
2021-11-01 14:16:20 +00:00
case Asc . c _oAscError . ID . KeyExpire :
config . msg = this . errorTokenExpire ;
break ;
2021-11-11 11:07:18 +00:00
case Asc . c _oAscError . ID . CoAuthoringDisconnect :
config . msg = this . errorViewerDisconnect ;
break ;
2021-11-30 09:47:56 +00:00
case Asc . c _oAscError . ID . SessionAbsolute :
config . msg = this . errorSessionAbsolute ;
break ;
case Asc . c _oAscError . ID . SessionIdle :
config . msg = this . errorSessionIdle ;
break ;
case Asc . c _oAscError . ID . SessionToken :
config . msg = this . errorSessionToken ;
break ;
case Asc . c _oAscError . ID . UplImageUrl :
config . msg = this . errorBadImageUrl ;
break ;
case Asc . c _oAscError . ID . DataEncrypted :
config . msg = this . errorDataEncrypted ;
break ;
2021-11-30 13:25:51 +00:00
case Asc . c _oAscError . ID . ConvertationSaveError :
config . msg = ( this . appOptions . isDesktopApp && this . appOptions . isOffline ) ? this . saveErrorTextDesktop : this . saveErrorText ;
break ;
2022-09-08 12:36:27 +00:00
case Asc . c _oAscError . ID . TextFormWrongFormat :
config . msg = this . errorTextFormWrongFormat ;
break ;
2021-08-06 10:55:26 +00:00
default :
config . msg = ( typeof id == 'string' ) ? id : this . errorDefaultMessage . replace ( '%1' , id ) ;
break ;
}
if ( level == Asc . c _oAscError . Level . Critical ) {
// report only critical errors
Common . Gateway . reportError ( id , config . msg ) ;
config . title = this . criticalErrorTitle ;
config . iconCls = 'error' ;
config . closable = false ;
config . callback = _ . bind ( function ( btn ) {
window . location . reload ( ) ;
} , this ) ;
if ( id == Asc . c _oAscError . ID . DataEncrypted ) {
this . api . asc _coAuthoringDisconnect ( ) ;
Common . NotificationCenter . trigger ( 'api:disconnect' ) ;
}
}
else {
Common . Gateway . reportWarning ( id , config . msg ) ;
config . title = this . notcriticalErrorTitle ;
config . iconCls = 'warn' ;
config . buttons = [ 'ok' ] ;
config . callback = _ . bind ( function ( btn ) {
2021-11-01 14:16:20 +00:00
if ( id == Asc . c _oAscError . ID . Warning && btn == 'ok' && this . appOptions . canDownload ) {
Common . UI . Menu . Manager . hideAll ( ) ;
2021-11-30 13:25:51 +00:00
if ( this . appOptions . isDesktopApp && this . appOptions . isOffline )
this . api . asc _DownloadAs ( ) ;
else {
var me = this ;
setTimeout ( function ( ) {
$ ( 'button' , me . view . btnOptions . cmpEl ) . click ( ) ;
} , 10 ) ;
}
2021-11-01 14:16:20 +00:00
} else if ( id == Asc . c _oAscError . ID . EditingError ) {
2021-08-06 10:55:26 +00:00
Common . NotificationCenter . trigger ( 'api:disconnect' , true ) ; // enable download and print
}
} , this ) ;
}
if ( ! Common . Utils . ModalWindow . isVisible ( ) || $ ( '.asc-window.modal.alert[data-value=' + id + ']' ) . length < 1 )
Common . UI . alert ( config ) . $window . attr ( 'data-value' , id ) ;
( id !== undefined ) && Common . component . Analytics . trackEvent ( 'Internal Error' , id . toString ( ) ) ;
} ,
hidePreloader : function ( ) {
2021-08-18 21:52:04 +00:00
$ ( '#loading-mask' ) . fadeOut ( 'slow' ) ;
2021-08-06 10:55:26 +00:00
} ,
onOpenDocument : function ( progress ) {
var elem = document . getElementById ( 'loadmask-text' ) ;
var proc = ( progress . asc _getCurrentFont ( ) + progress . asc _getCurrentImage ( ) ) / ( progress . asc _getFontsCount ( ) + progress . asc _getImagesCount ( ) ) ;
proc = this . textLoadingDocument + ': ' + Common . Utils . String . fixedDigits ( Math . min ( Math . round ( proc * 100 ) , 100 ) , 3 , " " ) + "%" ;
elem ? elem . innerHTML = proc : this . loadMask && this . loadMask . setTitle ( proc ) ;
} ,
onCountPages : function ( count ) {
2022-10-10 19:34:05 +00:00
if ( maxPages !== count ) {
maxPages = count ;
2022-10-10 19:26:42 +00:00
$ ( '#pages' ) . text ( this . textOf + " " + count ) ;
2022-10-10 19:34:05 +00:00
}
2021-08-06 10:55:26 +00:00
} ,
onCurrentPage : function ( number ) {
2021-08-18 21:52:04 +00:00
this . view . txtGoToPage . setValue ( number + 1 ) ;
2021-08-06 10:55:26 +00:00
} ,
2021-12-06 09:01:39 +00:00
updateWindowTitle : function ( force ) {
var isModified = this . api . isDocumentModified ( ) ;
if ( this . _state . isDocModified !== isModified || force ) {
this . _isDocReady && ( this . _state . isDocModified !== isModified ) && Common . Gateway . setDocumentModified ( isModified ) ;
this . _state . isDocModified = isModified ;
}
} ,
onDocumentModifiedChanged : function ( ) {
var isModified = this . api . asc _isDocumentCanSave ( ) ;
if ( this . _state . isDocModified !== isModified ) {
this . _isDocReady && Common . Gateway . setDocumentModified ( this . api . isDocumentModified ( ) ) ;
}
this . updateWindowTitle ( ) ;
} ,
2021-08-06 10:55:26 +00:00
loadConfig : function ( data ) {
this . editorConfig = $ . extend ( this . editorConfig , data . config ) ;
this . embedConfig = $ . extend ( this . embedConfig , data . config . embedded ) ;
2021-08-20 20:47:34 +00:00
$ ( '#toolbar' ) . addClass ( 'top' ) ;
this . boxSdk . addClass ( 'top' ) ;
ttOffset [ 1 ] = 40 ;
2021-08-06 10:55:26 +00:00
this . appOptions . customization = this . editorConfig . customization ;
this . appOptions . canRenameAnonymous = ! ( ( typeof ( this . appOptions . customization ) == 'object' ) && ( typeof ( this . appOptions . customization . anonymous ) == 'object' ) && ( this . appOptions . customization . anonymous . request === false ) ) ;
this . appOptions . guestName = ( typeof ( this . appOptions . customization ) == 'object' ) && ( typeof ( this . appOptions . customization . anonymous ) == 'object' ) &&
( typeof ( this . appOptions . customization . anonymous . label ) == 'string' ) && this . appOptions . customization . anonymous . label . trim ( ) !== '' ?
Common . Utils . String . htmlEncode ( this . appOptions . customization . anonymous . label ) : this . textGuest ;
var value ;
if ( this . appOptions . canRenameAnonymous ) {
value = Common . localStorage . getItem ( "guest-username" ) ;
Common . Utils . InternalSettings . set ( "guest-username" , value ) ;
Common . Utils . InternalSettings . set ( "save-guest-username" , ! ! value ) ;
}
this . editorConfig . user =
this . appOptions . user = Common . Utils . fillUserInfo ( this . editorConfig . user , this . editorConfig . lang , value ? ( value + ' (' + this . appOptions . guestName + ')' ) : this . textAnonymous ,
Common . localStorage . getItem ( "guest-id" ) || ( 'uid-' + Date . now ( ) ) ) ;
this . appOptions . user . anonymous && Common . localStorage . setItem ( "guest-id" , this . appOptions . user . id ) ;
this . appOptions . canRequestClose = this . editorConfig . canRequestClose ;
this . appOptions . canBackToFolder = ( this . editorConfig . canBackToFolder !== false ) && ( typeof ( this . editorConfig . customization ) == 'object' ) && ( typeof ( this . editorConfig . customization . goback ) == 'object' )
&& ( ! _ . isEmpty ( this . editorConfig . customization . goback . url ) || this . editorConfig . customization . goback . requestClose && this . appOptions . canRequestClose ) ;
2021-11-29 12:02:22 +00:00
this . appOptions . canRequestInsertImage = this . editorConfig . canRequestInsertImage ;
this . appOptions . fileChoiceUrl = this . editorConfig . fileChoiceUrl ;
2021-11-29 20:39:18 +00:00
this . appOptions . saveAsUrl = this . editorConfig . saveAsUrl ;
this . appOptions . canRequestSaveAs = this . editorConfig . canRequestSaveAs ;
2021-12-01 09:21:08 +00:00
this . appOptions . isDesktopApp = this . editorConfig . targetApp == 'desktop' ;
2022-02-22 15:23:37 +00:00
this . appOptions . lang = this . editorConfig . lang ;
this . appOptions . canPlugins = false ;
2021-08-06 10:55:26 +00:00
} ,
onExternalMessage : function ( msg ) {
if ( msg && msg . msg ) {
msg . msg = ( msg . msg ) . toString ( ) ;
this . showTips ( [ msg . msg . charAt ( 0 ) . toUpperCase ( ) + msg . msg . substring ( 1 ) ] ) ;
Common . component . Analytics . trackEvent ( 'External Error' ) ;
}
} ,
showTips : function ( strings ) {
var me = this ;
if ( ! strings . length ) return ;
if ( typeof ( strings ) != 'object' ) strings = [ strings ] ;
function showNextTip ( ) {
var str _tip = strings . shift ( ) ;
if ( str _tip ) {
str _tip += '\n' + me . textCloseTip ;
tooltip . setTitle ( str _tip ) ;
tooltip . show ( ) ;
}
}
if ( ! this . tooltip ) {
this . tooltip = new Common . UI . Tooltip ( {
owner : $ ( '#toolbar' ) ,
hideonclick : true ,
placement : 'bottom' ,
cls : 'main-info' ,
offset : 30
} ) ;
}
var tooltip = this . tooltip ;
tooltip . on ( 'tooltip:hide' , function ( ) {
setTimeout ( showNextTip , 300 ) ;
} ) ;
showNextTip ( ) ;
} ,
loadDocument : function ( data ) {
this . permissions = { } ;
this . document = data . doc ;
var docInfo = { } ;
if ( data . doc ) {
this . permissions = $ . extend ( this . permissions , data . doc . permissions ) ;
2022-05-16 16:53:13 +00:00
var _options = $ . extend ( { } , data . doc . options , this . editorConfig . actionLink || { } ) ;
2021-08-06 10:55:26 +00:00
var _user = new Asc . asc _CUserInfo ( ) ;
_user . put _Id ( this . appOptions . user . id ) ;
_user . put _FullName ( this . appOptions . user . fullname ) ;
_user . put _IsAnonymousUser ( ! ! this . appOptions . user . anonymous ) ;
docInfo = new Asc . asc _CDocInfo ( ) ;
docInfo . put _Id ( data . doc . key ) ;
docInfo . put _Url ( data . doc . url ) ;
2022-07-29 10:44:00 +00:00
docInfo . put _DirectUrl ( data . doc . directUrl ) ;
2021-08-06 10:55:26 +00:00
docInfo . put _Title ( data . doc . title ) ;
docInfo . put _Format ( data . doc . fileType ) ;
docInfo . put _VKey ( data . doc . vkey ) ;
docInfo . put _Options ( _options ) ;
docInfo . put _UserInfo ( _user ) ;
docInfo . put _CallbackUrl ( this . editorConfig . callbackUrl ) ;
docInfo . put _Token ( data . doc . token ) ;
2022-05-16 16:53:13 +00:00
docInfo . put _Permissions ( data . doc . permissions ) ;
2021-08-06 10:55:26 +00:00
docInfo . put _EncryptedInfo ( this . editorConfig . encryptionKeys ) ;
2021-08-31 13:12:30 +00:00
docInfo . put _Lang ( this . editorConfig . lang ) ;
docInfo . put _Mode ( this . editorConfig . mode ) ;
2021-08-06 10:55:26 +00:00
var enable = ! this . editorConfig . customization || ( this . editorConfig . customization . macros !== false ) ;
docInfo . asc _putIsEnabledMacroses ( ! ! enable ) ;
enable = ! this . editorConfig . customization || ( this . editorConfig . customization . plugins !== false ) ;
docInfo . asc _putIsEnabledPlugins ( ! ! enable ) ;
2022-02-11 14:54:01 +00:00
var type = /^(?:(pdf|djvu|xps|oxps))$/ . exec ( data . doc . fileType ) ;
2021-08-06 10:55:26 +00:00
if ( type && typeof type [ 1 ] === 'string' ) {
this . permissions . edit = this . permissions . review = false ;
}
}
2021-11-18 13:14:23 +00:00
labelDocName = $ ( '#title-doc-name' ) ;
if ( data . doc ) {
labelDocName . text ( data . doc . title || '' ) ;
this . embedConfig . docTitle = data . doc . title ;
}
2021-08-06 10:55:26 +00:00
this . api . asc _registerCallback ( 'asc_onGetEditorPermissions' , _ . bind ( this . onEditorPermissions , this ) ) ;
this . api . asc _registerCallback ( 'asc_onRunAutostartMacroses' , _ . bind ( this . onRunAutostartMacroses , this ) ) ;
2022-01-17 09:01:35 +00:00
this . api . asc _registerCallback ( 'asc_onLicenseChanged' , _ . bind ( this . onLicenseChanged , this ) ) ;
2021-08-06 10:55:26 +00:00
this . api . asc _setDocInfo ( docInfo ) ;
this . api . asc _getEditorPermissions ( this . editorConfig . licenseUrl , this . editorConfig . customerId ) ;
this . api . asc _enableKeyEvents ( true ) ;
Common . Analytics . trackEvent ( 'Load' , 'Start' ) ;
} ,
onRunAutostartMacroses : function ( ) {
if ( ! this . editorConfig . customization || ( this . editorConfig . customization . macros !== false ) ) {
this . api . asc _runAutostartMacroses ( ) ;
}
} ,
onEditorPermissions : function ( params ) {
var licType = params . asc _getLicenseType ( ) ;
if ( Asc . c _oLicenseResult . Expired === licType || Asc . c _oLicenseResult . Error === licType || Asc . c _oLicenseResult . ExpiredTrial === licType ) {
Common . UI . warning ( {
title : this . titleLicenseExp ,
msg : this . warnLicenseExp ,
buttons : [ ] ,
closable : false
} ) ;
return ;
}
if ( Asc . c _oLicenseResult . ExpiredLimited === licType )
this . _state . licenseType = licType ;
if ( this . onServerVersion ( params . asc _getBuildVersion ( ) ) ) return ;
this . permissions . review = ( this . permissions . review === undefined ) ? ( this . permissions . edit !== false ) : this . permissions . review ;
if ( params . asc _getRights ( ) !== Asc . c _oRights . Edit )
this . permissions . edit = this . permissions . review = false ;
2021-12-01 09:21:08 +00:00
this . appOptions . isOffline = this . api . asc _isOffline ( ) ;
2021-09-01 22:56:21 +00:00
this . appOptions . trialMode = params . asc _getLicenseMode ( ) ;
this . appOptions . isBeta = params . asc _getIsBeta ( ) ;
2021-08-06 10:55:26 +00:00
this . appOptions . canLicense = ( licType === Asc . c _oLicenseResult . Success || licType === Asc . c _oLicenseResult . SuccessLimit ) ;
2021-11-30 13:25:51 +00:00
this . appOptions . canSubmitForms = this . appOptions . canLicense && ( typeof ( this . editorConfig . customization ) == 'object' ) && ! ! this . editorConfig . customization . submitForm && ! this . appOptions . isOffline ;
2021-10-21 18:17:50 +00:00
var type = /^(?:(oform))$/ . exec ( this . document . fileType ) ; // can fill forms only in oform format
2021-11-29 16:48:09 +00:00
this . appOptions . isOFORM = ! ! ( type && typeof type [ 1 ] === 'string' ) ;
this . appOptions . canFillForms = this . appOptions . canLicense && this . appOptions . isOFORM && ( ( this . permissions . fillForms === undefined ) ? ( this . permissions . edit !== false ) : this . permissions . fillForms ) && ( this . editorConfig . mode !== 'view' ) ;
2021-08-06 10:55:26 +00:00
this . api . asc _setViewMode ( ! this . appOptions . canFillForms ) ;
2021-10-04 18:08:02 +00:00
this . appOptions . canBranding = params . asc _getCustomization ( ) ;
this . appOptions . canBranding && this . setBranding ( this . appOptions . customization ) ;
2021-09-29 14:45:40 +00:00
this . appOptions . canDownload = this . permissions . download !== false ;
2021-08-06 10:55:26 +00:00
this . appOptions . canPrint = ( this . permissions . print !== false ) ;
this . appOptions . fileKey = this . document . key ;
AscCommon . UserInfoParser . setParser ( true ) ;
AscCommon . UserInfoParser . setCurrentName ( this . appOptions . user . fullname ) ;
2022-02-22 15:23:37 +00:00
DE . getController ( 'Plugins' ) . setMode ( this . appOptions , this . api ) ;
2021-08-18 18:29:47 +00:00
var me = this ;
2021-08-19 20:09:18 +00:00
me . view . btnSubmit . setVisible ( this . appOptions . canFillForms && this . appOptions . canSubmitForms ) ;
2021-10-29 17:15:38 +00:00
me . view . btnDownload . setVisible ( this . appOptions . canDownload && this . appOptions . canFillForms && ! this . appOptions . canSubmitForms ) ;
2021-11-30 13:25:51 +00:00
if ( me . appOptions . isOffline || me . appOptions . canRequestSaveAs || ! ! me . appOptions . saveAsUrl ) {
me . view . btnDownload . setCaption ( me . appOptions . isOffline ? me . textSaveAsDesktop : me . textSaveAs ) ;
me . view . btnDownload . updateHint ( '' ) ;
2021-11-30 11:12:25 +00:00
}
2021-08-06 10:55:26 +00:00
if ( ! this . appOptions . canFillForms ) {
2021-08-18 18:29:47 +00:00
me . view . btnPrev . setVisible ( false ) ;
me . view . btnNext . setVisible ( false ) ;
me . view . btnClear . setVisible ( false ) ;
2021-08-06 10:55:26 +00:00
} else {
2021-08-18 18:29:47 +00:00
me . view . btnPrev . on ( 'click' , function ( ) {
2021-08-06 10:55:26 +00:00
me . api . asc _MoveToFillingForm ( false ) ;
} ) ;
2021-08-18 18:29:47 +00:00
me . view . btnNext . on ( 'click' , function ( ) {
2021-08-06 10:55:26 +00:00
me . api . asc _MoveToFillingForm ( true ) ;
} ) ;
2021-08-18 18:29:47 +00:00
me . view . btnClear . on ( 'click' , function ( ) {
2021-08-06 10:55:26 +00:00
me . api . asc _ClearAllSpecialForms ( ) ;
} ) ;
2021-08-19 20:09:18 +00:00
me . view . btnSubmit . on ( 'click' , function ( ) {
me . api . asc _SendForm ( ) ;
} ) ;
2021-10-29 17:15:38 +00:00
me . view . btnDownload . on ( 'click' , function ( ) {
2021-11-29 20:39:18 +00:00
if ( me . appOptions . canDownload ) {
2021-11-30 13:25:51 +00:00
if ( me . appOptions . isOffline )
me . api . asc _DownloadAs ( new Asc . asc _CDownloadOptions ( Asc . c _oAscFileType . PDF ) ) ;
else {
me . isFromBtnDownload = me . appOptions . canRequestSaveAs || ! ! me . appOptions . saveAsUrl ;
me . api . asc _DownloadAs ( new Asc . asc _CDownloadOptions ( Asc . c _oAscFileType . PDF , me . isFromBtnDownload ) ) ;
}
2021-11-29 20:39:18 +00:00
}
2021-10-29 17:15:38 +00:00
} ) ;
2021-08-06 10:55:26 +00:00
this . api . asc _setRestriction ( Asc . c _oAscRestrictionType . OnlyForms ) ;
this . api . asc _SetFastCollaborative ( true ) ;
this . api . asc _setAutoSaveGap ( 1 ) ;
2021-11-17 09:38:52 +00:00
this . api . SetCollaborativeMarksShowType ( Asc . c _oAscCollaborativeMarksShowType . None ) ;
2021-08-06 10:55:26 +00:00
}
this . onLongActionBegin ( Asc . c _oAscAsyncActionType [ 'BlockInteraction' ] , LoadingDocument ) ;
this . api . asc _LoadDocument ( ) ;
this . api . Resize ( ) ;
} ,
onServerVersion : function ( buildVersion ) {
if ( this . changeServerVersion ) return true ;
if ( DocsAPI . DocEditor . version ( ) !== buildVersion && ! window . compareVersions ) {
this . changeServerVersion = true ;
Common . UI . warning ( {
title : this . titleServerVersion ,
msg : this . errorServerVersion ,
callback : function ( ) {
_ . defer ( function ( ) {
Common . Gateway . updateVersion ( ) ;
} )
}
} ) ;
return true ;
}
return false ;
} ,
onUpdateVersion : function ( callback ) {
var me = this ;
me . needToUpdateVersion = true ;
me . onLongActionEnd ( Asc . c _oAscAsyncActionType [ 'BlockInteraction' ] , LoadingDocument ) ;
Common . UI . warning ( {
title : this . titleUpdateVersion ,
msg : this . errorUpdateVersion ,
callback : function ( ) {
_ . defer ( function ( ) {
Common . Gateway . updateVersion ( ) ;
if ( callback ) callback . call ( me ) ;
me . onLongActionBegin ( Asc . c _oAscAsyncActionType [ 'BlockInteraction' ] , LoadingDocument ) ;
} )
}
} ) ;
} ,
2022-01-17 09:01:35 +00:00
onLicenseChanged : function ( params ) {
var licType = params . asc _getLicenseType ( ) ;
if ( licType !== undefined && this . appOptions . canFillForms &&
( licType === Asc . c _oLicenseResult . Connections || licType === Asc . c _oLicenseResult . UsersCount || licType === Asc . c _oLicenseResult . ConnectionsOS || licType === Asc . c _oLicenseResult . UsersCountOS
|| licType === Asc . c _oLicenseResult . SuccessLimit && ( this . appOptions . trialMode & Asc . c _oLicenseMode . Limited ) !== 0 ) )
this . _state . licenseType = licType ;
if ( this . _isDocReady )
this . applyLicense ( ) ;
} ,
2021-09-01 22:56:21 +00:00
applyLicense : function ( ) {
if ( this . _state . licenseType ) {
var license = this . _state . licenseType ,
buttons = [ 'ok' ] ,
primary = 'ok' ;
if ( ( this . appOptions . trialMode & Asc . c _oLicenseMode . Limited ) !== 0 &&
( license === Asc . c _oLicenseResult . SuccessLimit || license === Asc . c _oLicenseResult . ExpiredLimited || this . appOptions . permissionsLicense === Asc . c _oLicenseResult . SuccessLimit ) ) {
license = ( license === Asc . c _oLicenseResult . ExpiredLimited ) ? this . warnLicenseLimitedNoAccess : this . warnLicenseLimitedRenewed ;
} else if ( license === Asc . c _oLicenseResult . Connections || license === Asc . c _oLicenseResult . UsersCount ) {
license = ( license === Asc . c _oLicenseResult . Connections ) ? this . warnLicenseExceeded : this . warnLicenseUsersExceeded ;
} else {
license = ( license === Asc . c _oLicenseResult . ConnectionsOS ) ? this . warnNoLicense : this . warnNoLicenseUsers ;
buttons = [ { value : 'buynow' , caption : this . textBuyNow } , { value : 'contact' , caption : this . textContactUs } ] ;
primary = 'buynow' ;
}
2022-01-17 15:09:45 +00:00
if ( this . _state . licenseType !== Asc . c _oLicenseResult . SuccessLimit && this . appOptions . canFillForms ) {
2022-01-24 16:07:47 +00:00
Common . NotificationCenter . trigger ( 'api:disconnect' ) ;
2022-01-17 15:09:45 +00:00
}
2021-09-01 22:56:21 +00:00
var value = Common . localStorage . getItem ( "de-license-warning" ) ;
value = ( value !== null ) ? parseInt ( value ) : 0 ;
var now = ( new Date ) . getTime ( ) ;
if ( now - value > 86400000 ) {
Common . UI . info ( {
maxwidth : 500 ,
title : this . textNoLicenseTitle ,
msg : license ,
buttons : buttons ,
primary : primary ,
callback : function ( btn ) {
Common . localStorage . setItem ( "de-license-warning" , now ) ;
if ( btn == 'buynow' )
window . open ( '{{PUBLISHER_URL}}' , "_blank" ) ;
else if ( btn == 'contact' )
window . open ( 'mailto:{{SALES_EMAIL}}' , "_blank" ) ;
}
} ) ;
}
}
} ,
2021-10-04 18:08:02 +00:00
setBranding : function ( value ) {
if ( value && value . logo ) {
var logo = $ ( '#header-logo' ) ;
2021-10-04 20:15:06 +00:00
if ( value . logo . image || value . logo . imageDark ) {
var image = Common . UI . Themes . isDarkTheme ( ) ? ( value . logo . imageDark || value . logo . image ) : ( value . logo . image || value . logo . imageDark ) ;
logo . html ( '<img src="' + image + '" style="max-width:100px; max-height:20px;"/>' ) ;
2021-10-04 18:08:02 +00:00
logo . css ( { 'background-image' : 'none' , width : 'auto' , height : 'auto' } ) ;
}
if ( value . logo . url ) {
logo . attr ( 'href' , value . logo . url ) ;
} else if ( value . logo . url !== undefined ) {
logo . removeAttr ( 'href' ) ; logo . removeAttr ( 'target' ) ;
}
}
} ,
2021-08-06 10:55:26 +00:00
onLongActionBegin : function ( type , id ) {
var action = { id : id , type : type } ;
this . stackLongActions . push ( action ) ;
this . setLongActionView ( action ) ;
} ,
setLongActionView : function ( action ) {
var title = '' , text = '' , force = false ;
switch ( action . id )
{
case Asc . c _oAscAsyncAction [ 'Print' ] :
text = this . downloadTextText ;
break ;
case Asc . c _oAscAsyncAction [ 'Submit' ] :
_submitFail = false ;
2021-08-19 20:09:18 +00:00
this . submitedTooltip && this . submitedTooltip . hide ( ) ;
this . view . btnSubmit . setDisabled ( true ) ;
this . view . btnSubmit . cmpEl . css ( "pointer-events" , "none" ) ;
2021-08-06 10:55:26 +00:00
break ;
case LoadingDocument :
text = this . textLoadingDocument + ' ' ;
break ;
default :
text = this . waitText ;
break ;
}
if ( action . type == Asc . c _oAscAsyncActionType [ 'BlockInteraction' ] ) {
if ( ! this . loadMask )
this . loadMask = new Common . UI . LoadMask ( { owner : $ ( document . body ) } ) ;
this . loadMask . setTitle ( text ) ;
this . loadMask . show ( ) ;
}
} ,
2021-11-30 10:44:18 +00:00
onLongActionEnd : function ( type , id ) {
2021-08-06 10:55:26 +00:00
var action = { id : id , type : type } ;
this . stackLongActions . pop ( action ) ;
2021-12-06 09:01:39 +00:00
this . updateWindowTitle ( true ) ;
2021-08-06 10:55:26 +00:00
action = this . stackLongActions . get ( { type : Asc . c _oAscAsyncActionType . Information } ) ;
action && this . setLongActionView ( action ) ;
action = this . stackLongActions . get ( { type : Asc . c _oAscAsyncActionType . BlockInteraction } ) ;
action ? this . setLongActionView ( action ) : this . loadMask && this . loadMask . hide ( ) ;
if ( id == Asc . c _oAscAsyncAction [ 'Submit' ] ) {
2021-08-19 20:09:18 +00:00
this . view . btnSubmit . setDisabled ( false ) ;
this . view . btnSubmit . cmpEl . css ( "pointer-events" , "auto" ) ;
2021-08-06 10:55:26 +00:00
if ( ! _submitFail ) {
2021-08-19 20:09:18 +00:00
if ( ! this . submitedTooltip ) {
var me = this ;
this . submitedTooltip = $ ( '<div class="submit-tooltip" style="display:none;">' + this . textSubmited + '</div>' ) ;
$ ( document . body ) . append ( this . submitedTooltip ) ;
this . submitedTooltip . on ( 'click' , function ( ) { me . submitedTooltip . hide ( ) ; } ) ;
2021-08-06 10:55:26 +00:00
}
2021-08-19 20:09:18 +00:00
this . submitedTooltip . show ( ) ;
2021-08-06 10:55:26 +00:00
}
}
2021-10-26 08:27:25 +00:00
if ( type == Asc . c _oAscAsyncActionType . BlockInteraction &&
! ( ( id == Asc . c _oAscAsyncAction [ 'LoadDocumentFonts' ] || id == Asc . c _oAscAsyncAction [ 'ApplyChanges' ] || id == Asc . c _oAscAsyncAction [ 'DownloadAs' ] ) && Common . Utils . ModalWindow . isVisible ( ) ) ) {
this . api . asc _enableKeyEvents ( true ) ;
}
2021-08-06 10:55:26 +00:00
} ,
2021-11-30 10:44:18 +00:00
onAdvancedOptions : function ( type , advOptions , mode , formatOptions ) {
if ( this . _openDlg ) return ;
var me = this ;
if ( type == Asc . c _oAscAdvancedOptionsID . DRM ) {
me . _openDlg = new Common . Views . OpenDialog ( {
title : Common . Views . OpenDialog . prototype . txtTitleProtected ,
closeFile : me . appOptions . canRequestClose ,
type : Common . Utils . importTextType . DRM ,
warning : ! ( me . appOptions . isDesktopApp && me . appOptions . isOffline ) && ( typeof advOptions == 'string' ) ,
warningMsg : advOptions ,
validatePwd : ! ! me . _isDRM ,
2022-05-19 21:01:09 +00:00
iconType : 'svg' ,
2021-11-30 10:44:18 +00:00
handler : function ( result , value ) {
me . isShowOpenDialog = false ;
if ( result == 'ok' ) {
if ( me . api ) {
me . api . asc _setAdvancedOptions ( type , value . drmOptions ) ;
me . loadMask && me . loadMask . show ( ) ;
}
} else {
Common . Gateway . requestClose ( ) ;
2022-01-10 11:46:38 +00:00
DE . Controllers . Desktop . requestClose ( ) ;
2021-11-30 10:44:18 +00:00
}
me . _openDlg = null ;
}
} ) ;
me . _isDRM = true ;
}
if ( me . _openDlg ) {
this . isShowOpenDialog = true ;
this . loadMask && this . loadMask . hide ( ) ;
this . onLongActionEnd ( Asc . c _oAscAsyncActionType . BlockInteraction , LoadingDocument ) ;
me . _openDlg . show ( ) ;
}
} ,
2021-08-06 10:55:26 +00:00
onDocMouseMoveStart : function ( ) {
2021-08-18 23:04:30 +00:00
screenTip . isHidden = true ;
2021-08-06 10:55:26 +00:00
} ,
onDocMouseMoveEnd : function ( ) {
2021-08-18 23:04:30 +00:00
var me = this ;
if ( screenTip . isHidden && screenTip . isVisible ) {
screenTip . isVisible = false ;
isTooltipHiding = true ;
screenTip . toolTip . hide ( function ( ) {
isTooltipHiding = false ;
if ( mouseMoveData ) me . onDocMouseMove ( mouseMoveData ) ;
mouseMoveData = null ;
} ) ;
2021-08-06 10:55:26 +00:00
}
} ,
onDocMouseMove : function ( data ) {
2021-08-06 17:07:03 +00:00
var me = this ;
2021-08-06 10:55:26 +00:00
if ( data ) {
2021-08-06 17:07:03 +00:00
var type = data . get _Type ( ) ;
if ( type == Asc . c _oAscMouseMoveDataTypes . Hyperlink || type == Asc . c _oAscMouseMoveDataTypes . Form ) { // hyperlink
2021-08-18 23:04:30 +00:00
if ( isTooltipHiding ) {
mouseMoveData = data ;
return ;
}
2021-08-06 10:55:26 +00:00
2021-08-06 17:07:03 +00:00
var str = ( type == Asc . c _oAscMouseMoveDataTypes . Hyperlink ) ? me . txtPressLink : data . get _FormHelpText ( ) ;
if ( str . length > 500 )
str = str . substr ( 0 , 500 ) + '...' ;
str = Common . Utils . String . htmlEncode ( str ) ;
2021-08-18 23:04:30 +00:00
var recalc = false ;
screenTip . isHidden = false ;
if ( screenTip . tipType !== type || screenTip . tipLength !== str . length || screenTip . strTip . indexOf ( str ) < 0 ) {
screenTip . toolTip . setTitle ( str ) ;
screenTip . tipLength = str . length ;
screenTip . strTip = str ;
screenTip . tipType = type ;
recalc = true ;
2021-08-06 10:55:26 +00:00
}
2021-08-18 23:04:30 +00:00
var showPoint = [ data . get _X ( ) + 5 , data . get _Y ( ) + ttOffset [ 1 ] - 15 ] ;
2021-08-06 17:07:03 +00:00
2021-08-18 23:04:30 +00:00
if ( ! screenTip . isVisible || recalc ) {
screenTip . isVisible = true ;
screenTip . toolTip . show ( [ - 10000 , - 10000 ] ) ;
}
if ( recalc ) {
screenTip . tipHeight = screenTip . toolTip . getBSTip ( ) . $tip . height ( ) ;
screenTip . tipWidth = screenTip . toolTip . getBSTip ( ) . $tip . width ( ) ;
}
2021-08-06 17:07:03 +00:00
! bodyWidth && ( bodyWidth = $ ( 'body' ) . width ( ) ) ;
2021-08-18 23:04:30 +00:00
recalc = false ;
if ( showPoint [ 0 ] + screenTip . tipWidth > bodyWidth ) {
showPoint [ 0 ] = bodyWidth - screenTip . tipWidth ;
recalc = true ;
2021-08-06 10:55:26 +00:00
}
2021-08-18 23:04:30 +00:00
if ( showPoint [ 1 ] - screenTip . tipHeight < 0 ) {
showPoint [ 1 ] = ( recalc ) ? showPoint [ 1 ] + 30 : 0 ;
} else
showPoint [ 1 ] -= screenTip . tipHeight ;
screenTip . toolTip . getBSTip ( ) . $tip . css ( { top : showPoint [ 1 ] + 'px' , left : showPoint [ 0 ] + 'px' } ) ;
2021-08-06 10:55:26 +00:00
}
}
} ,
2021-11-29 20:39:18 +00:00
onDownloadUrl : function ( url , fileType ) {
if ( this . isFromBtnDownload ) { // download as pdf
var me = this ,
defFileName = this . embedConfig . docTitle ;
! defFileName && ( defFileName = me . txtUntitled ) ;
var idx = defFileName . lastIndexOf ( '.' ) ;
if ( idx > 0 )
defFileName = defFileName . substring ( 0 , idx ) + '.pdf' ;
if ( me . appOptions . canRequestSaveAs ) {
Common . Gateway . requestSaveAs ( url , defFileName , fileType ) ;
} else {
me . _saveCopyDlg = new Common . Views . SaveAsDlg ( {
saveFolderUrl : me . appOptions . saveAsUrl ,
saveFileUrl : url ,
defFileName : defFileName
} ) ;
me . _saveCopyDlg . on ( 'saveaserror' , function ( obj , err ) {
Common . UI . warning ( {
closable : false ,
msg : err ,
callback : function ( btn ) {
Common . NotificationCenter . trigger ( 'edit:complete' , me ) ;
}
} ) ;
} ) . on ( 'close' , function ( obj ) {
me . _saveCopyDlg = undefined ;
} ) ;
me . _saveCopyDlg . show ( ) ;
}
} else {
Common . Gateway . downloadAs ( url ) ;
}
this . isFromBtnDownload = false ;
2021-08-06 10:55:26 +00:00
} ,
onPrint : function ( ) {
if ( ! this . appOptions . canPrint || Common . Utils . ModalWindow . isVisible ( ) ) return ;
if ( this . api )
2021-11-08 14:05:18 +00:00
this . api . asc _Print ( new Asc . asc _CDownloadOptions ( null , Common . Utils . isChrome || Common . Utils . isOpera || Common . Utils . isGecko && Common . Utils . firefoxVersion > 86 ) ) ; // if isChrome or isOpera == true use asc_onPrintUrl event
2021-08-06 10:55:26 +00:00
Common . component . Analytics . trackEvent ( 'Print' ) ;
} ,
onPrintUrl : function ( url ) {
if ( this . iframePrint ) {
this . iframePrint . parentNode . removeChild ( this . iframePrint ) ;
this . iframePrint = null ;
}
if ( ! this . iframePrint ) {
var me = this ;
this . iframePrint = document . createElement ( "iframe" ) ;
this . iframePrint . id = "id-print-frame" ;
this . iframePrint . style . display = 'none' ;
this . iframePrint . style . visibility = "hidden" ;
this . iframePrint . style . position = "fixed" ;
this . iframePrint . style . right = "0" ;
this . iframePrint . style . bottom = "0" ;
document . body . appendChild ( this . iframePrint ) ;
this . iframePrint . onload = function ( ) {
try {
me . iframePrint . contentWindow . focus ( ) ;
me . iframePrint . contentWindow . print ( ) ;
me . iframePrint . contentWindow . blur ( ) ;
window . focus ( ) ;
} catch ( e ) {
me . api . asc _DownloadAs ( new Asc . asc _CDownloadOptions ( Asc . c _oAscFileType . PDF ) ) ;
}
} ;
}
if ( url ) this . iframePrint . src = url ;
} ,
onFillRequiredFields : function ( isFilled ) {
2021-08-19 20:09:18 +00:00
this . view . btnSubmit . setDisabled ( ! isFilled ) ;
this . view . btnSubmit . cmpEl . css ( "pointer-events" , isFilled ? "auto" : "none" ) ;
2021-08-06 10:55:26 +00:00
} ,
onProcessMouse : function ( data ) {
if ( data . type == 'mouseup' ) {
var e = document . getElementById ( 'editor_sdk' ) ;
if ( e ) {
var r = e . getBoundingClientRect ( ) ;
this . api . OnMouseUp (
data . x - r . left ,
data . y - r . top
) ;
}
}
} ,
onRequestClose : function ( ) {
Common . Gateway . requestClose ( ) ;
} ,
onDownloadAs : function ( ) {
2021-09-29 14:45:40 +00:00
if ( ! this . appOptions . canDownload ) {
2021-08-06 10:55:26 +00:00
Common . Gateway . reportError ( Asc . c _oAscError . ID . AccessDeny , this . errorAccessDeny ) ;
return ;
}
2021-09-29 14:45:40 +00:00
var type = /^(?:(pdf|djvu|xps|oxps))$/ . exec ( this . document . fileType ) ;
2021-08-06 10:55:26 +00:00
if ( type && typeof type [ 1 ] === 'string' )
this . api . asc _DownloadOrigin ( true ) ;
else
this . api . asc _DownloadAs ( new Asc . asc _CDownloadOptions ( Asc . c _oAscFileType . DOCX , true ) ) ;
} ,
onHyperlinkClick : function ( url ) {
if ( url /*&& me.api.asc_getUrlType(url)>0*/ ) {
window . open ( url ) ;
}
} ,
2021-08-06 17:07:03 +00:00
onShowContentControlsActions : function ( obj , x , y ) {
2022-01-17 15:09:45 +00:00
if ( this . _isDisabled ) return ;
2021-08-06 17:07:03 +00:00
var me = this ;
switch ( obj . type ) {
2021-08-19 21:01:46 +00:00
case Asc . c _oAscContentControlSpecificType . DateTime :
this . onShowDateActions ( obj , x , y ) ;
break ;
2021-08-06 17:07:03 +00:00
case Asc . c _oAscContentControlSpecificType . Picture :
if ( obj . pr && obj . pr . get _Lock ) {
var lock = obj . pr . get _Lock ( ) ;
if ( lock == Asc . c _oAscSdtLockType . SdtContentLocked || lock == Asc . c _oAscSdtLockType . ContentLocked )
return ;
}
2021-11-29 12:02:22 +00:00
this . onShowImageActions ( obj , x , y ) ;
2021-08-06 17:07:03 +00:00
break ;
case Asc . c _oAscContentControlSpecificType . DropDownList :
case Asc . c _oAscContentControlSpecificType . ComboBox :
this . onShowListActions ( obj , x , y ) ;
break ;
}
} ,
onHideContentControlsActions : function ( ) {
2021-08-18 20:15:52 +00:00
this . listControlMenu && this . listControlMenu . isVisible ( ) && this . listControlMenu . hide ( ) ;
var controlsContainer = this . boxSdk . find ( '#calendar-control-container' ) ;
if ( controlsContainer . is ( ':visible' ) )
controlsContainer . hide ( ) ;
2021-08-06 17:07:03 +00:00
} ,
2021-11-29 12:02:22 +00:00
onShowImageActions : function ( obj , x , y ) {
var menu = this . imageControlMenu ,
menuContainer = menu ? this . boxSdk . find ( Common . Utils . String . format ( '#menu-container-{0}' , menu . id ) ) : null ,
me = this ;
this . internalFormObj = obj && obj . pr ? obj . pr . get _InternalId ( ) : null ;
this . _fromShowContentControls = true ;
Common . UI . Menu . Manager . hideAll ( ) ;
if ( ! menu ) {
this . imageControlMenu = menu = new Common . UI . Menu ( {
maxHeight : 207 ,
menuAlign : 'tl-bl' ,
items : [
{ caption : this . mniImageFromFile , value : 'file' } ,
{ caption : this . mniImageFromUrl , value : 'url' } ,
{ caption : this . mniImageFromStorage , value : 'storage' , visible : this . appOptions . canRequestInsertImage || this . appOptions . fileChoiceUrl && this . appOptions . fileChoiceUrl . indexOf ( "{documentType}" ) > - 1 }
]
} ) ;
menu . on ( 'item:click' , function ( menu , item ) {
setTimeout ( function ( ) {
me . onImageSelect ( menu , item ) ;
} , 1 ) ;
setTimeout ( function ( ) {
me . api . asc _UncheckContentControlButtons ( ) ;
} , 500 ) ;
} ) ;
// Prepare menu container
if ( ! menuContainer || menuContainer . length < 1 ) {
menuContainer = $ ( Common . Utils . String . format ( '<div id="menu-container-{0}" style="position: absolute; z-index: 10000;"><div class="dropdown-toggle" data-toggle="dropdown"></div></div>' , menu . id ) ) ;
this . boxSdk . append ( menuContainer ) ;
}
menu . render ( menuContainer ) ;
menu . cmpEl . attr ( { tabindex : "-1" } ) ;
menu . on ( 'hide:after' , function ( ) {
if ( ! me . _fromShowContentControls )
me . api . asc _UncheckContentControlButtons ( ) ;
} ) ;
}
menuContainer . css ( { left : x , top : y } ) ;
menuContainer . attr ( 'data-value' , 'prevent-canvas-click' ) ;
this . _preventClick = true ;
menu . show ( ) ;
_ . delay ( function ( ) {
menu . cmpEl . focus ( ) ;
} , 10 ) ;
this . _fromShowContentControls = false ;
} ,
onImageSelect : function ( menu , item ) {
if ( item . value == 'url' ) {
var me = this ;
( new Common . Views . ImageFromUrlDialog ( {
handler : function ( result , value ) {
if ( result == 'ok' ) {
if ( me . api ) {
var checkUrl = value . replace ( / /g , '' ) ;
if ( ! _ . isEmpty ( checkUrl ) ) {
me . setImageUrl ( checkUrl ) ;
}
}
}
}
} ) ) . show ( ) ;
} else if ( item . value == 'storage' ) {
Common . NotificationCenter . trigger ( 'storage:image-load' , 'control' ) ;
} else {
if ( this . _isFromFile ) return ;
this . _isFromFile = true ;
this . api . asc _addImage ( this . internalFormObj ) ;
this . _isFromFile = false ;
}
} ,
openImageFromStorage : function ( type ) {
var me = this ;
if ( this . appOptions . canRequestInsertImage ) {
Common . Gateway . requestInsertImage ( type ) ;
} else {
( new Common . Views . SelectFileDlg ( {
fileChoiceUrl : this . appOptions . fileChoiceUrl . replace ( "{fileExt}" , "" ) . replace ( "{documentType}" , "ImagesOnly" )
} ) ) . on ( 'selectfile' , function ( obj , file ) {
file && ( file . c = type ) ;
! file . images && ( file . images = [ { fileType : file . fileType , url : file . url } ] ) ; // SelectFileDlg uses old format for inserting image
file . url = null ;
me . insertImage ( file ) ;
} ) . show ( ) ;
}
} ,
setImageUrl : function ( url , token ) {
this . api . asc _SetContentControlPictureUrl ( url , this . internalFormObj && this . internalFormObj . pr ? this . internalFormObj . pr . get _InternalId ( ) : null , token ) ;
} ,
insertImage : function ( data ) { // gateway
if ( data && ( data . url || data . images ) ) {
data . url && console . log ( "Obsolete: The 'url' parameter of the 'insertImage' method is deprecated. Please use 'images' parameter instead." ) ;
var arr = [ ] ;
if ( data . images && data . images . length > 0 ) {
for ( var i = 0 ; i < data . images . length ; i ++ ) {
data . images [ i ] && data . images [ i ] . url && arr . push ( data . images [ i ] . url ) ;
}
} else
data . url && arr . push ( data . url ) ;
data . _urls = arr ;
}
Common . NotificationCenter . trigger ( 'storage:image-insert' , data ) ;
} ,
insertImageFromStorage : function ( data ) {
if ( data && data . _urls && data . c == 'control' ) {
this . setImageUrl ( data . _urls [ 0 ] , data . token ) ;
}
} ,
2021-08-06 17:07:03 +00:00
onShowListActions : function ( obj , x , y ) {
var type = obj . type ,
props = obj . pr ,
specProps = ( type == Asc . c _oAscContentControlSpecificType . ComboBox ) ? props . get _ComboBoxPr ( ) : props . get _DropDownListPr ( ) ,
isForm = ! ! props . get _FormPr ( ) ,
2021-08-18 20:15:52 +00:00
menu = this . listControlMenu ,
menuContainer = menu ? this . boxSdk . find ( Common . Utils . String . format ( '#menu-container-{0}' , menu . id ) ) : null ,
2021-08-06 17:07:03 +00:00
me = this ;
2021-08-18 20:15:52 +00:00
this . _listObj = props ;
this . _fromShowContentControls = true ;
Common . UI . Menu . Manager . hideAll ( ) ;
if ( ! menu ) {
this . listControlMenu = menu = new Common . UI . Menu ( {
maxHeight : 207 ,
menuAlign : 'tr-bl' ,
items : [ ]
2021-08-06 17:07:03 +00:00
} ) ;
2021-08-18 20:15:52 +00:00
menu . on ( 'item:click' , function ( menu , item ) {
setTimeout ( function ( ) {
( item . value !== - 1 ) && me . api . asc _SelectContentControlListItem ( item . value , me . _listObj . get _InternalId ( ) ) ;
} , 1 ) ;
2021-08-06 17:07:03 +00:00
} ) ;
2021-08-18 20:15:52 +00:00
// Prepare menu container
if ( ! menuContainer || menuContainer . length < 1 ) {
menuContainer = $ ( Common . Utils . String . format ( '<div id="menu-container-{0}" style="position: absolute; z-index: 10000;"><div class="dropdown-toggle" data-toggle="dropdown"></div></div>' , menu . id ) ) ;
this . boxSdk . append ( menuContainer ) ;
}
menu . render ( menuContainer ) ;
menu . cmpEl . attr ( { tabindex : "-1" } ) ;
menu . on ( 'hide:after' , function ( ) {
me . listControlMenu . removeAll ( ) ;
if ( ! me . _fromShowContentControls )
me . api . asc _UncheckContentControlButtons ( ) ;
} ) ;
}
2021-08-06 17:07:03 +00:00
if ( specProps ) {
if ( isForm ) { // for dropdown and combobox form control always add placeholder item
var text = props . get _PlaceholderText ( ) ;
2021-08-18 20:15:52 +00:00
menu . addItem ( new Common . UI . MenuItem ( {
caption : ( text . trim ( ) !== '' ) ? text : this . txtEmpty ,
value : '' ,
template : _ . template ( [
'<a id="<%= id %>" tabindex="-1" type="menuitem" style="<% if (options.value=="") { %> opacity: 0.6 <% } %>">' ,
'<%= caption %>' ,
'</a>'
] . join ( '' ) )
} ) ) ;
2021-08-06 17:07:03 +00:00
}
var count = specProps . get _ItemsCount ( ) ;
for ( var i = 0 ; i < count ; i ++ ) {
2021-08-18 20:15:52 +00:00
( specProps . get _ItemValue ( i ) !== '' || ! isForm ) && menu . addItem ( new Common . UI . MenuItem ( {
caption : specProps . get _ItemDisplayText ( i ) ,
value : specProps . get _ItemValue ( i ) ,
template : _ . template ( [
'<a id="<%= id %>" style="<%= style %>" tabindex="-1" type="menuitem">' ,
'<%= Common.Utils.String.htmlEncode(caption) %>' ,
'</a>'
] . join ( '' ) )
} ) ) ;
2021-08-06 17:07:03 +00:00
}
2021-08-18 20:15:52 +00:00
if ( ! isForm && menu . items . length < 1 ) {
menu . addItem ( new Common . UI . MenuItem ( {
caption : this . txtEmpty ,
value : - 1
} ) ) ;
2021-08-06 17:07:03 +00:00
}
}
menuContainer . css ( { left : x , top : y } ) ;
2021-08-18 20:15:52 +00:00
menuContainer . attr ( 'data-value' , 'prevent-canvas-click' ) ;
this . _preventClick = true ;
menu . show ( ) ;
_ . delay ( function ( ) {
menu . cmpEl . focus ( ) ;
} , 10 ) ;
this . _fromShowContentControls = false ;
2021-08-06 17:07:03 +00:00
} ,
2021-08-19 21:01:46 +00:00
onShowDateActions : function ( obj , x , y ) {
var props = obj . pr ,
specProps = props . get _DateTimePr ( ) ,
controlsContainer = this . boxSdk . find ( '#calendar-control-container' ) ,
me = this ;
this . _dateObj = props ;
if ( controlsContainer . length < 1 ) {
controlsContainer = $ ( '<div id="calendar-control-container" style="position: absolute;z-index: 1000;"><div id="id-document-calendar-control" style="position: fixed; left: -1000px; top: -1000px;"></div></div>' ) ;
this . boxSdk . append ( controlsContainer ) ;
}
Common . UI . Menu . Manager . hideAll ( ) ;
controlsContainer . css ( { left : x , top : y } ) ;
controlsContainer . show ( ) ;
if ( ! this . cmpCalendar ) {
this . cmpCalendar = new Common . UI . Calendar ( {
el : this . boxSdk . find ( '#id-document-calendar-control' ) ,
enableKeyEvents : true ,
firstday : 1
} ) ;
this . cmpCalendar . on ( 'date:click' , function ( cmp , date ) {
var specProps = me . _dateObj . get _DateTimePr ( ) ;
specProps . put _FullDate ( new Date ( date ) ) ;
me . api . asc _SetContentControlDatePickerDate ( specProps ) ;
controlsContainer . hide ( ) ;
me . api . asc _UncheckContentControlButtons ( ) ;
} ) ;
this . cmpCalendar . on ( 'calendar:keydown' , function ( cmp , e ) {
if ( e . keyCode == Common . UI . Keys . ESC ) {
controlsContainer . hide ( ) ;
me . api . asc _UncheckContentControlButtons ( ) ;
}
} ) ;
$ ( document ) . on ( 'mousedown' , function ( e ) {
if ( e . target . localName !== 'canvas' && controlsContainer . is ( ':visible' ) && controlsContainer . find ( e . target ) . length == 0 ) {
controlsContainer . hide ( ) ;
me . api . asc _UncheckContentControlButtons ( ) ;
}
} ) ;
}
this . cmpCalendar . setDate ( new Date ( specProps ? specProps . get _FullDate ( ) : undefined ) ) ;
// align
var offset = controlsContainer . offset ( ) ,
docW = Common . Utils . innerWidth ( ) ,
docH = Common . Utils . innerHeight ( ) - 10 , // Yep, it's magic number
menuW = this . cmpCalendar . cmpEl . outerWidth ( ) ,
menuH = this . cmpCalendar . cmpEl . outerHeight ( ) ,
buttonOffset = 22 ,
left = offset . left - menuW ,
top = offset . top ;
if ( top + menuH > docH ) {
top = docH - menuH ;
left -= buttonOffset ;
}
if ( top < 0 )
top = 0 ;
if ( left + menuW > docW )
left = docW - menuW ;
this . cmpCalendar . cmpEl . css ( { left : left , top : top } ) ;
this . _preventClick = true ;
} ,
2021-08-06 10:55:26 +00:00
onDocumentContentReady : function ( ) {
2021-12-06 09:01:39 +00:00
if ( this . _isDocReady )
return ;
2021-08-06 10:55:26 +00:00
2021-12-06 09:01:39 +00:00
var me = this ;
me . _isDocReady = true ;
2021-08-06 10:55:26 +00:00
this . hidePreloader ( ) ;
this . onLongActionEnd ( Asc . c _oAscAsyncActionType [ 'BlockInteraction' ] , LoadingDocument ) ;
2021-11-10 21:51:13 +00:00
var zf = ( this . appOptions . customization && this . appOptions . customization . zoom ? parseInt ( this . appOptions . customization . zoom ) : 100 ) ;
2021-08-06 10:55:26 +00:00
( zf == - 1 ) ? this . api . zoomFitToPage ( ) : ( ( zf == - 2 ) ? this . api . zoomFitToWidth ( ) : this . api . zoom ( zf > 0 ? zf : 100 ) ) ;
2021-08-18 23:04:30 +00:00
this . createDelayedElements ( ) ;
2021-08-06 10:55:26 +00:00
this . api . asc _registerCallback ( 'asc_onStartAction' , _ . bind ( this . onLongActionBegin , this ) ) ;
this . api . asc _registerCallback ( 'asc_onEndAction' , _ . bind ( this . onLongActionEnd , this ) ) ;
this . api . asc _registerCallback ( 'asc_onMouseMoveStart' , _ . bind ( this . onDocMouseMoveStart , this ) ) ;
this . api . asc _registerCallback ( 'asc_onMouseMoveEnd' , _ . bind ( this . onDocMouseMoveEnd , this ) ) ;
this . api . asc _registerCallback ( 'asc_onMouseMove' , _ . bind ( this . onDocMouseMove , this ) ) ;
this . api . asc _registerCallback ( 'asc_onHyperlinkClick' , _ . bind ( this . onHyperlinkClick , this ) ) ;
this . api . asc _registerCallback ( 'asc_onDownloadUrl' , _ . bind ( this . onDownloadUrl , this ) ) ;
this . api . asc _registerCallback ( 'asc_onPrint' , _ . bind ( this . onPrint , this ) ) ;
this . api . asc _registerCallback ( 'asc_onPrintUrl' , _ . bind ( this . onPrintUrl , this ) ) ;
this . api . asc _registerCallback ( 'sync_onAllRequiredFormsFilled' , _ . bind ( this . onFillRequiredFields , this ) ) ;
2021-11-10 14:41:01 +00:00
this . api . asc _registerCallback ( 'asc_onContextMenu' , _ . bind ( this . onContextMenu , this ) ) ;
2021-08-06 17:07:03 +00:00
if ( this . appOptions . canFillForms ) {
this . api . asc _registerCallback ( 'asc_onShowContentControlsActions' , _ . bind ( this . onShowContentControlsActions , this ) ) ;
this . api . asc _registerCallback ( 'asc_onHideContentControlsActions' , _ . bind ( this . onHideContentControlsActions , this ) ) ;
2021-09-01 22:56:21 +00:00
this . api . asc _SetHighlightRequiredFields ( true ) ;
2021-11-29 16:48:09 +00:00
Common . Gateway . on ( 'insertimage' , _ . bind ( this . insertImage , this ) ) ;
Common . NotificationCenter . on ( 'storage:image-load' , _ . bind ( this . openImageFromStorage , this ) ) ; // try to load image from storage
Common . NotificationCenter . on ( 'storage:image-insert' , _ . bind ( this . insertImageFromStorage , this ) ) ; // set loaded image to control
2021-08-06 17:07:03 +00:00
}
2022-02-22 15:23:37 +00:00
DE . getController ( 'Plugins' ) . setApi ( this . api ) ;
2022-06-07 14:57:01 +00:00
DE . getController ( 'SearchBar' ) . setApi ( this . api ) ;
2021-08-06 10:55:26 +00:00
2021-12-06 09:01:39 +00:00
this . updateWindowTitle ( true ) ;
2021-09-01 22:56:21 +00:00
if ( this . editorConfig . mode !== 'view' ) // if want to open editor, but viewer is loaded
this . applyLicense ( ) ;
2021-08-06 10:55:26 +00:00
Common . Gateway . on ( 'processmouse' , _ . bind ( this . onProcessMouse , this ) ) ;
Common . Gateway . on ( 'downloadas' , _ . bind ( this . onDownloadAs , this ) ) ;
Common . Gateway . on ( 'requestclose' , _ . bind ( this . onRequestClose , this ) ) ;
2021-08-18 21:52:04 +00:00
this . attachUIEvents ( ) ;
Common . Gateway . documentReady ( ) ;
Common . Analytics . trackEvent ( 'Load' , 'Complete' ) ;
} ,
onOptionsClick : function ( menu , item , e ) {
switch ( item . value ) {
case 'fullscr' :
this . onHyperlinkClick ( this . embedConfig . fullscreenUrl ) ;
break ;
case 'download' :
if ( ! ! this . embedConfig . saveUrl ) {
this . onHyperlinkClick ( this . embedConfig . saveUrl ) ;
} else if ( this . api && this . appOptions . canPrint ) {
2021-11-08 14:05:18 +00:00
this . api . asc _Print ( new Asc . asc _CDownloadOptions ( null , Common . Utils . isChrome || Common . Utils . isOpera || Common . Utils . isGecko && Common . Utils . firefoxVersion > 86 ) ) ; // if isChrome or isOpera == true use asc_onPrintUrl event
2021-08-18 21:52:04 +00:00
}
Common . Analytics . trackEvent ( 'Save' ) ;
break ;
case 'print' :
2021-11-08 14:05:18 +00:00
this . api . asc _Print ( new Asc . asc _CDownloadOptions ( null , Common . Utils . isChrome || Common . Utils . isOpera || Common . Utils . isGecko && Common . Utils . firefoxVersion > 86 ) ) ; // if isChrome or isOpera == true use asc_onPrintUrl event
2021-08-18 21:52:04 +00:00
Common . Analytics . trackEvent ( 'Print' ) ;
break ;
case 'close' :
2021-12-01 08:53:31 +00:00
if ( ! DE . Controllers . Desktop . process ( 'goback' ) &&
this . appOptions . customization && this . appOptions . customization . goback )
{
2021-08-18 21:52:04 +00:00
if ( this . appOptions . customization . goback . requestClose && this . appOptions . canRequestClose )
Common . Gateway . requestClose ( ) ;
2021-11-23 11:35:22 +00:00
else if ( this . appOptions . customization . goback . url ) {
if ( this . appOptions . customization . goback . blank !== false ) {
window . open ( this . appOptions . customization . goback . url , "_blank" ) ;
} else {
window . parent . location . href = this . appOptions . customization . goback . url ;
}
}
2021-08-18 21:52:04 +00:00
}
break ;
case 'download-docx' :
this . api . asc _DownloadAs ( new Asc . asc _CDownloadOptions ( Asc . c _oAscFileType . DOCX ) ) ;
Common . Analytics . trackEvent ( 'Save' ) ;
break ;
case 'download-pdf' :
this . api . asc _DownloadAs ( new Asc . asc _CDownloadOptions ( Asc . c _oAscFileType . PDF ) ) ;
Common . Analytics . trackEvent ( 'Save' ) ;
break ;
case 'share' :
2021-08-20 09:49:11 +00:00
( new Common . Views . ShareDialog ( {
embedConfig : this . embedConfig
} ) ) . show ( ) ;
2021-08-18 21:52:04 +00:00
break ;
case 'embed' :
2021-08-20 09:49:11 +00:00
( new Common . Views . EmbedDialog ( {
2021-08-20 08:22:17 +00:00
embedConfig : this . embedConfig
} ) ) . show ( ) ;
2021-08-18 21:52:04 +00:00
break ;
2022-06-07 14:57:01 +00:00
case 'search' :
Common . NotificationCenter . trigger ( 'search:show' ) ;
break ;
2021-08-18 21:52:04 +00:00
}
} ,
2021-09-27 17:02:14 +00:00
onThemeClick : function ( menu , item ) {
2021-11-19 14:36:02 +00:00
( item . value !== null ) && Common . UI . Themes . setTheme ( item . value ) ;
} ,
2021-12-15 13:43:21 +00:00
onApiZoomChange : function ( percent , type ) {
this . view . mnuZoom . items [ 0 ] . setChecked ( type == 2 , true ) ;
this . view . mnuZoom . items [ 1 ] . setChecked ( type == 1 , true ) ;
this . view . mnuZoom . options . value = percent ;
if ( this . view . mnuZoom . $el )
$ ( '.menu-zoom label.zoom' , this . view . mnuZoom . $el ) . html ( percent + '%' ) ;
} ,
onMenuZoomClick : function ( menu , item , e ) {
switch ( item . value ) {
case 'zoom:page' :
item . isChecked ( ) ? this . api . zoomFitToPage ( ) : this . api . zoomCustomMode ( ) ;
break ;
case 'zoom:width' :
item . isChecked ( ) ? this . api . zoomFitToWidth ( ) : this . api . zoomCustomMode ( ) ;
break ;
}
} ,
2021-12-17 02:04:24 +00:00
onBtnZoom : function ( btn , e ) {
btn == 'up' ? this . api . zoomIn ( ) : this . api . zoomOut ( ) ;
e . stopPropagation ( ) ;
} ,
2021-11-19 14:36:02 +00:00
onDarkModeClick : function ( item ) {
Common . UI . Themes . toggleContentTheme ( ) ;
2021-09-27 17:02:14 +00:00
} ,
onThemeChange : function ( ) {
var current = Common . UI . Themes . currentThemeId ( ) ;
_ . each ( this . view . mnuThemes . items , function ( item ) {
item . setChecked ( current === item . value , true ) ;
} ) ;
2021-11-19 14:36:02 +00:00
if ( this . view . menuItemsDarkMode ) {
this . view . menuItemsDarkMode . setDisabled ( ! Common . UI . Themes . isDarkTheme ( ) ) ;
this . view . menuItemsDarkMode . setChecked ( Common . UI . Themes . isContentThemeDark ( ) ) ;
}
2021-10-04 20:15:06 +00:00
if ( this . appOptions . canBranding ) {
var value = this . appOptions . customization ;
if ( value && value . logo && ( value . logo . image || value . logo . imageDark ) && ( value . logo . image !== value . logo . imageDark ) ) {
var image = Common . UI . Themes . isDarkTheme ( ) ? ( value . logo . imageDark || value . logo . image ) : ( value . logo . image || value . logo . imageDark ) ;
$ ( '#header-logo img' ) . attr ( 'src' , image ) ;
}
2021-10-04 15:42:14 +00:00
}
2021-09-27 17:02:14 +00:00
} ,
2021-11-19 14:36:02 +00:00
onContentThemeChangedToDark : function ( isdark ) {
this . view . menuItemsDarkMode . setChecked ( isdark , true ) ;
} ,
2021-08-18 23:04:30 +00:00
createDelayedElements : function ( ) {
2021-09-21 18:45:02 +00:00
var me = this ,
menuItems = this . view . btnOptions . menu . items ,
2021-09-27 17:02:14 +00:00
itemsCount = menuItems . length - 4 ;
2021-09-21 18:45:02 +00:00
var initMenu = function ( menu ) {
2022-06-08 21:07:07 +00:00
var last ; // divider item
2021-09-21 18:45:02 +00:00
2022-06-08 21:07:07 +00:00
// download and print
if ( ! menuItems [ 0 ] . isVisible ( ) && ! menuItems [ 1 ] . isVisible ( ) && ! menuItems [ 2 ] . isVisible ( ) && ! menuItems [ 3 ] . isVisible ( ) )
menuItems [ 4 ] . setVisible ( false ) ;
2021-09-21 18:45:02 +00:00
else
2022-06-08 21:07:07 +00:00
last = menuItems [ 4 ] ;
2021-09-21 18:45:02 +00:00
2021-12-17 13:53:21 +00:00
// theme and zoom
2022-06-08 21:07:07 +00:00
if ( ! menuItems [ 7 ] . isVisible ( ) && ! menuItems [ 8 ] . isVisible ( ) )
menuItems [ 9 ] . setVisible ( false ) ;
2021-09-21 18:45:02 +00:00
else
2022-06-08 21:07:07 +00:00
last = menuItems [ 9 ] ;
2021-12-15 13:43:21 +00:00
// share, location
2022-06-08 21:07:07 +00:00
if ( ! menuItems [ 10 ] . isVisible ( ) && ! menuItems [ 11 ] . isVisible ( ) )
menuItems [ 12 ] . setVisible ( false ) ;
2021-12-15 13:43:21 +00:00
else
2022-06-08 21:07:07 +00:00
last = menuItems [ 12 ] ;
2021-12-15 13:43:21 +00:00
// embed, fullscreen
2022-06-08 21:07:07 +00:00
if ( ! menuItems [ 13 ] . isVisible ( ) && ! menuItems [ 14 ] . isVisible ( ) )
2021-12-15 13:43:21 +00:00
last && last . setVisible ( false ) ;
2021-09-21 18:45:02 +00:00
menu . off ( 'show:after' , initMenu ) ;
} ;
2021-08-18 23:04:30 +00:00
if ( ! this . appOptions . canPrint ) {
2022-06-08 21:07:07 +00:00
menuItems [ 3 ] . setVisible ( false ) ;
2021-08-18 23:04:30 +00:00
itemsCount -- ;
}
2021-11-29 16:48:09 +00:00
if ( ! this . embedConfig . saveUrl || ! this . appOptions . canDownload || this . appOptions . isOFORM ) {
2022-06-08 21:07:07 +00:00
menuItems [ 0 ] . setVisible ( false ) ;
2021-08-18 23:04:30 +00:00
itemsCount -- ;
}
2021-11-30 13:25:51 +00:00
if ( ! this . appOptions . isOFORM || ! this . appOptions . canDownload || this . appOptions . isOffline ) {
2022-06-08 21:07:07 +00:00
menuItems [ 1 ] . setVisible ( false ) ;
menuItems [ 2 ] . setVisible ( false ) ;
2021-08-18 23:04:30 +00:00
itemsCount -= 2 ;
}
2021-09-27 17:02:14 +00:00
if ( Common . UI . Themes . available ( ) ) {
var current = Common . UI . Themes . currentThemeId ( ) ;
for ( var t in Common . UI . Themes . map ( ) ) {
this . view . mnuThemes . addItem ( new Common . UI . MenuItem ( {
caption : Common . UI . Themes . get ( t ) . text ,
value : t ,
toggleGroup : 'themes' ,
checkable : true ,
checked : t === current
} ) ) ;
}
}
if ( this . view . mnuThemes . items . length < 1 ) {
2022-06-08 21:07:07 +00:00
menuItems [ 7 ] . setVisible ( false ) ;
2021-08-18 23:04:30 +00:00
itemsCount -- ;
2021-09-27 17:02:14 +00:00
} else {
2021-11-19 14:36:02 +00:00
this . view . menuItemsDarkMode = new Common . UI . MenuItem ( {
caption : this . view . txtDarkMode ,
checkable : true ,
checked : Common . UI . Themes . isContentThemeDark ( ) ,
disabled : ! Common . UI . Themes . isDarkTheme ( )
} ) ;
this . view . mnuThemes . addItem ( new Common . UI . MenuItem ( { caption : '--' } ) ) ;
this . view . mnuThemes . addItem ( this . view . menuItemsDarkMode ) ;
2021-09-27 17:02:14 +00:00
this . view . mnuThemes . on ( 'item:click' , _ . bind ( this . onThemeClick , this ) ) ;
2021-11-19 14:36:02 +00:00
this . view . menuItemsDarkMode . on ( 'click' , _ . bind ( this . onDarkModeClick , this ) ) ;
2021-09-27 17:02:14 +00:00
Common . NotificationCenter . on ( 'uitheme:changed' , this . onThemeChange . bind ( this ) ) ;
2021-11-19 14:36:02 +00:00
Common . NotificationCenter . on ( 'contenttheme:dark' , this . onContentThemeChangedToDark . bind ( this ) ) ;
2021-09-27 17:02:14 +00:00
}
2021-11-29 16:48:09 +00:00
if ( ! this . embedConfig . shareUrl || this . appOptions . isOFORM ) {
2022-06-08 21:07:07 +00:00
menuItems [ 10 ] . setVisible ( false ) ;
2021-09-27 17:02:14 +00:00
itemsCount -- ;
2021-08-18 23:04:30 +00:00
}
if ( ! this . appOptions . canBackToFolder ) {
2022-06-08 21:07:07 +00:00
menuItems [ 11 ] . setVisible ( false ) ;
2021-08-18 23:04:30 +00:00
itemsCount -- ;
}
2021-11-29 16:48:09 +00:00
if ( ! this . embedConfig . embedUrl || this . appOptions . isOFORM ) {
2022-06-08 21:07:07 +00:00
menuItems [ 13 ] . setVisible ( false ) ;
2021-08-18 23:04:30 +00:00
itemsCount -- ;
}
2021-11-29 16:48:09 +00:00
if ( ! this . embedConfig . fullscreenUrl || this . appOptions . isOFORM ) {
2022-06-08 21:07:07 +00:00
menuItems [ 14 ] . setVisible ( false ) ;
2021-08-18 23:04:30 +00:00
itemsCount -- ;
}
if ( itemsCount < 1 )
this . view . btnOptions . setVisible ( false ) ;
2021-09-21 18:45:02 +00:00
this . view . btnOptions . menu . on ( 'show:after' , initMenu ) ;
2021-08-18 23:04:30 +00:00
screenTip = {
toolTip : new Common . UI . Tooltip ( {
owner : this ,
html : true ,
title : this . txtPressLink ,
cls : 'link-tooltip'
} ) ,
strTip : '' ,
isHidden : true ,
isVisible : false
} ;
} ,
2021-08-18 21:52:04 +00:00
attachUIEvents : function ( ) {
var me = this ;
// zoom
2021-08-07 08:44:58 +00:00
$ ( '#id-btn-zoom-in' ) . on ( 'click' , this . api . zoomIn . bind ( this . api ) ) ;
$ ( '#id-btn-zoom-out' ) . on ( 'click' , this . api . zoomOut . bind ( this . api ) ) ;
2021-12-17 02:59:15 +00:00
$ ( '#id-menu-zoom-in' ) . on ( 'click' , _ . bind ( this . onBtnZoom , this , 'up' ) ) ;
$ ( '#id-menu-zoom-out' ) . on ( 'click' , _ . bind ( this . onBtnZoom , this , 'down' ) ) ;
2021-08-07 08:44:58 +00:00
this . view . btnOptions . menu . on ( 'item:click' , _ . bind ( this . onOptionsClick , this ) ) ;
2021-12-15 13:43:21 +00:00
this . view . mnuZoom . on ( 'item:click' , _ . bind ( this . onMenuZoomClick , this ) ) ;
2021-08-06 10:55:26 +00:00
2021-08-18 21:52:04 +00:00
// pages
var $pagenum = this . view . txtGoToPage . _input ;
this . view . txtGoToPage . on ( {
'changed:after' : function ( input , newValue , oldValue ) {
var newPage = parseInt ( newValue ) ;
2021-08-06 10:55:26 +00:00
2021-08-18 21:52:04 +00:00
if ( newPage > maxPages ) newPage = maxPages ;
if ( newPage < 2 || isNaN ( newPage ) ) newPage = 1 ;
2021-08-06 10:55:26 +00:00
2021-08-18 21:52:04 +00:00
me . api . goToPage ( newPage - 1 ) ;
} ,
'inputleave' : function ( ) { $pagenum . blur ( ) ; }
} ) ;
$pagenum . on ( {
'focusin' : function ( e ) {
2021-08-06 10:55:26 +00:00
$pagenum . removeClass ( 'masked' ) ;
2021-08-18 21:52:04 +00:00
$pagenum . select ( ) ;
} ,
'focusout' : function ( e ) {
2021-08-06 10:55:26 +00:00
! $pagenum . hasClass ( 'masked' ) && $pagenum . addClass ( 'masked' ) ;
}
} ) ;
$ ( '#pages' ) . on ( 'click' , function ( e ) {
2021-08-18 21:52:04 +00:00
setTimeout ( function ( ) { $pagenum . focus ( ) . select ( ) ; } , 10 ) ;
2021-08-06 10:55:26 +00:00
} ) ;
// TODO: add asc_hasRequiredFields to sdk
if ( this . appOptions . canSubmitForms && ! this . api . asc _IsAllRequiredFormsFilled ( ) ) {
2021-08-19 20:09:18 +00:00
this . view . btnSubmit . setDisabled ( true ) ;
this . view . btnSubmit . cmpEl . css ( "pointer-events" , "none" ) ;
2021-08-06 10:55:26 +00:00
var sgroup = $ ( '#id-submit-group' ) ;
if ( ! Common . localStorage . getItem ( "de-embed-hide-submittip" ) ) {
2021-08-19 20:09:18 +00:00
var requiredTooltip = new Common . UI . SynchronizeTip ( {
extCls : 'colored' ,
placement : 'bottom-left' ,
target : this . view . btnSubmit . $el ,
text : this . textRequired ,
showLink : false ,
2021-10-29 15:33:03 +00:00
closable : false ,
2021-08-19 20:09:18 +00:00
showButton : true ,
textButton : this . textGotIt
} ) ;
var onclose = function ( ) {
requiredTooltip . hide ( ) ;
2021-08-06 10:55:26 +00:00
me . api . asc _MoveToFillingForm ( true , true , true ) ;
sgroup . attr ( 'data-toggle' , 'tooltip' ) ;
sgroup . tooltip ( {
title : me . textRequired ,
placement : 'bottom'
} ) ;
2021-08-19 20:09:18 +00:00
} ;
requiredTooltip . on ( 'buttonclick' , function ( ) {
onclose ( ) ;
Common . localStorage . setItem ( "de-embed-hide-submittip" , 1 ) ;
2021-08-06 10:55:26 +00:00
} ) ;
2021-08-19 20:09:18 +00:00
requiredTooltip . on ( 'closeclick' , onclose ) ;
requiredTooltip . show ( ) ;
2021-08-06 10:55:26 +00:00
} else {
sgroup . attr ( 'data-toggle' , 'tooltip' ) ;
sgroup . tooltip ( {
title : me . textRequired ,
placement : 'bottom'
} ) ;
}
}
var documentMoveTimer ;
var ismoved = false ;
$ ( document ) . mousemove ( function ( event ) {
$ ( '#id-btn-zoom-in' ) . fadeIn ( ) ;
$ ( '#id-btn-zoom-out' ) . fadeIn ( ) ;
ismoved = true ;
if ( ! documentMoveTimer ) {
documentMoveTimer = setInterval ( function ( ) {
if ( ! ismoved ) {
$ ( '#id-btn-zoom-in' ) . fadeOut ( ) ;
$ ( '#id-btn-zoom-out' ) . fadeOut ( ) ;
clearInterval ( documentMoveTimer ) ;
documentMoveTimer = undefined ;
}
ismoved = false ;
} , 2000 ) ;
}
} ) ;
2021-08-07 08:44:58 +00:00
} ,
2021-11-10 14:41:01 +00:00
onContextMenu : function ( event ) {
var me = this ;
_ . delay ( function ( ) {
if ( event . get _Type ( ) == 0 ) {
me . api && me . appOptions . canFillForms && me . fillMenuProps ( me . api . getSelectedElements ( ) , event ) ;
}
} , 10 ) ;
} ,
showPopupMenu : function ( menu , value , event ) {
if ( ! _ . isUndefined ( menu ) && menu !== null ) {
Common . UI . Menu . Manager . hideAll ( ) ;
var showPoint = [ event . get _X ( ) , event . get _Y ( ) ] ,
menuContainer = this . boxSdk . find ( Common . Utils . String . format ( '#menu-container-{0}' , menu . id ) ) ;
if ( ! menu . rendered ) {
// Prepare menu container
if ( menuContainer . length < 1 ) {
menuContainer = $ ( Common . Utils . String . format ( '<div id="menu-container-{0}" style="position: absolute; z-index: 10000;"><div class="dropdown-toggle" data-toggle="dropdown"></div></div>' , menu . id ) ) ;
this . boxSdk . append ( menuContainer ) ;
}
menu . render ( menuContainer ) ;
menu . cmpEl . attr ( { tabindex : "-1" } ) ;
}
menuContainer . css ( {
left : showPoint [ 0 ] ,
top : showPoint [ 1 ]
} ) ;
menu . show ( ) ;
if ( _ . isFunction ( menu . options . initMenu ) ) {
menu . options . initMenu ( value ) ;
menu . alignPosition ( ) ;
}
_ . delay ( function ( ) {
menu . cmpEl . focus ( ) ;
} , 10 ) ;
this . currentMenu = menu ;
}
} ,
fillMenuProps : function ( selectedElements , event ) {
if ( ! selectedElements || ! _ . isArray ( selectedElements ) ) return ;
if ( ! this . textMenu ) {
this . textMenu = this . view . getContextMenu ( ) ;
this . textMenu . on ( 'item:click' , _ . bind ( this . onContextMenuClick , this ) ) ;
}
var menu _props = { } ,
noobject = true ;
for ( var i = 0 ; i < selectedElements . length ; i ++ ) {
var elType = selectedElements [ i ] . get _ObjectType ( ) ;
var elValue = selectedElements [ i ] . get _ObjectValue ( ) ;
if ( Asc . c _oAscTypeSelectElement . Image == elType ) {
//image
menu _props . imgProps = { } ;
menu _props . imgProps . value = elValue ;
menu _props . imgProps . locked = ( elValue ) ? elValue . get _Locked ( ) : false ;
var control _props = this . api . asc _IsContentControl ( ) ? this . api . asc _GetContentControlProperties ( ) : null ,
lock _type = ( control _props ) ? control _props . get _Lock ( ) : Asc . c _oAscSdtLockType . Unlocked ;
menu _props . imgProps . content _locked = lock _type == Asc . c _oAscSdtLockType . SdtContentLocked || lock _type == Asc . c _oAscSdtLockType . ContentLocked ;
noobject = false ;
} else if ( Asc . c _oAscTypeSelectElement . Paragraph == elType ) {
menu _props . paraProps = { } ;
menu _props . paraProps . value = elValue ;
menu _props . paraProps . locked = ( elValue ) ? elValue . get _Locked ( ) : false ;
noobject = false ;
} else if ( Asc . c _oAscTypeSelectElement . Header == elType ) {
menu _props . headerProps = { } ;
menu _props . headerProps . locked = ( elValue ) ? elValue . get _Locked ( ) : false ;
}
}
if ( this . textMenu && ! noobject ) {
var cancopy = this . api . can _CopyCut ( ) ,
disabled = menu _props . paraProps && menu _props . paraProps . locked || menu _props . headerProps && menu _props . headerProps . locked ||
2022-01-17 15:09:45 +00:00
menu _props . imgProps && ( menu _props . imgProps . locked || menu _props . imgProps . content _locked ) || this . _isDisabled ;
2021-11-29 16:39:24 +00:00
this . textMenu . items [ 0 ] . setDisabled ( disabled || ! this . api . asc _getCanUndo ( ) ) ; // undo
this . textMenu . items [ 1 ] . setDisabled ( disabled || ! this . api . asc _getCanRedo ( ) ) ; // redo
2022-01-17 15:09:45 +00:00
this . textMenu . items [ 3 ] . setDisabled ( disabled || ! cancopy ) ; // cut
this . textMenu . items [ 4 ] . setDisabled ( ! cancopy ) ; // copy
2021-11-29 16:39:24 +00:00
this . textMenu . items [ 5 ] . setDisabled ( disabled ) // paste;
2021-11-10 14:41:01 +00:00
this . showPopupMenu ( this . textMenu , { } , event ) ;
}
} ,
onContextMenuClick : function ( menu , item , e ) {
switch ( item . value ) {
2021-11-29 16:39:24 +00:00
case 'undo' :
this . api && this . api . Undo ( ) ;
break ;
case 'redo' :
this . api && this . api . Redo ( ) ;
break ;
2021-11-10 14:41:01 +00:00
case 'copy' :
case 'cut' :
case 'paste' :
if ( this . api ) {
var res = ( item . value == 'cut' ) ? this . api . Cut ( ) : ( ( item . value == 'copy' ) ? this . api . Copy ( ) : this . api . Paste ( ) ) ;
if ( ! res ) {
if ( ! Common . localStorage . getBool ( "de-forms-hide-copywarning" ) ) {
( new Common . Views . CopyWarningDialog ( {
handler : function ( dontshow ) {
if ( dontshow ) Common . localStorage . setItem ( "de-forms-hide-copywarning" , 1 ) ;
}
} ) ) . show ( ) ;
}
}
}
break ;
}
} ,
2022-01-24 16:07:47 +00:00
onApiServerDisconnect : function ( enableDownload ) {
this . _state . isDisconnected = true ;
this . _isDisabled = true ;
this . view && this . view . btnClear && this . view . btnClear . setDisabled ( true ) ;
if ( ! enableDownload ) {
this . appOptions . canPrint = this . appOptions . canDownload = false ;
this . view && this . view . btnDownload . setDisabled ( true ) ;
this . view && this . view . btnSubmit . setDisabled ( true ) ;
if ( this . view && this . view . btnOptions && this . view . btnOptions . menu ) {
2022-06-08 21:07:07 +00:00
this . view . btnOptions . menu . items [ 3 ] . setDisabled ( true ) ; // print
this . view . btnOptions . menu . items [ 0 ] . setDisabled ( true ) ; // download
this . view . btnOptions . menu . items [ 1 ] . setDisabled ( true ) ; // download docx
this . view . btnOptions . menu . items [ 2 ] . setDisabled ( true ) ; // download pdf
2022-01-24 16:07:47 +00:00
}
}
2022-01-17 15:09:45 +00:00
} ,
2021-08-06 10:55:26 +00:00
errorDefaultMessage : 'Error code: %1' ,
unknownErrorText : 'Unknown error.' ,
convertationTimeoutText : 'Conversion timeout exceeded.' ,
convertationErrorText : 'Conversion failed.' ,
downloadErrorText : 'Download failed.' ,
criticalErrorTitle : 'Error' ,
notcriticalErrorTitle : 'Warning' ,
scriptLoadError : 'The connection is too slow, some of the components could not be loaded. Please reload the page.' ,
errorFilePassProtect : 'The file is password protected and cannot be opened.' ,
errorAccessDeny : 'You are trying to perform an action you do not have rights for.<br>Please contact your Document Server administrator.' ,
errorUserDrop : 'The file cannot be accessed right now.' ,
unsupportedBrowserErrorText : 'Your browser is not supported.' ,
textOf : 'of' ,
downloadTextText : 'Downloading document...' ,
waitText : 'Please, wait...' ,
textLoadingDocument : 'Loading document' ,
txtClose : 'Close' ,
errorFileSizeExceed : 'The file size exceeds the limitation set for your server.<br>Please contact your Document Server administrator for details.' ,
errorUpdateVersionOnDisconnect : 'Internet connection has been restored, and the file version has been changed.<br>Before you can continue working, you need to download the file or copy its content to make sure nothing is lost, and then reload this page.' ,
textSubmited : '<b>Form submitted successfully</b><br>Click to close the tip.' ,
errorSubmit : 'Submit failed.' ,
errorEditingDownloadas : 'An error occurred during the work with the document.<br>Use the \'Download as...\' option to save the file backup copy to your computer hard drive.' ,
textGuest : 'Guest' ,
textAnonymous : 'Anonymous' ,
textRequired : 'Fill all required fields to send form.' ,
textGotIt : 'Got it' ,
errorForceSave : "An error occurred while saving the file. Please use the 'Download as' option to save the file to your computer hard drive or try again later." ,
2021-08-06 17:07:03 +00:00
textCloseTip : "Click to close the tip." ,
txtPressLink : 'Press Ctrl and click link' ,
2021-09-01 22:11:52 +00:00
txtEmpty : '(Empty)' ,
titleServerVersion : 'Editor updated' ,
2021-09-01 22:56:21 +00:00
errorServerVersion : 'The editor version has been updated. The page will be reloaded to apply the changes.' ,
titleUpdateVersion : 'Version changed' ,
errorUpdateVersion : 'The file version has been changed. The page will be reloaded.' ,
warnLicenseLimitedRenewed : 'License needs to be renewed.<br>You have a limited access to document editing functionality.<br>Please contact your administrator to get full access' ,
warnLicenseLimitedNoAccess : 'License expired.<br>You have no access to document editing functionality.<br>Please contact your administrator.' ,
warnLicenseExceeded : "You've reached the limit for simultaneous connections to %1 editors. This document will be opened for viewing only.<br>Contact your administrator to learn more." ,
warnLicenseUsersExceeded : "You've reached the user limit for %1 editors. Contact your administrator to learn more." ,
warnNoLicense : "You've reached the limit for simultaneous connections to %1 editors. This document will be opened for viewing only.<br>Contact %1 sales team for personal upgrade terms." ,
warnNoLicenseUsers : "You've reached the user limit for %1 editors. Contact %1 sales team for personal upgrade terms." ,
textBuyNow : 'Visit website' ,
textNoLicenseTitle : 'License limit reached' ,
2021-10-01 12:23:16 +00:00
textContactUs : 'Contact sales' ,
2021-11-01 14:16:20 +00:00
errorLoadingFont : 'Fonts are not loaded.<br>Please contact your Document Server administrator.' ,
errorConnectToServer : 'The document could not be saved. Please check connection settings or contact your administrator.<br>When you click the \'OK\' button, you will be prompted to download the document.' ,
2021-11-11 11:07:18 +00:00
errorTokenExpire : 'The document security token has expired.<br>Please contact your Document Server administrator.' ,
errorViewerDisconnect : 'Connection is lost. You can still view the document,<br>but will not be able to download or print until the connection is restored and page is reloaded.' ,
uploadImageSizeMessage : 'Maximum image size limit exceeded.' ,
2021-11-23 10:41:03 +00:00
uploadImageExtMessage : 'Unknown image format.' ,
txtArt : 'Your text here' ,
txtChoose : 'Choose an item' ,
txtEnterDate : 'Enter a date' ,
2021-11-26 11:10:44 +00:00
txtClickToLoad : 'Click to load image' ,
2021-11-29 12:02:22 +00:00
openErrorText : 'An error has occurred while opening the file' ,
mniImageFromFile : 'Image from File' ,
mniImageFromUrl : 'Image from URL' ,
2021-11-29 20:39:18 +00:00
mniImageFromStorage : 'Image from Storage' ,
2021-11-30 09:47:56 +00:00
txtUntitled : 'Untitled' ,
errorToken : 'The document security token is not correctly formed.<br>Please contact your Document Server administrator.' ,
errorSessionAbsolute : 'The document editing session has expired. Please reload the page.' ,
errorSessionIdle : 'The document has not been edited for quite a long time. Please reload the page.' ,
errorSessionToken : 'The connection to the server has been interrupted. Please reload the page.' ,
errorBadImageUrl : 'Image url is incorrect' ,
errorDataEncrypted : 'Encrypted changes have been received, they cannot be deciphered.' ,
2021-11-30 13:25:51 +00:00
saveErrorText : 'An error has occurred while saving the file' ,
saveErrorTextDesktop : 'This file cannot be saved or created.<br>Possible reasons are: <br>1. The file is read-only. <br>2. The file is being edited by other users. <br>3. The disk is full or corrupted.' ,
errorEditingSaveas : 'An error occurred during the work with the document.<br>Use the \'Save as...\' option to save the file backup copy to your computer hard drive.' ,
textSaveAs : 'Save as PDF' ,
2022-01-14 13:04:39 +00:00
textSaveAsDesktop : 'Save as...' ,
warnLicenseExp : 'Your license has expired.<br>Please update your license and refresh the page.' ,
2022-09-08 12:36:27 +00:00
titleLicenseExp : 'License expired' ,
errorTextFormWrongFormat : 'The value entered does not match the format of the field.'
2021-09-01 22:56:21 +00:00
2021-08-06 10:55:26 +00:00
} , DE . Controllers . ApplicationController ) ) ;
2021-11-19 17:29:36 +00:00
var Desktop = function ( ) {
var features = {
version : '{{PRODUCT_VERSION}}' ,
// eventloading: true,
2021-12-09 21:42:53 +00:00
uitype : 'fillform' ,
2021-11-19 17:29:36 +00:00
uithemes : true
} ;
2021-12-05 17:15:56 +00:00
var api ;
2021-11-19 17:29:36 +00:00
var native = window . desktop || window . AscDesktopEditor ;
! ! native && native . execCommand ( 'webapps:features' , JSON . stringify ( features ) ) ;
if ( ! ! native ) {
$ ( '#header-logo, .brand-logo' ) . hide ( ) ;
window . on _native _message = function ( cmd , param ) {
if ( /theme:changed/ . test ( cmd ) ) {
2021-12-23 18:50:08 +00:00
if ( Common . UI . Themes && ! ! Common . UI . Themes . setTheme )
2021-12-02 07:18:03 +00:00
Common . UI . Themes . setTheme ( param ) ;
2021-11-30 21:49:44 +00:00
} else
if ( /window:features/ . test ( cmd ) ) {
var obj = JSON . parse ( param ) ;
2021-12-01 16:46:32 +00:00
if ( obj . singlewindow !== undefined ) {
2021-12-14 14:06:36 +00:00
native . features . singlewindow = obj . singlewindow ;
2021-12-01 16:46:32 +00:00
$ ( "#title-doc-name" ) [ obj . singlewindow ? 'hide' : 'show' ] ( ) ;
2021-11-30 21:49:44 +00:00
}
2021-11-19 17:29:36 +00:00
}
} ;
2021-11-30 21:49:44 +00:00
if ( ! ! window . native _message _cmd ) {
for ( var c in window . native _message _cmd ) {
window . on _native _message ( c , window . native _message _cmd [ c ] ) ;
}
}
2021-11-19 17:29:36 +00:00
Common . NotificationCenter . on ( {
'uitheme:changed' : function ( name ) {
2022-09-02 18:20:45 +00:00
if ( Common . localStorage . getBool ( 'ui-theme-use-system' , false ) ) {
native . execCommand ( "uitheme:changed" , JSON . stringify ( { name : 'theme-system' } ) ) ;
} else {
const theme = Common . UI . Themes . get ( name ) ;
if ( theme )
native . execCommand ( "uitheme:changed" , JSON . stringify ( { name : name , type : theme . type } ) ) ;
}
2021-11-19 17:29:36 +00:00
} ,
} ) ;
2021-12-15 11:14:42 +00:00
Common . Gateway . on ( 'opendocument' , function ( ) {
api = DE . getController ( 'ApplicationController' ) . api ;
2021-12-06 16:16:13 +00:00
2021-12-15 11:14:42 +00:00
$ ( "#title-doc-name" ) [ native . features . singlewindow ? 'hide' : 'show' ] ( ) ;
2021-12-06 16:16:13 +00:00
2021-12-15 11:14:42 +00:00
var is _win _xp = window . RendererProcessVariable && window . RendererProcessVariable . os === 'winxp' ;
Common . UI . Themes . setAvailable ( ! is _win _xp ) ;
} ) ;
}
2021-12-05 17:15:56 +00:00
2021-11-19 17:29:36 +00:00
return {
isActive : function ( ) {
return ! ! native ;
} ,
2021-12-01 08:53:31 +00:00
process : function ( opts ) {
2021-12-05 17:15:56 +00:00
if ( ! ! native && ! ! api ) {
2021-12-01 08:53:31 +00:00
if ( opts == 'goback' ) {
var config = DE . getController ( 'ApplicationController' ) . editorConfig ;
native . execCommand ( 'go:folder' ,
2021-12-05 17:15:56 +00:00
api . asc _isOffline ( ) ? 'offline' : config . customization . goback . url ) ;
2021-12-01 08:53:31 +00:00
return true ;
}
}
return false ;
} ,
2021-11-19 17:29:36 +00:00
}
} ;
DE . Controllers . Desktop = new Desktop ( ) ;
2022-08-25 21:31:29 +00:00
Common . Controllers = Common . Controllers || { } ;
Common . Controllers . Desktop = DE . Controllers . Desktop ;
2021-08-06 10:55:26 +00:00
} ) ;