2016-04-01 13:17:09 +00:00
/ *
*
* ( c ) Copyright Ascensio System Limited 2010 - 2016
*
* This program is a free software product . You can redistribute it and / or
* modify it under the terms of the GNU Affero General Public License ( AGPL )
* version 3 as published by the Free Software Foundation . In accordance with
* Section 7 ( a ) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non - infringement
* of any third - party rights .
*
* This program is distributed WITHOUT ANY WARRANTY ; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . For
* details , see the GNU AGPL at : http : //www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st . 125 a - 25 , Riga , Latvia ,
* EU , LV - 1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices , as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7 ( b ) of the License you must retain the original Product
* logo when distributing the program . Pursuant to Section 7 ( e ) we decline to
* grant you any rights under trademark law for use of our trademarks .
*
* All the Product ' s GUI elements , including illustrations and icon sets , as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution - ShareAlike 4.0 International . See the License
* terms at http : //creativecommons.org/licenses/by-sa/4.0/legalcode
*
* /
2016-03-11 00:48:53 +00:00
/ * *
* DocumentHolder . js
*
* DocumentHolder controller
*
* Created by Julia Radzhabova on 3 / 28 / 14
* Copyright ( c ) 2014 Ascensio System SIA . All rights reserved .
*
* /
define ( [
'core' ,
'common/main/lib/util/utils' ,
'common/main/lib/view/CopyWarningDialog' ,
'spreadsheeteditor/main/app/view/DocumentHolder' ,
'spreadsheeteditor/main/app/view/HyperlinkSettingsDialog' ,
'spreadsheeteditor/main/app/view/ParagraphSettingsAdvanced' ,
'spreadsheeteditor/main/app/view/SetValueDialog' ,
'spreadsheeteditor/main/app/view/AutoFilterDialog'
] , function ( ) {
'use strict' ;
SSE . Controllers . DocumentHolder = Backbone . Controller . extend ( _ . extend ( {
models : [ ] ,
collections : [ ] ,
views : [
'DocumentHolder'
] ,
initialize : function ( ) {
var me = this ;
me . tooltips = {
hyperlink : { } ,
/** coauthoring begin **/
comment : { } ,
/** coauthoring end **/
coauth : {
ttHeight : 20
} ,
row _column : {
ttHeight : 20
}
} ;
me . mouse = { } ;
me . popupmenu = false ;
me . rangeSelectionMode = false ;
me . namedrange _locked = false ;
2016-10-24 11:56:11 +00:00
me . _currentMathObj = undefined ;
me . _currentParaObjDisabled = false ;
2016-03-11 00:48:53 +00:00
/** coauthoring begin **/
this . wrapEvents = {
apiHideComment : _ . bind ( this . onApiHideComment , this )
} ;
/** coauthoring end **/
this . addListeners ( {
'DocumentHolder' : {
'createdelayedelements' : this . onCreateDelayedElements
}
} ) ;
var keymap = { } ;
this . hkComments = 'alt+h' ;
keymap [ this . hkComments ] = function ( ) {
me . onAddComment ( ) ;
} ;
Common . util . Shortcuts . delegateShortcuts ( { shortcuts : keymap } ) ;
} ,
onLaunch : function ( ) {
var me = this ;
me . documentHolder = this . createView ( 'DocumentHolder' ) ;
// me.documentHolder.on('render:after', _.bind(me.onAfterRender, me));
me . documentHolder . render ( ) ;
me . documentHolder . el . tabIndex = - 1 ;
$ ( document ) . on ( 'mousewheel' , _ . bind ( me . onDocumentWheel , me ) ) ;
$ ( document ) . on ( 'mousedown' , _ . bind ( me . onDocumentRightDown , me ) ) ;
$ ( document ) . on ( 'mouseup' , _ . bind ( me . onDocumentRightUp , me ) ) ;
$ ( document ) . on ( 'keydown' , _ . bind ( me . onDocumentKeyDown , me ) ) ;
$ ( window ) . on ( 'resize' , _ . bind ( me . onDocumentResize , me ) ) ;
var viewport = SSE . getController ( 'Viewport' ) . getView ( 'Viewport' ) ;
viewport . hlayout . on ( 'layout:resizedrag' , _ . bind ( me . onDocumentResize , me ) ) ;
Common . NotificationCenter . on ( {
'window:show' : function ( e ) {
me . hideHyperlinkTip ( ) ;
} ,
'modal:show' : function ( e ) {
me . hideCoAuthTips ( ) ;
} ,
'layout:changed' : function ( e ) {
me . hideHyperlinkTip ( ) ;
me . hideCoAuthTips ( ) ;
me . onDocumentResize ( ) ;
} ,
'cells:range' : function ( status ) {
me . onCellsRange ( status ) ;
}
} ) ;
} ,
onCreateDelayedElements : function ( view ) {
var me = this ;
view . pmiCut . on ( 'click' , _ . bind ( me . onCopyPaste , me ) ) ;
view . pmiCopy . on ( 'click' , _ . bind ( me . onCopyPaste , me ) ) ;
view . pmiPaste . on ( 'click' , _ . bind ( me . onCopyPaste , me ) ) ;
view . pmiImgCut . on ( 'click' , _ . bind ( me . onCopyPaste , me ) ) ;
view . pmiImgCopy . on ( 'click' , _ . bind ( me . onCopyPaste , me ) ) ;
view . pmiImgPaste . on ( 'click' , _ . bind ( me . onCopyPaste , me ) ) ;
view . pmiTextCut . on ( 'click' , _ . bind ( me . onCopyPaste , me ) ) ;
view . pmiTextCopy . on ( 'click' , _ . bind ( me . onCopyPaste , me ) ) ;
view . pmiTextPaste . on ( 'click' , _ . bind ( me . onCopyPaste , me ) ) ;
view . pmiInsertEntire . on ( 'click' , _ . bind ( me . onInsertEntire , me ) ) ;
view . pmiDeleteEntire . on ( 'click' , _ . bind ( me . onDeleteEntire , me ) ) ;
view . pmiInsertCells . menu . on ( 'item:click' , _ . bind ( me . onInsertCells , me ) ) ;
view . pmiDeleteCells . menu . on ( 'item:click' , _ . bind ( me . onDeleteCells , me ) ) ;
view . pmiSortCells . menu . on ( 'item:click' , _ . bind ( me . onSortCells , me ) ) ;
2016-05-17 08:01:41 +00:00
view . pmiFilterCells . menu . on ( 'item:click' , _ . bind ( me . onFilterCells , me ) ) ;
2016-05-17 08:21:28 +00:00
view . pmiReapply . on ( 'click' , _ . bind ( me . onReapply , me ) ) ;
2016-03-11 00:48:53 +00:00
view . pmiClear . menu . on ( 'item:click' , _ . bind ( me . onClear , me ) ) ;
2016-03-30 12:27:16 +00:00
view . pmiSelectTable . menu . on ( 'item:click' , _ . bind ( me . onSelectTable , me ) ) ;
view . pmiInsertTable . menu . on ( 'item:click' , _ . bind ( me . onInsertTable , me ) ) ;
view . pmiDeleteTable . menu . on ( 'item:click' , _ . bind ( me . onDeleteTable , me ) ) ;
2016-03-11 00:48:53 +00:00
view . pmiInsFunction . on ( 'click' , _ . bind ( me . onInsFunction , me ) ) ;
view . menuAddHyperlink . on ( 'click' , _ . bind ( me . onInsHyperlink , me ) ) ;
view . menuEditHyperlink . on ( 'click' , _ . bind ( me . onInsHyperlink , me ) ) ;
view . menuRemoveHyperlink . on ( 'click' , _ . bind ( me . onDelHyperlink , me ) ) ;
2016-07-26 12:47:48 +00:00
view . pmiRowHeight . menu . on ( 'item:click' , _ . bind ( me . onSetSize , me ) ) ;
view . pmiColumnWidth . menu . on ( 'item:click' , _ . bind ( me . onSetSize , me ) ) ;
2016-03-11 00:48:53 +00:00
view . pmiEntireHide . on ( 'click' , _ . bind ( me . onEntireHide , me ) ) ;
view . pmiEntireShow . on ( 'click' , _ . bind ( me . onEntireShow , me ) ) ;
view . pmiFreezePanes . on ( 'click' , _ . bind ( me . onFreezePanes , me ) ) ;
2016-10-25 13:22:22 +00:00
view . pmiEntriesList . on ( 'click' , _ . bind ( me . onEntriesList , me ) ) ;
2016-03-11 00:48:53 +00:00
/** coauthoring begin **/
view . pmiAddComment . on ( 'click' , _ . bind ( me . onAddComment , me ) ) ;
/** coauthoring end **/
view . pmiAddNamedRange . on ( 'click' , _ . bind ( me . onAddNamedRange , me ) ) ;
view . imgMenu . on ( 'item:click' , _ . bind ( me . onImgMenu , me ) ) ;
view . menuParagraphVAlign . menu . on ( 'item:click' , _ . bind ( me . onParagraphVAlign , me ) ) ;
view . menuParagraphDirection . menu . on ( 'item:click' , _ . bind ( me . onParagraphDirection , me ) ) ;
view . menuAddHyperlinkShape . on ( 'click' , _ . bind ( me . onInsHyperlink , me ) ) ;
view . menuEditHyperlinkShape . on ( 'click' , _ . bind ( me . onInsHyperlink , me ) ) ;
view . menuRemoveHyperlinkShape . on ( 'click' , _ . bind ( me . onRemoveHyperlinkShape , me ) ) ;
view . pmiTextAdvanced . on ( 'click' , _ . bind ( me . onTextAdvanced , me ) ) ;
view . mnuShapeAdvanced . on ( 'click' , _ . bind ( me . onShapeAdvanced , me ) ) ;
view . mnuChartEdit . on ( 'click' , _ . bind ( me . onChartEdit , me ) ) ;
var documentHolderEl = view . cmpEl ;
if ( documentHolderEl ) {
documentHolderEl . on ( {
keydown : function ( e ) {
if ( e . keyCode == e . F10 && e . shiftKey ) {
e . stopEvent ( ) ;
me . showObjectMenu ( e ) ;
}
} ,
mousedown : function ( e ) {
if ( e . target . localName == 'canvas' && e . button != 2 ) {
Common . UI . Menu . Manager . hideAll ( ) ;
}
} ,
click : function ( e ) {
if ( me . api ) {
me . api . isTextAreaBlur = false ;
if ( e . target . localName == 'canvas' && ! me . isEditFormula ) {
documentHolderEl . focus ( ) ;
}
}
}
} ) ;
//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 ( view . el , eventname , _ . bind ( this . onDocumentWheel , this ) ) ;
me . cellEditor = $ ( '#ce-cell-content' ) ;
}
} ,
loadConfig : function ( data ) {
this . editorConfig = data . config ;
} ,
setMode : function ( permissions ) {
this . permissions = permissions ;
/** coauthoring begin **/
! ( this . permissions . canCoAuthoring && this . permissions . isEdit && this . permissions . canComments )
? Common . util . Shortcuts . suspendEvents ( this . hkComments )
: Common . util . Shortcuts . resumeEvents ( this . hkComments ) ;
/** coauthoring end **/
} ,
setApi : function ( api ) {
this . api = api ;
this . api . asc _registerCallback ( 'asc_onContextMenu' , _ . bind ( this . onApiContextMenu , this ) ) ;
this . api . asc _registerCallback ( 'asc_onMouseMove' , _ . bind ( this . onApiMouseMove , this ) ) ;
/** coauthoring begin **/
this . api . asc _registerCallback ( 'asc_onHideComment' , this . wrapEvents . apiHideComment ) ;
// this.api.asc_registerCallback('asc_onShowComment', this.wrapEvents.apiShowComment);
/** coauthoring end **/
this . api . asc _registerCallback ( 'asc_onHyperlinkClick' , _ . bind ( this . onApiHyperlinkClick , this ) ) ;
this . api . asc _registerCallback ( 'asc_onSetAFDialog' , _ . bind ( this . onApiAutofilter , this ) ) ;
this . api . asc _registerCallback ( 'asc_onCoAuthoringDisconnect' , _ . bind ( this . onApiCoAuthoringDisconnect , this ) ) ;
Common . NotificationCenter . on ( 'api:disconnect' , _ . bind ( this . onApiCoAuthoringDisconnect , this ) ) ;
this . api . asc _registerCallback ( 'asc_onEditCell' , _ . bind ( this . onApiEditCell , this ) ) ;
this . api . asc _registerCallback ( 'asc_onLockDefNameManager' , _ . bind ( this . onLockDefNameManager , this ) ) ;
this . api . asc _registerCallback ( 'asc_onSelectionChanged' , _ . bind ( this . onSelectionChanged , this ) ) ;
2016-10-25 13:22:22 +00:00
this . api . asc _registerCallback ( 'asc_onEntriesListMenu' , _ . bind ( this . onEntriesListMenu , this ) ) ; // Alt + Down
2016-03-11 00:48:53 +00:00
this . api . asc _registerCallback ( 'asc_onFormulaCompleteMenu' , _ . bind ( this . onFormulaCompleteMenu , this ) ) ;
return this ;
} ,
resetApi : function ( api ) {
/** coauthoring begin **/
this . api . asc _unregisterCallback ( 'asc_onHideComment' , this . wrapEvents . apiHideComment ) ;
// this.api.asc_unregisterCallback('asc_onShowComment', this.wrapEvents.apiShowComment);
this . api . asc _registerCallback ( 'asc_onHideComment' , this . wrapEvents . apiHideComment ) ;
// this.api.asc_registerCallback('asc_onShowComment', this.wrapEvents.apiShowComment);
/** coauthoring end **/
} ,
onCopyPaste : function ( item ) {
var me = this ;
if ( me . api ) {
2016-07-26 14:46:42 +00:00
var res = ( item . value == 'cut' ) ? me . api . asc _Cut ( ) : ( ( item . value == 'copy' ) ? me . api . asc _Copy ( ) : me . api . asc _Paste ( ) ) ;
if ( ! res ) {
2016-03-11 00:48:53 +00:00
var value = Common . localStorage . getItem ( "sse-hide-copywarning" ) ;
if ( ! ( value && parseInt ( value ) == 1 ) ) {
( new Common . Views . CopyWarningDialog ( {
handler : function ( dontshow ) {
if ( dontshow ) Common . localStorage . setItem ( "sse-hide-copywarning" , 1 ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , me . documentHolder ) ;
}
} ) ) . show ( ) ;
}
2016-07-26 14:46:42 +00:00
} else
2016-03-11 00:48:53 +00:00
Common . component . Analytics . trackEvent ( 'ToolBar' , 'Copy Warning' ) ;
}
2016-07-26 14:46:42 +00:00
Common . NotificationCenter . trigger ( 'edit:complete' , me . documentHolder ) ;
2016-03-11 00:48:53 +00:00
} ,
onInsertEntire : function ( item ) {
if ( this . api ) {
switch ( this . api . asc _getCellInfo ( ) . asc _getFlags ( ) . asc _getSelectionType ( ) ) {
2016-04-05 11:52:34 +00:00
case Asc . c _oAscSelectionType . RangeRow :
this . api . asc _insertCells ( Asc . c _oAscInsertOptions . InsertRows ) ;
2016-03-11 00:48:53 +00:00
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscSelectionType . RangeCol :
this . api . asc _insertCells ( Asc . c _oAscInsertOptions . InsertColumns ) ;
2016-03-11 00:48:53 +00:00
break ;
}
Common . NotificationCenter . trigger ( 'edit:complete' , this . documentHolder ) ;
Common . component . Analytics . trackEvent ( 'DocumentHolder' , 'Insert Entire' ) ;
}
} ,
onInsertCells : function ( menu , item ) {
if ( this . api ) {
this . api . asc _insertCells ( item . value ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . documentHolder ) ;
Common . component . Analytics . trackEvent ( 'DocumentHolder' , 'Insert Cells' ) ;
}
} ,
onDeleteEntire : function ( item ) {
if ( this . api ) {
switch ( this . api . asc _getCellInfo ( ) . asc _getFlags ( ) . asc _getSelectionType ( ) ) {
2016-04-05 11:52:34 +00:00
case Asc . c _oAscSelectionType . RangeRow :
this . api . asc _deleteCells ( Asc . c _oAscDeleteOptions . DeleteRows ) ;
2016-03-11 00:48:53 +00:00
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscSelectionType . RangeCol :
this . api . asc _deleteCells ( Asc . c _oAscDeleteOptions . DeleteColumns ) ;
2016-03-11 00:48:53 +00:00
break ;
}
Common . NotificationCenter . trigger ( 'edit:complete' , this . documentHolder ) ;
Common . component . Analytics . trackEvent ( 'DocumentHolder' , 'Delete Entire' ) ;
}
} ,
onDeleteCells : function ( menu , item ) {
if ( this . api ) {
this . api . asc _deleteCells ( item . value ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . documentHolder ) ;
Common . component . Analytics . trackEvent ( 'DocumentHolder' , 'Delete Cells' ) ;
}
} ,
onSortCells : function ( menu , item ) {
if ( this . api ) {
2016-05-17 11:31:12 +00:00
this . api . asc _sortColFilter ( item . value , '' , undefined , ( item . value == Asc . c _oAscSortOptions . ByColorFill ) ? this . documentHolder . ssMenu . cellColor : this . documentHolder . ssMenu . fontColor ) ;
2016-03-11 00:48:53 +00:00
Common . NotificationCenter . trigger ( 'edit:complete' , this . documentHolder ) ;
Common . component . Analytics . trackEvent ( 'DocumentHolder' , 'Sort Cells' ) ;
}
} ,
2016-05-17 08:01:41 +00:00
onFilterCells : function ( menu , item ) {
if ( this . api ) {
var autoFilterObject = new Asc . AutoFiltersOptions ( ) ,
filterObj = new Asc . AutoFilterObj ( ) ;
if ( item . value > 0 ) {
filterObj . asc _setFilter ( new Asc . ColorFilter ( ) ) ;
filterObj . asc _setType ( Asc . c _oAscAutoFilterTypes . ColorFilter ) ;
var colorFilter = filterObj . asc _getFilter ( ) ;
colorFilter . asc _setCellColor ( ( item . value == 1 ) ? null : false ) ;
colorFilter . asc _setCColor ( ( item . value == 1 ) ? this . documentHolder . ssMenu . cellColor : this . documentHolder . ssMenu . fontColor ) ;
} else {
filterObj . asc _setFilter ( new Asc . CustomFilters ( ) ) ;
filterObj . asc _setType ( Asc . c _oAscAutoFilterTypes . CustomFilters ) ;
var customFilter = filterObj . asc _getFilter ( ) ;
customFilter . asc _setCustomFilters ( [ new Asc . CustomFilter ( ) ] ) ;
customFilter . asc _setAnd ( true ) ;
var customFilters = customFilter . asc _getCustomFilters ( ) ;
customFilters [ 0 ] . asc _setOperator ( Asc . c _oAscCustomAutoFilter . equals ) ;
// customFilters[0].asc_setVal('');
}
autoFilterObject . asc _setFilterObj ( filterObj ) ;
this . api . asc _applyAutoFilterByType ( autoFilterObject ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . documentHolder ) ;
Common . component . Analytics . trackEvent ( 'DocumentHolder' , 'Filter Cells' ) ;
}
} ,
onReapply : function ( ) {
2016-05-17 09:34:10 +00:00
this . api . asc _reapplyAutoFilter ( this . documentHolder . ssMenu . formatTableName ) ;
2016-05-17 08:01:41 +00:00
} ,
2016-03-11 00:48:53 +00:00
onClear : function ( menu , item ) {
if ( this . api ) {
this . api . asc _emptyCells ( item . value ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . documentHolder ) ;
Common . component . Analytics . trackEvent ( 'DocumentHolder' , 'Clear' ) ;
}
} ,
2016-03-30 12:27:16 +00:00
onSelectTable : function ( menu , item ) {
if ( this . api && this . documentHolder . ssMenu . formatTableName ) {
this . api . asc _changeSelectionFormatTable ( this . documentHolder . ssMenu . formatTableName , item . value ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . documentHolder ) ;
Common . component . Analytics . trackEvent ( 'DocumentHolder' , 'Select Table' ) ;
}
} ,
onInsertTable : function ( menu , item ) {
if ( this . api && this . documentHolder . ssMenu . formatTableName ) {
this . api . asc _insertCellsInTable ( this . documentHolder . ssMenu . formatTableName , item . value ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . documentHolder ) ;
Common . component . Analytics . trackEvent ( 'DocumentHolder' , 'Insert to Table' ) ;
}
} ,
onDeleteTable : function ( menu , item ) {
if ( this . api && this . documentHolder . ssMenu . formatTableName ) {
this . api . asc _deleteCellsInTable ( this . documentHolder . ssMenu . formatTableName , item . value ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . documentHolder ) ;
Common . component . Analytics . trackEvent ( 'DocumentHolder' , 'Delete from Table' ) ;
}
} ,
2016-03-11 00:48:53 +00:00
onInsFunction : function ( item ) {
var controller = this . getApplication ( ) . getController ( 'FormulaDialog' ) ;
if ( controller && this . api ) {
controller . showDialog ( ) ;
}
} ,
onInsHyperlink : function ( item ) {
var me = this ;
var win ,
props ;
if ( me . api ) {
var wc = me . api . asc _getWorksheetsCount ( ) ,
i = - 1 ,
items = [ ] ;
while ( ++ i < wc ) {
if ( ! this . api . asc _isWorksheetHidden ( i ) ) {
items . push ( { displayValue : me . api . asc _getWorksheetName ( i ) , value : me . api . asc _getWorksheetName ( i ) } ) ;
}
}
var handlerDlg = function ( dlg , result ) {
if ( result == 'ok' ) {
props = dlg . getSettings ( ) ;
me . api . asc _insertHyperlink ( props ) ;
}
Common . NotificationCenter . trigger ( 'edit:complete' , me . documentHolder ) ;
} ;
var cell = me . api . asc _getCellInfo ( ) ;
props = cell . asc _getHyperlink ( ) ;
win = new SSE . Views . HyperlinkSettingsDialog ( {
api : me . api ,
handler : handlerDlg
} ) ;
win . show ( ) ;
win . setSettings ( {
sheets : items ,
currentSheet : me . api . asc _getWorksheetName ( me . api . asc _getActiveWorksheetIndex ( ) ) ,
props : props ,
text : cell . asc _getText ( ) ,
isLock : cell . asc _getFlags ( ) . asc _getLockText ( ) ,
allowInternal : item . options . inCell
} ) ;
}
Common . component . Analytics . trackEvent ( 'DocumentHolder' , 'Add Hyperlink' ) ;
} ,
onDelHyperlink : function ( item ) {
if ( this . api ) {
this . api . asc _removeHyperlink ( ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . documentHolder ) ;
Common . component . Analytics . trackEvent ( 'DocumentHolder' , 'Remove Hyperlink' ) ;
}
} ,
2016-07-26 12:47:48 +00:00
onSetSize : function ( menu , item ) {
if ( item . value == 'row-height' || item . value == 'column-width' ) {
var me = this ;
( new SSE . Views . SetValueDialog ( {
title : item . caption ,
startvalue : item . value == 'row-height' ? me . api . asc _getRowHeight ( ) : me . api . asc _getColumnWidth ( ) ,
maxvalue : item . value == 'row-height' ? Asc . c _oAscMaxRowHeight : Asc . c _oAscMaxColumnWidth ,
step : item . value == 'row-height' ? 0.75 : 1 ,
defaultUnit : item . value == 'row-height' ? Common . Utils . Metric . getMetricName ( Common . Utils . Metric . c _MetricUnits . pt ) : me . textSym ,
handler : function ( dlg , result ) {
if ( result == 'ok' ) {
var val = dlg . getSettings ( ) ;
if ( ! isNaN ( val ) )
( item . value == 'row-height' ) ? me . api . asc _setRowHeight ( val ) : me . api . asc _setColumnWidth ( val ) ;
}
2016-03-11 00:48:53 +00:00
2016-07-26 12:47:48 +00:00
Common . NotificationCenter . trigger ( 'edit:complete' , me . documentHolder ) ;
}
} ) ) . show ( ) ;
} else {
( item . value == 'auto-row-height' ) ? this . api . asc _autoFitRowHeight ( ) : this . api . asc _autoFitColumnWidth ( ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . documentHolder ) ;
}
2016-03-11 00:48:53 +00:00
} ,
onEntireHide : function ( item ) {
if ( this . api )
this . api [ item . isrowmenu ? 'asc_hideRows' : 'asc_hideColumns' ] ( ) ;
} ,
onEntireShow : function ( item ) {
if ( this . api )
this . api [ item . isrowmenu ? 'asc_showRows' : 'asc_showColumns' ] ( ) ;
} ,
onFreezePanes : function ( item ) {
if ( this . api )
this . api . asc _freezePane ( ) ;
} ,
2016-10-25 13:22:22 +00:00
onEntriesList : function ( item ) {
if ( this . api ) {
var me = this ;
setTimeout ( function ( ) {
me . api . asc _showAutoComplete ( ) ;
} , 10 ) ;
}
} ,
2016-03-11 00:48:53 +00:00
onAddComment : function ( item ) {
if ( this . api && this . permissions . canCoAuthoring && this . permissions . isEdit && this . permissions . canComments ) {
var controller = SSE . getController ( 'Common.Controllers.Comments' ) ,
cellinfo = this . api . asc _getCellInfo ( ) ;
if ( controller ) {
var comments = cellinfo . asc _getComments ( ) ;
if ( comments . length ) {
controller . onEditComments ( comments ) ;
} else if ( this . permissions . canCoAuthoring || this . commentsCollection . getCommentsReplysCount ( ) < 3 ) {
controller . addDummyComment ( ) ;
}
}
}
} ,
onAddNamedRange : function ( item ) {
if ( this . namedrange _locked ) {
Common . NotificationCenter . trigger ( 'namedrange:locked' ) ;
return ;
}
var me = this ,
wc = me . api . asc _getWorksheetsCount ( ) ,
i = - 1 ,
items = [ ] ;
while ( ++ i < wc ) {
if ( ! this . api . asc _isWorksheetHidden ( i ) ) {
items . push ( { displayValue : me . api . asc _getWorksheetName ( i ) , value : i } ) ;
}
}
var handlerDlg = function ( result , settings ) {
if ( result == 'ok' && settings ) {
me . api . asc _setDefinedNames ( settings ) ;
Common . component . Analytics . trackEvent ( 'DocumentHolder' , 'New Named Range' ) ;
}
Common . NotificationCenter . trigger ( 'edit:complete' , me . documentHolder ) ;
} ;
( new SSE . Views . NamedRangeEditDlg ( {
api : me . api ,
handler : handlerDlg ,
sheets : items ,
currentSheet : me . api . asc _getActiveWorksheetIndex ( ) ,
props : me . api . asc _getDefaultDefinedName ( ) ,
isEdit : false
} ) ) . show ( ) ;
} ,
onImgMenu : function ( menu , item ) {
if ( this . api ) {
if ( item . options . type == 'arrange' ) {
this . api . asc _setSelectedDrawingObjectLayer ( item . value ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . documentHolder ) ;
Common . component . Analytics . trackEvent ( 'DocumentHolder' , 'Arrange' ) ;
} else if ( item . options . type == 'group' ) {
this . api [ ( item . value == 'grouping' ) ? 'asc_groupGraphicsObjects' : 'asc_unGroupGraphicsObjects' ] ( ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . documentHolder ) ;
Common . component . Analytics . trackEvent ( 'DocumentHolder' , ( item . value == 'grouping' ) ? 'Grouping' : 'Ungrouping' ) ;
}
}
} ,
onParagraphVAlign : function ( menu , item ) {
if ( this . api ) {
var properties = new Asc . asc _CImgProperty ( ) ;
properties . asc _putVerticalTextAlign ( item . value ) ;
this . api . asc _setGraphicObjectProps ( properties ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . documentHolder ) ;
Common . component . Analytics . trackEvent ( 'DocumentHolder' , 'Paragraph Vertical Align' ) ;
}
} ,
onParagraphDirection : function ( menu , item ) {
if ( this . api ) {
var properties = new Asc . asc _CImgProperty ( ) ;
properties . asc _putVert ( item . options . direction ) ;
this . api . asc _setGraphicObjectProps ( properties ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . documentHolder ) ;
Common . component . Analytics . trackEvent ( 'DocumentHolder' , 'Text Directio' ) ;
}
} ,
onRemoveHyperlinkShape : function ( item ) {
if ( this . api ) {
this . api . asc _removeHyperlink ( ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . documentHolder ) ;
Common . component . Analytics . trackEvent ( 'DocumentHolder' , 'Remove Hyperlink' ) ;
}
} ,
onTextAdvanced : function ( item ) {
var me = this ;
( new SSE . Views . ParagraphSettingsAdvanced ( {
paragraphProps : item . textInfo ,
api : me . api ,
handler : function ( result , value ) {
if ( result == 'ok' ) {
if ( me . api ) {
me . api . asc _setGraphicObjectProps ( value . paragraphProps ) ;
Common . component . Analytics . trackEvent ( 'DocumentHolder' , 'Apply advanced paragraph settings' ) ;
}
}
Common . NotificationCenter . trigger ( 'edit:complete' , me ) ;
}
} ) ) . show ( ) ;
} ,
onShapeAdvanced : function ( item ) {
var me = this ;
( new SSE . Views . ShapeSettingsAdvanced ( {
shapeProps : item . shapeInfo ,
api : me . api ,
handler : function ( result , value ) {
if ( result == 'ok' ) {
if ( me . api ) {
me . api . asc _setGraphicObjectProps ( value . shapeProps ) ;
Common . component . Analytics . trackEvent ( 'DocumentHolder' , 'Apply advanced shape settings' ) ;
}
}
Common . NotificationCenter . trigger ( 'edit:complete' , me ) ;
}
} ) ) . show ( ) ;
} ,
onChartEdit : function ( item ) {
var me = this ;
var win , props ;
if ( me . api ) {
props = me . api . asc _getChartObject ( ) ;
if ( props ) {
( new SSE . Views . ChartSettingsDlg (
{
chartSettings : props ,
api : me . api ,
handler : function ( result , value ) {
if ( result == 'ok' ) {
if ( me . api ) {
me . api . asc _editChartDrawingObject ( value . chartSettings ) ;
}
}
Common . NotificationCenter . trigger ( 'edit:complete' , me ) ;
}
} ) ) . show ( ) ;
}
}
} ,
onApiCoAuthoringDisconnect : function ( ) {
this . permissions . isEdit = false ;
} ,
hideCoAuthTips : function ( ) {
if ( this . tooltips . coauth . ref ) {
$ ( this . tooltips . coauth . ref ) . remove ( ) ;
this . tooltips . coauth . ref = undefined ;
this . tooltips . coauth . x _point = undefined ;
this . tooltips . coauth . y _point = undefined ;
}
} ,
hideHyperlinkTip : function ( ) {
if ( ! this . tooltips . hyperlink . isHidden && this . tooltips . hyperlink . ref ) {
this . tooltips . hyperlink . ref . hide ( ) ;
this . tooltips . hyperlink . isHidden = true ;
}
} ,
onApiMouseMove : function ( dataarray ) {
if ( ! this . _isFullscreenMenu && dataarray . length ) {
var index _hyperlink ,
/** coauthoring begin **/
index _comments ,
/** coauthoring end **/
index _locked ,
index _column , index _row ;
for ( var i = dataarray . length ; i > 0 ; i -- ) {
switch ( dataarray [ i - 1 ] . asc _getType ( ) ) {
2016-04-05 11:52:34 +00:00
case Asc . c _oAscMouseMoveType . Hyperlink :
2016-03-11 00:48:53 +00:00
index _hyperlink = i ;
break ;
/** coauthoring begin **/
2016-04-05 11:52:34 +00:00
case Asc . c _oAscMouseMoveType . Comment :
2016-03-11 00:48:53 +00:00
index _comments = i ;
break ;
/** coauthoring end **/
2016-04-05 11:52:34 +00:00
case Asc . c _oAscMouseMoveType . LockedObject :
2016-03-11 00:48:53 +00:00
index _locked = i ;
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscMouseMoveType . ResizeColumn :
2016-03-11 00:48:53 +00:00
index _column = i ;
break ;
2016-04-05 11:52:34 +00:00
case Asc . c _oAscMouseMoveType . ResizeRow :
2016-03-11 00:48:53 +00:00
index _row = i ;
break ;
}
}
var me = this ,
showPoint = [ 0 , 0 ] ,
/** coauthoring begin **/
coAuthTip = me . tooltips . coauth ,
commentTip = me . tooltips . comment ,
/** coauthoring end **/
hyperlinkTip = me . tooltips . hyperlink ,
row _columnTip = me . tooltips . row _column ,
pos = [
me . documentHolder . cmpEl . offset ( ) . left - $ ( window ) . scrollLeft ( ) ,
me . documentHolder . cmpEl . offset ( ) . top - $ ( window ) . scrollTop ( )
] ;
hyperlinkTip . isHidden = false ;
row _columnTip . isHidden = false ;
/** coauthoring begin **/
var getUserName = function ( id ) {
var usersStore = SSE . getCollection ( 'Common.Collections.Users' ) ;
if ( usersStore ) {
var rec = usersStore . findUser ( id ) ;
if ( rec )
return rec . get ( 'username' ) ;
}
return me . guestText ;
} ;
/** coauthoring end **/
if ( index _hyperlink ) {
var data = dataarray [ index _hyperlink - 1 ] ,
props = data . asc _getHyperlink ( ) ;
2016-04-05 11:52:34 +00:00
if ( props . asc _getType ( ) == Asc . c _oAscHyperlinkType . WebLink ) {
2016-03-11 00:48:53 +00:00
var linkstr = props . asc _getTooltip ( ) ;
if ( linkstr ) {
linkstr = Common . Utils . String . htmlEncode ( linkstr ) + '<br><b>' + me . textCtrlClick + '</b>' ;
} else {
linkstr = props . asc _getHyperlinkUrl ( ) + '<br><b>' + me . textCtrlClick + '</b>' ;
}
} else {
linkstr = props . asc _getTooltip ( ) || ( props . asc _getSheet ( ) + '!' + props . asc _getRange ( ) ) ;
}
if ( hyperlinkTip . ref && hyperlinkTip . ref . isVisible ( ) ) {
if ( hyperlinkTip . text != linkstr ) {
hyperlinkTip . ref . hide ( ) ;
hyperlinkTip . isHidden = true ;
}
}
if ( ! hyperlinkTip . ref || ! hyperlinkTip . ref . isVisible ( ) ) {
hyperlinkTip . text = linkstr ;
hyperlinkTip . ref = new Common . UI . Tooltip ( {
owner : me . documentHolder ,
html : true ,
title : linkstr
} ) . on ( 'tooltip:hide' , function ( tip ) {
hyperlinkTip . ref = undefined ;
hyperlinkTip . text = '' ;
} ) ;
hyperlinkTip . ref . show ( [ - 10000 , - 10000 ] ) ;
hyperlinkTip . isHidden = false ;
}
showPoint = [ data . asc _getX ( ) , data . asc _getY ( ) ] ;
showPoint [ 0 ] += ( pos [ 0 ] + 6 ) ;
showPoint [ 1 ] += ( pos [ 1 ] - 20 ) ;
showPoint [ 1 ] -= hyperlinkTip . ref . getBSTip ( ) . $tip . height ( ) ;
var tipwidth = hyperlinkTip . ref . getBSTip ( ) . $tip . width ( ) ;
if ( showPoint [ 0 ] + tipwidth > me . tooltips . coauth . bodyWidth )
showPoint [ 0 ] = me . tooltips . coauth . bodyWidth - tipwidth ;
hyperlinkTip . ref . getBSTip ( ) . $tip . css ( {
top : showPoint [ 1 ] + 'px' ,
left : showPoint [ 0 ] + 'px'
} ) ;
} else {
me . hideHyperlinkTip ( ) ;
}
if ( index _column !== undefined || index _row !== undefined ) {
var data = dataarray [ ( index _column !== undefined ) ? ( index _column - 1 ) : ( index _row - 1 ) ] ;
2016-11-11 08:47:22 +00:00
var str = Common . Utils . String . format ( ( index _column !== undefined ) ? this . textChangeColumnWidth : this . textChangeRowHeight , data . asc _getSizeCCOrPt ( ) . toFixed ( 2 ) , data . asc _getSizePx ( ) . toFixed ( ) ) ;
2016-03-11 00:48:53 +00:00
if ( row _columnTip . ref && row _columnTip . ref . isVisible ( ) ) {
if ( row _columnTip . text != str ) {
row _columnTip . text = str ;
row _columnTip . ref . setTitle ( str ) ;
row _columnTip . ref . updateTitle ( ) ;
}
}
if ( ! row _columnTip . ref || ! row _columnTip . ref . isVisible ( ) ) {
row _columnTip . text = str ;
row _columnTip . ref = new Common . UI . Tooltip ( {
owner : me . documentHolder ,
html : true ,
title : str
} ) . on ( 'tooltip:hide' , function ( tip ) {
row _columnTip . ref = undefined ;
row _columnTip . text = '' ;
} ) ;
row _columnTip . ref . show ( [ - 10000 , - 10000 ] ) ;
row _columnTip . isHidden = false ;
showPoint = [ data . asc _getX ( ) , data . asc _getY ( ) ] ;
showPoint [ 0 ] += ( pos [ 0 ] + 6 ) ;
showPoint [ 1 ] += ( pos [ 1 ] - 20 - row _columnTip . ttHeight ) ;
var tipwidth = row _columnTip . ref . getBSTip ( ) . $tip . width ( ) ;
if ( showPoint [ 0 ] + tipwidth > me . tooltips . coauth . bodyWidth )
showPoint [ 0 ] = me . tooltips . coauth . bodyWidth - tipwidth - 20 ;
row _columnTip . ref . getBSTip ( ) . $tip . css ( {
top : showPoint [ 1 ] + 'px' ,
left : showPoint [ 0 ] + 'px'
} ) ;
}
} else {
if ( ! row _columnTip . isHidden && row _columnTip . ref ) {
row _columnTip . ref . hide ( ) ;
row _columnTip . isHidden = true ;
}
}
if ( me . permissions . isEdit ) {
if ( index _comments && ! this . popupmenu ) {
data = dataarray [ index _comments - 1 ] ;
if ( ! commentTip . editCommentId && commentTip . moveCommentId != data . asc _getCommentIndexes ( ) [ 0 ] ) {
commentTip . moveCommentId = data . asc _getCommentIndexes ( ) [ 0 ] ;
if ( commentTip . moveCommentTimer ) {
clearTimeout ( commentTip . moveCommentTimer ) ;
}
var idxs = data . asc _getCommentIndexes ( ) ,
x = data . asc _getX ( ) ,
y = data . asc _getY ( ) ,
leftx = data . asc _getReverseX ( ) ;
commentTip . moveCommentTimer = setTimeout ( function ( ) {
if ( commentTip . moveCommentId && ! commentTip . editCommentId ) {
commentTip . viewCommentId = commentTip . moveCommentId ;
var commentsController = me . getApplication ( ) . getController ( 'Common.Controllers.Comments' ) ;
if ( commentsController ) {
if ( ! commentsController . isSelectedComment ) {
commentsController . onApiShowComment ( idxs , x , y , leftx , false , true ) ;
}
}
}
} , 400 ) ;
}
} else {
commentTip . moveCommentId = undefined ;
if ( commentTip . viewCommentId != undefined ) {
commentTip = { } ;
var commentsController = this . getApplication ( ) . getController ( 'Common.Controllers.Comments' ) ;
if ( commentsController ) {
if ( this . permissions . canCoAuthoring && this . permissions . canComments )
setTimeout ( function ( ) { commentsController . onApiHideComment ( true ) ; } , 200 ) ;
else
commentsController . onApiHideComment ( true ) ;
}
}
}
if ( index _locked ) {
data = dataarray [ index _locked - 1 ] ;
if ( ! coAuthTip . XY )
me . onDocumentResize ( ) ;
if ( coAuthTip . x _point != data . asc _getX ( ) || coAuthTip . y _point != data . asc _getY ( ) ) {
me . hideCoAuthTips ( ) ;
coAuthTip . x _point = data . asc _getX ( ) ;
coAuthTip . y _point = data . asc _getY ( ) ;
var src = $ ( document . createElement ( "div" ) ) ,
2016-04-05 11:52:34 +00:00
is _sheet _lock = data . asc _getLockedObjectType ( ) == Asc . c _oAscMouseMoveLockedObjectType . Sheet ||
data . asc _getLockedObjectType ( ) == Asc . c _oAscMouseMoveLockedObjectType . TableProperties ;
2016-03-11 00:48:53 +00:00
coAuthTip . ref = src ;
src . addClass ( 'username-tip' ) ;
src . css ( {
height : coAuthTip . ttHeight + 'px' ,
position : 'absolute' ,
zIndex : '900' ,
visibility : 'visible'
} ) ;
$ ( document . body ) . append ( src ) ;
showPoint = [
coAuthTip . x _point + coAuthTip . XY [ 0 ] ,
coAuthTip . y _point + coAuthTip . XY [ 1 ]
] ;
! is _sheet _lock && ( showPoint [ 0 ] = coAuthTip . bodyWidth - showPoint [ 0 ] ) ;
if ( showPoint [ 1 ] > coAuthTip . XY [ 1 ] &&
showPoint [ 1 ] + coAuthTip . ttHeight < coAuthTip . XY [ 1 ] + coAuthTip . apiHeight ) {
src . text ( getUserName ( data . asc _getUserId ( ) ) ) ;
if ( coAuthTip . bodyWidth - showPoint [ 0 ] < coAuthTip . ref . width ( ) ) {
src . css ( {
visibility : 'visible' ,
left : '0px' ,
top : ( showPoint [ 1 ] - coAuthTip . ttHeight ) + 'px'
} ) ;
} else
src . css ( {
visibility : 'visible' ,
right : showPoint [ 0 ] + 'px' ,
top : showPoint [ 1 ] + 'px'
} ) ;
}
}
} else {
me . hideCoAuthTips ( ) ;
}
}
}
} ,
onApiHideComment : function ( ) {
this . tooltips . comment . viewCommentId =
this . tooltips . comment . editCommentId =
this . tooltips . comment . moveCommentId = undefined ;
} ,
onApiHyperlinkClick : function ( url ) {
2016-08-05 11:40:47 +00:00
if ( ! url ) {
Common . UI . alert ( {
msg : this . errorInvalidLink ,
title : this . notcriticalErrorTitle ,
iconCls : 'warn' ,
buttons : [ 'ok' ] ,
callback : _ . bind ( function ( btn ) {
Common . NotificationCenter . trigger ( 'edit:complete' , this . documentHolder ) ;
} , this )
} ) ;
return ;
}
if ( this . api . asc _getUrlType ( url ) > 0 ) {
2016-03-11 00:48:53 +00:00
var newDocumentPage = window . open ( url , '_blank' ) ;
if ( newDocumentPage )
newDocumentPage . focus ( ) ;
}
} ,
onApiAutofilter : function ( config ) {
var me = this ;
2016-05-20 11:28:40 +00:00
if ( me . permissions . isEdit && ! me . dlgFilter ) {
me . dlgFilter = new SSE . Views . AutoFilterDialog ( { api : this . api } ) . on ( {
2016-03-11 00:48:53 +00:00
'close' : function ( ) {
if ( me . api ) {
me . api . asc _enableKeyEvents ( true ) ;
}
2016-05-20 11:28:40 +00:00
me . dlgFilter = undefined ;
2016-03-11 00:48:53 +00:00
}
} ) ;
if ( me . api ) {
me . api . asc _enableKeyEvents ( false ) ;
}
Common . UI . Menu . Manager . hideAll ( ) ;
2016-05-20 11:28:40 +00:00
me . dlgFilter . setSettings ( config ) ;
var offset = me . documentHolder . cmpEl . offset ( ) ,
2016-05-20 12:07:29 +00:00
rect = config . asc _getCellCoord ( ) ,
x = rect . asc _getX ( ) + rect . asc _getWidth ( ) + offset . left ,
y = rect . asc _getY ( ) + rect . asc _getHeight ( ) + offset . top ;
2016-08-19 13:41:48 +00:00
var docwidth = Common . Utils . innerWidth ( ) ,
docheight = Common . Utils . innerHeight ( ) ;
2016-05-20 11:54:29 +00:00
if ( x + me . dlgFilter . options . width > docwidth )
x = docwidth - me . dlgFilter . options . width - 5 ;
if ( y + me . dlgFilter . options . height > docheight )
y = docheight - me . dlgFilter . options . height - 5 ;
2016-05-20 11:28:40 +00:00
me . dlgFilter . show ( x , y ) ;
2016-03-11 00:48:53 +00:00
}
} ,
onApiContextMenu : function ( event ) {
var me = this ;
_ . delay ( function ( ) {
me . showObjectMenu . call ( me , event ) ;
} , 10 ) ;
} ,
onAfterRender : function ( view ) {
} ,
onDocumentResize : function ( e ) {
var me = this ;
if ( me . documentHolder ) {
me . tooltips . coauth . XY = [
me . documentHolder . cmpEl . offset ( ) . left - $ ( window ) . scrollLeft ( ) ,
me . documentHolder . cmpEl . offset ( ) . top - $ ( window ) . scrollTop ( )
] ;
me . tooltips . coauth . apiHeight = me . documentHolder . cmpEl . height ( ) ;
me . tooltips . coauth . bodyWidth = $ ( window ) . width ( ) ;
}
} ,
onDocumentWheel : function ( e ) {
if ( this . api && ! this . isEditCell ) {
var delta = ( _ . isUndefined ( e . originalEvent ) ) ? e . wheelDelta : e . originalEvent . wheelDelta ;
if ( _ . isUndefined ( delta ) ) {
delta = e . deltaY ;
}
if ( ( e . ctrlKey || e . metaKey ) && ! e . altKey ) {
var factor = this . api . asc _getZoom ( ) ;
if ( delta < 0 ) {
factor = Math . ceil ( factor * 10 ) / 10 ;
factor -= 0.1 ;
if ( ! ( factor < . 5 ) ) {
this . api . asc _setZoom ( factor ) ;
}
} else if ( delta > 0 ) {
factor = Math . floor ( factor * 10 ) / 10 ;
factor += 0.1 ;
if ( factor > 0 && ! ( factor > 2. ) ) {
this . api . asc _setZoom ( factor ) ;
}
}
e . preventDefault ( ) ;
e . stopPropagation ( ) ;
}
}
} ,
onDocumentKeyDown : function ( event ) {
if ( this . api ) {
var key = event . keyCode ;
if ( ( event . ctrlKey || event . metaKey ) && ! event . shiftKey && ! event . altKey ) {
if ( key === Common . UI . Keys . NUM _PLUS || key === Common . UI . Keys . EQUALITY || ( Common . Utils . isOpera && key == 43 ) ) {
if ( ! this . api . isCellEdited ) {
var factor = Math . floor ( this . api . asc _getZoom ( ) * 10 ) / 10 ;
factor += . 1 ;
if ( factor > 0 && ! ( factor > 2. ) ) {
this . api . asc _setZoom ( factor ) ;
}
event . preventDefault ( ) ;
event . stopPropagation ( ) ;
return false ;
}
} else if ( key === Common . UI . Keys . NUM _MINUS || key === Common . UI . Keys . MINUS || ( Common . Utils . isOpera && key == 45 ) ) {
if ( ! this . api . isCellEdited ) {
factor = Math . ceil ( this . api . asc _getZoom ( ) * 10 ) / 10 ;
factor -= . 1 ;
if ( ! ( factor < . 5 ) ) {
this . api . asc _setZoom ( factor ) ;
}
event . preventDefault ( ) ;
event . stopPropagation ( ) ;
return false ;
}
}
} else
if ( key == Common . UI . Keys . F10 && event . shiftKey ) {
this . showObjectMenu ( event ) ;
event . preventDefault ( ) ;
event . stopPropagation ( ) ;
return false ;
}
}
} ,
onDocumentRightDown : function ( event ) {
event . button == 0 && ( this . mouse . isLeftButtonDown = true ) ;
// event.button == 2 && (this.mouse.isRightButtonDown = true);
} ,
onDocumentRightUp : function ( event ) {
event . button == 0 && ( this . mouse . isLeftButtonDown = false ) ;
} ,
showObjectMenu : function ( event ) {
if ( this . api && this . permissions . isEdit && ! this . mouse . isLeftButtonDown && ! this . rangeSelectionMode ) {
this . fillMenuProps ( this . api . asc _getCellInfo ( ) , true , event ) ;
}
} ,
onSelectionChanged : function ( info ) {
if ( this . permissions . isEdit && ! this . mouse . isLeftButtonDown && ! this . rangeSelectionMode &&
this . currentMenu && this . currentMenu . isVisible ( ) ) {
this . fillMenuProps ( info ) ;
}
} ,
fillMenuProps : function ( cellinfo , showMenu , event ) {
var iscellmenu , isrowmenu , iscolmenu , isallmenu , ischartmenu , isimagemenu , istextshapemenu , isshapemenu , istextchartmenu ,
documentHolder = this . documentHolder ,
seltype = cellinfo . asc _getFlags ( ) . asc _getSelectionType ( ) ,
isCellLocked = cellinfo . asc _getLocked ( ) ,
isObjLocked = false ,
commentsController = this . getApplication ( ) . getController ( 'Common.Controllers.Comments' ) ,
insfunc = false ,
cansort = false ;
if ( this . permissions . isEditMailMerge ) {
2016-04-05 11:52:34 +00:00
cansort = ( seltype == Asc . c _oAscSelectionType . RangeCells ) ;
2016-03-11 00:48:53 +00:00
} else if ( this . permissions . isEditDiagram ) {
2016-04-05 11:52:34 +00:00
insfunc = ( seltype == Asc . c _oAscSelectionType . RangeCells ) ;
2016-03-11 00:48:53 +00:00
}
else {
switch ( seltype ) {
2016-04-05 11:52:34 +00:00
case Asc . c _oAscSelectionType . RangeCells : iscellmenu = true ; break ;
case Asc . c _oAscSelectionType . RangeRow : isrowmenu = true ; break ;
case Asc . c _oAscSelectionType . RangeCol : iscolmenu = true ; break ;
case Asc . c _oAscSelectionType . RangeMax : isallmenu = true ; break ;
case Asc . c _oAscSelectionType . RangeImage : isimagemenu = true ; break ;
case Asc . c _oAscSelectionType . RangeShape : isshapemenu = true ; break ;
case Asc . c _oAscSelectionType . RangeChart : ischartmenu = true ; break ;
case Asc . c _oAscSelectionType . RangeChartText : istextchartmenu = true ; break ;
case Asc . c _oAscSelectionType . RangeShapeText : istextshapemenu = true ; break ;
2016-03-11 00:48:53 +00:00
}
}
if ( isimagemenu || isshapemenu || ischartmenu ) {
if ( ! showMenu && ! documentHolder . imgMenu . isVisible ( ) ) return ;
isimagemenu = isshapemenu = ischartmenu = false ;
var has _chartprops = false ;
var selectedObjects = this . api . asc _getGraphicObjectProps ( ) ;
for ( var i = 0 ; i < selectedObjects . length ; i ++ ) {
2016-04-05 11:52:34 +00:00
if ( selectedObjects [ i ] . asc _getObjectType ( ) == Asc . c _oAscTypeSelectElement . Image ) {
2016-03-11 00:48:53 +00:00
var elValue = selectedObjects [ i ] . asc _getObjectValue ( ) ;
isObjLocked = isObjLocked || elValue . asc _getLocked ( ) ;
var shapeprops = elValue . asc _getShapeProperties ( ) ;
if ( shapeprops ) {
if ( shapeprops . asc _getFromChart ( ) )
ischartmenu = true ;
else {
documentHolder . mnuShapeAdvanced . shapeInfo = elValue ;
isshapemenu = true ;
}
} else if ( elValue . asc _getChartProperties ( ) ) {
ischartmenu = true ;
has _chartprops = true ;
}
else
isimagemenu = true ;
}
}
documentHolder . mnuUnGroupImg . setDisabled ( isObjLocked || ! this . api . asc _canUnGroupGraphicsObjects ( ) ) ;
documentHolder . mnuGroupImg . setDisabled ( isObjLocked || ! this . api . asc _canGroupGraphicsObjects ( ) ) ;
documentHolder . mnuShapeAdvanced . setVisible ( isshapemenu && ! isimagemenu && ! ischartmenu ) ;
documentHolder . mnuShapeAdvanced . setDisabled ( isObjLocked ) ;
documentHolder . mnuChartEdit . setVisible ( ischartmenu && ! isimagemenu && ! isshapemenu && has _chartprops ) ;
documentHolder . mnuChartEdit . setDisabled ( isObjLocked ) ;
documentHolder . pmiImgCut . setDisabled ( isObjLocked ) ;
documentHolder . pmiImgPaste . setDisabled ( isObjLocked ) ;
if ( showMenu ) this . showPopupMenu ( documentHolder . imgMenu , { } , event ) ;
documentHolder . mnuShapeSeparator . setVisible ( documentHolder . mnuShapeAdvanced . isVisible ( ) || documentHolder . mnuChartEdit . isVisible ( ) ) ;
} else if ( istextshapemenu || istextchartmenu ) {
if ( ! showMenu && ! documentHolder . textInShapeMenu . isVisible ( ) ) return ;
documentHolder . pmiTextAdvanced . textInfo = undefined ;
2016-10-24 11:56:11 +00:00
var selectedObjects = this . api . asc _getGraphicObjectProps ( ) ,
isEquation = false ;
2016-03-11 00:48:53 +00:00
for ( var i = 0 ; i < selectedObjects . length ; i ++ ) {
var elType = selectedObjects [ i ] . asc _getObjectType ( ) ;
2016-04-05 11:52:34 +00:00
if ( elType == Asc . c _oAscTypeSelectElement . Image ) {
2016-03-11 00:48:53 +00:00
var value = selectedObjects [ i ] . asc _getObjectValue ( ) ,
align = value . asc _getVerticalTextAlign ( ) ,
direct = value . asc _getVert ( ) ;
isObjLocked = isObjLocked || value . asc _getLocked ( ) ;
2016-11-10 11:24:18 +00:00
documentHolder . menuParagraphTop . setChecked ( align == Asc . c _oAscVAlign . Top ) ;
documentHolder . menuParagraphCenter . setChecked ( align == Asc . c _oAscVAlign . Center ) ;
documentHolder . menuParagraphBottom . setChecked ( align == Asc . c _oAscVAlign . Bottom ) ;
2016-04-05 11:52:34 +00:00
documentHolder . menuParagraphDirectH . setChecked ( direct == Asc . c _oAscVertDrawingText . normal ) ;
documentHolder . menuParagraphDirect90 . setChecked ( direct == Asc . c _oAscVertDrawingText . vert ) ;
documentHolder . menuParagraphDirect270 . setChecked ( direct == Asc . c _oAscVertDrawingText . vert270 ) ;
} else if ( elType == Asc . c _oAscTypeSelectElement . Paragraph ) {
2016-03-11 00:48:53 +00:00
documentHolder . pmiTextAdvanced . textInfo = selectedObjects [ i ] . asc _getObjectValue ( ) ;
isObjLocked = isObjLocked || documentHolder . pmiTextAdvanced . textInfo . asc _getLocked ( ) ;
2016-10-24 11:56:11 +00:00
} else if ( elType == Asc . c _oAscTypeSelectElement . Math ) {
this . _currentMathObj = selectedObjects [ i ] . asc _getObjectValue ( ) ;
isEquation = true ;
2016-03-11 00:48:53 +00:00
}
}
var hyperinfo = cellinfo . asc _getHyperlink ( ) ,
can _add _hyperlink = this . api . asc _canAddShapeHyperlink ( ) ;
documentHolder . menuHyperlinkShape . setVisible ( istextshapemenu && can _add _hyperlink !== false && hyperinfo ) ;
documentHolder . menuAddHyperlinkShape . setVisible ( istextshapemenu && can _add _hyperlink !== false && ! hyperinfo ) ;
2016-10-24 11:56:11 +00:00
documentHolder . menuParagraphVAlign . setVisible ( istextchartmenu !== true && ! isEquation ) ; // убрать после того, как заголовок можно будет растягивать по вертикали!!
documentHolder . menuParagraphDirection . setVisible ( istextchartmenu !== true && ! isEquation ) ; // убрать после того, как заголовок можно будет растягивать по вертикали!!
2016-03-11 00:48:53 +00:00
documentHolder . pmiTextAdvanced . setVisible ( documentHolder . pmiTextAdvanced . textInfo !== undefined ) ;
2016-10-24 11:56:11 +00:00
2016-03-11 00:48:53 +00:00
_ . each ( documentHolder . textInShapeMenu . items , function ( item ) {
item . setDisabled ( isObjLocked ) ;
} ) ;
documentHolder . pmiTextCopy . setDisabled ( false ) ;
2016-10-24 11:56:11 +00:00
//equation menu
var eqlen = 0 ;
this . _currentParaObjDisabled = isObjLocked ;
if ( isEquation ) {
eqlen = this . addEquationMenu ( 4 ) ;
} else
this . clearEquationMenu ( 4 ) ;
2016-03-11 00:48:53 +00:00
if ( showMenu ) this . showPopupMenu ( documentHolder . textInShapeMenu , { } , event ) ;
documentHolder . textInShapeMenu . items [ 3 ] . setVisible ( documentHolder . menuHyperlinkShape . isVisible ( ) ||
documentHolder . menuAddHyperlinkShape . isVisible ( ) ||
2016-10-24 13:40:06 +00:00
documentHolder . menuParagraphVAlign . isVisible ( ) || isEquation ) ;
2016-04-05 11:52:34 +00:00
} else if ( ! this . permissions . isEditMailMerge && ! this . permissions . isEditDiagram || ( seltype !== Asc . c _oAscSelectionType . RangeImage && seltype !== Asc . c _oAscSelectionType . RangeShape &&
seltype !== Asc . c _oAscSelectionType . RangeChart && seltype !== Asc . c _oAscSelectionType . RangeChartText && seltype !== Asc . c _oAscSelectionType . RangeShapeText ) ) {
2016-03-11 00:48:53 +00:00
if ( ! showMenu && ! documentHolder . ssMenu . isVisible ( ) ) return ;
2016-03-30 12:27:16 +00:00
var iscelledit = this . api . isCellEdited ,
formatTableInfo = cellinfo . asc _getFormatTableInfo ( ) ,
2016-11-01 15:04:35 +00:00
isintable = ( formatTableInfo !== null ) ,
ismultiselect = cellinfo . asc _getFlags ( ) . asc _getMultiselect ( ) ;
2016-03-30 12:27:16 +00:00
documentHolder . ssMenu . formatTableName = ( isintable ) ? formatTableInfo . asc _getTableName ( ) : null ;
2016-05-17 08:01:41 +00:00
documentHolder . ssMenu . cellColor = cellinfo . asc _getFill ( ) . asc _getColor ( ) ;
documentHolder . ssMenu . fontColor = cellinfo . asc _getFont ( ) . asc _getColor ( ) ;
2016-03-11 00:48:53 +00:00
documentHolder . pmiInsertEntire . setVisible ( isrowmenu || iscolmenu ) ;
documentHolder . pmiInsertEntire . setCaption ( ( isrowmenu ) ? this . textInsertTop : this . textInsertLeft ) ;
documentHolder . pmiDeleteEntire . setVisible ( isrowmenu || iscolmenu ) ;
2016-03-30 12:27:16 +00:00
documentHolder . pmiInsertCells . setVisible ( iscellmenu && ! iscelledit && ! isintable ) ;
documentHolder . pmiDeleteCells . setVisible ( iscellmenu && ! iscelledit && ! isintable ) ;
documentHolder . pmiSelectTable . setVisible ( iscellmenu && ! iscelledit && isintable ) ;
documentHolder . pmiInsertTable . setVisible ( iscellmenu && ! iscelledit && isintable ) ;
documentHolder . pmiDeleteTable . setVisible ( iscellmenu && ! iscelledit && isintable ) ;
2016-05-17 08:01:41 +00:00
documentHolder . pmiSortCells . setVisible ( ( iscellmenu || isallmenu || cansort ) && ! iscelledit ) ;
documentHolder . pmiFilterCells . setVisible ( ( iscellmenu || cansort ) && ! iscelledit ) ;
documentHolder . pmiReapply . setVisible ( ( iscellmenu || isallmenu || cansort ) && ! iscelledit ) ;
documentHolder . ssMenu . items [ 12 ] . setVisible ( ( iscellmenu || isallmenu || cansort ) && ! iscelledit ) ;
2016-03-11 00:48:53 +00:00
documentHolder . pmiInsFunction . setVisible ( iscellmenu || insfunc ) ;
documentHolder . pmiAddNamedRange . setVisible ( iscellmenu && ! iscelledit ) ;
2016-04-01 13:30:53 +00:00
if ( isintable ) {
documentHolder . pmiInsertTable . menu . items [ 0 ] . setDisabled ( ! formatTableInfo . asc _getIsInsertRowAbove ( ) ) ;
documentHolder . pmiInsertTable . menu . items [ 1 ] . setDisabled ( ! formatTableInfo . asc _getIsInsertRowBelow ( ) ) ;
documentHolder . pmiInsertTable . menu . items [ 2 ] . setDisabled ( ! formatTableInfo . asc _getIsInsertColumnLeft ( ) ) ;
documentHolder . pmiInsertTable . menu . items [ 3 ] . setDisabled ( ! formatTableInfo . asc _getIsInsertColumnRight ( ) ) ;
documentHolder . pmiDeleteTable . menu . items [ 0 ] . setDisabled ( ! formatTableInfo . asc _getIsDeleteRow ( ) ) ;
documentHolder . pmiDeleteTable . menu . items [ 1 ] . setDisabled ( ! formatTableInfo . asc _getIsDeleteColumn ( ) ) ;
documentHolder . pmiDeleteTable . menu . items [ 2 ] . setDisabled ( ! formatTableInfo . asc _getIsDeleteTable ( ) ) ;
}
2016-03-11 00:48:53 +00:00
var hyperinfo = cellinfo . asc _getHyperlink ( ) ;
2016-11-01 15:04:35 +00:00
documentHolder . menuHyperlink . setVisible ( iscellmenu && hyperinfo && ! iscelledit && ! ismultiselect ) ;
documentHolder . menuAddHyperlink . setVisible ( iscellmenu && ! hyperinfo && ! iscelledit && ! ismultiselect ) ;
2016-03-11 00:48:53 +00:00
documentHolder . pmiRowHeight . setVisible ( isrowmenu || isallmenu ) ;
documentHolder . pmiColumnWidth . setVisible ( iscolmenu || isallmenu ) ;
documentHolder . pmiEntireHide . setVisible ( iscolmenu || isrowmenu ) ;
documentHolder . pmiEntireShow . setVisible ( iscolmenu || isrowmenu ) ;
documentHolder . pmiFreezePanes . setVisible ( ! iscelledit ) ;
documentHolder . pmiFreezePanes . setCaption ( this . api . asc _getSheetViewSettings ( ) . asc _getIsFreezePane ( ) ? documentHolder . textUnFreezePanes : documentHolder . textFreezePanes ) ;
2016-10-25 13:22:22 +00:00
documentHolder . pmiEntriesList . setVisible ( ! iscelledit ) ;
2016-03-11 00:48:53 +00:00
/** coauthoring begin **/
2016-05-17 08:01:41 +00:00
documentHolder . ssMenu . items [ 16 ] . setVisible ( iscellmenu && ! iscelledit && this . permissions . canCoAuthoring && this . permissions . canComments ) ;
2016-03-11 00:48:53 +00:00
documentHolder . pmiAddComment . setVisible ( iscellmenu && ! iscelledit && this . permissions . canCoAuthoring && this . permissions . canComments ) ;
/** coauthoring end **/
documentHolder . pmiCellMenuSeparator . setVisible ( iscellmenu || isrowmenu || iscolmenu || isallmenu || insfunc ) ;
documentHolder . pmiEntireHide . isrowmenu = isrowmenu ;
documentHolder . pmiEntireShow . isrowmenu = isrowmenu ;
documentHolder . setMenuItemCommentCaptionMode ( cellinfo . asc _getComments ( ) . length > 0 ) ;
commentsController && commentsController . blockPopover ( true ) ;
documentHolder . pmiClear . menu . items [ 1 ] . setDisabled ( iscelledit ) ;
documentHolder . pmiClear . menu . items [ 2 ] . setDisabled ( iscelledit ) ;
documentHolder . pmiClear . menu . items [ 3 ] . setDisabled ( iscelledit ) ;
documentHolder . pmiClear . menu . items [ 4 ] . setDisabled ( iscelledit ) ;
documentHolder . pmiClear . menu . items [ 3 ] . setVisible ( ! this . permissions . isEditDiagram ) ;
documentHolder . pmiClear . menu . items [ 4 ] . setVisible ( ! this . permissions . isEditDiagram ) ;
2016-05-17 08:01:41 +00:00
var filterInfo = cellinfo . asc _getAutoFilterInfo ( ) ,
isApplyAutoFilter = ( filterInfo ) ? filterInfo . asc _getIsApplyAutoFilter ( ) : false ;
filterInfo = ( filterInfo ) ? filterInfo . asc _getIsAutoFilter ( ) : null ;
documentHolder . pmiInsertCells . menu . items [ 0 ] . setDisabled ( isApplyAutoFilter ) ;
documentHolder . pmiDeleteCells . menu . items [ 0 ] . setDisabled ( isApplyAutoFilter ) ;
documentHolder . pmiInsertCells . menu . items [ 1 ] . setDisabled ( isApplyAutoFilter ) ;
documentHolder . pmiDeleteCells . menu . items [ 1 ] . setDisabled ( isApplyAutoFilter ) ;
2016-03-11 00:48:53 +00:00
_ . each ( documentHolder . ssMenu . items , function ( item ) {
item . setDisabled ( isCellLocked ) ;
} ) ;
documentHolder . pmiCopy . setDisabled ( false ) ;
2016-10-11 11:08:41 +00:00
documentHolder . pmiFilterCells . setDisabled ( isCellLocked || ( filterInfo == null ) ) ;
2016-05-17 08:01:41 +00:00
documentHolder . pmiSortCells . setDisabled ( isCellLocked || ( filterInfo == null ) ) ;
2016-05-17 08:21:28 +00:00
documentHolder . pmiReapply . setDisabled ( isCellLocked || ( isApplyAutoFilter !== true ) ) ;
2016-03-11 00:48:53 +00:00
if ( showMenu ) this . showPopupMenu ( documentHolder . ssMenu , { } , event ) ;
2016-04-05 11:52:34 +00:00
} else if ( this . permissions . isEditDiagram && seltype == Asc . c _oAscSelectionType . RangeChartText ) {
2016-03-11 00:48:53 +00:00
if ( ! showMenu && ! documentHolder . textInShapeMenu . isVisible ( ) ) return ;
documentHolder . pmiTextAdvanced . textInfo = undefined ;
documentHolder . menuHyperlinkShape . setVisible ( false ) ;
documentHolder . menuAddHyperlinkShape . setVisible ( false ) ;
documentHolder . menuParagraphVAlign . setVisible ( false ) ; // убрать после того, как заголовок можно будет растягивать по вертикали!!
documentHolder . menuParagraphDirection . setVisible ( false ) ; // убрать после того, как заголовок можно будет растягивать по вертикали!!
documentHolder . pmiTextAdvanced . setVisible ( false ) ;
documentHolder . textInShapeMenu . items [ 3 ] . setVisible ( false ) ;
documentHolder . textInShapeMenu . items [ 8 ] . setVisible ( false ) ;
documentHolder . pmiTextCopy . setDisabled ( false ) ;
if ( showMenu ) this . showPopupMenu ( documentHolder . textInShapeMenu , { } , event ) ;
}
} ,
showPopupMenu : function ( menu , value , event ) {
if ( ! _ . isUndefined ( menu ) && menu !== null ) {
Common . UI . Menu . Manager . hideAll ( ) ;
var me = this ,
documentHolderView = me . documentHolder ,
2016-08-19 13:41:48 +00:00
showPoint = [ event . pageX * Common . Utils . zoom ( ) - documentHolderView . cmpEl . offset ( ) . left , event . pageY * Common . Utils . zoom ( ) - documentHolderView . cmpEl . offset ( ) . top ] ,
2016-03-11 00:48:53 +00:00
menuContainer = documentHolderView . cmpEl . 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 ) ) ;
documentHolderView . cmpEl . append ( menuContainer ) ;
}
menu . render ( menuContainer ) ;
menu . cmpEl . attr ( { tabindex : "-1" } ) ;
}
if ( /*!this.mouse.isRightButtonDown &&*/ event . button !== 2 ) {
var coord = me . api . asc _getActiveCellCoord ( ) ,
offset = { left : 0 , top : 0 } /*documentHolderView.cmpEl.offset()*/ ;
showPoint [ 0 ] = coord . asc _getX ( ) + coord . asc _getWidth ( ) + offset . left ;
showPoint [ 1 ] = ( coord . asc _getY ( ) < 0 ? 0 : coord . asc _getY ( ) ) + coord . asc _getHeight ( ) + offset . top ;
}
menuContainer . css ( {
left : showPoint [ 0 ] ,
top : showPoint [ 1 ]
} ) ;
if ( _ . isFunction ( menu . options . initMenu ) ) {
menu . options . initMenu ( value ) ;
menu . alignPosition ( ) ;
}
_ . delay ( function ( ) {
menu . cmpEl . focus ( ) ;
} , 10 ) ;
menu . show ( ) ;
me . currentMenu = menu ;
}
} ,
onEntriesListMenu : function ( textarr ) {
if ( textarr && textarr . length > 0 ) {
var me = this ,
documentHolderView = me . documentHolder ,
menu = documentHolderView . entriesMenu ,
menuContainer = documentHolderView . cmpEl . find ( Common . Utils . String . format ( '#menu-container-{0}' , menu . id ) ) ;
for ( var i = 0 ; i < menu . items . length ; i ++ ) {
menu . removeItem ( menu . items [ i ] ) ;
i -- ;
}
_ . each ( textarr , function ( menuItem , index ) {
var mnu = new Common . UI . MenuItem ( {
caption : menuItem
} ) . on ( 'click' , function ( item , e ) {
2016-04-05 11:52:34 +00:00
me . api . asc _insertFormula ( item . caption , Asc . c _oAscPopUpSelectorType . None , false ) ;
2016-03-11 00:48:53 +00:00
} ) ;
menu . addItem ( mnu ) ;
} ) ;
Common . UI . Menu . Manager . hideAll ( ) ;
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 ) ) ;
documentHolderView . cmpEl . append ( menuContainer ) ;
}
menu . render ( menuContainer ) ;
menu . cmpEl . attr ( { tabindex : "-1" } ) ;
}
var coord = me . api . asc _getActiveCellCoord ( ) ,
offset = { left : 0 , top : 0 } ,
showPoint = [ coord . asc _getX ( ) + offset . left , ( coord . asc _getY ( ) < 0 ? 0 : coord . asc _getY ( ) ) + coord . asc _getHeight ( ) + offset . top ] ;
menuContainer . css ( { left : showPoint [ 0 ] , top : showPoint [ 1 ] } ) ;
menu . show ( ) ;
menu . alignPosition ( ) ;
_ . delay ( function ( ) {
menu . cmpEl . focus ( ) ;
} , 10 ) ;
} else {
this . documentHolder . entriesMenu . hide ( ) ;
2016-11-11 13:22:35 +00:00
Common . UI . warning ( {
title : this . notcriticalErrorTitle ,
maxwidth : 600 ,
msg : this . txtNoChoices ,
callback : _ . bind ( function ( btn ) {
Common . NotificationCenter . trigger ( 'edit:complete' , this . documentHolder ) ;
} , this )
} ) ;
2016-03-11 00:48:53 +00:00
}
} ,
onFormulaCompleteMenu : function ( funcarr ) {
if ( funcarr ) {
var me = this ,
documentHolderView = me . documentHolder ,
menu = documentHolderView . funcMenu ,
menuContainer = documentHolderView . cmpEl . find ( '#menu-formula-selection' ) ;
for ( var i = 0 ; i < menu . items . length ; i ++ ) {
menu . removeItem ( menu . items [ i ] ) ;
i -- ;
}
_ . each ( funcarr , function ( menuItem , index ) {
var type = menuItem . asc _getType ( ) ,
mnu = new Common . UI . MenuItem ( {
2016-04-05 11:52:34 +00:00
iconCls : ( type == Asc . c _oAscPopUpSelectorType . Func ) ? 'mnu-popup-func' : ( ( type == Asc . c _oAscPopUpSelectorType . Table ) ? 'mnu-popup-table' : 'mnu-popup-range' ) ,
2016-03-11 00:48:53 +00:00
caption : menuItem . asc _getName ( )
} ) . on ( 'click' , function ( item , e ) {
setTimeout ( function ( ) { me . api . asc _insertFormula ( item . caption , type , false ) ; } , 10 ) ;
} ) ;
menu . addItem ( mnu ) ;
} ) ;
if ( ! menu . rendered ) {
// Prepare menu container
if ( menuContainer . length < 1 ) {
menuContainer = $ ( Common . Utils . String . format ( '<div id="menu-formula-selection" style="position: absolute; z-index: 10000;" class="no-stop-propagate"><div class="dropdown-toggle" data-toggle="dropdown"></div></div>' ) ) ;
documentHolderView . cmpEl . append ( menuContainer ) ;
}
2016-03-14 14:59:38 +00:00
menu . onAfterKeydownMenu = function ( e ) {
if ( e . keyCode == Common . UI . Keys . RETURN && ( e . ctrlKey || e . altKey ) ) return ;
2016-07-06 13:15:13 +00:00
// Common.UI.Menu.prototype.onAfterKeydownMenu.call(menu, e);
2016-03-11 00:48:53 +00:00
var li ;
2016-07-22 14:16:08 +00:00
if ( arguments . length > 1 && arguments [ 1 ] instanceof KeyboardEvent ) // when typing in cell editor
2016-03-11 00:48:53 +00:00
e = arguments [ 1 ] ;
2016-07-06 13:15:13 +00:00
if ( menuContainer . hasClass ( 'open' ) ) {
if ( e . keyCode == Common . UI . Keys . TAB || e . keyCode == Common . UI . Keys . RETURN && ! e . ctrlKey && ! e . altKey )
li = menuContainer . find ( 'a.focus' ) . closest ( 'li' ) ;
else if ( e . keyCode == Common . UI . Keys . UP || e . keyCode == Common . UI . Keys . DOWN ) {
var innerEl = menu . cmpEl ,
inner _top = innerEl . offset ( ) . top ,
li _focused = menuContainer . find ( 'a.focus' ) . closest ( 'li' ) ;
var li _top = li _focused . offset ( ) . top ;
if ( li _top < inner _top || li _top + li _focused . outerHeight ( ) > inner _top + innerEl . height ( ) ) {
if ( menu . scroller ) {
menu . scroller . scrollTop ( innerEl . scrollTop ( ) + li _top - inner _top , 0 ) ;
} else {
innerEl . scrollTop ( innerEl . scrollTop ( ) + li _top - inner _top ) ;
2016-03-11 00:48:53 +00:00
}
}
}
2016-07-06 13:15:13 +00:00
}
// } else if (e.keyCode == Common.UI.Keys.TAB)
// li = $(e.target).closest('li');
2016-03-14 14:59:38 +00:00
2016-03-11 00:48:53 +00:00
if ( li ) {
if ( li . length > 0 ) li . click ( ) ;
Common . UI . Menu . Manager . hideAll ( ) ;
}
2016-03-14 14:59:38 +00:00
} ;
menu . render ( menuContainer ) ;
menu . cmpEl . attr ( { tabindex : "-1" } ) ;
2016-03-11 00:48:53 +00:00
}
var coord = me . api . asc _getActiveCellCoord ( ) ,
offset = { left : 0 , top : 0 } ,
showPoint = [ coord . asc _getX ( ) + offset . left , ( coord . asc _getY ( ) < 0 ? 0 : coord . asc _getY ( ) ) + coord . asc _getHeight ( ) + offset . top ] ;
menuContainer . css ( { left : showPoint [ 0 ] , top : showPoint [ 1 ] } ) ;
menu . alignPosition ( ) ;
var infocus = me . cellEditor . is ( ":focus" ) ;
2016-03-14 14:59:38 +00:00
if ( ! menu . isVisible ( ) )
Common . UI . Menu . Manager . hideAll ( ) ;
2016-03-11 00:48:53 +00:00
_ . delay ( function ( ) {
2016-03-14 14:59:38 +00:00
if ( ! menu . isVisible ( ) ) menu . show ( ) ;
if ( menu . scroller ) {
menu . scroller . update ( { alwaysVisibleY : true } ) ;
menu . scroller . scrollTop ( 0 ) ;
}
2016-07-06 13:15:13 +00:00
if ( infocus )
2016-03-11 00:48:53 +00:00
me . cellEditor . focus ( ) ;
2016-07-22 14:16:08 +00:00
menu . cmpEl . toggleClass ( 'from-cell-edit' , infocus ) ;
2016-07-06 13:15:13 +00:00
_ . delay ( function ( ) {
menu . cmpEl . find ( 'li:first a' ) . addClass ( 'focus' ) ;
} , 10 ) ;
// } else {
// _.delay(function() {
// menu.cmpEl.focus();
// menu.cmpEl.find('li:first a').focus();
// }, 10);
// }
2016-03-11 00:48:53 +00:00
} , 1 ) ;
} else {
this . documentHolder . funcMenu . hide ( ) ;
}
} ,
onCellsRange : function ( status ) {
2016-04-05 11:52:34 +00:00
this . rangeSelectionMode = ( status != Asc . c _oAscSelectionDialogType . None ) ;
2016-03-11 00:48:53 +00:00
} ,
onApiEditCell : function ( state ) {
2016-04-05 11:52:34 +00:00
this . isEditFormula = ( state == Asc . c _oAscCellEditorState . editFormula ) ;
this . isEditCell = ( state != Asc . c _oAscCellEditorState . editEnd ) ;
2016-03-11 00:48:53 +00:00
} ,
onLockDefNameManager : function ( state ) {
2016-04-05 11:52:34 +00:00
this . namedrange _locked = ( state == Asc . c _oAscDefinedNameReason . LockDefNameManager ) ;
2016-03-11 00:48:53 +00:00
} ,
2016-10-24 11:56:11 +00:00
initEquationMenu : function ( ) {
2016-10-24 13:40:06 +00:00
if ( ! this . _currentMathObj ) return ;
2016-10-24 11:56:11 +00:00
var me = this ,
type = me . _currentMathObj . get _Type ( ) ,
value = me . _currentMathObj ,
mnu , arr = [ ] ;
switch ( type ) {
case Asc . c _oAscMathInterfaceType . Accent :
mnu = new Common . UI . MenuItem ( {
caption : me . txtRemoveAccentChar ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
equationProps : { type : type , callback : 'remove_AccentCharacter' }
} ) ;
arr . push ( mnu ) ;
break ;
case Asc . c _oAscMathInterfaceType . BorderBox :
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 ;
case Asc . c _oAscMathInterfaceType . Bar :
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 ( {
caption : ( value . get _Pos ( ) == Asc . c _oAscMathInterfaceBarPos . Top ) ? me . txtUnderbar : me . txtOverbar ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
equationProps : { type : type , callback : 'put_Pos' , value : ( value . get _Pos ( ) == Asc . c _oAscMathInterfaceBarPos . Top ) ? Asc . c _oAscMathInterfaceBarPos . Bottom : Asc . c _oAscMathInterfaceBarPos . Top }
} ) ;
arr . push ( mnu ) ;
break ;
case Asc . c _oAscMathInterfaceType . Script :
var scripttype = value . get _ScriptType ( ) ;
if ( scripttype == Asc . c _oAscMathInterfaceScript . PreSubSup ) {
mnu = new Common . UI . MenuItem ( {
caption : me . txtScriptsAfter ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
equationProps : { type : type , callback : 'put_ScriptType' , value : Asc . c _oAscMathInterfaceScript . SubSup }
} ) ;
arr . push ( mnu ) ;
mnu = new Common . UI . MenuItem ( {
caption : me . txtRemScripts ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
equationProps : { type : type , callback : 'put_ScriptType' , value : Asc . c _oAscMathInterfaceScript . None }
} ) ;
arr . push ( mnu ) ;
} else {
if ( scripttype == Asc . c _oAscMathInterfaceScript . SubSup ) {
mnu = new Common . UI . MenuItem ( {
caption : me . txtScriptsBefore ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
equationProps : { type : type , callback : 'put_ScriptType' , value : Asc . c _oAscMathInterfaceScript . PreSubSup }
} ) ;
arr . push ( mnu ) ;
}
if ( scripttype == Asc . c _oAscMathInterfaceScript . SubSup || scripttype == Asc . c _oAscMathInterfaceScript . Sub ) {
mnu = new Common . UI . MenuItem ( {
caption : me . txtRemSubscript ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
equationProps : { type : type , callback : 'put_ScriptType' , value : ( scripttype == Asc . c _oAscMathInterfaceScript . SubSup ) ? Asc . c _oAscMathInterfaceScript . Sup : Asc . c _oAscMathInterfaceScript . None }
} ) ;
arr . push ( mnu ) ;
}
if ( scripttype == Asc . c _oAscMathInterfaceScript . SubSup || scripttype == Asc . c _oAscMathInterfaceScript . Sup ) {
mnu = new Common . UI . MenuItem ( {
caption : me . txtRemSuperscript ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
equationProps : { type : type , callback : 'put_ScriptType' , value : ( scripttype == Asc . c _oAscMathInterfaceScript . SubSup ) ? Asc . c _oAscMathInterfaceScript . Sub : Asc . c _oAscMathInterfaceScript . None }
} ) ;
arr . push ( mnu ) ;
}
}
break ;
case Asc . c _oAscMathInterfaceType . Fraction :
var fraction = value . get _FractionType ( ) ;
if ( fraction == Asc . c _oAscMathInterfaceFraction . Skewed || fraction == Asc . c _oAscMathInterfaceFraction . Linear ) {
mnu = new Common . UI . MenuItem ( {
caption : me . txtFractionStacked ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
equationProps : { type : type , callback : 'put_FractionType' , value : Asc . c _oAscMathInterfaceFraction . Bar }
} ) ;
arr . push ( mnu ) ;
}
if ( fraction == Asc . c _oAscMathInterfaceFraction . Bar || fraction == Asc . c _oAscMathInterfaceFraction . Linear ) {
mnu = new Common . UI . MenuItem ( {
caption : me . txtFractionSkewed ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
equationProps : { type : type , callback : 'put_FractionType' , value : Asc . c _oAscMathInterfaceFraction . Skewed }
} ) ;
arr . push ( mnu ) ;
}
if ( fraction == Asc . c _oAscMathInterfaceFraction . Bar || fraction == Asc . c _oAscMathInterfaceFraction . Skewed ) {
mnu = new Common . UI . MenuItem ( {
caption : me . txtFractionLinear ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
equationProps : { type : type , callback : 'put_FractionType' , value : Asc . c _oAscMathInterfaceFraction . Linear }
} ) ;
arr . push ( mnu ) ;
}
if ( fraction == Asc . c _oAscMathInterfaceFraction . Bar || fraction == Asc . c _oAscMathInterfaceFraction . NoBar ) {
mnu = new Common . UI . MenuItem ( {
caption : ( fraction == Asc . c _oAscMathInterfaceFraction . Bar ) ? me . txtRemFractionBar : me . txtAddFractionBar ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
equationProps : { type : type , callback : 'put_FractionType' , value : ( fraction == Asc . c _oAscMathInterfaceFraction . Bar ) ? Asc . c _oAscMathInterfaceFraction . NoBar : Asc . c _oAscMathInterfaceFraction . Bar }
} ) ;
arr . push ( mnu ) ;
}
break ;
case Asc . c _oAscMathInterfaceType . Limit :
mnu = new Common . UI . MenuItem ( {
caption : ( value . get _Pos ( ) == Asc . c _oAscMathInterfaceLimitPos . Top ) ? me . txtLimitUnder : me . txtLimitOver ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
equationProps : { type : type , callback : 'put_Pos' , value : ( value . get _Pos ( ) == Asc . c _oAscMathInterfaceLimitPos . Top ) ? Asc . c _oAscMathInterfaceLimitPos . Bottom : Asc . c _oAscMathInterfaceLimitPos . Top }
} ) ;
arr . push ( mnu ) ;
mnu = new Common . UI . MenuItem ( {
caption : me . txtRemLimit ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
equationProps : { type : type , callback : 'put_Pos' , value : Asc . c _oAscMathInterfaceLimitPos . None }
} ) ;
arr . push ( mnu ) ;
break ;
case Asc . c _oAscMathInterfaceType . Matrix :
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 ,
checked : ( value . get _MatrixAlign ( ) == Asc . c _oAscMathInterfaceMatrixMatrixAlign . Top ) ,
equationProps : { type : type , callback : 'put_MatrixAlign' , value : Asc . c _oAscMathInterfaceMatrixMatrixAlign . Top }
} ,
{
caption : me . centerText ,
checkable : true ,
checked : ( value . get _MatrixAlign ( ) == Asc . c _oAscMathInterfaceMatrixMatrixAlign . Center ) ,
equationProps : { type : type , callback : 'put_MatrixAlign' , value : Asc . c _oAscMathInterfaceMatrixMatrixAlign . Center }
} ,
{
caption : me . txtBottom ,
checkable : true ,
checked : ( value . get _MatrixAlign ( ) == Asc . c _oAscMathInterfaceMatrixMatrixAlign . Bottom ) ,
equationProps : { type : type , callback : 'put_MatrixAlign' , value : Asc . c _oAscMathInterfaceMatrixMatrixAlign . Bottom }
}
]
} )
} ) ;
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 ,
checked : ( value . get _ColumnAlign ( ) == Asc . c _oAscMathInterfaceMatrixColumnAlign . Left ) ,
equationProps : { type : type , callback : 'put_ColumnAlign' , value : Asc . c _oAscMathInterfaceMatrixColumnAlign . Left }
} ,
{
caption : me . centerText ,
checkable : true ,
checked : ( value . get _ColumnAlign ( ) == Asc . c _oAscMathInterfaceMatrixColumnAlign . Center ) ,
equationProps : { type : type , callback : 'put_ColumnAlign' , value : Asc . c _oAscMathInterfaceMatrixColumnAlign . Center }
} ,
{
caption : me . rightText ,
checkable : true ,
checked : ( value . get _ColumnAlign ( ) == Asc . c _oAscMathInterfaceMatrixColumnAlign . Right ) ,
equationProps : { type : type , callback : 'put_ColumnAlign' , value : Asc . c _oAscMathInterfaceMatrixColumnAlign . Right }
}
]
} )
} ) ;
arr . push ( mnu ) ;
break ;
case Asc . c _oAscMathInterfaceType . EqArray :
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 ,
checked : ( value . get _Align ( ) == Asc . c _oAscMathInterfaceEqArrayAlign . Top ) ,
equationProps : { type : type , callback : 'put_Align' , value : Asc . c _oAscMathInterfaceEqArrayAlign . Top }
} ,
{
caption : me . centerText ,
checkable : true ,
checked : ( value . get _Align ( ) == Asc . c _oAscMathInterfaceEqArrayAlign . Center ) ,
equationProps : { type : type , callback : 'put_Align' , value : Asc . c _oAscMathInterfaceEqArrayAlign . Center }
} ,
{
caption : me . txtBottom ,
checkable : true ,
checked : ( value . get _Align ( ) == Asc . c _oAscMathInterfaceEqArrayAlign . Bottom ) ,
equationProps : { type : type , callback : 'put_Align' , value : Asc . c _oAscMathInterfaceEqArrayAlign . Bottom }
}
]
} )
} ) ;
arr . push ( mnu ) ;
break ;
case Asc . c _oAscMathInterfaceType . LargeOperator :
mnu = new Common . UI . MenuItem ( {
caption : me . txtLimitChange ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
equationProps : { type : type , callback : 'put_LimitLocation' , value : ( value . get _LimitLocation ( ) == Asc . c _oAscMathInterfaceNaryLimitLocation . UndOvr ) ? Asc . c _oAscMathInterfaceNaryLimitLocation . SubSup : Asc . c _oAscMathInterfaceNaryLimitLocation . UndOvr }
} ) ;
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 ;
case Asc . c _oAscMathInterfaceType . Delimiter :
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 ;
case Asc . c _oAscMathInterfaceType . GroupChar :
if ( value . can _ChangePos ( ) ) {
mnu = new Common . UI . MenuItem ( {
caption : ( value . get _Pos ( ) == Asc . c _oAscMathInterfaceGroupCharPos . Top ) ? me . txtGroupCharUnder : me . txtGroupCharOver ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
equationProps : { type : type , callback : 'put_Pos' , value : ( value . get _Pos ( ) == Asc . c _oAscMathInterfaceGroupCharPos . Top ) ? Asc . c _oAscMathInterfaceGroupCharPos . Bottom : Asc . c _oAscMathInterfaceGroupCharPos . Top }
} ) ;
arr . push ( mnu ) ;
mnu = new Common . UI . MenuItem ( {
caption : me . txtDeleteGroupChar ,
equation : true ,
disabled : me . _currentParaObjDisabled ,
equationProps : { type : type , callback : 'put_Pos' , value : Asc . c _oAscMathInterfaceGroupCharPos . None }
} ) ;
arr . push ( mnu ) ;
}
break ;
case Asc . c _oAscMathInterfaceType . Radical :
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 ;
} ,
addEquationMenu : function ( insertIdx ) {
var me = this ;
me . clearEquationMenu ( insertIdx ) ;
var equationMenu = me . documentHolder . textInShapeMenu ,
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 ;
} ,
clearEquationMenu : function ( insertIdx ) {
var me = this ;
var equationMenu = me . documentHolder . textInShapeMenu ;
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 ;
}
} ,
equationCallback : function ( eqProps ) {
var me = this ;
if ( eqProps ) {
var eqObj ;
switch ( eqProps . type ) {
case Asc . c _oAscMathInterfaceType . Accent :
eqObj = new CMathMenuAccent ( ) ;
break ;
case Asc . c _oAscMathInterfaceType . BorderBox :
eqObj = new CMathMenuBorderBox ( ) ;
break ;
case Asc . c _oAscMathInterfaceType . Box :
eqObj = new CMathMenuBox ( ) ;
break ;
case Asc . c _oAscMathInterfaceType . Bar :
eqObj = new CMathMenuBar ( ) ;
break ;
case Asc . c _oAscMathInterfaceType . Script :
eqObj = new CMathMenuScript ( ) ;
break ;
case Asc . c _oAscMathInterfaceType . Fraction :
eqObj = new CMathMenuFraction ( ) ;
break ;
case Asc . c _oAscMathInterfaceType . Limit :
eqObj = new CMathMenuLimit ( ) ;
break ;
case Asc . c _oAscMathInterfaceType . Matrix :
eqObj = new CMathMenuMatrix ( ) ;
break ;
case Asc . c _oAscMathInterfaceType . EqArray :
eqObj = new CMathMenuEqArray ( ) ;
break ;
case Asc . c _oAscMathInterfaceType . LargeOperator :
eqObj = new CMathMenuNary ( ) ;
break ;
case Asc . c _oAscMathInterfaceType . Delimiter :
eqObj = new CMathMenuDelimiter ( ) ;
break ;
case Asc . c _oAscMathInterfaceType . GroupChar :
eqObj = new CMathMenuGroupCharacter ( ) ;
break ;
case Asc . c _oAscMathInterfaceType . Radical :
eqObj = new CMathMenuRadical ( ) ;
break ;
case Asc . c _oAscMathInterfaceType . Common :
eqObj = new CMathMenuBase ( ) ;
break ;
}
if ( eqObj ) {
eqObj [ eqProps . callback ] ( eqProps . value ) ;
me . api . asc _SetMathProps ( eqObj ) ;
}
}
Common . NotificationCenter . trigger ( 'edit:complete' , me . documentHolder ) ;
} ,
2016-03-11 00:48:53 +00:00
guestText : 'Guest' ,
textCtrlClick : 'Press CTRL and click link' ,
txtHeight : 'Height' ,
txtWidth : 'Width' ,
tipIsLocked : 'This element is being edited by another user.' ,
textChangeColumnWidth : 'Column Width {0} symbols ({1} pixels)' ,
textChangeRowHeight : 'Row Height {0} points ({1} pixels)' ,
textInsertLeft : 'Insert Left' ,
2016-04-06 13:38:54 +00:00
textInsertTop : 'Insert Top' ,
2016-08-05 11:40:47 +00:00
textSym : 'sym' ,
notcriticalErrorTitle : 'Warning' ,
2016-10-24 11:56:11 +00:00
errorInvalidLink : 'The link reference does not exist. Please correct the link or delete it.' ,
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' ,
2016-10-26 13:20:51 +00:00
txtDeleteCharsAndSeparators : 'Delete enclosing characters and separators' ,
insertText : 'Insert' ,
alignmentText : 'Alignment' ,
leftText : 'Left' ,
rightText : 'Right' ,
centerText : 'Center' ,
insertRowAboveText : 'Row Above' ,
insertRowBelowText : 'Row Below' ,
insertColumnLeftText : 'Column Left' ,
insertColumnRightText : 'Column Right' ,
deleteText : 'Delete' ,
deleteRowText : 'Delete Row' ,
2016-11-11 13:22:35 +00:00
deleteColumnText : 'Delete Column' ,
txtNoChoices : 'There are no choices for filling the cell.<br>Only text values from the column can be selected for replacement.'
2016-03-11 00:48:53 +00:00
} , SSE . Controllers . DocumentHolder || { } ) ) ;
} ) ;