diff --git a/apps/documenteditor/main/app/controller/DocumentHolder.js b/apps/documenteditor/main/app/controller/DocumentHolder.js index 2e221d0ff..ea48c24f9 100644 --- a/apps/documenteditor/main/app/controller/DocumentHolder.js +++ b/apps/documenteditor/main/app/controller/DocumentHolder.js @@ -110,18 +110,161 @@ define([ initialize: function() { // + this.addListeners({ + 'DocumentHolder': { + 'createdelayedelements': this.createDelayedElements, + 'equation:callback': this.equationCallback + } + }); + + var me = this; + + me._TtHeight = 20; + me.usertips = []; + me.fastcoauthtips = []; + me._isDisabled = false; + me._state = {}; + me.mode = {}; + me.mouseMoveData = null; + me.isTooltipHiding = false; + + me.screenTip = { + toolTip: new Common.UI.Tooltip({ + owner: this, + html: true, + title: '
Press Ctrl and click link', + cls: 'link-tooltip' +// style: 'word-wrap: break-word;' + }), + strTip: '', + isHidden: true, + isVisible: false + }; + me.userTooltip = true; + me.wrapEvents = { + userTipMousover: _.bind(me.userTipMousover, me), + userTipMousout: _.bind(me.userTipMousout, me) + }; + + var keymap = {}; + me.hkComments = 'alt+h'; + keymap[me.hkComments] = function() { + if (me.api.can_AddQuotedComment()!==false) { + me.addComment(); + } + }; + Common.util.Shortcuts.delegateShortcuts({shortcuts:keymap}); + }, onLaunch: function() { this.documentHolder = this.createView('DocumentHolder').render(); this.documentHolder.el.tabIndex = -1; + this.onAfterRender(); + + var me = this; + Common.NotificationCenter.on({ + 'window:show': function(e){ + me.screenTip.toolTip.hide(); + me.screenTip.isVisible = false; + /** coauthoring begin **/ + me.userTipHide(); + /** coauthoring end **/ + me.mode && me.mode.isDesktopApp && me.api && me.api.asc_onShowPopupWindow(); + + }, + 'modal:show': function(e){ + me.hideTips(); + }, + 'layout:changed': function(e){ + me.screenTip.toolTip.hide(); + me.screenTip.isVisible = false; + /** coauthoring begin **/ + me.userTipHide(); + /** coauthoring end **/ + me.hideTips(); + me.onDocumentHolderResize(); + } + }); }, - setApi: function(api) { - this.api = api; + setApi: function(o) { + this.api = o; + + if (this.api) { + this.api.asc_registerCallback('asc_onContextMenu', _.bind(this.onContextMenu, this)); + this.api.asc_registerCallback('asc_onMouseMoveStart', _.bind(this.onMouseMoveStart, this)); + this.api.asc_registerCallback('asc_onMouseMoveEnd', _.bind(this.onMouseMoveEnd, this)); + + //hyperlink + this.api.asc_registerCallback('asc_onHyperlinkClick', _.bind(this.onHyperlinkClick, this)); + this.api.asc_registerCallback('asc_onMouseMove', _.bind(this.onMouseMove, this)); + + if (this.mode.isEdit === true) { + this.api.asc_registerCallback('asc_onImgWrapStyleChanged', _.bind(this.onImgWrapStyleChanged, this)); + this.api.asc_registerCallback('asc_onDialogAddHyperlink', _.bind(this.onDialogAddHyperlink, this)); + this.api.asc_registerCallback('asc_doubleClickOnChart', _.bind(this.onDoubleClickOnChart, this)); + this.api.asc_registerCallback('asc_doubleClickOnTableOleObject', _.bind(this.onDoubleClickOnTableOleObject, this)); + this.api.asc_registerCallback('asc_onSpellCheckVariantsFound', _.bind(this.onSpellCheckVariantsFound, this)); + this.api.asc_registerCallback('asc_onRulerDblClick', _.bind(this.onRulerDblClick, this)); + this.api.asc_registerCallback('asc_ChangeCropState', _.bind(this.onChangeCropState, this)); + this.api.asc_registerCallback('asc_onLockDocumentProps', _.bind(this.onApiLockDocumentProps, this)); + this.api.asc_registerCallback('asc_onUnLockDocumentProps', _.bind(this.onApiUnLockDocumentProps, this)); + } + this.api.asc_registerCallback('asc_onCoAuthoringDisconnect', _.bind(this.onCoAuthoringDisconnect, this)); + Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this)); + this.api.asc_registerCallback('asc_onTextLanguage', _.bind(this.onTextLanguage, this)); + this.api.asc_registerCallback('asc_onParaStyleName', _.bind(this.onApiParagraphStyleChange, this)); + + this.api.asc_registerCallback('asc_onShowForeignCursorLabel', _.bind(this.onShowForeignCursorLabel, this)); + this.api.asc_registerCallback('asc_onHideForeignCursorLabel', _.bind(this.onHideForeignCursorLabel, this)); + this.api.asc_registerCallback('asc_onFocusObject', _.bind(this.onFocusObject, this)); + this.api.asc_registerCallback('asc_onShowSpecialPasteOptions', _.bind(this.onShowSpecialPasteOptions, this)); + this.api.asc_registerCallback('asc_onHideSpecialPasteOptions', _.bind(this.onHideSpecialPasteOptions, this)); + if (this.mode.isEdit || this.mode.isRestrictedEdit && this.mode.canFillForms) { + this.api.asc_registerCallback('asc_onShowContentControlsActions',_.bind(this.onShowContentControlsActions, this)); + this.api.asc_registerCallback('asc_onHideContentControlsActions',_.bind(this.onHideContentControlsActions, this)); + } + + this.documentHolder.setApi(this.api); + } + + return this; }, - createDelayedElements: function() { + setMode: function(m) { + this.mode = m; + /** coauthoring begin **/ + !(this.mode.canCoAuthoring && this.mode.canComments) + ? Common.util.Shortcuts.suspendEvents(this.hkComments) + : Common.util.Shortcuts.resumeEvents(this.hkComments); + /** coauthoring end **/ + this.documentHolder.setMode(m); + }, + + createDelayedElements: function(view, type) { + var me = this, + view = me.documentHolder; + + if (type=='view') { + view.menuViewCopy.on('click', _.bind(me.onCutCopyPaste, me)); + view.menuViewPaste.on('click', _.bind(me.onCutCopyPaste, me)); + view.menuViewCut.on('click', _.bind(me.onCutCopyPaste, me)); + view.menuViewUndo.on('click', _.bind(me.onUndo, me)); + view.menuViewAddComment.on('click', _.bind(me.addComment, me)); + view.menuSignatureViewSign.on('click', _.bind(me.onSignatureClick, me)); + view.menuSignatureDetails.on('click', _.bind(me.onSignatureClick, me)); + view.menuSignatureViewSetup.on('click', _.bind(me.onSignatureClick, me)); + view.menuSignatureRemove.on('click', _.bind(me.onSignatureClick, me)); + view.menuViewPrint.on('click', _.bind(me.onPrintSelection, me)); + return; + } else if (type=='pdf') { + view.menuPDFViewCopy.on('click', _.bind(me.onCutCopyPaste, me)); + return; + } + + // type == 'edit' + var diagramEditor = this.getApplication().getController('Common.Controllers.ExternalDiagramEditor').getView('Common.Views.ExternalDiagramEditor'); if (diagramEditor) { diagramEditor.on('internalmessage', _.bind(function(cmp, message) { @@ -138,9 +281,8 @@ define([ this.api.asc_onCloseChartFrame(); this.api.asc_enableKeyEvents(true); } - var me = this; setTimeout(function(){ - me.documentHolder.fireEvent('editcomplete', me.documentHolder); + me.editComplete(); }, 10); }, this)); } @@ -157,9 +299,8 @@ define([ if (this.api) { this.api.asc_enableKeyEvents(true); } - var me = this; setTimeout(function(){ - me.documentHolder.fireEvent('editcomplete', me.documentHolder); + me.editComplete(); }, 10); }, this)); } @@ -178,17 +319,1923 @@ define([ if (this.api) { this.api.asc_enableKeyEvents(true); } - var me = this; setTimeout(function(){ - me.documentHolder.fireEvent('editcomplete', me.documentHolder); + me.editComplete(); }, 10); }, this)); } + + view.menuInsertCaption.on('click', _.bind(me.onInsertCaption, me)); + view.menuEquationInsertCaption.on('click', _.bind(me.onInsertCaption, me)); + view.menuTableInsertCaption.on('click', _.bind(me.onInsertCaption, me)); + view.menuChartEdit.on('click', _.bind(me.editChartClick, me)); + view.menuImgCopy.on('click', _.bind(me.onCutCopyPaste, me)); + view.menuImgPaste.on('click', _.bind(me.onCutCopyPaste, me)); + view.menuImgCut.on('click', _.bind(me.onCutCopyPaste, me)); + view.menuTableCopy.on('click', _.bind(me.onCutCopyPaste, me)); + view.menuTablePaste.on('click', _.bind(me.onCutCopyPaste, me)); + view.menuTableCut.on('click', _.bind(me.onCutCopyPaste, me)); + view.menuParaCopy.on('click', _.bind(me.onCutCopyPaste, me)); + view.menuParaPaste.on('click', _.bind(me.onCutCopyPaste, me)); + view.menuParaCut.on('click', _.bind(me.onCutCopyPaste, me)); + view.menuImgAccept.on('click', _.bind(me.onAcceptRejectChange, me)); + view.menuImgReject.on('click', _.bind(me.onAcceptRejectChange, me)); + view.menuTableAccept.on('click', _.bind(me.onAcceptRejectChange, me)); + view.menuTableReject.on('click', _.bind(me.onAcceptRejectChange, me)); + view.menuParaAccept.on('click', _.bind(me.onAcceptRejectChange, me)); + view.menuParaReject.on('click', _.bind(me.onAcceptRejectChange, me)); + view.menuImgPrint.on('click', _.bind(me.onPrintSelection, me)); + view.menuTablePrint.on('click', _.bind(me.onPrintSelection, me)); + view.menuParaPrint.on('click', _.bind(me.onPrintSelection, me)); + view.menuSignatureEditSign.on('click', _.bind(me.onSignatureClick, me)); + view.menuSignatureEditSetup.on('click', _.bind(me.onSignatureClick, me)); + view.menuImgRotate.menu.items[0].on('click', _.bind(me.onImgRotate, me)); + view.menuImgRotate.menu.items[1].on('click', _.bind(me.onImgRotate, me)); + view.menuImgRotate.menu.items[3].on('click', _.bind(me.onImgFlip, me)); + view.menuImgRotate.menu.items[4].on('click', _.bind(me.onImgFlip, me)); + view.menuImgCrop.menu.on('item:click', _.bind(me.onImgCrop, me)); + view.menuImgRemoveControl.on('click', _.bind(me.onControlsSelect, me)); + view.menuImgControlSettings.on('click', _.bind(me.onControlsSelect, me)); + view.menuTableRemoveForm.on('click', _.bind(me.onControlsSelect, me)); + view.menuTableRemoveControl.on('click', _.bind(me.onControlsSelect, me)); + view.menuTableControlSettings.on('click', _.bind(me.onControlsSelect, me)); + view.menuParaRemoveControl.on('click', _.bind(me.onControlsSelect, me)); + view.menuParaControlSettings.on('click', _.bind(me.onControlsSelect, me)); + view.menuTableCellAlign.menu.on('item:click', _.bind(me.tableCellsVAlign, me)); + view.menuTableAdvanced.on('click', _.bind(me.advancedTableClick, me)); + view.menuParagraphAdvancedInTable.on('click', _.bind(me.advancedParagraphClick, me)); + view.menuParagraphAdvanced.on('click', _.bind(me.advancedParagraphClick, me)); + view.menuEditHyperlinkTable.on('click', _.bind(me.editHyperlink, me)); + view.menuEditHyperlinkPara.on('click', _.bind(me.editHyperlink, me)); + view.menuRemoveHyperlinkTable.on('click', _.bind(me.onRemoveHyperlink, me)); + view.menuRemoveHyperlinkPara.on('click', _.bind(me.onRemoveHyperlink, me)); + view.menuAddHyperlinkTable.on('click', _.bind(me.addHyperlink, me)); + view.menuAddHyperlinkPara.on('click', _.bind(me.addHyperlink, me)); + view.menuAddCommentTable.on('click', _.bind(me.addComment, me)); + view.menuAddCommentPara.on('click', _.bind(me.addComment, me)); + view.menuTableFollow.on('click', _.bind(me.onFollowMove, me)); + view.menuParaFollow.on('click', _.bind(me.onFollowMove, me)); + view.menuTableStartNewList.on('click', _.bind(me.onStartNumbering, me, 1)); + view.menuParaStartNewList.on('click', _.bind(me.onStartNumbering, me, 1)); + view.menuTableStartNumberingFrom.on('click', _.bind(me.onStartNumbering, me, 'advanced')); + view.menuParaStartNumberingFrom.on('click', _.bind(me.onStartNumbering, me, 'advanced')); + view.menuTableContinueNumbering.on('click', _.bind(me.onContinueNumbering, me)); + view.menuParaContinueNumbering.on('click', _.bind(me.onContinueNumbering, me)); + view.menuFrameAdvanced.on('click', _.bind(me.advancedFrameClick, me, true)); + view.menuDropCapAdvanced.on('click', _.bind(me.advancedFrameClick, me, false)); + view.menuStyleSave.on('click', _.bind(me.onMenuSaveStyle, me)); + view.menuStyleUpdate.on('click', _.bind(me.onMenuUpdateStyle, me)); + view.menuTableSelectText.menu.on('item:click', _.bind(me.tableSelectText, me)); + view.menuTableInsertText.menu.on('item:click', _.bind(me.tableInsertText, me)); + view.menuTableDeleteText.menu.on('item:click', _.bind(me.tableDeleteText, me)); + view.menuImageAlign.menu.on('item:click', _.bind(me.onImgAlign, me)); + view.menuImageArrange.menu.on('item:click', _.bind(me.onImgArrange, me)); + view.mnuGroup.on('click', _.bind(me.onImgGroup, me)); + view.mnuUnGroup.on('click', _.bind(me.onImgUnGroup, me)); + view.menuWrapPolygon.on('click', _.bind(me.onImgWrapPolygon, me)); + view.menuImageWrap.menu.on('item:click', _.bind(me.onImgWrap, me)); + view.menuImageAdvanced.on('click', _.bind(me.onImgAdvanced, me)); + view.menuOriginalSize.on('click', _.bind(me.onImgOriginalSize, me)); + view.menuImgReplace.menu.on('item:click', _.bind(me.onImgReplace, me)); + view.menuImgEditPoints.on('click', _.bind(me.onImgEditPoints, me)); + view.mnuTableMerge.on('click', _.bind(me.onTableMerge, me)); + view.mnuTableSplit.on('click', _.bind(me.onTableSplit, me)); + view.menuIgnoreSpellTable.on('click', _.bind(me.onIgnoreSpell, me)); + view.menuIgnoreSpellPara.on('click', _.bind(me.onIgnoreSpell, me)); + view.menuIgnoreAllSpellTable.on('click', _.bind(me.onIgnoreSpell, me)); + view.menuIgnoreAllSpellPara.on('click', _.bind(me.onIgnoreSpell, me)); + view.menuToDictionaryTable.on('click', _.bind(me.onToDictionary, me)); + view.menuToDictionaryPara.on('click', _.bind(me.onToDictionary, me)); + view.menuTableDistRows.on('click', _.bind(me.onTableDist, me)); + view.menuTableDistCols.on('click', _.bind(me.onTableDist, me)); + view.menuTableDirection.menu.on('item:click', _.bind(me.tableDirection, me)); + view.menuTableRefreshField.on('click', _.bind(me.onRefreshField, me)); + view.menuParaRefreshField.on('click', _.bind(me.onRefreshField, me)); + view.menuParagraphBreakBefore.on('click', _.bind(me.onParagraphBreakBefore, me)); + view.menuParagraphKeepLines.on('click', _.bind(me.onParagraphKeepLines, me)); + view.menuParagraphVAlign.menu.on('item:click', _.bind(me.paragraphVAlign, me)); + view.menuParagraphDirection.menu.on('item:click', _.bind(me.paragraphDirection, me)); + view.langParaMenu.menu.on('item:click', _.bind(me.onLangMenu, me, 'para')); + view.langTableMenu.menu.on('item:click', _.bind(me.onLangMenu, me, 'table')); + view.menuTableTOC.menu.on('item:click', _.bind(me.onTOCMenu, me)); + view.menuParaTOCRefresh.menu.on('item:click', _.bind(me.onTOCMenu, me)); + view.menuParaTOCSettings.on('click', _.bind(me.onParaTOCSettings, me)); }, getView: function (name) { return !name ? this.documentHolder : Backbone.Controller.prototype.getView.call() + }, + + showPopupMenu: function(menu, value, event, docElement, eOpts){ + var me = this; + if (!_.isUndefined(menu) && menu !== null){ + Common.UI.Menu.Manager.hideAll(); + + var showPoint = [event.get_X(), event.get_Y()], + menuContainer = $(me.documentHolder.el).find(Common.Utils.String.format('#menu-container-{0}', menu.id)); + + if (!menu.rendered) { + // Prepare menu container + if (menuContainer.length < 1) { + menuContainer = $(Common.Utils.String.format('', menu.id)); + $(me.documentHolder.el).append(menuContainer); + } + + menu.render(menuContainer); + menu.cmpEl.attr({tabindex: "-1"}); + } + + menuContainer.css({ + left: showPoint[0], + top : showPoint[1] + }); + + menu.show(); + + if (_.isFunction(menu.options.initMenu)) { + menu.options.initMenu(value); + menu.alignPosition(); + } + _.delay(function() { + menu.cmpEl.focus(); + }, 10); + + me.documentHolder.currentMenu = menu; + } + }, + + fillMenuProps: function(selectedElements) { + if (!selectedElements || !_.isArray(selectedElements)) return; + var me = this, + documentHolder = this.documentHolder; + var menu_props = {}, + menu_to_show = documentHolder.textMenu, + noobject = true; + for (var i = 0; i 0) { + me.api.zoomIn(); + } + + event.preventDefault(); + event.stopPropagation(); + } + } + }, + + handleDocumentKeyDown: function(event){ + var me = this; + if (me.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.isGecko && key === Common.UI.Keys.EQUALITY_FF) || (Common.Utils.isOpera && key == 43)){ + me.api.zoomIn(); + event.preventDefault(); + event.stopPropagation(); + return false; + } + else if (key === Common.UI.Keys.NUM_MINUS || key === Common.UI.Keys.MINUS || (Common.Utils.isGecko && key === Common.UI.Keys.MINUS_FF) || (Common.Utils.isOpera && key == 45)){ + me.api.zoomOut(); + event.preventDefault(); + event.stopPropagation(); + return false; + } else if (key === 48 || key === 96) {// 0 + me.api.zoom(100); + event.preventDefault(); + event.stopPropagation(); + return false; + } + } + if (me.documentHolder.currentMenu && me.documentHolder.currentMenu.isVisible()) { + if (key == Common.UI.Keys.UP || + key == Common.UI.Keys.DOWN) { + $('ul.dropdown-menu', me.documentHolder.currentMenu.el).focus(); + } + } + + if (key == Common.UI.Keys.ESC) { + Common.UI.Menu.Manager.hideAll(); + if (!Common.UI.HintManager.isHintVisible()) + Common.NotificationCenter.trigger('leftmenu:change', 'hide'); + } + } + }, + + onDocumentHolderResize: function(e){ + var me = this; + me._XY = [ + me.documentHolder.cmpEl.offset().left - $(window).scrollLeft(), + me.documentHolder.cmpEl.offset().top - $(window).scrollTop() + ]; + me._Height = me.documentHolder.cmpEl.height(); + me._BodyWidth = $('body').width(); + }, + + onAfterRender: function(ct){ + var me = this; + var meEl = me.documentHolder.cmpEl; + if (meEl) { + meEl.on('contextmenu', function(e) { + e.preventDefault(); + e.stopPropagation(); + return false; + }); + meEl.on('click', function(e){ + if (e.target.localName == 'canvas') { + if (me._preventClick) + me._preventClick = false; + else + meEl.focus(); + } + }); + meEl.on('mousedown', function(e){ + if (e.target.localName == 'canvas') + Common.UI.Menu.Manager.hideAll(); + }); + + //NOTE: set mouse wheel handler + + var addEvent = function( elem, type, fn ) { + elem.addEventListener ? elem.addEventListener( type, fn, false ) : elem.attachEvent( "on" + type, fn ); + }; + + var eventname=(/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel'; + addEvent(me.documentHolder.el, eventname, _.bind(me.handleDocumentWheel, me)); + } + + !Common.Utils.isChrome ? $(document).on('mousewheel', _.bind(me.handleDocumentWheel, me)) : + document.addEventListener('mousewheel', _.bind(me.handleDocumentWheel, me), {passive: false}); + $(document).on('keydown', _.bind(me.handleDocumentKeyDown, me)); + + $(window).on('resize', _.bind(me.onDocumentHolderResize, me)); + var viewport = me.getApplication().getController('Viewport').getView('Viewport'); + viewport.hlayout.on('layout:resizedrag', _.bind(me.onDocumentHolderResize, me)); + }, + + getUserName: function(id){ + var usersStore = DE.getCollection('Common.Collections.Users'); + if (usersStore){ + var rec = usersStore.findUser(id); + if (rec) + return AscCommon.UserInfoParser.getParsedName(rec.get('username')); + } + return this.documentHolder.guestText; + }, + + isUserVisible: function(id){ + var usersStore = DE.getCollection('Common.Collections.Users'); + if (usersStore){ + var rec = usersStore.findUser(id); + if (rec) + return !rec.get('hidden'); + } + return true; + }, + + userTipMousover: function (evt, el, opt) { + var me = this; + if (me.userTooltip===true) { + me.userTooltip = new Common.UI.Tooltip({ + owner: evt.currentTarget, + title: me.documentHolder.tipIsLocked + }); + + me.userTooltip.show(); + } + }, + + userTipHide: function () { + var me = this; + if (typeof me.userTooltip == 'object') { + me.userTooltip.hide(); + me.userTooltip = undefined; + + for (var i=0; i0) + window.open(url); + else + Common.UI.warning({ + msg: me.documentHolder.txtWarnUrl, + buttons: ['yes', 'no'], + primary: 'yes', + callback: function(btn) { + (btn == 'yes') && window.open(url); + } + }); + } + }, + + onDialogAddHyperlink: function() { + var me = this; + var win, props, text; + if (me.api && me.mode.isEdit && !me._isDisabled && !me.getApplication().getController('LeftMenu').leftMenu.menuFile.isVisible()){ + var handlerDlg = function(dlg, result) { + if (result == 'ok') { + props = dlg.getSettings(); + (text!==false) + ? me.api.add_Hyperlink(props) + : me.api.change_Hyperlink(props); + } + + me.editComplete(); + }; + + text = me.api.can_AddHyperlink(); + + if (text !== false) { + win = new DE.Views.HyperlinkSettingsDialog({ + api: me.api, + handler: handlerDlg + }); + + props = new Asc.CHyperlinkProperty(); + props.put_Text(text); + + win.show(); + win.setSettings(props); + } else { + var selectedElements = me.api.getSelectedElements(); + if (selectedElements && _.isArray(selectedElements)){ + _.each(selectedElements, function(el, i) { + if (selectedElements[i].get_ObjectType() == Asc.c_oAscTypeSelectElement.Hyperlink) + props = selectedElements[i].get_ObjectValue(); + }); + } + if (props) { + win = new DE.Views.HyperlinkSettingsDialog({ + api: me.api, + handler: handlerDlg + }); + win.show(); + win.setSettings(props); + } + } + Common.component.Analytics.trackEvent('DocumentHolder', 'Add Hyperlink'); + } + }, + + onShowForeignCursorLabel: function(UserId, X, Y, color) { + if (!this.isUserVisible(UserId)) return; + + /** coauthoring begin **/ + var me = this; + var src; + for (var i=0; i0) { + if (typeof me.userTooltip == 'object') { + me.userTooltip.hide(); + me.userTooltip = true; + } + _.each(me.usertips, function(item) { + item.remove(); + }); + } + me.usertips = []; + me.usertipcount = 0; + /** coauthoring end **/ + }, + + onMouseMoveEnd: function() { + var me = this; + if (me.screenTip.isHidden && me.screenTip.isVisible) { + me.screenTip.isVisible = false; + me.isTooltipHiding = true; + me.screenTip.toolTip.hide(function(){ + me.isTooltipHiding = false; + if (me.mouseMoveData) me.onMouseMove(me.mouseMoveData); + me.mouseMoveData = null; + }); + } + }, + + onMouseMove: function(moveData) { + var me = this, + cmpEl = me.documentHolder.cmpEl, + screenTip = me.screenTip; + if (me._XY === undefined) { + me._XY = [ + cmpEl.offset().left - $(window).scrollLeft(), + cmpEl.offset().top - $(window).scrollTop() + ]; + me._Height = cmpEl.height(); + me._BodyWidth = $('body').width(); + } + + if (moveData) { + var showPoint, ToolTip, + type = moveData.get_Type(); + + if (type==Asc.c_oAscMouseMoveDataTypes.Hyperlink || type==Asc.c_oAscMouseMoveDataTypes.Footnote || type==Asc.c_oAscMouseMoveDataTypes.Form || + type==Asc.c_oAscMouseMoveDataTypes.Review && me.mode.reviewHoverMode) { + if (me.isTooltipHiding) { + me.mouseMoveData = moveData; + return; + } + + if (type==Asc.c_oAscMouseMoveDataTypes.Hyperlink) { + var hyperProps = moveData.get_Hyperlink(); + if (!hyperProps) return; + ToolTip = (_.isEmpty(hyperProps.get_ToolTip())) ? hyperProps.get_Value() : hyperProps.get_ToolTip(); + if (ToolTip.length>256) + ToolTip = ToolTip.substr(0, 256) + '...'; + } else if (type == Asc.c_oAscMouseMoveDataTypes.Footnote) { + ToolTip = moveData.get_FootnoteText(); + if (ToolTip.length>1000) + ToolTip = ToolTip.substr(0, 1000) + '...'; + } else if (type==Asc.c_oAscMouseMoveDataTypes.Form) { + ToolTip = moveData.get_FormHelpText(); + if (ToolTip.length>1000) + ToolTip = ToolTip.substr(0, 1000) + '...'; + } else if (type==Asc.c_oAscMouseMoveDataTypes.Review && moveData.get_ReviewChange()) { + var changes = me.getApplication().getController("Common.Controllers.ReviewChanges").readSDKChange([moveData.get_ReviewChange()]); + if (changes && changes.length>0) + changes = changes[0]; + if (changes) { + ToolTip = ''+ Common.Utils.String.htmlEncode(AscCommon.UserInfoParser.getParsedName(changes.get('username'))) +' '; + ToolTip += ''+ changes.get('date') +'
'; + ToolTip += changes.get('changetext'); + if (ToolTip.length>1000) + ToolTip = ToolTip.substr(0, 1000) + '...'; + } + } + + var recalc = false; + screenTip.isHidden = false; + + if (type!==Asc.c_oAscMouseMoveDataTypes.Review) + ToolTip = Common.Utils.String.htmlEncode(ToolTip); + + if (screenTip.tipType !== type || screenTip.tipLength !== ToolTip.length || screenTip.strTip.indexOf(ToolTip)<0 ) { + screenTip.toolTip.setTitle((type==Asc.c_oAscMouseMoveDataTypes.Hyperlink) ? (ToolTip + '
' + me.documentHolder.txtPressLink + '') : 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]); + } + + if ( recalc ) { + screenTip.tipHeight = screenTip.toolTip.getBSTip().$tip.height(); + screenTip.tipWidth = screenTip.toolTip.getBSTip().$tip.width(); + } + + recalc = false; + if (showPoint[0] + screenTip.tipWidth > me._BodyWidth ) { + showPoint[0] = me._BodyWidth - screenTip.tipWidth; + recalc = true; + } + if (showPoint[1] - screenTip.tipHeight < 0) { + showPoint[1] = (recalc) ? showPoint[1]+30 : 0; + } else + showPoint[1] -= screenTip.tipHeight; + + screenTip.toolTip.getBSTip().$tip.css({top: showPoint[1] + 'px', left: showPoint[0] + 'px'}); + } + /** coauthoring begin **/ + else if (moveData.get_Type()==Asc.c_oAscMouseMoveDataTypes.LockedObject && me.mode.isEdit && me.isUserVisible(moveData.get_UserId())) { // 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 (me.userTooltip) { + src.on('mouseover', me.wrapEvents.userTipMousover); + src.on('mouseout', me.wrapEvents.userTipMousout); + } + + me.usertips.push(src); + } + src = me.usertips[me.usertipcount]; + me.usertipcount++; + + ToolTip = me.getUserName(moveData.get_UserId()); + + showPoint = [moveData.get_X()+me._XY[0], moveData.get_Y()+me._XY[1]]; + var maxwidth = showPoint[0]; + showPoint[0] = me._BodyWidth - showPoint[0]; + showPoint[1] -= ((moveData.get_LockedObjectType()==2) ? me._TtHeight : 0); + + if (showPoint[1] > me._XY[1] && showPoint[1]+me._TtHeight < me._XY[1]+me._Height) { + src.text(ToolTip); + src.css({visibility: 'visible', top: showPoint[1] + 'px', right: showPoint[0] + 'px', 'max-width': maxwidth + 'px'}); + } else { + src.css({visibility: 'hidden'}); + } + } + /** coauthoring end **/ + } + }, + + onShowSpecialPasteOptions: function(specialPasteShowOptions) { + var me = this, + documentHolder = me.documentHolder; + var coord = specialPasteShowOptions.asc_getCellCoord(), + pasteContainer = documentHolder.cmpEl.find('#special-paste-container'), + pasteItems = specialPasteShowOptions.asc_getOptions(); + if (!pasteItems) return; + + // Prepare menu container + if (pasteContainer.length < 1) { + me._arrSpecialPaste = []; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.paste] = documentHolder.textPaste; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.sourceformatting] = documentHolder.txtPasteSourceFormat; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.keepTextOnly] = documentHolder.txtKeepTextOnly; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.insertAsNestedTable] = documentHolder.textNest; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.overwriteCells] = documentHolder.txtOverwriteCells; + + pasteContainer = $('
'); + documentHolder.cmpEl.find('#id_main_view').append(pasteContainer); + + me.btnSpecialPaste = new Common.UI.Button({ + parentEl: $('#id-document-holder-btn-special-paste'), + cls : 'btn-toolbar', + iconCls : 'toolbar__icon btn-paste', + menu : new Common.UI.Menu({items: []}) + }); + } + + 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]; + if (!Common.Utils.InternalSettings.get("de-hidden-rulers")) { + showPoint = [showPoint[0] - 19, showPoint[1] - 26]; + } + pasteContainer.css({left: showPoint[0], top : showPoint[1]}); + pasteContainer.show(); + } + }, + + onHideSpecialPasteOptions: function() { + var pasteContainer = this.documentHolder.cmpEl.find('#special-paste-container'); + if (pasteContainer.is(':visible')) + pasteContainer.hide(); + }, + + onDoubleClickOnChart: function(chart) { + if (this.mode.isEdit && !this._isDisabled) { + var diagramEditor = this.getApplication().getController('Common.Controllers.ExternalDiagramEditor').getView('Common.Views.ExternalDiagramEditor'); + if (diagramEditor && chart) { + diagramEditor.setEditMode(true); + diagramEditor.show(); + diagramEditor.setChartData(new Asc.asc_CChartBinary(chart)); + } + } + }, + + onDoubleClickOnTableOleObject: function(chart) { + if (this.mode.isEdit && !this._isDisabled) { + var oleEditor = this.getApplication().getController('Common.Controllers.ExternalOleEditor').getView('Common.Views.ExternalOleEditor'); + if (oleEditor && chart) { + oleEditor.setEditMode(true); + oleEditor.show(); + oleEditor.setOleData(Asc.asc_putBinaryDataToFrameFromTableOleObject(chart)); + } + } + }, + + onImgWrapStyleChanged: function(type){ + var menuImageWrap = this.documentHolder.menuImageWrap; + switch (type) { + case Asc.c_oAscWrapStyle2.Inline: + menuImageWrap.menu.items[0].setChecked(true); + break; + case Asc.c_oAscWrapStyle2.Square: + menuImageWrap.menu.items[2].setChecked(true); + break; + case Asc.c_oAscWrapStyle2.Tight: + menuImageWrap.menu.items[3].setChecked(true); + break; + case Asc.c_oAscWrapStyle2.Through: + menuImageWrap.menu.items[4].setChecked(true); + break; + case Asc.c_oAscWrapStyle2.TopAndBottom: + menuImageWrap.menu.items[5].setChecked(true); + break; + case Asc.c_oAscWrapStyle2.Behind: + menuImageWrap.menu.items[8].setChecked(true); + break; + case Asc.c_oAscWrapStyle2.InFront: + menuImageWrap.menu.items[7].setChecked(true); + break; + } + }, + + onChangeCropState: function(state) { + this.documentHolder.menuImgCrop.menu.items[0].setChecked(state, true); + }, + + onRulerDblClick: function(type) { + Common.UI.Menu.Manager.hideAll(); + + var win, me = this; + if (type == 'tables') { + win = this.advancedTableClick(); + if (win) + win.setActiveCategory(4); + } else if (type == 'indents' || type == 'tabs') { + win = this.advancedParagraphClick({isChart: false}); + if (win) + win.setActiveCategory(type == 'indents' ? 0 : 4); + } else if (type == 'margins') { + if (me._state.lock_doc) return; + win = new DE.Views.PageMarginsDialog({ + api: me.api, + handler: function(dlg, result) { + if (result == 'ok') { + var props = dlg.getSettings(); + var mnu = DE.getController('Toolbar').toolbar.btnPageMargins.menu.items[0]; + mnu.setVisible(true); + mnu.setChecked(true); + mnu.options.value = mnu.value = [props.get_TopMargin(), props.get_LeftMargin(), props.get_BottomMargin(), props.get_RightMargin()]; + $(mnu.el).html(mnu.template({id: Common.UI.getId(), caption : mnu.caption, options : mnu.options})); + Common.localStorage.setItem("de-pgmargins-top", props.get_TopMargin()); + Common.localStorage.setItem("de-pgmargins-left", props.get_LeftMargin()); + Common.localStorage.setItem("de-pgmargins-bottom", props.get_BottomMargin()); + Common.localStorage.setItem("de-pgmargins-right", props.get_RightMargin()); + + me.api.asc_SetSectionProps(props); + me.editComplete(); + } + } + }); + 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.editComplete(); + } + } + }); + win.show(); + win.setSettings(me.api.asc_GetColumnsProps()); + } + }, + + onApiParagraphStyleChange: function(name) { + window.currentStyleName = name; + }, + + onHideContentControlsActions: function() { + this.listControlMenu && this.listControlMenu.isVisible() && this.listControlMenu.hide(); + var controlsContainer = this.documentHolder.cmpEl.find('#calendar-control-container'); + if (controlsContainer.is(':visible')) + controlsContainer.hide(); + }, + + onShowDateActions: function(obj, x, y) { + var props = obj.pr, + specProps = props.get_DateTimePr(), + cmpEl = this.documentHolder.cmpEl, + controlsContainer = cmpEl.find('#calendar-control-container'), + me = this; + + this._dateObj = props; + + if (controlsContainer.length < 1) { + controlsContainer = $('
'); + cmpEl.append(controlsContainer); + } + + Common.UI.Menu.Manager.hideAll(); + + controlsContainer.css({left: x, top : y}); + controlsContainer.show(); + + if (!this.cmpCalendar) { + this.cmpCalendar = new Common.UI.Calendar({ + el: cmpEl.find('#id-document-calendar-control'), + enableKeyEvents: true, + firstday: 1 + }); + this.cmpCalendar.on('date:click', function (cmp, date) { + var specProps = me._dateObj.get_DateTimePr(); + specProps.put_FullDate(new Date(date)); + me.api.asc_SetContentControlDatePickerDate(specProps); + controlsContainer.hide(); + me.api.asc_UncheckContentControlButtons(); + me.editComplete(); + }); + this.cmpCalendar.on('calendar:keydown', function (cmp, e) { + if (e.keyCode==Common.UI.Keys.ESC) { + controlsContainer.hide(); + me.api.asc_UncheckContentControlButtons(); + } + }); + $(document).on('mousedown', function(e) { + if (e.target.localName !== 'canvas' && controlsContainer.is(':visible') && controlsContainer.find(e.target).length==0) { + controlsContainer.hide(); + me.api.asc_UncheckContentControlButtons(); + } + }); + + } + this.cmpCalendar.setDate(new Date(specProps ? specProps.get_FullDate() : undefined)); + + // align + var offset = controlsContainer.offset(), + docW = Common.Utils.innerWidth(), + docH = Common.Utils.innerHeight() - 10, // Yep, it's magic number + menuW = this.cmpCalendar.cmpEl.outerWidth(), + menuH = this.cmpCalendar.cmpEl.outerHeight(), + buttonOffset = 22, + left = offset.left - menuW, + top = offset.top; + if (top + menuH > docH) { + top = docH - menuH; + left -= buttonOffset; + } + if (top < 0) + top = 0; + if (left + menuW > docW) + left = docW - menuW; + this.cmpCalendar.cmpEl.css({left: left, top : top}); + + this._preventClick = true; + }, + + onShowListActions: function(obj, x, y) { + var type = obj.type, + props = obj.pr, + specProps = (type == Asc.c_oAscContentControlSpecificType.ComboBox) ? props.get_ComboBoxPr() : props.get_DropDownListPr(), + isForm = !!props.get_FormPr(), + cmpEl = this.documentHolder.cmpEl, + menu = this.listControlMenu, + menuContainer = menu ? cmpEl.find(Common.Utils.String.format('#menu-container-{0}', menu.id)) : null, + me = this; + + this._listObj = props; + + this._fromShowContentControls = true; + Common.UI.Menu.Manager.hideAll(); + + if (!menu) { + this.listControlMenu = menu = new Common.UI.Menu({ + maxHeight: 207, + menuAlign: 'tr-bl', + items: [] + }); + menu.on('item:click', function(menu, item) { + setTimeout(function(){ + (item.value!==-1) && me.api.asc_SelectContentControlListItem(item.value, me._listObj.get_InternalId()); + }, 1); + }); + + // Prepare menu container + if (!menuContainer || menuContainer.length < 1) { + menuContainer = $(Common.Utils.String.format('', menu.id)); + cmpEl.append(menuContainer); + } + + menu.render(menuContainer); + menu.cmpEl.attr({tabindex: "-1"}); + menu.on('hide:after', function(){ + me.listControlMenu.removeAll(); + if (!me._fromShowContentControls) + me.api.asc_UncheckContentControlButtons(); + }); + } + if (specProps) { + if (isForm){ // for dropdown and combobox form control always add placeholder item + var text = props.get_PlaceholderText(); + menu.addItem(new Common.UI.MenuItem({ + caption : (text.trim()!=='') ? text : this.documentHolder.txtEmpty, + value : '', + template : _.template([ + ' opacity: 0.6 <% } %>">', + '<%= caption %>', + '' + ].join('')) + })); + } + var count = specProps.get_ItemsCount(); + for (var i=0; i', + '<%= Common.Utils.String.htmlEncode(caption) %>', + '' + ].join('')) + })); + } + if (!isForm && menu.items.length<1) { + menu.addItem(new Common.UI.MenuItem({ + caption : this.documentHolder.txtEmpty, + value : -1 + })); + } + } + + menuContainer.css({left: x, top : y}); + menuContainer.attr('data-value', 'prevent-canvas-click'); + this._preventClick = true; + menu.show(); + + _.delay(function() { + menu.cmpEl.focus(); + }, 10); + this._fromShowContentControls = false; + }, + + onShowContentControlsActions: function(obj, x, y) { + var type = obj.type; + switch (type) { + case Asc.c_oAscContentControlSpecificType.DateTime: + this.onShowDateActions(obj, x, y); + break; + case Asc.c_oAscContentControlSpecificType.Picture: + if (obj.pr && obj.pr.get_Lock) { + var lock = obj.pr.get_Lock(); + if (lock == Asc.c_oAscSdtLockType.SdtContentLocked || lock==Asc.c_oAscSdtLockType.ContentLocked) + return; + } + this.api.asc_addImage(obj); + var me = this; + setTimeout(function(){ + me.api.asc_UncheckContentControlButtons(); + }, 500); + break; + case Asc.c_oAscContentControlSpecificType.DropDownList: + case Asc.c_oAscContentControlSpecificType.ComboBox: + this.onShowListActions(obj, x, y); + break; + } + }, + + onApiLockDocumentProps: function() { + this._state.lock_doc = true; + }, + + onApiUnLockDocumentProps: function() { + this._state.lock_doc = false; + }, + + onCoAuthoringDisconnect: function() { + this.mode.isEdit = false; + }, + + SetDisabled: function(state, canProtect, fillFormMode) { + this._isDisabled = state; + this.documentHolder.SetDisabled(state, canProtect, fillFormMode); + }, + + onTextLanguage: function(langid) { + this.documentHolder._currLang.id = langid; + }, + + onSpellCheckVariantsFound: function() { + var me = this; + var selectedElements = me.api.getSelectedElements(true); + var props; + if (selectedElements && _.isArray(selectedElements)){ + for (var i = 0; i = 0; i--) { + var elType, elValue; + elType = selectedElements[i].get_ObjectType(); + elValue = selectedElements[i].get_ObjectValue(); + + if (Asc.c_oAscTypeSelectElement.Paragraph == elType) { + win = new DE.Views.ParagraphSettingsAdvanced({ + tableStylerRows : 2, + tableStylerColumns : 1, + paragraphProps : elValue, + borderProps : me.borderAdvancedProps, + isChart : (item.isChart===true), + isSmartArtInternal : (item.isSmartArtInternal===true), + api : me.api, + handler: function(result, value) { + if (result == 'ok') { + if (me.api) { + me.borderAdvancedProps = value.borderProps; + me.api.paraApply(value.paragraphProps); + } + } + me.editComplete(); + } + }); + break; + } + } + } + } + + if (win) { + win.show(); + return win; + } + }, + + advancedFrameClick: function(isFrame, item, e, eOpt){ + Common.NotificationCenter.trigger('dropcap:settings', isFrame); + }, + + advancedTableClick: function(item, e, eOpt){ + var win, me = this; + if (me.api){ + var selectedElements = me.api.getSelectedElements(); + + if (selectedElements && _.isArray(selectedElements)){ + for (var i = selectedElements.length - 1; i >= 0; i--) { + var elType, elValue; + + elType = selectedElements[i].get_ObjectType(); + elValue = selectedElements[i].get_ObjectValue(); + + if (Asc.c_oAscTypeSelectElement.Table == elType) { + win = new DE.Views.TableSettingsAdvanced({ + tableStylerRows : (elValue.get_CellBorders().get_InsideH()===null && elValue.get_CellSelect()==true) ? 1 : 2, + tableStylerColumns : (elValue.get_CellBorders().get_InsideV()===null && elValue.get_CellSelect()==true) ? 1 : 2, + tableProps : elValue, + borderProps : me.borderAdvancedProps, + sectionProps : me.api.asc_GetSectionProps(), + handler : function(result, value) { + if (result == 'ok') { + if (me.api) { + me.borderAdvancedProps = value.borderProps; + me.api.tblApply(value.tableProps); + } + } + me.editComplete(); + } + }); + break; + } + } + } + } + + if (win) { + win.show(); + return win; + } + }, + + onMenuSaveStyle:function(item, e, eOpt){ + var me = this; + if (me.api) { + Common.NotificationCenter.trigger('style:commitsave', me.api.asc_GetStyleFromFormatting()); + } + }, + + onMenuUpdateStyle:function(item, e, eOpt){ + var me = this; + if (me.api) { + Common.NotificationCenter.trigger('style:commitchange', me.api.asc_GetStyleFromFormatting()); + } + }, + + /** coauthoring begin **/ + addComment: function(item, e, eOpt){ + if (this.api && this.mode.canCoAuthoring && this.mode.canComments) { + this.documentHolder.suppressEditComplete = true; + + var controller = DE.getController('Common.Controllers.Comments'); + if (controller) { + controller.addDummyComment(); + } + } + }, + /** coauthoring end **/ + + onCutCopyPaste: function(item, e) { + var me = this; + if (me.api) { + var res = (item.value == 'cut') ? me.api.Cut() : ((item.value == 'copy') ? me.api.Copy() : me.api.Paste()); + if (!res) { + if (!Common.localStorage.getBool("de-hide-copywarning")) { + (new Common.Views.CopyWarningDialog({ + handler: function(dontshow) { + if (dontshow) Common.localStorage.setItem("de-hide-copywarning", 1); + me.editComplete(); + } + })).show(); + } + } + } + me.editComplete(); + }, + + onUndo: function () { + this.api.Undo(); + }, + + onAcceptRejectChange: function(item, e) { + if (this.api) { + if (item.value == 'accept') + this.api.asc_AcceptChanges(); + else if (item.value == 'reject') + this.api.asc_RejectChanges(); + } + this.editComplete(); + }, + + onPrintSelection: function(item){ + if (this.api){ + var printopt = new Asc.asc_CAdjustPrint(); + printopt.asc_setPrintType(Asc.c_oAscPrintType.Selection); + var opts = new Asc.asc_CDownloadOptions(null, Common.Utils.isChrome || Common.Utils.isOpera || Common.Utils.isGecko && Common.Utils.firefoxVersion>86); // if isChrome or isOpera == true use asc_onPrintUrl event + opts.asc_setAdvancedOptions(printopt); + this.api.asc_Print(opts); + this.editComplete(); + Common.component.Analytics.trackEvent('DocumentHolder', 'Print Selection'); + } + }, + + onControlsSelect: function(item, e) { + var me = this; + var props = this.api.asc_GetContentControlProperties(); + if (props) { + if (item.value == 'settings') { + (new DE.Views.ControlSettingsDialog({ + props: props, + api: me.api, + handler: function (result, value) { + if (result == 'ok') { + me.api.asc_SetContentControlProperties(value, props.get_InternalId()); + } + + me.editComplete(); + } + })).show(); + } else if (item.value == 'remove') { + props.get_FormPr() ? this.api.asc_RemoveContentControl(props.get_InternalId()) : this.api.asc_RemoveContentControlWrapper(props.get_InternalId()); + } + } + me.editComplete(); + }, + + onInsertCaption: function() { + this.documentHolder.fireEvent('links:caption'); + }, + + onContinueNumbering: function(item, e) { + this.api.asc_ContinueNumbering(); + this.editComplete(); + }, + + onStartNumbering: function(startfrom, item, e) { + if (startfrom == 1) + this.api.asc_RestartNumbering(item.value.start); + else { + var me = this; + (new DE.Views.NumberingValueDialog({ + title: me.documentHolder.textNumberingValue, + props: item.value, + handler: function (result, value) { + if (result == 'ok') + me.api.asc_RestartNumbering(value); + me.editComplete(); + } + })).show(); + } + this.editComplete(); + }, + + onCellsRemove: function() { + var me = this; + (new Common.Views.OptionsDialog({ + title: me.documentHolder.textTitleCellsRemove, + items: [ + {caption: this.documentHolder.textLeft, value: 'left'}, + {caption: this.documentHolder.textRow, value: 'row'}, + {caption: this.documentHolder.textCol, value: 'col'} + ], + handler: function (dlg, result) { + if (result=='ok') { + var value = dlg.getSettings(); + if (value == 'row') + me.api.remRow(); + else if (value == 'col') + me.api.remColumn(); + else + me.api.asc_RemoveTableCells(); + } + me.editComplete(); + } + })).show(); + this.editComplete(); + }, + + 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.editComplete(); + } + })).show(); + this.editComplete(); + }, + + onSignatureClick: function(item) { + var datavalue = item.cmpEl.attr('data-value'); + switch (item.value) { + case 0: + Common.NotificationCenter.trigger('protect:sign', datavalue); //guid + break; + case 1: + this.api.asc_ViewCertificate(datavalue); //certificate id + break; + case 2: + Common.NotificationCenter.trigger('protect:signature', 'visible', this._isDisabled, datavalue);//guid, can edit settings for requested signature + break; + case 3: + var me = this; + Common.UI.warning({ + title: this.documentHolder.notcriticalErrorTitle, + msg: this.documentHolder.txtRemoveWarning, + buttons: ['ok', 'cancel'], + primary: 'ok', + callback: function(btn) { + if (btn == 'ok') { + me.api.asc_RemoveSignature(datavalue); + } + } + }); + break; + } + }, + + onImgRotate: function(item) { + var properties = new Asc.asc_CImgProperty(); + properties.asc_putRotAdd((item.value==1 ? 90 : 270) * 3.14159265358979 / 180); + this.api.ImgApply(properties); + this.editComplete(); + }, + + 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.editComplete(); + }, + + onImgCrop: function(menu, item) { + if (item.value == 1) { + this.api.asc_cropFill(); + } else if (item.value == 2) { + this.api.asc_cropFit(); + } else { + item.checked ? this.api.asc_startEditCrop() : this.api.asc_endEditCrop(); + } + this.editComplete(); + }, + + onFollowMove: function(item) { + if (this.api) { + this.api.asc_FollowRevisionMove(item.value); + } + this.editComplete(); + }, + + tableCellsVAlign: function(menu, item, e) { + if (this.api) { + var properties = new Asc.CTableProp(); + properties.put_CellsVAlign(item.options.valign); + this.api.tblApply(properties); + } + }, + + tableSelectText: function(menu, item, e) { + if (this.api) { + switch (item.value) { + case 0: + this.api.selectRow(); + break; + case 1: + this.api.selectColumn(); + break; + case 2: + this.api.selectCell(); + break; + case 3: + this.api.selectTable(); + break; + } + } + }, + + tableInsertText: function(menu, item, e) { + if (this.api) { + switch (item.value) { + case 0: + this.api.addColumnLeft(); + break; + case 1: + this.api.addColumnRight(); + break; + case 2: + this.api.addRowAbove(); + break; + case 3: + this.api.addRowBelow(); + break; + case 4: + this.onCellsAdd(); + break; + } + } + }, + + tableDeleteText: function(menu, item, e) { + if (this.api) { + switch (item.value) { + case 0: + this.api.remRow(); + break; + case 1: + this.api.remColumn(); + break; + case 2: + this.api.remTable(); + break; + case 3: + this.onCellsRemove(); + break; + } + } + }, + + onImgAlign: function(menu, item, e) { + var me = this; + if (me.api) { + var alignto = Common.Utils.InternalSettings.get("de-img-align-to"), + value = (alignto==1) ? Asc.c_oAscObjectsAlignType.Page : ((me.api.asc_getSelectedDrawingObjectsCount()<2 && !alignto || alignto==2) ? Asc.c_oAscObjectsAlignType.Margin : Asc.c_oAscObjectsAlignType.Selected); + if (item.value < 6) { + me.api.put_ShapesAlign(item.value, value); + Common.component.Analytics.trackEvent('DocumentHolder', 'Shape Align'); + } else if (item.value == 6) { + me.api.DistributeHorizontally(value); + Common.component.Analytics.trackEvent('DocumentHolder', 'Distribute Horizontally'); + } else if (item.value == 7){ + me.api.DistributeVertically(value); + Common.component.Analytics.trackEvent('DocumentHolder', 'Distribute Vertically'); + } + } + me.editComplete(); + }, + + onImgArrange: function(menu, item, e) { + var me = this; + if (me.api && item.options.valign!==undefined) { + var properties = new Asc.asc_CImgProperty(); + properties.put_ChangeLevel(item.options.valign); + me.api.ImgApply(properties); + } + me.editComplete(); + }, + + onImgGroup: function(item) { + var me = this; + if (me.api) { + var properties = new Asc.asc_CImgProperty(); + properties.put_Group(1); + me.api.ImgApply(properties); + } + me.editComplete(); + }, + + onImgUnGroup: function(item) { + var me = this; + if (me.api) { + var properties = new Asc.asc_CImgProperty(); + properties.put_Group(-1); + me.api.ImgApply(properties); + } + me.editComplete(); + }, + + onImgWrapPolygon: function(item) { + this.api && this.api.StartChangeWrapPolygon(); + this.editComplete(); + }, + + onImgWrap: function (menu, item, e) { + var me = this; + if (me.api && item.options.wrapType!==undefined) { + var properties = new Asc.asc_CImgProperty(); + properties.put_WrappingStyle(item.options.wrapType); + + if (me.documentHolder.menuImageWrap._originalProps.get_WrappingStyle() === Asc.c_oAscWrapStyle2.Inline && item.wrapType !== Asc.c_oAscWrapStyle2.Inline ) { + properties.put_PositionH(new Asc.CImagePositionH()); + properties.get_PositionH().put_UseAlign(false); + properties.get_PositionH().put_RelativeFrom(Asc.c_oAscRelativeFromH.Column); + var val = me.documentHolder.menuImageWrap._originalProps.get_Value_X(Asc.c_oAscRelativeFromH.Column); + properties.get_PositionH().put_Value(val); + + properties.put_PositionV(new Asc.CImagePositionV()); + properties.get_PositionV().put_UseAlign(false); + properties.get_PositionV().put_RelativeFrom(Asc.c_oAscRelativeFromV.Paragraph); + val = me.documentHolder.menuImageWrap._originalProps.get_Value_Y(Asc.c_oAscRelativeFromV.Paragraph); + properties.get_PositionV().put_Value(val); + } + me.api.ImgApply(properties); + } + me.editComplete(); + }, + + onImgAdvanced: function(item, e) { + var elType, elValue; + var me = this; + if (me.api){ + var selectedElements = me.api.getSelectedElements(); + + if (selectedElements && _.isArray(selectedElements)) { + for (var i = selectedElements.length - 1; i >= 0; i--) { + elType = selectedElements[i].get_ObjectType(); + elValue = selectedElements[i].get_ObjectValue(); + + if (Asc.c_oAscTypeSelectElement.Image == elType) { + var imgsizeOriginal; + if ( !elValue.get_ChartProperties() && !elValue.get_ShapeProperties() && !me.documentHolder.menuOriginalSize.isDisabled() && me.documentHolder.menuOriginalSize.isVisible()) { + imgsizeOriginal = me.api.get_OriginalSizeImage(); + if (imgsizeOriginal) + imgsizeOriginal = {width:imgsizeOriginal.get_ImageWidth(), height:imgsizeOriginal.get_ImageHeight()}; + } + + var win = new DE.Views.ImageSettingsAdvanced({ + imageProps : elValue, + sizeOriginal: imgsizeOriginal, + api : me.api, + sectionProps: me.api.asc_GetSectionProps(), + handler : function(result, value) { + if (result == 'ok') { + if (me.api) { + me.api.ImgApply(value.imageProps); + } + } + me.editComplete(); + } + }); + win.show(); + win.btnOriginalSize.setVisible(me.documentHolder.menuOriginalSize.isVisible()); + break; + } + } + } + } + }, + + onImgOriginalSize: function(item, e) { + var me = this; + if (me.api){ + var originalImageSize = me.api.get_OriginalSizeImage(); + + var properties = new Asc.asc_CImgProperty(); + properties.put_Width(originalImageSize.get_ImageWidth()); + properties.put_Height(originalImageSize.get_ImageHeight()); + properties.put_ResetCrop(true); + properties.put_Rot(0); + me.api.ImgApply(properties); + + me.editComplete(); + } + }, + + onImgReplace: function(menu, item, e) { + var me = this; + if (item.value==1) { + (new Common.Views.ImageFromUrlDialog({ + handler: function(result, value) { + if (result == 'ok') { + if (me.api) { + var checkUrl = value.replace(/ /g, ''); + if (!_.isEmpty(checkUrl)) { + var props = new Asc.asc_CImgProperty(); + props.put_ImageUrl(checkUrl); + me.api.ImgApply(props); + } + } + } + me.editComplete(); + } + })).show(); + } else if (item.value==2) { + Common.NotificationCenter.trigger('storage:image-load', 'change'); + } else { + setTimeout(function(){ + if (me.api) me.api.ChangeImageFromFile(); + me.editComplete(); + }, 10); + } + }, + + onImgEditPoints: function(item) { + this.api && this.api.asc_editPointsGeometry(); + }, + + onTableMerge: function(item) { + this.api && this.api.MergeCells(); + }, + + onTableSplit: function(item) { + var me = this; + if (me.api){ + (new Common.Views.InsertTableDialog({ + split: true, + handler: function(result, value) { + if (result == 'ok') { + if (me.api) { + me.api.SplitCell(value.columns, value.rows); + } + Common.component.Analytics.trackEvent('DocumentHolder', 'Table'); + } + me.editComplete(); + } + })).show(); + } + }, + + onIgnoreSpell: function(item, e){ + this.api && this.api.asc_ignoreMisspelledWord(this.documentHolder._currentSpellObj, !!item.value); + this.editComplete(); + }, + + onToDictionary: function(item, e){ + this.api && this.api.asc_spellCheckAddToDictionary(this.documentHolder._currentSpellObj); + this.editComplete(); + }, + + onTableDist: function(item, e){ + this.api && this.api.asc_DistributeTableCells(!!item.value); + this.editComplete(); + }, + + tableDirection: function(menu, item, e) { + var me = this; + if (me.api) { + var properties = new Asc.CTableProp(); + properties.put_CellsTextDirection(item.options.direction); + me.api.tblApply(properties); + } + }, + + onRefreshField: function(item, e){ + this.api && this.api.asc_UpdateComplexField(item.options.fieldProps); + this.editComplete(); + }, + + onParagraphBreakBefore: function(item, e){ + this.api && this.api.put_PageBreak(item.checked); + }, + + onParagraphKeepLines: function(item, e){ + this.api && this.api.put_KeepLines(item.checked); + }, + + paragraphVAlign: function(menu, item, e) { + var me = this; + if (me.api) { + var properties = new Asc.asc_CImgProperty(); + properties.put_VerticalTextAlign(item.options.valign); + me.api.ImgApply(properties); + } + }, + + paragraphDirection: function(menu, item, e) { + var me = this; + if (me.api) { + var properties = new Asc.asc_CImgProperty(); + properties.put_Vert(item.options.direction); + me.api.ImgApply(properties); + } + }, + + onLangMenu: function(type, menu, item){ + var me = this; + if (me.api){ + if (!_.isUndefined(item.langid)) + me.api.put_TextPrLang(item.langid); + + (type==='para') ? (me.documentHolder._currLang.paraid = item.langid) : (me.documentHolder._currLang.tableid = item.langid); + me.editComplete(); + } + }, + + onTOCMenu: function(menu, item, e) { + this.documentHolder.fireEvent((item.value==='settings') ? 'links:contents' : 'links:update', [item.value, true]); + }, + + onParaTOCSettings: function(item, e) { + this.documentHolder.fireEvent('links:contents', [item.value, true]); + }, + + editComplete: function() { + this.documentHolder && this.documentHolder.fireEvent('editcomplete', this.documentHolder); } }); }); \ No newline at end of file diff --git a/apps/documenteditor/main/app/controller/Links.js b/apps/documenteditor/main/app/controller/Links.js index f8947d704..cd3577712 100644 --- a/apps/documenteditor/main/app/controller/Links.js +++ b/apps/documenteditor/main/app/controller/Links.js @@ -454,7 +454,8 @@ define([ onShowTOCActions: function(obj, x, y) { var action = obj.button, menu = (action==AscCommon.CCButtonType.Toc) ? this.view.contentsUpdateMenu : this.view.contentsMenu, - documentHolderView = this.getApplication().getController('DocumentHolder').documentHolder, + documentHolder = this.getApplication().getController('DocumentHolder'), + documentHolderView = documentHolder.getView(), menuContainer = documentHolderView.cmpEl.find(Common.Utils.String.format('#menu-container-{0}', menu.id)), me = this; @@ -479,7 +480,7 @@ define([ menuContainer.css({left: x, top : y}); menuContainer.attr('data-value', 'prevent-canvas-click'); - documentHolderView._preventClick = true; + documentHolder._preventClick = true; menu.show(); menu.alignPosition(); diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index cc29c1909..d0db04c58 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -814,7 +814,7 @@ define([ app.getController('Toolbar').DisableToolbar(disable, options.viewMode, options.reviewMode, options.fillFormMode); } if (options.documentHolder) { - app.getController('DocumentHolder').getView().SetDisabled(disable, options.allowProtect, options.fillFormMode); + app.getController('DocumentHolder').SetDisabled(disable, options.allowProtect, options.fillFormMode); } if (options.leftMenu) { if (options.leftMenu.disable) @@ -1262,7 +1262,7 @@ define([ pluginsController.setApi(me.api); documentHolderController.setApi(me.api); - documentHolderController.createDelayedElements(); + // documentHolderController.createDelayedElements(); statusbarController.createDelayedElements(); leftmenuController.getView('LeftMenu').disableMenu('all',false); @@ -1270,7 +1270,7 @@ define([ if (me.appOptions.canBranding) me.getApplication().getController('LeftMenu').leftMenu.getMenu('about').setLicInfo(me.editorConfig.customization); - documentHolderController.getView().setApi(me.api).on('editcomplete', _.bind(me.onEditComplete, me)); + documentHolderController.getView().on('editcomplete', _.bind(me.onEditComplete, me)); if (me.appOptions.isEdit) { if (me.appOptions.canForcesave) {// use asc_setIsForceSaveOnUserSave only when customization->forcesave = true @@ -1645,7 +1645,7 @@ define([ var app = this.getApplication(), viewport = app.getController('Viewport').getView('Viewport'), statusbarView = app.getController('Statusbar').getView('Statusbar'), - documentHolder = app.getController('DocumentHolder').getView(), + documentHolder = app.getController('DocumentHolder'), toolbarController = app.getController('Toolbar'); viewport && viewport.setMode(this.appOptions); @@ -2259,7 +2259,7 @@ define([ synchronizeChanges: function() { this.getApplication().getController('Statusbar').synchronizeChanges(); this.getApplication().getController('Common.Controllers.ReviewChanges').synchronizeChanges(); - this.getApplication().getController('DocumentHolder').getView().hideTips(); + this.getApplication().getController('DocumentHolder').hideTips(); /** coauthoring begin **/ this.getApplication().getController('Toolbar').getView().synchronizeChanges(); /** coauthoring end **/ diff --git a/apps/documenteditor/main/app/view/DocumentHolder.js b/apps/documenteditor/main/app/view/DocumentHolder.js index d66adfac4..41e2eba48 100644 --- a/apps/documenteditor/main/app/view/DocumentHolder.js +++ b/apps/documenteditor/main/app/view/DocumentHolder.js @@ -71,1582 +71,11 @@ define([ }, 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; - me._isDisabled = false; - me._state = {}; - var showPopupMenu = function(menu, value, event, docElement, eOpts){ - if (!_.isUndefined(menu) && menu !== null){ - 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('', 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 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){ - if (key === Common.UI.Keys.NUM_PLUS || key === Common.UI.Keys.EQUALITY || (Common.Utils.isGecko && key === Common.UI.Keys.EQUALITY_FF) || (Common.Utils.isOpera && key == 43)){ - me.api.zoomIn(); - event.preventDefault(); - event.stopPropagation(); - return false; - } - else if (key === Common.UI.Keys.NUM_MINUS || key === Common.UI.Keys.MINUS || (Common.Utils.isGecko && key === Common.UI.Keys.MINUS_FF) || (Common.Utils.isOpera && key == 45)){ - me.api.zoomOut(); - event.preventDefault(); - event.stopPropagation(); - return false; - } else if (key === 48 || key === 96) {// 0 - me.api.zoom(100); - event.preventDefault(); - event.stopPropagation(); - return false; - } - } - 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(); - if (!Common.UI.HintManager.isHintVisible()) - 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') { - if (me._preventClick) - me._preventClick = false; - else - meEl.focus(); - } - }); - meEl.on('mousedown', function(e){ - if (e.target.localName == 'canvas') - Common.UI.Menu.Manager.hideAll(); - }); - - //NOTE: set mouse wheel handler - - var addEvent = function( elem, type, fn ) { - elem.addEventListener ? elem.addEventListener( type, fn, false ) : elem.attachEvent( "on" + type, fn ); - }; - - var eventname=(/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel'; - addEvent(me.el, eventname, handleDocumentWheel); - } - - !Common.Utils.isChrome ? $(document).on('mousewheel', handleDocumentWheel) : - document.addEventListener('mousewheel', handleDocumentWheel, {passive: false}); - $(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 AscCommon.UserInfoParser.getParsedName(rec.get('username')); - } - return me.guestText; - }; - var isUserVisible = function(id){ - if (usersStore){ - var rec = usersStore.findUser(id); - if (rec) - return !rec.get('hidden'); - } - return true; - }; - /** coauthoring end **/ - - - var screenTip = { - toolTip: new Common.UI.Tooltip({ - owner: this, - html: true, - title: '
Press Ctrl and click link', - cls: 'link-tooltip' -// 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; i0) - window.open(url); - else - Common.UI.warning({ - msg: me.txtWarnUrl, - buttons: ['yes', 'no'], - primary: 'yes', - callback: function(btn) { - (btn == 'yes') && 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 **/ - }; - - var mouseMoveData = null, - isTooltipHiding = false; - - var onMouseMoveEnd = function() { - if (screenTip.isHidden && screenTip.isVisible) { - screenTip.isVisible = false; - isTooltipHiding = true; - screenTip.toolTip.hide(function(){ - isTooltipHiding = false; - if (mouseMoveData) onMouseMove(mouseMoveData); - mouseMoveData = null; - }); - } - }; - - 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) { - var showPoint, ToolTip, - type = moveData.get_Type(); - - if (type==Asc.c_oAscMouseMoveDataTypes.Hyperlink || type==Asc.c_oAscMouseMoveDataTypes.Footnote || type==Asc.c_oAscMouseMoveDataTypes.Form || - type==Asc.c_oAscMouseMoveDataTypes.Review && me.mode.reviewHoverMode) { - if (isTooltipHiding) { - mouseMoveData = moveData; - return; - } - - if (type==Asc.c_oAscMouseMoveDataTypes.Hyperlink) { - var hyperProps = moveData.get_Hyperlink(); - if (!hyperProps) return; - ToolTip = (_.isEmpty(hyperProps.get_ToolTip())) ? hyperProps.get_Value() : hyperProps.get_ToolTip(); - if (ToolTip.length>256) - ToolTip = ToolTip.substr(0, 256) + '...'; - } else if (type == Asc.c_oAscMouseMoveDataTypes.Footnote) { - ToolTip = moveData.get_FootnoteText(); - if (ToolTip.length>1000) - ToolTip = ToolTip.substr(0, 1000) + '...'; - } else if (type==Asc.c_oAscMouseMoveDataTypes.Form) { - ToolTip = moveData.get_FormHelpText(); - if (ToolTip.length>1000) - ToolTip = ToolTip.substr(0, 1000) + '...'; - } else if (type==Asc.c_oAscMouseMoveDataTypes.Review && moveData.get_ReviewChange()) { - var changes = DE.getController("Common.Controllers.ReviewChanges").readSDKChange([moveData.get_ReviewChange()]); - if (changes && changes.length>0) - changes = changes[0]; - if (changes) { - ToolTip = ''+ Common.Utils.String.htmlEncode(AscCommon.UserInfoParser.getParsedName(changes.get('username'))) +' '; - ToolTip += ''+ changes.get('date') +'
'; - ToolTip += changes.get('changetext'); - if (ToolTip.length>1000) - ToolTip = ToolTip.substr(0, 1000) + '...'; - } - } - - var recalc = false; - screenTip.isHidden = false; - - if (type!==Asc.c_oAscMouseMoveDataTypes.Review) - ToolTip = Common.Utils.String.htmlEncode(ToolTip); - - if (screenTip.tipType !== type || screenTip.tipLength !== ToolTip.length || screenTip.strTip.indexOf(ToolTip)<0 ) { - screenTip.toolTip.setTitle((type==Asc.c_oAscMouseMoveDataTypes.Hyperlink) ? (ToolTip + '
' + me.txtPressLink + '') : 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]); - } - - if ( recalc ) { - screenTip.tipHeight = screenTip.toolTip.getBSTip().$tip.height(); - screenTip.tipWidth = screenTip.toolTip.getBSTip().$tip.width(); - } - - recalc = false; - if (showPoint[0] + screenTip.tipWidth > me._BodyWidth ) { - showPoint[0] = me._BodyWidth - screenTip.tipWidth; - recalc = true; - } - if (showPoint[1] - screenTip.tipHeight < 0) { - showPoint[1] = (recalc) ? showPoint[1]+30 : 0; - } else - showPoint[1] -= screenTip.tipHeight; - - screenTip.toolTip.getBSTip().$tip.css({top: showPoint[1] + 'px', left: showPoint[0] + 'px'}); - } - /** coauthoring begin **/ - else if (moveData.get_Type()==Asc.c_oAscMouseMoveDataTypes.LockedObject && me.mode.isEdit && isUserVisible(moveData.get_UserId())) { // 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]]; - var maxwidth = showPoint[0]; - showPoint[0] = me._BodyWidth - showPoint[0]; - showPoint[1] -= ((moveData.get_LockedObjectType()==2) ? me._TtHeight : 0); - - if (showPoint[1] > me._XY[1] && showPoint[1]+me._TtHeight < me._XY[1]+me._Height) { - src.text(ToolTip); - src.css({visibility: 'visible', top: showPoint[1] + 'px', right: showPoint[0] + 'px', 'max-width': maxwidth + 'px'}); - } else { - src.css({visibility: 'hidden'}); - } - } - /** coauthoring end **/ - } - }; - - var onShowForeignCursorLabel = function(UserId, X, Y, color) { - if (!isUserVisible(UserId)) return; - - /** coauthoring begin **/ - var src; - for (var i=0; i
'); - me.cmpEl.find('#id_main_view').append(pasteContainer); - - me.btnSpecialPaste = new Common.UI.Button({ - parentEl: $('#id-document-holder-btn-special-paste'), - cls : 'btn-toolbar', - iconCls : 'toolbar__icon btn-paste', - menu : new Common.UI.Menu({items: []}) - }); - } - - 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]; - if (!Common.Utils.InternalSettings.get("de-hidden-rulers")) { - showPoint = [showPoint[0] - 19, showPoint[1] - 26]; - } - pasteContainer.css({left: showPoint[0], top : showPoint[1]}); - pasteContainer.show(); - } - }; - - var onHideSpecialPasteOptions = function() { - var pasteContainer = me.cmpEl.find('#special-paste-container'); - if (pasteContainer.is(':visible')) - pasteContainer.hide(); - }; - - var onDialogAddHyperlink = function() { - var win, props, text; - if (me.api && me.mode.isEdit && !me._isDisabled && !DE.getController('LeftMenu').leftMenu.menuFile.isVisible()){ - var handlerDlg = function(dlg, result) { - if (result == 'ok') { - props = dlg.getSettings(); - (text!==false) - ? me.api.add_Hyperlink(props) - : me.api.change_Hyperlink(props); - } - - me.fireEvent('editcomplete', me); - }; - - text = me.api.can_AddHyperlink(); - - if (text !== false) { - win = new DE.Views.HyperlinkSettingsDialog({ - api: me.api, - handler: handlerDlg - }); - - props = new Asc.CHyperlinkProperty(); - props.put_Text(text); - - win.show(); - win.setSettings(props); - } else { - var selectedElements = me.api.getSelectedElements(); - if (selectedElements && _.isArray(selectedElements)){ - _.each(selectedElements, function(el, i) { - if (selectedElements[i].get_ObjectType() == Asc.c_oAscTypeSelectElement.Hyperlink) - props = selectedElements[i].get_ObjectValue(); - }); - } - if (props) { - win = new DE.Views.HyperlinkSettingsDialog({ - api: me.api, - handler: handlerDlg - }); - win.show(); - win.setSettings(props); - } - } - Common.component.Analytics.trackEvent('DocumentHolder', 'Add Hyperlink'); - } - }; - - var onDoubleClickOnChart = function(chart) { - if (me.mode.isEdit && !me._isDisabled) { - 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 onDoubleClickOnTableOleObject = function(chart) { - if (me.mode.isEdit && !me._isDisabled) { - var oleEditor = DE.getController('Common.Controllers.ExternalOleEditor').getView('Common.Views.ExternalOleEditor'); - if (oleEditor && chart) { - oleEditor.setEditMode(true); - oleEditor.show(); - oleEditor.setOleData(Asc.asc_putBinaryDataToFrameFromTableOleObject(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) { - menu.clearAll(); - } else { - var index = _.findIndex(menu.items, {langid: me._currLang.id}); - (index>-1) && !menu.items[index].checked && menu.setChecked(index, true); - } - }; - - var onSpellCheckVariantsFound = function() { - var selectedElements = me.api.getSelectedElements(true); - var props; - if (selectedElements && _.isArray(selectedElements)){ - for (var i = 0; i 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) { - _.each(arr, function(variant, index){ - me.textMenu.insertItem(index, variant); - }) - } else { - _.each(arr, function(variant, index){ - me.menuSpellCheckTable.menu.insertItem(index, variant); - }) - } - } - - if (arrMore.length > 0) { - _.each(arrMore, function(variant, index){ - moreMenu.menu.addItem(variant); - }); - } - - 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) { - 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({ - cls: 'shifted-right', - 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({ - cls: 'shifted-right', - 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({ - cls: 'shifted-right', - 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({ - cls: 'shifted-right', - 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({ - cls: 'shifted-right', - 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({ - cls: 'shifted-right', - 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; - }; - - 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) { - 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); - } - } - 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_doubleClickOnTableOleObject', onDoubleClickOnTableOleObject); - this.api.asc_registerCallback('asc_onSpellCheckVariantsFound', _.bind(onSpellCheckVariantsFound, this)); - this.api.asc_registerCallback('asc_onRulerDblClick', _.bind(this.onRulerDblClick, this)); - this.api.asc_registerCallback('asc_ChangeCropState', _.bind(this.onChangeCropState, this)); - this.api.asc_registerCallback('asc_onLockDocumentProps', _.bind(this.onApiLockDocumentProps, this)); - this.api.asc_registerCallback('asc_onUnLockDocumentProps', _.bind(this.onApiUnLockDocumentProps, this)); - } - this.api.asc_registerCallback('asc_onCoAuthoringDisconnect', _.bind(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)); - this.api.asc_registerCallback('asc_onShowSpecialPasteOptions', _.bind(onShowSpecialPasteOptions, this)); - this.api.asc_registerCallback('asc_onHideSpecialPasteOptions', _.bind(onHideSpecialPasteOptions, this)); - if (this.mode.isEdit || this.mode.isRestrictedEdit && this.mode.canFillForms) { - this.api.asc_registerCallback('asc_onShowContentControlsActions',_.bind(this.onShowContentControlsActions, this)); - this.api.asc_registerCallback('asc_onHideContentControlsActions',_.bind(this.onHideContentControlsActions, this)); - } - } - - return this; - }; - - this.mode = {}; - this.setMode = function(m) { - this.mode = m; - /** coauthoring begin **/ - !(this.mode.canCoAuthoring && this.mode.canComments) - ? Common.util.Shortcuts.suspendEvents(hkComments) - : Common.util.Shortcuts.resumeEvents(hkComments); - /** coauthoring end **/ - this.editorConfig = {user: m.user}; - this._fillFormMode = !this.mode.isEdit && this.mode.canFillForms; - }; - - me.on('render:after', onAfterRender, me); + this._currentMathObj = undefined; + this._currentSpellObj = undefined; + this._currentParaObjDisabled = false; + this._currLang = {}; + this._isDisabled = false; }, render: function () { @@ -1658,432 +87,62 @@ define([ return this; }, - onImgWrapStyleChanged: function(type){ - switch (type) { - case Asc.c_oAscWrapStyle2.Inline: - this.menuImageWrap.menu.items[0].setChecked(true); - break; - case Asc.c_oAscWrapStyle2.Square: - this.menuImageWrap.menu.items[2].setChecked(true); - break; - case Asc.c_oAscWrapStyle2.Tight: - this.menuImageWrap.menu.items[3].setChecked(true); - break; - case Asc.c_oAscWrapStyle2.Through: - this.menuImageWrap.menu.items[4].setChecked(true); - break; - case Asc.c_oAscWrapStyle2.TopAndBottom: - this.menuImageWrap.menu.items[5].setChecked(true); - break; - case Asc.c_oAscWrapStyle2.Behind: - this.menuImageWrap.menu.items[8].setChecked(true); - break; - case Asc.c_oAscWrapStyle2.InFront: - this.menuImageWrap.menu.items[7].setChecked(true); - break; - } + setApi: function(o) { + this.api = o; + return this; }, - onChangeCropState: function(state) { - this.menuImgCrop.menu.items[0].setChecked(state, true); - }, - - 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(); - - if (Asc.c_oAscTypeSelectElement.Paragraph == elType) { - win = new DE.Views.ParagraphSettingsAdvanced({ - tableStylerRows : 2, - tableStylerColumns : 1, - paragraphProps : elValue, - borderProps : me.borderAdvancedProps, - isChart : (item.isChart===true), - isSmartArtInternal : (item.isSmartArtInternal===true), - api : me.api, - handler: function(result, value) { - if (result == 'ok') { - if (me.api) { - me.borderAdvancedProps = value.borderProps; - me.api.paraApply(value.paragraphProps); - } - } - me.fireEvent('editcomplete', me); - } - }); - break; - } - } - } - } - - if (win) { - win.show(); - return win; - } - }, - - advancedFrameClick: function(isFrame, item, e, eOpt){ - Common.NotificationCenter.trigger('dropcap:settings', isFrame); - }, - - advancedTableClick: function(item, e, eOpt){ - var win, me = this; - if (me.api){ - var selectedElements = me.api.getSelectedElements(); - - if (selectedElements && _.isArray(selectedElements)){ - for (var i = selectedElements.length - 1; i >= 0; i--) { - var elType, elValue; - - elType = selectedElements[i].get_ObjectType(); - elValue = selectedElements[i].get_ObjectValue(); - - if (Asc.c_oAscTypeSelectElement.Table == elType) { - win = new DE.Views.TableSettingsAdvanced({ - tableStylerRows : (elValue.get_CellBorders().get_InsideH()===null && elValue.get_CellSelect()==true) ? 1 : 2, - tableStylerColumns : (elValue.get_CellBorders().get_InsideV()===null && elValue.get_CellSelect()==true) ? 1 : 2, - tableProps : elValue, - borderProps : me.borderAdvancedProps, - sectionProps : me.api.asc_GetSectionProps(), - handler : function(result, value) { - if (result == 'ok') { - if (me.api) { - me.borderAdvancedProps = value.borderProps; - me.api.tblApply(value.tableProps); - } - } - me.fireEvent('editcomplete', me); - } - }); - break; - } - } - } - } - - if (win) { - win.show(); - return win; - } - }, - - onRulerDblClick: function(type) { - Common.UI.Menu.Manager.hideAll(); - - var win, me = this; - if (type == 'tables') { - win = this.advancedTableClick(); - if (win) - win.setActiveCategory(4); - } else if (type == 'indents' || type == 'tabs') { - win = this.advancedParagraphClick({isChart: false}); - if (win) - win.setActiveCategory(type == 'indents' ? 0 : 4); - } else if (type == 'margins') { - if (me._state.lock_doc) return; - win = new DE.Views.PageMarginsDialog({ - api: me.api, - handler: function(dlg, result) { - if (result == 'ok') { - var props = dlg.getSettings(); - var mnu = DE.getController('Toolbar').toolbar.btnPageMargins.menu.items[0]; - mnu.setVisible(true); - mnu.setChecked(true); - mnu.options.value = mnu.value = [props.get_TopMargin(), props.get_LeftMargin(), props.get_BottomMargin(), props.get_RightMargin()]; - $(mnu.el).html(mnu.template({id: Common.UI.getId(), caption : mnu.caption, options : mnu.options})); - Common.localStorage.setItem("de-pgmargins-top", props.get_TopMargin()); - Common.localStorage.setItem("de-pgmargins-left", props.get_LeftMargin()); - Common.localStorage.setItem("de-pgmargins-bottom", props.get_BottomMargin()); - Common.localStorage.setItem("de-pgmargins-right", props.get_RightMargin()); - - me.api.asc_SetSectionProps(props); - 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()); - } - }, - - 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){ - if (this.api && this.mode.canCoAuthoring && this.mode.canComments) { - 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) { - var res = (item.value == 'cut') ? me.api.Cut() : ((item.value == 'copy') ? me.api.Copy() : me.api.Paste()); - if (!res) { - if (!Common.localStorage.getBool("de-hide-copywarning")) { - (new Common.Views.CopyWarningDialog({ - handler: function(dontshow) { - if (dontshow) Common.localStorage.setItem("de-hide-copywarning", 1); - me.fireEvent('editcomplete', me); - } - })).show(); - } - } - } - me.fireEvent('editcomplete', me); - }, - - onAcceptRejectChange: function(item, e) { - if (this.api) { - if (item.value == 'accept') - this.api.asc_AcceptChanges(); - else if (item.value == 'reject') - this.api.asc_RejectChanges(); - } - this.fireEvent('editcomplete', this); - }, - - onPrintSelection: function(item){ - if (this.api){ - var printopt = new Asc.asc_CAdjustPrint(); - printopt.asc_setPrintType(Asc.c_oAscPrintType.Selection); - var opts = new Asc.asc_CDownloadOptions(null, Common.Utils.isChrome || Common.Utils.isOpera || Common.Utils.isGecko && Common.Utils.firefoxVersion>86); // if isChrome or isOpera == true use asc_onPrintUrl event - opts.asc_setAdvancedOptions(printopt); - this.api.asc_Print(opts); - this.fireEvent('editcomplete', this); - Common.component.Analytics.trackEvent('DocumentHolder', 'Print Selection'); - } - }, - - onControlsSelect: function(item, e) { - var me = this; - var props = this.api.asc_GetContentControlProperties(); - if (props) { - if (item.value == 'settings') { - (new DE.Views.ControlSettingsDialog({ - props: props, - api: me.api, - handler: function (result, value) { - if (result == 'ok') { - me.api.asc_SetContentControlProperties(value, props.get_InternalId()); - } - - me.fireEvent('editcomplete', me); - } - })).show(); - } else if (item.value == 'remove') { - props.get_FormPr() ? this.api.asc_RemoveContentControl(props.get_InternalId()) : this.api.asc_RemoveContentControlWrapper(props.get_InternalId()); - } - } - me.fireEvent('editcomplete', me); - }, - - onInsertCaption: function() { - this.fireEvent('links:caption'); - }, - - onContinueNumbering: function(item, e) { - this.api.asc_ContinueNumbering(); - this.fireEvent('editcomplete', this); - }, - - onStartNumbering: function(startfrom, item, e) { - if (startfrom == 1) - this.api.asc_RestartNumbering(item.value.start); - else { - var me = this; - (new DE.Views.NumberingValueDialog({ - title: me.textNumberingValue, - props: item.value, - handler: function (result, value) { - if (result == 'ok') - me.api.asc_RestartNumbering(value); - me.fireEvent('editcomplete', me); - } - })).show(); - } - this.fireEvent('editcomplete', this); - }, - - onCellsRemove: function() { - var me = this; - (new Common.Views.OptionsDialog({ - title: me.textTitleCellsRemove, - items: [ - {caption: this.textLeft, value: 'left'}, - {caption: this.textRow, value: 'row'}, - {caption: this.textCol, value: 'col'} - ], - handler: function (dlg, result) { - if (result=='ok') { - var value = dlg.getSettings(); - if (value == 'row') - me.api.remRow(); - else if (value == 'col') - me.api.remColumn(); - else - me.api.asc_RemoveTableCells(); - } - me.fireEvent('editcomplete', me); - } - })).show(); - this.fireEvent('editcomplete', this); - }, - - 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); + setMode: function(m) { + this.mode = m; + this._fillFormMode = !this.mode.isEdit && this.mode.canFillForms; + return this; }, createDelayedElementsViewer: function() { var me = this; - var menuViewCopy = new Common.UI.MenuItem({ + me.menuViewCopy = new Common.UI.MenuItem({ iconCls: 'menu__icon btn-copy', caption: me.textCopy, value: 'copy' - }).on('click', _.bind(me.onCutCopyPaste, me)); + }); - var menuViewPaste = new Common.UI.MenuItem({ + me.menuViewPaste = new Common.UI.MenuItem({ iconCls: 'menu__icon btn-paste', caption : me.textPaste, value : 'paste' - }).on('click', _.bind(me.onCutCopyPaste, me)); + }); - var menuViewCut = new Common.UI.MenuItem({ + me.menuViewCut = new Common.UI.MenuItem({ iconCls: 'menu__icon btn-cut', caption : me.textCut, value : 'cut' - }).on('click', _.bind(me.onCutCopyPaste, me)); - - var menuViewUndo = new Common.UI.MenuItem({ - iconCls: 'menu__icon btn-undo', - caption: me.textUndo - }).on('click', function () { - me.api.Undo(); }); - var menuViewCopySeparator = new Common.UI.MenuItem({ + me.menuViewUndo = new Common.UI.MenuItem({ + iconCls: 'menu__icon btn-undo', + caption: me.textUndo + }); + + me.menuViewCopySeparator = new Common.UI.MenuItem({ caption: '--' }); - var menuViewAddComment = new Common.UI.MenuItem({ + me.menuViewAddComment = new Common.UI.MenuItem({ iconCls: 'menu__icon btn-menu-comments', caption: me.addCommentText - }).on('click', _.bind(me.addComment, me)); + }); - 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: '--' }); + me.menuSignatureViewSign = new Common.UI.MenuItem({caption: this.strSign, value: 0 }); + me.menuSignatureDetails = new Common.UI.MenuItem({caption: this.strDetails, value: 1 }); + me.menuSignatureViewSetup = new Common.UI.MenuItem({caption: this.strSetup, value: 2 }); + me.menuSignatureRemove = new Common.UI.MenuItem({caption: this.strDelete, value: 3 }); + me.menuViewSignSeparator = new Common.UI.MenuItem({caption: '--' }); - var menuViewPrint = new Common.UI.MenuItem({ + me.menuViewPrint = new Common.UI.MenuItem({ iconCls: 'menu__icon btn-print', caption : me.txtPrintSelection - }).on('click', _.bind(me.onPrintSelection, me)); + }); this.viewModeMenu = new Common.UI.Menu({ cls: 'shifted-right', @@ -2109,51 +168,51 @@ define([ canEditControl = spectype !== undefined && (spectype === Asc.c_oAscContentControlSpecificType.None || spectype === Asc.c_oAscContentControlSpecificType.ComboBox) && !control_lock; } - menuViewUndo.setVisible(me.mode.canCoAuthoring && me.mode.canComments && !me._isDisabled); - menuViewUndo.setDisabled(!me.api.asc_getCanUndo() && !me._isDisabled); - menuViewCopySeparator.setVisible(isInSign); + me.menuViewUndo.setVisible(me.mode.canCoAuthoring && me.mode.canComments && !me._isDisabled); + me.menuViewUndo.setDisabled(!me.api.asc_getCanUndo()); + me.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); + me.menuSignatureViewSign.setVisible(isInSign && isRequested); + me.menuSignatureDetails.setVisible(isInSign && !isRequested); + me.menuSignatureViewSetup.setVisible(isInSign); + me.menuSignatureRemove.setVisible(isInSign && !isRequested); + me.menuViewSignSeparator.setVisible(canComment); if (isInSign) { - menuSignatureViewSign.cmpEl.attr('data-value', signGuid); // sign - menuSignatureDetails.cmpEl.attr('data-value', signProps.asc_getId()); // view certificate - menuSignatureViewSetup.cmpEl.attr('data-value', signGuid); // view signature settings - menuSignatureRemove.cmpEl.attr('data-value', signGuid); + me.menuSignatureViewSign.cmpEl.attr('data-value', signGuid); // sign + me.menuSignatureDetails.cmpEl.attr('data-value', signProps.asc_getId()); // view certificate + me.menuSignatureViewSetup.cmpEl.attr('data-value', signGuid); // view signature settings + me.menuSignatureRemove.cmpEl.attr('data-value', signGuid); } - menuViewAddComment.setVisible(canComment); - menuViewAddComment.setDisabled(value.paraProps && value.paraProps.locked === true); + me.menuViewAddComment.setVisible(canComment); + me.menuViewAddComment.setDisabled(value.paraProps && value.paraProps.locked === true); var disabled = value.paraProps && value.paraProps.locked === true; var cancopy = me.api && me.api.can_CopyCut(); - menuViewCopy.setDisabled(!cancopy); - menuViewCut.setVisible(me._fillFormMode && canEditControl); - menuViewCut.setDisabled(disabled || !cancopy); - menuViewPaste.setVisible(me._fillFormMode && canEditControl); - menuViewPaste.setDisabled(disabled); - menuViewPrint.setVisible(me.mode.canPrint && !me._fillFormwMode); - menuViewPrint.setDisabled(!cancopy); + me.menuViewCopy.setDisabled(!cancopy); + me.menuViewCut.setVisible(me._fillFormMode && canEditControl); + me.menuViewCut.setDisabled(disabled || !cancopy); + me.menuViewPaste.setVisible(me._fillFormMode && canEditControl); + me.menuViewPaste.setDisabled(disabled); + me.menuViewPrint.setVisible(me.mode.canPrint && !me._fillFormMode); + me.menuViewPrint.setDisabled(!cancopy); }, items: [ - menuViewCut, - menuViewCopy, - menuViewPaste, - menuViewUndo, - menuViewPrint, - menuViewCopySeparator, - menuSignatureViewSign, - menuSignatureDetails, - menuSignatureViewSetup, - menuSignatureRemove, - menuViewSignSeparator, - menuViewAddComment + me.menuViewCut, + me.menuViewCopy, + me.menuViewPaste, + me.menuViewUndo, + me.menuViewPrint, + me.menuViewCopySeparator, + me.menuSignatureViewSign, + me.menuSignatureDetails, + me.menuSignatureViewSetup, + me.menuSignatureRemove, + me.menuViewSignSeparator, + me.menuViewAddComment ] }).on('hide:after', function (menu, e, isFromInputControl) { if (me.suppressEditComplete) { @@ -2165,24 +224,25 @@ define([ me.currentMenu = null; }); + this.fireEvent('createdelayedelements', [this, 'view']); }, createDelayedElementsPDFViewer: function() { var me = this; - var menuPDFViewCopy = new Common.UI.MenuItem({ + me.menuPDFViewCopy = new Common.UI.MenuItem({ iconCls: 'menu__icon btn-copy', caption: me.textCopy, value: 'copy' - }).on('click', _.bind(me.onCutCopyPaste, me)); + }); this.viewPDFModeMenu = new Common.UI.Menu({ cls: 'shifted-right', initMenu: function (value) { - menuPDFViewCopy.setDisabled(!(me.api && me.api.can_CopyCut())); + me.menuPDFViewCopy.setDisabled(!(me.api && me.api.can_CopyCut())); }, items: [ - menuPDFViewCopy + me.menuPDFViewCopy ] }).on('hide:after', function (menu, e, isFromInputControl) { if (me.suppressEditComplete) { @@ -2194,419 +254,264 @@ define([ me.currentMenu = null; }); + this.fireEvent('createdelayedelements', [this, 'pdf']); }, createDelayedElements: function() { var me = this; - var menuInsertCaption = new Common.UI.MenuItem({ + me.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({ + me.menuEquationInsertCaption = new Common.UI.MenuItem({ caption : me.txtInsertCaption - }).on('click', _.bind(me.onInsertCaption, me)); + }); var menuEquationInsertCaptionSeparator = new Common.UI.MenuItem({ caption: '--' }); - var menuImageAlign = new Common.UI.MenuItem({ + me.menuImageAlign = new Common.UI.MenuItem({ caption : me.textAlign, - menu : (function(){ - function onItemClick(item, e) { - if (me.api) { - var alignto = Common.Utils.InternalSettings.get("de-img-align-to"), - value = (alignto==1) ? Asc.c_oAscObjectsAlignType.Page : ((me.api.asc_getSelectedDrawingObjectsCount()<2 && !alignto || alignto==2) ? Asc.c_oAscObjectsAlignType.Margin : Asc.c_oAscObjectsAlignType.Selected); - if (item.value < 6) { - me.api.put_ShapesAlign(item.value, value); - Common.component.Analytics.trackEvent('DocumentHolder', 'Shape Align'); - } else if (item.value == 6) { - me.api.DistributeHorizontally(value); - Common.component.Analytics.trackEvent('DocumentHolder', 'Distribute Horizontally'); - } else if (item.value == 7){ - me.api.DistributeVertically(value); - Common.component.Analytics.trackEvent('DocumentHolder', 'Distribute Vertically'); - } - } - me.fireEvent('editcomplete', me); - } - return new Common.UI.Menu({ - cls: 'ppm-toolbar shifted-right', - menuAlign: 'tl-tr', - items: [ - new Common.UI.MenuItem({ - caption : me.textShapeAlignLeft, - iconCls : 'menu__icon shape-align-left', - value: Asc.c_oAscAlignShapeType.ALIGN_LEFT - }).on('click', onItemClick), - new Common.UI.MenuItem({ - caption : me.textShapeAlignCenter, - iconCls : 'menu__icon shape-align-center', - value: Asc.c_oAscAlignShapeType.ALIGN_CENTER - }).on('click', onItemClick), - new Common.UI.MenuItem({ - caption : me.textShapeAlignRight, - iconCls : 'menu__icon shape-align-right', - value: Asc.c_oAscAlignShapeType.ALIGN_RIGHT - }).on('click', onItemClick), - new Common.UI.MenuItem({ - caption : me.textShapeAlignTop, - iconCls : 'menu__icon shape-align-top', - value: Asc.c_oAscAlignShapeType.ALIGN_TOP - }).on('click', onItemClick), - new Common.UI.MenuItem({ - caption : me.textShapeAlignMiddle, - iconCls : 'menu__icon shape-align-middle', - value: Asc.c_oAscAlignShapeType.ALIGN_MIDDLE - }).on('click', onItemClick), - new Common.UI.MenuItem({ - caption : me.textShapeAlignBottom, - iconCls : 'menu__icon shape-align-bottom', - value: Asc.c_oAscAlignShapeType.ALIGN_BOTTOM - }).on('click', onItemClick), - {caption : '--'}, - new Common.UI.MenuItem({ - caption : me.txtDistribHor, - iconCls : 'menu__icon shape-distribute-hor', - value : 6 - }).on('click', onItemClick), - new Common.UI.MenuItem({ - caption : me.txtDistribVert, - iconCls : 'menu__icon shape-distribute-vert', - value : 7 - }).on('click', onItemClick) - ] - }) - })() - }); - - var mnuGroup = new Common.UI.MenuItem({ - caption : this.txtGroup, - iconCls : 'menu__icon shape-group' - }).on('click', function(item, e) { - if (me.api) { - var properties = new Asc.asc_CImgProperty(); - properties.put_Group(1); - me.api.ImgApply(properties); - } - me.fireEvent('editcomplete', this); - }); - - var mnuUnGroup = new Common.UI.MenuItem({ - iconCls : 'menu__icon shape-ungroup', - caption : this.txtUngroup - }).on('click', function(item, e) { - if (me.api) { - var properties = new Asc.asc_CImgProperty(); - 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) { - var properties = new Asc.asc_CImgProperty(); - properties.put_ChangeLevel(item.options.valign); - me.api.ImgApply(properties); - } - me.fireEvent('editcomplete', me); - } - - return new Common.UI.Menu({ - cls: 'ppm-toolbar shifted-right', - menuAlign: 'tl-tr', - items: [ - new Common.UI.MenuItem({ - caption : me.textArrangeFront, - iconCls : 'menu__icon arrange-front', - valign : Asc.c_oAscChangeLevel.BringToFront - }).on('click', onItemClick), - new Common.UI.MenuItem({ - caption : me.textArrangeBack, - iconCls : 'menu__icon arrange-back', - valign : Asc.c_oAscChangeLevel.SendToBack - }).on('click', onItemClick), - new Common.UI.MenuItem({ - caption : me.textArrangeForward, - iconCls : 'menu__icon arrange-forward', - valign : Asc.c_oAscChangeLevel.BringForward - }).on('click', onItemClick), - new Common.UI.MenuItem({ - caption : me.textArrangeBackward, - iconCls : 'menu__icon arrange-backward', - valign : Asc.c_oAscChangeLevel.BringBackward - }).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({ - iconCls: 'menu__icon wrap-inline', - caption : me.textWrap, - menu : (function(){ - function onItemClick(item, e) { - if (me.api) { - var properties = new Asc.asc_CImgProperty(); - properties.put_WrappingStyle(item.options.wrapType); - - if (me.menuImageWrap._originalProps.get_WrappingStyle() === Asc.c_oAscWrapStyle2.Inline && item.wrapType !== Asc.c_oAscWrapStyle2.Inline ) { - properties.put_PositionH(new Asc.CImagePositionH()); - properties.get_PositionH().put_UseAlign(false); - properties.get_PositionH().put_RelativeFrom(Asc.c_oAscRelativeFromH.Column); - var val = me.menuImageWrap._originalProps.get_Value_X(Asc.c_oAscRelativeFromH.Column); - properties.get_PositionH().put_Value(val); - - properties.put_PositionV(new Asc.CImagePositionV()); - properties.get_PositionV().put_UseAlign(false); - properties.get_PositionV().put_RelativeFrom(Asc.c_oAscRelativeFromV.Paragraph); - val = me.menuImageWrap._originalProps.get_Value_Y(Asc.c_oAscRelativeFromV.Paragraph); - properties.get_PositionV().put_Value(val); - } - me.api.ImgApply(properties); - } - me.fireEvent('editcomplete', me); - } - - return new Common.UI.Menu({ - cls: 'ppm-toolbar shifted-right', - menuAlign: 'tl-tr', - items: [ - new Common.UI.MenuItem({ - caption : me.txtInline, - iconCls : 'menu__icon wrap-inline', - toggleGroup : 'popuppicturewrapping', - wrapType : Asc.c_oAscWrapStyle2.Inline, - checkmark : false, - checkable : true - }).on('click', onItemClick), - { caption: '--' }, - new Common.UI.MenuItem({ - caption : me.txtSquare, - iconCls : 'menu__icon wrap-square', - toggleGroup : 'popuppicturewrapping', - wrapType : Asc.c_oAscWrapStyle2.Square, - checkmark : false, - checkable : true - }).on('click', onItemClick), - new Common.UI.MenuItem({ - caption : me.txtTight, - iconCls : 'menu__icon wrap-tight', - toggleGroup : 'popuppicturewrapping', - wrapType : Asc.c_oAscWrapStyle2.Tight, - checkmark : false, - checkable : true - }).on('click', onItemClick), - new Common.UI.MenuItem({ - caption : me.txtThrough, - iconCls : 'menu__icon wrap-through', - toggleGroup : 'popuppicturewrapping', - wrapType : Asc.c_oAscWrapStyle2.Through, - checkmark : false, - checkable : true - }).on('click', onItemClick), - new Common.UI.MenuItem({ - caption : me.txtTopAndBottom, - iconCls : 'menu__icon wrap-topandbottom', - toggleGroup : 'popuppicturewrapping', - wrapType : Asc.c_oAscWrapStyle2.TopAndBottom, - checkmark : false, - checkable : true - }).on('click', onItemClick), - { caption: '--' }, - new Common.UI.MenuItem({ - caption : me.txtInFront, - iconCls : 'menu__icon wrap-infront', - toggleGroup : 'popuppicturewrapping', - wrapType : Asc.c_oAscWrapStyle2.InFront, - checkmark : false, - checkable : true - }).on('click', onItemClick), - new Common.UI.MenuItem({ - caption : me.txtBehind, - iconCls : 'menu__icon wrap-behind', - toggleGroup : 'popuppicturewrapping', - wrapType : Asc.c_oAscWrapStyle2.Behind, - checkmark : false, - checkable : true - }).on('click', onItemClick), - { caption: '--' }, - menuWrapPolygon - ] - }) - })() - }); - - var menuImageAdvanced = new Common.UI.MenuItem({ - iconCls: 'menu__icon btn-menu-image', - 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(); - - if (Asc.c_oAscTypeSelectElement.Image == elType) { - 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, - api : me.api, - sectionProps: me.api.asc_GetSectionProps(), - 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)); - - var menuChartEditSeparator = new Common.UI.MenuItem({ - caption : '--' - }); - - this.menuOriginalSize = new Common.UI.MenuItem({ - caption : me.originalSizeText - }).on('click', function(item, e) { - if (me.api){ - var originalImageSize = me.api.get_OriginalSizeImage(); - - var properties = new Asc.asc_CImgProperty(); - properties.put_Width(originalImageSize.get_ImageWidth()); - properties.put_Height(originalImageSize.get_ImageHeight()); - properties.put_ResetCrop(true); - properties.put_Rot(0); - me.api.ImgApply(properties); - - me.fireEvent('editcomplete', this); - } - }); - - var menuImgReplace = new Common.UI.MenuItem({ - caption : me.textReplace, menu : new Common.UI.Menu({ - cls: 'shifted-right', + cls: 'ppm-toolbar shifted-right', 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); + caption : me.textShapeAlignLeft, + iconCls : 'menu__icon shape-align-left', + value: Asc.c_oAscAlignShapeType.ALIGN_LEFT }), 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(); + caption : me.textShapeAlignCenter, + iconCls : 'menu__icon shape-align-center', + value: Asc.c_oAscAlignShapeType.ALIGN_CENTER }), new Common.UI.MenuItem({ - caption : this.textFromStorage - }).on('click', function(item) { - Common.NotificationCenter.trigger('storage:image-load', 'change'); + caption : me.textShapeAlignRight, + iconCls : 'menu__icon shape-align-right', + value: Asc.c_oAscAlignShapeType.ALIGN_RIGHT + }), + new Common.UI.MenuItem({ + caption : me.textShapeAlignTop, + iconCls : 'menu__icon shape-align-top', + value: Asc.c_oAscAlignShapeType.ALIGN_TOP + }), + new Common.UI.MenuItem({ + caption : me.textShapeAlignMiddle, + iconCls : 'menu__icon shape-align-middle', + value: Asc.c_oAscAlignShapeType.ALIGN_MIDDLE + }), + new Common.UI.MenuItem({ + caption : me.textShapeAlignBottom, + iconCls : 'menu__icon shape-align-bottom', + value: Asc.c_oAscAlignShapeType.ALIGN_BOTTOM + }), + {caption : '--'}, + new Common.UI.MenuItem({ + caption : me.txtDistribHor, + iconCls : 'menu__icon shape-distribute-hor', + value : 6 + }), + new Common.UI.MenuItem({ + caption : me.txtDistribVert, + iconCls : 'menu__icon shape-distribute-vert', + value : 7 }) ] }) }); - var menuImgCopy = new Common.UI.MenuItem({ + me.mnuGroup = new Common.UI.MenuItem({ + caption : this.txtGroup, + iconCls : 'menu__icon shape-group' + }); + + me.mnuUnGroup = new Common.UI.MenuItem({ + iconCls : 'menu__icon shape-ungroup', + caption : this.txtUngroup + }); + + me.menuImageArrange = new Common.UI.MenuItem({ + caption : me.textArrange, + menu : new Common.UI.Menu({ + cls: 'ppm-toolbar shifted-right', + menuAlign: 'tl-tr', + items: [ + new Common.UI.MenuItem({ + caption : me.textArrangeFront, + iconCls : 'menu__icon arrange-front', + valign : Asc.c_oAscChangeLevel.BringToFront + }), + new Common.UI.MenuItem({ + caption : me.textArrangeBack, + iconCls : 'menu__icon arrange-back', + valign : Asc.c_oAscChangeLevel.SendToBack + }), + new Common.UI.MenuItem({ + caption : me.textArrangeForward, + iconCls : 'menu__icon arrange-forward', + valign : Asc.c_oAscChangeLevel.BringForward + }), + new Common.UI.MenuItem({ + caption : me.textArrangeBackward, + iconCls : 'menu__icon arrange-backward', + valign : Asc.c_oAscChangeLevel.BringBackward + }), + { caption: '--' }, + me.mnuGroup, + me.mnuUnGroup + ] + }) + }); + + me.menuWrapPolygon = new Common.UI.MenuItem({ + caption : me.textEditWrapBoundary, + cls : 'no-icon-wrap-item' + }); + + me.menuImageWrap = new Common.UI.MenuItem({ + iconCls: 'menu__icon wrap-inline', + caption : me.textWrap, + menu : new Common.UI.Menu({ + cls: 'ppm-toolbar shifted-right', + menuAlign: 'tl-tr', + items: [ + new Common.UI.MenuItem({ + caption : me.txtInline, + iconCls : 'menu__icon wrap-inline', + toggleGroup : 'popuppicturewrapping', + wrapType : Asc.c_oAscWrapStyle2.Inline, + checkmark : false, + checkable : true + }), + { caption: '--' }, + new Common.UI.MenuItem({ + caption : me.txtSquare, + iconCls : 'menu__icon wrap-square', + toggleGroup : 'popuppicturewrapping', + wrapType : Asc.c_oAscWrapStyle2.Square, + checkmark : false, + checkable : true + }), + new Common.UI.MenuItem({ + caption : me.txtTight, + iconCls : 'menu__icon wrap-tight', + toggleGroup : 'popuppicturewrapping', + wrapType : Asc.c_oAscWrapStyle2.Tight, + checkmark : false, + checkable : true + }), + new Common.UI.MenuItem({ + caption : me.txtThrough, + iconCls : 'menu__icon wrap-through', + toggleGroup : 'popuppicturewrapping', + wrapType : Asc.c_oAscWrapStyle2.Through, + checkmark : false, + checkable : true + }), + new Common.UI.MenuItem({ + caption : me.txtTopAndBottom, + iconCls : 'menu__icon wrap-topandbottom', + toggleGroup : 'popuppicturewrapping', + wrapType : Asc.c_oAscWrapStyle2.TopAndBottom, + checkmark : false, + checkable : true + }), + { caption: '--' }, + new Common.UI.MenuItem({ + caption : me.txtInFront, + iconCls : 'menu__icon wrap-infront', + toggleGroup : 'popuppicturewrapping', + wrapType : Asc.c_oAscWrapStyle2.InFront, + checkmark : false, + checkable : true + }), + new Common.UI.MenuItem({ + caption : me.txtBehind, + iconCls : 'menu__icon wrap-behind', + toggleGroup : 'popuppicturewrapping', + wrapType : Asc.c_oAscWrapStyle2.Behind, + checkmark : false, + checkable : true + }), + { caption: '--' }, + me.menuWrapPolygon + ] + }) + }); + + me.menuImageAdvanced = new Common.UI.MenuItem({ + iconCls: 'menu__icon btn-menu-image', + caption : me.advancedText + }); + + me.menuChartEdit = new Common.UI.MenuItem({ + caption : me.editChartText + }); + + var menuChartEditSeparator = new Common.UI.MenuItem({ + caption : '--' + }); + + me.menuOriginalSize = new Common.UI.MenuItem({ + caption : me.originalSizeText + }); + + me.menuImgReplace = new Common.UI.MenuItem({ + caption : me.textReplace, + menu : new Common.UI.Menu({ + cls: 'shifted-right', + menuAlign: 'tl-tr', + items: [ + new Common.UI.MenuItem({caption: this.textFromFile, value: 0}), + new Common.UI.MenuItem({caption: this.textFromUrl, value: 1}), + new Common.UI.MenuItem({caption: this.textFromStorage, value: 2}) + ] + }) + }); + + me.menuImgCopy = new Common.UI.MenuItem({ iconCls: 'menu__icon btn-copy', caption : me.textCopy, value : 'copy' - }).on('click', _.bind(me.onCutCopyPaste, me)); + }); - var menuImgPaste = new Common.UI.MenuItem({ + me.menuImgPaste = new Common.UI.MenuItem({ iconCls: 'menu__icon btn-paste', caption : me.textPaste, value : 'paste' - }).on('click', _.bind(me.onCutCopyPaste, me)); + }); - var menuImgCut = new Common.UI.MenuItem({ + me.menuImgCut = new Common.UI.MenuItem({ iconCls: 'menu__icon btn-cut', caption : me.textCut, value : 'cut' - }).on('click', _.bind(me.onCutCopyPaste, me)); + }); - var menuImgAccept = new Common.UI.MenuItem({ + me.menuImgAccept = new Common.UI.MenuItem({ caption : me.textAccept, value : 'accept' - }).on('click', _.bind(me.onAcceptRejectChange, me)); + }); - var menuImgReject = new Common.UI.MenuItem({ + me.menuImgReject = new Common.UI.MenuItem({ caption : me.textReject, value : 'reject' - }).on('click', _.bind(me.onAcceptRejectChange, me)); + }); var menuImgReviewSeparator = new Common.UI.MenuItem({ caption : '--' }); - var menuImgPrint = new Common.UI.MenuItem({ + me.menuImgPrint = new Common.UI.MenuItem({ iconCls: 'menu__icon btn-print', caption : me.txtPrintSelection - }).on('click', _.bind(me.onPrintSelection, me)); + }); - 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)); + me.menuSignatureEditSign = new Common.UI.MenuItem({caption: this.strSign, value: 0 }); + me.menuSignatureEditSetup = new Common.UI.MenuItem({caption: this.strSetup, value: 2 }); var menuEditSignSeparator = new Common.UI.MenuItem({ caption: '--' }); - var menuImgRotate = new Common.UI.MenuItem({ + me.menuImgRotate = new Common.UI.MenuItem({ caption : me.textRotate, menu : new Common.UI.Menu({ cls: 'shifted-right', @@ -2616,23 +521,23 @@ define([ iconCls: 'menu__icon btn-rotate-90', caption: this.textRotate90, value : 1 - }).on('click', _.bind(me.onImgRotate, me)), + }), new Common.UI.MenuItem({ iconCls: 'menu__icon btn-rotate-270', caption: this.textRotate270, value : 0 - }).on('click', _.bind(me.onImgRotate, me)), + }), { caption: '--' }, new Common.UI.MenuItem({ iconCls: 'menu__icon btn-flip-hor', caption: this.textFlipH, value : 1 - }).on('click', _.bind(me.onImgFlip, me)), + }), new Common.UI.MenuItem({ iconCls: 'menu__icon btn-flip-vert', caption: this.textFlipV, value : 0 - }).on('click', _.bind(me.onImgFlip, me)) + }) ] }) }); @@ -2648,38 +553,36 @@ define([ checkable: true, allowDepress: true, value : 0 - }).on('click', _.bind(me.onImgCrop, me)), + }), new Common.UI.MenuItem({ caption: me.textCropFill, value : 1 - }).on('click', _.bind(me.onImgCrop, me)), + }), new Common.UI.MenuItem({ caption: me.textCropFit, value : 2 - }).on('click', _.bind(me.onImgCrop, me)) + }) ] }) }); - var menuImgRemoveControl = new Common.UI.MenuItem({ + me.menuImgRemoveControl = new Common.UI.MenuItem({ iconCls: 'menu__icon cc-remove', caption: me.textRemoveControl, value: 'remove' - }).on('click', _.bind(me.onControlsSelect, me)); + }); - var menuImgControlSettings = new Common.UI.MenuItem({ + me.menuImgControlSettings = new Common.UI.MenuItem({ caption: me.textEditControls, value: 'settings' - }).on('click', _.bind(me.onControlsSelect, me)); + }); var menuImgControlSeparator = new Common.UI.MenuItem({ caption : '--' }); - var menuImgEditPoints = new Common.UI.MenuItem({ + me.menuImgEditPoints = new Common.UI.MenuItem({ caption: me.textEditPoints - }).on('click', function(item) { - me.api && me.api.asc_editPointsGeometry(); }); var menuImgEditPointsSeparator = new Common.UI.MenuItem({ @@ -2748,17 +651,16 @@ define([ }); var onlyCommonProps = ( value.imgProps.isImg && value.imgProps.isChart || value.imgProps.isImg && value.imgProps.isShape || - value.imgProps.isShape && value.imgProps.isChart); + value.imgProps.isShape && value.imgProps.isChart); if (onlyCommonProps) { - menuImageAdvanced.setCaption(me.advancedText, true); - menuImageAdvanced.setIconCls('menu__icon btn-menu-image'); + me.menuImageAdvanced.setCaption(me.advancedText, true); + me.menuImageAdvanced.setIconCls('menu__icon btn-menu-image'); } else { - menuImageAdvanced.setCaption((value.imgProps.isImg) ? me.imageText : ((value.imgProps.isChart) ? me.chartText : me.shapeText), true); - menuImageAdvanced.setIconCls('menu__icon ' + (value.imgProps.isImg ? 'btn-menu-image' : (value.imgProps.isChart ? 'btn-menu-chart' : 'btn-menu-shape'))); + me.menuImageAdvanced.setCaption((value.imgProps.isImg) ? me.imageText : ((value.imgProps.isChart) ? me.chartText : me.shapeText), true); + me.menuImageAdvanced.setIconCls('menu__icon ' + (value.imgProps.isImg ? 'btn-menu-image' : (value.imgProps.isChart ? 'btn-menu-chart' : 'btn-menu-shape'))); } - menuChartEdit.setVisible(!_.isNull(value.imgProps.value.get_ChartProperties()) && !onlyCommonProps); - + me.menuChartEdit.setVisible(!_.isNull(value.imgProps.value.get_ChartProperties()) && !onlyCommonProps); me.menuOriginalSize.setVisible(value.imgProps.isOnlyImg || !value.imgProps.isChart && !value.imgProps.isShape); var in_control = me.api.asc_IsContentControl(), @@ -2767,119 +669,119 @@ define([ content_locked = lock_type==Asc.c_oAscSdtLockType.SdtContentLocked || lock_type==Asc.c_oAscSdtLockType.ContentLocked, is_form = control_props && control_props.get_FormPr(); - menuImgRemoveControl.setVisible(in_control); - menuImgControlSettings.setVisible(in_control && me.mode.canEditContentControl && !is_form); + me.menuImgRemoveControl.setVisible(in_control); + me.menuImgControlSettings.setVisible(in_control && me.mode.canEditContentControl && !is_form); menuImgControlSeparator.setVisible(in_control); if (in_control) { - menuImgRemoveControl.setDisabled(lock_type==Asc.c_oAscSdtLockType.SdtContentLocked || lock_type==Asc.c_oAscSdtLockType.SdtLocked); - menuImgRemoveControl.setCaption(is_form ? me.getControlLabel(control_props) : me.textRemoveControl); + me.menuImgRemoveControl.setDisabled(lock_type==Asc.c_oAscSdtLockType.SdtContentLocked || lock_type==Asc.c_oAscSdtLockType.SdtLocked); + me.menuImgRemoveControl.setCaption(is_form ? me.getControlLabel(control_props) : me.textRemoveControl); } var islocked = value.imgProps.locked || (value.headerProps!==undefined && value.headerProps.locked) || content_locked; var pluginGuid = value.imgProps.value.asc_getPluginGuid(); - menuImgReplace.setVisible(value.imgProps.isOnlyImg && (pluginGuid===null || pluginGuid===undefined)); - if (menuImgReplace.isVisible()) - menuImgReplace.setDisabled(islocked || pluginGuid===null); - menuImgReplace.menu.items[2].setVisible(me.mode.canRequestInsertImage || me.mode.fileChoiceUrl && me.mode.fileChoiceUrl.indexOf("{documentType}")>-1); + me.menuImgReplace.setVisible(value.imgProps.isOnlyImg && (pluginGuid===null || pluginGuid===undefined)); + if (me.menuImgReplace.isVisible()) + me.menuImgReplace.setDisabled(islocked || pluginGuid===null); + me.menuImgReplace.menu.items[2].setVisible(me.mode.canRequestInsertImage || me.mode.fileChoiceUrl && me.mode.fileChoiceUrl.indexOf("{documentType}")>-1); - menuImgRotate.setVisible(!value.imgProps.isChart && (pluginGuid===null || pluginGuid===undefined)); - if (menuImgRotate.isVisible()) { - menuImgRotate.setDisabled(islocked || value.imgProps.isSmartArt); - menuImgRotate.menu.items[3].setDisabled(value.imgProps.isSmartArtInternal); - menuImgRotate.menu.items[4].setDisabled(value.imgProps.isSmartArtInternal); + me.menuImgRotate.setVisible(!value.imgProps.isChart && (pluginGuid===null || pluginGuid===undefined)); + if (me.menuImgRotate.isVisible()) { + me.menuImgRotate.setDisabled(islocked || value.imgProps.isSmartArt); + me.menuImgRotate.menu.items[3].setDisabled(value.imgProps.isSmartArtInternal); + me.menuImgRotate.menu.items[4].setDisabled(value.imgProps.isSmartArtInternal); } me.menuImgCrop.setVisible(me.api.asc_canEditCrop()); if (me.menuImgCrop.isVisible()) me.menuImgCrop.setDisabled(islocked); - if (menuChartEdit.isVisible()) - menuChartEdit.setDisabled(islocked || value.imgProps.value.get_SeveralCharts()); + if (me.menuChartEdit.isVisible()) + me.menuChartEdit.setDisabled(islocked || value.imgProps.value.get_SeveralCharts()); - menuChartEditSeparator.setVisible(menuChartEdit.isVisible()); + menuChartEditSeparator.setVisible(me.menuChartEdit.isVisible()); me.menuOriginalSize.setDisabled(islocked || value.imgProps.value.get_ImageUrl()===null || value.imgProps.value.get_ImageUrl()===undefined); - menuImageAdvanced.setDisabled(islocked); - menuImageAlign.setDisabled( islocked || (wrapping == Asc.c_oAscWrapStyle2.Inline) ); + me.menuImageAdvanced.setDisabled(islocked); + me.menuImageAlign.setDisabled( islocked || (wrapping == Asc.c_oAscWrapStyle2.Inline) ); 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)); + me.menuImageAlign.menu.items[7].setDisabled(objcount==2 && (!alignto || alignto==3)); + me.menuImageAlign.menu.items[8].setDisabled(objcount==2 && (!alignto || alignto==3)); } - menuImageArrange.setDisabled( (wrapping == Asc.c_oAscWrapStyle2.Inline) && !value.imgProps.value.get_FromGroup() || content_locked || - (me.api && !me.api.CanUnGroup() && !me.api.CanGroup() && value.imgProps.isSmartArtInternal)); - menuImageArrange.menu.items[0].setDisabled(value.imgProps.isSmartArtInternal); - menuImageArrange.menu.items[1].setDisabled(value.imgProps.isSmartArtInternal); - menuImageArrange.menu.items[2].setDisabled(value.imgProps.isSmartArtInternal); - menuImageArrange.menu.items[3].setDisabled(value.imgProps.isSmartArtInternal); + me.menuImageArrange.setDisabled( (wrapping == Asc.c_oAscWrapStyle2.Inline) && !value.imgProps.value.get_FromGroup() || content_locked || + (me.api && !me.api.CanUnGroup() && !me.api.CanGroup() && value.imgProps.isSmartArtInternal)); + me.menuImageArrange.menu.items[0].setDisabled(value.imgProps.isSmartArtInternal); + me.menuImageArrange.menu.items[1].setDisabled(value.imgProps.isSmartArtInternal); + me.menuImageArrange.menu.items[2].setDisabled(value.imgProps.isSmartArtInternal); + me.menuImageArrange.menu.items[3].setDisabled(value.imgProps.isSmartArtInternal); if (me.api) { - mnuUnGroup.setDisabled(islocked || !me.api.CanUnGroup()); - mnuGroup.setDisabled(islocked || !me.api.CanGroup()); - menuWrapPolygon.setDisabled(islocked || !me.api.CanChangeWrapPolygon()); + me.mnuUnGroup.setDisabled(islocked || !me.api.CanUnGroup()); + me.mnuGroup.setDisabled(islocked || !me.api.CanGroup()); + me.menuWrapPolygon.setDisabled(islocked || !me.api.CanChangeWrapPolygon()); } - me.menuImageWrap.setDisabled(islocked || value.imgProps.value.get_FromGroup() || (notflow && menuWrapPolygon.isDisabled()) || + me.menuImageWrap.setDisabled(islocked || value.imgProps.value.get_FromGroup() || (notflow && me.menuWrapPolygon.isDisabled()) || (!!control_props && control_props.get_SpecificType()==Asc.c_oAscContentControlSpecificType.Picture && !control_props.get_FormPr())); var cancopy = me.api && me.api.can_CopyCut(); - menuImgCopy.setDisabled(!cancopy); - menuImgCut.setDisabled(islocked || !cancopy); - menuImgPaste.setDisabled(islocked); - menuImgPrint.setVisible(me.mode.canPrint); - menuImgPrint.setDisabled(!cancopy); + me.menuImgCopy.setDisabled(!cancopy); + me.menuImgCut.setDisabled(islocked || !cancopy); + me.menuImgPaste.setDisabled(islocked); + me.menuImgPrint.setVisible(me.mode.canPrint); + me.menuImgPrint.setDisabled(!cancopy); var lockreview = Common.Utils.InternalSettings.get("de-accept-reject-lock"); - menuImgAccept.setVisible(!lockreview); - menuImgReject.setVisible(!lockreview); + me.menuImgAccept.setVisible(!lockreview); + me.menuImgReject.setVisible(!lockreview); menuImgReviewSeparator.setVisible(!lockreview); var signGuid = (value.imgProps && value.imgProps.value && me.mode.isSignatureSupport) ? value.imgProps.value.asc_getSignatureId() : undefined, isInSign = !!signGuid; - menuSignatureEditSign.setVisible(isInSign); - menuSignatureEditSetup.setVisible(isInSign); + me.menuSignatureEditSign.setVisible(isInSign); + me.menuSignatureEditSetup.setVisible(isInSign); menuEditSignSeparator.setVisible(isInSign); if (isInSign) { - menuSignatureEditSign.cmpEl.attr('data-value', signGuid); // sign - menuSignatureEditSetup.cmpEl.attr('data-value', signGuid); // edit signature settings + me.menuSignatureEditSign.cmpEl.attr('data-value', signGuid); // sign + me.menuSignatureEditSetup.cmpEl.attr('data-value', signGuid); // edit signature settings } var canEditPoints = me.api && me.api.asc_canEditGeometry(); - menuImgEditPoints.setVisible(canEditPoints); + me.menuImgEditPoints.setVisible(canEditPoints); menuImgEditPointsSeparator.setVisible(canEditPoints); - canEditPoints && menuImgEditPoints.setDisabled(islocked); + canEditPoints && me.menuImgEditPoints.setDisabled(islocked); }, items: [ - menuImgCut, - menuImgCopy, - menuImgPaste, - menuImgPrint, + me.menuImgCut, + me.menuImgCopy, + me.menuImgPaste, + me.menuImgPrint, { caption: '--' }, - menuImgAccept, - menuImgReject, + me.menuImgAccept, + me.menuImgReject, menuImgReviewSeparator, - menuSignatureEditSign, - menuSignatureEditSetup, + me.menuSignatureEditSign, + me.menuSignatureEditSetup, menuEditSignSeparator, - menuImgRemoveControl, - menuImgControlSettings, + me.menuImgRemoveControl, + me.menuImgControlSettings, menuImgControlSeparator, - menuImgEditPoints, + me.menuImgEditPoints, menuImgEditPointsSeparator, - menuImageArrange, - menuImageAlign, + me.menuImageArrange, + me.menuImageAlign, me.menuImageWrap, - menuImgRotate, + me.menuImgRotate, { caption: '--' }, - menuInsertCaption, + me.menuInsertCaption, menuInsertCaptionSeparator, me.menuImgCrop, me.menuOriginalSize, - menuImgReplace, - menuChartEdit, + me.menuImgReplace, + me.menuChartEdit, menuChartEditSeparator, - menuImageAdvanced + me.menuImageAdvanced ] }).on('hide:after', function(menu, e, isFromInputControl) { if (!isFromInputControl) me.fireEvent('editcomplete', me); @@ -2888,46 +790,20 @@ define([ /* table menu*/ - var menuTableInsertCaption = new Common.UI.MenuItem({ + me.menuTableInsertCaption = new Common.UI.MenuItem({ caption : me.txtInsertCaption - }).on('click', _.bind(me.onInsertCaption, me)); + }); - var mnuTableMerge = new Common.UI.MenuItem({ + me.mnuTableMerge = new Common.UI.MenuItem({ iconCls: 'menu__icon btn-merge-cells', caption : me.mergeCellsText - }).on('click', function(item) { - if (me.api) - me.api.MergeCells(); }); - var mnuTableSplit = new Common.UI.MenuItem({ + me.mnuTableSplit = new Common.UI.MenuItem({ caption : me.splitCellsText - }).on('click', function(item) { - if (me.api){ - (new Common.Views.InsertTableDialog({ - split: true, - handler: function(result, value) { - if (result == 'ok') { - if (me.api) { - me.api.SplitCell(value.columns, value.rows); - } - Common.component.Analytics.trackEvent('DocumentHolder', 'Table'); - } - me.fireEvent('editcomplete', me); - } - })).show(); - } }); - var tableCellsVAlign = function(item, e) { - if (me.api) { - var properties = new Asc.CTableProp(); - properties.put_CellsVAlign(item.options.valign); - me.api.tblApply(properties); - } - }; - - var menuTableCellAlign = new Common.UI.MenuItem({ + me.menuTableCellAlign = new Common.UI.MenuItem({ iconCls: 'menu__icon btn-align-top', caption : me.cellAlignText, menu : new Common.UI.Menu({ @@ -2942,7 +818,7 @@ define([ checkable : true, checked : false, valign : Asc.c_oAscVertAlignJc.Top - }).on('click', _.bind(tableCellsVAlign, me)), + }), me.menuTableCellCenter = new Common.UI.MenuItem({ iconCls: 'menu__icon btn-align-middle', caption : me.textShapeAlignMiddle, @@ -2951,7 +827,7 @@ define([ checkable : true, checked : false, valign : Asc.c_oAscVertAlignJc.Center - }).on('click', _.bind(tableCellsVAlign, me)), + }), me.menuTableCellBottom = new Common.UI.MenuItem({ iconCls: 'menu__icon btn-align-bottom', caption : me.textShapeAlignBottom, @@ -2960,34 +836,31 @@ define([ checkable : true, checked : false, valign : Asc.c_oAscVertAlignJc.Bottom - }).on('click', _.bind(tableCellsVAlign, me)) + }) ] }) }); - var menuTableAdvanced = new Common.UI.MenuItem({ + me.menuTableAdvanced = new Common.UI.MenuItem({ iconCls: 'menu__icon btn-menu-table', caption : me.advancedTableText - }).on('click', _.bind(me.advancedTableClick, me)); + }); - var menuParagraphAdvancedInTable = new Common.UI.MenuItem({ + me.menuParagraphAdvancedInTable = new Common.UI.MenuItem({ iconCls: 'menu__icon btn-paragraph', caption : me.advancedParagraphText - }).on('click', _.bind(me.advancedParagraphClick, me)); + }); var menuHyperlinkSeparator = new Common.UI.MenuItem({ caption : '--' }); - var menuEditHyperlinkTable = new Common.UI.MenuItem({ + me.menuEditHyperlinkTable = new Common.UI.MenuItem({ caption : me.editHyperlinkText - }).on('click', _.bind(me.editHyperlink, me)); + }); - var menuRemoveHyperlinkTable = new Common.UI.MenuItem({ + me.menuRemoveHyperlinkTable = new Common.UI.MenuItem({ caption : me.removeHyperlinkText - }).on('click', function(item, e){ - me.api && me.api.remove_Hyperlink(item.hyperProps.value); - me.fireEvent('editcomplete', me); }); var menuHyperlinkTable = new Common.UI.MenuItem({ @@ -2997,28 +870,28 @@ define([ cls: 'shifted-right', menuAlign: 'tl-tr', items : [ - menuEditHyperlinkTable, - menuRemoveHyperlinkTable + me.menuEditHyperlinkTable, + me.menuRemoveHyperlinkTable ] }) }); - var menuTableRemoveForm = new Common.UI.MenuItem({ + me.menuTableRemoveForm = new Common.UI.MenuItem({ iconCls: 'menu__icon cc-remove', caption: me.textRemove, value: 'remove' - }).on('click', _.bind(me.onControlsSelect, me)); + }); - var menuTableRemoveControl = new Common.UI.MenuItem({ + me.menuTableRemoveControl = new Common.UI.MenuItem({ iconCls: 'menu__icon cc-remove', caption: me.textRemoveControl, value: 'remove' - }).on('click', _.bind(me.onControlsSelect, me)); + }); - var menuTableControlSettings = new Common.UI.MenuItem({ + me.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, @@ -3026,13 +899,13 @@ define([ cls: 'shifted-right', menuAlign: 'tl-tr', items : [ - menuTableRemoveControl, - menuTableControlSettings + me.menuTableRemoveControl, + me.menuTableControlSettings ] }) }); - var menuTableTOC = new Common.UI.MenuItem({ + me.menuTableTOC = new Common.UI.MenuItem({ caption : me.textTOC, menu : new Common.UI.Menu({ cls: 'shifted-right', @@ -3053,25 +926,22 @@ define([ ] }) }); - menuTableTOC.menu.on('item:click', function (menu, item, e) { - me.fireEvent((item.value=='settings') ? 'links:contents' : 'links:update', [item.value, true]); - }); /** coauthoring begin **/ - var menuAddCommentTable = new Common.UI.MenuItem({ + me.menuAddCommentTable = new Common.UI.MenuItem({ iconCls: 'menu__icon btn-menu-comments', caption : me.addCommentText - }).on('click', _.bind(me.addComment, me)); + }); /** coauthoring end **/ - var menuAddHyperlinkTable = new Common.UI.MenuItem({ + me.menuAddHyperlinkTable = new Common.UI.MenuItem({ iconCls: 'menu__icon btn-inserthyperlink', caption : me.hyperlinkText - }).on('click', _.bind(me.addHyperlink, me)); + }); - var menuTableFollow = new Common.UI.MenuItem({ + me.menuTableFollow = new Common.UI.MenuItem({ caption: me.textFollow - }).on('click', _.bind(me.onFollowMove, me)); + }); me.menuSpellTable = new Common.UI.MenuItem({ caption : me.loadSpellText, @@ -3109,29 +979,18 @@ define([ }) }); - 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); - } + me.menuIgnoreSpellTable = new Common.UI.MenuItem({ + caption : me.ignoreSpellText, + value: false }); - 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); - } + me.menuIgnoreAllSpellTable = new Common.UI.MenuItem({ + caption : me.ignoreAllSpellText, + value: true }); - var menuToDictionaryTable = new Common.UI.MenuItem({ + me.menuToDictionaryTable = new Common.UI.MenuItem({ caption : me.toDictionaryText - }).on('click', function(item, e) { - me.api.asc_spellCheckAddToDictionary(me._currentSpellObj); - me.fireEvent('editcomplete', me); }); var menuIgnoreSpellTableSeparator = new Common.UI.MenuItem({ @@ -3152,82 +1011,68 @@ define([ me.menuSpellTable, me.menuSpellMoreTable, menuIgnoreSpellTableSeparator, - menuIgnoreSpellTable, - menuIgnoreAllSpellTable, - menuToDictionaryTable, + me.menuIgnoreSpellTable, + me.menuIgnoreAllSpellTable, + me.menuToDictionaryTable, { caption: '--' }, me.langTableMenu ] }) }); - var menuTableCopy = new Common.UI.MenuItem({ + me.menuTableCopy = new Common.UI.MenuItem({ iconCls: 'menu__icon btn-copy', caption : me.textCopy, value : 'copy' - }).on('click', _.bind(me.onCutCopyPaste, me)); + }); - var menuTablePaste = new Common.UI.MenuItem({ + me.menuTablePaste = new Common.UI.MenuItem({ iconCls: 'menu__icon btn-paste', caption : me.textPaste, value : 'paste' - }).on('click', _.bind(me.onCutCopyPaste, me)); + }); - var menuTableCut = new Common.UI.MenuItem({ + me.menuTableCut = new Common.UI.MenuItem({ iconCls: 'menu__icon btn-cut', caption : me.textCut, value : 'cut' - }).on('click', _.bind(me.onCutCopyPaste, me)); + }); - var menuTableAccept = new Common.UI.MenuItem({ + me.menuTableAccept = new Common.UI.MenuItem({ caption : me.textAccept, value : 'accept' - }).on('click', _.bind(me.onAcceptRejectChange, me)); + }); - var menuTableReject = new Common.UI.MenuItem({ + me.menuTableReject = new Common.UI.MenuItem({ caption : me.textReject, value : 'reject' - }).on('click', _.bind(me.onAcceptRejectChange, me)); + }); var menuTableReviewSeparator = new Common.UI.MenuItem({ caption : '--' }); - var menuTablePrint = new Common.UI.MenuItem({ + me.menuTablePrint = new Common.UI.MenuItem({ iconCls: 'menu__icon btn-print', caption : me.txtPrintSelection - }).on('click', _.bind(me.onPrintSelection, me)); + }); var menuEquationSeparatorInTable = new Common.UI.MenuItem({ caption : '--' }); - var menuTableDistRows = new Common.UI.MenuItem({ - caption : me.textDistributeRows - }).on('click', _.bind(function(){ - if (me.api) - me.api.asc_DistributeTableCells(false); - me.fireEvent('editcomplete', me); - }, me)); + me.menuTableDistRows = new Common.UI.MenuItem({ + caption : me.textDistributeRows, + value: false + }); - var menuTableDistCols = new Common.UI.MenuItem({ - caption : me.textDistributeCols - }).on('click', _.bind(function(){ - if (me.api) - me.api.asc_DistributeTableCells(true); - me.fireEvent('editcomplete', me); - }, me)); + me.menuTableDistCols = new Common.UI.MenuItem({ + caption : me.textDistributeCols, + value: true + }); - var tableDirection = function(item, e) { - if (me.api) { - var properties = new Asc.CTableProp(); - properties.put_CellsTextDirection(item.options.direction); - me.api.tblApply(properties); - } - }; - - var menuTableDirection = new Common.UI.MenuItem({ + me.menuTableDirection = new Common.UI.MenuItem({ iconCls: 'menu__icon text-orient-hor', caption : me.directionText, menu : new Common.UI.Menu({ @@ -3242,7 +1087,7 @@ define([ checked : false, toggleGroup : 'popuptabledirect', direction : Asc.c_oAscCellTextDirection.LRTB - }).on('click', _.bind(tableDirection, me)), + }), me.menuTableDirect90 = new Common.UI.MenuItem({ caption : me.direct90Text, iconCls : 'menu__icon text-orient-rdown', @@ -3251,7 +1096,7 @@ define([ checked : false, toggleGroup : 'popuptabledirect', direction : Asc.c_oAscCellTextDirection.TBRL - }).on('click', _.bind(tableDirection, me)), + }), me.menuTableDirect270 = new Common.UI.MenuItem({ caption : me.direct270Text, iconCls : 'menu__icon text-orient-rup', @@ -3260,22 +1105,22 @@ define([ checked : false, toggleGroup : 'popuptabledirect', direction : Asc.c_oAscCellTextDirection.BTLR - }).on('click', _.bind(tableDirection, me)) + }) ] }) }); - var menuTableStartNewList = new Common.UI.MenuItem({ + me.menuTableStartNewList = new Common.UI.MenuItem({ caption: me.textStartNewList - }).on('click', _.bind(me.onStartNumbering, me, 1)); + }); - var menuTableStartNumberingFrom = new Common.UI.MenuItem({ + me.menuTableStartNumberingFrom = new Common.UI.MenuItem({ caption: me.textStartNumberingFrom - }).on('click', _.bind(me.onStartNumbering, me, 'advanced')); + }); - var menuTableContinueNumbering = new Common.UI.MenuItem({ + me.menuTableContinueNumbering = new Common.UI.MenuItem({ caption: me.textContinueNumbering - }).on('click', _.bind(me.onContinueNumbering, me)); + }); var menuNumberingTable = new Common.UI.MenuItem({ caption : me.bulletsText, @@ -3283,24 +1128,107 @@ define([ cls: 'shifted-right', menuAlign: 'tl-tr', items : [ - menuTableStartNewList, - menuTableStartNumberingFrom, - menuTableContinueNumbering + me.menuTableStartNewList, + me.menuTableStartNumberingFrom, + me.menuTableContinueNumbering ] }) }); - var menuTableRefreshField = new Common.UI.MenuItem({ + me.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 : '--' }); + me.menuTableSelectText = new Common.UI.MenuItem({ + caption : me.selectText, + menu : new Common.UI.Menu({ + cls: 'shifted-right', + menuAlign: 'tl-tr', + style : 'width: 100px', + items : [ + new Common.UI.MenuItem({ + caption: me.rowText, + value: 0 + }), + new Common.UI.MenuItem({ + caption: me.columnText, + value: 1 + }), + new Common.UI.MenuItem({ + caption: me.cellText, + value: 2 + }), + new Common.UI.MenuItem({ + caption: me.tableText, + value: 3 + }) + ] + }) + }); + + me.menuTableInsertText = new Common.UI.MenuItem({ + iconCls: 'menu__icon btn-addcell', + caption : me.insertText, + menu : new Common.UI.Menu({ + cls: 'shifted-right', + menuAlign: 'tl-tr', + items : [ + new Common.UI.MenuItem({ + caption: me.insertColumnLeftText, + value: 0 + }), + new Common.UI.MenuItem({ + caption: me.insertColumnRightText, + value: 1 + }), + new Common.UI.MenuItem({ + caption: me.insertRowAboveText, + value: 2 + }), + new Common.UI.MenuItem({ + caption: me.insertRowBelowText, + value: 3 + }), + new Common.UI.MenuItem({ + caption: me.textSeveral, + value: 4 + }) + ] + }) + }); + + me.menuTableDeleteText = new Common.UI.MenuItem({ + iconCls: 'menu__icon btn-delcell', + caption : me.deleteText, + menu : new Common.UI.Menu({ + cls: 'shifted-right', + menuAlign: 'tl-tr', + style : 'width: 100px', + items : [ + new Common.UI.MenuItem({ + caption: me.rowText, + value: 0 + }), + new Common.UI.MenuItem({ + caption: me.columnText, + value: 1 + }), + new Common.UI.MenuItem({ + caption: me.tableText, + value: 2 + }), + new Common.UI.MenuItem({ + caption: me.textCells, + value: 3 + }) + ] + }) + }); + this.tableMenu = new Common.UI.Menu({ cls: 'shifted-right', restoreHeightAndTop: true, @@ -3328,7 +1256,7 @@ define([ cls = 'menu__icon btn-align-bottom'; break; } - menuTableCellAlign.setIconCls(cls); + me.menuTableCellAlign.setIconCls(cls); me.menuTableCellTop.setChecked(align == Asc.c_oAscVertAlignJc.Top); me.menuTableCellCenter.setChecked(align == Asc.c_oAscVertAlignJc.Center); me.menuTableCellBottom.setChecked(align == Asc.c_oAscVertAlignJc.Bottom); @@ -3346,7 +1274,7 @@ define([ cls = 'menu__icon text-orient-rup'; break; } - menuTableDirection.setIconCls(cls); + me.menuTableDirection.setIconCls(cls); me.menuTableDirectH.setChecked(dir == Asc.c_oAscCellTextDirection.LRTB); me.menuTableDirect90.setChecked(dir == Asc.c_oAscCellTextDirection.TBRL); me.menuTableDirect270.setChecked(dir == Asc.c_oAscCellTextDirection.BTLR); @@ -3356,26 +1284,26 @@ define([ me.tableMenu.items[15].setDisabled(disabled); if (me.api) { - mnuTableMerge.setDisabled(disabled || !me.api.CheckBeforeMergeCells()); - mnuTableSplit.setDisabled(disabled || !me.api.CheckBeforeSplitCells()); + me.mnuTableMerge.setDisabled(disabled || !me.api.CheckBeforeMergeCells()); + me.mnuTableSplit.setDisabled(disabled || !me.api.CheckBeforeSplitCells()); } - menuTableDistRows.setDisabled(disabled); - menuTableDistCols.setDisabled(disabled); - menuTableCellAlign.setDisabled(disabled); - menuTableDirection.setDisabled(disabled); - menuTableAdvanced.setDisabled(disabled); + me.menuTableDistRows.setDisabled(disabled); + me.menuTableDistCols.setDisabled(disabled); + me.menuTableCellAlign.setDisabled(disabled); + me.menuTableDirection.setDisabled(disabled); + me.menuTableAdvanced.setDisabled(disabled); var cancopy = me.api && me.api.can_CopyCut(); - menuTableCopy.setDisabled(!cancopy); - menuTableCut.setDisabled(disabled || !cancopy); - menuTablePaste.setDisabled(disabled); - menuTablePrint.setVisible(me.mode.canPrint); - menuTablePrint.setDisabled(!cancopy); + me.menuTableCopy.setDisabled(!cancopy); + me.menuTableCut.setDisabled(disabled || !cancopy); + me.menuTablePaste.setDisabled(disabled); + me.menuTablePrint.setVisible(me.mode.canPrint); + me.menuTablePrint.setDisabled(!cancopy); var lockreview = Common.Utils.InternalSettings.get("de-accept-reject-lock"); - menuTableAccept.setVisible(!lockreview); - menuTableReject.setVisible(!lockreview); + me.menuTableAccept.setVisible(!lockreview); + me.menuTableReject.setVisible(!lockreview); menuTableReviewSeparator.setVisible(!lockreview); // bullets & numbering @@ -3386,12 +1314,12 @@ define([ 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); - menuTableStartNewList.value = {start: numLvl.get_Start()}; - menuTableStartNumberingFrom.setVisible(format != Asc.c_oAscNumberingFormat.Bullet); - menuTableStartNumberingFrom.value = {format: format, start: start}; - menuTableStartNewList.setCaption((format == Asc.c_oAscNumberingFormat.Bullet) ? me.textSeparateList : me.textStartNewList); - menuTableContinueNumbering.setCaption((format == Asc.c_oAscNumberingFormat.Bullet) ? me.textJoinList : me.textContinueNumbering); + me.menuTableStartNewList.setVisible(numLvl.get_Start()!=start); + me.menuTableStartNewList.value = {start: numLvl.get_Start()}; + me.menuTableStartNumberingFrom.setVisible(format != Asc.c_oAscNumberingFormat.Bullet); + me.menuTableStartNumberingFrom.value = {format: format, start: start}; + me.menuTableStartNewList.setCaption((format == Asc.c_oAscNumberingFormat.Bullet) ? me.textSeparateList : me.textStartNewList); + me.menuTableContinueNumbering.setCaption((format == Asc.c_oAscNumberingFormat.Bullet) ? me.textJoinList : me.textContinueNumbering); } // hyperlink properties @@ -3399,43 +1327,43 @@ define([ if (me.api) { text = me.api.can_AddHyperlink(); } - menuAddHyperlinkTable.setVisible(value.hyperProps===undefined && text!==false); + me.menuAddHyperlinkTable.setVisible(value.hyperProps===undefined && text!==false); menuHyperlinkTable.setVisible(value.hyperProps!==undefined); - menuEditHyperlinkTable.hyperProps = value.hyperProps; - menuRemoveHyperlinkTable.hyperProps = value.hyperProps; + me.menuEditHyperlinkTable.hyperProps = value.hyperProps; + me.menuRemoveHyperlinkTable.hyperProps = value.hyperProps; if (text!==false) { - menuAddHyperlinkTable.hyperProps = {}; - menuAddHyperlinkTable.hyperProps.value = new Asc.CHyperlinkProperty(); - menuAddHyperlinkTable.hyperProps.value.put_Text(text); + me.menuAddHyperlinkTable.hyperProps = {}; + me.menuAddHyperlinkTable.hyperProps.value = new Asc.CHyperlinkProperty(); + me.menuAddHyperlinkTable.hyperProps.value.put_Text(text); } // review move var data = me.api.asc_GetRevisionsChangesStack(), move = false; - menuTableFollow.value = null; + me.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; + me.menuTableFollow.value = item; move = true; } }); - menuTableFollow.setVisible(move); + me.menuTableFollow.setVisible(move); - menuHyperlinkSeparator.setVisible(menuAddHyperlinkTable.isVisible() || menuHyperlinkTable.isVisible() || menuNumberingTable.isVisible() || menuTableFollow.isVisible()); + menuHyperlinkSeparator.setVisible(me.menuAddHyperlinkTable.isVisible() || menuHyperlinkTable.isVisible() || menuNumberingTable.isVisible() || me.menuTableFollow.isVisible()); // paragraph properties - menuParagraphAdvancedInTable.setVisible(value.paraProps!==undefined); + me.menuParagraphAdvancedInTable.setVisible(value.paraProps!==undefined); me._currentParaObjDisabled = disabled = value.paraProps.locked || (value.headerProps!==undefined && value.headerProps.locked); - menuAddHyperlinkTable.setDisabled(disabled); + me.menuAddHyperlinkTable.setDisabled(disabled); menuHyperlinkTable.setDisabled(disabled || value.hyperProps!==undefined && value.hyperProps.isSeveralLinks===true); - menuParagraphAdvancedInTable.setDisabled(disabled); + me.menuParagraphAdvancedInTable.setDisabled(disabled); me.menuSpellCheckTable.setVisible(value.spellProps!==undefined && value.spellProps.value.get_Checked()===false); - menuToDictionaryTable.setVisible(me.mode.isDesktopApp); + me.menuToDictionaryTable.setVisible(me.mode.isDesktopApp); menuSpellcheckTableSeparator.setVisible(value.spellProps!==undefined && value.spellProps.value.get_Checked()===false); me.langTableMenu.setDisabled(disabled); @@ -3468,185 +1396,81 @@ define([ var control_props = me.api.asc_GetContentControlProperties(), lock_type = (control_props) ? control_props.get_Lock() : Asc.c_oAscSdtLockType.Unlocked, is_form = control_props && control_props.get_FormPr(); - menuTableRemoveForm.setVisible(is_form); + me.menuTableRemoveForm.setVisible(is_form); menuTableControl.setVisible(!is_form); if (is_form) { - menuTableRemoveForm.setDisabled(lock_type==Asc.c_oAscSdtLockType.SdtContentLocked || lock_type==Asc.c_oAscSdtLockType.SdtLocked); - menuTableRemoveForm.setCaption(me.getControlLabel(control_props)); + me.menuTableRemoveForm.setDisabled(lock_type==Asc.c_oAscSdtLockType.SdtContentLocked || lock_type==Asc.c_oAscSdtLockType.SdtLocked); + me.menuTableRemoveForm.setCaption(me.getControlLabel(control_props)); } else { - menuTableRemoveControl.setDisabled(lock_type==Asc.c_oAscSdtLockType.SdtContentLocked || lock_type==Asc.c_oAscSdtLockType.SdtLocked); - menuTableControlSettings.setVisible(me.mode.canEditContentControl); + me.menuTableRemoveControl.setDisabled(lock_type==Asc.c_oAscSdtLockType.SdtContentLocked || lock_type==Asc.c_oAscSdtLockType.SdtLocked); + me.menuTableControlSettings.setVisible(me.mode.canEditContentControl); } var spectype = control_props ? control_props.get_SpecificType() : Asc.c_oAscContentControlSpecificType.None; control_lock = control_lock || spectype==Asc.c_oAscContentControlSpecificType.CheckBox || spectype==Asc.c_oAscContentControlSpecificType.Picture || spectype==Asc.c_oAscContentControlSpecificType.ComboBox || spectype==Asc.c_oAscContentControlSpecificType.DropDownList || spectype==Asc.c_oAscContentControlSpecificType.DateTime; } else { menuTableControl.setVisible(in_control); - menuTableRemoveForm.setVisible(in_control); + me.menuTableRemoveForm.setVisible(in_control); } - menuTableTOC.setVisible(in_toc); + me.menuTableTOC.setVisible(in_toc); /** coauthoring begin **/ // comments - menuAddCommentTable.setVisible(me.api.can_AddQuotedComment()!==false && me.mode.canCoAuthoring && me.mode.canComments && !control_lock); - menuAddCommentTable.setDisabled(value.paraProps!==undefined && value.paraProps.locked===true); + me.menuAddCommentTable.setVisible(me.api.can_AddQuotedComment()!==false && me.mode.canCoAuthoring && me.mode.canComments && !control_lock); + me.menuAddCommentTable.setDisabled(value.paraProps!==undefined && value.paraProps.locked===true); /** coauthoring end **/ var in_field = me.api.asc_GetCurrentComplexField(); - menuTableRefreshField.setVisible(!!in_field); - menuTableRefreshField.setDisabled(disabled); + me.menuTableRefreshField.setVisible(!!in_field); + me.menuTableRefreshField.setDisabled(disabled); menuTableFieldSeparator.setVisible(!!in_field); if (in_field) { - menuTableRefreshField.options.fieldProps = in_field; + me.menuTableRefreshField.options.fieldProps = in_field; } }, items: [ me.menuSpellCheckTable, menuSpellcheckTableSeparator, - menuTableCut, - menuTableCopy, - menuTablePaste, - menuTablePrint, + me.menuTableCut, + me.menuTableCopy, + me.menuTablePaste, + me.menuTablePrint, { caption: '--' }, - menuTableAccept, - menuTableReject, + me.menuTableAccept, + me.menuTableReject, menuTableReviewSeparator, menuEquationSeparatorInTable, - menuTableRefreshField, + me.menuTableRefreshField, menuTableFieldSeparator, - { - caption : me.selectText, - menu : new Common.UI.Menu({ - cls: 'shifted-right', - 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(); - }) - ] - }) - }, - { - iconCls: 'menu__icon btn-addcell', - caption : me.insertText, - menu : new Common.UI.Menu({ - cls: 'shifted-right', - menuAlign: 'tl-tr', - 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(); - }), - new Common.UI.MenuItem({ - caption: me.textSeveral - }).on('click', function(item) { - me.onCellsAdd(); - }) - ] - }) - }, - { - iconCls: 'menu__icon btn-delcell', - caption : me.deleteText, - menu : new Common.UI.Menu({ - cls: 'shifted-right', - 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(); - }), - new Common.UI.MenuItem({ - caption: me.textCells - }).on('click', function(item) { - me.onCellsRemove(); - }) - ] - }) - }, + me.menuTableSelectText, + me.menuTableInsertText, + me.menuTableDeleteText, { caption: '--' }, - mnuTableMerge, - mnuTableSplit, + me.mnuTableMerge, + me.mnuTableSplit, { caption: '--' }, - menuTableDistRows, - menuTableDistCols, + me.menuTableDistRows, + me.menuTableDistCols, { caption: '--' }, - menuTableCellAlign, - menuTableDirection, + me.menuTableCellAlign, + me.menuTableDirection, { caption: '--' }, - menuTableInsertCaption, + me.menuTableInsertCaption, { caption: '--' }, - menuTableAdvanced, + me.menuTableAdvanced, { caption: '--' }, /** coauthoring begin **/ - menuAddCommentTable, + me.menuAddCommentTable, /** coauthoring end **/ menuNumberingTable, - menuAddHyperlinkTable, + me.menuAddHyperlinkTable, menuHyperlinkTable, - menuTableFollow, + me.menuTableFollow, menuHyperlinkSeparator, - menuTableRemoveForm, + me.menuTableRemoveForm, menuTableControl, - menuTableTOC, - menuParagraphAdvancedInTable + me.menuTableTOC, + me.menuParagraphAdvancedInTable ] }).on('hide:after', function(menu, e, isFromInputControl) { if (me.suppressEditComplete) { @@ -3660,29 +1484,17 @@ define([ /* text menu */ - var menuParagraphBreakBefore = new Common.UI.MenuItem({ + me.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({ + me.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) { - var properties = new Asc.asc_CImgProperty(); - properties.put_VerticalTextAlign(item.options.valign); - me.api.ImgApply(properties); - } - }; - - var menuParagraphVAlign = new Common.UI.MenuItem({ + me.menuParagraphVAlign = new Common.UI.MenuItem({ iconCls: 'menu__icon btn-align-top', caption : me.vertAlignText, menu : new Common.UI.Menu({ @@ -3697,7 +1509,7 @@ define([ checked : false, toggleGroup : 'popupparagraphvalign', valign : Asc.c_oAscVAlign.Top - }).on('click', _.bind(paragraphVAlign, me)), + }), me.menuParagraphCenter = new Common.UI.MenuItem({ iconCls: 'menu__icon btn-align-middle', caption : me.textShapeAlignMiddle, @@ -3706,7 +1518,7 @@ define([ checked : false, toggleGroup : 'popupparagraphvalign', valign : Asc.c_oAscVAlign.Center - }).on('click', _.bind(paragraphVAlign, me)), + }), me.menuParagraphBottom = new Common.UI.MenuItem({ iconCls: 'menu__icon btn-align-bottom', caption : me.textShapeAlignBottom, @@ -3715,20 +1527,12 @@ define([ checked : false, toggleGroup : 'popupparagraphvalign', valign : Asc.c_oAscVAlign.Bottom - }).on('click', _.bind(paragraphVAlign, me)) + }) ] }) }); - var paragraphDirection = function(item, e) { - if (me.api) { - var properties = new Asc.asc_CImgProperty(); - properties.put_Vert(item.options.direction); - me.api.ImgApply(properties); - } - }; - - var menuParagraphDirection = new Common.UI.MenuItem({ + me.menuParagraphDirection = new Common.UI.MenuItem({ iconCls: 'menu__icon text-orient-hor', caption : me.directionText, menu : new Common.UI.Menu({ @@ -3743,7 +1547,7 @@ define([ checked : false, toggleGroup : 'popupparagraphdirect', direction : Asc.c_oAscVertDrawingText.normal - }).on('click', _.bind(paragraphDirection, me)), + }), me.menuParagraphDirect90 = new Common.UI.MenuItem({ caption : me.direct90Text, iconCls : 'menu__icon text-orient-rdown', @@ -3752,7 +1556,7 @@ define([ checked : false, toggleGroup : 'popupparagraphdirect', direction : Asc.c_oAscVertDrawingText.vert - }).on('click', _.bind(paragraphDirection, me)), + }), me.menuParagraphDirect270 = new Common.UI.MenuItem({ caption : me.direct270Text, iconCls : 'menu__icon text-orient-rup', @@ -3761,54 +1565,51 @@ define([ checked : false, toggleGroup : 'popupparagraphdirect', direction : Asc.c_oAscVertDrawingText.vert270 - }).on('click', _.bind(paragraphDirection, me)) + }) ] }) }); - var menuParagraphAdvanced = new Common.UI.MenuItem({ + me.menuParagraphAdvanced = new Common.UI.MenuItem({ iconCls: 'menu__icon btn-paragraph', caption : me.advancedParagraphText - }).on('click', _.bind(me.advancedParagraphClick, me)); + }); - var menuFrameAdvanced = new Common.UI.MenuItem({ + me.menuFrameAdvanced = new Common.UI.MenuItem({ caption : me.advancedFrameText - }).on('click', _.bind(me.advancedFrameClick, me, true)); + }); - var menuDropCapAdvanced = new Common.UI.MenuItem({ + me.menuDropCapAdvanced = new Common.UI.MenuItem({ iconCls: 'menu__icon dropcap-intext', caption : me.advancedDropCapText - }).on('click', _.bind(me.advancedFrameClick, me, false)); + }); /** coauthoring begin **/ var menuCommentSeparatorPara = new Common.UI.MenuItem({ caption : '--' }); - var menuAddCommentPara = new Common.UI.MenuItem({ + me.menuAddCommentPara = new Common.UI.MenuItem({ iconCls: 'menu__icon btn-menu-comments', caption : me.addCommentText - }).on('click', _.bind(me.addComment, me)); + }); /** coauthoring end **/ var menuHyperlinkParaSeparator = new Common.UI.MenuItem({ caption : '--' }); - var menuAddHyperlinkPara = new Common.UI.MenuItem({ + me.menuAddHyperlinkPara = new Common.UI.MenuItem({ iconCls: 'menu__icon btn-inserthyperlink', caption : me.hyperlinkText - }).on('click', _.bind(me.addHyperlink, me)); + }); - var menuEditHyperlinkPara = new Common.UI.MenuItem({ + me.menuEditHyperlinkPara = new Common.UI.MenuItem({ caption : me.editHyperlinkText - }).on('click', _.bind(me.editHyperlink, me)); + }); - var menuRemoveHyperlinkPara = new Common.UI.MenuItem({ + me.menuRemoveHyperlinkPara = new Common.UI.MenuItem({ caption : me.removeHyperlinkText - }).on('click', function(item, e) { - me.api.remove_Hyperlink(item.hyperProps.value); - me.fireEvent('editcomplete', me); }); var menuHyperlinkPara = new Common.UI.MenuItem({ @@ -3818,8 +1619,8 @@ define([ cls: 'shifted-right', menuAlign: 'tl-tr', items : [ - menuEditHyperlinkPara, - menuRemoveHyperlinkPara + me.menuEditHyperlinkPara, + me.menuRemoveHyperlinkPara ] }) }); @@ -3833,10 +1634,10 @@ define([ 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)) + }) ] }) }); @@ -3869,25 +1670,18 @@ define([ }) }); - 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); + me.menuIgnoreSpellPara = new Common.UI.MenuItem({ + caption : me.ignoreSpellText, + value: false }); - 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); + me.menuIgnoreAllSpellPara = new Common.UI.MenuItem({ + caption : me.ignoreAllSpellText, + value: true }); - var menuToDictionaryPara = new Common.UI.MenuItem({ + me.menuToDictionaryPara = new Common.UI.MenuItem({ caption : me.toDictionaryText - }).on('click', function(item, e) { - me.api.asc_spellCheckAddToDictionary(me._currentSpellObj); - me.fireEvent('editcomplete', me); }); var menuIgnoreSpellParaSeparator = new Common.UI.MenuItem({ @@ -3898,71 +1692,69 @@ define([ caption : '--' }); - var menuParaCopy = new Common.UI.MenuItem({ + me.menuParaCopy = new Common.UI.MenuItem({ iconCls: 'menu__icon btn-copy', caption : me.textCopy, value : 'copy' - }).on('click', _.bind(me.onCutCopyPaste, me)); + }); - var menuParaPaste = new Common.UI.MenuItem({ + me.menuParaPaste = new Common.UI.MenuItem({ iconCls: 'menu__icon btn-paste', caption : me.textPaste, value : 'paste' - }).on('click', _.bind(me.onCutCopyPaste, me)); + }); - var menuParaCut = new Common.UI.MenuItem({ + me.menuParaCut = new Common.UI.MenuItem({ iconCls: 'menu__icon btn-cut', caption : me.textCut, value : 'cut' - }).on('click', _.bind(me.onCutCopyPaste, me)); + }); - var menuParaAccept = new Common.UI.MenuItem({ + me.menuParaAccept = new Common.UI.MenuItem({ caption : me.textAccept, value : 'accept' - }).on('click', _.bind(me.onAcceptRejectChange, me)); + }); - var menuParaReject = new Common.UI.MenuItem({ + me.menuParaReject = new Common.UI.MenuItem({ caption : me.textReject, value : 'reject' - }).on('click', _.bind(me.onAcceptRejectChange, me)); + }); var menuParaReviewSeparator = new Common.UI.MenuItem({ caption : '--' }); - var menuParaPrint = new Common.UI.MenuItem({ + me.menuParaPrint = new Common.UI.MenuItem({ iconCls: 'menu__icon btn-print', caption : me.txtPrintSelection - }).on('click', _.bind(me.onPrintSelection, me)); + }); var menuEquationSeparator = new Common.UI.MenuItem({ caption : '--' }); - var menuParaRemoveControl = new Common.UI.MenuItem({ + me.menuParaRemoveControl = new Common.UI.MenuItem({ iconCls: 'menu__icon cc-remove', caption: me.textRemoveControl, value: 'remove' - }).on('click', _.bind(me.onControlsSelect, me)); + }); - var menuParaControlSettings = new Common.UI.MenuItem( + me.menuParaControlSettings = new Common.UI.MenuItem( { caption: me.textEditControls, value: 'settings' - }).on('click', _.bind(me.onControlsSelect, me)); + }); var menuParaControlSeparator = new Common.UI.MenuItem({ caption : '--' }); - var menuParaTOCSettings = new Common.UI.MenuItem({ + me.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({ + me.menuParaTOCRefresh = new Common.UI.MenuItem({ caption : me.textUpdateTOC, menu : new Common.UI.Menu({ cls: 'shifted-right', @@ -3979,44 +1771,38 @@ define([ ] }) }); - menuParaTOCRefresh.menu.on('item:click', function (menu, item, e) { - me.fireEvent('links:update', [item.value, true]); - }); var menuParaTOCSeparator = new Common.UI.MenuItem({ caption : '--' }); - var menuParaRefreshField = new Common.UI.MenuItem({ + me.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 : '--' }); - var menuParaStartNewList = new Common.UI.MenuItem({ + me.menuParaStartNewList = new Common.UI.MenuItem({ caption: me.textStartNewList - }).on('click', _.bind(me.onStartNumbering, me, 1)); + }); - var menuParaStartNumberingFrom = new Common.UI.MenuItem({ + me.menuParaStartNumberingFrom = new Common.UI.MenuItem({ caption: me.textStartNumberingFrom - }).on('click', _.bind(me.onStartNumbering, me, 'advanced')); + }); - var menuParaContinueNumbering = new Common.UI.MenuItem({ + me.menuParaContinueNumbering = new Common.UI.MenuItem({ caption: me.textContinueNumbering - }).on('click', _.bind(me.onContinueNumbering, me)); + }); var menuParaNumberingSeparator = new Common.UI.MenuItem({ caption : '--' }); - var menuParaFollow = new Common.UI.MenuItem({ + me.menuParaFollow = new Common.UI.MenuItem({ caption: me.textFollow - }).on('click', _.bind(me.onFollowMove, me)); + }); var menuParaFollowSeparator = new Common.UI.MenuItem({ caption : '--' @@ -4034,8 +1820,8 @@ define([ control_props = in_control ? me.api.asc_GetContentControlProperties() : null, is_form = control_props && control_props.get_FormPr(); - menuParagraphVAlign.setVisible(isInShape && !isInChart && !isEquation && !(is_form && control_props.get_FormPr().get_Fixed())); // после того, как заголовок можно будет растягивать по вертикали, вернуть "|| isInChart" !! - menuParagraphDirection.setVisible(isInShape && !isInChart && !isEquation && !(is_form && control_props.get_FormPr().get_Fixed())); // после того, как заголовок можно будет растягивать по вертикали, вернуть "|| isInChart" !! + me.menuParagraphVAlign.setVisible(isInShape && !isInChart && !isEquation && !(is_form && control_props.get_FormPr().get_Fixed())); // после того, как заголовок можно будет растягивать по вертикали, вернуть "|| isInChart" !! + me.menuParagraphDirection.setVisible(isInShape && !isInChart && !isEquation && !(is_form && control_props.get_FormPr().get_Fixed())); // после того, как заголовок можно будет растягивать по вертикали, вернуть "|| isInChart" !! if ( isInShape || isInChart ) { var align = value.imgProps.value.get_VerticalTextAlign(); var cls = ''; @@ -4050,7 +1836,7 @@ define([ cls = 'menu__icon btn-align-bottom'; break; } - menuParagraphVAlign.setIconCls(cls); + me.menuParagraphVAlign.setIconCls(cls); me.menuParagraphTop.setChecked(align == Asc.c_oAscVAlign.Top); me.menuParagraphCenter.setChecked(align == Asc.c_oAscVAlign.Center); me.menuParagraphBottom.setChecked(align == Asc.c_oAscVAlign.Bottom); @@ -4068,80 +1854,80 @@ define([ cls = 'menu__icon text-orient-rup'; break; } - menuParagraphDirection.setIconCls(cls); + me.menuParagraphDirection.setIconCls(cls); me.menuParagraphDirectH.setChecked(dir == Asc.c_oAscVertDrawingText.normal); me.menuParagraphDirect90.setChecked(dir == Asc.c_oAscVertDrawingText.vert); me.menuParagraphDirect270.setChecked(dir == Asc.c_oAscVertDrawingText.vert270); } - menuParagraphAdvanced.isChart = (value.imgProps && value.imgProps.isChart); - menuParagraphAdvanced.isSmartArtInternal = (value.imgProps && value.imgProps.isSmartArtInternal); - menuParagraphBreakBefore.setVisible(!isInShape && !isInChart && !isEquation); - menuParagraphKeepLines.setVisible(!isInShape && !isInChart && !isEquation); + me.menuParagraphAdvanced.isChart = (value.imgProps && value.imgProps.isChart); + me.menuParagraphAdvanced.isSmartArtInternal = (value.imgProps && value.imgProps.isSmartArtInternal); + me.menuParagraphBreakBefore.setVisible(!isInShape && !isInChart && !isEquation); + me.menuParagraphKeepLines.setVisible(!isInShape && !isInChart && !isEquation); if (value.paraProps) { - menuParagraphBreakBefore.setChecked(value.paraProps.value.get_PageBreakBefore()); - menuParagraphKeepLines.setChecked(value.paraProps.value.get_KeepLines()); + me.menuParagraphBreakBefore.setChecked(value.paraProps.value.get_PageBreakBefore()); + me.menuParagraphKeepLines.setChecked(value.paraProps.value.get_KeepLines()); } var text = null; if (me.api) { text = me.api.can_AddHyperlink(); } - menuAddHyperlinkPara.setVisible(value.hyperProps===undefined && text!==false); + me.menuAddHyperlinkPara.setVisible(value.hyperProps===undefined && text!==false); menuHyperlinkPara.setVisible(value.hyperProps!==undefined); - menuHyperlinkParaSeparator.setVisible(menuAddHyperlinkPara.isVisible() || menuHyperlinkPara.isVisible()); - menuEditHyperlinkPara.hyperProps = value.hyperProps; - menuRemoveHyperlinkPara.hyperProps = value.hyperProps; + menuHyperlinkParaSeparator.setVisible(me.menuAddHyperlinkPara.isVisible() || menuHyperlinkPara.isVisible()); + me.menuEditHyperlinkPara.hyperProps = value.hyperProps; + me.menuRemoveHyperlinkPara.hyperProps = value.hyperProps; if (text!==false) { - menuAddHyperlinkPara.hyperProps = {}; - menuAddHyperlinkPara.hyperProps.value = new Asc.CHyperlinkProperty(); - menuAddHyperlinkPara.hyperProps.value.put_Text(text); + me.menuAddHyperlinkPara.hyperProps = {}; + me.menuAddHyperlinkPara.hyperProps.value = new Asc.CHyperlinkProperty(); + me.menuAddHyperlinkPara.hyperProps.value.put_Text(text); } var disabled = value.paraProps.locked || (value.headerProps!==undefined && value.headerProps.locked); me._currentParaObjDisabled = disabled; - menuAddHyperlinkPara.setDisabled(disabled); + me.menuAddHyperlinkPara.setDisabled(disabled); menuHyperlinkPara.setDisabled(disabled || value.hyperProps!==undefined && value.hyperProps.isSeveralLinks===true); // review move var data = me.api.asc_GetRevisionsChangesStack(), move = false; - menuParaFollow.value = null; + me.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; + me.menuParaFollow.value = item; move = true; } }); - menuParaFollow.setVisible(move); + me.menuParaFollow.setVisible(move); menuParaFollowSeparator.setVisible(move); - menuParagraphBreakBefore.setDisabled(disabled || !_.isUndefined(value.headerProps) || !_.isUndefined(value.imgProps)); - menuParagraphKeepLines.setDisabled(disabled); - menuParagraphAdvanced.setDisabled(disabled); - menuFrameAdvanced.setDisabled(disabled); - menuDropCapAdvanced.setDisabled(disabled); - menuParagraphVAlign.setDisabled(disabled); - menuParagraphDirection.setDisabled(disabled); + me.menuParagraphBreakBefore.setDisabled(disabled || !_.isUndefined(value.headerProps) || !_.isUndefined(value.imgProps)); + me.menuParagraphKeepLines.setDisabled(disabled); + me.menuParagraphAdvanced.setDisabled(disabled); + me.menuFrameAdvanced.setDisabled(disabled); + me.menuDropCapAdvanced.setDisabled(disabled); + me.menuParagraphVAlign.setDisabled(disabled); + me.menuParagraphDirection.setDisabled(disabled); var cancopy = me.api && me.api.can_CopyCut(); - menuParaCopy.setDisabled(!cancopy); - menuParaCut.setDisabled(disabled || !cancopy); - menuParaPaste.setDisabled(disabled); - menuParaPrint.setVisible(me.mode.canPrint); - menuParaPrint.setDisabled(!cancopy); + me.menuParaCopy.setDisabled(!cancopy); + me.menuParaCut.setDisabled(disabled || !cancopy); + me.menuParaPaste.setDisabled(disabled); + me.menuParaPrint.setVisible(me.mode.canPrint); + me.menuParaPrint.setDisabled(!cancopy); var lockreview = Common.Utils.InternalSettings.get("de-accept-reject-lock"); - menuParaAccept.setVisible(!lockreview); - menuParaReject.setVisible(!lockreview); + me.menuParaAccept.setVisible(!lockreview); + me.menuParaReject.setVisible(!lockreview); menuParaReviewSeparator.setVisible(!lockreview); // spellCheck var spell = (value.spellProps!==undefined && value.spellProps.value.get_Checked()===false); me.menuSpellPara.setVisible(spell); menuSpellcheckParaSeparator.setVisible(spell); - menuIgnoreSpellPara.setVisible(spell); - menuIgnoreAllSpellPara.setVisible(spell); - menuToDictionaryPara.setVisible(spell && me.mode.isDesktopApp); + me.menuIgnoreSpellPara.setVisible(spell); + me.menuIgnoreAllSpellPara.setVisible(spell); + me.menuToDictionaryPara.setVisible(spell && me.mode.isDesktopApp); me.langParaMenu.setVisible(spell); me.langParaMenu.setDisabled(disabled); menuIgnoreSpellParaSeparator.setVisible(spell); @@ -4165,14 +1951,14 @@ define([ } else me.clearEquationMenu(true, 18); menuEquationSeparator.setVisible(isEquation && eqlen>0); - menuEquationInsertCaption.setVisible(isEquation); + me.menuEquationInsertCaption.setVisible(isEquation); menuEquationInsertCaptionSeparator.setVisible(isEquation); var frame_pr = value.paraProps.value.get_FramePr(); - menuFrameAdvanced.setVisible(frame_pr !== undefined); - menuDropCapAdvanced.setVisible(frame_pr !== undefined); + me.menuFrameAdvanced.setVisible(frame_pr !== undefined); + me.menuDropCapAdvanced.setVisible(frame_pr !== undefined); if (frame_pr) - menuDropCapAdvanced.setIconCls(frame_pr.get_DropCap()===Asc.c_oAscDropCap.Drop ? 'menu__icon dropcap-intext' : 'menu__icon dropcap-inmargin'); + me.menuDropCapAdvanced.setIconCls(frame_pr.get_DropCap()===Asc.c_oAscDropCap.Drop ? 'menu__icon dropcap-intext' : 'menu__icon dropcap-inmargin'); var edit_style = me.mode.canEditStyles && !isInChart && !(value.imgProps && value.imgProps.isSmartArtInternal); menuStyleSeparator.setVisible(edit_style); @@ -4184,21 +1970,21 @@ define([ var control_lock = (value.paraProps) ? (!value.paraProps.value.can_DeleteBlockContentControl() || !value.paraProps.value.can_EditBlockContentControl() || !value.paraProps.value.can_DeleteInlineContentControl() || !value.paraProps.value.can_EditInlineContentControl()) : false; - menuParaRemoveControl.setVisible(in_control); - menuParaControlSettings.setVisible(in_control && me.mode.canEditContentControl && !is_form); + me.menuParaRemoveControl.setVisible(in_control); + me.menuParaControlSettings.setVisible(in_control && me.mode.canEditContentControl && !is_form); menuParaControlSeparator.setVisible(in_control); if (in_control) { var 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); - menuParaRemoveControl.setCaption(is_form ? me.getControlLabel(control_props) : me.textRemoveControl); + me.menuParaRemoveControl.setDisabled(lock_type==Asc.c_oAscSdtLockType.SdtContentLocked || lock_type==Asc.c_oAscSdtLockType.SdtLocked); + me.menuParaRemoveControl.setCaption(is_form ? me.getControlLabel(control_props) : me.textRemoveControl); var spectype = control_props ? control_props.get_SpecificType() : Asc.c_oAscContentControlSpecificType.None; control_lock = control_lock || spectype==Asc.c_oAscContentControlSpecificType.CheckBox || spectype==Asc.c_oAscContentControlSpecificType.Picture || spectype==Asc.c_oAscContentControlSpecificType.ComboBox || spectype==Asc.c_oAscContentControlSpecificType.DropDownList || spectype==Asc.c_oAscContentControlSpecificType.DateTime; } - menuParaTOCSettings.setVisible(in_toc); - menuParaTOCRefresh.setVisible(in_toc); + me.menuParaTOCSettings.setVisible(in_toc); + me.menuParaTOCRefresh.setVisible(in_toc); menuParaTOCSeparator.setVisible(in_toc); /** coauthoring begin **/ @@ -4206,84 +1992,84 @@ define([ if (me.mode.compatibleFeatures) isVisible = isVisible && !isInShape; menuCommentSeparatorPara.setVisible(isVisible); - menuAddCommentPara.setVisible(isVisible); - menuAddCommentPara.setDisabled(value.paraProps && value.paraProps.locked === true); + me.menuAddCommentPara.setVisible(isVisible); + me.menuAddCommentPara.setDisabled(value.paraProps && value.paraProps.locked === true); /** coauthoring end **/ var in_field = me.api.asc_GetCurrentComplexField(); - menuParaRefreshField.setVisible(!!in_field); - menuParaRefreshField.setDisabled(disabled); + me.menuParaRefreshField.setVisible(!!in_field); + me.menuParaRefreshField.setDisabled(disabled); menuParaFieldSeparator.setVisible(!!in_field); if (in_field) { - menuParaRefreshField.options.fieldProps = in_field; + me.menuParaRefreshField.options.fieldProps = in_field; } 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); + me.menuParaStartNewList.setVisible(in_list); + me.menuParaStartNumberingFrom.setVisible(in_list); + me.menuParaContinueNumbering.setVisible(in_list); if (in_list) { 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); - menuParaStartNewList.value = {start: numLvl.get_Start()}; - menuParaStartNumberingFrom.setVisible(format != Asc.c_oAscNumberingFormat.Bullet); - menuParaStartNumberingFrom.value = {format: format, start: start}; - menuParaStartNewList.setCaption((format == Asc.c_oAscNumberingFormat.Bullet) ? me.textSeparateList : me.textStartNewList); - menuParaContinueNumbering.setCaption((format == Asc.c_oAscNumberingFormat.Bullet) ? me.textJoinList : me.textContinueNumbering); + me.menuParaStartNewList.setVisible(numLvl.get_Start()!=start); + me.menuParaStartNewList.value = {start: numLvl.get_Start()}; + me.menuParaStartNumberingFrom.setVisible(format != Asc.c_oAscNumberingFormat.Bullet); + me.menuParaStartNumberingFrom.value = {format: format, start: start}; + me.menuParaStartNewList.setCaption((format == Asc.c_oAscNumberingFormat.Bullet) ? me.textSeparateList : me.textStartNewList); + me.menuParaContinueNumbering.setCaption((format == Asc.c_oAscNumberingFormat.Bullet) ? me.textJoinList : me.textContinueNumbering); } }, items: [ me.menuSpellPara, me.menuSpellMorePara, menuSpellcheckParaSeparator, - menuIgnoreSpellPara, - menuIgnoreAllSpellPara, - menuToDictionaryPara, + me.menuIgnoreSpellPara, + me.menuIgnoreAllSpellPara, + me.menuToDictionaryPara, me.langParaMenu, menuIgnoreSpellParaSeparator, - menuParaCut, - menuParaCopy, - menuParaPaste, - menuParaPrint, + me.menuParaCut, + me.menuParaCopy, + me.menuParaPaste, + me.menuParaPrint, menuParaReviewSeparator, - menuParaAccept, - menuParaReject, + me.menuParaAccept, + me.menuParaReject, menuEquationInsertCaptionSeparator, - menuEquationInsertCaption, + me.menuEquationInsertCaption, { caption: '--' }, menuEquationSeparator, - menuParaRemoveControl, - menuParaControlSettings, + me.menuParaRemoveControl, + me.menuParaControlSettings, menuParaControlSeparator, - menuParaRefreshField, + me.menuParaRefreshField, menuParaFieldSeparator, - menuParaTOCSettings, - menuParaTOCRefresh, + me.menuParaTOCSettings, + me.menuParaTOCRefresh, menuParaTOCSeparator, - menuParagraphBreakBefore, - menuParagraphKeepLines, - menuParagraphVAlign, - menuParagraphDirection, - menuParagraphAdvanced, - menuFrameAdvanced, - menuDropCapAdvanced, + me.menuParagraphBreakBefore, + me.menuParagraphKeepLines, + me.menuParagraphVAlign, + me.menuParagraphDirection, + me.menuParagraphAdvanced, + me.menuFrameAdvanced, + me.menuDropCapAdvanced, /** coauthoring begin **/ menuCommentSeparatorPara, - menuAddCommentPara, + me.menuAddCommentPara, /** coauthoring end **/ menuHyperlinkParaSeparator, - menuAddHyperlinkPara, + me.menuAddHyperlinkPara, menuHyperlinkPara, menuParaFollowSeparator, - menuParaFollow, + me.menuParaFollow, menuParaNumberingSeparator, - menuParaStartNewList, - menuParaStartNumberingFrom, - menuParaContinueNumbering, + me.menuParaStartNewList, + me.menuParaStartNumberingFrom, + me.menuParaContinueNumbering, menuStyleSeparator, menuStyle ] @@ -4338,6 +2124,667 @@ define([ title : me.textPrevPage + Common.Utils.String.platformKey('Alt+PgUp'), placement : 'top-right' }); + + this.fireEvent('createdelayedelements', [this, 'edit']); + }, + + initEquationMenu: function() { + var me = this; + if (!me._currentMathObj) return; + var 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({ + cls: 'shifted-right', + 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({ + cls: 'shifted-right', + 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({ + cls: 'shifted-right', + 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({ + cls: 'shifted-right', + 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({ + cls: 'shifted-right', + 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({ + cls: 'shifted-right', + 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(isParagraph, insertIdx) { + var me = this; + 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; + }, + + clearEquationMenu: function(isParagraph, insertIdx) { + var me = this; + 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; + } + }, + + equationCallback: function(eqProps) { + this.fireEvent('equation:callback', [eqProps]); + }, + + addWordVariants: function(isParagraph) { + var me = this; + if (!me.textMenu || !me.textMenu.isVisible() && !me.tableMenu.isVisible()) return; + + 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) { + _.each(arr, function(variant, index){ + me.textMenu.insertItem(index, variant); + }) + } else { + _.each(arr, function(variant, index){ + me.menuSpellCheckTable.menu.insertItem(index, variant); + }) + } + } + + if (arrMore.length > 0) { + _.each(arrMore, function(variant, index){ + moreMenu.menu.addItem(variant); + }); + } + + spellMenu.setVisible(false); + } else { + moreMenu.setVisible(false); + spellMenu.setVisible(true); + spellMenu.setCaption(me.noSpellVariantsText, true); + } + }, + + clearWordVariants: function(isParagraph) { + var me = this; + 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; }, setLanguages: function(langs){ @@ -4358,285 +2805,16 @@ define([ }); me.langParaMenu.menu.resetItems(arrPara); me.langTableMenu.menu.resetItems(arrTable); - - me.langParaMenu.menu.on('item:click', function(menu, item){ - if (me.api){ - if (!_.isUndefined(item.langid)) - me.api.put_TextPrLang(item.langid); - - me._currLang.paraid = item.langid; - me.fireEvent('editcomplete', me); - } - }); - - me.langTableMenu.menu.on('item:click', function(menu, item, e){ - if (me.api){ - if (!_.isUndefined(item.langid)) - me.api.put_TextPrLang(item.langid); - - me._currLang.tableid = item.langid; - me.fireEvent('editcomplete', me); - } - }); } }, - onSignatureClick: function(item) { - var datavalue = item.cmpEl.attr('data-value'); - switch (item.value) { - case 0: - Common.NotificationCenter.trigger('protect:sign', datavalue); //guid - break; - case 1: - this.api.asc_ViewCertificate(datavalue); //certificate id - break; - case 2: - Common.NotificationCenter.trigger('protect:signature', 'visible', this._isDisabled, datavalue);//guid, can edit settings for requested signature - break; - case 3: - var me = this; - Common.UI.warning({ - title: this.notcriticalErrorTitle, - msg: this.txtRemoveWarning, - buttons: ['ok', 'cancel'], - primary: 'ok', - callback: function(btn) { - if (btn == 'ok') { - me.api.asc_RemoveSignature(datavalue); - } - } - }); - break; - } - }, - - onImgRotate: function(item) { - var properties = new Asc.asc_CImgProperty(); - properties.asc_putRotAdd((item.value==1 ? 90 : 270) * 3.14159265358979 / 180); - this.api.ImgApply(properties); - 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); - }, - - onImgCrop: function(item) { - if (item.value == 1) { - this.api.asc_cropFill(); - } else if (item.value == 2) { - this.api.asc_cropFit(); + changeLanguageMenu: function(menu) { + if (this._currLang.id===null || this._currLang.id===undefined) { + menu.clearAll(); } else { - item.checked ? this.api.asc_startEditCrop() : this.api.asc_endEditCrop(); + var index = _.findIndex(menu.items, {langid: this._currLang.id}); + (index>-1) && !menu.items[index].checked && menu.setChecked(index, true); } - this.fireEvent('editcomplete', this); - }, - - onFollowMove: function(item) { - if (this.api) { - this.api.asc_FollowRevisionMove(item.value); - } - this.fireEvent('editcomplete', this); - }, - - 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 = $('
'); - 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) { - var specProps = me._dateObj.get_DateTimePr(); - specProps.put_FullDate(new Date(date)); - me.api.asc_SetContentControlDatePickerDate(specProps); - 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(); - } - }); - $(document).on('mousedown', function(e) { - if (e.target.localName !== 'canvas' && controlsContainer.is(':visible') && controlsContainer.find(e.target).length==0) { - controlsContainer.hide(); - me.api.asc_UncheckContentControlButtons(); - } - }); - - } - this.cmpCalendar.setDate(new Date(specProps ? specProps.get_FullDate() : undefined)); - - // align - var offset = controlsContainer.offset(), - docW = Common.Utils.innerWidth(), - docH = Common.Utils.innerHeight() - 10, // Yep, it's magic number - menuW = this.cmpCalendar.cmpEl.outerWidth(), - menuH = this.cmpCalendar.cmpEl.outerHeight(), - buttonOffset = 22, - left = offset.left - menuW, - top = offset.top; - if (top + menuH > docH) { - top = docH - menuH; - left -= buttonOffset; - } - if (top < 0) - top = 0; - if (left + menuW > docW) - left = docW - menuW; - this.cmpCalendar.cmpEl.css({left: left, top : top}); - - this._preventClick = true; - }, - - onShowListActions: function(obj, x, y) { - var type = obj.type, - props = obj.pr, - specProps = (type == Asc.c_oAscContentControlSpecificType.ComboBox) ? props.get_ComboBoxPr() : props.get_DropDownListPr(), - isForm = !!props.get_FormPr(), - 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({ - maxHeight: 207, - menuAlign: 'tr-bl', - items: [] - }); - menu.on('item:click', function(menu, item) { - setTimeout(function(){ - (item.value!==-1) && me.api.asc_SelectContentControlListItem(item.value, me._listObj.get_InternalId()); - }, 1); - }); - - // Prepare menu container - if (!menuContainer || menuContainer.length < 1) { - menuContainer = $(Common.Utils.String.format('', 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) { - if (isForm){ // for dropdown and combobox form control always add placeholder item - var text = props.get_PlaceholderText(); - menu.addItem(new Common.UI.MenuItem({ - caption : (text.trim()!=='') ? text : this.txtEmpty, - value : '', - template : _.template([ - ' opacity: 0.6 <% } %>">', - '<%= caption %>', - '' - ].join('')) - })); - } - var count = specProps.get_ItemsCount(); - for (var i=0; i', - '<%= Common.Utils.String.htmlEncode(caption) %>', - '' - ].join('')) - })); - } - if (!isForm && menu.items.length<1) { - menu.addItem(new Common.UI.MenuItem({ - caption : this.txtEmpty, - value : -1 - })); - } - } - - menuContainer.css({left: x, top : y}); - menuContainer.attr('data-value', 'prevent-canvas-click'); - this._preventClick = true; - menu.show(); - - _.delay(function() { - menu.cmpEl.focus(); - }, 10); - this._fromShowContentControls = false; - }, - - onShowContentControlsActions: function(obj, x, y) { - var type = obj.type; - switch (type) { - case Asc.c_oAscContentControlSpecificType.DateTime: - this.onShowDateActions(obj, x, y); - break; - case Asc.c_oAscContentControlSpecificType.Picture: - if (obj.pr && obj.pr.get_Lock) { - var lock = obj.pr.get_Lock(); - if (lock == Asc.c_oAscSdtLockType.SdtContentLocked || lock==Asc.c_oAscSdtLockType.ContentLocked) - return; - } - this.api.asc_addImage(obj); - var me = this; - setTimeout(function(){ - me.api.asc_UncheckContentControlButtons(); - }, 500); - break; - case Asc.c_oAscContentControlSpecificType.DropDownList: - case Asc.c_oAscContentControlSpecificType.ComboBox: - this.onShowListActions(obj, x, y); - break; - } - }, - - onApiLockDocumentProps: function() { - this._state.lock_doc = true; - }, - - onApiUnLockDocumentProps: function() { - this._state.lock_doc = false; }, getControlLabel: function(props) { diff --git a/apps/presentationeditor/main/app/view/DocumentHolder.js b/apps/presentationeditor/main/app/view/DocumentHolder.js index dd7c39c9a..35d8ee7be 100644 --- a/apps/presentationeditor/main/app/view/DocumentHolder.js +++ b/apps/presentationeditor/main/app/view/DocumentHolder.js @@ -1855,7 +1855,7 @@ define([ cls: 'shifted-right', initMenu: function (value) { menuViewUndo.setVisible(me.mode.canCoAuthoring && me.mode.canComments && !me._isDisabled); - menuViewUndo.setDisabled(!me.api.asc_getCanUndo() && !me._isDisabled); + menuViewUndo.setDisabled(!me.api.asc_getCanUndo()); menuViewCopySeparator.setVisible(!value.isChart && me.api.can_AddQuotedComment() !== false && me.mode.canCoAuthoring && me.mode.canComments && !me._isDisabled); menuViewAddComment.setVisible(!value.isChart && me.api.can_AddQuotedComment() !== false && me.mode.canCoAuthoring && me.mode.canComments && !me._isDisabled); menuViewAddComment.setDisabled(value.locked); diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index ea87aa03a..c572a3fa1 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -2327,7 +2327,7 @@ define([ canComment = iscellmenu && !iscelledit && this.permissions.canCoAuthoring && this.permissions.canComments && !this._isDisabled && cellinfo.asc_getComments() && cellinfo.asc_getComments().length < 1; documentHolder.menuViewUndo.setVisible(this.permissions.canCoAuthoring && this.permissions.canComments && !this._isDisabled); - documentHolder.menuViewUndo.setDisabled(!this.api.asc_getCanUndo() && !this._isDisabled); + documentHolder.menuViewUndo.setDisabled(!this.api.asc_getCanUndo()); documentHolder.menuViewCopySeparator.setVisible(isInSign); var isRequested = (signProps) ? signProps.asc_getRequested() : false;