From 0079474f373f70e94e54c683f79aae6e62794e0b Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 29 Dec 2021 19:32:43 +0300 Subject: [PATCH] [DE] Move enumLock to Common --- apps/common/main/lib/view/ReviewChanges.js | 17 +++ .../main/app/controller/FormsTab.js | 8 +- .../main/app/controller/Links.js | 26 ++-- .../main/app/controller/PageLayout.js | 16 +-- .../main/app/controller/Toolbar.js | 118 +++++++++--------- .../main/app/controller/ViewTab.js | 6 +- apps/documenteditor/main/app/view/FormsTab.js | 4 +- apps/documenteditor/main/app/view/Links.js | 4 +- apps/documenteditor/main/app/view/Toolbar.js | 26 ++-- apps/documenteditor/main/app/view/ViewTab.js | 2 +- 10 files changed, 127 insertions(+), 100 deletions(-) diff --git a/apps/common/main/lib/view/ReviewChanges.js b/apps/common/main/lib/view/ReviewChanges.js index ab3912fe9..e7fe615b6 100644 --- a/apps/common/main/lib/view/ReviewChanges.js +++ b/apps/common/main/lib/view/ReviewChanges.js @@ -54,6 +54,23 @@ define([ ], function () { 'use strict'; + if (!Common.enumLock) + Common.enumLock = {}; + + var enumLock = { + isReviewOnly: 'review-only', + reviewChangelock: 'review-change-lock', + hasCoeditingUsers: 'has-coediting-users', + previewReviewMode: 'preview-review-mode', // display mode on Collaboration tab + viewFormMode: 'view-form-mode', // view form mode on Forms tab + viewMode: 'view-mode' // view mode on disconnect, version history etc + }; + for (var key in enumLock) { + if (enumLock.hasOwnProperty(key)) { + Common.enumLock[key] = enumLock[key]; + } + } + Common.Views.ReviewChanges = Common.UI.BaseView.extend(_.extend((function(){ var template = '
' + diff --git a/apps/documenteditor/main/app/controller/FormsTab.js b/apps/documenteditor/main/app/controller/FormsTab.js index 0ceefda70..b73623a38 100644 --- a/apps/documenteditor/main/app/controller/FormsTab.js +++ b/apps/documenteditor/main/app/controller/FormsTab.js @@ -145,10 +145,10 @@ define([ var content_locked = lock_type==Asc.c_oAscSdtLockType.SdtContentLocked || lock_type==Asc.c_oAscSdtLockType.ContentLocked; var arr = [ this.view.btnTextField, this.view.btnComboBox, this.view.btnDropDown, this.view.btnCheckBox, this.view.btnRadioBox, this.view.btnImageField ]; - Common.Utils.lockControls(DE.enumLock.paragraphLock, paragraph_locked, {array: arr}); - Common.Utils.lockControls(DE.enumLock.headerLock, header_locked, {array: arr}); - Common.Utils.lockControls(DE.enumLock.controlPlain, control_plain, {array: arr}); - Common.Utils.lockControls(DE.enumLock.contentLock, content_locked, {array: arr}); + Common.Utils.lockControls(Common.enumLock.paragraphLock, paragraph_locked, {array: arr}); + Common.Utils.lockControls(Common.enumLock.headerLock, header_locked, {array: arr}); + Common.Utils.lockControls(Common.enumLock.controlPlain, control_plain, {array: arr}); + Common.Utils.lockControls(Common.enumLock.contentLock, content_locked, {array: arr}); }, onChangeSpecialFormsGlobalSettings: function() { diff --git a/apps/documenteditor/main/app/controller/Links.js b/apps/documenteditor/main/app/controller/Links.js index 86ded0add..bfe29f5e6 100644 --- a/apps/documenteditor/main/app/controller/Links.js +++ b/apps/documenteditor/main/app/controller/Links.js @@ -174,21 +174,21 @@ define([ plain_del_lock = (frame_pr) ? !frame_pr.can_DeleteInlineContentControl() : false, plain_edit_lock = (frame_pr) ? !frame_pr.can_EditInlineContentControl() : false; - this.lockToolbar(DE.enumLock.paragraphLock, paragraph_locked, {array: this.view.btnsNotes.concat(this.view.btnsHyperlink).concat([this.view.btnBookmarks, this.view.btnTableFiguresUpdate, this.view.btnCrossRef])}); - this.lockToolbar(DE.enumLock.inHeader, in_header, {array: this.view.btnsNotes.concat(this.view.btnsContents).concat([this.view.btnBookmarks, this.view.btnTableFigures, + this.lockToolbar(Common.enumLock.paragraphLock, paragraph_locked, {array: this.view.btnsNotes.concat(this.view.btnsHyperlink).concat([this.view.btnBookmarks, this.view.btnTableFiguresUpdate, this.view.btnCrossRef])}); + this.lockToolbar(Common.enumLock.inHeader, in_header, {array: this.view.btnsNotes.concat(this.view.btnsContents).concat([this.view.btnBookmarks, this.view.btnTableFigures, this.view.btnTableFiguresUpdate, this.view.btnCaption])}); - this.lockToolbar(DE.enumLock.controlPlain, control_plain, {array: this.view.btnsNotes.concat([this.view.btnBookmarks, this.view.btnCrossRef])}); - this.lockToolbar(DE.enumLock.richEditLock, rich_edit_lock, {array: this.view.btnsNotes.concat(this.view.btnsContents).concat([this.view.btnTableFigures, this.view.btnTableFiguresUpdate, + this.lockToolbar(Common.enumLock.controlPlain, control_plain, {array: this.view.btnsNotes.concat([this.view.btnBookmarks, this.view.btnCrossRef])}); + this.lockToolbar(Common.enumLock.richEditLock, rich_edit_lock, {array: this.view.btnsNotes.concat(this.view.btnsContents).concat([this.view.btnTableFigures, this.view.btnTableFiguresUpdate, this.view.btnCrossRef])}); - this.lockToolbar(DE.enumLock.plainEditLock, plain_edit_lock, {array: this.view.btnsNotes.concat(this.view.btnsContents).concat([this.view.btnTableFigures, this.view.btnTableFiguresUpdate, + this.lockToolbar(Common.enumLock.plainEditLock, plain_edit_lock, {array: this.view.btnsNotes.concat(this.view.btnsContents).concat([this.view.btnTableFigures, this.view.btnTableFiguresUpdate, this.view.btnCrossRef])}); - this.lockToolbar(DE.enumLock.headerLock, header_locked, {array: this.view.btnsHyperlink.concat([this.view.btnBookmarks, this.view.btnCrossRef])}); - this.lockToolbar(DE.enumLock.inEquation, in_equation, {array: this.view.btnsNotes}); - this.lockToolbar(DE.enumLock.inImage, in_image, {array: this.view.btnsNotes}); - this.lockToolbar(DE.enumLock.richDelLock, rich_del_lock, {array: this.view.btnsContents.concat([this.view.btnTableFigures, this.view.btnTableFiguresUpdate])}); - this.lockToolbar(DE.enumLock.plainDelLock, plain_del_lock, {array: this.view.btnsContents.concat([this.view.btnTableFigures, this.view.btnTableFiguresUpdate])}); - this.lockToolbar(DE.enumLock.contentLock, content_locked, {array: [this.view.btnCrossRef]}); - this.lockToolbar(DE.enumLock.cantUpdateTOF, !this.api.asc_CanUpdateTablesOfFigures(), {array: [this.view.btnTableFiguresUpdate]}); + this.lockToolbar(Common.enumLock.headerLock, header_locked, {array: this.view.btnsHyperlink.concat([this.view.btnBookmarks, this.view.btnCrossRef])}); + this.lockToolbar(Common.enumLock.inEquation, in_equation, {array: this.view.btnsNotes}); + this.lockToolbar(Common.enumLock.inImage, in_image, {array: this.view.btnsNotes}); + this.lockToolbar(Common.enumLock.richDelLock, rich_del_lock, {array: this.view.btnsContents.concat([this.view.btnTableFigures, this.view.btnTableFiguresUpdate])}); + this.lockToolbar(Common.enumLock.plainDelLock, plain_del_lock, {array: this.view.btnsContents.concat([this.view.btnTableFigures, this.view.btnTableFiguresUpdate])}); + this.lockToolbar(Common.enumLock.contentLock, content_locked, {array: [this.view.btnCrossRef]}); + this.lockToolbar(Common.enumLock.cantUpdateTOF, !this.api.asc_CanUpdateTablesOfFigures(), {array: [this.view.btnTableFiguresUpdate]}); this.dlgCrossRefDialog && this.dlgCrossRefDialog.isVisible() && this.dlgCrossRefDialog.setLocked(this.view.btnCrossRef.isDisabled()); }, @@ -198,7 +198,7 @@ define([ }, onApiCanAddHyperlink: function(value) { - this.toolbar.editMode && this.lockToolbar(DE.enumLock.hyperlinkLock, !value, {array: this.view.btnsHyperlink}); + this.toolbar.editMode && this.lockToolbar(Common.enumLock.hyperlinkLock, !value, {array: this.view.btnsHyperlink}); }, onHyperlinkClick: function(btn) { diff --git a/apps/documenteditor/main/app/controller/PageLayout.js b/apps/documenteditor/main/app/controller/PageLayout.js index 2b51efd8a..8f2a673d3 100644 --- a/apps/documenteditor/main/app/controller/PageLayout.js +++ b/apps/documenteditor/main/app/controller/PageLayout.js @@ -166,14 +166,14 @@ define([ break; } } - me.toolbar.lockToolbar(DE.enumLock.noObjectSelected, no_object, {array: [me.toolbar.btnImgAlign, me.toolbar.btnImgGroup, me.toolbar.btnImgWrapping, me.toolbar.btnImgForward, me.toolbar.btnImgBackward]}); - me.toolbar.lockToolbar(DE.enumLock.imageLock, islocked, {array: [me.toolbar.btnImgAlign, me.toolbar.btnImgGroup, me.toolbar.btnImgWrapping]}); - me.toolbar.lockToolbar(DE.enumLock.contentLock, content_locked, {array: [me.toolbar.btnImgAlign, me.toolbar.btnImgGroup, me.toolbar.btnImgWrapping, me.toolbar.btnImgForward, me.toolbar.btnImgBackward]}); - me.toolbar.lockToolbar(DE.enumLock.inImageInline, wrapping == Asc.c_oAscWrapStyle2.Inline, {array: [me.toolbar.btnImgAlign, me.toolbar.btnImgGroup]}); - me.toolbar.lockToolbar(DE.enumLock.inSmartartInternal, shapeProps && shapeProps.asc_getFromSmartArtInternal(), {array: [me.toolbar.btnImgForward, me.toolbar.btnImgBackward]}); - me.toolbar.lockToolbar(DE.enumLock.cantGroup, !canGroupUngroup, {array: [me.toolbar.btnImgGroup]}); - me.toolbar.lockToolbar(DE.enumLock.cantWrap, disable.wrapping, {array: [me.toolbar.btnImgWrapping]}); - me.toolbar.lockToolbar(DE.enumLock.cantArrange, disable.arrange, {array: [me.toolbar.btnImgForward, me.toolbar.btnImgBackward]}); + me.toolbar.lockToolbar(Common.enumLock.noObjectSelected, no_object, {array: [me.toolbar.btnImgAlign, me.toolbar.btnImgGroup, me.toolbar.btnImgWrapping, me.toolbar.btnImgForward, me.toolbar.btnImgBackward]}); + me.toolbar.lockToolbar(Common.enumLock.imageLock, islocked, {array: [me.toolbar.btnImgAlign, me.toolbar.btnImgGroup, me.toolbar.btnImgWrapping]}); + me.toolbar.lockToolbar(Common.enumLock.contentLock, content_locked, {array: [me.toolbar.btnImgAlign, me.toolbar.btnImgGroup, me.toolbar.btnImgWrapping, me.toolbar.btnImgForward, me.toolbar.btnImgBackward]}); + me.toolbar.lockToolbar(Common.enumLock.inImageInline, wrapping == Asc.c_oAscWrapStyle2.Inline, {array: [me.toolbar.btnImgAlign, me.toolbar.btnImgGroup]}); + me.toolbar.lockToolbar(Common.enumLock.inSmartartInternal, shapeProps && shapeProps.asc_getFromSmartArtInternal(), {array: [me.toolbar.btnImgForward, me.toolbar.btnImgBackward]}); + me.toolbar.lockToolbar(Common.enumLock.cantGroup, !canGroupUngroup, {array: [me.toolbar.btnImgGroup]}); + me.toolbar.lockToolbar(Common.enumLock.cantWrap, disable.wrapping, {array: [me.toolbar.btnImgWrapping]}); + me.toolbar.lockToolbar(Common.enumLock.cantArrange, disable.arrange, {array: [me.toolbar.btnImgForward, me.toolbar.btnImgBackward]}); }, onApiCoAuthoringDisconnect: function() { diff --git a/apps/documenteditor/main/app/controller/Toolbar.js b/apps/documenteditor/main/app/controller/Toolbar.js index e9e8a7fe9..2dabf0415 100644 --- a/apps/documenteditor/main/app/controller/Toolbar.js +++ b/apps/documenteditor/main/app/controller/Toolbar.js @@ -503,12 +503,12 @@ define([ onApiCanRevert: function(which, can) { if (which=='undo') { if (this._state.can_undo !== can) { - this.toolbar.lockToolbar(DE.enumLock.undoLock, !can, {array: [this.toolbar.btnUndo]}); + this.toolbar.lockToolbar(Common.enumLock.undoLock, !can, {array: [this.toolbar.btnUndo]}); this._state.can_undo = can; } } else { if (this._state.can_redo !== can) { - this.toolbar.lockToolbar(DE.enumLock.redoLock, !can, {array: [this.toolbar.btnRedo]}); + this.toolbar.lockToolbar(Common.enumLock.redoLock, !can, {array: [this.toolbar.btnRedo]}); this._state.can_redo = can; } } @@ -516,7 +516,7 @@ define([ onApiCanCopyCut: function(can) { if (this._state.can_copycut !== can) { - this.toolbar.lockToolbar(DE.enumLock.copyLock, !can, {array: [this.toolbar.btnCopy]}); + this.toolbar.lockToolbar(Common.enumLock.copyLock, !can, {array: [this.toolbar.btnCopy]}); this._state.can_copycut = can; } }, @@ -725,21 +725,21 @@ define([ plain_del_lock = (frame_pr) ? !frame_pr.can_DeleteInlineContentControl() : false, plain_edit_lock = (frame_pr) ? !frame_pr.can_EditInlineContentControl() : false; - this.toolbar.lockToolbar(DE.enumLock.cantAddQuotedComment, !this.api.can_AddQuotedComment(), {array: this.btnsComment}); - this.toolbar.lockToolbar(DE.enumLock.imageLock, image_locked, {array: this.btnsComment}); - this.mode.compatibleFeatures && this.toolbar.lockToolbar(DE.enumLock.inImage, in_image, {array: this.btnsComment}); + this.toolbar.lockToolbar(Common.enumLock.cantAddQuotedComment, !this.api.can_AddQuotedComment(), {array: this.btnsComment}); + this.toolbar.lockToolbar(Common.enumLock.imageLock, image_locked, {array: this.btnsComment}); + this.mode.compatibleFeatures && this.toolbar.lockToolbar(Common.enumLock.inImage, in_image, {array: this.btnsComment}); if (this.api.asc_IsContentControl()) { var control_props = this.api.asc_GetContentControlProperties(), spectype = control_props ? control_props.get_SpecificType() : Asc.c_oAscContentControlSpecificType.None; - this.toolbar.lockToolbar(DE.enumLock.inSpecificForm, spectype==Asc.c_oAscContentControlSpecificType.CheckBox || spectype==Asc.c_oAscContentControlSpecificType.Picture || + this.toolbar.lockToolbar(Common.enumLock.inSpecificForm, 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, {array: this.btnsComment}); } - this.toolbar.lockToolbar(DE.enumLock.paragraphLock, paragraph_locked, {array: this.btnsComment}); - this.toolbar.lockToolbar(DE.enumLock.headerLock, header_locked, {array: this.btnsComment}); - this.toolbar.lockToolbar(DE.enumLock.richEditLock, rich_edit_lock, {array: this.btnsComment}); - this.toolbar.lockToolbar(DE.enumLock.plainEditLock, plain_edit_lock, {array: this.btnsComment}); - this.toolbar.lockToolbar(DE.enumLock.richDelLock, rich_del_lock, {array: this.btnsComment}); - this.toolbar.lockToolbar(DE.enumLock.plainDelLock, plain_del_lock, {array: this.btnsComment}); + this.toolbar.lockToolbar(Common.enumLock.paragraphLock, paragraph_locked, {array: this.btnsComment}); + this.toolbar.lockToolbar(Common.enumLock.headerLock, header_locked, {array: this.btnsComment}); + this.toolbar.lockToolbar(Common.enumLock.richEditLock, rich_edit_lock, {array: this.btnsComment}); + this.toolbar.lockToolbar(Common.enumLock.plainEditLock, plain_edit_lock, {array: this.btnsComment}); + this.toolbar.lockToolbar(Common.enumLock.richDelLock, rich_del_lock, {array: this.btnsComment}); + this.toolbar.lockToolbar(Common.enumLock.plainDelLock, plain_del_lock, {array: this.btnsComment}); }, onApiFocusObject: function(selectedObjects) { @@ -810,20 +810,20 @@ define([ in_smart_art = shape_pr && shape_pr.asc_getFromSmartArt(), in_smart_art_internal = shape_pr && shape_pr.asc_getFromSmartArtInternal(); - this.toolbar.lockToolbar(DE.enumLock.paragraphLock, paragraph_locked, {array: this.toolbar.paragraphControls.concat([toolbar.btnContentControls, toolbar.btnClearStyle])}); - this.toolbar.lockToolbar(DE.enumLock.headerLock, header_locked, {array: this.toolbar.paragraphControls.concat([toolbar.btnContentControls, toolbar.btnClearStyle, toolbar.btnWatermark])}); - this.toolbar.lockToolbar(DE.enumLock.richEditLock, rich_edit_lock, {array: this.toolbar.paragraphControls.concat([toolbar.btnClearStyle])}); - this.toolbar.lockToolbar(DE.enumLock.plainEditLock, plain_edit_lock, {array: this.toolbar.paragraphControls.concat([toolbar.btnClearStyle])}); + this.toolbar.lockToolbar(Common.enumLock.paragraphLock, paragraph_locked, {array: this.toolbar.paragraphControls.concat([toolbar.btnContentControls, toolbar.btnClearStyle])}); + this.toolbar.lockToolbar(Common.enumLock.headerLock, header_locked, {array: this.toolbar.paragraphControls.concat([toolbar.btnContentControls, toolbar.btnClearStyle, toolbar.btnWatermark])}); + this.toolbar.lockToolbar(Common.enumLock.richEditLock, rich_edit_lock, {array: this.toolbar.paragraphControls.concat([toolbar.btnClearStyle])}); + this.toolbar.lockToolbar(Common.enumLock.plainEditLock, plain_edit_lock, {array: this.toolbar.paragraphControls.concat([toolbar.btnClearStyle])}); - this.toolbar.lockToolbar(DE.enumLock.richDelLock, rich_del_lock, {array: this.btnsComment.concat(toolbar.btnsPageBreak).concat([toolbar.btnInsertTable, toolbar.btnInsertImage, toolbar.btnInsertChart, toolbar.btnInsertTextArt, + this.toolbar.lockToolbar(Common.enumLock.richDelLock, rich_del_lock, {array: this.btnsComment.concat(toolbar.btnsPageBreak).concat([toolbar.btnInsertTable, toolbar.btnInsertImage, toolbar.btnInsertChart, toolbar.btnInsertTextArt, toolbar.btnInsDateTime, toolbar.btnBlankPage, toolbar.btnInsertEquation, toolbar.btnInsertSymbol ])}); - this.toolbar.lockToolbar(DE.enumLock.plainDelLock, plain_del_lock, {array: this.btnsComment.concat(toolbar.btnsPageBreak).concat([toolbar.btnInsertTable, toolbar.btnInsertImage, toolbar.btnInsertChart, toolbar.btnInsertTextArt, + this.toolbar.lockToolbar(Common.enumLock.plainDelLock, plain_del_lock, {array: this.btnsComment.concat(toolbar.btnsPageBreak).concat([toolbar.btnInsertTable, toolbar.btnInsertImage, toolbar.btnInsertChart, toolbar.btnInsertTextArt, toolbar.btnInsDateTime, toolbar.btnBlankPage, toolbar.btnInsertEquation, toolbar.btnInsertSymbol ])}); - this.toolbar.lockToolbar(DE.enumLock.inChart, in_chart, {array: toolbar.textOnlyControls.concat([toolbar.btnClearStyle, toolbar.btnInsertEquation])}); - this.toolbar.lockToolbar(DE.enumLock.inSmartart, in_smart_art, {array: toolbar.textOnlyControls.concat([toolbar.btnClearStyle])}); - this.toolbar.lockToolbar(DE.enumLock.inSmartartInternal, in_smart_art_internal, {array: toolbar.textOnlyControls.concat([toolbar.btnClearStyle, toolbar.btnDecLeftOffset, toolbar.btnIncLeftOffset])}); - this.toolbar.lockToolbar(DE.enumLock.inEquation, in_equation, {array: toolbar.btnsPageBreak.concat([toolbar.btnDropCap, toolbar.btnInsertTable, toolbar.btnBlankPage, toolbar.btnInsertShape, + this.toolbar.lockToolbar(Common.enumLock.inChart, in_chart, {array: toolbar.textOnlyControls.concat([toolbar.btnClearStyle, toolbar.btnInsertEquation])}); + this.toolbar.lockToolbar(Common.enumLock.inSmartart, in_smart_art, {array: toolbar.textOnlyControls.concat([toolbar.btnClearStyle])}); + this.toolbar.lockToolbar(Common.enumLock.inSmartartInternal, in_smart_art_internal, {array: toolbar.textOnlyControls.concat([toolbar.btnClearStyle, toolbar.btnDecLeftOffset, toolbar.btnIncLeftOffset])}); + this.toolbar.lockToolbar(Common.enumLock.inEquation, in_equation, {array: toolbar.btnsPageBreak.concat([toolbar.btnDropCap, toolbar.btnInsertTable, toolbar.btnBlankPage, toolbar.btnInsertShape, toolbar.btnInsertText, toolbar.btnInsertTextArt, toolbar.btnInsertImage, toolbar.btnSuperscript, toolbar.btnSubscript, toolbar.btnEditHeader])}); in_control = this.api.asc_IsContentControl(); @@ -842,7 +842,7 @@ define([ toolbar.btnContentControls.menu.items[10].setDisabled(!in_control || if_form); } - this.toolbar.lockToolbar(DE.enumLock.controlPlain, control_plain, {array: [toolbar.btnInsertTable, toolbar.btnInsertImage, toolbar.btnInsertChart, toolbar.btnInsertText, toolbar.btnInsertTextArt, + this.toolbar.lockToolbar(Common.enumLock.controlPlain, control_plain, {array: [toolbar.btnInsertTable, toolbar.btnInsertImage, toolbar.btnInsertChart, toolbar.btnInsertText, toolbar.btnInsertTextArt, toolbar.btnInsertShape, toolbar.btnInsertEquation, toolbar.btnDropCap, toolbar.btnColumns, toolbar.mnuInsertPageNum ]}); if (enable_dropcap && frame_pr) { var value = frame_pr.get_FramePr(), @@ -859,18 +859,18 @@ define([ if (enable_dropcap) this.onDropCap(drop_value); } - this.toolbar.lockToolbar(DE.enumLock.dropcapLock, !enable_dropcap, {array: [toolbar.btnDropCap]}); + this.toolbar.lockToolbar(Common.enumLock.dropcapLock, !enable_dropcap, {array: [toolbar.btnDropCap]}); if ( !toolbar.btnDropCap.isDisabled() ) toolbar.mnuDropCapAdvanced.setDisabled(disable_dropcapadv); - this.toolbar.lockToolbar(DE.enumLock.cantAddTable, !can_add_table, {array: [toolbar.btnInsertTable]}); - this.toolbar.lockToolbar(DE.enumLock.cantAddPageNum, toolbar.mnuPageNumCurrentPos.isDisabled() && toolbar.mnuPageNumberPosPicker.isDisabled(), {array: [toolbar.mnuInsertPageNum]}); - this.toolbar.lockToolbar(DE.enumLock.inHeader, in_header, {array: toolbar.btnsPageBreak.concat([toolbar.btnBlankPage])}); - this.toolbar.lockToolbar(DE.enumLock.inControl, in_control, {array: toolbar.btnsPageBreak.concat([toolbar.btnBlankPage])}); - this.toolbar.lockToolbar(DE.enumLock.cantPageBreak, in_image && !btn_eq_state, {array: toolbar.btnsPageBreak.concat([toolbar.btnBlankPage])}); - this.toolbar.lockToolbar(DE.enumLock.contentLock, content_locked, {array: [toolbar.btnInsertShape, toolbar.btnInsertText, toolbar.btnInsertImage, toolbar.btnInsertTextArt, toolbar.btnInsertChart ]}); - this.toolbar.lockToolbar(DE.enumLock.inFootnote, in_footnote, {array: toolbar.btnsPageBreak.concat([toolbar.btnBlankPage, toolbar.btnInsertShape, toolbar.btnInsertText, toolbar.btnInsertTextArt ])}); - this.toolbar.lockToolbar(DE.enumLock.cantAddImagePara, in_para && !can_add_image, {array: [toolbar.btnInsertImage, toolbar.btnInsertTextArt]}); + this.toolbar.lockToolbar(Common.enumLock.cantAddTable, !can_add_table, {array: [toolbar.btnInsertTable]}); + this.toolbar.lockToolbar(Common.enumLock.cantAddPageNum, toolbar.mnuPageNumCurrentPos.isDisabled() && toolbar.mnuPageNumberPosPicker.isDisabled(), {array: [toolbar.mnuInsertPageNum]}); + this.toolbar.lockToolbar(Common.enumLock.inHeader, in_header, {array: toolbar.btnsPageBreak.concat([toolbar.btnBlankPage])}); + this.toolbar.lockToolbar(Common.enumLock.inControl, in_control, {array: toolbar.btnsPageBreak.concat([toolbar.btnBlankPage])}); + this.toolbar.lockToolbar(Common.enumLock.cantPageBreak, in_image && !btn_eq_state, {array: toolbar.btnsPageBreak.concat([toolbar.btnBlankPage])}); + this.toolbar.lockToolbar(Common.enumLock.contentLock, content_locked, {array: [toolbar.btnInsertShape, toolbar.btnInsertText, toolbar.btnInsertImage, toolbar.btnInsertTextArt, toolbar.btnInsertChart ]}); + this.toolbar.lockToolbar(Common.enumLock.inFootnote, in_footnote, {array: toolbar.btnsPageBreak.concat([toolbar.btnBlankPage, toolbar.btnInsertShape, toolbar.btnInsertText, toolbar.btnInsertTextArt ])}); + this.toolbar.lockToolbar(Common.enumLock.cantAddImagePara, in_para && !can_add_image, {array: [toolbar.btnInsertImage, toolbar.btnInsertTextArt]}); if (in_chart !== this._state.in_chart) { toolbar.btnInsertChart.updateHint(in_chart ? toolbar.tipChangeChart : toolbar.tipInsertChart); @@ -878,24 +878,24 @@ define([ } var need_disable = paragraph_locked || header_locked || in_equation || control_plain || rich_del_lock || plain_del_lock || content_locked || in_para && !can_add_image; need_disable = !in_chart && need_disable; - this.toolbar.lockToolbar(DE.enumLock.cantAddChart, need_disable, {array: [toolbar.btnInsertChart]}); - this.toolbar.lockToolbar(DE.enumLock.chartLock, in_chart && image_locked, {array: [toolbar.btnInsertChart]}); + this.toolbar.lockToolbar(Common.enumLock.cantAddChart, need_disable, {array: [toolbar.btnInsertChart]}); + this.toolbar.lockToolbar(Common.enumLock.chartLock, in_chart && image_locked, {array: [toolbar.btnInsertChart]}); - this.toolbar.lockToolbar(DE.enumLock.cantAddEquation, !can_add_image&&!in_equation, {array: [toolbar.btnInsertEquation]}); - this.toolbar.lockToolbar(DE.enumLock.noParagraphSelected, !in_para, {array: [toolbar.btnInsertSymbol, toolbar.btnInsDateTime]}); - this.toolbar.lockToolbar(DE.enumLock.inImage, in_image, {array: [toolbar.btnColumns]}); - this.toolbar.lockToolbar(DE.enumLock.inImagePara, in_image && in_para, {array: [toolbar.btnLineNumbers]}); + this.toolbar.lockToolbar(Common.enumLock.cantAddEquation, !can_add_image&&!in_equation, {array: [toolbar.btnInsertEquation]}); + this.toolbar.lockToolbar(Common.enumLock.noParagraphSelected, !in_para, {array: [toolbar.btnInsertSymbol, toolbar.btnInsDateTime]}); + this.toolbar.lockToolbar(Common.enumLock.inImage, in_image, {array: [toolbar.btnColumns]}); + this.toolbar.lockToolbar(Common.enumLock.inImagePara, in_image && in_para, {array: [toolbar.btnLineNumbers]}); if (toolbar.listStylesAdditionalMenuItem && (frame_pr===undefined) !== toolbar.listStylesAdditionalMenuItem.isDisabled()) toolbar.listStylesAdditionalMenuItem.setDisabled(frame_pr===undefined); // comments - this.toolbar.lockToolbar(DE.enumLock.cantAddQuotedComment, !this.api.can_AddQuotedComment(), {array: this.btnsComment}); - this.toolbar.lockToolbar(DE.enumLock.imageLock, image_locked, {array: this.btnsComment}); - this.mode.compatibleFeatures && this.toolbar.lockToolbar(DE.enumLock.inImage, in_image, {array: this.btnsComment}); + this.toolbar.lockToolbar(Common.enumLock.cantAddQuotedComment, !this.api.can_AddQuotedComment(), {array: this.btnsComment}); + this.toolbar.lockToolbar(Common.enumLock.imageLock, image_locked, {array: this.btnsComment}); + this.mode.compatibleFeatures && this.toolbar.lockToolbar(Common.enumLock.inImage, in_image, {array: this.btnsComment}); if (control_props) { var spectype = control_props.get_SpecificType(); - this.toolbar.lockToolbar(DE.enumLock.inSpecificForm, spectype==Asc.c_oAscContentControlSpecificType.CheckBox || spectype==Asc.c_oAscContentControlSpecificType.Picture || + this.toolbar.lockToolbar(Common.enumLock.inSpecificForm, 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, {array: this.btnsComment}); } @@ -944,34 +944,34 @@ define([ onApiLockDocumentProps: function() { if (this._state.lock_doc!==true) { - this.toolbar.lockToolbar(DE.enumLock.docPropsLock, true, {array: [this.toolbar.btnPageOrient, this.toolbar.btnPageSize, this.toolbar.btnPageMargins, this.toolbar.btnColumns, this.toolbar.btnLineNumbers]}); + this.toolbar.lockToolbar(Common.enumLock.docPropsLock, true, {array: [this.toolbar.btnPageOrient, this.toolbar.btnPageSize, this.toolbar.btnPageMargins, this.toolbar.btnColumns, this.toolbar.btnLineNumbers]}); if (this._state.activated) this._state.lock_doc = true; } }, onApiUnLockDocumentProps: function() { if (this._state.lock_doc!==false) { - this.toolbar.lockToolbar(DE.enumLock.docPropsLock, false, {array: [this.toolbar.btnPageOrient, this.toolbar.btnPageSize, this.toolbar.btnPageMargins, this.toolbar.btnColumns, this.toolbar.btnLineNumbers]}); + this.toolbar.lockToolbar(Common.enumLock.docPropsLock, false, {array: [this.toolbar.btnPageOrient, this.toolbar.btnPageSize, this.toolbar.btnPageMargins, this.toolbar.btnColumns, this.toolbar.btnLineNumbers]}); if (this._state.activated) this._state.lock_doc = false; } }, onApiLockDocumentSchema: function() { - this.toolbar.lockToolbar(DE.enumLock.docSchemaLock, true, {array: [this.toolbar.btnColorSchemas]}); + this.toolbar.lockToolbar(Common.enumLock.docSchemaLock, true, {array: [this.toolbar.btnColorSchemas]}); }, onApiUnLockDocumentSchema: function() { - this.toolbar.lockToolbar(DE.enumLock.docSchemaLock, false, {array: [this.toolbar.btnColorSchemas]}); + this.toolbar.lockToolbar(Common.enumLock.docSchemaLock, false, {array: [this.toolbar.btnColorSchemas]}); }, onApiLockHeaderFooters: function() { - this.toolbar.lockToolbar(DE.enumLock.headerFooterLock, true, {array: [this.toolbar.mnuPageNumberPosPicker]}); - this.toolbar.lockToolbar(DE.enumLock.cantAddPageNum, this.toolbar.mnuPageNumCurrentPos.isDisabled(), {array: [this.toolbar.mnuInsertPageNum]}); + this.toolbar.lockToolbar(Common.enumLock.headerFooterLock, true, {array: [this.toolbar.mnuPageNumberPosPicker]}); + this.toolbar.lockToolbar(Common.enumLock.cantAddPageNum, this.toolbar.mnuPageNumCurrentPos.isDisabled(), {array: [this.toolbar.mnuInsertPageNum]}); }, onApiUnLockHeaderFooters: function() { - this.toolbar.lockToolbar(DE.enumLock.headerFooterLock, false, {array: [this.toolbar.mnuPageNumberPosPicker]}); - this.toolbar.lockToolbar(DE.enumLock.cantAddPageNum, false, {array: [this.toolbar.mnuInsertPageNum]}); + this.toolbar.lockToolbar(Common.enumLock.headerFooterLock, false, {array: [this.toolbar.mnuPageNumberPosPicker]}); + this.toolbar.lockToolbar(Common.enumLock.cantAddPageNum, false, {array: [this.toolbar.mnuInsertPageNum]}); }, onApiZoomChange: function(percent, type) {}, @@ -2870,11 +2870,11 @@ define([ }, activateControls: function() { - this.toolbar.lockToolbar(DE.enumLock.disableOnStart, false); - this.toolbar.lockToolbar(DE.enumLock.undoLock, this._state.can_undo!==true, {array: [this.toolbar.btnUndo]}); - this.toolbar.lockToolbar(DE.enumLock.redoLock, this._state.can_redo!==true, {array: [this.toolbar.btnRedo]}); - this.toolbar.lockToolbar(DE.enumLock.copyLock, this._state.can_copycut!==true, {array: [this.toolbar.btnCopy]}); - this.toolbar.lockToolbar(DE.enumLock.mmergeLock, !!this._state.mmdisable, {array: [this.toolbar.btnMailRecepients]}); + this.toolbar.lockToolbar(Common.enumLock.disableOnStart, false); + this.toolbar.lockToolbar(Common.enumLock.undoLock, this._state.can_undo!==true, {array: [this.toolbar.btnUndo]}); + this.toolbar.lockToolbar(Common.enumLock.redoLock, this._state.can_redo!==true, {array: [this.toolbar.btnRedo]}); + this.toolbar.lockToolbar(Common.enumLock.copyLock, this._state.can_copycut!==true, {array: [this.toolbar.btnCopy]}); + this.toolbar.lockToolbar(Common.enumLock.mmergeLock, !!this._state.mmdisable, {array: [this.toolbar.btnMailRecepients]}); if (!this._state.mmdisable) { this.toolbar.mnuMailRecepients.items[2].setVisible(this.toolbar.mode.fileChoiceUrl || this.toolbar.mode.canRequestMailMergeRecipients); } @@ -2886,7 +2886,7 @@ define([ DisableMailMerge: function() { this._state.mmdisable = true; - this.toolbar && this.toolbar.btnMailRecepients && this.toolbar.lockToolbar(DE.enumLock.mmergeLock, true, {array: [this.toolbar.btnMailRecepients]}); + this.toolbar && this.toolbar.btnMailRecepients && this.toolbar.lockToolbar(Common.enumLock.mmergeLock, true, {array: [this.toolbar.btnMailRecepients]}); }, updateThemeColors: function() { @@ -3228,8 +3228,8 @@ define([ if ( config.canCoAuthoring && config.canComments ) { this.btnsComment = Common.Utils.injectButtons(this.toolbar.$el.find('.slot-comment'), 'tlbtn-addcomment-', 'toolbar__icon btn-menu-comments', this.toolbar.capBtnComment, - [ DE.enumLock.paragraphLock, DE.enumLock.headerLock, DE.enumLock.richEditLock, DE.enumLock.plainEditLock, DE.enumLock.richDelLock, DE.enumLock.plainDelLock, - DE.enumLock.cantAddQuotedComment, DE.enumLock.imageLock, DE.enumLock.inSpecificForm, DE.enumLock.inImage, DE.enumLock.lostConnect, DE.enumLock.disableOnStart], + [ Common.enumLock.paragraphLock, Common.enumLock.headerLock, Common.enumLock.richEditLock, Common.enumLock.plainEditLock, Common.enumLock.richDelLock, Common.enumLock.plainDelLock, + Common.enumLock.cantAddQuotedComment, Common.enumLock.imageLock, Common.enumLock.inSpecificForm, Common.enumLock.inImage, Common.enumLock.lostConnect, Common.enumLock.disableOnStart], undefined, undefined, undefined, '1', 'bottom'); if ( this.btnsComment.length ) { var _comments = DE.getController('Common.Controllers.Comments').getView(); diff --git a/apps/documenteditor/main/app/controller/ViewTab.js b/apps/documenteditor/main/app/controller/ViewTab.js index 8a9983b0b..8d25e2d32 100644 --- a/apps/documenteditor/main/app/controller/ViewTab.js +++ b/apps/documenteditor/main/app/controller/ViewTab.js @@ -151,12 +151,12 @@ define([ me.view.btnInterfaceTheme.menu.on('item:click', _.bind(function (menu, item) { var value = item.value; Common.UI.Themes.setTheme(value); - Common.Utils.lockControls(DE.enumLock.inLightTheme, !Common.UI.Themes.isDarkTheme(), {array: [me.view.btnDarkDocument]}); + Common.Utils.lockControls(Common.enumLock.inLightTheme, !Common.UI.Themes.isDarkTheme(), {array: [me.view.btnDarkDocument]}); }, me)); setTimeout(function () { me.onContentThemeChangedToDark(Common.UI.Themes.isContentThemeDark()); - Common.Utils.lockControls(DE.enumLock.inLightTheme, !Common.UI.Themes.isDarkTheme(), {array: [me.view.btnDarkDocument]}); + Common.Utils.lockControls(Common.enumLock.inLightTheme, !Common.UI.Themes.isDarkTheme(), {array: [me.view.btnDarkDocument]}); }, 0); } }); @@ -238,7 +238,7 @@ define([ menu_item = _.findWhere(this.view.btnInterfaceTheme.menu.items, {value: current_theme}); this.view.btnInterfaceTheme.menu.clearAll(); menu_item.setChecked(true, true); - Common.Utils.lockControls(DE.enumLock.inLightTheme, !Common.UI.Themes.isDarkTheme(), {array: [this.view.btnDarkDocument]}); + Common.Utils.lockControls(Common.enumLock.inLightTheme, !Common.UI.Themes.isDarkTheme(), {array: [this.view.btnDarkDocument]}); } }, diff --git a/apps/documenteditor/main/app/view/FormsTab.js b/apps/documenteditor/main/app/view/FormsTab.js index 808a60a04..2b6c2caee 100644 --- a/apps/documenteditor/main/app/view/FormsTab.js +++ b/apps/documenteditor/main/app/view/FormsTab.js @@ -142,7 +142,7 @@ define([ this.paragraphControls = []; var me = this; - var _set = DE.enumLock; + var _set = Common.enumLock; if (this.appConfig.isRestrictedEdit && this.appConfig.canFillForms) { this.btnClear = new Common.UI.Button({ @@ -316,7 +316,7 @@ define([ }); this.paragraphControls.push(this.btnSaveForm); } - Common.Utils.lockControls(DE.enumLock.disableOnStart, true, {array: this.paragraphControls}); + Common.Utils.lockControls(Common.enumLock.disableOnStart, true, {array: this.paragraphControls}); this._state = {disabled: false}; Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this)); }, diff --git a/apps/documenteditor/main/app/view/Links.js b/apps/documenteditor/main/app/view/Links.js index 3be0f84ae..ac450c254 100644 --- a/apps/documenteditor/main/app/view/Links.js +++ b/apps/documenteditor/main/app/view/Links.js @@ -157,7 +157,7 @@ define([ this.btnsPrevEndNote = []; this.btnsNextEndNote = []; this.paragraphControls = []; - var _set = DE.enumLock; + var _set = Common.enumLock; var me = this, $host = me.toolbar.$el; @@ -245,7 +245,7 @@ define([ dataHintOffset: 'medium' }); this.paragraphControls.push(this.btnTableFiguresUpdate); - Common.Utils.lockControls(DE.enumLock.disableOnStart, true, {array: this.paragraphControls}); + Common.Utils.lockControls(Common.enumLock.disableOnStart, true, {array: this.paragraphControls}); this._state = {disabled: false}; Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this)); }, diff --git a/apps/documenteditor/main/app/view/Toolbar.js b/apps/documenteditor/main/app/view/Toolbar.js index d8ee96964..a6dd971e2 100644 --- a/apps/documenteditor/main/app/view/Toolbar.js +++ b/apps/documenteditor/main/app/view/Toolbar.js @@ -39,6 +39,8 @@ * Copyright (c) 2018 Ascensio System SIA. All rights reserved. * */ +if (Common === undefined) + var Common = {}; define([ 'jquery', @@ -62,7 +64,10 @@ define([ ], function ($, _, Backbone, template, template_view) { 'use strict'; - DE.enumLock = { + if (!Common.enumLock) + Common.enumLock = {}; + + var enumLock = { undoLock: 'can-undo', redoLock: 'can-redo', copyLock: 'can-copy', @@ -111,6 +116,11 @@ define([ lostConnect: 'disconnect', disableOnStart: 'on-start' }; + for (var key in enumLock) { + if (enumLock.hasOwnProperty(key)) { + Common.enumLock[key] = enumLock[key]; + } + } DE.Views.Toolbar = Common.UI.Mixtbar.extend(_.extend((function(){ @@ -155,7 +165,7 @@ define([ applyLayout: function (config) { var me = this; me.lockControls = []; - var _set = DE.enumLock; + var _set = Common.enumLock; if ( config.isEdit ) { Common.UI.Mixtbar.prototype.initialize.call(this, { template: _.template(template), @@ -1489,7 +1499,7 @@ define([ // Disable all components before load document this.lockControls = me.toolbarControls.concat(me.paragraphControls); - this.lockToolbar(DE.enumLock.disableOnStart, true, {array: this.lockControls}); + this.lockToolbar(Common.enumLock.disableOnStart, true, {array: this.lockControls}); var editStyleMenuUpdate = new Common.UI.MenuItem({ caption: me.textStyleMenuUpdate @@ -1676,8 +1686,8 @@ define([ _injectComponent('#slot-btn-watermark', this.btnWatermark); this.btnsPageBreak = Common.Utils.injectButtons($host.find('.btn-slot.btn-pagebreak'), '', 'toolbar__icon btn-pagebreak', this.capBtnInsPagebreak, - [DE.enumLock.paragraphLock, DE.enumLock.headerLock, DE.enumLock.richEditLock, DE.enumLock.plainEditLock, DE.enumLock.inEquation, DE.enumLock.richDelLock, DE.enumLock.plainDelLock, - DE.enumLock.inHeader, DE.enumLock.inFootnote, DE.enumLock.inControl, DE.enumLock.cantPageBreak, DE.enumLock.lostConnect, DE.enumLock.disableOnStart], + [Common.enumLock.paragraphLock, Common.enumLock.headerLock, Common.enumLock.richEditLock, Common.enumLock.plainEditLock, Common.enumLock.inEquation, Common.enumLock.richDelLock, Common.enumLock.plainDelLock, + Common.enumLock.inHeader, Common.enumLock.inFootnote, Common.enumLock.inControl, Common.enumLock.cantPageBreak, Common.enumLock.previewReviewMode, Common.enumLock.lostConnect, Common.enumLock.disableOnStart], true, true, undefined, '1', 'bottom', 'small'); Array.prototype.push.apply(this.paragraphControls, this.btnsPageBreak); Array.prototype.push.apply(this.lockControls, this.btnsPageBreak); @@ -2372,13 +2382,13 @@ define([ setMode: function (mode) { if (mode.isDisconnected) { - this.lockToolbar(DE.enumLock.lostConnect, true); + this.lockToolbar(Common.enumLock.lostConnect, true); if ( this.synchTooltip ) this.synchTooltip.hide(); if (!mode.enableDownload) - this.lockToolbar(DE.enumLock.cantPrint, true, {array: [this.btnPrint]}); + this.lockToolbar(Common.enumLock.cantPrint, true, {array: [this.btnPrint]}); } else - this.lockToolbar(DE.enumLock.cantPrint, !mode.canPrint, {array: [this.btnPrint]}); + this.lockToolbar(Common.enumLock.cantPrint, !mode.canPrint, {array: [this.btnPrint]}); this.mode = mode; diff --git a/apps/documenteditor/main/app/view/ViewTab.js b/apps/documenteditor/main/app/view/ViewTab.js index 18bb46fe9..214c12aea 100644 --- a/apps/documenteditor/main/app/view/ViewTab.js +++ b/apps/documenteditor/main/app/view/ViewTab.js @@ -85,7 +85,7 @@ define([ var me = this, $host = me.toolbar.$el; - var _set = DE.enumLock; + var _set = Common.enumLock; this.btnNavigation = new Common.UI.Button({ parentEl: $host.find('#slot-btn-navigation'),