2021-08-28 23:46:21 +00:00
/ *
*
* ( c ) Copyright Ascensio System SIA 2010 - 2019
*
* 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
*
* You can contact Ascensio System SIA at 20 A - 12 Ernesta Birznieka - Upisha
* street , Riga , Latvia , EU , LV - 1050.
*
* 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
*
* /
DE . ApplicationController = new ( function ( ) {
var me ,
api ,
config = { } ,
docConfig = { } ,
embedConfig = { } ,
permissions = { } ,
maxPages = 0 ,
created = false ,
ttOffset = [ 0 , - 10 ] ,
appOptions = { } ,
btnSubmit ,
_submitFail , $submitedTooltip , $requiredTooltip ,
$listControlMenu , listControlItems = [ ] , listObj ,
bodyWidth = 0 ;
var LoadingDocument = - 256 ;
// Check browser
// -------------------------
if ( typeof isBrowserSupported !== 'undefined' && ! isBrowserSupported ( ) ) {
Common . Gateway . reportError ( undefined , this . unsupportedBrowserErrorText ) ;
return ;
}
common . localStorage . setId ( 'text' ) ;
common . localStorage . setKeysFilter ( 'de-,asc.text' ) ;
common . localStorage . sync ( ) ;
// Handlers
// -------------------------
function loadConfig ( data ) {
config = $ . extend ( config , data . config ) ;
embedConfig = $ . extend ( embedConfig , data . config . embedded ) ;
common . controller . modals . init ( embedConfig ) ;
// Docked toolbar
2021-08-30 01:49:25 +00:00
if ( embedConfig . toolbarDocked === 'bottom' ) {
2021-08-28 23:46:21 +00:00
$ ( '#editor_sdk' ) . addClass ( 'bottom' ) ;
} else {
$ ( '#editor_sdk' ) . addClass ( 'top' ) ;
}
config . canBackToFolder = ( config . canBackToFolder !== false ) && config . customization && config . customization . goback &&
( config . customization . goback . url || config . customization . goback . requestClose && config . canRequestClose ) ;
}
function loadDocument ( data ) {
docConfig = data . doc ;
if ( docConfig ) {
permissions = $ . extend ( permissions , docConfig . permissions ) ;
var _permissions = $ . extend ( { } , docConfig . permissions ) ,
docInfo = new Asc . asc _CDocInfo ( ) ,
_user = new Asc . asc _CUserInfo ( ) ;
var canRenameAnonymous = ! ( ( typeof ( config . customization ) == 'object' ) && ( typeof ( config . customization . anonymous ) == 'object' ) && ( config . customization . anonymous . request === false ) ) ,
guestName = ( typeof ( config . customization ) == 'object' ) && ( typeof ( config . customization . anonymous ) == 'object' ) &&
( typeof ( config . customization . anonymous . label ) == 'string' ) && config . customization . anonymous . label . trim ( ) !== '' ?
common . utils . htmlEncode ( config . customization . anonymous . label ) : me . textGuest ,
2021-08-30 01:49:25 +00:00
value = canRenameAnonymous ? common . localStorage . getItem ( "guest-username" ) : null ; //,
2021-08-28 23:46:21 +00:00
user = common . utils . fillUserInfo ( config . user , config . lang , value ? ( value + ' (' + guestName + ')' ) : me . textAnonymous ,
common . localStorage . getItem ( "guest-id" ) || ( 'uid-' + Date . now ( ) ) ) ;
user . anonymous && common . localStorage . setItem ( "guest-id" , user . id ) ;
_user . put _Id ( user . id ) ;
_user . put _FullName ( user . fullname ) ;
_user . put _IsAnonymousUser ( user . anonymous ) ;
docInfo . put _Id ( docConfig . key ) ;
docInfo . put _Url ( docConfig . url ) ;
docInfo . put _Title ( docConfig . title ) ;
docInfo . put _Format ( docConfig . fileType ) ;
docInfo . put _VKey ( docConfig . vkey ) ;
docInfo . put _UserInfo ( _user ) ;
docInfo . put _Token ( docConfig . token ) ;
docInfo . put _Permissions ( _permissions ) ;
docInfo . put _EncryptedInfo ( config . encryptionKeys ) ;
var enable = ! config . customization || ( config . customization . macros !== false ) ;
docInfo . asc _putIsEnabledMacroses ( ! ! enable ) ;
enable = ! config . customization || ( config . customization . plugins !== false ) ;
docInfo . asc _putIsEnabledPlugins ( ! ! enable ) ;
var type = /^(?:(pdf|djvu|xps))$/ . exec ( docConfig . fileType ) ;
if ( type && typeof type [ 1 ] === 'string' ) {
permissions . edit = permissions . review = false ;
}
if ( api ) {
api . asc _registerCallback ( 'asc_onGetEditorPermissions' , onEditorPermissions ) ;
api . asc _registerCallback ( 'asc_onRunAutostartMacroses' , onRunAutostartMacroses ) ;
api . asc _setDocInfo ( docInfo ) ;
api . asc _getEditorPermissions ( config . licenseUrl , config . customerId ) ;
api . asc _enableKeyEvents ( true ) ;
}
}
}
function onCountPages ( count ) {
maxPages = count ;
$ ( '#pages' ) . text ( me . textOf + " " + count ) ;
}
function onCurrentPage ( number ) {
2021-08-30 01:49:25 +00:00
//$('#page-number').val(number + 1);
2021-08-28 23:46:21 +00:00
}
function onLongActionBegin ( type , id ) {
var text = '' ;
switch ( id )
{
case Asc . c _oAscAsyncAction [ 'Print' ] :
text = me . downloadTextText ;
break ;
case Asc . c _oAscAsyncAction [ 'Submit' ] :
_submitFail = false ;
$submitedTooltip && $submitedTooltip . hide ( ) ;
2021-08-30 01:49:25 +00:00
/ * b t n S u b m i t . a t t r ( { d i s a b l e d : t r u e } ) ;
btnSubmit . css ( "pointer-events" , "none" ) ; * /
2021-08-28 23:46:21 +00:00
break ;
case LoadingDocument :
text = me . textLoadingDocument + ' ' ;
break ;
default :
text = me . waitText ;
break ;
}
if ( type == Asc . c _oAscAsyncActionType [ 'BlockInteraction' ] ) {
if ( ! me . loadMask )
me . loadMask = new common . view . LoadMask ( ) ;
me . loadMask . setTitle ( text ) ;
me . loadMask . show ( ) ;
}
}
function onLongActionEnd ( type , id ) {
if ( id == Asc . c _oAscAsyncAction [ 'Submit' ] ) {
2021-08-30 01:49:25 +00:00
/ * b t n S u b m i t . r e m o v e A t t r ( ' d i s a b l e d ' ) ;
btnSubmit . css ( "pointer-events" , "auto" ) ; * /
2021-08-28 23:46:21 +00:00
if ( ! _submitFail ) {
if ( ! $submitedTooltip ) {
$submitedTooltip = $ ( '<div class="submit-tooltip" style="display:none;">' + me . textSubmited + '</div>' ) ;
$ ( document . body ) . append ( $submitedTooltip ) ;
$submitedTooltip . on ( 'click' , function ( ) { $submitedTooltip . hide ( ) ; } ) ;
}
$submitedTooltip . show ( ) ;
}
}
me . loadMask && me . loadMask . hide ( ) ;
}
function onDocMouseMoveStart ( ) {
me . isHideBodyTip = true ;
}
function onDocMouseMoveEnd ( ) {
if ( me . isHideBodyTip ) {
if ( $tooltip ) {
$tooltip . tooltip ( 'hide' ) ;
$tooltip = false ;
}
}
}
var $ttEl , $tooltip ;
function onDocMouseMove ( data ) {
if ( data ) {
var type = data . get _Type ( ) ;
if ( type == Asc . c _oAscMouseMoveDataTypes . Hyperlink || type == Asc . c _oAscMouseMoveDataTypes . Form ) { // hyperlink
me . isHideBodyTip = false ;
var str = ( type == Asc . c _oAscMouseMoveDataTypes . Hyperlink ) ? me . txtPressLink : data . get _FormHelpText ( ) ;
if ( str . length > 500 )
str = str . substr ( 0 , 500 ) + '...' ;
str = common . utils . htmlEncode ( str ) ;
if ( ! $ttEl ) {
$ttEl = $ ( '.hyperlink-tooltip' ) ;
$ttEl . tooltip ( { 'container' : 'body' , 'trigger' : 'manual' } ) ;
}
$ttEl . ttpos = [ data . get _X ( ) , data . get _Y ( ) ] ;
if ( ! $tooltip )
$tooltip = $ttEl . data ( 'bs.tooltip' ) . tip ( ) ;
if ( ! $tooltip . is ( ':visible' ) ) {
var tip = $ttEl . data ( 'bs.tooltip' ) ;
tip . options . title = str ;
tip . show ( [ - 1000 , - 1000 ] ) ;
} else
$tooltip . find ( '.tooltip-inner' ) [ 'text' ] ( str ) ;
var ttHeight = $tooltip . height ( ) ,
ttWidth = $tooltip . width ( ) ;
! bodyWidth && ( bodyWidth = $ ( 'body' ) . width ( ) ) ;
$ttEl . ttpos [ 1 ] -= ( ttHeight - ttOffset [ 1 ] + 20 ) ;
if ( $ttEl . ttpos [ 0 ] + ttWidth + 10 > bodyWidth ) {
$ttEl . ttpos [ 0 ] = bodyWidth - ttWidth - 5 ;
if ( $ttEl . ttpos [ 1 ] < 0 )
$ttEl . ttpos [ 1 ] += ttHeight + ttOffset [ 1 ] + 20 ;
} else if ( $ttEl . ttpos [ 1 ] < 0 ) {
$ttEl . ttpos [ 1 ] = 0 ;
$ttEl . ttpos [ 0 ] += 20 ;
}
$tooltip . css ( {
left : $ttEl . ttpos [ 0 ] ,
top : $ttEl . ttpos [ 1 ]
} ) ;
}
}
}
function onDownloadUrl ( url , fileType ) {
Common . Gateway . downloadAs ( url , fileType ) ;
}
function onPrint ( ) {
if ( permissions . print !== false )
api . asc _Print ( new Asc . asc _CDownloadOptions ( null , $ . browser . chrome || $ . browser . safari || $ . browser . opera || $ . browser . mozilla && $ . browser . versionNumber > 86 ) ) ;
}
function onPrintUrl ( url ) {
common . utils . dialogPrint ( url , api ) ;
}
function onFillRequiredFields ( isFilled ) {
2021-08-30 01:49:25 +00:00
/ * i f ( i s F i l l e d ) {
2021-08-28 23:46:21 +00:00
btnSubmit . removeAttr ( 'disabled' ) ;
btnSubmit . css ( "pointer-events" , "auto" ) ;
// $requiredTooltip && $requiredTooltip.hide();
} else {
btnSubmit . attr ( { disabled : true } ) ;
btnSubmit . css ( "pointer-events" , "none" ) ;
2021-08-30 01:49:25 +00:00
} * /
2021-08-28 23:46:21 +00:00
}
function onShowContentControlsActions ( obj , x , y ) {
switch ( obj . type ) {
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 ;
}
api . asc _addImage ( obj ) ;
setTimeout ( function ( ) {
api . asc _UncheckContentControlButtons ( ) ;
} , 500 ) ;
break ;
case Asc . c _oAscContentControlSpecificType . DropDownList :
case Asc . c _oAscContentControlSpecificType . ComboBox :
onShowListActions ( obj , x , y ) ;
break ;
}
}
function onHideContentControlsActions ( ) {
$listControlMenu && $listControlMenu . hide ( ) ;
api . asc _UncheckContentControlButtons ( ) ;
}
function onShowListActions ( 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 ( ) ;
var menuContainer = DE . ApplicationView . getMenuForm ( ) ;
if ( ! $listControlMenu ) {
$listControlMenu = menuContainer . find ( 'ul' ) ;
$listControlMenu . on ( 'click' , 'li' , function ( e ) {
var value = $ ( e . target ) . attr ( 'value' ) ;
if ( value ) {
value = parseInt ( value ) ;
setTimeout ( function ( ) {
( value !== - 1 ) && api . asc _SelectContentControlListItem ( listControlItems [ value ] , listObj . get _InternalId ( ) ) ;
} , 1 ) ;
}
} ) ;
$ ( '#editor_sdk' ) . on ( 'click' , function ( e ) {
if ( e . target . localName == 'canvas' ) {
if ( me . _preventClick )
me . _preventClick = false ;
else {
$listControlMenu && $listControlMenu . hide ( ) ;
api . asc _UncheckContentControlButtons ( ) ;
}
}
} ) ;
}
$listControlMenu . find ( 'li' ) . remove ( ) ;
listControlItems = [ ] ;
listObj = props ;
if ( specProps ) {
var k = 0 ;
if ( isForm ) { // for dropdown and combobox form control always add placeholder item
var text = props . get _PlaceholderText ( ) ;
$listControlMenu . append ( '<li><a tabindex="-1" type="menuitem" style="opacity: 0.6" value="0">' +
( ( text . trim ( ) !== '' ) ? text : me . txtEmpty ) +
'</a></li>' ) ;
listControlItems . push ( '' ) ;
}
var count = specProps . get _ItemsCount ( ) ;
k = listControlItems . length ;
for ( var i = 0 ; i < count ; i ++ ) {
if ( specProps . get _ItemValue ( i ) !== '' || ! isForm ) {
$listControlMenu . append ( '<li><a tabindex="-1" type="menuitem" value="' + ( i + k ) + '">' +
common . utils . htmlEncode ( specProps . get _ItemDisplayText ( i ) ) +
'</a></li>' ) ;
listControlItems . push ( specProps . get _ItemValue ( i ) ) ;
}
}
if ( ! isForm && listControlItems . length < 1 ) {
$listControlMenu . append ( '<li><a tabindex="-1" type="menuitem" value="0">' +
me . txtEmpty +
'</a></li>' ) ;
listControlItems . push ( - 1 ) ;
}
}
menuContainer . css ( { left : x , top : y } ) ;
me . _preventClick = true ;
$listControlMenu . show ( ) ;
}
function hidePreloader ( ) {
$ ( '#loading-mask' ) . fadeOut ( 'slow' ) ;
}
function onDocumentContentReady ( ) {
hidePreloader ( ) ;
onLongActionEnd ( Asc . c _oAscAsyncActionType [ 'BlockInteraction' ] , LoadingDocument ) ;
var zf = ( config . customization && config . customization . zoom ? parseInt ( config . customization . zoom ) : - 2 ) ;
( zf == - 1 ) ? api . zoomFitToPage ( ) : ( ( zf == - 2 ) ? api . zoomFitToWidth ( ) : api . zoom ( zf > 0 ? zf : 100 ) ) ;
api . asc _registerCallback ( 'asc_onStartAction' , onLongActionBegin ) ;
api . asc _registerCallback ( 'asc_onEndAction' , onLongActionEnd ) ;
api . asc _registerCallback ( 'asc_onMouseMoveStart' , onDocMouseMoveStart ) ;
api . asc _registerCallback ( 'asc_onMouseMoveEnd' , onDocMouseMoveEnd ) ;
api . asc _registerCallback ( 'asc_onMouseMove' , onDocMouseMove ) ;
2021-08-30 01:49:25 +00:00
api . asc _registerCallback ( 'asc_onHyperlinkClick' , common . utils . openLink ) ;
2021-08-28 23:46:21 +00:00
api . asc _registerCallback ( 'asc_onDownloadUrl' , onDownloadUrl ) ;
api . asc _registerCallback ( 'asc_onPrint' , onPrint ) ;
api . asc _registerCallback ( 'asc_onPrintUrl' , onPrintUrl ) ;
2021-08-30 01:49:25 +00:00
api . asc _registerCallback ( 'sync_onAllRequiredFormsFilled' , onFillRequiredFields ) ;
2021-08-28 23:46:21 +00:00
if ( appOptions . canFillForms ) {
api . asc _registerCallback ( 'asc_onShowContentControlsActions' , onShowContentControlsActions ) ;
api . asc _registerCallback ( 'asc_onHideContentControlsActions' , onHideContentControlsActions ) ;
api . asc _SetHighlightRequiredFields ( true ) ;
}
Common . Gateway . on ( 'processmouse' , onProcessMouse ) ;
Common . Gateway . on ( 'downloadas' , onDownloadAs ) ;
Common . Gateway . on ( 'requestclose' , onRequestClose ) ;
var downloadAs = function ( format ) {
api . asc _DownloadAs ( new Asc . asc _CDownloadOptions ( format ) ) ;
} ;
// TODO: add asc_hasRequiredFields to sdk
2021-08-30 01:49:25 +00:00
2021-08-28 23:46:21 +00:00
var documentMoveTimer ;
var ismoved = false ;
$ ( document ) . mousemove ( function ( event ) {
2021-08-30 01:49:25 +00:00
/ * $ ( ' # i d - b t n - z o o m - i n ' ) . f a d e I n ( ) ;
$ ( '#id-btn-zoom-out' ) . fadeIn ( ) ; * /
2021-08-28 23:46:21 +00:00
ismoved = true ;
if ( ! documentMoveTimer ) {
documentMoveTimer = setInterval ( function ( ) {
if ( ! ismoved ) {
2021-08-30 01:49:25 +00:00
/ * $ ( ' # i d - b t n - z o o m - i n ' ) . f a d e O u t ( ) ;
$ ( '#id-btn-zoom-out' ) . fadeOut ( ) ; * /
2021-08-28 23:46:21 +00:00
clearInterval ( documentMoveTimer ) ;
documentMoveTimer = undefined ;
}
ismoved = false ;
} , 2000 ) ;
}
} ) ;
Common . Gateway . documentReady ( ) ;
}
function onEditorPermissions ( params ) {
var licType = params . asc _getLicenseType ( ) ;
appOptions . canLicense = ( licType === Asc . c _oLicenseResult . Success || licType === Asc . c _oLicenseResult . SuccessLimit ) ;
appOptions . canFillForms = appOptions . canLicense && ( permissions . fillForms === true ) && ( config . mode !== 'view' ) ;
appOptions . canSubmitForms = appOptions . canLicense && ( typeof ( config . customization ) == 'object' ) && ! ! config . customization . submitForm ;
api . asc _setViewMode ( ! appOptions . canFillForms ) ;
2021-08-30 01:49:25 +00:00
if ( appOptions . canFillForms ) {
2021-08-28 23:46:21 +00:00
api . asc _setRestriction ( Asc . c _oAscRestrictionType . OnlyForms ) ;
api . asc _SetFastCollaborative ( true ) ;
api . asc _setAutoSaveGap ( 1 ) ;
}
onLongActionBegin ( Asc . c _oAscAsyncActionType [ 'BlockInteraction' ] , LoadingDocument ) ;
api . asc _LoadDocument ( ) ;
api . Resize ( ) ;
}
function onOpenDocument ( progress ) {
var proc = ( progress . asc _getCurrentFont ( ) + progress . asc _getCurrentImage ( ) ) / ( progress . asc _getFontsCount ( ) + progress . asc _getImagesCount ( ) ) ;
me . loadMask && me . loadMask . setTitle ( me . textLoadingDocument + ': ' + common . utils . fixedDigits ( Math . min ( Math . round ( proc * 100 ) , 100 ) , 3 , " " ) + '%' ) ;
}
function onError ( id , level , errData ) {
if ( id == Asc . c _oAscError . ID . LoadingScriptError ) {
$ ( '#id-critical-error-title' ) . text ( me . criticalErrorTitle ) ;
$ ( '#id-critical-error-message' ) . text ( me . scriptLoadError ) ;
$ ( '#id-critical-error-close' ) . text ( me . txtClose ) . off ( ) . on ( 'click' , function ( ) {
window . location . reload ( ) ;
} ) ;
$ ( '#id-critical-error-dialog' ) . css ( 'z-index' , 20002 ) . modal ( 'show' ) ;
return ;
}
hidePreloader ( ) ;
onLongActionEnd ( Asc . c _oAscAsyncActionType [ 'BlockInteraction' ] , LoadingDocument ) ;
var message ;
switch ( id )
{
case Asc . c _oAscError . ID . Unknown :
message = me . unknownErrorText ;
break ;
case Asc . c _oAscError . ID . ConvertationTimeout :
message = me . convertationTimeoutText ;
break ;
case Asc . c _oAscError . ID . ConvertationError :
message = me . convertationErrorText ;
break ;
case Asc . c _oAscError . ID . DownloadError :
message = me . downloadErrorText ;
break ;
case Asc . c _oAscError . ID . ConvertationPassword :
message = me . errorFilePassProtect ;
break ;
case Asc . c _oAscError . ID . UserDrop :
message = me . errorUserDrop ;
break ;
case Asc . c _oAscError . ID . ConvertationOpenLimitError :
message = me . errorFileSizeExceed ;
break ;
case Asc . c _oAscError . ID . UpdateVersion :
message = me . errorUpdateVersionOnDisconnect ;
break ;
case Asc . c _oAscError . ID . AccessDeny :
message = me . errorAccessDeny ;
break ;
case Asc . c _oAscError . ID . Submit :
message = me . errorSubmit ;
_submitFail = true ;
$submitedTooltip && $submitedTooltip . hide ( ) ;
break ;
case Asc . c _oAscError . ID . EditingError :
message = me . errorEditingDownloadas ;
break ;
case Asc . c _oAscError . ID . ForceSaveButton :
case Asc . c _oAscError . ID . ForceSaveTimeout :
message = me . errorForceSave ;
break ;
case Asc . c _oAscError . ID . LoadingFontError :
message = me . errorLoadingFont ;
break ;
default :
message = me . errorDefaultMessage . replace ( '%1' , id ) ;
break ;
}
if ( level == Asc . c _oAscError . Level . Critical ) {
// report only critical errors
Common . Gateway . reportError ( id , message ) ;
$ ( '#id-critical-error-title' ) . text ( me . criticalErrorTitle ) ;
$ ( '#id-critical-error-message' ) . html ( message ) ;
$ ( '#id-critical-error-close' ) . text ( me . txtClose ) . off ( ) . on ( 'click' , function ( ) {
window . location . reload ( ) ;
} ) ;
}
else {
Common . Gateway . reportWarning ( id , message ) ;
$ ( '#id-critical-error-title' ) . text ( me . notcriticalErrorTitle ) ;
$ ( '#id-critical-error-message' ) . html ( message ) ;
$ ( '#id-critical-error-close' ) . text ( me . txtClose ) . off ( ) . on ( 'click' , function ( ) {
$ ( '#id-critical-error-dialog' ) . modal ( 'hide' ) ;
} ) ;
}
$ ( '#id-critical-error-dialog' ) . modal ( 'show' ) ;
}
function onExternalMessage ( error ) {
if ( error ) {
hidePreloader ( ) ;
$ ( '#id-error-mask-title' ) . text ( me . criticalErrorTitle ) ;
$ ( '#id-error-mask-text' ) . text ( error . msg ) ;
$ ( '#id-error-mask' ) . css ( 'display' , 'block' ) ;
}
}
function onProcessMouse ( data ) {
if ( data . type == 'mouseup' ) {
var e = document . getElementById ( 'editor_sdk' ) ;
if ( e ) {
var r = e . getBoundingClientRect ( ) ;
api . OnMouseUp (
data . x - r . left ,
data . y - r . top
) ;
}
}
}
function onRequestClose ( ) {
Common . Gateway . requestClose ( ) ;
}
function onDownloadAs ( ) {
if ( permissions . download === false ) {
Common . Gateway . reportError ( Asc . c _oAscError . ID . AccessDeny , me . errorAccessDeny ) ;
return ;
}
if ( api ) api . asc _DownloadAs ( new Asc . asc _CDownloadOptions ( Asc . c _oAscFileType . DOCX , true ) ) ;
}
function onRunAutostartMacroses ( ) {
if ( ! config . customization || ( config . customization . macros !== false ) )
if ( api ) api . asc _runAutostartMacroses ( ) ;
}
function onBeforeUnload ( ) {
common . localStorage . save ( ) ;
}
// Helpers
// -------------------------
function onDocumentResize ( ) {
api && api . Resize ( ) ;
bodyWidth = $ ( 'body' ) . width ( ) ;
}
function createController ( ) {
if ( created )
return me ;
me = this ;
created = true ;
$ ( window ) . resize ( function ( ) {
onDocumentResize ( ) ;
} ) ;
window . onbeforeunload = onBeforeUnload ;
var ismodalshown = false ;
$ ( document . body ) . on ( 'show.bs.modal' , '.modal' ,
function ( e ) {
ismodalshown = true ;
api . asc _enableKeyEvents ( false ) ;
}
) . on ( 'hidden.bs.modal' , '.modal' ,
function ( e ) {
ismodalshown = false ;
api . asc _enableKeyEvents ( true ) ;
}
) . on ( 'hidden.bs.dropdown' , '.dropdown' ,
function ( e ) {
if ( ! ismodalshown )
api . asc _enableKeyEvents ( true ) ;
}
) . on ( 'blur' , 'input, textarea' ,
function ( e ) {
if ( ! ismodalshown ) {
if ( ! /area_id/ . test ( e . target . id ) ) {
api . asc _enableKeyEvents ( true ) ;
}
}
}
) ;
$ ( '#editor_sdk' ) . on ( 'click' , function ( e ) {
if ( e . target . localName == 'canvas' ) {
e . currentTarget . focus ( ) ;
}
} ) ;
2021-08-30 01:49:25 +00:00
window [ "flat_desine" ] = true ;
2021-08-28 23:46:21 +00:00
api = new Asc . asc _docs _api ( {
'id-view' : 'editor_sdk' ,
'embedded' : true
} ) ;
if ( api ) {
api . asc _registerCallback ( 'asc_onError' , onError ) ;
api . asc _registerCallback ( 'asc_onDocumentContentReady' , onDocumentContentReady ) ;
api . asc _registerCallback ( 'asc_onOpenDocumentProgress' , onOpenDocument ) ;
api . asc _registerCallback ( 'asc_onCountPages' , onCountPages ) ;
// api.asc_registerCallback('OnCurrentVisiblePage', onCurrentPage);
api . asc _registerCallback ( 'asc_onCurrentPage' , onCurrentPage ) ;
// Initialize api gateway
Common . Gateway . on ( 'init' , loadConfig ) ;
Common . Gateway . on ( 'opendocument' , loadDocument ) ;
Common . Gateway . on ( 'showmessage' , onExternalMessage ) ;
Common . Gateway . appReady ( ) ;
}
return me ;
}
return {
create : createController ,
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.' ,
textNext : 'Next Field' ,
textClear : 'Clear All Fields' ,
textSubmit : 'Submit' ,
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." ,
txtEmpty : '(Empty)' ,
txtPressLink : 'Press Ctrl and click link' ,
errorLoadingFont : 'Fonts are not loaded.<br>Please contact your Document Server administrator.'
}
} ) ( ) ;