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 view
*
* Created by Alexander Yuzhin on 1 / 11 / 14
2018-03-01 12:16:38 +00:00
* Copyright ( c ) 2018 Ascensio System SIA . All rights reserved .
2016-03-11 00:48:53 +00:00
*
* /
define ( [
'jquery' ,
'underscore' ,
'backbone' ,
'gateway' ,
'common/main/lib/util/utils' ,
'common/main/lib/component/Menu' ,
2019-12-05 10:48:48 +00:00
'common/main/lib/component/Calendar' ,
2016-03-11 00:48:53 +00:00
'common/main/lib/view/InsertTableDialog' ,
'common/main/lib/view/CopyWarningDialog' ,
'documenteditor/main/app/view/DropcapSettingsAdvanced' ,
'documenteditor/main/app/view/HyperlinkSettingsDialog' ,
'documenteditor/main/app/view/ParagraphSettingsAdvanced' ,
2017-12-13 13:52:14 +00:00
'documenteditor/main/app/view/TableSettingsAdvanced' ,
2018-07-20 09:00:30 +00:00
'documenteditor/main/app/view/ControlSettingsDialog' ,
2019-09-05 11:38:34 +00:00
'documenteditor/main/app/view/NumberingValueDialog' ,
2019-09-06 11:37:43 +00:00
'documenteditor/main/app/view/CellsRemoveDialog' ,
'documenteditor/main/app/view/CellsAddDialog'
2016-03-11 00:48:53 +00:00
] , function ( $ , _ , Backbone , gateway ) { 'use strict' ;
DE . Views . DocumentHolder = Backbone . View . extend ( _ . extend ( {
el : '#editor_sdk' ,
// Compile our stats template
template : null ,
// Delegated events for creating new items, and clearing completed ones.
events : {
} ,
initialize : function ( ) {
var me = this ;
/** coauthoring begin **/
var usersStore = DE . getCollection ( 'Common.Collections.Users' ) ;
/** coauthoring end **/
me . _TtHeight = 20 ;
me . _currentSpellObj = undefined ;
me . _currLang = { } ;
me . usertips = [ ] ;
me . fastcoauthtips = [ ] ;
me . _currentMathObj = undefined ;
me . _currentParaObjDisabled = false ;
2017-08-23 15:06:55 +00:00
me . _isDisabled = false ;
2016-03-11 00:48:53 +00:00
var showPopupMenu = function ( menu , value , event , docElement , eOpts ) {
2017-06-06 08:04:04 +00:00
if ( ! _ . isUndefined ( menu ) && menu !== null ) {
2016-03-11 00:48:53 +00:00
Common . UI . Menu . Manager . hideAll ( ) ;
var showPoint = [ event . get _X ( ) , event . get _Y ( ) ] ,
menuContainer = $ ( me . 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 . 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 ) ;
me . currentMenu = menu ;
}
} ;
var fillMenuProps = function ( selectedElements ) {
if ( ! selectedElements || ! _ . isArray ( selectedElements ) ) return ;
var menu _props = { } ,
menu _to _show = me . textMenu ,
noobject = true ;
for ( var i = 0 ; i < selectedElements . length ; i ++ ) {
var elType = selectedElements [ i ] . get _ObjectType ( ) ;
var elValue = selectedElements [ i ] . get _ObjectValue ( ) ;
2016-04-05 11:52:34 +00:00
if ( Asc . c _oAscTypeSelectElement . Image == elType ) {
2016-03-11 00:48:53 +00:00
//image
menu _to _show = me . 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 ;
2018-02-06 08:56:13 +00:00
else if ( shapeprops . get _FromImage ( ) )
menu _props . imgProps . isOnlyImg = true ;
2016-03-11 00:48:53 +00:00
else
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 ;
2016-04-05 11:52:34 +00:00
} else if ( Asc . c _oAscTypeSelectElement . Table == elType )
2016-03-11 00:48:53 +00:00
{
menu _to _show = me . tableMenu ;
menu _props . tableProps = { } ;
menu _props . tableProps . value = elValue ;
menu _props . tableProps . locked = ( elValue ) ? elValue . get _Locked ( ) : false ;
noobject = false ;
2016-04-05 11:52:34 +00:00
} else if ( Asc . c _oAscTypeSelectElement . Paragraph == elType )
2016-03-11 00:48:53 +00:00
{
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 = me . textMenu ;
noobject = false ;
2016-04-05 11:52:34 +00:00
} else if ( Asc . c _oAscTypeSelectElement . Hyperlink == elType ) {
2016-03-11 00:48:53 +00:00
if ( menu _props . hyperProps )
menu _props . hyperProps . isSeveralLinks = true ;
else
menu _props . hyperProps = { } ;
menu _props . hyperProps . value = elValue ;
2016-04-05 11:52:34 +00:00
} else if ( Asc . c _oAscTypeSelectElement . Header == elType ) {
2016-03-11 00:48:53 +00:00
menu _props . headerProps = { } ;
menu _props . headerProps . locked = ( elValue ) ? elValue . get _Locked ( ) : false ;
2016-04-05 11:52:34 +00:00
} else if ( Asc . c _oAscTypeSelectElement . SpellCheck == elType ) {
2016-03-11 00:48:53 +00:00
menu _props . spellProps = { } ;
menu _props . spellProps . value = elValue ;
me . _currentSpellObj = elValue ;
2016-04-05 11:52:34 +00:00
} else if ( Asc . c _oAscTypeSelectElement . Math == elType ) {
2016-03-11 00:48:53 +00:00
menu _props . mathProps = { } ;
menu _props . mathProps . value = elValue ;
me . _currentMathObj = elValue ;
}
}
return ( ! noobject ) ? { menu _to _show : menu _to _show , menu _props : menu _props } : null ;
} ;
2017-06-06 08:04:04 +00:00
var fillViewMenuProps = function ( selectedElements ) {
if ( ! selectedElements || ! _ . isArray ( selectedElements ) ) return ;
2017-08-23 20:22:33 +00:00
if ( ! me . viewModeMenu )
me . createDelayedElementsViewer ( ) ;
2017-06-06 08:04:04 +00:00
var menu _props = { } ,
menu _to _show = me . 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 ;
}
}
return ( ! noobject ) ? { menu _to _show : menu _to _show , menu _props : menu _props } : null ;
} ;
2016-03-11 00:48:53 +00:00
var showObjectMenu = function ( event , docElement , eOpts ) {
2017-06-06 08:04:04 +00:00
if ( me . api ) {
2017-08-23 15:06:55 +00:00
var obj = ( me . mode . isEdit && ! me . _isDisabled ) ? fillMenuProps ( me . api . getSelectedElements ( ) ) : fillViewMenuProps ( me . api . getSelectedElements ( ) ) ;
2016-03-11 00:48:53 +00:00
if ( obj ) showPopupMenu ( obj . menu _to _show , obj . menu _props , event , docElement , eOpts ) ;
}
} ;
var onContextMenu = function ( event ) {
_ . delay ( function ( ) {
if ( event . get _Type ( ) == 0 ) {
showObjectMenu . call ( me , event ) ;
} else {
showPopupMenu . call ( me , me . hdrMenu , { Header : event . is _Header ( ) , PageNum : event . get _PageNum ( ) } , event ) ;
}
} , 10 ) ;
} ;
var onFocusObject = function ( selectedElements ) {
2017-06-06 08:04:04 +00:00
if ( me . currentMenu && me . currentMenu . isVisible ( ) && me . currentMenu !== me . hdrMenu ) {
2017-08-23 15:06:55 +00:00
var obj = ( me . mode . isEdit && ! me . _isDisabled ) ? fillMenuProps ( selectedElements ) : fillViewMenuProps ( selectedElements ) ;
2016-03-11 00:48:53 +00:00
if ( obj ) {
if ( obj . menu _to _show === me . currentMenu ) {
me . currentMenu . options . initMenu ( obj . menu _props ) ;
me . currentMenu . alignPosition ( ) ;
}
}
}
} ;
var handleDocumentWheel = function ( event ) {
if ( me . api ) {
var delta = ( _ . isUndefined ( event . originalEvent ) ) ? event . wheelDelta : event . originalEvent . wheelDelta ;
if ( _ . isUndefined ( delta ) ) {
delta = event . deltaY ;
}
if ( ( event . ctrlKey || event . metaKey ) && ! event . altKey ) {
if ( delta < 0 ) {
me . api . zoomOut ( ) ;
} else if ( delta > 0 ) {
me . api . zoomIn ( ) ;
}
event . preventDefault ( ) ;
event . stopPropagation ( ) ;
}
}
} ;
var handleDocumentKeyDown = function ( event ) {
if ( me . api ) {
var key = event . keyCode ;
if ( ( event . ctrlKey || event . metaKey ) && ! event . shiftKey && ! event . altKey ) {
2017-09-19 14:26:09 +00:00
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 ) ) {
2016-03-11 00:48:53 +00:00
me . api . zoomIn ( ) ;
event . preventDefault ( ) ;
event . stopPropagation ( ) ;
return false ;
}
2017-09-19 14:26:09 +00:00
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 ) ) {
2016-03-11 00:48:53 +00:00
me . api . zoomOut ( ) ;
event . preventDefault ( ) ;
event . stopPropagation ( ) ;
return false ;
}
}
if ( me . currentMenu && me . currentMenu . isVisible ( ) ) {
if ( key == Common . UI . Keys . UP ||
key == Common . UI . Keys . DOWN ) {
$ ( 'ul.dropdown-menu' , me . currentMenu . el ) . focus ( ) ;
}
}
if ( key == Common . UI . Keys . ESC ) {
Common . UI . Menu . Manager . hideAll ( ) ;
Common . NotificationCenter . trigger ( 'leftmenu:change' , 'hide' ) ;
}
}
} ;
var onDocumentHolderResize = function ( e ) {
me . _XY = [
me . cmpEl . offset ( ) . left - $ ( window ) . scrollLeft ( ) ,
me . cmpEl . offset ( ) . top - $ ( window ) . scrollTop ( )
] ;
me . _Height = me . cmpEl . height ( ) ;
me . _BodyWidth = $ ( 'body' ) . width ( ) ;
} ;
var onAfterRender = function ( ct ) {
var meEl = me . cmpEl ;
if ( meEl ) {
meEl . on ( 'contextmenu' , function ( e ) {
e . preventDefault ( ) ;
e . stopPropagation ( ) ;
return false ;
} ) ;
meEl . on ( 'click' , function ( e ) {
if ( e . target . localName == 'canvas' ) {
2018-03-14 10:19:41 +00:00
if ( me . _preventClick )
me . _preventClick = false ;
else
meEl . focus ( ) ;
2016-03-11 00:48:53 +00:00
}
} ) ;
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 . el , eventname , handleDocumentWheel ) ;
}
$ ( document ) . on ( 'mousewheel' , handleDocumentWheel ) ;
$ ( document ) . on ( 'keydown' , handleDocumentKeyDown ) ;
$ ( window ) . on ( 'resize' , onDocumentHolderResize ) ;
var viewport = DE . getController ( 'Viewport' ) . getView ( 'Viewport' ) ;
viewport . hlayout . on ( 'layout:resizedrag' , onDocumentHolderResize ) ;
} ;
/** coauthoring begin **/
var getUserName = function ( id ) {
if ( usersStore ) {
var rec = usersStore . findUser ( id ) ;
if ( rec )
return rec . get ( 'username' ) ;
}
return me . guestText ;
} ;
/** coauthoring end **/
var screenTip = {
toolTip : new Common . UI . Tooltip ( {
owner : this ,
html : true ,
2016-12-26 14:07:50 +00:00
title : '<br><b>Press Ctrl and click link</b>' ,
cls : 'link-tooltip'
2016-03-11 00:48:53 +00:00
// style: 'word-wrap: break-word;'
} ) ,
strTip : '' ,
isHidden : true ,
isVisible : false
} ;
/** coauthoring begin **/
var userTooltip = true ;
var userTipMousover = function ( evt , el , opt ) {
if ( userTooltip === true ) {
userTooltip = new Common . UI . Tooltip ( {
owner : evt . currentTarget ,
title : me . tipIsLocked
} ) ;
userTooltip . show ( ) ;
}
} ;
var userTipHide = function ( ) {
if ( typeof userTooltip == 'object' ) {
userTooltip . hide ( ) ;
userTooltip = undefined ;
for ( var i = 0 ; i < me . usertips . length ; i ++ ) {
me . usertips [ i ] . off ( 'mouseover' , userTipMousover ) ;
me . usertips [ i ] . off ( 'mouseout' , userTipMousout ) ;
}
}
} ;
var userTipMousout = function ( evt , el , opt ) {
if ( typeof userTooltip == 'object' ) {
if ( userTooltip . $element && evt . currentTarget === userTooltip . $element [ 0 ] ) {
userTipHide ( ) ;
}
}
} ;
/** coauthoring end **/
Common . NotificationCenter . on ( {
'window:show' : function ( e ) {
screenTip . toolTip . hide ( ) ;
screenTip . isVisible = false ;
/** coauthoring begin **/
userTipHide ( ) ;
/** coauthoring end **/
} ,
'modal:show' : function ( e ) {
me . hideTips ( ) ;
} ,
'layout:changed' : function ( e ) {
screenTip . toolTip . hide ( ) ;
screenTip . isVisible = false ;
/** coauthoring begin **/
userTipHide ( ) ;
/** coauthoring end **/
me . hideTips ( ) ;
onDocumentHolderResize ( ) ;
}
} ) ;
var onHyperlinkClick = function ( url ) {
if ( url && me . api . asc _getUrlType ( url ) > 0 ) {
window . open ( url ) ;
}
} ;
var onMouseMoveStart = function ( ) {
screenTip . isHidden = true ;
/** coauthoring begin **/
if ( me . usertips . length > 0 ) {
if ( typeof userTooltip == 'object' ) {
userTooltip . hide ( ) ;
userTooltip = true ;
}
_ . each ( me . usertips , function ( item ) {
item . remove ( ) ;
} ) ;
}
me . usertips = [ ] ;
me . usertipcount = 0 ;
/** coauthoring end **/
} ;
2016-12-26 14:07:50 +00:00
var mouseMoveData = null ,
isTooltipHiding = false ;
2016-03-11 00:48:53 +00:00
var onMouseMoveEnd = function ( ) {
if ( screenTip . isHidden && screenTip . isVisible ) {
screenTip . isVisible = false ;
2016-12-26 14:07:50 +00:00
isTooltipHiding = true ;
screenTip . toolTip . hide ( function ( ) {
isTooltipHiding = false ;
if ( mouseMoveData ) onMouseMove ( mouseMoveData ) ;
mouseMoveData = null ;
} ) ;
2016-03-11 00:48:53 +00:00
}
} ;
var onMouseMove = function ( moveData ) {
if ( me . _XY === undefined ) {
me . _XY = [
me . cmpEl . offset ( ) . left - $ ( window ) . scrollLeft ( ) ,
me . cmpEl . offset ( ) . top - $ ( window ) . scrollTop ( )
] ;
me . _Height = me . cmpEl . height ( ) ;
me . _BodyWidth = $ ( 'body' ) . width ( ) ;
}
if ( moveData ) {
2016-12-26 14:07:50 +00:00
var showPoint , ToolTip ,
type = moveData . get _Type ( ) ;
2016-03-11 00:48:53 +00:00
2016-12-26 14:07:50 +00:00
if ( type == 1 || type == 3 ) { // 1 - hyperlink, 3 - footnote
if ( isTooltipHiding ) {
mouseMoveData = moveData ;
return ;
}
2016-03-11 00:48:53 +00:00
2016-12-26 14:07:50 +00:00
if ( type == 1 ) {
var hyperProps = moveData . get _Hyperlink ( ) ;
if ( ! hyperProps ) return ;
2016-03-11 00:48:53 +00:00
ToolTip = ( _ . isEmpty ( hyperProps . get _ToolTip ( ) ) ) ? hyperProps . get _Value ( ) : hyperProps . get _ToolTip ( ) ;
2016-12-26 14:07:50 +00:00
} else {
ToolTip = moveData . get _FootnoteText ( ) ;
if ( ToolTip . length > 1000 )
ToolTip = ToolTip . substr ( 0 , 1000 ) + '...' ;
}
var recalc = false ;
screenTip . isHidden = false ;
ToolTip = Common . Utils . String . htmlEncode ( ToolTip ) ;
if ( screenTip . tipType !== type || screenTip . tipLength !== ToolTip . length || screenTip . strTip . indexOf ( ToolTip ) < 0 ) {
screenTip . toolTip . setTitle ( ( type == 1 ) ? ( ToolTip + '<br><b>' + me . txtPressLink + '</b>' ) : ToolTip ) ;
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 ] ) ;
2016-03-11 00:48:53 +00:00
}
2016-12-26 14:07:50 +00:00
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' } ) ;
2016-03-11 00:48:53 +00:00
}
/** coauthoring begin **/
else if ( moveData . get _Type ( ) == 2 && me . mode . isEdit ) { // 2 - locked object
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 ( userTooltip ) {
src . on ( 'mouseover' , userTipMousover ) ;
src . on ( 'mouseout' , userTipMousout ) ;
}
me . usertips . push ( src ) ;
}
src = me . usertips [ me . usertipcount ] ;
me . usertipcount ++ ;
ToolTip = getUserName ( moveData . get _UserId ( ) ) ;
showPoint = [ moveData . get _X ( ) + me . _XY [ 0 ] , moveData . get _Y ( ) + me . _XY [ 1 ] ] ;
2018-04-04 13:40:23 +00:00
var maxwidth = showPoint [ 0 ] ;
2016-03-11 00:48:53 +00:00
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 ) ;
2018-04-04 13:40:23 +00:00
src . css ( { visibility : 'visible' , top : showPoint [ 1 ] + 'px' , right : showPoint [ 0 ] + 'px' , 'max-width' : maxwidth + 'px' } ) ;
2016-03-11 00:48:53 +00:00
} else {
src . css ( { visibility : 'hidden' } ) ;
}
}
/** coauthoring end **/
}
} ;
var onShowForeignCursorLabel = function ( UserId , X , Y , color ) {
/** coauthoring begin **/
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 ( 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 **/
} ;
var onHideForeignCursorLabel = function ( UserId ) {
/** coauthoring begin **/
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 **/
} ;
2017-05-12 08:52:19 +00:00
var onShowSpecialPasteOptions = function ( specialPasteShowOptions ) {
var coord = specialPasteShowOptions . asc _getCellCoord ( ) ,
pasteContainer = me . cmpEl . find ( '#special-paste-container' ) ,
pasteItems = specialPasteShowOptions . asc _getOptions ( ) ;
2018-11-13 15:06:00 +00:00
if ( ! pasteItems ) return ;
2017-05-12 08:52:19 +00:00
// Prepare menu container
if ( pasteContainer . length < 1 ) {
me . _arrSpecialPaste = [ ] ;
me . _arrSpecialPaste [ Asc . c _oSpecialPasteProps . paste ] = me . textPaste ;
2018-03-23 14:11:51 +00:00
me . _arrSpecialPaste [ Asc . c _oSpecialPasteProps . sourceformatting ] = me . txtPasteSourceFormat ;
2017-05-12 08:52:19 +00:00
me . _arrSpecialPaste [ Asc . c _oSpecialPasteProps . keepTextOnly ] = me . txtKeepTextOnly ;
2017-12-08 15:00:56 +00:00
me . _arrSpecialPaste [ Asc . c _oSpecialPasteProps . insertAsNestedTable ] = me . textNest ;
me . _arrSpecialPaste [ Asc . c _oSpecialPasteProps . overwriteCells ] = me . txtOverwriteCells ;
2017-05-12 08:52:19 +00:00
pasteContainer = $ ( '<div id="special-paste-container" style="position: absolute;"><div id="id-document-holder-btn-special-paste"></div></div>' ) ;
me . cmpEl . append ( pasteContainer ) ;
me . btnSpecialPaste = new Common . UI . Button ( {
cls : 'btn-toolbar' ,
2019-12-10 13:49:35 +00:00
iconCls : 'toolbar__icon btn-paste' ,
2017-05-12 08:52:19 +00:00
menu : new Common . UI . Menu ( { items : [ ] } )
} ) ;
me . btnSpecialPaste . render ( $ ( '#id-document-holder-btn-special-paste' ) ) ;
}
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 ( {
caption : me . _arrSpecialPaste [ menuItem ] ,
value : menuItem ,
checkable : true ,
toggleGroup : 'specialPasteGroup'
} ) . on ( 'click' , function ( item , e ) {
me . api . asc _SpecialPaste ( item . value ) ;
setTimeout ( function ( ) { menu . hide ( ) ; } , 100 ) ;
} ) ;
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 ( ) ;
} else {
var showPoint = [ coord . asc _getX ( ) + coord . asc _getWidth ( ) + 3 , coord . asc _getY ( ) + coord . asc _getHeight ( ) + 3 ] ;
pasteContainer . css ( { left : showPoint [ 0 ] , top : showPoint [ 1 ] } ) ;
pasteContainer . show ( ) ;
}
} ;
var onHideSpecialPasteOptions = function ( ) {
var pasteContainer = me . cmpEl . find ( '#special-paste-container' ) ;
if ( pasteContainer . is ( ':visible' ) )
pasteContainer . hide ( ) ;
} ;
2016-03-11 00:48:53 +00:00
var onDialogAddHyperlink = function ( ) {
var win , props , text ;
2018-08-28 11:24:09 +00:00
if ( me . api && me . mode . isEdit && ! me . _isDisabled && ! DE . getController ( 'LeftMenu' ) . leftMenu . menuFile . isVisible ( ) ) {
2016-03-11 00:48:53 +00:00
var handlerDlg = function ( dlg , result ) {
if ( result == 'ok' ) {
props = dlg . getSettings ( ) ;
( text !== false )
? me . api . add _Hyperlink ( props )
: me . api . change _Hyperlink ( props ) ;
}
me . fireEvent ( 'editcomplete' , me ) ;
} ;
text = me . api . can _AddHyperlink ( ) ;
if ( text !== false ) {
win = new DE . Views . HyperlinkSettingsDialog ( {
api : me . api ,
handler : handlerDlg
} ) ;
2016-04-05 12:57:51 +00:00
props = new Asc . CHyperlinkProperty ( ) ;
2016-03-11 00:48:53 +00:00
props . put _Text ( text ) ;
win . show ( ) ;
win . setSettings ( props ) ;
} else {
var selectedElements = me . api . getSelectedElements ( ) ;
if ( selectedElements && _ . isArray ( selectedElements ) ) {
_ . each ( selectedElements , function ( el , i ) {
2016-04-05 11:52:34 +00:00
if ( selectedElements [ i ] . get _ObjectType ( ) == Asc . c _oAscTypeSelectElement . Hyperlink )
2016-03-11 00:48:53 +00:00
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' ) ;
}
} ;
var onDoubleClickOnChart = function ( chart ) {
2017-08-23 15:06:55 +00:00
if ( me . mode . isEdit && ! me . _isDisabled ) {
2016-03-11 00:48:53 +00:00
var diagramEditor = DE . getController ( 'Common.Controllers.ExternalDiagramEditor' ) . getView ( 'Common.Views.ExternalDiagramEditor' ) ;
if ( diagramEditor && chart ) {
diagramEditor . setEditMode ( true ) ;
diagramEditor . show ( ) ;
diagramEditor . setChartData ( new Asc . asc _CChartBinary ( chart ) ) ;
}
}
} ;
var onCoAuthoringDisconnect = function ( ) {
me . mode . isEdit = false ;
} ;
var onTextLanguage = function ( langid ) {
me . _currLang . id = langid ;
} ;
this . changeLanguageMenu = function ( menu ) {
if ( me . _currLang . id === null || me . _currLang . id === undefined ) {
2019-08-10 13:38:51 +00:00
menu . clearAll ( ) ;
2016-03-11 00:48:53 +00:00
} else {
2019-08-10 13:38:51 +00:00
var index = _ . findIndex ( menu . items , { langid : me . _currLang . id } ) ;
( index > - 1 ) && ! menu . items [ index ] . checked && menu . setChecked ( index , true ) ;
2016-03-11 00:48:53 +00:00
}
} ;
var onSpellCheckVariantsFound = function ( ) {
var selectedElements = me . api . getSelectedElements ( true ) ;
var props ;
if ( selectedElements && _ . isArray ( selectedElements ) ) {
for ( var i = 0 ; i < selectedElements . length ; i ++ ) {
2016-04-05 11:52:34 +00:00
if ( selectedElements [ i ] . get _ObjectType ( ) == Asc . c _oAscTypeSelectElement . SpellCheck ) {
2016-03-11 00:48:53 +00:00
props = selectedElements [ i ] . get _ObjectValue ( ) ;
me . _currentSpellObj = props ;
break ;
}
}
}
if ( props && props . get _Checked ( ) === false && props . get _Variants ( ) !== null && props . get _Variants ( ) !== undefined ) {
me . addWordVariants ( ) ;
2018-11-08 12:08:55 +00:00
if ( me . textMenu && me . textMenu . isVisible ( ) ) {
2016-03-11 00:48:53 +00:00
me . textMenu . alignPosition ( ) ;
}
}
} ;
this . addWordVariants = function ( isParagraph ) {
2019-07-11 11:35:24 +00:00
if ( ! me . textMenu || ! me . textMenu . isVisible ( ) && ! me . tableMenu . isVisible ( ) ) return ;
2018-11-08 12:08:55 +00:00
2016-03-11 00:48:53 +00:00
if ( _ . isUndefined ( isParagraph ) ) {
isParagraph = me . textMenu . isVisible ( ) ;
}
me . clearWordVariants ( isParagraph ) ;
var moreMenu = ( isParagraph ) ? me . menuSpellMorePara : me . menuSpellMoreTable ;
var spellMenu = ( isParagraph ) ? me . menuSpellPara : me . menuSpellTable ;
var arr = [ ] ,
arrMore = [ ] ;
var variants = me . _currentSpellObj . get _Variants ( ) ;
if ( variants . length > 0 ) {
moreMenu . setVisible ( variants . length > 3 ) ;
moreMenu . setDisabled ( me . _currentParaObjDisabled ) ;
_ . each ( variants , function ( variant , index ) {
var mnu = new Common . UI . MenuItem ( {
caption : variant ,
spellword : true ,
disabled : me . _currentParaObjDisabled
} ) . on ( 'click' , function ( item , e ) {
if ( me . api ) {
me . api . asc _replaceMisspelledWord ( item . caption , me . _currentSpellObj ) ;
me . fireEvent ( 'editcomplete' , me ) ;
}
} ) ;
( index < 3 ) ? arr . push ( mnu ) : arrMore . push ( mnu ) ;
} ) ;
if ( arr . length > 0 ) {
if ( isParagraph ) {
2019-06-25 13:13:50 +00:00
_ . each ( arr , function ( variant , index ) {
me . textMenu . insertItem ( index , variant ) ;
2016-03-11 00:48:53 +00:00
} )
} else {
2019-06-25 13:13:50 +00:00
_ . each ( arr , function ( variant , index ) {
me . menuSpellCheckTable . menu . insertItem ( index , variant ) ;
2016-03-11 00:48:53 +00:00
} )
}
}
if ( arrMore . length > 0 ) {
2019-06-25 13:13:50 +00:00
_ . each ( arrMore , function ( variant , index ) {
moreMenu . menu . addItem ( variant ) ;
2016-03-11 00:48:53 +00:00
} ) ;
}
spellMenu . setVisible ( false ) ;
} else {
moreMenu . setVisible ( false ) ;
spellMenu . setVisible ( true ) ;
spellMenu . setCaption ( me . noSpellVariantsText , true ) ;
}
} ;
this . clearWordVariants = function ( isParagraph ) {
var spellMenu = ( isParagraph ) ? me . textMenu : me . menuSpellCheckTable . menu ;
for ( var i = 0 ; i < spellMenu . items . length ; i ++ ) {
if ( spellMenu . items [ i ] . options . spellword ) {
if ( spellMenu . checkeditem == spellMenu . items [ i ] ) {
spellMenu . checkeditem = undefined ;
spellMenu . activeItem = undefined ;
}
spellMenu . removeItem ( spellMenu . items [ i ] ) ;
i -- ;
}
}
( isParagraph ) ? me . menuSpellMorePara . menu . removeAll ( ) : me . menuSpellMoreTable . menu . removeAll ( ) ;
me . menuSpellMorePara . menu . checkeditem = undefined ;
me . menuSpellMorePara . menu . activeItem = undefined ;
me . menuSpellMoreTable . menu . checkeditem = undefined ;
me . menuSpellMoreTable . menu . activeItem = undefined ;
} ;
this . initEquationMenu = function ( ) {
if ( ! me . _currentMathObj ) return ;
var type = me . _currentMathObj . get _Type ( ) ,
value = me . _currentMathObj ,
mnu , arr = [ ] ;
switch ( type ) {
2016-04-05 11:52:34 +00:00
case Asc . c _oAscMathInterfaceType . Accent :
2016-03-11 00:48:53 +00:00
mnu = new Common . UI . MenuItem ( {
caption : me . txtRemoveAccentChar ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
equationProps : { type : type , callback : 'remove_AccentCharacter' }
} ) ;
arr . push ( mnu ) ;
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscMathInterfaceType . BorderBox :
2016-03-11 00:48:53 +00:00
mnu = new Common . UI . MenuItem ( {
caption : me . txtBorderProps ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
menu : new Common . UI . Menu ( {
menuAlign : 'tl-tr' ,
items : [
{
caption : value . get _HideTop ( ) ? me . txtAddTop : me . txtHideTop ,
equationProps : { type : type , callback : 'put_HideTop' , value : ! value . get _HideTop ( ) }
} ,
{
caption : value . get _HideBottom ( ) ? me . txtAddBottom : me . txtHideBottom ,
equationProps : { type : type , callback : 'put_HideBottom' , value : ! value . get _HideBottom ( ) }
} ,
{
caption : value . get _HideLeft ( ) ? me . txtAddLeft : me . txtHideLeft ,
equationProps : { type : type , callback : 'put_HideLeft' , value : ! value . get _HideLeft ( ) }
} ,
{
caption : value . get _HideRight ( ) ? me . txtAddRight : me . txtHideRight ,
equationProps : { type : type , callback : 'put_HideRight' , value : ! value . get _HideRight ( ) }
} ,
{
caption : value . get _HideHor ( ) ? me . txtAddHor : me . txtHideHor ,
equationProps : { type : type , callback : 'put_HideHor' , value : ! value . get _HideHor ( ) }
} ,
{
caption : value . get _HideVer ( ) ? me . txtAddVer : me . txtHideVer ,
equationProps : { type : type , callback : 'put_HideVer' , value : ! value . get _HideVer ( ) }
} ,
{
caption : value . get _HideTopLTR ( ) ? me . txtAddLT : me . txtHideLT ,
equationProps : { type : type , callback : 'put_HideTopLTR' , value : ! value . get _HideTopLTR ( ) }
} ,
{
caption : value . get _HideTopRTL ( ) ? me . txtAddLB : me . txtHideLB ,
equationProps : { type : type , callback : 'put_HideTopRTL' , value : ! value . get _HideTopRTL ( ) }
}
]
} )
} ) ;
arr . push ( mnu ) ;
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscMathInterfaceType . Bar :
2016-03-11 00:48:53 +00:00
mnu = new Common . UI . MenuItem ( {
caption : me . txtRemoveBar ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
equationProps : { type : type , callback : 'remove_Bar' }
} ) ;
arr . push ( mnu ) ;
mnu = new Common . UI . MenuItem ( {
2016-04-05 11:52:34 +00:00
caption : ( value . get _Pos ( ) == Asc . c _oAscMathInterfaceBarPos . Top ) ? me . txtUnderbar : me . txtOverbar ,
2016-03-11 00:48:53 +00:00
equation : true ,
disabled : me . _currentParaObjDisabled ,
2016-04-05 11:52:34 +00:00
equationProps : { type : type , callback : 'put_Pos' , value : ( value . get _Pos ( ) == Asc . c _oAscMathInterfaceBarPos . Top ) ? Asc . c _oAscMathInterfaceBarPos . Bottom : Asc . c _oAscMathInterfaceBarPos . Top }
2016-03-11 00:48:53 +00:00
} ) ;
arr . push ( mnu ) ;
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscMathInterfaceType . Script :
2016-03-11 00:48:53 +00:00
var scripttype = value . get _ScriptType ( ) ;
2016-04-05 11:52:34 +00:00
if ( scripttype == Asc . c _oAscMathInterfaceScript . PreSubSup ) {
2016-03-11 00:48:53 +00:00
mnu = new Common . UI . MenuItem ( {
caption : me . txtScriptsAfter ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
2016-04-05 11:52:34 +00:00
equationProps : { type : type , callback : 'put_ScriptType' , value : Asc . c _oAscMathInterfaceScript . SubSup }
2016-03-11 00:48:53 +00:00
} ) ;
arr . push ( mnu ) ;
mnu = new Common . UI . MenuItem ( {
caption : me . txtRemScripts ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
2016-04-05 11:52:34 +00:00
equationProps : { type : type , callback : 'put_ScriptType' , value : Asc . c _oAscMathInterfaceScript . None }
2016-03-11 00:48:53 +00:00
} ) ;
arr . push ( mnu ) ;
} else {
2016-04-05 11:52:34 +00:00
if ( scripttype == Asc . c _oAscMathInterfaceScript . SubSup ) {
2016-03-11 00:48:53 +00:00
mnu = new Common . UI . MenuItem ( {
caption : me . txtScriptsBefore ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
2016-04-05 11:52:34 +00:00
equationProps : { type : type , callback : 'put_ScriptType' , value : Asc . c _oAscMathInterfaceScript . PreSubSup }
2016-03-11 00:48:53 +00:00
} ) ;
arr . push ( mnu ) ;
}
2016-04-05 11:52:34 +00:00
if ( scripttype == Asc . c _oAscMathInterfaceScript . SubSup || scripttype == Asc . c _oAscMathInterfaceScript . Sub ) {
2016-03-11 00:48:53 +00:00
mnu = new Common . UI . MenuItem ( {
caption : me . txtRemSubscript ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
2016-04-05 11:52:34 +00:00
equationProps : { type : type , callback : 'put_ScriptType' , value : ( scripttype == Asc . c _oAscMathInterfaceScript . SubSup ) ? Asc . c _oAscMathInterfaceScript . Sup : Asc . c _oAscMathInterfaceScript . None }
2016-03-11 00:48:53 +00:00
} ) ;
arr . push ( mnu ) ;
}
2016-04-05 11:52:34 +00:00
if ( scripttype == Asc . c _oAscMathInterfaceScript . SubSup || scripttype == Asc . c _oAscMathInterfaceScript . Sup ) {
2016-03-11 00:48:53 +00:00
mnu = new Common . UI . MenuItem ( {
caption : me . txtRemSuperscript ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
2016-04-05 11:52:34 +00:00
equationProps : { type : type , callback : 'put_ScriptType' , value : ( scripttype == Asc . c _oAscMathInterfaceScript . SubSup ) ? Asc . c _oAscMathInterfaceScript . Sub : Asc . c _oAscMathInterfaceScript . None }
2016-03-11 00:48:53 +00:00
} ) ;
arr . push ( mnu ) ;
}
}
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscMathInterfaceType . Fraction :
2016-03-11 00:48:53 +00:00
var fraction = value . get _FractionType ( ) ;
2016-04-05 11:52:34 +00:00
if ( fraction == Asc . c _oAscMathInterfaceFraction . Skewed || fraction == Asc . c _oAscMathInterfaceFraction . Linear ) {
2016-03-11 00:48:53 +00:00
mnu = new Common . UI . MenuItem ( {
caption : me . txtFractionStacked ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
2016-04-05 11:52:34 +00:00
equationProps : { type : type , callback : 'put_FractionType' , value : Asc . c _oAscMathInterfaceFraction . Bar }
2016-03-11 00:48:53 +00:00
} ) ;
arr . push ( mnu ) ;
}
2016-04-05 11:52:34 +00:00
if ( fraction == Asc . c _oAscMathInterfaceFraction . Bar || fraction == Asc . c _oAscMathInterfaceFraction . Linear ) {
2016-03-11 00:48:53 +00:00
mnu = new Common . UI . MenuItem ( {
caption : me . txtFractionSkewed ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
2016-04-05 11:52:34 +00:00
equationProps : { type : type , callback : 'put_FractionType' , value : Asc . c _oAscMathInterfaceFraction . Skewed }
2016-03-11 00:48:53 +00:00
} ) ;
arr . push ( mnu ) ;
}
2016-04-05 11:52:34 +00:00
if ( fraction == Asc . c _oAscMathInterfaceFraction . Bar || fraction == Asc . c _oAscMathInterfaceFraction . Skewed ) {
2016-03-11 00:48:53 +00:00
mnu = new Common . UI . MenuItem ( {
caption : me . txtFractionLinear ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
2016-04-05 11:52:34 +00:00
equationProps : { type : type , callback : 'put_FractionType' , value : Asc . c _oAscMathInterfaceFraction . Linear }
2016-03-11 00:48:53 +00:00
} ) ;
arr . push ( mnu ) ;
}
2016-04-05 11:52:34 +00:00
if ( fraction == Asc . c _oAscMathInterfaceFraction . Bar || fraction == Asc . c _oAscMathInterfaceFraction . NoBar ) {
2016-03-11 00:48:53 +00:00
mnu = new Common . UI . MenuItem ( {
2016-04-05 11:52:34 +00:00
caption : ( fraction == Asc . c _oAscMathInterfaceFraction . Bar ) ? me . txtRemFractionBar : me . txtAddFractionBar ,
2016-03-11 00:48:53 +00:00
equation : true ,
disabled : me . _currentParaObjDisabled ,
2016-04-05 11:52:34 +00:00
equationProps : { type : type , callback : 'put_FractionType' , value : ( fraction == Asc . c _oAscMathInterfaceFraction . Bar ) ? Asc . c _oAscMathInterfaceFraction . NoBar : Asc . c _oAscMathInterfaceFraction . Bar }
2016-03-11 00:48:53 +00:00
} ) ;
arr . push ( mnu ) ;
}
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscMathInterfaceType . Limit :
2016-03-11 00:48:53 +00:00
mnu = new Common . UI . MenuItem ( {
2016-04-05 11:52:34 +00:00
caption : ( value . get _Pos ( ) == Asc . c _oAscMathInterfaceLimitPos . Top ) ? me . txtLimitUnder : me . txtLimitOver ,
2016-03-11 00:48:53 +00:00
equation : true ,
disabled : me . _currentParaObjDisabled ,
2016-04-05 11:52:34 +00:00
equationProps : { type : type , callback : 'put_Pos' , value : ( value . get _Pos ( ) == Asc . c _oAscMathInterfaceLimitPos . Top ) ? Asc . c _oAscMathInterfaceLimitPos . Bottom : Asc . c _oAscMathInterfaceLimitPos . Top }
2016-03-11 00:48:53 +00:00
} ) ;
arr . push ( mnu ) ;
mnu = new Common . UI . MenuItem ( {
caption : me . txtRemLimit ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
2016-04-05 11:52:34 +00:00
equationProps : { type : type , callback : 'put_Pos' , value : Asc . c _oAscMathInterfaceLimitPos . None }
2016-03-11 00:48:53 +00:00
} ) ;
arr . push ( mnu ) ;
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscMathInterfaceType . Matrix :
2016-03-11 00:48:53 +00:00
mnu = new Common . UI . MenuItem ( {
caption : value . get _HidePlaceholder ( ) ? me . txtShowPlaceholder : me . txtHidePlaceholder ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
equationProps : { type : type , callback : 'put_HidePlaceholder' , value : ! value . get _HidePlaceholder ( ) }
} ) ;
arr . push ( mnu ) ;
mnu = new Common . UI . MenuItem ( {
caption : me . insertText ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
menu : new Common . UI . Menu ( {
menuAlign : 'tl-tr' ,
items : [
{
caption : me . insertRowAboveText ,
equationProps : { type : type , callback : 'insert_MatrixRow' , value : true }
} ,
{
caption : me . insertRowBelowText ,
equationProps : { type : type , callback : 'insert_MatrixRow' , value : false }
} ,
{
caption : me . insertColumnLeftText ,
equationProps : { type : type , callback : 'insert_MatrixColumn' , value : true }
} ,
{
caption : me . insertColumnRightText ,
equationProps : { type : type , callback : 'insert_MatrixColumn' , value : false }
}
]
} )
} ) ;
arr . push ( mnu ) ;
mnu = new Common . UI . MenuItem ( {
caption : me . deleteText ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
menu : new Common . UI . Menu ( {
menuAlign : 'tl-tr' ,
items : [
{
caption : me . deleteRowText ,
equationProps : { type : type , callback : 'delete_MatrixRow' }
} ,
{
caption : me . deleteColumnText ,
equationProps : { type : type , callback : 'delete_MatrixColumn' }
}
]
} )
} ) ;
arr . push ( mnu ) ;
mnu = new Common . UI . MenuItem ( {
caption : me . txtMatrixAlign ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
menu : new Common . UI . Menu ( {
menuAlign : 'tl-tr' ,
items : [
{
caption : me . txtTop ,
checkable : true ,
2016-04-05 11:52:34 +00:00
checked : ( value . get _MatrixAlign ( ) == Asc . c _oAscMathInterfaceMatrixMatrixAlign . Top ) ,
equationProps : { type : type , callback : 'put_MatrixAlign' , value : Asc . c _oAscMathInterfaceMatrixMatrixAlign . Top }
2016-03-11 00:48:53 +00:00
} ,
{
caption : me . centerText ,
checkable : true ,
2016-04-05 11:52:34 +00:00
checked : ( value . get _MatrixAlign ( ) == Asc . c _oAscMathInterfaceMatrixMatrixAlign . Center ) ,
equationProps : { type : type , callback : 'put_MatrixAlign' , value : Asc . c _oAscMathInterfaceMatrixMatrixAlign . Center }
2016-03-11 00:48:53 +00:00
} ,
{
caption : me . txtBottom ,
checkable : true ,
2016-04-05 11:52:34 +00:00
checked : ( value . get _MatrixAlign ( ) == Asc . c _oAscMathInterfaceMatrixMatrixAlign . Bottom ) ,
equationProps : { type : type , callback : 'put_MatrixAlign' , value : Asc . c _oAscMathInterfaceMatrixMatrixAlign . Bottom }
2016-03-11 00:48:53 +00:00
}
]
} )
} ) ;
arr . push ( mnu ) ;
mnu = new Common . UI . MenuItem ( {
caption : me . txtColumnAlign ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
menu : new Common . UI . Menu ( {
menuAlign : 'tl-tr' ,
items : [
{
caption : me . leftText ,
checkable : true ,
2016-04-05 11:52:34 +00:00
checked : ( value . get _ColumnAlign ( ) == Asc . c _oAscMathInterfaceMatrixColumnAlign . Left ) ,
equationProps : { type : type , callback : 'put_ColumnAlign' , value : Asc . c _oAscMathInterfaceMatrixColumnAlign . Left }
2016-03-11 00:48:53 +00:00
} ,
{
caption : me . centerText ,
checkable : true ,
2016-04-05 11:52:34 +00:00
checked : ( value . get _ColumnAlign ( ) == Asc . c _oAscMathInterfaceMatrixColumnAlign . Center ) ,
equationProps : { type : type , callback : 'put_ColumnAlign' , value : Asc . c _oAscMathInterfaceMatrixColumnAlign . Center }
2016-03-11 00:48:53 +00:00
} ,
{
caption : me . rightText ,
checkable : true ,
2016-04-05 11:52:34 +00:00
checked : ( value . get _ColumnAlign ( ) == Asc . c _oAscMathInterfaceMatrixColumnAlign . Right ) ,
equationProps : { type : type , callback : 'put_ColumnAlign' , value : Asc . c _oAscMathInterfaceMatrixColumnAlign . Right }
2016-03-11 00:48:53 +00:00
}
]
} )
} ) ;
arr . push ( mnu ) ;
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscMathInterfaceType . EqArray :
2016-03-11 00:48:53 +00:00
mnu = new Common . UI . MenuItem ( {
caption : me . txtInsertEqBefore ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
equationProps : { type : type , callback : 'insert_Equation' , value : true }
} ) ;
arr . push ( mnu ) ;
mnu = new Common . UI . MenuItem ( {
caption : me . txtInsertEqAfter ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
equationProps : { type : type , callback : 'insert_Equation' , value : false }
} ) ;
arr . push ( mnu ) ;
mnu = new Common . UI . MenuItem ( {
caption : me . txtDeleteEq ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
equationProps : { type : type , callback : 'delete_Equation' }
} ) ;
arr . push ( mnu ) ;
mnu = new Common . UI . MenuItem ( {
caption : me . alignmentText ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
menu : new Common . UI . Menu ( {
menuAlign : 'tl-tr' ,
items : [
{
caption : me . txtTop ,
checkable : true ,
2016-04-05 11:52:34 +00:00
checked : ( value . get _Align ( ) == Asc . c _oAscMathInterfaceEqArrayAlign . Top ) ,
equationProps : { type : type , callback : 'put_Align' , value : Asc . c _oAscMathInterfaceEqArrayAlign . Top }
2016-03-11 00:48:53 +00:00
} ,
{
caption : me . centerText ,
checkable : true ,
2016-04-05 11:52:34 +00:00
checked : ( value . get _Align ( ) == Asc . c _oAscMathInterfaceEqArrayAlign . Center ) ,
equationProps : { type : type , callback : 'put_Align' , value : Asc . c _oAscMathInterfaceEqArrayAlign . Center }
2016-03-11 00:48:53 +00:00
} ,
{
caption : me . txtBottom ,
checkable : true ,
2016-04-05 11:52:34 +00:00
checked : ( value . get _Align ( ) == Asc . c _oAscMathInterfaceEqArrayAlign . Bottom ) ,
equationProps : { type : type , callback : 'put_Align' , value : Asc . c _oAscMathInterfaceEqArrayAlign . Bottom }
2016-03-11 00:48:53 +00:00
}
]
} )
} ) ;
arr . push ( mnu ) ;
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscMathInterfaceType . LargeOperator :
2016-03-11 00:48:53 +00:00
mnu = new Common . UI . MenuItem ( {
caption : me . txtLimitChange ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
2016-04-05 11:52:34 +00:00
equationProps : { type : type , callback : 'put_LimitLocation' , value : ( value . get _LimitLocation ( ) == Asc . c _oAscMathInterfaceNaryLimitLocation . UndOvr ) ? Asc . c _oAscMathInterfaceNaryLimitLocation . SubSup : Asc . c _oAscMathInterfaceNaryLimitLocation . UndOvr }
2016-03-11 00:48:53 +00:00
} ) ;
arr . push ( mnu ) ;
if ( value . get _HideUpper ( ) !== undefined ) {
mnu = new Common . UI . MenuItem ( {
caption : value . get _HideUpper ( ) ? me . txtShowTopLimit : me . txtHideTopLimit ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
equationProps : { type : type , callback : 'put_HideUpper' , value : ! value . get _HideUpper ( ) }
} ) ;
arr . push ( mnu ) ;
}
if ( value . get _HideLower ( ) !== undefined ) {
mnu = new Common . UI . MenuItem ( {
caption : value . get _HideLower ( ) ? me . txtShowBottomLimit : me . txtHideBottomLimit ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
equationProps : { type : type , callback : 'put_HideLower' , value : ! value . get _HideLower ( ) }
} ) ;
arr . push ( mnu ) ;
}
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscMathInterfaceType . Delimiter :
2016-03-11 00:48:53 +00:00
mnu = new Common . UI . MenuItem ( {
caption : me . txtInsertArgBefore ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
equationProps : { type : type , callback : 'insert_DelimiterArgument' , value : true }
} ) ;
arr . push ( mnu ) ;
mnu = new Common . UI . MenuItem ( {
caption : me . txtInsertArgAfter ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
equationProps : { type : type , callback : 'insert_DelimiterArgument' , value : false }
} ) ;
arr . push ( mnu ) ;
if ( value . can _DeleteArgument ( ) ) {
mnu = new Common . UI . MenuItem ( {
caption : me . txtDeleteArg ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
equationProps : { type : type , callback : 'delete_DelimiterArgument' }
} ) ;
arr . push ( mnu ) ;
}
mnu = new Common . UI . MenuItem ( {
caption : value . has _Separators ( ) ? me . txtDeleteCharsAndSeparators : me . txtDeleteChars ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
equationProps : { type : type , callback : 'remove_DelimiterCharacters' }
} ) ;
arr . push ( mnu ) ;
mnu = new Common . UI . MenuItem ( {
caption : value . get _HideOpeningBracket ( ) ? me . txtShowOpenBracket : me . txtHideOpenBracket ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
equationProps : { type : type , callback : 'put_HideOpeningBracket' , value : ! value . get _HideOpeningBracket ( ) }
} ) ;
arr . push ( mnu ) ;
mnu = new Common . UI . MenuItem ( {
caption : value . get _HideClosingBracket ( ) ? me . txtShowCloseBracket : me . txtHideCloseBracket ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
equationProps : { type : type , callback : 'put_HideClosingBracket' , value : ! value . get _HideClosingBracket ( ) }
} ) ;
arr . push ( mnu ) ;
mnu = new Common . UI . MenuItem ( {
caption : me . txtStretchBrackets ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
checkable : true ,
checked : value . get _StretchBrackets ( ) ,
equationProps : { type : type , callback : 'put_StretchBrackets' , value : ! value . get _StretchBrackets ( ) }
} ) ;
arr . push ( mnu ) ;
mnu = new Common . UI . MenuItem ( {
caption : me . txtMatchBrackets ,
equation : true ,
disabled : ( ! value . get _StretchBrackets ( ) || me . _currentParaObjDisabled ) ,
checkable : true ,
checked : value . get _StretchBrackets ( ) && value . get _MatchBrackets ( ) ,
equationProps : { type : type , callback : 'put_MatchBrackets' , value : ! value . get _MatchBrackets ( ) }
} ) ;
arr . push ( mnu ) ;
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscMathInterfaceType . GroupChar :
2016-03-11 00:48:53 +00:00
if ( value . can _ChangePos ( ) ) {
mnu = new Common . UI . MenuItem ( {
2016-04-05 11:52:34 +00:00
caption : ( value . get _Pos ( ) == Asc . c _oAscMathInterfaceGroupCharPos . Top ) ? me . txtGroupCharUnder : me . txtGroupCharOver ,
2016-03-11 00:48:53 +00:00
equation : true ,
disabled : me . _currentParaObjDisabled ,
2016-04-05 11:52:34 +00:00
equationProps : { type : type , callback : 'put_Pos' , value : ( value . get _Pos ( ) == Asc . c _oAscMathInterfaceGroupCharPos . Top ) ? Asc . c _oAscMathInterfaceGroupCharPos . Bottom : Asc . c _oAscMathInterfaceGroupCharPos . Top }
2016-03-11 00:48:53 +00:00
} ) ;
arr . push ( mnu ) ;
mnu = new Common . UI . MenuItem ( {
caption : me . txtDeleteGroupChar ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
2016-04-05 11:52:34 +00:00
equationProps : { type : type , callback : 'put_Pos' , value : Asc . c _oAscMathInterfaceGroupCharPos . None }
2016-03-11 00:48:53 +00:00
} ) ;
arr . push ( mnu ) ;
}
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscMathInterfaceType . Radical :
2016-03-11 00:48:53 +00:00
if ( value . get _HideDegree ( ) !== undefined ) {
mnu = new Common . UI . MenuItem ( {
caption : value . get _HideDegree ( ) ? me . txtShowDegree : me . txtHideDegree ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
equationProps : { type : type , callback : 'put_HideDegree' , value : ! value . get _HideDegree ( ) }
} ) ;
arr . push ( mnu ) ;
}
mnu = new Common . UI . MenuItem ( {
caption : me . txtDeleteRadical ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
equationProps : { type : type , callback : 'remove_Radical' }
} ) ;
arr . push ( mnu ) ;
break ;
}
if ( value . can _IncreaseArgumentSize ( ) ) {
mnu = new Common . UI . MenuItem ( {
caption : me . txtIncreaseArg ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
equationProps : { type : type , callback : 'increase_ArgumentSize' }
} ) ;
arr . push ( mnu ) ;
}
if ( value . can _DecreaseArgumentSize ( ) ) {
mnu = new Common . UI . MenuItem ( {
caption : me . txtDecreaseArg ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
equationProps : { type : type , callback : 'decrease_ArgumentSize' }
} ) ;
arr . push ( mnu ) ;
}
if ( value . can _InsertManualBreak ( ) ) {
mnu = new Common . UI . MenuItem ( {
caption : me . txtInsertBreak ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
equationProps : { type : type , callback : 'insert_ManualBreak' }
} ) ;
arr . push ( mnu ) ;
}
if ( value . can _DeleteManualBreak ( ) ) {
mnu = new Common . UI . MenuItem ( {
caption : me . txtDeleteBreak ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
equationProps : { type : type , callback : 'delete_ManualBreak' }
} ) ;
arr . push ( mnu ) ;
}
if ( value . can _AlignToCharacter ( ) ) {
mnu = new Common . UI . MenuItem ( {
caption : me . txtAlignToChar ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
equationProps : { type : type , callback : 'align_ToCharacter' }
} ) ;
arr . push ( mnu ) ;
}
return arr ;
} ;
this . addEquationMenu = function ( isParagraph , insertIdx ) {
if ( _ . isUndefined ( isParagraph ) ) {
isParagraph = me . textMenu . isVisible ( ) ;
}
me . clearEquationMenu ( isParagraph , insertIdx ) ;
var equationMenu = ( isParagraph ) ? me . textMenu : me . tableMenu ,
menuItems = me . initEquationMenu ( ) ;
if ( menuItems . length > 0 ) {
_ . each ( menuItems , function ( menuItem , index ) {
if ( menuItem . menu ) {
_ . each ( menuItem . menu . items , function ( item ) {
item . on ( 'click' , _ . bind ( me . equationCallback , me , item . options . equationProps ) ) ;
} ) ;
} else
menuItem . on ( 'click' , _ . bind ( me . equationCallback , me , menuItem . options . equationProps ) ) ;
equationMenu . insertItem ( insertIdx , menuItem ) ;
insertIdx ++ ;
} ) ;
}
return menuItems . length ;
} ;
this . clearEquationMenu = function ( isParagraph , insertIdx ) {
var equationMenu = ( isParagraph ) ? me . textMenu : me . tableMenu ;
for ( var i = insertIdx ; i < equationMenu . items . length ; i ++ ) {
if ( equationMenu . items [ i ] . options . equation ) {
if ( equationMenu . items [ i ] . menu ) {
_ . each ( equationMenu . items [ i ] . menu . items , function ( item ) {
item . off ( 'click' ) ;
} ) ;
} else
equationMenu . items [ i ] . off ( 'click' ) ;
equationMenu . removeItem ( equationMenu . items [ i ] ) ;
i -- ;
} else
break ;
}
} ;
this . equationCallback = function ( eqProps ) {
if ( eqProps ) {
var eqObj ;
switch ( eqProps . type ) {
2016-04-05 11:52:34 +00:00
case Asc . c _oAscMathInterfaceType . Accent :
2016-03-11 00:48:53 +00:00
eqObj = new CMathMenuAccent ( ) ;
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscMathInterfaceType . BorderBox :
2016-03-11 00:48:53 +00:00
eqObj = new CMathMenuBorderBox ( ) ;
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscMathInterfaceType . Box :
2016-03-11 00:48:53 +00:00
eqObj = new CMathMenuBox ( ) ;
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscMathInterfaceType . Bar :
2016-03-11 00:48:53 +00:00
eqObj = new CMathMenuBar ( ) ;
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscMathInterfaceType . Script :
2016-03-11 00:48:53 +00:00
eqObj = new CMathMenuScript ( ) ;
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscMathInterfaceType . Fraction :
2016-03-11 00:48:53 +00:00
eqObj = new CMathMenuFraction ( ) ;
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscMathInterfaceType . Limit :
2016-03-11 00:48:53 +00:00
eqObj = new CMathMenuLimit ( ) ;
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscMathInterfaceType . Matrix :
2016-03-11 00:48:53 +00:00
eqObj = new CMathMenuMatrix ( ) ;
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscMathInterfaceType . EqArray :
2016-03-11 00:48:53 +00:00
eqObj = new CMathMenuEqArray ( ) ;
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscMathInterfaceType . LargeOperator :
2016-03-11 00:48:53 +00:00
eqObj = new CMathMenuNary ( ) ;
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscMathInterfaceType . Delimiter :
2016-03-11 00:48:53 +00:00
eqObj = new CMathMenuDelimiter ( ) ;
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscMathInterfaceType . GroupChar :
2016-03-11 00:48:53 +00:00
eqObj = new CMathMenuGroupCharacter ( ) ;
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscMathInterfaceType . Radical :
2016-03-11 00:48:53 +00:00
eqObj = new CMathMenuRadical ( ) ;
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscMathInterfaceType . Common :
2016-03-11 00:48:53 +00:00
eqObj = new CMathMenuBase ( ) ;
break ;
}
if ( eqObj ) {
eqObj [ eqProps . callback ] ( eqProps . value ) ;
me . api . asc _SetMathProps ( eqObj ) ;
}
}
me . fireEvent ( 'editcomplete' , me ) ;
} ;
this . changePosition = function ( ) {
me . _XY = [
me . cmpEl . offset ( ) . left - $ ( window ) . scrollLeft ( ) ,
me . cmpEl . offset ( ) . top - $ ( window ) . scrollTop ( )
] ;
me . _Height = me . cmpEl . height ( ) ;
me . _BodyWidth = $ ( 'body' ) . width ( ) ;
onMouseMoveStart ( ) ;
} ;
this . hideTips = function ( ) {
/** coauthoring begin **/
if ( typeof userTooltip == 'object' ) {
userTooltip . hide ( ) ;
userTooltip = true ;
}
_ . each ( me . usertips , function ( item ) {
item . remove ( ) ;
} ) ;
me . usertips = [ ] ;
me . usertipcount = 0 ;
/** coauthoring end **/
} ;
/** coauthoring begin **/
var keymap = { } ;
var hkComments = 'alt+h' ;
keymap [ hkComments ] = function ( ) {
if ( me . api . can _AddQuotedComment ( ) !== false ) {
me . addComment ( ) ;
}
} ;
Common . util . Shortcuts . delegateShortcuts ( { shortcuts : keymap } ) ;
/** coauthoring end **/
this . setApi = function ( o ) {
this . api = o ;
if ( this . api ) {
this . api . asc _registerCallback ( 'asc_onContextMenu' , _ . bind ( onContextMenu , this ) ) ;
this . api . asc _registerCallback ( 'asc_onMouseMoveStart' , _ . bind ( onMouseMoveStart , this ) ) ;
this . api . asc _registerCallback ( 'asc_onMouseMoveEnd' , _ . bind ( onMouseMoveEnd , this ) ) ;
//hyperlink
this . api . asc _registerCallback ( 'asc_onHyperlinkClick' , _ . bind ( onHyperlinkClick , this ) ) ;
this . api . asc _registerCallback ( 'asc_onMouseMove' , _ . bind ( onMouseMove , this ) ) ;
if ( this . mode . isEdit === true ) {
this . api . asc _registerCallback ( 'asc_onImgWrapStyleChanged' , _ . bind ( this . onImgWrapStyleChanged , this ) ) ;
this . api . asc _registerCallback ( 'asc_onDialogAddHyperlink' , onDialogAddHyperlink ) ;
this . api . asc _registerCallback ( 'asc_doubleClickOnChart' , onDoubleClickOnChart ) ;
this . api . asc _registerCallback ( 'asc_onSpellCheckVariantsFound' , _ . bind ( onSpellCheckVariantsFound , this ) ) ;
2018-02-06 14:03:04 +00:00
this . api . asc _registerCallback ( 'asc_onRulerDblClick' , _ . bind ( this . onRulerDblClick , this ) ) ;
2019-04-09 10:41:08 +00:00
this . api . asc _registerCallback ( 'asc_ChangeCropState' , _ . bind ( this . onChangeCropState , this ) ) ;
2016-03-11 00:48:53 +00:00
}
this . api . asc _registerCallback ( 'asc_onCoAuthoringDisconnect' , _ . bind ( onCoAuthoringDisconnect , this ) ) ;
Common . NotificationCenter . on ( 'api:disconnect' , _ . bind ( onCoAuthoringDisconnect , this ) ) ;
this . api . asc _registerCallback ( 'asc_onTextLanguage' , _ . bind ( onTextLanguage , this ) ) ;
this . api . asc _registerCallback ( 'asc_onParaStyleName' , _ . bind ( this . onApiParagraphStyleChange , this ) ) ;
this . api . asc _registerCallback ( 'asc_onShowForeignCursorLabel' , _ . bind ( onShowForeignCursorLabel , this ) ) ;
this . api . asc _registerCallback ( 'asc_onHideForeignCursorLabel' , _ . bind ( onHideForeignCursorLabel , this ) ) ;
this . api . asc _registerCallback ( 'asc_onFocusObject' , _ . bind ( onFocusObject , this ) ) ;
2017-05-12 08:52:19 +00:00
this . api . asc _registerCallback ( 'asc_onShowSpecialPasteOptions' , _ . bind ( onShowSpecialPasteOptions , this ) ) ;
this . api . asc _registerCallback ( 'asc_onHideSpecialPasteOptions' , _ . bind ( onHideSpecialPasteOptions , this ) ) ;
2019-12-05 10:48:48 +00:00
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 ) ) ;
}
2016-03-11 00:48:53 +00:00
}
return this ;
} ;
this . mode = { } ;
this . setMode = function ( m ) {
this . mode = m ;
/** coauthoring begin **/
2017-06-14 11:53:29 +00:00
! ( this . mode . canCoAuthoring && this . mode . canComments )
2016-03-11 00:48:53 +00:00
? Common . util . Shortcuts . suspendEvents ( hkComments )
: Common . util . Shortcuts . resumeEvents ( hkComments ) ;
/** coauthoring end **/
this . editorConfig = { user : m . user } ;
} ;
me . on ( 'render:after' , onAfterRender , me ) ;
} ,
render : function ( ) {
this . fireEvent ( 'render:before' , this ) ;
this . cmpEl = $ ( this . el ) ;
this . fireEvent ( 'render:after' , this ) ;
return this ;
} ,
onImgWrapStyleChanged : function ( type ) {
switch ( type ) {
2016-04-05 11:52:34 +00:00
case Asc . c _oAscWrapStyle2 . Inline :
2016-03-11 00:48:53 +00:00
this . menuImageWrap . menu . items [ 0 ] . setChecked ( true ) ;
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscWrapStyle2 . Square :
2016-03-11 00:48:53 +00:00
this . menuImageWrap . menu . items [ 1 ] . setChecked ( true ) ;
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscWrapStyle2 . Tight :
2016-03-11 00:48:53 +00:00
this . menuImageWrap . menu . items [ 2 ] . setChecked ( true ) ;
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscWrapStyle2 . Through :
2016-03-11 00:48:53 +00:00
this . menuImageWrap . menu . items [ 3 ] . setChecked ( true ) ;
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscWrapStyle2 . TopAndBottom :
2016-03-11 00:48:53 +00:00
this . menuImageWrap . menu . items [ 4 ] . setChecked ( true ) ;
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscWrapStyle2 . Behind :
2016-03-11 00:48:53 +00:00
this . menuImageWrap . menu . items [ 6 ] . setChecked ( true ) ;
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscWrapStyle2 . InFront :
2016-03-11 00:48:53 +00:00
this . menuImageWrap . menu . items [ 5 ] . setChecked ( true ) ;
break ;
}
} ,
2019-04-09 10:41:08 +00:00
onChangeCropState : function ( state ) {
this . menuImgCrop . menu . items [ 0 ] . setChecked ( state , true ) ;
} ,
2016-03-11 00:48:53 +00:00
onApiParagraphStyleChange : function ( name ) {
window . currentStyleName = name ;
} ,
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 ( ) ;
2016-04-05 11:52:34 +00:00
if ( Asc . c _oAscTypeSelectElement . Paragraph == elType ) {
2016-03-11 00:48:53 +00:00
win = new DE . Views . ParagraphSettingsAdvanced ( {
tableStylerRows : 2 ,
tableStylerColumns : 1 ,
paragraphProps : elValue ,
borderProps : me . borderAdvancedProps ,
isChart : ( item . isChart === true ) ,
api : me . api ,
handler : function ( result , value ) {
if ( result == 'ok' ) {
if ( me . api ) {
me . borderAdvancedProps = value . borderProps ;
me . api . paraApply ( value . paragraphProps ) ;
}
}
me . fireEvent ( 'editcomplete' , me ) ;
}
} ) ;
break ;
}
}
}
}
if ( win ) {
win . show ( ) ;
2018-02-06 14:03:04 +00:00
return win ;
2016-03-11 00:48:53 +00:00
}
} ,
advancedFrameClick : 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 ( ) ; // заменить на свойства рамки
2016-04-05 11:52:34 +00:00
if ( Asc . c _oAscTypeSelectElement . Paragraph == elType ) {
2016-03-11 00:48:53 +00:00
win = new DE . Views . DropcapSettingsAdvanced ( {
tableStylerRows : 2 ,
tableStylerColumns : 1 ,
paragraphProps : elValue ,
borderProps : me . borderAdvancedProps ,
api : me . api ,
isFrame : true ,
handler : function ( result , value ) {
if ( result == 'ok' ) {
me . borderAdvancedProps = value . borderProps ;
if ( value . paragraphProps && value . paragraphProps . get _Wrap ( ) === c _oAscFrameWrap . None ) {
me . api . removeDropcap ( false ) ;
} else
me . api . put _FramePr ( value . paragraphProps ) ;
}
me . fireEvent ( 'editcomplete' , me ) ;
}
} ) ;
break ;
}
}
}
}
if ( win ) {
win . show ( ) ;
}
} ,
2018-02-06 14:03:04 +00:00
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 ) ;
}
}
me . fireEvent ( 'editcomplete' , me ) ;
}
} ) ;
break ;
}
}
}
}
if ( win ) {
win . show ( ) ;
return win ;
}
} ,
onRulerDblClick : function ( type ) {
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 : 3 ) ;
} else if ( type == 'margins' ) {
win = new DE . Views . PageMarginsDialog ( {
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 ) ;
me . fireEvent ( 'editcomplete' , me ) ;
}
}
} ) ;
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 ( ) ) ;
me . fireEvent ( 'editcomplete' , me ) ;
}
}
} ) ;
win . show ( ) ;
win . setSettings ( me . api . asc _GetColumnsProps ( ) ) ;
}
} ,
2016-03-11 00:48:53 +00:00
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 ( ) ) ;
}
me . fireEvent ( 'editcomplete' , me ) ;
}
} ) ;
win . show ( ) ;
win . setSettings ( item . hyperProps . value ) ;
}
} ,
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 ( ) ) ;
}
} ,
/** coauthoring begin **/
addComment : function ( item , e , eOpt ) {
2017-06-14 11:53:29 +00:00
if ( this . api && this . mode . canCoAuthoring && this . mode . canComments ) {
2016-03-11 00:48:53 +00:00
this . suppressEditComplete = true ;
var controller = DE . getController ( 'Common.Controllers.Comments' ) ;
if ( controller ) {
controller . addDummyComment ( ) ;
}
}
} ,
/** coauthoring end **/
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 ( ) ) ;
}
me . fireEvent ( 'editcomplete' , me ) ;
}
} ) ;
win . show ( ) ;
win . setSettings ( item . hyperProps . value ) ;
Common . component . Analytics . trackEvent ( 'DocumentHolder' , 'Add Hyperlink' ) ;
}
} ,
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 ) ) ;
}
}
} ,
onCutCopyPaste : function ( item , e ) {
var me = this ;
if ( me . api ) {
2016-07-26 14:46:42 +00:00
var res = ( item . value == 'cut' ) ? me . api . Cut ( ) : ( ( item . value == 'copy' ) ? me . api . Copy ( ) : me . api . Paste ( ) ) ;
if ( ! res ) {
2017-04-19 11:22:31 +00:00
if ( ! Common . localStorage . getBool ( "de-hide-copywarning" ) ) {
2016-03-11 00:48:53 +00:00
( new Common . Views . CopyWarningDialog ( {
handler : function ( dontshow ) {
if ( dontshow ) Common . localStorage . setItem ( "de-hide-copywarning" , 1 ) ;
me . fireEvent ( 'editcomplete' , me ) ;
}
} ) ) . show ( ) ;
}
2016-07-26 14:46:42 +00:00
}
2016-03-11 00:48:53 +00:00
}
2016-07-26 14:46:42 +00:00
me . fireEvent ( 'editcomplete' , me ) ;
2016-03-11 00:48:53 +00:00
} ,
2019-08-07 09:16:40 +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 . isSafari || Common . Utils . isOpera ) ; // if isChrome or isSafari or isOpera == true use asc_onPrintUrl event
opts . asc _setAdvancedOptions ( printopt ) ;
this . api . asc _Print ( opts ) ;
this . fireEvent ( 'editcomplete' , this ) ;
Common . component . Analytics . trackEvent ( 'DocumentHolder' , 'Print Selection' ) ;
}
} ,
2017-12-13 13:52:14 +00:00
onControlsSelect : function ( item , e ) {
2018-02-21 13:05:03 +00:00
var me = this ;
2017-12-13 13:52:14 +00:00
var props = this . api . asc _GetContentControlProperties ( ) ;
if ( props ) {
if ( item . value == 'settings' ) {
( new DE . Views . ControlSettingsDialog ( {
props : props ,
2018-08-28 14:37:45 +00:00
api : me . api ,
2017-12-13 13:52:14 +00:00
handler : function ( result , value ) {
if ( result == 'ok' ) {
me . api . asc _SetContentControlProperties ( value , props . get _InternalId ( ) ) ;
}
2018-02-06 14:03:04 +00:00
me . fireEvent ( 'editcomplete' , me ) ;
2017-12-13 13:52:14 +00:00
}
} ) ) . show ( ) ;
} else if ( item . value == 'remove' ) {
this . api . asc _RemoveContentControlWrapper ( props . get _InternalId ( ) ) ;
}
}
2018-02-06 14:03:04 +00:00
me . fireEvent ( 'editcomplete' , me ) ;
2017-12-13 13:52:14 +00:00
} ,
2019-09-21 08:52:21 +00:00
onInsertCaption : function ( ) {
var me = this ;
( new DE . Views . CaptionDialog ( {
isObject : true ,
handler : function ( result , settings ) {
if ( result == 'ok' ) {
me . api . asc _AddObjectCaption ( settings ) ;
}
me . fireEvent ( 'editcomplete' , me ) ;
}
} ) ) . show ( ) ;
} ,
2018-07-20 09:00:30 +00:00
onContinueNumbering : function ( item , e ) {
this . api . asc _ContinueNumbering ( ) ;
this . fireEvent ( 'editcomplete' , this ) ;
} ,
onStartNumbering : function ( startfrom , item , e ) {
if ( startfrom == 1 )
2018-08-14 08:07:43 +00:00
this . api . asc _RestartNumbering ( item . value . start ) ;
2018-07-20 09:00:30 +00:00
else {
var me = this ;
( new DE . Views . NumberingValueDialog ( {
title : me . textNumberingValue ,
2018-07-20 12:15:28 +00:00
props : item . value ,
2018-07-20 09:00:30 +00:00
handler : function ( result , value ) {
if ( result == 'ok' )
me . api . asc _RestartNumbering ( value ) ;
me . fireEvent ( 'editcomplete' , me ) ;
}
} ) ) . show ( ) ;
}
this . fireEvent ( 'editcomplete' , this ) ;
} ,
2019-09-05 11:38:34 +00:00
onCellsRemove : function ( ) {
var me = this ;
( new DE . Views . CellsRemoveDialog ( {
handler : function ( result , value ) {
if ( result == 'ok' ) {
if ( value == 'row' )
me . api . remRow ( ) ;
else if ( value == 'col' )
me . api . remColumn ( ) ;
else
me . api . asc _RemoveTableCells ( ) ;
}
me . fireEvent ( 'editcomplete' , me ) ;
}
} ) ) . show ( ) ;
this . fireEvent ( 'editcomplete' , this ) ;
} ,
2019-09-06 11:37:43 +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 ) ;
}
}
me . fireEvent ( 'editcomplete' , me ) ;
}
} ) ) . show ( ) ;
this . fireEvent ( 'editcomplete' , this ) ;
} ,
2017-06-06 08:04:04 +00:00
createDelayedElementsViewer : function ( ) {
var me = this ;
var menuViewCopy = new Common . UI . MenuItem ( {
caption : me . textCopy ,
value : 'copy'
} ) . on ( 'click' , _ . bind ( me . onCutCopyPaste , me ) ) ;
var menuViewUndo = new Common . UI . MenuItem ( {
caption : me . textUndo
} ) . on ( 'click' , function ( ) {
me . api . Undo ( ) ;
} ) ;
var menuViewCopySeparator = new Common . UI . MenuItem ( {
caption : '--'
} ) ;
var menuViewAddComment = new Common . UI . MenuItem ( {
caption : me . addCommentText
} ) . on ( 'click' , _ . bind ( me . addComment , me ) ) ;
2017-11-22 08:41:47 +00:00
var menuSignatureViewSign = new Common . UI . MenuItem ( { caption : this . strSign , value : 0 } ) . on ( 'click' , _ . bind ( me . onSignatureClick , me ) ) ;
var menuSignatureDetails = new Common . UI . MenuItem ( { caption : this . strDetails , value : 1 } ) . on ( 'click' , _ . bind ( me . onSignatureClick , me ) ) ;
var menuSignatureViewSetup = new Common . UI . MenuItem ( { caption : this . strSetup , value : 2 } ) . on ( 'click' , _ . bind ( me . onSignatureClick , me ) ) ;
var menuSignatureRemove = new Common . UI . MenuItem ( { caption : this . strDelete , value : 3 } ) . on ( 'click' , _ . bind ( me . onSignatureClick , me ) ) ;
var menuViewSignSeparator = new Common . UI . MenuItem ( { caption : '--' } ) ;
2017-06-06 08:04:04 +00:00
this . viewModeMenu = new Common . UI . Menu ( {
initMenu : function ( value ) {
2017-11-22 08:41:47 +00:00
var isInChart = ( value . imgProps && value . imgProps . value && ! _ . isNull ( value . imgProps . value . get _ChartProperties ( ) ) ) ,
2019-11-01 08:36:32 +00:00
isInShape = ( value . imgProps && value . imgProps . value && ! _ . isNull ( value . imgProps . value . get _ShapeProperties ( ) ) ) ,
2018-08-01 16:08:24 +00:00
signGuid = ( value . imgProps && value . imgProps . value && me . mode . isSignatureSupport ) ? value . imgProps . value . asc _getSignatureId ( ) : undefined ,
2017-11-23 11:29:41 +00:00
signProps = ( signGuid ) ? me . api . asc _getSignatureSetup ( signGuid ) : null ,
2017-11-22 08:41:47 +00:00
isInSign = ! ! signProps && me . _canProtect ,
canComment = ! isInChart && me . api . can _AddQuotedComment ( ) !== false && me . mode . canCoAuthoring && me . mode . canComments && ! me . _isDisabled ;
2019-11-01 08:36:32 +00:00
if ( me . mode . compatibleFeatures )
canComment = canComment && ! isInShape ;
2017-06-06 08:04:04 +00:00
2017-08-23 15:06:55 +00:00
menuViewUndo . setVisible ( me . mode . canCoAuthoring && me . mode . canComments && ! me . _isDisabled ) ;
menuViewUndo . setDisabled ( ! me . api . asc _getCanUndo ( ) && ! me . _isDisabled ) ;
2017-11-22 08:41:47 +00:00
menuViewCopySeparator . setVisible ( isInSign ) ;
var isRequested = ( signProps ) ? signProps . asc _getRequested ( ) : false ;
menuSignatureViewSign . setVisible ( isInSign && isRequested ) ;
menuSignatureDetails . setVisible ( isInSign && ! isRequested ) ;
menuSignatureViewSetup . setVisible ( isInSign ) ;
menuSignatureRemove . setVisible ( isInSign && ! isRequested ) ;
menuViewSignSeparator . setVisible ( canComment ) ;
if ( isInSign ) {
menuSignatureViewSign . cmpEl . attr ( 'data-value' , signGuid ) ; // sign
2017-11-23 11:29:41 +00:00
menuSignatureDetails . cmpEl . attr ( 'data-value' , signProps . asc _getId ( ) ) ; // view certificate
2017-11-22 08:41:47 +00:00
menuSignatureViewSetup . cmpEl . attr ( 'data-value' , signGuid ) ; // view signature settings
menuSignatureRemove . cmpEl . attr ( 'data-value' , signGuid ) ;
}
menuViewAddComment . setVisible ( canComment ) ;
2017-06-06 08:04:04 +00:00
menuViewAddComment . setDisabled ( value . paraProps && value . paraProps . locked === true ) ;
var cancopy = me . api && me . api . can _CopyCut ( ) ;
menuViewCopy . setDisabled ( ! cancopy ) ;
} ,
items : [
menuViewCopy ,
menuViewUndo ,
menuViewCopySeparator ,
2017-11-22 08:41:47 +00:00
menuSignatureViewSign ,
menuSignatureDetails ,
menuSignatureViewSetup ,
menuSignatureRemove ,
menuViewSignSeparator ,
2017-06-06 08:04:04 +00:00
menuViewAddComment
]
} ) . on ( 'hide:after' , function ( menu , e , isFromInputControl ) {
if ( me . suppressEditComplete ) {
me . suppressEditComplete = false ;
return ;
}
if ( ! isFromInputControl ) me . fireEvent ( 'editcomplete' , me ) ;
me . currentMenu = null ;
} ) ;
} ,
2016-03-11 00:48:53 +00:00
createDelayedElements : function ( ) {
var me = this ;
2019-09-21 08:52:21 +00:00
var menuInsertCaption = new Common . UI . MenuItem ( {
caption : me . txtInsertCaption
} ) . on ( 'click' , _ . bind ( me . onInsertCaption , me ) ) ;
var menuInsertCaptionSeparator = new Common . UI . MenuItem ( { caption : '--' } ) ;
var menuEquationInsertCaption = new Common . UI . MenuItem ( {
caption : me . txtInsertCaption
} ) . on ( 'click' , _ . bind ( me . onInsertCaption , me ) ) ;
var menuEquationInsertCaptionSeparator = new Common . UI . MenuItem ( { caption : '--' } ) ;
2016-03-11 00:48:53 +00:00
var menuImageAlign = new Common . UI . MenuItem ( {
caption : me . textAlign ,
menu : ( function ( ) {
function onItemClick ( item , e ) {
if ( me . api ) {
2019-02-12 12:31:27 +00:00
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' ) ;
2016-03-11 00:48:53 +00:00
}
}
me . fireEvent ( 'editcomplete' , me ) ;
}
return new Common . UI . Menu ( {
cls : 'ppm-toolbar' ,
menuAlign : 'tl-tr' ,
items : [
new Common . UI . MenuItem ( {
caption : me . textShapeAlignLeft ,
2019-11-21 07:58:05 +00:00
iconCls : 'menu__icon shape-align-left' ,
2019-02-13 11:20:54 +00:00
value : Asc . c _oAscAlignShapeType . ALIGN _LEFT
2016-03-11 00:48:53 +00:00
} ) . on ( 'click' , onItemClick ) ,
new Common . UI . MenuItem ( {
caption : me . textShapeAlignCenter ,
2019-11-21 07:58:05 +00:00
iconCls : 'menu__icon shape-align-center' ,
2019-02-13 11:20:54 +00:00
value : Asc . c _oAscAlignShapeType . ALIGN _CENTER
2016-03-11 00:48:53 +00:00
} ) . on ( 'click' , onItemClick ) ,
new Common . UI . MenuItem ( {
caption : me . textShapeAlignRight ,
2019-11-21 07:58:05 +00:00
iconCls : 'menu__icon shape-align-right' ,
2019-02-13 11:20:54 +00:00
value : Asc . c _oAscAlignShapeType . ALIGN _RIGHT
2016-03-11 00:48:53 +00:00
} ) . on ( 'click' , onItemClick ) ,
new Common . UI . MenuItem ( {
caption : me . textShapeAlignTop ,
2019-11-21 07:58:05 +00:00
iconCls : 'menu__icon shape-align-top' ,
2019-02-13 11:20:54 +00:00
value : Asc . c _oAscAlignShapeType . ALIGN _TOP
2016-03-11 00:48:53 +00:00
} ) . on ( 'click' , onItemClick ) ,
new Common . UI . MenuItem ( {
caption : me . textShapeAlignMiddle ,
2019-11-21 07:58:05 +00:00
iconCls : 'menu__icon shape-align-middle' ,
2019-02-13 11:20:54 +00:00
value : Asc . c _oAscAlignShapeType . ALIGN _MIDDLE
2016-03-11 00:48:53 +00:00
} ) . on ( 'click' , onItemClick ) ,
new Common . UI . MenuItem ( {
caption : me . textShapeAlignBottom ,
2019-11-21 07:58:05 +00:00
iconCls : 'menu__icon shape-align-bottom' ,
2019-02-13 11:20:54 +00:00
value : Asc . c _oAscAlignShapeType . ALIGN _BOTTOM
2019-02-12 12:31:27 +00:00
} ) . on ( 'click' , onItemClick ) ,
{ caption : '--' } ,
new Common . UI . MenuItem ( {
caption : me . txtDistribHor ,
2019-11-21 07:58:05 +00:00
iconCls : 'menu__icon shape-distribute-hor' ,
2019-02-12 12:31:27 +00:00
value : 6
} ) . on ( 'click' , onItemClick ) ,
new Common . UI . MenuItem ( {
caption : me . txtDistribVert ,
2019-11-21 07:58:05 +00:00
iconCls : 'menu__icon shape-distribute-vert' ,
2019-02-12 12:31:27 +00:00
value : 7
2016-03-11 00:48:53 +00:00
} ) . on ( 'click' , onItemClick )
]
} )
} ) ( )
} ) ;
var mnuGroup = new Common . UI . MenuItem ( {
caption : this . txtGroup ,
2019-11-21 07:58:05 +00:00
iconCls : 'menu__icon shape-group'
2016-03-11 00:48:53 +00:00
} ) . on ( 'click' , function ( item , e ) {
if ( me . api ) {
2016-04-18 12:21:15 +00:00
var properties = new Asc . asc _CImgProperty ( ) ;
2016-03-11 00:48:53 +00:00
properties . put _Group ( 1 ) ;
me . api . ImgApply ( properties ) ;
}
me . fireEvent ( 'editcomplete' , this ) ;
} ) ;
var mnuUnGroup = new Common . UI . MenuItem ( {
2019-11-21 07:58:05 +00:00
iconCls : 'menu__icon shape-ungroup' ,
2016-03-11 00:48:53 +00:00
caption : this . txtUngroup
} ) . on ( 'click' , function ( item , e ) {
if ( me . api ) {
2016-04-18 12:21:15 +00:00
var properties = new Asc . asc _CImgProperty ( ) ;
2016-03-11 00:48:53 +00:00
properties . put _Group ( - 1 ) ;
me . api . ImgApply ( properties ) ;
}
me . fireEvent ( 'editcomplete' , this ) ;
} ) ;
var menuImageArrange = new Common . UI . MenuItem ( {
caption : me . textArrange ,
menu : ( function ( ) {
function onItemClick ( item , e ) {
if ( me . api ) {
2016-04-18 12:21:15 +00:00
var properties = new Asc . asc _CImgProperty ( ) ;
2016-03-11 00:48:53 +00:00
properties . put _ChangeLevel ( item . options . valign ) ;
me . api . ImgApply ( properties ) ;
}
me . fireEvent ( 'editcomplete' , me ) ;
}
return new Common . UI . Menu ( {
cls : 'ppm-toolbar' ,
menuAlign : 'tl-tr' ,
items : [
new Common . UI . MenuItem ( {
caption : me . textArrangeFront ,
2019-11-21 07:58:05 +00:00
iconCls : 'menu__icon arrange-front' ,
2016-04-05 11:52:34 +00:00
valign : Asc . c _oAscChangeLevel . BringToFront
2016-03-11 00:48:53 +00:00
} ) . on ( 'click' , onItemClick ) ,
new Common . UI . MenuItem ( {
caption : me . textArrangeBack ,
2019-11-21 07:58:05 +00:00
iconCls : 'menu__icon arrange-back' ,
2016-04-05 11:52:34 +00:00
valign : Asc . c _oAscChangeLevel . SendToBack
2016-03-11 00:48:53 +00:00
} ) . on ( 'click' , onItemClick ) ,
new Common . UI . MenuItem ( {
caption : me . textArrangeForward ,
2019-11-21 07:58:05 +00:00
iconCls : 'menu__icon arrange-forward' ,
2016-04-05 11:52:34 +00:00
valign : Asc . c _oAscChangeLevel . BringForward
2016-03-11 00:48:53 +00:00
} ) . on ( 'click' , onItemClick ) ,
new Common . UI . MenuItem ( {
caption : me . textArrangeBackward ,
2019-11-21 07:58:05 +00:00
iconCls : 'menu__icon arrange-backward' ,
2016-04-05 11:52:34 +00:00
valign : Asc . c _oAscChangeLevel . BringBackward
2016-03-11 00:48:53 +00:00
} ) . on ( 'click' , onItemClick ) ,
{ caption : '--' } ,
mnuGroup ,
mnuUnGroup
]
} )
} ) ( )
} ) ;
var menuWrapPolygon = new Common . UI . MenuItem ( {
caption : me . textEditWrapBoundary ,
cls : 'no-icon-wrap-item'
} ) . on ( 'click' , function ( item , e ) {
if ( me . api ) {
me . api . StartChangeWrapPolygon ( ) ;
}
me . fireEvent ( 'editcomplete' , me ) ;
} ) ;
this . menuImageWrap = new Common . UI . MenuItem ( {
caption : me . textWrap ,
menu : ( function ( ) {
function onItemClick ( item , e ) {
if ( me . api ) {
2016-04-18 12:21:15 +00:00
var properties = new Asc . asc _CImgProperty ( ) ;
2016-03-11 00:48:53 +00:00
properties . put _WrappingStyle ( item . options . wrapType ) ;
2016-04-05 11:52:34 +00:00
if ( me . menuImageWrap . _originalProps . get _WrappingStyle ( ) === Asc . c _oAscWrapStyle2 . Inline && item . wrapType !== Asc . c _oAscWrapStyle2 . Inline ) {
2016-04-05 12:57:51 +00:00
properties . put _PositionH ( new Asc . CImagePositionH ( ) ) ;
2016-03-11 00:48:53 +00:00
properties . get _PositionH ( ) . put _UseAlign ( false ) ;
2016-04-05 11:52:34 +00:00
properties . get _PositionH ( ) . put _RelativeFrom ( Asc . c _oAscRelativeFromH . Column ) ;
var val = me . menuImageWrap . _originalProps . get _Value _X ( Asc . c _oAscRelativeFromH . Column ) ;
2016-03-11 00:48:53 +00:00
properties . get _PositionH ( ) . put _Value ( val ) ;
2016-04-05 12:57:51 +00:00
properties . put _PositionV ( new Asc . CImagePositionV ( ) ) ;
2016-03-11 00:48:53 +00:00
properties . get _PositionV ( ) . put _UseAlign ( false ) ;
2016-04-05 11:52:34 +00:00
properties . get _PositionV ( ) . put _RelativeFrom ( Asc . c _oAscRelativeFromV . Paragraph ) ;
val = me . menuImageWrap . _originalProps . get _Value _Y ( Asc . c _oAscRelativeFromV . Paragraph ) ;
2016-03-11 00:48:53 +00:00
properties . get _PositionV ( ) . put _Value ( val ) ;
}
me . api . ImgApply ( properties ) ;
}
me . fireEvent ( 'editcomplete' , me ) ;
}
return new Common . UI . Menu ( {
cls : 'ppm-toolbar' ,
menuAlign : 'tl-tr' ,
items : [
new Common . UI . MenuItem ( {
caption : me . txtInline ,
2019-11-21 07:58:05 +00:00
iconCls : 'menu__icon wrap-inline' ,
2016-03-11 00:48:53 +00:00
toggleGroup : 'popuppicturewrapping' ,
2016-04-05 11:52:34 +00:00
wrapType : Asc . c _oAscWrapStyle2 . Inline ,
2019-11-21 07:58:05 +00:00
checkmark : false ,
2016-03-11 00:48:53 +00:00
checkable : true
} ) . on ( 'click' , onItemClick ) ,
new Common . UI . MenuItem ( {
caption : me . txtSquare ,
2019-11-21 07:58:05 +00:00
iconCls : 'menu__icon wrap-square' ,
2016-03-11 00:48:53 +00:00
toggleGroup : 'popuppicturewrapping' ,
2016-04-05 11:52:34 +00:00
wrapType : Asc . c _oAscWrapStyle2 . Square ,
2019-11-21 07:58:05 +00:00
checkmark : false ,
2016-03-11 00:48:53 +00:00
checkable : true
} ) . on ( 'click' , onItemClick ) ,
new Common . UI . MenuItem ( {
caption : me . txtTight ,
2019-11-21 07:58:05 +00:00
iconCls : 'menu__icon wrap-tight' ,
2016-03-11 00:48:53 +00:00
toggleGroup : 'popuppicturewrapping' ,
2016-04-05 11:52:34 +00:00
wrapType : Asc . c _oAscWrapStyle2 . Tight ,
2019-11-21 07:58:05 +00:00
checkmark : false ,
2016-03-11 00:48:53 +00:00
checkable : true
} ) . on ( 'click' , onItemClick ) ,
new Common . UI . MenuItem ( {
caption : me . txtThrough ,
2019-11-21 07:58:05 +00:00
iconCls : 'menu__icon wrap-through' ,
2016-03-11 00:48:53 +00:00
toggleGroup : 'popuppicturewrapping' ,
2016-04-05 11:52:34 +00:00
wrapType : Asc . c _oAscWrapStyle2 . Through ,
2019-11-21 07:58:05 +00:00
checkmark : false ,
2016-03-11 00:48:53 +00:00
checkable : true
} ) . on ( 'click' , onItemClick ) ,
new Common . UI . MenuItem ( {
caption : me . txtTopAndBottom ,
2019-11-21 07:58:05 +00:00
iconCls : 'menu__icon wrap-topandbottom' ,
2016-03-11 00:48:53 +00:00
toggleGroup : 'popuppicturewrapping' ,
2016-04-05 11:52:34 +00:00
wrapType : Asc . c _oAscWrapStyle2 . TopAndBottom ,
2019-11-21 07:58:05 +00:00
checkmark : false ,
2016-03-11 00:48:53 +00:00
checkable : true
} ) . on ( 'click' , onItemClick ) ,
new Common . UI . MenuItem ( {
caption : me . txtInFront ,
2019-11-21 07:58:05 +00:00
iconCls : 'menu__icon wrap-infront' ,
2016-03-11 00:48:53 +00:00
toggleGroup : 'popuppicturewrapping' ,
2016-04-05 11:52:34 +00:00
wrapType : Asc . c _oAscWrapStyle2 . InFront ,
2019-11-21 07:58:05 +00:00
checkmark : false ,
2016-03-11 00:48:53 +00:00
checkable : true
} ) . on ( 'click' , onItemClick ) ,
new Common . UI . MenuItem ( {
caption : me . txtBehind ,
2019-11-21 07:58:05 +00:00
iconCls : 'menu__icon wrap-behind' ,
2016-03-11 00:48:53 +00:00
toggleGroup : 'popuppicturewrapping' ,
2016-04-05 11:52:34 +00:00
wrapType : Asc . c _oAscWrapStyle2 . Behind ,
2019-11-21 07:58:05 +00:00
checkmark : false ,
2016-03-11 00:48:53 +00:00
checkable : true
} ) . on ( 'click' , onItemClick ) ,
{ caption : '--' } ,
menuWrapPolygon
]
} )
} ) ( )
} ) ;
var menuImageAdvanced = new Common . UI . MenuItem ( {
caption : me . advancedText
} ) . on ( 'click' , function ( item , e ) {
var elType , elValue ;
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 ( ) ;
2016-04-05 11:52:34 +00:00
if ( Asc . c _oAscTypeSelectElement . Image == elType ) {
2016-03-11 00:48:53 +00:00
var imgsizeOriginal ;
if ( ! elValue . get _ChartProperties ( ) && ! elValue . get _ShapeProperties ( ) && ! me . menuOriginalSize . isDisabled ( ) && me . 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 ,
2016-03-17 13:31:57 +00:00
sectionProps : me . api . asc _GetSectionProps ( ) ,
2016-03-11 00:48:53 +00:00
handler : function ( result , value ) {
if ( result == 'ok' ) {
if ( me . api ) {
me . api . ImgApply ( value . imageProps ) ;
}
}
me . fireEvent ( 'editcomplete' , me ) ;
}
} ) ;
win . show ( ) ;
win . btnOriginalSize . setVisible ( me . menuOriginalSize . isVisible ( ) ) ;
break ;
}
}
}
}
} ) ;
var menuChartEdit = new Common . UI . MenuItem ( {
caption : me . editChartText
} ) . on ( 'click' , _ . bind ( me . editChartClick , me ) ) ;
this . menuOriginalSize = new Common . UI . MenuItem ( {
caption : me . originalSizeText
} ) . on ( 'click' , function ( item , e ) {
if ( me . api ) {
var originalImageSize = me . api . get _OriginalSizeImage ( ) ;
2016-04-18 12:21:15 +00:00
var properties = new Asc . asc _CImgProperty ( ) ;
2016-03-11 00:48:53 +00:00
properties . put _Width ( originalImageSize . get _ImageWidth ( ) ) ;
properties . put _Height ( originalImageSize . get _ImageHeight ( ) ) ;
2019-04-11 10:09:28 +00:00
properties . put _ResetCrop ( true ) ;
2016-03-11 00:48:53 +00:00
me . api . ImgApply ( properties ) ;
me . fireEvent ( 'editcomplete' , this ) ;
}
} ) ;
2018-04-11 13:46:44 +00:00
var menuImgReplace = new Common . UI . MenuItem ( {
caption : me . textReplace ,
menu : new Common . UI . Menu ( {
menuAlign : 'tl-tr' ,
items : [
new Common . UI . MenuItem ( {
caption : this . textFromFile
} ) . on ( 'click' , function ( item ) {
setTimeout ( function ( ) {
if ( me . api ) me . api . ChangeImageFromFile ( ) ;
me . fireEvent ( 'editcomplete' , me ) ;
} , 10 ) ;
} ) ,
new Common . UI . MenuItem ( {
caption : this . textFromUrl
} ) . on ( 'click' , function ( item ) {
( 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 ) ;
}
}
}
me . fireEvent ( 'editcomplete' , me ) ;
}
} ) ) . show ( ) ;
} )
]
} )
} ) ;
2016-03-11 00:48:53 +00:00
var menuImgCopy = new Common . UI . MenuItem ( {
caption : me . textCopy ,
value : 'copy'
} ) . on ( 'click' , _ . bind ( me . onCutCopyPaste , me ) ) ;
var menuImgPaste = new Common . UI . MenuItem ( {
caption : me . textPaste ,
value : 'paste'
} ) . on ( 'click' , _ . bind ( me . onCutCopyPaste , me ) ) ;
var menuImgCut = new Common . UI . MenuItem ( {
caption : me . textCut ,
value : 'cut'
} ) . on ( 'click' , _ . bind ( me . onCutCopyPaste , me ) ) ;
2019-08-07 09:16:40 +00:00
var menuImgPrint = new Common . UI . MenuItem ( {
caption : me . txtPrintSelection
} ) . on ( 'click' , _ . bind ( me . onPrintSelection , me ) ) ;
2017-11-22 08:41:47 +00:00
var menuSignatureEditSign = new Common . UI . MenuItem ( { caption : this . strSign , value : 0 } ) . on ( 'click' , _ . bind ( me . onSignatureClick , me ) ) ;
var menuSignatureEditSetup = new Common . UI . MenuItem ( { caption : this . strSetup , value : 2 } ) . on ( 'click' , _ . bind ( me . onSignatureClick , me ) ) ;
var menuEditSignSeparator = new Common . UI . MenuItem ( { caption : '--' } ) ;
2019-02-26 15:59:16 +00:00
var menuImgRotate = new Common . UI . MenuItem ( {
caption : me . textRotate ,
menu : new Common . UI . Menu ( {
menuAlign : 'tl-tr' ,
items : [
new Common . UI . MenuItem ( {
caption : this . textRotate90 ,
value : 1
} ) . on ( 'click' , _ . bind ( me . onImgRotate , me ) ) ,
2019-02-27 10:11:28 +00:00
new Common . UI . MenuItem ( {
caption : this . textRotate270 ,
value : 0
} ) . on ( 'click' , _ . bind ( me . onImgRotate , me ) ) ,
2019-02-27 11:51:52 +00:00
{ caption : '--' } ,
2019-02-26 15:59:16 +00:00
new Common . UI . MenuItem ( {
caption : this . textFlipH ,
value : 1
} ) . on ( 'click' , _ . bind ( me . onImgFlip , me ) ) ,
new Common . UI . MenuItem ( {
caption : this . textFlipV ,
value : 0
} ) . on ( 'click' , _ . bind ( me . onImgFlip , me ) )
]
} )
} ) ;
2019-04-09 10:41:08 +00:00
me . menuImgCrop = new Common . UI . MenuItem ( {
caption : me . textCrop ,
menu : new Common . UI . Menu ( {
menuAlign : 'tl-tr' ,
items : [
new Common . UI . MenuItem ( {
2019-04-09 11:29:51 +00:00
caption : me . textCrop ,
2019-04-09 10:41:08 +00:00
checkable : true ,
allowDepress : true ,
value : 0
} ) . on ( 'click' , _ . bind ( me . onImgCrop , me ) ) ,
new Common . UI . MenuItem ( {
2019-04-09 11:29:51 +00:00
caption : me . textCropFill ,
2019-04-09 10:41:08 +00:00
value : 1
} ) . on ( 'click' , _ . bind ( me . onImgCrop , me ) ) ,
new Common . UI . MenuItem ( {
2019-04-09 11:29:51 +00:00
caption : me . textCropFit ,
2019-04-09 10:41:08 +00:00
value : 2
} ) . on ( 'click' , _ . bind ( me . onImgCrop , me ) )
]
} )
} ) ;
2016-03-11 00:48:53 +00:00
this . pictureMenu = new Common . UI . Menu ( {
initMenu : function ( value ) {
if ( _ . isUndefined ( value . imgProps ) )
return ;
var notflow = ! value . imgProps . value . get _CanBeFlow ( ) ,
wrapping = value . imgProps . value . get _WrappingStyle ( ) ;
me . menuImageWrap . _originalProps = value . imgProps . value ;
if ( notflow ) {
for ( var i = 0 ; i < 6 ; i ++ ) {
me . menuImageWrap . menu . items [ i ] . setChecked ( false ) ;
}
} else {
switch ( wrapping ) {
2016-04-05 11:52:34 +00:00
case Asc . c _oAscWrapStyle2 . Inline :
2016-03-11 00:48:53 +00:00
me . menuImageWrap . menu . items [ 0 ] . setChecked ( true ) ;
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscWrapStyle2 . Square :
2016-03-11 00:48:53 +00:00
me . menuImageWrap . menu . items [ 1 ] . setChecked ( true ) ;
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscWrapStyle2 . Tight :
2016-03-11 00:48:53 +00:00
me . menuImageWrap . menu . items [ 2 ] . setChecked ( true ) ;
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscWrapStyle2 . Through :
2016-03-11 00:48:53 +00:00
me . menuImageWrap . menu . items [ 3 ] . setChecked ( true ) ;
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscWrapStyle2 . TopAndBottom :
2016-03-11 00:48:53 +00:00
me . menuImageWrap . menu . items [ 4 ] . setChecked ( true ) ;
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscWrapStyle2 . Behind :
2016-03-11 00:48:53 +00:00
me . menuImageWrap . menu . items [ 6 ] . setChecked ( true ) ;
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscWrapStyle2 . InFront :
2016-03-11 00:48:53 +00:00
me . menuImageWrap . menu . items [ 5 ] . setChecked ( true ) ;
break ;
default :
for ( var i = 0 ; i < 6 ; i ++ ) {
me . menuImageWrap . menu . items [ i ] . setChecked ( false ) ;
}
break ;
}
}
_ . each ( me . menuImageWrap . menu . items , function ( item ) {
item . setDisabled ( notflow ) ;
} ) ;
var onlyCommonProps = ( value . imgProps . isImg && value . imgProps . isChart || value . imgProps . isImg && value . imgProps . isShape ||
value . imgProps . isShape && value . imgProps . isChart ) ;
if ( onlyCommonProps )
menuImageAdvanced . setCaption ( me . advancedText , true ) ;
else {
menuImageAdvanced . setCaption ( ( value . imgProps . isImg ) ? me . imageText : ( ( value . imgProps . isChart ) ? me . chartText : me . shapeText ) , true ) ;
}
menuChartEdit . setVisible ( ! _ . isNull ( value . imgProps . value . get _ChartProperties ( ) ) && ! onlyCommonProps ) ;
2018-04-11 13:46:44 +00:00
me . menuOriginalSize . setVisible ( value . imgProps . isOnlyImg || ! value . imgProps . isChart && ! value . imgProps . isShape ) ;
2019-02-26 15:59:16 +00:00
var islocked = value . imgProps . locked || ( value . headerProps !== undefined && value . headerProps . locked ) ;
2018-04-11 13:46:44 +00:00
var pluginGuid = value . imgProps . value . asc _getPluginGuid ( ) ;
menuImgReplace . setVisible ( value . imgProps . isOnlyImg && ( pluginGuid === null || pluginGuid === undefined ) ) ;
if ( menuImgReplace . isVisible ( ) )
menuImgReplace . setDisabled ( islocked || pluginGuid === null ) ;
2016-03-11 00:48:53 +00:00
2019-02-26 15:59:16 +00:00
menuImgRotate . setVisible ( ! value . imgProps . isChart && ( pluginGuid === null || pluginGuid === undefined ) ) ;
if ( menuImgRotate . isVisible ( ) )
menuImgRotate . setDisabled ( islocked ) ;
2019-04-09 10:41:08 +00:00
me . menuImgCrop . setVisible ( me . api . asc _canEditCrop ( ) ) ;
if ( me . menuImgCrop . isVisible ( ) )
me . menuImgCrop . setDisabled ( islocked ) ;
2016-03-11 00:48:53 +00:00
if ( menuChartEdit . isVisible ( ) )
menuChartEdit . setDisabled ( islocked || value . imgProps . value . get _SeveralCharts ( ) ) ;
2019-09-26 09:25:13 +00:00
me . pictureMenu . items [ 19 ] . setVisible ( menuChartEdit . isVisible ( ) ) ;
2018-04-11 13:46:44 +00:00
2016-03-11 00:48:53 +00:00
me . menuOriginalSize . setDisabled ( islocked || value . imgProps . value . get _ImageUrl ( ) === null || value . imgProps . value . get _ImageUrl ( ) === undefined ) ;
menuImageAdvanced . setDisabled ( islocked ) ;
2016-04-05 11:52:34 +00:00
menuImageAlign . setDisabled ( islocked || ( wrapping == Asc . c _oAscWrapStyle2 . Inline ) ) ;
2019-02-12 12:31:27 +00:00
if ( ! ( islocked || ( wrapping == Asc . c _oAscWrapStyle2 . Inline ) ) ) {
var objcount = me . api . asc _getSelectedDrawingObjectsCount ( ) ,
alignto = Common . Utils . InternalSettings . get ( "de-img-align-to" ) ; // 1 - page, 2 - margin, 3 - selected
menuImageAlign . menu . items [ 7 ] . setDisabled ( objcount == 2 && ( ! alignto || alignto == 3 ) ) ;
menuImageAlign . menu . items [ 8 ] . setDisabled ( objcount == 2 && ( ! alignto || alignto == 3 ) ) ;
}
2016-04-05 11:52:34 +00:00
menuImageArrange . setDisabled ( wrapping == Asc . c _oAscWrapStyle2 . Inline ) ;
2016-03-11 00:48:53 +00:00
if ( me . api ) {
mnuUnGroup . setDisabled ( islocked || ! me . api . CanUnGroup ( ) ) ;
mnuGroup . setDisabled ( islocked || ! me . api . CanGroup ( ) ) ;
menuWrapPolygon . setDisabled ( islocked || ! me . api . CanChangeWrapPolygon ( ) ) ;
}
me . menuImageWrap . setDisabled ( islocked || value . imgProps . value . get _FromGroup ( ) || ( notflow && menuWrapPolygon . isDisabled ( ) ) ) ;
var cancopy = me . api && me . api . can _CopyCut ( ) ;
menuImgCopy . setDisabled ( ! cancopy ) ;
menuImgCut . setDisabled ( islocked || ! cancopy ) ;
menuImgPaste . setDisabled ( islocked ) ;
2019-08-07 09:16:40 +00:00
menuImgPrint . setVisible ( me . mode . canPrint ) ;
menuImgPrint . setDisabled ( ! cancopy ) ;
2017-11-22 08:41:47 +00:00
2018-08-01 16:08:24 +00:00
var signGuid = ( value . imgProps && value . imgProps . value && me . mode . isSignatureSupport ) ? value . imgProps . value . asc _getSignatureId ( ) : undefined ,
2017-11-24 11:47:48 +00:00
isInSign = ! ! signGuid ;
2017-11-22 08:41:47 +00:00
menuSignatureEditSign . setVisible ( isInSign ) ;
menuSignatureEditSetup . setVisible ( isInSign ) ;
menuEditSignSeparator . setVisible ( isInSign ) ;
if ( isInSign ) {
menuSignatureEditSign . cmpEl . attr ( 'data-value' , signGuid ) ; // sign
menuSignatureEditSetup . cmpEl . attr ( 'data-value' , signGuid ) ; // edit signature settings
}
2016-03-11 00:48:53 +00:00
} ,
items : [
menuImgCut ,
menuImgCopy ,
menuImgPaste ,
2019-08-07 09:16:40 +00:00
menuImgPrint ,
2016-03-11 00:48:53 +00:00
{ caption : '--' } ,
2017-11-22 08:41:47 +00:00
menuSignatureEditSign ,
menuSignatureEditSetup ,
menuEditSignSeparator ,
2016-03-11 00:48:53 +00:00
menuImageArrange ,
menuImageAlign ,
me . menuImageWrap ,
2019-02-26 15:59:16 +00:00
menuImgRotate ,
2016-03-11 00:48:53 +00:00
{ caption : '--' } ,
2019-09-21 08:52:21 +00:00
menuInsertCaption ,
menuInsertCaptionSeparator ,
2019-04-09 10:41:08 +00:00
me . menuImgCrop ,
2016-03-11 00:48:53 +00:00
me . menuOriginalSize ,
2018-04-11 13:46:44 +00:00
menuImgReplace ,
2016-03-11 00:48:53 +00:00
menuChartEdit ,
{ caption : '--' } ,
menuImageAdvanced
]
2017-04-12 09:45:16 +00:00
} ) . on ( 'hide:after' , function ( menu , e , isFromInputControl ) {
if ( ! isFromInputControl ) me . fireEvent ( 'editcomplete' , me ) ;
2016-03-11 00:48:53 +00:00
me . currentMenu = null ;
} ) ;
/* table menu*/
2019-09-21 08:52:21 +00:00
var menuTableInsertCaption = new Common . UI . MenuItem ( {
caption : me . txtInsertCaption
} ) . on ( 'click' , _ . bind ( me . onInsertCaption , me ) ) ;
2016-03-11 00:48:53 +00:00
var mnuTableMerge = new Common . UI . MenuItem ( {
caption : me . mergeCellsText
} ) . on ( 'click' , function ( item ) {
if ( me . api )
me . api . MergeCells ( ) ;
} ) ;
var mnuTableSplit = new Common . UI . MenuItem ( {
caption : me . splitCellsText
} ) . on ( 'click' , function ( item ) {
if ( me . api ) {
( new Common . Views . InsertTableDialog ( {
2017-08-07 09:23:03 +00:00
split : true ,
2016-03-11 00:48:53 +00:00
handler : function ( result , value ) {
if ( result == 'ok' ) {
if ( me . api ) {
me . api . SplitCell ( value . columns , value . rows ) ;
}
Common . component . Analytics . trackEvent ( 'DocumentHolder' , 'Table' ) ;
}
2017-08-23 08:02:04 +00:00
me . fireEvent ( 'editcomplete' , me ) ;
2016-03-11 00:48:53 +00:00
}
} ) ) . show ( ) ;
}
} ) ;
var tableCellsVAlign = function ( item , e ) {
if ( me . api ) {
2016-04-05 12:57:51 +00:00
var properties = new Asc . CTableProp ( ) ;
2016-03-11 00:48:53 +00:00
properties . put _CellsVAlign ( item . options . valign ) ;
me . api . tblApply ( properties ) ;
}
} ;
var menuTableCellAlign = new Common . UI . MenuItem ( {
caption : me . cellAlignText ,
menu : new Common . UI . Menu ( {
menuAlign : 'tl-tr' ,
items : [
me . menuTableCellTop = new Common . UI . MenuItem ( {
2017-06-06 08:29:30 +00:00
caption : me . textShapeAlignTop ,
2016-03-11 00:48:53 +00:00
toggleGroup : 'popuptablecellalign' ,
checkable : true ,
checked : false ,
2016-04-05 11:52:34 +00:00
valign : Asc . c _oAscVertAlignJc . Top
2016-03-11 00:48:53 +00:00
} ) . on ( 'click' , _ . bind ( tableCellsVAlign , me ) ) ,
me . menuTableCellCenter = new Common . UI . MenuItem ( {
2017-06-06 08:29:30 +00:00
caption : me . textShapeAlignMiddle ,
2016-03-11 00:48:53 +00:00
toggleGroup : 'popuptablecellalign' ,
checkable : true ,
checked : false ,
2016-04-05 11:52:34 +00:00
valign : Asc . c _oAscVertAlignJc . Center
2016-03-11 00:48:53 +00:00
} ) . on ( 'click' , _ . bind ( tableCellsVAlign , me ) ) ,
me . menuTableCellBottom = new Common . UI . MenuItem ( {
2017-06-06 08:29:30 +00:00
caption : me . textShapeAlignBottom ,
2016-03-11 00:48:53 +00:00
toggleGroup : 'popuptablecellalign' ,
checkable : true ,
checked : false ,
2016-04-05 11:52:34 +00:00
valign : Asc . c _oAscVertAlignJc . Bottom
2016-03-11 00:48:53 +00:00
} ) . on ( 'click' , _ . bind ( tableCellsVAlign , me ) )
]
} )
} ) ;
var menuTableAdvanced = new Common . UI . MenuItem ( {
caption : me . advancedTableText
2018-02-06 14:03:04 +00:00
} ) . on ( 'click' , _ . bind ( me . advancedTableClick , me ) ) ;
2016-03-11 00:48:53 +00:00
var menuParagraphAdvancedInTable = new Common . UI . MenuItem ( {
caption : me . advancedParagraphText
} ) . on ( 'click' , _ . bind ( me . advancedParagraphClick , me ) ) ;
var menuHyperlinkSeparator = new Common . UI . MenuItem ( {
caption : '--'
} ) ;
var menuEditHyperlinkTable = new Common . UI . MenuItem ( {
caption : me . editHyperlinkText
} ) . on ( 'click' , _ . bind ( me . editHyperlink , me ) ) ;
var menuRemoveHyperlinkTable = new Common . UI . MenuItem ( {
caption : me . removeHyperlinkText
} ) . on ( 'click' , function ( item , e ) {
2017-12-15 10:06:52 +00:00
me . api && me . api . remove _Hyperlink ( item . hyperProps . value ) ;
2016-03-11 00:48:53 +00:00
me . fireEvent ( 'editcomplete' , me ) ;
} ) ;
var menuHyperlinkTable = new Common . UI . MenuItem ( {
caption : me . hyperlinkText ,
menu : new Common . UI . Menu ( {
menuAlign : 'tl-tr' ,
items : [
menuEditHyperlinkTable ,
menuRemoveHyperlinkTable
]
} )
} ) ;
2017-12-13 13:52:14 +00:00
var menuTableRemoveControl = new Common . UI . MenuItem ( {
caption : me . textRemove ,
value : 'remove'
} ) . on ( 'click' , _ . bind ( me . onControlsSelect , me ) ) ;
var menuTableControlSettings = new Common . UI . MenuItem ( {
caption : me . textSettings ,
value : 'settings'
} ) . on ( 'click' , _ . bind ( me . onControlsSelect , me ) ) ;
var menuTableControl = new Common . UI . MenuItem ( {
caption : me . textContentControls ,
menu : new Common . UI . Menu ( {
menuAlign : 'tl-tr' ,
items : [
menuTableRemoveControl ,
menuTableControlSettings
]
} )
} ) ;
2018-02-08 13:03:10 +00:00
var menuTableTOC = new Common . UI . MenuItem ( {
caption : me . textTOC ,
menu : new Common . UI . Menu ( {
menuAlign : 'tl-tr' ,
items : [
{
caption : me . textSettings ,
value : 'settings'
} ,
{
caption : me . textUpdateAll ,
value : 'all'
} ,
{
caption : me . textUpdatePages ,
value : 'pages'
}
]
} )
} ) ;
menuTableTOC . menu . on ( 'item:click' , function ( menu , item , e ) {
me . fireEvent ( ( item . value == 'settings' ) ? 'links:contents' : 'links:update' , [ item . value , true ] ) ;
} ) ;
2016-03-11 00:48:53 +00:00
/** coauthoring begin **/
var menuAddCommentTable = new Common . UI . MenuItem ( {
caption : me . addCommentText
} ) . on ( 'click' , _ . bind ( me . addComment , me ) ) ;
/** coauthoring end **/
var menuAddHyperlinkTable = new Common . UI . MenuItem ( {
caption : me . hyperlinkText
} ) . on ( 'click' , _ . bind ( me . addHyperlink , me ) ) ;
2019-04-15 14:37:15 +00:00
var menuTableFollow = new Common . UI . MenuItem ( {
caption : me . textFollow
} ) . on ( 'click' , _ . bind ( me . onFollowMove , me ) ) ;
2016-03-11 00:48:53 +00:00
me . menuSpellTable = new Common . UI . MenuItem ( {
caption : me . loadSpellText ,
disabled : true
} ) ;
me . menuSpellMoreTable = new Common . UI . MenuItem ( {
caption : me . moreText ,
menu : new Common . UI . Menu ( {
menuAlign : 'tl-tr' ,
2019-06-21 07:46:00 +00:00
restoreHeight : true ,
2016-03-11 00:48:53 +00:00
items : [
]
} )
} ) ;
2019-08-10 13:38:51 +00:00
var langTemplate = _ . template ( [
2019-08-10 14:02:16 +00:00
'<a id="<%= id %>" tabindex="-1" type="menuitem" style="padding-left: 28px !important;" langval="<%= value %>" class="<% if (checked) { %> checked <% } %>">' ,
2019-12-10 13:49:35 +00:00
'<i class="icon <% if (spellcheck) { %> toolbar__icon btn-ic-docspell spellcheck-lang <% } %>"></i>' ,
2019-08-10 13:38:51 +00:00
'<%= caption %>' ,
'</a>'
] . join ( '' ) ) ;
2016-03-11 00:48:53 +00:00
me . langTableMenu = new Common . UI . MenuItem ( {
caption : me . langText ,
2019-08-10 13:38:51 +00:00
menu : new Common . UI . MenuSimple ( {
2019-01-28 13:51:07 +00:00
cls : 'lang-menu' ,
2016-03-11 00:48:53 +00:00
menuAlign : 'tl-tr' ,
2019-08-07 10:06:36 +00:00
restoreHeight : 285 ,
2019-07-11 11:35:24 +00:00
items : [ ] ,
2019-08-10 13:38:51 +00:00
itemTemplate : langTemplate ,
2019-07-11 11:35:24 +00:00
search : true
2016-03-11 00:48:53 +00:00
} )
} ) ;
var menuIgnoreSpellTable = new Common . UI . MenuItem ( {
caption : me . ignoreSpellText
} ) . on ( 'click' , function ( item ) {
if ( me . api ) {
me . api . asc _ignoreMisspelledWord ( me . _currentSpellObj , false ) ;
me . fireEvent ( 'editcomplete' , me ) ;
}
} ) ;
var menuIgnoreAllSpellTable = new Common . UI . MenuItem ( {
caption : me . ignoreAllSpellText
} ) . on ( 'click' , function ( menu ) {
if ( me . api ) {
me . api . asc _ignoreMisspelledWord ( me . _currentSpellObj , true ) ;
me . fireEvent ( 'editcomplete' , me ) ;
}
} ) ;
2019-08-05 08:59:52 +00:00
var menuToDictionaryTable = new Common . UI . MenuItem ( {
caption : me . toDictionaryText
} ) . on ( 'click' , function ( item , e ) {
2019-08-06 11:32:12 +00:00
me . api . asc _spellCheckAddToDictionary ( me . _currentSpellObj ) ;
2019-08-05 08:59:52 +00:00
me . fireEvent ( 'editcomplete' , me ) ;
} ) ;
2016-03-11 00:48:53 +00:00
var menuIgnoreSpellTableSeparator = new Common . UI . MenuItem ( {
caption : '--'
} ) ;
var menuSpellcheckTableSeparator = new Common . UI . MenuItem ( {
caption : '--'
} ) ;
me . menuSpellCheckTable = new Common . UI . MenuItem ( {
caption : me . spellcheckText ,
menu : new Common . UI . Menu ( {
menuAlign : 'tl-tr' ,
items : [
me . menuSpellTable ,
me . menuSpellMoreTable ,
menuIgnoreSpellTableSeparator ,
menuIgnoreSpellTable ,
menuIgnoreAllSpellTable ,
2019-08-05 08:59:52 +00:00
menuToDictionaryTable ,
2016-03-11 00:48:53 +00:00
{ caption : '--' } ,
me . langTableMenu
]
} )
} ) ;
var menuTableCopy = new Common . UI . MenuItem ( {
caption : me . textCopy ,
value : 'copy'
} ) . on ( 'click' , _ . bind ( me . onCutCopyPaste , me ) ) ;
var menuTablePaste = new Common . UI . MenuItem ( {
caption : me . textPaste ,
value : 'paste'
} ) . on ( 'click' , _ . bind ( me . onCutCopyPaste , me ) ) ;
var menuTableCut = new Common . UI . MenuItem ( {
caption : me . textCut ,
value : 'cut'
} ) . on ( 'click' , _ . bind ( me . onCutCopyPaste , me ) ) ;
2019-08-07 09:16:40 +00:00
var menuTablePrint = new Common . UI . MenuItem ( {
caption : me . txtPrintSelection
} ) . on ( 'click' , _ . bind ( me . onPrintSelection , me ) ) ;
2016-03-11 00:48:53 +00:00
var menuEquationSeparatorInTable = new Common . UI . MenuItem ( {
caption : '--'
} ) ;
2018-01-18 14:44:03 +00:00
var menuTableDistRows = new Common . UI . MenuItem ( {
caption : me . textDistributeRows
} ) . on ( 'click' , _ . bind ( function ( ) {
2018-01-26 08:02:37 +00:00
if ( me . api )
me . api . asc _DistributeTableCells ( false ) ;
2018-01-18 14:44:03 +00:00
me . fireEvent ( 'editcomplete' , me ) ;
} , me ) ) ;
var menuTableDistCols = new Common . UI . MenuItem ( {
caption : me . textDistributeCols
} ) . on ( 'click' , _ . bind ( function ( ) {
2018-01-26 08:02:37 +00:00
if ( me . api )
me . api . asc _DistributeTableCells ( true ) ;
2018-01-18 14:44:03 +00:00
me . fireEvent ( 'editcomplete' , me ) ;
} , me ) ) ;
2016-03-11 00:48:53 +00:00
var tableDirection = function ( item , e ) {
if ( me . api ) {
2016-04-05 12:57:51 +00:00
var properties = new Asc . CTableProp ( ) ;
2016-03-11 00:48:53 +00:00
properties . put _CellsTextDirection ( item . options . direction ) ;
me . api . tblApply ( properties ) ;
}
} ;
var menuTableDirection = new Common . UI . MenuItem ( {
caption : me . directionText ,
menu : new Common . UI . Menu ( {
cls : 'ppm-toolbar' ,
menuAlign : 'tl-tr' ,
items : [
me . menuTableDirectH = new Common . UI . MenuItem ( {
caption : me . directHText ,
2019-11-21 07:58:05 +00:00
iconCls : 'menu__icon text-orient-hor' ,
2016-03-11 00:48:53 +00:00
checkable : true ,
2019-11-21 07:58:05 +00:00
checkmark : false ,
2016-03-11 00:48:53 +00:00
checked : false ,
toggleGroup : 'popuptabledirect' ,
2016-04-05 11:52:34 +00:00
direction : Asc . c _oAscCellTextDirection . LRTB
2016-03-11 00:48:53 +00:00
} ) . on ( 'click' , _ . bind ( tableDirection , me ) ) ,
me . menuTableDirect90 = new Common . UI . MenuItem ( {
caption : me . direct90Text ,
2019-11-21 07:58:05 +00:00
iconCls : 'menu__icon text-orient-rdown' ,
2016-03-11 00:48:53 +00:00
checkable : true ,
2019-11-21 07:58:05 +00:00
checkmark : false ,
2016-03-11 00:48:53 +00:00
checked : false ,
toggleGroup : 'popuptabledirect' ,
2016-04-05 11:52:34 +00:00
direction : Asc . c _oAscCellTextDirection . TBRL
2016-03-11 00:48:53 +00:00
} ) . on ( 'click' , _ . bind ( tableDirection , me ) ) ,
me . menuTableDirect270 = new Common . UI . MenuItem ( {
caption : me . direct270Text ,
2019-11-21 07:58:05 +00:00
iconCls : 'menu__icon text-orient-rup' ,
2016-03-11 00:48:53 +00:00
checkable : true ,
2019-11-21 07:58:05 +00:00
checkmark : false ,
2016-03-11 00:48:53 +00:00
checked : false ,
toggleGroup : 'popuptabledirect' ,
2016-04-05 11:52:34 +00:00
direction : Asc . c _oAscCellTextDirection . BTLR
2016-03-11 00:48:53 +00:00
} ) . on ( 'click' , _ . bind ( tableDirection , me ) )
]
} )
} ) ;
2018-07-20 09:55:03 +00:00
var menuTableStartNewList = new Common . UI . MenuItem ( {
caption : me . textStartNewList
} ) . on ( 'click' , _ . bind ( me . onStartNumbering , me , 1 ) ) ;
var menuTableStartNumberingFrom = new Common . UI . MenuItem ( {
caption : me . textStartNumberingFrom
} ) . on ( 'click' , _ . bind ( me . onStartNumbering , me , 'advanced' ) ) ;
var menuTableContinueNumbering = new Common . UI . MenuItem ( {
caption : me . textContinueNumbering
} ) . on ( 'click' , _ . bind ( me . onContinueNumbering , me ) ) ;
var menuNumberingTable = new Common . UI . MenuItem ( {
caption : me . bulletsText ,
menu : new Common . UI . Menu ( {
menuAlign : 'tl-tr' ,
items : [
menuTableStartNewList ,
menuTableStartNumberingFrom ,
menuTableContinueNumbering
]
} )
} ) ;
2019-03-05 11:03:18 +00:00
var menuTableRefreshField = new Common . UI . MenuItem ( {
caption : me . textRefreshField
} ) . on ( 'click' , function ( item , e ) {
me . api . asc _UpdateComplexField ( item . options . fieldProps ) ;
me . fireEvent ( 'editcomplete' , me ) ;
} ) ;
var menuTableFieldSeparator = new Common . UI . MenuItem ( {
caption : '--'
} ) ;
2016-03-11 00:48:53 +00:00
this . tableMenu = new Common . UI . Menu ( {
initMenu : function ( value ) {
// table properties
if ( _ . isUndefined ( value . tableProps ) )
return ;
var isEquation = ( value . mathProps && value . mathProps . value ) ;
2019-09-26 09:25:13 +00:00
for ( var i = 8 ; i < 27 ; i ++ ) {
2016-03-11 00:48:53 +00:00
me . tableMenu . items [ i ] . setVisible ( ! isEquation ) ;
}
var align = value . tableProps . value . get _CellsVAlign ( ) ;
2016-04-05 11:52:34 +00:00
me . menuTableCellTop . setChecked ( align == Asc . c _oAscVertAlignJc . Top ) ;
me . menuTableCellCenter . setChecked ( align == Asc . c _oAscVertAlignJc . Center ) ;
me . menuTableCellBottom . setChecked ( align == Asc . c _oAscVertAlignJc . Bottom ) ;
2016-03-11 00:48:53 +00:00
var dir = value . tableProps . value . get _CellsTextDirection ( ) ;
2016-04-05 11:52:34 +00:00
me . menuTableDirectH . setChecked ( dir == Asc . c _oAscCellTextDirection . LRTB ) ;
me . menuTableDirect90 . setChecked ( dir == Asc . c _oAscCellTextDirection . TBRL ) ;
me . menuTableDirect270 . setChecked ( dir == Asc . c _oAscCellTextDirection . BTLR ) ;
2016-03-11 00:48:53 +00:00
var disabled = value . tableProps . locked || ( value . headerProps !== undefined && value . headerProps . locked ) ;
2019-03-05 11:03:18 +00:00
me . tableMenu . items [ 11 ] . setDisabled ( disabled ) ;
2019-08-07 09:16:40 +00:00
me . tableMenu . items [ 12 ] . setDisabled ( disabled ) ;
2016-03-11 00:48:53 +00:00
if ( me . api ) {
mnuTableMerge . setDisabled ( disabled || ! me . api . CheckBeforeMergeCells ( ) ) ;
mnuTableSplit . setDisabled ( disabled || ! me . api . CheckBeforeSplitCells ( ) ) ;
}
2018-01-18 14:44:03 +00:00
menuTableDistRows . setDisabled ( disabled ) ;
menuTableDistCols . setDisabled ( disabled ) ;
2016-03-11 00:48:53 +00:00
menuTableCellAlign . setDisabled ( disabled ) ;
menuTableDirection . setDisabled ( disabled ) ;
menuTableAdvanced . setDisabled ( disabled ) ;
var cancopy = me . api && me . api . can _CopyCut ( ) ;
menuTableCopy . setDisabled ( ! cancopy ) ;
menuTableCut . setDisabled ( disabled || ! cancopy ) ;
menuTablePaste . setDisabled ( disabled ) ;
2019-08-07 09:16:40 +00:00
menuTablePrint . setVisible ( me . mode . canPrint ) ;
menuTablePrint . setDisabled ( ! cancopy ) ;
2016-03-11 00:48:53 +00:00
2018-07-20 09:55:03 +00:00
// bullets & numbering
var listId = me . api . asc _GetCurrentNumberingId ( ) ,
in _list = ( listId !== null ) ;
menuNumberingTable . setVisible ( in _list ) ;
if ( in _list ) {
2018-07-20 12:15:28 +00:00
var numLvl = me . api . asc _GetNumberingPr ( listId ) . get _Lvl ( me . api . asc _GetCurrentNumberingLvl ( ) ) ,
format = numLvl . get _Format ( ) ,
start = me . api . asc _GetCalculatedNumberingValue ( ) ;
menuTableStartNewList . setVisible ( numLvl . get _Start ( ) != start ) ;
2018-08-14 08:07:43 +00:00
menuTableStartNewList . value = { start : numLvl . get _Start ( ) } ;
2018-07-20 09:55:03 +00:00
menuTableStartNumberingFrom . setVisible ( format != Asc . c _oAscNumberingFormat . Bullet ) ;
2018-07-20 12:15:28 +00:00
menuTableStartNumberingFrom . value = { format : format , start : start } ;
2018-07-20 09:55:03 +00:00
menuTableStartNewList . setCaption ( ( format == Asc . c _oAscNumberingFormat . Bullet ) ? me . textSeparateList : me . textStartNewList ) ;
menuTableContinueNumbering . setCaption ( ( format == Asc . c _oAscNumberingFormat . Bullet ) ? me . textJoinList : me . textContinueNumbering ) ;
}
2016-03-11 00:48:53 +00:00
// hyperlink properties
var text = null ;
if ( me . api ) {
text = me . api . can _AddHyperlink ( ) ;
}
menuAddHyperlinkTable . setVisible ( value . hyperProps === undefined && text !== false ) ;
menuHyperlinkTable . setVisible ( value . hyperProps !== undefined ) ;
menuEditHyperlinkTable . hyperProps = value . hyperProps ;
2017-12-15 10:11:34 +00:00
menuRemoveHyperlinkTable . hyperProps = value . hyperProps ;
2016-03-11 00:48:53 +00:00
if ( text !== false ) {
menuAddHyperlinkTable . hyperProps = { } ;
2016-04-05 12:57:51 +00:00
menuAddHyperlinkTable . hyperProps . value = new Asc . CHyperlinkProperty ( ) ;
2016-03-11 00:48:53 +00:00
menuAddHyperlinkTable . hyperProps . value . put _Text ( text ) ;
}
/** coauthoring begin **/
// comments
menuAddCommentTable . setVisible ( me . api . can _AddQuotedComment ( ) !== false && me . mode . canCoAuthoring && me . mode . canComments ) ;
menuAddCommentTable . setDisabled ( value . paraProps !== undefined && value . paraProps . locked === true ) ;
/** coauthoring end **/
2019-04-15 14:37:15 +00:00
// review move
var data = me . api . asc _GetRevisionsChangesStack ( ) ,
move = false ;
menuTableFollow . value = null ;
_ . each ( data , function ( item ) {
if ( ( item . get _Type ( ) == Asc . c _oAscRevisionsChangeType . TextAdd || item . get _Type ( ) == Asc . c _oAscRevisionsChangeType . TextRem ) &&
item . get _MoveType ( ) != Asc . c _oAscRevisionsMove . NoMove ) {
menuTableFollow . value = item ;
move = true ;
}
} ) ;
menuTableFollow . setVisible ( move ) ;
menuHyperlinkSeparator . setVisible ( menuAddHyperlinkTable . isVisible ( ) || menuHyperlinkTable . isVisible ( ) || menuNumberingTable . isVisible ( ) || menuTableFollow . isVisible ( ) ) ;
// paragraph properties
2016-03-11 00:48:53 +00:00
menuParagraphAdvancedInTable . setVisible ( value . paraProps !== undefined ) ;
me . _currentParaObjDisabled = disabled = value . paraProps . locked || ( value . headerProps !== undefined && value . headerProps . locked ) ;
menuAddHyperlinkTable . setDisabled ( disabled ) ;
menuHyperlinkTable . setDisabled ( disabled || value . hyperProps !== undefined && value . hyperProps . isSeveralLinks === true ) ;
menuParagraphAdvancedInTable . setDisabled ( disabled ) ;
me . menuSpellCheckTable . setVisible ( value . spellProps !== undefined && value . spellProps . value . get _Checked ( ) === false ) ;
2019-08-05 15:30:42 +00:00
menuToDictionaryTable . setVisible ( me . mode . isDesktopApp ) ;
2016-03-11 00:48:53 +00:00
menuSpellcheckTableSeparator . setVisible ( value . spellProps !== undefined && value . spellProps . value . get _Checked ( ) === false ) ;
me . langTableMenu . setDisabled ( disabled ) ;
if ( value . spellProps !== undefined && value . spellProps . value . get _Checked ( ) === false && value . spellProps . value . get _Variants ( ) !== null && value . spellProps . value . get _Variants ( ) !== undefined ) {
me . addWordVariants ( false ) ;
} else {
me . menuSpellTable . setCaption ( me . loadSpellText , true ) ;
me . clearWordVariants ( false ) ;
me . menuSpellMoreTable . setVisible ( false ) ;
}
if ( me . menuSpellCheckTable . isVisible ( ) && me . _currLang . id !== me . _currLang . tableid ) {
me . changeLanguageMenu ( me . langTableMenu . menu ) ;
me . _currLang . tableid = me . _currLang . id ;
}
//equation menu
var eqlen = 0 ;
if ( isEquation ) {
2019-08-07 09:16:40 +00:00
eqlen = me . addEquationMenu ( false , 7 ) ;
2016-03-11 00:48:53 +00:00
} else
2019-08-07 09:16:40 +00:00
me . clearEquationMenu ( false , 7 ) ;
2016-03-11 00:48:53 +00:00
menuEquationSeparatorInTable . setVisible ( isEquation && eqlen > 0 ) ;
2017-12-13 13:52:14 +00:00
2018-02-08 13:03:10 +00:00
var in _toc = me . api . asc _GetTableOfContentsPr ( true ) ,
in _control = ! in _toc && me . api . asc _IsContentControl ( ) ;
2017-12-13 13:52:14 +00:00
menuTableControl . setVisible ( in _control ) ;
if ( in _control ) {
var control _props = me . api . asc _GetContentControlProperties ( ) ,
2017-12-15 08:50:56 +00:00
lock _type = ( control _props ) ? control _props . get _Lock ( ) : Asc . c _oAscSdtLockType . Unlocked ;
menuTableRemoveControl . setDisabled ( lock _type == Asc . c _oAscSdtLockType . SdtContentLocked || lock _type == Asc . c _oAscSdtLockType . SdtLocked ) ;
2018-06-26 12:46:49 +00:00
menuTableControlSettings . setVisible ( me . mode . canEditContentControl ) ;
2017-12-13 13:52:14 +00:00
}
2018-02-08 13:03:10 +00:00
menuTableTOC . setVisible ( in _toc ) ;
2019-03-05 11:03:18 +00:00
var in _field = me . api . asc _GetCurrentComplexField ( ) ;
menuTableRefreshField . setVisible ( ! ! in _field ) ;
menuTableRefreshField . setDisabled ( disabled ) ;
menuTableFieldSeparator . setVisible ( ! ! in _field ) ;
if ( in _field ) {
menuTableRefreshField . options . fieldProps = in _field ;
}
2016-03-11 00:48:53 +00:00
} ,
items : [
me . menuSpellCheckTable ,
menuSpellcheckTableSeparator ,
menuTableCut ,
menuTableCopy ,
menuTablePaste ,
2019-08-07 09:16:40 +00:00
menuTablePrint ,
2016-03-11 00:48:53 +00:00
{ caption : '--' } ,
menuEquationSeparatorInTable ,
2019-03-05 11:03:18 +00:00
menuTableRefreshField ,
menuTableFieldSeparator ,
2016-03-11 00:48:53 +00:00
{
caption : me . selectText ,
menu : new Common . UI . Menu ( {
menuAlign : 'tl-tr' ,
style : 'width: 100px' ,
items : [
new Common . UI . MenuItem ( {
caption : me . rowText
} ) . on ( 'click' , function ( item ) {
if ( me . api )
me . api . selectRow ( ) ;
} ) ,
new Common . UI . MenuItem ( {
caption : me . columnText
} ) . on ( 'click' , function ( item ) {
if ( me . api )
me . api . selectColumn ( ) ;
} ) ,
new Common . UI . MenuItem ( {
caption : me . cellText
} ) . on ( 'click' , function ( item ) {
if ( me . api )
me . api . selectCell ( ) ;
} ) ,
new Common . UI . MenuItem ( {
caption : me . tableText
} ) . on ( 'click' , function ( item ) {
if ( me . api )
me . api . selectTable ( ) ;
} )
]
} )
} ,
{
caption : me . insertText ,
menu : new Common . UI . Menu ( {
menuAlign : 'tl-tr' ,
style : 'width: 100px' ,
items : [
new Common . UI . MenuItem ( {
caption : me . insertColumnLeftText
} ) . on ( 'click' , function ( item ) {
if ( me . api )
me . api . addColumnLeft ( ) ;
} ) ,
new Common . UI . MenuItem ( {
caption : me . insertColumnRightText
} ) . on ( 'click' , function ( item ) {
if ( me . api )
me . api . addColumnRight ( ) ;
} ) ,
new Common . UI . MenuItem ( {
caption : me . insertRowAboveText
} ) . on ( 'click' , function ( item ) {
if ( me . api )
me . api . addRowAbove ( ) ;
} ) ,
new Common . UI . MenuItem ( {
caption : me . insertRowBelowText
} ) . on ( 'click' , function ( item ) {
if ( me . api )
me . api . addRowBelow ( ) ;
2019-09-06 11:37:43 +00:00
} ) ,
new Common . UI . MenuItem ( {
caption : me . textSeveral
} ) . on ( 'click' , function ( item ) {
me . onCellsAdd ( ) ;
2016-03-11 00:48:53 +00:00
} )
]
} )
} ,
{
caption : me . deleteText ,
menu : new Common . UI . Menu ( {
menuAlign : 'tl-tr' ,
style : 'width: 100px' ,
items : [
new Common . UI . MenuItem ( {
caption : me . rowText
} ) . on ( 'click' , function ( item ) {
if ( me . api )
me . api . remRow ( ) ;
} ) ,
new Common . UI . MenuItem ( {
caption : me . columnText
} ) . on ( 'click' , function ( item ) {
if ( me . api )
me . api . remColumn ( ) ;
} ) ,
new Common . UI . MenuItem ( {
caption : me . tableText
} ) . on ( 'click' , function ( item ) {
if ( me . api )
me . api . remTable ( ) ;
2019-09-05 11:38:34 +00:00
} ) ,
new Common . UI . MenuItem ( {
caption : me . textCells
} ) . on ( 'click' , function ( item ) {
me . onCellsRemove ( ) ;
2016-03-11 00:48:53 +00:00
} )
]
} )
} ,
{ caption : '--' } ,
mnuTableMerge ,
mnuTableSplit ,
{ caption : '--' } ,
2018-01-18 14:44:03 +00:00
menuTableDistRows ,
menuTableDistCols ,
{ caption : '--' } ,
2016-03-11 00:48:53 +00:00
menuTableCellAlign ,
menuTableDirection ,
{ caption : '--' } ,
2019-09-21 08:52:21 +00:00
menuTableInsertCaption ,
{ caption : '--' } ,
2016-03-11 00:48:53 +00:00
menuTableAdvanced ,
{ caption : '--' } ,
/** coauthoring begin **/
menuAddCommentTable ,
/** coauthoring end **/
2018-07-20 09:55:03 +00:00
menuNumberingTable ,
2016-03-11 00:48:53 +00:00
menuAddHyperlinkTable ,
menuHyperlinkTable ,
2019-04-15 14:37:15 +00:00
menuTableFollow ,
2016-03-11 00:48:53 +00:00
menuHyperlinkSeparator ,
2017-12-13 13:52:14 +00:00
menuTableControl ,
2018-02-08 13:03:10 +00:00
menuTableTOC ,
2016-03-11 00:48:53 +00:00
menuParagraphAdvancedInTable
]
2017-04-12 09:45:16 +00:00
} ) . on ( 'hide:after' , function ( menu , e , isFromInputControl ) {
2017-02-07 12:53:51 +00:00
if ( me . suppressEditComplete ) {
me . suppressEditComplete = false ;
return ;
}
2017-04-12 09:45:16 +00:00
if ( ! isFromInputControl ) me . fireEvent ( 'editcomplete' , me ) ;
2016-03-11 00:48:53 +00:00
me . currentMenu = null ;
} ) ;
/* text menu */
var menuParagraphBreakBefore = new Common . UI . MenuItem ( {
caption : me . breakBeforeText ,
checkable : true
} ) . on ( 'click' , function ( item , e ) {
me . api . put _PageBreak ( item . checked ) ;
} ) ;
var menuParagraphKeepLines = new Common . UI . MenuItem ( {
caption : me . keepLinesText ,
checkable : true
} ) . on ( 'click' , function ( item , e ) {
me . api . put _KeepLines ( item . checked ) ;
} ) ;
var paragraphVAlign = function ( item , e ) {
if ( me . api ) {
2016-04-18 12:21:15 +00:00
var properties = new Asc . asc _CImgProperty ( ) ;
2016-03-11 00:48:53 +00:00
properties . put _VerticalTextAlign ( item . options . valign ) ;
me . api . ImgApply ( properties ) ;
}
} ;
var menuParagraphVAlign = new Common . UI . MenuItem ( {
caption : me . vertAlignText ,
menu : new Common . UI . Menu ( {
menuAlign : 'tl-tr' ,
items : [
me . menuParagraphTop = new Common . UI . MenuItem ( {
2017-06-06 08:29:30 +00:00
caption : me . textShapeAlignTop ,
2016-03-11 00:48:53 +00:00
checkable : true ,
checked : false ,
toggleGroup : 'popupparagraphvalign' ,
2016-11-10 11:24:18 +00:00
valign : Asc . c _oAscVAlign . Top
2016-03-11 00:48:53 +00:00
} ) . on ( 'click' , _ . bind ( paragraphVAlign , me ) ) ,
me . menuParagraphCenter = new Common . UI . MenuItem ( {
2017-06-06 08:29:30 +00:00
caption : me . textShapeAlignMiddle ,
2016-03-11 00:48:53 +00:00
checkable : true ,
checked : false ,
toggleGroup : 'popupparagraphvalign' ,
2016-11-10 11:24:18 +00:00
valign : Asc . c _oAscVAlign . Center
2016-03-11 00:48:53 +00:00
} ) . on ( 'click' , _ . bind ( paragraphVAlign , me ) ) ,
me . menuParagraphBottom = new Common . UI . MenuItem ( {
2017-06-06 08:29:30 +00:00
caption : me . textShapeAlignBottom ,
2016-03-11 00:48:53 +00:00
checkable : true ,
checked : false ,
toggleGroup : 'popupparagraphvalign' ,
2016-11-10 11:24:18 +00:00
valign : Asc . c _oAscVAlign . Bottom
2016-03-11 00:48:53 +00:00
} ) . on ( 'click' , _ . bind ( paragraphVAlign , me ) )
]
} )
} ) ;
var paragraphDirection = function ( item , e ) {
if ( me . api ) {
2016-04-18 12:21:15 +00:00
var properties = new Asc . asc _CImgProperty ( ) ;
2016-03-11 00:48:53 +00:00
properties . put _Vert ( item . options . direction ) ;
me . api . ImgApply ( properties ) ;
}
} ;
var menuParagraphDirection = new Common . UI . MenuItem ( {
caption : me . directionText ,
menu : new Common . UI . Menu ( {
cls : 'ppm-toolbar' ,
menuAlign : 'tl-tr' ,
items : [
me . menuParagraphDirectH = new Common . UI . MenuItem ( {
caption : me . directHText ,
2019-11-21 07:58:05 +00:00
iconCls : 'menu__icon text-orient-hor' ,
2016-03-11 00:48:53 +00:00
checkable : true ,
2019-11-21 07:58:05 +00:00
checkmark : false ,
2016-03-11 00:48:53 +00:00
checked : false ,
toggleGroup : 'popupparagraphdirect' ,
2016-04-05 11:52:34 +00:00
direction : Asc . c _oAscVertDrawingText . normal
2016-03-11 00:48:53 +00:00
} ) . on ( 'click' , _ . bind ( paragraphDirection , me ) ) ,
me . menuParagraphDirect90 = new Common . UI . MenuItem ( {
caption : me . direct90Text ,
2019-11-21 07:58:05 +00:00
iconCls : 'menu__icon text-orient-rdown' ,
2016-03-11 00:48:53 +00:00
checkable : true ,
2019-11-21 07:58:05 +00:00
checkmark : false ,
2016-03-11 00:48:53 +00:00
checked : false ,
toggleGroup : 'popupparagraphdirect' ,
2016-04-05 11:52:34 +00:00
direction : Asc . c _oAscVertDrawingText . vert
2016-03-11 00:48:53 +00:00
} ) . on ( 'click' , _ . bind ( paragraphDirection , me ) ) ,
me . menuParagraphDirect270 = new Common . UI . MenuItem ( {
caption : me . direct270Text ,
2019-11-21 07:58:05 +00:00
iconCls : 'menu__icon text-orient-rup' ,
2016-03-11 00:48:53 +00:00
checkable : true ,
2019-11-21 07:58:05 +00:00
checkmark : false ,
2016-03-11 00:48:53 +00:00
checked : false ,
toggleGroup : 'popupparagraphdirect' ,
2016-04-05 11:52:34 +00:00
direction : Asc . c _oAscVertDrawingText . vert270
2016-03-11 00:48:53 +00:00
} ) . on ( 'click' , _ . bind ( paragraphDirection , me ) )
]
} )
} ) ;
var menuParagraphAdvanced = new Common . UI . MenuItem ( {
caption : me . advancedParagraphText
} ) . on ( 'click' , _ . bind ( me . advancedParagraphClick , me ) ) ;
var menuFrameAdvanced = new Common . UI . MenuItem ( {
caption : me . advancedFrameText
} ) . on ( 'click' , _ . bind ( me . advancedFrameClick , me ) ) ;
/** coauthoring begin **/
var menuCommentSeparatorPara = new Common . UI . MenuItem ( {
caption : '--'
} ) ;
var menuAddCommentPara = new Common . UI . MenuItem ( {
caption : me . addCommentText
} ) . on ( 'click' , _ . bind ( me . addComment , me ) ) ;
/** coauthoring end **/
var menuHyperlinkParaSeparator = new Common . UI . MenuItem ( {
caption : '--'
} ) ;
var menuAddHyperlinkPara = new Common . UI . MenuItem ( {
caption : me . hyperlinkText
} ) . on ( 'click' , _ . bind ( me . addHyperlink , me ) ) ;
var menuEditHyperlinkPara = new Common . UI . MenuItem ( {
caption : me . editHyperlinkText
} ) . on ( 'click' , _ . bind ( me . editHyperlink , me ) ) ;
var menuRemoveHyperlinkPara = new Common . UI . MenuItem ( {
caption : me . removeHyperlinkText
} ) . on ( 'click' , function ( item , e ) {
2017-12-15 10:06:52 +00:00
me . api . remove _Hyperlink ( item . hyperProps . value ) ;
2016-03-11 00:48:53 +00:00
me . fireEvent ( 'editcomplete' , me ) ;
} ) ;
var menuHyperlinkPara = new Common . UI . MenuItem ( {
caption : me . hyperlinkText ,
menu : new Common . UI . Menu ( {
menuAlign : 'tl-tr' ,
items : [
menuEditHyperlinkPara ,
menuRemoveHyperlinkPara
]
} )
} ) ;
var menuStyleSeparator = new Common . UI . MenuItemSeparator ( ) ;
var menuStyle = new Common . UI . MenuItem ( {
caption : me . styleText ,
menu : new Common . UI . Menu ( {
menuAlign : 'tl-tr' ,
items : [
me . menuStyleSave = new Common . UI . MenuItem ( {
caption : me . saveStyleText
} ) . on ( 'click' , _ . bind ( me . onMenuSaveStyle , me ) ) ,
me . menuStyleUpdate = new Common . UI . MenuItem ( {
caption : me . updateStyleText . replace ( '%1' , window . currentStyleName )
} ) . on ( 'click' , _ . bind ( me . onMenuUpdateStyle , me ) )
]
} )
} ) ;
me . menuSpellPara = new Common . UI . MenuItem ( {
caption : me . loadSpellText ,
disabled : true
} ) ;
me . menuSpellMorePara = new Common . UI . MenuItem ( {
caption : me . moreText ,
menu : new Common . UI . Menu ( {
menuAlign : 'tl-tr' ,
2019-06-21 07:46:00 +00:00
restoreHeight : true ,
2019-06-20 11:32:10 +00:00
items : [ ]
2016-03-11 00:48:53 +00:00
} )
} ) ;
me . langParaMenu = new Common . UI . MenuItem ( {
caption : me . langText ,
2019-08-10 13:38:51 +00:00
menu : new Common . UI . MenuSimple ( {
2019-01-28 13:51:07 +00:00
cls : 'lang-menu' ,
2016-03-11 00:48:53 +00:00
menuAlign : 'tl-tr' ,
2019-08-07 10:06:36 +00:00
restoreHeight : 285 ,
2019-07-11 11:35:24 +00:00
items : [ ] ,
2019-08-10 13:38:51 +00:00
itemTemplate : langTemplate ,
2019-07-11 11:35:24 +00:00
search : true
2016-03-11 00:48:53 +00:00
} )
} ) ;
var menuIgnoreSpellPara = new Common . UI . MenuItem ( {
caption : me . ignoreSpellText
} ) . on ( 'click' , function ( item , e ) {
me . api . asc _ignoreMisspelledWord ( me . _currentSpellObj , false ) ;
me . fireEvent ( 'editcomplete' , me ) ;
} ) ;
var menuIgnoreAllSpellPara = new Common . UI . MenuItem ( {
caption : me . ignoreAllSpellText
} ) . on ( 'click' , function ( item , e ) {
me . api . asc _ignoreMisspelledWord ( me . _currentSpellObj , true ) ;
me . fireEvent ( 'editcomplete' , me ) ;
} ) ;
2019-08-05 08:59:52 +00:00
var menuToDictionaryPara = new Common . UI . MenuItem ( {
caption : me . toDictionaryText
} ) . on ( 'click' , function ( item , e ) {
2019-08-06 11:32:12 +00:00
me . api . asc _spellCheckAddToDictionary ( me . _currentSpellObj ) ;
2019-08-05 08:59:52 +00:00
me . fireEvent ( 'editcomplete' , me ) ;
} ) ;
2016-03-11 00:48:53 +00:00
var menuIgnoreSpellParaSeparator = new Common . UI . MenuItem ( {
caption : '--'
} ) ;
var menuSpellcheckParaSeparator = new Common . UI . MenuItem ( {
caption : '--'
} ) ;
var menuParaCopy = new Common . UI . MenuItem ( {
caption : me . textCopy ,
value : 'copy'
} ) . on ( 'click' , _ . bind ( me . onCutCopyPaste , me ) ) ;
var menuParaPaste = new Common . UI . MenuItem ( {
caption : me . textPaste ,
value : 'paste'
} ) . on ( 'click' , _ . bind ( me . onCutCopyPaste , me ) ) ;
var menuParaCut = new Common . UI . MenuItem ( {
caption : me . textCut ,
value : 'cut'
} ) . on ( 'click' , _ . bind ( me . onCutCopyPaste , me ) ) ;
2019-08-07 09:16:40 +00:00
var menuParaPrint = new Common . UI . MenuItem ( {
caption : me . txtPrintSelection
} ) . on ( 'click' , _ . bind ( me . onPrintSelection , me ) ) ;
2016-03-11 00:48:53 +00:00
var menuEquationSeparator = new Common . UI . MenuItem ( {
caption : '--'
} ) ;
2017-12-13 13:52:14 +00:00
var menuParaRemoveControl = new Common . UI . MenuItem ( {
caption : me . textRemoveControl ,
value : 'remove'
} ) . on ( 'click' , _ . bind ( me . onControlsSelect , me ) ) ;
var menuParaControlSettings = new Common . UI . MenuItem (
{
caption : me . textEditControls ,
value : 'settings'
} ) . on ( 'click' , _ . bind ( me . onControlsSelect , me ) ) ;
var menuParaControlSeparator = new Common . UI . MenuItem ( {
caption : '--'
} ) ;
2018-02-08 13:03:10 +00:00
var menuParaTOCSettings = new Common . UI . MenuItem ( {
caption : me . textTOCSettings ,
value : 'settings'
} ) . on ( 'click' , function ( item , e ) {
me . fireEvent ( 'links:contents' , [ item . value , true ] ) ;
} ) ;
var menuParaTOCRefresh = new Common . UI . MenuItem ( {
caption : me . textUpdateTOC ,
menu : new Common . UI . Menu ( {
menuAlign : 'tl-tr' ,
items : [
{
caption : me . textUpdateAll ,
value : 'all'
} ,
{
caption : me . textUpdatePages ,
value : 'pages'
}
]
} )
} ) ;
menuParaTOCRefresh . menu . on ( 'item:click' , function ( menu , item , e ) {
me . fireEvent ( 'links:update' , [ item . value , true ] ) ;
} ) ;
var menuParaTOCSeparator = new Common . UI . MenuItem ( {
caption : '--'
} ) ;
2018-02-26 09:03:16 +00:00
var menuParaRefreshField = new Common . UI . MenuItem ( {
caption : me . textRefreshField
} ) . on ( 'click' , function ( item , e ) {
me . api . asc _UpdateComplexField ( item . options . fieldProps ) ;
me . fireEvent ( 'editcomplete' , me ) ;
} ) ;
var menuParaFieldSeparator = new Common . UI . MenuItem ( {
caption : '--'
} ) ;
2018-07-20 09:00:30 +00:00
var menuParaStartNewList = new Common . UI . MenuItem ( {
caption : me . textStartNewList
} ) . on ( 'click' , _ . bind ( me . onStartNumbering , me , 1 ) ) ;
var menuParaStartNumberingFrom = new Common . UI . MenuItem ( {
caption : me . textStartNumberingFrom
2018-07-20 09:06:03 +00:00
} ) . on ( 'click' , _ . bind ( me . onStartNumbering , me , 'advanced' ) ) ;
2018-07-20 09:00:30 +00:00
var menuParaContinueNumbering = new Common . UI . MenuItem ( {
caption : me . textContinueNumbering
} ) . on ( 'click' , _ . bind ( me . onContinueNumbering , me ) ) ;
var menuParaNumberingSeparator = new Common . UI . MenuItem ( {
caption : '--'
} ) ;
2019-04-15 14:37:15 +00:00
var menuParaFollow = new Common . UI . MenuItem ( {
caption : me . textFollow
} ) . on ( 'click' , _ . bind ( me . onFollowMove , me ) ) ;
var menuParaFollowSeparator = new Common . UI . MenuItem ( {
caption : '--'
} ) ;
2016-03-11 00:48:53 +00:00
this . textMenu = new Common . UI . Menu ( {
initMenu : function ( value ) {
var isInShape = ( value . imgProps && value . imgProps . value && ! _ . isNull ( value . imgProps . value . get _ShapeProperties ( ) ) ) ;
var isInChart = ( value . imgProps && value . imgProps . value && ! _ . isNull ( value . imgProps . value . get _ChartProperties ( ) ) ) ;
var isEquation = ( value . mathProps && value . mathProps . value ) ;
menuParagraphVAlign . setVisible ( isInShape && ! isInChart && ! isEquation ) ; // после того, как заголовок можно будет растягивать по вертикали, вернуть "|| isInChart" !!
menuParagraphDirection . setVisible ( isInShape && ! isInChart && ! isEquation ) ; // после того, как заголовок можно будет растягивать по вертикали, вернуть "|| isInChart" !!
if ( isInShape || isInChart ) {
var align = value . imgProps . value . get _VerticalTextAlign ( ) ;
2016-11-10 11:24:18 +00:00
me . menuParagraphTop . setChecked ( align == Asc . c _oAscVAlign . Top ) ;
me . menuParagraphCenter . setChecked ( align == Asc . c _oAscVAlign . Center ) ;
me . menuParagraphBottom . setChecked ( align == Asc . c _oAscVAlign . Bottom ) ;
2016-03-11 00:48:53 +00:00
var dir = value . imgProps . value . get _Vert ( ) ;
2016-04-05 11:52:34 +00:00
me . menuParagraphDirectH . setChecked ( dir == Asc . c _oAscVertDrawingText . normal ) ;
me . menuParagraphDirect90 . setChecked ( dir == Asc . c _oAscVertDrawingText . vert ) ;
me . menuParagraphDirect270 . setChecked ( dir == Asc . c _oAscVertDrawingText . vert270 ) ;
2016-03-11 00:48:53 +00:00
}
menuParagraphAdvanced . isChart = ( value . imgProps && value . imgProps . isChart ) ;
menuParagraphBreakBefore . setVisible ( ! isInShape && ! isInChart && ! isEquation ) ;
menuParagraphKeepLines . setVisible ( ! isInShape && ! isInChart && ! isEquation ) ;
if ( value . paraProps ) {
menuParagraphBreakBefore . setChecked ( value . paraProps . value . get _PageBreakBefore ( ) ) ;
menuParagraphKeepLines . setChecked ( value . paraProps . value . get _KeepLines ( ) ) ;
}
var text = null ;
if ( me . api ) {
text = me . api . can _AddHyperlink ( ) ;
}
/** coauthoring begin **/
2019-11-01 08:36:32 +00:00
var isVisible = ! isInChart && me . api . can _AddQuotedComment ( ) !== false && me . mode . canCoAuthoring && me . mode . canComments ;
if ( me . mode . compatibleFeatures )
isVisible = isVisible && ! isInShape ;
menuCommentSeparatorPara . setVisible ( isVisible ) ;
menuAddCommentPara . setVisible ( isVisible ) ;
2016-03-11 00:48:53 +00:00
menuAddCommentPara . setDisabled ( value . paraProps && value . paraProps . locked === true ) ;
/** coauthoring end **/
menuAddHyperlinkPara . setVisible ( value . hyperProps === undefined && text !== false ) ;
menuHyperlinkPara . setVisible ( value . hyperProps !== undefined ) ;
menuHyperlinkParaSeparator . setVisible ( menuAddHyperlinkPara . isVisible ( ) || menuHyperlinkPara . isVisible ( ) ) ;
menuEditHyperlinkPara . hyperProps = value . hyperProps ;
2017-12-15 10:11:34 +00:00
menuRemoveHyperlinkPara . hyperProps = value . hyperProps ;
2016-03-11 00:48:53 +00:00
if ( text !== false ) {
menuAddHyperlinkPara . hyperProps = { } ;
2016-04-05 12:57:51 +00:00
menuAddHyperlinkPara . hyperProps . value = new Asc . CHyperlinkProperty ( ) ;
2016-03-11 00:48:53 +00:00
menuAddHyperlinkPara . hyperProps . value . put _Text ( text ) ;
}
var disabled = value . paraProps . locked || ( value . headerProps !== undefined && value . headerProps . locked ) ;
me . _currentParaObjDisabled = disabled ;
menuAddHyperlinkPara . setDisabled ( disabled ) ;
menuHyperlinkPara . setDisabled ( disabled || value . hyperProps !== undefined && value . hyperProps . isSeveralLinks === true ) ;
2019-04-15 14:37:15 +00:00
// review move
var data = me . api . asc _GetRevisionsChangesStack ( ) ,
move = false ;
menuParaFollow . value = null ;
_ . each ( data , function ( item ) {
if ( ( item . get _Type ( ) == Asc . c _oAscRevisionsChangeType . TextAdd || item . get _Type ( ) == Asc . c _oAscRevisionsChangeType . TextRem ) &&
item . get _MoveType ( ) != Asc . c _oAscRevisionsMove . NoMove ) {
menuParaFollow . value = item ;
move = true ;
}
} ) ;
menuParaFollow . setVisible ( move ) ;
menuParaFollowSeparator . setVisible ( move ) ;
2016-03-11 00:48:53 +00:00
menuParagraphBreakBefore . setDisabled ( disabled || ! _ . isUndefined ( value . headerProps ) || ! _ . isUndefined ( value . imgProps ) ) ;
menuParagraphKeepLines . setDisabled ( disabled ) ;
menuParagraphAdvanced . setDisabled ( disabled ) ;
menuFrameAdvanced . setDisabled ( disabled ) ;
menuParagraphVAlign . setDisabled ( disabled ) ;
menuParagraphDirection . setDisabled ( disabled ) ;
var cancopy = me . api && me . api . can _CopyCut ( ) ;
menuParaCopy . setDisabled ( ! cancopy ) ;
menuParaCut . setDisabled ( disabled || ! cancopy ) ;
menuParaPaste . setDisabled ( disabled ) ;
2019-08-07 09:16:40 +00:00
menuParaPrint . setVisible ( me . mode . canPrint ) ;
menuParaPrint . setDisabled ( ! cancopy ) ;
2016-03-11 00:48:53 +00:00
// spellCheck
2019-08-05 08:59:52 +00:00
var spell = ( value . spellProps !== undefined && value . spellProps . value . get _Checked ( ) === false ) ;
me . menuSpellPara . setVisible ( spell ) ;
menuSpellcheckParaSeparator . setVisible ( spell ) ;
menuIgnoreSpellPara . setVisible ( spell ) ;
menuIgnoreAllSpellPara . setVisible ( spell ) ;
2019-08-05 15:30:42 +00:00
menuToDictionaryPara . setVisible ( spell && me . mode . isDesktopApp ) ;
2019-08-05 08:59:52 +00:00
me . langParaMenu . setVisible ( spell ) ;
2016-03-11 00:48:53 +00:00
me . langParaMenu . setDisabled ( disabled ) ;
2019-08-05 08:59:52 +00:00
menuIgnoreSpellParaSeparator . setVisible ( spell ) ;
2016-03-11 00:48:53 +00:00
2019-08-05 08:59:52 +00:00
if ( spell && value . spellProps . value . get _Variants ( ) !== null && value . spellProps . value . get _Variants ( ) !== undefined ) {
2016-03-11 00:48:53 +00:00
me . addWordVariants ( true ) ;
} else {
me . menuSpellPara . setCaption ( me . loadSpellText , true ) ;
me . clearWordVariants ( true ) ;
me . menuSpellMorePara . setVisible ( false ) ;
}
if ( me . langParaMenu . isVisible ( ) && me . _currLang . id !== me . _currLang . paraid ) {
me . changeLanguageMenu ( me . langParaMenu . menu ) ;
me . _currLang . paraid = me . _currLang . id ;
}
//equation menu
var eqlen = 0 ;
if ( isEquation ) {
2019-09-26 09:25:13 +00:00
eqlen = me . addEquationMenu ( true , 15 ) ;
2016-03-11 00:48:53 +00:00
} else
2019-09-26 09:25:13 +00:00
me . clearEquationMenu ( true , 15 ) ;
2016-03-11 00:48:53 +00:00
menuEquationSeparator . setVisible ( isEquation && eqlen > 0 ) ;
2019-09-21 08:52:21 +00:00
menuEquationInsertCaption . setVisible ( isEquation ) ;
menuEquationInsertCaptionSeparator . setVisible ( isEquation ) ;
2016-03-11 00:48:53 +00:00
menuFrameAdvanced . setVisible ( value . paraProps . value . get _FramePr ( ) !== undefined ) ;
menuStyleSeparator . setVisible ( me . mode . canEditStyles && ! isInChart ) ;
menuStyle . setVisible ( me . mode . canEditStyles && ! isInChart ) ;
2017-06-23 13:46:10 +00:00
if ( me . mode . canEditStyles && ! isInChart ) {
me . menuStyleUpdate . setCaption ( me . updateStyleText . replace ( '%1' , DE . getController ( 'Main' ) . translationTable [ window . currentStyleName ] || window . currentStyleName ) ) ;
}
2017-12-13 13:52:14 +00:00
2018-02-08 13:03:10 +00:00
var in _toc = me . api . asc _GetTableOfContentsPr ( true ) ,
in _control = ! in _toc && me . api . asc _IsContentControl ( ) ;
2017-12-13 13:52:14 +00:00
menuParaRemoveControl . setVisible ( in _control ) ;
2018-06-26 12:46:49 +00:00
menuParaControlSettings . setVisible ( in _control && me . mode . canEditContentControl ) ;
2017-12-13 13:52:14 +00:00
menuParaControlSeparator . setVisible ( in _control ) ;
if ( in _control ) {
var control _props = me . api . asc _GetContentControlProperties ( ) ,
2017-12-15 08:50:56 +00:00
lock _type = ( control _props ) ? control _props . get _Lock ( ) : Asc . c _oAscSdtLockType . Unlocked ;
menuParaRemoveControl . setDisabled ( lock _type == Asc . c _oAscSdtLockType . SdtContentLocked || lock _type == Asc . c _oAscSdtLockType . SdtLocked ) ;
2017-12-13 13:52:14 +00:00
}
2018-02-08 13:03:10 +00:00
menuParaTOCSettings . setVisible ( in _toc ) ;
menuParaTOCRefresh . setVisible ( in _toc ) ;
menuParaTOCSeparator . setVisible ( in _toc ) ;
2018-02-26 09:03:16 +00:00
var in _field = me . api . asc _GetCurrentComplexField ( ) ;
menuParaRefreshField . setVisible ( ! ! in _field ) ;
menuParaRefreshField . setDisabled ( disabled ) ;
menuParaFieldSeparator . setVisible ( ! ! in _field ) ;
if ( in _field ) {
menuParaRefreshField . options . fieldProps = in _field ;
}
2018-07-20 09:00:30 +00:00
var listId = me . api . asc _GetCurrentNumberingId ( ) ,
in _list = ( listId !== null ) ;
menuParaNumberingSeparator . setVisible ( in _list ) ; // hide when first item is selected
menuParaStartNewList . setVisible ( in _list ) ;
menuParaStartNumberingFrom . setVisible ( in _list ) ;
menuParaContinueNumbering . setVisible ( in _list ) ;
if ( in _list ) {
2018-07-20 12:15:28 +00:00
var numLvl = me . api . asc _GetNumberingPr ( listId ) . get _Lvl ( me . api . asc _GetCurrentNumberingLvl ( ) ) ,
format = numLvl . get _Format ( ) ,
start = me . api . asc _GetCalculatedNumberingValue ( ) ;
menuParaStartNewList . setVisible ( numLvl . get _Start ( ) != start ) ;
2018-08-14 08:07:43 +00:00
menuParaStartNewList . value = { start : numLvl . get _Start ( ) } ;
2018-07-20 09:00:30 +00:00
menuParaStartNumberingFrom . setVisible ( format != Asc . c _oAscNumberingFormat . Bullet ) ;
2018-07-20 12:15:28 +00:00
menuParaStartNumberingFrom . value = { format : format , start : start } ;
2018-07-20 09:00:30 +00:00
menuParaStartNewList . setCaption ( ( format == Asc . c _oAscNumberingFormat . Bullet ) ? me . textSeparateList : me . textStartNewList ) ;
menuParaContinueNumbering . setCaption ( ( format == Asc . c _oAscNumberingFormat . Bullet ) ? me . textJoinList : me . textContinueNumbering ) ;
}
2016-03-11 00:48:53 +00:00
} ,
items : [
me . menuSpellPara ,
me . menuSpellMorePara ,
menuSpellcheckParaSeparator ,
menuIgnoreSpellPara ,
menuIgnoreAllSpellPara ,
2019-08-05 08:59:52 +00:00
menuToDictionaryPara ,
2016-03-11 00:48:53 +00:00
me . langParaMenu ,
menuIgnoreSpellParaSeparator ,
menuParaCut ,
menuParaCopy ,
menuParaPaste ,
2019-08-07 09:16:40 +00:00
menuParaPrint ,
2019-09-21 08:52:21 +00:00
menuEquationInsertCaptionSeparator ,
menuEquationInsertCaption ,
2016-03-11 00:48:53 +00:00
{ caption : '--' } ,
menuEquationSeparator ,
2017-12-13 13:52:14 +00:00
menuParaRemoveControl ,
menuParaControlSettings ,
menuParaControlSeparator ,
2018-02-26 09:03:16 +00:00
menuParaRefreshField ,
menuParaFieldSeparator ,
2018-02-08 13:03:10 +00:00
menuParaTOCSettings ,
menuParaTOCRefresh ,
menuParaTOCSeparator ,
2016-03-11 00:48:53 +00:00
menuParagraphBreakBefore ,
menuParagraphKeepLines ,
menuParagraphVAlign ,
menuParagraphDirection ,
menuParagraphAdvanced ,
menuFrameAdvanced ,
/** coauthoring begin **/
menuCommentSeparatorPara ,
menuAddCommentPara ,
/** coauthoring end **/
menuHyperlinkParaSeparator ,
menuAddHyperlinkPara ,
menuHyperlinkPara ,
2019-04-15 14:37:15 +00:00
menuParaFollowSeparator ,
menuParaFollow ,
2018-07-20 09:00:30 +00:00
menuParaNumberingSeparator ,
menuParaStartNewList ,
menuParaStartNumberingFrom ,
menuParaContinueNumbering ,
2016-03-11 00:48:53 +00:00
menuStyleSeparator ,
menuStyle
]
2017-04-12 09:45:16 +00:00
} ) . on ( 'hide:after' , function ( menu , e , isFromInputControl ) {
2016-03-11 00:48:53 +00:00
if ( me . suppressEditComplete ) {
me . suppressEditComplete = false ;
return ;
}
2017-04-12 09:45:16 +00:00
if ( ! isFromInputControl ) me . fireEvent ( 'editcomplete' , me ) ;
2016-03-11 00:48:53 +00:00
me . currentMenu = null ;
} ) ;
/* header/footer menu */
var menuEditHeaderFooter = new Common . UI . MenuItem ( {
caption : me . editHeaderText
} ) ;
this . hdrMenu = new Common . UI . Menu ( {
initMenu : function ( value ) {
menuEditHeaderFooter . setCaption ( value . Header ? me . editHeaderText : me . editFooterText , true ) ;
menuEditHeaderFooter . off ( 'click' ) . on ( 'click' , function ( item ) {
if ( me . api ) {
if ( value . Header ) {
me . api . GoToHeader ( value . PageNum ) ;
}
else
me . api . GoToFooter ( value . PageNum ) ;
me . fireEvent ( 'editcomplete' , me ) ;
}
} ) ;
} ,
items : [
menuEditHeaderFooter
]
2017-04-12 09:45:16 +00:00
} ) . on ( 'hide:after' , function ( menu , e , isFromInputControl ) {
if ( ! isFromInputControl ) me . fireEvent ( 'editcomplete' , me ) ;
2016-03-11 00:48:53 +00:00
me . currentMenu = null ;
} ) ;
var nextpage = $ ( '#id_buttonNextPage' ) ;
nextpage . attr ( 'data-toggle' , 'tooltip' ) ;
nextpage . tooltip ( {
title : me . textNextPage + Common . Utils . String . platformKey ( 'Alt+PgDn' ) ,
placement : 'top-right'
} ) ;
var prevpage = $ ( '#id_buttonPrevPage' ) ;
prevpage . attr ( 'data-toggle' , 'tooltip' ) ;
prevpage . tooltip ( {
title : me . textPrevPage + Common . Utils . String . platformKey ( 'Alt+PgUp' ) ,
placement : 'top-right'
} ) ;
} ,
setLanguages : function ( langs ) {
var me = this ;
2017-04-19 08:28:40 +00:00
if ( langs && langs . length > 0 && me . langParaMenu && me . langTableMenu ) {
2019-08-10 13:38:51 +00:00
var arrPara = [ ] , arrTable = [ ] ;
_ . each ( langs , function ( lang ) {
var item = {
2019-01-28 13:51:07 +00:00
caption : lang . displayValue ,
2019-02-27 14:53:21 +00:00
value : lang . value ,
2016-03-11 00:48:53 +00:00
checkable : true ,
2019-01-28 13:51:07 +00:00
langid : lang . code ,
2019-08-10 13:38:51 +00:00
spellcheck : lang . spellcheck
} ;
arrPara . push ( item ) ;
arrTable . push ( _ . clone ( item ) ) ;
} ) ;
me . langParaMenu . menu . resetItems ( arrPara ) ;
me . langTableMenu . menu . resetItems ( arrTable ) ;
2016-03-11 00:48:53 +00:00
2019-08-10 13:38:51 +00:00
me . langParaMenu . menu . on ( 'item:click' , function ( menu , item ) {
if ( me . api ) {
if ( ! _ . isUndefined ( item . langid ) )
me . api . put _TextPrLang ( item . langid ) ;
2016-03-11 00:48:53 +00:00
2019-08-10 13:38:51 +00:00
me . _currLang . paraid = item . langid ;
me . fireEvent ( 'editcomplete' , me ) ;
}
} ) ;
2016-03-11 00:48:53 +00:00
2019-08-10 13:38:51 +00:00
me . langTableMenu . menu . on ( 'item:click' , function ( menu , item , e ) {
if ( me . api ) {
if ( ! _ . isUndefined ( item . langid ) )
me . api . put _TextPrLang ( item . langid ) ;
2016-03-11 00:48:53 +00:00
2019-08-10 13:38:51 +00:00
me . _currLang . tableid = item . langid ;
me . fireEvent ( 'editcomplete' , me ) ;
}
2016-03-11 00:48:53 +00:00
} ) ;
}
} ,
2017-11-24 11:47:48 +00:00
onSignatureClick : function ( item ) {
2017-11-22 08:41:47 +00:00
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 :
2017-11-24 11:47:48 +00:00
Common . NotificationCenter . trigger ( 'protect:signature' , 'visible' , this . _isDisabled , datavalue ) ; //guid, can edit settings for requested signature
2017-11-22 08:41:47 +00:00
break ;
case 3 :
this . api . asc _RemoveSignature ( datavalue ) ; //guid
break ;
}
} ,
2019-02-26 15:59:16 +00:00
onImgRotate : function ( item ) {
var properties = new Asc . asc _CImgProperty ( ) ;
properties . asc _putRotAdd ( ( item . value == 1 ? 90 : 270 ) * 3.14159265358979 / 180 ) ;
this . api . ImgApply ( properties ) ;
this . fireEvent ( 'editcomplete' , this ) ;
} ,
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 ) ;
this . fireEvent ( 'editcomplete' , this ) ;
} ,
2019-04-09 10:41:08 +00:00
onImgCrop : function ( 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 ( ) ;
}
this . fireEvent ( 'editcomplete' , this ) ;
} ,
2019-04-15 14:37:15 +00:00
onFollowMove : function ( item ) {
if ( this . api ) {
this . api . asc _FollowRevisionMove ( item . value ) ;
}
this . fireEvent ( 'editcomplete' , this ) ;
} ,
2019-12-05 10:48:48 +00:00
onHideContentControlsActions : function ( ) {
this . listControlMenu && this . listControlMenu . isVisible ( ) && this . listControlMenu . hide ( ) ;
var controlsContainer = this . cmpEl . find ( '#calendar-control-container' ) ;
if ( controlsContainer . is ( ':visible' ) )
controlsContainer . hide ( ) ;
} ,
onShowDateActions : function ( obj , x , y ) {
var props = obj . pr ,
specProps = props . get _DateTimePr ( ) ,
controlsContainer = this . 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>' ) ;
this . 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 : this . cmpEl . find ( '#id-document-calendar-control' ) ,
enableKeyEvents : true ,
firstday : 1
} ) ;
this . cmpCalendar . on ( 'date:click' , function ( cmp , date ) {
2019-12-09 12:55:41 +00:00
var specProps = me . _dateObj . get _DateTimePr ( ) ;
2019-12-05 10:48:48 +00:00
specProps . put _FullDate ( new Date ( date ) ) ;
2019-12-09 12:55:41 +00:00
me . api . asc _SetContentControlDatePickerDate ( specProps ) ;
2019-12-05 10:48:48 +00:00
controlsContainer . hide ( ) ;
me . api . asc _UncheckContentControlButtons ( ) ;
me . fireEvent ( 'editcomplete' , me ) ;
} ) ;
this . cmpCalendar . on ( 'calendar:keydown' , function ( cmp , e ) {
if ( e . keyCode == Common . UI . Keys . ESC ) {
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 ( ) ,
menu = this . listControlMenu ,
menuContainer = menu ? this . 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 ( {
menuAlign : 'tr-bl' ,
items : [ ]
} ) ;
menu . on ( 'item:click' , function ( menu , item ) {
setTimeout ( function ( ) {
2019-12-12 07:22:20 +00:00
( item . value !== - 1 ) && me . api . asc _SelectContentControlListItem ( item . value , me . _listObj . get _InternalId ( ) ) ;
2019-12-05 10:48:48 +00:00
} , 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 ) ) ;
this . 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 ) {
var count = specProps . get _ItemsCount ( ) ;
for ( var i = 0 ; i < count ; i ++ ) {
menu . addItem ( new Common . UI . MenuItem ( {
caption : specProps . get _ItemDisplayText ( i ) ,
value : specProps . get _ItemValue ( i )
} ) ) ;
}
2019-12-12 07:22:20 +00:00
if ( count < 1 ) {
menu . addItem ( new Common . UI . MenuItem ( {
caption : this . txtEmpty ,
value : - 1
} ) ) ;
}
2019-12-05 10:48:48 +00:00
}
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 :
this . api . asc _addImage ( obj ) ;
break ;
case Asc . c _oAscContentControlSpecificType . DropDownList :
case Asc . c _oAscContentControlSpecificType . ComboBox :
this . onShowListActions ( obj , x , y ) ;
break ;
}
} ,
2016-03-11 00:48:53 +00:00
focus : function ( ) {
var me = this ;
_ . defer ( function ( ) { me . cmpEl . focus ( ) ; } , 50 ) ;
} ,
2017-11-22 08:41:47 +00:00
SetDisabled : function ( state , canProtect ) {
2017-08-23 15:06:55 +00:00
this . _isDisabled = state ;
2017-11-22 08:41:47 +00:00
this . _canProtect = canProtect ;
2017-08-23 15:06:55 +00:00
} ,
2016-03-11 00:48:53 +00:00
alignmentText : 'Alignment' ,
leftText : 'Left' ,
rightText : 'Right' ,
centerText : 'Center' ,
selectRowText : 'Select Row' ,
selectColumnText : 'Select Column' ,
selectCellText : 'Select Cell' ,
selectTableText : 'Select Table' ,
insertRowAboveText : 'Row Above' ,
insertRowBelowText : 'Row Below' ,
insertColumnLeftText : 'Column Left' ,
insertColumnRightText : 'Column Right' ,
deleteText : 'Delete' ,
deleteRowText : 'Delete Row' ,
deleteColumnText : 'Delete Column' ,
deleteTableText : 'Delete Table' ,
mergeCellsText : 'Merge Cells' ,
splitCellsText : 'Split Cell...' ,
splitCellTitleText : 'Split Cell' ,
2019-11-06 08:16:29 +00:00
originalSizeText : 'Actual Size' ,
2016-03-11 00:48:53 +00:00
advancedText : 'Advanced Settings' ,
breakBeforeText : 'Page break before' ,
keepLinesText : 'Keep lines together' ,
editHeaderText : 'Edit header' ,
editFooterText : 'Edit footer' ,
hyperlinkText : 'Hyperlink' ,
editHyperlinkText : 'Edit Hyperlink' ,
removeHyperlinkText : 'Remove Hyperlink' ,
styleText : 'Formatting as Style' ,
saveStyleText : 'Create new style' ,
updateStyleText : 'Update %1 style' ,
txtPressLink : 'Press CTRL and click link' ,
selectText : 'Select' ,
insertRowText : 'Insert Row' ,
insertColumnText : 'Insert Column' ,
rowText : 'Row' ,
columnText : 'Column' ,
cellText : 'Cell' ,
tableText : 'Table' ,
aboveText : 'Above' ,
belowText : 'Below' ,
advancedTableText : 'Table Advanced Settings' ,
advancedParagraphText : 'Paragraph Advanced Settings' ,
paragraphText : 'Paragraph' ,
guestText : 'Guest' ,
editChartText : 'Edit Data' ,
/** coauthoring begin **/
addCommentText : 'Add Comment' ,
/** coauthoring end **/
cellAlignText : 'Cell Vertical Alignment' ,
txtInline : 'Inline' ,
txtSquare : 'Square' ,
txtTight : 'Tight' ,
txtThrough : 'Through' ,
txtTopAndBottom : 'Top and bottom' ,
txtBehind : 'Behind' ,
txtInFront : 'In front' ,
textWrap : 'Wrapping Style' ,
textAlign : 'Align' ,
textArrange : 'Arrange' ,
textShapeAlignLeft : 'Align Left' ,
textShapeAlignRight : 'Align Right' ,
textShapeAlignCenter : 'Align Center' ,
textShapeAlignTop : 'Align Top' ,
textShapeAlignBottom : 'Align Bottom' ,
textShapeAlignMiddle : 'Align Middle' ,
textArrangeFront : 'Bring To Front' ,
textArrangeBack : 'Send To Back' ,
textArrangeForward : 'Bring Forward' ,
textArrangeBackward : 'Send Backward' ,
txtGroup : 'Group' ,
txtUngroup : 'Ungroup' ,
textEditWrapBoundary : 'Edit Wrap Boundary' ,
vertAlignText : 'Vertical Alignment' ,
loadSpellText : 'Loading variants...' ,
ignoreAllSpellText : 'Ignore All' ,
ignoreSpellText : 'Ignore' ,
noSpellVariantsText : 'No variants' ,
moreText : 'More variants...' ,
spellcheckText : 'Spellcheck' ,
langText : 'Select Language' ,
advancedFrameText : 'Frame Advanced Settings' ,
tipIsLocked : 'This element is being edited by another user.' ,
textNextPage : 'Next Page' ,
textPrevPage : 'Previous Page' ,
imageText : 'Image Advanced Settings' ,
shapeText : 'Shape Advanced Settings' ,
chartText : 'Chart Advanced Settings' ,
insertText : 'Insert' ,
textCopy : 'Copy' ,
textPaste : 'Paste' ,
textCut : 'Cut' ,
directionText : 'Text Direction' ,
directHText : 'Horizontal' ,
2017-06-06 08:15:03 +00:00
direct90Text : 'Rotate Text Down' ,
direct270Text : 'Rotate Text Up°' ,
2016-03-11 00:48:53 +00:00
txtRemoveAccentChar : 'Remove accent character' ,
txtBorderProps : 'Borders property' ,
txtHideTop : 'Hide top border' ,
txtHideBottom : 'Hide bottom border' ,
txtHideLeft : 'Hide left border' ,
txtHideRight : 'Hide right border' ,
txtHideHor : 'Hide horizontal line' ,
txtHideVer : 'Hide vertical line' ,
txtHideLT : 'Hide left top line' ,
txtHideLB : 'Hide left bottom line' ,
txtAddTop : 'Add top border' ,
txtAddBottom : 'Add bottom border' ,
txtAddLeft : 'Add left border' ,
txtAddRight : 'Add right border' ,
txtAddHor : 'Add horizontal line' ,
txtAddVer : 'Add vertical line' ,
txtAddLT : 'Add left top line' ,
txtAddLB : 'Add left bottom line' ,
txtRemoveBar : 'Remove bar' ,
txtOverbar : 'Bar over text' ,
txtUnderbar : 'Bar under text' ,
txtRemScripts : 'Remove scripts' ,
txtRemSubscript : 'Remove subscript' ,
txtRemSuperscript : 'Remove superscript' ,
txtScriptsAfter : 'Scripts after text' ,
txtScriptsBefore : 'Scripts before text' ,
txtFractionStacked : 'Change to stacked fraction' ,
txtFractionSkewed : 'Change to skewed fraction' ,
txtFractionLinear : 'Change to linear fraction' ,
txtRemFractionBar : 'Remove fraction bar' ,
txtAddFractionBar : 'Add fraction bar' ,
txtRemLimit : 'Remove limit' ,
txtLimitOver : 'Limit over text' ,
txtLimitUnder : 'Limit under text' ,
txtHidePlaceholder : 'Hide placeholder' ,
txtShowPlaceholder : 'Show placeholder' ,
txtMatrixAlign : 'Matrix alignment' ,
txtColumnAlign : 'Column alignment' ,
txtTop : 'Top' ,
txtBottom : 'Bottom' ,
txtInsertEqBefore : 'Insert equation before' ,
txtInsertEqAfter : 'Insert equation after' ,
txtDeleteEq : 'Delete equation' ,
txtLimitChange : 'Change limits location' ,
txtHideTopLimit : 'Hide top limit' ,
txtShowTopLimit : 'Show top limit' ,
txtHideBottomLimit : 'Hide bottom limit' ,
txtShowBottomLimit : 'Show bottom limit' ,
txtInsertArgBefore : 'Insert argument before' ,
txtInsertArgAfter : 'Insert argument after' ,
txtDeleteArg : 'Delete argument' ,
txtHideOpenBracket : 'Hide opening bracket' ,
txtShowOpenBracket : 'Show opening bracket' ,
txtHideCloseBracket : 'Hide closing bracket' ,
txtShowCloseBracket : 'Show closing bracket' ,
txtStretchBrackets : 'Stretch brackets' ,
txtMatchBrackets : 'Match brackets to argument height' ,
txtGroupCharOver : 'Char over text' ,
txtGroupCharUnder : 'Char under text' ,
txtDeleteGroupChar : 'Delete char' ,
txtHideDegree : 'Hide degree' ,
txtShowDegree : 'Show degree' ,
txtIncreaseArg : 'Increase argument size' ,
txtDecreaseArg : 'Decrease argument size' ,
txtInsertBreak : 'Insert manual break' ,
txtDeleteBreak : 'Delete manual break' ,
txtAlignToChar : 'Align to character' ,
txtDeleteRadical : 'Delete radical' ,
txtDeleteChars : 'Delete enclosing characters' ,
2017-05-12 08:52:19 +00:00
txtDeleteCharsAndSeparators : 'Delete enclosing characters and separators' ,
2017-06-06 08:04:04 +00:00
txtKeepTextOnly : 'Keep text only' ,
2017-11-22 08:41:47 +00:00
textUndo : 'Undo' ,
strSign : 'Sign' ,
strDetails : 'Signature Details' ,
strSetup : 'Signature Setup' ,
2017-12-08 15:00:56 +00:00
strDelete : 'Remove Signature' ,
txtOverwriteCells : 'Overwrite cells' ,
2018-01-15 13:11:11 +00:00
textNest : 'Nest table' ,
2017-12-13 13:52:14 +00:00
textContentControls : 'Content control' ,
textRemove : 'Remove' ,
textSettings : 'Settings' ,
textRemoveControl : 'Remove content control' ,
2018-01-18 14:44:03 +00:00
textEditControls : 'Content control settings' ,
textDistributeRows : 'Distribute rows' ,
2018-02-08 13:03:10 +00:00
textDistributeCols : 'Distribute columns' ,
textUpdateTOC : 'Refresh table of contents' ,
textUpdateAll : 'Refresh entire table' ,
textUpdatePages : 'Refresh page numbers only' ,
textTOCSettings : 'Table of contents settings' ,
2018-02-26 09:03:16 +00:00
textTOC : 'Table of contents' ,
2018-03-23 14:11:51 +00:00
textRefreshField : 'Refresh field' ,
2018-04-11 13:46:44 +00:00
txtPasteSourceFormat : 'Keep source formatting' ,
textReplace : 'Replace image' ,
textFromUrl : 'From URL' ,
2018-07-20 09:00:30 +00:00
textFromFile : 'From File' ,
textStartNumberingFrom : 'Set numbering value' ,
textStartNewList : 'Start new list' ,
textContinueNumbering : 'Continue numbering' ,
textSeparateList : 'Separate list' ,
textJoinList : 'Join to previous list' ,
2018-07-20 09:55:03 +00:00
textNumberingValue : 'Numbering Value' ,
2019-02-12 12:31:27 +00:00
bulletsText : 'Bullets and Numbering' ,
txtDistribHor : 'Distribute Horizontally' ,
txtDistribVert : 'Distribute Vertically' ,
2019-02-27 10:11:28 +00:00
textRotate270 : 'Rotate 90° Counterclockwise' ,
textRotate90 : 'Rotate 90° Clockwise' ,
2019-02-26 15:59:16 +00:00
textFlipV : 'Flip Vertically' ,
textFlipH : 'Flip Horizontally' ,
2019-04-09 10:41:08 +00:00
textRotate : 'Rotate' ,
textCrop : 'Crop' ,
textCropFill : 'Fill' ,
2019-04-15 14:37:15 +00:00
textCropFit : 'Fit' ,
2019-08-05 08:59:52 +00:00
textFollow : 'Follow move' ,
2019-08-07 09:16:40 +00:00
toDictionaryText : 'Add to Dictionary' ,
2019-09-05 11:38:34 +00:00
txtPrintSelection : 'Print Selection' ,
2019-09-06 11:37:43 +00:00
textCells : 'Cells' ,
2019-09-21 08:52:21 +00:00
textSeveral : 'Several Rows/Columns' ,
2019-12-12 07:22:20 +00:00
txtInsertCaption : 'Insert Caption' ,
txtEmpty : '(Empty)'
2016-03-11 00:48:53 +00:00
} , DE . Views . DocumentHolder || { } ) ) ;
} ) ;