diff --git a/apps/common/main/lib/view/ReviewChanges.js b/apps/common/main/lib/view/ReviewChanges.js index 8f8ad705a..f24941211 100644 --- a/apps/common/main/lib/view/ReviewChanges.js +++ b/apps/common/main/lib/view/ReviewChanges.js @@ -468,7 +468,7 @@ define([ if (!me.btnHistory && separator_last) me.$el.find(separator_last).hide(); - Common.NotificationCenter.trigger('tab:visible', 'review', config.isEdit || config.canViewReview); + Common.NotificationCenter.trigger('tab:visible', 'review', config.isEdit || config.canViewReview || config.canCoAuthoring && config.canComments); setEvents.call(me); }); diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 22beaaa0c..f1e81d3de 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -1269,7 +1269,7 @@ define([ var toolbarController = application.getController('Toolbar'); toolbarController && toolbarController.setApi(me.api); - if (this.appOptions.isRestrictedEdit) return; + if (!this.appOptions.isEdit) return; var rightmenuController = application.getController('RightMenu'), fontsControllers = application.getController('Common.Controllers.Fonts'); diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index f1629ec05..ea3bd9378 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -976,14 +976,17 @@ define([ reviewController = application.getController('Common.Controllers.ReviewChanges'); reviewController.setMode(me.appOptions).setConfig({config: me.editorConfig}, me.api).loadDocument({doc:me.document}); - if (this.appOptions.isEdit) { - var toolbarController = application.getController('Toolbar'), - rightmenuController = application.getController('RightMenu'), + if (this.appOptions.isEdit || this.appOptions.isRestrictedEdit) { // set api events for toolbar in the Restricted Editing mode) + var toolbarController = application.getController('Toolbar'); + toolbarController && toolbarController.setApi(me.api); + + if (!this.appOptions.isEdit) return; + + var rightmenuController = application.getController('RightMenu'), fontsControllers = application.getController('Common.Controllers.Fonts'); // me.getStore('SlideLayouts'); fontsControllers && fontsControllers.setApi(me.api); - toolbarController && toolbarController.setApi(me.api); rightmenuController && rightmenuController.setApi(me.api); if (me.appOptions.canProtect) diff --git a/apps/presentationeditor/main/app/controller/Toolbar.js b/apps/presentationeditor/main/app/controller/Toolbar.js index e5f0f9509..0373668a7 100644 --- a/apps/presentationeditor/main/app/controller/Toolbar.js +++ b/apps/presentationeditor/main/app/controller/Toolbar.js @@ -323,48 +323,52 @@ define([ setApi: function(api) { this.api = api; - this.toolbar.setApi(api); + if (this.mode.isEdit) { + this.toolbar.setApi(api); - this.api.asc_registerCallback('asc_onFontSize', _.bind(this.onApiFontSize, this)); - this.api.asc_registerCallback('asc_onBold', _.bind(this.onApiBold, this)); - this.api.asc_registerCallback('asc_onItalic', _.bind(this.onApiItalic, this)); - this.api.asc_registerCallback('asc_onUnderline', _.bind(this.onApiUnderline, this)); - this.api.asc_registerCallback('asc_onStrikeout', _.bind(this.onApiStrikeout, this)); - this.api.asc_registerCallback('asc_onVerticalAlign', _.bind(this.onApiVerticalAlign, this)); - Common.NotificationCenter.on('fonts:change', _.bind(this.onApiChangeFont, this)); + this.api.asc_registerCallback('asc_onFontSize', _.bind(this.onApiFontSize, this)); + this.api.asc_registerCallback('asc_onBold', _.bind(this.onApiBold, this)); + this.api.asc_registerCallback('asc_onItalic', _.bind(this.onApiItalic, this)); + this.api.asc_registerCallback('asc_onUnderline', _.bind(this.onApiUnderline, this)); + this.api.asc_registerCallback('asc_onStrikeout', _.bind(this.onApiStrikeout, this)); + this.api.asc_registerCallback('asc_onVerticalAlign', _.bind(this.onApiVerticalAlign, this)); + Common.NotificationCenter.on('fonts:change', _.bind(this.onApiChangeFont, this)); - this.api.asc_registerCallback('asc_onCanUndo', _.bind(this.onApiCanRevert, this, 'undo')); - this.api.asc_registerCallback('asc_onCanRedo', _.bind(this.onApiCanRevert, this, 'redo')); - this.api.asc_registerCallback('asc_onPaintFormatChanged', _.bind(this.onApiStyleChange, this)); - this.api.asc_registerCallback('asc_onListType', _.bind(this.onApiBullets, this)); - this.api.asc_registerCallback('asc_canIncreaseIndent', _.bind(this.onApiCanIncreaseIndent, this)); - this.api.asc_registerCallback('asc_canDecreaseIndent', _.bind(this.onApiCanDecreaseIndent, this)); - this.api.asc_registerCallback('asc_onLineSpacing', _.bind(this.onApiLineSpacing, this)); - this.api.asc_registerCallback('asc_onPrAlign', _.bind(this.onApiParagraphAlign, this)); - this.api.asc_registerCallback('asc_onVerticalTextAlign', _.bind(this.onApiVerticalTextAlign, this)); - this.api.asc_registerCallback('asc_onCanAddHyperlink', _.bind(this.onApiCanAddHyperlink, this)); - this.api.asc_registerCallback('asc_onTextColor', _.bind(this.onApiTextColor, this)); + this.api.asc_registerCallback('asc_onCanUndo', _.bind(this.onApiCanRevert, this, 'undo')); + this.api.asc_registerCallback('asc_onCanRedo', _.bind(this.onApiCanRevert, this, 'redo')); + this.api.asc_registerCallback('asc_onPaintFormatChanged', _.bind(this.onApiStyleChange, this)); + this.api.asc_registerCallback('asc_onListType', _.bind(this.onApiBullets, this)); + this.api.asc_registerCallback('asc_canIncreaseIndent', _.bind(this.onApiCanIncreaseIndent, this)); + this.api.asc_registerCallback('asc_canDecreaseIndent', _.bind(this.onApiCanDecreaseIndent, this)); + this.api.asc_registerCallback('asc_onLineSpacing', _.bind(this.onApiLineSpacing, this)); + this.api.asc_registerCallback('asc_onPrAlign', _.bind(this.onApiParagraphAlign, this)); + this.api.asc_registerCallback('asc_onVerticalTextAlign', _.bind(this.onApiVerticalTextAlign, this)); + this.api.asc_registerCallback('asc_onCanAddHyperlink', _.bind(this.onApiCanAddHyperlink, this)); + this.api.asc_registerCallback('asc_onTextColor', _.bind(this.onApiTextColor, this)); - this.api.asc_registerCallback('asc_onUpdateThemeIndex', _.bind(this.onApiUpdateThemeIndex, this)); - this.api.asc_registerCallback('asc_onEndAddShape', _.bind(this.onApiEndAddShape, this)); - this.api.asc_registerCallback('asc_onCanGroup', _.bind(this.onApiCanGroup, this)); - this.api.asc_registerCallback('asc_onCanUnGroup', _.bind(this.onApiCanUnGroup, this)); - this.api.asc_registerCallback('asc_onPresentationSize', _.bind(this.onApiPageSize, this)); + this.api.asc_registerCallback('asc_onUpdateThemeIndex', _.bind(this.onApiUpdateThemeIndex, this)); + this.api.asc_registerCallback('asc_onEndAddShape', _.bind(this.onApiEndAddShape, this)); + this.api.asc_registerCallback('asc_onCanGroup', _.bind(this.onApiCanGroup, this)); + this.api.asc_registerCallback('asc_onCanUnGroup', _.bind(this.onApiCanUnGroup, this)); + this.api.asc_registerCallback('asc_onPresentationSize', _.bind(this.onApiPageSize, this)); - this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onApiCoAuthoringDisconnect, this)); - Common.NotificationCenter.on('api:disconnect', _.bind(this.onApiCoAuthoringDisconnect, this)); - this.api.asc_registerCallback('asc_onZoomChange', _.bind(this.onApiZoomChange, this)); - this.api.asc_registerCallback('asc_onFocusObject', _.bind(this.onApiFocusObject, 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_onLockDocumentTheme', _.bind(this.onApiLockDocumentTheme, this)); - this.api.asc_registerCallback('asc_onUnLockDocumentTheme', _.bind(this.onApiUnLockDocumentTheme, this)); - this.api.asc_registerCallback('asc_onInitEditorStyles', _.bind(this.onApiInitEditorStyles, this)); + this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onApiCoAuthoringDisconnect, this)); + Common.NotificationCenter.on('api:disconnect', _.bind(this.onApiCoAuthoringDisconnect, this)); + this.api.asc_registerCallback('asc_onZoomChange', _.bind(this.onApiZoomChange, this)); + this.api.asc_registerCallback('asc_onFocusObject', _.bind(this.onApiFocusObject, 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_onLockDocumentTheme', _.bind(this.onApiLockDocumentTheme, this)); + this.api.asc_registerCallback('asc_onUnLockDocumentTheme', _.bind(this.onApiUnLockDocumentTheme, this)); + this.api.asc_registerCallback('asc_onInitEditorStyles', _.bind(this.onApiInitEditorStyles, this)); - this.api.asc_registerCallback('asc_onCountPages', _.bind(this.onApiCountPages, this)); - this.api.asc_registerCallback('asc_onMathTypes', _.bind(this.onApiMathTypes, this)); - this.api.asc_registerCallback('asc_onContextMenu', _.bind(this.onContextMenu, this)); - this.api.asc_registerCallback('asc_onTextLanguage', _.bind(this.onTextLanguage, this)); + this.api.asc_registerCallback('asc_onCountPages', _.bind(this.onApiCountPages, this)); + this.api.asc_registerCallback('asc_onMathTypes', _.bind(this.onApiMathTypes, this)); + this.api.asc_registerCallback('asc_onContextMenu', _.bind(this.onContextMenu, this)); + this.api.asc_registerCallback('asc_onTextLanguage', _.bind(this.onTextLanguage, this)); + } else if (this.mode.isRestrictedEdit) { + this.api.asc_registerCallback('asc_onCountPages', _.bind(this.onApiCountPagesRestricted, this)); + } }, onChangeCompactView: function(view, compact) { @@ -638,6 +642,14 @@ define([ } }, + onApiCountPagesRestricted: function(count) { + if (this._state.no_slides !== (count<=0)) { + this._state.no_slides = (count<=0); + if (this.btnsComment) + this.toolbar.lockToolbar(PE.enumLock.noSlides, this._state.no_slides, { array: this.btnsComment }); + } + }, + onApiFocusObject: function(selectedObjects) { if (!this.editMode) return; @@ -2139,12 +2151,13 @@ define([ me.toolbar.render(_.extend({compactview: compactview}, config)); + var tab = {action: 'review', caption: me.toolbar.textTabCollaboration}; + var $panel = me.getApplication().getController('Common.Controllers.ReviewChanges').createToolbarPanel(); + if ( $panel ) + me.toolbar.addTab(tab, $panel, 3); + if ( config.isEdit ) { me.toolbar.setMode(config); - var tab = {action: 'review', caption: me.toolbar.textTabCollaboration}; - var $panel = me.getApplication().getController('Common.Controllers.ReviewChanges').createToolbarPanel(); - if ( $panel ) - me.toolbar.addTab(tab, $panel, 3); me.toolbar.btnSave.on('disabled', _.bind(me.onBtnChangeState, me, 'save:disabled')); diff --git a/apps/presentationeditor/main/app/view/Toolbar.js b/apps/presentationeditor/main/app/view/Toolbar.js index 37e238ecd..253df53b9 100644 --- a/apps/presentationeditor/main/app/view/Toolbar.js +++ b/apps/presentationeditor/main/app/view/Toolbar.js @@ -121,7 +121,7 @@ define([ applyLayout: function (config) { var me = this; - + me.lockControls = []; if ( config.isEdit ) { Common.UI.Mixtbar.prototype.initialize.call(this, { template: _.template(template), diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 8a6694f98..74a38f3bf 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -1050,14 +1050,17 @@ define([ reviewController = application.getController('Common.Controllers.ReviewChanges'); reviewController.setMode(me.appOptions).setConfig({config: me.editorConfig}, me.api).loadDocument({doc:me.appOptions.spreadsheet}); - if (this.appOptions.isEdit) { - var toolbarController = application.getController('Toolbar'), - statusbarController = application.getController('Statusbar'), + if (this.appOptions.isEdit || this.appOptions.isRestrictedEdit) { // set api events for toolbar in the Restricted Editing mode + var toolbarController = application.getController('Toolbar'); + toolbarController && toolbarController.setApi(me.api); + + if (!this.appOptions.isEdit) return; + + var statusbarController = application.getController('Statusbar'), rightmenuController = application.getController('RightMenu'), fontsControllers = application.getController('Common.Controllers.Fonts'); fontsControllers && fontsControllers.setApi(me.api); - toolbarController && toolbarController.setApi(me.api); // statusbarController && statusbarController.setApi(me.api); rightmenuController && rightmenuController.setApi(me.api); diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index 38f3a4009..0a2c60e52 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -389,18 +389,21 @@ define([ this.api = api; var config = SSE.getController('Main').appOptions; - if ( !config.isEditDiagram && !config.isEditMailMerge ) { - this.api.asc_registerCallback('asc_onSendThemeColors', _.bind(this.onSendThemeColors, this)); - this.api.asc_registerCallback('asc_onMathTypes', _.bind(this.onApiMathTypes, this)); - this.api.asc_registerCallback('asc_onContextMenu', _.bind(this.onContextMenu, this)); - } + if (config.isEdit) { + if ( !config.isEditDiagram && !config.isEditMailMerge ) { + this.api.asc_registerCallback('asc_onSendThemeColors', _.bind(this.onSendThemeColors, this)); + this.api.asc_registerCallback('asc_onMathTypes', _.bind(this.onApiMathTypes, this)); + this.api.asc_registerCallback('asc_onContextMenu', _.bind(this.onContextMenu, this)); + } + this.api.asc_registerCallback('asc_onInitEditorStyles', _.bind(this.onApiInitEditorStyles, this)); + this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onApiCoAuthoringDisconnect, this)); + Common.NotificationCenter.on('api:disconnect', _.bind(this.onApiCoAuthoringDisconnect, this)); + this.api.asc_registerCallback('asc_onLockDefNameManager', _.bind(this.onLockDefNameManager, this)); + this.api.asc_registerCallback('asc_onZoomChanged', _.bind(this.onApiZoomChange, this)); + Common.NotificationCenter.on('fonts:change', _.bind(this.onApiChangeFont, this)); + } else if (config.isRestrictedEdit) + this.api.asc_registerCallback('asc_onSelectionChanged', _.bind(this.onApiSelectionChangedRestricted, this)); - this.api.asc_registerCallback('asc_onInitEditorStyles', _.bind(this.onApiInitEditorStyles, this)); - this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onApiCoAuthoringDisconnect, this)); - Common.NotificationCenter.on('api:disconnect', _.bind(this.onApiCoAuthoringDisconnect, this)); - this.api.asc_registerCallback('asc_onLockDefNameManager', _.bind(this.onLockDefNameManager, this)); - this.api.asc_registerCallback('asc_onZoomChanged', _.bind(this.onApiZoomChange, this)); - Common.NotificationCenter.on('fonts:change', _.bind(this.onApiChangeFont, this)); }, // onNewDocument: function(btn, e) { @@ -2429,6 +2432,13 @@ define([ toolbar.lockToolbar(SSE.enumLock.headerLock, info.asc_getLockedHeaderFooter(), {array: this.toolbar.btnsEditHeader}); }, + onApiSelectionChangedRestricted: function(info) { + var selectionType = info.asc_getFlags().asc_getSelectionType(); + this.toolbar.lockToolbar(SSE.enumLock.commentLock, (selectionType == Asc.c_oAscSelectionType.RangeCells) && (info.asc_getComments().length>0 || info.asc_getLocked()) || + this.appConfig && this.appConfig.compatibleFeatures && (selectionType != Asc.c_oAscSelectionType.RangeCells), + { array: this.btnsComment }); + }, + onApiSelectionChanged_DiagramEditor: function(info) { if ( !this.editMode || this.api.isCellEdited || this.api.isRangeSelection) return; @@ -3177,6 +3187,13 @@ define([ me.toolbar.render(_.extend({isCompactView: compactview}, config)); + if ( !config.isEditDiagram && !config.isEditMailMerge ) { + var tab = {action: 'review', caption: me.toolbar.textTabCollaboration}; + var $panel = me.getApplication().getController('Common.Controllers.ReviewChanges').createToolbarPanel(); + if ($panel) + me.toolbar.addTab(tab, $panel, 6); + } + if ( config.isEdit ) { me.toolbar.setMode(config); @@ -3204,19 +3221,14 @@ define([ Array.prototype.push.apply(me.toolbar.lockControls, formulatab.getButtons()); if ( !config.isOffline ) { - tab = {action: 'pivot', caption: me.textPivot}; - $panel = me.getApplication().getController('PivotTable').createToolbarPanel(); + var tab = {action: 'pivot', caption: me.textPivot}; + var $panel = me.getApplication().getController('PivotTable').createToolbarPanel(); if ($panel) { me.toolbar.addTab(tab, $panel, 5); me.toolbar.setVisible('pivot', true); } } - var tab = {action: 'review', caption: me.toolbar.textTabCollaboration}; - var $panel = me.getApplication().getController('Common.Controllers.ReviewChanges').createToolbarPanel(); - if ( $panel ) - me.toolbar.addTab(tab, $panel, 6); - if (!(config.customization && config.customization.compactHeader)) { // hide 'print' and 'save' buttons group and next separator me.toolbar.btnPrint.$el.parents('.group').hide().next().hide(); @@ -3231,8 +3243,8 @@ define([ if ( config.isDesktopApp ) { if ( config.canProtect ) { - tab = {action: 'protect', caption: me.toolbar.textTabProtect}; - $panel = me.getApplication().getController('Common.Controllers.Protection').createToolbarPanel(); + var tab = {action: 'protect', caption: me.toolbar.textTabProtect}; + var $panel = me.getApplication().getController('Common.Controllers.Protection').createToolbarPanel(); if ($panel) me.toolbar.addTab(tab, $panel, 7); } diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index 769be62ab..f67499c25 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -1460,7 +1460,7 @@ define([ } ); } - + me.lockControls = []; if (config.isEdit) { me.lockControls = [ me.cmbFontName, me.cmbFontSize, me.btnIncFontSize, me.btnDecFontSize, me.btnBold,