2016-04-01 13:17:09 +00:00
/ *
*
2019-01-17 13:05:03 +00:00
* ( c ) Copyright Ascensio System SIA 2010 - 2019
2016-04-01 13:17:09 +00:00
*
* This program is a free software product . You can redistribute it and / or
* modify it under the terms of the GNU Affero General Public License ( AGPL )
* version 3 as published by the Free Software Foundation . In accordance with
* Section 7 ( a ) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non - infringement
* of any third - party rights .
*
* This program is distributed WITHOUT ANY WARRANTY ; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . For
* details , see the GNU AGPL at : http : //www.gnu.org/licenses/agpl-3.0.html
*
2019-01-17 13:00:34 +00:00
* You can contact Ascensio System SIA at 20 A - 12 Ernesta Birznieka - Upisha
* street , Riga , Latvia , EU , LV - 1050.
2016-04-01 13:17:09 +00:00
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices , as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7 ( b ) of the License you must retain the original Product
* logo when distributing the program . Pursuant to Section 7 ( e ) we decline to
* grant you any rights under trademark law for use of our trademarks .
*
* All the Product ' s GUI elements , including illustrations and icon sets , as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution - ShareAlike 4.0 International . See the License
* terms at http : //creativecommons.org/licenses/by-sa/4.0/legalcode
*
* /
2016-03-11 00:48:53 +00:00
/ * *
* DocumentHolder . js
*
* DocumentHolder controller
*
* Created by Alexander Yuzhin on 1 / 15 / 14
2018-03-01 12:16:38 +00:00
* Copyright ( c ) 2018 Ascensio System SIA . All rights reserved .
2016-03-11 00:48:53 +00:00
*
* /
var c _paragraphLinerule = {
LINERULE _LEAST : 0 ,
LINERULE _AUTO : 1 ,
LINERULE _EXACT : 2
} ;
2019-07-31 08:45:21 +00:00
var c _paragraphSpecial = {
NONE _SPECIAL : 0 ,
2019-07-29 09:24:16 +00:00
FIRST _LINE : 1 ,
HANGING : 2
} ;
var c _paragraphTextAlignment = {
RIGHT : 0 ,
LEFT : 1 ,
CENTERED : 2 ,
JUSTIFIED : 3
} ;
2016-03-11 00:48:53 +00:00
var c _pageNumPosition = {
PAGE _NUM _POSITION _TOP : 0x01 ,
PAGE _NUM _POSITION _BOTTOM : 0x02 ,
PAGE _NUM _POSITION _RIGHT : 0 ,
PAGE _NUM _POSITION _LEFT : 1 ,
PAGE _NUM _POSITION _CENTER : 2
} ;
var c _tableWrap = {
TABLE _WRAP _NONE : 0 ,
TABLE _WRAP _PARALLEL : 1
} ;
var c _tableAlign = {
TABLE _ALIGN _LEFT : 0 ,
TABLE _ALIGN _CENTER : 1 ,
TABLE _ALIGN _RIGHT : 2
} ;
var c _tableBorder = {
BORDER _VERTICAL _LEFT : 0 ,
BORDER _HORIZONTAL _TOP : 1 ,
BORDER _VERTICAL _RIGHT : 2 ,
BORDER _HORIZONTAL _BOTTOM : 3 ,
BORDER _VERTICAL _CENTER : 4 ,
BORDER _HORIZONTAL _CENTER : 5 ,
BORDER _INNER : 6 ,
BORDER _OUTER : 7 ,
BORDER _ALL : 8 ,
BORDER _NONE : 9 ,
BORDER _ALL _TABLE : 10 , // table border and all cell borders
BORDER _NONE _TABLE : 11 , // table border and no cell borders
BORDER _INNER _TABLE : 12 , // table border and inner cell borders
BORDER _OUTER _TABLE : 13 // table border and outer cell borders
} ;
define ( [
'core' ,
'documenteditor/main/app/view/DocumentHolder'
] , function ( ) {
'use strict' ;
DE . Controllers . DocumentHolder = Backbone . Controller . extend ( {
models : [ ] ,
collections : [ ] ,
views : [
'DocumentHolder'
] ,
initialize : function ( ) {
//
2022-04-27 19:24:39 +00:00
this . addListeners ( {
'DocumentHolder' : {
'createdelayedelements' : this . createDelayedElements ,
'equation:callback' : this . equationCallback
}
} ) ;
var me = this ;
me . _TtHeight = 20 ;
me . usertips = [ ] ;
me . fastcoauthtips = [ ] ;
me . _isDisabled = false ;
me . _state = { } ;
me . mode = { } ;
me . mouseMoveData = null ;
me . isTooltipHiding = false ;
me . screenTip = {
toolTip : new Common . UI . Tooltip ( {
owner : this ,
html : true ,
title : '<br><b>Press Ctrl and click link</b>' ,
cls : 'link-tooltip'
// style: 'word-wrap: break-word;'
} ) ,
strTip : '' ,
isHidden : true ,
isVisible : false
} ;
me . userTooltip = true ;
me . wrapEvents = {
userTipMousover : _ . bind ( me . userTipMousover , me ) ,
2022-06-01 19:49:52 +00:00
userTipMousout : _ . bind ( me . userTipMousout , me ) ,
onKeyUp : _ . bind ( me . onKeyUp , me )
2022-04-27 19:24:39 +00:00
} ;
var keymap = { } ;
me . hkComments = 'alt+h' ;
keymap [ me . hkComments ] = function ( ) {
if ( me . api . can _AddQuotedComment ( ) !== false ) {
me . addComment ( ) ;
}
} ;
Common . util . Shortcuts . delegateShortcuts ( { shortcuts : keymap } ) ;
2016-03-11 00:48:53 +00:00
} ,
onLaunch : function ( ) {
this . documentHolder = this . createView ( 'DocumentHolder' ) . render ( ) ;
this . documentHolder . el . tabIndex = - 1 ;
2022-04-27 19:24:39 +00:00
this . onAfterRender ( ) ;
var me = this ;
Common . NotificationCenter . on ( {
'window:show' : function ( e ) {
me . screenTip . toolTip . hide ( ) ;
me . screenTip . isVisible = false ;
/** coauthoring begin **/
me . userTipHide ( ) ;
/** coauthoring end **/
me . mode && me . mode . isDesktopApp && me . api && me . api . asc _onShowPopupWindow ( ) ;
} ,
'modal:show' : function ( e ) {
me . hideTips ( ) ;
} ,
'layout:changed' : function ( e ) {
me . screenTip . toolTip . hide ( ) ;
me . screenTip . isVisible = false ;
/** coauthoring begin **/
me . userTipHide ( ) ;
/** coauthoring end **/
me . hideTips ( ) ;
me . onDocumentHolderResize ( ) ;
}
} ) ;
} ,
setApi : function ( o ) {
this . api = o ;
if ( this . api ) {
this . api . asc _registerCallback ( 'asc_onContextMenu' , _ . bind ( this . onContextMenu , this ) ) ;
this . api . asc _registerCallback ( 'asc_onMouseMoveStart' , _ . bind ( this . onMouseMoveStart , this ) ) ;
this . api . asc _registerCallback ( 'asc_onMouseMoveEnd' , _ . bind ( this . onMouseMoveEnd , this ) ) ;
//hyperlink
this . api . asc _registerCallback ( 'asc_onHyperlinkClick' , _ . bind ( this . onHyperlinkClick , this ) ) ;
this . api . asc _registerCallback ( 'asc_onMouseMove' , _ . bind ( this . onMouseMove , this ) ) ;
if ( this . mode . isEdit === true ) {
this . api . asc _registerCallback ( 'asc_onImgWrapStyleChanged' , _ . bind ( this . onImgWrapStyleChanged , this ) ) ;
this . api . asc _registerCallback ( 'asc_onDialogAddHyperlink' , _ . bind ( this . onDialogAddHyperlink , this ) ) ;
this . api . asc _registerCallback ( 'asc_doubleClickOnChart' , _ . bind ( this . onDoubleClickOnChart , this ) ) ;
this . api . asc _registerCallback ( 'asc_doubleClickOnTableOleObject' , _ . bind ( this . onDoubleClickOnTableOleObject , this ) ) ;
this . api . asc _registerCallback ( 'asc_onSpellCheckVariantsFound' , _ . bind ( this . onSpellCheckVariantsFound , this ) ) ;
this . api . asc _registerCallback ( 'asc_onRulerDblClick' , _ . bind ( this . onRulerDblClick , this ) ) ;
this . api . asc _registerCallback ( 'asc_ChangeCropState' , _ . bind ( this . onChangeCropState , this ) ) ;
this . api . asc _registerCallback ( 'asc_onLockDocumentProps' , _ . bind ( this . onApiLockDocumentProps , this ) ) ;
this . api . asc _registerCallback ( 'asc_onUnLockDocumentProps' , _ . bind ( this . onApiUnLockDocumentProps , this ) ) ;
}
this . api . asc _registerCallback ( 'asc_onCoAuthoringDisconnect' , _ . bind ( this . onCoAuthoringDisconnect , this ) ) ;
Common . NotificationCenter . on ( 'api:disconnect' , _ . bind ( this . onCoAuthoringDisconnect , this ) ) ;
this . api . asc _registerCallback ( 'asc_onTextLanguage' , _ . bind ( this . onTextLanguage , this ) ) ;
this . api . asc _registerCallback ( 'asc_onParaStyleName' , _ . bind ( this . onApiParagraphStyleChange , this ) ) ;
this . api . asc _registerCallback ( 'asc_onShowForeignCursorLabel' , _ . bind ( this . onShowForeignCursorLabel , this ) ) ;
this . api . asc _registerCallback ( 'asc_onHideForeignCursorLabel' , _ . bind ( this . onHideForeignCursorLabel , this ) ) ;
this . api . asc _registerCallback ( 'asc_onFocusObject' , _ . bind ( this . onFocusObject , this ) ) ;
this . api . asc _registerCallback ( 'asc_onShowSpecialPasteOptions' , _ . bind ( this . onShowSpecialPasteOptions , this ) ) ;
this . api . asc _registerCallback ( 'asc_onHideSpecialPasteOptions' , _ . bind ( this . onHideSpecialPasteOptions , this ) ) ;
if ( this . mode . isEdit || this . mode . isRestrictedEdit && this . mode . canFillForms ) {
this . api . asc _registerCallback ( 'asc_onShowContentControlsActions' , _ . bind ( this . onShowContentControlsActions , this ) ) ;
this . api . asc _registerCallback ( 'asc_onHideContentControlsActions' , _ . bind ( this . onHideContentControlsActions , this ) ) ;
}
this . documentHolder . setApi ( this . api ) ;
}
return this ;
2016-03-11 00:48:53 +00:00
} ,
2022-04-27 19:24:39 +00:00
setMode : function ( m ) {
this . mode = m ;
/** coauthoring begin **/
! ( this . mode . canCoAuthoring && this . mode . canComments )
? Common . util . Shortcuts . suspendEvents ( this . hkComments )
: Common . util . Shortcuts . resumeEvents ( this . hkComments ) ;
/** coauthoring end **/
this . documentHolder . setMode ( m ) ;
2016-03-11 00:48:53 +00:00
} ,
2022-04-27 19:24:39 +00:00
createDelayedElements : function ( view , type ) {
var me = this ,
view = me . documentHolder ;
if ( type == 'view' ) {
view . menuViewCopy . on ( 'click' , _ . bind ( me . onCutCopyPaste , me ) ) ;
view . menuViewPaste . on ( 'click' , _ . bind ( me . onCutCopyPaste , me ) ) ;
view . menuViewCut . on ( 'click' , _ . bind ( me . onCutCopyPaste , me ) ) ;
2022-05-04 19:18:04 +00:00
view . menuViewUndo . on ( 'click' , _ . bind ( me . onUndo , me ) ) ;
2022-04-27 19:24:39 +00:00
view . menuViewAddComment . on ( 'click' , _ . bind ( me . addComment , me ) ) ;
view . menuSignatureViewSign . on ( 'click' , _ . bind ( me . onSignatureClick , me ) ) ;
view . menuSignatureDetails . on ( 'click' , _ . bind ( me . onSignatureClick , me ) ) ;
view . menuSignatureViewSetup . on ( 'click' , _ . bind ( me . onSignatureClick , me ) ) ;
view . menuSignatureRemove . on ( 'click' , _ . bind ( me . onSignatureClick , me ) ) ;
view . menuViewPrint . on ( 'click' , _ . bind ( me . onPrintSelection , me ) ) ;
return ;
} else if ( type == 'pdf' ) {
view . menuPDFViewCopy . on ( 'click' , _ . bind ( me . onCutCopyPaste , me ) ) ;
return ;
}
// type == 'edit'
2016-03-11 00:48:53 +00:00
var diagramEditor = this . getApplication ( ) . getController ( 'Common.Controllers.ExternalDiagramEditor' ) . getView ( 'Common.Views.ExternalDiagramEditor' ) ;
if ( diagramEditor ) {
diagramEditor . on ( 'internalmessage' , _ . bind ( function ( cmp , message ) {
var command = message . data . command ;
var data = message . data . data ;
if ( this . api ) {
( diagramEditor . isEditMode ( ) )
? this . api . asc _editChartDrawingObject ( data )
: this . api . asc _addChartDrawingObject ( data ) ;
}
} , this ) ) ;
diagramEditor . on ( 'hide' , _ . bind ( function ( cmp , message ) {
if ( this . api ) {
this . api . asc _onCloseChartFrame ( ) ;
this . api . asc _enableKeyEvents ( true ) ;
}
2019-08-26 13:48:10 +00:00
setTimeout ( function ( ) {
2022-05-04 19:59:02 +00:00
me . editComplete ( ) ;
2019-08-26 13:48:10 +00:00
} , 10 ) ;
2016-03-11 00:48:53 +00:00
} , this ) ) ;
}
var mergeEditor = this . getApplication ( ) . getController ( 'Common.Controllers.ExternalMergeEditor' ) . getView ( 'Common.Views.ExternalMergeEditor' ) ;
if ( mergeEditor ) {
mergeEditor . on ( 'internalmessage' , _ . bind ( function ( cmp , message ) {
var command = message . data . command ;
var data = message . data . data ;
if ( this . api )
this . api . asc _setMailMergeData ( data ) ;
} , this ) ) ;
mergeEditor . on ( 'hide' , _ . bind ( function ( cmp , message ) {
if ( this . api ) {
this . api . asc _enableKeyEvents ( true ) ;
}
2019-08-26 13:48:10 +00:00
setTimeout ( function ( ) {
2022-05-04 19:59:02 +00:00
me . editComplete ( ) ;
2019-08-26 13:48:10 +00:00
} , 10 ) ;
2016-03-11 00:48:53 +00:00
} , this ) ) ;
}
2022-03-10 16:21:29 +00:00
var oleEditor = this . getApplication ( ) . getController ( 'Common.Controllers.ExternalOleEditor' ) . getView ( 'Common.Views.ExternalOleEditor' ) ;
if ( oleEditor ) {
2022-03-11 10:04:30 +00:00
oleEditor . on ( 'internalmessage' , _ . bind ( function ( cmp , message ) {
2022-03-10 16:21:29 +00:00
var command = message . data . command ;
var data = message . data . data ;
if ( this . api ) {
2022-04-01 14:49:24 +00:00
oleEditor . isEditMode ( )
? this . api . asc _editTableOleObject ( data )
: this . api . asc _addTableOleObject ( data ) ;
2022-03-10 16:21:29 +00:00
}
} , this ) ) ;
2022-03-11 10:04:30 +00:00
oleEditor . on ( 'hide' , _ . bind ( function ( cmp , message ) {
2022-03-10 16:21:29 +00:00
if ( this . api ) {
this . api . asc _enableKeyEvents ( true ) ;
}
setTimeout ( function ( ) {
2022-05-04 19:59:02 +00:00
me . editComplete ( ) ;
2022-03-10 16:21:29 +00:00
} , 10 ) ;
} , this ) ) ;
}
2022-04-27 19:24:39 +00:00
view . menuInsertCaption . on ( 'click' , _ . bind ( me . onInsertCaption , me ) ) ;
view . menuEquationInsertCaption . on ( 'click' , _ . bind ( me . onInsertCaption , me ) ) ;
view . menuTableInsertCaption . on ( 'click' , _ . bind ( me . onInsertCaption , me ) ) ;
view . menuChartEdit . on ( 'click' , _ . bind ( me . editChartClick , me ) ) ;
view . menuImgCopy . on ( 'click' , _ . bind ( me . onCutCopyPaste , me ) ) ;
view . menuImgPaste . on ( 'click' , _ . bind ( me . onCutCopyPaste , me ) ) ;
view . menuImgCut . on ( 'click' , _ . bind ( me . onCutCopyPaste , me ) ) ;
view . menuTableCopy . on ( 'click' , _ . bind ( me . onCutCopyPaste , me ) ) ;
view . menuTablePaste . on ( 'click' , _ . bind ( me . onCutCopyPaste , me ) ) ;
view . menuTableCut . on ( 'click' , _ . bind ( me . onCutCopyPaste , me ) ) ;
view . menuParaCopy . on ( 'click' , _ . bind ( me . onCutCopyPaste , me ) ) ;
view . menuParaPaste . on ( 'click' , _ . bind ( me . onCutCopyPaste , me ) ) ;
view . menuParaCut . on ( 'click' , _ . bind ( me . onCutCopyPaste , me ) ) ;
view . menuImgAccept . on ( 'click' , _ . bind ( me . onAcceptRejectChange , me ) ) ;
view . menuImgReject . on ( 'click' , _ . bind ( me . onAcceptRejectChange , me ) ) ;
view . menuTableAccept . on ( 'click' , _ . bind ( me . onAcceptRejectChange , me ) ) ;
view . menuTableReject . on ( 'click' , _ . bind ( me . onAcceptRejectChange , me ) ) ;
view . menuParaAccept . on ( 'click' , _ . bind ( me . onAcceptRejectChange , me ) ) ;
view . menuParaReject . on ( 'click' , _ . bind ( me . onAcceptRejectChange , me ) ) ;
view . menuImgPrint . on ( 'click' , _ . bind ( me . onPrintSelection , me ) ) ;
view . menuTablePrint . on ( 'click' , _ . bind ( me . onPrintSelection , me ) ) ;
view . menuParaPrint . on ( 'click' , _ . bind ( me . onPrintSelection , me ) ) ;
view . menuSignatureEditSign . on ( 'click' , _ . bind ( me . onSignatureClick , me ) ) ;
view . menuSignatureEditSetup . on ( 'click' , _ . bind ( me . onSignatureClick , me ) ) ;
view . menuImgRotate . menu . items [ 0 ] . on ( 'click' , _ . bind ( me . onImgRotate , me ) ) ;
view . menuImgRotate . menu . items [ 1 ] . on ( 'click' , _ . bind ( me . onImgRotate , me ) ) ;
view . menuImgRotate . menu . items [ 3 ] . on ( 'click' , _ . bind ( me . onImgFlip , me ) ) ;
view . menuImgRotate . menu . items [ 4 ] . on ( 'click' , _ . bind ( me . onImgFlip , me ) ) ;
view . menuImgCrop . menu . on ( 'item:click' , _ . bind ( me . onImgCrop , me ) ) ;
view . menuImgRemoveControl . on ( 'click' , _ . bind ( me . onControlsSelect , me ) ) ;
view . menuImgControlSettings . on ( 'click' , _ . bind ( me . onControlsSelect , me ) ) ;
view . menuTableRemoveForm . on ( 'click' , _ . bind ( me . onControlsSelect , me ) ) ;
view . menuTableRemoveControl . on ( 'click' , _ . bind ( me . onControlsSelect , me ) ) ;
view . menuTableControlSettings . on ( 'click' , _ . bind ( me . onControlsSelect , me ) ) ;
view . menuParaRemoveControl . on ( 'click' , _ . bind ( me . onControlsSelect , me ) ) ;
view . menuParaControlSettings . on ( 'click' , _ . bind ( me . onControlsSelect , me ) ) ;
view . menuTableCellAlign . menu . on ( 'item:click' , _ . bind ( me . tableCellsVAlign , me ) ) ;
view . menuTableAdvanced . on ( 'click' , _ . bind ( me . advancedTableClick , me ) ) ;
view . menuParagraphAdvancedInTable . on ( 'click' , _ . bind ( me . advancedParagraphClick , me ) ) ;
view . menuParagraphAdvanced . on ( 'click' , _ . bind ( me . advancedParagraphClick , me ) ) ;
view . menuEditHyperlinkTable . on ( 'click' , _ . bind ( me . editHyperlink , me ) ) ;
view . menuEditHyperlinkPara . on ( 'click' , _ . bind ( me . editHyperlink , me ) ) ;
2022-05-04 19:18:04 +00:00
view . menuRemoveHyperlinkTable . on ( 'click' , _ . bind ( me . onRemoveHyperlink , me ) ) ;
view . menuRemoveHyperlinkPara . on ( 'click' , _ . bind ( me . onRemoveHyperlink , me ) ) ;
2022-04-27 19:24:39 +00:00
view . menuAddHyperlinkTable . on ( 'click' , _ . bind ( me . addHyperlink , me ) ) ;
view . menuAddHyperlinkPara . on ( 'click' , _ . bind ( me . addHyperlink , me ) ) ;
2022-05-04 19:18:04 +00:00
view . menuAddCommentTable . on ( 'click' , _ . bind ( me . addComment , me ) ) ;
view . menuAddCommentPara . on ( 'click' , _ . bind ( me . addComment , me ) ) ;
2022-04-27 19:24:39 +00:00
view . menuTableFollow . on ( 'click' , _ . bind ( me . onFollowMove , me ) ) ;
view . menuParaFollow . on ( 'click' , _ . bind ( me . onFollowMove , me ) ) ;
view . menuTableStartNewList . on ( 'click' , _ . bind ( me . onStartNumbering , me , 1 ) ) ;
view . menuParaStartNewList . on ( 'click' , _ . bind ( me . onStartNumbering , me , 1 ) ) ;
view . menuTableStartNumberingFrom . on ( 'click' , _ . bind ( me . onStartNumbering , me , 'advanced' ) ) ;
view . menuParaStartNumberingFrom . on ( 'click' , _ . bind ( me . onStartNumbering , me , 'advanced' ) ) ;
view . menuTableContinueNumbering . on ( 'click' , _ . bind ( me . onContinueNumbering , me ) ) ;
view . menuParaContinueNumbering . on ( 'click' , _ . bind ( me . onContinueNumbering , me ) ) ;
view . menuFrameAdvanced . on ( 'click' , _ . bind ( me . advancedFrameClick , me , true ) ) ;
view . menuDropCapAdvanced . on ( 'click' , _ . bind ( me . advancedFrameClick , me , false ) ) ;
view . menuStyleSave . on ( 'click' , _ . bind ( me . onMenuSaveStyle , me ) ) ;
view . menuStyleUpdate . on ( 'click' , _ . bind ( me . onMenuUpdateStyle , me ) ) ;
2022-04-29 12:55:24 +00:00
view . menuTableSelectText . menu . on ( 'item:click' , _ . bind ( me . tableSelectText , me ) ) ;
view . menuTableInsertText . menu . on ( 'item:click' , _ . bind ( me . tableInsertText , me ) ) ;
view . menuTableDeleteText . menu . on ( 'item:click' , _ . bind ( me . tableDeleteText , me ) ) ;
2022-05-04 13:51:53 +00:00
view . menuImageAlign . menu . on ( 'item:click' , _ . bind ( me . onImgAlign , me ) ) ;
view . menuImageArrange . menu . on ( 'item:click' , _ . bind ( me . onImgArrange , me ) ) ;
view . mnuGroup . on ( 'click' , _ . bind ( me . onImgGroup , me ) ) ;
view . mnuUnGroup . on ( 'click' , _ . bind ( me . onImgUnGroup , me ) ) ;
view . menuWrapPolygon . on ( 'click' , _ . bind ( me . onImgWrapPolygon , me ) ) ;
view . menuImageWrap . menu . on ( 'item:click' , _ . bind ( me . onImgWrap , me ) ) ;
view . menuImageAdvanced . on ( 'click' , _ . bind ( me . onImgAdvanced , me ) ) ;
view . menuOriginalSize . on ( 'click' , _ . bind ( me . onImgOriginalSize , me ) ) ;
view . menuImgReplace . menu . on ( 'item:click' , _ . bind ( me . onImgReplace , me ) ) ;
view . menuImgEditPoints . on ( 'click' , _ . bind ( me . onImgEditPoints , me ) ) ;
2022-05-04 19:18:04 +00:00
view . mnuTableMerge . on ( 'click' , _ . bind ( me . onTableMerge , me ) ) ;
view . mnuTableSplit . on ( 'click' , _ . bind ( me . onTableSplit , me ) ) ;
view . menuIgnoreSpellTable . on ( 'click' , _ . bind ( me . onIgnoreSpell , me ) ) ;
view . menuIgnoreSpellPara . on ( 'click' , _ . bind ( me . onIgnoreSpell , me ) ) ;
view . menuIgnoreAllSpellTable . on ( 'click' , _ . bind ( me . onIgnoreSpell , me ) ) ;
view . menuIgnoreAllSpellPara . on ( 'click' , _ . bind ( me . onIgnoreSpell , me ) ) ;
view . menuToDictionaryTable . on ( 'click' , _ . bind ( me . onToDictionary , me ) ) ;
view . menuToDictionaryPara . on ( 'click' , _ . bind ( me . onToDictionary , me ) ) ;
view . menuTableDistRows . on ( 'click' , _ . bind ( me . onTableDist , me ) ) ;
view . menuTableDistCols . on ( 'click' , _ . bind ( me . onTableDist , me ) ) ;
view . menuTableDirection . menu . on ( 'item:click' , _ . bind ( me . tableDirection , me ) ) ;
view . menuTableRefreshField . on ( 'click' , _ . bind ( me . onRefreshField , me ) ) ;
view . menuParaRefreshField . on ( 'click' , _ . bind ( me . onRefreshField , me ) ) ;
view . menuParagraphBreakBefore . on ( 'click' , _ . bind ( me . onParagraphBreakBefore , me ) ) ;
view . menuParagraphKeepLines . on ( 'click' , _ . bind ( me . onParagraphKeepLines , me ) ) ;
view . menuParagraphVAlign . menu . on ( 'item:click' , _ . bind ( me . paragraphVAlign , me ) ) ;
view . menuParagraphDirection . menu . on ( 'item:click' , _ . bind ( me . paragraphDirection , me ) ) ;
view . langParaMenu . menu . on ( 'item:click' , _ . bind ( me . onLangMenu , me , 'para' ) ) ;
view . langTableMenu . menu . on ( 'item:click' , _ . bind ( me . onLangMenu , me , 'table' ) ) ;
2022-05-04 20:18:05 +00:00
view . menuTableTOC . menu . on ( 'item:click' , _ . bind ( me . onTOCMenu , me ) ) ;
view . menuParaTOCRefresh . menu . on ( 'item:click' , _ . bind ( me . onTOCMenu , me ) ) ;
view . menuParaTOCSettings . on ( 'click' , _ . bind ( me . onParaTOCSettings , me ) ) ;
2017-04-03 16:24:24 +00:00
} ,
getView : function ( name ) {
return ! name ?
this . documentHolder : Backbone . Controller . prototype . getView . call ( )
2022-04-27 19:24:39 +00:00
} ,
showPopupMenu : function ( menu , value , event , docElement , eOpts ) {
var me = this ;
if ( ! _ . isUndefined ( menu ) && menu !== null ) {
Common . UI . Menu . Manager . hideAll ( ) ;
var showPoint = [ event . get _X ( ) , event . get _Y ( ) ] ,
menuContainer = $ ( me . documentHolder . el ) . 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 ) ) ;
$ ( me . documentHolder . el ) . 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 ) ;
2022-04-28 21:06:04 +00:00
me . documentHolder . currentMenu = menu ;
2022-04-27 19:24:39 +00:00
}
} ,
fillMenuProps : function ( selectedElements ) {
if ( ! selectedElements || ! _ . isArray ( selectedElements ) ) return ;
var me = this ,
documentHolder = this . documentHolder ;
var menu _props = { } ,
menu _to _show = documentHolder . textMenu ,
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 _to _show = documentHolder . pictureMenu ;
if ( menu _props . imgProps === undefined )
menu _props . imgProps = { } ;
var shapeprops = elValue . get _ShapeProperties ( ) ;
var chartprops = elValue . get _ChartProperties ( ) ;
if ( shapeprops ) {
if ( shapeprops . get _FromChart ( ) )
menu _props . imgProps . isChart = true ;
else if ( shapeprops . get _FromImage ( ) )
menu _props . imgProps . isOnlyImg = true ;
else {
if ( shapeprops . get _FromSmartArt ( ) )
menu _props . imgProps . isSmartArt = true ;
if ( shapeprops . get _FromSmartArtInternal ( ) )
menu _props . imgProps . isSmartArtInternal = true ;
menu _props . imgProps . isShape = true ;
}
} else if ( chartprops )
menu _props . imgProps . isChart = true ;
else
menu _props . imgProps . isImg = true ;
menu _props . imgProps . value = elValue ;
menu _props . imgProps . locked = ( elValue ) ? elValue . get _Locked ( ) : false ;
noobject = false ;
if ( ( shapeprops === undefined || shapeprops === null ) && ( chartprops === undefined || chartprops === null ) ) // not shape and chart
break ;
} else if ( Asc . c _oAscTypeSelectElement . Table == elType )
{
menu _to _show = documentHolder . tableMenu ;
menu _props . tableProps = { } ;
menu _props . tableProps . value = elValue ;
menu _props . tableProps . locked = ( elValue ) ? elValue . get _Locked ( ) : false ;
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 ;
if ( menu _props . imgProps && ( menu _props . imgProps . isChart || menu _props . imgProps . isShape ) && // text in shape, need to show paragraph menu with vertical align
menu _props . tableProps === undefined )
menu _to _show = documentHolder . textMenu ;
noobject = false ;
} else if ( Asc . c _oAscTypeSelectElement . Hyperlink == elType ) {
if ( menu _props . hyperProps )
menu _props . hyperProps . isSeveralLinks = true ;
else
menu _props . hyperProps = { } ;
menu _props . hyperProps . value = elValue ;
} else if ( Asc . c _oAscTypeSelectElement . Header == elType ) {
menu _props . headerProps = { } ;
menu _props . headerProps . locked = ( elValue ) ? elValue . get _Locked ( ) : false ;
} else if ( Asc . c _oAscTypeSelectElement . SpellCheck == elType ) {
menu _props . spellProps = { } ;
menu _props . spellProps . value = elValue ;
me . documentHolder . _currentSpellObj = elValue ;
} else if ( Asc . c _oAscTypeSelectElement . Math == elType ) {
menu _props . mathProps = { } ;
menu _props . mathProps . value = elValue ;
me . documentHolder . _currentMathObj = elValue ;
}
}
return ( ! noobject ) ? { menu _to _show : menu _to _show , menu _props : menu _props } : null ;
} ,
fillViewMenuProps : function ( selectedElements ) {
if ( ! selectedElements || ! _ . isArray ( selectedElements ) ) return ;
2022-04-28 21:06:04 +00:00
var documentHolder = this . documentHolder ;
2022-04-27 19:24:39 +00:00
if ( ! documentHolder . viewModeMenu )
documentHolder . createDelayedElementsViewer ( ) ;
var menu _props = { } ,
menu _to _show = documentHolder . viewModeMenu ,
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 ;
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 . Text == elType )
{
if ( ! documentHolder . viewPDFModeMenu )
documentHolder . createDelayedElementsPDFViewer ( ) ;
menu _to _show = documentHolder . viewPDFModeMenu ;
noobject = false ;
}
}
return ( ! noobject ) ? { menu _to _show : menu _to _show , menu _props : menu _props } : null ;
} ,
showObjectMenu : function ( event , docElement , eOpts ) {
var me = this ;
if ( me . api ) {
var obj = ( me . mode . isEdit && ! me . _isDisabled ) ? me . fillMenuProps ( me . api . getSelectedElements ( ) ) : me . fillViewMenuProps ( me . api . getSelectedElements ( ) ) ;
if ( obj ) me . showPopupMenu ( obj . menu _to _show , obj . menu _props , event , docElement , eOpts ) ;
}
} ,
onContextMenu : function ( event ) {
if ( Common . UI . HintManager . isHintVisible ( ) )
Common . UI . HintManager . clearHints ( ) ;
if ( ! event ) {
Common . UI . Menu . Manager . hideAll ( ) ;
return ;
}
var me = this ;
_ . delay ( function ( ) {
if ( event . get _Type ( ) == 0 ) {
me . showObjectMenu . call ( me , event ) ;
} else {
me . showPopupMenu . call ( me , me . documentHolder . hdrMenu , { Header : event . is _Header ( ) , PageNum : event . get _PageNum ( ) } , event ) ;
}
} , 10 ) ;
} ,
onFocusObject : function ( selectedElements ) {
2022-04-28 21:06:04 +00:00
var me = this ,
currentMenu = me . documentHolder . currentMenu ;
if ( currentMenu && currentMenu . isVisible ( ) && currentMenu !== me . documentHolder . hdrMenu ) {
2022-04-27 19:24:39 +00:00
var obj = ( me . mode . isEdit && ! me . _isDisabled ) ? me . fillMenuProps ( selectedElements ) : me . fillViewMenuProps ( selectedElements ) ;
if ( obj ) {
2022-04-28 21:06:04 +00:00
if ( obj . menu _to _show === currentMenu ) {
currentMenu . options . initMenu ( obj . menu _props ) ;
currentMenu . alignPosition ( ) ;
2022-04-27 19:24:39 +00:00
}
}
}
} ,
handleDocumentWheel : function ( event ) {
var me = this ;
if ( me . api ) {
var delta = ( _ . isUndefined ( event . originalEvent ) ) ? event . wheelDelta : event . originalEvent . wheelDelta ;
if ( _ . isUndefined ( delta ) ) {
delta = event . deltaY ;
}
2022-05-25 10:13:03 +00:00
if ( event . ctrlKey && ! event . altKey ) {
2022-04-27 19:24:39 +00:00
if ( delta < 0 ) {
me . api . zoomOut ( ) ;
} else if ( delta > 0 ) {
me . api . zoomIn ( ) ;
}
event . preventDefault ( ) ;
event . stopPropagation ( ) ;
}
}
} ,
handleDocumentKeyDown : function ( event ) {
var me = this ;
if ( me . api ) {
var key = event . keyCode ;
2022-06-01 19:49:52 +00:00
if ( me . hkSpecPaste ) {
me . _needShowSpecPasteMenu = ! event . shiftKey && ! event . altKey && event . keyCode == Common . UI . Keys . CTRL ;
}
2022-04-27 19:24:39 +00:00
if ( ( event . ctrlKey || event . metaKey ) && ! event . shiftKey && ! event . altKey ) {
if ( key === Common . UI . Keys . NUM _PLUS || key === Common . UI . Keys . EQUALITY || ( Common . Utils . isGecko && key === Common . UI . Keys . EQUALITY _FF ) || ( Common . Utils . isOpera && key == 43 ) ) {
me . api . zoomIn ( ) ;
event . preventDefault ( ) ;
event . stopPropagation ( ) ;
return false ;
}
else if ( key === Common . UI . Keys . NUM _MINUS || key === Common . UI . Keys . MINUS || ( Common . Utils . isGecko && key === Common . UI . Keys . MINUS _FF ) || ( Common . Utils . isOpera && key == 45 ) ) {
me . api . zoomOut ( ) ;
event . preventDefault ( ) ;
event . stopPropagation ( ) ;
return false ;
} else if ( key === 48 || key === 96 ) { // 0
me . api . zoom ( 100 ) ;
event . preventDefault ( ) ;
event . stopPropagation ( ) ;
return false ;
}
}
2022-04-28 21:06:04 +00:00
if ( me . documentHolder . currentMenu && me . documentHolder . currentMenu . isVisible ( ) ) {
2022-04-27 19:24:39 +00:00
if ( key == Common . UI . Keys . UP ||
key == Common . UI . Keys . DOWN ) {
2022-04-28 21:06:04 +00:00
$ ( 'ul.dropdown-menu' , me . documentHolder . currentMenu . el ) . focus ( ) ;
2022-04-27 19:24:39 +00:00
}
}
if ( key == Common . UI . Keys . ESC ) {
Common . UI . Menu . Manager . hideAll ( ) ;
if ( ! Common . UI . HintManager . isHintVisible ( ) )
Common . NotificationCenter . trigger ( 'leftmenu:change' , 'hide' ) ;
}
}
} ,
onDocumentHolderResize : function ( e ) {
var me = this ;
me . _XY = [
me . documentHolder . cmpEl . offset ( ) . left - $ ( window ) . scrollLeft ( ) ,
me . documentHolder . cmpEl . offset ( ) . top - $ ( window ) . scrollTop ( )
] ;
me . _Height = me . documentHolder . cmpEl . height ( ) ;
me . _BodyWidth = $ ( 'body' ) . width ( ) ;
} ,
onAfterRender : function ( ct ) {
var me = this ;
var meEl = me . documentHolder . cmpEl ;
if ( meEl ) {
meEl . on ( 'contextmenu' , function ( e ) {
e . preventDefault ( ) ;
e . stopPropagation ( ) ;
return false ;
} ) ;
meEl . on ( 'click' , function ( e ) {
if ( e . target . localName == 'canvas' ) {
if ( me . _preventClick )
me . _preventClick = false ;
else
meEl . focus ( ) ;
}
} ) ;
meEl . on ( 'mousedown' , function ( e ) {
if ( e . target . localName == 'canvas' )
Common . UI . Menu . Manager . hideAll ( ) ;
} ) ;
//NOTE: set mouse wheel handler
var addEvent = function ( elem , type , fn ) {
elem . addEventListener ? elem . addEventListener ( type , fn , false ) : elem . attachEvent ( "on" + type , fn ) ;
} ;
var eventname = ( /Firefox/i . test ( navigator . userAgent ) ) ? 'DOMMouseScroll' : 'mousewheel' ;
addEvent ( me . documentHolder . el , eventname , _ . bind ( me . handleDocumentWheel , me ) ) ;
}
! Common . Utils . isChrome ? $ ( document ) . on ( 'mousewheel' , _ . bind ( me . handleDocumentWheel , me ) ) :
document . addEventListener ( 'mousewheel' , _ . bind ( me . handleDocumentWheel , me ) , { passive : false } ) ;
$ ( document ) . on ( 'keydown' , _ . bind ( me . handleDocumentKeyDown , me ) ) ;
$ ( window ) . on ( 'resize' , _ . bind ( me . onDocumentHolderResize , me ) ) ;
var viewport = me . getApplication ( ) . getController ( 'Viewport' ) . getView ( 'Viewport' ) ;
viewport . hlayout . on ( 'layout:resizedrag' , _ . bind ( me . onDocumentHolderResize , me ) ) ;
} ,
getUserName : function ( id ) {
var usersStore = DE . getCollection ( 'Common.Collections.Users' ) ;
if ( usersStore ) {
var rec = usersStore . findUser ( id ) ;
if ( rec )
return AscCommon . UserInfoParser . getParsedName ( rec . get ( 'username' ) ) ;
}
return this . documentHolder . guestText ;
} ,
isUserVisible : function ( id ) {
var usersStore = DE . getCollection ( 'Common.Collections.Users' ) ;
if ( usersStore ) {
var rec = usersStore . findUser ( id ) ;
if ( rec )
return ! rec . get ( 'hidden' ) ;
}
return true ;
} ,
userTipMousover : function ( evt , el , opt ) {
var me = this ;
if ( me . userTooltip === true ) {
me . userTooltip = new Common . UI . Tooltip ( {
owner : evt . currentTarget ,
title : me . documentHolder . tipIsLocked
} ) ;
me . userTooltip . show ( ) ;
}
} ,
userTipHide : function ( ) {
var me = this ;
if ( typeof me . userTooltip == 'object' ) {
me . userTooltip . hide ( ) ;
me . userTooltip = undefined ;
for ( var i = 0 ; i < me . usertips . length ; i ++ ) {
me . usertips [ i ] . off ( 'mouseover' , me . wrapEvents . userTipMousover ) ;
me . usertips [ i ] . off ( 'mouseout' , me . wrapEvents . userTipMousout ) ;
}
}
} ,
userTipMousout : function ( evt , el , opt ) {
var me = this ;
if ( typeof me . userTooltip == 'object' ) {
if ( me . userTooltip . $element && evt . currentTarget === me . userTooltip . $element [ 0 ] ) {
me . userTipHide ( ) ;
}
}
} ,
hideTips : function ( ) {
var me = this ;
/** coauthoring begin **/
if ( typeof me . userTooltip == 'object' ) {
me . userTooltip . hide ( ) ;
me . userTooltip = true ;
}
_ . each ( me . usertips , function ( item ) {
item . remove ( ) ;
} ) ;
me . usertips = [ ] ;
me . usertipcount = 0 ;
/** coauthoring end **/
} ,
onHyperlinkClick : function ( url ) {
if ( url ) {
2022-06-16 17:50:54 +00:00
var type = this . api . asc _getUrlType ( url ) ;
if ( type === AscCommon . c _oAscUrlType . Http || type === AscCommon . c _oAscUrlType . Email )
2022-04-27 19:24:39 +00:00
window . open ( url ) ;
else
Common . UI . warning ( {
2022-06-16 17:50:54 +00:00
msg : this . documentHolder . txtWarnUrl ,
2022-04-27 19:24:39 +00:00
buttons : [ 'yes' , 'no' ] ,
primary : 'yes' ,
callback : function ( btn ) {
( btn == 'yes' ) && window . open ( url ) ;
}
} ) ;
}
} ,
onDialogAddHyperlink : function ( ) {
var me = this ;
var win , props , text ;
if ( me . api && me . mode . isEdit && ! me . _isDisabled && ! me . getApplication ( ) . getController ( 'LeftMenu' ) . leftMenu . menuFile . isVisible ( ) ) {
var handlerDlg = function ( dlg , result ) {
if ( result == 'ok' ) {
props = dlg . getSettings ( ) ;
( text !== false )
? me . api . add _Hyperlink ( props )
: me . api . change _Hyperlink ( props ) ;
}
2022-05-04 19:59:02 +00:00
me . editComplete ( ) ;
2022-04-27 19:24:39 +00:00
} ;
text = me . api . can _AddHyperlink ( ) ;
if ( text !== false ) {
win = new DE . Views . HyperlinkSettingsDialog ( {
api : me . api ,
handler : handlerDlg
} ) ;
props = new Asc . CHyperlinkProperty ( ) ;
props . put _Text ( text ) ;
win . show ( ) ;
win . setSettings ( props ) ;
} else {
var selectedElements = me . api . getSelectedElements ( ) ;
if ( selectedElements && _ . isArray ( selectedElements ) ) {
_ . each ( selectedElements , function ( el , i ) {
if ( selectedElements [ i ] . get _ObjectType ( ) == Asc . c _oAscTypeSelectElement . Hyperlink )
props = selectedElements [ i ] . get _ObjectValue ( ) ;
} ) ;
}
if ( props ) {
win = new DE . Views . HyperlinkSettingsDialog ( {
api : me . api ,
handler : handlerDlg
} ) ;
win . show ( ) ;
win . setSettings ( props ) ;
}
}
Common . component . Analytics . trackEvent ( 'DocumentHolder' , 'Add Hyperlink' ) ;
}
} ,
onShowForeignCursorLabel : function ( UserId , X , Y , color ) {
if ( ! this . isUserVisible ( UserId ) ) return ;
/** coauthoring begin **/
var me = this ;
var src ;
for ( var i = 0 ; i < me . fastcoauthtips . length ; i ++ ) {
if ( me . fastcoauthtips [ i ] . attr ( 'userid' ) == UserId ) {
src = me . fastcoauthtips [ i ] ;
break ;
}
}
if ( ! src ) {
src = $ ( document . createElement ( "div" ) ) ;
src . addClass ( 'username-tip' ) ;
src . attr ( 'userid' , UserId ) ;
src . css ( { height : me . _TtHeight + 'px' , position : 'absolute' , zIndex : '900' , display : 'none' , 'pointer-events' : 'none' ,
'background-color' : '#' + Common . Utils . ThemeColor . getHexColor ( color . get _r ( ) , color . get _g ( ) , color . get _b ( ) ) } ) ;
src . text ( me . getUserName ( UserId ) ) ;
$ ( '#id_main_view' ) . append ( src ) ;
me . fastcoauthtips . push ( src ) ;
src . fadeIn ( 150 ) ;
}
src . css ( { top : ( Y - me . _TtHeight ) + 'px' , left : X + 'px' } ) ;
/** coauthoring end **/
} ,
onHideForeignCursorLabel : function ( UserId ) {
/** coauthoring begin **/
var me = this ;
for ( var i = 0 ; i < me . fastcoauthtips . length ; i ++ ) {
if ( me . fastcoauthtips [ i ] . attr ( 'userid' ) == UserId ) {
var src = me . fastcoauthtips [ i ] ;
me . fastcoauthtips [ i ] . fadeOut ( 150 , function ( ) { src . remove ( ) } ) ;
me . fastcoauthtips . splice ( i , 1 ) ;
break ;
}
}
/** coauthoring end **/
} ,
onMouseMoveStart : function ( ) {
var me = this ;
me . screenTip . isHidden = true ;
/** coauthoring begin **/
if ( me . usertips . length > 0 ) {
if ( typeof me . userTooltip == 'object' ) {
me . userTooltip . hide ( ) ;
me . userTooltip = true ;
}
_ . each ( me . usertips , function ( item ) {
item . remove ( ) ;
} ) ;
}
me . usertips = [ ] ;
me . usertipcount = 0 ;
/** coauthoring end **/
} ,
onMouseMoveEnd : function ( ) {
var me = this ;
if ( me . screenTip . isHidden && me . screenTip . isVisible ) {
me . screenTip . isVisible = false ;
me . isTooltipHiding = true ;
me . screenTip . toolTip . hide ( function ( ) {
me . isTooltipHiding = false ;
if ( me . mouseMoveData ) me . onMouseMove ( me . mouseMoveData ) ;
me . mouseMoveData = null ;
} ) ;
}
} ,
onMouseMove : function ( moveData ) {
var me = this ,
cmpEl = me . documentHolder . cmpEl ,
screenTip = me . screenTip ;
if ( me . _XY === undefined ) {
me . _XY = [
cmpEl . offset ( ) . left - $ ( window ) . scrollLeft ( ) ,
cmpEl . offset ( ) . top - $ ( window ) . scrollTop ( )
] ;
me . _Height = cmpEl . height ( ) ;
me . _BodyWidth = $ ( 'body' ) . width ( ) ;
}
if ( moveData ) {
var showPoint , ToolTip ,
type = moveData . get _Type ( ) ;
if ( type == Asc . c _oAscMouseMoveDataTypes . Hyperlink || type == Asc . c _oAscMouseMoveDataTypes . Footnote || type == Asc . c _oAscMouseMoveDataTypes . Form ||
type == Asc . c _oAscMouseMoveDataTypes . Review && me . mode . reviewHoverMode ) {
if ( me . isTooltipHiding ) {
me . mouseMoveData = moveData ;
return ;
}
if ( type == Asc . c _oAscMouseMoveDataTypes . Hyperlink ) {
var hyperProps = moveData . get _Hyperlink ( ) ;
if ( ! hyperProps ) return ;
ToolTip = ( _ . isEmpty ( hyperProps . get _ToolTip ( ) ) ) ? hyperProps . get _Value ( ) : hyperProps . get _ToolTip ( ) ;
if ( ToolTip . length > 256 )
ToolTip = ToolTip . substr ( 0 , 256 ) + '...' ;
} else if ( type == Asc . c _oAscMouseMoveDataTypes . Footnote ) {
ToolTip = moveData . get _FootnoteText ( ) ;
if ( ToolTip . length > 1000 )
ToolTip = ToolTip . substr ( 0 , 1000 ) + '...' ;
} else if ( type == Asc . c _oAscMouseMoveDataTypes . Form ) {
ToolTip = moveData . get _FormHelpText ( ) ;
if ( ToolTip . length > 1000 )
ToolTip = ToolTip . substr ( 0 , 1000 ) + '...' ;
} else if ( type == Asc . c _oAscMouseMoveDataTypes . Review && moveData . get _ReviewChange ( ) ) {
var changes = me . getApplication ( ) . getController ( "Common.Controllers.ReviewChanges" ) . readSDKChange ( [ moveData . get _ReviewChange ( ) ] ) ;
if ( changes && changes . length > 0 )
changes = changes [ 0 ] ;
if ( changes ) {
ToolTip = '<b>' + Common . Utils . String . htmlEncode ( AscCommon . UserInfoParser . getParsedName ( changes . get ( 'username' ) ) ) + ' </b>' ;
ToolTip += '<span style="font-size:10px; opacity: 0.7;">' + changes . get ( 'date' ) + '</span><br>' ;
ToolTip += changes . get ( 'changetext' ) ;
if ( ToolTip . length > 1000 )
ToolTip = ToolTip . substr ( 0 , 1000 ) + '...' ;
}
}
var recalc = false ;
screenTip . isHidden = false ;
if ( type !== Asc . c _oAscMouseMoveDataTypes . Review )
ToolTip = Common . Utils . String . htmlEncode ( ToolTip ) ;
if ( screenTip . tipType !== type || screenTip . tipLength !== ToolTip . length || screenTip . strTip . indexOf ( ToolTip ) < 0 ) {
2022-06-26 10:43:51 +00:00
screenTip . toolTip . setTitle ( ( type == Asc . c _oAscMouseMoveDataTypes . Hyperlink ) ? ( ToolTip + '<br><b>' + Common . Utils . String . platformKey ( 'Ctrl' , me . documentHolder . txtPressLink ) + '</b>' ) : ToolTip ) ;
2022-04-27 19:24:39 +00:00
screenTip . tipLength = ToolTip . length ;
screenTip . strTip = ToolTip ;
screenTip . tipType = type ;
recalc = true ;
}
showPoint = [ moveData . get _X ( ) , moveData . get _Y ( ) ] ;
showPoint [ 1 ] += ( me . _XY [ 1 ] - 15 ) ;
showPoint [ 0 ] += ( me . _XY [ 0 ] + 5 ) ;
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 ( ) ;
}
recalc = false ;
if ( showPoint [ 0 ] + screenTip . tipWidth > me . _BodyWidth ) {
showPoint [ 0 ] = me . _BodyWidth - screenTip . tipWidth ;
recalc = true ;
}
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' } ) ;
}
/** coauthoring begin **/
2022-05-05 18:28:29 +00:00
else if ( moveData . get _Type ( ) == Asc . c _oAscMouseMoveDataTypes . LockedObject && me . mode . isEdit && me . isUserVisible ( moveData . get _UserId ( ) ) ) { // 2 - locked object
2022-04-27 19:24:39 +00:00
var src ;
if ( me . usertipcount >= me . usertips . length ) {
src = $ ( document . createElement ( "div" ) ) ;
src . addClass ( 'username-tip' ) ;
src . css ( { height : me . _TtHeight + 'px' , position : 'absolute' , zIndex : '900' , visibility : 'visible' } ) ;
$ ( document . body ) . append ( src ) ;
if ( me . userTooltip ) {
src . on ( 'mouseover' , me . wrapEvents . userTipMousover ) ;
src . on ( 'mouseout' , me . wrapEvents . userTipMousout ) ;
}
me . usertips . push ( src ) ;
}
src = me . usertips [ me . usertipcount ] ;
me . usertipcount ++ ;
ToolTip = me . getUserName ( moveData . get _UserId ( ) ) ;
showPoint = [ moveData . get _X ( ) + me . _XY [ 0 ] , moveData . get _Y ( ) + me . _XY [ 1 ] ] ;
var maxwidth = showPoint [ 0 ] ;
showPoint [ 0 ] = me . _BodyWidth - showPoint [ 0 ] ;
showPoint [ 1 ] -= ( ( moveData . get _LockedObjectType ( ) == 2 ) ? me . _TtHeight : 0 ) ;
if ( showPoint [ 1 ] > me . _XY [ 1 ] && showPoint [ 1 ] + me . _TtHeight < me . _XY [ 1 ] + me . _Height ) {
src . text ( ToolTip ) ;
src . css ( { visibility : 'visible' , top : showPoint [ 1 ] + 'px' , right : showPoint [ 0 ] + 'px' , 'max-width' : maxwidth + 'px' } ) ;
} else {
src . css ( { visibility : 'hidden' } ) ;
}
}
/** coauthoring end **/
}
} ,
onShowSpecialPasteOptions : function ( specialPasteShowOptions ) {
var me = this ,
documentHolder = me . documentHolder ;
var coord = specialPasteShowOptions . asc _getCellCoord ( ) ,
pasteContainer = documentHolder . cmpEl . find ( '#special-paste-container' ) ,
pasteItems = specialPasteShowOptions . asc _getOptions ( ) ;
if ( ! pasteItems ) return ;
// Prepare menu container
if ( pasteContainer . length < 1 ) {
me . _arrSpecialPaste = [ ] ;
me . _arrSpecialPaste [ Asc . c _oSpecialPasteProps . paste ] = documentHolder . textPaste ;
me . _arrSpecialPaste [ Asc . c _oSpecialPasteProps . sourceformatting ] = documentHolder . txtPasteSourceFormat ;
me . _arrSpecialPaste [ Asc . c _oSpecialPasteProps . keepTextOnly ] = documentHolder . txtKeepTextOnly ;
me . _arrSpecialPaste [ Asc . c _oSpecialPasteProps . insertAsNestedTable ] = documentHolder . textNest ;
me . _arrSpecialPaste [ Asc . c _oSpecialPasteProps . overwriteCells ] = documentHolder . txtOverwriteCells ;
pasteContainer = $ ( '<div id="special-paste-container" style="position: absolute;"><div id="id-document-holder-btn-special-paste"></div></div>' ) ;
documentHolder . cmpEl . find ( '#id_main_view' ) . append ( pasteContainer ) ;
me . btnSpecialPaste = new Common . UI . Button ( {
parentEl : $ ( '#id-document-holder-btn-special-paste' ) ,
cls : 'btn-toolbar' ,
iconCls : 'toolbar__icon btn-paste' ,
2022-06-01 19:49:52 +00:00
caption : Common . Utils . String . platformKey ( 'Ctrl' , '({0})' ) ,
2022-04-27 19:24:39 +00:00
menu : new Common . UI . Menu ( { items : [ ] } )
} ) ;
2022-06-01 19:49:52 +00:00
me . initSpecialPasteEvents ( ) ;
2022-04-27 19:24:39 +00:00
}
if ( pasteItems . length > 0 ) {
var menu = me . btnSpecialPaste . menu ;
for ( var i = 0 ; i < menu . items . length ; i ++ ) {
menu . removeItem ( menu . items [ i ] ) ;
i -- ;
}
var group _prev = - 1 ;
_ . each ( pasteItems , function ( menuItem , index ) {
var mnu = new Common . UI . MenuItem ( {
2022-06-01 19:49:52 +00:00
caption : me . _arrSpecialPaste [ menuItem ] + ' (' + me . hkSpecPaste [ menuItem ] + ')' ,
2022-04-27 19:24:39 +00:00
value : menuItem ,
checkable : true ,
toggleGroup : 'specialPasteGroup'
2022-06-01 19:49:52 +00:00
} ) . on ( 'click' , _ . bind ( me . onSpecialPasteItemClick , me ) ) ;
2022-04-27 19:24:39 +00:00
menu . addItem ( mnu ) ;
} ) ;
( menu . items . length > 0 ) && menu . items [ 0 ] . setChecked ( true , true ) ;
}
if ( coord . asc _getX ( ) < 0 || coord . asc _getY ( ) < 0 ) {
if ( pasteContainer . is ( ':visible' ) ) pasteContainer . hide ( ) ;
2022-06-01 19:49:52 +00:00
$ ( document ) . off ( 'keyup' , this . wrapEvents . onKeyUp ) ;
2022-04-27 19:24:39 +00:00
} else {
var showPoint = [ coord . asc _getX ( ) + coord . asc _getWidth ( ) + 3 , coord . asc _getY ( ) + coord . asc _getHeight ( ) + 3 ] ;
if ( ! Common . Utils . InternalSettings . get ( "de-hidden-rulers" ) ) {
showPoint = [ showPoint [ 0 ] - 19 , showPoint [ 1 ] - 26 ] ;
}
pasteContainer . css ( { left : showPoint [ 0 ] , top : showPoint [ 1 ] } ) ;
pasteContainer . show ( ) ;
2022-06-01 19:49:52 +00:00
setTimeout ( function ( ) {
$ ( document ) . on ( 'keyup' , me . wrapEvents . onKeyUp ) ;
} , 10 ) ;
2022-04-27 19:24:39 +00:00
}
} ,
onHideSpecialPasteOptions : function ( ) {
var pasteContainer = this . documentHolder . cmpEl . find ( '#special-paste-container' ) ;
2022-06-01 19:49:52 +00:00
if ( pasteContainer . is ( ':visible' ) ) {
2022-04-27 19:24:39 +00:00
pasteContainer . hide ( ) ;
2022-06-01 19:49:52 +00:00
$ ( document ) . off ( 'keyup' , this . wrapEvents . onKeyUp ) ;
}
} ,
onKeyUp : function ( e ) {
if ( e . keyCode == Common . UI . Keys . CTRL && this . _needShowSpecPasteMenu && ! this . btnSpecialPaste . menu . isVisible ( ) && /area_id/ . test ( e . target . id ) ) {
$ ( 'button' , this . btnSpecialPaste . cmpEl ) . click ( ) ;
e . preventDefault ( ) ;
}
this . _needShowSpecPasteMenu = false ;
} ,
initSpecialPasteEvents : function ( ) {
var me = this ;
me . hkSpecPaste = [ ] ;
me . hkSpecPaste [ Asc . c _oSpecialPasteProps . paste ] = 'P' ;
me . hkSpecPaste [ Asc . c _oSpecialPasteProps . sourceformatting ] = 'K' ;
me . hkSpecPaste [ Asc . c _oSpecialPasteProps . keepTextOnly ] = 'T' ;
me . hkSpecPaste [ Asc . c _oSpecialPasteProps . insertAsNestedTable ] = 'N' ;
me . hkSpecPaste [ Asc . c _oSpecialPasteProps . overwriteCells ] = 'O' ;
for ( var key in me . hkSpecPaste ) {
if ( me . hkSpecPaste . hasOwnProperty ( key ) ) {
var keymap = { } ;
keymap [ me . hkSpecPaste [ key ] ] = _ . bind ( me . onSpecialPasteItemClick , me , { value : parseInt ( key ) } ) ;
Common . util . Shortcuts . delegateShortcuts ( { shortcuts : keymap } ) ;
Common . util . Shortcuts . suspendEvents ( me . hkSpecPaste [ key ] , undefined , true ) ;
}
}
me . btnSpecialPaste . menu . on ( 'show:after' , function ( menu ) {
for ( var i = 0 ; i < menu . items . length ; i ++ ) {
me . hkSpecPaste [ menu . items [ i ] . value ] && Common . util . Shortcuts . resumeEvents ( me . hkSpecPaste [ menu . items [ i ] . value ] ) ;
}
} ) . on ( 'hide:after' , function ( menu ) {
for ( var i = 0 ; i < menu . items . length ; i ++ ) {
me . hkSpecPaste [ menu . items [ i ] . value ] && Common . util . Shortcuts . suspendEvents ( me . hkSpecPaste [ menu . items [ i ] . value ] , undefined , true ) ;
}
} ) ;
2022-04-27 19:24:39 +00:00
} ,
onDoubleClickOnChart : function ( chart ) {
if ( this . mode . isEdit && ! this . _isDisabled ) {
var diagramEditor = this . getApplication ( ) . getController ( 'Common.Controllers.ExternalDiagramEditor' ) . getView ( 'Common.Views.ExternalDiagramEditor' ) ;
if ( diagramEditor && chart ) {
diagramEditor . setEditMode ( true ) ;
diagramEditor . show ( ) ;
diagramEditor . setChartData ( new Asc . asc _CChartBinary ( chart ) ) ;
}
}
} ,
onDoubleClickOnTableOleObject : function ( chart ) {
if ( this . mode . isEdit && ! this . _isDisabled ) {
var oleEditor = this . getApplication ( ) . getController ( 'Common.Controllers.ExternalOleEditor' ) . getView ( 'Common.Views.ExternalOleEditor' ) ;
if ( oleEditor && chart ) {
oleEditor . setEditMode ( true ) ;
oleEditor . show ( ) ;
oleEditor . setOleData ( Asc . asc _putBinaryDataToFrameFromTableOleObject ( chart ) ) ;
}
}
} ,
onImgWrapStyleChanged : function ( type ) {
var menuImageWrap = this . documentHolder . menuImageWrap ;
switch ( type ) {
case Asc . c _oAscWrapStyle2 . Inline :
menuImageWrap . menu . items [ 0 ] . setChecked ( true ) ;
break ;
case Asc . c _oAscWrapStyle2 . Square :
menuImageWrap . menu . items [ 2 ] . setChecked ( true ) ;
break ;
case Asc . c _oAscWrapStyle2 . Tight :
menuImageWrap . menu . items [ 3 ] . setChecked ( true ) ;
break ;
case Asc . c _oAscWrapStyle2 . Through :
menuImageWrap . menu . items [ 4 ] . setChecked ( true ) ;
break ;
case Asc . c _oAscWrapStyle2 . TopAndBottom :
menuImageWrap . menu . items [ 5 ] . setChecked ( true ) ;
break ;
case Asc . c _oAscWrapStyle2 . Behind :
menuImageWrap . menu . items [ 8 ] . setChecked ( true ) ;
break ;
case Asc . c _oAscWrapStyle2 . InFront :
menuImageWrap . menu . items [ 7 ] . setChecked ( true ) ;
break ;
}
} ,
onChangeCropState : function ( state ) {
this . documentHolder . menuImgCrop . menu . items [ 0 ] . setChecked ( state , true ) ;
} ,
onRulerDblClick : function ( type ) {
Common . UI . Menu . Manager . hideAll ( ) ;
var win , me = this ;
if ( type == 'tables' ) {
win = this . advancedTableClick ( ) ;
if ( win )
win . setActiveCategory ( 4 ) ;
} else if ( type == 'indents' || type == 'tabs' ) {
win = this . advancedParagraphClick ( { isChart : false } ) ;
if ( win )
win . setActiveCategory ( type == 'indents' ? 0 : 4 ) ;
} else if ( type == 'margins' ) {
if ( me . _state . lock _doc ) return ;
win = new DE . Views . PageMarginsDialog ( {
api : me . api ,
handler : function ( dlg , result ) {
if ( result == 'ok' ) {
var props = dlg . getSettings ( ) ;
var mnu = DE . getController ( 'Toolbar' ) . toolbar . btnPageMargins . menu . items [ 0 ] ;
mnu . setVisible ( true ) ;
mnu . setChecked ( true ) ;
mnu . options . value = mnu . value = [ props . get _TopMargin ( ) , props . get _LeftMargin ( ) , props . get _BottomMargin ( ) , props . get _RightMargin ( ) ] ;
$ ( mnu . el ) . html ( mnu . template ( { id : Common . UI . getId ( ) , caption : mnu . caption , options : mnu . options } ) ) ;
Common . localStorage . setItem ( "de-pgmargins-top" , props . get _TopMargin ( ) ) ;
Common . localStorage . setItem ( "de-pgmargins-left" , props . get _LeftMargin ( ) ) ;
Common . localStorage . setItem ( "de-pgmargins-bottom" , props . get _BottomMargin ( ) ) ;
Common . localStorage . setItem ( "de-pgmargins-right" , props . get _RightMargin ( ) ) ;
me . api . asc _SetSectionProps ( props ) ;
2022-05-04 19:59:02 +00:00
me . editComplete ( ) ;
2022-04-27 19:24:39 +00:00
}
}
} ) ;
win . show ( ) ;
win . setSettings ( me . api . asc _GetSectionProps ( ) ) ;
} else if ( type == 'columns' ) {
win = new DE . Views . CustomColumnsDialog ( {
handler : function ( dlg , result ) {
if ( result == 'ok' ) {
me . api . asc _SetColumnsProps ( dlg . getSettings ( ) ) ;
2022-05-04 19:59:02 +00:00
me . editComplete ( ) ;
2022-04-27 19:24:39 +00:00
}
}
} ) ;
win . show ( ) ;
win . setSettings ( me . api . asc _GetColumnsProps ( ) ) ;
}
} ,
onApiParagraphStyleChange : function ( name ) {
window . currentStyleName = name ;
} ,
onHideContentControlsActions : function ( ) {
this . listControlMenu && this . listControlMenu . isVisible ( ) && this . listControlMenu . hide ( ) ;
var controlsContainer = this . documentHolder . cmpEl . find ( '#calendar-control-container' ) ;
if ( controlsContainer . is ( ':visible' ) )
controlsContainer . hide ( ) ;
} ,
onShowDateActions : function ( obj , x , y ) {
var props = obj . pr ,
specProps = props . get _DateTimePr ( ) ,
cmpEl = this . documentHolder . cmpEl ,
controlsContainer = cmpEl . 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>' ) ;
cmpEl . 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 : cmpEl . 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 ( ) ;
2022-05-04 19:59:02 +00:00
me . editComplete ( ) ;
2022-04-27 19:24:39 +00:00
} ) ;
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 ;
} ,
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 ( ) ,
cmpEl = this . documentHolder . cmpEl ,
menu = this . listControlMenu ,
menuContainer = menu ? cmpEl . find ( Common . Utils . String . format ( '#menu-container-{0}' , menu . id ) ) : null ,
me = this ;
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 : [ ]
} ) ;
menu . on ( 'item:click' , function ( menu , item ) {
setTimeout ( function ( ) {
( item . value !== - 1 ) && me . api . asc _SelectContentControlListItem ( item . value , me . _listObj . get _InternalId ( ) ) ;
} , 1 ) ;
} ) ;
// 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 ) ) ;
cmpEl . 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 ( ) ;
} ) ;
}
if ( specProps ) {
if ( isForm ) { // for dropdown and combobox form control always add placeholder item
var text = props . get _PlaceholderText ( ) ;
menu . addItem ( new Common . UI . MenuItem ( {
caption : ( text . trim ( ) !== '' ) ? text : this . documentHolder . txtEmpty ,
value : '' ,
template : _ . template ( [
'<a id="<%= id %>" tabindex="-1" type="menuitem" style="<% if (options.value=="") { %> opacity: 0.6 <% } %>">' ,
'<%= caption %>' ,
'</a>'
] . join ( '' ) )
} ) ) ;
}
var count = specProps . get _ItemsCount ( ) ;
for ( var i = 0 ; i < count ; i ++ ) {
( 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 ( '' ) )
} ) ) ;
}
if ( ! isForm && menu . items . length < 1 ) {
menu . addItem ( new Common . UI . MenuItem ( {
caption : this . documentHolder . txtEmpty ,
value : - 1
} ) ) ;
}
}
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 ;
} ,
onShowContentControlsActions : function ( obj , x , y ) {
var type = obj . type ;
switch ( type ) {
case Asc . c _oAscContentControlSpecificType . DateTime :
this . onShowDateActions ( obj , x , y ) ;
break ;
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 ;
}
this . api . asc _addImage ( obj ) ;
var me = this ;
setTimeout ( function ( ) {
me . api . asc _UncheckContentControlButtons ( ) ;
} , 500 ) ;
break ;
case Asc . c _oAscContentControlSpecificType . DropDownList :
case Asc . c _oAscContentControlSpecificType . ComboBox :
this . onShowListActions ( obj , x , y ) ;
break ;
}
} ,
onApiLockDocumentProps : function ( ) {
this . _state . lock _doc = true ;
} ,
onApiUnLockDocumentProps : function ( ) {
this . _state . lock _doc = false ;
} ,
onCoAuthoringDisconnect : function ( ) {
this . mode . isEdit = false ;
} ,
SetDisabled : function ( state , canProtect , fillFormMode ) {
this . _isDisabled = state ;
this . documentHolder . SetDisabled ( state , canProtect , fillFormMode ) ;
} ,
onTextLanguage : function ( langid ) {
this . documentHolder . _currLang . id = langid ;
} ,
onSpellCheckVariantsFound : function ( ) {
var me = this ;
var selectedElements = me . api . getSelectedElements ( true ) ;
var props ;
if ( selectedElements && _ . isArray ( selectedElements ) ) {
for ( var i = 0 ; i < selectedElements . length ; i ++ ) {
if ( selectedElements [ i ] . get _ObjectType ( ) == Asc . c _oAscTypeSelectElement . SpellCheck ) {
props = selectedElements [ i ] . get _ObjectValue ( ) ;
me . documentHolder . _currentSpellObj = props ;
break ;
}
}
}
if ( props && props . get _Checked ( ) === false && props . get _Variants ( ) !== null && props . get _Variants ( ) !== undefined ) {
me . documentHolder . addWordVariants ( ) ;
if ( me . documentHolder . textMenu && me . documentHolder . textMenu . isVisible ( ) ) {
me . documentHolder . textMenu . alignPosition ( ) ;
}
}
} ,
equationCallback : function ( eqProps ) {
if ( eqProps ) {
var eqObj ;
switch ( eqProps . type ) {
case Asc . c _oAscMathInterfaceType . Accent :
eqObj = new CMathMenuAccent ( ) ;
break ;
case Asc . c _oAscMathInterfaceType . BorderBox :
eqObj = new CMathMenuBorderBox ( ) ;
break ;
case Asc . c _oAscMathInterfaceType . Box :
eqObj = new CMathMenuBox ( ) ;
break ;
case Asc . c _oAscMathInterfaceType . Bar :
eqObj = new CMathMenuBar ( ) ;
break ;
case Asc . c _oAscMathInterfaceType . Script :
eqObj = new CMathMenuScript ( ) ;
break ;
case Asc . c _oAscMathInterfaceType . Fraction :
eqObj = new CMathMenuFraction ( ) ;
break ;
case Asc . c _oAscMathInterfaceType . Limit :
eqObj = new CMathMenuLimit ( ) ;
break ;
case Asc . c _oAscMathInterfaceType . Matrix :
eqObj = new CMathMenuMatrix ( ) ;
break ;
case Asc . c _oAscMathInterfaceType . EqArray :
eqObj = new CMathMenuEqArray ( ) ;
break ;
case Asc . c _oAscMathInterfaceType . LargeOperator :
eqObj = new CMathMenuNary ( ) ;
break ;
case Asc . c _oAscMathInterfaceType . Delimiter :
eqObj = new CMathMenuDelimiter ( ) ;
break ;
case Asc . c _oAscMathInterfaceType . GroupChar :
eqObj = new CMathMenuGroupCharacter ( ) ;
break ;
case Asc . c _oAscMathInterfaceType . Radical :
eqObj = new CMathMenuRadical ( ) ;
break ;
case Asc . c _oAscMathInterfaceType . Common :
eqObj = new CMathMenuBase ( ) ;
break ;
}
if ( eqObj ) {
eqObj [ eqProps . callback ] ( eqProps . value ) ;
this . api . asc _SetMathProps ( eqObj ) ;
}
}
2022-05-04 19:59:02 +00:00
this . editComplete ( ) ;
2022-04-27 19:24:39 +00:00
} ,
changePosition : function ( ) {
var me = this ,
cmpEl = me . documentHolder . cmpEl ;
me . _XY = [
cmpEl . offset ( ) . left - $ ( window ) . scrollLeft ( ) ,
cmpEl . offset ( ) . top - $ ( window ) . scrollTop ( )
] ;
me . _Height = cmpEl . height ( ) ;
me . _BodyWidth = $ ( 'body' ) . width ( ) ;
me . onMouseMoveStart ( ) ;
} ,
addHyperlink : function ( item , e , eOpt ) {
var win , me = this ;
if ( me . api ) {
win = new DE . Views . HyperlinkSettingsDialog ( {
api : me . api ,
handler : function ( dlg , result ) {
if ( result == 'ok' ) {
me . api . add _Hyperlink ( dlg . getSettings ( ) ) ;
}
2022-05-04 19:59:02 +00:00
me . editComplete ( ) ;
2022-04-27 19:24:39 +00:00
}
} ) ;
win . show ( ) ;
win . setSettings ( item . hyperProps . value ) ;
Common . component . Analytics . trackEvent ( 'DocumentHolder' , 'Add Hyperlink' ) ;
}
} ,
editHyperlink : function ( item , e , eOpt ) {
var win , me = this ;
if ( me . api ) {
win = new DE . Views . HyperlinkSettingsDialog ( {
api : me . api ,
handler : function ( dlg , result ) {
if ( result == 'ok' ) {
me . api . change _Hyperlink ( win . getSettings ( ) ) ;
}
2022-05-04 19:59:02 +00:00
me . editComplete ( ) ;
2022-04-27 19:24:39 +00:00
}
} ) ;
win . show ( ) ;
win . setSettings ( item . hyperProps . value ) ;
}
} ,
2022-05-04 19:18:04 +00:00
onRemoveHyperlink : function ( item , e ) {
this . api && this . api . remove _Hyperlink ( item . hyperProps . value ) ;
2022-05-04 19:59:02 +00:00
this . editComplete ( ) ;
2022-05-04 19:18:04 +00:00
} ,
2022-04-27 19:24:39 +00:00
editChartClick : function ( ) {
var diagramEditor = DE . getController ( 'Common.Controllers.ExternalDiagramEditor' ) . getView ( 'Common.Views.ExternalDiagramEditor' ) ;
if ( diagramEditor ) {
diagramEditor . setEditMode ( true ) ;
diagramEditor . show ( ) ;
var chart = this . api . asc _getChartObject ( ) ;
if ( chart ) {
diagramEditor . setChartData ( new Asc . asc _CChartBinary ( chart ) ) ;
}
}
} ,
advancedParagraphClick : function ( item , e , eOpt ) {
var win , me = this ;
if ( me . api ) {
var selectedElements = me . api . getSelectedElements ( ) ;
if ( selectedElements && _ . isArray ( selectedElements ) ) {
for ( var i = selectedElements . length - 1 ; i >= 0 ; i -- ) {
var elType , elValue ;
elType = selectedElements [ i ] . get _ObjectType ( ) ;
elValue = selectedElements [ i ] . get _ObjectValue ( ) ;
if ( Asc . c _oAscTypeSelectElement . Paragraph == elType ) {
win = new DE . Views . ParagraphSettingsAdvanced ( {
tableStylerRows : 2 ,
tableStylerColumns : 1 ,
paragraphProps : elValue ,
borderProps : me . borderAdvancedProps ,
isChart : ( item . isChart === true ) ,
isSmartArtInternal : ( item . isSmartArtInternal === true ) ,
api : me . api ,
handler : function ( result , value ) {
if ( result == 'ok' ) {
if ( me . api ) {
me . borderAdvancedProps = value . borderProps ;
me . api . paraApply ( value . paragraphProps ) ;
}
}
2022-05-04 19:59:02 +00:00
me . editComplete ( ) ;
2022-04-27 19:24:39 +00:00
}
} ) ;
break ;
}
}
}
}
if ( win ) {
win . show ( ) ;
return win ;
}
} ,
advancedFrameClick : function ( isFrame , item , e , eOpt ) {
Common . NotificationCenter . trigger ( 'dropcap:settings' , isFrame ) ;
} ,
advancedTableClick : function ( item , e , eOpt ) {
var win , me = this ;
if ( me . api ) {
var selectedElements = me . api . getSelectedElements ( ) ;
if ( selectedElements && _ . isArray ( selectedElements ) ) {
for ( var i = selectedElements . length - 1 ; i >= 0 ; i -- ) {
var elType , elValue ;
elType = selectedElements [ i ] . get _ObjectType ( ) ;
elValue = selectedElements [ i ] . get _ObjectValue ( ) ;
if ( Asc . c _oAscTypeSelectElement . Table == elType ) {
win = new DE . Views . TableSettingsAdvanced ( {
tableStylerRows : ( elValue . get _CellBorders ( ) . get _InsideH ( ) === null && elValue . get _CellSelect ( ) == true ) ? 1 : 2 ,
tableStylerColumns : ( elValue . get _CellBorders ( ) . get _InsideV ( ) === null && elValue . get _CellSelect ( ) == true ) ? 1 : 2 ,
tableProps : elValue ,
borderProps : me . borderAdvancedProps ,
sectionProps : me . api . asc _GetSectionProps ( ) ,
handler : function ( result , value ) {
if ( result == 'ok' ) {
if ( me . api ) {
me . borderAdvancedProps = value . borderProps ;
me . api . tblApply ( value . tableProps ) ;
}
}
2022-05-04 19:59:02 +00:00
me . editComplete ( ) ;
2022-04-27 19:24:39 +00:00
}
} ) ;
break ;
}
}
}
}
if ( win ) {
win . show ( ) ;
return win ;
}
} ,
onMenuSaveStyle : function ( item , e , eOpt ) {
var me = this ;
if ( me . api ) {
Common . NotificationCenter . trigger ( 'style:commitsave' , me . api . asc _GetStyleFromFormatting ( ) ) ;
}
} ,
onMenuUpdateStyle : function ( item , e , eOpt ) {
var me = this ;
if ( me . api ) {
Common . NotificationCenter . trigger ( 'style:commitchange' , me . api . asc _GetStyleFromFormatting ( ) ) ;
}
} ,
addComment : function ( item , e , eOpt ) {
if ( this . api && this . mode . canCoAuthoring && this . mode . canComments ) {
this . documentHolder . suppressEditComplete = true ;
var controller = DE . getController ( 'Common.Controllers.Comments' ) ;
if ( controller ) {
controller . addDummyComment ( ) ;
}
}
} ,
onCutCopyPaste : function ( item , e ) {
var me = this ;
if ( me . api ) {
var res = ( item . value == 'cut' ) ? me . api . Cut ( ) : ( ( item . value == 'copy' ) ? me . api . Copy ( ) : me . api . Paste ( ) ) ;
if ( ! res ) {
if ( ! Common . localStorage . getBool ( "de-hide-copywarning" ) ) {
( new Common . Views . CopyWarningDialog ( {
handler : function ( dontshow ) {
if ( dontshow ) Common . localStorage . setItem ( "de-hide-copywarning" , 1 ) ;
2022-05-04 19:59:02 +00:00
me . editComplete ( ) ;
2022-04-27 19:24:39 +00:00
}
} ) ) . show ( ) ;
}
}
}
2022-05-04 19:59:02 +00:00
me . editComplete ( ) ;
2022-04-27 19:24:39 +00:00
} ,
2022-05-04 19:18:04 +00:00
onUndo : function ( ) {
this . api . Undo ( ) ;
} ,
2022-04-27 19:24:39 +00:00
onAcceptRejectChange : function ( item , e ) {
if ( this . api ) {
if ( item . value == 'accept' )
this . api . asc _AcceptChanges ( ) ;
else if ( item . value == 'reject' )
this . api . asc _RejectChanges ( ) ;
}
2022-05-04 19:59:02 +00:00
this . editComplete ( ) ;
2022-04-27 19:24:39 +00:00
} ,
onPrintSelection : function ( item ) {
if ( this . api ) {
var printopt = new Asc . asc _CAdjustPrint ( ) ;
printopt . asc _setPrintType ( Asc . c _oAscPrintType . Selection ) ;
var opts = 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
opts . asc _setAdvancedOptions ( printopt ) ;
this . api . asc _Print ( opts ) ;
2022-05-04 19:59:02 +00:00
this . editComplete ( ) ;
2022-04-27 19:24:39 +00:00
Common . component . Analytics . trackEvent ( 'DocumentHolder' , 'Print Selection' ) ;
}
} ,
onControlsSelect : function ( item , e ) {
var me = this ;
var props = this . api . asc _GetContentControlProperties ( ) ;
if ( props ) {
if ( item . value == 'settings' ) {
( new DE . Views . ControlSettingsDialog ( {
props : props ,
api : me . api ,
handler : function ( result , value ) {
if ( result == 'ok' ) {
me . api . asc _SetContentControlProperties ( value , props . get _InternalId ( ) ) ;
}
2022-05-04 19:59:02 +00:00
me . editComplete ( ) ;
2022-04-27 19:24:39 +00:00
}
} ) ) . show ( ) ;
} else if ( item . value == 'remove' ) {
props . get _FormPr ( ) ? this . api . asc _RemoveContentControl ( props . get _InternalId ( ) ) : this . api . asc _RemoveContentControlWrapper ( props . get _InternalId ( ) ) ;
}
}
2022-05-04 19:59:02 +00:00
me . editComplete ( ) ;
2022-04-27 19:24:39 +00:00
} ,
onInsertCaption : function ( ) {
this . documentHolder . fireEvent ( 'links:caption' ) ;
} ,
onContinueNumbering : function ( item , e ) {
this . api . asc _ContinueNumbering ( ) ;
2022-05-04 19:59:02 +00:00
this . editComplete ( ) ;
2022-04-27 19:24:39 +00:00
} ,
onStartNumbering : function ( startfrom , item , e ) {
if ( startfrom == 1 )
this . api . asc _RestartNumbering ( item . value . start ) ;
else {
var me = this ;
( new DE . Views . NumberingValueDialog ( {
2022-04-29 12:55:24 +00:00
title : me . documentHolder . textNumberingValue ,
2022-04-27 19:24:39 +00:00
props : item . value ,
handler : function ( result , value ) {
if ( result == 'ok' )
me . api . asc _RestartNumbering ( value ) ;
2022-05-04 19:59:02 +00:00
me . editComplete ( ) ;
2022-04-27 19:24:39 +00:00
}
} ) ) . show ( ) ;
}
2022-05-04 19:59:02 +00:00
this . editComplete ( ) ;
2022-04-27 19:24:39 +00:00
} ,
onCellsRemove : function ( ) {
var me = this ;
( new Common . Views . OptionsDialog ( {
title : me . documentHolder . textTitleCellsRemove ,
items : [
{ caption : this . documentHolder . textLeft , value : 'left' } ,
{ caption : this . documentHolder . textRow , value : 'row' } ,
{ caption : this . documentHolder . textCol , value : 'col' }
] ,
handler : function ( dlg , result ) {
if ( result == 'ok' ) {
var value = dlg . getSettings ( ) ;
if ( value == 'row' )
me . api . remRow ( ) ;
else if ( value == 'col' )
me . api . remColumn ( ) ;
else
me . api . asc _RemoveTableCells ( ) ;
}
2022-05-04 19:59:02 +00:00
me . editComplete ( ) ;
2022-04-27 19:24:39 +00:00
}
} ) ) . show ( ) ;
2022-05-04 19:59:02 +00:00
this . editComplete ( ) ;
2022-04-27 19:24:39 +00:00
} ,
onCellsAdd : function ( ) {
var me = this ;
( new DE . Views . CellsAddDialog ( {
handler : function ( result , settings ) {
if ( result == 'ok' ) {
if ( settings . row ) {
settings . before ? me . api . addRowAbove ( settings . count ) : me . api . addRowBelow ( settings . count ) ;
} else {
settings . before ? me . api . addColumnLeft ( settings . count ) : me . api . addColumnRight ( settings . count ) ;
}
}
2022-05-04 19:59:02 +00:00
me . editComplete ( ) ;
2022-04-27 19:24:39 +00:00
}
} ) ) . show ( ) ;
2022-05-04 19:59:02 +00:00
this . editComplete ( ) ;
2022-04-27 19:24:39 +00:00
} ,
onSignatureClick : function ( item ) {
var datavalue = item . cmpEl . attr ( 'data-value' ) ;
switch ( item . value ) {
case 0 :
Common . NotificationCenter . trigger ( 'protect:sign' , datavalue ) ; //guid
break ;
case 1 :
this . api . asc _ViewCertificate ( datavalue ) ; //certificate id
break ;
case 2 :
Common . NotificationCenter . trigger ( 'protect:signature' , 'visible' , this . _isDisabled , datavalue ) ; //guid, can edit settings for requested signature
break ;
case 3 :
var me = this ;
Common . UI . warning ( {
title : this . documentHolder . notcriticalErrorTitle ,
msg : this . documentHolder . txtRemoveWarning ,
buttons : [ 'ok' , 'cancel' ] ,
primary : 'ok' ,
callback : function ( btn ) {
if ( btn == 'ok' ) {
me . api . asc _RemoveSignature ( datavalue ) ;
}
}
} ) ;
break ;
}
} ,
onImgRotate : function ( item ) {
var properties = new Asc . asc _CImgProperty ( ) ;
properties . asc _putRotAdd ( ( item . value == 1 ? 90 : 270 ) * 3.14159265358979 / 180 ) ;
this . api . ImgApply ( properties ) ;
2022-05-04 19:59:02 +00:00
this . editComplete ( ) ;
2022-04-27 19:24:39 +00:00
} ,
onImgFlip : function ( item ) {
var properties = new Asc . asc _CImgProperty ( ) ;
if ( item . value == 1 )
properties . asc _putFlipHInvert ( true ) ;
else
properties . asc _putFlipVInvert ( true ) ;
this . api . ImgApply ( properties ) ;
2022-05-04 19:59:02 +00:00
this . editComplete ( ) ;
2022-04-27 19:24:39 +00:00
} ,
onImgCrop : function ( menu , item ) {
if ( item . value == 1 ) {
this . api . asc _cropFill ( ) ;
} else if ( item . value == 2 ) {
this . api . asc _cropFit ( ) ;
} else {
item . checked ? this . api . asc _startEditCrop ( ) : this . api . asc _endEditCrop ( ) ;
}
2022-05-04 19:59:02 +00:00
this . editComplete ( ) ;
2022-04-27 19:24:39 +00:00
} ,
onFollowMove : function ( item ) {
if ( this . api ) {
this . api . asc _FollowRevisionMove ( item . value ) ;
}
2022-05-04 19:59:02 +00:00
this . editComplete ( ) ;
2022-04-27 19:24:39 +00:00
} ,
tableCellsVAlign : function ( menu , item , e ) {
if ( this . api ) {
var properties = new Asc . CTableProp ( ) ;
properties . put _CellsVAlign ( item . options . valign ) ;
this . api . tblApply ( properties ) ;
}
} ,
2022-04-29 12:55:24 +00:00
tableSelectText : function ( menu , item , e ) {
if ( this . api ) {
switch ( item . value ) {
case 0 :
this . api . selectRow ( ) ;
break ;
case 1 :
this . api . selectColumn ( ) ;
break ;
case 2 :
this . api . selectCell ( ) ;
break ;
case 3 :
this . api . selectTable ( ) ;
break ;
}
}
} ,
tableInsertText : function ( menu , item , e ) {
if ( this . api ) {
switch ( item . value ) {
case 0 :
this . api . addColumnLeft ( ) ;
break ;
case 1 :
this . api . addColumnRight ( ) ;
break ;
case 2 :
this . api . addRowAbove ( ) ;
break ;
case 3 :
this . api . addRowBelow ( ) ;
break ;
case 4 :
this . onCellsAdd ( ) ;
break ;
}
}
} ,
tableDeleteText : function ( menu , item , e ) {
if ( this . api ) {
switch ( item . value ) {
case 0 :
this . api . remRow ( ) ;
break ;
case 1 :
this . api . remColumn ( ) ;
break ;
case 2 :
this . api . remTable ( ) ;
break ;
case 3 :
this . onCellsRemove ( ) ;
break ;
}
}
} ,
2022-05-04 13:51:53 +00:00
onImgAlign : function ( menu , item , e ) {
var me = this ;
if ( me . api ) {
var alignto = Common . Utils . InternalSettings . get ( "de-img-align-to" ) ,
value = ( alignto == 1 ) ? Asc . c _oAscObjectsAlignType . Page : ( ( me . api . asc _getSelectedDrawingObjectsCount ( ) < 2 && ! alignto || alignto == 2 ) ? Asc . c _oAscObjectsAlignType . Margin : Asc . c _oAscObjectsAlignType . Selected ) ;
if ( item . value < 6 ) {
me . api . put _ShapesAlign ( item . value , value ) ;
Common . component . Analytics . trackEvent ( 'DocumentHolder' , 'Shape Align' ) ;
} else if ( item . value == 6 ) {
me . api . DistributeHorizontally ( value ) ;
Common . component . Analytics . trackEvent ( 'DocumentHolder' , 'Distribute Horizontally' ) ;
} else if ( item . value == 7 ) {
me . api . DistributeVertically ( value ) ;
Common . component . Analytics . trackEvent ( 'DocumentHolder' , 'Distribute Vertically' ) ;
}
}
2022-05-04 19:59:02 +00:00
me . editComplete ( ) ;
2022-05-04 13:51:53 +00:00
} ,
onImgArrange : function ( menu , item , e ) {
var me = this ;
if ( me . api && item . options . valign !== undefined ) {
var properties = new Asc . asc _CImgProperty ( ) ;
properties . put _ChangeLevel ( item . options . valign ) ;
me . api . ImgApply ( properties ) ;
}
2022-05-04 19:59:02 +00:00
me . editComplete ( ) ;
2022-05-04 13:51:53 +00:00
} ,
onImgGroup : function ( item ) {
var me = this ;
if ( me . api ) {
var properties = new Asc . asc _CImgProperty ( ) ;
properties . put _Group ( 1 ) ;
me . api . ImgApply ( properties ) ;
}
2022-05-04 19:59:02 +00:00
me . editComplete ( ) ;
2022-05-04 13:51:53 +00:00
} ,
onImgUnGroup : function ( item ) {
var me = this ;
if ( me . api ) {
var properties = new Asc . asc _CImgProperty ( ) ;
properties . put _Group ( - 1 ) ;
me . api . ImgApply ( properties ) ;
}
2022-05-04 19:59:02 +00:00
me . editComplete ( ) ;
2022-05-04 13:51:53 +00:00
} ,
onImgWrapPolygon : function ( item ) {
this . api && this . api . StartChangeWrapPolygon ( ) ;
2022-05-04 19:59:02 +00:00
this . editComplete ( ) ;
2022-05-04 13:51:53 +00:00
} ,
onImgWrap : function ( menu , item , e ) {
var me = this ;
if ( me . api && item . options . wrapType !== undefined ) {
var properties = new Asc . asc _CImgProperty ( ) ;
properties . put _WrappingStyle ( item . options . wrapType ) ;
if ( me . documentHolder . menuImageWrap . _originalProps . get _WrappingStyle ( ) === Asc . c _oAscWrapStyle2 . Inline && item . wrapType !== Asc . c _oAscWrapStyle2 . Inline ) {
properties . put _PositionH ( new Asc . CImagePositionH ( ) ) ;
properties . get _PositionH ( ) . put _UseAlign ( false ) ;
properties . get _PositionH ( ) . put _RelativeFrom ( Asc . c _oAscRelativeFromH . Column ) ;
var val = me . documentHolder . menuImageWrap . _originalProps . get _Value _X ( Asc . c _oAscRelativeFromH . Column ) ;
properties . get _PositionH ( ) . put _Value ( val ) ;
properties . put _PositionV ( new Asc . CImagePositionV ( ) ) ;
properties . get _PositionV ( ) . put _UseAlign ( false ) ;
properties . get _PositionV ( ) . put _RelativeFrom ( Asc . c _oAscRelativeFromV . Paragraph ) ;
val = me . documentHolder . menuImageWrap . _originalProps . get _Value _Y ( Asc . c _oAscRelativeFromV . Paragraph ) ;
properties . get _PositionV ( ) . put _Value ( val ) ;
}
me . api . ImgApply ( properties ) ;
}
2022-05-04 19:59:02 +00:00
me . editComplete ( ) ;
2022-05-04 13:51:53 +00:00
} ,
onImgAdvanced : function ( item , e ) {
var elType , elValue ;
var me = this ;
if ( me . api ) {
var selectedElements = me . api . getSelectedElements ( ) ;
if ( selectedElements && _ . isArray ( selectedElements ) ) {
for ( var i = selectedElements . length - 1 ; i >= 0 ; i -- ) {
elType = selectedElements [ i ] . get _ObjectType ( ) ;
elValue = selectedElements [ i ] . get _ObjectValue ( ) ;
if ( Asc . c _oAscTypeSelectElement . Image == elType ) {
var imgsizeOriginal ;
if ( ! elValue . get _ChartProperties ( ) && ! elValue . get _ShapeProperties ( ) && ! me . documentHolder . menuOriginalSize . isDisabled ( ) && me . documentHolder . menuOriginalSize . isVisible ( ) ) {
imgsizeOriginal = me . api . get _OriginalSizeImage ( ) ;
if ( imgsizeOriginal )
imgsizeOriginal = { width : imgsizeOriginal . get _ImageWidth ( ) , height : imgsizeOriginal . get _ImageHeight ( ) } ;
}
var win = new DE . Views . ImageSettingsAdvanced ( {
imageProps : elValue ,
sizeOriginal : imgsizeOriginal ,
api : me . api ,
sectionProps : me . api . asc _GetSectionProps ( ) ,
handler : function ( result , value ) {
if ( result == 'ok' ) {
if ( me . api ) {
me . api . ImgApply ( value . imageProps ) ;
}
}
2022-05-04 19:59:02 +00:00
me . editComplete ( ) ;
2022-05-04 13:51:53 +00:00
}
} ) ;
win . show ( ) ;
win . btnOriginalSize . setVisible ( me . documentHolder . menuOriginalSize . isVisible ( ) ) ;
break ;
}
}
}
}
} ,
onImgOriginalSize : function ( item , e ) {
var me = this ;
if ( me . api ) {
var originalImageSize = me . api . get _OriginalSizeImage ( ) ;
var properties = new Asc . asc _CImgProperty ( ) ;
properties . put _Width ( originalImageSize . get _ImageWidth ( ) ) ;
properties . put _Height ( originalImageSize . get _ImageHeight ( ) ) ;
properties . put _ResetCrop ( true ) ;
properties . put _Rot ( 0 ) ;
me . api . ImgApply ( properties ) ;
2022-05-04 19:59:02 +00:00
me . editComplete ( ) ;
2022-05-04 13:51:53 +00:00
}
} ,
onImgReplace : function ( menu , item , e ) {
var me = this ;
if ( item . value == 1 ) {
( new Common . Views . ImageFromUrlDialog ( {
handler : function ( result , value ) {
if ( result == 'ok' ) {
if ( me . api ) {
var checkUrl = value . replace ( / /g , '' ) ;
if ( ! _ . isEmpty ( checkUrl ) ) {
var props = new Asc . asc _CImgProperty ( ) ;
props . put _ImageUrl ( checkUrl ) ;
me . api . ImgApply ( props ) ;
}
}
}
2022-05-04 19:59:02 +00:00
me . editComplete ( ) ;
2022-05-04 13:51:53 +00:00
}
} ) ) . show ( ) ;
} else if ( item . value == 2 ) {
Common . NotificationCenter . trigger ( 'storage:image-load' , 'change' ) ;
} else {
setTimeout ( function ( ) {
if ( me . api ) me . api . ChangeImageFromFile ( ) ;
2022-05-04 19:59:02 +00:00
me . editComplete ( ) ;
2022-05-04 13:51:53 +00:00
} , 10 ) ;
}
} ,
onImgEditPoints : function ( item ) {
this . api && this . api . asc _editPointsGeometry ( ) ;
} ,
2022-05-04 19:18:04 +00:00
onTableMerge : function ( item ) {
this . api && this . api . MergeCells ( ) ;
} ,
onTableSplit : function ( item ) {
var me = this ;
if ( me . api ) {
( new Common . Views . InsertTableDialog ( {
split : true ,
handler : function ( result , value ) {
if ( result == 'ok' ) {
if ( me . api ) {
me . api . SplitCell ( value . columns , value . rows ) ;
}
Common . component . Analytics . trackEvent ( 'DocumentHolder' , 'Table' ) ;
}
2022-05-04 19:59:02 +00:00
me . editComplete ( ) ;
2022-05-04 19:18:04 +00:00
}
} ) ) . show ( ) ;
}
} ,
onIgnoreSpell : function ( item , e ) {
this . api && this . api . asc _ignoreMisspelledWord ( this . documentHolder . _currentSpellObj , ! ! item . value ) ;
2022-05-04 19:59:02 +00:00
this . editComplete ( ) ;
2022-05-04 19:18:04 +00:00
} ,
onToDictionary : function ( item , e ) {
this . api && this . api . asc _spellCheckAddToDictionary ( this . documentHolder . _currentSpellObj ) ;
2022-05-04 19:59:02 +00:00
this . editComplete ( ) ;
2022-05-04 19:18:04 +00:00
} ,
onTableDist : function ( item , e ) {
this . api && this . api . asc _DistributeTableCells ( ! ! item . value ) ;
2022-05-04 19:59:02 +00:00
this . editComplete ( ) ;
2022-05-04 19:18:04 +00:00
} ,
tableDirection : function ( menu , item , e ) {
var me = this ;
if ( me . api ) {
var properties = new Asc . CTableProp ( ) ;
properties . put _CellsTextDirection ( item . options . direction ) ;
me . api . tblApply ( properties ) ;
}
} ,
2022-05-04 13:51:53 +00:00
2022-05-04 19:18:04 +00:00
onRefreshField : function ( item , e ) {
this . api && this . api . asc _UpdateComplexField ( item . options . fieldProps ) ;
2022-05-04 19:59:02 +00:00
this . editComplete ( ) ;
2022-05-04 19:18:04 +00:00
} ,
2022-05-04 13:51:53 +00:00
2022-05-04 19:18:04 +00:00
onParagraphBreakBefore : function ( item , e ) {
this . api && this . api . put _PageBreak ( item . checked ) ;
} ,
onParagraphKeepLines : function ( item , e ) {
this . api && this . api . put _KeepLines ( item . checked ) ;
} ,
paragraphVAlign : function ( menu , item , e ) {
var me = this ;
if ( me . api ) {
var properties = new Asc . asc _CImgProperty ( ) ;
properties . put _VerticalTextAlign ( item . options . valign ) ;
me . api . ImgApply ( properties ) ;
}
} ,
paragraphDirection : function ( menu , item , e ) {
var me = this ;
if ( me . api ) {
var properties = new Asc . asc _CImgProperty ( ) ;
properties . put _Vert ( item . options . direction ) ;
me . api . ImgApply ( properties ) ;
}
} ,
onLangMenu : function ( type , menu , item ) {
var me = this ;
if ( me . api ) {
if ( ! _ . isUndefined ( item . langid ) )
me . api . put _TextPrLang ( item . langid ) ;
2022-05-04 20:18:05 +00:00
( type === 'para' ) ? ( me . documentHolder . _currLang . paraid = item . langid ) : ( me . documentHolder . _currLang . tableid = item . langid ) ;
2022-05-04 19:59:02 +00:00
me . editComplete ( ) ;
2022-05-04 19:18:04 +00:00
}
} ,
2022-05-04 13:51:53 +00:00
2022-05-04 20:18:05 +00:00
onTOCMenu : function ( menu , item , e ) {
this . documentHolder . fireEvent ( ( item . value === 'settings' ) ? 'links:contents' : 'links:update' , [ item . value , true ] ) ;
} ,
onParaTOCSettings : function ( item , e ) {
this . documentHolder . fireEvent ( 'links:contents' , [ item . value , true ] ) ;
} ,
2022-06-01 19:49:52 +00:00
onSpecialPasteItemClick : function ( item , e ) {
if ( this . api ) {
this . api . asc _SpecialPaste ( item . value ) ;
var menu = this . btnSpecialPaste . menu ;
if ( ! item . cmpEl ) {
for ( var i = 0 ; i < menu . items . length ; i ++ ) {
menu . items [ i ] . setChecked ( menu . items [ i ] . value === item . value , true ) ;
}
}
setTimeout ( function ( ) {
menu . hide ( ) ;
} , 100 ) ;
}
return false ;
} ,
2022-05-04 13:51:53 +00:00
editComplete : function ( ) {
this . documentHolder && this . documentHolder . fireEvent ( 'editcomplete' , this . documentHolder ) ;
2022-05-04 19:18:04 +00:00
}
2016-03-11 00:48:53 +00:00
} ) ;
} ) ;